peachsim 0.1.2438 → 0.1.2439

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.
Files changed (175) hide show
  1. package/README.md +30 -98
  2. package/cli/app-catalog.ts +4 -73
  3. package/cli/catalog/content.ts +1 -1
  4. package/cli/cloud-box-artifact.ts +26 -39
  5. package/cli/cloud-client.ts +69 -117
  6. package/cli/cloud-session.ts +2 -9
  7. package/cli/commands/box.ts +6 -6
  8. package/cli/commands/control.ts +4 -11
  9. package/cli/commands/flow.ts +5 -9
  10. package/cli/commands/kotlin.ts +2 -1
  11. package/cli/commands/platform.ts +21 -39
  12. package/cli/commands/record-three.ts +1 -1
  13. package/cli/commands/shell-url.ts +29 -23
  14. package/cli/dev-build-freshness.ts +4 -3
  15. package/cli/native-input.ts +2 -2
  16. package/cli/outbound-endpoints.ts +20 -45
  17. package/cli/remote-project-bundle.ts +8 -14
  18. package/cli/remote-simulators.ts +1 -1
  19. package/cli/send-to-box.ts +2 -1
  20. package/detox/jest-preset.cjs +1 -1
  21. package/detox/jest-transform.cjs +40 -2
  22. package/dist-lib/agent-daemon-client.cjs +34 -24
  23. package/dist-lib/agent-events.cjs +1 -1
  24. package/dist-lib/attached-projects.cjs +19 -17
  25. package/dist-lib/auth/shared-session.cjs +18 -16
  26. package/dist-lib/backend-origin.cjs +1 -1
  27. package/dist-lib/beta.cjs +1 -1
  28. package/dist-lib/beta.mjs +2 -1
  29. package/dist-lib/bridge-constants.cjs +1 -1
  30. package/dist-lib/bridge-contract-input.cjs +1 -1
  31. package/dist-lib/bridge-contract-input.mjs +20 -583
  32. package/dist-lib/bridge-contract.cjs +1 -1
  33. package/dist-lib/bridge-contract.mjs +17 -99
  34. package/dist-lib/bundle-channel.cjs +8718 -5552
  35. package/dist-lib/capture-contract.cjs +1 -1
  36. package/dist-lib/capture-contract.mjs +13 -363
  37. package/dist-lib/cloud-contract.cjs +1 -1
  38. package/dist-lib/cloud-contract.mjs +34 -155
  39. package/dist-lib/cloud-test-args.cjs +1 -1
  40. package/dist-lib/cloud-test-args.mjs +2 -1
  41. package/dist-lib/cloud.cjs +1 -1
  42. package/dist-lib/cloud.mjs +26 -155
  43. package/dist-lib/config.cjs +1 -4
  44. package/dist-lib/config.mjs +11 -30
  45. package/dist-lib/detox/index.cjs +2554 -230
  46. package/dist-lib/detox/jest-preset.cjs +1 -1
  47. package/dist-lib/detox/jest-transform.cjs +40 -2
  48. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  49. package/dist-lib/esm-chunks/acorn-FGE4PYDJ.mjs +50 -0
  50. package/dist-lib/esm-chunks/chunk-2EUHEBIJ.mjs +664 -0
  51. package/dist-lib/esm-chunks/chunk-2NPABFPN.mjs +5719 -0
  52. package/dist-lib/esm-chunks/chunk-4ZFNH7TU.mjs +10 -0
  53. package/dist-lib/esm-chunks/chunk-5T4XBUJP.mjs +1353 -0
  54. package/dist-lib/esm-chunks/chunk-6VY6HTJC.mjs +18951 -0
  55. package/dist-lib/esm-chunks/chunk-7HANEMO4.mjs +188 -0
  56. package/dist-lib/esm-chunks/chunk-C3WBGYP6.mjs +186 -0
  57. package/dist-lib/esm-chunks/chunk-CVGDRROP.mjs +57 -0
  58. package/dist-lib/esm-chunks/chunk-DADGQELM.mjs +375 -0
  59. package/dist-lib/esm-chunks/chunk-DEGYKHN7.mjs +12 -0
  60. package/dist-lib/esm-chunks/chunk-HIDNO3RP.mjs +10992 -0
  61. package/dist-lib/esm-chunks/chunk-HSADZOVN.mjs +30 -0
  62. package/dist-lib/esm-chunks/chunk-IWJUYJQO.mjs +42 -0
  63. package/dist-lib/esm-chunks/chunk-JCKI3VZ6.mjs +10 -0
  64. package/dist-lib/esm-chunks/chunk-KSQ5KM5Y.mjs +17 -0
  65. package/dist-lib/esm-chunks/chunk-KVTIDLBK.mjs +598 -0
  66. package/dist-lib/esm-chunks/chunk-MIQSRBVU.mjs +10 -0
  67. package/dist-lib/esm-chunks/chunk-YB27R6JG.mjs +115 -0
  68. package/dist-lib/esm-chunks/metro-layout-parser-MVUAXRUJ.mjs +58 -0
  69. package/dist-lib/expo-swift-bundle.cjs +7856 -4707
  70. package/dist-lib/expo-swift-metadata.cjs +1 -1
  71. package/dist-lib/expo-swift-metadata.mjs +16 -165
  72. package/dist-lib/home-paths.cjs +1 -1
  73. package/dist-lib/host/bridge-host.cjs +15658 -11404
  74. package/dist-lib/host/fetch-proxy-handler.cjs +3927 -342
  75. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  76. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -1
  77. package/dist-lib/host/replacement-module-handler.cjs +4 -4
  78. package/dist-lib/host/websocket-proxy.cjs +1 -1
  79. package/dist-lib/index.cjs +9145 -32150
  80. package/dist-lib/jump-to-source-babel.cjs +1 -1
  81. package/dist-lib/jump-to-source-native.cjs +2 -2
  82. package/dist-lib/kotlin-host.cjs +260 -253
  83. package/dist-lib/menu.cjs +1 -1
  84. package/dist-lib/menu.mjs +5 -13
  85. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  86. package/dist-lib/metro-fingerprint-registry.mjs +5 -6
  87. package/dist-lib/metro-production-bundle.cjs +22 -3
  88. package/dist-lib/metro-production-bundle.mjs +26 -92
  89. package/dist-lib/native-app-identity-project.cjs +663 -451
  90. package/dist-lib/native-app-identity-project.mjs +509 -2318
  91. package/dist-lib/native-app-identity.cjs +1 -1
  92. package/dist-lib/native-app-identity.mjs +27 -1340
  93. package/dist-lib/native-firebase-metadata.cjs +1 -1
  94. package/dist-lib/native-firebase-metadata.mjs +5 -18
  95. package/dist-lib/pdfium-raster.cjs +1 -1
  96. package/dist-lib/pdfium-raster.mjs +2 -1
  97. package/dist-lib/plist.cjs +2 -2
  98. package/dist-lib/plist.mjs +5 -7
  99. package/dist-lib/profiles.cjs +2 -1
  100. package/dist-lib/public-brand.cjs +1 -1
  101. package/dist-lib/public-origins-lib-esm.json +246 -187
  102. package/dist-lib/public-origins-lib-static.json +1 -1
  103. package/dist-lib/public-origins-lib.json +1059 -1238
  104. package/dist-lib/react-native-host-modules.cjs +1 -1
  105. package/dist-lib/react-native-host-modules.mjs +2 -1
  106. package/dist-lib/reap-browser.cjs +18 -7
  107. package/dist-lib/scripts/dev-server-scanner.cjs +6 -230
  108. package/dist-lib/sdk.cjs +1 -1
  109. package/dist-lib/sdk.mjs +22 -78
  110. package/dist-lib/skills.cjs +21657 -17374
  111. package/dist-lib/swift-compile.cjs +1343 -1318
  112. package/dist-lib/swift-compile.mjs +68 -19013
  113. package/dist-lib/swift-package.cjs +1 -1
  114. package/dist-lib/swift-package.mjs +35 -630
  115. package/dist-lib/swift-submit.cjs +1 -1
  116. package/dist-lib/swift-submit.mjs +9 -24
  117. package/dist-lib/swift-toolchain.cjs +1 -1
  118. package/dist-lib/swift.cjs +1 -1
  119. package/dist-lib/vendor/@peculiar/x509.cjs +18061 -0
  120. package/dist-lib/vendor/acorn.cjs +5699 -0
  121. package/dist-lib/vendor/bplist-parser.cjs +1589 -0
  122. package/dist-lib/vendor/ignore.cjs +455 -0
  123. package/dist-lib/vendor/magic-string.cjs +1693 -0
  124. package/dist-lib/vendor/plist.cjs +10978 -0
  125. package/dist-lib/vendor/smol-toml.cjs +768 -0
  126. package/dist-lib/vendor/stream-json.cjs +1997 -0
  127. package/dist-lib/vendor/sucrase/dist/index.js.cjs +23593 -0
  128. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +15750 -0
  129. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +11316 -0
  130. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +482 -0
  131. package/dist-lib/vendor/sucrase.cjs +23593 -0
  132. package/dist-lib/vendor/terser.cjs +36874 -0
  133. package/dist-lib/vendor/valibot.cjs +6253 -0
  134. package/dist-lib/vendor/zod.cjs +23262 -0
  135. package/dist-lib/worklet-executable.cjs +3 -3
  136. package/dist-lib/worklet-executable.mjs +11 -16
  137. package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
  138. package/kotlin/fork/NOTICE +3 -0
  139. package/kotlin/sdk.tar.gz +0 -0
  140. package/kotlin/toolchain.json +6 -6
  141. package/package.json +17 -121
  142. package/runtime-companion.json +1 -1
  143. package/scripts/dev-server-scanner.ts +13 -223
  144. package/src/android-autolinking.ts +2 -2
  145. package/src/bundle-channel.mjs +3 -15
  146. package/src/cloud-contract.ts +3 -4
  147. package/src/config.ts +0 -5
  148. package/src/host/bridge-host.ts +19 -1
  149. package/src/host/server-scan-handler.ts +1 -9
  150. package/src/index.ts +0 -2
  151. package/src/kotlin-host.ts +1 -2
  152. package/src/kotlinDiscoveryContract.ts +1 -0
  153. package/src/metro-production-bundle.ts +28 -6
  154. package/src/native-seam-manifest.ts +0 -13
  155. package/src/one-native-app-catalog.ts +8 -27
  156. package/src/one-native-app-config.ts +95 -0
  157. package/src/one-native-source.ts +250 -0
  158. package/src/one-widget-metadata.ts +45 -126
  159. package/src/oneWidgetContract.ts +80 -117
  160. package/src/serverDiscoveryContract.ts +0 -1
  161. package/src/simulator-route.ts +8 -0
  162. package/src/vite-plugin.ts +2 -2
  163. package/src/xcode-project.ts +1 -1
  164. package/dist-lib/metro.cjs +0 -27984
  165. package/dist-lib/vite-swift.cjs +0 -43376
  166. package/dist-lib/vite.cjs +0 -21456
  167. package/src/androidAutolinkingContract.ts +0 -48
  168. package/src/androidRootModuleContract.ts +0 -39
  169. package/src/dev-server-open.ts +0 -92
  170. package/src/metro-plugin.ts +0 -578
  171. package/src/one-widget-discovery.ts +0 -23
  172. package/src/swift-vite-lifetime.ts +0 -42
  173. package/src/vite-plugin-one.ts +0 -746
  174. package/src/vite-plugin-swift.ts +0 -225
  175. package/src/vite.d.ts +0 -10
