convoker 0.3.2 → 0.3.4

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.
Files changed (50) hide show
  1. package/dist/chunk-z5eko27R.mjs +13 -0
  2. package/dist/color-BuHvMolk.d.mts +158 -0
  3. package/dist/color-OlJQTTxb.mjs +172 -0
  4. package/dist/color.d.mts +2 -0
  5. package/dist/color.mjs +4 -0
  6. package/dist/command-BXmfoT-l.d.mts +331 -0
  7. package/dist/command-D2UiQBNA.mjs +583 -0
  8. package/dist/command.d.mts +5 -0
  9. package/dist/command.mjs +10 -0
  10. package/dist/error-C1S1gs8L.mjs +115 -0
  11. package/dist/error.d.mts +5 -0
  12. package/dist/error.mjs +3 -0
  13. package/dist/index-Dikc5KAP.d.mts +199 -0
  14. package/dist/index.d.mts +73 -0
  15. package/dist/index.mjs +10 -0
  16. package/dist/input-B12iaqb8.d.mts +187 -0
  17. package/dist/input-DRy_sVxZ.mjs +174 -0
  18. package/dist/input.d.mts +3 -0
  19. package/dist/input.mjs +5 -0
  20. package/dist/prompt/index.d.mts +5 -0
  21. package/dist/prompt/index.mjs +8 -0
  22. package/dist/prompt/raw.d.mts +2 -0
  23. package/dist/prompt/raw.mjs +4 -0
  24. package/dist/prompt-Cvufljin.mjs +248 -0
  25. package/dist/raw--889icsd.mjs +105 -0
  26. package/dist/raw-BqvlveTU.d.mts +37 -0
  27. package/dist/standard-schema-DBXbMy6L.mjs +17 -0
  28. package/dist/standard-schema-DLeKaehR.d.mts +58 -0
  29. package/dist/utils-ChmY93uA.mjs +45 -0
  30. package/package.json +24 -19
  31. package/dist/color.d.ts +0 -153
  32. package/dist/color.js +0 -143
  33. package/dist/command.d.ts +0 -218
  34. package/dist/command.js +0 -531
  35. package/dist/error.d.ts +0 -107
  36. package/dist/error.js +0 -100
  37. package/dist/index.d.ts +0 -6
  38. package/dist/index.js +0 -6
  39. package/dist/input.d.ts +0 -182
  40. package/dist/input.js +0 -185
  41. package/dist/log.d.ts +0 -61
  42. package/dist/log.js +0 -216
  43. package/dist/prompt/index.d.ts +0 -193
  44. package/dist/prompt/index.js +0 -273
  45. package/dist/prompt/raw.d.ts +0 -32
  46. package/dist/prompt/raw.js +0 -105
  47. package/dist/standard-schema.d.ts +0 -62
  48. package/dist/standard-schema.js +0 -16
  49. package/dist/utils.d.ts +0 -30
  50. package/dist/utils.js +0 -56
