@shapeshift-labs/frontier-lang-compiler 0.2.190 → 0.2.192

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.
@@ -110,6 +110,8 @@ export interface JsTsProjectSafeMergeInput {
110
110
  readonly globalAugmentationCompatibilityProofs?: readonly JsTsProjectGlobalAugmentationCompatibilityProof[]; readonly jsxRenderReturnBranchProof?: JsTsProjectJsxRenderReturnBranchProof; readonly jsxRenderReturnBranchProofs?: readonly JsTsProjectJsxRenderReturnBranchProof[]; readonly externalSemanticEquivalenceProof?: JsTsProjectSemanticEquivalenceProof; readonly semanticEquivalenceProof?: JsTsProjectSemanticEquivalenceProof;
111
111
  readonly htmlMergeOptions?: JsTsProjectHtmlCssMergeOptions; readonly markupMergeOptions?: JsTsProjectHtmlCssMergeOptions; readonly htmlMergeOptionsByPath?: Readonly<Record<string,JsTsProjectHtmlCssMergeOptions>>; readonly markupMergeOptionsByPath?: Readonly<Record<string,JsTsProjectHtmlCssMergeOptions>>;
112
112
  readonly cssMergeOptions?: JsTsProjectHtmlCssMergeOptions; readonly styleMergeOptions?: JsTsProjectHtmlCssMergeOptions; readonly cssMergeOptionsByPath?: Readonly<Record<string,JsTsProjectHtmlCssMergeOptions>>; readonly styleMergeOptionsByPath?: Readonly<Record<string,JsTsProjectHtmlCssMergeOptions>>;
113
+ readonly disableProjectCssDependencyGraphProofSynthesis?: boolean;
114
+ readonly disableProjectCssModuleProofSynthesis?: boolean;
113
115
  readonly moduleResolution?: NativeProjectModuleResolutionOptions;
114
116
  readonly tsconfig?: JsTsProjectTsconfigInput | NativeProjectModuleResolutionOptions;
115
117
  readonly projectReferences?: JsTsProjectReferencesInput;
@@ -1,5 +1,41 @@
1
1
  export {};
2
2
 
3
+ export interface NativeProjectSymbolGraphCompilerAdvancedTypeProofRequirement {
4
+ readonly kind: 'typescript-checker-public-api-advanced-type-shape-equivalence' | string;
5
+ readonly requiredEvidence?: 'typescript-checker-public-api-type-equivalence' | string;
6
+ readonly status?: 'requires-type-equivalence-proof' | 'missing-compiler-evidence' | 'requires-review' | string;
7
+ readonly requiredSignals?: readonly string[];
8
+ readonly missingSignals?: readonly string[];
9
+ readonly unsupportedSignals?: readonly string[];
10
+ readonly advancedTypeShapeCount?: number;
11
+ readonly advancedTypeShapeKinds?: readonly string[];
12
+ readonly conditionalTypeCount?: number;
13
+ readonly mappedTypeCount?: number;
14
+ readonly indexedAccessTypeCount?: number;
15
+ readonly keyofTypeOperatorCount?: number;
16
+ readonly templateLiteralTypeCount?: number;
17
+ readonly inferTypeCount?: number;
18
+ readonly unionTypeCount?: number;
19
+ readonly intersectionTypeCount?: number;
20
+ readonly tupleTypeCount?: number;
21
+ readonly sourcePath?: string;
22
+ readonly sourceHash?: string;
23
+ readonly sourceBound?: boolean;
24
+ readonly autoMergeClaim: false;
25
+ readonly semanticEquivalenceClaim: false;
26
+ }
27
+
28
+ export interface NativeProjectSymbolGraphCompilerAdvancedTypeMissingProof {
29
+ readonly kind: 'typescript-checker-public-api-advanced-type-shape-equivalence' | string;
30
+ readonly requiredEvidence?: 'typescript-checker-public-api-type-equivalence' | string;
31
+ readonly status?: 'missing-compiler-evidence' | 'requires-review' | string;
32
+ readonly reasonCode?: 'typescript-public-api-advanced-type-shape-proof-missing' | 'typescript-public-api-advanced-type-shape-proof-requires-review' | string;
33
+ readonly missingSignals?: readonly string[];
34
+ readonly unsupportedSignals?: readonly string[];
35
+ readonly autoMergeClaim: false;
36
+ readonly semanticEquivalenceClaim: false;
37
+ }
38
+
3
39
  declare module './native-project-compiler-scope.js' {
4
40
  interface NativeProjectSymbolGraphCompilerAdvancedTypeShapeRecord {
5
41
  readonly memberTypeTexts?: readonly string[];
@@ -11,8 +47,13 @@ declare module './native-project-compiler-scope.js' {
11
47
  readonly unionTypeSetHash?: string;
12
48
  readonly intersectionTypeSetHash?: string;
13
49
  readonly tupleTypeSetHash?: string;
50
+ readonly unionTypeCount?: number;
51
+ readonly intersectionTypeCount?: number;
52
+ readonly tupleTypeCount?: number;
14
53
  }
15
54
  interface NativeProjectSymbolGraphCompilerTypeRecord {
55
+ readonly advancedTypeProofRequirement?: NativeProjectSymbolGraphCompilerAdvancedTypeProofRequirement;
56
+ readonly advancedTypeMissingProof?: NativeProjectSymbolGraphCompilerAdvancedTypeMissingProof;
16
57
  readonly unionTypeCount?: number;
17
58
  readonly intersectionTypeCount?: number;
18
59
  readonly tupleTypeCount?: number;
@@ -5,3 +5,15 @@ export interface NativeProjectSymbolGraphCompilerIndexSignatureRecord {
5
5
  readonly readonly?: boolean;
6
6
  readonly declarationText?: string;
7
7
  }
8
+
9
+ declare module './native-project-compiler-scope.js' {
10
+ interface NativeProjectSymbolGraphCompilerTypeEquivalenceProof {
11
+ readonly indexSignatureSetHash?: string;
12
+ readonly indexSignatureCount?: number;
13
+ readonly indexSignatureReadonlyCount?: number;
14
+ }
15
+
16
+ interface NativeProjectSymbolGraphCompilerTypeRecord {
17
+ readonly indexSignatureReadonlyCount?: number;
18
+ }
19
+ }
@@ -4,5 +4,6 @@ declare module './native-project-compiler-scope.js' {
4
4
  interface NativeProjectSymbolGraphCompilerTypeEquivalenceProof {
5
5
  readonly sourcePath?: string;
6
6
  readonly sourceHash?: string;
7
+ readonly sourceBoundPublicApi?: boolean;
7
8
  }
8
9
  }
@@ -0,0 +1,106 @@
1
+ import { hashText, safeId } from './js-ts-safe-project-merge-core.js';
2
+
3
+ const CssDependencyGraphProofGap = 'css-dependency-graph-proof-unproved';
4
+ const CssDependencyGraphConflict = 'css-dependency-graph-proof-blocked';
5
+ const ProjectProofLevel = 'css-custom-property-dependency-graph-project-source-bound';
6
+ const SourceBoundDependencyGraphProofKind = 'css-source-bound-dependency-graph-proof';
7
+ const SynthesizableDependencyKinds = new Set(['custom-property-definition', 'custom-property-reference']);
8
+
9
+ function projectCssDependencyProofOptionsForBlockedMerge(input) {
10
+ const { projectInput, sourcePath, firstResult, base, worker, head } = input;
11
+ if (projectInput?.disableProjectCssDependencyGraphProofSynthesis === true) return undefined;
12
+ if (firstResult?.status !== 'blocked' || typeof firstResult.candidateMergedSourceText !== 'string' || !firstResult.candidateMergedSourceHash) return undefined;
13
+ const evidence = firstResult.dependencyGraphEvidence;
14
+ const conflicts = dependencyGraphProofConflicts(firstResult);
15
+ if (!evidence?.changedDependencySurfaces?.length || !conflicts.length) return undefined;
16
+ const changesByKey = new Map(evidence.changedDependencySurfaces.map((change) => [dependencyChangeKey(change), change]));
17
+ const proofChanges = conflicts
18
+ .map((conflict) => changesByKey.get(dependencyConflictKey(conflict)) ?? dependencyChangeFromConflict(conflict))
19
+ .filter((change) => change?.reasonCode === CssDependencyGraphProofGap && canSynthesizeDependencyChange(change));
20
+ if (!proofChanges.length) return undefined;
21
+ return {
22
+ mergeOptions: {
23
+ cssDependencyGraphProofs: proofChanges.map((change, index) => projectCssDependencyGraphProof({ sourcePath, evidence, change, firstResult, base, worker, head, index }))
24
+ }
25
+ };
26
+ }
27
+
28
+ function dependencyGraphProofConflicts(result) {
29
+ return (result.conflicts ?? []).filter((conflict) => conflict.code === CssDependencyGraphConflict && conflict.details?.reasonCode === CssDependencyGraphProofGap);
30
+ }
31
+
32
+ function dependencyChangeFromConflict(conflict) {
33
+ const details = conflict?.details;
34
+ if (!details?.side || !details?.cascadeKey) return undefined;
35
+ return {
36
+ side: details.side,
37
+ cascadeKey: details.cascadeKey,
38
+ reasonCode: details.reasonCode,
39
+ changeKind: details.changeKind,
40
+ before: details.before,
41
+ after: details.after
42
+ };
43
+ }
44
+
45
+ function canSynthesizeDependencyChange(change) {
46
+ const kinds = uniqueStrings([...(change.before?.dependencyKinds ?? []), ...(change.after?.dependencyKinds ?? [])]);
47
+ return kinds.length > 0 && kinds.every((kind) => SynthesizableDependencyKinds.has(kind));
48
+ }
49
+
50
+ function projectCssDependencyGraphProof({ sourcePath, evidence, change, firstResult, base, worker, head, index }) {
51
+ return {
52
+ id: `project_css_dependency_graph_${safeId(sourcePath)}_${index}`,
53
+ kind: SourceBoundDependencyGraphProofKind,
54
+ status: 'passed',
55
+ proofLevel: ProjectProofLevel,
56
+ sourcePath,
57
+ reasonCode: change.reasonCode,
58
+ side: change.side,
59
+ cascadeKey: change.cascadeKey,
60
+ dependencyKinds: uniqueStrings([...(change.before?.dependencyKinds ?? []), ...(change.after?.dependencyKinds ?? [])]),
61
+ baseSourceHash: hashText(base),
62
+ workerSourceHash: hashText(worker),
63
+ headSourceHash: hashText(head),
64
+ outputSourceHash: firstResult.candidateMergedSourceHash,
65
+ dependencyGraphHashes: dependencyGraphHashes(evidence),
66
+ cssDependencyGraphHashes: cssDependencyGraphHashes(evidence),
67
+ browserCascadeEquivalenceClaim: false,
68
+ browserRenderEquivalenceClaim: false,
69
+ semanticEquivalenceClaim: false
70
+ };
71
+ }
72
+
73
+ function dependencyGraphHashes(evidence) {
74
+ return compactRecord({
75
+ base: evidence.sides?.base?.dependencyGraphHash,
76
+ worker: evidence.sides?.worker?.dependencyGraphHash,
77
+ head: evidence.sides?.head?.dependencyGraphHash
78
+ });
79
+ }
80
+
81
+ function cssDependencyGraphHashes(evidence) {
82
+ return compactRecord({
83
+ base: evidence.sides?.base?.cssDependencyGraphHash,
84
+ worker: evidence.sides?.worker?.cssDependencyGraphHash,
85
+ head: evidence.sides?.head?.cssDependencyGraphHash
86
+ });
87
+ }
88
+
89
+ function dependencyChangeKey(change) {
90
+ return `${change?.side ?? ''}#${change?.cascadeKey ?? ''}#${change?.reasonCode ?? ''}`;
91
+ }
92
+
93
+ function dependencyConflictKey(conflict) {
94
+ const details = conflict?.details ?? {};
95
+ return `${details.side ?? ''}#${details.cascadeKey ?? ''}#${details.reasonCode ?? ''}`;
96
+ }
97
+
98
+ function uniqueStrings(values) {
99
+ return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))];
100
+ }
101
+
102
+ function compactRecord(record) {
103
+ return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
104
+ }
105
+
106
+ export { projectCssDependencyProofOptionsForBlockedMerge };
@@ -2,6 +2,7 @@ import { safeMergeCssSource } from '@shapeshift-labs/frontier-lang-css';
2
2
  import { safeMergeHtmlSource } from '@shapeshift-labs/frontier-lang-html';
3
3
  import { compactRecord } from './js-ts-safe-merge-context.js';
4
4
  import { hashText, safeId, uniqueStrings } from './js-ts-safe-project-merge-core.js';
5
+ import { projectCssDependencyProofOptionsForBlockedMerge } from './js-ts-safe-project-merge-css-dependency-proofs.js';
5
6
  import { projectCssModuleMergeOptionsForFile, projectCssModuleProofOptionsForBlockedMerge } from './js-ts-safe-project-merge-css-module-proofs.js';
6
7
  import { htmlRuntimeBoundaryChanges, htmlRuntimeBoundaryProofForChange, htmlRuntimeBoundaryProofRecord, htmlRuntimeBoundaryProvenResult } from './js-ts-safe-project-merge-html-runtime-boundaries.js';
7
8
 
@@ -22,10 +23,16 @@ function maybeMergeHtmlCssProjectFile(options) {
22
23
  const runtimeBoundaryProofs = language === 'html' ? htmlRuntimeBoundaryProofCandidates(input, file.sourcePath, mergeOptions) : [];
23
24
  const runtimeBoundaryMergeOptions = runtimeBoundaryProofs.length ? { htmlRuntimeBoundaryProofs: runtimeBoundaryProofs, htmlSourceBoundRuntimeBoundaryProofs: runtimeBoundaryProofs } : {};
24
25
  let result = merge({ ...sourceInput, ...mergeOptions, ...context, ...runtimeBoundaryMergeOptions, id: resultId, baseSourceText: base, workerSourceText: worker, headSourceText: head, includeBlockedMergeCandidate: language === 'css' || sourceInput.includeBlockedMergeCandidate === true });
26
+ if (language === 'css' && result.status === 'blocked') {
27
+ const proofOptions = projectCssDependencyProofOptionsForBlockedMerge({ projectInput: input, sourcePath: file.sourcePath, firstResult: result, base, worker, head });
28
+ if (proofOptions?.mergeOptions) {
29
+ result = merge({ ...sourceInput, ...mergeOptions, ...proofOptions.mergeOptions, ...context, id: resultId, baseSourceText: base, workerSourceText: worker, headSourceText: head, includeBlockedMergeCandidate: true });
30
+ }
31
+ }
25
32
  if (language === 'css' && result.status === 'blocked') {
26
33
  const proofOptions = projectCssModuleProofOptionsForBlockedMerge({ evidence: projectCssModuleMergeEvidence, sourcePath: file.sourcePath, mergeOptions, firstResult: result, base, worker, head });
27
34
  if (proofOptions?.mergeOptions) {
28
- result = merge({ ...sourceInput, ...mergeOptions, ...proofOptions.mergeOptions, ...context, id: resultId, baseSourceText: base, workerSourceText: worker, headSourceText: head });
35
+ result = merge({ ...sourceInput, ...mergeOptions, ...proofOptions.mergeOptions, ...context, id: resultId, baseSourceText: base, workerSourceText: worker, headSourceText: head, includeBlockedMergeCandidate: true });
29
36
  } else if (proofOptions?.result) {
30
37
  result = proofOptions.result;
31
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.190",
3
+ "version": "0.2.192",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",