@fluidgrids/workflows 2026.1027.0 → 2026.1027.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -5
- package/dist/{assemble-DMOuaxRI.d.ts → assemble-CrpUyd_3.d.ts} +20 -2
- package/dist/{assemble-BJo9TECS.d.cts → assemble-DEf3znGD.d.cts} +20 -2
- package/dist/chunk-3M34AUIY.cjs +27 -0
- package/dist/chunk-5AW745OG.js +25 -0
- package/dist/{chunk-RRQ5HOBF.cjs → chunk-6AIAC2FP.cjs} +4 -4
- package/dist/{chunk-GO34UHSY.js → chunk-6BEW4QD6.js} +3 -3
- package/dist/{chunk-SS4LT2IP.js → chunk-6U446SKY.js} +5 -10
- package/dist/{chunk-AU3YW7FZ.cjs → chunk-7YR7DI7B.cjs} +46 -51
- package/dist/{chunk-27HASETB.cjs → chunk-CSYBNN3V.cjs} +3 -1
- package/dist/{chunk-LRM6JXJA.cjs → chunk-E3APHA6O.cjs} +19 -1
- package/dist/{chunk-BWSLWF2E.js → chunk-EEAIM35V.js} +38 -12
- package/dist/{chunk-X4HKU3MX.js → chunk-IHKXLG6I.js} +3 -1
- package/dist/chunk-MBBKGD7K.js +440 -0
- package/dist/{chunk-LSKSBVL4.cjs → chunk-OSPTJCDI.cjs} +6 -6
- package/dist/{chunk-KUTMY2IO.cjs → chunk-TQF7MYEN.cjs} +101 -75
- package/dist/{chunk-BYJ7QTLY.cjs → chunk-TWOYB4Y7.cjs} +13 -13
- package/dist/{chunk-PL73GJR4.js → chunk-UB2BHU2M.js} +1 -1
- package/dist/{chunk-REV7ZOA4.js → chunk-UJNHTS6D.js} +13 -2
- package/dist/{chunk-IZQNUNSU.cjs → chunk-UWQWD7BP.cjs} +17 -17
- package/dist/{chunk-4DPEGDPW.js → chunk-W32BSO3M.js} +4 -4
- package/dist/{chunk-LMX35GNQ.js → chunk-XBIID5DY.js} +4 -4
- package/dist/chunk-Y7NWR3WH.cjs +450 -0
- package/dist/codegen/index.cjs +7 -7
- package/dist/codegen/index.js +5 -5
- package/dist/index.cjs +30 -30
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/ir/index.cjs +118 -116
- package/dist/ir/index.d.cts +18 -8
- package/dist/ir/index.d.ts +18 -8
- package/dist/ir/index.js +21 -19
- package/dist/{lower-Dw5grNrI.d.ts → lower-CXggJTIo.d.ts} +20 -2
- package/dist/{lower-DcOY8ux0.d.cts → lower-DAzvsJCo.d.cts} +20 -2
- package/dist/node-evaluator-CH3XCJND.cjs +17 -0
- package/dist/node-evaluator-TULXA3WE.js +8 -0
- package/dist/quickjs/index.cjs +32 -78
- package/dist/quickjs/index.d.cts +4 -4
- package/dist/quickjs/index.d.ts +4 -4
- package/dist/quickjs/index.js +32 -78
- package/dist/roundtrip/index.cjs +201 -128
- package/dist/roundtrip/index.d.cts +7 -4
- package/dist/roundtrip/index.d.ts +7 -4
- package/dist/roundtrip/index.js +87 -18
- package/package.json +44 -18
- package/dist/chunk-265J2FCH.cjs +0 -33
- package/dist/chunk-LUXCXFOE.cjs +0 -269
- package/dist/chunk-S34NJE3A.js +0 -262
- package/dist/chunk-SRQRLWOS.js +0 -31
- package/dist/node-evaluator-2GTUZVPK.cjs +0 -17
- package/dist/node-evaluator-RMYEWCXZ.js +0 -8
package/dist/ir/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { diffDefinitions } from '../chunk-
|
|
2
|
-
import { findManifest, operationsOf, fieldsSchema } from '../chunk-
|
|
3
|
-
export { fieldSchema, fieldsSchema, findManifest, isTriggerOperation, operationsOf } from '../chunk-
|
|
4
|
-
import { usesMergedParameters, CODE_WORKFLOW_NODE_TYPE, INTERNAL_TRIGGER_TYPES, V2_NODE_TYPES, normalizeDefinition } from '../chunk-
|
|
5
|
-
export { CODE_WORKFLOW_NODE_TYPE, INTERNAL_TRIGGER_TYPES, WAIT_FOR_SIGNAL_NODE_TYPE, buildIdOf, hashedProjection, irHash, normalizeDefinition, sourceHash, usesMergedParameters } from '../chunk-
|
|
1
|
+
export { diffDefinitions } from '../chunk-W32BSO3M.js';
|
|
2
|
+
import { findManifest, operationsOf, fieldsSchema } from '../chunk-6BEW4QD6.js';
|
|
3
|
+
export { fieldSchema, fieldsSchema, findManifest, isTriggerOperation, operationsOf } from '../chunk-6BEW4QD6.js';
|
|
4
|
+
import { usesMergedParameters, CODE_WORKFLOW_NODE_TYPE, INTERNAL_TRIGGER_TYPES, V2_NODE_TYPES, normalizeDefinition } from '../chunk-6U446SKY.js';
|
|
5
|
+
export { CODE_WORKFLOW_NODE_TYPE, INTERNAL_TRIGGER_TYPES, WAIT_FOR_SIGNAL_NODE_TYPE, buildIdOf, hashedProjection, irHash, normalizeDefinition, sourceHash, usesMergedParameters } from '../chunk-6U446SKY.js';
|
|
6
6
|
export { LAYOUT_COLUMN_WIDTH, LAYOUT_ROW_HEIGHT, autoLayout } from '../chunk-5LUIDMF4.js';
|
|
7
|
-
export { CanonicalJsonError, canonicalJson, sha256Hex, sha256Tagged, stableStringify } from '../chunk-
|
|
8
|
-
import { isRecord, hasLegacyTemplate } from '../chunk-
|
|
9
|
-
export { formatRefExpression, formatRefTemplate, parseRefExpression, parseTemplate } from '../chunk-
|
|
7
|
+
export { CanonicalJsonError, canonicalJson, sha256Hex, sha256Tagged, stableStringify } from '../chunk-IHKXLG6I.js';
|
|
8
|
+
import { isRecord, setOwn, deepEqual, hasLegacyTemplate } from '../chunk-UJNHTS6D.js';
|
|
9
|
+
export { formatRefExpression, formatRefTemplate, parseRefExpression, parseTemplate } from '../chunk-UJNHTS6D.js';
|
|
10
10
|
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
11
11
|
import { CronExpressionParser } from 'cron-parser';
|
|
12
12
|
|
|
@@ -363,6 +363,8 @@ function executorNodeView(node) {
|
|
|
363
363
|
const nodeData = isRecord(data?.["nodeData"]) ? data["nodeData"] : void 0;
|
|
364
364
|
const argsContext = isRecord(args?.["context"]) ? args["context"] : void 0;
|
|
365
365
|
const contextNode = isRecord(argsContext?.["node"]) ? argsContext["node"] : void 0;
|
|
366
|
+
const subNodeState = merged ? void 0 : args?.["state"] || dataArgs?.["state"] || {};
|
|
367
|
+
const toolOperation = merged ? void 0 : (isRecord(subNodeState) ? subNodeState["operation"] : void 0) || data?.["operation_name"];
|
|
366
368
|
return {
|
|
367
369
|
id: record["id"],
|
|
368
370
|
type: record["type"],
|
|
@@ -377,7 +379,11 @@ function executorNodeView(node) {
|
|
|
377
379
|
runOn: dataSettings?.["runOn"],
|
|
378
380
|
disabled: record["disabled"] === true || data?.["disabled"] === true,
|
|
379
381
|
nodeDataNodeType: nodeData?.["nodeType"],
|
|
380
|
-
argsContextNodeType: contextNode?.["type"]
|
|
382
|
+
argsContextNodeType: contextNode?.["type"],
|
|
383
|
+
dataOperationName: data?.["operation_name"],
|
|
384
|
+
nodeStateVersion: data?.["version"] || "1.0.0",
|
|
385
|
+
subNodeState,
|
|
386
|
+
toolOperation
|
|
381
387
|
};
|
|
382
388
|
}
|
|
383
389
|
function executorView(definition) {
|
|
@@ -638,17 +644,13 @@ function legacyMirrors(node) {
|
|
|
638
644
|
const data = isRecord(node["data"]) ? node["data"] : void 0;
|
|
639
645
|
const dataArgs = isRecord(data?.["args"]) ? data["args"] : void 0;
|
|
640
646
|
if (data) {
|
|
641
|
-
for (const key of [
|
|
642
|
-
"label",
|
|
643
|
-
"operation_name",
|
|
644
|
-
"errorConfig",
|
|
645
|
-
"disabled",
|
|
646
|
-
"state",
|
|
647
|
-
"nodeVersion"
|
|
648
|
-
]) {
|
|
647
|
+
for (const key of ["label", "errorConfig", "disabled", "state", "nodeVersion"]) {
|
|
649
648
|
if (data[key] !== void 0) found.push(`data.${key}`);
|
|
650
649
|
}
|
|
651
|
-
if (
|
|
650
|
+
if (data["operation_name"] !== void 0 && !deepEqual(data["operation_name"], node["operation_name"]))
|
|
651
|
+
found.push("data.operation_name");
|
|
652
|
+
if (!merged && data["version"] !== void 0 && !deepEqual(data["version"], node["version"]))
|
|
653
|
+
found.push("data.version");
|
|
652
654
|
for (const key of ["state", "connections", "credentials", "context"]) {
|
|
653
655
|
if (dataArgs?.[key] !== void 0) found.push(`data.args.${key}`);
|
|
654
656
|
}
|
|
@@ -1076,7 +1078,7 @@ function workflowInputsSchema(workflowInputs) {
|
|
|
1076
1078
|
const name = (rawName ?? "").trim();
|
|
1077
1079
|
if (!name) continue;
|
|
1078
1080
|
const type = (rawType ?? "").trim().toLowerCase();
|
|
1079
|
-
properties
|
|
1081
|
+
setOwn(properties, name, FIELD_TYPES.has(type) ? { type } : {});
|
|
1080
1082
|
required.push(name);
|
|
1081
1083
|
}
|
|
1082
1084
|
return {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
2
|
import { S as SourceFile } from './hash-CZkTXPCX.js';
|
|
3
3
|
import { W as WorkflowDefinition } from './types-Dr2Fn1Ax.js';
|
|
4
|
-
import { h as ConnectionResolver } from './assemble-
|
|
4
|
+
import { h as ConnectionResolver } from './assemble-CrpUyd_3.js';
|
|
5
|
+
|
|
6
|
+
/** Why an evaluation produced no collection. */
|
|
7
|
+
type IsolateFailure = 'error' | 'timeout' | 'determinism' | 'no-collection' | 'out-of-memory' | 'crashed';
|
|
5
8
|
|
|
6
9
|
/** The esbuild API surface lower() uses (`esbuild` or `esbuild-wasm`, version 0.28.2). */
|
|
7
10
|
type EsbuildApi = Pick<typeof esbuild, 'build' | 'transform'>;
|
|
@@ -13,7 +16,18 @@ interface Evaluator {
|
|
|
13
16
|
}
|
|
14
17
|
declare const EVALUATION_GLOBAL = "__fluidgridsBundle";
|
|
15
18
|
declare const ESBUILD_VERSION = "0.28.2";
|
|
19
|
+
/** Why lowering failed, when the cause is one a caller may want to tell apart. */
|
|
20
|
+
type LowerFailureReason = IsolateFailure | 'too-large';
|
|
16
21
|
declare class LowerError extends Error {
|
|
22
|
+
readonly reason?: LowerFailureReason | undefined;
|
|
23
|
+
constructor(message: string, reason?: LowerFailureReason | undefined);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The workflow code read the clock or a random source while it was defined
|
|
27
|
+
* (`Date.now()`, `new Date()`, `Math.random()`, …), which would make two builds
|
|
28
|
+
* of the same source differ.
|
|
29
|
+
*/
|
|
30
|
+
declare class DeterminismViolationError extends LowerError {
|
|
17
31
|
constructor(message: string);
|
|
18
32
|
}
|
|
19
33
|
interface LowerOptions {
|
|
@@ -24,6 +38,10 @@ interface LowerOptions {
|
|
|
24
38
|
connections?: ConnectionResolver;
|
|
25
39
|
/** Largest JSON the evaluation may return. Default 16 MiB. */
|
|
26
40
|
maxOutputBytes?: number;
|
|
41
|
+
/** Largest total size of the source files, in UTF-8 bytes, checked before esbuild. Default 1 MiB. */
|
|
42
|
+
maxSourceBytes?: number;
|
|
43
|
+
/** Largest bundle, in UTF-8 bytes, checked before evaluation. Default 1.5 MiB. */
|
|
44
|
+
maxBundleBytes?: number;
|
|
27
45
|
}
|
|
28
46
|
interface LoweredWorkflow {
|
|
29
47
|
key: string;
|
|
@@ -46,4 +64,4 @@ declare function bundleProject(files: ReadonlyMap<string, string>, entries: read
|
|
|
46
64
|
/** Lower tier-1 sources to IR v2. */
|
|
47
65
|
declare function lower(files: readonly SourceFile[] | Readonly<Record<string, string>>, options?: LowerOptions): Promise<LowerResult>;
|
|
48
66
|
|
|
49
|
-
export { type Evaluator as E, LowerError as L, type EsbuildApi as a, ESBUILD_VERSION as b, EVALUATION_GLOBAL as c, type
|
|
67
|
+
export { DeterminismViolationError as D, type Evaluator as E, LowerError as L, type EsbuildApi as a, ESBUILD_VERSION as b, EVALUATION_GLOBAL as c, type LowerFailureReason as d, type LowerOptions as e, type LowerResult as f, type LoweredWorkflow as g, bundleProject as h, defaultEntries as i, lower as l };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
2
|
import { S as SourceFile } from './hash-CZkTXPCX.cjs';
|
|
3
3
|
import { W as WorkflowDefinition } from './types-Dr2Fn1Ax.cjs';
|
|
4
|
-
import { h as ConnectionResolver } from './assemble-
|
|
4
|
+
import { h as ConnectionResolver } from './assemble-DEf3znGD.cjs';
|
|
5
|
+
|
|
6
|
+
/** Why an evaluation produced no collection. */
|
|
7
|
+
type IsolateFailure = 'error' | 'timeout' | 'determinism' | 'no-collection' | 'out-of-memory' | 'crashed';
|
|
5
8
|
|
|
6
9
|
/** The esbuild API surface lower() uses (`esbuild` or `esbuild-wasm`, version 0.28.2). */
|
|
7
10
|
type EsbuildApi = Pick<typeof esbuild, 'build' | 'transform'>;
|
|
@@ -13,7 +16,18 @@ interface Evaluator {
|
|
|
13
16
|
}
|
|
14
17
|
declare const EVALUATION_GLOBAL = "__fluidgridsBundle";
|
|
15
18
|
declare const ESBUILD_VERSION = "0.28.2";
|
|
19
|
+
/** Why lowering failed, when the cause is one a caller may want to tell apart. */
|
|
20
|
+
type LowerFailureReason = IsolateFailure | 'too-large';
|
|
16
21
|
declare class LowerError extends Error {
|
|
22
|
+
readonly reason?: LowerFailureReason | undefined;
|
|
23
|
+
constructor(message: string, reason?: LowerFailureReason | undefined);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The workflow code read the clock or a random source while it was defined
|
|
27
|
+
* (`Date.now()`, `new Date()`, `Math.random()`, …), which would make two builds
|
|
28
|
+
* of the same source differ.
|
|
29
|
+
*/
|
|
30
|
+
declare class DeterminismViolationError extends LowerError {
|
|
17
31
|
constructor(message: string);
|
|
18
32
|
}
|
|
19
33
|
interface LowerOptions {
|
|
@@ -24,6 +38,10 @@ interface LowerOptions {
|
|
|
24
38
|
connections?: ConnectionResolver;
|
|
25
39
|
/** Largest JSON the evaluation may return. Default 16 MiB. */
|
|
26
40
|
maxOutputBytes?: number;
|
|
41
|
+
/** Largest total size of the source files, in UTF-8 bytes, checked before esbuild. Default 1 MiB. */
|
|
42
|
+
maxSourceBytes?: number;
|
|
43
|
+
/** Largest bundle, in UTF-8 bytes, checked before evaluation. Default 1.5 MiB. */
|
|
44
|
+
maxBundleBytes?: number;
|
|
27
45
|
}
|
|
28
46
|
interface LoweredWorkflow {
|
|
29
47
|
key: string;
|
|
@@ -46,4 +64,4 @@ declare function bundleProject(files: ReadonlyMap<string, string>, entries: read
|
|
|
46
64
|
/** Lower tier-1 sources to IR v2. */
|
|
47
65
|
declare function lower(files: readonly SourceFile[] | Readonly<Record<string, string>>, options?: LowerOptions): Promise<LowerResult>;
|
|
48
66
|
|
|
49
|
-
export { type Evaluator as E, LowerError as L, type EsbuildApi as a, ESBUILD_VERSION as b, EVALUATION_GLOBAL as c, type
|
|
67
|
+
export { DeterminismViolationError as D, type Evaluator as E, LowerError as L, type EsbuildApi as a, ESBUILD_VERSION as b, EVALUATION_GLOBAL as c, type LowerFailureReason as d, type LowerOptions as e, type LowerResult as f, type LoweredWorkflow as g, bundleProject as h, defaultEntries as i, lower as l };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk3M34AUIY_cjs = require('./chunk-3M34AUIY.cjs');
|
|
4
|
+
require('./chunk-Y7NWR3WH.cjs');
|
|
5
|
+
require('./chunk-TQF7MYEN.cjs');
|
|
6
|
+
require('./chunk-7YR7DI7B.cjs');
|
|
7
|
+
require('./chunk-G4UEPUGO.cjs');
|
|
8
|
+
require('./chunk-6AIAC2FP.cjs');
|
|
9
|
+
require('./chunk-CSYBNN3V.cjs');
|
|
10
|
+
require('./chunk-E3APHA6O.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Object.defineProperty(exports, "createNodeVmEvaluator", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunk3M34AUIY_cjs.createNodeVmEvaluator; }
|
|
17
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createNodeVmEvaluator } from './chunk-5AW745OG.js';
|
|
2
|
+
import './chunk-MBBKGD7K.js';
|
|
3
|
+
import './chunk-EEAIM35V.js';
|
|
4
|
+
import './chunk-6U446SKY.js';
|
|
5
|
+
import './chunk-5LUIDMF4.js';
|
|
6
|
+
import './chunk-UB2BHU2M.js';
|
|
7
|
+
import './chunk-IHKXLG6I.js';
|
|
8
|
+
import './chunk-UJNHTS6D.js';
|
package/dist/quickjs/index.cjs
CHANGED
|
@@ -1,90 +1,44 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunkY7NWR3WH_cjs = require('../chunk-Y7NWR3WH.cjs');
|
|
4
|
+
require('../chunk-TQF7MYEN.cjs');
|
|
5
|
+
require('../chunk-7YR7DI7B.cjs');
|
|
6
6
|
require('../chunk-G4UEPUGO.cjs');
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
10
|
-
var
|
|
7
|
+
require('../chunk-6AIAC2FP.cjs');
|
|
8
|
+
require('../chunk-CSYBNN3V.cjs');
|
|
9
|
+
var chunkE3APHA6O_cjs = require('../chunk-E3APHA6O.cjs');
|
|
10
|
+
var module$1 = require('module');
|
|
11
|
+
var url = require('url');
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
var ENGINE_HEADROOM_BYTES = 32 * 1024 * 1024;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
|
|
13
|
+
// src/generated/quickjs-worker-source.ts
|
|
14
|
+
var QUICKJS_WORKER_SOURCE = '"use strict";\n\nvar import_node_worker_threads = require("node:worker_threads");\n\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\n\nvar DETERMINISM_VIOLATION = "DeterminismViolation";\nvar DETERMINISM_PRELUDE = `(() => {\n const NAME = ${JSON.stringify(DETERMINISM_VIOLATION)};\n const fail = (what) => {\n const error = new Error(\n what + " is not allowed in workflow code: lowering must give the same IR on every build. Read times and random values at run time instead (for example wf.now)."\n );\n error.name = NAME;\n throw error;\n };\n const lock = (target, key, value) =>\n Object.defineProperty(target, key, { value, writable: false, enumerable: false, configurable: false });\n const RealDate = Date;\n const LockedDate = function Date(...args) {\n if (new.target === undefined) return fail("Date()");\n if (args.length === 0) return fail("new Date()");\n return Reflect.construct(RealDate, args, new.target);\n };\n lock(LockedDate, "prototype", RealDate.prototype);\n lock(RealDate.prototype, "constructor", LockedDate);\n lock(LockedDate, "now", function now() { return fail("Date.now()"); });\n lock(LockedDate, "parse", RealDate.parse);\n lock(LockedDate, "UTC", RealDate.UTC);\n lock(globalThis, "Date", LockedDate);\n lock(Math, "random", function random() { return fail("Math.random()"); });\n const crypto = globalThis.crypto;\n if (crypto !== null && typeof crypto === "object") {\n for (const name of ["getRandomValues", "randomUUID"]) {\n if (typeof crypto[name] === "function") lock(crypto, name, function () { return fail("crypto." + name + "()"); });\n }\n }\n const DateTimeFormat = typeof Intl === "object" && Intl !== null ? Intl.DateTimeFormat : undefined;\n if (typeof DateTimeFormat === "function") {\n const proto = DateTimeFormat.prototype;\n const format = Object.getOwnPropertyDescriptor(proto, "format");\n if (format && typeof format.get === "function") {\n const get = format.get;\n Object.defineProperty(proto, "format", {\n get() {\n const bound = get.call(this);\n return (date) => (date === undefined ? fail("Intl.DateTimeFormat format()") : bound(date));\n },\n enumerable: false,\n configurable: false,\n });\n }\n const formatToParts = proto.formatToParts;\n if (typeof formatToParts === "function") {\n lock(proto, "formatToParts", function (date) {\n return date === undefined ? fail("Intl.DateTimeFormat formatToParts()") : formatToParts.call(this, date);\n });\n }\n }\n})();\n`;\nfunction failure(kind, message) {\n return { ok: false, failure: kind, message };\n}\nfunction failureForErrorName(name) {\n return name === DETERMINISM_VIOLATION ? "determinism" : "error";\n}\n\nfunction isQuickJSApi(value) {\n return isRecord(value) && typeof value["newQuickJSWASMModuleFromVariant"] === "function" && typeof value["newVariant"] === "function" && typeof value["shouldInterruptAfterDeadline"] === "function" && value["RELEASE_SYNC"] !== void 0;\n}\nvar WASM_PAGE_BYTES = 64 * 1024;\nvar ENGINE_HEADROOM_BYTES = 32 * 1024 * 1024;\nvar INITIAL_ENGINE_BYTES = 16 * 1024 * 1024;\nfunction describe(ctx, handle) {\n const dumped = ctx.dump(handle);\n if (isRecord(dumped)) {\n const name = typeof dumped["name"] === "string" ? dumped["name"] : "Error";\n const message = dumped["message"];\n return {\n name,\n message: typeof message === "string" ? message : message === void 0 ? JSON.stringify(dumped) : String(message)\n };\n }\n return { name: "Error", message: String(dumped) };\n}\nasync function evaluateInQuickJS(api, code, limits) {\n const maximum = Math.ceil((limits.memoryLimitBytes + ENGINE_HEADROOM_BYTES) / WASM_PAGE_BYTES);\n const initial = Math.min(maximum, INITIAL_ENGINE_BYTES / WASM_PAGE_BYTES);\n const engine = await api.newQuickJSWASMModuleFromVariant(\n api.newVariant(api.RELEASE_SYNC, { wasmMemory: new WebAssembly.Memory({ initial, maximum }) })\n );\n const runtime = engine.newRuntime();\n const deadline = Date.now() + limits.timeoutMs;\n runtime.setMemoryLimit(limits.memoryLimitBytes);\n runtime.setMaxStackSize(limits.maxStackSizeBytes);\n runtime.setInterruptHandler(api.shouldInterruptAfterDeadline(deadline));\n const ctx = runtime.newContext();\n const handles = [];\n const timedOut = () => failure("timeout", `Evaluating the workflow code timed out after ${limits.timeoutMs} ms`);\n const thrown = (handle) => {\n const { name, message } = describe(ctx, handle);\n handle.dispose();\n if (Date.now() > deadline && /interrupted/.test(message)) return timedOut();\n return failure(failureForErrorName(name), message);\n };\n try {\n const prelude = ctx.evalCode(DETERMINISM_PRELUDE, "determinism-prelude.js", { type: "global" });\n if (prelude.error) return thrown(prelude.error);\n prelude.value.dispose();\n const result = ctx.evalCode(code, "workflow-bundle.mjs", { type: "module" });\n if (result.error) return thrown(result.error);\n let namespace = result.value;\n handles.push(namespace);\n const state = ctx.getPromiseState(namespace);\n if (!(state.type === "fulfilled" && state.notAPromise === true)) {\n if (state.type === "fulfilled") state.value.dispose();\n else if (state.type === "rejected") state.error.dispose();\n while (runtime.hasPendingJob()) {\n if (Date.now() > deadline) return timedOut();\n const jobs = runtime.executePendingJobs();\n if (jobs.error) return thrown(jobs.error);\n }\n const settled = ctx.getPromiseState(namespace);\n if (settled.type === "rejected") return thrown(settled.error);\n if (settled.type === "pending")\n return failure("error", "The workflow module never finished evaluating");\n namespace = settled.value;\n handles.push(namespace);\n }\n const exported = ctx.getProp(namespace, "__fluidgrids");\n handles.push(exported);\n if (ctx.typeof(exported) !== "string")\n return failure("no-collection", "The bundle did not export a workflow collection");\n return { ok: true, value: ctx.getString(exported) };\n } catch (error) {\n return failure("error", error instanceof Error ? error.message : String(error));\n } finally {\n for (const handle of handles.reverse()) if (handle.alive) handle.dispose();\n ctx.dispose();\n runtime.dispose();\n }\n}\n\nprocess.on("unhandledRejection", () => void 0);\nasync function main(input) {\n if (!isRecord(input) || typeof input["code"] !== "string" || typeof input["moduleUrl"] !== "string" || !isRecord(input["limits"]))\n return failure("crashed", "The evaluation worker received no bundle");\n const { timeoutMs, memoryLimitBytes, maxStackSizeBytes } = input["limits"];\n if (typeof timeoutMs !== "number" || typeof memoryLimitBytes !== "number" || typeof maxStackSizeBytes !== "number")\n return failure("crashed", "The evaluation worker received no limits");\n const loaded = await import(input["moduleUrl"]);\n const api = isQuickJSApi(loaded) ? loaded : isRecord(loaded) && isQuickJSApi(loaded["default"]) ? loaded["default"] : void 0;\n if (!api) return failure("crashed", "quickjs-emscripten could not be loaded");\n return evaluateInQuickJS(api, input["code"], {\n timeoutMs,\n memoryLimitBytes,\n maxStackSizeBytes\n });\n}\nmain(import_node_worker_threads.workerData).then(\n (outcome) => import_node_worker_threads.parentPort?.postMessage(outcome),\n (error) => import_node_worker_threads.parentPort?.postMessage(\n failure("crashed", error instanceof Error ? error.message : String(error))\n )\n);\n';
|
|
15
|
+
|
|
16
|
+
// src/quickjs/index.ts
|
|
17
|
+
function quickjsModuleUrl() {
|
|
18
|
+
try {
|
|
19
|
+
return url.pathToFileURL(module$1.createRequire(chunkE3APHA6O_cjs.importMetaUrl).resolve("quickjs-emscripten")).href;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new chunkY7NWR3WH_cjs.LowerError(
|
|
22
|
+
`quickjs-emscripten cannot be resolved: ${error instanceof Error ? error.message : String(error)}`,
|
|
23
|
+
"crashed"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
27
|
function createQuickJSEvaluator(options = {}) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
const limits = {
|
|
29
|
+
timeoutMs: options.timeoutMs ?? 5e3,
|
|
30
|
+
memoryLimitBytes: options.memoryLimitBytes ?? 64 * 1024 * 1024,
|
|
31
|
+
maxStackSizeBytes: options.maxStackSizeBytes ?? 1024 * 1024
|
|
32
|
+
};
|
|
25
33
|
return {
|
|
26
34
|
format: "esm",
|
|
27
35
|
async evaluate(code) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const deadline = Date.now() + timeoutMs;
|
|
35
|
-
runtime.setMemoryLimit(memoryLimitBytes);
|
|
36
|
-
runtime.setMaxStackSize(maxStackSizeBytes);
|
|
37
|
-
runtime.setInterruptHandler(quickjsEmscripten.shouldInterruptAfterDeadline(deadline));
|
|
38
|
-
const ctx = runtime.newContext();
|
|
39
|
-
const handles = [];
|
|
40
|
-
try {
|
|
41
|
-
const result = ctx.evalCode(code, "workflow-bundle.mjs", { type: "module" });
|
|
42
|
-
if (result.error) {
|
|
43
|
-
const message = errorMessage(ctx, result.error);
|
|
44
|
-
result.error.dispose();
|
|
45
|
-
throw new chunkLUXCXFOE_cjs.LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
46
|
-
}
|
|
47
|
-
let namespace = result.value;
|
|
48
|
-
handles.push(namespace);
|
|
49
|
-
const state = ctx.getPromiseState(namespace);
|
|
50
|
-
if (!(state.type === "fulfilled" && state.notAPromise === true)) {
|
|
51
|
-
if (state.type === "fulfilled") state.value.dispose();
|
|
52
|
-
else if (state.type === "rejected") state.error.dispose();
|
|
53
|
-
while (runtime.hasPendingJob()) {
|
|
54
|
-
if (Date.now() > deadline)
|
|
55
|
-
throw new chunkLUXCXFOE_cjs.LowerError("Evaluating the workflow code timed out");
|
|
56
|
-
const jobs = runtime.executePendingJobs();
|
|
57
|
-
if (jobs.error) {
|
|
58
|
-
const message = errorMessage(ctx, jobs.error);
|
|
59
|
-
jobs.error.dispose();
|
|
60
|
-
throw new chunkLUXCXFOE_cjs.LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const settled = ctx.getPromiseState(namespace);
|
|
64
|
-
if (settled.type === "rejected") {
|
|
65
|
-
const message = errorMessage(ctx, settled.error);
|
|
66
|
-
settled.error.dispose();
|
|
67
|
-
throw new chunkLUXCXFOE_cjs.LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
68
|
-
}
|
|
69
|
-
if (settled.type === "pending")
|
|
70
|
-
throw new chunkLUXCXFOE_cjs.LowerError("The workflow module never finished evaluating");
|
|
71
|
-
namespace = settled.value;
|
|
72
|
-
handles.push(namespace);
|
|
73
|
-
}
|
|
74
|
-
const exported = ctx.getProp(namespace, "__fluidgrids");
|
|
75
|
-
handles.push(exported);
|
|
76
|
-
if (ctx.typeof(exported) !== "string")
|
|
77
|
-
throw new chunkLUXCXFOE_cjs.LowerError("The bundle did not export a workflow collection");
|
|
78
|
-
return ctx.getString(exported);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
if (error instanceof chunkLUXCXFOE_cjs.LowerError) throw error;
|
|
81
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
82
|
-
throw new chunkLUXCXFOE_cjs.LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
83
|
-
} finally {
|
|
84
|
-
for (const handle of handles.reverse()) if (handle.alive) handle.dispose();
|
|
85
|
-
ctx.dispose();
|
|
86
|
-
runtime.dispose();
|
|
87
|
-
}
|
|
36
|
+
const outcome = await chunkY7NWR3WH_cjs.runIsolateWorker({
|
|
37
|
+
source: QUICKJS_WORKER_SOURCE,
|
|
38
|
+
workerData: { code, limits, moduleUrl: quickjsModuleUrl() },
|
|
39
|
+
timeoutMs: limits.timeoutMs
|
|
40
|
+
});
|
|
41
|
+
return chunkY7NWR3WH_cjs.outcomeToCollection(outcome);
|
|
88
42
|
}
|
|
89
43
|
};
|
|
90
44
|
}
|
package/dist/quickjs/index.d.cts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { E as Evaluator } from '../lower-
|
|
1
|
+
import { E as Evaluator } from '../lower-DAzvsJCo.cjs';
|
|
2
2
|
import 'esbuild';
|
|
3
3
|
import '../hash-CZkTXPCX.cjs';
|
|
4
4
|
import '../types-Dr2Fn1Ax.cjs';
|
|
5
|
-
import '../assemble-
|
|
5
|
+
import '../assemble-DEf3znGD.cjs';
|
|
6
6
|
|
|
7
7
|
interface QuickJSEvaluatorOptions {
|
|
8
|
-
/** Wall-clock budget. Default 5000 ms. */
|
|
8
|
+
/** Wall-clock budget, including parsing and compiling the bundle. Default 5000 ms. */
|
|
9
9
|
timeoutMs?: number;
|
|
10
10
|
/** Runtime heap cap. Default 64 MiB. */
|
|
11
11
|
memoryLimitBytes?: number;
|
|
12
12
|
/** Native stack cap. Default 1 MiB. */
|
|
13
13
|
maxStackSizeBytes?: number;
|
|
14
14
|
}
|
|
15
|
-
/** An {@link Evaluator} backed by a bounded QuickJS engine. */
|
|
15
|
+
/** An {@link Evaluator} backed by a bounded QuickJS engine in a worker thread. */
|
|
16
16
|
declare function createQuickJSEvaluator(options?: QuickJSEvaluatorOptions): Evaluator;
|
|
17
17
|
|
|
18
18
|
export { type QuickJSEvaluatorOptions, createQuickJSEvaluator };
|
package/dist/quickjs/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { E as Evaluator } from '../lower-
|
|
1
|
+
import { E as Evaluator } from '../lower-CXggJTIo.js';
|
|
2
2
|
import 'esbuild';
|
|
3
3
|
import '../hash-CZkTXPCX.js';
|
|
4
4
|
import '../types-Dr2Fn1Ax.js';
|
|
5
|
-
import '../assemble-
|
|
5
|
+
import '../assemble-CrpUyd_3.js';
|
|
6
6
|
|
|
7
7
|
interface QuickJSEvaluatorOptions {
|
|
8
|
-
/** Wall-clock budget. Default 5000 ms. */
|
|
8
|
+
/** Wall-clock budget, including parsing and compiling the bundle. Default 5000 ms. */
|
|
9
9
|
timeoutMs?: number;
|
|
10
10
|
/** Runtime heap cap. Default 64 MiB. */
|
|
11
11
|
memoryLimitBytes?: number;
|
|
12
12
|
/** Native stack cap. Default 1 MiB. */
|
|
13
13
|
maxStackSizeBytes?: number;
|
|
14
14
|
}
|
|
15
|
-
/** An {@link Evaluator} backed by a bounded QuickJS engine. */
|
|
15
|
+
/** An {@link Evaluator} backed by a bounded QuickJS engine in a worker thread. */
|
|
16
16
|
declare function createQuickJSEvaluator(options?: QuickJSEvaluatorOptions): Evaluator;
|
|
17
17
|
|
|
18
18
|
export { type QuickJSEvaluatorOptions, createQuickJSEvaluator };
|
package/dist/quickjs/index.js
CHANGED
|
@@ -1,88 +1,42 @@
|
|
|
1
|
-
import { LowerError } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { runIsolateWorker, outcomeToCollection, LowerError } from '../chunk-MBBKGD7K.js';
|
|
2
|
+
import '../chunk-EEAIM35V.js';
|
|
3
|
+
import '../chunk-6U446SKY.js';
|
|
4
4
|
import '../chunk-5LUIDMF4.js';
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import {
|
|
5
|
+
import '../chunk-UB2BHU2M.js';
|
|
6
|
+
import '../chunk-IHKXLG6I.js';
|
|
7
|
+
import '../chunk-UJNHTS6D.js';
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
|
+
import { pathToFileURL } from 'url';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
var ENGINE_HEADROOM_BYTES = 32 * 1024 * 1024;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
-
|
|
11
|
+
// src/generated/quickjs-worker-source.ts
|
|
12
|
+
var QUICKJS_WORKER_SOURCE = '"use strict";\n\nvar import_node_worker_threads = require("node:worker_threads");\n\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\n\nvar DETERMINISM_VIOLATION = "DeterminismViolation";\nvar DETERMINISM_PRELUDE = `(() => {\n const NAME = ${JSON.stringify(DETERMINISM_VIOLATION)};\n const fail = (what) => {\n const error = new Error(\n what + " is not allowed in workflow code: lowering must give the same IR on every build. Read times and random values at run time instead (for example wf.now)."\n );\n error.name = NAME;\n throw error;\n };\n const lock = (target, key, value) =>\n Object.defineProperty(target, key, { value, writable: false, enumerable: false, configurable: false });\n const RealDate = Date;\n const LockedDate = function Date(...args) {\n if (new.target === undefined) return fail("Date()");\n if (args.length === 0) return fail("new Date()");\n return Reflect.construct(RealDate, args, new.target);\n };\n lock(LockedDate, "prototype", RealDate.prototype);\n lock(RealDate.prototype, "constructor", LockedDate);\n lock(LockedDate, "now", function now() { return fail("Date.now()"); });\n lock(LockedDate, "parse", RealDate.parse);\n lock(LockedDate, "UTC", RealDate.UTC);\n lock(globalThis, "Date", LockedDate);\n lock(Math, "random", function random() { return fail("Math.random()"); });\n const crypto = globalThis.crypto;\n if (crypto !== null && typeof crypto === "object") {\n for (const name of ["getRandomValues", "randomUUID"]) {\n if (typeof crypto[name] === "function") lock(crypto, name, function () { return fail("crypto." + name + "()"); });\n }\n }\n const DateTimeFormat = typeof Intl === "object" && Intl !== null ? Intl.DateTimeFormat : undefined;\n if (typeof DateTimeFormat === "function") {\n const proto = DateTimeFormat.prototype;\n const format = Object.getOwnPropertyDescriptor(proto, "format");\n if (format && typeof format.get === "function") {\n const get = format.get;\n Object.defineProperty(proto, "format", {\n get() {\n const bound = get.call(this);\n return (date) => (date === undefined ? fail("Intl.DateTimeFormat format()") : bound(date));\n },\n enumerable: false,\n configurable: false,\n });\n }\n const formatToParts = proto.formatToParts;\n if (typeof formatToParts === "function") {\n lock(proto, "formatToParts", function (date) {\n return date === undefined ? fail("Intl.DateTimeFormat formatToParts()") : formatToParts.call(this, date);\n });\n }\n }\n})();\n`;\nfunction failure(kind, message) {\n return { ok: false, failure: kind, message };\n}\nfunction failureForErrorName(name) {\n return name === DETERMINISM_VIOLATION ? "determinism" : "error";\n}\n\nfunction isQuickJSApi(value) {\n return isRecord(value) && typeof value["newQuickJSWASMModuleFromVariant"] === "function" && typeof value["newVariant"] === "function" && typeof value["shouldInterruptAfterDeadline"] === "function" && value["RELEASE_SYNC"] !== void 0;\n}\nvar WASM_PAGE_BYTES = 64 * 1024;\nvar ENGINE_HEADROOM_BYTES = 32 * 1024 * 1024;\nvar INITIAL_ENGINE_BYTES = 16 * 1024 * 1024;\nfunction describe(ctx, handle) {\n const dumped = ctx.dump(handle);\n if (isRecord(dumped)) {\n const name = typeof dumped["name"] === "string" ? dumped["name"] : "Error";\n const message = dumped["message"];\n return {\n name,\n message: typeof message === "string" ? message : message === void 0 ? JSON.stringify(dumped) : String(message)\n };\n }\n return { name: "Error", message: String(dumped) };\n}\nasync function evaluateInQuickJS(api, code, limits) {\n const maximum = Math.ceil((limits.memoryLimitBytes + ENGINE_HEADROOM_BYTES) / WASM_PAGE_BYTES);\n const initial = Math.min(maximum, INITIAL_ENGINE_BYTES / WASM_PAGE_BYTES);\n const engine = await api.newQuickJSWASMModuleFromVariant(\n api.newVariant(api.RELEASE_SYNC, { wasmMemory: new WebAssembly.Memory({ initial, maximum }) })\n );\n const runtime = engine.newRuntime();\n const deadline = Date.now() + limits.timeoutMs;\n runtime.setMemoryLimit(limits.memoryLimitBytes);\n runtime.setMaxStackSize(limits.maxStackSizeBytes);\n runtime.setInterruptHandler(api.shouldInterruptAfterDeadline(deadline));\n const ctx = runtime.newContext();\n const handles = [];\n const timedOut = () => failure("timeout", `Evaluating the workflow code timed out after ${limits.timeoutMs} ms`);\n const thrown = (handle) => {\n const { name, message } = describe(ctx, handle);\n handle.dispose();\n if (Date.now() > deadline && /interrupted/.test(message)) return timedOut();\n return failure(failureForErrorName(name), message);\n };\n try {\n const prelude = ctx.evalCode(DETERMINISM_PRELUDE, "determinism-prelude.js", { type: "global" });\n if (prelude.error) return thrown(prelude.error);\n prelude.value.dispose();\n const result = ctx.evalCode(code, "workflow-bundle.mjs", { type: "module" });\n if (result.error) return thrown(result.error);\n let namespace = result.value;\n handles.push(namespace);\n const state = ctx.getPromiseState(namespace);\n if (!(state.type === "fulfilled" && state.notAPromise === true)) {\n if (state.type === "fulfilled") state.value.dispose();\n else if (state.type === "rejected") state.error.dispose();\n while (runtime.hasPendingJob()) {\n if (Date.now() > deadline) return timedOut();\n const jobs = runtime.executePendingJobs();\n if (jobs.error) return thrown(jobs.error);\n }\n const settled = ctx.getPromiseState(namespace);\n if (settled.type === "rejected") return thrown(settled.error);\n if (settled.type === "pending")\n return failure("error", "The workflow module never finished evaluating");\n namespace = settled.value;\n handles.push(namespace);\n }\n const exported = ctx.getProp(namespace, "__fluidgrids");\n handles.push(exported);\n if (ctx.typeof(exported) !== "string")\n return failure("no-collection", "The bundle did not export a workflow collection");\n return { ok: true, value: ctx.getString(exported) };\n } catch (error) {\n return failure("error", error instanceof Error ? error.message : String(error));\n } finally {\n for (const handle of handles.reverse()) if (handle.alive) handle.dispose();\n ctx.dispose();\n runtime.dispose();\n }\n}\n\nprocess.on("unhandledRejection", () => void 0);\nasync function main(input) {\n if (!isRecord(input) || typeof input["code"] !== "string" || typeof input["moduleUrl"] !== "string" || !isRecord(input["limits"]))\n return failure("crashed", "The evaluation worker received no bundle");\n const { timeoutMs, memoryLimitBytes, maxStackSizeBytes } = input["limits"];\n if (typeof timeoutMs !== "number" || typeof memoryLimitBytes !== "number" || typeof maxStackSizeBytes !== "number")\n return failure("crashed", "The evaluation worker received no limits");\n const loaded = await import(input["moduleUrl"]);\n const api = isQuickJSApi(loaded) ? loaded : isRecord(loaded) && isQuickJSApi(loaded["default"]) ? loaded["default"] : void 0;\n if (!api) return failure("crashed", "quickjs-emscripten could not be loaded");\n return evaluateInQuickJS(api, input["code"], {\n timeoutMs,\n memoryLimitBytes,\n maxStackSizeBytes\n });\n}\nmain(import_node_worker_threads.workerData).then(\n (outcome) => import_node_worker_threads.parentPort?.postMessage(outcome),\n (error) => import_node_worker_threads.parentPort?.postMessage(\n failure("crashed", error instanceof Error ? error.message : String(error))\n )\n);\n';
|
|
13
|
+
|
|
14
|
+
// src/quickjs/index.ts
|
|
15
|
+
function quickjsModuleUrl() {
|
|
16
|
+
try {
|
|
17
|
+
return pathToFileURL(createRequire(import.meta.url).resolve("quickjs-emscripten")).href;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new LowerError(
|
|
20
|
+
`quickjs-emscripten cannot be resolved: ${error instanceof Error ? error.message : String(error)}`,
|
|
21
|
+
"crashed"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
18
24
|
}
|
|
19
25
|
function createQuickJSEvaluator(options = {}) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
const limits = {
|
|
27
|
+
timeoutMs: options.timeoutMs ?? 5e3,
|
|
28
|
+
memoryLimitBytes: options.memoryLimitBytes ?? 64 * 1024 * 1024,
|
|
29
|
+
maxStackSizeBytes: options.maxStackSizeBytes ?? 1024 * 1024
|
|
30
|
+
};
|
|
23
31
|
return {
|
|
24
32
|
format: "esm",
|
|
25
33
|
async evaluate(code) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const deadline = Date.now() + timeoutMs;
|
|
33
|
-
runtime.setMemoryLimit(memoryLimitBytes);
|
|
34
|
-
runtime.setMaxStackSize(maxStackSizeBytes);
|
|
35
|
-
runtime.setInterruptHandler(shouldInterruptAfterDeadline(deadline));
|
|
36
|
-
const ctx = runtime.newContext();
|
|
37
|
-
const handles = [];
|
|
38
|
-
try {
|
|
39
|
-
const result = ctx.evalCode(code, "workflow-bundle.mjs", { type: "module" });
|
|
40
|
-
if (result.error) {
|
|
41
|
-
const message = errorMessage(ctx, result.error);
|
|
42
|
-
result.error.dispose();
|
|
43
|
-
throw new LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
44
|
-
}
|
|
45
|
-
let namespace = result.value;
|
|
46
|
-
handles.push(namespace);
|
|
47
|
-
const state = ctx.getPromiseState(namespace);
|
|
48
|
-
if (!(state.type === "fulfilled" && state.notAPromise === true)) {
|
|
49
|
-
if (state.type === "fulfilled") state.value.dispose();
|
|
50
|
-
else if (state.type === "rejected") state.error.dispose();
|
|
51
|
-
while (runtime.hasPendingJob()) {
|
|
52
|
-
if (Date.now() > deadline)
|
|
53
|
-
throw new LowerError("Evaluating the workflow code timed out");
|
|
54
|
-
const jobs = runtime.executePendingJobs();
|
|
55
|
-
if (jobs.error) {
|
|
56
|
-
const message = errorMessage(ctx, jobs.error);
|
|
57
|
-
jobs.error.dispose();
|
|
58
|
-
throw new LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const settled = ctx.getPromiseState(namespace);
|
|
62
|
-
if (settled.type === "rejected") {
|
|
63
|
-
const message = errorMessage(ctx, settled.error);
|
|
64
|
-
settled.error.dispose();
|
|
65
|
-
throw new LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
66
|
-
}
|
|
67
|
-
if (settled.type === "pending")
|
|
68
|
-
throw new LowerError("The workflow module never finished evaluating");
|
|
69
|
-
namespace = settled.value;
|
|
70
|
-
handles.push(namespace);
|
|
71
|
-
}
|
|
72
|
-
const exported = ctx.getProp(namespace, "__fluidgrids");
|
|
73
|
-
handles.push(exported);
|
|
74
|
-
if (ctx.typeof(exported) !== "string")
|
|
75
|
-
throw new LowerError("The bundle did not export a workflow collection");
|
|
76
|
-
return ctx.getString(exported);
|
|
77
|
-
} catch (error) {
|
|
78
|
-
if (error instanceof LowerError) throw error;
|
|
79
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
80
|
-
throw new LowerError(`Evaluating the workflow code failed: ${message}`);
|
|
81
|
-
} finally {
|
|
82
|
-
for (const handle of handles.reverse()) if (handle.alive) handle.dispose();
|
|
83
|
-
ctx.dispose();
|
|
84
|
-
runtime.dispose();
|
|
85
|
-
}
|
|
34
|
+
const outcome = await runIsolateWorker({
|
|
35
|
+
source: QUICKJS_WORKER_SOURCE,
|
|
36
|
+
workerData: { code, limits, moduleUrl: quickjsModuleUrl() },
|
|
37
|
+
timeoutMs: limits.timeoutMs
|
|
38
|
+
});
|
|
39
|
+
return outcomeToCollection(outcome);
|
|
86
40
|
}
|
|
87
41
|
};
|
|
88
42
|
}
|