@fluidgrids/workflows 2026.1029.1 → 2026.1030.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 +112 -4
- package/dist/{activation-CESehfYi.d.cts → activation-DqUfpHzk.d.cts} +1 -1
- package/dist/{activation-BnVQMv9y.d.ts → activation-xpx1oWuo.d.ts} +1 -1
- package/dist/{chunk-MJ5TGYVG.js → chunk-2D3MYIIF.js} +969 -153
- package/dist/{chunk-2B37XAFQ.cjs → chunk-3U2NU7YC.cjs} +24 -11
- package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
- package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
- package/dist/{chunk-2DDULZFM.js → chunk-5HIVIV53.js} +86 -75
- package/dist/chunk-5MFVJM76.js +1222 -0
- package/dist/{chunk-EWYADREB.cjs → chunk-672KMMBK.cjs} +2 -2
- package/dist/{chunk-KXJDRQ6G.js → chunk-6A2FGSUS.js} +22 -2
- package/dist/{chunk-OIX4O6UR.js → chunk-6OLN6BMB.js} +16 -3
- package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
- package/dist/chunk-A5SXCA62.cjs +93 -0
- package/dist/chunk-AC6ZEXVR.js +85 -0
- package/dist/{chunk-FWBRQWRX.js → chunk-AE5Q6ZAJ.js} +167 -10
- package/dist/{chunk-7ILGCUI6.js → chunk-C4F5KJTI.js} +142 -3
- package/dist/{chunk-WXXNCHUY.js → chunk-G5H32GIG.js} +1 -1
- package/dist/{chunk-OMY3CKUZ.cjs → chunk-GEQDGUGB.cjs} +1042 -226
- package/dist/{chunk-25BKWR2O.js → chunk-HCM7ZC7Q.js} +1 -1
- package/dist/{chunk-I47EENR4.cjs → chunk-HMZUGSMU.cjs} +673 -156
- package/dist/{chunk-NXFBVDOI.cjs → chunk-IQPXHQQQ.cjs} +8 -4
- package/dist/{chunk-RUQIMTN5.cjs → chunk-ISOIA7NV.cjs} +178 -15
- package/dist/chunk-JSC75O5C.cjs +167 -0
- package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
- package/dist/chunk-ODZ2IAR2.cjs +1247 -0
- package/dist/{chunk-FQSJI5NV.js → chunk-SR7TR5KX.js} +6 -2
- package/dist/{chunk-OKX3FYIM.cjs → chunk-TCTE7DX5.cjs} +3 -3
- package/dist/{chunk-3FIDHONL.cjs → chunk-TYF56RGB.cjs} +99 -80
- package/dist/{chunk-J3PYFGKA.cjs → chunk-VA4OFR72.cjs} +162 -4
- package/dist/chunk-VU5S5A7V.js +150 -0
- package/dist/{chunk-A36CCOWS.js → chunk-YEHR4NNE.js} +633 -128
- package/dist/{chunk-ELL2RBML.cjs → chunk-ZCGKGDCL.cjs} +23 -1
- package/dist/codegen/index.d.cts +2 -2
- package/dist/codegen/index.d.ts +2 -2
- package/dist/{collect-BTHjQaSp.d.ts → collect-6NIEufHd.d.ts} +20 -3
- package/dist/{collect-CSyOg5XC.d.cts → collect-CcTCKqx6.d.cts} +20 -3
- package/dist/{file-cgL9l9l8.d.cts → file-BxYpwjRQ.d.cts} +250 -15
- package/dist/{file-olQudcx5.d.ts → file-CFdPQJI9.d.ts} +250 -15
- package/dist/history/index.cjs +283 -106
- package/dist/history/index.d.cts +549 -10
- package/dist/history/index.d.ts +549 -10
- package/dist/history/index.js +5 -4
- package/dist/index.cjs +146 -53
- package/dist/index.d.cts +38 -14
- package/dist/index.d.ts +38 -14
- package/dist/index.js +6 -5
- package/dist/interceptors-CNcr2dlk.d.ts +159 -0
- package/dist/interceptors-CqkNZVfI.d.cts +159 -0
- package/dist/ir/index.cjs +339 -36
- package/dist/ir/index.d.cts +244 -8
- package/dist/ir/index.d.ts +244 -8
- package/dist/ir/index.js +306 -21
- package/dist/{lower-3S6PsqjJ.d.cts → lower-BtRfIW2A.d.cts} +23 -9
- package/dist/{lower-DmZpQ8hJ.d.ts → lower-CpsMFOFX.d.ts} +23 -9
- package/dist/{manifest-BJjrQt77.d.ts → manifest-D-I_twys.d.ts} +1 -1
- package/dist/{manifest-gRI2Q5Fj.d.cts → manifest-DahBQVM8.d.cts} +1 -1
- package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
- package/dist/node-evaluator-LEEVD7H7.js +14 -0
- package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
- package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
- package/dist/quickjs/index.cjs +27 -27
- package/dist/quickjs/index.d.cts +6 -6
- package/dist/quickjs/index.d.ts +6 -6
- package/dist/quickjs/index.js +9 -9
- package/dist/roundtrip/index.cjs +72 -66
- package/dist/roundtrip/index.d.cts +25 -11
- package/dist/roundtrip/index.d.ts +25 -11
- package/dist/roundtrip/index.js +13 -11
- package/dist/runtime/index.cjs +19 -19
- package/dist/runtime/index.d.cts +139 -12
- package/dist/runtime/index.d.ts +139 -12
- package/dist/runtime/index.js +6 -6
- package/dist/testing/index.cjs +688 -121
- package/dist/testing/index.d.cts +174 -10
- package/dist/testing/index.d.ts +174 -10
- package/dist/testing/index.js +646 -82
- package/dist/{types-CnIOinoz.d.ts → types-Bv2i4cBX.d.cts} +126 -23
- package/dist/{types-CQKOhPTa.d.cts → types-DGx-b9eq.d.ts} +126 -23
- package/dist/{types-Bb2wRnJ5.d.cts → types-V7jEEUaL.d.cts} +1 -1
- package/dist/{types-Bb2wRnJ5.d.ts → types-V7jEEUaL.d.ts} +1 -1
- package/dist/{workflow-8uRU9rhL.d.ts → workflow-B18OeF7g.d.ts} +2 -2
- package/dist/{workflow-DWTPHFbt.d.ts → workflow-BGnv8SS6.d.ts} +261 -14
- package/dist/{workflow-CZOXUlQ5.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
- package/dist/{workflow-O6e64ZcG.d.cts → workflow-DS32Gtws.d.cts} +261 -14
- package/fixtures/histories/activity-options-updated.history.json +159 -0
- package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
- package/fixtures/histories/codec-opaque.history.json +229 -0
- package/fixtures/histories/dynamic-workflow.history.json +150 -0
- package/fixtures/histories/interceptor-headers.history.json +339 -0
- package/fixtures/histories/query-custom.history.json +213 -0
- package/fixtures/histories/query-default-handler.history.json +120 -0
- package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
- package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -0
- package/fixtures/histories/search-attributes-upserted.history.json +177 -0
- package/fixtures/histories/update-accepted-completed.history.json +45 -30
- package/fixtures/histories/update-default-handler.history.json +246 -0
- package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
- package/fixtures/histories/update-not-handled.history.json +138 -0
- package/fixtures/histories/update-rejected-no-event.history.json +190 -0
- package/fixtures/histories/update-with-start-admitted.history.json +150 -0
- package/fixtures/histories/user-activity-cancel.history.json +149 -0
- package/fixtures/histories/user-activity-retry.history.json +143 -0
- package/fixtures/histories/user-activity.history.json +149 -0
- package/package.json +1 -1
- package/schema/bridge-v2.schema.json +1062 -0
- package/schema/history-file.schema.json +255 -81
- package/schema/ir-v2.schema.json +246 -1
- package/schema/payload-fields.json +162 -0
- package/schema/run-event.schema.json +239 -80
- package/schema/workflow-command.schema.json +210 -84
- package/schema/workflow-task.schema.json +532 -167
- package/dist/chunk-6QPOJZT6.cjs +0 -1180
- package/dist/chunk-A2OHX3UQ.js +0 -1156
- package/dist/chunk-PWIUEWC3.js +0 -81
- package/dist/chunk-YHBVMOMK.cjs +0 -87
- package/dist/node-evaluator-SOADN23V.js +0 -14
- package/dist/node-evaluator-YGDEXK4U.cjs +0 -24
package/dist/quickjs/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { runIsolateWorker, outcomeToCollection, LowerError } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import { failedTaskResult } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import { buildIdOf } from '../chunk-
|
|
1
|
+
import { runIsolateWorker, outcomeToCollection, LowerError } from '../chunk-5MFVJM76.js';
|
|
2
|
+
import '../chunk-6OLN6BMB.js';
|
|
3
|
+
import { failedTaskResult } from '../chunk-G5H32GIG.js';
|
|
4
|
+
import '../chunk-SR7TR5KX.js';
|
|
5
|
+
import { buildIdOf } from '../chunk-NWQ5WRLE.js';
|
|
6
6
|
import '../chunk-5LUIDMF4.js';
|
|
7
7
|
import '../chunk-JZ4TOOLN.js';
|
|
8
8
|
import '../chunk-E2VK7J2C.js';
|
|
9
9
|
import '../chunk-7AAZGVKD.js';
|
|
10
10
|
import { isRecord } from '../chunk-PMCM2OH4.js';
|
|
11
11
|
import '../chunk-4LYSEANA.js';
|
|
12
|
-
import '../chunk-
|
|
12
|
+
import '../chunk-C4F5KJTI.js';
|
|
13
13
|
import '../chunk-LNUQE6D6.js';
|
|
14
|
-
import '../chunk-
|
|
15
|
-
import '../chunk-
|
|
14
|
+
import '../chunk-AC6ZEXVR.js';
|
|
15
|
+
import '../chunk-5HIVIV53.js';
|
|
16
16
|
import { createRequire } from 'module';
|
|
17
17
|
import { pathToFileURL } from 'url';
|
|
18
18
|
import { Worker } from 'worker_threads';
|
|
@@ -21,7 +21,7 @@ import { Worker } from 'worker_threads';
|
|
|
21
21
|
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';
|
|
22
22
|
|
|
23
23
|
// src/generated/quickjs-task-worker-source.ts
|
|
24
|
-
var QUICKJS_TASK_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\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;\n\nvar HISTORY_PROTOCOL = 1;\nvar DEFAULT_HISTORY_LIMIT = { events: 1e4, bytes: 16 * 1024 * 1024 };\n\nvar SHIM_VIOLATION = "DeterminismViolation";\nvar SHIM_HOOK = "__fluidgridsShims";\nvar TASK_PRELUDE = `(() => {\n const NAME = ${JSON.stringify(SHIM_VIOLATION)};\n const fail = (what) => {\n const error = new Error(what + " is not allowed in workflow code: use ctx.now(), ctx.random(), ctx.sleep() or an activity.");\n error.name = NAME;\n throw error;\n };\n let hooks = null;\n const now = (what) => (hooks !== null ? hooks.now() : fail(what + " outside a workflow task"));\n const lock = (target, key, value) =>\n Object.defineProperty(target, key, { value, writable: false, enumerable: false, configurable: false });\n const RealDate = Date;\n // ---- Built-ins that differ between hosts and engines --------------------\n // Local time is UTC whatever the host\'s TZ, locale formatting is fixed\n // (en-US shapes, no ICU), Intl is absent and garbage collection cannot be\n // observed, so QuickJS and vm on any host run workflow code the same way.\n const proto = RealDate.prototype;\n const hostOffset = proto.getTimezoneOffset;\n const realParse = RealDate.parse;\n const isInvalid = (date) => Number.isNaN(proto.getTime.call(date));\n for (const unit of ["FullYear", "Month", "Date", "Day", "Hours", "Minutes", "Seconds", "Milliseconds"]) {\n lock(proto, "get" + unit, proto["getUTC" + unit]);\n if (unit !== "Day") lock(proto, "set" + unit, proto["setUTC" + unit]);\n }\n lock(proto, "getTimezoneOffset", function getTimezoneOffset() { return isInvalid(this) ? NaN : 0; });\n if (typeof proto.getYear === "function")\n lock(proto, "getYear", function getYear() { return isInvalid(this) ? NaN : this.getUTCFullYear() - 1900; });\n if (typeof proto.setYear === "function")\n lock(proto, "setYear", function setYear(value) {\n const year = Number(value);\n if (Number.isNaN(year)) return this.setTime(NaN);\n const whole = Math.trunc(year);\n const base = new RealDate(isInvalid(this) ? 0 : this.getTime());\n base.setUTCFullYear(whole >= 0 && whole <= 99 ? 1900 + whole : whole);\n return this.setTime(base.getTime());\n });\n const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];\n const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];\n const pad = (value, width) => String(value).padStart(width, "0");\n const yearText = (year) => (year < 0 ? "-" + pad(-year, 6) : pad(year, 4));\n const dateText = (d) =>\n DAYS[d.getUTCDay()] + " " + MONTHS[d.getUTCMonth()] + " " + pad(d.getUTCDate(), 2) + " " + yearText(d.getUTCFullYear());\n const timeText = (d) =>\n pad(d.getUTCHours(), 2) + ":" + pad(d.getUTCMinutes(), 2) + ":" + pad(d.getUTCSeconds(), 2) + " GMT+0000 (Coordinated Universal Time)";\n const localeDate = (d) => d.getUTCMonth() + 1 + "/" + d.getUTCDate() + "/" + d.getUTCFullYear();\n const localeTime = (d) => {\n const hours = d.getUTCHours();\n return ((hours + 11) % 12) + 1 + ":" + pad(d.getUTCMinutes(), 2) + ":" + pad(d.getUTCSeconds(), 2) + (hours < 12 ? " AM" : " PM");\n };\n const formatter = (format) => function () { return isInvalid(this) ? "Invalid Date" : format(this); };\n lock(proto, "toString", formatter((d) => dateText(d) + " " + timeText(d)));\n lock(proto, "toDateString", formatter(dateText));\n lock(proto, "toTimeString", formatter(timeText));\n lock(proto, "toLocaleString", formatter((d) => localeDate(d) + ", " + localeTime(d)));\n lock(proto, "toLocaleDateString", formatter(localeDate));\n lock(proto, "toLocaleTimeString", formatter(localeTime));\n // A date-time without an offset is local time to the host\'s parser; read it as UTC.\n const DATE_ONLY = /^[+-]?\\\\d{4,6}(?:-\\\\d{2}(?:-\\\\d{2})?)?$/;\n 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;\n const NAMED_ZONE = /\\\\b(?:GMT|UTC|UT)\\\\b(?:\\\\s*[+-]\\\\d{2}:?\\\\d{2})?\\\\s*(?:\\\\([^)]*\\\\))?\\\\s*$/i;\n const parse = function parse(value) {\n const text = String(value);\n const time = realParse(text);\n if (Number.isNaN(time)) return time;\n const trimmed = text.trim();\n if (DATE_ONLY.test(trimmed) || ZONE_AFTER_TIME.test(trimmed) || NAMED_ZONE.test(trimmed)) return time;\n return time - hostOffset.call(new RealDate(time)) * 60000;\n };\n const toTimeValue = (value) => {\n if (value instanceof RealDate) return value.getTime();\n let primitive = value;\n if (typeof value === "object" && value !== null) {\n primitive = value.valueOf();\n if (typeof primitive === "object" && primitive !== null) primitive = String(value);\n }\n return typeof primitive === "string" ? parse(primitive) : primitive;\n };\n // ---- Number, string and array locale methods ----------------------------\n const group = (digits) => digits.replace(/\\\\B(?=(\\\\d{3})+(?!\\\\d))/g, ",");\n lock(Number.prototype, "toLocaleString", function toLocaleString() {\n const x = Number.prototype.valueOf.call(this);\n if (Number.isNaN(x)) return "NaN";\n const sign = x < 0 || Object.is(x, -0) ? "-" : "";\n const abs = Math.abs(x);\n if (abs === Infinity) return sign + "\\\\u221e";\n const fixed = abs < 1e21 ? abs.toFixed(3) : BigInt(abs).toString() + ".000";\n const [whole, fraction] = fixed.split(".");\n const kept = fraction.replace(/0+$/, "");\n return sign + group(whole) + (kept === "" ? "" : "." + kept);\n });\n if (typeof BigInt === "function")\n lock(BigInt.prototype, "toLocaleString", function toLocaleString() {\n const text = BigInt.prototype.toString.call(this);\n return text.startsWith("-") ? "-" + group(text.slice(1)) : group(text);\n });\n lock(String.prototype, "localeCompare", function localeCompare(that) {\n const a = String(this);\n const b = String(that);\n return a < b ? -1 : a > b ? 1 : 0;\n });\n lock(String.prototype, "toLocaleUpperCase", function toLocaleUpperCase() { return String(this).toUpperCase(); });\n lock(String.prototype, "toLocaleLowerCase", function toLocaleLowerCase() { return String(this).toLowerCase(); });\n const listLocale = function toLocaleString() {\n return Array.prototype.map.call(this, (item) => (item === null || item === undefined ? "" : item.toLocaleString())).join(",");\n };\n lock(Array.prototype, "toLocaleString", listLocale);\n lock(Object.getPrototypeOf(Uint8Array.prototype), "toLocaleString", listLocale);\n // ---- Absent or refused ---------------------------------------------------\n if (!Reflect.deleteProperty(globalThis, "Intl")) lock(globalThis, "Intl", undefined);\n for (const name of ["WeakRef", "FinalizationRegistry"]) {\n lock(globalThis, name, function () { return fail(name + " (garbage collection is not deterministic)"); });\n }\n const LockedDate = function Date(...args) {\n if (new.target === undefined) return new RealDate(now("Date()")).toString();\n if (args.length === 0) return Reflect.construct(RealDate, [now("new Date()")], new.target);\n if (args.length === 1) return Reflect.construct(RealDate, [toTimeValue(args[0])], new.target);\n return Reflect.construct(RealDate, [RealDate.UTC(...args)], new.target);\n };\n lock(LockedDate, "prototype", RealDate.prototype);\n lock(RealDate.prototype, "constructor", LockedDate);\n lock(LockedDate, "now", function now_() { return now("Date.now()"); });\n lock(LockedDate, "parse", parse);\n lock(LockedDate, "UTC", RealDate.UTC);\n lock(globalThis, "Date", LockedDate);\n lock(Math, "random", function random() {\n return hooks !== null ? hooks.random() : fail("Math.random() outside a workflow task");\n });\n const crypto = globalThis.crypto;\n if (crypto !== null && typeof crypto === "object") {\n if (typeof crypto.getRandomValues === "function")\n lock(crypto, "getRandomValues", function getRandomValues(array) {\n if (hooks === null) return fail("crypto.getRandomValues() outside a workflow task");\n for (let i = 0; i < array.length; i++) array[i] = Math.floor(hooks.random() * 256);\n return array;\n });\n if (typeof crypto.randomUUID === "function")\n lock(crypto, "randomUUID", function randomUUID() { return fail("crypto.randomUUID(): use ctx.uuid()"); });\n }\n for (const name of ["setTimeout", "setInterval", "setImmediate", "clearTimeout", "clearInterval", "clearImmediate"]) {\n lock(globalThis, name, function () { return fail(name + "(): use ctx.sleep()"); });\n }\n for (const name of ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"]) {\n lock(globalThis, name, function () { return fail(name + ": do I/O in an activity (ctx.run)"); });\n }\n Object.defineProperty(globalThis, ${JSON.stringify(SHIM_HOOK)}, {\n value: Object.freeze({\n attach(next) { hooks = next; },\n detach() { hooks = null; },\n }),\n writable: false,\n enumerable: false,\n configurable: true,\n });\n})();\n`;\n\nvar WASM_PAGE_BYTES2 = 64 * 1024;\nvar HOST_STACK_OVERFLOW = /maximum call stack size exceeded|too much recursion/i;\nvar ENGINE_HEADROOM_BYTES2 = 32 * 1024 * 1024;\nvar INITIAL_ENGINE_BYTES2 = 16 * 1024 * 1024;\nasync function createTaskModule(api, memoryLimitBytes) {\n const maximum = Math.ceil((memoryLimitBytes + ENGINE_HEADROOM_BYTES2) / WASM_PAGE_BYTES2);\n const initial = Math.min(maximum, INITIAL_ENGINE_BYTES2 / WASM_PAGE_BYTES2);\n return api.newQuickJSWASMModuleFromVariant(\n api.newVariant(api.RELEASE_SYNC, { wasmMemory: new WebAssembly.Memory({ initial, maximum }) })\n );\n}\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 = typeof dumped["message"] === "string" ? dumped["message"] : JSON.stringify(dumped);\n return { name, message };\n }\n return { name: "Error", message: String(dumped) };\n}\nvar TaskError = class extends Error {\n constructor(cause, message, fatal = false) {\n super(message);\n this.cause = cause;\n this.fatal = fatal;\n }\n cause;\n fatal;\n};\nfunction runTaskInQuickJS(api, module2, code, requestJson, limits) {\n const disposed = { failed: false };\n const outcome = runTask(api, module2, code, requestJson, limits, disposed);\n return disposed.failed && outcome.fatal !== true ? { ...outcome, fatal: true } : outcome;\n}\nfunction runTask(api, module2, code, requestJson, limits, disposed) {\n let runtime;\n let ctx;\n const handles = [];\n const deadline = Date.now() + limits.timeoutMs;\n try {\n runtime = module2.newRuntime();\n runtime.setMemoryLimit(limits.memoryLimitBytes);\n runtime.setMaxStackSize(limits.maxStackSizeBytes);\n runtime.setInterruptHandler(api.shouldInterruptAfterDeadline(deadline));\n const rt = runtime;\n const context = rt.newContext();\n ctx = context;\n const fail = (handle, during) => {\n const { name, message } = describe(context, handle);\n handle.dispose();\n if (Date.now() > deadline && /interrupted/i.test(message))\n throw new TaskError(\n "TASK_TIMEOUT",\n `The workflow task ran past its ${limits.timeoutMs} ms budget`\n );\n if (/out of memory/i.test(message) || name === "InternalError" && /memory/i.test(message))\n throw new TaskError("ISOLATE_MEMORY", `The workflow task ran out of memory ${during}`);\n if (name === "DeterminismViolation") throw new TaskError("NON_DETERMINISM", message);\n throw new TaskError("WORKFLOW_CODE_ERROR", `${name}: ${message} (${during})`);\n };\n const drain = (during) => {\n while (rt.hasPendingJob()) {\n if (Date.now() > deadline)\n throw new TaskError(\n "TASK_TIMEOUT",\n `The workflow task ran past its ${limits.timeoutMs} ms budget`\n );\n const jobs = rt.executePendingJobs();\n if (jobs.error) fail(jobs.error, during);\n }\n };\n const prelude = context.evalCode(TASK_PRELUDE, "fluidgrids-task-prelude.js", {\n type: "global"\n });\n if (prelude.error) fail(prelude.error, "in the task prelude");\n else prelude.value.dispose();\n const evaluated = context.evalCode(code, "workflow-bundle.mjs", { type: "module" });\n if (evaluated.error) fail(evaluated.error, "while loading the bundle");\n else {\n handles.push(evaluated.value);\n drain("while loading the bundle");\n const state = context.getPromiseState(evaluated.value);\n if (state.type === "rejected") fail(state.error, "while loading the bundle");\n else if (state.type === "fulfilled" && state.notAPromise !== true) state.value.dispose();\n }\n const abi = context.getProp(context.global, "__fluidgridsRuntime");\n handles.push(abi);\n if (context.typeof(abi) !== "object")\n throw new TaskError(\n "INVALID_REQUEST",\n "The bundle has no workflow runtime (build it with @fluidgrids/workflows 2026.1028 or later)"\n );\n const protocol = context.getProp(abi, "protocol");\n const protocolValue = context.dump(protocol);\n protocol.dispose();\n if (protocolValue !== HISTORY_PROTOCOL)\n throw new TaskError(\n "PROTOCOL_MISMATCH",\n `The bundle speaks runtime protocol ${String(protocolValue)}; this host speaks ${HISTORY_PROTOCOL}`\n );\n const call = (name, args) => {\n const fn = context.getProp(abi, name);\n try {\n const result = context.callFunction(fn, abi, ...args);\n if (result.error) return fail(result.error, `in ${name}()`);\n return result.value;\n } finally {\n fn.dispose();\n }\n };\n const request = context.newString(requestJson);\n handles.push(request);\n call("start", [request]).dispose();\n drain("in the workflow code");\n for (; ; ) {\n const step = call("step", []);\n const value = context.dump(step);\n step.dispose();\n drain("in the workflow code");\n if (value !== "more") break;\n }\n const completed = call("complete", []);\n const resultValue = context.dump(completed);\n completed.dispose();\n if (typeof resultValue !== "string")\n throw new TaskError("INTERNAL", "The runtime returned no result");\n return { ok: true, resultJson: resultValue };\n } catch (error) {\n if (error instanceof TaskError)\n return {\n ok: false,\n cause: error.cause,\n message: error.message,\n ...error.fatal ? { fatal: true } : {}\n };\n const message = error instanceof Error ? error.message : String(error);\n if (HOST_STACK_OVERFLOW.test(message))\n return {\n ok: false,\n cause: "WORKFLOW_CODE_ERROR",\n message: `RangeError: stack overflow (the engine\'s host stack ran out: ${message})`,\n fatal: true\n };\n return {\n ok: false,\n cause: /memory|out of bounds|abort/i.test(message) ? "ISOLATE_MEMORY" : "INTERNAL",\n message,\n fatal: true\n };\n } finally {\n for (const handle of handles.reverse()) if (handle.alive) handle.dispose();\n try {\n ctx?.dispose();\n runtime?.dispose();\n } catch {\n disposed.failed = true;\n }\n }\n}\n\nprocess.on("unhandledRejection", () => void 0);\nasync function main(input) {\n const port = import_node_worker_threads.parentPort;\n if (!port) return;\n if (!isRecord(input) || typeof input["moduleUrl"] !== "string" || typeof input["memoryLimitBytes"] !== "number") {\n port.postMessage({ type: "fatal", message: "The task worker received no configuration" });\n return;\n }\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) {\n port.postMessage({ type: "fatal", message: "quickjs-emscripten could not be loaded" });\n return;\n }\n const module2 = await createTaskModule(api, input["memoryLimitBytes"]);\n port.on("message", (message) => {\n if (!isRecord(message) || message["type"] !== "task") return;\n const id = message["id"];\n const limits = message["limits"];\n let outcome;\n if (typeof message["code"] !== "string" || typeof message["requestJson"] !== "string" || !isRecord(limits) || typeof limits["timeoutMs"] !== "number" || typeof limits["memoryLimitBytes"] !== "number" || typeof limits["maxStackSizeBytes"] !== "number")\n outcome = {\n ok: false,\n cause: "INTERNAL",\n message: "The task worker received a malformed task"\n };\n else\n outcome = runTaskInQuickJS(api, module2, message["code"], message["requestJson"], {\n timeoutMs: limits["timeoutMs"],\n memoryLimitBytes: limits["memoryLimitBytes"],\n maxStackSizeBytes: limits["maxStackSizeBytes"]\n });\n port.postMessage({ type: "result", id, outcome });\n if (outcome.fatal === true) process.exit(1);\n });\n port.postMessage({ type: "ready" });\n}\nmain(import_node_worker_threads.workerData).catch((error) => {\n import_node_worker_threads.parentPort?.postMessage({\n type: "fatal",\n message: error instanceof Error ? error.message : String(error)\n });\n});\n';
|
|
24
|
+
var QUICKJS_TASK_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\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;\n\nvar HISTORY_PROTOCOL = 1;\nvar MAX_HEADERS_BYTES = 16 * 1024;\nvar DEFAULT_HISTORY_LIMIT = { events: 1e4, bytes: 16 * 1024 * 1024 };\n\nvar SHIM_VIOLATION = "DeterminismViolation";\nvar SHIM_HOOK = "__fluidgridsShims";\nvar TASK_PRELUDE = `(() => {\n const NAME = ${JSON.stringify(SHIM_VIOLATION)};\n const fail = (what) => {\n const error = new Error(what + " is not allowed in workflow code: use ctx.now(), ctx.random(), ctx.sleep() or an activity.");\n error.name = NAME;\n throw error;\n };\n let hooks = null;\n const now = (what) => (hooks !== null ? hooks.now() : fail(what + " outside a workflow task"));\n const lock = (target, key, value) =>\n Object.defineProperty(target, key, { value, writable: false, enumerable: false, configurable: false });\n const RealDate = Date;\n // ---- Built-ins that differ between hosts and engines --------------------\n // Local time is UTC whatever the host\'s TZ, locale formatting is fixed\n // (en-US shapes, no ICU), Intl is absent and garbage collection cannot be\n // observed, so QuickJS and vm on any host run workflow code the same way.\n const proto = RealDate.prototype;\n const hostOffset = proto.getTimezoneOffset;\n const realParse = RealDate.parse;\n const isInvalid = (date) => Number.isNaN(proto.getTime.call(date));\n for (const unit of ["FullYear", "Month", "Date", "Day", "Hours", "Minutes", "Seconds", "Milliseconds"]) {\n lock(proto, "get" + unit, proto["getUTC" + unit]);\n if (unit !== "Day") lock(proto, "set" + unit, proto["setUTC" + unit]);\n }\n lock(proto, "getTimezoneOffset", function getTimezoneOffset() { return isInvalid(this) ? NaN : 0; });\n if (typeof proto.getYear === "function")\n lock(proto, "getYear", function getYear() { return isInvalid(this) ? NaN : this.getUTCFullYear() - 1900; });\n if (typeof proto.setYear === "function")\n lock(proto, "setYear", function setYear(value) {\n const year = Number(value);\n if (Number.isNaN(year)) return this.setTime(NaN);\n const whole = Math.trunc(year);\n const base = new RealDate(isInvalid(this) ? 0 : this.getTime());\n base.setUTCFullYear(whole >= 0 && whole <= 99 ? 1900 + whole : whole);\n return this.setTime(base.getTime());\n });\n const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];\n const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];\n const pad = (value, width) => String(value).padStart(width, "0");\n const yearText = (year) => (year < 0 ? "-" + pad(-year, 6) : pad(year, 4));\n const dateText = (d) =>\n DAYS[d.getUTCDay()] + " " + MONTHS[d.getUTCMonth()] + " " + pad(d.getUTCDate(), 2) + " " + yearText(d.getUTCFullYear());\n const timeText = (d) =>\n pad(d.getUTCHours(), 2) + ":" + pad(d.getUTCMinutes(), 2) + ":" + pad(d.getUTCSeconds(), 2) + " GMT+0000 (Coordinated Universal Time)";\n const localeDate = (d) => d.getUTCMonth() + 1 + "/" + d.getUTCDate() + "/" + d.getUTCFullYear();\n const localeTime = (d) => {\n const hours = d.getUTCHours();\n return ((hours + 11) % 12) + 1 + ":" + pad(d.getUTCMinutes(), 2) + ":" + pad(d.getUTCSeconds(), 2) + (hours < 12 ? " AM" : " PM");\n };\n const formatter = (format) => function () { return isInvalid(this) ? "Invalid Date" : format(this); };\n lock(proto, "toString", formatter((d) => dateText(d) + " " + timeText(d)));\n lock(proto, "toDateString", formatter(dateText));\n lock(proto, "toTimeString", formatter(timeText));\n lock(proto, "toLocaleString", formatter((d) => localeDate(d) + ", " + localeTime(d)));\n lock(proto, "toLocaleDateString", formatter(localeDate));\n lock(proto, "toLocaleTimeString", formatter(localeTime));\n // A date-time without an offset is local time to the host\'s parser; read it as UTC.\n const DATE_ONLY = /^[+-]?\\\\d{4,6}(?:-\\\\d{2}(?:-\\\\d{2})?)?$/;\n 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;\n const NAMED_ZONE = /\\\\b(?:GMT|UTC|UT)\\\\b(?:\\\\s*[+-]\\\\d{2}:?\\\\d{2})?\\\\s*(?:\\\\([^)]*\\\\))?\\\\s*$/i;\n const parse = function parse(value) {\n const text = String(value);\n const time = realParse(text);\n if (Number.isNaN(time)) return time;\n const trimmed = text.trim();\n if (DATE_ONLY.test(trimmed) || ZONE_AFTER_TIME.test(trimmed) || NAMED_ZONE.test(trimmed)) return time;\n return time - hostOffset.call(new RealDate(time)) * 60000;\n };\n const toTimeValue = (value) => {\n if (value instanceof RealDate) return value.getTime();\n let primitive = value;\n if (typeof value === "object" && value !== null) {\n primitive = value.valueOf();\n if (typeof primitive === "object" && primitive !== null) primitive = String(value);\n }\n return typeof primitive === "string" ? parse(primitive) : primitive;\n };\n // ---- Number, string and array locale methods ----------------------------\n const group = (digits) => digits.replace(/\\\\B(?=(\\\\d{3})+(?!\\\\d))/g, ",");\n lock(Number.prototype, "toLocaleString", function toLocaleString() {\n const x = Number.prototype.valueOf.call(this);\n if (Number.isNaN(x)) return "NaN";\n const sign = x < 0 || Object.is(x, -0) ? "-" : "";\n const abs = Math.abs(x);\n if (abs === Infinity) return sign + "\\\\u221e";\n const fixed = abs < 1e21 ? abs.toFixed(3) : BigInt(abs).toString() + ".000";\n const [whole, fraction] = fixed.split(".");\n const kept = fraction.replace(/0+$/, "");\n return sign + group(whole) + (kept === "" ? "" : "." + kept);\n });\n if (typeof BigInt === "function")\n lock(BigInt.prototype, "toLocaleString", function toLocaleString() {\n const text = BigInt.prototype.toString.call(this);\n return text.startsWith("-") ? "-" + group(text.slice(1)) : group(text);\n });\n lock(String.prototype, "localeCompare", function localeCompare(that) {\n const a = String(this);\n const b = String(that);\n return a < b ? -1 : a > b ? 1 : 0;\n });\n lock(String.prototype, "toLocaleUpperCase", function toLocaleUpperCase() { return String(this).toUpperCase(); });\n lock(String.prototype, "toLocaleLowerCase", function toLocaleLowerCase() { return String(this).toLowerCase(); });\n const listLocale = function toLocaleString() {\n return Array.prototype.map.call(this, (item) => (item === null || item === undefined ? "" : item.toLocaleString())).join(",");\n };\n lock(Array.prototype, "toLocaleString", listLocale);\n lock(Object.getPrototypeOf(Uint8Array.prototype), "toLocaleString", listLocale);\n // ---- Absent or refused ---------------------------------------------------\n if (!Reflect.deleteProperty(globalThis, "Intl")) lock(globalThis, "Intl", undefined);\n for (const name of ["WeakRef", "FinalizationRegistry"]) {\n lock(globalThis, name, function () { return fail(name + " (garbage collection is not deterministic)"); });\n }\n const LockedDate = function Date(...args) {\n if (new.target === undefined) return new RealDate(now("Date()")).toString();\n if (args.length === 0) return Reflect.construct(RealDate, [now("new Date()")], new.target);\n if (args.length === 1) return Reflect.construct(RealDate, [toTimeValue(args[0])], new.target);\n return Reflect.construct(RealDate, [RealDate.UTC(...args)], new.target);\n };\n lock(LockedDate, "prototype", RealDate.prototype);\n lock(RealDate.prototype, "constructor", LockedDate);\n lock(LockedDate, "now", function now_() { return now("Date.now()"); });\n lock(LockedDate, "parse", parse);\n lock(LockedDate, "UTC", RealDate.UTC);\n lock(globalThis, "Date", LockedDate);\n lock(Math, "random", function random() {\n return hooks !== null ? hooks.random() : fail("Math.random() outside a workflow task");\n });\n const crypto = globalThis.crypto;\n if (crypto !== null && typeof crypto === "object") {\n if (typeof crypto.getRandomValues === "function")\n lock(crypto, "getRandomValues", function getRandomValues(array) {\n if (hooks === null) return fail("crypto.getRandomValues() outside a workflow task");\n for (let i = 0; i < array.length; i++) array[i] = Math.floor(hooks.random() * 256);\n return array;\n });\n if (typeof crypto.randomUUID === "function")\n lock(crypto, "randomUUID", function randomUUID() { return fail("crypto.randomUUID(): use ctx.uuid()"); });\n }\n for (const name of ["setTimeout", "setInterval", "setImmediate", "clearTimeout", "clearInterval", "clearImmediate"]) {\n lock(globalThis, name, function () { return fail(name + "(): use ctx.sleep()"); });\n }\n for (const name of ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"]) {\n lock(globalThis, name, function () { return fail(name + ": do I/O in an activity (ctx.run)"); });\n }\n Object.defineProperty(globalThis, ${JSON.stringify(SHIM_HOOK)}, {\n value: Object.freeze({\n attach(next) { hooks = next; },\n detach() { hooks = null; },\n }),\n writable: false,\n enumerable: false,\n configurable: true,\n });\n})();\n`;\n\nvar WASM_PAGE_BYTES2 = 64 * 1024;\nvar HOST_STACK_OVERFLOW = /maximum call stack size exceeded|too much recursion/i;\nvar ENGINE_HEADROOM_BYTES2 = 32 * 1024 * 1024;\nvar INITIAL_ENGINE_BYTES2 = 16 * 1024 * 1024;\nasync function createTaskModule(api, memoryLimitBytes) {\n const maximum = Math.ceil((memoryLimitBytes + ENGINE_HEADROOM_BYTES2) / WASM_PAGE_BYTES2);\n const initial = Math.min(maximum, INITIAL_ENGINE_BYTES2 / WASM_PAGE_BYTES2);\n return api.newQuickJSWASMModuleFromVariant(\n api.newVariant(api.RELEASE_SYNC, { wasmMemory: new WebAssembly.Memory({ initial, maximum }) })\n );\n}\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 = typeof dumped["message"] === "string" ? dumped["message"] : JSON.stringify(dumped);\n return { name, message };\n }\n return { name: "Error", message: String(dumped) };\n}\nvar TaskError = class extends Error {\n constructor(cause, message, fatal = false) {\n super(message);\n this.cause = cause;\n this.fatal = fatal;\n }\n cause;\n fatal;\n};\nfunction runTaskInQuickJS(api, module2, code, requestJson, limits) {\n const disposed = { failed: false };\n const outcome = runTask(api, module2, code, requestJson, limits, disposed);\n return disposed.failed && outcome.fatal !== true ? { ...outcome, fatal: true } : outcome;\n}\nfunction runTask(api, module2, code, requestJson, limits, disposed) {\n let runtime;\n let ctx;\n const handles = [];\n const deadline = Date.now() + limits.timeoutMs;\n try {\n runtime = module2.newRuntime();\n runtime.setMemoryLimit(limits.memoryLimitBytes);\n runtime.setMaxStackSize(limits.maxStackSizeBytes);\n runtime.setInterruptHandler(api.shouldInterruptAfterDeadline(deadline));\n const rt = runtime;\n const context = rt.newContext();\n ctx = context;\n const fail = (handle, during) => {\n const { name, message } = describe(context, handle);\n handle.dispose();\n if (Date.now() > deadline && /interrupted/i.test(message))\n throw new TaskError(\n "TASK_TIMEOUT",\n `The workflow task ran past its ${limits.timeoutMs} ms budget`\n );\n if (/out of memory/i.test(message) || name === "InternalError" && /memory/i.test(message))\n throw new TaskError("ISOLATE_MEMORY", `The workflow task ran out of memory ${during}`);\n if (name === "DeterminismViolation") throw new TaskError("NON_DETERMINISM", message);\n throw new TaskError("WORKFLOW_CODE_ERROR", `${name}: ${message} (${during})`);\n };\n const drain = (during) => {\n while (rt.hasPendingJob()) {\n if (Date.now() > deadline)\n throw new TaskError(\n "TASK_TIMEOUT",\n `The workflow task ran past its ${limits.timeoutMs} ms budget`\n );\n const jobs = rt.executePendingJobs();\n if (jobs.error) fail(jobs.error, during);\n }\n };\n const prelude = context.evalCode(TASK_PRELUDE, "fluidgrids-task-prelude.js", {\n type: "global"\n });\n if (prelude.error) fail(prelude.error, "in the task prelude");\n else prelude.value.dispose();\n const evaluated = context.evalCode(code, "workflow-bundle.mjs", { type: "module" });\n if (evaluated.error) fail(evaluated.error, "while loading the bundle");\n else {\n handles.push(evaluated.value);\n drain("while loading the bundle");\n const state = context.getPromiseState(evaluated.value);\n if (state.type === "rejected") fail(state.error, "while loading the bundle");\n else if (state.type === "fulfilled" && state.notAPromise !== true) state.value.dispose();\n }\n const abi = context.getProp(context.global, "__fluidgridsRuntime");\n handles.push(abi);\n if (context.typeof(abi) !== "object")\n throw new TaskError(\n "INVALID_REQUEST",\n "The bundle has no workflow runtime (build it with @fluidgrids/workflows 2026.1028 or later)"\n );\n const protocol = context.getProp(abi, "protocol");\n const protocolValue = context.dump(protocol);\n protocol.dispose();\n if (protocolValue !== HISTORY_PROTOCOL)\n throw new TaskError(\n "PROTOCOL_MISMATCH",\n `The bundle speaks runtime protocol ${String(protocolValue)}; this host speaks ${HISTORY_PROTOCOL}`\n );\n const call = (name, args) => {\n const fn = context.getProp(abi, name);\n try {\n const result = context.callFunction(fn, abi, ...args);\n if (result.error) return fail(result.error, `in ${name}()`);\n return result.value;\n } finally {\n fn.dispose();\n }\n };\n const request = context.newString(requestJson);\n handles.push(request);\n call("start", [request]).dispose();\n drain("in the workflow code");\n for (; ; ) {\n const step = call("step", []);\n const value = context.dump(step);\n step.dispose();\n drain("in the workflow code");\n if (value !== "more") break;\n }\n const completed = call("complete", []);\n const resultValue = context.dump(completed);\n completed.dispose();\n if (typeof resultValue !== "string")\n throw new TaskError("INTERNAL", "The runtime returned no result");\n return { ok: true, resultJson: resultValue };\n } catch (error) {\n if (error instanceof TaskError)\n return {\n ok: false,\n cause: error.cause,\n message: error.message,\n ...error.fatal ? { fatal: true } : {}\n };\n const message = error instanceof Error ? error.message : String(error);\n if (HOST_STACK_OVERFLOW.test(message))\n return {\n ok: false,\n cause: "WORKFLOW_CODE_ERROR",\n message: `RangeError: stack overflow (the engine\'s host stack ran out: ${message})`,\n fatal: true\n };\n return {\n ok: false,\n cause: /memory|out of bounds|abort/i.test(message) ? "ISOLATE_MEMORY" : "INTERNAL",\n message,\n fatal: true\n };\n } finally {\n for (const handle of handles.reverse()) if (handle.alive) handle.dispose();\n try {\n ctx?.dispose();\n runtime?.dispose();\n } catch {\n disposed.failed = true;\n }\n }\n}\n\nprocess.on("unhandledRejection", () => void 0);\nasync function main(input) {\n const port = import_node_worker_threads.parentPort;\n if (!port) return;\n if (!isRecord(input) || typeof input["moduleUrl"] !== "string" || typeof input["memoryLimitBytes"] !== "number") {\n port.postMessage({ type: "fatal", message: "The task worker received no configuration" });\n return;\n }\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) {\n port.postMessage({ type: "fatal", message: "quickjs-emscripten could not be loaded" });\n return;\n }\n const module2 = await createTaskModule(api, input["memoryLimitBytes"]);\n port.on("message", (message) => {\n if (!isRecord(message) || message["type"] !== "task") return;\n const id = message["id"];\n const limits = message["limits"];\n let outcome;\n if (typeof message["code"] !== "string" || typeof message["requestJson"] !== "string" || !isRecord(limits) || typeof limits["timeoutMs"] !== "number" || typeof limits["memoryLimitBytes"] !== "number" || typeof limits["maxStackSizeBytes"] !== "number")\n outcome = {\n ok: false,\n cause: "INTERNAL",\n message: "The task worker received a malformed task"\n };\n else\n outcome = runTaskInQuickJS(api, module2, message["code"], message["requestJson"], {\n timeoutMs: limits["timeoutMs"],\n memoryLimitBytes: limits["memoryLimitBytes"],\n maxStackSizeBytes: limits["maxStackSizeBytes"]\n });\n port.postMessage({ type: "result", id, outcome });\n if (outcome.fatal === true) process.exit(1);\n });\n port.postMessage({ type: "ready" });\n}\nmain(import_node_worker_threads.workerData).catch((error) => {\n import_node_worker_threads.parentPort?.postMessage({\n type: "fatal",\n message: error instanceof Error ? error.message : String(error)\n });\n});\n';
|
|
25
25
|
|
|
26
26
|
// src/quickjs/task-runner.ts
|
|
27
27
|
var MAX_START_FAILURES = 3;
|
package/dist/roundtrip/index.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkTCTE7DX5_cjs = require('../chunk-TCTE7DX5.cjs');
|
|
4
|
+
var chunk4QKB4ARC_cjs = require('../chunk-4QKB4ARC.cjs');
|
|
5
5
|
var chunkSX2PNKKT_cjs = require('../chunk-SX2PNKKT.cjs');
|
|
6
6
|
var chunkCPDK3K5N_cjs = require('../chunk-CPDK3K5N.cjs');
|
|
7
|
-
var
|
|
8
|
-
require('../chunk-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
7
|
+
var chunkODZ2IAR2_cjs = require('../chunk-ODZ2IAR2.cjs');
|
|
8
|
+
require('../chunk-3U2NU7YC.cjs');
|
|
9
|
+
var chunkIQPXHQQQ_cjs = require('../chunk-IQPXHQQQ.cjs');
|
|
10
|
+
var chunk54FLQNUM_cjs = require('../chunk-54FLQNUM.cjs');
|
|
11
11
|
require('../chunk-G4UEPUGO.cjs');
|
|
12
12
|
var chunkGVTZMA5C_cjs = require('../chunk-GVTZMA5C.cjs');
|
|
13
13
|
var chunkQKZL3ONM_cjs = require('../chunk-QKZL3ONM.cjs');
|
|
14
14
|
var chunkTBDXTV22_cjs = require('../chunk-TBDXTV22.cjs');
|
|
15
15
|
var chunkSAENRNBJ_cjs = require('../chunk-SAENRNBJ.cjs');
|
|
16
16
|
var chunkQ4MWQNJK_cjs = require('../chunk-Q4MWQNJK.cjs');
|
|
17
|
-
require('../chunk-
|
|
17
|
+
require('../chunk-VA4OFR72.cjs');
|
|
18
18
|
require('../chunk-FR7KYWRO.cjs');
|
|
19
|
-
require('../chunk-
|
|
20
|
-
require('../chunk-
|
|
19
|
+
require('../chunk-A5SXCA62.cjs');
|
|
20
|
+
require('../chunk-TYF56RGB.cjs');
|
|
21
21
|
require('../chunk-Z2Y65YOY.cjs');
|
|
22
22
|
var fs = require('fs');
|
|
23
23
|
var path = require('path');
|
|
@@ -64,7 +64,9 @@ var HELPER_METHODS = {
|
|
|
64
64
|
"internal:noop": "noop"
|
|
65
65
|
};
|
|
66
66
|
var INTERNAL_DESCRIPTOR_NAMES = {
|
|
67
|
-
"internal:code-workflow": "codeWorkflow"
|
|
67
|
+
"internal:code-workflow": "codeWorkflow",
|
|
68
|
+
"internal:signal-run": "signalRun",
|
|
69
|
+
"internal:set-search-attributes": "setSearchAttributes"
|
|
68
70
|
};
|
|
69
71
|
var TRIGGER_NAMES = {
|
|
70
72
|
"internal:api": "api",
|
|
@@ -256,7 +258,7 @@ function richEdge(edge2, info, items) {
|
|
|
256
258
|
const options2 = [];
|
|
257
259
|
const extra = [];
|
|
258
260
|
if (edge2["id"] === void 0) options2.push(["id", { k: "literal", value: false }]);
|
|
259
|
-
else if (edge2["id"] !==
|
|
261
|
+
else if (edge2["id"] !== chunkIQPXHQQQ_cjs.defaultEdgeId(source, target, sourceHandle, targetHandle))
|
|
260
262
|
options2.push(["id", literalOrStructure(edge2["id"])]);
|
|
261
263
|
if (edge2["type"] === void 0) options2.push(["type", { k: "literal", value: false }]);
|
|
262
264
|
else if (edge2["type"] !== "deletable") options2.push(["type", literalOrStructure(edge2["type"])]);
|
|
@@ -757,19 +759,19 @@ function connectionsByName(connectionNames, definition) {
|
|
|
757
759
|
function descriptor(operation) {
|
|
758
760
|
switch (operation.kind) {
|
|
759
761
|
case "trigger": {
|
|
760
|
-
const value2 =
|
|
762
|
+
const value2 = chunkIQPXHQQQ_cjs.triggers[operation.name];
|
|
761
763
|
if (!value2) throw new LiftError(`Unknown trigger ${operation.name}`);
|
|
762
764
|
return value2;
|
|
763
765
|
}
|
|
764
766
|
case "internal": {
|
|
765
|
-
const value2 =
|
|
767
|
+
const value2 = chunkIQPXHQQQ_cjs.internalNodes[operation.name];
|
|
766
768
|
if (!value2) throw new LiftError(`Unknown internal node ${operation.name}`);
|
|
767
769
|
return value2;
|
|
768
770
|
}
|
|
769
771
|
case "client":
|
|
770
|
-
return operation.role === "trigger" ?
|
|
772
|
+
return operation.role === "trigger" ? chunkIQPXHQQQ_cjs.trigger(operation.nodeType, operation.version, operation.operation) : chunkIQPXHQQQ_cjs.op(operation.nodeType, operation.version, operation.operation);
|
|
771
773
|
case "custom":
|
|
772
|
-
return
|
|
774
|
+
return chunkIQPXHQQQ_cjs.nodes.custom(operation.nodeType, operation.operation, operation.version);
|
|
773
775
|
}
|
|
774
776
|
}
|
|
775
777
|
function refValue(ref, wf, runtime) {
|
|
@@ -827,7 +829,7 @@ function value(expression2, wf, runtime) {
|
|
|
827
829
|
return (declared ?? wf.ref(expression2.nodeId)).handle(expression2.handle);
|
|
828
830
|
}
|
|
829
831
|
case "edge":
|
|
830
|
-
return
|
|
832
|
+
return chunkIQPXHQQQ_cjs.edge(
|
|
831
833
|
value(expression2.from, wf, runtime),
|
|
832
834
|
value({ k: "object", entries: expression2.options }, wf, runtime)
|
|
833
835
|
);
|
|
@@ -855,7 +857,7 @@ function interpretPlan(plan) {
|
|
|
855
857
|
k: "object",
|
|
856
858
|
entries: plan.workflowOptions
|
|
857
859
|
});
|
|
858
|
-
const workflow =
|
|
860
|
+
const workflow = chunkIQPXHQQQ_cjs.defineWorkflow(workflowOptions2, (wf) => {
|
|
859
861
|
const runtime = /* @__PURE__ */ new Map();
|
|
860
862
|
for (const statement of plan.statements) {
|
|
861
863
|
if (statement.kind === "node") {
|
|
@@ -1133,8 +1135,8 @@ function layoutOf(reference) {
|
|
|
1133
1135
|
if (typeof x === "number" && typeof y === "number") chunkSAENRNBJ_cjs.setOwn(positions, node["id"], { x, y });
|
|
1134
1136
|
}
|
|
1135
1137
|
const sidecar = {
|
|
1136
|
-
format:
|
|
1137
|
-
formatVersion:
|
|
1138
|
+
format: chunkIQPXHQQQ_cjs.LAYOUT_FORMAT,
|
|
1139
|
+
formatVersion: chunkIQPXHQQQ_cjs.LAYOUT_FORMAT_VERSION,
|
|
1138
1140
|
positions
|
|
1139
1141
|
};
|
|
1140
1142
|
if (Array.isArray(data["stickyNotes"])) sidecar.stickyNotes = data["stickyNotes"];
|
|
@@ -1201,7 +1203,7 @@ function rejectedByBuilder(reference, run) {
|
|
|
1201
1203
|
return { nodes: nodes2, edges };
|
|
1202
1204
|
}
|
|
1203
1205
|
function prepareLift(definition, options2 = {}) {
|
|
1204
|
-
const normalized =
|
|
1206
|
+
const normalized = chunk54FLQNUM_cjs.normalizeDefinition(definition);
|
|
1205
1207
|
if (!chunkSAENRNBJ_cjs.isRecord(normalized) || !chunkSAENRNBJ_cjs.isRecord(normalized["data"]))
|
|
1206
1208
|
throw new TypeError("A workflow definition must be an object with data");
|
|
1207
1209
|
const reference = { ...normalized };
|
|
@@ -1232,12 +1234,12 @@ function prepareLift(definition, options2 = {}) {
|
|
|
1232
1234
|
const run = (rawNodes, rawEdges) => {
|
|
1233
1235
|
const build = buildPlan(reference, options2, rawNodes, rawEdges);
|
|
1234
1236
|
const recording = interpretPlan(build.plan);
|
|
1235
|
-
const candidate =
|
|
1237
|
+
const candidate = chunkIQPXHQQQ_cjs.assembleRecording(recording, {
|
|
1236
1238
|
layout,
|
|
1237
1239
|
...connections ? { connections } : {},
|
|
1238
1240
|
...pinned ? { pinnedData: pinned } : {}
|
|
1239
1241
|
});
|
|
1240
|
-
return { build, candidate:
|
|
1242
|
+
return { build, candidate: chunk54FLQNUM_cjs.normalizeDefinition(candidate) };
|
|
1241
1243
|
};
|
|
1242
1244
|
let rejected = { nodes: /* @__PURE__ */ new Set(), edges: /* @__PURE__ */ new Set() };
|
|
1243
1245
|
let attempt = tryRun(() => run(rejected.nodes, rejected.edges));
|
|
@@ -1360,12 +1362,12 @@ function readJson(path) {
|
|
|
1360
1362
|
try {
|
|
1361
1363
|
parsed = JSON.parse(fs.readFileSync(path, "utf8"));
|
|
1362
1364
|
} catch (error) {
|
|
1363
|
-
throw new
|
|
1365
|
+
throw new chunkODZ2IAR2_cjs.LowerError(
|
|
1364
1366
|
`Cannot read ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
1365
1367
|
);
|
|
1366
1368
|
}
|
|
1367
1369
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
1368
|
-
throw new
|
|
1370
|
+
throw new chunkODZ2IAR2_cjs.LowerError(`${path} is not a JSON object`);
|
|
1369
1371
|
return parsed;
|
|
1370
1372
|
}
|
|
1371
1373
|
function namesOf(value2) {
|
|
@@ -1398,7 +1400,7 @@ function collectFiles(packageDir, dir, files, budget) {
|
|
|
1398
1400
|
if (!KEPT_EXTENSIONS.some((ext) => entry.endsWith(ext))) continue;
|
|
1399
1401
|
budget.left -= stats.size;
|
|
1400
1402
|
if (budget.left < 0)
|
|
1401
|
-
throw new
|
|
1403
|
+
throw new chunkODZ2IAR2_cjs.LowerError(
|
|
1402
1404
|
`The vendored packages are larger than the limit (reached at "${budget.name}")`,
|
|
1403
1405
|
"too-large"
|
|
1404
1406
|
);
|
|
@@ -1418,7 +1420,7 @@ function vendorDependencies(projectDir, options2 = {}) {
|
|
|
1418
1420
|
const packageDir = locate(next.name, next.fromDir);
|
|
1419
1421
|
if (packageDir === void 0) {
|
|
1420
1422
|
if (next.optional) continue;
|
|
1421
|
-
throw new
|
|
1423
|
+
throw new chunkODZ2IAR2_cjs.LowerError(
|
|
1422
1424
|
`"${next.name}" is a dependency but is not installed under ${rootDir}; run your package manager's install first`
|
|
1423
1425
|
);
|
|
1424
1426
|
}
|
|
@@ -1456,10 +1458,10 @@ function packSources(archive) {
|
|
|
1456
1458
|
return new Uint8Array(zipped.buffer, zipped.byteOffset, zipped.byteLength);
|
|
1457
1459
|
}
|
|
1458
1460
|
function stringMap(value2, what) {
|
|
1459
|
-
if (!chunkSAENRNBJ_cjs.isRecord(value2)) throw new
|
|
1461
|
+
if (!chunkSAENRNBJ_cjs.isRecord(value2)) throw new chunkODZ2IAR2_cjs.LowerError(`${what} must be an object`);
|
|
1460
1462
|
const out = {};
|
|
1461
1463
|
for (const [key, entry] of Object.entries(value2)) {
|
|
1462
|
-
if (typeof entry !== "string") throw new
|
|
1464
|
+
if (typeof entry !== "string") throw new chunkODZ2IAR2_cjs.LowerError(`${what}["${key}"] must be a string`);
|
|
1463
1465
|
Object.defineProperty(out, key, {
|
|
1464
1466
|
value: entry,
|
|
1465
1467
|
enumerable: true,
|
|
@@ -1476,7 +1478,7 @@ function unpackSources(data, options2 = {}) {
|
|
|
1476
1478
|
text = zlib.gunzipSync(data, { maxOutputLength: maxBytes }).toString("utf8");
|
|
1477
1479
|
} catch (error) {
|
|
1478
1480
|
const message = error instanceof Error ? error.message : String(error);
|
|
1479
|
-
throw new
|
|
1481
|
+
throw new chunkODZ2IAR2_cjs.LowerError(
|
|
1480
1482
|
/buffer|length|range/i.test(message) ? `The source archive is larger than ${maxBytes} bytes uncompressed` : `The source archive is not gzip: ${message}`,
|
|
1481
1483
|
/buffer|length|range/i.test(message) ? "too-large" : void 0
|
|
1482
1484
|
);
|
|
@@ -1485,24 +1487,24 @@ function unpackSources(data, options2 = {}) {
|
|
|
1485
1487
|
try {
|
|
1486
1488
|
parsed = JSON.parse(text);
|
|
1487
1489
|
} catch {
|
|
1488
|
-
throw new
|
|
1490
|
+
throw new chunkODZ2IAR2_cjs.LowerError("The source archive is not JSON");
|
|
1489
1491
|
}
|
|
1490
|
-
if (!chunkSAENRNBJ_cjs.isRecord(parsed)) throw new
|
|
1492
|
+
if (!chunkSAENRNBJ_cjs.isRecord(parsed)) throw new chunkODZ2IAR2_cjs.LowerError("The source archive is not an object");
|
|
1491
1493
|
const archive = { files: stringMap(parsed["files"], "files") };
|
|
1492
1494
|
if (parsed["lock"] !== void 0) {
|
|
1493
|
-
if (typeof parsed["lock"] !== "string") throw new
|
|
1495
|
+
if (typeof parsed["lock"] !== "string") throw new chunkODZ2IAR2_cjs.LowerError("lock must be a string");
|
|
1494
1496
|
archive.lock = parsed["lock"];
|
|
1495
1497
|
}
|
|
1496
1498
|
if (parsed["map"] !== void 0) {
|
|
1497
|
-
if (typeof parsed["map"] !== "string") throw new
|
|
1499
|
+
if (typeof parsed["map"] !== "string") throw new chunkODZ2IAR2_cjs.LowerError("map must be a string");
|
|
1498
1500
|
archive.map = parsed["map"];
|
|
1499
1501
|
}
|
|
1500
1502
|
if (parsed["vendored"] !== void 0) {
|
|
1501
|
-
if (!chunkSAENRNBJ_cjs.isRecord(parsed["vendored"])) throw new
|
|
1503
|
+
if (!chunkSAENRNBJ_cjs.isRecord(parsed["vendored"])) throw new chunkODZ2IAR2_cjs.LowerError("vendored must be an object");
|
|
1502
1504
|
const vendored = {};
|
|
1503
1505
|
for (const [name, pkg] of Object.entries(parsed["vendored"])) {
|
|
1504
1506
|
if (!chunkSAENRNBJ_cjs.isRecord(pkg) || typeof pkg["version"] !== "string")
|
|
1505
|
-
throw new
|
|
1507
|
+
throw new chunkODZ2IAR2_cjs.LowerError(`vendored["${name}"] needs a version`);
|
|
1506
1508
|
Object.defineProperty(vendored, name, {
|
|
1507
1509
|
value: {
|
|
1508
1510
|
version: pkg["version"],
|
|
@@ -1531,7 +1533,7 @@ function decodeVlq(segment) {
|
|
|
1531
1533
|
let shift = 0;
|
|
1532
1534
|
for (const char of segment) {
|
|
1533
1535
|
const digit = BASE64_VALUE.get(char);
|
|
1534
|
-
if (digit === void 0) throw new
|
|
1536
|
+
if (digit === void 0) throw new chunkODZ2IAR2_cjs.LowerError(`Invalid source map character "${char}"`);
|
|
1535
1537
|
value2 += (digit & 31) * 2 ** shift;
|
|
1536
1538
|
if (digit & 32) {
|
|
1537
1539
|
shift += 5;
|
|
@@ -1541,7 +1543,7 @@ function decodeVlq(segment) {
|
|
|
1541
1543
|
value2 = 0;
|
|
1542
1544
|
shift = 0;
|
|
1543
1545
|
}
|
|
1544
|
-
if (shift !== 0) throw new
|
|
1546
|
+
if (shift !== 0) throw new chunkODZ2IAR2_cjs.LowerError("A source map segment ends in the middle of a number");
|
|
1545
1547
|
return values;
|
|
1546
1548
|
}
|
|
1547
1549
|
function createSourceMapper(mapText) {
|
|
@@ -1549,16 +1551,16 @@ function createSourceMapper(mapText) {
|
|
|
1549
1551
|
try {
|
|
1550
1552
|
parsed = JSON.parse(mapText);
|
|
1551
1553
|
} catch {
|
|
1552
|
-
throw new
|
|
1554
|
+
throw new chunkODZ2IAR2_cjs.LowerError("The source map is not JSON");
|
|
1553
1555
|
}
|
|
1554
1556
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
1555
|
-
throw new
|
|
1557
|
+
throw new chunkODZ2IAR2_cjs.LowerError("The source map is not an object");
|
|
1556
1558
|
const record = parsed;
|
|
1557
1559
|
const sources = record["sources"];
|
|
1558
1560
|
const names = Array.isArray(record["names"]) ? record["names"].map(String) : [];
|
|
1559
1561
|
const mappings = record["mappings"];
|
|
1560
1562
|
if (record["version"] !== 3 || !Array.isArray(sources) || typeof mappings !== "string")
|
|
1561
|
-
throw new
|
|
1563
|
+
throw new chunkODZ2IAR2_cjs.LowerError("Only version 3 source maps with mappings are supported");
|
|
1562
1564
|
const sourceNames = sources.map(String);
|
|
1563
1565
|
const lines = [];
|
|
1564
1566
|
let source = 0;
|
|
@@ -1688,7 +1690,7 @@ async function checkFidelity(files, reference, items, options2 = {}) {
|
|
|
1688
1690
|
const all = [...items];
|
|
1689
1691
|
const connections = options2.connectionNames && chunkSAENRNBJ_cjs.isRecord(reference) ? connectionsByName(options2.connectionNames, reference) : void 0;
|
|
1690
1692
|
try {
|
|
1691
|
-
const result = await
|
|
1693
|
+
const result = await chunkODZ2IAR2_cjs.lower(
|
|
1692
1694
|
files.map((file) => ({ path: file.path, content: file.content })),
|
|
1693
1695
|
{
|
|
1694
1696
|
...options2.esbuild ? { esbuild: options2.esbuild } : {},
|
|
@@ -1702,8 +1704,8 @@ async function checkFidelity(files, reference, items, options2 = {}) {
|
|
|
1702
1704
|
kind: "lowering-failed",
|
|
1703
1705
|
detail: `Lowering produced ${result.workflows.length} workflows instead of one`
|
|
1704
1706
|
});
|
|
1705
|
-
} else if (
|
|
1706
|
-
for (const change of
|
|
1707
|
+
} else if (chunk54FLQNUM_cjs.irHash(lowered) !== chunk54FLQNUM_cjs.irHash(reference)) {
|
|
1708
|
+
for (const change of chunk4QKB4ARC_cjs.diffDefinitions(reference, lowered)) {
|
|
1707
1709
|
all.push({
|
|
1708
1710
|
path: change.path,
|
|
1709
1711
|
kind: "roundtrip-mismatch",
|
|
@@ -1728,12 +1730,12 @@ async function exportWorkflowCode(definition, options2) {
|
|
|
1728
1730
|
...options2.connectionNames ? { connectionNames: options2.connectionNames } : {}
|
|
1729
1731
|
});
|
|
1730
1732
|
const files = options2.format === "PYTHON" ? (await liftToPython(definition, options2)).files : ts.files;
|
|
1731
|
-
return { format: options2.format, files, fidelity, irHash:
|
|
1733
|
+
return { format: options2.format, files, fidelity, irHash: chunk54FLQNUM_cjs.irHash(definition) };
|
|
1732
1734
|
}
|
|
1733
1735
|
|
|
1734
1736
|
Object.defineProperty(exports, "createNodeVmEvaluator", {
|
|
1735
1737
|
enumerable: true,
|
|
1736
|
-
get: function () { return
|
|
1738
|
+
get: function () { return chunkTCTE7DX5_cjs.createNodeVmEvaluator; }
|
|
1737
1739
|
});
|
|
1738
1740
|
Object.defineProperty(exports, "PY_LINE_LENGTH", {
|
|
1739
1741
|
enumerable: true,
|
|
@@ -1747,89 +1749,93 @@ Object.defineProperty(exports, "TS_NODES_IMPORT", {
|
|
|
1747
1749
|
enumerable: true,
|
|
1748
1750
|
get: function () { return chunkSX2PNKKT_cjs.TS_NODES_IMPORT; }
|
|
1749
1751
|
});
|
|
1752
|
+
Object.defineProperty(exports, "DYNAMIC_EXPORT", {
|
|
1753
|
+
enumerable: true,
|
|
1754
|
+
get: function () { return chunkODZ2IAR2_cjs.DYNAMIC_EXPORT; }
|
|
1755
|
+
});
|
|
1750
1756
|
Object.defineProperty(exports, "DeterminismViolationError", {
|
|
1751
1757
|
enumerable: true,
|
|
1752
|
-
get: function () { return
|
|
1758
|
+
get: function () { return chunkODZ2IAR2_cjs.DeterminismViolationError; }
|
|
1753
1759
|
});
|
|
1754
1760
|
Object.defineProperty(exports, "ESBUILD_VERSION", {
|
|
1755
1761
|
enumerable: true,
|
|
1756
|
-
get: function () { return
|
|
1762
|
+
get: function () { return chunkODZ2IAR2_cjs.ESBUILD_VERSION; }
|
|
1757
1763
|
});
|
|
1758
1764
|
Object.defineProperty(exports, "EVALUATION_GLOBAL", {
|
|
1759
1765
|
enumerable: true,
|
|
1760
|
-
get: function () { return
|
|
1766
|
+
get: function () { return chunkODZ2IAR2_cjs.EVALUATION_GLOBAL; }
|
|
1761
1767
|
});
|
|
1762
1768
|
Object.defineProperty(exports, "LowerError", {
|
|
1763
1769
|
enumerable: true,
|
|
1764
|
-
get: function () { return
|
|
1770
|
+
get: function () { return chunkODZ2IAR2_cjs.LowerError; }
|
|
1765
1771
|
});
|
|
1766
1772
|
Object.defineProperty(exports, "NODE_BUILTINS", {
|
|
1767
1773
|
enumerable: true,
|
|
1768
|
-
get: function () { return
|
|
1774
|
+
get: function () { return chunkODZ2IAR2_cjs.NODE_BUILTINS; }
|
|
1769
1775
|
});
|
|
1770
1776
|
Object.defineProperty(exports, "buildBundle", {
|
|
1771
1777
|
enumerable: true,
|
|
1772
|
-
get: function () { return
|
|
1778
|
+
get: function () { return chunkODZ2IAR2_cjs.buildBundle; }
|
|
1773
1779
|
});
|
|
1774
1780
|
Object.defineProperty(exports, "bundleProject", {
|
|
1775
1781
|
enumerable: true,
|
|
1776
|
-
get: function () { return
|
|
1782
|
+
get: function () { return chunkODZ2IAR2_cjs.bundleProject; }
|
|
1777
1783
|
});
|
|
1778
1784
|
Object.defineProperty(exports, "bundleSourceHash", {
|
|
1779
1785
|
enumerable: true,
|
|
1780
|
-
get: function () { return
|
|
1786
|
+
get: function () { return chunkODZ2IAR2_cjs.bundleSourceHash; }
|
|
1781
1787
|
});
|
|
1782
1788
|
Object.defineProperty(exports, "callArguments", {
|
|
1783
1789
|
enumerable: true,
|
|
1784
|
-
get: function () { return
|
|
1790
|
+
get: function () { return chunkODZ2IAR2_cjs.callArguments; }
|
|
1785
1791
|
});
|
|
1786
1792
|
Object.defineProperty(exports, "defaultEntries", {
|
|
1787
1793
|
enumerable: true,
|
|
1788
|
-
get: function () { return
|
|
1794
|
+
get: function () { return chunkODZ2IAR2_cjs.defaultEntries; }
|
|
1789
1795
|
});
|
|
1790
1796
|
Object.defineProperty(exports, "durableFeatures", {
|
|
1791
1797
|
enumerable: true,
|
|
1792
|
-
get: function () { return
|
|
1798
|
+
get: function () { return chunkODZ2IAR2_cjs.durableFeatures; }
|
|
1793
1799
|
});
|
|
1794
1800
|
Object.defineProperty(exports, "durableScanModules", {
|
|
1795
1801
|
enumerable: true,
|
|
1796
|
-
get: function () { return
|
|
1802
|
+
get: function () { return chunkODZ2IAR2_cjs.durableScanModules; }
|
|
1797
1803
|
});
|
|
1798
1804
|
Object.defineProperty(exports, "literalDurationMs", {
|
|
1799
1805
|
enumerable: true,
|
|
1800
|
-
get: function () { return
|
|
1806
|
+
get: function () { return chunkODZ2IAR2_cjs.literalDurationMs; }
|
|
1801
1807
|
});
|
|
1802
1808
|
Object.defineProperty(exports, "lower", {
|
|
1803
1809
|
enumerable: true,
|
|
1804
|
-
get: function () { return
|
|
1810
|
+
get: function () { return chunkODZ2IAR2_cjs.lower; }
|
|
1805
1811
|
});
|
|
1806
1812
|
Object.defineProperty(exports, "objectEntries", {
|
|
1807
1813
|
enumerable: true,
|
|
1808
|
-
get: function () { return
|
|
1814
|
+
get: function () { return chunkODZ2IAR2_cjs.objectEntries; }
|
|
1809
1815
|
});
|
|
1810
1816
|
Object.defineProperty(exports, "resolvePackageEntry", {
|
|
1811
1817
|
enumerable: true,
|
|
1812
|
-
get: function () { return
|
|
1818
|
+
get: function () { return chunkODZ2IAR2_cjs.resolvePackageEntry; }
|
|
1813
1819
|
});
|
|
1814
1820
|
Object.defineProperty(exports, "scanDurableSource", {
|
|
1815
1821
|
enumerable: true,
|
|
1816
|
-
get: function () { return
|
|
1822
|
+
get: function () { return chunkODZ2IAR2_cjs.scanDurableSource; }
|
|
1817
1823
|
});
|
|
1818
1824
|
Object.defineProperty(exports, "scanDurableSources", {
|
|
1819
1825
|
enumerable: true,
|
|
1820
|
-
get: function () { return
|
|
1826
|
+
get: function () { return chunkODZ2IAR2_cjs.scanDurableSources; }
|
|
1821
1827
|
});
|
|
1822
1828
|
Object.defineProperty(exports, "splitSpecifier", {
|
|
1823
1829
|
enumerable: true,
|
|
1824
|
-
get: function () { return
|
|
1830
|
+
get: function () { return chunkODZ2IAR2_cjs.splitSpecifier; }
|
|
1825
1831
|
});
|
|
1826
1832
|
Object.defineProperty(exports, "splitTopLevel", {
|
|
1827
1833
|
enumerable: true,
|
|
1828
|
-
get: function () { return
|
|
1834
|
+
get: function () { return chunkODZ2IAR2_cjs.splitTopLevel; }
|
|
1829
1835
|
});
|
|
1830
1836
|
Object.defineProperty(exports, "withoutAllComments", {
|
|
1831
1837
|
enumerable: true,
|
|
1832
|
-
get: function () { return
|
|
1838
|
+
get: function () { return chunkODZ2IAR2_cjs.withoutAllComments; }
|
|
1833
1839
|
});
|
|
1834
1840
|
exports.BUNDLE_FILE_NAME = BUNDLE_FILE_NAME;
|
|
1835
1841
|
exports.LiftError = LiftError;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { W as WorkflowDefinition,
|
|
2
|
-
import { f as LayoutSidecar } from '../collect-
|
|
3
|
-
import { N as NodeManifest } from '../manifest-
|
|
1
|
+
import { W as WorkflowDefinition, J as JsonObject, a as Json } from '../types-V7jEEUaL.cjs';
|
|
2
|
+
import { f as LayoutSidecar } from '../collect-CcTCKqx6.cjs';
|
|
3
|
+
import { N as NodeManifest } from '../manifest-DahBQVM8.cjs';
|
|
4
4
|
import { P as PathSegment } from '../expressions-DhHaqyar.cjs';
|
|
5
|
-
import { V as VendoredDeps, a as VendoredPackage, E as Evaluator } from '../lower-
|
|
6
|
-
export { B as BuildBundleOptions, b as BuiltBundle, D as
|
|
5
|
+
import { V as VendoredDeps, a as VendoredPackage, E as Evaluator } from '../lower-BtRfIW2A.cjs';
|
|
6
|
+
export { B as BuildBundleOptions, b as BuiltBundle, D as DYNAMIC_EXPORT, c as DeterminismViolationError, d as ESBUILD_VERSION, e as EVALUATION_GLOBAL, L as LowerIssue, f as LowerOptions, g as LowerResult, h as LoweredWorkflow, N as NODE_BUILTINS, i as buildBundle, j as bundleProject, k as bundleSourceHash, l as defaultEntries, m as durableFeatures, n as durableScanModules, o as lower, r as resolvePackageEntry, s as scanDurableSources, p as splitSpecifier } from '../lower-BtRfIW2A.cjs';
|
|
7
7
|
import { E as EsbuildApi } from '../lower-types-DQNBfWQn.cjs';
|
|
8
8
|
export { B as BuildDiagnostic, a as BuildDiagnosticLocation, L as LowerError, b as LowerFailureReason } from '../lower-types-DQNBfWQn.cjs';
|
|
9
|
-
import '../workflow-
|
|
10
|
-
import '../workflow-
|
|
11
|
-
import '../types-
|
|
9
|
+
import '../workflow-BJPFv3cp.cjs';
|
|
10
|
+
import '../workflow-DS32Gtws.cjs';
|
|
11
|
+
import '../types-Bv2i4cBX.cjs';
|
|
12
12
|
import '../hash-CZkTXPCX.cjs';
|
|
13
13
|
import 'esbuild';
|
|
14
14
|
|
|
@@ -291,8 +291,18 @@ declare function mapEnhancedStackTrace(value: Json, mapper: SourceMapper, bundle
|
|
|
291
291
|
/** The source positions of the bundle frames of a stack text, innermost first. */
|
|
292
292
|
declare function sourceLocations(stack: string, mapper: SourceMapper, bundleFile?: string): SourcePosition[];
|
|
293
293
|
|
|
294
|
-
/**
|
|
295
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Bundle features a call site can show (the option-level ones come from the
|
|
296
|
+
* declarations). Phase C (C-R1) adds `userActivity`, `updates`, `queries`,
|
|
297
|
+
* `searchAttributes`, `dynamic` and `interceptors`.
|
|
298
|
+
*/
|
|
299
|
+
type SourceFeature = 'localActivity' | 'externalCancel' | 'childOptions' | 'canOptions' | 'userActivity' | 'updates' | 'queries' | 'searchAttributes' | 'dynamic' | 'interceptors';
|
|
300
|
+
/** Default handlers a module registers, which open the interface (11 §2.29). */
|
|
301
|
+
interface OpenHandlers {
|
|
302
|
+
signals: boolean;
|
|
303
|
+
queries: boolean;
|
|
304
|
+
updates: boolean;
|
|
305
|
+
}
|
|
296
306
|
/**
|
|
297
307
|
* The text between the parenthesis at `open` and its match, skipping string
|
|
298
308
|
* and template literals and comments. Unbalanced text runs to the end.
|
|
@@ -318,8 +328,12 @@ interface DurableSourceFindings {
|
|
|
318
328
|
features: SourceFeature[];
|
|
319
329
|
/** `startToCloseTimeout` literals of local activities above the cap, in milliseconds. */
|
|
320
330
|
localActivityTimeouts: number[];
|
|
321
|
-
/** Local activities given a function (user local activities,
|
|
331
|
+
/** Local activities given a function (user local activities, not run yet). */
|
|
322
332
|
userLocalActivities: number;
|
|
333
|
+
/** Default handlers the module registers. */
|
|
334
|
+
open: OpenHandlers;
|
|
335
|
+
/** User-activity implementations the module creates (`implementActivity` and the like). */
|
|
336
|
+
activityImplementations: string[];
|
|
323
337
|
}
|
|
324
338
|
/** Read one tier-2 module (or a module a tier-2 workflow may call). */
|
|
325
339
|
declare function scanDurableSource(source: string): DurableSourceFindings;
|