@shapeshift-labs/frontier-lang-compiler 0.2.191 → 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;
|
|
@@ -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