@shapeshift-labs/frontier-lang-compiler 0.2.115 → 0.2.116

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 CHANGED
@@ -244,6 +244,9 @@ enough evidence. For `export { thing as renamedThing } from './thing.js'`,
244
244
  `originSymbolId`, `exportedSymbolId`, and `localSymbolId`.
245
245
  Public contract regions include `apiSurfaceKind`, `signatureHash`, and
246
246
  `contractHash`, giving merge admission a stable API surface fingerprint.
247
+ For `export * from './module.js'`, project graphs fan out re-export identities
248
+ for each named export in the resolved target document and omit `default`, which
249
+ matches JavaScript module semantics.
247
250
 
248
251
  High-risk native features also have explicit evidence policies. These policies are advisory in this package: they tell a swarm or admission queue what evidence is missing without silently changing the existing readiness classification.
249
252
 
@@ -116,7 +116,7 @@ export interface NativeProjectSymbolGraphModuleEdgeRecord {
116
116
  readonly importedName?: string;
117
117
  readonly exportedName?: string;
118
118
  readonly localName?: string; readonly namespace?: string;
119
- readonly isTypeOnly?: boolean;
119
+ readonly exportStar?: boolean; readonly isTypeOnly?: boolean;
120
120
  readonly isReExport?: boolean;
121
121
  readonly publicContract?: boolean;
122
122
  readonly evidenceIds?: readonly string[];
@@ -133,8 +133,8 @@ export interface NativeProjectSymbolGraphReExportIdentityRecord {
133
133
  readonly exportedName?: string;
134
134
  readonly importedName?: string;
135
135
  readonly localName?: string;
136
- readonly namespace?: string;
137
- readonly isTypeOnly?: boolean;
136
+ readonly namespace?: string; readonly isTypeOnly?: boolean;
137
+ readonly isExportStar?: boolean;
138
138
  readonly symbolId?: string; readonly originSymbolId?: string;
139
139
  readonly exportedSymbolId?: string; readonly localSymbolId?: string;
140
140
  readonly relationId?: string;
@@ -1,8 +1,8 @@
1
1
  import{idFragment,uniqueByEvidenceId,uniqueByLossId,uniqueStrings}from'../../native-import-utils.js';import{createDocument,createPatch,createUniversalAstEnvelope}from'@shapeshift-labs/frontier-lang-kernel';
2
2
  import{createNativeImportResultContract}from'./createNativeImportResultContract.js';import{createProjectImportAdmissionRecord}from'./createProjectImportAdmissionRecord.js';import{mergeSemanticIndexes}from'./mergeSemanticIndexes.js';import{summarizeNativeImportLosses}from'./summarizeNativeImportLosses.js';import{summarizeProjectSourcePreservation}from'./summarizeProjectSourcePreservation.js';
3
- import{createProjectDocumentExportSymbolResolver,createProjectModuleSymbolResolver,resolveProjectModule}from'./projectSymbolGraphModuleResolution.js';
3
+ import{createProjectDocumentExportSymbolResolver,createProjectDocumentExportSymbolsResolver,createProjectModuleSymbolResolver,resolveProjectModule}from'./projectSymbolGraphModuleResolution.js';
4
4
  import{publicContractRegionRecord}from'./projectSymbolGraphPublicContracts.js';
5
- import{isReExportImportEdge,reExportIdentityInputFromEdge,reExportIdentityRecord}from'./projectSymbolGraphReExports.js';
5
+ import{exportStarReExportIdentityRecords,isReExportImportEdge,reExportIdentityInputFromEdge,reExportIdentityRecord}from'./projectSymbolGraphReExports.js';
6
6
  export function createNativeProjectImportResult(input, imports) {
7
7
  const idPart = idFragment(input.id ?? input.projectRoot ?? 'native_project');
8
8
  const nodes = {};
@@ -156,6 +156,7 @@ function createProjectSymbolGraphSummary(semanticIndex, imports, input) {
156
156
  const moduleResolution = input.moduleResolution ?? input.tsconfig;
157
157
  const resolveTargetSymbolId = createProjectModuleSymbolResolver(semanticIndex?.symbols ?? [], documents);
158
158
  const resolveDocumentExportSymbolId = createProjectDocumentExportSymbolResolver(semanticIndex?.symbols ?? [], documents);
159
+ const resolveDocumentExportSymbols = createProjectDocumentExportSymbolsResolver(semanticIndex?.symbols ?? [], documents);
159
160
  const facts = semanticIndex?.facts ?? [];
160
161
  const moduleEdgeFacts = facts.filter((fact) => fact.predicate === 'moduleEdge');
161
162
  const moduleEdgeByRelation = new Map(moduleEdgeFacts.map((fact) => [fact.subjectId, fact]));
@@ -176,7 +177,9 @@ function createProjectSymbolGraphSummary(semanticIndex, imports, input) {
176
177
  .map((edge) => reExportIdentityRecord(reExportIdentityInputFromEdge(edge, `reexport_${idFragment(edge.id)}`), edge, resolveDocumentExportSymbolId)),
177
178
  ...importEdges
178
179
  .filter((edge) => isReExportImportEdge(edge))
179
- .map((edge) => reExportIdentityRecord(reExportIdentityInputFromEdge(edge, `reexport_${idFragment(edge.id)}`), edge, resolveDocumentExportSymbolId))
180
+ .flatMap((edge) => edge.exportStar
181
+ ? exportStarReExportIdentityRecords(edge, resolveDocumentExportSymbols(edge.targetDocumentId))
182
+ : [reExportIdentityRecord(reExportIdentityInputFromEdge(edge, `reexport_${idFragment(edge.id)}`), edge, resolveDocumentExportSymbolId)])
180
183
  ]);
181
184
  const publicContractRegions = uniqueRecords(facts
182
185
  .filter((fact) => fact.predicate === 'publicContractRegion' && fact.value)
@@ -246,8 +249,9 @@ function moduleEdgeRecord(relation, moduleEdgeByRelation, symbolsById, documents
246
249
  exportedName: firstString(moduleEdge.exportedName, value.exportedName, symbolMetadata.exportedName),
247
250
  localName: firstString(moduleEdge.localName, value.localName, symbolMetadata.localName),
248
251
  namespace: firstString(moduleEdge.namespace, value.namespace, symbolMetadata.namespace),
252
+ exportStar: firstBoolean(moduleEdge.exportStar, value.exportStar, symbolMetadata.exportStar),
249
253
  isTypeOnly: firstBoolean(moduleEdge.isTypeOnly, value.isTypeOnly),
250
- isReExport: firstBoolean(moduleEdge.isReExport, value.isReExport) ?? (relation.predicate === 'exports' && Boolean(moduleSpecifier)),
254
+ isReExport: firstBoolean(moduleEdge.isReExport, value.isReExport, symbolMetadata.reexport) ?? (relation.predicate === 'exports' && Boolean(moduleSpecifier)),
251
255
  publicContract: firstBoolean(moduleEdge.publicContract, value.publicContract, metadata.publicContract),
252
256
  evidenceIds: uniqueStrings([...(relation.evidenceIds ?? []), ...(fact?.evidenceIds ?? [])])
253
257
  };
@@ -34,6 +34,22 @@ export function createProjectDocumentExportSymbolResolver(symbols, documents) {
34
34
  };
35
35
  }
36
36
 
37
+ export function createProjectDocumentExportSymbolsResolver(symbols, documents) {
38
+ const documentsByPath = new Map(documents.filter((document) => document.path).map((document) => [document.path, document]));
39
+ const exportsByDocumentId = new Map();
40
+ for (const symbol of symbols ?? []) {
41
+ if (symbol?.kind !== 'export' || !symbol.name) continue;
42
+ const document = documentsByPath.get(symbol.definitionSpan?.path);
43
+ if (!document) continue;
44
+ const exports = exportsByDocumentId.get(document.id) ?? [];
45
+ exports.push(symbol);
46
+ exportsByDocumentId.set(document.id, exports);
47
+ }
48
+ return function resolveDocumentExports(documentId) {
49
+ return exportsByDocumentId.get(documentId) ?? [];
50
+ };
51
+ }
52
+
37
53
  function projectExportSymbolMap(symbols, documents) {
38
54
  const documentsByPath = new Map(documents.filter((document) => document.path).map((document) => [document.path, document]));
39
55
  const exportedByDocumentAndName = new Map();
@@ -15,7 +15,7 @@ export function reExportIdentityRecord(identity, edge, resolveDocumentExportSymb
15
15
  }
16
16
 
17
17
  export function isReExportImportEdge(edge) {
18
- return edge.importKind === 'reexport' || edge.importKind === 'namespace-reexport';
18
+ return edge.importKind === 'reexport' || edge.importKind === 'namespace-reexport' || edge.exportStar === true;
19
19
  }
20
20
 
21
21
  export function reExportIdentityInputFromEdge(edge, id) {
@@ -31,6 +31,32 @@ export function reExportIdentityInputFromEdge(edge, id) {
31
31
  });
32
32
  }
33
33
 
34
+ export function exportStarReExportIdentityRecords(edge, targetExports) {
35
+ if (!edge?.exportStar || !edge.targetDocumentId) return [];
36
+ return targetExports
37
+ .filter((symbol) => symbol.name && symbol.name !== 'default')
38
+ .map((symbol) => compactRecord({
39
+ id: `reexport_star_${idFragment(edge.id)}_${idFragment(symbol.id)}`,
40
+ sourceDocumentId: edge.sourceDocumentId,
41
+ sourcePath: edge.sourcePath,
42
+ sourceHash: edge.sourceHash,
43
+ moduleSpecifier: edge.moduleSpecifier,
44
+ symbolId: edge.targetSymbolId,
45
+ relationId: edge.id,
46
+ importedName: symbol.name,
47
+ exportedName: symbol.name,
48
+ originSymbolId: symbol.id,
49
+ exportedSymbolId: symbol.id,
50
+ localSymbolId: edge.targetSymbolId,
51
+ isExportStar: true,
52
+ publicContract: edge.publicContract
53
+ }));
54
+ }
55
+
56
+ function idFragment(value) {
57
+ return String(value ?? '').toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '').slice(0, 80) || 'id';
58
+ }
59
+
34
60
  function compactRecord(record) {
35
61
  return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
36
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.115",
3
+ "version": "0.2.116",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",