@c9up/vellum 0.1.1 → 0.1.2
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/VellumProvider.d.ts +1 -0
- package/dist/VellumProvider.d.ts.map +1 -1
- package/dist/VellumProvider.js +16 -3
- package/dist/VellumProvider.js.map +1 -1
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +5 -28
- package/dist/native.js.map +1 -1
- package/dist/services/main.d.ts +10 -1
- package/dist/services/main.d.ts.map +1 -1
- package/dist/services/main.js +12 -1
- package/dist/services/main.js.map +1 -1
- package/dist/vendor/nativeBinary.d.ts +43 -0
- package/dist/vendor/nativeBinary.d.ts.map +1 -0
- package/dist/vendor/nativeBinary.js +99 -0
- package/dist/vendor/nativeBinary.js.map +1 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/src/VellumProvider.ts +17 -3
- package/src/native.ts +8 -30
- package/src/services/main.ts +13 -1
- package/src/vendor/nativeBinary.ts +110 -0
package/dist/VellumProvider.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VellumProvider.d.ts","sourceRoot":"","sources":["../src/VellumProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,oBAAoB,CAAC;AAI5B,UAAU,eAAe;IACxB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IACxD,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACjD;AAED,UAAU,iBAAiB;IAC1B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,EAAE,iBAAiB,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,OAAO,cAAc
|
|
1
|
+
{"version":3,"file":"VellumProvider.d.ts","sourceRoot":"","sources":["../src/VellumProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,oBAAoB,CAAC;AAI5B,UAAU,eAAe;IACxB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IACxD,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACjD;AAED,UAAU,iBAAiB;IAC1B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,EAAE,iBAAiB,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,OAAO,cAAc;;IAItB,SAAS,CAAC,GAAG,EAAE,gBAAgB;gBAArB,GAAG,EAAE,gBAAgB;IAE3C,QAAQ,IAAI,IAAI;IAeV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAU/B"}
|
package/dist/VellumProvider.js
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* duck-typed below, which is what keeps the package publishable on its own and
|
|
6
6
|
* usable from a host that is not Ream.
|
|
7
7
|
*/
|
|
8
|
-
import { setVellum } from "./services/main.js";
|
|
8
|
+
import { clearVellum, getVellum, setVellum } from "./services/main.js";
|
|
9
9
|
import "./augmentations.js";
|
|
10
10
|
import { Vellum } from "./Vellum.js";
|
|
11
11
|
export default class VellumProvider {
|
|
12
12
|
app;
|
|
13
|
+
/** The service this provider seated, so shutdown only clears its own. */
|
|
14
|
+
#service;
|
|
13
15
|
constructor(app) {
|
|
14
16
|
this.app = app;
|
|
15
17
|
}
|
|
@@ -26,8 +28,19 @@ export default class VellumProvider {
|
|
|
26
28
|
this.app.container.singleton("vellum", () => this.app.container.resolve(Vellum));
|
|
27
29
|
}
|
|
28
30
|
async boot() {
|
|
29
|
-
|
|
31
|
+
const service = await this.app.container.resolve(Vellum);
|
|
32
|
+
this.#service = service;
|
|
33
|
+
setVellum(service);
|
|
34
|
+
}
|
|
35
|
+
async shutdown() {
|
|
36
|
+
// Release the module-level singleton, while it is still ours: a stopped
|
|
37
|
+
// application left a dead Vellum reachable through `services/main`, and
|
|
38
|
+
// with two applications in one process the survivor's service must not
|
|
39
|
+
// be the one cleared.
|
|
40
|
+
if (this.#service !== undefined && getVellum() === this.#service) {
|
|
41
|
+
clearVellum();
|
|
42
|
+
}
|
|
43
|
+
this.#service = undefined;
|
|
30
44
|
}
|
|
31
|
-
async shutdown() { }
|
|
32
45
|
}
|
|
33
46
|
//# sourceMappingURL=VellumProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VellumProvider.js","sourceRoot":"","sources":["../src/VellumProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"VellumProvider.js","sourceRoot":"","sources":["../src/VellumProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBrC,MAAM,CAAC,OAAO,OAAO,cAAc;IAIZ;IAHtB,yEAAyE;IACzE,QAAQ,CAAqB;IAE7B,YAAsB,GAAqB;QAArB,QAAG,GAAH,GAAG,CAAkB;IAAG,CAAC;IAE/C,QAAQ;QACP,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;YACzC,iEAAiE;YACjE,uDAAuD;YACvD,wDAAwD;YACxD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAe,QAAQ,CAAC,IAAI,EAAE,CAAC;YACjE,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,uEAAuE;QACvE,uDAAuD;QACvD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,EAAE,CAC3C,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAS,MAAM,CAAC,CAC1C,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAS,MAAM,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,SAAS,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,QAAQ;QACb,wEAAwE;QACxE,wEAAwE;QACxE,uEAAuE;QACvE,sBAAsB;QACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,SAAS,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClE,WAAW,EAAE,CAAC;QACf,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC3B,CAAC;CACD"}
|
package/dist/native.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB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AAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,EACnC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAEhE;AAED,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACX,MAAM,CAIR;AAED,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,kBAAkB,GACvB,OAAO,CAAC,eAAe,EAAE,CAAC,CAE5B;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAErE;AAED,wBAAgB,qBAAqB,CACpC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACZ,MAAM,CAIR;AAED,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,GAAG,IAAI,GACf,gBAAgB,CAIlB"}
|
package/dist/native.js
CHANGED
|
@@ -6,43 +6,20 @@
|
|
|
6
6
|
* failure with an actionable message — never a silent degradation that lets
|
|
7
7
|
* one deployment behave differently from another.
|
|
8
8
|
*/
|
|
9
|
-
import { createRequire } from "node:module";
|
|
10
|
-
import { dirname, join } from "node:path";
|
|
11
|
-
import { arch, platform } from "node:process";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
9
|
import { VellumError } from "./errors.js";
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
"linux-arm64": "linux-arm64-gnu",
|
|
19
|
-
"darwin-x64": "darwin-x64",
|
|
20
|
-
"darwin-arm64": "darwin-arm64",
|
|
21
|
-
"win32-x64": "win32-x64-msvc",
|
|
22
|
-
};
|
|
23
|
-
let native;
|
|
24
|
-
let loadError;
|
|
25
|
-
try {
|
|
26
|
-
const suffix = platformMap[`${platform}-${arch}`];
|
|
27
|
-
if (suffix) {
|
|
28
|
-
native = requireNative(join(here, `../index.${suffix}.node`));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
loadError = error;
|
|
33
|
-
}
|
|
10
|
+
import { loadNativeBinary, unavailableReason as vendorUnavailableReason, } from "./vendor/nativeBinary.js";
|
|
11
|
+
const attempt = loadNativeBinary();
|
|
12
|
+
const native = attempt.loaded ? attempt.binary : undefined;
|
|
13
|
+
const loadError = attempt.loaded ? undefined : attempt.cause;
|
|
34
14
|
export function isNativeAvailable() {
|
|
35
15
|
return native !== undefined;
|
|
36
16
|
}
|
|
37
17
|
/** Why the engine could not be loaded, phrased for whoever has to fix it. */
|
|
38
18
|
function unavailableReason() {
|
|
39
|
-
const target = `${platform}-${arch}`;
|
|
40
19
|
if (loadError !== undefined) {
|
|
41
20
|
return `failed to load (${loadError instanceof Error ? loadError.message : String(loadError)})`;
|
|
42
21
|
}
|
|
43
|
-
return
|
|
44
|
-
? "binary not found"
|
|
45
|
-
: `no prebuilt binary for ${target}`;
|
|
22
|
+
return vendorUnavailableReason();
|
|
46
23
|
}
|
|
47
24
|
/** Raised when an operation needs the Rust engine and it is not there. */
|
|
48
25
|
export class VellumNativeRequiredError extends VellumError {
|
package/dist/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiB1C,OAAO,EACN,gBAAgB,EAChB,iBAAiB,IAAI,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Y,CAAC,WAAW,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,WAAmB,EACnB,MAAc;IAEd,OAAO,GAAG,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,CACtC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAC3C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CACnC,QAAgB,EAChB,WAAmB,EACnB,MAAc,EACd,EAAiB;IAEjB,OAAO,GAAG,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,CACtC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,IAAI,SAAS,CAAC,CACrE,CAAC;AACH,CAAC"}
|
package/dist/services/main.d.ts
CHANGED
|
@@ -8,7 +8,16 @@
|
|
|
8
8
|
import type { Vellum } from "../Vellum.js";
|
|
9
9
|
/** @internal Called by the provider once the service exists. */
|
|
10
10
|
export declare function setVellum(service: Vellum): void;
|
|
11
|
-
/** @internal
|
|
11
|
+
/** @internal Read the seated service, if there is one. */
|
|
12
|
+
export declare function getVellum(): Vellum | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* @internal Forget the service — called by the provider on shutdown, and by
|
|
15
|
+
* tests between cases.
|
|
16
|
+
*
|
|
17
|
+
* The caller checks ownership first (`getVellum() === mine`): two applications
|
|
18
|
+
* share this module in one process, and the one shutting down must not clear a
|
|
19
|
+
* service the other has since seated.
|
|
20
|
+
*/
|
|
12
21
|
export declare function clearVellum(): void;
|
|
13
22
|
declare const vellum: Vellum;
|
|
14
23
|
export default vellum;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/services/main.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/services/main.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,0DAA0D;AAC1D,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAE9C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAYD,QAAA,MAAM,MAAM,EAAE,MAaZ,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/dist/services/main.js
CHANGED
|
@@ -10,7 +10,18 @@ let instance;
|
|
|
10
10
|
export function setVellum(service) {
|
|
11
11
|
instance = service;
|
|
12
12
|
}
|
|
13
|
-
/** @internal
|
|
13
|
+
/** @internal Read the seated service, if there is one. */
|
|
14
|
+
export function getVellum() {
|
|
15
|
+
return instance;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @internal Forget the service — called by the provider on shutdown, and by
|
|
19
|
+
* tests between cases.
|
|
20
|
+
*
|
|
21
|
+
* The caller checks ownership first (`getVellum() === mine`): two applications
|
|
22
|
+
* share this module in one process, and the one shutting down must not clear a
|
|
23
|
+
* service the other has since seated.
|
|
24
|
+
*/
|
|
14
25
|
export function clearVellum() {
|
|
15
26
|
instance = undefined;
|
|
16
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/services/main.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,IAAI,QAA4B,CAAC;AAEjC,gEAAgE;AAChE,MAAM,UAAU,SAAS,CAAC,OAAe;IACxC,QAAQ,GAAG,OAAO,CAAC;AACpB,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/services/main.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,IAAI,QAA4B,CAAC;AAEjC,gEAAgE;AAChE,MAAM,UAAU,SAAS,CAAC,OAAe;IACxC,QAAQ,GAAG,OAAO,CAAC;AACpB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,SAAS;IACxB,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW;IAC1B,QAAQ,GAAG,SAAS,CAAC;AACtB,CAAC;AAED,SAAS,OAAO;IACf,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACd,qEAAqE;YACpE,2EAA2E,CAC5E,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,MAAM,MAAM,GAAW,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;IACrD,GAAG,CAAC,OAAO,EAAE,QAAQ;QACpB,uEAAuE;QACvE,iEAAiE;QACjE,qEAAqE;QACrE,qCAAqC;QACrC,IAAI,QAAQ,KAAK,MAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACzD,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,CAAC;CACD,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every `platform-arch` a binary is built for.
|
|
3
|
+
*
|
|
4
|
+
* For the message a package raises when it refuses: "no binary for
|
|
5
|
+
* linux-riscv64" is only actionable next to the list of what there IS.
|
|
6
|
+
*/
|
|
7
|
+
export declare function supportedTargets(): readonly string[];
|
|
8
|
+
/** The suffix a given `platform-arch` builds under, or `undefined`. */
|
|
9
|
+
export declare function nativeTargetSuffix(target: string): string | undefined;
|
|
10
|
+
/** The suffix for THIS platform, or `undefined` where no binary is built. */
|
|
11
|
+
export declare function nativeBinarySuffix(): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Why the binary is not there, phrased for whoever has to fix it.
|
|
14
|
+
*
|
|
15
|
+
* "not found" and "not built for your platform" call for different actions,
|
|
16
|
+
* and a single "unavailable" leaves the reader to guess which one they are
|
|
17
|
+
* looking at.
|
|
18
|
+
*/
|
|
19
|
+
export declare function unavailableReason(cause?: unknown): string;
|
|
20
|
+
/**
|
|
21
|
+
* `musl` builds under a different suffix, and the failure is otherwise
|
|
22
|
+
* baffling: the file is there, and `require` still refuses it. Worth saying so
|
|
23
|
+
* in a message rather than leaving a reader to discover glibc.
|
|
24
|
+
*/
|
|
25
|
+
export declare function muslHint(): string;
|
|
26
|
+
/** What a load attempt did, so the caller can apply its own policy. */
|
|
27
|
+
export type NativeBinaryResult<T> = {
|
|
28
|
+
loaded: true;
|
|
29
|
+
binary: T;
|
|
30
|
+
} | {
|
|
31
|
+
loaded: false;
|
|
32
|
+
suffix: string | undefined;
|
|
33
|
+
cause?: unknown;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Load `<package root>/index.<suffix>.node`.
|
|
37
|
+
*
|
|
38
|
+
* The path is fixed rather than passed: this file is generated into
|
|
39
|
+
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
40
|
+
* `src` and from `dist` alike.
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadNativeBinary<T>(): NativeBinaryResult<T>;
|
|
43
|
+
//# sourceMappingURL=nativeBinary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeBinary.d.ts","sourceRoot":"","sources":["../../src/vendor/nativeBinary.ts"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,SAAS,MAAM,EAAE,CAEpD;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAQzD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAIjC;AAED,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAC7B;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAElE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAa3D"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Generated from scripts/vendor/nativeBinary.ts — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// This package is published and built from its own repository, so the file
|
|
4
|
+
// has to exist here rather than be imported. `pnpm vendor:sync` rewrites it,
|
|
5
|
+
// and `pnpm vendor:check` fails if this copy has drifted from the original.
|
|
6
|
+
/**
|
|
7
|
+
* Finding the NAPI binary a package ships beside itself.
|
|
8
|
+
*
|
|
9
|
+
* Every package with a Rust engine repeats the same table: napi-rs names its
|
|
10
|
+
* artefacts `index.<platform>-<arch>-<abi>.node`, and the mapping from Node's
|
|
11
|
+
* `platform`/`arch` to that suffix is the part that must never differ between
|
|
12
|
+
* packages. Adding a target means adding it everywhere, and a package that
|
|
13
|
+
* missed the edit fails only on that platform — which is exactly the failure
|
|
14
|
+
* nobody reproduces.
|
|
15
|
+
*
|
|
16
|
+
* What is NOT here is the policy. Some packages degrade when the binary is
|
|
17
|
+
* absent and answer `undefined`; others refuse loudly with build instructions.
|
|
18
|
+
* Both are right for their package, so the loader reports what happened and
|
|
19
|
+
* the caller decides.
|
|
20
|
+
*/
|
|
21
|
+
import { createRequire } from "node:module";
|
|
22
|
+
import { dirname, join } from "node:path";
|
|
23
|
+
import { arch, platform } from "node:process";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
/** Node's `platform-arch` → the suffix napi-rs builds under. */
|
|
26
|
+
const TARGETS = {
|
|
27
|
+
"linux-x64": "linux-x64-gnu",
|
|
28
|
+
"linux-arm64": "linux-arm64-gnu",
|
|
29
|
+
"darwin-x64": "darwin-x64",
|
|
30
|
+
"darwin-arm64": "darwin-arm64",
|
|
31
|
+
"win32-x64": "win32-x64-msvc",
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Every `platform-arch` a binary is built for.
|
|
35
|
+
*
|
|
36
|
+
* For the message a package raises when it refuses: "no binary for
|
|
37
|
+
* linux-riscv64" is only actionable next to the list of what there IS.
|
|
38
|
+
*/
|
|
39
|
+
export function supportedTargets() {
|
|
40
|
+
return Object.keys(TARGETS);
|
|
41
|
+
}
|
|
42
|
+
/** The suffix a given `platform-arch` builds under, or `undefined`. */
|
|
43
|
+
export function nativeTargetSuffix(target) {
|
|
44
|
+
return TARGETS[target];
|
|
45
|
+
}
|
|
46
|
+
/** The suffix for THIS platform, or `undefined` where no binary is built. */
|
|
47
|
+
export function nativeBinarySuffix() {
|
|
48
|
+
return nativeTargetSuffix(`${platform}-${arch}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Why the binary is not there, phrased for whoever has to fix it.
|
|
52
|
+
*
|
|
53
|
+
* "not found" and "not built for your platform" call for different actions,
|
|
54
|
+
* and a single "unavailable" leaves the reader to guess which one they are
|
|
55
|
+
* looking at.
|
|
56
|
+
*/
|
|
57
|
+
export function unavailableReason(cause) {
|
|
58
|
+
if (cause !== undefined) {
|
|
59
|
+
return `failed to load (${cause instanceof Error ? cause.message : String(cause)})`;
|
|
60
|
+
}
|
|
61
|
+
const target = `${platform}-${arch}`;
|
|
62
|
+
return nativeTargetSuffix(target) !== undefined
|
|
63
|
+
? "binary not found"
|
|
64
|
+
: `no prebuilt binary for ${target}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `musl` builds under a different suffix, and the failure is otherwise
|
|
68
|
+
* baffling: the file is there, and `require` still refuses it. Worth saying so
|
|
69
|
+
* in a message rather than leaving a reader to discover glibc.
|
|
70
|
+
*/
|
|
71
|
+
export function muslHint() {
|
|
72
|
+
return platform === "linux"
|
|
73
|
+
? " On Alpine/musl, the gnu binary will not load — build the musl target."
|
|
74
|
+
: "";
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Load `<package root>/index.<suffix>.node`.
|
|
78
|
+
*
|
|
79
|
+
* The path is fixed rather than passed: this file is generated into
|
|
80
|
+
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
81
|
+
* `src` and from `dist` alike.
|
|
82
|
+
*/
|
|
83
|
+
export function loadNativeBinary() {
|
|
84
|
+
const suffix = nativeBinarySuffix();
|
|
85
|
+
if (suffix === undefined)
|
|
86
|
+
return { loaded: false, suffix };
|
|
87
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
88
|
+
try {
|
|
89
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
90
|
+
return {
|
|
91
|
+
loaded: true,
|
|
92
|
+
binary: nodeRequire(join(here, `../../index.${suffix}.node`)),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (cause) {
|
|
96
|
+
return { loaded: false, suffix, cause };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=nativeBinary.js.map
|
|
@@ -0,0 +1 @@
|
|
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OAAO,kBAAkB,CAAC,MAAM,CAAC,KAAK,SAAS;QAC9C,CAAC,CAAC,kBAAkB;QACpB,CAAC,CAAC,0BAA0B,MAAM,EAAE,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACvB,OAAO,QAAQ,KAAK,OAAO;QAC1B,CAAC,CAAC,wEAAwE;QAC1E,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AAOD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC/B,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,IAAI,CAAC;QACJ,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO;YACN,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,MAAM,OAAO,CAAC,CAAM;SAClE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACzC,CAAC;AACF,CAAC"}
|
|
Binary file
|
package/package.json
CHANGED
package/src/VellumProvider.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* usable from a host that is not Ream.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { setVellum } from "./services/main.js";
|
|
9
|
+
import { clearVellum, getVellum, setVellum } from "./services/main.js";
|
|
10
10
|
import "./augmentations.js";
|
|
11
11
|
import type { VellumConfig } from "./Vellum.js";
|
|
12
12
|
import { Vellum } from "./Vellum.js";
|
|
@@ -26,6 +26,9 @@ export interface VellumAppContext {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export default class VellumProvider {
|
|
29
|
+
/** The service this provider seated, so shutdown only clears its own. */
|
|
30
|
+
#service: Vellum | undefined;
|
|
31
|
+
|
|
29
32
|
constructor(protected app: VellumAppContext) {}
|
|
30
33
|
|
|
31
34
|
register(): void {
|
|
@@ -44,8 +47,19 @@ export default class VellumProvider {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
async boot(): Promise<void> {
|
|
47
|
-
|
|
50
|
+
const service = await this.app.container.resolve<Vellum>(Vellum);
|
|
51
|
+
this.#service = service;
|
|
52
|
+
setVellum(service);
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
async shutdown(): Promise<void> {
|
|
55
|
+
async shutdown(): Promise<void> {
|
|
56
|
+
// Release the module-level singleton, while it is still ours: a stopped
|
|
57
|
+
// application left a dead Vellum reachable through `services/main`, and
|
|
58
|
+
// with two applications in one process the survivor's service must not
|
|
59
|
+
// be the one cleared.
|
|
60
|
+
if (this.#service !== undefined && getVellum() === this.#service) {
|
|
61
|
+
clearVellum();
|
|
62
|
+
}
|
|
63
|
+
this.#service = undefined;
|
|
64
|
+
}
|
|
51
65
|
}
|
package/src/native.ts
CHANGED
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
* one deployment behave differently from another.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { createRequire } from "node:module";
|
|
11
|
-
import { dirname, join } from "node:path";
|
|
12
|
-
import { arch, platform } from "node:process";
|
|
13
|
-
import { fileURLToPath } from "node:url";
|
|
14
10
|
import { VellumError } from "./errors.js";
|
|
15
11
|
import type {
|
|
16
12
|
DocumentInfo,
|
|
@@ -28,17 +24,10 @@ import type {
|
|
|
28
24
|
SignatureReport,
|
|
29
25
|
TimestampQuery,
|
|
30
26
|
} from "./native/generated.js";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const platformMap: Record<string, string> = {
|
|
36
|
-
"linux-x64": "linux-x64-gnu",
|
|
37
|
-
"linux-arm64": "linux-arm64-gnu",
|
|
38
|
-
"darwin-x64": "darwin-x64",
|
|
39
|
-
"darwin-arm64": "darwin-arm64",
|
|
40
|
-
"win32-x64": "win32-x64-msvc",
|
|
41
|
-
};
|
|
27
|
+
import {
|
|
28
|
+
loadNativeBinary,
|
|
29
|
+
unavailableReason as vendorUnavailableReason,
|
|
30
|
+
} from "./vendor/nativeBinary.js";
|
|
42
31
|
|
|
43
32
|
/**
|
|
44
33
|
* The engine's surface, as the Rust declares it.
|
|
@@ -60,17 +49,9 @@ export type {
|
|
|
60
49
|
SignatureReport,
|
|
61
50
|
} from "./native/generated.js";
|
|
62
51
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const suffix = platformMap[`${platform}-${arch}`];
|
|
68
|
-
if (suffix) {
|
|
69
|
-
native = requireNative(join(here, `../index.${suffix}.node`));
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
loadError = error;
|
|
73
|
-
}
|
|
52
|
+
const attempt = loadNativeBinary<NativeVellum>();
|
|
53
|
+
const native = attempt.loaded ? attempt.binary : undefined;
|
|
54
|
+
const loadError = attempt.loaded ? undefined : attempt.cause;
|
|
74
55
|
|
|
75
56
|
export function isNativeAvailable(): boolean {
|
|
76
57
|
return native !== undefined;
|
|
@@ -78,13 +59,10 @@ export function isNativeAvailable(): boolean {
|
|
|
78
59
|
|
|
79
60
|
/** Why the engine could not be loaded, phrased for whoever has to fix it. */
|
|
80
61
|
function unavailableReason(): string {
|
|
81
|
-
const target = `${platform}-${arch}`;
|
|
82
62
|
if (loadError !== undefined) {
|
|
83
63
|
return `failed to load (${loadError instanceof Error ? loadError.message : String(loadError)})`;
|
|
84
64
|
}
|
|
85
|
-
return
|
|
86
|
-
? "binary not found"
|
|
87
|
-
: `no prebuilt binary for ${target}`;
|
|
65
|
+
return vendorUnavailableReason();
|
|
88
66
|
}
|
|
89
67
|
|
|
90
68
|
/** Raised when an operation needs the Rust engine and it is not there. */
|
package/src/services/main.ts
CHANGED
|
@@ -15,7 +15,19 @@ export function setVellum(service: Vellum): void {
|
|
|
15
15
|
instance = service;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/** @internal
|
|
18
|
+
/** @internal Read the seated service, if there is one. */
|
|
19
|
+
export function getVellum(): Vellum | undefined {
|
|
20
|
+
return instance;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @internal Forget the service — called by the provider on shutdown, and by
|
|
25
|
+
* tests between cases.
|
|
26
|
+
*
|
|
27
|
+
* The caller checks ownership first (`getVellum() === mine`): two applications
|
|
28
|
+
* share this module in one process, and the one shutting down must not clear a
|
|
29
|
+
* service the other has since seated.
|
|
30
|
+
*/
|
|
19
31
|
export function clearVellum(): void {
|
|
20
32
|
instance = undefined;
|
|
21
33
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Generated from scripts/vendor/nativeBinary.ts — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// This package is published and built from its own repository, so the file
|
|
4
|
+
// has to exist here rather than be imported. `pnpm vendor:sync` rewrites it,
|
|
5
|
+
// and `pnpm vendor:check` fails if this copy has drifted from the original.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Finding the NAPI binary a package ships beside itself.
|
|
9
|
+
*
|
|
10
|
+
* Every package with a Rust engine repeats the same table: napi-rs names its
|
|
11
|
+
* artefacts `index.<platform>-<arch>-<abi>.node`, and the mapping from Node's
|
|
12
|
+
* `platform`/`arch` to that suffix is the part that must never differ between
|
|
13
|
+
* packages. Adding a target means adding it everywhere, and a package that
|
|
14
|
+
* missed the edit fails only on that platform — which is exactly the failure
|
|
15
|
+
* nobody reproduces.
|
|
16
|
+
*
|
|
17
|
+
* What is NOT here is the policy. Some packages degrade when the binary is
|
|
18
|
+
* absent and answer `undefined`; others refuse loudly with build instructions.
|
|
19
|
+
* Both are right for their package, so the loader reports what happened and
|
|
20
|
+
* the caller decides.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { createRequire } from "node:module";
|
|
24
|
+
import { dirname, join } from "node:path";
|
|
25
|
+
import { arch, platform } from "node:process";
|
|
26
|
+
import { fileURLToPath } from "node:url";
|
|
27
|
+
|
|
28
|
+
/** Node's `platform-arch` → the suffix napi-rs builds under. */
|
|
29
|
+
const TARGETS: Record<string, string> = {
|
|
30
|
+
"linux-x64": "linux-x64-gnu",
|
|
31
|
+
"linux-arm64": "linux-arm64-gnu",
|
|
32
|
+
"darwin-x64": "darwin-x64",
|
|
33
|
+
"darwin-arm64": "darwin-arm64",
|
|
34
|
+
"win32-x64": "win32-x64-msvc",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Every `platform-arch` a binary is built for.
|
|
39
|
+
*
|
|
40
|
+
* For the message a package raises when it refuses: "no binary for
|
|
41
|
+
* linux-riscv64" is only actionable next to the list of what there IS.
|
|
42
|
+
*/
|
|
43
|
+
export function supportedTargets(): readonly string[] {
|
|
44
|
+
return Object.keys(TARGETS);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The suffix a given `platform-arch` builds under, or `undefined`. */
|
|
48
|
+
export function nativeTargetSuffix(target: string): string | undefined {
|
|
49
|
+
return TARGETS[target];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The suffix for THIS platform, or `undefined` where no binary is built. */
|
|
53
|
+
export function nativeBinarySuffix(): string | undefined {
|
|
54
|
+
return nativeTargetSuffix(`${platform}-${arch}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Why the binary is not there, phrased for whoever has to fix it.
|
|
59
|
+
*
|
|
60
|
+
* "not found" and "not built for your platform" call for different actions,
|
|
61
|
+
* and a single "unavailable" leaves the reader to guess which one they are
|
|
62
|
+
* looking at.
|
|
63
|
+
*/
|
|
64
|
+
export function unavailableReason(cause?: unknown): string {
|
|
65
|
+
if (cause !== undefined) {
|
|
66
|
+
return `failed to load (${cause instanceof Error ? cause.message : String(cause)})`;
|
|
67
|
+
}
|
|
68
|
+
const target = `${platform}-${arch}`;
|
|
69
|
+
return nativeTargetSuffix(target) !== undefined
|
|
70
|
+
? "binary not found"
|
|
71
|
+
: `no prebuilt binary for ${target}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `musl` builds under a different suffix, and the failure is otherwise
|
|
76
|
+
* baffling: the file is there, and `require` still refuses it. Worth saying so
|
|
77
|
+
* in a message rather than leaving a reader to discover glibc.
|
|
78
|
+
*/
|
|
79
|
+
export function muslHint(): string {
|
|
80
|
+
return platform === "linux"
|
|
81
|
+
? " On Alpine/musl, the gnu binary will not load — build the musl target."
|
|
82
|
+
: "";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** What a load attempt did, so the caller can apply its own policy. */
|
|
86
|
+
export type NativeBinaryResult<T> =
|
|
87
|
+
| { loaded: true; binary: T }
|
|
88
|
+
| { loaded: false; suffix: string | undefined; cause?: unknown };
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Load `<package root>/index.<suffix>.node`.
|
|
92
|
+
*
|
|
93
|
+
* The path is fixed rather than passed: this file is generated into
|
|
94
|
+
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
95
|
+
* `src` and from `dist` alike.
|
|
96
|
+
*/
|
|
97
|
+
export function loadNativeBinary<T>(): NativeBinaryResult<T> {
|
|
98
|
+
const suffix = nativeBinarySuffix();
|
|
99
|
+
if (suffix === undefined) return { loaded: false, suffix };
|
|
100
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
101
|
+
try {
|
|
102
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
103
|
+
return {
|
|
104
|
+
loaded: true,
|
|
105
|
+
binary: nodeRequire(join(here, `../../index.${suffix}.node`)) as T,
|
|
106
|
+
};
|
|
107
|
+
} catch (cause) {
|
|
108
|
+
return { loaded: false, suffix, cause };
|
|
109
|
+
}
|
|
110
|
+
}
|