@shapeshift-labs/frontier-lang-compiler 0.2.161 → 0.2.163

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.
Files changed (30) hide show
  1. package/dist/internal/index-impl/moduleHostResourceImportMetadata.js +47 -0
  2. package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +215 -1
  3. package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +1 -1
  4. package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +56 -1
  5. package/dist/internal/index-impl/projectSymbolGraphCssModules.js +48 -4
  6. package/dist/internal/index-impl/projectSymbolGraphJsxPropRecordFields.js +91 -0
  7. package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +35 -7
  8. package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +4 -31
  9. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturnCollectionHelpers.js +201 -0
  10. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturnCollections.js +210 -0
  11. package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +12 -5
  12. package/dist/internal/index-impl/projectSymbolGraphJsxSpreadPropValues.js +196 -0
  13. package/dist/internal/index-impl/projectSymbolGraphJsxStaticLiterals.js +207 -0
  14. package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +12 -14
  15. package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +33 -31
  16. package/dist/internal/index-impl/projectSymbolGraphPackageRuntimeConditions.js +22 -0
  17. package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +11 -19
  18. package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +27 -1
  19. package/dist/js-ts-safe-project-merge-admission.js +10 -0
  20. package/dist/js-ts-safe-project-merge-evidence-routing.js +30 -2
  21. package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +7 -0
  22. package/dist/js-ts-safe-project-merge-html-css-matrix.js +7 -2
  23. package/dist/js-ts-safe-project-merge-html-css-summary.js +110 -2
  24. package/dist/js-ts-safe-project-merge-html-css.js +137 -3
  25. package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +9 -0
  26. package/dist/js-ts-safe-project-merge.js +3 -0
  27. package/dist/native-source-preservation-scanner.js +10 -0
  28. package/dist/semantic-import-runtime-dynamic-import-evidence.js +141 -0
  29. package/dist/semantic-import-runtime-order-evidence.js +5 -4
  30. package/package.json +1 -1
@@ -57,6 +57,16 @@ function scanPreservedSourceTokens(sourceText, input) {
57
57
  push(trivia, 'whitespace', text, start);
58
58
  continue;
59
59
  }
