@telorun/kernel 0.9.1 → 0.10.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/controller-loader.d.ts +11 -3
- package/dist/controller-loader.d.ts.map +1 -1
- package/dist/controller-loader.js +2 -2
- package/dist/controller-loader.js.map +1 -1
- package/dist/controller-loaders/npm-loader.d.ts +128 -13
- package/dist/controller-loaders/npm-loader.d.ts.map +1 -1
- package/dist/controller-loaders/npm-loader.js +764 -216
- package/dist/controller-loaders/npm-loader.js.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.js +1 -0
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
- package/dist/generated/runtime-deps.json +6 -0
- package/dist/kernel.d.ts +57 -5
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +137 -23
- package/dist/kernel.js.map +1 -1
- package/dist/resource-context.d.ts +1 -0
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +3 -0
- package/dist/resource-context.js.map +1 -1
- package/package.json +16 -5
- package/src/controller-loader.ts +13 -3
- package/src/controller-loaders/npm-loader.ts +843 -229
- package/src/controllers/resource-definition/resource-definition-controller.ts +1 -0
- package/src/kernel.ts +157 -22
- package/src/resource-context.ts +4 -0
|
@@ -51,6 +51,14 @@ export type ControllerLoaderEvent = {
|
|
|
51
51
|
export type ControllerLoaderEmit = (event: ControllerLoaderEvent) => void | Promise<void>;
|
|
52
52
|
export interface ControllerLoaderOptions {
|
|
53
53
|
emit?: ControllerLoaderEmit;
|
|
54
|
+
/**
|
|
55
|
+
* URL of the entry manifest. The npm-loader anchors a single per-manifest
|
|
56
|
+
* `<entry-dir>/.telo/npm/` install tree here, so every controller — registry
|
|
57
|
+
* tag or `local_path` — resolves through the same `node_modules`. Required
|
|
58
|
+
* for `pkg:npm` candidates; absent for callers that only resolve `pkg:cargo`
|
|
59
|
+
* (cargo loader has its own per-crate cache and does not need this).
|
|
60
|
+
*/
|
|
61
|
+
entryUrl?: string;
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
56
64
|
* Top-level controller-loader dispatcher. Picks a per-scheme sub-loader by
|
|
@@ -70,9 +78,9 @@ export interface ControllerLoaderOptions {
|
|
|
70
78
|
* `ControllerLoadFailed`) for the one that won.
|
|
71
79
|
*/
|
|
72
80
|
export declare class ControllerLoader {
|
|
73
|
-
private
|
|
74
|
-
private
|
|
75
|
-
private
|
|
81
|
+
private readonly emit;
|
|
82
|
+
private readonly npmLoader;
|
|
83
|
+
private readonly napiLoader;
|
|
76
84
|
constructor(options?: ControllerLoaderOptions);
|
|
77
85
|
load(purlCandidates: string[], baseUri: string, policy?: ControllerPolicy): Promise<ControllerInstance>;
|
|
78
86
|
private dispatchOne;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-loader.d.ts","sourceRoot":"","sources":["../src/controller-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAmC,MAAM,uBAAuB,CAAC;AAE1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAC/B,OAAO,GACP,cAAc,GACd,OAAO,GACP,aAAa,GACb,aAAa,CAAC;AAElB,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACxD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,uBAAuB,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAChF,GACD;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,OAAO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AMG;GACD;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1F,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmC;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;gBAEtC,OAAO,GAAE,uBAA4B;IAM3C,IAAI,CACR,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,kBAAkB,CAAC;YAqDhB,WAAW;CAY1B"}
|
|
@@ -21,9 +21,9 @@ import { DEFAULT_POLICY, POLICY_WILDCARD } from "./runtime-registry.js";
|
|
|
21
21
|
*/
|
|
22
22
|
export class ControllerLoader {
|
|
23
23
|
constructor(options = {}) {
|
|
24
|
-
this.npmLoader = new NpmControllerLoader();
|
|
25
|
-
this.napiLoader = new NapiControllerLoader();
|
|
26
24
|
this.emit = options.emit;
|
|
25
|
+
this.npmLoader = new NpmControllerLoader({ entryUrl: options.entryUrl });
|
|
26
|
+
this.napiLoader = new NapiControllerLoader();
|
|
27
27
|
}
|
|
28
28
|
async load(purlCandidates, baseUri, policy) {
|
|
29
29
|
if (!purlCandidates || purlCandidates.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-loader.js","sourceRoot":"","sources":["../src/controller-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAoB,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"controller-loader.js","sourceRoot":"","sources":["../src/controller-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAoB,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAsD1F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,gBAAgB;IAK3B,YAAY,UAAmC,EAAE;QAC/C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAmB,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,IAAI,CACR,cAAwB,EACxB,OAAe,EACf,MAAyB;QAEzB,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,YAAY,CAAC,0BAA0B,EAAE,oCAAoC,CAAC,CAAC;QAC3F,CAAC;QACD,MAAM,eAAe,GAAG,MAAM,IAAI,cAAc,CAAC;QACjD,MAAM,OAAO,GAAG,eAAe,CAAC,cAAc,EAAE,eAAe,CAAC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AAG,CAAC,SAAS,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -10,22 +10,137 @@ export interface NpmLoadResult {
|
|
|
10
10
|
instance: ControllerInstance;
|
|
11
11
|
source: NpmResolveSource;
|
|
12
12
|
}
|
|
13
|
+
export interface NpmControllerLoaderOptions {
|
|
14
|
+
/**
|
|
15
|
+
* URL of the entry manifest. The install root is anchored here so every
|
|
16
|
+
* controller in this kernel process resolves through one `node_modules`
|
|
17
|
+
* tree. Required at construction time when the kernel is the caller; the
|
|
18
|
+
* `pkg-name` cli command resolves it from its argument.
|
|
19
|
+
*/
|
|
20
|
+
entryUrl?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The npm-loader maintains a single install root per kernel process at
|
|
24
|
+
* `<entry-manifest-dir>/.telo/npm/`. Every controller — registry tag or
|
|
25
|
+
* `local_path` — is installed via `npm install <spec>` into this root, then
|
|
26
|
+
* imported from `<root>/node_modules/<pkg>`. This collapses two parallel
|
|
27
|
+
* module realms (kernel-side @telorun/sdk vs. controller-side @telorun/sdk)
|
|
28
|
+
* into one: the kernel's own SDK is wired in as a `file:` dep, npm/pnpm
|
|
29
|
+
* symlink it, and Node's ESM resolver follows the symlink to the same
|
|
30
|
+
* realpath as the kernel — so `Stream` (and any other class-identity-sensitive
|
|
31
|
+
* type) has a single constructor across the process.
|
|
32
|
+
*
|
|
33
|
+
* Per-kernel state lives on each `NpmControllerLoader` instance (one is
|
|
34
|
+
* constructed per `ControllerLoader`, which is itself constructed per
|
|
35
|
+
* `Telo.Definition.init`). The instance caches the install-root materialization
|
|
36
|
+
* promise (`rootReady`), the set of installed specs (`installedSpecs`), an
|
|
37
|
+
* in-flight install map for single-flight dedupe (`inFlight`), and a snapshot
|
|
38
|
+
* of the install root's `dependencies` map (`rootDeps`) so per-controller
|
|
39
|
+
* fast paths can hit without re-reading `package.json`. Cross-kernel and
|
|
40
|
+
* cross-process safety is provided by a filesystem lock on `<root>/.lock`.
|
|
41
|
+
*/
|
|
13
42
|
export declare class NpmControllerLoader {
|
|
43
|
+
private readonly entryUrl?;
|
|
44
|
+
/**
|
|
45
|
+
* Per-process cache of "this controller's package + version is already
|
|
46
|
+
* installed in the root and matches our spec" so concurrent loads of the
|
|
47
|
+
* same definition skip the lock + re-check round-trip after the first
|
|
48
|
+
* caller wins. Keyed by absolute spec (e.g. `@telorun/sdk@file:/abs/path`
|
|
49
|
+
* or `@scope/pkg@^1.2.3`).
|
|
50
|
+
*/
|
|
51
|
+
private readonly installedSpecs;
|
|
14
52
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
53
|
+
* In-flight installs keyed by canonical spec. Two callers racing for the
|
|
54
|
+
* same spec share one `npm install <spec>` invocation rather than each
|
|
55
|
+
* acquiring the fs-lock and reinstalling.
|
|
18
56
|
*/
|
|
57
|
+
private readonly inFlight;
|
|
58
|
+
/**
|
|
59
|
+
* Promise that resolves when the install root has been materialized
|
|
60
|
+
* (package.json written, kernel-side runtime deps wired up, base
|
|
61
|
+
* `npm install` completed). Subsequent loads await this once.
|
|
62
|
+
*/
|
|
63
|
+
private rootReady?;
|
|
64
|
+
/**
|
|
65
|
+
* Snapshot of the install root's `dependencies` map at the time of last
|
|
66
|
+
* read. Set during `materializeInstallRoot()` and refreshed when an
|
|
67
|
+
* install adds a new spec. Lets the per-controller fast path decide on
|
|
68
|
+
* "already installed?" without re-reading and re-parsing `package.json`
|
|
69
|
+
* for every load — a single test typically touches 5–10 controllers,
|
|
70
|
+
* and a test suite spawns one Kernel per fixture, so the multiplier is
|
|
71
|
+
* `tests * controllers` file reads otherwise.
|
|
72
|
+
*/
|
|
73
|
+
private rootDeps;
|
|
74
|
+
constructor(options?: NpmControllerLoaderOptions);
|
|
19
75
|
load(purl: string, baseUri: string): Promise<NpmLoadResult>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Compute the install root from the entry URL, write a baseline package.json
|
|
78
|
+
* pinning the kernel's own runtime deps as `file:` references, run a single
|
|
79
|
+
* `npm install` once, and return the absolute root path. Memoized for the
|
|
80
|
+
* lifetime of this loader instance.
|
|
81
|
+
*/
|
|
82
|
+
private ensureInstallRoot;
|
|
83
|
+
private materializeInstallRoot;
|
|
84
|
+
/**
|
|
85
|
+
* Populate the in-process caches that drive the per-controller fast path:
|
|
86
|
+
* `installedSpecs` (so duplicate calls from the same Kernel return immediately)
|
|
87
|
+
* and `rootDeps` (so the fast path doesn't re-read `package.json` per load).
|
|
88
|
+
* `dependencies` is the freshly-built map we know is on disk; it's used as a
|
|
89
|
+
* fallback when the actual file-read fails (e.g. immediately after a hot
|
|
90
|
+
* reload where the writer is still racing).
|
|
91
|
+
*/
|
|
92
|
+
private seedDepCaches;
|
|
93
|
+
/**
|
|
94
|
+
* Install one controller spec into the existing root. Single-flight per
|
|
95
|
+
* spec within the process; cross-process safety is the fs-lock around the
|
|
96
|
+
* `npm install` call. If the spec is already present in the manifest's
|
|
97
|
+
* package.json (under `dependencies`), skip — reusing the previous install.
|
|
98
|
+
*
|
|
99
|
+
* `kind` distinguishes a `local_path` source (loader synthesized `file:`
|
|
100
|
+
* spec) from a registry tag. The CLI silences progress for both `cache`
|
|
101
|
+
* and `local`; `npm-install` is the only event surfaced. Folding this
|
|
102
|
+
* decision in here means the caller no longer needs to override the
|
|
103
|
+
* returned source after the fact.
|
|
104
|
+
*/
|
|
105
|
+
private installPackage;
|
|
30
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Walk up from `from` until the directory contains a `package.json`.
|
|
109
|
+
* Returns null at filesystem root if none found.
|
|
110
|
+
*/
|
|
111
|
+
declare function walkUpToPackageRoot(from: string): Promise<string | null>;
|
|
112
|
+
/**
|
|
113
|
+
* Normalize a `file:` spec to an absolute path so two specs that point at the
|
|
114
|
+
* same source — one absolute (what the loader synthesizes from `local_path`)
|
|
115
|
+
* and one relative (what npm rewrites into the install root's package.json) —
|
|
116
|
+
* compare equal. Specs that aren't `file:` deps pass through unchanged, since
|
|
117
|
+
* registry tags compare exactly.
|
|
118
|
+
*/
|
|
119
|
+
declare function normalizeFileSpec(spec: string, installRoot: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* Try a path verbatim, then with `.js` appended if it has no extension.
|
|
122
|
+
* Returns the first path that exists, or null if neither does. Centralizes
|
|
123
|
+
* the extension-fallback rule so it's not repeated at every call site.
|
|
124
|
+
*/
|
|
125
|
+
declare function tryResolveFile(absPath: string): Promise<string | null>;
|
|
126
|
+
declare function resolvePackageExportTarget(exportsField: any, entry: string, conditions: ReadonlyArray<string>): string | null;
|
|
127
|
+
declare function resolveExportTargetValue(target: any, conditions: ReadonlyArray<string>, depth: number): string | null;
|
|
128
|
+
/**
|
|
129
|
+
* Pure helpers exported under a stable namespace for unit tests. The class
|
|
130
|
+
* itself isn't useful in isolation (it requires a package manager binary, a
|
|
131
|
+
* filesystem, and a network for non-local specs); these are the deterministic
|
|
132
|
+
* parts that benefit from cheap unit coverage and have no side effects.
|
|
133
|
+
*
|
|
134
|
+
* Not part of the kernel's public API — consumers should not import these.
|
|
135
|
+
*/
|
|
136
|
+
export declare const __testing__: {
|
|
137
|
+
normalizeFileSpec: typeof normalizeFileSpec;
|
|
138
|
+
resolvePackageExportTarget: typeof resolvePackageExportTarget;
|
|
139
|
+
resolveExportTargetValue: typeof resolveExportTargetValue;
|
|
140
|
+
tryResolveFile: typeof tryResolveFile;
|
|
141
|
+
walkUpToPackageRoot: typeof walkUpToPackageRoot;
|
|
142
|
+
EXPORTS_MAX_DEPTH: number;
|
|
143
|
+
DEFAULT_RESOLVER_CONDITIONS: readonly string[];
|
|
144
|
+
};
|
|
145
|
+
export {};
|
|
31
146
|
//# sourceMappingURL=npm-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm-loader.d.ts","sourceRoot":"","sources":["../../src/controller-loaders/npm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"npm-loader.d.ts","sourceRoot":"","sources":["../../src/controller-loaders/npm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAyClD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,cAAc,GAAG,aAAa,GAAG,OAAO,CAAC;AAoBlF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IAEnC;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;IAEpD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAE7D;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAC,CAAkB;IAEpC;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,CAA8B;gBAElC,OAAO,GAAE,0BAA+B;IAI9C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAcjE;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;YAUX,sBAAsB;IA6FpC;;;;;;;OAOG;YACW,aAAa;IAU3B;;;;;;;;;;;OAWG;YACW,cAAc;CAsF7B;AAsCD;;;GAGG;AACH,iBAAe,mBAAmB,CAAC,IAAI,EAA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