@@ -0,0 +1,1997 @@
1
+ /*! peach v0.1.2439 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
+ let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // ../../node_modules/stream-json/src/index.js
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ default: () => src_default2,
35
+ parser: () => parser_default2,
36
+ parserStream: () => parserStream
37
+ });
38
+ module.exports = __toCommonJS(src_exports);
39
+
40
+ // ../../node_modules/stream-chain/src/index.js
41
+ var import_node_stream2 = require("node:stream");
42
+
43
+ // ../../node_modules/stream-chain/src/defs.js
44
+ var defs_exports = {};
45
+ __export(defs_exports, {
46
+ Stop: () => Stop,
47
+ abortSymbol: () => abortSymbol,
48
+ clearFunctionList: () => clearFunctionList,
49
+ combineMany: () => combineMany,
50
+ combineManyMut: () => combineManyMut,
51
+ fListSymbol: () => fListSymbol,
52
+ final: () => final,
53
+ finalSymbol: () => finalSymbol,
54
+ finalValue: () => finalValue,
55
+ flushSymbol: () => flushSymbol,
56
+ flushable: () => flushable,
57
+ getFinalValue: () => getFinalValue,
58
+ getFunctionList: () => getFunctionList,
59
+ getManyValues: () => getManyValues,
60
+ isDuplexNodeStream: () => isDuplexNodeStream,
61
+ isDuplexWebStream: () => isDuplexWebStream,
62
+ isFinalValue: () => isFinalValue,
63
+ isFlushable: () => isFlushable,
64
+ isFunctionList: () => isFunctionList,
65
+ isMany: () => isMany,
66
+ isReadableNodeStream: () => isReadableNodeStream,
67
+ isReadableWebStream: () => isReadableWebStream,
68
+ isStop: () => isStop,
69
+ isWritableNodeStream: () => isWritableNodeStream,
70
+ isWritableWebStream: () => isWritableWebStream,
71
+ many: () => many,
72
+ manySymbol: () => manySymbol,
73
+ none: () => none,
74
+ normalizeMany: () => normalizeMany,
75
+ setFunctionList: () => setFunctionList,
76
+ stop: () => stop,
77
+ stopErrorSymbol: () => stopErrorSymbol,
78
+ toMany: () => toMany
79
+ });
80
+ var none = Symbol.for("object-stream.none");
81
+ var stop = Symbol.for("object-stream.stop");
82
+ var finalSymbol = Symbol.for("object-stream.final");
83
+ var manySymbol = Symbol.for("object-stream.many");
84
+ var flushSymbol = Symbol.for("object-stream.flush");
85
+ var abortSymbol = Symbol.for("object-stream.abort");
86
+ var fListSymbol = Symbol.for("object-stream.fList");
87
+ var stopErrorSymbol = Symbol.for("object-stream.stopError");
88
+ var finalValue = (value) => ({ [finalSymbol]: 1, value });
89
+ var many = (values) => ({ [manySymbol]: 1, values });
90
+ var isFinalValue = (o) => o && o[finalSymbol] === 1;
91
+ var isMany = (o) => o && o[manySymbol] === 1;
92
+ var isFlushable = (o) => o && o[flushSymbol] === 1;
93
+ var isFunctionList = (o) => o && o[fListSymbol] === 1;
94
+ var isStop = (o) => o && o[stopErrorSymbol] === 1;
95
+ var getFinalValue = (o) => o.value;
96
+ var getManyValues = (o) => o.values;
97
+ var getFunctionList = (o) => o.fList;
98
+ var flushable = (write2, final3 = null, abort = null) => {
99
+ const fn = final3 ? (value) => value === none ? final3() : write2(value) : write2;
100
+ fn[flushSymbol] = 1;
101
+ if (abort) fn[abortSymbol] = abort;
102
+ return fn;
103
+ };
104
+ var setFunctionList = (o, fns) => {
105
+ o.fList = fns;
106
+ o[fListSymbol] = 1;
107
+ return o;
108
+ };
109
+ var clearFunctionList = (o) => {
110
+ delete o.fList;
111
+ delete o[fListSymbol];
112
+ return o;
113
+ };
114
+ var Stop = class extends Error {
115
+ };
116
+ Stop.prototype[stopErrorSymbol] = 1;
117
+ var toMany = (value) => value === none ? many([]) : value && value[manySymbol] === 1 ? value : many([value]);
118
+ var normalizeMany = (o) => {
119
+ if (o?.[manySymbol] === 1) {
120
+ switch (o.values.length) {
121
+ case 0:
122
+ return none;
123
+ case 1:
124
+ return o.values[0];
125
+ }
126
+ }
127
+ return o;
128
+ };
129
+ var combineMany = (...args) => {
130
+ const values = [];
131
+ for (let i = 0; i < args.length; ++i) {
132
+ const a = args[i];
133
+ if (a === none) continue;
134
+ if (a?.[manySymbol] === 1) {
135
+ values.push(...a.values);
136
+ } else {
137
+ values.push(a);
138
+ }
139
+ }
140
+ return many(values);
141
+ };
142
+ var combineManyMut = (a, ...args) => {
143
+ const values = a === none ? [] : a?.[manySymbol] === 1 ? a.values : [a];
144
+ for (let i = 0; i < args.length; ++i) {
145
+ const b = args[i];
146
+ if (b === none) continue;
147
+ if (b?.[manySymbol] === 1) {
148
+ values.push(...b.values);
149
+ } else {
150
+ values.push(b);
151
+ }
152
+ }
153
+ return many(values);
154
+ };
155
+ var isReadableWebStream = (x) => !!(x && typeof x === "object" && typeof x.getReader === "function" && typeof x.pipeTo === "function");
156
+ var isWritableWebStream = (x) => !!(x && typeof x === "object" && typeof x.getWriter === "function" && typeof x.abort === "function");
157
+ var isDuplexWebStream = (x) => !!(x && typeof x === "object" && isReadableWebStream(x.readable) && isWritableWebStream(x.writable));
158
+ var isReadableNodeStream = (obj) => obj && typeof obj.pipe === "function" && typeof obj.on === "function" && (!obj._writableState || (typeof obj._readableState === "object" ? obj._readableState.readable : null) !== false) && (!obj._writableState || obj._readableState);
159
+ var isWritableNodeStream = (obj) => obj && typeof obj.write === "function" && typeof obj.on === "function" && (!obj._readableState || (typeof obj._writableState === "object" ? obj._writableState.writable : null) !== false);
160
+ var isDuplexNodeStream = (obj) => obj && typeof obj.pipe === "function" && obj._readableState && typeof obj.on === "function" && typeof obj.write === "function";
161
+ var final = finalValue;
162
+
163
+ // ../../node_modules/stream-chain/src/exec.js
164
+ var cancelSymbol = Symbol.for("object-stream.cancel");
165
+ var dropNullSymbol = Symbol.for("object-stream.dropNull");
166
+ var pipeRunSymbol = Symbol.for("object-stream.pipeRun");
167
+ var stopAtSymbol = Symbol.for("object-stream.stopAt");
168
+ var GEN_CANCEL = Symbol.for("object-stream.genCancel");
169
+ var markStop = (error, index) => {
170
+ if (isStop(error)) error[stopAtSymbol] = index;
171
+ throw error;
172
+ };
173
+ var stopIndex = (stop2, fns) => stop2[stopAtSymbol] ?? fns.length;
174
+ var withCleanupError = (err, cleanupErr) => {
175
+ if (err == null || isStop(err)) return cleanupErr;
176
+ return err instanceof Error ? new AggregateError([err, cleanupErr], "pipeline error; generator cleanup also failed") : err;
177
+ };
178
+ var hasAborters = (fns) => fns.some((fn) => fn[abortSymbol]);
179
+ var noteFinal = (value, fn, finished) => {
180
+ if (value && typeof value.then == "function") return value.then((v) => (finished.add(fn), v));
181
+ finished.add(fn);
182
+ return value;
183
+ };
184
+ var abortStages = async (fns, finished, to = fns.length) => {
185
+ let failure;
186
+ for (let i = 0; i < to; ++i) {
187
+ const fn = fns[i], abort = fn[abortSymbol];
188
+ if (!abort || finished.has(fn)) continue;
189
+ finished.add(fn);
190
+ try {
191
+ await abort();
192
+ } catch (error) {
193
+ failure = failure === void 0 ? error : new AggregateError([failure, error], "stage cleanup failed more than once");
194
+ }
195
+ }
196
+ return failure;
197
+ };
198
+ var next = (value, fns, index, push) => {
199
+ for (let i = index; ; ) {
200
+ if (value && typeof value.then == "function") {
201
+ const ii = i;
202
+ return value.then(
203
+ (v) => next(v, fns, ii, push),
204
+ (e) => markStop(e, ii)
205
+ );
206
+ }
207
+ if (value === none || value == null && push[dropNullSymbol]) return void 0;
208
+ if (value === stop) markStop(new Stop(), i);
209
+ if (isFinalValue(value)) {
210
+ const final3 = getFinalValue(value);
211
+ if (final3 == null && push[dropNullSymbol]) return void 0;
212
+ return push(final3);
213
+ }
214
+ if (isMany(value)) {
215
+ return nextMany(getManyValues(value), fns, i, push);
216
+ }
217
+ if (value && typeof value.next == "function") {
218
+ return nextGen(value, fns, i, push);
219
+ }
220
+ if (i >= fns.length) {
221
+ return push(value);
222
+ }
223
+ try {
224
+ value = fns[i++](value);
225
+ } catch (error) {
226
+ markStop(error, i);
227
+ }
228
+ }
229
+ };
230
+ var nextMany = (values, fns, i, push) => {
231
+ const step = (j) => {
232
+ for (; j < values.length; ++j) {
233
+ const r = next(values[j], fns, i, push);
234
+ if (r && typeof r.then == "function") {
235
+ const jj = j;
236
+ return r.then(() => step(jj + 1));
237
+ }
238
+ }
239
+ };
240
+ return step(0);
241
+ };
242
+ var nextGen = (it, fns, i, push) => {
243
+ const step = () => {
244
+ for (; ; ) {
245
+ if (push[cancelSymbol]) throw push[cancelSymbol];
246
+ let data;
247
+ try {
248
+ data = it.next();
249
+ } catch (error) {
250
+ markStop(error, i);
251
+ }
252
+ if (data && typeof data.then == "function") {
253
+ return data.then(
254
+ (d) => {
255
+ if (d.done) return;
256
+ const r3 = next(d.value, fns, i, push);
257
+ return r3 && typeof r3.then == "function" ? r3.then(step) : step();
258
+ },
259
+ (e) => markStop(e, i)
260
+ );
261
+ }
262
+ if (data.done) return;
263
+ const r2 = next(data.value, fns, i, push);
264
+ if (r2 && typeof r2.then == "function") return r2.then(step);
265
+ }
266
+ };
267
+ const abort = (err) => {
268
+ const onCleanupError = (cleanupErr) => withCleanupError(err, cleanupErr);
269
+ let ret;
270
+ try {
271
+ ret = it.return ? it.return() : void 0;
272
+ } catch (cleanupErr) {
273
+ throw onCleanupError(cleanupErr);
274
+ }
275
+ if (ret && typeof ret.then == "function") {
276
+ return ret.then(
277
+ () => {
278
+ throw err;
279
+ },
280
+ (cleanupErr) => {
281
+ throw onCleanupError(cleanupErr);
282
+ }
283
+ );
284
+ }
285
+ throw err;
286
+ };
287
+ let r;
288
+ try {
289
+ r = step();
290
+ } catch (err) {
291
+ return abort(err);
292
+ }
293
+ return r && typeof r.then == "function" ? r.then(void 0, abort) : r;
294
+ };
295
+ var flush = (fns, index, push, finished) => {
296
+ let stop2 = null;
297
+ const resume = (error) => {
298
+ if (!isStop(error)) throw error;
299
+ stop2 = error;
300
+ return step(stopIndex(error, fns));
301
+ };
302
+ const step = (i) => {
303
+ for (; i < fns.length; ++i) {
304
+ const f = fns[i];
305
+ if (!isFlushable(f) || finished?.has(f)) continue;
306
+ let r;
307
+ try {
308
+ let value;
309
+ try {
310
+ value = f(none);
311
+ } catch (error) {
312
+ markStop(error, i + 1);
313
+ }
314
+ if (finished) value = noteFinal(value, f, finished);
315
+ r = next(value, fns, i + 1, push);
316
+ } catch (error) {
317
+ return resume(error);
318
+ }
319
+ if (r && typeof r.then == "function") {
320
+ const ii = i;
321
+ return r.then(() => step(ii + 1), resume);
322
+ }
323
+ }
324
+ if (stop2) throw stop2;
325
+ };
326
+ return step(index);
327
+ };
328
+ var releaseStopped = async (fns, finished, stop2) => {
329
+ const failure = await abortStages(fns, finished, stopIndex(stop2, fns));
330
+ if (failure === void 0) return void 0;
331
+ const more = await abortStages(fns, finished);
332
+ return more === void 0 ? failure : new AggregateError([failure, more], "stage cleanup failed more than once");
333
+ };
334
+ var finishStop = async (fns, stop2, push, finished) => {
335
+ let error;
336
+ try {
337
+ await flush(fns, stopIndex(stop2, fns), push, finished);
338
+ } catch (e) {
339
+ if (isStop(e)) stop2 = e;
340
+ else error = e;
341
+ }
342
+ const failure = error === void 0 ? await releaseStopped(fns, finished, stop2) : await abortStages(fns, finished);
343
+ if (failure !== void 0) error = withCleanupError(error, failure);
344
+ if (error !== void 0) throw error;
345
+ };
346
+ var genBridge = (fns, once) => {
347
+ fns = fns.filter((fn) => fn).flat(Infinity).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
348
+ if (!fns.length) {
349
+ fns = [(x) => x];
350
+ }
351
+ const canAbort = hasAborters(fns), finished = /* @__PURE__ */ new Set();
352
+ let flushed = false, stopAt = 0;
353
+ const drive = async (value, push) => {
354
+ try {
355
+ await next(value, fns, 0, push);
356
+ } catch (error) {
357
+ if (!isStop(error)) throw error;
358
+ await finishStop(fns, error, push, finished);
359
+ throw error;
360
+ }
361
+ await flush(fns, 0, push, finished);
362
+ };
363
+ let g = async function* (value) {
364
+ if (flushed) throw Error("Call to a flushed pipe.");
365
+ const isFlush = !once && value === none;
366
+ if (isFlush || once) flushed = true;
367
+ const pending = [];
368
+ let wakeConsumer = null;
369
+ let resolveProducer = null;
370
+ let rejectProducer = null;
371
+ let done = false, error = null, cancelled = false, completed = false;
372
+ const push = (v) => {
373
+ if (cancelled) throw GEN_CANCEL;
374
+ pending.push(v);
375
+ if (wakeConsumer) {
376
+ const w = wakeConsumer;
377
+ wakeConsumer = null;
378
+ w();
379
+ }
380
+ return new Promise((res, rej) => {
381
+ resolveProducer = res;
382
+ rejectProducer = rej;
383
+ });
384
+ };
385
+ Promise.resolve().then(
386
+ () => once ? drive(value, push) : isFlush ? flush(fns, stopAt, push, finished) : next(value, fns, 0, push)
387
+ ).then(
388
+ () => {
389
+ },
390
+ (e) => {
391
+ if (e === GEN_CANCEL) return;
392
+ error = e;
393
+ if (!isFlush && isStop(e)) stopAt = stopIndex(e, fns);
394
+ }
395
+ ).finally(() => {
396
+ done = true;
397
+ if (wakeConsumer) {
398
+ const w = wakeConsumer;
399
+ wakeConsumer = null;
400
+ w();
401
+ }
402
+ });
403
+ try {
404
+ for (; ; ) {
405
+ while (pending.length) {
406
+ const v = pending.shift();
407
+ if (resolveProducer) {
408
+ const r = resolveProducer;
409
+ resolveProducer = rejectProducer = null;
410
+ r();
411
+ }
412
+ yield v;
413
+ }
414
+ if (error) throw error;
415
+ if (done) {
416
+ completed = true;
417
+ return;
418
+ }
419
+ await new Promise((res) => wakeConsumer = res);
420
+ }
421
+ } finally {
422
+ cancelled = true;
423
+ push[cancelSymbol] = GEN_CANCEL;
424
+ if (rejectProducer) {
425
+ const rj = rejectProducer;
426
+ resolveProducer = rejectProducer = null;
427
+ rj(GEN_CANCEL);
428
+ }
429
+ if (!completed && canAbort) {
430
+ const failure = isStop(error) ? await releaseStopped(fns, finished, error) : await abortStages(fns, finished);
431
+ if (failure !== void 0) throw withCleanupError(error, failure);
432
+ }
433
+ }
434
+ };
435
+ if (once) return g;
436
+ const needToFlush = fns.some((fn) => isFlushable(fn));
437
+ if (needToFlush) g = flushable(g);
438
+ return setFunctionList(g, fns);
439
+ };
440
+
441
+ // ../../node_modules/stream-chain/src/gen.js
442
+ var gen = (...fns) => genBridge(fns, false);
443
+ var gen_default = gen;
444
+
445
+ // ../../node_modules/stream-chain/src/asStream.js
446
+ var import_node_stream = require("node:stream");
447
+ var CANCEL = Symbol.for("object-stream.asStreamCancel");
448
+ var asStream = (fn, options) => {
449
+ if (typeof fn != "function") {
450
+ throw TypeError("Only a function is accepted as the first argument");
451
+ }
452
+ const innerFns = isFunctionList(fn) ? fn.fList : null;
453
+ const stages = innerFns ?? [fn];
454
+ const canAbort = hasAborters(stages), finished = /* @__PURE__ */ new Set();
455
+ let stopped = false;
456
+ let destroyed = false;
457
+ let flushed = false;
458
+ let nullPushed = false;
459
+ let resolvePaused = null;
460
+ let rejectPaused = null;
461
+ let stream = null;
462
+ const resume = () => {
463
+ if (!resolvePaused) return;
464
+ const resolve = resolvePaused;
465
+ resolvePaused = rejectPaused = null;
466
+ resolve();
467
+ };
468
+ const cancelPaused = () => {
469
+ if (!rejectPaused) return;
470
+ const reject = rejectPaused;
471
+ resolvePaused = rejectPaused = null;
472
+ reject(CANCEL);
473
+ };
474
+ const signalEnd = () => {
475
+ if (nullPushed) return;
476
+ nullPushed = true;
477
+ stream.push(null);
478
+ };
479
+ const enqueue = (value) => {
480
+ if (destroyed) throw CANCEL;
481
+ if (nullPushed) return;
482
+ if (!stream.push(value)) {
483
+ return new Promise((resolve, reject) => {
484
+ resolvePaused = resolve;
485
+ rejectPaused = reject;
486
+ });
487
+ }
488
+ };
489
+ enqueue[dropNullSymbol] = true;
490
+ const queue = [];
491
+ const pump = async () => {
492
+ while (queue.length) {
493
+ if (destroyed) throw CANCEL;
494
+ const g = queue[queue.length - 1];
495
+ let result = g.next();
496
+ if (result && typeof result.then == "function") result = await result;
497
+ if (result.done) {
498
+ queue.pop();
499
+ continue;
500
+ }
501
+ let value = result.value;
502
+ if (value && typeof value.then == "function") value = await value;
503
+ const r = processValue(value);
504
+ if (r) await r;
505
+ }
506
+ };
507
+ const release = async (error) => {
508
+ while (queue.length) {
509
+ const g = queue.pop();
510
+ try {
511
+ if (g.return) await g.return();
512
+ } catch (cleanupErr) {
513
+ error = withCleanupError(error, cleanupErr);
514
+ }
515
+ }
516
+ throw error;
517
+ };
518
+ const processValue = (value) => {
519
+ if (value && typeof value.then == "function") {
520
+ return value.then(processValue);
521
+ }
522
+ if (value == null || value === none) return;
523
+ if (value === stop) throw new Stop();
524
+ if (isMany(value)) {
525
+ const values = getManyValues(value);
526
+ let promise;
527
+ for (let i = 0; i < values.length; ++i) {
528
+ if (promise) {
529
+ const ii = i;
530
+ promise = promise.then(() => processValue(values[ii]));
531
+ } else {
532
+ const r = processValue(values[i]);
533
+ if (r) promise = r;
534
+ }
535
+ }
536
+ return promise;
537
+ }
538
+ if (isFinalValue(value)) {
539
+ return processValue(getFinalValue(value));
540
+ }
541
+ if (value && typeof value.next == "function") {
542
+ queue.push(value);
543
+ return pump().catch(release);
544
+ }
545
+ return enqueue(value);
546
+ };
547
+ const finishWrite = (callback, error) => {
548
+ if (!error || error === CANCEL) {
549
+ callback(null);
550
+ } else if (!isStop(error)) {
551
+ callback(error);
552
+ } else {
553
+ stopped = true;
554
+ finishStop(stages, error, enqueue, finished).then(
555
+ () => {
556
+ flushed = true;
557
+ signalEnd();
558
+ callback(null);
559
+ },
560
+ (failure) => callback(failure)
561
+ );
562
+ }
563
+ };
564
+ stream = new import_node_stream.Duplex({
565
+ writableObjectMode: true,
566
+ readableObjectMode: true,
567
+ ...options,
568
+ write(chunk, encoding, callback) {
569
+ if (stopped) return callback(null);
570
+ if (innerFns) {
571
+ let r2;
572
+ try {
573
+ r2 = next(chunk, innerFns, 0, enqueue);
574
+ } catch (error) {
575
+ return finishWrite(callback, error);
576
+ }
577
+ if (r2 && typeof r2.then == "function") {
578
+ r2.then(
579
+ () => callback(null),
580
+ (error) => finishWrite(callback, error)
581
+ );
582
+ } else {
583
+ callback(null);
584
+ }
585
+ return;
586
+ }
587
+ let r;
588
+ try {
589
+ r = processValue(fn(chunk, encoding));
590
+ } catch (error) {
591
+ return finishWrite(callback, error);
592
+ }
593
+ if (r) {
594
+ r.then(
595
+ () => callback(null),
596
+ (error) => finishWrite(callback, error)
597
+ );
598
+ } else {
599
+ callback(null);
600
+ }
601
+ },
602
+ final(callback) {
603
+ const onComplete = () => {
604
+ flushed = true;
605
+ signalEnd();
606
+ callback(null);
607
+ };
608
+ if (stopped) {
609
+ onComplete();
610
+ return;
611
+ }
612
+ if (innerFns) {
613
+ let r2;
614
+ try {
615
+ r2 = flush(innerFns, 0, enqueue, finished);
616
+ } catch (error) {
617
+ return finishWrite(callback, error);
618
+ }
619
+ if (r2 && typeof r2.then == "function") {
620
+ r2.then(onComplete, (error) => finishWrite(callback, error));
621
+ } else {
622
+ onComplete();
623
+ }
624
+ return;
625
+ }
626
+ if (!isFlushable(fn)) {
627
+ onComplete();
628
+ return;
629
+ }
630
+ let r;
631
+ try {
632
+ const value = fn(none, null);
633
+ r = processValue(noteFinal(value, fn, finished));
634
+ } catch (error) {
635
+ return finishWrite(callback, error);
636
+ }
637
+ if (r) {
638
+ r.then(onComplete, (error) => finishWrite(callback, error));
639
+ } else {
640
+ onComplete();
641
+ }
642
+ },
643
+ read() {
644
+ resume();
645
+ },
646
+ // Unblock any pending paused-promise so an in-flight write can settle —
647
+ // mirrors asWebStream's controller.signal listener for writer.abort().
648
+ destroy(error, callback) {
649
+ stopped = destroyed = true;
650
+ enqueue[cancelSymbol] = CANCEL;
651
+ cancelPaused();
652
+ if (flushed || !canAbort) {
653
+ callback(error);
654
+ return;
655
+ }
656
+ abortStages(stages, finished).then(
657
+ (failure) => callback(
658
+ failure === void 0 ? error : (
659
+ /** @type {Error} */
660
+ withCleanupError(error, failure)
661
+ )
662
+ )
663
+ );
664
+ }
665
+ });
666
+ return stream;
667
+ };
668
+ var asStream_default = asStream;
669
+
670
+ // ../../node_modules/stream-chain/src/asWebStream.js
671
+ var CANCEL2 = Symbol.for("object-stream.asWebStreamCancel");
672
+ var asWebStream = (fn, options) => {
673
+ if (isDuplexWebStream(fn) || isReadableWebStream(fn) || isWritableWebStream(fn)) {
674
+ return fn;
675
+ }
676
+ if (typeof fn !== "function") {
677
+ throw new TypeError("Only a function or Web Streams object is accepted as the first argument");
678
+ }
679
+ const strategy = options?.strategy;
680
+ const readableStrategy = options?.readableStrategy ?? strategy;
681
+ const writableStrategy = options?.writableStrategy ?? strategy;
682
+ const innerFns = isFunctionList(fn) ? fn.fList : null;
683
+ const stages = innerFns ?? [fn];
684
+ const canAbort = hasAborters(stages), finished = /* @__PURE__ */ new Set();
685
+ let stopped = false;
686
+ let cancelled = false;
687
+ let flushed = false;
688
+ let releasing = null;
689
+ let readableClosed = false;
690
+ let writableErrored = false;
691
+ let readableController;
692
+ let writableController;
693
+ let pendingDrain = null;
694
+ let rejectDrain = null;
695
+ const unblockDrain = () => {
696
+ if (!pendingDrain) return;
697
+ const resolve = pendingDrain;
698
+ pendingDrain = rejectDrain = null;
699
+ resolve();
700
+ };
701
+ const cancelDrain = () => {
702
+ if (!rejectDrain) return;
703
+ const reject = rejectDrain;
704
+ pendingDrain = rejectDrain = null;
705
+ reject(CANCEL2);
706
+ };
707
+ const closeReadable = () => {
708
+ if (readableClosed) return;
709
+ readableClosed = true;
710
+ readableController.close();
711
+ };
712
+ const errorReadable = (reason) => {
713
+ if (readableClosed) return;
714
+ readableClosed = true;
715
+ readableController.error(reason);
716
+ };
717
+ const errorWritable = (reason) => {
718
+ if (writableErrored || !writableController) return;
719
+ writableErrored = true;
720
+ writableController.error(reason);
721
+ };
722
+ const readable = new ReadableStream(
723
+ {
724
+ start(c) {
725
+ readableController = c;
726
+ },
727
+ pull() {
728
+ unblockDrain();
729
+ },
730
+ cancel(reason) {
731
+ readableClosed = true;
732
+ cancelProducer();
733
+ errorWritable(reason);
734
+ return releaseStages().then(rethrow);
735
+ }
736
+ },
737
+ readableStrategy
738
+ );
739
+ const enqueue = (value) => {
740
+ if (cancelled) throw CANCEL2;
741
+ if (readableClosed) return;
742
+ readableController.enqueue(value);
743
+ if (readableController.desiredSize <= 0) {
744
+ return new Promise((resolve, reject) => {
745
+ pendingDrain = resolve;
746
+ rejectDrain = reject;
747
+ });
748
+ }
749
+ };
750
+ enqueue[dropNullSymbol] = true;
751
+ const cancelProducer = () => {
752
+ stopped = cancelled = true;
753
+ enqueue[cancelSymbol] = CANCEL2;
754
+ cancelDrain();
755
+ };
756
+ const releaseStages = () => {
757
+ if (flushed || !canAbort) return Promise.resolve(void 0);
758
+ releasing ??= abortStages(stages, finished);
759
+ return releasing;
760
+ };
761
+ const rethrow = (failure) => {
762
+ if (failure !== void 0) throw failure;
763
+ };
764
+ const queue = [];
765
+ const pump = async () => {
766
+ while (queue.length) {
767
+ if (cancelled) throw CANCEL2;
768
+ const g = queue[queue.length - 1];
769
+ let result = g.next();
770
+ if (result && typeof result.then == "function") result = await result;
771
+ if (result.done) {
772
+ queue.pop();
773
+ continue;
774
+ }
775
+ let value = result.value;
776
+ if (value && typeof value.then == "function") value = await value;
777
+ const r = processValue(value);
778
+ if (r) await r;
779
+ }
780
+ };
781
+ const release = async (error) => {
782
+ while (queue.length) {
783
+ const g = queue.pop();
784
+ try {
785
+ if (g.return) await g.return();
786
+ } catch (cleanupErr) {
787
+ error = withCleanupError(error, cleanupErr);
788
+ }
789
+ }
790
+ throw error;
791
+ };
792
+ const processValue = (value) => {
793
+ if (value && typeof value.then == "function") {
794
+ return value.then(processValue);
795
+ }
796
+ if (value == null || value === none) return;
797
+ if (value === stop) throw new Stop();
798
+ if (isMany(value)) {
799
+ const values = getManyValues(value);
800
+ let promise;
801
+ for (let i = 0; i < values.length; ++i) {
802
+ if (promise) {
803
+ const ii = i;
804
+ promise = promise.then(() => processValue(values[ii]));
805
+ } else {
806
+ const r = processValue(values[i]);
807
+ if (r) promise = r;
808
+ }
809
+ }
810
+ return promise;
811
+ }
812
+ if (isFinalValue(value)) {
813
+ return processValue(getFinalValue(value));
814
+ }
815
+ if (value && typeof value.next == "function") {
816
+ queue.push(value);
817
+ return pump().catch(release);
818
+ }
819
+ return enqueue(value);
820
+ };
821
+ const endAfterStop = async (stop2) => {
822
+ stopped = true;
823
+ try {
824
+ await finishStop(stages, stop2, enqueue, finished);
825
+ } catch (error) {
826
+ errorReadable(error);
827
+ throw error;
828
+ }
829
+ flushed = true;
830
+ closeReadable();
831
+ };
832
+ const writable = new WritableStream(
833
+ {
834
+ // `controller.signal` aborts during writer.abort() BEFORE the sink's
835
+ // abort() callback runs. The spec waits for in-flight write() to
836
+ // settle first — so if write() is awaiting pendingDrain, we'd
837
+ // deadlock unless the signal listener wakes it.
838
+ // Optional-chained because Bun ≤1.3.14 returns `undefined` for the
839
+ // controller's signal (spec-required per WHATWG Streams §4.5.2 but
840
+ // missing in Bun's builtin — see oven-sh/bun#31156 / PR #31157).
841
+ // Fixed upstream (present in Bun 1.4.0); the chaining stays for older
842
+ // Bun, which only loses the abort wakeup.
843
+ start(controller) {
844
+ writableController = controller;
845
+ controller.signal?.addEventListener("abort", cancelProducer);
846
+ },
847
+ async write(chunk) {
848
+ if (stopped) return;
849
+ try {
850
+ if (innerFns) {
851
+ const r2 = next(chunk, innerFns, 0, enqueue);
852
+ if (r2) await r2;
853
+ return;
854
+ }
855
+ const r = processValue(fn(chunk));
856
+ if (r) await r;
857
+ } catch (error) {
858
+ if (error === CANCEL2) return;
859
+ if (isStop(error)) return endAfterStop(error);
860
+ errorReadable(error);
861
+ const failure = await releaseStages();
862
+ throw failure === void 0 ? error : withCleanupError(error, failure);
863
+ }
864
+ },
865
+ async close() {
866
+ try {
867
+ if (!stopped) {
868
+ if (innerFns) {
869
+ const r = flush(innerFns, 0, enqueue, finished);
870
+ if (r) await r;
871
+ } else if (isFlushable(fn)) {
872
+ const r = processValue(noteFinal(fn(none), fn, finished));
873
+ if (r) await r;
874
+ }
875
+ flushed = true;
876
+ }
877
+ } catch (error) {
878
+ if (isStop(error)) return endAfterStop(error);
879
+ if (error !== CANCEL2) {
880
+ errorReadable(error);
881
+ const failure = await releaseStages();
882
+ throw failure === void 0 ? error : withCleanupError(error, failure);
883
+ }
884
+ }
885
+ closeReadable();
886
+ },
887
+ abort(reason) {
888
+ cancelProducer();
889
+ errorReadable(reason);
890
+ return releaseStages().then(rethrow);
891
+ }
892
+ },
893
+ writableStrategy
894
+ );
895
+ return { readable, writable };
896
+ };
897
+ var asWebStream_default = asWebStream;
898
+
899
+ // ../../node_modules/stream-chain/src/dataSource.js
900
+ var dataSource = (fn) => {
901
+ if (typeof fn == "function") return fn;
902
+ if (fn) {
903
+ if (typeof fn[Symbol.asyncIterator] == "function") return fn[Symbol.asyncIterator].bind(fn);
904
+ if (typeof fn[Symbol.iterator] == "function") return fn[Symbol.iterator].bind(fn);
905
+ }
906
+ throw new TypeError("The argument should be a function or an iterable object.");
907
+ };
908
+ var dataSource_default = dataSource;
909
+
910
+ // ../../node_modules/stream-chain/src/index.js
911
+ var {
912
+ isReadableWebStream: isReadableWebStream2,
913
+ isWritableWebStream: isWritableWebStream2,
914
+ isDuplexWebStream: isDuplexWebStream2,
915
+ isReadableNodeStream: isReadableNodeStream2,
916
+ isWritableNodeStream: isWritableNodeStream2,
917
+ isDuplexNodeStream: isDuplexNodeStream2
918
+ } = defs_exports;
919
+ var groupFunctions = (output, fn, index, fns) => {
920
+ if (isDuplexNodeStream2(fn) || !index && isReadableNodeStream2(fn) || index === fns.length - 1 && isWritableNodeStream2(fn)) {
921
+ output.push(fn);
922
+ return output;
923
+ }
924
+ if (isDuplexWebStream2(fn)) {
925
+ output.push(import_node_stream2.Duplex.fromWeb(fn, { objectMode: true }));
926
+ return output;
927
+ }
928
+ if (!index && isReadableWebStream2(fn)) {
929
+ output.push(import_node_stream2.Readable.fromWeb(fn, { objectMode: true }));
930
+ return output;
931
+ }
932
+ if (index === fns.length - 1 && isWritableWebStream2(fn)) {
933
+ output.push(import_node_stream2.Writable.fromWeb(fn, { objectMode: true }));
934
+ return output;
935
+ }
936
+ if (typeof fn != "function")
937
+ throw TypeError("Item #" + index + " is not a proper stream, nor a function.");
938
+ if (!output.length) output.push([]);
939
+ const last = output[output.length - 1];
940
+ if (Array.isArray(last)) {
941
+ last.push(fn);
942
+ } else {
943
+ output.push([fn]);
944
+ }
945
+ return output;
946
+ };
947
+ var produceStreams = (item) => {
948
+ if (Array.isArray(item)) {
949
+ if (!item.length) return null;
950
+ if (item.length == 1) return item[0] && /** @type {any} */
951
+ chain.asStream(item[0]);
952
+ return (
953
+ /** @type {any} */
954
+ chain.asStream(
955
+ /** @type {any} */
956
+ chain.gen(...item)
957
+ )
958
+ );
959
+ }
960
+ return item;
961
+ };
962
+ var wrapFunctions = (fn, index, fns) => {
963
+ if (isDuplexNodeStream2(fn) || !index && isReadableNodeStream2(fn) || index === fns.length - 1 && isWritableNodeStream2(fn)) {
964
+ return fn;
965
+ }
966
+ if (isDuplexWebStream2(fn)) {
967
+ return import_node_stream2.Duplex.fromWeb(fn, { objectMode: true });
968
+ }
969
+ if (!index && isReadableWebStream2(fn)) {
970
+ return import_node_stream2.Readable.fromWeb(fn, { objectMode: true });
971
+ }
972
+ if (index === fns.length - 1 && isWritableWebStream2(fn)) {
973
+ return import_node_stream2.Writable.fromWeb(fn, { objectMode: true });
974
+ }
975
+ if (typeof fn == "function") return (
976
+ /** @type {any} */
977
+ chain.asStream(fn)
978
+ );
979
+ throw TypeError("Item #" + index + " is not a proper stream, nor a function.");
980
+ };
981
+ var write = (input, chunk, encoding, callback) => {
982
+ let error = null;
983
+ try {
984
+ input.write(chunk, encoding, (e) => callback(e || error));
985
+ } catch (e) {
986
+ error = e;
987
+ }
988
+ };
989
+ var final2 = (input, callback) => {
990
+ let error = null;
991
+ try {
992
+ input.end(null, null, (e) => callback(e || error));
993
+ } catch (e) {
994
+ error = e;
995
+ }
996
+ };
997
+ var read = (output) => {
998
+ output.resume();
999
+ };
1000
+ var chain = (fns, options) => {
1001
+ if (!Array.isArray(fns) || !fns.length) {
1002
+ throw TypeError("Chain's first argument should be a non-empty array.");
1003
+ }
1004
+ fns = fns.flat(Infinity).filter((fn) => fn);
1005
+ const streams = (options?.noGrouping ? fns.map(wrapFunctions) : fns.map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity).reduce(groupFunctions, []).map(produceStreams)).filter((s) => s), input = streams[0], output = streams.reduce((output2, item) => output2 && output2.pipe(item) || item);
1006
+ let stream = null;
1007
+ let writeMethod = (chunk, encoding, callback) => write(input, chunk, encoding, callback), finalMethod = (callback) => final2(input, callback), readMethod = () => read(output);
1008
+ if (!isWritableNodeStream2(input)) {
1009
+ writeMethod = (_1, _2, callback) => callback(null);
1010
+ finalMethod = (callback) => callback(null);
1011
+ input.on("end", () => stream.end());
1012
+ }
1013
+ if (isReadableNodeStream2(output)) {
1014
+ output.on("data", (chunk) => !stream.push(chunk) && output.pause());
1015
+ output.on("end", () => stream.push(null));
1016
+ } else {
1017
+ readMethod = () => {
1018
+ };
1019
+ output.on("finish", () => stream.push(null));
1020
+ }
1021
+ stream = /** @type {Duplex & {streams: any[], input: any, output: any}} */
1022
+ new import_node_stream2.Duplex({
1023
+ writableObjectMode: true,
1024
+ readableObjectMode: true,
1025
+ ...options,
1026
+ readable: isReadableNodeStream2(output),
1027
+ writable: isWritableNodeStream2(input),
1028
+ write: writeMethod,
1029
+ final: finalMethod,
1030
+ read: readMethod,
1031
+ destroy(error, callback) {
1032
+ if (!stream.writableFinished || !stream.readableEnded) {
1033
+ for (const item of streams) item.destroy();
1034
+ }
1035
+ callback(error);
1036
+ }
1037
+ });
1038
+ stream.streams = streams;
1039
+ stream.input = input;
1040
+ stream.output = output;
1041
+ if (!isReadableNodeStream2(output)) {
1042
+ stream.resume();
1043
+ }
1044
+ if (!options?.skipEvents) {
1045
+ streams.forEach((item) => item.on("error", (error) => stream.emit("error", error)));
1046
+ }
1047
+ return stream;
1048
+ };
1049
+ chain.none = none;
1050
+ chain.stop = stop;
1051
+ chain.Stop = Stop;
1052
+ chain.stopErrorSymbol = stopErrorSymbol;
1053
+ chain.isStop = isStop;
1054
+ chain.finalSymbol = finalSymbol;
1055
+ chain.finalValue = finalValue;
1056
+ chain.final = final;
1057
+ chain.isFinalValue = isFinalValue;
1058
+ chain.getFinalValue = getFinalValue;
1059
+ chain.manySymbol = manySymbol;
1060
+ chain.many = many;
1061
+ chain.isMany = isMany;
1062
+ chain.getManyValues = getManyValues;
1063
+ chain.flushSymbol = flushSymbol;
1064
+ chain.flushable = flushable;
1065
+ chain.isFlushable = isFlushable;
1066
+ chain.abortSymbol = abortSymbol;
1067
+ chain.fListSymbol = fListSymbol;
1068
+ chain.isFunctionList = isFunctionList;
1069
+ chain.getFunctionList = getFunctionList;
1070
+ chain.setFunctionList = setFunctionList;
1071
+ chain.clearFunctionList = clearFunctionList;
1072
+ chain.toMany = toMany;
1073
+ chain.normalizeMany = normalizeMany;
1074
+ chain.combineMany = combineMany;
1075
+ chain.combineManyMut = combineManyMut;
1076
+ chain.chain = chain;
1077
+ chain.chainUnchecked = chain;
1078
+ chain.gen = gen_default;
1079
+ chain.asStream = asStream_default;
1080
+ chain.asWebStream = asWebStream_default;
1081
+ chain.dataSource = dataSource_default;
1082
+
1083
+ // ../../node_modules/stream-chain/src/fun.js
1084
+ var asArray = (...fns) => {
1085
+ fns = fns.filter((fn) => fn).flat(Infinity).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
1086
+ if (!fns.length) {
1087
+ fns = [(x) => x];
1088
+ }
1089
+ let flushed = false, stopAt = 0;
1090
+ const noteStop = (error) => {
1091
+ if (isStop(error)) stopAt = stopIndex(error, fns);
1092
+ throw error;
1093
+ };
1094
+ let g = (value) => {
1095
+ if (flushed) throw Error("Call to a flushed pipe.");
1096
+ const results = [], push = (v) => {
1097
+ results.push(v);
1098
+ };
1099
+ let pending;
1100
+ if (value !== none) {
1101
+ try {
1102
+ pending = next(value, fns, 0, push);
1103
+ } catch (error) {
1104
+ noteStop(error);
1105
+ }
1106
+ } else {
1107
+ flushed = true;
1108
+ pending = flush(fns, stopAt, push);
1109
+ }
1110
+ return pending && typeof pending.then == "function" ? pending.then(() => results, noteStop) : results;
1111
+ };
1112
+ const needToFlush = fns.some((fn) => isFlushable(fn));
1113
+ if (needToFlush) g = flushable(g);
1114
+ return setFunctionList(g, fns);
1115
+ };
1116
+ var fun = (...fns) => {
1117
+ const f = asArray(...fns);
1118
+ let g = (value) => {
1119
+ const result = (
1120
+ /** @type {any} */
1121
+ f(value)
1122
+ );
1123
+ if (result && typeof result.then == "function") {
1124
+ return result.then((results) => many(results));
1125
+ }
1126
+ return many(result);
1127
+ };
1128
+ if (isFlushable(f)) g = flushable(g);
1129
+ return setFunctionList(g, getFunctionList(f));
1130
+ };
1131
+ var fun_default = fun;
1132
+
1133
+ // ../../node_modules/stream-chain/src/web/index.js
1134
+ var groupFunctions2 = (output, item, index, items) => {
1135
+ if (isDuplexWebStream(item)) {
1136
+ output.push(item);
1137
+ return output;
1138
+ }
1139
+ if (!index && isReadableWebStream(item)) {
1140
+ output.push({ readable: item, writable: null });
1141
+ return output;
1142
+ }
1143
+ if (index === items.length - 1 && isWritableWebStream(item)) {
1144
+ output.push({ readable: null, writable: item });
1145
+ return output;
1146
+ }
1147
+ if (typeof item !== "function") {
1148
+ throw new TypeError(`Item #${index} is not a Web Streams object or function.`);
1149
+ }
1150
+ if (!output.length) output.push([]);
1151
+ const last = output[output.length - 1];
1152
+ if (Array.isArray(last)) {
1153
+ last.push(item);
1154
+ } else {
1155
+ output.push([item]);
1156
+ }
1157
+ return output;
1158
+ };
1159
+ var makeProduceStages = (options) => (item) => {
1160
+ if (Array.isArray(item)) {
1161
+ if (!item.length) return null;
1162
+ if (item.length === 1) return (
1163
+ /** @type {any} */
1164
+ chain2.asWebStream(item[0], options)
1165
+ );
1166
+ return (
1167
+ /** @type {any} */
1168
+ chain2.asWebStream(
1169
+ /** @type {any} */
1170
+ chain2.gen(...item),
1171
+ options
1172
+ )
1173
+ );
1174
+ }
1175
+ return item;
1176
+ };
1177
+ var chain2 = (fns, options) => {
1178
+ if (!Array.isArray(fns) || !fns.length) {
1179
+ throw new TypeError("Chain's first argument should be a non-empty array.");
1180
+ }
1181
+ fns = fns.flat(Infinity).filter(Boolean).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
1182
+ if (!fns.length) {
1183
+ throw new TypeError("Chain's first argument is empty after flattening.");
1184
+ }
1185
+ const stages = fns.reduce(groupFunctions2, []).map(makeProduceStages(options)).filter((s) => s);
1186
+ for (let i = 0; i < stages.length - 1; ++i) {
1187
+ const from = stages[i].readable;
1188
+ const to = stages[i + 1].writable;
1189
+ if (!from) {
1190
+ throw new TypeError(`Stage #${i} has no readable side; cannot pipe to next stage.`);
1191
+ }
1192
+ if (!to) {
1193
+ throw new TypeError(`Stage #${i + 1} has no writable side; cannot accept input.`);
1194
+ }
1195
+ from.pipeTo(to).catch(() => {
1196
+ });
1197
+ }
1198
+ const c = {
1199
+ readable: stages[stages.length - 1].readable,
1200
+ writable: stages[0].writable,
1201
+ streams: stages,
1202
+ input: stages[0],
1203
+ output: stages[stages.length - 1]
1204
+ };
1205
+ return c;
1206
+ };
1207
+ chain2.none = none;
1208
+ chain2.stop = stop;
1209
+ chain2.Stop = Stop;
1210
+ chain2.stopErrorSymbol = stopErrorSymbol;
1211
+ chain2.isStop = isStop;
1212
+ chain2.finalSymbol = finalSymbol;
1213
+ chain2.finalValue = finalValue;
1214
+ chain2.final = final;
1215
+ chain2.isFinalValue = isFinalValue;
1216
+ chain2.getFinalValue = getFinalValue;
1217
+ chain2.manySymbol = manySymbol;
1218
+ chain2.many = many;
1219
+ chain2.isMany = isMany;
1220
+ chain2.getManyValues = getManyValues;
1221
+ chain2.flushSymbol = flushSymbol;
1222
+ chain2.flushable = flushable;
1223
+ chain2.isFlushable = isFlushable;
1224
+ chain2.abortSymbol = abortSymbol;
1225
+ chain2.fListSymbol = fListSymbol;
1226
+ chain2.isFunctionList = isFunctionList;
1227
+ chain2.getFunctionList = getFunctionList;
1228
+ chain2.setFunctionList = setFunctionList;
1229
+ chain2.clearFunctionList = clearFunctionList;
1230
+ chain2.toMany = toMany;
1231
+ chain2.normalizeMany = normalizeMany;
1232
+ chain2.combineMany = combineMany;
1233
+ chain2.combineManyMut = combineManyMut;
1234
+ chain2.chain = chain2;
1235
+ chain2.chainUnchecked = chain2;
1236
+ chain2.gen = gen_default;
1237
+ chain2.fun = fun_default;
1238
+ chain2.asWebStream = asWebStream_default;
1239
+ chain2.dataSource = dataSource_default;
1240
+
1241
+ // ../../node_modules/stream-chain/src/core/index.js
1242
+ var chain3 = (fns, _options) => {
1243
+ const flat = (Array.isArray(fns) ? fns : []).flat(Infinity).filter(Boolean).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
1244
+ const g = gen_default(...flat);
1245
+ const c = async function* (input) {
1246
+ if (input == null) return;
1247
+ if (typeof input === "string" || input[Symbol.asyncIterator] === void 0 && input[Symbol.iterator] === void 0) {
1248
+ yield* g(input);
1249
+ return;
1250
+ }
1251
+ for await (const value of input) yield* g(value);
1252
+ };
1253
+ c.streams = null;
1254
+ c.input = null;
1255
+ c.output = null;
1256
+ return c;
1257
+ };
1258
+ chain3.none = none;
1259
+ chain3.stop = stop;
1260
+ chain3.Stop = Stop;
1261
+ chain3.stopErrorSymbol = stopErrorSymbol;
1262
+ chain3.isStop = isStop;
1263
+ chain3.finalSymbol = finalSymbol;
1264
+ chain3.finalValue = finalValue;
1265
+ chain3.final = final;
1266
+ chain3.isFinalValue = isFinalValue;
1267
+ chain3.getFinalValue = getFinalValue;
1268
+ chain3.manySymbol = manySymbol;
1269
+ chain3.many = many;
1270
+ chain3.isMany = isMany;
1271
+ chain3.getManyValues = getManyValues;
1272
+ chain3.flushSymbol = flushSymbol;
1273
+ chain3.flushable = flushable;
1274
+ chain3.isFlushable = isFlushable;
1275
+ chain3.abortSymbol = abortSymbol;
1276
+ chain3.fListSymbol = fListSymbol;
1277
+ chain3.isFunctionList = isFunctionList;
1278
+ chain3.getFunctionList = getFunctionList;
1279
+ chain3.setFunctionList = setFunctionList;
1280
+ chain3.clearFunctionList = clearFunctionList;
1281
+ chain3.toMany = toMany;
1282
+ chain3.normalizeMany = normalizeMany;
1283
+ chain3.combineMany = combineMany;
1284
+ chain3.combineManyMut = combineManyMut;
1285
+ chain3.chain = chain3;
1286
+ chain3.chainUnchecked = chain3;
1287
+ chain3.gen = gen_default;
1288
+ chain3.fun = fun_default;
1289
+ chain3.dataSource = dataSource_default;
1290
+
1291
+ // ../../node_modules/stream-chain/src/utils/fixUtf8Stream.js
1292
+ var dropBOM = (s) => s.charCodeAt(0) === 65279 ? s.slice(1) : s;
1293
+ var makeTextDecoderImpl = (options) => {
1294
+ const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
1295
+ let atStart = !options?.ignoreBOM;
1296
+ return flushable((chunk) => {
1297
+ let s;
1298
+ if (chunk === none) s = textDecoder.decode();
1299
+ else if (typeof chunk == "string") s = chunk;
1300
+ else if (chunk instanceof Uint8Array) s = textDecoder.decode(chunk, { stream: true });
1301
+ else throw new TypeError("Expected a string or a Uint8Array");
1302
+ if (!atStart || !s) return s;
1303
+ atStart = false;
1304
+ return dropBOM(s);
1305
+ });
1306
+ };
1307
+ var makeStringDecoderImpl = (StringDecoder) => (options) => {
1308
+ const stringDecoder = new StringDecoder();
1309
+ let atStart = !options?.ignoreBOM;
1310
+ return flushable((chunk) => {
1311
+ let s;
1312
+ if (chunk === none) s = stringDecoder.end();
1313
+ else if (typeof chunk == "string") s = chunk;
1314
+ else if (chunk instanceof Uint8Array) s = stringDecoder.write(chunk);
1315
+ else throw new TypeError("Expected a string or a Uint8Array");
1316
+ if (!atStart || !s) return s;
1317
+ atStart = false;
1318
+ return dropBOM(s);
1319
+ });
1320
+ };
1321
+ var impl = makeTextDecoderImpl;
1322
+ var isDeno = typeof globalThis["Deno"] == "object" && globalThis["Deno"]?.version;
1323
+ var isBun = typeof globalThis["Bun"] == "object" && globalThis["Bun"]?.version;
1324
+ var isNode = !isDeno && !isBun && typeof process == "object" && process?.versions?.node;
1325
+ var readyPromise = isNode ? import("node:string_decoder").then(
1326
+ ({ StringDecoder }) => {
1327
+ impl = makeStringDecoderImpl(StringDecoder);
1328
+ },
1329
+ () => {
1330
+ }
1331
+ // squelch — stick with TextDecoder
1332
+ ) : Promise.resolve();
1333
+ var fixUtf8Stream = (options) => impl(options);
1334
+ var fixUtf8Stream_default = fixUtf8Stream;
1335
+
1336
+ // ../../node_modules/stream-json/src/core/parser.js
1337
+ var patterns = {
1338
+ value1: /[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256}/y,
1339
+ string: /[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\"/y,
1340
+ numberStart: /\d/y,
1341
+ numberDigit: /\d{0,256}/y,
1342
+ numberFraction: /[\.eE]/y,
1343
+ numberExponent: /[eE]/y,
1344
+ numberExpSign: /[-+]/y
1345
+ };
1346
+ var MAX_PATTERN_SIZE = 16;
1347
+ patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
1348
+ patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
1349
+ var expected = { object: "objectStop", array: "arrayStop", "": "done" };
1350
+ var tokenStartObject = { name: "startObject" };
1351
+ var tokenEndObject = { name: "endObject" };
1352
+ var tokenStartArray = { name: "startArray" };
1353
+ var tokenEndArray = { name: "endArray" };
1354
+ var tokenStartString = { name: "startString" };
1355
+ var tokenEndString = { name: "endString" };
1356
+ var tokenStartNumber = { name: "startNumber" };
1357
+ var tokenEndNumber = { name: "endNumber" };
1358
+ var tokenStartKey = { name: "startKey" };
1359
+ var tokenEndKey = { name: "endKey" };
1360
+ var literalTokens = {
1361
+ true: { name: "trueValue", value: true },
1362
+ false: { name: "falseValue", value: false },
1363
+ null: { name: "nullValue", value: null }
1364
+ };
1365
+ var fromHex = (s) => String.fromCharCode(parseInt(s.slice(2), 16));
1366
+ var codes = { b: "\b", f: "\f", n: "\n", r: "\r", t: " ", '"': '"', "\\": "\\", "/": "/" };
1367
+ var ASCII_TAB = " ".charCodeAt(0);
1368
+ var ASCII_LF = "\n".charCodeAt(0);
1369
+ var ASCII_CR = "\r".charCodeAt(0);
1370
+ var ASCII_SPACE = " ".charCodeAt(0);
1371
+ var ASCII_QUOTE = '"'.charCodeAt(0);
1372
+ var ASCII_BACKSLASH = "\\".charCodeAt(0);
1373
+ var ASCII_OPEN_BRACE = "{".charCodeAt(0);
1374
+ var ASCII_CLOSE_BRACE = "}".charCodeAt(0);
1375
+ var ASCII_OPEN_BRACKET = "[".charCodeAt(0);
1376
+ var ASCII_CLOSE_BRACKET = "]".charCodeAt(0);
1377
+ var ASCII_MINUS = "-".charCodeAt(0);
1378
+ var ASCII_COLON = ":".charCodeAt(0);
1379
+ var ASCII_COMMA = ",".charCodeAt(0);
1380
+ var ASCII_ZERO = "0".charCodeAt(0);
1381
+ var ASCII_NINE = "9".charCodeAt(0);
1382
+ var ASCII_UPPER_A = "A".charCodeAt(0);
1383
+ var ASCII_UPPER_F = "F".charCodeAt(0);
1384
+ var ASCII_LOWER_A = "a".charCodeAt(0);
1385
+ var ASCII_LOWER_F = "f".charCodeAt(0);
1386
+ var ASCII_LOWER_N = "n".charCodeAt(0);
1387
+ var ASCII_LOWER_T = "t".charCodeAt(0);
1388
+ var ASCII_LOWER_U = "u".charCodeAt(0);
1389
+ var HIGH_SURROGATE_FIRST = 55296;
1390
+ var HIGH_SURROGATE_LAST = 56319;
1391
+ var TERM = [];
1392
+ for (const ch of ",}] \n\r") TERM[ch.charCodeAt(0)] = 1;
1393
+ var numberFull = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/y;
1394
+ var HEX = (c) => c >= ASCII_ZERO && c <= ASCII_NINE || c >= ASCII_UPPER_A && c <= ASCII_UPPER_F || c >= ASCII_LOWER_A && c <= ASCII_LOWER_F;
1395
+ var jsonParser = (options) => {
1396
+ let packKeys = true, packStrings = true, packNumbers = true, streamKeys = true, streamStrings = true, streamNumbers = true, jsonStreaming = false;
1397
+ if (options) {
1398
+ "packValues" in options && (packKeys = packStrings = packNumbers = options.packValues);
1399
+ "packKeys" in options && (packKeys = options.packKeys);
1400
+ "packStrings" in options && (packStrings = options.packStrings);
1401
+ "packNumbers" in options && (packNumbers = options.packNumbers);
1402
+ "streamValues" in options && (streamKeys = streamStrings = streamNumbers = options.streamValues);
1403
+ "streamKeys" in options && (streamKeys = options.streamKeys);
1404
+ "streamStrings" in options && (streamStrings = options.streamStrings);
1405
+ "streamNumbers" in options && (streamNumbers = options.streamNumbers);
1406
+ jsonStreaming = options.jsonStreaming;
1407
+ }
1408
+ !packKeys && (streamKeys = true);
1409
+ !packStrings && (streamStrings = true);
1410
+ !packNumbers && (streamNumbers = true);
1411
+ let done = false, expect = jsonStreaming ? "done" : "value", parent = "", openNumber = false, accumulator = "", heldSurrogate = "", buffer = "";
1412
+ const stack = [];
1413
+ const pushStringChunk = (tokens, value) => {
1414
+ if (heldSurrogate) {
1415
+ value = heldSurrogate + value;
1416
+ heldSurrogate = "";
1417
+ }
1418
+ const last = value.charCodeAt(value.length - 1);
1419
+ if (last >= HIGH_SURROGATE_FIRST && last <= HIGH_SURROGATE_LAST) {
1420
+ heldSurrogate = value.charAt(value.length - 1);
1421
+ if (value.length === 1) return;
1422
+ value = value.slice(0, -1);
1423
+ }
1424
+ tokens.push({ name: "stringChunk", value });
1425
+ };
1426
+ return flushable((buf) => {
1427
+ const tokens = [];
1428
+ if (buf === none) {
1429
+ done = true;
1430
+ } else {
1431
+ buffer += buf;
1432
+ }
1433
+ let match, fm, s, e, q, rs, cc, value, index = 0;
1434
+ main: for (; ; ) {
1435
+ switch (expect) {
1436
+ case "value1":
1437
+ case "value": {
1438
+ while (index < buffer.length) {
1439
+ cc = buffer.charCodeAt(index);
1440
+ if (cc === ASCII_SPACE || cc === ASCII_TAB || cc === ASCII_LF || cc === ASCII_CR) {
1441
+ ++index;
1442
+ continue;
1443
+ }
1444
+ break;
1445
+ }
1446
+ if (index >= buffer.length) {
1447
+ if (done) throw new Error("Parser has expected a value");
1448
+ break main;
1449
+ }
1450
+ cc = buffer.charCodeAt(index);
1451
+ if (cc === ASCII_QUOTE) {
1452
+ q = index + 1;
1453
+ rs = q;
1454
+ s = "";
1455
+ for (; ; ) {
1456
+ if (q >= buffer.length) {
1457
+ q = -1;
1458
+ break;
1459
+ }
1460
+ e = buffer.charCodeAt(q);
1461
+ if (e === ASCII_QUOTE) {
1462
+ s += buffer.slice(rs, q);
1463
+ break;
1464
+ }
1465
+ if (e < ASCII_SPACE) {
1466
+ q = -1;
1467
+ break;
1468
+ }
1469
+ if (e === ASCII_BACKSLASH) {
1470
+ if (q + 1 >= buffer.length) {
1471
+ q = -1;
1472
+ break;
1473
+ }
1474
+ cc = buffer.charCodeAt(q + 1);
1475
+ if (cc === ASCII_LOWER_U) {
1476
+ if (q + 6 > buffer.length || !(HEX(buffer.charCodeAt(q + 2)) && HEX(buffer.charCodeAt(q + 3)) && HEX(buffer.charCodeAt(q + 4)) && HEX(buffer.charCodeAt(q + 5)))) {
1477
+ q = -1;
1478
+ break;
1479
+ }
1480
+ s += buffer.slice(rs, q) + String.fromCharCode(parseInt(buffer.slice(q + 2, q + 6), 16));
1481
+ q += 6;
1482
+ } else {
1483
+ value = codes[buffer.charAt(q + 1)];
1484
+ if (value === void 0) {
1485
+ q = -1;
1486
+ break;
1487
+ }
1488
+ s += buffer.slice(rs, q) + value;
1489
+ q += 2;
1490
+ }
1491
+ rs = q;
1492
+ continue;
1493
+ }
1494
+ ++q;
1495
+ }
1496
+ if (q >= 0) {
1497
+ if (streamStrings) {
1498
+ tokens.push(tokenStartString);
1499
+ if (s) tokens.push({ name: "stringChunk", value: s });
1500
+ tokens.push(tokenEndString);
1501
+ }
1502
+ if (packStrings) tokens.push({ name: "stringValue", value: s });
1503
+ index = q + 1;
1504
+ expect = expected[parent];
1505
+ continue main;
1506
+ }
1507
+ if (streamStrings) tokens.push(tokenStartString);
1508
+ expect = "string";
1509
+ ++index;
1510
+ continue main;
1511
+ }
1512
+ if (cc === ASCII_OPEN_BRACE) {
1513
+ tokens.push(tokenStartObject);
1514
+ stack.push(parent);
1515
+ parent = "object";
1516
+ expect = "key1";
1517
+ ++index;
1518
+ continue main;
1519
+ }
1520
+ if (cc === ASCII_OPEN_BRACKET) {
1521
+ tokens.push(tokenStartArray);
1522
+ stack.push(parent);
1523
+ parent = "array";
1524
+ expect = "value1";
1525
+ ++index;
1526
+ continue main;
1527
+ }
1528
+ if (cc === ASCII_CLOSE_BRACKET) {
1529
+ if (expect !== "value1") throw new Error("Parser cannot parse input: unexpected token ']'");
1530
+ tokens.push(tokenEndArray);
1531
+ parent = stack.pop();
1532
+ expect = expected[parent];
1533
+ ++index;
1534
+ continue main;
1535
+ }
1536
+ if (cc === ASCII_MINUS || cc >= ASCII_ZERO && cc <= ASCII_NINE) {
1537
+ numberFull.lastIndex = index;
1538
+ fm = numberFull.exec(buffer);
1539
+ if (fm) {
1540
+ e = index + fm[0].length;
1541
+ if (e < buffer.length && TERM[buffer.charCodeAt(e)]) {
1542
+ s = fm[0];
1543
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: s }, tokenEndNumber);
1544
+ if (packNumbers) tokens.push({ name: "numberValue", value: s });
1545
+ index = e;
1546
+ expect = expected[parent];
1547
+ continue main;
1548
+ }
1549
+ }
1550
+ openNumber = true;
1551
+ if (cc === ASCII_MINUS) {
1552
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: "-" });
1553
+ packNumbers && (accumulator = "-");
1554
+ expect = "numberStart";
1555
+ } else if (cc === ASCII_ZERO) {
1556
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: "0" });
1557
+ packNumbers && (accumulator = "0");
1558
+ expect = "numberFraction";
1559
+ } else {
1560
+ s = buffer.charAt(index);
1561
+ if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: s });
1562
+ packNumbers && (accumulator = s);
1563
+ expect = "numberDigit";
1564
+ }
1565
+ ++index;
1566
+ continue main;
1567
+ }
1568
+ if (cc === ASCII_LOWER_T || cc === ASCII_LOWER_F || cc === ASCII_LOWER_N) {
1569
+ patterns.value1.lastIndex = index;
1570
+ match = patterns.value1.exec(buffer);
1571
+ if (!match) {
1572
+ if (done || index + MAX_PATTERN_SIZE < buffer.length) {
1573
+ throw new Error("Parser cannot parse input: expected a value");
1574
+ }
1575
+ break main;
1576
+ }
1577
+ value = match[0];
1578
+ if (buffer.length - index === value.length && !done) break main;
1579
+ tokens.push(literalTokens[value]);
1580
+ expect = expected[parent];
1581
+ index += value.length;
1582
+ continue main;
1583
+ }
1584
+ throw new Error("Parser cannot parse input: expected a value");
1585
+ }
1586
+ // incremental string body (escapes / long / cross-chunk)
1587
+ case "keyVal":
1588
+ case "string":
1589
+ patterns.string.lastIndex = index;
1590
+ match = patterns.string.exec(buffer);
1591
+ if (!match) {
1592
+ if (index < buffer.length && (done || buffer.length - index >= 6)) throw new Error("Parser cannot parse input: escaped characters");
1593
+ if (done) throw new Error("Parser has expected a string value");
1594
+ break main;
1595
+ }
1596
+ value = match[0];
1597
+ if (value === '"') {
1598
+ if (heldSurrogate) {
1599
+ tokens.push({ name: "stringChunk", value: heldSurrogate });
1600
+ heldSurrogate = "";
1601
+ }
1602
+ if (expect === "keyVal") {
1603
+ if (streamKeys) tokens.push(tokenEndKey);
1604
+ if (packKeys) {
1605
+ tokens.push({ name: "keyValue", value: accumulator });
1606
+ accumulator = "";
1607
+ }
1608
+ expect = "colon";
1609
+ } else {
1610
+ if (streamStrings) tokens.push(tokenEndString);
1611
+ if (packStrings) {
1612
+ tokens.push({ name: "stringValue", value: accumulator });
1613
+ accumulator = "";
1614
+ }
1615
+ expect = expected[parent];
1616
+ }
1617
+ } else if (value.length > 1 && value.charAt(0) === "\\") {
1618
+ const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value);
1619
+ if (expect === "keyVal" ? streamKeys : streamStrings) {
1620
+ pushStringChunk(tokens, t);
1621
+ }
1622
+ if (expect === "keyVal" ? packKeys : packStrings) {
1623
+ accumulator += t;
1624
+ }
1625
+ } else {
1626
+ if (expect === "keyVal" ? streamKeys : streamStrings) {
1627
+ pushStringChunk(tokens, value);
1628
+ }
1629
+ if (expect === "keyVal" ? packKeys : packStrings) {
1630
+ accumulator += value;
1631
+ }
1632
+ }
1633
+ index += value.length;
1634
+ break;
1635
+ case "key1":
1636
+ case "key": {
1637
+ while (index < buffer.length) {
1638
+ cc = buffer.charCodeAt(index);
1639
+ if (cc === ASCII_SPACE || cc === ASCII_TAB || cc === ASCII_LF || cc === ASCII_CR) {
1640
+ ++index;
1641
+ continue;
1642
+ }
1643
+ break;
1644
+ }
1645
+ if (index >= buffer.length) {
1646
+ if (done) throw new Error("Parser cannot parse input: expected an object key");
1647
+ break main;
1648
+ }
1649
+ cc = buffer.charCodeAt(index);
1650
+ if (cc === ASCII_QUOTE) {
1651
+ q = index + 1;
1652
+ rs = q;
1653
+ s = "";
1654
+ for (; ; ) {
1655
+ if (q >= buffer.length) {
1656
+ q = -1;
1657
+ break;
1658
+ }
1659
+ e = buffer.charCodeAt(q);
1660
+ if (e === ASCII_QUOTE) {
1661
+ s += buffer.slice(rs, q);
1662
+ break;
1663
+ }
1664
+ if (e < ASCII_SPACE) {
1665
+ q = -1;
1666
+ break;
1667
+ }
1668
+ if (e === ASCII_BACKSLASH) {
1669
+ if (q + 1 >= buffer.length) {
1670
+ q = -1;
1671
+ break;
1672
+ }
1673
+ cc = buffer.charCodeAt(q + 1);
1674
+ if (cc === ASCII_LOWER_U) {
1675
+ if (q + 6 > buffer.length || !(HEX(buffer.charCodeAt(q + 2)) && HEX(buffer.charCodeAt(q + 3)) && HEX(buffer.charCodeAt(q + 4)) && HEX(buffer.charCodeAt(q + 5)))) {
1676
+ q = -1;
1677
+ break;
1678
+ }
1679
+ s += buffer.slice(rs, q) + String.fromCharCode(parseInt(buffer.slice(q + 2, q + 6), 16));
1680
+ q += 6;
1681
+ } else {
1682
+ value = codes[buffer.charAt(q + 1)];
1683
+ if (value === void 0) {
1684
+ q = -1;
1685
+ break;
1686
+ }
1687
+ s += buffer.slice(rs, q) + value;
1688
+ q += 2;
1689
+ }
1690
+ rs = q;
1691
+ continue;
1692
+ }
1693
+ ++q;
1694
+ }
1695
+ if (q >= 0) {
1696
+ if (streamKeys) {
1697
+ tokens.push(tokenStartKey);
1698
+ if (s) tokens.push({ name: "stringChunk", value: s });
1699
+ tokens.push(tokenEndKey);
1700
+ }
1701
+ if (packKeys) tokens.push({ name: "keyValue", value: s });
1702
+ index = q + 1;
1703
+ expect = "colon";
1704
+ continue main;
1705
+ }
1706
+ if (streamKeys) tokens.push(tokenStartKey);
1707
+ expect = "keyVal";
1708
+ ++index;
1709
+ continue main;
1710
+ }
1711
+ if (cc === ASCII_CLOSE_BRACE) {
1712
+ if (expect !== "key1") throw new Error("Parser cannot parse input: unexpected token '}'");
1713
+ tokens.push(tokenEndObject);
1714
+ parent = stack.pop();
1715
+ expect = expected[parent];
1716
+ ++index;
1717
+ continue main;
1718
+ }
1719
+ throw new Error("Parser cannot parse input: expected an object key");
1720
+ }
1721
+ case "colon": {
1722
+ while (index < buffer.length) {
1723
+ cc = buffer.charCodeAt(index);
1724
+ if (cc === ASCII_SPACE || cc === ASCII_TAB || cc === ASCII_LF || cc === ASCII_CR) {
1725
+ ++index;
1726
+ continue;
1727
+ }
1728
+ break;
1729
+ }
1730
+ if (index >= buffer.length) {
1731
+ if (done) throw new Error("Parser cannot parse input: expected ':'");
1732
+ break main;
1733
+ }
1734
+ cc = buffer.charCodeAt(index);
1735
+ if (cc === ASCII_COLON) {
1736
+ expect = "value";
1737
+ ++index;
1738
+ continue main;
1739
+ }
1740
+ throw new Error("Parser cannot parse input: expected ':'");
1741
+ }
1742
+ case "arrayStop":
1743
+ case "objectStop": {
1744
+ while (index < buffer.length) {
1745
+ cc = buffer.charCodeAt(index);
1746
+ if (cc === ASCII_SPACE || cc === ASCII_TAB || cc === ASCII_LF || cc === ASCII_CR) {
1747
+ ++index;
1748
+ continue;
1749
+ }
1750
+ break;
1751
+ }
1752
+ if (index >= buffer.length) {
1753
+ if (done) throw new Error("Parser cannot parse input: expected ','");
1754
+ break main;
1755
+ }
1756
+ if (openNumber) {
1757
+ if (streamNumbers) tokens.push(tokenEndNumber);
1758
+ openNumber = false;
1759
+ if (packNumbers) {
1760
+ tokens.push({ name: "numberValue", value: accumulator });
1761
+ accumulator = "";
1762
+ }
1763
+ }
1764
+ cc = buffer.charCodeAt(index);
1765
+ if (cc === ASCII_COMMA) {
1766
+ expect = expect === "arrayStop" ? "value" : "key";
1767
+ ++index;
1768
+ continue main;
1769
+ }
1770
+ if (cc === ASCII_CLOSE_BRACE || cc === ASCII_CLOSE_BRACKET) {
1771
+ if (cc === ASCII_CLOSE_BRACE ? expect === "arrayStop" : expect !== "arrayStop") {
1772
+ throw new Error("Parser cannot parse input: expected '" + (expect === "arrayStop" ? "]" : "}") + "'");
1773
+ }
1774
+ tokens.push(cc === ASCII_CLOSE_BRACE ? tokenEndObject : tokenEndArray);
1775
+ parent = stack.pop();
1776
+ expect = expected[parent];
1777
+ ++index;
1778
+ continue main;
1779
+ }
1780
+ throw new Error("Parser cannot parse input: expected ','");
1781
+ }
1782
+ // number chunks — cross-chunk / fallback
1783
+ case "numberStart":
1784
+ patterns.numberStart.lastIndex = index;
1785
+ match = patterns.numberStart.exec(buffer);
1786
+ if (!match) {
1787
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a starting digit");
1788
+ break main;
1789
+ }
1790
+ value = match[0];
1791
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1792
+ packNumbers && (accumulator += value);
1793
+ expect = value === "0" ? "numberFraction" : "numberDigit";
1794
+ index += value.length;
1795
+ break;
1796
+ case "numberDigit":
1797
+ patterns.numberDigit.lastIndex = index;
1798
+ match = patterns.numberDigit.exec(buffer);
1799
+ if (!match) {
1800
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a digit");
1801
+ break main;
1802
+ }
1803
+ value = match[0];
1804
+ if (value) {
1805
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1806
+ packNumbers && (accumulator += value);
1807
+ index += value.length;
1808
+ } else {
1809
+ if (index < buffer.length) {
1810
+ expect = "numberFraction";
1811
+ break;
1812
+ }
1813
+ if (done) {
1814
+ expect = expected[parent];
1815
+ break;
1816
+ }
1817
+ break main;
1818
+ }
1819
+ break;
1820
+ case "numberFraction":
1821
+ patterns.numberFraction.lastIndex = index;
1822
+ match = patterns.numberFraction.exec(buffer);
1823
+ if (!match) {
1824
+ if (index < buffer.length || done) {
1825
+ expect = expected[parent];
1826
+ break;
1827
+ }
1828
+ break main;
1829
+ }
1830
+ value = match[0];
1831
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1832
+ packNumbers && (accumulator += value);
1833
+ expect = value === "." ? "numberFracStart" : "numberExpSign";
1834
+ index += value.length;
1835
+ break;
1836
+ case "numberFracStart":
1837
+ patterns.numberFracStart.lastIndex = index;
1838
+ match = patterns.numberFracStart.exec(buffer);
1839
+ if (!match) {
1840
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a fractional part of a number");
1841
+ break main;
1842
+ }
1843
+ value = match[0];
1844
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1845
+ packNumbers && (accumulator += value);
1846
+ expect = "numberFracDigit";
1847
+ index += value.length;
1848
+ break;
1849
+ case "numberFracDigit":
1850
+ patterns.numberFracDigit.lastIndex = index;
1851
+ match = patterns.numberFracDigit.exec(buffer);
1852
+ value = match[0];
1853
+ if (value) {
1854
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1855
+ packNumbers && (accumulator += value);
1856
+ index += value.length;
1857
+ } else {
1858
+ if (index < buffer.length) {
1859
+ expect = "numberExponent";
1860
+ break;
1861
+ }
1862
+ if (done) {
1863
+ expect = expected[parent];
1864
+ break;
1865
+ }
1866
+ break main;
1867
+ }
1868
+ break;
1869
+ case "numberExponent":
1870
+ patterns.numberExponent.lastIndex = index;
1871
+ match = patterns.numberExponent.exec(buffer);
1872
+ if (!match) {
1873
+ if (index < buffer.length) {
1874
+ expect = expected[parent];
1875
+ break;
1876
+ }
1877
+ if (done) {
1878
+ expect = expected[parent];
1879
+ break;
1880
+ }
1881
+ break main;
1882
+ }
1883
+ value = match[0];
1884
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1885
+ packNumbers && (accumulator += value);
1886
+ expect = "numberExpSign";
1887
+ index += value.length;
1888
+ break;
1889
+ case "numberExpSign":
1890
+ patterns.numberExpSign.lastIndex = index;
1891
+ match = patterns.numberExpSign.exec(buffer);
1892
+ if (!match) {
1893
+ if (index < buffer.length) {
1894
+ expect = "numberExpStart";
1895
+ break;
1896
+ }
1897
+ if (done) throw new Error("Parser has expected an exponent value of a number");
1898
+ break main;
1899
+ }
1900
+ value = match[0];
1901
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1902
+ packNumbers && (accumulator += value);
1903
+ expect = "numberExpStart";
1904
+ index += value.length;
1905
+ break;
1906
+ case "numberExpStart":
1907
+ patterns.numberExpStart.lastIndex = index;
1908
+ match = patterns.numberExpStart.exec(buffer);
1909
+ if (!match) {
1910
+ if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected an exponent part of a number");
1911
+ break main;
1912
+ }
1913
+ value = match[0];
1914
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1915
+ packNumbers && (accumulator += value);
1916
+ expect = "numberExpDigit";
1917
+ index += value.length;
1918
+ break;
1919
+ case "numberExpDigit":
1920
+ patterns.numberExpDigit.lastIndex = index;
1921
+ match = patterns.numberExpDigit.exec(buffer);
1922
+ value = match[0];
1923
+ if (value) {
1924
+ if (streamNumbers) tokens.push({ name: "numberChunk", value });
1925
+ packNumbers && (accumulator += value);
1926
+ index += value.length;
1927
+ } else {
1928
+ if (index < buffer.length || done) {
1929
+ expect = expected[parent];
1930
+ break;
1931
+ }
1932
+ break main;
1933
+ }
1934
+ break;
1935
+ case "done": {
1936
+ while (index < buffer.length) {
1937
+ cc = buffer.charCodeAt(index);
1938
+ if (cc === ASCII_SPACE || cc === ASCII_TAB || cc === ASCII_LF || cc === ASCII_CR) {
1939
+ if (openNumber) {
1940
+ if (streamNumbers) tokens.push(tokenEndNumber);
1941
+ openNumber = false;
1942
+ if (packNumbers) {
1943
+ tokens.push({ name: "numberValue", value: accumulator });
1944
+ accumulator = "";
1945
+ }
1946
+ }
1947
+ ++index;
1948
+ continue;
1949
+ }
1950
+ break;
1951
+ }
1952
+ if (index >= buffer.length) break main;
1953
+ if (jsonStreaming) {
1954
+ if (openNumber) {
1955
+ if (streamNumbers) tokens.push(tokenEndNumber);
1956
+ openNumber = false;
1957
+ if (packNumbers) {
1958
+ tokens.push({ name: "numberValue", value: accumulator });
1959
+ accumulator = "";
1960
+ }
1961
+ }
1962
+ expect = "value";
1963
+ continue main;
1964
+ }
1965
+ throw new Error("Parser cannot parse input: unexpected characters");
1966
+ }
1967
+ }
1968
+ }
1969
+ if (done && openNumber) {
1970
+ if (streamNumbers) tokens.push(tokenEndNumber);
1971
+ openNumber = false;
1972
+ if (packNumbers) {
1973
+ tokens.push({ name: "numberValue", value: accumulator });
1974
+ accumulator = "";
1975
+ }
1976
+ }
1977
+ buffer = buffer.slice(index);
1978
+ return tokens.length ? many(tokens) : none;
1979
+ });
1980
+ };
1981
+ var parser = (options) => gen_default(fixUtf8Stream_default(options), jsonParser(options));
1982
+ parser.parser = parser;
1983
+ var parser_default = parser;
1984
+
1985
+ // ../../node_modules/stream-json/src/parser.js
1986
+ parser_default.asStream = (options) => asStream_default(parser_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
1987
+ parser_default.asWebStream = (options) => asWebStream_default(parser_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
1988
+ var parser_default2 = parser_default;
1989
+
1990
+ // ../../node_modules/stream-json/src/index.js
1991
+ var parserStream = parser_default2.asStream;
1992
+ var src_default2 = parserStream;
1993
+ // Annotate the CommonJS export names for ESM import in node:
1994
+ 0 && (module.exports = {
1995
+ parser,
1996
+ parserStream
1997
+ });