void 0.10.12 → 0.20.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/AGENTS_TEMPLATE.md +6 -0
- package/{skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md → LICENSE} +1 -1
- package/README.md +34 -8
- package/dist/{auth-qgMlYp7Z.d.mts → auth-DkcFflXV.d.mts} +10 -11
- package/dist/auth-W9WII-mN.mjs +630 -0
- package/dist/{auth-cmd-BqsdZJp5.mjs → auth-cmd-CYVhSNFy.mjs} +4 -3
- package/dist/{auth-migrations-BTZ-ATvQ.mjs → auth-migrations-9vif1uj8.mjs} +53 -12
- package/dist/{better-auth-shared-BQooDxbw.mjs → better-auth-shared-CYw1T3k4.mjs} +7 -10
- package/dist/{better-auth-shared-DealXecJ.d.mts → better-auth-shared-DSCeohOK.d.mts} +10 -5
- package/dist/{build-cmd-Bujrv5q-.mjs → build-cmd-CkVD1uOh.mjs} +6 -4
- package/dist/{cache-C11V8Fxq.mjs → cache-QcUfR-ff.mjs} +9 -5
- package/dist/{cancel-deploy-fwFYF04b.mjs → cancel-deploy-DsvWKFTe.mjs} +3 -2
- package/dist/cf-access-AJ1ehiFR.mjs +42 -0
- package/dist/cf-access-DsSsZUPr.mjs +67 -0
- package/dist/cli/cli.d.mts +1 -1
- package/dist/cli/cli.mjs +1592 -153
- package/dist/cli/env-schema-probe.d.mts +48 -61
- package/dist/cli/env-schema-probe.mjs +10 -58
- package/dist/{client-Gb71-XkG.mjs → client-CyCHWSO_.mjs} +61 -463
- package/dist/cloudflare-auth-DRkGe7-s.mjs +170 -0
- package/dist/cloudflare-cmd-D3ME2GAe.mjs +62 -0
- package/dist/cloudflare-connect-BivMefMA.mjs +56 -0
- package/dist/cloudflare-operations-CPTpRW6d.mjs +566 -0
- package/dist/{config-BkTvs43g.mjs → config-BQFq7QvD.mjs} +85 -41
- package/dist/{config-CutEMNGJ.mjs → config-NOG_U1aK.mjs} +10 -15
- package/dist/connect-D9Yr-T5f.mjs +79 -0
- package/dist/{create-project-DsYvl3TB.mjs → create-project-DMV-csEm.mjs} +26 -16
- package/dist/database-provider.d.mts +21 -0
- package/dist/database-provider.mjs +6 -0
- package/dist/{db-DOiJMRt2.mjs → db-BxoUWL0F.mjs} +600 -115
- package/dist/{delete-mh6p-zkQ.mjs → delete-iJOqxBz1.mjs} +9 -6
- package/dist/{deploy-u7Rv9q_q.mjs → deploy-CcDoeBIf.mjs} +3451 -1986
- package/dist/dev-inbox-DkgRWLkW.mjs +307 -0
- package/dist/{discover-CJHyvYfR.mjs → discover-xvfrgJeo.mjs} +3 -3
- package/dist/{magic-string.es-ZQjdJFFn.mjs → dist-BR1quN_w.mjs} +570 -216
- package/dist/{dist-DaKKDf8D.mjs → dist-BrsS7cai.mjs} +17 -2
- package/dist/{dist-BuiRJkTd.mjs → dist-m40_XgNh.mjs} +48 -33
- package/dist/{domain-DiaNQbrl.mjs → domain-gu_iaHmn.mjs} +41 -4
- package/dist/dotenv-VQxupEUv.mjs +181 -0
- package/dist/edge.d.mts +2 -0
- package/dist/edge.mjs +2 -0
- package/dist/email-Ce6SQq-i.mjs +182 -0
- package/dist/email-r6DHJyAB.mjs +262 -0
- package/dist/{entry-D7yy4xVH.mjs → entry-DU3oDoQ3.mjs} +2 -2
- package/dist/env-D4Emu-M_.mjs +95 -0
- package/dist/env-DmU2To0C.mjs +73 -0
- package/dist/env-helpers-CyKtOBpj.d.mts +22 -0
- package/dist/env-public-D_6u46fX.d.mts +135 -0
- package/dist/{env-types-QBj-ndax.mjs → env-types-BNPhro-M.mjs} +2 -2
- package/dist/{env-validation-Dea3v3ej.mjs → env-validation-ENpMy6Ez.mjs} +68 -122
- package/dist/{gen-o_w-8yI8.mjs → gen-BKw6qHIg.mjs} +70 -15
- package/dist/{github-cmd-DKcGUNsj.mjs → github-cmd-DJS5Ab-H.mjs} +39 -31
- package/dist/{handler-Cjh8uM3Y.d.mts → handler-D1hLsObx.d.mts} +124 -122
- package/dist/{head-nmvOgFjd.d.mts → head-Do8P4puT.d.mts} +9 -8
- package/dist/{headers-nsHIFixA.mjs → headers-D8QfRX9Y.mjs} +12 -10
- package/dist/inbound-BJ70in1n.d.mts +354 -0
- package/dist/inbound-CNKxb3FY.mjs +694 -0
- package/dist/index.d.mts +61 -34
- package/dist/index.mjs +1048 -321
- package/dist/{init-3rgHKBVi.mjs → init-Dx5cgKqK.mjs} +329 -271
- package/dist/link-D_rm5sRH.mjs +52 -0
- package/dist/{list-CPwFDZ_c.mjs → list-M8XShti7.mjs} +37 -5
- package/dist/{runner-kapo9aPs.mjs → local-d1-BE8KBbMy.mjs} +116 -6
- package/dist/{login-BT3H8PN3.mjs → login-C8-UuLnp.mjs} +17 -15
- package/dist/{logs-Bt313ax7.mjs → logs-DwFU7dMW.mjs} +16 -2
- package/dist/mime-BJD7d_qL.mjs +1216 -0
- package/dist/neon-DHwd2zvC.mjs +54 -0
- package/dist/{node-Da0UcsGA.mjs → node-BkaXcpAc.mjs} +29 -8
- package/dist/operator-cmd-DYWRbWUA.mjs +348 -0
- package/dist/{agents-CtgBYqld.mjs → output-tFQLLj26.mjs} +676 -211
- package/dist/{package-json-Cx1osYo6.mjs → package-json-CPoWX79C.mjs} +1 -1
- package/dist/pages/client.d.mts +43 -41
- package/dist/pages/client.mjs +40 -33
- package/dist/pages/head-client.d.mts +10 -12
- package/dist/pages/head.d.mts +1 -1
- package/dist/pages/index.d.mts +37 -14
- package/dist/pages/index.mjs +5 -5
- package/dist/pages/islands-plugin.d.mts +25 -27
- package/dist/pages/islands-plugin.mjs +6 -4
- package/dist/pages/prefetch.d.mts +6 -7
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +2 -1
- package/dist/pages/serialize.d.mts +7 -8
- package/dist/platform-cmd-BEOVv1PN.mjs +123 -0
- package/dist/platform-domain-BszUfiS8.mjs +228 -0
- package/dist/platform-lifecycle-CjSr6xf0.mjs +4450 -0
- package/dist/platform-management-W30iCaTL.mjs +698 -0
- package/dist/platform-recovery-pHHv4ZSg.mjs +99 -0
- package/dist/{plugin-inference-DMeavIJ6.mjs → plugin-inference-BDRfZngg.mjs} +35 -19
- package/dist/prepare-BfJvFUtJ.mjs +14 -0
- package/dist/{prepare-BoKHgMNx.mjs → prepare-CBetXvsN.mjs} +15 -24
- package/dist/{preset-BjyR3lzz.mjs → preset-lAy0B0BQ.mjs} +25 -212
- package/dist/{project-cmd-D_w-4w5B.mjs → project-cmd-DCpk1cDt.mjs} +25 -12
- package/dist/{project-paths-BQd7OmIo.mjs → project-paths-SK8nMHPp.mjs} +3 -1
- package/dist/{project-tsconfig-B-QtXjLQ.mjs → project-tsconfig-Ql2XsSQp.mjs} +2 -2
- package/dist/{protocol-Bnb0LFp3.d.mts → protocol-C-pqYJjE.d.mts} +3 -4
- package/dist/{provision-rShh6MKY.mjs → provision-Blnstcm2.mjs} +78 -45
- package/dist/r2-conditions-D1Wk8i7b.mjs +30 -0
- package/dist/{requests-B8sZxaFM.mjs → requests-Dn8Vheh1.mjs} +5 -3
- package/dist/{resolve-project-BBMtLLV9.mjs → resolve-project--Vxawf7z.mjs} +2 -2
- package/dist/rollback-CtlPXEBi.mjs +166 -0
- package/dist/{rolldown-runtime-DJK8HYOj.mjs → rolldown-runtime-rQ84J-ij.mjs} +1 -1
- package/dist/{route-types-COI2DsZv.mjs → route-types-Da-DpyUp.mjs} +85 -26
- package/dist/routes-stub.d.mts +22 -23
- package/dist/runner-mysql-CgRFl3s6.mjs +61 -0
- package/dist/{runner-pg-CHM76xuC.mjs → runner-pg-DCkWPsWS.mjs} +18 -6
- package/dist/runtime/ai.d.mts +21 -14
- package/dist/runtime/ai.mjs +5 -4
- package/dist/runtime/auth-client-react.d.mts +3 -5
- package/dist/runtime/auth-client-solid.d.mts +3 -5
- package/dist/runtime/auth-client-svelte.d.mts +3 -5
- package/dist/runtime/auth-client-vue.d.mts +3 -5
- package/dist/runtime/auth-client.d.mts +3 -5
- package/dist/runtime/auth.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.d.mts +10 -0
- package/dist/runtime/better-auth-mysql.mjs +49 -0
- package/dist/runtime/better-auth-pg.d.mts +8 -9
- package/dist/runtime/better-auth-pg.mjs +2 -2
- package/dist/runtime/better-auth.d.mts +8 -9
- package/dist/runtime/better-auth.mjs +2 -2
- package/dist/runtime/client-react.d.mts +1 -1
- package/dist/runtime/client-solid.d.mts +1 -1
- package/dist/runtime/client-svelte.d.mts +1 -1
- package/dist/runtime/client-vue.d.mts +1 -1
- package/dist/runtime/client.d.mts +1 -1
- package/dist/runtime/db-mysql.d.mts +2 -0
- package/dist/runtime/db-mysql.mjs +1 -0
- package/dist/runtime/db.d.mts +10 -11
- package/dist/runtime/durable.d.mts +47 -0
- package/dist/runtime/durable.mjs +146 -0
- package/dist/runtime/email/testing.d.mts +112 -0
- package/dist/runtime/email/testing.mjs +283 -0
- package/dist/runtime/email.d.mts +30 -0
- package/dist/runtime/email.mjs +573 -0
- package/dist/runtime/env-helpers.d.mts +2 -2
- package/dist/runtime/env-helpers.mjs +5 -42
- package/dist/runtime/env-public-client.d.mts +10 -11
- package/dist/runtime/env-public-client.mjs +1 -1
- package/dist/runtime/env-public.d.mts +2 -2
- package/dist/runtime/env-public.mjs +104 -49
- package/dist/runtime/env.d.mts +19 -18
- package/dist/runtime/env.mjs +15 -2
- package/dist/runtime/fetch-stream.d.mts +20 -21
- package/dist/runtime/fetch.d.mts +15 -16
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/isr.d.mts +21 -22
- package/dist/runtime/isr.mjs +26 -8
- package/dist/runtime/kv.d.mts +9 -10
- package/dist/runtime/live-client.d.mts +5 -7
- package/dist/runtime/live-client.mjs +9 -7
- package/dist/runtime/live-server.d.mts +4 -5
- package/dist/runtime/live.d.mts +22 -24
- package/dist/runtime/live.mjs +1 -1
- package/dist/runtime/log.d.mts +16 -17
- package/dist/runtime/migration-handler-mysql.d.mts +4 -0
- package/dist/runtime/migration-handler-mysql.mjs +81 -0
- package/dist/runtime/migration-handler-pg.d.mts +2 -4
- package/dist/runtime/migration-handler.d.mts +5 -6
- package/dist/runtime/migration-handler.mjs +4 -3
- package/dist/runtime/queues.d.mts +3 -4
- package/dist/runtime/queues.mjs +2 -1
- package/dist/runtime/remote/binding-handler.d.mts +10 -12
- package/dist/runtime/remote/binding-handler.mjs +24 -3
- package/dist/runtime/remote/index.d.mts +5 -6
- package/dist/runtime/remote/index.mjs +21 -18
- package/dist/runtime/response.d.mts +10 -11
- package/dist/runtime/sandbox.d.mts +56 -55
- package/dist/runtime/sandbox.mjs +57 -49
- package/dist/runtime/schema-mysql.d.mts +1 -0
- package/dist/runtime/schema-mysql.mjs +2 -0
- package/dist/runtime/seed.d.mts +14 -9
- package/dist/runtime/sse-client.d.mts +6 -7
- package/dist/runtime/sse.d.mts +11 -12
- package/dist/runtime/storage.d.mts +3 -4
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +12 -12
- package/dist/runtime/ws-server.mjs +32 -4
- package/dist/runtime/ws.d.mts +19 -21
- package/dist/{scan-DYXkrasO.mjs → scan-BMH4rzlv.mjs} +53 -31
- package/dist/{scan-DEwlM_Xy.mjs → scan-CpK-57ug.mjs} +9 -5
- package/dist/{secret-Dt32J6RI.mjs → secret-BqTxGqki.mjs} +62 -5
- package/dist/{skills-CLjN0uUO.mjs → skills-Q46GZMO-.mjs} +6 -4
- package/dist/{standard-schema-DJ0HW7QP.d.mts → standard-schema-Fo_vCAZh.d.mts} +6 -6
- package/dist/{subcommand-prompt-BzV8iQZo.mjs → subcommand-prompt-WfySCQ7S.mjs} +67 -48
- package/dist/sveltekit.d.mts +12 -11
- package/dist/sveltekit.mjs +1 -1
- package/dist/types-BAp5AEBU.d.mts +79 -0
- package/dist/types-CKWnYgfy.d.mts +1 -0
- package/dist/{validate-Cw_RLeTj.mjs → validate-Bihr8WBi.mjs} +3 -3
- package/dist/wrangler--imS8n0d.mjs +1796 -0
- package/dist/{yarn-pnp-DJn3SAHF.mjs → yarn-pnp-DxSInkzL.mjs} +1 -1
- package/package.json +79 -65
- package/schema.json +35 -3
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +1 -1
- package/skills/void/SKILL.md +59 -2
- package/skills/void/docs/guide/ai.md +32 -14
- package/skills/void/docs/guide/app-types.md +6 -6
- package/skills/void/docs/guide/auth.md +14 -16
- package/skills/void/docs/guide/database/d1.md +6 -0
- package/skills/void/docs/guide/database/mysql.md +60 -0
- package/skills/void/docs/guide/database/postgresql.md +14 -9
- package/skills/void/docs/guide/database.md +39 -26
- package/skills/void/docs/guide/deployment.md +163 -22
- package/skills/void/docs/guide/durable-state.md +140 -0
- package/skills/void/docs/guide/edge/headers.md +5 -5
- package/skills/void/docs/guide/edge/prerendering.md +2 -0
- package/skills/void/docs/guide/edge/revalidation.md +21 -6
- package/skills/void/docs/guide/edge/rewrites.md +18 -14
- package/skills/void/docs/guide/edge/static-assets.md +23 -8
- package/skills/void/docs/guide/email.md +609 -0
- package/skills/void/docs/guide/env-migration.md +109 -0
- package/skills/void/docs/guide/env-vars.md +70 -248
- package/skills/void/docs/guide/index.md +15 -17
- package/skills/void/docs/guide/jobs.md +8 -5
- package/skills/void/docs/guide/live.md +7 -15
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +8 -4
- package/skills/void/docs/guide/pages-routing/islands.md +3 -3
- package/skills/void/docs/guide/pages-routing/loaders.md +6 -4
- package/skills/void/docs/guide/pages-routing/overview.md +7 -7
- package/skills/void/docs/guide/platform-administration.md +212 -0
- package/skills/void/docs/guide/platform-development.md +235 -0
- package/skills/void/docs/guide/queues.md +10 -10
- package/skills/void/docs/guide/quickstart.md +46 -67
- package/skills/void/docs/guide/remote-dev.md +8 -6
- package/skills/void/docs/guide/sandboxes.md +33 -16
- package/skills/void/docs/guide/self-hosted-platform.md +553 -0
- package/skills/void/docs/guide/server-routing.md +25 -5
- package/skills/void/docs/guide/sse.md +4 -4
- package/skills/void/docs/guide/ssg.md +5 -3
- package/skills/void/docs/guide/storage.md +2 -2
- package/skills/void/docs/guide/websockets.md +18 -7
- package/skills/void/docs/index.md +3 -3
- package/skills/void/docs/integrations/agents.md +6 -64
- package/skills/void/docs/integrations/cloudflare.md +165 -146
- package/skills/void/docs/integrations/frameworks/analog.md +4 -4
- package/skills/void/docs/integrations/frameworks/astro.md +5 -5
- package/skills/void/docs/integrations/frameworks/nuxt.md +5 -5
- package/skills/void/docs/integrations/frameworks/overview.md +3 -3
- package/skills/void/docs/integrations/frameworks/react-router.md +3 -3
- package/skills/void/docs/integrations/frameworks/sveltekit.md +3 -3
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +2 -2
- package/skills/void/docs/integrations/nodejs-bun-deno.md +11 -4
- package/skills/void/docs/reference/api.md +42 -6
- package/skills/void/docs/reference/cli.md +637 -159
- package/skills/void/docs/reference/config.md +80 -25
- package/skills/void/docs/reference/resource-inference.md +13 -9
- package/skills/void/docs/reference/structure.md +10 -11
- package/AGENT_PROMPT.md +0 -19
- package/dist/cf-access-Bqw81xAf.mjs +0 -22
- package/dist/env-CZy5MorI.mjs +0 -299
- package/dist/env-helpers-z4stu8uc.d.mts +0 -52
- package/dist/env-mask-Dd47NbR6.mjs +0 -90
- package/dist/env-public-BfiLcMBk.d.mts +0 -140
- package/dist/link-CdGHSIy-.mjs +0 -45
- package/dist/mcp-DoM3_nhd.mjs +0 -377
- package/dist/project-paths-GpziKeQQ.d.mts +0 -25
- package/dist/providers-BNKRacMr.d.mts +0 -7
- package/dist/proxy-D-3_D-Gl.mjs +0 -5
- package/dist/rollback-CkvTFXx5.mjs +0 -90
- package/dist/runtime/isr-cache.d.mts +0 -207
- package/dist/runtime/isr-cache.mjs +0 -523
- package/dist/types-lLjNE9Qp.d.mts +0 -51
- package/getting-started-prompt.txt +0 -28
- package/skills/void/command/void.md +0 -7
- package/skills/void/docs/integrations/auth-providers.md +0 -0
- package/skills/void/docs/integrations/payment-processors.md +0 -0
- package/skills/void/docs/node_modules/@iconify/vue/README.md +0 -408
- package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +0 -5
- package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +0 -103
- package/skills/void/docs/node_modules/oxc-minify/README.md +0 -78
- package/skills/void/docs/node_modules/reka-ui/README.md +0 -80
- package/skills/void/docs/node_modules/vitepress/README.md +0 -28
- package/skills/void/docs/node_modules/vitepress/template/api-examples.md +0 -49
- package/skills/void/docs/node_modules/vitepress/template/index.md +0 -28
- package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +0 -85
- package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +0 -101
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +0 -19
- package/skills/void/docs/node_modules/void/CLAUDE.md +0 -219
- package/skills/void/docs/node_modules/void/README.md +0 -90
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +0 -685
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +0 -396
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +0 -219
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +0 -37
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +0 -135
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +0 -189
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +0 -143
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +0 -1272
- package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +0 -19
- package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@types/proper-lockfile/README.md +0 -51
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +0 -22
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +0 -69
- package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +0 -153
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +0 -9
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +0 -9
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +0 -24
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +0 -565
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +0 -127
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +0 -600
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +0 -386
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +0 -95
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-footnote/README.md +0 -135
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathslash/README.md +0 -64
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +0 -25
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/AGENTS.md +0 -16
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/README.md +0 -220
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/build.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/check.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/create.md +0 -70
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/fmt.md +0 -20
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/index.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/lint.md +0 -26
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/pack.md +0 -17
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/run.md +0 -364
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/staged.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/test.md +0 -18
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/automatic-data-tracking.md +0 -145
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/build.md +0 -40
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/cache.md +0 -107
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/check.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/ci.md +0 -62
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/commit-hooks.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/create.md +0 -341
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/dev.md +0 -24
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/docker.md +0 -175
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/env.md +0 -167
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/fmt.md +0 -41
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/github-actions-cache.md +0 -165
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/ide-integration.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/implode.md +0 -23
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/index.md +0 -134
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/install.md +0 -199
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/lint.md +0 -50
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/migrate-rules.md +0 -347
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/migrate.md +0 -197
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/monorepo.md +0 -176
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/pack.md +0 -69
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/run.md +0 -356
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/test.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/troubleshooting.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/upgrade.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/vpx.md +0 -66
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/why.md +0 -39
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/index.md +0 -12
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/team.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/templates/generator/README.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/templates/monorepo/README.md +0 -29
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +0 -58
- package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +0 -165
- package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +0 -20
- package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +0 -32
- package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +0 -99
- package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +0 -51
- package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +0 -79
- package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +0 -44
- package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +0 -51
- package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +0 -65
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +0 -403
- package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +0 -48
- package/skills/void/docs/node_modules/void/node_modules/hono/README.md +0 -85
- package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +0 -452
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +0 -76
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +0 -364
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +0 -41
- package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +0 -325
- package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +0 -398
- package/skills/void/docs/node_modules/void/node_modules/pathslash/README.md +0 -64
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +0 -96
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +0 -135
- package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/proper-lockfile/CHANGELOG.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/proper-lockfile/README.md +0 -183
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +0 -25
- package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +0 -9
- package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +0 -94
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/AGENTS.md +0 -16
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/README.md +0 -220
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/build.md +0 -21
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/check.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/create.md +0 -70
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/fmt.md +0 -20
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/index.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/lint.md +0 -26
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/pack.md +0 -17
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/run.md +0 -364
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/staged.md +0 -15
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/test.md +0 -18
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/automatic-data-tracking.md +0 -145
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/build.md +0 -40
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/cache.md +0 -107
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/check.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/ci.md +0 -62
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/commit-hooks.md +0 -60
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/create.md +0 -341
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/dev.md +0 -24
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/docker.md +0 -175
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/env.md +0 -167
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/fmt.md +0 -41
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/github-actions-cache.md +0 -165
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/ide-integration.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/implode.md +0 -23
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/index.md +0 -134
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/install.md +0 -199
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/lint.md +0 -50
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/migrate-rules.md +0 -347
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/migrate.md +0 -197
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/monorepo.md +0 -176
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/pack.md +0 -69
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/run.md +0 -356
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/test.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/troubleshooting.md +0 -108
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/upgrade.md +0 -101
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/vpx.md +0 -66
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/why.md +0 -39
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/index.md +0 -12
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/team.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/templates/generator/README.md +0 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/templates/monorepo/README.md +0 -29
- package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +0 -63
- package/skills/void/docs/node_modules/void/node_modules/zod/README.md +0 -191
- package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +0 -175
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +0 -76
- package/skills/void/docs/node_modules/void/skills/void/command/void.md +0 -7
- package/skills/void/docs/node_modules/void/test/e2e/README.md +0 -85
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.
|
|
1
|
+
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
2
2
|
var comma = ",".charCodeAt(0);
|
|
3
3
|
var semicolon = ";".charCodeAt(0);
|
|
4
4
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -9,18 +9,18 @@ for (let i = 0; i < chars.length; i++) {
|
|
|
9
9
|
intToChar[i] = c;
|
|
10
10
|
charToInt[c] = i;
|
|
11
11
|
}
|
|
12
|
-
function encodeInteger(builder, num
|
|
13
|
-
let delta = num - relative;
|
|
14
|
-
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
12
|
+
function encodeInteger(builder, num) {
|
|
15
13
|
do {
|
|
16
|
-
let clamped =
|
|
17
|
-
|
|
18
|
-
if (
|
|
14
|
+
let clamped = num & 31;
|
|
15
|
+
num >>>= 5;
|
|
16
|
+
if (num > 0) clamped |= 32;
|
|
19
17
|
builder.write(intToChar[clamped]);
|
|
20
|
-
} while (
|
|
21
|
-
return num;
|
|
18
|
+
} while (num > 0);
|
|
22
19
|
}
|
|
23
|
-
|
|
20
|
+
function encodeSign(num) {
|
|
21
|
+
return num < 0 ? -num << 1 | 1 : num << 1;
|
|
22
|
+
}
|
|
23
|
+
var bufLength = 16384;
|
|
24
24
|
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
|
|
25
25
|
return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
|
|
26
26
|
} } : { decode(buf) {
|
|
@@ -47,6 +47,21 @@ var StringWriter = class {
|
|
|
47
47
|
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
+
function encodeRangeMappings(decoded) {
|
|
51
|
+
if (decoded.length === 0) return "";
|
|
52
|
+
const writer = new StringWriter();
|
|
53
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
54
|
+
const indices = decoded[i];
|
|
55
|
+
if (i > 0) writer.write(semicolon);
|
|
56
|
+
let index = 0;
|
|
57
|
+
for (let j = 0; j < indices.length; j++) {
|
|
58
|
+
const offset = indices[j];
|
|
59
|
+
encodeInteger(writer, offset - index);
|
|
60
|
+
index = offset;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return writer.flush();
|
|
64
|
+
}
|
|
50
65
|
function encode(decoded) {
|
|
51
66
|
const writer = new StringWriter();
|
|
52
67
|
let sourcesIndex = 0;
|
|
@@ -61,19 +76,24 @@ function encode(decoded) {
|
|
|
61
76
|
for (let j = 0; j < line.length; j++) {
|
|
62
77
|
const segment = line[j];
|
|
63
78
|
if (j > 0) writer.write(comma);
|
|
64
|
-
|
|
79
|
+
encodeInteger(writer, encodeSign(segment[0] - genColumn));
|
|
80
|
+
genColumn = segment[0];
|
|
65
81
|
if (segment.length === 1) continue;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
encodeInteger(writer, encodeSign(segment[1] - sourcesIndex));
|
|
83
|
+
encodeInteger(writer, encodeSign(segment[2] - sourceLine));
|
|
84
|
+
encodeInteger(writer, encodeSign(segment[3] - sourceColumn));
|
|
85
|
+
sourcesIndex = segment[1];
|
|
86
|
+
sourceLine = segment[2];
|
|
87
|
+
sourceColumn = segment[3];
|
|
69
88
|
if (segment.length === 4) continue;
|
|
70
|
-
|
|
89
|
+
encodeInteger(writer, encodeSign(segment[4] - namesIndex));
|
|
90
|
+
namesIndex = segment[4];
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
93
|
return writer.flush();
|
|
74
94
|
}
|
|
75
95
|
//#endregion
|
|
76
|
-
//#region ../../node_modules/.pnpm/magic-string@
|
|
96
|
+
//#region ../../node_modules/.pnpm/magic-string@1.3.1/node_modules/magic-string/dist/index.mjs
|
|
77
97
|
var BitSet = class BitSet {
|
|
78
98
|
constructor(arg) {
|
|
79
99
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
@@ -117,14 +137,16 @@ var Chunk = class Chunk {
|
|
|
117
137
|
return this.start < index && index < this.end;
|
|
118
138
|
}
|
|
119
139
|
eachNext(fn) {
|
|
120
|
-
|
|
140
|
+
fn(this);
|
|
141
|
+
let chunk = this.next;
|
|
121
142
|
while (chunk) {
|
|
122
143
|
fn(chunk);
|
|
123
144
|
chunk = chunk.next;
|
|
124
145
|
}
|
|
125
146
|
}
|
|
126
147
|
eachPrevious(fn) {
|
|
127
|
-
|
|
148
|
+
fn(this);
|
|
149
|
+
let chunk = this.previous;
|
|
128
150
|
while (chunk) {
|
|
129
151
|
fn(chunk);
|
|
130
152
|
chunk = chunk.previous;
|
|
@@ -183,8 +205,8 @@ var Chunk = class Chunk {
|
|
|
183
205
|
const trimmed = this.content.replace(rx, "");
|
|
184
206
|
if (trimmed.length) {
|
|
185
207
|
if (trimmed !== this.content) {
|
|
186
|
-
this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
187
208
|
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
209
|
+
else this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
188
210
|
}
|
|
189
211
|
return true;
|
|
190
212
|
} else {
|
|
@@ -199,9 +221,11 @@ var Chunk = class Chunk {
|
|
|
199
221
|
const trimmed = this.content.replace(rx, "");
|
|
200
222
|
if (trimmed.length) {
|
|
201
223
|
if (trimmed !== this.content) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
224
|
+
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
225
|
+
else {
|
|
226
|
+
this.split(this.end - trimmed.length);
|
|
227
|
+
this.edit("", void 0, true);
|
|
228
|
+
}
|
|
205
229
|
}
|
|
206
230
|
return true;
|
|
207
231
|
} else {
|
|
@@ -211,14 +235,29 @@ var Chunk = class Chunk {
|
|
|
211
235
|
}
|
|
212
236
|
}
|
|
213
237
|
};
|
|
238
|
+
/**
|
|
239
|
+
* The single error type thrown by MagicString.
|
|
240
|
+
*
|
|
241
|
+
* Every message is prefixed with `[MagicString]` so its source is obvious at a
|
|
242
|
+
* glance, and is kept short and consistent in tone.
|
|
243
|
+
*/
|
|
244
|
+
var MagicStringError = class extends Error {
|
|
245
|
+
name = "MagicStringError";
|
|
246
|
+
constructor(message, options) {
|
|
247
|
+
super(`[MagicString] ${message}`, options);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
214
250
|
function getBtoa() {
|
|
251
|
+
/* v8 ignore next -- environment fallback, unreachable when `btoa` is present */
|
|
215
252
|
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
253
|
+
const buffer = globalThis["Buffer"];
|
|
254
|
+
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
255
|
+
return () => {
|
|
256
|
+
throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
|
|
219
257
|
};
|
|
258
|
+
/* v8 ignore stop */
|
|
220
259
|
}
|
|
221
|
-
const btoa =
|
|
260
|
+
const btoa = /* #__PURE__ */ getBtoa();
|
|
222
261
|
var SourceMap = class {
|
|
223
262
|
constructor(properties) {
|
|
224
263
|
this.version = 3;
|
|
@@ -229,25 +268,46 @@ var SourceMap = class {
|
|
|
229
268
|
this.mappings = encode(properties.mappings);
|
|
230
269
|
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
231
270
|
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
271
|
+
if (typeof properties.rangeMappings !== "undefined") {
|
|
272
|
+
let shouldOutputRangeMapping = false;
|
|
273
|
+
for (const line of properties.rangeMappings) if (line.length !== 0) {
|
|
274
|
+
shouldOutputRangeMapping = true;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
if (shouldOutputRangeMapping) this.rangeMappings = encodeRangeMappings(properties.rangeMappings);
|
|
278
|
+
}
|
|
232
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Returns the equivalent of `JSON.stringify(map)`
|
|
282
|
+
*/
|
|
233
283
|
toString() {
|
|
234
284
|
return JSON.stringify(this);
|
|
235
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
|
288
|
+
* `generateMap(options?: SourceMapOptions): SourceMap;`
|
|
289
|
+
*/
|
|
236
290
|
toUrl() {
|
|
237
|
-
return
|
|
291
|
+
return `data:application/json;charset=utf-8;base64,${btoa(this.toString())}`;
|
|
238
292
|
}
|
|
239
293
|
};
|
|
240
|
-
function
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
294
|
+
function getLocator(source) {
|
|
295
|
+
const lineOffsets = [0];
|
|
296
|
+
for (let i = source.indexOf("\n"); i !== -1; i = source.indexOf("\n", i + 1)) lineOffsets.push(i + 1);
|
|
297
|
+
return function locate(index) {
|
|
298
|
+
let i = 0;
|
|
299
|
+
let j = lineOffsets.length;
|
|
300
|
+
while (i < j) {
|
|
301
|
+
const m = i + j >> 1;
|
|
302
|
+
if (index < lineOffsets[m]) j = m;
|
|
303
|
+
else i = m + 1;
|
|
304
|
+
}
|
|
305
|
+
const line = i - 1;
|
|
306
|
+
return {
|
|
307
|
+
line,
|
|
308
|
+
column: index - lineOffsets[line]
|
|
309
|
+
};
|
|
310
|
+
};
|
|
251
311
|
}
|
|
252
312
|
function getRelativePath(from, to) {
|
|
253
313
|
const fromParts = from.split(/[/\\]/);
|
|
@@ -263,33 +323,26 @@ function getRelativePath(from, to) {
|
|
|
263
323
|
}
|
|
264
324
|
return fromParts.concat(toParts).join("/");
|
|
265
325
|
}
|
|
326
|
+
function guessIndent(code) {
|
|
327
|
+
const lines = code.split("\n");
|
|
328
|
+
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
329
|
+
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
330
|
+
if (tabbed.length === 0 && spaced.length === 0) return null;
|
|
331
|
+
if (tabbed.length >= spaced.length) return " ";
|
|
332
|
+
const min = spaced.reduce((previous, current) => {
|
|
333
|
+
const numSpaces = /^ +/.exec(current)[0].length;
|
|
334
|
+
return Math.min(numSpaces, previous);
|
|
335
|
+
}, Infinity);
|
|
336
|
+
return " ".repeat(min);
|
|
337
|
+
}
|
|
266
338
|
const toString = Object.prototype.toString;
|
|
267
339
|
function isObject(thing) {
|
|
268
340
|
return toString.call(thing) === "[object Object]";
|
|
269
341
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
274
|
-
lineOffsets.push(pos);
|
|
275
|
-
pos += originalLines[i].length + 1;
|
|
276
|
-
}
|
|
277
|
-
return function locate(index) {
|
|
278
|
-
let i = 0;
|
|
279
|
-
let j = lineOffsets.length;
|
|
280
|
-
while (i < j) {
|
|
281
|
-
const m = i + j >> 1;
|
|
282
|
-
if (index < lineOffsets[m]) j = m;
|
|
283
|
-
else i = m + 1;
|
|
284
|
-
}
|
|
285
|
-
const line = i - 1;
|
|
286
|
-
return {
|
|
287
|
-
line,
|
|
288
|
-
column: index - lineOffsets[line]
|
|
289
|
-
};
|
|
290
|
-
};
|
|
342
|
+
const NEWLINE_CHAR$1 = 10;
|
|
343
|
+
function isWordCode(code) {
|
|
344
|
+
return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95;
|
|
291
345
|
}
|
|
292
|
-
const wordRegex = /\w/;
|
|
293
346
|
var Mappings = class {
|
|
294
347
|
constructor(hires) {
|
|
295
348
|
this.hires = hires;
|
|
@@ -297,9 +350,12 @@ var Mappings = class {
|
|
|
297
350
|
this.generatedCodeColumn = 0;
|
|
298
351
|
this.raw = [];
|
|
299
352
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
353
|
+
this.rawRangeMappings = [];
|
|
354
|
+
this.rawRangeMappingsIndices = this.rawRangeMappings[this.generatedCodeLine] = [];
|
|
300
355
|
this.pending = null;
|
|
301
356
|
}
|
|
302
357
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
358
|
+
/* v8 ignore else -- `pending` is never assigned a truthy value */
|
|
303
359
|
if (content.length) {
|
|
304
360
|
const contentLengthMinusOne = content.length - 1;
|
|
305
361
|
let contentLineEnd = content.indexOf("\n", 0);
|
|
@@ -315,6 +371,7 @@ var Mappings = class {
|
|
|
315
371
|
this.rawSegments.push(segment);
|
|
316
372
|
this.generatedCodeLine += 1;
|
|
317
373
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
374
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
318
375
|
this.generatedCodeColumn = 0;
|
|
319
376
|
previousContentLineEnd = contentLineEnd;
|
|
320
377
|
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
@@ -335,64 +392,195 @@ var Mappings = class {
|
|
|
335
392
|
this.pending = null;
|
|
336
393
|
}
|
|
337
394
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
338
|
-
|
|
339
|
-
let
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
395
|
+
const end = chunk.end;
|
|
396
|
+
let i = chunk.start;
|
|
397
|
+
if (this.hires) {
|
|
398
|
+
const boundary = this.hires === "boundary";
|
|
399
|
+
const experimentalRange = this.hires === "experimental-range";
|
|
400
|
+
let charInHiresBoundary = false;
|
|
401
|
+
while (i < end) {
|
|
402
|
+
if (experimentalRange && i + 1 >= end) this.rawSegments.push([
|
|
403
|
+
this.generatedCodeColumn,
|
|
404
|
+
sourceIndex,
|
|
405
|
+
loc.line,
|
|
406
|
+
loc.column
|
|
407
|
+
]);
|
|
408
|
+
const code = original.charCodeAt(i);
|
|
409
|
+
if (code === NEWLINE_CHAR$1) {
|
|
410
|
+
loc.line += 1;
|
|
411
|
+
loc.column = 0;
|
|
412
|
+
this.generatedCodeLine += 1;
|
|
413
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
414
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
415
|
+
this.generatedCodeColumn = 0;
|
|
416
|
+
charInHiresBoundary = false;
|
|
417
|
+
} else {
|
|
418
|
+
if (boundary) {
|
|
419
|
+
if (isWordCode(code)) {
|
|
420
|
+
if (!charInHiresBoundary) {
|
|
421
|
+
this.rawSegments.push([
|
|
422
|
+
this.generatedCodeColumn,
|
|
423
|
+
sourceIndex,
|
|
424
|
+
loc.line,
|
|
425
|
+
loc.column
|
|
426
|
+
]);
|
|
427
|
+
charInHiresBoundary = true;
|
|
428
|
+
}
|
|
429
|
+
} else {
|
|
430
|
+
this.rawSegments.push([
|
|
431
|
+
this.generatedCodeColumn,
|
|
432
|
+
sourceIndex,
|
|
433
|
+
loc.line,
|
|
434
|
+
loc.column
|
|
435
|
+
]);
|
|
436
|
+
charInHiresBoundary = false;
|
|
437
|
+
}
|
|
438
|
+
} else if (experimentalRange) {
|
|
439
|
+
if (i === chunk.start) {
|
|
440
|
+
this.rawRangeMappingsIndices.push(this.rawSegments.length);
|
|
441
|
+
this.rawSegments.push([
|
|
442
|
+
this.generatedCodeColumn,
|
|
443
|
+
sourceIndex,
|
|
444
|
+
loc.line,
|
|
445
|
+
loc.column
|
|
446
|
+
]);
|
|
447
|
+
}
|
|
448
|
+
} else this.rawSegments.push([
|
|
353
449
|
this.generatedCodeColumn,
|
|
354
450
|
sourceIndex,
|
|
355
451
|
loc.line,
|
|
356
452
|
loc.column
|
|
357
|
-
];
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
453
|
+
]);
|
|
454
|
+
loc.column += 1;
|
|
455
|
+
this.generatedCodeColumn += 1;
|
|
456
|
+
}
|
|
457
|
+
i += 1;
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
const bits = sourcemapLocations.bits;
|
|
461
|
+
while (i < end) {
|
|
462
|
+
let newline = original.indexOf("\n", i);
|
|
463
|
+
if (newline === -1 || newline > end) newline = end;
|
|
464
|
+
if (newline > i) {
|
|
465
|
+
this.rawSegments.push([
|
|
466
|
+
this.generatedCodeColumn,
|
|
467
|
+
sourceIndex,
|
|
468
|
+
loc.line,
|
|
469
|
+
loc.column
|
|
470
|
+
]);
|
|
471
|
+
for (let w = i + 1 >> 5, last = newline - 1 >> 5; w <= last; w++) {
|
|
472
|
+
let word = bits[w];
|
|
473
|
+
if (!word) continue;
|
|
474
|
+
const base = w << 5;
|
|
475
|
+
while (word) {
|
|
476
|
+
const lowest = word & -word;
|
|
477
|
+
const index = base + 31 - Math.clz32(lowest);
|
|
478
|
+
if (index > i && index < newline) {
|
|
479
|
+
const offset = index - i;
|
|
480
|
+
this.rawSegments.push([
|
|
481
|
+
this.generatedCodeColumn + offset,
|
|
482
|
+
sourceIndex,
|
|
483
|
+
loc.line,
|
|
484
|
+
loc.column + offset
|
|
485
|
+
]);
|
|
486
|
+
}
|
|
487
|
+
word ^= lowest;
|
|
362
488
|
}
|
|
363
|
-
} else {
|
|
364
|
-
this.rawSegments.push(segment);
|
|
365
|
-
charInHiresBoundary = false;
|
|
366
489
|
}
|
|
367
|
-
|
|
490
|
+
loc.column += newline - i;
|
|
491
|
+
this.generatedCodeColumn += newline - i;
|
|
368
492
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
493
|
+
if (newline === end) break;
|
|
494
|
+
loc.line += 1;
|
|
495
|
+
loc.column = 0;
|
|
496
|
+
this.generatedCodeLine += 1;
|
|
497
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
498
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
499
|
+
this.generatedCodeColumn = 0;
|
|
500
|
+
i = newline + 1;
|
|
372
501
|
}
|
|
373
|
-
originalCharIndex += 1;
|
|
374
502
|
}
|
|
375
503
|
this.pending = null;
|
|
376
504
|
}
|
|
377
505
|
advance(str) {
|
|
378
506
|
if (!str) return;
|
|
379
|
-
const
|
|
380
|
-
if (
|
|
381
|
-
for (let i =
|
|
507
|
+
const lastNewline = str.lastIndexOf("\n");
|
|
508
|
+
if (lastNewline !== -1) {
|
|
509
|
+
for (let i = str.indexOf("\n"); i !== -1; i = str.indexOf("\n", i + 1)) {
|
|
382
510
|
this.generatedCodeLine++;
|
|
383
511
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
512
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
384
513
|
}
|
|
385
514
|
this.generatedCodeColumn = 0;
|
|
386
515
|
}
|
|
387
|
-
this.generatedCodeColumn +=
|
|
516
|
+
this.generatedCodeColumn += str.length - lastNewline - 1;
|
|
388
517
|
}
|
|
389
518
|
};
|
|
390
519
|
const n = "\n";
|
|
520
|
+
const NEWLINE_CHAR = "\n".charCodeAt(0);
|
|
521
|
+
const CR_CHAR = "\r".charCodeAt(0);
|
|
391
522
|
const warned = {
|
|
392
523
|
insertLeft: false,
|
|
393
524
|
insertRight: false,
|
|
394
525
|
storeName: false
|
|
395
526
|
};
|
|
527
|
+
/**
|
|
528
|
+
* Expands the `$` substitution patterns that `String.prototype.replace` accepts
|
|
529
|
+
* in a string replacement.
|
|
530
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
|
|
531
|
+
*
|
|
532
|
+
* `captures` holds the capture groups in order, so `captures[0]` is `$1`.
|
|
533
|
+
* `namedCaptures` is `undefined` when the pattern has no named groups, and
|
|
534
|
+
* `$<name>` is then literal text - which is also the case for a string search
|
|
535
|
+
* value, where there are no groups of either kind.
|
|
536
|
+
*/
|
|
537
|
+
function expandReplacement(replacement, matched, position, str, captures, namedCaptures) {
|
|
538
|
+
if (!replacement.includes("$")) return replacement;
|
|
539
|
+
let result = "";
|
|
540
|
+
let index = 0;
|
|
541
|
+
while (index < replacement.length) {
|
|
542
|
+
const dollar = replacement.indexOf("$", index);
|
|
543
|
+
if (dollar === -1) {
|
|
544
|
+
result += replacement.slice(index);
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
result += replacement.slice(index, dollar);
|
|
548
|
+
const char = replacement[dollar + 1];
|
|
549
|
+
let expansion = "$";
|
|
550
|
+
let consumed = 1;
|
|
551
|
+
if (char === "$") consumed = 2;
|
|
552
|
+
else if (char === "&") {
|
|
553
|
+
expansion = matched;
|
|
554
|
+
consumed = 2;
|
|
555
|
+
} else if (char === "`") {
|
|
556
|
+
expansion = str.slice(0, position);
|
|
557
|
+
consumed = 2;
|
|
558
|
+
} else if (char === "'") {
|
|
559
|
+
expansion = str.slice(position + matched.length);
|
|
560
|
+
consumed = 2;
|
|
561
|
+
} else if (char === "<" && namedCaptures !== void 0) {
|
|
562
|
+
const close = replacement.indexOf(">", dollar + 2);
|
|
563
|
+
if (close !== -1) {
|
|
564
|
+
expansion = namedCaptures[replacement.slice(dollar + 2, close)] ?? "";
|
|
565
|
+
consumed = close + 1 - dollar;
|
|
566
|
+
}
|
|
567
|
+
} else if (char >= "0" && char <= "9") {
|
|
568
|
+
const second = replacement[dollar + 2];
|
|
569
|
+
const double = second >= "0" && second <= "9" ? Number(char + second) : NaN;
|
|
570
|
+
const single = Number(char);
|
|
571
|
+
if (double >= 1 && double <= captures.length) {
|
|
572
|
+
expansion = captures[double - 1] ?? "";
|
|
573
|
+
consumed = 3;
|
|
574
|
+
} else if (single >= 1 && single <= captures.length) {
|
|
575
|
+
expansion = captures[single - 1] ?? "";
|
|
576
|
+
consumed = 2;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
result += expansion;
|
|
580
|
+
index = dollar + consumed;
|
|
581
|
+
}
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
396
584
|
var MagicString = class MagicString {
|
|
397
585
|
constructor(string, options = {}) {
|
|
398
586
|
const chunk = new Chunk(0, string.length, string);
|
|
@@ -423,11 +611,11 @@ var MagicString = class MagicString {
|
|
|
423
611
|
},
|
|
424
612
|
byStart: {
|
|
425
613
|
writable: true,
|
|
426
|
-
value:
|
|
614
|
+
value: /* @__PURE__ */ new Map([[0, chunk]])
|
|
427
615
|
},
|
|
428
616
|
byEnd: {
|
|
429
617
|
writable: true,
|
|
430
|
-
value:
|
|
618
|
+
value: /* @__PURE__ */ new Map([[string.length, chunk]])
|
|
431
619
|
},
|
|
432
620
|
filename: {
|
|
433
621
|
writable: true,
|
|
@@ -456,47 +644,69 @@ var MagicString = class MagicString {
|
|
|
456
644
|
offset: {
|
|
457
645
|
writable: true,
|
|
458
646
|
value: options.offset || 0
|
|
647
|
+
},
|
|
648
|
+
hasMovedChunks: {
|
|
649
|
+
writable: true,
|
|
650
|
+
value: false
|
|
459
651
|
}
|
|
460
652
|
});
|
|
461
|
-
this.byStart[0] = chunk;
|
|
462
|
-
this.byEnd[string.length] = chunk;
|
|
463
653
|
}
|
|
654
|
+
/**
|
|
655
|
+
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
|
656
|
+
*/
|
|
464
657
|
addSourcemapLocation(char) {
|
|
465
658
|
this.sourcemapLocations.add(char);
|
|
466
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* Appends the specified content to the end of the string.
|
|
662
|
+
*/
|
|
467
663
|
append(content) {
|
|
468
|
-
if (typeof content !== "string") throw new
|
|
664
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
469
665
|
this.outro += content;
|
|
470
666
|
return this;
|
|
471
667
|
}
|
|
668
|
+
/**
|
|
669
|
+
* Appends the specified content at the index in the original string.
|
|
670
|
+
* If a range *ending* with index is subsequently moved, the insert will be moved with it.
|
|
671
|
+
* See also `s.prependLeft(...)`.
|
|
672
|
+
*/
|
|
472
673
|
appendLeft(index, content) {
|
|
473
674
|
index = index + this.offset;
|
|
474
|
-
if (typeof content !== "string") throw new
|
|
675
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
475
676
|
this._split(index);
|
|
476
|
-
const chunk = this.byEnd
|
|
677
|
+
const chunk = this.byEnd.get(index);
|
|
477
678
|
if (chunk) chunk.appendLeft(content);
|
|
478
679
|
else this.intro += content;
|
|
479
680
|
return this;
|
|
480
681
|
}
|
|
682
|
+
/**
|
|
683
|
+
* Appends the specified content at the index in the original string.
|
|
684
|
+
* If a range *starting* with index is subsequently moved, the insert will be moved with it.
|
|
685
|
+
* See also `s.prependRight(...)`.
|
|
686
|
+
*/
|
|
481
687
|
appendRight(index, content) {
|
|
482
688
|
index = index + this.offset;
|
|
483
|
-
if (typeof content !== "string") throw new
|
|
689
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
484
690
|
this._split(index);
|
|
485
|
-
const chunk = this.byStart
|
|
691
|
+
const chunk = this.byStart.get(index);
|
|
486
692
|
if (chunk) chunk.appendRight(content);
|
|
487
693
|
else this.outro += content;
|
|
488
694
|
return this;
|
|
489
695
|
}
|
|
696
|
+
/**
|
|
697
|
+
* Does what you'd expect.
|
|
698
|
+
*/
|
|
490
699
|
clone() {
|
|
491
700
|
const cloned = new MagicString(this.original, {
|
|
492
701
|
filename: this.filename,
|
|
702
|
+
ignoreList: this.ignoreList,
|
|
493
703
|
offset: this.offset
|
|
494
704
|
});
|
|
495
705
|
let originalChunk = this.firstChunk;
|
|
496
706
|
let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
|
|
497
707
|
while (originalChunk) {
|
|
498
|
-
cloned.byStart
|
|
499
|
-
cloned.byEnd
|
|
708
|
+
cloned.byStart.set(clonedChunk.start, clonedChunk);
|
|
709
|
+
cloned.byEnd.set(clonedChunk.end, clonedChunk);
|
|
500
710
|
const nextOriginalChunk = originalChunk.next;
|
|
501
711
|
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
502
712
|
if (nextClonedChunk) {
|
|
@@ -509,10 +719,16 @@ var MagicString = class MagicString {
|
|
|
509
719
|
cloned.lastChunk = clonedChunk;
|
|
510
720
|
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
511
721
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
722
|
+
cloned.storedNames = { ...this.storedNames };
|
|
512
723
|
cloned.intro = this.intro;
|
|
513
724
|
cloned.outro = this.outro;
|
|
725
|
+
cloned.hasMovedChunks = this.hasMovedChunks;
|
|
514
726
|
return cloned;
|
|
515
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
|
|
730
|
+
* Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
|
731
|
+
*/
|
|
516
732
|
generateDecodedMap(options) {
|
|
517
733
|
options = options || {};
|
|
518
734
|
const sourceIndex = 0;
|
|
@@ -534,15 +750,21 @@ var MagicString = class MagicString {
|
|
|
534
750
|
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
535
751
|
names,
|
|
536
752
|
mappings: mappings.raw,
|
|
537
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
753
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0,
|
|
754
|
+
rangeMappings: mappings.rawRangeMappings
|
|
538
755
|
};
|
|
539
756
|
}
|
|
757
|
+
/**
|
|
758
|
+
* Generates a version 3 sourcemap.
|
|
759
|
+
*/
|
|
540
760
|
generateMap(options) {
|
|
541
761
|
return new SourceMap(this.generateDecodedMap(options));
|
|
542
762
|
}
|
|
763
|
+
/** @internal */
|
|
543
764
|
_ensureindentStr() {
|
|
544
765
|
if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
|
|
545
766
|
}
|
|
767
|
+
/** @internal */
|
|
546
768
|
_getRawIndentString() {
|
|
547
769
|
this._ensureindentStr();
|
|
548
770
|
return this.indentStr;
|
|
@@ -562,55 +784,77 @@ var MagicString = class MagicString {
|
|
|
562
784
|
indentStr = this.indentStr || " ";
|
|
563
785
|
}
|
|
564
786
|
if (indentStr === "") return this;
|
|
787
|
+
const resolvedIndentStr = indentStr;
|
|
565
788
|
options = options || {};
|
|
566
789
|
const isExcluded = {};
|
|
567
790
|
if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
|
|
568
791
|
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
569
792
|
});
|
|
570
793
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
573
|
-
|
|
574
|
-
|
|
794
|
+
const indentPiece = (str) => {
|
|
795
|
+
if (str === "") return str;
|
|
796
|
+
const indented = str.replace(pattern, (match, offset) => offset > 0 || shouldIndentNextCharacter ? `${resolvedIndentStr}${match}` : match);
|
|
797
|
+
shouldIndentNextCharacter = str[str.length - 1] === "\n";
|
|
798
|
+
return indented;
|
|
575
799
|
};
|
|
576
|
-
this.intro = this.intro
|
|
800
|
+
this.intro = indentPiece(this.intro);
|
|
577
801
|
let charIndex = 0;
|
|
578
802
|
let chunk = this.firstChunk;
|
|
803
|
+
const indentAt = (index) => {
|
|
804
|
+
shouldIndentNextCharacter = false;
|
|
805
|
+
if (index === chunk.start) chunk.appendRight(resolvedIndentStr);
|
|
806
|
+
else {
|
|
807
|
+
this._splitChunk(chunk, index);
|
|
808
|
+
chunk = chunk.next;
|
|
809
|
+
chunk.prependRight(resolvedIndentStr);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
579
812
|
while (chunk) {
|
|
580
813
|
const end = chunk.end;
|
|
814
|
+
if (!isExcluded[chunk.start]) chunk.intro = indentPiece(chunk.intro);
|
|
581
815
|
if (chunk.edited) {
|
|
582
|
-
if (!isExcluded[charIndex])
|
|
583
|
-
|
|
584
|
-
|
|
816
|
+
if (!isExcluded[charIndex]) chunk.content = indentPiece(chunk.content);
|
|
817
|
+
} else if (options.exclude) {
|
|
818
|
+
charIndex = chunk.start;
|
|
819
|
+
while (charIndex < end) {
|
|
820
|
+
if (!isExcluded[charIndex]) {
|
|
821
|
+
const char = this.original.charCodeAt(charIndex);
|
|
822
|
+
if (char === NEWLINE_CHAR) shouldIndentNextCharacter = true;
|
|
823
|
+
else if (char !== CR_CHAR && shouldIndentNextCharacter) indentAt(charIndex);
|
|
824
|
+
}
|
|
825
|
+
charIndex += 1;
|
|
585
826
|
}
|
|
586
827
|
} else {
|
|
587
828
|
charIndex = chunk.start;
|
|
588
829
|
while (charIndex < end) {
|
|
589
|
-
if (!
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
830
|
+
if (!shouldIndentNextCharacter) {
|
|
831
|
+
const nextLine = this.original.indexOf(n, charIndex);
|
|
832
|
+
if (nextLine === -1 || nextLine >= end) break;
|
|
833
|
+
shouldIndentNextCharacter = true;
|
|
834
|
+
charIndex = nextLine + 1;
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
const char = this.original.charCodeAt(charIndex);
|
|
838
|
+
if (char === NEWLINE_CHAR || char === CR_CHAR) {
|
|
839
|
+
charIndex += 1;
|
|
840
|
+
continue;
|
|
601
841
|
}
|
|
842
|
+
indentAt(charIndex);
|
|
602
843
|
charIndex += 1;
|
|
603
844
|
}
|
|
604
845
|
}
|
|
846
|
+
if (!isExcluded[chunk.end - 1]) chunk.outro = indentPiece(chunk.outro);
|
|
605
847
|
charIndex = chunk.end;
|
|
606
848
|
chunk = chunk.next;
|
|
607
849
|
}
|
|
608
|
-
this.outro = this.outro
|
|
850
|
+
this.outro = indentPiece(this.outro);
|
|
609
851
|
return this;
|
|
610
852
|
}
|
|
853
|
+
/** @internal */
|
|
611
854
|
insert() {
|
|
612
|
-
throw new
|
|
855
|
+
throw new MagicStringError("insert() is deprecated, use appendLeft() or prependRight()");
|
|
613
856
|
}
|
|
857
|
+
/** @internal */
|
|
614
858
|
insertLeft(index, content) {
|
|
615
859
|
if (!warned.insertLeft) {
|
|
616
860
|
console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
|
|
@@ -618,6 +862,7 @@ var MagicString = class MagicString {
|
|
|
618
862
|
}
|
|
619
863
|
return this.appendLeft(index, content);
|
|
620
864
|
}
|
|
865
|
+
/** @internal */
|
|
621
866
|
insertRight(index, content) {
|
|
622
867
|
if (!warned.insertRight) {
|
|
623
868
|
console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
|
|
@@ -625,19 +870,30 @@ var MagicString = class MagicString {
|
|
|
625
870
|
}
|
|
626
871
|
return this.prependRight(index, content);
|
|
627
872
|
}
|
|
873
|
+
/**
|
|
874
|
+
* Moves the characters from `start` and `end` to `index`.
|
|
875
|
+
*/
|
|
628
876
|
move(start, end, index) {
|
|
629
877
|
start = start + this.offset;
|
|
630
878
|
end = end + this.offset;
|
|
631
879
|
index = index + this.offset;
|
|
632
|
-
if (
|
|
880
|
+
if (start === end) return this;
|
|
881
|
+
if (index >= start && index <= end) throw new MagicStringError("cannot move a selection inside itself");
|
|
633
882
|
this._split(start);
|
|
634
883
|
this._split(end);
|
|
635
884
|
this._split(index);
|
|
636
|
-
const first = this.byStart
|
|
637
|
-
const last = this.byEnd
|
|
885
|
+
const first = this.byStart.get(start);
|
|
886
|
+
const last = this.byEnd.get(end);
|
|
887
|
+
if (this.hasMovedChunks) {
|
|
888
|
+
let cursor = first;
|
|
889
|
+
while (cursor !== last) {
|
|
890
|
+
cursor = cursor.next;
|
|
891
|
+
if (!cursor || cursor.start < start || cursor.end > end) throw new MagicStringError(`cannot move ${start} to ${end} because an earlier move split that range`);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
638
894
|
const oldLeft = first.previous;
|
|
639
895
|
const oldRight = last.next;
|
|
640
|
-
const newRight = this.byStart
|
|
896
|
+
const newRight = this.byStart.get(index);
|
|
641
897
|
if (!newRight && last === this.lastChunk) return this;
|
|
642
898
|
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
643
899
|
if (oldLeft) oldLeft.next = oldRight;
|
|
@@ -653,25 +909,45 @@ var MagicString = class MagicString {
|
|
|
653
909
|
last.next = newRight || null;
|
|
654
910
|
if (!newLeft) this.firstChunk = first;
|
|
655
911
|
if (!newRight) this.lastChunk = last;
|
|
912
|
+
this.hasMovedChunks = true;
|
|
656
913
|
return this;
|
|
657
914
|
}
|
|
915
|
+
/**
|
|
916
|
+
* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
|
|
917
|
+
* that range. The same restrictions as `s.remove()` apply.
|
|
918
|
+
*
|
|
919
|
+
* The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
|
|
920
|
+
* for later inclusion in a sourcemap's names array - and a contentOnly property which determines whether only
|
|
921
|
+
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
922
|
+
*
|
|
923
|
+
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
|
924
|
+
*/
|
|
658
925
|
overwrite(start, end, content, options) {
|
|
659
|
-
|
|
926
|
+
const optionObject = typeof options === "object" && options ? options : {};
|
|
660
927
|
return this.update(start, end, content, {
|
|
661
|
-
...
|
|
662
|
-
overwrite: !
|
|
928
|
+
...optionObject,
|
|
929
|
+
overwrite: !optionObject.contentOnly
|
|
663
930
|
});
|
|
664
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
|
|
934
|
+
*
|
|
935
|
+
* The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
|
|
936
|
+
* for later inclusion in a sourcemap's names array - and an overwrite property which determines whether only
|
|
937
|
+
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
938
|
+
*/
|
|
665
939
|
update(start, end, content, options) {
|
|
666
940
|
start = start + this.offset;
|
|
667
941
|
end = end + this.offset;
|
|
668
|
-
if (typeof content !== "string") throw new
|
|
942
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
669
943
|
if (this.original.length !== 0) {
|
|
670
|
-
|
|
671
|
-
|
|
944
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
945
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
672
946
|
}
|
|
673
|
-
if (
|
|
674
|
-
if (
|
|
947
|
+
if (start < 0) throw new MagicStringError(`start ${start} is out of bounds`);
|
|
948
|
+
if (end > this.original.length) throw new MagicStringError(`end ${end} is out of bounds`);
|
|
949
|
+
if (start === end) throw new MagicStringError(`cannot overwrite a zero-length range at ${start}, use appendLeft() or prependRight()`);
|
|
950
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
675
951
|
this._split(start);
|
|
676
952
|
this._split(end);
|
|
677
953
|
if (options === true) {
|
|
@@ -681,8 +957,9 @@ var MagicString = class MagicString {
|
|
|
681
957
|
}
|
|
682
958
|
options = { storeName: true };
|
|
683
959
|
}
|
|
684
|
-
const
|
|
685
|
-
const
|
|
960
|
+
const optionObject = typeof options === "object" && options ? options : {};
|
|
961
|
+
const storeName = optionObject.storeName || false;
|
|
962
|
+
const overwrite = optionObject.overwrite || false;
|
|
686
963
|
if (storeName) {
|
|
687
964
|
const original = this.original.slice(start, end);
|
|
688
965
|
Object.defineProperty(this.storedNames, original, {
|
|
@@ -691,12 +968,13 @@ var MagicString = class MagicString {
|
|
|
691
968
|
enumerable: true
|
|
692
969
|
});
|
|
693
970
|
}
|
|
694
|
-
const first = this.byStart
|
|
695
|
-
const last = this.byEnd
|
|
971
|
+
const first = this.byStart.get(start);
|
|
972
|
+
const last = this.byEnd.get(end);
|
|
973
|
+
/* v8 ignore else -- unreachable: a valid start/end always yields a `first` chunk */
|
|
696
974
|
if (first) {
|
|
697
975
|
let chunk = first;
|
|
698
976
|
while (chunk !== last) {
|
|
699
|
-
if (chunk.next !== this.byStart
|
|
977
|
+
if (chunk.next !== this.byStart.get(chunk.end)) throw new MagicStringError("cannot overwrite across a split point");
|
|
700
978
|
chunk = chunk.next;
|
|
701
979
|
chunk.edit("", false);
|
|
702
980
|
}
|
|
@@ -708,77 +986,94 @@ var MagicString = class MagicString {
|
|
|
708
986
|
}
|
|
709
987
|
return this;
|
|
710
988
|
}
|
|
989
|
+
/**
|
|
990
|
+
* Prepends the string with the specified content.
|
|
991
|
+
*/
|
|
711
992
|
prepend(content) {
|
|
712
|
-
if (typeof content !== "string") throw new
|
|
993
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
713
994
|
this.intro = content + this.intro;
|
|
714
995
|
return this;
|
|
715
996
|
}
|
|
997
|
+
/**
|
|
998
|
+
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
|
|
999
|
+
*/
|
|
716
1000
|
prependLeft(index, content) {
|
|
717
1001
|
index = index + this.offset;
|
|
718
|
-
if (typeof content !== "string") throw new
|
|
1002
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
719
1003
|
this._split(index);
|
|
720
|
-
const chunk = this.byEnd
|
|
1004
|
+
const chunk = this.byEnd.get(index);
|
|
721
1005
|
if (chunk) chunk.prependLeft(content);
|
|
722
1006
|
else this.intro = content + this.intro;
|
|
723
1007
|
return this;
|
|
724
1008
|
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
|
1011
|
+
*/
|
|
725
1012
|
prependRight(index, content) {
|
|
726
1013
|
index = index + this.offset;
|
|
727
|
-
if (typeof content !== "string") throw new
|
|
1014
|
+
if (typeof content !== "string") throw new MagicStringError(`content must be a string, got ${typeof content}`);
|
|
728
1015
|
this._split(index);
|
|
729
|
-
const chunk = this.byStart
|
|
1016
|
+
const chunk = this.byStart.get(index);
|
|
730
1017
|
if (chunk) chunk.prependRight(content);
|
|
731
1018
|
else this.outro = content + this.outro;
|
|
732
1019
|
return this;
|
|
733
1020
|
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
|
1023
|
+
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
|
1024
|
+
*/
|
|
734
1025
|
remove(start, end) {
|
|
735
1026
|
start = start + this.offset;
|
|
736
1027
|
end = end + this.offset;
|
|
737
1028
|
if (this.original.length !== 0) {
|
|
738
|
-
|
|
739
|
-
|
|
1029
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
1030
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
740
1031
|
}
|
|
741
1032
|
if (start === end) return this;
|
|
742
|
-
if (start < 0 || end > this.original.length) throw new
|
|
743
|
-
if (start > end) throw new
|
|
1033
|
+
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
1034
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
744
1035
|
this._split(start);
|
|
745
1036
|
this._split(end);
|
|
746
|
-
let chunk = this.byStart
|
|
1037
|
+
let chunk = this.byStart.get(start);
|
|
747
1038
|
while (chunk) {
|
|
748
1039
|
chunk.intro = "";
|
|
749
1040
|
chunk.outro = "";
|
|
750
1041
|
chunk.edit("");
|
|
751
|
-
chunk = end > chunk.end ? this.byStart
|
|
1042
|
+
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
752
1043
|
}
|
|
753
1044
|
return this;
|
|
754
1045
|
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
|
|
1048
|
+
*/
|
|
755
1049
|
reset(start, end) {
|
|
756
1050
|
start = start + this.offset;
|
|
757
1051
|
end = end + this.offset;
|
|
758
1052
|
if (this.original.length !== 0) {
|
|
759
|
-
|
|
760
|
-
|
|
1053
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
1054
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
761
1055
|
}
|
|
762
1056
|
if (start === end) return this;
|
|
763
|
-
if (start < 0 || end > this.original.length) throw new
|
|
764
|
-
if (start > end) throw new
|
|
1057
|
+
if (start < 0 || end > this.original.length) throw new MagicStringError(`range ${start}–${end} is out of bounds`);
|
|
1058
|
+
if (start > end) throw new MagicStringError(`end must be greater than start (start: ${start}, end: ${end})`);
|
|
765
1059
|
this._split(start);
|
|
766
1060
|
this._split(end);
|
|
767
|
-
let chunk = this.byStart
|
|
1061
|
+
let chunk = this.byStart.get(start);
|
|
768
1062
|
while (chunk) {
|
|
769
1063
|
chunk.reset();
|
|
770
|
-
chunk = end > chunk.end ? this.byStart
|
|
1064
|
+
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
771
1065
|
}
|
|
772
1066
|
return this;
|
|
773
1067
|
}
|
|
774
1068
|
lastChar() {
|
|
775
1069
|
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
776
1070
|
let chunk = this.lastChunk;
|
|
777
|
-
|
|
1071
|
+
while (chunk) {
|
|
778
1072
|
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
779
1073
|
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
780
1074
|
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
781
|
-
|
|
1075
|
+
chunk = chunk.previous;
|
|
1076
|
+
}
|
|
782
1077
|
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
783
1078
|
return "";
|
|
784
1079
|
}
|
|
@@ -787,7 +1082,7 @@ var MagicString = class MagicString {
|
|
|
787
1082
|
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
788
1083
|
let lineStr = this.outro;
|
|
789
1084
|
let chunk = this.lastChunk;
|
|
790
|
-
|
|
1085
|
+
while (chunk) {
|
|
791
1086
|
if (chunk.outro.length > 0) {
|
|
792
1087
|
lineIndex = chunk.outro.lastIndexOf(n);
|
|
793
1088
|
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
@@ -803,17 +1098,22 @@ var MagicString = class MagicString {
|
|
|
803
1098
|
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
804
1099
|
lineStr = chunk.intro + lineStr;
|
|
805
1100
|
}
|
|
806
|
-
|
|
1101
|
+
chunk = chunk.previous;
|
|
1102
|
+
}
|
|
807
1103
|
lineIndex = this.intro.lastIndexOf(n);
|
|
808
1104
|
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
809
1105
|
return this.intro + lineStr;
|
|
810
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
|
|
1109
|
+
* Throws error if the indices are for characters that were already removed.
|
|
1110
|
+
*/
|
|
811
1111
|
slice(start = 0, end = this.original.length - this.offset) {
|
|
812
1112
|
start = start + this.offset;
|
|
813
1113
|
end = end + this.offset;
|
|
814
1114
|
if (this.original.length !== 0) {
|
|
815
|
-
|
|
816
|
-
|
|
1115
|
+
if (start < 0) start = Math.max(0, start + this.original.length);
|
|
1116
|
+
if (end < 0) end = Math.max(0, end + this.original.length);
|
|
817
1117
|
}
|
|
818
1118
|
let result = "";
|
|
819
1119
|
let chunk = this.firstChunk;
|
|
@@ -821,12 +1121,12 @@ var MagicString = class MagicString {
|
|
|
821
1121
|
if (chunk.start < end && chunk.end >= end) return result;
|
|
822
1122
|
chunk = chunk.next;
|
|
823
1123
|
}
|
|
824
|
-
if (chunk && chunk.edited && chunk.start !== start) throw new
|
|
1124
|
+
if (chunk && chunk.edited && chunk.start !== start) throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
825
1125
|
const startChunk = chunk;
|
|
826
1126
|
while (chunk) {
|
|
827
1127
|
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
828
1128
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
829
|
-
if (containsEnd && chunk.edited && chunk.end !== end) throw new
|
|
1129
|
+
if (containsEnd && chunk.edited && chunk.end !== end) throw new MagicStringError(`cannot use edited character ${end} as slice end anchor`);
|
|
830
1130
|
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
831
1131
|
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
832
1132
|
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
@@ -836,37 +1136,45 @@ var MagicString = class MagicString {
|
|
|
836
1136
|
}
|
|
837
1137
|
return result;
|
|
838
1138
|
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
|
1141
|
+
*/
|
|
839
1142
|
snip(start, end) {
|
|
840
1143
|
const clone = this.clone();
|
|
841
1144
|
clone.remove(0, start);
|
|
842
1145
|
clone.remove(end, clone.original.length);
|
|
843
1146
|
return clone;
|
|
844
1147
|
}
|
|
1148
|
+
/** @internal */
|
|
845
1149
|
_split(index) {
|
|
846
|
-
if (this.byStart
|
|
1150
|
+
if (this.byStart.get(index) || this.byEnd.get(index)) return;
|
|
847
1151
|
let chunk = this.lastSearchedChunk;
|
|
848
1152
|
let previousChunk = chunk;
|
|
849
1153
|
const searchForward = index > chunk.end;
|
|
850
1154
|
while (chunk) {
|
|
851
1155
|
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
852
|
-
chunk = searchForward ? this.byStart
|
|
1156
|
+
chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
|
|
853
1157
|
if (chunk === previousChunk) return;
|
|
854
1158
|
previousChunk = chunk;
|
|
855
1159
|
}
|
|
856
1160
|
}
|
|
1161
|
+
/** @internal */
|
|
857
1162
|
_splitChunk(chunk, index) {
|
|
858
1163
|
if (chunk.edited && chunk.content.length) {
|
|
859
1164
|
const loc = getLocator(this.original)(index);
|
|
860
|
-
throw new
|
|
1165
|
+
throw new MagicStringError(`cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
|
|
861
1166
|
}
|
|
862
1167
|
const newChunk = chunk.split(index);
|
|
863
|
-
this.byEnd
|
|
864
|
-
this.byStart
|
|
865
|
-
this.byEnd
|
|
1168
|
+
this.byEnd.set(index, chunk);
|
|
1169
|
+
this.byStart.set(index, newChunk);
|
|
1170
|
+
this.byEnd.set(newChunk.end, newChunk);
|
|
866
1171
|
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
867
1172
|
this.lastSearchedChunk = chunk;
|
|
868
1173
|
return true;
|
|
869
1174
|
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Returns the generated string.
|
|
1177
|
+
*/
|
|
870
1178
|
toString() {
|
|
871
1179
|
let str = this.intro;
|
|
872
1180
|
let chunk = this.firstChunk;
|
|
@@ -876,29 +1184,43 @@ var MagicString = class MagicString {
|
|
|
876
1184
|
}
|
|
877
1185
|
return str + this.outro;
|
|
878
1186
|
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Returns true if the resulting source is empty (disregarding white space).
|
|
1189
|
+
*/
|
|
879
1190
|
isEmpty() {
|
|
1191
|
+
if (this.intro.length && this.intro.trim()) return false;
|
|
880
1192
|
let chunk = this.firstChunk;
|
|
881
|
-
|
|
1193
|
+
while (chunk) {
|
|
882
1194
|
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
883
|
-
|
|
1195
|
+
chunk = chunk.next;
|
|
1196
|
+
}
|
|
1197
|
+
if (this.outro.length && this.outro.trim()) return false;
|
|
884
1198
|
return true;
|
|
885
1199
|
}
|
|
886
1200
|
length() {
|
|
887
1201
|
let chunk = this.firstChunk;
|
|
888
1202
|
let length = 0;
|
|
889
|
-
|
|
1203
|
+
while (chunk) {
|
|
890
1204
|
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
891
|
-
|
|
1205
|
+
chunk = chunk.next;
|
|
1206
|
+
}
|
|
892
1207
|
return length;
|
|
893
1208
|
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Removes empty lines from the start and end.
|
|
1211
|
+
*/
|
|
894
1212
|
trimLines() {
|
|
895
1213
|
return this.trim("[\\r\\n]");
|
|
896
1214
|
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
|
|
1217
|
+
*/
|
|
897
1218
|
trim(charType) {
|
|
898
1219
|
return this.trimStart(charType).trimEnd(charType);
|
|
899
1220
|
}
|
|
1221
|
+
/** @internal */
|
|
900
1222
|
trimEndAborted(charType) {
|
|
901
|
-
const rx = new RegExp(
|
|
1223
|
+
const rx = new RegExp(`${charType || "\\s"}+$`);
|
|
902
1224
|
this.outro = this.outro.replace(rx, "");
|
|
903
1225
|
if (this.outro.length) return true;
|
|
904
1226
|
let chunk = this.lastChunk;
|
|
@@ -907,21 +1229,25 @@ var MagicString = class MagicString {
|
|
|
907
1229
|
const aborted = chunk.trimEnd(rx);
|
|
908
1230
|
if (chunk.end !== end) {
|
|
909
1231
|
if (this.lastChunk === chunk) this.lastChunk = chunk.next;
|
|
910
|
-
this.byEnd
|
|
911
|
-
this.byStart
|
|
912
|
-
this.byEnd
|
|
1232
|
+
this.byEnd.set(chunk.end, chunk);
|
|
1233
|
+
this.byStart.set(chunk.next.start, chunk.next);
|
|
1234
|
+
this.byEnd.set(chunk.next.end, chunk.next);
|
|
913
1235
|
}
|
|
914
1236
|
if (aborted) return true;
|
|
915
1237
|
chunk = chunk.previous;
|
|
916
1238
|
} while (chunk);
|
|
917
1239
|
return false;
|
|
918
1240
|
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
|
1243
|
+
*/
|
|
919
1244
|
trimEnd(charType) {
|
|
920
1245
|
this.trimEndAborted(charType);
|
|
921
1246
|
return this;
|
|
922
1247
|
}
|
|
1248
|
+
/** @internal */
|
|
923
1249
|
trimStartAborted(charType) {
|
|
924
|
-
const rx = new RegExp(
|
|
1250
|
+
const rx = new RegExp(`^${charType || "\\s"}+`);
|
|
925
1251
|
this.intro = this.intro.replace(rx, "");
|
|
926
1252
|
if (this.intro.length) return true;
|
|
927
1253
|
let chunk = this.firstChunk;
|
|
@@ -930,80 +1256,108 @@ var MagicString = class MagicString {
|
|
|
930
1256
|
const aborted = chunk.trimStart(rx);
|
|
931
1257
|
if (chunk.end !== end) {
|
|
932
1258
|
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
933
|
-
this.byEnd
|
|
934
|
-
this.byStart
|
|
935
|
-
this.byEnd
|
|
1259
|
+
this.byEnd.set(chunk.end, chunk);
|
|
1260
|
+
this.byStart.set(chunk.next.start, chunk.next);
|
|
1261
|
+
this.byEnd.set(chunk.next.end, chunk.next);
|
|
936
1262
|
}
|
|
937
1263
|
if (aborted) return true;
|
|
938
1264
|
chunk = chunk.next;
|
|
939
1265
|
} while (chunk);
|
|
940
1266
|
return false;
|
|
941
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
|
1270
|
+
*/
|
|
942
1271
|
trimStart(charType) {
|
|
943
1272
|
this.trimStartAborted(charType);
|
|
944
1273
|
return this;
|
|
945
1274
|
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Indicates if the string has been changed.
|
|
1277
|
+
*/
|
|
946
1278
|
hasChanged() {
|
|
947
|
-
|
|
1279
|
+
if (this.intro || this.outro) return true;
|
|
1280
|
+
let outputIndex = 0;
|
|
1281
|
+
let chunk = this.firstChunk;
|
|
1282
|
+
while (chunk) {
|
|
1283
|
+
if (chunk.intro || chunk.outro) return true;
|
|
1284
|
+
if (!chunk.edited && chunk.start === outputIndex) outputIndex = chunk.end;
|
|
1285
|
+
else {
|
|
1286
|
+
if (!this.original.startsWith(chunk.content, outputIndex)) return true;
|
|
1287
|
+
outputIndex += chunk.content.length;
|
|
1288
|
+
}
|
|
1289
|
+
chunk = chunk.next;
|
|
1290
|
+
}
|
|
1291
|
+
return outputIndex !== this.original.length;
|
|
948
1292
|
}
|
|
1293
|
+
/** @internal */
|
|
949
1294
|
_replaceRegexp(searchValue, replacement) {
|
|
950
1295
|
function getReplacement(match, str) {
|
|
951
|
-
if (typeof replacement === "string") return replacement.
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
if (match.index != null) {
|
|
967
|
-
const replacement = getReplacement(match, this.original);
|
|
968
|
-
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
969
|
-
}
|
|
970
|
-
});
|
|
971
|
-
else {
|
|
1296
|
+
if (typeof replacement === "string") return expandReplacement(replacement, match[0], match.index, str, match.slice(1), match.groups);
|
|
1297
|
+
else return match.groups === void 0 ? replacement(match[0], ...match.slice(1), match.index, str) : replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
1298
|
+
}
|
|
1299
|
+
const replaceMatch = (match) => {
|
|
1300
|
+
/* v8 ignore next 2 -- `match.index` is always defined for matches from `matchAll` */
|
|
1301
|
+
if (match.index == null) return;
|
|
1302
|
+
const replacement = getReplacement(match, this.original);
|
|
1303
|
+
if (replacement === match[0]) return;
|
|
1304
|
+
if (match[0].length === 0) this.appendRight(match.index, replacement);
|
|
1305
|
+
else this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1306
|
+
};
|
|
1307
|
+
if (searchValue.global) {
|
|
1308
|
+
searchValue.lastIndex = 0;
|
|
1309
|
+
for (const match of this.original.matchAll(searchValue)) replaceMatch(match);
|
|
1310
|
+
} else {
|
|
972
1311
|
const match = this.original.match(searchValue);
|
|
973
|
-
if (match
|
|
974
|
-
const replacement = getReplacement(match, this.original);
|
|
975
|
-
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
976
|
-
}
|
|
1312
|
+
if (match) replaceMatch(match);
|
|
977
1313
|
}
|
|
978
1314
|
return this;
|
|
979
1315
|
}
|
|
1316
|
+
/** @internal */
|
|
980
1317
|
_replaceString(string, replacement) {
|
|
981
1318
|
const { original } = this;
|
|
982
1319
|
const index = original.indexOf(string);
|
|
983
1320
|
if (index !== -1) {
|
|
984
1321
|
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
985
|
-
|
|
1322
|
+
else replacement = expandReplacement(replacement, string, index, original, [], void 0);
|
|
1323
|
+
if (string !== replacement) {
|
|
1324
|
+
if (string.length === 0) this.appendRight(index, replacement);
|
|
1325
|
+
else this.overwrite(index, index + string.length, replacement);
|
|
1326
|
+
}
|
|
986
1327
|
}
|
|
987
1328
|
return this;
|
|
988
1329
|
}
|
|
1330
|
+
/**
|
|
1331
|
+
* String replacement with RegExp or string.
|
|
1332
|
+
*/
|
|
989
1333
|
replace(searchValue, replacement) {
|
|
990
1334
|
if (typeof searchValue === "string") return this._replaceString(searchValue, replacement);
|
|
991
1335
|
return this._replaceRegexp(searchValue, replacement);
|
|
992
1336
|
}
|
|
1337
|
+
/** @internal */
|
|
993
1338
|
_replaceAllString(string, replacement) {
|
|
994
1339
|
const { original } = this;
|
|
995
1340
|
const stringLength = string.length;
|
|
1341
|
+
if (stringLength === 0) {
|
|
1342
|
+
for (let index = 0; index <= original.length; index += 1) {
|
|
1343
|
+
const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], void 0);
|
|
1344
|
+
if (_replacement !== "") this.appendRight(index, _replacement);
|
|
1345
|
+
}
|
|
1346
|
+
return this;
|
|
1347
|
+
}
|
|
996
1348
|
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
997
1349
|
const previous = original.slice(index, index + stringLength);
|
|
998
|
-
|
|
999
|
-
if (typeof replacement === "function") _replacement = replacement(previous, index, original);
|
|
1350
|
+
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], void 0);
|
|
1000
1351
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1001
1352
|
}
|
|
1002
1353
|
return this;
|
|
1003
1354
|
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Same as `s.replace`, but replace all matched strings instead of just one.
|
|
1357
|
+
*/
|
|
1004
1358
|
replaceAll(searchValue, replacement) {
|
|
1005
1359
|
if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
|
|
1006
|
-
if (!searchValue.global) throw new
|
|
1360
|
+
if (!searchValue.global) throw new MagicStringError("replaceAll() requires a global RegExp");
|
|
1007
1361
|
return this._replaceRegexp(searchValue, replacement);
|
|
1008
1362
|
}
|
|
1009
1363
|
};
|