@shapeshift-labs/frontier-lang-compiler 0.2.150 → 0.2.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -9
- package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
- package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
- package/bench/real-repo-corpus-command-execution.mjs +314 -0
- package/bench/real-repo-corpus-evidence.mjs +165 -0
- package/bench/real-repo-corpus-suite.mjs +273 -0
- package/bench/smoke.mjs +109 -7
- package/dist/declarations/import-adapter-core.d.ts +4 -3
- package/dist/declarations/import-adapter-options-native.d.ts +21 -0
- package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
- package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
- package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
- package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
- package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
- package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
- package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
- package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
- package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
- package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
- package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
- package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
- package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
- package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
- package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
- package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
- package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
- package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
- package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
- package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
- package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
- package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
- package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
- package/dist/declarations/native-project-css-modules.d.ts +90 -0
- package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
- package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
- package/dist/declarations/native-project-module-declarations.d.ts +52 -0
- package/dist/declarations/native-project-module-resolution.d.ts +76 -1
- package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
- package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
- package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
- package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
- package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
- package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
- package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
- package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
- package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
- package/dist/declarations/native-project-source-evidence.d.ts +8 -0
- package/dist/declarations/native-project.d.ts +40 -39
- package/dist/declarations/semantic-edit-script.d.ts +10 -8
- package/dist/declarations/semantic-graph-layers.d.ts +79 -0
- package/dist/declarations/semantic-sidecar.d.ts +3 -2
- package/dist/declarations/semantic-structural-diff.d.ts +94 -0
- package/dist/declarations/source-preservation.d.ts +32 -1
- package/dist/declarations/target-adapters.d.ts +22 -2
- package/dist/index.d.ts +31 -0
- package/dist/index.js +5 -0
- package/dist/internal/index-impl/compileNativeSource.js +53 -5
- package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
- package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
- package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
- package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
- package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
- package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
- package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
- package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
- package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
- package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
- package/dist/internal/index-impl/importNativeSource.js +2 -3
- package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
- package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
- package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
- package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
- package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
- package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
- package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
- package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
- package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
- package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
- package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
- package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
- package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
- package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
- package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
- package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
- package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
- package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
- package/dist/internal/index-impl/semanticEditScripts.js +42 -5
- package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
- package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
- package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
- package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
- package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
- package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
- package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
- package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
- package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
- package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
- package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
- package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
- package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
- package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
- package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
- package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
- package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
- package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
- package/dist/js-ts-safe-member-class-invariants.js +247 -0
- package/dist/js-ts-safe-member-merge-result.js +23 -3
- package/dist/js-ts-safe-member-merge.js +28 -4
- package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +151 -157
- package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
- package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
- package/dist/js-ts-safe-merge-parse-statements.js +8 -0
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +13 -5
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -1
- package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
- package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
- package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
- package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
- package/dist/js-ts-safe-merge.js +136 -0
- package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
- package/dist/js-ts-safe-project-merge-admission.js +161 -0
- package/dist/js-ts-safe-project-merge-ambient.js +110 -0
- package/dist/js-ts-safe-project-merge-core.js +85 -0
- package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
- package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
- package/dist/js-ts-safe-project-merge-declarations.js +227 -0
- package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
- package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
- package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
- package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
- package/dist/js-ts-safe-project-merge-files.js +70 -0
- package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
- package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
- package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
- package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
- package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
- package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
- package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
- package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
- package/dist/js-ts-safe-project-merge-graph.js +37 -5
- package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
- package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
- package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
- package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
- package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
- package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
- package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
- package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
- package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
- package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
- package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
- package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
- package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
- package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
- package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
- package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
- package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
- package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
- package/dist/js-ts-safe-project-merge-summary.js +320 -0
- package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
- package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
- package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
- package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
- package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
- package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
- package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
- package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
- package/dist/js-ts-safe-project-merge.js +170 -171
- package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
- package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
- package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
- package/dist/js-ts-semantic-scope-use-def.js +217 -0
- package/dist/lightweight-dependency-effects.js +28 -4
- package/dist/lightweight-dependency-relations.js +13 -7
- package/dist/lightweight-dependency-top-level.js +63 -0
- package/dist/native-import-language-profiles.js +27 -1
- package/dist/native-js-ts-importers.js +9 -5
- package/dist/native-parser-ast-format-profiles.js +12 -0
- package/dist/native-parser-html-css-format-profiles.js +85 -0
- package/dist/native-region-scanner-core.js +5 -3
- package/dist/native-region-scanner-js-commonjs.js +155 -0
- package/dist/native-region-scanner-js-imports.js +51 -13
- package/dist/native-region-scanner-js-reexports.js +79 -0
- package/dist/native-region-scanner-js-ts-helpers.js +23 -0
- package/dist/native-source-ledger-helpers.js +1 -1
- package/dist/native-source-ledger.js +24 -10
- package/dist/native-source-maps-ecma426.js +316 -0
- package/dist/native-source-maps.js +36 -6
- package/dist/native-source-preservation-ownership.js +292 -0
- package/dist/native-source-preservation-scanner.js +63 -25
- package/dist/native-source-preservation-types.d.ts +3 -0
- package/dist/semantic-import-effect-occurrences.js +242 -0
- package/dist/semantic-import-effect-regions.js +95 -58
- package/dist/semantic-import-graph-layers.js +224 -0
- package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
- package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
- package/dist/semantic-import-runtime-exit-evidence.js +32 -0
- package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
- package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
- package/dist/semantic-import-runtime-order-evidence.js +318 -0
- package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
- package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
- package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
- package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
- package/dist/semantic-import-runtime-switch-evidence.js +304 -0
- package/dist/semantic-import-runtime-throw-evidence.js +44 -0
- package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
- package/dist/semantic-import-sidecar-entry.js +4 -0
- package/dist/semantic-import-source-preservation.js +6 -2
- package/package.json +1 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { uniqueStrings } from '../../native-import-utils.js';
|
|
2
|
+
import { nativeImportSourceText } from './nativeImportSourceText.js';
|
|
3
|
+
import { sourceTextForSpan } from './sourceTextForSpan.js';
|
|
4
|
+
|
|
5
|
+
export function typeSyntaxEditClassification(input) {
|
|
6
|
+
const reasonCodes = typeSyntaxEditReasonCodes(input);
|
|
7
|
+
if (!reasonCodes.length) return undefined;
|
|
8
|
+
const evidenceIds = typeSyntaxEvidenceIds(input);
|
|
9
|
+
if (evidenceIds.length) {
|
|
10
|
+
return {
|
|
11
|
+
status: 'portable',
|
|
12
|
+
reasonCodes: uniqueStrings([...reasonCodes, 'type-syntax-edit-backed-by-typechecker-or-declaration-evidence']),
|
|
13
|
+
evidenceIds
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
status: 'blocked',
|
|
18
|
+
reasonCodes: uniqueStrings([...reasonCodes, 'type-syntax-edit-requires-typechecker-or-declaration-evidence']),
|
|
19
|
+
evidenceIds: []
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function typeSyntaxEditReasonCodes(input) {
|
|
24
|
+
if (!isJsTsLanguage(input) || input.region?.regionKind === 'import') return [];
|
|
25
|
+
if (!['modified', 'removed', 'added'].includes(input.region?.changeKind)) return [];
|
|
26
|
+
const baseText = typeSyntaxSourceText(input.context.base, input.baseSymbol, input.region, 'before');
|
|
27
|
+
const workerText = typeSyntaxSourceText(input.context.worker, input.workerSymbol, input.region, 'after');
|
|
28
|
+
if (typeof baseText !== 'string' || typeof workerText !== 'string' || baseText === workerText) return [];
|
|
29
|
+
const allowAngleAssertion = !isJsxLikeLanguage(input);
|
|
30
|
+
const base = typeSyntaxSignals(baseText, allowAngleAssertion);
|
|
31
|
+
const worker = typeSyntaxSignals(workerText, allowAngleAssertion);
|
|
32
|
+
const reasons = [];
|
|
33
|
+
if (base.satisfies || worker.satisfies) reasons.push('satisfies-expression-edit-requires-typechecker-evidence');
|
|
34
|
+
if (base.asConst || worker.asConst) reasons.push('as-const-assertion-edit-requires-declaration-evidence');
|
|
35
|
+
if (base.typeAssertion || worker.typeAssertion) reasons.push('type-assertion-edit-requires-typechecker-evidence');
|
|
36
|
+
if (base.constTypeParameters !== worker.constTypeParameters) reasons.push('const-type-parameter-edit-requires-declaration-evidence');
|
|
37
|
+
if (base.constraints !== worker.constraints) reasons.push('generic-constraint-edit-requires-typechecker-evidence');
|
|
38
|
+
if (base.generics !== worker.generics) reasons.push('generic-type-parameter-edit-requires-typechecker-evidence');
|
|
39
|
+
if (base.conditionalTypes !== worker.conditionalTypes) reasons.push('conditional-type-edit-requires-declaration-evidence');
|
|
40
|
+
return uniqueStrings(reasons);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function typeSyntaxSignals(text, allowAngleAssertion) {
|
|
44
|
+
const normalized = String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
45
|
+
const genericClauses = typeParameterClauses(normalized);
|
|
46
|
+
return {
|
|
47
|
+
satisfies: /\bsatisfies\b/.test(normalized),
|
|
48
|
+
asConst: /\bas\s+const\b/.test(normalized),
|
|
49
|
+
typeAssertion: hasTypeAssertionSyntax(normalized, allowAngleAssertion),
|
|
50
|
+
generics: genericClauses.join('|'),
|
|
51
|
+
constraints: genericClauses.filter((clause) => /\bextends\b/.test(clause)).join('|'),
|
|
52
|
+
constTypeParameters: genericClauses.filter((clause) => /<[^>]*\bconst\s+[A-Za-z_$]/.test(clause)).join('|'),
|
|
53
|
+
conditionalTypes: conditionalTypeClauses(normalized).join('|')
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function typeSyntaxSourceText(imported, symbol, region, projectionSide) {
|
|
58
|
+
const sourceText = nativeImportSourceText(imported);
|
|
59
|
+
const projection = region?.metadata?.changedRegionProjection;
|
|
60
|
+
const span = symbol?.sourceSpan ?? projection?.[projectionSide]?.sourceSpan ?? region?.sourceSpan;
|
|
61
|
+
const exact = sourceTextForSpan(sourceText, span);
|
|
62
|
+
const lineText = sourceLineTextForSpan(sourceText, span);
|
|
63
|
+
return typeof lineText === 'string' && hasTypeSyntaxCue(lineText) ? lineText : exact;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function hasTypeSyntaxCue(text) {
|
|
67
|
+
return /\b(?:satisfies|extends|infer|as\s+const|as\s+(?:unknown|any|never|string|number|boolean|symbol|bigint))\b|<\s*const\s+[A-Za-z_$]|\btype\s+[A-Za-z_$][\w$]*(?:\s*<[^>\n]+>)?\s*=/.test(String(text ?? ''));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function sourceLineTextForSpan(sourceText, span) {
|
|
71
|
+
if (typeof sourceText !== 'string' || typeof span?.startLine !== 'number') return undefined;
|
|
72
|
+
const lines = sourceText.split('\n');
|
|
73
|
+
const startLine = Math.max(1, span.startLine);
|
|
74
|
+
const endLine = Math.max(startLine, typeof span.endLine === 'number' ? span.endLine : startLine);
|
|
75
|
+
return lines.slice(startLine - 1, endLine).join('\n');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function typeParameterClauses(text) {
|
|
79
|
+
const clauses = [];
|
|
80
|
+
const pattern = /\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?(?:function|class|interface|type)\s+[A-Za-z_$][\w$]*\s*(<[^>\n]+>)/g;
|
|
81
|
+
for (const match of text.matchAll(pattern)) clauses.push(match[1].replace(/\s+/g, ' '));
|
|
82
|
+
return clauses;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function conditionalTypeClauses(text) {
|
|
86
|
+
const clauses = [];
|
|
87
|
+
const pattern = /\btype\s+[A-Za-z_$][\w$]*(?:\s*<[^>\n]+>)?\s*=\s*([^;\n]*\bextends\b[^;\n]*\?[^;\n]*:[^;\n]*)/g;
|
|
88
|
+
for (const match of text.matchAll(pattern)) clauses.push(match[1].replace(/\s+/g, ' '));
|
|
89
|
+
return clauses;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function hasTypeAssertionSyntax(text, allowAngleAssertion) {
|
|
93
|
+
if (/\bas\s+const\b/.test(text)) return true;
|
|
94
|
+
const asAssertion = /\bas\s+(?:unknown|any|never|string|number|boolean|symbol|bigint|readonly|[A-Z_$][\w$]*|\{|\[)/;
|
|
95
|
+
const angleAssertion = /(?:\b(?:return|throw)\b|[=([,])\s*<\s*[A-Za-z_$][^>\n]*>\s*(?:[A-Za-z_$"'[(])/;
|
|
96
|
+
return asAssertion.test(text) || (allowAngleAssertion && angleAssertion.test(text));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function typeSyntaxEvidenceIds(input) {
|
|
100
|
+
return uniqueStrings(typeSyntaxEvidenceRecords(input)
|
|
101
|
+
.filter(typeSyntaxEvidencePassed).map((record) => String(record.id ?? record.evidenceId ?? record.hash ?? record.kind)));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function typeSyntaxEvidenceRecords(input) {
|
|
105
|
+
return [
|
|
106
|
+
input.scriptInput?.typeSyntaxEvidence,
|
|
107
|
+
input.scriptInput?.typeCheckerEvidence,
|
|
108
|
+
input.scriptInput?.typescriptEvidence,
|
|
109
|
+
input.scriptInput?.diagnosticsEvidence,
|
|
110
|
+
input.scriptInput?.declarationEvidence,
|
|
111
|
+
input.scriptInput?.evidence,
|
|
112
|
+
input.context?.typeSyntaxEvidence
|
|
113
|
+
].flatMap((entry) => Array.isArray(entry) ? entry : [entry]).filter((entry) => entry && typeof entry === 'object');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function typeSyntaxEvidencePassed(record) {
|
|
117
|
+
const status = String(record.status ?? record.result ?? '').toLowerCase();
|
|
118
|
+
if (status && !['passed', 'pass', 'ok', 'clean', 'accepted-clean'].includes(status)) return false;
|
|
119
|
+
const text = [
|
|
120
|
+
record.kind, record.type, record.source, record.gateId, record.summary, record.metadata?.kind,
|
|
121
|
+
record.metadata?.source, record.metadata?.diagnosticSource, record.metadata?.declarationSource
|
|
122
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
123
|
+
return /\b(typechecker|type-checker|typescript|diagnostic|diagnostics|declaration|declarations|d\.ts|type-syntax)\b/.test(text);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function isJsTsLanguage(input) {
|
|
127
|
+
const language = String(input.region?.language ?? input.context?.workerChangeSet?.language ?? input.context?.base?.language ?? '').toLowerCase();
|
|
128
|
+
return ['javascript', 'typescript', 'jsx', 'tsx'].includes(language);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function isJsxLikeLanguage(input) {
|
|
132
|
+
const language = String(input.region?.language ?? input.context?.workerChangeSet?.language ?? input.context?.base?.language ?? '').toLowerCase();
|
|
133
|
+
return ['jsx', 'tsx'].includes(language);
|
|
134
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import{idFragment,caseSensitiveIdFragment}from'../../native-import-utils.js';import{semanticOwnershipRegionForDeclaration}from'../../semantic-import-regions.js';import{createSemanticIndexRecord,hashSemanticValue}from'@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import{dynamicImportExpressionEdgeFields}from'./dynamicImportExpressionMetadata.js';import{hostDependencyEdgeFields}from'./importMetaUrlDependencyMetadata.js';import{moduleImportAttributeEdgeFields}from'./moduleImportAttributeMetadata.js';
|
|
2
3
|
import{relationPredicateForDeclaration}from'./relationPredicateForDeclaration.js';
|
|
3
4
|
export function semanticIndexFromNativeDeclarations(declarations, input, options) {
|
|
4
5
|
const documentId = `doc_${idFragment(input.sourcePath ?? input.language)}_${idFragment(input.sourceHash)}`;
|
|
@@ -94,7 +95,7 @@ export function semanticIndexFromNativeDeclarations(declarations, input, options
|
|
|
94
95
|
granularity: ownershipRegion.granularity,
|
|
95
96
|
key: ownershipRegion.key
|
|
96
97
|
}
|
|
97
|
-
}, ...projectSymbolGraphFacts({ moduleEdge, publicContractRegion, reExportIdentity, relationId, symbolId, evidenceId }));
|
|
98
|
+
}, ...projectSymbolGraphFacts({ moduleEdge, publicContractRegion, reExportIdentity, relationId, symbolId, evidenceId, compilerSymbol: declaration.metadata?.compilerSymbol, compilerSymbolIdentityHash: declaration.metadata?.compilerSymbolIdentityHash, compilerType: declaration.metadata?.compilerType, compilerTypeIdentityHash: declaration.metadata?.compilerTypeIdentityHash }));
|
|
98
99
|
mappings.push({
|
|
99
100
|
id: `map_${idFragment(declaration.nativeNode.id)}_${idFragment(symbolId)}`,
|
|
100
101
|
nativeAstNodeId: declaration.nativeNode.id,
|
|
@@ -124,7 +125,8 @@ export function semanticIndexFromNativeDeclarations(declarations, input, options
|
|
|
124
125
|
fileHashes: input.sourceHash ? 1 : 0,
|
|
125
126
|
moduleEdges: facts.filter((fact) => fact.predicate === 'moduleEdge').length,
|
|
126
127
|
reExportIdentities: facts.filter((fact) => fact.predicate === 'reExportIdentity').length,
|
|
127
|
-
publicContractRegions: facts.filter((fact) => fact.predicate === 'publicContractRegion').length
|
|
128
|
+
publicContractRegions: facts.filter((fact) => fact.predicate === 'publicContractRegion').length,
|
|
129
|
+
compilerSymbols: facts.filter((fact) => fact.predicate === 'compilerSymbol').length, compilerTypes: facts.filter((fact) => fact.predicate === 'compilerType').length
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
}];
|
|
@@ -199,6 +201,8 @@ function moduleEdgeForDeclaration(declaration, input, documentId, relationId, ow
|
|
|
199
201
|
namespace: declaration.namespace ?? declaration.metadata?.namespace,
|
|
200
202
|
isTypeOnly: declaration.isTypeOnly ?? declaration.metadata?.isTypeOnly ?? declaration.metadata?.typeOnly,
|
|
201
203
|
exportStar: declaration.exportStar ?? declaration.metadata?.exportStar,
|
|
204
|
+
...dynamicImportExpressionEdgeFields(declaration.metadata), ...hostDependencyEdgeFields(declaration.metadata),
|
|
205
|
+
...moduleImportAttributeEdgeFields(declaration.metadata),
|
|
202
206
|
isReExport: edgeKind === 're-export',
|
|
203
207
|
publicContract: publicContractForDeclaration(declaration, edgeKind)
|
|
204
208
|
});
|
|
@@ -256,16 +260,18 @@ function reExportIdentityForDeclaration(declaration, input, documentId, relation
|
|
|
256
260
|
localName: declaration.localName ?? declaration.metadata?.localName, namespace: declaration.namespace ?? declaration.metadata?.namespace,
|
|
257
261
|
isTypeOnly: declaration.isTypeOnly ?? declaration.metadata?.isTypeOnly ?? declaration.metadata?.typeOnly, exportStar: declaration.exportStar ?? declaration.metadata?.exportStar,
|
|
258
262
|
symbolId: declaration.symbolId, relationId, ownershipRegionId: ownershipRegion.id, ownershipRegionKey: ownershipRegion.key,
|
|
259
|
-
publicContract: true
|
|
263
|
+
publicContract: true, hasImportAttributes: moduleEdge?.hasImportAttributes, importAttributeCount: moduleEdge?.importAttributeCount, importAttributeKeys: moduleEdge?.importAttributeKeys, importAttributeHash: moduleEdge?.importAttributeHash, importAttributes: moduleEdge?.importAttributes
|
|
260
264
|
});
|
|
261
265
|
}
|
|
262
266
|
|
|
263
|
-
function projectSymbolGraphFacts({ moduleEdge, publicContractRegion, reExportIdentity, relationId, symbolId, evidenceId }) {
|
|
267
|
+
function projectSymbolGraphFacts({ moduleEdge, publicContractRegion, reExportIdentity, relationId, symbolId, evidenceId, compilerSymbol, compilerSymbolIdentityHash, compilerType, compilerTypeIdentityHash }) {
|
|
264
268
|
return [
|
|
269
|
+
compilerSymbol ? { id: graphFactId(relationId, symbolId, 'compiler_symbol'), predicate: 'compilerSymbol', subjectId: symbolId, value: { ...compilerSymbol, identityHash: compilerSymbolIdentityHash }, evidenceIds: [evidenceId] } : undefined,
|
|
270
|
+
compilerType ? { id: graphFactId(relationId, symbolId, 'compiler_type'), predicate: 'compilerType', subjectId: symbolId, value: { ...compilerType, identityHash: compilerTypeIdentityHash }, evidenceIds: [evidenceId] } : undefined,
|
|
265
271
|
moduleEdge ? {
|
|
266
272
|
id: graphFactId(relationId, symbolId, 'module_edge'),
|
|
267
273
|
predicate: 'moduleEdge',
|
|
268
|
-
subjectId:
|
|
274
|
+
subjectId: symbolId,
|
|
269
275
|
objectId: symbolId,
|
|
270
276
|
value: moduleEdge,
|
|
271
277
|
evidenceIds: [evidenceId]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { idFragment, uniqueStrings } from '../../native-import-utils.js';
|
|
3
|
+
|
|
4
|
+
function semanticStructuralEdit(input) {
|
|
5
|
+
const actions = structuralEditActions(input);
|
|
6
|
+
const structuralKind = structuralEditKind(actions);
|
|
7
|
+
const record = compactRecord({
|
|
8
|
+
id: `semantic_structural_edit_${idFragment(input.operationId)}`,
|
|
9
|
+
kind: 'frontier.lang.semanticStructuralEdit',
|
|
10
|
+
version: 1,
|
|
11
|
+
algorithm: 'frontier.semantic-edit-structural-diff.v1',
|
|
12
|
+
runtimeNeutral: true,
|
|
13
|
+
operationId: input.operationId,
|
|
14
|
+
structuralKind,
|
|
15
|
+
actions,
|
|
16
|
+
operationKind: input.kind,
|
|
17
|
+
changeKind: input.changeKind,
|
|
18
|
+
anchorKey: input.anchor?.key,
|
|
19
|
+
conflictKey: input.anchor?.conflictKey,
|
|
20
|
+
regionKind: input.anchor?.regionKind,
|
|
21
|
+
sourcePath: input.anchor?.sourcePath,
|
|
22
|
+
symbolName: input.anchor?.symbolName,
|
|
23
|
+
symbolKind: input.anchor?.symbolKind,
|
|
24
|
+
from: structuralSpanLocation(input.spans?.base),
|
|
25
|
+
to: structuralSpanLocation(input.spans?.worker),
|
|
26
|
+
head: structuralSpanLocation(input.spans?.head),
|
|
27
|
+
baseTextHash: input.hashes?.baseTextHash,
|
|
28
|
+
workerTextHash: input.hashes?.workerTextHash,
|
|
29
|
+
headTextHash: input.hashes?.headTextHash,
|
|
30
|
+
beforeSignatureHash: input.hashes?.beforeSignatureHash,
|
|
31
|
+
afterSignatureHash: input.hashes?.afterSignatureHash,
|
|
32
|
+
status: input.status,
|
|
33
|
+
reviewRequired: true,
|
|
34
|
+
confidence: input.confidence,
|
|
35
|
+
reasonCodes: uniqueStrings([
|
|
36
|
+
...(input.reasonCodes ?? []),
|
|
37
|
+
'structural-diff-review-required',
|
|
38
|
+
'replay-required-for-safety'
|
|
39
|
+
]),
|
|
40
|
+
reanchor: input.reanchor,
|
|
41
|
+
metadata: {
|
|
42
|
+
autoMergeClaim: false,
|
|
43
|
+
semanticEquivalenceClaim: false
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return { ...record, hash: hashSemanticValue(record) };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function semanticStructuralDiff(input) {
|
|
50
|
+
const edits = (input.operations ?? []).map((operation) => operation.structuralEdit).filter(Boolean);
|
|
51
|
+
const summary = summarizeStructuralEdits(edits);
|
|
52
|
+
const core = {
|
|
53
|
+
kind: 'frontier.lang.semanticStructuralDiff',
|
|
54
|
+
version: 1,
|
|
55
|
+
schema: 'frontier.lang.semanticStructuralDiff.v1',
|
|
56
|
+
id: input.input.structuralDiffId ?? `semantic_structural_diff_${idFragment(input.input.id ?? input.sourcePath ?? 'semantic_edit')}`,
|
|
57
|
+
algorithm: 'frontier.semantic-edit-structural-diff.v1',
|
|
58
|
+
runtimeNeutral: true,
|
|
59
|
+
language: input.language,
|
|
60
|
+
sourcePath: input.sourcePath,
|
|
61
|
+
workerChangeSetId: input.workerChangeSet.id,
|
|
62
|
+
headChangeSetId: input.headChangeSet?.id,
|
|
63
|
+
edits,
|
|
64
|
+
summary,
|
|
65
|
+
admission: {
|
|
66
|
+
status: 'review-required',
|
|
67
|
+
action: 'run-replay-and-diagnostics',
|
|
68
|
+
reviewRequired: true,
|
|
69
|
+
autoMergeClaim: false,
|
|
70
|
+
semanticEquivalenceClaim: false,
|
|
71
|
+
reasonCodes: ['structural-diff-review-required', 'replay-required-for-safety']
|
|
72
|
+
},
|
|
73
|
+
metadata: {
|
|
74
|
+
autoMergeClaim: false,
|
|
75
|
+
semanticEquivalenceClaim: false,
|
|
76
|
+
note: 'Structural edit records classify AST/CST-neutral anchor movement and content changes; source replay diagnostics still decide safety.'
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return { ...core, hash: hashSemanticValue(core) };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function structuralEditActions(input) {
|
|
83
|
+
if (input.changeKind === 'added') return ['insert'];
|
|
84
|
+
if (input.changeKind === 'removed') return ['delete'];
|
|
85
|
+
const actions = [];
|
|
86
|
+
if (structuralSpanMoved(input.spans?.base, input.spans?.worker) || input.reanchor?.toAnchorKey) actions.push('move');
|
|
87
|
+
if (structuralContentChanged(input.hashes)) actions.push('update');
|
|
88
|
+
return actions.length ? actions : ['update'];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function structuralEditKind(actions) {
|
|
92
|
+
if (actions.includes('move') && actions.includes('update')) return 'move-update';
|
|
93
|
+
return actions[0] ?? 'update';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function structuralContentChanged(hashes) {
|
|
97
|
+
return Boolean(
|
|
98
|
+
hashes?.baseTextHash && hashes?.workerTextHash && hashes.baseTextHash !== hashes.workerTextHash
|
|
99
|
+
|| hashes?.beforeSignatureHash && hashes?.afterSignatureHash && hashes.beforeSignatureHash !== hashes.afterSignatureHash
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function structuralSpanMoved(left, right) {
|
|
104
|
+
if (!left || !right) return false;
|
|
105
|
+
return (left.path && right.path && left.path !== right.path)
|
|
106
|
+
|| left.startLine !== right.startLine
|
|
107
|
+
|| left.startColumn !== right.startColumn
|
|
108
|
+
|| left.endLine !== right.endLine
|
|
109
|
+
|| left.endColumn !== right.endColumn;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function structuralSpanLocation(span) {
|
|
113
|
+
return span ? compactRecord({
|
|
114
|
+
path: span.path,
|
|
115
|
+
startLine: span.startLine,
|
|
116
|
+
startColumn: span.startColumn,
|
|
117
|
+
endLine: span.endLine,
|
|
118
|
+
endColumn: span.endColumn
|
|
119
|
+
}) : undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function summarizeStructuralEdits(edits) {
|
|
123
|
+
const byKind = countBy(edits.map((edit) => edit.structuralKind));
|
|
124
|
+
const byAction = countBy(edits.flatMap((edit) => edit.actions ?? []));
|
|
125
|
+
return {
|
|
126
|
+
edits: edits.length,
|
|
127
|
+
byKind,
|
|
128
|
+
byAction,
|
|
129
|
+
moves: byAction.move ?? 0,
|
|
130
|
+
updates: byAction.update ?? 0,
|
|
131
|
+
inserts: byAction.insert ?? 0,
|
|
132
|
+
deletes: byAction.delete ?? 0,
|
|
133
|
+
moveUpdates: byKind['move-update'] ?? 0,
|
|
134
|
+
reviewRequired: edits.length > 0,
|
|
135
|
+
autoMergeClaim: false,
|
|
136
|
+
semanticEquivalenceClaim: false
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function countBy(values) {
|
|
141
|
+
const result = {};
|
|
142
|
+
for (const value of values.filter(Boolean)) result[value] = (result[value] ?? 0) + 1;
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function compactRecord(value) {
|
|
147
|
+
return Object.fromEntries(Object.entries(value ?? {}).filter(([, entry]) => entry !== undefined && (!Array.isArray(entry) || entry.length > 0)));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { semanticStructuralDiff, semanticStructuralEdit };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { countBy, uniqueStrings } from '../../native-import-utils.js';
|
|
2
|
+
|
|
3
|
+
export function classifySourceMapGeneratedBoundary(sourceMaps, options = {}) {
|
|
4
|
+
const maps = normalizeSourceMapCollection(sourceMaps);
|
|
5
|
+
const entries = maps.flatMap((sourceMap) => (sourceMap?.mappings ?? [])
|
|
6
|
+
.map((mapping) => ({ sourceMap, mapping })));
|
|
7
|
+
const exactEntries = entries.filter(({ sourceMap, mapping }) => hasExactGeneratedBoundary(sourceMap, mapping));
|
|
8
|
+
const generatedBoundaryOwnershipRecords = exactEntries.map(generatedBoundaryOwnershipRecord).filter(Boolean);
|
|
9
|
+
const summary = sourceMapGeneratedBoundarySummary(maps, entries);
|
|
10
|
+
const exactBoundary = generatedBoundaryOwnershipRecords.length > 0;
|
|
11
|
+
return {
|
|
12
|
+
schema: 'frontier.lang.sourceMapGeneratedBoundaryGate.v1',
|
|
13
|
+
version: 1,
|
|
14
|
+
status: exactBoundary ? 'ready' : 'blocked',
|
|
15
|
+
readiness: exactBoundary ? 'ready' : 'blocked',
|
|
16
|
+
action: exactBoundary ? 'admit-exact-source-map-generated-boundary' : 'block-generated-file-merge-admission',
|
|
17
|
+
reviewRequired: !exactBoundary,
|
|
18
|
+
exactBoundary,
|
|
19
|
+
autoMergeClaim: false,
|
|
20
|
+
semanticEquivalenceClaim: false,
|
|
21
|
+
sourceLanguage: options.sourceLanguage,
|
|
22
|
+
target: options.target,
|
|
23
|
+
outputMode: options.outputMode,
|
|
24
|
+
projectionMode: options.projectionMode,
|
|
25
|
+
sourceMapIds: uniqueStrings(maps.map((sourceMap) => sourceMap?.id)),
|
|
26
|
+
sourceMapMappingIds: uniqueStrings(exactEntries.map(({ mapping }) => mapping?.id)),
|
|
27
|
+
generatedBoundaryOwnershipStatus: exactBoundary ? 'deterministic-source-map-span' : 'blocked',
|
|
28
|
+
generatedBoundaryOwnershipKeys: uniqueStrings(generatedBoundaryOwnershipRecords.map((record) => record.key)),
|
|
29
|
+
generatedBoundaryOwnershipRecords,
|
|
30
|
+
invariant: 'ECMA-426 source maps identify generated positions and original positions; Frontier generated-file merge admission requires validated source-map evidence plus exact source and generated spans with source and target hashes.',
|
|
31
|
+
missingInvariant: exactBoundary ? undefined : 'ecma-426-generated-position-only-no-range-boundary',
|
|
32
|
+
summary,
|
|
33
|
+
reasonCodes: sourceMapGeneratedBoundaryReasonCodes(summary, exactBoundary)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalizeSourceMapCollection(sourceMaps) {
|
|
38
|
+
if (!sourceMaps) return [];
|
|
39
|
+
return Array.isArray(sourceMaps) ? sourceMaps.filter(Boolean) : [sourceMaps].filter(Boolean);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function hasExactGeneratedBoundary(sourceMap, mapping) {
|
|
43
|
+
return mapping?.precision === 'exact'
|
|
44
|
+
&& hasExactSpan(mapping.sourceSpan)
|
|
45
|
+
&& hasExactSpan(mapping.generatedSpan)
|
|
46
|
+
&& Boolean(sourceBoundaryHash(sourceMap, mapping))
|
|
47
|
+
&& Boolean(targetBoundaryHash(sourceMap, mapping));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function hasExactSpan(span) {
|
|
51
|
+
if (!span) return false;
|
|
52
|
+
return [span.startLine, span.startColumn, span.endLine, span.endColumn]
|
|
53
|
+
.every((value) => Number.isFinite(value));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function sourceMapGeneratedBoundarySummary(maps, entries) {
|
|
57
|
+
const mappings = entries.map(({ mapping }) => mapping);
|
|
58
|
+
const ecma426Payloads = maps.map(ecma426SourceMapEvidence).filter((record) => record?.present);
|
|
59
|
+
const ecma426ReasonCodes = uniqueStrings(ecma426Payloads.flatMap((record) => record?.reasonCodes ?? []));
|
|
60
|
+
const generatedBoundaryOwnershipRecords = entries
|
|
61
|
+
.filter(({ sourceMap, mapping }) => hasExactGeneratedBoundary(sourceMap, mapping))
|
|
62
|
+
.map(generatedBoundaryOwnershipRecord)
|
|
63
|
+
.filter(Boolean);
|
|
64
|
+
return {
|
|
65
|
+
sourceMaps: maps.length,
|
|
66
|
+
mappings: mappings.length,
|
|
67
|
+
exactBoundaryMappings: entries.filter(({ sourceMap, mapping }) => hasExactGeneratedBoundary(sourceMap, mapping)).length,
|
|
68
|
+
deterministicGeneratedBoundaryOwnerships: generatedBoundaryOwnershipRecords.length,
|
|
69
|
+
exactPrecisionMappings: mappings.filter((mapping) => mapping?.precision === 'exact').length,
|
|
70
|
+
withSourceSpan: mappings.filter((mapping) => hasExactSpan(mapping?.sourceSpan)).length,
|
|
71
|
+
withGeneratedSpan: mappings.filter((mapping) => hasExactSpan(mapping?.generatedSpan)).length,
|
|
72
|
+
withSourceHash: entries.filter(({ sourceMap, mapping }) => sourceBoundaryHash(sourceMap, mapping)).length,
|
|
73
|
+
withTargetHash: entries.filter(({ sourceMap, mapping }) => targetBoundaryHash(sourceMap, mapping)).length,
|
|
74
|
+
byPrecision: countBy(mappings.map((mapping) => mapping?.precision ?? 'unknown')),
|
|
75
|
+
byOrigin: countBy(mappings.map((mapping) => mapping?.metadata?.sourceMapOrigin ?? 'native-import')),
|
|
76
|
+
byBoundaryKind: countBy(entries.map(({ sourceMap, mapping }) => sourceMapBoundaryKind(sourceMap, mapping))),
|
|
77
|
+
byEcma426Status: countBy(maps.map((sourceMap) => ecma426SourceMapEvidence(sourceMap)?.status ?? 'missing')),
|
|
78
|
+
ecma426Payloads: ecma426Payloads.length,
|
|
79
|
+
validEcma426Payloads: ecma426Payloads.filter((record) => record?.status === 'valid').length,
|
|
80
|
+
invalidEcma426Payloads: ecma426Payloads.filter((record) => record?.status === 'blocked').length,
|
|
81
|
+
decodedEcma426Mappings: ecma426Payloads.reduce((sum, record) => sum + numeric(record?.summary?.decodedMappings), 0),
|
|
82
|
+
ecma426ReasonCodes,
|
|
83
|
+
sourcePaths: uniqueStrings(entries.map(({ sourceMap, mapping }) => mapping?.sourceSpan?.path ?? sourceMap?.sourcePath)),
|
|
84
|
+
targetPaths: uniqueStrings(entries.map(({ sourceMap, mapping }) => mapping?.generatedSpan?.targetPath
|
|
85
|
+
?? mapping?.generatedSpan?.path ?? sourceMap?.targetPath ?? sourceMap?.target?.emitPath))
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function sourceMapGeneratedBoundaryReasonCodes(summary, exactBoundary) {
|
|
90
|
+
return uniqueStrings([
|
|
91
|
+
'ecma-426:source-map-generated-boundary-gate',
|
|
92
|
+
'runtime-neutral:source-map-records-only',
|
|
93
|
+
exactBoundary ? 'source-map-generated-boundary:exact' : 'ecma-426:missing-exact-source-generated-boundary',
|
|
94
|
+
exactBoundary ? 'source-map-generated-boundary:deterministic-source-map-span-ownership' : undefined,
|
|
95
|
+
summary.sourceMaps === 0 ? 'source-map:missing' : undefined,
|
|
96
|
+
!exactBoundary && summary.ecma426Payloads === 0 ? 'ecma-426:payload-missing' : undefined,
|
|
97
|
+
summary.validEcma426Payloads > 0 ? 'ecma-426:payload-valid' : undefined,
|
|
98
|
+
!exactBoundary && summary.invalidEcma426Payloads > 0 ? 'ecma-426:payload-invalid' : undefined,
|
|
99
|
+
!exactBoundary && summary.validEcma426Payloads > 0 && summary.exactBoundaryMappings === 0 ? 'ecma-426:payload-position-only' : undefined,
|
|
100
|
+
...summary.ecma426ReasonCodes,
|
|
101
|
+
summary.mappings === 0 ? 'source-map:mappings-missing' : undefined,
|
|
102
|
+
summary.exactPrecisionMappings === 0 ? 'source-map:exact-precision-missing' : undefined,
|
|
103
|
+
summary.withSourceSpan < summary.mappings ? 'ecma-426:missing-original-range' : undefined,
|
|
104
|
+
summary.withGeneratedSpan < summary.mappings ? 'ecma-426:missing-generated-range' : undefined,
|
|
105
|
+
summary.withSourceHash < summary.mappings ? 'source-map:source-hash-missing' : undefined,
|
|
106
|
+
summary.withTargetHash < summary.mappings ? 'source-map:target-hash-missing' : undefined
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function sourceBoundaryHash(sourceMap, mapping) {
|
|
111
|
+
return sourceMap?.sourceHash ?? mapping?.sourceSpan?.sourceHash ?? mapping?.sourceSpan?.sourceId;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function targetBoundaryHash(sourceMap, mapping) {
|
|
115
|
+
return sourceMap?.targetHash ?? mapping?.generatedSpan?.targetHash ?? mapping?.targetHash;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function generatedBoundaryOwnershipRecord({ sourceMap, mapping }) {
|
|
119
|
+
if (!hasExactGeneratedBoundary(sourceMap, mapping)) return undefined;
|
|
120
|
+
const sourceSpan = mapping?.sourceSpan;
|
|
121
|
+
const generatedSpan = mapping?.generatedSpan;
|
|
122
|
+
const sourcePath = sourceSpan?.path ?? sourceMap?.sourcePath;
|
|
123
|
+
const targetPath = generatedSpan?.targetPath ?? generatedSpan?.path ?? sourceMap?.targetPath ?? sourceMap?.target?.emitPath;
|
|
124
|
+
const sourceHash = sourceBoundaryHash(sourceMap, mapping);
|
|
125
|
+
const targetHash = targetBoundaryHash(sourceMap, mapping);
|
|
126
|
+
const sourceSpanKey = exactSpanKey(sourceSpan);
|
|
127
|
+
const generatedSpanKey = exactSpanKey(generatedSpan);
|
|
128
|
+
const key = stableKey(['generated-boundary', sourcePath, sourceHash, sourceSpanKey, targetPath, targetHash, generatedSpanKey]);
|
|
129
|
+
return compactRecord({
|
|
130
|
+
key,
|
|
131
|
+
status: 'deterministic-source-map-span',
|
|
132
|
+
sourceMapId: sourceMap?.id,
|
|
133
|
+
sourceMapMappingId: mapping?.id,
|
|
134
|
+
sourcePath,
|
|
135
|
+
targetPath,
|
|
136
|
+
sourceHash,
|
|
137
|
+
targetHash,
|
|
138
|
+
sourceSpanKey,
|
|
139
|
+
generatedSpanKey,
|
|
140
|
+
boundaryKind: sourceMapBoundaryKind(sourceMap, mapping),
|
|
141
|
+
sourceMapOrigin: mapping?.metadata?.sourceMapOrigin ?? 'native-import'
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function exactSpanKey(span) {
|
|
146
|
+
return stableKey([
|
|
147
|
+
span?.path ?? span?.targetPath ?? span?.sourceId,
|
|
148
|
+
span?.start,
|
|
149
|
+
span?.end,
|
|
150
|
+
span?.startLine,
|
|
151
|
+
span?.startColumn,
|
|
152
|
+
span?.endLine,
|
|
153
|
+
span?.endColumn
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function ecma426SourceMapEvidence(sourceMap) {
|
|
158
|
+
return sourceMap?.metadata?.ecma426SourceMap;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function numeric(value) {
|
|
162
|
+
const number = Number(value);
|
|
163
|
+
return Number.isFinite(number) ? number : 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function sourceMapBoundaryKind(sourceMap, mapping) {
|
|
167
|
+
const sourcePath = mapping?.sourceSpan?.path ?? sourceMap?.sourcePath;
|
|
168
|
+
const targetPath = mapping?.generatedSpan?.targetPath ?? mapping?.generatedSpan?.path
|
|
169
|
+
?? sourceMap?.targetPath ?? sourceMap?.target?.emitPath;
|
|
170
|
+
const sourceHash = sourceBoundaryHash(sourceMap, mapping);
|
|
171
|
+
const targetHash = targetBoundaryHash(sourceMap, mapping);
|
|
172
|
+
if (sourcePath && targetPath && sourcePath === targetPath && sourceHash && targetHash && sourceHash === targetHash) {
|
|
173
|
+
return 'preserved-source';
|
|
174
|
+
}
|
|
175
|
+
return 'source-generated';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function stableKey(parts) {
|
|
179
|
+
const values = parts.map((part) => part === undefined || part === null ? '' : String(part));
|
|
180
|
+
return values.some(Boolean) ? values.join('#') : undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function compactRecord(record) {
|
|
184
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
185
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function readStaticMemberLiteral(sourceText, start, limit) {
|
|
2
|
+
const quote = sourceText[start];
|
|
3
|
+
if (quote === '\'' || quote === '"') return readQuotedMemberLiteral(sourceText, start, limit, quote);
|
|
4
|
+
if (quote === '`') return readTemplateMemberLiteral(sourceText, start, limit);
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function readQuotedMemberLiteral(sourceText, start, limit, quote) {
|
|
9
|
+
let value = '';
|
|
10
|
+
for (let index = start + 1; index < limit; index += 1) {
|
|
11
|
+
const char = sourceText[index];
|
|
12
|
+
if (char === '\\' || char === '\n' || char === '\r') return undefined;
|
|
13
|
+
if (char === quote) return { value, start: start + 1, end: index, literalKind: 'string-literal' };
|
|
14
|
+
value += char;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function readTemplateMemberLiteral(sourceText, start, limit) {
|
|
20
|
+
let value = '';
|
|
21
|
+
for (let index = start + 1; index < limit; index += 1) {
|
|
22
|
+
const char = sourceText[index];
|
|
23
|
+
if (char === '\\' || char === '\n' || char === '\r') return undefined;
|
|
24
|
+
if (char === '$' && sourceText[index + 1] === '{') return undefined;
|
|
25
|
+
if (char === '`') return { value, start: start + 1, end: index, literalKind: 'static-template-literal' };
|
|
26
|
+
value += char;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { readStaticMemberLiteral };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function staticOptionalMemberReference(text) {
|
|
2
|
+
const normalized = normalizedOptionalMemberExpression(text);
|
|
3
|
+
if (!normalized.includes('?.')) return undefined;
|
|
4
|
+
if (!/^(?:this|[A-Za-z_$][\w$]*)(?:(?:\?\.|\.)[A-Za-z_$][\w$]*)+$/.test(normalized)) return undefined;
|
|
5
|
+
const path = normalized.split(/\?\.|\./);
|
|
6
|
+
const operators = normalized.match(/\?\.|\./g) ?? [];
|
|
7
|
+
const optionalSegmentIndexes = operators.flatMap((operator, index) => operator === '?.' ? [index + 1] : []);
|
|
8
|
+
return {
|
|
9
|
+
text: normalized,
|
|
10
|
+
root: path[0],
|
|
11
|
+
path,
|
|
12
|
+
memberPath: path.slice(1),
|
|
13
|
+
optionalSegments: optionalSegmentIndexes.map((index) => path[index]),
|
|
14
|
+
optionalSegmentIndexes
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function normalizedOptionalMemberExpression(text) {
|
|
19
|
+
return String(text ?? '').trim().replace(/\s+/g, ' ').replace(/\s*(\?\.|\.)\s*/g, '$1').replace(/\s+/g, '');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { staticOptionalMemberReference };
|