@bluelibs/runner 4.4.1 → 4.5.0-alpha
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/AI.md +31 -0
- package/README.md +6 -2
- package/dist/context.d.ts +1 -2
- package/dist/context.js +3 -2
- package/dist/context.js.map +1 -1
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +11 -1
- package/dist/errors.js.map +1 -1
- package/dist/models/DependencyProcessor.js +0 -5
- package/dist/models/DependencyProcessor.js.map +1 -1
- package/dist/models/EventManager.js +32 -21
- package/dist/models/EventManager.js.map +1 -1
- package/dist/models/LogPrinter.js +20 -22
- package/dist/models/LogPrinter.js.map +1 -1
- package/dist/models/Logger.js +17 -21
- package/dist/models/Logger.js.map +1 -1
- package/dist/models/MiddlewareManager.js +24 -14
- package/dist/models/MiddlewareManager.js.map +1 -1
- package/dist/models/OverrideManager.js +2 -3
- package/dist/models/OverrideManager.js.map +1 -1
- package/dist/models/Queue.js +8 -6
- package/dist/models/Queue.js.map +1 -1
- package/dist/models/ResourceInitializer.js +0 -4
- package/dist/models/ResourceInitializer.js.map +1 -1
- package/dist/models/RunResult.js +45 -51
- package/dist/models/RunResult.js.map +1 -1
- package/dist/models/Semaphore.js +2 -4
- package/dist/models/Semaphore.js.map +1 -1
- package/dist/models/Store.js +20 -16
- package/dist/models/Store.js.map +1 -1
- package/dist/models/StoreRegistry.js +7 -9
- package/dist/models/StoreRegistry.js.map +1 -1
- package/dist/models/StoreValidator.js +0 -1
- package/dist/models/StoreValidator.js.map +1 -1
- package/dist/models/TaskRunner.js +1 -5
- package/dist/models/TaskRunner.js.map +1 -1
- package/dist/platform/browser.d.ts +15 -0
- package/dist/platform/browser.js +98 -0
- package/dist/platform/browser.js.map +1 -0
- package/dist/platform/index.d.ts +8 -0
- package/dist/platform/index.js +47 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/node.d.ts +11 -0
- package/dist/platform/node.js +45 -0
- package/dist/platform/node.js.map +1 -0
- package/dist/platform/types.d.ts +28 -0
- package/dist/platform/types.js +19 -0
- package/dist/platform/types.js.map +1 -0
- package/dist/platform/universal.d.ts +16 -0
- package/dist/platform/universal.js +57 -0
- package/dist/platform/universal.js.map +1 -0
- package/dist/processHooks.js +15 -6
- package/dist/processHooks.js.map +1 -1
- package/dist/run.js +3 -1
- package/dist/run.js.map +1 -1
- package/dist/tools/getCallerFile.js +2 -2
- package/dist/tools/getCallerFile.js.map +1 -1
- package/package.json +17 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserPlatformAdapter = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
class BrowserPlatformAdapter {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.setTimeout = globalThis.setTimeout;
|
|
8
|
+
this.clearTimeout = globalThis.clearTimeout;
|
|
9
|
+
}
|
|
10
|
+
onUncaughtException(handler) {
|
|
11
|
+
const listener = (event) => handler(event.error);
|
|
12
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
13
|
+
window.addEventListener("error", listener);
|
|
14
|
+
return () => window.removeEventListener("error", listener);
|
|
15
|
+
}
|
|
16
|
+
// Fallback to globalThis if window is not available
|
|
17
|
+
globalThis.addEventListener?.("error", listener);
|
|
18
|
+
return () => globalThis.removeEventListener?.("error", listener);
|
|
19
|
+
}
|
|
20
|
+
onUnhandledRejection(handler) {
|
|
21
|
+
const listener = (event) => handler(event.reason);
|
|
22
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
23
|
+
window.addEventListener("unhandledrejection", listener);
|
|
24
|
+
return () => window.removeEventListener("unhandledrejection", listener);
|
|
25
|
+
}
|
|
26
|
+
globalThis.addEventListener?.("unhandledrejection", listener);
|
|
27
|
+
return () => globalThis.removeEventListener?.("unhandledrejection", listener);
|
|
28
|
+
}
|
|
29
|
+
onShutdownSignal(handler) {
|
|
30
|
+
const beforeUnloadListener = () => handler();
|
|
31
|
+
const visibilityListener = () => {
|
|
32
|
+
const doc = typeof document !== "undefined" ? document : undefined;
|
|
33
|
+
if (doc?.visibilityState === "hidden")
|
|
34
|
+
handler();
|
|
35
|
+
};
|
|
36
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
37
|
+
window.addEventListener("beforeunload", beforeUnloadListener);
|
|
38
|
+
window.addEventListener("visibilitychange", visibilityListener);
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener("beforeunload", beforeUnloadListener);
|
|
41
|
+
window.removeEventListener("visibilitychange", visibilityListener);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
globalThis.addEventListener?.("beforeunload", beforeUnloadListener);
|
|
45
|
+
globalThis.addEventListener?.("visibilitychange", visibilityListener);
|
|
46
|
+
return () => {
|
|
47
|
+
globalThis.removeEventListener?.("beforeunload", beforeUnloadListener);
|
|
48
|
+
globalThis.removeEventListener?.("visibilitychange", visibilityListener);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exit(code) {
|
|
52
|
+
throw new errors_1.PlatformUnsupportedFunction(`exit(${code})`);
|
|
53
|
+
}
|
|
54
|
+
getEnv(key) {
|
|
55
|
+
return (globalThis.__ENV__?.[key] ||
|
|
56
|
+
globalThis.process?.env?.[key] ||
|
|
57
|
+
globalThis.env?.[key]);
|
|
58
|
+
}
|
|
59
|
+
createAsyncLocalStorage() {
|
|
60
|
+
// Best-effort polyfill using a context token on globalThis
|
|
61
|
+
const contexts = new WeakMap();
|
|
62
|
+
const contextSymbol = Symbol("asyncContext");
|
|
63
|
+
return {
|
|
64
|
+
getStore() {
|
|
65
|
+
const ctx = globalThis[contextSymbol];
|
|
66
|
+
return ctx ? contexts.get(ctx) : undefined;
|
|
67
|
+
},
|
|
68
|
+
run(store, callback) {
|
|
69
|
+
const ctx = {};
|
|
70
|
+
contexts.set(ctx, store);
|
|
71
|
+
const previous = globalThis[contextSymbol];
|
|
72
|
+
globalThis[contextSymbol] = ctx;
|
|
73
|
+
let restored = false;
|
|
74
|
+
const restore = () => {
|
|
75
|
+
if (!restored) {
|
|
76
|
+
globalThis[contextSymbol] = previous;
|
|
77
|
+
restored = true;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
try {
|
|
81
|
+
const result = callback();
|
|
82
|
+
const maybePromise = result;
|
|
83
|
+
if (maybePromise && typeof maybePromise.then === "function") {
|
|
84
|
+
return maybePromise.finally(restore);
|
|
85
|
+
}
|
|
86
|
+
restore();
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
restore();
|
|
91
|
+
throw e;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.BrowserPlatformAdapter = BrowserPlatformAdapter;
|
|
98
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/platform/browser.ts"],"names":[],"mappings":";;;AAKA,sCAAwD;AAExD,MAAa,sBAAsB;IAAnC;QAmHE,eAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACnC,iBAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IACzC,CAAC;IApHC,mBAAmB,CAAC,OAA6B;QAC/C,MAAM,QAAQ,GAAG,CAAC,KAAiB,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC7D,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAe,CAAC,CAAC;YAClD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAe,CAAC,CAAC;QACpE,CAAC;QACD,oDAAoD;QACnD,UAAkB,CAAC,gBAAgB,EAAE,CAAC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AAE,CAAC;gBACf,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACzB,MAAM,QAAQ,GAAI,UAAkB,CAAC,aAAa,CAAC,CAAC;gBACnD,UAAkB,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC;gBAEzC,IAAI,QAAQ,GAAG,KAAK,CAAC;gBACrB,MAAM,OAAO,GAAG,GAAG,EAAE;oBACnB,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACb,UAAkB,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;wBAC9C,QAAQ,GAAG,IAAI,CAAC;oBAClB,CAAC;gBACH,CAAC,CAAC;gBAEF,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;oBAC1B,MAAM,YAAY,GAAG,MAAa,CAAC;oBACnC,IAAI,YAAY,IAAI,OAAO,YAAY,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;wBAC5D,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;oBACvC,CAAC;oBACD,OAAO,EAAE,CAAC;oBACV,OAAO,MAAM,CAAC;gBAChB,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,EAAE,CAAC;oBACV,MAAM,CAAC,CAAC;gBACV,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CAIF;AArHD,wDAqHC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IPlatformAdapter } from "./types";
|
|
2
|
+
export declare function getPlatform(): IPlatformAdapter;
|
|
3
|
+
export declare function setPlatform(adapter: IPlatformAdapter): void;
|
|
4
|
+
export declare function resetPlatform(): void;
|
|
5
|
+
export type { IPlatformAdapter, IAsyncLocalStorage } from "./types";
|
|
6
|
+
export { NodePlatformAdapter } from "./node";
|
|
7
|
+
export { BrowserPlatformAdapter } from "./browser";
|
|
8
|
+
export { UniversalPlatformAdapter } from "./universal";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniversalPlatformAdapter = exports.BrowserPlatformAdapter = exports.NodePlatformAdapter = void 0;
|
|
4
|
+
exports.getPlatform = getPlatform;
|
|
5
|
+
exports.setPlatform = setPlatform;
|
|
6
|
+
exports.resetPlatform = resetPlatform;
|
|
7
|
+
/**
|
|
8
|
+
* Platform detection and factory
|
|
9
|
+
* Automatically detects the runtime environment and returns the appropriate adapter
|
|
10
|
+
*/
|
|
11
|
+
const node_1 = require("./node");
|
|
12
|
+
const browser_1 = require("./browser");
|
|
13
|
+
const universal_1 = require("./universal");
|
|
14
|
+
let platformInstance = null;
|
|
15
|
+
function getPlatform() {
|
|
16
|
+
if (platformInstance) {
|
|
17
|
+
return platformInstance;
|
|
18
|
+
}
|
|
19
|
+
// Detect Node.js environment
|
|
20
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
21
|
+
platformInstance = new node_1.NodePlatformAdapter();
|
|
22
|
+
}
|
|
23
|
+
else if (typeof window !== "undefined" || typeof document !== "undefined") {
|
|
24
|
+
// Browser main thread (or environments exposing window/document)
|
|
25
|
+
platformInstance = new browser_1.BrowserPlatformAdapter();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Universal environment (browser, web workers, edge runtimes, etc.)
|
|
29
|
+
platformInstance = new universal_1.UniversalPlatformAdapter();
|
|
30
|
+
}
|
|
31
|
+
return platformInstance;
|
|
32
|
+
}
|
|
33
|
+
// Allow manual override for testing or special cases
|
|
34
|
+
function setPlatform(adapter) {
|
|
35
|
+
platformInstance = adapter;
|
|
36
|
+
}
|
|
37
|
+
// Reset to auto-detection
|
|
38
|
+
function resetPlatform() {
|
|
39
|
+
platformInstance = null;
|
|
40
|
+
}
|
|
41
|
+
var node_2 = require("./node");
|
|
42
|
+
Object.defineProperty(exports, "NodePlatformAdapter", { enumerable: true, get: function () { return node_2.NodePlatformAdapter; } });
|
|
43
|
+
var browser_2 = require("./browser");
|
|
44
|
+
Object.defineProperty(exports, "BrowserPlatformAdapter", { enumerable: true, get: function () { return browser_2.BrowserPlatformAdapter; } });
|
|
45
|
+
var universal_2 = require("./universal");
|
|
46
|
+
Object.defineProperty(exports, "UniversalPlatformAdapter", { enumerable: true, get: function () { return universal_2.UniversalPlatformAdapter; } });
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":";;;AAWA,kCAmBC;AAGD,kCAEC;AAGD,sCAEC;AAxCD;;;GAGG;AACH,iCAA6C;AAC7C,uCAAmD;AACnD,2CAAuD;AAGvD,IAAI,gBAAgB,GAA4B,IAAI,CAAC;AAErD,SAAgB,WAAW;IACzB,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,6BAA6B;IAC7B,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC7D,gBAAgB,GAAG,IAAI,0BAAmB,EAAE,CAAC;IAC/C,CAAC;SAAM,IACL,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAChE,CAAC;QACD,iEAAiE;QACjE,gBAAgB,GAAG,IAAI,gCAAsB,EAAE,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,oEAAoE;QACpE,gBAAgB,GAAG,IAAI,oCAAwB,EAAE,CAAC;IACpD,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,qDAAqD;AACrD,SAAgB,WAAW,CAAC,OAAyB;IACnD,gBAAgB,GAAG,OAAO,CAAC;AAC7B,CAAC;AAED,0BAA0B;AAC1B,SAAgB,aAAa;IAC3B,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAID,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA;AAC5B,qCAAmD;AAA1C,iHAAA,sBAAsB,OAAA;AAC/B,yCAAuD;AAA9C,qHAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IPlatformAdapter, IAsyncLocalStorage } from "./types";
|
|
2
|
+
export declare class NodePlatformAdapter implements IPlatformAdapter {
|
|
3
|
+
onUncaughtException(handler: (error: any) => void): () => void;
|
|
4
|
+
onUnhandledRejection(handler: (reason: any) => void): () => void;
|
|
5
|
+
onShutdownSignal(handler: () => void): () => void;
|
|
6
|
+
exit(code: number): void;
|
|
7
|
+
getEnv(key: string): string | undefined;
|
|
8
|
+
createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
|
|
9
|
+
setTimeout: typeof setTimeout;
|
|
10
|
+
clearTimeout: typeof clearTimeout;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodePlatformAdapter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Node.js Platform Adapter
|
|
6
|
+
* Uses Node.js-specific APIs for process management and async context
|
|
7
|
+
*/
|
|
8
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
9
|
+
class NodePlatformAdapter {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.setTimeout = globalThis.setTimeout;
|
|
12
|
+
this.clearTimeout = globalThis.clearTimeout;
|
|
13
|
+
}
|
|
14
|
+
onUncaughtException(handler) {
|
|
15
|
+
process.on("uncaughtException", handler);
|
|
16
|
+
return () => process.off("uncaughtException", handler);
|
|
17
|
+
}
|
|
18
|
+
onUnhandledRejection(handler) {
|
|
19
|
+
process.on("unhandledRejection", handler);
|
|
20
|
+
return () => process.off("unhandledRejection", handler);
|
|
21
|
+
}
|
|
22
|
+
onShutdownSignal(handler) {
|
|
23
|
+
process.on("SIGINT", handler);
|
|
24
|
+
process.on("SIGTERM", handler);
|
|
25
|
+
return () => {
|
|
26
|
+
process.off("SIGINT", handler);
|
|
27
|
+
process.off("SIGTERM", handler);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exit(code) {
|
|
31
|
+
process.exit(code);
|
|
32
|
+
}
|
|
33
|
+
getEnv(key) {
|
|
34
|
+
return process.env[key];
|
|
35
|
+
}
|
|
36
|
+
createAsyncLocalStorage() {
|
|
37
|
+
const als = new node_async_hooks_1.AsyncLocalStorage();
|
|
38
|
+
return {
|
|
39
|
+
getStore: () => als.getStore(),
|
|
40
|
+
run: (store, callback) => als.run(store, callback),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.NodePlatformAdapter = NodePlatformAdapter;
|
|
45
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/platform/node.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uDAAqD;AAGrD,MAAa,mBAAmB;IAAhC;QAoCE,eAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACnC,iBAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IACzC,CAAC;IArCC,mBAAmB,CAAC,OAA6B;QAC/C,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QACzC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,oBAAoB,CAAC,OAA8B;QACjD,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,gBAAgB,CAAC,OAAmB;QAClC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAY;QACf,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,uBAAuB;QACrB,MAAM,GAAG,GAAG,IAAI,oCAAiB,EAAK,CAAC;QACvC,OAAO;YACL,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC9B,GAAG,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC;SACnD,CAAC;IACJ,CAAC;CAIF;AAtCD,kDAsCC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform abstraction interface for universal compatibility
|
|
3
|
+
* Inspired by Remix's approach to Web APIs and runtime-agnostic design
|
|
4
|
+
*/
|
|
5
|
+
export interface IPlatformAdapter {
|
|
6
|
+
onUncaughtException(handler: (error: Error) => void): () => void;
|
|
7
|
+
onUnhandledRejection(handler: (reason: unknown) => void): () => void;
|
|
8
|
+
onShutdownSignal(handler: () => void): () => void;
|
|
9
|
+
exit(code: number): void;
|
|
10
|
+
getEnv(key: string): string | undefined;
|
|
11
|
+
createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
|
|
12
|
+
setTimeout: typeof globalThis.setTimeout;
|
|
13
|
+
clearTimeout: typeof globalThis.clearTimeout;
|
|
14
|
+
}
|
|
15
|
+
export interface IAsyncLocalStorage<T> {
|
|
16
|
+
getStore(): T | undefined;
|
|
17
|
+
run<R>(store: T, callback: () => R): R;
|
|
18
|
+
}
|
|
19
|
+
export interface BrowserErrorEvent extends ErrorEvent {
|
|
20
|
+
error: Error;
|
|
21
|
+
}
|
|
22
|
+
export interface BrowserPromiseRejectionEvent extends PromiseRejectionEvent {
|
|
23
|
+
reason: unknown;
|
|
24
|
+
promise: Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
export declare const isBrowser: () => boolean;
|
|
27
|
+
export declare const isWebWorker: () => boolean;
|
|
28
|
+
export declare const isNode: () => boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Platform abstraction interface for universal compatibility
|
|
4
|
+
* Inspired by Remix's approach to Web APIs and runtime-agnostic design
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isNode = exports.isWebWorker = exports.isBrowser = void 0;
|
|
8
|
+
// Environment detection utilities
|
|
9
|
+
const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
10
|
+
exports.isBrowser = isBrowser;
|
|
11
|
+
const isWebWorker = () => typeof self !== "undefined" &&
|
|
12
|
+
typeof window === "undefined" &&
|
|
13
|
+
typeof globalThis.importScripts === "function";
|
|
14
|
+
exports.isWebWorker = isWebWorker;
|
|
15
|
+
const isNode = () => typeof process !== "undefined" &&
|
|
16
|
+
process.versions != null &&
|
|
17
|
+
process.versions.node != null;
|
|
18
|
+
exports.isNode = isNode;
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/platform/types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmCH,kCAAkC;AAC3B,MAAM,SAAS,GAAG,GAAY,EAAE,CACrC,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,CAAC;AADtD,QAAA,SAAS,aAC6C;AAE5D,MAAM,WAAW,GAAG,GAAY,EAAE,CACvC,OAAO,IAAI,KAAK,WAAW;IAC3B,OAAO,MAAM,KAAK,WAAW;IAC7B,OAAQ,UAAkB,CAAC,aAAa,KAAK,UAAU,CAAC;AAH7C,QAAA,WAAW,eAGkC;AAEnD,MAAM,MAAM,GAAG,GAAY,EAAE,CAClC,OAAO,OAAO,KAAK,WAAW;IAC9B,OAAO,CAAC,QAAQ,IAAI,IAAI;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC;AAHnB,QAAA,MAAM,UAGa"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal Platform Adapter
|
|
3
|
+
* Works in browsers, web workers, edge runtimes, and other non-Node.js environments
|
|
4
|
+
* Uses Web APIs and polyfills where necessary
|
|
5
|
+
*/
|
|
6
|
+
import type { IPlatformAdapter, IAsyncLocalStorage } from "./types";
|
|
7
|
+
export declare class UniversalPlatformAdapter implements IPlatformAdapter {
|
|
8
|
+
onUncaughtException(handler: (error: any) => void): () => void;
|
|
9
|
+
onUnhandledRejection(handler: (reason: any) => void): () => void;
|
|
10
|
+
onShutdownSignal(handler: () => void): () => void;
|
|
11
|
+
exit(code: number): void;
|
|
12
|
+
getEnv(key: string): string | undefined;
|
|
13
|
+
createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
|
|
14
|
+
setTimeout: typeof setTimeout;
|
|
15
|
+
clearTimeout: typeof clearTimeout;
|
|
16
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UniversalPlatformAdapter = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
class UniversalPlatformAdapter {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.setTimeout = globalThis.setTimeout;
|
|
8
|
+
this.clearTimeout = globalThis.clearTimeout;
|
|
9
|
+
}
|
|
10
|
+
onUncaughtException(handler) {
|
|
11
|
+
const listener = (event) => handler(event.error);
|
|
12
|
+
globalThis.addEventListener?.("error", listener);
|
|
13
|
+
return () => globalThis.removeEventListener?.("error", listener);
|
|
14
|
+
}
|
|
15
|
+
onUnhandledRejection(handler) {
|
|
16
|
+
const listener = (event) => handler(event.reason);
|
|
17
|
+
globalThis.addEventListener?.("unhandledrejection", listener);
|
|
18
|
+
return () => globalThis.removeEventListener?.("unhandledrejection", listener);
|
|
19
|
+
}
|
|
20
|
+
onShutdownSignal(handler) {
|
|
21
|
+
// Browser equivalent - beforeunload for graceful cleanup
|
|
22
|
+
const listener = () => handler();
|
|
23
|
+
globalThis.addEventListener?.("beforeunload", listener);
|
|
24
|
+
// Also listen for visibilitychange as a secondary signal
|
|
25
|
+
const visibilityListener = () => {
|
|
26
|
+
const doc = globalThis.document;
|
|
27
|
+
if (doc?.visibilityState === "hidden") {
|
|
28
|
+
handler();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
globalThis.addEventListener?.("visibilitychange", visibilityListener);
|
|
32
|
+
return () => {
|
|
33
|
+
globalThis.removeEventListener?.("beforeunload", listener);
|
|
34
|
+
globalThis.removeEventListener?.("visibilitychange", visibilityListener);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exit(code) {
|
|
38
|
+
// Not supported in universal environments (browser/edge workers)
|
|
39
|
+
throw new errors_1.PlatformUnsupportedFunction(`exit(${code})`);
|
|
40
|
+
}
|
|
41
|
+
getEnv(key) {
|
|
42
|
+
// Try various environment sources in order of preference
|
|
43
|
+
return (
|
|
44
|
+
// Vite/build tool injected env
|
|
45
|
+
globalThis.__ENV__?.[key] ||
|
|
46
|
+
// Node.js-like process.env (if available)
|
|
47
|
+
globalThis.process?.env?.[key] ||
|
|
48
|
+
// Browser build-time env (if injected by bundler)
|
|
49
|
+
globalThis.env?.[key] ||
|
|
50
|
+
undefined);
|
|
51
|
+
}
|
|
52
|
+
createAsyncLocalStorage() {
|
|
53
|
+
throw new errors_1.PlatformUnsupportedFunction("createAsyncLocalStorage");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.UniversalPlatformAdapter = UniversalPlatformAdapter;
|
|
57
|
+
//# sourceMappingURL=universal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal.js","sourceRoot":"","sources":["../../src/platform/universal.ts"],"names":[],"mappings":";;;AAMA,sCAAwD;AAExD,MAAa,wBAAwB;IAArC;QA8DE,eAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACnC,iBAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IACzC,CAAC;IA/DC,mBAAmB,CAAC,OAA6B;QAC/C,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrD,UAAkB,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC1D,OAAO,GAAG,EAAE,CAAE,UAAkB,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IAED,oBAAoB,CAAC,OAA8B;QACjD,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACtD,UAAkB,CAAC,gBAAgB,EAAE,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;QACvE,OAAO,GAAG,EAAE,CACT,UAAkB,CAAC,mBAAmB,EAAE,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAC9E,CAAC;IAED,gBAAgB,CAAC,OAAmB;QAClC,yDAAyD;QACzD,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAChC,UAAkB,CAAC,gBAAgB,EAAE,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAEjE,yDAAyD;QACzD,MAAM,kBAAkB,GAAG,GAAG,EAAE;YAC9B,MAAM,GAAG,GAAI,UAAkB,CAAC,QAAQ,CAAC;YACzC,IAAI,GAAG,EAAE,eAAe,KAAK,QAAQ,EAAE,CAAC;gBACtC,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC;QACD,UAAkB,CAAC,gBAAgB,EAAE,CACpC,kBAAkB,EAClB,kBAAkB,CACnB,CAAC;QAEF,OAAO,GAAG,EAAE;YACT,UAAkB,CAAC,mBAAmB,EAAE,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;YACnE,UAAkB,CAAC,mBAAmB,EAAE,CACvC,kBAAkB,EAClB,kBAAkB,CACnB,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAY;QACf,iEAAiE;QACjE,MAAM,IAAI,oCAA2B,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,yDAAyD;QACzD,OAAO;QACL,+BAA+B;QAC9B,UAAkB,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC;YAClC,0CAA0C;YACzC,UAAkB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC;YACvC,kDAAkD;YACjD,UAAkB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;YAC9B,SAAS,CACV,CAAC;IACJ,CAAC;IAED,uBAAuB;QACrB,MAAM,IAAI,oCAA2B,CAAC,yBAAyB,CAAC,CAAC;IACnE,CAAC;CAIF;AAhED,4DAgEC"}
|
package/dist/processHooks.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerProcessLevelSafetyNets = registerProcessLevelSafetyNets;
|
|
4
4
|
exports.registerShutdownHook = registerShutdownHook;
|
|
5
|
+
const platform_1 = require("./platform");
|
|
6
|
+
const errors_1 = require("./errors");
|
|
7
|
+
const platform = (0, platform_1.getPlatform)();
|
|
5
8
|
// Global registry of active error handlers for process-level safety nets
|
|
6
9
|
const activeErrorHandlers = new Set();
|
|
7
10
|
let processSafetyNetsInstalled = false;
|
|
@@ -25,8 +28,8 @@ function installGlobalProcessSafetyNetsOnce() {
|
|
|
25
28
|
catch (_) { }
|
|
26
29
|
}
|
|
27
30
|
};
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
platform.onUncaughtException(onUncaughtException);
|
|
32
|
+
platform.onUnhandledRejection(onUnhandledRejection);
|
|
30
33
|
}
|
|
31
34
|
function registerProcessLevelSafetyNets(handler) {
|
|
32
35
|
installGlobalProcessSafetyNetsOnce();
|
|
@@ -42,7 +45,7 @@ function installGlobalShutdownHooksOnce() {
|
|
|
42
45
|
if (shutdownHooksInstalled)
|
|
43
46
|
return;
|
|
44
47
|
shutdownHooksInstalled = true;
|
|
45
|
-
const handler = async (
|
|
48
|
+
const handler = async () => {
|
|
46
49
|
try {
|
|
47
50
|
const disposers = Array.from(activeDisposers);
|
|
48
51
|
for (const d of disposers) {
|
|
@@ -54,11 +57,17 @@ function installGlobalShutdownHooksOnce() {
|
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
finally {
|
|
57
|
-
|
|
60
|
+
try {
|
|
61
|
+
platform.exit(0);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
if (!(e instanceof errors_1.PlatformUnsupportedFunction)) {
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
};
|
|
60
|
-
|
|
61
|
-
process.on("SIGTERM", handler);
|
|
70
|
+
platform.onShutdownSignal(handler);
|
|
62
71
|
}
|
|
63
72
|
function registerShutdownHook(disposeOnce) {
|
|
64
73
|
installGlobalShutdownHooksOnce();
|
package/dist/processHooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processHooks.js","sourceRoot":"","sources":["../src/processHooks.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"processHooks.js","sourceR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,MAAM,eAAe,GAAG,IAAI,GAAG,EAAuB,CAAC;AACvD,IAAI,sBAAsB,GAAG,KAAK,CAAC;AAEnC,SAAS,8BAA8B;IACrC,IAAI,sBAAsB;QAAE,OAAO;IACnC,sBAAsB,GAAG,IAAI,CAAC;IAC9B,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;QACzB,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC9C,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;gBAC1B,IAAI,CAAC;oBACH,MAAM,CAAC,EAAE,CAAC;gBACZ,CAAC;gBAAC,MAAM,CAAC,CAAA,CAAC;gBACV,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC;gBACH,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,CAAC,CAAC,YAAY,oCAA2B,CAAC,EAAE,CAAC;oBAChD,MAAM,CAAC,CAAC;gBACV,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,oBAAoB,CAAC,WAAgC;IACnE,8BAA8B,EAAE,CAAC;IACjC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/run.js
CHANGED
|
@@ -12,6 +12,8 @@ const debug_1 = require("./globals/resources/debug");
|
|
|
12
12
|
const processHooks_1 = require("./processHooks");
|
|
13
13
|
const UnhandledError_1 = require("./models/UnhandledError");
|
|
14
14
|
const RunResult_1 = require("./models/RunResult");
|
|
15
|
+
const platform_1 = require("./platform");
|
|
16
|
+
const platform = (0, platform_1.getPlatform)();
|
|
15
17
|
/**
|
|
16
18
|
* This is the central function that kicks off you runner. You can run as many resources as you want in a single process, they will run in complete isolation.
|
|
17
19
|
*
|
|
@@ -22,7 +24,7 @@ const RunResult_1 = require("./models/RunResult");
|
|
|
22
24
|
async function run(resourceOrResourceWithConfig, // For optional config
|
|
23
25
|
options) {
|
|
24
26
|
const { debug = undefined, logs = {}, errorBoundary = true, shutdownHooks = true, dryRun = false, onUnhandledError: onUnhandledErrorOpt, runtimeCycleDetection = true, } = options || {};
|
|
25
|
-
const { printThreshold =
|
|
27
|
+
const { printThreshold = platform.getEnv("NODE_ENV") === "test" ? null : "info", printStrategy = "pretty", bufferLogs = false, } = logs;
|
|
26
28
|
const eventManager = new EventManager_1.EventManager({
|
|
27
29
|
runtimeCycleDetection,
|
|
28
30
|
});
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;AAiCA,kBA2JC;AA5LD,oDAAiD;AAEjD,sEAAmE;AACnE,wDAAqD;AACrD,yDAAsD;AACtD,0CAAuC;AAGvC,4CAAyC;AACzC,qCAAgD;AAChD,qDAA0D;AAC1D,iDAGwB;AACxB,4DAIiC;AACjC,kDAA+C;AAE/C,yCAAyC;AAEzC,MAAM,QAAQ,GAAG,IAAA,sBAAW,GAAE,CAAC;AAE/B;;;;;;GAMG;AACI,KAAK,UAAU,GAAG,CACvB,4BAGgD,EAAE,sBAAsB;AACxE,OAAoB;IAEpB,MAAM,EACJ,KAAK,GAAG,SAAS,EACjB,IAAI,GAAG,EAAE,EACT,aAAa,GAAG,IAAI,EACpB,aAAa,GAAG,IAAI,EACpB,MAAM,GAAG,KAAK,EACd,gBAAgB,EAAE,mBAAmB,EACr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AAC;AAC9B,CAAC"}
|
|
@@ -18,9 +18,9 @@ function getCallerFile() {
|
|
|
18
18
|
// Remove the first frame (getCallerFile itself)
|
|
19
19
|
stack.shift();
|
|
20
20
|
// Remove the second frame (the direct caller of getCallerFile)
|
|
21
|
-
currentfile = stack.shift()?.getFileName();
|
|
21
|
+
currentfile = stack.shift()?.getFileName?.();
|
|
22
22
|
// The third frame (the caller above the immediate one)
|
|
23
|
-
callerfile = stack.shift()?.getFileName();
|
|
23
|
+
callerfile = stack.shift()?.getFileName?.();
|
|
24
24
|
return callerfile; // Return the file name of the caller above
|
|
25
25
|
}
|
|
26
26
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCallerFile.js","sourceRoot":"","sources":["../../src/tools/getCallerFile.ts"],"names":[],"mappings":";;AAAA,sCAgCC;AAhCD,SAAgB,aAAa;IAC3B,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,UAAU,CAAC;QACf,IAAI,WAAW,CAAC;QAEhB,8BAA8B;QAC9B,KAAK,CAAC,iBAAiB,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;QAEhD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAqC,CAAC;QAExD,+BAA+B;QAC/B,0BAA0B;QAC1B,8EAA8E;QAC9E,sBAAsB;QACtB,IAAI;QAEJ,gDAAgD;QAChD,KAAK,CAAC,KAAK,EAAE,CAAC;QAEd,+DAA+D;QAC/D,WAAW,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"getCallerFile.js","sourceRoot":"","sources":["../../src/tools/getCallerFile.ts"],"names":[],"mappings":";;AAAA,sCAgCC;AAhCD,SAAgB,aAAa;IAC3B,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,UAAU,CAAC;QACf,IAAI,WAAW,CAAC;QAEhB,8BAA8B;QAC9B,KAAK,CAAC,iBAAiB,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;QAEhD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAqC,CAAC;QAExD,+BAA+B;QAC/B,0BAA0B;QAC1B,8EAA8E;QAC9E,sBAAsB;QACtB,IAAI;QAEJ,gDAAgD;QAChD,KAAK,CAAC,KAAK,EAAE,CAAC;QAEd,+DAA+D;QAC/D,WAAW,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC;QAE7C,uDAAuD;QACvD,UAAU,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,CAAC;QAE5C,OAAO,UAAoB,CAAC,CAAC,2CAA2C;IAC1E,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,iBAAiB,GAAG,YAAY,CAAC;IACzC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluelibs/runner",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-alpha",
|
|
4
4
|
"description": "BlueLibs Runner",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"node": "./dist/index.js",
|
|
12
|
+
"browser": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./platform": {
|
|
16
|
+
"types": "./dist/platform/index.d.ts",
|
|
17
|
+
"node": "./dist/platform/node.js",
|
|
18
|
+
"browser": "./dist/platform/browser.js",
|
|
19
|
+
"default": "./dist/platform/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
6
22
|
"repository": {
|
|
7
23
|
"type": "git",
|
|
8
24
|
"url": "https://github.com/bluelibs/bluelibs"
|