@fluidgrids/workflows 2026.1027.0 → 2026.1028.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 +170 -18
- package/dist/activation-BBh1p82z.d.cts +57 -0
- package/dist/activation-DnhG7SmF.d.ts +57 -0
- package/dist/assemble-BLqQ8lSu.d.cts +39 -0
- package/dist/assemble-DWgaXHd-.d.ts +39 -0
- package/dist/chunk-2DP2Y6EU.cjs +832 -0
- package/dist/chunk-2J6TF7YI.cjs +86 -0
- package/dist/chunk-3FOTFQ3J.js +1622 -0
- package/dist/chunk-4LYSEANA.js +199 -0
- package/dist/{chunk-KUTMY2IO.cjs → chunk-57MSZ24T.cjs} +162 -98
- package/dist/{chunk-BWSLWF2E.js → chunk-5HDSBTBX.js} +99 -32
- package/dist/chunk-623FVQSN.cjs +251 -0
- package/dist/{chunk-4DPEGDPW.js → chunk-6FSHT5IL.js} +4 -4
- package/dist/{chunk-REV7ZOA4.js → chunk-7AAZGVKD.js} +1 -35
- package/dist/chunk-7NQ37GZU.js +73 -0
- package/dist/chunk-ABFZWYHT.js +612 -0
- package/dist/{chunk-SS4LT2IP.js → chunk-BD7ZPG53.js} +5 -10
- package/dist/chunk-BO6OVILK.js +79 -0
- package/dist/chunk-C5OLWZ42.js +245 -0
- package/dist/chunk-CBL5JSCC.cjs +75 -0
- package/dist/{chunk-LSKSBVL4.cjs → chunk-CPDK3K5N.cjs} +6 -6
- package/dist/chunk-CSNWNFKU.cjs +1635 -0
- package/dist/chunk-DJYMDLV5.js +227 -0
- package/dist/{chunk-X4HKU3MX.js → chunk-E2VK7J2C.js} +3 -1
- package/dist/chunk-FMSW2HDF.cjs +267 -0
- package/dist/chunk-FQIHX7YI.cjs +80 -0
- package/dist/chunk-FR7KYWRO.cjs +41 -0
- package/dist/{chunk-AU3YW7FZ.cjs → chunk-GBQ33SIZ.cjs} +46 -51
- package/dist/{chunk-RRQ5HOBF.cjs → chunk-GVTZMA5C.cjs} +4 -4
- package/dist/chunk-H7KEVW2M.js +816 -0
- package/dist/chunk-HR3BN4C4.cjs +27 -0
- package/dist/chunk-IISBRUWJ.js +13 -0
- package/dist/chunk-JD2VQIDZ.cjs +15 -0
- package/dist/{chunk-PL73GJR4.js → chunk-JZ4TOOLN.js} +1 -1
- package/dist/chunk-L24YIZY7.cjs +207 -0
- package/dist/chunk-LNUQE6D6.js +39 -0
- package/dist/{chunk-BYJ7QTLY.cjs → chunk-NEIUQASE.cjs} +13 -13
- package/dist/chunk-P6TA5EZT.cjs +634 -0
- package/dist/chunk-PDHLTDZB.js +72 -0
- package/dist/chunk-PMCM2OH4.js +46 -0
- package/dist/chunk-PZCVF76Q.cjs +868 -0
- package/dist/{chunk-GO34UHSY.js → chunk-QAN5MZEM.js} +3 -3
- package/dist/{chunk-27HASETB.cjs → chunk-QKZL3ONM.cjs} +3 -1
- package/dist/chunk-SAENRNBJ.cjs +52 -0
- package/dist/{chunk-LMX35GNQ.js → chunk-SMCANK3F.js} +5 -4
- package/dist/{chunk-IZQNUNSU.cjs → chunk-SX2PNKKT.cjs} +18 -17
- package/dist/{chunk-LRM6JXJA.cjs → chunk-TBDXTV22.cjs} +0 -37
- package/dist/chunk-VOKMAAJP.js +848 -0
- package/dist/chunk-XB53G2DK.js +25 -0
- package/dist/chunk-Z2Y65YOY.cjs +7 -0
- package/dist/codegen/index.cjs +9 -7
- package/dist/codegen/index.d.cts +2 -2
- package/dist/codegen/index.d.ts +2 -2
- package/dist/codegen/index.js +6 -5
- package/dist/file-BOoHZgoQ.d.cts +1557 -0
- package/dist/file-yuPCFU5b.d.ts +1557 -0
- package/dist/history/index.cjs +287 -0
- package/dist/history/index.d.cts +157 -0
- package/dist/history/index.d.ts +157 -0
- package/dist/history/index.js +5 -0
- package/dist/index.cjs +134 -36
- package/dist/index.d.cts +137 -9
- package/dist/index.d.ts +137 -9
- package/dist/index.js +8 -3
- package/dist/ir/index.cjs +161 -165
- package/dist/ir/index.d.cts +32 -12
- package/dist/ir/index.d.ts +32 -12
- package/dist/ir/index.js +54 -61
- package/dist/lower-BuSvAFqi.d.cts +129 -0
- package/dist/lower-C_Qv_34S.d.ts +129 -0
- package/dist/lower-types-nofRXw9c.d.cts +15 -0
- package/dist/lower-types-nofRXw9c.d.ts +15 -0
- package/dist/{manifest-Duf-gHdO.d.cts → manifest-0OLw0i7k.d.cts} +1 -1
- package/dist/{manifest-Bp9ZJlav.d.ts → manifest-C8N6HDYl.d.ts} +1 -1
- package/dist/node-evaluator-CJNP4GHX.js +12 -0
- package/dist/node-evaluator-DMKPKUWA.cjs +22 -0
- package/dist/quickjs/index.cjs +256 -78
- package/dist/quickjs/index.d.cts +48 -7
- package/dist/quickjs/index.d.ts +48 -7
- package/dist/quickjs/index.js +254 -79
- package/dist/roundtrip/index.cjs +404 -129
- package/dist/roundtrip/index.d.cts +43 -8
- package/dist/roundtrip/index.d.ts +43 -8
- package/dist/roundtrip/index.js +260 -19
- package/dist/runtime/index.cjs +90 -0
- package/dist/runtime/index.d.cts +297 -0
- package/dist/runtime/index.d.ts +297 -0
- package/dist/runtime/index.js +8 -0
- package/dist/testing/index.cjs +1057 -0
- package/dist/testing/index.d.cts +305 -0
- package/dist/testing/index.d.ts +305 -0
- package/dist/testing/index.js +1037 -0
- package/dist/{types-Dr2Fn1Ax.d.ts → types-BGoPzgcl.d.cts} +1 -1
- package/dist/{types-Dr2Fn1Ax.d.cts → types-BGoPzgcl.d.ts} +1 -1
- package/dist/types-CpBBjaGX.d.cts +380 -0
- package/dist/types-DV-HX_Gt.d.ts +380 -0
- package/dist/{assemble-DMOuaxRI.d.ts → workflow-Bpr3vnA_.d.ts} +60 -162
- package/dist/workflow-C2a05WUJ.d.ts +444 -0
- package/dist/{assemble-BJo9TECS.d.cts → workflow-FXUkpIBc.d.cts} +60 -162
- package/dist/workflow-J-yYixny.d.cts +444 -0
- package/fixtures/README.md +128 -0
- package/fixtures/histories/activity-failure-fails-run.history.json +163 -0
- package/fixtures/histories/activity-retry-then-success.history.json +147 -0
- package/fixtures/histories/cancel-activity-abandon.history.json +126 -0
- package/fixtures/histories/cancel-activity-compensate.history.json +307 -0
- package/fixtures/histories/cancel-concurrent-non-cancellable.history.json +234 -0
- package/fixtures/histories/cancel-concurrent-scope-timeout.history.json +184 -0
- package/fixtures/histories/cancel-condition-after-cancel.history.json +200 -0
- package/fixtures/histories/cancel-during-timer.history.json +123 -0
- package/fixtures/histories/cancel-saga-compensations.history.json +325 -0
- package/fixtures/histories/cancel-scope-timeout.history.json +148 -0
- package/fixtures/histories/child-abandon-outlives-parent.history.json +191 -0
- package/fixtures/histories/child-cancel-default.history.json +234 -0
- package/fixtures/histories/child-cancel-request.history.json +206 -0
- package/fixtures/histories/child-durable-child-side.history.json +124 -0
- package/fixtures/histories/child-durable-result.history.json +163 -0
- package/fixtures/histories/child-failure-caught.history.json +166 -0
- package/fixtures/histories/child-graph-by-key.history.json +138 -0
- package/fixtures/histories/child-terminated-by-parent-close.history.json +85 -0
- package/fixtures/histories/continue-as-new-first-run.history.json +146 -0
- package/fixtures/histories/continue-as-new-history-limit.history.json +489 -0
- package/fixtures/histories/continue-as-new-last-run.history.json +147 -0
- package/fixtures/histories/continue-as-new-suggested.history.json +352 -0
- package/fixtures/histories/details-and-context.history.json +176 -0
- package/fixtures/histories/deterministic-values.history.json +128 -0
- package/fixtures/histories/engine-builtins.history.json +172 -0
- package/fixtures/histories/gather-activities.history.json +291 -0
- package/fixtures/histories/gather-all-settled.history.json +219 -0
- package/fixtures/histories/gather-mixed.history.json +281 -0
- package/fixtures/histories/input-during-running-task.history.json +111 -0
- package/fixtures/histories/nondeterminism-reordered.history.json +218 -0
- package/fixtures/histories/patched-deprecated.history.json +271 -0
- package/fixtures/histories/patched-new-run.history.json +270 -0
- package/fixtures/histories/patched-old-history.history.json +190 -0
- package/fixtures/histories/race-activity-wins.history.json +152 -0
- package/fixtures/histories/race-signal-beats-child.history.json +161 -0
- package/fixtures/histories/race-timeout-wins.history.json +118 -0
- package/fixtures/histories/side-effect-recorded.history.json +153 -0
- package/fixtures/histories/signal-buffered-at-start.history.json +157 -0
- package/fixtures/histories/signal-default-handler.history.json +187 -0
- package/fixtures/histories/signal-handler.history.json +191 -0
- package/fixtures/histories/signal-parent-child-side.history.json +132 -0
- package/fixtures/histories/signal-parent.history.json +202 -0
- package/fixtures/histories/signal-run-delivered.history.json +128 -0
- package/fixtures/histories/signal-run-undelivered.history.json +134 -0
- package/fixtures/histories/signal-wait.history.json +111 -0
- package/fixtures/histories/task-failure-code-error.history.json +137 -0
- package/fixtures/histories/task-failure-then-transient-attempt.history.json +140 -0
- package/fixtures/histories/timer-condition-met.history.json +201 -0
- package/fixtures/histories/timer-condition-timeout.history.json +118 -0
- package/fixtures/histories/timer-sleep-once.history.json +118 -0
- package/fixtures/histories/timer-sleep-sequence.history.json +210 -0
- package/fixtures/histories/update-accepted-completed.history.json +149 -0
- package/fixtures/histories/update-with-start-rejected-validation.history.json +91 -0
- package/package.json +85 -20
- package/schema/history-file.schema.json +2544 -0
- package/schema/ir-v2.schema.json +16 -0
- package/schema/run-event.schema.json +2374 -0
- package/schema/workflow-command.schema.json +1095 -0
- package/schema/workflow-task.schema.json +3560 -0
- 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/lower-DcOY8ux0.d.cts +0 -49
- package/dist/lower-Dw5grNrI.d.ts +0 -49
- package/dist/node-evaluator-2GTUZVPK.cjs +0 -17
- package/dist/node-evaluator-RMYEWCXZ.js +0 -8
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk2DP2Y6EU_cjs = require('./chunk-2DP2Y6EU.cjs');
|
|
4
|
+
|
|
5
|
+
// src/generated/vm-worker-source.ts
|
|
6
|
+
var VM_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}\n\nvar import_node_vm = require("node:vm");\nvar import_node_util = require("node:util");\nvar BUNDLE_GLOBAL = "__fluidgridsBundle";\nfunction wrap(code) {\n return `(function () {\n const describe = (error) => {\n let name = "Error";\n let message = "";\n try {\n if (error !== null && (typeof error === "object" || typeof error === "function")) {\n const n = error.name;\n if (typeof n === "string") name = n;\n const m = error.message;\n message = typeof m === "string" ? m : m === undefined ? "" + error : "" + m;\n } else {\n message = "" + error;\n }\n } catch (_) {\n message = "a value whose message cannot be read was thrown";\n }\n return (name === ${JSON.stringify(DETERMINISM_VIOLATION)} ? "D" : "E") + message;\n };\n try {\n${code}\n;const __fluidgridsValue = ${BUNDLE_GLOBAL}.__fluidgrids;\n return typeof __fluidgridsValue === "string" ? "R" + __fluidgridsValue : "N";\n } catch (error) {\n try {\n return describe(error);\n } catch (_) {\n return "Ean error that cannot be described was thrown";\n }\n }\n})()`;\n}\nfunction hostErrorFields(error) {\n if (!import_node_util.types.isNativeError(error)) return {};\n const code = Object.getOwnPropertyDescriptor(error, "code")?.value;\n const message = Object.getOwnPropertyDescriptor(error, "message")?.value;\n return {\n ...typeof code === "string" ? { code } : {},\n ...typeof message === "string" ? { message } : {}\n };\n}\nfunction decode(result) {\n const tag = result.charAt(0);\n const rest = result.slice(1);\n if (tag === "R") return { ok: true, value: rest };\n if (tag === "N")\n return failure("no-collection", "The bundle did not export a workflow collection");\n if (tag === "D") return failure("determinism", rest);\n return failure("error", rest);\n}\nfunction runInVmContext(code, timeoutMs) {\n const context = (0, import_node_vm.createContext)(/* @__PURE__ */ Object.create(null), {\n codeGeneration: { strings: false, wasm: false },\n microtaskMode: "afterEvaluate",\n name: "fluidgrids-workflow-lowering"\n });\n const refuseImport = () => {\n throw new Error("Workflow code may not import modules at run time");\n };\n const deadline = Date.now() + timeoutMs;\n const run = (source, filename) => new import_node_vm.Script(source, { filename, importModuleDynamically: refuseImport }).runInContext(context, {\n timeout: Math.max(1, deadline - Date.now()),\n breakOnSigint: true\n });\n try {\n run(DETERMINISM_PRELUDE, "determinism-prelude.js");\n const result = run(wrap(code), "workflow-bundle.js");\n return typeof result === "string" ? decode(result) : failure("no-collection", "The bundle did not export a workflow collection");\n } catch (error) {\n const fields = hostErrorFields(error);\n if (fields.code === "ERR_SCRIPT_EXECUTION_TIMEOUT" || fields.message !== void 0 && /^Script execution timed out/.test(fields.message)) {\n return failure("timeout", `Evaluating the workflow code timed out after ${timeoutMs} ms`);\n }\n return failure("error", fields.message ?? "The workflow code could not be evaluated");\n }\n}\n\nprocess.on("unhandledRejection", () => void 0);\nvar input = import_node_worker_threads.workerData;\nimport_node_worker_threads.parentPort?.postMessage(\n isRecord(input) && typeof input["code"] === "string" && typeof input["timeoutMs"] === "number" ? runInVmContext(input["code"], input["timeoutMs"]) : failure("crashed", "The evaluation worker received no bundle")\n);\n';
|
|
7
|
+
|
|
8
|
+
// src/roundtrip/node-evaluator.ts
|
|
9
|
+
var MIB = 1024 * 1024;
|
|
10
|
+
function createNodeVmEvaluator(options = {}) {
|
|
11
|
+
const timeoutMs = options.timeoutMs ?? 5e3;
|
|
12
|
+
const memoryLimitBytes = options.memoryLimitBytes ?? 512 * MIB;
|
|
13
|
+
return {
|
|
14
|
+
format: "iife",
|
|
15
|
+
async evaluate(code) {
|
|
16
|
+
const outcome = await chunk2DP2Y6EU_cjs.runIsolateWorker({
|
|
17
|
+
source: VM_WORKER_SOURCE,
|
|
18
|
+
workerData: { code, timeoutMs },
|
|
19
|
+
timeoutMs,
|
|
20
|
+
resourceLimits: { maxOldGenerationSizeMb: Math.max(16, Math.ceil(memoryLimitBytes / MIB)) }
|
|
21
|
+
});
|
|
22
|
+
return chunk2DP2Y6EU_cjs.outcomeToCollection(outcome);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.createNodeVmEvaluator = createNodeVmEvaluator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HISTORY_PROTOCOL } from './chunk-DJYMDLV5.js';
|
|
2
|
+
|
|
3
|
+
function failedTaskResult(cause, message) {
|
|
4
|
+
return {
|
|
5
|
+
protocol: HISTORY_PROTOCOL,
|
|
6
|
+
outcome: "failed",
|
|
7
|
+
commands: [],
|
|
8
|
+
failure: { cause, message },
|
|
9
|
+
logs: []
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { failedTaskResult };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk623FVQSN_cjs = require('./chunk-623FVQSN.cjs');
|
|
4
|
+
|
|
5
|
+
function failedTaskResult(cause, message) {
|
|
6
|
+
return {
|
|
7
|
+
protocol: chunk623FVQSN_cjs.HISTORY_PROTOCOL,
|
|
8
|
+
outcome: "failed",
|
|
9
|
+
commands: [],
|
|
10
|
+
failure: { cause, message },
|
|
11
|
+
logs: []
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.failedTaskResult = failedTaskResult;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/runtime/shims.ts
|
|
4
|
+
var SHIM_VIOLATION = "DeterminismViolation";
|
|
5
|
+
var SHIM_HOOK = "__fluidgridsShims";
|
|
6
|
+
var TASK_PRELUDE = `(() => {
|
|
7
|
+
const NAME = ${JSON.stringify(SHIM_VIOLATION)};
|
|
8
|
+
const fail = (what) => {
|
|
9
|
+
const error = new Error(what + " is not allowed in workflow code: use ctx.now(), ctx.random(), ctx.sleep() or an activity.");
|
|
10
|
+
error.name = NAME;
|
|
11
|
+
throw error;
|
|
12
|
+
};
|
|
13
|
+
let hooks = null;
|
|
14
|
+
const now = (what) => (hooks !== null ? hooks.now() : fail(what + " outside a workflow task"));
|
|
15
|
+
const lock = (target, key, value) =>
|
|
16
|
+
Object.defineProperty(target, key, { value, writable: false, enumerable: false, configurable: false });
|
|
17
|
+
const RealDate = Date;
|
|
18
|
+
// ---- Built-ins that differ between hosts and engines --------------------
|
|
19
|
+
// Local time is UTC whatever the host's TZ, locale formatting is fixed
|
|
20
|
+
// (en-US shapes, no ICU), Intl is absent and garbage collection cannot be
|
|
21
|
+
// observed, so QuickJS and vm on any host run workflow code the same way.
|
|
22
|
+
const proto = RealDate.prototype;
|
|
23
|
+
const hostOffset = proto.getTimezoneOffset;
|
|
24
|
+
const realParse = RealDate.parse;
|
|
25
|
+
const isInvalid = (date) => Number.isNaN(proto.getTime.call(date));
|
|
26
|
+
for (const unit of ["FullYear", "Month", "Date", "Day", "Hours", "Minutes", "Seconds", "Milliseconds"]) {
|
|
27
|
+
lock(proto, "get" + unit, proto["getUTC" + unit]);
|
|
28
|
+
if (unit !== "Day") lock(proto, "set" + unit, proto["setUTC" + unit]);
|
|
29
|
+
}
|
|
30
|
+
lock(proto, "getTimezoneOffset", function getTimezoneOffset() { return isInvalid(this) ? NaN : 0; });
|
|
31
|
+
if (typeof proto.getYear === "function")
|
|
32
|
+
lock(proto, "getYear", function getYear() { return isInvalid(this) ? NaN : this.getUTCFullYear() - 1900; });
|
|
33
|
+
if (typeof proto.setYear === "function")
|
|
34
|
+
lock(proto, "setYear", function setYear(value) {
|
|
35
|
+
const year = Number(value);
|
|
36
|
+
if (Number.isNaN(year)) return this.setTime(NaN);
|
|
37
|
+
const whole = Math.trunc(year);
|
|
38
|
+
const base = new RealDate(isInvalid(this) ? 0 : this.getTime());
|
|
39
|
+
base.setUTCFullYear(whole >= 0 && whole <= 99 ? 1900 + whole : whole);
|
|
40
|
+
return this.setTime(base.getTime());
|
|
41
|
+
});
|
|
42
|
+
const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
43
|
+
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
44
|
+
const pad = (value, width) => String(value).padStart(width, "0");
|
|
45
|
+
const yearText = (year) => (year < 0 ? "-" + pad(-year, 6) : pad(year, 4));
|
|
46
|
+
const dateText = (d) =>
|
|
47
|
+
DAYS[d.getUTCDay()] + " " + MONTHS[d.getUTCMonth()] + " " + pad(d.getUTCDate(), 2) + " " + yearText(d.getUTCFullYear());
|
|
48
|
+
const timeText = (d) =>
|
|
49
|
+
pad(d.getUTCHours(), 2) + ":" + pad(d.getUTCMinutes(), 2) + ":" + pad(d.getUTCSeconds(), 2) + " GMT+0000 (Coordinated Universal Time)";
|
|
50
|
+
const localeDate = (d) => d.getUTCMonth() + 1 + "/" + d.getUTCDate() + "/" + d.getUTCFullYear();
|
|
51
|
+
const localeTime = (d) => {
|
|
52
|
+
const hours = d.getUTCHours();
|
|
53
|
+
return ((hours + 11) % 12) + 1 + ":" + pad(d.getUTCMinutes(), 2) + ":" + pad(d.getUTCSeconds(), 2) + (hours < 12 ? " AM" : " PM");
|
|
54
|
+
};
|
|
55
|
+
const formatter = (format) => function () { return isInvalid(this) ? "Invalid Date" : format(this); };
|
|
56
|
+
lock(proto, "toString", formatter((d) => dateText(d) + " " + timeText(d)));
|
|
57
|
+
lock(proto, "toDateString", formatter(dateText));
|
|
58
|
+
lock(proto, "toTimeString", formatter(timeText));
|
|
59
|
+
lock(proto, "toLocaleString", formatter((d) => localeDate(d) + ", " + localeTime(d)));
|
|
60
|
+
lock(proto, "toLocaleDateString", formatter(localeDate));
|
|
61
|
+
lock(proto, "toLocaleTimeString", formatter(localeTime));
|
|
62
|
+
// A date-time without an offset is local time to the host's parser; read it as UTC.
|
|
63
|
+
const DATE_ONLY = /^[+-]?\\d{4,6}(?:-\\d{2}(?:-\\d{2})?)?$/;
|
|
64
|
+
const ZONE_AFTER_TIME = /\\d:\\d{2}(?::\\d{2}(?:[.,]\\d+)?)?\\s*(?:[AP]M\\s*)?(?:Z|[+-]\\d{2}(?::?\\d{2})?|[ECMP][SD]T)\\s*(?:\\([^)]*\\))?\\s*$/i;
|
|
65
|
+
const NAMED_ZONE = /\\b(?:GMT|UTC|UT)\\b(?:\\s*[+-]\\d{2}:?\\d{2})?\\s*(?:\\([^)]*\\))?\\s*$/i;
|
|
66
|
+
const parse = function parse(value) {
|
|
67
|
+
const text = String(value);
|
|
68
|
+
const time = realParse(text);
|
|
69
|
+
if (Number.isNaN(time)) return time;
|
|
70
|
+
const trimmed = text.trim();
|
|
71
|
+
if (DATE_ONLY.test(trimmed) || ZONE_AFTER_TIME.test(trimmed) || NAMED_ZONE.test(trimmed)) return time;
|
|
72
|
+
return time - hostOffset.call(new RealDate(time)) * 60000;
|
|
73
|
+
};
|
|
74
|
+
const toTimeValue = (value) => {
|
|
75
|
+
if (value instanceof RealDate) return value.getTime();
|
|
76
|
+
let primitive = value;
|
|
77
|
+
if (typeof value === "object" && value !== null) {
|
|
78
|
+
primitive = value.valueOf();
|
|
79
|
+
if (typeof primitive === "object" && primitive !== null) primitive = String(value);
|
|
80
|
+
}
|
|
81
|
+
return typeof primitive === "string" ? parse(primitive) : primitive;
|
|
82
|
+
};
|
|
83
|
+
// ---- Number, string and array locale methods ----------------------------
|
|
84
|
+
const group = (digits) => digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ",");
|
|
85
|
+
lock(Number.prototype, "toLocaleString", function toLocaleString() {
|
|
86
|
+
const x = Number.prototype.valueOf.call(this);
|
|
87
|
+
if (Number.isNaN(x)) return "NaN";
|
|
88
|
+
const sign = x < 0 || Object.is(x, -0) ? "-" : "";
|
|
89
|
+
const abs = Math.abs(x);
|
|
90
|
+
if (abs === Infinity) return sign + "\\u221e";
|
|
91
|
+
const fixed = abs < 1e21 ? abs.toFixed(3) : BigInt(abs).toString() + ".000";
|
|
92
|
+
const [whole, fraction] = fixed.split(".");
|
|
93
|
+
const kept = fraction.replace(/0+$/, "");
|
|
94
|
+
return sign + group(whole) + (kept === "" ? "" : "." + kept);
|
|
95
|
+
});
|
|
96
|
+
if (typeof BigInt === "function")
|
|
97
|
+
lock(BigInt.prototype, "toLocaleString", function toLocaleString() {
|
|
98
|
+
const text = BigInt.prototype.toString.call(this);
|
|
99
|
+
return text.startsWith("-") ? "-" + group(text.slice(1)) : group(text);
|
|
100
|
+
});
|
|
101
|
+
lock(String.prototype, "localeCompare", function localeCompare(that) {
|
|
102
|
+
const a = String(this);
|
|
103
|
+
const b = String(that);
|
|
104
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
105
|
+
});
|
|
106
|
+
lock(String.prototype, "toLocaleUpperCase", function toLocaleUpperCase() { return String(this).toUpperCase(); });
|
|
107
|
+
lock(String.prototype, "toLocaleLowerCase", function toLocaleLowerCase() { return String(this).toLowerCase(); });
|
|
108
|
+
const listLocale = function toLocaleString() {
|
|
109
|
+
return Array.prototype.map.call(this, (item) => (item === null || item === undefined ? "" : item.toLocaleString())).join(",");
|
|
110
|
+
};
|
|
111
|
+
lock(Array.prototype, "toLocaleString", listLocale);
|
|
112
|
+
lock(Object.getPrototypeOf(Uint8Array.prototype), "toLocaleString", listLocale);
|
|
113
|
+
// ---- Absent or refused ---------------------------------------------------
|
|
114
|
+
if (!Reflect.deleteProperty(globalThis, "Intl")) lock(globalThis, "Intl", undefined);
|
|
115
|
+
for (const name of ["WeakRef", "FinalizationRegistry"]) {
|
|
116
|
+
lock(globalThis, name, function () { return fail(name + " (garbage collection is not deterministic)"); });
|
|
117
|
+
}
|
|
118
|
+
const LockedDate = function Date(...args) {
|
|
119
|
+
if (new.target === undefined) return new RealDate(now("Date()")).toString();
|
|
120
|
+
if (args.length === 0) return Reflect.construct(RealDate, [now("new Date()")], new.target);
|
|
121
|
+
if (args.length === 1) return Reflect.construct(RealDate, [toTimeValue(args[0])], new.target);
|
|
122
|
+
return Reflect.construct(RealDate, [RealDate.UTC(...args)], new.target);
|
|
123
|
+
};
|
|
124
|
+
lock(LockedDate, "prototype", RealDate.prototype);
|
|
125
|
+
lock(RealDate.prototype, "constructor", LockedDate);
|
|
126
|
+
lock(LockedDate, "now", function now_() { return now("Date.now()"); });
|
|
127
|
+
lock(LockedDate, "parse", parse);
|
|
128
|
+
lock(LockedDate, "UTC", RealDate.UTC);
|
|
129
|
+
lock(globalThis, "Date", LockedDate);
|
|
130
|
+
lock(Math, "random", function random() {
|
|
131
|
+
return hooks !== null ? hooks.random() : fail("Math.random() outside a workflow task");
|
|
132
|
+
});
|
|
133
|
+
const crypto = globalThis.crypto;
|
|
134
|
+
if (crypto !== null && typeof crypto === "object") {
|
|
135
|
+
if (typeof crypto.getRandomValues === "function")
|
|
136
|
+
lock(crypto, "getRandomValues", function getRandomValues(array) {
|
|
137
|
+
if (hooks === null) return fail("crypto.getRandomValues() outside a workflow task");
|
|
138
|
+
for (let i = 0; i < array.length; i++) array[i] = Math.floor(hooks.random() * 256);
|
|
139
|
+
return array;
|
|
140
|
+
});
|
|
141
|
+
if (typeof crypto.randomUUID === "function")
|
|
142
|
+
lock(crypto, "randomUUID", function randomUUID() { return fail("crypto.randomUUID(): use ctx.uuid()"); });
|
|
143
|
+
}
|
|
144
|
+
for (const name of ["setTimeout", "setInterval", "setImmediate", "clearTimeout", "clearInterval", "clearImmediate"]) {
|
|
145
|
+
lock(globalThis, name, function () { return fail(name + "(): use ctx.sleep()"); });
|
|
146
|
+
}
|
|
147
|
+
for (const name of ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"]) {
|
|
148
|
+
lock(globalThis, name, function () { return fail(name + ": do I/O in an activity (ctx.run)"); });
|
|
149
|
+
}
|
|
150
|
+
Object.defineProperty(globalThis, ${JSON.stringify(SHIM_HOOK)}, {
|
|
151
|
+
value: Object.freeze({
|
|
152
|
+
attach(next) { hooks = next; },
|
|
153
|
+
detach() { hooks = null; },
|
|
154
|
+
}),
|
|
155
|
+
writable: false,
|
|
156
|
+
enumerable: false,
|
|
157
|
+
configurable: true,
|
|
158
|
+
});
|
|
159
|
+
})();
|
|
160
|
+
`;
|
|
161
|
+
function isShimControl(value) {
|
|
162
|
+
return typeof value === "object" && value !== null && typeof value.attach === "function" && typeof value.detach === "function";
|
|
163
|
+
}
|
|
164
|
+
function takeShimControl() {
|
|
165
|
+
const holder = globalThis;
|
|
166
|
+
const control = holder[SHIM_HOOK];
|
|
167
|
+
if (!isShimControl(control)) return void 0;
|
|
168
|
+
delete holder[SHIM_HOOK];
|
|
169
|
+
return control;
|
|
170
|
+
}
|
|
171
|
+
function seedOf(text) {
|
|
172
|
+
let hash = 2166136261;
|
|
173
|
+
for (let index = 0; index < text.length; index++) {
|
|
174
|
+
hash ^= text.charCodeAt(index);
|
|
175
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
176
|
+
}
|
|
177
|
+
return hash >>> 0;
|
|
178
|
+
}
|
|
179
|
+
function createRandom(seed) {
|
|
180
|
+
let state = seed >>> 0;
|
|
181
|
+
return () => {
|
|
182
|
+
state = state + 1831565813 >>> 0;
|
|
183
|
+
let t = state;
|
|
184
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
185
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
186
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function uuidFrom(random) {
|
|
190
|
+
const hex = [];
|
|
191
|
+
for (let index = 0; index < 16; index++) {
|
|
192
|
+
let byte = Math.floor(random() * 256) & 255;
|
|
193
|
+
if (index === 6) byte = byte & 15 | 64;
|
|
194
|
+
if (index === 8) byte = byte & 63 | 128;
|
|
195
|
+
hex.push(byte.toString(16).padStart(2, "0"));
|
|
196
|
+
}
|
|
197
|
+
const text = hex.join("");
|
|
198
|
+
return `${text.slice(0, 8)}-${text.slice(8, 12)}-${text.slice(12, 16)}-${text.slice(16, 20)}-${text.slice(20)}`;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
exports.SHIM_HOOK = SHIM_HOOK;
|
|
202
|
+
exports.SHIM_VIOLATION = SHIM_VIOLATION;
|
|
203
|
+
exports.TASK_PRELUDE = TASK_PRELUDE;
|
|
204
|
+
exports.createRandom = createRandom;
|
|
205
|
+
exports.seedOf = seedOf;
|
|
206
|
+
exports.takeShimControl = takeShimControl;
|
|
207
|
+
exports.uuidFrom = uuidFrom;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/ir/duration.ts
|
|
2
|
+
var SHORT = /^(\d+(?:\.\d+)?)(ms|s|m|h|d|w)$/;
|
|
3
|
+
var ISO = /^P(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;
|
|
4
|
+
var SECOND_MS = 1e3;
|
|
5
|
+
var MINUTE_MS = 60 * SECOND_MS;
|
|
6
|
+
var HOUR_MS = 60 * MINUTE_MS;
|
|
7
|
+
var DAY_MS = 24 * HOUR_MS;
|
|
8
|
+
var WEEK_MS = 7 * DAY_MS;
|
|
9
|
+
var UNIT_MS = {
|
|
10
|
+
ms: 1,
|
|
11
|
+
s: SECOND_MS,
|
|
12
|
+
m: MINUTE_MS,
|
|
13
|
+
h: HOUR_MS,
|
|
14
|
+
d: DAY_MS,
|
|
15
|
+
w: WEEK_MS
|
|
16
|
+
};
|
|
17
|
+
function durationMs(value, numberUnit) {
|
|
18
|
+
if (typeof value === "number") {
|
|
19
|
+
if (!Number.isFinite(value) || value < 0) return void 0;
|
|
20
|
+
return numberUnit === "s" ? value * 1e3 : value;
|
|
21
|
+
}
|
|
22
|
+
if (typeof value !== "string") return void 0;
|
|
23
|
+
const text = value.trim();
|
|
24
|
+
const short = SHORT.exec(text);
|
|
25
|
+
if (short?.[1] !== void 0 && short[2] !== void 0) {
|
|
26
|
+
const unit = UNIT_MS[short[2]];
|
|
27
|
+
return unit === void 0 ? void 0 : Number(short[1]) * unit;
|
|
28
|
+
}
|
|
29
|
+
const iso = ISO.exec(text);
|
|
30
|
+
if (iso && text !== "P" && text !== "PT") {
|
|
31
|
+
const [, weeks, days, hours, minutes, seconds] = iso;
|
|
32
|
+
const parts = [weeks, days, hours, minutes, seconds];
|
|
33
|
+
if (parts.every((part) => part === void 0)) return void 0;
|
|
34
|
+
return Number(weeks ?? 0) * WEEK_MS + Number(days ?? 0) * DAY_MS + Number(hours ?? 0) * HOUR_MS + Number(minutes ?? 0) * MINUTE_MS + Number(seconds ?? 0) * SECOND_MS;
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { durationMs };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkGBQ33SIZ_cjs = require('./chunk-GBQ33SIZ.cjs');
|
|
4
|
+
var chunkSAENRNBJ_cjs = require('./chunk-SAENRNBJ.cjs');
|
|
5
5
|
|
|
6
6
|
// src/ir/diff.ts
|
|
7
7
|
function keyPath(base, key) {
|
|
8
8
|
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? base ? `${base}.${key}` : key : `${base}[${JSON.stringify(key)}]`;
|
|
9
9
|
}
|
|
10
10
|
function diffValues(before, after, path, out) {
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
11
|
+
if (chunkSAENRNBJ_cjs.deepEqual(before, after)) return;
|
|
12
|
+
if (chunkSAENRNBJ_cjs.isRecord(before) && chunkSAENRNBJ_cjs.isRecord(after)) {
|
|
13
13
|
const keys = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])].sort();
|
|
14
14
|
for (const key of keys) {
|
|
15
|
-
const left = before
|
|
16
|
-
const right = after
|
|
15
|
+
const left = chunkSAENRNBJ_cjs.ownValue(before, key);
|
|
16
|
+
const right = chunkSAENRNBJ_cjs.ownValue(after, key);
|
|
17
17
|
if (left === void 0 && right !== void 0)
|
|
18
18
|
out.push({ kind: "added", path: keyPath(path, key), after: right });
|
|
19
19
|
else if (left !== void 0 && right === void 0)
|
|
@@ -28,7 +28,7 @@ function byId(items) {
|
|
|
28
28
|
const map = /* @__PURE__ */ new Map();
|
|
29
29
|
if (!Array.isArray(items)) return map;
|
|
30
30
|
items.forEach((item, index) => {
|
|
31
|
-
if (!
|
|
31
|
+
if (!chunkSAENRNBJ_cjs.isRecord(item)) return;
|
|
32
32
|
const id = typeof item["id"] === "string" ? item["id"] : `#${index}`;
|
|
33
33
|
if (!map.has(id)) map.set(id, item);
|
|
34
34
|
});
|
|
@@ -48,23 +48,23 @@ function diffCollection(before, after, path, out) {
|
|
|
48
48
|
const common = (ids, other) => ids.filter((id) => other.has(id));
|
|
49
49
|
const leftOrder = common([...left.keys()], right);
|
|
50
50
|
const rightOrder = common([...right.keys()], left);
|
|
51
|
-
if (!
|
|
51
|
+
if (!chunkSAENRNBJ_cjs.deepEqual(leftOrder, rightOrder)) {
|
|
52
52
|
out.push({ kind: "reordered", path, before: leftOrder, after: rightOrder });
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
function diffDefinitions(before, after) {
|
|
56
|
-
const left =
|
|
57
|
-
const right =
|
|
56
|
+
const left = chunkGBQ33SIZ_cjs.hashedProjection(before);
|
|
57
|
+
const right = chunkGBQ33SIZ_cjs.hashedProjection(after);
|
|
58
58
|
const out = [];
|
|
59
|
-
if (!
|
|
59
|
+
if (!chunkSAENRNBJ_cjs.isRecord(left) || !chunkSAENRNBJ_cjs.isRecord(right)) {
|
|
60
60
|
diffValues(left, right, "", out);
|
|
61
61
|
return out;
|
|
62
62
|
}
|
|
63
63
|
const { data: leftData, ...leftRest } = left;
|
|
64
64
|
const { data: rightData, ...rightRest } = right;
|
|
65
65
|
diffValues(leftRest, rightRest, "", out);
|
|
66
|
-
const leftDataRecord =
|
|
67
|
-
const rightDataRecord =
|
|
66
|
+
const leftDataRecord = chunkSAENRNBJ_cjs.isRecord(leftData) ? leftData : {};
|
|
67
|
+
const rightDataRecord = chunkSAENRNBJ_cjs.isRecord(rightData) ? rightData : {};
|
|
68
68
|
const { nodes: leftNodes, edges: leftEdges, ...leftDataRest } = leftDataRecord;
|
|
69
69
|
const { nodes: rightNodes, edges: rightEdges, ...rightDataRest } = rightDataRecord;
|
|
70
70
|
diffCollection(leftNodes, rightNodes, "data.nodes", out);
|