void 0.1.6 → 0.7.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/AGENT_PROMPT.md +15 -0
- package/README.md +62 -123
- package/dist/auth-BdsJ0Aff.d.mts +43 -0
- package/dist/auth-cmd-Dx8oPKZC.mjs +43 -0
- package/dist/auth-migrations-BAtAck2g.mjs +117 -0
- package/dist/better-auth-shared-C9_GHSkR.d.mts +71 -0
- package/dist/better-auth-shared-CdYmQGry.mjs +163 -0
- package/dist/cache-W82I8ihI.mjs +47 -0
- package/dist/cancel-deploy-BOBTqqh0.mjs +59 -0
- package/dist/cf-access-Dee5cXxL.mjs +22 -0
- package/dist/chunk-DJd-R1mw.mjs +34 -0
- package/dist/cli/cli.d.mts +1 -0
- package/dist/cli/cli.mjs +1807 -0
- package/dist/client-snXOjrp1.mjs +565 -0
- package/dist/collect-CjeZgz5D.mjs +55 -0
- package/dist/config-BIa9HwVX.mjs +573 -0
- package/dist/config-BzM9Dy7T.mjs +37 -0
- package/dist/config-CvHtTM0q.mjs +30 -0
- package/dist/create-project-BIA15W7z.mjs +90 -0
- package/dist/db-DsRoMcfN.mjs +895 -0
- package/dist/defer-DcxEsVH1.mjs +49 -0
- package/dist/delete-DAP6yDc7.mjs +64 -0
- package/dist/deploy-BPKblFx6.mjs +2424 -0
- package/dist/discover-B7FkXBLB.mjs +40 -0
- package/dist/dist-DUyXJLkq.mjs +2667 -0
- package/dist/dist-Dayj3gCK.mjs +1287 -0
- package/dist/domain-BGofcQ6I.mjs +79 -0
- package/dist/dotenv-DwO4ti0Z.mjs +173 -0
- package/dist/drizzle-NnudE_UN.mjs +232 -0
- package/dist/env-CyG3tvU0.mjs +301 -0
- package/dist/env-helpers-Dr9Y7RnE.d.mts +52 -0
- package/dist/env-raw-BDL4TvdN.mjs +32 -0
- package/dist/env-types-DknSA4SO.mjs +64 -0
- package/dist/env-validation-DJKjR_8q.mjs +163 -0
- package/dist/fetch-error-BQ8sZ5Nd.mjs +266 -0
- package/dist/fetch-error-CVZ5CGA-.d.mts +20 -0
- package/dist/gen-U0Ktr4Zd.mjs +761 -0
- package/dist/handler-B0ds0OHJ.d.mts +269 -0
- package/dist/head-P-egrtFE.d.mts +45 -0
- package/dist/headers-DCXc7mDs.mjs +279 -0
- package/dist/index.d.mts +32 -0
- package/dist/index.mjs +4695 -0
- package/dist/init-C7wS5iGP.mjs +2625 -0
- package/dist/link-p2R6NbgN.mjs +49 -0
- package/dist/list-Bfel-QLc.mjs +113 -0
- package/dist/log-DXdqnmhF.mjs +26 -0
- package/dist/login-CkcXUiIu.mjs +72 -0
- package/dist/logs-DmkrRvx6.mjs +98 -0
- package/dist/magic-string.es-D6g9UnIy.mjs +1011 -0
- package/dist/mcp-CaQzfeUi.mjs +373 -0
- package/dist/node-DDfXj10V.mjs +54 -0
- package/dist/output-BwlcIYSR.mjs +139 -0
- package/dist/pages/client.d.mts +198 -0
- package/dist/pages/client.mjs +980 -0
- package/dist/pages/head-client.d.mts +15 -0
- package/dist/pages/head-client.mjs +90 -0
- package/dist/pages/head.d.mts +2 -0
- package/dist/pages/head.mjs +112 -0
- package/dist/pages/index.d.mts +38 -0
- package/dist/pages/index.mjs +76 -0
- package/dist/pages/islands-plugin.d.mts +50 -0
- package/dist/pages/islands-plugin.mjs +195 -0
- package/dist/pages/prefetch.d.mts +31 -0
- package/dist/pages/prefetch.mjs +90 -0
- package/dist/pages/protocol.d.mts +3 -0
- package/dist/pages/protocol.mjs +193 -0
- package/dist/pages/serialize.d.mts +10 -0
- package/dist/pages/serialize.mjs +14 -0
- package/dist/pathe.M-eThtNZ-D-kmWkCS.mjs +150 -0
- package/dist/plugin-inference-oZ6Ybu2_.mjs +2447 -0
- package/dist/prepare-BAtWufvm.mjs +99 -0
- package/dist/preset-D4I73kT4.mjs +221 -0
- package/dist/project-TqORyHn8.mjs +72 -0
- package/dist/project-cmd-B7lQp3F3.mjs +67 -0
- package/dist/project-slug-CKam8lF9.mjs +11 -0
- package/dist/project-tsconfig-DfkESbDL.mjs +63 -0
- package/dist/protocol-BWzXs2A2.d.mts +34 -0
- package/dist/providers-B3aMxWzP.mjs +67 -0
- package/dist/resolve-project-Br5BR03U.mjs +29 -0
- package/dist/rollback-gyC59l7U.mjs +92 -0
- package/dist/route-types-DReF1gUY.mjs +255 -0
- package/dist/routes-stub.d.mts +55 -0
- package/dist/routes-stub.mjs +1 -0
- package/dist/runner-6Ep3fNQu.mjs +123 -0
- package/dist/runner-pg-D0wWHYnr.mjs +57 -0
- package/dist/runtime/ai.d.mts +127 -0
- package/dist/runtime/ai.mjs +348 -0
- package/dist/runtime/auth-client-react.d.mts +8 -0
- package/dist/runtime/auth-client-react.mjs +6 -0
- package/dist/runtime/auth-client-solid.d.mts +8 -0
- package/dist/runtime/auth-client-solid.mjs +6 -0
- package/dist/runtime/auth-client-svelte.d.mts +8 -0
- package/dist/runtime/auth-client-svelte.mjs +6 -0
- package/dist/runtime/auth-client-vue.d.mts +8 -0
- package/dist/runtime/auth-client-vue.mjs +6 -0
- package/dist/runtime/auth-client.d.mts +8 -0
- package/dist/runtime/auth-client.mjs +6 -0
- package/dist/runtime/auth.d.mts +2 -0
- package/dist/runtime/auth.mjs +22 -0
- package/dist/runtime/better-auth-pg.d.mts +11 -0
- package/dist/runtime/better-auth-pg.mjs +51 -0
- package/dist/runtime/better-auth.d.mts +11 -0
- package/dist/runtime/better-auth.mjs +33 -0
- package/dist/runtime/client.d.mts +6 -0
- package/dist/runtime/client.mjs +5 -0
- package/dist/runtime/db-pg.d.mts +2 -0
- package/dist/runtime/db-pg.mjs +1 -0
- package/dist/runtime/db.d.mts +17 -0
- package/dist/runtime/db.mjs +30 -0
- package/dist/runtime/drizzle-arktype.d.mts +1 -0
- package/dist/runtime/drizzle-arktype.mjs +2 -0
- package/dist/runtime/drizzle-valibot.d.mts +1 -0
- package/dist/runtime/drizzle-valibot.mjs +2 -0
- package/dist/runtime/drizzle-zod.d.mts +1 -0
- package/dist/runtime/drizzle-zod.mjs +2 -0
- package/dist/runtime/env-helpers.d.mts +2 -0
- package/dist/runtime/env-helpers.mjs +173 -0
- package/dist/runtime/env-public-client.d.mts +22 -0
- package/dist/runtime/env-public-client.mjs +54 -0
- package/dist/runtime/env-public.d.mts +143 -0
- package/dist/runtime/env-public.mjs +366 -0
- package/dist/runtime/env.d.mts +13 -0
- package/dist/runtime/env.mjs +51 -0
- package/dist/runtime/fetch-stream.d.mts +51 -0
- package/dist/runtime/fetch-stream.mjs +81 -0
- package/dist/runtime/fetch.d.mts +59 -0
- package/dist/runtime/fetch.mjs +18 -0
- package/dist/runtime/handler.d.mts +3 -0
- package/dist/runtime/handler.mjs +85 -0
- package/dist/runtime/isr.d.mts +26 -0
- package/dist/runtime/isr.mjs +43 -0
- package/dist/runtime/kv.d.mts +48 -0
- package/dist/runtime/kv.mjs +106 -0
- package/dist/runtime/log.d.mts +24 -0
- package/dist/runtime/log.mjs +31 -0
- package/dist/runtime/migration-handler-pg.d.mts +6 -0
- package/dist/runtime/migration-handler-pg.mjs +85 -0
- package/dist/runtime/migration-handler.d.mts +19 -0
- package/dist/runtime/migration-handler.mjs +92 -0
- package/dist/runtime/queues.d.mts +7 -0
- package/dist/runtime/queues.mjs +8 -0
- package/dist/runtime/remote/binding-handler.d.mts +15 -0
- package/dist/runtime/remote/binding-handler.mjs +208 -0
- package/dist/runtime/remote/index.d.mts +8 -0
- package/dist/runtime/remote/index.mjs +461 -0
- package/dist/runtime/response.d.mts +14 -0
- package/dist/runtime/response.mjs +30 -0
- package/dist/runtime/sandbox.d.mts +17 -0
- package/dist/runtime/sandbox.mjs +19 -0
- package/dist/runtime/schema-d1.d.mts +1 -0
- package/dist/runtime/schema-d1.mjs +2 -0
- package/dist/runtime/schema-pg.d.mts +1 -0
- package/dist/runtime/schema-pg.mjs +2 -0
- package/dist/runtime/seed.d.mts +30 -0
- package/dist/runtime/seed.mjs +6 -0
- package/dist/runtime/storage.d.mts +7 -0
- package/dist/runtime/storage.mjs +14 -0
- package/dist/runtime/validator.d.mts +2 -0
- package/dist/runtime/validator.mjs +72 -0
- package/dist/runtime/ws-server.d.mts +26 -0
- package/dist/runtime/ws-server.mjs +296 -0
- package/dist/runtime/ws.d.mts +123 -0
- package/dist/runtime/ws.mjs +103 -0
- package/dist/scan-Ba4hFwlH.mjs +324 -0
- package/dist/scan-C6HMEIdW.mjs +318 -0
- package/dist/secret-CeRSukgM.mjs +109 -0
- package/dist/skills-ipldjlKE.mjs +62 -0
- package/dist/standard-schema-9CRjx-uR.d.mts +42 -0
- package/dist/subcommand-prompt-BKjuNAPb.mjs +349 -0
- package/dist/sveltekit.d.mts +20 -0
- package/dist/sveltekit.mjs +61 -0
- package/dist/types-mHOEwpW4.d.mts +57 -0
- package/dist/validate-CaMavMxu.mjs +146 -0
- package/dist/yarn-pnp-BFqMV_bl.mjs +196 -0
- package/getting-started-prompt.txt +26 -0
- package/package.json +322 -30
- package/schema.json +364 -0
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/SKILL.md +75 -0
- package/skills/void/command/void.md +7 -0
- package/skills/void/docs/guide/ai.md +235 -0
- package/skills/void/docs/guide/app-types.md +103 -0
- package/skills/void/docs/guide/auth.md +257 -0
- package/skills/void/docs/guide/database/d1.md +106 -0
- package/skills/void/docs/guide/database/postgresql.md +106 -0
- package/skills/void/docs/guide/database.md +418 -0
- package/skills/void/docs/guide/deployment.md +98 -0
- package/skills/void/docs/guide/edge/headers.md +79 -0
- package/skills/void/docs/guide/edge/prerendering.md +83 -0
- package/skills/void/docs/guide/edge/redirects.md +116 -0
- package/skills/void/docs/guide/edge/revalidation.md +131 -0
- package/skills/void/docs/guide/edge/rewrites.md +354 -0
- package/skills/void/docs/guide/edge/static-assets.md +72 -0
- package/skills/void/docs/guide/env-vars.md +298 -0
- package/skills/void/docs/guide/index.md +80 -0
- package/skills/void/docs/guide/jobs.md +91 -0
- package/skills/void/docs/guide/kv.md +107 -0
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +419 -0
- package/skills/void/docs/guide/pages-routing/head.md +130 -0
- package/skills/void/docs/guide/pages-routing/islands.md +405 -0
- package/skills/void/docs/guide/pages-routing/layouts.md +362 -0
- package/skills/void/docs/guide/pages-routing/loaders.md +267 -0
- package/skills/void/docs/guide/pages-routing/markdown.md +625 -0
- package/skills/void/docs/guide/pages-routing/overview.md +236 -0
- package/skills/void/docs/guide/pages-routing/view-transitions.md +140 -0
- package/skills/void/docs/guide/queues.md +140 -0
- package/skills/void/docs/guide/quickstart.md +233 -0
- package/skills/void/docs/guide/remote-dev.md +67 -0
- package/skills/void/docs/guide/sandboxes.md +82 -0
- package/skills/void/docs/guide/server-routing.md +246 -0
- package/skills/void/docs/guide/ssg.md +74 -0
- package/skills/void/docs/guide/ssr.md +105 -0
- package/skills/void/docs/guide/storage.md +67 -0
- package/skills/void/docs/guide/type-safety.md +179 -0
- package/skills/void/docs/guide/typed-fetch.md +113 -0
- package/skills/void/docs/guide/websockets.md +190 -0
- package/skills/void/docs/index.md +48 -0
- package/skills/void/docs/integrations/agents.md +84 -0
- package/skills/void/docs/integrations/cloudflare.md +284 -0
- package/skills/void/docs/integrations/frameworks/analog.md +182 -0
- package/skills/void/docs/integrations/frameworks/astro.md +197 -0
- package/skills/void/docs/integrations/frameworks/nuxt.md +164 -0
- package/skills/void/docs/integrations/frameworks/overview.md +136 -0
- package/skills/void/docs/integrations/frameworks/react-router.md +137 -0
- package/skills/void/docs/integrations/frameworks/sveltekit.md +191 -0
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +140 -0
- package/skills/void/docs/integrations/hono.md +97 -0
- package/skills/void/docs/integrations/nodejs-bun-deno.md +210 -0
- package/skills/void/docs/node_modules/@iconify/vue/README.md +408 -0
- package/skills/void/docs/node_modules/@iconify/vue/offline/readme.md +5 -0
- package/skills/void/docs/node_modules/@voidzero-dev/vitepress-theme/README.md +103 -0
- package/skills/void/docs/node_modules/oxc-minify/README.md +78 -0
- package/skills/void/docs/node_modules/reka-ui/README.md +80 -0
- package/skills/void/docs/node_modules/vitepress/README.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/api-examples.md +49 -0
- package/skills/void/docs/node_modules/vitepress/template/index.md +28 -0
- package/skills/void/docs/node_modules/vitepress/template/markdown-examples.md +85 -0
- package/skills/void/docs/node_modules/vitepress-plugin-group-icons/README.md +101 -0
- package/skills/void/docs/node_modules/void/AGENTS.md +204 -0
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +15 -0
- package/skills/void/docs/node_modules/void/README.md +89 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +591 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +375 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +174 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/vite-plugin/README.md +37 -0
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/workers-types/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +189 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/CHANGELOG.md +143 -0
- package/skills/void/docs/node_modules/void/node_modules/@hono/oauth-providers/README.md +1272 -0
- package/skills/void/docs/node_modules/void/node_modules/@napi-rs/keyring/README.md +19 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/better-sqlite3/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@types/pg/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/README.md +22 -0
- package/skills/void/docs/node_modules/void/node_modules/@typescript/native-preview/vendor/vscode-jsonrpc/README.md +69 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/README.md +152 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/engine-javascript/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@shikijs/transformers/README.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/CHANGELOG.md +24 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/gray-matter/README.md +565 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +124 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-anchor/README.md +600 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-attrs/README.md +386 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-container/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-it-emoji/README.md +101 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/shiki/README.md +15 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vue/README.md +58 -0
- package/skills/void/docs/node_modules/void/node_modules/arktype/README.md +165 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/LICENSE.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/better-auth/README.md +32 -0
- package/skills/void/docs/node_modules/void/node_modules/better-sqlite3/README.md +99 -0
- package/skills/void/docs/node_modules/void/node_modules/blake3-jit/README.md +108 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-arktype/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-kit/README.md +79 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-orm/README.md +44 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-valibot/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/drizzle-zod/README.md +65 -0
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +390 -0
- package/skills/void/docs/node_modules/void/node_modules/estree-walker/README.md +48 -0
- package/skills/void/docs/node_modules/void/node_modules/hono/README.md +85 -0
- package/skills/void/docs/node_modules/void/node_modules/ignore/README.md +452 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/CHANGELOG.md +76 -0
- package/{LICENSE → skills/void/docs/node_modules/void/node_modules/jsonc-parser/LICENSE.md} +21 -21
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/README.md +364 -0
- package/skills/void/docs/node_modules/void/node_modules/jsonc-parser/SECURITY.md +41 -0
- package/skills/void/docs/node_modules/void/node_modules/magic-string/README.md +325 -0
- package/skills/void/docs/node_modules/void/node_modules/ofetch/README.md +398 -0
- package/skills/void/docs/node_modules/void/node_modules/pathe/README.md +73 -0
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +95 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/LICENSE.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/pglite-server/README.md +135 -0
- package/skills/void/docs/node_modules/void/node_modules/picocolors/README.md +21 -0
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +25 -0
- package/skills/void/docs/node_modules/void/node_modules/tsdown/README.md +55 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/LICENSE.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/valibot/README.md +94 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/LICENSE.md +2230 -0
- package/skills/void/docs/node_modules/void/node_modules/vite/README.md +20 -0
- package/skills/void/docs/node_modules/void/node_modules/wrangler/README.md +63 -0
- package/skills/void/docs/node_modules/void/node_modules/zod/README.md +191 -0
- package/skills/void/docs/node_modules/void/skills/migrate-vite-cloudflare-to-void/SKILL.md +175 -0
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +75 -0
- package/skills/void/docs/node_modules/void/skills/void/command/void.md +7 -0
- package/skills/void/docs/reference/api.md +917 -0
- package/skills/void/docs/reference/cli.md +561 -0
- package/skills/void/docs/reference/config.md +408 -0
- package/skills/void/docs/reference/resource-inference.md +149 -0
- package/skills/void/docs/reference/structure.md +176 -0
- package/.npmignore +0 -29
- package/.travis.yml +0 -9
- package/favicon.ico +0 -0
- package/index.js +0 -14
- package/lib/Job.js +0 -150
- package/lib/Void.js +0 -99
- package/lib/scan.js +0 -19
- package/test/credentials.js +0 -20
- package/test/job.js +0 -64
- package/test/static/dir1/test6.html +0 -0
- package/test/static/dir2/test7.html +0 -0
- package/test/static/dir2/test8.html +0 -0
- package/test/static/dir2/test9.html +0 -0
- package/test/static/test1.html +0 -0
- package/test/static/test2.html +0 -0
- package/test/static/test3.html +0 -0
- package/test/void.js +0 -31
- /package/{test/static/dir1/test4.html → skills/void/docs/integrations/auth-providers.md} +0 -0
- /package/{test/static/dir1/test5.html → skills/void/docs/integrations/payment-processors.md} +0 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/ofetch@2.0.0-alpha.3/node_modules/ofetch/dist/index.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Joins the given base URL and path, ensuring that there is only one slash between them.
|
|
4
|
+
*/
|
|
5
|
+
function joinURL(base, path) {
|
|
6
|
+
if (!base || base === "/") return path || "/";
|
|
7
|
+
if (!path || path === "/") return base || "/";
|
|
8
|
+
const baseHasTrailing = base[base.length - 1] === "/";
|
|
9
|
+
const pathHasLeading = path[0] === "/";
|
|
10
|
+
if (baseHasTrailing && pathHasLeading) return base + path.slice(1);
|
|
11
|
+
if (!baseHasTrailing && !pathHasLeading) return `${base}/${path}`;
|
|
12
|
+
return base + path;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Adds the base path to the input path, if it is not already present.
|
|
16
|
+
*/
|
|
17
|
+
function withBase(input = "", base = "") {
|
|
18
|
+
if (!base || base === "/") return input;
|
|
19
|
+
const _base = withoutTrailingSlash(base);
|
|
20
|
+
if (input.startsWith(_base)) return input;
|
|
21
|
+
return joinURL(_base, input);
|
|
22
|
+
}
|
|
23
|
+
function withoutTrailingSlash(path) {
|
|
24
|
+
if (!path || path === "/") return "/";
|
|
25
|
+
return path[path.length - 1] === "/" ? path.slice(0, -1) : path;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns the URL with the given query parameters. If a query parameter is undefined, it is omitted.
|
|
29
|
+
*/
|
|
30
|
+
function withQuery(input, query) {
|
|
31
|
+
if (!query || Object.keys(query).length === 0) return input;
|
|
32
|
+
const searchIndex = input.indexOf("?");
|
|
33
|
+
if (searchIndex === -1) {
|
|
34
|
+
const normalizedQuery = Object.entries(query).filter(([, value]) => value !== void 0).flatMap(([key, value]) => {
|
|
35
|
+
if (Array.isArray(value)) return value.map((item) => [key, normalizeQueryValue(item)]);
|
|
36
|
+
return [[key, normalizeQueryValue(value)]];
|
|
37
|
+
});
|
|
38
|
+
const queryString$1 = new URLSearchParams(normalizedQuery).toString();
|
|
39
|
+
return queryString$1 ? `${input}?${queryString$1}` : input;
|
|
40
|
+
}
|
|
41
|
+
const searchParams = new URLSearchParams(input.slice(searchIndex + 1));
|
|
42
|
+
const base = input.slice(0, searchIndex);
|
|
43
|
+
for (const [key, value] of Object.entries(query)) if (value === void 0) searchParams.delete(key);
|
|
44
|
+
else if (Array.isArray(value)) for (const item of value) searchParams.append(key, normalizeQueryValue(item));
|
|
45
|
+
else searchParams.set(key, normalizeQueryValue(value));
|
|
46
|
+
const queryString = searchParams.toString();
|
|
47
|
+
return queryString ? `${base}?${queryString}` : base;
|
|
48
|
+
}
|
|
49
|
+
function normalizeQueryValue(value) {
|
|
50
|
+
if (value === null) return "";
|
|
51
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
52
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
53
|
+
return String(value);
|
|
54
|
+
}
|
|
55
|
+
var FetchError$1 = class extends Error {
|
|
56
|
+
constructor(message, opts) {
|
|
57
|
+
super(message, opts);
|
|
58
|
+
this.name = "FetchError";
|
|
59
|
+
if (opts?.cause && !this.cause) this.cause = opts.cause;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function createFetchError(ctx) {
|
|
63
|
+
const errorMessage = ctx.error?.message || ctx.error?.toString() || "";
|
|
64
|
+
const method = ctx.request?.method || ctx.options?.method || "GET";
|
|
65
|
+
const url = ctx.request?.url || String(ctx.request) || "/";
|
|
66
|
+
const fetchError = new FetchError$1(`${`[${method}] ${JSON.stringify(url)}`}: ${ctx.response ? `${ctx.response.status} ${ctx.response.statusText}` : "<no response>"}${errorMessage ? ` ${errorMessage}` : ""}`, ctx.error ? { cause: ctx.error } : void 0);
|
|
67
|
+
for (const key of [
|
|
68
|
+
"request",
|
|
69
|
+
"options",
|
|
70
|
+
"response"
|
|
71
|
+
]) Object.defineProperty(fetchError, key, { get() {
|
|
72
|
+
return ctx[key];
|
|
73
|
+
} });
|
|
74
|
+
for (const [key, refKey] of [
|
|
75
|
+
["data", "_data"],
|
|
76
|
+
["status", "status"],
|
|
77
|
+
["statusCode", "status"],
|
|
78
|
+
["statusText", "statusText"],
|
|
79
|
+
["statusMessage", "statusText"]
|
|
80
|
+
]) Object.defineProperty(fetchError, key, { get() {
|
|
81
|
+
return ctx.response && ctx.response[refKey];
|
|
82
|
+
} });
|
|
83
|
+
return fetchError;
|
|
84
|
+
}
|
|
85
|
+
const payloadMethods = new Set(Object.freeze([
|
|
86
|
+
"PATCH",
|
|
87
|
+
"POST",
|
|
88
|
+
"PUT",
|
|
89
|
+
"DELETE"
|
|
90
|
+
]));
|
|
91
|
+
function isPayloadMethod(method = "GET") {
|
|
92
|
+
return payloadMethods.has(method.toUpperCase());
|
|
93
|
+
}
|
|
94
|
+
function isJSONSerializable(value) {
|
|
95
|
+
if (value === void 0) return false;
|
|
96
|
+
const t = typeof value;
|
|
97
|
+
if (t === "string" || t === "number" || t === "boolean" || t === null) return true;
|
|
98
|
+
if (t !== "object") return false;
|
|
99
|
+
if (Array.isArray(value)) return true;
|
|
100
|
+
if (value.buffer) return false;
|
|
101
|
+
if (value instanceof FormData || value instanceof URLSearchParams) return false;
|
|
102
|
+
return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
|
|
103
|
+
}
|
|
104
|
+
const textTypes = new Set([
|
|
105
|
+
"image/svg",
|
|
106
|
+
"application/xml",
|
|
107
|
+
"application/xhtml",
|
|
108
|
+
"application/html"
|
|
109
|
+
]);
|
|
110
|
+
const JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
|
|
111
|
+
function detectResponseType(_contentType = "") {
|
|
112
|
+
if (!_contentType) return "json";
|
|
113
|
+
const contentType = _contentType.split(";").shift() || "";
|
|
114
|
+
if (JSON_RE.test(contentType)) return "json";
|
|
115
|
+
if (contentType === "text/event-stream") return "stream";
|
|
116
|
+
if (textTypes.has(contentType) || contentType.startsWith("text/")) return "text";
|
|
117
|
+
return "blob";
|
|
118
|
+
}
|
|
119
|
+
function resolveFetchOptions(request, input, defaults, Headers$1) {
|
|
120
|
+
const headers = mergeHeaders(input?.headers ?? request?.headers, defaults?.headers, Headers$1);
|
|
121
|
+
let query;
|
|
122
|
+
if (defaults?.query || defaults?.params || input?.params || input?.query) query = {
|
|
123
|
+
...defaults?.params,
|
|
124
|
+
...defaults?.query,
|
|
125
|
+
...input?.params,
|
|
126
|
+
...input?.query
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
...defaults,
|
|
130
|
+
...input,
|
|
131
|
+
query,
|
|
132
|
+
params: query,
|
|
133
|
+
headers
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function mergeHeaders(input, defaults, Headers$1) {
|
|
137
|
+
if (!defaults) return new Headers$1(input);
|
|
138
|
+
const headers = new Headers$1(defaults);
|
|
139
|
+
if (input) for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers$1(input)) headers.set(key, value);
|
|
140
|
+
return headers;
|
|
141
|
+
}
|
|
142
|
+
async function callHooks(context, hooks) {
|
|
143
|
+
if (hooks) if (Array.isArray(hooks)) for (const hook of hooks) await hook(context);
|
|
144
|
+
else await hooks(context);
|
|
145
|
+
}
|
|
146
|
+
const retryStatusCodes = new Set([
|
|
147
|
+
408,
|
|
148
|
+
409,
|
|
149
|
+
425,
|
|
150
|
+
429,
|
|
151
|
+
500,
|
|
152
|
+
502,
|
|
153
|
+
503,
|
|
154
|
+
504
|
|
155
|
+
]);
|
|
156
|
+
const nullBodyResponses = new Set([
|
|
157
|
+
101,
|
|
158
|
+
204,
|
|
159
|
+
205,
|
|
160
|
+
304
|
|
161
|
+
]);
|
|
162
|
+
function createFetch(globalOptions = {}) {
|
|
163
|
+
const { fetch: fetch$1 = globalThis.fetch } = globalOptions;
|
|
164
|
+
async function onError(context) {
|
|
165
|
+
const isAbort = context.error && context.error.name === "AbortError" && !context.options.timeout || false;
|
|
166
|
+
if (context.options.retry !== false && !isAbort) {
|
|
167
|
+
let retries;
|
|
168
|
+
if (typeof context.options.retry === "number") retries = context.options.retry;
|
|
169
|
+
else retries = isPayloadMethod(context.options.method) ? 0 : 1;
|
|
170
|
+
const responseCode = context.response && context.response.status || 500;
|
|
171
|
+
if (retries > 0 && (Array.isArray(context.options.retryStatusCodes) ? context.options.retryStatusCodes.includes(responseCode) : retryStatusCodes.has(responseCode))) {
|
|
172
|
+
const retryDelay = typeof context.options.retryDelay === "function" ? context.options.retryDelay(context) : context.options.retryDelay || 0;
|
|
173
|
+
if (retryDelay > 0) await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
174
|
+
return $fetchRaw(context.request, {
|
|
175
|
+
...context.options,
|
|
176
|
+
retry: retries - 1
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const error = createFetchError(context);
|
|
181
|
+
if (Error.captureStackTrace) Error.captureStackTrace(error, $fetchRaw);
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
const $fetchRaw = async function $fetchRaw$1(_request, _options = {}) {
|
|
185
|
+
const context = {
|
|
186
|
+
request: _request,
|
|
187
|
+
options: resolveFetchOptions(_request, _options, globalOptions.defaults, Headers),
|
|
188
|
+
response: void 0,
|
|
189
|
+
error: void 0
|
|
190
|
+
};
|
|
191
|
+
if (context.options.method) context.options.method = context.options.method.toUpperCase();
|
|
192
|
+
if (context.options.onRequest) await callHooks(context, context.options.onRequest);
|
|
193
|
+
if (typeof context.request === "string") {
|
|
194
|
+
if (context.options.baseURL) context.request = withBase(context.request, context.options.baseURL);
|
|
195
|
+
if (context.options.query) {
|
|
196
|
+
context.request = withQuery(context.request, context.options.query);
|
|
197
|
+
delete context.options.query;
|
|
198
|
+
}
|
|
199
|
+
if ("query" in context.options) delete context.options.query;
|
|
200
|
+
if ("params" in context.options) delete context.options.params;
|
|
201
|
+
}
|
|
202
|
+
if (context.options.body && isPayloadMethod(context.options.method)) {
|
|
203
|
+
if (isJSONSerializable(context.options.body)) {
|
|
204
|
+
const contentType = context.options.headers.get("content-type");
|
|
205
|
+
if (typeof context.options.body !== "string") context.options.body = contentType === "application/x-www-form-urlencoded" ? new URLSearchParams(context.options.body).toString() : JSON.stringify(context.options.body);
|
|
206
|
+
context.options.headers = new Headers(context.options.headers || {});
|
|
207
|
+
if (!contentType) context.options.headers.set("content-type", "application/json");
|
|
208
|
+
if (!context.options.headers.has("accept")) context.options.headers.set("accept", "application/json");
|
|
209
|
+
} else if ("pipeTo" in context.options.body && typeof context.options.body.pipeTo === "function" || typeof context.options.body.pipe === "function") {
|
|
210
|
+
if (!("duplex" in context.options)) context.options.duplex = "half";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (context.options.timeout) context.options.signal = context.options.signal ? AbortSignal.any([AbortSignal.timeout(context.options.timeout), context.options.signal]) : AbortSignal.timeout(context.options.timeout);
|
|
214
|
+
try {
|
|
215
|
+
context.response = await fetch$1(context.request, context.options);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
context.error = error;
|
|
218
|
+
if (context.options.onRequestError) await callHooks(context, context.options.onRequestError);
|
|
219
|
+
return await onError(context);
|
|
220
|
+
}
|
|
221
|
+
if ((context.response.body || context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== "HEAD") {
|
|
222
|
+
const responseType = (context.options.parseResponse ? "json" : context.options.responseType) || detectResponseType(context.response.headers.get("content-type") || "");
|
|
223
|
+
switch (responseType) {
|
|
224
|
+
case "json": {
|
|
225
|
+
const data = await context.response.text();
|
|
226
|
+
if (data) {
|
|
227
|
+
const parseFunction = context.options.parseResponse || JSON.parse;
|
|
228
|
+
context.response._data = parseFunction(data);
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case "stream":
|
|
233
|
+
context.response._data = context.response.body || context.response._bodyInit;
|
|
234
|
+
break;
|
|
235
|
+
default: context.response._data = await context.response[responseType]();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (context.options.onResponse) await callHooks(context, context.options.onResponse);
|
|
239
|
+
if (!context.options.ignoreResponseError && context.response.status >= 400 && context.response.status < 600) {
|
|
240
|
+
if (context.options.onResponseError) await callHooks(context, context.options.onResponseError);
|
|
241
|
+
return await onError(context);
|
|
242
|
+
}
|
|
243
|
+
return context.response;
|
|
244
|
+
};
|
|
245
|
+
const $fetch$1 = async function $fetch$2(request, options) {
|
|
246
|
+
return (await $fetchRaw(request, options))._data;
|
|
247
|
+
};
|
|
248
|
+
$fetch$1.raw = $fetchRaw;
|
|
249
|
+
$fetch$1.native = (...args) => fetch$1(...args);
|
|
250
|
+
$fetch$1.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({
|
|
251
|
+
...globalOptions,
|
|
252
|
+
...customGlobalOptions,
|
|
253
|
+
defaults: {
|
|
254
|
+
...globalOptions.defaults,
|
|
255
|
+
...customGlobalOptions.defaults,
|
|
256
|
+
...defaultOptions
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return $fetch$1;
|
|
260
|
+
}
|
|
261
|
+
const ofetch = createFetch({ fetch: globalThis.fetch ? (...args) => globalThis.fetch(...args) : () => Promise.reject(/* @__PURE__ */ new Error("[ofetch] global.fetch is not supported!")) });
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/runtime/fetch-error.ts
|
|
264
|
+
const FetchError = FetchError$1;
|
|
265
|
+
//#endregion
|
|
266
|
+
export { ofetch as n, FetchError as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/runtime/fetch-error.d.ts
|
|
2
|
+
interface FetchResponse<T = unknown> extends Response {
|
|
3
|
+
_data?: T;
|
|
4
|
+
}
|
|
5
|
+
interface FetchError<T = unknown> extends Error {
|
|
6
|
+
request?: RequestInfo;
|
|
7
|
+
options?: RequestInit & Record<string, unknown>;
|
|
8
|
+
response?: FetchResponse<T>;
|
|
9
|
+
data?: T;
|
|
10
|
+
status?: number;
|
|
11
|
+
statusText?: string;
|
|
12
|
+
statusCode?: number;
|
|
13
|
+
statusMessage?: string;
|
|
14
|
+
}
|
|
15
|
+
type FetchErrorConstructor = new <T = unknown>(message: string, opts?: {
|
|
16
|
+
cause: unknown;
|
|
17
|
+
}) => FetchError<T>;
|
|
18
|
+
declare const FetchError: FetchErrorConstructor;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FetchError as t };
|