yansu 0.0.0-beta.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.
Files changed (142) hide show
  1. package/README.md +1 -0
  2. package/bin.mjs +18 -0
  3. package/dist/cli.d.mts +2 -0
  4. package/dist/cli.mjs +68 -0
  5. package/dist/dirs.d.mts +4 -0
  6. package/dist/dirs.mjs +6 -0
  7. package/dist/index.d.mts +78 -0
  8. package/dist/index.mjs +121 -0
  9. package/dist/nitro.json +15 -0
  10. package/dist/public/_nuxt/BHIHUtPz.js +4 -0
  11. package/dist/public/_nuxt/CCgOhniq.js +1 -0
  12. package/dist/public/_nuxt/CR6vfq1R.js +1 -0
  13. package/dist/public/_nuxt/DmxzK6E8.js +1 -0
  14. package/dist/public/_nuxt/builds/latest.json +1 -0
  15. package/dist/public/_nuxt/builds/meta/e9079134-f314-434b-b3a7-092c4a1e187d.json +1 -0
  16. package/dist/public/_nuxt/entry.DJ3VOi_0.css +1 -0
  17. package/dist/public/_nuxt/error-404.lC6KBLNm.css +1 -0
  18. package/dist/public/_nuxt/error-500.NtBcR2wE.css +1 -0
  19. package/dist/server/chunks/_/error-500.mjs +9 -0
  20. package/dist/server/chunks/build/_plugin-vue_export-helper-DjsbPc54.mjs +29 -0
  21. package/dist/server/chunks/build/client.precomputed.mjs +3 -0
  22. package/dist/server/chunks/build/error-404-Du0ot2hm.mjs +369 -0
  23. package/dist/server/chunks/build/error-500-Y3RUV6n2.mjs +73 -0
  24. package/dist/server/chunks/build/server.mjs +727 -0
  25. package/dist/server/chunks/nitro/nitro.mjs +5176 -0
  26. package/dist/server/chunks/routes/api/metadata.json.mjs +147 -0
  27. package/dist/server/chunks/routes/api/platform.json.mjs +20 -0
  28. package/dist/server/chunks/routes/renderer.mjs +408 -0
  29. package/dist/server/chunks/virtual/_virtual_spa-template.mjs +3 -0
  30. package/dist/server/index.mjs +9 -0
  31. package/dist/server/node_modules/.nitro/@vue/shared@3.5.25/dist/shared.cjs.prod.js +604 -0
  32. package/dist/server/node_modules/.nitro/@vue/shared@3.5.25/package.json +47 -0
  33. package/dist/server/node_modules/.nitro/@vue/shared@3.5.26/dist/shared.cjs.prod.js +604 -0
  34. package/dist/server/node_modules/.nitro/@vue/shared@3.5.26/package.json +47 -0
  35. package/dist/server/node_modules/@babel/parser/lib/index.js +14662 -0
  36. package/dist/server/node_modules/@babel/parser/package.json +50 -0
  37. package/dist/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6763 -0
  38. package/dist/server/node_modules/@vue/compiler-core/package.json +58 -0
  39. package/dist/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
  40. package/dist/server/node_modules/@vue/compiler-dom/package.json +57 -0
  41. package/dist/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
  42. package/dist/server/node_modules/@vue/compiler-ssr/package.json +34 -0
  43. package/dist/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1853 -0
  44. package/dist/server/node_modules/@vue/reactivity/package.json +55 -0
  45. package/dist/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6770 -0
  46. package/dist/server/node_modules/@vue/runtime-core/package.json +52 -0
  47. package/dist/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1732 -0
  48. package/dist/server/node_modules/@vue/runtime-dom/package.json +60 -0
  49. package/dist/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +879 -0
  50. package/dist/server/node_modules/@vue/server-renderer/package.json +55 -0
  51. package/dist/server/node_modules/ansis/index.cjs +1 -0
  52. package/dist/server/node_modules/ansis/index.mjs +1 -0
  53. package/dist/server/node_modules/ansis/package.json +25 -0
  54. package/dist/server/node_modules/birpc/dist/index.mjs +173 -0
  55. package/dist/server/node_modules/birpc/package.json +56 -0
  56. package/dist/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
  57. package/dist/server/node_modules/consola/dist/core.mjs +512 -0
  58. package/dist/server/node_modules/consola/dist/index.mjs +651 -0
  59. package/dist/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
  60. package/dist/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
  61. package/dist/server/node_modules/consola/package.json +136 -0
  62. package/dist/server/node_modules/devalue/index.js +4 -0
  63. package/dist/server/node_modules/devalue/package.json +37 -0
  64. package/dist/server/node_modules/devalue/src/base64.js +110 -0
  65. package/dist/server/node_modules/devalue/src/constants.js +6 -0
  66. package/dist/server/node_modules/devalue/src/parse.js +205 -0
  67. package/dist/server/node_modules/devalue/src/stringify.js +265 -0
  68. package/dist/server/node_modules/devalue/src/uneval.js +407 -0
  69. package/dist/server/node_modules/devalue/src/utils.js +118 -0
  70. package/dist/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
  71. package/dist/server/node_modules/entities/dist/commonjs/decode.js +568 -0
  72. package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
  73. package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
  74. package/dist/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
  75. package/dist/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
  76. package/dist/server/node_modules/entities/dist/commonjs/package.json +3 -0
  77. package/dist/server/node_modules/entities/package.json +113 -0
  78. package/dist/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
  79. package/dist/server/node_modules/estree-walker/package.json +37 -0
  80. package/dist/server/node_modules/get-port-please/dist/index.mjs +430 -0
  81. package/dist/server/node_modules/get-port-please/package.json +39 -0
  82. package/dist/server/node_modules/hookable/dist/index.mjs +290 -0
  83. package/dist/server/node_modules/hookable/package.json +49 -0
  84. package/dist/server/node_modules/source-map-js/lib/array-set.js +121 -0
  85. package/dist/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  86. package/dist/server/node_modules/source-map-js/lib/base64.js +67 -0
  87. package/dist/server/node_modules/source-map-js/lib/binary-search.js +111 -0
  88. package/dist/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
  89. package/dist/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
  90. package/dist/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  91. package/dist/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  92. package/dist/server/node_modules/source-map-js/lib/source-node.js +413 -0
  93. package/dist/server/node_modules/source-map-js/lib/util.js +594 -0
  94. package/dist/server/node_modules/source-map-js/package.json +71 -0
  95. package/dist/server/node_modules/source-map-js/source-map.js +8 -0
  96. package/dist/server/node_modules/structured-clone-es/dist/index.mjs +285 -0
  97. package/dist/server/node_modules/structured-clone-es/package.json +56 -0
  98. package/dist/server/node_modules/ufo/dist/index.mjs +638 -0
  99. package/dist/server/node_modules/ufo/package.json +47 -0
  100. package/dist/server/node_modules/unhead/dist/index.mjs +9 -0
  101. package/dist/server/node_modules/unhead/dist/parser.mjs +508 -0
  102. package/dist/server/node_modules/unhead/dist/plugins.mjs +101 -0
  103. package/dist/server/node_modules/unhead/dist/scripts.mjs +30 -0
  104. package/dist/server/node_modules/unhead/dist/server.mjs +182 -0
  105. package/dist/server/node_modules/unhead/dist/shared/unhead.B578PsDV.mjs +266 -0
  106. package/dist/server/node_modules/unhead/dist/shared/unhead.BPM0-cfG.mjs +44 -0
  107. package/dist/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
  108. package/dist/server/node_modules/unhead/dist/shared/unhead.BpRRHAhY.mjs +194 -0
  109. package/dist/server/node_modules/unhead/dist/shared/unhead.CApf5sj3.mjs +148 -0
  110. package/dist/server/node_modules/unhead/dist/shared/unhead.DH45uomy.mjs +180 -0
  111. package/dist/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
  112. package/dist/server/node_modules/unhead/dist/shared/unhead.DZbvapt-.mjs +70 -0
  113. package/dist/server/node_modules/unhead/dist/shared/unhead.Djo8ep_Y.mjs +166 -0
  114. package/dist/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
  115. package/dist/server/node_modules/unhead/dist/utils.mjs +5 -0
  116. package/dist/server/node_modules/unhead/package.json +105 -0
  117. package/dist/server/node_modules/vue/dist/vue.cjs.js +80 -0
  118. package/dist/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
  119. package/dist/server/node_modules/vue/index.js +7 -0
  120. package/dist/server/node_modules/vue/index.mjs +1 -0
  121. package/dist/server/node_modules/vue/package.json +112 -0
  122. package/dist/server/node_modules/vue/server-renderer/index.mjs +1 -0
  123. package/dist/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +301 -0
  124. package/dist/server/node_modules/vue-bundle-renderer/package.json +55 -0
  125. package/dist/server/node_modules/ws/lib/buffer-util.js +131 -0
  126. package/dist/server/node_modules/ws/lib/constants.js +19 -0
  127. package/dist/server/node_modules/ws/lib/event-target.js +292 -0
  128. package/dist/server/node_modules/ws/lib/extension.js +203 -0
  129. package/dist/server/node_modules/ws/lib/limiter.js +55 -0
  130. package/dist/server/node_modules/ws/lib/permessage-deflate.js +528 -0
  131. package/dist/server/node_modules/ws/lib/receiver.js +706 -0
  132. package/dist/server/node_modules/ws/lib/sender.js +602 -0
  133. package/dist/server/node_modules/ws/lib/stream.js +161 -0
  134. package/dist/server/node_modules/ws/lib/subprotocol.js +62 -0
  135. package/dist/server/node_modules/ws/lib/validation.js +152 -0
  136. package/dist/server/node_modules/ws/lib/websocket-server.js +554 -0
  137. package/dist/server/node_modules/ws/lib/websocket.js +1393 -0
  138. package/dist/server/node_modules/ws/package.json +69 -0
  139. package/dist/server/node_modules/ws/wrapper.mjs +8 -0
  140. package/dist/server/package.json +32 -0
  141. package/dist/shared/yansu.DmdNF4qf.mjs +151 -0
  142. package/package.json +50 -0
