Preserve CommonJS literal paths and confined ESM URL semantics, including package main fallback, directory intent, Unicode identity, and present opaque modules. Parse extraction inputs at their AST/source owner, retain skipped HTML and source-map coverage, and distinguish endpoint candidates from proven receiver facts. Version structural fingerprints with computed literal contents and propagate them through worker contracts. Reviewed fixes include #1810, #1840, #2642, #2700, #2702, #2714, #2803, #2960, #2968, #2986, #3035, and #3036. Validation: 158 resolver tests passed; public CLI/MCP module lookup controls, package-main/Unicode workflows, and six builtin workflows passed in the current compiled lane. Worker schema/fingerprint regressions passed. Large public pdf.js completion and real Electron analysis remain unverified.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { analyzeJavaScriptStaticSource } from "../../domain/javascript/javascriptStaticAnalysis.js";
|
|
import { javaScriptWorkerStaticAnalysisSchema } from "./JavaScriptAnalysisWorkerSchemas.js";
|
|
|
|
it("versions fingerprints through the worker schema and rejects v1", () => {
|
|
const facts =
|
|
analyzeJavaScriptStaticSource(`globalThis.webpackChunkApp.push([[1], {
|
|
17(module, exports) { const key = selectKey(); exports.read = value[key]; }
|
|
}]);`);
|
|
expect(facts.bundler_registrations[0]?.modules[0]).toMatchObject({
|
|
structural_fingerprint_algorithm: "babel-ast-v2",
|
|
structural_fingerprint_sha256: expect.stringMatching(/^[a-f0-9]{64}$/u),
|
|
});
|
|
expect(
|
|
javaScriptWorkerStaticAnalysisSchema.safeParse(
|
|
JSON.parse(JSON.stringify(facts)) as unknown,
|
|
).success,
|
|
).toBe(true);
|
|
const old = {
|
|
...facts,
|
|
bundler_registrations: facts.bundler_registrations.map((registration) => ({
|
|
...registration,
|
|
modules: registration.modules.map((module) => ({
|
|
...module,
|
|
structural_fingerprint_algorithm: "babel-ast-v1",
|
|
})),
|
|
})),
|
|
};
|
|
expect(javaScriptWorkerStaticAnalysisSchema.safeParse(old).success).toBe(
|
|
false,
|
|
);
|
|
});
|