shelfware 0.0.1 → 0.1.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 (206) hide show
  1. package/.output/nitro.json +15 -0
  2. package/.output/public/_nuxt/6IstVYrV.js +1 -0
  3. package/.output/public/_nuxt/9C5WUlLE.js +36 -0
  4. package/.output/public/_nuxt/BDNMzG2s.js +1 -0
  5. package/.output/public/_nuxt/BW3xJdEx.js +1 -0
  6. package/.output/public/_nuxt/BXXtFil5.js +1 -0
  7. package/.output/public/_nuxt/BZuUK3cr.js +1 -0
  8. package/.output/public/_nuxt/BeLyMmd4.js +1 -0
  9. package/.output/public/_nuxt/C_VgD9ZI.js +3 -0
  10. package/.output/public/_nuxt/DB5Vxbte.js +2 -0
  11. package/.output/public/_nuxt/DMg0j7gv.js +14 -0
  12. package/.output/public/_nuxt/builds/latest.json +1 -0
  13. package/.output/public/_nuxt/builds/meta/e0d2b6a3-3a30-44b7-8c79-a56f66400005.json +1 -0
  14. package/.output/public/_nuxt/entry.b3_DJTEt.css +2 -0
  15. package/.output/public/_nuxt/error-404.CHsn7XF-.css +1 -0
  16. package/.output/public/_nuxt/error-500.Bawx2bLr.css +1 -0
  17. package/.output/server/chunks/_/api-handler.mjs +44 -0
  18. package/.output/server/chunks/_/batch.mjs +27 -0
  19. package/.output/server/chunks/_/catalog.mjs +1115 -0
  20. package/.output/server/chunks/_/detail.mjs +16 -0
  21. package/.output/server/chunks/_/error-500.mjs +19 -0
  22. package/.output/server/chunks/_/quarantine.mjs +159 -0
  23. package/.output/server/chunks/nitro/nitro.mjs +5399 -0
  24. package/.output/server/chunks/routes/api/_..._.mjs +16 -0
  25. package/.output/server/chunks/routes/api/health.get.mjs +13 -0
  26. package/.output/server/chunks/routes/api/skills/_id/file.get.mjs +25 -0
  27. package/.output/server/chunks/routes/api/skills/_id_.get.mjs +25 -0
  28. package/.output/server/chunks/routes/api/skills/_id_.put.mjs +74 -0
  29. package/.output/server/chunks/routes/api/skills/delete.post.mjs +48 -0
  30. package/.output/server/chunks/routes/api/skills/quarantine.post.mjs +26 -0
  31. package/.output/server/chunks/routes/api/skills/restore.post.mjs +26 -0
  32. package/.output/server/chunks/routes/api/skills.get.mjs +41 -0
  33. package/.output/server/chunks/routes/renderer.mjs +341 -0
  34. package/.output/server/chunks/virtual/_virtual_spa-template.mjs +3 -0
  35. package/.output/server/chunks/virtual/precomputed.mjs +3 -0
  36. package/.output/server/index.mjs +9 -0
  37. package/.output/server/node_modules/@babel/parser/lib/index.js +14611 -0
  38. package/.output/server/node_modules/@babel/parser/package.json +50 -0
  39. package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6801 -0
  40. package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
  41. package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +692 -0
  42. package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
  43. package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
  44. package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
  45. package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1903 -0
  46. package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
  47. package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6980 -0
  48. package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
  49. package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1867 -0
  50. package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
  51. package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +904 -0
  52. package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
  53. package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +636 -0
  54. package/.output/server/node_modules/@vue/shared/package.json +47 -0
  55. package/.output/server/node_modules/devalue/index.js +17 -0
  56. package/.output/server/node_modules/devalue/package.json +39 -0
  57. package/.output/server/node_modules/devalue/src/base64.js +60 -0
  58. package/.output/server/node_modules/devalue/src/constants.js +12 -0
  59. package/.output/server/node_modules/devalue/src/operations.js +193 -0
  60. package/.output/server/node_modules/devalue/src/parse.js +274 -0
  61. package/.output/server/node_modules/devalue/src/stringify.js +428 -0
  62. package/.output/server/node_modules/devalue/src/uneval.js +606 -0
  63. package/.output/server/node_modules/devalue/src/utils.js +185 -0
  64. package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
  65. package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
  66. package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
  67. package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
  68. package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
  69. package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
  70. package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
  71. package/.output/server/node_modules/entities/package.json +120 -0
  72. package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
  73. package/.output/server/node_modules/estree-walker/package.json +37 -0
  74. package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
  75. package/.output/server/node_modules/hookable/package.json +53 -0
  76. package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
  77. package/.output/server/node_modules/nostics/dist/index.mjs +187 -0
  78. package/.output/server/node_modules/nostics/package.json +125 -0
  79. package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
  80. package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  81. package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
  82. package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
  83. package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
  84. package/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
  85. package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  86. package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  87. package/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
  88. package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
  89. package/.output/server/node_modules/source-map-js/package.json +71 -0
  90. package/.output/server/node_modules/source-map-js/source-map.js +8 -0
  91. package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
  92. package/.output/server/node_modules/ufo/package.json +48 -0
  93. package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
  94. package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
  95. package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
  96. package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
  97. package/.output/server/node_modules/unhead/dist/plugins.mjs +720 -0
  98. package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
  99. package/.output/server/node_modules/unhead/dist/shared/unhead.-hZVKou0.mjs +400 -0
  100. package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
  101. package/.output/server/node_modules/unhead/dist/shared/unhead.BGFxPGPQ.mjs +47 -0
  102. package/.output/server/node_modules/unhead/dist/shared/unhead.BQWSw36o.mjs +192 -0
  103. package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
  104. package/.output/server/node_modules/unhead/dist/shared/unhead.Bjbp1C8D.mjs +224 -0
  105. package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
  106. package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
  107. package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
  108. package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
  109. package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
  110. package/.output/server/node_modules/unhead/dist/shared/unhead.Dssd7L5I.mjs +196 -0
  111. package/.output/server/node_modules/unhead/dist/shared/unhead.jEy9BmRq.mjs +264 -0
  112. package/.output/server/node_modules/unhead/dist/shared/unhead.oZ7pkTV1.mjs +19 -0
  113. package/.output/server/node_modules/unhead/dist/shared/unhead.tQnRaXfX.mjs +240 -0
  114. package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
  115. package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
  116. package/.output/server/node_modules/unhead/dist/stream/server.mjs +445 -0
  117. package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
  118. package/.output/server/node_modules/unhead/package.json +179 -0
  119. package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
  120. package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
  121. package/.output/server/node_modules/vue/index.js +7 -0
  122. package/.output/server/node_modules/vue/index.mjs +1 -0
  123. package/.output/server/node_modules/vue/package.json +112 -0
  124. package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
  125. package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +278 -0
  126. package/.output/server/node_modules/vue-bundle-renderer/package.json +54 -0
  127. package/.output/server/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  128. package/.output/server/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  129. package/.output/server/node_modules/yaml/dist/compose/compose-node.js +112 -0
  130. package/.output/server/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  131. package/.output/server/node_modules/yaml/dist/compose/composer.js +224 -0
  132. package/.output/server/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  133. package/.output/server/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  134. package/.output/server/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  135. package/.output/server/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  136. package/.output/server/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  137. package/.output/server/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
  138. package/.output/server/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  139. package/.output/server/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  140. package/.output/server/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  141. package/.output/server/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  142. package/.output/server/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  143. package/.output/server/node_modules/yaml/dist/doc/Document.js +337 -0
  144. package/.output/server/node_modules/yaml/dist/doc/anchors.js +76 -0
  145. package/.output/server/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  146. package/.output/server/node_modules/yaml/dist/doc/createNode.js +90 -0
  147. package/.output/server/node_modules/yaml/dist/doc/directives.js +178 -0
  148. package/.output/server/node_modules/yaml/dist/errors.js +62 -0
  149. package/.output/server/node_modules/yaml/dist/index.js +50 -0
  150. package/.output/server/node_modules/yaml/dist/log.js +19 -0
  151. package/.output/server/node_modules/yaml/dist/nodes/Alias.js +118 -0
  152. package/.output/server/node_modules/yaml/dist/nodes/Collection.js +151 -0
  153. package/.output/server/node_modules/yaml/dist/nodes/Node.js +40 -0
  154. package/.output/server/node_modules/yaml/dist/nodes/Pair.js +39 -0
  155. package/.output/server/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  156. package/.output/server/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  157. package/.output/server/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  158. package/.output/server/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  159. package/.output/server/node_modules/yaml/dist/nodes/identity.js +53 -0
  160. package/.output/server/node_modules/yaml/dist/nodes/toJS.js +39 -0
  161. package/.output/server/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  162. package/.output/server/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  163. package/.output/server/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  164. package/.output/server/node_modules/yaml/dist/parse/cst.js +112 -0
  165. package/.output/server/node_modules/yaml/dist/parse/lexer.js +723 -0
  166. package/.output/server/node_modules/yaml/dist/parse/line-counter.js +41 -0
  167. package/.output/server/node_modules/yaml/dist/parse/parser.js +980 -0
  168. package/.output/server/node_modules/yaml/dist/public-api.js +107 -0
  169. package/.output/server/node_modules/yaml/dist/schema/Schema.js +39 -0
  170. package/.output/server/node_modules/yaml/dist/schema/common/map.js +19 -0
  171. package/.output/server/node_modules/yaml/dist/schema/common/null.js +17 -0
  172. package/.output/server/node_modules/yaml/dist/schema/common/seq.js +19 -0
  173. package/.output/server/node_modules/yaml/dist/schema/common/string.js +16 -0
  174. package/.output/server/node_modules/yaml/dist/schema/core/bool.js +21 -0
  175. package/.output/server/node_modules/yaml/dist/schema/core/float.js +47 -0
  176. package/.output/server/node_modules/yaml/dist/schema/core/int.js +42 -0
  177. package/.output/server/node_modules/yaml/dist/schema/core/schema.js +25 -0
  178. package/.output/server/node_modules/yaml/dist/schema/json/schema.js +64 -0
  179. package/.output/server/node_modules/yaml/dist/schema/tags.js +99 -0
  180. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  181. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  182. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  183. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  184. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  185. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  186. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  187. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  188. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  189. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  190. package/.output/server/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  191. package/.output/server/node_modules/yaml/dist/stringify/stringify.js +132 -0
  192. package/.output/server/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  193. package/.output/server/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  194. package/.output/server/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  195. package/.output/server/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  196. package/.output/server/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  197. package/.output/server/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  198. package/.output/server/node_modules/yaml/dist/visit.js +236 -0
  199. package/.output/server/node_modules/yaml/package.json +97 -0
  200. package/.output/server/package.json +28 -0
  201. package/LICENSE +21 -0
  202. package/README.md +57 -1
  203. package/bin/launch.mjs +216 -0
  204. package/bin/shelfware.mjs +11 -0
  205. package/package.json +64 -5
  206. package/cli.mjs +0 -3
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@vue/shared",
3
+ "version": "3.5.42",
4
+ "description": "internal utils shared across @vue packages",
5
+ "main": "index.js",
6
+ "module": "dist/shared.esm-bundler.js",
7
+ "types": "dist/shared.d.ts",
8
+ "files": [
9
+ "index.js",
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/shared.d.ts",
15
+ "node": {
16
+ "production": "./dist/shared.cjs.prod.js",
17
+ "development": "./dist/shared.cjs.js",
18
+ "default": "./dist/shared.cjs.prod.js"
19
+ },
20
+ "module": "./dist/shared.esm-bundler.js",
21
+ "import": "./dist/shared.esm-bundler.js",
22
+ "require": "./index.js"
23
+ },
24
+ "./*": "./*"
25
+ },
26
+ "sideEffects": false,
27
+ "buildOptions": {
28
+ "formats": [
29
+ "esm-bundler",
30
+ "cjs"
31
+ ]
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/vuejs/core.git",
36
+ "directory": "packages/shared"
37
+ },
38
+ "keywords": [
39
+ "vue"
40
+ ],
41
+ "author": "Evan You",
42
+ "license": "MIT",
43
+ "bugs": {
44
+ "url": "https://github.com/vuejs/core/issues"
45
+ },
46
+ "homepage": "https://github.com/vuejs/core/tree/main/packages/shared#readme"
47
+ }
@@ -0,0 +1,17 @@
1
+ export { uneval } from './src/uneval.js';
2
+ export { parse, unflatten } from './src/parse.js';
3
+ export { stringify, stringifyAsync } from './src/stringify.js';
4
+ export {
5
+ default_stringify_operations as defaultStringifyOperations,
6
+ default_parse_operations as defaultParseOperations
7
+ } from './src/operations.js';
8
+ export { DevalueError, filter_array_indices as filterArrayIndices } from './src/utils.js';
9
+
10
+ /** @typedef {import('./src/types.js').StringValueTag} StringValueTag */
11
+ /** @typedef {import('./src/types.js').ViewTag} ViewTag */
12
+ /** @typedef {import('./src/types.js').StringifyOperations} StringifyOperations */
13
+ /** @typedef {import('./src/types.js').DefaultStringifyOperations} DefaultStringifyOperations */
14
+ /** @typedef {import('./src/types.js').StringifyOptions} StringifyOptions */
15
+ /** @typedef {import('./src/types.js').ParseOperations} ParseOperations */
16
+ /** @typedef {import('./src/types.js').DefaultParseOperations} DefaultParseOperations */
17
+ /** @typedef {import('./src/types.js').ParseOptions} ParseOptions */
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "devalue",
3
+ "description": "Gets the job done when JSON.stringify can't",
4
+ "version": "5.9.2",
5
+ "repository": "sveltejs/devalue",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "types": "./types/index.d.ts",
10
+ "import": "./index.js",
11
+ "default": "./index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "index.js",
16
+ "src",
17
+ "types"
18
+ ],
19
+ "types": "./types/index.d.ts",
20
+ "devDependencies": {
21
+ "@changesets/cli": "^2.29.6",
22
+ "@js-temporal/polyfill": "^0.5.1",
23
+ "@types/node": "^24.12.0",
24
+ "dts-buddy": "^0.6.2",
25
+ "publint": "^0.3.12",
26
+ "typescript": "^5.9.2",
27
+ "uvu": "^0.5.6"
28
+ },
29
+ "license": "MIT",
30
+ "type": "module",
31
+ "scripts": {
32
+ "changeset:version": "changeset version",
33
+ "changeset:publish": "changeset publish",
34
+ "build": "dts-buddy",
35
+ "test": "uvu",
36
+ "bench": "node --allow-natives-syntax ./benchmarking/run.js",
37
+ "bench:compare": "node --allow-natives-syntax ./benchmarking/compare/index.js"
38
+ }
39
+ }
@@ -0,0 +1,60 @@
1
+ /* Baseline 2025 runtimes */
2
+
3
+ /** @type {(array_buffer: ArrayBuffer) => string} */
4
+ export function encode_native(array_buffer) {
5
+ return new Uint8Array(array_buffer).toBase64();
6
+ }
7
+
8
+ /** @type {(base64: string) => ArrayBuffer} */
9
+ export function decode_native(base64) {
10
+ return Uint8Array.fromBase64(base64).buffer;
11
+ }
12
+
13
+ /* Node-compatible runtimes */
14
+
15
+ /** @type {(array_buffer: ArrayBuffer) => string} */
16
+ export function encode_buffer(array_buffer) {
17
+ return Buffer.from(array_buffer).toString('base64');
18
+ }
19
+
20
+ /** @type {(base64: string) => ArrayBuffer} */
21
+ export function decode_buffer(base64) {
22
+ return Uint8Array.from(Buffer.from(base64, 'base64')).buffer;
23
+ }
24
+
25
+ /* Legacy runtimes */
26
+
27
+ /** @type {(array_buffer: ArrayBuffer) => string} */
28
+ export function encode_legacy(array_buffer) {
29
+ const array = new Uint8Array(array_buffer);
30
+ let binary = '';
31
+
32
+ // the maximum number of arguments to String.fromCharCode.apply
33
+ // should be around 0xFFFF in modern engines
34
+ const chunk_size = 0x8000;
35
+ for (let i = 0; i < array.length; i += chunk_size) {
36
+ const chunk = array.subarray(i, i + chunk_size);
37
+ binary += String.fromCharCode.apply(null, chunk);
38
+ }
39
+
40
+ return btoa(binary);
41
+ }
42
+
43
+ /** @type {(base64: string) => ArrayBuffer} */
44
+ export function decode_legacy(base64) {
45
+ const binary_string = atob(base64);
46
+ const len = binary_string.length;
47
+ const array = new Uint8Array(len);
48
+
49
+ for (let i = 0; i < len; i++) {
50
+ array[i] = binary_string.charCodeAt(i);
51
+ }
52
+
53
+ return array.buffer;
54
+ }
55
+
56
+ const native = typeof Uint8Array.fromBase64 === 'function';
57
+ const buffer = typeof process === 'object' && process.versions?.node !== undefined;
58
+
59
+ export const encode64 = native ? encode_native : buffer ? encode_buffer : encode_legacy;
60
+ export const decode64 = native ? decode_native : buffer ? decode_buffer : decode_legacy;
@@ -0,0 +1,12 @@
1
+ export const UNDEFINED = -1;
2
+ export const HOLE = -2;
3
+ export const NAN = -3;
4
+ export const POSITIVE_INFINITY = -4;
5
+ export const NEGATIVE_INFINITY = -5;
6
+ export const NEGATIVE_ZERO = -6;
7
+ export const SPARSE = -7;
8
+
9
+ // The largest valid value for a JavaScript array's `length` property,
10
+ // and the largest valid array index (one less than the max length).
11
+ export const MAX_ARRAY_LEN = 2 ** 32 - 1;
12
+ export const MAX_ARRAY_INDEX = MAX_ARRAY_LEN - 1;
@@ -0,0 +1,193 @@
1
+ import { MAX_ARRAY_INDEX } from './constants.js';
2
+ import {
3
+ enumerable_symbols,
4
+ get_type,
5
+ is_plain_object,
6
+ valid_array_indices
7
+ } from './utils.js';
8
+
9
+ /**
10
+ * Merges caller-provided operation overrides over the defaults. Iterating the
11
+ * default keys (rather than the override's own keys) means nullish members
12
+ * fall back to the default, and inherited members — e.g. from a class
13
+ * instance — are picked up.
14
+ *
15
+ * @template {Record<string, any>} T
16
+ * @param {T} defaults
17
+ * @param {Partial<T> | undefined} overrides
18
+ * @returns {T}
19
+ */
20
+ export function merge_operations(defaults, overrides) {
21
+ if (!overrides) return defaults;
22
+
23
+ const merged = /** @type {T} */ ({});
24
+
25
+ for (const key of /** @type {(keyof T)[]} */ (Object.keys(defaults))) {
26
+ merged[key] = overrides[key] ?? defaults[key];
27
+ }
28
+
29
+ return merged;
30
+ }
31
+
32
+ /** @type {{ kind: 'not-plain' }} */
33
+ const NOT_PLAIN = Object.freeze({ kind: 'not-plain' });
34
+
35
+ /** @type {{ kind: 'symbol-keys' }} */
36
+ const SYMBOL_KEYS = Object.freeze({ kind: 'symbol-keys' });
37
+
38
+ /**
39
+ * The default implementations of every introspection/extraction operation
40
+ * `stringify` performs on the value being serialized. Each one uses native
41
+ * JavaScript semantics (property access, iteration, prototype methods, etc).
42
+ *
43
+ * Pass overrides via the `operations` option of `stringify`/`stringifyAsync`
44
+ * to customize how values are inspected — e.g. to serialize values without
45
+ * triggering getters, proxy traps, or patched prototype methods, or to
46
+ * serialize values that live in a different JavaScript runtime (a `node:vm`
47
+ * context, a WASM-hosted engine, a remote process) through handle objects.
48
+ *
49
+ * The object is frozen — it is shared by every `stringify` call that does
50
+ * not override a given operation.
51
+ *
52
+ */
53
+ /** @type {import('./types.js').DefaultStringifyOperations} */
54
+ const stringify_operations = {
55
+ identify: (value) => value,
56
+
57
+ typeOf: (value) => (value === null ? 'null' : typeof value),
58
+
59
+ toPrimitive: (value) => value,
60
+
61
+ tagOf: (value) => get_type(value),
62
+
63
+ isThenable: (value) => typeof value.then === 'function',
64
+
65
+ toPromise: (thenable) => Promise.resolve(thenable),
66
+
67
+ unbox: (boxed) => boxed.valueOf(),
68
+
69
+ toISOString: (date) => (isNaN(date.getDate()) ? '' : date.toISOString()),
70
+
71
+ toStringValue: (value) => value.toString(),
72
+
73
+ regExpInfo: (regexp) => ({ source: regexp.source, flags: regexp.flags }),
74
+
75
+ valuesOf: (set) => set,
76
+
77
+ entriesOf: (map) => map,
78
+
79
+ viewInfo: (view) => ({
80
+ buffer: view.buffer,
81
+ byteOffset: view.byteOffset,
82
+ byteLength: view.byteLength,
83
+ length: view.length,
84
+ bufferByteLength: view.buffer.byteLength
85
+ }),
86
+
87
+ toArrayBuffer: (buffer) => buffer,
88
+
89
+ lengthOf: (array) => array.length,
90
+
91
+ hasOwn: (value, key) => Object.hasOwn(value, key),
92
+
93
+ indicesOf: (array) => valid_array_indices(array),
94
+
95
+ shapeOf: (value) => {
96
+ if (!is_plain_object(value)) return NOT_PLAIN;
97
+ if (enumerable_symbols(value).length > 0) return SYMBOL_KEYS;
98
+
99
+ return {
100
+ kind: Object.getPrototypeOf(value) === null ? 'null-proto' : 'plain',
101
+ keys: Object.keys(value)
102
+ };
103
+ },
104
+
105
+ get: (value, key) => value[key]
106
+ };
107
+
108
+ export const default_stringify_operations = Object.freeze(stringify_operations);
109
+
110
+ /**
111
+ * The default implementations of every construction operation `parse` and
112
+ * `unflatten` perform while reviving a value. Each one uses native
113
+ * JavaScript semantics (built-in constructors, property assignment, etc).
114
+ *
115
+ * Pass overrides via the `operations` option of `parse`/`unflatten` to
116
+ * customize how values are built — e.g. to construct them from the
117
+ * intrinsics of a different realm (a `node:vm` context), or to build up
118
+ * values inside another JavaScript runtime (a WASM-hosted engine, a remote
119
+ * process) through handle objects.
120
+ *
121
+ * The object is frozen — it is shared by every `parse` call that does not
122
+ * override a given operation.
123
+ *
124
+ */
125
+ /** @type {import('./types.js').DefaultParseOperations} */
126
+ const parse_operations = {
127
+ fromPrimitive: (primitive) => primitive,
128
+
129
+ fromISOString: (iso) => new Date(iso),
130
+
131
+ fromStringValue: (tag, text) => {
132
+ if (tag === 'URL') return new URL(text);
133
+ if (tag === 'URLSearchParams') return new URLSearchParams(text);
134
+ // 'Temporal.Instant', 'Temporal.PlainDate', ...
135
+ // @ts-expect-error TS doesn't know about Temporal yet
136
+ return Temporal[tag.slice(9)].from(text);
137
+ },
138
+
139
+ fromArrayBuffer: (buffer) => buffer,
140
+
141
+ fromRegExpInfo: (source, flags) => new RegExp(source, flags),
142
+
143
+ fromViewInfo: (tag, buffer, byteOffset, length) => {
144
+ const Constructor = /** @type {any} */ (globalThis)[tag];
145
+ return byteOffset !== undefined
146
+ ? new Constructor(buffer, byteOffset, length)
147
+ : new Constructor(buffer);
148
+ },
149
+
150
+ box: (value) => Object(value),
151
+
152
+ createArray: (length) => new Array(length),
153
+
154
+ createSparseArray: (length) => {
155
+ /** @type {any[]} */
156
+ const array = [];
157
+
158
+ // Setting `array.length = length` (or equivalently calling
159
+ // `new Array(length)`) on an untrusted length is a DoS vector: V8
160
+ // eagerly allocates a contiguous backing store for array lengths below
161
+ // ~10^8, so a small payload with a huge declared length can force
162
+ // arbitrary memory allocation. Touching the largest-possible index
163
+ // first forces V8 into dictionary-elements mode, where `length` is
164
+ // just a number and no contiguous allocation occurs.
165
+ array[MAX_ARRAY_INDEX] = undefined;
166
+ delete array[MAX_ARRAY_INDEX];
167
+ array.length = length;
168
+
169
+ return array;
170
+ },
171
+
172
+ createObject: () => ({}),
173
+
174
+ createNullPrototypeObject: () => Object.create(null),
175
+
176
+ createSet: () => new Set(),
177
+
178
+ createMap: () => new Map(),
179
+
180
+ set: (target, key, value) => {
181
+ target[key] = value;
182
+ },
183
+
184
+ addValue: (set, value) => {
185
+ set.add(value);
186
+ },
187
+
188
+ addEntry: (map, key, value) => {
189
+ map.set(key, value);
190
+ }
191
+ };
192
+
193
+ export const default_parse_operations = Object.freeze(parse_operations);
@@ -0,0 +1,274 @@
1
+ import { decode64 } from './base64.js';
2
+ import {
3
+ HOLE,
4
+ NAN,
5
+ NEGATIVE_INFINITY,
6
+ NEGATIVE_ZERO,
7
+ POSITIVE_INFINITY,
8
+ SPARSE,
9
+ UNDEFINED
10
+ } from './constants.js';
11
+ import { default_parse_operations, merge_operations } from './operations.js';
12
+ import { is_valid_array_index, is_valid_array_len } from './utils.js';
13
+
14
+ /**
15
+ * Revive a value serialized with `devalue.stringify`
16
+ * @param {string} serialized
17
+ * @param {Record<string, (value: any) => any>} [revivers]
18
+ * @param {import('./types.js').ParseOptions} [options]
19
+ */
20
+ export function parse(serialized, revivers, options) {
21
+ return unflatten(JSON.parse(serialized), revivers, options);
22
+ }
23
+
24
+ /**
25
+ * Revive a value flattened with `devalue.stringify`
26
+ * @param {number | any[]} parsed
27
+ * @param {Record<string, (value: any) => any>} [revivers]
28
+ * @param {import('./types.js').ParseOptions} [options]
29
+ */
30
+ export function unflatten(parsed, revivers, options) {
31
+ /** @type {import('./types.js').ParseOperations} */
32
+ const ops = merge_operations(default_parse_operations, options?.operations);
33
+
34
+ if (typeof parsed === 'number') return hydrate(parsed, true);
35
+
36
+ if (!Array.isArray(parsed) || parsed.length === 0) {
37
+ throw new Error('Invalid input');
38
+ }
39
+
40
+ const values = /** @type {any[]} */ (parsed);
41
+
42
+ const hydrated = Array(values.length);
43
+
44
+ /**
45
+ * A set of values currently being hydrated with custom revivers,
46
+ * used to detect invalid cyclical dependencies
47
+ * @type {Set<number> | null}
48
+ */
49
+ let hydrating = null;
50
+
51
+ /**
52
+ * @param {number} index
53
+ * @returns {any}
54
+ */
55
+ function hydrate(index, standalone = false) {
56
+ if (index === UNDEFINED) return ops.fromPrimitive(undefined);
57
+ if (index === NAN) return ops.fromPrimitive(NaN);
58
+ if (index === POSITIVE_INFINITY) return ops.fromPrimitive(Infinity);
59
+ if (index === NEGATIVE_INFINITY) return ops.fromPrimitive(-Infinity);
60
+ if (index === NEGATIVE_ZERO) return ops.fromPrimitive(-0);
61
+
62
+ if (standalone || typeof index !== 'number') {
63
+ throw new Error(`Invalid input`);
64
+ }
65
+
66
+ if (index in hydrated) return hydrated[index];
67
+
68
+ if (index >= values.length) {
69
+ throw new Error(`Invalid input`);
70
+ }
71
+
72
+ const value = values[index];
73
+
74
+ if (!value || typeof value !== 'object') {
75
+ hydrated[index] = ops.fromPrimitive(value);
76
+ } else if (Array.isArray(value)) {
77
+ if (typeof value[0] === 'string') {
78
+ const type = value[0];
79
+
80
+ const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : undefined;
81
+
82
+ if (reviver) {
83
+ let i = value[1];
84
+ if (typeof i !== 'number') {
85
+ // if it's not a number, it was serialized by a builtin reviver
86
+ // so we need to munge it into the format expected by a custom reviver
87
+ i = values.push(value[1]) - 1;
88
+ }
89
+
90
+ // If the payload is already hydrated, its recursion has already
91
+ // terminated (e.g. a self-referential object cached itself before
92
+ // following its own back-reference), so revive it directly. Falling
93
+ // through to the `hydrating` guard here would wrongly reject a valid
94
+ // cycle. An actually infinite payload (e.g. `[["Custom", 0]]`) is never
95
+ // cached, so it still hits the guard below.
96
+ if (Object.hasOwn(hydrated, i)) {
97
+ return (hydrated[index] = reviver(hydrated[i]));
98
+ }
99
+
100
+ hydrating ??= new Set();
101
+
102
+ if (hydrating.has(i)) {
103
+ throw new Error('Invalid circular reference');
104
+ }
105
+
106
+ hydrating.add(i);
107
+ hydrated[index] = reviver(hydrate(i));
108
+ hydrating.delete(i);
109
+
110
+ return hydrated[index];
111
+ }
112
+
113
+ switch (type) {
114
+ case 'Date':
115
+ hydrated[index] = ops.fromISOString(value[1]);
116
+ break;
117
+
118
+ case 'Set':
119
+ const set = ops.createSet();
120
+ hydrated[index] = set;
121
+ for (let i = 1; i < value.length; i += 1) {
122
+ ops.addValue(set, hydrate(value[i]));
123
+ }
124
+ break;
125
+
126
+ case 'Map':
127
+ const map = ops.createMap();
128
+ hydrated[index] = map;
129
+ for (let i = 1; i < value.length; i += 2) {
130
+ ops.addEntry(map, hydrate(value[i]), hydrate(value[i + 1]));
131
+ }
132
+ break;
133
+
134
+ case 'RegExp':
135
+ hydrated[index] = ops.fromRegExpInfo(value[1], value[2]);
136
+ break;
137
+
138
+ case 'Object': {
139
+ const wrapped_index = value[1];
140
+
141
+ if (
142
+ typeof values[wrapped_index] === 'object' &&
143
+ values[wrapped_index][0] !== 'BigInt'
144
+ ) {
145
+ // avoid infinite recusion in case of malformed input
146
+ throw new Error('Invalid input');
147
+ }
148
+
149
+ hydrated[index] = ops.box(hydrate(wrapped_index));
150
+ break;
151
+ }
152
+
153
+ case 'BigInt':
154
+ hydrated[index] = ops.fromPrimitive(BigInt(value[1]));
155
+ break;
156
+
157
+ case 'null':
158
+ const obj = ops.createNullPrototypeObject();
159
+ hydrated[index] = obj;
160
+ for (let i = 1; i < value.length; i += 2) {
161
+ if (value[i] === '__proto__') {
162
+ throw new Error('Cannot parse an object with a `__proto__` property');
163
+ }
164
+
165
+ ops.set(obj, value[i], hydrate(value[i + 1]));
166
+ }
167
+ break;
168
+
169
+ case 'Int8Array':
170
+ case 'Uint8Array':
171
+ case 'Uint8ClampedArray':
172
+ case 'Int16Array':
173
+ case 'Uint16Array':
174
+ case 'Float16Array':
175
+ case 'Int32Array':
176
+ case 'Uint32Array':
177
+ case 'Float32Array':
178
+ case 'Float64Array':
179
+ case 'BigInt64Array':
180
+ case 'BigUint64Array':
181
+ case 'DataView': {
182
+ if (values[value[1]][0] !== 'ArrayBuffer') {
183
+ // without this, if we receive malformed input we could
184
+ // end up trying to hydrate in a circle or allocate
185
+ // huge amounts of memory when we call `new TypedArrayConstructor(buffer)`
186
+ throw new Error('Invalid data');
187
+ }
188
+
189
+ const buffer = hydrate(value[1]);
190
+
191
+ hydrated[index] = ops.fromViewInfo(type, buffer, value[2], value[3]);
192
+
193
+ break;
194
+ }
195
+
196
+ case 'ArrayBuffer': {
197
+ const base64 = value[1];
198
+ if (typeof base64 !== 'string') {
199
+ throw new Error('Invalid ArrayBuffer encoding');
200
+ }
201
+ hydrated[index] = ops.fromArrayBuffer(decode64(base64));
202
+ break;
203
+ }
204
+
205
+ case 'URL':
206
+ case 'URLSearchParams':
207
+ case 'Temporal.Duration':
208
+ case 'Temporal.Instant':
209
+ case 'Temporal.PlainDate':
210
+ case 'Temporal.PlainTime':
211
+ case 'Temporal.PlainDateTime':
212
+ case 'Temporal.PlainMonthDay':
213
+ case 'Temporal.PlainYearMonth':
214
+ case 'Temporal.ZonedDateTime': {
215
+ // the same tags `toStringValue` serializes on the stringify side
216
+ hydrated[index] = ops.fromStringValue(type, value[1]);
217
+ break;
218
+ }
219
+
220
+ default:
221
+ throw new Error(`Unknown type ${type}`);
222
+ }
223
+ } else if (value[0] === SPARSE) {
224
+ // Sparse array encoding: [SPARSE, length, idx, val, idx, val, ...]
225
+ const len = value[1];
226
+
227
+ if (!is_valid_array_len(len)) {
228
+ throw new Error('Invalid input');
229
+ }
230
+
231
+ // `len` comes from the input rather than being bounded by it, so
232
+ // `createSparseArray` is responsible for not allocating storage
233
+ // proportional to it.
234
+ const array = ops.createSparseArray(len);
235
+ hydrated[index] = array;
236
+
237
+ for (let i = 2; i < value.length; i += 2) {
238
+ const idx = value[i];
239
+
240
+ if (!is_valid_array_index(idx) || idx >= len) {
241
+ throw new Error('Invalid input');
242
+ }
243
+
244
+ ops.set(array, idx, hydrate(value[i + 1]));
245
+ }
246
+ } else {
247
+ const array = ops.createArray(value.length);
248
+ hydrated[index] = array;
249
+
250
+ for (let i = 0; i < value.length; i += 1) {
251
+ const n = value[i];
252
+ if (n === HOLE) continue;
253
+
254
+ ops.set(array, i, hydrate(n));
255
+ }
256
+ }
257
+ } else {
258
+ const object = ops.createObject();
259
+ hydrated[index] = object;
260
+
261
+ for (const key of Object.keys(value)) {
262
+ if (key === '__proto__') {
263
+ throw new Error('Cannot parse an object with a `__proto__` property');
264
+ }
265
+
266
+ ops.set(object, key, hydrate(value[key]));
267
+ }
268
+ }
269
+
270
+ return hydrated[index];
271
+ }
272
+
273
+ return hydrate(0);
274
+ }