@poppinss/utils 7.0.0-next.3 → 7.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -0
- package/build/chunk-BNZ4_A-W.js +23 -0
- package/build/exception-L7vjh-Gv.js +2 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +142 -167
- package/build/main-CdreHl1_.js +694 -0
- package/build/main-aO4h7ygK.js +514 -0
- package/build/modules/assert.js +8 -21
- package/build/modules/base64.js +24 -41
- package/build/modules/exception.js +2 -12
- package/build/modules/fs/main.js +52 -75
- package/build/modules/json/main.js +3 -8
- package/build/modules/string/main.js +1 -4
- package/build/modules/string/string_builder.js +1 -4
- package/build/modules/types.js +1 -1
- package/build/src/compose.d.ts +4 -4
- package/build/src/imports_bag.d.ts +24 -0
- package/package.json +28 -25
- package/build/chunk-SKNTF5Q5.js +0 -14
- package/build/chunk-XFX47BKO.js +0 -23
- package/build/chunk-YFSCSJNE.js +0 -33
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
import { n as __toESM, t as __commonJSMin } from "./chunk-BNZ4_A-W.js";
|
|
2
|
+
var import_secure_json_parse = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3
|
+
const hasBuffer = typeof Buffer !== "undefined";
|
|
4
|
+
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
5
|
+
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
6
|
+
function _parse(text, reviver, options) {
|
|
7
|
+
if (options == null) {
|
|
8
|
+
if (reviver !== null && typeof reviver === "object") {
|
|
9
|
+
options = reviver;
|
|
10
|
+
reviver = void 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (hasBuffer && Buffer.isBuffer(text)) text = text.toString();
|
|
14
|
+
if (text && text.charCodeAt(0) === 65279) text = text.slice(1);
|
|
15
|
+
const obj = JSON.parse(text, reviver);
|
|
16
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
17
|
+
const protoAction = options && options.protoAction || "error";
|
|
18
|
+
const constructorAction = options && options.constructorAction || "error";
|
|
19
|
+
if (protoAction === "ignore" && constructorAction === "ignore") return obj;
|
|
20
|
+
if (protoAction !== "ignore" && constructorAction !== "ignore") {
|
|
21
|
+
if (suspectProtoRx.test(text) === false && suspectConstructorRx.test(text) === false) return obj;
|
|
22
|
+
} else if (protoAction !== "ignore" && constructorAction === "ignore") {
|
|
23
|
+
if (suspectProtoRx.test(text) === false) return obj;
|
|
24
|
+
} else if (suspectConstructorRx.test(text) === false) return obj;
|
|
25
|
+
return filter(obj, {
|
|
26
|
+
protoAction,
|
|
27
|
+
constructorAction,
|
|
28
|
+
safe: options && options.safe
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function filter(obj, { protoAction = "error", constructorAction = "error", safe } = {}) {
|
|
32
|
+
let next = [obj];
|
|
33
|
+
while (next.length) {
|
|
34
|
+
const nodes = next;
|
|
35
|
+
next = [];
|
|
36
|
+
for (const node of nodes) {
|
|
37
|
+
if (protoAction !== "ignore" && Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
38
|
+
if (safe === true) return null;
|
|
39
|
+
else if (protoAction === "error") throw new SyntaxError("Object contains forbidden prototype property");
|
|
40
|
+
delete node.__proto__;
|
|
41
|
+
}
|
|
42
|
+
if (constructorAction !== "ignore" && Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
43
|
+
if (safe === true) return null;
|
|
44
|
+
else if (constructorAction === "error") throw new SyntaxError("Object contains forbidden prototype property");
|
|
45
|
+
delete node.constructor;
|
|
46
|
+
}
|
|
47
|
+
for (const key in node) {
|
|
48
|
+
const value = node[key];
|
|
49
|
+
if (value && typeof value === "object") next.push(value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return obj;
|
|
54
|
+
}
|
|
55
|
+
function parse(text, reviver, options) {
|
|
56
|
+
const { stackTraceLimit } = Error;
|
|
57
|
+
Error.stackTraceLimit = 0;
|
|
58
|
+
try {
|
|
59
|
+
return _parse(text, reviver, options);
|
|
60
|
+
} finally {
|
|
61
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function safeParse(text, reviver) {
|
|
65
|
+
const { stackTraceLimit } = Error;
|
|
66
|
+
Error.stackTraceLimit = 0;
|
|
67
|
+
try {
|
|
68
|
+
return _parse(text, reviver, { safe: true });
|
|
69
|
+
} catch {
|
|
70
|
+
return;
|
|
71
|
+
} finally {
|
|
72
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
module.exports = parse;
|
|
76
|
+
module.exports.default = parse;
|
|
77
|
+
module.exports.parse = parse;
|
|
78
|
+
module.exports.safeParse = safeParse;
|
|
79
|
+
module.exports.scan = filter;
|
|
80
|
+
})))();
|
|
81
|
+
function safeParse(jsonString, reviver) {
|
|
82
|
+
return (0, import_secure_json_parse.parse)(jsonString, reviver, {
|
|
83
|
+
protoAction: "remove",
|
|
84
|
+
constructorAction: "remove"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
var import_safe_stable_stringify = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
88
|
+
const { hasOwnProperty } = Object.prototype;
|
|
89
|
+
const stringify = configure();
|
|
90
|
+
stringify.configure = configure;
|
|
91
|
+
stringify.stringify = stringify;
|
|
92
|
+
stringify.default = stringify;
|
|
93
|
+
exports.stringify = stringify;
|
|
94
|
+
exports.configure = configure;
|
|
95
|
+
module.exports = stringify;
|
|
96
|
+
const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
|
|
97
|
+
function strEscape(str) {
|
|
98
|
+
if (str.length < 5e3 && !strEscapeSequencesRegExp.test(str)) return `"${str}"`;
|
|
99
|
+
return JSON.stringify(str);
|
|
100
|
+
}
|
|
101
|
+
function sort(array, comparator) {
|
|
102
|
+
if (array.length > 200 || comparator) return array.sort(comparator);
|
|
103
|
+
for (let i = 1; i < array.length; i++) {
|
|
104
|
+
const currentValue = array[i];
|
|
105
|
+
let position = i;
|
|
106
|
+
while (position !== 0 && array[position - 1] > currentValue) {
|
|
107
|
+
array[position] = array[position - 1];
|
|
108
|
+
position--;
|
|
109
|
+
}
|
|
110
|
+
array[position] = currentValue;
|
|
111
|
+
}
|
|
112
|
+
return array;
|
|
113
|
+
}
|
|
114
|
+
const typedArrayPrototypeGetSymbolToStringTag = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array())), Symbol.toStringTag).get;
|
|
115
|
+
function isTypedArrayWithEntries(value) {
|
|
116
|
+
return typedArrayPrototypeGetSymbolToStringTag.call(value) !== void 0 && value.length !== 0;
|
|
117
|
+
}
|
|
118
|
+
function stringifyTypedArray(array, separator, maximumBreadth) {
|
|
119
|
+
if (array.length < maximumBreadth) maximumBreadth = array.length;
|
|
120
|
+
const whitespace = separator === "," ? "" : " ";
|
|
121
|
+
let res = `"0":${whitespace}${array[0]}`;
|
|
122
|
+
for (let i = 1; i < maximumBreadth; i++) res += `${separator}"${i}":${whitespace}${array[i]}`;
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
function getCircularValueOption(options) {
|
|
126
|
+
if (hasOwnProperty.call(options, "circularValue")) {
|
|
127
|
+
const circularValue = options.circularValue;
|
|
128
|
+
if (typeof circularValue === "string") return `"${circularValue}"`;
|
|
129
|
+
if (circularValue == null) return circularValue;
|
|
130
|
+
if (circularValue === Error || circularValue === TypeError) return { toString() {
|
|
131
|
+
throw new TypeError("Converting circular structure to JSON");
|
|
132
|
+
} };
|
|
133
|
+
throw new TypeError("The \"circularValue\" argument must be of type string or the value null or undefined");
|
|
134
|
+
}
|
|
135
|
+
return "\"[Circular]\"";
|
|
136
|
+
}
|
|
137
|
+
function getDeterministicOption(options) {
|
|
138
|
+
let value;
|
|
139
|
+
if (hasOwnProperty.call(options, "deterministic")) {
|
|
140
|
+
value = options.deterministic;
|
|
141
|
+
if (typeof value !== "boolean" && typeof value !== "function") throw new TypeError("The \"deterministic\" argument must be of type boolean or comparator function");
|
|
142
|
+
}
|
|
143
|
+
return value === void 0 ? true : value;
|
|
144
|
+
}
|
|
145
|
+
function getBooleanOption(options, key) {
|
|
146
|
+
let value;
|
|
147
|
+
if (hasOwnProperty.call(options, key)) {
|
|
148
|
+
value = options[key];
|
|
149
|
+
if (typeof value !== "boolean") throw new TypeError(`The "${key}" argument must be of type boolean`);
|
|
150
|
+
}
|
|
151
|
+
return value === void 0 ? true : value;
|
|
152
|
+
}
|
|
153
|
+
function getPositiveIntegerOption(options, key) {
|
|
154
|
+
let value;
|
|
155
|
+
if (hasOwnProperty.call(options, key)) {
|
|
156
|
+
value = options[key];
|
|
157
|
+
if (typeof value !== "number") throw new TypeError(`The "${key}" argument must be of type number`);
|
|
158
|
+
if (!Number.isInteger(value)) throw new TypeError(`The "${key}" argument must be an integer`);
|
|
159
|
+
if (value < 1) throw new RangeError(`The "${key}" argument must be >= 1`);
|
|
160
|
+
}
|
|
161
|
+
return value === void 0 ? Infinity : value;
|
|
162
|
+
}
|
|
163
|
+
function getItemCount(number) {
|
|
164
|
+
if (number === 1) return "1 item";
|
|
165
|
+
return `${number} items`;
|
|
166
|
+
}
|
|
167
|
+
function getUniqueReplacerSet(replacerArray) {
|
|
168
|
+
const replacerSet = /* @__PURE__ */ new Set();
|
|
169
|
+
for (const value of replacerArray) if (typeof value === "string" || typeof value === "number") replacerSet.add(String(value));
|
|
170
|
+
return replacerSet;
|
|
171
|
+
}
|
|
172
|
+
function getStrictOption(options) {
|
|
173
|
+
if (hasOwnProperty.call(options, "strict")) {
|
|
174
|
+
const value = options.strict;
|
|
175
|
+
if (typeof value !== "boolean") throw new TypeError("The \"strict\" argument must be of type boolean");
|
|
176
|
+
if (value) return (value$1) => {
|
|
177
|
+
let message = `Object can not safely be stringified. Received type ${typeof value$1}`;
|
|
178
|
+
if (typeof value$1 !== "function") message += ` (${value$1.toString()})`;
|
|
179
|
+
throw new Error(message);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function configure(options) {
|
|
184
|
+
options = { ...options };
|
|
185
|
+
const fail = getStrictOption(options);
|
|
186
|
+
if (fail) {
|
|
187
|
+
if (options.bigint === void 0) options.bigint = false;
|
|
188
|
+
if (!("circularValue" in options)) options.circularValue = Error;
|
|
189
|
+
}
|
|
190
|
+
const circularValue = getCircularValueOption(options);
|
|
191
|
+
const bigint = getBooleanOption(options, "bigint");
|
|
192
|
+
const deterministic = getDeterministicOption(options);
|
|
193
|
+
const comparator = typeof deterministic === "function" ? deterministic : void 0;
|
|
194
|
+
const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
|
|
195
|
+
const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
|
|
196
|
+
function stringifyFnReplacer(key, parent, stack, replacer, spacer, indentation) {
|
|
197
|
+
let value = parent[key];
|
|
198
|
+
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") value = value.toJSON(key);
|
|
199
|
+
value = replacer.call(parent, key, value);
|
|
200
|
+
switch (typeof value) {
|
|
201
|
+
case "string": return strEscape(value);
|
|
202
|
+
case "object": {
|
|
203
|
+
if (value === null) return "null";
|
|
204
|
+
if (stack.indexOf(value) !== -1) return circularValue;
|
|
205
|
+
let res = "";
|
|
206
|
+
let join = ",";
|
|
207
|
+
const originalIndentation = indentation;
|
|
208
|
+
if (Array.isArray(value)) {
|
|
209
|
+
if (value.length === 0) return "[]";
|
|
210
|
+
if (maximumDepth < stack.length + 1) return "\"[Array]\"";
|
|
211
|
+
stack.push(value);
|
|
212
|
+
if (spacer !== "") {
|
|
213
|
+
indentation += spacer;
|
|
214
|
+
res += `\n${indentation}`;
|
|
215
|
+
join = `,\n${indentation}`;
|
|
216
|
+
}
|
|
217
|
+
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
218
|
+
let i = 0;
|
|
219
|
+
for (; i < maximumValuesToStringify - 1; i++) {
|
|
220
|
+
const tmp$1 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
221
|
+
res += tmp$1 !== void 0 ? tmp$1 : "null";
|
|
222
|
+
res += join;
|
|
223
|
+
}
|
|
224
|
+
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
225
|
+
res += tmp !== void 0 ? tmp : "null";
|
|
226
|
+
if (value.length - 1 > maximumBreadth) {
|
|
227
|
+
const removedKeys = value.length - maximumBreadth - 1;
|
|
228
|
+
res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
229
|
+
}
|
|
230
|
+
if (spacer !== "") res += `\n${originalIndentation}`;
|
|
231
|
+
stack.pop();
|
|
232
|
+
return `[${res}]`;
|
|
233
|
+
}
|
|
234
|
+
let keys = Object.keys(value);
|
|
235
|
+
const keyLength = keys.length;
|
|
236
|
+
if (keyLength === 0) return "{}";
|
|
237
|
+
if (maximumDepth < stack.length + 1) return "\"[Object]\"";
|
|
238
|
+
let whitespace = "";
|
|
239
|
+
let separator = "";
|
|
240
|
+
if (spacer !== "") {
|
|
241
|
+
indentation += spacer;
|
|
242
|
+
join = `,\n${indentation}`;
|
|
243
|
+
whitespace = " ";
|
|
244
|
+
}
|
|
245
|
+
const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
246
|
+
if (deterministic && !isTypedArrayWithEntries(value)) keys = sort(keys, comparator);
|
|
247
|
+
stack.push(value);
|
|
248
|
+
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
249
|
+
const key$1 = keys[i];
|
|
250
|
+
const tmp = stringifyFnReplacer(key$1, value, stack, replacer, spacer, indentation);
|
|
251
|
+
if (tmp !== void 0) {
|
|
252
|
+
res += `${separator}${strEscape(key$1)}:${whitespace}${tmp}`;
|
|
253
|
+
separator = join;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (keyLength > maximumBreadth) {
|
|
257
|
+
const removedKeys = keyLength - maximumBreadth;
|
|
258
|
+
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
259
|
+
separator = join;
|
|
260
|
+
}
|
|
261
|
+
if (spacer !== "" && separator.length > 1) res = `\n${indentation}${res}\n${originalIndentation}`;
|
|
262
|
+
stack.pop();
|
|
263
|
+
return `{${res}}`;
|
|
264
|
+
}
|
|
265
|
+
case "number": return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
266
|
+
case "boolean": return value === true ? "true" : "false";
|
|
267
|
+
case "undefined": return;
|
|
268
|
+
case "bigint": if (bigint) return String(value);
|
|
269
|
+
default: return fail ? fail(value) : void 0;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function stringifyArrayReplacer(key, value, stack, replacer, spacer, indentation) {
|
|
273
|
+
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") value = value.toJSON(key);
|
|
274
|
+
switch (typeof value) {
|
|
275
|
+
case "string": return strEscape(value);
|
|
276
|
+
case "object": {
|
|
277
|
+
if (value === null) return "null";
|
|
278
|
+
if (stack.indexOf(value) !== -1) return circularValue;
|
|
279
|
+
const originalIndentation = indentation;
|
|
280
|
+
let res = "";
|
|
281
|
+
let join = ",";
|
|
282
|
+
if (Array.isArray(value)) {
|
|
283
|
+
if (value.length === 0) return "[]";
|
|
284
|
+
if (maximumDepth < stack.length + 1) return "\"[Array]\"";
|
|
285
|
+
stack.push(value);
|
|
286
|
+
if (spacer !== "") {
|
|
287
|
+
indentation += spacer;
|
|
288
|
+
res += `\n${indentation}`;
|
|
289
|
+
join = `,\n${indentation}`;
|
|
290
|
+
}
|
|
291
|
+
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
292
|
+
let i = 0;
|
|
293
|
+
for (; i < maximumValuesToStringify - 1; i++) {
|
|
294
|
+
const tmp$1 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
295
|
+
res += tmp$1 !== void 0 ? tmp$1 : "null";
|
|
296
|
+
res += join;
|
|
297
|
+
}
|
|
298
|
+
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
299
|
+
res += tmp !== void 0 ? tmp : "null";
|
|
300
|
+
if (value.length - 1 > maximumBreadth) {
|
|
301
|
+
const removedKeys = value.length - maximumBreadth - 1;
|
|
302
|
+
res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
303
|
+
}
|
|
304
|
+
if (spacer !== "") res += `\n${originalIndentation}`;
|
|
305
|
+
stack.pop();
|
|
306
|
+
return `[${res}]`;
|
|
307
|
+
}
|
|
308
|
+
stack.push(value);
|
|
309
|
+
let whitespace = "";
|
|
310
|
+
if (spacer !== "") {
|
|
311
|
+
indentation += spacer;
|
|
312
|
+
join = `,\n${indentation}`;
|
|
313
|
+
whitespace = " ";
|
|
314
|
+
}
|
|
315
|
+
let separator = "";
|
|
316
|
+
for (const key$1 of replacer) {
|
|
317
|
+
const tmp = stringifyArrayReplacer(key$1, value[key$1], stack, replacer, spacer, indentation);
|
|
318
|
+
if (tmp !== void 0) {
|
|
319
|
+
res += `${separator}${strEscape(key$1)}:${whitespace}${tmp}`;
|
|
320
|
+
separator = join;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (spacer !== "" && separator.length > 1) res = `\n${indentation}${res}\n${originalIndentation}`;
|
|
324
|
+
stack.pop();
|
|
325
|
+
return `{${res}}`;
|
|
326
|
+
}
|
|
327
|
+
case "number": return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
328
|
+
case "boolean": return value === true ? "true" : "false";
|
|
329
|
+
case "undefined": return;
|
|
330
|
+
case "bigint": if (bigint) return String(value);
|
|
331
|
+
default: return fail ? fail(value) : void 0;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function stringifyIndent(key, value, stack, spacer, indentation) {
|
|
335
|
+
switch (typeof value) {
|
|
336
|
+
case "string": return strEscape(value);
|
|
337
|
+
case "object": {
|
|
338
|
+
if (value === null) return "null";
|
|
339
|
+
if (typeof value.toJSON === "function") {
|
|
340
|
+
value = value.toJSON(key);
|
|
341
|
+
if (typeof value !== "object") return stringifyIndent(key, value, stack, spacer, indentation);
|
|
342
|
+
if (value === null) return "null";
|
|
343
|
+
}
|
|
344
|
+
if (stack.indexOf(value) !== -1) return circularValue;
|
|
345
|
+
const originalIndentation = indentation;
|
|
346
|
+
if (Array.isArray(value)) {
|
|
347
|
+
if (value.length === 0) return "[]";
|
|
348
|
+
if (maximumDepth < stack.length + 1) return "\"[Array]\"";
|
|
349
|
+
stack.push(value);
|
|
350
|
+
indentation += spacer;
|
|
351
|
+
let res$1 = `\n${indentation}`;
|
|
352
|
+
const join$1 = `,\n${indentation}`;
|
|
353
|
+
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
354
|
+
let i = 0;
|
|
355
|
+
for (; i < maximumValuesToStringify - 1; i++) {
|
|
356
|
+
const tmp$1 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
357
|
+
res$1 += tmp$1 !== void 0 ? tmp$1 : "null";
|
|
358
|
+
res$1 += join$1;
|
|
359
|
+
}
|
|
360
|
+
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
361
|
+
res$1 += tmp !== void 0 ? tmp : "null";
|
|
362
|
+
if (value.length - 1 > maximumBreadth) {
|
|
363
|
+
const removedKeys = value.length - maximumBreadth - 1;
|
|
364
|
+
res$1 += `${join$1}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
365
|
+
}
|
|
366
|
+
res$1 += `\n${originalIndentation}`;
|
|
367
|
+
stack.pop();
|
|
368
|
+
return `[${res$1}]`;
|
|
369
|
+
}
|
|
370
|
+
let keys = Object.keys(value);
|
|
371
|
+
const keyLength = keys.length;
|
|
372
|
+
if (keyLength === 0) return "{}";
|
|
373
|
+
if (maximumDepth < stack.length + 1) return "\"[Object]\"";
|
|
374
|
+
indentation += spacer;
|
|
375
|
+
const join = `,\n${indentation}`;
|
|
376
|
+
let res = "";
|
|
377
|
+
let separator = "";
|
|
378
|
+
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
379
|
+
if (isTypedArrayWithEntries(value)) {
|
|
380
|
+
res += stringifyTypedArray(value, join, maximumBreadth);
|
|
381
|
+
keys = keys.slice(value.length);
|
|
382
|
+
maximumPropertiesToStringify -= value.length;
|
|
383
|
+
separator = join;
|
|
384
|
+
}
|
|
385
|
+
if (deterministic) keys = sort(keys, comparator);
|
|
386
|
+
stack.push(value);
|
|
387
|
+
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
388
|
+
const key$1 = keys[i];
|
|
389
|
+
const tmp = stringifyIndent(key$1, value[key$1], stack, spacer, indentation);
|
|
390
|
+
if (tmp !== void 0) {
|
|
391
|
+
res += `${separator}${strEscape(key$1)}: ${tmp}`;
|
|
392
|
+
separator = join;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (keyLength > maximumBreadth) {
|
|
396
|
+
const removedKeys = keyLength - maximumBreadth;
|
|
397
|
+
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
398
|
+
separator = join;
|
|
399
|
+
}
|
|
400
|
+
if (separator !== "") res = `\n${indentation}${res}\n${originalIndentation}`;
|
|
401
|
+
stack.pop();
|
|
402
|
+
return `{${res}}`;
|
|
403
|
+
}
|
|
404
|
+
case "number": return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
405
|
+
case "boolean": return value === true ? "true" : "false";
|
|
406
|
+
case "undefined": return;
|
|
407
|
+
case "bigint": if (bigint) return String(value);
|
|
408
|
+
default: return fail ? fail(value) : void 0;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function stringifySimple(key, value, stack) {
|
|
412
|
+
switch (typeof value) {
|
|
413
|
+
case "string": return strEscape(value);
|
|
414
|
+
case "object": {
|
|
415
|
+
if (value === null) return "null";
|
|
416
|
+
if (typeof value.toJSON === "function") {
|
|
417
|
+
value = value.toJSON(key);
|
|
418
|
+
if (typeof value !== "object") return stringifySimple(key, value, stack);
|
|
419
|
+
if (value === null) return "null";
|
|
420
|
+
}
|
|
421
|
+
if (stack.indexOf(value) !== -1) return circularValue;
|
|
422
|
+
let res = "";
|
|
423
|
+
const hasLength = value.length !== void 0;
|
|
424
|
+
if (hasLength && Array.isArray(value)) {
|
|
425
|
+
if (value.length === 0) return "[]";
|
|
426
|
+
if (maximumDepth < stack.length + 1) return "\"[Array]\"";
|
|
427
|
+
stack.push(value);
|
|
428
|
+
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
429
|
+
let i = 0;
|
|
430
|
+
for (; i < maximumValuesToStringify - 1; i++) {
|
|
431
|
+
const tmp$1 = stringifySimple(String(i), value[i], stack);
|
|
432
|
+
res += tmp$1 !== void 0 ? tmp$1 : "null";
|
|
433
|
+
res += ",";
|
|
434
|
+
}
|
|
435
|
+
const tmp = stringifySimple(String(i), value[i], stack);
|
|
436
|
+
res += tmp !== void 0 ? tmp : "null";
|
|
437
|
+
if (value.length - 1 > maximumBreadth) {
|
|
438
|
+
const removedKeys = value.length - maximumBreadth - 1;
|
|
439
|
+
res += `,"... ${getItemCount(removedKeys)} not stringified"`;
|
|
440
|
+
}
|
|
441
|
+
stack.pop();
|
|
442
|
+
return `[${res}]`;
|
|
443
|
+
}
|
|
444
|
+
let keys = Object.keys(value);
|
|
445
|
+
const keyLength = keys.length;
|
|
446
|
+
if (keyLength === 0) return "{}";
|
|
447
|
+
if (maximumDepth < stack.length + 1) return "\"[Object]\"";
|
|
448
|
+
let separator = "";
|
|
449
|
+
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
450
|
+
if (hasLength && isTypedArrayWithEntries(value)) {
|
|
451
|
+
res += stringifyTypedArray(value, ",", maximumBreadth);
|
|
452
|
+
keys = keys.slice(value.length);
|
|
453
|
+
maximumPropertiesToStringify -= value.length;
|
|
454
|
+
separator = ",";
|
|
455
|
+
}
|
|
456
|
+
if (deterministic) keys = sort(keys, comparator);
|
|
457
|
+
stack.push(value);
|
|
458
|
+
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
459
|
+
const key$1 = keys[i];
|
|
460
|
+
const tmp = stringifySimple(key$1, value[key$1], stack);
|
|
461
|
+
if (tmp !== void 0) {
|
|
462
|
+
res += `${separator}${strEscape(key$1)}:${tmp}`;
|
|
463
|
+
separator = ",";
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (keyLength > maximumBreadth) {
|
|
467
|
+
const removedKeys = keyLength - maximumBreadth;
|
|
468
|
+
res += `${separator}"...":"${getItemCount(removedKeys)} not stringified"`;
|
|
469
|
+
}
|
|
470
|
+
stack.pop();
|
|
471
|
+
return `{${res}}`;
|
|
472
|
+
}
|
|
473
|
+
case "number": return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
474
|
+
case "boolean": return value === true ? "true" : "false";
|
|
475
|
+
case "undefined": return;
|
|
476
|
+
case "bigint": if (bigint) return String(value);
|
|
477
|
+
default: return fail ? fail(value) : void 0;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function stringify$2(value, replacer, space) {
|
|
481
|
+
if (arguments.length > 1) {
|
|
482
|
+
let spacer = "";
|
|
483
|
+
if (typeof space === "number") spacer = " ".repeat(Math.min(space, 10));
|
|
484
|
+
else if (typeof space === "string") spacer = space.slice(0, 10);
|
|
485
|
+
if (replacer != null) {
|
|
486
|
+
if (typeof replacer === "function") return stringifyFnReplacer("", { "": value }, [], replacer, spacer, "");
|
|
487
|
+
if (Array.isArray(replacer)) return stringifyArrayReplacer("", value, [], getUniqueReplacerSet(replacer), spacer, "");
|
|
488
|
+
}
|
|
489
|
+
if (spacer.length !== 0) return stringifyIndent("", value, [], spacer, "");
|
|
490
|
+
}
|
|
491
|
+
return stringifySimple("", value, []);
|
|
492
|
+
}
|
|
493
|
+
return stringify$2;
|
|
494
|
+
}
|
|
495
|
+
})))(), 1);
|
|
496
|
+
const configure = import_safe_stable_stringify.configure;
|
|
497
|
+
import_safe_stable_stringify.default;
|
|
498
|
+
import_safe_stable_stringify.default;
|
|
499
|
+
const stringify = configure({
|
|
500
|
+
bigint: false,
|
|
501
|
+
circularValue: void 0,
|
|
502
|
+
deterministic: false
|
|
503
|
+
});
|
|
504
|
+
function jsonStringifyReplacer(replacer) {
|
|
505
|
+
return function(key, value) {
|
|
506
|
+
const val = replacer ? replacer.call(this, key, value) : value;
|
|
507
|
+
if (typeof val === "bigint") return val.toString();
|
|
508
|
+
return val;
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function safeStringify(value, replacer, space) {
|
|
512
|
+
return stringify(value, jsonStringifyReplacer(replacer), space);
|
|
513
|
+
}
|
|
514
|
+
export { safeParse as n, safeStringify as t };
|
package/build/modules/assert.js
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { AssertionError } from "assert";
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
import { AssertionError } from "node:assert";
|
|
4
3
|
function assert(value, message) {
|
|
5
|
-
|
|
4
|
+
return assertExists(value, message);
|
|
6
5
|
}
|
|
7
6
|
function assertExists(value, message) {
|
|
8
|
-
|
|
9
|
-
throw new AssertionError({ message: message ?? "value is falsy" });
|
|
10
|
-
}
|
|
7
|
+
if (!value) throw new AssertionError({ message: message ?? "value is falsy" });
|
|
11
8
|
}
|
|
12
9
|
function assertUnreachable(x) {
|
|
13
|
-
|
|
10
|
+
throw new AssertionError({ message: `unreachable code executed: ${inspect(x)}` });
|
|
14
11
|
}
|
|
15
12
|
function assertNotNull(value, message) {
|
|
16
|
-
|
|
17
|
-
throw new AssertionError({ message: message ?? "unexpected null value" });
|
|
18
|
-
}
|
|
13
|
+
if (value === null) throw new AssertionError({ message: message ?? "unexpected null value" });
|
|
19
14
|
}
|
|
20
15
|
function assertIsDefined(value, message) {
|
|
21
|
-
|
|
22
|
-
throw new AssertionError({ message: message ?? "unexpected undefined value" });
|
|
23
|
-
}
|
|
16
|
+
if (value === void 0) throw new AssertionError({ message: message ?? "unexpected undefined value" });
|
|
24
17
|
}
|
|
25
|
-
export {
|
|
26
|
-
assert,
|
|
27
|
-
assertExists,
|
|
28
|
-
assertIsDefined,
|
|
29
|
-
assertNotNull,
|
|
30
|
-
assertUnreachable
|
|
31
|
-
};
|
|
18
|
+
export { assert, assertExists, assertIsDefined, assertNotNull, assertUnreachable };
|
package/build/modules/base64.js
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
|
-
// modules/base64.ts
|
|
2
1
|
var Base64 = class {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
|
|
26
|
-
}
|
|
27
|
-
urlDecode(encoded, encoding = "utf-8", strict = false) {
|
|
28
|
-
if (Buffer.isBuffer(encoded)) {
|
|
29
|
-
return encoded.toString(encoding);
|
|
30
|
-
}
|
|
31
|
-
const decoded = Buffer.from(encoded, "base64").toString(encoding);
|
|
32
|
-
const isInvalid = this.urlEncode(decoded, encoding) !== encoded;
|
|
33
|
-
if (strict && isInvalid) {
|
|
34
|
-
throw new Error("Cannot urlDecode malformed value");
|
|
35
|
-
}
|
|
36
|
-
return isInvalid ? null : decoded;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var base64 = new Base64();
|
|
40
|
-
var base64_default = base64;
|
|
41
|
-
export {
|
|
42
|
-
base64_default as default
|
|
2
|
+
encode(data, encoding) {
|
|
3
|
+
if (typeof data === "string") return Buffer.from(data, encoding).toString("base64");
|
|
4
|
+
if (Buffer.isBuffer(data)) return data.toString("base64");
|
|
5
|
+
return Buffer.from(data).toString("base64");
|
|
6
|
+
}
|
|
7
|
+
decode(encoded, encoding = "utf-8", strict = false) {
|
|
8
|
+
if (Buffer.isBuffer(encoded)) return encoded.toString(encoding);
|
|
9
|
+
const decoded = Buffer.from(encoded, "base64").toString(encoding);
|
|
10
|
+
const isInvalid = this.encode(decoded, encoding) !== encoded;
|
|
11
|
+
if (strict && isInvalid) throw new Error("Cannot decode malformed value");
|
|
12
|
+
return isInvalid ? null : decoded;
|
|
13
|
+
}
|
|
14
|
+
urlEncode(data, encoding) {
|
|
15
|
+
return (typeof data === "string" ? this.encode(data, encoding) : this.encode(data)).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
|
|
16
|
+
}
|
|
17
|
+
urlDecode(encoded, encoding = "utf-8", strict = false) {
|
|
18
|
+
if (Buffer.isBuffer(encoded)) return encoded.toString(encoding);
|
|
19
|
+
const decoded = Buffer.from(encoded, "base64").toString(encoding);
|
|
20
|
+
const isInvalid = this.urlEncode(decoded, encoding) !== encoded;
|
|
21
|
+
if (strict && isInvalid) throw new Error("Cannot urlDecode malformed value");
|
|
22
|
+
return isInvalid ? null : decoded;
|
|
23
|
+
}
|
|
43
24
|
};
|
|
25
|
+
var base64_default = new Base64();
|
|
26
|
+
export { base64_default as default };
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
InvalidArgumentsException,
|
|
4
|
-
RuntimeException,
|
|
5
|
-
createError
|
|
6
|
-
} from "../chunk-SKNTF5Q5.js";
|
|
7
|
-
export {
|
|
8
|
-
Exception,
|
|
9
|
-
InvalidArgumentsException,
|
|
10
|
-
RuntimeException,
|
|
11
|
-
createError
|
|
12
|
-
};
|
|
1
|
+
import { i as createError, n as InvalidArgumentsException, r as RuntimeException, t as Exception } from "../exception-L7vjh-Gv.js";
|
|
2
|
+
export { Exception, InvalidArgumentsException, RuntimeException, createError };
|