60
+ if (offset === 0 && char === '#' && next === '!') {
61
+ let text = '';
62
+ while (offset < sourceText.length && sourceText[offset] !== '\n' && sourceText[offset] !== '\r') {
63
+ text += sourceText[offset];
64
+ offset += 1;
65
+ column += 1;
66
+ }
67
+ push(trivia, 'shebang', text, start);
68
+ continue;
69
+ }
60
70
  if (char === '/' && next === '/') {
61
71
  let text = '';
62
72
  while (offset < sourceText.length && sourceText[offset] !== '\n' && sourceText[offset] !== '\r') {
@@ -0,0 +1,141 @@
1
+ function dynamicImportEvidenceRecords(line, start, end) {
2
+ const expression = String(line ?? '');
3
+ const records = [];
4
+ for (const call of dynamicImportCalls(expression)) {
5
+ if (!rangesOverlap(start, end, call.start, call.end) && !rangesOverlap(start, end, call.argumentStart, call.argumentEnd)) continue;
6
+ const specifier = normalizeOrderEvidenceText(call.argumentText);
7
+ const specifierKind = dynamicImportSpecifierKind(specifier, call.closed);
8
+ const staticSpecifier = dynamicImportStaticSpecifierEvidence(specifier, specifierKind);
9
+ records.push(compactRecord({
10
+ kind: 'dynamic-import',
11
+ ordinal: records.length + 1,
12
+ text: normalizeOrderEvidenceText(call.text),
13
+ specifierText: specifier,
14
+ specifierKind,
15
+ dynamicImportStaticSpecifierEvidence: staticSpecifier,
16
+ dynamicImportRuntimeResolutionClaim: false,
17
+ dynamicImportResolutionProofRequired: !staticSpecifier,
18
+ runtimeEquivalenceClaim: false
19
+ }));
20
+ }
21
+ return records;
22
+ }
23
+
24
+ function dynamicImportCalls(expression) {
25
+ const text = String(expression ?? '');
26
+ const records = [];
27
+ let quote;
28
+ let escaped = false;
29
+ for (let index = 0; index < text.length; index += 1) {
30
+ const char = text[index];
31
+ if (quote) {
32
+ if (escaped) escaped = false;
33
+ else if (char === '\\') escaped = true;
34
+ else if (char === quote) quote = undefined;
35
+ continue;
36
+ }
37
+ if (char === '\'' || char === '"' || char === '`') { quote = char; continue; }
38
+ const match = dynamicImportAt(text, index);
39
+ if (!match) continue;
40
+ records.push(match);
41
+ index = Math.max(index, match.end - 1);
42
+ }
43
+ return records;
44
+ }
45
+
46
+ function dynamicImportAt(text, index) {
47
+ if (text.slice(index, index + 6) !== 'import' || isIdentifierPart(text[index - 1]) || isIdentifierPart(text[index + 6])) return undefined;
48
+ let cursor = index + 6;
49
+ while (/\s/.test(text[cursor] ?? '')) cursor += 1;
50
+ if (text[cursor] !== '(') return undefined;
51
+ const close = matchingParenIndex(text, cursor);
52
+ const end = close === undefined ? statementEnd(text, cursor) : close + 1;
53
+ return {
54
+ start: index,
55
+ text: text.slice(index, end),
56
+ argumentText: firstCallArgumentText(text, cursor + 1, close ?? end),
57
+ argumentStart: cursor + 1,
58
+ argumentEnd: close ?? end,
59
+ end,
60
+ closed: close !== undefined
61
+ };
62
+ }
63
+
64
+ function firstCallArgumentText(text, start, end) {
65
+ let depth = 0;
66
+ let quote;
67
+ let escaped = false;
68
+ for (let index = start; index < end; index += 1) {
69
+ const char = text[index];
70
+ if (quote) {
71
+ if (escaped) escaped = false;
72
+ else if (char === '\\') escaped = true;
73
+ else if (char === quote) quote = undefined;
74
+ continue;
75
+ }
76
+ if (char === '\'' || char === '"' || char === '`') { quote = char; continue; }
77
+ if (char === '(' || char === '[' || char === '{') depth += 1;
78
+ else if (char === ')' || char === ']' || char === '}') depth = Math.max(0, depth - 1);
79
+ else if (char === ',' && depth === 0) return text.slice(start, index);
80
+ }
81
+ return text.slice(start, end);
82
+ }
83
+
84
+ function dynamicImportSpecifierKind(specifierText, closed) {
85
+ const text = String(specifierText ?? '').trim();
86
+ if (!closed || !text) return 'unparsed';
87
+ if (isStaticStringLiteral(text) || isStaticTemplateLiteral(text)) return 'literal';
88
+ if (text.startsWith('`')) return 'template';
89
+ if (/^[A-Za-z_$][\w$]*$/.test(text)) return 'identifier';
90
+ if (/^[A-Za-z_$][\w$]*(?:(?:\.|\?\.)[A-Za-z_$][\w$]*|\[[^\]]+\])+$/.test(text)) return 'member';
91
+ if (/\?/.test(text) && /:/.test(text)) return 'conditional';
92
+ if (/[+\-*/%]|\|\||&&|\?\?/.test(text)) return 'binary';
93
+ if (/\)\s*$/.test(text)) return 'call';
94
+ return 'expression';
95
+ }
96
+
97
+ function dynamicImportStaticSpecifierEvidence(specifierText, specifierKind) {
98
+ if (specifierKind !== 'literal') return false;
99
+ return isStaticStringLiteral(specifierText) || isStaticTemplateLiteral(specifierText);
100
+ }
101
+
102
+ function dynamicImportSignatureEvidence(record) {
103
+ return compactRecord({
104
+ specifierKind: record?.specifierKind,
105
+ specifierText: record?.specifierText,
106
+ dynamicImportStaticSpecifierEvidence: record?.dynamicImportStaticSpecifierEvidence,
107
+ dynamicImportRuntimeResolutionClaim: record?.dynamicImportRuntimeResolutionClaim,
108
+ dynamicImportResolutionProofRequired: record?.dynamicImportResolutionProofRequired,
109
+ runtimeEquivalenceClaim: record?.runtimeEquivalenceClaim
110
+ });
111
+ }
112
+
113
+ function matchingParenIndex(line, open) {
114
+ if (open < 0) return undefined;
115
+ let depth = 0;
116
+ let quote;
117
+ let escaped = false;
118
+ for (let index = open; index < line.length; index += 1) {
119
+ const char = line[index];
120
+ if (quote) {
121
+ if (escaped) escaped = false;
122
+ else if (char === '\\') escaped = true;
123
+ else if (char === quote) quote = undefined;
124
+ continue;
125
+ }
126
+ if (char === '\'' || char === '"' || char === '`') { quote = char; continue; }
127
+ if (char === '(') depth += 1;
128
+ else if (char === ')' && --depth === 0) return index;
129
+ }
130
+ return undefined;
131
+ }
132
+
133
+ function rangesOverlap(leftStart, leftEnd, rightStart, rightEnd) { return Math.max(leftStart, rightStart) < Math.min(leftEnd, rightEnd); }
134
+ function normalizeOrderEvidenceText(value) { return String(value ?? '').replace(/\s+/g, ' ').trim(); }
135
+ function isStaticStringLiteral(value) { const text = String(value ?? '').trim(), quote = text[0]; return (quote === '\'' || quote === '"') && text.endsWith(quote); }
136
+ function isStaticTemplateLiteral(value) { const text = String(value ?? '').trim(); return text.startsWith('`') && text.endsWith('`') && !text.includes('${'); }
137
+ function isIdentifierPart(char) { return /[A-Za-z0-9_$]/.test(char ?? ''); }
138
+ function statementEnd(line, start) { const semicolon = line.indexOf(';', start); return semicolon === -1 ? line.length : semicolon + 1; }
139
+ function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0))); }
140
+
141
+ export { dynamicImportEvidenceRecords, dynamicImportSignatureEvidence };
@@ -9,6 +9,7 @@ import { reachabilityOrderEvidence } from './semantic-import-runtime-reachabilit
9
9
  import { throwOrderEvidenceRecords } from './semantic-import-runtime-throw-evidence.js';
