@workflow/web 5.0.0-beta.5 → 5.0.0-beta.51
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 +1 -0
- package/build/client/assets/app-9JVnf-IU.css +1 -0
- package/build/client/assets/arrow-up-right-D35zSWdr.js +15 -0
- package/build/client/assets/{entry.client-DtOpLtMQ.js → entry.client-DmlDFlyx.js} +25 -185
- package/build/client/assets/{highlighted-body-B3W2YXNL-L1CrwoL_.js → highlighted-body-B3W2YXNL-CaN05-wF.js} +2 -2
- package/build/client/assets/{home-B6UmDDP6.js → home-CERPMYFB.js} +1762 -291
- package/build/client/assets/index-HqNj_XIX.js +200 -0
- package/build/client/assets/{index-BsV8i_Jn.js → index-thGVuYbY.js} +19 -19
- package/build/client/assets/loader-circle-BS067e3l.js +12 -0
- package/build/client/assets/manifest-e59a5df7.js +1 -0
- package/build/client/assets/mermaid-3ZIDBTTL-D8CjRQta.css +1 -0
- package/build/client/assets/{mermaid-3ZIDBTTL-BQLU7GUr.js → mermaid-3ZIDBTTL-DX-qOY9c.js} +17613 -12954
- package/build/client/assets/root-Bl5xphvU.css +1 -0
- package/build/client/assets/{root-Yk3JVwUh.js → root-D0H-cabN.js} +17 -42
- package/build/client/assets/{run-detail-DMUaWXhb.js → run-detail-C7nNgL_7.js} +2215 -1599
- package/build/client/assets/run-detail-CWoGxu_0.css +1 -0
- package/build/client/assets/{workflow-graph-viewer-yqeN-U_2.js → workflow-graph-viewer-nSzDqm6s.js} +5111 -5254
- package/build/client/assets/zstd-B5R2yJjB.wasm +0 -0
- package/build/client/assets/zstd-browser-decoder-DtSP7rJ_.js +27 -0
- package/build/server/assets/{server-build-DtcOUEHS.js → app-8hyjFpMO.js} +77875 -59603
- package/build/server/assets/{highlighted-body-B3W2YXNL-CZjJIpdD.js → highlighted-body-B3W2YXNL-DY_BqM6l.js} +16 -8
- package/build/server/assets/index-Az8HzIf_.js +174 -0
- package/build/server/assets/index-BfLBLRRi.js +204 -0
- package/build/server/assets/index-CETb4fkq.js +1164 -0
- package/build/server/assets/index-CvyMHP_b.js +1262 -0
- package/build/server/assets/{mermaid-3ZIDBTTL-Cc8IPTBj.js → mermaid-3ZIDBTTL-Bca_z0-z.js} +17 -9
- package/build/server/assets/{token-DHnArVm7.js → token-BcUtceXk.js} +5 -2
- package/build/server/assets/{token-util-B3uKeZ0s.js → token-util-BgQCuyAc.js} +5 -2
- package/build/server/assets/websocket-server-D2905vlr.js +3669 -0
- package/build/server/assets/wrapper-BxY6HvLW.js +69 -0
- package/build/server/assets/ws-transport-nlG6b7qI.js +551 -0
- package/build/server/assets/zstd-browser-decoder-Ce8lEOjC.js +72 -0
- package/build/server/index.js +50 -2
- package/handler.d.ts +22 -0
- package/handler.js +186 -0
- package/package.json +27 -13
- package/registry.d.ts +29 -0
- package/registry.js +89 -0
- package/build/client/assets/encryption-CEh0YXii.js +0 -28
- package/build/client/assets/index-B4xuge0I.js +0 -249
- package/build/client/assets/manifest-e4c1c787.js +0 -1
- package/build/client/assets/mermaid-3ZIDBTTL-DKxHcEOp.css +0 -1
- package/build/client/assets/root-C0Tu5TVN.css +0 -1
- package/build/client/assets/server-build-DqaxIrF0.css +0 -1
- package/build/client/assets/worker-CqHKTA7D.js +0 -115
- package/build/server/assets/app-L1V62FgT.js +0 -9213
- package/build/server/assets/index-BwtNigf1.js +0 -80
- package/build/server/assets/index-meg9qk8y.js +0 -1282
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { createRequire as __wkfCreateRequire } from "node:module";
|
|
2
|
+
if (typeof require === "undefined") {
|
|
3
|
+
globalThis.require = __wkfCreateRequire(import.meta.url);
|
|
4
|
+
}
|
|
5
|
+
import { b4 as reactExports, b5 as R, b6 as Ks, b7 as jsxRuntimeExports, b8 as Qe } from "./app-8hyjFpMO.js";
|
|
3
6
|
import "node:stream";
|
|
7
|
+
import "stream";
|
|
4
8
|
import "util";
|
|
5
9
|
import "crypto";
|
|
6
10
|
import "async_hooks";
|
|
7
|
-
import "stream";
|
|
8
11
|
import "node:crypto";
|
|
9
12
|
import "node:process";
|
|
10
13
|
import "node:path";
|
|
11
14
|
import "node:url";
|
|
12
15
|
import "module";
|
|
13
16
|
import "node:fs/promises";
|
|
17
|
+
import "node:module";
|
|
14
18
|
import "node:util";
|
|
15
19
|
import "node:async_hooks";
|
|
16
|
-
import "node:module";
|
|
17
20
|
import "node:fs";
|
|
21
|
+
import "node:os";
|
|
18
22
|
import "node:child_process";
|
|
19
23
|
import "node:timers/promises";
|
|
24
|
+
import "node:buffer";
|
|
25
|
+
import "node:http";
|
|
26
|
+
import "node:https";
|
|
27
|
+
import "node:zlib";
|
|
20
28
|
import "events";
|
|
21
29
|
import "node:assert";
|
|
22
30
|
import "node:net";
|
|
23
|
-
import "node:http";
|
|
24
31
|
import "node:querystring";
|
|
25
32
|
import "node:events";
|
|
26
33
|
import "node:diagnostics_channel";
|
|
27
34
|
import "node:tls";
|
|
28
|
-
import "node:buffer";
|
|
29
|
-
import "node:zlib";
|
|
30
35
|
import "node:perf_hooks";
|
|
31
36
|
import "node:util/types";
|
|
32
37
|
import "node:sqlite";
|
|
@@ -36,9 +41,12 @@ import "node:timers";
|
|
|
36
41
|
import "node:dns";
|
|
37
42
|
import "path";
|
|
38
43
|
import "fs";
|
|
44
|
+
import "constants";
|
|
45
|
+
import "assert";
|
|
39
46
|
import "os";
|
|
47
|
+
import "assert/strict";
|
|
40
48
|
import "net";
|
|
41
|
-
import "node:
|
|
49
|
+
import "node:assert/strict";
|
|
42
50
|
import "express";
|
|
43
51
|
var L = ({ code: s, language: t, raw: e, className: n, ...d$1 }) => {
|
|
44
52
|
let { shikiTheme: l } = reactExports.useContext(R), o = Ks(), [m, i] = reactExports.useState(e);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { createRequire as __wkfCreateRequire } from "node:module";
|
|
2
|
+
if (typeof require === "undefined") {
|
|
3
|
+
globalThis.require = __wkfCreateRequire(import.meta.url);
|
|
4
|
+
}
|
|
5
|
+
import { H as HookSchema } from "./app-8hyjFpMO.js";
|
|
6
|
+
import { A, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, B, r, s, t, u, C, D, v, E, w, x, y, F, z, G, I, J, K, L, M, O, P, Q, R, S, T, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as, at, au, av, aw, ax, ay, az, aA, aB, aC, aD, aE, aF, aG, aH, aI, aJ, aK, aL, aM, aN, aO, aP, aQ, aR, aS, aT, aU, aV, aW, aX, aY, aZ, a_, a$, b0, b1, b2, b3 } from "./app-8hyjFpMO.js";
|
|
7
|
+
import "node:stream";
|
|
8
|
+
import "stream";
|
|
9
|
+
import "util";
|
|
10
|
+
import "crypto";
|
|
11
|
+
import "async_hooks";
|
|
12
|
+
import "node:crypto";
|
|
13
|
+
import "node:process";
|
|
14
|
+
import "node:path";
|
|
15
|
+
import "node:url";
|
|
16
|
+
import "module";
|
|
17
|
+
import "node:fs/promises";
|
|
18
|
+
import "node:module";
|
|
19
|
+
import "node:util";
|
|
20
|
+
import "node:async_hooks";
|
|
21
|
+
import "node:fs";
|
|
22
|
+
import "node:os";
|
|
23
|
+
import "node:child_process";
|
|
24
|
+
import "node:timers/promises";
|
|
25
|
+
import "node:buffer";
|
|
26
|
+
import "node:http";
|
|
27
|
+
import "node:https";
|
|
28
|
+
import "node:zlib";
|
|
29
|
+
import "events";
|
|
30
|
+
import "node:assert";
|
|
31
|
+
import "node:net";
|
|
32
|
+
import "node:querystring";
|
|
33
|
+
import "node:events";
|
|
34
|
+
import "node:diagnostics_channel";
|
|
35
|
+
import "node:tls";
|
|
36
|
+
import "node:perf_hooks";
|
|
37
|
+
import "node:util/types";
|
|
38
|
+
import "node:sqlite";
|
|
39
|
+
import "node:worker_threads";
|
|
40
|
+
import "node:console";
|
|
41
|
+
import "node:timers";
|
|
42
|
+
import "node:dns";
|
|
43
|
+
import "path";
|
|
44
|
+
import "fs";
|
|
45
|
+
import "constants";
|
|
46
|
+
import "assert";
|
|
47
|
+
import "os";
|
|
48
|
+
import "assert/strict";
|
|
49
|
+
import "net";
|
|
50
|
+
import "node:assert/strict";
|
|
51
|
+
import "express";
|
|
52
|
+
export {
|
|
53
|
+
A as ANALYTICS_EVENTS_GET_MANY_LIMIT,
|
|
54
|
+
a as ANALYTICS_MAX_ATTRIBUTE_FILTERS,
|
|
55
|
+
b as ANALYTICS_PAGE_LIMIT,
|
|
56
|
+
c as ANALYTICS_RUN_SCOPED_PAGE_LIMIT,
|
|
57
|
+
d as ATTRIBUTE_KEY_MAX_LENGTH,
|
|
58
|
+
e as ATTRIBUTE_MAX_PER_RUN,
|
|
59
|
+
f as ATTRIBUTE_VALUE_MAX_BYTES,
|
|
60
|
+
g as AnalyticsAttributeKeySchema,
|
|
61
|
+
h as AnalyticsEventSchema,
|
|
62
|
+
i as AnalyticsHookSchema,
|
|
63
|
+
j as AnalyticsRunSchema,
|
|
64
|
+
k as AnalyticsStepSchema,
|
|
65
|
+
l as AnalyticsWaitSchema,
|
|
66
|
+
m as AttributeChangeSchema,
|
|
67
|
+
n as AttributeChangesSchema,
|
|
68
|
+
o as AttributeKeySchema,
|
|
69
|
+
p as AttributeValidationError,
|
|
70
|
+
q as AttributeValueSchema,
|
|
71
|
+
B as BULK_CANCEL_MAX_RUN_IDS,
|
|
72
|
+
r as BaseEventSchema,
|
|
73
|
+
s as BulkCancelWorkflowRunResultSchema,
|
|
74
|
+
t as BulkCancelWorkflowRunsRequestSchema,
|
|
75
|
+
u as BulkCancelWorkflowRunsResultSchema,
|
|
76
|
+
C as CHILD_ENTITY_CREATION_EVENT_TYPES,
|
|
77
|
+
D as DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS,
|
|
78
|
+
v as DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS,
|
|
79
|
+
E as EVENT_ID_BODY_LENGTH,
|
|
80
|
+
w as EVENT_ID_PREFIX,
|
|
81
|
+
x as EventSchema,
|
|
82
|
+
y as EventTypeSchema,
|
|
83
|
+
F as FIRST_EVENT_SLOT,
|
|
84
|
+
z as HOOK_EVENTS_REQUIRING_EXISTENCE,
|
|
85
|
+
G as HOOK_LIFECYCLE_EVENT_TYPES,
|
|
86
|
+
I as HOOK_RESUME_DEDUP_VERSION,
|
|
87
|
+
J as HOOK_RESUME_INPUT_VERSION,
|
|
88
|
+
K as HealthCheckPayloadSchema,
|
|
89
|
+
L as HookCreatedEventSchema,
|
|
90
|
+
M as HookResumeCapabilitiesSchema,
|
|
91
|
+
HookSchema,
|
|
92
|
+
O as LegacySerializedDataSchemaV1,
|
|
93
|
+
P as MessageId,
|
|
94
|
+
Q as NODE_HTTP_DEFAULT,
|
|
95
|
+
R as NODE_HTTP_ENV_VAR,
|
|
96
|
+
S as PARENT_RUN_ID_ATTRIBUTE,
|
|
97
|
+
T as PaginatedResponseSchema,
|
|
98
|
+
U as QueuePayloadSchema,
|
|
99
|
+
V as QueuePrefix,
|
|
100
|
+
W as RESERVED_ATTRIBUTE_KEY_PREFIX,
|
|
101
|
+
X as RETENTION_ATTRIBUTE,
|
|
102
|
+
Y as RETENTION_DEFAULT,
|
|
103
|
+
Z as RETENTION_ZERO,
|
|
104
|
+
_ as ROOT_RUN_ID_ATTRIBUTE,
|
|
105
|
+
$ as RUN_ENTITY_KEY,
|
|
106
|
+
a0 as RunInputSchema,
|
|
107
|
+
a1 as SEALED_LOG_ENV_VAR,
|
|
108
|
+
a2 as SPEC_VERSION_CURRENT,
|
|
109
|
+
a3 as SPEC_VERSION_LEGACY,
|
|
110
|
+
a4 as SPEC_VERSION_MAX_SUPPORTED,
|
|
111
|
+
a5 as SPEC_VERSION_SUPPORTS_ATTRIBUTES,
|
|
112
|
+
a6 as SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT,
|
|
113
|
+
a7 as SPEC_VERSION_SUPPORTS_COMPRESSION,
|
|
114
|
+
a8 as SPEC_VERSION_SUPPORTS_SEALED_LOG,
|
|
115
|
+
a9 as SPEC_VERSION_SUPPORTS_SLOT_IDENTITY,
|
|
116
|
+
aa as STEP_EVENT_TYPES,
|
|
117
|
+
ab as SerializedDataSchema,
|
|
118
|
+
ac as StepSchema,
|
|
119
|
+
ad as StepStatusSchema,
|
|
120
|
+
ae as StructuredErrorSchema,
|
|
121
|
+
af as TERMINAL_EVENT_CLASSES,
|
|
122
|
+
ag as TERMINAL_RUN_EVENT_TYPES,
|
|
123
|
+
ah as TERMINAL_STEP_EVENT_TYPES,
|
|
124
|
+
ai as TERMINAL_STEP_STATUSES,
|
|
125
|
+
aj as TERMINAL_WORKFLOW_RUN_STATUSES,
|
|
126
|
+
ak as TerminalRunEventTypeSchema,
|
|
127
|
+
al as TerminalStepStatusSchema,
|
|
128
|
+
am as TerminalWorkflowRunStatusSchema,
|
|
129
|
+
an as ValidQueueName,
|
|
130
|
+
ao as WAIT_EVENT_TYPES,
|
|
131
|
+
ap as WaitSchema,
|
|
132
|
+
aq as WaitStatusSchema,
|
|
133
|
+
ar as WorkflowInvokePayloadSchema,
|
|
134
|
+
as as WorkflowRunBaseSchema,
|
|
135
|
+
at as WorkflowRunSchema,
|
|
136
|
+
au as WorkflowRunStatusSchema,
|
|
137
|
+
av as applyAttributeChanges,
|
|
138
|
+
aw as classifyEntityEvent,
|
|
139
|
+
ax as entityEventClass,
|
|
140
|
+
ay as envFlag,
|
|
141
|
+
az as envNumber,
|
|
142
|
+
aA as eventIdToSlot,
|
|
143
|
+
aB as getEventDataPayloadField,
|
|
144
|
+
aC as getEventDataRefFields,
|
|
145
|
+
aD as getMaxEventsPerRun,
|
|
146
|
+
aE as getQueueTopicPrefix,
|
|
147
|
+
aF as isChildEntityCreationEvent,
|
|
148
|
+
aG as isChildEntityCreationEventType,
|
|
149
|
+
aH as isHookEventRequiringExistence,
|
|
150
|
+
aI as isHookLifecycleEventType,
|
|
151
|
+
aJ as isLegacySpecVersion,
|
|
152
|
+
aK as isNodeHttpEnabled,
|
|
153
|
+
aL as isSealedNoopEvent,
|
|
154
|
+
aM as isSlotBody,
|
|
155
|
+
aN as isSlotEventId,
|
|
156
|
+
aO as isStepEventType,
|
|
157
|
+
aP as isTerminalRunEventType,
|
|
158
|
+
aQ as isTerminalStepEventType,
|
|
159
|
+
aR as isTerminalStepStatus,
|
|
160
|
+
aS as isTerminalWorkflowRunStatus,
|
|
161
|
+
aT as isWaitEventType,
|
|
162
|
+
aU as mintedSpecVersion,
|
|
163
|
+
aV as parseQueueName,
|
|
164
|
+
aW as readRunRetention,
|
|
165
|
+
aX as reenqueueActiveRuns,
|
|
166
|
+
aY as requiresNewerWorld,
|
|
167
|
+
aZ as resolveQueueNamespace,
|
|
168
|
+
a_ as slotToEventId,
|
|
169
|
+
a$ as stripEventDataRefs,
|
|
170
|
+
b0 as ulidToDate,
|
|
171
|
+
b1 as validateAttributeChanges,
|
|
172
|
+
b2 as validateUlidTimestamp,
|
|
173
|
+
b3 as workflowRunIdSchema
|
|
174
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { createRequire as __wkfCreateRequire } from "node:module";
|
|
2
|
+
if (typeof require === "undefined") {
|
|
3
|
+
globalThis.require = __wkfCreateRequire(import.meta.url);
|
|
4
|
+
}
|
|
5
|
+
const compiledCache = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
async function compileSource(source) {
|
|
7
|
+
const resolved = await source;
|
|
8
|
+
if (resolved instanceof WebAssembly.Module)
|
|
9
|
+
return resolved;
|
|
10
|
+
const buf = resolved;
|
|
11
|
+
const cacheKey = buf.buffer instanceof ArrayBuffer ? buf.buffer : buf;
|
|
12
|
+
const cached = compiledCache.get(cacheKey);
|
|
13
|
+
if (cached)
|
|
14
|
+
return cached;
|
|
15
|
+
const compiled = await WebAssembly.compile(buf);
|
|
16
|
+
compiledCache.set(cacheKey, compiled);
|
|
17
|
+
return compiled;
|
|
18
|
+
}
|
|
19
|
+
const BUF_LAYOUT = {
|
|
20
|
+
src: 0,
|
|
21
|
+
srcSize: 4,
|
|
22
|
+
srcPos: 8,
|
|
23
|
+
dst: 12,
|
|
24
|
+
dstSize: 16,
|
|
25
|
+
dstPos: 20,
|
|
26
|
+
SIZE: 24
|
|
27
|
+
};
|
|
28
|
+
function readCString(memory, ptr) {
|
|
29
|
+
const bytes = new Uint8Array(memory.buffer, ptr);
|
|
30
|
+
let end = 0;
|
|
31
|
+
while (bytes[end] !== 0 && end < bytes.length)
|
|
32
|
+
end++;
|
|
33
|
+
return new TextDecoder().decode(bytes.subarray(0, end));
|
|
34
|
+
}
|
|
35
|
+
class ZstdDecoder {
|
|
36
|
+
constructor(exports, dctxPtr, inPtr, inCap, outPtr, outCap, bufPtr) {
|
|
37
|
+
this.exports = exports;
|
|
38
|
+
this.dctxPtr = dctxPtr;
|
|
39
|
+
this.inPtr = inPtr;
|
|
40
|
+
this.inCap = inCap;
|
|
41
|
+
this.outPtr = outPtr;
|
|
42
|
+
this.outCap = outCap;
|
|
43
|
+
this.bufPtr = bufPtr;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Compile the bundled `zstd.wasm` (or a pre-compiled module) and
|
|
47
|
+
* return a ready-to-use `ZstdDecoder`.
|
|
48
|
+
*/
|
|
49
|
+
static async create(wasm) {
|
|
50
|
+
const module = await compileSource(wasm);
|
|
51
|
+
const instance = await WebAssembly.instantiate(module, {});
|
|
52
|
+
const exports = instance.exports;
|
|
53
|
+
const dctxPtr = exports.dctx_new();
|
|
54
|
+
if (!dctxPtr)
|
|
55
|
+
throw new Error("zstd: failed to allocate decompression context");
|
|
56
|
+
const inCap = exports.dstream_in_size();
|
|
57
|
+
const outCap = exports.dstream_out_size();
|
|
58
|
+
const inPtr = exports.zstd_malloc(inCap);
|
|
59
|
+
const outPtr = exports.zstd_malloc(outCap);
|
|
60
|
+
const bufPtr = exports.zstd_malloc(BUF_LAYOUT.SIZE);
|
|
61
|
+
if (!inPtr || !outPtr || !bufPtr) {
|
|
62
|
+
throw new Error("zstd: failed to allocate streaming buffers");
|
|
63
|
+
}
|
|
64
|
+
return new ZstdDecoder(exports, dctxPtr, inPtr, inCap, outPtr, outCap, bufPtr);
|
|
65
|
+
}
|
|
66
|
+
dispose() {
|
|
67
|
+
if (!this.dctxPtr)
|
|
68
|
+
return;
|
|
69
|
+
const e = this.exports;
|
|
70
|
+
e.dctx_free(this.dctxPtr);
|
|
71
|
+
e.zstd_free(this.inPtr);
|
|
72
|
+
e.zstd_free(this.outPtr);
|
|
73
|
+
e.zstd_free(this.bufPtr);
|
|
74
|
+
this.dctxPtr = 0;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get a fresh `Uint8Array` view of WASM linear memory.
|
|
78
|
+
*
|
|
79
|
+
* IMPORTANT: any call into WASM may grow `memory.buffer`, which
|
|
80
|
+
* detaches all existing `ArrayBuffer`-backed views. Always
|
|
81
|
+
* re-acquire views from this getter (and `bufView`) AFTER each
|
|
82
|
+
* WASM call rather than caching them.
|
|
83
|
+
*/
|
|
84
|
+
get heap() {
|
|
85
|
+
return new Uint8Array(this.exports.memory.buffer);
|
|
86
|
+
}
|
|
87
|
+
get bufView() {
|
|
88
|
+
return new DataView(this.exports.memory.buffer, this.bufPtr, BUF_LAYOUT.SIZE);
|
|
89
|
+
}
|
|
90
|
+
checkError(ret) {
|
|
91
|
+
if (this.exports.is_error(ret) !== 0) {
|
|
92
|
+
const name = readCString(this.exports.memory, this.exports.get_error_name(ret));
|
|
93
|
+
throw new Error(`zstd: ${name} (code ${ret})`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Feed `chunk` to the decoder and pull out as much decoded data
|
|
98
|
+
* as fits in our output buffer. Calls `onOutput` zero or more
|
|
99
|
+
* times with non-empty `Uint8Array` slices into the WASM memory.
|
|
100
|
+
*
|
|
101
|
+
* IMPORTANT: the slices passed to `onOutput` are views into WASM
|
|
102
|
+
* memory and are only valid until the next decoder call. Callers
|
|
103
|
+
* that need to keep the data must copy it (`.slice()` or
|
|
104
|
+
* `.set()` into their own buffer).
|
|
105
|
+
*/
|
|
106
|
+
push(chunk, onOutput) {
|
|
107
|
+
const e = this.exports;
|
|
108
|
+
let chunkOffset = 0;
|
|
109
|
+
while (chunkOffset < chunk.length) {
|
|
110
|
+
const copyLen = Math.min(chunk.length - chunkOffset, this.inCap);
|
|
111
|
+
this.heap.set(chunk.subarray(chunkOffset, chunkOffset + copyLen), this.inPtr);
|
|
112
|
+
chunkOffset += copyLen;
|
|
113
|
+
let srcPos = 0;
|
|
114
|
+
while (srcPos < copyLen) {
|
|
115
|
+
let view = this.bufView;
|
|
116
|
+
view.setUint32(BUF_LAYOUT.src, this.inPtr, true);
|
|
117
|
+
view.setUint32(BUF_LAYOUT.srcSize, copyLen, true);
|
|
118
|
+
view.setUint32(BUF_LAYOUT.srcPos, srcPos, true);
|
|
119
|
+
view.setUint32(BUF_LAYOUT.dst, this.outPtr, true);
|
|
120
|
+
view.setUint32(BUF_LAYOUT.dstSize, this.outCap, true);
|
|
121
|
+
view.setUint32(BUF_LAYOUT.dstPos, 0, true);
|
|
122
|
+
const ret = e.decompress_stream(this.dctxPtr, this.bufPtr);
|
|
123
|
+
this.checkError(ret);
|
|
124
|
+
view = this.bufView;
|
|
125
|
+
const dstPos = view.getUint32(BUF_LAYOUT.dstPos, true);
|
|
126
|
+
if (dstPos > 0) {
|
|
127
|
+
onOutput(this.heap.subarray(this.outPtr, this.outPtr + dstPos));
|
|
128
|
+
}
|
|
129
|
+
const newSrcPos = view.getUint32(BUF_LAYOUT.srcPos, true);
|
|
130
|
+
if (newSrcPos === srcPos && dstPos === 0) {
|
|
131
|
+
throw new Error("zstd: decoder made no progress");
|
|
132
|
+
}
|
|
133
|
+
srcPos = newSrcPos;
|
|
134
|
+
if (ret === 0 && srcPos === copyLen)
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Decompress an entire compressed buffer in one shot. Convenient
|
|
141
|
+
* for small inputs; large inputs should prefer
|
|
142
|
+
* `ZstdDecompressStream` to avoid buffering everything in memory.
|
|
143
|
+
*/
|
|
144
|
+
decode(compressed) {
|
|
145
|
+
const out = [];
|
|
146
|
+
let total = 0;
|
|
147
|
+
this.push(compressed, (chunk) => {
|
|
148
|
+
const copy = new Uint8Array(chunk);
|
|
149
|
+
out.push(copy);
|
|
150
|
+
total += copy.length;
|
|
151
|
+
});
|
|
152
|
+
const result = new Uint8Array(total);
|
|
153
|
+
let off = 0;
|
|
154
|
+
for (const c of out) {
|
|
155
|
+
result.set(c, off);
|
|
156
|
+
off += c.length;
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
class ZstdDecompressStream extends TransformStream {
|
|
162
|
+
constructor(wasm) {
|
|
163
|
+
let decoderPromise = null;
|
|
164
|
+
const getDecoder = () => {
|
|
165
|
+
if (!decoderPromise)
|
|
166
|
+
decoderPromise = ZstdDecoder.create(wasm);
|
|
167
|
+
return decoderPromise;
|
|
168
|
+
};
|
|
169
|
+
super({
|
|
170
|
+
async transform(chunk, controller) {
|
|
171
|
+
try {
|
|
172
|
+
const dec = await getDecoder();
|
|
173
|
+
dec.push(chunk, (out) => {
|
|
174
|
+
controller.enqueue(new Uint8Array(out));
|
|
175
|
+
});
|
|
176
|
+
} catch (err) {
|
|
177
|
+
controller.error(err);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
async flush() {
|
|
181
|
+
if (decoderPromise) {
|
|
182
|
+
try {
|
|
183
|
+
const dec = await decoderPromise;
|
|
184
|
+
dec.dispose();
|
|
185
|
+
} catch {
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async function decompressBytes(wasm, compressed) {
|
|
193
|
+
const dec = await ZstdDecoder.create(wasm);
|
|
194
|
+
try {
|
|
195
|
+
return dec.decode(compressed);
|
|
196
|
+
} finally {
|
|
197
|
+
dec.dispose();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
ZstdDecoder,
|
|
202
|
+
ZstdDecompressStream,
|
|
203
|
+
decompressBytes
|
|
204
|
+
};
|