@desplega.ai/agent-swarm 1.173.0 → 2.0.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/README.md +1 -1
- package/dist/{acp-adapter-ccm9xrep.js → acp-adapter-sj2g0m84.js} +17 -16
- package/dist/{actions-sgeyv08k.js → actions-fegk44gr.js} +39 -34
- package/dist/{amp-adapter-gpxp3kc9.js → amp-adapter-ad8ft89x.js} +8 -7
- package/dist/{app-km9qnv2f.js → app-kfvgbvzy.js} +18 -14
- package/dist/{assistant-5r8tcvvd.js → assistant-z7zdy9ja.js} +40 -35
- package/dist/{boot-reembed-swwzdgd7.js → boot-reembed-5c2z0mbe.js} +10 -9
- package/dist/{boot-reembed-16rv9843.js → boot-reembed-j8xa181e.js} +10 -9
- package/dist/{boot-scrub-sweep-zkr6vkqb.js → boot-scrub-sweep-hnkn3rgt.js} +11 -10
- package/dist/{boot-seeds-d8sp49t2.js → boot-seeds-kwjq4d2z.js} +14 -13
- package/dist/{claude-adapter-yzzzh8jp.js → claude-adapter-9vmvpvgd.js} +19 -18
- package/dist/{claude-managed-adapter-xgxhqrt2.js → claude-managed-adapter-k9qae05j.js} +7 -5
- package/dist/{claude-managed-setup-bnmjarjc.js → claude-managed-setup-q54zx5q2.js} +6 -4
- package/dist/{claude-sdk-session-4whxere4.js → claude-sdk-session-9jye6cxr.js} +11881 -11472
- package/dist/{cli-94b48jhk.js → cli-03gedhng.js} +16 -14
- package/dist/{cli-1w0vj3gw.js → cli-1e4b6bzh.js} +7 -7
- package/dist/{cli-d603qf86.js → cli-29jc5q7w.js} +10 -8
- package/dist/cli-2m1ktfzz.js +17795 -0
- package/dist/{cli-x119kdba.js → cli-3dj8k4vy.js} +1 -1
- package/dist/{cli-srqq3gc5.js → cli-3fbmmawm.js} +5 -5
- package/dist/{cli-gmdajfw5.js → cli-4jxm2qtz.js} +4987 -1708
- package/dist/{cli-tadfgd0t.js → cli-5hkm7whv.js} +33 -4
- package/dist/{cli-42qhyvwx.js → cli-5t4f29ez.js} +3 -3
- package/dist/{cli-7a0sde2x.js → cli-6cagzc96.js} +9 -0
- package/dist/cli-6cvfxs8r.js +47 -0
- package/dist/{cli-0kxf81jj.js → cli-6jyj59nb.js} +2 -2
- package/dist/{cli-w1apjecb.js → cli-6razj6t4.js} +2 -2
- package/dist/{cli-anzdk0z4.js → cli-74ahz61x.js} +2 -2
- package/dist/{cli-m89t9jdf.js → cli-7x0g4sn1.js} +15416 -16024
- package/dist/{cli-yatxqynm.js → cli-9ha6hs2d.js} +1 -290
- package/dist/{cli-81r1wjyv.js → cli-9nfx44eh.js} +1 -1
- package/dist/cli-9traj3dn.js +638 -0
- package/dist/{cli-smcrrmhy.js → cli-agzebbd5.js} +9 -9
- package/dist/{cli-na2pxe4f.js → cli-apx87jne.js} +2 -2
- package/dist/{cli-rfz2ve55.js → cli-bzszjf2p.js} +2855 -862
- package/dist/{cli-c5km5znr.js → cli-c8r3kzzb.js} +1 -1
- package/dist/{cli-hsem16hb.js → cli-cgtksawx.js} +7 -4
- package/dist/{cli-db3m6zdt.js → cli-d2qr7aj4.js} +1 -1
- package/dist/{cli-rfs4vddv.js → cli-d5f9ed5c.js} +5 -5
- package/dist/cli-e3g5mbkz.js +776 -0
- package/dist/{cli-7jykv7ef.js → cli-e6mpjhed.js} +1 -1
- package/dist/{cli-7a93cv8c.js → cli-ee9gtz70.js} +98 -23
- package/dist/{cli-3nxdmjrc.js → cli-eejsgvm4.js} +4 -4
- package/dist/{cli-fmhj1ehj.js → cli-ef1hg1wv.js} +470 -51
- package/dist/cli-f527ce74.js +781 -0
- package/dist/{cli-ppy4nnnh.js → cli-f7kr7svz.js} +2 -2
- package/dist/cli-hjwmhcg1.js +10622 -0
- package/dist/{cli-2bw3w47j.js → cli-hnhtk6cj.js} +1 -1
- package/dist/{cli-ywm1azg9.js → cli-hnmhtzvh.js} +6 -4
- package/dist/{cli-h7k0xtry.js → cli-hvqbtna4.js} +4 -1256
- package/dist/{cli-s8z6x4b4.js → cli-j0pfptdp.js} +218 -102
- package/dist/cli-jta2eyzc.js +619 -0
- package/dist/{cli-5er5gjbm.js → cli-k382tshb.js} +10 -11
- package/dist/{cli-v3zhnxsb.js → cli-k3dp5tpf.js} +2 -2
- package/dist/{cli-wd0hz6ah.js → cli-kbrt8gqa.js} +9 -91
- package/dist/cli-kceah1eh.js +92 -0
- package/dist/{cli-ne7smj1b.js → cli-ke896fcf.js} +10 -10
- package/dist/{cli-xc7p7s3g.js → cli-kt6zqg0e.js} +6 -6
- package/dist/{cli-wrh08zjd.js → cli-m50t4309.js} +5 -18
- package/dist/cli-n2wq4j7m.js +6985 -0
- package/dist/{cli-bv2etw2y.js → cli-n3hzg89b.js} +46 -15
- package/dist/{cli-tmhsxhb8.js → cli-n5vwg842.js} +23 -6
- package/dist/{cli-qm1448f9.js → cli-ne236afy.js} +8 -8
- package/dist/{cli-d161g69q.js → cli-p1x85d2t.js} +50 -2
- package/dist/{cli-7pz3b7x5.js → cli-przpmdgr.js} +25 -0
- package/dist/{cli-0a7mm3zp.js → cli-q0ke1yww.js} +25 -21
- package/dist/{cli-e3pmyt39.js → cli-q50942rs.js} +1 -1
- package/dist/{cli-r44t9wqc.js → cli-r106725k.js} +2 -2
- package/dist/{cli-phcqp1b9.js → cli-r2pnvj8g.js} +2 -2
- package/dist/{cli-jpc4r224.js → cli-r62a35ea.js} +19 -3
- package/dist/{cli-cd0hv9nh.js → cli-ra0xzggj.js} +2 -2
- package/dist/cli-rhs9pz33.js +294 -0
- package/dist/{cli-r4fqfpwf.js → cli-s2sp957d.js} +50 -27
- package/dist/{cli-1x7da0de.js → cli-s4setq91.js} +8 -8
- package/dist/{cli-6thk4jz3.js → cli-se8w6wny.js} +6 -6
- package/dist/cli-skxvvpap.js +10140 -0
- package/dist/{cli-014vns2y.js → cli-stfs0k5s.js} +208 -525
- package/dist/{cli-0p3enk35.js → cli-tqaazemc.js} +9 -1
- package/dist/{cli-nwrdx840.js → cli-tr4sxp68.js} +3 -3
- package/dist/{cli-r0byd61h.js → cli-tsde1hdr.js} +15 -15
- package/dist/{cli-b07hr3bt.js → cli-txqb9s38.js} +2 -2
- package/dist/{cli-6r2f7edk.js → cli-v1yb0rqb.js} +6 -6
- package/dist/{cli-saqyage0.js → cli-vatyhshy.js} +179 -27
- package/dist/{cli-5wpw4rab.js → cli-vdach5a9.js} +5 -5
- package/dist/{cli-7avy4v8w.js → cli-w1q7h2r2.js} +5 -3
- package/dist/{cli-rcp5aqdw.js → cli-w7m81tb7.js} +1 -1
- package/dist/{cli-c3rk1v0x.js → cli-wayw93nt.js} +3 -3
- package/dist/cli-wmgrkscj.js +23254 -0
- package/dist/{cli-9xf7fdtp.js → cli-z5jjpaxw.js} +29 -6
- package/dist/{cli-451ks6aw.js → cli-zkpks3r3.js} +1 -1
- package/dist/cli.js +29 -45
- package/dist/{codex-adapter-r3dn4fp5.js → codex-adapter-y81sssk0.js} +15 -14
- package/dist/{codex-login-841kv5fk.js → codex-login-f2rcfpp9.js} +3 -2
- package/dist/{codex-session-runner-fwt793h4.js → codex-session-runner-8vx4j6a9.js} +15 -14
- package/dist/{commands-z8fq9qna.js → commands-kcpvpcrr.js} +11 -10
- package/dist/{controller-hq5ggpcp.js → controller-ywrmt6yd.js} +5 -4
- package/dist/{controllers-connect-3mf2btyj.js → controllers-connect-kwpvj3rf.js} +42 -37
- package/dist/{cursor-adapter-q8pgv5qa.js → cursor-adapter-cehv1qns.js} +7 -6
- package/dist/{db-yyhqqrbf.js → db-k8ankj20.js} +12 -11
- package/dist/{db-qfpq4bt7.js → db-ww5d7jq3.js} +28 -9
- package/dist/{devin-adapter-xgtj680j.js → devin-adapter-x1022qb1.js} +3 -2
- package/dist/{dispatcher-x0x7qfcq.js → dispatcher-e8gq5m68.js} +38 -33
- package/dist/{docker-f503k9p0.js → docker-ff6y1190.js} +3 -2
- package/dist/{dsh-adapter-34etvb5m.js → dsh-adapter-3epjm3af.js} +7 -6
- package/dist/{e2b-66xra4az.js → e2b-8ygwhg0f.js} +4 -3
- package/dist/{e2b-xwhyj8cw.js → e2b-swhnpw3n.js} +4 -3
- package/dist/{event-bus-vjtv82gm.js → event-bus-6axnngdj.js} +3 -2
- package/dist/{external-channel-h1fjecwe.js → external-channel-h3359cwn.js} +11 -10
- package/dist/{google-generative-ai-szdxbpqg.js → google-generative-ai-g8db7x0f.js} +4 -2
- package/dist/{google-vertex-qzw3p36d.js → google-vertex-r2692q0r.js} +4 -2
- package/dist/{grok-adapter-e7mr287e.js → grok-adapter-0d4x7gkx.js} +18 -17
- package/dist/{handlers-znb9n7d4.js → handlers-an1gzv21.js} +41 -36
- package/dist/{heartbeat-bm4qkn8d.js → heartbeat-6dakeb61.js} +43 -38
- package/dist/{hook-254r4mza.js → hook-6v6cv6d5.js} +11 -23
- package/dist/{hook-xaa3q80s.js → hook-sa5xye4y.js} +12 -11
- package/dist/{http-3dgrgp8y.js → http-r7f3eky0.js} +1499 -251
- package/dist/index-52j1aja4.js +3465 -0
- package/dist/{index-fx3jqq1e.js → index-7ep4gzdk.js} +38 -33
- package/dist/index-9gw58n4k.js +193 -0
- package/dist/index-9j87mcm8.js +56305 -0
- package/dist/index-bsmcresk.js +79424 -0
- package/dist/index-mh85qhec.js +475 -0
- package/dist/{index-g2byveez.js → index-rmpw9a8q.js} +38 -33
- package/dist/{index-2ybk7khy.js → index-s2wxgzr0.js} +468 -683
- package/dist/{index-bdsqa799.js → index-v1v6n7hg.js} +43 -38
- package/dist/index-we27kd31.js +12810 -0
- package/dist/{index-jd7sejm2.js → index-zk96aq1k.js} +10 -9
- package/dist/{keepalive-6ywhpja1.js → keepalive-be9vwy5h.js} +12 -11
- package/dist/{lead-cw45n21s.js → lead-0861cwrf.js} +61 -56
- package/dist/{maintenance-ss1a1ge9.js → maintenance-mzzgc8bn.js} +10 -9
- package/dist/{node-fkajaq96.js → node-mn1zs7an.js} +2 -1
- package/dist/{oauth-refresh-sweep-3c6f8vyy.js → oauth-refresh-sweep-cpdnfwdj.js} +11 -10
- package/dist/{onboard-8hzdhc1k.js → onboard-fh8qs4r3.js} +11 -3
- package/dist/{opencode-adapter-qbchbcfz.js → opencode-adapter-nm42wwj8.js} +18 -13
- package/dist/{otel-impl-e6mnvc4v.js → otel-impl-x6c1c9g4.js} +242 -868
- package/dist/{pi-mono-adapter-3c9g9snh.js → pi-mono-adapter-9n2ya240.js} +244 -106
- package/dist/{pricing-refresh-gedkjdw0.js → pricing-refresh-qb0rv0ap.js} +12 -11
- package/dist/{rbac-roles-dt4vh1yy.js → rbac-roles-1gzdwbh1.js} +11 -10
- package/dist/{rbac-roles-eszdg6pm.js → rbac-roles-3mraey52.js} +12 -11
- package/dist/{render-v2-907cy6sa.js → render-v2-agpa45zz.js} +18 -14
- package/dist/{resume-42stcaz0.js → resume-x0ydy9s9.js} +25 -21
- package/dist/{runtime-qfry88v2.js → runtime-sa2vr16g.js} +2 -2
- package/dist/{setup-adbc1c10.js → setup-as9ga0d6.js} +2 -2
- package/dist/{virtual-modules-rtmt494q.js → virtual-modules-9gkxqrap.js} +6 -5
- package/dist/{work-objects-wpj8ck95.js → work-objects-y5g1y7ev.js} +41 -36
- package/dist/{worker-bzdra9rf.js → worker-860c3e38.js} +61 -56
- package/dist/{x-qfmygqqv.js → x-m477fr0h.js} +3 -2
- package/openapi.json +523 -344
- package/package.json +10 -11
- package/src/be/config-refs.ts +60 -0
- package/src/be/db/page-versions.ts +15 -0
- package/src/be/db/runtime.ts +35 -8
- package/src/be/db/skill-name-resolution.ts +36 -0
- package/src/be/db/tasks/read.ts +230 -0
- package/src/be/db/tasks/write.ts +7 -0
- package/src/be/db.ts +52 -7
- package/src/be/migrations/215_swarm_config_export_to_env.sql +34 -0
- package/src/be/migrations/216_task_resolved_effort.sql +5 -0
- package/src/be/migrations/217_chat_sdk_state.sql +104 -0
- package/src/be/model-catalog-store.ts +5 -1
- package/src/be/model-tier-resolution.ts +12 -1
- package/src/be/model-validation.ts +5 -2
- package/src/be/models-catalog.ts +26 -1
- package/src/be/modelsdev-cache.json +198 -63
- package/src/be/modelsdev-cache.ts +9 -1
- package/src/be/script-credential-broker.ts +39 -2
- package/src/be/scripts/run-saved.ts +1 -0
- package/src/be/scripts/typecheck.ts +10 -8
- package/src/be/seed/runner.ts +13 -1
- package/src/be/seed/state-db.ts +5 -0
- package/src/be/seed/types.ts +6 -0
- package/src/be/seed-pricing.ts +19 -2
- package/src/be/seed-scripts/catalog/ops-catalog-audit.inline.ts +1 -1
- package/src/be/seed-scripts/catalog/ops-catalog-audit.ts +1 -1
- package/src/be/seed-skills/bundled-files.generated.json +0 -18
- package/src/be/seed-skills/index.ts +104 -3
- package/src/be/swarm-config-guard.ts +52 -0
- package/src/cli.tsx +0 -16
- package/src/commands/onboard/non-interactive.ts +4 -2
- package/src/commands/provider-credentials.ts +52 -6
- package/src/commands/runner.ts +190 -54
- package/src/e2b/env.ts +5 -0
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +45 -0
- package/src/extensions/dispatcher.ts +7 -0
- package/src/extensions/post-bridge.ts +40 -0
- package/src/github/handlers.ts +11 -4
- package/src/heartbeat/templates.ts +8 -5
- package/src/hooks/hook.ts +0 -26
- package/src/http/all-routes.ts +0 -1
- package/src/http/config.ts +36 -17
- package/src/http/core.ts +4 -0
- package/src/http/index.ts +14 -2
- package/src/http/integrations.ts +88 -1
- package/src/http/mcp.ts +15 -5
- package/src/http/page-proxy.ts +2 -4
- package/src/http/pages-public.ts +3 -3
- package/src/http/pages.ts +3 -13
- package/src/http/poll.ts +28 -68
- package/src/http/requested-by.ts +54 -0
- package/src/http/scripts.ts +1 -0
- package/src/http/stats.ts +1 -30
- package/src/http/tasks.ts +61 -5
- package/src/http/utils.ts +14 -0
- package/src/http/webhooks.ts +159 -1
- package/src/http/x.ts +1 -0
- package/src/integrations/chat-sdk/adapters.ts +129 -0
- package/src/integrations/chat-sdk/attachments.ts +232 -0
- package/src/integrations/chat-sdk/background.ts +36 -0
- package/src/integrations/chat-sdk/commands.ts +194 -0
- package/src/integrations/chat-sdk/config.ts +198 -0
- package/src/integrations/chat-sdk/discord-api.ts +63 -0
- package/src/integrations/chat-sdk/discord-gateway.ts +185 -0
- package/src/integrations/chat-sdk/handlers.ts +28 -0
- package/src/integrations/chat-sdk/inbound.ts +426 -0
- package/src/integrations/chat-sdk/limits.ts +48 -0
- package/src/integrations/chat-sdk/logger.ts +81 -0
- package/src/integrations/chat-sdk/outbound.ts +123 -0
- package/src/integrations/chat-sdk/relay.ts +172 -0
- package/src/integrations/chat-sdk/router.ts +169 -0
- package/src/integrations/chat-sdk/runtime.ts +351 -0
- package/src/integrations/chat-sdk/schema.ts +245 -0
- package/src/integrations/chat-sdk/state.ts +243 -0
- package/src/integrations/chat-sdk/status.ts +244 -0
- package/src/integrations/chat-sdk/steering.ts +58 -0
- package/src/integrations/chat-sdk/teams-origin.ts +77 -0
- package/src/integrations/chat-sdk/telegram-api.ts +56 -0
- package/src/integrations/chat-sdk/templates.ts +16 -0
- package/src/integrations/chat-sdk/test-hooks.ts +37 -0
- package/src/integrations/chat-sdk/thread-buffer.ts +100 -0
- package/src/integrations/chat-sdk/typing.ts +65 -0
- package/src/pages/version.ts +4 -5
- package/src/prompts/base-prompt.ts +111 -45
- package/src/providers/acp-target-catalog.ts +6 -0
- package/src/providers/acp-targets.ts +55 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +1 -1
- package/src/providers/claude-flag-settings.ts +17 -5
- package/src/providers/claude-managed-adapter.ts +1 -1
- package/src/providers/claude-session-events.ts +6 -1
- package/src/providers/dsh-adapter.ts +1 -1
- package/src/providers/opencode-adapter.ts +243 -26
- package/src/providers/opencode-swarm-plugin.ts +31 -0
- package/src/providers/pi-mono-adapter.ts +398 -153
- package/src/providers/pricing-sources.md +33 -2
- package/src/providers/reasoning-effort.ts +27 -0
- package/src/providers/types.ts +6 -2
- package/src/rbac/legacy-policy.ts +8 -2
- package/src/rbac/permissions.ts +21 -0
- package/src/scheduler/scheduler.ts +4 -2
- package/src/scripts-runtime/loader.ts +19 -7
- package/src/scripts-runtime/sdk-allowlist.ts +8 -6
- package/src/scripts-runtime/swarm-sdk.ts +0 -11
- package/src/scripts-runtime/types/stdlib.d.ts +27 -15
- package/src/scripts-runtime/types/swarm-extension.d.ts +63 -1
- package/src/scripts-runtime/types/swarm-sdk.d.ts +27 -15
- package/src/server.ts +52 -18
- package/src/slack/event-dedup.ts +1 -1
- package/src/tasks/additive-buffer.ts +4 -2
- package/src/tasks/context-key.ts +60 -1
- package/src/tasks/model-pin.ts +67 -0
- package/src/tasks/worker-follow-up.ts +4 -31
- package/src/tests/acp-adapter.test.ts +42 -0
- package/src/tests/api-drain-worker-e2e.test.ts +1 -6
- package/src/tests/base-prompt.test.ts +58 -54
- package/src/tests/chat-sdk-commands.test.ts +191 -0
- package/src/tests/chat-sdk-config.test.ts +334 -0
- package/src/tests/chat-sdk-discord-api.test.ts +68 -0
- package/src/tests/chat-sdk-discord-gateway.test.ts +252 -0
- package/src/tests/chat-sdk-discord-webhook.test.ts +126 -0
- package/src/tests/chat-sdk-fields-sync.test.ts +50 -0
- package/src/tests/chat-sdk-harness.ts +146 -0
- package/src/tests/chat-sdk-inbound.test.ts +363 -0
- package/src/tests/chat-sdk-relay.test.ts +470 -0
- package/src/tests/chat-sdk-reload.test.ts +128 -0
- package/src/tests/chat-sdk-shutdown.test.ts +220 -0
- package/src/tests/chat-sdk-slack.test.ts +268 -0
- package/src/tests/chat-sdk-state.test.ts +163 -0
- package/src/tests/chat-sdk-status-route.test.ts +382 -0
- package/src/tests/chat-sdk-teams.test.ts +277 -0
- package/src/tests/chat-sdk-tools.test.ts +520 -0
- package/src/tests/chat-sdk-typing.test.ts +120 -0
- package/src/tests/chat-sdk-webhook-telegram.test.ts +200 -0
- package/src/tests/claude-adapter-binary.test.ts +9 -4
- package/src/tests/claude-flag-settings.test.ts +11 -3
- package/src/tests/claude-managed-adapter.test.ts +1 -1
- package/src/tests/claude-sdk-lifecycle.test.ts +9 -3
- package/src/tests/claude-thinking-tokens.test.ts +57 -0
- package/src/tests/claude-worker-parity.test.ts +2 -7
- package/src/tests/config-env-export-chat-sdk.test.ts +11 -0
- package/src/tests/config-refs.test.ts +66 -0
- package/src/tests/context-key.test.ts +19 -0
- package/src/tests/cors-allowlist.test.ts +25 -0
- package/src/tests/create-page-tool.test.ts +18 -0
- package/src/tests/credential-check.test.ts +139 -0
- package/src/tests/credentials.test.ts +21 -0
- package/src/tests/db-runtime.test.ts +61 -0
- package/src/tests/db-task-read-contract.test.ts +20 -0
- package/src/tests/db-task-write-contract.test.ts +10 -0
- package/src/tests/docs-index-footprint.test.js +3 -3
- package/src/tests/dsh-adapter.test.ts +1 -1
- package/src/tests/enabled-capabilities.test.ts +20 -0
- package/src/tests/entrypoint-api-readiness.test.ts +14 -8
- package/src/tests/entrypoint-config-env-export.test.ts +5 -2
- package/src/tests/entrypoint-export-to-env.test.ts +78 -0
- package/src/tests/explicit-model-validation.test.ts +105 -1
- package/src/tests/extensions-example-route-chat-channel.test.ts +154 -0
- package/src/tests/extensions-post-bridge.test.ts +51 -0
- package/src/tests/fetch-resolved-env.test.ts +128 -0
- package/src/tests/fixtures/chat-sdk/telegram-private-text.json +10 -0
- package/src/tests/fixtures/extensions/route-chat-channel-to-agent/hooks.ts +27 -0
- package/src/tests/fixtures/extensions/route-chat-channel-to-agent/manifest.json +9 -0
- package/src/tests/fixtures/openai-compatible-registry-extension.child.ts +146 -0
- package/src/tests/fixtures/runner-legacy-resume-prompt.ts +122 -0
- package/src/tests/github-handlers.test.ts +35 -0
- package/src/tests/harness-provider-resolution.test.ts +12 -0
- package/src/tests/heartbeat-checklist.test.ts +3 -2
- package/src/tests/hook-runtime-close.test.ts +0 -2
- package/src/tests/http-api-integration.test.ts +0 -25
- package/src/tests/migration-046-budgets.test.ts +17 -16
- package/src/tests/migration-217-chat-sdk-state.test.ts +113 -0
- package/src/tests/model-tier-resolution.test.ts +93 -0
- package/src/tests/models-catalog.test.ts +42 -1
- package/src/tests/openai-compatible-providers.test.ts +134 -0
- package/src/tests/openai-compatible-registry-extension.test.ts +42 -0
- package/src/tests/opencode-adapter.test.ts +216 -2
- package/src/tests/opencode-helmcode-sdk.test.ts +201 -0
- package/src/tests/opencode-shell-env.test.ts +145 -0
- package/src/tests/openrouter-base-url.test.ts +101 -151
- package/src/tests/page-proxy.test.ts +1 -1
- package/src/tests/pages-browser-sdk.test.ts +76 -0
- package/src/tests/pages-feedback.test.ts +1 -1
- package/src/tests/paused-tasks-requested-by.test.ts +102 -0
- package/src/tests/pi-custom-provider-fake-server.test.ts +442 -0
- package/src/tests/pi-mono-adapter.test.ts +385 -5
- package/src/tests/pi-shell-env.test.ts +170 -0
- package/src/tests/prompt-template-remaining.test.ts +35 -0
- package/src/tests/rbac-engine.test.ts +11 -3
- package/src/tests/runner-exit-after-tasks.test.ts +0 -4
- package/src/tests/runner-legacy-resume-prompt.test.ts +64 -0
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/scripts-http.test.ts +201 -1
- package/src/tests/scripts-only-gating.test.ts +2 -3
- package/src/tests/scripts-runtime.test.ts +58 -40
- package/src/tests/secret-scrubber.test.ts +86 -0
- package/src/tests/seed-skills-bundled-files.test.ts +45 -53
- package/src/tests/seed-skills-retire.test.ts +182 -0
- package/src/tests/send-task-requester-gate.test.ts +58 -0
- package/src/tests/session-cost-recompute-unit.test.ts +46 -0
- package/src/tests/skill-get-name-resolution.test.ts +137 -0
- package/src/tests/sonnet-5-5-registry.test.ts +9 -1
- package/src/tests/swarm-config-export-to-env.test.ts +267 -0
- package/src/tests/swarm-config-reserved-keys.test.ts +16 -0
- package/src/tests/swarm-diff.test.ts +1 -1
- package/src/tests/task-model-effort-rerun.test.ts +164 -0
- package/src/tests/task-session-prompts.test.ts +132 -0
- package/src/tests/task-tool-manifest.test.ts +14 -0
- package/src/tests/task-tools-ctx.test.ts +2 -0
- package/src/tests/tool-annotations.test.ts +6 -6
- package/src/tests/ui-logs-parser.test.ts +43 -0
- package/src/tests/used-by-route.test.ts +6 -0
- package/src/tests/vercel-ai-gateway.test.ts +149 -0
- package/src/tests/workflow-swarm-script.test.ts +38 -0
- package/src/tests/workflow-wait-filter.test.ts +5 -3
- package/src/tools/chat-access.ts +41 -0
- package/src/tools/chat-open-dm.ts +59 -0
- package/src/tools/chat-post.ts +74 -0
- package/src/tools/chat-read-thread.ts +100 -0
- package/src/tools/chat-reply.ts +75 -0
- package/src/tools/create-page.ts +3 -13
- package/src/tools/model-catalog/index.ts +2 -1
- package/src/tools/register-chat-channel.ts +139 -0
- package/src/tools/send-task.ts +24 -0
- package/src/tools/skills/skill-get.ts +17 -9
- package/src/tools/swarm-config/get-config.ts +2 -1
- package/src/tools/swarm-config/list-config.ts +2 -1
- package/src/tools/swarm-config/set-config.ts +16 -3
- package/src/tools/tool-config.ts +8 -6
- package/src/types.ts +12 -2
- package/src/utils/config-env-export.ts +74 -0
- package/src/utils/credentials.test.ts +92 -0
- package/src/utils/credentials.ts +52 -4
- package/src/utils/harness-provider.ts +15 -6
- package/src/utils/runtime-model-catalog.ts +11 -1
- package/src/utils/secret-scrubber.ts +71 -2
- package/src/utils/task-tool-manifest.ts +19 -2
- package/src/workflows/executors/swarm-script.ts +1 -0
- package/templates/skills/agent-browser/SKILL.md +1 -1
- package/templates/skills/agent-browser/content.md +1 -1
- package/templates/skills/apps/SKILL.md +8 -1
- package/templates/skills/apps/content.md +8 -1
- package/templates/skills/chat-sdk/config.json +14 -0
- package/templates/skills/chat-sdk/content.md +84 -0
- package/templates/skills/composio-gmail/content.md +7 -0
- package/templates/skills/composio-google-docs/content.md +1 -1
- package/templates/skills/email-domain-health/config.json +14 -0
- package/templates/skills/email-domain-health/content.md +131 -0
- package/templates/skills/kv-storage/content.md +2 -2
- package/templates/skills/pages/content.md +8 -10
- package/templates/skills/swarm-extensions/content.md +2 -0
- package/templates/skills/swarm-scripts/SKILL.md +4 -2
- package/templates/skills/swarm-scripts/config.json +1 -1
- package/templates/skills/swarm-scripts/content.md +4 -2
- package/templates/skills/workflow-iterate/content.md +38 -0
- package/dist/artifact-eczsknc3.js +0 -3843
- package/dist/cli-bd957dgb.js +0 -153
- package/dist/cli-q51yprfq.js +0 -1104
- package/dist/cli-t1ze64h3.js +0 -811
- package/dist/cli-tcc4wd5d.js +0 -56471
- package/dist/index-9ch1n761.js +0 -1102
- package/src/artifact-sdk/index.ts +0 -2
- package/src/artifact-sdk/localtunnel.d.ts +0 -20
- package/src/artifact-sdk/port.ts +0 -12
- package/src/artifact-sdk/server.ts +0 -183
- package/src/artifact-sdk/tunnel.ts +0 -19
- package/src/commands/artifact.ts +0 -249
- package/src/http/ecosystem.ts +0 -77
- package/src/tests/artifact-commands.test.ts +0 -92
- package/src/tests/artifact-sdk.test.ts +0 -793
- package/src/tests/register-service-security.test.ts +0 -194
- package/src/tools/list-services.ts +0 -107
- package/src/tools/register-service.ts +0 -177
- package/src/tools/unregister-service.ts +0 -73
- package/src/tools/update-service-status.ts +0 -96
- package/templates/skills/artifacts/config.json +0 -14
- package/templates/skills/artifacts/content.md +0 -344
- package/templates/skills/artifacts/files/examples/approval-flow.ts +0 -34
- package/templates/skills/artifacts/files/examples/hono-dashboard.ts +0 -31
- package/templates/skills/artifacts/files/examples/multi-artifact.ts +0 -20
- package/templates/skills/artifacts/files/examples/static-report.sh +0 -17
- /package/src/{artifact-sdk → pages}/browser-sdk.ts +0 -0
- /package/src/{artifact-sdk → pages}/feedback-overlay.ts +0 -0
|
@@ -1,3843 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BROWSER_SDK_JS
|
|
3
|
-
} from "./cli-t1ze64h3.js";
|
|
4
|
-
import {
|
|
5
|
-
require_follow_redirects,
|
|
6
|
-
require_src
|
|
7
|
-
} from "./cli-q51yprfq.js";
|
|
8
|
-
import"./cli-bd957dgb.js";
|
|
9
|
-
import {
|
|
10
|
-
getMcpBaseUrl,
|
|
11
|
-
init_constants
|
|
12
|
-
} from "./cli-gd4favx9.js";
|
|
13
|
-
import"./cli-ej6gbxfb.js";
|
|
14
|
-
import {
|
|
15
|
-
getApiKey,
|
|
16
|
-
init_api_key
|
|
17
|
-
} from "./cli-a1b9b32n.js";
|
|
18
|
-
import {
|
|
19
|
-
__commonJS,
|
|
20
|
-
__require,
|
|
21
|
-
__toESM
|
|
22
|
-
} from "./cli-bc05qbss.js";
|
|
23
|
-
|
|
24
|
-
// node_modules/axios/lib/helpers/bind.js
|
|
25
|
-
var require_bind = __commonJS(function(exports, module) {
|
|
26
|
-
module.exports = function bind(fn, thisArg) {
|
|
27
|
-
return function wrap() {
|
|
28
|
-
var args = new Array(arguments.length);
|
|
29
|
-
for (var i = 0;i < args.length; i++) {
|
|
30
|
-
args[i] = arguments[i];
|
|
31
|
-
}
|
|
32
|
-
return fn.apply(thisArg, args);
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// node_modules/axios/lib/utils.js
|
|
38
|
-
var require_utils = __commonJS(function(exports, module) {
|
|
39
|
-
var bind = require_bind();
|
|
40
|
-
var toString = Object.prototype.toString;
|
|
41
|
-
function isArray(val) {
|
|
42
|
-
return toString.call(val) === "[object Array]";
|
|
43
|
-
}
|
|
44
|
-
function isUndefined(val) {
|
|
45
|
-
return typeof val === "undefined";
|
|
46
|
-
}
|
|
47
|
-
function isBuffer(val) {
|
|
48
|
-
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
|
|
49
|
-
}
|
|
50
|
-
function isArrayBuffer(val) {
|
|
51
|
-
return toString.call(val) === "[object ArrayBuffer]";
|
|
52
|
-
}
|
|
53
|
-
function isFormData(val) {
|
|
54
|
-
return typeof FormData !== "undefined" && val instanceof FormData;
|
|
55
|
-
}
|
|
56
|
-
function isArrayBufferView(val) {
|
|
57
|
-
var result;
|
|
58
|
-
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
59
|
-
result = ArrayBuffer.isView(val);
|
|
60
|
-
} else {
|
|
61
|
-
result = val && val.buffer && val.buffer instanceof ArrayBuffer;
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
function isString(val) {
|
|
66
|
-
return typeof val === "string";
|
|
67
|
-
}
|
|
68
|
-
function isNumber(val) {
|
|
69
|
-
return typeof val === "number";
|
|
70
|
-
}
|
|
71
|
-
function isObject(val) {
|
|
72
|
-
return val !== null && typeof val === "object";
|
|
73
|
-
}
|
|
74
|
-
function isPlainObject(val) {
|
|
75
|
-
if (toString.call(val) !== "[object Object]") {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
var prototype = Object.getPrototypeOf(val);
|
|
79
|
-
return prototype === null || prototype === Object.prototype;
|
|
80
|
-
}
|
|
81
|
-
function isDate(val) {
|
|
82
|
-
return toString.call(val) === "[object Date]";
|
|
83
|
-
}
|
|
84
|
-
function isFile(val) {
|
|
85
|
-
return toString.call(val) === "[object File]";
|
|
86
|
-
}
|
|
87
|
-
function isBlob(val) {
|
|
88
|
-
return toString.call(val) === "[object Blob]";
|
|
89
|
-
}
|
|
90
|
-
function isFunction(val) {
|
|
91
|
-
return toString.call(val) === "[object Function]";
|
|
92
|
-
}
|
|
93
|
-
function isStream(val) {
|
|
94
|
-
return isObject(val) && isFunction(val.pipe);
|
|
95
|
-
}
|
|
96
|
-
function isURLSearchParams(val) {
|
|
97
|
-
return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
|
|
98
|
-
}
|
|
99
|
-
function trim(str) {
|
|
100
|
-
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
|
|
101
|
-
}
|
|
102
|
-
function isStandardBrowserEnv() {
|
|
103
|
-
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
107
|
-
}
|
|
108
|
-
function forEach(obj, fn) {
|
|
109
|
-
if (obj === null || typeof obj === "undefined") {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (typeof obj !== "object") {
|
|
113
|
-
obj = [obj];
|
|
114
|
-
}
|
|
115
|
-
if (isArray(obj)) {
|
|
116
|
-
for (var i = 0, l = obj.length;i < l; i++) {
|
|
117
|
-
fn.call(null, obj[i], i, obj);
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
for (var key in obj) {
|
|
121
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
122
|
-
fn.call(null, obj[key], key, obj);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function merge() {
|
|
128
|
-
var result = {};
|
|
129
|
-
function assignValue(val, key) {
|
|
130
|
-
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
|
131
|
-
result[key] = merge(result[key], val);
|
|
132
|
-
} else if (isPlainObject(val)) {
|
|
133
|
-
result[key] = merge({}, val);
|
|
134
|
-
} else if (isArray(val)) {
|
|
135
|
-
result[key] = val.slice();
|
|
136
|
-
} else {
|
|
137
|
-
result[key] = val;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
for (var i = 0, l = arguments.length;i < l; i++) {
|
|
141
|
-
forEach(arguments[i], assignValue);
|
|
142
|
-
}
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
function extend(a, b, thisArg) {
|
|
146
|
-
forEach(b, function assignValue(val, key) {
|
|
147
|
-
if (thisArg && typeof val === "function") {
|
|
148
|
-
a[key] = bind(val, thisArg);
|
|
149
|
-
} else {
|
|
150
|
-
a[key] = val;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
return a;
|
|
154
|
-
}
|
|
155
|
-
function stripBOM(content) {
|
|
156
|
-
if (content.charCodeAt(0) === 65279) {
|
|
157
|
-
content = content.slice(1);
|
|
158
|
-
}
|
|
159
|
-
return content;
|
|
160
|
-
}
|
|
161
|
-
module.exports = {
|
|
162
|
-
isArray,
|
|
163
|
-
isArrayBuffer,
|
|
164
|
-
isBuffer,
|
|
165
|
-
isFormData,
|
|
166
|
-
isArrayBufferView,
|
|
167
|
-
isString,
|
|
168
|
-
isNumber,
|
|
169
|
-
isObject,
|
|
170
|
-
isPlainObject,
|
|
171
|
-
isUndefined,
|
|
172
|
-
isDate,
|
|
173
|
-
isFile,
|
|
174
|
-
isBlob,
|
|
175
|
-
isFunction,
|
|
176
|
-
isStream,
|
|
177
|
-
isURLSearchParams,
|
|
178
|
-
isStandardBrowserEnv,
|
|
179
|
-
forEach,
|
|
180
|
-
merge,
|
|
181
|
-
extend,
|
|
182
|
-
trim,
|
|
183
|
-
stripBOM
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// node_modules/axios/lib/helpers/buildURL.js
|
|
188
|
-
var require_buildURL = __commonJS(function(exports, module) {
|
|
189
|
-
var utils = require_utils();
|
|
190
|
-
function encode(val) {
|
|
191
|
-
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
192
|
-
}
|
|
193
|
-
module.exports = function buildURL(url, params, paramsSerializer) {
|
|
194
|
-
if (!params) {
|
|
195
|
-
return url;
|
|
196
|
-
}
|
|
197
|
-
var serializedParams;
|
|
198
|
-
if (paramsSerializer) {
|
|
199
|
-
serializedParams = paramsSerializer(params);
|
|
200
|
-
} else if (utils.isURLSearchParams(params)) {
|
|
201
|
-
serializedParams = params.toString();
|
|
202
|
-
} else {
|
|
203
|
-
var parts = [];
|
|
204
|
-
utils.forEach(params, function serialize(val, key) {
|
|
205
|
-
if (val === null || typeof val === "undefined") {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
if (utils.isArray(val)) {
|
|
209
|
-
key = key + "[]";
|
|
210
|
-
} else {
|
|
211
|
-
val = [val];
|
|
212
|
-
}
|
|
213
|
-
utils.forEach(val, function parseValue(v) {
|
|
214
|
-
if (utils.isDate(v)) {
|
|
215
|
-
v = v.toISOString();
|
|
216
|
-
} else if (utils.isObject(v)) {
|
|
217
|
-
v = JSON.stringify(v);
|
|
218
|
-
}
|
|
219
|
-
parts.push(encode(key) + "=" + encode(v));
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
serializedParams = parts.join("&");
|
|
223
|
-
}
|
|
224
|
-
if (serializedParams) {
|
|
225
|
-
var hashmarkIndex = url.indexOf("#");
|
|
226
|
-
if (hashmarkIndex !== -1) {
|
|
227
|
-
url = url.slice(0, hashmarkIndex);
|
|
228
|
-
}
|
|
229
|
-
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
230
|
-
}
|
|
231
|
-
return url;
|
|
232
|
-
};
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
// node_modules/axios/lib/core/InterceptorManager.js
|
|
236
|
-
var require_InterceptorManager = __commonJS(function(exports, module) {
|
|
237
|
-
var utils = require_utils();
|
|
238
|
-
function InterceptorManager() {
|
|
239
|
-
this.handlers = [];
|
|
240
|
-
}
|
|
241
|
-
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
|
|
242
|
-
this.handlers.push({
|
|
243
|
-
fulfilled,
|
|
244
|
-
rejected,
|
|
245
|
-
synchronous: options ? options.synchronous : false,
|
|
246
|
-
runWhen: options ? options.runWhen : null
|
|
247
|
-
});
|
|
248
|
-
return this.handlers.length - 1;
|
|
249
|
-
};
|
|
250
|
-
InterceptorManager.prototype.eject = function eject(id) {
|
|
251
|
-
if (this.handlers[id]) {
|
|
252
|
-
this.handlers[id] = null;
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
InterceptorManager.prototype.forEach = function forEach(fn) {
|
|
256
|
-
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
257
|
-
if (h !== null) {
|
|
258
|
-
fn(h);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
module.exports = InterceptorManager;
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
// node_modules/axios/lib/helpers/normalizeHeaderName.js
|
|
266
|
-
var require_normalizeHeaderName = __commonJS(function(exports, module) {
|
|
267
|
-
var utils = require_utils();
|
|
268
|
-
module.exports = function normalizeHeaderName(headers, normalizedName) {
|
|
269
|
-
utils.forEach(headers, function processHeader(value, name) {
|
|
270
|
-
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
|
271
|
-
headers[normalizedName] = value;
|
|
272
|
-
delete headers[name];
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
// node_modules/axios/lib/core/enhanceError.js
|
|
279
|
-
var require_enhanceError = __commonJS(function(exports, module) {
|
|
280
|
-
module.exports = function enhanceError(error, config, code, request, response) {
|
|
281
|
-
error.config = config;
|
|
282
|
-
if (code) {
|
|
283
|
-
error.code = code;
|
|
284
|
-
}
|
|
285
|
-
error.request = request;
|
|
286
|
-
error.response = response;
|
|
287
|
-
error.isAxiosError = true;
|
|
288
|
-
error.toJSON = function toJSON() {
|
|
289
|
-
return {
|
|
290
|
-
message: this.message,
|
|
291
|
-
name: this.name,
|
|
292
|
-
description: this.description,
|
|
293
|
-
number: this.number,
|
|
294
|
-
fileName: this.fileName,
|
|
295
|
-
lineNumber: this.lineNumber,
|
|
296
|
-
columnNumber: this.columnNumber,
|
|
297
|
-
stack: this.stack,
|
|
298
|
-
config: this.config,
|
|
299
|
-
code: this.code
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
|
-
return error;
|
|
303
|
-
};
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// node_modules/axios/lib/core/createError.js
|
|
307
|
-
var require_createError = __commonJS(function(exports, module) {
|
|
308
|
-
var enhanceError = require_enhanceError();
|
|
309
|
-
module.exports = function createError(message, config, code, request, response) {
|
|
310
|
-
var error = new Error(message);
|
|
311
|
-
return enhanceError(error, config, code, request, response);
|
|
312
|
-
};
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// node_modules/axios/lib/core/settle.js
|
|
316
|
-
var require_settle = __commonJS(function(exports, module) {
|
|
317
|
-
var createError = require_createError();
|
|
318
|
-
module.exports = function settle(resolve, reject, response) {
|
|
319
|
-
var validateStatus = response.config.validateStatus;
|
|
320
|
-
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
321
|
-
resolve(response);
|
|
322
|
-
} else {
|
|
323
|
-
reject(createError("Request failed with status code " + response.status, response.config, null, response.request, response));
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// node_modules/axios/lib/helpers/cookies.js
|
|
329
|
-
var require_cookies = __commonJS(function(exports, module) {
|
|
330
|
-
var utils = require_utils();
|
|
331
|
-
module.exports = utils.isStandardBrowserEnv() ? function standardBrowserEnv() {
|
|
332
|
-
return {
|
|
333
|
-
write: function write2(name, value, expires, path, domain, secure) {
|
|
334
|
-
var cookie = [];
|
|
335
|
-
cookie.push(name + "=" + encodeURIComponent(value));
|
|
336
|
-
if (utils.isNumber(expires)) {
|
|
337
|
-
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
338
|
-
}
|
|
339
|
-
if (utils.isString(path)) {
|
|
340
|
-
cookie.push("path=" + path);
|
|
341
|
-
}
|
|
342
|
-
if (utils.isString(domain)) {
|
|
343
|
-
cookie.push("domain=" + domain);
|
|
344
|
-
}
|
|
345
|
-
if (secure === true) {
|
|
346
|
-
cookie.push("secure");
|
|
347
|
-
}
|
|
348
|
-
document.cookie = cookie.join("; ");
|
|
349
|
-
},
|
|
350
|
-
read: function read(name) {
|
|
351
|
-
var match2 = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
|
|
352
|
-
return match2 ? decodeURIComponent(match2[3]) : null;
|
|
353
|
-
},
|
|
354
|
-
remove: function remove(name) {
|
|
355
|
-
this.write(name, "", Date.now() - 86400000);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
}() : function nonStandardBrowserEnv() {
|
|
359
|
-
return {
|
|
360
|
-
write: function write2() {},
|
|
361
|
-
read: function read() {
|
|
362
|
-
return null;
|
|
363
|
-
},
|
|
364
|
-
remove: function remove() {}
|
|
365
|
-
};
|
|
366
|
-
}();
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
// node_modules/axios/lib/helpers/isAbsoluteURL.js
|
|
370
|
-
var require_isAbsoluteURL = __commonJS(function(exports, module) {
|
|
371
|
-
module.exports = function isAbsoluteURL(url) {
|
|
372
|
-
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
373
|
-
};
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
// node_modules/axios/lib/helpers/combineURLs.js
|
|
377
|
-
var require_combineURLs = __commonJS(function(exports, module) {
|
|
378
|
-
module.exports = function combineURLs(baseURL, relativeURL) {
|
|
379
|
-
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
380
|
-
};
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
// node_modules/axios/lib/core/buildFullPath.js
|
|
384
|
-
var require_buildFullPath = __commonJS(function(exports, module) {
|
|
385
|
-
var isAbsoluteURL = require_isAbsoluteURL();
|
|
386
|
-
var combineURLs = require_combineURLs();
|
|
387
|
-
module.exports = function buildFullPath(baseURL, requestedURL) {
|
|
388
|
-
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
389
|
-
return combineURLs(baseURL, requestedURL);
|
|
390
|
-
}
|
|
391
|
-
return requestedURL;
|
|
392
|
-
};
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// node_modules/axios/lib/helpers/parseHeaders.js
|
|
396
|
-
var require_parseHeaders = __commonJS(function(exports, module) {
|
|
397
|
-
var utils = require_utils();
|
|
398
|
-
var ignoreDuplicateOf = [
|
|
399
|
-
"age",
|
|
400
|
-
"authorization",
|
|
401
|
-
"content-length",
|
|
402
|
-
"content-type",
|
|
403
|
-
"etag",
|
|
404
|
-
"expires",
|
|
405
|
-
"from",
|
|
406
|
-
"host",
|
|
407
|
-
"if-modified-since",
|
|
408
|
-
"if-unmodified-since",
|
|
409
|
-
"last-modified",
|
|
410
|
-
"location",
|
|
411
|
-
"max-forwards",
|
|
412
|
-
"proxy-authorization",
|
|
413
|
-
"referer",
|
|
414
|
-
"retry-after",
|
|
415
|
-
"user-agent"
|
|
416
|
-
];
|
|
417
|
-
module.exports = function parseHeaders(headers) {
|
|
418
|
-
var parsed = {};
|
|
419
|
-
var key;
|
|
420
|
-
var val;
|
|
421
|
-
var i;
|
|
422
|
-
if (!headers) {
|
|
423
|
-
return parsed;
|
|
424
|
-
}
|
|
425
|
-
utils.forEach(headers.split(`
|
|
426
|
-
`), function parser(line) {
|
|
427
|
-
i = line.indexOf(":");
|
|
428
|
-
key = utils.trim(line.substr(0, i)).toLowerCase();
|
|
429
|
-
val = utils.trim(line.substr(i + 1));
|
|
430
|
-
if (key) {
|
|
431
|
-
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (key === "set-cookie") {
|
|
435
|
-
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
436
|
-
} else {
|
|
437
|
-
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
return parsed;
|
|
442
|
-
};
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
// node_modules/axios/lib/helpers/isURLSameOrigin.js
|
|
446
|
-
var require_isURLSameOrigin = __commonJS(function(exports, module) {
|
|
447
|
-
var utils = require_utils();
|
|
448
|
-
module.exports = utils.isStandardBrowserEnv() ? function standardBrowserEnv() {
|
|
449
|
-
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
450
|
-
var urlParsingNode = document.createElement("a");
|
|
451
|
-
var originURL;
|
|
452
|
-
function resolveURL(url) {
|
|
453
|
-
var href = url;
|
|
454
|
-
if (msie) {
|
|
455
|
-
urlParsingNode.setAttribute("href", href);
|
|
456
|
-
href = urlParsingNode.href;
|
|
457
|
-
}
|
|
458
|
-
urlParsingNode.setAttribute("href", href);
|
|
459
|
-
return {
|
|
460
|
-
href: urlParsingNode.href,
|
|
461
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
|
462
|
-
host: urlParsingNode.host,
|
|
463
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
|
464
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
|
465
|
-
hostname: urlParsingNode.hostname,
|
|
466
|
-
port: urlParsingNode.port,
|
|
467
|
-
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
originURL = resolveURL(window.location.href);
|
|
471
|
-
return function isURLSameOrigin(requestURL) {
|
|
472
|
-
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
|
473
|
-
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
|
474
|
-
};
|
|
475
|
-
}() : function nonStandardBrowserEnv() {
|
|
476
|
-
return function isURLSameOrigin() {
|
|
477
|
-
return true;
|
|
478
|
-
};
|
|
479
|
-
}();
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
// node_modules/axios/lib/adapters/xhr.js
|
|
483
|
-
var require_xhr = __commonJS(function(exports, module) {
|
|
484
|
-
var utils = require_utils();
|
|
485
|
-
var settle = require_settle();
|
|
486
|
-
var cookies = require_cookies();
|
|
487
|
-
var buildURL = require_buildURL();
|
|
488
|
-
var buildFullPath = require_buildFullPath();
|
|
489
|
-
var parseHeaders = require_parseHeaders();
|
|
490
|
-
var isURLSameOrigin = require_isURLSameOrigin();
|
|
491
|
-
var createError = require_createError();
|
|
492
|
-
module.exports = function xhrAdapter(config) {
|
|
493
|
-
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
494
|
-
var requestData = config.data;
|
|
495
|
-
var requestHeaders = config.headers;
|
|
496
|
-
var responseType = config.responseType;
|
|
497
|
-
if (utils.isFormData(requestData)) {
|
|
498
|
-
delete requestHeaders["Content-Type"];
|
|
499
|
-
}
|
|
500
|
-
var request = new XMLHttpRequest;
|
|
501
|
-
if (config.auth) {
|
|
502
|
-
var username = config.auth.username || "";
|
|
503
|
-
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
|
504
|
-
requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
|
|
505
|
-
}
|
|
506
|
-
var fullPath = buildFullPath(config.baseURL, config.url);
|
|
507
|
-
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
|
508
|
-
request.timeout = config.timeout;
|
|
509
|
-
function onloadend() {
|
|
510
|
-
if (!request) {
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
var responseHeaders = "getAllResponseHeaders" in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
|
514
|
-
var responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
|
|
515
|
-
var response = {
|
|
516
|
-
data: responseData,
|
|
517
|
-
status: request.status,
|
|
518
|
-
statusText: request.statusText,
|
|
519
|
-
headers: responseHeaders,
|
|
520
|
-
config,
|
|
521
|
-
request
|
|
522
|
-
};
|
|
523
|
-
settle(resolve, reject, response);
|
|
524
|
-
request = null;
|
|
525
|
-
}
|
|
526
|
-
if ("onloadend" in request) {
|
|
527
|
-
request.onloadend = onloadend;
|
|
528
|
-
} else {
|
|
529
|
-
request.onreadystatechange = function handleLoad() {
|
|
530
|
-
if (!request || request.readyState !== 4) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
setTimeout(onloadend);
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
request.onabort = function handleAbort() {
|
|
540
|
-
if (!request) {
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
reject(createError("Request aborted", config, "ECONNABORTED", request));
|
|
544
|
-
request = null;
|
|
545
|
-
};
|
|
546
|
-
request.onerror = function handleError() {
|
|
547
|
-
reject(createError("Network Error", config, null, request));
|
|
548
|
-
request = null;
|
|
549
|
-
};
|
|
550
|
-
request.ontimeout = function handleTimeout() {
|
|
551
|
-
var timeoutErrorMessage = "timeout of " + config.timeout + "ms exceeded";
|
|
552
|
-
if (config.timeoutErrorMessage) {
|
|
553
|
-
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
554
|
-
}
|
|
555
|
-
reject(createError(timeoutErrorMessage, config, config.transitional && config.transitional.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request));
|
|
556
|
-
request = null;
|
|
557
|
-
};
|
|
558
|
-
if (utils.isStandardBrowserEnv()) {
|
|
559
|
-
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : undefined;
|
|
560
|
-
if (xsrfValue) {
|
|
561
|
-
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
if ("setRequestHeader" in request) {
|
|
565
|
-
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
566
|
-
if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
|
|
567
|
-
delete requestHeaders[key];
|
|
568
|
-
} else {
|
|
569
|
-
request.setRequestHeader(key, val);
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
if (!utils.isUndefined(config.withCredentials)) {
|
|
574
|
-
request.withCredentials = !!config.withCredentials;
|
|
575
|
-
}
|
|
576
|
-
if (responseType && responseType !== "json") {
|
|
577
|
-
request.responseType = config.responseType;
|
|
578
|
-
}
|
|
579
|
-
if (typeof config.onDownloadProgress === "function") {
|
|
580
|
-
request.addEventListener("progress", config.onDownloadProgress);
|
|
581
|
-
}
|
|
582
|
-
if (typeof config.onUploadProgress === "function" && request.upload) {
|
|
583
|
-
request.upload.addEventListener("progress", config.onUploadProgress);
|
|
584
|
-
}
|
|
585
|
-
if (config.cancelToken) {
|
|
586
|
-
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
587
|
-
if (!request) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
request.abort();
|
|
591
|
-
reject(cancel);
|
|
592
|
-
request = null;
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
if (!requestData) {
|
|
596
|
-
requestData = null;
|
|
597
|
-
}
|
|
598
|
-
request.send(requestData);
|
|
599
|
-
});
|
|
600
|
-
};
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
// node_modules/axios/package.json
|
|
604
|
-
var require_package = __commonJS(function(exports, module) {
|
|
605
|
-
module.exports = {
|
|
606
|
-
name: "axios",
|
|
607
|
-
version: "0.21.4",
|
|
608
|
-
description: "Promise based HTTP client for the browser and node.js",
|
|
609
|
-
main: "index.js",
|
|
610
|
-
scripts: {
|
|
611
|
-
test: "grunt test",
|
|
612
|
-
start: "node ./sandbox/server.js",
|
|
613
|
-
build: "NODE_ENV=production grunt build",
|
|
614
|
-
preversion: "npm test",
|
|
615
|
-
version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
|
|
616
|
-
postversion: "git push && git push --tags",
|
|
617
|
-
examples: "node ./examples/server.js",
|
|
618
|
-
coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
619
|
-
fix: "eslint --fix lib/**/*.js"
|
|
620
|
-
},
|
|
621
|
-
repository: {
|
|
622
|
-
type: "git",
|
|
623
|
-
url: "https://github.com/axios/axios.git"
|
|
624
|
-
},
|
|
625
|
-
keywords: [
|
|
626
|
-
"xhr",
|
|
627
|
-
"http",
|
|
628
|
-
"ajax",
|
|
629
|
-
"promise",
|
|
630
|
-
"node"
|
|
631
|
-
],
|
|
632
|
-
author: "Matt Zabriskie",
|
|
633
|
-
license: "MIT",
|
|
634
|
-
bugs: {
|
|
635
|
-
url: "https://github.com/axios/axios/issues"
|
|
636
|
-
},
|
|
637
|
-
homepage: "https://axios-http.com",
|
|
638
|
-
devDependencies: {
|
|
639
|
-
coveralls: "^3.0.0",
|
|
640
|
-
"es6-promise": "^4.2.4",
|
|
641
|
-
grunt: "^1.3.0",
|
|
642
|
-
"grunt-banner": "^0.6.0",
|
|
643
|
-
"grunt-cli": "^1.2.0",
|
|
644
|
-
"grunt-contrib-clean": "^1.1.0",
|
|
645
|
-
"grunt-contrib-watch": "^1.0.0",
|
|
646
|
-
"grunt-eslint": "^23.0.0",
|
|
647
|
-
"grunt-karma": "^4.0.0",
|
|
648
|
-
"grunt-mocha-test": "^0.13.3",
|
|
649
|
-
"grunt-ts": "^6.0.0-beta.19",
|
|
650
|
-
"grunt-webpack": "^4.0.2",
|
|
651
|
-
"istanbul-instrumenter-loader": "^1.0.0",
|
|
652
|
-
"jasmine-core": "^2.4.1",
|
|
653
|
-
karma: "^6.3.2",
|
|
654
|
-
"karma-chrome-launcher": "^3.1.0",
|
|
655
|
-
"karma-firefox-launcher": "^2.1.0",
|
|
656
|
-
"karma-jasmine": "^1.1.1",
|
|
657
|
-
"karma-jasmine-ajax": "^0.1.13",
|
|
658
|
-
"karma-safari-launcher": "^1.0.0",
|
|
659
|
-
"karma-sauce-launcher": "^4.3.6",
|
|
660
|
-
"karma-sinon": "^1.0.5",
|
|
661
|
-
"karma-sourcemap-loader": "^0.3.8",
|
|
662
|
-
"karma-webpack": "^4.0.2",
|
|
663
|
-
"load-grunt-tasks": "^3.5.2",
|
|
664
|
-
minimist: "^1.2.0",
|
|
665
|
-
mocha: "^8.2.1",
|
|
666
|
-
sinon: "^4.5.0",
|
|
667
|
-
"terser-webpack-plugin": "^4.2.3",
|
|
668
|
-
typescript: "^4.0.5",
|
|
669
|
-
"url-search-params": "^0.10.0",
|
|
670
|
-
webpack: "^4.44.2",
|
|
671
|
-
"webpack-dev-server": "^3.11.0"
|
|
672
|
-
},
|
|
673
|
-
browser: {
|
|
674
|
-
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
|
675
|
-
},
|
|
676
|
-
jsdelivr: "dist/axios.min.js",
|
|
677
|
-
unpkg: "dist/axios.min.js",
|
|
678
|
-
typings: "./index.d.ts",
|
|
679
|
-
dependencies: {
|
|
680
|
-
"follow-redirects": "^1.14.0"
|
|
681
|
-
},
|
|
682
|
-
bundlesize: [
|
|
683
|
-
{
|
|
684
|
-
path: "./dist/axios.min.js",
|
|
685
|
-
threshold: "5kB"
|
|
686
|
-
}
|
|
687
|
-
]
|
|
688
|
-
};
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
// node_modules/axios/lib/adapters/http.js
|
|
692
|
-
var require_http = __commonJS(function(exports, module) {
|
|
693
|
-
var utils = require_utils();
|
|
694
|
-
var settle = require_settle();
|
|
695
|
-
var buildFullPath = require_buildFullPath();
|
|
696
|
-
var buildURL = require_buildURL();
|
|
697
|
-
var http = __require("http");
|
|
698
|
-
var https = __require("https");
|
|
699
|
-
var httpFollow = require_follow_redirects().http;
|
|
700
|
-
var httpsFollow = require_follow_redirects().https;
|
|
701
|
-
var url = __require("url");
|
|
702
|
-
var zlib = __require("zlib");
|
|
703
|
-
var pkg = require_package();
|
|
704
|
-
var createError = require_createError();
|
|
705
|
-
var enhanceError = require_enhanceError();
|
|
706
|
-
var isHttps = /https:?/;
|
|
707
|
-
function setProxy(options, proxy, location) {
|
|
708
|
-
options.hostname = proxy.host;
|
|
709
|
-
options.host = proxy.host;
|
|
710
|
-
options.port = proxy.port;
|
|
711
|
-
options.path = location;
|
|
712
|
-
if (proxy.auth) {
|
|
713
|
-
var base64 = Buffer.from(proxy.auth.username + ":" + proxy.auth.password, "utf8").toString("base64");
|
|
714
|
-
options.headers["Proxy-Authorization"] = "Basic " + base64;
|
|
715
|
-
}
|
|
716
|
-
options.beforeRedirect = function beforeRedirect(redirection) {
|
|
717
|
-
redirection.headers.host = redirection.host;
|
|
718
|
-
setProxy(redirection, proxy, redirection.href);
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
module.exports = function httpAdapter(config) {
|
|
722
|
-
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
|
723
|
-
var resolve = function resolve2(value) {
|
|
724
|
-
resolvePromise(value);
|
|
725
|
-
};
|
|
726
|
-
var reject = function reject2(value) {
|
|
727
|
-
rejectPromise(value);
|
|
728
|
-
};
|
|
729
|
-
var data = config.data;
|
|
730
|
-
var headers = config.headers;
|
|
731
|
-
if ("User-Agent" in headers || "user-agent" in headers) {
|
|
732
|
-
if (!headers["User-Agent"] && !headers["user-agent"]) {
|
|
733
|
-
delete headers["User-Agent"];
|
|
734
|
-
delete headers["user-agent"];
|
|
735
|
-
}
|
|
736
|
-
} else {
|
|
737
|
-
headers["User-Agent"] = "axios/" + pkg.version;
|
|
738
|
-
}
|
|
739
|
-
if (data && !utils.isStream(data)) {
|
|
740
|
-
if (Buffer.isBuffer(data)) {} else if (utils.isArrayBuffer(data)) {
|
|
741
|
-
data = Buffer.from(new Uint8Array(data));
|
|
742
|
-
} else if (utils.isString(data)) {
|
|
743
|
-
data = Buffer.from(data, "utf-8");
|
|
744
|
-
} else {
|
|
745
|
-
return reject(createError("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream", config));
|
|
746
|
-
}
|
|
747
|
-
headers["Content-Length"] = data.length;
|
|
748
|
-
}
|
|
749
|
-
var auth = undefined;
|
|
750
|
-
if (config.auth) {
|
|
751
|
-
var username = config.auth.username || "";
|
|
752
|
-
var password = config.auth.password || "";
|
|
753
|
-
auth = username + ":" + password;
|
|
754
|
-
}
|
|
755
|
-
var fullPath = buildFullPath(config.baseURL, config.url);
|
|
756
|
-
var parsed = url.parse(fullPath);
|
|
757
|
-
var protocol = parsed.protocol || "http:";
|
|
758
|
-
if (!auth && parsed.auth) {
|
|
759
|
-
var urlAuth = parsed.auth.split(":");
|
|
760
|
-
var urlUsername = urlAuth[0] || "";
|
|
761
|
-
var urlPassword = urlAuth[1] || "";
|
|
762
|
-
auth = urlUsername + ":" + urlPassword;
|
|
763
|
-
}
|
|
764
|
-
if (auth) {
|
|
765
|
-
delete headers.Authorization;
|
|
766
|
-
}
|
|
767
|
-
var isHttpsRequest = isHttps.test(protocol);
|
|
768
|
-
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
769
|
-
var options = {
|
|
770
|
-
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ""),
|
|
771
|
-
method: config.method.toUpperCase(),
|
|
772
|
-
headers,
|
|
773
|
-
agent,
|
|
774
|
-
agents: { http: config.httpAgent, https: config.httpsAgent },
|
|
775
|
-
auth
|
|
776
|
-
};
|
|
777
|
-
if (config.socketPath) {
|
|
778
|
-
options.socketPath = config.socketPath;
|
|
779
|
-
} else {
|
|
780
|
-
options.hostname = parsed.hostname;
|
|
781
|
-
options.port = parsed.port;
|
|
782
|
-
}
|
|
783
|
-
var proxy = config.proxy;
|
|
784
|
-
if (!proxy && proxy !== false) {
|
|
785
|
-
var proxyEnv = protocol.slice(0, -1) + "_proxy";
|
|
786
|
-
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
|
|
787
|
-
if (proxyUrl) {
|
|
788
|
-
var parsedProxyUrl = url.parse(proxyUrl);
|
|
789
|
-
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
|
|
790
|
-
var shouldProxy = true;
|
|
791
|
-
if (noProxyEnv) {
|
|
792
|
-
var noProxy = noProxyEnv.split(",").map(function trim(s) {
|
|
793
|
-
return s.trim();
|
|
794
|
-
});
|
|
795
|
-
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
|
|
796
|
-
if (!proxyElement) {
|
|
797
|
-
return false;
|
|
798
|
-
}
|
|
799
|
-
if (proxyElement === "*") {
|
|
800
|
-
return true;
|
|
801
|
-
}
|
|
802
|
-
if (proxyElement[0] === "." && parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
|
|
803
|
-
return true;
|
|
804
|
-
}
|
|
805
|
-
return parsed.hostname === proxyElement;
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
if (shouldProxy) {
|
|
809
|
-
proxy = {
|
|
810
|
-
host: parsedProxyUrl.hostname,
|
|
811
|
-
port: parsedProxyUrl.port,
|
|
812
|
-
protocol: parsedProxyUrl.protocol
|
|
813
|
-
};
|
|
814
|
-
if (parsedProxyUrl.auth) {
|
|
815
|
-
var proxyUrlAuth = parsedProxyUrl.auth.split(":");
|
|
816
|
-
proxy.auth = {
|
|
817
|
-
username: proxyUrlAuth[0],
|
|
818
|
-
password: proxyUrlAuth[1]
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
if (proxy) {
|
|
825
|
-
options.headers.host = parsed.hostname + (parsed.port ? ":" + parsed.port : "");
|
|
826
|
-
setProxy(options, proxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path);
|
|
827
|
-
}
|
|
828
|
-
var transport;
|
|
829
|
-
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
|
|
830
|
-
if (config.transport) {
|
|
831
|
-
transport = config.transport;
|
|
832
|
-
} else if (config.maxRedirects === 0) {
|
|
833
|
-
transport = isHttpsProxy ? https : http;
|
|
834
|
-
} else {
|
|
835
|
-
if (config.maxRedirects) {
|
|
836
|
-
options.maxRedirects = config.maxRedirects;
|
|
837
|
-
}
|
|
838
|
-
transport = isHttpsProxy ? httpsFollow : httpFollow;
|
|
839
|
-
}
|
|
840
|
-
if (config.maxBodyLength > -1) {
|
|
841
|
-
options.maxBodyLength = config.maxBodyLength;
|
|
842
|
-
}
|
|
843
|
-
var req = transport.request(options, function handleResponse(res) {
|
|
844
|
-
if (req.aborted)
|
|
845
|
-
return;
|
|
846
|
-
var stream = res;
|
|
847
|
-
var lastRequest = res.req || req;
|
|
848
|
-
if (res.statusCode !== 204 && lastRequest.method !== "HEAD" && config.decompress !== false) {
|
|
849
|
-
switch (res.headers["content-encoding"]) {
|
|
850
|
-
case "gzip":
|
|
851
|
-
case "compress":
|
|
852
|
-
case "deflate":
|
|
853
|
-
stream = stream.pipe(zlib.createUnzip());
|
|
854
|
-
delete res.headers["content-encoding"];
|
|
855
|
-
break;
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
var response = {
|
|
859
|
-
status: res.statusCode,
|
|
860
|
-
statusText: res.statusMessage,
|
|
861
|
-
headers: res.headers,
|
|
862
|
-
config,
|
|
863
|
-
request: lastRequest
|
|
864
|
-
};
|
|
865
|
-
if (config.responseType === "stream") {
|
|
866
|
-
response.data = stream;
|
|
867
|
-
settle(resolve, reject, response);
|
|
868
|
-
} else {
|
|
869
|
-
var responseBuffer = [];
|
|
870
|
-
var totalResponseBytes = 0;
|
|
871
|
-
stream.on("data", function handleStreamData(chunk) {
|
|
872
|
-
responseBuffer.push(chunk);
|
|
873
|
-
totalResponseBytes += chunk.length;
|
|
874
|
-
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
|
875
|
-
stream.destroy();
|
|
876
|
-
reject(createError("maxContentLength size of " + config.maxContentLength + " exceeded", config, null, lastRequest));
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
stream.on("error", function handleStreamError(err) {
|
|
880
|
-
if (req.aborted)
|
|
881
|
-
return;
|
|
882
|
-
reject(enhanceError(err, config, null, lastRequest));
|
|
883
|
-
});
|
|
884
|
-
stream.on("end", function handleStreamEnd() {
|
|
885
|
-
var responseData = Buffer.concat(responseBuffer);
|
|
886
|
-
if (config.responseType !== "arraybuffer") {
|
|
887
|
-
responseData = responseData.toString(config.responseEncoding);
|
|
888
|
-
if (!config.responseEncoding || config.responseEncoding === "utf8") {
|
|
889
|
-
responseData = utils.stripBOM(responseData);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
response.data = responseData;
|
|
893
|
-
settle(resolve, reject, response);
|
|
894
|
-
});
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
req.on("error", function handleRequestError(err) {
|
|
898
|
-
if (req.aborted && err.code !== "ERR_FR_TOO_MANY_REDIRECTS")
|
|
899
|
-
return;
|
|
900
|
-
reject(enhanceError(err, config, null, req));
|
|
901
|
-
});
|
|
902
|
-
if (config.timeout) {
|
|
903
|
-
var timeout = parseInt(config.timeout, 10);
|
|
904
|
-
if (isNaN(timeout)) {
|
|
905
|
-
reject(createError("error trying to parse `config.timeout` to int", config, "ERR_PARSE_TIMEOUT", req));
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
req.setTimeout(timeout, function handleRequestTimeout() {
|
|
909
|
-
req.abort();
|
|
910
|
-
reject(createError("timeout of " + timeout + "ms exceeded", config, config.transitional && config.transitional.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", req));
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
if (config.cancelToken) {
|
|
914
|
-
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
915
|
-
if (req.aborted)
|
|
916
|
-
return;
|
|
917
|
-
req.abort();
|
|
918
|
-
reject(cancel);
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
|
-
if (utils.isStream(data)) {
|
|
922
|
-
data.on("error", function handleStreamError(err) {
|
|
923
|
-
reject(enhanceError(err, config, null, req));
|
|
924
|
-
}).pipe(req);
|
|
925
|
-
} else {
|
|
926
|
-
req.end(data);
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
};
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
// node_modules/axios/lib/defaults.js
|
|
933
|
-
var require_defaults = __commonJS(function(exports, module) {
|
|
934
|
-
var utils = require_utils();
|
|
935
|
-
var normalizeHeaderName = require_normalizeHeaderName();
|
|
936
|
-
var enhanceError = require_enhanceError();
|
|
937
|
-
var DEFAULT_CONTENT_TYPE = {
|
|
938
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
939
|
-
};
|
|
940
|
-
function setContentTypeIfUnset(headers, value) {
|
|
941
|
-
if (!utils.isUndefined(headers) && utils.isUndefined(headers["Content-Type"])) {
|
|
942
|
-
headers["Content-Type"] = value;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
function getDefaultAdapter() {
|
|
946
|
-
var adapter;
|
|
947
|
-
if (typeof XMLHttpRequest !== "undefined") {
|
|
948
|
-
adapter = require_xhr();
|
|
949
|
-
} else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
|
|
950
|
-
adapter = require_http();
|
|
951
|
-
}
|
|
952
|
-
return adapter;
|
|
953
|
-
}
|
|
954
|
-
function stringifySafely(rawValue, parser, encoder) {
|
|
955
|
-
if (utils.isString(rawValue)) {
|
|
956
|
-
try {
|
|
957
|
-
(parser || JSON.parse)(rawValue);
|
|
958
|
-
return utils.trim(rawValue);
|
|
959
|
-
} catch (e) {
|
|
960
|
-
if (e.name !== "SyntaxError") {
|
|
961
|
-
throw e;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
return (encoder || JSON.stringify)(rawValue);
|
|
966
|
-
}
|
|
967
|
-
var defaults = {
|
|
968
|
-
transitional: {
|
|
969
|
-
silentJSONParsing: true,
|
|
970
|
-
forcedJSONParsing: true,
|
|
971
|
-
clarifyTimeoutError: false
|
|
972
|
-
},
|
|
973
|
-
adapter: getDefaultAdapter(),
|
|
974
|
-
transformRequest: [function transformRequest(data, headers) {
|
|
975
|
-
normalizeHeaderName(headers, "Accept");
|
|
976
|
-
normalizeHeaderName(headers, "Content-Type");
|
|
977
|
-
if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
|
978
|
-
return data;
|
|
979
|
-
}
|
|
980
|
-
if (utils.isArrayBufferView(data)) {
|
|
981
|
-
return data.buffer;
|
|
982
|
-
}
|
|
983
|
-
if (utils.isURLSearchParams(data)) {
|
|
984
|
-
setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
|
|
985
|
-
return data.toString();
|
|
986
|
-
}
|
|
987
|
-
if (utils.isObject(data) || headers && headers["Content-Type"] === "application/json") {
|
|
988
|
-
setContentTypeIfUnset(headers, "application/json");
|
|
989
|
-
return stringifySafely(data);
|
|
990
|
-
}
|
|
991
|
-
return data;
|
|
992
|
-
}],
|
|
993
|
-
transformResponse: [function transformResponse(data) {
|
|
994
|
-
var transitional = this.transitional;
|
|
995
|
-
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
996
|
-
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
997
|
-
var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
|
|
998
|
-
if (strictJSONParsing || forcedJSONParsing && utils.isString(data) && data.length) {
|
|
999
|
-
try {
|
|
1000
|
-
return JSON.parse(data);
|
|
1001
|
-
} catch (e) {
|
|
1002
|
-
if (strictJSONParsing) {
|
|
1003
|
-
if (e.name === "SyntaxError") {
|
|
1004
|
-
throw enhanceError(e, this, "E_JSON_PARSE");
|
|
1005
|
-
}
|
|
1006
|
-
throw e;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
return data;
|
|
1011
|
-
}],
|
|
1012
|
-
timeout: 0,
|
|
1013
|
-
xsrfCookieName: "XSRF-TOKEN",
|
|
1014
|
-
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
1015
|
-
maxContentLength: -1,
|
|
1016
|
-
maxBodyLength: -1,
|
|
1017
|
-
validateStatus: function validateStatus(status) {
|
|
1018
|
-
return status >= 200 && status < 300;
|
|
1019
|
-
}
|
|
1020
|
-
};
|
|
1021
|
-
defaults.headers = {
|
|
1022
|
-
common: {
|
|
1023
|
-
Accept: "application/json, text/plain, */*"
|
|
1024
|
-
}
|
|
1025
|
-
};
|
|
1026
|
-
utils.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
|
|
1027
|
-
defaults.headers[method] = {};
|
|
1028
|
-
});
|
|
1029
|
-
utils.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
1030
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
1031
|
-
});
|
|
1032
|
-
module.exports = defaults;
|
|
1033
|
-
});
|
|
1034
|
-
|
|
1035
|
-
// node_modules/axios/lib/core/transformData.js
|
|
1036
|
-
var require_transformData = __commonJS(function(exports, module) {
|
|
1037
|
-
var utils = require_utils();
|
|
1038
|
-
var defaults = require_defaults();
|
|
1039
|
-
module.exports = function transformData(data, headers, fns) {
|
|
1040
|
-
var context = this || defaults;
|
|
1041
|
-
utils.forEach(fns, function transform(fn) {
|
|
1042
|
-
data = fn.call(context, data, headers);
|
|
1043
|
-
});
|
|
1044
|
-
return data;
|
|
1045
|
-
};
|
|
1046
|
-
});
|
|
1047
|
-
|
|
1048
|
-
// node_modules/axios/lib/cancel/isCancel.js
|
|
1049
|
-
var require_isCancel = __commonJS(function(exports, module) {
|
|
1050
|
-
module.exports = function isCancel(value) {
|
|
1051
|
-
return !!(value && value.__CANCEL__);
|
|
1052
|
-
};
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
// node_modules/axios/lib/core/dispatchRequest.js
|
|
1056
|
-
var require_dispatchRequest = __commonJS(function(exports, module) {
|
|
1057
|
-
var utils = require_utils();
|
|
1058
|
-
var transformData = require_transformData();
|
|
1059
|
-
var isCancel = require_isCancel();
|
|
1060
|
-
var defaults = require_defaults();
|
|
1061
|
-
function throwIfCancellationRequested(config) {
|
|
1062
|
-
if (config.cancelToken) {
|
|
1063
|
-
config.cancelToken.throwIfRequested();
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
module.exports = function dispatchRequest(config) {
|
|
1067
|
-
throwIfCancellationRequested(config);
|
|
1068
|
-
config.headers = config.headers || {};
|
|
1069
|
-
config.data = transformData.call(config, config.data, config.headers, config.transformRequest);
|
|
1070
|
-
config.headers = utils.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
|
|
1071
|
-
utils.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
|
|
1072
|
-
delete config.headers[method];
|
|
1073
|
-
});
|
|
1074
|
-
var adapter = config.adapter || defaults.adapter;
|
|
1075
|
-
return adapter(config).then(function onAdapterResolution(response) {
|
|
1076
|
-
throwIfCancellationRequested(config);
|
|
1077
|
-
response.data = transformData.call(config, response.data, response.headers, config.transformResponse);
|
|
1078
|
-
return response;
|
|
1079
|
-
}, function onAdapterRejection(reason) {
|
|
1080
|
-
if (!isCancel(reason)) {
|
|
1081
|
-
throwIfCancellationRequested(config);
|
|
1082
|
-
if (reason && reason.response) {
|
|
1083
|
-
reason.response.data = transformData.call(config, reason.response.data, reason.response.headers, config.transformResponse);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
return Promise.reject(reason);
|
|
1087
|
-
});
|
|
1088
|
-
};
|
|
1089
|
-
});
|
|
1090
|
-
|
|
1091
|
-
// node_modules/axios/lib/core/mergeConfig.js
|
|
1092
|
-
var require_mergeConfig = __commonJS(function(exports, module) {
|
|
1093
|
-
var utils = require_utils();
|
|
1094
|
-
module.exports = function mergeConfig(config1, config2) {
|
|
1095
|
-
config2 = config2 || {};
|
|
1096
|
-
var config = {};
|
|
1097
|
-
var valueFromConfig2Keys = ["url", "method", "data"];
|
|
1098
|
-
var mergeDeepPropertiesKeys = ["headers", "auth", "proxy", "params"];
|
|
1099
|
-
var defaultToConfig2Keys = [
|
|
1100
|
-
"baseURL",
|
|
1101
|
-
"transformRequest",
|
|
1102
|
-
"transformResponse",
|
|
1103
|
-
"paramsSerializer",
|
|
1104
|
-
"timeout",
|
|
1105
|
-
"timeoutMessage",
|
|
1106
|
-
"withCredentials",
|
|
1107
|
-
"adapter",
|
|
1108
|
-
"responseType",
|
|
1109
|
-
"xsrfCookieName",
|
|
1110
|
-
"xsrfHeaderName",
|
|
1111
|
-
"onUploadProgress",
|
|
1112
|
-
"onDownloadProgress",
|
|
1113
|
-
"decompress",
|
|
1114
|
-
"maxContentLength",
|
|
1115
|
-
"maxBodyLength",
|
|
1116
|
-
"maxRedirects",
|
|
1117
|
-
"transport",
|
|
1118
|
-
"httpAgent",
|
|
1119
|
-
"httpsAgent",
|
|
1120
|
-
"cancelToken",
|
|
1121
|
-
"socketPath",
|
|
1122
|
-
"responseEncoding"
|
|
1123
|
-
];
|
|
1124
|
-
var directMergeKeys = ["validateStatus"];
|
|
1125
|
-
function getMergedValue(target, source) {
|
|
1126
|
-
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
1127
|
-
return utils.merge(target, source);
|
|
1128
|
-
} else if (utils.isPlainObject(source)) {
|
|
1129
|
-
return utils.merge({}, source);
|
|
1130
|
-
} else if (utils.isArray(source)) {
|
|
1131
|
-
return source.slice();
|
|
1132
|
-
}
|
|
1133
|
-
return source;
|
|
1134
|
-
}
|
|
1135
|
-
function mergeDeepProperties(prop) {
|
|
1136
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
1137
|
-
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
1138
|
-
} else if (!utils.isUndefined(config1[prop])) {
|
|
1139
|
-
config[prop] = getMergedValue(undefined, config1[prop]);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
|
|
1143
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
1144
|
-
config[prop] = getMergedValue(undefined, config2[prop]);
|
|
1145
|
-
}
|
|
1146
|
-
});
|
|
1147
|
-
utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
|
1148
|
-
utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
|
|
1149
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
1150
|
-
config[prop] = getMergedValue(undefined, config2[prop]);
|
|
1151
|
-
} else if (!utils.isUndefined(config1[prop])) {
|
|
1152
|
-
config[prop] = getMergedValue(undefined, config1[prop]);
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
utils.forEach(directMergeKeys, function merge(prop) {
|
|
1156
|
-
if (prop in config2) {
|
|
1157
|
-
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
1158
|
-
} else if (prop in config1) {
|
|
1159
|
-
config[prop] = getMergedValue(undefined, config1[prop]);
|
|
1160
|
-
}
|
|
1161
|
-
});
|
|
1162
|
-
var axiosKeys = valueFromConfig2Keys.concat(mergeDeepPropertiesKeys).concat(defaultToConfig2Keys).concat(directMergeKeys);
|
|
1163
|
-
var otherKeys = Object.keys(config1).concat(Object.keys(config2)).filter(function filterAxiosKeys(key) {
|
|
1164
|
-
return axiosKeys.indexOf(key) === -1;
|
|
1165
|
-
});
|
|
1166
|
-
utils.forEach(otherKeys, mergeDeepProperties);
|
|
1167
|
-
return config;
|
|
1168
|
-
};
|
|
1169
|
-
});
|
|
1170
|
-
|
|
1171
|
-
// node_modules/axios/lib/helpers/validator.js
|
|
1172
|
-
var require_validator = __commonJS(function(exports, module) {
|
|
1173
|
-
var pkg = require_package();
|
|
1174
|
-
var validators = {};
|
|
1175
|
-
["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i) {
|
|
1176
|
-
validators[type] = function validator(thing) {
|
|
1177
|
-
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
1178
|
-
};
|
|
1179
|
-
});
|
|
1180
|
-
var deprecatedWarnings = {};
|
|
1181
|
-
var currentVerArr = pkg.version.split(".");
|
|
1182
|
-
function isOlderVersion(version, thanVersion) {
|
|
1183
|
-
var pkgVersionArr = thanVersion ? thanVersion.split(".") : currentVerArr;
|
|
1184
|
-
var destVer = version.split(".");
|
|
1185
|
-
for (var i = 0;i < 3; i++) {
|
|
1186
|
-
if (pkgVersionArr[i] > destVer[i]) {
|
|
1187
|
-
return true;
|
|
1188
|
-
} else if (pkgVersionArr[i] < destVer[i]) {
|
|
1189
|
-
return false;
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
return false;
|
|
1193
|
-
}
|
|
1194
|
-
validators.transitional = function transitional(validator, version, message) {
|
|
1195
|
-
var isDeprecated = version && isOlderVersion(version);
|
|
1196
|
-
function formatMessage(opt, desc) {
|
|
1197
|
-
return "[Axios v" + pkg.version + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
1198
|
-
}
|
|
1199
|
-
return function(value, opt, opts) {
|
|
1200
|
-
if (validator === false) {
|
|
1201
|
-
throw new Error(formatMessage(opt, " has been removed in " + version));
|
|
1202
|
-
}
|
|
1203
|
-
if (isDeprecated && !deprecatedWarnings[opt]) {
|
|
1204
|
-
deprecatedWarnings[opt] = true;
|
|
1205
|
-
console.warn(formatMessage(opt, " has been deprecated since v" + version + " and will be removed in the near future"));
|
|
1206
|
-
}
|
|
1207
|
-
return validator ? validator(value, opt, opts) : true;
|
|
1208
|
-
};
|
|
1209
|
-
};
|
|
1210
|
-
function assertOptions(options, schema, allowUnknown) {
|
|
1211
|
-
if (typeof options !== "object") {
|
|
1212
|
-
throw new TypeError("options must be an object");
|
|
1213
|
-
}
|
|
1214
|
-
var keys = Object.keys(options);
|
|
1215
|
-
var i = keys.length;
|
|
1216
|
-
while (i-- > 0) {
|
|
1217
|
-
var opt = keys[i];
|
|
1218
|
-
var validator = schema[opt];
|
|
1219
|
-
if (validator) {
|
|
1220
|
-
var value = options[opt];
|
|
1221
|
-
var result = value === undefined || validator(value, opt, options);
|
|
1222
|
-
if (result !== true) {
|
|
1223
|
-
throw new TypeError("option " + opt + " must be " + result);
|
|
1224
|
-
}
|
|
1225
|
-
continue;
|
|
1226
|
-
}
|
|
1227
|
-
if (allowUnknown !== true) {
|
|
1228
|
-
throw Error("Unknown option " + opt);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
module.exports = {
|
|
1233
|
-
isOlderVersion,
|
|
1234
|
-
assertOptions,
|
|
1235
|
-
validators
|
|
1236
|
-
};
|
|
1237
|
-
});
|
|
1238
|
-
|
|
1239
|
-
// node_modules/axios/lib/core/Axios.js
|
|
1240
|
-
var require_Axios = __commonJS(function(exports, module) {
|
|
1241
|
-
var utils = require_utils();
|
|
1242
|
-
var buildURL = require_buildURL();
|
|
1243
|
-
var InterceptorManager = require_InterceptorManager();
|
|
1244
|
-
var dispatchRequest = require_dispatchRequest();
|
|
1245
|
-
var mergeConfig = require_mergeConfig();
|
|
1246
|
-
var validator = require_validator();
|
|
1247
|
-
var validators = validator.validators;
|
|
1248
|
-
function Axios(instanceConfig) {
|
|
1249
|
-
this.defaults = instanceConfig;
|
|
1250
|
-
this.interceptors = {
|
|
1251
|
-
request: new InterceptorManager,
|
|
1252
|
-
response: new InterceptorManager
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
Axios.prototype.request = function request(config) {
|
|
1256
|
-
if (typeof config === "string") {
|
|
1257
|
-
config = arguments[1] || {};
|
|
1258
|
-
config.url = arguments[0];
|
|
1259
|
-
} else {
|
|
1260
|
-
config = config || {};
|
|
1261
|
-
}
|
|
1262
|
-
config = mergeConfig(this.defaults, config);
|
|
1263
|
-
if (config.method) {
|
|
1264
|
-
config.method = config.method.toLowerCase();
|
|
1265
|
-
} else if (this.defaults.method) {
|
|
1266
|
-
config.method = this.defaults.method.toLowerCase();
|
|
1267
|
-
} else {
|
|
1268
|
-
config.method = "get";
|
|
1269
|
-
}
|
|
1270
|
-
var transitional = config.transitional;
|
|
1271
|
-
if (transitional !== undefined) {
|
|
1272
|
-
validator.assertOptions(transitional, {
|
|
1273
|
-
silentJSONParsing: validators.transitional(validators.boolean, "1.0.0"),
|
|
1274
|
-
forcedJSONParsing: validators.transitional(validators.boolean, "1.0.0"),
|
|
1275
|
-
clarifyTimeoutError: validators.transitional(validators.boolean, "1.0.0")
|
|
1276
|
-
}, false);
|
|
1277
|
-
}
|
|
1278
|
-
var requestInterceptorChain = [];
|
|
1279
|
-
var synchronousRequestInterceptors = true;
|
|
1280
|
-
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
1281
|
-
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
1282
|
-
return;
|
|
1283
|
-
}
|
|
1284
|
-
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
1285
|
-
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
1286
|
-
});
|
|
1287
|
-
var responseInterceptorChain = [];
|
|
1288
|
-
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
1289
|
-
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
1290
|
-
});
|
|
1291
|
-
var promise;
|
|
1292
|
-
if (!synchronousRequestInterceptors) {
|
|
1293
|
-
var chain = [dispatchRequest, undefined];
|
|
1294
|
-
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
1295
|
-
chain = chain.concat(responseInterceptorChain);
|
|
1296
|
-
promise = Promise.resolve(config);
|
|
1297
|
-
while (chain.length) {
|
|
1298
|
-
promise = promise.then(chain.shift(), chain.shift());
|
|
1299
|
-
}
|
|
1300
|
-
return promise;
|
|
1301
|
-
}
|
|
1302
|
-
var newConfig = config;
|
|
1303
|
-
while (requestInterceptorChain.length) {
|
|
1304
|
-
var onFulfilled = requestInterceptorChain.shift();
|
|
1305
|
-
var onRejected = requestInterceptorChain.shift();
|
|
1306
|
-
try {
|
|
1307
|
-
newConfig = onFulfilled(newConfig);
|
|
1308
|
-
} catch (error) {
|
|
1309
|
-
onRejected(error);
|
|
1310
|
-
break;
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
try {
|
|
1314
|
-
promise = dispatchRequest(newConfig);
|
|
1315
|
-
} catch (error) {
|
|
1316
|
-
return Promise.reject(error);
|
|
1317
|
-
}
|
|
1318
|
-
while (responseInterceptorChain.length) {
|
|
1319
|
-
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
1320
|
-
}
|
|
1321
|
-
return promise;
|
|
1322
|
-
};
|
|
1323
|
-
Axios.prototype.getUri = function getUri(config) {
|
|
1324
|
-
config = mergeConfig(this.defaults, config);
|
|
1325
|
-
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
1326
|
-
};
|
|
1327
|
-
utils.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
1328
|
-
Axios.prototype[method] = function(url, config) {
|
|
1329
|
-
return this.request(mergeConfig(config || {}, {
|
|
1330
|
-
method,
|
|
1331
|
-
url,
|
|
1332
|
-
data: (config || {}).data
|
|
1333
|
-
}));
|
|
1334
|
-
};
|
|
1335
|
-
});
|
|
1336
|
-
utils.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
1337
|
-
Axios.prototype[method] = function(url, data, config) {
|
|
1338
|
-
return this.request(mergeConfig(config || {}, {
|
|
1339
|
-
method,
|
|
1340
|
-
url,
|
|
1341
|
-
data
|
|
1342
|
-
}));
|
|
1343
|
-
};
|
|
1344
|
-
});
|
|
1345
|
-
module.exports = Axios;
|
|
1346
|
-
});
|
|
1347
|
-
|
|
1348
|
-
// node_modules/axios/lib/cancel/Cancel.js
|
|
1349
|
-
var require_Cancel = __commonJS(function(exports, module) {
|
|
1350
|
-
function Cancel(message) {
|
|
1351
|
-
this.message = message;
|
|
1352
|
-
}
|
|
1353
|
-
Cancel.prototype.toString = function toString() {
|
|
1354
|
-
return "Cancel" + (this.message ? ": " + this.message : "");
|
|
1355
|
-
};
|
|
1356
|
-
Cancel.prototype.__CANCEL__ = true;
|
|
1357
|
-
module.exports = Cancel;
|
|
1358
|
-
});
|
|
1359
|
-
|
|
1360
|
-
// node_modules/axios/lib/cancel/CancelToken.js
|
|
1361
|
-
var require_CancelToken = __commonJS(function(exports, module) {
|
|
1362
|
-
var Cancel = require_Cancel();
|
|
1363
|
-
function CancelToken(executor) {
|
|
1364
|
-
if (typeof executor !== "function") {
|
|
1365
|
-
throw new TypeError("executor must be a function.");
|
|
1366
|
-
}
|
|
1367
|
-
var resolvePromise;
|
|
1368
|
-
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
1369
|
-
resolvePromise = resolve;
|
|
1370
|
-
});
|
|
1371
|
-
var token = this;
|
|
1372
|
-
executor(function cancel(message) {
|
|
1373
|
-
if (token.reason) {
|
|
1374
|
-
return;
|
|
1375
|
-
}
|
|
1376
|
-
token.reason = new Cancel(message);
|
|
1377
|
-
resolvePromise(token.reason);
|
|
1378
|
-
});
|
|
1379
|
-
}
|
|
1380
|
-
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
1381
|
-
if (this.reason) {
|
|
1382
|
-
throw this.reason;
|
|
1383
|
-
}
|
|
1384
|
-
};
|
|
1385
|
-
CancelToken.source = function source() {
|
|
1386
|
-
var cancel;
|
|
1387
|
-
var token = new CancelToken(function executor(c) {
|
|
1388
|
-
cancel = c;
|
|
1389
|
-
});
|
|
1390
|
-
return {
|
|
1391
|
-
token,
|
|
1392
|
-
cancel
|
|
1393
|
-
};
|
|
1394
|
-
};
|
|
1395
|
-
module.exports = CancelToken;
|
|
1396
|
-
});
|
|
1397
|
-
|
|
1398
|
-
// node_modules/axios/lib/helpers/spread.js
|
|
1399
|
-
var require_spread = __commonJS(function(exports, module) {
|
|
1400
|
-
module.exports = function spread(callback) {
|
|
1401
|
-
return function wrap(arr) {
|
|
1402
|
-
return callback.apply(null, arr);
|
|
1403
|
-
};
|
|
1404
|
-
};
|
|
1405
|
-
});
|
|
1406
|
-
|
|
1407
|
-
// node_modules/axios/lib/helpers/isAxiosError.js
|
|
1408
|
-
var require_isAxiosError = __commonJS(function(exports, module) {
|
|
1409
|
-
module.exports = function isAxiosError(payload) {
|
|
1410
|
-
return typeof payload === "object" && payload.isAxiosError === true;
|
|
1411
|
-
};
|
|
1412
|
-
});
|
|
1413
|
-
|
|
1414
|
-
// node_modules/axios/lib/axios.js
|
|
1415
|
-
var require_axios = __commonJS(function(exports, module) {
|
|
1416
|
-
var utils = require_utils();
|
|
1417
|
-
var bind = require_bind();
|
|
1418
|
-
var Axios = require_Axios();
|
|
1419
|
-
var mergeConfig = require_mergeConfig();
|
|
1420
|
-
var defaults = require_defaults();
|
|
1421
|
-
function createInstance(defaultConfig) {
|
|
1422
|
-
var context = new Axios(defaultConfig);
|
|
1423
|
-
var instance = bind(Axios.prototype.request, context);
|
|
1424
|
-
utils.extend(instance, Axios.prototype, context);
|
|
1425
|
-
utils.extend(instance, context);
|
|
1426
|
-
return instance;
|
|
1427
|
-
}
|
|
1428
|
-
var axios = createInstance(defaults);
|
|
1429
|
-
axios.Axios = Axios;
|
|
1430
|
-
axios.create = function create(instanceConfig) {
|
|
1431
|
-
return createInstance(mergeConfig(axios.defaults, instanceConfig));
|
|
1432
|
-
};
|
|
1433
|
-
axios.Cancel = require_Cancel();
|
|
1434
|
-
axios.CancelToken = require_CancelToken();
|
|
1435
|
-
axios.isCancel = require_isCancel();
|
|
1436
|
-
axios.all = function all(promises) {
|
|
1437
|
-
return Promise.all(promises);
|
|
1438
|
-
};
|
|
1439
|
-
axios.spread = require_spread();
|
|
1440
|
-
axios.isAxiosError = require_isAxiosError();
|
|
1441
|
-
module.exports = axios;
|
|
1442
|
-
module.exports.default = axios;
|
|
1443
|
-
});
|
|
1444
|
-
|
|
1445
|
-
// node_modules/@desplega.ai/localtunnel/lib/HeaderHostTransformer.js
|
|
1446
|
-
var require_HeaderHostTransformer = __commonJS(function(exports, module) {
|
|
1447
|
-
var { Transform } = __require("stream");
|
|
1448
|
-
|
|
1449
|
-
class HeaderHostTransformer extends Transform {
|
|
1450
|
-
constructor(opts = {}) {
|
|
1451
|
-
super(opts);
|
|
1452
|
-
this.host = opts.host || "localhost";
|
|
1453
|
-
this.replaced = false;
|
|
1454
|
-
}
|
|
1455
|
-
_transform(data, encoding, callback) {
|
|
1456
|
-
callback(null, this.replaced ? data : data.toString().replace(/(\r\n[Hh]ost: )\S+/, (match2, $1) => {
|
|
1457
|
-
this.replaced = true;
|
|
1458
|
-
return $1 + this.host;
|
|
1459
|
-
}));
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
module.exports = HeaderHostTransformer;
|
|
1463
|
-
});
|
|
1464
|
-
|
|
1465
|
-
// node_modules/@desplega.ai/localtunnel/lib/TunnelCluster.js
|
|
1466
|
-
var require_TunnelCluster = __commonJS(function(exports, module) {
|
|
1467
|
-
var { EventEmitter } = __require("events");
|
|
1468
|
-
var debug = require_src()("localtunnel:client");
|
|
1469
|
-
var fs = __require("fs");
|
|
1470
|
-
var net = __require("net");
|
|
1471
|
-
var tls = __require("tls");
|
|
1472
|
-
var HeaderHostTransformer = require_HeaderHostTransformer();
|
|
1473
|
-
module.exports = class TunnelCluster extends EventEmitter {
|
|
1474
|
-
constructor(opts = {}) {
|
|
1475
|
-
super(opts);
|
|
1476
|
-
this.opts = opts;
|
|
1477
|
-
this.closed = false;
|
|
1478
|
-
this._sockets = new Set;
|
|
1479
|
-
this._localSockets = new Set;
|
|
1480
|
-
this._transformers = new Set;
|
|
1481
|
-
this._timeouts = new Set;
|
|
1482
|
-
}
|
|
1483
|
-
open() {
|
|
1484
|
-
if (this.closed) {
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
const opt = this.opts;
|
|
1488
|
-
const remoteHostOrIp = opt.remote_ip || opt.remote_host;
|
|
1489
|
-
const remotePort = opt.remote_port;
|
|
1490
|
-
const localHost = opt.local_host || "localhost";
|
|
1491
|
-
const localPort = opt.local_port;
|
|
1492
|
-
const localProtocol = opt.local_https ? "https" : "http";
|
|
1493
|
-
const allowInvalidCert = opt.allow_invalid_cert;
|
|
1494
|
-
debug("establishing tunnel %s://%s:%s <> %s:%s", localProtocol, localHost, localPort, remoteHostOrIp, remotePort);
|
|
1495
|
-
const remote = net.connect({
|
|
1496
|
-
host: remoteHostOrIp,
|
|
1497
|
-
port: remotePort
|
|
1498
|
-
});
|
|
1499
|
-
this._sockets.add(remote);
|
|
1500
|
-
remote.once("close", () => this._sockets.delete(remote));
|
|
1501
|
-
remote.setKeepAlive(true);
|
|
1502
|
-
remote.on("error", (err) => {
|
|
1503
|
-
debug("got remote connection error", err.message);
|
|
1504
|
-
if (err.code === "ECONNREFUSED") {
|
|
1505
|
-
this.emit("error", new Error(`connection refused: ${remoteHostOrIp}:${remotePort} (check your firewall settings)`));
|
|
1506
|
-
}
|
|
1507
|
-
remote.end();
|
|
1508
|
-
});
|
|
1509
|
-
const connLocal = () => {
|
|
1510
|
-
if (this.closed) {
|
|
1511
|
-
debug("cluster closed, aborting local connection");
|
|
1512
|
-
remote.destroy();
|
|
1513
|
-
return;
|
|
1514
|
-
}
|
|
1515
|
-
if (remote.destroyed) {
|
|
1516
|
-
debug("remote destroyed");
|
|
1517
|
-
this.emit("dead");
|
|
1518
|
-
return;
|
|
1519
|
-
}
|
|
1520
|
-
debug("connecting locally to %s://%s:%d", localProtocol, localHost, localPort);
|
|
1521
|
-
remote.pause();
|
|
1522
|
-
if (allowInvalidCert) {
|
|
1523
|
-
debug("allowing invalid certificates");
|
|
1524
|
-
}
|
|
1525
|
-
const getLocalCertOpts = () => allowInvalidCert ? { rejectUnauthorized: false } : {
|
|
1526
|
-
cert: fs.readFileSync(opt.local_cert),
|
|
1527
|
-
key: fs.readFileSync(opt.local_key),
|
|
1528
|
-
ca: opt.local_ca ? [fs.readFileSync(opt.local_ca)] : undefined
|
|
1529
|
-
};
|
|
1530
|
-
const local = opt.local_https ? tls.connect({ host: localHost, port: localPort, ...getLocalCertOpts() }) : net.connect({ host: localHost, port: localPort });
|
|
1531
|
-
this._localSockets.add(local);
|
|
1532
|
-
local.once("close", () => this._localSockets.delete(local));
|
|
1533
|
-
const remoteClose = () => {
|
|
1534
|
-
debug("remote close");
|
|
1535
|
-
this.emit("dead");
|
|
1536
|
-
local.end();
|
|
1537
|
-
};
|
|
1538
|
-
remote.once("close", remoteClose);
|
|
1539
|
-
local.once("error", (err) => {
|
|
1540
|
-
debug("local error %s", err.message);
|
|
1541
|
-
local.end();
|
|
1542
|
-
remote.removeListener("close", remoteClose);
|
|
1543
|
-
if (err.code !== "ECONNREFUSED" && err.code !== "ECONNRESET") {
|
|
1544
|
-
return remote.end();
|
|
1545
|
-
}
|
|
1546
|
-
const timeoutId = setTimeout(connLocal, 1000);
|
|
1547
|
-
this._timeouts.add(timeoutId);
|
|
1548
|
-
});
|
|
1549
|
-
local.once("connect", () => {
|
|
1550
|
-
debug("connected locally");
|
|
1551
|
-
remote.resume();
|
|
1552
|
-
let stream = remote;
|
|
1553
|
-
if (opt.local_host) {
|
|
1554
|
-
debug("transform Host header to %s", opt.local_host);
|
|
1555
|
-
const transformer = new HeaderHostTransformer({ host: opt.local_host });
|
|
1556
|
-
this._transformers.add(transformer);
|
|
1557
|
-
transformer.once("close", () => this._transformers.delete(transformer));
|
|
1558
|
-
stream = remote.pipe(transformer);
|
|
1559
|
-
}
|
|
1560
|
-
stream.pipe(local).pipe(remote);
|
|
1561
|
-
local.once("close", (hadError) => {
|
|
1562
|
-
debug("local connection closed [%s]", hadError);
|
|
1563
|
-
});
|
|
1564
|
-
});
|
|
1565
|
-
};
|
|
1566
|
-
remote.on("data", (data) => {
|
|
1567
|
-
const match2 = data.toString().match(/^(\w+) (\S+)/);
|
|
1568
|
-
if (match2) {
|
|
1569
|
-
this.emit("request", {
|
|
1570
|
-
method: match2[1],
|
|
1571
|
-
path: match2[2]
|
|
1572
|
-
});
|
|
1573
|
-
}
|
|
1574
|
-
});
|
|
1575
|
-
remote.once("connect", () => {
|
|
1576
|
-
this.emit("open", remote);
|
|
1577
|
-
connLocal();
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
destroy() {
|
|
1581
|
-
if (this.closed)
|
|
1582
|
-
return;
|
|
1583
|
-
this.closed = true;
|
|
1584
|
-
for (const id of this._timeouts) {
|
|
1585
|
-
clearTimeout(id);
|
|
1586
|
-
}
|
|
1587
|
-
this._timeouts.clear();
|
|
1588
|
-
for (const transformer of this._transformers) {
|
|
1589
|
-
transformer.unpipe();
|
|
1590
|
-
transformer.destroy();
|
|
1591
|
-
}
|
|
1592
|
-
this._transformers.clear();
|
|
1593
|
-
for (const socket of this._localSockets) {
|
|
1594
|
-
socket.unpipe();
|
|
1595
|
-
socket.destroy();
|
|
1596
|
-
}
|
|
1597
|
-
this._localSockets.clear();
|
|
1598
|
-
for (const socket of this._sockets) {
|
|
1599
|
-
socket.unpipe();
|
|
1600
|
-
socket.destroy();
|
|
1601
|
-
}
|
|
1602
|
-
this._sockets.clear();
|
|
1603
|
-
this.removeAllListeners();
|
|
1604
|
-
debug("TunnelCluster destroyed");
|
|
1605
|
-
}
|
|
1606
|
-
};
|
|
1607
|
-
});
|
|
1608
|
-
|
|
1609
|
-
// node_modules/@desplega.ai/localtunnel/lib/Tunnel.js
|
|
1610
|
-
var require_Tunnel = __commonJS(function(exports, module) {
|
|
1611
|
-
var { parse } = __require("url");
|
|
1612
|
-
var { EventEmitter } = __require("events");
|
|
1613
|
-
var axios = require_axios();
|
|
1614
|
-
var debug = require_src()("localtunnel:client");
|
|
1615
|
-
var TunnelCluster = require_TunnelCluster();
|
|
1616
|
-
module.exports = class Tunnel extends EventEmitter {
|
|
1617
|
-
constructor(opts = {}) {
|
|
1618
|
-
super(opts);
|
|
1619
|
-
this.opts = opts;
|
|
1620
|
-
this.closed = false;
|
|
1621
|
-
this._initTimeout = null;
|
|
1622
|
-
this._handlers = null;
|
|
1623
|
-
if (!this.opts.host) {
|
|
1624
|
-
this.opts.host = "https://lt.desplega.ai";
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
_getInfo(body) {
|
|
1628
|
-
const { id, ip, port, url, cached_url, max_conn_count } = body;
|
|
1629
|
-
const { host, port: local_port, local_host } = this.opts;
|
|
1630
|
-
const { local_https, local_cert, local_key, local_ca, allow_invalid_cert } = this.opts;
|
|
1631
|
-
return {
|
|
1632
|
-
name: id,
|
|
1633
|
-
url,
|
|
1634
|
-
cached_url,
|
|
1635
|
-
max_conn: max_conn_count || 1,
|
|
1636
|
-
remote_host: parse(host).hostname,
|
|
1637
|
-
remote_ip: ip,
|
|
1638
|
-
remote_port: port,
|
|
1639
|
-
local_port,
|
|
1640
|
-
local_host,
|
|
1641
|
-
local_https,
|
|
1642
|
-
local_cert,
|
|
1643
|
-
local_key,
|
|
1644
|
-
local_ca,
|
|
1645
|
-
allow_invalid_cert
|
|
1646
|
-
};
|
|
1647
|
-
}
|
|
1648
|
-
_init(cb) {
|
|
1649
|
-
const opt = this.opts;
|
|
1650
|
-
const getInfo = this._getInfo.bind(this);
|
|
1651
|
-
const params = {
|
|
1652
|
-
responseType: "json"
|
|
1653
|
-
};
|
|
1654
|
-
const baseUri = `${opt.host}/`;
|
|
1655
|
-
const assignedDomain = opt.subdomain;
|
|
1656
|
-
let uri = baseUri + (assignedDomain || "?new");
|
|
1657
|
-
if (opt.auth) {
|
|
1658
|
-
const separator = assignedDomain ? "?" : "&";
|
|
1659
|
-
uri += `${separator}username=hi`;
|
|
1660
|
-
if (opt.auth !== true) {
|
|
1661
|
-
uri += `&password=${encodeURIComponent(opt.auth)}`;
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
const self = this;
|
|
1665
|
-
(function getUrl() {
|
|
1666
|
-
axios.get(uri, params).then((res) => {
|
|
1667
|
-
const body = res.data;
|
|
1668
|
-
debug("got tunnel information", res.data);
|
|
1669
|
-
if (res.status !== 200) {
|
|
1670
|
-
const err = new Error(body && body.message || "localtunnel server returned an error, please try again");
|
|
1671
|
-
return cb(err);
|
|
1672
|
-
}
|
|
1673
|
-
cb(null, getInfo(body));
|
|
1674
|
-
}).catch((err) => {
|
|
1675
|
-
if (err.response?.status === 409) {
|
|
1676
|
-
const message = err.response.data?.message || "Subdomain is already in use";
|
|
1677
|
-
debug("subdomain in use: %s", message);
|
|
1678
|
-
return cb(new Error(message));
|
|
1679
|
-
}
|
|
1680
|
-
debug(`tunnel server offline: ${err.message}, retry 1s`);
|
|
1681
|
-
self._initTimeout = setTimeout(getUrl, 1000);
|
|
1682
|
-
});
|
|
1683
|
-
})();
|
|
1684
|
-
}
|
|
1685
|
-
_establish(info) {
|
|
1686
|
-
this.setMaxListeners(info.max_conn + (EventEmitter.defaultMaxListeners || 10));
|
|
1687
|
-
this.tunnelCluster = new TunnelCluster(info);
|
|
1688
|
-
let tunnelCount = 0;
|
|
1689
|
-
this._handlers = {
|
|
1690
|
-
firstOpen: () => {
|
|
1691
|
-
this.emit("url", info.url);
|
|
1692
|
-
},
|
|
1693
|
-
error: (err) => {
|
|
1694
|
-
debug("got socket error", err.message);
|
|
1695
|
-
this.emit("error", err);
|
|
1696
|
-
},
|
|
1697
|
-
open: (tunnel) => {
|
|
1698
|
-
tunnelCount++;
|
|
1699
|
-
debug("tunnel open [total: %d]", tunnelCount);
|
|
1700
|
-
const closeHandler = () => {
|
|
1701
|
-
tunnel.destroy();
|
|
1702
|
-
};
|
|
1703
|
-
if (this.closed) {
|
|
1704
|
-
return closeHandler();
|
|
1705
|
-
}
|
|
1706
|
-
this.once("close", closeHandler);
|
|
1707
|
-
tunnel.once("close", () => {
|
|
1708
|
-
this.removeListener("close", closeHandler);
|
|
1709
|
-
});
|
|
1710
|
-
},
|
|
1711
|
-
dead: () => {
|
|
1712
|
-
tunnelCount--;
|
|
1713
|
-
debug("tunnel dead [total: %d]", tunnelCount);
|
|
1714
|
-
if (this.closed) {
|
|
1715
|
-
return;
|
|
1716
|
-
}
|
|
1717
|
-
this.tunnelCluster.open();
|
|
1718
|
-
},
|
|
1719
|
-
request: (req) => {
|
|
1720
|
-
this.emit("request", req);
|
|
1721
|
-
}
|
|
1722
|
-
};
|
|
1723
|
-
this.tunnelCluster.once("open", this._handlers.firstOpen);
|
|
1724
|
-
this.tunnelCluster.on("error", this._handlers.error);
|
|
1725
|
-
this.tunnelCluster.on("open", this._handlers.open);
|
|
1726
|
-
this.tunnelCluster.on("dead", this._handlers.dead);
|
|
1727
|
-
this.tunnelCluster.on("request", this._handlers.request);
|
|
1728
|
-
for (let count = 0;count < info.max_conn; ++count) {
|
|
1729
|
-
this.tunnelCluster.open();
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
open(cb) {
|
|
1733
|
-
this._init((err, info) => {
|
|
1734
|
-
if (err) {
|
|
1735
|
-
return cb(err);
|
|
1736
|
-
}
|
|
1737
|
-
this.clientId = info.name;
|
|
1738
|
-
this.url = info.url;
|
|
1739
|
-
if (info.cached_url) {
|
|
1740
|
-
this.cachedUrl = info.cached_url;
|
|
1741
|
-
}
|
|
1742
|
-
this._establish(info);
|
|
1743
|
-
cb();
|
|
1744
|
-
});
|
|
1745
|
-
}
|
|
1746
|
-
async close() {
|
|
1747
|
-
if (this.closed) {
|
|
1748
|
-
return;
|
|
1749
|
-
}
|
|
1750
|
-
this.closed = true;
|
|
1751
|
-
debug("closing tunnel");
|
|
1752
|
-
if (this._initTimeout) {
|
|
1753
|
-
clearTimeout(this._initTimeout);
|
|
1754
|
-
this._initTimeout = null;
|
|
1755
|
-
}
|
|
1756
|
-
if (this.tunnelCluster) {
|
|
1757
|
-
if (this._handlers) {
|
|
1758
|
-
this.tunnelCluster.removeListener("open", this._handlers.firstOpen);
|
|
1759
|
-
this.tunnelCluster.removeListener("error", this._handlers.error);
|
|
1760
|
-
this.tunnelCluster.removeListener("open", this._handlers.open);
|
|
1761
|
-
this.tunnelCluster.removeListener("dead", this._handlers.dead);
|
|
1762
|
-
this.tunnelCluster.removeListener("request", this._handlers.request);
|
|
1763
|
-
this._handlers = null;
|
|
1764
|
-
}
|
|
1765
|
-
this.tunnelCluster.destroy();
|
|
1766
|
-
this.tunnelCluster = null;
|
|
1767
|
-
}
|
|
1768
|
-
this.emit("close");
|
|
1769
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
1770
|
-
this.removeAllListeners();
|
|
1771
|
-
debug("tunnel closed");
|
|
1772
|
-
}
|
|
1773
|
-
};
|
|
1774
|
-
});
|
|
1775
|
-
|
|
1776
|
-
// node_modules/@desplega.ai/localtunnel/localtunnel.js
|
|
1777
|
-
var require_localtunnel = __commonJS(function(exports, module) {
|
|
1778
|
-
var Tunnel = require_Tunnel();
|
|
1779
|
-
module.exports = function localtunnel(arg1, arg2, arg3) {
|
|
1780
|
-
const options = typeof arg1 === "object" ? arg1 : { ...arg2, port: arg1 };
|
|
1781
|
-
const callback = typeof arg1 === "object" ? arg2 : arg3;
|
|
1782
|
-
const client = new Tunnel(options);
|
|
1783
|
-
if (callback) {
|
|
1784
|
-
client.open((err) => err ? callback(err) : callback(null, client));
|
|
1785
|
-
return client;
|
|
1786
|
-
}
|
|
1787
|
-
return new Promise((resolve, reject) => client.open((err) => err ? reject(err) : resolve(client)));
|
|
1788
|
-
};
|
|
1789
|
-
});
|
|
1790
|
-
|
|
1791
|
-
// node_modules/hono/dist/compose.js
|
|
1792
|
-
var compose = (middleware, onError, onNotFound) => {
|
|
1793
|
-
return (context, next) => {
|
|
1794
|
-
let index = -1;
|
|
1795
|
-
return dispatch(0);
|
|
1796
|
-
async function dispatch(i) {
|
|
1797
|
-
if (i <= index) {
|
|
1798
|
-
throw new Error("next() called multiple times");
|
|
1799
|
-
}
|
|
1800
|
-
index = i;
|
|
1801
|
-
let res;
|
|
1802
|
-
let isError = false;
|
|
1803
|
-
let handler;
|
|
1804
|
-
if (middleware[i]) {
|
|
1805
|
-
handler = middleware[i][0][0];
|
|
1806
|
-
context.req.routeIndex = i;
|
|
1807
|
-
} else {
|
|
1808
|
-
handler = i === middleware.length && next || undefined;
|
|
1809
|
-
}
|
|
1810
|
-
if (handler) {
|
|
1811
|
-
try {
|
|
1812
|
-
res = await handler(context, () => dispatch(i + 1));
|
|
1813
|
-
} catch (err) {
|
|
1814
|
-
if (err instanceof Error && onError) {
|
|
1815
|
-
context.error = err;
|
|
1816
|
-
res = await onError(err, context);
|
|
1817
|
-
isError = true;
|
|
1818
|
-
} else {
|
|
1819
|
-
throw err;
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
} else {
|
|
1823
|
-
if (context.finalized === false && onNotFound) {
|
|
1824
|
-
res = await onNotFound(context);
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
if (res && (context.finalized === false || isError)) {
|
|
1828
|
-
context.res = res;
|
|
1829
|
-
}
|
|
1830
|
-
return context;
|
|
1831
|
-
}
|
|
1832
|
-
};
|
|
1833
|
-
};
|
|
1834
|
-
|
|
1835
|
-
// node_modules/hono/dist/request/constants.js
|
|
1836
|
-
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
1837
|
-
|
|
1838
|
-
// node_modules/hono/dist/utils/body.js
|
|
1839
|
-
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
1840
|
-
const { all = false, dot = false } = options;
|
|
1841
|
-
const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
|
|
1842
|
-
const contentType = headers.get("Content-Type");
|
|
1843
|
-
if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) {
|
|
1844
|
-
return parseFormData(request, { all, dot });
|
|
1845
|
-
}
|
|
1846
|
-
return {};
|
|
1847
|
-
};
|
|
1848
|
-
async function parseFormData(request, options) {
|
|
1849
|
-
const formData = await request.formData();
|
|
1850
|
-
if (formData) {
|
|
1851
|
-
return convertFormDataToBodyData(formData, options);
|
|
1852
|
-
}
|
|
1853
|
-
return {};
|
|
1854
|
-
}
|
|
1855
|
-
function convertFormDataToBodyData(formData, options) {
|
|
1856
|
-
const form = /* @__PURE__ */ Object.create(null);
|
|
1857
|
-
formData.forEach((value, key) => {
|
|
1858
|
-
const shouldParseAllValues = options.all || key.endsWith("[]");
|
|
1859
|
-
if (!shouldParseAllValues) {
|
|
1860
|
-
form[key] = value;
|
|
1861
|
-
} else {
|
|
1862
|
-
handleParsingAllValues(form, key, value);
|
|
1863
|
-
}
|
|
1864
|
-
});
|
|
1865
|
-
if (options.dot) {
|
|
1866
|
-
Object.entries(form).forEach(([key, value]) => {
|
|
1867
|
-
const shouldParseDotValues = key.includes(".");
|
|
1868
|
-
if (shouldParseDotValues) {
|
|
1869
|
-
handleParsingNestedValues(form, key, value);
|
|
1870
|
-
delete form[key];
|
|
1871
|
-
}
|
|
1872
|
-
});
|
|
1873
|
-
}
|
|
1874
|
-
return form;
|
|
1875
|
-
}
|
|
1876
|
-
var handleParsingAllValues = (form, key, value) => {
|
|
1877
|
-
if (form[key] !== undefined) {
|
|
1878
|
-
if (Array.isArray(form[key])) {
|
|
1879
|
-
form[key].push(value);
|
|
1880
|
-
} else {
|
|
1881
|
-
form[key] = [form[key], value];
|
|
1882
|
-
}
|
|
1883
|
-
} else {
|
|
1884
|
-
if (!key.endsWith("[]")) {
|
|
1885
|
-
form[key] = value;
|
|
1886
|
-
} else {
|
|
1887
|
-
form[key] = [value];
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
};
|
|
1891
|
-
var handleParsingNestedValues = (form, key, value) => {
|
|
1892
|
-
let nestedForm = form;
|
|
1893
|
-
const keys = key.split(".");
|
|
1894
|
-
keys.forEach((key2, index) => {
|
|
1895
|
-
if (index === keys.length - 1) {
|
|
1896
|
-
nestedForm[key2] = value;
|
|
1897
|
-
} else {
|
|
1898
|
-
if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
|
|
1899
|
-
nestedForm[key2] = /* @__PURE__ */ Object.create(null);
|
|
1900
|
-
}
|
|
1901
|
-
nestedForm = nestedForm[key2];
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
};
|
|
1905
|
-
|
|
1906
|
-
// node_modules/hono/dist/utils/url.js
|
|
1907
|
-
var splitPath = (path) => {
|
|
1908
|
-
const paths = path.split("/");
|
|
1909
|
-
if (paths[0] === "") {
|
|
1910
|
-
paths.shift();
|
|
1911
|
-
}
|
|
1912
|
-
return paths;
|
|
1913
|
-
};
|
|
1914
|
-
var splitRoutingPath = (routePath) => {
|
|
1915
|
-
const { groups, path } = extractGroupsFromPath(routePath);
|
|
1916
|
-
const paths = splitPath(path);
|
|
1917
|
-
return replaceGroupMarks(paths, groups);
|
|
1918
|
-
};
|
|
1919
|
-
var extractGroupsFromPath = (path) => {
|
|
1920
|
-
const groups = [];
|
|
1921
|
-
path = path.replace(/\{[^}]+\}/g, (match, index) => {
|
|
1922
|
-
const mark = `@${index}`;
|
|
1923
|
-
groups.push([mark, match]);
|
|
1924
|
-
return mark;
|
|
1925
|
-
});
|
|
1926
|
-
return { groups, path };
|
|
1927
|
-
};
|
|
1928
|
-
var replaceGroupMarks = (paths, groups) => {
|
|
1929
|
-
for (let i = groups.length - 1;i >= 0; i--) {
|
|
1930
|
-
const [mark] = groups[i];
|
|
1931
|
-
for (let j = paths.length - 1;j >= 0; j--) {
|
|
1932
|
-
if (paths[j].includes(mark)) {
|
|
1933
|
-
paths[j] = paths[j].replace(mark, groups[i][1]);
|
|
1934
|
-
break;
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
return paths;
|
|
1939
|
-
};
|
|
1940
|
-
var patternCache = {};
|
|
1941
|
-
var getPattern = (label, next) => {
|
|
1942
|
-
if (label === "*") {
|
|
1943
|
-
return "*";
|
|
1944
|
-
}
|
|
1945
|
-
const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
1946
|
-
if (match) {
|
|
1947
|
-
const cacheKey = `${label}#${next}`;
|
|
1948
|
-
if (!patternCache[cacheKey]) {
|
|
1949
|
-
if (match[2]) {
|
|
1950
|
-
patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [cacheKey, match[1], new RegExp(`^${match[2]}(?=/${next})`)] : [label, match[1], new RegExp(`^${match[2]}$`)];
|
|
1951
|
-
} else {
|
|
1952
|
-
patternCache[cacheKey] = [label, match[1], true];
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
return patternCache[cacheKey];
|
|
1956
|
-
}
|
|
1957
|
-
return null;
|
|
1958
|
-
};
|
|
1959
|
-
var tryDecode = (str, decoder) => {
|
|
1960
|
-
try {
|
|
1961
|
-
return decoder(str);
|
|
1962
|
-
} catch {
|
|
1963
|
-
return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
|
|
1964
|
-
try {
|
|
1965
|
-
return decoder(match);
|
|
1966
|
-
} catch {
|
|
1967
|
-
return match;
|
|
1968
|
-
}
|
|
1969
|
-
});
|
|
1970
|
-
}
|
|
1971
|
-
};
|
|
1972
|
-
var tryDecodeURI = (str) => tryDecode(str, decodeURI);
|
|
1973
|
-
var getPath = (request) => {
|
|
1974
|
-
const url = request.url;
|
|
1975
|
-
const start = url.indexOf("/", url.indexOf(":") + 4);
|
|
1976
|
-
let i = start;
|
|
1977
|
-
for (;i < url.length; i++) {
|
|
1978
|
-
const charCode = url.charCodeAt(i);
|
|
1979
|
-
if (charCode === 37) {
|
|
1980
|
-
const queryIndex = url.indexOf("?", i);
|
|
1981
|
-
const hashIndex = url.indexOf("#", i);
|
|
1982
|
-
const end = queryIndex === -1 ? hashIndex === -1 ? undefined : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
1983
|
-
const path = url.slice(start, end);
|
|
1984
|
-
return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
|
|
1985
|
-
} else if (charCode === 63 || charCode === 35) {
|
|
1986
|
-
break;
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
return url.slice(start, i);
|
|
1990
|
-
};
|
|
1991
|
-
var getPathNoStrict = (request) => {
|
|
1992
|
-
const result = getPath(request);
|
|
1993
|
-
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
1994
|
-
};
|
|
1995
|
-
var mergePath = (base, sub, ...rest) => {
|
|
1996
|
-
if (rest.length) {
|
|
1997
|
-
sub = mergePath(sub, ...rest);
|
|
1998
|
-
}
|
|
1999
|
-
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
2000
|
-
};
|
|
2001
|
-
var checkOptionalParameter = (path) => {
|
|
2002
|
-
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
|
|
2003
|
-
return null;
|
|
2004
|
-
}
|
|
2005
|
-
const segments = path.split("/");
|
|
2006
|
-
const results = [];
|
|
2007
|
-
let basePath = "";
|
|
2008
|
-
segments.forEach((segment) => {
|
|
2009
|
-
if (segment !== "" && !/\:/.test(segment)) {
|
|
2010
|
-
basePath += "/" + segment;
|
|
2011
|
-
} else if (/\:/.test(segment)) {
|
|
2012
|
-
if (/\?/.test(segment)) {
|
|
2013
|
-
if (results.length === 0 && basePath === "") {
|
|
2014
|
-
results.push("/");
|
|
2015
|
-
} else {
|
|
2016
|
-
results.push(basePath);
|
|
2017
|
-
}
|
|
2018
|
-
const optionalSegment = segment.replace("?", "");
|
|
2019
|
-
basePath += "/" + optionalSegment;
|
|
2020
|
-
results.push(basePath);
|
|
2021
|
-
} else {
|
|
2022
|
-
basePath += "/" + segment;
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
});
|
|
2026
|
-
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
2027
|
-
};
|
|
2028
|
-
var _decodeURI = (value) => {
|
|
2029
|
-
if (!/[%+]/.test(value)) {
|
|
2030
|
-
return value;
|
|
2031
|
-
}
|
|
2032
|
-
if (value.indexOf("+") !== -1) {
|
|
2033
|
-
value = value.replace(/\+/g, " ");
|
|
2034
|
-
}
|
|
2035
|
-
return value.indexOf("%") !== -1 ? tryDecode(value, decodeURIComponent_) : value;
|
|
2036
|
-
};
|
|
2037
|
-
var _getQueryParam = (url, key, multiple) => {
|
|
2038
|
-
let encoded;
|
|
2039
|
-
if (!multiple && key && !/[%+]/.test(key)) {
|
|
2040
|
-
let keyIndex2 = url.indexOf("?", 8);
|
|
2041
|
-
if (keyIndex2 === -1) {
|
|
2042
|
-
return;
|
|
2043
|
-
}
|
|
2044
|
-
if (!url.startsWith(key, keyIndex2 + 1)) {
|
|
2045
|
-
keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
|
|
2046
|
-
}
|
|
2047
|
-
while (keyIndex2 !== -1) {
|
|
2048
|
-
const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
|
|
2049
|
-
if (trailingKeyCode === 61) {
|
|
2050
|
-
const valueIndex = keyIndex2 + key.length + 2;
|
|
2051
|
-
const endIndex = url.indexOf("&", valueIndex);
|
|
2052
|
-
return _decodeURI(url.slice(valueIndex, endIndex === -1 ? undefined : endIndex));
|
|
2053
|
-
} else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) {
|
|
2054
|
-
return "";
|
|
2055
|
-
}
|
|
2056
|
-
keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
|
|
2057
|
-
}
|
|
2058
|
-
encoded = /[%+]/.test(url);
|
|
2059
|
-
if (!encoded) {
|
|
2060
|
-
return;
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
const results = {};
|
|
2064
|
-
encoded ??= /[%+]/.test(url);
|
|
2065
|
-
let keyIndex = url.indexOf("?", 8);
|
|
2066
|
-
while (keyIndex !== -1) {
|
|
2067
|
-
const nextKeyIndex = url.indexOf("&", keyIndex + 1);
|
|
2068
|
-
let valueIndex = url.indexOf("=", keyIndex);
|
|
2069
|
-
if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) {
|
|
2070
|
-
valueIndex = -1;
|
|
2071
|
-
}
|
|
2072
|
-
let name = url.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? undefined : nextKeyIndex : valueIndex);
|
|
2073
|
-
if (encoded) {
|
|
2074
|
-
name = _decodeURI(name);
|
|
2075
|
-
}
|
|
2076
|
-
keyIndex = nextKeyIndex;
|
|
2077
|
-
if (name === "") {
|
|
2078
|
-
continue;
|
|
2079
|
-
}
|
|
2080
|
-
let value;
|
|
2081
|
-
if (valueIndex === -1) {
|
|
2082
|
-
value = "";
|
|
2083
|
-
} else {
|
|
2084
|
-
value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? undefined : nextKeyIndex);
|
|
2085
|
-
if (encoded) {
|
|
2086
|
-
value = _decodeURI(value);
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
if (multiple) {
|
|
2090
|
-
if (!(results[name] && Array.isArray(results[name]))) {
|
|
2091
|
-
results[name] = [];
|
|
2092
|
-
}
|
|
2093
|
-
results[name].push(value);
|
|
2094
|
-
} else {
|
|
2095
|
-
results[name] ??= value;
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
return key ? results[key] : results;
|
|
2099
|
-
};
|
|
2100
|
-
var getQueryParam = _getQueryParam;
|
|
2101
|
-
var getQueryParams = (url, key) => {
|
|
2102
|
-
return _getQueryParam(url, key, true);
|
|
2103
|
-
};
|
|
2104
|
-
var decodeURIComponent_ = decodeURIComponent;
|
|
2105
|
-
|
|
2106
|
-
// node_modules/hono/dist/request.js
|
|
2107
|
-
var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
|
|
2108
|
-
var HonoRequest = class {
|
|
2109
|
-
raw;
|
|
2110
|
-
#validatedData;
|
|
2111
|
-
#matchResult;
|
|
2112
|
-
routeIndex = 0;
|
|
2113
|
-
path;
|
|
2114
|
-
bodyCache = {};
|
|
2115
|
-
constructor(request, path = "/", matchResult = [[]]) {
|
|
2116
|
-
this.raw = request;
|
|
2117
|
-
this.path = path;
|
|
2118
|
-
this.#matchResult = matchResult;
|
|
2119
|
-
this.#validatedData = {};
|
|
2120
|
-
}
|
|
2121
|
-
param(key) {
|
|
2122
|
-
return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();
|
|
2123
|
-
}
|
|
2124
|
-
#getDecodedParam(key) {
|
|
2125
|
-
const paramKey = this.#matchResult[0][this.routeIndex][1][key];
|
|
2126
|
-
const param = this.#getParamValue(paramKey);
|
|
2127
|
-
return param && /\%/.test(param) ? tryDecodeURIComponent(param) : param;
|
|
2128
|
-
}
|
|
2129
|
-
#getAllDecodedParams() {
|
|
2130
|
-
const decoded = {};
|
|
2131
|
-
const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
|
|
2132
|
-
for (const key of keys) {
|
|
2133
|
-
const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
|
|
2134
|
-
if (value !== undefined) {
|
|
2135
|
-
decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
return decoded;
|
|
2139
|
-
}
|
|
2140
|
-
#getParamValue(paramKey) {
|
|
2141
|
-
return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey;
|
|
2142
|
-
}
|
|
2143
|
-
query(key) {
|
|
2144
|
-
return getQueryParam(this.url, key);
|
|
2145
|
-
}
|
|
2146
|
-
queries(key) {
|
|
2147
|
-
return getQueryParams(this.url, key);
|
|
2148
|
-
}
|
|
2149
|
-
header(name) {
|
|
2150
|
-
if (name) {
|
|
2151
|
-
return this.raw.headers.get(name) ?? undefined;
|
|
2152
|
-
}
|
|
2153
|
-
const headerData = {};
|
|
2154
|
-
this.raw.headers.forEach((value, key) => {
|
|
2155
|
-
headerData[key] = value;
|
|
2156
|
-
});
|
|
2157
|
-
return headerData;
|
|
2158
|
-
}
|
|
2159
|
-
async parseBody(options) {
|
|
2160
|
-
return this.bodyCache.parsedBody ??= await parseBody(this, options);
|
|
2161
|
-
}
|
|
2162
|
-
#cachedBody = (key) => {
|
|
2163
|
-
const { bodyCache, raw } = this;
|
|
2164
|
-
const cachedBody = bodyCache[key];
|
|
2165
|
-
if (cachedBody) {
|
|
2166
|
-
return cachedBody;
|
|
2167
|
-
}
|
|
2168
|
-
const anyCachedKey = Object.keys(bodyCache)[0];
|
|
2169
|
-
if (anyCachedKey) {
|
|
2170
|
-
return bodyCache[anyCachedKey].then((body) => {
|
|
2171
|
-
if (anyCachedKey === "json") {
|
|
2172
|
-
body = JSON.stringify(body);
|
|
2173
|
-
}
|
|
2174
|
-
return new Response(body)[key]();
|
|
2175
|
-
});
|
|
2176
|
-
}
|
|
2177
|
-
return bodyCache[key] = raw[key]();
|
|
2178
|
-
};
|
|
2179
|
-
json() {
|
|
2180
|
-
return this.#cachedBody("text").then((text) => JSON.parse(text));
|
|
2181
|
-
}
|
|
2182
|
-
text() {
|
|
2183
|
-
return this.#cachedBody("text");
|
|
2184
|
-
}
|
|
2185
|
-
arrayBuffer() {
|
|
2186
|
-
return this.#cachedBody("arrayBuffer");
|
|
2187
|
-
}
|
|
2188
|
-
blob() {
|
|
2189
|
-
return this.#cachedBody("blob");
|
|
2190
|
-
}
|
|
2191
|
-
formData() {
|
|
2192
|
-
return this.#cachedBody("formData");
|
|
2193
|
-
}
|
|
2194
|
-
addValidatedData(target, data) {
|
|
2195
|
-
this.#validatedData[target] = data;
|
|
2196
|
-
}
|
|
2197
|
-
valid(target) {
|
|
2198
|
-
return this.#validatedData[target];
|
|
2199
|
-
}
|
|
2200
|
-
get url() {
|
|
2201
|
-
return this.raw.url;
|
|
2202
|
-
}
|
|
2203
|
-
get method() {
|
|
2204
|
-
return this.raw.method;
|
|
2205
|
-
}
|
|
2206
|
-
get [GET_MATCH_RESULT]() {
|
|
2207
|
-
return this.#matchResult;
|
|
2208
|
-
}
|
|
2209
|
-
get matchedRoutes() {
|
|
2210
|
-
return this.#matchResult[0].map(([[, route]]) => route);
|
|
2211
|
-
}
|
|
2212
|
-
get routePath() {
|
|
2213
|
-
return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
|
|
2214
|
-
}
|
|
2215
|
-
};
|
|
2216
|
-
|
|
2217
|
-
// node_modules/hono/dist/utils/html.js
|
|
2218
|
-
var HtmlEscapedCallbackPhase = {
|
|
2219
|
-
Stringify: 1,
|
|
2220
|
-
BeforeStream: 2,
|
|
2221
|
-
Stream: 3
|
|
2222
|
-
};
|
|
2223
|
-
var raw = (value, callbacks) => {
|
|
2224
|
-
const escapedString = new String(value);
|
|
2225
|
-
escapedString.isEscaped = true;
|
|
2226
|
-
escapedString.callbacks = callbacks;
|
|
2227
|
-
return escapedString;
|
|
2228
|
-
};
|
|
2229
|
-
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
2230
|
-
if (typeof str === "object" && !(str instanceof String)) {
|
|
2231
|
-
if (!(str instanceof Promise)) {
|
|
2232
|
-
str = str.toString();
|
|
2233
|
-
}
|
|
2234
|
-
if (str instanceof Promise) {
|
|
2235
|
-
str = await str;
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
const callbacks = str.callbacks;
|
|
2239
|
-
if (!callbacks?.length) {
|
|
2240
|
-
return Promise.resolve(str);
|
|
2241
|
-
}
|
|
2242
|
-
if (buffer) {
|
|
2243
|
-
buffer[0] += str;
|
|
2244
|
-
} else {
|
|
2245
|
-
buffer = [str];
|
|
2246
|
-
}
|
|
2247
|
-
const resStr = Promise.all(callbacks.map((c) => c({ phase, buffer, context }))).then((res) => Promise.all(res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))).then(() => buffer[0]));
|
|
2248
|
-
if (preserveCallbacks) {
|
|
2249
|
-
return raw(await resStr, callbacks);
|
|
2250
|
-
} else {
|
|
2251
|
-
return resStr;
|
|
2252
|
-
}
|
|
2253
|
-
};
|
|
2254
|
-
|
|
2255
|
-
// node_modules/hono/dist/context.js
|
|
2256
|
-
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
2257
|
-
var setDefaultContentType = (contentType, headers) => {
|
|
2258
|
-
return {
|
|
2259
|
-
"Content-Type": contentType,
|
|
2260
|
-
...headers
|
|
2261
|
-
};
|
|
2262
|
-
};
|
|
2263
|
-
var createResponseInstance = (body, init) => new Response(body, init);
|
|
2264
|
-
var Context = class {
|
|
2265
|
-
#rawRequest;
|
|
2266
|
-
#req;
|
|
2267
|
-
env = {};
|
|
2268
|
-
#var;
|
|
2269
|
-
finalized = false;
|
|
2270
|
-
error;
|
|
2271
|
-
#status;
|
|
2272
|
-
#executionCtx;
|
|
2273
|
-
#res;
|
|
2274
|
-
#layout;
|
|
2275
|
-
#renderer;
|
|
2276
|
-
#notFoundHandler;
|
|
2277
|
-
#preparedHeaders;
|
|
2278
|
-
#matchResult;
|
|
2279
|
-
#path;
|
|
2280
|
-
constructor(req, options) {
|
|
2281
|
-
this.#rawRequest = req;
|
|
2282
|
-
if (options) {
|
|
2283
|
-
this.#executionCtx = options.executionCtx;
|
|
2284
|
-
this.env = options.env;
|
|
2285
|
-
this.#notFoundHandler = options.notFoundHandler;
|
|
2286
|
-
this.#path = options.path;
|
|
2287
|
-
this.#matchResult = options.matchResult;
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
get req() {
|
|
2291
|
-
this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
|
|
2292
|
-
return this.#req;
|
|
2293
|
-
}
|
|
2294
|
-
get event() {
|
|
2295
|
-
if (this.#executionCtx && "respondWith" in this.#executionCtx) {
|
|
2296
|
-
return this.#executionCtx;
|
|
2297
|
-
} else {
|
|
2298
|
-
throw Error("This context has no FetchEvent");
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
get executionCtx() {
|
|
2302
|
-
if (this.#executionCtx) {
|
|
2303
|
-
return this.#executionCtx;
|
|
2304
|
-
} else {
|
|
2305
|
-
throw Error("This context has no ExecutionContext");
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
get res() {
|
|
2309
|
-
return this.#res ||= createResponseInstance(null, {
|
|
2310
|
-
headers: this.#preparedHeaders ??= new Headers
|
|
2311
|
-
});
|
|
2312
|
-
}
|
|
2313
|
-
set res(_res) {
|
|
2314
|
-
if (this.#res && _res) {
|
|
2315
|
-
_res = createResponseInstance(_res.body, _res);
|
|
2316
|
-
for (const [k, v] of this.#res.headers.entries()) {
|
|
2317
|
-
if (k === "content-type") {
|
|
2318
|
-
continue;
|
|
2319
|
-
}
|
|
2320
|
-
if (k === "set-cookie") {
|
|
2321
|
-
const cookies = this.#res.headers.getSetCookie();
|
|
2322
|
-
_res.headers.delete("set-cookie");
|
|
2323
|
-
for (const cookie of cookies) {
|
|
2324
|
-
_res.headers.append("set-cookie", cookie);
|
|
2325
|
-
}
|
|
2326
|
-
} else {
|
|
2327
|
-
_res.headers.set(k, v);
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
this.#res = _res;
|
|
2332
|
-
this.finalized = true;
|
|
2333
|
-
}
|
|
2334
|
-
render = (...args) => {
|
|
2335
|
-
this.#renderer ??= (content) => this.html(content);
|
|
2336
|
-
return this.#renderer(...args);
|
|
2337
|
-
};
|
|
2338
|
-
setLayout = (layout) => this.#layout = layout;
|
|
2339
|
-
getLayout = () => this.#layout;
|
|
2340
|
-
setRenderer = (renderer) => {
|
|
2341
|
-
this.#renderer = renderer;
|
|
2342
|
-
};
|
|
2343
|
-
header = (name, value, options) => {
|
|
2344
|
-
if (this.finalized) {
|
|
2345
|
-
this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
2346
|
-
}
|
|
2347
|
-
const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers;
|
|
2348
|
-
if (value === undefined) {
|
|
2349
|
-
headers.delete(name);
|
|
2350
|
-
} else if (options?.append) {
|
|
2351
|
-
headers.append(name, value);
|
|
2352
|
-
} else {
|
|
2353
|
-
headers.set(name, value);
|
|
2354
|
-
}
|
|
2355
|
-
};
|
|
2356
|
-
status = (status) => {
|
|
2357
|
-
this.#status = status;
|
|
2358
|
-
};
|
|
2359
|
-
set = (key, value) => {
|
|
2360
|
-
this.#var ??= /* @__PURE__ */ new Map;
|
|
2361
|
-
this.#var.set(key, value);
|
|
2362
|
-
};
|
|
2363
|
-
get = (key) => {
|
|
2364
|
-
return this.#var ? this.#var.get(key) : undefined;
|
|
2365
|
-
};
|
|
2366
|
-
get var() {
|
|
2367
|
-
if (!this.#var) {
|
|
2368
|
-
return {};
|
|
2369
|
-
}
|
|
2370
|
-
return Object.fromEntries(this.#var);
|
|
2371
|
-
}
|
|
2372
|
-
#newResponse(data, arg, headers) {
|
|
2373
|
-
const responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders ?? new Headers;
|
|
2374
|
-
if (typeof arg === "object" && "headers" in arg) {
|
|
2375
|
-
const argHeaders = arg.headers instanceof Headers ? arg.headers : new Headers(arg.headers);
|
|
2376
|
-
for (const [key, value] of argHeaders) {
|
|
2377
|
-
if (key.toLowerCase() === "set-cookie") {
|
|
2378
|
-
responseHeaders.append(key, value);
|
|
2379
|
-
} else {
|
|
2380
|
-
responseHeaders.set(key, value);
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
if (headers) {
|
|
2385
|
-
for (const [k, v] of Object.entries(headers)) {
|
|
2386
|
-
if (typeof v === "string") {
|
|
2387
|
-
responseHeaders.set(k, v);
|
|
2388
|
-
} else {
|
|
2389
|
-
responseHeaders.delete(k);
|
|
2390
|
-
for (const v2 of v) {
|
|
2391
|
-
responseHeaders.append(k, v2);
|
|
2392
|
-
}
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
const status = typeof arg === "number" ? arg : arg?.status ?? this.#status;
|
|
2397
|
-
return createResponseInstance(data, { status, headers: responseHeaders });
|
|
2398
|
-
}
|
|
2399
|
-
newResponse = (...args) => this.#newResponse(...args);
|
|
2400
|
-
body = (data, arg, headers) => this.#newResponse(data, arg, headers);
|
|
2401
|
-
text = (text, arg, headers) => {
|
|
2402
|
-
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(text, arg, setDefaultContentType(TEXT_PLAIN, headers));
|
|
2403
|
-
};
|
|
2404
|
-
json = (object, arg, headers) => {
|
|
2405
|
-
return this.#newResponse(JSON.stringify(object), arg, setDefaultContentType("application/json", headers));
|
|
2406
|
-
};
|
|
2407
|
-
html = (html, arg, headers) => {
|
|
2408
|
-
const res = (html2) => this.#newResponse(html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
|
|
2409
|
-
return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
|
|
2410
|
-
};
|
|
2411
|
-
redirect = (location, status) => {
|
|
2412
|
-
const locationString = String(location);
|
|
2413
|
-
this.header("Location", !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString));
|
|
2414
|
-
return this.newResponse(null, status ?? 302);
|
|
2415
|
-
};
|
|
2416
|
-
notFound = () => {
|
|
2417
|
-
this.#notFoundHandler ??= () => createResponseInstance();
|
|
2418
|
-
return this.#notFoundHandler(this);
|
|
2419
|
-
};
|
|
2420
|
-
};
|
|
2421
|
-
|
|
2422
|
-
// node_modules/hono/dist/router.js
|
|
2423
|
-
var METHOD_NAME_ALL = "ALL";
|
|
2424
|
-
var METHOD_NAME_ALL_LOWERCASE = "all";
|
|
2425
|
-
var METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
2426
|
-
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
2427
|
-
var UnsupportedPathError = class extends Error {
|
|
2428
|
-
};
|
|
2429
|
-
|
|
2430
|
-
// node_modules/hono/dist/utils/constants.js
|
|
2431
|
-
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
2432
|
-
|
|
2433
|
-
// node_modules/hono/dist/hono-base.js
|
|
2434
|
-
var notFoundHandler = (c) => {
|
|
2435
|
-
return c.text("404 Not Found", 404);
|
|
2436
|
-
};
|
|
2437
|
-
var errorHandler = (err, c) => {
|
|
2438
|
-
if ("getResponse" in err) {
|
|
2439
|
-
const res = err.getResponse();
|
|
2440
|
-
return c.newResponse(res.body, res);
|
|
2441
|
-
}
|
|
2442
|
-
console.error(err);
|
|
2443
|
-
return c.text("Internal Server Error", 500);
|
|
2444
|
-
};
|
|
2445
|
-
var Hono = class _Hono {
|
|
2446
|
-
get;
|
|
2447
|
-
post;
|
|
2448
|
-
put;
|
|
2449
|
-
delete;
|
|
2450
|
-
options;
|
|
2451
|
-
patch;
|
|
2452
|
-
all;
|
|
2453
|
-
on;
|
|
2454
|
-
use;
|
|
2455
|
-
router;
|
|
2456
|
-
getPath;
|
|
2457
|
-
_basePath = "/";
|
|
2458
|
-
#path = "/";
|
|
2459
|
-
routes = [];
|
|
2460
|
-
constructor(options = {}) {
|
|
2461
|
-
const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
|
|
2462
|
-
allMethods.forEach((method) => {
|
|
2463
|
-
this[method] = (args1, ...args) => {
|
|
2464
|
-
if (typeof args1 === "string") {
|
|
2465
|
-
this.#path = args1;
|
|
2466
|
-
} else {
|
|
2467
|
-
this.#addRoute(method, this.#path, args1);
|
|
2468
|
-
}
|
|
2469
|
-
args.forEach((handler) => {
|
|
2470
|
-
this.#addRoute(method, this.#path, handler);
|
|
2471
|
-
});
|
|
2472
|
-
return this;
|
|
2473
|
-
};
|
|
2474
|
-
});
|
|
2475
|
-
this.on = (method, path, ...handlers) => {
|
|
2476
|
-
for (const p of [path].flat()) {
|
|
2477
|
-
this.#path = p;
|
|
2478
|
-
for (const m of [method].flat()) {
|
|
2479
|
-
handlers.map((handler) => {
|
|
2480
|
-
this.#addRoute(m.toUpperCase(), this.#path, handler);
|
|
2481
|
-
});
|
|
2482
|
-
}
|
|
2483
|
-
}
|
|
2484
|
-
return this;
|
|
2485
|
-
};
|
|
2486
|
-
this.use = (arg1, ...handlers) => {
|
|
2487
|
-
if (typeof arg1 === "string") {
|
|
2488
|
-
this.#path = arg1;
|
|
2489
|
-
} else {
|
|
2490
|
-
this.#path = "*";
|
|
2491
|
-
handlers.unshift(arg1);
|
|
2492
|
-
}
|
|
2493
|
-
handlers.forEach((handler) => {
|
|
2494
|
-
this.#addRoute(METHOD_NAME_ALL, this.#path, handler);
|
|
2495
|
-
});
|
|
2496
|
-
return this;
|
|
2497
|
-
};
|
|
2498
|
-
const { strict, ...optionsWithoutStrict } = options;
|
|
2499
|
-
Object.assign(this, optionsWithoutStrict);
|
|
2500
|
-
this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;
|
|
2501
|
-
}
|
|
2502
|
-
#clone() {
|
|
2503
|
-
const clone = new _Hono({
|
|
2504
|
-
router: this.router,
|
|
2505
|
-
getPath: this.getPath
|
|
2506
|
-
});
|
|
2507
|
-
clone.errorHandler = this.errorHandler;
|
|
2508
|
-
clone.#notFoundHandler = this.#notFoundHandler;
|
|
2509
|
-
clone.routes = this.routes;
|
|
2510
|
-
return clone;
|
|
2511
|
-
}
|
|
2512
|
-
#notFoundHandler = notFoundHandler;
|
|
2513
|
-
errorHandler = errorHandler;
|
|
2514
|
-
route(path, app) {
|
|
2515
|
-
const subApp = this.basePath(path);
|
|
2516
|
-
app.routes.map((r) => {
|
|
2517
|
-
let handler;
|
|
2518
|
-
if (app.errorHandler === errorHandler) {
|
|
2519
|
-
handler = r.handler;
|
|
2520
|
-
} else {
|
|
2521
|
-
handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
|
|
2522
|
-
handler[COMPOSED_HANDLER] = r.handler;
|
|
2523
|
-
}
|
|
2524
|
-
subApp.#addRoute(r.method, r.path, handler);
|
|
2525
|
-
});
|
|
2526
|
-
return this;
|
|
2527
|
-
}
|
|
2528
|
-
basePath(path) {
|
|
2529
|
-
const subApp = this.#clone();
|
|
2530
|
-
subApp._basePath = mergePath(this._basePath, path);
|
|
2531
|
-
return subApp;
|
|
2532
|
-
}
|
|
2533
|
-
onError = (handler) => {
|
|
2534
|
-
this.errorHandler = handler;
|
|
2535
|
-
return this;
|
|
2536
|
-
};
|
|
2537
|
-
notFound = (handler) => {
|
|
2538
|
-
this.#notFoundHandler = handler;
|
|
2539
|
-
return this;
|
|
2540
|
-
};
|
|
2541
|
-
mount(path, applicationHandler, options) {
|
|
2542
|
-
let replaceRequest;
|
|
2543
|
-
let optionHandler;
|
|
2544
|
-
if (options) {
|
|
2545
|
-
if (typeof options === "function") {
|
|
2546
|
-
optionHandler = options;
|
|
2547
|
-
} else {
|
|
2548
|
-
optionHandler = options.optionHandler;
|
|
2549
|
-
if (options.replaceRequest === false) {
|
|
2550
|
-
replaceRequest = (request) => request;
|
|
2551
|
-
} else {
|
|
2552
|
-
replaceRequest = options.replaceRequest;
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
}
|
|
2556
|
-
const getOptions = optionHandler ? (c) => {
|
|
2557
|
-
const options2 = optionHandler(c);
|
|
2558
|
-
return Array.isArray(options2) ? options2 : [options2];
|
|
2559
|
-
} : (c) => {
|
|
2560
|
-
let executionContext = undefined;
|
|
2561
|
-
try {
|
|
2562
|
-
executionContext = c.executionCtx;
|
|
2563
|
-
} catch {}
|
|
2564
|
-
return [c.env, executionContext];
|
|
2565
|
-
};
|
|
2566
|
-
replaceRequest ||= (() => {
|
|
2567
|
-
const mergedPath = mergePath(this._basePath, path);
|
|
2568
|
-
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
2569
|
-
return (request) => {
|
|
2570
|
-
const url = new URL(request.url);
|
|
2571
|
-
url.pathname = url.pathname.slice(pathPrefixLength) || "/";
|
|
2572
|
-
return new Request(url, request);
|
|
2573
|
-
};
|
|
2574
|
-
})();
|
|
2575
|
-
const handler = async (c, next) => {
|
|
2576
|
-
const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
|
|
2577
|
-
if (res) {
|
|
2578
|
-
return res;
|
|
2579
|
-
}
|
|
2580
|
-
await next();
|
|
2581
|
-
};
|
|
2582
|
-
this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
|
|
2583
|
-
return this;
|
|
2584
|
-
}
|
|
2585
|
-
#addRoute(method, path, handler) {
|
|
2586
|
-
method = method.toUpperCase();
|
|
2587
|
-
path = mergePath(this._basePath, path);
|
|
2588
|
-
const r = { basePath: this._basePath, path, method, handler };
|
|
2589
|
-
this.router.add(method, path, [handler, r]);
|
|
2590
|
-
this.routes.push(r);
|
|
2591
|
-
}
|
|
2592
|
-
#handleError(err, c) {
|
|
2593
|
-
if (err instanceof Error) {
|
|
2594
|
-
return this.errorHandler(err, c);
|
|
2595
|
-
}
|
|
2596
|
-
throw err;
|
|
2597
|
-
}
|
|
2598
|
-
#dispatch(request, executionCtx, env, method) {
|
|
2599
|
-
if (method === "HEAD") {
|
|
2600
|
-
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
|
|
2601
|
-
}
|
|
2602
|
-
const path = this.getPath(request, { env });
|
|
2603
|
-
const matchResult = this.router.match(method, path);
|
|
2604
|
-
const c = new Context(request, {
|
|
2605
|
-
path,
|
|
2606
|
-
matchResult,
|
|
2607
|
-
env,
|
|
2608
|
-
executionCtx,
|
|
2609
|
-
notFoundHandler: this.#notFoundHandler
|
|
2610
|
-
});
|
|
2611
|
-
if (matchResult[0].length === 1) {
|
|
2612
|
-
let res;
|
|
2613
|
-
try {
|
|
2614
|
-
res = matchResult[0][0][0][0](c, async () => {
|
|
2615
|
-
c.res = await this.#notFoundHandler(c);
|
|
2616
|
-
});
|
|
2617
|
-
} catch (err) {
|
|
2618
|
-
return this.#handleError(err, c);
|
|
2619
|
-
}
|
|
2620
|
-
return res instanceof Promise ? res.then((resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c))).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c);
|
|
2621
|
-
}
|
|
2622
|
-
const composed = compose(matchResult[0], this.errorHandler, this.#notFoundHandler);
|
|
2623
|
-
return (async () => {
|
|
2624
|
-
try {
|
|
2625
|
-
const context = await composed(c);
|
|
2626
|
-
if (!context.finalized) {
|
|
2627
|
-
throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
|
|
2628
|
-
}
|
|
2629
|
-
return context.res;
|
|
2630
|
-
} catch (err) {
|
|
2631
|
-
return this.#handleError(err, c);
|
|
2632
|
-
}
|
|
2633
|
-
})();
|
|
2634
|
-
}
|
|
2635
|
-
fetch = (request, ...rest) => {
|
|
2636
|
-
return this.#dispatch(request, rest[1], rest[0], request.method);
|
|
2637
|
-
};
|
|
2638
|
-
request = (input, requestInit, Env, executionCtx) => {
|
|
2639
|
-
if (input instanceof Request) {
|
|
2640
|
-
return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
|
|
2641
|
-
}
|
|
2642
|
-
input = input.toString();
|
|
2643
|
-
return this.fetch(new Request(/^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`, requestInit), Env, executionCtx);
|
|
2644
|
-
};
|
|
2645
|
-
fire = () => {
|
|
2646
|
-
addEventListener("fetch", (event) => {
|
|
2647
|
-
event.respondWith(this.#dispatch(event.request, event, undefined, event.request.method));
|
|
2648
|
-
});
|
|
2649
|
-
};
|
|
2650
|
-
};
|
|
2651
|
-
|
|
2652
|
-
// node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
2653
|
-
var emptyParam = [];
|
|
2654
|
-
function match(method, path) {
|
|
2655
|
-
const matchers = this.buildAllMatchers();
|
|
2656
|
-
const match2 = (method2, path2) => {
|
|
2657
|
-
const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
|
|
2658
|
-
const staticMatch = matcher[2][path2];
|
|
2659
|
-
if (staticMatch) {
|
|
2660
|
-
return staticMatch;
|
|
2661
|
-
}
|
|
2662
|
-
const match3 = path2.match(matcher[0]);
|
|
2663
|
-
if (!match3) {
|
|
2664
|
-
return [[], emptyParam];
|
|
2665
|
-
}
|
|
2666
|
-
const index = match3.indexOf("", 1);
|
|
2667
|
-
return [matcher[1][index], match3];
|
|
2668
|
-
};
|
|
2669
|
-
this.match = match2;
|
|
2670
|
-
return match2(method, path);
|
|
2671
|
-
}
|
|
2672
|
-
|
|
2673
|
-
// node_modules/hono/dist/router/reg-exp-router/node.js
|
|
2674
|
-
var LABEL_REG_EXP_STR = "[^/]+";
|
|
2675
|
-
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
2676
|
-
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
2677
|
-
var PATH_ERROR = /* @__PURE__ */ Symbol();
|
|
2678
|
-
var regExpMetaChars = new Set(".\\+*[^]$()");
|
|
2679
|
-
function compareKey(a, b) {
|
|
2680
|
-
if (a.length === 1) {
|
|
2681
|
-
return b.length === 1 ? a < b ? -1 : 1 : -1;
|
|
2682
|
-
}
|
|
2683
|
-
if (b.length === 1) {
|
|
2684
|
-
return 1;
|
|
2685
|
-
}
|
|
2686
|
-
if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
|
|
2687
|
-
return 1;
|
|
2688
|
-
} else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
|
|
2689
|
-
return -1;
|
|
2690
|
-
}
|
|
2691
|
-
if (a === LABEL_REG_EXP_STR) {
|
|
2692
|
-
return 1;
|
|
2693
|
-
} else if (b === LABEL_REG_EXP_STR) {
|
|
2694
|
-
return -1;
|
|
2695
|
-
}
|
|
2696
|
-
return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
|
|
2697
|
-
}
|
|
2698
|
-
var Node = class _Node {
|
|
2699
|
-
#index;
|
|
2700
|
-
#varIndex;
|
|
2701
|
-
#children = /* @__PURE__ */ Object.create(null);
|
|
2702
|
-
insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
|
|
2703
|
-
if (tokens.length === 0) {
|
|
2704
|
-
if (this.#index !== undefined) {
|
|
2705
|
-
throw PATH_ERROR;
|
|
2706
|
-
}
|
|
2707
|
-
if (pathErrorCheckOnly) {
|
|
2708
|
-
return;
|
|
2709
|
-
}
|
|
2710
|
-
this.#index = index;
|
|
2711
|
-
return;
|
|
2712
|
-
}
|
|
2713
|
-
const [token, ...restTokens] = tokens;
|
|
2714
|
-
const pattern = token === "*" ? restTokens.length === 0 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
2715
|
-
let node;
|
|
2716
|
-
if (pattern) {
|
|
2717
|
-
const name = pattern[1];
|
|
2718
|
-
let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
|
|
2719
|
-
if (name && pattern[2]) {
|
|
2720
|
-
if (regexpStr === ".*") {
|
|
2721
|
-
throw PATH_ERROR;
|
|
2722
|
-
}
|
|
2723
|
-
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
2724
|
-
if (/\((?!\?:)/.test(regexpStr)) {
|
|
2725
|
-
throw PATH_ERROR;
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
node = this.#children[regexpStr];
|
|
2729
|
-
if (!node) {
|
|
2730
|
-
if (Object.keys(this.#children).some((k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) {
|
|
2731
|
-
throw PATH_ERROR;
|
|
2732
|
-
}
|
|
2733
|
-
if (pathErrorCheckOnly) {
|
|
2734
|
-
return;
|
|
2735
|
-
}
|
|
2736
|
-
node = this.#children[regexpStr] = new _Node;
|
|
2737
|
-
if (name !== "") {
|
|
2738
|
-
node.#varIndex = context.varIndex++;
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
|
-
if (!pathErrorCheckOnly && name !== "") {
|
|
2742
|
-
paramMap.push([name, node.#varIndex]);
|
|
2743
|
-
}
|
|
2744
|
-
} else {
|
|
2745
|
-
node = this.#children[token];
|
|
2746
|
-
if (!node) {
|
|
2747
|
-
if (Object.keys(this.#children).some((k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) {
|
|
2748
|
-
throw PATH_ERROR;
|
|
2749
|
-
}
|
|
2750
|
-
if (pathErrorCheckOnly) {
|
|
2751
|
-
return;
|
|
2752
|
-
}
|
|
2753
|
-
node = this.#children[token] = new _Node;
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
|
|
2757
|
-
}
|
|
2758
|
-
buildRegExpStr() {
|
|
2759
|
-
const childKeys = Object.keys(this.#children).sort(compareKey);
|
|
2760
|
-
const strList = childKeys.map((k) => {
|
|
2761
|
-
const c = this.#children[k];
|
|
2762
|
-
return (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
|
|
2763
|
-
});
|
|
2764
|
-
if (typeof this.#index === "number") {
|
|
2765
|
-
strList.unshift(`#${this.#index}`);
|
|
2766
|
-
}
|
|
2767
|
-
if (strList.length === 0) {
|
|
2768
|
-
return "";
|
|
2769
|
-
}
|
|
2770
|
-
if (strList.length === 1) {
|
|
2771
|
-
return strList[0];
|
|
2772
|
-
}
|
|
2773
|
-
return "(?:" + strList.join("|") + ")";
|
|
2774
|
-
}
|
|
2775
|
-
};
|
|
2776
|
-
|
|
2777
|
-
// node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
2778
|
-
var Trie = class {
|
|
2779
|
-
#context = { varIndex: 0 };
|
|
2780
|
-
#root = new Node;
|
|
2781
|
-
insert(path, index, pathErrorCheckOnly) {
|
|
2782
|
-
const paramAssoc = [];
|
|
2783
|
-
const groups = [];
|
|
2784
|
-
for (let i = 0;; ) {
|
|
2785
|
-
let replaced = false;
|
|
2786
|
-
path = path.replace(/\{[^}]+\}/g, (m) => {
|
|
2787
|
-
const mark = `@\\${i}`;
|
|
2788
|
-
groups[i] = [mark, m];
|
|
2789
|
-
i++;
|
|
2790
|
-
replaced = true;
|
|
2791
|
-
return mark;
|
|
2792
|
-
});
|
|
2793
|
-
if (!replaced) {
|
|
2794
|
-
break;
|
|
2795
|
-
}
|
|
2796
|
-
}
|
|
2797
|
-
const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
2798
|
-
for (let i = groups.length - 1;i >= 0; i--) {
|
|
2799
|
-
const [mark] = groups[i];
|
|
2800
|
-
for (let j = tokens.length - 1;j >= 0; j--) {
|
|
2801
|
-
if (tokens[j].indexOf(mark) !== -1) {
|
|
2802
|
-
tokens[j] = tokens[j].replace(mark, groups[i][1]);
|
|
2803
|
-
break;
|
|
2804
|
-
}
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
this.#root.insert(tokens, index, paramAssoc, this.#context, pathErrorCheckOnly);
|
|
2808
|
-
return paramAssoc;
|
|
2809
|
-
}
|
|
2810
|
-
buildRegExp() {
|
|
2811
|
-
let regexp = this.#root.buildRegExpStr();
|
|
2812
|
-
if (regexp === "") {
|
|
2813
|
-
return [/^$/, [], []];
|
|
2814
|
-
}
|
|
2815
|
-
let captureIndex = 0;
|
|
2816
|
-
const indexReplacementMap = [];
|
|
2817
|
-
const paramReplacementMap = [];
|
|
2818
|
-
regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex) => {
|
|
2819
|
-
if (handlerIndex !== undefined) {
|
|
2820
|
-
indexReplacementMap[++captureIndex] = Number(handlerIndex);
|
|
2821
|
-
return "$()";
|
|
2822
|
-
}
|
|
2823
|
-
if (paramIndex !== undefined) {
|
|
2824
|
-
paramReplacementMap[Number(paramIndex)] = ++captureIndex;
|
|
2825
|
-
return "";
|
|
2826
|
-
}
|
|
2827
|
-
return "";
|
|
2828
|
-
});
|
|
2829
|
-
return [new RegExp(`^${regexp}`), indexReplacementMap, paramReplacementMap];
|
|
2830
|
-
}
|
|
2831
|
-
};
|
|
2832
|
-
|
|
2833
|
-
// node_modules/hono/dist/router/reg-exp-router/router.js
|
|
2834
|
-
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
2835
|
-
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
2836
|
-
function buildWildcardRegExp(path) {
|
|
2837
|
-
return wildcardRegExpCache[path] ??= new RegExp(path === "*" ? "" : `^${path.replace(/\/\*$|([.\\+*[^\]$()])/g, (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)")}$`);
|
|
2838
|
-
}
|
|
2839
|
-
function clearWildcardRegExpCache() {
|
|
2840
|
-
wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
2841
|
-
}
|
|
2842
|
-
function buildMatcherFromPreprocessedRoutes(routes) {
|
|
2843
|
-
const trie = new Trie;
|
|
2844
|
-
const handlerData = [];
|
|
2845
|
-
if (routes.length === 0) {
|
|
2846
|
-
return nullMatcher;
|
|
2847
|
-
}
|
|
2848
|
-
const routesWithStaticPathFlag = routes.map((route) => [!/\*|\/:/.test(route[0]), ...route]).sort(([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length);
|
|
2849
|
-
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
2850
|
-
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length;i < len; i++) {
|
|
2851
|
-
const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
|
|
2852
|
-
if (pathErrorCheckOnly) {
|
|
2853
|
-
staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
2854
|
-
} else {
|
|
2855
|
-
j++;
|
|
2856
|
-
}
|
|
2857
|
-
let paramAssoc;
|
|
2858
|
-
try {
|
|
2859
|
-
paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
|
|
2860
|
-
} catch (e) {
|
|
2861
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
|
|
2862
|
-
}
|
|
2863
|
-
if (pathErrorCheckOnly) {
|
|
2864
|
-
continue;
|
|
2865
|
-
}
|
|
2866
|
-
handlerData[j] = handlers.map(([h, paramCount]) => {
|
|
2867
|
-
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
2868
|
-
paramCount -= 1;
|
|
2869
|
-
for (;paramCount >= 0; paramCount--) {
|
|
2870
|
-
const [key, value] = paramAssoc[paramCount];
|
|
2871
|
-
paramIndexMap[key] = value;
|
|
2872
|
-
}
|
|
2873
|
-
return [h, paramIndexMap];
|
|
2874
|
-
});
|
|
2875
|
-
}
|
|
2876
|
-
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
2877
|
-
for (let i = 0, len = handlerData.length;i < len; i++) {
|
|
2878
|
-
for (let j = 0, len2 = handlerData[i].length;j < len2; j++) {
|
|
2879
|
-
const map = handlerData[i][j]?.[1];
|
|
2880
|
-
if (!map) {
|
|
2881
|
-
continue;
|
|
2882
|
-
}
|
|
2883
|
-
const keys = Object.keys(map);
|
|
2884
|
-
for (let k = 0, len3 = keys.length;k < len3; k++) {
|
|
2885
|
-
map[keys[k]] = paramReplacementMap[map[keys[k]]];
|
|
2886
|
-
}
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
const handlerMap = [];
|
|
2890
|
-
for (const i in indexReplacementMap) {
|
|
2891
|
-
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
2892
|
-
}
|
|
2893
|
-
return [regexp, handlerMap, staticMap];
|
|
2894
|
-
}
|
|
2895
|
-
function findMiddleware(middleware, path) {
|
|
2896
|
-
if (!middleware) {
|
|
2897
|
-
return;
|
|
2898
|
-
}
|
|
2899
|
-
for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
|
|
2900
|
-
if (buildWildcardRegExp(k).test(path)) {
|
|
2901
|
-
return [...middleware[k]];
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
return;
|
|
2905
|
-
}
|
|
2906
|
-
var RegExpRouter = class {
|
|
2907
|
-
name = "RegExpRouter";
|
|
2908
|
-
#middleware;
|
|
2909
|
-
#routes;
|
|
2910
|
-
constructor() {
|
|
2911
|
-
this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
2912
|
-
this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
2913
|
-
}
|
|
2914
|
-
add(method, path, handler) {
|
|
2915
|
-
const middleware = this.#middleware;
|
|
2916
|
-
const routes = this.#routes;
|
|
2917
|
-
if (!middleware || !routes) {
|
|
2918
|
-
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
2919
|
-
}
|
|
2920
|
-
if (!middleware[method]) {
|
|
2921
|
-
[middleware, routes].forEach((handlerMap) => {
|
|
2922
|
-
handlerMap[method] = /* @__PURE__ */ Object.create(null);
|
|
2923
|
-
Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
|
|
2924
|
-
handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
|
|
2925
|
-
});
|
|
2926
|
-
});
|
|
2927
|
-
}
|
|
2928
|
-
if (path === "/*") {
|
|
2929
|
-
path = "*";
|
|
2930
|
-
}
|
|
2931
|
-
const paramCount = (path.match(/\/:/g) || []).length;
|
|
2932
|
-
if (/\*$/.test(path)) {
|
|
2933
|
-
const re = buildWildcardRegExp(path);
|
|
2934
|
-
if (method === METHOD_NAME_ALL) {
|
|
2935
|
-
Object.keys(middleware).forEach((m) => {
|
|
2936
|
-
middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
2937
|
-
});
|
|
2938
|
-
} else {
|
|
2939
|
-
middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
2940
|
-
}
|
|
2941
|
-
Object.keys(middleware).forEach((m) => {
|
|
2942
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
2943
|
-
Object.keys(middleware[m]).forEach((p) => {
|
|
2944
|
-
re.test(p) && middleware[m][p].push([handler, paramCount]);
|
|
2945
|
-
});
|
|
2946
|
-
}
|
|
2947
|
-
});
|
|
2948
|
-
Object.keys(routes).forEach((m) => {
|
|
2949
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
2950
|
-
Object.keys(routes[m]).forEach((p) => re.test(p) && routes[m][p].push([handler, paramCount]));
|
|
2951
|
-
}
|
|
2952
|
-
});
|
|
2953
|
-
return;
|
|
2954
|
-
}
|
|
2955
|
-
const paths = checkOptionalParameter(path) || [path];
|
|
2956
|
-
for (let i = 0, len = paths.length;i < len; i++) {
|
|
2957
|
-
const path2 = paths[i];
|
|
2958
|
-
Object.keys(routes).forEach((m) => {
|
|
2959
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
2960
|
-
routes[m][path2] ||= [
|
|
2961
|
-
...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
|
|
2962
|
-
];
|
|
2963
|
-
routes[m][path2].push([handler, paramCount - len + i + 1]);
|
|
2964
|
-
}
|
|
2965
|
-
});
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
match = match;
|
|
2969
|
-
buildAllMatchers() {
|
|
2970
|
-
const matchers = /* @__PURE__ */ Object.create(null);
|
|
2971
|
-
Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach((method) => {
|
|
2972
|
-
matchers[method] ||= this.#buildMatcher(method);
|
|
2973
|
-
});
|
|
2974
|
-
this.#middleware = this.#routes = undefined;
|
|
2975
|
-
clearWildcardRegExpCache();
|
|
2976
|
-
return matchers;
|
|
2977
|
-
}
|
|
2978
|
-
#buildMatcher(method) {
|
|
2979
|
-
const routes = [];
|
|
2980
|
-
let hasOwnRoute = method === METHOD_NAME_ALL;
|
|
2981
|
-
[this.#middleware, this.#routes].forEach((r) => {
|
|
2982
|
-
const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];
|
|
2983
|
-
if (ownRoute.length !== 0) {
|
|
2984
|
-
hasOwnRoute ||= true;
|
|
2985
|
-
routes.push(...ownRoute);
|
|
2986
|
-
} else if (method !== METHOD_NAME_ALL) {
|
|
2987
|
-
routes.push(...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]]));
|
|
2988
|
-
}
|
|
2989
|
-
});
|
|
2990
|
-
if (!hasOwnRoute) {
|
|
2991
|
-
return null;
|
|
2992
|
-
} else {
|
|
2993
|
-
return buildMatcherFromPreprocessedRoutes(routes);
|
|
2994
|
-
}
|
|
2995
|
-
}
|
|
2996
|
-
};
|
|
2997
|
-
|
|
2998
|
-
// node_modules/hono/dist/router/smart-router/router.js
|
|
2999
|
-
var SmartRouter = class {
|
|
3000
|
-
name = "SmartRouter";
|
|
3001
|
-
#routers = [];
|
|
3002
|
-
#routes = [];
|
|
3003
|
-
constructor(init) {
|
|
3004
|
-
this.#routers = init.routers;
|
|
3005
|
-
}
|
|
3006
|
-
add(method, path, handler) {
|
|
3007
|
-
if (!this.#routes) {
|
|
3008
|
-
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
3009
|
-
}
|
|
3010
|
-
this.#routes.push([method, path, handler]);
|
|
3011
|
-
}
|
|
3012
|
-
match(method, path) {
|
|
3013
|
-
if (!this.#routes) {
|
|
3014
|
-
throw new Error("Fatal error");
|
|
3015
|
-
}
|
|
3016
|
-
const routers = this.#routers;
|
|
3017
|
-
const routes = this.#routes;
|
|
3018
|
-
const len = routers.length;
|
|
3019
|
-
let i = 0;
|
|
3020
|
-
let res;
|
|
3021
|
-
for (;i < len; i++) {
|
|
3022
|
-
const router = routers[i];
|
|
3023
|
-
try {
|
|
3024
|
-
for (let i2 = 0, len2 = routes.length;i2 < len2; i2++) {
|
|
3025
|
-
router.add(...routes[i2]);
|
|
3026
|
-
}
|
|
3027
|
-
res = router.match(method, path);
|
|
3028
|
-
} catch (e) {
|
|
3029
|
-
if (e instanceof UnsupportedPathError) {
|
|
3030
|
-
continue;
|
|
3031
|
-
}
|
|
3032
|
-
throw e;
|
|
3033
|
-
}
|
|
3034
|
-
this.match = router.match.bind(router);
|
|
3035
|
-
this.#routers = [router];
|
|
3036
|
-
this.#routes = undefined;
|
|
3037
|
-
break;
|
|
3038
|
-
}
|
|
3039
|
-
if (i === len) {
|
|
3040
|
-
throw new Error("Fatal error");
|
|
3041
|
-
}
|
|
3042
|
-
this.name = `SmartRouter + ${this.activeRouter.name}`;
|
|
3043
|
-
return res;
|
|
3044
|
-
}
|
|
3045
|
-
get activeRouter() {
|
|
3046
|
-
if (this.#routes || this.#routers.length !== 1) {
|
|
3047
|
-
throw new Error("No active router has been determined yet.");
|
|
3048
|
-
}
|
|
3049
|
-
return this.#routers[0];
|
|
3050
|
-
}
|
|
3051
|
-
};
|
|
3052
|
-
|
|
3053
|
-
// node_modules/hono/dist/router/trie-router/node.js
|
|
3054
|
-
var emptyParams = /* @__PURE__ */ Object.create(null);
|
|
3055
|
-
var hasChildren = (children) => {
|
|
3056
|
-
for (const _ in children) {
|
|
3057
|
-
return true;
|
|
3058
|
-
}
|
|
3059
|
-
return false;
|
|
3060
|
-
};
|
|
3061
|
-
var Node2 = class _Node2 {
|
|
3062
|
-
#methods;
|
|
3063
|
-
#children;
|
|
3064
|
-
#patterns;
|
|
3065
|
-
#order = 0;
|
|
3066
|
-
#params = emptyParams;
|
|
3067
|
-
constructor(method, handler, children) {
|
|
3068
|
-
this.#children = children || /* @__PURE__ */ Object.create(null);
|
|
3069
|
-
this.#methods = [];
|
|
3070
|
-
if (method && handler) {
|
|
3071
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
3072
|
-
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
3073
|
-
this.#methods = [m];
|
|
3074
|
-
}
|
|
3075
|
-
this.#patterns = [];
|
|
3076
|
-
}
|
|
3077
|
-
insert(method, path, handler) {
|
|
3078
|
-
this.#order = ++this.#order;
|
|
3079
|
-
let curNode = this;
|
|
3080
|
-
const parts = splitRoutingPath(path);
|
|
3081
|
-
const possibleKeys = [];
|
|
3082
|
-
for (let i = 0, len = parts.length;i < len; i++) {
|
|
3083
|
-
const p = parts[i];
|
|
3084
|
-
const nextP = parts[i + 1];
|
|
3085
|
-
const pattern = getPattern(p, nextP);
|
|
3086
|
-
const key = Array.isArray(pattern) ? pattern[0] : p;
|
|
3087
|
-
if (key in curNode.#children) {
|
|
3088
|
-
curNode = curNode.#children[key];
|
|
3089
|
-
if (pattern) {
|
|
3090
|
-
possibleKeys.push(pattern[1]);
|
|
3091
|
-
}
|
|
3092
|
-
continue;
|
|
3093
|
-
}
|
|
3094
|
-
curNode.#children[key] = new _Node2;
|
|
3095
|
-
if (pattern) {
|
|
3096
|
-
curNode.#patterns.push(pattern);
|
|
3097
|
-
possibleKeys.push(pattern[1]);
|
|
3098
|
-
}
|
|
3099
|
-
curNode = curNode.#children[key];
|
|
3100
|
-
}
|
|
3101
|
-
curNode.#methods.push({
|
|
3102
|
-
[method]: {
|
|
3103
|
-
handler,
|
|
3104
|
-
possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
|
|
3105
|
-
score: this.#order
|
|
3106
|
-
}
|
|
3107
|
-
});
|
|
3108
|
-
return curNode;
|
|
3109
|
-
}
|
|
3110
|
-
#pushHandlerSets(handlerSets, node, method, nodeParams, params) {
|
|
3111
|
-
for (let i = 0, len = node.#methods.length;i < len; i++) {
|
|
3112
|
-
const m = node.#methods[i];
|
|
3113
|
-
const handlerSet = m[method] || m[METHOD_NAME_ALL];
|
|
3114
|
-
const processedSet = {};
|
|
3115
|
-
if (handlerSet !== undefined) {
|
|
3116
|
-
handlerSet.params = /* @__PURE__ */ Object.create(null);
|
|
3117
|
-
handlerSets.push(handlerSet);
|
|
3118
|
-
if (nodeParams !== emptyParams || params && params !== emptyParams) {
|
|
3119
|
-
for (let i2 = 0, len2 = handlerSet.possibleKeys.length;i2 < len2; i2++) {
|
|
3120
|
-
const key = handlerSet.possibleKeys[i2];
|
|
3121
|
-
const processed = processedSet[handlerSet.score];
|
|
3122
|
-
handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
|
|
3123
|
-
processedSet[handlerSet.score] = true;
|
|
3124
|
-
}
|
|
3125
|
-
}
|
|
3126
|
-
}
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
search(method, path) {
|
|
3130
|
-
const handlerSets = [];
|
|
3131
|
-
this.#params = emptyParams;
|
|
3132
|
-
const curNode = this;
|
|
3133
|
-
let curNodes = [curNode];
|
|
3134
|
-
const parts = splitPath(path);
|
|
3135
|
-
const curNodesQueue = [];
|
|
3136
|
-
const len = parts.length;
|
|
3137
|
-
let partOffsets = null;
|
|
3138
|
-
for (let i = 0;i < len; i++) {
|
|
3139
|
-
const part = parts[i];
|
|
3140
|
-
const isLast = i === len - 1;
|
|
3141
|
-
const tempNodes = [];
|
|
3142
|
-
for (let j = 0, len2 = curNodes.length;j < len2; j++) {
|
|
3143
|
-
const node = curNodes[j];
|
|
3144
|
-
const nextNode = node.#children[part];
|
|
3145
|
-
if (nextNode) {
|
|
3146
|
-
nextNode.#params = node.#params;
|
|
3147
|
-
if (isLast) {
|
|
3148
|
-
if (nextNode.#children["*"]) {
|
|
3149
|
-
this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node.#params);
|
|
3150
|
-
}
|
|
3151
|
-
this.#pushHandlerSets(handlerSets, nextNode, method, node.#params);
|
|
3152
|
-
} else {
|
|
3153
|
-
tempNodes.push(nextNode);
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
for (let k = 0, len3 = node.#patterns.length;k < len3; k++) {
|
|
3157
|
-
const pattern = node.#patterns[k];
|
|
3158
|
-
const params = node.#params === emptyParams ? {} : { ...node.#params };
|
|
3159
|
-
if (pattern === "*") {
|
|
3160
|
-
const astNode = node.#children["*"];
|
|
3161
|
-
if (astNode) {
|
|
3162
|
-
this.#pushHandlerSets(handlerSets, astNode, method, node.#params);
|
|
3163
|
-
astNode.#params = params;
|
|
3164
|
-
tempNodes.push(astNode);
|
|
3165
|
-
}
|
|
3166
|
-
continue;
|
|
3167
|
-
}
|
|
3168
|
-
const [key, name, matcher] = pattern;
|
|
3169
|
-
if (!part && !(matcher instanceof RegExp)) {
|
|
3170
|
-
continue;
|
|
3171
|
-
}
|
|
3172
|
-
const child = node.#children[key];
|
|
3173
|
-
if (matcher instanceof RegExp) {
|
|
3174
|
-
if (partOffsets === null) {
|
|
3175
|
-
partOffsets = new Array(len);
|
|
3176
|
-
let offset = path[0] === "/" ? 1 : 0;
|
|
3177
|
-
for (let p = 0;p < len; p++) {
|
|
3178
|
-
partOffsets[p] = offset;
|
|
3179
|
-
offset += parts[p].length + 1;
|
|
3180
|
-
}
|
|
3181
|
-
}
|
|
3182
|
-
const restPathString = path.substring(partOffsets[i]);
|
|
3183
|
-
const m = matcher.exec(restPathString);
|
|
3184
|
-
if (m) {
|
|
3185
|
-
params[name] = m[0];
|
|
3186
|
-
this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
|
|
3187
|
-
if (hasChildren(child.#children)) {
|
|
3188
|
-
child.#params = params;
|
|
3189
|
-
const componentCount = m[0].match(/\//)?.length ?? 0;
|
|
3190
|
-
const targetCurNodes = curNodesQueue[componentCount] ||= [];
|
|
3191
|
-
targetCurNodes.push(child);
|
|
3192
|
-
}
|
|
3193
|
-
continue;
|
|
3194
|
-
}
|
|
3195
|
-
}
|
|
3196
|
-
if (matcher === true || matcher.test(part)) {
|
|
3197
|
-
params[name] = part;
|
|
3198
|
-
if (isLast) {
|
|
3199
|
-
this.#pushHandlerSets(handlerSets, child, method, params, node.#params);
|
|
3200
|
-
if (child.#children["*"]) {
|
|
3201
|
-
this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node.#params);
|
|
3202
|
-
}
|
|
3203
|
-
} else {
|
|
3204
|
-
child.#params = params;
|
|
3205
|
-
tempNodes.push(child);
|
|
3206
|
-
}
|
|
3207
|
-
}
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
const shifted = curNodesQueue.shift();
|
|
3211
|
-
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
3212
|
-
}
|
|
3213
|
-
if (handlerSets.length > 1) {
|
|
3214
|
-
handlerSets.sort((a, b) => {
|
|
3215
|
-
return a.score - b.score;
|
|
3216
|
-
});
|
|
3217
|
-
}
|
|
3218
|
-
return [handlerSets.map(({ handler, params }) => [handler, params])];
|
|
3219
|
-
}
|
|
3220
|
-
};
|
|
3221
|
-
|
|
3222
|
-
// node_modules/hono/dist/router/trie-router/router.js
|
|
3223
|
-
var TrieRouter = class {
|
|
3224
|
-
name = "TrieRouter";
|
|
3225
|
-
#node;
|
|
3226
|
-
constructor() {
|
|
3227
|
-
this.#node = new Node2;
|
|
3228
|
-
}
|
|
3229
|
-
add(method, path, handler) {
|
|
3230
|
-
const results = checkOptionalParameter(path);
|
|
3231
|
-
if (results) {
|
|
3232
|
-
for (let i = 0, len = results.length;i < len; i++) {
|
|
3233
|
-
this.#node.insert(method, results[i], handler);
|
|
3234
|
-
}
|
|
3235
|
-
return;
|
|
3236
|
-
}
|
|
3237
|
-
this.#node.insert(method, path, handler);
|
|
3238
|
-
}
|
|
3239
|
-
match(method, path) {
|
|
3240
|
-
return this.#node.search(method, path);
|
|
3241
|
-
}
|
|
3242
|
-
};
|
|
3243
|
-
|
|
3244
|
-
// node_modules/hono/dist/hono.js
|
|
3245
|
-
var Hono2 = class extends Hono {
|
|
3246
|
-
constructor(options = {}) {
|
|
3247
|
-
super(options);
|
|
3248
|
-
this.router = options.router ?? new SmartRouter({
|
|
3249
|
-
routers: [new RegExpRouter, new TrieRouter]
|
|
3250
|
-
});
|
|
3251
|
-
}
|
|
3252
|
-
};
|
|
3253
|
-
|
|
3254
|
-
// node_modules/hono/dist/adapter/bun/serve-static.js
|
|
3255
|
-
import { stat } from "node:fs/promises";
|
|
3256
|
-
import { join } from "node:path";
|
|
3257
|
-
|
|
3258
|
-
// node_modules/hono/dist/utils/compress.js
|
|
3259
|
-
var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
3260
|
-
|
|
3261
|
-
// node_modules/hono/dist/utils/mime.js
|
|
3262
|
-
var getMimeType = (filename, mimes = baseMimes) => {
|
|
3263
|
-
const regexp = /\.([a-zA-Z0-9]+?)$/;
|
|
3264
|
-
const match2 = filename.match(regexp);
|
|
3265
|
-
if (!match2) {
|
|
3266
|
-
return;
|
|
3267
|
-
}
|
|
3268
|
-
let mimeType = mimes[match2[1]];
|
|
3269
|
-
if (mimeType && mimeType.startsWith("text")) {
|
|
3270
|
-
mimeType += "; charset=utf-8";
|
|
3271
|
-
}
|
|
3272
|
-
return mimeType;
|
|
3273
|
-
};
|
|
3274
|
-
var _baseMimes = {
|
|
3275
|
-
aac: "audio/aac",
|
|
3276
|
-
avi: "video/x-msvideo",
|
|
3277
|
-
avif: "image/avif",
|
|
3278
|
-
av1: "video/av1",
|
|
3279
|
-
bin: "application/octet-stream",
|
|
3280
|
-
bmp: "image/bmp",
|
|
3281
|
-
css: "text/css",
|
|
3282
|
-
csv: "text/csv",
|
|
3283
|
-
eot: "application/vnd.ms-fontobject",
|
|
3284
|
-
epub: "application/epub+zip",
|
|
3285
|
-
gif: "image/gif",
|
|
3286
|
-
gz: "application/gzip",
|
|
3287
|
-
htm: "text/html",
|
|
3288
|
-
html: "text/html",
|
|
3289
|
-
ico: "image/x-icon",
|
|
3290
|
-
ics: "text/calendar",
|
|
3291
|
-
jpeg: "image/jpeg",
|
|
3292
|
-
jpg: "image/jpeg",
|
|
3293
|
-
js: "text/javascript",
|
|
3294
|
-
json: "application/json",
|
|
3295
|
-
jsonld: "application/ld+json",
|
|
3296
|
-
map: "application/json",
|
|
3297
|
-
mid: "audio/x-midi",
|
|
3298
|
-
midi: "audio/x-midi",
|
|
3299
|
-
mjs: "text/javascript",
|
|
3300
|
-
mp3: "audio/mpeg",
|
|
3301
|
-
mp4: "video/mp4",
|
|
3302
|
-
mpeg: "video/mpeg",
|
|
3303
|
-
oga: "audio/ogg",
|
|
3304
|
-
ogv: "video/ogg",
|
|
3305
|
-
ogx: "application/ogg",
|
|
3306
|
-
opus: "audio/opus",
|
|
3307
|
-
otf: "font/otf",
|
|
3308
|
-
pdf: "application/pdf",
|
|
3309
|
-
png: "image/png",
|
|
3310
|
-
rtf: "application/rtf",
|
|
3311
|
-
svg: "image/svg+xml",
|
|
3312
|
-
tif: "image/tiff",
|
|
3313
|
-
tiff: "image/tiff",
|
|
3314
|
-
ts: "video/mp2t",
|
|
3315
|
-
ttf: "font/ttf",
|
|
3316
|
-
txt: "text/plain",
|
|
3317
|
-
wasm: "application/wasm",
|
|
3318
|
-
webm: "video/webm",
|
|
3319
|
-
weba: "audio/webm",
|
|
3320
|
-
webmanifest: "application/manifest+json",
|
|
3321
|
-
webp: "image/webp",
|
|
3322
|
-
woff: "font/woff",
|
|
3323
|
-
woff2: "font/woff2",
|
|
3324
|
-
xhtml: "application/xhtml+xml",
|
|
3325
|
-
xml: "application/xml",
|
|
3326
|
-
zip: "application/zip",
|
|
3327
|
-
"3gp": "video/3gpp",
|
|
3328
|
-
"3g2": "video/3gpp2",
|
|
3329
|
-
gltf: "model/gltf+json",
|
|
3330
|
-
glb: "model/gltf-binary"
|
|
3331
|
-
};
|
|
3332
|
-
var baseMimes = _baseMimes;
|
|
3333
|
-
|
|
3334
|
-
// node_modules/hono/dist/middleware/serve-static/path.js
|
|
3335
|
-
var defaultJoin = (...paths) => {
|
|
3336
|
-
let result = paths.filter((p) => p !== "").join("/");
|
|
3337
|
-
result = result.replace(/(?<=\/)\/+/g, "");
|
|
3338
|
-
const segments = result.split("/");
|
|
3339
|
-
const resolved = [];
|
|
3340
|
-
for (const segment of segments) {
|
|
3341
|
-
if (segment === ".." && resolved.length > 0 && resolved.at(-1) !== "..") {
|
|
3342
|
-
resolved.pop();
|
|
3343
|
-
} else if (segment !== ".") {
|
|
3344
|
-
resolved.push(segment);
|
|
3345
|
-
}
|
|
3346
|
-
}
|
|
3347
|
-
return resolved.join("/") || ".";
|
|
3348
|
-
};
|
|
3349
|
-
|
|
3350
|
-
// node_modules/hono/dist/middleware/serve-static/index.js
|
|
3351
|
-
var ENCODINGS = {
|
|
3352
|
-
br: ".br",
|
|
3353
|
-
zstd: ".zst",
|
|
3354
|
-
gzip: ".gz"
|
|
3355
|
-
};
|
|
3356
|
-
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
3357
|
-
var DEFAULT_DOCUMENT = "index.html";
|
|
3358
|
-
var serveStatic = (options) => {
|
|
3359
|
-
const root = options.root ?? "./";
|
|
3360
|
-
const optionPath = options.path;
|
|
3361
|
-
const join = options.join ?? defaultJoin;
|
|
3362
|
-
return async (c, next) => {
|
|
3363
|
-
if (c.finalized) {
|
|
3364
|
-
return next();
|
|
3365
|
-
}
|
|
3366
|
-
let filename;
|
|
3367
|
-
if (options.path) {
|
|
3368
|
-
filename = options.path;
|
|
3369
|
-
} else {
|
|
3370
|
-
try {
|
|
3371
|
-
filename = decodeURIComponent(c.req.path);
|
|
3372
|
-
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
|
|
3373
|
-
throw new Error;
|
|
3374
|
-
}
|
|
3375
|
-
} catch {
|
|
3376
|
-
await options.onNotFound?.(c.req.path, c);
|
|
3377
|
-
return next();
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
|
-
let path = join(root, !optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename);
|
|
3381
|
-
if (options.isDir && await options.isDir(path)) {
|
|
3382
|
-
path = join(path, DEFAULT_DOCUMENT);
|
|
3383
|
-
}
|
|
3384
|
-
const getContent = options.getContent;
|
|
3385
|
-
let content = await getContent(path, c);
|
|
3386
|
-
if (content instanceof Response) {
|
|
3387
|
-
return c.newResponse(content.body, content);
|
|
3388
|
-
}
|
|
3389
|
-
if (content) {
|
|
3390
|
-
const mimeType = options.mimes && getMimeType(path, options.mimes) || getMimeType(path);
|
|
3391
|
-
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
3392
|
-
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
3393
|
-
const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim()));
|
|
3394
|
-
for (const encoding of ENCODINGS_ORDERED_KEYS) {
|
|
3395
|
-
if (!acceptEncodingSet.has(encoding)) {
|
|
3396
|
-
continue;
|
|
3397
|
-
}
|
|
3398
|
-
const compressedContent = await getContent(path + ENCODINGS[encoding], c);
|
|
3399
|
-
if (compressedContent) {
|
|
3400
|
-
content = compressedContent;
|
|
3401
|
-
c.header("Content-Encoding", encoding);
|
|
3402
|
-
c.header("Vary", "Accept-Encoding", { append: true });
|
|
3403
|
-
break;
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
}
|
|
3407
|
-
await options.onFound?.(path, c);
|
|
3408
|
-
return c.body(content);
|
|
3409
|
-
}
|
|
3410
|
-
await options.onNotFound?.(path, c);
|
|
3411
|
-
await next();
|
|
3412
|
-
return;
|
|
3413
|
-
};
|
|
3414
|
-
};
|
|
3415
|
-
|
|
3416
|
-
// node_modules/hono/dist/adapter/bun/serve-static.js
|
|
3417
|
-
var serveStatic2 = (options) => {
|
|
3418
|
-
return async function serveStatic22(c, next) {
|
|
3419
|
-
const getContent = async (path) => {
|
|
3420
|
-
const file = Bun.file(path);
|
|
3421
|
-
return await file.exists() ? file : null;
|
|
3422
|
-
};
|
|
3423
|
-
const isDir = async (path) => {
|
|
3424
|
-
let isDir2;
|
|
3425
|
-
try {
|
|
3426
|
-
const stats = await stat(path);
|
|
3427
|
-
isDir2 = stats.isDirectory();
|
|
3428
|
-
} catch {}
|
|
3429
|
-
return isDir2;
|
|
3430
|
-
};
|
|
3431
|
-
return serveStatic({
|
|
3432
|
-
...options,
|
|
3433
|
-
getContent,
|
|
3434
|
-
join,
|
|
3435
|
-
isDir
|
|
3436
|
-
})(c, next);
|
|
3437
|
-
};
|
|
3438
|
-
};
|
|
3439
|
-
|
|
3440
|
-
// node_modules/hono/dist/helper/ssg/middleware.js
|
|
3441
|
-
var X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
|
|
3442
|
-
var SSG_DISABLED_RESPONSE = (() => {
|
|
3443
|
-
try {
|
|
3444
|
-
return new Response("SSG is disabled", {
|
|
3445
|
-
status: 404,
|
|
3446
|
-
headers: { [X_HONO_DISABLE_SSG_HEADER_KEY]: "true" }
|
|
3447
|
-
});
|
|
3448
|
-
} catch {
|
|
3449
|
-
return null;
|
|
3450
|
-
}
|
|
3451
|
-
})();
|
|
3452
|
-
// node_modules/hono/dist/adapter/bun/ssg.js
|
|
3453
|
-
var { write } = Bun;
|
|
3454
|
-
|
|
3455
|
-
// node_modules/hono/dist/helper/websocket/index.js
|
|
3456
|
-
var defineWebSocketHelper = (handler) => {
|
|
3457
|
-
return (...args) => {
|
|
3458
|
-
if (typeof args[0] === "function") {
|
|
3459
|
-
const [createEvents, options] = args;
|
|
3460
|
-
return async function upgradeWebSocket(c, next) {
|
|
3461
|
-
const events = await createEvents(c);
|
|
3462
|
-
const result = await handler(c, events, options);
|
|
3463
|
-
if (result) {
|
|
3464
|
-
return result;
|
|
3465
|
-
}
|
|
3466
|
-
await next();
|
|
3467
|
-
};
|
|
3468
|
-
} else {
|
|
3469
|
-
const [c, events, options] = args;
|
|
3470
|
-
return (async () => {
|
|
3471
|
-
const upgraded = await handler(c, events, options);
|
|
3472
|
-
if (!upgraded) {
|
|
3473
|
-
throw new Error("Failed to upgrade WebSocket");
|
|
3474
|
-
}
|
|
3475
|
-
return upgraded;
|
|
3476
|
-
})();
|
|
3477
|
-
}
|
|
3478
|
-
};
|
|
3479
|
-
};
|
|
3480
|
-
|
|
3481
|
-
// node_modules/hono/dist/adapter/bun/server.js
|
|
3482
|
-
var getBunServer = (c) => ("server" in c.env) ? c.env.server : c.env;
|
|
3483
|
-
|
|
3484
|
-
// node_modules/hono/dist/adapter/bun/websocket.js
|
|
3485
|
-
var upgradeWebSocket = defineWebSocketHelper((c, events) => {
|
|
3486
|
-
const server = getBunServer(c);
|
|
3487
|
-
if (!server) {
|
|
3488
|
-
throw new TypeError("env has to include the 2nd argument of fetch.");
|
|
3489
|
-
}
|
|
3490
|
-
const upgradeResult = server.upgrade(c.req.raw, {
|
|
3491
|
-
data: {
|
|
3492
|
-
events,
|
|
3493
|
-
url: new URL(c.req.url),
|
|
3494
|
-
protocol: c.req.url
|
|
3495
|
-
}
|
|
3496
|
-
});
|
|
3497
|
-
if (upgradeResult) {
|
|
3498
|
-
return new Response(null);
|
|
3499
|
-
}
|
|
3500
|
-
return;
|
|
3501
|
-
});
|
|
3502
|
-
|
|
3503
|
-
// src/artifact-sdk/server.ts
|
|
3504
|
-
init_api_key();
|
|
3505
|
-
init_constants();
|
|
3506
|
-
|
|
3507
|
-
// src/artifact-sdk/port.ts
|
|
3508
|
-
import { createServer } from "node:net";
|
|
3509
|
-
async function getAvailablePort() {
|
|
3510
|
-
return new Promise((resolve, reject) => {
|
|
3511
|
-
const server = createServer();
|
|
3512
|
-
server.listen(0, () => {
|
|
3513
|
-
const { port } = server.address();
|
|
3514
|
-
server.close(() => resolve(port));
|
|
3515
|
-
});
|
|
3516
|
-
server.on("error", reject);
|
|
3517
|
-
});
|
|
3518
|
-
}
|
|
3519
|
-
|
|
3520
|
-
// src/artifact-sdk/tunnel.ts
|
|
3521
|
-
var import_localtunnel = __toESM(require_localtunnel(), 1);
|
|
3522
|
-
async function createTunnel(opts) {
|
|
3523
|
-
const tunnel = await import_localtunnel.default({
|
|
3524
|
-
port: opts.port,
|
|
3525
|
-
subdomain: opts.subdomain,
|
|
3526
|
-
auth: opts.auth,
|
|
3527
|
-
username: opts.username || "hi"
|
|
3528
|
-
});
|
|
3529
|
-
return tunnel;
|
|
3530
|
-
}
|
|
3531
|
-
|
|
3532
|
-
// src/artifact-sdk/server.ts
|
|
3533
|
-
var NativeResponse = globalThis.Response;
|
|
3534
|
-
function createBunResponse(body, init) {
|
|
3535
|
-
return new NativeResponse(body, init);
|
|
3536
|
-
}
|
|
3537
|
-
function createBunHonoFetchHandler(app) {
|
|
3538
|
-
return async (req) => {
|
|
3539
|
-
const response = await app.fetch(req);
|
|
3540
|
-
return createBunResponse(response.body, {
|
|
3541
|
-
status: response.status,
|
|
3542
|
-
statusText: response.statusText,
|
|
3543
|
-
headers: response.headers
|
|
3544
|
-
});
|
|
3545
|
-
};
|
|
3546
|
-
}
|
|
3547
|
-
function createArtifactServer(opts) {
|
|
3548
|
-
const agentId = process.env.AGENT_ID || "unknown";
|
|
3549
|
-
const apiKey = getApiKey();
|
|
3550
|
-
const mcpBaseUrl = getMcpBaseUrl();
|
|
3551
|
-
const app = new Hono2;
|
|
3552
|
-
app.get("/@swarm/sdk.js", (c) => {
|
|
3553
|
-
c.header("Content-Type", "application/javascript");
|
|
3554
|
-
return c.body(BROWSER_SDK_JS);
|
|
3555
|
-
});
|
|
3556
|
-
app.get("/@swarm/config", (c) => {
|
|
3557
|
-
return c.json({ agentId, artifactName: opts.name });
|
|
3558
|
-
});
|
|
3559
|
-
app.all("/@swarm/api/*", async (c) => {
|
|
3560
|
-
const path = c.req.path.replace("/@swarm/api", "/api");
|
|
3561
|
-
const targetUrl = `${mcpBaseUrl}${path}`;
|
|
3562
|
-
const headers = {
|
|
3563
|
-
Authorization: `Bearer ${apiKey}`,
|
|
3564
|
-
"X-Agent-ID": agentId
|
|
3565
|
-
};
|
|
3566
|
-
if (c.req.method !== "GET") {
|
|
3567
|
-
headers["Content-Type"] = "application/json";
|
|
3568
|
-
}
|
|
3569
|
-
try {
|
|
3570
|
-
const res = await fetch(targetUrl, {
|
|
3571
|
-
method: c.req.method,
|
|
3572
|
-
headers,
|
|
3573
|
-
body: c.req.method !== "GET" ? await c.req.text() : undefined
|
|
3574
|
-
});
|
|
3575
|
-
return new Response(res.body, {
|
|
3576
|
-
status: res.status,
|
|
3577
|
-
headers: {
|
|
3578
|
-
"Access-Control-Allow-Origin": "*",
|
|
3579
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
3580
|
-
"Access-Control-Allow-Headers": "Content-Type"
|
|
3581
|
-
}
|
|
3582
|
-
});
|
|
3583
|
-
} catch (e) {
|
|
3584
|
-
return c.json({ error: "Proxy error", message: String(e) }, 502);
|
|
3585
|
-
}
|
|
3586
|
-
});
|
|
3587
|
-
app.options("/@swarm/api/*", (_c) => {
|
|
3588
|
-
return new Response(null, {
|
|
3589
|
-
status: 204,
|
|
3590
|
-
headers: {
|
|
3591
|
-
"Access-Control-Allow-Origin": "*",
|
|
3592
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
3593
|
-
"Access-Control-Allow-Headers": "Content-Type"
|
|
3594
|
-
}
|
|
3595
|
-
});
|
|
3596
|
-
});
|
|
3597
|
-
if (opts.app) {
|
|
3598
|
-
app.route("/", opts.app);
|
|
3599
|
-
} else if (opts.static) {
|
|
3600
|
-
app.use("/*", serveStatic2({ root: opts.static }));
|
|
3601
|
-
}
|
|
3602
|
-
let server = null;
|
|
3603
|
-
let tunnel = null;
|
|
3604
|
-
let actualPort = 0;
|
|
3605
|
-
const artifact = {
|
|
3606
|
-
url: "",
|
|
3607
|
-
port: 0,
|
|
3608
|
-
tunnel: null,
|
|
3609
|
-
async start() {
|
|
3610
|
-
actualPort = opts.port || await getAvailablePort();
|
|
3611
|
-
server = Bun.serve({ port: actualPort, fetch: createBunHonoFetchHandler(app) });
|
|
3612
|
-
artifact.port = actualPort;
|
|
3613
|
-
const subdomain = opts.subdomain || `${agentId}-${opts.name}`;
|
|
3614
|
-
const authPassword = opts.auth === false ? undefined : apiKey;
|
|
3615
|
-
tunnel = await createTunnel({
|
|
3616
|
-
port: actualPort,
|
|
3617
|
-
subdomain,
|
|
3618
|
-
auth: authPassword
|
|
3619
|
-
});
|
|
3620
|
-
artifact.url = tunnel.url;
|
|
3621
|
-
artifact.tunnel = tunnel;
|
|
3622
|
-
try {
|
|
3623
|
-
await fetch(`${mcpBaseUrl}/api/services`, {
|
|
3624
|
-
method: "POST",
|
|
3625
|
-
headers: {
|
|
3626
|
-
Authorization: `Bearer ${apiKey}`,
|
|
3627
|
-
"X-Agent-ID": agentId,
|
|
3628
|
-
"Content-Type": "application/json"
|
|
3629
|
-
},
|
|
3630
|
-
body: JSON.stringify({
|
|
3631
|
-
script: `artifact-${opts.name}`,
|
|
3632
|
-
metadata: {
|
|
3633
|
-
type: "artifact",
|
|
3634
|
-
artifactName: opts.name,
|
|
3635
|
-
port: actualPort,
|
|
3636
|
-
publicUrl: tunnel.url
|
|
3637
|
-
}
|
|
3638
|
-
})
|
|
3639
|
-
});
|
|
3640
|
-
} catch (e) {
|
|
3641
|
-
console.warn("Failed to register artifact in service registry:", e);
|
|
3642
|
-
}
|
|
3643
|
-
console.log(`Artifact "${opts.name}" live at ${tunnel.url} (port ${actualPort})`);
|
|
3644
|
-
},
|
|
3645
|
-
async stop() {
|
|
3646
|
-
if (tunnel) {
|
|
3647
|
-
tunnel.close();
|
|
3648
|
-
tunnel = null;
|
|
3649
|
-
}
|
|
3650
|
-
if (server) {
|
|
3651
|
-
await server.stop(true);
|
|
3652
|
-
server = null;
|
|
3653
|
-
}
|
|
3654
|
-
}
|
|
3655
|
-
};
|
|
3656
|
-
return artifact;
|
|
3657
|
-
}
|
|
3658
|
-
// src/commands/artifact.ts
|
|
3659
|
-
init_api_key();
|
|
3660
|
-
init_constants();
|
|
3661
|
-
async function runArtifact(subcommand, args) {
|
|
3662
|
-
switch (subcommand) {
|
|
3663
|
-
case "serve":
|
|
3664
|
-
return artifactServe(args);
|
|
3665
|
-
case "list":
|
|
3666
|
-
return artifactList();
|
|
3667
|
-
case "stop":
|
|
3668
|
-
return artifactStop(args);
|
|
3669
|
-
default:
|
|
3670
|
-
printHelp();
|
|
3671
|
-
}
|
|
3672
|
-
}
|
|
3673
|
-
function printHelp() {
|
|
3674
|
-
console.log(`Usage: agent-swarm artifact <subcommand>
|
|
3675
|
-
|
|
3676
|
-
Subcommands:
|
|
3677
|
-
serve <path> --name <name> [--port <port>] [--no-auth] [--subdomain <sub>]
|
|
3678
|
-
Serve a directory or script as an artifact via localtunnel
|
|
3679
|
-
|
|
3680
|
-
list
|
|
3681
|
-
List active artifacts (from service registry)
|
|
3682
|
-
|
|
3683
|
-
stop <name>
|
|
3684
|
-
Stop an artifact and close its tunnel
|
|
3685
|
-
|
|
3686
|
-
Examples:
|
|
3687
|
-
agent-swarm artifact serve ./my-report --name my-report
|
|
3688
|
-
agent-swarm artifact serve ./server.ts --name dashboard
|
|
3689
|
-
agent-swarm artifact list
|
|
3690
|
-
agent-swarm artifact stop my-report`);
|
|
3691
|
-
}
|
|
3692
|
-
async function artifactServe(args) {
|
|
3693
|
-
const additionalArgs = args.additionalArgs || [];
|
|
3694
|
-
let path = "";
|
|
3695
|
-
let name = "";
|
|
3696
|
-
let port;
|
|
3697
|
-
let noAuth = false;
|
|
3698
|
-
let subdomain;
|
|
3699
|
-
for (let i = 0;i < additionalArgs.length; i++) {
|
|
3700
|
-
const arg = additionalArgs[i] ?? "";
|
|
3701
|
-
if (arg === "--name") {
|
|
3702
|
-
name = additionalArgs[i + 1] ?? "";
|
|
3703
|
-
i++;
|
|
3704
|
-
} else if (arg === "--port") {
|
|
3705
|
-
port = Number.parseInt(additionalArgs[i + 1] ?? "0", 10);
|
|
3706
|
-
i++;
|
|
3707
|
-
} else if (arg === "--no-auth") {
|
|
3708
|
-
noAuth = true;
|
|
3709
|
-
} else if (arg === "--subdomain") {
|
|
3710
|
-
subdomain = additionalArgs[i + 1] ?? "";
|
|
3711
|
-
i++;
|
|
3712
|
-
} else if (!arg.startsWith("-") && !path) {
|
|
3713
|
-
path = arg;
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
if (!path) {
|
|
3717
|
-
console.error("Error: path is required. Usage: artifact serve <path> --name <name>");
|
|
3718
|
-
process.exit(1);
|
|
3719
|
-
}
|
|
3720
|
-
if (!name) {
|
|
3721
|
-
name = path.split("/").filter(Boolean).pop() || "artifact";
|
|
3722
|
-
}
|
|
3723
|
-
const file = Bun.file(path);
|
|
3724
|
-
const isFile = await file.exists();
|
|
3725
|
-
let app;
|
|
3726
|
-
let staticDir;
|
|
3727
|
-
if (isFile && (path.endsWith(".ts") || path.endsWith(".js"))) {
|
|
3728
|
-
try {
|
|
3729
|
-
const mod = await (path.startsWith("/") ? import(path) : import(`${process.cwd()}/${path}`));
|
|
3730
|
-
if (mod.default instanceof Hono2) {
|
|
3731
|
-
app = mod.default;
|
|
3732
|
-
} else {
|
|
3733
|
-
console.error(`Error: ${path} must export a default Hono app instance`);
|
|
3734
|
-
process.exit(1);
|
|
3735
|
-
}
|
|
3736
|
-
} catch (e) {
|
|
3737
|
-
console.error(`Error loading ${path}:`, e);
|
|
3738
|
-
process.exit(1);
|
|
3739
|
-
}
|
|
3740
|
-
} else {
|
|
3741
|
-
const { existsSync } = await import("node:fs");
|
|
3742
|
-
if (!existsSync(path)) {
|
|
3743
|
-
console.error(`Error: path "${path}" does not exist`);
|
|
3744
|
-
process.exit(1);
|
|
3745
|
-
}
|
|
3746
|
-
staticDir = path;
|
|
3747
|
-
}
|
|
3748
|
-
const server = createArtifactServer({
|
|
3749
|
-
name,
|
|
3750
|
-
app,
|
|
3751
|
-
static: staticDir,
|
|
3752
|
-
port,
|
|
3753
|
-
auth: noAuth ? false : undefined,
|
|
3754
|
-
subdomain
|
|
3755
|
-
});
|
|
3756
|
-
await server.start();
|
|
3757
|
-
process.on("SIGINT", async () => {
|
|
3758
|
-
console.log(`
|
|
3759
|
-
Stopping artifact "${name}"...`);
|
|
3760
|
-
await server.stop();
|
|
3761
|
-
process.exit(0);
|
|
3762
|
-
});
|
|
3763
|
-
process.on("SIGTERM", async () => {
|
|
3764
|
-
await server.stop();
|
|
3765
|
-
process.exit(0);
|
|
3766
|
-
});
|
|
3767
|
-
await new Promise(() => {});
|
|
3768
|
-
}
|
|
3769
|
-
async function artifactList() {
|
|
3770
|
-
const apiKey = getApiKey();
|
|
3771
|
-
const mcpBaseUrl = getMcpBaseUrl();
|
|
3772
|
-
const agentId = process.env.AGENT_ID || "";
|
|
3773
|
-
try {
|
|
3774
|
-
const res = await fetch(`${mcpBaseUrl}/api/services`, {
|
|
3775
|
-
headers: {
|
|
3776
|
-
Authorization: `Bearer ${apiKey}`,
|
|
3777
|
-
"X-Agent-ID": agentId
|
|
3778
|
-
}
|
|
3779
|
-
});
|
|
3780
|
-
if (!res.ok) {
|
|
3781
|
-
console.error(`Failed to fetch services: ${res.status} ${res.statusText}`);
|
|
3782
|
-
process.exit(1);
|
|
3783
|
-
}
|
|
3784
|
-
const body = await res.json();
|
|
3785
|
-
const services = body.services ?? [];
|
|
3786
|
-
const artifacts = services.filter((s) => s.metadata?.type === "artifact");
|
|
3787
|
-
if (artifacts.length === 0) {
|
|
3788
|
-
console.log("No active artifacts");
|
|
3789
|
-
return;
|
|
3790
|
-
}
|
|
3791
|
-
console.log(`${"NAME".padEnd(20)} ${"AGENT".padEnd(16)} ${"PORT".padEnd(8)} ${"URL".padEnd(50)} STATUS`);
|
|
3792
|
-
for (const a of artifacts) {
|
|
3793
|
-
const name = (a.metadata?.artifactName || a.name).padEnd(20);
|
|
3794
|
-
const agent = (a.agentId || "").substring(0, 14).padEnd(16);
|
|
3795
|
-
const port = String(a.metadata?.port || "?").padEnd(8);
|
|
3796
|
-
const url = (a.metadata?.publicUrl || "").padEnd(50);
|
|
3797
|
-
console.log(`${name} ${agent} ${port} ${url} ${a.status}`);
|
|
3798
|
-
}
|
|
3799
|
-
} catch (e) {
|
|
3800
|
-
console.error("Failed to list artifacts:", e);
|
|
3801
|
-
process.exit(1);
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3804
|
-
async function artifactStop(args) {
|
|
3805
|
-
const name = args.additionalArgs?.[0];
|
|
3806
|
-
if (!name) {
|
|
3807
|
-
console.error("Error: name is required. Usage: artifact stop <name>");
|
|
3808
|
-
process.exit(1);
|
|
3809
|
-
}
|
|
3810
|
-
const apiKey = getApiKey();
|
|
3811
|
-
const mcpBaseUrl = getMcpBaseUrl();
|
|
3812
|
-
const agentId = process.env.AGENT_ID || "";
|
|
3813
|
-
try {
|
|
3814
|
-
await Bun.$`pm2 delete artifact-${name} 2>/dev/null`.quiet();
|
|
3815
|
-
console.log(`Stopped PM2 process: artifact-${name}`);
|
|
3816
|
-
} catch {}
|
|
3817
|
-
try {
|
|
3818
|
-
const res = await fetch(`${mcpBaseUrl}/api/services`, {
|
|
3819
|
-
headers: {
|
|
3820
|
-
Authorization: `Bearer ${apiKey}`,
|
|
3821
|
-
"X-Agent-ID": agentId
|
|
3822
|
-
}
|
|
3823
|
-
});
|
|
3824
|
-
if (res.ok) {
|
|
3825
|
-
const body = await res.json();
|
|
3826
|
-
const services = body.services ?? [];
|
|
3827
|
-
const service = services.find((s) => s.metadata?.type === "artifact" && s.metadata?.artifactName === name);
|
|
3828
|
-
if (service) {
|
|
3829
|
-
await fetch(`${mcpBaseUrl}/api/services/${service.id}`, {
|
|
3830
|
-
method: "DELETE",
|
|
3831
|
-
headers: {
|
|
3832
|
-
Authorization: `Bearer ${apiKey}`,
|
|
3833
|
-
"X-Agent-ID": agentId
|
|
3834
|
-
}
|
|
3835
|
-
});
|
|
3836
|
-
}
|
|
3837
|
-
}
|
|
3838
|
-
} catch {}
|
|
3839
|
-
console.log(`Artifact '${name}' stopped.`);
|
|
3840
|
-
}
|
|
3841
|
-
export {
|
|
3842
|
-
runArtifact
|
|
3843
|
-
};
|