@dannote/figma-use 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +219 -0
- package/bin/figma-use.js +21 -0
- package/dist/cli/index.js +4136 -0
- package/dist/proxy/index.js +19451 -0
- package/package.json +59 -0
- package/packages/plugin/dist/main.js +996 -0
- package/packages/plugin/dist/manifest.json +15 -0
- package/packages/plugin/dist/ui.html +78 -0
- package/packages/plugin/dist/ui.js +61 -0
|
@@ -0,0 +1,4136 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
+
var __toCommonJS = (from) => {
|
|
8
|
+
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
if (entry)
|
|
10
|
+
return entry;
|
|
11
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
}));
|
|
17
|
+
__moduleCache.set(from, entry);
|
|
18
|
+
return entry;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, {
|
|
23
|
+
get: all[name],
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
set: (newValue) => all[name] = () => newValue
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
|
+
|
|
31
|
+
// node_modules/.bun/consola@3.4.2/node_modules/consola/dist/chunks/prompt.mjs
|
|
32
|
+
var exports_prompt = {};
|
|
33
|
+
__export(exports_prompt, {
|
|
34
|
+
prompt: () => prompt,
|
|
35
|
+
kCancel: () => kCancel
|
|
36
|
+
});
|
|
37
|
+
import g, { stdin, stdout } from "process";
|
|
38
|
+
import f from "readline";
|
|
39
|
+
import { WriteStream } from "tty";
|
|
40
|
+
function getDefaultExportFromCjs(x) {
|
|
41
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
42
|
+
}
|
|
43
|
+
function requireSrc() {
|
|
44
|
+
if (hasRequiredSrc)
|
|
45
|
+
return src;
|
|
46
|
+
hasRequiredSrc = 1;
|
|
47
|
+
const ESC = "\x1B";
|
|
48
|
+
const CSI = `${ESC}[`;
|
|
49
|
+
const beep = "\x07";
|
|
50
|
+
const cursor = {
|
|
51
|
+
to(x, y) {
|
|
52
|
+
if (!y)
|
|
53
|
+
return `${CSI}${x + 1}G`;
|
|
54
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
55
|
+
},
|
|
56
|
+
move(x, y) {
|
|
57
|
+
let ret = "";
|
|
58
|
+
if (x < 0)
|
|
59
|
+
ret += `${CSI}${-x}D`;
|
|
60
|
+
else if (x > 0)
|
|
61
|
+
ret += `${CSI}${x}C`;
|
|
62
|
+
if (y < 0)
|
|
63
|
+
ret += `${CSI}${-y}A`;
|
|
64
|
+
else if (y > 0)
|
|
65
|
+
ret += `${CSI}${y}B`;
|
|
66
|
+
return ret;
|
|
67
|
+
},
|
|
68
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
69
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
70
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
71
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
72
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
73
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
74
|
+
left: `${CSI}G`,
|
|
75
|
+
hide: `${CSI}?25l`,
|
|
76
|
+
show: `${CSI}?25h`,
|
|
77
|
+
save: `${ESC}7`,
|
|
78
|
+
restore: `${ESC}8`
|
|
79
|
+
};
|
|
80
|
+
const scroll = {
|
|
81
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
82
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
83
|
+
};
|
|
84
|
+
const erase = {
|
|
85
|
+
screen: `${CSI}2J`,
|
|
86
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
87
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
88
|
+
line: `${CSI}2K`,
|
|
89
|
+
lineEnd: `${CSI}K`,
|
|
90
|
+
lineStart: `${CSI}1K`,
|
|
91
|
+
lines(count) {
|
|
92
|
+
let clear = "";
|
|
93
|
+
for (let i = 0;i < count; i++)
|
|
94
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
95
|
+
if (count)
|
|
96
|
+
clear += cursor.left;
|
|
97
|
+
return clear;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
src = { cursor, scroll, erase, beep };
|
|
101
|
+
return src;
|
|
102
|
+
}
|
|
103
|
+
function requirePicocolors() {
|
|
104
|
+
if (hasRequiredPicocolors)
|
|
105
|
+
return picocolors.exports;
|
|
106
|
+
hasRequiredPicocolors = 1;
|
|
107
|
+
let p = process || {}, argv2 = p.argv || [], env2 = p.env || {};
|
|
108
|
+
let isColorSupported2 = !(!!env2.NO_COLOR || argv2.includes("--no-color")) && (!!env2.FORCE_COLOR || argv2.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env2.TERM !== "dumb" || !!env2.CI);
|
|
109
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
110
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
111
|
+
return ~index ? open + replaceClose2(string, close, replace, index) + close : open + string + close;
|
|
112
|
+
};
|
|
113
|
+
let replaceClose2 = (string, close, replace, index) => {
|
|
114
|
+
let result = "", cursor = 0;
|
|
115
|
+
do {
|
|
116
|
+
result += string.substring(cursor, index) + replace;
|
|
117
|
+
cursor = index + close.length;
|
|
118
|
+
index = string.indexOf(close, cursor);
|
|
119
|
+
} while (~index);
|
|
120
|
+
return result + string.substring(cursor);
|
|
121
|
+
};
|
|
122
|
+
let createColors2 = (enabled = isColorSupported2) => {
|
|
123
|
+
let f2 = enabled ? formatter : () => String;
|
|
124
|
+
return {
|
|
125
|
+
isColorSupported: enabled,
|
|
126
|
+
reset: f2("\x1B[0m", "\x1B[0m"),
|
|
127
|
+
bold: f2("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
128
|
+
dim: f2("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
129
|
+
italic: f2("\x1B[3m", "\x1B[23m"),
|
|
130
|
+
underline: f2("\x1B[4m", "\x1B[24m"),
|
|
131
|
+
inverse: f2("\x1B[7m", "\x1B[27m"),
|
|
132
|
+
hidden: f2("\x1B[8m", "\x1B[28m"),
|
|
133
|
+
strikethrough: f2("\x1B[9m", "\x1B[29m"),
|
|
134
|
+
black: f2("\x1B[30m", "\x1B[39m"),
|
|
135
|
+
red: f2("\x1B[31m", "\x1B[39m"),
|
|
136
|
+
green: f2("\x1B[32m", "\x1B[39m"),
|
|
137
|
+
yellow: f2("\x1B[33m", "\x1B[39m"),
|
|
138
|
+
blue: f2("\x1B[34m", "\x1B[39m"),
|
|
139
|
+
magenta: f2("\x1B[35m", "\x1B[39m"),
|
|
140
|
+
cyan: f2("\x1B[36m", "\x1B[39m"),
|
|
141
|
+
white: f2("\x1B[37m", "\x1B[39m"),
|
|
142
|
+
gray: f2("\x1B[90m", "\x1B[39m"),
|
|
143
|
+
bgBlack: f2("\x1B[40m", "\x1B[49m"),
|
|
144
|
+
bgRed: f2("\x1B[41m", "\x1B[49m"),
|
|
145
|
+
bgGreen: f2("\x1B[42m", "\x1B[49m"),
|
|
146
|
+
bgYellow: f2("\x1B[43m", "\x1B[49m"),
|
|
147
|
+
bgBlue: f2("\x1B[44m", "\x1B[49m"),
|
|
148
|
+
bgMagenta: f2("\x1B[45m", "\x1B[49m"),
|
|
149
|
+
bgCyan: f2("\x1B[46m", "\x1B[49m"),
|
|
150
|
+
bgWhite: f2("\x1B[47m", "\x1B[49m"),
|
|
151
|
+
blackBright: f2("\x1B[90m", "\x1B[39m"),
|
|
152
|
+
redBright: f2("\x1B[91m", "\x1B[39m"),
|
|
153
|
+
greenBright: f2("\x1B[92m", "\x1B[39m"),
|
|
154
|
+
yellowBright: f2("\x1B[93m", "\x1B[39m"),
|
|
155
|
+
blueBright: f2("\x1B[94m", "\x1B[39m"),
|
|
156
|
+
magentaBright: f2("\x1B[95m", "\x1B[39m"),
|
|
157
|
+
cyanBright: f2("\x1B[96m", "\x1B[39m"),
|
|
158
|
+
whiteBright: f2("\x1B[97m", "\x1B[39m"),
|
|
159
|
+
bgBlackBright: f2("\x1B[100m", "\x1B[49m"),
|
|
160
|
+
bgRedBright: f2("\x1B[101m", "\x1B[49m"),
|
|
161
|
+
bgGreenBright: f2("\x1B[102m", "\x1B[49m"),
|
|
162
|
+
bgYellowBright: f2("\x1B[103m", "\x1B[49m"),
|
|
163
|
+
bgBlueBright: f2("\x1B[104m", "\x1B[49m"),
|
|
164
|
+
bgMagentaBright: f2("\x1B[105m", "\x1B[49m"),
|
|
165
|
+
bgCyanBright: f2("\x1B[106m", "\x1B[49m"),
|
|
166
|
+
bgWhiteBright: f2("\x1B[107m", "\x1B[49m")
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
picocolors.exports = createColors2();
|
|
170
|
+
picocolors.exports.createColors = createColors2;
|
|
171
|
+
return picocolors.exports;
|
|
172
|
+
}
|
|
173
|
+
function J({ onlyFirst: t = false } = {}) {
|
|
174
|
+
const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
175
|
+
return new RegExp(F, t ? undefined : "g");
|
|
176
|
+
}
|
|
177
|
+
function T$1(t) {
|
|
178
|
+
if (typeof t != "string")
|
|
179
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);
|
|
180
|
+
return t.replace(Q, "");
|
|
181
|
+
}
|
|
182
|
+
function O(t) {
|
|
183
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
184
|
+
}
|
|
185
|
+
function A$1(t, u = {}) {
|
|
186
|
+
if (typeof t != "string" || t.length === 0 || (u = { ambiguousIsNarrow: true, ...u }, t = T$1(t), t.length === 0))
|
|
187
|
+
return 0;
|
|
188
|
+
t = t.replace(FD(), " ");
|
|
189
|
+
const F = u.ambiguousIsNarrow ? 1 : 2;
|
|
190
|
+
let e2 = 0;
|
|
191
|
+
for (const s of t) {
|
|
192
|
+
const i = s.codePointAt(0);
|
|
193
|
+
if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879)
|
|
194
|
+
continue;
|
|
195
|
+
switch (DD.eastAsianWidth(s)) {
|
|
196
|
+
case "F":
|
|
197
|
+
case "W":
|
|
198
|
+
e2 += 2;
|
|
199
|
+
break;
|
|
200
|
+
case "A":
|
|
201
|
+
e2 += F;
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
204
|
+
e2 += 1;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return e2;
|
|
208
|
+
}
|
|
209
|
+
function sD() {
|
|
210
|
+
const t = new Map;
|
|
211
|
+
for (const [u, F] of Object.entries(r)) {
|
|
212
|
+
for (const [e2, s] of Object.entries(F))
|
|
213
|
+
r[e2] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[e2] = r[e2], t.set(s[0], s[1]);
|
|
214
|
+
Object.defineProperty(r, u, { value: F, enumerable: false });
|
|
215
|
+
}
|
|
216
|
+
return Object.defineProperty(r, "codes", { value: t, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = L$1(), r.color.ansi256 = N(), r.color.ansi16m = I(), r.bgColor.ansi = L$1(m), r.bgColor.ansi256 = N(m), r.bgColor.ansi16m = I(m), Object.defineProperties(r, { rgbToAnsi256: { value: (u, F, e2) => u === F && F === e2 ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(e2 / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
|
|
217
|
+
const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
|
|
218
|
+
if (!F)
|
|
219
|
+
return [0, 0, 0];
|
|
220
|
+
let [e2] = F;
|
|
221
|
+
e2.length === 3 && (e2 = [...e2].map((i) => i + i).join(""));
|
|
222
|
+
const s = Number.parseInt(e2, 16);
|
|
223
|
+
return [s >> 16 & 255, s >> 8 & 255, s & 255];
|
|
224
|
+
}, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
|
|
225
|
+
if (u < 8)
|
|
226
|
+
return 30 + u;
|
|
227
|
+
if (u < 16)
|
|
228
|
+
return 90 + (u - 8);
|
|
229
|
+
let F, e2, s;
|
|
230
|
+
if (u >= 232)
|
|
231
|
+
F = ((u - 232) * 10 + 8) / 255, e2 = F, s = F;
|
|
232
|
+
else {
|
|
233
|
+
u -= 16;
|
|
234
|
+
const C = u % 36;
|
|
235
|
+
F = Math.floor(u / 36) / 5, e2 = Math.floor(C / 6) / 5, s = C % 6 / 5;
|
|
236
|
+
}
|
|
237
|
+
const i = Math.max(F, e2, s) * 2;
|
|
238
|
+
if (i === 0)
|
|
239
|
+
return 30;
|
|
240
|
+
let D = 30 + (Math.round(s) << 2 | Math.round(e2) << 1 | Math.round(F));
|
|
241
|
+
return i === 2 && (D += 60), D;
|
|
242
|
+
}, enumerable: false }, rgbToAnsi: { value: (u, F, e2) => r.ansi256ToAnsi(r.rgbToAnsi256(u, F, e2)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
|
|
243
|
+
}
|
|
244
|
+
function G(t, u, F) {
|
|
245
|
+
return String(t).normalize().replace(/\r\n/g, `
|
|
246
|
+
`).split(`
|
|
247
|
+
`).map((e2) => oD(e2, u, F)).join(`
|
|
248
|
+
`);
|
|
249
|
+
}
|
|
250
|
+
function k$1(t, u) {
|
|
251
|
+
if (typeof t == "string")
|
|
252
|
+
return c.aliases.get(t) === u;
|
|
253
|
+
for (const F of t)
|
|
254
|
+
if (F !== undefined && k$1(F, u))
|
|
255
|
+
return true;
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
function lD(t, u) {
|
|
259
|
+
if (t === u)
|
|
260
|
+
return;
|
|
261
|
+
const F = t.split(`
|
|
262
|
+
`), e2 = u.split(`
|
|
263
|
+
`), s = [];
|
|
264
|
+
for (let i = 0;i < Math.max(F.length, e2.length); i++)
|
|
265
|
+
F[i] !== e2[i] && s.push(i);
|
|
266
|
+
return s;
|
|
267
|
+
}
|
|
268
|
+
function d$1(t, u) {
|
|
269
|
+
const F = t;
|
|
270
|
+
F.isTTY && F.setRawMode(u);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
class x {
|
|
274
|
+
constructor(u, F = true) {
|
|
275
|
+
h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", new Map), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
|
|
276
|
+
const { input: e2 = stdin, output: s = stdout, render: i, signal: D, ...C } = u;
|
|
277
|
+
this.opts = C, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = F, this._abortSignal = D, this.input = e2, this.output = s;
|
|
278
|
+
}
|
|
279
|
+
unsubscribe() {
|
|
280
|
+
this._subscribers.clear();
|
|
281
|
+
}
|
|
282
|
+
setSubscriber(u, F) {
|
|
283
|
+
const e2 = this._subscribers.get(u) ?? [];
|
|
284
|
+
e2.push(F), this._subscribers.set(u, e2);
|
|
285
|
+
}
|
|
286
|
+
on(u, F) {
|
|
287
|
+
this.setSubscriber(u, { cb: F });
|
|
288
|
+
}
|
|
289
|
+
once(u, F) {
|
|
290
|
+
this.setSubscriber(u, { cb: F, once: true });
|
|
291
|
+
}
|
|
292
|
+
emit(u, ...F) {
|
|
293
|
+
const e2 = this._subscribers.get(u) ?? [], s = [];
|
|
294
|
+
for (const i of e2)
|
|
295
|
+
i.cb(...F), i.once && s.push(() => e2.splice(e2.indexOf(i), 1));
|
|
296
|
+
for (const i of s)
|
|
297
|
+
i();
|
|
298
|
+
}
|
|
299
|
+
prompt() {
|
|
300
|
+
return new Promise((u, F) => {
|
|
301
|
+
if (this._abortSignal) {
|
|
302
|
+
if (this._abortSignal.aborted)
|
|
303
|
+
return this.state = "cancel", this.close(), u(S);
|
|
304
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
305
|
+
this.state = "cancel", this.close();
|
|
306
|
+
}, { once: true });
|
|
307
|
+
}
|
|
308
|
+
const e2 = new WriteStream(0);
|
|
309
|
+
e2._write = (s, i, D) => {
|
|
310
|
+
this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
|
|
311
|
+
}, this.input.pipe(e2), this.rl = f.createInterface({ input: this.input, output: e2, tabSize: 2, prompt: "", escapeCodeTimeout: 50 }), f.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== undefined && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), d$1(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
312
|
+
this.output.write(srcExports.cursor.show), this.output.off("resize", this.render), d$1(this.input, false), u(this.value);
|
|
313
|
+
}), this.once("cancel", () => {
|
|
314
|
+
this.output.write(srcExports.cursor.show), this.output.off("resize", this.render), d$1(this.input, false), u(S);
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
onKeypress(u, F) {
|
|
319
|
+
if (this.state === "error" && (this.state = "active"), F?.name && (!this._track && c.aliases.has(F.name) && this.emit("cursor", c.aliases.get(F.name)), c.actions.has(F.name) && this.emit("cursor", F.name)), u && (u.toLowerCase() === "y" || u.toLowerCase() === "n") && this.emit("confirm", u.toLowerCase() === "y"), u === "\t" && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u && this.emit("key", u.toLowerCase()), F?.name === "return") {
|
|
320
|
+
if (this.opts.validate) {
|
|
321
|
+
const e2 = this.opts.validate(this.value);
|
|
322
|
+
e2 && (this.error = e2 instanceof Error ? e2.message : e2, this.state = "error", this.rl?.write(this.value));
|
|
323
|
+
}
|
|
324
|
+
this.state !== "error" && (this.state = "submit");
|
|
325
|
+
}
|
|
326
|
+
k$1([u, F?.name, F?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
327
|
+
}
|
|
328
|
+
close() {
|
|
329
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
330
|
+
`), d$1(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
331
|
+
}
|
|
332
|
+
restoreCursor() {
|
|
333
|
+
const u = G(this._prevFrame, process.stdout.columns, { hard: true }).split(`
|
|
334
|
+
`).length - 1;
|
|
335
|
+
this.output.write(srcExports.cursor.move(-999, u * -1));
|
|
336
|
+
}
|
|
337
|
+
render() {
|
|
338
|
+
const u = G(this._render(this) ?? "", process.stdout.columns, { hard: true });
|
|
339
|
+
if (u !== this._prevFrame) {
|
|
340
|
+
if (this.state === "initial")
|
|
341
|
+
this.output.write(srcExports.cursor.hide);
|
|
342
|
+
else {
|
|
343
|
+
const F = lD(this._prevFrame, u);
|
|
344
|
+
if (this.restoreCursor(), F && F?.length === 1) {
|
|
345
|
+
const e2 = F[0];
|
|
346
|
+
this.output.write(srcExports.cursor.move(0, e2)), this.output.write(srcExports.erase.lines(1));
|
|
347
|
+
const s = u.split(`
|
|
348
|
+
`);
|
|
349
|
+
this.output.write(s[e2]), this._prevFrame = u, this.output.write(srcExports.cursor.move(0, s.length - e2 - 1));
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if (F && F?.length > 1) {
|
|
353
|
+
const e2 = F[0];
|
|
354
|
+
this.output.write(srcExports.cursor.move(0, e2)), this.output.write(srcExports.erase.down());
|
|
355
|
+
const s = u.split(`
|
|
356
|
+
`).slice(e2);
|
|
357
|
+
this.output.write(s.join(`
|
|
358
|
+
`)), this._prevFrame = u;
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
this.output.write(srcExports.erase.down());
|
|
362
|
+
}
|
|
363
|
+
this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function ce() {
|
|
368
|
+
return g.platform !== "win32" ? g.env.TERM !== "linux" : !!g.env.CI || !!g.env.WT_SESSION || !!g.env.TERMINUS_SUBLIME || g.env.ConEmuTask === "{cmd::Cmder}" || g.env.TERM_PROGRAM === "Terminus-Sublime" || g.env.TERM_PROGRAM === "vscode" || g.env.TERM === "xterm-256color" || g.env.TERM === "alacritty" || g.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
369
|
+
}
|
|
370
|
+
async function prompt(message, opts = {}) {
|
|
371
|
+
const handleCancel = (value) => {
|
|
372
|
+
if (typeof value !== "symbol" || value.toString() !== "Symbol(clack:cancel)") {
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
switch (opts.cancel) {
|
|
376
|
+
case "reject": {
|
|
377
|
+
const error = new Error("Prompt cancelled.");
|
|
378
|
+
error.name = "ConsolaPromptCancelledError";
|
|
379
|
+
if (Error.captureStackTrace) {
|
|
380
|
+
Error.captureStackTrace(error, prompt);
|
|
381
|
+
}
|
|
382
|
+
throw error;
|
|
383
|
+
}
|
|
384
|
+
case "undefined": {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
case "null": {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
case "symbol": {
|
|
391
|
+
return kCancel;
|
|
392
|
+
}
|
|
393
|
+
default:
|
|
394
|
+
case "default": {
|
|
395
|
+
return opts.default ?? opts.initial;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
if (!opts.type || opts.type === "text") {
|
|
400
|
+
return await he({
|
|
401
|
+
message,
|
|
402
|
+
defaultValue: opts.default,
|
|
403
|
+
placeholder: opts.placeholder,
|
|
404
|
+
initialValue: opts.initial
|
|
405
|
+
}).then(handleCancel);
|
|
406
|
+
}
|
|
407
|
+
if (opts.type === "confirm") {
|
|
408
|
+
return await ye({
|
|
409
|
+
message,
|
|
410
|
+
initialValue: opts.initial
|
|
411
|
+
}).then(handleCancel);
|
|
412
|
+
}
|
|
413
|
+
if (opts.type === "select") {
|
|
414
|
+
return await ve({
|
|
415
|
+
message,
|
|
416
|
+
options: opts.options.map((o2) => typeof o2 === "string" ? { value: o2, label: o2 } : o2),
|
|
417
|
+
initialValue: opts.initial
|
|
418
|
+
}).then(handleCancel);
|
|
419
|
+
}
|
|
420
|
+
if (opts.type === "multiselect") {
|
|
421
|
+
return await fe({
|
|
422
|
+
message,
|
|
423
|
+
options: opts.options.map((o2) => typeof o2 === "string" ? { value: o2, label: o2 } : o2),
|
|
424
|
+
required: opts.required,
|
|
425
|
+
initialValues: opts.initial
|
|
426
|
+
}).then(handleCancel);
|
|
427
|
+
}
|
|
428
|
+
throw new Error(`Unknown prompt type: ${opts.type}`);
|
|
429
|
+
}
|
|
430
|
+
var src, hasRequiredSrc, srcExports, picocolors, hasRequiredPicocolors, picocolorsExports, e, Q, P$1, X, DD, uD = function() {
|
|
431
|
+
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
|
432
|
+
}, FD, m = 10, L$1 = (t = 0) => (u) => `\x1B[${u + t}m`, N = (t = 0) => (u) => `\x1B[${38 + t};5;${u}m`, I = (t = 0) => (u, F, e2) => `\x1B[${38 + t};2;${u};${F};${e2}m`, r, tD, eD, iD, v, CD = 39, w$1 = "\x07", W$1 = "[", rD = "]", R = "m", y, V$1 = (t) => `${v.values().next().value}${W$1}${t}${R}`, z = (t) => `${v.values().next().value}${y}${t}${w$1}`, ED = (t) => t.split(" ").map((u) => A$1(u)), _ = (t, u, F) => {
|
|
433
|
+
const e2 = [...u];
|
|
434
|
+
let s = false, i = false, D = A$1(T$1(t[t.length - 1]));
|
|
435
|
+
for (const [C, o] of e2.entries()) {
|
|
436
|
+
const E = A$1(o);
|
|
437
|
+
if (D + E <= F ? t[t.length - 1] += o : (t.push(o), D = 0), v.has(o) && (s = true, i = e2.slice(C + 1).join("").startsWith(y)), s) {
|
|
438
|
+
i ? o === w$1 && (s = false, i = false) : o === R && (s = false);
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
D += E, D === F && C < e2.length - 1 && (t.push(""), D = 0);
|
|
442
|
+
}
|
|
443
|
+
!D && t[t.length - 1].length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
444
|
+
}, nD = (t) => {
|
|
445
|
+
const u = t.split(" ");
|
|
446
|
+
let F = u.length;
|
|
447
|
+
for (;F > 0 && !(A$1(u[F - 1]) > 0); )
|
|
448
|
+
F--;
|
|
449
|
+
return F === u.length ? t : u.slice(0, F).join(" ") + u.slice(F).join("");
|
|
450
|
+
}, oD = (t, u, F = {}) => {
|
|
451
|
+
if (F.trim !== false && t.trim() === "")
|
|
452
|
+
return "";
|
|
453
|
+
let e2 = "", s, i;
|
|
454
|
+
const D = ED(t);
|
|
455
|
+
let C = [""];
|
|
456
|
+
for (const [E, a] of t.split(" ").entries()) {
|
|
457
|
+
F.trim !== false && (C[C.length - 1] = C[C.length - 1].trimStart());
|
|
458
|
+
let n = A$1(C[C.length - 1]);
|
|
459
|
+
if (E !== 0 && (n >= u && (F.wordWrap === false || F.trim === false) && (C.push(""), n = 0), (n > 0 || F.trim === false) && (C[C.length - 1] += " ", n++)), F.hard && D[E] > u) {
|
|
460
|
+
const B = u - n, p = 1 + Math.floor((D[E] - B - 1) / u);
|
|
461
|
+
Math.floor((D[E] - 1) / u) < p && C.push(""), _(C, a, u);
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
if (n + D[E] > u && n > 0 && D[E] > 0) {
|
|
465
|
+
if (F.wordWrap === false && n < u) {
|
|
466
|
+
_(C, a, u);
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
C.push("");
|
|
470
|
+
}
|
|
471
|
+
if (n + D[E] > u && F.wordWrap === false) {
|
|
472
|
+
_(C, a, u);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
C[C.length - 1] += a;
|
|
476
|
+
}
|
|
477
|
+
F.trim !== false && (C = C.map((E) => nD(E)));
|
|
478
|
+
const o = [...C.join(`
|
|
479
|
+
`)];
|
|
480
|
+
for (const [E, a] of o.entries()) {
|
|
481
|
+
if (e2 += a, v.has(a)) {
|
|
482
|
+
const { groups: B } = new RegExp(`(?:\\${W$1}(?<code>\\d+)m|\\${y}(?<uri>.*)${w$1})`).exec(o.slice(E).join("")) || { groups: {} };
|
|
483
|
+
if (B.code !== undefined) {
|
|
484
|
+
const p = Number.parseFloat(B.code);
|
|
485
|
+
s = p === CD ? undefined : p;
|
|
486
|
+
} else
|
|
487
|
+
B.uri !== undefined && (i = B.uri.length === 0 ? undefined : B.uri);
|
|
488
|
+
}
|
|
489
|
+
const n = iD.codes.get(Number(s));
|
|
490
|
+
o[E + 1] === `
|
|
491
|
+
` ? (i && (e2 += z("")), s && n && (e2 += V$1(n))) : a === `
|
|
492
|
+
` && (s && n && (e2 += V$1(s)), i && (e2 += z(i)));
|
|
493
|
+
}
|
|
494
|
+
return e2;
|
|
495
|
+
}, aD, c, S, AD, pD = (t, u, F) => (u in t) ? AD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F, h = (t, u, F) => (pD(t, typeof u != "symbol" ? u + "" : u, F), F), fD, bD, mD = (t, u, F) => (u in t) ? bD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F, Y = (t, u, F) => (mD(t, typeof u != "symbol" ? u + "" : u, F), F), wD, SD, $D = (t, u, F) => (u in t) ? SD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F, q = (t, u, F) => ($D(t, typeof u != "symbol" ? u + "" : u, F), F), jD, PD, V, u = (t, n) => V ? t : n, le, L, W, C, o, d, k, P, A, T, F, w = (t) => {
|
|
496
|
+
switch (t) {
|
|
497
|
+
case "initial":
|
|
498
|
+
case "active":
|
|
499
|
+
return e.cyan(le);
|
|
500
|
+
case "cancel":
|
|
501
|
+
return e.red(L);
|
|
502
|
+
case "error":
|
|
503
|
+
return e.yellow(W);
|
|
504
|
+
case "submit":
|
|
505
|
+
return e.green(C);
|
|
506
|
+
}
|
|
507
|
+
}, B = (t) => {
|
|
508
|
+
const { cursor: n, options: s, style: r2 } = t, i = t.maxItems ?? Number.POSITIVE_INFINITY, a = Math.max(process.stdout.rows - 4, 0), c2 = Math.min(a, Math.max(i, 5));
|
|
509
|
+
let l = 0;
|
|
510
|
+
n >= l + c2 - 3 ? l = Math.max(Math.min(n - c2 + 3, s.length - c2), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
|
|
511
|
+
const $ = c2 < s.length && l > 0, p = c2 < s.length && l + c2 < s.length;
|
|
512
|
+
return s.slice(l, l + c2).map((M, v2, x2) => {
|
|
513
|
+
const j = v2 === 0 && $, E = v2 === x2.length - 1 && p;
|
|
514
|
+
return j || E ? e.dim("...") : r2(M, v2 + l === n);
|
|
515
|
+
});
|
|
516
|
+
}, he = (t) => new PD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
|
|
517
|
+
const n = `${e.gray(o)}
|
|
518
|
+
${w(this.state)} ${t.message}
|
|
519
|
+
`, s = t.placeholder ? e.inverse(t.placeholder[0]) + e.dim(t.placeholder.slice(1)) : e.inverse(e.hidden("_")), r2 = this.value ? this.valueWithCursor : s;
|
|
520
|
+
switch (this.state) {
|
|
521
|
+
case "error":
|
|
522
|
+
return `${n.trim()}
|
|
523
|
+
${e.yellow(o)} ${r2}
|
|
524
|
+
${e.yellow(d)} ${e.yellow(this.error)}
|
|
525
|
+
`;
|
|
526
|
+
case "submit":
|
|
527
|
+
return `${n}${e.gray(o)} ${e.dim(this.value || t.placeholder)}`;
|
|
528
|
+
case "cancel":
|
|
529
|
+
return `${n}${e.gray(o)} ${e.strikethrough(e.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
530
|
+
${e.gray(o)}` : ""}`;
|
|
531
|
+
default:
|
|
532
|
+
return `${n}${e.cyan(o)} ${r2}
|
|
533
|
+
${e.cyan(d)}
|
|
534
|
+
`;
|
|
535
|
+
}
|
|
536
|
+
} }).prompt(), ye = (t) => {
|
|
537
|
+
const n = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
538
|
+
return new fD({ active: n, inactive: s, initialValue: t.initialValue ?? true, render() {
|
|
539
|
+
const r2 = `${e.gray(o)}
|
|
540
|
+
${w(this.state)} ${t.message}
|
|
541
|
+
`, i = this.value ? n : s;
|
|
542
|
+
switch (this.state) {
|
|
543
|
+
case "submit":
|
|
544
|
+
return `${r2}${e.gray(o)} ${e.dim(i)}`;
|
|
545
|
+
case "cancel":
|
|
546
|
+
return `${r2}${e.gray(o)} ${e.strikethrough(e.dim(i))}
|
|
547
|
+
${e.gray(o)}`;
|
|
548
|
+
default:
|
|
549
|
+
return `${r2}${e.cyan(o)} ${this.value ? `${e.green(k)} ${n}` : `${e.dim(P)} ${e.dim(n)}`} ${e.dim("/")} ${this.value ? `${e.dim(P)} ${e.dim(s)}` : `${e.green(k)} ${s}`}
|
|
550
|
+
${e.cyan(d)}
|
|
551
|
+
`;
|
|
552
|
+
}
|
|
553
|
+
} }).prompt();
|
|
554
|
+
}, ve = (t) => {
|
|
555
|
+
const n = (s, r2) => {
|
|
556
|
+
const i = s.label ?? String(s.value);
|
|
557
|
+
switch (r2) {
|
|
558
|
+
case "selected":
|
|
559
|
+
return `${e.dim(i)}`;
|
|
560
|
+
case "active":
|
|
561
|
+
return `${e.green(k)} ${i} ${s.hint ? e.dim(`(${s.hint})`) : ""}`;
|
|
562
|
+
case "cancelled":
|
|
563
|
+
return `${e.strikethrough(e.dim(i))}`;
|
|
564
|
+
default:
|
|
565
|
+
return `${e.dim(P)} ${e.dim(i)}`;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
return new jD({ options: t.options, initialValue: t.initialValue, render() {
|
|
569
|
+
const s = `${e.gray(o)}
|
|
570
|
+
${w(this.state)} ${t.message}
|
|
571
|
+
`;
|
|
572
|
+
switch (this.state) {
|
|
573
|
+
case "submit":
|
|
574
|
+
return `${s}${e.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
575
|
+
case "cancel":
|
|
576
|
+
return `${s}${e.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
577
|
+
${e.gray(o)}`;
|
|
578
|
+
default:
|
|
579
|
+
return `${s}${e.cyan(o)} ${B({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (r2, i) => n(r2, i ? "active" : "inactive") }).join(`
|
|
580
|
+
${e.cyan(o)} `)}
|
|
581
|
+
${e.cyan(d)}
|
|
582
|
+
`;
|
|
583
|
+
}
|
|
584
|
+
} }).prompt();
|
|
585
|
+
}, fe = (t) => {
|
|
586
|
+
const n = (s, r2) => {
|
|
587
|
+
const i = s.label ?? String(s.value);
|
|
588
|
+
return r2 === "active" ? `${e.cyan(A)} ${i} ${s.hint ? e.dim(`(${s.hint})`) : ""}` : r2 === "selected" ? `${e.green(T)} ${e.dim(i)}` : r2 === "cancelled" ? `${e.strikethrough(e.dim(i))}` : r2 === "active-selected" ? `${e.green(T)} ${i} ${s.hint ? e.dim(`(${s.hint})`) : ""}` : r2 === "submitted" ? `${e.dim(i)}` : `${e.dim(F)} ${e.dim(i)}`;
|
|
589
|
+
};
|
|
590
|
+
return new wD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(s) {
|
|
591
|
+
if (this.required && s.length === 0)
|
|
592
|
+
return `Please select at least one option.
|
|
593
|
+
${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`;
|
|
594
|
+
}, render() {
|
|
595
|
+
const s = `${e.gray(o)}
|
|
596
|
+
${w(this.state)} ${t.message}
|
|
597
|
+
`, r2 = (i, a) => {
|
|
598
|
+
const c2 = this.value.includes(i.value);
|
|
599
|
+
return a && c2 ? n(i, "active-selected") : c2 ? n(i, "selected") : n(i, a ? "active" : "inactive");
|
|
600
|
+
};
|
|
601
|
+
switch (this.state) {
|
|
602
|
+
case "submit":
|
|
603
|
+
return `${s}${e.gray(o)} ${this.options.filter(({ value: i }) => this.value.includes(i)).map((i) => n(i, "submitted")).join(e.dim(", ")) || e.dim("none")}`;
|
|
604
|
+
case "cancel": {
|
|
605
|
+
const i = this.options.filter(({ value: a }) => this.value.includes(a)).map((a) => n(a, "cancelled")).join(e.dim(", "));
|
|
606
|
+
return `${s}${e.gray(o)} ${i.trim() ? `${i}
|
|
607
|
+
${e.gray(o)}` : ""}`;
|
|
608
|
+
}
|
|
609
|
+
case "error": {
|
|
610
|
+
const i = this.error.split(`
|
|
611
|
+
`).map((a, c2) => c2 === 0 ? `${e.yellow(d)} ${e.yellow(a)}` : ` ${a}`).join(`
|
|
612
|
+
`);
|
|
613
|
+
return `${s + e.yellow(o)} ${B({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: r2 }).join(`
|
|
614
|
+
${e.yellow(o)} `)}
|
|
615
|
+
${i}
|
|
616
|
+
`;
|
|
617
|
+
}
|
|
618
|
+
default:
|
|
619
|
+
return `${s}${e.cyan(o)} ${B({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: r2 }).join(`
|
|
620
|
+
${e.cyan(o)} `)}
|
|
621
|
+
${e.cyan(d)}
|
|
622
|
+
`;
|
|
623
|
+
}
|
|
624
|
+
} }).prompt();
|
|
625
|
+
}, kCancel;
|
|
626
|
+
var init_prompt = __esm(() => {
|
|
627
|
+
srcExports = requireSrc();
|
|
628
|
+
picocolors = { exports: {} };
|
|
629
|
+
picocolorsExports = /* @__PURE__ */ requirePicocolors();
|
|
630
|
+
e = /* @__PURE__ */ getDefaultExportFromCjs(picocolorsExports);
|
|
631
|
+
Q = J();
|
|
632
|
+
P$1 = { exports: {} };
|
|
633
|
+
(function(t) {
|
|
634
|
+
var u = {};
|
|
635
|
+
t.exports = u, u.eastAsianWidth = function(e2) {
|
|
636
|
+
var s = e2.charCodeAt(0), i = e2.length == 2 ? e2.charCodeAt(1) : 0, D = s;
|
|
637
|
+
return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D = s << 10 | i, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
|
|
638
|
+
}, u.characterLength = function(e2) {
|
|
639
|
+
var s = this.eastAsianWidth(e2);
|
|
640
|
+
return s == "F" || s == "W" || s == "A" ? 2 : 1;
|
|
641
|
+
};
|
|
642
|
+
function F(e2) {
|
|
643
|
+
return e2.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
|
|
644
|
+
}
|
|
645
|
+
u.length = function(e2) {
|
|
646
|
+
for (var s = F(e2), i = 0, D = 0;D < s.length; D++)
|
|
647
|
+
i = i + this.characterLength(s[D]);
|
|
648
|
+
return i;
|
|
649
|
+
}, u.slice = function(e2, s, i) {
|
|
650
|
+
textLen = u.length(e2), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
|
|
651
|
+
for (var D = "", C = 0, o = F(e2), E = 0;E < o.length; E++) {
|
|
652
|
+
var a = o[E], n = u.length(a);
|
|
653
|
+
if (C >= s - (n == 2 ? 1 : 0))
|
|
654
|
+
if (C + n <= i)
|
|
655
|
+
D += a;
|
|
656
|
+
else
|
|
657
|
+
break;
|
|
658
|
+
C += n;
|
|
659
|
+
}
|
|
660
|
+
return D;
|
|
661
|
+
};
|
|
662
|
+
})(P$1);
|
|
663
|
+
X = P$1.exports;
|
|
664
|
+
DD = O(X);
|
|
665
|
+
FD = O(uD);
|
|
666
|
+
r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
|
|
667
|
+
Object.keys(r.modifier);
|
|
668
|
+
tD = Object.keys(r.color);
|
|
669
|
+
eD = Object.keys(r.bgColor);
|
|
670
|
+
[...tD, ...eD];
|
|
671
|
+
iD = sD();
|
|
672
|
+
v = new Set(["\x1B", "\x9B"]);
|
|
673
|
+
y = `${rD}8;;`;
|
|
674
|
+
aD = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
675
|
+
c = { actions: new Set(aD), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]) };
|
|
676
|
+
globalThis.process.platform.startsWith("win");
|
|
677
|
+
S = Symbol("clack:cancel");
|
|
678
|
+
AD = Object.defineProperty;
|
|
679
|
+
fD = class fD extends x {
|
|
680
|
+
get cursor() {
|
|
681
|
+
return this.value ? 0 : 1;
|
|
682
|
+
}
|
|
683
|
+
get _value() {
|
|
684
|
+
return this.cursor === 0;
|
|
685
|
+
}
|
|
686
|
+
constructor(u) {
|
|
687
|
+
super(u, false), this.value = !!u.initialValue, this.on("value", () => {
|
|
688
|
+
this.value = this._value;
|
|
689
|
+
}), this.on("confirm", (F) => {
|
|
690
|
+
this.output.write(srcExports.cursor.move(0, -1)), this.value = F, this.state = "submit", this.close();
|
|
691
|
+
}), this.on("cursor", () => {
|
|
692
|
+
this.value = !this.value;
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
bD = Object.defineProperty;
|
|
697
|
+
wD = class extends x {
|
|
698
|
+
constructor(u) {
|
|
699
|
+
super(u, false), Y(this, "options"), Y(this, "cursor", 0), this.options = u.options, this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F }) => F === u.cursorAt), 0), this.on("key", (F) => {
|
|
700
|
+
F === "a" && this.toggleAll();
|
|
701
|
+
}), this.on("cursor", (F) => {
|
|
702
|
+
switch (F) {
|
|
703
|
+
case "left":
|
|
704
|
+
case "up":
|
|
705
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
706
|
+
break;
|
|
707
|
+
case "down":
|
|
708
|
+
case "right":
|
|
709
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
710
|
+
break;
|
|
711
|
+
case "space":
|
|
712
|
+
this.toggleValue();
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
get _value() {
|
|
718
|
+
return this.options[this.cursor].value;
|
|
719
|
+
}
|
|
720
|
+
toggleAll() {
|
|
721
|
+
const u = this.value.length === this.options.length;
|
|
722
|
+
this.value = u ? [] : this.options.map((F) => F.value);
|
|
723
|
+
}
|
|
724
|
+
toggleValue() {
|
|
725
|
+
const u = this.value.includes(this._value);
|
|
726
|
+
this.value = u ? this.value.filter((F) => F !== this._value) : [...this.value, this._value];
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
SD = Object.defineProperty;
|
|
730
|
+
jD = class jD extends x {
|
|
731
|
+
constructor(u) {
|
|
732
|
+
super(u, false), q(this, "options"), q(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: F }) => F === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F) => {
|
|
733
|
+
switch (F) {
|
|
734
|
+
case "left":
|
|
735
|
+
case "up":
|
|
736
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
737
|
+
break;
|
|
738
|
+
case "down":
|
|
739
|
+
case "right":
|
|
740
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
this.changeValue();
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
get _value() {
|
|
747
|
+
return this.options[this.cursor];
|
|
748
|
+
}
|
|
749
|
+
changeValue() {
|
|
750
|
+
this.value = this._value.value;
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
PD = class PD extends x {
|
|
754
|
+
get valueWithCursor() {
|
|
755
|
+
if (this.state === "submit")
|
|
756
|
+
return this.value;
|
|
757
|
+
if (this.cursor >= this.value.length)
|
|
758
|
+
return `${this.value}\u2588`;
|
|
759
|
+
const u = this.value.slice(0, this.cursor), [F, ...e$1] = this.value.slice(this.cursor);
|
|
760
|
+
return `${u}${e.inverse(F)}${e$1.join("")}`;
|
|
761
|
+
}
|
|
762
|
+
get cursor() {
|
|
763
|
+
return this._cursor;
|
|
764
|
+
}
|
|
765
|
+
constructor(u) {
|
|
766
|
+
super(u), this.on("finalize", () => {
|
|
767
|
+
this.value || (this.value = u.defaultValue);
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
V = ce();
|
|
772
|
+
le = u("\u276F", ">");
|
|
773
|
+
L = u("\u25A0", "x");
|
|
774
|
+
W = u("\u25B2", "x");
|
|
775
|
+
C = u("\u2714", "\u221A");
|
|
776
|
+
o = u("");
|
|
777
|
+
d = u("");
|
|
778
|
+
k = u("\u25CF", ">");
|
|
779
|
+
P = u("\u25CB", " ");
|
|
780
|
+
A = u("\u25FB", "[\u2022]");
|
|
781
|
+
T = u("\u25FC", "[+]");
|
|
782
|
+
F = u("\u25FB", "[ ]");
|
|
783
|
+
`${e.gray(o)} `;
|
|
784
|
+
kCancel = Symbol.for("cancel");
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
// packages/cli/src/output.ts
|
|
788
|
+
var exports_output = {};
|
|
789
|
+
__export(exports_output, {
|
|
790
|
+
printResult: () => printResult,
|
|
791
|
+
printError: () => printError,
|
|
792
|
+
formatResult: () => formatResult
|
|
793
|
+
});
|
|
794
|
+
function formatColor(color) {
|
|
795
|
+
return color.startsWith("#") ? color : color;
|
|
796
|
+
}
|
|
797
|
+
function formatFills(fills) {
|
|
798
|
+
if (!fills || fills.length === 0)
|
|
799
|
+
return null;
|
|
800
|
+
const solid = fills.find((f3) => f3.type === "SOLID");
|
|
801
|
+
return solid?.color ? formatColor(solid.color) : null;
|
|
802
|
+
}
|
|
803
|
+
function formatStrokes(strokes, weight) {
|
|
804
|
+
if (!strokes || strokes.length === 0)
|
|
805
|
+
return null;
|
|
806
|
+
const solid = strokes.find((f3) => f3.type === "SOLID");
|
|
807
|
+
if (!solid?.color)
|
|
808
|
+
return null;
|
|
809
|
+
return weight ? `${formatColor(solid.color)} ${weight}px` : formatColor(solid.color);
|
|
810
|
+
}
|
|
811
|
+
function formatBox(node) {
|
|
812
|
+
if (node.width === undefined || node.height === undefined)
|
|
813
|
+
return null;
|
|
814
|
+
const size = `${Math.round(node.width)}x${Math.round(node.height)}`;
|
|
815
|
+
if (node.x !== undefined && node.y !== undefined) {
|
|
816
|
+
return `${size} at (${Math.round(node.x)}, ${Math.round(node.y)})`;
|
|
817
|
+
}
|
|
818
|
+
return size;
|
|
819
|
+
}
|
|
820
|
+
function formatNode(node, indent = "") {
|
|
821
|
+
const lines = [];
|
|
822
|
+
const type = TYPE_LABELS[node.type] || node.type?.toLowerCase() || "node";
|
|
823
|
+
const name = node.name || node.characters || "";
|
|
824
|
+
const id = node.id;
|
|
825
|
+
lines.push(`${indent}[${type}] "${name}" (${id})`);
|
|
826
|
+
const details = [];
|
|
827
|
+
const box2 = formatBox(node);
|
|
828
|
+
if (box2)
|
|
829
|
+
details.push(`box: ${box2}`);
|
|
830
|
+
const fill = formatFills(node.fills);
|
|
831
|
+
if (fill)
|
|
832
|
+
details.push(`fill: ${fill}`);
|
|
833
|
+
const stroke = formatStrokes(node.strokes, node.strokeWeight);
|
|
834
|
+
if (stroke)
|
|
835
|
+
details.push(`stroke: ${stroke}`);
|
|
836
|
+
if (node.cornerRadius && node.cornerRadius !== 0) {
|
|
837
|
+
details.push(`radius: ${node.cornerRadius}px`);
|
|
838
|
+
}
|
|
839
|
+
if (node.fontSize) {
|
|
840
|
+
const weight = node.fontWeight || "";
|
|
841
|
+
details.push(`font: ${node.fontSize}px ${weight}`.trim());
|
|
842
|
+
}
|
|
843
|
+
if (node.characters && !name) {
|
|
844
|
+
details.push(`text: "${node.characters}"`);
|
|
845
|
+
}
|
|
846
|
+
if (node.childCount !== undefined && node.childCount > 0) {
|
|
847
|
+
details.push(`children: ${node.childCount}`);
|
|
848
|
+
}
|
|
849
|
+
if (node.layoutMode) {
|
|
850
|
+
details.push(`layout: ${node.layoutMode}`);
|
|
851
|
+
}
|
|
852
|
+
if (node.opacity !== undefined && node.opacity !== 1) {
|
|
853
|
+
details.push(`opacity: ${node.opacity}`);
|
|
854
|
+
}
|
|
855
|
+
for (const detail of details) {
|
|
856
|
+
lines.push(`${indent} ${detail}`);
|
|
857
|
+
}
|
|
858
|
+
return lines.join(`
|
|
859
|
+
`);
|
|
860
|
+
}
|
|
861
|
+
function formatNodeList(nodes) {
|
|
862
|
+
return nodes.map((node, i2) => {
|
|
863
|
+
const type = TYPE_LABELS[node.type] || node.type?.toLowerCase() || "node";
|
|
864
|
+
const name = node.name || node.characters || "";
|
|
865
|
+
const id = node.id;
|
|
866
|
+
const box2 = formatBox(node);
|
|
867
|
+
const details = [];
|
|
868
|
+
if (box2)
|
|
869
|
+
details.push(`box: ${box2}`);
|
|
870
|
+
const fill = formatFills(node.fills);
|
|
871
|
+
if (fill)
|
|
872
|
+
details.push(`fill: ${fill}`);
|
|
873
|
+
const stroke = formatStrokes(node.strokes, node.strokeWeight);
|
|
874
|
+
if (stroke)
|
|
875
|
+
details.push(`stroke: ${stroke}`);
|
|
876
|
+
if (node.cornerRadius && node.cornerRadius !== 0) {
|
|
877
|
+
details.push(`radius: ${node.cornerRadius}px`);
|
|
878
|
+
}
|
|
879
|
+
let line = `[${i2}] ${type} "${name}" (${id})`;
|
|
880
|
+
if (details.length > 0) {
|
|
881
|
+
line += `
|
|
882
|
+
` + details.join(`
|
|
883
|
+
`);
|
|
884
|
+
}
|
|
885
|
+
return line;
|
|
886
|
+
}).join(`
|
|
887
|
+
|
|
888
|
+
`);
|
|
889
|
+
}
|
|
890
|
+
function formatCreated(node, action = "Created") {
|
|
891
|
+
const type = TYPE_LABELS[node.type] || node.type?.toLowerCase() || "node";
|
|
892
|
+
const name = node.name || node.characters || "";
|
|
893
|
+
const lines = [`\x1B[32m\u2713\x1B[0m ${action} ${type} "${name}"`];
|
|
894
|
+
lines.push(` id: ${node.id}`);
|
|
895
|
+
const box2 = formatBox(node);
|
|
896
|
+
if (box2)
|
|
897
|
+
lines.push(` box: ${box2}`);
|
|
898
|
+
const fill = formatFills(node.fills);
|
|
899
|
+
if (fill)
|
|
900
|
+
lines.push(` fill: ${fill}`);
|
|
901
|
+
const stroke = formatStrokes(node.strokes, node.strokeWeight);
|
|
902
|
+
if (stroke)
|
|
903
|
+
lines.push(` stroke: ${stroke}`);
|
|
904
|
+
if (node.cornerRadius && node.cornerRadius !== 0) {
|
|
905
|
+
lines.push(` radius: ${node.cornerRadius}px`);
|
|
906
|
+
}
|
|
907
|
+
if (node.fontSize) {
|
|
908
|
+
lines.push(` font: ${node.fontSize}px`);
|
|
909
|
+
}
|
|
910
|
+
return lines.join(`
|
|
911
|
+
`);
|
|
912
|
+
}
|
|
913
|
+
function formatExport(result) {
|
|
914
|
+
if (result.path) {
|
|
915
|
+
return `\x1B[32m\u2713\x1B[0m Exported to ${result.path}`;
|
|
916
|
+
}
|
|
917
|
+
return "\x1B[32m\u2713\x1B[0m Exported";
|
|
918
|
+
}
|
|
919
|
+
function formatDeleted(result) {
|
|
920
|
+
if (result.deleted) {
|
|
921
|
+
return "\x1B[32m\u2713\x1B[0m Deleted";
|
|
922
|
+
}
|
|
923
|
+
return "\x1B[31m\u2717\x1B[0m Delete failed";
|
|
924
|
+
}
|
|
925
|
+
function formatPages(pages) {
|
|
926
|
+
return pages.map((p, i2) => `[${i2}] "${p.name}" (${p.id})`).join(`
|
|
927
|
+
`);
|
|
928
|
+
}
|
|
929
|
+
function formatStatus(status) {
|
|
930
|
+
if (status.pluginConnected) {
|
|
931
|
+
return "\x1B[32m\u2713\x1B[0m Plugin connected";
|
|
932
|
+
}
|
|
933
|
+
return "\x1B[31m\u2717\x1B[0m Plugin not connected";
|
|
934
|
+
}
|
|
935
|
+
function formatResult(result, context) {
|
|
936
|
+
if (result === null || result === undefined) {
|
|
937
|
+
return "";
|
|
938
|
+
}
|
|
939
|
+
if (typeof result === "string") {
|
|
940
|
+
return result;
|
|
941
|
+
}
|
|
942
|
+
if (Array.isArray(result)) {
|
|
943
|
+
if (result.length === 0)
|
|
944
|
+
return "(empty)";
|
|
945
|
+
if (result[0]?.id && result[0]?.name !== undefined) {
|
|
946
|
+
if (result[0]?.type) {
|
|
947
|
+
return formatNodeList(result);
|
|
948
|
+
}
|
|
949
|
+
return formatPages(result);
|
|
950
|
+
}
|
|
951
|
+
return JSON.stringify(result, null, 2);
|
|
952
|
+
}
|
|
953
|
+
if (typeof result === "object") {
|
|
954
|
+
const obj = result;
|
|
955
|
+
if (obj.deleted !== undefined) {
|
|
956
|
+
return formatDeleted(obj);
|
|
957
|
+
}
|
|
958
|
+
if (context === "export" || obj.path) {
|
|
959
|
+
return formatExport(obj);
|
|
960
|
+
}
|
|
961
|
+
if (obj.pluginConnected !== undefined) {
|
|
962
|
+
return formatStatus(obj);
|
|
963
|
+
}
|
|
964
|
+
if (obj.id && obj.type) {
|
|
965
|
+
if (context === "create") {
|
|
966
|
+
return formatCreated(obj, "Created");
|
|
967
|
+
}
|
|
968
|
+
if (context === "update") {
|
|
969
|
+
return formatCreated(obj, "Updated");
|
|
970
|
+
}
|
|
971
|
+
return formatNode(obj);
|
|
972
|
+
}
|
|
973
|
+
if (obj.id && obj.name && !obj.type) {
|
|
974
|
+
return `[page] "${obj.name}" (${obj.id})`;
|
|
975
|
+
}
|
|
976
|
+
if (obj.center && obj.zoom) {
|
|
977
|
+
return `\x1B[32m\u2713\x1B[0m Zoomed to fit (${(obj.zoom * 100).toFixed(0)}%)`;
|
|
978
|
+
}
|
|
979
|
+
if (obj.selection !== undefined) {
|
|
980
|
+
const sel = obj.selection;
|
|
981
|
+
if (sel.length === 0)
|
|
982
|
+
return "(no selection)";
|
|
983
|
+
return `Selected: ${sel.join(", ")}`;
|
|
984
|
+
}
|
|
985
|
+
return JSON.stringify(obj, null, 2);
|
|
986
|
+
}
|
|
987
|
+
return String(result);
|
|
988
|
+
}
|
|
989
|
+
function printResult(result, jsonMode = false, context) {
|
|
990
|
+
if (jsonMode) {
|
|
991
|
+
console.log(JSON.stringify(result, null, 2));
|
|
992
|
+
} else {
|
|
993
|
+
console.log(formatResult(result, context));
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
function printError(error) {
|
|
997
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
998
|
+
console.error(`\x1B[31m\u2717\x1B[0m ${message}`);
|
|
999
|
+
}
|
|
1000
|
+
var TYPE_LABELS;
|
|
1001
|
+
var init_output = __esm(() => {
|
|
1002
|
+
TYPE_LABELS = {
|
|
1003
|
+
FRAME: "frame",
|
|
1004
|
+
RECTANGLE: "rect",
|
|
1005
|
+
ELLIPSE: "ellipse",
|
|
1006
|
+
TEXT: "text",
|
|
1007
|
+
COMPONENT: "component",
|
|
1008
|
+
INSTANCE: "instance",
|
|
1009
|
+
GROUP: "group",
|
|
1010
|
+
VECTOR: "vector",
|
|
1011
|
+
LINE: "line",
|
|
1012
|
+
POLYGON: "polygon",
|
|
1013
|
+
STAR: "star",
|
|
1014
|
+
BOOLEAN_OPERATION: "boolean"
|
|
1015
|
+
};
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
// node_modules/.bun/consola@3.4.2/node_modules/consola/dist/core.mjs
|
|
1019
|
+
var LogLevels = {
|
|
1020
|
+
silent: Number.NEGATIVE_INFINITY,
|
|
1021
|
+
fatal: 0,
|
|
1022
|
+
error: 0,
|
|
1023
|
+
warn: 1,
|
|
1024
|
+
log: 2,
|
|
1025
|
+
info: 3,
|
|
1026
|
+
success: 3,
|
|
1027
|
+
fail: 3,
|
|
1028
|
+
ready: 3,
|
|
1029
|
+
start: 3,
|
|
1030
|
+
box: 3,
|
|
1031
|
+
debug: 4,
|
|
1032
|
+
trace: 5,
|
|
1033
|
+
verbose: Number.POSITIVE_INFINITY
|
|
1034
|
+
};
|
|
1035
|
+
var LogTypes = {
|
|
1036
|
+
silent: {
|
|
1037
|
+
level: -1
|
|
1038
|
+
},
|
|
1039
|
+
fatal: {
|
|
1040
|
+
level: LogLevels.fatal
|
|
1041
|
+
},
|
|
1042
|
+
error: {
|
|
1043
|
+
level: LogLevels.error
|
|
1044
|
+
},
|
|
1045
|
+
warn: {
|
|
1046
|
+
level: LogLevels.warn
|
|
1047
|
+
},
|
|
1048
|
+
log: {
|
|
1049
|
+
level: LogLevels.log
|
|
1050
|
+
},
|
|
1051
|
+
info: {
|
|
1052
|
+
level: LogLevels.info
|
|
1053
|
+
},
|
|
1054
|
+
success: {
|
|
1055
|
+
level: LogLevels.success
|
|
1056
|
+
},
|
|
1057
|
+
fail: {
|
|
1058
|
+
level: LogLevels.fail
|
|
1059
|
+
},
|
|
1060
|
+
ready: {
|
|
1061
|
+
level: LogLevels.info
|
|
1062
|
+
},
|
|
1063
|
+
start: {
|
|
1064
|
+
level: LogLevels.info
|
|
1065
|
+
},
|
|
1066
|
+
box: {
|
|
1067
|
+
level: LogLevels.info
|
|
1068
|
+
},
|
|
1069
|
+
debug: {
|
|
1070
|
+
level: LogLevels.debug
|
|
1071
|
+
},
|
|
1072
|
+
trace: {
|
|
1073
|
+
level: LogLevels.trace
|
|
1074
|
+
},
|
|
1075
|
+
verbose: {
|
|
1076
|
+
level: LogLevels.verbose
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
function isPlainObject$1(value) {
|
|
1080
|
+
if (value === null || typeof value !== "object") {
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1084
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
1085
|
+
return false;
|
|
1086
|
+
}
|
|
1087
|
+
if (Symbol.iterator in value) {
|
|
1088
|
+
return false;
|
|
1089
|
+
}
|
|
1090
|
+
if (Symbol.toStringTag in value) {
|
|
1091
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
1092
|
+
}
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1095
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
1096
|
+
if (!isPlainObject$1(defaults)) {
|
|
1097
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
1098
|
+
}
|
|
1099
|
+
const object = Object.assign({}, defaults);
|
|
1100
|
+
for (const key in baseObject) {
|
|
1101
|
+
if (key === "__proto__" || key === "constructor") {
|
|
1102
|
+
continue;
|
|
1103
|
+
}
|
|
1104
|
+
const value = baseObject[key];
|
|
1105
|
+
if (value === null || value === undefined) {
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
1112
|
+
object[key] = [...value, ...object[key]];
|
|
1113
|
+
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
1114
|
+
object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
1115
|
+
} else {
|
|
1116
|
+
object[key] = value;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return object;
|
|
1120
|
+
}
|
|
1121
|
+
function createDefu(merger) {
|
|
1122
|
+
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
1123
|
+
}
|
|
1124
|
+
var defu = createDefu();
|
|
1125
|
+
function isPlainObject(obj) {
|
|
1126
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
1127
|
+
}
|
|
1128
|
+
function isLogObj(arg) {
|
|
1129
|
+
if (!isPlainObject(arg)) {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
if (!arg.message && !arg.args) {
|
|
1133
|
+
return false;
|
|
1134
|
+
}
|
|
1135
|
+
if (arg.stack) {
|
|
1136
|
+
return false;
|
|
1137
|
+
}
|
|
1138
|
+
return true;
|
|
1139
|
+
}
|
|
1140
|
+
var paused = false;
|
|
1141
|
+
var queue = [];
|
|
1142
|
+
|
|
1143
|
+
class Consola {
|
|
1144
|
+
options;
|
|
1145
|
+
_lastLog;
|
|
1146
|
+
_mockFn;
|
|
1147
|
+
constructor(options = {}) {
|
|
1148
|
+
const types = options.types || LogTypes;
|
|
1149
|
+
this.options = defu({
|
|
1150
|
+
...options,
|
|
1151
|
+
defaults: { ...options.defaults },
|
|
1152
|
+
level: _normalizeLogLevel(options.level, types),
|
|
1153
|
+
reporters: [...options.reporters || []]
|
|
1154
|
+
}, {
|
|
1155
|
+
types: LogTypes,
|
|
1156
|
+
throttle: 1000,
|
|
1157
|
+
throttleMin: 5,
|
|
1158
|
+
formatOptions: {
|
|
1159
|
+
date: true,
|
|
1160
|
+
colors: false,
|
|
1161
|
+
compact: true
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
for (const type in types) {
|
|
1165
|
+
const defaults = {
|
|
1166
|
+
type,
|
|
1167
|
+
...this.options.defaults,
|
|
1168
|
+
...types[type]
|
|
1169
|
+
};
|
|
1170
|
+
this[type] = this._wrapLogFn(defaults);
|
|
1171
|
+
this[type].raw = this._wrapLogFn(defaults, true);
|
|
1172
|
+
}
|
|
1173
|
+
if (this.options.mockFn) {
|
|
1174
|
+
this.mockTypes();
|
|
1175
|
+
}
|
|
1176
|
+
this._lastLog = {};
|
|
1177
|
+
}
|
|
1178
|
+
get level() {
|
|
1179
|
+
return this.options.level;
|
|
1180
|
+
}
|
|
1181
|
+
set level(level) {
|
|
1182
|
+
this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
|
|
1183
|
+
}
|
|
1184
|
+
prompt(message, opts) {
|
|
1185
|
+
if (!this.options.prompt) {
|
|
1186
|
+
throw new Error("prompt is not supported!");
|
|
1187
|
+
}
|
|
1188
|
+
return this.options.prompt(message, opts);
|
|
1189
|
+
}
|
|
1190
|
+
create(options) {
|
|
1191
|
+
const instance = new Consola({
|
|
1192
|
+
...this.options,
|
|
1193
|
+
...options
|
|
1194
|
+
});
|
|
1195
|
+
if (this._mockFn) {
|
|
1196
|
+
instance.mockTypes(this._mockFn);
|
|
1197
|
+
}
|
|
1198
|
+
return instance;
|
|
1199
|
+
}
|
|
1200
|
+
withDefaults(defaults) {
|
|
1201
|
+
return this.create({
|
|
1202
|
+
...this.options,
|
|
1203
|
+
defaults: {
|
|
1204
|
+
...this.options.defaults,
|
|
1205
|
+
...defaults
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
withTag(tag) {
|
|
1210
|
+
return this.withDefaults({
|
|
1211
|
+
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
addReporter(reporter) {
|
|
1215
|
+
this.options.reporters.push(reporter);
|
|
1216
|
+
return this;
|
|
1217
|
+
}
|
|
1218
|
+
removeReporter(reporter) {
|
|
1219
|
+
if (reporter) {
|
|
1220
|
+
const i = this.options.reporters.indexOf(reporter);
|
|
1221
|
+
if (i !== -1) {
|
|
1222
|
+
return this.options.reporters.splice(i, 1);
|
|
1223
|
+
}
|
|
1224
|
+
} else {
|
|
1225
|
+
this.options.reporters.splice(0);
|
|
1226
|
+
}
|
|
1227
|
+
return this;
|
|
1228
|
+
}
|
|
1229
|
+
setReporters(reporters) {
|
|
1230
|
+
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
1231
|
+
return this;
|
|
1232
|
+
}
|
|
1233
|
+
wrapAll() {
|
|
1234
|
+
this.wrapConsole();
|
|
1235
|
+
this.wrapStd();
|
|
1236
|
+
}
|
|
1237
|
+
restoreAll() {
|
|
1238
|
+
this.restoreConsole();
|
|
1239
|
+
this.restoreStd();
|
|
1240
|
+
}
|
|
1241
|
+
wrapConsole() {
|
|
1242
|
+
for (const type in this.options.types) {
|
|
1243
|
+
if (!console["__" + type]) {
|
|
1244
|
+
console["__" + type] = console[type];
|
|
1245
|
+
}
|
|
1246
|
+
console[type] = this[type].raw;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
restoreConsole() {
|
|
1250
|
+
for (const type in this.options.types) {
|
|
1251
|
+
if (console["__" + type]) {
|
|
1252
|
+
console[type] = console["__" + type];
|
|
1253
|
+
delete console["__" + type];
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
wrapStd() {
|
|
1258
|
+
this._wrapStream(this.options.stdout, "log");
|
|
1259
|
+
this._wrapStream(this.options.stderr, "log");
|
|
1260
|
+
}
|
|
1261
|
+
_wrapStream(stream, type) {
|
|
1262
|
+
if (!stream) {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
if (!stream.__write) {
|
|
1266
|
+
stream.__write = stream.write;
|
|
1267
|
+
}
|
|
1268
|
+
stream.write = (data) => {
|
|
1269
|
+
this[type].raw(String(data).trim());
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
restoreStd() {
|
|
1273
|
+
this._restoreStream(this.options.stdout);
|
|
1274
|
+
this._restoreStream(this.options.stderr);
|
|
1275
|
+
}
|
|
1276
|
+
_restoreStream(stream) {
|
|
1277
|
+
if (!stream) {
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
if (stream.__write) {
|
|
1281
|
+
stream.write = stream.__write;
|
|
1282
|
+
delete stream.__write;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
pauseLogs() {
|
|
1286
|
+
paused = true;
|
|
1287
|
+
}
|
|
1288
|
+
resumeLogs() {
|
|
1289
|
+
paused = false;
|
|
1290
|
+
const _queue = queue.splice(0);
|
|
1291
|
+
for (const item of _queue) {
|
|
1292
|
+
item[0]._logFn(item[1], item[2]);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
mockTypes(mockFn) {
|
|
1296
|
+
const _mockFn = mockFn || this.options.mockFn;
|
|
1297
|
+
this._mockFn = _mockFn;
|
|
1298
|
+
if (typeof _mockFn !== "function") {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
for (const type in this.options.types) {
|
|
1302
|
+
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
1303
|
+
this[type].raw = this[type];
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
_wrapLogFn(defaults, isRaw) {
|
|
1307
|
+
return (...args) => {
|
|
1308
|
+
if (paused) {
|
|
1309
|
+
queue.push([this, defaults, args, isRaw]);
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
return this._logFn(defaults, args, isRaw);
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
_logFn(defaults, args, isRaw) {
|
|
1316
|
+
if ((defaults.level || 0) > this.level) {
|
|
1317
|
+
return false;
|
|
1318
|
+
}
|
|
1319
|
+
const logObj = {
|
|
1320
|
+
date: /* @__PURE__ */ new Date,
|
|
1321
|
+
args: [],
|
|
1322
|
+
...defaults,
|
|
1323
|
+
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
1324
|
+
};
|
|
1325
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
1326
|
+
Object.assign(logObj, args[0]);
|
|
1327
|
+
} else {
|
|
1328
|
+
logObj.args = [...args];
|
|
1329
|
+
}
|
|
1330
|
+
if (logObj.message) {
|
|
1331
|
+
logObj.args.unshift(logObj.message);
|
|
1332
|
+
delete logObj.message;
|
|
1333
|
+
}
|
|
1334
|
+
if (logObj.additional) {
|
|
1335
|
+
if (!Array.isArray(logObj.additional)) {
|
|
1336
|
+
logObj.additional = logObj.additional.split(`
|
|
1337
|
+
`);
|
|
1338
|
+
}
|
|
1339
|
+
logObj.args.push(`
|
|
1340
|
+
` + logObj.additional.join(`
|
|
1341
|
+
`));
|
|
1342
|
+
delete logObj.additional;
|
|
1343
|
+
}
|
|
1344
|
+
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
1345
|
+
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
1346
|
+
const resolveLog = (newLog = false) => {
|
|
1347
|
+
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
1348
|
+
if (this._lastLog.object && repeated > 0) {
|
|
1349
|
+
const args2 = [...this._lastLog.object.args];
|
|
1350
|
+
if (repeated > 1) {
|
|
1351
|
+
args2.push(`(repeated ${repeated} times)`);
|
|
1352
|
+
}
|
|
1353
|
+
this._log({ ...this._lastLog.object, args: args2 });
|
|
1354
|
+
this._lastLog.count = 1;
|
|
1355
|
+
}
|
|
1356
|
+
if (newLog) {
|
|
1357
|
+
this._lastLog.object = logObj;
|
|
1358
|
+
this._log(logObj);
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
clearTimeout(this._lastLog.timeout);
|
|
1362
|
+
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
1363
|
+
this._lastLog.time = logObj.date;
|
|
1364
|
+
if (diffTime < this.options.throttle) {
|
|
1365
|
+
try {
|
|
1366
|
+
const serializedLog = JSON.stringify([
|
|
1367
|
+
logObj.type,
|
|
1368
|
+
logObj.tag,
|
|
1369
|
+
logObj.args
|
|
1370
|
+
]);
|
|
1371
|
+
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
1372
|
+
this._lastLog.serialized = serializedLog;
|
|
1373
|
+
if (isSameLog) {
|
|
1374
|
+
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
1375
|
+
if (this._lastLog.count > this.options.throttleMin) {
|
|
1376
|
+
this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
} catch {}
|
|
1381
|
+
}
|
|
1382
|
+
resolveLog(true);
|
|
1383
|
+
}
|
|
1384
|
+
_log(logObj) {
|
|
1385
|
+
for (const reporter of this.options.reporters) {
|
|
1386
|
+
reporter.log(logObj, {
|
|
1387
|
+
options: this.options
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
1393
|
+
if (input === undefined) {
|
|
1394
|
+
return defaultLevel;
|
|
1395
|
+
}
|
|
1396
|
+
if (typeof input === "number") {
|
|
1397
|
+
return input;
|
|
1398
|
+
}
|
|
1399
|
+
if (types[input] && types[input].level !== undefined) {
|
|
1400
|
+
return types[input].level;
|
|
1401
|
+
}
|
|
1402
|
+
return defaultLevel;
|
|
1403
|
+
}
|
|
1404
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
1405
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
1406
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
1407
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
1408
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
1409
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
1410
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
1411
|
+
function createConsola(options = {}) {
|
|
1412
|
+
return new Consola(options);
|
|
1413
|
+
}
|
|
1414
|
+
// node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
|
|
1415
|
+
import { formatWithOptions } from "util";
|
|
1416
|
+
import { sep } from "path";
|
|
1417
|
+
function parseStack(stack, message) {
|
|
1418
|
+
const cwd = process.cwd() + sep;
|
|
1419
|
+
const lines = stack.split(`
|
|
1420
|
+
`).splice(message.split(`
|
|
1421
|
+
`).length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
|
|
1422
|
+
return lines;
|
|
1423
|
+
}
|
|
1424
|
+
function writeStream(data, stream) {
|
|
1425
|
+
const write = stream.__write || stream.write;
|
|
1426
|
+
return write.call(stream, data);
|
|
1427
|
+
}
|
|
1428
|
+
var bracket = (x) => x ? `[${x}]` : "";
|
|
1429
|
+
|
|
1430
|
+
class BasicReporter {
|
|
1431
|
+
formatStack(stack, message, opts) {
|
|
1432
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
1433
|
+
return indent + parseStack(stack, message).join(`
|
|
1434
|
+
${indent}`);
|
|
1435
|
+
}
|
|
1436
|
+
formatError(err, opts) {
|
|
1437
|
+
const message = err.message ?? formatWithOptions(opts, err);
|
|
1438
|
+
const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
|
|
1439
|
+
const level = opts?.errorLevel || 0;
|
|
1440
|
+
const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
|
|
1441
|
+
const causedError = err.cause ? `
|
|
1442
|
+
|
|
1443
|
+
` + this.formatError(err.cause, { ...opts, errorLevel: level + 1 }) : "";
|
|
1444
|
+
return causedPrefix + message + `
|
|
1445
|
+
` + stack + causedError;
|
|
1446
|
+
}
|
|
1447
|
+
formatArgs(args, opts) {
|
|
1448
|
+
const _args = args.map((arg) => {
|
|
1449
|
+
if (arg && typeof arg.stack === "string") {
|
|
1450
|
+
return this.formatError(arg, opts);
|
|
1451
|
+
}
|
|
1452
|
+
return arg;
|
|
1453
|
+
});
|
|
1454
|
+
return formatWithOptions(opts, ..._args);
|
|
1455
|
+
}
|
|
1456
|
+
formatDate(date, opts) {
|
|
1457
|
+
return opts.date ? date.toLocaleTimeString() : "";
|
|
1458
|
+
}
|
|
1459
|
+
filterAndJoin(arr) {
|
|
1460
|
+
return arr.filter(Boolean).join(" ");
|
|
1461
|
+
}
|
|
1462
|
+
formatLogObj(logObj, opts) {
|
|
1463
|
+
const message = this.formatArgs(logObj.args, opts);
|
|
1464
|
+
if (logObj.type === "box") {
|
|
1465
|
+
return `
|
|
1466
|
+
` + [
|
|
1467
|
+
bracket(logObj.tag),
|
|
1468
|
+
logObj.title && logObj.title,
|
|
1469
|
+
...message.split(`
|
|
1470
|
+
`)
|
|
1471
|
+
].filter(Boolean).map((l) => " > " + l).join(`
|
|
1472
|
+
`) + `
|
|
1473
|
+
`;
|
|
1474
|
+
}
|
|
1475
|
+
return this.filterAndJoin([
|
|
1476
|
+
bracket(logObj.type),
|
|
1477
|
+
bracket(logObj.tag),
|
|
1478
|
+
message
|
|
1479
|
+
]);
|
|
1480
|
+
}
|
|
1481
|
+
log(logObj, ctx) {
|
|
1482
|
+
const line = this.formatLogObj(logObj, {
|
|
1483
|
+
columns: ctx.options.stdout.columns || 0,
|
|
1484
|
+
...ctx.options.formatOptions
|
|
1485
|
+
});
|
|
1486
|
+
return writeStream(line + `
|
|
1487
|
+
`, logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
// node_modules/.bun/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
1492
|
+
import g$1 from "process";
|
|
1493
|
+
|
|
1494
|
+
// node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
|
|
1495
|
+
import * as tty from "tty";
|
|
1496
|
+
var {
|
|
1497
|
+
env = {},
|
|
1498
|
+
argv = [],
|
|
1499
|
+
platform = ""
|
|
1500
|
+
} = typeof process === "undefined" ? {} : process;
|
|
1501
|
+
var isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
1502
|
+
var isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
1503
|
+
var isWindows = platform === "win32";
|
|
1504
|
+
var isDumbTerminal = env.TERM === "dumb";
|
|
1505
|
+
var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
1506
|
+
var isCI = "CI" in env && (("GITHUB_ACTIONS" in env) || ("GITLAB_CI" in env) || ("CIRCLECI" in env));
|
|
1507
|
+
var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
1508
|
+
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
|
1509
|
+
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
1510
|
+
}
|
|
1511
|
+
function clearBleed(index, string, open, close, replace) {
|
|
1512
|
+
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
1513
|
+
}
|
|
1514
|
+
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
|
1515
|
+
return (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
1516
|
+
}
|
|
1517
|
+
function init(open, close, replace) {
|
|
1518
|
+
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
|
1519
|
+
}
|
|
1520
|
+
var colorDefs = {
|
|
1521
|
+
reset: init(0, 0),
|
|
1522
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
1523
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
1524
|
+
italic: init(3, 23),
|
|
1525
|
+
underline: init(4, 24),
|
|
1526
|
+
inverse: init(7, 27),
|
|
1527
|
+
hidden: init(8, 28),
|
|
1528
|
+
strikethrough: init(9, 29),
|
|
1529
|
+
black: init(30, 39),
|
|
1530
|
+
red: init(31, 39),
|
|
1531
|
+
green: init(32, 39),
|
|
1532
|
+
yellow: init(33, 39),
|
|
1533
|
+
blue: init(34, 39),
|
|
1534
|
+
magenta: init(35, 39),
|
|
1535
|
+
cyan: init(36, 39),
|
|
1536
|
+
white: init(37, 39),
|
|
1537
|
+
gray: init(90, 39),
|
|
1538
|
+
bgBlack: init(40, 49),
|
|
1539
|
+
bgRed: init(41, 49),
|
|
1540
|
+
bgGreen: init(42, 49),
|
|
1541
|
+
bgYellow: init(43, 49),
|
|
1542
|
+
bgBlue: init(44, 49),
|
|
1543
|
+
bgMagenta: init(45, 49),
|
|
1544
|
+
bgCyan: init(46, 49),
|
|
1545
|
+
bgWhite: init(47, 49),
|
|
1546
|
+
blackBright: init(90, 39),
|
|
1547
|
+
redBright: init(91, 39),
|
|
1548
|
+
greenBright: init(92, 39),
|
|
1549
|
+
yellowBright: init(93, 39),
|
|
1550
|
+
blueBright: init(94, 39),
|
|
1551
|
+
magentaBright: init(95, 39),
|
|
1552
|
+
cyanBright: init(96, 39),
|
|
1553
|
+
whiteBright: init(97, 39),
|
|
1554
|
+
bgBlackBright: init(100, 49),
|
|
1555
|
+
bgRedBright: init(101, 49),
|
|
1556
|
+
bgGreenBright: init(102, 49),
|
|
1557
|
+
bgYellowBright: init(103, 49),
|
|
1558
|
+
bgBlueBright: init(104, 49),
|
|
1559
|
+
bgMagentaBright: init(105, 49),
|
|
1560
|
+
bgCyanBright: init(106, 49),
|
|
1561
|
+
bgWhiteBright: init(107, 49)
|
|
1562
|
+
};
|
|
1563
|
+
function createColors(useColor = isColorSupported) {
|
|
1564
|
+
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
1565
|
+
}
|
|
1566
|
+
var colors = createColors();
|
|
1567
|
+
function getColor(color, fallback = "reset") {
|
|
1568
|
+
return colors[color] || colors[fallback];
|
|
1569
|
+
}
|
|
1570
|
+
var ansiRegex = [
|
|
1571
|
+
String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
|
|
1572
|
+
String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
|
|
1573
|
+
].join("|");
|
|
1574
|
+
function stripAnsi(text) {
|
|
1575
|
+
return text.replace(new RegExp(ansiRegex, "g"), "");
|
|
1576
|
+
}
|
|
1577
|
+
var boxStylePresets = {
|
|
1578
|
+
solid: {
|
|
1579
|
+
tl: "\u250C",
|
|
1580
|
+
tr: "\u2510",
|
|
1581
|
+
bl: "\u2514",
|
|
1582
|
+
br: "\u2518",
|
|
1583
|
+
h: "\u2500",
|
|
1584
|
+
v: "\u2502"
|
|
1585
|
+
},
|
|
1586
|
+
double: {
|
|
1587
|
+
tl: "\u2554",
|
|
1588
|
+
tr: "\u2557",
|
|
1589
|
+
bl: "\u255A",
|
|
1590
|
+
br: "\u255D",
|
|
1591
|
+
h: "\u2550",
|
|
1592
|
+
v: "\u2551"
|
|
1593
|
+
},
|
|
1594
|
+
doubleSingle: {
|
|
1595
|
+
tl: "\u2553",
|
|
1596
|
+
tr: "\u2556",
|
|
1597
|
+
bl: "\u2559",
|
|
1598
|
+
br: "\u255C",
|
|
1599
|
+
h: "\u2500",
|
|
1600
|
+
v: "\u2551"
|
|
1601
|
+
},
|
|
1602
|
+
doubleSingleRounded: {
|
|
1603
|
+
tl: "\u256D",
|
|
1604
|
+
tr: "\u256E",
|
|
1605
|
+
bl: "\u2570",
|
|
1606
|
+
br: "\u256F",
|
|
1607
|
+
h: "\u2500",
|
|
1608
|
+
v: "\u2551"
|
|
1609
|
+
},
|
|
1610
|
+
singleThick: {
|
|
1611
|
+
tl: "\u250F",
|
|
1612
|
+
tr: "\u2513",
|
|
1613
|
+
bl: "\u2517",
|
|
1614
|
+
br: "\u251B",
|
|
1615
|
+
h: "\u2501",
|
|
1616
|
+
v: "\u2503"
|
|
1617
|
+
},
|
|
1618
|
+
singleDouble: {
|
|
1619
|
+
tl: "\u2552",
|
|
1620
|
+
tr: "\u2555",
|
|
1621
|
+
bl: "\u2558",
|
|
1622
|
+
br: "\u255B",
|
|
1623
|
+
h: "\u2550",
|
|
1624
|
+
v: "\u2502"
|
|
1625
|
+
},
|
|
1626
|
+
singleDoubleRounded: {
|
|
1627
|
+
tl: "\u256D",
|
|
1628
|
+
tr: "\u256E",
|
|
1629
|
+
bl: "\u2570",
|
|
1630
|
+
br: "\u256F",
|
|
1631
|
+
h: "\u2550",
|
|
1632
|
+
v: "\u2502"
|
|
1633
|
+
},
|
|
1634
|
+
rounded: {
|
|
1635
|
+
tl: "\u256D",
|
|
1636
|
+
tr: "\u256E",
|
|
1637
|
+
bl: "\u2570",
|
|
1638
|
+
br: "\u256F",
|
|
1639
|
+
h: "\u2500",
|
|
1640
|
+
v: "\u2502"
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
var defaultStyle = {
|
|
1644
|
+
borderColor: "white",
|
|
1645
|
+
borderStyle: "rounded",
|
|
1646
|
+
valign: "center",
|
|
1647
|
+
padding: 2,
|
|
1648
|
+
marginLeft: 1,
|
|
1649
|
+
marginTop: 1,
|
|
1650
|
+
marginBottom: 1
|
|
1651
|
+
};
|
|
1652
|
+
function box(text, _opts = {}) {
|
|
1653
|
+
const opts = {
|
|
1654
|
+
..._opts,
|
|
1655
|
+
style: {
|
|
1656
|
+
...defaultStyle,
|
|
1657
|
+
..._opts.style
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
const textLines = text.split(`
|
|
1661
|
+
`);
|
|
1662
|
+
const boxLines = [];
|
|
1663
|
+
const _color = getColor(opts.style.borderColor);
|
|
1664
|
+
const borderStyle = {
|
|
1665
|
+
...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
|
|
1666
|
+
};
|
|
1667
|
+
if (_color) {
|
|
1668
|
+
for (const key in borderStyle) {
|
|
1669
|
+
borderStyle[key] = _color(borderStyle[key]);
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
1673
|
+
const height = textLines.length + paddingOffset;
|
|
1674
|
+
const width = Math.max(...textLines.map((line) => stripAnsi(line).length), opts.title ? stripAnsi(opts.title).length : 0) + paddingOffset;
|
|
1675
|
+
const widthOffset = width + paddingOffset;
|
|
1676
|
+
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
1677
|
+
if (opts.style.marginTop > 0) {
|
|
1678
|
+
boxLines.push("".repeat(opts.style.marginTop));
|
|
1679
|
+
}
|
|
1680
|
+
if (opts.title) {
|
|
1681
|
+
const title = _color ? _color(opts.title) : opts.title;
|
|
1682
|
+
const left = borderStyle.h.repeat(Math.floor((width - stripAnsi(opts.title).length) / 2));
|
|
1683
|
+
const right = borderStyle.h.repeat(width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset);
|
|
1684
|
+
boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
|
|
1685
|
+
} else {
|
|
1686
|
+
boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
|
|
1687
|
+
}
|
|
1688
|
+
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
1689
|
+
for (let i = 0;i < height; i++) {
|
|
1690
|
+
if (i < valignOffset || i >= valignOffset + textLines.length) {
|
|
1691
|
+
boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
|
|
1692
|
+
} else {
|
|
1693
|
+
const line = textLines[i - valignOffset];
|
|
1694
|
+
const left = " ".repeat(paddingOffset);
|
|
1695
|
+
const right = " ".repeat(width - stripAnsi(line).length);
|
|
1696
|
+
boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
|
|
1700
|
+
if (opts.style.marginBottom > 0) {
|
|
1701
|
+
boxLines.push("".repeat(opts.style.marginBottom));
|
|
1702
|
+
}
|
|
1703
|
+
return boxLines.join(`
|
|
1704
|
+
`);
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
// node_modules/.bun/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
1708
|
+
var r2 = Object.create(null);
|
|
1709
|
+
var i = (e2) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e2 ? r2 : globalThis);
|
|
1710
|
+
var o2 = new Proxy(r2, { get(e2, s) {
|
|
1711
|
+
return i()[s] ?? r2[s];
|
|
1712
|
+
}, has(e2, s) {
|
|
1713
|
+
const E = i();
|
|
1714
|
+
return s in E || s in r2;
|
|
1715
|
+
}, set(e2, s, E) {
|
|
1716
|
+
const B2 = i(true);
|
|
1717
|
+
return B2[s] = E, true;
|
|
1718
|
+
}, deleteProperty(e2, s) {
|
|
1719
|
+
if (!s)
|
|
1720
|
+
return false;
|
|
1721
|
+
const E = i(true);
|
|
1722
|
+
return delete E[s], true;
|
|
1723
|
+
}, ownKeys() {
|
|
1724
|
+
const e2 = i(true);
|
|
1725
|
+
return Object.keys(e2);
|
|
1726
|
+
} });
|
|
1727
|
+
var t = typeof process < "u" && process.env && "development" || "";
|
|
1728
|
+
var f2 = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
|
|
1729
|
+
function b() {
|
|
1730
|
+
if (globalThis.process?.env)
|
|
1731
|
+
for (const e2 of f2) {
|
|
1732
|
+
const s = e2[1] || e2[0];
|
|
1733
|
+
if (globalThis.process?.env[s])
|
|
1734
|
+
return { name: e2[0].toLowerCase(), ...e2[2] };
|
|
1735
|
+
}
|
|
1736
|
+
return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
|
|
1737
|
+
}
|
|
1738
|
+
var l = b();
|
|
1739
|
+
l.name;
|
|
1740
|
+
function n(e2) {
|
|
1741
|
+
return e2 ? e2 !== "false" : false;
|
|
1742
|
+
}
|
|
1743
|
+
var I2 = globalThis.process?.platform || "";
|
|
1744
|
+
var T2 = n(o2.CI) || l.ci !== false;
|
|
1745
|
+
var a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
|
|
1746
|
+
var g2 = n(o2.DEBUG);
|
|
1747
|
+
var R2 = t === "test" || n(o2.TEST);
|
|
1748
|
+
n(o2.MINIMAL);
|
|
1749
|
+
var A2 = /^win/i.test(I2);
|
|
1750
|
+
!n(o2.NO_COLOR) && (n(o2.FORCE_COLOR) || (a || A2) && o2.TERM);
|
|
1751
|
+
var C2 = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
|
|
1752
|
+
Number(C2?.split(".")[0]);
|
|
1753
|
+
var y2 = globalThis.process || Object.create(null);
|
|
1754
|
+
var _2 = { versions: {} };
|
|
1755
|
+
new Proxy(y2, { get(e2, s) {
|
|
1756
|
+
if (s === "env")
|
|
1757
|
+
return o2;
|
|
1758
|
+
if (s in e2)
|
|
1759
|
+
return e2[s];
|
|
1760
|
+
if (s in _2)
|
|
1761
|
+
return _2[s];
|
|
1762
|
+
} });
|
|
1763
|
+
var c2 = globalThis.process?.release?.name === "node";
|
|
1764
|
+
var O2 = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
|
|
1765
|
+
var D = !!globalThis.Deno;
|
|
1766
|
+
var L2 = !!globalThis.fastly;
|
|
1767
|
+
var S2 = !!globalThis.Netlify;
|
|
1768
|
+
var u2 = !!globalThis.EdgeRuntime;
|
|
1769
|
+
var N2 = globalThis.navigator?.userAgent === "Cloudflare-Workers";
|
|
1770
|
+
var F2 = [[S2, "netlify"], [u2, "edge-light"], [N2, "workerd"], [L2, "fastly"], [D, "deno"], [O2, "bun"], [c2, "node"]];
|
|
1771
|
+
function G2() {
|
|
1772
|
+
const e2 = F2.find((s) => s[0]);
|
|
1773
|
+
if (e2)
|
|
1774
|
+
return { name: e2[1] };
|
|
1775
|
+
}
|
|
1776
|
+
var P2 = G2();
|
|
1777
|
+
P2?.name;
|
|
1778
|
+
function ansiRegex2({ onlyFirst = false } = {}) {
|
|
1779
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
1780
|
+
const pattern = [
|
|
1781
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
1782
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
1783
|
+
].join("|");
|
|
1784
|
+
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
1785
|
+
}
|
|
1786
|
+
var regex = ansiRegex2();
|
|
1787
|
+
function stripAnsi2(string) {
|
|
1788
|
+
if (typeof string !== "string") {
|
|
1789
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
1790
|
+
}
|
|
1791
|
+
return string.replace(regex, "");
|
|
1792
|
+
}
|
|
1793
|
+
function isAmbiguous(x2) {
|
|
1794
|
+
return x2 === 161 || x2 === 164 || x2 === 167 || x2 === 168 || x2 === 170 || x2 === 173 || x2 === 174 || x2 >= 176 && x2 <= 180 || x2 >= 182 && x2 <= 186 || x2 >= 188 && x2 <= 191 || x2 === 198 || x2 === 208 || x2 === 215 || x2 === 216 || x2 >= 222 && x2 <= 225 || x2 === 230 || x2 >= 232 && x2 <= 234 || x2 === 236 || x2 === 237 || x2 === 240 || x2 === 242 || x2 === 243 || x2 >= 247 && x2 <= 250 || x2 === 252 || x2 === 254 || x2 === 257 || x2 === 273 || x2 === 275 || x2 === 283 || x2 === 294 || x2 === 295 || x2 === 299 || x2 >= 305 && x2 <= 307 || x2 === 312 || x2 >= 319 && x2 <= 322 || x2 === 324 || x2 >= 328 && x2 <= 331 || x2 === 333 || x2 === 338 || x2 === 339 || x2 === 358 || x2 === 359 || x2 === 363 || x2 === 462 || x2 === 464 || x2 === 466 || x2 === 468 || x2 === 470 || x2 === 472 || x2 === 474 || x2 === 476 || x2 === 593 || x2 === 609 || x2 === 708 || x2 === 711 || x2 >= 713 && x2 <= 715 || x2 === 717 || x2 === 720 || x2 >= 728 && x2 <= 731 || x2 === 733 || x2 === 735 || x2 >= 768 && x2 <= 879 || x2 >= 913 && x2 <= 929 || x2 >= 931 && x2 <= 937 || x2 >= 945 && x2 <= 961 || x2 >= 963 && x2 <= 969 || x2 === 1025 || x2 >= 1040 && x2 <= 1103 || x2 === 1105 || x2 === 8208 || x2 >= 8211 && x2 <= 8214 || x2 === 8216 || x2 === 8217 || x2 === 8220 || x2 === 8221 || x2 >= 8224 && x2 <= 8226 || x2 >= 8228 && x2 <= 8231 || x2 === 8240 || x2 === 8242 || x2 === 8243 || x2 === 8245 || x2 === 8251 || x2 === 8254 || x2 === 8308 || x2 === 8319 || x2 >= 8321 && x2 <= 8324 || x2 === 8364 || x2 === 8451 || x2 === 8453 || x2 === 8457 || x2 === 8467 || x2 === 8470 || x2 === 8481 || x2 === 8482 || x2 === 8486 || x2 === 8491 || x2 === 8531 || x2 === 8532 || x2 >= 8539 && x2 <= 8542 || x2 >= 8544 && x2 <= 8555 || x2 >= 8560 && x2 <= 8569 || x2 === 8585 || x2 >= 8592 && x2 <= 8601 || x2 === 8632 || x2 === 8633 || x2 === 8658 || x2 === 8660 || x2 === 8679 || x2 === 8704 || x2 === 8706 || x2 === 8707 || x2 === 8711 || x2 === 8712 || x2 === 8715 || x2 === 8719 || x2 === 8721 || x2 === 8725 || x2 === 8730 || x2 >= 8733 && x2 <= 8736 || x2 === 8739 || x2 === 8741 || x2 >= 8743 && x2 <= 8748 || x2 === 8750 || x2 >= 8756 && x2 <= 8759 || x2 === 8764 || x2 === 8765 || x2 === 8776 || x2 === 8780 || x2 === 8786 || x2 === 8800 || x2 === 8801 || x2 >= 8804 && x2 <= 8807 || x2 === 8810 || x2 === 8811 || x2 === 8814 || x2 === 8815 || x2 === 8834 || x2 === 8835 || x2 === 8838 || x2 === 8839 || x2 === 8853 || x2 === 8857 || x2 === 8869 || x2 === 8895 || x2 === 8978 || x2 >= 9312 && x2 <= 9449 || x2 >= 9451 && x2 <= 9547 || x2 >= 9552 && x2 <= 9587 || x2 >= 9600 && x2 <= 9615 || x2 >= 9618 && x2 <= 9621 || x2 === 9632 || x2 === 9633 || x2 >= 9635 && x2 <= 9641 || x2 === 9650 || x2 === 9651 || x2 === 9654 || x2 === 9655 || x2 === 9660 || x2 === 9661 || x2 === 9664 || x2 === 9665 || x2 >= 9670 && x2 <= 9672 || x2 === 9675 || x2 >= 9678 && x2 <= 9681 || x2 >= 9698 && x2 <= 9701 || x2 === 9711 || x2 === 9733 || x2 === 9734 || x2 === 9737 || x2 === 9742 || x2 === 9743 || x2 === 9756 || x2 === 9758 || x2 === 9792 || x2 === 9794 || x2 === 9824 || x2 === 9825 || x2 >= 9827 && x2 <= 9829 || x2 >= 9831 && x2 <= 9834 || x2 === 9836 || x2 === 9837 || x2 === 9839 || x2 === 9886 || x2 === 9887 || x2 === 9919 || x2 >= 9926 && x2 <= 9933 || x2 >= 9935 && x2 <= 9939 || x2 >= 9941 && x2 <= 9953 || x2 === 9955 || x2 === 9960 || x2 === 9961 || x2 >= 9963 && x2 <= 9969 || x2 === 9972 || x2 >= 9974 && x2 <= 9977 || x2 === 9979 || x2 === 9980 || x2 === 9982 || x2 === 9983 || x2 === 10045 || x2 >= 10102 && x2 <= 10111 || x2 >= 11094 && x2 <= 11097 || x2 >= 12872 && x2 <= 12879 || x2 >= 57344 && x2 <= 63743 || x2 >= 65024 && x2 <= 65039 || x2 === 65533 || x2 >= 127232 && x2 <= 127242 || x2 >= 127248 && x2 <= 127277 || x2 >= 127280 && x2 <= 127337 || x2 >= 127344 && x2 <= 127373 || x2 === 127375 || x2 === 127376 || x2 >= 127387 && x2 <= 127404 || x2 >= 917760 && x2 <= 917999 || x2 >= 983040 && x2 <= 1048573 || x2 >= 1048576 && x2 <= 1114109;
|
|
1795
|
+
}
|
|
1796
|
+
function isFullWidth(x2) {
|
|
1797
|
+
return x2 === 12288 || x2 >= 65281 && x2 <= 65376 || x2 >= 65504 && x2 <= 65510;
|
|
1798
|
+
}
|
|
1799
|
+
function isWide(x2) {
|
|
1800
|
+
return x2 >= 4352 && x2 <= 4447 || x2 === 8986 || x2 === 8987 || x2 === 9001 || x2 === 9002 || x2 >= 9193 && x2 <= 9196 || x2 === 9200 || x2 === 9203 || x2 === 9725 || x2 === 9726 || x2 === 9748 || x2 === 9749 || x2 >= 9776 && x2 <= 9783 || x2 >= 9800 && x2 <= 9811 || x2 === 9855 || x2 >= 9866 && x2 <= 9871 || x2 === 9875 || x2 === 9889 || x2 === 9898 || x2 === 9899 || x2 === 9917 || x2 === 9918 || x2 === 9924 || x2 === 9925 || x2 === 9934 || x2 === 9940 || x2 === 9962 || x2 === 9970 || x2 === 9971 || x2 === 9973 || x2 === 9978 || x2 === 9981 || x2 === 9989 || x2 === 9994 || x2 === 9995 || x2 === 10024 || x2 === 10060 || x2 === 10062 || x2 >= 10067 && x2 <= 10069 || x2 === 10071 || x2 >= 10133 && x2 <= 10135 || x2 === 10160 || x2 === 10175 || x2 === 11035 || x2 === 11036 || x2 === 11088 || x2 === 11093 || x2 >= 11904 && x2 <= 11929 || x2 >= 11931 && x2 <= 12019 || x2 >= 12032 && x2 <= 12245 || x2 >= 12272 && x2 <= 12287 || x2 >= 12289 && x2 <= 12350 || x2 >= 12353 && x2 <= 12438 || x2 >= 12441 && x2 <= 12543 || x2 >= 12549 && x2 <= 12591 || x2 >= 12593 && x2 <= 12686 || x2 >= 12688 && x2 <= 12773 || x2 >= 12783 && x2 <= 12830 || x2 >= 12832 && x2 <= 12871 || x2 >= 12880 && x2 <= 42124 || x2 >= 42128 && x2 <= 42182 || x2 >= 43360 && x2 <= 43388 || x2 >= 44032 && x2 <= 55203 || x2 >= 63744 && x2 <= 64255 || x2 >= 65040 && x2 <= 65049 || x2 >= 65072 && x2 <= 65106 || x2 >= 65108 && x2 <= 65126 || x2 >= 65128 && x2 <= 65131 || x2 >= 94176 && x2 <= 94180 || x2 === 94192 || x2 === 94193 || x2 >= 94208 && x2 <= 100343 || x2 >= 100352 && x2 <= 101589 || x2 >= 101631 && x2 <= 101640 || x2 >= 110576 && x2 <= 110579 || x2 >= 110581 && x2 <= 110587 || x2 === 110589 || x2 === 110590 || x2 >= 110592 && x2 <= 110882 || x2 === 110898 || x2 >= 110928 && x2 <= 110930 || x2 === 110933 || x2 >= 110948 && x2 <= 110951 || x2 >= 110960 && x2 <= 111355 || x2 >= 119552 && x2 <= 119638 || x2 >= 119648 && x2 <= 119670 || x2 === 126980 || x2 === 127183 || x2 === 127374 || x2 >= 127377 && x2 <= 127386 || x2 >= 127488 && x2 <= 127490 || x2 >= 127504 && x2 <= 127547 || x2 >= 127552 && x2 <= 127560 || x2 === 127568 || x2 === 127569 || x2 >= 127584 && x2 <= 127589 || x2 >= 127744 && x2 <= 127776 || x2 >= 127789 && x2 <= 127797 || x2 >= 127799 && x2 <= 127868 || x2 >= 127870 && x2 <= 127891 || x2 >= 127904 && x2 <= 127946 || x2 >= 127951 && x2 <= 127955 || x2 >= 127968 && x2 <= 127984 || x2 === 127988 || x2 >= 127992 && x2 <= 128062 || x2 === 128064 || x2 >= 128066 && x2 <= 128252 || x2 >= 128255 && x2 <= 128317 || x2 >= 128331 && x2 <= 128334 || x2 >= 128336 && x2 <= 128359 || x2 === 128378 || x2 === 128405 || x2 === 128406 || x2 === 128420 || x2 >= 128507 && x2 <= 128591 || x2 >= 128640 && x2 <= 128709 || x2 === 128716 || x2 >= 128720 && x2 <= 128722 || x2 >= 128725 && x2 <= 128727 || x2 >= 128732 && x2 <= 128735 || x2 === 128747 || x2 === 128748 || x2 >= 128756 && x2 <= 128764 || x2 >= 128992 && x2 <= 129003 || x2 === 129008 || x2 >= 129292 && x2 <= 129338 || x2 >= 129340 && x2 <= 129349 || x2 >= 129351 && x2 <= 129535 || x2 >= 129648 && x2 <= 129660 || x2 >= 129664 && x2 <= 129673 || x2 >= 129679 && x2 <= 129734 || x2 >= 129742 && x2 <= 129756 || x2 >= 129759 && x2 <= 129769 || x2 >= 129776 && x2 <= 129784 || x2 >= 131072 && x2 <= 196605 || x2 >= 196608 && x2 <= 262141;
|
|
1801
|
+
}
|
|
1802
|
+
function validate(codePoint) {
|
|
1803
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
1804
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
1808
|
+
validate(codePoint);
|
|
1809
|
+
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
1810
|
+
return 2;
|
|
1811
|
+
}
|
|
1812
|
+
return 1;
|
|
1813
|
+
}
|
|
1814
|
+
var emojiRegex = () => {
|
|
1815
|
+
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
1816
|
+
};
|
|
1817
|
+
var segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter : { segment: (str) => str.split("") };
|
|
1818
|
+
var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
1819
|
+
function stringWidth$1(string, options = {}) {
|
|
1820
|
+
if (typeof string !== "string" || string.length === 0) {
|
|
1821
|
+
return 0;
|
|
1822
|
+
}
|
|
1823
|
+
const {
|
|
1824
|
+
ambiguousIsNarrow = true,
|
|
1825
|
+
countAnsiEscapeCodes = false
|
|
1826
|
+
} = options;
|
|
1827
|
+
if (!countAnsiEscapeCodes) {
|
|
1828
|
+
string = stripAnsi2(string);
|
|
1829
|
+
}
|
|
1830
|
+
if (string.length === 0) {
|
|
1831
|
+
return 0;
|
|
1832
|
+
}
|
|
1833
|
+
let width = 0;
|
|
1834
|
+
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
1835
|
+
for (const { segment: character } of segmenter.segment(string)) {
|
|
1836
|
+
const codePoint = character.codePointAt(0);
|
|
1837
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
|
|
1841
|
+
continue;
|
|
1842
|
+
}
|
|
1843
|
+
if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
|
|
1844
|
+
continue;
|
|
1845
|
+
}
|
|
1846
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1849
|
+
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
1850
|
+
continue;
|
|
1851
|
+
}
|
|
1852
|
+
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
1853
|
+
continue;
|
|
1854
|
+
}
|
|
1855
|
+
if (emojiRegex().test(character)) {
|
|
1856
|
+
width += 2;
|
|
1857
|
+
continue;
|
|
1858
|
+
}
|
|
1859
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
1860
|
+
}
|
|
1861
|
+
return width;
|
|
1862
|
+
}
|
|
1863
|
+
function isUnicodeSupported() {
|
|
1864
|
+
const { env: env2 } = g$1;
|
|
1865
|
+
const { TERM, TERM_PROGRAM } = env2;
|
|
1866
|
+
if (g$1.platform !== "win32") {
|
|
1867
|
+
return TERM !== "linux";
|
|
1868
|
+
}
|
|
1869
|
+
return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1870
|
+
}
|
|
1871
|
+
var TYPE_COLOR_MAP = {
|
|
1872
|
+
info: "cyan",
|
|
1873
|
+
fail: "red",
|
|
1874
|
+
success: "green",
|
|
1875
|
+
ready: "green",
|
|
1876
|
+
start: "magenta"
|
|
1877
|
+
};
|
|
1878
|
+
var LEVEL_COLOR_MAP = {
|
|
1879
|
+
0: "red",
|
|
1880
|
+
1: "yellow"
|
|
1881
|
+
};
|
|
1882
|
+
var unicode = isUnicodeSupported();
|
|
1883
|
+
var s = (c3, fallback) => unicode ? c3 : fallback;
|
|
1884
|
+
var TYPE_ICONS = {
|
|
1885
|
+
error: s("\u2716", "\xD7"),
|
|
1886
|
+
fatal: s("\u2716", "\xD7"),
|
|
1887
|
+
ready: s("\u2714", "\u221A"),
|
|
1888
|
+
warn: s("\u26A0", "\u203C"),
|
|
1889
|
+
info: s("\u2139", "i"),
|
|
1890
|
+
success: s("\u2714", "\u221A"),
|
|
1891
|
+
debug: s("\u2699", "D"),
|
|
1892
|
+
trace: s("\u2192", "\u2192"),
|
|
1893
|
+
fail: s("\u2716", "\xD7"),
|
|
1894
|
+
start: s("\u25D0", "o"),
|
|
1895
|
+
log: ""
|
|
1896
|
+
};
|
|
1897
|
+
function stringWidth(str) {
|
|
1898
|
+
const hasICU = typeof Intl === "object";
|
|
1899
|
+
if (!hasICU || !Intl.Segmenter) {
|
|
1900
|
+
return stripAnsi(str).length;
|
|
1901
|
+
}
|
|
1902
|
+
return stringWidth$1(str);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
class FancyReporter extends BasicReporter {
|
|
1906
|
+
formatStack(stack, message, opts) {
|
|
1907
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
1908
|
+
return `
|
|
1909
|
+
${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m2) => colors.gray(m2)).replace(/\((.+)\)/, (_3, m2) => `(${colors.cyan(m2)})`)).join(`
|
|
1910
|
+
${indent}`);
|
|
1911
|
+
}
|
|
1912
|
+
formatType(logObj, isBadge, opts) {
|
|
1913
|
+
const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
|
|
1914
|
+
if (isBadge) {
|
|
1915
|
+
return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
|
|
1916
|
+
}
|
|
1917
|
+
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
1918
|
+
return _type ? getColor2(typeColor)(_type) : "";
|
|
1919
|
+
}
|
|
1920
|
+
formatLogObj(logObj, opts) {
|
|
1921
|
+
const [message, ...additional] = this.formatArgs(logObj.args, opts).split(`
|
|
1922
|
+
`);
|
|
1923
|
+
if (logObj.type === "box") {
|
|
1924
|
+
return box(characterFormat(message + (additional.length > 0 ? `
|
|
1925
|
+
` + additional.join(`
|
|
1926
|
+
`) : "")), {
|
|
1927
|
+
title: logObj.title ? characterFormat(logObj.title) : undefined,
|
|
1928
|
+
style: logObj.style
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
const date = this.formatDate(logObj.date, opts);
|
|
1932
|
+
const coloredDate = date && colors.gray(date);
|
|
1933
|
+
const isBadge = logObj.badge ?? logObj.level < 2;
|
|
1934
|
+
const type = this.formatType(logObj, isBadge, opts);
|
|
1935
|
+
const tag = logObj.tag ? colors.gray(logObj.tag) : "";
|
|
1936
|
+
let line;
|
|
1937
|
+
const left = this.filterAndJoin([type, characterFormat(message)]);
|
|
1938
|
+
const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
|
|
1939
|
+
const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
|
|
1940
|
+
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
|
|
1941
|
+
line += characterFormat(additional.length > 0 ? `
|
|
1942
|
+
` + additional.join(`
|
|
1943
|
+
`) : "");
|
|
1944
|
+
if (logObj.type === "trace") {
|
|
1945
|
+
const _err = new Error("Trace: " + logObj.message);
|
|
1946
|
+
line += this.formatStack(_err.stack || "", _err.message);
|
|
1947
|
+
}
|
|
1948
|
+
return isBadge ? `
|
|
1949
|
+
` + line + `
|
|
1950
|
+
` : line;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
function characterFormat(str) {
|
|
1954
|
+
return str.replace(/`([^`]+)`/gm, (_3, m2) => colors.cyan(m2)).replace(/\s+_([^_]+)_\s+/gm, (_3, m2) => ` ${colors.underline(m2)} `);
|
|
1955
|
+
}
|
|
1956
|
+
function getColor2(color = "white") {
|
|
1957
|
+
return colors[color] || colors.white;
|
|
1958
|
+
}
|
|
1959
|
+
function getBgColor(color = "bgWhite") {
|
|
1960
|
+
return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
|
|
1961
|
+
}
|
|
1962
|
+
function createConsola2(options = {}) {
|
|
1963
|
+
let level = _getDefaultLogLevel();
|
|
1964
|
+
if (process.env.CONSOLA_LEVEL) {
|
|
1965
|
+
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
1966
|
+
}
|
|
1967
|
+
const consola2 = createConsola({
|
|
1968
|
+
level,
|
|
1969
|
+
defaults: { level },
|
|
1970
|
+
stdout: process.stdout,
|
|
1971
|
+
stderr: process.stderr,
|
|
1972
|
+
prompt: (...args) => Promise.resolve().then(() => (init_prompt(), exports_prompt)).then((m2) => m2.prompt(...args)),
|
|
1973
|
+
reporters: options.reporters || [
|
|
1974
|
+
options.fancy ?? !(T2 || R2) ? new FancyReporter : new BasicReporter
|
|
1975
|
+
],
|
|
1976
|
+
...options
|
|
1977
|
+
});
|
|
1978
|
+
return consola2;
|
|
1979
|
+
}
|
|
1980
|
+
function _getDefaultLogLevel() {
|
|
1981
|
+
if (g2) {
|
|
1982
|
+
return LogLevels.debug;
|
|
1983
|
+
}
|
|
1984
|
+
if (R2) {
|
|
1985
|
+
return LogLevels.warn;
|
|
1986
|
+
}
|
|
1987
|
+
return LogLevels.info;
|
|
1988
|
+
}
|
|
1989
|
+
var consola = createConsola2();
|
|
1990
|
+
// node_modules/.bun/citty@0.1.6/node_modules/citty/dist/index.mjs
|
|
1991
|
+
function toArray(val) {
|
|
1992
|
+
if (Array.isArray(val)) {
|
|
1993
|
+
return val;
|
|
1994
|
+
}
|
|
1995
|
+
return val === undefined ? [] : [val];
|
|
1996
|
+
}
|
|
1997
|
+
function formatLineColumns(lines, linePrefix = "") {
|
|
1998
|
+
const maxLengh = [];
|
|
1999
|
+
for (const line of lines) {
|
|
2000
|
+
for (const [i2, element] of line.entries()) {
|
|
2001
|
+
maxLengh[i2] = Math.max(maxLengh[i2] || 0, element.length);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
return lines.map((l2) => l2.map((c3, i2) => linePrefix + c3[i2 === 0 ? "padStart" : "padEnd"](maxLengh[i2])).join(" ")).join(`
|
|
2005
|
+
`);
|
|
2006
|
+
}
|
|
2007
|
+
function resolveValue(input) {
|
|
2008
|
+
return typeof input === "function" ? input() : input;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
class CLIError extends Error {
|
|
2012
|
+
constructor(message, code) {
|
|
2013
|
+
super(message);
|
|
2014
|
+
this.code = code;
|
|
2015
|
+
this.name = "CLIError";
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
var NUMBER_CHAR_RE = /\d/;
|
|
2019
|
+
var STR_SPLITTERS = ["-", "_", "/", "."];
|
|
2020
|
+
function isUppercase(char = "") {
|
|
2021
|
+
if (NUMBER_CHAR_RE.test(char)) {
|
|
2022
|
+
return;
|
|
2023
|
+
}
|
|
2024
|
+
return char !== char.toLowerCase();
|
|
2025
|
+
}
|
|
2026
|
+
function splitByCase(str, separators) {
|
|
2027
|
+
const splitters = separators ?? STR_SPLITTERS;
|
|
2028
|
+
const parts = [];
|
|
2029
|
+
if (!str || typeof str !== "string") {
|
|
2030
|
+
return parts;
|
|
2031
|
+
}
|
|
2032
|
+
let buff = "";
|
|
2033
|
+
let previousUpper;
|
|
2034
|
+
let previousSplitter;
|
|
2035
|
+
for (const char of str) {
|
|
2036
|
+
const isSplitter = splitters.includes(char);
|
|
2037
|
+
if (isSplitter === true) {
|
|
2038
|
+
parts.push(buff);
|
|
2039
|
+
buff = "";
|
|
2040
|
+
previousUpper = undefined;
|
|
2041
|
+
continue;
|
|
2042
|
+
}
|
|
2043
|
+
const isUpper = isUppercase(char);
|
|
2044
|
+
if (previousSplitter === false) {
|
|
2045
|
+
if (previousUpper === false && isUpper === true) {
|
|
2046
|
+
parts.push(buff);
|
|
2047
|
+
buff = char;
|
|
2048
|
+
previousUpper = isUpper;
|
|
2049
|
+
continue;
|
|
2050
|
+
}
|
|
2051
|
+
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
2052
|
+
const lastChar = buff.at(-1);
|
|
2053
|
+
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
2054
|
+
buff = lastChar + char;
|
|
2055
|
+
previousUpper = isUpper;
|
|
2056
|
+
continue;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
buff += char;
|
|
2060
|
+
previousUpper = isUpper;
|
|
2061
|
+
previousSplitter = isSplitter;
|
|
2062
|
+
}
|
|
2063
|
+
parts.push(buff);
|
|
2064
|
+
return parts;
|
|
2065
|
+
}
|
|
2066
|
+
function upperFirst(str) {
|
|
2067
|
+
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
2068
|
+
}
|
|
2069
|
+
function lowerFirst(str) {
|
|
2070
|
+
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
2071
|
+
}
|
|
2072
|
+
function pascalCase(str, opts) {
|
|
2073
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
2074
|
+
}
|
|
2075
|
+
function camelCase(str, opts) {
|
|
2076
|
+
return lowerFirst(pascalCase(str || "", opts));
|
|
2077
|
+
}
|
|
2078
|
+
function kebabCase(str, joiner) {
|
|
2079
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
2080
|
+
}
|
|
2081
|
+
function toArr(any) {
|
|
2082
|
+
return any == undefined ? [] : Array.isArray(any) ? any : [any];
|
|
2083
|
+
}
|
|
2084
|
+
function toVal(out, key, val, opts) {
|
|
2085
|
+
let x2;
|
|
2086
|
+
const old = out[key];
|
|
2087
|
+
const nxt = ~opts.string.indexOf(key) ? val == undefined || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x2 = +val, x2 * 0 === 0) ? x2 : val), !!val) : (x2 = +val, x2 * 0 === 0) ? x2 : val;
|
|
2088
|
+
out[key] = old == undefined ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
2089
|
+
}
|
|
2090
|
+
function parseRawArgs(args = [], opts = {}) {
|
|
2091
|
+
let k2;
|
|
2092
|
+
let arr;
|
|
2093
|
+
let arg;
|
|
2094
|
+
let name;
|
|
2095
|
+
let val;
|
|
2096
|
+
const out = { _: [] };
|
|
2097
|
+
let i2 = 0;
|
|
2098
|
+
let j = 0;
|
|
2099
|
+
let idx = 0;
|
|
2100
|
+
const len = args.length;
|
|
2101
|
+
const alibi = opts.alias !== undefined;
|
|
2102
|
+
const strict = opts.unknown !== undefined;
|
|
2103
|
+
const defaults = opts.default !== undefined;
|
|
2104
|
+
opts.alias = opts.alias || {};
|
|
2105
|
+
opts.string = toArr(opts.string);
|
|
2106
|
+
opts.boolean = toArr(opts.boolean);
|
|
2107
|
+
if (alibi) {
|
|
2108
|
+
for (k2 in opts.alias) {
|
|
2109
|
+
arr = opts.alias[k2] = toArr(opts.alias[k2]);
|
|
2110
|
+
for (i2 = 0;i2 < arr.length; i2++) {
|
|
2111
|
+
(opts.alias[arr[i2]] = arr.concat(k2)).splice(i2, 1);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
for (i2 = opts.boolean.length;i2-- > 0; ) {
|
|
2116
|
+
arr = opts.alias[opts.boolean[i2]] || [];
|
|
2117
|
+
for (j = arr.length;j-- > 0; ) {
|
|
2118
|
+
opts.boolean.push(arr[j]);
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
for (i2 = opts.string.length;i2-- > 0; ) {
|
|
2122
|
+
arr = opts.alias[opts.string[i2]] || [];
|
|
2123
|
+
for (j = arr.length;j-- > 0; ) {
|
|
2124
|
+
opts.string.push(arr[j]);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
if (defaults) {
|
|
2128
|
+
for (k2 in opts.default) {
|
|
2129
|
+
name = typeof opts.default[k2];
|
|
2130
|
+
arr = opts.alias[k2] = opts.alias[k2] || [];
|
|
2131
|
+
if (opts[name] !== undefined) {
|
|
2132
|
+
opts[name].push(k2);
|
|
2133
|
+
for (i2 = 0;i2 < arr.length; i2++) {
|
|
2134
|
+
opts[name].push(arr[i2]);
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
2140
|
+
for (i2 = 0;i2 < len; i2++) {
|
|
2141
|
+
arg = args[i2];
|
|
2142
|
+
if (arg === "--") {
|
|
2143
|
+
out._ = out._.concat(args.slice(++i2));
|
|
2144
|
+
break;
|
|
2145
|
+
}
|
|
2146
|
+
for (j = 0;j < arg.length; j++) {
|
|
2147
|
+
if (arg.charCodeAt(j) !== 45) {
|
|
2148
|
+
break;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
if (j === 0) {
|
|
2152
|
+
out._.push(arg);
|
|
2153
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
2154
|
+
name = arg.slice(Math.max(0, j + 3));
|
|
2155
|
+
if (strict && !~keys.indexOf(name)) {
|
|
2156
|
+
return opts.unknown(arg);
|
|
2157
|
+
}
|
|
2158
|
+
out[name] = false;
|
|
2159
|
+
} else {
|
|
2160
|
+
for (idx = j + 1;idx < arg.length; idx++) {
|
|
2161
|
+
if (arg.charCodeAt(idx) === 61) {
|
|
2162
|
+
break;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
name = arg.substring(j, idx);
|
|
2166
|
+
val = arg.slice(Math.max(0, ++idx)) || i2 + 1 === len || ("" + args[i2 + 1]).charCodeAt(0) === 45 || args[++i2];
|
|
2167
|
+
arr = j === 2 ? [name] : name;
|
|
2168
|
+
for (idx = 0;idx < arr.length; idx++) {
|
|
2169
|
+
name = arr[idx];
|
|
2170
|
+
if (strict && !~keys.indexOf(name)) {
|
|
2171
|
+
return opts.unknown("-".repeat(j) + name);
|
|
2172
|
+
}
|
|
2173
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
if (defaults) {
|
|
2178
|
+
for (k2 in opts.default) {
|
|
2179
|
+
if (out[k2] === undefined) {
|
|
2180
|
+
out[k2] = opts.default[k2];
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
if (alibi) {
|
|
2185
|
+
for (k2 in out) {
|
|
2186
|
+
arr = opts.alias[k2] || [];
|
|
2187
|
+
while (arr.length > 0) {
|
|
2188
|
+
out[arr.shift()] = out[k2];
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
return out;
|
|
2193
|
+
}
|
|
2194
|
+
function parseArgs(rawArgs, argsDef) {
|
|
2195
|
+
const parseOptions = {
|
|
2196
|
+
boolean: [],
|
|
2197
|
+
string: [],
|
|
2198
|
+
mixed: [],
|
|
2199
|
+
alias: {},
|
|
2200
|
+
default: {}
|
|
2201
|
+
};
|
|
2202
|
+
const args = resolveArgs(argsDef);
|
|
2203
|
+
for (const arg of args) {
|
|
2204
|
+
if (arg.type === "positional") {
|
|
2205
|
+
continue;
|
|
2206
|
+
}
|
|
2207
|
+
if (arg.type === "string") {
|
|
2208
|
+
parseOptions.string.push(arg.name);
|
|
2209
|
+
} else if (arg.type === "boolean") {
|
|
2210
|
+
parseOptions.boolean.push(arg.name);
|
|
2211
|
+
}
|
|
2212
|
+
if (arg.default !== undefined) {
|
|
2213
|
+
parseOptions.default[arg.name] = arg.default;
|
|
2214
|
+
}
|
|
2215
|
+
if (arg.alias) {
|
|
2216
|
+
parseOptions.alias[arg.name] = arg.alias;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
const parsed = parseRawArgs(rawArgs, parseOptions);
|
|
2220
|
+
const [...positionalArguments] = parsed._;
|
|
2221
|
+
const parsedArgsProxy = new Proxy(parsed, {
|
|
2222
|
+
get(target, prop) {
|
|
2223
|
+
return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
|
|
2224
|
+
}
|
|
2225
|
+
});
|
|
2226
|
+
for (const [, arg] of args.entries()) {
|
|
2227
|
+
if (arg.type === "positional") {
|
|
2228
|
+
const nextPositionalArgument = positionalArguments.shift();
|
|
2229
|
+
if (nextPositionalArgument !== undefined) {
|
|
2230
|
+
parsedArgsProxy[arg.name] = nextPositionalArgument;
|
|
2231
|
+
} else if (arg.default === undefined && arg.required !== false) {
|
|
2232
|
+
throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
|
|
2233
|
+
} else {
|
|
2234
|
+
parsedArgsProxy[arg.name] = arg.default;
|
|
2235
|
+
}
|
|
2236
|
+
} else if (arg.required && parsedArgsProxy[arg.name] === undefined) {
|
|
2237
|
+
throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
return parsedArgsProxy;
|
|
2241
|
+
}
|
|
2242
|
+
function resolveArgs(argsDef) {
|
|
2243
|
+
const args = [];
|
|
2244
|
+
for (const [name, argDef] of Object.entries(argsDef || {})) {
|
|
2245
|
+
args.push({
|
|
2246
|
+
...argDef,
|
|
2247
|
+
name,
|
|
2248
|
+
alias: toArray(argDef.alias)
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
return args;
|
|
2252
|
+
}
|
|
2253
|
+
function defineCommand(def) {
|
|
2254
|
+
return def;
|
|
2255
|
+
}
|
|
2256
|
+
async function runCommand(cmd, opts) {
|
|
2257
|
+
const cmdArgs = await resolveValue(cmd.args || {});
|
|
2258
|
+
const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
|
|
2259
|
+
const context = {
|
|
2260
|
+
rawArgs: opts.rawArgs,
|
|
2261
|
+
args: parsedArgs,
|
|
2262
|
+
data: opts.data,
|
|
2263
|
+
cmd
|
|
2264
|
+
};
|
|
2265
|
+
if (typeof cmd.setup === "function") {
|
|
2266
|
+
await cmd.setup(context);
|
|
2267
|
+
}
|
|
2268
|
+
let result;
|
|
2269
|
+
try {
|
|
2270
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
2271
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
2272
|
+
const subCommandArgIndex = opts.rawArgs.findIndex((arg) => !arg.startsWith("-"));
|
|
2273
|
+
const subCommandName = opts.rawArgs[subCommandArgIndex];
|
|
2274
|
+
if (subCommandName) {
|
|
2275
|
+
if (!subCommands[subCommandName]) {
|
|
2276
|
+
throw new CLIError(`Unknown command \`${subCommandName}\``, "E_UNKNOWN_COMMAND");
|
|
2277
|
+
}
|
|
2278
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
2279
|
+
if (subCommand) {
|
|
2280
|
+
await runCommand(subCommand, {
|
|
2281
|
+
rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1)
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
} else if (!cmd.run) {
|
|
2285
|
+
throw new CLIError(`No command specified.`, "E_NO_COMMAND");
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
if (typeof cmd.run === "function") {
|
|
2289
|
+
result = await cmd.run(context);
|
|
2290
|
+
}
|
|
2291
|
+
} finally {
|
|
2292
|
+
if (typeof cmd.cleanup === "function") {
|
|
2293
|
+
await cmd.cleanup(context);
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
return { result };
|
|
2297
|
+
}
|
|
2298
|
+
async function resolveSubCommand(cmd, rawArgs, parent) {
|
|
2299
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
2300
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
2301
|
+
const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
|
|
2302
|
+
const subCommandName = rawArgs[subCommandArgIndex];
|
|
2303
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
2304
|
+
if (subCommand) {
|
|
2305
|
+
return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
return [cmd, parent];
|
|
2309
|
+
}
|
|
2310
|
+
async function showUsage(cmd, parent) {
|
|
2311
|
+
try {
|
|
2312
|
+
consola.log(await renderUsage(cmd, parent) + `
|
|
2313
|
+
`);
|
|
2314
|
+
} catch (error) {
|
|
2315
|
+
consola.error(error);
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
async function renderUsage(cmd, parent) {
|
|
2319
|
+
const cmdMeta = await resolveValue(cmd.meta || {});
|
|
2320
|
+
const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
|
|
2321
|
+
const parentMeta = await resolveValue(parent?.meta || {});
|
|
2322
|
+
const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
|
|
2323
|
+
const argLines = [];
|
|
2324
|
+
const posLines = [];
|
|
2325
|
+
const commandsLines = [];
|
|
2326
|
+
const usageLine = [];
|
|
2327
|
+
for (const arg of cmdArgs) {
|
|
2328
|
+
if (arg.type === "positional") {
|
|
2329
|
+
const name = arg.name.toUpperCase();
|
|
2330
|
+
const isRequired = arg.required !== false && arg.default === undefined;
|
|
2331
|
+
const defaultHint = arg.default ? `="${arg.default}"` : "";
|
|
2332
|
+
posLines.push([
|
|
2333
|
+
"`" + name + defaultHint + "`",
|
|
2334
|
+
arg.description || "",
|
|
2335
|
+
arg.valueHint ? `<${arg.valueHint}>` : ""
|
|
2336
|
+
]);
|
|
2337
|
+
usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
|
|
2338
|
+
} else {
|
|
2339
|
+
const isRequired = arg.required === true && arg.default === undefined;
|
|
2340
|
+
const argStr = (arg.type === "boolean" && arg.default === true ? [
|
|
2341
|
+
...(arg.alias || []).map((a2) => `--no-${a2}`),
|
|
2342
|
+
`--no-${arg.name}`
|
|
2343
|
+
].join(", ") : [...(arg.alias || []).map((a2) => `-${a2}`), `--${arg.name}`].join(", ")) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
|
|
2344
|
+
argLines.push([
|
|
2345
|
+
"`" + argStr + (isRequired ? " (required)" : "") + "`",
|
|
2346
|
+
arg.description || ""
|
|
2347
|
+
]);
|
|
2348
|
+
if (isRequired) {
|
|
2349
|
+
usageLine.push(argStr);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
if (cmd.subCommands) {
|
|
2354
|
+
const commandNames = [];
|
|
2355
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
2356
|
+
for (const [name, sub] of Object.entries(subCommands)) {
|
|
2357
|
+
const subCmd = await resolveValue(sub);
|
|
2358
|
+
const meta = await resolveValue(subCmd?.meta);
|
|
2359
|
+
commandsLines.push([`\`${name}\``, meta?.description || ""]);
|
|
2360
|
+
commandNames.push(name);
|
|
2361
|
+
}
|
|
2362
|
+
usageLine.push(commandNames.join("|"));
|
|
2363
|
+
}
|
|
2364
|
+
const usageLines = [];
|
|
2365
|
+
const version = cmdMeta.version || parentMeta.version;
|
|
2366
|
+
usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
|
|
2367
|
+
const hasOptions = argLines.length > 0 || posLines.length > 0;
|
|
2368
|
+
usageLines.push(`${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``, "");
|
|
2369
|
+
if (posLines.length > 0) {
|
|
2370
|
+
usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
|
|
2371
|
+
usageLines.push(formatLineColumns(posLines, " "));
|
|
2372
|
+
usageLines.push("");
|
|
2373
|
+
}
|
|
2374
|
+
if (argLines.length > 0) {
|
|
2375
|
+
usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
|
|
2376
|
+
usageLines.push(formatLineColumns(argLines, " "));
|
|
2377
|
+
usageLines.push("");
|
|
2378
|
+
}
|
|
2379
|
+
if (commandsLines.length > 0) {
|
|
2380
|
+
usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
|
|
2381
|
+
usageLines.push(formatLineColumns(commandsLines, " "));
|
|
2382
|
+
usageLines.push("", `Use \`${commandName} <command> --help\` for more information about a command.`);
|
|
2383
|
+
}
|
|
2384
|
+
return usageLines.filter((l2) => typeof l2 === "string").join(`
|
|
2385
|
+
`);
|
|
2386
|
+
}
|
|
2387
|
+
async function runMain(cmd, opts = {}) {
|
|
2388
|
+
const rawArgs = opts.rawArgs || process.argv.slice(2);
|
|
2389
|
+
const showUsage$1 = opts.showUsage || showUsage;
|
|
2390
|
+
try {
|
|
2391
|
+
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
2392
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
2393
|
+
process.exit(0);
|
|
2394
|
+
} else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
|
|
2395
|
+
const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
|
|
2396
|
+
if (!meta?.version) {
|
|
2397
|
+
throw new CLIError("No version specified", "E_NO_VERSION");
|
|
2398
|
+
}
|
|
2399
|
+
consola.log(meta.version);
|
|
2400
|
+
} else {
|
|
2401
|
+
await runCommand(cmd, { rawArgs });
|
|
2402
|
+
}
|
|
2403
|
+
} catch (error) {
|
|
2404
|
+
const isCLIError = error instanceof CLIError;
|
|
2405
|
+
if (!isCLIError) {
|
|
2406
|
+
consola.error(error, `
|
|
2407
|
+
`);
|
|
2408
|
+
}
|
|
2409
|
+
if (isCLIError) {
|
|
2410
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
2411
|
+
}
|
|
2412
|
+
consola.error(error.message);
|
|
2413
|
+
process.exit(1);
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
// packages/cli/src/commands/index.ts
|
|
2418
|
+
var exports_commands = {};
|
|
2419
|
+
__export(exports_commands, {
|
|
2420
|
+
"zoom-to-fit": () => zoom_to_fit_default,
|
|
2421
|
+
"union-nodes": () => union_nodes_default,
|
|
2422
|
+
"ungroup-node": () => ungroup_node_default,
|
|
2423
|
+
"subtract-nodes": () => subtract_nodes_default,
|
|
2424
|
+
status: () => status_default,
|
|
2425
|
+
"set-visible": () => set_visible_default,
|
|
2426
|
+
"set-viewport": () => set_viewport_default,
|
|
2427
|
+
"set-text-properties": () => set_text_properties_default,
|
|
2428
|
+
"set-text": () => set_text_default,
|
|
2429
|
+
"set-stroke-color": () => set_stroke_color_default,
|
|
2430
|
+
"set-stroke-align": () => set_stroke_align_default,
|
|
2431
|
+
"set-rotation": () => set_rotation_default,
|
|
2432
|
+
"set-parent": () => set_parent_default,
|
|
2433
|
+
"set-opacity": () => set_opacity_default,
|
|
2434
|
+
"set-min-max": () => set_min_max_default,
|
|
2435
|
+
"set-locked": () => set_locked_default,
|
|
2436
|
+
"set-layout-child": () => set_layout_child_default,
|
|
2437
|
+
"set-layout": () => set_layout_default,
|
|
2438
|
+
"set-instance-properties": () => set_instance_properties_default,
|
|
2439
|
+
"set-image-fill": () => set_image_fill_default,
|
|
2440
|
+
"set-font": () => set_font_default,
|
|
2441
|
+
"set-fill-color": () => set_fill_color_default,
|
|
2442
|
+
"set-effect": () => set_effect_default,
|
|
2443
|
+
"set-current-page": () => set_current_page_default,
|
|
2444
|
+
"set-corner-radius": () => set_corner_radius_default,
|
|
2445
|
+
"set-constraints": () => set_constraints_default,
|
|
2446
|
+
"set-component-property-refs": () => set_component_property_refs_default,
|
|
2447
|
+
"set-blend-mode": () => set_blend_mode_default,
|
|
2448
|
+
"set-auto-layout": () => set_auto_layout_default,
|
|
2449
|
+
"select-nodes": () => select_nodes_default,
|
|
2450
|
+
screenshot: () => screenshot_default,
|
|
2451
|
+
"resize-node": () => resize_node_default,
|
|
2452
|
+
"rename-node": () => rename_node_default,
|
|
2453
|
+
"move-node": () => move_node_default,
|
|
2454
|
+
"intersect-nodes": () => intersect_nodes_default,
|
|
2455
|
+
"import-svg": () => import_svg_default,
|
|
2456
|
+
"group-nodes": () => group_nodes_default,
|
|
2457
|
+
"get-viewport": () => get_viewport_default,
|
|
2458
|
+
"get-selection": () => get_selection_default,
|
|
2459
|
+
"get-pages": () => get_pages_default,
|
|
2460
|
+
"get-node": () => get_node_default,
|
|
2461
|
+
"get-local-styles": () => get_local_styles_default,
|
|
2462
|
+
"get-components": () => get_components_default,
|
|
2463
|
+
"get-children": () => get_children_default,
|
|
2464
|
+
"flatten-nodes": () => flatten_nodes_default,
|
|
2465
|
+
"find-by-name": () => find_by_name_default,
|
|
2466
|
+
"export-selection": () => export_selection_default,
|
|
2467
|
+
"export-node": () => export_node_default,
|
|
2468
|
+
"exclude-nodes": () => exclude_nodes_default,
|
|
2469
|
+
"edit-component-property": () => edit_component_property_default,
|
|
2470
|
+
"delete-node": () => delete_node_default,
|
|
2471
|
+
"delete-component-property": () => delete_component_property_default,
|
|
2472
|
+
"create-vector": () => create_vector_default,
|
|
2473
|
+
"create-text-style": () => create_text_style_default,
|
|
2474
|
+
"create-text": () => create_text_default,
|
|
2475
|
+
"create-star": () => create_star_default,
|
|
2476
|
+
"create-slice": () => create_slice_default,
|
|
2477
|
+
"create-section": () => create_section_default,
|
|
2478
|
+
"create-rectangle": () => create_rectangle_default,
|
|
2479
|
+
"create-polygon": () => create_polygon_default,
|
|
2480
|
+
"create-paint-style": () => create_paint_style_default,
|
|
2481
|
+
"create-page": () => create_page_default,
|
|
2482
|
+
"create-line": () => create_line_default,
|
|
2483
|
+
"create-instance": () => create_instance_default,
|
|
2484
|
+
"create-frame": () => create_frame_default,
|
|
2485
|
+
"create-ellipse": () => create_ellipse_default,
|
|
2486
|
+
"create-effect-style": () => create_effect_style_default,
|
|
2487
|
+
"create-component": () => create_component_default,
|
|
2488
|
+
"clone-node": () => clone_node_default,
|
|
2489
|
+
"add-component-property": () => add_component_property_default
|
|
2490
|
+
});
|
|
2491
|
+
|
|
2492
|
+
// packages/cli/src/client.ts
|
|
2493
|
+
init_output();
|
|
2494
|
+
var PROXY_URL = process.env.FIGMA_PROXY_URL || "http://localhost:38451";
|
|
2495
|
+
async function sendCommand(command, args) {
|
|
2496
|
+
const response = await fetch(`${PROXY_URL}/command`, {
|
|
2497
|
+
method: "POST",
|
|
2498
|
+
headers: { "Content-Type": "application/json" },
|
|
2499
|
+
body: JSON.stringify({ command, args })
|
|
2500
|
+
});
|
|
2501
|
+
const data = await response.json();
|
|
2502
|
+
if (data.error) {
|
|
2503
|
+
throw new Error(data.error);
|
|
2504
|
+
}
|
|
2505
|
+
return data.result;
|
|
2506
|
+
}
|
|
2507
|
+
async function getStatus() {
|
|
2508
|
+
const response = await fetch(`${PROXY_URL}/status`);
|
|
2509
|
+
return response.json();
|
|
2510
|
+
}
|
|
2511
|
+
function handleError(error) {
|
|
2512
|
+
const { printError: printError2 } = (init_output(), __toCommonJS(exports_output));
|
|
2513
|
+
printError2(error);
|
|
2514
|
+
process.exit(1);
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
// packages/cli/src/commands/status.ts
|
|
2518
|
+
var status_default = defineCommand({
|
|
2519
|
+
meta: { description: "Check if plugin is connected" },
|
|
2520
|
+
args: { json: { type: "boolean", description: "Output as JSON" } },
|
|
2521
|
+
async run({ args }) {
|
|
2522
|
+
try {
|
|
2523
|
+
const status = await getStatus();
|
|
2524
|
+
console.log(status.pluginConnected ? "\u2713 Plugin connected" : "\u2717 Plugin not connected");
|
|
2525
|
+
} catch {
|
|
2526
|
+
console.log("\u2717 Proxy not running");
|
|
2527
|
+
process.exit(1);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
});
|
|
2531
|
+
// packages/cli/src/commands/get-pages.ts
|
|
2532
|
+
var get_pages_default = defineCommand({
|
|
2533
|
+
meta: { description: "Get all pages" },
|
|
2534
|
+
args: { json: { type: "boolean", description: "Output as JSON" } },
|
|
2535
|
+
async run({ args }) {
|
|
2536
|
+
try {
|
|
2537
|
+
const result = await sendCommand("get-pages");
|
|
2538
|
+
printResult(result, args.json, "get");
|
|
2539
|
+
} catch (e2) {
|
|
2540
|
+
handleError(e2);
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
// packages/cli/src/commands/get-selection.ts
|
|
2545
|
+
var get_selection_default = defineCommand({
|
|
2546
|
+
meta: { description: "Get current selection" },
|
|
2547
|
+
args: { json: { type: "boolean", description: "Output as JSON" } },
|
|
2548
|
+
async run({ args }) {
|
|
2549
|
+
try {
|
|
2550
|
+
const result = await sendCommand("get-selection");
|
|
2551
|
+
printResult(result, args.json, "get");
|
|
2552
|
+
} catch (e2) {
|
|
2553
|
+
handleError(e2);
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
// packages/cli/src/commands/get-node.ts
|
|
2558
|
+
var get_node_default = defineCommand({
|
|
2559
|
+
meta: { description: "Get node info" },
|
|
2560
|
+
args: {
|
|
2561
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2562
|
+
id: { type: "string", description: "Node ID", required: true }
|
|
2563
|
+
},
|
|
2564
|
+
async run({ args }) {
|
|
2565
|
+
try {
|
|
2566
|
+
const result = await sendCommand("get-node-info", { id: args.id });
|
|
2567
|
+
printResult(result, args.json, "get");
|
|
2568
|
+
} catch (e2) {
|
|
2569
|
+
handleError(e2);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
});
|
|
2573
|
+
// packages/cli/src/commands/get-components.ts
|
|
2574
|
+
var get_components_default = defineCommand({
|
|
2575
|
+
meta: { description: "Get all components" },
|
|
2576
|
+
args: { json: { type: "boolean", description: "Output as JSON" } },
|
|
2577
|
+
async run({ args }) {
|
|
2578
|
+
try {
|
|
2579
|
+
const result = await sendCommand("get-all-components");
|
|
2580
|
+
printResult(result, args.json, "get");
|
|
2581
|
+
} catch (e2) {
|
|
2582
|
+
handleError(e2);
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
});
|
|
2586
|
+
// packages/cli/src/commands/get-local-styles.ts
|
|
2587
|
+
var get_local_styles_default = defineCommand({
|
|
2588
|
+
meta: { description: "Get local styles (paint, text, effect, grid)" },
|
|
2589
|
+
args: {
|
|
2590
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2591
|
+
type: { type: "string", description: "Style type: paint, text, effect, grid, or all", default: "all" }
|
|
2592
|
+
},
|
|
2593
|
+
async run({ args }) {
|
|
2594
|
+
try {
|
|
2595
|
+
const result = await sendCommand("get-local-styles", { type: args.type });
|
|
2596
|
+
printResult(result, args.json, "get");
|
|
2597
|
+
} catch (e2) {
|
|
2598
|
+
handleError(e2);
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
});
|
|
2602
|
+
// packages/cli/src/commands/get-viewport.ts
|
|
2603
|
+
var get_viewport_default = defineCommand({
|
|
2604
|
+
meta: { description: "Get current viewport position and zoom" },
|
|
2605
|
+
args: { json: { type: "boolean", description: "Output as JSON" } },
|
|
2606
|
+
async run({ args }) {
|
|
2607
|
+
try {
|
|
2608
|
+
const result = await sendCommand("get-viewport");
|
|
2609
|
+
printResult(result, args.json, "get");
|
|
2610
|
+
} catch (e2) {
|
|
2611
|
+
handleError(e2);
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
});
|
|
2615
|
+
// packages/cli/src/commands/create-rectangle.ts
|
|
2616
|
+
var create_rectangle_default = defineCommand({
|
|
2617
|
+
meta: { description: "Create a rectangle" },
|
|
2618
|
+
args: {
|
|
2619
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2620
|
+
x: { type: "string", description: "X coordinate", required: true },
|
|
2621
|
+
y: { type: "string", description: "Y coordinate", required: true },
|
|
2622
|
+
width: { type: "string", description: "Width", required: true },
|
|
2623
|
+
height: { type: "string", description: "Height", required: true },
|
|
2624
|
+
name: { type: "string", description: "Name" },
|
|
2625
|
+
parentId: { type: "string", description: "Parent node ID" },
|
|
2626
|
+
fill: { type: "string", description: "Fill color (hex)" },
|
|
2627
|
+
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
2628
|
+
strokeWeight: { type: "string", description: "Stroke weight" },
|
|
2629
|
+
radius: { type: "string", description: "Corner radius" },
|
|
2630
|
+
opacity: { type: "string", description: "Opacity (0-1)" }
|
|
2631
|
+
},
|
|
2632
|
+
async run({ args }) {
|
|
2633
|
+
try {
|
|
2634
|
+
const result = await sendCommand("create-rectangle", {
|
|
2635
|
+
x: Number(args.x),
|
|
2636
|
+
y: Number(args.y),
|
|
2637
|
+
width: Number(args.width),
|
|
2638
|
+
height: Number(args.height),
|
|
2639
|
+
name: args.name,
|
|
2640
|
+
parentId: args.parentId,
|
|
2641
|
+
fill: args.fill,
|
|
2642
|
+
stroke: args.stroke,
|
|
2643
|
+
strokeWeight: args.strokeWeight ? Number(args.strokeWeight) : undefined,
|
|
2644
|
+
radius: args.radius ? Number(args.radius) : undefined,
|
|
2645
|
+
opacity: args.opacity ? Number(args.opacity) : undefined
|
|
2646
|
+
});
|
|
2647
|
+
printResult(result, args.json, "create");
|
|
2648
|
+
} catch (e2) {
|
|
2649
|
+
handleError(e2);
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
// packages/cli/src/commands/create-ellipse.ts
|
|
2654
|
+
var create_ellipse_default = defineCommand({
|
|
2655
|
+
meta: { description: "Create an ellipse" },
|
|
2656
|
+
args: {
|
|
2657
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2658
|
+
x: { type: "string", description: "X position", required: true },
|
|
2659
|
+
y: { type: "string", description: "Y position", required: true },
|
|
2660
|
+
width: { type: "string", description: "Width", required: true },
|
|
2661
|
+
height: { type: "string", description: "Height", required: true },
|
|
2662
|
+
name: { type: "string", description: "Node name" },
|
|
2663
|
+
parentId: { type: "string", description: "Parent node ID" },
|
|
2664
|
+
fill: { type: "string", description: "Fill color (hex)" },
|
|
2665
|
+
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
2666
|
+
strokeWeight: { type: "string", description: "Stroke weight" },
|
|
2667
|
+
opacity: { type: "string", description: "Opacity (0-1)" }
|
|
2668
|
+
},
|
|
2669
|
+
async run({ args }) {
|
|
2670
|
+
try {
|
|
2671
|
+
const result = await sendCommand("create-ellipse", {
|
|
2672
|
+
x: Number(args.x),
|
|
2673
|
+
y: Number(args.y),
|
|
2674
|
+
width: Number(args.width),
|
|
2675
|
+
height: Number(args.height),
|
|
2676
|
+
name: args.name,
|
|
2677
|
+
parentId: args.parentId,
|
|
2678
|
+
fill: args.fill,
|
|
2679
|
+
stroke: args.stroke,
|
|
2680
|
+
strokeWeight: args.strokeWeight ? Number(args.strokeWeight) : undefined,
|
|
2681
|
+
opacity: args.opacity ? Number(args.opacity) : undefined
|
|
2682
|
+
});
|
|
2683
|
+
printResult(result, args.json, "create");
|
|
2684
|
+
} catch (e2) {
|
|
2685
|
+
handleError(e2);
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
});
|
|
2689
|
+
// packages/cli/src/commands/create-line.ts
|
|
2690
|
+
var create_line_default = defineCommand({
|
|
2691
|
+
meta: { description: "Create a line" },
|
|
2692
|
+
args: {
|
|
2693
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2694
|
+
x: { type: "string", description: "X position", required: true },
|
|
2695
|
+
y: { type: "string", description: "Y position", required: true },
|
|
2696
|
+
length: { type: "string", description: "Line length", required: true },
|
|
2697
|
+
rotation: { type: "string", description: "Rotation in degrees", default: "0" },
|
|
2698
|
+
name: { type: "string", description: "Node name" },
|
|
2699
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
2700
|
+
},
|
|
2701
|
+
async run({ args }) {
|
|
2702
|
+
try {
|
|
2703
|
+
const result = await sendCommand("create-line", {
|
|
2704
|
+
x: Number(args.x),
|
|
2705
|
+
y: Number(args.y),
|
|
2706
|
+
length: Number(args.length),
|
|
2707
|
+
rotation: Number(args.rotation),
|
|
2708
|
+
name: args.name,
|
|
2709
|
+
parentId: args.parentId
|
|
2710
|
+
});
|
|
2711
|
+
printResult(result, args.json, "create");
|
|
2712
|
+
} catch (e2) {
|
|
2713
|
+
handleError(e2);
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
});
|
|
2717
|
+
// packages/cli/src/commands/create-polygon.ts
|
|
2718
|
+
var create_polygon_default = defineCommand({
|
|
2719
|
+
meta: { description: "Create a polygon" },
|
|
2720
|
+
args: {
|
|
2721
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2722
|
+
x: { type: "string", description: "X position", required: true },
|
|
2723
|
+
y: { type: "string", description: "Y position", required: true },
|
|
2724
|
+
size: { type: "string", description: "Size", required: true },
|
|
2725
|
+
sides: { type: "string", description: "Number of sides", default: "3" },
|
|
2726
|
+
name: { type: "string", description: "Node name" },
|
|
2727
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
2728
|
+
},
|
|
2729
|
+
async run({ args }) {
|
|
2730
|
+
try {
|
|
2731
|
+
const result = await sendCommand("create-polygon", {
|
|
2732
|
+
x: Number(args.x),
|
|
2733
|
+
y: Number(args.y),
|
|
2734
|
+
size: Number(args.size),
|
|
2735
|
+
sides: Number(args.sides),
|
|
2736
|
+
name: args.name,
|
|
2737
|
+
parentId: args.parentId
|
|
2738
|
+
});
|
|
2739
|
+
printResult(result, args.json, "create");
|
|
2740
|
+
} catch (e2) {
|
|
2741
|
+
handleError(e2);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
// packages/cli/src/commands/create-star.ts
|
|
2746
|
+
var create_star_default = defineCommand({
|
|
2747
|
+
meta: { description: "Create a star" },
|
|
2748
|
+
args: {
|
|
2749
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2750
|
+
x: { type: "string", description: "X position", required: true },
|
|
2751
|
+
y: { type: "string", description: "Y position", required: true },
|
|
2752
|
+
size: { type: "string", description: "Size", required: true },
|
|
2753
|
+
points: { type: "string", description: "Number of points", default: "5" },
|
|
2754
|
+
innerRadius: { type: "string", description: "Inner radius ratio (0-1)", default: "0.5" },
|
|
2755
|
+
name: { type: "string", description: "Node name" },
|
|
2756
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
2757
|
+
},
|
|
2758
|
+
async run({ args }) {
|
|
2759
|
+
try {
|
|
2760
|
+
const result = await sendCommand("create-star", {
|
|
2761
|
+
x: Number(args.x),
|
|
2762
|
+
y: Number(args.y),
|
|
2763
|
+
size: Number(args.size),
|
|
2764
|
+
points: Number(args.points),
|
|
2765
|
+
innerRadius: Number(args.innerRadius),
|
|
2766
|
+
name: args.name,
|
|
2767
|
+
parentId: args.parentId
|
|
2768
|
+
});
|
|
2769
|
+
printResult(result, args.json, "create");
|
|
2770
|
+
} catch (e2) {
|
|
2771
|
+
handleError(e2);
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
});
|
|
2775
|
+
// packages/cli/src/commands/create-vector.ts
|
|
2776
|
+
var create_vector_default = defineCommand({
|
|
2777
|
+
meta: { description: "Create a vector from SVG path" },
|
|
2778
|
+
args: {
|
|
2779
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2780
|
+
x: { type: "string", description: "X position", required: true },
|
|
2781
|
+
y: { type: "string", description: "Y position", required: true },
|
|
2782
|
+
path: { type: "string", description: "SVG path data", required: true },
|
|
2783
|
+
name: { type: "string", description: "Node name" },
|
|
2784
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
2785
|
+
},
|
|
2786
|
+
async run({ args }) {
|
|
2787
|
+
try {
|
|
2788
|
+
const result = await sendCommand("create-vector", {
|
|
2789
|
+
x: Number(args.x),
|
|
2790
|
+
y: Number(args.y),
|
|
2791
|
+
path: args.path,
|
|
2792
|
+
name: args.name,
|
|
2793
|
+
parentId: args.parentId
|
|
2794
|
+
});
|
|
2795
|
+
printResult(result, args.json, "create");
|
|
2796
|
+
} catch (e2) {
|
|
2797
|
+
handleError(e2);
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
});
|
|
2801
|
+
// packages/cli/src/commands/create-frame.ts
|
|
2802
|
+
var create_frame_default = defineCommand({
|
|
2803
|
+
meta: { description: "Create a frame" },
|
|
2804
|
+
args: {
|
|
2805
|
+
x: { type: "string", description: "X coordinate", required: true },
|
|
2806
|
+
y: { type: "string", description: "Y coordinate", required: true },
|
|
2807
|
+
width: { type: "string", description: "Width", required: true },
|
|
2808
|
+
height: { type: "string", description: "Height", required: true },
|
|
2809
|
+
name: { type: "string", description: "Name" },
|
|
2810
|
+
parentId: { type: "string", description: "Parent node ID" },
|
|
2811
|
+
fill: { type: "string", description: "Fill color (hex)" },
|
|
2812
|
+
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
2813
|
+
strokeWeight: { type: "string", description: "Stroke weight" },
|
|
2814
|
+
radius: { type: "string", description: "Corner radius" },
|
|
2815
|
+
opacity: { type: "string", description: "Opacity (0-1)" },
|
|
2816
|
+
layoutMode: { type: "string", description: "Layout mode: HORIZONTAL, VERTICAL, NONE" },
|
|
2817
|
+
itemSpacing: { type: "string", description: "Item spacing" },
|
|
2818
|
+
padding: { type: "string", description: 'Padding (single value or "top,right,bottom,left")' },
|
|
2819
|
+
json: { type: "boolean", description: "Output as JSON" }
|
|
2820
|
+
},
|
|
2821
|
+
async run({ args }) {
|
|
2822
|
+
try {
|
|
2823
|
+
let paddingObj;
|
|
2824
|
+
if (args.padding) {
|
|
2825
|
+
const parts = args.padding.split(",").map(Number);
|
|
2826
|
+
if (parts.length === 1) {
|
|
2827
|
+
paddingObj = { top: parts[0], right: parts[0], bottom: parts[0], left: parts[0] };
|
|
2828
|
+
} else if (parts.length === 4) {
|
|
2829
|
+
paddingObj = { top: parts[0], right: parts[1], bottom: parts[2], left: parts[3] };
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
const result = await sendCommand("create-frame", {
|
|
2833
|
+
x: Number(args.x),
|
|
2834
|
+
y: Number(args.y),
|
|
2835
|
+
width: Number(args.width),
|
|
2836
|
+
height: Number(args.height),
|
|
2837
|
+
name: args.name,
|
|
2838
|
+
parentId: args.parentId,
|
|
2839
|
+
fill: args.fill,
|
|
2840
|
+
stroke: args.stroke,
|
|
2841
|
+
strokeWeight: args.strokeWeight ? Number(args.strokeWeight) : undefined,
|
|
2842
|
+
radius: args.radius ? Number(args.radius) : undefined,
|
|
2843
|
+
opacity: args.opacity ? Number(args.opacity) : undefined,
|
|
2844
|
+
layoutMode: args.layoutMode,
|
|
2845
|
+
itemSpacing: args.itemSpacing ? Number(args.itemSpacing) : undefined,
|
|
2846
|
+
padding: paddingObj
|
|
2847
|
+
});
|
|
2848
|
+
printResult(result, args.json, "create");
|
|
2849
|
+
} catch (e2) {
|
|
2850
|
+
handleError(e2);
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
});
|
|
2854
|
+
// packages/cli/src/commands/create-section.ts
|
|
2855
|
+
var create_section_default = defineCommand({
|
|
2856
|
+
meta: { description: "Create a section" },
|
|
2857
|
+
args: {
|
|
2858
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2859
|
+
x: { type: "string", description: "X position", required: true },
|
|
2860
|
+
y: { type: "string", description: "Y position", required: true },
|
|
2861
|
+
width: { type: "string", description: "Width", required: true },
|
|
2862
|
+
height: { type: "string", description: "Height", required: true },
|
|
2863
|
+
name: { type: "string", description: "Section name" }
|
|
2864
|
+
},
|
|
2865
|
+
async run({ args }) {
|
|
2866
|
+
try {
|
|
2867
|
+
const result = await sendCommand("create-section", {
|
|
2868
|
+
x: Number(args.x),
|
|
2869
|
+
y: Number(args.y),
|
|
2870
|
+
width: Number(args.width),
|
|
2871
|
+
height: Number(args.height),
|
|
2872
|
+
name: args.name
|
|
2873
|
+
});
|
|
2874
|
+
printResult(result, args.json, "create");
|
|
2875
|
+
} catch (e2) {
|
|
2876
|
+
handleError(e2);
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
});
|
|
2880
|
+
// packages/cli/src/commands/create-slice.ts
|
|
2881
|
+
var create_slice_default = defineCommand({
|
|
2882
|
+
meta: { description: "Create a slice for export" },
|
|
2883
|
+
args: {
|
|
2884
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2885
|
+
x: { type: "string", description: "X position", required: true },
|
|
2886
|
+
y: { type: "string", description: "Y position", required: true },
|
|
2887
|
+
width: { type: "string", description: "Width", required: true },
|
|
2888
|
+
height: { type: "string", description: "Height", required: true },
|
|
2889
|
+
name: { type: "string", description: "Slice name" }
|
|
2890
|
+
},
|
|
2891
|
+
async run({ args }) {
|
|
2892
|
+
try {
|
|
2893
|
+
const result = await sendCommand("create-slice", {
|
|
2894
|
+
x: Number(args.x),
|
|
2895
|
+
y: Number(args.y),
|
|
2896
|
+
width: Number(args.width),
|
|
2897
|
+
height: Number(args.height),
|
|
2898
|
+
name: args.name
|
|
2899
|
+
});
|
|
2900
|
+
printResult(result, args.json, "create");
|
|
2901
|
+
} catch (e2) {
|
|
2902
|
+
handleError(e2);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2906
|
+
// packages/cli/src/commands/create-text.ts
|
|
2907
|
+
var create_text_default = defineCommand({
|
|
2908
|
+
meta: { description: "Create a text node" },
|
|
2909
|
+
args: {
|
|
2910
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2911
|
+
x: { type: "string", description: "X coordinate", required: true },
|
|
2912
|
+
y: { type: "string", description: "Y coordinate", required: true },
|
|
2913
|
+
text: { type: "string", description: "Text content", required: true },
|
|
2914
|
+
fontSize: { type: "string", description: "Font size" },
|
|
2915
|
+
fontFamily: { type: "string", description: "Font family (default: Inter)" },
|
|
2916
|
+
fontStyle: { type: "string", description: "Font style (Regular, Bold, Medium, etc)" },
|
|
2917
|
+
fill: { type: "string", description: "Text color (hex)" },
|
|
2918
|
+
opacity: { type: "string", description: "Opacity (0-1)" },
|
|
2919
|
+
name: { type: "string", description: "Node name" },
|
|
2920
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
2921
|
+
},
|
|
2922
|
+
async run({ args }) {
|
|
2923
|
+
try {
|
|
2924
|
+
const result = await sendCommand("create-text", {
|
|
2925
|
+
x: Number(args.x),
|
|
2926
|
+
y: Number(args.y),
|
|
2927
|
+
text: args.text,
|
|
2928
|
+
fontSize: args.fontSize ? Number(args.fontSize) : undefined,
|
|
2929
|
+
fontFamily: args.fontFamily,
|
|
2930
|
+
fontStyle: args.fontStyle,
|
|
2931
|
+
fill: args.fill,
|
|
2932
|
+
opacity: args.opacity ? Number(args.opacity) : undefined,
|
|
2933
|
+
name: args.name,
|
|
2934
|
+
parentId: args.parentId
|
|
2935
|
+
});
|
|
2936
|
+
printResult(result, args.json, "create");
|
|
2937
|
+
} catch (e2) {
|
|
2938
|
+
handleError(e2);
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
});
|
|
2942
|
+
// packages/cli/src/commands/create-instance.ts
|
|
2943
|
+
var create_instance_default = defineCommand({
|
|
2944
|
+
meta: { description: "Create an instance of a component" },
|
|
2945
|
+
args: {
|
|
2946
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2947
|
+
componentId: { type: "string", description: "Component ID", required: true },
|
|
2948
|
+
x: { type: "string", description: "X coordinate" },
|
|
2949
|
+
y: { type: "string", description: "Y coordinate" },
|
|
2950
|
+
name: { type: "string", description: "Instance name" },
|
|
2951
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
2952
|
+
},
|
|
2953
|
+
async run({ args }) {
|
|
2954
|
+
try {
|
|
2955
|
+
const result = await sendCommand("create-instance", {
|
|
2956
|
+
componentId: args.componentId,
|
|
2957
|
+
x: args.x ? Number(args.x) : undefined,
|
|
2958
|
+
y: args.y ? Number(args.y) : undefined,
|
|
2959
|
+
name: args.name,
|
|
2960
|
+
parentId: args.parentId
|
|
2961
|
+
});
|
|
2962
|
+
printResult(result, args.json, "create");
|
|
2963
|
+
} catch (e2) {
|
|
2964
|
+
handleError(e2);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
});
|
|
2968
|
+
// packages/cli/src/commands/create-component.ts
|
|
2969
|
+
var create_component_default = defineCommand({
|
|
2970
|
+
meta: { description: "Create a component" },
|
|
2971
|
+
args: {
|
|
2972
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2973
|
+
name: { type: "string", description: "Component name", required: true },
|
|
2974
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
2975
|
+
},
|
|
2976
|
+
async run({ args }) {
|
|
2977
|
+
try {
|
|
2978
|
+
const result = await sendCommand("create-component", {
|
|
2979
|
+
name: args.name,
|
|
2980
|
+
parentId: args.parentId
|
|
2981
|
+
});
|
|
2982
|
+
printResult(result, args.json, "create");
|
|
2983
|
+
} catch (e2) {
|
|
2984
|
+
handleError(e2);
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
// packages/cli/src/commands/clone-node.ts
|
|
2989
|
+
var clone_node_default = defineCommand({
|
|
2990
|
+
meta: { description: "Clone a node" },
|
|
2991
|
+
args: {
|
|
2992
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
2993
|
+
id: { type: "string", description: "Node ID to clone", required: true }
|
|
2994
|
+
},
|
|
2995
|
+
async run({ args }) {
|
|
2996
|
+
try {
|
|
2997
|
+
const result = await sendCommand("clone-node", { id: args.id });
|
|
2998
|
+
printResult(result, args.json, "create");
|
|
2999
|
+
} catch (e2) {
|
|
3000
|
+
handleError(e2);
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
// packages/cli/src/commands/create-paint-style.ts
|
|
3005
|
+
var create_paint_style_default = defineCommand({
|
|
3006
|
+
meta: { description: "Create a paint/color style" },
|
|
3007
|
+
args: {
|
|
3008
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3009
|
+
name: { type: "string", description: "Style name", required: true },
|
|
3010
|
+
color: { type: "string", description: "Hex color (e.g. #FF0000)", required: true }
|
|
3011
|
+
},
|
|
3012
|
+
async run({ args }) {
|
|
3013
|
+
try {
|
|
3014
|
+
const result = await sendCommand("create-paint-style", {
|
|
3015
|
+
name: args.name,
|
|
3016
|
+
color: args.color
|
|
3017
|
+
});
|
|
3018
|
+
printResult(result, args.json, "create");
|
|
3019
|
+
} catch (e2) {
|
|
3020
|
+
handleError(e2);
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
});
|
|
3024
|
+
// packages/cli/src/commands/create-text-style.ts
|
|
3025
|
+
var create_text_style_default = defineCommand({
|
|
3026
|
+
meta: { description: "Create a text style" },
|
|
3027
|
+
args: {
|
|
3028
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3029
|
+
name: { type: "string", description: "Style name", required: true },
|
|
3030
|
+
fontFamily: { type: "string", description: "Font family", default: "Inter" },
|
|
3031
|
+
fontStyle: { type: "string", description: "Font style (Regular, Bold, etc)", default: "Regular" },
|
|
3032
|
+
fontSize: { type: "string", description: "Font size", default: "16" }
|
|
3033
|
+
},
|
|
3034
|
+
async run({ args }) {
|
|
3035
|
+
try {
|
|
3036
|
+
const result = await sendCommand("create-text-style", {
|
|
3037
|
+
name: args.name,
|
|
3038
|
+
fontFamily: args.fontFamily,
|
|
3039
|
+
fontStyle: args.fontStyle,
|
|
3040
|
+
fontSize: Number(args.fontSize)
|
|
3041
|
+
});
|
|
3042
|
+
printResult(result, args.json, "create");
|
|
3043
|
+
} catch (e2) {
|
|
3044
|
+
handleError(e2);
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
});
|
|
3048
|
+
// packages/cli/src/commands/create-effect-style.ts
|
|
3049
|
+
var create_effect_style_default = defineCommand({
|
|
3050
|
+
meta: { description: "Create an effect style" },
|
|
3051
|
+
args: {
|
|
3052
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3053
|
+
name: { type: "string", description: "Style name", required: true },
|
|
3054
|
+
type: { type: "string", description: "Effect type: DROP_SHADOW, INNER_SHADOW, BLUR, BACKGROUND_BLUR", required: true },
|
|
3055
|
+
radius: { type: "string", description: "Blur radius", default: "10" },
|
|
3056
|
+
color: { type: "string", description: "Shadow color (hex)", default: "#00000040" },
|
|
3057
|
+
offsetX: { type: "string", description: "Shadow X offset", default: "0" },
|
|
3058
|
+
offsetY: { type: "string", description: "Shadow Y offset", default: "4" }
|
|
3059
|
+
},
|
|
3060
|
+
async run({ args }) {
|
|
3061
|
+
try {
|
|
3062
|
+
const result = await sendCommand("create-effect-style", {
|
|
3063
|
+
name: args.name,
|
|
3064
|
+
type: args.type,
|
|
3065
|
+
radius: Number(args.radius),
|
|
3066
|
+
color: args.color,
|
|
3067
|
+
offsetX: Number(args.offsetX),
|
|
3068
|
+
offsetY: Number(args.offsetY)
|
|
3069
|
+
});
|
|
3070
|
+
printResult(result, args.json, "create");
|
|
3071
|
+
} catch (e2) {
|
|
3072
|
+
handleError(e2);
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
});
|
|
3076
|
+
// packages/cli/src/commands/move-node.ts
|
|
3077
|
+
var move_node_default = defineCommand({
|
|
3078
|
+
meta: { description: "Move a node" },
|
|
3079
|
+
args: {
|
|
3080
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3081
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3082
|
+
x: { type: "string", description: "X coordinate", required: true },
|
|
3083
|
+
y: { type: "string", description: "Y coordinate", required: true }
|
|
3084
|
+
},
|
|
3085
|
+
async run({ args }) {
|
|
3086
|
+
try {
|
|
3087
|
+
const result = await sendCommand("move-node", {
|
|
3088
|
+
id: args.id,
|
|
3089
|
+
x: Number(args.x),
|
|
3090
|
+
y: Number(args.y)
|
|
3091
|
+
});
|
|
3092
|
+
printResult(result, args.json, "update");
|
|
3093
|
+
} catch (e2) {
|
|
3094
|
+
handleError(e2);
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
});
|
|
3098
|
+
// packages/cli/src/commands/resize-node.ts
|
|
3099
|
+
var resize_node_default = defineCommand({
|
|
3100
|
+
meta: { description: "Resize a node" },
|
|
3101
|
+
args: {
|
|
3102
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3103
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3104
|
+
width: { type: "string", description: "Width", required: true },
|
|
3105
|
+
height: { type: "string", description: "Height", required: true }
|
|
3106
|
+
},
|
|
3107
|
+
async run({ args }) {
|
|
3108
|
+
try {
|
|
3109
|
+
const result = await sendCommand("resize-node", {
|
|
3110
|
+
id: args.id,
|
|
3111
|
+
width: Number(args.width),
|
|
3112
|
+
height: Number(args.height)
|
|
3113
|
+
});
|
|
3114
|
+
printResult(result, args.json, "update");
|
|
3115
|
+
} catch (e2) {
|
|
3116
|
+
handleError(e2);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
});
|
|
3120
|
+
// packages/cli/src/commands/set-fill-color.ts
|
|
3121
|
+
var set_fill_color_default = defineCommand({
|
|
3122
|
+
meta: { description: "Set fill color of a node" },
|
|
3123
|
+
args: {
|
|
3124
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3125
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3126
|
+
color: { type: "string", description: "Color (hex, e.g. #FF0000FF)", required: true }
|
|
3127
|
+
},
|
|
3128
|
+
async run({ args }) {
|
|
3129
|
+
try {
|
|
3130
|
+
const result = await sendCommand("set-fill-color", {
|
|
3131
|
+
id: args.id,
|
|
3132
|
+
color: args.color
|
|
3133
|
+
});
|
|
3134
|
+
printResult(result, args.json, "update");
|
|
3135
|
+
} catch (e2) {
|
|
3136
|
+
handleError(e2);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
// packages/cli/src/commands/set-stroke-color.ts
|
|
3141
|
+
var set_stroke_color_default = defineCommand({
|
|
3142
|
+
meta: { description: "Set stroke color of a node" },
|
|
3143
|
+
args: {
|
|
3144
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3145
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3146
|
+
color: { type: "string", description: "Color (hex, e.g. #0000FFFF)", required: true }
|
|
3147
|
+
},
|
|
3148
|
+
async run({ args }) {
|
|
3149
|
+
try {
|
|
3150
|
+
const result = await sendCommand("set-stroke-color", {
|
|
3151
|
+
id: args.id,
|
|
3152
|
+
color: args.color
|
|
3153
|
+
});
|
|
3154
|
+
printResult(result, args.json, "update");
|
|
3155
|
+
} catch (e2) {
|
|
3156
|
+
handleError(e2);
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
});
|
|
3160
|
+
// packages/cli/src/commands/set-corner-radius.ts
|
|
3161
|
+
var set_corner_radius_default = defineCommand({
|
|
3162
|
+
meta: { description: "Set corner radius of a node" },
|
|
3163
|
+
args: {
|
|
3164
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3165
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3166
|
+
radius: { type: "string", description: "Corner radius", required: true },
|
|
3167
|
+
topLeft: { type: "string", description: "Top left radius" },
|
|
3168
|
+
topRight: { type: "string", description: "Top right radius" },
|
|
3169
|
+
bottomLeft: { type: "string", description: "Bottom left radius" },
|
|
3170
|
+
bottomRight: { type: "string", description: "Bottom right radius" }
|
|
3171
|
+
},
|
|
3172
|
+
async run({ args }) {
|
|
3173
|
+
try {
|
|
3174
|
+
const result = await sendCommand("set-corner-radius", {
|
|
3175
|
+
id: args.id,
|
|
3176
|
+
cornerRadius: Number(args.radius),
|
|
3177
|
+
topLeftRadius: args.topLeft ? Number(args.topLeft) : undefined,
|
|
3178
|
+
topRightRadius: args.topRight ? Number(args.topRight) : undefined,
|
|
3179
|
+
bottomLeftRadius: args.bottomLeft ? Number(args.bottomLeft) : undefined,
|
|
3180
|
+
bottomRightRadius: args.bottomRight ? Number(args.bottomRight) : undefined
|
|
3181
|
+
});
|
|
3182
|
+
printResult(result, args.json, "update");
|
|
3183
|
+
} catch (e2) {
|
|
3184
|
+
handleError(e2);
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
// packages/cli/src/commands/set-opacity.ts
|
|
3189
|
+
var set_opacity_default = defineCommand({
|
|
3190
|
+
meta: { description: "Set node opacity" },
|
|
3191
|
+
args: {
|
|
3192
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3193
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3194
|
+
opacity: { type: "string", description: "Opacity (0-1)", required: true }
|
|
3195
|
+
},
|
|
3196
|
+
async run({ args }) {
|
|
3197
|
+
try {
|
|
3198
|
+
const result = await sendCommand("set-opacity", {
|
|
3199
|
+
id: args.id,
|
|
3200
|
+
opacity: Number(args.opacity)
|
|
3201
|
+
});
|
|
3202
|
+
printResult(result, args.json, "update");
|
|
3203
|
+
} catch (e2) {
|
|
3204
|
+
handleError(e2);
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
});
|
|
3208
|
+
// packages/cli/src/commands/set-image-fill.ts
|
|
3209
|
+
var set_image_fill_default = defineCommand({
|
|
3210
|
+
meta: { description: "Set image fill from URL" },
|
|
3211
|
+
args: {
|
|
3212
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3213
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3214
|
+
url: { type: "string", description: "Image URL", required: true },
|
|
3215
|
+
scaleMode: { type: "string", description: "Scale mode: FILL, FIT, CROP, TILE", default: "FILL" }
|
|
3216
|
+
},
|
|
3217
|
+
async run({ args }) {
|
|
3218
|
+
try {
|
|
3219
|
+
const result = await sendCommand("set-image-fill", {
|
|
3220
|
+
id: args.id,
|
|
3221
|
+
url: args.url,
|
|
3222
|
+
scaleMode: args.scaleMode
|
|
3223
|
+
});
|
|
3224
|
+
printResult(result, args.json, "update");
|
|
3225
|
+
} catch (e2) {
|
|
3226
|
+
handleError(e2);
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3230
|
+
// packages/cli/src/commands/rename-node.ts
|
|
3231
|
+
var rename_node_default = defineCommand({
|
|
3232
|
+
meta: { description: "Rename a node" },
|
|
3233
|
+
args: {
|
|
3234
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3235
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3236
|
+
name: { type: "string", description: "New name", required: true }
|
|
3237
|
+
},
|
|
3238
|
+
async run({ args }) {
|
|
3239
|
+
try {
|
|
3240
|
+
const result = await sendCommand("rename-node", { id: args.id, name: args.name });
|
|
3241
|
+
printResult(result, args.json);
|
|
3242
|
+
} catch (e2) {
|
|
3243
|
+
handleError(e2);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
});
|
|
3247
|
+
// packages/cli/src/commands/set-visible.ts
|
|
3248
|
+
var set_visible_default = defineCommand({
|
|
3249
|
+
meta: { description: "Set node visibility" },
|
|
3250
|
+
args: {
|
|
3251
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3252
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3253
|
+
visible: { type: "boolean", description: "Visible", required: true }
|
|
3254
|
+
},
|
|
3255
|
+
async run({ args }) {
|
|
3256
|
+
try {
|
|
3257
|
+
const result = await sendCommand("set-visible", {
|
|
3258
|
+
id: args.id,
|
|
3259
|
+
visible: args.visible
|
|
3260
|
+
});
|
|
3261
|
+
printResult(result, args.json, "update");
|
|
3262
|
+
} catch (e2) {
|
|
3263
|
+
handleError(e2);
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
});
|
|
3267
|
+
// packages/cli/src/commands/set-locked.ts
|
|
3268
|
+
var set_locked_default = defineCommand({
|
|
3269
|
+
meta: { description: "Set node locked state" },
|
|
3270
|
+
args: {
|
|
3271
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3272
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3273
|
+
locked: { type: "boolean", description: "Locked", required: true }
|
|
3274
|
+
},
|
|
3275
|
+
async run({ args }) {
|
|
3276
|
+
try {
|
|
3277
|
+
const result = await sendCommand("set-locked", {
|
|
3278
|
+
id: args.id,
|
|
3279
|
+
locked: args.locked
|
|
3280
|
+
});
|
|
3281
|
+
printResult(result, args.json, "update");
|
|
3282
|
+
} catch (e2) {
|
|
3283
|
+
handleError(e2);
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
});
|
|
3287
|
+
// packages/cli/src/commands/set-layout.ts
|
|
3288
|
+
var set_layout_default = defineCommand({
|
|
3289
|
+
meta: { description: "Set layout of a node" },
|
|
3290
|
+
args: {
|
|
3291
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3292
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3293
|
+
mode: { type: "string", description: "Layout mode (NONE, HORIZONTAL, VERTICAL)", required: true },
|
|
3294
|
+
wrap: { type: "boolean", description: "Enable wrapping" },
|
|
3295
|
+
clip: { type: "boolean", description: "Clip content" },
|
|
3296
|
+
itemSpacing: { type: "string", description: "Item spacing" },
|
|
3297
|
+
primaryAxisAlign: { type: "string", description: "Primary axis alignment (MIN, MAX, CENTER, SPACE_BETWEEN)" },
|
|
3298
|
+
counterAxisAlign: { type: "string", description: "Counter axis alignment (MIN, MAX, CENTER, SPACE_BETWEEN)" },
|
|
3299
|
+
paddingLeft: { type: "string", description: "Left padding" },
|
|
3300
|
+
paddingRight: { type: "string", description: "Right padding" },
|
|
3301
|
+
paddingTop: { type: "string", description: "Top padding" },
|
|
3302
|
+
paddingBottom: { type: "string", description: "Bottom padding" },
|
|
3303
|
+
sizingVertical: { type: "string", description: "Vertical sizing (FIXED, HUG, FILL)" },
|
|
3304
|
+
sizingHorizontal: { type: "string", description: "Horizontal sizing (FIXED, HUG, FILL)" }
|
|
3305
|
+
},
|
|
3306
|
+
async run({ args }) {
|
|
3307
|
+
try {
|
|
3308
|
+
const result = await sendCommand("set-layout", {
|
|
3309
|
+
id: args.id,
|
|
3310
|
+
mode: args.mode,
|
|
3311
|
+
wrap: args.wrap,
|
|
3312
|
+
clip: args.clip,
|
|
3313
|
+
itemSpacing: args.itemSpacing ? Number(args.itemSpacing) : undefined,
|
|
3314
|
+
primaryAxisAlignItems: args.primaryAxisAlign,
|
|
3315
|
+
counterAxisAlignItems: args.counterAxisAlign,
|
|
3316
|
+
paddingLeft: args.paddingLeft ? Number(args.paddingLeft) : undefined,
|
|
3317
|
+
paddingRight: args.paddingRight ? Number(args.paddingRight) : undefined,
|
|
3318
|
+
paddingTop: args.paddingTop ? Number(args.paddingTop) : undefined,
|
|
3319
|
+
paddingBottom: args.paddingBottom ? Number(args.paddingBottom) : undefined,
|
|
3320
|
+
layoutSizingVertical: args.sizingVertical,
|
|
3321
|
+
layoutSizingHorizontal: args.sizingHorizontal
|
|
3322
|
+
});
|
|
3323
|
+
printResult(result, args.json, "update");
|
|
3324
|
+
} catch (e2) {
|
|
3325
|
+
handleError(e2);
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
});
|
|
3329
|
+
// packages/cli/src/commands/set-parent.ts
|
|
3330
|
+
var set_parent_default = defineCommand({
|
|
3331
|
+
meta: { description: "Set parent of a node" },
|
|
3332
|
+
args: {
|
|
3333
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3334
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3335
|
+
parentId: { type: "string", description: "Parent node ID", required: true }
|
|
3336
|
+
},
|
|
3337
|
+
async run({ args }) {
|
|
3338
|
+
try {
|
|
3339
|
+
const result = await sendCommand("set-parent-id", {
|
|
3340
|
+
id: args.id,
|
|
3341
|
+
parentId: args.parentId
|
|
3342
|
+
});
|
|
3343
|
+
printResult(result, args.json, "update");
|
|
3344
|
+
} catch (e2) {
|
|
3345
|
+
handleError(e2);
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
// packages/cli/src/commands/group-nodes.ts
|
|
3350
|
+
var group_nodes_default = defineCommand({
|
|
3351
|
+
meta: { description: "Group nodes together" },
|
|
3352
|
+
args: {
|
|
3353
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3354
|
+
ids: { type: "string", description: "Comma-separated node IDs", required: true },
|
|
3355
|
+
name: { type: "string", description: "Group name" }
|
|
3356
|
+
},
|
|
3357
|
+
async run({ args }) {
|
|
3358
|
+
try {
|
|
3359
|
+
const result = await sendCommand("group-nodes", {
|
|
3360
|
+
ids: args.ids.split(",").map((s2) => s2.trim()),
|
|
3361
|
+
name: args.name
|
|
3362
|
+
});
|
|
3363
|
+
printResult(result, args.json);
|
|
3364
|
+
} catch (e2) {
|
|
3365
|
+
handleError(e2);
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
});
|
|
3369
|
+
// packages/cli/src/commands/ungroup-node.ts
|
|
3370
|
+
var ungroup_node_default = defineCommand({
|
|
3371
|
+
meta: { description: "Ungroup a group node" },
|
|
3372
|
+
args: {
|
|
3373
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3374
|
+
id: { type: "string", description: "Group node ID", required: true }
|
|
3375
|
+
},
|
|
3376
|
+
async run({ args }) {
|
|
3377
|
+
try {
|
|
3378
|
+
const result = await sendCommand("ungroup-node", { id: args.id });
|
|
3379
|
+
printResult(result, args.json);
|
|
3380
|
+
} catch (e2) {
|
|
3381
|
+
handleError(e2);
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
});
|
|
3385
|
+
// packages/cli/src/commands/flatten-nodes.ts
|
|
3386
|
+
var flatten_nodes_default = defineCommand({
|
|
3387
|
+
meta: { description: "Flatten nodes into a vector" },
|
|
3388
|
+
args: {
|
|
3389
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3390
|
+
ids: { type: "string", description: "Comma-separated node IDs", required: true }
|
|
3391
|
+
},
|
|
3392
|
+
async run({ args }) {
|
|
3393
|
+
try {
|
|
3394
|
+
const result = await sendCommand("flatten-nodes", {
|
|
3395
|
+
ids: args.ids.split(",").map((s2) => s2.trim())
|
|
3396
|
+
});
|
|
3397
|
+
printResult(result, args.json);
|
|
3398
|
+
} catch (e2) {
|
|
3399
|
+
handleError(e2);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
});
|
|
3403
|
+
// packages/cli/src/commands/union-nodes.ts
|
|
3404
|
+
var union_nodes_default = defineCommand({
|
|
3405
|
+
meta: { description: "Union nodes (boolean operation)" },
|
|
3406
|
+
args: {
|
|
3407
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3408
|
+
ids: { type: "string", description: "Comma-separated node IDs", required: true }
|
|
3409
|
+
},
|
|
3410
|
+
async run({ args }) {
|
|
3411
|
+
try {
|
|
3412
|
+
const result = await sendCommand("boolean-operation", {
|
|
3413
|
+
ids: args.ids.split(",").map((s2) => s2.trim()),
|
|
3414
|
+
operation: "UNION"
|
|
3415
|
+
});
|
|
3416
|
+
printResult(result, args.json);
|
|
3417
|
+
} catch (e2) {
|
|
3418
|
+
handleError(e2);
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
});
|
|
3422
|
+
// packages/cli/src/commands/subtract-nodes.ts
|
|
3423
|
+
var subtract_nodes_default = defineCommand({
|
|
3424
|
+
meta: { description: "Subtract nodes (boolean operation)" },
|
|
3425
|
+
args: {
|
|
3426
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3427
|
+
ids: { type: "string", description: "Comma-separated node IDs", required: true }
|
|
3428
|
+
},
|
|
3429
|
+
async run({ args }) {
|
|
3430
|
+
try {
|
|
3431
|
+
const result = await sendCommand("boolean-operation", {
|
|
3432
|
+
ids: args.ids.split(",").map((s2) => s2.trim()),
|
|
3433
|
+
operation: "SUBTRACT"
|
|
3434
|
+
});
|
|
3435
|
+
printResult(result, args.json);
|
|
3436
|
+
} catch (e2) {
|
|
3437
|
+
handleError(e2);
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
});
|
|
3441
|
+
// packages/cli/src/commands/intersect-nodes.ts
|
|
3442
|
+
var intersect_nodes_default = defineCommand({
|
|
3443
|
+
meta: { description: "Intersect nodes (boolean operation)" },
|
|
3444
|
+
args: {
|
|
3445
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3446
|
+
ids: { type: "string", description: "Comma-separated node IDs", required: true }
|
|
3447
|
+
},
|
|
3448
|
+
async run({ args }) {
|
|
3449
|
+
try {
|
|
3450
|
+
const result = await sendCommand("boolean-operation", {
|
|
3451
|
+
ids: args.ids.split(",").map((s2) => s2.trim()),
|
|
3452
|
+
operation: "INTERSECT"
|
|
3453
|
+
});
|
|
3454
|
+
printResult(result, args.json);
|
|
3455
|
+
} catch (e2) {
|
|
3456
|
+
handleError(e2);
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
});
|
|
3460
|
+
// packages/cli/src/commands/exclude-nodes.ts
|
|
3461
|
+
var exclude_nodes_default = defineCommand({
|
|
3462
|
+
meta: { description: "Exclude nodes (boolean operation)" },
|
|
3463
|
+
args: {
|
|
3464
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3465
|
+
ids: { type: "string", description: "Comma-separated node IDs", required: true }
|
|
3466
|
+
},
|
|
3467
|
+
async run({ args }) {
|
|
3468
|
+
try {
|
|
3469
|
+
const result = await sendCommand("boolean-operation", {
|
|
3470
|
+
ids: args.ids.split(",").map((s2) => s2.trim()),
|
|
3471
|
+
operation: "EXCLUDE"
|
|
3472
|
+
});
|
|
3473
|
+
printResult(result, args.json);
|
|
3474
|
+
} catch (e2) {
|
|
3475
|
+
handleError(e2);
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
});
|
|
3479
|
+
// packages/cli/src/commands/set-instance-properties.ts
|
|
3480
|
+
var set_instance_properties_default = defineCommand({
|
|
3481
|
+
meta: { description: "Set instance properties" },
|
|
3482
|
+
args: {
|
|
3483
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3484
|
+
id: { type: "string", description: "Instance ID", required: true },
|
|
3485
|
+
properties: { type: "string", description: "Properties JSON", required: true }
|
|
3486
|
+
},
|
|
3487
|
+
async run({ args }) {
|
|
3488
|
+
try {
|
|
3489
|
+
const result = await sendCommand("set-instance-properties", {
|
|
3490
|
+
instanceId: args.id,
|
|
3491
|
+
properties: JSON.parse(args.properties)
|
|
3492
|
+
});
|
|
3493
|
+
printResult(result, args.json, "update");
|
|
3494
|
+
} catch (e2) {
|
|
3495
|
+
handleError(e2);
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
});
|
|
3499
|
+
// packages/cli/src/commands/set-component-property-refs.ts
|
|
3500
|
+
var set_component_property_refs_default = defineCommand({
|
|
3501
|
+
meta: { description: "Set component property references of a node" },
|
|
3502
|
+
args: {
|
|
3503
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3504
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3505
|
+
refs: { type: "string", description: 'References JSON (e.g. {"characters": "propName"})', required: true }
|
|
3506
|
+
},
|
|
3507
|
+
async run({ args }) {
|
|
3508
|
+
try {
|
|
3509
|
+
const result = await sendCommand("set-node-component-property-references", {
|
|
3510
|
+
id: args.id,
|
|
3511
|
+
componentPropertyReferences: JSON.parse(args.refs)
|
|
3512
|
+
});
|
|
3513
|
+
printResult(result, args.json, "update");
|
|
3514
|
+
} catch (e2) {
|
|
3515
|
+
handleError(e2);
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
});
|
|
3519
|
+
// packages/cli/src/commands/add-component-property.ts
|
|
3520
|
+
var add_component_property_default = defineCommand({
|
|
3521
|
+
meta: { description: "Add a component property" },
|
|
3522
|
+
args: {
|
|
3523
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3524
|
+
componentId: { type: "string", description: "Component ID", required: true },
|
|
3525
|
+
name: { type: "string", description: "Property name", required: true },
|
|
3526
|
+
type: { type: "string", description: "Property type (BOOLEAN, TEXT, INSTANCE_SWAP, VARIANT)", required: true },
|
|
3527
|
+
defaultValue: { type: "string", description: "Default value", required: true }
|
|
3528
|
+
},
|
|
3529
|
+
async run({ args }) {
|
|
3530
|
+
try {
|
|
3531
|
+
const result = await sendCommand("add-component-property", {
|
|
3532
|
+
componentId: args.componentId,
|
|
3533
|
+
name: args.name,
|
|
3534
|
+
type: args.type,
|
|
3535
|
+
defaultValue: args.defaultValue
|
|
3536
|
+
});
|
|
3537
|
+
printResult(result, args.json);
|
|
3538
|
+
} catch (e2) {
|
|
3539
|
+
handleError(e2);
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
});
|
|
3543
|
+
// packages/cli/src/commands/edit-component-property.ts
|
|
3544
|
+
var edit_component_property_default = defineCommand({
|
|
3545
|
+
meta: { description: "Edit a component property" },
|
|
3546
|
+
args: {
|
|
3547
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3548
|
+
componentId: { type: "string", description: "Component ID", required: true },
|
|
3549
|
+
name: { type: "string", description: "Property name", required: true },
|
|
3550
|
+
type: { type: "string", description: "Property type (BOOLEAN, TEXT, INSTANCE_SWAP, VARIANT)", required: true },
|
|
3551
|
+
defaultValue: { type: "string", description: "Default value", required: true },
|
|
3552
|
+
preferredValues: { type: "string", description: "Preferred values JSON array" }
|
|
3553
|
+
},
|
|
3554
|
+
async run({ args }) {
|
|
3555
|
+
try {
|
|
3556
|
+
const result = await sendCommand("edit-component-property", {
|
|
3557
|
+
componentId: args.componentId,
|
|
3558
|
+
name: args.name,
|
|
3559
|
+
type: args.type,
|
|
3560
|
+
defaultValue: args.defaultValue,
|
|
3561
|
+
preferredValues: args.preferredValues ? JSON.parse(args.preferredValues) : undefined
|
|
3562
|
+
});
|
|
3563
|
+
printResult(result, args.json);
|
|
3564
|
+
} catch (e2) {
|
|
3565
|
+
handleError(e2);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
});
|
|
3569
|
+
// packages/cli/src/commands/delete-component-property.ts
|
|
3570
|
+
var delete_component_property_default = defineCommand({
|
|
3571
|
+
meta: { description: "Delete a component property" },
|
|
3572
|
+
args: {
|
|
3573
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3574
|
+
componentId: { type: "string", description: "Component ID", required: true },
|
|
3575
|
+
name: { type: "string", description: "Property name", required: true }
|
|
3576
|
+
},
|
|
3577
|
+
async run({ args }) {
|
|
3578
|
+
try {
|
|
3579
|
+
const result = await sendCommand("delete-component-property", {
|
|
3580
|
+
componentId: args.componentId,
|
|
3581
|
+
name: args.name
|
|
3582
|
+
});
|
|
3583
|
+
printResult(result, args.json, "delete");
|
|
3584
|
+
} catch (e2) {
|
|
3585
|
+
handleError(e2);
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
});
|
|
3589
|
+
// packages/cli/src/commands/set-viewport.ts
|
|
3590
|
+
var set_viewport_default = defineCommand({
|
|
3591
|
+
meta: { description: "Set viewport position and zoom" },
|
|
3592
|
+
args: {
|
|
3593
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3594
|
+
x: { type: "string", description: "X position" },
|
|
3595
|
+
y: { type: "string", description: "Y position" },
|
|
3596
|
+
zoom: { type: "string", description: "Zoom level (1 = 100%)" }
|
|
3597
|
+
},
|
|
3598
|
+
async run({ args }) {
|
|
3599
|
+
try {
|
|
3600
|
+
const result = await sendCommand("set-viewport", {
|
|
3601
|
+
x: args.x ? Number(args.x) : undefined,
|
|
3602
|
+
y: args.y ? Number(args.y) : undefined,
|
|
3603
|
+
zoom: args.zoom ? Number(args.zoom) : undefined
|
|
3604
|
+
});
|
|
3605
|
+
printResult(result, args.json, "update");
|
|
3606
|
+
} catch (e2) {
|
|
3607
|
+
handleError(e2);
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
});
|
|
3611
|
+
// packages/cli/src/commands/zoom-to-fit.ts
|
|
3612
|
+
var zoom_to_fit_default = defineCommand({
|
|
3613
|
+
meta: { description: "Zoom viewport to fit nodes" },
|
|
3614
|
+
args: {
|
|
3615
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3616
|
+
ids: { type: "string", description: "Comma-separated node IDs (or empty for selection)" }
|
|
3617
|
+
},
|
|
3618
|
+
async run({ args }) {
|
|
3619
|
+
try {
|
|
3620
|
+
const result = await sendCommand("zoom-to-fit", {
|
|
3621
|
+
ids: args.ids ? args.ids.split(",").map((s2) => s2.trim()) : undefined
|
|
3622
|
+
});
|
|
3623
|
+
printResult(result, args.json);
|
|
3624
|
+
} catch (e2) {
|
|
3625
|
+
handleError(e2);
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
});
|
|
3629
|
+
// packages/cli/src/commands/export-node.ts
|
|
3630
|
+
import { writeFileSync } from "fs";
|
|
3631
|
+
var export_node_default = defineCommand({
|
|
3632
|
+
meta: { description: "Export node as image" },
|
|
3633
|
+
args: {
|
|
3634
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3635
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3636
|
+
format: { type: "string", description: "Format: PNG, JPG, SVG, PDF", default: "PNG" },
|
|
3637
|
+
scale: { type: "string", description: "Export scale", default: "1" },
|
|
3638
|
+
output: { type: "string", description: "Output file path" }
|
|
3639
|
+
},
|
|
3640
|
+
async run({ args }) {
|
|
3641
|
+
try {
|
|
3642
|
+
const result = await sendCommand("export-node", {
|
|
3643
|
+
id: args.id,
|
|
3644
|
+
format: args.format.toUpperCase(),
|
|
3645
|
+
scale: Number(args.scale)
|
|
3646
|
+
});
|
|
3647
|
+
if (args.output) {
|
|
3648
|
+
const buffer = Buffer.from(result.data, "base64");
|
|
3649
|
+
writeFileSync(args.output, buffer);
|
|
3650
|
+
console.log(`Exported to ${args.output}`);
|
|
3651
|
+
} else {
|
|
3652
|
+
console.log(JSON.stringify(result, null, 2));
|
|
3653
|
+
}
|
|
3654
|
+
} catch (e2) {
|
|
3655
|
+
handleError(e2);
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
});
|
|
3659
|
+
// packages/cli/src/commands/delete-node.ts
|
|
3660
|
+
var delete_node_default = defineCommand({
|
|
3661
|
+
meta: { description: "Delete a node" },
|
|
3662
|
+
args: {
|
|
3663
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3664
|
+
id: { type: "string", description: "Node ID", required: true }
|
|
3665
|
+
},
|
|
3666
|
+
async run({ args }) {
|
|
3667
|
+
try {
|
|
3668
|
+
const result = await sendCommand("delete-node", { id: args.id });
|
|
3669
|
+
printResult(result, args.json, "delete");
|
|
3670
|
+
} catch (e2) {
|
|
3671
|
+
handleError(e2);
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
});
|
|
3675
|
+
// packages/cli/src/commands/screenshot.ts
|
|
3676
|
+
import { writeFileSync as writeFileSync2 } from "fs";
|
|
3677
|
+
var screenshot_default = defineCommand({
|
|
3678
|
+
meta: { description: "Take a screenshot of current viewport" },
|
|
3679
|
+
args: {
|
|
3680
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3681
|
+
output: { type: "string", description: "Output file path", default: "/tmp/figma-screenshot.png" },
|
|
3682
|
+
scale: { type: "string", description: "Export scale", default: "1" }
|
|
3683
|
+
},
|
|
3684
|
+
async run({ args }) {
|
|
3685
|
+
try {
|
|
3686
|
+
const result = await sendCommand("screenshot", {
|
|
3687
|
+
scale: Number(args.scale)
|
|
3688
|
+
});
|
|
3689
|
+
const buffer = Buffer.from(result.data, "base64");
|
|
3690
|
+
writeFileSync2(args.output, buffer);
|
|
3691
|
+
console.log(args.output);
|
|
3692
|
+
} catch (e2) {
|
|
3693
|
+
handleError(e2);
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
});
|
|
3697
|
+
// packages/cli/src/commands/export-selection.ts
|
|
3698
|
+
import { writeFileSync as writeFileSync3 } from "fs";
|
|
3699
|
+
var export_selection_default = defineCommand({
|
|
3700
|
+
meta: { description: "Export current selection as image" },
|
|
3701
|
+
args: {
|
|
3702
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3703
|
+
output: { type: "string", description: "Output file path", default: "/tmp/figma-selection.png" },
|
|
3704
|
+
format: { type: "string", description: "Format: PNG, JPG, SVG, PDF", default: "PNG" },
|
|
3705
|
+
scale: { type: "string", description: "Export scale", default: "2" },
|
|
3706
|
+
padding: { type: "string", description: "Padding around selection", default: "0" }
|
|
3707
|
+
},
|
|
3708
|
+
async run({ args }) {
|
|
3709
|
+
try {
|
|
3710
|
+
const result = await sendCommand("export-selection", {
|
|
3711
|
+
format: args.format.toUpperCase(),
|
|
3712
|
+
scale: Number(args.scale),
|
|
3713
|
+
padding: Number(args.padding)
|
|
3714
|
+
});
|
|
3715
|
+
const buffer = Buffer.from(result.data, "base64");
|
|
3716
|
+
writeFileSync3(args.output, buffer);
|
|
3717
|
+
console.log(args.output);
|
|
3718
|
+
} catch (e2) {
|
|
3719
|
+
handleError(e2);
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
});
|
|
3723
|
+
// packages/cli/src/commands/create-page.ts
|
|
3724
|
+
var create_page_default = defineCommand({
|
|
3725
|
+
meta: { description: "Create a new page" },
|
|
3726
|
+
args: {
|
|
3727
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3728
|
+
name: { type: "string", description: "Page name", required: true }
|
|
3729
|
+
},
|
|
3730
|
+
async run({ args }) {
|
|
3731
|
+
try {
|
|
3732
|
+
const result = await sendCommand("create-page", { name: args.name });
|
|
3733
|
+
printResult(result, args.json, "create");
|
|
3734
|
+
} catch (e2) {
|
|
3735
|
+
handleError(e2);
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3738
|
+
});
|
|
3739
|
+
// packages/cli/src/commands/set-current-page.ts
|
|
3740
|
+
var set_current_page_default = defineCommand({
|
|
3741
|
+
meta: { description: "Switch to a page" },
|
|
3742
|
+
args: {
|
|
3743
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3744
|
+
id: { type: "string", description: "Page ID", required: true }
|
|
3745
|
+
},
|
|
3746
|
+
async run({ args }) {
|
|
3747
|
+
try {
|
|
3748
|
+
const result = await sendCommand("set-current-page", { id: args.id });
|
|
3749
|
+
printResult(result, args.json, "update");
|
|
3750
|
+
} catch (e2) {
|
|
3751
|
+
handleError(e2);
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
});
|
|
3755
|
+
// packages/cli/src/commands/set-effect.ts
|
|
3756
|
+
var set_effect_default = defineCommand({
|
|
3757
|
+
meta: { description: "Set effect (shadow, blur) on a node" },
|
|
3758
|
+
args: {
|
|
3759
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3760
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3761
|
+
type: { type: "string", description: "Effect type: DROP_SHADOW, INNER_SHADOW, BLUR", required: true },
|
|
3762
|
+
color: { type: "string", description: "Shadow color (hex with alpha, e.g. #00000040)" },
|
|
3763
|
+
offsetX: { type: "string", description: "Shadow X offset" },
|
|
3764
|
+
offsetY: { type: "string", description: "Shadow Y offset" },
|
|
3765
|
+
radius: { type: "string", description: "Blur radius" },
|
|
3766
|
+
spread: { type: "string", description: "Shadow spread" }
|
|
3767
|
+
},
|
|
3768
|
+
async run({ args }) {
|
|
3769
|
+
try {
|
|
3770
|
+
const result = await sendCommand("set-effect", {
|
|
3771
|
+
id: args.id,
|
|
3772
|
+
type: args.type,
|
|
3773
|
+
color: args.color,
|
|
3774
|
+
offsetX: args.offsetX ? Number(args.offsetX) : undefined,
|
|
3775
|
+
offsetY: args.offsetY ? Number(args.offsetY) : undefined,
|
|
3776
|
+
radius: args.radius ? Number(args.radius) : undefined,
|
|
3777
|
+
spread: args.spread ? Number(args.spread) : undefined
|
|
3778
|
+
});
|
|
3779
|
+
printResult(result, args.json, "update");
|
|
3780
|
+
} catch (e2) {
|
|
3781
|
+
handleError(e2);
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
});
|
|
3785
|
+
// packages/cli/src/commands/import-svg.ts
|
|
3786
|
+
var import_svg_default = defineCommand({
|
|
3787
|
+
meta: { description: "Import SVG as vector node" },
|
|
3788
|
+
args: {
|
|
3789
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3790
|
+
svg: { type: "string", description: "SVG string", required: true },
|
|
3791
|
+
x: { type: "string", description: "X position", default: "0" },
|
|
3792
|
+
y: { type: "string", description: "Y position", default: "0" },
|
|
3793
|
+
name: { type: "string", description: "Node name" },
|
|
3794
|
+
parentId: { type: "string", description: "Parent node ID" }
|
|
3795
|
+
},
|
|
3796
|
+
async run({ args }) {
|
|
3797
|
+
try {
|
|
3798
|
+
const result = await sendCommand("import-svg", {
|
|
3799
|
+
svg: args.svg,
|
|
3800
|
+
x: Number(args.x),
|
|
3801
|
+
y: Number(args.y),
|
|
3802
|
+
name: args.name,
|
|
3803
|
+
parentId: args.parentId
|
|
3804
|
+
});
|
|
3805
|
+
printResult(result, args.json, "create");
|
|
3806
|
+
} catch (e2) {
|
|
3807
|
+
handleError(e2);
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
});
|
|
3811
|
+
// packages/cli/src/commands/set-text.ts
|
|
3812
|
+
var set_text_default = defineCommand({
|
|
3813
|
+
meta: { description: "Set text content of a text node" },
|
|
3814
|
+
args: {
|
|
3815
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3816
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3817
|
+
text: { type: "string", description: "New text content", required: true }
|
|
3818
|
+
},
|
|
3819
|
+
async run({ args }) {
|
|
3820
|
+
try {
|
|
3821
|
+
const result = await sendCommand("set-text", { id: args.id, text: args.text });
|
|
3822
|
+
printResult(result, args.json, "update");
|
|
3823
|
+
} catch (e2) {
|
|
3824
|
+
handleError(e2);
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
});
|
|
3828
|
+
// packages/cli/src/commands/set-font.ts
|
|
3829
|
+
var set_font_default = defineCommand({
|
|
3830
|
+
meta: { description: "Set font of a text node" },
|
|
3831
|
+
args: {
|
|
3832
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3833
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3834
|
+
fontFamily: { type: "string", description: "Font family" },
|
|
3835
|
+
fontStyle: { type: "string", description: "Font style (Regular, Bold, Medium, etc)" },
|
|
3836
|
+
fontSize: { type: "string", description: "Font size" }
|
|
3837
|
+
},
|
|
3838
|
+
async run({ args }) {
|
|
3839
|
+
try {
|
|
3840
|
+
const result = await sendCommand("set-font", {
|
|
3841
|
+
id: args.id,
|
|
3842
|
+
fontFamily: args.fontFamily,
|
|
3843
|
+
fontStyle: args.fontStyle,
|
|
3844
|
+
fontSize: args.fontSize ? Number(args.fontSize) : undefined
|
|
3845
|
+
});
|
|
3846
|
+
printResult(result, args.json, "update");
|
|
3847
|
+
} catch (e2) {
|
|
3848
|
+
handleError(e2);
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
});
|
|
3852
|
+
// packages/cli/src/commands/get-children.ts
|
|
3853
|
+
var get_children_default = defineCommand({
|
|
3854
|
+
meta: { description: "Get children of a node" },
|
|
3855
|
+
args: {
|
|
3856
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3857
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3858
|
+
depth: { type: "string", description: "Depth (1 = direct children only)", default: "1" }
|
|
3859
|
+
},
|
|
3860
|
+
async run({ args }) {
|
|
3861
|
+
try {
|
|
3862
|
+
const result = await sendCommand("get-children", {
|
|
3863
|
+
id: args.id,
|
|
3864
|
+
depth: Number(args.depth)
|
|
3865
|
+
});
|
|
3866
|
+
printResult(result, args.json, "get");
|
|
3867
|
+
} catch (e2) {
|
|
3868
|
+
handleError(e2);
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
});
|
|
3872
|
+
// packages/cli/src/commands/find-by-name.ts
|
|
3873
|
+
var find_by_name_default = defineCommand({
|
|
3874
|
+
meta: { description: "Find nodes by name" },
|
|
3875
|
+
args: {
|
|
3876
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3877
|
+
name: { type: "string", description: "Name to search for", required: true },
|
|
3878
|
+
type: { type: "string", description: "Filter by type (FRAME, TEXT, RECTANGLE, etc)" },
|
|
3879
|
+
exact: { type: "boolean", description: "Exact match (default: contains)", default: false }
|
|
3880
|
+
},
|
|
3881
|
+
async run({ args }) {
|
|
3882
|
+
try {
|
|
3883
|
+
const result = await sendCommand("find-by-name", {
|
|
3884
|
+
name: args.name,
|
|
3885
|
+
type: args.type,
|
|
3886
|
+
exact: args.exact
|
|
3887
|
+
});
|
|
3888
|
+
printResult(result, args.json);
|
|
3889
|
+
} catch (e2) {
|
|
3890
|
+
handleError(e2);
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
});
|
|
3894
|
+
// packages/cli/src/commands/select-nodes.ts
|
|
3895
|
+
var select_nodes_default = defineCommand({
|
|
3896
|
+
meta: { description: "Select nodes in Figma UI" },
|
|
3897
|
+
args: {
|
|
3898
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3899
|
+
ids: { type: "string", description: "Comma-separated node IDs", required: true }
|
|
3900
|
+
},
|
|
3901
|
+
async run({ args }) {
|
|
3902
|
+
try {
|
|
3903
|
+
const result = await sendCommand("select-nodes", {
|
|
3904
|
+
ids: args.ids.split(",").map((s2) => s2.trim())
|
|
3905
|
+
});
|
|
3906
|
+
printResult(result, args.json);
|
|
3907
|
+
} catch (e2) {
|
|
3908
|
+
handleError(e2);
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
});
|
|
3912
|
+
// packages/cli/src/commands/set-constraints.ts
|
|
3913
|
+
var set_constraints_default = defineCommand({
|
|
3914
|
+
meta: { description: "Set constraints of a node" },
|
|
3915
|
+
args: {
|
|
3916
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3917
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3918
|
+
horizontal: { type: "string", description: "Horizontal: MIN, CENTER, MAX, STRETCH, SCALE" },
|
|
3919
|
+
vertical: { type: "string", description: "Vertical: MIN, CENTER, MAX, STRETCH, SCALE" }
|
|
3920
|
+
},
|
|
3921
|
+
async run({ args }) {
|
|
3922
|
+
try {
|
|
3923
|
+
const result = await sendCommand("set-constraints", {
|
|
3924
|
+
id: args.id,
|
|
3925
|
+
horizontal: args.horizontal,
|
|
3926
|
+
vertical: args.vertical
|
|
3927
|
+
});
|
|
3928
|
+
printResult(result, args.json, "update");
|
|
3929
|
+
} catch (e2) {
|
|
3930
|
+
handleError(e2);
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
});
|
|
3934
|
+
// packages/cli/src/commands/set-auto-layout.ts
|
|
3935
|
+
var set_auto_layout_default = defineCommand({
|
|
3936
|
+
meta: { description: "Set auto-layout properties of a frame" },
|
|
3937
|
+
args: {
|
|
3938
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3939
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3940
|
+
mode: { type: "string", description: "Layout mode: HORIZONTAL, VERTICAL, NONE" },
|
|
3941
|
+
wrap: { type: "boolean", description: "Wrap children" },
|
|
3942
|
+
itemSpacing: { type: "string", description: "Spacing between items" },
|
|
3943
|
+
counterSpacing: { type: "string", description: "Spacing between wrapped rows/columns" },
|
|
3944
|
+
padding: { type: "string", description: 'Padding (single or "top,right,bottom,left")' },
|
|
3945
|
+
primaryAlign: { type: "string", description: "Primary axis: MIN, CENTER, MAX, SPACE_BETWEEN" },
|
|
3946
|
+
counterAlign: { type: "string", description: "Counter axis: MIN, CENTER, MAX, BASELINE" },
|
|
3947
|
+
sizingH: { type: "string", description: "Horizontal sizing: FIXED, HUG, FILL" },
|
|
3948
|
+
sizingV: { type: "string", description: "Vertical sizing: FIXED, HUG, FILL" }
|
|
3949
|
+
},
|
|
3950
|
+
async run({ args }) {
|
|
3951
|
+
try {
|
|
3952
|
+
let paddingObj;
|
|
3953
|
+
if (args.padding) {
|
|
3954
|
+
const parts = args.padding.split(",").map(Number);
|
|
3955
|
+
if (parts.length === 1) {
|
|
3956
|
+
paddingObj = { top: parts[0], right: parts[0], bottom: parts[0], left: parts[0] };
|
|
3957
|
+
} else if (parts.length === 4) {
|
|
3958
|
+
paddingObj = { top: parts[0], right: parts[1], bottom: parts[2], left: parts[3] };
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
const result = await sendCommand("set-auto-layout", {
|
|
3962
|
+
id: args.id,
|
|
3963
|
+
mode: args.mode,
|
|
3964
|
+
wrap: args.wrap,
|
|
3965
|
+
itemSpacing: args.itemSpacing ? Number(args.itemSpacing) : undefined,
|
|
3966
|
+
counterSpacing: args.counterSpacing ? Number(args.counterSpacing) : undefined,
|
|
3967
|
+
padding: paddingObj,
|
|
3968
|
+
primaryAlign: args.primaryAlign,
|
|
3969
|
+
counterAlign: args.counterAlign,
|
|
3970
|
+
sizingH: args.sizingH,
|
|
3971
|
+
sizingV: args.sizingV
|
|
3972
|
+
});
|
|
3973
|
+
printResult(result, args.json, "update");
|
|
3974
|
+
} catch (e2) {
|
|
3975
|
+
handleError(e2);
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3978
|
+
});
|
|
3979
|
+
// packages/cli/src/commands/set-blend-mode.ts
|
|
3980
|
+
var set_blend_mode_default = defineCommand({
|
|
3981
|
+
meta: { description: "Set blend mode of a node" },
|
|
3982
|
+
args: {
|
|
3983
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
3984
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
3985
|
+
mode: { type: "string", description: "Blend mode: NORMAL, DARKEN, MULTIPLY, SCREEN, OVERLAY, etc", required: true }
|
|
3986
|
+
},
|
|
3987
|
+
async run({ args }) {
|
|
3988
|
+
try {
|
|
3989
|
+
const result = await sendCommand("set-blend-mode", {
|
|
3990
|
+
id: args.id,
|
|
3991
|
+
mode: args.mode
|
|
3992
|
+
});
|
|
3993
|
+
printResult(result, args.json, "update");
|
|
3994
|
+
} catch (e2) {
|
|
3995
|
+
handleError(e2);
|
|
3996
|
+
}
|
|
3997
|
+
}
|
|
3998
|
+
});
|
|
3999
|
+
// packages/cli/src/commands/set-layout-child.ts
|
|
4000
|
+
var set_layout_child_default = defineCommand({
|
|
4001
|
+
meta: { description: "Set layout properties of a child in auto-layout" },
|
|
4002
|
+
args: {
|
|
4003
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
4004
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
4005
|
+
horizontalSizing: { type: "string", description: "Horizontal sizing: FIXED, FILL, HUG" },
|
|
4006
|
+
verticalSizing: { type: "string", description: "Vertical sizing: FIXED, FILL, HUG" },
|
|
4007
|
+
positioning: { type: "string", description: "Positioning: AUTO, ABSOLUTE" },
|
|
4008
|
+
x: { type: "string", description: "X position (for absolute)" },
|
|
4009
|
+
y: { type: "string", description: "Y position (for absolute)" }
|
|
4010
|
+
},
|
|
4011
|
+
async run({ args }) {
|
|
4012
|
+
try {
|
|
4013
|
+
const result = await sendCommand("set-layout-child", {
|
|
4014
|
+
id: args.id,
|
|
4015
|
+
horizontalSizing: args.horizontalSizing,
|
|
4016
|
+
verticalSizing: args.verticalSizing,
|
|
4017
|
+
positioning: args.positioning,
|
|
4018
|
+
x: args.x ? Number(args.x) : undefined,
|
|
4019
|
+
y: args.y ? Number(args.y) : undefined
|
|
4020
|
+
});
|
|
4021
|
+
printResult(result, args.json, "update");
|
|
4022
|
+
} catch (e2) {
|
|
4023
|
+
handleError(e2);
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
});
|
|
4027
|
+
// packages/cli/src/commands/set-text-properties.ts
|
|
4028
|
+
var set_text_properties_default = defineCommand({
|
|
4029
|
+
meta: { description: "Set text properties (line height, spacing, alignment, etc)" },
|
|
4030
|
+
args: {
|
|
4031
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
4032
|
+
id: { type: "string", description: "Text node ID", required: true },
|
|
4033
|
+
lineHeight: { type: "string", description: 'Line height (number or "auto")' },
|
|
4034
|
+
letterSpacing: { type: "string", description: "Letter spacing in px" },
|
|
4035
|
+
textAlign: { type: "string", description: "Horizontal: LEFT, CENTER, RIGHT, JUSTIFIED" },
|
|
4036
|
+
verticalAlign: { type: "string", description: "Vertical: TOP, CENTER, BOTTOM" },
|
|
4037
|
+
autoResize: { type: "string", description: "Auto resize: NONE, WIDTH_AND_HEIGHT, HEIGHT, TRUNCATE" },
|
|
4038
|
+
maxLines: { type: "string", description: "Max lines (for truncation)" },
|
|
4039
|
+
paragraphSpacing: { type: "string", description: "Spacing between paragraphs" },
|
|
4040
|
+
paragraphIndent: { type: "string", description: "First line indent" }
|
|
4041
|
+
},
|
|
4042
|
+
async run({ args }) {
|
|
4043
|
+
try {
|
|
4044
|
+
const result = await sendCommand("set-text-properties", {
|
|
4045
|
+
id: args.id,
|
|
4046
|
+
lineHeight: args.lineHeight === "auto" ? "auto" : args.lineHeight ? Number(args.lineHeight) : undefined,
|
|
4047
|
+
letterSpacing: args.letterSpacing ? Number(args.letterSpacing) : undefined,
|
|
4048
|
+
textAlign: args.textAlign,
|
|
4049
|
+
verticalAlign: args.verticalAlign,
|
|
4050
|
+
autoResize: args.autoResize,
|
|
4051
|
+
maxLines: args.maxLines ? Number(args.maxLines) : undefined,
|
|
4052
|
+
paragraphSpacing: args.paragraphSpacing ? Number(args.paragraphSpacing) : undefined,
|
|
4053
|
+
paragraphIndent: args.paragraphIndent ? Number(args.paragraphIndent) : undefined
|
|
4054
|
+
});
|
|
4055
|
+
printResult(result, args.json, "update");
|
|
4056
|
+
} catch (e2) {
|
|
4057
|
+
handleError(e2);
|
|
4058
|
+
}
|
|
4059
|
+
}
|
|
4060
|
+
});
|
|
4061
|
+
// packages/cli/src/commands/set-min-max.ts
|
|
4062
|
+
var set_min_max_default = defineCommand({
|
|
4063
|
+
meta: { description: "Set min/max width and height constraints" },
|
|
4064
|
+
args: {
|
|
4065
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
4066
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
4067
|
+
minWidth: { type: "string", description: "Minimum width" },
|
|
4068
|
+
maxWidth: { type: "string", description: "Maximum width" },
|
|
4069
|
+
minHeight: { type: "string", description: "Minimum height" },
|
|
4070
|
+
maxHeight: { type: "string", description: "Maximum height" }
|
|
4071
|
+
},
|
|
4072
|
+
async run({ args }) {
|
|
4073
|
+
try {
|
|
4074
|
+
const result = await sendCommand("set-min-max", {
|
|
4075
|
+
id: args.id,
|
|
4076
|
+
minWidth: args.minWidth ? Number(args.minWidth) : undefined,
|
|
4077
|
+
maxWidth: args.maxWidth ? Number(args.maxWidth) : undefined,
|
|
4078
|
+
minHeight: args.minHeight ? Number(args.minHeight) : undefined,
|
|
4079
|
+
maxHeight: args.maxHeight ? Number(args.maxHeight) : undefined
|
|
4080
|
+
});
|
|
4081
|
+
printResult(result, args.json, "update");
|
|
4082
|
+
} catch (e2) {
|
|
4083
|
+
handleError(e2);
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
});
|
|
4087
|
+
// packages/cli/src/commands/set-rotation.ts
|
|
4088
|
+
var set_rotation_default = defineCommand({
|
|
4089
|
+
meta: { description: "Set rotation of a node" },
|
|
4090
|
+
args: {
|
|
4091
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
4092
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
4093
|
+
angle: { type: "string", description: "Rotation angle in degrees", required: true }
|
|
4094
|
+
},
|
|
4095
|
+
async run({ args }) {
|
|
4096
|
+
try {
|
|
4097
|
+
const result = await sendCommand("set-rotation", {
|
|
4098
|
+
id: args.id,
|
|
4099
|
+
angle: Number(args.angle)
|
|
4100
|
+
});
|
|
4101
|
+
printResult(result, args.json, "update");
|
|
4102
|
+
} catch (e2) {
|
|
4103
|
+
handleError(e2);
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
});
|
|
4107
|
+
// packages/cli/src/commands/set-stroke-align.ts
|
|
4108
|
+
var set_stroke_align_default = defineCommand({
|
|
4109
|
+
meta: { description: "Set stroke alignment" },
|
|
4110
|
+
args: {
|
|
4111
|
+
json: { type: "boolean", description: "Output as JSON" },
|
|
4112
|
+
id: { type: "string", description: "Node ID", required: true },
|
|
4113
|
+
align: { type: "string", description: "Alignment: INSIDE, OUTSIDE, CENTER", required: true }
|
|
4114
|
+
},
|
|
4115
|
+
async run({ args }) {
|
|
4116
|
+
try {
|
|
4117
|
+
const result = await sendCommand("set-stroke-align", {
|
|
4118
|
+
id: args.id,
|
|
4119
|
+
align: args.align
|
|
4120
|
+
});
|
|
4121
|
+
printResult(result, args.json, "update");
|
|
4122
|
+
} catch (e2) {
|
|
4123
|
+
handleError(e2);
|
|
4124
|
+
}
|
|
4125
|
+
}
|
|
4126
|
+
});
|
|
4127
|
+
// packages/cli/src/index.ts
|
|
4128
|
+
var main = defineCommand({
|
|
4129
|
+
meta: {
|
|
4130
|
+
name: "figma",
|
|
4131
|
+
description: "CLI to interact with Figma via proxy",
|
|
4132
|
+
version: "0.1.0"
|
|
4133
|
+
},
|
|
4134
|
+
subCommands: exports_commands
|
|
4135
|
+
});
|
|
4136
|
+
runMain(main);
|