@shapeshift-labs/frontier-lang-compiler 0.2.114 → 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
@@ -242,6 +242,11 @@ Named re-export identities also include symbol links when the project graph has
242
242
  enough evidence. For `export { thing as renamedThing } from './thing.js'`,
243
243
  `reExportIdentities[]` records the source module, imported/exported names,
244
244
  `originSymbolId`, `exportedSymbolId`, and `localSymbolId`.
245
+ Public contract regions include `apiSurfaceKind`, `signatureHash`, and
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.
245
250
 
246
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.
247
252
 
@@ -82,9 +82,6 @@ export type NativeProjectSymbolGraphRemainingField =
82
82
  | 'reExportIdentities[].originSymbolId'
83
83
  | 'reExportIdentities[].exportedSymbolId'
84
84
  | 'reExportIdentities[].localSymbolId'
85
- | 'publicContractRegions[].apiSurfaceKind'
86
- | 'publicContractRegions[].signatureHash'
87
- | 'publicContractRegions[].contractHash'
88
85
  | string;
89
86
 
90
87
  export interface NativeProjectSymbolGraphFileHashRecord {
@@ -119,7 +116,7 @@ export interface NativeProjectSymbolGraphModuleEdgeRecord {
119
116
  readonly importedName?: string;
120
117
  readonly exportedName?: string;
121
118
  readonly localName?: string; readonly namespace?: string;
122
- readonly isTypeOnly?: boolean;
119
+ readonly exportStar?: boolean; readonly isTypeOnly?: boolean;
123
120
  readonly isReExport?: boolean;
124
121
  readonly publicContract?: boolean;
125
122
  readonly evidenceIds?: readonly string[];
@@ -136,8 +133,8 @@ export interface NativeProjectSymbolGraphReExportIdentityRecord {
136
133
  readonly exportedName?: string;
137
134
  readonly importedName?: string;
138
135
  readonly localName?: string;
139
- readonly namespace?: string;
140
- readonly isTypeOnly?: boolean;
136
+ readonly namespace?: string; readonly isTypeOnly?: boolean;
137
+ readonly isExportStar?: boolean;
141
138
  readonly symbolId?: string; readonly originSymbolId?: string;
142
139
  readonly exportedSymbolId?: string; readonly localSymbolId?: string;
143
140
  readonly relationId?: string;
@@ -158,6 +155,9 @@ export interface NativeProjectSymbolGraphPublicContractRegionRecord {
158
155
  readonly symbolId?: string;
159
156
  readonly symbolName?: string;
160
157
  readonly symbolKind?: string;
158
+ readonly apiSurfaceKind?: string;
159
+ readonly signatureHash?: string;
160
+ readonly contractHash?: string;
161
161
  readonly nativeAstNodeId?: string;
162
162
  readonly sourceSpan?: SourceSpan;
163
163
  readonly precision?: string;
@@ -1,7 +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';
4
- import{isReExportImportEdge,reExportIdentityInputFromEdge,reExportIdentityRecord}from'./projectSymbolGraphReExports.js';
3
+ import{createProjectDocumentExportSymbolResolver,createProjectDocumentExportSymbolsResolver,createProjectModuleSymbolResolver,resolveProjectModule}from'./projectSymbolGraphModuleResolution.js';
4
+ import{publicContractRegionRecord}from'./projectSymbolGraphPublicContracts.js';
5
+ import{exportStarReExportIdentityRecords,isReExportImportEdge,reExportIdentityInputFromEdge,reExportIdentityRecord}from'./projectSymbolGraphReExports.js';
5
6
  export function createNativeProjectImportResult(input, imports) {
6
7
  const idPart = idFragment(input.id ?? input.projectRoot ?? 'native_project');
7
8
  const nodes = {};
@@ -144,10 +145,7 @@ export function createNativeProjectImportResult(input, imports) {
144
145
  const PROJECT_SYMBOL_GRAPH_REMAINING_FIELDS = Object.freeze([
145
146
  'reExportIdentities[].originSymbolId',
146
147
  'reExportIdentities[].exportedSymbolId',
147
- 'reExportIdentities[].localSymbolId',
148
- 'publicContractRegions[].apiSurfaceKind',
149
- 'publicContractRegions[].signatureHash',
150
- 'publicContractRegions[].contractHash'
148
+ 'reExportIdentities[].localSymbolId'
151
149
  ]);
152
150
 
153
151
  function createProjectSymbolGraphSummary(semanticIndex, imports, input) {
@@ -158,6 +156,7 @@ function createProjectSymbolGraphSummary(semanticIndex, imports, input) {
158
156
  const moduleResolution = input.moduleResolution ?? input.tsconfig;
159
157
  const resolveTargetSymbolId = createProjectModuleSymbolResolver(semanticIndex?.symbols ?? [], documents);
160
158
  const resolveDocumentExportSymbolId = createProjectDocumentExportSymbolResolver(semanticIndex?.symbols ?? [], documents);
159
+ const resolveDocumentExportSymbols = createProjectDocumentExportSymbolsResolver(semanticIndex?.symbols ?? [], documents);
161
160
  const facts = semanticIndex?.facts ?? [];
162
161
  const moduleEdgeFacts = facts.filter((fact) => fact.predicate === 'moduleEdge');
163
162
  const moduleEdgeByRelation = new Map(moduleEdgeFacts.map((fact) => [fact.subjectId, fact]));
@@ -178,11 +177,13 @@ function createProjectSymbolGraphSummary(semanticIndex, imports, input) {
178
177
  .map((edge) => reExportIdentityRecord(reExportIdentityInputFromEdge(edge, `reexport_${idFragment(edge.id)}`), edge, resolveDocumentExportSymbolId)),
179
178
  ...importEdges
180
179
  .filter((edge) => isReExportImportEdge(edge))
181
- .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)])
182
183
  ]);
183
184
  const publicContractRegions = uniqueRecords(facts
184
185
  .filter((fact) => fact.predicate === 'publicContractRegion' && fact.value)
185
- .map((fact) => ({ ...objectValue(fact.value), factId: fact.id, symbolId: fact.subjectId })));
186
+ .map((fact) => publicContractRegionRecord(objectValue(fact.value), fact, symbolsById.get(fact.subjectId))));
186
187
  const fileHashes = uniqueRecords([
187
188
  ...documents.map((document) => fileHashRecord(document)),
188
189
  ...facts
@@ -248,8 +249,9 @@ function moduleEdgeRecord(relation, moduleEdgeByRelation, symbolsById, documents
248
249
  exportedName: firstString(moduleEdge.exportedName, value.exportedName, symbolMetadata.exportedName),
249
250
  localName: firstString(moduleEdge.localName, value.localName, symbolMetadata.localName),
250
251
  namespace: firstString(moduleEdge.namespace, value.namespace, symbolMetadata.namespace),
252
+ exportStar: firstBoolean(moduleEdge.exportStar, value.exportStar, symbolMetadata.exportStar),
251
253
  isTypeOnly: firstBoolean(moduleEdge.isTypeOnly, value.isTypeOnly),
252
- 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)),
253
255
  publicContract: firstBoolean(moduleEdge.publicContract, value.publicContract, metadata.publicContract),
254
256
  evidenceIds: uniqueStrings([...(relation.evidenceIds ?? []), ...(fact?.evidenceIds ?? [])])
255
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();
@@ -0,0 +1,41 @@
1
+ import{hashSemanticValue}from'@shapeshift-labs/frontier-lang-kernel';
2
+
3
+ export function publicContractRegionRecord(value, fact, symbol) {
4
+ const record = {
5
+ ...value,
6
+ factId: fact.id,
7
+ symbolId: fact.subjectId,
8
+ apiSurfaceKind: value.apiSurfaceKind ?? apiSurfaceKind(value, symbol),
9
+ signatureHash: value.signatureHash ?? symbol?.signatureHash
10
+ };
11
+ return compactRecord({
12
+ ...record,
13
+ contractHash: value.contractHash ?? publicContractHash(record)
14
+ });
15
+ }
16
+
17
+ function apiSurfaceKind(region, symbol) {
18
+ if (region.edgeKind === 're-export') return 'module-re-export';
19
+ if (region.edgeKind === 'export') return 'module-export';
20
+ if (symbol?.kind === 'export') return 'named-export';
21
+ return region.symbolKind ?? symbol?.kind ?? region.regionKind;
22
+ }
23
+
24
+ function publicContractHash(region) {
25
+ return hashSemanticValue({
26
+ kind: 'frontier.lang.publicContractRegionHash',
27
+ sourceHash: region.sourceHash,
28
+ symbolId: region.symbolId,
29
+ symbolName: region.symbolName,
30
+ symbolKind: region.symbolKind,
31
+ signatureHash: region.signatureHash,
32
+ moduleSpecifier: region.moduleSpecifier,
33
+ exportedName: region.exportedName,
34
+ edgeKind: region.edgeKind,
35
+ apiSurfaceKind: region.apiSurfaceKind
36
+ });
37
+ }
38
+
39
+ function compactRecord(record) {
40
+ return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
41
+ }
@@ -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.114",
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",