@kubb/agent 5.0.0-alpha.34 → 5.0.0-alpha.36
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 +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +1790 -20812
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +16 -14
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +16 -14
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
- package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
- package/.output/server/node_modules/@clack/core/package.json +60 -0
- package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
- package/.output/server/node_modules/@clack/prompts/package.json +65 -0
- package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
- package/.output/server/node_modules/@kubb/ast/package.json +70 -0
- package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
- package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
- package/.output/server/node_modules/@kubb/core/package.json +109 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
- package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
- package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
- package/.output/server/node_modules/@kubb/oas/package.json +94 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
- package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
- package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
- package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
- package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
- package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
- package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
- package/.output/server/node_modules/@redocly/config/lib/root-config-schema.js +11 -1
- package/.output/server/node_modules/@redocly/config/package.json +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-document.js +25 -10
- package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-visitor.js +32 -29
- package/.output/server/node_modules/@redocly/openapi-core/lib/config/config.js +5 -0
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/index.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/remove-unused-components.js +47 -38
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/index.js +1 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/remove-unused-components.js +45 -41
- package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-http-verbs-in-paths.js +3 -1
- package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-required-schema-properties-undefined.js +41 -55
- package/.output/server/node_modules/@redocly/openapi-core/lib/walk.js +28 -16
- package/.output/server/node_modules/@redocly/openapi-core/package.json +2 -2
- package/.output/server/node_modules/buffer-from/index.js +72 -0
- package/.output/server/node_modules/buffer-from/package.json +19 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
- package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
- package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
- package/.output/server/node_modules/fast-string-width/package.json +34 -0
- package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
- package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
- package/.output/server/node_modules/p-limit/index.js +127 -0
- package/.output/server/node_modules/p-limit/package.json +58 -0
- package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
- package/.output/server/node_modules/react-devtools-core/package.json +38 -0
- package/.output/server/node_modules/sisteransi/package.json +34 -0
- package/.output/server/node_modules/sisteransi/src/index.js +58 -0
- package/.output/server/node_modules/source-map-support/package.json +31 -0
- package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
- package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
- package/.output/server/node_modules/typescript/package.json +120 -0
- package/.output/server/node_modules/yocto-queue/index.js +90 -0
- package/.output/server/node_modules/yocto-queue/package.json +48 -0
- package/.output/server/package.json +35 -4
- package/package.json +20 -20
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { tokenChars } = require('./validation');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.
|
|
7
|
+
*
|
|
8
|
+
* @param {String} header The field value of the header
|
|
9
|
+
* @return {Set} The subprotocol names
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
function parse(header) {
|
|
13
|
+
const protocols = new Set();
|
|
14
|
+
let start = -1;
|
|
15
|
+
let end = -1;
|
|
16
|
+
let i = 0;
|
|
17
|
+
|
|
18
|
+
for (i; i < header.length; i++) {
|
|
19
|
+
const code = header.charCodeAt(i);
|
|
20
|
+
|
|
21
|
+
if (end === -1 && tokenChars[code] === 1) {
|
|
22
|
+
if (start === -1) start = i;
|
|
23
|
+
} else if (
|
|
24
|
+
i !== 0 &&
|
|
25
|
+
(code === 0x20 /* ' ' */ || code === 0x09) /* '\t' */
|
|
26
|
+
) {
|
|
27
|
+
if (end === -1 && start !== -1) end = i;
|
|
28
|
+
} else if (code === 0x2c /* ',' */) {
|
|
29
|
+
if (start === -1) {
|
|
30
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (end === -1) end = i;
|
|
34
|
+
|
|
35
|
+
const protocol = header.slice(start, end);
|
|
36
|
+
|
|
37
|
+
if (protocols.has(protocol)) {
|
|
38
|
+
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protocols.add(protocol);
|
|
42
|
+
start = end = -1;
|
|
43
|
+
} else {
|
|
44
|
+
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (start === -1 || end !== -1) {
|
|
49
|
+
throw new SyntaxError('Unexpected end of input');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const protocol = header.slice(start, i);
|
|
53
|
+
|
|
54
|
+
if (protocols.has(protocol)) {
|
|
55
|
+
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protocols.add(protocol);
|
|
59
|
+
return protocols;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { parse };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { isUtf8 } = require('buffer');
|
|
4
|
+
|
|
5
|
+
const { hasBlob } = require('./constants');
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
// Allowed token characters:
|
|
9
|
+
//
|
|
10
|
+
// '!', '#', '$', '%', '&', ''', '*', '+', '-',
|
|
11
|
+
// '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~'
|
|
12
|
+
//
|
|
13
|
+
// tokenChars[32] === 0 // ' '
|
|
14
|
+
// tokenChars[33] === 1 // '!'
|
|
15
|
+
// tokenChars[34] === 0 // '"'
|
|
16
|
+
// ...
|
|
17
|
+
//
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
const tokenChars = [
|
|
20
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15
|
|
21
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31
|
|
22
|
+
0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32 - 47
|
|
23
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63
|
|
24
|
+
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79
|
|
25
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80 - 95
|
|
26
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111
|
|
27
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0 // 112 - 127
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Checks if a status code is allowed in a close frame.
|
|
32
|
+
*
|
|
33
|
+
* @param {Number} code The status code
|
|
34
|
+
* @return {Boolean} `true` if the status code is valid, else `false`
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
function isValidStatusCode(code) {
|
|
38
|
+
return (
|
|
39
|
+
(code >= 1000 &&
|
|
40
|
+
code <= 1014 &&
|
|
41
|
+
code !== 1004 &&
|
|
42
|
+
code !== 1005 &&
|
|
43
|
+
code !== 1006) ||
|
|
44
|
+
(code >= 3000 && code <= 4999)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a given buffer contains only correct UTF-8.
|
|
50
|
+
* Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by
|
|
51
|
+
* Markus Kuhn.
|
|
52
|
+
*
|
|
53
|
+
* @param {Buffer} buf The buffer to check
|
|
54
|
+
* @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
function _isValidUTF8(buf) {
|
|
58
|
+
const len = buf.length;
|
|
59
|
+
let i = 0;
|
|
60
|
+
|
|
61
|
+
while (i < len) {
|
|
62
|
+
if ((buf[i] & 0x80) === 0) {
|
|
63
|
+
// 0xxxxxxx
|
|
64
|
+
i++;
|
|
65
|
+
} else if ((buf[i] & 0xe0) === 0xc0) {
|
|
66
|
+
// 110xxxxx 10xxxxxx
|
|
67
|
+
if (
|
|
68
|
+
i + 1 === len ||
|
|
69
|
+
(buf[i + 1] & 0xc0) !== 0x80 ||
|
|
70
|
+
(buf[i] & 0xfe) === 0xc0 // Overlong
|
|
71
|
+
) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
i += 2;
|
|
76
|
+
} else if ((buf[i] & 0xf0) === 0xe0) {
|
|
77
|
+
// 1110xxxx 10xxxxxx 10xxxxxx
|
|
78
|
+
if (
|
|
79
|
+
i + 2 >= len ||
|
|
80
|
+
(buf[i + 1] & 0xc0) !== 0x80 ||
|
|
81
|
+
(buf[i + 2] & 0xc0) !== 0x80 ||
|
|
82
|
+
(buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80) || // Overlong
|
|
83
|
+
(buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF)
|
|
84
|
+
) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
i += 3;
|
|
89
|
+
} else if ((buf[i] & 0xf8) === 0xf0) {
|
|
90
|
+
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
|
91
|
+
if (
|
|
92
|
+
i + 3 >= len ||
|
|
93
|
+
(buf[i + 1] & 0xc0) !== 0x80 ||
|
|
94
|
+
(buf[i + 2] & 0xc0) !== 0x80 ||
|
|
95
|
+
(buf[i + 3] & 0xc0) !== 0x80 ||
|
|
96
|
+
(buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80) || // Overlong
|
|
97
|
+
(buf[i] === 0xf4 && buf[i + 1] > 0x8f) ||
|
|
98
|
+
buf[i] > 0xf4 // > U+10FFFF
|
|
99
|
+
) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
i += 4;
|
|
104
|
+
} else {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Determines whether a value is a `Blob`.
|
|
114
|
+
*
|
|
115
|
+
* @param {*} value The value to be tested
|
|
116
|
+
* @return {Boolean} `true` if `value` is a `Blob`, else `false`
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
function isBlob(value) {
|
|
120
|
+
return (
|
|
121
|
+
hasBlob &&
|
|
122
|
+
typeof value === 'object' &&
|
|
123
|
+
typeof value.arrayBuffer === 'function' &&
|
|
124
|
+
typeof value.type === 'string' &&
|
|
125
|
+
typeof value.stream === 'function' &&
|
|
126
|
+
(value[Symbol.toStringTag] === 'Blob' ||
|
|
127
|
+
value[Symbol.toStringTag] === 'File')
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = {
|
|
132
|
+
isBlob,
|
|
133
|
+
isValidStatusCode,
|
|
134
|
+
isValidUTF8: _isValidUTF8,
|
|
135
|
+
tokenChars
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (isUtf8) {
|
|
139
|
+
module.exports.isValidUTF8 = function (buf) {
|
|
140
|
+
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
141
|
+
};
|
|
142
|
+
} /* istanbul ignore else */ else if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
143
|
+
try {
|
|
144
|
+
const isValidUTF8 = require('utf-8-validate');
|
|
145
|
+
|
|
146
|
+
module.exports.isValidUTF8 = function (buf) {
|
|
147
|
+
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
148
|
+
};
|
|
149
|
+
} catch (e) {
|
|
150
|
+
// Continue regardless of the error.
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{styleText as y}from"node:util";import{stdout as S,stdin as $}from"node:process";import*as _ from"node:readline";import P from"node:readline";import{wrapAnsi as x}from"fast-wrap-ansi";import{cursor as c,erase as M}from"sisteransi";import{ReadStream as D}from"node:tty";function d(r,t,e){if(!e.some(o=>!o.disabled))return r;const s=r+t,i=Math.max(e.length-1,0),n=s<0?i:s>i?0:s;return e[n].disabled?d(n,t<0?-1:1,e):n}const E=["up","down","left","right","space","enter","cancel"],G=["January","February","March","April","May","June","July","August","September","October","November","December"],u={actions:new Set(E),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...G],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(r,t)=>`There are only ${r} days in ${t}`,afterMin:r=>`Date must be on or after ${r.toISOString().slice(0,10)}`,beforeMax:r=>`Date must be on or before ${r.toISOString().slice(0,10)}`}}};function K(r){if(r.aliases!==void 0){const t=r.aliases;for(const e in t){if(!Object.hasOwn(t,e))continue;const s=t[e];u.actions.has(s)&&(u.aliases.has(e)||u.aliases.set(e,s))}}if(r.messages!==void 0){const t=r.messages;t.cancel!==void 0&&(u.messages.cancel=t.cancel),t.error!==void 0&&(u.messages.error=t.error)}if(r.withGuide!==void 0&&(u.withGuide=r.withGuide!==!1),r.date!==void 0){const t=r.date;t.monthNames!==void 0&&(u.date.monthNames=[...t.monthNames]),t.messages!==void 0&&(t.messages.required!==void 0&&(u.date.messages.required=t.messages.required),t.messages.invalidMonth!==void 0&&(u.date.messages.invalidMonth=t.messages.invalidMonth),t.messages.invalidDay!==void 0&&(u.date.messages.invalidDay=t.messages.invalidDay),t.messages.afterMin!==void 0&&(u.date.messages.afterMin=t.messages.afterMin),t.messages.beforeMax!==void 0&&(u.date.messages.beforeMax=t.messages.beforeMax))}}function V(r,t){if(typeof r=="string")return u.aliases.get(r)===t;for(const e of r)if(e!==void 0&&V(e,t))return!0;return!1}function j(r,t){if(r===t)return;const e=r.split(`
|
|
2
|
+
`),s=t.split(`
|
|
3
|
+
`),i=Math.max(e.length,s.length),n=[];for(let o=0;o<i;o++)e[o]!==s[o]&&n.push(o);return{lines:n,numLinesBefore:e.length,numLinesAfter:s.length,numLines:i}}const Y=globalThis.process.platform.startsWith("win"),C=Symbol("clack:cancel");function q(r){return r===C}function w(r,t){const e=r;e.isTTY&&e.setRawMode(t)}function z({input:r=$,output:t=S,overwrite:e=!0,hideCursor:s=!0}={}){const i=_.createInterface({input:r,output:t,prompt:"",tabSize:1});_.emitKeypressEvents(r,i),r instanceof D&&r.isTTY&&r.setRawMode(!0);const n=(o,{name:a,sequence:h})=>{const l=String(o);if(V([l,a,h],"cancel")){s&&t.write(c.show),process.exit(0);return}if(!e)return;const f=a==="return"?0:-1,v=a==="return"?-1:0;_.moveCursor(t,f,v,()=>{_.clearLine(t,1,()=>{r.once("keypress",n)})})};return s&&t.write(c.hide),r.once("keypress",n),()=>{r.off("keypress",n),s&&t.write(c.show),r instanceof D&&r.isTTY&&!Y&&r.setRawMode(!1),i.terminal=!1,i.close()}}const O=r=>"columns"in r&&typeof r.columns=="number"?r.columns:80,A=r=>"rows"in r&&typeof r.rows=="number"?r.rows:20;function R(r,t,e,s=e){const i=O(r??S);return x(t,i-e.length,{hard:!0,trim:!1}).split(`
|
|
4
|
+
`).map((n,o)=>`${o===0?s:e}${n}`).join(`
|
|
5
|
+
`)}let p=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,e=!0){const{input:s=$,output:i=S,render:n,signal:o,...a}=t;this.opts=a,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=e,this._abortSignal=o,this.input=s,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(t,e){const s=this._subscribers.get(t)??[];s.push(e),this._subscribers.set(t,s)}on(t,e){this.setSubscriber(t,{cb:e})}once(t,e){this.setSubscriber(t,{cb:e,once:!0})}emit(t,...e){const s=this._subscribers.get(t)??[],i=[];for(const n of s)n.cb(...e),n.once&&i.push(()=>s.splice(s.indexOf(n),1));for(const n of i)n()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(C);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=P.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),w(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(c.show),this.output.off("resize",this.render),w(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(c.show),this.output.off("resize",this.render),w(this.input,!1),t(C)})})}_isActionKey(t,e){return t===" "}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,e){this.userInput=t??"",this.emit("userInput",this.userInput),e&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t,e){if(this._track&&e.name!=="return"&&(e.name&&this._isActionKey(t,e)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),e?.name&&(!this._track&&u.aliases.has(e.name)&&this.emit("cursor",u.aliases.get(e.name)),u.actions.has(e.name)&&this.emit("cursor",e.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t?.toLowerCase(),e),e?.name==="return"){if(this.opts.validate){const s=this.opts.validate(this.value);s&&(this.error=s instanceof Error?s.message:s,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}V([t,e?.name,e?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
6
|
+
`),w(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=x(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
7
|
+
`).length-1;this.output.write(c.move(-999,t*-1))}render(){const t=x(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(c.hide);else{const e=j(this._prevFrame,t),s=A(this.output);if(this.restoreCursor(),e){const i=Math.max(0,e.numLinesAfter-s),n=Math.max(0,e.numLinesBefore-s);let o=e.lines.find(a=>a>=i);if(o===void 0){this._prevFrame=t;return}if(e.lines.length===1){this.output.write(c.move(0,o-n)),this.output.write(M.lines(1));const a=t.split(`
|
|
8
|
+
`);this.output.write(a[o]),this._prevFrame=t,this.output.write(c.move(0,a.length-o-1));return}else if(e.lines.length>1){if(i<n)o=i;else{const h=o-n;h>0&&this.output.write(c.move(0,h))}this.output.write(M.down());const a=t.split(`
|
|
9
|
+
`).slice(o);this.output.write(a.join(`
|
|
10
|
+
`)),this._prevFrame=t;return}}this.output.write(M.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}};function W(r,t){if(r===void 0||t.length===0)return 0;const e=t.findIndex(s=>s.value===r);return e!==-1?e:0}function B(r,t){return(t.label??String(t.value)).toLowerCase().includes(r.toLowerCase())}function J(r,t){if(t)return r?t:t[0]}let H=class extends p{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#o="";#t;#n;#a;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return y(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;const t=this.userInput.slice(0,this._cursor),[e,...s]=this.userInput.slice(this._cursor);return`${t}${y("inverse",e)}${s.join("")}`}get options(){return typeof this.#n=="function"?this.#n():this.#n}constructor(t){super(t),this.#n=t.options,this.#a=t.placeholder;const e=this.options;this.filteredOptions=[...e],this.multiple=t.multiple===!0,this.#t=typeof t.options=="function"?t.filter:t.filter??B;let s;if(t.initialValue&&Array.isArray(t.initialValue)?this.multiple?s=t.initialValue:s=t.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(s=[this.options[0].value]),s)for(const i of s){const n=e.findIndex(o=>o.value===i);n!==-1&&(this.toggleSelected(i),this.#e=n)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(i,n)=>this.#s(i,n)),this.on("userInput",i=>this.#i(i))}_isActionKey(t,e){return t===" "||this.multiple&&this.isNavigating&&e.name==="space"&&t!==void 0&&t!==""}#s(t,e){const s=e.name==="up",i=e.name==="down",n=e.name==="return",o=this.userInput===""||this.userInput===" ",a=this.#a,h=this.options,l=a!==void 0&&a!==""&&h.some(f=>!f.disabled&&(this.#t?this.#t(a,f):!0));if(e.name==="tab"&&o&&l){this.userInput===" "&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}s||i?(this.#e=d(this.#e,s?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):n?this.value=J(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(e.name==="tab"||this.isNavigating&&e.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(t){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(t)?this.selectedValues=this.selectedValues.filter(e=>e!==t):this.selectedValues=[...this.selectedValues,t]:this.selectedValues=[t])}#i(t){if(t!==this.#o){this.#o=t;const e=this.options;t&&this.#t?this.filteredOptions=e.filter(n=>this.#t?.(t,n)):this.filteredOptions=[...e];const s=W(this.focusedValue,this.filteredOptions);this.#e=d(s,0,this.filteredOptions);const i=this.filteredOptions[this.#e];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class Q extends p{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",e=>{this.output.write(c.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}const X={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function L(r){return[...r].map(t=>X[t])}function Z(r){const t=new Intl.DateTimeFormat(r,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2e3,0,15)),e=[];let s="/";for(const i of t)i.type==="literal"?s=i.value.trim()||i.value:(i.type==="year"||i.type==="month"||i.type==="day")&&e.push({type:i.type,len:i.type==="year"?4:2});return{segments:e,separator:s}}function k(r){return Number.parseInt((r||"0").replace(/_/g,"0"),10)||0}function I(r){return{year:k(r.year),month:k(r.month),day:k(r.day)}}function T(r,t){return new Date(r||2001,t||1,0).getDate()}function F(r){const{year:t,month:e,day:s}=I(r);if(!t||t<0||t>9999||!e||e<1||e>12||!s||s<1)return;const i=new Date(Date.UTC(t,e-1,s));if(!(i.getUTCFullYear()!==t||i.getUTCMonth()!==e-1||i.getUTCDate()!==s))return{year:t,month:e,day:s}}function N(r){const t=F(r);return t?new Date(Date.UTC(t.year,t.month-1,t.day)):void 0}function tt(r,t,e,s){const i=e?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate()}:null,n=s?{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate()}:null;return r==="year"?{min:i?.year??1,max:n?.year??9999}:r==="month"?{min:i&&t.year===i.year?i.month:1,max:n&&t.year===n.year?n.month:12}:{min:i&&t.year===i.year&&t.month===i.month?i.day:1,max:n&&t.year===n.year&&t.month===n.month?n.day:T(t.year,t.month)}}class et extends p{#e;#o;#t;#n;#a;#s={segmentIndex:0,positionInSegment:0};#i=!0;#r=null;inlineError="";get segmentCursor(){return{...this.#s}}get segmentValues(){return{...this.#t}}get segments(){return this.#e}get separator(){return this.#o}get formattedValue(){return this.#c(this.#t)}#c(t){return this.#e.map(e=>t[e.type]).join(this.#o)}#h(){this._setUserInput(this.#c(this.#t)),this._setValue(N(this.#t)??void 0)}constructor(t){const e=t.format?{segments:L(t.format),separator:t.separator??"/"}:Z(t.locale),s=t.separator??e.separator,i=t.format?L(t.format):e.segments,n=t.initialValue??t.defaultValue,o=n?{year:String(n.getUTCFullYear()).padStart(4,"0"),month:String(n.getUTCMonth()+1).padStart(2,"0"),day:String(n.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},a=i.map(h=>o[h.type]).join(s);super({...t,initialUserInput:a},!1),this.#e=i,this.#o=s,this.#t=o,this.#n=t.minDate,this.#a=t.maxDate,this.#h(),this.on("cursor",h=>this.#d(h)),this.on("key",(h,l)=>this.#f(h,l)),this.on("finalize",()=>this.#g(t))}#u(){const t=Math.max(0,Math.min(this.#s.segmentIndex,this.#e.length-1)),e=this.#e[t];if(e)return this.#s.positionInSegment=Math.max(0,Math.min(this.#s.positionInSegment,e.len-1)),{segment:e,index:t}}#l(t){this.inlineError="",this.#r=null;const e=this.#u();e&&(this.#s.segmentIndex=Math.max(0,Math.min(this.#e.length-1,e.index+t)),this.#s.positionInSegment=0,this.#i=!0)}#p(t){const e=this.#u();if(!e)return;const{segment:s}=e,i=this.#t[s.type],n=!i||i.replace(/_/g,"")==="",o=Number.parseInt((i||"0").replace(/_/g,"0"),10)||0,a=tt(s.type,I(this.#t),this.#n,this.#a);let h;n?h=t===1?a.min:a.max:h=Math.max(Math.min(a.max,o+t),a.min),this.#t={...this.#t,[s.type]:h.toString().padStart(s.len,"0")},this.#i=!0,this.#r=null,this.#h()}#d(t){if(t)switch(t){case"right":return this.#l(1);case"left":return this.#l(-1);case"up":return this.#p(1);case"down":return this.#p(-1)}}#f(t,e){if(e?.name==="backspace"||e?.sequence==="\x7F"||e?.sequence==="\b"||t==="\x7F"||t==="\b"){this.inlineError="";const s=this.#u();if(!s)return;if(!this.#t[s.segment.type].replace(/_/g,"")){this.#l(-1);return}this.#t[s.segment.type]="_".repeat(s.segment.len),this.#i=!0,this.#s.positionInSegment=0,this.#h();return}if(e?.name==="tab"){this.inlineError="";const s=this.#u();if(!s)return;const i=e.shift?-1:1,n=s.index+i;n>=0&&n<this.#e.length&&(this.#s.segmentIndex=n,this.#s.positionInSegment=0,this.#i=!0);return}if(t&&/^[0-9]$/.test(t)){const s=this.#u();if(!s)return;const{segment:i}=s,n=!this.#t[i.type].replace(/_/g,"");if(this.#i&&this.#r!==null&&!n){const m=this.#r+t,g={...this.#t,[i.type]:m},b=this.#m(g,i);if(b){this.inlineError=b,this.#r=null,this.#i=!1;return}this.inlineError="",this.#t[i.type]=m,this.#r=null,this.#i=!1,this.#h(),s.index<this.#e.length-1&&(this.#s.segmentIndex=s.index+1,this.#s.positionInSegment=0,this.#i=!0);return}this.#i&&!n&&(this.#t[i.type]="_".repeat(i.len),this.#s.positionInSegment=0),this.#i=!1,this.#r=null;const o=this.#t[i.type],a=o.indexOf("_"),h=a>=0?a:Math.min(this.#s.positionInSegment,i.len-1);if(h<0||h>=i.len)return;let l=o.slice(0,h)+t+o.slice(h+1),f=!1;if(h===0&&o==="__"&&(i.type==="month"||i.type==="day")){const m=Number.parseInt(t,10);l=`0${t}`,f=m<=(i.type==="month"?1:2)}if(i.type==="year"&&(l=(o.replace(/_/g,"")+t).padStart(i.len,"_")),!l.includes("_")){const m={...this.#t,[i.type]:l},g=this.#m(m,i);if(g){this.inlineError=g;return}}this.inlineError="",this.#t[i.type]=l;const v=l.includes("_")?void 0:F(this.#t);if(v){const{year:m,month:g}=v,b=T(m,g);this.#t={year:String(Math.max(0,Math.min(9999,m))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,g))).padStart(2,"0"),day:String(Math.max(1,Math.min(b,v.day))).padStart(2,"0")}}this.#h();const U=l.indexOf("_");f?(this.#i=!0,this.#r=t):U>=0?this.#s.positionInSegment=U:a>=0&&s.index<this.#e.length-1?(this.#s.segmentIndex=s.index+1,this.#s.positionInSegment=0,this.#i=!0):this.#s.positionInSegment=Math.min(h+1,i.len-1)}}#m(t,e){const{month:s,day:i}=I(t);if(e.type==="month"&&(s<0||s>12))return u.date.messages.invalidMonth;if(e.type==="day"&&(i<0||i>31))return u.date.messages.invalidDay(31,"any month")}#g(t){const{year:e,month:s,day:i}=I(this.#t);if(e&&s&&i){const n=T(e,s);this.#t={...this.#t,day:String(Math.min(i,n)).padStart(2,"0")}}this.value=N(this.#t)??t.defaultValue??void 0}}class st extends p{options;cursor=0;#e;getGroupItems(t){return this.options.filter(e=>e.group===t)}isGroupSelected(t){const e=this.getGroupItems(t),s=this.value;return s===void 0?!1:e.every(i=>s.includes(i.value))}toggleValue(){const t=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),t.group===!0){const e=t.value,s=this.getGroupItems(e);this.isGroupSelected(e)?this.value=this.value.filter(i=>s.findIndex(n=>n.value===i)===-1):this.value=[...this.value,...s.map(i=>i.value)],this.value=Array.from(new Set(this.value))}else{const e=this.value.includes(t.value);this.value=e?this.value.filter(s=>s!==t.value):[...this.value,t.value]}}constructor(t){super(t,!1);const{options:e}=t;this.#e=t.selectableGroups!==!1,this.options=Object.entries(e).flatMap(([s,i])=>[{value:s,group:!0,label:s},...i.map(n=>({...n,group:s}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:s})=>s===t.cursorAt),this.#e?0:1),this.on("cursor",s=>{switch(s){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;const i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;const i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}let it=class extends p{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(t=>t.disabled!==!0)}toggleAll(){const t=this._enabledOptions,e=this.value!==void 0&&this.value.length===t.length;this.value=e?[]:t.map(s=>s.value)}toggleInvert(){const t=this.value;if(!t)return;const e=this._enabledOptions.filter(s=>!t.includes(s.value));this.value=e.map(s=>s.value)}toggleValue(){this.value===void 0&&(this.value=[]);const t=this.value.includes(this._value);this.value=t?this.value.filter(e=>e!==this._value):[...this.value,this._value]}constructor(t){super(t,!1),this.options=t.options,this.value=[...t.initialValues??[]];const e=Math.max(this.options.findIndex(({value:s})=>s===t.cursorAt),0);this.cursor=this.options[e].disabled?d(e,1,this.options):e,this.on("key",s=>{s==="a"&&this.toggleAll(),s==="i"&&this.toggleInvert()}),this.on("cursor",s=>{switch(s){case"left":case"up":this.cursor=d(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=d(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}};class rt extends p{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;const t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${y(["inverse","hidden"],"_")}`;const e=this.masked,s=e.slice(0,this.cursor),i=e.slice(this.cursor);return`${s}${y("inverse",i[0])}${i.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...e}){super(e),this._mask=t??"\u2022",this.on("userInput",s=>{this._setValue(s)})}}class nt extends p{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;const e=this.options.findIndex(({value:i})=>i===t.initialValue),s=e===-1?0:e;this.cursor=this.options[s].disabled?d(s,1,this.options):s,this.changeValue(),this.on("cursor",i=>{switch(i){case"left":case"up":this.cursor=d(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=d(this.cursor,1,this.options);break}this.changeValue()})}}class ot extends p{options;cursor=0;constructor(t){super(t,!1),this.options=t.options;const e=t.caseSensitive===!0,s=this.options.map(({value:[i]})=>e?i:i?.toLowerCase());this.cursor=Math.max(s.indexOf(t.initialValue),0),this.on("key",(i,n)=>{if(!i)return;const o=e&&n.shift?i.toUpperCase():i;if(!s.includes(o))return;const a=this.options.find(({value:[h]})=>e?h===o:h?.toLowerCase()===i);a&&(this.value=a.value,this.state="submit",this.emit("submit"))})}}class at extends p{get userInputWithCursor(){if(this.state==="submit")return this.userInput;const t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;const e=t.slice(0,this.cursor),[s,...i]=t.slice(this.cursor);return`${e}${y("inverse",s)}${i.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",e=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}export{H as AutocompletePrompt,Q as ConfirmPrompt,et as DatePrompt,st as GroupMultiSelectPrompt,it as MultiSelectPrompt,rt as PasswordPrompt,p as Prompt,ot as SelectKeyPrompt,nt as SelectPrompt,at as TextPrompt,z as block,O as getColumns,A as getRows,q as isCancel,u as settings,K as updateSettings,R as wrapTextWithPrefix};
|
|
11
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clack/core",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.mts",
|
|
10
|
+
"default": "./dist/index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/bombshell-dev/clack.git",
|
|
18
|
+
"directory": "packages/core"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/bombshell-dev/clack/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/bombshell-dev/clack/tree/main/packages/core#readme",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"CHANGELOG.md"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"ask",
|
|
30
|
+
"clack",
|
|
31
|
+
"cli",
|
|
32
|
+
"command-line",
|
|
33
|
+
"command",
|
|
34
|
+
"input",
|
|
35
|
+
"interact",
|
|
36
|
+
"interface",
|
|
37
|
+
"menu",
|
|
38
|
+
"prompt",
|
|
39
|
+
"prompts",
|
|
40
|
+
"stdin",
|
|
41
|
+
"ui"
|
|
42
|
+
],
|
|
43
|
+
"author": {
|
|
44
|
+
"name": "Nate Moore",
|
|
45
|
+
"email": "nate@natemoo.re",
|
|
46
|
+
"url": "https://twitter.com/n_moore"
|
|
47
|
+
},
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"fast-wrap-ansi": "^0.1.3",
|
|
51
|
+
"sisteransi": "^1.0.5"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"vitest": "^3.2.4"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "unbuild",
|
|
58
|
+
"test": "vitest run"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import{getColumns as X,getRows as ke,AutocompletePrompt as ve,settings as I,ConfirmPrompt as Le,wrapTextWithPrefix as N,DatePrompt as De,isCancel as We,GroupMultiSelectPrompt as Fe,MultiSelectPrompt as He,PasswordPrompt as Ue,block as Ke,SelectPrompt as qe,SelectKeyPrompt as Je,TextPrompt as Ye}from"@clack/core";export{isCancel,settings,updateSettings}from"@clack/core";import{styleText as t,stripVTControlCharacters as ne}from"node:util";import P from"node:process";import{wrapAnsi as q}from"fast-wrap-ansi";import B from"fast-string-width";import{existsSync as Xe,lstatSync as we,readdirSync as ze}from"node:fs";import{dirname as be,join as Qe}from"node:path";import{cursor as Se,erase as Ce}from"sisteransi";function Ze(){return P.platform!=="win32"?P.env.TERM!=="linux":!!P.env.CI||!!P.env.WT_SESSION||!!P.env.TERMINUS_SUBLIME||P.env.ConEmuTask==="{cmd::Cmder}"||P.env.TERM_PROGRAM==="Terminus-Sublime"||P.env.TERM_PROGRAM==="vscode"||P.env.TERM==="xterm-256color"||P.env.TERM==="alacritty"||P.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const ee=Ze(),ae=()=>process.env.CI==="true",Te=e=>e.isTTY===!0,w=(e,i)=>ee?e:i,_e=w("\u25C6","*"),oe=w("\u25A0","x"),ue=w("\u25B2","x"),F=w("\u25C7","o"),le=w("\u250C","T"),d=w("\u2502","|"),E=w("\u2514","\u2014"),Ie=w("\u2510","T"),Ee=w("\u2518","\u2014"),z=w("\u25CF",">"),H=w("\u25CB"," "),te=w("\u25FB","[\u2022]"),U=w("\u25FC","[+]"),J=w("\u25FB","[ ]"),xe=w("\u25AA","\u2022"),se=w("\u2500","-"),ce=w("\u256E","+"),Ge=w("\u251C","+"),$e=w("\u256F","+"),de=w("\u2570","+"),Oe=w("\u256D","+"),he=w("\u25CF","\u2022"),pe=w("\u25C6","*"),me=w("\u25B2","!"),ge=w("\u25A0","x"),V=e=>{switch(e){case"initial":case"active":return t("cyan",_e);case"cancel":return t("red",oe);case"error":return t("yellow",ue);case"submit":return t("green",F)}},ye=e=>{switch(e){case"initial":case"active":return t("cyan",d);case"cancel":return t("red",d);case"error":return t("yellow",d);case"submit":return t("green",d)}},et=(e,i,s,r,u)=>{let n=i,o=0;for(let c=s;c<r;c++){const a=e[c];if(n=n-a.length,o++,n<=u)break}return{lineCount:n,removals:o}},Y=({cursor:e,options:i,style:s,output:r=process.stdout,maxItems:u=Number.POSITIVE_INFINITY,columnPadding:n=0,rowPadding:o=4})=>{const c=X(r)-n,a=ke(r),l=t("dim","..."),$=Math.max(a-o,0),y=Math.max(Math.min(u,$),5);let p=0;e>=y-3&&(p=Math.max(Math.min(e-y+3,i.length-y),0));let m=y<i.length&&p>0,g=y<i.length&&p+y<i.length;const S=Math.min(p+y,i.length),h=[];let f=0;m&&f++,g&&f++;const v=p+(m?1:0),T=S-(g?1:0);for(let b=v;b<T;b++){const x=q(s(i[b],b===e),c,{hard:!0,trim:!1}).split(`
|
|
2
|
+
`);h.push(x),f+=x.length}if(f>$){let b=0,x=0,G=f;const M=e-v,R=(j,D)=>et(h,G,j,D,$);m?({lineCount:G,removals:b}=R(0,M),G>$&&({lineCount:G,removals:x}=R(M+1,h.length))):({lineCount:G,removals:x}=R(M+1,h.length),G>$&&({lineCount:G,removals:b}=R(0,M))),b>0&&(m=!0,h.splice(0,b)),x>0&&(g=!0,h.splice(h.length-x,x))}const C=[];m&&C.push(l);for(const b of h)for(const x of b)C.push(x);return g&&C.push(l),C};function Me(e){return e.label??String(e.value??"")}function Re(e,i){if(!e)return!0;const s=(i.label??String(i.value??"")).toLowerCase(),r=(i.hint??"").toLowerCase(),u=String(i.value).toLowerCase(),n=e.toLowerCase();return s.includes(n)||r.includes(n)||u.includes(n)}function tt(e,i){const s=[];for(const r of i)e.includes(r.value)&&s.push(r);return s}const Ae=e=>new ve({options:e.options,initialValue:e.initialValue?[e.initialValue]:void 0,initialUserInput:e.initialUserInput,placeholder:e.placeholder,filter:e.filter??((i,s)=>Re(i,s)),signal:e.signal,input:e.input,output:e.output,validate:e.validate,render(){const i=e.withGuide??I.withGuide,s=i?[`${t("gray",d)}`,`${V(this.state)} ${e.message}`]:[`${V(this.state)} ${e.message}`],r=this.userInput,u=this.options,n=e.placeholder,o=r===""&&n!==void 0,c=(a,l)=>{const $=Me(a),y=a.hint&&a.value===this.focusedValue?t("dim",` (${a.hint})`):"";switch(l){case"active":return`${t("green",z)} ${$}${y}`;case"inactive":return`${t("dim",H)} ${t("dim",$)}`;case"disabled":return`${t("gray",H)} ${t(["strikethrough","gray"],$)}`}};switch(this.state){case"submit":{const a=tt(this.selectedValues,u),l=a.length>0?` ${t("dim",a.map(Me).join(", "))}`:"",$=i?t("gray",d):"";return`${s.join(`
|
|
3
|
+
`)}
|
|
4
|
+
${$}${l}`}case"cancel":{const a=r?` ${t(["strikethrough","dim"],r)}`:"",l=i?t("gray",d):"";return`${s.join(`
|
|
5
|
+
`)}
|
|
6
|
+
${l}${a}`}default:{const a=this.state==="error"?"yellow":"cyan",l=i?`${t(a,d)} `:"",$=i?t(a,E):"";let y="";if(this.isNavigating||o){const v=o?n:r;y=v!==""?` ${t("dim",v)}`:""}else y=` ${this.userInputWithCursor}`;const p=this.filteredOptions.length!==u.length?t("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",m=this.filteredOptions.length===0&&r?[`${l}${t("yellow","No matches found")}`]:[],g=this.state==="error"?[`${l}${t("yellow",this.error)}`]:[];i&&s.push(`${l.trimEnd()}`),s.push(`${l}${t("dim","Search:")}${y}${p}`,...m,...g);const S=[`${t("dim","\u2191/\u2193")} to select`,`${t("dim","Enter:")} confirm`,`${t("dim","Type:")} to search`],h=[`${l}${S.join(" \u2022 ")}`,$],f=this.filteredOptions.length===0?[]:Y({cursor:this.cursor,options:this.filteredOptions,columnPadding:i?3:0,rowPadding:s.length+h.length,style:(v,T)=>c(v,v.disabled?"disabled":T?"active":"inactive"),maxItems:e.maxItems,output:e.output});return[...s,...f.map(v=>`${l}${v}`),...h].join(`
|
|
7
|
+
`)}}}}).prompt(),st=e=>{const i=(r,u,n,o)=>{const c=n.includes(r.value),a=r.label??String(r.value??""),l=r.hint&&o!==void 0&&r.value===o?t("dim",` (${r.hint})`):"",$=c?t("green",U):t("dim",J);return r.disabled?`${t("gray",J)} ${t(["strikethrough","gray"],a)}`:u?`${$} ${a}${l}`:`${$} ${t("dim",a)}`},s=new ve({options:e.options,multiple:!0,placeholder:e.placeholder,filter:e.filter??((r,u)=>Re(r,u)),validate:()=>{if(e.required&&s.selectedValues.length===0)return"Please select at least one item"},initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){const r=e.withGuide??I.withGuide,u=`${r?`${t("gray",d)}
|
|
8
|
+
`:""}${V(this.state)} ${e.message}
|
|
9
|
+
`,n=this.userInput,o=e.placeholder,c=n===""&&o!==void 0,a=this.isNavigating||c?t("dim",c?o:n):this.userInputWithCursor,l=this.options,$=this.filteredOptions.length!==l.length?t("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${u}${r?`${t("gray",d)} `:""}${t("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${u}${r?`${t("gray",d)} `:""}${t(["strikethrough","dim"],n)}`;default:{const y=this.state==="error"?"yellow":"cyan",p=r?`${t(y,d)} `:"",m=r?t(y,E):"",g=[`${t("dim","\u2191/\u2193")} to navigate`,`${t("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${t("dim","Enter:")} confirm`,`${t("dim","Type:")} to search`],S=this.filteredOptions.length===0&&n?[`${p}${t("yellow","No matches found")}`]:[],h=this.state==="error"?[`${p}${t("yellow",this.error)}`]:[],f=[...`${u}${r?t(y,d):""}`.split(`
|
|
10
|
+
`),`${p}${t("dim","Search:")} ${a}${$}`,...S,...h],v=[`${p}${g.join(" \u2022 ")}`,m],T=Y({cursor:this.cursor,options:this.filteredOptions,style:(C,b)=>i(C,b,this.selectedValues,this.focusedValue),maxItems:e.maxItems,output:e.output,rowPadding:f.length+v.length});return[...f,...T.map(C=>`${p}${C}`),...v].join(`
|
|
11
|
+
`)}}}});return s.prompt()},rt=[Oe,ce,de,$e],it=[le,Ie,E,Ee];function Pe(e,i,s,r){let u=s,n=s;return r==="center"?u=Math.floor((i-e)/2):r==="right"&&(u=i-e-s),n=i-u-e,[u,n]}const nt=e=>e,at=(e="",i="",s)=>{const r=s?.output??process.stdout,u=X(r),n=2,o=s?.titlePadding??1,c=s?.contentPadding??2,a=s?.width===void 0||s.width==="auto"?1:Math.min(1,s.width),l=s?.withGuide??I.withGuide?`${d} `:"",$=s?.formatBorder??nt,y=(s?.rounded?rt:it).map($),p=$(se),m=$(d),g=B(l),S=B(i),h=u-g;let f=Math.floor(u*a)-g;if(s?.width==="auto"){const R=e.split(`
|
|
12
|
+
`);let j=S+o*2;for(const ie of R){const W=B(ie)+c*2;W>j&&(j=W)}const D=j+n;D<f&&(f=D)}f%2!==0&&(f<h?f++:f--);const v=f-n,T=v-o*2,C=S>T?`${i.slice(0,T-3)}...`:i,[b,x]=Pe(B(C),v,o,s?.titleAlign),G=q(e,v-c*2,{hard:!0,trim:!1});r.write(`${l}${y[0]}${p.repeat(b)}${C}${p.repeat(x)}${y[1]}
|
|
13
|
+
`);const M=G.split(`
|
|
14
|
+
`);for(const R of M){const[j,D]=Pe(B(R),v,c,s?.contentAlign);r.write(`${l}${m}${" ".repeat(j)}${R}${" ".repeat(D)}${m}
|
|
15
|
+
`)}r.write(`${l}${y[2]}${p.repeat(v)}${y[3]}
|
|
16
|
+
`)},ot=e=>{const i=e.active??"Yes",s=e.inactive??"No";return new Le({active:i,inactive:s,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const r=e.withGuide??I.withGuide,u=`${V(this.state)} `,n=r?`${t("gray",d)} `:"",o=N(e.output,e.message,n,u),c=`${r?`${t("gray",d)}
|
|
17
|
+
`:""}${o}
|
|
18
|
+
`,a=this.value?i:s;switch(this.state){case"submit":{const l=r?`${t("gray",d)} `:"";return`${c}${l}${t("dim",a)}`}case"cancel":{const l=r?`${t("gray",d)} `:"";return`${c}${l}${t(["strikethrough","dim"],a)}${r?`
|
|
19
|
+
${t("gray",d)}`:""}`}default:{const l=r?`${t("cyan",d)} `:"",$=r?t("cyan",E):"";return`${c}${l}${this.value?`${t("green",z)} ${i}`:`${t("dim",H)} ${t("dim",i)}`}${e.vertical?r?`
|
|
20
|
+
${t("cyan",d)} `:`
|
|
21
|
+
`:` ${t("dim","/")} `}${this.value?`${t("dim",H)} ${t("dim",s)}`:`${t("green",z)} ${s}`}
|
|
22
|
+
${$}
|
|
23
|
+
`}}}}).prompt()},ut=e=>{const i=e.validate;return new De({...e,validate(s){if(s===void 0)return e.defaultValue!==void 0?void 0:i?i(s):I.date.messages.required;const r=u=>u.toISOString().slice(0,10);if(e.minDate&&r(s)<r(e.minDate))return I.date.messages.afterMin(e.minDate);if(e.maxDate&&r(s)>r(e.maxDate))return I.date.messages.beforeMax(e.maxDate);if(i)return i(s)},render(){const s=(e?.withGuide??I.withGuide)!==!1,r=`${`${s?`${t("gray",d)}
|
|
24
|
+
`:""}${V(this.state)} `}${e.message}
|
|
25
|
+
`,u=this.state!=="initial"?this.state:"active",n=lt(this,u),o=this.value instanceof Date?this.formattedValue:"";switch(this.state){case"error":{const c=this.error?` ${t("yellow",this.error)}`:"",a=s?`${t("yellow",d)} `:"",l=s?t("yellow",E):"";return`${r.trim()}
|
|
26
|
+
${a}${n}
|
|
27
|
+
${l}${c}
|
|
28
|
+
`}case"submit":{const c=o?` ${t("dim",o)}`:"",a=s?t("gray",d):"";return`${r}${a}${c}`}case"cancel":{const c=o?` ${t(["strikethrough","dim"],o)}`:"",a=s?t("gray",d):"";return`${r}${a}${c}${o.trim()?`
|
|
29
|
+
${a}`:""}`}default:{const c=s?`${t("cyan",d)} `:"",a=s?t("cyan",E):"",l=s?`${t("cyan",d)} `:"",$=this.inlineError?`
|
|
30
|
+
${l}${t("yellow",this.inlineError)}`:"";return`${r}${c}${n}${$}
|
|
31
|
+
${a}
|
|
32
|
+
`}}}}).prompt()};function lt(e,i){const s=e.segmentValues,r=e.segmentCursor;if(i==="submit"||i==="cancel")return e.formattedValue;const u=t("gray",e.separator);return e.segments.map((n,o)=>{const c=o===r.segmentIndex&&!["submit","cancel"].includes(i),a=$t[n.type];return ct(s[n.type],{isActive:c,label:a})}).join(u)}function ct(e,i){const s=!e||e.replace(/_/g,"")==="";return i.isActive?t("inverse",s?i.label:e.replace(/_/g," ")):s?t("dim",i.label):e.replace(/_/g,t("dim"," "))}const $t={year:"yyyy",month:"mm",day:"dd"},dt=async(e,i)=>{const s={},r=Object.keys(e);for(const u of r){const n=e[u],o=await n({results:s})?.catch(c=>{throw c});if(typeof i?.onCancel=="function"&&We(o)){s[u]="canceled",i.onCancel({results:s});continue}s[u]=o}return s},ht=e=>{const{selectableGroups:i=!0,groupSpacing:s=0}=e,r=(n,o,c=[])=>{const a=n.label??String(n.value),l=typeof n.group=="string",$=l&&(c[c.indexOf(n)+1]??{group:!0}),y=l&&$&&$.group===!0,p=l?i?`${y?E:d} `:" ":"";let m="";if(s>0&&!l){const S=`
|
|
33
|
+
${t("cyan",d)}`;m=`${S.repeat(s-1)}${S} `}if(o==="active")return`${m}${t("dim",p)}${t("cyan",te)} ${a}${n.hint?` ${t("dim",`(${n.hint})`)}`:""}`;if(o==="group-active")return`${m}${p}${t("cyan",te)} ${t("dim",a)}`;if(o==="group-active-selected")return`${m}${p}${t("green",U)} ${t("dim",a)}`;if(o==="selected"){const S=l||i?t("green",U):"";return`${m}${t("dim",p)}${S} ${t("dim",a)}${n.hint?` ${t("dim",`(${n.hint})`)}`:""}`}if(o==="cancelled")return`${t(["strikethrough","dim"],a)}`;if(o==="active-selected")return`${m}${t("dim",p)}${t("green",U)} ${a}${n.hint?` ${t("dim",`(${n.hint})`)}`:""}`;if(o==="submitted")return`${t("dim",a)}`;const g=l||i?t("dim",J):"";return`${m}${t("dim",p)}${g} ${t("dim",a)}`},u=e.required??!0;return new Fe({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:u,cursorAt:e.cursorAt,selectableGroups:i,validate(n){if(u&&(n===void 0||n.length===0))return`Please select at least one option.
|
|
34
|
+
${t("reset",t("dim",`Press ${t(["gray","bgWhite","inverse"]," space ")} to select, ${t("gray",t(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){const n=e.withGuide??I.withGuide,o=`${n?`${t("gray",d)}
|
|
35
|
+
`:""}${V(this.state)} ${e.message}
|
|
36
|
+
`,c=this.value??[];switch(this.state){case"submit":{const a=this.options.filter(({value:$})=>c.includes($)).map($=>r($,"submitted")),l=a.length===0?"":` ${a.join(t("dim",", "))}`;return`${o}${n?t("gray",d):""}${l}`}case"cancel":{const a=this.options.filter(({value:l})=>c.includes(l)).map(l=>r(l,"cancelled")).join(t("dim",", "));return`${o}${n?`${t("gray",d)} `:""}${a.trim()?`${a}${n?`
|
|
37
|
+
${t("gray",d)}`:""}`:""}`}case"error":{const a=this.error.split(`
|
|
38
|
+
`).map((l,$)=>$===0?`${n?`${t("yellow",E)} `:""}${t("yellow",l)}`:` ${l}`).join(`
|
|
39
|
+
`);return`${o}${n?`${t("yellow",d)} `:""}${this.options.map((l,$,y)=>{const p=c.includes(l.value)||l.group===!0&&this.isGroupSelected(`${l.value}`),m=$===this.cursor;return!m&&typeof l.group=="string"&&this.options[this.cursor].value===l.group?r(l,p?"group-active-selected":"group-active",y):m&&p?r(l,"active-selected",y):p?r(l,"selected",y):r(l,m?"active":"inactive",y)}).join(`
|
|
40
|
+
${n?`${t("yellow",d)} `:""}`)}
|
|
41
|
+
${a}
|
|
42
|
+
`}default:{const a=this.options.map(($,y,p)=>{const m=c.includes($.value)||$.group===!0&&this.isGroupSelected(`${$.value}`),g=y===this.cursor,S=!g&&typeof $.group=="string"&&this.options[this.cursor].value===$.group;let h="";return S?h=r($,m?"group-active-selected":"group-active",p):g&&m?h=r($,"active-selected",p):m?h=r($,"selected",p):h=r($,g?"active":"inactive",p),`${y!==0&&!h.startsWith(`
|
|
43
|
+
`)?" ":""}${h}`}).join(`
|
|
44
|
+
${n?t("cyan",d):""}`),l=a.startsWith(`
|
|
45
|
+
`)?"":" ";return`${o}${n?t("cyan",d):""}${l}${a}
|
|
46
|
+
${n?t("cyan",E):""}
|
|
47
|
+
`}}}}).prompt()},O={message:(e=[],{symbol:i=t("gray",d),secondarySymbol:s=t("gray",d),output:r=process.stdout,spacing:u=1,withGuide:n}={})=>{const o=[],c=n??I.withGuide,a=c?s:"",l=c?`${i} `:"",$=c?`${s} `:"";for(let p=0;p<u;p++)o.push(a);const y=Array.isArray(e)?e:e.split(`
|
|
48
|
+
`);if(y.length>0){const[p,...m]=y;p.length>0?o.push(`${l}${p}`):o.push(c?i:"");for(const g of m)g.length>0?o.push(`${$}${g}`):o.push(c?s:"")}r.write(`${o.join(`
|
|
49
|
+
`)}
|
|
50
|
+
`)},info:(e,i)=>{O.message(e,{...i,symbol:t("blue",he)})},success:(e,i)=>{O.message(e,{...i,symbol:t("green",pe)})},step:(e,i)=>{O.message(e,{...i,symbol:t("green",F)})},warn:(e,i)=>{O.message(e,{...i,symbol:t("yellow",me)})},warning:(e,i)=>{O.warn(e,i)},error:(e,i)=>{O.message(e,{...i,symbol:t("red",ge)})}},pt=(e="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??I.withGuide?`${t("gray",E)} `:"";s.write(`${r}${t("red",e)}
|
|
51
|
+
|
|
52
|
+
`)},mt=(e="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??I.withGuide?`${t("gray",le)} `:"";s.write(`${r}${e}
|
|
53
|
+
`)},gt=(e="",i)=>{const s=i?.output??process.stdout,r=i?.withGuide??I.withGuide?`${t("gray",d)}
|
|
54
|
+
${t("gray",E)} `:"";s.write(`${r}${e}
|
|
55
|
+
|
|
56
|
+
`)},Q=(e,i)=>e.split(`
|
|
57
|
+
`).map(s=>i(s)).join(`
|
|
58
|
+
`),yt=e=>{const i=(r,u)=>{const n=r.label??String(r.value);return u==="disabled"?`${t("gray",J)} ${Q(n,o=>t(["strikethrough","gray"],o))}${r.hint?` ${t("dim",`(${r.hint??"disabled"})`)}`:""}`:u==="active"?`${t("cyan",te)} ${n}${r.hint?` ${t("dim",`(${r.hint})`)}`:""}`:u==="selected"?`${t("green",U)} ${Q(n,o=>t("dim",o))}${r.hint?` ${t("dim",`(${r.hint})`)}`:""}`:u==="cancelled"?`${Q(n,o=>t(["strikethrough","dim"],o))}`:u==="active-selected"?`${t("green",U)} ${n}${r.hint?` ${t("dim",`(${r.hint})`)}`:""}`:u==="submitted"?`${Q(n,o=>t("dim",o))}`:`${t("dim",J)} ${Q(n,o=>t("dim",o))}`},s=e.required??!0;return new He({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:s,cursorAt:e.cursorAt,validate(r){if(s&&(r===void 0||r.length===0))return`Please select at least one option.
|
|
59
|
+
${t("reset",t("dim",`Press ${t(["gray","bgWhite","inverse"]," space ")} to select, ${t("gray",t("bgWhite",t("inverse"," enter ")))} to submit`))}`},render(){const r=e.withGuide??I.withGuide,u=N(e.output,e.message,r?`${ye(this.state)} `:"",`${V(this.state)} `),n=`${r?`${t("gray",d)}
|
|
60
|
+
`:""}${u}
|
|
61
|
+
`,o=this.value??[],c=(a,l)=>{if(a.disabled)return i(a,"disabled");const $=o.includes(a.value);return l&&$?i(a,"active-selected"):$?i(a,"selected"):i(a,l?"active":"inactive")};switch(this.state){case"submit":{const a=this.options.filter(({value:$})=>o.includes($)).map($=>i($,"submitted")).join(t("dim",", "))||t("dim","none"),l=N(e.output,a,r?`${t("gray",d)} `:"");return`${n}${l}`}case"cancel":{const a=this.options.filter(({value:$})=>o.includes($)).map($=>i($,"cancelled")).join(t("dim",", "));if(a.trim()==="")return`${n}${t("gray",d)}`;const l=N(e.output,a,r?`${t("gray",d)} `:"");return`${n}${l}${r?`
|
|
62
|
+
${t("gray",d)}`:""}`}case"error":{const a=r?`${t("yellow",d)} `:"",l=this.error.split(`
|
|
63
|
+
`).map((p,m)=>m===0?`${r?`${t("yellow",E)} `:""}${t("yellow",p)}`:` ${p}`).join(`
|
|
64
|
+
`),$=n.split(`
|
|
65
|
+
`).length,y=l.split(`
|
|
66
|
+
`).length+1;return`${n}${a}${Y({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:$+y,style:c}).join(`
|
|
67
|
+
${a}`)}
|
|
68
|
+
${l}
|
|
69
|
+
`}default:{const a=r?`${t("cyan",d)} `:"",l=n.split(`
|
|
70
|
+
`).length,$=r?2:1;return`${n}${a}${Y({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:l+$,style:c}).join(`
|
|
71
|
+
${a}`)}
|
|
72
|
+
${r?t("cyan",E):""}
|
|
73
|
+
`}}}}).prompt()},ft=e=>t("dim",e),vt=(e,i,s)=>{const r={hard:!0,trim:!1},u=q(e,i,r).split(`
|
|
74
|
+
`),n=u.reduce((a,l)=>Math.max(B(l),a),0),o=u.map(s).reduce((a,l)=>Math.max(B(l),a),0),c=i-(o-n);return q(e,c,r)},wt=(e="",i="",s)=>{const r=s?.output??P.stdout,u=s?.withGuide??I.withGuide,n=s?.format??ft,o=["",...vt(e,X(r)-6,n).split(`
|
|
75
|
+
`).map(n),""],c=B(i),a=Math.max(o.reduce((p,m)=>{const g=B(m);return g>p?g:p},0),c)+2,l=o.map(p=>`${t("gray",d)} ${p}${" ".repeat(a-B(p))}${t("gray",d)}`).join(`
|
|
76
|
+
`),$=u?`${t("gray",d)}
|
|
77
|
+
`:"",y=u?Ge:de;r.write(`${$}${t("green",F)} ${t("reset",i)} ${t("gray",se.repeat(Math.max(a-c-1,1))+ce)}
|
|
78
|
+
${l}
|
|
79
|
+
${t("gray",y+se.repeat(a+2)+$e)}
|
|
80
|
+
`)},bt=e=>new Ue({validate:e.validate,mask:e.mask??xe,signal:e.signal,input:e.input,output:e.output,render(){const i=e.withGuide??I.withGuide,s=`${i?`${t("gray",d)}
|
|
81
|
+
`:""}${V(this.state)} ${e.message}
|
|
82
|
+
`,r=this.userInputWithCursor,u=this.masked;switch(this.state){case"error":{const n=i?`${t("yellow",d)} `:"",o=i?`${t("yellow",E)} `:"",c=u??"";return e.clearOnError&&this.clear(),`${s.trim()}
|
|
83
|
+
${n}${c}
|
|
84
|
+
${o}${t("yellow",this.error)}
|
|
85
|
+
`}case"submit":{const n=i?`${t("gray",d)} `:"",o=u?t("dim",u):"";return`${s}${n}${o}`}case"cancel":{const n=i?`${t("gray",d)} `:"",o=u?t(["strikethrough","dim"],u):"";return`${s}${n}${o}${u&&i?`
|
|
86
|
+
${t("gray",d)}`:""}`}default:{const n=i?`${t("cyan",d)} `:"",o=i?t("cyan",E):"";return`${s}${n}${r}
|
|
87
|
+
${o}
|
|
88
|
+
`}}}}).prompt(),St=e=>{const i=e.validate;return Ae({...e,initialUserInput:e.initialValue??e.root??process.cwd(),maxItems:5,validate(s){if(!Array.isArray(s)){if(!s)return"Please select a path";if(i)return i(s)}},options(){const s=this.userInput;if(s==="")return[];try{let r;Xe(s)?we(s).isDirectory()&&(!e.directory||s.endsWith("/"))?r=s:r=be(s):r=be(s);const u=s.length>1&&s.endsWith("/")?s.slice(0,-1):s;return ze(r).map(n=>{const o=Qe(r,n),c=we(o);return{name:n,path:o,isDirectory:c.isDirectory()}}).filter(({path:n,isDirectory:o})=>n.startsWith(u)&&(o||!e.directory)).map(n=>({value:n.path}))}catch{return[]}}})},Ct=e=>t("magenta",e),fe=({indicator:e="dots",onCancel:i,output:s=process.stdout,cancelMessage:r,errorMessage:u,frames:n=ee?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=ee?80:120,signal:c,...a}={})=>{const l=ae();let $,y,p=!1,m=!1,g="",S,h=performance.now();const f=X(s),v=a?.styleFrame??Ct,T=_=>{const A=_>1?u??I.messages.error:r??I.messages.cancel;m=_===1,p&&(W(A,_),m&&typeof i=="function"&&i())},C=()=>T(2),b=()=>T(1),x=()=>{process.on("uncaughtExceptionMonitor",C),process.on("unhandledRejection",C),process.on("SIGINT",b),process.on("SIGTERM",b),process.on("exit",T),c&&c.addEventListener("abort",b)},G=()=>{process.removeListener("uncaughtExceptionMonitor",C),process.removeListener("unhandledRejection",C),process.removeListener("SIGINT",b),process.removeListener("SIGTERM",b),process.removeListener("exit",T),c&&c.removeEventListener("abort",b)},M=()=>{if(S===void 0)return;l&&s.write(`
|
|
89
|
+
`);const _=q(S,f,{hard:!0,trim:!1}).split(`
|
|
90
|
+
`);_.length>1&&s.write(Se.up(_.length-1)),s.write(Se.to(0)),s.write(Ce.down())},R=_=>_.replace(/\.+$/,""),j=_=>{const A=(performance.now()-_)/1e3,k=Math.floor(A/60),L=Math.floor(A%60);return k>0?`[${k}m ${L}s]`:`[${L}s]`},D=a.withGuide??I.withGuide,ie=(_="")=>{p=!0,$=Ke({output:s}),g=R(_),h=performance.now(),D&&s.write(`${t("gray",d)}
|
|
91
|
+
`);let A=0,k=0;x(),y=setInterval(()=>{if(l&&g===S)return;M(),S=g;const L=v(n[A]);let Z;if(l)Z=`${L} ${g}...`;else if(e==="timer")Z=`${L} ${g} ${j(h)}`;else{const Be=".".repeat(Math.floor(k)).slice(0,3);Z=`${L} ${g}${Be}`}const Ne=q(Z,f,{hard:!0,trim:!1});s.write(Ne),A=A+1<n.length?A+1:0,k=k<4?k+.125:0},o)},W=(_="",A=0,k=!1)=>{if(!p)return;p=!1,clearInterval(y),M();const L=A===0?t("green",F):A===1?t("red",oe):t("red",ue);g=_??g,k||(e==="timer"?s.write(`${L} ${g} ${j(h)}
|
|
92
|
+
`):s.write(`${L} ${g}
|
|
93
|
+
`)),G(),$()};return{start:ie,stop:(_="")=>W(_,0),message:(_="")=>{g=R(_??g)},cancel:(_="")=>W(_,1),error:(_="")=>W(_,2),clear:()=>W("",0,!0),get isCancelled(){return m}}},Ve={light:w("\u2500","-"),heavy:w("\u2501","="),block:w("\u2588","#")};function Tt({style:e="heavy",max:i=100,size:s=40,...r}={}){const u=fe(r);let n=0,o="";const c=Math.max(1,i),a=Math.max(1,s),l=m=>{switch(m){case"initial":case"active":return g=>t("magenta",g);case"error":case"cancel":return g=>t("red",g);case"submit":return g=>t("green",g);default:return g=>t("magenta",g)}},$=(m,g)=>{const S=Math.floor(n/c*a);return`${l(m)(Ve[e].repeat(S))}${t("dim",Ve[e].repeat(a-S))} ${g}`},y=(m="")=>{o=m,u.start($("initial",m))},p=(m=1,g)=>{n=Math.min(c,m+n),u.message($("active",g??o)),o=g??o};return{start:y,stop:u.stop,cancel:u.cancel,error:u.error,clear:u.clear,advance:p,isCancelled:u.isCancelled,message:m=>p(0,m)}}const re=(e,i)=>e.includes(`
|
|
94
|
+
`)?e.split(`
|
|
95
|
+
`).map(s=>i(s)).join(`
|
|
96
|
+
`):i(e),_t=e=>{const i=(s,r)=>{const u=s.label??String(s.value);switch(r){case"disabled":return`${t("gray",H)} ${re(u,n=>t("gray",n))}${s.hint?` ${t("dim",`(${s.hint??"disabled"})`)}`:""}`;case"selected":return`${re(u,n=>t("dim",n))}`;case"active":return`${t("green",z)} ${u}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`;case"cancelled":return`${re(u,n=>t(["strikethrough","dim"],n))}`;default:return`${t("dim",H)} ${re(u,n=>t("dim",n))}`}};return new qe({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const s=e.withGuide??I.withGuide,r=`${V(this.state)} `,u=`${ye(this.state)} `,n=N(e.output,e.message,u,r),o=`${s?`${t("gray",d)}
|
|
97
|
+
`:""}${n}
|
|
98
|
+
`;switch(this.state){case"submit":{const c=s?`${t("gray",d)} `:"",a=N(e.output,i(this.options[this.cursor],"selected"),c);return`${o}${a}`}case"cancel":{const c=s?`${t("gray",d)} `:"",a=N(e.output,i(this.options[this.cursor],"cancelled"),c);return`${o}${a}${s?`
|
|
99
|
+
${t("gray",d)}`:""}`}default:{const c=s?`${t("cyan",d)} `:"",a=s?t("cyan",E):"",l=o.split(`
|
|
100
|
+
`).length,$=s?2:1;return`${o}${c}${Y({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:c.length,rowPadding:l+$,style:(y,p)=>i(y,y.disabled?"disabled":p?"active":"inactive")}).join(`
|
|
101
|
+
${c}`)}
|
|
102
|
+
${a}
|
|
103
|
+
`}}}}).prompt()},It=e=>{const i=(s,r="inactive")=>{const u=s.label??String(s.value);return r==="selected"?`${t("dim",u)}`:r==="cancelled"?`${t(["strikethrough","dim"],u)}`:r==="active"?`${t(["bgCyan","gray"],` ${s.value} `)} ${u}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`:`${t(["gray","bgWhite","inverse"],` ${s.value} `)} ${u}${s.hint?` ${t("dim",`(${s.hint})`)}`:""}`};return new Je({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,caseSensitive:e.caseSensitive,render(){const s=e.withGuide??I.withGuide,r=`${s?`${t("gray",d)}
|
|
104
|
+
`:""}${V(this.state)} ${e.message}
|
|
105
|
+
`;switch(this.state){case"submit":{const u=s?`${t("gray",d)} `:"",n=this.options.find(c=>c.value===this.value)??e.options[0],o=N(e.output,i(n,"selected"),u);return`${r}${o}`}case"cancel":{const u=s?`${t("gray",d)} `:"",n=N(e.output,i(this.options[0],"cancelled"),u);return`${r}${n}${s?`
|
|
106
|
+
${t("gray",d)}`:""}`}default:{const u=s?`${t("cyan",d)} `:"",n=s?t("cyan",E):"",o=this.options.map((c,a)=>N(e.output,i(c,a===this.cursor?"active":"inactive"),u)).join(`
|
|
107
|
+
`);return`${r}${o}
|
|
108
|
+
${n}
|
|
109
|
+
`}}}}).prompt()},je=`${t("gray",d)} `,K={message:async(e,{symbol:i=t("gray",d)}={})=>{process.stdout.write(`${t("gray",d)}
|
|
110
|
+
${i} `);let s=3;for await(let r of e){r=r.replace(/\n/g,`
|
|
111
|
+
${je}`),r.includes(`
|
|
112
|
+
`)&&(s=3+ne(r.slice(r.lastIndexOf(`
|
|
113
|
+
`))).length);const u=ne(r).length;s+u<process.stdout.columns?(s+=u,process.stdout.write(r)):(process.stdout.write(`
|
|
114
|
+
${je}${r.trimStart()}`),s=3+ne(r.trimStart()).length)}process.stdout.write(`
|
|
115
|
+
`)},info:e=>K.message(e,{symbol:t("blue",he)}),success:e=>K.message(e,{symbol:t("green",pe)}),step:e=>K.message(e,{symbol:t("green",F)}),warn:e=>K.message(e,{symbol:t("yellow",me)}),warning:e=>K.warn(e),error:e=>K.message(e,{symbol:t("red",ge)})},Et=async(e,i)=>{for(const s of e){if(s.enabled===!1)continue;const r=fe(i);r.start(s.title);const u=await s.task(r.message);r.stop(u||s.title)}},xt=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),Gt=e=>{const i=e.output??process.stdout,s=X(i),r=t("gray",d),u=e.spacing??1,n=3,o=e.retainLog===!0,c=!ae()&&Te(i);i.write(`${r}
|
|
116
|
+
`),i.write(`${t("green",F)} ${e.title}
|
|
117
|
+
`);for(let h=0;h<u;h++)i.write(`${r}
|
|
118
|
+
`);const a=[{value:"",full:""}];let l=!1;const $=h=>{if(a.length===0)return;let f=0;h&&(f+=u+2);for(const v of a){const{value:T,result:C}=v;let b=C?.message??T;if(b.length===0)continue;C===void 0&&v.header!==void 0&&v.header!==""&&(b+=`
|
|
119
|
+
${v.header}`);const x=b.split(`
|
|
120
|
+
`).reduce((G,M)=>M===""?G+1:G+Math.ceil((M.length+n)/s),0);f+=x}f>0&&(f+=1,i.write(Ce.lines(f)))},y=(h,f,v)=>{const T=v?`${h.full}
|
|
121
|
+
${h.value}`:h.value;h.header!==void 0&&h.header!==""&&O.message(h.header.split(`
|
|
122
|
+
`).map(C=>t("bold",C)),{output:i,secondarySymbol:r,symbol:r,spacing:0}),O.message(T.split(`
|
|
123
|
+
`).map(C=>t("dim",C)),{output:i,secondarySymbol:r,symbol:r,spacing:f??u})},p=()=>{for(const h of a){const{header:f,value:v,full:T}=h;(f===void 0||f.length===0)&&v.length===0||y(h,void 0,o===!0&&T.length>0)}},m=(h,f,v)=>{if($(!1),(v?.raw!==!0||!l)&&h.value!==""&&(h.value+=`
|
|
124
|
+
`),h.value+=xt(f),l=v?.raw===!0,e.limit!==void 0){const T=h.value.split(`
|
|
125
|
+
`),C=T.length-e.limit;if(C>0){const b=T.splice(0,C);o&&(h.full+=(h.full===""?"":`
|
|
126
|
+
`)+b.join(`
|
|
127
|
+
`))}h.value=T.join(`
|
|
128
|
+
`)}c&&g()},g=()=>{for(const h of a)h.result?h.result.status==="error"?O.error(h.result.message,{output:i,secondarySymbol:r,spacing:0}):O.success(h.result.message,{output:i,secondarySymbol:r,spacing:0}):h.value!==""&&y(h,0)},S=(h,f)=>{$(!1),h.result=f,c&&g()};return{message(h,f){m(a[0],h,f)},group(h){const f={header:h,value:"",full:""};return a.push(f),{message(v,T){m(f,v,T)},error(v){S(f,{status:"error",message:v})},success(v){S(f,{status:"success",message:v})}}},error(h,f){$(!0),O.error(h,{output:i,secondarySymbol:r,spacing:1}),f?.showLog!==!1&&p(),a.splice(1,a.length-1),a[0].value="",a[0].full=""},success(h,f){$(!0),O.success(h,{output:i,secondarySymbol:r,spacing:1}),f?.showLog===!0&&p(),a.splice(1,a.length-1),a[0].value="",a[0].full=""}}},Ot=e=>new Ye({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){const i=e?.withGuide??I.withGuide,s=`${`${i?`${t("gray",d)}
|
|
129
|
+
`:""}${V(this.state)} `}${e.message}
|
|
130
|
+
`,r=e.placeholder?t("inverse",e.placeholder[0])+t("dim",e.placeholder.slice(1)):t(["inverse","hidden"],"_"),u=this.userInput?this.userInputWithCursor:r,n=this.value??"";switch(this.state){case"error":{const o=this.error?` ${t("yellow",this.error)}`:"",c=i?`${t("yellow",d)} `:"",a=i?t("yellow",E):"";return`${s.trim()}
|
|
131
|
+
${c}${u}
|
|
132
|
+
${a}${o}
|
|
133
|
+
`}case"submit":{const o=n?` ${t("dim",n)}`:"",c=i?t("gray",d):"";return`${s}${c}${o}`}case"cancel":{const o=n?` ${t(["strikethrough","dim"],n)}`:"",c=i?t("gray",d):"";return`${s}${c}${o}${n.trim()?`
|
|
134
|
+
${c}`:""}`}default:{const o=i?`${t("cyan",d)} `:"",c=i?t("cyan",E):"";return`${s}${o}${u}
|
|
135
|
+
${c}
|
|
136
|
+
`}}}}).prompt();export{d as S_BAR,E as S_BAR_END,Ee as S_BAR_END_RIGHT,se as S_BAR_H,le as S_BAR_START,Ie as S_BAR_START_RIGHT,te as S_CHECKBOX_ACTIVE,J as S_CHECKBOX_INACTIVE,U as S_CHECKBOX_SELECTED,Ge as S_CONNECT_LEFT,de as S_CORNER_BOTTOM_LEFT,$e as S_CORNER_BOTTOM_RIGHT,Oe as S_CORNER_TOP_LEFT,ce as S_CORNER_TOP_RIGHT,ge as S_ERROR,he as S_INFO,xe as S_PASSWORD_MASK,z as S_RADIO_ACTIVE,H as S_RADIO_INACTIVE,_e as S_STEP_ACTIVE,oe as S_STEP_CANCEL,ue as S_STEP_ERROR,F as S_STEP_SUBMIT,pe as S_SUCCESS,me as S_WARN,Ae as autocomplete,st as autocompleteMultiselect,at as box,pt as cancel,ot as confirm,ut as date,dt as group,ht as groupMultiselect,mt as intro,ae as isCI,Te as isTTY,Y as limitOptions,O as log,yt as multiselect,wt as note,gt as outro,bt as password,St as path,Tt as progress,_t as select,It as selectKey,fe as spinner,K as stream,V as symbol,ye as symbolBar,Gt as taskLog,Et as tasks,Ot as text,ee as unicode,w as unicodeOr};
|
|
137
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clack/prompts",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.mjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.mts",
|
|
10
|
+
"default": "./dist/index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/bombshell-dev/clack.git",
|
|
18
|
+
"directory": "packages/prompts"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/bombshell-dev/clack/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/bombshell-dev/clack/tree/main/packages/prompts#readme",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"CHANGELOG.md"
|
|
27
|
+
],
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Nate Moore",
|
|
30
|
+
"email": "nate@natemoo.re",
|
|
31
|
+
"url": "https://twitter.com/n_moore"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"ask",
|
|
36
|
+
"clack",
|
|
37
|
+
"cli",
|
|
38
|
+
"command-line",
|
|
39
|
+
"command",
|
|
40
|
+
"input",
|
|
41
|
+
"interact",
|
|
42
|
+
"interface",
|
|
43
|
+
"menu",
|
|
44
|
+
"prompt",
|
|
45
|
+
"prompts",
|
|
46
|
+
"stdin",
|
|
47
|
+
"ui"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"fast-string-width": "^1.1.0",
|
|
51
|
+
"fast-wrap-ansi": "^0.1.3",
|
|
52
|
+
"sisteransi": "^1.0.5",
|
|
53
|
+
"@clack/core": "1.2.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"is-unicode-supported": "^1.3.0",
|
|
57
|
+
"memfs": "^4.17.2",
|
|
58
|
+
"vitest": "^3.2.4",
|
|
59
|
+
"vitest-ansi-serializer": "^0.1.2"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "unbuild",
|
|
63
|
+
"test": "vitest run"
|
|
64
|
+
}
|
|
65
|
+
}
|