10
10
  import { promiseCombinatorEvidenceRecords } from './semantic-import-runtime-promise-combinator-evidence.js';
11
11
  import { promiseChainEvidenceRecords } from './semantic-import-runtime-promise-chain-evidence.js';
12
+ import { dynamicImportEvidenceRecords, dynamicImportSignatureEvidence } from './semantic-import-runtime-dynamic-import-evidence.js';
12
13
  function semanticFactOrderInfo(groups) {
13
14
  const bySubject = new Map();
14
15
  const info = new Map();
@@ -61,6 +62,7 @@ function semanticFactRuntimeOrderEvidence(sourceText, group, fact, spanInfo, ord
61
62
  sameLineAwaitOrder: sameLineEvidence.awaitOrder,
62
63
  sameLineOptionalChain: sameLineEvidence.optionalChain,
63
64
  sameLineConditionalExpression: sameLineEvidence.conditionalExpression,
65
+ sameLineDynamicImport: sameLineEvidence.dynamicImport,
64
66
  sameLinePromiseCombinator: sameLineEvidence.promiseCombinator,
65
67
  sameLinePromiseChain: sameLineEvidence.promiseChain,
66
68
  sameLineThrow: sameLineEvidence.throw,
@@ -85,6 +87,7 @@ function semanticFactRuntimeOrderSignatureEvidence(evidence) {
85
87
  sameLineAwaitOrder: evidence?.sameLineAwaitOrder,
86
88
  sameLineOptionalChain: evidence?.sameLineOptionalChain,
87
89
  sameLineConditionalExpression: evidence?.sameLineConditionalExpression,
90
+ sameLineDynamicImport: evidence?.sameLineDynamicImport?.map(dynamicImportSignatureEvidence),
88
91
  sameLinePromiseCombinator: evidence?.sameLinePromiseCombinator,
89
92
  sameLinePromiseChain: evidence?.sameLinePromiseChain,
90
93
  sameLineThrow: evidence?.sameLineThrow,
@@ -100,7 +103,7 @@ function sameLineRuntimeOrderEvidence(line, start, end) {
100
103
  const prefix = String(line ?? '').slice(0, start);
101
104
  const controlFlow = controlHeadEvidenceRecords(prefix), shortCircuit = shortCircuitEvidenceRecords(prefix), awaitOrder = awaitOrderEvidenceRecords(prefix);
102
105
  const optionalChain = optionalChainEvidenceRecords(line, start, end), conditionalExpression = conditionalExpressionEvidenceRecords(line, start, end);
103
- const promiseCombinator = promiseCombinatorEvidenceRecords(line, start, end), promiseChain = promiseChainEvidenceRecords(line, start, end), throwOrder = throwOrderEvidenceRecords(line, start, end);
106
+ const dynamicImport = dynamicImportEvidenceRecords(line, start, end), promiseCombinator = promiseCombinatorEvidenceRecords(line, start, end), promiseChain = promiseChainEvidenceRecords(line, start, end), throwOrder = throwOrderEvidenceRecords(line, start, end);
104
107
  return {
105
108
  controlFlow: controlFlow.length ? controlFlow : undefined,
106
109
  shortCircuit: shortCircuit.length ? shortCircuit : undefined,
@@ -108,6 +111,7 @@ function sameLineRuntimeOrderEvidence(line, start, end) {
108
111
  awaitOrder: awaitOrder.length ? awaitOrder : undefined,
109
112
  optionalChain: optionalChain.length ? optionalChain : undefined,
110
113
  conditionalExpression: conditionalExpression.length ? conditionalExpression : undefined,
114
+ dynamicImport: dynamicImport.length ? dynamicImport : undefined,
111
115
  promiseCombinator: promiseCombinator.length ? promiseCombinator : undefined,
112
116
  promiseChain: promiseChain.length ? promiseChain : undefined,
113
117
  throw: throwOrder.length ? true : /\bthrow\b/.test(prefix) || undefined,
@@ -126,7 +130,6 @@ function controlFlowOrderEvidence(line, lineNumber, group) {
126
130
  loop: records.filter((record) => record.kind === 'loop')
127
131
  };
128
132
  }
129
-
130
133
  function optionalChainEvidenceRecords(line, start, end) {
131
134
  const expression = String(line ?? '').slice(Math.max(0, start), Math.max(start, end));
132
135
  const matches = [...expression.matchAll(/\?\.(?:\s*\(|\s*[A-Za-z_$][\w$]*|\s*\[)/g)];
@@ -136,7 +139,6 @@ function optionalChainEvidenceRecords(line, start, end) {
136
139
  text: normalizeOrderEvidenceText(expression.slice(Math.max(0, match.index - 24), match.index + match[0].length + 24))
137
140
  }));
138
141
  }
139
-
140
142
  function awaitOrderEvidenceRecords(prefix) {
141
143
  const text = String(prefix ?? '');
142
144
  const tokens = awaitTokenIndexes(text);
@@ -164,7 +166,6 @@ function awaitTokenIndexes(text) {
164
166
  }
165
167
  return indexes;
166
168
  }
167
-
168
169
  function shortCircuitEvidenceRecords(prefix) {
169
170
  const text = String(prefix ?? '');
170
171
  const operators = shortCircuitOperators(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.161",
3
+ "version": "0.2.163",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",