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