@uniformdev/cli 18.18.1-alpha.12 → 18.19.1-alpha.7

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.
@@ -1,2013 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // ../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js
30
- var require_color_name = __commonJS({
31
- "../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js"(exports, module2) {
32
- "use strict";
33
- module2.exports = {
34
- "aliceblue": [240, 248, 255],
35
- "antiquewhite": [250, 235, 215],
36
- "aqua": [0, 255, 255],
37
- "aquamarine": [127, 255, 212],
38
- "azure": [240, 255, 255],
39
- "beige": [245, 245, 220],
40
- "bisque": [255, 228, 196],
41
- "black": [0, 0, 0],
42
- "blanchedalmond": [255, 235, 205],
43
- "blue": [0, 0, 255],
44
- "blueviolet": [138, 43, 226],
45
- "brown": [165, 42, 42],
46
- "burlywood": [222, 184, 135],
47
- "cadetblue": [95, 158, 160],
48
- "chartreuse": [127, 255, 0],
49
- "chocolate": [210, 105, 30],
50
- "coral": [255, 127, 80],
51
- "cornflowerblue": [100, 149, 237],
52
- "cornsilk": [255, 248, 220],
53
- "crimson": [220, 20, 60],
54
- "cyan": [0, 255, 255],
55
- "darkblue": [0, 0, 139],
56
- "darkcyan": [0, 139, 139],
57
- "darkgoldenrod": [184, 134, 11],
58
- "darkgray": [169, 169, 169],
59
- "darkgreen": [0, 100, 0],
60
- "darkgrey": [169, 169, 169],
61
- "darkkhaki": [189, 183, 107],
62
- "darkmagenta": [139, 0, 139],
63
- "darkolivegreen": [85, 107, 47],
64
- "darkorange": [255, 140, 0],
65
- "darkorchid": [153, 50, 204],
66
- "darkred": [139, 0, 0],
67
- "darksalmon": [233, 150, 122],
68
- "darkseagreen": [143, 188, 143],
69
- "darkslateblue": [72, 61, 139],
70
- "darkslategray": [47, 79, 79],
71
- "darkslategrey": [47, 79, 79],
72
- "darkturquoise": [0, 206, 209],
73
- "darkviolet": [148, 0, 211],
74
- "deeppink": [255, 20, 147],
75
- "deepskyblue": [0, 191, 255],
76
- "dimgray": [105, 105, 105],
77
- "dimgrey": [105, 105, 105],
78
- "dodgerblue": [30, 144, 255],
79
- "firebrick": [178, 34, 34],
80
- "floralwhite": [255, 250, 240],
81
- "forestgreen": [34, 139, 34],
82
- "fuchsia": [255, 0, 255],
83
- "gainsboro": [220, 220, 220],
84
- "ghostwhite": [248, 248, 255],
85
- "gold": [255, 215, 0],
86
- "goldenrod": [218, 165, 32],
87
- "gray": [128, 128, 128],
88
- "green": [0, 128, 0],
89
- "greenyellow": [173, 255, 47],
90
- "grey": [128, 128, 128],
91
- "honeydew": [240, 255, 240],
92
- "hotpink": [255, 105, 180],
93
- "indianred": [205, 92, 92],
94
- "indigo": [75, 0, 130],
95
- "ivory": [255, 255, 240],
96
- "khaki": [240, 230, 140],
97
- "lavender": [230, 230, 250],
98
- "lavenderblush": [255, 240, 245],
99
- "lawngreen": [124, 252, 0],
100
- "lemonchiffon": [255, 250, 205],
101
- "lightblue": [173, 216, 230],
102
- "lightcoral": [240, 128, 128],
103
- "lightcyan": [224, 255, 255],
104
- "lightgoldenrodyellow": [250, 250, 210],
105
- "lightgray": [211, 211, 211],
106
- "lightgreen": [144, 238, 144],
107
- "lightgrey": [211, 211, 211],
108
- "lightpink": [255, 182, 193],
109
- "lightsalmon": [255, 160, 122],
110
- "lightseagreen": [32, 178, 170],
111
- "lightskyblue": [135, 206, 250],
112
- "lightslategray": [119, 136, 153],
113
- "lightslategrey": [119, 136, 153],
114
- "lightsteelblue": [176, 196, 222],
115
- "lightyellow": [255, 255, 224],
116
- "lime": [0, 255, 0],
117
- "limegreen": [50, 205, 50],
118
- "linen": [250, 240, 230],
119
- "magenta": [255, 0, 255],
120
- "maroon": [128, 0, 0],
121
- "mediumaquamarine": [102, 205, 170],
122
- "mediumblue": [0, 0, 205],
123
- "mediumorchid": [186, 85, 211],
124
- "mediumpurple": [147, 112, 219],
125
- "mediumseagreen": [60, 179, 113],
126
- "mediumslateblue": [123, 104, 238],
127
- "mediumspringgreen": [0, 250, 154],
128
- "mediumturquoise": [72, 209, 204],
129
- "mediumvioletred": [199, 21, 133],
130
- "midnightblue": [25, 25, 112],
131
- "mintcream": [245, 255, 250],
132
- "mistyrose": [255, 228, 225],
133
- "moccasin": [255, 228, 181],
134
- "navajowhite": [255, 222, 173],
135
- "navy": [0, 0, 128],
136
- "oldlace": [253, 245, 230],
137
- "olive": [128, 128, 0],
138
- "olivedrab": [107, 142, 35],
139
- "orange": [255, 165, 0],
140
- "orangered": [255, 69, 0],
141
- "orchid": [218, 112, 214],
142
- "palegoldenrod": [238, 232, 170],
143
- "palegreen": [152, 251, 152],
144
- "paleturquoise": [175, 238, 238],
145
- "palevioletred": [219, 112, 147],
146
- "papayawhip": [255, 239, 213],
147
- "peachpuff": [255, 218, 185],
148
- "peru": [205, 133, 63],
149
- "pink": [255, 192, 203],
150
- "plum": [221, 160, 221],
151
- "powderblue": [176, 224, 230],
152
- "purple": [128, 0, 128],
153
- "rebeccapurple": [102, 51, 153],
154
- "red": [255, 0, 0],
155
- "rosybrown": [188, 143, 143],
156
- "royalblue": [65, 105, 225],
157
- "saddlebrown": [139, 69, 19],
158
- "salmon": [250, 128, 114],
159
- "sandybrown": [244, 164, 96],
160
- "seagreen": [46, 139, 87],
161
- "seashell": [255, 245, 238],
162
- "sienna": [160, 82, 45],
163
- "silver": [192, 192, 192],
164
- "skyblue": [135, 206, 235],
165
- "slateblue": [106, 90, 205],
166
- "slategray": [112, 128, 144],
167
- "slategrey": [112, 128, 144],
168
- "snow": [255, 250, 250],
169
- "springgreen": [0, 255, 127],
170
- "steelblue": [70, 130, 180],
171
- "tan": [210, 180, 140],
172
- "teal": [0, 128, 128],
173
- "thistle": [216, 191, 216],
174
- "tomato": [255, 99, 71],
175
- "turquoise": [64, 224, 208],
176
- "violet": [238, 130, 238],
177
- "wheat": [245, 222, 179],
178
- "white": [255, 255, 255],
179
- "whitesmoke": [245, 245, 245],
180
- "yellow": [255, 255, 0],
181
- "yellowgreen": [154, 205, 50]
182
- };
183
- }
184
- });
185
-
186
- // ../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js
187
- var require_conversions = __commonJS({
188
- "../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js"(exports, module2) {
189
- var cssKeywords = require_color_name();
190
- var reverseKeywords = {};
191
- for (const key of Object.keys(cssKeywords)) {
192
- reverseKeywords[cssKeywords[key]] = key;
193
- }
194
- var convert = {
195
- rgb: { channels: 3, labels: "rgb" },
196
- hsl: { channels: 3, labels: "hsl" },
197
- hsv: { channels: 3, labels: "hsv" },
198
- hwb: { channels: 3, labels: "hwb" },
199
- cmyk: { channels: 4, labels: "cmyk" },
200
- xyz: { channels: 3, labels: "xyz" },
201
- lab: { channels: 3, labels: "lab" },
202
- lch: { channels: 3, labels: "lch" },
203
- hex: { channels: 1, labels: ["hex"] },
204
- keyword: { channels: 1, labels: ["keyword"] },
205
- ansi16: { channels: 1, labels: ["ansi16"] },
206
- ansi256: { channels: 1, labels: ["ansi256"] },
207
- hcg: { channels: 3, labels: ["h", "c", "g"] },
208
- apple: { channels: 3, labels: ["r16", "g16", "b16"] },
209
- gray: { channels: 1, labels: ["gray"] }
210
- };
211
- module2.exports = convert;
212
- for (const model of Object.keys(convert)) {
213
- if (!("channels" in convert[model])) {
214
- throw new Error("missing channels property: " + model);
215
- }
216
- if (!("labels" in convert[model])) {
217
- throw new Error("missing channel labels property: " + model);
218
- }
219
- if (convert[model].labels.length !== convert[model].channels) {
220
- throw new Error("channel and label counts mismatch: " + model);
221
- }
222
- const { channels, labels } = convert[model];
223
- delete convert[model].channels;
224
- delete convert[model].labels;
225
- Object.defineProperty(convert[model], "channels", { value: channels });
226
- Object.defineProperty(convert[model], "labels", { value: labels });
227
- }
228
- convert.rgb.hsl = function(rgb) {
229
- const r = rgb[0] / 255;
230
- const g = rgb[1] / 255;
231
- const b = rgb[2] / 255;
232
- const min = Math.min(r, g, b);
233
- const max = Math.max(r, g, b);
234
- const delta = max - min;
235
- let h;
236
- let s;
237
- if (max === min) {
238
- h = 0;
239
- } else if (r === max) {
240
- h = (g - b) / delta;
241
- } else if (g === max) {
242
- h = 2 + (b - r) / delta;
243
- } else if (b === max) {
244
- h = 4 + (r - g) / delta;
245
- }
246
- h = Math.min(h * 60, 360);
247
- if (h < 0) {
248
- h += 360;
249
- }
250
- const l = (min + max) / 2;
251
- if (max === min) {
252
- s = 0;
253
- } else if (l <= 0.5) {
254
- s = delta / (max + min);
255
- } else {
256
- s = delta / (2 - max - min);
257
- }
258
- return [h, s * 100, l * 100];
259
- };
260
- convert.rgb.hsv = function(rgb) {
261
- let rdif;
262
- let gdif;
263
- let bdif;
264
- let h;
265
- let s;
266
- const r = rgb[0] / 255;
267
- const g = rgb[1] / 255;
268
- const b = rgb[2] / 255;
269
- const v = Math.max(r, g, b);
270
- const diff = v - Math.min(r, g, b);
271
- const diffc = function(c) {
272
- return (v - c) / 6 / diff + 1 / 2;
273
- };
274
- if (diff === 0) {
275
- h = 0;
276
- s = 0;
277
- } else {
278
- s = diff / v;
279
- rdif = diffc(r);
280
- gdif = diffc(g);
281
- bdif = diffc(b);
282
- if (r === v) {
283
- h = bdif - gdif;
284
- } else if (g === v) {
285
- h = 1 / 3 + rdif - bdif;
286
- } else if (b === v) {
287
- h = 2 / 3 + gdif - rdif;
288
- }
289
- if (h < 0) {
290
- h += 1;
291
- } else if (h > 1) {
292
- h -= 1;
293
- }
294
- }
295
- return [
296
- h * 360,
297
- s * 100,
298
- v * 100
299
- ];
300
- };
301
- convert.rgb.hwb = function(rgb) {
302
- const r = rgb[0];
303
- const g = rgb[1];
304
- let b = rgb[2];
305
- const h = convert.rgb.hsl(rgb)[0];
306
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
307
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
308
- return [h, w * 100, b * 100];
309
- };
310
- convert.rgb.cmyk = function(rgb) {
311
- const r = rgb[0] / 255;
312
- const g = rgb[1] / 255;
313
- const b = rgb[2] / 255;
314
- const k = Math.min(1 - r, 1 - g, 1 - b);
315
- const c = (1 - r - k) / (1 - k) || 0;
316
- const m = (1 - g - k) / (1 - k) || 0;
317
- const y = (1 - b - k) / (1 - k) || 0;
318
- return [c * 100, m * 100, y * 100, k * 100];
319
- };
320
- function comparativeDistance(x, y) {
321
- return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
322
- }
323
- convert.rgb.keyword = function(rgb) {
324
- const reversed = reverseKeywords[rgb];
325
- if (reversed) {
326
- return reversed;
327
- }
328
- let currentClosestDistance = Infinity;
329
- let currentClosestKeyword;
330
- for (const keyword of Object.keys(cssKeywords)) {
331
- const value = cssKeywords[keyword];
332
- const distance = comparativeDistance(rgb, value);
333
- if (distance < currentClosestDistance) {
334
- currentClosestDistance = distance;
335
- currentClosestKeyword = keyword;
336
- }
337
- }
338
- return currentClosestKeyword;
339
- };
340
- convert.keyword.rgb = function(keyword) {
341
- return cssKeywords[keyword];
342
- };
343
- convert.rgb.xyz = function(rgb) {
344
- let r = rgb[0] / 255;
345
- let g = rgb[1] / 255;
346
- let b = rgb[2] / 255;
347
- r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
348
- g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
349
- b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
350
- const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
351
- const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
352
- const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
353
- return [x * 100, y * 100, z * 100];
354
- };
355
- convert.rgb.lab = function(rgb) {
356
- const xyz = convert.rgb.xyz(rgb);
357
- let x = xyz[0];
358
- let y = xyz[1];
359
- let z = xyz[2];
360
- x /= 95.047;
361
- y /= 100;
362
- z /= 108.883;
363
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
364
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
365
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
366
- const l = 116 * y - 16;
367
- const a = 500 * (x - y);
368
- const b = 200 * (y - z);
369
- return [l, a, b];
370
- };
371
- convert.hsl.rgb = function(hsl) {
372
- const h = hsl[0] / 360;
373
- const s = hsl[1] / 100;
374
- const l = hsl[2] / 100;
375
- let t2;
376
- let t3;
377
- let val;
378
- if (s === 0) {
379
- val = l * 255;
380
- return [val, val, val];
381
- }
382
- if (l < 0.5) {
383
- t2 = l * (1 + s);
384
- } else {
385
- t2 = l + s - l * s;
386
- }
387
- const t1 = 2 * l - t2;
388
- const rgb = [0, 0, 0];
389
- for (let i = 0; i < 3; i++) {
390
- t3 = h + 1 / 3 * -(i - 1);
391
- if (t3 < 0) {
392
- t3++;
393
- }
394
- if (t3 > 1) {
395
- t3--;
396
- }
397
- if (6 * t3 < 1) {
398
- val = t1 + (t2 - t1) * 6 * t3;
399
- } else if (2 * t3 < 1) {
400
- val = t2;
401
- } else if (3 * t3 < 2) {
402
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
403
- } else {
404
- val = t1;
405
- }
406
- rgb[i] = val * 255;
407
- }
408
- return rgb;
409
- };
410
- convert.hsl.hsv = function(hsl) {
411
- const h = hsl[0];
412
- let s = hsl[1] / 100;
413
- let l = hsl[2] / 100;
414
- let smin = s;
415
- const lmin = Math.max(l, 0.01);
416
- l *= 2;
417
- s *= l <= 1 ? l : 2 - l;
418
- smin *= lmin <= 1 ? lmin : 2 - lmin;
419
- const v = (l + s) / 2;
420
- const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
421
- return [h, sv * 100, v * 100];
422
- };
423
- convert.hsv.rgb = function(hsv) {
424
- const h = hsv[0] / 60;
425
- const s = hsv[1] / 100;
426
- let v = hsv[2] / 100;
427
- const hi = Math.floor(h) % 6;
428
- const f = h - Math.floor(h);
429
- const p = 255 * v * (1 - s);
430
- const q = 255 * v * (1 - s * f);
431
- const t = 255 * v * (1 - s * (1 - f));
432
- v *= 255;
433
- switch (hi) {
434
- case 0:
435
- return [v, t, p];
436
- case 1:
437
- return [q, v, p];
438
- case 2:
439
- return [p, v, t];
440
- case 3:
441
- return [p, q, v];
442
- case 4:
443
- return [t, p, v];
444
- case 5:
445
- return [v, p, q];
446
- }
447
- };
448
- convert.hsv.hsl = function(hsv) {
449
- const h = hsv[0];
450
- const s = hsv[1] / 100;
451
- const v = hsv[2] / 100;
452
- const vmin = Math.max(v, 0.01);
453
- let sl;
454
- let l;
455
- l = (2 - s) * v;
456
- const lmin = (2 - s) * vmin;
457
- sl = s * vmin;
458
- sl /= lmin <= 1 ? lmin : 2 - lmin;
459
- sl = sl || 0;
460
- l /= 2;
461
- return [h, sl * 100, l * 100];
462
- };
463
- convert.hwb.rgb = function(hwb) {
464
- const h = hwb[0] / 360;
465
- let wh = hwb[1] / 100;
466
- let bl = hwb[2] / 100;
467
- const ratio = wh + bl;
468
- let f;
469
- if (ratio > 1) {
470
- wh /= ratio;
471
- bl /= ratio;
472
- }
473
- const i = Math.floor(6 * h);
474
- const v = 1 - bl;
475
- f = 6 * h - i;
476
- if ((i & 1) !== 0) {
477
- f = 1 - f;
478
- }
479
- const n = wh + f * (v - wh);
480
- let r;
481
- let g;
482
- let b;
483
- switch (i) {
484
- default:
485
- case 6:
486
- case 0:
487
- r = v;
488
- g = n;
489
- b = wh;
490
- break;
491
- case 1:
492
- r = n;
493
- g = v;
494
- b = wh;
495
- break;
496
- case 2:
497
- r = wh;
498
- g = v;
499
- b = n;
500
- break;
501
- case 3:
502
- r = wh;
503
- g = n;
504
- b = v;
505
- break;
506
- case 4:
507
- r = n;
508
- g = wh;
509
- b = v;
510
- break;
511
- case 5:
512
- r = v;
513
- g = wh;
514
- b = n;
515
- break;
516
- }
517
- return [r * 255, g * 255, b * 255];
518
- };
519
- convert.cmyk.rgb = function(cmyk) {
520
- const c = cmyk[0] / 100;
521
- const m = cmyk[1] / 100;
522
- const y = cmyk[2] / 100;
523
- const k = cmyk[3] / 100;
524
- const r = 1 - Math.min(1, c * (1 - k) + k);
525
- const g = 1 - Math.min(1, m * (1 - k) + k);
526
- const b = 1 - Math.min(1, y * (1 - k) + k);
527
- return [r * 255, g * 255, b * 255];
528
- };
529
- convert.xyz.rgb = function(xyz) {
530
- const x = xyz[0] / 100;
531
- const y = xyz[1] / 100;
532
- const z = xyz[2] / 100;
533
- let r;
534
- let g;
535
- let b;
536
- r = x * 3.2406 + y * -1.5372 + z * -0.4986;
537
- g = x * -0.9689 + y * 1.8758 + z * 0.0415;
538
- b = x * 0.0557 + y * -0.204 + z * 1.057;
539
- r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
540
- g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
541
- b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
542
- r = Math.min(Math.max(0, r), 1);
543
- g = Math.min(Math.max(0, g), 1);
544
- b = Math.min(Math.max(0, b), 1);
545
- return [r * 255, g * 255, b * 255];
546
- };
547
- convert.xyz.lab = function(xyz) {
548
- let x = xyz[0];
549
- let y = xyz[1];
550
- let z = xyz[2];
551
- x /= 95.047;
552
- y /= 100;
553
- z /= 108.883;
554
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
555
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
556
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
557
- const l = 116 * y - 16;
558
- const a = 500 * (x - y);
559
- const b = 200 * (y - z);
560
- return [l, a, b];
561
- };
562
- convert.lab.xyz = function(lab) {
563
- const l = lab[0];
564
- const a = lab[1];
565
- const b = lab[2];
566
- let x;
567
- let y;
568
- let z;
569
- y = (l + 16) / 116;
570
- x = a / 500 + y;
571
- z = y - b / 200;
572
- const y2 = y ** 3;
573
- const x2 = x ** 3;
574
- const z2 = z ** 3;
575
- y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
576
- x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
577
- z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
578
- x *= 95.047;
579
- y *= 100;
580
- z *= 108.883;
581
- return [x, y, z];
582
- };
583
- convert.lab.lch = function(lab) {
584
- const l = lab[0];
585
- const a = lab[1];
586
- const b = lab[2];
587
- let h;
588
- const hr = Math.atan2(b, a);
589
- h = hr * 360 / 2 / Math.PI;
590
- if (h < 0) {
591
- h += 360;
592
- }
593
- const c = Math.sqrt(a * a + b * b);
594
- return [l, c, h];
595
- };
596
- convert.lch.lab = function(lch) {
597
- const l = lch[0];
598
- const c = lch[1];
599
- const h = lch[2];
600
- const hr = h / 360 * 2 * Math.PI;
601
- const a = c * Math.cos(hr);
602
- const b = c * Math.sin(hr);
603
- return [l, a, b];
604
- };
605
- convert.rgb.ansi16 = function(args, saturation = null) {
606
- const [r, g, b] = args;
607
- let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
608
- value = Math.round(value / 50);
609
- if (value === 0) {
610
- return 30;
611
- }
612
- let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
613
- if (value === 2) {
614
- ansi += 60;
615
- }
616
- return ansi;
617
- };
618
- convert.hsv.ansi16 = function(args) {
619
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
620
- };
621
- convert.rgb.ansi256 = function(args) {
622
- const r = args[0];
623
- const g = args[1];
624
- const b = args[2];
625
- if (r === g && g === b) {
626
- if (r < 8) {
627
- return 16;
628
- }
629
- if (r > 248) {
630
- return 231;
631
- }
632
- return Math.round((r - 8) / 247 * 24) + 232;
633
- }
634
- const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
635
- return ansi;
636
- };
637
- convert.ansi16.rgb = function(args) {
638
- let color = args % 10;
639
- if (color === 0 || color === 7) {
640
- if (args > 50) {
641
- color += 3.5;
642
- }
643
- color = color / 10.5 * 255;
644
- return [color, color, color];
645
- }
646
- const mult = (~~(args > 50) + 1) * 0.5;
647
- const r = (color & 1) * mult * 255;
648
- const g = (color >> 1 & 1) * mult * 255;
649
- const b = (color >> 2 & 1) * mult * 255;
650
- return [r, g, b];
651
- };
652
- convert.ansi256.rgb = function(args) {
653
- if (args >= 232) {
654
- const c = (args - 232) * 10 + 8;
655
- return [c, c, c];
656
- }
657
- args -= 16;
658
- let rem;
659
- const r = Math.floor(args / 36) / 5 * 255;
660
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
661
- const b = rem % 6 / 5 * 255;
662
- return [r, g, b];
663
- };
664
- convert.rgb.hex = function(args) {
665
- const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
666
- const string = integer.toString(16).toUpperCase();
667
- return "000000".substring(string.length) + string;
668
- };
669
- convert.hex.rgb = function(args) {
670
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
671
- if (!match) {
672
- return [0, 0, 0];
673
- }
674
- let colorString = match[0];
675
- if (match[0].length === 3) {
676
- colorString = colorString.split("").map((char) => {
677
- return char + char;
678
- }).join("");
679
- }
680
- const integer = parseInt(colorString, 16);
681
- const r = integer >> 16 & 255;
682
- const g = integer >> 8 & 255;
683
- const b = integer & 255;
684
- return [r, g, b];
685
- };
686
- convert.rgb.hcg = function(rgb) {
687
- const r = rgb[0] / 255;
688
- const g = rgb[1] / 255;
689
- const b = rgb[2] / 255;
690
- const max = Math.max(Math.max(r, g), b);
691
- const min = Math.min(Math.min(r, g), b);
692
- const chroma = max - min;
693
- let grayscale;
694
- let hue;
695
- if (chroma < 1) {
696
- grayscale = min / (1 - chroma);
697
- } else {
698
- grayscale = 0;
699
- }
700
- if (chroma <= 0) {
701
- hue = 0;
702
- } else if (max === r) {
703
- hue = (g - b) / chroma % 6;
704
- } else if (max === g) {
705
- hue = 2 + (b - r) / chroma;
706
- } else {
707
- hue = 4 + (r - g) / chroma;
708
- }
709
- hue /= 6;
710
- hue %= 1;
711
- return [hue * 360, chroma * 100, grayscale * 100];
712
- };
713
- convert.hsl.hcg = function(hsl) {
714
- const s = hsl[1] / 100;
715
- const l = hsl[2] / 100;
716
- const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
717
- let f = 0;
718
- if (c < 1) {
719
- f = (l - 0.5 * c) / (1 - c);
720
- }
721
- return [hsl[0], c * 100, f * 100];
722
- };
723
- convert.hsv.hcg = function(hsv) {
724
- const s = hsv[1] / 100;
725
- const v = hsv[2] / 100;
726
- const c = s * v;
727
- let f = 0;
728
- if (c < 1) {
729
- f = (v - c) / (1 - c);
730
- }
731
- return [hsv[0], c * 100, f * 100];
732
- };
733
- convert.hcg.rgb = function(hcg) {
734
- const h = hcg[0] / 360;
735
- const c = hcg[1] / 100;
736
- const g = hcg[2] / 100;
737
- if (c === 0) {
738
- return [g * 255, g * 255, g * 255];
739
- }
740
- const pure = [0, 0, 0];
741
- const hi = h % 1 * 6;
742
- const v = hi % 1;
743
- const w = 1 - v;
744
- let mg = 0;
745
- switch (Math.floor(hi)) {
746
- case 0:
747
- pure[0] = 1;
748
- pure[1] = v;
749
- pure[2] = 0;
750
- break;
751
- case 1:
752
- pure[0] = w;
753
- pure[1] = 1;
754
- pure[2] = 0;
755
- break;
756
- case 2:
757
- pure[0] = 0;
758
- pure[1] = 1;
759
- pure[2] = v;
760
- break;
761
- case 3:
762
- pure[0] = 0;
763
- pure[1] = w;
764
- pure[2] = 1;
765
- break;
766
- case 4:
767
- pure[0] = v;
768
- pure[1] = 0;
769
- pure[2] = 1;
770
- break;
771
- default:
772
- pure[0] = 1;
773
- pure[1] = 0;
774
- pure[2] = w;
775
- }
776
- mg = (1 - c) * g;
777
- return [
778
- (c * pure[0] + mg) * 255,
779
- (c * pure[1] + mg) * 255,
780
- (c * pure[2] + mg) * 255
781
- ];
782
- };
783
- convert.hcg.hsv = function(hcg) {
784
- const c = hcg[1] / 100;
785
- const g = hcg[2] / 100;
786
- const v = c + g * (1 - c);
787
- let f = 0;
788
- if (v > 0) {
789
- f = c / v;
790
- }
791
- return [hcg[0], f * 100, v * 100];
792
- };
793
- convert.hcg.hsl = function(hcg) {
794
- const c = hcg[1] / 100;
795
- const g = hcg[2] / 100;
796
- const l = g * (1 - c) + 0.5 * c;
797
- let s = 0;
798
- if (l > 0 && l < 0.5) {
799
- s = c / (2 * l);
800
- } else if (l >= 0.5 && l < 1) {
801
- s = c / (2 * (1 - l));
802
- }
803
- return [hcg[0], s * 100, l * 100];
804
- };
805
- convert.hcg.hwb = function(hcg) {
806
- const c = hcg[1] / 100;
807
- const g = hcg[2] / 100;
808
- const v = c + g * (1 - c);
809
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
810
- };
811
- convert.hwb.hcg = function(hwb) {
812
- const w = hwb[1] / 100;
813
- const b = hwb[2] / 100;
814
- const v = 1 - b;
815
- const c = v - w;
816
- let g = 0;
817
- if (c < 1) {
818
- g = (v - c) / (1 - c);
819
- }
820
- return [hwb[0], c * 100, g * 100];
821
- };
822
- convert.apple.rgb = function(apple) {
823
- return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
824
- };
825
- convert.rgb.apple = function(rgb) {
826
- return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
827
- };
828
- convert.gray.rgb = function(args) {
829
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
830
- };
831
- convert.gray.hsl = function(args) {
832
- return [0, 0, args[0]];
833
- };
834
- convert.gray.hsv = convert.gray.hsl;
835
- convert.gray.hwb = function(gray) {
836
- return [0, 100, gray[0]];
837
- };
838
- convert.gray.cmyk = function(gray) {
839
- return [0, 0, 0, gray[0]];
840
- };
841
- convert.gray.lab = function(gray) {
842
- return [gray[0], 0, 0];
843
- };
844
- convert.gray.hex = function(gray) {
845
- const val = Math.round(gray[0] / 100 * 255) & 255;
846
- const integer = (val << 16) + (val << 8) + val;
847
- const string = integer.toString(16).toUpperCase();
848
- return "000000".substring(string.length) + string;
849
- };
850
- convert.rgb.gray = function(rgb) {
851
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
852
- return [val / 255 * 100];
853
- };
854
- }
855
- });
856
-
857
- // ../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js
858
- var require_route = __commonJS({
859
- "../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js"(exports, module2) {
860
- var conversions = require_conversions();
861
- function buildGraph() {
862
- const graph = {};
863
- const models = Object.keys(conversions);
864
- for (let len = models.length, i = 0; i < len; i++) {
865
- graph[models[i]] = {
866
- distance: -1,
867
- parent: null
868
- };
869
- }
870
- return graph;
871
- }
872
- function deriveBFS(fromModel) {
873
- const graph = buildGraph();
874
- const queue = [fromModel];
875
- graph[fromModel].distance = 0;
876
- while (queue.length) {
877
- const current = queue.pop();
878
- const adjacents = Object.keys(conversions[current]);
879
- for (let len = adjacents.length, i = 0; i < len; i++) {
880
- const adjacent = adjacents[i];
881
- const node = graph[adjacent];
882
- if (node.distance === -1) {
883
- node.distance = graph[current].distance + 1;
884
- node.parent = current;
885
- queue.unshift(adjacent);
886
- }
887
- }
888
- }
889
- return graph;
890
- }
891
- function link(from, to) {
892
- return function(args) {
893
- return to(from(args));
894
- };
895
- }
896
- function wrapConversion(toModel, graph) {
897
- const path = [graph[toModel].parent, toModel];
898
- let fn = conversions[graph[toModel].parent][toModel];
899
- let cur = graph[toModel].parent;
900
- while (graph[cur].parent) {
901
- path.unshift(graph[cur].parent);
902
- fn = link(conversions[graph[cur].parent][cur], fn);
903
- cur = graph[cur].parent;
904
- }
905
- fn.conversion = path;
906
- return fn;
907
- }
908
- module2.exports = function(fromModel) {
909
- const graph = deriveBFS(fromModel);
910
- const conversion = {};
911
- const models = Object.keys(graph);
912
- for (let len = models.length, i = 0; i < len; i++) {
913
- const toModel = models[i];
914
- const node = graph[toModel];
915
- if (node.parent === null) {
916
- continue;
917
- }
918
- conversion[toModel] = wrapConversion(toModel, graph);
919
- }
920
- return conversion;
921
- };
922
- }
923
- });
924
-
925
- // ../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js
926
- var require_color_convert = __commonJS({
927
- "../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js"(exports, module2) {
928
- var conversions = require_conversions();
929
- var route = require_route();
930
- var convert = {};
931
- var models = Object.keys(conversions);
932
- function wrapRaw(fn) {
933
- const wrappedFn = function(...args) {
934
- const arg0 = args[0];
935
- if (arg0 === void 0 || arg0 === null) {
936
- return arg0;
937
- }
938
- if (arg0.length > 1) {
939
- args = arg0;
940
- }
941
- return fn(args);
942
- };
943
- if ("conversion" in fn) {
944
- wrappedFn.conversion = fn.conversion;
945
- }
946
- return wrappedFn;
947
- }
948
- function wrapRounded(fn) {
949
- const wrappedFn = function(...args) {
950
- const arg0 = args[0];
951
- if (arg0 === void 0 || arg0 === null) {
952
- return arg0;
953
- }
954
- if (arg0.length > 1) {
955
- args = arg0;
956
- }
957
- const result = fn(args);
958
- if (typeof result === "object") {
959
- for (let len = result.length, i = 0; i < len; i++) {
960
- result[i] = Math.round(result[i]);
961
- }
962
- }
963
- return result;
964
- };
965
- if ("conversion" in fn) {
966
- wrappedFn.conversion = fn.conversion;
967
- }
968
- return wrappedFn;
969
- }
970
- models.forEach((fromModel) => {
971
- convert[fromModel] = {};
972
- Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
973
- Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
974
- const routes = route(fromModel);
975
- const routeModels = Object.keys(routes);
976
- routeModels.forEach((toModel) => {
977
- const fn = routes[toModel];
978
- convert[fromModel][toModel] = wrapRounded(fn);
979
- convert[fromModel][toModel].raw = wrapRaw(fn);
980
- });
981
- });
982
- module2.exports = convert;
983
- }
984
- });
985
-
986
- // ../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js
987
- var require_ansi_styles = __commonJS({
988
- "../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js"(exports, module2) {
989
- "use strict";
990
- var wrapAnsi16 = (fn, offset) => (...args) => {
991
- const code = fn(...args);
992
- return `\x1B[${code + offset}m`;
993
- };
994
- var wrapAnsi256 = (fn, offset) => (...args) => {
995
- const code = fn(...args);
996
- return `\x1B[${38 + offset};5;${code}m`;
997
- };
998
- var wrapAnsi16m = (fn, offset) => (...args) => {
999
- const rgb = fn(...args);
1000
- return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1001
- };
1002
- var ansi2ansi = (n) => n;
1003
- var rgb2rgb = (r, g, b) => [r, g, b];
1004
- var setLazyProperty = (object, property, get) => {
1005
- Object.defineProperty(object, property, {
1006
- get: () => {
1007
- const value = get();
1008
- Object.defineProperty(object, property, {
1009
- value,
1010
- enumerable: true,
1011
- configurable: true
1012
- });
1013
- return value;
1014
- },
1015
- enumerable: true,
1016
- configurable: true
1017
- });
1018
- };
1019
- var colorConvert;
1020
- var makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1021
- if (colorConvert === void 0) {
1022
- colorConvert = require_color_convert();
1023
- }
1024
- const offset = isBackground ? 10 : 0;
1025
- const styles = {};
1026
- for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
1027
- const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1028
- if (sourceSpace === targetSpace) {
1029
- styles[name] = wrap(identity, offset);
1030
- } else if (typeof suite === "object") {
1031
- styles[name] = wrap(suite[targetSpace], offset);
1032
- }
1033
- }
1034
- return styles;
1035
- };
1036
- function assembleStyles() {
1037
- const codes = /* @__PURE__ */ new Map();
1038
- const styles = {
1039
- modifier: {
1040
- reset: [0, 0],
1041
- bold: [1, 22],
1042
- dim: [2, 22],
1043
- italic: [3, 23],
1044
- underline: [4, 24],
1045
- inverse: [7, 27],
1046
- hidden: [8, 28],
1047
- strikethrough: [9, 29]
1048
- },
1049
- color: {
1050
- black: [30, 39],
1051
- red: [31, 39],
1052
- green: [32, 39],
1053
- yellow: [33, 39],
1054
- blue: [34, 39],
1055
- magenta: [35, 39],
1056
- cyan: [36, 39],
1057
- white: [37, 39],
1058
- blackBright: [90, 39],
1059
- redBright: [91, 39],
1060
- greenBright: [92, 39],
1061
- yellowBright: [93, 39],
1062
- blueBright: [94, 39],
1063
- magentaBright: [95, 39],
1064
- cyanBright: [96, 39],
1065
- whiteBright: [97, 39]
1066
- },
1067
- bgColor: {
1068
- bgBlack: [40, 49],
1069
- bgRed: [41, 49],
1070
- bgGreen: [42, 49],
1071
- bgYellow: [43, 49],
1072
- bgBlue: [44, 49],
1073
- bgMagenta: [45, 49],
1074
- bgCyan: [46, 49],
1075
- bgWhite: [47, 49],
1076
- bgBlackBright: [100, 49],
1077
- bgRedBright: [101, 49],
1078
- bgGreenBright: [102, 49],
1079
- bgYellowBright: [103, 49],
1080
- bgBlueBright: [104, 49],
1081
- bgMagentaBright: [105, 49],
1082
- bgCyanBright: [106, 49],
1083
- bgWhiteBright: [107, 49]
1084
- }
1085
- };
1086
- styles.color.gray = styles.color.blackBright;
1087
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1088
- styles.color.grey = styles.color.blackBright;
1089
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1090
- for (const [groupName, group] of Object.entries(styles)) {
1091
- for (const [styleName, style] of Object.entries(group)) {
1092
- styles[styleName] = {
1093
- open: `\x1B[${style[0]}m`,
1094
- close: `\x1B[${style[1]}m`
1095
- };
1096
- group[styleName] = styles[styleName];
1097
- codes.set(style[0], style[1]);
1098
- }
1099
- Object.defineProperty(styles, groupName, {
1100
- value: group,
1101
- enumerable: false
1102
- });
1103
- }
1104
- Object.defineProperty(styles, "codes", {
1105
- value: codes,
1106
- enumerable: false
1107
- });
1108
- styles.color.close = "\x1B[39m";
1109
- styles.bgColor.close = "\x1B[49m";
1110
- setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1111
- setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1112
- setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1113
- setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1114
- setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1115
- setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1116
- return styles;
1117
- }
1118
- Object.defineProperty(module2, "exports", {
1119
- enumerable: true,
1120
- get: assembleStyles
1121
- });
1122
- }
1123
- });
1124
-
1125
- // ../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
1126
- var require_has_flag = __commonJS({
1127
- "../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module2) {
1128
- "use strict";
1129
- module2.exports = (flag, argv = process.argv) => {
1130
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1131
- const position = argv.indexOf(prefix + flag);
1132
- const terminatorPosition = argv.indexOf("--");
1133
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1134
- };
1135
- }
1136
- });
1137
-
1138
- // ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
1139
- var require_supports_color = __commonJS({
1140
- "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module2) {
1141
- "use strict";
1142
- var os = require("os");
1143
- var tty = require("tty");
1144
- var hasFlag = require_has_flag();
1145
- var { env } = process;
1146
- var forceColor;
1147
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
1148
- forceColor = 0;
1149
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1150
- forceColor = 1;
1151
- }
1152
- if ("FORCE_COLOR" in env) {
1153
- if (env.FORCE_COLOR === "true") {
1154
- forceColor = 1;
1155
- } else if (env.FORCE_COLOR === "false") {
1156
- forceColor = 0;
1157
- } else {
1158
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
1159
- }
1160
- }
1161
- function translateLevel(level) {
1162
- if (level === 0) {
1163
- return false;
1164
- }
1165
- return {
1166
- level,
1167
- hasBasic: true,
1168
- has256: level >= 2,
1169
- has16m: level >= 3
1170
- };
1171
- }
1172
- function supportsColor(haveStream, streamIsTTY) {
1173
- if (forceColor === 0) {
1174
- return 0;
1175
- }
1176
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1177
- return 3;
1178
- }
1179
- if (hasFlag("color=256")) {
1180
- return 2;
1181
- }
1182
- if (haveStream && !streamIsTTY && forceColor === void 0) {
1183
- return 0;
1184
- }
1185
- const min = forceColor || 0;
1186
- if (env.TERM === "dumb") {
1187
- return min;
1188
- }
1189
- if (process.platform === "win32") {
1190
- const osRelease = os.release().split(".");
1191
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1192
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1193
- }
1194
- return 1;
1195
- }
1196
- if ("CI" in env) {
1197
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1198
- return 1;
1199
- }
1200
- return min;
1201
- }
1202
- if ("TEAMCITY_VERSION" in env) {
1203
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1204
- }
1205
- if (env.COLORTERM === "truecolor") {
1206
- return 3;
1207
- }
1208
- if ("TERM_PROGRAM" in env) {
1209
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1210
- switch (env.TERM_PROGRAM) {
1211
- case "iTerm.app":
1212
- return version >= 3 ? 3 : 2;
1213
- case "Apple_Terminal":
1214
- return 2;
1215
- }
1216
- }
1217
- if (/-256(color)?$/i.test(env.TERM)) {
1218
- return 2;
1219
- }
1220
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1221
- return 1;
1222
- }
1223
- if ("COLORTERM" in env) {
1224
- return 1;
1225
- }
1226
- return min;
1227
- }
1228
- function getSupportLevel(stream) {
1229
- const level = supportsColor(stream, stream && stream.isTTY);
1230
- return translateLevel(level);
1231
- }
1232
- module2.exports = {
1233
- supportsColor: getSupportLevel,
1234
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
1235
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
1236
- };
1237
- }
1238
- });
1239
-
1240
- // ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js
1241
- var require_util = __commonJS({
1242
- "../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js"(exports, module2) {
1243
- "use strict";
1244
- var stringReplaceAll = (string, substring, replacer) => {
1245
- let index = string.indexOf(substring);
1246
- if (index === -1) {
1247
- return string;
1248
- }
1249
- const substringLength = substring.length;
1250
- let endIndex = 0;
1251
- let returnValue = "";
1252
- do {
1253
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1254
- endIndex = index + substringLength;
1255
- index = string.indexOf(substring, endIndex);
1256
- } while (index !== -1);
1257
- returnValue += string.substr(endIndex);
1258
- return returnValue;
1259
- };
1260
- var stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
1261
- let endIndex = 0;
1262
- let returnValue = "";
1263
- do {
1264
- const gotCR = string[index - 1] === "\r";
1265
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1266
- endIndex = index + 1;
1267
- index = string.indexOf("\n", endIndex);
1268
- } while (index !== -1);
1269
- returnValue += string.substr(endIndex);
1270
- return returnValue;
1271
- };
1272
- module2.exports = {
1273
- stringReplaceAll,
1274
- stringEncaseCRLFWithFirstIndex
1275
- };
1276
- }
1277
- });
1278
-
1279
- // ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js
1280
- var require_templates = __commonJS({
1281
- "../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js"(exports, module2) {
1282
- "use strict";
1283
- var TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1284
- var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1285
- var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1286
- var ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1287
- var ESCAPES = /* @__PURE__ */ new Map([
1288
- ["n", "\n"],
1289
- ["r", "\r"],
1290
- ["t", " "],
1291
- ["b", "\b"],
1292
- ["f", "\f"],
1293
- ["v", "\v"],
1294
- ["0", "\0"],
1295
- ["\\", "\\"],
1296
- ["e", "\x1B"],
1297
- ["a", "\x07"]
1298
- ]);
1299
- function unescape(c) {
1300
- const u = c[0] === "u";
1301
- const bracket = c[1] === "{";
1302
- if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
1303
- return String.fromCharCode(parseInt(c.slice(1), 16));
1304
- }
1305
- if (u && bracket) {
1306
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1307
- }
1308
- return ESCAPES.get(c) || c;
1309
- }
1310
- function parseArguments(name, arguments_) {
1311
- const results = [];
1312
- const chunks = arguments_.trim().split(/\s*,\s*/g);
1313
- let matches;
1314
- for (const chunk of chunks) {
1315
- const number = Number(chunk);
1316
- if (!Number.isNaN(number)) {
1317
- results.push(number);
1318
- } else if (matches = chunk.match(STRING_REGEX)) {
1319
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
1320
- } else {
1321
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1322
- }
1323
- }
1324
- return results;
1325
- }
1326
- function parseStyle(style) {
1327
- STYLE_REGEX.lastIndex = 0;
1328
- const results = [];
1329
- let matches;
1330
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
1331
- const name = matches[1];
1332
- if (matches[2]) {
1333
- const args = parseArguments(name, matches[2]);
1334
- results.push([name].concat(args));
1335
- } else {
1336
- results.push([name]);
1337
- }
1338
- }
1339
- return results;
1340
- }
1341
- function buildStyle(chalk3, styles) {
1342
- const enabled = {};
1343
- for (const layer of styles) {
1344
- for (const style of layer.styles) {
1345
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
1346
- }
1347
- }
1348
- let current = chalk3;
1349
- for (const [styleName, styles2] of Object.entries(enabled)) {
1350
- if (!Array.isArray(styles2)) {
1351
- continue;
1352
- }
1353
- if (!(styleName in current)) {
1354
- throw new Error(`Unknown Chalk style: ${styleName}`);
1355
- }
1356
- current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
1357
- }
1358
- return current;
1359
- }
1360
- module2.exports = (chalk3, temporary) => {
1361
- const styles = [];
1362
- const chunks = [];
1363
- let chunk = [];
1364
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1365
- if (escapeCharacter) {
1366
- chunk.push(unescape(escapeCharacter));
1367
- } else if (style) {
1368
- const string = chunk.join("");
1369
- chunk = [];
1370
- chunks.push(styles.length === 0 ? string : buildStyle(chalk3, styles)(string));
1371
- styles.push({ inverse, styles: parseStyle(style) });
1372
- } else if (close) {
1373
- if (styles.length === 0) {
1374
- throw new Error("Found extraneous } in Chalk template literal");
1375
- }
1376
- chunks.push(buildStyle(chalk3, styles)(chunk.join("")));
1377
- chunk = [];
1378
- styles.pop();
1379
- } else {
1380
- chunk.push(character);
1381
- }
1382
- });
1383
- chunks.push(chunk.join(""));
1384
- if (styles.length > 0) {
1385
- const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
1386
- throw new Error(errMessage);
1387
- }
1388
- return chunks.join("");
1389
- };
1390
- }
1391
- });
1392
-
1393
- // ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js
1394
- var require_source = __commonJS({
1395
- "../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js"(exports, module2) {
1396
- "use strict";
1397
- var ansiStyles = require_ansi_styles();
1398
- var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
1399
- var {
1400
- stringReplaceAll,
1401
- stringEncaseCRLFWithFirstIndex
1402
- } = require_util();
1403
- var { isArray } = Array;
1404
- var levelMapping = [
1405
- "ansi",
1406
- "ansi",
1407
- "ansi256",
1408
- "ansi16m"
1409
- ];
1410
- var styles = /* @__PURE__ */ Object.create(null);
1411
- var applyOptions = (object, options = {}) => {
1412
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1413
- throw new Error("The `level` option should be an integer from 0 to 3");
1414
- }
1415
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1416
- object.level = options.level === void 0 ? colorLevel : options.level;
1417
- };
1418
- var ChalkClass = class {
1419
- constructor(options) {
1420
- return chalkFactory(options);
1421
- }
1422
- };
1423
- var chalkFactory = (options) => {
1424
- const chalk4 = {};
1425
- applyOptions(chalk4, options);
1426
- chalk4.template = (...arguments_) => chalkTag(chalk4.template, ...arguments_);
1427
- Object.setPrototypeOf(chalk4, Chalk.prototype);
1428
- Object.setPrototypeOf(chalk4.template, chalk4);
1429
- chalk4.template.constructor = () => {
1430
- throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1431
- };
1432
- chalk4.template.Instance = ChalkClass;
1433
- return chalk4.template;
1434
- };
1435
- function Chalk(options) {
1436
- return chalkFactory(options);
1437
- }
1438
- for (const [styleName, style] of Object.entries(ansiStyles)) {
1439
- styles[styleName] = {
1440
- get() {
1441
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1442
- Object.defineProperty(this, styleName, { value: builder });
1443
- return builder;
1444
- }
1445
- };
1446
- }
1447
- styles.visible = {
1448
- get() {
1449
- const builder = createBuilder(this, this._styler, true);
1450
- Object.defineProperty(this, "visible", { value: builder });
1451
- return builder;
1452
- }
1453
- };
1454
- var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1455
- for (const model of usedModels) {
1456
- styles[model] = {
1457
- get() {
1458
- const { level } = this;
1459
- return function(...arguments_) {
1460
- const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
1461
- return createBuilder(this, styler, this._isEmpty);
1462
- };
1463
- }
1464
- };
1465
- }
1466
- for (const model of usedModels) {
1467
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1468
- styles[bgModel] = {
1469
- get() {
1470
- const { level } = this;
1471
- return function(...arguments_) {
1472
- const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
1473
- return createBuilder(this, styler, this._isEmpty);
1474
- };
1475
- }
1476
- };
1477
- }
1478
- var proto = Object.defineProperties(() => {
1479
- }, {
1480
- ...styles,
1481
- level: {
1482
- enumerable: true,
1483
- get() {
1484
- return this._generator.level;
1485
- },
1486
- set(level) {
1487
- this._generator.level = level;
1488
- }
1489
- }
1490
- });
1491
- var createStyler = (open, close, parent) => {
1492
- let openAll;
1493
- let closeAll;
1494
- if (parent === void 0) {
1495
- openAll = open;
1496
- closeAll = close;
1497
- } else {
1498
- openAll = parent.openAll + open;
1499
- closeAll = close + parent.closeAll;
1500
- }
1501
- return {
1502
- open,
1503
- close,
1504
- openAll,
1505
- closeAll,
1506
- parent
1507
- };
1508
- };
1509
- var createBuilder = (self, _styler, _isEmpty) => {
1510
- const builder = (...arguments_) => {
1511
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1512
- return applyStyle(builder, chalkTag(builder, ...arguments_));
1513
- }
1514
- return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1515
- };
1516
- Object.setPrototypeOf(builder, proto);
1517
- builder._generator = self;
1518
- builder._styler = _styler;
1519
- builder._isEmpty = _isEmpty;
1520
- return builder;
1521
- };
1522
- var applyStyle = (self, string) => {
1523
- if (self.level <= 0 || !string) {
1524
- return self._isEmpty ? "" : string;
1525
- }
1526
- let styler = self._styler;
1527
- if (styler === void 0) {
1528
- return string;
1529
- }
1530
- const { openAll, closeAll } = styler;
1531
- if (string.indexOf("\x1B") !== -1) {
1532
- while (styler !== void 0) {
1533
- string = stringReplaceAll(string, styler.close, styler.open);
1534
- styler = styler.parent;
1535
- }
1536
- }
1537
- const lfIndex = string.indexOf("\n");
1538
- if (lfIndex !== -1) {
1539
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1540
- }
1541
- return openAll + string + closeAll;
1542
- };
1543
- var template;
1544
- var chalkTag = (chalk4, ...strings) => {
1545
- const [firstString] = strings;
1546
- if (!isArray(firstString) || !isArray(firstString.raw)) {
1547
- return strings.join(" ");
1548
- }
1549
- const arguments_ = strings.slice(1);
1550
- const parts = [firstString.raw[0]];
1551
- for (let i = 1; i < firstString.length; i++) {
1552
- parts.push(
1553
- String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
1554
- String(firstString.raw[i])
1555
- );
1556
- }
1557
- if (template === void 0) {
1558
- template = require_templates();
1559
- }
1560
- return template(chalk4, parts.join(""));
1561
- };
1562
- Object.defineProperties(Chalk.prototype, styles);
1563
- var chalk3 = Chalk();
1564
- chalk3.supportsColor = stdoutColor;
1565
- chalk3.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1566
- chalk3.stderr.supportsColor = stderrColor;
1567
- module2.exports = chalk3;
1568
- }
1569
- });
1570
-
1571
- // src/sync/index.ts
1572
- var sync_exports = {};
1573
- __export(sync_exports, {
1574
- SyncEngineError: () => SyncEngineError,
1575
- createArraySyncEngineDataSource: () => createArraySyncEngineDataSource,
1576
- createFileSyncEngineDataSource: () => createFileSyncEngineDataSource,
1577
- createSyncEngineConsoleLogger: () => createSyncEngineConsoleLogger,
1578
- emitWithFormat: () => emitWithFormat,
1579
- isPathAPackageFile: () => isPathAPackageFile,
1580
- nodeFetchProxy: () => nodeFetchProxy,
1581
- paginateAsync: () => paginateAsync,
1582
- readFileToObject: () => readFileToObject,
1583
- readUniformPackage: () => readUniformPackage,
1584
- syncEngine: () => syncEngine,
1585
- withApiOptions: () => withApiOptions,
1586
- withDiffOptions: () => withDiffOptions,
1587
- withFormatOptions: () => withFormatOptions,
1588
- withProjectOptions: () => withProjectOptions,
1589
- writeUniformPackage: () => writeUniformPackage
1590
- });
1591
- module.exports = __toCommonJS(sync_exports);
1592
-
1593
- // src/sync/arraySyncEngineDataSource.ts
1594
- async function createArraySyncEngineDataSource({
1595
- objects,
1596
- selectIdentifier,
1597
- selectDisplayName = selectIdentifier,
1598
- onSyncComplete
1599
- }) {
1600
- const objectIndex = objects.reduce((result, current) => {
1601
- const identifier = selectIdentifier(current);
1602
- if (result[identifier]) {
1603
- throw new Error(`Identifier ${identifier} was not unique.`);
1604
- }
1605
- result[identifier] = {
1606
- id: identifier,
1607
- object: current,
1608
- providerId: identifier,
1609
- displayName: selectDisplayName(current)
1610
- };
1611
- return result;
1612
- }, {});
1613
- async function* getObjects() {
1614
- for (const item of Object.values(objectIndex)) {
1615
- yield item;
1616
- }
1617
- }
1618
- function extractCurrent() {
1619
- return Object.entries(objectIndex).sort((a, b) => a[0].localeCompare(b[0])).map((entry) => entry[1].object);
1620
- }
1621
- return {
1622
- objects: getObjects(),
1623
- deleteObject: async (providerId) => {
1624
- delete objectIndex[providerId];
1625
- },
1626
- writeObject: async (objectToWrite) => {
1627
- const id = selectIdentifier(objectToWrite.object);
1628
- objectIndex[id] = objectToWrite;
1629
- },
1630
- extractCurrent,
1631
- onSyncComplete: onSyncComplete ? (isTarget) => onSyncComplete(isTarget, extractCurrent()) : void 0
1632
- };
1633
- }
1634
-
1635
- // src/sync/fileSyncEngineDataSource.ts
1636
- var import_chalk = __toESM(require_source());
1637
- var import_fs3 = require("fs");
1638
- var import_promises = require("fs/promises");
1639
- var import_path2 = require("path");
1640
-
1641
- // src/sync/util.ts
1642
- var import_fs = require("fs");
1643
- var import_fs2 = require("fs");
1644
- var import_https_proxy_agent = require("https-proxy-agent");
1645
- var import_isomorphic_unfetch = __toESM(require("isomorphic-unfetch"));
1646
- var import_js_yaml = require("js-yaml");
1647
- var import_path = require("path");
1648
- function withApiOptions(yargs) {
1649
- var _a, _b, _c;
1650
- return yargs.option("apiKey", {
1651
- describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
1652
- default: (_c = (_b = (_a = process.env.UNIFORM_CLI_API_KEY) != null ? _a : process.env.CANVAS_CLI_API_KEY) != null ? _b : process.env.UPM_CLI_API_KEY) != null ? _c : process.env.UNIFORM_API_KEY,
1653
- demandOption: true,
1654
- type: "string"
1655
- }).option("apiHost", {
1656
- describe: "Uniform host. Defaults to UNIFORM_CLI_BASE_URL env var or https://uniform.app. Supports dotenv.",
1657
- default: process.env.UNIFORM_CLI_BASE_URL || "https://uniform.app",
1658
- demandOption: true,
1659
- type: "string"
1660
- }).option("edgeApiHost", {
1661
- describe: "Uniform edge host. Defaults to UNIFORM_CLI_BASE_EDGE_URL env var or https://uniform.global. Supports dotenv.",
1662
- default: process.env.UNIFORM_CLI_BASE_EDGE_URL || "https://uniform.global",
1663
- demandOption: true,
1664
- type: "string"
1665
- }).option("proxy", {
1666
- describe: "HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",
1667
- default: process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy,
1668
- type: "string"
1669
- });
1670
- }
1671
- function nodeFetchProxy(proxy) {
1672
- if (proxy) {
1673
- console.log(`\u{1F991} Using proxy ${proxy}`);
1674
- }
1675
- const wrappedFetch = (input, init) => {
1676
- if (proxy) {
1677
- const wrappedInit = {
1678
- ...init,
1679
- agent: new import_https_proxy_agent.HttpsProxyAgent(proxy)
1680
- };
1681
- return (0, import_isomorphic_unfetch.default)(input, wrappedInit);
1682
- }
1683
- return (0, import_isomorphic_unfetch.default)(input, init);
1684
- };
1685
- return wrappedFetch;
1686
- }
1687
- function withProjectOptions(yargs) {
1688
- var _a, _b, _c;
1689
- return yargs.option("project", {
1690
- describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
1691
- default: (_c = (_b = (_a = process.env.UNIFORM_CLI_PROJECT_ID) != null ? _a : process.env.CANVAS_CLI_PROJECT_ID) != null ? _b : process.env.UPM_CLI_PROJECT_ID) != null ? _c : process.env.UNIFORM_PROJECT_ID,
1692
- demandOption: true,
1693
- type: "string",
1694
- alias: ["p"]
1695
- });
1696
- }
1697
- function withFormatOptions(yargs) {
1698
- return yargs.option("format", {
1699
- alias: ["f"],
1700
- describe: "Output format",
1701
- default: "yaml",
1702
- choices: ["yaml", "json"],
1703
- type: "string"
1704
- }).option("filename", {
1705
- alias: ["o"],
1706
- describe: "Output filename. If not specified, write to stdout.",
1707
- type: "string"
1708
- });
1709
- }
1710
- function withDiffOptions(yargs) {
1711
- var _a;
1712
- return yargs.option("diff", {
1713
- describe: "Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",
1714
- default: (_a = process.env.UNIFORM_CLI_DIFF_MODE) != null ? _a : "off",
1715
- type: "string",
1716
- choices: ["off", "update", "on"],
1717
- alias: ["d"]
1718
- });
1719
- }
1720
- function isPathAPackageFile(path) {
1721
- const extension = (0, import_path.extname)(path);
1722
- return extension === ".yaml" || extension === ".yml" || extension === ".json";
1723
- }
1724
- function emitWithFormat(object, format, filename) {
1725
- let content;
1726
- if (filename && !format) {
1727
- const extension = (0, import_path.extname)(filename);
1728
- if (extension === ".yaml" || extension === ".yml") {
1729
- format = "yaml";
1730
- } else if (extension === ".json") {
1731
- format = "json";
1732
- }
1733
- } else if (!format) {
1734
- throw new Error("Format must be specified when no filename is passed");
1735
- }
1736
- switch (format) {
1737
- case "json":
1738
- content = JSON.stringify(object, null, 2);
1739
- break;
1740
- case "yaml":
1741
- content = (0, import_js_yaml.dump)(object);
1742
- break;
1743
- default:
1744
- throw new Error(`Unsupported format: ${format}`);
1745
- }
1746
- if (filename) {
1747
- (0, import_fs.writeFileSync)(filename, content, "utf8");
1748
- } else {
1749
- console.log(content);
1750
- }
1751
- }
1752
- function readFileToObject(filename) {
1753
- const file = (0, import_fs2.readFileSync)(filename, "utf8");
1754
- return (0, import_js_yaml.load)(file, { filename, json: true });
1755
- }
1756
- async function* paginateAsync(fetchPage, options) {
1757
- const perPage = options.pageSize || 100;
1758
- let offset = 0;
1759
- let pageData = [];
1760
- do {
1761
- pageData = await fetchPage(offset, perPage);
1762
- for (const item of pageData) {
1763
- yield item;
1764
- }
1765
- offset += perPage;
1766
- } while (pageData.length === perPage);
1767
- }
1768
-
1769
- // src/sync/fileSyncEngineDataSource.ts
1770
- async function createFileSyncEngineDataSource({
1771
- directory,
1772
- format = "yaml",
1773
- selectIdentifier,
1774
- selectDisplayName = selectIdentifier,
1775
- selectFilename
1776
- }) {
1777
- const dirExists = (0, import_fs3.existsSync)(directory);
1778
- if (!dirExists) {
1779
- (0, import_fs3.mkdirSync)(directory, { recursive: true });
1780
- }
1781
- const rawFilenames = await (0, import_promises.readdir)(directory, "utf-8");
1782
- const filenames = new Set(
1783
- rawFilenames.filter((filename) => {
1784
- const ext = (0, import_path2.extname)(filename);
1785
- return ext === `.json` || ext === `.yaml` || ext === `.yml`;
1786
- })
1787
- );
1788
- const getFullFilename = (id) => (0, import_path2.join)(directory, `${id}.${format}`);
1789
- async function* getObjects() {
1790
- for (const filename of filenames) {
1791
- const fullFilename = (0, import_path2.join)(directory, filename);
1792
- try {
1793
- const contents = await readFileToObject(fullFilename);
1794
- const object = {
1795
- id: selectIdentifier(contents),
1796
- displayName: selectDisplayName(contents),
1797
- providerId: fullFilename,
1798
- object: contents
1799
- };
1800
- yield object;
1801
- } catch (e) {
1802
- console.error(import_chalk.default.red(`Failed to read ${fullFilename}, data is likely invalid.
1803
- ${e == null ? void 0 : e.message}`));
1804
- throw e;
1805
- }
1806
- }
1807
- }
1808
- return {
1809
- objects: getObjects(),
1810
- deleteObject: async (providerId) => {
1811
- await (0, import_promises.unlink)(providerId);
1812
- },
1813
- writeObject: async (object) => {
1814
- if (selectFilename) {
1815
- emitWithFormat(object.object, format, (0, import_path2.join)(directory, `${selectFilename(object.object)}.${format}`));
1816
- } else {
1817
- emitWithFormat(object.object, format, getFullFilename(object.id));
1818
- }
1819
- }
1820
- };
1821
- }
1822
-
1823
- // src/sync/package.ts
1824
- var import_fs4 = __toESM(require("fs"));
1825
- function readUniformPackage(filename, assertExists) {
1826
- if (!assertExists && !import_fs4.default.existsSync(filename)) {
1827
- return {};
1828
- }
1829
- const packageContents = readFileToObject(filename);
1830
- if (typeof packageContents !== "object") {
1831
- throw new Error(`Package ${filename} does not appear valid.`);
1832
- }
1833
- return packageContents;
1834
- }
1835
- function writeUniformPackage(filename, packageContents) {
1836
- emitWithFormat(packageContents, void 0, filename);
1837
- }
1838
-
1839
- // src/sync/syncEngine.ts
1840
- var import_diff = require("diff");
1841
- var import_lodash = __toESM(require("lodash.isequalwith"));
1842
- async function syncEngine({
1843
- source,
1844
- target,
1845
- compareContents = (source2, target2) => {
1846
- return (0, import_lodash.default)(
1847
- source2.object,
1848
- target2.object,
1849
- (_a, _b, key) => key === "created" || key === "modified" ? true : void 0
1850
- );
1851
- },
1852
- mode,
1853
- allowEmptySource = false,
1854
- whatIf = false,
1855
- log = () => {
1856
- }
1857
- }) {
1858
- var _a, _b;
1859
- const targetItems = /* @__PURE__ */ new Map();
1860
- for await (const obj of target.objects) {
1861
- targetItems.set(obj.id, obj);
1862
- }
1863
- const actions = [];
1864
- let sourceHasItems = false;
1865
- for await (const sourceObject of source.objects) {
1866
- sourceHasItems = true;
1867
- const id = sourceObject.id;
1868
- const targetObject = targetItems.get(id);
1869
- if (targetObject) {
1870
- if (!compareContents(sourceObject, targetObject)) {
1871
- if (mode === "createOrUpdate" || mode === "mirror") {
1872
- const process2 = async (sourceObject2, targetObject2) => {
1873
- var _a2;
1874
- if (!whatIf) {
1875
- try {
1876
- await target.writeObject(sourceObject2, targetObject2);
1877
- } catch (e) {
1878
- throw new SyncEngineError(e, sourceObject2);
1879
- }
1880
- }
1881
- log({
1882
- action: "update",
1883
- id,
1884
- providerId: sourceObject2.providerId,
1885
- displayName: (_a2 = sourceObject2.displayName) != null ? _a2 : sourceObject2.providerId,
1886
- whatIf,
1887
- diff: (0, import_diff.diffJson)(targetObject2.object, sourceObject2.object)
1888
- });
1889
- };
1890
- actions.push(process2(sourceObject, targetObject));
1891
- }
1892
- }
1893
- targetItems.delete(id);
1894
- } else {
1895
- const process2 = async (sourceObject2, id2) => {
1896
- var _a2;
1897
- if (!whatIf) {
1898
- try {
1899
- await target.writeObject(sourceObject2);
1900
- } catch (e) {
1901
- throw new SyncEngineError(e, sourceObject2);
1902
- }
1903
- }
1904
- log({
1905
- action: "create",
1906
- id: id2,
1907
- providerId: id2,
1908
- displayName: (_a2 = sourceObject2.displayName) != null ? _a2 : sourceObject2.providerId,
1909
- whatIf,
1910
- diff: (0, import_diff.diffLines)("", JSON.stringify(sourceObject2.object, null, 2))
1911
- });
1912
- };
1913
- actions.push(process2(sourceObject, id));
1914
- }
1915
- }
1916
- await Promise.all(actions);
1917
- if (mode === "mirror") {
1918
- if (!sourceHasItems && !allowEmptySource) {
1919
- throw new Error(
1920
- "Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition."
1921
- );
1922
- }
1923
- const deletes = [];
1924
- targetItems.forEach(async (object) => {
1925
- const process2 = async (object2) => {
1926
- var _a2;
1927
- if (!whatIf) {
1928
- try {
1929
- await target.deleteObject(object2.providerId, object2);
1930
- } catch (e) {
1931
- throw new SyncEngineError(e, object2);
1932
- }
1933
- }
1934
- log({
1935
- action: "delete",
1936
- id: object2.id,
1937
- providerId: object2.providerId,
1938
- displayName: (_a2 = object2.displayName) != null ? _a2 : object2.providerId,
1939
- whatIf,
1940
- diff: (0, import_diff.diffLines)(JSON.stringify(object2.object, null, 2), "")
1941
- });
1942
- };
1943
- deletes.push(process2(object));
1944
- });
1945
- await Promise.all(deletes);
1946
- }
1947
- await Promise.all([(_a = source.onSyncComplete) == null ? void 0 : _a.call(source, false), (_b = target.onSyncComplete) == null ? void 0 : _b.call(target, true)]);
1948
- }
1949
- var SyncEngineError = class extends Error {
1950
- constructor(innerError, sourceObject) {
1951
- var _a;
1952
- super(
1953
- `Error syncing ${(_a = sourceObject.displayName) != null ? _a : sourceObject.providerId} (${sourceObject.providerId})
1954
- ${innerError}`
1955
- );
1956
- this.stack = void 0;
1957
- Object.setPrototypeOf(this, SyncEngineError.prototype);
1958
- }
1959
- };
1960
-
1961
- // src/sync/syncEngineConsoleLogger.ts
1962
- var import_chalk2 = __toESM(require_source());
1963
- function createSyncEngineConsoleLogger(options) {
1964
- const { diffMode = "off", indent, prefix } = options != null ? options : {};
1965
- return function syncEngineConsoleLogger({ action, displayName, whatIf, diff }) {
1966
- let actionTag = "";
1967
- switch (action) {
1968
- case "create":
1969
- actionTag = import_chalk2.default.green("[A]");
1970
- break;
1971
- case "update":
1972
- actionTag = import_chalk2.default.white("[U]");
1973
- break;
1974
- case "delete":
1975
- actionTag = import_chalk2.default.yellow("[D]");
1976
- break;
1977
- }
1978
- let diffString = "";
1979
- if (diffMode === "on" || diffMode === "update" && action === "update") {
1980
- diffString = "\n" + diff.map((change) => {
1981
- if (change.added) {
1982
- return import_chalk2.default.green(change.value);
1983
- }
1984
- if (change.removed) {
1985
- return import_chalk2.default.red(change.value);
1986
- }
1987
- return change.value;
1988
- }).join("");
1989
- }
1990
- console.log(
1991
- `${indent != null ? indent : ""}${whatIf ? import_chalk2.default.gray("[WHATIF]") : ""}${actionTag}${prefix != null ? prefix : ""} ${displayName}${diffString}`
1992
- );
1993
- };
1994
- }
1995
- // Annotate the CommonJS export names for ESM import in node:
1996
- 0 && (module.exports = {
1997
- SyncEngineError,
1998
- createArraySyncEngineDataSource,
1999
- createFileSyncEngineDataSource,
2000
- createSyncEngineConsoleLogger,
2001
- emitWithFormat,
2002
- isPathAPackageFile,
2003
- nodeFetchProxy,
2004
- paginateAsync,
2005
- readFileToObject,
2006
- readUniformPackage,
2007
- syncEngine,
2008
- withApiOptions,
2009
- withDiffOptions,
2010
- withFormatOptions,
2011
- withProjectOptions,
2012
- writeUniformPackage
2013
- });