rm-graphical-computing-node 1.0.98 → 1.0.100
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/dist/index.mjs +2133 -82
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,10 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
7
7
|
var __commonJS = (cb, mod) => function __require() {
|
|
8
8
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
9
|
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
10
14
|
var __copyProps = (to, from, except, desc) => {
|
|
11
15
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
16
|
for (let key of __getOwnPropNames(from))
|
|
@@ -304,8 +308,8 @@ var require_rbush = __commonJS({
|
|
|
304
308
|
}
|
|
305
309
|
return node;
|
|
306
310
|
};
|
|
307
|
-
RBush.prototype._insert = function _insert(item, level,
|
|
308
|
-
var bbox2 =
|
|
311
|
+
RBush.prototype._insert = function _insert(item, level, isNode2) {
|
|
312
|
+
var bbox2 = isNode2 ? item : this.toBBox(item);
|
|
309
313
|
var insertPath = [];
|
|
310
314
|
var node = this._chooseSubtree(bbox2, this.data, level, insertPath);
|
|
311
315
|
node.children.push(item);
|
|
@@ -4240,11 +4244,11 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
4240
4244
|
if (Math.abs(tmpRegion.facePoints[0].z - line2.start.z) < doorSill) {
|
|
4241
4245
|
let isInsert = false;
|
|
4242
4246
|
for (let k = 0; k < runDataList.length; k++) {
|
|
4243
|
-
let
|
|
4244
|
-
if (
|
|
4247
|
+
let next2 = k + 1;
|
|
4248
|
+
if (next2 >= runDataList.length)
|
|
4245
4249
|
continue;
|
|
4246
4250
|
let start = new THREE5.Vector3(runDataList[k].x, runDataList[k].y, runDataList[k].z);
|
|
4247
|
-
let end = new THREE5.Vector3(runDataList[
|
|
4251
|
+
let end = new THREE5.Vector3(runDataList[next2].x, runDataList[next2].y, runDataList[next2].z);
|
|
4248
4252
|
let insertPt = segmentsIntersect2D(
|
|
4249
4253
|
new THREE5.Vector3(start.x, start.y, 0),
|
|
4250
4254
|
new THREE5.Vector3(end.x, end.y, 0),
|
|
@@ -6233,7 +6237,7 @@ var getColLine = async (lines, runDataList, collectDataPath, pointCloudCluster =
|
|
|
6233
6237
|
if (tmpLineData.checkResults.length != 1) continue;
|
|
6234
6238
|
lines2.push(tmpLineData);
|
|
6235
6239
|
}
|
|
6236
|
-
await penetratingTask(lines2, trajectoryObj, collectDataPath, 0.
|
|
6240
|
+
await penetratingTask(lines2, trajectoryObj, collectDataPath, 0.2);
|
|
6237
6241
|
for (let i = 0; i < lines2.length; i++) {
|
|
6238
6242
|
let len = lines2[i].checkResults[0].allCenterPoints.length;
|
|
6239
6243
|
const allCenterPoints = lines2[i].allCenterPoints;
|
|
@@ -6268,7 +6272,7 @@ var getColLine = async (lines, runDataList, collectDataPath, pointCloudCluster =
|
|
|
6268
6272
|
}
|
|
6269
6273
|
colDatas.threeEdgeRect = colDatas.threeEdgeRect.filter((p) => !p.isDel);
|
|
6270
6274
|
}
|
|
6271
|
-
return colDatas;
|
|
6275
|
+
return { colDatas, lines };
|
|
6272
6276
|
};
|
|
6273
6277
|
var penetratingTask = async (finalLines, trajectoryObj, collectDataPath, offsetsNum = 0.5, type = "normal", diff = 0.01) => {
|
|
6274
6278
|
if (!finalLines.length) return finalLines;
|
|
@@ -7799,26 +7803,26 @@ function computeContour(points) {
|
|
|
7799
7803
|
contour.push(uniq[cur]);
|
|
7800
7804
|
visited[cur] = 1;
|
|
7801
7805
|
const nb = adj.get(cur) || [];
|
|
7802
|
-
let
|
|
7806
|
+
let next2 = -1;
|
|
7803
7807
|
for (let i = 0; i < nb.length; i++) {
|
|
7804
7808
|
const v2 = nb[i];
|
|
7805
7809
|
if (v2 !== prev && !visited[v2]) {
|
|
7806
|
-
|
|
7810
|
+
next2 = v2;
|
|
7807
7811
|
break;
|
|
7808
7812
|
}
|
|
7809
7813
|
}
|
|
7810
|
-
if (
|
|
7814
|
+
if (next2 === -1) {
|
|
7811
7815
|
for (let i = 0; i < nb.length; i++) {
|
|
7812
7816
|
const v2 = nb[i];
|
|
7813
7817
|
if (v2 !== prev) {
|
|
7814
|
-
|
|
7818
|
+
next2 = v2;
|
|
7815
7819
|
break;
|
|
7816
7820
|
}
|
|
7817
7821
|
}
|
|
7818
7822
|
}
|
|
7819
|
-
if (
|
|
7823
|
+
if (next2 === -1) break;
|
|
7820
7824
|
prev = cur;
|
|
7821
|
-
cur =
|
|
7825
|
+
cur = next2;
|
|
7822
7826
|
} while (cur !== start && contour.length <= boundaryLength + 1);
|
|
7823
7827
|
if (contour.length > 0) {
|
|
7824
7828
|
contour.push(contour[0]);
|
|
@@ -7940,8 +7944,8 @@ function isObject(input) {
|
|
|
7940
7944
|
// node_modules/@turf/meta/dist/esm/index.js
|
|
7941
7945
|
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
7942
7946
|
if (geojson === null) return;
|
|
7943
|
-
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature",
|
|
7944
|
-
for (var featureIndex = 0; featureIndex <
|
|
7947
|
+
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop2 = isFeatureCollection ? geojson.features.length : 1;
|
|
7948
|
+
for (var featureIndex = 0; featureIndex < stop2; featureIndex++) {
|
|
7945
7949
|
geometryMaybeCollection = isFeatureCollection ? (
|
|
7946
7950
|
// @ts-expect-error: Known type conflict
|
|
7947
7951
|
geojson.features[featureIndex].geometry
|
|
@@ -8063,8 +8067,8 @@ function coordAll(geojson) {
|
|
|
8063
8067
|
return coords;
|
|
8064
8068
|
}
|
|
8065
8069
|
function geomEach(geojson, callback) {
|
|
8066
|
-
var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection, featureProperties, featureBBox, featureId, featureIndex = 0, isFeatureCollection = geojson.type === "FeatureCollection", isFeature = geojson.type === "Feature",
|
|
8067
|
-
for (i = 0; i <
|
|
8070
|
+
var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection, featureProperties, featureBBox, featureId, featureIndex = 0, isFeatureCollection = geojson.type === "FeatureCollection", isFeature = geojson.type === "Feature", stop2 = isFeatureCollection ? geojson.features.length : 1;
|
|
8071
|
+
for (i = 0; i < stop2; i++) {
|
|
8068
8072
|
geometryMaybeCollection = isFeatureCollection ? (
|
|
8069
8073
|
// @ts-expect-error: Known type conflict
|
|
8070
8074
|
geojson.features[i].geometry
|
|
@@ -9591,6 +9595,30 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
9591
9595
|
}
|
|
9592
9596
|
return retPcdPointArr;
|
|
9593
9597
|
};
|
|
9598
|
+
var checkSwitchSizeIsTrue = (retPcdPointArr) => {
|
|
9599
|
+
for (let i = 0; i < retPcdPointArr.length; i++) {
|
|
9600
|
+
const pcd = retPcdPointArr[i];
|
|
9601
|
+
if (!pcd.direction || !pcd.obj_id.includes("switch"))
|
|
9602
|
+
continue;
|
|
9603
|
+
let direction = getPt3(pcd.direction);
|
|
9604
|
+
const size = new THREE8.Vector3();
|
|
9605
|
+
pcd.obbBox.getSize(size);
|
|
9606
|
+
const e = pcd.obbBox.rotation.elements;
|
|
9607
|
+
const xAxis = new THREE8.Vector3(e[0], e[1], e[2]).multiplyScalar(size.x);
|
|
9608
|
+
const yAxis = new THREE8.Vector3(e[3], e[4], e[5]).multiplyScalar(size.y);
|
|
9609
|
+
console.log(xAxis, yAxis, size);
|
|
9610
|
+
let isPX = isParallel(xAxis, direction);
|
|
9611
|
+
let isPY = isParallel(yAxis, direction);
|
|
9612
|
+
if (isPX.parallel && (size.x > 0.06 || size.y < 0.05)) {
|
|
9613
|
+
pcd.isDel = true;
|
|
9614
|
+
} else if (isPY.parallel && (size.y > 0.06 || size.x < 0.05)) {
|
|
9615
|
+
pcd.isDel = true;
|
|
9616
|
+
}
|
|
9617
|
+
if (size.z > 0.3)
|
|
9618
|
+
pcd.isDel = true;
|
|
9619
|
+
}
|
|
9620
|
+
return retPcdPointArr.filter((item) => !item.isDel);
|
|
9621
|
+
};
|
|
9594
9622
|
var getMergeFloorMeaning = (allProjectionResults) => {
|
|
9595
9623
|
if (allProjectionResults.length == 0) return [];
|
|
9596
9624
|
const pcdPointsArr = [];
|
|
@@ -11108,11 +11136,11 @@ function computeContour2(points) {
|
|
|
11108
11136
|
contour.push(uniq[cur]);
|
|
11109
11137
|
visited.add(cur);
|
|
11110
11138
|
const nb = adj.get(cur) || [];
|
|
11111
|
-
let
|
|
11112
|
-
if (
|
|
11113
|
-
if (
|
|
11139
|
+
let next2 = nb.find((n) => n !== prev && !visited.has(n));
|
|
11140
|
+
if (next2 === void 0) next2 = nb.find((n) => n !== prev);
|
|
11141
|
+
if (next2 === void 0) break;
|
|
11114
11142
|
prev = cur;
|
|
11115
|
-
cur =
|
|
11143
|
+
cur = next2;
|
|
11116
11144
|
} while (cur !== start && contour.length <= boundary.length + 1);
|
|
11117
11145
|
if (contour.length > 0)
|
|
11118
11146
|
contour.push(contour[0]);
|
|
@@ -11122,28 +11150,2060 @@ function computeContour2(points) {
|
|
|
11122
11150
|
// src/geometry/slabLine.mjs
|
|
11123
11151
|
import * as THREE9 from "three";
|
|
11124
11152
|
import { max, min } from "three/tsl";
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
|
|
11153
|
+
|
|
11154
|
+
// node_modules/stream-chain/src/index.js
|
|
11155
|
+
import { Readable, Writable, Duplex as Duplex2 } from "node:stream";
|
|
11156
|
+
|
|
11157
|
+
// node_modules/stream-chain/src/defs.js
|
|
11158
|
+
var defs_exports = {};
|
|
11159
|
+
__export(defs_exports, {
|
|
11160
|
+
Stop: () => Stop,
|
|
11161
|
+
clearFunctionList: () => clearFunctionList,
|
|
11162
|
+
combineMany: () => combineMany,
|
|
11163
|
+
combineManyMut: () => combineManyMut,
|
|
11164
|
+
fListSymbol: () => fListSymbol,
|
|
11165
|
+
final: () => final,
|
|
11166
|
+
finalSymbol: () => finalSymbol,
|
|
11167
|
+
finalValue: () => finalValue,
|
|
11168
|
+
flushSymbol: () => flushSymbol,
|
|
11169
|
+
flushable: () => flushable,
|
|
11170
|
+
getFinalValue: () => getFinalValue,
|
|
11171
|
+
getFunctionList: () => getFunctionList,
|
|
11172
|
+
getManyValues: () => getManyValues,
|
|
11173
|
+
isDuplexNodeStream: () => isDuplexNodeStream,
|
|
11174
|
+
isDuplexWebStream: () => isDuplexWebStream,
|
|
11175
|
+
isFinalValue: () => isFinalValue,
|
|
11176
|
+
isFlushable: () => isFlushable,
|
|
11177
|
+
isFunctionList: () => isFunctionList,
|
|
11178
|
+
isMany: () => isMany,
|
|
11179
|
+
isReadableNodeStream: () => isReadableNodeStream,
|
|
11180
|
+
isReadableWebStream: () => isReadableWebStream,
|
|
11181
|
+
isWritableNodeStream: () => isWritableNodeStream,
|
|
11182
|
+
isWritableWebStream: () => isWritableWebStream,
|
|
11183
|
+
many: () => many,
|
|
11184
|
+
manySymbol: () => manySymbol,
|
|
11185
|
+
none: () => none,
|
|
11186
|
+
normalizeMany: () => normalizeMany,
|
|
11187
|
+
setFunctionList: () => setFunctionList,
|
|
11188
|
+
stop: () => stop,
|
|
11189
|
+
toMany: () => toMany
|
|
11190
|
+
});
|
|
11191
|
+
var none = /* @__PURE__ */ Symbol.for("object-stream.none");
|
|
11192
|
+
var stop = /* @__PURE__ */ Symbol.for("object-stream.stop");
|
|
11193
|
+
var finalSymbol = /* @__PURE__ */ Symbol.for("object-stream.final");
|
|
11194
|
+
var manySymbol = /* @__PURE__ */ Symbol.for("object-stream.many");
|
|
11195
|
+
var flushSymbol = /* @__PURE__ */ Symbol.for("object-stream.flush");
|
|
11196
|
+
var fListSymbol = /* @__PURE__ */ Symbol.for("object-stream.fList");
|
|
11197
|
+
var finalValue = (value) => ({ [finalSymbol]: 1, value });
|
|
11198
|
+
var many = (values) => ({ [manySymbol]: 1, values });
|
|
11199
|
+
var isFinalValue = (o) => o && o[finalSymbol] === 1;
|
|
11200
|
+
var isMany = (o) => o && o[manySymbol] === 1;
|
|
11201
|
+
var isFlushable = (o) => o && o[flushSymbol] === 1;
|
|
11202
|
+
var isFunctionList = (o) => o && o[fListSymbol] === 1;
|
|
11203
|
+
var getFinalValue = (o) => o.value;
|
|
11204
|
+
var getManyValues = (o) => o.values;
|
|
11205
|
+
var getFunctionList = (o) => o.fList;
|
|
11206
|
+
var flushable = (write2, final3 = null) => {
|
|
11207
|
+
const fn = final3 ? (value) => value === none ? final3() : write2(value) : write2;
|
|
11208
|
+
fn[flushSymbol] = 1;
|
|
11209
|
+
return fn;
|
|
11210
|
+
};
|
|
11211
|
+
var setFunctionList = (o, fns) => {
|
|
11212
|
+
o.fList = fns;
|
|
11213
|
+
o[fListSymbol] = 1;
|
|
11214
|
+
return o;
|
|
11215
|
+
};
|
|
11216
|
+
var clearFunctionList = (o) => {
|
|
11217
|
+
delete o.fList;
|
|
11218
|
+
delete o[fListSymbol];
|
|
11219
|
+
return o;
|
|
11220
|
+
};
|
|
11221
|
+
var Stop = class extends Error {
|
|
11222
|
+
};
|
|
11223
|
+
var toMany = (value) => value === none ? many([]) : value && value[manySymbol] === 1 ? value : many([value]);
|
|
11224
|
+
var normalizeMany = (o) => {
|
|
11225
|
+
if (o?.[manySymbol] === 1) {
|
|
11226
|
+
switch (o.values.length) {
|
|
11227
|
+
case 0:
|
|
11228
|
+
return none;
|
|
11229
|
+
case 1:
|
|
11230
|
+
return o.values[0];
|
|
11231
|
+
}
|
|
11232
|
+
}
|
|
11233
|
+
return o;
|
|
11234
|
+
};
|
|
11235
|
+
var combineMany = (...args) => {
|
|
11236
|
+
const values = [];
|
|
11237
|
+
for (let i = 0; i < args.length; ++i) {
|
|
11238
|
+
const a = args[i];
|
|
11239
|
+
if (a === none) continue;
|
|
11240
|
+
if (a?.[manySymbol] === 1) {
|
|
11241
|
+
values.push(...a.values);
|
|
11242
|
+
} else {
|
|
11243
|
+
values.push(a);
|
|
11244
|
+
}
|
|
11245
|
+
}
|
|
11246
|
+
return many(values);
|
|
11247
|
+
};
|
|
11248
|
+
var combineManyMut = (a, ...args) => {
|
|
11249
|
+
const values = a === none ? [] : a?.[manySymbol] === 1 ? a.values : [a];
|
|
11250
|
+
for (let i = 0; i < args.length; ++i) {
|
|
11251
|
+
const b = args[i];
|
|
11252
|
+
if (b === none) continue;
|
|
11253
|
+
if (b?.[manySymbol] === 1) {
|
|
11254
|
+
values.push(...b.values);
|
|
11255
|
+
} else {
|
|
11256
|
+
values.push(b);
|
|
11257
|
+
}
|
|
11258
|
+
}
|
|
11259
|
+
return many(values);
|
|
11260
|
+
};
|
|
11261
|
+
var isReadableWebStream = (x) => !!(x && typeof x === "object" && typeof x.getReader === "function" && typeof x.pipeTo === "function");
|
|
11262
|
+
var isWritableWebStream = (x) => !!(x && typeof x === "object" && typeof x.getWriter === "function" && typeof x.abort === "function");
|
|
11263
|
+
var isDuplexWebStream = (x) => !!(x && typeof x === "object" && isReadableWebStream(x.readable) && isWritableWebStream(x.writable));
|
|
11264
|
+
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);
|
|
11265
|
+
var isWritableNodeStream = (obj) => obj && typeof obj.write === "function" && typeof obj.on === "function" && (!obj._readableState || (typeof obj._writableState === "object" ? obj._writableState.writable : null) !== false);
|
|
11266
|
+
var isDuplexNodeStream = (obj) => obj && typeof obj.pipe === "function" && obj._readableState && typeof obj.on === "function" && typeof obj.write === "function";
|
|
11267
|
+
var final = finalValue;
|
|
11268
|
+
|
|
11269
|
+
// node_modules/stream-chain/src/exec.js
|
|
11270
|
+
var next = (value, fns, index, push) => {
|
|
11271
|
+
for (let i = index; ; ) {
|
|
11272
|
+
if (value && typeof value.then == "function") {
|
|
11273
|
+
const ii = i;
|
|
11274
|
+
return value.then((v2) => next(v2, fns, ii, push));
|
|
11275
|
+
}
|
|
11276
|
+
if (value == null || value === none) return;
|
|
11277
|
+
if (value === stop) throw new Stop();
|
|
11278
|
+
if (isFinalValue(value)) {
|
|
11279
|
+
return push(getFinalValue(value));
|
|
11280
|
+
}
|
|
11281
|
+
if (isMany(value)) {
|
|
11282
|
+
return nextMany(getManyValues(value), fns, i, push);
|
|
11283
|
+
}
|
|
11284
|
+
if (value && typeof value.next == "function") {
|
|
11285
|
+
return nextGen(value, fns, i, push);
|
|
11286
|
+
}
|
|
11287
|
+
if (i >= fns.length) {
|
|
11288
|
+
return push(value);
|
|
11289
|
+
}
|
|
11290
|
+
value = fns[i++](value);
|
|
11291
|
+
}
|
|
11292
|
+
};
|
|
11293
|
+
var nextMany = (values, fns, i, push) => {
|
|
11294
|
+
const step = (j) => {
|
|
11295
|
+
for (; j < values.length; ++j) {
|
|
11296
|
+
const r = next(values[j], fns, i, push);
|
|
11297
|
+
if (r && typeof r.then == "function") {
|
|
11298
|
+
const jj = j;
|
|
11299
|
+
return r.then(() => step(jj + 1));
|
|
11136
11300
|
}
|
|
11137
11301
|
}
|
|
11302
|
+
};
|
|
11303
|
+
return step(0);
|
|
11304
|
+
};
|
|
11305
|
+
var nextGen = (it, fns, i, push) => {
|
|
11306
|
+
const step = () => {
|
|
11307
|
+
for (; ; ) {
|
|
11308
|
+
let data = it.next();
|
|
11309
|
+
if (data && typeof data.then == "function") {
|
|
11310
|
+
return data.then((d) => {
|
|
11311
|
+
if (d.done) return;
|
|
11312
|
+
const r3 = next(d.value, fns, i, push);
|
|
11313
|
+
return r3 && typeof r3.then == "function" ? r3.then(step) : step();
|
|
11314
|
+
});
|
|
11315
|
+
}
|
|
11316
|
+
if (data.done) return;
|
|
11317
|
+
const r2 = next(data.value, fns, i, push);
|
|
11318
|
+
if (r2 && typeof r2.then == "function") return r2.then(step);
|
|
11319
|
+
}
|
|
11320
|
+
};
|
|
11321
|
+
const abort = (err) => {
|
|
11322
|
+
const onCleanupError = (cleanupErr) => err instanceof Error ? new AggregateError([err, cleanupErr], "pipeline error; generator cleanup also failed") : err;
|
|
11323
|
+
let ret;
|
|
11324
|
+
try {
|
|
11325
|
+
ret = it.return ? it.return() : void 0;
|
|
11326
|
+
} catch (cleanupErr) {
|
|
11327
|
+
throw onCleanupError(cleanupErr);
|
|
11328
|
+
}
|
|
11329
|
+
if (ret && typeof ret.then == "function") {
|
|
11330
|
+
return ret.then(
|
|
11331
|
+
() => {
|
|
11332
|
+
throw err;
|
|
11333
|
+
},
|
|
11334
|
+
(cleanupErr) => {
|
|
11335
|
+
throw onCleanupError(cleanupErr);
|
|
11336
|
+
}
|
|
11337
|
+
);
|
|
11338
|
+
}
|
|
11339
|
+
throw err;
|
|
11340
|
+
};
|
|
11341
|
+
let r;
|
|
11342
|
+
try {
|
|
11343
|
+
r = step();
|
|
11344
|
+
} catch (err) {
|
|
11345
|
+
return abort(err);
|
|
11346
|
+
}
|
|
11347
|
+
return r && typeof r.then == "function" ? r.then(void 0, abort) : r;
|
|
11348
|
+
};
|
|
11349
|
+
var flush = (fns, index, push) => {
|
|
11350
|
+
const step = (i) => {
|
|
11351
|
+
for (; i < fns.length; ++i) {
|
|
11352
|
+
const f = fns[i];
|
|
11353
|
+
if (!isFlushable(f)) continue;
|
|
11354
|
+
const r = next(f(none), fns, i + 1, push);
|
|
11355
|
+
if (r && typeof r.then == "function") {
|
|
11356
|
+
const ii = i;
|
|
11357
|
+
return r.then(() => step(ii + 1));
|
|
11358
|
+
}
|
|
11359
|
+
}
|
|
11360
|
+
};
|
|
11361
|
+
return step(index);
|
|
11362
|
+
};
|
|
11363
|
+
|
|
11364
|
+
// node_modules/stream-chain/src/gen.js
|
|
11365
|
+
var gen = (...fns) => {
|
|
11366
|
+
fns = fns.filter((fn) => fn).flat(Infinity).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
|
|
11367
|
+
if (!fns.length) {
|
|
11368
|
+
fns = [(x) => x];
|
|
11369
|
+
}
|
|
11370
|
+
let flushed = false;
|
|
11371
|
+
let g = async function* (value) {
|
|
11372
|
+
if (flushed) throw Error("Call to a flushed pipe.");
|
|
11373
|
+
const isFlush = value === none;
|
|
11374
|
+
if (isFlush) flushed = true;
|
|
11375
|
+
const pending = [];
|
|
11376
|
+
let wakeConsumer = null;
|
|
11377
|
+
let resolveProducer = null;
|
|
11378
|
+
let rejectProducer = null;
|
|
11379
|
+
let done = false, error = null, cancelled = false;
|
|
11380
|
+
const CANCEL = /* @__PURE__ */ Symbol("cancel");
|
|
11381
|
+
const push = (v2) => {
|
|
11382
|
+
if (cancelled) throw CANCEL;
|
|
11383
|
+
pending.push(v2);
|
|
11384
|
+
if (wakeConsumer) {
|
|
11385
|
+
const w = wakeConsumer;
|
|
11386
|
+
wakeConsumer = null;
|
|
11387
|
+
w();
|
|
11388
|
+
}
|
|
11389
|
+
return new Promise((res, rej) => {
|
|
11390
|
+
resolveProducer = res;
|
|
11391
|
+
rejectProducer = rej;
|
|
11392
|
+
});
|
|
11393
|
+
};
|
|
11394
|
+
Promise.resolve().then(() => isFlush ? flush(fns, 0, push) : next(value, fns, 0, push)).then(
|
|
11395
|
+
() => {
|
|
11396
|
+
},
|
|
11397
|
+
(e) => {
|
|
11398
|
+
if (e !== CANCEL) error = e;
|
|
11399
|
+
}
|
|
11400
|
+
).finally(() => {
|
|
11401
|
+
done = true;
|
|
11402
|
+
if (wakeConsumer) {
|
|
11403
|
+
const w = wakeConsumer;
|
|
11404
|
+
wakeConsumer = null;
|
|
11405
|
+
w();
|
|
11406
|
+
}
|
|
11407
|
+
});
|
|
11408
|
+
try {
|
|
11409
|
+
for (; ; ) {
|
|
11410
|
+
while (pending.length) {
|
|
11411
|
+
const v2 = pending.shift();
|
|
11412
|
+
if (resolveProducer) {
|
|
11413
|
+
const r = resolveProducer;
|
|
11414
|
+
resolveProducer = rejectProducer = null;
|
|
11415
|
+
r();
|
|
11416
|
+
}
|
|
11417
|
+
yield v2;
|
|
11418
|
+
}
|
|
11419
|
+
if (error) throw error;
|
|
11420
|
+
if (done) return;
|
|
11421
|
+
await new Promise((res) => wakeConsumer = res);
|
|
11422
|
+
}
|
|
11423
|
+
} finally {
|
|
11424
|
+
cancelled = true;
|
|
11425
|
+
if (rejectProducer) {
|
|
11426
|
+
const rj = rejectProducer;
|
|
11427
|
+
resolveProducer = rejectProducer = null;
|
|
11428
|
+
rj(CANCEL);
|
|
11429
|
+
}
|
|
11430
|
+
}
|
|
11431
|
+
};
|
|
11432
|
+
const needToFlush = fns.some((fn) => isFlushable(fn));
|
|
11433
|
+
if (needToFlush) g = flushable(g);
|
|
11434
|
+
return setFunctionList(g, fns);
|
|
11435
|
+
};
|
|
11436
|
+
var gen_default = gen;
|
|
11437
|
+
|
|
11438
|
+
// node_modules/stream-chain/src/asStream.js
|
|
11439
|
+
import { Duplex } from "node:stream";
|
|
11440
|
+
var asStream = (fn, options) => {
|
|
11441
|
+
if (typeof fn != "function") {
|
|
11442
|
+
throw TypeError("Only a function is accepted as the first argument");
|
|
11443
|
+
}
|
|
11444
|
+
const innerFns = isFunctionList(fn) ? fn.fList : null;
|
|
11445
|
+
let stopped = false;
|
|
11446
|
+
let nullPushed = false;
|
|
11447
|
+
let resolvePaused = null;
|
|
11448
|
+
let stream = null;
|
|
11449
|
+
const resume = () => {
|
|
11450
|
+
if (!resolvePaused) return;
|
|
11451
|
+
const resolve = resolvePaused;
|
|
11452
|
+
resolvePaused = null;
|
|
11453
|
+
resolve();
|
|
11454
|
+
};
|
|
11455
|
+
const signalEnd = () => {
|
|
11456
|
+
if (nullPushed) return;
|
|
11457
|
+
nullPushed = true;
|
|
11458
|
+
stream.push(null);
|
|
11459
|
+
};
|
|
11460
|
+
const enqueue = (value) => {
|
|
11461
|
+
if (stopped) return;
|
|
11462
|
+
if (!stream.push(value)) {
|
|
11463
|
+
return new Promise((resolve) => {
|
|
11464
|
+
resolvePaused = resolve;
|
|
11465
|
+
});
|
|
11466
|
+
}
|
|
11467
|
+
};
|
|
11468
|
+
const queue = [];
|
|
11469
|
+
const pump = async () => {
|
|
11470
|
+
while (queue.length) {
|
|
11471
|
+
const g = queue[queue.length - 1];
|
|
11472
|
+
let result = g.next();
|
|
11473
|
+
if (result && typeof result.then == "function") result = await result;
|
|
11474
|
+
if (result.done) {
|
|
11475
|
+
queue.pop();
|
|
11476
|
+
continue;
|
|
11477
|
+
}
|
|
11478
|
+
let value = result.value;
|
|
11479
|
+
if (value && typeof value.then == "function") value = await value;
|
|
11480
|
+
const r = processValue(value);
|
|
11481
|
+
if (r) await r;
|
|
11482
|
+
}
|
|
11483
|
+
};
|
|
11484
|
+
const processValue = (value) => {
|
|
11485
|
+
if (value && typeof value.then == "function") {
|
|
11486
|
+
return value.then(processValue);
|
|
11487
|
+
}
|
|
11488
|
+
if (value == null || value === none) return;
|
|
11489
|
+
if (value === stop) throw new Stop();
|
|
11490
|
+
if (isMany(value)) {
|
|
11491
|
+
const values = getManyValues(value);
|
|
11492
|
+
let promise;
|
|
11493
|
+
for (let i = 0; i < values.length; ++i) {
|
|
11494
|
+
if (promise) {
|
|
11495
|
+
const ii = i;
|
|
11496
|
+
promise = promise.then(() => processValue(values[ii]));
|
|
11497
|
+
} else {
|
|
11498
|
+
const r = processValue(values[i]);
|
|
11499
|
+
if (r) promise = r;
|
|
11500
|
+
}
|
|
11501
|
+
}
|
|
11502
|
+
return promise;
|
|
11503
|
+
}
|
|
11504
|
+
if (isFinalValue(value)) {
|
|
11505
|
+
return processValue(getFinalValue(value));
|
|
11506
|
+
}
|
|
11507
|
+
if (value && typeof value.next == "function") {
|
|
11508
|
+
queue.push(value);
|
|
11509
|
+
return pump();
|
|
11510
|
+
}
|
|
11511
|
+
return enqueue(value);
|
|
11512
|
+
};
|
|
11513
|
+
const absorbStop = (error) => {
|
|
11514
|
+
if (error instanceof Stop) {
|
|
11515
|
+
stopped = true;
|
|
11516
|
+
signalEnd();
|
|
11517
|
+
return true;
|
|
11518
|
+
}
|
|
11519
|
+
return false;
|
|
11520
|
+
};
|
|
11521
|
+
const finishWrite = (callback, error) => {
|
|
11522
|
+
if (!error) return callback(null);
|
|
11523
|
+
if (absorbStop(error)) return callback(null);
|
|
11524
|
+
callback(error);
|
|
11525
|
+
};
|
|
11526
|
+
stream = new Duplex({
|
|
11527
|
+
writableObjectMode: true,
|
|
11528
|
+
readableObjectMode: true,
|
|
11529
|
+
...options,
|
|
11530
|
+
write(chunk, encoding, callback) {
|
|
11531
|
+
if (stopped) return callback(null);
|
|
11532
|
+
if (innerFns) {
|
|
11533
|
+
let r2;
|
|
11534
|
+
try {
|
|
11535
|
+
r2 = next(chunk, innerFns, 0, enqueue);
|
|
11536
|
+
} catch (error) {
|
|
11537
|
+
return finishWrite(callback, error);
|
|
11538
|
+
}
|
|
11539
|
+
if (r2 && typeof r2.then == "function") {
|
|
11540
|
+
r2.then(
|
|
11541
|
+
() => callback(null),
|
|
11542
|
+
(error) => finishWrite(callback, error)
|
|
11543
|
+
);
|
|
11544
|
+
} else {
|
|
11545
|
+
callback(null);
|
|
11546
|
+
}
|
|
11547
|
+
return;
|
|
11548
|
+
}
|
|
11549
|
+
let r;
|
|
11550
|
+
try {
|
|
11551
|
+
r = processValue(fn(chunk, encoding));
|
|
11552
|
+
} catch (error) {
|
|
11553
|
+
return finishWrite(callback, error);
|
|
11554
|
+
}
|
|
11555
|
+
if (r) {
|
|
11556
|
+
r.then(
|
|
11557
|
+
() => callback(null),
|
|
11558
|
+
(error) => finishWrite(callback, error)
|
|
11559
|
+
);
|
|
11560
|
+
} else {
|
|
11561
|
+
callback(null);
|
|
11562
|
+
}
|
|
11563
|
+
},
|
|
11564
|
+
final(callback) {
|
|
11565
|
+
const onComplete = () => {
|
|
11566
|
+
signalEnd();
|
|
11567
|
+
callback(null);
|
|
11568
|
+
};
|
|
11569
|
+
if (innerFns) {
|
|
11570
|
+
let r2;
|
|
11571
|
+
try {
|
|
11572
|
+
r2 = flush(innerFns, 0, enqueue);
|
|
11573
|
+
} catch (error) {
|
|
11574
|
+
return finishWrite(callback, error);
|
|
11575
|
+
}
|
|
11576
|
+
if (r2 && typeof r2.then == "function") {
|
|
11577
|
+
r2.then(onComplete, (error) => finishWrite(callback, error));
|
|
11578
|
+
} else {
|
|
11579
|
+
onComplete();
|
|
11580
|
+
}
|
|
11581
|
+
return;
|
|
11582
|
+
}
|
|
11583
|
+
if (!isFlushable(fn)) {
|
|
11584
|
+
onComplete();
|
|
11585
|
+
return;
|
|
11586
|
+
}
|
|
11587
|
+
let r;
|
|
11588
|
+
try {
|
|
11589
|
+
r = processValue(fn(none, null));
|
|
11590
|
+
} catch (error) {
|
|
11591
|
+
return finishWrite(callback, error);
|
|
11592
|
+
}
|
|
11593
|
+
if (r) {
|
|
11594
|
+
r.then(onComplete, (error) => finishWrite(callback, error));
|
|
11595
|
+
} else {
|
|
11596
|
+
onComplete();
|
|
11597
|
+
}
|
|
11598
|
+
},
|
|
11599
|
+
read() {
|
|
11600
|
+
resume();
|
|
11601
|
+
},
|
|
11602
|
+
// Unblock any pending paused-promise so an in-flight write can settle —
|
|
11603
|
+
// mirrors asWebStream's controller.signal listener for writer.abort().
|
|
11604
|
+
destroy(error, callback) {
|
|
11605
|
+
stopped = true;
|
|
11606
|
+
resume();
|
|
11607
|
+
callback(error);
|
|
11608
|
+
}
|
|
11609
|
+
});
|
|
11610
|
+
return stream;
|
|
11611
|
+
};
|
|
11612
|
+
var asStream_default = asStream;
|
|
11613
|
+
|
|
11614
|
+
// node_modules/stream-chain/src/asWebStream.js
|
|
11615
|
+
var asWebStream = (fn, options) => {
|
|
11616
|
+
if (isDuplexWebStream(fn) || isReadableWebStream(fn) || isWritableWebStream(fn)) {
|
|
11617
|
+
return fn;
|
|
11618
|
+
}
|
|
11619
|
+
if (typeof fn !== "function") {
|
|
11620
|
+
throw new TypeError("Only a function or Web Streams object is accepted as the first argument");
|
|
11621
|
+
}
|
|
11622
|
+
const strategy = options?.strategy;
|
|
11623
|
+
const readableStrategy = options?.readableStrategy ?? strategy;
|
|
11624
|
+
const writableStrategy = options?.writableStrategy ?? strategy;
|
|
11625
|
+
const innerFns = isFunctionList(fn) ? fn.fList : null;
|
|
11626
|
+
let stopped = false;
|
|
11627
|
+
let readableClosed = false;
|
|
11628
|
+
let writableErrored = false;
|
|
11629
|
+
let readableController;
|
|
11630
|
+
let writableController;
|
|
11631
|
+
let pendingDrain = null;
|
|
11632
|
+
const unblockDrain = () => {
|
|
11633
|
+
if (!pendingDrain) return;
|
|
11634
|
+
const resolve = pendingDrain;
|
|
11635
|
+
pendingDrain = null;
|
|
11636
|
+
resolve();
|
|
11637
|
+
};
|
|
11638
|
+
const closeReadable = () => {
|
|
11639
|
+
if (readableClosed) return;
|
|
11640
|
+
readableClosed = true;
|
|
11641
|
+
readableController.close();
|
|
11642
|
+
};
|
|
11643
|
+
const errorReadable = (reason) => {
|
|
11644
|
+
if (readableClosed) return;
|
|
11645
|
+
readableClosed = true;
|
|
11646
|
+
readableController.error(reason);
|
|
11647
|
+
};
|
|
11648
|
+
const errorWritable = (reason) => {
|
|
11649
|
+
if (writableErrored || !writableController) return;
|
|
11650
|
+
writableErrored = true;
|
|
11651
|
+
writableController.error(reason);
|
|
11652
|
+
};
|
|
11653
|
+
const readable = new ReadableStream(
|
|
11654
|
+
{
|
|
11655
|
+
start(c) {
|
|
11656
|
+
readableController = c;
|
|
11657
|
+
},
|
|
11658
|
+
pull() {
|
|
11659
|
+
unblockDrain();
|
|
11660
|
+
},
|
|
11661
|
+
cancel(reason) {
|
|
11662
|
+
stopped = true;
|
|
11663
|
+
readableClosed = true;
|
|
11664
|
+
unblockDrain();
|
|
11665
|
+
errorWritable(reason);
|
|
11666
|
+
}
|
|
11667
|
+
},
|
|
11668
|
+
readableStrategy
|
|
11669
|
+
);
|
|
11670
|
+
const enqueue = (value) => {
|
|
11671
|
+
if (stopped) return;
|
|
11672
|
+
readableController.enqueue(value);
|
|
11673
|
+
if (readableController.desiredSize <= 0) {
|
|
11674
|
+
return new Promise((resolve) => {
|
|
11675
|
+
pendingDrain = resolve;
|
|
11676
|
+
});
|
|
11677
|
+
}
|
|
11678
|
+
};
|
|
11679
|
+
const queue = [];
|
|
11680
|
+
const pump = async () => {
|
|
11681
|
+
while (queue.length) {
|
|
11682
|
+
const g = queue[queue.length - 1];
|
|
11683
|
+
let result = g.next();
|
|
11684
|
+
if (result && typeof result.then == "function") result = await result;
|
|
11685
|
+
if (result.done) {
|
|
11686
|
+
queue.pop();
|
|
11687
|
+
continue;
|
|
11688
|
+
}
|
|
11689
|
+
let value = result.value;
|
|
11690
|
+
if (value && typeof value.then == "function") value = await value;
|
|
11691
|
+
const r = processValue(value);
|
|
11692
|
+
if (r) await r;
|
|
11693
|
+
}
|
|
11694
|
+
};
|
|
11695
|
+
const processValue = (value) => {
|
|
11696
|
+
if (value && typeof value.then == "function") {
|
|
11697
|
+
return value.then(processValue);
|
|
11698
|
+
}
|
|
11699
|
+
if (value == null || value === none) return;
|
|
11700
|
+
if (value === stop) throw new Stop();
|
|
11701
|
+
if (isMany(value)) {
|
|
11702
|
+
const values = getManyValues(value);
|
|
11703
|
+
let promise;
|
|
11704
|
+
for (let i = 0; i < values.length; ++i) {
|
|
11705
|
+
if (promise) {
|
|
11706
|
+
const ii = i;
|
|
11707
|
+
promise = promise.then(() => processValue(values[ii]));
|
|
11708
|
+
} else {
|
|
11709
|
+
const r = processValue(values[i]);
|
|
11710
|
+
if (r) promise = r;
|
|
11711
|
+
}
|
|
11712
|
+
}
|
|
11713
|
+
return promise;
|
|
11714
|
+
}
|
|
11715
|
+
if (isFinalValue(value)) {
|
|
11716
|
+
return processValue(getFinalValue(value));
|
|
11717
|
+
}
|
|
11718
|
+
if (value && typeof value.next == "function") {
|
|
11719
|
+
queue.push(value);
|
|
11720
|
+
return pump();
|
|
11721
|
+
}
|
|
11722
|
+
return enqueue(value);
|
|
11723
|
+
};
|
|
11724
|
+
const absorbStop = (error) => {
|
|
11725
|
+
if (error instanceof Stop) {
|
|
11726
|
+
stopped = true;
|
|
11727
|
+
return true;
|
|
11728
|
+
}
|
|
11729
|
+
return false;
|
|
11730
|
+
};
|
|
11731
|
+
const writable = new WritableStream(
|
|
11732
|
+
{
|
|
11733
|
+
// `controller.signal` aborts during writer.abort() BEFORE the sink's
|
|
11734
|
+
// abort() callback runs. The spec waits for in-flight write() to
|
|
11735
|
+
// settle first — so if write() is awaiting pendingDrain, we'd
|
|
11736
|
+
// deadlock unless the signal listener wakes it.
|
|
11737
|
+
// Optional-chained because Bun ≤1.3.14 returns `undefined` for the
|
|
11738
|
+
// controller's signal (spec-required per WHATWG Streams §4.5.2 but
|
|
11739
|
+
// missing in Bun's builtin — see oven-sh/bun#31156 / PR #31157).
|
|
11740
|
+
// Fixed upstream (present in Bun 1.4.0); the chaining stays for older
|
|
11741
|
+
// Bun, which only loses the abort wakeup.
|
|
11742
|
+
start(controller) {
|
|
11743
|
+
writableController = controller;
|
|
11744
|
+
controller.signal?.addEventListener("abort", () => {
|
|
11745
|
+
stopped = true;
|
|
11746
|
+
unblockDrain();
|
|
11747
|
+
});
|
|
11748
|
+
},
|
|
11749
|
+
async write(chunk) {
|
|
11750
|
+
if (stopped) return;
|
|
11751
|
+
try {
|
|
11752
|
+
if (innerFns) {
|
|
11753
|
+
const r2 = next(chunk, innerFns, 0, enqueue);
|
|
11754
|
+
if (r2) await r2;
|
|
11755
|
+
return;
|
|
11756
|
+
}
|
|
11757
|
+
const r = processValue(fn(chunk));
|
|
11758
|
+
if (r) await r;
|
|
11759
|
+
} catch (error) {
|
|
11760
|
+
if (absorbStop(error)) return;
|
|
11761
|
+
errorReadable(error);
|
|
11762
|
+
throw error;
|
|
11763
|
+
}
|
|
11764
|
+
},
|
|
11765
|
+
async close() {
|
|
11766
|
+
try {
|
|
11767
|
+
if (!stopped) {
|
|
11768
|
+
if (innerFns) {
|
|
11769
|
+
const r = flush(innerFns, 0, enqueue);
|
|
11770
|
+
if (r) await r;
|
|
11771
|
+
} else if (isFlushable(fn)) {
|
|
11772
|
+
const r = processValue(fn(none));
|
|
11773
|
+
if (r) await r;
|
|
11774
|
+
}
|
|
11775
|
+
}
|
|
11776
|
+
} catch (error) {
|
|
11777
|
+
if (!absorbStop(error)) {
|
|
11778
|
+
errorReadable(error);
|
|
11779
|
+
throw error;
|
|
11780
|
+
}
|
|
11781
|
+
}
|
|
11782
|
+
closeReadable();
|
|
11783
|
+
},
|
|
11784
|
+
abort(reason) {
|
|
11785
|
+
stopped = true;
|
|
11786
|
+
unblockDrain();
|
|
11787
|
+
errorReadable(reason);
|
|
11788
|
+
}
|
|
11789
|
+
},
|
|
11790
|
+
writableStrategy
|
|
11791
|
+
);
|
|
11792
|
+
return { readable, writable };
|
|
11793
|
+
};
|
|
11794
|
+
var asWebStream_default = asWebStream;
|
|
11795
|
+
|
|
11796
|
+
// node_modules/stream-chain/src/dataSource.js
|
|
11797
|
+
var dataSource = (fn) => {
|
|
11798
|
+
if (typeof fn == "function") return fn;
|
|
11799
|
+
if (fn) {
|
|
11800
|
+
if (typeof fn[Symbol.asyncIterator] == "function") return fn[Symbol.asyncIterator].bind(fn);
|
|
11801
|
+
if (typeof fn[Symbol.iterator] == "function") return fn[Symbol.iterator].bind(fn);
|
|
11802
|
+
}
|
|
11803
|
+
throw new TypeError("The argument should be a function or an iterable object.");
|
|
11804
|
+
};
|
|
11805
|
+
var dataSource_default = dataSource;
|
|
11806
|
+
|
|
11807
|
+
// node_modules/stream-chain/src/index.js
|
|
11808
|
+
var {
|
|
11809
|
+
isReadableWebStream: isReadableWebStream2,
|
|
11810
|
+
isWritableWebStream: isWritableWebStream2,
|
|
11811
|
+
isDuplexWebStream: isDuplexWebStream2,
|
|
11812
|
+
isReadableNodeStream: isReadableNodeStream2,
|
|
11813
|
+
isWritableNodeStream: isWritableNodeStream2,
|
|
11814
|
+
isDuplexNodeStream: isDuplexNodeStream2
|
|
11815
|
+
} = defs_exports;
|
|
11816
|
+
var groupFunctions = (output, fn, index, fns) => {
|
|
11817
|
+
if (isDuplexNodeStream2(fn) || !index && isReadableNodeStream2(fn) || index === fns.length - 1 && isWritableNodeStream2(fn)) {
|
|
11818
|
+
output.push(fn);
|
|
11819
|
+
return output;
|
|
11820
|
+
}
|
|
11821
|
+
if (isDuplexWebStream2(fn)) {
|
|
11822
|
+
output.push(Duplex2.fromWeb(fn, { objectMode: true }));
|
|
11823
|
+
return output;
|
|
11824
|
+
}
|
|
11825
|
+
if (!index && isReadableWebStream2(fn)) {
|
|
11826
|
+
output.push(Readable.fromWeb(fn, { objectMode: true }));
|
|
11827
|
+
return output;
|
|
11828
|
+
}
|
|
11829
|
+
if (index === fns.length - 1 && isWritableWebStream2(fn)) {
|
|
11830
|
+
output.push(Writable.fromWeb(fn, { objectMode: true }));
|
|
11831
|
+
return output;
|
|
11832
|
+
}
|
|
11833
|
+
if (typeof fn != "function")
|
|
11834
|
+
throw TypeError("Item #" + index + " is not a proper stream, nor a function.");
|
|
11835
|
+
if (!output.length) output.push([]);
|
|
11836
|
+
const last = output[output.length - 1];
|
|
11837
|
+
if (Array.isArray(last)) {
|
|
11838
|
+
last.push(fn);
|
|
11138
11839
|
} else {
|
|
11139
|
-
|
|
11140
|
-
|
|
11840
|
+
output.push([fn]);
|
|
11841
|
+
}
|
|
11842
|
+
return output;
|
|
11843
|
+
};
|
|
11844
|
+
var produceStreams = (item) => {
|
|
11845
|
+
if (Array.isArray(item)) {
|
|
11846
|
+
if (!item.length) return null;
|
|
11847
|
+
if (item.length == 1) return item[0] && /** @type {any} */
|
|
11848
|
+
chain.asStream(item[0]);
|
|
11849
|
+
return (
|
|
11850
|
+
/** @type {any} */
|
|
11851
|
+
chain.asStream(
|
|
11852
|
+
/** @type {any} */
|
|
11853
|
+
chain.gen(...item)
|
|
11854
|
+
)
|
|
11855
|
+
);
|
|
11856
|
+
}
|
|
11857
|
+
return item;
|
|
11858
|
+
};
|
|
11859
|
+
var wrapFunctions = (fn, index, fns) => {
|
|
11860
|
+
if (isDuplexNodeStream2(fn) || !index && isReadableNodeStream2(fn) || index === fns.length - 1 && isWritableNodeStream2(fn)) {
|
|
11861
|
+
return fn;
|
|
11862
|
+
}
|
|
11863
|
+
if (isDuplexWebStream2(fn)) {
|
|
11864
|
+
return Duplex2.fromWeb(fn, { objectMode: true });
|
|
11865
|
+
}
|
|
11866
|
+
if (!index && isReadableWebStream2(fn)) {
|
|
11867
|
+
return Readable.fromWeb(fn, { objectMode: true });
|
|
11868
|
+
}
|
|
11869
|
+
if (index === fns.length - 1 && isWritableWebStream2(fn)) {
|
|
11870
|
+
return Writable.fromWeb(fn, { objectMode: true });
|
|
11871
|
+
}
|
|
11872
|
+
if (typeof fn == "function") return (
|
|
11873
|
+
/** @type {any} */
|
|
11874
|
+
chain.asStream(fn)
|
|
11875
|
+
);
|
|
11876
|
+
throw TypeError("Item #" + index + " is not a proper stream, nor a function.");
|
|
11877
|
+
};
|
|
11878
|
+
var write = (input, chunk, encoding, callback) => {
|
|
11879
|
+
let error = null;
|
|
11880
|
+
try {
|
|
11881
|
+
input.write(chunk, encoding, (e) => callback(e || error));
|
|
11882
|
+
} catch (e) {
|
|
11883
|
+
error = e;
|
|
11884
|
+
}
|
|
11885
|
+
};
|
|
11886
|
+
var final2 = (input, callback) => {
|
|
11887
|
+
let error = null;
|
|
11888
|
+
try {
|
|
11889
|
+
input.end(null, null, (e) => callback(e || error));
|
|
11890
|
+
} catch (e) {
|
|
11891
|
+
error = e;
|
|
11892
|
+
}
|
|
11893
|
+
};
|
|
11894
|
+
var read = (output) => {
|
|
11895
|
+
output.resume();
|
|
11896
|
+
};
|
|
11897
|
+
var chain = (fns, options) => {
|
|
11898
|
+
if (!Array.isArray(fns) || !fns.length) {
|
|
11899
|
+
throw TypeError("Chain's first argument should be a non-empty array.");
|
|
11900
|
+
}
|
|
11901
|
+
fns = fns.flat(Infinity).filter((fn) => fn);
|
|
11902
|
+
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);
|
|
11903
|
+
let stream = null;
|
|
11904
|
+
let writeMethod = (chunk, encoding, callback) => write(input, chunk, encoding, callback), finalMethod = (callback) => final2(input, callback), readMethod = () => read(output);
|
|
11905
|
+
if (!isWritableNodeStream2(input)) {
|
|
11906
|
+
writeMethod = (_1, _2, callback) => callback(null);
|
|
11907
|
+
finalMethod = (callback) => callback(null);
|
|
11908
|
+
input.on("end", () => stream.end());
|
|
11909
|
+
}
|
|
11910
|
+
if (isReadableNodeStream2(output)) {
|
|
11911
|
+
output.on("data", (chunk) => !stream.push(chunk) && output.pause());
|
|
11912
|
+
output.on("end", () => stream.push(null));
|
|
11913
|
+
} else {
|
|
11914
|
+
readMethod = () => {
|
|
11915
|
+
};
|
|
11916
|
+
output.on("finish", () => stream.push(null));
|
|
11917
|
+
}
|
|
11918
|
+
stream = /** @type {Duplex & {streams: any[], input: any, output: any}} */
|
|
11919
|
+
new Duplex2({
|
|
11920
|
+
writableObjectMode: true,
|
|
11921
|
+
readableObjectMode: true,
|
|
11922
|
+
...options,
|
|
11923
|
+
readable: isReadableNodeStream2(output),
|
|
11924
|
+
writable: isWritableNodeStream2(input),
|
|
11925
|
+
write: writeMethod,
|
|
11926
|
+
final: finalMethod,
|
|
11927
|
+
read: readMethod
|
|
11928
|
+
});
|
|
11929
|
+
stream.streams = streams;
|
|
11930
|
+
stream.input = input;
|
|
11931
|
+
stream.output = output;
|
|
11932
|
+
if (!isReadableNodeStream2(output)) {
|
|
11933
|
+
stream.resume();
|
|
11934
|
+
}
|
|
11935
|
+
if (!options?.skipEvents) {
|
|
11936
|
+
streams.forEach((item) => item.on("error", (error) => stream.emit("error", error)));
|
|
11937
|
+
}
|
|
11938
|
+
return stream;
|
|
11939
|
+
};
|
|
11940
|
+
chain.none = none;
|
|
11941
|
+
chain.stop = stop;
|
|
11942
|
+
chain.Stop = Stop;
|
|
11943
|
+
chain.finalSymbol = finalSymbol;
|
|
11944
|
+
chain.finalValue = finalValue;
|
|
11945
|
+
chain.final = final;
|
|
11946
|
+
chain.isFinalValue = isFinalValue;
|
|
11947
|
+
chain.getFinalValue = getFinalValue;
|
|
11948
|
+
chain.manySymbol = manySymbol;
|
|
11949
|
+
chain.many = many;
|
|
11950
|
+
chain.isMany = isMany;
|
|
11951
|
+
chain.getManyValues = getManyValues;
|
|
11952
|
+
chain.flushSymbol = flushSymbol;
|
|
11953
|
+
chain.flushable = flushable;
|
|
11954
|
+
chain.isFlushable = isFlushable;
|
|
11955
|
+
chain.fListSymbol = fListSymbol;
|
|
11956
|
+
chain.isFunctionList = isFunctionList;
|
|
11957
|
+
chain.getFunctionList = getFunctionList;
|
|
11958
|
+
chain.setFunctionList = setFunctionList;
|
|
11959
|
+
chain.clearFunctionList = clearFunctionList;
|
|
11960
|
+
chain.toMany = toMany;
|
|
11961
|
+
chain.normalizeMany = normalizeMany;
|
|
11962
|
+
chain.combineMany = combineMany;
|
|
11963
|
+
chain.combineManyMut = combineManyMut;
|
|
11964
|
+
chain.chain = chain;
|
|
11965
|
+
chain.chainUnchecked = chain;
|
|
11966
|
+
chain.gen = gen_default;
|
|
11967
|
+
chain.asStream = asStream_default;
|
|
11968
|
+
chain.asWebStream = asWebStream_default;
|
|
11969
|
+
chain.dataSource = dataSource_default;
|
|
11970
|
+
|
|
11971
|
+
// node_modules/stream-chain/src/fun.js
|
|
11972
|
+
var asArray = (...fns) => {
|
|
11973
|
+
fns = fns.filter((fn) => fn).flat(Infinity).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
|
|
11974
|
+
if (!fns.length) {
|
|
11975
|
+
fns = [(x) => x];
|
|
11976
|
+
}
|
|
11977
|
+
let flushed = false;
|
|
11978
|
+
let g = (value) => {
|
|
11979
|
+
if (flushed) throw Error("Call to a flushed pipe.");
|
|
11980
|
+
const results = [], push = (v2) => {
|
|
11981
|
+
results.push(v2);
|
|
11982
|
+
};
|
|
11983
|
+
let pending;
|
|
11984
|
+
if (value !== none) {
|
|
11985
|
+
pending = next(value, fns, 0, push);
|
|
11986
|
+
} else {
|
|
11987
|
+
flushed = true;
|
|
11988
|
+
pending = flush(fns, 0, push);
|
|
11989
|
+
}
|
|
11990
|
+
return pending && typeof pending.then == "function" ? pending.then(() => results) : results;
|
|
11991
|
+
};
|
|
11992
|
+
const needToFlush = fns.some((fn) => isFlushable(fn));
|
|
11993
|
+
if (needToFlush) g = flushable(g);
|
|
11994
|
+
return setFunctionList(g, fns);
|
|
11995
|
+
};
|
|
11996
|
+
var fun = (...fns) => {
|
|
11997
|
+
const f = asArray(...fns);
|
|
11998
|
+
let g = (value) => {
|
|
11999
|
+
const result = (
|
|
12000
|
+
/** @type {any} */
|
|
12001
|
+
f(value)
|
|
12002
|
+
);
|
|
12003
|
+
if (result && typeof result.then == "function") {
|
|
12004
|
+
return result.then((results) => many(results));
|
|
12005
|
+
}
|
|
12006
|
+
return many(result);
|
|
12007
|
+
};
|
|
12008
|
+
if (isFlushable(f)) g = flushable(g);
|
|
12009
|
+
return setFunctionList(g, getFunctionList(f));
|
|
12010
|
+
};
|
|
12011
|
+
var fun_default = fun;
|
|
12012
|
+
|
|
12013
|
+
// node_modules/stream-chain/src/web/index.js
|
|
12014
|
+
var groupFunctions2 = (output, item, index, items) => {
|
|
12015
|
+
if (isDuplexWebStream(item)) {
|
|
12016
|
+
output.push(item);
|
|
12017
|
+
return output;
|
|
12018
|
+
}
|
|
12019
|
+
if (!index && isReadableWebStream(item)) {
|
|
12020
|
+
output.push({ readable: item, writable: null });
|
|
12021
|
+
return output;
|
|
12022
|
+
}
|
|
12023
|
+
if (index === items.length - 1 && isWritableWebStream(item)) {
|
|
12024
|
+
output.push({ readable: null, writable: item });
|
|
12025
|
+
return output;
|
|
12026
|
+
}
|
|
12027
|
+
if (typeof item !== "function") {
|
|
12028
|
+
throw new TypeError(`Item #${index} is not a Web Streams object or function.`);
|
|
12029
|
+
}
|
|
12030
|
+
if (!output.length) output.push([]);
|
|
12031
|
+
const last = output[output.length - 1];
|
|
12032
|
+
if (Array.isArray(last)) {
|
|
12033
|
+
last.push(item);
|
|
12034
|
+
} else {
|
|
12035
|
+
output.push([item]);
|
|
11141
12036
|
}
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
12037
|
+
return output;
|
|
12038
|
+
};
|
|
12039
|
+
var makeProduceStages = (options) => (item) => {
|
|
12040
|
+
if (Array.isArray(item)) {
|
|
12041
|
+
if (!item.length) return null;
|
|
12042
|
+
if (item.length === 1) return (
|
|
12043
|
+
/** @type {any} */
|
|
12044
|
+
chain2.asWebStream(item[0], options)
|
|
12045
|
+
);
|
|
12046
|
+
return (
|
|
12047
|
+
/** @type {any} */
|
|
12048
|
+
chain2.asWebStream(
|
|
12049
|
+
/** @type {any} */
|
|
12050
|
+
chain2.gen(...item),
|
|
12051
|
+
options
|
|
12052
|
+
)
|
|
12053
|
+
);
|
|
12054
|
+
}
|
|
12055
|
+
return item;
|
|
12056
|
+
};
|
|
12057
|
+
var chain2 = (fns, options) => {
|
|
12058
|
+
if (!Array.isArray(fns) || !fns.length) {
|
|
12059
|
+
throw new TypeError("Chain's first argument should be a non-empty array.");
|
|
12060
|
+
}
|
|
12061
|
+
fns = fns.flat(Infinity).filter(Boolean).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
|
|
12062
|
+
if (!fns.length) {
|
|
12063
|
+
throw new TypeError("Chain's first argument is empty after flattening.");
|
|
12064
|
+
}
|
|
12065
|
+
const stages = fns.reduce(groupFunctions2, []).map(makeProduceStages(options)).filter((s) => s);
|
|
12066
|
+
for (let i = 0; i < stages.length - 1; ++i) {
|
|
12067
|
+
const from = stages[i].readable;
|
|
12068
|
+
const to = stages[i + 1].writable;
|
|
12069
|
+
if (!from) {
|
|
12070
|
+
throw new TypeError(`Stage #${i} has no readable side; cannot pipe to next stage.`);
|
|
12071
|
+
}
|
|
12072
|
+
if (!to) {
|
|
12073
|
+
throw new TypeError(`Stage #${i + 1} has no writable side; cannot accept input.`);
|
|
12074
|
+
}
|
|
12075
|
+
from.pipeTo(to).catch(() => {
|
|
12076
|
+
});
|
|
12077
|
+
}
|
|
12078
|
+
const c = {
|
|
12079
|
+
readable: stages[stages.length - 1].readable,
|
|
12080
|
+
writable: stages[0].writable,
|
|
12081
|
+
streams: stages,
|
|
12082
|
+
input: stages[0],
|
|
12083
|
+
output: stages[stages.length - 1]
|
|
12084
|
+
};
|
|
12085
|
+
return c;
|
|
12086
|
+
};
|
|
12087
|
+
chain2.none = none;
|
|
12088
|
+
chain2.stop = stop;
|
|
12089
|
+
chain2.Stop = Stop;
|
|
12090
|
+
chain2.finalSymbol = finalSymbol;
|
|
12091
|
+
chain2.finalValue = finalValue;
|
|
12092
|
+
chain2.final = final;
|
|
12093
|
+
chain2.isFinalValue = isFinalValue;
|
|
12094
|
+
chain2.getFinalValue = getFinalValue;
|
|
12095
|
+
chain2.manySymbol = manySymbol;
|
|
12096
|
+
chain2.many = many;
|
|
12097
|
+
chain2.isMany = isMany;
|
|
12098
|
+
chain2.getManyValues = getManyValues;
|
|
12099
|
+
chain2.flushSymbol = flushSymbol;
|
|
12100
|
+
chain2.flushable = flushable;
|
|
12101
|
+
chain2.isFlushable = isFlushable;
|
|
12102
|
+
chain2.fListSymbol = fListSymbol;
|
|
12103
|
+
chain2.isFunctionList = isFunctionList;
|
|
12104
|
+
chain2.getFunctionList = getFunctionList;
|
|
12105
|
+
chain2.setFunctionList = setFunctionList;
|
|
12106
|
+
chain2.clearFunctionList = clearFunctionList;
|
|
12107
|
+
chain2.toMany = toMany;
|
|
12108
|
+
chain2.normalizeMany = normalizeMany;
|
|
12109
|
+
chain2.combineMany = combineMany;
|
|
12110
|
+
chain2.combineManyMut = combineManyMut;
|
|
12111
|
+
chain2.chain = chain2;
|
|
12112
|
+
chain2.chainUnchecked = chain2;
|
|
12113
|
+
chain2.gen = gen_default;
|
|
12114
|
+
chain2.fun = fun_default;
|
|
12115
|
+
chain2.asWebStream = asWebStream_default;
|
|
12116
|
+
chain2.dataSource = dataSource_default;
|
|
12117
|
+
|
|
12118
|
+
// node_modules/stream-chain/src/core/index.js
|
|
12119
|
+
var chain3 = (fns, _options) => {
|
|
12120
|
+
const flat = (Array.isArray(fns) ? fns : []).flat(Infinity).filter(Boolean).map((fn) => isFunctionList(fn) ? getFunctionList(fn) : fn).flat(Infinity);
|
|
12121
|
+
const g = gen_default(...flat);
|
|
12122
|
+
const c = async function* (input) {
|
|
12123
|
+
if (input == null) return;
|
|
12124
|
+
if (typeof input === "string" || input[Symbol.asyncIterator] === void 0 && input[Symbol.iterator] === void 0) {
|
|
12125
|
+
yield* g(input);
|
|
12126
|
+
return;
|
|
12127
|
+
}
|
|
12128
|
+
for await (const value of input) yield* g(value);
|
|
12129
|
+
};
|
|
12130
|
+
c.streams = null;
|
|
12131
|
+
c.input = null;
|
|
12132
|
+
c.output = null;
|
|
12133
|
+
return c;
|
|
11146
12134
|
};
|
|
12135
|
+
chain3.none = none;
|
|
12136
|
+
chain3.stop = stop;
|
|
12137
|
+
chain3.Stop = Stop;
|
|
12138
|
+
chain3.finalSymbol = finalSymbol;
|
|
12139
|
+
chain3.finalValue = finalValue;
|
|
12140
|
+
chain3.final = final;
|
|
12141
|
+
chain3.isFinalValue = isFinalValue;
|
|
12142
|
+
chain3.getFinalValue = getFinalValue;
|
|
12143
|
+
chain3.manySymbol = manySymbol;
|
|
12144
|
+
chain3.many = many;
|
|
12145
|
+
chain3.isMany = isMany;
|
|
12146
|
+
chain3.getManyValues = getManyValues;
|
|
12147
|
+
chain3.flushSymbol = flushSymbol;
|
|
12148
|
+
chain3.flushable = flushable;
|
|
12149
|
+
chain3.isFlushable = isFlushable;
|
|
12150
|
+
chain3.fListSymbol = fListSymbol;
|
|
12151
|
+
chain3.isFunctionList = isFunctionList;
|
|
12152
|
+
chain3.getFunctionList = getFunctionList;
|
|
12153
|
+
chain3.setFunctionList = setFunctionList;
|
|
12154
|
+
chain3.clearFunctionList = clearFunctionList;
|
|
12155
|
+
chain3.toMany = toMany;
|
|
12156
|
+
chain3.normalizeMany = normalizeMany;
|
|
12157
|
+
chain3.combineMany = combineMany;
|
|
12158
|
+
chain3.combineManyMut = combineManyMut;
|
|
12159
|
+
chain3.chain = chain3;
|
|
12160
|
+
chain3.chainUnchecked = chain3;
|
|
12161
|
+
chain3.gen = gen_default;
|
|
12162
|
+
chain3.fun = fun_default;
|
|
12163
|
+
chain3.dataSource = dataSource_default;
|
|
12164
|
+
|
|
12165
|
+
// node_modules/stream-chain/src/utils/fixUtf8Stream.js
|
|
12166
|
+
var makeTextDecoderImpl = () => {
|
|
12167
|
+
const textDecoder = new TextDecoder();
|
|
12168
|
+
return flushable((chunk) => {
|
|
12169
|
+
if (chunk === none) return textDecoder.decode();
|
|
12170
|
+
if (typeof chunk == "string") return chunk;
|
|
12171
|
+
if (chunk instanceof Uint8Array) return textDecoder.decode(chunk, { stream: true });
|
|
12172
|
+
throw new TypeError("Expected a string or a Uint8Array");
|
|
12173
|
+
});
|
|
12174
|
+
};
|
|
12175
|
+
var makeStringDecoderImpl = (StringDecoder) => () => {
|
|
12176
|
+
const stringDecoder = new StringDecoder();
|
|
12177
|
+
return flushable((chunk) => {
|
|
12178
|
+
if (chunk === none) return stringDecoder.end();
|
|
12179
|
+
if (typeof chunk == "string") return chunk;
|
|
12180
|
+
if (chunk instanceof Uint8Array) return stringDecoder.write(chunk);
|
|
12181
|
+
throw new TypeError("Expected a string or a Uint8Array");
|
|
12182
|
+
});
|
|
12183
|
+
};
|
|
12184
|
+
var impl = makeTextDecoderImpl;
|
|
12185
|
+
var isDeno = typeof globalThis["Deno"] == "object" && globalThis["Deno"]?.version;
|
|
12186
|
+
var isBun = typeof globalThis["Bun"] == "object" && globalThis["Bun"]?.version;
|
|
12187
|
+
var isNode = !isDeno && !isBun && typeof process == "object" && process?.versions?.node;
|
|
12188
|
+
var readyPromise = isNode ? import("node:string_decoder").then(
|
|
12189
|
+
({ StringDecoder }) => {
|
|
12190
|
+
impl = makeStringDecoderImpl(StringDecoder);
|
|
12191
|
+
},
|
|
12192
|
+
() => {
|
|
12193
|
+
}
|
|
12194
|
+
// squelch — stick with TextDecoder
|
|
12195
|
+
) : Promise.resolve();
|
|
12196
|
+
var fixUtf8Stream = () => impl();
|
|
12197
|
+
var fixUtf8Stream_default = fixUtf8Stream;
|
|
12198
|
+
|
|
12199
|
+
// node_modules/stream-json/src/core/parser.js
|
|
12200
|
+
var patterns = {
|
|
12201
|
+
value1: /[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256}/y,
|
|
12202
|
+
string: /[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\"/y,
|
|
12203
|
+
numberStart: /\d/y,
|
|
12204
|
+
numberDigit: /\d{0,256}/y,
|
|
12205
|
+
numberFraction: /[\.eE]/y,
|
|
12206
|
+
numberExponent: /[eE]/y,
|
|
12207
|
+
numberExpSign: /[-+]/y
|
|
12208
|
+
};
|
|
12209
|
+
var MAX_PATTERN_SIZE = 16;
|
|
12210
|
+
patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
|
|
12211
|
+
patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
|
|
12212
|
+
var expected = { object: "objectStop", array: "arrayStop", "": "done" };
|
|
12213
|
+
var tokenStartObject = { name: "startObject" };
|
|
12214
|
+
var tokenEndObject = { name: "endObject" };
|
|
12215
|
+
var tokenStartArray = { name: "startArray" };
|
|
12216
|
+
var tokenEndArray = { name: "endArray" };
|
|
12217
|
+
var tokenStartString = { name: "startString" };
|
|
12218
|
+
var tokenEndString = { name: "endString" };
|
|
12219
|
+
var tokenStartNumber = { name: "startNumber" };
|
|
12220
|
+
var tokenEndNumber = { name: "endNumber" };
|
|
12221
|
+
var tokenStartKey = { name: "startKey" };
|
|
12222
|
+
var tokenEndKey = { name: "endKey" };
|
|
12223
|
+
var literalTokens = {
|
|
12224
|
+
true: { name: "trueValue", value: true },
|
|
12225
|
+
false: { name: "falseValue", value: false },
|
|
12226
|
+
null: { name: "nullValue", value: null }
|
|
12227
|
+
};
|
|
12228
|
+
var fromHex = (s) => String.fromCharCode(parseInt(s.slice(2), 16));
|
|
12229
|
+
var codes = { b: "\b", f: "\f", n: "\n", r: "\r", t: " ", '"': '"', "\\": "\\", "/": "/" };
|
|
12230
|
+
var ASCII_TAB = " ".charCodeAt(0);
|
|
12231
|
+
var ASCII_LF = "\n".charCodeAt(0);
|
|
12232
|
+
var ASCII_CR = "\r".charCodeAt(0);
|
|
12233
|
+
var ASCII_SPACE = " ".charCodeAt(0);
|
|
12234
|
+
var ASCII_QUOTE = '"'.charCodeAt(0);
|
|
12235
|
+
var ASCII_BACKSLASH = "\\".charCodeAt(0);
|
|
12236
|
+
var ASCII_OPEN_BRACE = "{".charCodeAt(0);
|
|
12237
|
+
var ASCII_CLOSE_BRACE = "}".charCodeAt(0);
|
|
12238
|
+
var ASCII_OPEN_BRACKET = "[".charCodeAt(0);
|
|
12239
|
+
var ASCII_CLOSE_BRACKET = "]".charCodeAt(0);
|
|
12240
|
+
var ASCII_MINUS = "-".charCodeAt(0);
|
|
12241
|
+
var ASCII_COLON = ":".charCodeAt(0);
|
|
12242
|
+
var ASCII_COMMA = ",".charCodeAt(0);
|
|
12243
|
+
var ASCII_ZERO = "0".charCodeAt(0);
|
|
12244
|
+
var ASCII_NINE = "9".charCodeAt(0);
|
|
12245
|
+
var ASCII_UPPER_A = "A".charCodeAt(0);
|
|
12246
|
+
var ASCII_UPPER_F = "F".charCodeAt(0);
|
|
12247
|
+
var ASCII_LOWER_A = "a".charCodeAt(0);
|
|
12248
|
+
var ASCII_LOWER_F = "f".charCodeAt(0);
|
|
12249
|
+
var ASCII_LOWER_N = "n".charCodeAt(0);
|
|
12250
|
+
var ASCII_LOWER_T = "t".charCodeAt(0);
|
|
12251
|
+
var ASCII_LOWER_U = "u".charCodeAt(0);
|
|
12252
|
+
var TERM = [];
|
|
12253
|
+
for (const ch of ",}] \n\r") TERM[ch.charCodeAt(0)] = 1;
|
|
12254
|
+
var numberFull = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/y;
|
|
12255
|
+
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;
|
|
12256
|
+
var jsonParser = (options) => {
|
|
12257
|
+
let packKeys = true, packStrings = true, packNumbers = true, streamKeys = true, streamStrings = true, streamNumbers = true, jsonStreaming = false;
|
|
12258
|
+
if (options) {
|
|
12259
|
+
"packValues" in options && (packKeys = packStrings = packNumbers = options.packValues);
|
|
12260
|
+
"packKeys" in options && (packKeys = options.packKeys);
|
|
12261
|
+
"packStrings" in options && (packStrings = options.packStrings);
|
|
12262
|
+
"packNumbers" in options && (packNumbers = options.packNumbers);
|
|
12263
|
+
"streamValues" in options && (streamKeys = streamStrings = streamNumbers = options.streamValues);
|
|
12264
|
+
"streamKeys" in options && (streamKeys = options.streamKeys);
|
|
12265
|
+
"streamStrings" in options && (streamStrings = options.streamStrings);
|
|
12266
|
+
"streamNumbers" in options && (streamNumbers = options.streamNumbers);
|
|
12267
|
+
jsonStreaming = options.jsonStreaming;
|
|
12268
|
+
}
|
|
12269
|
+
!packKeys && (streamKeys = true);
|
|
12270
|
+
!packStrings && (streamStrings = true);
|
|
12271
|
+
!packNumbers && (streamNumbers = true);
|
|
12272
|
+
let done = false, expect = jsonStreaming ? "done" : "value", parent = "", openNumber = false, accumulator = "", buffer = "";
|
|
12273
|
+
const stack = [];
|
|
12274
|
+
return flushable((buf) => {
|
|
12275
|
+
const tokens = [];
|
|
12276
|
+
if (buf === none) {
|
|
12277
|
+
done = true;
|
|
12278
|
+
} else {
|
|
12279
|
+
buffer += buf;
|
|
12280
|
+
}
|
|
12281
|
+
let match, fm, s, e, q, rs, cc2, value, index = 0;
|
|
12282
|
+
main: for (; ; ) {
|
|
12283
|
+
switch (expect) {
|
|
12284
|
+
case "value1":
|
|
12285
|
+
case "value": {
|
|
12286
|
+
while (index < buffer.length) {
|
|
12287
|
+
cc2 = buffer.charCodeAt(index);
|
|
12288
|
+
if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
|
|
12289
|
+
++index;
|
|
12290
|
+
continue;
|
|
12291
|
+
}
|
|
12292
|
+
break;
|
|
12293
|
+
}
|
|
12294
|
+
if (index >= buffer.length) {
|
|
12295
|
+
if (done) throw new Error("Parser has expected a value");
|
|
12296
|
+
break main;
|
|
12297
|
+
}
|
|
12298
|
+
cc2 = buffer.charCodeAt(index);
|
|
12299
|
+
if (cc2 === ASCII_QUOTE) {
|
|
12300
|
+
q = index + 1;
|
|
12301
|
+
rs = q;
|
|
12302
|
+
s = "";
|
|
12303
|
+
for (; ; ) {
|
|
12304
|
+
if (q >= buffer.length) {
|
|
12305
|
+
q = -1;
|
|
12306
|
+
break;
|
|
12307
|
+
}
|
|
12308
|
+
e = buffer.charCodeAt(q);
|
|
12309
|
+
if (e === ASCII_QUOTE) {
|
|
12310
|
+
s += buffer.slice(rs, q);
|
|
12311
|
+
break;
|
|
12312
|
+
}
|
|
12313
|
+
if (e < ASCII_SPACE) {
|
|
12314
|
+
q = -1;
|
|
12315
|
+
break;
|
|
12316
|
+
}
|
|
12317
|
+
if (e === ASCII_BACKSLASH) {
|
|
12318
|
+
if (q + 1 >= buffer.length) {
|
|
12319
|
+
q = -1;
|
|
12320
|
+
break;
|
|
12321
|
+
}
|
|
12322
|
+
cc2 = buffer.charCodeAt(q + 1);
|
|
12323
|
+
if (cc2 === ASCII_LOWER_U) {
|
|
12324
|
+
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)))) {
|
|
12325
|
+
q = -1;
|
|
12326
|
+
break;
|
|
12327
|
+
}
|
|
12328
|
+
s += buffer.slice(rs, q) + String.fromCharCode(parseInt(buffer.slice(q + 2, q + 6), 16));
|
|
12329
|
+
q += 6;
|
|
12330
|
+
} else {
|
|
12331
|
+
value = codes[buffer.charAt(q + 1)];
|
|
12332
|
+
if (value === void 0) {
|
|
12333
|
+
q = -1;
|
|
12334
|
+
break;
|
|
12335
|
+
}
|
|
12336
|
+
s += buffer.slice(rs, q) + value;
|
|
12337
|
+
q += 2;
|
|
12338
|
+
}
|
|
12339
|
+
rs = q;
|
|
12340
|
+
continue;
|
|
12341
|
+
}
|
|
12342
|
+
++q;
|
|
12343
|
+
}
|
|
12344
|
+
if (q >= 0) {
|
|
12345
|
+
if (streamStrings) {
|
|
12346
|
+
tokens.push(tokenStartString);
|
|
12347
|
+
if (s) tokens.push({ name: "stringChunk", value: s });
|
|
12348
|
+
tokens.push(tokenEndString);
|
|
12349
|
+
}
|
|
12350
|
+
if (packStrings) tokens.push({ name: "stringValue", value: s });
|
|
12351
|
+
index = q + 1;
|
|
12352
|
+
expect = expected[parent];
|
|
12353
|
+
continue main;
|
|
12354
|
+
}
|
|
12355
|
+
if (streamStrings) tokens.push(tokenStartString);
|
|
12356
|
+
expect = "string";
|
|
12357
|
+
++index;
|
|
12358
|
+
continue main;
|
|
12359
|
+
}
|
|
12360
|
+
if (cc2 === ASCII_OPEN_BRACE) {
|
|
12361
|
+
tokens.push(tokenStartObject);
|
|
12362
|
+
stack.push(parent);
|
|
12363
|
+
parent = "object";
|
|
12364
|
+
expect = "key1";
|
|
12365
|
+
++index;
|
|
12366
|
+
continue main;
|
|
12367
|
+
}
|
|
12368
|
+
if (cc2 === ASCII_OPEN_BRACKET) {
|
|
12369
|
+
tokens.push(tokenStartArray);
|
|
12370
|
+
stack.push(parent);
|
|
12371
|
+
parent = "array";
|
|
12372
|
+
expect = "value1";
|
|
12373
|
+
++index;
|
|
12374
|
+
continue main;
|
|
12375
|
+
}
|
|
12376
|
+
if (cc2 === ASCII_CLOSE_BRACKET) {
|
|
12377
|
+
if (expect !== "value1") throw new Error("Parser cannot parse input: unexpected token ']'");
|
|
12378
|
+
tokens.push(tokenEndArray);
|
|
12379
|
+
parent = stack.pop();
|
|
12380
|
+
expect = expected[parent];
|
|
12381
|
+
++index;
|
|
12382
|
+
continue main;
|
|
12383
|
+
}
|
|
12384
|
+
if (cc2 === ASCII_MINUS || cc2 >= ASCII_ZERO && cc2 <= ASCII_NINE) {
|
|
12385
|
+
numberFull.lastIndex = index;
|
|
12386
|
+
fm = numberFull.exec(buffer);
|
|
12387
|
+
if (fm) {
|
|
12388
|
+
e = index + fm[0].length;
|
|
12389
|
+
if (e < buffer.length && TERM[buffer.charCodeAt(e)]) {
|
|
12390
|
+
s = fm[0];
|
|
12391
|
+
if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: s }, tokenEndNumber);
|
|
12392
|
+
if (packNumbers) tokens.push({ name: "numberValue", value: s });
|
|
12393
|
+
index = e;
|
|
12394
|
+
expect = expected[parent];
|
|
12395
|
+
continue main;
|
|
12396
|
+
}
|
|
12397
|
+
}
|
|
12398
|
+
openNumber = true;
|
|
12399
|
+
if (cc2 === ASCII_MINUS) {
|
|
12400
|
+
if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: "-" });
|
|
12401
|
+
packNumbers && (accumulator = "-");
|
|
12402
|
+
expect = "numberStart";
|
|
12403
|
+
} else if (cc2 === ASCII_ZERO) {
|
|
12404
|
+
if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: "0" });
|
|
12405
|
+
packNumbers && (accumulator = "0");
|
|
12406
|
+
expect = "numberFraction";
|
|
12407
|
+
} else {
|
|
12408
|
+
s = buffer.charAt(index);
|
|
12409
|
+
if (streamNumbers) tokens.push(tokenStartNumber, { name: "numberChunk", value: s });
|
|
12410
|
+
packNumbers && (accumulator = s);
|
|
12411
|
+
expect = "numberDigit";
|
|
12412
|
+
}
|
|
12413
|
+
++index;
|
|
12414
|
+
continue main;
|
|
12415
|
+
}
|
|
12416
|
+
if (cc2 === ASCII_LOWER_T || cc2 === ASCII_LOWER_F || cc2 === ASCII_LOWER_N) {
|
|
12417
|
+
patterns.value1.lastIndex = index;
|
|
12418
|
+
match = patterns.value1.exec(buffer);
|
|
12419
|
+
if (!match) {
|
|
12420
|
+
if (done || index + MAX_PATTERN_SIZE < buffer.length) {
|
|
12421
|
+
throw new Error("Parser cannot parse input: expected a value");
|
|
12422
|
+
}
|
|
12423
|
+
break main;
|
|
12424
|
+
}
|
|
12425
|
+
value = match[0];
|
|
12426
|
+
if (buffer.length - index === value.length && !done) break main;
|
|
12427
|
+
tokens.push(literalTokens[value]);
|
|
12428
|
+
expect = expected[parent];
|
|
12429
|
+
index += value.length;
|
|
12430
|
+
continue main;
|
|
12431
|
+
}
|
|
12432
|
+
throw new Error("Parser cannot parse input: expected a value");
|
|
12433
|
+
}
|
|
12434
|
+
// incremental string body (escapes / long / cross-chunk)
|
|
12435
|
+
case "keyVal":
|
|
12436
|
+
case "string":
|
|
12437
|
+
patterns.string.lastIndex = index;
|
|
12438
|
+
match = patterns.string.exec(buffer);
|
|
12439
|
+
if (!match) {
|
|
12440
|
+
if (index < buffer.length && (done || buffer.length - index >= 6)) throw new Error("Parser cannot parse input: escaped characters");
|
|
12441
|
+
if (done) throw new Error("Parser has expected a string value");
|
|
12442
|
+
break main;
|
|
12443
|
+
}
|
|
12444
|
+
value = match[0];
|
|
12445
|
+
if (value === '"') {
|
|
12446
|
+
if (expect === "keyVal") {
|
|
12447
|
+
if (streamKeys) tokens.push(tokenEndKey);
|
|
12448
|
+
if (packKeys) {
|
|
12449
|
+
tokens.push({ name: "keyValue", value: accumulator });
|
|
12450
|
+
accumulator = "";
|
|
12451
|
+
}
|
|
12452
|
+
expect = "colon";
|
|
12453
|
+
} else {
|
|
12454
|
+
if (streamStrings) tokens.push(tokenEndString);
|
|
12455
|
+
if (packStrings) {
|
|
12456
|
+
tokens.push({ name: "stringValue", value: accumulator });
|
|
12457
|
+
accumulator = "";
|
|
12458
|
+
}
|
|
12459
|
+
expect = expected[parent];
|
|
12460
|
+
}
|
|
12461
|
+
} else if (value.length > 1 && value.charAt(0) === "\\") {
|
|
12462
|
+
const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value);
|
|
12463
|
+
if (expect === "keyVal" ? streamKeys : streamStrings) {
|
|
12464
|
+
tokens.push({ name: "stringChunk", value: t });
|
|
12465
|
+
}
|
|
12466
|
+
if (expect === "keyVal" ? packKeys : packStrings) {
|
|
12467
|
+
accumulator += t;
|
|
12468
|
+
}
|
|
12469
|
+
} else {
|
|
12470
|
+
if (expect === "keyVal" ? streamKeys : streamStrings) {
|
|
12471
|
+
tokens.push({ name: "stringChunk", value });
|
|
12472
|
+
}
|
|
12473
|
+
if (expect === "keyVal" ? packKeys : packStrings) {
|
|
12474
|
+
accumulator += value;
|
|
12475
|
+
}
|
|
12476
|
+
}
|
|
12477
|
+
index += value.length;
|
|
12478
|
+
break;
|
|
12479
|
+
case "key1":
|
|
12480
|
+
case "key": {
|
|
12481
|
+
while (index < buffer.length) {
|
|
12482
|
+
cc2 = buffer.charCodeAt(index);
|
|
12483
|
+
if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
|
|
12484
|
+
++index;
|
|
12485
|
+
continue;
|
|
12486
|
+
}
|
|
12487
|
+
break;
|
|
12488
|
+
}
|
|
12489
|
+
if (index >= buffer.length) {
|
|
12490
|
+
if (done) throw new Error("Parser cannot parse input: expected an object key");
|
|
12491
|
+
break main;
|
|
12492
|
+
}
|
|
12493
|
+
cc2 = buffer.charCodeAt(index);
|
|
12494
|
+
if (cc2 === ASCII_QUOTE) {
|
|
12495
|
+
q = index + 1;
|
|
12496
|
+
rs = q;
|
|
12497
|
+
s = "";
|
|
12498
|
+
for (; ; ) {
|
|
12499
|
+
if (q >= buffer.length) {
|
|
12500
|
+
q = -1;
|
|
12501
|
+
break;
|
|
12502
|
+
}
|
|
12503
|
+
e = buffer.charCodeAt(q);
|
|
12504
|
+
if (e === ASCII_QUOTE) {
|
|
12505
|
+
s += buffer.slice(rs, q);
|
|
12506
|
+
break;
|
|
12507
|
+
}
|
|
12508
|
+
if (e < ASCII_SPACE) {
|
|
12509
|
+
q = -1;
|
|
12510
|
+
break;
|
|
12511
|
+
}
|
|
12512
|
+
if (e === ASCII_BACKSLASH) {
|
|
12513
|
+
if (q + 1 >= buffer.length) {
|
|
12514
|
+
q = -1;
|
|
12515
|
+
break;
|
|
12516
|
+
}
|
|
12517
|
+
cc2 = buffer.charCodeAt(q + 1);
|
|
12518
|
+
if (cc2 === ASCII_LOWER_U) {
|
|
12519
|
+
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)))) {
|
|
12520
|
+
q = -1;
|
|
12521
|
+
break;
|
|
12522
|
+
}
|
|
12523
|
+
s += buffer.slice(rs, q) + String.fromCharCode(parseInt(buffer.slice(q + 2, q + 6), 16));
|
|
12524
|
+
q += 6;
|
|
12525
|
+
} else {
|
|
12526
|
+
value = codes[buffer.charAt(q + 1)];
|
|
12527
|
+
if (value === void 0) {
|
|
12528
|
+
q = -1;
|
|
12529
|
+
break;
|
|
12530
|
+
}
|
|
12531
|
+
s += buffer.slice(rs, q) + value;
|
|
12532
|
+
q += 2;
|
|
12533
|
+
}
|
|
12534
|
+
rs = q;
|
|
12535
|
+
continue;
|
|
12536
|
+
}
|
|
12537
|
+
++q;
|
|
12538
|
+
}
|
|
12539
|
+
if (q >= 0) {
|
|
12540
|
+
if (streamKeys) {
|
|
12541
|
+
tokens.push(tokenStartKey);
|
|
12542
|
+
if (s) tokens.push({ name: "stringChunk", value: s });
|
|
12543
|
+
tokens.push(tokenEndKey);
|
|
12544
|
+
}
|
|
12545
|
+
if (packKeys) tokens.push({ name: "keyValue", value: s });
|
|
12546
|
+
index = q + 1;
|
|
12547
|
+
expect = "colon";
|
|
12548
|
+
continue main;
|
|
12549
|
+
}
|
|
12550
|
+
if (streamKeys) tokens.push(tokenStartKey);
|
|
12551
|
+
expect = "keyVal";
|
|
12552
|
+
++index;
|
|
12553
|
+
continue main;
|
|
12554
|
+
}
|
|
12555
|
+
if (cc2 === ASCII_CLOSE_BRACE) {
|
|
12556
|
+
if (expect !== "key1") throw new Error("Parser cannot parse input: unexpected token '}'");
|
|
12557
|
+
tokens.push(tokenEndObject);
|
|
12558
|
+
parent = stack.pop();
|
|
12559
|
+
expect = expected[parent];
|
|
12560
|
+
++index;
|
|
12561
|
+
continue main;
|
|
12562
|
+
}
|
|
12563
|
+
throw new Error("Parser cannot parse input: expected an object key");
|
|
12564
|
+
}
|
|
12565
|
+
case "colon": {
|
|
12566
|
+
while (index < buffer.length) {
|
|
12567
|
+
cc2 = buffer.charCodeAt(index);
|
|
12568
|
+
if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
|
|
12569
|
+
++index;
|
|
12570
|
+
continue;
|
|
12571
|
+
}
|
|
12572
|
+
break;
|
|
12573
|
+
}
|
|
12574
|
+
if (index >= buffer.length) {
|
|
12575
|
+
if (done) throw new Error("Parser cannot parse input: expected ':'");
|
|
12576
|
+
break main;
|
|
12577
|
+
}
|
|
12578
|
+
cc2 = buffer.charCodeAt(index);
|
|
12579
|
+
if (cc2 === ASCII_COLON) {
|
|
12580
|
+
expect = "value";
|
|
12581
|
+
++index;
|
|
12582
|
+
continue main;
|
|
12583
|
+
}
|
|
12584
|
+
throw new Error("Parser cannot parse input: expected ':'");
|
|
12585
|
+
}
|
|
12586
|
+
case "arrayStop":
|
|
12587
|
+
case "objectStop": {
|
|
12588
|
+
while (index < buffer.length) {
|
|
12589
|
+
cc2 = buffer.charCodeAt(index);
|
|
12590
|
+
if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
|
|
12591
|
+
++index;
|
|
12592
|
+
continue;
|
|
12593
|
+
}
|
|
12594
|
+
break;
|
|
12595
|
+
}
|
|
12596
|
+
if (index >= buffer.length) {
|
|
12597
|
+
if (done) throw new Error("Parser cannot parse input: expected ','");
|
|
12598
|
+
break main;
|
|
12599
|
+
}
|
|
12600
|
+
if (openNumber) {
|
|
12601
|
+
if (streamNumbers) tokens.push(tokenEndNumber);
|
|
12602
|
+
openNumber = false;
|
|
12603
|
+
if (packNumbers) {
|
|
12604
|
+
tokens.push({ name: "numberValue", value: accumulator });
|
|
12605
|
+
accumulator = "";
|
|
12606
|
+
}
|
|
12607
|
+
}
|
|
12608
|
+
cc2 = buffer.charCodeAt(index);
|
|
12609
|
+
if (cc2 === ASCII_COMMA) {
|
|
12610
|
+
expect = expect === "arrayStop" ? "value" : "key";
|
|
12611
|
+
++index;
|
|
12612
|
+
continue main;
|
|
12613
|
+
}
|
|
12614
|
+
if (cc2 === ASCII_CLOSE_BRACE || cc2 === ASCII_CLOSE_BRACKET) {
|
|
12615
|
+
if (cc2 === ASCII_CLOSE_BRACE ? expect === "arrayStop" : expect !== "arrayStop") {
|
|
12616
|
+
throw new Error("Parser cannot parse input: expected '" + (expect === "arrayStop" ? "]" : "}") + "'");
|
|
12617
|
+
}
|
|
12618
|
+
tokens.push(cc2 === ASCII_CLOSE_BRACE ? tokenEndObject : tokenEndArray);
|
|
12619
|
+
parent = stack.pop();
|
|
12620
|
+
expect = expected[parent];
|
|
12621
|
+
++index;
|
|
12622
|
+
continue main;
|
|
12623
|
+
}
|
|
12624
|
+
throw new Error("Parser cannot parse input: expected ','");
|
|
12625
|
+
}
|
|
12626
|
+
// number chunks — cross-chunk / fallback
|
|
12627
|
+
case "numberStart":
|
|
12628
|
+
patterns.numberStart.lastIndex = index;
|
|
12629
|
+
match = patterns.numberStart.exec(buffer);
|
|
12630
|
+
if (!match) {
|
|
12631
|
+
if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a starting digit");
|
|
12632
|
+
break main;
|
|
12633
|
+
}
|
|
12634
|
+
value = match[0];
|
|
12635
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12636
|
+
packNumbers && (accumulator += value);
|
|
12637
|
+
expect = value === "0" ? "numberFraction" : "numberDigit";
|
|
12638
|
+
index += value.length;
|
|
12639
|
+
break;
|
|
12640
|
+
case "numberDigit":
|
|
12641
|
+
patterns.numberDigit.lastIndex = index;
|
|
12642
|
+
match = patterns.numberDigit.exec(buffer);
|
|
12643
|
+
if (!match) {
|
|
12644
|
+
if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a digit");
|
|
12645
|
+
break main;
|
|
12646
|
+
}
|
|
12647
|
+
value = match[0];
|
|
12648
|
+
if (value) {
|
|
12649
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12650
|
+
packNumbers && (accumulator += value);
|
|
12651
|
+
index += value.length;
|
|
12652
|
+
} else {
|
|
12653
|
+
if (index < buffer.length) {
|
|
12654
|
+
expect = "numberFraction";
|
|
12655
|
+
break;
|
|
12656
|
+
}
|
|
12657
|
+
if (done) {
|
|
12658
|
+
expect = expected[parent];
|
|
12659
|
+
break;
|
|
12660
|
+
}
|
|
12661
|
+
break main;
|
|
12662
|
+
}
|
|
12663
|
+
break;
|
|
12664
|
+
case "numberFraction":
|
|
12665
|
+
patterns.numberFraction.lastIndex = index;
|
|
12666
|
+
match = patterns.numberFraction.exec(buffer);
|
|
12667
|
+
if (!match) {
|
|
12668
|
+
if (index < buffer.length || done) {
|
|
12669
|
+
expect = expected[parent];
|
|
12670
|
+
break;
|
|
12671
|
+
}
|
|
12672
|
+
break main;
|
|
12673
|
+
}
|
|
12674
|
+
value = match[0];
|
|
12675
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12676
|
+
packNumbers && (accumulator += value);
|
|
12677
|
+
expect = value === "." ? "numberFracStart" : "numberExpSign";
|
|
12678
|
+
index += value.length;
|
|
12679
|
+
break;
|
|
12680
|
+
case "numberFracStart":
|
|
12681
|
+
patterns.numberFracStart.lastIndex = index;
|
|
12682
|
+
match = patterns.numberFracStart.exec(buffer);
|
|
12683
|
+
if (!match) {
|
|
12684
|
+
if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected a fractional part of a number");
|
|
12685
|
+
break main;
|
|
12686
|
+
}
|
|
12687
|
+
value = match[0];
|
|
12688
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12689
|
+
packNumbers && (accumulator += value);
|
|
12690
|
+
expect = "numberFracDigit";
|
|
12691
|
+
index += value.length;
|
|
12692
|
+
break;
|
|
12693
|
+
case "numberFracDigit":
|
|
12694
|
+
patterns.numberFracDigit.lastIndex = index;
|
|
12695
|
+
match = patterns.numberFracDigit.exec(buffer);
|
|
12696
|
+
value = match[0];
|
|
12697
|
+
if (value) {
|
|
12698
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12699
|
+
packNumbers && (accumulator += value);
|
|
12700
|
+
index += value.length;
|
|
12701
|
+
} else {
|
|
12702
|
+
if (index < buffer.length) {
|
|
12703
|
+
expect = "numberExponent";
|
|
12704
|
+
break;
|
|
12705
|
+
}
|
|
12706
|
+
if (done) {
|
|
12707
|
+
expect = expected[parent];
|
|
12708
|
+
break;
|
|
12709
|
+
}
|
|
12710
|
+
break main;
|
|
12711
|
+
}
|
|
12712
|
+
break;
|
|
12713
|
+
case "numberExponent":
|
|
12714
|
+
patterns.numberExponent.lastIndex = index;
|
|
12715
|
+
match = patterns.numberExponent.exec(buffer);
|
|
12716
|
+
if (!match) {
|
|
12717
|
+
if (index < buffer.length) {
|
|
12718
|
+
expect = expected[parent];
|
|
12719
|
+
break;
|
|
12720
|
+
}
|
|
12721
|
+
if (done) {
|
|
12722
|
+
expect = expected[parent];
|
|
12723
|
+
break;
|
|
12724
|
+
}
|
|
12725
|
+
break main;
|
|
12726
|
+
}
|
|
12727
|
+
value = match[0];
|
|
12728
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12729
|
+
packNumbers && (accumulator += value);
|
|
12730
|
+
expect = "numberExpSign";
|
|
12731
|
+
index += value.length;
|
|
12732
|
+
break;
|
|
12733
|
+
case "numberExpSign":
|
|
12734
|
+
patterns.numberExpSign.lastIndex = index;
|
|
12735
|
+
match = patterns.numberExpSign.exec(buffer);
|
|
12736
|
+
if (!match) {
|
|
12737
|
+
if (index < buffer.length) {
|
|
12738
|
+
expect = "numberExpStart";
|
|
12739
|
+
break;
|
|
12740
|
+
}
|
|
12741
|
+
if (done) throw new Error("Parser has expected an exponent value of a number");
|
|
12742
|
+
break main;
|
|
12743
|
+
}
|
|
12744
|
+
value = match[0];
|
|
12745
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12746
|
+
packNumbers && (accumulator += value);
|
|
12747
|
+
expect = "numberExpStart";
|
|
12748
|
+
index += value.length;
|
|
12749
|
+
break;
|
|
12750
|
+
case "numberExpStart":
|
|
12751
|
+
patterns.numberExpStart.lastIndex = index;
|
|
12752
|
+
match = patterns.numberExpStart.exec(buffer);
|
|
12753
|
+
if (!match) {
|
|
12754
|
+
if (index < buffer.length || done) throw new Error("Parser cannot parse input: expected an exponent part of a number");
|
|
12755
|
+
break main;
|
|
12756
|
+
}
|
|
12757
|
+
value = match[0];
|
|
12758
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12759
|
+
packNumbers && (accumulator += value);
|
|
12760
|
+
expect = "numberExpDigit";
|
|
12761
|
+
index += value.length;
|
|
12762
|
+
break;
|
|
12763
|
+
case "numberExpDigit":
|
|
12764
|
+
patterns.numberExpDigit.lastIndex = index;
|
|
12765
|
+
match = patterns.numberExpDigit.exec(buffer);
|
|
12766
|
+
value = match[0];
|
|
12767
|
+
if (value) {
|
|
12768
|
+
if (streamNumbers) tokens.push({ name: "numberChunk", value });
|
|
12769
|
+
packNumbers && (accumulator += value);
|
|
12770
|
+
index += value.length;
|
|
12771
|
+
} else {
|
|
12772
|
+
if (index < buffer.length || done) {
|
|
12773
|
+
expect = expected[parent];
|
|
12774
|
+
break;
|
|
12775
|
+
}
|
|
12776
|
+
break main;
|
|
12777
|
+
}
|
|
12778
|
+
break;
|
|
12779
|
+
case "done": {
|
|
12780
|
+
while (index < buffer.length) {
|
|
12781
|
+
cc2 = buffer.charCodeAt(index);
|
|
12782
|
+
if (cc2 === ASCII_SPACE || cc2 === ASCII_TAB || cc2 === ASCII_LF || cc2 === ASCII_CR) {
|
|
12783
|
+
if (openNumber) {
|
|
12784
|
+
if (streamNumbers) tokens.push(tokenEndNumber);
|
|
12785
|
+
openNumber = false;
|
|
12786
|
+
if (packNumbers) {
|
|
12787
|
+
tokens.push({ name: "numberValue", value: accumulator });
|
|
12788
|
+
accumulator = "";
|
|
12789
|
+
}
|
|
12790
|
+
}
|
|
12791
|
+
++index;
|
|
12792
|
+
continue;
|
|
12793
|
+
}
|
|
12794
|
+
break;
|
|
12795
|
+
}
|
|
12796
|
+
if (index >= buffer.length) break main;
|
|
12797
|
+
if (jsonStreaming) {
|
|
12798
|
+
if (openNumber) {
|
|
12799
|
+
if (streamNumbers) tokens.push(tokenEndNumber);
|
|
12800
|
+
openNumber = false;
|
|
12801
|
+
if (packNumbers) {
|
|
12802
|
+
tokens.push({ name: "numberValue", value: accumulator });
|
|
12803
|
+
accumulator = "";
|
|
12804
|
+
}
|
|
12805
|
+
}
|
|
12806
|
+
expect = "value";
|
|
12807
|
+
continue main;
|
|
12808
|
+
}
|
|
12809
|
+
throw new Error("Parser cannot parse input: unexpected characters");
|
|
12810
|
+
}
|
|
12811
|
+
}
|
|
12812
|
+
}
|
|
12813
|
+
if (done && openNumber) {
|
|
12814
|
+
if (streamNumbers) tokens.push(tokenEndNumber);
|
|
12815
|
+
openNumber = false;
|
|
12816
|
+
if (packNumbers) {
|
|
12817
|
+
tokens.push({ name: "numberValue", value: accumulator });
|
|
12818
|
+
accumulator = "";
|
|
12819
|
+
}
|
|
12820
|
+
}
|
|
12821
|
+
buffer = buffer.slice(index);
|
|
12822
|
+
return tokens.length ? many(tokens) : none;
|
|
12823
|
+
});
|
|
12824
|
+
};
|
|
12825
|
+
var parser = (options) => gen_default(fixUtf8Stream_default(), jsonParser(options));
|
|
12826
|
+
parser.parser = parser;
|
|
12827
|
+
var parser_default = parser;
|
|
12828
|
+
|
|
12829
|
+
// node_modules/stream-json/src/parser.js
|
|
12830
|
+
parser_default.asStream = (options) => asStream_default(parser_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
|
|
12831
|
+
parser_default.asWebStream = (options) => asWebStream_default(parser_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
|
|
12832
|
+
var parser_default2 = parser_default;
|
|
12833
|
+
|
|
12834
|
+
// node_modules/stream-json/src/index.js
|
|
12835
|
+
var parserStream = parser_default2.asStream;
|
|
12836
|
+
|
|
12837
|
+
// node_modules/stream-json/src/core/assembler.js
|
|
12838
|
+
var startObject = (Ctr) => (
|
|
12839
|
+
/** @this {Assembler} */
|
|
12840
|
+
function() {
|
|
12841
|
+
if (this.done) {
|
|
12842
|
+
this.done = false;
|
|
12843
|
+
} else {
|
|
12844
|
+
this.stack.push(this.current, this.key);
|
|
12845
|
+
}
|
|
12846
|
+
this.current = new Ctr();
|
|
12847
|
+
this.key = null;
|
|
12848
|
+
}
|
|
12849
|
+
);
|
|
12850
|
+
var Assembler = class _Assembler {
|
|
12851
|
+
static connectTo(stream, options) {
|
|
12852
|
+
return new _Assembler(options).connectTo(stream);
|
|
12853
|
+
}
|
|
12854
|
+
constructor(options) {
|
|
12855
|
+
this.stack = [];
|
|
12856
|
+
this.current = this.key = null;
|
|
12857
|
+
this.done = true;
|
|
12858
|
+
this._onDone = null;
|
|
12859
|
+
if (options) {
|
|
12860
|
+
this.reviver = typeof options.reviver == "function" && options.reviver;
|
|
12861
|
+
if (this.reviver) {
|
|
12862
|
+
this.stringValue = this._saveValue = this._saveValueWithReviver;
|
|
12863
|
+
}
|
|
12864
|
+
if (options.numberAsString) {
|
|
12865
|
+
this.numberValue = this.stringValue;
|
|
12866
|
+
}
|
|
12867
|
+
if (typeof options.onDone == "function") {
|
|
12868
|
+
this._onDone = options.onDone;
|
|
12869
|
+
}
|
|
12870
|
+
}
|
|
12871
|
+
this.tapChain = (chunk) => {
|
|
12872
|
+
if (this[chunk.name]) {
|
|
12873
|
+
this[chunk.name](chunk.value);
|
|
12874
|
+
if (this.done) return this.current;
|
|
12875
|
+
}
|
|
12876
|
+
return none;
|
|
12877
|
+
};
|
|
12878
|
+
}
|
|
12879
|
+
connectTo(stream) {
|
|
12880
|
+
const consume = (chunk) => {
|
|
12881
|
+
if (this[chunk.name]) {
|
|
12882
|
+
this[chunk.name](chunk.value);
|
|
12883
|
+
if (this.done) this._onDone?.(this);
|
|
12884
|
+
}
|
|
12885
|
+
};
|
|
12886
|
+
if (typeof stream?.getReader === "function") {
|
|
12887
|
+
const reader = stream.getReader();
|
|
12888
|
+
(async () => {
|
|
12889
|
+
try {
|
|
12890
|
+
for (; ; ) {
|
|
12891
|
+
const { done, value } = await reader.read();
|
|
12892
|
+
if (done) return;
|
|
12893
|
+
consume(value);
|
|
12894
|
+
}
|
|
12895
|
+
} finally {
|
|
12896
|
+
reader.releaseLock();
|
|
12897
|
+
}
|
|
12898
|
+
})();
|
|
12899
|
+
} else {
|
|
12900
|
+
stream.on("data", consume);
|
|
12901
|
+
}
|
|
12902
|
+
return this;
|
|
12903
|
+
}
|
|
12904
|
+
onDone(fn) {
|
|
12905
|
+
this._onDone = typeof fn == "function" ? fn : null;
|
|
12906
|
+
return this;
|
|
12907
|
+
}
|
|
12908
|
+
get depth() {
|
|
12909
|
+
return (this.stack.length >> 1) + (this.done ? 0 : 1);
|
|
12910
|
+
}
|
|
12911
|
+
get path() {
|
|
12912
|
+
const path3 = [];
|
|
12913
|
+
for (let i = 0; i < this.stack.length; i += 2) {
|
|
12914
|
+
const key = this.stack[i + 1];
|
|
12915
|
+
path3.push(key === null ? this.stack[i].length : key);
|
|
12916
|
+
}
|
|
12917
|
+
return path3;
|
|
12918
|
+
}
|
|
12919
|
+
dropToLevel(level) {
|
|
12920
|
+
if (level < this.depth) {
|
|
12921
|
+
if (level > 0) {
|
|
12922
|
+
const index = level - 1 << 1;
|
|
12923
|
+
this.current = this.stack[index];
|
|
12924
|
+
this.key = this.stack[index + 1];
|
|
12925
|
+
this.stack.splice(index);
|
|
12926
|
+
} else {
|
|
12927
|
+
this.stack = [];
|
|
12928
|
+
this.current = this.key = null;
|
|
12929
|
+
this.done = true;
|
|
12930
|
+
}
|
|
12931
|
+
}
|
|
12932
|
+
return this;
|
|
12933
|
+
}
|
|
12934
|
+
consume(chunk) {
|
|
12935
|
+
this[chunk.name]?.(chunk.value);
|
|
12936
|
+
return this;
|
|
12937
|
+
}
|
|
12938
|
+
keyValue(value) {
|
|
12939
|
+
this.key = value;
|
|
12940
|
+
}
|
|
12941
|
+
//stringValue() - aliased below to _saveValue()
|
|
12942
|
+
numberValue(value) {
|
|
12943
|
+
this._saveValue(parseFloat(value));
|
|
12944
|
+
}
|
|
12945
|
+
nullValue() {
|
|
12946
|
+
this._saveValue(null);
|
|
12947
|
+
}
|
|
12948
|
+
trueValue() {
|
|
12949
|
+
this._saveValue(true);
|
|
12950
|
+
}
|
|
12951
|
+
falseValue() {
|
|
12952
|
+
this._saveValue(false);
|
|
12953
|
+
}
|
|
12954
|
+
//startObject() - assigned below
|
|
12955
|
+
endObject() {
|
|
12956
|
+
if (this.stack.length) {
|
|
12957
|
+
const value = this.current;
|
|
12958
|
+
this.key = this.stack.pop();
|
|
12959
|
+
this.current = this.stack.pop();
|
|
12960
|
+
this._saveValue(value);
|
|
12961
|
+
} else {
|
|
12962
|
+
if (this.reviver) {
|
|
12963
|
+
this.current = this.reviver.call({ "": this.current }, "", this.current);
|
|
12964
|
+
}
|
|
12965
|
+
this.done = true;
|
|
12966
|
+
}
|
|
12967
|
+
}
|
|
12968
|
+
//startArray() - assigned below
|
|
12969
|
+
//endArray() - aliased below to endObject()
|
|
12970
|
+
_saveValue(value) {
|
|
12971
|
+
if (this.done) {
|
|
12972
|
+
this.current = value;
|
|
12973
|
+
return;
|
|
12974
|
+
}
|
|
12975
|
+
if (this.current instanceof Array) {
|
|
12976
|
+
this.current.push(value);
|
|
12977
|
+
} else {
|
|
12978
|
+
if (this.key === "__proto__") {
|
|
12979
|
+
Object.defineProperty(this.current, this.key, { value, writable: true, enumerable: true, configurable: true });
|
|
12980
|
+
} else {
|
|
12981
|
+
this.current[this.key] = value;
|
|
12982
|
+
}
|
|
12983
|
+
this.key = null;
|
|
12984
|
+
}
|
|
12985
|
+
}
|
|
12986
|
+
_saveValueWithReviver(value) {
|
|
12987
|
+
if (this.done) {
|
|
12988
|
+
this.current = this.reviver.call({ "": value }, "", value);
|
|
12989
|
+
return;
|
|
12990
|
+
}
|
|
12991
|
+
if (this.current instanceof Array) {
|
|
12992
|
+
this.current.push(value);
|
|
12993
|
+
value = this.reviver.call(this.current, String(this.current.length - 1), value);
|
|
12994
|
+
if (value === void 0) {
|
|
12995
|
+
delete this.current[this.current.length - 1];
|
|
12996
|
+
} else {
|
|
12997
|
+
this.current[this.current.length - 1] = value;
|
|
12998
|
+
}
|
|
12999
|
+
} else {
|
|
13000
|
+
value = this.reviver.call(this.current, this.key, value);
|
|
13001
|
+
if (value !== void 0) {
|
|
13002
|
+
if (this.key === "__proto__") {
|
|
13003
|
+
Object.defineProperty(this.current, this.key, { value, writable: true, enumerable: true, configurable: true });
|
|
13004
|
+
} else {
|
|
13005
|
+
this.current[this.key] = value;
|
|
13006
|
+
}
|
|
13007
|
+
}
|
|
13008
|
+
this.key = null;
|
|
13009
|
+
}
|
|
13010
|
+
}
|
|
13011
|
+
};
|
|
13012
|
+
var proto = (
|
|
13013
|
+
/** @type {any} */
|
|
13014
|
+
Assembler.prototype
|
|
13015
|
+
);
|
|
13016
|
+
proto.stringValue = Assembler.prototype._saveValue;
|
|
13017
|
+
proto.startObject = startObject(Object);
|
|
13018
|
+
proto.startArray = startObject(Array);
|
|
13019
|
+
proto.endArray = Assembler.prototype.endObject;
|
|
13020
|
+
var assembler = (options) => new Assembler(options);
|
|
13021
|
+
Assembler.assembler = assembler;
|
|
13022
|
+
|
|
13023
|
+
// node_modules/stream-json/src/core/streamers/stream-base.js
|
|
13024
|
+
var Counter = class {
|
|
13025
|
+
constructor(initialDepth) {
|
|
13026
|
+
this.depth = initialDepth;
|
|
13027
|
+
}
|
|
13028
|
+
startObject() {
|
|
13029
|
+
++this.depth;
|
|
13030
|
+
}
|
|
13031
|
+
endObject() {
|
|
13032
|
+
--this.depth;
|
|
13033
|
+
}
|
|
13034
|
+
startArray() {
|
|
13035
|
+
++this.depth;
|
|
13036
|
+
}
|
|
13037
|
+
endArray() {
|
|
13038
|
+
--this.depth;
|
|
13039
|
+
}
|
|
13040
|
+
};
|
|
13041
|
+
var streamBase = ({ push, first, level }) => (options = {}) => {
|
|
13042
|
+
const { objectFilter, includeUndecided } = options;
|
|
13043
|
+
let asm = assembler(options);
|
|
13044
|
+
let state = first ? "first" : "check", savedAsm = null;
|
|
13045
|
+
if (typeof objectFilter != "function") {
|
|
13046
|
+
if (state === "check")
|
|
13047
|
+
return (chunk) => {
|
|
13048
|
+
if (asm[chunk.name]) {
|
|
13049
|
+
asm[chunk.name](chunk.value);
|
|
13050
|
+
if (asm.depth === level) {
|
|
13051
|
+
return push(asm);
|
|
13052
|
+
}
|
|
13053
|
+
}
|
|
13054
|
+
return none;
|
|
13055
|
+
};
|
|
13056
|
+
return (chunk) => {
|
|
13057
|
+
switch (state) {
|
|
13058
|
+
case "first":
|
|
13059
|
+
first(chunk);
|
|
13060
|
+
state = "accept";
|
|
13061
|
+
// fall through
|
|
13062
|
+
case "accept":
|
|
13063
|
+
if (asm[chunk.name]) {
|
|
13064
|
+
asm[chunk.name](chunk.value);
|
|
13065
|
+
if (asm.depth === level) {
|
|
13066
|
+
return push(asm);
|
|
13067
|
+
}
|
|
13068
|
+
}
|
|
13069
|
+
break;
|
|
13070
|
+
}
|
|
13071
|
+
return none;
|
|
13072
|
+
};
|
|
13073
|
+
}
|
|
13074
|
+
return (chunk) => {
|
|
13075
|
+
switch (state) {
|
|
13076
|
+
case "first":
|
|
13077
|
+
first(chunk);
|
|
13078
|
+
state = "check";
|
|
13079
|
+
// fall through
|
|
13080
|
+
case "check":
|
|
13081
|
+
if (asm[chunk.name]) {
|
|
13082
|
+
asm[chunk.name](chunk.value);
|
|
13083
|
+
const result = objectFilter(asm);
|
|
13084
|
+
if (result) {
|
|
13085
|
+
state = "accept";
|
|
13086
|
+
if (asm.depth === level) return push(asm);
|
|
13087
|
+
} else if (result === false) {
|
|
13088
|
+
if (asm.depth === level) return push(asm, true);
|
|
13089
|
+
state = "reject";
|
|
13090
|
+
savedAsm = asm;
|
|
13091
|
+
asm = new Counter(savedAsm.depth);
|
|
13092
|
+
savedAsm.dropToLevel(level);
|
|
13093
|
+
} else {
|
|
13094
|
+
if (asm.depth === level) return push(asm, !includeUndecided);
|
|
13095
|
+
}
|
|
13096
|
+
}
|
|
13097
|
+
break;
|
|
13098
|
+
case "accept":
|
|
13099
|
+
if (asm[chunk.name]) {
|
|
13100
|
+
asm[chunk.name](chunk.value);
|
|
13101
|
+
if (asm.depth === level) {
|
|
13102
|
+
state = "check";
|
|
13103
|
+
return push(asm);
|
|
13104
|
+
}
|
|
13105
|
+
}
|
|
13106
|
+
break;
|
|
13107
|
+
case "reject":
|
|
13108
|
+
if (asm[chunk.name]) {
|
|
13109
|
+
asm[chunk.name](chunk.value);
|
|
13110
|
+
if (asm.depth === level) {
|
|
13111
|
+
state = "check";
|
|
13112
|
+
asm = savedAsm;
|
|
13113
|
+
savedAsm = null;
|
|
13114
|
+
return push(asm, true);
|
|
13115
|
+
}
|
|
13116
|
+
}
|
|
13117
|
+
break;
|
|
13118
|
+
}
|
|
13119
|
+
return none;
|
|
13120
|
+
};
|
|
13121
|
+
};
|
|
13122
|
+
var stream_base_default = streamBase;
|
|
13123
|
+
|
|
13124
|
+
// node_modules/stream-json/src/core/streamers/stream-array.js
|
|
13125
|
+
var streamArray = (options) => {
|
|
13126
|
+
let key = 0;
|
|
13127
|
+
return stream_base_default({
|
|
13128
|
+
level: 1,
|
|
13129
|
+
first(chunk) {
|
|
13130
|
+
if (chunk.name !== "startArray") throw new Error("Top-level object should be an array.");
|
|
13131
|
+
},
|
|
13132
|
+
push(asm, discard) {
|
|
13133
|
+
const current = (
|
|
13134
|
+
/** @type {unknown[]} */
|
|
13135
|
+
asm.current
|
|
13136
|
+
);
|
|
13137
|
+
if (current.length) {
|
|
13138
|
+
if (discard) {
|
|
13139
|
+
++key;
|
|
13140
|
+
current.pop();
|
|
13141
|
+
} else {
|
|
13142
|
+
return { key: key++, value: current.pop() };
|
|
13143
|
+
}
|
|
13144
|
+
}
|
|
13145
|
+
return none;
|
|
13146
|
+
}
|
|
13147
|
+
})(options);
|
|
13148
|
+
};
|
|
13149
|
+
streamArray.streamArray = streamArray;
|
|
13150
|
+
var stream_array_default = streamArray;
|
|
13151
|
+
|
|
13152
|
+
// node_modules/stream-json/src/core/utils/with-parser.js
|
|
13153
|
+
var withParser = (fn, options) => gen_default(parser_default(options), fn(options));
|
|
13154
|
+
withParser.withParser = withParser;
|
|
13155
|
+
var with_parser_default = withParser;
|
|
13156
|
+
|
|
13157
|
+
// node_modules/stream-json/src/utils/with-parser.js
|
|
13158
|
+
with_parser_default.asStream = (fn, options) => asStream_default(with_parser_default(fn, options), { ...options, writableObjectMode: false, readableObjectMode: true });
|
|
13159
|
+
with_parser_default.asWebStream = (fn, options) => asWebStream_default(with_parser_default(fn, options), { ...options, writableObjectMode: false, readableObjectMode: true });
|
|
13160
|
+
var with_parser_default2 = with_parser_default;
|
|
13161
|
+
|
|
13162
|
+
// node_modules/stream-json/src/streamers/stream-array.js
|
|
13163
|
+
stream_array_default.asStream = (options) => asStream_default(stream_array_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
|
|
13164
|
+
stream_array_default.asWebStream = (options) => asWebStream_default(stream_array_default(options), { writableObjectMode: true, readableObjectMode: true, ...options });
|
|
13165
|
+
stream_array_default.withParser = (options) => with_parser_default2(stream_array_default, { packKeys: true, ...options });
|
|
13166
|
+
stream_array_default.withParserAsStream = (options) => (
|
|
13167
|
+
/** @type {any} */
|
|
13168
|
+
with_parser_default2.asStream(stream_array_default, { packKeys: true, ...options })
|
|
13169
|
+
);
|
|
13170
|
+
stream_array_default.withParserAsWebStream = (options) => (
|
|
13171
|
+
/** @type {any} */
|
|
13172
|
+
with_parser_default2.asWebStream(stream_array_default, { packKeys: true, ...options })
|
|
13173
|
+
);
|
|
13174
|
+
|
|
13175
|
+
// src/geometry/slabLine.mjs
|
|
13176
|
+
var getSlabData = (
|
|
13177
|
+
/**async */
|
|
13178
|
+
(lines, runDataList, pointCloudCluster = null, getFlatSlab = true, getFlatFloor = false, getOblique = false) => {
|
|
13179
|
+
const flatSlabPoints = [];
|
|
13180
|
+
const obliqueSlabPoints = [];
|
|
13181
|
+
if (getOblique) {
|
|
13182
|
+
for (let i = 0; i < lines.length; i++) {
|
|
13183
|
+
const normal = lines[i][0];
|
|
13184
|
+
if (normal.length != 3) continue;
|
|
13185
|
+
if (normal[2] > 0.98)
|
|
13186
|
+
flatSlabPoints.push(lines[i]);
|
|
13187
|
+
else {
|
|
13188
|
+
obliqueSlabPoints.push(lines[i]);
|
|
13189
|
+
}
|
|
13190
|
+
}
|
|
13191
|
+
} else {
|
|
13192
|
+
for (let i = 0; i < lines.length; i++)
|
|
13193
|
+
flatSlabPoints.push(lines[i]);
|
|
13194
|
+
}
|
|
13195
|
+
let flatSlabDatas = [];
|
|
13196
|
+
let flatFloorDatas = [];
|
|
13197
|
+
let obliqueSlabDatas = [];
|
|
13198
|
+
if (getFlatSlab)
|
|
13199
|
+
flatSlabDatas = getFlatSlabData(flatSlabPoints, runDataList, pointCloudCluster);
|
|
13200
|
+
if (getFlatFloor)
|
|
13201
|
+
flatFloorDatas = getFlatFloorData(flatSlabPoints, runDataList, pointCloudCluster);
|
|
13202
|
+
if (getOblique)
|
|
13203
|
+
obliqueSlabDatas = getObliqueSlabData(obliqueSlabPoints, runDataList, pointCloudCluster);
|
|
13204
|
+
return { flatSlabDatas, obliqueSlabDatas, flatFloorDatas };
|
|
13205
|
+
}
|
|
13206
|
+
);
|
|
11147
13207
|
var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
11148
13208
|
if (lines.length === 0) return;
|
|
11149
13209
|
let slabDatas = [];
|
|
@@ -11226,33 +13286,22 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
11226
13286
|
for (let j = 0; j < newSlabDatas.length; j++) {
|
|
11227
13287
|
if (delIndex.has(j)) continue;
|
|
11228
13288
|
const slabData1 = newSlabDatas[j];
|
|
11229
|
-
let mergeSlabArray = [slabData1];
|
|
11230
13289
|
for (let k = 0; k < newSlabDatas.length; k++) {
|
|
11231
13290
|
if (j == k || delIndex.has(k))
|
|
11232
13291
|
continue;
|
|
11233
13292
|
const slabData2 = newSlabDatas[k];
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
const isIntersect = contoursIntersect(slabData3.contour, slabData2.contour, 1e-3);
|
|
11238
|
-
if (isIntersect) {
|
|
11239
|
-
mergeSlabArray.push(slabData2);
|
|
11240
|
-
delIndex.add(k);
|
|
11241
|
-
k = -1;
|
|
11242
|
-
break;
|
|
11243
|
-
}
|
|
11244
|
-
}
|
|
11245
|
-
}
|
|
11246
|
-
if (mergeSlabArray.length > 1) {
|
|
11247
|
-
for (let c = 1; c < mergeSlabArray.length; c++) {
|
|
11248
|
-
const slabData2 = mergeSlabArray[c];
|
|
13293
|
+
if (Math.abs(slabData1.averagePz - slabData2.averagePz) > 0.05) continue;
|
|
13294
|
+
const isIntersect = contoursIntersect(slabData1.contour, slabData2.contour, 1e-3);
|
|
13295
|
+
if (isIntersect) {
|
|
11249
13296
|
for (let b = 0; b < slabData2.points.length; b++)
|
|
11250
13297
|
slabData1.points.push(slabData2.points[b]);
|
|
13298
|
+
let tmpPoints = slabData1.points.map((p) => [p.x, p.y]);
|
|
13299
|
+
tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.2);
|
|
13300
|
+
let path3 = computeContour(tmpPoints);
|
|
13301
|
+
slabData1.contour = path3;
|
|
13302
|
+
delIndex.add(k);
|
|
13303
|
+
k = -1;
|
|
11251
13304
|
}
|
|
11252
|
-
let tmpPoints = slabData1.points.map((p) => [p.x, p.y]);
|
|
11253
|
-
tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.2);
|
|
11254
|
-
let path3 = computeContour(tmpPoints);
|
|
11255
|
-
slabData1.contour = path3;
|
|
11256
13305
|
}
|
|
11257
13306
|
}
|
|
11258
13307
|
slabDatas = [];
|
|
@@ -11358,7 +13407,7 @@ var getFlatFloorData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
11358
13407
|
for (let b = 0; b < floorData2.points.length; b++)
|
|
11359
13408
|
floorData1.points.push(floorData2.points[b]);
|
|
11360
13409
|
let tmpPoints = floorData1.points.map((p) => [p.x, p.y]);
|
|
11361
|
-
tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.
|
|
13410
|
+
tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.2);
|
|
11362
13411
|
let path3 = computeContour(tmpPoints);
|
|
11363
13412
|
floorData1.contour = path3;
|
|
11364
13413
|
delIndex.add(k);
|
|
@@ -12429,6 +14478,7 @@ var getWindowPcdData = (lines, pcdData) => {
|
|
|
12429
14478
|
let eligibilityLinesIndexs = [];
|
|
12430
14479
|
for (let j = 0; j < lines.length; j++) {
|
|
12431
14480
|
const line3 = lines[j];
|
|
14481
|
+
if (line3.isRebuild) continue;
|
|
12432
14482
|
let ptStart2 = getPt3(line3.start);
|
|
12433
14483
|
let ptEnd2 = getPt3(line3.end);
|
|
12434
14484
|
ptStart2.z = ptEnd2.z = ptMid1.z;
|
|
@@ -16676,15 +18726,15 @@ function smoothPolyline(pts) {
|
|
|
16676
18726
|
if (pts.length < 4) return pts;
|
|
16677
18727
|
let cur = pts.map((p) => ({ x: p.x, z: p.z }));
|
|
16678
18728
|
for (let iter = 0; iter < 3; iter++) {
|
|
16679
|
-
const
|
|
18729
|
+
const next2 = [{ ...cur[0] }];
|
|
16680
18730
|
for (let i = 1; i < cur.length - 1; i++) {
|
|
16681
|
-
|
|
18731
|
+
next2.push({
|
|
16682
18732
|
x: (cur[i - 1].x + cur[i].x + cur[i + 1].x) / 3,
|
|
16683
18733
|
z: (cur[i - 1].z + cur[i].z + cur[i + 1].z) / 3
|
|
16684
18734
|
});
|
|
16685
18735
|
}
|
|
16686
|
-
|
|
16687
|
-
cur =
|
|
18736
|
+
next2.push({ ...cur[cur.length - 1] });
|
|
18737
|
+
cur = next2;
|
|
16688
18738
|
}
|
|
16689
18739
|
return cur;
|
|
16690
18740
|
}
|
|
@@ -17580,11 +19630,11 @@ function segmentContourCurves(contour, config) {
|
|
|
17580
19630
|
const sorted = [...survivors].sort((a, b) => a.start - b.start);
|
|
17581
19631
|
let cur = sorted[0];
|
|
17582
19632
|
for (let i = 1; i < sorted.length; i++) {
|
|
17583
|
-
const
|
|
17584
|
-
let gap =
|
|
19633
|
+
const next2 = sorted[i];
|
|
19634
|
+
let gap = next2.start - cur.end;
|
|
17585
19635
|
if (gap < 0) {
|
|
17586
|
-
if (cur.end > n * 0.5 &&
|
|
17587
|
-
gap =
|
|
19636
|
+
if (cur.end > n * 0.5 && next2.start < n * 0.5) {
|
|
19637
|
+
gap = next2.start + n - cur.end;
|
|
17588
19638
|
} else {
|
|
17589
19639
|
gap = 0;
|
|
17590
19640
|
}
|
|
@@ -17592,15 +19642,15 @@ function segmentContourCurves(contour, config) {
|
|
|
17592
19642
|
const isOverlap = gap === 0;
|
|
17593
19643
|
let canMerge = gap <= MERGE_GAP_MAX && isOverlap;
|
|
17594
19644
|
if (!canMerge && gap <= MERGE_GAP_MAX) {
|
|
17595
|
-
const cdist = Math.sqrt((cur.seg.centerX -
|
|
17596
|
-
const rMax = Math.max(cur.seg.radius,
|
|
17597
|
-
const rMin = Math.min(cur.seg.radius,
|
|
19645
|
+
const cdist = Math.sqrt((cur.seg.centerX - next2.seg.centerX) ** 2 + (cur.seg.centerZ - next2.seg.centerZ) ** 2);
|
|
19646
|
+
const rMax = Math.max(cur.seg.radius, next2.seg.radius);
|
|
19647
|
+
const rMin = Math.min(cur.seg.radius, next2.seg.radius);
|
|
17598
19648
|
const rRatio = rMin > 0 ? rMax / rMin : 99;
|
|
17599
19649
|
canMerge = cdist < MERGE_CENTER_DIST && rRatio < MERGE_RADIUS_RATIO;
|
|
17600
19650
|
}
|
|
17601
19651
|
if (canMerge) {
|
|
17602
|
-
const uStart = Math.min(cur.start,
|
|
17603
|
-
const uEnd = Math.max(cur.end,
|
|
19652
|
+
const uStart = Math.min(cur.start, next2.start);
|
|
19653
|
+
const uEnd = Math.max(cur.end, next2.end);
|
|
17604
19654
|
const allPts = [];
|
|
17605
19655
|
for (let j = uStart; ; j = (j + 1) % n) {
|
|
17606
19656
|
allPts.push({ ...contour[j] });
|
|
@@ -17616,13 +19666,13 @@ function segmentContourCurves(contour, config) {
|
|
|
17616
19666
|
cur = {
|
|
17617
19667
|
seg: { points: allPts, type: "C_curve", radius: r, centerX: cx, centerZ: cz, arcAngle: arcAng, arcLength: calcTotalLength(allPts) },
|
|
17618
19668
|
start: cur.start,
|
|
17619
|
-
end:
|
|
19669
|
+
end: next2.end,
|
|
17620
19670
|
source: cur.source
|
|
17621
19671
|
};
|
|
17622
19672
|
mergeCount++;
|
|
17623
19673
|
} else {
|
|
17624
19674
|
merged.push(cur);
|
|
17625
|
-
cur =
|
|
19675
|
+
cur = next2;
|
|
17626
19676
|
}
|
|
17627
19677
|
}
|
|
17628
19678
|
merged.push(cur);
|
|
@@ -17881,9 +19931,9 @@ function processFromPointCloud(points3D, rawLines, pcConfig) {
|
|
|
17881
19931
|
const n = pts.length;
|
|
17882
19932
|
const result = pts.map((p) => ({ x: p.x, z: p.z }));
|
|
17883
19933
|
for (let i = 0; i < n; i++) {
|
|
17884
|
-
const prev = pts[(i - 1 + n) % n], curr = pts[i],
|
|
19934
|
+
const prev = pts[(i - 1 + n) % n], curr = pts[i], next2 = pts[(i + 1) % n];
|
|
17885
19935
|
const v1x = curr.x - prev.x, v1z = curr.z - prev.z;
|
|
17886
|
-
const v2x =
|
|
19936
|
+
const v2x = next2.x - curr.x, v2z = next2.z - curr.z;
|
|
17887
19937
|
const l1 = Math.sqrt(v1x * v1x + v1z * v1z);
|
|
17888
19938
|
const l2 = Math.sqrt(v2x * v2x + v2z * v2z);
|
|
17889
19939
|
if (l1 < 1e-3 || l2 < 1e-3) continue;
|
|
@@ -17938,9 +19988,9 @@ function processFromPointCloud(points3D, rawLines, pcConfig) {
|
|
|
17938
19988
|
const isCW = polySignedArea(pts) >= 0;
|
|
17939
19989
|
return pts.map((p, i) => {
|
|
17940
19990
|
const prev = pts[(i - 1 + pts.length) % pts.length];
|
|
17941
|
-
const
|
|
17942
|
-
const dx =
|
|
17943
|
-
const dz =
|
|
19991
|
+
const next2 = pts[(i + 1) % pts.length];
|
|
19992
|
+
const dx = next2.x - prev.x;
|
|
19993
|
+
const dz = next2.z - prev.z;
|
|
17944
19994
|
const len = Math.sqrt(dx * dx + dz * dz);
|
|
17945
19995
|
if (len < 1e-3) return { ...p };
|
|
17946
19996
|
const nx = isCW ? dz : -dz;
|
|
@@ -18039,9 +20089,9 @@ function processFromSegments(segments, config) {
|
|
|
18039
20089
|
const isCW = signedArea2(pts) >= 0;
|
|
18040
20090
|
const expanded = pts.map((p, i) => {
|
|
18041
20091
|
const prev = pts[(i - 1 + pts.length) % pts.length];
|
|
18042
|
-
const
|
|
18043
|
-
const dx =
|
|
18044
|
-
const dz =
|
|
20092
|
+
const next2 = pts[(i + 1) % pts.length];
|
|
20093
|
+
const dx = next2.x - prev.x;
|
|
20094
|
+
const dz = next2.z - prev.z;
|
|
18045
20095
|
const len = Math.sqrt(dx * dx + dz * dz);
|
|
18046
20096
|
if (len < 1e-3) return { ...p };
|
|
18047
20097
|
const nx = isCW ? dz : -dz;
|
|
@@ -19189,6 +21239,7 @@ export {
|
|
|
19189
21239
|
attachWindows,
|
|
19190
21240
|
calcAngle3 as calcAngle,
|
|
19191
21241
|
checkBeamIsReasonable,
|
|
21242
|
+
checkSwitchSizeIsTrue,
|
|
19192
21243
|
checkWindowAndDoorIsTrue,
|
|
19193
21244
|
classifyWallByPointCloudPCA,
|
|
19194
21245
|
processPipeline2 as classifyWallShapes,
|