@shapeshift-labs/frontier-lang-compiler 0.2.149 → 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-patch-bundle-composition.d.ts +62 -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 +32 -0
- package/dist/index.js +6 -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/semanticPatchBundleComposition.js +166 -0
- 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-context.js +1 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +314 -0
- 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-plan.js +3 -1
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +49 -0
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +5 -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 +171 -172
- 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,99 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
|
|
3
|
+
const TypeReferenceTargetProofKind = 'typescript-checker-public-api-type-reference-target-proof';
|
|
4
|
+
|
|
5
|
+
const RequiredFields = [
|
|
6
|
+
field('typeReferenceName', 'Names', 'compiler-type-reference-target-names'),
|
|
7
|
+
field('targetSymbolName', 'SymbolNames', 'compiler-type-reference-target-symbol-names'),
|
|
8
|
+
field('targetFullyQualifiedName', 'FullyQualifiedNames', 'compiler-type-reference-target-fully-qualified-names'),
|
|
9
|
+
field('targetDeclarationSourcePath', 'DeclarationSourcePaths', 'compiler-type-reference-target-declaration-source-paths'),
|
|
10
|
+
field('targetDeclarationSpan', 'DeclarationSpans', 'compiler-type-reference-target-declaration-spans'),
|
|
11
|
+
field('targetDeclarationTextHash', 'DeclarationTextHashes', 'compiler-type-reference-target-declaration-text-hashes'),
|
|
12
|
+
field('targetSymbolIdentityHash', 'SymbolIdentityHashes', 'compiler-type-reference-target-symbol-identity-hashes'),
|
|
13
|
+
field('typeReferenceTargetProofHash', 'ProofHashes', 'compiler-type-reference-target-proof-hashes')
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
function typeReferenceTargetSetHash(value, counts) {
|
|
17
|
+
if (!counts.typeReferenceTargetCount || missingTypeReferenceTargetSignals(value, counts).length) return undefined;
|
|
18
|
+
return hashSemanticValue({
|
|
19
|
+
kind: 'frontier.lang.typescript.compilerTypeReferenceTargetSetEquivalence.v1',
|
|
20
|
+
typeReferenceTargets: typeReferenceTargets(value).map(canonicalTypeReferenceTarget)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function typeReferenceTargetRequiredSignals(counts) {
|
|
25
|
+
return counts.typeReferenceTargetCount > 0
|
|
26
|
+
? ['compiler-type-reference-target-count', ...RequiredFields.map((item) => item.signal)]
|
|
27
|
+
: [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function missingTypeReferenceTargetSignals(value, counts) {
|
|
31
|
+
if (!counts.typeReferenceTargetCount) return [];
|
|
32
|
+
const targets = typeReferenceTargets(value);
|
|
33
|
+
const missing = [];
|
|
34
|
+
if (targets.length !== counts.typeReferenceTargetCount) missing.push('compiler-type-reference-target-count');
|
|
35
|
+
for (const item of RequiredFields) if (targets.some((target) => fieldMissing(target?.[item.key]))) missing.push(item.signal);
|
|
36
|
+
return uniqueStrings(missing);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function typeReferenceTargetCheckerEvidence(value, counts) {
|
|
40
|
+
if (!counts.typeReferenceTargetCount) return {};
|
|
41
|
+
const targets = typeReferenceTargets(value);
|
|
42
|
+
return compactRecord({
|
|
43
|
+
typeReferenceTargetCount: counts.typeReferenceTargetCount,
|
|
44
|
+
typeReferenceTargets: targets,
|
|
45
|
+
...Object.fromEntries(RequiredFields.map((item) => [
|
|
46
|
+
`typeReferenceTarget${item.evidenceSuffix}`,
|
|
47
|
+
targets.map((target) => target[item.key]).filter((fieldValue) => fieldValue !== undefined && fieldValue !== null)
|
|
48
|
+
]))
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function typeReferenceTargetCheckerInvariant(counts) {
|
|
53
|
+
return counts.typeReferenceTargetCount > 0
|
|
54
|
+
? 'type reference targets resolve to compiler symbols, declaration spans, and declaration source hashes'
|
|
55
|
+
: undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function typeReferenceTargetProofLevel(counts) {
|
|
59
|
+
return counts.typeReferenceTargetCount > 0 ? 'type-reference-target-set' : undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function typeReferenceTargetProofKind(counts) {
|
|
63
|
+
return counts.typeReferenceTargetCount > 0 ? TypeReferenceTargetProofKind : undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function canonicalTypeReferenceTarget(target) {
|
|
67
|
+
return compactRecord({
|
|
68
|
+
kind: target.kind,
|
|
69
|
+
typeReferenceName: target.typeReferenceName,
|
|
70
|
+
targetSymbolName: target.targetSymbolName,
|
|
71
|
+
targetFullyQualifiedName: target.targetFullyQualifiedName,
|
|
72
|
+
targetDeclarationSourcePath: target.targetDeclarationSourcePath,
|
|
73
|
+
targetDeclarationSpan: target.targetDeclarationSpan,
|
|
74
|
+
targetDeclarationTextHash: target.targetDeclarationTextHash,
|
|
75
|
+
targetSymbolIdentityHash: target.targetSymbolIdentityHash,
|
|
76
|
+
typeReferenceTargetProofHash: target.typeReferenceTargetProofHash
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function typeReferenceTargets(value) { return arrayValue(value.typeReferenceTargets); }
|
|
81
|
+
function field(key, evidenceSuffix, signal) { return { key, evidenceSuffix, signal }; }
|
|
82
|
+
function fieldMissing(value) {
|
|
83
|
+
if (Array.isArray(value)) return !value.length || value.some((item) => item === undefined || item === null);
|
|
84
|
+
return value === undefined || value === null;
|
|
85
|
+
}
|
|
86
|
+
function arrayValue(value) { return Array.isArray(value) ? value : []; }
|
|
87
|
+
function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); }
|
|
88
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
TypeReferenceTargetProofKind,
|
|
92
|
+
missingTypeReferenceTargetSignals,
|
|
93
|
+
typeReferenceTargetCheckerEvidence,
|
|
94
|
+
typeReferenceTargetCheckerInvariant,
|
|
95
|
+
typeReferenceTargetProofKind,
|
|
96
|
+
typeReferenceTargetProofLevel,
|
|
97
|
+
typeReferenceTargetRequiredSignals,
|
|
98
|
+
typeReferenceTargetSetHash
|
|
99
|
+
};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { idFragment } from '../../native-import-utils.js';
|
|
3
|
+
import {
|
|
4
|
+
compactRecord,
|
|
5
|
+
cssModuleSpecifierPath,
|
|
6
|
+
groupBy,
|
|
7
|
+
semanticSpanForHash,
|
|
8
|
+
sourceSpanForRange
|
|
9
|
+
} from './projectSymbolGraphCssModuleUtils.js';
|
|
10
|
+
|
|
11
|
+
function cssModuleImportBindingRecord(edge, index, documentsById, cssSourcesByPath) {
|
|
12
|
+
const cssSourcePath = edge.resolvedModulePath ?? cssModuleSpecifierPath(edge.moduleSpecifier);
|
|
13
|
+
const document = documentsById.get(edge.targetDocumentId);
|
|
14
|
+
const cssSource = cssSourcesByPath.get(cssSourcePath);
|
|
15
|
+
const cssModuleEvidence = cssSource?.cssModuleEvidence;
|
|
16
|
+
const cssModuleExportNames = cssModuleEvidenceExportNames(cssModuleEvidence);
|
|
17
|
+
const cssModuleHash = cssModuleEvidence?.moduleHash ?? hashSemanticValue({
|
|
18
|
+
kind: 'frontier.lang.cssModuleUnprovedSource.v1',
|
|
19
|
+
sourcePath: cssSourcePath,
|
|
20
|
+
sourceHash: document?.sourceHash ?? cssSource?.sourceHash
|
|
21
|
+
});
|
|
22
|
+
const signatureHash = hashSemanticValue({
|
|
23
|
+
kind: 'frontier.lang.cssModuleImportBinding.v1',
|
|
24
|
+
sourcePath: edge.sourcePath,
|
|
25
|
+
moduleSpecifier: edge.moduleSpecifier,
|
|
26
|
+
resolvedModulePath: edge.resolvedModulePath,
|
|
27
|
+
importKind: edge.importKind,
|
|
28
|
+
importedName: edge.importedName,
|
|
29
|
+
localName: edge.localName,
|
|
30
|
+
cssModuleSourcePath: cssSourcePath,
|
|
31
|
+
cssModuleSourceHash: document?.sourceHash ?? cssSource?.sourceHash,
|
|
32
|
+
cssModuleHash
|
|
33
|
+
});
|
|
34
|
+
return compactRecord({
|
|
35
|
+
id: `css_module_import_${idFragment(edge.id ?? `${edge.sourcePath}_${index}`)}`,
|
|
36
|
+
kind: 'css-module-import-binding',
|
|
37
|
+
sourcePath: edge.sourcePath,
|
|
38
|
+
sourceHash: edge.sourceHash,
|
|
39
|
+
sourceSpan: edge.sourceSpan,
|
|
40
|
+
importEdgeId: edge.id,
|
|
41
|
+
moduleSpecifier: edge.moduleSpecifier,
|
|
42
|
+
resolvedModulePath: edge.resolvedModulePath,
|
|
43
|
+
targetDocumentId: edge.targetDocumentId,
|
|
44
|
+
importKind: edge.importKind,
|
|
45
|
+
importedName: edge.importedName,
|
|
46
|
+
localName: edge.localName,
|
|
47
|
+
cssModuleSourcePath: cssSourcePath,
|
|
48
|
+
cssModuleSourceHash: document?.sourceHash ?? cssSource?.sourceHash,
|
|
49
|
+
cssModuleHash,
|
|
50
|
+
cssModuleEvidenceStatus: cssModuleEvidence ? 'supplied' : 'unproved',
|
|
51
|
+
cssModuleExportNames: cssModuleExportNames.length ? cssModuleExportNames : undefined,
|
|
52
|
+
cssModuleExportNamesHash: cssModuleExportNames.length ? hashSemanticValue(cssModuleExportNames) : undefined,
|
|
53
|
+
generatedClassNameMapHash: cssModuleEvidence?.generatedClassNameMapHash ?? cssModuleGeneratedClassNameMapHash(cssModuleEvidence),
|
|
54
|
+
jsTsUseSiteGraphHash: cssModuleEvidence?.jsTsUseSiteGraphHash,
|
|
55
|
+
cssModuleCompositionGraphHash: cssModuleEvidence?.cssModuleCompositionGraphHash,
|
|
56
|
+
icssGraphHash: cssModuleEvidence?.icssGraphHash,
|
|
57
|
+
bundlerTransformHash: cssSource?.bundlerTransformHash,
|
|
58
|
+
sourceMapProofHash: cssSource?.sourceMapProofHash,
|
|
59
|
+
signatureHash
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function cssModuleUseSiteRecord(binding, input) {
|
|
64
|
+
const signatureHash = hashSemanticValue({
|
|
65
|
+
kind: 'frontier.lang.cssModuleUseSite.v1',
|
|
66
|
+
binding: binding.signatureHash,
|
|
67
|
+
useSiteKind: input.useSiteKind,
|
|
68
|
+
accessKind: input.accessKind,
|
|
69
|
+
exportName: input.exportName,
|
|
70
|
+
expressionText: input.expressionText,
|
|
71
|
+
sourceSpan: semanticSpanForHash(input.sourceSpan)
|
|
72
|
+
});
|
|
73
|
+
return compactRecord({
|
|
74
|
+
id: `css_module_use_${idFragment(binding.id)}_${idFragment(signatureHash)}`,
|
|
75
|
+
kind: 'css-module-use-site',
|
|
76
|
+
cssModuleImportBindingId: binding.id,
|
|
77
|
+
importEdgeId: binding.importEdgeId,
|
|
78
|
+
cssModuleSourcePath: binding.cssModuleSourcePath,
|
|
79
|
+
cssModuleHash: binding.cssModuleHash,
|
|
80
|
+
exportName: input.exportName,
|
|
81
|
+
cssModuleExportHash: cssModuleExportHash(binding, input.exportName),
|
|
82
|
+
useSiteKind: input.useSiteKind,
|
|
83
|
+
jsSourcePath: input.sourcePath,
|
|
84
|
+
jsSourceHash: input.sourceHash,
|
|
85
|
+
sourceSpan: input.sourceSpan,
|
|
86
|
+
accessKind: input.accessKind,
|
|
87
|
+
receiverLocalName: input.receiverLocalName,
|
|
88
|
+
localReferenceName: input.localReferenceName,
|
|
89
|
+
expressionText: input.expressionText,
|
|
90
|
+
jsxPropRecordId: input.jsxPropRecordId,
|
|
91
|
+
scopeReferenceRecordId: input.scopeReferenceRecordId,
|
|
92
|
+
conditionalRuntimePresence: input.conditionalRuntimePresence,
|
|
93
|
+
signatureHash
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function cssModuleAccessBlocker(binding, sourceText, start, end, reasonCode, expressionText, extra = {}) {
|
|
98
|
+
return cssModuleBindingBlocker(binding, {
|
|
99
|
+
sourceSpan: sourceSpanForRange(sourceText, binding.sourcePath, binding.sourceHash, start, end),
|
|
100
|
+
expressionText,
|
|
101
|
+
reasonCode,
|
|
102
|
+
...extra
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function cssModulePropBlocker(binding, prop, reasonCode) {
|
|
107
|
+
return cssModuleBindingBlocker(binding, {
|
|
108
|
+
sourcePath: prop.sourcePath,
|
|
109
|
+
sourceHash: prop.sourceHash,
|
|
110
|
+
sourceSpan: prop.sourceSpan,
|
|
111
|
+
expressionText: prop.propValueExpressionText ?? prop.propValueText ?? prop.propValueDynamicText,
|
|
112
|
+
reasonCode,
|
|
113
|
+
jsxPropRecordId: prop.id
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function cssModuleBindingBlocker(binding, input = {}) {
|
|
118
|
+
const sourcePath = input.sourcePath ?? binding.sourcePath;
|
|
119
|
+
const sourceHash = input.sourceHash ?? binding.sourceHash;
|
|
120
|
+
const reasonCode = input.reasonCode ?? 'css-module-import-resolution-unproved';
|
|
121
|
+
const expressionText = input.expressionText ?? binding.localName ?? binding.moduleSpecifier;
|
|
122
|
+
const blockerHash = hashSemanticValue({
|
|
123
|
+
kind: 'frontier.lang.cssModuleUseSiteBlocker.v1',
|
|
124
|
+
binding: binding.signatureHash,
|
|
125
|
+
reasonCode,
|
|
126
|
+
sourcePath,
|
|
127
|
+
sourceSpan: semanticSpanForHash(input.sourceSpan),
|
|
128
|
+
expressionText
|
|
129
|
+
});
|
|
130
|
+
return compactRecord({
|
|
131
|
+
id: `css_module_blocker_${idFragment(binding.id)}_${idFragment(blockerHash)}`,
|
|
132
|
+
kind: 'css-module-use-site-blocker',
|
|
133
|
+
sourcePath,
|
|
134
|
+
sourceHash,
|
|
135
|
+
sourceSpan: input.sourceSpan,
|
|
136
|
+
moduleSpecifier: binding.moduleSpecifier,
|
|
137
|
+
localName: binding.localName,
|
|
138
|
+
cssModuleImportBindingId: binding.id,
|
|
139
|
+
cssModuleSourcePath: binding.cssModuleSourcePath,
|
|
140
|
+
expressionText,
|
|
141
|
+
reasonCode,
|
|
142
|
+
writeOperation: input.writeOperation,
|
|
143
|
+
jsxPropRecordId: input.jsxPropRecordId,
|
|
144
|
+
failClosed: true,
|
|
145
|
+
semanticEquivalenceClaim: false,
|
|
146
|
+
signatureHash: blockerHash
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function cssModuleTransformBlockers(binding) {
|
|
151
|
+
const blockers = [];
|
|
152
|
+
if (binding.cssModuleEvidenceStatus !== 'supplied') blockers.push(cssModuleBindingBlocker(binding, { reasonCode: 'css-module-import-resolution-unproved' }));
|
|
153
|
+
if (!binding.generatedClassNameMapHash) blockers.push(cssModuleBindingBlocker(binding, { reasonCode: 'css-module-generated-class-map-unproved' }));
|
|
154
|
+
if (!binding.bundlerTransformHash) blockers.push(cssModuleBindingBlocker(binding, { reasonCode: 'css-module-bundler-transform-identity-unproved' }));
|
|
155
|
+
if (!binding.sourceMapProofHash) blockers.push(cssModuleBindingBlocker(binding, { reasonCode: 'css-module-source-map-proof-unproved' }));
|
|
156
|
+
return blockers;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function cssModuleMissingExportBlockers(bindingsById, useSites) {
|
|
160
|
+
return useSites
|
|
161
|
+
.filter((site) => cssModuleExportNameMissing(bindingsById.get(site.cssModuleImportBindingId), site.exportName))
|
|
162
|
+
.map((site) => cssModuleBindingBlocker(bindingsById.get(site.cssModuleImportBindingId), {
|
|
163
|
+
sourcePath: site.jsSourcePath,
|
|
164
|
+
sourceHash: site.jsSourceHash,
|
|
165
|
+
sourceSpan: site.sourceSpan,
|
|
166
|
+
expressionText: site.expressionText,
|
|
167
|
+
reasonCode: 'css-module-export-name-unresolved'
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function cssModuleExportNameMissing(binding, exportName) {
|
|
172
|
+
if (!binding || !exportName || !Array.isArray(binding.cssModuleExportNames)) return false;
|
|
173
|
+
return !binding.cssModuleExportNames.includes(exportName);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function cssModuleUseSiteGraphRecords(importBindings, useSites, blockers) {
|
|
177
|
+
return [...groupBy(importBindings, (binding) => binding.cssModuleSourcePath).values()].map((bindings) => {
|
|
178
|
+
const cssModuleSourcePath = bindings[0]?.cssModuleSourcePath;
|
|
179
|
+
const bindingIds = new Set(bindings.map((binding) => binding.id));
|
|
180
|
+
const graphUseSites = useSites.filter((site) => bindingIds.has(site.cssModuleImportBindingId));
|
|
181
|
+
const graphBlockers = blockers.filter((blocker) => bindingIds.has(blocker.cssModuleImportBindingId));
|
|
182
|
+
return cssModuleUseSiteGraphRecord(cssModuleSourcePath, bindings, graphUseSites, graphBlockers);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function cssModuleUseSiteGraphRecord(cssModuleSourcePath, bindings, graphUseSites, graphBlockers) {
|
|
187
|
+
const graphHash = hashSemanticValue({
|
|
188
|
+
kind: 'frontier.lang.cssModuleUseSiteGraph.v1',
|
|
189
|
+
cssModuleSourcePath,
|
|
190
|
+
bindings: bindings.map((binding) => binding.signatureHash).sort(),
|
|
191
|
+
useSites: graphUseSites.map((site) => site.signatureHash).sort(),
|
|
192
|
+
blockers: graphBlockers.map((blocker) => blocker.signatureHash).sort()
|
|
193
|
+
});
|
|
194
|
+
return compactRecord({
|
|
195
|
+
kind: 'frontier.lang.cssModuleUseSiteGraph',
|
|
196
|
+
version: 1,
|
|
197
|
+
cssModuleSourcePath,
|
|
198
|
+
cssModuleHash: bindings[0]?.cssModuleHash,
|
|
199
|
+
cssModuleSourceHash: bindings[0]?.cssModuleSourceHash,
|
|
200
|
+
importBindingIds: bindings.map((binding) => binding.id),
|
|
201
|
+
useSiteIds: graphUseSites.map((site) => site.id),
|
|
202
|
+
blockerIds: graphBlockers.map((blocker) => blocker.id),
|
|
203
|
+
importBindingCount: bindings.length,
|
|
204
|
+
useSiteCount: graphUseSites.length,
|
|
205
|
+
blockerCount: graphBlockers.length,
|
|
206
|
+
generatedClassNameMapHash: bindings.find((binding) => binding.generatedClassNameMapHash)?.generatedClassNameMapHash,
|
|
207
|
+
cssModuleExportNamesHash: bindings.find((binding) => binding.cssModuleExportNamesHash)?.cssModuleExportNamesHash,
|
|
208
|
+
bundlerTransformHash: bindings.find((binding) => binding.bundlerTransformHash)?.bundlerTransformHash,
|
|
209
|
+
sourceMapProofHash: bindings.find((binding) => binding.sourceMapProofHash)?.sourceMapProofHash,
|
|
210
|
+
status: graphBlockers.length ? 'blocked' : 'ready',
|
|
211
|
+
graphHash,
|
|
212
|
+
autoMergeClaim: false,
|
|
213
|
+
semanticEquivalenceClaim: false
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function cssModuleExportHash(binding, exportName) {
|
|
218
|
+
if (!exportName || !Array.isArray(binding.cssModuleExportNames) || !binding.cssModuleExportNames.includes(exportName)) return undefined;
|
|
219
|
+
return hashSemanticValue({ kind: 'frontier.lang.cssModuleExport.v1', cssModuleHash: binding.cssModuleHash, exportName });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function cssModuleEvidenceExportNames(evidence) {
|
|
223
|
+
return uniqueSortedStrings([
|
|
224
|
+
...arrayValue(evidence?.exportNames),
|
|
225
|
+
...arrayValue(evidence?.localClassNames),
|
|
226
|
+
...arrayValue(evidence?.classNames),
|
|
227
|
+
...objectKeys(evidence?.exports),
|
|
228
|
+
...objectKeys(evidence?.generatedClassNameMap),
|
|
229
|
+
...objectKeys(evidence?.classMap)
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function cssModuleGeneratedClassNameMapHash(evidence) {
|
|
234
|
+
const map = objectValue(evidence?.generatedClassNameMap) ?? objectValue(evidence?.classMap) ?? objectValue(evidence?.exports);
|
|
235
|
+
return map ? hashSemanticValue({ kind: 'frontier.lang.cssModuleGeneratedClassNameMap.v1', map }) : undefined;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function arrayValue(value) {
|
|
239
|
+
return Array.isArray(value) ? value : [];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function objectKeys(value) {
|
|
243
|
+
const object = objectValue(value);
|
|
244
|
+
return object ? Object.keys(object) : [];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function objectValue(value) {
|
|
248
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function uniqueSortedStrings(values) {
|
|
252
|
+
return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))].sort();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
cssModuleAccessBlocker,
|
|
257
|
+
cssModuleBindingBlocker,
|
|
258
|
+
cssModuleImportBindingRecord,
|
|
259
|
+
cssModuleMissingExportBlockers,
|
|
260
|
+
cssModulePropBlocker,
|
|
261
|
+
cssModuleTransformBlockers,
|
|
262
|
+
cssModuleUseSiteGraphRecords,
|
|
263
|
+
cssModuleUseSiteRecord
|
|
264
|
+
};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { readStaticMemberLiteral } from './staticMemberLiteral.js';
|
|
2
|
+
import {
|
|
3
|
+
bindingsForSourcePath,
|
|
4
|
+
escapeRegExp,
|
|
5
|
+
isIdentifierChar,
|
|
6
|
+
localKey,
|
|
7
|
+
sourceSpanForRange
|
|
8
|
+
} from './projectSymbolGraphCssModuleUtils.js';
|
|
9
|
+
import {
|
|
10
|
+
cssModuleAccessBlocker,
|
|
11
|
+
cssModulePropBlocker,
|
|
12
|
+
cssModuleUseSiteRecord
|
|
13
|
+
} from './projectSymbolGraphCssModuleRecords.js';
|
|
14
|
+
|
|
15
|
+
const IdentifierPattern = /^[A-Za-z_$][\w$]*$/;
|
|
16
|
+
|
|
17
|
+
function cssModuleLexicalUseSites(importBindings, sourceTextsByPath) {
|
|
18
|
+
const useSites = [];
|
|
19
|
+
const blockers = [];
|
|
20
|
+
for (const binding of importBindings) {
|
|
21
|
+
if (!binding.localName) continue;
|
|
22
|
+
if (binding.importKind !== 'default' && binding.importKind !== 'namespace') continue;
|
|
23
|
+
const sourceText = sourceTextsByPath.get(binding.sourcePath);
|
|
24
|
+
if (typeof sourceText !== 'string') {
|
|
25
|
+
blockers.push(cssModuleAccessBlocker(binding, '', 0, 0, 'css-module-import-resolution-unproved'));
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
useSites.push(...cssModuleDestructuringUseSites(binding, sourceText, blockers));
|
|
29
|
+
useSites.push(...cssModuleMemberUseSites(binding, sourceText, blockers));
|
|
30
|
+
}
|
|
31
|
+
return { useSites, blockers };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function cssModuleMemberUseSites(binding, sourceText, blockers) {
|
|
35
|
+
const useSites = [];
|
|
36
|
+
for (const occurrence of identifierOccurrences(sourceText, binding.localName)) {
|
|
37
|
+
const access = cssModuleMemberAccess(sourceText, occurrence.end);
|
|
38
|
+
if (!access) continue;
|
|
39
|
+
if (access.status === 'blocked') {
|
|
40
|
+
blockers.push(cssModuleAccessBlocker(binding, sourceText, occurrence.start, access.end ?? occurrence.end, access.reasonCode, access.expressionText));
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const writeOperation = memberWriteOperation(sourceText, occurrence.start, access.end);
|
|
44
|
+
if (writeOperation) {
|
|
45
|
+
blockers.push(cssModuleAccessBlocker(binding, sourceText, occurrence.start, access.end, 'css-module-member-write-unsupported', sourceText.slice(occurrence.start, access.end), { writeOperation }));
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
useSites.push(cssModuleUseSiteRecord(binding, {
|
|
49
|
+
useSiteKind: 'scope-member-read',
|
|
50
|
+
accessKind: access.accessKind,
|
|
51
|
+
exportName: access.memberName,
|
|
52
|
+
receiverLocalName: binding.localName,
|
|
53
|
+
expressionText: sourceText.slice(occurrence.start, access.end),
|
|
54
|
+
sourcePath: binding.sourcePath,
|
|
55
|
+
sourceHash: binding.sourceHash,
|
|
56
|
+
sourceSpan: sourceSpanForRange(sourceText, binding.sourcePath, binding.sourceHash, occurrence.start, access.end)
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
return useSites;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function cssModuleDestructuringUseSites(binding, sourceText, blockers) {
|
|
63
|
+
const useSites = [];
|
|
64
|
+
const pattern = new RegExp(`\\b(?:const|let|var)\\s*\\{([\\s\\S]*?)\\}\\s*=\\s*${escapeRegExp(binding.localName)}\\b`, 'g');
|
|
65
|
+
for (const match of sourceText.matchAll(pattern)) {
|
|
66
|
+
const body = match[1] ?? '';
|
|
67
|
+
const bodyStart = match.index + match[0].indexOf(body);
|
|
68
|
+
for (const part of splitTopLevelComma(body, bodyStart)) {
|
|
69
|
+
const text = part.text.trim();
|
|
70
|
+
if (!text) continue;
|
|
71
|
+
if (text.startsWith('...')) {
|
|
72
|
+
blockers.push(cssModuleAccessBlocker(binding, sourceText, part.offset, part.offset + part.text.length, 'css-module-destructuring-rest-unsupported', part.text));
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const property = destructuringProperty(text);
|
|
76
|
+
if (!property?.exportName) continue;
|
|
77
|
+
useSites.push(cssModuleUseSiteRecord(binding, {
|
|
78
|
+
useSiteKind: 'destructured-binding',
|
|
79
|
+
accessKind: 'destructure',
|
|
80
|
+
exportName: property.exportName,
|
|
81
|
+
receiverLocalName: binding.localName,
|
|
82
|
+
localReferenceName: property.localName,
|
|
83
|
+
expressionText: text,
|
|
84
|
+
sourcePath: binding.sourcePath,
|
|
85
|
+
sourceHash: binding.sourceHash,
|
|
86
|
+
sourceSpan: sourceSpanForRange(sourceText, binding.sourcePath, binding.sourceHash, part.offset, part.offset + part.text.length)
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return useSites;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function cssModuleJsxUseSites(bindingsByLocal, jsxPropRecords) {
|
|
94
|
+
const useSites = [];
|
|
95
|
+
const blockers = [];
|
|
96
|
+
for (const prop of jsxPropRecords ?? []) {
|
|
97
|
+
const root = prop.propValueReferenceRoot;
|
|
98
|
+
const sourceBindings = root ? bindingsByLocal.get(localKey(prop.sourcePath, root)) ?? [] : [];
|
|
99
|
+
useSites.push(...cssModuleJsxStaticUseSites(sourceBindings, prop));
|
|
100
|
+
const classNameBindings = bindingsForSourcePath(bindingsByLocal, prop.sourcePath);
|
|
101
|
+
if (prop.propName !== 'className' || !classNameBindings.length) continue;
|
|
102
|
+
blockers.push(...cssModuleJsxBlockers(classNameBindings, prop));
|
|
103
|
+
}
|
|
104
|
+
return { useSites, blockers };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function cssModuleJsxStaticUseSites(sourceBindings, prop) {
|
|
108
|
+
if (prop.propName !== 'className' || prop.propValueKind !== 'reference') return [];
|
|
109
|
+
const referencePath = prop.propValueReferencePath ?? [];
|
|
110
|
+
if (referencePath.length < 2) return [];
|
|
111
|
+
return sourceBindings.map((binding) => cssModuleUseSiteRecord(binding, {
|
|
112
|
+
useSiteKind: 'jsx-className',
|
|
113
|
+
accessKind: 'dot',
|
|
114
|
+
exportName: referencePath[1],
|
|
115
|
+
receiverLocalName: referencePath[0],
|
|
116
|
+
expressionText: prop.propValueExpressionText,
|
|
117
|
+
sourcePath: prop.sourcePath,
|
|
118
|
+
sourceHash: prop.sourceHash,
|
|
119
|
+
sourceSpan: prop.sourceSpan,
|
|
120
|
+
jsxPropRecordId: prop.id
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function cssModuleJsxBlockers(classNameBindings, prop) {
|
|
125
|
+
if (prop.propValueKind === 'string') {
|
|
126
|
+
return classNameBindings.map((binding) => cssModulePropBlocker(binding, prop, 'css-module-string-literal-classname-unproved'));
|
|
127
|
+
}
|
|
128
|
+
if (!prop.propValueDynamicBlockerReasonCode) return [];
|
|
129
|
+
const expressionText = prop.propValueExpressionText ?? prop.propValueDynamicText ?? '';
|
|
130
|
+
return classNameBindings
|
|
131
|
+
.filter((binding) => expressionText.includes(binding.localName))
|
|
132
|
+
.map((binding) => cssModulePropBlocker(binding, prop, jsxDynamicReason(prop.propValueDynamicBlockerReasonCode)));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function cssModuleMemberAccess(sourceText, receiverEnd) {
|
|
136
|
+
let index = receiverEnd;
|
|
137
|
+
while (index < sourceText.length && /\s/.test(sourceText[index])) index += 1;
|
|
138
|
+
if (sourceText[index] === '?' && sourceText[index + 1] === '.') index += 2;
|
|
139
|
+
else if (sourceText[index] === '.') index += 1;
|
|
140
|
+
else if (sourceText[index] === '[') return cssModuleComputedAccess(sourceText, index);
|
|
141
|
+
else return undefined;
|
|
142
|
+
while (index < sourceText.length && /\s/.test(sourceText[index])) index += 1;
|
|
143
|
+
const match = /^[A-Za-z_$][\w$]*/.exec(sourceText.slice(index));
|
|
144
|
+
return match ? { accessKind: 'dot', memberName: match[0], end: index + match[0].length } : undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function cssModuleComputedAccess(sourceText, open) {
|
|
148
|
+
const close = findMatchingBracket(sourceText, open);
|
|
149
|
+
if (close === -1) return { status: 'blocked', reasonCode: 'css-module-dynamic-member-access-unproved', end: open + 1 };
|
|
150
|
+
let index = open + 1;
|
|
151
|
+
while (index < close && /\s/.test(sourceText[index])) index += 1;
|
|
152
|
+
const literal = readStaticMemberLiteral(sourceText, index, close);
|
|
153
|
+
if (!literal || !IdentifierPattern.test(literal.value)) {
|
|
154
|
+
return { status: 'blocked', reasonCode: 'css-module-dynamic-member-access-unproved', end: close + 1, expressionText: sourceText.slice(open, close + 1) };
|
|
155
|
+
}
|
|
156
|
+
return { accessKind: literal.literalKind === 'static-template-literal' ? 'static-template' : 'static-bracket', memberName: literal.value, end: close + 1 };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function memberWriteOperation(sourceText, start, end) {
|
|
160
|
+
if (hasPrefixUpdateOperator(sourceText, start)) return 'update';
|
|
161
|
+
let index = end;
|
|
162
|
+
while (index < sourceText.length && /\s/.test(sourceText[index])) index += 1;
|
|
163
|
+
if (sourceText.slice(index, index + 2) === '++' || sourceText.slice(index, index + 2) === '--') return 'update';
|
|
164
|
+
return assignmentOperatorAt(sourceText, index) ? 'assignment' : undefined;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function assignmentOperatorAt(code, index) {
|
|
168
|
+
for (const operator of ['>>>=', '**=', '<<=', '>>=', '&&=', '||=', '??=', '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '=']) {
|
|
169
|
+
if (!code.startsWith(operator, index)) continue;
|
|
170
|
+
if (operator === '=' && (code[index + 1] === '=' || code[index + 1] === '>')) return undefined;
|
|
171
|
+
return operator;
|
|
172
|
+
}
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function hasPrefixUpdateOperator(code, tokenStart) {
|
|
177
|
+
let index = tokenStart - 1;
|
|
178
|
+
while (index >= 0 && /\s/.test(code[index])) index -= 1;
|
|
179
|
+
const operator = code.slice(index - 1, index + 1);
|
|
180
|
+
if (operator !== '++' && operator !== '--') return false;
|
|
181
|
+
let before = index - 2;
|
|
182
|
+
while (before >= 0 && /\s/.test(code[before])) before -= 1;
|
|
183
|
+
return before < 0 || !/[A-Za-z0-9_$)\]]/.test(code[before]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function findMatchingBracket(sourceText, open) {
|
|
187
|
+
let depth = 0;
|
|
188
|
+
for (let index = open; index < sourceText.length; index += 1) {
|
|
189
|
+
if (sourceText[index] === '[') depth += 1;
|
|
190
|
+
else if (sourceText[index] === ']' && --depth === 0) return index;
|
|
191
|
+
}
|
|
192
|
+
return -1;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function destructuringProperty(text) {
|
|
196
|
+
const value = String(text ?? '').trim();
|
|
197
|
+
const [rawName, rawLocal] = value.split(':').map((part) => part.trim());
|
|
198
|
+
const exportName = rawName?.match(/^([A-Za-z_$][\w$]*)$/)?.[1];
|
|
199
|
+
const localName = (rawLocal ?? rawName)?.match(/^([A-Za-z_$][\w$]*)$/)?.[1];
|
|
200
|
+
return exportName ? { exportName, localName } : undefined;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function splitTopLevelComma(text, baseOffset) {
|
|
204
|
+
const parts = [];
|
|
205
|
+
let start = 0;
|
|
206
|
+
let brace = 0, bracket = 0, paren = 0;
|
|
207
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
208
|
+
const char = text[index];
|
|
209
|
+
if (char === '{') brace += 1;
|
|
210
|
+
else if (char === '}') brace = Math.max(0, brace - 1);
|
|
211
|
+
else if (char === '[') bracket += 1;
|
|
212
|
+
else if (char === ']') bracket = Math.max(0, bracket - 1);
|
|
213
|
+
else if (char === '(') paren += 1;
|
|
214
|
+
else if (char === ')') paren = Math.max(0, paren - 1);
|
|
215
|
+
if (char === ',' && brace === 0 && bracket === 0 && paren === 0) {
|
|
216
|
+
parts.push({ text: text.slice(start, index), offset: baseOffset + start });
|
|
217
|
+
start = index + 1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
parts.push({ text: text.slice(start), offset: baseOffset + start });
|
|
221
|
+
return parts;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function identifierOccurrences(sourceText, name) {
|
|
225
|
+
const result = [];
|
|
226
|
+
const pattern = new RegExp(`\\b${escapeRegExp(name)}\\b`, 'g');
|
|
227
|
+
for (const match of sourceText.matchAll(pattern)) {
|
|
228
|
+
const start = match.index;
|
|
229
|
+
const end = start + name.length;
|
|
230
|
+
if (isIdentifierChar(sourceText[start - 1]) || isIdentifierChar(sourceText[end])) continue;
|
|
231
|
+
result.push({ start, end });
|
|
232
|
+
}
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function jsxDynamicReason(reasonCode) {
|
|
237
|
+
if (reasonCode.includes('call')) return 'css-module-helper-call-unproved';
|
|
238
|
+
if (reasonCode.includes('computed')) return 'css-module-dynamic-member-access-unproved';
|
|
239
|
+
return 'css-module-helper-dynamic-argument-unsupported';
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export { cssModuleJsxUseSites, cssModuleLexicalUseSites };
|