@shapeshift-labs/frontier-lang-compiler 0.2.98 → 0.2.100
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/dist/declarations/semantic-edit-bundle.d.ts +90 -0
- package/dist/declarations/semantic-edit-script.d.ts +34 -37
- package/dist/declarations/semantic-lineage.d.ts +63 -34
- package/dist/declarations/semantic-patch-bundle-index.d.ts +3 -0
- package/dist/declarations/semantic-patch-bundle.d.ts +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/index-impl/declarationRecord.js +2 -2
- package/dist/internal/index-impl/inferSemanticLineageEvents.js +8 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +56 -64
- package/dist/internal/index-impl/replaySemanticEditProjection.js +54 -22
- package/dist/internal/index-impl/semanticEditBundleAdmission.js +220 -0
- package/dist/internal/index-impl/semanticEditBundleIndex.js +16 -10
- package/dist/internal/index-impl/semanticEditSourceRanges.js +204 -0
- package/dist/internal/index-impl/semanticHistoryLineageResolution.js +35 -1
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +2 -2
- package/dist/internal/index-impl/semanticLineageInferenceMatching.js +150 -13
- package/dist/internal/index-impl/semanticLineageResolutionRecords.js +28 -1
- package/dist/internal/index-impl/semanticPatchBundleAdmission.js +130 -11
- package/dist/internal/index-impl/semanticPatchBundleLineageLinks.js +199 -0
- package/dist/internal/index-impl/semanticPatchBundleOverlaps.js +6 -2
- package/dist/internal/index-impl/semanticPatchBundleRecords.js +65 -126
- package/dist/internal/index-impl/semanticPatchBundleSourceRecords.js +127 -0
- package/dist/internal/index-impl/sourceTextForSpan.js +4 -9
- package/dist/lightweight-dependency-relations.js +113 -7
- package/dist/native-import-utils.js +15 -1
- package/dist/native-region-scanner-js-helpers.js +61 -17
- package/dist/native-region-scanner-js.js +12 -4
- package/dist/semantic-import-regions.js +3 -3
- package/package.json +1 -1
|
@@ -121,10 +121,64 @@ function jsRegionKindForDeclarationName(name, source = '') {
|
|
|
121
121
|
function jsExportedContainerDeclaration(input, lineNumber, trimmed) {
|
|
122
122
|
let match = trimmed.match(/^export\s+default\s+(.+)$/);
|
|
123
123
|
if (match) return jsContainerExport(input, lineNumber, 'ExportDefaultContainer', 'default', match[1], { exportDefault: true });
|
|
124
|
-
match = trimmed.match(/^(
|
|
124
|
+
match = trimmed.match(/^(module\.exports|exports)(?:\.([A-Za-z_$][\w$]*))?\s*=\s*(.+)$/);
|
|
125
125
|
if (!match) return undefined;
|
|
126
|
-
const name = match[
|
|
127
|
-
return jsContainerExport(input, lineNumber, 'CommonJsContainerExport', name, match[
|
|
126
|
+
const name = match[2] ? `${match[1]}.${match[2]}` : 'module.exports';
|
|
127
|
+
return jsContainerExport(input, lineNumber, 'CommonJsContainerExport', name, match[3], { export: 'commonjs' });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function jsExportedFunctionWrapperDeclaration(input, lineNumber, trimmed) {
|
|
131
|
+
const match = trimmed.match(/^export\s+default\s+((?:React\.)?(?:forwardRef|memo|lazy|observer))\s*(?:<[^>]+>)?\s*\(\s*(.+)$/);
|
|
132
|
+
if (!match) return undefined;
|
|
133
|
+
const wrapper = match[1];
|
|
134
|
+
const argument = match[2].trim();
|
|
135
|
+
let functionMatch = argument.match(/^(?:async\s+)?function\*?\s*([A-Za-z_$][\w$]*)?\s*(?:<[^({;]+>)?\s*\(([^)]*)\)/);
|
|
136
|
+
if (functionMatch) {
|
|
137
|
+
return nativeDeclaration(input, lineNumber, 'ExportDefaultFunctionWrapperDeclaration', 'function', functionMatch[1] ?? 'default', {
|
|
138
|
+
exportDefault: true,
|
|
139
|
+
wrapper,
|
|
140
|
+
parameters: splitParameters(functionMatch[2])
|
|
141
|
+
}, true);
|
|
142
|
+
}
|
|
143
|
+
functionMatch = argument.match(/^(?:async\s*)?(?:\(([^)]*)\)|([A-Za-z_$][\w$]*))\s*(?::\s*[^=]+)?=>/);
|
|
144
|
+
if (functionMatch) {
|
|
145
|
+
return nativeDeclaration(input, lineNumber, 'ExportDefaultFunctionWrapperDeclaration', 'function', 'default', {
|
|
146
|
+
exportDefault: true,
|
|
147
|
+
wrapper,
|
|
148
|
+
parameters: splitParameters(functionMatch[1] ?? functionMatch[2])
|
|
149
|
+
}, true);
|
|
150
|
+
}
|
|
151
|
+
const aliasMatch = argument.match(/^([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*(?:[,)]|$)/);
|
|
152
|
+
if (!aliasMatch) return undefined;
|
|
153
|
+
return nativeDeclaration(input, lineNumber, 'ExportDefaultWrappedAlias', 'variable', 'default', {
|
|
154
|
+
exportDefault: true,
|
|
155
|
+
wrapper,
|
|
156
|
+
alias: aliasMatch[1],
|
|
157
|
+
initializerKind: 'function-wrapper'
|
|
158
|
+
}, false, {
|
|
159
|
+
metadata: { exportDefault: true, wrapper, alias: aliasMatch[1], initializerKind: 'function-wrapper' }
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function jsExportAliasDeclaration(input, lineNumber, trimmed) {
|
|
164
|
+
let match = trimmed.match(/^export\s+default\s+([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*;?$/);
|
|
165
|
+
if (match) return jsAliasExport(input, lineNumber, 'ExportDefaultAlias', 'default', match[1], { exportDefault: true }, trimmed);
|
|
166
|
+
match = trimmed.match(/^module\.exports\s*=\s*([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*;?$/);
|
|
167
|
+
if (match) return jsAliasExport(input, lineNumber, 'CommonJsAliasExport', 'module.exports', match[1], { export: 'commonjs' }, trimmed);
|
|
168
|
+
match = trimmed.match(/^(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=\s*([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*;?$/);
|
|
169
|
+
if (!match) return undefined;
|
|
170
|
+
return jsAliasExport(input, lineNumber, 'CommonJsAliasExport', match[1], match[2], { export: 'commonjs' }, trimmed);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function jsAliasExport(input, lineNumber, languageKind, name, alias, fields, source) {
|
|
174
|
+
const regionKind = jsRegionKindForDeclarationName(name, source);
|
|
175
|
+
return nativeDeclaration(input, lineNumber, languageKind, 'variable', name, {
|
|
176
|
+
...fields,
|
|
177
|
+
alias
|
|
178
|
+
}, false, {
|
|
179
|
+
regionKind,
|
|
180
|
+
metadata: { ...fields, alias }
|
|
181
|
+
});
|
|
128
182
|
}
|
|
129
183
|
|
|
130
184
|
function jsContainerExport(input, lineNumber, languageKind, name, initializer, fields) {
|
|
@@ -254,17 +308,7 @@ function findUnescapedBacktick(text, startIndex) {
|
|
|
254
308
|
return -1;
|
|
255
309
|
}
|
|
256
310
|
|
|
257
|
-
export {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
jsExportedContainerDeclaration,
|
|
262
|
-
jsInitializerKind,
|
|
263
|
-
jsImportDeclarations,
|
|
264
|
-
jsObjectPropertyDeclaration,
|
|
265
|
-
jsObjectRegionContext,
|
|
266
|
-
jsRegionKindForDeclarationName,
|
|
267
|
-
jsRouteRecordDeclaration,
|
|
268
|
-
jsVariableHasBody,
|
|
269
|
-
jsVariableSymbolKind
|
|
270
|
-
};
|
|
311
|
+
export { jsCommentOnlyLine, jsContainerDelta, jsDeclarationScanLine };
|
|
312
|
+
export { jsExportAliasDeclaration, jsExportedContainerDeclaration, jsExportedFunctionWrapperDeclaration };
|
|
313
|
+
export { jsInitializerKind, jsImportDeclarations, jsObjectPropertyDeclaration, jsObjectRegionContext };
|
|
314
|
+
export { jsRegionKindForDeclarationName, jsRouteRecordDeclaration, jsVariableHasBody, jsVariableSymbolKind };
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
jsCommentOnlyLine,
|
|
11
11
|
jsContainerDelta,
|
|
12
12
|
jsDeclarationScanLine,
|
|
13
|
+
jsExportAliasDeclaration,
|
|
13
14
|
jsExportedContainerDeclaration,
|
|
15
|
+
jsExportedFunctionWrapperDeclaration,
|
|
14
16
|
jsInitializerKind,
|
|
15
17
|
jsImportDeclarations,
|
|
16
18
|
jsObjectPropertyDeclaration,
|
|
@@ -75,11 +77,13 @@ function scanJavaScriptLike(input) {
|
|
|
75
77
|
pushDeclaration(nativeDeclaration(input, number, 'FunctionDeclaration', 'function', match[1], { parameters: splitParameters(match[2]) }, declarationLine.includes('{')));
|
|
76
78
|
} else if ((match = trimmed.match(/^export\s+default\s+(?:async\s+)?function\*?\s*([A-Za-z_$][\w$]*)?\s*(?:<[^({;]+>)?\s*\(([^)]*)\)\s*(?::\s*[^={]+)?/))) {
|
|
77
79
|
pushDeclaration(nativeDeclaration(input, number, 'ExportDefaultFunctionDeclaration', 'function', match[1] ?? 'default', { parameters: splitParameters(match[2]), exportDefault: true }, trimmed.includes('{')));
|
|
78
|
-
} else if ((match = declarationLine.match(/^(
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
} else if ((match = declarationLine.match(/^(default\s+)?(?:abstract\s+)?class\b(?:\s+(?!(?:extends|implements)\b)([A-Za-z_$][\w$]*))?/)) && (match[1] || match[2])) {
|
|
81
|
+
const className = match[2] ?? 'default';
|
|
82
|
+
const exportDefault = Boolean(match[1]);
|
|
83
|
+
pushDeclaration(nativeDeclaration(input, number, exportDefault ? 'ExportDefaultClassDeclaration' : 'ClassDeclaration', 'class', className, { exportDefault: exportDefault || undefined }, declarationLine.includes('{')));
|
|
84
|
+
pushDeclarations(jsInlineClassMemberDeclarations(input, number, declarationLine, className));
|
|
81
85
|
if (jsStructureDelta(declarationLine).value > 0) {
|
|
82
|
-
currentClass =
|
|
86
|
+
currentClass = className;
|
|
83
87
|
classDepth = 0;
|
|
84
88
|
}
|
|
85
89
|
} else if ((match = declarationLine.match(/^interface\s+([A-Za-z_$][\w$]*)/))) {
|
|
@@ -109,10 +113,14 @@ function scanJavaScriptLike(input) {
|
|
|
109
113
|
pushDeclarations(jsInlineNestedObjectDeclarations(input, number, declarationLine, declarations[declarations.length - 1]));
|
|
110
114
|
const objectContext = jsObjectRegionContext(match[1], declarationLine, number, regionKind);
|
|
111
115
|
if (objectContext) objectStack.push(objectContext);
|
|
116
|
+
} else if ((match = jsExportedFunctionWrapperDeclaration(input, number, trimmed))) {
|
|
117
|
+
pushDeclaration(match);
|
|
112
118
|
} else if ((match = jsExportedContainerDeclaration(input, number, trimmed))) {
|
|
113
119
|
pushDeclaration(match.declaration);
|
|
114
120
|
pushDeclarations(jsInlineNestedObjectDeclarations(input, number, trimmed, match.declaration));
|
|
115
121
|
if (match.context) objectStack.push(match.context);
|
|
122
|
+
} else if ((match = jsExportAliasDeclaration(input, number, trimmed))) {
|
|
123
|
+
pushDeclaration(match);
|
|
116
124
|
} else if ((match = trimmed.match(/^(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=\s*(?:async\s+)?function\*?\s*\(([^)]*)\)/))) {
|
|
117
125
|
pushDeclaration(nativeDeclaration(input, number, 'CommonJsFunctionExport', 'function', match[1], { parameters: splitParameters(match[2]) }, true));
|
|
118
126
|
} else if ((match = trimmed.match(/^(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=/))) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { idFragment, uniqueStrings } from './native-import-utils.js';
|
|
1
|
+
import { caseSensitiveIdFragment, idFragment, uniqueStrings } from './native-import-utils.js';
|
|
2
2
|
|
|
3
3
|
const NativeImportRegionTaxonomyKinds = Object.freeze([
|
|
4
4
|
'symbol',
|
|
@@ -27,7 +27,7 @@ function semanticOwnershipRegionForSymbol(imported, symbol, mapping, nativeNode,
|
|
|
27
27
|
symbol.name ?? symbol.id
|
|
28
28
|
].map((part) => String(part).replace(/\s+/g, ' ').trim()).join('#');
|
|
29
29
|
return {
|
|
30
|
-
id: `region_${
|
|
30
|
+
id: `region_${caseSensitiveIdFragment(key)}`,
|
|
31
31
|
key,
|
|
32
32
|
regionKind,
|
|
33
33
|
granularity: 'symbol',
|
|
@@ -54,7 +54,7 @@ function semanticOwnershipRegionForDeclaration(input, declaration, documentId) {
|
|
|
54
54
|
const regionKind = semanticRegionKindForDeclaration(declaration);
|
|
55
55
|
const key = ['source', sourcePath, regionKind, name].map((part) => String(part).replace(/\s+/g, ' ').trim()).join('#');
|
|
56
56
|
return {
|
|
57
|
-
id: `region_${
|
|
57
|
+
id: `region_${caseSensitiveIdFragment(key)}`,
|
|
58
58
|
key,
|
|
59
59
|
regionKind,
|
|
60
60
|
granularity: 'symbol',
|
package/package.json
CHANGED