@slicemachine/manager 0.1.1-dev-plugins.3 → 0.1.1-dev-plugins.5
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/__node_modules/@msgpack/msgpack/dist.es5_esm/CachedKeyDecoder.cjs +65 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/CachedKeyDecoder.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/CachedKeyDecoder.js +65 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/CachedKeyDecoder.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/DecodeError.cjs +40 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/DecodeError.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/DecodeError.js +40 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/DecodeError.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.cjs +801 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.js +801 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Decoder.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Encoder.cjs +351 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Encoder.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Encoder.js +351 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/Encoder.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtData.cjs +11 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtData.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtData.js +11 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtData.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtensionCodec.cjs +62 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtensionCodec.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtensionCodec.js +62 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/ExtensionCodec.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/decode.cjs +14 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/decode.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/decode.js +14 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/decode.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/encode.cjs +13 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/encode.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/encode.js +13 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/encode.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/timestamp.cjs +91 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/timestamp.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/timestamp.js +91 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/timestamp.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/int.cjs +31 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/int.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/int.js +31 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/int.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/prettyByte.cjs +7 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/prettyByte.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/prettyByte.js +7 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/prettyByte.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/typedArrays.cjs +23 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/typedArrays.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/typedArrays.js +23 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/typedArrays.js.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/utf8.cjs +132 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/utf8.cjs.map +1 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/utf8.js +132 -0
- package/dist/__node_modules/@msgpack/msgpack/dist.es5_esm/utils/utf8.js.map +1 -0
- package/dist/__node_modules/r19/dist/client/createRPCClient.cjs +29 -11
- package/dist/__node_modules/r19/dist/client/createRPCClient.cjs.map +1 -1
- package/dist/__node_modules/r19/dist/client/createRPCClient.js +29 -11
- package/dist/__node_modules/r19/dist/client/createRPCClient.js.map +1 -1
- package/dist/__node_modules/r19/dist/createRPCMiddleware.cjs +5 -4
- package/dist/__node_modules/r19/dist/createRPCMiddleware.cjs.map +1 -1
- package/dist/__node_modules/r19/dist/createRPCMiddleware.js +6 -5
- package/dist/__node_modules/r19/dist/createRPCMiddleware.js.map +1 -1
- package/dist/__node_modules/r19/dist/handleRPCRequest.cjs +39 -110
- package/dist/__node_modules/r19/dist/handleRPCRequest.cjs.map +1 -1
- package/dist/__node_modules/r19/dist/handleRPCRequest.js +39 -110
- package/dist/__node_modules/r19/dist/handleRPCRequest.js.map +1 -1
- package/dist/__node_modules/r19/dist/lib/replaceLeaves.cjs +28 -0
- package/dist/__node_modules/r19/dist/lib/replaceLeaves.cjs.map +1 -0
- package/dist/__node_modules/r19/dist/lib/replaceLeaves.js +28 -0
- package/dist/__node_modules/r19/dist/lib/replaceLeaves.js.map +1 -0
- package/dist/managers/createSliceMachineManagerMiddleware.cjs +0 -4
- package/dist/managers/createSliceMachineManagerMiddleware.cjs.map +1 -1
- package/dist/managers/createSliceMachineManagerMiddleware.js +0 -4
- package/dist/managers/createSliceMachineManagerMiddleware.js.map +1 -1
- package/dist/managers/screenshots/ScreenshotsManager.cjs +33 -16
- package/dist/managers/screenshots/ScreenshotsManager.cjs.map +1 -1
- package/dist/managers/screenshots/ScreenshotsManager.d.ts +2 -4
- package/dist/managers/screenshots/ScreenshotsManager.js +34 -17
- package/dist/managers/screenshots/ScreenshotsManager.js.map +1 -1
- package/dist/test/createSliceMachineManagerMSWHandler.cjs +3 -10
- package/dist/test/createSliceMachineManagerMSWHandler.cjs.map +1 -1
- package/dist/test/createSliceMachineManagerMSWHandler.js +3 -10
- package/dist/test/createSliceMachineManagerMSWHandler.js.map +1 -1
- package/package.json +4 -4
- package/src/client/index.ts +1 -1
- package/src/managers/screenshots/ScreenshotsManager.ts +65 -18
- package/src/test/createSliceMachineManagerMSWHandler.ts +2 -14
- package/dist/__node_modules/busboy/lib/index.cjs +0 -51
- package/dist/__node_modules/busboy/lib/index.cjs.map +0 -1
- package/dist/__node_modules/busboy/lib/index.js +0 -52
- package/dist/__node_modules/busboy/lib/index.js.map +0 -1
- package/dist/__node_modules/busboy/lib/types/multipart.cjs +0 -1046
- package/dist/__node_modules/busboy/lib/types/multipart.cjs.map +0 -1
- package/dist/__node_modules/busboy/lib/types/multipart.js +0 -1047
- package/dist/__node_modules/busboy/lib/types/multipart.js.map +0 -1
- package/dist/__node_modules/busboy/lib/types/urlencoded.cjs +0 -545
- package/dist/__node_modules/busboy/lib/types/urlencoded.cjs.map +0 -1
- package/dist/__node_modules/busboy/lib/types/urlencoded.js +0 -546
- package/dist/__node_modules/busboy/lib/types/urlencoded.js.map +0 -1
- package/dist/__node_modules/busboy/lib/utils.cjs +0 -1681
- package/dist/__node_modules/busboy/lib/utils.cjs.map +0 -1
- package/dist/__node_modules/busboy/lib/utils.js +0 -1682
- package/dist/__node_modules/busboy/lib/utils.js.map +0 -1
- package/dist/__node_modules/devalue/src/constants.cjs +0 -15
- package/dist/__node_modules/devalue/src/constants.cjs.map +0 -1
- package/dist/__node_modules/devalue/src/constants.js +0 -15
- package/dist/__node_modules/devalue/src/constants.js.map +0 -1
- package/dist/__node_modules/devalue/src/parse.cjs +0 -95
- package/dist/__node_modules/devalue/src/parse.cjs.map +0 -1
- package/dist/__node_modules/devalue/src/parse.js +0 -95
- package/dist/__node_modules/devalue/src/parse.js.map +0 -1
- package/dist/__node_modules/devalue/src/stringify.cjs +0 -140
- package/dist/__node_modules/devalue/src/stringify.cjs.map +0 -1
- package/dist/__node_modules/devalue/src/stringify.js +0 -140
- package/dist/__node_modules/devalue/src/stringify.js.map +0 -1
- package/dist/__node_modules/devalue/src/uneval.cjs +0 -4
- package/dist/__node_modules/devalue/src/uneval.cjs.map +0 -1
- package/dist/__node_modules/devalue/src/uneval.js +0 -3
- package/dist/__node_modules/devalue/src/uneval.js.map +0 -1
- package/dist/__node_modules/devalue/src/utils.cjs +0 -68
- package/dist/__node_modules/devalue/src/utils.cjs.map +0 -1
- package/dist/__node_modules/devalue/src/utils.js +0 -68
- package/dist/__node_modules/devalue/src/utils.js.map +0 -1
- package/dist/__node_modules/formdata-node/lib/browser.cjs +0 -16
- package/dist/__node_modules/formdata-node/lib/browser.cjs.map +0 -1
- package/dist/__node_modules/formdata-node/lib/browser.js +0 -16
- package/dist/__node_modules/formdata-node/lib/browser.js.map +0 -1
- package/dist/__node_modules/r19/dist/constants.cjs +0 -5
- package/dist/__node_modules/r19/dist/constants.cjs.map +0 -1
- package/dist/__node_modules/r19/dist/constants.js +0 -5
- package/dist/__node_modules/r19/dist/constants.js.map +0 -1
- package/dist/__node_modules/r19/dist/lib/encodeFormData.cjs +0 -46
- package/dist/__node_modules/r19/dist/lib/encodeFormData.cjs.map +0 -1
- package/dist/__node_modules/r19/dist/lib/encodeFormData.js +0 -46
- package/dist/__node_modules/r19/dist/lib/encodeFormData.js.map +0 -1
- package/dist/__node_modules/r19/dist/lib/flattenObject.cjs +0 -43
- package/dist/__node_modules/r19/dist/lib/flattenObject.cjs.map +0 -1
- package/dist/__node_modules/r19/dist/lib/flattenObject.js +0 -43
- package/dist/__node_modules/r19/dist/lib/flattenObject.js.map +0 -1
- package/dist/__node_modules/r19/dist/lib/formDataToObject.client.cjs +0 -19
- package/dist/__node_modules/r19/dist/lib/formDataToObject.client.cjs.map +0 -1
- package/dist/__node_modules/r19/dist/lib/formDataToObject.client.js +0 -19
- package/dist/__node_modules/r19/dist/lib/formDataToObject.client.js.map +0 -1
- package/dist/__node_modules/r19/dist/lib/objectToFormData.client.cjs +0 -20
- package/dist/__node_modules/r19/dist/lib/objectToFormData.client.cjs.map +0 -1
- package/dist/__node_modules/r19/dist/lib/objectToFormData.client.js +0 -20
- package/dist/__node_modules/r19/dist/lib/objectToFormData.client.js.map +0 -1
- package/dist/__node_modules/r19/dist/lib/objectToFormData.server.cjs +0 -22
- package/dist/__node_modules/r19/dist/lib/objectToFormData.server.cjs.map +0 -1
- package/dist/__node_modules/r19/dist/lib/objectToFormData.server.js +0 -22
- package/dist/__node_modules/r19/dist/lib/objectToFormData.server.js.map +0 -1
- package/dist/__node_modules/r19/dist/lib/unflattenObject.cjs +0 -20
- package/dist/__node_modules/r19/dist/lib/unflattenObject.cjs.map +0 -1
- package/dist/__node_modules/r19/dist/lib/unflattenObject.js +0 -20
- package/dist/__node_modules/r19/dist/lib/unflattenObject.js.map +0 -1
- package/dist/__node_modules/streamsearch/lib/sbmh.cjs +0 -393
- package/dist/__node_modules/streamsearch/lib/sbmh.cjs.map +0 -1
- package/dist/__node_modules/streamsearch/lib/sbmh.js +0 -394
- package/dist/__node_modules/streamsearch/lib/sbmh.js.map +0 -1
|
@@ -0,0 +1,801 @@
|
|
|
1
|
+
import { prettyByte } from "./utils/prettyByte.js";
|
|
2
|
+
import { ExtensionCodec } from "./ExtensionCodec.js";
|
|
3
|
+
import { getUint64, getInt64, UINT32_MAX } from "./utils/int.js";
|
|
4
|
+
import { TEXT_DECODER_THRESHOLD, utf8DecodeTD, utf8DecodeJs } from "./utils/utf8.js";
|
|
5
|
+
import { ensureUint8Array, createDataView } from "./utils/typedArrays.js";
|
|
6
|
+
import { CachedKeyDecoder } from "./CachedKeyDecoder.js";
|
|
7
|
+
import { DecodeError } from "./DecodeError.js";
|
|
8
|
+
var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) {
|
|
10
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
11
|
+
resolve(value);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
15
|
+
function fulfilled(value) {
|
|
16
|
+
try {
|
|
17
|
+
step(generator.next(value));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function rejected(value) {
|
|
23
|
+
try {
|
|
24
|
+
step(generator["throw"](value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function step(result) {
|
|
30
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
31
|
+
}
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var __generator = globalThis && globalThis.__generator || function(thisArg, body) {
|
|
36
|
+
var _ = { label: 0, sent: function() {
|
|
37
|
+
if (t[0] & 1)
|
|
38
|
+
throw t[1];
|
|
39
|
+
return t[1];
|
|
40
|
+
}, trys: [], ops: [] }, f, y, t, g;
|
|
41
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
42
|
+
return this;
|
|
43
|
+
}), g;
|
|
44
|
+
function verb(n) {
|
|
45
|
+
return function(v) {
|
|
46
|
+
return step([n, v]);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f)
|
|
51
|
+
throw new TypeError("Generator is already executing.");
|
|
52
|
+
while (_)
|
|
53
|
+
try {
|
|
54
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
55
|
+
return t;
|
|
56
|
+
if (y = 0, t)
|
|
57
|
+
op = [op[0] & 2, t.value];
|
|
58
|
+
switch (op[0]) {
|
|
59
|
+
case 0:
|
|
60
|
+
case 1:
|
|
61
|
+
t = op;
|
|
62
|
+
break;
|
|
63
|
+
case 4:
|
|
64
|
+
_.label++;
|
|
65
|
+
return { value: op[1], done: false };
|
|
66
|
+
case 5:
|
|
67
|
+
_.label++;
|
|
68
|
+
y = op[1];
|
|
69
|
+
op = [0];
|
|
70
|
+
continue;
|
|
71
|
+
case 7:
|
|
72
|
+
op = _.ops.pop();
|
|
73
|
+
_.trys.pop();
|
|
74
|
+
continue;
|
|
75
|
+
default:
|
|
76
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
77
|
+
_ = 0;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
81
|
+
_.label = op[1];
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
85
|
+
_.label = t[1];
|
|
86
|
+
t = op;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
if (t && _.label < t[2]) {
|
|
90
|
+
_.label = t[2];
|
|
91
|
+
_.ops.push(op);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (t[2])
|
|
95
|
+
_.ops.pop();
|
|
96
|
+
_.trys.pop();
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
op = body.call(thisArg, _);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
op = [6, e];
|
|
102
|
+
y = 0;
|
|
103
|
+
} finally {
|
|
104
|
+
f = t = 0;
|
|
105
|
+
}
|
|
106
|
+
if (op[0] & 5)
|
|
107
|
+
throw op[1];
|
|
108
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var __asyncValues = globalThis && globalThis.__asyncValues || function(o) {
|
|
112
|
+
if (!Symbol.asyncIterator)
|
|
113
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
114
|
+
var m = o[Symbol.asyncIterator], i;
|
|
115
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
116
|
+
return this;
|
|
117
|
+
}, i);
|
|
118
|
+
function verb(n) {
|
|
119
|
+
i[n] = o[n] && function(v) {
|
|
120
|
+
return new Promise(function(resolve, reject) {
|
|
121
|
+
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function settle(resolve, reject, d, v) {
|
|
126
|
+
Promise.resolve(v).then(function(v2) {
|
|
127
|
+
resolve({ value: v2, done: d });
|
|
128
|
+
}, reject);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var __await = globalThis && globalThis.__await || function(v) {
|
|
132
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
133
|
+
};
|
|
134
|
+
var __asyncGenerator = globalThis && globalThis.__asyncGenerator || function(thisArg, _arguments, generator) {
|
|
135
|
+
if (!Symbol.asyncIterator)
|
|
136
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
137
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
138
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
139
|
+
return this;
|
|
140
|
+
}, i;
|
|
141
|
+
function verb(n) {
|
|
142
|
+
if (g[n])
|
|
143
|
+
i[n] = function(v) {
|
|
144
|
+
return new Promise(function(a, b) {
|
|
145
|
+
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function resume(n, v) {
|
|
150
|
+
try {
|
|
151
|
+
step(g[n](v));
|
|
152
|
+
} catch (e) {
|
|
153
|
+
settle(q[0][3], e);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function step(r) {
|
|
157
|
+
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
158
|
+
}
|
|
159
|
+
function fulfill(value) {
|
|
160
|
+
resume("next", value);
|
|
161
|
+
}
|
|
162
|
+
function reject(value) {
|
|
163
|
+
resume("throw", value);
|
|
164
|
+
}
|
|
165
|
+
function settle(f, v) {
|
|
166
|
+
if (f(v), q.shift(), q.length)
|
|
167
|
+
resume(q[0][0], q[0][1]);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
var isValidMapKeyType = function(key) {
|
|
171
|
+
var keyType = typeof key;
|
|
172
|
+
return keyType === "string" || keyType === "number";
|
|
173
|
+
};
|
|
174
|
+
var HEAD_BYTE_REQUIRED = -1;
|
|
175
|
+
var EMPTY_VIEW = new DataView(new ArrayBuffer(0));
|
|
176
|
+
var EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
|
|
177
|
+
var DataViewIndexOutOfBoundsError = function() {
|
|
178
|
+
try {
|
|
179
|
+
EMPTY_VIEW.getInt8(0);
|
|
180
|
+
} catch (e) {
|
|
181
|
+
return e.constructor;
|
|
182
|
+
}
|
|
183
|
+
throw new Error("never reached");
|
|
184
|
+
}();
|
|
185
|
+
var MORE_DATA = new DataViewIndexOutOfBoundsError("Insufficient data");
|
|
186
|
+
var sharedCachedKeyDecoder = new CachedKeyDecoder();
|
|
187
|
+
var Decoder = function() {
|
|
188
|
+
function Decoder2(extensionCodec, context, maxStrLength, maxBinLength, maxArrayLength, maxMapLength, maxExtLength, keyDecoder) {
|
|
189
|
+
if (extensionCodec === void 0) {
|
|
190
|
+
extensionCodec = ExtensionCodec.defaultCodec;
|
|
191
|
+
}
|
|
192
|
+
if (context === void 0) {
|
|
193
|
+
context = void 0;
|
|
194
|
+
}
|
|
195
|
+
if (maxStrLength === void 0) {
|
|
196
|
+
maxStrLength = UINT32_MAX;
|
|
197
|
+
}
|
|
198
|
+
if (maxBinLength === void 0) {
|
|
199
|
+
maxBinLength = UINT32_MAX;
|
|
200
|
+
}
|
|
201
|
+
if (maxArrayLength === void 0) {
|
|
202
|
+
maxArrayLength = UINT32_MAX;
|
|
203
|
+
}
|
|
204
|
+
if (maxMapLength === void 0) {
|
|
205
|
+
maxMapLength = UINT32_MAX;
|
|
206
|
+
}
|
|
207
|
+
if (maxExtLength === void 0) {
|
|
208
|
+
maxExtLength = UINT32_MAX;
|
|
209
|
+
}
|
|
210
|
+
if (keyDecoder === void 0) {
|
|
211
|
+
keyDecoder = sharedCachedKeyDecoder;
|
|
212
|
+
}
|
|
213
|
+
this.extensionCodec = extensionCodec;
|
|
214
|
+
this.context = context;
|
|
215
|
+
this.maxStrLength = maxStrLength;
|
|
216
|
+
this.maxBinLength = maxBinLength;
|
|
217
|
+
this.maxArrayLength = maxArrayLength;
|
|
218
|
+
this.maxMapLength = maxMapLength;
|
|
219
|
+
this.maxExtLength = maxExtLength;
|
|
220
|
+
this.keyDecoder = keyDecoder;
|
|
221
|
+
this.totalPos = 0;
|
|
222
|
+
this.pos = 0;
|
|
223
|
+
this.view = EMPTY_VIEW;
|
|
224
|
+
this.bytes = EMPTY_BYTES;
|
|
225
|
+
this.headByte = HEAD_BYTE_REQUIRED;
|
|
226
|
+
this.stack = [];
|
|
227
|
+
}
|
|
228
|
+
Decoder2.prototype.reinitializeState = function() {
|
|
229
|
+
this.totalPos = 0;
|
|
230
|
+
this.headByte = HEAD_BYTE_REQUIRED;
|
|
231
|
+
this.stack.length = 0;
|
|
232
|
+
};
|
|
233
|
+
Decoder2.prototype.setBuffer = function(buffer) {
|
|
234
|
+
this.bytes = ensureUint8Array(buffer);
|
|
235
|
+
this.view = createDataView(this.bytes);
|
|
236
|
+
this.pos = 0;
|
|
237
|
+
};
|
|
238
|
+
Decoder2.prototype.appendBuffer = function(buffer) {
|
|
239
|
+
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
|
|
240
|
+
this.setBuffer(buffer);
|
|
241
|
+
} else {
|
|
242
|
+
var remainingData = this.bytes.subarray(this.pos);
|
|
243
|
+
var newData = ensureUint8Array(buffer);
|
|
244
|
+
var newBuffer = new Uint8Array(remainingData.length + newData.length);
|
|
245
|
+
newBuffer.set(remainingData);
|
|
246
|
+
newBuffer.set(newData, remainingData.length);
|
|
247
|
+
this.setBuffer(newBuffer);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
Decoder2.prototype.hasRemaining = function(size) {
|
|
251
|
+
return this.view.byteLength - this.pos >= size;
|
|
252
|
+
};
|
|
253
|
+
Decoder2.prototype.createExtraByteError = function(posToShow) {
|
|
254
|
+
var _a = this, view = _a.view, pos = _a.pos;
|
|
255
|
+
return new RangeError("Extra ".concat(view.byteLength - pos, " of ").concat(view.byteLength, " byte(s) found at buffer[").concat(posToShow, "]"));
|
|
256
|
+
};
|
|
257
|
+
Decoder2.prototype.decode = function(buffer) {
|
|
258
|
+
this.reinitializeState();
|
|
259
|
+
this.setBuffer(buffer);
|
|
260
|
+
var object = this.doDecodeSync();
|
|
261
|
+
if (this.hasRemaining(1)) {
|
|
262
|
+
throw this.createExtraByteError(this.pos);
|
|
263
|
+
}
|
|
264
|
+
return object;
|
|
265
|
+
};
|
|
266
|
+
Decoder2.prototype.decodeMulti = function(buffer) {
|
|
267
|
+
return __generator(this, function(_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0:
|
|
270
|
+
this.reinitializeState();
|
|
271
|
+
this.setBuffer(buffer);
|
|
272
|
+
_a.label = 1;
|
|
273
|
+
case 1:
|
|
274
|
+
if (!this.hasRemaining(1))
|
|
275
|
+
return [3, 3];
|
|
276
|
+
return [4, this.doDecodeSync()];
|
|
277
|
+
case 2:
|
|
278
|
+
_a.sent();
|
|
279
|
+
return [3, 1];
|
|
280
|
+
case 3:
|
|
281
|
+
return [
|
|
282
|
+
2
|
|
283
|
+
/*return*/
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
Decoder2.prototype.decodeAsync = function(stream) {
|
|
289
|
+
var stream_1, stream_1_1;
|
|
290
|
+
var e_1, _a;
|
|
291
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
292
|
+
var decoded, object, buffer, e_1_1, _b, headByte, pos, totalPos;
|
|
293
|
+
return __generator(this, function(_c) {
|
|
294
|
+
switch (_c.label) {
|
|
295
|
+
case 0:
|
|
296
|
+
decoded = false;
|
|
297
|
+
_c.label = 1;
|
|
298
|
+
case 1:
|
|
299
|
+
_c.trys.push([1, 6, 7, 12]);
|
|
300
|
+
stream_1 = __asyncValues(stream);
|
|
301
|
+
_c.label = 2;
|
|
302
|
+
case 2:
|
|
303
|
+
return [4, stream_1.next()];
|
|
304
|
+
case 3:
|
|
305
|
+
if (!(stream_1_1 = _c.sent(), !stream_1_1.done))
|
|
306
|
+
return [3, 5];
|
|
307
|
+
buffer = stream_1_1.value;
|
|
308
|
+
if (decoded) {
|
|
309
|
+
throw this.createExtraByteError(this.totalPos);
|
|
310
|
+
}
|
|
311
|
+
this.appendBuffer(buffer);
|
|
312
|
+
try {
|
|
313
|
+
object = this.doDecodeSync();
|
|
314
|
+
decoded = true;
|
|
315
|
+
} catch (e) {
|
|
316
|
+
if (!(e instanceof DataViewIndexOutOfBoundsError)) {
|
|
317
|
+
throw e;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
this.totalPos += this.pos;
|
|
321
|
+
_c.label = 4;
|
|
322
|
+
case 4:
|
|
323
|
+
return [3, 2];
|
|
324
|
+
case 5:
|
|
325
|
+
return [3, 12];
|
|
326
|
+
case 6:
|
|
327
|
+
e_1_1 = _c.sent();
|
|
328
|
+
e_1 = { error: e_1_1 };
|
|
329
|
+
return [3, 12];
|
|
330
|
+
case 7:
|
|
331
|
+
_c.trys.push([7, , 10, 11]);
|
|
332
|
+
if (!(stream_1_1 && !stream_1_1.done && (_a = stream_1.return)))
|
|
333
|
+
return [3, 9];
|
|
334
|
+
return [4, _a.call(stream_1)];
|
|
335
|
+
case 8:
|
|
336
|
+
_c.sent();
|
|
337
|
+
_c.label = 9;
|
|
338
|
+
case 9:
|
|
339
|
+
return [3, 11];
|
|
340
|
+
case 10:
|
|
341
|
+
if (e_1)
|
|
342
|
+
throw e_1.error;
|
|
343
|
+
return [
|
|
344
|
+
7
|
|
345
|
+
/*endfinally*/
|
|
346
|
+
];
|
|
347
|
+
case 11:
|
|
348
|
+
return [
|
|
349
|
+
7
|
|
350
|
+
/*endfinally*/
|
|
351
|
+
];
|
|
352
|
+
case 12:
|
|
353
|
+
if (decoded) {
|
|
354
|
+
if (this.hasRemaining(1)) {
|
|
355
|
+
throw this.createExtraByteError(this.totalPos);
|
|
356
|
+
}
|
|
357
|
+
return [2, object];
|
|
358
|
+
}
|
|
359
|
+
_b = this, headByte = _b.headByte, pos = _b.pos, totalPos = _b.totalPos;
|
|
360
|
+
throw new RangeError("Insufficient data in parsing ".concat(prettyByte(headByte), " at ").concat(totalPos, " (").concat(pos, " in the current buffer)"));
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
Decoder2.prototype.decodeArrayStream = function(stream) {
|
|
366
|
+
return this.decodeMultiAsync(stream, true);
|
|
367
|
+
};
|
|
368
|
+
Decoder2.prototype.decodeStream = function(stream) {
|
|
369
|
+
return this.decodeMultiAsync(stream, false);
|
|
370
|
+
};
|
|
371
|
+
Decoder2.prototype.decodeMultiAsync = function(stream, isArray) {
|
|
372
|
+
return __asyncGenerator(this, arguments, function decodeMultiAsync_1() {
|
|
373
|
+
var isArrayHeaderRequired, arrayItemsLeft, stream_2, stream_2_1, buffer, e_2, e_3_1;
|
|
374
|
+
var e_3, _a;
|
|
375
|
+
return __generator(this, function(_b) {
|
|
376
|
+
switch (_b.label) {
|
|
377
|
+
case 0:
|
|
378
|
+
isArrayHeaderRequired = isArray;
|
|
379
|
+
arrayItemsLeft = -1;
|
|
380
|
+
_b.label = 1;
|
|
381
|
+
case 1:
|
|
382
|
+
_b.trys.push([1, 13, 14, 19]);
|
|
383
|
+
stream_2 = __asyncValues(stream);
|
|
384
|
+
_b.label = 2;
|
|
385
|
+
case 2:
|
|
386
|
+
return [4, __await(stream_2.next())];
|
|
387
|
+
case 3:
|
|
388
|
+
if (!(stream_2_1 = _b.sent(), !stream_2_1.done))
|
|
389
|
+
return [3, 12];
|
|
390
|
+
buffer = stream_2_1.value;
|
|
391
|
+
if (isArray && arrayItemsLeft === 0) {
|
|
392
|
+
throw this.createExtraByteError(this.totalPos);
|
|
393
|
+
}
|
|
394
|
+
this.appendBuffer(buffer);
|
|
395
|
+
if (isArrayHeaderRequired) {
|
|
396
|
+
arrayItemsLeft = this.readArraySize();
|
|
397
|
+
isArrayHeaderRequired = false;
|
|
398
|
+
this.complete();
|
|
399
|
+
}
|
|
400
|
+
_b.label = 4;
|
|
401
|
+
case 4:
|
|
402
|
+
_b.trys.push([4, 9, , 10]);
|
|
403
|
+
_b.label = 5;
|
|
404
|
+
case 5:
|
|
405
|
+
return [4, __await(this.doDecodeSync())];
|
|
406
|
+
case 6:
|
|
407
|
+
return [4, _b.sent()];
|
|
408
|
+
case 7:
|
|
409
|
+
_b.sent();
|
|
410
|
+
if (--arrayItemsLeft === 0) {
|
|
411
|
+
return [3, 8];
|
|
412
|
+
}
|
|
413
|
+
return [3, 5];
|
|
414
|
+
case 8:
|
|
415
|
+
return [3, 10];
|
|
416
|
+
case 9:
|
|
417
|
+
e_2 = _b.sent();
|
|
418
|
+
if (!(e_2 instanceof DataViewIndexOutOfBoundsError)) {
|
|
419
|
+
throw e_2;
|
|
420
|
+
}
|
|
421
|
+
return [3, 10];
|
|
422
|
+
case 10:
|
|
423
|
+
this.totalPos += this.pos;
|
|
424
|
+
_b.label = 11;
|
|
425
|
+
case 11:
|
|
426
|
+
return [3, 2];
|
|
427
|
+
case 12:
|
|
428
|
+
return [3, 19];
|
|
429
|
+
case 13:
|
|
430
|
+
e_3_1 = _b.sent();
|
|
431
|
+
e_3 = { error: e_3_1 };
|
|
432
|
+
return [3, 19];
|
|
433
|
+
case 14:
|
|
434
|
+
_b.trys.push([14, , 17, 18]);
|
|
435
|
+
if (!(stream_2_1 && !stream_2_1.done && (_a = stream_2.return)))
|
|
436
|
+
return [3, 16];
|
|
437
|
+
return [4, __await(_a.call(stream_2))];
|
|
438
|
+
case 15:
|
|
439
|
+
_b.sent();
|
|
440
|
+
_b.label = 16;
|
|
441
|
+
case 16:
|
|
442
|
+
return [3, 18];
|
|
443
|
+
case 17:
|
|
444
|
+
if (e_3)
|
|
445
|
+
throw e_3.error;
|
|
446
|
+
return [
|
|
447
|
+
7
|
|
448
|
+
/*endfinally*/
|
|
449
|
+
];
|
|
450
|
+
case 18:
|
|
451
|
+
return [
|
|
452
|
+
7
|
|
453
|
+
/*endfinally*/
|
|
454
|
+
];
|
|
455
|
+
case 19:
|
|
456
|
+
return [
|
|
457
|
+
2
|
|
458
|
+
/*return*/
|
|
459
|
+
];
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
};
|
|
464
|
+
Decoder2.prototype.doDecodeSync = function() {
|
|
465
|
+
DECODE:
|
|
466
|
+
while (true) {
|
|
467
|
+
var headByte = this.readHeadByte();
|
|
468
|
+
var object = void 0;
|
|
469
|
+
if (headByte >= 224) {
|
|
470
|
+
object = headByte - 256;
|
|
471
|
+
} else if (headByte < 192) {
|
|
472
|
+
if (headByte < 128) {
|
|
473
|
+
object = headByte;
|
|
474
|
+
} else if (headByte < 144) {
|
|
475
|
+
var size = headByte - 128;
|
|
476
|
+
if (size !== 0) {
|
|
477
|
+
this.pushMapState(size);
|
|
478
|
+
this.complete();
|
|
479
|
+
continue DECODE;
|
|
480
|
+
} else {
|
|
481
|
+
object = {};
|
|
482
|
+
}
|
|
483
|
+
} else if (headByte < 160) {
|
|
484
|
+
var size = headByte - 144;
|
|
485
|
+
if (size !== 0) {
|
|
486
|
+
this.pushArrayState(size);
|
|
487
|
+
this.complete();
|
|
488
|
+
continue DECODE;
|
|
489
|
+
} else {
|
|
490
|
+
object = [];
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
var byteLength = headByte - 160;
|
|
494
|
+
object = this.decodeUtf8String(byteLength, 0);
|
|
495
|
+
}
|
|
496
|
+
} else if (headByte === 192) {
|
|
497
|
+
object = null;
|
|
498
|
+
} else if (headByte === 194) {
|
|
499
|
+
object = false;
|
|
500
|
+
} else if (headByte === 195) {
|
|
501
|
+
object = true;
|
|
502
|
+
} else if (headByte === 202) {
|
|
503
|
+
object = this.readF32();
|
|
504
|
+
} else if (headByte === 203) {
|
|
505
|
+
object = this.readF64();
|
|
506
|
+
} else if (headByte === 204) {
|
|
507
|
+
object = this.readU8();
|
|
508
|
+
} else if (headByte === 205) {
|
|
509
|
+
object = this.readU16();
|
|
510
|
+
} else if (headByte === 206) {
|
|
511
|
+
object = this.readU32();
|
|
512
|
+
} else if (headByte === 207) {
|
|
513
|
+
object = this.readU64();
|
|
514
|
+
} else if (headByte === 208) {
|
|
515
|
+
object = this.readI8();
|
|
516
|
+
} else if (headByte === 209) {
|
|
517
|
+
object = this.readI16();
|
|
518
|
+
} else if (headByte === 210) {
|
|
519
|
+
object = this.readI32();
|
|
520
|
+
} else if (headByte === 211) {
|
|
521
|
+
object = this.readI64();
|
|
522
|
+
} else if (headByte === 217) {
|
|
523
|
+
var byteLength = this.lookU8();
|
|
524
|
+
object = this.decodeUtf8String(byteLength, 1);
|
|
525
|
+
} else if (headByte === 218) {
|
|
526
|
+
var byteLength = this.lookU16();
|
|
527
|
+
object = this.decodeUtf8String(byteLength, 2);
|
|
528
|
+
} else if (headByte === 219) {
|
|
529
|
+
var byteLength = this.lookU32();
|
|
530
|
+
object = this.decodeUtf8String(byteLength, 4);
|
|
531
|
+
} else if (headByte === 220) {
|
|
532
|
+
var size = this.readU16();
|
|
533
|
+
if (size !== 0) {
|
|
534
|
+
this.pushArrayState(size);
|
|
535
|
+
this.complete();
|
|
536
|
+
continue DECODE;
|
|
537
|
+
} else {
|
|
538
|
+
object = [];
|
|
539
|
+
}
|
|
540
|
+
} else if (headByte === 221) {
|
|
541
|
+
var size = this.readU32();
|
|
542
|
+
if (size !== 0) {
|
|
543
|
+
this.pushArrayState(size);
|
|
544
|
+
this.complete();
|
|
545
|
+
continue DECODE;
|
|
546
|
+
} else {
|
|
547
|
+
object = [];
|
|
548
|
+
}
|
|
549
|
+
} else if (headByte === 222) {
|
|
550
|
+
var size = this.readU16();
|
|
551
|
+
if (size !== 0) {
|
|
552
|
+
this.pushMapState(size);
|
|
553
|
+
this.complete();
|
|
554
|
+
continue DECODE;
|
|
555
|
+
} else {
|
|
556
|
+
object = {};
|
|
557
|
+
}
|
|
558
|
+
} else if (headByte === 223) {
|
|
559
|
+
var size = this.readU32();
|
|
560
|
+
if (size !== 0) {
|
|
561
|
+
this.pushMapState(size);
|
|
562
|
+
this.complete();
|
|
563
|
+
continue DECODE;
|
|
564
|
+
} else {
|
|
565
|
+
object = {};
|
|
566
|
+
}
|
|
567
|
+
} else if (headByte === 196) {
|
|
568
|
+
var size = this.lookU8();
|
|
569
|
+
object = this.decodeBinary(size, 1);
|
|
570
|
+
} else if (headByte === 197) {
|
|
571
|
+
var size = this.lookU16();
|
|
572
|
+
object = this.decodeBinary(size, 2);
|
|
573
|
+
} else if (headByte === 198) {
|
|
574
|
+
var size = this.lookU32();
|
|
575
|
+
object = this.decodeBinary(size, 4);
|
|
576
|
+
} else if (headByte === 212) {
|
|
577
|
+
object = this.decodeExtension(1, 0);
|
|
578
|
+
} else if (headByte === 213) {
|
|
579
|
+
object = this.decodeExtension(2, 0);
|
|
580
|
+
} else if (headByte === 214) {
|
|
581
|
+
object = this.decodeExtension(4, 0);
|
|
582
|
+
} else if (headByte === 215) {
|
|
583
|
+
object = this.decodeExtension(8, 0);
|
|
584
|
+
} else if (headByte === 216) {
|
|
585
|
+
object = this.decodeExtension(16, 0);
|
|
586
|
+
} else if (headByte === 199) {
|
|
587
|
+
var size = this.lookU8();
|
|
588
|
+
object = this.decodeExtension(size, 1);
|
|
589
|
+
} else if (headByte === 200) {
|
|
590
|
+
var size = this.lookU16();
|
|
591
|
+
object = this.decodeExtension(size, 2);
|
|
592
|
+
} else if (headByte === 201) {
|
|
593
|
+
var size = this.lookU32();
|
|
594
|
+
object = this.decodeExtension(size, 4);
|
|
595
|
+
} else {
|
|
596
|
+
throw new DecodeError("Unrecognized type byte: ".concat(prettyByte(headByte)));
|
|
597
|
+
}
|
|
598
|
+
this.complete();
|
|
599
|
+
var stack = this.stack;
|
|
600
|
+
while (stack.length > 0) {
|
|
601
|
+
var state = stack[stack.length - 1];
|
|
602
|
+
if (state.type === 0) {
|
|
603
|
+
state.array[state.position] = object;
|
|
604
|
+
state.position++;
|
|
605
|
+
if (state.position === state.size) {
|
|
606
|
+
stack.pop();
|
|
607
|
+
object = state.array;
|
|
608
|
+
} else {
|
|
609
|
+
continue DECODE;
|
|
610
|
+
}
|
|
611
|
+
} else if (state.type === 1) {
|
|
612
|
+
if (!isValidMapKeyType(object)) {
|
|
613
|
+
throw new DecodeError("The type of key must be string or number but " + typeof object);
|
|
614
|
+
}
|
|
615
|
+
if (object === "__proto__") {
|
|
616
|
+
throw new DecodeError("The key __proto__ is not allowed");
|
|
617
|
+
}
|
|
618
|
+
state.key = object;
|
|
619
|
+
state.type = 2;
|
|
620
|
+
continue DECODE;
|
|
621
|
+
} else {
|
|
622
|
+
state.map[state.key] = object;
|
|
623
|
+
state.readCount++;
|
|
624
|
+
if (state.readCount === state.size) {
|
|
625
|
+
stack.pop();
|
|
626
|
+
object = state.map;
|
|
627
|
+
} else {
|
|
628
|
+
state.key = null;
|
|
629
|
+
state.type = 1;
|
|
630
|
+
continue DECODE;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return object;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
Decoder2.prototype.readHeadByte = function() {
|
|
638
|
+
if (this.headByte === HEAD_BYTE_REQUIRED) {
|
|
639
|
+
this.headByte = this.readU8();
|
|
640
|
+
}
|
|
641
|
+
return this.headByte;
|
|
642
|
+
};
|
|
643
|
+
Decoder2.prototype.complete = function() {
|
|
644
|
+
this.headByte = HEAD_BYTE_REQUIRED;
|
|
645
|
+
};
|
|
646
|
+
Decoder2.prototype.readArraySize = function() {
|
|
647
|
+
var headByte = this.readHeadByte();
|
|
648
|
+
switch (headByte) {
|
|
649
|
+
case 220:
|
|
650
|
+
return this.readU16();
|
|
651
|
+
case 221:
|
|
652
|
+
return this.readU32();
|
|
653
|
+
default: {
|
|
654
|
+
if (headByte < 160) {
|
|
655
|
+
return headByte - 144;
|
|
656
|
+
} else {
|
|
657
|
+
throw new DecodeError("Unrecognized array type byte: ".concat(prettyByte(headByte)));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
Decoder2.prototype.pushMapState = function(size) {
|
|
663
|
+
if (size > this.maxMapLength) {
|
|
664
|
+
throw new DecodeError("Max length exceeded: map length (".concat(size, ") > maxMapLengthLength (").concat(this.maxMapLength, ")"));
|
|
665
|
+
}
|
|
666
|
+
this.stack.push({
|
|
667
|
+
type: 1,
|
|
668
|
+
size,
|
|
669
|
+
key: null,
|
|
670
|
+
readCount: 0,
|
|
671
|
+
map: {}
|
|
672
|
+
});
|
|
673
|
+
};
|
|
674
|
+
Decoder2.prototype.pushArrayState = function(size) {
|
|
675
|
+
if (size > this.maxArrayLength) {
|
|
676
|
+
throw new DecodeError("Max length exceeded: array length (".concat(size, ") > maxArrayLength (").concat(this.maxArrayLength, ")"));
|
|
677
|
+
}
|
|
678
|
+
this.stack.push({
|
|
679
|
+
type: 0,
|
|
680
|
+
size,
|
|
681
|
+
array: new Array(size),
|
|
682
|
+
position: 0
|
|
683
|
+
});
|
|
684
|
+
};
|
|
685
|
+
Decoder2.prototype.decodeUtf8String = function(byteLength, headerOffset) {
|
|
686
|
+
var _a;
|
|
687
|
+
if (byteLength > this.maxStrLength) {
|
|
688
|
+
throw new DecodeError("Max length exceeded: UTF-8 byte length (".concat(byteLength, ") > maxStrLength (").concat(this.maxStrLength, ")"));
|
|
689
|
+
}
|
|
690
|
+
if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
|
|
691
|
+
throw MORE_DATA;
|
|
692
|
+
}
|
|
693
|
+
var offset = this.pos + headerOffset;
|
|
694
|
+
var object;
|
|
695
|
+
if (this.stateIsMapKey() && ((_a = this.keyDecoder) === null || _a === void 0 ? void 0 : _a.canBeCached(byteLength))) {
|
|
696
|
+
object = this.keyDecoder.decode(this.bytes, offset, byteLength);
|
|
697
|
+
} else if (byteLength > TEXT_DECODER_THRESHOLD) {
|
|
698
|
+
object = utf8DecodeTD(this.bytes, offset, byteLength);
|
|
699
|
+
} else {
|
|
700
|
+
object = utf8DecodeJs(this.bytes, offset, byteLength);
|
|
701
|
+
}
|
|
702
|
+
this.pos += headerOffset + byteLength;
|
|
703
|
+
return object;
|
|
704
|
+
};
|
|
705
|
+
Decoder2.prototype.stateIsMapKey = function() {
|
|
706
|
+
if (this.stack.length > 0) {
|
|
707
|
+
var state = this.stack[this.stack.length - 1];
|
|
708
|
+
return state.type === 1;
|
|
709
|
+
}
|
|
710
|
+
return false;
|
|
711
|
+
};
|
|
712
|
+
Decoder2.prototype.decodeBinary = function(byteLength, headOffset) {
|
|
713
|
+
if (byteLength > this.maxBinLength) {
|
|
714
|
+
throw new DecodeError("Max length exceeded: bin length (".concat(byteLength, ") > maxBinLength (").concat(this.maxBinLength, ")"));
|
|
715
|
+
}
|
|
716
|
+
if (!this.hasRemaining(byteLength + headOffset)) {
|
|
717
|
+
throw MORE_DATA;
|
|
718
|
+
}
|
|
719
|
+
var offset = this.pos + headOffset;
|
|
720
|
+
var object = this.bytes.subarray(offset, offset + byteLength);
|
|
721
|
+
this.pos += headOffset + byteLength;
|
|
722
|
+
return object;
|
|
723
|
+
};
|
|
724
|
+
Decoder2.prototype.decodeExtension = function(size, headOffset) {
|
|
725
|
+
if (size > this.maxExtLength) {
|
|
726
|
+
throw new DecodeError("Max length exceeded: ext length (".concat(size, ") > maxExtLength (").concat(this.maxExtLength, ")"));
|
|
727
|
+
}
|
|
728
|
+
var extType = this.view.getInt8(this.pos + headOffset);
|
|
729
|
+
var data = this.decodeBinary(
|
|
730
|
+
size,
|
|
731
|
+
headOffset + 1
|
|
732
|
+
/* extType */
|
|
733
|
+
);
|
|
734
|
+
return this.extensionCodec.decode(data, extType, this.context);
|
|
735
|
+
};
|
|
736
|
+
Decoder2.prototype.lookU8 = function() {
|
|
737
|
+
return this.view.getUint8(this.pos);
|
|
738
|
+
};
|
|
739
|
+
Decoder2.prototype.lookU16 = function() {
|
|
740
|
+
return this.view.getUint16(this.pos);
|
|
741
|
+
};
|
|
742
|
+
Decoder2.prototype.lookU32 = function() {
|
|
743
|
+
return this.view.getUint32(this.pos);
|
|
744
|
+
};
|
|
745
|
+
Decoder2.prototype.readU8 = function() {
|
|
746
|
+
var value = this.view.getUint8(this.pos);
|
|
747
|
+
this.pos++;
|
|
748
|
+
return value;
|
|
749
|
+
};
|
|
750
|
+
Decoder2.prototype.readI8 = function() {
|
|
751
|
+
var value = this.view.getInt8(this.pos);
|
|
752
|
+
this.pos++;
|
|
753
|
+
return value;
|
|
754
|
+
};
|
|
755
|
+
Decoder2.prototype.readU16 = function() {
|
|
756
|
+
var value = this.view.getUint16(this.pos);
|
|
757
|
+
this.pos += 2;
|
|
758
|
+
return value;
|
|
759
|
+
};
|
|
760
|
+
Decoder2.prototype.readI16 = function() {
|
|
761
|
+
var value = this.view.getInt16(this.pos);
|
|
762
|
+
this.pos += 2;
|
|
763
|
+
return value;
|
|
764
|
+
};
|
|
765
|
+
Decoder2.prototype.readU32 = function() {
|
|
766
|
+
var value = this.view.getUint32(this.pos);
|
|
767
|
+
this.pos += 4;
|
|
768
|
+
return value;
|
|
769
|
+
};
|
|
770
|
+
Decoder2.prototype.readI32 = function() {
|
|
771
|
+
var value = this.view.getInt32(this.pos);
|
|
772
|
+
this.pos += 4;
|
|
773
|
+
return value;
|
|
774
|
+
};
|
|
775
|
+
Decoder2.prototype.readU64 = function() {
|
|
776
|
+
var value = getUint64(this.view, this.pos);
|
|
777
|
+
this.pos += 8;
|
|
778
|
+
return value;
|
|
779
|
+
};
|
|
780
|
+
Decoder2.prototype.readI64 = function() {
|
|
781
|
+
var value = getInt64(this.view, this.pos);
|
|
782
|
+
this.pos += 8;
|
|
783
|
+
return value;
|
|
784
|
+
};
|
|
785
|
+
Decoder2.prototype.readF32 = function() {
|
|
786
|
+
var value = this.view.getFloat32(this.pos);
|
|
787
|
+
this.pos += 4;
|
|
788
|
+
return value;
|
|
789
|
+
};
|
|
790
|
+
Decoder2.prototype.readF64 = function() {
|
|
791
|
+
var value = this.view.getFloat64(this.pos);
|
|
792
|
+
this.pos += 8;
|
|
793
|
+
return value;
|
|
794
|
+
};
|
|
795
|
+
return Decoder2;
|
|
796
|
+
}();
|
|
797
|
+
export {
|
|
798
|
+
DataViewIndexOutOfBoundsError,
|
|
799
|
+
Decoder
|
|
800
|
+
};
|
|
801
|
+
//# sourceMappingURL=Decoder.js.map
|