@@ -0,0 +1,407 @@
1
+ import {
2
+ DevalueError,
3
+ enumerable_symbols,
4
+ escaped,
5
+ get_type,
6
+ is_plain_object,
7
+ is_primitive,
8
+ stringify_key,
9
+ stringify_string
10
+ } from './utils.js';
11
+
12
+ const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
13
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
14
+ const reserved =
15
+ /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
16
+
17
+ /**
18
+ * Turn a value into the JavaScript that creates an equivalent value
19
+ * @param {any} value
20
+ * @param {(value: any, uneval: (value: any) => string) => string | void} [replacer]
21
+ */
22
+ export function uneval(value, replacer) {
23
+ const counts = new Map();
24
+
25
+ /** @type {string[]} */
26
+ const keys = [];
27
+
28
+ const custom = new Map();
29
+
30
+ /** @param {any} thing */
31
+ function walk(thing) {
32
+ if (!is_primitive(thing)) {
33
+ if (counts.has(thing)) {
34
+ counts.set(thing, counts.get(thing) + 1);
35
+ return;
36
+ }
37
+
38
+ counts.set(thing, 1);
39
+
40
+ if (replacer) {
41
+ const str = replacer(thing, (value) => uneval(value, replacer));
42
+
43
+ if (typeof str === 'string') {
44
+ custom.set(thing, str);
45
+ return;
46
+ }
47
+ }
48
+
49
+ if (typeof thing === 'function') {
50
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
51
+ }
52
+
53
+ const type = get_type(thing);
54
+
55
+ switch (type) {
56
+ case 'Number':
57
+ case 'BigInt':
58
+ case 'String':
59
+ case 'Boolean':
60
+ case 'Date':
61
+ case 'RegExp':
62
+ case 'URL':
63
+ case 'URLSearchParams':
64
+ return;
65
+
66
+ case 'Array':
67
+ /** @type {any[]} */ (thing).forEach((value, i) => {
68
+ keys.push(`[${i}]`);
69
+ walk(value);
70
+ keys.pop();
71
+ });
72
+ break;
73
+
74
+ case 'Set':
75
+ Array.from(thing).forEach(walk);
76
+ break;
77
+
78
+ case 'Map':
79
+ for (const [key, value] of thing) {
80
+ keys.push(
81
+ `.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`
82
+ );
83
+ walk(value);
84
+ keys.pop();
85
+ }
86
+ break;
87
+
88
+ case 'Int8Array':
89
+ case 'Uint8Array':
90
+ case 'Uint8ClampedArray':
91
+ case 'Int16Array':
92
+ case 'Uint16Array':
93
+ case 'Int32Array':
94
+ case 'Uint32Array':
95
+ case 'Float32Array':
96
+ case 'Float64Array':
97
+ case 'BigInt64Array':
98
+ case 'BigUint64Array':
99
+ walk(thing.buffer);
100
+ return;
101
+
102
+ case 'ArrayBuffer':
103
+ return;
104
+
105
+ case 'Temporal.Duration':
106
+ case 'Temporal.Instant':
107
+ case 'Temporal.PlainDate':
108
+ case 'Temporal.PlainTime':
109
+ case 'Temporal.PlainDateTime':
110
+ case 'Temporal.PlainMonthDay':
111
+ case 'Temporal.PlainYearMonth':
112
+ case 'Temporal.ZonedDateTime':
113
+ return;
114
+
115
+ default:
116
+ if (!is_plain_object(thing)) {
117
+ throw new DevalueError(
118
+ `Cannot stringify arbitrary non-POJOs`,
119
+ keys,
120
+ thing,
121
+ value
122
+ );
123
+ }
124
+
125
+ if (enumerable_symbols(thing).length > 0) {
126
+ throw new DevalueError(
127
+ `Cannot stringify POJOs with symbolic keys`,
128
+ keys,
129
+ thing,
130
+ value
131
+ );
132
+ }
133
+
134
+ for (const key in thing) {
135
+ keys.push(stringify_key(key));
136
+ walk(thing[key]);
137
+ keys.pop();
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ walk(value);
144
+
145
+ const names = new Map();
146
+
147
+ Array.from(counts)
148
+ .filter((entry) => entry[1] > 1)
149
+ .sort((a, b) => b[1] - a[1])
150
+ .forEach((entry, i) => {
151
+ names.set(entry[0], get_name(i));
152
+ });
153
+
154
+ /**
155
+ * @param {any} thing
156
+ * @returns {string}
157
+ */
158
+ function stringify(thing) {
159
+ if (names.has(thing)) {
160
+ return names.get(thing);
161
+ }
162
+
163
+ if (is_primitive(thing)) {
164
+ return stringify_primitive(thing);
165
+ }
166
+
167
+ if (custom.has(thing)) {
168
+ return custom.get(thing);
169
+ }
170
+
171
+ const type = get_type(thing);
172
+
173
+ switch (type) {
174
+ case 'Number':
175
+ case 'String':
176
+ case 'Boolean':
177
+ return `Object(${stringify(thing.valueOf())})`;
178
+
179
+ case 'RegExp':
180
+ return `new RegExp(${stringify_string(thing.source)}, "${
181
+ thing.flags
182
+ }")`;
183
+
184
+ case 'Date':
185
+ return `new Date(${thing.getTime()})`;
186
+
187
+ case 'URL':
188
+ return `new URL(${stringify_string(thing.toString())})`;
189
+
190
+ case 'URLSearchParams':
191
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
192
+
193
+ case 'Array':
194
+ const members = /** @type {any[]} */ (thing).map((v, i) =>
195
+ i in thing ? stringify(v) : ''
196
+ );
197
+ const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
198
+ return `[${members.join(',')}${tail}]`;
199
+
200
+ case 'Set':
201
+ case 'Map':
202
+ return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
203
+
204
+ case 'Int8Array':
205
+ case 'Uint8Array':
206
+ case 'Uint8ClampedArray':
207
+ case 'Int16Array':
208
+ case 'Uint16Array':
209
+ case 'Int32Array':
210
+ case 'Uint32Array':
211
+ case 'Float32Array':
212
+ case 'Float64Array':
213
+ case 'BigInt64Array':
214
+ case 'BigUint64Array': {
215
+ let str = `new ${type}`;
216
+
217
+ if (counts.get(thing.buffer) === 1) {
218
+ const array = new thing.constructor(thing.buffer);
219
+ str += `([${array}])`;
220
+ } else {
221
+ str += `([${stringify(thing.buffer)}])`;
222
+ }
223
+
224
+ const a = thing.byteOffset;
225
+ const b = a + thing.byteLength;
226
+
227
+ // handle subarrays
228
+ if (a > 0 || b !== thing.buffer.byteLength) {
229
+ const m = +/(\d+)/.exec(type)[1] / 8;
230
+ str += `.subarray(${a / m},${b / m})`;
231
+ }
232
+
233
+ return str;
234
+ }
235
+
236
+ case 'ArrayBuffer': {
237
+ const ui8 = new Uint8Array(thing);
238
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
239
+ }
240
+
241
+ case 'Temporal.Duration':
242
+ case 'Temporal.Instant':
243
+ case 'Temporal.PlainDate':
244
+ case 'Temporal.PlainTime':
245
+ case 'Temporal.PlainDateTime':
246
+ case 'Temporal.PlainMonthDay':
247
+ case 'Temporal.PlainYearMonth':
248
+ case 'Temporal.ZonedDateTime':
249
+ return `${type}.from(${stringify_string(thing.toString())})`;
250
+
251
+ default:
252
+ const keys = Object.keys(thing);
253
+ const obj = keys
254
+ .map((key) => `${safe_key(key)}:${stringify(thing[key])}`)
255
+ .join(',');
256
+ const proto = Object.getPrototypeOf(thing);
257
+ if (proto === null) {
258
+ return keys.length > 0
259
+ ? `{${obj},__proto__:null}`
260
+ : `{__proto__:null}`;
261
+ }
262
+
263
+ return `{${obj}}`;
264
+ }
265
+ }
266
+
267
+ const str = stringify(value);
268
+
269
+ if (names.size) {
270
+ /** @type {string[]} */
271
+ const params = [];
272
+
273
+ /** @type {string[]} */
274
+ const statements = [];
275
+
276
+ /** @type {string[]} */
277
+ const values = [];
278
+
279
+ names.forEach((name, thing) => {
280
+ params.push(name);
281
+
282
+ if (custom.has(thing)) {
283
+ values.push(/** @type {string} */ (custom.get(thing)));
284
+ return;
285
+ }
286
+
287
+ if (is_primitive(thing)) {
288
+ values.push(stringify_primitive(thing));
289
+ return;
290
+ }
291
+
292
+ const type = get_type(thing);
293
+
294
+ switch (type) {
295
+ case 'Number':
296
+ case 'String':
297
+ case 'Boolean':
298
+ values.push(`Object(${stringify(thing.valueOf())})`);
299
+ break;
300
+
301
+ case 'RegExp':
302
+ values.push(thing.toString());
303
+ break;
304
+
305
+ case 'Date':
306
+ values.push(`new Date(${thing.getTime()})`);
307
+ break;
308
+
309
+ case 'Array':
310
+ values.push(`Array(${thing.length})`);
311
+ /** @type {any[]} */ (thing).forEach((v, i) => {
312
+ statements.push(`${name}[${i}]=${stringify(v)}`);
313
+ });
314
+ break;
315
+
316
+ case 'Set':
317
+ values.push(`new Set`);
318
+ statements.push(
319
+ `${name}.${Array.from(thing)
320
+ .map((v) => `add(${stringify(v)})`)
321
+ .join('.')}`
322
+ );
323
+ break;
324
+
325
+ case 'Map':
326
+ values.push(`new Map`);
327
+ statements.push(
328
+ `${name}.${Array.from(thing)
329
+ .map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)
330
+ .join('.')}`
331
+ );
332
+ break;
333
+
334
+ case 'ArrayBuffer':
335
+ values.push(
336
+ `new Uint8Array([${new Uint8Array(thing).join(',')}]).buffer`
337
+ );
338
+ break;
339
+
340
+ default:
341
+ values.push(
342
+ Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'
343
+ );
344
+ Object.keys(thing).forEach((key) => {
345
+ statements.push(
346
+ `${name}${safe_prop(key)}=${stringify(thing[key])}`
347
+ );
348
+ });
349
+ }
350
+ });
351
+
352
+ statements.push(`return ${str}`);
353
+
354
+ return `(function(${params.join(',')}){${statements.join(
355
+ ';'
356
+ )}}(${values.join(',')}))`;
357
+ } else {
358
+ return str;
359
+ }
360
+ }
361
+
362
+ /** @param {number} num */
363
+ function get_name(num) {
364
+ let name = '';
365
+
366
+ do {
367
+ name = chars[num % chars.length] + name;
368
+ num = ~~(num / chars.length) - 1;
369
+ } while (num >= 0);
370
+
371
+ return reserved.test(name) ? `${name}0` : name;
372
+ }
373
+
374
+ /** @param {string} c */
375
+ function escape_unsafe_char(c) {
376
+ return escaped[c] || c;
377
+ }
378
+
379
+ /** @param {string} str */
380
+ function escape_unsafe_chars(str) {
381
+ return str.replace(unsafe_chars, escape_unsafe_char);
382
+ }
383
+
384
+ /** @param {string} key */
385
+ function safe_key(key) {
386
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
387
+ ? key
388
+ : escape_unsafe_chars(JSON.stringify(key));
389
+ }
390
+
391
+ /** @param {string} key */
392
+ function safe_prop(key) {
393
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
394
+ ? `.${key}`
395
+ : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
396
+ }
397
+
398
+ /** @param {any} thing */
399
+ function stringify_primitive(thing) {
400
+ if (typeof thing === 'string') return stringify_string(thing);
401
+ if (thing === void 0) return 'void 0';
402
+ if (thing === 0 && 1 / thing < 0) return '-0';
403
+ const str = String(thing);
404
+ if (typeof thing === 'number') return str.replace(/^(-)?0\./, '$1.');
405
+ if (typeof thing === 'bigint') return thing + 'n';
406
+ return str;
407
+ }
@@ -0,0 +1,118 @@
1
+ /** @type {Record<string, string>} */
2
+ export const escaped = {
3
+ '<': '\\u003C',
4
+ '\\': '\\\\',
5
+ '\b': '\\b',
6
+ '\f': '\\f',
7
+ '\n': '\\n',
8
+ '\r': '\\r',
9
+ '\t': '\\t',
10
+ '\u2028': '\\u2028',
11
+ '\u2029': '\\u2029'
12
+ };
13
+
14
+ export class DevalueError extends Error {
15
+ /**
16
+ * @param {string} message
17
+ * @param {string[]} keys
18
+ * @param {any} [value] - The value that failed to be serialized
19
+ * @param {any} [root] - The root value being serialized
20
+ */
21
+ constructor(message, keys, value, root) {
22
+ super(message);
23
+ this.name = 'DevalueError';
24
+ this.path = keys.join('');
25
+ this.value = value;
26
+ this.root = root;
27
+ }
28
+ }
29
+
30
+ /** @param {any} thing */
31
+ export function is_primitive(thing) {
32
+ return Object(thing) !== thing;
33
+ }
34
+
35
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
36
+ Object.prototype
37
+ )
38
+ .sort()
39
+ .join('\0');
40
+
41
+ /** @param {any} thing */
42
+ export function is_plain_object(thing) {
43
+ const proto = Object.getPrototypeOf(thing);
44
+
45
+ return (
46
+ proto === Object.prototype ||
47
+ proto === null ||
48
+ Object.getPrototypeOf(proto) === null ||
49
+ Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
50
+ );
51
+ }
52
+
53
+ /** @param {any} thing */
54
+ export function get_type(thing) {
55
+ return Object.prototype.toString.call(thing).slice(8, -1);
56
+ }
57
+
58
+ /** @param {string} char */
59
+ function get_escaped_char(char) {
60
+ switch (char) {
61
+ case '"':
62
+ return '\\"';
63
+ case '<':
64
+ return '\\u003C';
65
+ case '\\':
66
+ return '\\\\';
67
+ case '\n':
68
+ return '\\n';
69
+ case '\r':
70
+ return '\\r';
71
+ case '\t':
72
+ return '\\t';
73
+ case '\b':
74
+ return '\\b';
75
+ case '\f':
76
+ return '\\f';
77
+ case '\u2028':
78
+ return '\\u2028';
79
+ case '\u2029':
80
+ return '\\u2029';
81
+ default:
82
+ return char < ' '
83
+ ? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`
84
+ : '';
85
+ }
86
+ }
87
+
88
+ /** @param {string} str */
89
+ export function stringify_string(str) {
90
+ let result = '';
91
+ let last_pos = 0;
92
+ const len = str.length;
93
+
94
+ for (let i = 0; i < len; i += 1) {
95
+ const char = str[i];
96
+ const replacement = get_escaped_char(char);
97
+ if (replacement) {
98
+ result += str.slice(last_pos, i) + replacement;
99
+ last_pos = i + 1;
100
+ }
101
+ }
102
+
103
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
104
+ }
105
+
106
+ /** @param {Record<string | symbol, any>} object */
107
+ export function enumerable_symbols(object) {
108
+ return Object.getOwnPropertySymbols(object).filter(
109
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
110
+ );
111
+ }
112
+
113
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
114
+
115
+ /** @param {string} key */
116
+ export function stringify_key(key) {
117
+ return is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';
118
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
3
+ var _a;
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.fromCodePoint = void 0;
6
+ exports.replaceCodePoint = replaceCodePoint;
7
+ exports.decodeCodePoint = decodeCodePoint;
8
+ const decodeMap = new Map([
9
+ [0, 65533],
10
+ // C1 Unicode control character reference replacements
11
+ [128, 8364],
12
+ [130, 8218],
13
+ [131, 402],
14
+ [132, 8222],
15
+ [133, 8230],
16
+ [134, 8224],
17
+ [135, 8225],
18
+ [136, 710],
19
+ [137, 8240],
20
+ [138, 352],
21
+ [139, 8249],
22
+ [140, 338],
23
+ [142, 381],
24
+ [145, 8216],
25
+ [146, 8217],
26
+ [147, 8220],
27
+ [148, 8221],
28
+ [149, 8226],
29
+ [150, 8211],
30
+ [151, 8212],
31
+ [152, 732],
32
+ [153, 8482],
33
+ [154, 353],
34
+ [155, 8250],
35
+ [156, 339],
36
+ [158, 382],
37
+ [159, 376],
38
+ ]);
39
+ /**
40
+ * Polyfill for `String.fromCodePoint`. It is used to create a string from a Unicode code point.
41
+ */
42
+ exports.fromCodePoint =
43
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, n/no-unsupported-features/es-builtins
44
+ (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : ((codePoint) => {
45
+ let output = "";
46
+ if (codePoint > 65535) {
47
+ codePoint -= 65536;
48
+ output += String.fromCharCode(((codePoint >>> 10) & 1023) | 55296);
49
+ codePoint = 56320 | (codePoint & 1023);
50
+ }
51
+ output += String.fromCharCode(codePoint);
52
+ return output;
53
+ });
54
+ /**
55
+ * Replace the given code point with a replacement character if it is a
56
+ * surrogate or is outside the valid range. Otherwise return the code
57
+ * point unchanged.
58
+ */
59
+ function replaceCodePoint(codePoint) {
60
+ var _a;
61
+ if ((codePoint >= 55296 && codePoint <= 57343) ||
62
+ codePoint > 1114111) {
63
+ return 65533;
64
+ }
65
+ return (_a = decodeMap.get(codePoint)) !== null && _a !== void 0 ? _a : codePoint;
66
+ }
67
+ /**
68
+ * Replace the code point if relevant, then convert it to a string.
69
+ *
70
+ * @deprecated Use `fromCodePoint(replaceCodePoint(codePoint))` instead.
71
+ * @param codePoint The code point to decode.
72
+ * @returns The decoded code point.
73
+ */
74
+ function decodeCodePoint(codePoint) {
75
+ return (0, exports.fromCodePoint)(replaceCodePoint(codePoint));
76
+ }
77
+ //# sourceMappingURL=decode-codepoint.js.map