@juiceboxcreative/loop 0.0.0-stage → 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.
@@ -0,0 +1,250 @@
1
+ import { __toESM } from "../../rolldown-runtime.mjs";
2
+ import { LD, MD, RD, dD, fD, require_picocolors, require_src } from "./core.mjs";
3
+ import y from "node:process";
4
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
5
+ var import_src = require_src();
6
+ function ce() {
7
+ return y.platform !== "win32" ? y.env.TERM !== "linux" : !!y.env.CI || !!y.env.WT_SESSION || !!y.env.TERMINUS_SUBLIME || y.env.ConEmuTask === "{cmd::Cmder}" || y.env.TERM_PROGRAM === "Terminus-Sublime" || y.env.TERM_PROGRAM === "vscode" || y.env.TERM === "xterm-256color" || y.env.TERM === "alacritty" || y.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
8
+ }
9
+ const V = ce();
10
+ const u = (t, n) => V ? t : n;
11
+ const le = u("◆", "*");
12
+ const L = u("■", "x");
13
+ const W = u("▲", "x");
14
+ const C = u("◇", "o");
15
+ const ue = u("┌", "T");
16
+ const o = u("│", "|");
17
+ const d = u("└", "—");
18
+ const k = u("●", ">");
19
+ const P = u("○", " ");
20
+ const $e = u("▪", "•");
21
+ const q = u("●", "•");
22
+ const D = u("◆", "*");
23
+ const U = u("▲", "!");
24
+ const K = u("■", "x");
25
+ const b = (t) => {
26
+ switch (t) {
27
+ case "initial":
28
+ case "active": return import_picocolors.default.cyan(le);
29
+ case "cancel": return import_picocolors.default.red(L);
30
+ case "error": return import_picocolors.default.yellow(W);
31
+ case "submit": return import_picocolors.default.green(C);
32
+ }
33
+ };
34
+ const G = (t) => {
35
+ const { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
36
+ let l = 0;
37
+ n >= l + a - 3 ? l = Math.max(Math.min(n - a + 3, r.length - a), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
38
+ const $ = a < r.length && l > 0, g = a < r.length && l + a < r.length;
39
+ return r.slice(l, l + a).map((p, v, f) => {
40
+ const j = v === 0 && $, E = v === f.length - 1 && g;
41
+ return j || E ? import_picocolors.default.dim("...") : i(p, v + l === n);
42
+ });
43
+ };
44
+ const he = (t) => new RD({
45
+ validate: t.validate,
46
+ placeholder: t.placeholder,
47
+ defaultValue: t.defaultValue,
48
+ initialValue: t.initialValue,
49
+ render() {
50
+ const n = `${import_picocolors.default.gray(o)}
51
+ ${b(this.state)} ${t.message}
52
+ `, r = t.placeholder ? import_picocolors.default.inverse(t.placeholder[0]) + import_picocolors.default.dim(t.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), i = this.value ? this.valueWithCursor : r;
53
+ switch (this.state) {
54
+ case "error": return `${n.trim()}
55
+ ${import_picocolors.default.yellow(o)} ${i}
56
+ ${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
57
+ `;
58
+ case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(this.value || t.placeholder)}`;
59
+ case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(this.value ?? ""))}${this.value?.trim() ? `
60
+ ${import_picocolors.default.gray(o)}` : ""}`;
61
+ default: return `${n}${import_picocolors.default.cyan(o)} ${i}
62
+ ${import_picocolors.default.cyan(d)}
63
+ `;
64
+ }
65
+ }
66
+ }).prompt();
67
+ const ge = (t) => new MD({
68
+ validate: t.validate,
69
+ mask: t.mask ?? $e,
70
+ render() {
71
+ const n = `${import_picocolors.default.gray(o)}
72
+ ${b(this.state)} ${t.message}
73
+ `, r = this.valueWithCursor, i = this.masked;
74
+ switch (this.state) {
75
+ case "error": return `${n.trim()}
76
+ ${import_picocolors.default.yellow(o)} ${i}
77
+ ${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
78
+ `;
79
+ case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(i)}`;
80
+ case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i ?? ""))}${i ? `
81
+ ${import_picocolors.default.gray(o)}` : ""}`;
82
+ default: return `${n}${import_picocolors.default.cyan(o)} ${r}
83
+ ${import_picocolors.default.cyan(d)}
84
+ `;
85
+ }
86
+ }
87
+ }).prompt();
88
+ const ye = (t) => {
89
+ const n = t.active ?? "Yes", r = t.inactive ?? "No";
90
+ return new dD({
91
+ active: n,
92
+ inactive: r,
93
+ initialValue: t.initialValue ?? !0,
94
+ render() {
95
+ const i = `${import_picocolors.default.gray(o)}
96
+ ${b(this.state)} ${t.message}
97
+ `, s = this.value ? n : r;
98
+ switch (this.state) {
99
+ case "submit": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(s)}`;
100
+ case "cancel": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}
101
+ ${import_picocolors.default.gray(o)}`;
102
+ default: return `${i}${import_picocolors.default.cyan(o)} ${this.value ? `${import_picocolors.default.green(k)} ${n}` : `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(n)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(r)}` : `${import_picocolors.default.green(k)} ${r}`}
103
+ ${import_picocolors.default.cyan(d)}
104
+ `;
105
+ }
106
+ }
107
+ }).prompt();
108
+ };
109
+ const ve = (t) => {
110
+ const n = (r, i) => {
111
+ const s = r.label ?? String(r.value);
112
+ switch (i) {
113
+ case "selected": return `${import_picocolors.default.dim(s)}`;
114
+ case "active": return `${import_picocolors.default.green(k)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}`;
115
+ case "cancelled": return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
116
+ default: return `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(s)}`;
117
+ }
118
+ };
119
+ return new LD({
120
+ options: t.options,
121
+ initialValue: t.initialValue,
122
+ render() {
123
+ const r = `${import_picocolors.default.gray(o)}
124
+ ${b(this.state)} ${t.message}
125
+ `;
126
+ switch (this.state) {
127
+ case "submit": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
128
+ case "cancel": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
129
+ ${import_picocolors.default.gray(o)}`;
130
+ default: return `${r}${import_picocolors.default.cyan(o)} ${G({
131
+ cursor: this.cursor,
132
+ options: this.options,
133
+ maxItems: t.maxItems,
134
+ style: (i, s) => n(i, s ? "active" : "inactive")
135
+ }).join(`
136
+ ${import_picocolors.default.cyan(o)} `)}
137
+ ${import_picocolors.default.cyan(d)}
138
+ `;
139
+ }
140
+ }
141
+ }).prompt();
142
+ };
143
+ const xe = (t = "") => {
144
+ process.stdout.write(`${import_picocolors.default.gray(d)} ${import_picocolors.default.red(t)}
145
+
146
+ `);
147
+ };
148
+ const Ie = (t = "") => {
149
+ process.stdout.write(`${import_picocolors.default.gray(ue)} ${t}
150
+ `);
151
+ };
152
+ const Se = (t = "") => {
153
+ process.stdout.write(`${import_picocolors.default.gray(o)}
154
+ ${import_picocolors.default.gray(d)} ${t}
155
+
156
+ `);
157
+ };
158
+ const M = {
159
+ message: (t = "", { symbol: n = import_picocolors.default.gray(o) } = {}) => {
160
+ const r = [`${import_picocolors.default.gray(o)}`];
161
+ if (t) {
162
+ const [i, ...s] = t.split(`
163
+ `);
164
+ r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors.default.gray(o)} ${c}`));
165
+ }
166
+ process.stdout.write(`${r.join(`
167
+ `)}
168
+ `);
169
+ },
170
+ info: (t) => {
171
+ M.message(t, { symbol: import_picocolors.default.blue(q) });
172
+ },
173
+ success: (t) => {
174
+ M.message(t, { symbol: import_picocolors.default.green(D) });
175
+ },
176
+ step: (t) => {
177
+ M.message(t, { symbol: import_picocolors.default.green(C) });
178
+ },
179
+ warn: (t) => {
180
+ M.message(t, { symbol: import_picocolors.default.yellow(U) });
181
+ },
182
+ warning: (t) => {
183
+ M.warn(t);
184
+ },
185
+ error: (t) => {
186
+ M.message(t, { symbol: import_picocolors.default.red(K) });
187
+ }
188
+ };
189
+ `${import_picocolors.default.gray(o)}`;
190
+ const Y = ({ indicator: t = "dots" } = {}) => {
191
+ const n = V ? [
192
+ "◒",
193
+ "◐",
194
+ "◓",
195
+ "◑"
196
+ ] : [
197
+ "•",
198
+ "o",
199
+ "O",
200
+ "0"
201
+ ], r = V ? 80 : 120, i = process.env.CI === "true";
202
+ let s, c, a = !1, l = "", $, g = performance.now();
203
+ const p = (m) => {
204
+ a && N(m > 1 ? "Something went wrong" : "Canceled", m);
205
+ }, v = () => p(2), f = () => p(1), j = () => {
206
+ process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p);
207
+ }, E = () => {
208
+ process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p);
209
+ }, B = () => {
210
+ if ($ === void 0) return;
211
+ i && process.stdout.write(`
212
+ `);
213
+ const m = $.split(`
214
+ `);
215
+ process.stdout.write(import_src.cursor.move(-999, m.length - 1)), process.stdout.write(import_src.erase.down(m.length));
216
+ }, R = (m) => m.replace(/\.+$/, ""), O = (m) => {
217
+ const h = (performance.now() - m) / 1e3, w = Math.floor(h / 60), I = Math.floor(h % 60);
218
+ return w > 0 ? `[${w}m ${I}s]` : `[${I}s]`;
219
+ }, H = (m = "") => {
220
+ a = !0, s = fD(), l = R(m), g = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
221
+ `);
222
+ let h = 0, w = 0;
223
+ j(), c = setInterval(() => {
224
+ if (i && l === $) return;
225
+ B(), $ = l;
226
+ const I = import_picocolors.default.magenta(n[h]);
227
+ if (i) process.stdout.write(`${I} ${l}...`);
228
+ else if (t === "timer") process.stdout.write(`${I} ${l} ${O(g)}`);
229
+ else {
230
+ const z = ".".repeat(Math.floor(w)).slice(0, 3);
231
+ process.stdout.write(`${I} ${l}${z}`);
232
+ }
233
+ h = h + 1 < n.length ? h + 1 : 0, w = w < n.length ? w + .125 : 0;
234
+ }, r);
235
+ }, N = (m = "", h = 0) => {
236
+ a = !1, clearInterval(c), B();
237
+ const w = h === 0 ? import_picocolors.default.green(C) : h === 1 ? import_picocolors.default.red(L) : import_picocolors.default.red(W);
238
+ l = R(m ?? l), t === "timer" ? process.stdout.write(`${w} ${l} ${O(g)}
239
+ `) : process.stdout.write(`${w} ${l}
240
+ `), E(), s();
241
+ };
242
+ return {
243
+ start: H,
244
+ stop: N,
245
+ message: (m = "") => {
246
+ l = R(m ?? l);
247
+ }
248
+ };
249
+ };
250
+ export { Ie, M, Se, Y, ge, he, ve, xe, ye };
@@ -0,0 +1,22 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ export { __commonJSMin, __toESM };
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export {}