@@ -1,105 +0,0 @@
1
- import { isDeno } from "../utils";
2
- /**
3
- * Reads a line from standard input.
4
- * @param message The message.
5
- * @param def Default value.
6
- * @param opts Options for reading a line.
7
- * @returns The line that was read.
8
- */
9
- export async function readLine(message = "", def, opts) {
10
- // Deno
11
- if (isDeno) {
12
- await Deno.stdout.write(new TextEncoder().encode(message));
13
- const decoder = new TextDecoder();
14
- const buf = new Uint8Array(1024);
15
- let input = "";
16
- while (true) {
17
- const n = await Deno.stdin.read(buf);
18
- if (!n)
19
- break;
20
- const chunk = decoder.decode(buf.subarray(0, n));
21
- if (chunk.includes("\n")) {
22
- input += chunk.split("\n")[0];
23
- break;
24
- }
25
- input += chunk;
26
- }
27
- return input.trim() || def || "";
28
- }
29
- // Node / Bun
30
- const readline = await import("node:readline");
31
- return new Promise((resolve) => {
32
- const rl = readline.createInterface({
33
- input: process.stdin,
34
- output: process.stdout,
35
- terminal: true,
36
- });
37
- if (opts?.masked) {
38
- const write = rl._writeToOutput.bind(rl);
39
- rl._writeToOutput = (str) => {
40
- if (str.match(/^\x1b/))
41
- return write(str);
42
- if (str.endsWith("\n") || str.endsWith("\r"))
43
- return write(str);
44
- const mask = opts.maskChar ?? "*";
45
- write(mask.repeat(str.length));
46
- };
47
- }
48
- rl.question(message, (answer) => {
49
- rl.close();
50
- resolve(answer || def || "");
51
- });
52
- });
53
- }
54
- /**
55
- * Reads a single key from stdin.
56
- * @returns The key that was read.
57
- */
58
- export async function readKey() {
59
- return new Promise((resolve) => {
60
- const stdin = process.stdin;
61
- stdin.setRawMode(true);
62
- stdin.resume();
63
- stdin.once("data", (data) => {
64
- const s = data.toString();
65
- stdin.setRawMode(false);
66
- stdin.pause();
67
- if (s === "\r" || s === "\n")
68
- return resolve("enter");
69
- if (s === " ")
70
- return resolve("space");
71
- if (s === "\u001b[A")
72
- return resolve("up");
73
- if (s === "\u001b[B")
74
- return resolve("down");
75
- if (s === "\u001b[C")
76
- return resolve("right");
77
- if (s === "\u001b[D")
78
- return resolve("left");
79
- return resolve(s);
80
- });
81
- });
82
- }
83
- /**
84
- * Clears `lines` amount of lines.
85
- * @param lines Amount of lines to clear.
86
- */
87
- export function clearLines(lines = 1) {
88
- for (let i = 0; i < lines; i++)
89
- process.stdout.write("\x1b[2K\x1b[1A");
90
- process.stdout.write("\x1b[2K\r");
91
- }
92
- /**
93
- * Moves the cursor up `n` times.
94
- * @param n The amount of steps to move.
95
- */
96
- export function cursorUp(n = 1) {
97
- process.stdout.write(`\x1b[${n}A`);
98
- }
99
- /**
100
- * Moves the cursor down `n` times.
101
- * @param n The amount of steps to move.
102
- */
103
- export function cursorDown(n = 1) {
104
- process.stdout.write(`\x1b[${n}B`);
105
- }
@@ -1,62 +0,0 @@
1
- /** The Standard Schema interface. */
2
- export interface StandardSchemaV1<Input = unknown, Output = Input> {
3
- /** The Standard Schema properties. */
4
- readonly "~standard": StandardSchemaV1.Props<Input, Output>;
5
- }
6
- export declare namespace StandardSchemaV1 {
7
- /** The Standard Schema properties interface. */
8
- interface Props<Input = unknown, Output = Input> {
9
- /** The version number of the standard. */
10
- readonly version: 1;
11
- /** The vendor name of the schema library. */
12
- readonly vendor: string;
13
- /** Validates unknown input values. */
14
- readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
15
- /** Inferred types associated with the schema. */
16
- readonly types?: Types<Input, Output> | undefined;
17
- }
18
- /** The result interface of the validate function. */
19
- type Result<Output> = SuccessResult<Output> | FailureResult;
20
- /** The result interface if validation succeeds. */
21
- interface SuccessResult<Output> {
22
- /** The typed output value. */
23
- readonly value: Output;
24
- /** The non-existent issues. */
25
- readonly issues?: undefined;
26
- }
27
- /** The result interface if validation fails. */
28
- interface FailureResult {
29
- /** The issues of failed validation. */
30
- readonly issues: ReadonlyArray<Issue>;
31
- }
32
- /** The issue interface of the failure output. */
33
- interface Issue {
34
- /** The error message of the issue. */
35
- readonly message: string;
36
- /** The path of the issue, if any. */
37
- readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
38
- }
39
- /** The path segment interface of the issue. */
40
- interface PathSegment {
41
- /** The key representing a path segment. */
42
- readonly key: PropertyKey;
43
- }
44
- /** The Standard Schema types interface. */
45
- interface Types<Input = unknown, Output = Input> {
46
- /** The input type of the schema. */
47
- readonly input: Input;
48
- /** The output type of the schema. */
49
- readonly output: Output;
50
- }
51
- /** Infers the input type of a Standard Schema. */
52
- type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
53
- /** Infers the output type of a Standard Schema. */
54
- type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
55
- }
56
- /**
57
- * Validates a value.
58
- * @param entry The Standard Schema validator.
59
- * @param value The value to validate.
60
- * @returns The validated value.
61
- */
62
- export declare function validate<T extends StandardSchemaV1<any, any>>(entry: T, value: any): Promise<T extends StandardSchemaV1<any, infer Out> ? Out : never>;
@@ -1,16 +0,0 @@
1
- // * https://standardschema.dev * //
2
- import { InputValidationError } from "./error";
3
- /**
4
- * Validates a value.
5
- * @param entry The Standard Schema validator.
6
- * @param value The value to validate.
7
- * @returns The validated value.
8
- */
9
- export async function validate(entry, value) {
10
- const result = await entry["~standard"].validate(value);
11
- if (result.issues) {
12
- const msgs = result.issues.map((i) => i.message);
13
- throw new InputValidationError(msgs);
14
- }
15
- return result.value;
16
- }
package/dist/utils.d.ts DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * If the runtime is Node.js.
3
- */
4
- export declare const isNode: boolean;
5
- /**
6
- * If the runtime is Deno.
7
- */
8
- export declare const isDeno: boolean;
9
- /**
10
- * If the runtime is Bun.
11
- */
12
- export declare const isBun: boolean;
13
- /**
14
- * All TypeScript primitive types.
15
- */
16
- type Primitive = string | number | boolean | symbol | null | undefined | bigint;
17
- /**
18
- * Merges two objects deeply.
19
- */
20
- export type DeepMerge<T, U> = T extends Primitive ? U : U extends Primitive ? U : T extends Array<infer TItem> ? U extends Array<infer UItem> ? Array<DeepMerge<TItem, UItem>> : U : T extends object ? U extends object ? {
21
- [K in keyof T | keyof U]: K extends keyof U ? K extends keyof T ? DeepMerge<T[K], U[K]> : U[K] : K extends keyof T ? T[K] : never;
22
- } : U : U;
23
- /**
24
- * Merges two objects deeply.
25
- * @param source The source object.
26
- * @param target The target object.
27
- * @returns The merged objects.
28
- */
29
- export declare function merge<T, U>(source: T, target: U): DeepMerge<T, U>;
30
- export {};
package/dist/utils.js DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * If the runtime is Node.js.
3
- */
4
- export const isNode = typeof process !== "undefined" &&
5
- process.versions != null &&
6
- process.versions.node != null;
7
- /**
8
- * If the runtime is Deno.
9
- */
10
- export const isDeno = typeof Deno !== "undefined" && typeof Deno.version?.deno === "string";
11
- /**
12
- * If the runtime is Bun.
13
- */
14
- export const isBun = typeof Bun !== "undefined" && typeof Bun.version === "string";
15
- /**
16
- * Checks if a value is a plain object.
17
- * @param value The value to check.
18
- * @returns If the value is a plain object.
19
- */
20
- function isPlainObject(value) {
21
- return (value !== null &&
22
- typeof value === "object" &&
23
- Object.getPrototypeOf(value) === Object.prototype);
24
- }
25
- /**
26
- * Merges two objects deeply.
27
- * @param source The source object.
28
- * @param target The target object.
29
- * @returns The merged objects.
30
- */
31
- export function merge(source, target) {
32
- if (Array.isArray(source) && Array.isArray(target)) {
33
- // Replace arrays
34
- return target;
35
- }
36
- if (isPlainObject(source) && isPlainObject(target)) {
37
- const result = {};
38
- const keys = new Set([...Object.keys(source), ...Object.keys(target)]);
39
- keys.forEach((key) => {
40
- const sourceVal = source[key];
41
- const targetVal = target[key];
42
- if (sourceVal !== undefined && targetVal !== undefined) {
43
- result[key] = merge(sourceVal, targetVal);
44
- }
45
- else if (targetVal !== undefined) {
46
- result[key] = targetVal;
47
- }
48
- else {
49
- result[key] = sourceVal;
50
- }
51
- });
52
- return result;
53
- }
54
- // For class instances or primitives, always use target
55
- return target;
56
- }