@telorun/analyzer 0.8.1 → 0.9.0
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/analysis-registry.d.ts +1 -0
- package/dist/analysis-registry.d.ts.map +1 -1
- package/dist/analysis-registry.js +2 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +2 -2
- package/dist/flatten-for-analyzer.d.ts +30 -0
- package/dist/flatten-for-analyzer.d.ts.map +1 -0
- package/dist/flatten-for-analyzer.js +119 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/loaded-types.d.ts +81 -0
- package/dist/loaded-types.d.ts.map +1 -0
- package/dist/loaded-types.js +1 -0
- package/dist/manifest-loader.d.ts +30 -9
- package/dist/manifest-loader.d.ts.map +1 -1
- package/dist/manifest-loader.js +197 -417
- package/dist/parse-loaded-file.d.ts +12 -0
- package/dist/parse-loaded-file.d.ts.map +1 -0
- package/dist/parse-loaded-file.js +50 -0
- package/dist/position-metadata.d.ts +27 -0
- package/dist/position-metadata.d.ts.map +1 -0
- package/dist/position-metadata.js +88 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validate-references.d.ts.map +1 -1
- package/dist/validate-references.js +62 -0
- package/package.json +3 -3
- package/src/analysis-registry.ts +2 -1
- package/src/analyzer.ts +4 -2
- package/src/flatten-for-analyzer.ts +134 -0
- package/src/index.ts +18 -0
- package/src/loaded-types.ts +86 -0
- package/src/manifest-loader.ts +230 -459
- package/src/parse-loaded-file.ts +70 -0
- package/src/position-metadata.ts +106 -0
- package/src/types.ts +6 -0
- package/src/validate-references.ts +68 -0
|
@@ -8,6 +8,7 @@ import type { AnalysisContext } from "./types.js";
|
|
|
8
8
|
export declare class AnalysisRegistry {
|
|
9
9
|
private readonly defs;
|
|
10
10
|
private readonly aliases;
|
|
11
|
+
private readonly aliasesByModule;
|
|
11
12
|
registerDefinition(def: ResourceDefinition): void;
|
|
12
13
|
registerModuleIdentity(namespace: string | null, name: string): void;
|
|
13
14
|
registerImport(alias: string, target: string, kinds: string[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analysis-registry.d.ts","sourceRoot":"","sources":["../src/analysis-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;
|
|
1
|
+
{"version":3,"file":"analysis-registry.d.ts","sourceRoot":"","sources":["../src/analysis-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoC;IAEpE,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI;IAIjD,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIpE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAIpE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7C;;;OAGG;IACH,mBAAmB,CACjB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,EAClC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GACnC,IAAI;IAcP;;;;OAIG;IACH,kBAAkB,IAAI,kBAAkB,EAAE;IAI1C,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAM/D,QAAQ,IAAI,MAAM,EAAE;IAIpB;mEAC+D;IAC/D,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC;;;gCAG4B;IAC5B,oBAAoB,IAAI,MAAM,EAAE;IAIhC;wEACoE;IACpE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIhD,qFAAqF;IACrF,QAAQ,IAAI,eAAe;CAG5B"}
|
|
@@ -11,6 +11,7 @@ import { isRefEntry, isScopeEntry } from "./reference-field-map.js";
|
|
|
11
11
|
export class AnalysisRegistry {
|
|
12
12
|
defs = new DefinitionRegistry();
|
|
13
13
|
aliases = new AliasResolver();
|
|
14
|
+
aliasesByModule = new Map();
|
|
14
15
|
registerDefinition(def) {
|
|
15
16
|
this.defs.register(def);
|
|
16
17
|
}
|
|
@@ -76,6 +77,6 @@ export class AnalysisRegistry {
|
|
|
76
77
|
}
|
|
77
78
|
/** @internal Bridge for StaticAnalyzer — do not use outside the analyzer package. */
|
|
78
79
|
_context() {
|
|
79
|
-
return { aliases: this.aliases, definitions: this.defs };
|
|
80
|
+
return { aliases: this.aliases, definitions: this.defs, aliasesByModule: this.aliasesByModule };
|
|
80
81
|
}
|
|
81
82
|
}
|
package/dist/analyzer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC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E,QAAQ,EAAE,gBAAgB,GAAG,gBAAgB,EAAE;IAKxF,OAAO,CACL,SAAS,EAAE,gBAAgB,EAAE,EAC7B,QAAQ,EAAE,gBAAgB,GACzB;QAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;CAiB5F"}
|
package/dist/analyzer.js
CHANGED
|
@@ -324,7 +324,7 @@ export class StaticAnalyzer {
|
|
|
324
324
|
rootModules.add(m.metadata.name);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
const aliasesByModule = new Map();
|
|
327
|
+
const aliasesByModule = ctx?.aliasesByModule ?? new Map();
|
|
328
328
|
for (const m of manifests) {
|
|
329
329
|
if (isModuleKind(m.kind)) {
|
|
330
330
|
const namespace = m.metadata.namespace ?? null;
|
|
@@ -575,7 +575,7 @@ export class StaticAnalyzer {
|
|
|
575
575
|
});
|
|
576
576
|
}
|
|
577
577
|
// Validate resource references (Phase 3)
|
|
578
|
-
diagnostics.push(...validateReferences(allManifests, { aliases, definitions: defs }));
|
|
578
|
+
diagnostics.push(...validateReferences(allManifests, { aliases, definitions: defs, aliasesByModule }));
|
|
579
579
|
// Validate `extends` fields and flag legacy `capability: <UserAbstract>` overload.
|
|
580
580
|
diagnostics.push(...validateExtends(allManifests, defs, aliases));
|
|
581
581
|
// Validate throws: declarations and catches: coverage (rules 1, 2, 4, 7)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ResourceManifest } from "@telorun/sdk";
|
|
2
|
+
import type { LoadedGraph, LoadedModule } from "./loaded-types.js";
|
|
3
|
+
/** Produce the flat manifest list `analyze()` consumes today.
|
|
4
|
+
*
|
|
5
|
+
* Combines the entry module's manifests with `Telo.Definition`,
|
|
6
|
+
* `Telo.Abstract`, and `Telo.Import` docs forwarded from imported libraries.
|
|
7
|
+
* Stamps three flavours of metadata along the way:
|
|
8
|
+
*
|
|
9
|
+
* - `metadata.source` and `metadata.sourceLine` — already on each manifest
|
|
10
|
+
* from `parseLoadedFile`, copied here unchanged.
|
|
11
|
+
* - `metadata.module` — the owning module's `Telo.Application` /
|
|
12
|
+
* `Telo.Library` `metadata.name`, applied to non-module manifests that
|
|
13
|
+
* don't already carry one.
|
|
14
|
+
* - `metadata.resolvedModuleName` / `metadata.resolvedNamespace` — for every
|
|
15
|
+
* `Telo.Import` manifest, looked up via `graph.importEdges` to find the
|
|
16
|
+
* target module's own `Telo.Library` identity. Without this, the
|
|
17
|
+
* analyzer's alias resolver and `validate-extends` fall back to
|
|
18
|
+
* path-derived identity and produce spurious diagnostics.
|
|
19
|
+
*
|
|
20
|
+
* Position metadata (`positionIndex`) is NOT stamped on manifests —
|
|
21
|
+
* callers look it up via `findPositions(graph, ...)` on the LoadedGraph. */
|
|
22
|
+
export declare function flattenForAnalyzer(graph: LoadedGraph): ResourceManifest[];
|
|
23
|
+
/** Project a LoadedModule (owner + partials) to a flat ResourceManifest[]
|
|
24
|
+
* with `metadata.module` stamped on non-module docs. The kernel's runtime
|
|
25
|
+
* entry load uses this to convert a `Loader.loadModule` result into the
|
|
26
|
+
* classic ResourceManifest[] shape it iterates over. Imports are not
|
|
27
|
+
* followed — the kernel's import-controller loads each import's module
|
|
28
|
+
* separately at runtime. */
|
|
29
|
+
export declare function flattenLoadedModule(mod: LoadedModule): ResourceManifest[];
|
|
30
|
+
//# sourceMappingURL=flatten-for-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten-for-analyzer.d.ts","sourceRoot":"","sources":["../src/flatten-for-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAc,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/E;;;;;;;;;;;;;;;;;;6EAkB6E;AAC7E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,EAAE,CAyDzE;AAED;;;;;6BAK6B;AAC7B,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,gBAAgB,EAAE,CAEzE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { isModuleKind } from "./module-kinds.js";
|
|
2
|
+
/** Produce the flat manifest list `analyze()` consumes today.
|
|
3
|
+
*
|
|
4
|
+
* Combines the entry module's manifests with `Telo.Definition`,
|
|
5
|
+
* `Telo.Abstract`, and `Telo.Import` docs forwarded from imported libraries.
|
|
6
|
+
* Stamps three flavours of metadata along the way:
|
|
7
|
+
*
|
|
8
|
+
* - `metadata.source` and `metadata.sourceLine` — already on each manifest
|
|
9
|
+
* from `parseLoadedFile`, copied here unchanged.
|
|
10
|
+
* - `metadata.module` — the owning module's `Telo.Application` /
|
|
11
|
+
* `Telo.Library` `metadata.name`, applied to non-module manifests that
|
|
12
|
+
* don't already carry one.
|
|
13
|
+
* - `metadata.resolvedModuleName` / `metadata.resolvedNamespace` — for every
|
|
14
|
+
* `Telo.Import` manifest, looked up via `graph.importEdges` to find the
|
|
15
|
+
* target module's own `Telo.Library` identity. Without this, the
|
|
16
|
+
* analyzer's alias resolver and `validate-extends` fall back to
|
|
17
|
+
* path-derived identity and produce spurious diagnostics.
|
|
18
|
+
*
|
|
19
|
+
* Position metadata (`positionIndex`) is NOT stamped on manifests —
|
|
20
|
+
* callers look it up via `findPositions(graph, ...)` on the LoadedGraph. */
|
|
21
|
+
export function flattenForAnalyzer(graph) {
|
|
22
|
+
const result = [];
|
|
23
|
+
const stampedEntry = collectModuleManifests(graph.entry);
|
|
24
|
+
result.push(...stampedEntry);
|
|
25
|
+
const seen = new Set([graph.rootSource]);
|
|
26
|
+
const queue = [graph.rootSource];
|
|
27
|
+
while (queue.length > 0) {
|
|
28
|
+
const fromSource = queue.shift();
|
|
29
|
+
const edges = graph.importEdges.get(fromSource);
|
|
30
|
+
if (!edges)
|
|
31
|
+
continue;
|
|
32
|
+
for (const edge of edges.values()) {
|
|
33
|
+
if (seen.has(edge.targetSource))
|
|
34
|
+
continue;
|
|
35
|
+
seen.add(edge.targetSource);
|
|
36
|
+
queue.push(edge.targetSource);
|
|
37
|
+
const targetModule = graph.modules.get(edge.targetSource);
|
|
38
|
+
if (!targetModule)
|
|
39
|
+
continue;
|
|
40
|
+
const stamped = collectModuleManifests(targetModule);
|
|
41
|
+
for (const m of stamped) {
|
|
42
|
+
if (m.kind === "Telo.Definition" ||
|
|
43
|
+
m.kind === "Telo.Abstract" ||
|
|
44
|
+
m.kind === "Telo.Import") {
|
|
45
|
+
result.push(m);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Stamp resolved import identity on every Telo.Import in the result by
|
|
51
|
+
// reading the edge's pre-resolved name/namespace — no re-derivation from
|
|
52
|
+
// manifest metadata. The edge is keyed by (owner-file, alias) which is
|
|
53
|
+
// exactly the (metadata.source, metadata.name) pair on each Telo.Import.
|
|
54
|
+
for (let i = 0; i < result.length; i++) {
|
|
55
|
+
const m = result[i];
|
|
56
|
+
if (m.kind !== "Telo.Import")
|
|
57
|
+
continue;
|
|
58
|
+
const owner = m.metadata?.source;
|
|
59
|
+
const alias = m.metadata?.name;
|
|
60
|
+
if (!owner || !alias)
|
|
61
|
+
continue;
|
|
62
|
+
const edge = graph.importEdges.get(owner)?.get(alias);
|
|
63
|
+
if (!edge?.targetModuleName)
|
|
64
|
+
continue;
|
|
65
|
+
const newMetadata = {
|
|
66
|
+
...m.metadata,
|
|
67
|
+
resolvedModuleName: edge.targetModuleName,
|
|
68
|
+
resolvedNamespace: edge.targetNamespace,
|
|
69
|
+
};
|
|
70
|
+
result[i] = { ...m, metadata: newMetadata };
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
/** Project a LoadedModule (owner + partials) to a flat ResourceManifest[]
|
|
75
|
+
* with `metadata.module` stamped on non-module docs. The kernel's runtime
|
|
76
|
+
* entry load uses this to convert a `Loader.loadModule` result into the
|
|
77
|
+
* classic ResourceManifest[] shape it iterates over. Imports are not
|
|
78
|
+
* followed — the kernel's import-controller loads each import's module
|
|
79
|
+
* separately at runtime. */
|
|
80
|
+
export function flattenLoadedModule(mod) {
|
|
81
|
+
return collectModuleManifests(mod);
|
|
82
|
+
}
|
|
83
|
+
function collectModuleManifests(mod) {
|
|
84
|
+
const owner = stampFile(mod.owner, ownerModuleName(mod.owner));
|
|
85
|
+
const partials = [];
|
|
86
|
+
for (const p of mod.partials) {
|
|
87
|
+
partials.push(...stampFile(p, ownerModuleName(mod.owner)));
|
|
88
|
+
}
|
|
89
|
+
return [...owner, ...partials];
|
|
90
|
+
}
|
|
91
|
+
function ownerModuleName(file) {
|
|
92
|
+
for (const m of file.manifests) {
|
|
93
|
+
if (m && isModuleKind(m.kind)) {
|
|
94
|
+
const name = m.metadata?.name;
|
|
95
|
+
if (typeof name === "string")
|
|
96
|
+
return name;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
function stampFile(file, ownerModule) {
|
|
102
|
+
const out = [];
|
|
103
|
+
for (let i = 0; i < file.manifests.length; i++) {
|
|
104
|
+
const m = file.manifests[i];
|
|
105
|
+
if (m === null || m === undefined)
|
|
106
|
+
continue;
|
|
107
|
+
const { sourceLine } = file.positions[i];
|
|
108
|
+
const metadata = {
|
|
109
|
+
...m.metadata,
|
|
110
|
+
source: file.source,
|
|
111
|
+
sourceLine,
|
|
112
|
+
};
|
|
113
|
+
if (ownerModule && !isModuleKind(m.kind) && !metadata.module) {
|
|
114
|
+
metadata.module = ownerModule;
|
|
115
|
+
}
|
|
116
|
+
out.push({ ...m, metadata: metadata });
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export { AnalysisRegistry } from "./analysis-registry.js";
|
|
2
2
|
export { StaticAnalyzer } from "./analyzer.js";
|
|
3
|
+
export type { GraphLoadError, ImportEdge, LoadedFile, LoadedGraph, LoadedModule, ParseError, } from "./loaded-types.js";
|
|
4
|
+
export { flattenForAnalyzer, flattenLoadedModule } from "./flatten-for-analyzer.js";
|
|
3
5
|
export { Loader } from "./manifest-loader.js";
|
|
4
6
|
export { isModuleKind, MODULE_KINDS } from "./module-kinds.js";
|
|
5
7
|
export type { ModuleKind } from "./module-kinds.js";
|
|
8
|
+
export { parseLoadedFile } from "./parse-loaded-file.js";
|
|
9
|
+
export type { ParseOptions } from "./parse-loaded-file.js";
|
|
10
|
+
export { buildDocumentPositions, buildLineOffsets, buildPositionIndex, documentLineOffsets, } from "./position-metadata.js";
|
|
11
|
+
export type { DocumentPosition } from "./position-metadata.js";
|
|
6
12
|
export { HttpSource } from "./sources/http-source.js";
|
|
7
13
|
export { RegistrySource } from "./sources/registry-source.js";
|
|
8
14
|
export { DEFAULT_MANIFEST_FILENAME, DiagnosticSeverity } from "./types.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC3E,YAAY,EACR,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
1
|
export { AnalysisRegistry } from "./analysis-registry.js";
|
|
2
2
|
export { StaticAnalyzer } from "./analyzer.js";
|
|
3
|
+
export { flattenForAnalyzer, flattenLoadedModule } from "./flatten-for-analyzer.js";
|
|
3
4
|
export { Loader } from "./manifest-loader.js";
|
|
4
5
|
export { isModuleKind, MODULE_KINDS } from "./module-kinds.js";
|
|
6
|
+
export { parseLoadedFile } from "./parse-loaded-file.js";
|
|
7
|
+
export { buildDocumentPositions, buildLineOffsets, buildPositionIndex, documentLineOffsets, } from "./position-metadata.js";
|
|
5
8
|
export { HttpSource } from "./sources/http-source.js";
|
|
6
9
|
export { RegistrySource } from "./sources/registry-source.js";
|
|
7
10
|
export { DEFAULT_MANIFEST_FILENAME, DiagnosticSeverity } from "./types.js";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ResourceManifest } from "@telorun/sdk";
|
|
2
|
+
import type { Document } from "yaml";
|
|
3
|
+
import type { DocumentPosition } from "./position-metadata.js";
|
|
4
|
+
import type { Range } from "./types.js";
|
|
5
|
+
/** One physical file's parsed result. Returned for the owner manifest, for
|
|
6
|
+
* each `include:` partial, and for each external import target.
|
|
7
|
+
*
|
|
8
|
+
* Identity rule: every map key, every cross-reference, every editor-side
|
|
9
|
+
* cache uses `source` — the URL the source adapter's `read()` returned. */
|
|
10
|
+
export interface LoadedFile {
|
|
11
|
+
/** Canonical identity. The URL the source adapter's `read()` returned —
|
|
12
|
+
* HTTPS for http/registry, an absolute path for local. */
|
|
13
|
+
source: string;
|
|
14
|
+
/** The URL the caller supplied (e.g. registry ref `std/javascript@0.3.0`).
|
|
15
|
+
* Differs from `source` only for adapter-resolved URLs. */
|
|
16
|
+
requestedUrl: string;
|
|
17
|
+
/** Raw text exactly as `read()` returned it. */
|
|
18
|
+
text: string;
|
|
19
|
+
/** Per-document parsed AST, in source order. */
|
|
20
|
+
documents: Document[];
|
|
21
|
+
/** Per-document JSON projection (`doc.toJSON()`). Aligned to `documents`. */
|
|
22
|
+
manifests: Array<ResourceManifest | null>;
|
|
23
|
+
/** Per-document `{sourceLine, positionIndex}`. Aligned to `documents`. */
|
|
24
|
+
positions: DocumentPosition[];
|
|
25
|
+
/** Document-level parse errors aggregated from `yaml.Document.errors`. */
|
|
26
|
+
parseErrors: ParseError[];
|
|
27
|
+
}
|
|
28
|
+
export interface ParseError {
|
|
29
|
+
documentIndex: number;
|
|
30
|
+
message: string;
|
|
31
|
+
/** Line/character of the failure, when the yaml parser provided one. */
|
|
32
|
+
range?: Range;
|
|
33
|
+
}
|
|
34
|
+
/** An owner file plus the partial files it includes. The unit
|
|
35
|
+
* `Loader.loadModule` returns. */
|
|
36
|
+
export interface LoadedModule {
|
|
37
|
+
owner: LoadedFile;
|
|
38
|
+
/** Each `include:` target as its own LoadedFile. Empty when no `include:`.
|
|
39
|
+
* Order matches the `include:` list (after glob expansion). */
|
|
40
|
+
partials: LoadedFile[];
|
|
41
|
+
}
|
|
42
|
+
/** Resolved Telo.Import edge: where the import points and what library
|
|
43
|
+
* identity it resolves to. Carrying name/namespace on the edge means
|
|
44
|
+
* `flattenForAnalyzer` can stamp `metadata.resolvedModuleName` /
|
|
45
|
+
* `resolvedNamespace` from this single source rather than re-deriving
|
|
46
|
+
* the target from manifest metadata, which would silently miss whenever
|
|
47
|
+
* a future projection forgets to stamp `metadata.source` consistently. */
|
|
48
|
+
export interface ImportEdge {
|
|
49
|
+
/** Canonical resolved URL of the target — a key into `modules`. */
|
|
50
|
+
targetSource: string;
|
|
51
|
+
/** Target library's `metadata.name`, or `null` when the target had no
|
|
52
|
+
* Telo.Library doc (an error case captured in `LoadedGraph.errors`). */
|
|
53
|
+
targetModuleName: string | null;
|
|
54
|
+
/** Target library's `metadata.namespace` (or `null` when unset). */
|
|
55
|
+
targetNamespace: string | null;
|
|
56
|
+
}
|
|
57
|
+
/** An entry plus every transitively-imported library. Returned by
|
|
58
|
+
* `Loader.loadGraph`. */
|
|
59
|
+
export interface LoadedGraph {
|
|
60
|
+
/** Canonical entry source — equals `entry.owner.source`. */
|
|
61
|
+
rootSource: string;
|
|
62
|
+
entry: LoadedModule;
|
|
63
|
+
/** Map keyed by `LoadedFile.source` (canonical resolved URL). Includes
|
|
64
|
+
* entry, partials, and every transitively reachable Telo.Import target +
|
|
65
|
+
* its partials. */
|
|
66
|
+
modules: Map<string, LoadedModule>;
|
|
67
|
+
/** Per-Telo.Import resolution. Keyed by the resolved URL of the file the
|
|
68
|
+
* Telo.Import was declared in, then by the import's PascalCase alias. */
|
|
69
|
+
importEdges: Map<string, Map<string, ImportEdge>>;
|
|
70
|
+
/** Surface-level errors that did not abort the graph load (e.g. an import
|
|
71
|
+
* whose target failed to fetch). */
|
|
72
|
+
errors: GraphLoadError[];
|
|
73
|
+
}
|
|
74
|
+
export interface GraphLoadError {
|
|
75
|
+
/** URL of the file that failed to load. */
|
|
76
|
+
url: string;
|
|
77
|
+
/** Source of the import that triggered the load, or null for the entry. */
|
|
78
|
+
fromSource: string | null;
|
|
79
|
+
error: Error;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=loaded-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loaded-types.d.ts","sourceRoot":"","sources":["../src/loaded-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;4EAI4E;AAC5E,MAAM,WAAW,UAAU;IACzB;+DAC2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf;gEAC4D;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,SAAS,EAAE,QAAQ,EAAE,CA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
@@ -1,22 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LoadedFile, LoadedGraph, LoadedModule } from "./loaded-types.js";
|
|
2
2
|
import { type LoadOptions, type LoaderInitOptions, type ManifestSource } from "./types.js";
|
|
3
3
|
export declare class Loader {
|
|
4
|
-
|
|
4
|
+
/** LoadedFile cache keyed by `${compile ? "compiled" : "raw"}:${source}`.
|
|
5
|
+
* Same dual-keying as the legacy ResourceManifest[] cache: a compile-mode
|
|
6
|
+
* caller (kernel) and a raw-mode caller (analyzer/editor) on the same file
|
|
7
|
+
* get distinct entries, so neither sees the wrong manifest tree. */
|
|
8
|
+
private readonly fileCache;
|
|
5
9
|
protected sources: ManifestSource[];
|
|
6
10
|
private readonly celEnv;
|
|
7
11
|
constructor(extraSourcesOrOptions?: ManifestSource[] | LoaderInitOptions);
|
|
8
12
|
register(source: ManifestSource): this;
|
|
9
13
|
private pick;
|
|
10
14
|
resolveEntryPoint(url: string): Promise<string>;
|
|
11
|
-
|
|
15
|
+
/** Read one file via the source chain and parse it into a LoadedFile.
|
|
16
|
+
* The result is shared with `Loader.fileCache`. Callers that want a
|
|
17
|
+
* private mutable copy must call `parseLoadedFile` directly with the
|
|
18
|
+
* LoadedFile's `text`. */
|
|
19
|
+
loadFile(url: string, options?: LoadOptions): Promise<LoadedFile>;
|
|
20
|
+
/** Load an owner file plus every partial reachable through its `include:`
|
|
21
|
+
* list. Globs are expanded via the owning source's `expandGlob`. The
|
|
22
|
+
* partials list is empty when the owner declares no `include:`. */
|
|
23
|
+
loadModule(url: string, options?: LoadOptions): Promise<LoadedModule>;
|
|
24
|
+
/** Load a module and every transitively-imported library. Returns the full
|
|
25
|
+
* LoadedGraph: `entry`, `modules` keyed by canonical source, and
|
|
26
|
+
* `importEdges` mapping each importing file's PascalCase aliases to their
|
|
27
|
+
* target's canonical source. */
|
|
28
|
+
loadGraph(entryUrl: string, options?: LoadOptions): Promise<LoadedGraph>;
|
|
29
|
+
private resolveImportUrl;
|
|
30
|
+
private assertSingleModuleDeclaration;
|
|
31
|
+
private assertNoSystemKindsInPartialContext;
|
|
32
|
+
private assertImportTargetIsLibrary;
|
|
12
33
|
private resolveIncludes;
|
|
13
|
-
|
|
14
|
-
|
|
34
|
+
/** Find the owning telo.yaml for `fileUrl` (or use it directly if it's an
|
|
35
|
+
* owner) and return the `LoadedGraph` rooted at that owner. Returns
|
|
36
|
+
* `null` only when `fileUrl` is neither an owner nor reachable from one
|
|
37
|
+
* via parent-directory traversal. */
|
|
38
|
+
loadGraphForFile(fileUrl: string): Promise<{
|
|
39
|
+
graph: LoadedGraph;
|
|
15
40
|
ownerUrl: string;
|
|
16
|
-
manifests: ResourceManifest[];
|
|
17
|
-
sourceManifests: Map<string, ResourceManifest[]>;
|
|
18
41
|
} | null>;
|
|
19
|
-
loadModuleGraph(entryUrl: string, onError?: (url: string, error: Error) => void): Promise<Map<string, ResourceManifest[]>>;
|
|
20
|
-
loadManifests(entryUrl: string): Promise<ResourceManifest[]>;
|
|
21
42
|
}
|
|
22
43
|
//# sourceMappingURL=manifest-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-loader.d.ts","sourceRoot":"","sources":["../src/manifest-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifest-loader.d.ts","sourceRoot":"","sources":["../src/manifest-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,UAAU,EACV,WAAW,EACX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AASpB,qBAAa,MAAM;IACjB;;;yEAGqE;IACrE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiC;IAE3D,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,qBAAqB,GAAE,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