@matdata/yasgui-graph-plugin 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/yasgui-graph-plugin.cjs.js +3659 -34
- package/dist/yasgui-graph-plugin.cjs.js.map +4 -4
- package/dist/yasgui-graph-plugin.esm.js +3669 -31
- package/dist/yasgui-graph-plugin.esm.js.map +4 -4
- package/dist/yasgui-graph-plugin.min.js +39 -27
- package/dist/yasgui-graph-plugin.min.js.map +4 -4
- package/package.json +5 -3
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
8
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -13,9 +18,1793 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
18
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
19
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
20
|
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// node_modules/base64-js/index.js
|
|
34
|
+
var require_base64_js = __commonJS({
|
|
35
|
+
"node_modules/base64-js/index.js"(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
exports.byteLength = byteLength;
|
|
38
|
+
exports.toByteArray = toByteArray;
|
|
39
|
+
exports.fromByteArray = fromByteArray;
|
|
40
|
+
var lookup = [];
|
|
41
|
+
var revLookup = [];
|
|
42
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
43
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
44
|
+
for (i = 0, len = code.length; i < len; ++i) {
|
|
45
|
+
lookup[i] = code[i];
|
|
46
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
47
|
+
}
|
|
48
|
+
var i;
|
|
49
|
+
var len;
|
|
50
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
51
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
52
|
+
function getLens(b64) {
|
|
53
|
+
var len2 = b64.length;
|
|
54
|
+
if (len2 % 4 > 0) {
|
|
55
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
56
|
+
}
|
|
57
|
+
var validLen = b64.indexOf("=");
|
|
58
|
+
if (validLen === -1) validLen = len2;
|
|
59
|
+
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
|
|
60
|
+
return [validLen, placeHoldersLen];
|
|
61
|
+
}
|
|
62
|
+
function byteLength(b64) {
|
|
63
|
+
var lens = getLens(b64);
|
|
64
|
+
var validLen = lens[0];
|
|
65
|
+
var placeHoldersLen = lens[1];
|
|
66
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
67
|
+
}
|
|
68
|
+
function _byteLength(b64, validLen, placeHoldersLen) {
|
|
69
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
70
|
+
}
|
|
71
|
+
function toByteArray(b64) {
|
|
72
|
+
var tmp;
|
|
73
|
+
var lens = getLens(b64);
|
|
74
|
+
var validLen = lens[0];
|
|
75
|
+
var placeHoldersLen = lens[1];
|
|
76
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
77
|
+
var curByte = 0;
|
|
78
|
+
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
79
|
+
var i2;
|
|
80
|
+
for (i2 = 0; i2 < len2; i2 += 4) {
|
|
81
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
|
|
82
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
83
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
84
|
+
arr[curByte++] = tmp & 255;
|
|
85
|
+
}
|
|
86
|
+
if (placeHoldersLen === 2) {
|
|
87
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
|
|
88
|
+
arr[curByte++] = tmp & 255;
|
|
89
|
+
}
|
|
90
|
+
if (placeHoldersLen === 1) {
|
|
91
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
|
|
92
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
93
|
+
arr[curByte++] = tmp & 255;
|
|
94
|
+
}
|
|
95
|
+
return arr;
|
|
96
|
+
}
|
|
97
|
+
function tripletToBase64(num) {
|
|
98
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
99
|
+
}
|
|
100
|
+
function encodeChunk(uint8, start, end) {
|
|
101
|
+
var tmp;
|
|
102
|
+
var output = [];
|
|
103
|
+
for (var i2 = start; i2 < end; i2 += 3) {
|
|
104
|
+
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
105
|
+
output.push(tripletToBase64(tmp));
|
|
106
|
+
}
|
|
107
|
+
return output.join("");
|
|
108
|
+
}
|
|
109
|
+
function fromByteArray(uint8) {
|
|
110
|
+
var tmp;
|
|
111
|
+
var len2 = uint8.length;
|
|
112
|
+
var extraBytes = len2 % 3;
|
|
113
|
+
var parts = [];
|
|
114
|
+
var maxChunkLength = 16383;
|
|
115
|
+
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
|
|
116
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
117
|
+
}
|
|
118
|
+
if (extraBytes === 1) {
|
|
119
|
+
tmp = uint8[len2 - 1];
|
|
120
|
+
parts.push(
|
|
121
|
+
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
|
122
|
+
);
|
|
123
|
+
} else if (extraBytes === 2) {
|
|
124
|
+
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
125
|
+
parts.push(
|
|
126
|
+
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return parts.join("");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// node_modules/ieee754/index.js
|
|
135
|
+
var require_ieee754 = __commonJS({
|
|
136
|
+
"node_modules/ieee754/index.js"(exports) {
|
|
137
|
+
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
138
|
+
var e, m;
|
|
139
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
140
|
+
var eMax = (1 << eLen) - 1;
|
|
141
|
+
var eBias = eMax >> 1;
|
|
142
|
+
var nBits = -7;
|
|
143
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
144
|
+
var d = isLE ? -1 : 1;
|
|
145
|
+
var s = buffer[offset + i];
|
|
146
|
+
i += d;
|
|
147
|
+
e = s & (1 << -nBits) - 1;
|
|
148
|
+
s >>= -nBits;
|
|
149
|
+
nBits += eLen;
|
|
150
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
151
|
+
}
|
|
152
|
+
m = e & (1 << -nBits) - 1;
|
|
153
|
+
e >>= -nBits;
|
|
154
|
+
nBits += mLen;
|
|
155
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
156
|
+
}
|
|
157
|
+
if (e === 0) {
|
|
158
|
+
e = 1 - eBias;
|
|
159
|
+
} else if (e === eMax) {
|
|
160
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
161
|
+
} else {
|
|
162
|
+
m = m + Math.pow(2, mLen);
|
|
163
|
+
e = e - eBias;
|
|
164
|
+
}
|
|
165
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
166
|
+
};
|
|
167
|
+
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
168
|
+
var e, m, c2;
|
|
169
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
170
|
+
var eMax = (1 << eLen) - 1;
|
|
171
|
+
var eBias = eMax >> 1;
|
|
172
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
173
|
+
var i = isLE ? 0 : nBytes - 1;
|
|
174
|
+
var d = isLE ? 1 : -1;
|
|
175
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
176
|
+
value = Math.abs(value);
|
|
177
|
+
if (isNaN(value) || value === Infinity) {
|
|
178
|
+
m = isNaN(value) ? 1 : 0;
|
|
179
|
+
e = eMax;
|
|
180
|
+
} else {
|
|
181
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
182
|
+
if (value * (c2 = Math.pow(2, -e)) < 1) {
|
|
183
|
+
e--;
|
|
184
|
+
c2 *= 2;
|
|
185
|
+
}
|
|
186
|
+
if (e + eBias >= 1) {
|
|
187
|
+
value += rt / c2;
|
|
188
|
+
} else {
|
|
189
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
190
|
+
}
|
|
191
|
+
if (value * c2 >= 2) {
|
|
192
|
+
e++;
|
|
193
|
+
c2 /= 2;
|
|
194
|
+
}
|
|
195
|
+
if (e + eBias >= eMax) {
|
|
196
|
+
m = 0;
|
|
197
|
+
e = eMax;
|
|
198
|
+
} else if (e + eBias >= 1) {
|
|
199
|
+
m = (value * c2 - 1) * Math.pow(2, mLen);
|
|
200
|
+
e = e + eBias;
|
|
201
|
+
} else {
|
|
202
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
203
|
+
e = 0;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
207
|
+
}
|
|
208
|
+
e = e << mLen | m;
|
|
209
|
+
eLen += mLen;
|
|
210
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
211
|
+
}
|
|
212
|
+
buffer[offset + i - d] |= s * 128;
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// node_modules/buffer/index.js
|
|
218
|
+
var require_buffer = __commonJS({
|
|
219
|
+
"node_modules/buffer/index.js"(exports) {
|
|
220
|
+
"use strict";
|
|
221
|
+
var base64 = require_base64_js();
|
|
222
|
+
var ieee754 = require_ieee754();
|
|
223
|
+
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
224
|
+
exports.Buffer = Buffer3;
|
|
225
|
+
exports.SlowBuffer = SlowBuffer;
|
|
226
|
+
exports.INSPECT_MAX_BYTES = 50;
|
|
227
|
+
var K_MAX_LENGTH = 2147483647;
|
|
228
|
+
exports.kMaxLength = K_MAX_LENGTH;
|
|
229
|
+
Buffer3.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
230
|
+
if (!Buffer3.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
231
|
+
console.error(
|
|
232
|
+
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function typedArraySupport() {
|
|
236
|
+
try {
|
|
237
|
+
const arr = new Uint8Array(1);
|
|
238
|
+
const proto = { foo: function() {
|
|
239
|
+
return 42;
|
|
240
|
+
} };
|
|
241
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
242
|
+
Object.setPrototypeOf(arr, proto);
|
|
243
|
+
return arr.foo() === 42;
|
|
244
|
+
} catch (e) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
Object.defineProperty(Buffer3.prototype, "parent", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
get: function() {
|
|
251
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
252
|
+
return this.buffer;
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(Buffer3.prototype, "offset", {
|
|
256
|
+
enumerable: true,
|
|
257
|
+
get: function() {
|
|
258
|
+
if (!Buffer3.isBuffer(this)) return void 0;
|
|
259
|
+
return this.byteOffset;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
function createBuffer(length2) {
|
|
263
|
+
if (length2 > K_MAX_LENGTH) {
|
|
264
|
+
throw new RangeError('The value "' + length2 + '" is invalid for option "size"');
|
|
265
|
+
}
|
|
266
|
+
const buf = new Uint8Array(length2);
|
|
267
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
268
|
+
return buf;
|
|
269
|
+
}
|
|
270
|
+
function Buffer3(arg, encodingOrOffset, length2) {
|
|
271
|
+
if (typeof arg === "number") {
|
|
272
|
+
if (typeof encodingOrOffset === "string") {
|
|
273
|
+
throw new TypeError(
|
|
274
|
+
'The "string" argument must be of type string. Received type number'
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
return allocUnsafe(arg);
|
|
278
|
+
}
|
|
279
|
+
return from(arg, encodingOrOffset, length2);
|
|
280
|
+
}
|
|
281
|
+
Buffer3.poolSize = 8192;
|
|
282
|
+
function from(value, encodingOrOffset, length2) {
|
|
283
|
+
if (typeof value === "string") {
|
|
284
|
+
return fromString(value, encodingOrOffset);
|
|
285
|
+
}
|
|
286
|
+
if (ArrayBuffer.isView(value)) {
|
|
287
|
+
return fromArrayView(value);
|
|
288
|
+
}
|
|
289
|
+
if (value == null) {
|
|
290
|
+
throw new TypeError(
|
|
291
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
|
|
295
|
+
return fromArrayBuffer(value, encodingOrOffset, length2);
|
|
296
|
+
}
|
|
297
|
+
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
|
|
298
|
+
return fromArrayBuffer(value, encodingOrOffset, length2);
|
|
299
|
+
}
|
|
300
|
+
if (typeof value === "number") {
|
|
301
|
+
throw new TypeError(
|
|
302
|
+
'The "value" argument must not be of type number. Received type number'
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
306
|
+
if (valueOf != null && valueOf !== value) {
|
|
307
|
+
return Buffer3.from(valueOf, encodingOrOffset, length2);
|
|
308
|
+
}
|
|
309
|
+
const b = fromObject(value);
|
|
310
|
+
if (b) return b;
|
|
311
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
312
|
+
return Buffer3.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length2);
|
|
313
|
+
}
|
|
314
|
+
throw new TypeError(
|
|
315
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
Buffer3.from = function(value, encodingOrOffset, length2) {
|
|
319
|
+
return from(value, encodingOrOffset, length2);
|
|
320
|
+
};
|
|
321
|
+
Object.setPrototypeOf(Buffer3.prototype, Uint8Array.prototype);
|
|
322
|
+
Object.setPrototypeOf(Buffer3, Uint8Array);
|
|
323
|
+
function assertSize(size) {
|
|
324
|
+
if (typeof size !== "number") {
|
|
325
|
+
throw new TypeError('"size" argument must be of type number');
|
|
326
|
+
} else if (size < 0) {
|
|
327
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function alloc(size, fill3, encoding) {
|
|
331
|
+
assertSize(size);
|
|
332
|
+
if (size <= 0) {
|
|
333
|
+
return createBuffer(size);
|
|
334
|
+
}
|
|
335
|
+
if (fill3 !== void 0) {
|
|
336
|
+
return typeof encoding === "string" ? createBuffer(size).fill(fill3, encoding) : createBuffer(size).fill(fill3);
|
|
337
|
+
}
|
|
338
|
+
return createBuffer(size);
|
|
339
|
+
}
|
|
340
|
+
Buffer3.alloc = function(size, fill3, encoding) {
|
|
341
|
+
return alloc(size, fill3, encoding);
|
|
342
|
+
};
|
|
343
|
+
function allocUnsafe(size) {
|
|
344
|
+
assertSize(size);
|
|
345
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
|
346
|
+
}
|
|
347
|
+
Buffer3.allocUnsafe = function(size) {
|
|
348
|
+
return allocUnsafe(size);
|
|
349
|
+
};
|
|
350
|
+
Buffer3.allocUnsafeSlow = function(size) {
|
|
351
|
+
return allocUnsafe(size);
|
|
352
|
+
};
|
|
353
|
+
function fromString(string2, encoding) {
|
|
354
|
+
if (typeof encoding !== "string" || encoding === "") {
|
|
355
|
+
encoding = "utf8";
|
|
356
|
+
}
|
|
357
|
+
if (!Buffer3.isEncoding(encoding)) {
|
|
358
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
359
|
+
}
|
|
360
|
+
const length2 = byteLength(string2, encoding) | 0;
|
|
361
|
+
let buf = createBuffer(length2);
|
|
362
|
+
const actual = buf.write(string2, encoding);
|
|
363
|
+
if (actual !== length2) {
|
|
364
|
+
buf = buf.slice(0, actual);
|
|
365
|
+
}
|
|
366
|
+
return buf;
|
|
367
|
+
}
|
|
368
|
+
function fromArrayLike(array2) {
|
|
369
|
+
const length2 = array2.length < 0 ? 0 : checked(array2.length) | 0;
|
|
370
|
+
const buf = createBuffer(length2);
|
|
371
|
+
for (let i = 0; i < length2; i += 1) {
|
|
372
|
+
buf[i] = array2[i] & 255;
|
|
373
|
+
}
|
|
374
|
+
return buf;
|
|
375
|
+
}
|
|
376
|
+
function fromArrayView(arrayView) {
|
|
377
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
378
|
+
const copy = new Uint8Array(arrayView);
|
|
379
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
|
380
|
+
}
|
|
381
|
+
return fromArrayLike(arrayView);
|
|
382
|
+
}
|
|
383
|
+
function fromArrayBuffer(array2, byteOffset, length2) {
|
|
384
|
+
if (byteOffset < 0 || array2.byteLength < byteOffset) {
|
|
385
|
+
throw new RangeError('"offset" is outside of buffer bounds');
|
|
386
|
+
}
|
|
387
|
+
if (array2.byteLength < byteOffset + (length2 || 0)) {
|
|
388
|
+
throw new RangeError('"length" is outside of buffer bounds');
|
|
389
|
+
}
|
|
390
|
+
let buf;
|
|
391
|
+
if (byteOffset === void 0 && length2 === void 0) {
|
|
392
|
+
buf = new Uint8Array(array2);
|
|
393
|
+
} else if (length2 === void 0) {
|
|
394
|
+
buf = new Uint8Array(array2, byteOffset);
|
|
395
|
+
} else {
|
|
396
|
+
buf = new Uint8Array(array2, byteOffset, length2);
|
|
397
|
+
}
|
|
398
|
+
Object.setPrototypeOf(buf, Buffer3.prototype);
|
|
399
|
+
return buf;
|
|
400
|
+
}
|
|
401
|
+
function fromObject(obj) {
|
|
402
|
+
if (Buffer3.isBuffer(obj)) {
|
|
403
|
+
const len = checked(obj.length) | 0;
|
|
404
|
+
const buf = createBuffer(len);
|
|
405
|
+
if (buf.length === 0) {
|
|
406
|
+
return buf;
|
|
407
|
+
}
|
|
408
|
+
obj.copy(buf, 0, 0, len);
|
|
409
|
+
return buf;
|
|
410
|
+
}
|
|
411
|
+
if (obj.length !== void 0) {
|
|
412
|
+
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
|
413
|
+
return createBuffer(0);
|
|
414
|
+
}
|
|
415
|
+
return fromArrayLike(obj);
|
|
416
|
+
}
|
|
417
|
+
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
418
|
+
return fromArrayLike(obj.data);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function checked(length2) {
|
|
422
|
+
if (length2 >= K_MAX_LENGTH) {
|
|
423
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
|
424
|
+
}
|
|
425
|
+
return length2 | 0;
|
|
426
|
+
}
|
|
427
|
+
function SlowBuffer(length2) {
|
|
428
|
+
if (+length2 != length2) {
|
|
429
|
+
length2 = 0;
|
|
430
|
+
}
|
|
431
|
+
return Buffer3.alloc(+length2);
|
|
432
|
+
}
|
|
433
|
+
Buffer3.isBuffer = function isBuffer(b) {
|
|
434
|
+
return b != null && b._isBuffer === true && b !== Buffer3.prototype;
|
|
435
|
+
};
|
|
436
|
+
Buffer3.compare = function compare(a, b) {
|
|
437
|
+
if (isInstance(a, Uint8Array)) a = Buffer3.from(a, a.offset, a.byteLength);
|
|
438
|
+
if (isInstance(b, Uint8Array)) b = Buffer3.from(b, b.offset, b.byteLength);
|
|
439
|
+
if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
|
|
440
|
+
throw new TypeError(
|
|
441
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
if (a === b) return 0;
|
|
445
|
+
let x = a.length;
|
|
446
|
+
let y = b.length;
|
|
447
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
448
|
+
if (a[i] !== b[i]) {
|
|
449
|
+
x = a[i];
|
|
450
|
+
y = b[i];
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (x < y) return -1;
|
|
455
|
+
if (y < x) return 1;
|
|
456
|
+
return 0;
|
|
457
|
+
};
|
|
458
|
+
Buffer3.isEncoding = function isEncoding(encoding) {
|
|
459
|
+
switch (String(encoding).toLowerCase()) {
|
|
460
|
+
case "hex":
|
|
461
|
+
case "utf8":
|
|
462
|
+
case "utf-8":
|
|
463
|
+
case "ascii":
|
|
464
|
+
case "latin1":
|
|
465
|
+
case "binary":
|
|
466
|
+
case "base64":
|
|
467
|
+
case "ucs2":
|
|
468
|
+
case "ucs-2":
|
|
469
|
+
case "utf16le":
|
|
470
|
+
case "utf-16le":
|
|
471
|
+
return true;
|
|
472
|
+
default:
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
Buffer3.concat = function concat3(list, length2) {
|
|
477
|
+
if (!Array.isArray(list)) {
|
|
478
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
479
|
+
}
|
|
480
|
+
if (list.length === 0) {
|
|
481
|
+
return Buffer3.alloc(0);
|
|
482
|
+
}
|
|
483
|
+
let i;
|
|
484
|
+
if (length2 === void 0) {
|
|
485
|
+
length2 = 0;
|
|
486
|
+
for (i = 0; i < list.length; ++i) {
|
|
487
|
+
length2 += list[i].length;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const buffer = Buffer3.allocUnsafe(length2);
|
|
491
|
+
let pos = 0;
|
|
492
|
+
for (i = 0; i < list.length; ++i) {
|
|
493
|
+
let buf = list[i];
|
|
494
|
+
if (isInstance(buf, Uint8Array)) {
|
|
495
|
+
if (pos + buf.length > buffer.length) {
|
|
496
|
+
if (!Buffer3.isBuffer(buf)) buf = Buffer3.from(buf);
|
|
497
|
+
buf.copy(buffer, pos);
|
|
498
|
+
} else {
|
|
499
|
+
Uint8Array.prototype.set.call(
|
|
500
|
+
buffer,
|
|
501
|
+
buf,
|
|
502
|
+
pos
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
} else if (!Buffer3.isBuffer(buf)) {
|
|
506
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
507
|
+
} else {
|
|
508
|
+
buf.copy(buffer, pos);
|
|
509
|
+
}
|
|
510
|
+
pos += buf.length;
|
|
511
|
+
}
|
|
512
|
+
return buffer;
|
|
513
|
+
};
|
|
514
|
+
function byteLength(string2, encoding) {
|
|
515
|
+
if (Buffer3.isBuffer(string2)) {
|
|
516
|
+
return string2.length;
|
|
517
|
+
}
|
|
518
|
+
if (ArrayBuffer.isView(string2) || isInstance(string2, ArrayBuffer)) {
|
|
519
|
+
return string2.byteLength;
|
|
520
|
+
}
|
|
521
|
+
if (typeof string2 !== "string") {
|
|
522
|
+
throw new TypeError(
|
|
523
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string2
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
const len = string2.length;
|
|
527
|
+
const mustMatch = arguments.length > 2 && arguments[2] === true;
|
|
528
|
+
if (!mustMatch && len === 0) return 0;
|
|
529
|
+
let loweredCase = false;
|
|
530
|
+
for (; ; ) {
|
|
531
|
+
switch (encoding) {
|
|
532
|
+
case "ascii":
|
|
533
|
+
case "latin1":
|
|
534
|
+
case "binary":
|
|
535
|
+
return len;
|
|
536
|
+
case "utf8":
|
|
537
|
+
case "utf-8":
|
|
538
|
+
return utf8ToBytes(string2).length;
|
|
539
|
+
case "ucs2":
|
|
540
|
+
case "ucs-2":
|
|
541
|
+
case "utf16le":
|
|
542
|
+
case "utf-16le":
|
|
543
|
+
return len * 2;
|
|
544
|
+
case "hex":
|
|
545
|
+
return len >>> 1;
|
|
546
|
+
case "base64":
|
|
547
|
+
return base64ToBytes(string2).length;
|
|
548
|
+
default:
|
|
549
|
+
if (loweredCase) {
|
|
550
|
+
return mustMatch ? -1 : utf8ToBytes(string2).length;
|
|
551
|
+
}
|
|
552
|
+
encoding = ("" + encoding).toLowerCase();
|
|
553
|
+
loweredCase = true;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
Buffer3.byteLength = byteLength;
|
|
558
|
+
function slowToString(encoding, start, end) {
|
|
559
|
+
let loweredCase = false;
|
|
560
|
+
if (start === void 0 || start < 0) {
|
|
561
|
+
start = 0;
|
|
562
|
+
}
|
|
563
|
+
if (start > this.length) {
|
|
564
|
+
return "";
|
|
565
|
+
}
|
|
566
|
+
if (end === void 0 || end > this.length) {
|
|
567
|
+
end = this.length;
|
|
568
|
+
}
|
|
569
|
+
if (end <= 0) {
|
|
570
|
+
return "";
|
|
571
|
+
}
|
|
572
|
+
end >>>= 0;
|
|
573
|
+
start >>>= 0;
|
|
574
|
+
if (end <= start) {
|
|
575
|
+
return "";
|
|
576
|
+
}
|
|
577
|
+
if (!encoding) encoding = "utf8";
|
|
578
|
+
while (true) {
|
|
579
|
+
switch (encoding) {
|
|
580
|
+
case "hex":
|
|
581
|
+
return hexSlice(this, start, end);
|
|
582
|
+
case "utf8":
|
|
583
|
+
case "utf-8":
|
|
584
|
+
return utf8Slice(this, start, end);
|
|
585
|
+
case "ascii":
|
|
586
|
+
return asciiSlice(this, start, end);
|
|
587
|
+
case "latin1":
|
|
588
|
+
case "binary":
|
|
589
|
+
return latin1Slice(this, start, end);
|
|
590
|
+
case "base64":
|
|
591
|
+
return base64Slice(this, start, end);
|
|
592
|
+
case "ucs2":
|
|
593
|
+
case "ucs-2":
|
|
594
|
+
case "utf16le":
|
|
595
|
+
case "utf-16le":
|
|
596
|
+
return utf16leSlice(this, start, end);
|
|
597
|
+
default:
|
|
598
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
599
|
+
encoding = (encoding + "").toLowerCase();
|
|
600
|
+
loweredCase = true;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
Buffer3.prototype._isBuffer = true;
|
|
605
|
+
function swap(b, n, m) {
|
|
606
|
+
const i = b[n];
|
|
607
|
+
b[n] = b[m];
|
|
608
|
+
b[m] = i;
|
|
609
|
+
}
|
|
610
|
+
Buffer3.prototype.swap16 = function swap16() {
|
|
611
|
+
const len = this.length;
|
|
612
|
+
if (len % 2 !== 0) {
|
|
613
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
614
|
+
}
|
|
615
|
+
for (let i = 0; i < len; i += 2) {
|
|
616
|
+
swap(this, i, i + 1);
|
|
617
|
+
}
|
|
618
|
+
return this;
|
|
619
|
+
};
|
|
620
|
+
Buffer3.prototype.swap32 = function swap32() {
|
|
621
|
+
const len = this.length;
|
|
622
|
+
if (len % 4 !== 0) {
|
|
623
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
624
|
+
}
|
|
625
|
+
for (let i = 0; i < len; i += 4) {
|
|
626
|
+
swap(this, i, i + 3);
|
|
627
|
+
swap(this, i + 1, i + 2);
|
|
628
|
+
}
|
|
629
|
+
return this;
|
|
630
|
+
};
|
|
631
|
+
Buffer3.prototype.swap64 = function swap64() {
|
|
632
|
+
const len = this.length;
|
|
633
|
+
if (len % 8 !== 0) {
|
|
634
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
635
|
+
}
|
|
636
|
+
for (let i = 0; i < len; i += 8) {
|
|
637
|
+
swap(this, i, i + 7);
|
|
638
|
+
swap(this, i + 1, i + 6);
|
|
639
|
+
swap(this, i + 2, i + 5);
|
|
640
|
+
swap(this, i + 3, i + 4);
|
|
641
|
+
}
|
|
642
|
+
return this;
|
|
643
|
+
};
|
|
644
|
+
Buffer3.prototype.toString = function toString3() {
|
|
645
|
+
const length2 = this.length;
|
|
646
|
+
if (length2 === 0) return "";
|
|
647
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length2);
|
|
648
|
+
return slowToString.apply(this, arguments);
|
|
649
|
+
};
|
|
650
|
+
Buffer3.prototype.toLocaleString = Buffer3.prototype.toString;
|
|
651
|
+
Buffer3.prototype.equals = function equals(b) {
|
|
652
|
+
if (!Buffer3.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
653
|
+
if (this === b) return true;
|
|
654
|
+
return Buffer3.compare(this, b) === 0;
|
|
655
|
+
};
|
|
656
|
+
Buffer3.prototype.inspect = function inspect() {
|
|
657
|
+
let str = "";
|
|
658
|
+
const max2 = exports.INSPECT_MAX_BYTES;
|
|
659
|
+
str = this.toString("hex", 0, max2).replace(/(.{2})/g, "$1 ").trim();
|
|
660
|
+
if (this.length > max2) str += " ... ";
|
|
661
|
+
return "<Buffer " + str + ">";
|
|
662
|
+
};
|
|
663
|
+
if (customInspectSymbol) {
|
|
664
|
+
Buffer3.prototype[customInspectSymbol] = Buffer3.prototype.inspect;
|
|
665
|
+
}
|
|
666
|
+
Buffer3.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
667
|
+
if (isInstance(target, Uint8Array)) {
|
|
668
|
+
target = Buffer3.from(target, target.offset, target.byteLength);
|
|
669
|
+
}
|
|
670
|
+
if (!Buffer3.isBuffer(target)) {
|
|
671
|
+
throw new TypeError(
|
|
672
|
+
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
if (start === void 0) {
|
|
676
|
+
start = 0;
|
|
677
|
+
}
|
|
678
|
+
if (end === void 0) {
|
|
679
|
+
end = target ? target.length : 0;
|
|
680
|
+
}
|
|
681
|
+
if (thisStart === void 0) {
|
|
682
|
+
thisStart = 0;
|
|
683
|
+
}
|
|
684
|
+
if (thisEnd === void 0) {
|
|
685
|
+
thisEnd = this.length;
|
|
686
|
+
}
|
|
687
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
688
|
+
throw new RangeError("out of range index");
|
|
689
|
+
}
|
|
690
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
691
|
+
return 0;
|
|
692
|
+
}
|
|
693
|
+
if (thisStart >= thisEnd) {
|
|
694
|
+
return -1;
|
|
695
|
+
}
|
|
696
|
+
if (start >= end) {
|
|
697
|
+
return 1;
|
|
698
|
+
}
|
|
699
|
+
start >>>= 0;
|
|
700
|
+
end >>>= 0;
|
|
701
|
+
thisStart >>>= 0;
|
|
702
|
+
thisEnd >>>= 0;
|
|
703
|
+
if (this === target) return 0;
|
|
704
|
+
let x = thisEnd - thisStart;
|
|
705
|
+
let y = end - start;
|
|
706
|
+
const len = Math.min(x, y);
|
|
707
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
708
|
+
const targetCopy = target.slice(start, end);
|
|
709
|
+
for (let i = 0; i < len; ++i) {
|
|
710
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
711
|
+
x = thisCopy[i];
|
|
712
|
+
y = targetCopy[i];
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
if (x < y) return -1;
|
|
717
|
+
if (y < x) return 1;
|
|
718
|
+
return 0;
|
|
719
|
+
};
|
|
720
|
+
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
721
|
+
if (buffer.length === 0) return -1;
|
|
722
|
+
if (typeof byteOffset === "string") {
|
|
723
|
+
encoding = byteOffset;
|
|
724
|
+
byteOffset = 0;
|
|
725
|
+
} else if (byteOffset > 2147483647) {
|
|
726
|
+
byteOffset = 2147483647;
|
|
727
|
+
} else if (byteOffset < -2147483648) {
|
|
728
|
+
byteOffset = -2147483648;
|
|
729
|
+
}
|
|
730
|
+
byteOffset = +byteOffset;
|
|
731
|
+
if (numberIsNaN(byteOffset)) {
|
|
732
|
+
byteOffset = dir ? 0 : buffer.length - 1;
|
|
733
|
+
}
|
|
734
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
735
|
+
if (byteOffset >= buffer.length) {
|
|
736
|
+
if (dir) return -1;
|
|
737
|
+
else byteOffset = buffer.length - 1;
|
|
738
|
+
} else if (byteOffset < 0) {
|
|
739
|
+
if (dir) byteOffset = 0;
|
|
740
|
+
else return -1;
|
|
741
|
+
}
|
|
742
|
+
if (typeof val === "string") {
|
|
743
|
+
val = Buffer3.from(val, encoding);
|
|
744
|
+
}
|
|
745
|
+
if (Buffer3.isBuffer(val)) {
|
|
746
|
+
if (val.length === 0) {
|
|
747
|
+
return -1;
|
|
748
|
+
}
|
|
749
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
750
|
+
} else if (typeof val === "number") {
|
|
751
|
+
val = val & 255;
|
|
752
|
+
if (typeof Uint8Array.prototype.indexOf === "function") {
|
|
753
|
+
if (dir) {
|
|
754
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
755
|
+
} else {
|
|
756
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
760
|
+
}
|
|
761
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
762
|
+
}
|
|
763
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
764
|
+
let indexSize = 1;
|
|
765
|
+
let arrLength = arr.length;
|
|
766
|
+
let valLength = val.length;
|
|
767
|
+
if (encoding !== void 0) {
|
|
768
|
+
encoding = String(encoding).toLowerCase();
|
|
769
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
770
|
+
if (arr.length < 2 || val.length < 2) {
|
|
771
|
+
return -1;
|
|
772
|
+
}
|
|
773
|
+
indexSize = 2;
|
|
774
|
+
arrLength /= 2;
|
|
775
|
+
valLength /= 2;
|
|
776
|
+
byteOffset /= 2;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
function read(buf, i2) {
|
|
780
|
+
if (indexSize === 1) {
|
|
781
|
+
return buf[i2];
|
|
782
|
+
} else {
|
|
783
|
+
return buf.readUInt16BE(i2 * indexSize);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
let i;
|
|
787
|
+
if (dir) {
|
|
788
|
+
let foundIndex = -1;
|
|
789
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
790
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
791
|
+
if (foundIndex === -1) foundIndex = i;
|
|
792
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
793
|
+
} else {
|
|
794
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
795
|
+
foundIndex = -1;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
} else {
|
|
799
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
800
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
801
|
+
let found = true;
|
|
802
|
+
for (let j = 0; j < valLength; j++) {
|
|
803
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
804
|
+
found = false;
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (found) return i;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return -1;
|
|
812
|
+
}
|
|
813
|
+
Buffer3.prototype.includes = function includes4(val, byteOffset, encoding) {
|
|
814
|
+
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
815
|
+
};
|
|
816
|
+
Buffer3.prototype.indexOf = function indexOf3(val, byteOffset, encoding) {
|
|
817
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
818
|
+
};
|
|
819
|
+
Buffer3.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
820
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
821
|
+
};
|
|
822
|
+
function hexWrite(buf, string2, offset, length2) {
|
|
823
|
+
offset = Number(offset) || 0;
|
|
824
|
+
const remaining = buf.length - offset;
|
|
825
|
+
if (!length2) {
|
|
826
|
+
length2 = remaining;
|
|
827
|
+
} else {
|
|
828
|
+
length2 = Number(length2);
|
|
829
|
+
if (length2 > remaining) {
|
|
830
|
+
length2 = remaining;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
const strLen = string2.length;
|
|
834
|
+
if (length2 > strLen / 2) {
|
|
835
|
+
length2 = strLen / 2;
|
|
836
|
+
}
|
|
837
|
+
let i;
|
|
838
|
+
for (i = 0; i < length2; ++i) {
|
|
839
|
+
const parsed = parseInt(string2.substr(i * 2, 2), 16);
|
|
840
|
+
if (numberIsNaN(parsed)) return i;
|
|
841
|
+
buf[offset + i] = parsed;
|
|
842
|
+
}
|
|
843
|
+
return i;
|
|
844
|
+
}
|
|
845
|
+
function utf8Write(buf, string2, offset, length2) {
|
|
846
|
+
return blitBuffer(utf8ToBytes(string2, buf.length - offset), buf, offset, length2);
|
|
847
|
+
}
|
|
848
|
+
function asciiWrite(buf, string2, offset, length2) {
|
|
849
|
+
return blitBuffer(asciiToBytes(string2), buf, offset, length2);
|
|
850
|
+
}
|
|
851
|
+
function base64Write(buf, string2, offset, length2) {
|
|
852
|
+
return blitBuffer(base64ToBytes(string2), buf, offset, length2);
|
|
853
|
+
}
|
|
854
|
+
function ucs2Write(buf, string2, offset, length2) {
|
|
855
|
+
return blitBuffer(utf16leToBytes(string2, buf.length - offset), buf, offset, length2);
|
|
856
|
+
}
|
|
857
|
+
Buffer3.prototype.write = function write(string2, offset, length2, encoding) {
|
|
858
|
+
if (offset === void 0) {
|
|
859
|
+
encoding = "utf8";
|
|
860
|
+
length2 = this.length;
|
|
861
|
+
offset = 0;
|
|
862
|
+
} else if (length2 === void 0 && typeof offset === "string") {
|
|
863
|
+
encoding = offset;
|
|
864
|
+
length2 = this.length;
|
|
865
|
+
offset = 0;
|
|
866
|
+
} else if (isFinite(offset)) {
|
|
867
|
+
offset = offset >>> 0;
|
|
868
|
+
if (isFinite(length2)) {
|
|
869
|
+
length2 = length2 >>> 0;
|
|
870
|
+
if (encoding === void 0) encoding = "utf8";
|
|
871
|
+
} else {
|
|
872
|
+
encoding = length2;
|
|
873
|
+
length2 = void 0;
|
|
874
|
+
}
|
|
875
|
+
} else {
|
|
876
|
+
throw new Error(
|
|
877
|
+
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
const remaining = this.length - offset;
|
|
881
|
+
if (length2 === void 0 || length2 > remaining) length2 = remaining;
|
|
882
|
+
if (string2.length > 0 && (length2 < 0 || offset < 0) || offset > this.length) {
|
|
883
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
884
|
+
}
|
|
885
|
+
if (!encoding) encoding = "utf8";
|
|
886
|
+
let loweredCase = false;
|
|
887
|
+
for (; ; ) {
|
|
888
|
+
switch (encoding) {
|
|
889
|
+
case "hex":
|
|
890
|
+
return hexWrite(this, string2, offset, length2);
|
|
891
|
+
case "utf8":
|
|
892
|
+
case "utf-8":
|
|
893
|
+
return utf8Write(this, string2, offset, length2);
|
|
894
|
+
case "ascii":
|
|
895
|
+
case "latin1":
|
|
896
|
+
case "binary":
|
|
897
|
+
return asciiWrite(this, string2, offset, length2);
|
|
898
|
+
case "base64":
|
|
899
|
+
return base64Write(this, string2, offset, length2);
|
|
900
|
+
case "ucs2":
|
|
901
|
+
case "ucs-2":
|
|
902
|
+
case "utf16le":
|
|
903
|
+
case "utf-16le":
|
|
904
|
+
return ucs2Write(this, string2, offset, length2);
|
|
905
|
+
default:
|
|
906
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
907
|
+
encoding = ("" + encoding).toLowerCase();
|
|
908
|
+
loweredCase = true;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
Buffer3.prototype.toJSON = function toJSON() {
|
|
913
|
+
return {
|
|
914
|
+
type: "Buffer",
|
|
915
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
function base64Slice(buf, start, end) {
|
|
919
|
+
if (start === 0 && end === buf.length) {
|
|
920
|
+
return base64.fromByteArray(buf);
|
|
921
|
+
} else {
|
|
922
|
+
return base64.fromByteArray(buf.slice(start, end));
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
function utf8Slice(buf, start, end) {
|
|
926
|
+
end = Math.min(buf.length, end);
|
|
927
|
+
const res = [];
|
|
928
|
+
let i = start;
|
|
929
|
+
while (i < end) {
|
|
930
|
+
const firstByte = buf[i];
|
|
931
|
+
let codePoint = null;
|
|
932
|
+
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
933
|
+
if (i + bytesPerSequence <= end) {
|
|
934
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
935
|
+
switch (bytesPerSequence) {
|
|
936
|
+
case 1:
|
|
937
|
+
if (firstByte < 128) {
|
|
938
|
+
codePoint = firstByte;
|
|
939
|
+
}
|
|
940
|
+
break;
|
|
941
|
+
case 2:
|
|
942
|
+
secondByte = buf[i + 1];
|
|
943
|
+
if ((secondByte & 192) === 128) {
|
|
944
|
+
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
945
|
+
if (tempCodePoint > 127) {
|
|
946
|
+
codePoint = tempCodePoint;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
break;
|
|
950
|
+
case 3:
|
|
951
|
+
secondByte = buf[i + 1];
|
|
952
|
+
thirdByte = buf[i + 2];
|
|
953
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
954
|
+
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
955
|
+
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
956
|
+
codePoint = tempCodePoint;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
break;
|
|
960
|
+
case 4:
|
|
961
|
+
secondByte = buf[i + 1];
|
|
962
|
+
thirdByte = buf[i + 2];
|
|
963
|
+
fourthByte = buf[i + 3];
|
|
964
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
965
|
+
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
966
|
+
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
967
|
+
codePoint = tempCodePoint;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (codePoint === null) {
|
|
973
|
+
codePoint = 65533;
|
|
974
|
+
bytesPerSequence = 1;
|
|
975
|
+
} else if (codePoint > 65535) {
|
|
976
|
+
codePoint -= 65536;
|
|
977
|
+
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
978
|
+
codePoint = 56320 | codePoint & 1023;
|
|
979
|
+
}
|
|
980
|
+
res.push(codePoint);
|
|
981
|
+
i += bytesPerSequence;
|
|
982
|
+
}
|
|
983
|
+
return decodeCodePointsArray(res);
|
|
984
|
+
}
|
|
985
|
+
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
986
|
+
function decodeCodePointsArray(codePoints) {
|
|
987
|
+
const len = codePoints.length;
|
|
988
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
989
|
+
return String.fromCharCode.apply(String, codePoints);
|
|
990
|
+
}
|
|
991
|
+
let res = "";
|
|
992
|
+
let i = 0;
|
|
993
|
+
while (i < len) {
|
|
994
|
+
res += String.fromCharCode.apply(
|
|
995
|
+
String,
|
|
996
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
return res;
|
|
1000
|
+
}
|
|
1001
|
+
function asciiSlice(buf, start, end) {
|
|
1002
|
+
let ret = "";
|
|
1003
|
+
end = Math.min(buf.length, end);
|
|
1004
|
+
for (let i = start; i < end; ++i) {
|
|
1005
|
+
ret += String.fromCharCode(buf[i] & 127);
|
|
1006
|
+
}
|
|
1007
|
+
return ret;
|
|
1008
|
+
}
|
|
1009
|
+
function latin1Slice(buf, start, end) {
|
|
1010
|
+
let ret = "";
|
|
1011
|
+
end = Math.min(buf.length, end);
|
|
1012
|
+
for (let i = start; i < end; ++i) {
|
|
1013
|
+
ret += String.fromCharCode(buf[i]);
|
|
1014
|
+
}
|
|
1015
|
+
return ret;
|
|
1016
|
+
}
|
|
1017
|
+
function hexSlice(buf, start, end) {
|
|
1018
|
+
const len = buf.length;
|
|
1019
|
+
if (!start || start < 0) start = 0;
|
|
1020
|
+
if (!end || end < 0 || end > len) end = len;
|
|
1021
|
+
let out = "";
|
|
1022
|
+
for (let i = start; i < end; ++i) {
|
|
1023
|
+
out += hexSliceLookupTable[buf[i]];
|
|
1024
|
+
}
|
|
1025
|
+
return out;
|
|
1026
|
+
}
|
|
1027
|
+
function utf16leSlice(buf, start, end) {
|
|
1028
|
+
const bytes = buf.slice(start, end);
|
|
1029
|
+
let res = "";
|
|
1030
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
1031
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
1032
|
+
}
|
|
1033
|
+
return res;
|
|
1034
|
+
}
|
|
1035
|
+
Buffer3.prototype.slice = function slice3(start, end) {
|
|
1036
|
+
const len = this.length;
|
|
1037
|
+
start = ~~start;
|
|
1038
|
+
end = end === void 0 ? len : ~~end;
|
|
1039
|
+
if (start < 0) {
|
|
1040
|
+
start += len;
|
|
1041
|
+
if (start < 0) start = 0;
|
|
1042
|
+
} else if (start > len) {
|
|
1043
|
+
start = len;
|
|
1044
|
+
}
|
|
1045
|
+
if (end < 0) {
|
|
1046
|
+
end += len;
|
|
1047
|
+
if (end < 0) end = 0;
|
|
1048
|
+
} else if (end > len) {
|
|
1049
|
+
end = len;
|
|
1050
|
+
}
|
|
1051
|
+
if (end < start) end = start;
|
|
1052
|
+
const newBuf = this.subarray(start, end);
|
|
1053
|
+
Object.setPrototypeOf(newBuf, Buffer3.prototype);
|
|
1054
|
+
return newBuf;
|
|
1055
|
+
};
|
|
1056
|
+
function checkOffset(offset, ext, length2) {
|
|
1057
|
+
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
1058
|
+
if (offset + ext > length2) throw new RangeError("Trying to access beyond buffer length");
|
|
1059
|
+
}
|
|
1060
|
+
Buffer3.prototype.readUintLE = Buffer3.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
1061
|
+
offset = offset >>> 0;
|
|
1062
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1063
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1064
|
+
let val = this[offset];
|
|
1065
|
+
let mul = 1;
|
|
1066
|
+
let i = 0;
|
|
1067
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1068
|
+
val += this[offset + i] * mul;
|
|
1069
|
+
}
|
|
1070
|
+
return val;
|
|
1071
|
+
};
|
|
1072
|
+
Buffer3.prototype.readUintBE = Buffer3.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
1073
|
+
offset = offset >>> 0;
|
|
1074
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1075
|
+
if (!noAssert) {
|
|
1076
|
+
checkOffset(offset, byteLength2, this.length);
|
|
1077
|
+
}
|
|
1078
|
+
let val = this[offset + --byteLength2];
|
|
1079
|
+
let mul = 1;
|
|
1080
|
+
while (byteLength2 > 0 && (mul *= 256)) {
|
|
1081
|
+
val += this[offset + --byteLength2] * mul;
|
|
1082
|
+
}
|
|
1083
|
+
return val;
|
|
1084
|
+
};
|
|
1085
|
+
Buffer3.prototype.readUint8 = Buffer3.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1086
|
+
offset = offset >>> 0;
|
|
1087
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1088
|
+
return this[offset];
|
|
1089
|
+
};
|
|
1090
|
+
Buffer3.prototype.readUint16LE = Buffer3.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1091
|
+
offset = offset >>> 0;
|
|
1092
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1093
|
+
return this[offset] | this[offset + 1] << 8;
|
|
1094
|
+
};
|
|
1095
|
+
Buffer3.prototype.readUint16BE = Buffer3.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1096
|
+
offset = offset >>> 0;
|
|
1097
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1098
|
+
return this[offset] << 8 | this[offset + 1];
|
|
1099
|
+
};
|
|
1100
|
+
Buffer3.prototype.readUint32LE = Buffer3.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1101
|
+
offset = offset >>> 0;
|
|
1102
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1103
|
+
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1104
|
+
};
|
|
1105
|
+
Buffer3.prototype.readUint32BE = Buffer3.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1106
|
+
offset = offset >>> 0;
|
|
1107
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1108
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1109
|
+
};
|
|
1110
|
+
Buffer3.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
|
1111
|
+
offset = offset >>> 0;
|
|
1112
|
+
validateNumber(offset, "offset");
|
|
1113
|
+
const first2 = this[offset];
|
|
1114
|
+
const last = this[offset + 7];
|
|
1115
|
+
if (first2 === void 0 || last === void 0) {
|
|
1116
|
+
boundsError(offset, this.length - 8);
|
|
1117
|
+
}
|
|
1118
|
+
const lo = first2 + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
|
|
1119
|
+
const hi2 = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
|
|
1120
|
+
return BigInt(lo) + (BigInt(hi2) << BigInt(32));
|
|
1121
|
+
});
|
|
1122
|
+
Buffer3.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
|
1123
|
+
offset = offset >>> 0;
|
|
1124
|
+
validateNumber(offset, "offset");
|
|
1125
|
+
const first2 = this[offset];
|
|
1126
|
+
const last = this[offset + 7];
|
|
1127
|
+
if (first2 === void 0 || last === void 0) {
|
|
1128
|
+
boundsError(offset, this.length - 8);
|
|
1129
|
+
}
|
|
1130
|
+
const hi2 = first2 * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1131
|
+
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
|
|
1132
|
+
return (BigInt(hi2) << BigInt(32)) + BigInt(lo);
|
|
1133
|
+
});
|
|
1134
|
+
Buffer3.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
1135
|
+
offset = offset >>> 0;
|
|
1136
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1137
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1138
|
+
let val = this[offset];
|
|
1139
|
+
let mul = 1;
|
|
1140
|
+
let i = 0;
|
|
1141
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1142
|
+
val += this[offset + i] * mul;
|
|
1143
|
+
}
|
|
1144
|
+
mul *= 128;
|
|
1145
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1146
|
+
return val;
|
|
1147
|
+
};
|
|
1148
|
+
Buffer3.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
1149
|
+
offset = offset >>> 0;
|
|
1150
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1151
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1152
|
+
let i = byteLength2;
|
|
1153
|
+
let mul = 1;
|
|
1154
|
+
let val = this[offset + --i];
|
|
1155
|
+
while (i > 0 && (mul *= 256)) {
|
|
1156
|
+
val += this[offset + --i] * mul;
|
|
1157
|
+
}
|
|
1158
|
+
mul *= 128;
|
|
1159
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1160
|
+
return val;
|
|
1161
|
+
};
|
|
1162
|
+
Buffer3.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1163
|
+
offset = offset >>> 0;
|
|
1164
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1165
|
+
if (!(this[offset] & 128)) return this[offset];
|
|
1166
|
+
return (255 - this[offset] + 1) * -1;
|
|
1167
|
+
};
|
|
1168
|
+
Buffer3.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1169
|
+
offset = offset >>> 0;
|
|
1170
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1171
|
+
const val = this[offset] | this[offset + 1] << 8;
|
|
1172
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1173
|
+
};
|
|
1174
|
+
Buffer3.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1175
|
+
offset = offset >>> 0;
|
|
1176
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1177
|
+
const val = this[offset + 1] | this[offset] << 8;
|
|
1178
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1179
|
+
};
|
|
1180
|
+
Buffer3.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1181
|
+
offset = offset >>> 0;
|
|
1182
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1183
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1184
|
+
};
|
|
1185
|
+
Buffer3.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1186
|
+
offset = offset >>> 0;
|
|
1187
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1188
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1189
|
+
};
|
|
1190
|
+
Buffer3.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
|
1191
|
+
offset = offset >>> 0;
|
|
1192
|
+
validateNumber(offset, "offset");
|
|
1193
|
+
const first2 = this[offset];
|
|
1194
|
+
const last = this[offset + 7];
|
|
1195
|
+
if (first2 === void 0 || last === void 0) {
|
|
1196
|
+
boundsError(offset, this.length - 8);
|
|
1197
|
+
}
|
|
1198
|
+
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
|
|
1199
|
+
return (BigInt(val) << BigInt(32)) + BigInt(first2 + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
|
|
1200
|
+
});
|
|
1201
|
+
Buffer3.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
|
1202
|
+
offset = offset >>> 0;
|
|
1203
|
+
validateNumber(offset, "offset");
|
|
1204
|
+
const first2 = this[offset];
|
|
1205
|
+
const last = this[offset + 7];
|
|
1206
|
+
if (first2 === void 0 || last === void 0) {
|
|
1207
|
+
boundsError(offset, this.length - 8);
|
|
1208
|
+
}
|
|
1209
|
+
const val = (first2 << 24) + // Overflow
|
|
1210
|
+
this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1211
|
+
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
|
|
1212
|
+
});
|
|
1213
|
+
Buffer3.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1214
|
+
offset = offset >>> 0;
|
|
1215
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1216
|
+
return ieee754.read(this, offset, true, 23, 4);
|
|
1217
|
+
};
|
|
1218
|
+
Buffer3.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1219
|
+
offset = offset >>> 0;
|
|
1220
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1221
|
+
return ieee754.read(this, offset, false, 23, 4);
|
|
1222
|
+
};
|
|
1223
|
+
Buffer3.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1224
|
+
offset = offset >>> 0;
|
|
1225
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1226
|
+
return ieee754.read(this, offset, true, 52, 8);
|
|
1227
|
+
};
|
|
1228
|
+
Buffer3.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1229
|
+
offset = offset >>> 0;
|
|
1230
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1231
|
+
return ieee754.read(this, offset, false, 52, 8);
|
|
1232
|
+
};
|
|
1233
|
+
function checkInt(buf, value, offset, ext, max2, min2) {
|
|
1234
|
+
if (!Buffer3.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1235
|
+
if (value > max2 || value < min2) throw new RangeError('"value" argument is out of bounds');
|
|
1236
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1237
|
+
}
|
|
1238
|
+
Buffer3.prototype.writeUintLE = Buffer3.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1239
|
+
value = +value;
|
|
1240
|
+
offset = offset >>> 0;
|
|
1241
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1242
|
+
if (!noAssert) {
|
|
1243
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1244
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1245
|
+
}
|
|
1246
|
+
let mul = 1;
|
|
1247
|
+
let i = 0;
|
|
1248
|
+
this[offset] = value & 255;
|
|
1249
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1250
|
+
this[offset + i] = value / mul & 255;
|
|
1251
|
+
}
|
|
1252
|
+
return offset + byteLength2;
|
|
1253
|
+
};
|
|
1254
|
+
Buffer3.prototype.writeUintBE = Buffer3.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1255
|
+
value = +value;
|
|
1256
|
+
offset = offset >>> 0;
|
|
1257
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1258
|
+
if (!noAssert) {
|
|
1259
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1260
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1261
|
+
}
|
|
1262
|
+
let i = byteLength2 - 1;
|
|
1263
|
+
let mul = 1;
|
|
1264
|
+
this[offset + i] = value & 255;
|
|
1265
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1266
|
+
this[offset + i] = value / mul & 255;
|
|
1267
|
+
}
|
|
1268
|
+
return offset + byteLength2;
|
|
1269
|
+
};
|
|
1270
|
+
Buffer3.prototype.writeUint8 = Buffer3.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1271
|
+
value = +value;
|
|
1272
|
+
offset = offset >>> 0;
|
|
1273
|
+
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1274
|
+
this[offset] = value & 255;
|
|
1275
|
+
return offset + 1;
|
|
1276
|
+
};
|
|
1277
|
+
Buffer3.prototype.writeUint16LE = Buffer3.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1278
|
+
value = +value;
|
|
1279
|
+
offset = offset >>> 0;
|
|
1280
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1281
|
+
this[offset] = value & 255;
|
|
1282
|
+
this[offset + 1] = value >>> 8;
|
|
1283
|
+
return offset + 2;
|
|
1284
|
+
};
|
|
1285
|
+
Buffer3.prototype.writeUint16BE = Buffer3.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1286
|
+
value = +value;
|
|
1287
|
+
offset = offset >>> 0;
|
|
1288
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1289
|
+
this[offset] = value >>> 8;
|
|
1290
|
+
this[offset + 1] = value & 255;
|
|
1291
|
+
return offset + 2;
|
|
1292
|
+
};
|
|
1293
|
+
Buffer3.prototype.writeUint32LE = Buffer3.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1294
|
+
value = +value;
|
|
1295
|
+
offset = offset >>> 0;
|
|
1296
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1297
|
+
this[offset + 3] = value >>> 24;
|
|
1298
|
+
this[offset + 2] = value >>> 16;
|
|
1299
|
+
this[offset + 1] = value >>> 8;
|
|
1300
|
+
this[offset] = value & 255;
|
|
1301
|
+
return offset + 4;
|
|
1302
|
+
};
|
|
1303
|
+
Buffer3.prototype.writeUint32BE = Buffer3.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1304
|
+
value = +value;
|
|
1305
|
+
offset = offset >>> 0;
|
|
1306
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1307
|
+
this[offset] = value >>> 24;
|
|
1308
|
+
this[offset + 1] = value >>> 16;
|
|
1309
|
+
this[offset + 2] = value >>> 8;
|
|
1310
|
+
this[offset + 3] = value & 255;
|
|
1311
|
+
return offset + 4;
|
|
1312
|
+
};
|
|
1313
|
+
function wrtBigUInt64LE(buf, value, offset, min2, max2) {
|
|
1314
|
+
checkIntBI(value, min2, max2, buf, offset, 7);
|
|
1315
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1316
|
+
buf[offset++] = lo;
|
|
1317
|
+
lo = lo >> 8;
|
|
1318
|
+
buf[offset++] = lo;
|
|
1319
|
+
lo = lo >> 8;
|
|
1320
|
+
buf[offset++] = lo;
|
|
1321
|
+
lo = lo >> 8;
|
|
1322
|
+
buf[offset++] = lo;
|
|
1323
|
+
let hi2 = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1324
|
+
buf[offset++] = hi2;
|
|
1325
|
+
hi2 = hi2 >> 8;
|
|
1326
|
+
buf[offset++] = hi2;
|
|
1327
|
+
hi2 = hi2 >> 8;
|
|
1328
|
+
buf[offset++] = hi2;
|
|
1329
|
+
hi2 = hi2 >> 8;
|
|
1330
|
+
buf[offset++] = hi2;
|
|
1331
|
+
return offset;
|
|
1332
|
+
}
|
|
1333
|
+
function wrtBigUInt64BE(buf, value, offset, min2, max2) {
|
|
1334
|
+
checkIntBI(value, min2, max2, buf, offset, 7);
|
|
1335
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1336
|
+
buf[offset + 7] = lo;
|
|
1337
|
+
lo = lo >> 8;
|
|
1338
|
+
buf[offset + 6] = lo;
|
|
1339
|
+
lo = lo >> 8;
|
|
1340
|
+
buf[offset + 5] = lo;
|
|
1341
|
+
lo = lo >> 8;
|
|
1342
|
+
buf[offset + 4] = lo;
|
|
1343
|
+
let hi2 = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1344
|
+
buf[offset + 3] = hi2;
|
|
1345
|
+
hi2 = hi2 >> 8;
|
|
1346
|
+
buf[offset + 2] = hi2;
|
|
1347
|
+
hi2 = hi2 >> 8;
|
|
1348
|
+
buf[offset + 1] = hi2;
|
|
1349
|
+
hi2 = hi2 >> 8;
|
|
1350
|
+
buf[offset] = hi2;
|
|
1351
|
+
return offset + 8;
|
|
1352
|
+
}
|
|
1353
|
+
Buffer3.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1354
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1355
|
+
});
|
|
1356
|
+
Buffer3.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1357
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1358
|
+
});
|
|
1359
|
+
Buffer3.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1360
|
+
value = +value;
|
|
1361
|
+
offset = offset >>> 0;
|
|
1362
|
+
if (!noAssert) {
|
|
1363
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1364
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1365
|
+
}
|
|
1366
|
+
let i = 0;
|
|
1367
|
+
let mul = 1;
|
|
1368
|
+
let sub = 0;
|
|
1369
|
+
this[offset] = value & 255;
|
|
1370
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1371
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1372
|
+
sub = 1;
|
|
1373
|
+
}
|
|
1374
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1375
|
+
}
|
|
1376
|
+
return offset + byteLength2;
|
|
1377
|
+
};
|
|
1378
|
+
Buffer3.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1379
|
+
value = +value;
|
|
1380
|
+
offset = offset >>> 0;
|
|
1381
|
+
if (!noAssert) {
|
|
1382
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1383
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1384
|
+
}
|
|
1385
|
+
let i = byteLength2 - 1;
|
|
1386
|
+
let mul = 1;
|
|
1387
|
+
let sub = 0;
|
|
1388
|
+
this[offset + i] = value & 255;
|
|
1389
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1390
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1391
|
+
sub = 1;
|
|
1392
|
+
}
|
|
1393
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1394
|
+
}
|
|
1395
|
+
return offset + byteLength2;
|
|
1396
|
+
};
|
|
1397
|
+
Buffer3.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1398
|
+
value = +value;
|
|
1399
|
+
offset = offset >>> 0;
|
|
1400
|
+
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1401
|
+
if (value < 0) value = 255 + value + 1;
|
|
1402
|
+
this[offset] = value & 255;
|
|
1403
|
+
return offset + 1;
|
|
1404
|
+
};
|
|
1405
|
+
Buffer3.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1406
|
+
value = +value;
|
|
1407
|
+
offset = offset >>> 0;
|
|
1408
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1409
|
+
this[offset] = value & 255;
|
|
1410
|
+
this[offset + 1] = value >>> 8;
|
|
1411
|
+
return offset + 2;
|
|
1412
|
+
};
|
|
1413
|
+
Buffer3.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1414
|
+
value = +value;
|
|
1415
|
+
offset = offset >>> 0;
|
|
1416
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1417
|
+
this[offset] = value >>> 8;
|
|
1418
|
+
this[offset + 1] = value & 255;
|
|
1419
|
+
return offset + 2;
|
|
1420
|
+
};
|
|
1421
|
+
Buffer3.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1422
|
+
value = +value;
|
|
1423
|
+
offset = offset >>> 0;
|
|
1424
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1425
|
+
this[offset] = value & 255;
|
|
1426
|
+
this[offset + 1] = value >>> 8;
|
|
1427
|
+
this[offset + 2] = value >>> 16;
|
|
1428
|
+
this[offset + 3] = value >>> 24;
|
|
1429
|
+
return offset + 4;
|
|
1430
|
+
};
|
|
1431
|
+
Buffer3.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1432
|
+
value = +value;
|
|
1433
|
+
offset = offset >>> 0;
|
|
1434
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1435
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
1436
|
+
this[offset] = value >>> 24;
|
|
1437
|
+
this[offset + 1] = value >>> 16;
|
|
1438
|
+
this[offset + 2] = value >>> 8;
|
|
1439
|
+
this[offset + 3] = value & 255;
|
|
1440
|
+
return offset + 4;
|
|
1441
|
+
};
|
|
1442
|
+
Buffer3.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1443
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1444
|
+
});
|
|
1445
|
+
Buffer3.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1446
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1447
|
+
});
|
|
1448
|
+
function checkIEEE754(buf, value, offset, ext, max2, min2) {
|
|
1449
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1450
|
+
if (offset < 0) throw new RangeError("Index out of range");
|
|
1451
|
+
}
|
|
1452
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
1453
|
+
value = +value;
|
|
1454
|
+
offset = offset >>> 0;
|
|
1455
|
+
if (!noAssert) {
|
|
1456
|
+
checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
|
|
1457
|
+
}
|
|
1458
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
1459
|
+
return offset + 4;
|
|
1460
|
+
}
|
|
1461
|
+
Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1462
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
1463
|
+
};
|
|
1464
|
+
Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1465
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
1466
|
+
};
|
|
1467
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
1468
|
+
value = +value;
|
|
1469
|
+
offset = offset >>> 0;
|
|
1470
|
+
if (!noAssert) {
|
|
1471
|
+
checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
|
|
1472
|
+
}
|
|
1473
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
1474
|
+
return offset + 8;
|
|
1475
|
+
}
|
|
1476
|
+
Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1477
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
1478
|
+
};
|
|
1479
|
+
Buffer3.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1480
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
1481
|
+
};
|
|
1482
|
+
Buffer3.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1483
|
+
if (!Buffer3.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
1484
|
+
if (!start) start = 0;
|
|
1485
|
+
if (!end && end !== 0) end = this.length;
|
|
1486
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
1487
|
+
if (!targetStart) targetStart = 0;
|
|
1488
|
+
if (end > 0 && end < start) end = start;
|
|
1489
|
+
if (end === start) return 0;
|
|
1490
|
+
if (target.length === 0 || this.length === 0) return 0;
|
|
1491
|
+
if (targetStart < 0) {
|
|
1492
|
+
throw new RangeError("targetStart out of bounds");
|
|
1493
|
+
}
|
|
1494
|
+
if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
|
|
1495
|
+
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1496
|
+
if (end > this.length) end = this.length;
|
|
1497
|
+
if (target.length - targetStart < end - start) {
|
|
1498
|
+
end = target.length - targetStart + start;
|
|
1499
|
+
}
|
|
1500
|
+
const len = end - start;
|
|
1501
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
|
|
1502
|
+
this.copyWithin(targetStart, start, end);
|
|
1503
|
+
} else {
|
|
1504
|
+
Uint8Array.prototype.set.call(
|
|
1505
|
+
target,
|
|
1506
|
+
this.subarray(start, end),
|
|
1507
|
+
targetStart
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
return len;
|
|
1511
|
+
};
|
|
1512
|
+
Buffer3.prototype.fill = function fill3(val, start, end, encoding) {
|
|
1513
|
+
if (typeof val === "string") {
|
|
1514
|
+
if (typeof start === "string") {
|
|
1515
|
+
encoding = start;
|
|
1516
|
+
start = 0;
|
|
1517
|
+
end = this.length;
|
|
1518
|
+
} else if (typeof end === "string") {
|
|
1519
|
+
encoding = end;
|
|
1520
|
+
end = this.length;
|
|
1521
|
+
}
|
|
1522
|
+
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1523
|
+
throw new TypeError("encoding must be a string");
|
|
1524
|
+
}
|
|
1525
|
+
if (typeof encoding === "string" && !Buffer3.isEncoding(encoding)) {
|
|
1526
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
1527
|
+
}
|
|
1528
|
+
if (val.length === 1) {
|
|
1529
|
+
const code = val.charCodeAt(0);
|
|
1530
|
+
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
|
|
1531
|
+
val = code;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
} else if (typeof val === "number") {
|
|
1535
|
+
val = val & 255;
|
|
1536
|
+
} else if (typeof val === "boolean") {
|
|
1537
|
+
val = Number(val);
|
|
1538
|
+
}
|
|
1539
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
1540
|
+
throw new RangeError("Out of range index");
|
|
1541
|
+
}
|
|
1542
|
+
if (end <= start) {
|
|
1543
|
+
return this;
|
|
1544
|
+
}
|
|
1545
|
+
start = start >>> 0;
|
|
1546
|
+
end = end === void 0 ? this.length : end >>> 0;
|
|
1547
|
+
if (!val) val = 0;
|
|
1548
|
+
let i;
|
|
1549
|
+
if (typeof val === "number") {
|
|
1550
|
+
for (i = start; i < end; ++i) {
|
|
1551
|
+
this[i] = val;
|
|
1552
|
+
}
|
|
1553
|
+
} else {
|
|
1554
|
+
const bytes = Buffer3.isBuffer(val) ? val : Buffer3.from(val, encoding);
|
|
1555
|
+
const len = bytes.length;
|
|
1556
|
+
if (len === 0) {
|
|
1557
|
+
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
1558
|
+
}
|
|
1559
|
+
for (i = 0; i < end - start; ++i) {
|
|
1560
|
+
this[i + start] = bytes[i % len];
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return this;
|
|
1564
|
+
};
|
|
1565
|
+
var errors = {};
|
|
1566
|
+
function E(sym, getMessage, Base) {
|
|
1567
|
+
errors[sym] = class NodeError extends Base {
|
|
1568
|
+
constructor() {
|
|
1569
|
+
super();
|
|
1570
|
+
Object.defineProperty(this, "message", {
|
|
1571
|
+
value: getMessage.apply(this, arguments),
|
|
1572
|
+
writable: true,
|
|
1573
|
+
configurable: true
|
|
1574
|
+
});
|
|
1575
|
+
this.name = `${this.name} [${sym}]`;
|
|
1576
|
+
this.stack;
|
|
1577
|
+
delete this.name;
|
|
1578
|
+
}
|
|
1579
|
+
get code() {
|
|
1580
|
+
return sym;
|
|
1581
|
+
}
|
|
1582
|
+
set code(value) {
|
|
1583
|
+
Object.defineProperty(this, "code", {
|
|
1584
|
+
configurable: true,
|
|
1585
|
+
enumerable: true,
|
|
1586
|
+
value,
|
|
1587
|
+
writable: true
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
toString() {
|
|
1591
|
+
return `${this.name} [${sym}]: ${this.message}`;
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
E(
|
|
1596
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
1597
|
+
function(name) {
|
|
1598
|
+
if (name) {
|
|
1599
|
+
return `${name} is outside of buffer bounds`;
|
|
1600
|
+
}
|
|
1601
|
+
return "Attempt to access memory outside buffer bounds";
|
|
1602
|
+
},
|
|
1603
|
+
RangeError
|
|
1604
|
+
);
|
|
1605
|
+
E(
|
|
1606
|
+
"ERR_INVALID_ARG_TYPE",
|
|
1607
|
+
function(name, actual) {
|
|
1608
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
|
|
1609
|
+
},
|
|
1610
|
+
TypeError
|
|
1611
|
+
);
|
|
1612
|
+
E(
|
|
1613
|
+
"ERR_OUT_OF_RANGE",
|
|
1614
|
+
function(str, range, input) {
|
|
1615
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
1616
|
+
let received = input;
|
|
1617
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
1618
|
+
received = addNumericalSeparator(String(input));
|
|
1619
|
+
} else if (typeof input === "bigint") {
|
|
1620
|
+
received = String(input);
|
|
1621
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
1622
|
+
received = addNumericalSeparator(received);
|
|
1623
|
+
}
|
|
1624
|
+
received += "n";
|
|
1625
|
+
}
|
|
1626
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
1627
|
+
return msg;
|
|
1628
|
+
},
|
|
1629
|
+
RangeError
|
|
1630
|
+
);
|
|
1631
|
+
function addNumericalSeparator(val) {
|
|
1632
|
+
let res = "";
|
|
1633
|
+
let i = val.length;
|
|
1634
|
+
const start = val[0] === "-" ? 1 : 0;
|
|
1635
|
+
for (; i >= start + 4; i -= 3) {
|
|
1636
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
1637
|
+
}
|
|
1638
|
+
return `${val.slice(0, i)}${res}`;
|
|
1639
|
+
}
|
|
1640
|
+
function checkBounds(buf, offset, byteLength2) {
|
|
1641
|
+
validateNumber(offset, "offset");
|
|
1642
|
+
if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
|
|
1643
|
+
boundsError(offset, buf.length - (byteLength2 + 1));
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
function checkIntBI(value, min2, max2, buf, offset, byteLength2) {
|
|
1647
|
+
if (value > max2 || value < min2) {
|
|
1648
|
+
const n = typeof min2 === "bigint" ? "n" : "";
|
|
1649
|
+
let range;
|
|
1650
|
+
if (byteLength2 > 3) {
|
|
1651
|
+
if (min2 === 0 || min2 === BigInt(0)) {
|
|
1652
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
|
|
1653
|
+
} else {
|
|
1654
|
+
range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
|
|
1655
|
+
}
|
|
1656
|
+
} else {
|
|
1657
|
+
range = `>= ${min2}${n} and <= ${max2}${n}`;
|
|
1658
|
+
}
|
|
1659
|
+
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
|
1660
|
+
}
|
|
1661
|
+
checkBounds(buf, offset, byteLength2);
|
|
1662
|
+
}
|
|
1663
|
+
function validateNumber(value, name) {
|
|
1664
|
+
if (typeof value !== "number") {
|
|
1665
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
function boundsError(value, length2, type) {
|
|
1669
|
+
if (Math.floor(value) !== value) {
|
|
1670
|
+
validateNumber(value, type);
|
|
1671
|
+
throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
|
|
1672
|
+
}
|
|
1673
|
+
if (length2 < 0) {
|
|
1674
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
|
1675
|
+
}
|
|
1676
|
+
throw new errors.ERR_OUT_OF_RANGE(
|
|
1677
|
+
type || "offset",
|
|
1678
|
+
`>= ${type ? 1 : 0} and <= ${length2}`,
|
|
1679
|
+
value
|
|
1680
|
+
);
|
|
1681
|
+
}
|
|
1682
|
+
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
1683
|
+
function base64clean(str) {
|
|
1684
|
+
str = str.split("=")[0];
|
|
1685
|
+
str = str.trim().replace(INVALID_BASE64_RE, "");
|
|
1686
|
+
if (str.length < 2) return "";
|
|
1687
|
+
while (str.length % 4 !== 0) {
|
|
1688
|
+
str = str + "=";
|
|
1689
|
+
}
|
|
1690
|
+
return str;
|
|
1691
|
+
}
|
|
1692
|
+
function utf8ToBytes(string2, units) {
|
|
1693
|
+
units = units || Infinity;
|
|
1694
|
+
let codePoint;
|
|
1695
|
+
const length2 = string2.length;
|
|
1696
|
+
let leadSurrogate = null;
|
|
1697
|
+
const bytes = [];
|
|
1698
|
+
for (let i = 0; i < length2; ++i) {
|
|
1699
|
+
codePoint = string2.charCodeAt(i);
|
|
1700
|
+
if (codePoint > 55295 && codePoint < 57344) {
|
|
1701
|
+
if (!leadSurrogate) {
|
|
1702
|
+
if (codePoint > 56319) {
|
|
1703
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1704
|
+
continue;
|
|
1705
|
+
} else if (i + 1 === length2) {
|
|
1706
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1707
|
+
continue;
|
|
1708
|
+
}
|
|
1709
|
+
leadSurrogate = codePoint;
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
if (codePoint < 56320) {
|
|
1713
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1714
|
+
leadSurrogate = codePoint;
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
1718
|
+
} else if (leadSurrogate) {
|
|
1719
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1720
|
+
}
|
|
1721
|
+
leadSurrogate = null;
|
|
1722
|
+
if (codePoint < 128) {
|
|
1723
|
+
if ((units -= 1) < 0) break;
|
|
1724
|
+
bytes.push(codePoint);
|
|
1725
|
+
} else if (codePoint < 2048) {
|
|
1726
|
+
if ((units -= 2) < 0) break;
|
|
1727
|
+
bytes.push(
|
|
1728
|
+
codePoint >> 6 | 192,
|
|
1729
|
+
codePoint & 63 | 128
|
|
1730
|
+
);
|
|
1731
|
+
} else if (codePoint < 65536) {
|
|
1732
|
+
if ((units -= 3) < 0) break;
|
|
1733
|
+
bytes.push(
|
|
1734
|
+
codePoint >> 12 | 224,
|
|
1735
|
+
codePoint >> 6 & 63 | 128,
|
|
1736
|
+
codePoint & 63 | 128
|
|
1737
|
+
);
|
|
1738
|
+
} else if (codePoint < 1114112) {
|
|
1739
|
+
if ((units -= 4) < 0) break;
|
|
1740
|
+
bytes.push(
|
|
1741
|
+
codePoint >> 18 | 240,
|
|
1742
|
+
codePoint >> 12 & 63 | 128,
|
|
1743
|
+
codePoint >> 6 & 63 | 128,
|
|
1744
|
+
codePoint & 63 | 128
|
|
1745
|
+
);
|
|
1746
|
+
} else {
|
|
1747
|
+
throw new Error("Invalid code point");
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return bytes;
|
|
1751
|
+
}
|
|
1752
|
+
function asciiToBytes(str) {
|
|
1753
|
+
const byteArray = [];
|
|
1754
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1755
|
+
byteArray.push(str.charCodeAt(i) & 255);
|
|
1756
|
+
}
|
|
1757
|
+
return byteArray;
|
|
1758
|
+
}
|
|
1759
|
+
function utf16leToBytes(str, units) {
|
|
1760
|
+
let c2, hi2, lo;
|
|
1761
|
+
const byteArray = [];
|
|
1762
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1763
|
+
if ((units -= 2) < 0) break;
|
|
1764
|
+
c2 = str.charCodeAt(i);
|
|
1765
|
+
hi2 = c2 >> 8;
|
|
1766
|
+
lo = c2 % 256;
|
|
1767
|
+
byteArray.push(lo);
|
|
1768
|
+
byteArray.push(hi2);
|
|
1769
|
+
}
|
|
1770
|
+
return byteArray;
|
|
1771
|
+
}
|
|
1772
|
+
function base64ToBytes(str) {
|
|
1773
|
+
return base64.toByteArray(base64clean(str));
|
|
1774
|
+
}
|
|
1775
|
+
function blitBuffer(src, dst, offset, length2) {
|
|
1776
|
+
let i;
|
|
1777
|
+
for (i = 0; i < length2; ++i) {
|
|
1778
|
+
if (i + offset >= dst.length || i >= src.length) break;
|
|
1779
|
+
dst[i + offset] = src[i];
|
|
1780
|
+
}
|
|
1781
|
+
return i;
|
|
1782
|
+
}
|
|
1783
|
+
function isInstance(obj, type) {
|
|
1784
|
+
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
|
1785
|
+
}
|
|
1786
|
+
function numberIsNaN(obj) {
|
|
1787
|
+
return obj !== obj;
|
|
1788
|
+
}
|
|
1789
|
+
var hexSliceLookupTable = (function() {
|
|
1790
|
+
const alphabet = "0123456789abcdef";
|
|
1791
|
+
const table = new Array(256);
|
|
1792
|
+
for (let i = 0; i < 16; ++i) {
|
|
1793
|
+
const i16 = i * 16;
|
|
1794
|
+
for (let j = 0; j < 16; ++j) {
|
|
1795
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
return table;
|
|
1799
|
+
})();
|
|
1800
|
+
function defineBigIntMethod(fn) {
|
|
1801
|
+
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
1802
|
+
}
|
|
1803
|
+
function BufferBigIntNotDefined() {
|
|
1804
|
+
throw new Error("BigInt not supported");
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
19
1808
|
|
|
20
1809
|
// src/index.ts
|
|
21
1810
|
var index_exports = {};
|
|
@@ -141,38 +1930,1864 @@ function getDefaultNetworkOptions(themeColors, settings) {
|
|
|
141
1930
|
};
|
|
142
1931
|
}
|
|
143
1932
|
|
|
1933
|
+
// node_modules/n3/src/N3Lexer.js
|
|
1934
|
+
var import_buffer = __toESM(require_buffer());
|
|
1935
|
+
|
|
1936
|
+
// node_modules/n3/src/IRIs.js
|
|
1937
|
+
var RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
|
1938
|
+
var XSD = "http://www.w3.org/2001/XMLSchema#";
|
|
1939
|
+
var SWAP = "http://www.w3.org/2000/10/swap/";
|
|
1940
|
+
var IRIs_default = {
|
|
1941
|
+
xsd: {
|
|
1942
|
+
decimal: `${XSD}decimal`,
|
|
1943
|
+
boolean: `${XSD}boolean`,
|
|
1944
|
+
double: `${XSD}double`,
|
|
1945
|
+
integer: `${XSD}integer`,
|
|
1946
|
+
string: `${XSD}string`
|
|
1947
|
+
},
|
|
1948
|
+
rdf: {
|
|
1949
|
+
type: `${RDF}type`,
|
|
1950
|
+
nil: `${RDF}nil`,
|
|
1951
|
+
first: `${RDF}first`,
|
|
1952
|
+
rest: `${RDF}rest`,
|
|
1953
|
+
langString: `${RDF}langString`,
|
|
1954
|
+
dirLangString: `${RDF}dirLangString`,
|
|
1955
|
+
reifies: `${RDF}reifies`
|
|
1956
|
+
},
|
|
1957
|
+
owl: {
|
|
1958
|
+
sameAs: "http://www.w3.org/2002/07/owl#sameAs"
|
|
1959
|
+
},
|
|
1960
|
+
r: {
|
|
1961
|
+
forSome: `${SWAP}reify#forSome`,
|
|
1962
|
+
forAll: `${SWAP}reify#forAll`
|
|
1963
|
+
},
|
|
1964
|
+
log: {
|
|
1965
|
+
implies: `${SWAP}log#implies`,
|
|
1966
|
+
isImpliedBy: `${SWAP}log#isImpliedBy`
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
|
|
1970
|
+
// node_modules/n3/src/N3Lexer.js
|
|
1971
|
+
var { xsd } = IRIs_default;
|
|
1972
|
+
var escapeSequence = /\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\([^])/g;
|
|
1973
|
+
var escapeReplacements = {
|
|
1974
|
+
"\\": "\\",
|
|
1975
|
+
"'": "'",
|
|
1976
|
+
'"': '"',
|
|
1977
|
+
"n": "\n",
|
|
1978
|
+
"r": "\r",
|
|
1979
|
+
"t": " ",
|
|
1980
|
+
"f": "\f",
|
|
1981
|
+
"b": "\b",
|
|
1982
|
+
"_": "_",
|
|
1983
|
+
"~": "~",
|
|
1984
|
+
".": ".",
|
|
1985
|
+
"-": "-",
|
|
1986
|
+
"!": "!",
|
|
1987
|
+
"$": "$",
|
|
1988
|
+
"&": "&",
|
|
1989
|
+
"(": "(",
|
|
1990
|
+
")": ")",
|
|
1991
|
+
"*": "*",
|
|
1992
|
+
"+": "+",
|
|
1993
|
+
",": ",",
|
|
1994
|
+
";": ";",
|
|
1995
|
+
"=": "=",
|
|
1996
|
+
"/": "/",
|
|
1997
|
+
"?": "?",
|
|
1998
|
+
"#": "#",
|
|
1999
|
+
"@": "@",
|
|
2000
|
+
"%": "%"
|
|
2001
|
+
};
|
|
2002
|
+
var illegalIriChars = /[\x00-\x20<>\\"\{\}\|\^\`]/;
|
|
2003
|
+
var lineModeRegExps = {
|
|
2004
|
+
_iri: true,
|
|
2005
|
+
_unescapedIri: true,
|
|
2006
|
+
_simpleQuotedString: true,
|
|
2007
|
+
_langcode: true,
|
|
2008
|
+
_dircode: true,
|
|
2009
|
+
_blank: true,
|
|
2010
|
+
_newline: true,
|
|
2011
|
+
_comment: true,
|
|
2012
|
+
_whitespace: true,
|
|
2013
|
+
_endOfFile: true
|
|
2014
|
+
};
|
|
2015
|
+
var invalidRegExp = /$0^/;
|
|
2016
|
+
var N3Lexer = class {
|
|
2017
|
+
constructor(options) {
|
|
2018
|
+
this._iri = /^<((?:[^ <>{}\\]|\\[uU])+)>[ \t]*/;
|
|
2019
|
+
this._unescapedIri = /^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/;
|
|
2020
|
+
this._simpleQuotedString = /^"([^"\\\r\n]*)"(?=[^"])/;
|
|
2021
|
+
this._simpleApostropheString = /^'([^'\\\r\n]*)'(?=[^'])/;
|
|
2022
|
+
this._langcode = /^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9])/i;
|
|
2023
|
+
this._dircode = /^--(ltr)|(rtl)/;
|
|
2024
|
+
this._prefix = /^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/;
|
|
2025
|
+
this._prefixed = /^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/;
|
|
2026
|
+
this._variable = /^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/;
|
|
2027
|
+
this._blank = /^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/;
|
|
2028
|
+
this._number = /^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/;
|
|
2029
|
+
this._boolean = /^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/;
|
|
2030
|
+
this._atKeyword = /^@[a-z]+(?=[\s#<:])/i;
|
|
2031
|
+
this._keyword = /^(?:PREFIX|BASE|VERSION|GRAPH)(?=[\s#<])/i;
|
|
2032
|
+
this._shortPredicates = /^a(?=[\s#()\[\]\{\}"'<>])/;
|
|
2033
|
+
this._newline = /^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/;
|
|
2034
|
+
this._comment = /#([^\n\r]*)/;
|
|
2035
|
+
this._whitespace = /^[ \t]+/;
|
|
2036
|
+
this._endOfFile = /^(?:#[^\n\r]*)?$/;
|
|
2037
|
+
options = options || {};
|
|
2038
|
+
this._isImpliedBy = options.isImpliedBy;
|
|
2039
|
+
if (this._lineMode = !!options.lineMode) {
|
|
2040
|
+
this._n3Mode = false;
|
|
2041
|
+
for (const key in this) {
|
|
2042
|
+
if (!(key in lineModeRegExps) && this[key] instanceof RegExp)
|
|
2043
|
+
this[key] = invalidRegExp;
|
|
2044
|
+
}
|
|
2045
|
+
} else {
|
|
2046
|
+
this._n3Mode = options.n3 !== false;
|
|
2047
|
+
}
|
|
2048
|
+
this.comments = !!options.comments;
|
|
2049
|
+
this._literalClosingPos = 0;
|
|
2050
|
+
}
|
|
2051
|
+
// ## Private methods
|
|
2052
|
+
// ### `_tokenizeToEnd` tokenizes as for as possible, emitting tokens through the callback
|
|
2053
|
+
_tokenizeToEnd(callback, inputFinished) {
|
|
2054
|
+
let input = this._input;
|
|
2055
|
+
let currentLineLength = input.length;
|
|
2056
|
+
while (true) {
|
|
2057
|
+
let whiteSpaceMatch, comment;
|
|
2058
|
+
while (whiteSpaceMatch = this._newline.exec(input)) {
|
|
2059
|
+
if (this.comments && (comment = this._comment.exec(whiteSpaceMatch[0])))
|
|
2060
|
+
emitToken("comment", comment[1], "", this._line, whiteSpaceMatch[0].length);
|
|
2061
|
+
input = input.substr(whiteSpaceMatch[0].length, input.length);
|
|
2062
|
+
currentLineLength = input.length;
|
|
2063
|
+
this._line++;
|
|
2064
|
+
}
|
|
2065
|
+
if (!whiteSpaceMatch && (whiteSpaceMatch = this._whitespace.exec(input)))
|
|
2066
|
+
input = input.substr(whiteSpaceMatch[0].length, input.length);
|
|
2067
|
+
if (this._endOfFile.test(input)) {
|
|
2068
|
+
if (inputFinished) {
|
|
2069
|
+
if (this.comments && (comment = this._comment.exec(input)))
|
|
2070
|
+
emitToken("comment", comment[1], "", this._line, input.length);
|
|
2071
|
+
input = null;
|
|
2072
|
+
emitToken("eof", "", "", this._line, 0);
|
|
2073
|
+
}
|
|
2074
|
+
return this._input = input;
|
|
2075
|
+
}
|
|
2076
|
+
const line = this._line, firstChar = input[0];
|
|
2077
|
+
let type = "", value = "", prefix = "", match2 = null, matchLength = 0, inconclusive = false;
|
|
2078
|
+
switch (firstChar) {
|
|
2079
|
+
case "^":
|
|
2080
|
+
if (input.length < 3)
|
|
2081
|
+
break;
|
|
2082
|
+
else if (input[1] === "^") {
|
|
2083
|
+
this._previousMarker = "^^";
|
|
2084
|
+
input = input.substr(2);
|
|
2085
|
+
if (input[0] !== "<") {
|
|
2086
|
+
inconclusive = true;
|
|
2087
|
+
break;
|
|
2088
|
+
}
|
|
2089
|
+
} else {
|
|
2090
|
+
if (this._n3Mode) {
|
|
2091
|
+
matchLength = 1;
|
|
2092
|
+
type = "^";
|
|
2093
|
+
}
|
|
2094
|
+
break;
|
|
2095
|
+
}
|
|
2096
|
+
// Fall through in case the type is an IRI
|
|
2097
|
+
case "<":
|
|
2098
|
+
if (match2 = this._unescapedIri.exec(input))
|
|
2099
|
+
type = "IRI", value = match2[1];
|
|
2100
|
+
else if (match2 = this._iri.exec(input)) {
|
|
2101
|
+
value = this._unescape(match2[1]);
|
|
2102
|
+
if (value === null || illegalIriChars.test(value))
|
|
2103
|
+
return reportSyntaxError(this);
|
|
2104
|
+
type = "IRI";
|
|
2105
|
+
} else if (input.length > 2 && input[1] === "<" && input[2] === "(")
|
|
2106
|
+
type = "<<(", matchLength = 3;
|
|
2107
|
+
else if (!this._lineMode && input.length > (inputFinished ? 1 : 2) && input[1] === "<")
|
|
2108
|
+
type = "<<", matchLength = 2;
|
|
2109
|
+
else if (this._n3Mode && input.length > 1 && input[1] === "=") {
|
|
2110
|
+
matchLength = 2;
|
|
2111
|
+
if (this._isImpliedBy) type = "abbreviation", value = "<";
|
|
2112
|
+
else type = "inverse", value = ">";
|
|
2113
|
+
}
|
|
2114
|
+
break;
|
|
2115
|
+
case ">":
|
|
2116
|
+
if (input.length > 1 && input[1] === ">")
|
|
2117
|
+
type = ">>", matchLength = 2;
|
|
2118
|
+
break;
|
|
2119
|
+
case "_":
|
|
2120
|
+
if ((match2 = this._blank.exec(input)) || inputFinished && (match2 = this._blank.exec(`${input} `)))
|
|
2121
|
+
type = "blank", prefix = "_", value = match2[1];
|
|
2122
|
+
break;
|
|
2123
|
+
case '"':
|
|
2124
|
+
if (match2 = this._simpleQuotedString.exec(input))
|
|
2125
|
+
value = match2[1];
|
|
2126
|
+
else {
|
|
2127
|
+
({ value, matchLength } = this._parseLiteral(input));
|
|
2128
|
+
if (value === null)
|
|
2129
|
+
return reportSyntaxError(this);
|
|
2130
|
+
}
|
|
2131
|
+
if (match2 !== null || matchLength !== 0) {
|
|
2132
|
+
type = "literal";
|
|
2133
|
+
this._literalClosingPos = 0;
|
|
2134
|
+
}
|
|
2135
|
+
break;
|
|
2136
|
+
case "'":
|
|
2137
|
+
if (!this._lineMode) {
|
|
2138
|
+
if (match2 = this._simpleApostropheString.exec(input))
|
|
2139
|
+
value = match2[1];
|
|
2140
|
+
else {
|
|
2141
|
+
({ value, matchLength } = this._parseLiteral(input));
|
|
2142
|
+
if (value === null)
|
|
2143
|
+
return reportSyntaxError(this);
|
|
2144
|
+
}
|
|
2145
|
+
if (match2 !== null || matchLength !== 0) {
|
|
2146
|
+
type = "literal";
|
|
2147
|
+
this._literalClosingPos = 0;
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
break;
|
|
2151
|
+
case "?":
|
|
2152
|
+
if (this._n3Mode && (match2 = this._variable.exec(input)))
|
|
2153
|
+
type = "var", value = match2[0];
|
|
2154
|
+
break;
|
|
2155
|
+
case "@":
|
|
2156
|
+
if (this._previousMarker === "literal" && (match2 = this._langcode.exec(input)) && match2[1] !== "version")
|
|
2157
|
+
type = "langcode", value = match2[1];
|
|
2158
|
+
else if (match2 = this._atKeyword.exec(input))
|
|
2159
|
+
type = match2[0];
|
|
2160
|
+
break;
|
|
2161
|
+
case ".":
|
|
2162
|
+
if (input.length === 1 ? inputFinished : input[1] < "0" || input[1] > "9") {
|
|
2163
|
+
type = ".";
|
|
2164
|
+
matchLength = 1;
|
|
2165
|
+
break;
|
|
2166
|
+
}
|
|
2167
|
+
// Fall through to numerical case (could be a decimal dot)
|
|
2168
|
+
case "0":
|
|
2169
|
+
case "1":
|
|
2170
|
+
case "2":
|
|
2171
|
+
case "3":
|
|
2172
|
+
case "4":
|
|
2173
|
+
case "5":
|
|
2174
|
+
case "6":
|
|
2175
|
+
case "7":
|
|
2176
|
+
case "8":
|
|
2177
|
+
case "9":
|
|
2178
|
+
case "+":
|
|
2179
|
+
case "-":
|
|
2180
|
+
if (input[1] === "-") {
|
|
2181
|
+
if (this._previousMarker === "langcode" && (match2 = this._dircode.exec(input)))
|
|
2182
|
+
type = "dircode", matchLength = 2, value = match2[1] || match2[2], matchLength = value.length + 2;
|
|
2183
|
+
break;
|
|
2184
|
+
}
|
|
2185
|
+
if (match2 = this._number.exec(input) || inputFinished && (match2 = this._number.exec(`${input} `))) {
|
|
2186
|
+
type = "literal", value = match2[0];
|
|
2187
|
+
prefix = typeof match2[1] === "string" ? xsd.double : typeof match2[2] === "string" ? xsd.decimal : xsd.integer;
|
|
2188
|
+
}
|
|
2189
|
+
break;
|
|
2190
|
+
case "B":
|
|
2191
|
+
case "b":
|
|
2192
|
+
case "p":
|
|
2193
|
+
case "P":
|
|
2194
|
+
case "G":
|
|
2195
|
+
case "g":
|
|
2196
|
+
case "V":
|
|
2197
|
+
case "v":
|
|
2198
|
+
if (match2 = this._keyword.exec(input))
|
|
2199
|
+
type = match2[0].toUpperCase();
|
|
2200
|
+
else
|
|
2201
|
+
inconclusive = true;
|
|
2202
|
+
break;
|
|
2203
|
+
case "f":
|
|
2204
|
+
case "t":
|
|
2205
|
+
if (match2 = this._boolean.exec(input))
|
|
2206
|
+
type = "literal", value = match2[0], prefix = xsd.boolean;
|
|
2207
|
+
else
|
|
2208
|
+
inconclusive = true;
|
|
2209
|
+
break;
|
|
2210
|
+
case "a":
|
|
2211
|
+
if (match2 = this._shortPredicates.exec(input))
|
|
2212
|
+
type = "abbreviation", value = "a";
|
|
2213
|
+
else
|
|
2214
|
+
inconclusive = true;
|
|
2215
|
+
break;
|
|
2216
|
+
case "=":
|
|
2217
|
+
if (this._n3Mode && input.length > 1) {
|
|
2218
|
+
type = "abbreviation";
|
|
2219
|
+
if (input[1] !== ">")
|
|
2220
|
+
matchLength = 1, value = "=";
|
|
2221
|
+
else
|
|
2222
|
+
matchLength = 2, value = ">";
|
|
2223
|
+
}
|
|
2224
|
+
break;
|
|
2225
|
+
case "!":
|
|
2226
|
+
if (!this._n3Mode)
|
|
2227
|
+
break;
|
|
2228
|
+
case ")":
|
|
2229
|
+
if (!inputFinished && (input.length === 1 || input.length === 2 && input[1] === ">")) {
|
|
2230
|
+
break;
|
|
2231
|
+
}
|
|
2232
|
+
if (input.length > 2 && input[1] === ">" && input[2] === ">") {
|
|
2233
|
+
type = ")>>", matchLength = 3;
|
|
2234
|
+
break;
|
|
2235
|
+
}
|
|
2236
|
+
case ",":
|
|
2237
|
+
case ";":
|
|
2238
|
+
case "[":
|
|
2239
|
+
case "]":
|
|
2240
|
+
case "(":
|
|
2241
|
+
case "}":
|
|
2242
|
+
case "~":
|
|
2243
|
+
if (!this._lineMode) {
|
|
2244
|
+
matchLength = 1;
|
|
2245
|
+
type = firstChar;
|
|
2246
|
+
}
|
|
2247
|
+
break;
|
|
2248
|
+
case "{":
|
|
2249
|
+
if (!this._lineMode && input.length >= 2) {
|
|
2250
|
+
if (input[1] === "|")
|
|
2251
|
+
type = "{|", matchLength = 2;
|
|
2252
|
+
else
|
|
2253
|
+
type = firstChar, matchLength = 1;
|
|
2254
|
+
}
|
|
2255
|
+
break;
|
|
2256
|
+
case "|":
|
|
2257
|
+
if (input.length >= 2 && input[1] === "}")
|
|
2258
|
+
type = "|}", matchLength = 2;
|
|
2259
|
+
break;
|
|
2260
|
+
default:
|
|
2261
|
+
inconclusive = true;
|
|
2262
|
+
}
|
|
2263
|
+
if (inconclusive) {
|
|
2264
|
+
if ((this._previousMarker === "@prefix" || this._previousMarker === "PREFIX") && (match2 = this._prefix.exec(input)))
|
|
2265
|
+
type = "prefix", value = match2[1] || "";
|
|
2266
|
+
else if ((match2 = this._prefixed.exec(input)) || inputFinished && (match2 = this._prefixed.exec(`${input} `)))
|
|
2267
|
+
type = "prefixed", prefix = match2[1] || "", value = this._unescape(match2[2]);
|
|
2268
|
+
}
|
|
2269
|
+
if (this._previousMarker === "^^") {
|
|
2270
|
+
switch (type) {
|
|
2271
|
+
case "prefixed":
|
|
2272
|
+
type = "type";
|
|
2273
|
+
break;
|
|
2274
|
+
case "IRI":
|
|
2275
|
+
type = "typeIRI";
|
|
2276
|
+
break;
|
|
2277
|
+
default:
|
|
2278
|
+
type = "";
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
if (!type) {
|
|
2282
|
+
if (inputFinished || !/^'''|^"""/.test(input) && /\n|\r/.test(input))
|
|
2283
|
+
return reportSyntaxError(this);
|
|
2284
|
+
else
|
|
2285
|
+
return this._input = input;
|
|
2286
|
+
}
|
|
2287
|
+
const length2 = matchLength || match2[0].length;
|
|
2288
|
+
const token2 = emitToken(type, value, prefix, line, length2);
|
|
2289
|
+
this.previousToken = token2;
|
|
2290
|
+
this._previousMarker = type;
|
|
2291
|
+
input = input.substr(length2, input.length);
|
|
2292
|
+
}
|
|
2293
|
+
function emitToken(type, value, prefix, line, length2) {
|
|
2294
|
+
const start = input ? currentLineLength - input.length : currentLineLength;
|
|
2295
|
+
const end = start + length2;
|
|
2296
|
+
const token2 = { type, value, prefix, line, start, end };
|
|
2297
|
+
callback(null, token2);
|
|
2298
|
+
return token2;
|
|
2299
|
+
}
|
|
2300
|
+
function reportSyntaxError(self2) {
|
|
2301
|
+
callback(self2._syntaxError(/^\S*/.exec(input)[0]));
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
// ### `_unescape` replaces N3 escape codes by their corresponding characters
|
|
2305
|
+
_unescape(item) {
|
|
2306
|
+
let invalid = false;
|
|
2307
|
+
const replaced = item.replace(escapeSequence, (sequence, unicode4, unicode8, escapedChar) => {
|
|
2308
|
+
if (typeof unicode4 === "string")
|
|
2309
|
+
return String.fromCharCode(Number.parseInt(unicode4, 16));
|
|
2310
|
+
if (typeof unicode8 === "string") {
|
|
2311
|
+
let charCode = Number.parseInt(unicode8, 16);
|
|
2312
|
+
return charCode <= 65535 ? String.fromCharCode(Number.parseInt(unicode8, 16)) : String.fromCharCode(55296 + ((charCode -= 65536) >> 10), 56320 + (charCode & 1023));
|
|
2313
|
+
}
|
|
2314
|
+
if (escapedChar in escapeReplacements)
|
|
2315
|
+
return escapeReplacements[escapedChar];
|
|
2316
|
+
invalid = true;
|
|
2317
|
+
return "";
|
|
2318
|
+
});
|
|
2319
|
+
return invalid ? null : replaced;
|
|
2320
|
+
}
|
|
2321
|
+
// ### `_parseLiteral` parses a literal into an unescaped value
|
|
2322
|
+
_parseLiteral(input) {
|
|
2323
|
+
if (input.length >= 3) {
|
|
2324
|
+
const opening = input.match(/^(?:"""|"|'''|'|)/)[0];
|
|
2325
|
+
const openingLength = opening.length;
|
|
2326
|
+
let closingPos = Math.max(this._literalClosingPos, openingLength);
|
|
2327
|
+
while ((closingPos = input.indexOf(opening, closingPos)) > 0) {
|
|
2328
|
+
let backslashCount = 0;
|
|
2329
|
+
while (input[closingPos - backslashCount - 1] === "\\")
|
|
2330
|
+
backslashCount++;
|
|
2331
|
+
if (backslashCount % 2 === 0) {
|
|
2332
|
+
const raw = input.substring(openingLength, closingPos);
|
|
2333
|
+
const lines = raw.split(/\r\n|\r|\n/).length - 1;
|
|
2334
|
+
const matchLength = closingPos + openingLength;
|
|
2335
|
+
if (openingLength === 1 && lines !== 0 || openingLength === 3 && this._lineMode)
|
|
2336
|
+
break;
|
|
2337
|
+
this._line += lines;
|
|
2338
|
+
return { value: this._unescape(raw), matchLength };
|
|
2339
|
+
}
|
|
2340
|
+
closingPos++;
|
|
2341
|
+
}
|
|
2342
|
+
this._literalClosingPos = input.length - openingLength + 1;
|
|
2343
|
+
}
|
|
2344
|
+
return { value: "", matchLength: 0 };
|
|
2345
|
+
}
|
|
2346
|
+
// ### `_syntaxError` creates a syntax error for the given issue
|
|
2347
|
+
_syntaxError(issue) {
|
|
2348
|
+
this._input = null;
|
|
2349
|
+
const err = new Error(`Unexpected "${issue}" on line ${this._line}.`);
|
|
2350
|
+
err.context = {
|
|
2351
|
+
token: void 0,
|
|
2352
|
+
line: this._line,
|
|
2353
|
+
previousToken: this.previousToken
|
|
2354
|
+
};
|
|
2355
|
+
return err;
|
|
2356
|
+
}
|
|
2357
|
+
// ### Strips off any starting UTF BOM mark.
|
|
2358
|
+
_readStartingBom(input) {
|
|
2359
|
+
return input.startsWith("\uFEFF") ? input.substr(1) : input;
|
|
2360
|
+
}
|
|
2361
|
+
// ## Public methods
|
|
2362
|
+
// ### `tokenize` starts the transformation of an N3 document into an array of tokens.
|
|
2363
|
+
// The input can be a string or a stream.
|
|
2364
|
+
tokenize(input, callback) {
|
|
2365
|
+
this._line = 1;
|
|
2366
|
+
if (typeof input === "string") {
|
|
2367
|
+
this._input = this._readStartingBom(input);
|
|
2368
|
+
if (typeof callback === "function")
|
|
2369
|
+
queueMicrotask(() => this._tokenizeToEnd(callback, true));
|
|
2370
|
+
else {
|
|
2371
|
+
const tokens = [];
|
|
2372
|
+
let error;
|
|
2373
|
+
this._tokenizeToEnd((e, t) => e ? error = e : tokens.push(t), true);
|
|
2374
|
+
if (error) throw error;
|
|
2375
|
+
return tokens;
|
|
2376
|
+
}
|
|
2377
|
+
} else {
|
|
2378
|
+
this._pendingBuffer = null;
|
|
2379
|
+
if (typeof input.setEncoding === "function")
|
|
2380
|
+
input.setEncoding("utf8");
|
|
2381
|
+
input.on("data", (data2) => {
|
|
2382
|
+
if (this._input !== null && data2.length !== 0) {
|
|
2383
|
+
if (this._pendingBuffer) {
|
|
2384
|
+
data2 = import_buffer.Buffer.concat([this._pendingBuffer, data2]);
|
|
2385
|
+
this._pendingBuffer = null;
|
|
2386
|
+
}
|
|
2387
|
+
if (data2[data2.length - 1] & 128) {
|
|
2388
|
+
this._pendingBuffer = data2;
|
|
2389
|
+
} else {
|
|
2390
|
+
if (typeof this._input === "undefined")
|
|
2391
|
+
this._input = this._readStartingBom(typeof data2 === "string" ? data2 : data2.toString());
|
|
2392
|
+
else
|
|
2393
|
+
this._input += data2;
|
|
2394
|
+
this._tokenizeToEnd(callback, false);
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
input.on("end", () => {
|
|
2399
|
+
if (typeof this._input === "string")
|
|
2400
|
+
this._tokenizeToEnd(callback, true);
|
|
2401
|
+
});
|
|
2402
|
+
input.on("error", callback);
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
|
|
2407
|
+
// node_modules/n3/src/N3DataFactory.js
|
|
2408
|
+
var { rdf, xsd: xsd2 } = IRIs_default;
|
|
2409
|
+
var DEFAULTGRAPH;
|
|
2410
|
+
var _blankNodeCounter = 0;
|
|
2411
|
+
var DataFactory = {
|
|
2412
|
+
namedNode,
|
|
2413
|
+
blankNode,
|
|
2414
|
+
variable,
|
|
2415
|
+
literal,
|
|
2416
|
+
defaultGraph,
|
|
2417
|
+
quad,
|
|
2418
|
+
triple: quad,
|
|
2419
|
+
fromTerm,
|
|
2420
|
+
fromQuad
|
|
2421
|
+
};
|
|
2422
|
+
var N3DataFactory_default = DataFactory;
|
|
2423
|
+
var Term = class _Term {
|
|
2424
|
+
constructor(id2) {
|
|
2425
|
+
this.id = id2;
|
|
2426
|
+
}
|
|
2427
|
+
// ### The value of this term
|
|
2428
|
+
get value() {
|
|
2429
|
+
return this.id;
|
|
2430
|
+
}
|
|
2431
|
+
// ### Returns whether this object represents the same term as the other
|
|
2432
|
+
equals(other) {
|
|
2433
|
+
if (other instanceof _Term)
|
|
2434
|
+
return this.id === other.id;
|
|
2435
|
+
return !!other && this.termType === other.termType && this.value === other.value;
|
|
2436
|
+
}
|
|
2437
|
+
// ### Implement hashCode for Immutable.js, since we implement `equals`
|
|
2438
|
+
// https://immutable-js.com/docs/v4.0.0/ValueObject/#hashCode()
|
|
2439
|
+
hashCode() {
|
|
2440
|
+
return 0;
|
|
2441
|
+
}
|
|
2442
|
+
// ### Returns a plain object representation of this term
|
|
2443
|
+
toJSON() {
|
|
2444
|
+
return {
|
|
2445
|
+
termType: this.termType,
|
|
2446
|
+
value: this.value
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
var NamedNode = class extends Term {
|
|
2451
|
+
// ### The term type of this term
|
|
2452
|
+
get termType() {
|
|
2453
|
+
return "NamedNode";
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
var Literal = class _Literal extends Term {
|
|
2457
|
+
// ### The term type of this term
|
|
2458
|
+
get termType() {
|
|
2459
|
+
return "Literal";
|
|
2460
|
+
}
|
|
2461
|
+
// ### The text value of this literal
|
|
2462
|
+
get value() {
|
|
2463
|
+
return this.id.substring(1, this.id.lastIndexOf('"'));
|
|
2464
|
+
}
|
|
2465
|
+
// ### The language of this literal
|
|
2466
|
+
get language() {
|
|
2467
|
+
const id2 = this.id;
|
|
2468
|
+
let atPos = id2.lastIndexOf('"') + 1;
|
|
2469
|
+
const dirPos = id2.lastIndexOf("--");
|
|
2470
|
+
return atPos < id2.length && id2[atPos++] === "@" ? (dirPos > atPos ? id2.substr(0, dirPos) : id2).substr(atPos).toLowerCase() : "";
|
|
2471
|
+
}
|
|
2472
|
+
// ### The direction of this literal
|
|
2473
|
+
get direction() {
|
|
2474
|
+
const id2 = this.id;
|
|
2475
|
+
const atPos = id2.lastIndexOf("--") + 2;
|
|
2476
|
+
return atPos > 1 && atPos < id2.length ? id2.substr(atPos).toLowerCase() : "";
|
|
2477
|
+
}
|
|
2478
|
+
// ### The datatype IRI of this literal
|
|
2479
|
+
get datatype() {
|
|
2480
|
+
return new NamedNode(this.datatypeString);
|
|
2481
|
+
}
|
|
2482
|
+
// ### The datatype string of this literal
|
|
2483
|
+
get datatypeString() {
|
|
2484
|
+
const id2 = this.id, dtPos = id2.lastIndexOf('"') + 1;
|
|
2485
|
+
const char = dtPos < id2.length ? id2[dtPos] : "";
|
|
2486
|
+
return char === "^" ? id2.substr(dtPos + 2) : (
|
|
2487
|
+
// If "@" follows, return rdf:langString or rdf:dirLangString; xsd:string otherwise
|
|
2488
|
+
char !== "@" ? xsd2.string : id2.indexOf("--", dtPos) > 0 ? rdf.dirLangString : rdf.langString
|
|
2489
|
+
);
|
|
2490
|
+
}
|
|
2491
|
+
// ### Returns whether this object represents the same term as the other
|
|
2492
|
+
equals(other) {
|
|
2493
|
+
if (other instanceof _Literal)
|
|
2494
|
+
return this.id === other.id;
|
|
2495
|
+
return !!other && !!other.datatype && this.termType === other.termType && this.value === other.value && this.language === other.language && (this.direction === other.direction || this.direction === "" && !other.direction) && this.datatype.value === other.datatype.value;
|
|
2496
|
+
}
|
|
2497
|
+
toJSON() {
|
|
2498
|
+
return {
|
|
2499
|
+
termType: this.termType,
|
|
2500
|
+
value: this.value,
|
|
2501
|
+
language: this.language,
|
|
2502
|
+
direction: this.direction,
|
|
2503
|
+
datatype: { termType: "NamedNode", value: this.datatypeString }
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
var BlankNode = class extends Term {
|
|
2508
|
+
constructor(name) {
|
|
2509
|
+
super(`_:${name}`);
|
|
2510
|
+
}
|
|
2511
|
+
// ### The term type of this term
|
|
2512
|
+
get termType() {
|
|
2513
|
+
return "BlankNode";
|
|
2514
|
+
}
|
|
2515
|
+
// ### The name of this blank node
|
|
2516
|
+
get value() {
|
|
2517
|
+
return this.id.substr(2);
|
|
2518
|
+
}
|
|
2519
|
+
};
|
|
2520
|
+
var Variable = class extends Term {
|
|
2521
|
+
constructor(name) {
|
|
2522
|
+
super(`?${name}`);
|
|
2523
|
+
}
|
|
2524
|
+
// ### The term type of this term
|
|
2525
|
+
get termType() {
|
|
2526
|
+
return "Variable";
|
|
2527
|
+
}
|
|
2528
|
+
// ### The name of this variable
|
|
2529
|
+
get value() {
|
|
2530
|
+
return this.id.substr(1);
|
|
2531
|
+
}
|
|
2532
|
+
};
|
|
2533
|
+
var DefaultGraph = class extends Term {
|
|
2534
|
+
constructor() {
|
|
2535
|
+
super("");
|
|
2536
|
+
return DEFAULTGRAPH || this;
|
|
2537
|
+
}
|
|
2538
|
+
// ### The term type of this term
|
|
2539
|
+
get termType() {
|
|
2540
|
+
return "DefaultGraph";
|
|
2541
|
+
}
|
|
2542
|
+
// ### Returns whether this object represents the same term as the other
|
|
2543
|
+
equals(other) {
|
|
2544
|
+
return this === other || !!other && this.termType === other.termType;
|
|
2545
|
+
}
|
|
2546
|
+
};
|
|
2547
|
+
DEFAULTGRAPH = new DefaultGraph();
|
|
2548
|
+
var Quad = class extends Term {
|
|
2549
|
+
constructor(subject, predicate, object2, graph) {
|
|
2550
|
+
super("");
|
|
2551
|
+
this._subject = subject;
|
|
2552
|
+
this._predicate = predicate;
|
|
2553
|
+
this._object = object2;
|
|
2554
|
+
this._graph = graph || DEFAULTGRAPH;
|
|
2555
|
+
}
|
|
2556
|
+
// ### The term type of this term
|
|
2557
|
+
get termType() {
|
|
2558
|
+
return "Quad";
|
|
2559
|
+
}
|
|
2560
|
+
get subject() {
|
|
2561
|
+
return this._subject;
|
|
2562
|
+
}
|
|
2563
|
+
get predicate() {
|
|
2564
|
+
return this._predicate;
|
|
2565
|
+
}
|
|
2566
|
+
get object() {
|
|
2567
|
+
return this._object;
|
|
2568
|
+
}
|
|
2569
|
+
get graph() {
|
|
2570
|
+
return this._graph;
|
|
2571
|
+
}
|
|
2572
|
+
// ### Returns a plain object representation of this quad
|
|
2573
|
+
toJSON() {
|
|
2574
|
+
return {
|
|
2575
|
+
termType: this.termType,
|
|
2576
|
+
subject: this._subject.toJSON(),
|
|
2577
|
+
predicate: this._predicate.toJSON(),
|
|
2578
|
+
object: this._object.toJSON(),
|
|
2579
|
+
graph: this._graph.toJSON()
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2582
|
+
// ### Returns whether this object represents the same quad as the other
|
|
2583
|
+
equals(other) {
|
|
2584
|
+
return !!other && this._subject.equals(other.subject) && this._predicate.equals(other.predicate) && this._object.equals(other.object) && this._graph.equals(other.graph);
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
function namedNode(iri) {
|
|
2588
|
+
return new NamedNode(iri);
|
|
2589
|
+
}
|
|
2590
|
+
function blankNode(name) {
|
|
2591
|
+
return new BlankNode(name || `n3-${_blankNodeCounter++}`);
|
|
2592
|
+
}
|
|
2593
|
+
function literal(value, languageOrDataType) {
|
|
2594
|
+
if (typeof languageOrDataType === "string")
|
|
2595
|
+
return new Literal(`"${value}"@${languageOrDataType.toLowerCase()}`);
|
|
2596
|
+
if (languageOrDataType !== void 0 && !("termType" in languageOrDataType)) {
|
|
2597
|
+
return new Literal(`"${value}"@${languageOrDataType.language.toLowerCase()}${languageOrDataType.direction ? `--${languageOrDataType.direction.toLowerCase()}` : ""}`);
|
|
2598
|
+
}
|
|
2599
|
+
let datatype = languageOrDataType ? languageOrDataType.value : "";
|
|
2600
|
+
if (datatype === "") {
|
|
2601
|
+
if (typeof value === "boolean")
|
|
2602
|
+
datatype = xsd2.boolean;
|
|
2603
|
+
else if (typeof value === "number") {
|
|
2604
|
+
if (Number.isFinite(value))
|
|
2605
|
+
datatype = Number.isInteger(value) ? xsd2.integer : xsd2.double;
|
|
2606
|
+
else {
|
|
2607
|
+
datatype = xsd2.double;
|
|
2608
|
+
if (!Number.isNaN(value))
|
|
2609
|
+
value = value > 0 ? "INF" : "-INF";
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
return datatype === "" || datatype === xsd2.string ? new Literal(`"${value}"`) : new Literal(`"${value}"^^${datatype}`);
|
|
2614
|
+
}
|
|
2615
|
+
function variable(name) {
|
|
2616
|
+
return new Variable(name);
|
|
2617
|
+
}
|
|
2618
|
+
function defaultGraph() {
|
|
2619
|
+
return DEFAULTGRAPH;
|
|
2620
|
+
}
|
|
2621
|
+
function quad(subject, predicate, object2, graph) {
|
|
2622
|
+
return new Quad(subject, predicate, object2, graph);
|
|
2623
|
+
}
|
|
2624
|
+
function fromTerm(term) {
|
|
2625
|
+
if (term instanceof Term)
|
|
2626
|
+
return term;
|
|
2627
|
+
switch (term.termType) {
|
|
2628
|
+
case "NamedNode":
|
|
2629
|
+
return namedNode(term.value);
|
|
2630
|
+
case "BlankNode":
|
|
2631
|
+
return blankNode(term.value);
|
|
2632
|
+
case "Variable":
|
|
2633
|
+
return variable(term.value);
|
|
2634
|
+
case "DefaultGraph":
|
|
2635
|
+
return DEFAULTGRAPH;
|
|
2636
|
+
case "Literal":
|
|
2637
|
+
return literal(term.value, term.language || term.datatype);
|
|
2638
|
+
case "Quad":
|
|
2639
|
+
return fromQuad(term);
|
|
2640
|
+
default:
|
|
2641
|
+
throw new Error(`Unexpected termType: ${term.termType}`);
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
function fromQuad(inQuad) {
|
|
2645
|
+
if (inQuad instanceof Quad)
|
|
2646
|
+
return inQuad;
|
|
2647
|
+
if (inQuad.termType !== "Quad")
|
|
2648
|
+
throw new Error(`Unexpected termType: ${inQuad.termType}`);
|
|
2649
|
+
return quad(fromTerm(inQuad.subject), fromTerm(inQuad.predicate), fromTerm(inQuad.object), fromTerm(inQuad.graph));
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
// node_modules/n3/src/N3Parser.js
|
|
2653
|
+
var blankNodePrefix = 0;
|
|
2654
|
+
var N3Parser = class _N3Parser {
|
|
2655
|
+
constructor(options) {
|
|
2656
|
+
this._contextStack = [];
|
|
2657
|
+
this._graph = null;
|
|
2658
|
+
options = options || {};
|
|
2659
|
+
this._setBase(options.baseIRI);
|
|
2660
|
+
options.factory && initDataFactory(this, options.factory);
|
|
2661
|
+
const format = typeof options.format === "string" ? options.format.match(/\w*$/)[0].toLowerCase() : "", isTurtle = /turtle/.test(format), isTriG = /trig/.test(format), isNTriples = /triple/.test(format), isNQuads = /quad/.test(format), isN3 = this._n3Mode = /n3/.test(format), isLineMode = isNTriples || isNQuads;
|
|
2662
|
+
if (!(this._supportsNamedGraphs = !(isTurtle || isN3)))
|
|
2663
|
+
this._readPredicateOrNamedGraph = this._readPredicate;
|
|
2664
|
+
this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
|
|
2665
|
+
this._isImpliedBy = options.isImpliedBy;
|
|
2666
|
+
if (isLineMode)
|
|
2667
|
+
this._resolveRelativeIRI = (iri) => {
|
|
2668
|
+
return null;
|
|
2669
|
+
};
|
|
2670
|
+
this._blankNodePrefix = typeof options.blankNodePrefix !== "string" ? "" : options.blankNodePrefix.replace(/^(?!_:)/, "_:");
|
|
2671
|
+
this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode, n3: isN3, isImpliedBy: this._isImpliedBy });
|
|
2672
|
+
this._explicitQuantifiers = !!options.explicitQuantifiers;
|
|
2673
|
+
this._parseUnsupportedVersions = !!options.parseUnsupportedVersions;
|
|
2674
|
+
this._version = options.version;
|
|
2675
|
+
}
|
|
2676
|
+
// ## Static class methods
|
|
2677
|
+
// ### `_resetBlankNodePrefix` restarts blank node prefix identification
|
|
2678
|
+
static _resetBlankNodePrefix() {
|
|
2679
|
+
blankNodePrefix = 0;
|
|
2680
|
+
}
|
|
2681
|
+
// ## Private methods
|
|
2682
|
+
// ### `_setBase` sets the base IRI to resolve relative IRIs
|
|
2683
|
+
_setBase(baseIRI) {
|
|
2684
|
+
if (!baseIRI) {
|
|
2685
|
+
this._base = "";
|
|
2686
|
+
this._basePath = "";
|
|
2687
|
+
} else {
|
|
2688
|
+
const fragmentPos = baseIRI.indexOf("#");
|
|
2689
|
+
if (fragmentPos >= 0)
|
|
2690
|
+
baseIRI = baseIRI.substr(0, fragmentPos);
|
|
2691
|
+
this._base = baseIRI;
|
|
2692
|
+
this._basePath = baseIRI.indexOf("/") < 0 ? baseIRI : baseIRI.replace(/[^\/?]*(?:\?.*)?$/, "");
|
|
2693
|
+
baseIRI = baseIRI.match(/^(?:([a-z][a-z0-9+.-]*:))?(?:\/\/[^\/]*)?/i);
|
|
2694
|
+
this._baseRoot = baseIRI[0];
|
|
2695
|
+
this._baseScheme = baseIRI[1];
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
// ### `_saveContext` stores the current parsing context
|
|
2699
|
+
// when entering a new scope (list, blank node, formula)
|
|
2700
|
+
_saveContext(type, graph, subject, predicate, object2) {
|
|
2701
|
+
const n3Mode = this._n3Mode;
|
|
2702
|
+
this._contextStack.push({
|
|
2703
|
+
type,
|
|
2704
|
+
subject,
|
|
2705
|
+
predicate,
|
|
2706
|
+
object: object2,
|
|
2707
|
+
graph,
|
|
2708
|
+
inverse: n3Mode ? this._inversePredicate : false,
|
|
2709
|
+
blankPrefix: n3Mode ? this._prefixes._ : "",
|
|
2710
|
+
quantified: n3Mode ? this._quantified : null
|
|
2711
|
+
});
|
|
2712
|
+
if (n3Mode) {
|
|
2713
|
+
this._inversePredicate = false;
|
|
2714
|
+
this._prefixes._ = this._graph ? `${this._graph.value}.` : ".";
|
|
2715
|
+
this._quantified = Object.create(this._quantified);
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
// ### `_restoreContext` restores the parent context
|
|
2719
|
+
// when leaving a scope (list, blank node, formula)
|
|
2720
|
+
_restoreContext(type, token2) {
|
|
2721
|
+
const context = this._contextStack.pop();
|
|
2722
|
+
if (!context || context.type !== type)
|
|
2723
|
+
return this._error(`Unexpected ${token2.type}`, token2);
|
|
2724
|
+
this._subject = context.subject;
|
|
2725
|
+
this._predicate = context.predicate;
|
|
2726
|
+
this._object = context.object;
|
|
2727
|
+
this._graph = context.graph;
|
|
2728
|
+
if (this._n3Mode) {
|
|
2729
|
+
this._inversePredicate = context.inverse;
|
|
2730
|
+
this._prefixes._ = context.blankPrefix;
|
|
2731
|
+
this._quantified = context.quantified;
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
// ### `_readBeforeTopContext` is called once only at the start of parsing.
|
|
2735
|
+
_readBeforeTopContext(token2) {
|
|
2736
|
+
if (this._version && !this._isValidVersion(this._version))
|
|
2737
|
+
return this._error(`Detected unsupported version as media type parameter: "${this._version}"`, token2);
|
|
2738
|
+
return this._readInTopContext(token2);
|
|
2739
|
+
}
|
|
2740
|
+
// ### `_readInTopContext` reads a token when in the top context
|
|
2741
|
+
_readInTopContext(token2) {
|
|
2742
|
+
switch (token2.type) {
|
|
2743
|
+
// If an EOF token arrives in the top context, signal that we're done
|
|
2744
|
+
case "eof":
|
|
2745
|
+
if (this._graph !== null)
|
|
2746
|
+
return this._error("Unclosed graph", token2);
|
|
2747
|
+
delete this._prefixes._;
|
|
2748
|
+
return this._callback(null, null, this._prefixes);
|
|
2749
|
+
// It could be a prefix declaration
|
|
2750
|
+
case "PREFIX":
|
|
2751
|
+
this._sparqlStyle = true;
|
|
2752
|
+
case "@prefix":
|
|
2753
|
+
return this._readPrefix;
|
|
2754
|
+
// It could be a base declaration
|
|
2755
|
+
case "BASE":
|
|
2756
|
+
this._sparqlStyle = true;
|
|
2757
|
+
case "@base":
|
|
2758
|
+
return this._readBaseIRI;
|
|
2759
|
+
// It could be a version declaration
|
|
2760
|
+
case "VERSION":
|
|
2761
|
+
this._sparqlStyle = true;
|
|
2762
|
+
case "@version":
|
|
2763
|
+
return this._readVersion;
|
|
2764
|
+
// It could be a graph
|
|
2765
|
+
case "{":
|
|
2766
|
+
if (this._supportsNamedGraphs) {
|
|
2767
|
+
this._graph = "";
|
|
2768
|
+
this._subject = null;
|
|
2769
|
+
return this._readSubject;
|
|
2770
|
+
}
|
|
2771
|
+
case "GRAPH":
|
|
2772
|
+
if (this._supportsNamedGraphs)
|
|
2773
|
+
return this._readNamedGraphLabel;
|
|
2774
|
+
// Otherwise, the next token must be a subject
|
|
2775
|
+
default:
|
|
2776
|
+
return this._readSubject(token2);
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
// ### `_readEntity` reads an IRI, prefixed name, blank node, or variable
|
|
2780
|
+
_readEntity(token2, quantifier) {
|
|
2781
|
+
let value;
|
|
2782
|
+
switch (token2.type) {
|
|
2783
|
+
// Read a relative or absolute IRI
|
|
2784
|
+
case "IRI":
|
|
2785
|
+
case "typeIRI":
|
|
2786
|
+
const iri = this._resolveIRI(token2.value);
|
|
2787
|
+
if (iri === null)
|
|
2788
|
+
return this._error("Invalid IRI", token2);
|
|
2789
|
+
value = this._factory.namedNode(iri);
|
|
2790
|
+
break;
|
|
2791
|
+
// Read a prefixed name
|
|
2792
|
+
case "type":
|
|
2793
|
+
case "prefixed":
|
|
2794
|
+
const prefix = this._prefixes[token2.prefix];
|
|
2795
|
+
if (prefix === void 0)
|
|
2796
|
+
return this._error(`Undefined prefix "${token2.prefix}:"`, token2);
|
|
2797
|
+
value = this._factory.namedNode(prefix + token2.value);
|
|
2798
|
+
break;
|
|
2799
|
+
// Read a blank node
|
|
2800
|
+
case "blank":
|
|
2801
|
+
value = this._factory.blankNode(this._prefixes[token2.prefix] + token2.value);
|
|
2802
|
+
break;
|
|
2803
|
+
// Read a variable
|
|
2804
|
+
case "var":
|
|
2805
|
+
value = this._factory.variable(token2.value.substr(1));
|
|
2806
|
+
break;
|
|
2807
|
+
// Everything else is not an entity
|
|
2808
|
+
default:
|
|
2809
|
+
return this._error(`Expected entity but got ${token2.type}`, token2);
|
|
2810
|
+
}
|
|
2811
|
+
if (!quantifier && this._n3Mode && value.id in this._quantified)
|
|
2812
|
+
value = this._quantified[value.id];
|
|
2813
|
+
return value;
|
|
2814
|
+
}
|
|
2815
|
+
// ### `_readSubject` reads a quad's subject
|
|
2816
|
+
_readSubject(token2) {
|
|
2817
|
+
this._predicate = null;
|
|
2818
|
+
switch (token2.type) {
|
|
2819
|
+
case "[":
|
|
2820
|
+
this._saveContext(
|
|
2821
|
+
"blank",
|
|
2822
|
+
this._graph,
|
|
2823
|
+
this._subject = this._factory.blankNode(),
|
|
2824
|
+
null,
|
|
2825
|
+
null
|
|
2826
|
+
);
|
|
2827
|
+
return this._readBlankNodeHead;
|
|
2828
|
+
case "(":
|
|
2829
|
+
const stack = this._contextStack, parent2 = stack.length && stack[stack.length - 1];
|
|
2830
|
+
if (parent2.type === "<<") {
|
|
2831
|
+
return this._error("Unexpected list in reified triple", token2);
|
|
2832
|
+
}
|
|
2833
|
+
this._saveContext("list", this._graph, this.RDF_NIL, null, null);
|
|
2834
|
+
this._subject = null;
|
|
2835
|
+
return this._readListItem;
|
|
2836
|
+
case "{":
|
|
2837
|
+
if (!this._n3Mode)
|
|
2838
|
+
return this._error("Unexpected graph", token2);
|
|
2839
|
+
this._saveContext(
|
|
2840
|
+
"formula",
|
|
2841
|
+
this._graph,
|
|
2842
|
+
this._graph = this._factory.blankNode(),
|
|
2843
|
+
null,
|
|
2844
|
+
null
|
|
2845
|
+
);
|
|
2846
|
+
return this._readSubject;
|
|
2847
|
+
case "}":
|
|
2848
|
+
return this._readPunctuation(token2);
|
|
2849
|
+
case "@forSome":
|
|
2850
|
+
if (!this._n3Mode)
|
|
2851
|
+
return this._error('Unexpected "@forSome"', token2);
|
|
2852
|
+
this._subject = null;
|
|
2853
|
+
this._predicate = this.N3_FORSOME;
|
|
2854
|
+
this._quantifier = "blankNode";
|
|
2855
|
+
return this._readQuantifierList;
|
|
2856
|
+
case "@forAll":
|
|
2857
|
+
if (!this._n3Mode)
|
|
2858
|
+
return this._error('Unexpected "@forAll"', token2);
|
|
2859
|
+
this._subject = null;
|
|
2860
|
+
this._predicate = this.N3_FORALL;
|
|
2861
|
+
this._quantifier = "variable";
|
|
2862
|
+
return this._readQuantifierList;
|
|
2863
|
+
case "literal":
|
|
2864
|
+
if (!this._n3Mode)
|
|
2865
|
+
return this._error("Unexpected literal", token2);
|
|
2866
|
+
if (token2.prefix.length === 0) {
|
|
2867
|
+
this._literalValue = token2.value;
|
|
2868
|
+
return this._completeSubjectLiteral;
|
|
2869
|
+
} else
|
|
2870
|
+
this._subject = this._factory.literal(token2.value, this._factory.namedNode(token2.prefix));
|
|
2871
|
+
break;
|
|
2872
|
+
case "<<(":
|
|
2873
|
+
if (!this._n3Mode)
|
|
2874
|
+
return this._error("Disallowed triple term as subject", token2);
|
|
2875
|
+
this._saveContext("<<(", this._graph, null, null, null);
|
|
2876
|
+
this._graph = null;
|
|
2877
|
+
return this._readSubject;
|
|
2878
|
+
case "<<":
|
|
2879
|
+
this._saveContext("<<", this._graph, null, null, null);
|
|
2880
|
+
this._graph = null;
|
|
2881
|
+
return this._readSubject;
|
|
2882
|
+
default:
|
|
2883
|
+
if ((this._subject = this._readEntity(token2)) === void 0)
|
|
2884
|
+
return;
|
|
2885
|
+
if (this._n3Mode)
|
|
2886
|
+
return this._getPathReader(this._readPredicateOrNamedGraph);
|
|
2887
|
+
}
|
|
2888
|
+
return this._readPredicateOrNamedGraph;
|
|
2889
|
+
}
|
|
2890
|
+
// ### `_readPredicate` reads a quad's predicate
|
|
2891
|
+
_readPredicate(token2) {
|
|
2892
|
+
const type = token2.type;
|
|
2893
|
+
switch (type) {
|
|
2894
|
+
case "inverse":
|
|
2895
|
+
this._inversePredicate = true;
|
|
2896
|
+
case "abbreviation":
|
|
2897
|
+
this._predicate = this.ABBREVIATIONS[token2.value];
|
|
2898
|
+
break;
|
|
2899
|
+
case ".":
|
|
2900
|
+
case "]":
|
|
2901
|
+
case "}":
|
|
2902
|
+
case "|}":
|
|
2903
|
+
if (this._predicate === null)
|
|
2904
|
+
return this._error(`Unexpected ${type}`, token2);
|
|
2905
|
+
this._subject = null;
|
|
2906
|
+
return type === "]" ? this._readBlankNodeTail(token2) : this._readPunctuation(token2);
|
|
2907
|
+
case ";":
|
|
2908
|
+
return this._predicate !== null ? this._readPredicate : this._error("Expected predicate but got ;", token2);
|
|
2909
|
+
case "[":
|
|
2910
|
+
if (this._n3Mode) {
|
|
2911
|
+
this._saveContext(
|
|
2912
|
+
"blank",
|
|
2913
|
+
this._graph,
|
|
2914
|
+
this._subject,
|
|
2915
|
+
this._subject = this._factory.blankNode(),
|
|
2916
|
+
null
|
|
2917
|
+
);
|
|
2918
|
+
return this._readBlankNodeHead;
|
|
2919
|
+
}
|
|
2920
|
+
case "blank":
|
|
2921
|
+
if (!this._n3Mode)
|
|
2922
|
+
return this._error("Disallowed blank node as predicate", token2);
|
|
2923
|
+
default:
|
|
2924
|
+
if ((this._predicate = this._readEntity(token2)) === void 0)
|
|
2925
|
+
return;
|
|
2926
|
+
}
|
|
2927
|
+
this._validAnnotation = true;
|
|
2928
|
+
return this._readObject;
|
|
2929
|
+
}
|
|
2930
|
+
// ### `_readObject` reads a quad's object
|
|
2931
|
+
_readObject(token2) {
|
|
2932
|
+
switch (token2.type) {
|
|
2933
|
+
case "literal":
|
|
2934
|
+
if (token2.prefix.length === 0) {
|
|
2935
|
+
this._literalValue = token2.value;
|
|
2936
|
+
return this._readDataTypeOrLang;
|
|
2937
|
+
} else
|
|
2938
|
+
this._object = this._factory.literal(token2.value, this._factory.namedNode(token2.prefix));
|
|
2939
|
+
break;
|
|
2940
|
+
case "[":
|
|
2941
|
+
this._saveContext(
|
|
2942
|
+
"blank",
|
|
2943
|
+
this._graph,
|
|
2944
|
+
this._subject,
|
|
2945
|
+
this._predicate,
|
|
2946
|
+
this._subject = this._factory.blankNode()
|
|
2947
|
+
);
|
|
2948
|
+
return this._readBlankNodeHead;
|
|
2949
|
+
case "(":
|
|
2950
|
+
const stack = this._contextStack, parent2 = stack.length && stack[stack.length - 1];
|
|
2951
|
+
if (parent2.type === "<<") {
|
|
2952
|
+
return this._error("Unexpected list in reified triple", token2);
|
|
2953
|
+
}
|
|
2954
|
+
this._saveContext("list", this._graph, this._subject, this._predicate, this.RDF_NIL);
|
|
2955
|
+
this._subject = null;
|
|
2956
|
+
return this._readListItem;
|
|
2957
|
+
case "{":
|
|
2958
|
+
if (!this._n3Mode)
|
|
2959
|
+
return this._error("Unexpected graph", token2);
|
|
2960
|
+
this._saveContext(
|
|
2961
|
+
"formula",
|
|
2962
|
+
this._graph,
|
|
2963
|
+
this._subject,
|
|
2964
|
+
this._predicate,
|
|
2965
|
+
this._graph = this._factory.blankNode()
|
|
2966
|
+
);
|
|
2967
|
+
return this._readSubject;
|
|
2968
|
+
case "<<(":
|
|
2969
|
+
this._saveContext("<<(", this._graph, this._subject, this._predicate, null);
|
|
2970
|
+
this._graph = null;
|
|
2971
|
+
return this._readSubject;
|
|
2972
|
+
case "<<":
|
|
2973
|
+
this._saveContext("<<", this._graph, this._subject, this._predicate, null);
|
|
2974
|
+
this._graph = null;
|
|
2975
|
+
return this._readSubject;
|
|
2976
|
+
default:
|
|
2977
|
+
if ((this._object = this._readEntity(token2)) === void 0)
|
|
2978
|
+
return;
|
|
2979
|
+
if (this._n3Mode)
|
|
2980
|
+
return this._getPathReader(this._getContextEndReader());
|
|
2981
|
+
}
|
|
2982
|
+
return this._getContextEndReader();
|
|
2983
|
+
}
|
|
2984
|
+
// ### `_readPredicateOrNamedGraph` reads a quad's predicate, or a named graph
|
|
2985
|
+
_readPredicateOrNamedGraph(token2) {
|
|
2986
|
+
return token2.type === "{" ? this._readGraph(token2) : this._readPredicate(token2);
|
|
2987
|
+
}
|
|
2988
|
+
// ### `_readGraph` reads a graph
|
|
2989
|
+
_readGraph(token2) {
|
|
2990
|
+
if (token2.type !== "{")
|
|
2991
|
+
return this._error(`Expected graph but got ${token2.type}`, token2);
|
|
2992
|
+
this._graph = this._subject, this._subject = null;
|
|
2993
|
+
return this._readSubject;
|
|
2994
|
+
}
|
|
2995
|
+
// ### `_readBlankNodeHead` reads the head of a blank node
|
|
2996
|
+
_readBlankNodeHead(token2) {
|
|
2997
|
+
if (token2.type === "]") {
|
|
2998
|
+
this._subject = null;
|
|
2999
|
+
return this._readBlankNodeTail(token2);
|
|
3000
|
+
} else {
|
|
3001
|
+
const stack = this._contextStack, parentParent = stack.length > 1 && stack[stack.length - 2];
|
|
3002
|
+
if (parentParent.type === "<<") {
|
|
3003
|
+
return this._error("Unexpected compound blank node expression in reified triple", token2);
|
|
3004
|
+
}
|
|
3005
|
+
this._predicate = null;
|
|
3006
|
+
return this._readPredicate(token2);
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
// ### `_readBlankNodeTail` reads the end of a blank node
|
|
3010
|
+
_readBlankNodeTail(token2) {
|
|
3011
|
+
if (token2.type !== "]")
|
|
3012
|
+
return this._readBlankNodePunctuation(token2);
|
|
3013
|
+
if (this._subject !== null)
|
|
3014
|
+
this._emit(this._subject, this._predicate, this._object, this._graph);
|
|
3015
|
+
const empty2 = this._predicate === null;
|
|
3016
|
+
this._restoreContext("blank", token2);
|
|
3017
|
+
if (this._object !== null)
|
|
3018
|
+
return this._getContextEndReader();
|
|
3019
|
+
else if (this._predicate !== null)
|
|
3020
|
+
return this._readObject;
|
|
3021
|
+
else
|
|
3022
|
+
return empty2 ? this._readPredicateOrNamedGraph : this._readPredicateAfterBlank;
|
|
3023
|
+
}
|
|
3024
|
+
// ### `_readPredicateAfterBlank` reads a predicate after an anonymous blank node
|
|
3025
|
+
_readPredicateAfterBlank(token2) {
|
|
3026
|
+
switch (token2.type) {
|
|
3027
|
+
case ".":
|
|
3028
|
+
case "}":
|
|
3029
|
+
this._subject = null;
|
|
3030
|
+
return this._readPunctuation(token2);
|
|
3031
|
+
default:
|
|
3032
|
+
return this._readPredicate(token2);
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
// ### `_readListItem` reads items from a list
|
|
3036
|
+
_readListItem(token2) {
|
|
3037
|
+
let item = null, list = null, next3 = this._readListItem;
|
|
3038
|
+
const previousList = this._subject, stack = this._contextStack, parent2 = stack[stack.length - 1];
|
|
3039
|
+
switch (token2.type) {
|
|
3040
|
+
case "[":
|
|
3041
|
+
this._saveContext(
|
|
3042
|
+
"blank",
|
|
3043
|
+
this._graph,
|
|
3044
|
+
list = this._factory.blankNode(),
|
|
3045
|
+
this.RDF_FIRST,
|
|
3046
|
+
this._subject = item = this._factory.blankNode()
|
|
3047
|
+
);
|
|
3048
|
+
next3 = this._readBlankNodeHead;
|
|
3049
|
+
break;
|
|
3050
|
+
case "(":
|
|
3051
|
+
this._saveContext(
|
|
3052
|
+
"list",
|
|
3053
|
+
this._graph,
|
|
3054
|
+
list = this._factory.blankNode(),
|
|
3055
|
+
this.RDF_FIRST,
|
|
3056
|
+
this.RDF_NIL
|
|
3057
|
+
);
|
|
3058
|
+
this._subject = null;
|
|
3059
|
+
break;
|
|
3060
|
+
case ")":
|
|
3061
|
+
this._restoreContext("list", token2);
|
|
3062
|
+
if (stack.length !== 0 && stack[stack.length - 1].type === "list")
|
|
3063
|
+
this._emit(this._subject, this._predicate, this._object, this._graph);
|
|
3064
|
+
if (this._predicate === null) {
|
|
3065
|
+
next3 = this._readPredicate;
|
|
3066
|
+
if (this._subject === this.RDF_NIL)
|
|
3067
|
+
return next3;
|
|
3068
|
+
} else {
|
|
3069
|
+
next3 = this._getContextEndReader();
|
|
3070
|
+
if (this._object === this.RDF_NIL)
|
|
3071
|
+
return next3;
|
|
3072
|
+
}
|
|
3073
|
+
list = this.RDF_NIL;
|
|
3074
|
+
break;
|
|
3075
|
+
case "literal":
|
|
3076
|
+
if (token2.prefix.length === 0) {
|
|
3077
|
+
this._literalValue = token2.value;
|
|
3078
|
+
next3 = this._readListItemDataTypeOrLang;
|
|
3079
|
+
} else {
|
|
3080
|
+
item = this._factory.literal(token2.value, this._factory.namedNode(token2.prefix));
|
|
3081
|
+
next3 = this._getContextEndReader();
|
|
3082
|
+
}
|
|
3083
|
+
break;
|
|
3084
|
+
case "{":
|
|
3085
|
+
if (!this._n3Mode)
|
|
3086
|
+
return this._error("Unexpected graph", token2);
|
|
3087
|
+
this._saveContext(
|
|
3088
|
+
"formula",
|
|
3089
|
+
this._graph,
|
|
3090
|
+
this._subject,
|
|
3091
|
+
this._predicate,
|
|
3092
|
+
this._graph = this._factory.blankNode()
|
|
3093
|
+
);
|
|
3094
|
+
return this._readSubject;
|
|
3095
|
+
case "<<":
|
|
3096
|
+
this._saveContext("<<", this._graph, null, null, null);
|
|
3097
|
+
this._graph = null;
|
|
3098
|
+
next3 = this._readSubject;
|
|
3099
|
+
break;
|
|
3100
|
+
default:
|
|
3101
|
+
if ((item = this._readEntity(token2)) === void 0)
|
|
3102
|
+
return;
|
|
3103
|
+
}
|
|
3104
|
+
if (list === null)
|
|
3105
|
+
this._subject = list = this._factory.blankNode();
|
|
3106
|
+
if (token2.type === "<<")
|
|
3107
|
+
stack[stack.length - 1].subject = this._subject;
|
|
3108
|
+
if (previousList === null) {
|
|
3109
|
+
if (parent2.predicate === null)
|
|
3110
|
+
parent2.subject = list;
|
|
3111
|
+
else
|
|
3112
|
+
parent2.object = list;
|
|
3113
|
+
} else {
|
|
3114
|
+
this._emit(previousList, this.RDF_REST, list, this._graph);
|
|
3115
|
+
}
|
|
3116
|
+
if (item !== null) {
|
|
3117
|
+
if (this._n3Mode && (token2.type === "IRI" || token2.type === "prefixed")) {
|
|
3118
|
+
this._saveContext("item", this._graph, list, this.RDF_FIRST, item);
|
|
3119
|
+
this._subject = item, this._predicate = null;
|
|
3120
|
+
return this._getPathReader(this._readListItem);
|
|
3121
|
+
}
|
|
3122
|
+
this._emit(list, this.RDF_FIRST, item, this._graph);
|
|
3123
|
+
}
|
|
3124
|
+
return next3;
|
|
3125
|
+
}
|
|
3126
|
+
// ### `_readDataTypeOrLang` reads an _optional_ datatype or language
|
|
3127
|
+
_readDataTypeOrLang(token2) {
|
|
3128
|
+
return this._completeObjectLiteral(token2, false);
|
|
3129
|
+
}
|
|
3130
|
+
// ### `_readListItemDataTypeOrLang` reads an _optional_ datatype or language in a list
|
|
3131
|
+
_readListItemDataTypeOrLang(token2) {
|
|
3132
|
+
return this._completeObjectLiteral(token2, true);
|
|
3133
|
+
}
|
|
3134
|
+
// ### `_completeLiteral` completes a literal with an optional datatype or language
|
|
3135
|
+
_completeLiteral(token2, component) {
|
|
3136
|
+
let literal2 = this._factory.literal(this._literalValue);
|
|
3137
|
+
let readCb;
|
|
3138
|
+
switch (token2.type) {
|
|
3139
|
+
// Create a datatyped literal
|
|
3140
|
+
case "type":
|
|
3141
|
+
case "typeIRI":
|
|
3142
|
+
const datatype = this._readEntity(token2);
|
|
3143
|
+
if (datatype === void 0) return;
|
|
3144
|
+
if (datatype.value === IRIs_default.rdf.langString || datatype.value === IRIs_default.rdf.dirLangString) {
|
|
3145
|
+
return this._error("Detected illegal (directional) languaged-tagged string with explicit datatype", token2);
|
|
3146
|
+
}
|
|
3147
|
+
literal2 = this._factory.literal(this._literalValue, datatype);
|
|
3148
|
+
token2 = null;
|
|
3149
|
+
break;
|
|
3150
|
+
// Create a language-tagged string
|
|
3151
|
+
case "langcode":
|
|
3152
|
+
if (token2.value.length > 8)
|
|
3153
|
+
return this._error("Detected language tag of length larger than 8", token2);
|
|
3154
|
+
literal2 = this._factory.literal(this._literalValue, token2.value);
|
|
3155
|
+
this._literalLanguage = token2.value;
|
|
3156
|
+
token2 = null;
|
|
3157
|
+
readCb = this._readDirCode.bind(this, component);
|
|
3158
|
+
break;
|
|
3159
|
+
}
|
|
3160
|
+
return { token: token2, literal: literal2, readCb };
|
|
3161
|
+
}
|
|
3162
|
+
_readDirCode(component, listItem, token2) {
|
|
3163
|
+
if (token2.type === "dircode") {
|
|
3164
|
+
const term = this._factory.literal(this._literalValue, { language: this._literalLanguage, direction: token2.value });
|
|
3165
|
+
if (component === "subject")
|
|
3166
|
+
this._subject = term;
|
|
3167
|
+
else
|
|
3168
|
+
this._object = term;
|
|
3169
|
+
this._literalLanguage = void 0;
|
|
3170
|
+
token2 = null;
|
|
3171
|
+
}
|
|
3172
|
+
if (component === "subject")
|
|
3173
|
+
return token2 === null ? this._readPredicateOrNamedGraph : this._readPredicateOrNamedGraph(token2);
|
|
3174
|
+
return this._completeObjectLiteralPost(token2, listItem);
|
|
3175
|
+
}
|
|
3176
|
+
// Completes a literal in subject position
|
|
3177
|
+
_completeSubjectLiteral(token2) {
|
|
3178
|
+
const completed = this._completeLiteral(token2, "subject");
|
|
3179
|
+
this._subject = completed.literal;
|
|
3180
|
+
if (completed.readCb)
|
|
3181
|
+
return completed.readCb.bind(this, false);
|
|
3182
|
+
return this._readPredicateOrNamedGraph;
|
|
3183
|
+
}
|
|
3184
|
+
// Completes a literal in object position
|
|
3185
|
+
_completeObjectLiteral(token2, listItem) {
|
|
3186
|
+
const completed = this._completeLiteral(token2, "object");
|
|
3187
|
+
if (!completed)
|
|
3188
|
+
return;
|
|
3189
|
+
this._object = completed.literal;
|
|
3190
|
+
if (completed.readCb)
|
|
3191
|
+
return completed.readCb.bind(this, listItem);
|
|
3192
|
+
return this._completeObjectLiteralPost(completed.token, listItem);
|
|
3193
|
+
}
|
|
3194
|
+
_completeObjectLiteralPost(token2, listItem) {
|
|
3195
|
+
if (listItem)
|
|
3196
|
+
this._emit(this._subject, this.RDF_FIRST, this._object, this._graph);
|
|
3197
|
+
if (token2 === null)
|
|
3198
|
+
return this._getContextEndReader();
|
|
3199
|
+
else {
|
|
3200
|
+
this._readCallback = this._getContextEndReader();
|
|
3201
|
+
return this._readCallback(token2);
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
// ### `_readFormulaTail` reads the end of a formula
|
|
3205
|
+
_readFormulaTail(token2) {
|
|
3206
|
+
if (token2.type !== "}")
|
|
3207
|
+
return this._readPunctuation(token2);
|
|
3208
|
+
if (this._subject !== null)
|
|
3209
|
+
this._emit(this._subject, this._predicate, this._object, this._graph);
|
|
3210
|
+
this._restoreContext("formula", token2);
|
|
3211
|
+
return this._object === null ? this._readPredicate : this._getContextEndReader();
|
|
3212
|
+
}
|
|
3213
|
+
// ### `_readPunctuation` reads punctuation between quads or quad parts
|
|
3214
|
+
_readPunctuation(token2) {
|
|
3215
|
+
let next3, graph = this._graph, startingAnnotation = false;
|
|
3216
|
+
const subject = this._subject, inversePredicate = this._inversePredicate;
|
|
3217
|
+
switch (token2.type) {
|
|
3218
|
+
// A closing brace ends a graph
|
|
3219
|
+
case "}":
|
|
3220
|
+
if (this._graph === null)
|
|
3221
|
+
return this._error("Unexpected graph closing", token2);
|
|
3222
|
+
if (this._n3Mode)
|
|
3223
|
+
return this._readFormulaTail(token2);
|
|
3224
|
+
this._graph = null;
|
|
3225
|
+
// A dot just ends the statement, without sharing anything with the next
|
|
3226
|
+
case ".":
|
|
3227
|
+
this._subject = null;
|
|
3228
|
+
this._tripleTerm = null;
|
|
3229
|
+
next3 = this._contextStack.length ? this._readSubject : this._readInTopContext;
|
|
3230
|
+
if (inversePredicate) this._inversePredicate = false;
|
|
3231
|
+
break;
|
|
3232
|
+
// Semicolon means the subject is shared; predicate and object are different
|
|
3233
|
+
case ";":
|
|
3234
|
+
next3 = this._readPredicate;
|
|
3235
|
+
break;
|
|
3236
|
+
// Comma means both the subject and predicate are shared; the object is different
|
|
3237
|
+
case ",":
|
|
3238
|
+
next3 = this._readObject;
|
|
3239
|
+
break;
|
|
3240
|
+
// ~ is allowed in the annotation syntax
|
|
3241
|
+
case "~":
|
|
3242
|
+
next3 = this._readReifierInAnnotation;
|
|
3243
|
+
startingAnnotation = true;
|
|
3244
|
+
break;
|
|
3245
|
+
// {| means that the current triple is annotated with predicate-object pairs.
|
|
3246
|
+
case "{|":
|
|
3247
|
+
this._subject = this._readTripleTerm();
|
|
3248
|
+
this._validAnnotation = false;
|
|
3249
|
+
startingAnnotation = true;
|
|
3250
|
+
next3 = this._readPredicate;
|
|
3251
|
+
break;
|
|
3252
|
+
// |} means that the current reified triple in annotation syntax is finalized.
|
|
3253
|
+
case "|}":
|
|
3254
|
+
if (!this._annotation)
|
|
3255
|
+
return this._error("Unexpected annotation syntax closing", token2);
|
|
3256
|
+
if (!this._validAnnotation)
|
|
3257
|
+
return this._error("Annotation block can not be empty", token2);
|
|
3258
|
+
this._subject = null;
|
|
3259
|
+
this._annotation = false;
|
|
3260
|
+
next3 = this._readPunctuation;
|
|
3261
|
+
break;
|
|
3262
|
+
default:
|
|
3263
|
+
if (this._supportsQuads && this._graph === null && (graph = this._readEntity(token2)) !== void 0) {
|
|
3264
|
+
next3 = this._readQuadPunctuation;
|
|
3265
|
+
break;
|
|
3266
|
+
}
|
|
3267
|
+
return this._error(`Expected punctuation to follow "${this._object.id}"`, token2);
|
|
3268
|
+
}
|
|
3269
|
+
if (subject !== null && (!startingAnnotation || startingAnnotation && !this._annotation)) {
|
|
3270
|
+
const predicate = this._predicate, object2 = this._object;
|
|
3271
|
+
if (!inversePredicate)
|
|
3272
|
+
this._emit(subject, predicate, object2, graph);
|
|
3273
|
+
else
|
|
3274
|
+
this._emit(object2, predicate, subject, graph);
|
|
3275
|
+
}
|
|
3276
|
+
if (startingAnnotation) {
|
|
3277
|
+
this._annotation = true;
|
|
3278
|
+
}
|
|
3279
|
+
return next3;
|
|
3280
|
+
}
|
|
3281
|
+
// ### `_readBlankNodePunctuation` reads punctuation in a blank node
|
|
3282
|
+
_readBlankNodePunctuation(token2) {
|
|
3283
|
+
let next3;
|
|
3284
|
+
switch (token2.type) {
|
|
3285
|
+
// Semicolon means the subject is shared; predicate and object are different
|
|
3286
|
+
case ";":
|
|
3287
|
+
next3 = this._readPredicate;
|
|
3288
|
+
break;
|
|
3289
|
+
// Comma means both the subject and predicate are shared; the object is different
|
|
3290
|
+
case ",":
|
|
3291
|
+
next3 = this._readObject;
|
|
3292
|
+
break;
|
|
3293
|
+
default:
|
|
3294
|
+
return this._error(`Expected punctuation to follow "${this._object.id}"`, token2);
|
|
3295
|
+
}
|
|
3296
|
+
this._emit(this._subject, this._predicate, this._object, this._graph);
|
|
3297
|
+
return next3;
|
|
3298
|
+
}
|
|
3299
|
+
// ### `_readQuadPunctuation` reads punctuation after a quad
|
|
3300
|
+
_readQuadPunctuation(token2) {
|
|
3301
|
+
if (token2.type !== ".")
|
|
3302
|
+
return this._error("Expected dot to follow quad", token2);
|
|
3303
|
+
return this._readInTopContext;
|
|
3304
|
+
}
|
|
3305
|
+
// ### `_readPrefix` reads the prefix of a prefix declaration
|
|
3306
|
+
_readPrefix(token2) {
|
|
3307
|
+
if (token2.type !== "prefix")
|
|
3308
|
+
return this._error("Expected prefix to follow @prefix", token2);
|
|
3309
|
+
this._prefix = token2.value;
|
|
3310
|
+
return this._readPrefixIRI;
|
|
3311
|
+
}
|
|
3312
|
+
// ### `_readPrefixIRI` reads the IRI of a prefix declaration
|
|
3313
|
+
_readPrefixIRI(token2) {
|
|
3314
|
+
if (token2.type !== "IRI")
|
|
3315
|
+
return this._error(`Expected IRI to follow prefix "${this._prefix}:"`, token2);
|
|
3316
|
+
const prefixNode = this._readEntity(token2);
|
|
3317
|
+
this._prefixes[this._prefix] = prefixNode.value;
|
|
3318
|
+
this._prefixCallback(this._prefix, prefixNode);
|
|
3319
|
+
return this._readDeclarationPunctuation;
|
|
3320
|
+
}
|
|
3321
|
+
// ### `_readBaseIRI` reads the IRI of a base declaration
|
|
3322
|
+
_readBaseIRI(token2) {
|
|
3323
|
+
const iri = token2.type === "IRI" && this._resolveIRI(token2.value);
|
|
3324
|
+
if (!iri)
|
|
3325
|
+
return this._error("Expected valid IRI to follow base declaration", token2);
|
|
3326
|
+
this._setBase(iri);
|
|
3327
|
+
return this._readDeclarationPunctuation;
|
|
3328
|
+
}
|
|
3329
|
+
// ### `_isValidVersion` checks if the given version is valid for this parser to handle.
|
|
3330
|
+
_isValidVersion(version2) {
|
|
3331
|
+
return this._parseUnsupportedVersions || _N3Parser.SUPPORTED_VERSIONS.includes(version2);
|
|
3332
|
+
}
|
|
3333
|
+
// ### `_readVersion` reads version string declaration
|
|
3334
|
+
_readVersion(token2) {
|
|
3335
|
+
if (token2.type !== "literal")
|
|
3336
|
+
return this._error("Expected literal to follow version declaration", token2);
|
|
3337
|
+
if (token2.end - token2.start !== token2.value.length + 2)
|
|
3338
|
+
return this._error("Version declarations must use single quotes", token2);
|
|
3339
|
+
this._versionCallback(token2.value);
|
|
3340
|
+
if (!this._isValidVersion(token2.value))
|
|
3341
|
+
return this._error(`Detected unsupported version: "${token2.value}"`, token2);
|
|
3342
|
+
return this._readDeclarationPunctuation;
|
|
3343
|
+
}
|
|
3344
|
+
// ### `_readNamedGraphLabel` reads the label of a named graph
|
|
3345
|
+
_readNamedGraphLabel(token2) {
|
|
3346
|
+
switch (token2.type) {
|
|
3347
|
+
case "IRI":
|
|
3348
|
+
case "blank":
|
|
3349
|
+
case "prefixed":
|
|
3350
|
+
return this._readSubject(token2), this._readGraph;
|
|
3351
|
+
case "[":
|
|
3352
|
+
return this._readNamedGraphBlankLabel;
|
|
3353
|
+
default:
|
|
3354
|
+
return this._error("Invalid graph label", token2);
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
// ### `_readNamedGraphLabel` reads a blank node label of a named graph
|
|
3358
|
+
_readNamedGraphBlankLabel(token2) {
|
|
3359
|
+
if (token2.type !== "]")
|
|
3360
|
+
return this._error("Invalid graph label", token2);
|
|
3361
|
+
this._subject = this._factory.blankNode();
|
|
3362
|
+
return this._readGraph;
|
|
3363
|
+
}
|
|
3364
|
+
// ### `_readDeclarationPunctuation` reads the punctuation of a declaration
|
|
3365
|
+
_readDeclarationPunctuation(token2) {
|
|
3366
|
+
if (this._sparqlStyle) {
|
|
3367
|
+
this._sparqlStyle = false;
|
|
3368
|
+
return this._readInTopContext(token2);
|
|
3369
|
+
}
|
|
3370
|
+
if (token2.type !== ".")
|
|
3371
|
+
return this._error("Expected declaration to end with a dot", token2);
|
|
3372
|
+
return this._readInTopContext;
|
|
3373
|
+
}
|
|
3374
|
+
// Reads a list of quantified symbols from a @forSome or @forAll statement
|
|
3375
|
+
_readQuantifierList(token2) {
|
|
3376
|
+
let entity;
|
|
3377
|
+
switch (token2.type) {
|
|
3378
|
+
case "IRI":
|
|
3379
|
+
case "prefixed":
|
|
3380
|
+
if ((entity = this._readEntity(token2, true)) !== void 0)
|
|
3381
|
+
break;
|
|
3382
|
+
default:
|
|
3383
|
+
return this._error(`Unexpected ${token2.type}`, token2);
|
|
3384
|
+
}
|
|
3385
|
+
if (!this._explicitQuantifiers)
|
|
3386
|
+
this._quantified[entity.id] = this._factory[this._quantifier](this._factory.blankNode().value);
|
|
3387
|
+
else {
|
|
3388
|
+
if (this._subject === null)
|
|
3389
|
+
this._emit(
|
|
3390
|
+
this._graph || this.DEFAULTGRAPH,
|
|
3391
|
+
this._predicate,
|
|
3392
|
+
this._subject = this._factory.blankNode(),
|
|
3393
|
+
this.QUANTIFIERS_GRAPH
|
|
3394
|
+
);
|
|
3395
|
+
else
|
|
3396
|
+
this._emit(
|
|
3397
|
+
this._subject,
|
|
3398
|
+
this.RDF_REST,
|
|
3399
|
+
this._subject = this._factory.blankNode(),
|
|
3400
|
+
this.QUANTIFIERS_GRAPH
|
|
3401
|
+
);
|
|
3402
|
+
this._emit(this._subject, this.RDF_FIRST, entity, this.QUANTIFIERS_GRAPH);
|
|
3403
|
+
}
|
|
3404
|
+
return this._readQuantifierPunctuation;
|
|
3405
|
+
}
|
|
3406
|
+
// Reads punctuation from a @forSome or @forAll statement
|
|
3407
|
+
_readQuantifierPunctuation(token2) {
|
|
3408
|
+
if (token2.type === ",")
|
|
3409
|
+
return this._readQuantifierList;
|
|
3410
|
+
else {
|
|
3411
|
+
if (this._explicitQuantifiers) {
|
|
3412
|
+
this._emit(this._subject, this.RDF_REST, this.RDF_NIL, this.QUANTIFIERS_GRAPH);
|
|
3413
|
+
this._subject = null;
|
|
3414
|
+
}
|
|
3415
|
+
this._readCallback = this._getContextEndReader();
|
|
3416
|
+
return this._readCallback(token2);
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
// ### `_getPathReader` reads a potential path and then resumes with the given function
|
|
3420
|
+
_getPathReader(afterPath) {
|
|
3421
|
+
this._afterPath = afterPath;
|
|
3422
|
+
return this._readPath;
|
|
3423
|
+
}
|
|
3424
|
+
// ### `_readPath` reads a potential path
|
|
3425
|
+
_readPath(token2) {
|
|
3426
|
+
switch (token2.type) {
|
|
3427
|
+
// Forward path
|
|
3428
|
+
case "!":
|
|
3429
|
+
return this._readForwardPath;
|
|
3430
|
+
// Backward path
|
|
3431
|
+
case "^":
|
|
3432
|
+
return this._readBackwardPath;
|
|
3433
|
+
// Not a path; resume reading where we left off
|
|
3434
|
+
default:
|
|
3435
|
+
const stack = this._contextStack, parent2 = stack.length && stack[stack.length - 1];
|
|
3436
|
+
if (parent2 && parent2.type === "item") {
|
|
3437
|
+
const item = this._subject;
|
|
3438
|
+
this._restoreContext("item", token2);
|
|
3439
|
+
this._emit(this._subject, this.RDF_FIRST, item, this._graph);
|
|
3440
|
+
}
|
|
3441
|
+
return this._afterPath(token2);
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
// ### `_readForwardPath` reads a '!' path
|
|
3445
|
+
_readForwardPath(token2) {
|
|
3446
|
+
let subject, predicate;
|
|
3447
|
+
const object2 = this._factory.blankNode();
|
|
3448
|
+
if ((predicate = this._readEntity(token2)) === void 0)
|
|
3449
|
+
return;
|
|
3450
|
+
if (this._predicate === null)
|
|
3451
|
+
subject = this._subject, this._subject = object2;
|
|
3452
|
+
else
|
|
3453
|
+
subject = this._object, this._object = object2;
|
|
3454
|
+
this._emit(subject, predicate, object2, this._graph);
|
|
3455
|
+
return this._readPath;
|
|
3456
|
+
}
|
|
3457
|
+
// ### `_readBackwardPath` reads a '^' path
|
|
3458
|
+
_readBackwardPath(token2) {
|
|
3459
|
+
const subject = this._factory.blankNode();
|
|
3460
|
+
let predicate, object2;
|
|
3461
|
+
if ((predicate = this._readEntity(token2)) === void 0)
|
|
3462
|
+
return;
|
|
3463
|
+
if (this._predicate === null)
|
|
3464
|
+
object2 = this._subject, this._subject = subject;
|
|
3465
|
+
else
|
|
3466
|
+
object2 = this._object, this._object = subject;
|
|
3467
|
+
this._emit(subject, predicate, object2, this._graph);
|
|
3468
|
+
return this._readPath;
|
|
3469
|
+
}
|
|
3470
|
+
// ### `_readTripleTermTail` reads the end of a triple term
|
|
3471
|
+
_readTripleTermTail(token2) {
|
|
3472
|
+
if (token2.type !== ")>>")
|
|
3473
|
+
return this._error(`Expected )>> but got ${token2.type}`, token2);
|
|
3474
|
+
const quad2 = this._factory.quad(
|
|
3475
|
+
this._subject,
|
|
3476
|
+
this._predicate,
|
|
3477
|
+
this._object,
|
|
3478
|
+
this._graph || this.DEFAULTGRAPH
|
|
3479
|
+
);
|
|
3480
|
+
this._restoreContext("<<(", token2);
|
|
3481
|
+
if (this._subject === null) {
|
|
3482
|
+
this._subject = quad2;
|
|
3483
|
+
return this._readPredicate;
|
|
3484
|
+
} else {
|
|
3485
|
+
this._object = quad2;
|
|
3486
|
+
return this._getContextEndReader();
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
// ### `_readReifiedTripleTailOrReifier` reads a reifier or the end of a nested reified triple
|
|
3490
|
+
_readReifiedTripleTailOrReifier(token2) {
|
|
3491
|
+
if (token2.type === "~") {
|
|
3492
|
+
return this._readReifier;
|
|
3493
|
+
}
|
|
3494
|
+
return this._readReifiedTripleTail(token2);
|
|
3495
|
+
}
|
|
3496
|
+
// ### `_readReifiedTripleTail` reads the end of a nested reified triple
|
|
3497
|
+
_readReifiedTripleTail(token2) {
|
|
3498
|
+
if (token2.type !== ">>")
|
|
3499
|
+
return this._error(`Expected >> but got ${token2.type}`, token2);
|
|
3500
|
+
this._tripleTerm = null;
|
|
3501
|
+
const reifier = this._readTripleTerm();
|
|
3502
|
+
this._restoreContext("<<", token2);
|
|
3503
|
+
const stack = this._contextStack, parent2 = stack.length && stack[stack.length - 1];
|
|
3504
|
+
if (parent2 && parent2.type === "list") {
|
|
3505
|
+
this._emit(this._subject, this.RDF_FIRST, reifier, this._graph);
|
|
3506
|
+
return this._getContextEndReader();
|
|
3507
|
+
} else if (this._subject === null) {
|
|
3508
|
+
this._subject = reifier;
|
|
3509
|
+
return this._readPredicateOrReifierTripleEnd;
|
|
3510
|
+
} else {
|
|
3511
|
+
this._object = reifier;
|
|
3512
|
+
return this._getContextEndReader();
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
_readPredicateOrReifierTripleEnd(token2) {
|
|
3516
|
+
if (token2.type === ".") {
|
|
3517
|
+
this._subject = null;
|
|
3518
|
+
return this._readPunctuation(token2);
|
|
3519
|
+
}
|
|
3520
|
+
return this._readPredicate(token2);
|
|
3521
|
+
}
|
|
3522
|
+
// ### `_readReifier` reads the triple term identifier after a tilde when in a reifying triple.
|
|
3523
|
+
_readReifier(token2) {
|
|
3524
|
+
this._reifier = this._readEntity(token2);
|
|
3525
|
+
return this._readReifiedTripleTail;
|
|
3526
|
+
}
|
|
3527
|
+
// ### `_readReifier` reads the optional triple term identifier after a tilde when in annotation syntax.
|
|
3528
|
+
_readReifierInAnnotation(token2) {
|
|
3529
|
+
if (token2.type === "IRI" || token2.type === "typeIRI" || token2.type === "type" || token2.type === "prefixed" || token2.type === "blank" || token2.type === "var") {
|
|
3530
|
+
this._reifier = this._readEntity(token2);
|
|
3531
|
+
return this._readPunctuation;
|
|
3532
|
+
}
|
|
3533
|
+
this._readTripleTerm();
|
|
3534
|
+
this._subject = null;
|
|
3535
|
+
return this._readPunctuation(token2);
|
|
3536
|
+
}
|
|
3537
|
+
_readTripleTerm() {
|
|
3538
|
+
const stack = this._contextStack, parent2 = stack.length && stack[stack.length - 1];
|
|
3539
|
+
const parentGraph = parent2 ? parent2.graph : void 0;
|
|
3540
|
+
const reifier = this._reifier || this._factory.blankNode();
|
|
3541
|
+
this._reifier = null;
|
|
3542
|
+
this._tripleTerm = this._tripleTerm || this._factory.quad(this._subject, this._predicate, this._object);
|
|
3543
|
+
this._emit(reifier, this.RDF_REIFIES, this._tripleTerm, parentGraph || this.DEFAULTGRAPH);
|
|
3544
|
+
return reifier;
|
|
3545
|
+
}
|
|
3546
|
+
// ### `_getContextEndReader` gets the next reader function at the end of a context
|
|
3547
|
+
_getContextEndReader() {
|
|
3548
|
+
const contextStack = this._contextStack;
|
|
3549
|
+
if (!contextStack.length)
|
|
3550
|
+
return this._readPunctuation;
|
|
3551
|
+
switch (contextStack[contextStack.length - 1].type) {
|
|
3552
|
+
case "blank":
|
|
3553
|
+
return this._readBlankNodeTail;
|
|
3554
|
+
case "list":
|
|
3555
|
+
return this._readListItem;
|
|
3556
|
+
case "formula":
|
|
3557
|
+
return this._readFormulaTail;
|
|
3558
|
+
case "<<(":
|
|
3559
|
+
return this._readTripleTermTail;
|
|
3560
|
+
case "<<":
|
|
3561
|
+
return this._readReifiedTripleTailOrReifier;
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
// ### `_emit` sends a quad through the callback
|
|
3565
|
+
_emit(subject, predicate, object2, graph) {
|
|
3566
|
+
this._callback(null, this._factory.quad(subject, predicate, object2, graph || this.DEFAULTGRAPH));
|
|
3567
|
+
}
|
|
3568
|
+
// ### `_error` emits an error message through the callback
|
|
3569
|
+
_error(message, token2) {
|
|
3570
|
+
const err = new Error(`${message} on line ${token2.line}.`);
|
|
3571
|
+
err.context = {
|
|
3572
|
+
token: token2,
|
|
3573
|
+
line: token2.line,
|
|
3574
|
+
previousToken: this._lexer.previousToken
|
|
3575
|
+
};
|
|
3576
|
+
this._callback(err);
|
|
3577
|
+
this._callback = noop;
|
|
3578
|
+
}
|
|
3579
|
+
// ### `_resolveIRI` resolves an IRI against the base path
|
|
3580
|
+
_resolveIRI(iri) {
|
|
3581
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(iri) ? iri : this._resolveRelativeIRI(iri);
|
|
3582
|
+
}
|
|
3583
|
+
// ### `_resolveRelativeIRI` resolves an IRI against the base path,
|
|
3584
|
+
// assuming that a base path has been set and that the IRI is indeed relative
|
|
3585
|
+
_resolveRelativeIRI(iri) {
|
|
3586
|
+
if (!iri.length)
|
|
3587
|
+
return this._base;
|
|
3588
|
+
switch (iri[0]) {
|
|
3589
|
+
// Resolve relative fragment IRIs against the base IRI
|
|
3590
|
+
case "#":
|
|
3591
|
+
return this._base + iri;
|
|
3592
|
+
// Resolve relative query string IRIs by replacing the query string
|
|
3593
|
+
case "?":
|
|
3594
|
+
return this._base.replace(/(?:\?.*)?$/, iri);
|
|
3595
|
+
// Resolve root-relative IRIs at the root of the base IRI
|
|
3596
|
+
case "/":
|
|
3597
|
+
return (iri[1] === "/" ? this._baseScheme : this._baseRoot) + this._removeDotSegments(iri);
|
|
3598
|
+
// Resolve all other IRIs at the base IRI's path
|
|
3599
|
+
default:
|
|
3600
|
+
return /^[^/:]*:/.test(iri) ? null : this._removeDotSegments(this._basePath + iri);
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
// ### `_removeDotSegments` resolves './' and '../' path segments in an IRI as per RFC3986
|
|
3604
|
+
_removeDotSegments(iri) {
|
|
3605
|
+
if (!/(^|\/)\.\.?($|[/#?])/.test(iri))
|
|
3606
|
+
return iri;
|
|
3607
|
+
const length2 = iri.length;
|
|
3608
|
+
let result = "", i = -1, pathStart = -1, segmentStart = 0, next3 = "/";
|
|
3609
|
+
while (i < length2) {
|
|
3610
|
+
switch (next3) {
|
|
3611
|
+
// The path starts with the first slash after the authority
|
|
3612
|
+
case ":":
|
|
3613
|
+
if (pathStart < 0) {
|
|
3614
|
+
if (iri[++i] === "/" && iri[++i] === "/")
|
|
3615
|
+
while ((pathStart = i + 1) < length2 && iri[pathStart] !== "/")
|
|
3616
|
+
i = pathStart;
|
|
3617
|
+
}
|
|
3618
|
+
break;
|
|
3619
|
+
// Don't modify a query string or fragment
|
|
3620
|
+
case "?":
|
|
3621
|
+
case "#":
|
|
3622
|
+
i = length2;
|
|
3623
|
+
break;
|
|
3624
|
+
// Handle '/.' or '/..' path segments
|
|
3625
|
+
case "/":
|
|
3626
|
+
if (iri[i + 1] === ".") {
|
|
3627
|
+
next3 = iri[++i + 1];
|
|
3628
|
+
switch (next3) {
|
|
3629
|
+
// Remove a '/.' segment
|
|
3630
|
+
case "/":
|
|
3631
|
+
result += iri.substring(segmentStart, i - 1);
|
|
3632
|
+
segmentStart = i + 1;
|
|
3633
|
+
break;
|
|
3634
|
+
// Remove a trailing '/.' segment
|
|
3635
|
+
case void 0:
|
|
3636
|
+
case "?":
|
|
3637
|
+
case "#":
|
|
3638
|
+
return result + iri.substring(segmentStart, i) + iri.substr(i + 1);
|
|
3639
|
+
// Remove a '/..' segment
|
|
3640
|
+
case ".":
|
|
3641
|
+
next3 = iri[++i + 1];
|
|
3642
|
+
if (next3 === void 0 || next3 === "/" || next3 === "?" || next3 === "#") {
|
|
3643
|
+
result += iri.substring(segmentStart, i - 2);
|
|
3644
|
+
if ((segmentStart = result.lastIndexOf("/")) >= pathStart)
|
|
3645
|
+
result = result.substr(0, segmentStart);
|
|
3646
|
+
if (next3 !== "/")
|
|
3647
|
+
return `${result}/${iri.substr(i + 1)}`;
|
|
3648
|
+
segmentStart = i + 1;
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
next3 = iri[++i];
|
|
3654
|
+
}
|
|
3655
|
+
return result + iri.substring(segmentStart);
|
|
3656
|
+
}
|
|
3657
|
+
// ## Public methods
|
|
3658
|
+
// ### `parse` parses the N3 input and emits each parsed quad through the onQuad callback.
|
|
3659
|
+
parse(input, quadCallback, prefixCallback, versionCallback) {
|
|
3660
|
+
let onQuad, onPrefix, onComment, onVersion;
|
|
3661
|
+
if (quadCallback && (quadCallback.onQuad || quadCallback.onPrefix || quadCallback.onComment || quadCallback.onVersion)) {
|
|
3662
|
+
onQuad = quadCallback.onQuad;
|
|
3663
|
+
onPrefix = quadCallback.onPrefix;
|
|
3664
|
+
onComment = quadCallback.onComment;
|
|
3665
|
+
onVersion = quadCallback.onVersion;
|
|
3666
|
+
} else {
|
|
3667
|
+
onQuad = quadCallback;
|
|
3668
|
+
onPrefix = prefixCallback;
|
|
3669
|
+
onVersion = versionCallback;
|
|
3670
|
+
}
|
|
3671
|
+
this._readCallback = this._readBeforeTopContext;
|
|
3672
|
+
this._sparqlStyle = false;
|
|
3673
|
+
this._prefixes = /* @__PURE__ */ Object.create(null);
|
|
3674
|
+
this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2) : `b${blankNodePrefix++}_`;
|
|
3675
|
+
this._prefixCallback = onPrefix || noop;
|
|
3676
|
+
this._versionCallback = onVersion || noop;
|
|
3677
|
+
this._inversePredicate = false;
|
|
3678
|
+
this._quantified = /* @__PURE__ */ Object.create(null);
|
|
3679
|
+
if (!onQuad) {
|
|
3680
|
+
const quads = [];
|
|
3681
|
+
let error;
|
|
3682
|
+
this._callback = (e, t) => {
|
|
3683
|
+
e ? error = e : t && quads.push(t);
|
|
3684
|
+
};
|
|
3685
|
+
this._lexer.tokenize(input).every((token2) => {
|
|
3686
|
+
return this._readCallback = this._readCallback(token2);
|
|
3687
|
+
});
|
|
3688
|
+
if (error) throw error;
|
|
3689
|
+
return quads;
|
|
3690
|
+
}
|
|
3691
|
+
let processNextToken = (error, token2) => {
|
|
3692
|
+
if (error !== null)
|
|
3693
|
+
this._callback(error), this._callback = noop;
|
|
3694
|
+
else if (this._readCallback)
|
|
3695
|
+
this._readCallback = this._readCallback(token2);
|
|
3696
|
+
};
|
|
3697
|
+
if (onComment) {
|
|
3698
|
+
this._lexer.comments = true;
|
|
3699
|
+
processNextToken = (error, token2) => {
|
|
3700
|
+
if (error !== null)
|
|
3701
|
+
this._callback(error), this._callback = noop;
|
|
3702
|
+
else if (this._readCallback) {
|
|
3703
|
+
if (token2.type === "comment")
|
|
3704
|
+
onComment(token2.value);
|
|
3705
|
+
else
|
|
3706
|
+
this._readCallback = this._readCallback(token2);
|
|
3707
|
+
}
|
|
3708
|
+
};
|
|
3709
|
+
}
|
|
3710
|
+
this._callback = onQuad;
|
|
3711
|
+
this._lexer.tokenize(input, processNextToken);
|
|
3712
|
+
}
|
|
3713
|
+
};
|
|
3714
|
+
function noop() {
|
|
3715
|
+
}
|
|
3716
|
+
function initDataFactory(parser, factory) {
|
|
3717
|
+
parser._factory = factory;
|
|
3718
|
+
parser.DEFAULTGRAPH = factory.defaultGraph();
|
|
3719
|
+
parser.RDF_FIRST = factory.namedNode(IRIs_default.rdf.first);
|
|
3720
|
+
parser.RDF_REST = factory.namedNode(IRIs_default.rdf.rest);
|
|
3721
|
+
parser.RDF_NIL = factory.namedNode(IRIs_default.rdf.nil);
|
|
3722
|
+
parser.RDF_REIFIES = factory.namedNode(IRIs_default.rdf.reifies);
|
|
3723
|
+
parser.N3_FORALL = factory.namedNode(IRIs_default.r.forAll);
|
|
3724
|
+
parser.N3_FORSOME = factory.namedNode(IRIs_default.r.forSome);
|
|
3725
|
+
parser.ABBREVIATIONS = {
|
|
3726
|
+
"a": factory.namedNode(IRIs_default.rdf.type),
|
|
3727
|
+
"=": factory.namedNode(IRIs_default.owl.sameAs),
|
|
3728
|
+
">": factory.namedNode(IRIs_default.log.implies),
|
|
3729
|
+
"<": factory.namedNode(IRIs_default.log.isImpliedBy)
|
|
3730
|
+
};
|
|
3731
|
+
parser.QUANTIFIERS_GRAPH = factory.namedNode("urn:n3:quantifiers");
|
|
3732
|
+
}
|
|
3733
|
+
N3Parser.SUPPORTED_VERSIONS = [
|
|
3734
|
+
"1.2",
|
|
3735
|
+
"1.2-basic",
|
|
3736
|
+
"1.1"
|
|
3737
|
+
];
|
|
3738
|
+
initDataFactory(N3Parser.prototype, N3DataFactory_default);
|
|
3739
|
+
|
|
144
3740
|
// src/parsers.ts
|
|
145
3741
|
async function parseBackgroundQueryResponse(response) {
|
|
146
|
-
var _a
|
|
3742
|
+
var _a;
|
|
147
3743
|
if (!response) return [];
|
|
148
3744
|
try {
|
|
149
|
-
let
|
|
150
|
-
if (typeof response.
|
|
151
|
-
|
|
3745
|
+
let rdfText;
|
|
3746
|
+
if (typeof response.text === "function") {
|
|
3747
|
+
rdfText = await response.text();
|
|
152
3748
|
} else if (typeof response.data === "string") {
|
|
153
|
-
|
|
154
|
-
} else if (typeof response === "
|
|
155
|
-
|
|
3749
|
+
rdfText = response.data;
|
|
3750
|
+
} else if (typeof response === "string") {
|
|
3751
|
+
rdfText = response;
|
|
156
3752
|
} else {
|
|
157
3753
|
return [];
|
|
158
3754
|
}
|
|
159
|
-
const
|
|
3755
|
+
const parser = new N3Parser();
|
|
3756
|
+
const quads = parser.parse(rdfText);
|
|
160
3757
|
const triples = [];
|
|
161
|
-
for (const
|
|
162
|
-
|
|
3758
|
+
for (const quad2 of quads) {
|
|
3759
|
+
const subject = quad2.subject.value;
|
|
3760
|
+
const predicate = quad2.predicate.value;
|
|
3761
|
+
let objectType;
|
|
3762
|
+
let objectValue;
|
|
3763
|
+
let datatype;
|
|
3764
|
+
let lang;
|
|
3765
|
+
if (quad2.object.termType === "Literal") {
|
|
3766
|
+
objectType = "literal";
|
|
3767
|
+
objectValue = quad2.object.value;
|
|
3768
|
+
datatype = (_a = quad2.object.datatype) == null ? void 0 : _a.value;
|
|
3769
|
+
lang = quad2.object.language || void 0;
|
|
3770
|
+
} else if (quad2.object.termType === "BlankNode") {
|
|
3771
|
+
objectType = "bnode";
|
|
3772
|
+
objectValue = quad2.object.value;
|
|
3773
|
+
} else {
|
|
3774
|
+
objectType = "uri";
|
|
3775
|
+
objectValue = quad2.object.value;
|
|
3776
|
+
}
|
|
163
3777
|
triples.push({
|
|
164
|
-
subject
|
|
165
|
-
predicate
|
|
3778
|
+
subject,
|
|
3779
|
+
predicate,
|
|
166
3780
|
object: {
|
|
167
|
-
value:
|
|
168
|
-
type:
|
|
169
|
-
datatype
|
|
170
|
-
lang
|
|
3781
|
+
value: objectValue,
|
|
3782
|
+
type: objectType,
|
|
3783
|
+
datatype,
|
|
3784
|
+
lang
|
|
171
3785
|
}
|
|
172
3786
|
});
|
|
173
3787
|
}
|
|
174
3788
|
return triples;
|
|
175
|
-
} catch (
|
|
3789
|
+
} catch (error) {
|
|
3790
|
+
console.error("Failed to parse RDF response:", error);
|
|
176
3791
|
return [];
|
|
177
3792
|
}
|
|
178
3793
|
}
|
|
@@ -686,8 +4301,8 @@ var path$u = {};
|
|
|
686
4301
|
var path$t = path$u;
|
|
687
4302
|
var global$m = global$n;
|
|
688
4303
|
var isCallable$f = isCallable$h;
|
|
689
|
-
var aFunction = function(
|
|
690
|
-
return isCallable$f(
|
|
4304
|
+
var aFunction = function(variable2) {
|
|
4305
|
+
return isCallable$f(variable2) ? variable2 : void 0;
|
|
691
4306
|
};
|
|
692
4307
|
var getBuiltIn$b = function(namespace, method2) {
|
|
693
4308
|
return arguments.length < 2 ? aFunction(path$t[namespace]) || aFunction(global$m[namespace]) : path$t[namespace] && path$t[namespace][method2] || global$m[namespace] && global$m[namespace][method2];
|
|
@@ -2176,17 +5791,17 @@ var isCallable$7 = isCallable$h;
|
|
|
2176
5791
|
var classof$d = classof$e;
|
|
2177
5792
|
var getBuiltIn$9 = getBuiltIn$b;
|
|
2178
5793
|
var inspectSource = inspectSource$1;
|
|
2179
|
-
var
|
|
5794
|
+
var noop2 = function() {
|
|
2180
5795
|
};
|
|
2181
5796
|
var empty = [];
|
|
2182
5797
|
var construct = getBuiltIn$9("Reflect", "construct");
|
|
2183
5798
|
var constructorRegExp = /^\s*(?:class|function)\b/;
|
|
2184
5799
|
var exec$2 = uncurryThis$k(constructorRegExp.exec);
|
|
2185
|
-
var INCORRECT_TO_STRING = !constructorRegExp.test(
|
|
5800
|
+
var INCORRECT_TO_STRING = !constructorRegExp.test(noop2);
|
|
2186
5801
|
var isConstructorModern = function isConstructor(argument) {
|
|
2187
5802
|
if (!isCallable$7(argument)) return false;
|
|
2188
5803
|
try {
|
|
2189
|
-
construct(
|
|
5804
|
+
construct(noop2, empty, argument);
|
|
2190
5805
|
return true;
|
|
2191
5806
|
} catch (error) {
|
|
2192
5807
|
return false;
|
|
@@ -5822,16 +9437,16 @@ function Mash() {
|
|
|
5822
9437
|
};
|
|
5823
9438
|
}
|
|
5824
9439
|
function hammerMock() {
|
|
5825
|
-
const
|
|
9440
|
+
const noop3 = () => {
|
|
5826
9441
|
};
|
|
5827
9442
|
return {
|
|
5828
|
-
on:
|
|
5829
|
-
off:
|
|
5830
|
-
destroy:
|
|
5831
|
-
emit:
|
|
9443
|
+
on: noop3,
|
|
9444
|
+
off: noop3,
|
|
9445
|
+
destroy: noop3,
|
|
9446
|
+
emit: noop3,
|
|
5832
9447
|
get() {
|
|
5833
9448
|
return {
|
|
5834
|
-
set:
|
|
9449
|
+
set: noop3
|
|
5835
9450
|
};
|
|
5836
9451
|
}
|
|
5837
9452
|
};
|
|
@@ -10625,7 +14240,7 @@ var isNan = isNan$1;
|
|
|
10625
14240
|
var _Number$isNaN = /* @__PURE__ */ getDefaultExportFromCjs(isNan);
|
|
10626
14241
|
var global$4 = global$n;
|
|
10627
14242
|
var globalIsFinite = global$4.isFinite;
|
|
10628
|
-
var numberIsFinite$1 = Number.isFinite || function
|
|
14243
|
+
var numberIsFinite$1 = Number.isFinite || function isFinite2(it2) {
|
|
10629
14244
|
return typeof it2 == "number" && globalIsFinite(it2);
|
|
10630
14245
|
};
|
|
10631
14246
|
var $$g = _export;
|
|
@@ -30112,7 +33727,6 @@ var GraphPlugin = class {
|
|
|
30112
33727
|
this.expansionAbortController.abort();
|
|
30113
33728
|
this.expansionAbortController = null;
|
|
30114
33729
|
}
|
|
30115
|
-
this.expandedNodes = /* @__PURE__ */ new Set();
|
|
30116
33730
|
this.uriToNodeId = /* @__PURE__ */ new Map();
|
|
30117
33731
|
this.yasr.resultsEl.innerHTML = "";
|
|
30118
33732
|
try {
|
|
@@ -30610,7 +34224,7 @@ var GraphPlugin = class {
|
|
|
30610
34224
|
};
|
|
30611
34225
|
try {
|
|
30612
34226
|
const response = await this.yasr.executeQuery(`DESCRIBE <${uri}>`, {
|
|
30613
|
-
acceptHeader: "
|
|
34227
|
+
acceptHeader: "text/turtle",
|
|
30614
34228
|
signal: controller.signal
|
|
30615
34229
|
});
|
|
30616
34230
|
if (controller.signal.aborted) {
|
|
@@ -30720,6 +34334,17 @@ if (typeof window !== "undefined" && window.Yasgui && window.Yasgui.Yasr) {
|
|
|
30720
34334
|
var index_default = GraphPlugin_default;
|
|
30721
34335
|
/*! Bundled license information:
|
|
30722
34336
|
|
|
34337
|
+
ieee754/index.js:
|
|
34338
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
34339
|
+
|
|
34340
|
+
buffer/index.js:
|
|
34341
|
+
(*!
|
|
34342
|
+
* The buffer module from node.js, for the browser.
|
|
34343
|
+
*
|
|
34344
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
34345
|
+
* @license MIT
|
|
34346
|
+
*)
|
|
34347
|
+
|
|
30723
34348
|
vis-network/standalone/esm/vis-network.js:
|
|
30724
34349
|
(**
|
|
30725
34350
|
* vis-network
|