athar-mcp 0.1.0 → 0.2.0
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/dashboard/.output/nitro.json +15 -0
- package/dashboard/.output/public/_fonts/31PZhXd_YTCmsoiPQZc-xVtAWAkLogRFRj5mWplmKFE-6WsTw05QKugcwLySGc_b9CIheG8j8LRyo47qPL430Mk.woff2 +0 -0
- package/dashboard/.output/public/_fonts/3e3wuf-V_7icWvlsSS3Ud6R1mFSymwsfz35VcqiVjOk-jnii4_jMs7YAJOhzZP3bGdrbXGt5dYv8_t_rhpHzpcQ.woff2 +0 -0
- package/dashboard/.output/public/_fonts/3mk1pEYaO7RuhctnlpKcyb7yjVLICedncSfY13ffbM8-vJidvBvYJRk77_zQIyVpja44ymm1FQTiYKUcM_aD5Sg.woff2 +0 -0
- package/dashboard/.output/public/_fonts/9FWLUGCSCYLRIRMtCzLrt4Go7DMFXOeN_pyCOJD_44Y-Yh2wNaqrq_e759vVlc3tX81lMwRu9ktkQJX_Svgs-VI.woff2 +0 -0
- package/dashboard/.output/public/_fonts/9IZYb3o3tpRXPqjzNd4r3vIIohLuRBC5-h_ByvqRowU-ZgMUMfi6FcHpaV_ucYIWcBvLG6geajFq70Smps0DAj0.woff2 +0 -0
- package/dashboard/.output/public/_fonts/AA0_6TP-Ed9gQINhOsvbweBE3xLQgxmg6pXqHmvCwsM-egZLwYC5qVnfGWql7G5NfYTIiMP1PB_tQWIq5f7S-0k.woff2 +0 -0
- package/dashboard/.output/public/_fonts/BQnDL9FFy0Q_jvURlmv87luvmXLSMbSuXsfZv_R2Rkk-y5MVrLtP4J_1al8rz8R-MDaUOMAHckAWCwDrKhw25fY.woff2 +0 -0
- package/dashboard/.output/public/_fonts/Df7M9JXECnQBPeMk0JlWv5oI4E80OSjKvG82PCAX-MI-aXpKyr1n0W6NWbCApKANrm9O50H_fjFMdBzwfTY75iM.woff2 +0 -0
- package/dashboard/.output/public/_fonts/F00Bxq4ciZESODR5suhK3xDWcsQ9RLj9SyZQEevpEsw-BLNEvb6wAcL3fpb4n4d3zVEKUoa2hsUKxxkf3YdvJKc.woff2 +0 -0
- package/dashboard/.output/public/_fonts/HsvEuay0nMOs_2ObxMGaCaFlKdRnnDmfWeFTeRbjAVE-UeGuS_NHKiKleun7gcayWaUNaV2zWnEeGUxJVueLYm0.woff +0 -0
- package/dashboard/.output/public/_fonts/JSrPAbQHsQEdUrIE5Ts6fIQ2ymsa4i7HhiCpui6ulCc-_AoyGWssOn06OMh3ZY_GddBBPRny4Igxin4fT_1K6F4.woff2 +0 -0
- package/dashboard/.output/public/_fonts/Jtqhy44WKYEjGWTSusP5YJfJv7Wf74QqgkBOI9u_77s-Rl_Bht5SvmaotE20bkavBEAJEEGEa0hcz3d_8yOeXmw.woff +0 -0
- package/dashboard/.output/public/_fonts/KOrIgK47CByspZJWjOLg8AL2ADg9uFcNjZd9W78jrmM-dU37DP77KwUzMqqldljJHhSe3lJpaSfI9HPfiVAxPOM.woff2 +0 -0
- package/dashboard/.output/public/_fonts/M-60tFLmAJxdPjHsK-2ILWom5zPbu37lb3Qex2waL14-A9y4QcXALPi_RvQsmRsSFUxrT3_J213W4zPFIXetlbw.woff2 +0 -0
- package/dashboard/.output/public/_fonts/NwLHmPccLrJlBVGp4QRXOLZaNI0M_K6XuSwyVjpr47g-jl4tqz8gcsgAJDPcbl5roY78zy31I6Rq51WBLpZngFg.woff2 +0 -0
- package/dashboard/.output/public/_fonts/T-ozk-QJ_Ck37B2RHPl2i-s_gAGGo7suFgagWoJ8bO4-maDXQ_nEXKAaLHm4Joud3DJR9EVzS7QXWMWK8YOTIcs.woff2 +0 -0
- package/dashboard/.output/public/_fonts/TTYbISAfwy-y4uVGS9AH32sK7b2xJsoCESo64ryf8LU-y87nRMqBGo42rUOW9tWZa06o4oTa0USJrAMMoKDamgs.woff2 +0 -0
- package/dashboard/.output/public/_fonts/Y_5DOsLit49q2i2tbcNxnyUen9__GPCX8mwAi03q1aA-pBCjVKDT5tBT3BJckh9uzNkfUWeUIBPz9Y8T55vcj8E.woff2 +0 -0
- package/dashboard/.output/public/_fonts/ZHaz3DhCHNWhsElqYfuM71rfBBDgjuU2sd34vaYJwQg-71NZaZSGjxzAGjCMnCc2zS5rS_EGA0xHKPGCggWuXik.woff +0 -0
- package/dashboard/.output/public/_fonts/_lyVj3lEzRng_G7gZNcCmL83BnMEos-Hf8bpHLMzGQI-zsVE1T2QbmkXlEbQhs2gb3j3VBOOGhzqyW_ZW_0s3F8.woff2 +0 -0
- package/dashboard/.output/public/_fonts/bUcXp2ExGsFoCjH4L_AiPGX0TLCAgnqR8nvW7SxSJYQ-kvm9UWc_MFZW_r85yX6uPdzXVmdcUOio_Wb1x_7QdXM.woff2 +0 -0
- package/dashboard/.output/public/_fonts/f3COenLcoezM74LmVz7-HHQTyPKopVoMY6x2syLMzQE-shPZYE7IAjZWz4okT_CWn96WfGzoLhasK43_mhj3CZI.woff2 +0 -0
- package/dashboard/.output/public/_fonts/h9PwCjip_BNPVO50hT4v29USWFv6H3ZlYx_IestfqgY-sYfLVuZXl9E1aYbn1S0pAr4zfdQ_WT7iBZhrgQY6N-4.woff2 +0 -0
- package/dashboard/.output/public/_fonts/l00UCz_-QvI_NO8AGcu7ooAcrFDlxYUdxCSCh6gBwd4-vPjTZ3ztgw27A2TnHeCycxPvUtXWEVpG33_97ra6su8.woff2 +0 -0
- package/dashboard/.output/public/_fonts/nuenOq7ZFSZ65QudJO7uQ0sOjDqow2WjfXrQh4S9gEc-uF81rxcswER5srfhzyLfPoGlKNAIt2C_BvkXFOc19rw.woff2 +0 -0
- package/dashboard/.output/public/_fonts/pWMvGwciZ-EfQsfR2ueelhC7Jnt5K-8Px8PjPK0mDII-eT9iD0iZ9WWhTJs6V5GxXr0iaUwx_WxgGGriOiGb81o.woff2 +0 -0
- package/dashboard/.output/public/_fonts/sqxfSu-14RfawvZSbzb3mPoBYaXxmTGIac1Kk0GVk_w-oe_5KiWXPVdvpURHWSiaIjA1N_zLqpjSzmfpwRHr7CQ.woff2 +0 -0
- package/dashboard/.output/public/_fonts/wMdBqIWtsuS5eTYXRFwACf6n6oW2h-j42f90vWIPIO8-vrVOc_lrScYZMKO0_R3igKLheJfV2qZ3c5qlWOY0LDQ.woff +0 -0
- package/dashboard/.output/public/_fonts/y3mP_zJcojQwJn30TpF_XxDzgeM6Nbk7MaRg1Ne0YcI-lFx13nqMCMgk_S70gRmwEHXlE5BLp1B4W82RpFihpMs.woff2 +0 -0
- package/dashboard/.output/public/_fonts/zr3WxpLd5PmlBr7e4PWGkhZv6XTg70Pi4sCbC-CEV0Q-v2yL98XOiD3FkbiYlYYeAeTSVSkgAckeOp55Q5kHJmU.woff2 +0 -0
- package/dashboard/.output/public/_nuxt/B0Bu7wg2.js +1 -0
- package/dashboard/.output/public/_nuxt/BNBS3IWx.js +1 -0
- package/dashboard/.output/public/_nuxt/Ba3u15ft.js +1 -0
- package/dashboard/.output/public/_nuxt/CH7yjz82.js +4 -0
- package/dashboard/.output/public/_nuxt/COkkU9In.js +1 -0
- package/dashboard/.output/public/_nuxt/C_XEhq4z.js +1 -0
- package/dashboard/.output/public/_nuxt/YOlRD-cU.js +1 -0
- package/dashboard/.output/public/_nuxt/_id_.Dz86UAW3.css +1 -0
- package/dashboard/.output/public/_nuxt/builds/latest.json +1 -0
- package/dashboard/.output/public/_nuxt/builds/meta/a6e303b2-379a-45a9-8bdf-906e96134fda.json +1 -0
- package/dashboard/.output/public/_nuxt/entry.D51cHmax.css +1 -0
- package/dashboard/.output/public/_nuxt/error-404.C3kT2QX-.css +1 -0
- package/dashboard/.output/public/_nuxt/error-500.BW0Y54Of.css +1 -0
- package/dashboard/.output/public/_nuxt/fpe_5SoV.js +1 -0
- package/dashboard/.output/server/chunks/_/db.mjs +27 -0
- package/dashboard/.output/server/chunks/_/db.mjs.map +1 -0
- package/dashboard/.output/server/chunks/_/error-500.mjs +19 -0
- package/dashboard/.output/server/chunks/_/error-500.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/_id_-CQaF66RF.mjs +139 -0
- package/dashboard/.output/server/chunks/build/_id_-CQaF66RF.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/_id_-styles.DKwggH1p.mjs +8 -0
- package/dashboard/.output/server/chunks/build/_id_-styles.DKwggH1p.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/app-styles.nHRnXOH3.mjs +25 -0
- package/dashboard/.output/server/chunks/build/app-styles.nHRnXOH3.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/client.precomputed.mjs +4 -0
- package/dashboard/.output/server/chunks/build/client.precomputed.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/composables-lps5heb5.mjs +23 -0
- package/dashboard/.output/server/chunks/build/composables-lps5heb5.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/error-404-D0Xi6cQ6.mjs +92 -0
- package/dashboard/.output/server/chunks/build/error-404-D0Xi6cQ6.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/error-404-styles.C8lgdT6t.mjs +8 -0
- package/dashboard/.output/server/chunks/build/error-404-styles.C8lgdT6t.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/error-500-DabQpmqy.mjs +75 -0
- package/dashboard/.output/server/chunks/build/error-500-DabQpmqy.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/error-500-styles.Ccrcwcfa.mjs +8 -0
- package/dashboard/.output/server/chunks/build/error-500-styles.Ccrcwcfa.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/fetch-BlczD9wj.mjs +503 -0
- package/dashboard/.output/server/chunks/build/fetch-BlczD9wj.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/index-C-zhU_b9.mjs +174 -0
- package/dashboard/.output/server/chunks/build/index-C-zhU_b9.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/index-Dnk7jknb.mjs +154 -0
- package/dashboard/.output/server/chunks/build/index-Dnk7jknb.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/server.mjs +1552 -0
- package/dashboard/.output/server/chunks/build/server.mjs.map +1 -0
- package/dashboard/.output/server/chunks/build/styles.mjs +10 -0
- package/dashboard/.output/server/chunks/build/styles.mjs.map +1 -0
- package/dashboard/.output/server/chunks/nitro/nitro.mjs +5497 -0
- package/dashboard/.output/server/chunks/nitro/nitro.mjs.map +1 -0
- package/dashboard/.output/server/chunks/routes/api/lessons/_id_.get.mjs +35 -0
- package/dashboard/.output/server/chunks/routes/api/lessons/_id_.get.mjs.map +1 -0
- package/dashboard/.output/server/chunks/routes/api/lessons.get.mjs +64 -0
- package/dashboard/.output/server/chunks/routes/api/lessons.get.mjs.map +1 -0
- package/dashboard/.output/server/chunks/routes/api/stats.get.mjs +59 -0
- package/dashboard/.output/server/chunks/routes/api/stats.get.mjs.map +1 -0
- package/dashboard/.output/server/chunks/routes/renderer.mjs +458 -0
- package/dashboard/.output/server/chunks/routes/renderer.mjs.map +1 -0
- package/dashboard/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
- package/dashboard/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
- package/dashboard/.output/server/index.mjs +10 -0
- package/dashboard/.output/server/index.mjs.map +1 -0
- package/dashboard/.output/server/node_modules/@babel/parser/lib/index.js +14599 -0
- package/dashboard/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/dashboard/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6759 -0
- package/dashboard/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/dashboard/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
- package/dashboard/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/dashboard/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
- package/dashboard/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/api/api.js +2 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/api/app.js +2 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/api/component.js +2 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/api/context.js +2 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js +2 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/api/index.js +22 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/api/util.js +2 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/const.js +5 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/env.js +17 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/index.js +45 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/plugin.js +2 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/proxy.js +111 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/lib/cjs/time.js +28 -0
- package/dashboard/.output/server/node_modules/@vue/devtools-api/package.json +37 -0
- package/dashboard/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1899 -0
- package/dashboard/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/dashboard/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6940 -0
- package/dashboard/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/dashboard/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1822 -0
- package/dashboard/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/dashboard/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +896 -0
- package/dashboard/.output/server/node_modules/@vue/server-renderer/package.json +55 -0
- package/dashboard/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +604 -0
- package/dashboard/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/dashboard/.output/server/node_modules/devalue/index.js +4 -0
- package/dashboard/.output/server/node_modules/devalue/package.json +40 -0
- package/dashboard/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/dashboard/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/dashboard/.output/server/node_modules/devalue/src/parse.js +283 -0
- package/dashboard/.output/server/node_modules/devalue/src/stringify.js +401 -0
- package/dashboard/.output/server/node_modules/devalue/src/uneval.js +552 -0
- package/dashboard/.output/server/node_modules/devalue/src/utils.js +160 -0
- package/dashboard/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/dashboard/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/dashboard/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/dashboard/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/dashboard/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/dashboard/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/dashboard/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/dashboard/.output/server/node_modules/entities/package.json +120 -0
- package/dashboard/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/dashboard/.output/server/node_modules/estree-walker/package.json +37 -0
- package/dashboard/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/dashboard/.output/server/node_modules/hookable/package.json +53 -0
- package/dashboard/.output/server/node_modules/perfect-debounce/dist/index.mjs +89 -0
- package/dashboard/.output/server/node_modules/perfect-debounce/package.json +41 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/dashboard/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/dashboard/.output/server/node_modules/source-map-js/package.json +71 -0
- package/dashboard/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/dashboard/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/dashboard/.output/server/node_modules/ufo/package.json +48 -0
- package/dashboard/.output/server/node_modules/unhead/dist/index.mjs +9 -0
- package/dashboard/.output/server/node_modules/unhead/dist/parser.mjs +508 -0
- package/dashboard/.output/server/node_modules/unhead/dist/plugins.mjs +101 -0
- package/dashboard/.output/server/node_modules/unhead/dist/scripts.mjs +30 -0
- package/dashboard/.output/server/node_modules/unhead/dist/server.mjs +180 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.B3VbJo7Y.mjs +207 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.BnoAbrHA.mjs +269 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.CaI5ZD4O.mjs +182 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs +71 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.Dh1cQCTe.mjs +44 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.TxTMM7cM.mjs +166 -0
- package/dashboard/.output/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/dashboard/.output/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/dashboard/.output/server/node_modules/unhead/package.json +105 -0
- package/dashboard/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/dashboard/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/dashboard/.output/server/node_modules/vue/index.js +7 -0
- package/dashboard/.output/server/node_modules/vue/index.mjs +1 -0
- package/dashboard/.output/server/node_modules/vue/package.json +112 -0
- package/dashboard/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/dashboard/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +249 -0
- package/dashboard/.output/server/node_modules/vue-bundle-renderer/package.json +57 -0
- package/dashboard/.output/server/node_modules/vue-router/dist/devtools-EWN81iOl.mjs +1220 -0
- package/dashboard/.output/server/node_modules/vue-router/dist/vue-router.mjs +1557 -0
- package/dashboard/.output/server/node_modules/vue-router/package.json +153 -0
- package/dashboard/.output/server/node_modules/vue-router/vue-router.node.mjs +2 -0
- package/dashboard/.output/server/package.json +29 -0
- package/dist/cli/commands/dashboard.d.ts +2 -0
- package/dist/cli/commands/dashboard.d.ts.map +1 -0
- package/dist/cli/commands/dashboard.js +30 -0
- package/dist/cli/commands/dashboard.js.map +1 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DevalueError,
|
|
3
|
+
enumerable_symbols,
|
|
4
|
+
get_type,
|
|
5
|
+
is_plain_object,
|
|
6
|
+
is_primitive,
|
|
7
|
+
stringify_key,
|
|
8
|
+
stringify_string,
|
|
9
|
+
valid_array_indices
|
|
10
|
+
} from './utils.js';
|
|
11
|
+
import {
|
|
12
|
+
HOLE,
|
|
13
|
+
NAN,
|
|
14
|
+
NEGATIVE_INFINITY,
|
|
15
|
+
NEGATIVE_ZERO,
|
|
16
|
+
POSITIVE_INFINITY,
|
|
17
|
+
SPARSE,
|
|
18
|
+
UNDEFINED
|
|
19
|
+
} from './constants.js';
|
|
20
|
+
import { encode64 } from './base64.js';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Turn a value into a JSON string that can be parsed with `devalue.parse`
|
|
24
|
+
* @param {any} value
|
|
25
|
+
* @param {Record<string, (value: any) => any>} [reducers]
|
|
26
|
+
*/
|
|
27
|
+
export function stringify(value, reducers) {
|
|
28
|
+
const stringified = run(false, value, reducers);
|
|
29
|
+
return typeof stringified === 'string' ? stringified : `[${stringified.join(',')}]`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Turn a value into a JSON string that can be parsed with `devalue.parse`
|
|
34
|
+
* @param {any} value
|
|
35
|
+
* @param {Record<string, (value: any) => any>} [reducers]
|
|
36
|
+
*/
|
|
37
|
+
export async function stringifyAsync(value, reducers) {
|
|
38
|
+
const stringified = run(true, value, reducers);
|
|
39
|
+
|
|
40
|
+
if (typeof stringified === 'string') {
|
|
41
|
+
return stringified;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let out = '[';
|
|
45
|
+
|
|
46
|
+
for (let i = 0; i < stringified.length; i += 1) {
|
|
47
|
+
let value = stringified[i];
|
|
48
|
+
|
|
49
|
+
if (typeof value !== 'string') {
|
|
50
|
+
await value;
|
|
51
|
+
value = stringified[i];
|
|
52
|
+
|
|
53
|
+
if (i === 0 && value < 0) {
|
|
54
|
+
return `${value}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
out += value;
|
|
59
|
+
|
|
60
|
+
if (i < stringified.length - 1) {
|
|
61
|
+
out += ',';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
out += ']';
|
|
66
|
+
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @param {boolean} async
|
|
72
|
+
* @param {any} value
|
|
73
|
+
* @param {Record<string, (value: any) => any>} [reducers]
|
|
74
|
+
*/
|
|
75
|
+
function run(async, value, reducers) {
|
|
76
|
+
/** @type {any[]} */
|
|
77
|
+
const stringified = [];
|
|
78
|
+
|
|
79
|
+
/** @type {Map<any, number>} */
|
|
80
|
+
const indexes = new Map();
|
|
81
|
+
|
|
82
|
+
/** @type {Array<{ key: string, fn: (value: any) => any }>} */
|
|
83
|
+
const custom = [];
|
|
84
|
+
if (reducers) {
|
|
85
|
+
for (const key of Object.getOwnPropertyNames(reducers)) {
|
|
86
|
+
custom.push({ key, fn: reducers[key] });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @type {string[]} */
|
|
91
|
+
const keys = [];
|
|
92
|
+
|
|
93
|
+
let p = 0;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param {any} thing
|
|
97
|
+
* @param {number} [index]
|
|
98
|
+
*/
|
|
99
|
+
function flatten(thing, index) {
|
|
100
|
+
if (thing === undefined) return UNDEFINED;
|
|
101
|
+
if (Number.isNaN(thing)) return NAN;
|
|
102
|
+
if (thing === Infinity) return POSITIVE_INFINITY;
|
|
103
|
+
if (thing === -Infinity) return NEGATIVE_INFINITY;
|
|
104
|
+
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
|
|
105
|
+
|
|
106
|
+
if (indexes.has(thing)) return /** @type {number} */ (indexes.get(thing));
|
|
107
|
+
|
|
108
|
+
index ??= p++;
|
|
109
|
+
indexes.set(thing, index);
|
|
110
|
+
|
|
111
|
+
for (const { key, fn } of custom) {
|
|
112
|
+
const value = fn(thing);
|
|
113
|
+
if (value) {
|
|
114
|
+
stringified[index] = `["${key}",${flatten(value)}]`;
|
|
115
|
+
return index;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (typeof thing === 'function') {
|
|
120
|
+
throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
|
|
121
|
+
} else if (typeof thing === 'symbol') {
|
|
122
|
+
throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** @type {string | Promise<any>} */
|
|
126
|
+
let str = '';
|
|
127
|
+
|
|
128
|
+
if (is_primitive(thing)) {
|
|
129
|
+
str = stringify_primitive(thing);
|
|
130
|
+
} else if (typeof thing.then === 'function') {
|
|
131
|
+
if (!async) {
|
|
132
|
+
throw new DevalueError(
|
|
133
|
+
`Cannot stringify a Promise or thenable — use stringifyAsync instead`,
|
|
134
|
+
keys,
|
|
135
|
+
thing,
|
|
136
|
+
value
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
str = Promise.resolve(thing).then((value) => {
|
|
141
|
+
const i = flatten(value, index);
|
|
142
|
+
if (i < 0) stringified[index] = i;
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
const type = get_type(thing);
|
|
146
|
+
|
|
147
|
+
switch (type) {
|
|
148
|
+
case 'Number':
|
|
149
|
+
case 'String':
|
|
150
|
+
case 'Boolean':
|
|
151
|
+
case 'BigInt':
|
|
152
|
+
str = `["Object",${flatten(thing.valueOf())}]`;
|
|
153
|
+
break;
|
|
154
|
+
|
|
155
|
+
case 'Date':
|
|
156
|
+
const valid = !isNaN(thing.getDate());
|
|
157
|
+
str = `["Date","${valid ? thing.toISOString() : ''}"]`;
|
|
158
|
+
break;
|
|
159
|
+
|
|
160
|
+
case 'URL':
|
|
161
|
+
str = `["URL",${stringify_string(thing.toString())}]`;
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
case 'URLSearchParams':
|
|
165
|
+
str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
|
|
166
|
+
break;
|
|
167
|
+
|
|
168
|
+
case 'RegExp':
|
|
169
|
+
const { source, flags } = thing;
|
|
170
|
+
str = flags
|
|
171
|
+
? `["RegExp",${stringify_string(source)},"${flags}"]`
|
|
172
|
+
: `["RegExp",${stringify_string(source)}]`;
|
|
173
|
+
break;
|
|
174
|
+
|
|
175
|
+
case 'Array': {
|
|
176
|
+
// For dense arrays (no holes), we iterate normally.
|
|
177
|
+
// When we encounter the first hole, we call Object.keys
|
|
178
|
+
// to determine the sparseness, then decide between:
|
|
179
|
+
// - HOLE encoding: [-2, val, -2, ...] (default)
|
|
180
|
+
// - Sparse encoding: [-7, length, idx, val, ...] (for very sparse arrays)
|
|
181
|
+
// Only the sparse path avoids iterating every slot, which
|
|
182
|
+
// is what protects against the DoS of e.g. `arr[1000000] = 1`.
|
|
183
|
+
let mostly_dense = false;
|
|
184
|
+
|
|
185
|
+
str = '[';
|
|
186
|
+
|
|
187
|
+
for (let i = 0; i < thing.length; i += 1) {
|
|
188
|
+
if (i > 0) str += ',';
|
|
189
|
+
|
|
190
|
+
if (Object.hasOwn(thing, i)) {
|
|
191
|
+
keys.push(`[${i}]`);
|
|
192
|
+
str += flatten(thing[i]);
|
|
193
|
+
keys.pop();
|
|
194
|
+
} else if (mostly_dense) {
|
|
195
|
+
// Use dense encoding. The heuristic guarantees the
|
|
196
|
+
// array is only mildly sparse, so iterating over every
|
|
197
|
+
// slot is fine.
|
|
198
|
+
str += HOLE;
|
|
199
|
+
} else {
|
|
200
|
+
// Decide between HOLE encoding and sparse encoding.
|
|
201
|
+
//
|
|
202
|
+
// HOLE encoding: each hole is serialized as the HOLE
|
|
203
|
+
// sentinel (-2). For example, [, "a", ,] becomes
|
|
204
|
+
// [-2, 0, -2]. Each hole costs 3 chars ("-2" + comma).
|
|
205
|
+
//
|
|
206
|
+
// Sparse encoding: lists only populated indices.
|
|
207
|
+
// For example, [, "a", ,] becomes [-7, 3, 1, 0] — the
|
|
208
|
+
// -7 sentinel, the array length (3), then index-value
|
|
209
|
+
// pairs. This avoids paying per-hole, but each element
|
|
210
|
+
// costs extra chars to write its index.
|
|
211
|
+
//
|
|
212
|
+
// The values are the same size either way, so the
|
|
213
|
+
// choice comes down to structural overhead:
|
|
214
|
+
//
|
|
215
|
+
// HOLE overhead:
|
|
216
|
+
// 3 chars per hole ("-2" + comma)
|
|
217
|
+
// = (L - P) * 3
|
|
218
|
+
//
|
|
219
|
+
// Sparse overhead:
|
|
220
|
+
// "-7," — 3 chars (sparse sentinel + comma)
|
|
221
|
+
// + length + "," — (d + 1) chars (array length + comma)
|
|
222
|
+
// + per element: index + "," — (d + 1) chars
|
|
223
|
+
// = (4 + d) + P * (d + 1)
|
|
224
|
+
//
|
|
225
|
+
// where L is the array length, P is the number of
|
|
226
|
+
// populated elements, and d is the number of digits
|
|
227
|
+
// in L (an upper bound on the digits in any index).
|
|
228
|
+
//
|
|
229
|
+
// Sparse encoding is cheaper when:
|
|
230
|
+
// (4 + d) + P * (d + 1) < (L - P) * 3
|
|
231
|
+
const populated_keys = valid_array_indices(/** @type {any[]} */ (thing));
|
|
232
|
+
const population = populated_keys.length;
|
|
233
|
+
const d = String(thing.length).length;
|
|
234
|
+
|
|
235
|
+
const hole_cost = (thing.length - population) * 3;
|
|
236
|
+
const sparse_cost = 4 + d + population * (d + 1);
|
|
237
|
+
|
|
238
|
+
if (hole_cost > sparse_cost) {
|
|
239
|
+
str = '[' + SPARSE + ',' + thing.length;
|
|
240
|
+
for (let j = 0; j < populated_keys.length; j++) {
|
|
241
|
+
const key = populated_keys[j];
|
|
242
|
+
keys.push(`[${key}]`);
|
|
243
|
+
str += ',' + key + ',' + flatten(thing[key]);
|
|
244
|
+
keys.pop();
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
} else {
|
|
248
|
+
mostly_dense = true;
|
|
249
|
+
str += HOLE;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
str += ']';
|
|
255
|
+
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
case 'Set':
|
|
260
|
+
str = '["Set"';
|
|
261
|
+
|
|
262
|
+
for (const value of thing) {
|
|
263
|
+
str += `,${flatten(value)}`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
str += ']';
|
|
267
|
+
break;
|
|
268
|
+
|
|
269
|
+
case 'Map':
|
|
270
|
+
str = '["Map"';
|
|
271
|
+
|
|
272
|
+
for (const [key, value] of thing) {
|
|
273
|
+
keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`);
|
|
274
|
+
str += `,${flatten(key)},${flatten(value)}`;
|
|
275
|
+
keys.pop();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
str += ']';
|
|
279
|
+
break;
|
|
280
|
+
|
|
281
|
+
case 'Int8Array':
|
|
282
|
+
case 'Uint8Array':
|
|
283
|
+
case 'Uint8ClampedArray':
|
|
284
|
+
case 'Int16Array':
|
|
285
|
+
case 'Uint16Array':
|
|
286
|
+
case 'Float16Array':
|
|
287
|
+
case 'Int32Array':
|
|
288
|
+
case 'Uint32Array':
|
|
289
|
+
case 'Float32Array':
|
|
290
|
+
case 'Float64Array':
|
|
291
|
+
case 'BigInt64Array':
|
|
292
|
+
case 'BigUint64Array':
|
|
293
|
+
case 'DataView': {
|
|
294
|
+
/** @type {import("./types.js").TypedArray} */
|
|
295
|
+
const typedArray = thing;
|
|
296
|
+
str = '["' + type + '",' + flatten(typedArray.buffer);
|
|
297
|
+
|
|
298
|
+
// handle subarrays
|
|
299
|
+
if (typedArray.byteLength !== typedArray.buffer.byteLength) {
|
|
300
|
+
// to be used with `new TypedArray(buffer, byteOffset, length)`
|
|
301
|
+
str += `,${typedArray.byteOffset},${typedArray.length}`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
str += ']';
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
case 'ArrayBuffer': {
|
|
309
|
+
/** @type {ArrayBuffer} */
|
|
310
|
+
const arraybuffer = thing;
|
|
311
|
+
const base64 = encode64(arraybuffer);
|
|
312
|
+
|
|
313
|
+
str = `["ArrayBuffer","${base64}"]`;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
case 'Temporal.Duration':
|
|
318
|
+
case 'Temporal.Instant':
|
|
319
|
+
case 'Temporal.PlainDate':
|
|
320
|
+
case 'Temporal.PlainTime':
|
|
321
|
+
case 'Temporal.PlainDateTime':
|
|
322
|
+
case 'Temporal.PlainMonthDay':
|
|
323
|
+
case 'Temporal.PlainYearMonth':
|
|
324
|
+
case 'Temporal.ZonedDateTime':
|
|
325
|
+
str = `["${type}",${stringify_string(thing.toString())}]`;
|
|
326
|
+
break;
|
|
327
|
+
|
|
328
|
+
default:
|
|
329
|
+
if (!is_plain_object(thing)) {
|
|
330
|
+
throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (enumerable_symbols(thing).length > 0) {
|
|
334
|
+
throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (Object.getPrototypeOf(thing) === null) {
|
|
338
|
+
str = '["null"';
|
|
339
|
+
for (const key of Object.keys(thing)) {
|
|
340
|
+
if (key === '__proto__') {
|
|
341
|
+
throw new DevalueError(
|
|
342
|
+
`Cannot stringify objects with __proto__ keys`,
|
|
343
|
+
keys,
|
|
344
|
+
thing,
|
|
345
|
+
value
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
keys.push(stringify_key(key));
|
|
350
|
+
str += `,${stringify_string(key)},${flatten(thing[key])}`;
|
|
351
|
+
keys.pop();
|
|
352
|
+
}
|
|
353
|
+
str += ']';
|
|
354
|
+
} else {
|
|
355
|
+
str = '{';
|
|
356
|
+
let started = false;
|
|
357
|
+
for (const key of Object.keys(thing)) {
|
|
358
|
+
if (key === '__proto__') {
|
|
359
|
+
throw new DevalueError(
|
|
360
|
+
`Cannot stringify objects with __proto__ keys`,
|
|
361
|
+
keys,
|
|
362
|
+
thing,
|
|
363
|
+
value
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (started) str += ',';
|
|
368
|
+
started = true;
|
|
369
|
+
keys.push(stringify_key(key));
|
|
370
|
+
str += `${stringify_string(key)}:${flatten(thing[key])}`;
|
|
371
|
+
keys.pop();
|
|
372
|
+
}
|
|
373
|
+
str += '}';
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
stringified[index] = str;
|
|
379
|
+
return index;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const index = flatten(value);
|
|
383
|
+
|
|
384
|
+
// special case — value is represented as a negative index
|
|
385
|
+
if (index < 0) return `${index}`;
|
|
386
|
+
|
|
387
|
+
return stringified;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @param {any} thing
|
|
392
|
+
* @returns {string}
|
|
393
|
+
*/
|
|
394
|
+
function stringify_primitive(thing) {
|
|
395
|
+
const type = typeof thing;
|
|
396
|
+
if (type === 'string') return stringify_string(thing);
|
|
397
|
+
if (thing === void 0) return UNDEFINED.toString();
|
|
398
|
+
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
|
|
399
|
+
if (type === 'bigint') return `["BigInt","${thing}"]`;
|
|
400
|
+
return String(thing);
|
|
401
|
+
}
|