@fortemi/core 2026.9.3 → 2026.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/dist/aiwg-index-schema.js +1827 -0
- package/dist/aiwg-index-schema.js.map +1 -1
- package/dist/{aiwg-index-shard-BCdaz0X1.d.ts → aiwg-index-shard-jyT_f8H6.d.ts} +4 -4
- package/dist/aiwg-index-shard.d.ts +1 -1
- package/dist/aiwg-index-shard.js +2193 -23
- package/dist/aiwg-index-shard.js.map +1 -1
- package/dist/index.d.ts +985 -22
- package/dist/index.js +35069 -28090
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/aiwg-index-shard.js
CHANGED
|
@@ -5,7 +5,1824 @@ import { blake3 } from '@noble/hashes/blake3';
|
|
|
5
5
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
6
6
|
import { v5 } from 'uuid';
|
|
7
7
|
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __esm = (fn, res) => function __init() {
|
|
15
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key2 of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
24
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
|
|
38
|
+
var require_base64_js = __commonJS({
|
|
39
|
+
"../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports$1) {
|
|
40
|
+
init_geometry_buffer();
|
|
41
|
+
exports$1.byteLength = byteLength;
|
|
42
|
+
exports$1.toByteArray = toByteArray;
|
|
43
|
+
exports$1.fromByteArray = fromByteArray;
|
|
44
|
+
var lookup = [];
|
|
45
|
+
var revLookup = [];
|
|
46
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
47
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
48
|
+
for (i = 0, len = code.length; i < len; ++i) {
|
|
49
|
+
lookup[i] = code[i];
|
|
50
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
51
|
+
}
|
|
52
|
+
var i;
|
|
53
|
+
var len;
|
|
54
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
55
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
56
|
+
function getLens(b64) {
|
|
57
|
+
var len2 = b64.length;
|
|
58
|
+
if (len2 % 4 > 0) {
|
|
59
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
60
|
+
}
|
|
61
|
+
var validLen = b64.indexOf("=");
|
|
62
|
+
if (validLen === -1) validLen = len2;
|
|
63
|
+
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
|
|
64
|
+
return [validLen, placeHoldersLen];
|
|
65
|
+
}
|
|
66
|
+
function byteLength(b64) {
|
|
67
|
+
var lens = getLens(b64);
|
|
68
|
+
var validLen = lens[0];
|
|
69
|
+
var placeHoldersLen = lens[1];
|
|
70
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
71
|
+
}
|
|
72
|
+
function _byteLength(b64, validLen, placeHoldersLen) {
|
|
73
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
74
|
+
}
|
|
75
|
+
function toByteArray(b64) {
|
|
76
|
+
var tmp;
|
|
77
|
+
var lens = getLens(b64);
|
|
78
|
+
var validLen = lens[0];
|
|
79
|
+
var placeHoldersLen = lens[1];
|
|
80
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
81
|
+
var curByte = 0;
|
|
82
|
+
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
83
|
+
var i2;
|
|
84
|
+
for (i2 = 0; i2 < len2; i2 += 4) {
|
|
85
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
|
|
86
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
87
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
88
|
+
arr[curByte++] = tmp & 255;
|
|
89
|
+
}
|
|
90
|
+
if (placeHoldersLen === 2) {
|
|
91
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
|
|
92
|
+
arr[curByte++] = tmp & 255;
|
|
93
|
+
}
|
|
94
|
+
if (placeHoldersLen === 1) {
|
|
95
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
|
|
96
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
97
|
+
arr[curByte++] = tmp & 255;
|
|
98
|
+
}
|
|
99
|
+
return arr;
|
|
100
|
+
}
|
|
101
|
+
function tripletToBase64(num) {
|
|
102
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
103
|
+
}
|
|
104
|
+
function encodeChunk(uint8, start, end) {
|
|
105
|
+
var tmp;
|
|
106
|
+
var output = [];
|
|
107
|
+
for (var i2 = start; i2 < end; i2 += 3) {
|
|
108
|
+
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
109
|
+
output.push(tripletToBase64(tmp));
|
|
110
|
+
}
|
|
111
|
+
return output.join("");
|
|
112
|
+
}
|
|
113
|
+
function fromByteArray(uint8) {
|
|
114
|
+
var tmp;
|
|
115
|
+
var len2 = uint8.length;
|
|
116
|
+
var extraBytes = len2 % 3;
|
|
117
|
+
var parts = [];
|
|
118
|
+
var maxChunkLength = 16383;
|
|
119
|
+
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
|
|
120
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
121
|
+
}
|
|
122
|
+
if (extraBytes === 1) {
|
|
123
|
+
tmp = uint8[len2 - 1];
|
|
124
|
+
parts.push(
|
|
125
|
+
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
|
126
|
+
);
|
|
127
|
+
} else if (extraBytes === 2) {
|
|
128
|
+
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
129
|
+
parts.push(
|
|
130
|
+
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return parts.join("");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
|
|
139
|
+
var require_ieee754 = __commonJS({
|
|
140
|
+
"../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js"(exports$1) {
|
|
141
|
+
init_geometry_buffer();
|
|
142
|
+
exports$1.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
143
|
+
var e, m;
|
|
144
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
145
|
+
var eMax = (1 << eLen) - 1;
|
|
146
|
+
var eBias = eMax >> 1;
|
|
147
|
+
var nBits = -7;
|
|
148
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
149
|
+
var d = isLE ? -1 : 1;
|
|
150
|
+
var s = buffer[offset + i];
|
|
151
|
+
i += d;
|
|
152
|
+
e = s & (1 << -nBits) - 1;
|
|
153
|
+
s >>= -nBits;
|
|
154
|
+
nBits += eLen;
|
|
155
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
156
|
+
}
|
|
157
|
+
m = e & (1 << -nBits) - 1;
|
|
158
|
+
e >>= -nBits;
|
|
159
|
+
nBits += mLen;
|
|
160
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
161
|
+
}
|
|
162
|
+
if (e === 0) {
|
|
163
|
+
e = 1 - eBias;
|
|
164
|
+
} else if (e === eMax) {
|
|
165
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
166
|
+
} else {
|
|
167
|
+
m = m + Math.pow(2, mLen);
|
|
168
|
+
e = e - eBias;
|
|
169
|
+
}
|
|
170
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
171
|
+
};
|
|
172
|
+
exports$1.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
173
|
+
var e, m, c;
|
|
174
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
175
|
+
var eMax = (1 << eLen) - 1;
|
|
176
|
+
var eBias = eMax >> 1;
|
|
177
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
178
|
+
var i = isLE ? 0 : nBytes - 1;
|
|
179
|
+
var d = isLE ? 1 : -1;
|
|
180
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
181
|
+
value = Math.abs(value);
|
|
182
|
+
if (isNaN(value) || value === Infinity) {
|
|
183
|
+
m = isNaN(value) ? 1 : 0;
|
|
184
|
+
e = eMax;
|
|
185
|
+
} else {
|
|
186
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
187
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
188
|
+
e--;
|
|
189
|
+
c *= 2;
|
|
190
|
+
}
|
|
191
|
+
if (e + eBias >= 1) {
|
|
192
|
+
value += rt / c;
|
|
193
|
+
} else {
|
|
194
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
195
|
+
}
|
|
196
|
+
if (value * c >= 2) {
|
|
197
|
+
e++;
|
|
198
|
+
c /= 2;
|
|
199
|
+
}
|
|
200
|
+
if (e + eBias >= eMax) {
|
|
201
|
+
m = 0;
|
|
202
|
+
e = eMax;
|
|
203
|
+
} else if (e + eBias >= 1) {
|
|
204
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
205
|
+
e = e + eBias;
|
|
206
|
+
} else {
|
|
207
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
208
|
+
e = 0;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
212
|
+
}
|
|
213
|
+
e = e << mLen | m;
|
|
214
|
+
eLen += mLen;
|
|
215
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
216
|
+
}
|
|
217
|
+
buffer[offset + i - d] |= s * 128;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// ../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
|
|
223
|
+
var require_buffer = __commonJS({
|
|
224
|
+
"../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js"(exports$1) {
|
|
225
|
+
init_geometry_buffer();
|
|
226
|
+
var base64 = require_base64_js();
|
|
227
|
+
var ieee754 = require_ieee754();
|
|
228
|
+
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
229
|
+
exports$1.Buffer = Buffer3;
|
|
230
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
231
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
232
|
+
var K_MAX_LENGTH = 2147483647;
|
|
233
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
234
|
+
Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
235
|
+
if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
236
|
+
console.error(
|
|
237
|
+
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
function typedArraySupport() {
|
|
241
|
+
try {
|
|
242
|
+
const arr = new Uint8Array(1);
|
|
243
|
+
const proto = { foo: function() {
|
|
244
|
+
return 42;
|
|
245
|
+
} };
|
|
246
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
247
|
+
Object.setPrototypeOf(arr, proto);
|
|
248
|
+
return arr.foo() === 42;
|
|
249
|
+
} catch (e) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
Object.defineProperty(Buffer3.prototype, "parent", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: function() {
|
|
256
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
257
|
+
return this.buffer;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
Object.defineProperty(Buffer3.prototype, "offset", {
|
|
261
|
+
enumerable: true,
|
|
262
|
+
get: function() {
|
|
263
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
264
|
+
return this.byteOffset;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
function createBuffer(length) {
|
|
268
|
+
if (length > K_MAX_LENGTH) {
|
|
269
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
|
270
|
+
}
|
|
271
|
+
const buf = new Uint8Array(length);
|
|
272
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
273
|
+
return buf;
|
|
274
|
+
}
|
|
275
|
+
function Buffer3(arg, encodingOrOffset, length) {
|
|
276
|
+
if (typeof arg === "number") {
|
|
277
|
+
if (typeof encodingOrOffset === "string") {
|
|
278
|
+
throw new TypeError(
|
|
279
|
+
'The "string" argument must be of type string. Received type number'
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
return allocUnsafe(arg);
|
|
283
|
+
}
|
|
284
|
+
return from(arg, encodingOrOffset, length);
|
|
285
|
+
}
|
|
286
|
+
Buffer3.poolSize = 8192;
|
|
287
|
+
function from(value, encodingOrOffset, length) {
|
|
288
|
+
if (typeof value === "string") {
|
|
289
|
+
return fromString(value, encodingOrOffset);
|
|
290
|
+
}
|
|
291
|
+
if (ArrayBuffer.isView(value)) {
|
|
292
|
+
return fromArrayView(value);
|
|
293
|
+
}
|
|
294
|
+
if (value == null) {
|
|
295
|
+
throw new TypeError(
|
|
296
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
|
|
300
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
301
|
+
}
|
|
302
|
+
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
|
|
303
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
304
|
+
}
|
|
305
|
+
if (typeof value === "number") {
|
|
306
|
+
throw new TypeError(
|
|
307
|
+
'The "value" argument must not be of type number. Received type number'
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
311
|
+
if (valueOf != null && valueOf !== value) {
|
|
312
|
+
return Buffer3.from(valueOf, encodingOrOffset, length);
|
|
313
|
+
}
|
|
314
|
+
const b = fromObject(value);
|
|
315
|
+
if (b) return b;
|
|
316
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
317
|
+
return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
318
|
+
}
|
|
319
|
+
throw new TypeError(
|
|
320
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
Buffer3.from = function(value, encodingOrOffset, length) {
|
|
324
|
+
return from(value, encodingOrOffset, length);
|
|
325
|
+
};
|
|
326
|
+
Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
|
|
327
|
+
Object.setPrototypeOf(Buffer3, Uint8Array);
|
|
328
|
+
function assertSize(size) {
|
|
329
|
+
if (typeof size !== "number") {
|
|
330
|
+
throw new TypeError('"size" argument must be of type number');
|
|
331
|
+
} else if (size < 0) {
|
|
332
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function alloc(size, fill, encoding) {
|
|
336
|
+
assertSize(size);
|
|
337
|
+
if (size <= 0) {
|
|
338
|
+
return createBuffer(size);
|
|
339
|
+
}
|
|
340
|
+
if (fill !== void 0) {
|
|
341
|
+
return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
|
|
342
|
+
}
|
|
343
|
+
return createBuffer(size);
|
|
344
|
+
}
|
|
345
|
+
Buffer3.alloc = function(size, fill, encoding) {
|
|
346
|
+
return alloc(size, fill, encoding);
|
|
347
|
+
};
|
|
348
|
+
function allocUnsafe(size) {
|
|
349
|
+
assertSize(size);
|
|
350
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
|
351
|
+
}
|
|
352
|
+
Buffer3.allocUnsafe = function(size) {
|
|
353
|
+
return allocUnsafe(size);
|
|
354
|
+
};
|
|
355
|
+
Buffer3.allocUnsafeSlow = function(size) {
|
|
356
|
+
return allocUnsafe(size);
|
|
357
|
+
};
|
|
358
|
+
function fromString(string, encoding) {
|
|
359
|
+
if (typeof encoding !== "string" || encoding === "") {
|
|
360
|
+
encoding = "utf8";
|
|
361
|
+
}
|
|
362
|
+
if (!Buffer3.isEncoding(encoding)) {
|
|
363
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
364
|
+
}
|
|
365
|
+
const length = byteLength(string, encoding) | 0;
|
|
366
|
+
let buf = createBuffer(length);
|
|
367
|
+
const actual = buf.write(string, encoding);
|
|
368
|
+
if (actual !== length) {
|
|
369
|
+
buf = buf.slice(0, actual);
|
|
370
|
+
}
|
|
371
|
+
return buf;
|
|
372
|
+
}
|
|
373
|
+
function fromArrayLike(array) {
|
|
374
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
375
|
+
const buf = createBuffer(length);
|
|
376
|
+
for (let i = 0; i < length; i += 1) {
|
|
377
|
+
buf[i] = array[i] & 255;
|
|
378
|
+
}
|
|
379
|
+
return buf;
|
|
380
|
+
}
|
|
381
|
+
function fromArrayView(arrayView) {
|
|
382
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
383
|
+
const copy = new Uint8Array(arrayView);
|
|
384
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
|
385
|
+
}
|
|
386
|
+
return fromArrayLike(arrayView);
|
|
387
|
+
}
|
|
388
|
+
function fromArrayBuffer(array, byteOffset, length) {
|
|
389
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
390
|
+
throw new RangeError('"offset" is outside of buffer bounds');
|
|
391
|
+
}
|
|
392
|
+
if (array.byteLength < byteOffset + (length || 0)) {
|
|
393
|
+
throw new RangeError('"length" is outside of buffer bounds');
|
|
394
|
+
}
|
|
395
|
+
let buf;
|
|
396
|
+
if (byteOffset === void 0 && length === void 0) {
|
|
397
|
+
buf = new Uint8Array(array);
|
|
398
|
+
} else if (length === void 0) {
|
|
399
|
+
buf = new Uint8Array(array, byteOffset);
|
|
400
|
+
} else {
|
|
401
|
+
buf = new Uint8Array(array, byteOffset, length);
|
|
402
|
+
}
|
|
403
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
404
|
+
return buf;
|
|
405
|
+
}
|
|
406
|
+
function fromObject(obj) {
|
|
407
|
+
if (Buffer3.isBuffer(obj)) {
|
|
408
|
+
const len = checked(obj.length) | 0;
|
|
409
|
+
const buf = createBuffer(len);
|
|
410
|
+
if (buf.length === 0) {
|
|
411
|
+
return buf;
|
|
412
|
+
}
|
|
413
|
+
obj.copy(buf, 0, 0, len);
|
|
414
|
+
return buf;
|
|
415
|
+
}
|
|
416
|
+
if (obj.length !== void 0) {
|
|
417
|
+
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
|
418
|
+
return createBuffer(0);
|
|
419
|
+
}
|
|
420
|
+
return fromArrayLike(obj);
|
|
421
|
+
}
|
|
422
|
+
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
423
|
+
return fromArrayLike(obj.data);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function checked(length) {
|
|
427
|
+
if (length >= K_MAX_LENGTH) {
|
|
428
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
|
429
|
+
}
|
|
430
|
+
return length | 0;
|
|
431
|
+
}
|
|
432
|
+
function SlowBuffer(length) {
|
|
433
|
+
if (+length != length) {
|
|
434
|
+
length = 0;
|
|
435
|
+
}
|
|
436
|
+
return Buffer3.alloc(+length);
|
|
437
|
+
}
|
|
438
|
+
Buffer3.isBuffer = function isBuffer(b) {
|
|
439
|
+
return b != null && b._isBuffer === true && b !== Buffer3.prototype;
|
|
440
|
+
};
|
|
441
|
+
Buffer3.compare = function compare(a, b) {
|
|
442
|
+
if (isInstance(a, Uint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
|
|
443
|
+
if (isInstance(b, Uint8Array)) b = Buffer3.from(b, b.offset, b.byteLength);
|
|
444
|
+
if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
|
|
445
|
+
throw new TypeError(
|
|
446
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
if (a === b) return 0;
|
|
450
|
+
let x = a.length;
|
|
451
|
+
let y = b.length;
|
|
452
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
453
|
+
if (a[i] !== b[i]) {
|
|
454
|
+
x = a[i];
|
|
455
|
+
y = b[i];
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (x < y) return -1;
|
|
460
|
+
if (y < x) return 1;
|
|
461
|
+
return 0;
|
|
462
|
+
};
|
|
463
|
+
Buffer3.isEncoding = function isEncoding(encoding) {
|
|
464
|
+
switch (String(encoding).toLowerCase()) {
|
|
465
|
+
case "hex":
|
|
466
|
+
case "utf8":
|
|
467
|
+
case "utf-8":
|
|
468
|
+
case "ascii":
|
|
469
|
+
case "latin1":
|
|
470
|
+
case "binary":
|
|
471
|
+
case "base64":
|
|
472
|
+
case "ucs2":
|
|
473
|
+
case "ucs-2":
|
|
474
|
+
case "utf16le":
|
|
475
|
+
case "utf-16le":
|
|
476
|
+
return true;
|
|
477
|
+
default:
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
Buffer3.concat = function concat(list, length) {
|
|
482
|
+
if (!Array.isArray(list)) {
|
|
483
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
484
|
+
}
|
|
485
|
+
if (list.length === 0) {
|
|
486
|
+
return Buffer3.alloc(0);
|
|
487
|
+
}
|
|
488
|
+
let i;
|
|
489
|
+
if (length === void 0) {
|
|
490
|
+
length = 0;
|
|
491
|
+
for (i = 0; i < list.length; ++i) {
|
|
492
|
+
length += list[i].length;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const buffer = Buffer3.allocUnsafe(length);
|
|
496
|
+
let pos = 0;
|
|
497
|
+
for (i = 0; i < list.length; ++i) {
|
|
498
|
+
let buf = list[i];
|
|
499
|
+
if (isInstance(buf, Uint8Array)) {
|
|
500
|
+
if (pos + buf.length > buffer.length) {
|
|
501
|
+
if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
|
|
502
|
+
buf.copy(buffer, pos);
|
|
503
|
+
} else {
|
|
504
|
+
Uint8Array.prototype.set.call(
|
|
505
|
+
buffer,
|
|
506
|
+
buf,
|
|
507
|
+
pos
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
} else if (!Buffer3.isBuffer(buf)) {
|
|
511
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
512
|
+
} else {
|
|
513
|
+
buf.copy(buffer, pos);
|
|
514
|
+
}
|
|
515
|
+
pos += buf.length;
|
|
516
|
+
}
|
|
517
|
+
return buffer;
|
|
518
|
+
};
|
|
519
|
+
function byteLength(string, encoding) {
|
|
520
|
+
if (Buffer3.isBuffer(string)) {
|
|
521
|
+
return string.length;
|
|
522
|
+
}
|
|
523
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
524
|
+
return string.byteLength;
|
|
525
|
+
}
|
|
526
|
+
if (typeof string !== "string") {
|
|
527
|
+
throw new TypeError(
|
|
528
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
const len = string.length;
|
|
532
|
+
const mustMatch = arguments.length > 2 && arguments[2] === true;
|
|
533
|
+
if (!mustMatch && len === 0) return 0;
|
|
534
|
+
let loweredCase = false;
|
|
535
|
+
for (; ; ) {
|
|
536
|
+
switch (encoding) {
|
|
537
|
+
case "ascii":
|
|
538
|
+
case "latin1":
|
|
539
|
+
case "binary":
|
|
540
|
+
return len;
|
|
541
|
+
case "utf8":
|
|
542
|
+
case "utf-8":
|
|
543
|
+
return utf8ToBytes(string).length;
|
|
544
|
+
case "ucs2":
|
|
545
|
+
case "ucs-2":
|
|
546
|
+
case "utf16le":
|
|
547
|
+
case "utf-16le":
|
|
548
|
+
return len * 2;
|
|
549
|
+
case "hex":
|
|
550
|
+
return len >>> 1;
|
|
551
|
+
case "base64":
|
|
552
|
+
return base64ToBytes(string).length;
|
|
553
|
+
default:
|
|
554
|
+
if (loweredCase) {
|
|
555
|
+
return mustMatch ? -1 : utf8ToBytes(string).length;
|
|
556
|
+
}
|
|
557
|
+
encoding = ("" + encoding).toLowerCase();
|
|
558
|
+
loweredCase = true;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
Buffer3.byteLength = byteLength;
|
|
563
|
+
function slowToString(encoding, start, end) {
|
|
564
|
+
let loweredCase = false;
|
|
565
|
+
if (start === void 0 || start < 0) {
|
|
566
|
+
start = 0;
|
|
567
|
+
}
|
|
568
|
+
if (start > this.length) {
|
|
569
|
+
return "";
|
|
570
|
+
}
|
|
571
|
+
if (end === void 0 || end > this.length) {
|
|
572
|
+
end = this.length;
|
|
573
|
+
}
|
|
574
|
+
if (end <= 0) {
|
|
575
|
+
return "";
|
|
576
|
+
}
|
|
577
|
+
end >>>= 0;
|
|
578
|
+
start >>>= 0;
|
|
579
|
+
if (end <= start) {
|
|
580
|
+
return "";
|
|
581
|
+
}
|
|
582
|
+
if (!encoding) encoding = "utf8";
|
|
583
|
+
while (true) {
|
|
584
|
+
switch (encoding) {
|
|
585
|
+
case "hex":
|
|
586
|
+
return hexSlice(this, start, end);
|
|
587
|
+
case "utf8":
|
|
588
|
+
case "utf-8":
|
|
589
|
+
return utf8Slice(this, start, end);
|
|
590
|
+
case "ascii":
|
|
591
|
+
return asciiSlice(this, start, end);
|
|
592
|
+
case "latin1":
|
|
593
|
+
case "binary":
|
|
594
|
+
return latin1Slice(this, start, end);
|
|
595
|
+
case "base64":
|
|
596
|
+
return base64Slice(this, start, end);
|
|
597
|
+
case "ucs2":
|
|
598
|
+
case "ucs-2":
|
|
599
|
+
case "utf16le":
|
|
600
|
+
case "utf-16le":
|
|
601
|
+
return utf16leSlice(this, start, end);
|
|
602
|
+
default:
|
|
603
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
604
|
+
encoding = (encoding + "").toLowerCase();
|
|
605
|
+
loweredCase = true;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
Buffer3.prototype._isBuffer = true;
|
|
610
|
+
function swap(b, n, m) {
|
|
611
|
+
const i = b[n];
|
|
612
|
+
b[n] = b[m];
|
|
613
|
+
b[m] = i;
|
|
614
|
+
}
|
|
615
|
+
Buffer3.prototype.swap16 = function swap16() {
|
|
616
|
+
const len = this.length;
|
|
617
|
+
if (len % 2 !== 0) {
|
|
618
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
619
|
+
}
|
|
620
|
+
for (let i = 0; i < len; i += 2) {
|
|
621
|
+
swap(this, i, i + 1);
|
|
622
|
+
}
|
|
623
|
+
return this;
|
|
624
|
+
};
|
|
625
|
+
Buffer3.prototype.swap32 = function swap32() {
|
|
626
|
+
const len = this.length;
|
|
627
|
+
if (len % 4 !== 0) {
|
|
628
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
629
|
+
}
|
|
630
|
+
for (let i = 0; i < len; i += 4) {
|
|
631
|
+
swap(this, i, i + 3);
|
|
632
|
+
swap(this, i + 1, i + 2);
|
|
633
|
+
}
|
|
634
|
+
return this;
|
|
635
|
+
};
|
|
636
|
+
Buffer3.prototype.swap64 = function swap64() {
|
|
637
|
+
const len = this.length;
|
|
638
|
+
if (len % 8 !== 0) {
|
|
639
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
640
|
+
}
|
|
641
|
+
for (let i = 0; i < len; i += 8) {
|
|
642
|
+
swap(this, i, i + 7);
|
|
643
|
+
swap(this, i + 1, i + 6);
|
|
644
|
+
swap(this, i + 2, i + 5);
|
|
645
|
+
swap(this, i + 3, i + 4);
|
|
646
|
+
}
|
|
647
|
+
return this;
|
|
648
|
+
};
|
|
649
|
+
Buffer3.prototype.toString = function toString() {
|
|
650
|
+
const length = this.length;
|
|
651
|
+
if (length === 0) return "";
|
|
652
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
653
|
+
return slowToString.apply(this, arguments);
|
|
654
|
+
};
|
|
655
|
+
Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
|
|
656
|
+
Buffer3.prototype.equals = function equals(b) {
|
|
657
|
+
if (!Buffer3.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
658
|
+
if (this === b) return true;
|
|
659
|
+
return Buffer3.compare(this, b) === 0;
|
|
660
|
+
};
|
|
661
|
+
Buffer3.prototype.inspect = function inspect() {
|
|
662
|
+
let str = "";
|
|
663
|
+
const max = exports$1.INSPECT_MAX_BYTES;
|
|
664
|
+
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
665
|
+
if (this.length > max) str += " ... ";
|
|
666
|
+
return "<Buffer " + str + ">";
|
|
667
|
+
};
|
|
668
|
+
if (customInspectSymbol) {
|
|
669
|
+
Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
|
|
670
|
+
}
|
|
671
|
+
Buffer3.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
672
|
+
if (isInstance(target, Uint8Array)) {
|
|
673
|
+
target = Buffer3.from(target, target.offset, target.byteLength);
|
|
674
|
+
}
|
|
675
|
+
if (!Buffer3.isBuffer(target)) {
|
|
676
|
+
throw new TypeError(
|
|
677
|
+
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
if (start === void 0) {
|
|
681
|
+
start = 0;
|
|
682
|
+
}
|
|
683
|
+
if (end === void 0) {
|
|
684
|
+
end = target ? target.length : 0;
|
|
685
|
+
}
|
|
686
|
+
if (thisStart === void 0) {
|
|
687
|
+
thisStart = 0;
|
|
688
|
+
}
|
|
689
|
+
if (thisEnd === void 0) {
|
|
690
|
+
thisEnd = this.length;
|
|
691
|
+
}
|
|
692
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
693
|
+
throw new RangeError("out of range index");
|
|
694
|
+
}
|
|
695
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
696
|
+
return 0;
|
|
697
|
+
}
|
|
698
|
+
if (thisStart >= thisEnd) {
|
|
699
|
+
return -1;
|
|
700
|
+
}
|
|
701
|
+
if (start >= end) {
|
|
702
|
+
return 1;
|
|
703
|
+
}
|
|
704
|
+
start >>>= 0;
|
|
705
|
+
end >>>= 0;
|
|
706
|
+
thisStart >>>= 0;
|
|
707
|
+
thisEnd >>>= 0;
|
|
708
|
+
if (this === target) return 0;
|
|
709
|
+
let x = thisEnd - thisStart;
|
|
710
|
+
let y = end - start;
|
|
711
|
+
const len = Math.min(x, y);
|
|
712
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
713
|
+
const targetCopy = target.slice(start, end);
|
|
714
|
+
for (let i = 0; i < len; ++i) {
|
|
715
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
716
|
+
x = thisCopy[i];
|
|
717
|
+
y = targetCopy[i];
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (x < y) return -1;
|
|
722
|
+
if (y < x) return 1;
|
|
723
|
+
return 0;
|
|
724
|
+
};
|
|
725
|
+
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
726
|
+
if (buffer.length === 0) return -1;
|
|
727
|
+
if (typeof byteOffset === "string") {
|
|
728
|
+
encoding = byteOffset;
|
|
729
|
+
byteOffset = 0;
|
|
730
|
+
} else if (byteOffset > 2147483647) {
|
|
731
|
+
byteOffset = 2147483647;
|
|
732
|
+
} else if (byteOffset < -2147483648) {
|
|
733
|
+
byteOffset = -2147483648;
|
|
734
|
+
}
|
|
735
|
+
byteOffset = +byteOffset;
|
|
736
|
+
if (numberIsNaN(byteOffset)) {
|
|
737
|
+
byteOffset = dir ? 0 : buffer.length - 1;
|
|
738
|
+
}
|
|
739
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
740
|
+
if (byteOffset >= buffer.length) {
|
|
741
|
+
if (dir) return -1;
|
|
742
|
+
else byteOffset = buffer.length - 1;
|
|
743
|
+
} else if (byteOffset < 0) {
|
|
744
|
+
if (dir) byteOffset = 0;
|
|
745
|
+
else return -1;
|
|
746
|
+
}
|
|
747
|
+
if (typeof val === "string") {
|
|
748
|
+
val = Buffer3.from(val, encoding);
|
|
749
|
+
}
|
|
750
|
+
if (Buffer3.isBuffer(val)) {
|
|
751
|
+
if (val.length === 0) {
|
|
752
|
+
return -1;
|
|
753
|
+
}
|
|
754
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
755
|
+
} else if (typeof val === "number") {
|
|
756
|
+
val = val & 255;
|
|
757
|
+
if (typeof Uint8Array.prototype.indexOf === "function") {
|
|
758
|
+
if (dir) {
|
|
759
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
760
|
+
} else {
|
|
761
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
765
|
+
}
|
|
766
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
767
|
+
}
|
|
768
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
769
|
+
let indexSize = 1;
|
|
770
|
+
let arrLength = arr.length;
|
|
771
|
+
let valLength = val.length;
|
|
772
|
+
if (encoding !== void 0) {
|
|
773
|
+
encoding = String(encoding).toLowerCase();
|
|
774
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
775
|
+
if (arr.length < 2 || val.length < 2) {
|
|
776
|
+
return -1;
|
|
777
|
+
}
|
|
778
|
+
indexSize = 2;
|
|
779
|
+
arrLength /= 2;
|
|
780
|
+
valLength /= 2;
|
|
781
|
+
byteOffset /= 2;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
function read(buf, i2) {
|
|
785
|
+
if (indexSize === 1) {
|
|
786
|
+
return buf[i2];
|
|
787
|
+
} else {
|
|
788
|
+
return buf.readUInt16BE(i2 * indexSize);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
let i;
|
|
792
|
+
if (dir) {
|
|
793
|
+
let foundIndex = -1;
|
|
794
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
795
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
796
|
+
if (foundIndex === -1) foundIndex = i;
|
|
797
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
798
|
+
} else {
|
|
799
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
800
|
+
foundIndex = -1;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
} else {
|
|
804
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
805
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
806
|
+
let found = true;
|
|
807
|
+
for (let j = 0; j < valLength; j++) {
|
|
808
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
809
|
+
found = false;
|
|
810
|
+
break;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (found) return i;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return -1;
|
|
817
|
+
}
|
|
818
|
+
Buffer3.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
819
|
+
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
820
|
+
};
|
|
821
|
+
Buffer3.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
822
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
823
|
+
};
|
|
824
|
+
Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
825
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
826
|
+
};
|
|
827
|
+
function hexWrite(buf, string, offset, length) {
|
|
828
|
+
offset = Number(offset) || 0;
|
|
829
|
+
const remaining = buf.length - offset;
|
|
830
|
+
if (!length) {
|
|
831
|
+
length = remaining;
|
|
832
|
+
} else {
|
|
833
|
+
length = Number(length);
|
|
834
|
+
if (length > remaining) {
|
|
835
|
+
length = remaining;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
const strLen = string.length;
|
|
839
|
+
if (length > strLen / 2) {
|
|
840
|
+
length = strLen / 2;
|
|
841
|
+
}
|
|
842
|
+
let i;
|
|
843
|
+
for (i = 0; i < length; ++i) {
|
|
844
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
845
|
+
if (numberIsNaN(parsed)) return i;
|
|
846
|
+
buf[offset + i] = parsed;
|
|
847
|
+
}
|
|
848
|
+
return i;
|
|
849
|
+
}
|
|
850
|
+
function utf8Write(buf, string, offset, length) {
|
|
851
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
852
|
+
}
|
|
853
|
+
function asciiWrite(buf, string, offset, length) {
|
|
854
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
855
|
+
}
|
|
856
|
+
function base64Write(buf, string, offset, length) {
|
|
857
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
858
|
+
}
|
|
859
|
+
function ucs2Write(buf, string, offset, length) {
|
|
860
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
861
|
+
}
|
|
862
|
+
Buffer3.prototype.write = function write(string, offset, length, encoding) {
|
|
863
|
+
if (offset === void 0) {
|
|
864
|
+
encoding = "utf8";
|
|
865
|
+
length = this.length;
|
|
866
|
+
offset = 0;
|
|
867
|
+
} else if (length === void 0 && typeof offset === "string") {
|
|
868
|
+
encoding = offset;
|
|
869
|
+
length = this.length;
|
|
870
|
+
offset = 0;
|
|
871
|
+
} else if (isFinite(offset)) {
|
|
872
|
+
offset = offset >>> 0;
|
|
873
|
+
if (isFinite(length)) {
|
|
874
|
+
length = length >>> 0;
|
|
875
|
+
if (encoding === void 0) encoding = "utf8";
|
|
876
|
+
} else {
|
|
877
|
+
encoding = length;
|
|
878
|
+
length = void 0;
|
|
879
|
+
}
|
|
880
|
+
} else {
|
|
881
|
+
throw new Error(
|
|
882
|
+
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
const remaining = this.length - offset;
|
|
886
|
+
if (length === void 0 || length > remaining) length = remaining;
|
|
887
|
+
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
|
888
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
889
|
+
}
|
|
890
|
+
if (!encoding) encoding = "utf8";
|
|
891
|
+
let loweredCase = false;
|
|
892
|
+
for (; ; ) {
|
|
893
|
+
switch (encoding) {
|
|
894
|
+
case "hex":
|
|
895
|
+
return hexWrite(this, string, offset, length);
|
|
896
|
+
case "utf8":
|
|
897
|
+
case "utf-8":
|
|
898
|
+
return utf8Write(this, string, offset, length);
|
|
899
|
+
case "ascii":
|
|
900
|
+
case "latin1":
|
|
901
|
+
case "binary":
|
|
902
|
+
return asciiWrite(this, string, offset, length);
|
|
903
|
+
case "base64":
|
|
904
|
+
return base64Write(this, string, offset, length);
|
|
905
|
+
case "ucs2":
|
|
906
|
+
case "ucs-2":
|
|
907
|
+
case "utf16le":
|
|
908
|
+
case "utf-16le":
|
|
909
|
+
return ucs2Write(this, string, offset, length);
|
|
910
|
+
default:
|
|
911
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
912
|
+
encoding = ("" + encoding).toLowerCase();
|
|
913
|
+
loweredCase = true;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
Buffer3.prototype.toJSON = function toJSON() {
|
|
918
|
+
return {
|
|
919
|
+
type: "Buffer",
|
|
920
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
921
|
+
};
|
|
922
|
+
};
|
|
923
|
+
function base64Slice(buf, start, end) {
|
|
924
|
+
if (start === 0 && end === buf.length) {
|
|
925
|
+
return base64.fromByteArray(buf);
|
|
926
|
+
} else {
|
|
927
|
+
return base64.fromByteArray(buf.slice(start, end));
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function utf8Slice(buf, start, end) {
|
|
931
|
+
end = Math.min(buf.length, end);
|
|
932
|
+
const res = [];
|
|
933
|
+
let i = start;
|
|
934
|
+
while (i < end) {
|
|
935
|
+
const firstByte = buf[i];
|
|
936
|
+
let codePoint = null;
|
|
937
|
+
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
938
|
+
if (i + bytesPerSequence <= end) {
|
|
939
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
940
|
+
switch (bytesPerSequence) {
|
|
941
|
+
case 1:
|
|
942
|
+
if (firstByte < 128) {
|
|
943
|
+
codePoint = firstByte;
|
|
944
|
+
}
|
|
945
|
+
break;
|
|
946
|
+
case 2:
|
|
947
|
+
secondByte = buf[i + 1];
|
|
948
|
+
if ((secondByte & 192) === 128) {
|
|
949
|
+
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
950
|
+
if (tempCodePoint > 127) {
|
|
951
|
+
codePoint = tempCodePoint;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
break;
|
|
955
|
+
case 3:
|
|
956
|
+
secondByte = buf[i + 1];
|
|
957
|
+
thirdByte = buf[i + 2];
|
|
958
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
959
|
+
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
960
|
+
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
961
|
+
codePoint = tempCodePoint;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
break;
|
|
965
|
+
case 4:
|
|
966
|
+
secondByte = buf[i + 1];
|
|
967
|
+
thirdByte = buf[i + 2];
|
|
968
|
+
fourthByte = buf[i + 3];
|
|
969
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
970
|
+
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
971
|
+
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
972
|
+
codePoint = tempCodePoint;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
if (codePoint === null) {
|
|
978
|
+
codePoint = 65533;
|
|
979
|
+
bytesPerSequence = 1;
|
|
980
|
+
} else if (codePoint > 65535) {
|
|
981
|
+
codePoint -= 65536;
|
|
982
|
+
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
983
|
+
codePoint = 56320 | codePoint & 1023;
|
|
984
|
+
}
|
|
985
|
+
res.push(codePoint);
|
|
986
|
+
i += bytesPerSequence;
|
|
987
|
+
}
|
|
988
|
+
return decodeCodePointsArray(res);
|
|
989
|
+
}
|
|
990
|
+
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
991
|
+
function decodeCodePointsArray(codePoints) {
|
|
992
|
+
const len = codePoints.length;
|
|
993
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
994
|
+
return String.fromCharCode.apply(String, codePoints);
|
|
995
|
+
}
|
|
996
|
+
let res = "";
|
|
997
|
+
let i = 0;
|
|
998
|
+
while (i < len) {
|
|
999
|
+
res += String.fromCharCode.apply(
|
|
1000
|
+
String,
|
|
1001
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
return res;
|
|
1005
|
+
}
|
|
1006
|
+
function asciiSlice(buf, start, end) {
|
|
1007
|
+
let ret = "";
|
|
1008
|
+
end = Math.min(buf.length, end);
|
|
1009
|
+
for (let i = start; i < end; ++i) {
|
|
1010
|
+
ret += String.fromCharCode(buf[i] & 127);
|
|
1011
|
+
}
|
|
1012
|
+
return ret;
|
|
1013
|
+
}
|
|
1014
|
+
function latin1Slice(buf, start, end) {
|
|
1015
|
+
let ret = "";
|
|
1016
|
+
end = Math.min(buf.length, end);
|
|
1017
|
+
for (let i = start; i < end; ++i) {
|
|
1018
|
+
ret += String.fromCharCode(buf[i]);
|
|
1019
|
+
}
|
|
1020
|
+
return ret;
|
|
1021
|
+
}
|
|
1022
|
+
function hexSlice(buf, start, end) {
|
|
1023
|
+
const len = buf.length;
|
|
1024
|
+
if (!start || start < 0) start = 0;
|
|
1025
|
+
if (!end || end < 0 || end > len) end = len;
|
|
1026
|
+
let out = "";
|
|
1027
|
+
for (let i = start; i < end; ++i) {
|
|
1028
|
+
out += hexSliceLookupTable[buf[i]];
|
|
1029
|
+
}
|
|
1030
|
+
return out;
|
|
1031
|
+
}
|
|
1032
|
+
function utf16leSlice(buf, start, end) {
|
|
1033
|
+
const bytes = buf.slice(start, end);
|
|
1034
|
+
let res = "";
|
|
1035
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
1036
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
1037
|
+
}
|
|
1038
|
+
return res;
|
|
1039
|
+
}
|
|
1040
|
+
Buffer3.prototype.slice = function slice(start, end) {
|
|
1041
|
+
const len = this.length;
|
|
1042
|
+
start = ~~start;
|
|
1043
|
+
end = end === void 0 ? len : ~~end;
|
|
1044
|
+
if (start < 0) {
|
|
1045
|
+
start += len;
|
|
1046
|
+
if (start < 0) start = 0;
|
|
1047
|
+
} else if (start > len) {
|
|
1048
|
+
start = len;
|
|
1049
|
+
}
|
|
1050
|
+
if (end < 0) {
|
|
1051
|
+
end += len;
|
|
1052
|
+
if (end < 0) end = 0;
|
|
1053
|
+
} else if (end > len) {
|
|
1054
|
+
end = len;
|
|
1055
|
+
}
|
|
1056
|
+
if (end < start) end = start;
|
|
1057
|
+
const newBuf = this.subarray(start, end);
|
|
1058
|
+
Object.setPrototypeOf(newBuf, Buffer3.prototype);
|
|
1059
|
+
return newBuf;
|
|
1060
|
+
};
|
|
1061
|
+
function checkOffset(offset, ext, length) {
|
|
1062
|
+
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
1063
|
+
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
1064
|
+
}
|
|
1065
|
+
Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
1066
|
+
offset = offset >>> 0;
|
|
1067
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1068
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1069
|
+
let val = this[offset];
|
|
1070
|
+
let mul = 1;
|
|
1071
|
+
let i = 0;
|
|
1072
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1073
|
+
val += this[offset + i] * mul;
|
|
1074
|
+
}
|
|
1075
|
+
return val;
|
|
1076
|
+
};
|
|
1077
|
+
Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
1078
|
+
offset = offset >>> 0;
|
|
1079
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1080
|
+
if (!noAssert) {
|
|
1081
|
+
checkOffset(offset, byteLength2, this.length);
|
|
1082
|
+
}
|
|
1083
|
+
let val = this[offset + --byteLength2];
|
|
1084
|
+
let mul = 1;
|
|
1085
|
+
while (byteLength2 > 0 && (mul *= 256)) {
|
|
1086
|
+
val += this[offset + --byteLength2] * mul;
|
|
1087
|
+
}
|
|
1088
|
+
return val;
|
|
1089
|
+
};
|
|
1090
|
+
Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1091
|
+
offset = offset >>> 0;
|
|
1092
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1093
|
+
return this[offset];
|
|
1094
|
+
};
|
|
1095
|
+
Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1096
|
+
offset = offset >>> 0;
|
|
1097
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1098
|
+
return this[offset] | this[offset + 1] << 8;
|
|
1099
|
+
};
|
|
1100
|
+
Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1101
|
+
offset = offset >>> 0;
|
|
1102
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1103
|
+
return this[offset] << 8 | this[offset + 1];
|
|
1104
|
+
};
|
|
1105
|
+
Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1106
|
+
offset = offset >>> 0;
|
|
1107
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1108
|
+
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1109
|
+
};
|
|
1110
|
+
Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1111
|
+
offset = offset >>> 0;
|
|
1112
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1113
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1114
|
+
};
|
|
1115
|
+
Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
|
1116
|
+
offset = offset >>> 0;
|
|
1117
|
+
validateNumber(offset, "offset");
|
|
1118
|
+
const first = this[offset];
|
|
1119
|
+
const last = this[offset + 7];
|
|
1120
|
+
if (first === void 0 || last === void 0) {
|
|
1121
|
+
boundsError(offset, this.length - 8);
|
|
1122
|
+
}
|
|
1123
|
+
const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
|
|
1124
|
+
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
|
|
1125
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32));
|
|
1126
|
+
});
|
|
1127
|
+
Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
|
1128
|
+
offset = offset >>> 0;
|
|
1129
|
+
validateNumber(offset, "offset");
|
|
1130
|
+
const first = this[offset];
|
|
1131
|
+
const last = this[offset + 7];
|
|
1132
|
+
if (first === void 0 || last === void 0) {
|
|
1133
|
+
boundsError(offset, this.length - 8);
|
|
1134
|
+
}
|
|
1135
|
+
const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1136
|
+
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
|
|
1137
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
|
1138
|
+
});
|
|
1139
|
+
Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
1140
|
+
offset = offset >>> 0;
|
|
1141
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1142
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1143
|
+
let val = this[offset];
|
|
1144
|
+
let mul = 1;
|
|
1145
|
+
let i = 0;
|
|
1146
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1147
|
+
val += this[offset + i] * mul;
|
|
1148
|
+
}
|
|
1149
|
+
mul *= 128;
|
|
1150
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1151
|
+
return val;
|
|
1152
|
+
};
|
|
1153
|
+
Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
1154
|
+
offset = offset >>> 0;
|
|
1155
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1156
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1157
|
+
let i = byteLength2;
|
|
1158
|
+
let mul = 1;
|
|
1159
|
+
let val = this[offset + --i];
|
|
1160
|
+
while (i > 0 && (mul *= 256)) {
|
|
1161
|
+
val += this[offset + --i] * mul;
|
|
1162
|
+
}
|
|
1163
|
+
mul *= 128;
|
|
1164
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1165
|
+
return val;
|
|
1166
|
+
};
|
|
1167
|
+
Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1168
|
+
offset = offset >>> 0;
|
|
1169
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1170
|
+
if (!(this[offset] & 128)) return this[offset];
|
|
1171
|
+
return (255 - this[offset] + 1) * -1;
|
|
1172
|
+
};
|
|
1173
|
+
Buffer3.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1174
|
+
offset = offset >>> 0;
|
|
1175
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1176
|
+
const val = this[offset] | this[offset + 1] << 8;
|
|
1177
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1178
|
+
};
|
|
1179
|
+
Buffer3.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1180
|
+
offset = offset >>> 0;
|
|
1181
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1182
|
+
const val = this[offset + 1] | this[offset] << 8;
|
|
1183
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1184
|
+
};
|
|
1185
|
+
Buffer3.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1186
|
+
offset = offset >>> 0;
|
|
1187
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1188
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1189
|
+
};
|
|
1190
|
+
Buffer3.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1191
|
+
offset = offset >>> 0;
|
|
1192
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1193
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1194
|
+
};
|
|
1195
|
+
Buffer3.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
|
1196
|
+
offset = offset >>> 0;
|
|
1197
|
+
validateNumber(offset, "offset");
|
|
1198
|
+
const first = this[offset];
|
|
1199
|
+
const last = this[offset + 7];
|
|
1200
|
+
if (first === void 0 || last === void 0) {
|
|
1201
|
+
boundsError(offset, this.length - 8);
|
|
1202
|
+
}
|
|
1203
|
+
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
|
|
1204
|
+
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
|
|
1205
|
+
});
|
|
1206
|
+
Buffer3.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
|
1207
|
+
offset = offset >>> 0;
|
|
1208
|
+
validateNumber(offset, "offset");
|
|
1209
|
+
const first = this[offset];
|
|
1210
|
+
const last = this[offset + 7];
|
|
1211
|
+
if (first === void 0 || last === void 0) {
|
|
1212
|
+
boundsError(offset, this.length - 8);
|
|
1213
|
+
}
|
|
1214
|
+
const val = (first << 24) + // Overflow
|
|
1215
|
+
this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1216
|
+
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
|
|
1217
|
+
});
|
|
1218
|
+
Buffer3.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1219
|
+
offset = offset >>> 0;
|
|
1220
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1221
|
+
return ieee754.read(this, offset, true, 23, 4);
|
|
1222
|
+
};
|
|
1223
|
+
Buffer3.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1224
|
+
offset = offset >>> 0;
|
|
1225
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1226
|
+
return ieee754.read(this, offset, false, 23, 4);
|
|
1227
|
+
};
|
|
1228
|
+
Buffer3.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1229
|
+
offset = offset >>> 0;
|
|
1230
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1231
|
+
return ieee754.read(this, offset, true, 52, 8);
|
|
1232
|
+
};
|
|
1233
|
+
Buffer3.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1234
|
+
offset = offset >>> 0;
|
|
1235
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1236
|
+
return ieee754.read(this, offset, false, 52, 8);
|
|
1237
|
+
};
|
|
1238
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
|
1239
|
+
if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1240
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
1241
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1242
|
+
}
|
|
1243
|
+
Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1244
|
+
value = +value;
|
|
1245
|
+
offset = offset >>> 0;
|
|
1246
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1247
|
+
if (!noAssert) {
|
|
1248
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1249
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1250
|
+
}
|
|
1251
|
+
let mul = 1;
|
|
1252
|
+
let i = 0;
|
|
1253
|
+
this[offset] = value & 255;
|
|
1254
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1255
|
+
this[offset + i] = value / mul & 255;
|
|
1256
|
+
}
|
|
1257
|
+
return offset + byteLength2;
|
|
1258
|
+
};
|
|
1259
|
+
Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1260
|
+
value = +value;
|
|
1261
|
+
offset = offset >>> 0;
|
|
1262
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1263
|
+
if (!noAssert) {
|
|
1264
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1265
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1266
|
+
}
|
|
1267
|
+
let i = byteLength2 - 1;
|
|
1268
|
+
let mul = 1;
|
|
1269
|
+
this[offset + i] = value & 255;
|
|
1270
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1271
|
+
this[offset + i] = value / mul & 255;
|
|
1272
|
+
}
|
|
1273
|
+
return offset + byteLength2;
|
|
1274
|
+
};
|
|
1275
|
+
Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1276
|
+
value = +value;
|
|
1277
|
+
offset = offset >>> 0;
|
|
1278
|
+
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1279
|
+
this[offset] = value & 255;
|
|
1280
|
+
return offset + 1;
|
|
1281
|
+
};
|
|
1282
|
+
Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1283
|
+
value = +value;
|
|
1284
|
+
offset = offset >>> 0;
|
|
1285
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1286
|
+
this[offset] = value & 255;
|
|
1287
|
+
this[offset + 1] = value >>> 8;
|
|
1288
|
+
return offset + 2;
|
|
1289
|
+
};
|
|
1290
|
+
Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1291
|
+
value = +value;
|
|
1292
|
+
offset = offset >>> 0;
|
|
1293
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1294
|
+
this[offset] = value >>> 8;
|
|
1295
|
+
this[offset + 1] = value & 255;
|
|
1296
|
+
return offset + 2;
|
|
1297
|
+
};
|
|
1298
|
+
Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1299
|
+
value = +value;
|
|
1300
|
+
offset = offset >>> 0;
|
|
1301
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1302
|
+
this[offset + 3] = value >>> 24;
|
|
1303
|
+
this[offset + 2] = value >>> 16;
|
|
1304
|
+
this[offset + 1] = value >>> 8;
|
|
1305
|
+
this[offset] = value & 255;
|
|
1306
|
+
return offset + 4;
|
|
1307
|
+
};
|
|
1308
|
+
Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1309
|
+
value = +value;
|
|
1310
|
+
offset = offset >>> 0;
|
|
1311
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1312
|
+
this[offset] = value >>> 24;
|
|
1313
|
+
this[offset + 1] = value >>> 16;
|
|
1314
|
+
this[offset + 2] = value >>> 8;
|
|
1315
|
+
this[offset + 3] = value & 255;
|
|
1316
|
+
return offset + 4;
|
|
1317
|
+
};
|
|
1318
|
+
function wrtBigUInt64LE(buf, value, offset, min, max) {
|
|
1319
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1320
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1321
|
+
buf[offset++] = lo;
|
|
1322
|
+
lo = lo >> 8;
|
|
1323
|
+
buf[offset++] = lo;
|
|
1324
|
+
lo = lo >> 8;
|
|
1325
|
+
buf[offset++] = lo;
|
|
1326
|
+
lo = lo >> 8;
|
|
1327
|
+
buf[offset++] = lo;
|
|
1328
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1329
|
+
buf[offset++] = hi;
|
|
1330
|
+
hi = hi >> 8;
|
|
1331
|
+
buf[offset++] = hi;
|
|
1332
|
+
hi = hi >> 8;
|
|
1333
|
+
buf[offset++] = hi;
|
|
1334
|
+
hi = hi >> 8;
|
|
1335
|
+
buf[offset++] = hi;
|
|
1336
|
+
return offset;
|
|
1337
|
+
}
|
|
1338
|
+
function wrtBigUInt64BE(buf, value, offset, min, max) {
|
|
1339
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1340
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1341
|
+
buf[offset + 7] = lo;
|
|
1342
|
+
lo = lo >> 8;
|
|
1343
|
+
buf[offset + 6] = lo;
|
|
1344
|
+
lo = lo >> 8;
|
|
1345
|
+
buf[offset + 5] = lo;
|
|
1346
|
+
lo = lo >> 8;
|
|
1347
|
+
buf[offset + 4] = lo;
|
|
1348
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1349
|
+
buf[offset + 3] = hi;
|
|
1350
|
+
hi = hi >> 8;
|
|
1351
|
+
buf[offset + 2] = hi;
|
|
1352
|
+
hi = hi >> 8;
|
|
1353
|
+
buf[offset + 1] = hi;
|
|
1354
|
+
hi = hi >> 8;
|
|
1355
|
+
buf[offset] = hi;
|
|
1356
|
+
return offset + 8;
|
|
1357
|
+
}
|
|
1358
|
+
Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1359
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1360
|
+
});
|
|
1361
|
+
Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1362
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1363
|
+
});
|
|
1364
|
+
Buffer3.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1365
|
+
value = +value;
|
|
1366
|
+
offset = offset >>> 0;
|
|
1367
|
+
if (!noAssert) {
|
|
1368
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1369
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1370
|
+
}
|
|
1371
|
+
let i = 0;
|
|
1372
|
+
let mul = 1;
|
|
1373
|
+
let sub = 0;
|
|
1374
|
+
this[offset] = value & 255;
|
|
1375
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1376
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1377
|
+
sub = 1;
|
|
1378
|
+
}
|
|
1379
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1380
|
+
}
|
|
1381
|
+
return offset + byteLength2;
|
|
1382
|
+
};
|
|
1383
|
+
Buffer3.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1384
|
+
value = +value;
|
|
1385
|
+
offset = offset >>> 0;
|
|
1386
|
+
if (!noAssert) {
|
|
1387
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1388
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1389
|
+
}
|
|
1390
|
+
let i = byteLength2 - 1;
|
|
1391
|
+
let mul = 1;
|
|
1392
|
+
let sub = 0;
|
|
1393
|
+
this[offset + i] = value & 255;
|
|
1394
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1395
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1396
|
+
sub = 1;
|
|
1397
|
+
}
|
|
1398
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1399
|
+
}
|
|
1400
|
+
return offset + byteLength2;
|
|
1401
|
+
};
|
|
1402
|
+
Buffer3.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1403
|
+
value = +value;
|
|
1404
|
+
offset = offset >>> 0;
|
|
1405
|
+
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1406
|
+
if (value < 0) value = 255 + value + 1;
|
|
1407
|
+
this[offset] = value & 255;
|
|
1408
|
+
return offset + 1;
|
|
1409
|
+
};
|
|
1410
|
+
Buffer3.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1411
|
+
value = +value;
|
|
1412
|
+
offset = offset >>> 0;
|
|
1413
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1414
|
+
this[offset] = value & 255;
|
|
1415
|
+
this[offset + 1] = value >>> 8;
|
|
1416
|
+
return offset + 2;
|
|
1417
|
+
};
|
|
1418
|
+
Buffer3.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1419
|
+
value = +value;
|
|
1420
|
+
offset = offset >>> 0;
|
|
1421
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1422
|
+
this[offset] = value >>> 8;
|
|
1423
|
+
this[offset + 1] = value & 255;
|
|
1424
|
+
return offset + 2;
|
|
1425
|
+
};
|
|
1426
|
+
Buffer3.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1427
|
+
value = +value;
|
|
1428
|
+
offset = offset >>> 0;
|
|
1429
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1430
|
+
this[offset] = value & 255;
|
|
1431
|
+
this[offset + 1] = value >>> 8;
|
|
1432
|
+
this[offset + 2] = value >>> 16;
|
|
1433
|
+
this[offset + 3] = value >>> 24;
|
|
1434
|
+
return offset + 4;
|
|
1435
|
+
};
|
|
1436
|
+
Buffer3.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1437
|
+
value = +value;
|
|
1438
|
+
offset = offset >>> 0;
|
|
1439
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1440
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
1441
|
+
this[offset] = value >>> 24;
|
|
1442
|
+
this[offset + 1] = value >>> 16;
|
|
1443
|
+
this[offset + 2] = value >>> 8;
|
|
1444
|
+
this[offset + 3] = value & 255;
|
|
1445
|
+
return offset + 4;
|
|
1446
|
+
};
|
|
1447
|
+
Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1448
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1449
|
+
});
|
|
1450
|
+
Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1451
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1452
|
+
});
|
|
1453
|
+
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
1454
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1455
|
+
if (offset < 0) throw new RangeError("Index out of range");
|
|
1456
|
+
}
|
|
1457
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
1458
|
+
value = +value;
|
|
1459
|
+
offset = offset >>> 0;
|
|
1460
|
+
if (!noAssert) {
|
|
1461
|
+
checkIEEE754(buf, value, offset, 4);
|
|
1462
|
+
}
|
|
1463
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
1464
|
+
return offset + 4;
|
|
1465
|
+
}
|
|
1466
|
+
Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1467
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
1468
|
+
};
|
|
1469
|
+
Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1470
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
1471
|
+
};
|
|
1472
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
1473
|
+
value = +value;
|
|
1474
|
+
offset = offset >>> 0;
|
|
1475
|
+
if (!noAssert) {
|
|
1476
|
+
checkIEEE754(buf, value, offset, 8);
|
|
1477
|
+
}
|
|
1478
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
1479
|
+
return offset + 8;
|
|
1480
|
+
}
|
|
1481
|
+
Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1482
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
1483
|
+
};
|
|
1484
|
+
Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1485
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
1486
|
+
};
|
|
1487
|
+
Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1488
|
+
if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
1489
|
+
if (!start) start = 0;
|
|
1490
|
+
if (!end && end !== 0) end = this.length;
|
|
1491
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
1492
|
+
if (!targetStart) targetStart = 0;
|
|
1493
|
+
if (end > 0 && end < start) end = start;
|
|
1494
|
+
if (end === start) return 0;
|
|
1495
|
+
if (target.length === 0 || this.length === 0) return 0;
|
|
1496
|
+
if (targetStart < 0) {
|
|
1497
|
+
throw new RangeError("targetStart out of bounds");
|
|
1498
|
+
}
|
|
1499
|
+
if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
|
|
1500
|
+
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1501
|
+
if (end > this.length) end = this.length;
|
|
1502
|
+
if (target.length - targetStart < end - start) {
|
|
1503
|
+
end = target.length - targetStart + start;
|
|
1504
|
+
}
|
|
1505
|
+
const len = end - start;
|
|
1506
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
|
|
1507
|
+
this.copyWithin(targetStart, start, end);
|
|
1508
|
+
} else {
|
|
1509
|
+
Uint8Array.prototype.set.call(
|
|
1510
|
+
target,
|
|
1511
|
+
this.subarray(start, end),
|
|
1512
|
+
targetStart
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
return len;
|
|
1516
|
+
};
|
|
1517
|
+
Buffer3.prototype.fill = function fill(val, start, end, encoding) {
|
|
1518
|
+
if (typeof val === "string") {
|
|
1519
|
+
if (typeof start === "string") {
|
|
1520
|
+
encoding = start;
|
|
1521
|
+
start = 0;
|
|
1522
|
+
end = this.length;
|
|
1523
|
+
} else if (typeof end === "string") {
|
|
1524
|
+
encoding = end;
|
|
1525
|
+
end = this.length;
|
|
1526
|
+
}
|
|
1527
|
+
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1528
|
+
throw new TypeError("encoding must be a string");
|
|
1529
|
+
}
|
|
1530
|
+
if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
|
|
1531
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
1532
|
+
}
|
|
1533
|
+
if (val.length === 1) {
|
|
1534
|
+
const code = val.charCodeAt(0);
|
|
1535
|
+
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
|
|
1536
|
+
val = code;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
} else if (typeof val === "number") {
|
|
1540
|
+
val = val & 255;
|
|
1541
|
+
} else if (typeof val === "boolean") {
|
|
1542
|
+
val = Number(val);
|
|
1543
|
+
}
|
|
1544
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
1545
|
+
throw new RangeError("Out of range index");
|
|
1546
|
+
}
|
|
1547
|
+
if (end <= start) {
|
|
1548
|
+
return this;
|
|
1549
|
+
}
|
|
1550
|
+
start = start >>> 0;
|
|
1551
|
+
end = end === void 0 ? this.length : end >>> 0;
|
|
1552
|
+
if (!val) val = 0;
|
|
1553
|
+
let i;
|
|
1554
|
+
if (typeof val === "number") {
|
|
1555
|
+
for (i = start; i < end; ++i) {
|
|
1556
|
+
this[i] = val;
|
|
1557
|
+
}
|
|
1558
|
+
} else {
|
|
1559
|
+
const bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
|
|
1560
|
+
const len = bytes.length;
|
|
1561
|
+
if (len === 0) {
|
|
1562
|
+
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
1563
|
+
}
|
|
1564
|
+
for (i = 0; i < end - start; ++i) {
|
|
1565
|
+
this[i + start] = bytes[i % len];
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
return this;
|
|
1569
|
+
};
|
|
1570
|
+
var errors = {};
|
|
1571
|
+
function E(sym, getMessage, Base) {
|
|
1572
|
+
errors[sym] = class NodeError extends Base {
|
|
1573
|
+
constructor() {
|
|
1574
|
+
super();
|
|
1575
|
+
Object.defineProperty(this, "message", {
|
|
1576
|
+
value: getMessage.apply(this, arguments),
|
|
1577
|
+
writable: true,
|
|
1578
|
+
configurable: true
|
|
1579
|
+
});
|
|
1580
|
+
this.name = `${this.name} [${sym}]`;
|
|
1581
|
+
this.stack;
|
|
1582
|
+
delete this.name;
|
|
1583
|
+
}
|
|
1584
|
+
get code() {
|
|
1585
|
+
return sym;
|
|
1586
|
+
}
|
|
1587
|
+
set code(value) {
|
|
1588
|
+
Object.defineProperty(this, "code", {
|
|
1589
|
+
configurable: true,
|
|
1590
|
+
enumerable: true,
|
|
1591
|
+
value,
|
|
1592
|
+
writable: true
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
toString() {
|
|
1596
|
+
return `${this.name} [${sym}]: ${this.message}`;
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
E(
|
|
1601
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
1602
|
+
function(name) {
|
|
1603
|
+
if (name) {
|
|
1604
|
+
return `${name} is outside of buffer bounds`;
|
|
1605
|
+
}
|
|
1606
|
+
return "Attempt to access memory outside buffer bounds";
|
|
1607
|
+
},
|
|
1608
|
+
RangeError
|
|
1609
|
+
);
|
|
1610
|
+
E(
|
|
1611
|
+
"ERR_INVALID_ARG_TYPE",
|
|
1612
|
+
function(name, actual) {
|
|
1613
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
|
|
1614
|
+
},
|
|
1615
|
+
TypeError
|
|
1616
|
+
);
|
|
1617
|
+
E(
|
|
1618
|
+
"ERR_OUT_OF_RANGE",
|
|
1619
|
+
function(str, range, input) {
|
|
1620
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
1621
|
+
let received = input;
|
|
1622
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
1623
|
+
received = addNumericalSeparator(String(input));
|
|
1624
|
+
} else if (typeof input === "bigint") {
|
|
1625
|
+
received = String(input);
|
|
1626
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
1627
|
+
received = addNumericalSeparator(received);
|
|
1628
|
+
}
|
|
1629
|
+
received += "n";
|
|
1630
|
+
}
|
|
1631
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
1632
|
+
return msg;
|
|
1633
|
+
},
|
|
1634
|
+
RangeError
|
|
1635
|
+
);
|
|
1636
|
+
function addNumericalSeparator(val) {
|
|
1637
|
+
let res = "";
|
|
1638
|
+
let i = val.length;
|
|
1639
|
+
const start = val[0] === "-" ? 1 : 0;
|
|
1640
|
+
for (; i >= start + 4; i -= 3) {
|
|
1641
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
1642
|
+
}
|
|
1643
|
+
return `${val.slice(0, i)}${res}`;
|
|
1644
|
+
}
|
|
1645
|
+
function checkBounds(buf, offset, byteLength2) {
|
|
1646
|
+
validateNumber(offset, "offset");
|
|
1647
|
+
if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
|
|
1648
|
+
boundsError(offset, buf.length - (byteLength2 + 1));
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
function checkIntBI(value, min, max, buf, offset, byteLength2) {
|
|
1652
|
+
if (value > max || value < min) {
|
|
1653
|
+
const n = typeof min === "bigint" ? "n" : "";
|
|
1654
|
+
let range;
|
|
1655
|
+
{
|
|
1656
|
+
if (min === 0 || min === BigInt(0)) {
|
|
1657
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
|
|
1658
|
+
} else {
|
|
1659
|
+
range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
|
1663
|
+
}
|
|
1664
|
+
checkBounds(buf, offset, byteLength2);
|
|
1665
|
+
}
|
|
1666
|
+
function validateNumber(value, name) {
|
|
1667
|
+
if (typeof value !== "number") {
|
|
1668
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
function boundsError(value, length, type) {
|
|
1672
|
+
if (Math.floor(value) !== value) {
|
|
1673
|
+
validateNumber(value, type);
|
|
1674
|
+
throw new errors.ERR_OUT_OF_RANGE("offset", "an integer", value);
|
|
1675
|
+
}
|
|
1676
|
+
if (length < 0) {
|
|
1677
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
|
1678
|
+
}
|
|
1679
|
+
throw new errors.ERR_OUT_OF_RANGE(
|
|
1680
|
+
"offset",
|
|
1681
|
+
`>= ${0} and <= ${length}`,
|
|
1682
|
+
value
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
1686
|
+
function base64clean(str) {
|
|
1687
|
+
str = str.split("=")[0];
|
|
1688
|
+
str = str.trim().replace(INVALID_BASE64_RE, "");
|
|
1689
|
+
if (str.length < 2) return "";
|
|
1690
|
+
while (str.length % 4 !== 0) {
|
|
1691
|
+
str = str + "=";
|
|
1692
|
+
}
|
|
1693
|
+
return str;
|
|
1694
|
+
}
|
|
1695
|
+
function utf8ToBytes(string, units) {
|
|
1696
|
+
units = units || Infinity;
|
|
1697
|
+
let codePoint;
|
|
1698
|
+
const length = string.length;
|
|
1699
|
+
let leadSurrogate = null;
|
|
1700
|
+
const bytes = [];
|
|
1701
|
+
for (let i = 0; i < length; ++i) {
|
|
1702
|
+
codePoint = string.charCodeAt(i);
|
|
1703
|
+
if (codePoint > 55295 && codePoint < 57344) {
|
|
1704
|
+
if (!leadSurrogate) {
|
|
1705
|
+
if (codePoint > 56319) {
|
|
1706
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1707
|
+
continue;
|
|
1708
|
+
} else if (i + 1 === length) {
|
|
1709
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
leadSurrogate = codePoint;
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
if (codePoint < 56320) {
|
|
1716
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1717
|
+
leadSurrogate = codePoint;
|
|
1718
|
+
continue;
|
|
1719
|
+
}
|
|
1720
|
+
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
1721
|
+
} else if (leadSurrogate) {
|
|
1722
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1723
|
+
}
|
|
1724
|
+
leadSurrogate = null;
|
|
1725
|
+
if (codePoint < 128) {
|
|
1726
|
+
if ((units -= 1) < 0) break;
|
|
1727
|
+
bytes.push(codePoint);
|
|
1728
|
+
} else if (codePoint < 2048) {
|
|
1729
|
+
if ((units -= 2) < 0) break;
|
|
1730
|
+
bytes.push(
|
|
1731
|
+
codePoint >> 6 | 192,
|
|
1732
|
+
codePoint & 63 | 128
|
|
1733
|
+
);
|
|
1734
|
+
} else if (codePoint < 65536) {
|
|
1735
|
+
if ((units -= 3) < 0) break;
|
|
1736
|
+
bytes.push(
|
|
1737
|
+
codePoint >> 12 | 224,
|
|
1738
|
+
codePoint >> 6 & 63 | 128,
|
|
1739
|
+
codePoint & 63 | 128
|
|
1740
|
+
);
|
|
1741
|
+
} else if (codePoint < 1114112) {
|
|
1742
|
+
if ((units -= 4) < 0) break;
|
|
1743
|
+
bytes.push(
|
|
1744
|
+
codePoint >> 18 | 240,
|
|
1745
|
+
codePoint >> 12 & 63 | 128,
|
|
1746
|
+
codePoint >> 6 & 63 | 128,
|
|
1747
|
+
codePoint & 63 | 128
|
|
1748
|
+
);
|
|
1749
|
+
} else {
|
|
1750
|
+
throw new Error("Invalid code point");
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
return bytes;
|
|
1754
|
+
}
|
|
1755
|
+
function asciiToBytes(str) {
|
|
1756
|
+
const byteArray = [];
|
|
1757
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1758
|
+
byteArray.push(str.charCodeAt(i) & 255);
|
|
1759
|
+
}
|
|
1760
|
+
return byteArray;
|
|
1761
|
+
}
|
|
1762
|
+
function utf16leToBytes(str, units) {
|
|
1763
|
+
let c, hi, lo;
|
|
1764
|
+
const byteArray = [];
|
|
1765
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1766
|
+
if ((units -= 2) < 0) break;
|
|
1767
|
+
c = str.charCodeAt(i);
|
|
1768
|
+
hi = c >> 8;
|
|
1769
|
+
lo = c % 256;
|
|
1770
|
+
byteArray.push(lo);
|
|
1771
|
+
byteArray.push(hi);
|
|
1772
|
+
}
|
|
1773
|
+
return byteArray;
|
|
1774
|
+
}
|
|
1775
|
+
function base64ToBytes(str) {
|
|
1776
|
+
return base64.toByteArray(base64clean(str));
|
|
1777
|
+
}
|
|
1778
|
+
function blitBuffer(src, dst, offset, length) {
|
|
1779
|
+
let i;
|
|
1780
|
+
for (i = 0; i < length; ++i) {
|
|
1781
|
+
if (i + offset >= dst.length || i >= src.length) break;
|
|
1782
|
+
dst[i + offset] = src[i];
|
|
1783
|
+
}
|
|
1784
|
+
return i;
|
|
1785
|
+
}
|
|
1786
|
+
function isInstance(obj, type) {
|
|
1787
|
+
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
|
1788
|
+
}
|
|
1789
|
+
function numberIsNaN(obj) {
|
|
1790
|
+
return obj !== obj;
|
|
1791
|
+
}
|
|
1792
|
+
var hexSliceLookupTable = (function() {
|
|
1793
|
+
const alphabet = "0123456789abcdef";
|
|
1794
|
+
const table = new Array(256);
|
|
1795
|
+
for (let i = 0; i < 16; ++i) {
|
|
1796
|
+
const i16 = i * 16;
|
|
1797
|
+
for (let j = 0; j < 16; ++j) {
|
|
1798
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
return table;
|
|
1802
|
+
})();
|
|
1803
|
+
function defineBigIntMethod(fn) {
|
|
1804
|
+
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
1805
|
+
}
|
|
1806
|
+
function BufferBigIntNotDefined() {
|
|
1807
|
+
throw new Error("BigInt not supported");
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
|
|
1812
|
+
// src/shard/geometry-buffer.ts
|
|
1813
|
+
var import_buffer;
|
|
1814
|
+
var init_geometry_buffer = __esm({
|
|
1815
|
+
"src/shard/geometry-buffer.ts"() {
|
|
1816
|
+
import_buffer = __toESM(require_buffer());
|
|
1817
|
+
typeof globalThis.Buffer === "undefined" ? import_buffer.Buffer : globalThis.Buffer;
|
|
1818
|
+
}
|
|
1819
|
+
});
|
|
1820
|
+
|
|
1821
|
+
// src/aiwg-index-shard.ts
|
|
1822
|
+
init_geometry_buffer();
|
|
1823
|
+
|
|
8
1824
|
// src/aiwg-index.ts
|
|
1825
|
+
init_geometry_buffer();
|
|
9
1826
|
var REQUIRED_RECORD_FIELDS = [
|
|
10
1827
|
"schema_version",
|
|
11
1828
|
"id",
|
|
@@ -374,6 +2191,9 @@ function validateAiwgFortemiIndexExport(value) {
|
|
|
374
2191
|
return { valid: errors.length === 0, errors, counts };
|
|
375
2192
|
}
|
|
376
2193
|
|
|
2194
|
+
// src/aiwg-index-schema.ts
|
|
2195
|
+
init_geometry_buffer();
|
|
2196
|
+
|
|
377
2197
|
// schemas/aiwg-fortemi-index-export.schema.json
|
|
378
2198
|
var aiwg_fortemi_index_export_schema_default = {
|
|
379
2199
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -1096,6 +2916,7 @@ function validateAiwgFortemiIndexExportSchema(value) {
|
|
|
1096
2916
|
}
|
|
1097
2917
|
|
|
1098
2918
|
// src/shard/checksum.ts
|
|
2919
|
+
init_geometry_buffer();
|
|
1099
2920
|
async function sha256Hex(data) {
|
|
1100
2921
|
const buf = new ArrayBuffer(data.byteLength);
|
|
1101
2922
|
new Uint8Array(buf).set(data);
|
|
@@ -1119,6 +2940,326 @@ async function validateChecksums(checksums, files) {
|
|
|
1119
2940
|
return { valid: failures.length === 0, failures };
|
|
1120
2941
|
}
|
|
1121
2942
|
|
|
2943
|
+
// src/shard/schema-validator.ts
|
|
2944
|
+
init_geometry_buffer();
|
|
2945
|
+
|
|
2946
|
+
// src/shard/full-v1-references.ts
|
|
2947
|
+
init_geometry_buffer();
|
|
2948
|
+
var uuid = (value) => typeof value === "string" ? value.toLowerCase() : value;
|
|
2949
|
+
var key = (...values) => JSON.stringify(values);
|
|
2950
|
+
var present = (value) => value !== null && value !== void 0;
|
|
2951
|
+
function fullV1ReferenceErrors(records) {
|
|
2952
|
+
const errors = [];
|
|
2953
|
+
const rows = (component) => records.get(component) ?? [];
|
|
2954
|
+
const check = (ok, component, index, message) => {
|
|
2955
|
+
if (!ok && errors.length < 100) errors.push(`${component}[${index}]: ${message}`);
|
|
2956
|
+
};
|
|
2957
|
+
const unique = (component, identity) => {
|
|
2958
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2959
|
+
rows(component).forEach((row, index) => {
|
|
2960
|
+
const value = identity(row);
|
|
2961
|
+
if (!present(value)) return;
|
|
2962
|
+
check(!seen.has(value), component, index, "duplicate identity or coordinates");
|
|
2963
|
+
seen.add(value);
|
|
2964
|
+
});
|
|
2965
|
+
return seen;
|
|
2966
|
+
};
|
|
2967
|
+
const ids = (component) => unique(component, (row) => uuid(row.id));
|
|
2968
|
+
const ref = (row, field, targets, component, index, optional = false, normalize = true) => {
|
|
2969
|
+
if (optional && !present(row[field])) return;
|
|
2970
|
+
check(
|
|
2971
|
+
targets.has(normalize ? uuid(row[field]) : row[field]),
|
|
2972
|
+
component,
|
|
2973
|
+
index,
|
|
2974
|
+
`${field} does not reference a declared record`
|
|
2975
|
+
);
|
|
2976
|
+
};
|
|
2977
|
+
const notes = ids("notes");
|
|
2978
|
+
const collections = ids("collections");
|
|
2979
|
+
const collectionRows = new Map(rows("collections").map((row) => [uuid(row.id), row]));
|
|
2980
|
+
const completed = /* @__PURE__ */ new Set();
|
|
2981
|
+
rows("collections").forEach((row, index) => {
|
|
2982
|
+
ref(row, "parent_id", collections, "collections", index, true);
|
|
2983
|
+
const path = /* @__PURE__ */ new Set();
|
|
2984
|
+
let current = row;
|
|
2985
|
+
while (current && !completed.has(uuid(current.id))) {
|
|
2986
|
+
const id = uuid(current.id);
|
|
2987
|
+
if (path.has(id)) {
|
|
2988
|
+
check(false, "collections", index, "collection hierarchy contains a cycle");
|
|
2989
|
+
break;
|
|
2990
|
+
}
|
|
2991
|
+
path.add(id);
|
|
2992
|
+
current = collectionRows.get(uuid(current.parent_id));
|
|
2993
|
+
}
|
|
2994
|
+
for (const id of path) completed.add(id);
|
|
2995
|
+
});
|
|
2996
|
+
ids("templates");
|
|
2997
|
+
rows("templates").forEach((row, index) => ref(row, "collection_id", collections, "templates", index, true));
|
|
2998
|
+
const attachmentIds = /* @__PURE__ */ new Set();
|
|
2999
|
+
const digests = /* @__PURE__ */ new Map();
|
|
3000
|
+
rows("notes").forEach((row, index) => {
|
|
3001
|
+
ref(row, "collection_id", collections, "notes", index, true);
|
|
3002
|
+
for (const projection of row.attachments ?? []) {
|
|
3003
|
+
const attachment = projection.attachment;
|
|
3004
|
+
const id = uuid(attachment.id);
|
|
3005
|
+
check(!attachmentIds.has(id), "notes", index, "duplicate attachment identity");
|
|
3006
|
+
attachmentIds.add(id);
|
|
3007
|
+
const declaration = key(attachment.bytes, attachment.mime);
|
|
3008
|
+
check(
|
|
3009
|
+
!digests.has(attachment.checksum) || digests.get(attachment.checksum) === declaration,
|
|
3010
|
+
"notes",
|
|
3011
|
+
index,
|
|
3012
|
+
"attachment digest declarations conflict"
|
|
3013
|
+
);
|
|
3014
|
+
digests.set(attachment.checksum, declaration);
|
|
3015
|
+
}
|
|
3016
|
+
});
|
|
3017
|
+
ids("links");
|
|
3018
|
+
rows("links").forEach((row, index) => {
|
|
3019
|
+
ref(row, "from_note_id", notes, "links", index);
|
|
3020
|
+
ref(row, "to_note_id", notes, "links", index, true);
|
|
3021
|
+
});
|
|
3022
|
+
const noteRows = new Map(rows("notes").map((row) => [uuid(row.id), row]));
|
|
3023
|
+
const originals = new Map(rows("note_originals").map((row) => [uuid(row.note_id), row]));
|
|
3024
|
+
unique("note_originals", (row) => uuid(row.note_id));
|
|
3025
|
+
rows("note_originals").forEach((row, index) => {
|
|
3026
|
+
ref(row, "note_id", notes, "note_originals", index);
|
|
3027
|
+
const note = noteRows.get(uuid(row.note_id));
|
|
3028
|
+
if (typeof note?.original_content === "string" && typeof note.revised_content === "string") {
|
|
3029
|
+
check(note.original_content === row.content, "note_originals", index, "current original content conflicts with note");
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
3032
|
+
ids("note_original_history");
|
|
3033
|
+
unique("note_original_history", (row) => key(uuid(row.note_id), row.version_number));
|
|
3034
|
+
rows("note_original_history").forEach((row, index) => {
|
|
3035
|
+
ref(row, "note_id", notes, "note_original_history", index);
|
|
3036
|
+
const current = originals.get(uuid(row.note_id));
|
|
3037
|
+
check(
|
|
3038
|
+
!current || Number(row.version_number) < Number(current.version_number),
|
|
3039
|
+
"note_original_history",
|
|
3040
|
+
index,
|
|
3041
|
+
"original history version ordering is invalid"
|
|
3042
|
+
);
|
|
3043
|
+
});
|
|
3044
|
+
const revisionIds = ids("note_revisions");
|
|
3045
|
+
unique("note_revisions", (row) => key(uuid(row.note_id), row.revision_number));
|
|
3046
|
+
const revisions = new Map(rows("note_revisions").map((row) => [uuid(row.id), row]));
|
|
3047
|
+
rows("note_revisions").forEach((row, index) => {
|
|
3048
|
+
ref(row, "note_id", notes, "note_revisions", index);
|
|
3049
|
+
if (present(row.parent_revision_id)) {
|
|
3050
|
+
const parent = revisions.get(uuid(row.parent_revision_id));
|
|
3051
|
+
check(
|
|
3052
|
+
parent && uuid(parent.note_id) === uuid(row.note_id) && Number(parent.revision_number) < Number(row.revision_number),
|
|
3053
|
+
"note_revisions",
|
|
3054
|
+
index,
|
|
3055
|
+
"revision parent ownership or ordering is invalid"
|
|
3056
|
+
);
|
|
3057
|
+
}
|
|
3058
|
+
});
|
|
3059
|
+
unique("note_revised_current", (row) => uuid(row.note_id));
|
|
3060
|
+
rows("note_revised_current").forEach((row, index) => {
|
|
3061
|
+
ref(row, "note_id", notes, "note_revised_current", index);
|
|
3062
|
+
const note = noteRows.get(uuid(row.note_id));
|
|
3063
|
+
if (typeof note?.original_content === "string" && typeof note.revised_content === "string") {
|
|
3064
|
+
check(note.revised_content === row.content, "note_revised_current", index, "current revised content conflicts with note");
|
|
3065
|
+
}
|
|
3066
|
+
if (present(row.last_revision_id)) {
|
|
3067
|
+
const last = revisions.get(uuid(row.last_revision_id));
|
|
3068
|
+
check(
|
|
3069
|
+
last && uuid(last.note_id) === uuid(row.note_id) && last.content === row.content,
|
|
3070
|
+
"note_revised_current",
|
|
3071
|
+
index,
|
|
3072
|
+
"last revision ownership or content is invalid"
|
|
3073
|
+
);
|
|
3074
|
+
}
|
|
3075
|
+
});
|
|
3076
|
+
ids("provenance_edges");
|
|
3077
|
+
rows("provenance_edges").forEach((row, index) => {
|
|
3078
|
+
ref(row, "revision_id", revisionIds, "provenance_edges", index, true);
|
|
3079
|
+
ref(row, "source_note_id", notes, "provenance_edges", index, true);
|
|
3080
|
+
});
|
|
3081
|
+
const activities = ids("provenance_activities");
|
|
3082
|
+
rows("provenance_activities").forEach((row, index) => {
|
|
3083
|
+
ref(row, "note_id", notes, "provenance_activities", index);
|
|
3084
|
+
if (present(row.revision_id)) {
|
|
3085
|
+
check(
|
|
3086
|
+
uuid(revisions.get(uuid(row.revision_id))?.note_id) === uuid(row.note_id),
|
|
3087
|
+
"provenance_activities",
|
|
3088
|
+
index,
|
|
3089
|
+
"revision belongs to another or unknown note"
|
|
3090
|
+
);
|
|
3091
|
+
}
|
|
3092
|
+
});
|
|
3093
|
+
const namedLocations = ids("named_locations");
|
|
3094
|
+
unique("named_locations", (row) => row.slug);
|
|
3095
|
+
const locations = ids("provenance_locations");
|
|
3096
|
+
rows("provenance_locations").forEach((row, index) => {
|
|
3097
|
+
ref(row, "named_location_id", namedLocations, "provenance_locations", index, true);
|
|
3098
|
+
});
|
|
3099
|
+
const devices = ids("provenance_devices");
|
|
3100
|
+
unique("provenance_devices", (row) => key(row.device_make, row.device_model, uuid(row.owner_id)));
|
|
3101
|
+
ids("provenance_records");
|
|
3102
|
+
unique("provenance_records", (row) => uuid(row.note_id));
|
|
3103
|
+
rows("provenance_records").forEach((row, index) => {
|
|
3104
|
+
check(present(row.note_id) || present(row.attachment_id), "provenance_records", index, "target is required");
|
|
3105
|
+
ref(row, "note_id", notes, "provenance_records", index, true);
|
|
3106
|
+
ref(row, "attachment_id", attachmentIds, "provenance_records", index, true);
|
|
3107
|
+
ref(row, "location_id", locations, "provenance_records", index, true);
|
|
3108
|
+
ref(row, "original_location_id", locations, "provenance_records", index, true);
|
|
3109
|
+
ref(row, "device_id", devices, "provenance_records", index, true);
|
|
3110
|
+
ref(row, "activity_id", activities, "provenance_records", index, true);
|
|
3111
|
+
for (const field of ["capture_time", "original_capture_time"]) {
|
|
3112
|
+
if (present(row[field])) check(
|
|
3113
|
+
validTimestampRange(row[field]),
|
|
3114
|
+
"provenance_records",
|
|
3115
|
+
index,
|
|
3116
|
+
`${field} bounds are inconsistent`
|
|
3117
|
+
);
|
|
3118
|
+
}
|
|
3119
|
+
});
|
|
3120
|
+
const configs = ids("embedding_configs");
|
|
3121
|
+
unique("embedding_configs", (row) => row.name);
|
|
3122
|
+
const configRows = new Map(rows("embedding_configs").map((row) => [uuid(row.id), row]));
|
|
3123
|
+
const sets = ids("embedding_sets");
|
|
3124
|
+
unique("embedding_sets", (row) => row.name);
|
|
3125
|
+
unique("embedding_sets", (row) => row.slug);
|
|
3126
|
+
const dimensions = /* @__PURE__ */ new Map();
|
|
3127
|
+
rows("embedding_sets").forEach((row, index) => {
|
|
3128
|
+
ref(row, "embedding_config_id", configs, "embedding_sets", index, true);
|
|
3129
|
+
const config = configRows.get(uuid(row.embedding_config_id));
|
|
3130
|
+
if (config) dimensions.set(uuid(row.id), Number(row.truncate_dim ?? config.dimension));
|
|
3131
|
+
});
|
|
3132
|
+
unique("embedding_set_members", (row) => key(uuid(row.embedding_set_id), uuid(row.note_id)));
|
|
3133
|
+
rows("embedding_set_members").forEach((row, index) => {
|
|
3134
|
+
ref(row, "embedding_set_id", sets, "embedding_set_members", index);
|
|
3135
|
+
ref(row, "note_id", notes, "embedding_set_members", index);
|
|
3136
|
+
});
|
|
3137
|
+
ids("embeddings");
|
|
3138
|
+
unique("embeddings", (row) => present(row.note_id) && present(row.embedding_set_id) ? key(uuid(row.note_id), uuid(row.embedding_set_id), row.chunk_index) : null);
|
|
3139
|
+
rows("embeddings").forEach((row, index) => {
|
|
3140
|
+
ref(row, "note_id", notes, "embeddings", index, true);
|
|
3141
|
+
ref(row, "embedding_set_id", sets, "embeddings", index, true);
|
|
3142
|
+
if (Array.isArray(row.vector) && dimensions.has(uuid(row.embedding_set_id))) {
|
|
3143
|
+
check(
|
|
3144
|
+
row.vector.length === dimensions.get(uuid(row.embedding_set_id)),
|
|
3145
|
+
"embeddings",
|
|
3146
|
+
index,
|
|
3147
|
+
"vector dimension conflicts with the set configuration"
|
|
3148
|
+
);
|
|
3149
|
+
}
|
|
3150
|
+
});
|
|
3151
|
+
const schemes = ids("skos_schemes");
|
|
3152
|
+
unique("skos_schemes", (row) => row.notation);
|
|
3153
|
+
unique("skos_schemes", (row) => row.uri);
|
|
3154
|
+
const concepts = ids("skos_concepts");
|
|
3155
|
+
unique("skos_concepts", (row) => row.uri);
|
|
3156
|
+
unique("skos_concepts", (row) => present(row.notation) ? key(uuid(row.primary_scheme_id), row.notation) : null);
|
|
3157
|
+
rows("skos_concepts").forEach((row, index) => {
|
|
3158
|
+
ref(row, "primary_scheme_id", schemes, "skos_concepts", index);
|
|
3159
|
+
ref(row, "replaced_by_id", concepts, "skos_concepts", index, true);
|
|
3160
|
+
check(uuid(row.replaced_by_id) !== uuid(row.id), "skos_concepts", index, "concept replaces itself");
|
|
3161
|
+
});
|
|
3162
|
+
ids("skos_labels");
|
|
3163
|
+
unique("skos_labels", (row) => key(uuid(row.concept_id), row.label_type, row.language, row.value));
|
|
3164
|
+
unique("skos_labels", (row) => row.label_type === "pref_label" ? key(uuid(row.concept_id), row.language) : null);
|
|
3165
|
+
rows("skos_labels").forEach((row, index) => ref(row, "concept_id", concepts, "skos_labels", index));
|
|
3166
|
+
ids("skos_notes");
|
|
3167
|
+
rows("skos_notes").forEach((row, index) => ref(row, "concept_id", concepts, "skos_notes", index));
|
|
3168
|
+
ids("skos_relations");
|
|
3169
|
+
unique("skos_relations", (row) => key(uuid(row.subject_id), uuid(row.object_id), row.relation_type));
|
|
3170
|
+
rows("skos_relations").forEach((row, index) => {
|
|
3171
|
+
ref(row, "subject_id", concepts, "skos_relations", index);
|
|
3172
|
+
ref(row, "object_id", concepts, "skos_relations", index);
|
|
3173
|
+
check(uuid(row.subject_id) !== uuid(row.object_id), "skos_relations", index, "self relation is invalid");
|
|
3174
|
+
});
|
|
3175
|
+
ids("skos_mapping_relations");
|
|
3176
|
+
unique("skos_mapping_relations", (row) => key(uuid(row.concept_id), row.target_uri, row.relation_type));
|
|
3177
|
+
rows("skos_mapping_relations").forEach((row, index) => ref(row, "concept_id", concepts, "skos_mapping_relations", index));
|
|
3178
|
+
unique("skos_scheme_memberships", (row) => key(uuid(row.concept_id), uuid(row.scheme_id)));
|
|
3179
|
+
rows("skos_scheme_memberships").forEach((row, index) => {
|
|
3180
|
+
ref(row, "concept_id", concepts, "skos_scheme_memberships", index);
|
|
3181
|
+
ref(row, "scheme_id", schemes, "skos_scheme_memberships", index);
|
|
3182
|
+
});
|
|
3183
|
+
unique("note_skos_tags", (row) => key(uuid(row.note_id), uuid(row.concept_id)));
|
|
3184
|
+
rows("note_skos_tags").forEach((row, index) => {
|
|
3185
|
+
ref(row, "note_id", notes, "note_skos_tags", index);
|
|
3186
|
+
ref(row, "concept_id", concepts, "note_skos_tags", index);
|
|
3187
|
+
});
|
|
3188
|
+
const skosCollections = ids("skos_collections");
|
|
3189
|
+
unique("skos_collections", (row) => row.uri);
|
|
3190
|
+
rows("skos_collections").forEach((row, index) => ref(row, "scheme_id", schemes, "skos_collections", index, true));
|
|
3191
|
+
unique("skos_collection_members", (row) => key(uuid(row.collection_id), uuid(row.concept_id)));
|
|
3192
|
+
rows("skos_collection_members").forEach((row, index) => {
|
|
3193
|
+
ref(row, "collection_id", skosCollections, "skos_collection_members", index);
|
|
3194
|
+
ref(row, "concept_id", concepts, "skos_collection_members", index);
|
|
3195
|
+
});
|
|
3196
|
+
const sources = unique("graph_sources", (row) => row.id);
|
|
3197
|
+
rows("graph_sources").forEach((row, index) => {
|
|
3198
|
+
if (present(row.dimension) && present(row.truncate_dimension)) {
|
|
3199
|
+
check(
|
|
3200
|
+
Number(row.truncate_dimension) <= Number(row.dimension),
|
|
3201
|
+
"graph_sources",
|
|
3202
|
+
index,
|
|
3203
|
+
"truncate dimension exceeds source dimension"
|
|
3204
|
+
);
|
|
3205
|
+
}
|
|
3206
|
+
});
|
|
3207
|
+
unique("graph_edges", (row) => key(row.graph_source_id, uuid(row.from_note_id), uuid(row.to_note_id), row.kind));
|
|
3208
|
+
rows("graph_edges").forEach((row, index) => {
|
|
3209
|
+
ref(row, "graph_source_id", sources, "graph_edges", index, false, false);
|
|
3210
|
+
ref(row, "from_note_id", notes, "graph_edges", index);
|
|
3211
|
+
ref(row, "to_note_id", notes, "graph_edges", index);
|
|
3212
|
+
check(uuid(row.from_note_id) !== uuid(row.to_note_id), "graph_edges", index, "self edge is invalid");
|
|
3213
|
+
});
|
|
3214
|
+
unique("communities", (row) => row.id);
|
|
3215
|
+
const communities = /* @__PURE__ */ new Set();
|
|
3216
|
+
rows("communities").forEach((row, index) => {
|
|
3217
|
+
ref(row, "graph_source_id", sources, "communities", index, false, false);
|
|
3218
|
+
for (const community of row.communities) {
|
|
3219
|
+
const id = key(row.id, community.id);
|
|
3220
|
+
check(!communities.has(id), "communities", index, "duplicate community identity within set");
|
|
3221
|
+
communities.add(id);
|
|
3222
|
+
const representatives = /* @__PURE__ */ new Set();
|
|
3223
|
+
for (const noteId of community.representative_note_ids ?? []) {
|
|
3224
|
+
check(
|
|
3225
|
+
notes.has(uuid(noteId)) && !representatives.has(uuid(noteId)),
|
|
3226
|
+
"communities",
|
|
3227
|
+
index,
|
|
3228
|
+
"unknown or duplicate representative note"
|
|
3229
|
+
);
|
|
3230
|
+
representatives.add(uuid(noteId));
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
});
|
|
3234
|
+
unique("community_assignments", (row) => key(row.community_set_id, uuid(row.note_id)));
|
|
3235
|
+
rows("community_assignments").forEach((row, index) => {
|
|
3236
|
+
check(
|
|
3237
|
+
communities.has(key(row.community_set_id, row.community_id)),
|
|
3238
|
+
"community_assignments",
|
|
3239
|
+
index,
|
|
3240
|
+
"community does not belong to the declared set"
|
|
3241
|
+
);
|
|
3242
|
+
ref(row, "note_id", notes, "community_assignments", index);
|
|
3243
|
+
});
|
|
3244
|
+
return errors;
|
|
3245
|
+
}
|
|
3246
|
+
function validTimestampRange(range) {
|
|
3247
|
+
if (range.empty === true) return !present(range.lower) && !present(range.upper) && !range.lower_inclusive && !range.upper_inclusive && !range.lower_infinite && !range.upper_infinite;
|
|
3248
|
+
if (range.lower_infinite ? present(range.lower) || range.lower_inclusive : !present(range.lower)) return false;
|
|
3249
|
+
if (range.upper_infinite ? present(range.upper) || range.upper_inclusive : !present(range.upper)) return false;
|
|
3250
|
+
if (!present(range.lower) || !present(range.upper)) return true;
|
|
3251
|
+
const instant = (value) => {
|
|
3252
|
+
const match = /^(.*?)(?:\.(\d+))?(Z|[+-]\d{2}:\d{2})$/i.exec(String(value));
|
|
3253
|
+
if (!match) return null;
|
|
3254
|
+
const seconds = Date.parse(`${match[1]}${match[3]}`);
|
|
3255
|
+
if (!Number.isFinite(seconds)) return null;
|
|
3256
|
+
return BigInt(seconds) * 1000000n + BigInt((match[2] ?? "").padEnd(9, "0").slice(0, 9));
|
|
3257
|
+
};
|
|
3258
|
+
const lower = instant(range.lower);
|
|
3259
|
+
const upper = instant(range.upper);
|
|
3260
|
+
return lower !== null && upper !== null && (lower < upper || lower === upper && range.lower_inclusive === true && range.upper_inclusive === true);
|
|
3261
|
+
}
|
|
3262
|
+
|
|
1122
3263
|
// schemas/knowledge-shard/1.0.0/core-v1/manifest.schema.json
|
|
1123
3264
|
var manifest_schema_default = {
|
|
1124
3265
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -9135,6 +11276,9 @@ var signature_schema_default2 = {
|
|
|
9135
11276
|
}
|
|
9136
11277
|
}
|
|
9137
11278
|
};
|
|
11279
|
+
|
|
11280
|
+
// src/shard/shard-tar.ts
|
|
11281
|
+
init_geometry_buffer();
|
|
9138
11282
|
var BLOCK_SIZE = 512;
|
|
9139
11283
|
var USTAR_MAGIC = "ustar\x0000";
|
|
9140
11284
|
function writeString(buf, offset, str, len) {
|
|
@@ -9257,13 +11401,18 @@ function unpackTarGz(data, opts) {
|
|
|
9257
11401
|
}
|
|
9258
11402
|
|
|
9259
11403
|
// src/shard/types.ts
|
|
11404
|
+
init_geometry_buffer();
|
|
9260
11405
|
var CURRENT_SHARD_VERSION = "1.2.0";
|
|
9261
11406
|
var SHARD_FORMAT = "matric-shard";
|
|
11407
|
+
|
|
11408
|
+
// src/hash.ts
|
|
11409
|
+
init_geometry_buffer();
|
|
9262
11410
|
function computeBlobHash(data) {
|
|
9263
11411
|
return `blake3:${bytesToHex(blake3(data))}`;
|
|
9264
11412
|
}
|
|
9265
11413
|
|
|
9266
11414
|
// src/shard/blob-sidecar.ts
|
|
11415
|
+
init_geometry_buffer();
|
|
9267
11416
|
var SIDECAR_PREFIX = "blobs/";
|
|
9268
11417
|
function blobChecksumToHex(checksum) {
|
|
9269
11418
|
const sep = checksum.indexOf(":");
|
|
@@ -9506,21 +11655,21 @@ function fullSchemaVersion(value) {
|
|
|
9506
11655
|
return value === "1.1.0" || value === "1.2.0" || value === "2.0.0" ? value : void 0;
|
|
9507
11656
|
}
|
|
9508
11657
|
function coreValidatorFor(name, version = CURRENT_SHARD_VERSION) {
|
|
9509
|
-
const
|
|
9510
|
-
const cached = coreValidators.get(
|
|
11658
|
+
const key2 = `${version}:${name}`;
|
|
11659
|
+
const cached = coreValidators.get(key2);
|
|
9511
11660
|
if (cached) return cached;
|
|
9512
11661
|
const schema = CORE_V1_SCHEMAS[version][name];
|
|
9513
11662
|
const validator = getCoreAjv().getSchema(schema.$id) ?? getCoreAjv().compile(schema);
|
|
9514
|
-
coreValidators.set(
|
|
11663
|
+
coreValidators.set(key2, validator);
|
|
9515
11664
|
return validator;
|
|
9516
11665
|
}
|
|
9517
11666
|
function fullValidatorFor(name, version = CURRENT_SHARD_VERSION) {
|
|
9518
|
-
const
|
|
9519
|
-
const cached = fullValidators.get(
|
|
11667
|
+
const key2 = `${version}:${name}`;
|
|
11668
|
+
const cached = fullValidators.get(key2);
|
|
9520
11669
|
if (cached) return cached;
|
|
9521
11670
|
const schema = FULL_V1_SCHEMAS[version][name];
|
|
9522
11671
|
const validator = getFullAjv().getSchema(schema.$id) ?? getFullAjv().compile(schema);
|
|
9523
|
-
fullValidators.set(
|
|
11672
|
+
fullValidators.set(key2, validator);
|
|
9524
11673
|
return validator;
|
|
9525
11674
|
}
|
|
9526
11675
|
function formatErrors2(errors) {
|
|
@@ -9677,6 +11826,9 @@ function validateCoreV1Structure(files, manifest) {
|
|
|
9677
11826
|
}
|
|
9678
11827
|
function validateFullV1Structure(files, manifest) {
|
|
9679
11828
|
const errors = [];
|
|
11829
|
+
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) {
|
|
11830
|
+
return ["manifest.json must be an object"];
|
|
11831
|
+
}
|
|
9680
11832
|
const schemaVersion = fullSchemaVersion(manifest.version);
|
|
9681
11833
|
if (!schemaVersion) {
|
|
9682
11834
|
return ["manifest.json uses an unsupported canonical full-v1 schema version"];
|
|
@@ -9726,6 +11878,7 @@ function validateFullV1Structure(files, manifest) {
|
|
|
9726
11878
|
}
|
|
9727
11879
|
records.set(component, parsed.records);
|
|
9728
11880
|
}
|
|
11881
|
+
if (errors.length > 0) return errors;
|
|
9729
11882
|
const communitySets = records.get("communities");
|
|
9730
11883
|
const communityCount = communitySets.reduce((total, set) => {
|
|
9731
11884
|
const communities = Array.isArray(set.communities) ? set.communities : [];
|
|
@@ -9771,6 +11924,7 @@ function validateFullV1Structure(files, manifest) {
|
|
|
9771
11924
|
}
|
|
9772
11925
|
}
|
|
9773
11926
|
}
|
|
11927
|
+
if (errors.length === 0) errors.push(...fullV1ReferenceErrors(records));
|
|
9774
11928
|
return errors;
|
|
9775
11929
|
}
|
|
9776
11930
|
async function validateCoreV1ShardArchive(input) {
|
|
@@ -9836,6 +11990,9 @@ async function validateFullV1ShardArchive(input) {
|
|
|
9836
11990
|
return { valid: errors.length === 0, errors };
|
|
9837
11991
|
}
|
|
9838
11992
|
|
|
11993
|
+
// src/aiwg-index-full-shard.ts
|
|
11994
|
+
init_geometry_buffer();
|
|
11995
|
+
|
|
9839
11996
|
// schemas/knowledge-shard-v2.schema.receipt.json
|
|
9840
11997
|
var knowledge_shard_v2_schema_receipt_default = {
|
|
9841
11998
|
source: {
|
|
@@ -9847,7 +12004,7 @@ var knowledge_shard_v2_schema_receipt_default = {
|
|
|
9847
12004
|
sha256: "66dee80876c73fdc8756541c72e96ae189c098113a831c849d619381c4121c02"}};
|
|
9848
12005
|
var encoder = new TextEncoder();
|
|
9849
12006
|
var UUID_NAMESPACE = "7ab5d1f8-29d2-5e35-9e2f-3a45de171a9e";
|
|
9850
|
-
function
|
|
12007
|
+
function uuid2(kind, id) {
|
|
9851
12008
|
return v5(`${kind}:${id}`, UUID_NAMESPACE);
|
|
9852
12009
|
}
|
|
9853
12010
|
function own(value, field) {
|
|
@@ -9958,7 +12115,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
9958
12115
|
const losses = [];
|
|
9959
12116
|
const exportedAt = timestamp(options.createdAt) ?? new Date(index.generated_at).toISOString();
|
|
9960
12117
|
const records = [...index.items].sort((a, b) => a.id.localeCompare(b.id));
|
|
9961
|
-
const noteIds = new Map(records.map((record) => [record.id,
|
|
12118
|
+
const noteIds = new Map(records.map((record) => [record.id, uuid2("record", record.id)]));
|
|
9962
12119
|
const rows = /* @__PURE__ */ new Map();
|
|
9963
12120
|
for (const component of Object.keys(FULL_V1_COMPONENT_FILES)) rows.set(component, []);
|
|
9964
12121
|
const tags = /* @__PURE__ */ new Set();
|
|
@@ -10031,7 +12188,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10031
12188
|
});
|
|
10032
12189
|
const hash = await sha256Hex(encoder.encode(content));
|
|
10033
12190
|
rows.get("note_originals").push({
|
|
10034
|
-
id:
|
|
12191
|
+
id: uuid2("note-original", record.id),
|
|
10035
12192
|
note_id: noteId,
|
|
10036
12193
|
content,
|
|
10037
12194
|
hash: `sha256:${hash}`,
|
|
@@ -10051,9 +12208,9 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10051
12208
|
for (const record of records) {
|
|
10052
12209
|
for (const [position, relationship] of record.relationships.entries()) {
|
|
10053
12210
|
const target = noteIds.get(relationship.target_id) ?? null;
|
|
10054
|
-
const
|
|
12211
|
+
const key2 = `${record.id}\0${position}\0${relationship.type}\0${relationship.target_id}`;
|
|
10055
12212
|
rows.get("links").push({
|
|
10056
|
-
id:
|
|
12213
|
+
id: uuid2("relationship", key2),
|
|
10057
12214
|
from_note_id: noteIds.get(record.id),
|
|
10058
12215
|
to_note_id: target,
|
|
10059
12216
|
to_url: target ? null : `aiwg://record/${encodeURIComponent(relationship.target_id)}`,
|
|
@@ -10168,7 +12325,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10168
12325
|
}
|
|
10169
12326
|
}
|
|
10170
12327
|
const schemeIds = new Map(
|
|
10171
|
-
[...new Set([...concepts.values()].map(schemeName))].sort().map((name) => [name,
|
|
12328
|
+
[...new Set([...concepts.values()].map(schemeName))].sort().map((name) => [name, uuid2("skos-scheme", name)])
|
|
10172
12329
|
);
|
|
10173
12330
|
for (const [name, id] of schemeIds) {
|
|
10174
12331
|
rows.get("skos_schemes").push({
|
|
@@ -10192,7 +12349,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10192
12349
|
embedded_at: null
|
|
10193
12350
|
});
|
|
10194
12351
|
}
|
|
10195
|
-
const conceptIds = new Map([...concepts.keys()].sort().map((id) => [id,
|
|
12352
|
+
const conceptIds = new Map([...concepts.keys()].sort().map((id) => [id, uuid2("skos-concept", id)]));
|
|
10196
12353
|
for (const [sourceId, concept] of [...concepts].sort(([a], [b]) => a.localeCompare(b))) {
|
|
10197
12354
|
const id = conceptIds.get(sourceId);
|
|
10198
12355
|
const schemeId = schemeIds.get(schemeName(concept));
|
|
@@ -10210,7 +12367,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10210
12367
|
action: "omit"
|
|
10211
12368
|
}
|
|
10212
12369
|
);
|
|
10213
|
-
const unmappedConceptMetadata = Object.keys(concept.metadata ?? {}).filter((
|
|
12370
|
+
const unmappedConceptMetadata = Object.keys(concept.metadata ?? {}).filter((key2) => key2 !== "domain");
|
|
10214
12371
|
if (unmappedConceptMetadata.length > 0) addLoss(
|
|
10215
12372
|
losses,
|
|
10216
12373
|
"aiwg-skos-metadata-unmapped",
|
|
@@ -10260,7 +12417,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10260
12417
|
added_at: exportedAt
|
|
10261
12418
|
});
|
|
10262
12419
|
rows.get("skos_labels").push({
|
|
10263
|
-
id:
|
|
12420
|
+
id: uuid2("skos-label", `${sourceId}:pref:${concept.prefLabel}`),
|
|
10264
12421
|
concept_id: id,
|
|
10265
12422
|
label_type: "pref_label",
|
|
10266
12423
|
value: concept.prefLabel,
|
|
@@ -10268,7 +12425,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10268
12425
|
created_at: exportedAt
|
|
10269
12426
|
});
|
|
10270
12427
|
for (const label of concept.altLabels ?? []) rows.get("skos_labels").push({
|
|
10271
|
-
id:
|
|
12428
|
+
id: uuid2("skos-label", `${sourceId}:alt:${label}`),
|
|
10272
12429
|
concept_id: id,
|
|
10273
12430
|
label_type: "alt_label",
|
|
10274
12431
|
value: label,
|
|
@@ -10276,7 +12433,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10276
12433
|
created_at: exportedAt
|
|
10277
12434
|
});
|
|
10278
12435
|
if (concept.definition !== void 0) rows.get("skos_notes").push({
|
|
10279
|
-
id:
|
|
12436
|
+
id: uuid2("skos-note", `${sourceId}:definition`),
|
|
10280
12437
|
concept_id: id,
|
|
10281
12438
|
note_type: "definition",
|
|
10282
12439
|
value: concept.definition,
|
|
@@ -10339,7 +12496,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10339
12496
|
continue;
|
|
10340
12497
|
}
|
|
10341
12498
|
rows.get("skos_relations").push({
|
|
10342
|
-
id:
|
|
12499
|
+
id: uuid2("skos-relation", `${relation.source_id}:${relation.type}:${relation.target_id}`),
|
|
10343
12500
|
subject_id: subject,
|
|
10344
12501
|
object_id: object,
|
|
10345
12502
|
relation_type: relation.type,
|
|
@@ -10367,7 +12524,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10367
12524
|
}
|
|
10368
12525
|
);
|
|
10369
12526
|
rows.get("provenance_activities").push({
|
|
10370
|
-
id:
|
|
12527
|
+
id: uuid2("provenance-event", event.id ?? `${record.id}:${position}`),
|
|
10371
12528
|
note_id: noteIds.get(record.id),
|
|
10372
12529
|
revision_id: null,
|
|
10373
12530
|
activity_type: event.activity,
|
|
@@ -10385,7 +12542,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10385
12542
|
}
|
|
10386
12543
|
for (const [position, provenance] of record.provenance.entries()) {
|
|
10387
12544
|
rows.get("provenance_activities").push({
|
|
10388
|
-
id:
|
|
12545
|
+
id: uuid2("provenance-field", `${record.id}:${position}:${provenance.field}`),
|
|
10389
12546
|
note_id: noteIds.get(record.id),
|
|
10390
12547
|
revision_id: null,
|
|
10391
12548
|
activity_type: `source:${provenance.field}`,
|
|
@@ -10431,7 +12588,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10431
12588
|
);
|
|
10432
12589
|
let group = embeddingGroups.get(model);
|
|
10433
12590
|
if (!group) {
|
|
10434
|
-
group = { config:
|
|
12591
|
+
group = { config: uuid2("embedding-config", model), set: uuid2("embedding-set", model), count: 0 };
|
|
10435
12592
|
embeddingGroups.set(model, group);
|
|
10436
12593
|
}
|
|
10437
12594
|
group.count += 1;
|
|
@@ -10455,7 +12612,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10455
12612
|
}
|
|
10456
12613
|
);
|
|
10457
12614
|
rows.get("embeddings").push({
|
|
10458
|
-
id:
|
|
12615
|
+
id: uuid2("embedding", embedding.id ?? `${record.id}:${position}`),
|
|
10459
12616
|
note_id: noteIds.get(record.id),
|
|
10460
12617
|
embedding_set_id: group.set,
|
|
10461
12618
|
chunk_index: position,
|
|
@@ -10498,7 +12655,7 @@ async function convertAiwgIndexToFullV1(index, options = {}) {
|
|
|
10498
12655
|
rows.get("embedding_sets").push({
|
|
10499
12656
|
id: group.set,
|
|
10500
12657
|
name: model,
|
|
10501
|
-
slug:
|
|
12658
|
+
slug: uuid2("embedding-slug", model),
|
|
10502
12659
|
description: null,
|
|
10503
12660
|
purpose: null,
|
|
10504
12661
|
usage_hints: null,
|
|
@@ -10828,6 +12985,19 @@ ${validation.errors.join("\n")}`);
|
|
|
10828
12985
|
}
|
|
10829
12986
|
return restored;
|
|
10830
12987
|
}
|
|
12988
|
+
/*! Bundled license information:
|
|
12989
|
+
|
|
12990
|
+
ieee754/index.js:
|
|
12991
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
12992
|
+
|
|
12993
|
+
buffer/index.js:
|
|
12994
|
+
(*!
|
|
12995
|
+
* The buffer module from node.js, for the browser.
|
|
12996
|
+
*
|
|
12997
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
12998
|
+
* @license MIT
|
|
12999
|
+
*)
|
|
13000
|
+
*/
|
|
10831
13001
|
|
|
10832
13002
|
export { aiwgFortemiIndexFromKnowledgeShard, aiwgFortemiIndexToKnowledgeShard, aiwgFortemiIndexToKnowledgeShardWithReport };
|
|
10833
13003
|
//# sourceMappingURL=aiwg-index-shard.js.map
|