bantou 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +13 -0
- package/.output/public/_nuxt/BmGsA4i2.js +1 -0
- package/.output/public/_nuxt/D_G6gzEa.js +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -0
- package/.output/public/_nuxt/builds/meta/1a8fc623-6671-445b-bdd3-c3d073520a3a.json +1 -0
- package/.output/public/_nuxt/entry.CZSvzYhH.css +1 -0
- package/.output/public/_nuxt/error-404.C3wqHTJz.css +1 -0
- package/.output/public/_nuxt/error-500.D6rBzoDj.css +1 -0
- package/.output/public/_nuxt/pdFQkwM_.js +4 -0
- package/.output/server/chunks/_/error-500.mjs +20 -0
- package/.output/server/chunks/_/error-500.mjs.map +1 -0
- package/.output/server/chunks/nitro/nitro.mjs +5870 -0
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -0
- package/.output/server/chunks/routes/mcp.mjs +22 -0
- package/.output/server/chunks/routes/mcp.mjs.map +1 -0
- package/.output/server/chunks/routes/renderer.mjs +462 -0
- package/.output/server/chunks/routes/renderer.mjs.map +1 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
- package/.output/server/chunks/virtual/precomputed.mjs +4 -0
- package/.output/server/chunks/virtual/precomputed.mjs.map +1 -0
- package/.output/server/index.mjs +18 -0
- package/.output/server/index.mjs.map +1 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +14657 -0
- package/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js +64 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js +16 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js +32 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js +246 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/package.json +1 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +41 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +429 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +971 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js +58 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +961 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +228 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +51 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +1137 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +92 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js +239 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +2065 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +87 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/package.json +165 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/index.mjs +349 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/package.json +44 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/watcher.wasm +0 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/wrapper.js +88 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/index.mjs +12 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/shared/messenger-broker.B8W77sqB.mjs +1177 -0
- package/.output/server/node_modules/@unagents/messenger-broker/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/index.mjs +9 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CfQVmH_Z.mjs +975 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CoDKzubj.mjs +1000 -0
- package/.output/server/node_modules/@unagents/messenger-client/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/dist/index.mjs +103 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/package.json +29 -0
- package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6802 -0
- package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +729 -0
- package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1933 -0
- package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +7085 -0
- package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1917 -0
- package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +951 -0
- package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
- package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +655 -0
- package/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/.output/server/node_modules/ajv/dist/ajv.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/code.js +156 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/index.js +697 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
- package/.output/server/node_modules/ajv/dist/compile/errors.js +123 -0
- package/.output/server/node_modules/ajv/dist/compile/index.js +242 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js +28 -0
- package/.output/server/node_modules/ajv/dist/compile/ref_error.js +12 -0
- package/.output/server/node_modules/ajv/dist/compile/resolve.js +155 -0
- package/.output/server/node_modules/ajv/dist/compile/rules.js +26 -0
- package/.output/server/node_modules/ajv/dist/compile/util.js +178 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js +520 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
- package/.output/server/node_modules/ajv/dist/core.js +618 -0
- package/.output/server/node_modules/ajv/dist/refs/data.json +13 -0
- package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
- package/.output/server/node_modules/ajv/dist/runtime/equal.js +7 -0
- package/.output/server/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
- package/.output/server/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/.output/server/node_modules/ajv/dist/runtime/validation_error.js +11 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js +131 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
- package/.output/server/node_modules/ajv/package.json +126 -0
- package/.output/server/node_modules/ajv-formats/dist/formats.js +208 -0
- package/.output/server/node_modules/ajv-formats/dist/index.js +37 -0
- package/.output/server/node_modules/ajv-formats/dist/limit.js +69 -0
- package/.output/server/node_modules/ajv-formats/package.json +74 -0
- package/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/.output/server/node_modules/consola/dist/core.mjs +512 -0
- package/.output/server/node_modules/consola/dist/index.mjs +651 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/.output/server/node_modules/consola/dist/utils.mjs +54 -0
- package/.output/server/node_modules/consola/package.json +136 -0
- package/.output/server/node_modules/content-type/index.js +225 -0
- package/.output/server/node_modules/content-type/package.json +42 -0
- package/.output/server/node_modules/cookie-es/dist/index.mjs +268 -0
- package/.output/server/node_modules/cookie-es/package.json +46 -0
- package/.output/server/node_modules/crossws/dist/_chunks/_request.mjs +83 -0
- package/.output/server/node_modules/crossws/dist/_chunks/adapter.mjs +234 -0
- package/.output/server/node_modules/crossws/dist/_chunks/error.mjs +7 -0
- package/.output/server/node_modules/crossws/dist/_chunks/libs/ws.mjs +6 -0
- package/.output/server/node_modules/crossws/dist/_chunks/node.mjs +220 -0
- package/.output/server/node_modules/crossws/dist/_chunks/peer.mjs +208 -0
- package/.output/server/node_modules/crossws/dist/adapters/node.mjs +1 -0
- package/.output/server/node_modules/crossws/package.json +115 -0
- package/.output/server/node_modules/defu/dist/defu.mjs +69 -0
- package/.output/server/node_modules/defu/package.json +48 -0
- package/.output/server/node_modules/destr/dist/index.mjs +72 -0
- package/.output/server/node_modules/destr/package.json +47 -0
- package/.output/server/node_modules/devalue/index.js +17 -0
- package/.output/server/node_modules/devalue/package.json +39 -0
- package/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/.output/server/node_modules/devalue/src/operations.js +221 -0
- package/.output/server/node_modules/devalue/src/parse.js +279 -0
- package/.output/server/node_modules/devalue/src/stringify.js +433 -0
- package/.output/server/node_modules/devalue/src/uneval.js +698 -0
- package/.output/server/node_modules/devalue/src/utils.js +190 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/.output/server/node_modules/entities/package.json +120 -0
- package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/.output/server/node_modules/estree-walker/package.json +37 -0
- package/.output/server/node_modules/fast-deep-equal/index.js +46 -0
- package/.output/server/node_modules/fast-deep-equal/package.json +61 -0
- package/.output/server/node_modules/fast-uri/index.js +711 -0
- package/.output/server/node_modules/fast-uri/lib/schemes.js +272 -0
- package/.output/server/node_modules/fast-uri/lib/utils.js +799 -0
- package/.output/server/node_modules/fast-uri/package.json +68 -0
- package/.output/server/node_modules/get-port-please/dist/index.mjs +430 -0
- package/.output/server/node_modules/get-port-please/package.json +39 -0
- package/.output/server/node_modules/h3/dist/index.mjs +2498 -0
- package/.output/server/node_modules/h3/package.json +75 -0
- package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/.output/server/node_modules/hookable/package.json +54 -0
- package/.output/server/node_modules/http-shutdown/index.js +85 -0
- package/.output/server/node_modules/http-shutdown/package.json +32 -0
- package/.output/server/node_modules/iron-webcrypto/dist/index.js +298 -0
- package/.output/server/node_modules/iron-webcrypto/package.json +72 -0
- package/.output/server/node_modules/is-extglob/index.js +20 -0
- package/.output/server/node_modules/is-extglob/package.json +69 -0
- package/.output/server/node_modules/is-glob/index.js +150 -0
- package/.output/server/node_modules/is-glob/package.json +81 -0
- package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
- package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
- package/.output/server/node_modules/jiti/package.json +146 -0
- package/.output/server/node_modules/json-schema-traverse/index.js +93 -0
- package/.output/server/node_modules/json-schema-traverse/package.json +43 -0
- package/.output/server/node_modules/listhen/dist/chunks/xdg-open.mjs +1069 -0
- package/.output/server/node_modules/listhen/dist/index.mjs +19 -0
- package/.output/server/node_modules/listhen/dist/shared/listhen.tqe5I1Rl.mjs +1040 -0
- package/.output/server/node_modules/listhen/package.json +84 -0
- package/.output/server/node_modules/napi-wasm/index.mjs +1371 -0
- package/.output/server/node_modules/napi-wasm/package.json +33 -0
- package/.output/server/node_modules/node-forge/lib/aes.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
- package/.output/server/node_modules/node-forge/lib/asn1-validator.js +91 -0
- package/.output/server/node_modules/node-forge/lib/asn1.js +1522 -0
- package/.output/server/node_modules/node-forge/lib/baseN.js +186 -0
- package/.output/server/node_modules/node-forge/lib/cipher.js +230 -0
- package/.output/server/node_modules/node-forge/lib/cipherModes.js +1027 -0
- package/.output/server/node_modules/node-forge/lib/des.js +496 -0
- package/.output/server/node_modules/node-forge/lib/ed25519.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/forge.js +13 -0
- package/.output/server/node_modules/node-forge/lib/hmac.js +146 -0
- package/.output/server/node_modules/node-forge/lib/index.js +33 -0
- package/.output/server/node_modules/node-forge/lib/jsbn.js +1294 -0
- package/.output/server/node_modules/node-forge/lib/kem.js +168 -0
- package/.output/server/node_modules/node-forge/lib/log.js +319 -0
- package/.output/server/node_modules/node-forge/lib/md.all.js +13 -0
- package/.output/server/node_modules/node-forge/lib/md.js +11 -0
- package/.output/server/node_modules/node-forge/lib/md5.js +289 -0
- package/.output/server/node_modules/node-forge/lib/mgf.js +12 -0
- package/.output/server/node_modules/node-forge/lib/mgf1.js +57 -0
- package/.output/server/node_modules/node-forge/lib/oids.js +180 -0
- package/.output/server/node_modules/node-forge/lib/pbe.js +1029 -0
- package/.output/server/node_modules/node-forge/lib/pbkdf2.js +211 -0
- package/.output/server/node_modules/node-forge/lib/pem.js +413 -0
- package/.output/server/node_modules/node-forge/lib/pkcs1.js +276 -0
- package/.output/server/node_modules/node-forge/lib/pkcs12.js +1081 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7.js +1260 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7asn1.js +410 -0
- package/.output/server/node_modules/node-forge/lib/pki.js +102 -0
- package/.output/server/node_modules/node-forge/lib/prime.js +297 -0
- package/.output/server/node_modules/node-forge/lib/prng.js +419 -0
- package/.output/server/node_modules/node-forge/lib/pss.js +241 -0
- package/.output/server/node_modules/node-forge/lib/random.js +191 -0
- package/.output/server/node_modules/node-forge/lib/rc2.js +410 -0
- package/.output/server/node_modules/node-forge/lib/rsa.js +2014 -0
- package/.output/server/node_modules/node-forge/lib/sha1.js +319 -0
- package/.output/server/node_modules/node-forge/lib/sha256.js +327 -0
- package/.output/server/node_modules/node-forge/lib/sha512.js +561 -0
- package/.output/server/node_modules/node-forge/lib/ssh.js +236 -0
- package/.output/server/node_modules/node-forge/lib/tls.js +4334 -0
- package/.output/server/node_modules/node-forge/lib/util.js +2652 -0
- package/.output/server/node_modules/node-forge/lib/x509.js +3257 -0
- package/.output/server/node_modules/node-forge/package.json +123 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/package.json +63 -0
- package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
- package/.output/server/node_modules/nostics/dist/index.mjs +194 -0
- package/.output/server/node_modules/nostics/package.json +126 -0
- package/.output/server/node_modules/pathe/dist/index.mjs +19 -0
- package/.output/server/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/.output/server/node_modules/pathe/package.json +61 -0
- package/.output/server/node_modules/picomatch/index.js +17 -0
- package/.output/server/node_modules/picomatch/lib/constants.js +184 -0
- package/.output/server/node_modules/picomatch/lib/parse.js +1425 -0
- package/.output/server/node_modules/picomatch/lib/picomatch.js +361 -0
- package/.output/server/node_modules/picomatch/lib/scan.js +403 -0
- package/.output/server/node_modules/picomatch/lib/utils.js +72 -0
- package/.output/server/node_modules/picomatch/package.json +83 -0
- package/.output/server/node_modules/radix3/dist/index.mjs +262 -0
- package/.output/server/node_modules/radix3/package.json +52 -0
- package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/source-map-js/lib/quick-sort.js +141 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1236 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +446 -0
- package/.output/server/node_modules/source-map-js/lib/source-node.js +420 -0
- package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/.output/server/node_modules/source-map-js/package.json +71 -0
- package/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/.output/server/node_modules/std-env/dist/index.mjs +1 -0
- package/.output/server/node_modules/std-env/package.json +43 -0
- package/.output/server/node_modules/tinyclip/dist/index.js +143 -0
- package/.output/server/node_modules/tinyclip/package.json +48 -0
- package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/.output/server/node_modules/ufo/package.json +48 -0
- package/.output/server/node_modules/uncrypto/dist/crypto.node.mjs +16 -0
- package/.output/server/node_modules/uncrypto/package.json +60 -0
- package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
- package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
- package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
- package/.output/server/node_modules/unhead/dist/plugins.mjs +782 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C_7zwq8E.mjs +11 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CaeaMM5q.mjs +19 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D9VfQWNo.mjs +240 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DD4N5B4k.mjs +224 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DGl9jcjg.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DJuZwX9c.mjs +400 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DkxnqlHC.mjs +264 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DspMpm6y.mjs +48 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.o8j9utSy.mjs +208 -0
- package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
- package/.output/server/node_modules/unhead/dist/stream/server.mjs +446 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
- package/.output/server/node_modules/unhead/package.json +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/cloudflared.mjs +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/log.mjs +27 -0
- package/.output/server/node_modules/untun/dist/index.mjs +47 -0
- package/.output/server/node_modules/untun/package.json +44 -0
- package/.output/server/node_modules/uqr/dist/index.mjs +739 -0
- package/.output/server/node_modules/uqr/package.json +69 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/vue/index.js +7 -0
- package/.output/server/node_modules/vue/index.mjs +1 -0
- package/.output/server/node_modules/vue/package.json +112 -0
- package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +687 -0
- package/.output/server/node_modules/vue-bundle-renderer/package.json +66 -0
- package/.output/server/node_modules/zod/index.js +7 -0
- package/.output/server/node_modules/zod/package.json +147 -0
- package/.output/server/node_modules/zod/v3/ZodError.js +143 -0
- package/.output/server/node_modules/zod/v3/errors.js +9 -0
- package/.output/server/node_modules/zod/v3/external.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/.output/server/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/.output/server/node_modules/zod/v3/helpers/util.js +133 -0
- package/.output/server/node_modules/zod/v3/index.js +4 -0
- package/.output/server/node_modules/zod/v3/locales/en.js +109 -0
- package/.output/server/node_modules/zod/v3/package.json +7 -0
- package/.output/server/node_modules/zod/v3/types.js +3697 -0
- package/.output/server/node_modules/zod/v4/classic/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/classic/coerce.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/compat.js +31 -0
- package/.output/server/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/classic/errors.js +57 -0
- package/.output/server/node_modules/zod/v4/classic/external.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/from-json-schema.js +881 -0
- package/.output/server/node_modules/zod/v4/classic/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/classic/index.js +4 -0
- package/.output/server/node_modules/zod/v4/classic/iso.js +15 -0
- package/.output/server/node_modules/zod/v4/classic/package.json +7 -0
- package/.output/server/node_modules/zod/v4/classic/parse.js +16 -0
- package/.output/server/node_modules/zod/v4/classic/schemas.js +1535 -0
- package/.output/server/node_modules/zod/v4/core/api.js +1107 -0
- package/.output/server/node_modules/zod/v4/core/checks.js +516 -0
- package/.output/server/node_modules/zod/v4/core/compile.js +1866 -0
- package/.output/server/node_modules/zod/v4/core/core.js +141 -0
- package/.output/server/node_modules/zod/v4/core/doc.js +38 -0
- package/.output/server/node_modules/zod/v4/core/errors.js +267 -0
- package/.output/server/node_modules/zod/v4/core/index.js +19 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-generator.js +99 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-processors.js +843 -0
- package/.output/server/node_modules/zod/v4/core/json-schema.js +1 -0
- package/.output/server/node_modules/zod/v4/core/memoizer.js +311 -0
- package/.output/server/node_modules/zod/v4/core/package.json +7 -0
- package/.output/server/node_modules/zod/v4/core/parse.js +175 -0
- package/.output/server/node_modules/zod/v4/core/regexes.js +156 -0
- package/.output/server/node_modules/zod/v4/core/registries.js +51 -0
- package/.output/server/node_modules/zod/v4/core/schemas.js +2636 -0
- package/.output/server/node_modules/zod/v4/core/to-json-schema.js +651 -0
- package/.output/server/node_modules/zod/v4/core/util.js +873 -0
- package/.output/server/node_modules/zod/v4/core/versions.js +5 -0
- package/.output/server/node_modules/zod/v4/core/visit.js +169 -0
- package/.output/server/node_modules/zod/v4/index.js +4 -0
- package/.output/server/node_modules/zod/v4/locales/ar.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/az.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/be.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/bg.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/bn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ca.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ckb.js +133 -0
- package/.output/server/node_modules/zod/v4/locales/cs.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/da.js +120 -0
- package/.output/server/node_modules/zod/v4/locales/de.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/el.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/en.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/eo.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/es.js +136 -0
- package/.output/server/node_modules/zod/v4/locales/fa.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/fi.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/fr-CA.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/fr.js +129 -0
- package/.output/server/node_modules/zod/v4/locales/gu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/he.js +221 -0
- package/.output/server/node_modules/zod/v4/locales/hi.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/hr.js +126 -0
- package/.output/server/node_modules/zod/v4/locales/hu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/hy.js +158 -0
- package/.output/server/node_modules/zod/v4/locales/id.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/index.js +63 -0
- package/.output/server/node_modules/zod/v4/locales/is.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/it.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ja.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ka.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/kh.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/km.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/kn.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/ko.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/lt.js +207 -0
- package/.output/server/node_modules/zod/v4/locales/mk.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ms.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ne.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/nl.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/nn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/no.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ota.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/package.json +7 -0
- package/.output/server/node_modules/zod/v4/locales/pl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ps.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/.output/server/node_modules/zod/v4/locales/pt.js +142 -0
- package/.output/server/node_modules/zod/v4/locales/ro.js +122 -0
- package/.output/server/node_modules/zod/v4/locales/ru.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/sk.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/sl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/sv.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/ta.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tg.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/th.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tk.js +107 -0
- package/.output/server/node_modules/zod/v4/locales/tr.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/ua.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/uk.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ur.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/uz.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/vi.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/yo.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/zh-CN.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/zh-TW.js +112 -0
- package/.output/server/node_modules/zod/v4/mini/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/coerce.js +22 -0
- package/.output/server/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/mini/external.js +16 -0
- package/.output/server/node_modules/zod/v4/mini/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/mini/iso.js +34 -0
- package/.output/server/node_modules/zod/v4/mini/package.json +7 -0
- package/.output/server/node_modules/zod/v4/mini/parse.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/schemas.js +1002 -0
- package/.output/server/node_modules/zod/v4/package.json +7 -0
- package/.output/server/node_modules/zod/v4-mini/index.js +3 -0
- package/.output/server/node_modules/zod/v4-mini/package.json +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Options.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Refs.js +22 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +14 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +8 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/index.js +40 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/package.json +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseDef.js +62 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseTypes.js +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +17 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +49 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +5 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +16 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +11 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +10 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +33 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +72 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +61 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +352 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +32 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +80 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/selectParser.js +105 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +87 -0
- package/.output/server/node_modules/zod-to-json-schema/package.json +85 -0
- package/.output/server/package.json +64 -0
- package/README.md +226 -23
- package/bin/bantou.mjs +33 -0
- package/package.json +18 -8
- package/protocol/PROTOCOL.md +26 -0
- package/protocol/protocol.json +92 -0
- package/dist/cap.js +0 -7
- package/dist/cli.js +0 -27
- package/dist/config.js +0 -23
- package/dist/daemon.js +0 -23
- package/dist/session.js +0 -7
- package/dist/workspace.js +0 -8
|
@@ -0,0 +1,1040 @@
|
|
|
1
|
+
import { join, extname } from 'node:path';
|
|
2
|
+
import consola$1, { consola } from 'consola';
|
|
3
|
+
import { createServer as createServer$1 } from 'node:http';
|
|
4
|
+
import { createServer } from 'node:https';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { getPort } from 'get-port-please';
|
|
7
|
+
import addShutdown from 'http-shutdown';
|
|
8
|
+
import { defu } from 'defu';
|
|
9
|
+
import { colors, getColor } from 'consola/utils';
|
|
10
|
+
import { renderUnicodeCompact } from 'uqr';
|
|
11
|
+
import childProcess from 'node:child_process';
|
|
12
|
+
import fs, { statSync, readFileSync, accessSync, constants, promises, existsSync } from 'node:fs';
|
|
13
|
+
import os, { networkInterfaces } from 'node:os';
|
|
14
|
+
import { relative, join as join$1, dirname, resolve } from 'pathe';
|
|
15
|
+
import { provider } from 'std-env';
|
|
16
|
+
import forge from 'node-forge';
|
|
17
|
+
import { stat, readFile } from 'node:fs/promises';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
19
|
+
|
|
20
|
+
let isDockerCached;
|
|
21
|
+
function isDocker() {
|
|
22
|
+
if (isDockerCached === void 0) {
|
|
23
|
+
isDockerCached = _hasDockerEnvironment() || _hasDockerCGroup();
|
|
24
|
+
}
|
|
25
|
+
return isDockerCached;
|
|
26
|
+
}
|
|
27
|
+
function _hasDockerEnvironment() {
|
|
28
|
+
try {
|
|
29
|
+
statSync("/.dockerenv");
|
|
30
|
+
return true;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _hasDockerCGroup() {
|
|
36
|
+
try {
|
|
37
|
+
return readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let isWSLCached;
|
|
44
|
+
function isWsl() {
|
|
45
|
+
if (isWSLCached === void 0) {
|
|
46
|
+
isWSLCached = _isWsl();
|
|
47
|
+
}
|
|
48
|
+
return isWSLCached;
|
|
49
|
+
}
|
|
50
|
+
function _isWsl() {
|
|
51
|
+
if (process.platform !== "linux") {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
55
|
+
if (isDocker()) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isDocker() : false;
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const defaultMountPoint = "/mnt/";
|
|
67
|
+
let _wslMountpoint;
|
|
68
|
+
function getWslDrivesMountPoint() {
|
|
69
|
+
if (_wslMountpoint) {
|
|
70
|
+
return _wslMountpoint;
|
|
71
|
+
}
|
|
72
|
+
const configFilePath = "/etc/wsl.conf";
|
|
73
|
+
let isConfigFileExists = false;
|
|
74
|
+
try {
|
|
75
|
+
accessSync(configFilePath, constants.F_OK);
|
|
76
|
+
isConfigFileExists = true;
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
if (!isConfigFileExists) {
|
|
80
|
+
return defaultMountPoint;
|
|
81
|
+
}
|
|
82
|
+
const configContent = readFileSync(configFilePath, { encoding: "utf8" });
|
|
83
|
+
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
84
|
+
if (!configMountPoint || !configMountPoint.groups) {
|
|
85
|
+
return defaultMountPoint;
|
|
86
|
+
}
|
|
87
|
+
_wslMountpoint = configMountPoint.groups.mountPoint.trim();
|
|
88
|
+
_wslMountpoint = _wslMountpoint.endsWith("/") ? _wslMountpoint : `${_wslMountpoint}/`;
|
|
89
|
+
return _wslMountpoint;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function open(target, options = {}) {
|
|
93
|
+
let command;
|
|
94
|
+
const cliArguments = [];
|
|
95
|
+
const childProcessOptions = {};
|
|
96
|
+
if (process.platform === "darwin") {
|
|
97
|
+
command = "open";
|
|
98
|
+
if (options.wait) {
|
|
99
|
+
cliArguments.push("--wait-apps");
|
|
100
|
+
}
|
|
101
|
+
if (options.background) {
|
|
102
|
+
cliArguments.push("--background");
|
|
103
|
+
}
|
|
104
|
+
if (options.newInstance) {
|
|
105
|
+
cliArguments.push("--new");
|
|
106
|
+
}
|
|
107
|
+
} else if (process.platform === "win32" || isWsl() && !isDocker()) {
|
|
108
|
+
command = isWsl() ? `${getWslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
|
|
109
|
+
cliArguments.push(
|
|
110
|
+
"-NoProfile",
|
|
111
|
+
"-NonInteractive",
|
|
112
|
+
"\u2013ExecutionPolicy",
|
|
113
|
+
"Bypass",
|
|
114
|
+
"-EncodedCommand"
|
|
115
|
+
);
|
|
116
|
+
if (!isWsl()) {
|
|
117
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
118
|
+
}
|
|
119
|
+
const encodedArguments = ["Start"];
|
|
120
|
+
if (options.wait) {
|
|
121
|
+
encodedArguments.push("-Wait");
|
|
122
|
+
}
|
|
123
|
+
encodedArguments.push(target);
|
|
124
|
+
target = Buffer.from(encodedArguments.join(" "), "utf16le").toString("base64");
|
|
125
|
+
} else {
|
|
126
|
+
command = "xdg-open";
|
|
127
|
+
const useSystemXdgOpen = process.versions.electron || process.platform === "android";
|
|
128
|
+
if (!useSystemXdgOpen) {
|
|
129
|
+
command = join(os.tmpdir(), "xdg-open");
|
|
130
|
+
if (!fs.existsSync(command)) {
|
|
131
|
+
try {
|
|
132
|
+
fs.writeFileSync(
|
|
133
|
+
join(os.tmpdir(), "xdg-open"),
|
|
134
|
+
await import('../chunks/xdg-open.mjs').then((r) => r.xdgOpenScript()),
|
|
135
|
+
"utf8"
|
|
136
|
+
);
|
|
137
|
+
fs.chmodSync(
|
|
138
|
+
command,
|
|
139
|
+
493
|
|
140
|
+
/* rwx r-x r-x */
|
|
141
|
+
);
|
|
142
|
+
} catch {
|
|
143
|
+
command = "xdg-open";
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!options.wait) {
|
|
148
|
+
childProcessOptions.stdio = "ignore";
|
|
149
|
+
childProcessOptions.detached = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
cliArguments.push(target);
|
|
153
|
+
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
154
|
+
if (options.wait) {
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
subprocess.once("error", reject);
|
|
157
|
+
subprocess.once("close", (exitCode) => {
|
|
158
|
+
if (options.allowNonzeroExitCode && exitCode > 0) {
|
|
159
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
resolve(subprocess);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
subprocess.unref();
|
|
167
|
+
return subprocess;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function getNetworkInterfaces(includeIPV6) {
|
|
171
|
+
const addrs = /* @__PURE__ */ new Set();
|
|
172
|
+
for (const details of Object.values(networkInterfaces())) {
|
|
173
|
+
if (details) {
|
|
174
|
+
for (const d of details) {
|
|
175
|
+
if (!d.internal && !(d.mac === "00:00:00:00:00:00") && !d.address.startsWith("fe80::") && !d.address.startsWith("169.254.") && !(!includeIPV6 && (d.family === "IPv6" || +d.family === 6))) {
|
|
176
|
+
addrs.add(formatAddress(d));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return [...addrs].sort();
|
|
182
|
+
}
|
|
183
|
+
function formatAddress(addr) {
|
|
184
|
+
return addr.family === "IPv6" || addr.family === 6 ? `[${addr.address}]` : addr.address;
|
|
185
|
+
}
|
|
186
|
+
function formatURL(url) {
|
|
187
|
+
return colors.cyan(
|
|
188
|
+
colors.underline(decodeURI(url).replace(/:(\d+)\//g, `:${colors.bold("$1")}/`))
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
const _localHosts = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "::1"]);
|
|
192
|
+
function isLocalhost(hostname) {
|
|
193
|
+
return hostname === void 0 ? false : _localHosts.has(hostname);
|
|
194
|
+
}
|
|
195
|
+
const _anyHosts = /* @__PURE__ */ new Set(["", "0.0.0.0", "::"]);
|
|
196
|
+
function isAnyhost(hostname) {
|
|
197
|
+
return hostname === void 0 ? false : _anyHosts.has(hostname);
|
|
198
|
+
}
|
|
199
|
+
function generateURL(hostname, listhenOptions, baseURL) {
|
|
200
|
+
const proto = listhenOptions.https ? "https://" : "http://";
|
|
201
|
+
let port = listhenOptions.port || "";
|
|
202
|
+
if (port === 80 && proto === "http://" || port === 443 && proto === "https://") {
|
|
203
|
+
port = "";
|
|
204
|
+
}
|
|
205
|
+
if (hostname[0] !== "[" && hostname.includes(":")) {
|
|
206
|
+
hostname = `[${hostname}]`;
|
|
207
|
+
}
|
|
208
|
+
return proto + (hostname || "localhost") + ":" + port + (baseURL || listhenOptions.baseURL || "");
|
|
209
|
+
}
|
|
210
|
+
function getDefaultHost(preferPublic) {
|
|
211
|
+
if (isDocker() || isWsl()) {
|
|
212
|
+
return "";
|
|
213
|
+
}
|
|
214
|
+
return preferPublic ? "" : "localhost";
|
|
215
|
+
}
|
|
216
|
+
function getPublicURL(listhenOptions, baseURL) {
|
|
217
|
+
if (listhenOptions.publicURL) {
|
|
218
|
+
return listhenOptions.publicURL;
|
|
219
|
+
}
|
|
220
|
+
if (provider === "stackblitz") {
|
|
221
|
+
const stackblitzURL = detectStackblitzURL(listhenOptions._entry);
|
|
222
|
+
if (stackblitzURL) {
|
|
223
|
+
return stackblitzURL;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (listhenOptions.hostname && !isLocalhost(listhenOptions.hostname) && !isAnyhost(listhenOptions.hostname)) {
|
|
227
|
+
return generateURL(listhenOptions.hostname, listhenOptions, baseURL);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function detectStackblitzURL(entry) {
|
|
231
|
+
try {
|
|
232
|
+
const cwd = process.env.PWD || "";
|
|
233
|
+
if (cwd.startsWith("/home/projects")) {
|
|
234
|
+
const projectId = cwd.split("/")[3];
|
|
235
|
+
const relativeEntry = entry && relative(process.cwd(), entry).replace(/^\.\//, "");
|
|
236
|
+
const query = relativeEntry ? `?file=${relativeEntry}` : "";
|
|
237
|
+
return `https://stackblitz.com/edit/${projectId}${query}`;
|
|
238
|
+
}
|
|
239
|
+
if (cwd.startsWith("/home")) {
|
|
240
|
+
const githubRepo = cwd.split("/").slice(2).join("/");
|
|
241
|
+
return `https://stackblitz.com/edit/~/github.com/${githubRepo}`;
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error(error);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const HOSTNAME_RE = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
|
|
248
|
+
function validateHostname(hostname, _public) {
|
|
249
|
+
if (hostname && !HOSTNAME_RE.test(hostname)) {
|
|
250
|
+
const fallbackHost = _public ? "" : "localhost";
|
|
251
|
+
consola.warn(
|
|
252
|
+
`[listhen] Invalid hostname \`${hostname}\`. Using \`${fallbackHost}\` as fallback.`
|
|
253
|
+
);
|
|
254
|
+
return fallbackHost;
|
|
255
|
+
}
|
|
256
|
+
return hostname;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const word = '[a-fA-F\\d:]';
|
|
260
|
+
|
|
261
|
+
const boundry = options => options && options.includeBoundaries
|
|
262
|
+
? `(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))`
|
|
263
|
+
: '';
|
|
264
|
+
|
|
265
|
+
const v4 = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';
|
|
266
|
+
|
|
267
|
+
const v6segment = '[a-fA-F\\d]{1,4}';
|
|
268
|
+
|
|
269
|
+
const v6 = `
|
|
270
|
+
(?:
|
|
271
|
+
(?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
272
|
+
(?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
|
|
273
|
+
(?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
|
|
274
|
+
(?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
|
|
275
|
+
(?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
|
|
276
|
+
(?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
|
|
277
|
+
(?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
278
|
+
(?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
279
|
+
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
280
|
+
`.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();
|
|
281
|
+
|
|
282
|
+
// Pre-compile only the exact regexes because adding a global flag make regexes stateful
|
|
283
|
+
const v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`);
|
|
284
|
+
const v4exact = new RegExp(`^${v4}$`);
|
|
285
|
+
const v6exact = new RegExp(`^${v6}$`);
|
|
286
|
+
|
|
287
|
+
const ipRegex = options => options && options.exact
|
|
288
|
+
? v46Exact
|
|
289
|
+
: new RegExp(`(?:${boundry(options)}${v4}${boundry(options)})|(?:${boundry(options)}${v6}${boundry(options)})`, 'g');
|
|
290
|
+
|
|
291
|
+
ipRegex.v4 = options => options && options.exact ? v4exact : new RegExp(`${boundry(options)}${v4}${boundry(options)}`, 'g');
|
|
292
|
+
ipRegex.v6 = options => options && options.exact ? v6exact : new RegExp(`${boundry(options)}${v6}${boundry(options)}`, 'g');
|
|
293
|
+
|
|
294
|
+
async function resolveCertificate(options) {
|
|
295
|
+
let https;
|
|
296
|
+
if (typeof options === "object" && options.key && options.cert) {
|
|
297
|
+
https = await resolveCert(options);
|
|
298
|
+
if (options.passphrase) {
|
|
299
|
+
https.passphrase = options.passphrase;
|
|
300
|
+
}
|
|
301
|
+
} else if (typeof options === "object" && options.pfx) {
|
|
302
|
+
const pfx = await resolvePfx(options);
|
|
303
|
+
if (!pfx.safeContents || pfx.safeContents.length < 2 || pfx.safeContents[0].safeBags.length === 0 || pfx.safeContents[1].safeBags.length === 0) {
|
|
304
|
+
throw new Error("keystore not containing a cert AND a key");
|
|
305
|
+
}
|
|
306
|
+
const _cert = pfx.safeContents[0].safeBags[0].cert;
|
|
307
|
+
const _key = pfx.safeContents[1].safeBags[0].key;
|
|
308
|
+
https = {
|
|
309
|
+
key: forge.pki.privateKeyToPem(_key),
|
|
310
|
+
cert: forge.pki.certificateToPem(_cert)
|
|
311
|
+
};
|
|
312
|
+
} else {
|
|
313
|
+
const { cert } = await generateCertificates(options);
|
|
314
|
+
https = cert;
|
|
315
|
+
}
|
|
316
|
+
return https;
|
|
317
|
+
}
|
|
318
|
+
async function generateCertificates(options) {
|
|
319
|
+
const defaults = {
|
|
320
|
+
commonName: "localhost",
|
|
321
|
+
countryCode: "US",
|
|
322
|
+
state: "Michigan",
|
|
323
|
+
locality: "Berkley",
|
|
324
|
+
organization: "Testing Corp",
|
|
325
|
+
organizationalUnit: "IT department",
|
|
326
|
+
domains: ["localhost", "127.0.0.1", "::1"],
|
|
327
|
+
validityDays: 1,
|
|
328
|
+
bits: 2048
|
|
329
|
+
};
|
|
330
|
+
const caOptions = defu(options, defaults);
|
|
331
|
+
caOptions.passphrase = options.signingKeyPassphrase;
|
|
332
|
+
const ca = await generateCACert(caOptions);
|
|
333
|
+
const domains = Array.isArray(options.domains) ? options.domains : ["localhost", "127.0.0.1", "::1"];
|
|
334
|
+
const certOptions = defu(options, defaults);
|
|
335
|
+
const cert = await generateTLSCert({
|
|
336
|
+
...certOptions,
|
|
337
|
+
signingKeyCert: ca.cert,
|
|
338
|
+
signingKey: ca.key,
|
|
339
|
+
domains
|
|
340
|
+
});
|
|
341
|
+
return { ca, cert };
|
|
342
|
+
}
|
|
343
|
+
async function resolveCert(options) {
|
|
344
|
+
if (options && options.key && options.cert) {
|
|
345
|
+
const isInline = (s = "") => s.startsWith("--");
|
|
346
|
+
const r = (s) => isInline(s) ? s : promises.readFile(s, "utf8");
|
|
347
|
+
return {
|
|
348
|
+
key: await r(options.key),
|
|
349
|
+
cert: await r(options.cert)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
throw new Error("Certificate or Private Key not present");
|
|
353
|
+
}
|
|
354
|
+
async function resolvePfx(options) {
|
|
355
|
+
if (options && options.pfx) {
|
|
356
|
+
const pfx = await promises.readFile(options.pfx, "binary");
|
|
357
|
+
const p12Asn1 = forge.asn1.fromDer(pfx);
|
|
358
|
+
if (options.passphrase) {
|
|
359
|
+
return forge.pkcs12.pkcs12FromAsn1(p12Asn1, options.passphrase);
|
|
360
|
+
}
|
|
361
|
+
return forge.pkcs12.pkcs12FromAsn1(p12Asn1, "");
|
|
362
|
+
}
|
|
363
|
+
throw new Error("Error resolving the pfx store");
|
|
364
|
+
}
|
|
365
|
+
function createAttributes(options) {
|
|
366
|
+
return [
|
|
367
|
+
options.commonName && { name: "commonName", value: options.commonName },
|
|
368
|
+
options.countryCode && { name: "countryName", value: options.countryCode },
|
|
369
|
+
options.state && { name: "stateOrProvinceName", value: options.state },
|
|
370
|
+
options.locality && { name: "localityName", value: options.locality },
|
|
371
|
+
options.organization && {
|
|
372
|
+
name: "organizationName",
|
|
373
|
+
value: options.organization
|
|
374
|
+
},
|
|
375
|
+
options.organizationalUnit && {
|
|
376
|
+
name: "organizationalUnitName",
|
|
377
|
+
value: options.organizationalUnit
|
|
378
|
+
},
|
|
379
|
+
options.emailAddress && {
|
|
380
|
+
name: "emailAddress",
|
|
381
|
+
value: options.emailAddress
|
|
382
|
+
}
|
|
383
|
+
].filter(Boolean);
|
|
384
|
+
}
|
|
385
|
+
function createCertificateInfo(options) {
|
|
386
|
+
if (!options.domains || options.domains && options.domains.length === 0) {
|
|
387
|
+
options.domains = ["localhost.local"];
|
|
388
|
+
}
|
|
389
|
+
options.commonName = options.commonName || options.domains[0];
|
|
390
|
+
const attributes = createAttributes(options);
|
|
391
|
+
const extensions = [
|
|
392
|
+
{ name: "basicConstraints", cA: false, critical: true },
|
|
393
|
+
{
|
|
394
|
+
name: "keyUsage",
|
|
395
|
+
digitalSignature: true,
|
|
396
|
+
keyEncipherment: true,
|
|
397
|
+
critical: true
|
|
398
|
+
},
|
|
399
|
+
{ name: "extKeyUsage", serverAuth: true, clientAuth: true },
|
|
400
|
+
{
|
|
401
|
+
name: "subjectAltName",
|
|
402
|
+
altNames: options.domains.map((domain) => {
|
|
403
|
+
const types = { domain: 2, ip: 7 };
|
|
404
|
+
const isIp = ipRegex({ exact: true }).test(domain);
|
|
405
|
+
if (isIp) {
|
|
406
|
+
return { type: types.ip, ip: domain };
|
|
407
|
+
}
|
|
408
|
+
return { type: types.domain, value: domain };
|
|
409
|
+
})
|
|
410
|
+
}
|
|
411
|
+
];
|
|
412
|
+
return { attributes, extensions };
|
|
413
|
+
}
|
|
414
|
+
function createCaInfo(options) {
|
|
415
|
+
const attributes = createAttributes(options);
|
|
416
|
+
const extensions = [
|
|
417
|
+
{ name: "basicConstraints", cA: true, critical: true },
|
|
418
|
+
{ name: "keyUsage", keyCertSign: true, critical: true }
|
|
419
|
+
];
|
|
420
|
+
return { attributes, extensions };
|
|
421
|
+
}
|
|
422
|
+
async function generateTLSCert(options) {
|
|
423
|
+
const { attributes, extensions } = createCertificateInfo(options);
|
|
424
|
+
const ca = forge.pki.certificateFromPem(options.signingKeyCert);
|
|
425
|
+
return await generateCert({
|
|
426
|
+
bits: options.bits,
|
|
427
|
+
subject: attributes,
|
|
428
|
+
issuer: ca.subject.attributes,
|
|
429
|
+
extensions,
|
|
430
|
+
validityDays: options.validityDays || 1,
|
|
431
|
+
signingKey: options.signingKey,
|
|
432
|
+
signingKeyPassphrase: options.signingKeyPassphrase,
|
|
433
|
+
passphrase: options.passphrase
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
async function generateCACert(options = {}) {
|
|
437
|
+
const { attributes, extensions } = createCaInfo(options);
|
|
438
|
+
return await generateCert({
|
|
439
|
+
...options,
|
|
440
|
+
bits: options.bits || 2048,
|
|
441
|
+
subject: attributes,
|
|
442
|
+
issuer: attributes,
|
|
443
|
+
extensions,
|
|
444
|
+
validityDays: options.validityDays || 1
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function signCertificate(options, cert) {
|
|
448
|
+
if (options.signingKey) {
|
|
449
|
+
if (isValidPassphrase(options.signingKeyPassphrase)) {
|
|
450
|
+
const encryptedPrivateKey = forge.pki.encryptedPrivateKeyFromPem(options.signingKey);
|
|
451
|
+
const decryptedPrivateKey = forge.pki.decryptPrivateKeyInfo(
|
|
452
|
+
encryptedPrivateKey,
|
|
453
|
+
options.signingKeyPassphrase
|
|
454
|
+
);
|
|
455
|
+
cert.sign(forge.pki.privateKeyFromAsn1(decryptedPrivateKey), forge.md.sha256.create());
|
|
456
|
+
} else {
|
|
457
|
+
cert.sign(forge.pki.privateKeyFromPem(options.signingKey), forge.md.sha256.create());
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
cert.sign(cert.privateKey, forge.md.sha256.create());
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function createCertificateFromKeyPair(keyPair, options) {
|
|
464
|
+
const serial = Math.floor(Math.random() * 95e3 + 5e4).toString();
|
|
465
|
+
const cert = forge.pki.createCertificate();
|
|
466
|
+
cert.publicKey = keyPair.publicKey;
|
|
467
|
+
cert.privateKey = keyPair.privateKey;
|
|
468
|
+
cert.serialNumber = Buffer.from(serial).toString("hex");
|
|
469
|
+
cert.validity.notBefore = /* @__PURE__ */ new Date();
|
|
470
|
+
cert.validity.notAfter = /* @__PURE__ */ new Date();
|
|
471
|
+
cert.validity.notAfter.setDate(cert.validity.notAfter.getDate() + options.validityDays);
|
|
472
|
+
cert.setSubject(options.subject);
|
|
473
|
+
cert.setIssuer(options.issuer);
|
|
474
|
+
cert.setExtensions(options.extensions);
|
|
475
|
+
return cert;
|
|
476
|
+
}
|
|
477
|
+
async function generateKeyPair(bits = 2048) {
|
|
478
|
+
const _generateKeyPair = promisify(forge.pki.rsa.generateKeyPair.bind(forge.pki.rsa));
|
|
479
|
+
return await _generateKeyPair({
|
|
480
|
+
bits,
|
|
481
|
+
workers: os.availableParallelism ? os.availableParallelism() : os.cpus().length
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function isValidPassphrase(passphrase) {
|
|
485
|
+
return typeof passphrase === "string" && passphrase.length < 2e3;
|
|
486
|
+
}
|
|
487
|
+
async function generateCert(options) {
|
|
488
|
+
const keyPair = await generateKeyPair(options.bits);
|
|
489
|
+
const cert = createCertificateFromKeyPair(keyPair, options);
|
|
490
|
+
if (isValidPassphrase(options.passphrase)) {
|
|
491
|
+
const asn1PrivateKey = forge.pki.privateKeyToAsn1(keyPair.privateKey);
|
|
492
|
+
const privateKeyInfo = forge.pki.wrapRsaPrivateKey(asn1PrivateKey);
|
|
493
|
+
const encryptedPrivateKeyInfo = forge.pki.encryptPrivateKeyInfo(
|
|
494
|
+
privateKeyInfo,
|
|
495
|
+
options.passphrase,
|
|
496
|
+
{
|
|
497
|
+
algorithm: "aes256"
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
signCertificate(
|
|
501
|
+
{
|
|
502
|
+
signingKey: options.signingKey,
|
|
503
|
+
signingKeyPassphrase: options.signingKeyPassphrase
|
|
504
|
+
},
|
|
505
|
+
cert
|
|
506
|
+
);
|
|
507
|
+
return {
|
|
508
|
+
key: forge.pki.encryptedPrivateKeyToPem(encryptedPrivateKeyInfo),
|
|
509
|
+
cert: forge.pki.certificateToPem(cert),
|
|
510
|
+
passphrase: options.passphrase
|
|
511
|
+
};
|
|
512
|
+
} else {
|
|
513
|
+
signCertificate(
|
|
514
|
+
{
|
|
515
|
+
signingKey: options.signingKey,
|
|
516
|
+
signingKeyPassphrase: options.signingKeyPassphrase
|
|
517
|
+
},
|
|
518
|
+
cert
|
|
519
|
+
);
|
|
520
|
+
return {
|
|
521
|
+
key: forge.pki.privateKeyToPem(keyPair.privateKey),
|
|
522
|
+
cert: forge.pki.certificateToPem(cert)
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
async function listen(handle, _options = {}) {
|
|
528
|
+
const _isProd = _options.isProd ?? process.env.NODE_ENV === "production";
|
|
529
|
+
const _isTest = _options.isTest ?? process.env.NODE_ENV === "test";
|
|
530
|
+
const _hostname = _options.hostname ?? process.env.HOST;
|
|
531
|
+
const _public = _options.public ?? (isLocalhost(_hostname) ? false : void 0) ?? (isAnyhost(_hostname) ? true : void 0) ?? (process.argv.includes("--host") ? true : void 0) ?? _isProd;
|
|
532
|
+
const listhenOptions = defu(_options, {
|
|
533
|
+
name: "",
|
|
534
|
+
https: false,
|
|
535
|
+
port: process.env.PORT || 3e3,
|
|
536
|
+
hostname: _hostname ?? getDefaultHost(_public),
|
|
537
|
+
showURL: true,
|
|
538
|
+
baseURL: "/",
|
|
539
|
+
open: false,
|
|
540
|
+
clipboard: false,
|
|
541
|
+
isTest: _isTest,
|
|
542
|
+
isProd: _isProd,
|
|
543
|
+
public: _public,
|
|
544
|
+
autoClose: true
|
|
545
|
+
});
|
|
546
|
+
listhenOptions.hostname = validateHostname(listhenOptions.hostname, listhenOptions.public);
|
|
547
|
+
const _localhost = isLocalhost(listhenOptions.hostname);
|
|
548
|
+
const _anyhost = isAnyhost(listhenOptions.hostname);
|
|
549
|
+
if (listhenOptions.public && _localhost) {
|
|
550
|
+
consola$1.warn(
|
|
551
|
+
`[listhen] Trying to listhen on private host ${JSON.stringify(
|
|
552
|
+
listhenOptions.hostname
|
|
553
|
+
)} with public option enabled.`
|
|
554
|
+
);
|
|
555
|
+
listhenOptions.public = false;
|
|
556
|
+
} else if (!listhenOptions.public && _anyhost && !(isWsl() || isDocker())) {
|
|
557
|
+
consola$1.warn(
|
|
558
|
+
`[listhen] Trying to listhen on public host ${JSON.stringify(
|
|
559
|
+
listhenOptions.hostname
|
|
560
|
+
)} with public option disabled. Using "localhost".`
|
|
561
|
+
);
|
|
562
|
+
listhenOptions.public = false;
|
|
563
|
+
listhenOptions.hostname = "localhost";
|
|
564
|
+
}
|
|
565
|
+
if (listhenOptions.isTest) {
|
|
566
|
+
listhenOptions.showURL = false;
|
|
567
|
+
}
|
|
568
|
+
if (listhenOptions.isProd || listhenOptions.isTest) {
|
|
569
|
+
listhenOptions.open = false;
|
|
570
|
+
listhenOptions.clipboard = false;
|
|
571
|
+
}
|
|
572
|
+
const port = listhenOptions.port = await getPort({
|
|
573
|
+
port: Number(listhenOptions.port),
|
|
574
|
+
verbose: !listhenOptions.isTest,
|
|
575
|
+
host: listhenOptions.hostname,
|
|
576
|
+
...listhenOptions.isProd ? { random: false } : { alternativePortRange: [3e3, 3100] },
|
|
577
|
+
public: listhenOptions.public,
|
|
578
|
+
...typeof listhenOptions.port === "object" && listhenOptions.port
|
|
579
|
+
});
|
|
580
|
+
let server;
|
|
581
|
+
let https = false;
|
|
582
|
+
const httpsOptions = listhenOptions.https;
|
|
583
|
+
let _addr;
|
|
584
|
+
if (httpsOptions) {
|
|
585
|
+
https = await resolveCertificate(httpsOptions);
|
|
586
|
+
server = createServer(https, handle);
|
|
587
|
+
addShutdown(server);
|
|
588
|
+
await promisify(server.listen.bind(server))(port, listhenOptions.hostname);
|
|
589
|
+
_addr = server.address();
|
|
590
|
+
listhenOptions.port = _addr.port;
|
|
591
|
+
} else {
|
|
592
|
+
server = createServer$1(handle);
|
|
593
|
+
addShutdown(server);
|
|
594
|
+
await promisify(server.listen.bind(server))(port, listhenOptions.hostname);
|
|
595
|
+
_addr = server.address();
|
|
596
|
+
listhenOptions.port = _addr.port;
|
|
597
|
+
}
|
|
598
|
+
if (listhenOptions.ws) {
|
|
599
|
+
if (typeof listhenOptions.ws === "function") {
|
|
600
|
+
server.on("upgrade", listhenOptions.ws);
|
|
601
|
+
} else {
|
|
602
|
+
consola$1.warn(
|
|
603
|
+
"[listhen] Using experimental websocket API. Learn more: `https://crossws.unjs.io`"
|
|
604
|
+
);
|
|
605
|
+
const nodeWSAdapter = await import('crossws/adapters/node').then((r) => r.default || r);
|
|
606
|
+
const { handleUpgrade } = nodeWSAdapter({
|
|
607
|
+
...listhenOptions.ws
|
|
608
|
+
});
|
|
609
|
+
server.on("upgrade", handleUpgrade);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const getURL = (host = listhenOptions.hostname, baseURL) => generateURL(host, listhenOptions, baseURL);
|
|
613
|
+
let tunnel;
|
|
614
|
+
if (listhenOptions.tunnel) {
|
|
615
|
+
const { startTunnel } = await import('untun');
|
|
616
|
+
tunnel = await startTunnel({
|
|
617
|
+
url: getURL()
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
let _closed = false;
|
|
621
|
+
const close = async () => {
|
|
622
|
+
if (_closed) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
_closed = true;
|
|
626
|
+
await promisify(server.shutdown)().catch(() => {
|
|
627
|
+
});
|
|
628
|
+
await tunnel?.close().catch(() => {
|
|
629
|
+
});
|
|
630
|
+
};
|
|
631
|
+
if (listhenOptions.clipboard) {
|
|
632
|
+
try {
|
|
633
|
+
const { writeText } = await import('tinyclip');
|
|
634
|
+
await writeText(getURL());
|
|
635
|
+
} catch {
|
|
636
|
+
listhenOptions.clipboard = false;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
const getURLs = async (getURLOptions = {}) => {
|
|
640
|
+
const urls = [];
|
|
641
|
+
const _addURL = (type, url, title) => {
|
|
642
|
+
if (!urls.some((u) => u.url === url)) {
|
|
643
|
+
urls.push({ url, type, title });
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
const publicURL = getURLOptions.publicURL || getPublicURL(listhenOptions, getURLOptions.baseURL);
|
|
647
|
+
if (publicURL) {
|
|
648
|
+
_addURL("network", publicURL);
|
|
649
|
+
}
|
|
650
|
+
if (_localhost || _anyhost) {
|
|
651
|
+
_addURL("local", getURL(listhenOptions.hostname, getURLOptions.baseURL));
|
|
652
|
+
}
|
|
653
|
+
if (tunnel) {
|
|
654
|
+
_addURL("tunnel", await tunnel.getURL());
|
|
655
|
+
}
|
|
656
|
+
const extraURLs = getURLOptions.extraURLs ?? listhenOptions.extraURLs ?? [{ title: "Portless", env: "PORTLESS_URL" }];
|
|
657
|
+
for (const extraURL of extraURLs) {
|
|
658
|
+
const url = extraURL.url || (extraURL.env ? process.env[extraURL.env] : void 0);
|
|
659
|
+
if (url) {
|
|
660
|
+
_addURL("extra", url, extraURL.title);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
if (listhenOptions.public) {
|
|
664
|
+
const _ipv6Host = listhenOptions.hostname.includes(":");
|
|
665
|
+
for (const addr of getNetworkInterfaces(_ipv6Host)) {
|
|
666
|
+
if (addr === publicURL) {
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
_addURL("network", getURL(addr, getURLOptions.baseURL));
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
return urls;
|
|
673
|
+
};
|
|
674
|
+
const showURL = async (showURLOptions = {}) => {
|
|
675
|
+
const lines = [];
|
|
676
|
+
const nameSuffix = showURLOptions.name || listhenOptions.name ? ` (${showURLOptions.name || listhenOptions.name})` : "";
|
|
677
|
+
const urls = await getURLs(showURLOptions);
|
|
678
|
+
const firstLocalUrl = urls.find((u) => u.type === "local");
|
|
679
|
+
const firstPublicUrl = urls.find((u) => u.type !== "local");
|
|
680
|
+
const showQR = (showURLOptions.qr ?? listhenOptions.qr) !== false;
|
|
681
|
+
if (firstPublicUrl && showQR) {
|
|
682
|
+
const space = " ".repeat(14);
|
|
683
|
+
lines.push(
|
|
684
|
+
" ",
|
|
685
|
+
...renderUnicodeCompact(firstPublicUrl.url).split("\n").map((line) => space + line),
|
|
686
|
+
" "
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
const typeMap = {
|
|
690
|
+
local: ["Local", "green"],
|
|
691
|
+
tunnel: ["Tunnel", "yellow"],
|
|
692
|
+
network: ["Network", "magenta"]
|
|
693
|
+
};
|
|
694
|
+
const labels = urls.map(
|
|
695
|
+
(url) => url.type === "extra" ? [url.title || "URL", "blue"] : typeMap[url.type]
|
|
696
|
+
);
|
|
697
|
+
const labelWidth = Math.max(7, ...labels.map(([name]) => name.length)) + 1;
|
|
698
|
+
for (const [i, url] of urls.entries()) {
|
|
699
|
+
const type = labels[i];
|
|
700
|
+
const label = getColor(type[1])(
|
|
701
|
+
` \u279C ${(type[0] + ":").padEnd(labelWidth, " ")}${nameSuffix} `
|
|
702
|
+
);
|
|
703
|
+
let suffix = "";
|
|
704
|
+
if (url === firstLocalUrl && listhenOptions.clipboard) {
|
|
705
|
+
suffix += colors.gray(" [copied to clipboard]");
|
|
706
|
+
}
|
|
707
|
+
if (url === firstPublicUrl && showQR) {
|
|
708
|
+
suffix += colors.gray(" [QR code]");
|
|
709
|
+
}
|
|
710
|
+
lines.push(`${label} ${formatURL(url.url)}${suffix}`);
|
|
711
|
+
}
|
|
712
|
+
if (!firstPublicUrl) {
|
|
713
|
+
lines.push(colors.gray(` \u279C Network: use ${colors.white("--host")} to expose`));
|
|
714
|
+
}
|
|
715
|
+
console.log("\n" + lines.join("\n") + "\n");
|
|
716
|
+
};
|
|
717
|
+
if (listhenOptions.showURL) {
|
|
718
|
+
showURL();
|
|
719
|
+
}
|
|
720
|
+
const _open = async () => {
|
|
721
|
+
await open(getURL()).catch(() => {
|
|
722
|
+
});
|
|
723
|
+
};
|
|
724
|
+
if (listhenOptions.open) {
|
|
725
|
+
await _open();
|
|
726
|
+
}
|
|
727
|
+
if (listhenOptions.autoClose) {
|
|
728
|
+
process.setMaxListeners(0);
|
|
729
|
+
process.once("exit", () => close());
|
|
730
|
+
process.once("SIGINT", () => process.exit(0));
|
|
731
|
+
process.once("SIGTERM", () => process.exit(0));
|
|
732
|
+
process.once("SIGHUP", () => process.exit(0));
|
|
733
|
+
}
|
|
734
|
+
return {
|
|
735
|
+
url: getURL(),
|
|
736
|
+
https,
|
|
737
|
+
server,
|
|
738
|
+
address: _addr,
|
|
739
|
+
open: _open,
|
|
740
|
+
showURL,
|
|
741
|
+
getURLs,
|
|
742
|
+
close
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
async function createResolver() {
|
|
747
|
+
const { createJiti } = await import('jiti');
|
|
748
|
+
const jiti = createJiti(join$1(process.cwd(), "_"), {
|
|
749
|
+
cache: true,
|
|
750
|
+
requireCache: false,
|
|
751
|
+
interopDefault: true
|
|
752
|
+
});
|
|
753
|
+
return {
|
|
754
|
+
relative: (path) => relative(process.cwd(), path),
|
|
755
|
+
formatRelative: (path) => `\`./${relative(process.cwd(), path)}\``,
|
|
756
|
+
import: jiti.import,
|
|
757
|
+
resolve: (id) => jiti.esmResolve(id),
|
|
758
|
+
tryResolve: (id) => jiti.esmResolve(id, { try: true }),
|
|
759
|
+
/**
|
|
760
|
+
* Resolve `id` from the first of `dirs` that can see it, falling back to
|
|
761
|
+
* listhen's own dependencies. Returns a `file://` URL.
|
|
762
|
+
*
|
|
763
|
+
* A jiti instance is created per candidate so that a miss returns
|
|
764
|
+
* `undefined` instead of falling back to this instance's root (which would
|
|
765
|
+
* resolve via CJS and pick the wrong build).
|
|
766
|
+
*/
|
|
767
|
+
resolveFrom: (id, dirs) => {
|
|
768
|
+
for (const dir of [...dirs, dirname(fileURLToPath(import.meta.url))]) {
|
|
769
|
+
const resolved = createJiti(join$1(dir, "_")).esmResolve(id, {
|
|
770
|
+
try: true
|
|
771
|
+
});
|
|
772
|
+
if (resolved) {
|
|
773
|
+
return resolved;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
throw new Error(`Cannot resolve \`${id}\` from ${dirs.join(", ")}`);
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
async function createDevServer(entry, options) {
|
|
782
|
+
const logger = options.logger || consola.withTag("listhen");
|
|
783
|
+
const resolver = await createResolver();
|
|
784
|
+
const h3Entry = resolver.resolveFrom("h3", [options.cwd, process.cwd()].filter(Boolean));
|
|
785
|
+
const {
|
|
786
|
+
createApp,
|
|
787
|
+
fromNodeMiddleware,
|
|
788
|
+
serveStatic,
|
|
789
|
+
eventHandler,
|
|
790
|
+
dynamicEventHandler,
|
|
791
|
+
toNodeListener
|
|
792
|
+
} = await import(h3Entry);
|
|
793
|
+
const resolveEntry = () => {
|
|
794
|
+
for (const suffix of ["", "/server/src", "/server", "/src"]) {
|
|
795
|
+
const resolved = resolver.tryResolve(entry + suffix);
|
|
796
|
+
if (resolved) {
|
|
797
|
+
return fileURLToPath(resolved);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
let cwd = options.cwd || "";
|
|
802
|
+
if (!cwd) {
|
|
803
|
+
const resolvedEntry = resolveEntry() || resolve(process.cwd(), entry);
|
|
804
|
+
cwd = statSync(resolvedEntry, { throwIfNoEntry: false })?.isDirectory() ? resolvedEntry : dirname(resolvedEntry);
|
|
805
|
+
}
|
|
806
|
+
const app = createApp();
|
|
807
|
+
const dynamicWS = /* @__PURE__ */ Object.create(null);
|
|
808
|
+
let _ws = options.ws;
|
|
809
|
+
if (_ws && typeof _ws !== "function") {
|
|
810
|
+
_ws = {
|
|
811
|
+
...options.ws,
|
|
812
|
+
async resolve(info) {
|
|
813
|
+
return {
|
|
814
|
+
...await options.ws?.resolve?.(info),
|
|
815
|
+
...dynamicWS.hooks,
|
|
816
|
+
...await dynamicWS.resolve?.(info)
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
const staticDirs = (options.staticDirs || ["public"]).filter(Boolean).map((d) => resolve(cwd, d)).filter((d) => existsSync(d) && statSync(d).isDirectory());
|
|
822
|
+
for (const dir of staticDirs) {
|
|
823
|
+
app.use(
|
|
824
|
+
eventHandler(async (event) => {
|
|
825
|
+
await serveStatic(event, {
|
|
826
|
+
fallthrough: true,
|
|
827
|
+
getContents: (id) => readFile(join$1(dir, id)),
|
|
828
|
+
getMeta: async (id) => {
|
|
829
|
+
const stats = await stat(join$1(dir, id)).catch(() => {
|
|
830
|
+
});
|
|
831
|
+
if (!stats || !stats.isFile()) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
return {
|
|
835
|
+
size: stats.size,
|
|
836
|
+
mtime: stats.mtimeMs
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
})
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
let error;
|
|
844
|
+
app.use(
|
|
845
|
+
eventHandler(() => {
|
|
846
|
+
if (error) {
|
|
847
|
+
return errorTemplate(String(error), error.stack);
|
|
848
|
+
}
|
|
849
|
+
})
|
|
850
|
+
);
|
|
851
|
+
const dynamicHandler = dynamicEventHandler(() => {
|
|
852
|
+
return `<!DOCTYPE html><html lang="en-US"><meta http-equiv="refresh" content="1"></head><body><p>Server is loading...</p>`;
|
|
853
|
+
});
|
|
854
|
+
app.use(dynamicHandler);
|
|
855
|
+
let loadTime = 0;
|
|
856
|
+
const loadHandle = async (initial) => {
|
|
857
|
+
if (initial) {
|
|
858
|
+
for (const dir of staticDirs) {
|
|
859
|
+
logger.log(`\u{1F4C1} Serving static files from ${resolver.formatRelative(dir)}`);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
const start = Date.now();
|
|
863
|
+
try {
|
|
864
|
+
const _entry = resolveEntry();
|
|
865
|
+
if (!_entry) {
|
|
866
|
+
const message = `Cannot find a server entry in ${entry}`;
|
|
867
|
+
logger.warn(message);
|
|
868
|
+
error = new Error(message);
|
|
869
|
+
error.stack = "";
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (initial) {
|
|
873
|
+
logger.log(`\u{1F680} Loading server entry ${resolver.formatRelative(_entry)}`);
|
|
874
|
+
}
|
|
875
|
+
const _loadedEntry = await resolver.import(_entry);
|
|
876
|
+
let _handler = _loadedEntry.handler || _loadedEntry.handle || _loadedEntry.app || _loadedEntry.default || _loadedEntry;
|
|
877
|
+
if (options.ws) {
|
|
878
|
+
Object.assign(
|
|
879
|
+
dynamicWS,
|
|
880
|
+
_loadedEntry.webSocket || _loadedEntry.websocket || _handler.webSocket || _handler.websocket || {}
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
if (_handler.handler) {
|
|
884
|
+
_handler = _handler.handler;
|
|
885
|
+
}
|
|
886
|
+
if (typeof _handler !== "function") {
|
|
887
|
+
throw new TypeError(
|
|
888
|
+
"Make sure your server entrypoint exports a compatible `handler`, `handle`, `app` or `default` function export."
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
dynamicHandler.set(fromNodeMiddleware(_handler));
|
|
892
|
+
error = void 0;
|
|
893
|
+
} catch (_error) {
|
|
894
|
+
error = normalizeErrorStack(_error);
|
|
895
|
+
}
|
|
896
|
+
loadTime = Date.now() - start;
|
|
897
|
+
if (error) {
|
|
898
|
+
logger.error(error);
|
|
899
|
+
} else {
|
|
900
|
+
logger.log(`\u2705 Server ${initial ? "initialized" : "reloaded"} in ${loadTime}ms`);
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
return {
|
|
904
|
+
cwd,
|
|
905
|
+
resolver,
|
|
906
|
+
nodeListener: toNodeListener(app),
|
|
907
|
+
reload: (_initial) => loadHandle(_initial),
|
|
908
|
+
_ws,
|
|
909
|
+
_entry: resolveEntry()
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
const InternalStackRe = /jiti|node:internal|citty|listhen|listenAndWatch/;
|
|
913
|
+
function normalizeErrorStack(error) {
|
|
914
|
+
if (process.env.DEBUG) {
|
|
915
|
+
return error;
|
|
916
|
+
}
|
|
917
|
+
try {
|
|
918
|
+
const cwd = process.cwd();
|
|
919
|
+
error.stack = error.stack.split("\n").slice(1).map((l) => l.replace(cwd, ".")).filter((l) => !InternalStackRe.test(l)).join("\n");
|
|
920
|
+
} catch {
|
|
921
|
+
}
|
|
922
|
+
return error;
|
|
923
|
+
}
|
|
924
|
+
function errorTemplate(message, stack = "") {
|
|
925
|
+
return `<!DOCTYPE html>
|
|
926
|
+
<html>
|
|
927
|
+
<head>
|
|
928
|
+
<title>Server Error</title>
|
|
929
|
+
<meta charset="utf-8">
|
|
930
|
+
<meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name=viewport>
|
|
931
|
+
<style>
|
|
932
|
+
.error-page {
|
|
933
|
+
padding: 1rem;
|
|
934
|
+
background: #222;
|
|
935
|
+
color: #fff;
|
|
936
|
+
text-align: center;
|
|
937
|
+
display: flex;
|
|
938
|
+
justify-content: center;
|
|
939
|
+
align-items: center;
|
|
940
|
+
flex-direction: column;
|
|
941
|
+
font-family: sans-serif;
|
|
942
|
+
font-weight: 100 !important;
|
|
943
|
+
-ms-text-size-adjust: 100%;
|
|
944
|
+
-webkit-text-size-adjust: 100%;
|
|
945
|
+
-webkit-font-smoothing: antialiased;
|
|
946
|
+
position: absolute;
|
|
947
|
+
top: 0;
|
|
948
|
+
left: 0;
|
|
949
|
+
right: 0;
|
|
950
|
+
bottom: 0;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
.error-page .error {
|
|
954
|
+
max-width: 450px;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
.error-page .title {
|
|
958
|
+
font-size: 1rem;
|
|
959
|
+
margin-top: 15px;
|
|
960
|
+
color: #fff;
|
|
961
|
+
margin-bottom: 8px;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
.error-page .description {
|
|
965
|
+
color: #ccc;
|
|
966
|
+
line-height: 1.2;
|
|
967
|
+
margin-bottom: 10px;
|
|
968
|
+
text-align: left;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
.error-page a {
|
|
972
|
+
color: #ccc !important;
|
|
973
|
+
text-decoration: none;
|
|
974
|
+
}
|
|
975
|
+
</style>
|
|
976
|
+
</head>
|
|
977
|
+
<body>
|
|
978
|
+
<div class="error-page">
|
|
979
|
+
<div class="error">
|
|
980
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="90" height="90" fill="#DBE1EC" viewBox="0 0 48 48"><path d="M22 30h4v4h-4zm0-16h4v12h-4zm1.99-10C12.94 4 4 12.95 4 24s8.94 20 19.99 20S44 35.05 44 24 35.04 4 23.99 4zM24 40c-8.84 0-16-7.16-16-16S15.16 8 24 8s16 7.16 16 16-7.16 16-16 16z"/></svg>
|
|
981
|
+
<div class="title">Server Error</div>
|
|
982
|
+
<div class="description">${message}<pre>${stack}</pre></div>
|
|
983
|
+
</div>
|
|
984
|
+
</div>
|
|
985
|
+
</body>
|
|
986
|
+
</html>`;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
async function listenAndWatch(entry, options) {
|
|
990
|
+
const logger = options.logger || consola.withTag("listhen");
|
|
991
|
+
let watcher;
|
|
992
|
+
const devServer = await createDevServer(entry, {
|
|
993
|
+
...options,
|
|
994
|
+
logger
|
|
995
|
+
});
|
|
996
|
+
const listener = await listen(devServer.nodeListener, {
|
|
997
|
+
...options,
|
|
998
|
+
_entry: devServer._entry,
|
|
999
|
+
ws: options.ws ? devServer._ws : void 0
|
|
1000
|
+
});
|
|
1001
|
+
await devServer.reload(true);
|
|
1002
|
+
const _close = listener.close;
|
|
1003
|
+
listener.close = async () => {
|
|
1004
|
+
if (watcher) {
|
|
1005
|
+
await watcher.unsubscribe().catch((error) => {
|
|
1006
|
+
logger.error(error);
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
await _close();
|
|
1010
|
+
};
|
|
1011
|
+
try {
|
|
1012
|
+
const subscribe = await import('@parcel/watcher').then((r) => r.subscribe).catch(() => import('@parcel/watcher-wasm').then((r) => r.subscribe));
|
|
1013
|
+
const jsExts = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]);
|
|
1014
|
+
watcher = await subscribe(
|
|
1015
|
+
devServer.cwd,
|
|
1016
|
+
(_error, events) => {
|
|
1017
|
+
const filteredEvents = events.filter((e) => jsExts.has(extname(e.path)));
|
|
1018
|
+
if (filteredEvents.length === 0) {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
const eventsString = filteredEvents.map((e) => `${devServer.resolver.formatRelative(e.path)} ${e.type}d`).join(", ");
|
|
1022
|
+
logger.log(`\u{1F504} Reloading server (${eventsString})`);
|
|
1023
|
+
devServer.reload();
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
ignore: options.ignore || ["**/.git/**", "**/node_modules/**", "**/dist/**"]
|
|
1027
|
+
}
|
|
1028
|
+
);
|
|
1029
|
+
logger.log(`\u{1F440} Watching ${devServer.resolver.formatRelative(devServer.cwd)} for changes`);
|
|
1030
|
+
} catch (error) {
|
|
1031
|
+
logger.warn(
|
|
1032
|
+
"Cannot start the watcher!\n",
|
|
1033
|
+
error,
|
|
1034
|
+
"\n\n\u2714\uFE0F Your dev server is still running, but it won't reload automatically after changes. You need to restart it manually."
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
return listener;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
export { listenAndWatch as a, createDevServer as c, listen as l };
|