@dannote/figma-use 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -1
- package/README.md +114 -256
- package/SKILL.md +82 -20
- package/dist/cli/index.js +3947 -380
- package/dist/proxy/index.js +8 -6
- package/package.json +8 -1
- package/packages/cli/src/render/component-set.tsx +7 -3
- package/packages/cli/src/render/components.tsx +16 -47
- package/packages/cli/src/render/icon.ts +163 -0
- package/packages/cli/src/render/index.ts +7 -1
- package/packages/cli/src/render/reconciler.ts +96 -34
- package/packages/cli/src/render/shorthands.ts +129 -0
- package/packages/cli/src/render/vars.ts +4 -5
- package/packages/plugin/dist/main.js +127 -33
package/dist/cli/index.js
CHANGED
|
@@ -23858,12 +23858,14 @@ function serializeNode(node) {
|
|
|
23858
23858
|
lines.push(`pos: ${node.x} ${node.y}`);
|
|
23859
23859
|
}
|
|
23860
23860
|
const fills = node.fills;
|
|
23861
|
-
|
|
23862
|
-
|
|
23861
|
+
const firstFill = fills?.[0];
|
|
23862
|
+
if (firstFill?.type === "SOLID" && firstFill.color) {
|
|
23863
|
+
lines.push(`fill: ${firstFill.color}`);
|
|
23863
23864
|
}
|
|
23864
23865
|
const strokes = node.strokes;
|
|
23865
|
-
|
|
23866
|
-
|
|
23866
|
+
const firstStroke = strokes?.[0];
|
|
23867
|
+
if (firstStroke?.type === "SOLID" && firstStroke.color) {
|
|
23868
|
+
lines.push(`stroke: ${firstStroke.color}`);
|
|
23867
23869
|
}
|
|
23868
23870
|
if (node.strokeWeight !== undefined && node.strokeWeight !== 0) {
|
|
23869
23871
|
lines.push(`strokeWeight: ${node.strokeWeight}`);
|
|
@@ -24370,6 +24372,2112 @@ ${oldContent.split(`
|
|
|
24370
24372
|
});
|
|
24371
24373
|
});
|
|
24372
24374
|
|
|
24375
|
+
// node_modules/pngjs/lib/chunkstream.js
|
|
24376
|
+
var require_chunkstream = __commonJS((exports, module) => {
|
|
24377
|
+
var util = __require("util");
|
|
24378
|
+
var Stream = __require("stream");
|
|
24379
|
+
var ChunkStream = module.exports = function() {
|
|
24380
|
+
Stream.call(this);
|
|
24381
|
+
this._buffers = [];
|
|
24382
|
+
this._buffered = 0;
|
|
24383
|
+
this._reads = [];
|
|
24384
|
+
this._paused = false;
|
|
24385
|
+
this._encoding = "utf8";
|
|
24386
|
+
this.writable = true;
|
|
24387
|
+
};
|
|
24388
|
+
util.inherits(ChunkStream, Stream);
|
|
24389
|
+
ChunkStream.prototype.read = function(length, callback) {
|
|
24390
|
+
this._reads.push({
|
|
24391
|
+
length: Math.abs(length),
|
|
24392
|
+
allowLess: length < 0,
|
|
24393
|
+
func: callback
|
|
24394
|
+
});
|
|
24395
|
+
process.nextTick(function() {
|
|
24396
|
+
this._process();
|
|
24397
|
+
if (this._paused && this._reads && this._reads.length > 0) {
|
|
24398
|
+
this._paused = false;
|
|
24399
|
+
this.emit("drain");
|
|
24400
|
+
}
|
|
24401
|
+
}.bind(this));
|
|
24402
|
+
};
|
|
24403
|
+
ChunkStream.prototype.write = function(data, encoding) {
|
|
24404
|
+
if (!this.writable) {
|
|
24405
|
+
this.emit("error", new Error("Stream not writable"));
|
|
24406
|
+
return false;
|
|
24407
|
+
}
|
|
24408
|
+
let dataBuffer;
|
|
24409
|
+
if (Buffer.isBuffer(data)) {
|
|
24410
|
+
dataBuffer = data;
|
|
24411
|
+
} else {
|
|
24412
|
+
dataBuffer = Buffer.from(data, encoding || this._encoding);
|
|
24413
|
+
}
|
|
24414
|
+
this._buffers.push(dataBuffer);
|
|
24415
|
+
this._buffered += dataBuffer.length;
|
|
24416
|
+
this._process();
|
|
24417
|
+
if (this._reads && this._reads.length === 0) {
|
|
24418
|
+
this._paused = true;
|
|
24419
|
+
}
|
|
24420
|
+
return this.writable && !this._paused;
|
|
24421
|
+
};
|
|
24422
|
+
ChunkStream.prototype.end = function(data, encoding) {
|
|
24423
|
+
if (data) {
|
|
24424
|
+
this.write(data, encoding);
|
|
24425
|
+
}
|
|
24426
|
+
this.writable = false;
|
|
24427
|
+
if (!this._buffers) {
|
|
24428
|
+
return;
|
|
24429
|
+
}
|
|
24430
|
+
if (this._buffers.length === 0) {
|
|
24431
|
+
this._end();
|
|
24432
|
+
} else {
|
|
24433
|
+
this._buffers.push(null);
|
|
24434
|
+
this._process();
|
|
24435
|
+
}
|
|
24436
|
+
};
|
|
24437
|
+
ChunkStream.prototype.destroySoon = ChunkStream.prototype.end;
|
|
24438
|
+
ChunkStream.prototype._end = function() {
|
|
24439
|
+
if (this._reads.length > 0) {
|
|
24440
|
+
this.emit("error", new Error("Unexpected end of input"));
|
|
24441
|
+
}
|
|
24442
|
+
this.destroy();
|
|
24443
|
+
};
|
|
24444
|
+
ChunkStream.prototype.destroy = function() {
|
|
24445
|
+
if (!this._buffers) {
|
|
24446
|
+
return;
|
|
24447
|
+
}
|
|
24448
|
+
this.writable = false;
|
|
24449
|
+
this._reads = null;
|
|
24450
|
+
this._buffers = null;
|
|
24451
|
+
this.emit("close");
|
|
24452
|
+
};
|
|
24453
|
+
ChunkStream.prototype._processReadAllowingLess = function(read) {
|
|
24454
|
+
this._reads.shift();
|
|
24455
|
+
let smallerBuf = this._buffers[0];
|
|
24456
|
+
if (smallerBuf.length > read.length) {
|
|
24457
|
+
this._buffered -= read.length;
|
|
24458
|
+
this._buffers[0] = smallerBuf.slice(read.length);
|
|
24459
|
+
read.func.call(this, smallerBuf.slice(0, read.length));
|
|
24460
|
+
} else {
|
|
24461
|
+
this._buffered -= smallerBuf.length;
|
|
24462
|
+
this._buffers.shift();
|
|
24463
|
+
read.func.call(this, smallerBuf);
|
|
24464
|
+
}
|
|
24465
|
+
};
|
|
24466
|
+
ChunkStream.prototype._processRead = function(read) {
|
|
24467
|
+
this._reads.shift();
|
|
24468
|
+
let pos = 0;
|
|
24469
|
+
let count = 0;
|
|
24470
|
+
let data = Buffer.alloc(read.length);
|
|
24471
|
+
while (pos < read.length) {
|
|
24472
|
+
let buf = this._buffers[count++];
|
|
24473
|
+
let len = Math.min(buf.length, read.length - pos);
|
|
24474
|
+
buf.copy(data, pos, 0, len);
|
|
24475
|
+
pos += len;
|
|
24476
|
+
if (len !== buf.length) {
|
|
24477
|
+
this._buffers[--count] = buf.slice(len);
|
|
24478
|
+
}
|
|
24479
|
+
}
|
|
24480
|
+
if (count > 0) {
|
|
24481
|
+
this._buffers.splice(0, count);
|
|
24482
|
+
}
|
|
24483
|
+
this._buffered -= read.length;
|
|
24484
|
+
read.func.call(this, data);
|
|
24485
|
+
};
|
|
24486
|
+
ChunkStream.prototype._process = function() {
|
|
24487
|
+
try {
|
|
24488
|
+
while (this._buffered > 0 && this._reads && this._reads.length > 0) {
|
|
24489
|
+
let read = this._reads[0];
|
|
24490
|
+
if (read.allowLess) {
|
|
24491
|
+
this._processReadAllowingLess(read);
|
|
24492
|
+
} else if (this._buffered >= read.length) {
|
|
24493
|
+
this._processRead(read);
|
|
24494
|
+
} else {
|
|
24495
|
+
break;
|
|
24496
|
+
}
|
|
24497
|
+
}
|
|
24498
|
+
if (this._buffers && !this.writable) {
|
|
24499
|
+
this._end();
|
|
24500
|
+
}
|
|
24501
|
+
} catch (ex) {
|
|
24502
|
+
this.emit("error", ex);
|
|
24503
|
+
}
|
|
24504
|
+
};
|
|
24505
|
+
});
|
|
24506
|
+
|
|
24507
|
+
// node_modules/pngjs/lib/interlace.js
|
|
24508
|
+
var require_interlace = __commonJS((exports) => {
|
|
24509
|
+
var imagePasses = [
|
|
24510
|
+
{
|
|
24511
|
+
x: [0],
|
|
24512
|
+
y: [0]
|
|
24513
|
+
},
|
|
24514
|
+
{
|
|
24515
|
+
x: [4],
|
|
24516
|
+
y: [0]
|
|
24517
|
+
},
|
|
24518
|
+
{
|
|
24519
|
+
x: [0, 4],
|
|
24520
|
+
y: [4]
|
|
24521
|
+
},
|
|
24522
|
+
{
|
|
24523
|
+
x: [2, 6],
|
|
24524
|
+
y: [0, 4]
|
|
24525
|
+
},
|
|
24526
|
+
{
|
|
24527
|
+
x: [0, 2, 4, 6],
|
|
24528
|
+
y: [2, 6]
|
|
24529
|
+
},
|
|
24530
|
+
{
|
|
24531
|
+
x: [1, 3, 5, 7],
|
|
24532
|
+
y: [0, 2, 4, 6]
|
|
24533
|
+
},
|
|
24534
|
+
{
|
|
24535
|
+
x: [0, 1, 2, 3, 4, 5, 6, 7],
|
|
24536
|
+
y: [1, 3, 5, 7]
|
|
24537
|
+
}
|
|
24538
|
+
];
|
|
24539
|
+
exports.getImagePasses = function(width, height) {
|
|
24540
|
+
let images = [];
|
|
24541
|
+
let xLeftOver = width % 8;
|
|
24542
|
+
let yLeftOver = height % 8;
|
|
24543
|
+
let xRepeats = (width - xLeftOver) / 8;
|
|
24544
|
+
let yRepeats = (height - yLeftOver) / 8;
|
|
24545
|
+
for (let i3 = 0;i3 < imagePasses.length; i3++) {
|
|
24546
|
+
let pass = imagePasses[i3];
|
|
24547
|
+
let passWidth = xRepeats * pass.x.length;
|
|
24548
|
+
let passHeight = yRepeats * pass.y.length;
|
|
24549
|
+
for (let j = 0;j < pass.x.length; j++) {
|
|
24550
|
+
if (pass.x[j] < xLeftOver) {
|
|
24551
|
+
passWidth++;
|
|
24552
|
+
} else {
|
|
24553
|
+
break;
|
|
24554
|
+
}
|
|
24555
|
+
}
|
|
24556
|
+
for (let j = 0;j < pass.y.length; j++) {
|
|
24557
|
+
if (pass.y[j] < yLeftOver) {
|
|
24558
|
+
passHeight++;
|
|
24559
|
+
} else {
|
|
24560
|
+
break;
|
|
24561
|
+
}
|
|
24562
|
+
}
|
|
24563
|
+
if (passWidth > 0 && passHeight > 0) {
|
|
24564
|
+
images.push({ width: passWidth, height: passHeight, index: i3 });
|
|
24565
|
+
}
|
|
24566
|
+
}
|
|
24567
|
+
return images;
|
|
24568
|
+
};
|
|
24569
|
+
exports.getInterlaceIterator = function(width) {
|
|
24570
|
+
return function(x3, y5, pass) {
|
|
24571
|
+
let outerXLeftOver = x3 % imagePasses[pass].x.length;
|
|
24572
|
+
let outerX = (x3 - outerXLeftOver) / imagePasses[pass].x.length * 8 + imagePasses[pass].x[outerXLeftOver];
|
|
24573
|
+
let outerYLeftOver = y5 % imagePasses[pass].y.length;
|
|
24574
|
+
let outerY = (y5 - outerYLeftOver) / imagePasses[pass].y.length * 8 + imagePasses[pass].y[outerYLeftOver];
|
|
24575
|
+
return outerX * 4 + outerY * width * 4;
|
|
24576
|
+
};
|
|
24577
|
+
};
|
|
24578
|
+
});
|
|
24579
|
+
|
|
24580
|
+
// node_modules/pngjs/lib/paeth-predictor.js
|
|
24581
|
+
var require_paeth_predictor = __commonJS((exports, module) => {
|
|
24582
|
+
module.exports = function paethPredictor(left, above, upLeft) {
|
|
24583
|
+
let paeth = left + above - upLeft;
|
|
24584
|
+
let pLeft = Math.abs(paeth - left);
|
|
24585
|
+
let pAbove = Math.abs(paeth - above);
|
|
24586
|
+
let pUpLeft = Math.abs(paeth - upLeft);
|
|
24587
|
+
if (pLeft <= pAbove && pLeft <= pUpLeft) {
|
|
24588
|
+
return left;
|
|
24589
|
+
}
|
|
24590
|
+
if (pAbove <= pUpLeft) {
|
|
24591
|
+
return above;
|
|
24592
|
+
}
|
|
24593
|
+
return upLeft;
|
|
24594
|
+
};
|
|
24595
|
+
});
|
|
24596
|
+
|
|
24597
|
+
// node_modules/pngjs/lib/filter-parse.js
|
|
24598
|
+
var require_filter_parse = __commonJS((exports, module) => {
|
|
24599
|
+
var interlaceUtils = require_interlace();
|
|
24600
|
+
var paethPredictor = require_paeth_predictor();
|
|
24601
|
+
function getByteWidth(width, bpp, depth) {
|
|
24602
|
+
let byteWidth = width * bpp;
|
|
24603
|
+
if (depth !== 8) {
|
|
24604
|
+
byteWidth = Math.ceil(byteWidth / (8 / depth));
|
|
24605
|
+
}
|
|
24606
|
+
return byteWidth;
|
|
24607
|
+
}
|
|
24608
|
+
var Filter = module.exports = function(bitmapInfo, dependencies) {
|
|
24609
|
+
let width = bitmapInfo.width;
|
|
24610
|
+
let height = bitmapInfo.height;
|
|
24611
|
+
let interlace = bitmapInfo.interlace;
|
|
24612
|
+
let bpp = bitmapInfo.bpp;
|
|
24613
|
+
let depth = bitmapInfo.depth;
|
|
24614
|
+
this.read = dependencies.read;
|
|
24615
|
+
this.write = dependencies.write;
|
|
24616
|
+
this.complete = dependencies.complete;
|
|
24617
|
+
this._imageIndex = 0;
|
|
24618
|
+
this._images = [];
|
|
24619
|
+
if (interlace) {
|
|
24620
|
+
let passes = interlaceUtils.getImagePasses(width, height);
|
|
24621
|
+
for (let i3 = 0;i3 < passes.length; i3++) {
|
|
24622
|
+
this._images.push({
|
|
24623
|
+
byteWidth: getByteWidth(passes[i3].width, bpp, depth),
|
|
24624
|
+
height: passes[i3].height,
|
|
24625
|
+
lineIndex: 0
|
|
24626
|
+
});
|
|
24627
|
+
}
|
|
24628
|
+
} else {
|
|
24629
|
+
this._images.push({
|
|
24630
|
+
byteWidth: getByteWidth(width, bpp, depth),
|
|
24631
|
+
height,
|
|
24632
|
+
lineIndex: 0
|
|
24633
|
+
});
|
|
24634
|
+
}
|
|
24635
|
+
if (depth === 8) {
|
|
24636
|
+
this._xComparison = bpp;
|
|
24637
|
+
} else if (depth === 16) {
|
|
24638
|
+
this._xComparison = bpp * 2;
|
|
24639
|
+
} else {
|
|
24640
|
+
this._xComparison = 1;
|
|
24641
|
+
}
|
|
24642
|
+
};
|
|
24643
|
+
Filter.prototype.start = function() {
|
|
24644
|
+
this.read(this._images[this._imageIndex].byteWidth + 1, this._reverseFilterLine.bind(this));
|
|
24645
|
+
};
|
|
24646
|
+
Filter.prototype._unFilterType1 = function(rawData, unfilteredLine, byteWidth) {
|
|
24647
|
+
let xComparison = this._xComparison;
|
|
24648
|
+
let xBiggerThan = xComparison - 1;
|
|
24649
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
24650
|
+
let rawByte = rawData[1 + x3];
|
|
24651
|
+
let f1Left = x3 > xBiggerThan ? unfilteredLine[x3 - xComparison] : 0;
|
|
24652
|
+
unfilteredLine[x3] = rawByte + f1Left;
|
|
24653
|
+
}
|
|
24654
|
+
};
|
|
24655
|
+
Filter.prototype._unFilterType2 = function(rawData, unfilteredLine, byteWidth) {
|
|
24656
|
+
let lastLine = this._lastLine;
|
|
24657
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
24658
|
+
let rawByte = rawData[1 + x3];
|
|
24659
|
+
let f2Up = lastLine ? lastLine[x3] : 0;
|
|
24660
|
+
unfilteredLine[x3] = rawByte + f2Up;
|
|
24661
|
+
}
|
|
24662
|
+
};
|
|
24663
|
+
Filter.prototype._unFilterType3 = function(rawData, unfilteredLine, byteWidth) {
|
|
24664
|
+
let xComparison = this._xComparison;
|
|
24665
|
+
let xBiggerThan = xComparison - 1;
|
|
24666
|
+
let lastLine = this._lastLine;
|
|
24667
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
24668
|
+
let rawByte = rawData[1 + x3];
|
|
24669
|
+
let f3Up = lastLine ? lastLine[x3] : 0;
|
|
24670
|
+
let f3Left = x3 > xBiggerThan ? unfilteredLine[x3 - xComparison] : 0;
|
|
24671
|
+
let f3Add = Math.floor((f3Left + f3Up) / 2);
|
|
24672
|
+
unfilteredLine[x3] = rawByte + f3Add;
|
|
24673
|
+
}
|
|
24674
|
+
};
|
|
24675
|
+
Filter.prototype._unFilterType4 = function(rawData, unfilteredLine, byteWidth) {
|
|
24676
|
+
let xComparison = this._xComparison;
|
|
24677
|
+
let xBiggerThan = xComparison - 1;
|
|
24678
|
+
let lastLine = this._lastLine;
|
|
24679
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
24680
|
+
let rawByte = rawData[1 + x3];
|
|
24681
|
+
let f4Up = lastLine ? lastLine[x3] : 0;
|
|
24682
|
+
let f4Left = x3 > xBiggerThan ? unfilteredLine[x3 - xComparison] : 0;
|
|
24683
|
+
let f4UpLeft = x3 > xBiggerThan && lastLine ? lastLine[x3 - xComparison] : 0;
|
|
24684
|
+
let f4Add = paethPredictor(f4Left, f4Up, f4UpLeft);
|
|
24685
|
+
unfilteredLine[x3] = rawByte + f4Add;
|
|
24686
|
+
}
|
|
24687
|
+
};
|
|
24688
|
+
Filter.prototype._reverseFilterLine = function(rawData) {
|
|
24689
|
+
let filter = rawData[0];
|
|
24690
|
+
let unfilteredLine;
|
|
24691
|
+
let currentImage = this._images[this._imageIndex];
|
|
24692
|
+
let byteWidth = currentImage.byteWidth;
|
|
24693
|
+
if (filter === 0) {
|
|
24694
|
+
unfilteredLine = rawData.slice(1, byteWidth + 1);
|
|
24695
|
+
} else {
|
|
24696
|
+
unfilteredLine = Buffer.alloc(byteWidth);
|
|
24697
|
+
switch (filter) {
|
|
24698
|
+
case 1:
|
|
24699
|
+
this._unFilterType1(rawData, unfilteredLine, byteWidth);
|
|
24700
|
+
break;
|
|
24701
|
+
case 2:
|
|
24702
|
+
this._unFilterType2(rawData, unfilteredLine, byteWidth);
|
|
24703
|
+
break;
|
|
24704
|
+
case 3:
|
|
24705
|
+
this._unFilterType3(rawData, unfilteredLine, byteWidth);
|
|
24706
|
+
break;
|
|
24707
|
+
case 4:
|
|
24708
|
+
this._unFilterType4(rawData, unfilteredLine, byteWidth);
|
|
24709
|
+
break;
|
|
24710
|
+
default:
|
|
24711
|
+
throw new Error("Unrecognised filter type - " + filter);
|
|
24712
|
+
}
|
|
24713
|
+
}
|
|
24714
|
+
this.write(unfilteredLine);
|
|
24715
|
+
currentImage.lineIndex++;
|
|
24716
|
+
if (currentImage.lineIndex >= currentImage.height) {
|
|
24717
|
+
this._lastLine = null;
|
|
24718
|
+
this._imageIndex++;
|
|
24719
|
+
currentImage = this._images[this._imageIndex];
|
|
24720
|
+
} else {
|
|
24721
|
+
this._lastLine = unfilteredLine;
|
|
24722
|
+
}
|
|
24723
|
+
if (currentImage) {
|
|
24724
|
+
this.read(currentImage.byteWidth + 1, this._reverseFilterLine.bind(this));
|
|
24725
|
+
} else {
|
|
24726
|
+
this._lastLine = null;
|
|
24727
|
+
this.complete();
|
|
24728
|
+
}
|
|
24729
|
+
};
|
|
24730
|
+
});
|
|
24731
|
+
|
|
24732
|
+
// node_modules/pngjs/lib/filter-parse-async.js
|
|
24733
|
+
var require_filter_parse_async = __commonJS((exports, module) => {
|
|
24734
|
+
var util = __require("util");
|
|
24735
|
+
var ChunkStream = require_chunkstream();
|
|
24736
|
+
var Filter = require_filter_parse();
|
|
24737
|
+
var FilterAsync = module.exports = function(bitmapInfo) {
|
|
24738
|
+
ChunkStream.call(this);
|
|
24739
|
+
let buffers = [];
|
|
24740
|
+
let that = this;
|
|
24741
|
+
this._filter = new Filter(bitmapInfo, {
|
|
24742
|
+
read: this.read.bind(this),
|
|
24743
|
+
write: function(buffer) {
|
|
24744
|
+
buffers.push(buffer);
|
|
24745
|
+
},
|
|
24746
|
+
complete: function() {
|
|
24747
|
+
that.emit("complete", Buffer.concat(buffers));
|
|
24748
|
+
}
|
|
24749
|
+
});
|
|
24750
|
+
this._filter.start();
|
|
24751
|
+
};
|
|
24752
|
+
util.inherits(FilterAsync, ChunkStream);
|
|
24753
|
+
});
|
|
24754
|
+
|
|
24755
|
+
// node_modules/pngjs/lib/constants.js
|
|
24756
|
+
var require_constants = __commonJS((exports, module) => {
|
|
24757
|
+
module.exports = {
|
|
24758
|
+
PNG_SIGNATURE: [137, 80, 78, 71, 13, 10, 26, 10],
|
|
24759
|
+
TYPE_IHDR: 1229472850,
|
|
24760
|
+
TYPE_IEND: 1229278788,
|
|
24761
|
+
TYPE_IDAT: 1229209940,
|
|
24762
|
+
TYPE_PLTE: 1347179589,
|
|
24763
|
+
TYPE_tRNS: 1951551059,
|
|
24764
|
+
TYPE_gAMA: 1732332865,
|
|
24765
|
+
COLORTYPE_GRAYSCALE: 0,
|
|
24766
|
+
COLORTYPE_PALETTE: 1,
|
|
24767
|
+
COLORTYPE_COLOR: 2,
|
|
24768
|
+
COLORTYPE_ALPHA: 4,
|
|
24769
|
+
COLORTYPE_PALETTE_COLOR: 3,
|
|
24770
|
+
COLORTYPE_COLOR_ALPHA: 6,
|
|
24771
|
+
COLORTYPE_TO_BPP_MAP: {
|
|
24772
|
+
0: 1,
|
|
24773
|
+
2: 3,
|
|
24774
|
+
3: 1,
|
|
24775
|
+
4: 2,
|
|
24776
|
+
6: 4
|
|
24777
|
+
},
|
|
24778
|
+
GAMMA_DIVISION: 1e5
|
|
24779
|
+
};
|
|
24780
|
+
});
|
|
24781
|
+
|
|
24782
|
+
// node_modules/pngjs/lib/crc.js
|
|
24783
|
+
var require_crc = __commonJS((exports, module) => {
|
|
24784
|
+
var crcTable = [];
|
|
24785
|
+
(function() {
|
|
24786
|
+
for (let i3 = 0;i3 < 256; i3++) {
|
|
24787
|
+
let currentCrc = i3;
|
|
24788
|
+
for (let j = 0;j < 8; j++) {
|
|
24789
|
+
if (currentCrc & 1) {
|
|
24790
|
+
currentCrc = 3988292384 ^ currentCrc >>> 1;
|
|
24791
|
+
} else {
|
|
24792
|
+
currentCrc = currentCrc >>> 1;
|
|
24793
|
+
}
|
|
24794
|
+
}
|
|
24795
|
+
crcTable[i3] = currentCrc;
|
|
24796
|
+
}
|
|
24797
|
+
})();
|
|
24798
|
+
var CrcCalculator = module.exports = function() {
|
|
24799
|
+
this._crc = -1;
|
|
24800
|
+
};
|
|
24801
|
+
CrcCalculator.prototype.write = function(data) {
|
|
24802
|
+
for (let i3 = 0;i3 < data.length; i3++) {
|
|
24803
|
+
this._crc = crcTable[(this._crc ^ data[i3]) & 255] ^ this._crc >>> 8;
|
|
24804
|
+
}
|
|
24805
|
+
return true;
|
|
24806
|
+
};
|
|
24807
|
+
CrcCalculator.prototype.crc32 = function() {
|
|
24808
|
+
return this._crc ^ -1;
|
|
24809
|
+
};
|
|
24810
|
+
CrcCalculator.crc32 = function(buf) {
|
|
24811
|
+
let crc = -1;
|
|
24812
|
+
for (let i3 = 0;i3 < buf.length; i3++) {
|
|
24813
|
+
crc = crcTable[(crc ^ buf[i3]) & 255] ^ crc >>> 8;
|
|
24814
|
+
}
|
|
24815
|
+
return crc ^ -1;
|
|
24816
|
+
};
|
|
24817
|
+
});
|
|
24818
|
+
|
|
24819
|
+
// node_modules/pngjs/lib/parser.js
|
|
24820
|
+
var require_parser = __commonJS((exports, module) => {
|
|
24821
|
+
var constants = require_constants();
|
|
24822
|
+
var CrcCalculator = require_crc();
|
|
24823
|
+
var Parser = module.exports = function(options, dependencies) {
|
|
24824
|
+
this._options = options;
|
|
24825
|
+
options.checkCRC = options.checkCRC !== false;
|
|
24826
|
+
this._hasIHDR = false;
|
|
24827
|
+
this._hasIEND = false;
|
|
24828
|
+
this._emittedHeadersFinished = false;
|
|
24829
|
+
this._palette = [];
|
|
24830
|
+
this._colorType = 0;
|
|
24831
|
+
this._chunks = {};
|
|
24832
|
+
this._chunks[constants.TYPE_IHDR] = this._handleIHDR.bind(this);
|
|
24833
|
+
this._chunks[constants.TYPE_IEND] = this._handleIEND.bind(this);
|
|
24834
|
+
this._chunks[constants.TYPE_IDAT] = this._handleIDAT.bind(this);
|
|
24835
|
+
this._chunks[constants.TYPE_PLTE] = this._handlePLTE.bind(this);
|
|
24836
|
+
this._chunks[constants.TYPE_tRNS] = this._handleTRNS.bind(this);
|
|
24837
|
+
this._chunks[constants.TYPE_gAMA] = this._handleGAMA.bind(this);
|
|
24838
|
+
this.read = dependencies.read;
|
|
24839
|
+
this.error = dependencies.error;
|
|
24840
|
+
this.metadata = dependencies.metadata;
|
|
24841
|
+
this.gamma = dependencies.gamma;
|
|
24842
|
+
this.transColor = dependencies.transColor;
|
|
24843
|
+
this.palette = dependencies.palette;
|
|
24844
|
+
this.parsed = dependencies.parsed;
|
|
24845
|
+
this.inflateData = dependencies.inflateData;
|
|
24846
|
+
this.finished = dependencies.finished;
|
|
24847
|
+
this.simpleTransparency = dependencies.simpleTransparency;
|
|
24848
|
+
this.headersFinished = dependencies.headersFinished || function() {};
|
|
24849
|
+
};
|
|
24850
|
+
Parser.prototype.start = function() {
|
|
24851
|
+
this.read(constants.PNG_SIGNATURE.length, this._parseSignature.bind(this));
|
|
24852
|
+
};
|
|
24853
|
+
Parser.prototype._parseSignature = function(data) {
|
|
24854
|
+
let signature = constants.PNG_SIGNATURE;
|
|
24855
|
+
for (let i3 = 0;i3 < signature.length; i3++) {
|
|
24856
|
+
if (data[i3] !== signature[i3]) {
|
|
24857
|
+
this.error(new Error("Invalid file signature"));
|
|
24858
|
+
return;
|
|
24859
|
+
}
|
|
24860
|
+
}
|
|
24861
|
+
this.read(8, this._parseChunkBegin.bind(this));
|
|
24862
|
+
};
|
|
24863
|
+
Parser.prototype._parseChunkBegin = function(data) {
|
|
24864
|
+
let length = data.readUInt32BE(0);
|
|
24865
|
+
let type = data.readUInt32BE(4);
|
|
24866
|
+
let name = "";
|
|
24867
|
+
for (let i3 = 4;i3 < 8; i3++) {
|
|
24868
|
+
name += String.fromCharCode(data[i3]);
|
|
24869
|
+
}
|
|
24870
|
+
let ancillary = Boolean(data[4] & 32);
|
|
24871
|
+
if (!this._hasIHDR && type !== constants.TYPE_IHDR) {
|
|
24872
|
+
this.error(new Error("Expected IHDR on beggining"));
|
|
24873
|
+
return;
|
|
24874
|
+
}
|
|
24875
|
+
this._crc = new CrcCalculator;
|
|
24876
|
+
this._crc.write(Buffer.from(name));
|
|
24877
|
+
if (this._chunks[type]) {
|
|
24878
|
+
return this._chunks[type](length);
|
|
24879
|
+
}
|
|
24880
|
+
if (!ancillary) {
|
|
24881
|
+
this.error(new Error("Unsupported critical chunk type " + name));
|
|
24882
|
+
return;
|
|
24883
|
+
}
|
|
24884
|
+
this.read(length + 4, this._skipChunk.bind(this));
|
|
24885
|
+
};
|
|
24886
|
+
Parser.prototype._skipChunk = function() {
|
|
24887
|
+
this.read(8, this._parseChunkBegin.bind(this));
|
|
24888
|
+
};
|
|
24889
|
+
Parser.prototype._handleChunkEnd = function() {
|
|
24890
|
+
this.read(4, this._parseChunkEnd.bind(this));
|
|
24891
|
+
};
|
|
24892
|
+
Parser.prototype._parseChunkEnd = function(data) {
|
|
24893
|
+
let fileCrc = data.readInt32BE(0);
|
|
24894
|
+
let calcCrc = this._crc.crc32();
|
|
24895
|
+
if (this._options.checkCRC && calcCrc !== fileCrc) {
|
|
24896
|
+
this.error(new Error("Crc error - " + fileCrc + " - " + calcCrc));
|
|
24897
|
+
return;
|
|
24898
|
+
}
|
|
24899
|
+
if (!this._hasIEND) {
|
|
24900
|
+
this.read(8, this._parseChunkBegin.bind(this));
|
|
24901
|
+
}
|
|
24902
|
+
};
|
|
24903
|
+
Parser.prototype._handleIHDR = function(length) {
|
|
24904
|
+
this.read(length, this._parseIHDR.bind(this));
|
|
24905
|
+
};
|
|
24906
|
+
Parser.prototype._parseIHDR = function(data) {
|
|
24907
|
+
this._crc.write(data);
|
|
24908
|
+
let width = data.readUInt32BE(0);
|
|
24909
|
+
let height = data.readUInt32BE(4);
|
|
24910
|
+
let depth = data[8];
|
|
24911
|
+
let colorType = data[9];
|
|
24912
|
+
let compr = data[10];
|
|
24913
|
+
let filter = data[11];
|
|
24914
|
+
let interlace = data[12];
|
|
24915
|
+
if (depth !== 8 && depth !== 4 && depth !== 2 && depth !== 1 && depth !== 16) {
|
|
24916
|
+
this.error(new Error("Unsupported bit depth " + depth));
|
|
24917
|
+
return;
|
|
24918
|
+
}
|
|
24919
|
+
if (!(colorType in constants.COLORTYPE_TO_BPP_MAP)) {
|
|
24920
|
+
this.error(new Error("Unsupported color type"));
|
|
24921
|
+
return;
|
|
24922
|
+
}
|
|
24923
|
+
if (compr !== 0) {
|
|
24924
|
+
this.error(new Error("Unsupported compression method"));
|
|
24925
|
+
return;
|
|
24926
|
+
}
|
|
24927
|
+
if (filter !== 0) {
|
|
24928
|
+
this.error(new Error("Unsupported filter method"));
|
|
24929
|
+
return;
|
|
24930
|
+
}
|
|
24931
|
+
if (interlace !== 0 && interlace !== 1) {
|
|
24932
|
+
this.error(new Error("Unsupported interlace method"));
|
|
24933
|
+
return;
|
|
24934
|
+
}
|
|
24935
|
+
this._colorType = colorType;
|
|
24936
|
+
let bpp = constants.COLORTYPE_TO_BPP_MAP[this._colorType];
|
|
24937
|
+
this._hasIHDR = true;
|
|
24938
|
+
this.metadata({
|
|
24939
|
+
width,
|
|
24940
|
+
height,
|
|
24941
|
+
depth,
|
|
24942
|
+
interlace: Boolean(interlace),
|
|
24943
|
+
palette: Boolean(colorType & constants.COLORTYPE_PALETTE),
|
|
24944
|
+
color: Boolean(colorType & constants.COLORTYPE_COLOR),
|
|
24945
|
+
alpha: Boolean(colorType & constants.COLORTYPE_ALPHA),
|
|
24946
|
+
bpp,
|
|
24947
|
+
colorType
|
|
24948
|
+
});
|
|
24949
|
+
this._handleChunkEnd();
|
|
24950
|
+
};
|
|
24951
|
+
Parser.prototype._handlePLTE = function(length) {
|
|
24952
|
+
this.read(length, this._parsePLTE.bind(this));
|
|
24953
|
+
};
|
|
24954
|
+
Parser.prototype._parsePLTE = function(data) {
|
|
24955
|
+
this._crc.write(data);
|
|
24956
|
+
let entries = Math.floor(data.length / 3);
|
|
24957
|
+
for (let i3 = 0;i3 < entries; i3++) {
|
|
24958
|
+
this._palette.push([data[i3 * 3], data[i3 * 3 + 1], data[i3 * 3 + 2], 255]);
|
|
24959
|
+
}
|
|
24960
|
+
this.palette(this._palette);
|
|
24961
|
+
this._handleChunkEnd();
|
|
24962
|
+
};
|
|
24963
|
+
Parser.prototype._handleTRNS = function(length) {
|
|
24964
|
+
this.simpleTransparency();
|
|
24965
|
+
this.read(length, this._parseTRNS.bind(this));
|
|
24966
|
+
};
|
|
24967
|
+
Parser.prototype._parseTRNS = function(data) {
|
|
24968
|
+
this._crc.write(data);
|
|
24969
|
+
if (this._colorType === constants.COLORTYPE_PALETTE_COLOR) {
|
|
24970
|
+
if (this._palette.length === 0) {
|
|
24971
|
+
this.error(new Error("Transparency chunk must be after palette"));
|
|
24972
|
+
return;
|
|
24973
|
+
}
|
|
24974
|
+
if (data.length > this._palette.length) {
|
|
24975
|
+
this.error(new Error("More transparent colors than palette size"));
|
|
24976
|
+
return;
|
|
24977
|
+
}
|
|
24978
|
+
for (let i3 = 0;i3 < data.length; i3++) {
|
|
24979
|
+
this._palette[i3][3] = data[i3];
|
|
24980
|
+
}
|
|
24981
|
+
this.palette(this._palette);
|
|
24982
|
+
}
|
|
24983
|
+
if (this._colorType === constants.COLORTYPE_GRAYSCALE) {
|
|
24984
|
+
this.transColor([data.readUInt16BE(0)]);
|
|
24985
|
+
}
|
|
24986
|
+
if (this._colorType === constants.COLORTYPE_COLOR) {
|
|
24987
|
+
this.transColor([
|
|
24988
|
+
data.readUInt16BE(0),
|
|
24989
|
+
data.readUInt16BE(2),
|
|
24990
|
+
data.readUInt16BE(4)
|
|
24991
|
+
]);
|
|
24992
|
+
}
|
|
24993
|
+
this._handleChunkEnd();
|
|
24994
|
+
};
|
|
24995
|
+
Parser.prototype._handleGAMA = function(length) {
|
|
24996
|
+
this.read(length, this._parseGAMA.bind(this));
|
|
24997
|
+
};
|
|
24998
|
+
Parser.prototype._parseGAMA = function(data) {
|
|
24999
|
+
this._crc.write(data);
|
|
25000
|
+
this.gamma(data.readUInt32BE(0) / constants.GAMMA_DIVISION);
|
|
25001
|
+
this._handleChunkEnd();
|
|
25002
|
+
};
|
|
25003
|
+
Parser.prototype._handleIDAT = function(length) {
|
|
25004
|
+
if (!this._emittedHeadersFinished) {
|
|
25005
|
+
this._emittedHeadersFinished = true;
|
|
25006
|
+
this.headersFinished();
|
|
25007
|
+
}
|
|
25008
|
+
this.read(-length, this._parseIDAT.bind(this, length));
|
|
25009
|
+
};
|
|
25010
|
+
Parser.prototype._parseIDAT = function(length, data) {
|
|
25011
|
+
this._crc.write(data);
|
|
25012
|
+
if (this._colorType === constants.COLORTYPE_PALETTE_COLOR && this._palette.length === 0) {
|
|
25013
|
+
throw new Error("Expected palette not found");
|
|
25014
|
+
}
|
|
25015
|
+
this.inflateData(data);
|
|
25016
|
+
let leftOverLength = length - data.length;
|
|
25017
|
+
if (leftOverLength > 0) {
|
|
25018
|
+
this._handleIDAT(leftOverLength);
|
|
25019
|
+
} else {
|
|
25020
|
+
this._handleChunkEnd();
|
|
25021
|
+
}
|
|
25022
|
+
};
|
|
25023
|
+
Parser.prototype._handleIEND = function(length) {
|
|
25024
|
+
this.read(length, this._parseIEND.bind(this));
|
|
25025
|
+
};
|
|
25026
|
+
Parser.prototype._parseIEND = function(data) {
|
|
25027
|
+
this._crc.write(data);
|
|
25028
|
+
this._hasIEND = true;
|
|
25029
|
+
this._handleChunkEnd();
|
|
25030
|
+
if (this.finished) {
|
|
25031
|
+
this.finished();
|
|
25032
|
+
}
|
|
25033
|
+
};
|
|
25034
|
+
});
|
|
25035
|
+
|
|
25036
|
+
// node_modules/pngjs/lib/bitmapper.js
|
|
25037
|
+
var require_bitmapper = __commonJS((exports) => {
|
|
25038
|
+
var interlaceUtils = require_interlace();
|
|
25039
|
+
var pixelBppMapper = [
|
|
25040
|
+
function() {},
|
|
25041
|
+
function(pxData, data, pxPos, rawPos) {
|
|
25042
|
+
if (rawPos === data.length) {
|
|
25043
|
+
throw new Error("Ran out of data");
|
|
25044
|
+
}
|
|
25045
|
+
let pixel = data[rawPos];
|
|
25046
|
+
pxData[pxPos] = pixel;
|
|
25047
|
+
pxData[pxPos + 1] = pixel;
|
|
25048
|
+
pxData[pxPos + 2] = pixel;
|
|
25049
|
+
pxData[pxPos + 3] = 255;
|
|
25050
|
+
},
|
|
25051
|
+
function(pxData, data, pxPos, rawPos) {
|
|
25052
|
+
if (rawPos + 1 >= data.length) {
|
|
25053
|
+
throw new Error("Ran out of data");
|
|
25054
|
+
}
|
|
25055
|
+
let pixel = data[rawPos];
|
|
25056
|
+
pxData[pxPos] = pixel;
|
|
25057
|
+
pxData[pxPos + 1] = pixel;
|
|
25058
|
+
pxData[pxPos + 2] = pixel;
|
|
25059
|
+
pxData[pxPos + 3] = data[rawPos + 1];
|
|
25060
|
+
},
|
|
25061
|
+
function(pxData, data, pxPos, rawPos) {
|
|
25062
|
+
if (rawPos + 2 >= data.length) {
|
|
25063
|
+
throw new Error("Ran out of data");
|
|
25064
|
+
}
|
|
25065
|
+
pxData[pxPos] = data[rawPos];
|
|
25066
|
+
pxData[pxPos + 1] = data[rawPos + 1];
|
|
25067
|
+
pxData[pxPos + 2] = data[rawPos + 2];
|
|
25068
|
+
pxData[pxPos + 3] = 255;
|
|
25069
|
+
},
|
|
25070
|
+
function(pxData, data, pxPos, rawPos) {
|
|
25071
|
+
if (rawPos + 3 >= data.length) {
|
|
25072
|
+
throw new Error("Ran out of data");
|
|
25073
|
+
}
|
|
25074
|
+
pxData[pxPos] = data[rawPos];
|
|
25075
|
+
pxData[pxPos + 1] = data[rawPos + 1];
|
|
25076
|
+
pxData[pxPos + 2] = data[rawPos + 2];
|
|
25077
|
+
pxData[pxPos + 3] = data[rawPos + 3];
|
|
25078
|
+
}
|
|
25079
|
+
];
|
|
25080
|
+
var pixelBppCustomMapper = [
|
|
25081
|
+
function() {},
|
|
25082
|
+
function(pxData, pixelData, pxPos, maxBit) {
|
|
25083
|
+
let pixel = pixelData[0];
|
|
25084
|
+
pxData[pxPos] = pixel;
|
|
25085
|
+
pxData[pxPos + 1] = pixel;
|
|
25086
|
+
pxData[pxPos + 2] = pixel;
|
|
25087
|
+
pxData[pxPos + 3] = maxBit;
|
|
25088
|
+
},
|
|
25089
|
+
function(pxData, pixelData, pxPos) {
|
|
25090
|
+
let pixel = pixelData[0];
|
|
25091
|
+
pxData[pxPos] = pixel;
|
|
25092
|
+
pxData[pxPos + 1] = pixel;
|
|
25093
|
+
pxData[pxPos + 2] = pixel;
|
|
25094
|
+
pxData[pxPos + 3] = pixelData[1];
|
|
25095
|
+
},
|
|
25096
|
+
function(pxData, pixelData, pxPos, maxBit) {
|
|
25097
|
+
pxData[pxPos] = pixelData[0];
|
|
25098
|
+
pxData[pxPos + 1] = pixelData[1];
|
|
25099
|
+
pxData[pxPos + 2] = pixelData[2];
|
|
25100
|
+
pxData[pxPos + 3] = maxBit;
|
|
25101
|
+
},
|
|
25102
|
+
function(pxData, pixelData, pxPos) {
|
|
25103
|
+
pxData[pxPos] = pixelData[0];
|
|
25104
|
+
pxData[pxPos + 1] = pixelData[1];
|
|
25105
|
+
pxData[pxPos + 2] = pixelData[2];
|
|
25106
|
+
pxData[pxPos + 3] = pixelData[3];
|
|
25107
|
+
}
|
|
25108
|
+
];
|
|
25109
|
+
function bitRetriever(data, depth) {
|
|
25110
|
+
let leftOver = [];
|
|
25111
|
+
let i3 = 0;
|
|
25112
|
+
function split() {
|
|
25113
|
+
if (i3 === data.length) {
|
|
25114
|
+
throw new Error("Ran out of data");
|
|
25115
|
+
}
|
|
25116
|
+
let byte = data[i3];
|
|
25117
|
+
i3++;
|
|
25118
|
+
let byte8, byte7, byte6, byte5, byte4, byte3, byte2, byte1;
|
|
25119
|
+
switch (depth) {
|
|
25120
|
+
default:
|
|
25121
|
+
throw new Error("unrecognised depth");
|
|
25122
|
+
case 16:
|
|
25123
|
+
byte2 = data[i3];
|
|
25124
|
+
i3++;
|
|
25125
|
+
leftOver.push((byte << 8) + byte2);
|
|
25126
|
+
break;
|
|
25127
|
+
case 4:
|
|
25128
|
+
byte2 = byte & 15;
|
|
25129
|
+
byte1 = byte >> 4;
|
|
25130
|
+
leftOver.push(byte1, byte2);
|
|
25131
|
+
break;
|
|
25132
|
+
case 2:
|
|
25133
|
+
byte4 = byte & 3;
|
|
25134
|
+
byte3 = byte >> 2 & 3;
|
|
25135
|
+
byte2 = byte >> 4 & 3;
|
|
25136
|
+
byte1 = byte >> 6 & 3;
|
|
25137
|
+
leftOver.push(byte1, byte2, byte3, byte4);
|
|
25138
|
+
break;
|
|
25139
|
+
case 1:
|
|
25140
|
+
byte8 = byte & 1;
|
|
25141
|
+
byte7 = byte >> 1 & 1;
|
|
25142
|
+
byte6 = byte >> 2 & 1;
|
|
25143
|
+
byte5 = byte >> 3 & 1;
|
|
25144
|
+
byte4 = byte >> 4 & 1;
|
|
25145
|
+
byte3 = byte >> 5 & 1;
|
|
25146
|
+
byte2 = byte >> 6 & 1;
|
|
25147
|
+
byte1 = byte >> 7 & 1;
|
|
25148
|
+
leftOver.push(byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8);
|
|
25149
|
+
break;
|
|
25150
|
+
}
|
|
25151
|
+
}
|
|
25152
|
+
return {
|
|
25153
|
+
get: function(count) {
|
|
25154
|
+
while (leftOver.length < count) {
|
|
25155
|
+
split();
|
|
25156
|
+
}
|
|
25157
|
+
let returner = leftOver.slice(0, count);
|
|
25158
|
+
leftOver = leftOver.slice(count);
|
|
25159
|
+
return returner;
|
|
25160
|
+
},
|
|
25161
|
+
resetAfterLine: function() {
|
|
25162
|
+
leftOver.length = 0;
|
|
25163
|
+
},
|
|
25164
|
+
end: function() {
|
|
25165
|
+
if (i3 !== data.length) {
|
|
25166
|
+
throw new Error("extra data found");
|
|
25167
|
+
}
|
|
25168
|
+
}
|
|
25169
|
+
};
|
|
25170
|
+
}
|
|
25171
|
+
function mapImage8Bit(image, pxData, getPxPos, bpp, data, rawPos) {
|
|
25172
|
+
let imageWidth = image.width;
|
|
25173
|
+
let imageHeight = image.height;
|
|
25174
|
+
let imagePass = image.index;
|
|
25175
|
+
for (let y5 = 0;y5 < imageHeight; y5++) {
|
|
25176
|
+
for (let x3 = 0;x3 < imageWidth; x3++) {
|
|
25177
|
+
let pxPos = getPxPos(x3, y5, imagePass);
|
|
25178
|
+
pixelBppMapper[bpp](pxData, data, pxPos, rawPos);
|
|
25179
|
+
rawPos += bpp;
|
|
25180
|
+
}
|
|
25181
|
+
}
|
|
25182
|
+
return rawPos;
|
|
25183
|
+
}
|
|
25184
|
+
function mapImageCustomBit(image, pxData, getPxPos, bpp, bits, maxBit) {
|
|
25185
|
+
let imageWidth = image.width;
|
|
25186
|
+
let imageHeight = image.height;
|
|
25187
|
+
let imagePass = image.index;
|
|
25188
|
+
for (let y5 = 0;y5 < imageHeight; y5++) {
|
|
25189
|
+
for (let x3 = 0;x3 < imageWidth; x3++) {
|
|
25190
|
+
let pixelData = bits.get(bpp);
|
|
25191
|
+
let pxPos = getPxPos(x3, y5, imagePass);
|
|
25192
|
+
pixelBppCustomMapper[bpp](pxData, pixelData, pxPos, maxBit);
|
|
25193
|
+
}
|
|
25194
|
+
bits.resetAfterLine();
|
|
25195
|
+
}
|
|
25196
|
+
}
|
|
25197
|
+
exports.dataToBitMap = function(data, bitmapInfo) {
|
|
25198
|
+
let width = bitmapInfo.width;
|
|
25199
|
+
let height = bitmapInfo.height;
|
|
25200
|
+
let depth = bitmapInfo.depth;
|
|
25201
|
+
let bpp = bitmapInfo.bpp;
|
|
25202
|
+
let interlace = bitmapInfo.interlace;
|
|
25203
|
+
let bits;
|
|
25204
|
+
if (depth !== 8) {
|
|
25205
|
+
bits = bitRetriever(data, depth);
|
|
25206
|
+
}
|
|
25207
|
+
let pxData;
|
|
25208
|
+
if (depth <= 8) {
|
|
25209
|
+
pxData = Buffer.alloc(width * height * 4);
|
|
25210
|
+
} else {
|
|
25211
|
+
pxData = new Uint16Array(width * height * 4);
|
|
25212
|
+
}
|
|
25213
|
+
let maxBit = Math.pow(2, depth) - 1;
|
|
25214
|
+
let rawPos = 0;
|
|
25215
|
+
let images;
|
|
25216
|
+
let getPxPos;
|
|
25217
|
+
if (interlace) {
|
|
25218
|
+
images = interlaceUtils.getImagePasses(width, height);
|
|
25219
|
+
getPxPos = interlaceUtils.getInterlaceIterator(width, height);
|
|
25220
|
+
} else {
|
|
25221
|
+
let nonInterlacedPxPos = 0;
|
|
25222
|
+
getPxPos = function() {
|
|
25223
|
+
let returner = nonInterlacedPxPos;
|
|
25224
|
+
nonInterlacedPxPos += 4;
|
|
25225
|
+
return returner;
|
|
25226
|
+
};
|
|
25227
|
+
images = [{ width, height }];
|
|
25228
|
+
}
|
|
25229
|
+
for (let imageIndex = 0;imageIndex < images.length; imageIndex++) {
|
|
25230
|
+
if (depth === 8) {
|
|
25231
|
+
rawPos = mapImage8Bit(images[imageIndex], pxData, getPxPos, bpp, data, rawPos);
|
|
25232
|
+
} else {
|
|
25233
|
+
mapImageCustomBit(images[imageIndex], pxData, getPxPos, bpp, bits, maxBit);
|
|
25234
|
+
}
|
|
25235
|
+
}
|
|
25236
|
+
if (depth === 8) {
|
|
25237
|
+
if (rawPos !== data.length) {
|
|
25238
|
+
throw new Error("extra data found");
|
|
25239
|
+
}
|
|
25240
|
+
} else {
|
|
25241
|
+
bits.end();
|
|
25242
|
+
}
|
|
25243
|
+
return pxData;
|
|
25244
|
+
};
|
|
25245
|
+
});
|
|
25246
|
+
|
|
25247
|
+
// node_modules/pngjs/lib/format-normaliser.js
|
|
25248
|
+
var require_format_normaliser = __commonJS((exports, module) => {
|
|
25249
|
+
function dePalette(indata, outdata, width, height, palette) {
|
|
25250
|
+
let pxPos = 0;
|
|
25251
|
+
for (let y5 = 0;y5 < height; y5++) {
|
|
25252
|
+
for (let x3 = 0;x3 < width; x3++) {
|
|
25253
|
+
let color = palette[indata[pxPos]];
|
|
25254
|
+
if (!color) {
|
|
25255
|
+
throw new Error("index " + indata[pxPos] + " not in palette");
|
|
25256
|
+
}
|
|
25257
|
+
for (let i3 = 0;i3 < 4; i3++) {
|
|
25258
|
+
outdata[pxPos + i3] = color[i3];
|
|
25259
|
+
}
|
|
25260
|
+
pxPos += 4;
|
|
25261
|
+
}
|
|
25262
|
+
}
|
|
25263
|
+
}
|
|
25264
|
+
function replaceTransparentColor(indata, outdata, width, height, transColor) {
|
|
25265
|
+
let pxPos = 0;
|
|
25266
|
+
for (let y5 = 0;y5 < height; y5++) {
|
|
25267
|
+
for (let x3 = 0;x3 < width; x3++) {
|
|
25268
|
+
let makeTrans = false;
|
|
25269
|
+
if (transColor.length === 1) {
|
|
25270
|
+
if (transColor[0] === indata[pxPos]) {
|
|
25271
|
+
makeTrans = true;
|
|
25272
|
+
}
|
|
25273
|
+
} else if (transColor[0] === indata[pxPos] && transColor[1] === indata[pxPos + 1] && transColor[2] === indata[pxPos + 2]) {
|
|
25274
|
+
makeTrans = true;
|
|
25275
|
+
}
|
|
25276
|
+
if (makeTrans) {
|
|
25277
|
+
for (let i3 = 0;i3 < 4; i3++) {
|
|
25278
|
+
outdata[pxPos + i3] = 0;
|
|
25279
|
+
}
|
|
25280
|
+
}
|
|
25281
|
+
pxPos += 4;
|
|
25282
|
+
}
|
|
25283
|
+
}
|
|
25284
|
+
}
|
|
25285
|
+
function scaleDepth(indata, outdata, width, height, depth) {
|
|
25286
|
+
let maxOutSample = 255;
|
|
25287
|
+
let maxInSample = Math.pow(2, depth) - 1;
|
|
25288
|
+
let pxPos = 0;
|
|
25289
|
+
for (let y5 = 0;y5 < height; y5++) {
|
|
25290
|
+
for (let x3 = 0;x3 < width; x3++) {
|
|
25291
|
+
for (let i3 = 0;i3 < 4; i3++) {
|
|
25292
|
+
outdata[pxPos + i3] = Math.floor(indata[pxPos + i3] * maxOutSample / maxInSample + 0.5);
|
|
25293
|
+
}
|
|
25294
|
+
pxPos += 4;
|
|
25295
|
+
}
|
|
25296
|
+
}
|
|
25297
|
+
}
|
|
25298
|
+
module.exports = function(indata, imageData, skipRescale = false) {
|
|
25299
|
+
let depth = imageData.depth;
|
|
25300
|
+
let width = imageData.width;
|
|
25301
|
+
let height = imageData.height;
|
|
25302
|
+
let colorType = imageData.colorType;
|
|
25303
|
+
let transColor = imageData.transColor;
|
|
25304
|
+
let palette = imageData.palette;
|
|
25305
|
+
let outdata = indata;
|
|
25306
|
+
if (colorType === 3) {
|
|
25307
|
+
dePalette(indata, outdata, width, height, palette);
|
|
25308
|
+
} else {
|
|
25309
|
+
if (transColor) {
|
|
25310
|
+
replaceTransparentColor(indata, outdata, width, height, transColor);
|
|
25311
|
+
}
|
|
25312
|
+
if (depth !== 8 && !skipRescale) {
|
|
25313
|
+
if (depth === 16) {
|
|
25314
|
+
outdata = Buffer.alloc(width * height * 4);
|
|
25315
|
+
}
|
|
25316
|
+
scaleDepth(indata, outdata, width, height, depth);
|
|
25317
|
+
}
|
|
25318
|
+
}
|
|
25319
|
+
return outdata;
|
|
25320
|
+
};
|
|
25321
|
+
});
|
|
25322
|
+
|
|
25323
|
+
// node_modules/pngjs/lib/parser-async.js
|
|
25324
|
+
var require_parser_async = __commonJS((exports, module) => {
|
|
25325
|
+
var util = __require("util");
|
|
25326
|
+
var zlib = __require("zlib");
|
|
25327
|
+
var ChunkStream = require_chunkstream();
|
|
25328
|
+
var FilterAsync = require_filter_parse_async();
|
|
25329
|
+
var Parser = require_parser();
|
|
25330
|
+
var bitmapper = require_bitmapper();
|
|
25331
|
+
var formatNormaliser = require_format_normaliser();
|
|
25332
|
+
var ParserAsync = module.exports = function(options) {
|
|
25333
|
+
ChunkStream.call(this);
|
|
25334
|
+
this._parser = new Parser(options, {
|
|
25335
|
+
read: this.read.bind(this),
|
|
25336
|
+
error: this._handleError.bind(this),
|
|
25337
|
+
metadata: this._handleMetaData.bind(this),
|
|
25338
|
+
gamma: this.emit.bind(this, "gamma"),
|
|
25339
|
+
palette: this._handlePalette.bind(this),
|
|
25340
|
+
transColor: this._handleTransColor.bind(this),
|
|
25341
|
+
finished: this._finished.bind(this),
|
|
25342
|
+
inflateData: this._inflateData.bind(this),
|
|
25343
|
+
simpleTransparency: this._simpleTransparency.bind(this),
|
|
25344
|
+
headersFinished: this._headersFinished.bind(this)
|
|
25345
|
+
});
|
|
25346
|
+
this._options = options;
|
|
25347
|
+
this.writable = true;
|
|
25348
|
+
this._parser.start();
|
|
25349
|
+
};
|
|
25350
|
+
util.inherits(ParserAsync, ChunkStream);
|
|
25351
|
+
ParserAsync.prototype._handleError = function(err) {
|
|
25352
|
+
this.emit("error", err);
|
|
25353
|
+
this.writable = false;
|
|
25354
|
+
this.destroy();
|
|
25355
|
+
if (this._inflate && this._inflate.destroy) {
|
|
25356
|
+
this._inflate.destroy();
|
|
25357
|
+
}
|
|
25358
|
+
if (this._filter) {
|
|
25359
|
+
this._filter.destroy();
|
|
25360
|
+
this._filter.on("error", function() {});
|
|
25361
|
+
}
|
|
25362
|
+
this.errord = true;
|
|
25363
|
+
};
|
|
25364
|
+
ParserAsync.prototype._inflateData = function(data) {
|
|
25365
|
+
if (!this._inflate) {
|
|
25366
|
+
if (this._bitmapInfo.interlace) {
|
|
25367
|
+
this._inflate = zlib.createInflate();
|
|
25368
|
+
this._inflate.on("error", this.emit.bind(this, "error"));
|
|
25369
|
+
this._filter.on("complete", this._complete.bind(this));
|
|
25370
|
+
this._inflate.pipe(this._filter);
|
|
25371
|
+
} else {
|
|
25372
|
+
let rowSize = (this._bitmapInfo.width * this._bitmapInfo.bpp * this._bitmapInfo.depth + 7 >> 3) + 1;
|
|
25373
|
+
let imageSize = rowSize * this._bitmapInfo.height;
|
|
25374
|
+
let chunkSize = Math.max(imageSize, zlib.Z_MIN_CHUNK);
|
|
25375
|
+
this._inflate = zlib.createInflate({ chunkSize });
|
|
25376
|
+
let leftToInflate = imageSize;
|
|
25377
|
+
let emitError = this.emit.bind(this, "error");
|
|
25378
|
+
this._inflate.on("error", function(err) {
|
|
25379
|
+
if (!leftToInflate) {
|
|
25380
|
+
return;
|
|
25381
|
+
}
|
|
25382
|
+
emitError(err);
|
|
25383
|
+
});
|
|
25384
|
+
this._filter.on("complete", this._complete.bind(this));
|
|
25385
|
+
let filterWrite = this._filter.write.bind(this._filter);
|
|
25386
|
+
this._inflate.on("data", function(chunk) {
|
|
25387
|
+
if (!leftToInflate) {
|
|
25388
|
+
return;
|
|
25389
|
+
}
|
|
25390
|
+
if (chunk.length > leftToInflate) {
|
|
25391
|
+
chunk = chunk.slice(0, leftToInflate);
|
|
25392
|
+
}
|
|
25393
|
+
leftToInflate -= chunk.length;
|
|
25394
|
+
filterWrite(chunk);
|
|
25395
|
+
});
|
|
25396
|
+
this._inflate.on("end", this._filter.end.bind(this._filter));
|
|
25397
|
+
}
|
|
25398
|
+
}
|
|
25399
|
+
this._inflate.write(data);
|
|
25400
|
+
};
|
|
25401
|
+
ParserAsync.prototype._handleMetaData = function(metaData) {
|
|
25402
|
+
this._metaData = metaData;
|
|
25403
|
+
this._bitmapInfo = Object.create(metaData);
|
|
25404
|
+
this._filter = new FilterAsync(this._bitmapInfo);
|
|
25405
|
+
};
|
|
25406
|
+
ParserAsync.prototype._handleTransColor = function(transColor) {
|
|
25407
|
+
this._bitmapInfo.transColor = transColor;
|
|
25408
|
+
};
|
|
25409
|
+
ParserAsync.prototype._handlePalette = function(palette) {
|
|
25410
|
+
this._bitmapInfo.palette = palette;
|
|
25411
|
+
};
|
|
25412
|
+
ParserAsync.prototype._simpleTransparency = function() {
|
|
25413
|
+
this._metaData.alpha = true;
|
|
25414
|
+
};
|
|
25415
|
+
ParserAsync.prototype._headersFinished = function() {
|
|
25416
|
+
this.emit("metadata", this._metaData);
|
|
25417
|
+
};
|
|
25418
|
+
ParserAsync.prototype._finished = function() {
|
|
25419
|
+
if (this.errord) {
|
|
25420
|
+
return;
|
|
25421
|
+
}
|
|
25422
|
+
if (!this._inflate) {
|
|
25423
|
+
this.emit("error", "No Inflate block");
|
|
25424
|
+
} else {
|
|
25425
|
+
this._inflate.end();
|
|
25426
|
+
}
|
|
25427
|
+
};
|
|
25428
|
+
ParserAsync.prototype._complete = function(filteredData) {
|
|
25429
|
+
if (this.errord) {
|
|
25430
|
+
return;
|
|
25431
|
+
}
|
|
25432
|
+
let normalisedBitmapData;
|
|
25433
|
+
try {
|
|
25434
|
+
let bitmapData = bitmapper.dataToBitMap(filteredData, this._bitmapInfo);
|
|
25435
|
+
normalisedBitmapData = formatNormaliser(bitmapData, this._bitmapInfo, this._options.skipRescale);
|
|
25436
|
+
bitmapData = null;
|
|
25437
|
+
} catch (ex) {
|
|
25438
|
+
this._handleError(ex);
|
|
25439
|
+
return;
|
|
25440
|
+
}
|
|
25441
|
+
this.emit("parsed", normalisedBitmapData);
|
|
25442
|
+
};
|
|
25443
|
+
});
|
|
25444
|
+
|
|
25445
|
+
// node_modules/pngjs/lib/bitpacker.js
|
|
25446
|
+
var require_bitpacker = __commonJS((exports, module) => {
|
|
25447
|
+
var constants = require_constants();
|
|
25448
|
+
module.exports = function(dataIn, width, height, options) {
|
|
25449
|
+
let outHasAlpha = [constants.COLORTYPE_COLOR_ALPHA, constants.COLORTYPE_ALPHA].indexOf(options.colorType) !== -1;
|
|
25450
|
+
if (options.colorType === options.inputColorType) {
|
|
25451
|
+
let bigEndian = function() {
|
|
25452
|
+
let buffer = new ArrayBuffer(2);
|
|
25453
|
+
new DataView(buffer).setInt16(0, 256, true);
|
|
25454
|
+
return new Int16Array(buffer)[0] !== 256;
|
|
25455
|
+
}();
|
|
25456
|
+
if (options.bitDepth === 8 || options.bitDepth === 16 && bigEndian) {
|
|
25457
|
+
return dataIn;
|
|
25458
|
+
}
|
|
25459
|
+
}
|
|
25460
|
+
let data = options.bitDepth !== 16 ? dataIn : new Uint16Array(dataIn.buffer);
|
|
25461
|
+
let maxValue = 255;
|
|
25462
|
+
let inBpp = constants.COLORTYPE_TO_BPP_MAP[options.inputColorType];
|
|
25463
|
+
if (inBpp === 4 && !options.inputHasAlpha) {
|
|
25464
|
+
inBpp = 3;
|
|
25465
|
+
}
|
|
25466
|
+
let outBpp = constants.COLORTYPE_TO_BPP_MAP[options.colorType];
|
|
25467
|
+
if (options.bitDepth === 16) {
|
|
25468
|
+
maxValue = 65535;
|
|
25469
|
+
outBpp *= 2;
|
|
25470
|
+
}
|
|
25471
|
+
let outData = Buffer.alloc(width * height * outBpp);
|
|
25472
|
+
let inIndex = 0;
|
|
25473
|
+
let outIndex = 0;
|
|
25474
|
+
let bgColor = options.bgColor || {};
|
|
25475
|
+
if (bgColor.red === undefined) {
|
|
25476
|
+
bgColor.red = maxValue;
|
|
25477
|
+
}
|
|
25478
|
+
if (bgColor.green === undefined) {
|
|
25479
|
+
bgColor.green = maxValue;
|
|
25480
|
+
}
|
|
25481
|
+
if (bgColor.blue === undefined) {
|
|
25482
|
+
bgColor.blue = maxValue;
|
|
25483
|
+
}
|
|
25484
|
+
function getRGBA() {
|
|
25485
|
+
let red;
|
|
25486
|
+
let green;
|
|
25487
|
+
let blue;
|
|
25488
|
+
let alpha = maxValue;
|
|
25489
|
+
switch (options.inputColorType) {
|
|
25490
|
+
case constants.COLORTYPE_COLOR_ALPHA:
|
|
25491
|
+
alpha = data[inIndex + 3];
|
|
25492
|
+
red = data[inIndex];
|
|
25493
|
+
green = data[inIndex + 1];
|
|
25494
|
+
blue = data[inIndex + 2];
|
|
25495
|
+
break;
|
|
25496
|
+
case constants.COLORTYPE_COLOR:
|
|
25497
|
+
red = data[inIndex];
|
|
25498
|
+
green = data[inIndex + 1];
|
|
25499
|
+
blue = data[inIndex + 2];
|
|
25500
|
+
break;
|
|
25501
|
+
case constants.COLORTYPE_ALPHA:
|
|
25502
|
+
alpha = data[inIndex + 1];
|
|
25503
|
+
red = data[inIndex];
|
|
25504
|
+
green = red;
|
|
25505
|
+
blue = red;
|
|
25506
|
+
break;
|
|
25507
|
+
case constants.COLORTYPE_GRAYSCALE:
|
|
25508
|
+
red = data[inIndex];
|
|
25509
|
+
green = red;
|
|
25510
|
+
blue = red;
|
|
25511
|
+
break;
|
|
25512
|
+
default:
|
|
25513
|
+
throw new Error("input color type:" + options.inputColorType + " is not supported at present");
|
|
25514
|
+
}
|
|
25515
|
+
if (options.inputHasAlpha) {
|
|
25516
|
+
if (!outHasAlpha) {
|
|
25517
|
+
alpha /= maxValue;
|
|
25518
|
+
red = Math.min(Math.max(Math.round((1 - alpha) * bgColor.red + alpha * red), 0), maxValue);
|
|
25519
|
+
green = Math.min(Math.max(Math.round((1 - alpha) * bgColor.green + alpha * green), 0), maxValue);
|
|
25520
|
+
blue = Math.min(Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0), maxValue);
|
|
25521
|
+
}
|
|
25522
|
+
}
|
|
25523
|
+
return { red, green, blue, alpha };
|
|
25524
|
+
}
|
|
25525
|
+
for (let y5 = 0;y5 < height; y5++) {
|
|
25526
|
+
for (let x3 = 0;x3 < width; x3++) {
|
|
25527
|
+
let rgba = getRGBA(data, inIndex);
|
|
25528
|
+
switch (options.colorType) {
|
|
25529
|
+
case constants.COLORTYPE_COLOR_ALPHA:
|
|
25530
|
+
case constants.COLORTYPE_COLOR:
|
|
25531
|
+
if (options.bitDepth === 8) {
|
|
25532
|
+
outData[outIndex] = rgba.red;
|
|
25533
|
+
outData[outIndex + 1] = rgba.green;
|
|
25534
|
+
outData[outIndex + 2] = rgba.blue;
|
|
25535
|
+
if (outHasAlpha) {
|
|
25536
|
+
outData[outIndex + 3] = rgba.alpha;
|
|
25537
|
+
}
|
|
25538
|
+
} else {
|
|
25539
|
+
outData.writeUInt16BE(rgba.red, outIndex);
|
|
25540
|
+
outData.writeUInt16BE(rgba.green, outIndex + 2);
|
|
25541
|
+
outData.writeUInt16BE(rgba.blue, outIndex + 4);
|
|
25542
|
+
if (outHasAlpha) {
|
|
25543
|
+
outData.writeUInt16BE(rgba.alpha, outIndex + 6);
|
|
25544
|
+
}
|
|
25545
|
+
}
|
|
25546
|
+
break;
|
|
25547
|
+
case constants.COLORTYPE_ALPHA:
|
|
25548
|
+
case constants.COLORTYPE_GRAYSCALE: {
|
|
25549
|
+
let grayscale = (rgba.red + rgba.green + rgba.blue) / 3;
|
|
25550
|
+
if (options.bitDepth === 8) {
|
|
25551
|
+
outData[outIndex] = grayscale;
|
|
25552
|
+
if (outHasAlpha) {
|
|
25553
|
+
outData[outIndex + 1] = rgba.alpha;
|
|
25554
|
+
}
|
|
25555
|
+
} else {
|
|
25556
|
+
outData.writeUInt16BE(grayscale, outIndex);
|
|
25557
|
+
if (outHasAlpha) {
|
|
25558
|
+
outData.writeUInt16BE(rgba.alpha, outIndex + 2);
|
|
25559
|
+
}
|
|
25560
|
+
}
|
|
25561
|
+
break;
|
|
25562
|
+
}
|
|
25563
|
+
default:
|
|
25564
|
+
throw new Error("unrecognised color Type " + options.colorType);
|
|
25565
|
+
}
|
|
25566
|
+
inIndex += inBpp;
|
|
25567
|
+
outIndex += outBpp;
|
|
25568
|
+
}
|
|
25569
|
+
}
|
|
25570
|
+
return outData;
|
|
25571
|
+
};
|
|
25572
|
+
});
|
|
25573
|
+
|
|
25574
|
+
// node_modules/pngjs/lib/filter-pack.js
|
|
25575
|
+
var require_filter_pack = __commonJS((exports, module) => {
|
|
25576
|
+
var paethPredictor = require_paeth_predictor();
|
|
25577
|
+
function filterNone(pxData, pxPos, byteWidth, rawData, rawPos) {
|
|
25578
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25579
|
+
rawData[rawPos + x3] = pxData[pxPos + x3];
|
|
25580
|
+
}
|
|
25581
|
+
}
|
|
25582
|
+
function filterSumNone(pxData, pxPos, byteWidth) {
|
|
25583
|
+
let sum = 0;
|
|
25584
|
+
let length = pxPos + byteWidth;
|
|
25585
|
+
for (let i3 = pxPos;i3 < length; i3++) {
|
|
25586
|
+
sum += Math.abs(pxData[i3]);
|
|
25587
|
+
}
|
|
25588
|
+
return sum;
|
|
25589
|
+
}
|
|
25590
|
+
function filterSub(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
|
|
25591
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25592
|
+
let left = x3 >= bpp ? pxData[pxPos + x3 - bpp] : 0;
|
|
25593
|
+
let val = pxData[pxPos + x3] - left;
|
|
25594
|
+
rawData[rawPos + x3] = val;
|
|
25595
|
+
}
|
|
25596
|
+
}
|
|
25597
|
+
function filterSumSub(pxData, pxPos, byteWidth, bpp) {
|
|
25598
|
+
let sum = 0;
|
|
25599
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25600
|
+
let left = x3 >= bpp ? pxData[pxPos + x3 - bpp] : 0;
|
|
25601
|
+
let val = pxData[pxPos + x3] - left;
|
|
25602
|
+
sum += Math.abs(val);
|
|
25603
|
+
}
|
|
25604
|
+
return sum;
|
|
25605
|
+
}
|
|
25606
|
+
function filterUp(pxData, pxPos, byteWidth, rawData, rawPos) {
|
|
25607
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25608
|
+
let up = pxPos > 0 ? pxData[pxPos + x3 - byteWidth] : 0;
|
|
25609
|
+
let val = pxData[pxPos + x3] - up;
|
|
25610
|
+
rawData[rawPos + x3] = val;
|
|
25611
|
+
}
|
|
25612
|
+
}
|
|
25613
|
+
function filterSumUp(pxData, pxPos, byteWidth) {
|
|
25614
|
+
let sum = 0;
|
|
25615
|
+
let length = pxPos + byteWidth;
|
|
25616
|
+
for (let x3 = pxPos;x3 < length; x3++) {
|
|
25617
|
+
let up = pxPos > 0 ? pxData[x3 - byteWidth] : 0;
|
|
25618
|
+
let val = pxData[x3] - up;
|
|
25619
|
+
sum += Math.abs(val);
|
|
25620
|
+
}
|
|
25621
|
+
return sum;
|
|
25622
|
+
}
|
|
25623
|
+
function filterAvg(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
|
|
25624
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25625
|
+
let left = x3 >= bpp ? pxData[pxPos + x3 - bpp] : 0;
|
|
25626
|
+
let up = pxPos > 0 ? pxData[pxPos + x3 - byteWidth] : 0;
|
|
25627
|
+
let val = pxData[pxPos + x3] - (left + up >> 1);
|
|
25628
|
+
rawData[rawPos + x3] = val;
|
|
25629
|
+
}
|
|
25630
|
+
}
|
|
25631
|
+
function filterSumAvg(pxData, pxPos, byteWidth, bpp) {
|
|
25632
|
+
let sum = 0;
|
|
25633
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25634
|
+
let left = x3 >= bpp ? pxData[pxPos + x3 - bpp] : 0;
|
|
25635
|
+
let up = pxPos > 0 ? pxData[pxPos + x3 - byteWidth] : 0;
|
|
25636
|
+
let val = pxData[pxPos + x3] - (left + up >> 1);
|
|
25637
|
+
sum += Math.abs(val);
|
|
25638
|
+
}
|
|
25639
|
+
return sum;
|
|
25640
|
+
}
|
|
25641
|
+
function filterPaeth(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
|
|
25642
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25643
|
+
let left = x3 >= bpp ? pxData[pxPos + x3 - bpp] : 0;
|
|
25644
|
+
let up = pxPos > 0 ? pxData[pxPos + x3 - byteWidth] : 0;
|
|
25645
|
+
let upleft = pxPos > 0 && x3 >= bpp ? pxData[pxPos + x3 - (byteWidth + bpp)] : 0;
|
|
25646
|
+
let val = pxData[pxPos + x3] - paethPredictor(left, up, upleft);
|
|
25647
|
+
rawData[rawPos + x3] = val;
|
|
25648
|
+
}
|
|
25649
|
+
}
|
|
25650
|
+
function filterSumPaeth(pxData, pxPos, byteWidth, bpp) {
|
|
25651
|
+
let sum = 0;
|
|
25652
|
+
for (let x3 = 0;x3 < byteWidth; x3++) {
|
|
25653
|
+
let left = x3 >= bpp ? pxData[pxPos + x3 - bpp] : 0;
|
|
25654
|
+
let up = pxPos > 0 ? pxData[pxPos + x3 - byteWidth] : 0;
|
|
25655
|
+
let upleft = pxPos > 0 && x3 >= bpp ? pxData[pxPos + x3 - (byteWidth + bpp)] : 0;
|
|
25656
|
+
let val = pxData[pxPos + x3] - paethPredictor(left, up, upleft);
|
|
25657
|
+
sum += Math.abs(val);
|
|
25658
|
+
}
|
|
25659
|
+
return sum;
|
|
25660
|
+
}
|
|
25661
|
+
var filters = {
|
|
25662
|
+
0: filterNone,
|
|
25663
|
+
1: filterSub,
|
|
25664
|
+
2: filterUp,
|
|
25665
|
+
3: filterAvg,
|
|
25666
|
+
4: filterPaeth
|
|
25667
|
+
};
|
|
25668
|
+
var filterSums = {
|
|
25669
|
+
0: filterSumNone,
|
|
25670
|
+
1: filterSumSub,
|
|
25671
|
+
2: filterSumUp,
|
|
25672
|
+
3: filterSumAvg,
|
|
25673
|
+
4: filterSumPaeth
|
|
25674
|
+
};
|
|
25675
|
+
module.exports = function(pxData, width, height, options, bpp) {
|
|
25676
|
+
let filterTypes;
|
|
25677
|
+
if (!("filterType" in options) || options.filterType === -1) {
|
|
25678
|
+
filterTypes = [0, 1, 2, 3, 4];
|
|
25679
|
+
} else if (typeof options.filterType === "number") {
|
|
25680
|
+
filterTypes = [options.filterType];
|
|
25681
|
+
} else {
|
|
25682
|
+
throw new Error("unrecognised filter types");
|
|
25683
|
+
}
|
|
25684
|
+
if (options.bitDepth === 16) {
|
|
25685
|
+
bpp *= 2;
|
|
25686
|
+
}
|
|
25687
|
+
let byteWidth = width * bpp;
|
|
25688
|
+
let rawPos = 0;
|
|
25689
|
+
let pxPos = 0;
|
|
25690
|
+
let rawData = Buffer.alloc((byteWidth + 1) * height);
|
|
25691
|
+
let sel = filterTypes[0];
|
|
25692
|
+
for (let y5 = 0;y5 < height; y5++) {
|
|
25693
|
+
if (filterTypes.length > 1) {
|
|
25694
|
+
let min = Infinity;
|
|
25695
|
+
for (let i3 = 0;i3 < filterTypes.length; i3++) {
|
|
25696
|
+
let sum = filterSums[filterTypes[i3]](pxData, pxPos, byteWidth, bpp);
|
|
25697
|
+
if (sum < min) {
|
|
25698
|
+
sel = filterTypes[i3];
|
|
25699
|
+
min = sum;
|
|
25700
|
+
}
|
|
25701
|
+
}
|
|
25702
|
+
}
|
|
25703
|
+
rawData[rawPos] = sel;
|
|
25704
|
+
rawPos++;
|
|
25705
|
+
filters[sel](pxData, pxPos, byteWidth, rawData, rawPos, bpp);
|
|
25706
|
+
rawPos += byteWidth;
|
|
25707
|
+
pxPos += byteWidth;
|
|
25708
|
+
}
|
|
25709
|
+
return rawData;
|
|
25710
|
+
};
|
|
25711
|
+
});
|
|
25712
|
+
|
|
25713
|
+
// node_modules/pngjs/lib/packer.js
|
|
25714
|
+
var require_packer = __commonJS((exports, module) => {
|
|
25715
|
+
var constants = require_constants();
|
|
25716
|
+
var CrcStream = require_crc();
|
|
25717
|
+
var bitPacker = require_bitpacker();
|
|
25718
|
+
var filter = require_filter_pack();
|
|
25719
|
+
var zlib = __require("zlib");
|
|
25720
|
+
var Packer = module.exports = function(options) {
|
|
25721
|
+
this._options = options;
|
|
25722
|
+
options.deflateChunkSize = options.deflateChunkSize || 32 * 1024;
|
|
25723
|
+
options.deflateLevel = options.deflateLevel != null ? options.deflateLevel : 9;
|
|
25724
|
+
options.deflateStrategy = options.deflateStrategy != null ? options.deflateStrategy : 3;
|
|
25725
|
+
options.inputHasAlpha = options.inputHasAlpha != null ? options.inputHasAlpha : true;
|
|
25726
|
+
options.deflateFactory = options.deflateFactory || zlib.createDeflate;
|
|
25727
|
+
options.bitDepth = options.bitDepth || 8;
|
|
25728
|
+
options.colorType = typeof options.colorType === "number" ? options.colorType : constants.COLORTYPE_COLOR_ALPHA;
|
|
25729
|
+
options.inputColorType = typeof options.inputColorType === "number" ? options.inputColorType : constants.COLORTYPE_COLOR_ALPHA;
|
|
25730
|
+
if ([
|
|
25731
|
+
constants.COLORTYPE_GRAYSCALE,
|
|
25732
|
+
constants.COLORTYPE_COLOR,
|
|
25733
|
+
constants.COLORTYPE_COLOR_ALPHA,
|
|
25734
|
+
constants.COLORTYPE_ALPHA
|
|
25735
|
+
].indexOf(options.colorType) === -1) {
|
|
25736
|
+
throw new Error("option color type:" + options.colorType + " is not supported at present");
|
|
25737
|
+
}
|
|
25738
|
+
if ([
|
|
25739
|
+
constants.COLORTYPE_GRAYSCALE,
|
|
25740
|
+
constants.COLORTYPE_COLOR,
|
|
25741
|
+
constants.COLORTYPE_COLOR_ALPHA,
|
|
25742
|
+
constants.COLORTYPE_ALPHA
|
|
25743
|
+
].indexOf(options.inputColorType) === -1) {
|
|
25744
|
+
throw new Error("option input color type:" + options.inputColorType + " is not supported at present");
|
|
25745
|
+
}
|
|
25746
|
+
if (options.bitDepth !== 8 && options.bitDepth !== 16) {
|
|
25747
|
+
throw new Error("option bit depth:" + options.bitDepth + " is not supported at present");
|
|
25748
|
+
}
|
|
25749
|
+
};
|
|
25750
|
+
Packer.prototype.getDeflateOptions = function() {
|
|
25751
|
+
return {
|
|
25752
|
+
chunkSize: this._options.deflateChunkSize,
|
|
25753
|
+
level: this._options.deflateLevel,
|
|
25754
|
+
strategy: this._options.deflateStrategy
|
|
25755
|
+
};
|
|
25756
|
+
};
|
|
25757
|
+
Packer.prototype.createDeflate = function() {
|
|
25758
|
+
return this._options.deflateFactory(this.getDeflateOptions());
|
|
25759
|
+
};
|
|
25760
|
+
Packer.prototype.filterData = function(data, width, height) {
|
|
25761
|
+
let packedData = bitPacker(data, width, height, this._options);
|
|
25762
|
+
let bpp = constants.COLORTYPE_TO_BPP_MAP[this._options.colorType];
|
|
25763
|
+
let filteredData = filter(packedData, width, height, this._options, bpp);
|
|
25764
|
+
return filteredData;
|
|
25765
|
+
};
|
|
25766
|
+
Packer.prototype._packChunk = function(type, data) {
|
|
25767
|
+
let len = data ? data.length : 0;
|
|
25768
|
+
let buf = Buffer.alloc(len + 12);
|
|
25769
|
+
buf.writeUInt32BE(len, 0);
|
|
25770
|
+
buf.writeUInt32BE(type, 4);
|
|
25771
|
+
if (data) {
|
|
25772
|
+
data.copy(buf, 8);
|
|
25773
|
+
}
|
|
25774
|
+
buf.writeInt32BE(CrcStream.crc32(buf.slice(4, buf.length - 4)), buf.length - 4);
|
|
25775
|
+
return buf;
|
|
25776
|
+
};
|
|
25777
|
+
Packer.prototype.packGAMA = function(gamma4) {
|
|
25778
|
+
let buf = Buffer.alloc(4);
|
|
25779
|
+
buf.writeUInt32BE(Math.floor(gamma4 * constants.GAMMA_DIVISION), 0);
|
|
25780
|
+
return this._packChunk(constants.TYPE_gAMA, buf);
|
|
25781
|
+
};
|
|
25782
|
+
Packer.prototype.packIHDR = function(width, height) {
|
|
25783
|
+
let buf = Buffer.alloc(13);
|
|
25784
|
+
buf.writeUInt32BE(width, 0);
|
|
25785
|
+
buf.writeUInt32BE(height, 4);
|
|
25786
|
+
buf[8] = this._options.bitDepth;
|
|
25787
|
+
buf[9] = this._options.colorType;
|
|
25788
|
+
buf[10] = 0;
|
|
25789
|
+
buf[11] = 0;
|
|
25790
|
+
buf[12] = 0;
|
|
25791
|
+
return this._packChunk(constants.TYPE_IHDR, buf);
|
|
25792
|
+
};
|
|
25793
|
+
Packer.prototype.packIDAT = function(data) {
|
|
25794
|
+
return this._packChunk(constants.TYPE_IDAT, data);
|
|
25795
|
+
};
|
|
25796
|
+
Packer.prototype.packIEND = function() {
|
|
25797
|
+
return this._packChunk(constants.TYPE_IEND, null);
|
|
25798
|
+
};
|
|
25799
|
+
});
|
|
25800
|
+
|
|
25801
|
+
// node_modules/pngjs/lib/packer-async.js
|
|
25802
|
+
var require_packer_async = __commonJS((exports, module) => {
|
|
25803
|
+
var util = __require("util");
|
|
25804
|
+
var Stream = __require("stream");
|
|
25805
|
+
var constants = require_constants();
|
|
25806
|
+
var Packer = require_packer();
|
|
25807
|
+
var PackerAsync = module.exports = function(opt) {
|
|
25808
|
+
Stream.call(this);
|
|
25809
|
+
let options = opt || {};
|
|
25810
|
+
this._packer = new Packer(options);
|
|
25811
|
+
this._deflate = this._packer.createDeflate();
|
|
25812
|
+
this.readable = true;
|
|
25813
|
+
};
|
|
25814
|
+
util.inherits(PackerAsync, Stream);
|
|
25815
|
+
PackerAsync.prototype.pack = function(data, width, height, gamma4) {
|
|
25816
|
+
this.emit("data", Buffer.from(constants.PNG_SIGNATURE));
|
|
25817
|
+
this.emit("data", this._packer.packIHDR(width, height));
|
|
25818
|
+
if (gamma4) {
|
|
25819
|
+
this.emit("data", this._packer.packGAMA(gamma4));
|
|
25820
|
+
}
|
|
25821
|
+
let filteredData = this._packer.filterData(data, width, height);
|
|
25822
|
+
this._deflate.on("error", this.emit.bind(this, "error"));
|
|
25823
|
+
this._deflate.on("data", function(compressedData) {
|
|
25824
|
+
this.emit("data", this._packer.packIDAT(compressedData));
|
|
25825
|
+
}.bind(this));
|
|
25826
|
+
this._deflate.on("end", function() {
|
|
25827
|
+
this.emit("data", this._packer.packIEND());
|
|
25828
|
+
this.emit("end");
|
|
25829
|
+
}.bind(this));
|
|
25830
|
+
this._deflate.end(filteredData);
|
|
25831
|
+
};
|
|
25832
|
+
});
|
|
25833
|
+
|
|
25834
|
+
// node_modules/pngjs/lib/sync-inflate.js
|
|
25835
|
+
var require_sync_inflate = __commonJS((exports, module) => {
|
|
25836
|
+
var assert = __require("assert").ok;
|
|
25837
|
+
var zlib = __require("zlib");
|
|
25838
|
+
var util = __require("util");
|
|
25839
|
+
var kMaxLength = __require("buffer").kMaxLength;
|
|
25840
|
+
function Inflate(opts) {
|
|
25841
|
+
if (!(this instanceof Inflate)) {
|
|
25842
|
+
return new Inflate(opts);
|
|
25843
|
+
}
|
|
25844
|
+
if (opts && opts.chunkSize < zlib.Z_MIN_CHUNK) {
|
|
25845
|
+
opts.chunkSize = zlib.Z_MIN_CHUNK;
|
|
25846
|
+
}
|
|
25847
|
+
zlib.Inflate.call(this, opts);
|
|
25848
|
+
this._offset = this._offset === undefined ? this._outOffset : this._offset;
|
|
25849
|
+
this._buffer = this._buffer || this._outBuffer;
|
|
25850
|
+
if (opts && opts.maxLength != null) {
|
|
25851
|
+
this._maxLength = opts.maxLength;
|
|
25852
|
+
}
|
|
25853
|
+
}
|
|
25854
|
+
function createInflate(opts) {
|
|
25855
|
+
return new Inflate(opts);
|
|
25856
|
+
}
|
|
25857
|
+
function _close(engine, callback) {
|
|
25858
|
+
if (callback) {
|
|
25859
|
+
process.nextTick(callback);
|
|
25860
|
+
}
|
|
25861
|
+
if (!engine._handle) {
|
|
25862
|
+
return;
|
|
25863
|
+
}
|
|
25864
|
+
engine._handle.close();
|
|
25865
|
+
engine._handle = null;
|
|
25866
|
+
}
|
|
25867
|
+
Inflate.prototype._processChunk = function(chunk, flushFlag, asyncCb) {
|
|
25868
|
+
if (typeof asyncCb === "function") {
|
|
25869
|
+
return zlib.Inflate._processChunk.call(this, chunk, flushFlag, asyncCb);
|
|
25870
|
+
}
|
|
25871
|
+
let self = this;
|
|
25872
|
+
let availInBefore = chunk && chunk.length;
|
|
25873
|
+
let availOutBefore = this._chunkSize - this._offset;
|
|
25874
|
+
let leftToInflate = this._maxLength;
|
|
25875
|
+
let inOff = 0;
|
|
25876
|
+
let buffers = [];
|
|
25877
|
+
let nread = 0;
|
|
25878
|
+
let error;
|
|
25879
|
+
this.on("error", function(err) {
|
|
25880
|
+
error = err;
|
|
25881
|
+
});
|
|
25882
|
+
function handleChunk(availInAfter, availOutAfter) {
|
|
25883
|
+
if (self._hadError) {
|
|
25884
|
+
return;
|
|
25885
|
+
}
|
|
25886
|
+
let have = availOutBefore - availOutAfter;
|
|
25887
|
+
assert(have >= 0, "have should not go down");
|
|
25888
|
+
if (have > 0) {
|
|
25889
|
+
let out = self._buffer.slice(self._offset, self._offset + have);
|
|
25890
|
+
self._offset += have;
|
|
25891
|
+
if (out.length > leftToInflate) {
|
|
25892
|
+
out = out.slice(0, leftToInflate);
|
|
25893
|
+
}
|
|
25894
|
+
buffers.push(out);
|
|
25895
|
+
nread += out.length;
|
|
25896
|
+
leftToInflate -= out.length;
|
|
25897
|
+
if (leftToInflate === 0) {
|
|
25898
|
+
return false;
|
|
25899
|
+
}
|
|
25900
|
+
}
|
|
25901
|
+
if (availOutAfter === 0 || self._offset >= self._chunkSize) {
|
|
25902
|
+
availOutBefore = self._chunkSize;
|
|
25903
|
+
self._offset = 0;
|
|
25904
|
+
self._buffer = Buffer.allocUnsafe(self._chunkSize);
|
|
25905
|
+
}
|
|
25906
|
+
if (availOutAfter === 0) {
|
|
25907
|
+
inOff += availInBefore - availInAfter;
|
|
25908
|
+
availInBefore = availInAfter;
|
|
25909
|
+
return true;
|
|
25910
|
+
}
|
|
25911
|
+
return false;
|
|
25912
|
+
}
|
|
25913
|
+
assert(this._handle, "zlib binding closed");
|
|
25914
|
+
let res;
|
|
25915
|
+
do {
|
|
25916
|
+
res = this._handle.writeSync(flushFlag, chunk, inOff, availInBefore, this._buffer, this._offset, availOutBefore);
|
|
25917
|
+
res = res || this._writeState;
|
|
25918
|
+
} while (!this._hadError && handleChunk(res[0], res[1]));
|
|
25919
|
+
if (this._hadError) {
|
|
25920
|
+
throw error;
|
|
25921
|
+
}
|
|
25922
|
+
if (nread >= kMaxLength) {
|
|
25923
|
+
_close(this);
|
|
25924
|
+
throw new RangeError("Cannot create final Buffer. It would be larger than 0x" + kMaxLength.toString(16) + " bytes");
|
|
25925
|
+
}
|
|
25926
|
+
let buf = Buffer.concat(buffers, nread);
|
|
25927
|
+
_close(this);
|
|
25928
|
+
return buf;
|
|
25929
|
+
};
|
|
25930
|
+
util.inherits(Inflate, zlib.Inflate);
|
|
25931
|
+
function zlibBufferSync(engine, buffer) {
|
|
25932
|
+
if (typeof buffer === "string") {
|
|
25933
|
+
buffer = Buffer.from(buffer);
|
|
25934
|
+
}
|
|
25935
|
+
if (!(buffer instanceof Buffer)) {
|
|
25936
|
+
throw new TypeError("Not a string or buffer");
|
|
25937
|
+
}
|
|
25938
|
+
let flushFlag = engine._finishFlushFlag;
|
|
25939
|
+
if (flushFlag == null) {
|
|
25940
|
+
flushFlag = zlib.Z_FINISH;
|
|
25941
|
+
}
|
|
25942
|
+
return engine._processChunk(buffer, flushFlag);
|
|
25943
|
+
}
|
|
25944
|
+
function inflateSync(buffer, opts) {
|
|
25945
|
+
return zlibBufferSync(new Inflate(opts), buffer);
|
|
25946
|
+
}
|
|
25947
|
+
module.exports = exports = inflateSync;
|
|
25948
|
+
exports.Inflate = Inflate;
|
|
25949
|
+
exports.createInflate = createInflate;
|
|
25950
|
+
exports.inflateSync = inflateSync;
|
|
25951
|
+
});
|
|
25952
|
+
|
|
25953
|
+
// node_modules/pngjs/lib/sync-reader.js
|
|
25954
|
+
var require_sync_reader = __commonJS((exports, module) => {
|
|
25955
|
+
var SyncReader = module.exports = function(buffer) {
|
|
25956
|
+
this._buffer = buffer;
|
|
25957
|
+
this._reads = [];
|
|
25958
|
+
};
|
|
25959
|
+
SyncReader.prototype.read = function(length, callback) {
|
|
25960
|
+
this._reads.push({
|
|
25961
|
+
length: Math.abs(length),
|
|
25962
|
+
allowLess: length < 0,
|
|
25963
|
+
func: callback
|
|
25964
|
+
});
|
|
25965
|
+
};
|
|
25966
|
+
SyncReader.prototype.process = function() {
|
|
25967
|
+
while (this._reads.length > 0 && this._buffer.length) {
|
|
25968
|
+
let read = this._reads[0];
|
|
25969
|
+
if (this._buffer.length && (this._buffer.length >= read.length || read.allowLess)) {
|
|
25970
|
+
this._reads.shift();
|
|
25971
|
+
let buf = this._buffer;
|
|
25972
|
+
this._buffer = buf.slice(read.length);
|
|
25973
|
+
read.func.call(this, buf.slice(0, read.length));
|
|
25974
|
+
} else {
|
|
25975
|
+
break;
|
|
25976
|
+
}
|
|
25977
|
+
}
|
|
25978
|
+
if (this._reads.length > 0) {
|
|
25979
|
+
throw new Error("There are some read requests waitng on finished stream");
|
|
25980
|
+
}
|
|
25981
|
+
if (this._buffer.length > 0) {
|
|
25982
|
+
throw new Error("unrecognised content at end of stream");
|
|
25983
|
+
}
|
|
25984
|
+
};
|
|
25985
|
+
});
|
|
25986
|
+
|
|
25987
|
+
// node_modules/pngjs/lib/filter-parse-sync.js
|
|
25988
|
+
var require_filter_parse_sync = __commonJS((exports) => {
|
|
25989
|
+
var SyncReader = require_sync_reader();
|
|
25990
|
+
var Filter = require_filter_parse();
|
|
25991
|
+
exports.process = function(inBuffer, bitmapInfo) {
|
|
25992
|
+
let outBuffers = [];
|
|
25993
|
+
let reader = new SyncReader(inBuffer);
|
|
25994
|
+
let filter = new Filter(bitmapInfo, {
|
|
25995
|
+
read: reader.read.bind(reader),
|
|
25996
|
+
write: function(bufferPart) {
|
|
25997
|
+
outBuffers.push(bufferPart);
|
|
25998
|
+
},
|
|
25999
|
+
complete: function() {}
|
|
26000
|
+
});
|
|
26001
|
+
filter.start();
|
|
26002
|
+
reader.process();
|
|
26003
|
+
return Buffer.concat(outBuffers);
|
|
26004
|
+
};
|
|
26005
|
+
});
|
|
26006
|
+
|
|
26007
|
+
// node_modules/pngjs/lib/parser-sync.js
|
|
26008
|
+
var require_parser_sync = __commonJS((exports, module) => {
|
|
26009
|
+
var hasSyncZlib = true;
|
|
26010
|
+
var zlib = __require("zlib");
|
|
26011
|
+
var inflateSync = require_sync_inflate();
|
|
26012
|
+
if (!zlib.deflateSync) {
|
|
26013
|
+
hasSyncZlib = false;
|
|
26014
|
+
}
|
|
26015
|
+
var SyncReader = require_sync_reader();
|
|
26016
|
+
var FilterSync = require_filter_parse_sync();
|
|
26017
|
+
var Parser = require_parser();
|
|
26018
|
+
var bitmapper = require_bitmapper();
|
|
26019
|
+
var formatNormaliser = require_format_normaliser();
|
|
26020
|
+
module.exports = function(buffer, options) {
|
|
26021
|
+
if (!hasSyncZlib) {
|
|
26022
|
+
throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");
|
|
26023
|
+
}
|
|
26024
|
+
let err;
|
|
26025
|
+
function handleError2(_err_) {
|
|
26026
|
+
err = _err_;
|
|
26027
|
+
}
|
|
26028
|
+
let metaData;
|
|
26029
|
+
function handleMetaData(_metaData_) {
|
|
26030
|
+
metaData = _metaData_;
|
|
26031
|
+
}
|
|
26032
|
+
function handleTransColor(transColor) {
|
|
26033
|
+
metaData.transColor = transColor;
|
|
26034
|
+
}
|
|
26035
|
+
function handlePalette(palette) {
|
|
26036
|
+
metaData.palette = palette;
|
|
26037
|
+
}
|
|
26038
|
+
function handleSimpleTransparency() {
|
|
26039
|
+
metaData.alpha = true;
|
|
26040
|
+
}
|
|
26041
|
+
let gamma4;
|
|
26042
|
+
function handleGamma(_gamma_) {
|
|
26043
|
+
gamma4 = _gamma_;
|
|
26044
|
+
}
|
|
26045
|
+
let inflateDataList = [];
|
|
26046
|
+
function handleInflateData(inflatedData2) {
|
|
26047
|
+
inflateDataList.push(inflatedData2);
|
|
26048
|
+
}
|
|
26049
|
+
let reader = new SyncReader(buffer);
|
|
26050
|
+
let parser = new Parser(options, {
|
|
26051
|
+
read: reader.read.bind(reader),
|
|
26052
|
+
error: handleError2,
|
|
26053
|
+
metadata: handleMetaData,
|
|
26054
|
+
gamma: handleGamma,
|
|
26055
|
+
palette: handlePalette,
|
|
26056
|
+
transColor: handleTransColor,
|
|
26057
|
+
inflateData: handleInflateData,
|
|
26058
|
+
simpleTransparency: handleSimpleTransparency
|
|
26059
|
+
});
|
|
26060
|
+
parser.start();
|
|
26061
|
+
reader.process();
|
|
26062
|
+
if (err) {
|
|
26063
|
+
throw err;
|
|
26064
|
+
}
|
|
26065
|
+
let inflateData = Buffer.concat(inflateDataList);
|
|
26066
|
+
inflateDataList.length = 0;
|
|
26067
|
+
let inflatedData;
|
|
26068
|
+
if (metaData.interlace) {
|
|
26069
|
+
inflatedData = zlib.inflateSync(inflateData);
|
|
26070
|
+
} else {
|
|
26071
|
+
let rowSize = (metaData.width * metaData.bpp * metaData.depth + 7 >> 3) + 1;
|
|
26072
|
+
let imageSize = rowSize * metaData.height;
|
|
26073
|
+
inflatedData = inflateSync(inflateData, {
|
|
26074
|
+
chunkSize: imageSize,
|
|
26075
|
+
maxLength: imageSize
|
|
26076
|
+
});
|
|
26077
|
+
}
|
|
26078
|
+
inflateData = null;
|
|
26079
|
+
if (!inflatedData || !inflatedData.length) {
|
|
26080
|
+
throw new Error("bad png - invalid inflate data response");
|
|
26081
|
+
}
|
|
26082
|
+
let unfilteredData = FilterSync.process(inflatedData, metaData);
|
|
26083
|
+
inflateData = null;
|
|
26084
|
+
let bitmapData = bitmapper.dataToBitMap(unfilteredData, metaData);
|
|
26085
|
+
unfilteredData = null;
|
|
26086
|
+
let normalisedBitmapData = formatNormaliser(bitmapData, metaData, options.skipRescale);
|
|
26087
|
+
metaData.data = normalisedBitmapData;
|
|
26088
|
+
metaData.gamma = gamma4 || 0;
|
|
26089
|
+
return metaData;
|
|
26090
|
+
};
|
|
26091
|
+
});
|
|
26092
|
+
|
|
26093
|
+
// node_modules/pngjs/lib/packer-sync.js
|
|
26094
|
+
var require_packer_sync = __commonJS((exports, module) => {
|
|
26095
|
+
var hasSyncZlib = true;
|
|
26096
|
+
var zlib = __require("zlib");
|
|
26097
|
+
if (!zlib.deflateSync) {
|
|
26098
|
+
hasSyncZlib = false;
|
|
26099
|
+
}
|
|
26100
|
+
var constants = require_constants();
|
|
26101
|
+
var Packer = require_packer();
|
|
26102
|
+
module.exports = function(metaData, opt) {
|
|
26103
|
+
if (!hasSyncZlib) {
|
|
26104
|
+
throw new Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");
|
|
26105
|
+
}
|
|
26106
|
+
let options = opt || {};
|
|
26107
|
+
let packer = new Packer(options);
|
|
26108
|
+
let chunks = [];
|
|
26109
|
+
chunks.push(Buffer.from(constants.PNG_SIGNATURE));
|
|
26110
|
+
chunks.push(packer.packIHDR(metaData.width, metaData.height));
|
|
26111
|
+
if (metaData.gamma) {
|
|
26112
|
+
chunks.push(packer.packGAMA(metaData.gamma));
|
|
26113
|
+
}
|
|
26114
|
+
let filteredData = packer.filterData(metaData.data, metaData.width, metaData.height);
|
|
26115
|
+
let compressedData = zlib.deflateSync(filteredData, packer.getDeflateOptions());
|
|
26116
|
+
filteredData = null;
|
|
26117
|
+
if (!compressedData || !compressedData.length) {
|
|
26118
|
+
throw new Error("bad png - invalid compressed data response");
|
|
26119
|
+
}
|
|
26120
|
+
chunks.push(packer.packIDAT(compressedData));
|
|
26121
|
+
chunks.push(packer.packIEND());
|
|
26122
|
+
return Buffer.concat(chunks);
|
|
26123
|
+
};
|
|
26124
|
+
});
|
|
26125
|
+
|
|
26126
|
+
// node_modules/pngjs/lib/png-sync.js
|
|
26127
|
+
var require_png_sync = __commonJS((exports) => {
|
|
26128
|
+
var parse2 = require_parser_sync();
|
|
26129
|
+
var pack = require_packer_sync();
|
|
26130
|
+
exports.read = function(buffer, options) {
|
|
26131
|
+
return parse2(buffer, options || {});
|
|
26132
|
+
};
|
|
26133
|
+
exports.write = function(png, options) {
|
|
26134
|
+
return pack(png, options);
|
|
26135
|
+
};
|
|
26136
|
+
});
|
|
26137
|
+
|
|
26138
|
+
// node_modules/pngjs/lib/png.js
|
|
26139
|
+
var require_png = __commonJS((exports) => {
|
|
26140
|
+
var util = __require("util");
|
|
26141
|
+
var Stream = __require("stream");
|
|
26142
|
+
var Parser = require_parser_async();
|
|
26143
|
+
var Packer = require_packer_async();
|
|
26144
|
+
var PNGSync = require_png_sync();
|
|
26145
|
+
var PNG = exports.PNG = function(options) {
|
|
26146
|
+
Stream.call(this);
|
|
26147
|
+
options = options || {};
|
|
26148
|
+
this.width = options.width | 0;
|
|
26149
|
+
this.height = options.height | 0;
|
|
26150
|
+
this.data = this.width > 0 && this.height > 0 ? Buffer.alloc(4 * this.width * this.height) : null;
|
|
26151
|
+
if (options.fill && this.data) {
|
|
26152
|
+
this.data.fill(0);
|
|
26153
|
+
}
|
|
26154
|
+
this.gamma = 0;
|
|
26155
|
+
this.readable = this.writable = true;
|
|
26156
|
+
this._parser = new Parser(options);
|
|
26157
|
+
this._parser.on("error", this.emit.bind(this, "error"));
|
|
26158
|
+
this._parser.on("close", this._handleClose.bind(this));
|
|
26159
|
+
this._parser.on("metadata", this._metadata.bind(this));
|
|
26160
|
+
this._parser.on("gamma", this._gamma.bind(this));
|
|
26161
|
+
this._parser.on("parsed", function(data) {
|
|
26162
|
+
this.data = data;
|
|
26163
|
+
this.emit("parsed", data);
|
|
26164
|
+
}.bind(this));
|
|
26165
|
+
this._packer = new Packer(options);
|
|
26166
|
+
this._packer.on("data", this.emit.bind(this, "data"));
|
|
26167
|
+
this._packer.on("end", this.emit.bind(this, "end"));
|
|
26168
|
+
this._parser.on("close", this._handleClose.bind(this));
|
|
26169
|
+
this._packer.on("error", this.emit.bind(this, "error"));
|
|
26170
|
+
};
|
|
26171
|
+
util.inherits(PNG, Stream);
|
|
26172
|
+
PNG.sync = PNGSync;
|
|
26173
|
+
PNG.prototype.pack = function() {
|
|
26174
|
+
if (!this.data || !this.data.length) {
|
|
26175
|
+
this.emit("error", "No data provided");
|
|
26176
|
+
return this;
|
|
26177
|
+
}
|
|
26178
|
+
process.nextTick(function() {
|
|
26179
|
+
this._packer.pack(this.data, this.width, this.height, this.gamma);
|
|
26180
|
+
}.bind(this));
|
|
26181
|
+
return this;
|
|
26182
|
+
};
|
|
26183
|
+
PNG.prototype.parse = function(data, callback) {
|
|
26184
|
+
if (callback) {
|
|
26185
|
+
let onParsed, onError;
|
|
26186
|
+
onParsed = function(parsedData) {
|
|
26187
|
+
this.removeListener("error", onError);
|
|
26188
|
+
this.data = parsedData;
|
|
26189
|
+
callback(null, this);
|
|
26190
|
+
}.bind(this);
|
|
26191
|
+
onError = function(err) {
|
|
26192
|
+
this.removeListener("parsed", onParsed);
|
|
26193
|
+
callback(err, null);
|
|
26194
|
+
}.bind(this);
|
|
26195
|
+
this.once("parsed", onParsed);
|
|
26196
|
+
this.once("error", onError);
|
|
26197
|
+
}
|
|
26198
|
+
this.end(data);
|
|
26199
|
+
return this;
|
|
26200
|
+
};
|
|
26201
|
+
PNG.prototype.write = function(data) {
|
|
26202
|
+
this._parser.write(data);
|
|
26203
|
+
return true;
|
|
26204
|
+
};
|
|
26205
|
+
PNG.prototype.end = function(data) {
|
|
26206
|
+
this._parser.end(data);
|
|
26207
|
+
};
|
|
26208
|
+
PNG.prototype._metadata = function(metadata) {
|
|
26209
|
+
this.width = metadata.width;
|
|
26210
|
+
this.height = metadata.height;
|
|
26211
|
+
this.emit("metadata", metadata);
|
|
26212
|
+
};
|
|
26213
|
+
PNG.prototype._gamma = function(gamma4) {
|
|
26214
|
+
this.gamma = gamma4;
|
|
26215
|
+
};
|
|
26216
|
+
PNG.prototype._handleClose = function() {
|
|
26217
|
+
if (!this._parser.writable && !this._packer.readable) {
|
|
26218
|
+
this.emit("close");
|
|
26219
|
+
}
|
|
26220
|
+
};
|
|
26221
|
+
PNG.bitblt = function(src3, dst, srcX, srcY, width, height, deltaX, deltaY) {
|
|
26222
|
+
srcX |= 0;
|
|
26223
|
+
srcY |= 0;
|
|
26224
|
+
width |= 0;
|
|
26225
|
+
height |= 0;
|
|
26226
|
+
deltaX |= 0;
|
|
26227
|
+
deltaY |= 0;
|
|
26228
|
+
if (srcX > src3.width || srcY > src3.height || srcX + width > src3.width || srcY + height > src3.height) {
|
|
26229
|
+
throw new Error("bitblt reading outside image");
|
|
26230
|
+
}
|
|
26231
|
+
if (deltaX > dst.width || deltaY > dst.height || deltaX + width > dst.width || deltaY + height > dst.height) {
|
|
26232
|
+
throw new Error("bitblt writing outside image");
|
|
26233
|
+
}
|
|
26234
|
+
for (let y5 = 0;y5 < height; y5++) {
|
|
26235
|
+
src3.data.copy(dst.data, (deltaY + y5) * dst.width + deltaX << 2, (srcY + y5) * src3.width + srcX << 2, (srcY + y5) * src3.width + srcX + width << 2);
|
|
26236
|
+
}
|
|
26237
|
+
};
|
|
26238
|
+
PNG.prototype.bitblt = function(dst, srcX, srcY, width, height, deltaX, deltaY) {
|
|
26239
|
+
PNG.bitblt(this, dst, srcX, srcY, width, height, deltaX, deltaY);
|
|
26240
|
+
return this;
|
|
26241
|
+
};
|
|
26242
|
+
PNG.adjustGamma = function(src3) {
|
|
26243
|
+
if (src3.gamma) {
|
|
26244
|
+
for (let y5 = 0;y5 < src3.height; y5++) {
|
|
26245
|
+
for (let x3 = 0;x3 < src3.width; x3++) {
|
|
26246
|
+
let idx = src3.width * y5 + x3 << 2;
|
|
26247
|
+
for (let i3 = 0;i3 < 3; i3++) {
|
|
26248
|
+
let sample = src3.data[idx + i3] / 255;
|
|
26249
|
+
sample = Math.pow(sample, 1 / 2.2 / src3.gamma);
|
|
26250
|
+
src3.data[idx + i3] = Math.round(sample * 255);
|
|
26251
|
+
}
|
|
26252
|
+
}
|
|
26253
|
+
}
|
|
26254
|
+
src3.gamma = 0;
|
|
26255
|
+
}
|
|
26256
|
+
};
|
|
26257
|
+
PNG.prototype.adjustGamma = function() {
|
|
26258
|
+
PNG.adjustGamma(this);
|
|
26259
|
+
};
|
|
26260
|
+
});
|
|
26261
|
+
|
|
26262
|
+
// node_modules/pixelmatch/index.js
|
|
26263
|
+
function pixelmatch(img1, img2, output, width, height, options = {}) {
|
|
26264
|
+
const {
|
|
26265
|
+
threshold = 0.1,
|
|
26266
|
+
alpha = 0.1,
|
|
26267
|
+
aaColor = [255, 255, 0],
|
|
26268
|
+
diffColor = [255, 0, 0],
|
|
26269
|
+
includeAA,
|
|
26270
|
+
diffColorAlt,
|
|
26271
|
+
diffMask
|
|
26272
|
+
} = options;
|
|
26273
|
+
if (!isPixelData(img1) || !isPixelData(img2) || output && !isPixelData(output))
|
|
26274
|
+
throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");
|
|
26275
|
+
if (img1.length !== img2.length || output && output.length !== img1.length)
|
|
26276
|
+
throw new Error("Image sizes do not match.");
|
|
26277
|
+
if (img1.length !== width * height * 4)
|
|
26278
|
+
throw new Error("Image data size does not match width/height.");
|
|
26279
|
+
const len = width * height;
|
|
26280
|
+
const a32 = new Uint32Array(img1.buffer, img1.byteOffset, len);
|
|
26281
|
+
const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len);
|
|
26282
|
+
let identical = true;
|
|
26283
|
+
for (let i3 = 0;i3 < len; i3++) {
|
|
26284
|
+
if (a32[i3] !== b32[i3]) {
|
|
26285
|
+
identical = false;
|
|
26286
|
+
break;
|
|
26287
|
+
}
|
|
26288
|
+
}
|
|
26289
|
+
if (identical) {
|
|
26290
|
+
if (output && !diffMask) {
|
|
26291
|
+
for (let i3 = 0;i3 < len; i3++)
|
|
26292
|
+
drawGrayPixel(img1, 4 * i3, alpha, output);
|
|
26293
|
+
}
|
|
26294
|
+
return 0;
|
|
26295
|
+
}
|
|
26296
|
+
const maxDelta = 35215 * threshold * threshold;
|
|
26297
|
+
const [aaR, aaG, aaB] = aaColor;
|
|
26298
|
+
const [diffR, diffG, diffB] = diffColor;
|
|
26299
|
+
const [altR, altG, altB] = diffColorAlt || diffColor;
|
|
26300
|
+
let diff = 0;
|
|
26301
|
+
for (let y5 = 0;y5 < height; y5++) {
|
|
26302
|
+
for (let x3 = 0;x3 < width; x3++) {
|
|
26303
|
+
const i3 = y5 * width + x3;
|
|
26304
|
+
const pos = i3 * 4;
|
|
26305
|
+
const delta = a32[i3] === b32[i3] ? 0 : colorDelta(img1, img2, pos, pos, false);
|
|
26306
|
+
if (Math.abs(delta) > maxDelta) {
|
|
26307
|
+
const isAA = antialiased(img1, x3, y5, width, height, a32, b32) || antialiased(img2, x3, y5, width, height, b32, a32);
|
|
26308
|
+
if (!includeAA && isAA) {
|
|
26309
|
+
if (output && !diffMask)
|
|
26310
|
+
drawPixel(output, pos, aaR, aaG, aaB);
|
|
26311
|
+
} else {
|
|
26312
|
+
if (output) {
|
|
26313
|
+
if (delta < 0) {
|
|
26314
|
+
drawPixel(output, pos, altR, altG, altB);
|
|
26315
|
+
} else {
|
|
26316
|
+
drawPixel(output, pos, diffR, diffG, diffB);
|
|
26317
|
+
}
|
|
26318
|
+
}
|
|
26319
|
+
diff++;
|
|
26320
|
+
}
|
|
26321
|
+
} else if (output && !diffMask) {
|
|
26322
|
+
drawGrayPixel(img1, pos, alpha, output);
|
|
26323
|
+
}
|
|
26324
|
+
}
|
|
26325
|
+
}
|
|
26326
|
+
return diff;
|
|
26327
|
+
}
|
|
26328
|
+
function isPixelData(arr) {
|
|
26329
|
+
return ArrayBuffer.isView(arr) && arr.BYTES_PER_ELEMENT === 1;
|
|
26330
|
+
}
|
|
26331
|
+
function antialiased(img, x1, y1, width, height, a32, b32) {
|
|
26332
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
26333
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
26334
|
+
const x22 = Math.min(x1 + 1, width - 1);
|
|
26335
|
+
const y22 = Math.min(y1 + 1, height - 1);
|
|
26336
|
+
const pos = y1 * width + x1;
|
|
26337
|
+
let zeroes = x1 === x0 || x1 === x22 || y1 === y0 || y1 === y22 ? 1 : 0;
|
|
26338
|
+
let min = 0;
|
|
26339
|
+
let max = 0;
|
|
26340
|
+
let minX = 0;
|
|
26341
|
+
let minY = 0;
|
|
26342
|
+
let maxX = 0;
|
|
26343
|
+
let maxY = 0;
|
|
26344
|
+
for (let x3 = x0;x3 <= x22; x3++) {
|
|
26345
|
+
for (let y5 = y0;y5 <= y22; y5++) {
|
|
26346
|
+
if (x3 === x1 && y5 === y1)
|
|
26347
|
+
continue;
|
|
26348
|
+
const delta = colorDelta(img, img, pos * 4, (y5 * width + x3) * 4, true);
|
|
26349
|
+
if (delta === 0) {
|
|
26350
|
+
zeroes++;
|
|
26351
|
+
if (zeroes > 2)
|
|
26352
|
+
return false;
|
|
26353
|
+
} else if (delta < min) {
|
|
26354
|
+
min = delta;
|
|
26355
|
+
minX = x3;
|
|
26356
|
+
minY = y5;
|
|
26357
|
+
} else if (delta > max) {
|
|
26358
|
+
max = delta;
|
|
26359
|
+
maxX = x3;
|
|
26360
|
+
maxY = y5;
|
|
26361
|
+
}
|
|
26362
|
+
}
|
|
26363
|
+
}
|
|
26364
|
+
if (min === 0 || max === 0)
|
|
26365
|
+
return false;
|
|
26366
|
+
return hasManySiblings(a32, minX, minY, width, height) && hasManySiblings(b32, minX, minY, width, height) || hasManySiblings(a32, maxX, maxY, width, height) && hasManySiblings(b32, maxX, maxY, width, height);
|
|
26367
|
+
}
|
|
26368
|
+
function hasManySiblings(img, x1, y1, width, height) {
|
|
26369
|
+
const x0 = Math.max(x1 - 1, 0);
|
|
26370
|
+
const y0 = Math.max(y1 - 1, 0);
|
|
26371
|
+
const x22 = Math.min(x1 + 1, width - 1);
|
|
26372
|
+
const y22 = Math.min(y1 + 1, height - 1);
|
|
26373
|
+
const val = img[y1 * width + x1];
|
|
26374
|
+
let zeroes = x1 === x0 || x1 === x22 || y1 === y0 || y1 === y22 ? 1 : 0;
|
|
26375
|
+
for (let x3 = x0;x3 <= x22; x3++) {
|
|
26376
|
+
for (let y5 = y0;y5 <= y22; y5++) {
|
|
26377
|
+
if (x3 === x1 && y5 === y1)
|
|
26378
|
+
continue;
|
|
26379
|
+
zeroes += +(val === img[y5 * width + x3]);
|
|
26380
|
+
if (zeroes > 2)
|
|
26381
|
+
return true;
|
|
26382
|
+
}
|
|
26383
|
+
}
|
|
26384
|
+
return false;
|
|
26385
|
+
}
|
|
26386
|
+
function colorDelta(img1, img2, k6, m3, yOnly) {
|
|
26387
|
+
const r1 = img1[k6];
|
|
26388
|
+
const g1 = img1[k6 + 1];
|
|
26389
|
+
const b1 = img1[k6 + 2];
|
|
26390
|
+
const a1 = img1[k6 + 3];
|
|
26391
|
+
const r22 = img2[m3];
|
|
26392
|
+
const g22 = img2[m3 + 1];
|
|
26393
|
+
const b22 = img2[m3 + 2];
|
|
26394
|
+
const a22 = img2[m3 + 3];
|
|
26395
|
+
let dr = r1 - r22;
|
|
26396
|
+
let dg = g1 - g22;
|
|
26397
|
+
let db = b1 - b22;
|
|
26398
|
+
const da = a1 - a22;
|
|
26399
|
+
if (!dr && !dg && !db && !da)
|
|
26400
|
+
return 0;
|
|
26401
|
+
if (a1 < 255 || a22 < 255) {
|
|
26402
|
+
const rb = 48 + 159 * (k6 % 2);
|
|
26403
|
+
const gb = 48 + 159 * ((k6 / 1.618033988749895 | 0) % 2);
|
|
26404
|
+
const bb = 48 + 159 * ((k6 / 2.618033988749895 | 0) % 2);
|
|
26405
|
+
dr = (r1 * a1 - r22 * a22 - rb * da) / 255;
|
|
26406
|
+
dg = (g1 * a1 - g22 * a22 - gb * da) / 255;
|
|
26407
|
+
db = (b1 * a1 - b22 * a22 - bb * da) / 255;
|
|
26408
|
+
}
|
|
26409
|
+
const y5 = dr * 0.29889531 + dg * 0.58662247 + db * 0.11448223;
|
|
26410
|
+
if (yOnly)
|
|
26411
|
+
return y5;
|
|
26412
|
+
const i3 = dr * 0.59597799 - dg * 0.2741761 - db * 0.32180189;
|
|
26413
|
+
const q3 = dr * 0.21147017 - dg * 0.52261711 + db * 0.31114694;
|
|
26414
|
+
const delta = 0.5053 * y5 * y5 + 0.299 * i3 * i3 + 0.1957 * q3 * q3;
|
|
26415
|
+
return y5 > 0 ? -delta : delta;
|
|
26416
|
+
}
|
|
26417
|
+
function drawPixel(output, pos, r5, g5, b3) {
|
|
26418
|
+
output[pos + 0] = r5;
|
|
26419
|
+
output[pos + 1] = g5;
|
|
26420
|
+
output[pos + 2] = b3;
|
|
26421
|
+
output[pos + 3] = 255;
|
|
26422
|
+
}
|
|
26423
|
+
function drawGrayPixel(img, i3, alpha, output) {
|
|
26424
|
+
const val = 255 + (img[i3] * 0.29889531 + img[i3 + 1] * 0.58662247 + img[i3 + 2] * 0.11448223 - 255) * alpha * img[i3 + 3] / 255;
|
|
26425
|
+
drawPixel(output, i3, val, val, val);
|
|
26426
|
+
}
|
|
26427
|
+
|
|
26428
|
+
// packages/cli/src/commands/diff/visual.ts
|
|
26429
|
+
var exports_visual = {};
|
|
26430
|
+
__export(exports_visual, {
|
|
26431
|
+
default: () => visual_default
|
|
26432
|
+
});
|
|
26433
|
+
var import_pngjs, visual_default;
|
|
26434
|
+
var init_visual = __esm(() => {
|
|
26435
|
+
init_dist2();
|
|
26436
|
+
init_client();
|
|
26437
|
+
init_format();
|
|
26438
|
+
import_pngjs = __toESM(require_png(), 1);
|
|
26439
|
+
visual_default = defineCommand({
|
|
26440
|
+
meta: { description: "Create visual diff between two nodes as PNG" },
|
|
26441
|
+
args: {
|
|
26442
|
+
from: { type: "string", description: "Source node ID", required: true },
|
|
26443
|
+
to: { type: "string", description: "Target node ID", required: true },
|
|
26444
|
+
output: { type: "string", description: "Output file path", required: true },
|
|
26445
|
+
scale: { type: "string", description: "Export scale (default: 1)" },
|
|
26446
|
+
threshold: { type: "string", description: "Color threshold 0-1 (default: 0.1)" }
|
|
26447
|
+
},
|
|
26448
|
+
async run({ args }) {
|
|
26449
|
+
try {
|
|
26450
|
+
const scale = args.scale ? Number(args.scale) : 1;
|
|
26451
|
+
const threshold = args.threshold ? Number(args.threshold) : 0.1;
|
|
26452
|
+
const [fromResult, toResult] = await Promise.all([
|
|
26453
|
+
sendCommand("export-node", { id: args.from, format: "PNG", scale }),
|
|
26454
|
+
sendCommand("export-node", { id: args.to, format: "PNG", scale })
|
|
26455
|
+
]);
|
|
26456
|
+
if (!fromResult?.data || !toResult?.data) {
|
|
26457
|
+
console.error(fail("Could not export nodes"));
|
|
26458
|
+
process.exit(1);
|
|
26459
|
+
}
|
|
26460
|
+
const fromPng = import_pngjs.PNG.sync.read(Buffer.from(fromResult.data, "base64"));
|
|
26461
|
+
const toPng = import_pngjs.PNG.sync.read(Buffer.from(toResult.data, "base64"));
|
|
26462
|
+
if (fromPng.width !== toPng.width || fromPng.height !== toPng.height) {
|
|
26463
|
+
console.error(fail(`Size mismatch: ${fromPng.width}\xD7${fromPng.height} vs ${toPng.width}\xD7${toPng.height}`));
|
|
26464
|
+
process.exit(1);
|
|
26465
|
+
}
|
|
26466
|
+
const { width, height } = fromPng;
|
|
26467
|
+
const diff = new import_pngjs.PNG({ width, height });
|
|
26468
|
+
const diffPixels = pixelmatch(fromPng.data, toPng.data, diff.data, width, height, { threshold });
|
|
26469
|
+
const totalPixels = width * height;
|
|
26470
|
+
const diffPercent = (diffPixels / totalPixels * 100).toFixed(2);
|
|
26471
|
+
await Bun.write(args.output, import_pngjs.PNG.sync.write(diff));
|
|
26472
|
+
console.log(`${diffPixels} pixels differ (${diffPercent}%)`);
|
|
26473
|
+
console.log(`Saved to ${args.output}`);
|
|
26474
|
+
} catch (e6) {
|
|
26475
|
+
handleError(e6);
|
|
26476
|
+
}
|
|
26477
|
+
}
|
|
26478
|
+
});
|
|
26479
|
+
});
|
|
26480
|
+
|
|
24373
26481
|
// packages/cli/src/index.ts
|
|
24374
26482
|
init_dist2();
|
|
24375
26483
|
|
|
@@ -29078,317 +31186,1596 @@ var convertXybToRgb = ({ x: x3, y: y5, b: b3, alpha }) => {
|
|
|
29078
31186
|
res.alpha = alpha;
|
|
29079
31187
|
return res;
|
|
29080
31188
|
};
|
|
29081
|
-
var convertXybToRgb_default = convertXybToRgb;
|
|
31189
|
+
var convertXybToRgb_default = convertXybToRgb;
|
|
31190
|
+
|
|
31191
|
+
// packages/cli/node_modules/culori/src/xyb/definition.js
|
|
31192
|
+
var definition25 = {
|
|
31193
|
+
mode: "xyb",
|
|
31194
|
+
channels: ["x", "y", "b", "alpha"],
|
|
31195
|
+
parse: ["--xyb"],
|
|
31196
|
+
serialize: "--xyb",
|
|
31197
|
+
toMode: {
|
|
31198
|
+
rgb: convertXybToRgb_default
|
|
31199
|
+
},
|
|
31200
|
+
fromMode: {
|
|
31201
|
+
rgb: convertRgbToXyb_default
|
|
31202
|
+
},
|
|
31203
|
+
ranges: {
|
|
31204
|
+
x: [-0.0154, 0.0281],
|
|
31205
|
+
y: [0, 0.8453],
|
|
31206
|
+
b: [-0.2778, 0.388]
|
|
31207
|
+
},
|
|
31208
|
+
interpolate: {
|
|
31209
|
+
x: interpolatorLinear,
|
|
31210
|
+
y: interpolatorLinear,
|
|
31211
|
+
b: interpolatorLinear,
|
|
31212
|
+
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
|
|
31213
|
+
}
|
|
31214
|
+
};
|
|
31215
|
+
var definition_default25 = definition25;
|
|
31216
|
+
|
|
31217
|
+
// packages/cli/node_modules/culori/src/xyz50/definition.js
|
|
31218
|
+
var definition26 = {
|
|
31219
|
+
mode: "xyz50",
|
|
31220
|
+
parse: ["xyz-d50"],
|
|
31221
|
+
serialize: "xyz-d50",
|
|
31222
|
+
toMode: {
|
|
31223
|
+
rgb: convertXyz50ToRgb_default,
|
|
31224
|
+
lab: convertXyz50ToLab_default
|
|
31225
|
+
},
|
|
31226
|
+
fromMode: {
|
|
31227
|
+
rgb: convertRgbToXyz50_default,
|
|
31228
|
+
lab: convertLabToXyz50_default
|
|
31229
|
+
},
|
|
31230
|
+
channels: ["x", "y", "z", "alpha"],
|
|
31231
|
+
ranges: {
|
|
31232
|
+
x: [0, 0.964],
|
|
31233
|
+
y: [0, 0.999],
|
|
31234
|
+
z: [0, 0.825]
|
|
31235
|
+
},
|
|
31236
|
+
interpolate: {
|
|
31237
|
+
x: interpolatorLinear,
|
|
31238
|
+
y: interpolatorLinear,
|
|
31239
|
+
z: interpolatorLinear,
|
|
31240
|
+
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
|
|
31241
|
+
}
|
|
31242
|
+
};
|
|
31243
|
+
var definition_default26 = definition26;
|
|
31244
|
+
|
|
31245
|
+
// packages/cli/node_modules/culori/src/xyz65/convertXyz65ToXyz50.js
|
|
31246
|
+
var convertXyz65ToXyz50 = (xyz65) => {
|
|
31247
|
+
let { x: x3, y: y5, z: z3, alpha } = xyz65;
|
|
31248
|
+
if (x3 === undefined)
|
|
31249
|
+
x3 = 0;
|
|
31250
|
+
if (y5 === undefined)
|
|
31251
|
+
y5 = 0;
|
|
31252
|
+
if (z3 === undefined)
|
|
31253
|
+
z3 = 0;
|
|
31254
|
+
let res = {
|
|
31255
|
+
mode: "xyz50",
|
|
31256
|
+
x: 1.0479298208405488 * x3 + 0.0229467933410191 * y5 - 0.0501922295431356 * z3,
|
|
31257
|
+
y: 0.0296278156881593 * x3 + 0.990434484573249 * y5 - 0.0170738250293851 * z3,
|
|
31258
|
+
z: -0.0092430581525912 * x3 + 0.0150551448965779 * y5 + 0.7518742899580008 * z3
|
|
31259
|
+
};
|
|
31260
|
+
if (alpha !== undefined) {
|
|
31261
|
+
res.alpha = alpha;
|
|
31262
|
+
}
|
|
31263
|
+
return res;
|
|
31264
|
+
};
|
|
31265
|
+
var convertXyz65ToXyz50_default = convertXyz65ToXyz50;
|
|
31266
|
+
|
|
31267
|
+
// packages/cli/node_modules/culori/src/xyz65/convertXyz50ToXyz65.js
|
|
31268
|
+
var convertXyz50ToXyz65 = (xyz50) => {
|
|
31269
|
+
let { x: x3, y: y5, z: z3, alpha } = xyz50;
|
|
31270
|
+
if (x3 === undefined)
|
|
31271
|
+
x3 = 0;
|
|
31272
|
+
if (y5 === undefined)
|
|
31273
|
+
y5 = 0;
|
|
31274
|
+
if (z3 === undefined)
|
|
31275
|
+
z3 = 0;
|
|
31276
|
+
let res = {
|
|
31277
|
+
mode: "xyz65",
|
|
31278
|
+
x: 0.9554734527042182 * x3 - 0.0230985368742614 * y5 + 0.0632593086610217 * z3,
|
|
31279
|
+
y: -0.0283697069632081 * x3 + 1.0099954580058226 * y5 + 0.021041398966943 * z3,
|
|
31280
|
+
z: 0.0123140016883199 * x3 - 0.0205076964334779 * y5 + 1.3303659366080753 * z3
|
|
31281
|
+
};
|
|
31282
|
+
if (alpha !== undefined) {
|
|
31283
|
+
res.alpha = alpha;
|
|
31284
|
+
}
|
|
31285
|
+
return res;
|
|
31286
|
+
};
|
|
31287
|
+
var convertXyz50ToXyz65_default = convertXyz50ToXyz65;
|
|
31288
|
+
|
|
31289
|
+
// packages/cli/node_modules/culori/src/xyz65/definition.js
|
|
31290
|
+
var definition27 = {
|
|
31291
|
+
mode: "xyz65",
|
|
31292
|
+
toMode: {
|
|
31293
|
+
rgb: convertXyz65ToRgb_default,
|
|
31294
|
+
xyz50: convertXyz65ToXyz50_default
|
|
31295
|
+
},
|
|
31296
|
+
fromMode: {
|
|
31297
|
+
rgb: convertRgbToXyz65_default,
|
|
31298
|
+
xyz50: convertXyz50ToXyz65_default
|
|
31299
|
+
},
|
|
31300
|
+
ranges: {
|
|
31301
|
+
x: [0, 0.95],
|
|
31302
|
+
y: [0, 1],
|
|
31303
|
+
z: [0, 1.088]
|
|
31304
|
+
},
|
|
31305
|
+
channels: ["x", "y", "z", "alpha"],
|
|
31306
|
+
parse: ["xyz", "xyz-d65"],
|
|
31307
|
+
serialize: "xyz-d65",
|
|
31308
|
+
interpolate: {
|
|
31309
|
+
x: interpolatorLinear,
|
|
31310
|
+
y: interpolatorLinear,
|
|
31311
|
+
z: interpolatorLinear,
|
|
31312
|
+
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
|
|
31313
|
+
}
|
|
31314
|
+
};
|
|
31315
|
+
var definition_default27 = definition27;
|
|
31316
|
+
|
|
31317
|
+
// packages/cli/node_modules/culori/src/yiq/convertRgbToYiq.js
|
|
31318
|
+
var convertRgbToYiq = ({ r: r5, g: g5, b: b3, alpha }) => {
|
|
31319
|
+
if (r5 === undefined)
|
|
31320
|
+
r5 = 0;
|
|
31321
|
+
if (g5 === undefined)
|
|
31322
|
+
g5 = 0;
|
|
31323
|
+
if (b3 === undefined)
|
|
31324
|
+
b3 = 0;
|
|
31325
|
+
const res = {
|
|
31326
|
+
mode: "yiq",
|
|
31327
|
+
y: 0.29889531 * r5 + 0.58662247 * g5 + 0.11448223 * b3,
|
|
31328
|
+
i: 0.59597799 * r5 - 0.2741761 * g5 - 0.32180189 * b3,
|
|
31329
|
+
q: 0.21147017 * r5 - 0.52261711 * g5 + 0.31114694 * b3
|
|
31330
|
+
};
|
|
31331
|
+
if (alpha !== undefined)
|
|
31332
|
+
res.alpha = alpha;
|
|
31333
|
+
return res;
|
|
31334
|
+
};
|
|
31335
|
+
var convertRgbToYiq_default = convertRgbToYiq;
|
|
31336
|
+
|
|
31337
|
+
// packages/cli/node_modules/culori/src/yiq/convertYiqToRgb.js
|
|
31338
|
+
var convertYiqToRgb = ({ y: y5, i: i3, q: q3, alpha }) => {
|
|
31339
|
+
if (y5 === undefined)
|
|
31340
|
+
y5 = 0;
|
|
31341
|
+
if (i3 === undefined)
|
|
31342
|
+
i3 = 0;
|
|
31343
|
+
if (q3 === undefined)
|
|
31344
|
+
q3 = 0;
|
|
31345
|
+
const res = {
|
|
31346
|
+
mode: "rgb",
|
|
31347
|
+
r: y5 + 0.95608445 * i3 + 0.6208885 * q3,
|
|
31348
|
+
g: y5 - 0.27137664 * i3 - 0.6486059 * q3,
|
|
31349
|
+
b: y5 - 1.10561724 * i3 + 1.70250126 * q3
|
|
31350
|
+
};
|
|
31351
|
+
if (alpha !== undefined)
|
|
31352
|
+
res.alpha = alpha;
|
|
31353
|
+
return res;
|
|
31354
|
+
};
|
|
31355
|
+
var convertYiqToRgb_default = convertYiqToRgb;
|
|
29082
31356
|
|
|
29083
|
-
// packages/cli/node_modules/culori/src/
|
|
29084
|
-
var
|
|
29085
|
-
mode: "
|
|
29086
|
-
channels: ["x", "y", "b", "alpha"],
|
|
29087
|
-
parse: ["--xyb"],
|
|
29088
|
-
serialize: "--xyb",
|
|
31357
|
+
// packages/cli/node_modules/culori/src/yiq/definition.js
|
|
31358
|
+
var definition28 = {
|
|
31359
|
+
mode: "yiq",
|
|
29089
31360
|
toMode: {
|
|
29090
|
-
rgb:
|
|
31361
|
+
rgb: convertYiqToRgb_default
|
|
29091
31362
|
},
|
|
29092
31363
|
fromMode: {
|
|
29093
|
-
rgb:
|
|
31364
|
+
rgb: convertRgbToYiq_default
|
|
29094
31365
|
},
|
|
31366
|
+
channels: ["y", "i", "q", "alpha"],
|
|
31367
|
+
parse: ["--yiq"],
|
|
31368
|
+
serialize: "--yiq",
|
|
29095
31369
|
ranges: {
|
|
29096
|
-
|
|
29097
|
-
|
|
29098
|
-
b: [-0.2778, 0.388]
|
|
31370
|
+
i: [-0.595, 0.595],
|
|
31371
|
+
q: [-0.522, 0.522]
|
|
29099
31372
|
},
|
|
29100
31373
|
interpolate: {
|
|
29101
|
-
x: interpolatorLinear,
|
|
29102
31374
|
y: interpolatorLinear,
|
|
29103
|
-
|
|
31375
|
+
i: interpolatorLinear,
|
|
31376
|
+
q: interpolatorLinear,
|
|
29104
31377
|
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
|
|
29105
31378
|
}
|
|
29106
31379
|
};
|
|
29107
|
-
var
|
|
31380
|
+
var definition_default28 = definition28;
|
|
31381
|
+
// packages/cli/node_modules/culori/src/index.js
|
|
31382
|
+
var a98 = useMode(definition_default2);
|
|
31383
|
+
var cubehelix = useMode(definition_default3);
|
|
31384
|
+
var dlab = useMode(definition_default4);
|
|
31385
|
+
var dlch = useMode(definition_default5);
|
|
31386
|
+
var hsi = useMode(definition_default6);
|
|
31387
|
+
var hsl = useMode(definition_default7);
|
|
31388
|
+
var hsv = useMode(definition_default8);
|
|
31389
|
+
var hwb = useMode(definition_default9);
|
|
31390
|
+
var itp = useMode(definition_default10);
|
|
31391
|
+
var jab = useMode(definition_default11);
|
|
31392
|
+
var jch = useMode(definition_default12);
|
|
31393
|
+
var lab = useMode(definition_default13);
|
|
31394
|
+
var lab65 = useMode(definition_default14);
|
|
31395
|
+
var lch = useMode(definition_default15);
|
|
31396
|
+
var lch65 = useMode(definition_default16);
|
|
31397
|
+
var lchuv = useMode(definition_default17);
|
|
31398
|
+
var lrgb = useMode(definition_default18);
|
|
31399
|
+
var luv = useMode(definition_default19);
|
|
31400
|
+
var okhsl = useMode(modeOkhsl_default);
|
|
31401
|
+
var okhsv = useMode(modeOkhsv_default);
|
|
31402
|
+
var oklab = useMode(definition_default20);
|
|
31403
|
+
var oklch = useMode(definition_default21);
|
|
31404
|
+
var p3 = useMode(definition_default22);
|
|
31405
|
+
var prophoto = useMode(definition_default23);
|
|
31406
|
+
var rec2020 = useMode(definition_default24);
|
|
31407
|
+
var rgb = useMode(definition_default);
|
|
31408
|
+
var xyb = useMode(definition_default25);
|
|
31409
|
+
var xyz50 = useMode(definition_default26);
|
|
31410
|
+
var xyz65 = useMode(definition_default27);
|
|
31411
|
+
var yiq = useMode(definition_default28);
|
|
29108
31412
|
|
|
29109
|
-
// packages/cli/
|
|
29110
|
-
var
|
|
29111
|
-
|
|
29112
|
-
|
|
29113
|
-
|
|
29114
|
-
|
|
29115
|
-
rgb: convertXyz50ToRgb_default,
|
|
29116
|
-
lab: convertXyz50ToLab_default
|
|
29117
|
-
},
|
|
29118
|
-
fromMode: {
|
|
29119
|
-
rgb: convertRgbToXyz50_default,
|
|
29120
|
-
lab: convertLabToXyz50_default
|
|
29121
|
-
},
|
|
29122
|
-
channels: ["x", "y", "z", "alpha"],
|
|
29123
|
-
ranges: {
|
|
29124
|
-
x: [0, 0.964],
|
|
29125
|
-
y: [0, 0.999],
|
|
29126
|
-
z: [0, 0.825]
|
|
29127
|
-
},
|
|
29128
|
-
interpolate: {
|
|
29129
|
-
x: interpolatorLinear,
|
|
29130
|
-
y: interpolatorLinear,
|
|
29131
|
-
z: interpolatorLinear,
|
|
29132
|
-
alpha: { use: interpolatorLinear, fixup: fixupAlpha }
|
|
31413
|
+
// packages/cli/src/color.ts
|
|
31414
|
+
var toRgb = converter_default("rgb");
|
|
31415
|
+
function parseColor(color) {
|
|
31416
|
+
const parsed = parse_default(color);
|
|
31417
|
+
if (!parsed) {
|
|
31418
|
+
return { r: 0, g: 0, b: 0, a: 1 };
|
|
29133
31419
|
}
|
|
31420
|
+
const rgb2 = toRgb(parsed);
|
|
31421
|
+
return {
|
|
31422
|
+
r: rgb2?.r ?? 0,
|
|
31423
|
+
g: rgb2?.g ?? 0,
|
|
31424
|
+
b: rgb2?.b ?? 0,
|
|
31425
|
+
a: parsed.alpha ?? 1
|
|
31426
|
+
};
|
|
31427
|
+
}
|
|
31428
|
+
|
|
31429
|
+
// packages/cli/src/render/reconciler.ts
|
|
31430
|
+
init_vars();
|
|
31431
|
+
|
|
31432
|
+
// packages/cli/src/render/components.tsx
|
|
31433
|
+
init_vars();
|
|
31434
|
+
var React = __toESM(require_react(), 1);
|
|
31435
|
+
var componentRegistry = new Map;
|
|
31436
|
+
function getComponentRegistry() {
|
|
31437
|
+
return componentRegistry;
|
|
31438
|
+
}
|
|
31439
|
+
var c6 = (type) => (props) => React.createElement(type, props);
|
|
31440
|
+
var Frame = c6("frame");
|
|
31441
|
+
var Rectangle = c6("rectangle");
|
|
31442
|
+
var Ellipse = c6("ellipse");
|
|
31443
|
+
var Text = c6("text");
|
|
31444
|
+
var Line = c6("line");
|
|
31445
|
+
var Star = c6("star");
|
|
31446
|
+
var Polygon = c6("polygon");
|
|
31447
|
+
var Vector = c6("vector");
|
|
31448
|
+
var Component = c6("component");
|
|
31449
|
+
var Instance = c6("instance");
|
|
31450
|
+
var Group = c6("group");
|
|
31451
|
+
var Page = c6("page");
|
|
31452
|
+
var Icon = c6("icon");
|
|
31453
|
+
var INTRINSIC_ELEMENTS = [
|
|
31454
|
+
"Frame",
|
|
31455
|
+
"Rectangle",
|
|
31456
|
+
"Ellipse",
|
|
31457
|
+
"Text",
|
|
31458
|
+
"Line",
|
|
31459
|
+
"Star",
|
|
31460
|
+
"Polygon",
|
|
31461
|
+
"Vector",
|
|
31462
|
+
"Component",
|
|
31463
|
+
"Instance",
|
|
31464
|
+
"Group",
|
|
31465
|
+
"Page",
|
|
31466
|
+
"View",
|
|
31467
|
+
"Icon"
|
|
31468
|
+
];
|
|
31469
|
+
|
|
31470
|
+
// packages/cli/src/render/shorthands.ts
|
|
31471
|
+
var shorthands = {
|
|
31472
|
+
w: "width",
|
|
31473
|
+
h: "height",
|
|
31474
|
+
bg: "backgroundColor",
|
|
31475
|
+
rounded: "borderRadius",
|
|
31476
|
+
p: "padding",
|
|
31477
|
+
pt: "paddingTop",
|
|
31478
|
+
pr: "paddingRight",
|
|
31479
|
+
pb: "paddingBottom",
|
|
31480
|
+
pl: "paddingLeft",
|
|
31481
|
+
size: "fontSize",
|
|
31482
|
+
font: "fontFamily",
|
|
31483
|
+
weight: "fontWeight"
|
|
29134
31484
|
};
|
|
29135
|
-
var
|
|
31485
|
+
var valueTransforms = {
|
|
31486
|
+
flexDirection: { col: "column" },
|
|
31487
|
+
justifyContent: {
|
|
31488
|
+
start: "flex-start",
|
|
31489
|
+
end: "flex-end",
|
|
31490
|
+
between: "space-between",
|
|
31491
|
+
evenly: "space-evenly"
|
|
31492
|
+
},
|
|
31493
|
+
alignItems: { start: "flex-start", end: "flex-end" }
|
|
31494
|
+
};
|
|
31495
|
+
function normalizeStyle(style) {
|
|
31496
|
+
const result = {};
|
|
31497
|
+
for (const [key, value] of Object.entries(style)) {
|
|
31498
|
+
if (key === "px" || key === "py" || key === "flex" || key === "justify" || key === "items") {
|
|
31499
|
+
continue;
|
|
31500
|
+
}
|
|
31501
|
+
const fullKey = shorthands[key] || key;
|
|
31502
|
+
if (shorthands[key] && style[fullKey] !== undefined) {
|
|
31503
|
+
continue;
|
|
31504
|
+
}
|
|
31505
|
+
if (result[fullKey] === undefined) {
|
|
31506
|
+
const transform = valueTransforms[fullKey];
|
|
31507
|
+
result[fullKey] = transform?.[value] ?? value;
|
|
31508
|
+
}
|
|
31509
|
+
}
|
|
31510
|
+
if (style.px !== undefined) {
|
|
31511
|
+
if (result.paddingLeft === undefined)
|
|
31512
|
+
result.paddingLeft = style.px;
|
|
31513
|
+
if (result.paddingRight === undefined)
|
|
31514
|
+
result.paddingRight = style.px;
|
|
31515
|
+
}
|
|
31516
|
+
if (style.py !== undefined) {
|
|
31517
|
+
if (result.paddingTop === undefined)
|
|
31518
|
+
result.paddingTop = style.py;
|
|
31519
|
+
if (result.paddingBottom === undefined)
|
|
31520
|
+
result.paddingBottom = style.py;
|
|
31521
|
+
}
|
|
31522
|
+
if (style.flex !== undefined && result.flexDirection === undefined) {
|
|
31523
|
+
const transform = valueTransforms.flexDirection;
|
|
31524
|
+
const value = transform?.[style.flex] ?? style.flex;
|
|
31525
|
+
result.flexDirection = value === "col" ? "column" : value;
|
|
31526
|
+
}
|
|
31527
|
+
if (style.justify !== undefined && result.justifyContent === undefined) {
|
|
31528
|
+
const transform = valueTransforms.justifyContent;
|
|
31529
|
+
result.justifyContent = transform?.[style.justify] ?? style.justify;
|
|
31530
|
+
}
|
|
31531
|
+
if (style.items !== undefined && result.alignItems === undefined) {
|
|
31532
|
+
const transform = valueTransforms.alignItems;
|
|
31533
|
+
result.alignItems = transform?.[style.items] ?? style.items;
|
|
31534
|
+
}
|
|
31535
|
+
return result;
|
|
31536
|
+
}
|
|
29136
31537
|
|
|
29137
|
-
// packages/cli/
|
|
29138
|
-
var
|
|
29139
|
-
|
|
29140
|
-
|
|
29141
|
-
|
|
29142
|
-
|
|
29143
|
-
|
|
29144
|
-
|
|
29145
|
-
|
|
29146
|
-
|
|
29147
|
-
|
|
29148
|
-
|
|
29149
|
-
|
|
29150
|
-
|
|
31538
|
+
// packages/cli/src/render/component-set.tsx
|
|
31539
|
+
var React2 = __toESM(require_react(), 1);
|
|
31540
|
+
var REGISTRY_KEY = "__figma_use_component_set_registry__";
|
|
31541
|
+
var componentSetRegistry = globalThis[REGISTRY_KEY] || (globalThis[REGISTRY_KEY] = new Map);
|
|
31542
|
+
function getComponentSetRegistry() {
|
|
31543
|
+
return componentSetRegistry;
|
|
31544
|
+
}
|
|
31545
|
+
function generateVariantCombinations(variants) {
|
|
31546
|
+
const keys = Object.keys(variants);
|
|
31547
|
+
if (keys.length === 0)
|
|
31548
|
+
return [{}];
|
|
31549
|
+
const result = [];
|
|
31550
|
+
function combine(index, current) {
|
|
31551
|
+
if (index === keys.length) {
|
|
31552
|
+
result.push(current);
|
|
31553
|
+
return;
|
|
31554
|
+
}
|
|
31555
|
+
const key = keys[index];
|
|
31556
|
+
for (const value of variants[key]) {
|
|
31557
|
+
combine(index + 1, { ...current, [key]: value });
|
|
31558
|
+
}
|
|
31559
|
+
}
|
|
31560
|
+
combine(0, {});
|
|
31561
|
+
return result;
|
|
31562
|
+
}
|
|
31563
|
+
function buildVariantName(props) {
|
|
31564
|
+
return Object.entries(props).map(([k6, v3]) => `${k6}=${v3}`).join(", ");
|
|
31565
|
+
}
|
|
31566
|
+
function buildStateGroupPropertyValueOrders(variants) {
|
|
31567
|
+
return Object.entries(variants).map(([property, values]) => ({
|
|
31568
|
+
property,
|
|
31569
|
+
values: [...values]
|
|
31570
|
+
}));
|
|
31571
|
+
}
|
|
31572
|
+
|
|
31573
|
+
// node_modules/@iconify/core/lib/api/callbacks.js
|
|
31574
|
+
function removeCallback(storages, id) {
|
|
31575
|
+
storages.forEach((storage) => {
|
|
31576
|
+
const items = storage.loaderCallbacks;
|
|
31577
|
+
if (items)
|
|
31578
|
+
storage.loaderCallbacks = items.filter((row) => row.id !== id);
|
|
31579
|
+
});
|
|
31580
|
+
}
|
|
31581
|
+
function updateCallbacks(storage) {
|
|
31582
|
+
if (!storage.pendingCallbacksFlag) {
|
|
31583
|
+
storage.pendingCallbacksFlag = true;
|
|
31584
|
+
setTimeout(() => {
|
|
31585
|
+
storage.pendingCallbacksFlag = false;
|
|
31586
|
+
const items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];
|
|
31587
|
+
if (!items.length)
|
|
31588
|
+
return;
|
|
31589
|
+
let hasPending = false;
|
|
31590
|
+
const provider = storage.provider;
|
|
31591
|
+
const prefix = storage.prefix;
|
|
31592
|
+
items.forEach((item) => {
|
|
31593
|
+
const icons = item.icons;
|
|
31594
|
+
const oldLength = icons.pending.length;
|
|
31595
|
+
icons.pending = icons.pending.filter((icon) => {
|
|
31596
|
+
if (icon.prefix !== prefix)
|
|
31597
|
+
return true;
|
|
31598
|
+
const name = icon.name;
|
|
31599
|
+
if (storage.icons[name])
|
|
31600
|
+
icons.loaded.push({
|
|
31601
|
+
provider,
|
|
31602
|
+
prefix,
|
|
31603
|
+
name
|
|
31604
|
+
});
|
|
31605
|
+
else if (storage.missing.has(name))
|
|
31606
|
+
icons.missing.push({
|
|
31607
|
+
provider,
|
|
31608
|
+
prefix,
|
|
31609
|
+
name
|
|
31610
|
+
});
|
|
31611
|
+
else {
|
|
31612
|
+
hasPending = true;
|
|
31613
|
+
return true;
|
|
31614
|
+
}
|
|
31615
|
+
return false;
|
|
31616
|
+
});
|
|
31617
|
+
if (icons.pending.length !== oldLength) {
|
|
31618
|
+
if (!hasPending)
|
|
31619
|
+
removeCallback([storage], item.id);
|
|
31620
|
+
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
|
|
31621
|
+
}
|
|
31622
|
+
});
|
|
31623
|
+
});
|
|
31624
|
+
}
|
|
31625
|
+
}
|
|
31626
|
+
var idCounter = 0;
|
|
31627
|
+
function storeCallback(callback, icons, pendingSources) {
|
|
31628
|
+
const id = idCounter++;
|
|
31629
|
+
const abort = removeCallback.bind(null, pendingSources, id);
|
|
31630
|
+
if (!icons.pending.length)
|
|
31631
|
+
return abort;
|
|
31632
|
+
const item = {
|
|
31633
|
+
id,
|
|
31634
|
+
icons,
|
|
31635
|
+
callback,
|
|
31636
|
+
abort
|
|
29151
31637
|
};
|
|
29152
|
-
|
|
29153
|
-
|
|
31638
|
+
pendingSources.forEach((storage) => {
|
|
31639
|
+
(storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);
|
|
31640
|
+
});
|
|
31641
|
+
return abort;
|
|
31642
|
+
}
|
|
31643
|
+
|
|
31644
|
+
// node_modules/@iconify/utils/lib/icon-set/tree.js
|
|
31645
|
+
function getIconsTree(data, names) {
|
|
31646
|
+
const icons = data.icons;
|
|
31647
|
+
const aliases = data.aliases || Object.create(null);
|
|
31648
|
+
const resolved = Object.create(null);
|
|
31649
|
+
function resolve3(name) {
|
|
31650
|
+
if (icons[name])
|
|
31651
|
+
return resolved[name] = [];
|
|
31652
|
+
if (!(name in resolved)) {
|
|
31653
|
+
resolved[name] = null;
|
|
31654
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
31655
|
+
const value = parent && resolve3(parent);
|
|
31656
|
+
if (value)
|
|
31657
|
+
resolved[name] = [parent].concat(value);
|
|
31658
|
+
}
|
|
31659
|
+
return resolved[name];
|
|
31660
|
+
}
|
|
31661
|
+
(names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve3);
|
|
31662
|
+
return resolved;
|
|
31663
|
+
}
|
|
31664
|
+
|
|
31665
|
+
// node_modules/@iconify/utils/lib/icon/defaults.js
|
|
31666
|
+
var defaultIconDimensions = Object.freeze({
|
|
31667
|
+
left: 0,
|
|
31668
|
+
top: 0,
|
|
31669
|
+
width: 16,
|
|
31670
|
+
height: 16
|
|
31671
|
+
});
|
|
31672
|
+
var defaultIconTransformations = Object.freeze({
|
|
31673
|
+
rotate: 0,
|
|
31674
|
+
vFlip: false,
|
|
31675
|
+
hFlip: false
|
|
31676
|
+
});
|
|
31677
|
+
var defaultIconProps = Object.freeze({
|
|
31678
|
+
...defaultIconDimensions,
|
|
31679
|
+
...defaultIconTransformations
|
|
31680
|
+
});
|
|
31681
|
+
var defaultExtendedIconProps = Object.freeze({
|
|
31682
|
+
...defaultIconProps,
|
|
31683
|
+
body: "",
|
|
31684
|
+
hidden: false
|
|
31685
|
+
});
|
|
31686
|
+
|
|
31687
|
+
// node_modules/@iconify/utils/lib/icon/transformations.js
|
|
31688
|
+
function mergeIconTransformations(obj1, obj2) {
|
|
31689
|
+
const result = {};
|
|
31690
|
+
if (!obj1.hFlip !== !obj2.hFlip)
|
|
31691
|
+
result.hFlip = true;
|
|
31692
|
+
if (!obj1.vFlip !== !obj2.vFlip)
|
|
31693
|
+
result.vFlip = true;
|
|
31694
|
+
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
31695
|
+
if (rotate)
|
|
31696
|
+
result.rotate = rotate;
|
|
31697
|
+
return result;
|
|
31698
|
+
}
|
|
31699
|
+
|
|
31700
|
+
// node_modules/@iconify/utils/lib/icon/merge.js
|
|
31701
|
+
function mergeIconData(parent, child) {
|
|
31702
|
+
const result = mergeIconTransformations(parent, child);
|
|
31703
|
+
for (const key in defaultExtendedIconProps)
|
|
31704
|
+
if (key in defaultIconTransformations) {
|
|
31705
|
+
if (key in parent && !(key in result))
|
|
31706
|
+
result[key] = defaultIconTransformations[key];
|
|
31707
|
+
} else if (key in child)
|
|
31708
|
+
result[key] = child[key];
|
|
31709
|
+
else if (key in parent)
|
|
31710
|
+
result[key] = parent[key];
|
|
31711
|
+
return result;
|
|
31712
|
+
}
|
|
31713
|
+
|
|
31714
|
+
// node_modules/@iconify/utils/lib/icon-set/get-icon.js
|
|
31715
|
+
function internalGetIconData(data, name, tree) {
|
|
31716
|
+
const icons = data.icons;
|
|
31717
|
+
const aliases = data.aliases || Object.create(null);
|
|
31718
|
+
let currentProps = {};
|
|
31719
|
+
function parse2(name$1) {
|
|
31720
|
+
currentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);
|
|
31721
|
+
}
|
|
31722
|
+
parse2(name);
|
|
31723
|
+
tree.forEach(parse2);
|
|
31724
|
+
return mergeIconData(data, currentProps);
|
|
31725
|
+
}
|
|
31726
|
+
|
|
31727
|
+
// node_modules/@iconify/utils/lib/icon-set/parse.js
|
|
31728
|
+
function parseIconSet(data, callback) {
|
|
31729
|
+
const names = [];
|
|
31730
|
+
if (typeof data !== "object" || typeof data.icons !== "object")
|
|
31731
|
+
return names;
|
|
31732
|
+
if (data.not_found instanceof Array)
|
|
31733
|
+
data.not_found.forEach((name) => {
|
|
31734
|
+
callback(name, null);
|
|
31735
|
+
names.push(name);
|
|
31736
|
+
});
|
|
31737
|
+
const tree = getIconsTree(data);
|
|
31738
|
+
for (const name in tree) {
|
|
31739
|
+
const item = tree[name];
|
|
31740
|
+
if (item) {
|
|
31741
|
+
callback(name, internalGetIconData(data, name, item));
|
|
31742
|
+
names.push(name);
|
|
31743
|
+
}
|
|
31744
|
+
}
|
|
31745
|
+
return names;
|
|
31746
|
+
}
|
|
31747
|
+
|
|
31748
|
+
// node_modules/@iconify/utils/lib/icon-set/validate-basic.js
|
|
31749
|
+
var optionalPropertyDefaults = {
|
|
31750
|
+
provider: "",
|
|
31751
|
+
aliases: {},
|
|
31752
|
+
not_found: {},
|
|
31753
|
+
...defaultIconDimensions
|
|
31754
|
+
};
|
|
31755
|
+
function checkOptionalProps(item, defaults) {
|
|
31756
|
+
for (const prop in defaults)
|
|
31757
|
+
if (prop in item && typeof item[prop] !== typeof defaults[prop])
|
|
31758
|
+
return false;
|
|
31759
|
+
return true;
|
|
31760
|
+
}
|
|
31761
|
+
function quicklyValidateIconSet(obj) {
|
|
31762
|
+
if (typeof obj !== "object" || obj === null)
|
|
31763
|
+
return null;
|
|
31764
|
+
const data = obj;
|
|
31765
|
+
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object")
|
|
31766
|
+
return null;
|
|
31767
|
+
if (!checkOptionalProps(obj, optionalPropertyDefaults))
|
|
31768
|
+
return null;
|
|
31769
|
+
const icons = data.icons;
|
|
31770
|
+
for (const name in icons) {
|
|
31771
|
+
const icon = icons[name];
|
|
31772
|
+
if (!name || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps))
|
|
31773
|
+
return null;
|
|
29154
31774
|
}
|
|
29155
|
-
|
|
29156
|
-
|
|
29157
|
-
|
|
31775
|
+
const aliases = data.aliases || Object.create(null);
|
|
31776
|
+
for (const name in aliases) {
|
|
31777
|
+
const icon = aliases[name];
|
|
31778
|
+
const parent = icon.parent;
|
|
31779
|
+
if (!name || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps))
|
|
31780
|
+
return null;
|
|
31781
|
+
}
|
|
31782
|
+
return data;
|
|
31783
|
+
}
|
|
29158
31784
|
|
|
29159
|
-
//
|
|
29160
|
-
var
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
z3 = 0;
|
|
29168
|
-
let res = {
|
|
29169
|
-
mode: "xyz65",
|
|
29170
|
-
x: 0.9554734527042182 * x3 - 0.0230985368742614 * y5 + 0.0632593086610217 * z3,
|
|
29171
|
-
y: -0.0283697069632081 * x3 + 1.0099954580058226 * y5 + 0.021041398966943 * z3,
|
|
29172
|
-
z: 0.0123140016883199 * x3 - 0.0205076964334779 * y5 + 1.3303659366080753 * z3
|
|
31785
|
+
// node_modules/@iconify/core/lib/storage/storage.js
|
|
31786
|
+
var dataStorage = Object.create(null);
|
|
31787
|
+
function newStorage(provider, prefix) {
|
|
31788
|
+
return {
|
|
31789
|
+
provider,
|
|
31790
|
+
prefix,
|
|
31791
|
+
icons: Object.create(null),
|
|
31792
|
+
missing: /* @__PURE__ */ new Set
|
|
29173
31793
|
};
|
|
29174
|
-
|
|
29175
|
-
|
|
31794
|
+
}
|
|
31795
|
+
function getStorage(provider, prefix) {
|
|
31796
|
+
const providerStorage = dataStorage[provider] || (dataStorage[provider] = Object.create(null));
|
|
31797
|
+
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
31798
|
+
}
|
|
31799
|
+
function addIconSet(storage, data) {
|
|
31800
|
+
if (!quicklyValidateIconSet(data))
|
|
31801
|
+
return [];
|
|
31802
|
+
return parseIconSet(data, (name, icon) => {
|
|
31803
|
+
if (icon)
|
|
31804
|
+
storage.icons[name] = icon;
|
|
31805
|
+
else
|
|
31806
|
+
storage.missing.add(name);
|
|
31807
|
+
});
|
|
31808
|
+
}
|
|
31809
|
+
|
|
31810
|
+
// node_modules/@iconify/core/lib/icon/sort.js
|
|
31811
|
+
function sortIcons(icons) {
|
|
31812
|
+
const result = {
|
|
31813
|
+
loaded: [],
|
|
31814
|
+
missing: [],
|
|
31815
|
+
pending: []
|
|
31816
|
+
};
|
|
31817
|
+
const storage = Object.create(null);
|
|
31818
|
+
icons.sort((a3, b3) => {
|
|
31819
|
+
if (a3.provider !== b3.provider)
|
|
31820
|
+
return a3.provider.localeCompare(b3.provider);
|
|
31821
|
+
if (a3.prefix !== b3.prefix)
|
|
31822
|
+
return a3.prefix.localeCompare(b3.prefix);
|
|
31823
|
+
return a3.name.localeCompare(b3.name);
|
|
31824
|
+
});
|
|
31825
|
+
let lastIcon = {
|
|
31826
|
+
provider: "",
|
|
31827
|
+
prefix: "",
|
|
31828
|
+
name: ""
|
|
31829
|
+
};
|
|
31830
|
+
icons.forEach((icon) => {
|
|
31831
|
+
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider)
|
|
31832
|
+
return;
|
|
31833
|
+
lastIcon = icon;
|
|
31834
|
+
const provider = icon.provider;
|
|
31835
|
+
const prefix = icon.prefix;
|
|
31836
|
+
const name = icon.name;
|
|
31837
|
+
const providerStorage = storage[provider] || (storage[provider] = Object.create(null));
|
|
31838
|
+
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
31839
|
+
let list;
|
|
31840
|
+
if (name in localStorage.icons)
|
|
31841
|
+
list = result.loaded;
|
|
31842
|
+
else if (prefix === "" || localStorage.missing.has(name))
|
|
31843
|
+
list = result.missing;
|
|
31844
|
+
else
|
|
31845
|
+
list = result.pending;
|
|
31846
|
+
const item = {
|
|
31847
|
+
provider,
|
|
31848
|
+
prefix,
|
|
31849
|
+
name
|
|
31850
|
+
};
|
|
31851
|
+
list.push(item);
|
|
31852
|
+
});
|
|
31853
|
+
return result;
|
|
31854
|
+
}
|
|
31855
|
+
|
|
31856
|
+
// node_modules/@iconify/core/lib/api/modules.js
|
|
31857
|
+
var storage = Object.create(null);
|
|
31858
|
+
function setAPIModule(provider, item) {
|
|
31859
|
+
storage[provider] = item;
|
|
31860
|
+
}
|
|
31861
|
+
function getAPIModule(provider) {
|
|
31862
|
+
return storage[provider] || storage[""];
|
|
31863
|
+
}
|
|
31864
|
+
|
|
31865
|
+
// node_modules/@iconify/utils/lib/icon/name.js
|
|
31866
|
+
var matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
31867
|
+
var stringToIcon = (value, validate3, allowSimpleName, provider = "") => {
|
|
31868
|
+
const colonSeparated = value.split(":");
|
|
31869
|
+
if (value.slice(0, 1) === "@") {
|
|
31870
|
+
if (colonSeparated.length < 2 || colonSeparated.length > 3)
|
|
31871
|
+
return null;
|
|
31872
|
+
provider = colonSeparated.shift().slice(1);
|
|
29176
31873
|
}
|
|
29177
|
-
|
|
31874
|
+
if (colonSeparated.length > 3 || !colonSeparated.length)
|
|
31875
|
+
return null;
|
|
31876
|
+
if (colonSeparated.length > 1) {
|
|
31877
|
+
const name$1 = colonSeparated.pop();
|
|
31878
|
+
const prefix = colonSeparated.pop();
|
|
31879
|
+
const result = {
|
|
31880
|
+
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
|
|
31881
|
+
prefix,
|
|
31882
|
+
name: name$1
|
|
31883
|
+
};
|
|
31884
|
+
return validate3 && !validateIconName(result) ? null : result;
|
|
31885
|
+
}
|
|
31886
|
+
const name = colonSeparated[0];
|
|
31887
|
+
const dashSeparated = name.split("-");
|
|
31888
|
+
if (dashSeparated.length > 1) {
|
|
31889
|
+
const result = {
|
|
31890
|
+
provider,
|
|
31891
|
+
prefix: dashSeparated.shift(),
|
|
31892
|
+
name: dashSeparated.join("-")
|
|
31893
|
+
};
|
|
31894
|
+
return validate3 && !validateIconName(result) ? null : result;
|
|
31895
|
+
}
|
|
31896
|
+
if (allowSimpleName && provider === "") {
|
|
31897
|
+
const result = {
|
|
31898
|
+
provider,
|
|
31899
|
+
prefix: "",
|
|
31900
|
+
name
|
|
31901
|
+
};
|
|
31902
|
+
return validate3 && !validateIconName(result, allowSimpleName) ? null : result;
|
|
31903
|
+
}
|
|
31904
|
+
return null;
|
|
31905
|
+
};
|
|
31906
|
+
var validateIconName = (icon, allowSimpleName) => {
|
|
31907
|
+
if (!icon)
|
|
31908
|
+
return false;
|
|
31909
|
+
return !!((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
|
|
29178
31910
|
};
|
|
29179
|
-
var convertXyz50ToXyz65_default = convertXyz50ToXyz65;
|
|
29180
31911
|
|
|
29181
|
-
//
|
|
29182
|
-
|
|
29183
|
-
|
|
29184
|
-
|
|
29185
|
-
|
|
29186
|
-
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
|
|
29192
|
-
|
|
29193
|
-
|
|
29194
|
-
|
|
29195
|
-
|
|
29196
|
-
|
|
29197
|
-
|
|
29198
|
-
|
|
29199
|
-
|
|
29200
|
-
|
|
29201
|
-
|
|
29202
|
-
|
|
29203
|
-
|
|
29204
|
-
|
|
31912
|
+
// node_modules/@iconify/core/lib/icon/list.js
|
|
31913
|
+
function listToIcons(list, validate3 = true, simpleNames = false) {
|
|
31914
|
+
const result = [];
|
|
31915
|
+
list.forEach((item) => {
|
|
31916
|
+
const icon = typeof item === "string" ? stringToIcon(item, validate3, simpleNames) : item;
|
|
31917
|
+
if (icon)
|
|
31918
|
+
result.push(icon);
|
|
31919
|
+
});
|
|
31920
|
+
return result;
|
|
31921
|
+
}
|
|
31922
|
+
|
|
31923
|
+
// node_modules/@iconify/core/lib/storage/functions.js
|
|
31924
|
+
var simpleNames = false;
|
|
31925
|
+
function allowSimpleNames(allow) {
|
|
31926
|
+
if (typeof allow === "boolean")
|
|
31927
|
+
simpleNames = allow;
|
|
31928
|
+
return simpleNames;
|
|
31929
|
+
}
|
|
31930
|
+
function getIconData(name) {
|
|
31931
|
+
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
|
|
31932
|
+
if (icon) {
|
|
31933
|
+
const storage2 = getStorage(icon.provider, icon.prefix);
|
|
31934
|
+
const iconName = icon.name;
|
|
31935
|
+
return storage2.icons[iconName] || (storage2.missing.has(iconName) ? null : undefined);
|
|
29205
31936
|
}
|
|
29206
|
-
}
|
|
29207
|
-
var definition_default27 = definition27;
|
|
31937
|
+
}
|
|
29208
31938
|
|
|
29209
|
-
//
|
|
29210
|
-
|
|
29211
|
-
|
|
29212
|
-
|
|
29213
|
-
|
|
29214
|
-
|
|
29215
|
-
|
|
29216
|
-
|
|
29217
|
-
|
|
29218
|
-
|
|
29219
|
-
|
|
29220
|
-
|
|
29221
|
-
|
|
31939
|
+
// node_modules/@iconify/core/lib/api/config.js
|
|
31940
|
+
function createAPIConfig(source) {
|
|
31941
|
+
let resources;
|
|
31942
|
+
if (typeof source.resources === "string")
|
|
31943
|
+
resources = [source.resources];
|
|
31944
|
+
else {
|
|
31945
|
+
resources = source.resources;
|
|
31946
|
+
if (!(resources instanceof Array) || !resources.length)
|
|
31947
|
+
return null;
|
|
31948
|
+
}
|
|
31949
|
+
const result = {
|
|
31950
|
+
resources,
|
|
31951
|
+
path: source.path || "/",
|
|
31952
|
+
maxURL: source.maxURL || 500,
|
|
31953
|
+
rotate: source.rotate || 750,
|
|
31954
|
+
timeout: source.timeout || 5000,
|
|
31955
|
+
random: source.random === true,
|
|
31956
|
+
index: source.index || 0,
|
|
31957
|
+
dataAfterTimeout: source.dataAfterTimeout !== false
|
|
29222
31958
|
};
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
|
|
31959
|
+
return result;
|
|
31960
|
+
}
|
|
31961
|
+
var configStorage = Object.create(null);
|
|
31962
|
+
var fallBackAPISources = ["https://api.simplesvg.com", "https://api.unisvg.com"];
|
|
31963
|
+
var fallBackAPI = [];
|
|
31964
|
+
while (fallBackAPISources.length > 0)
|
|
31965
|
+
if (fallBackAPISources.length === 1)
|
|
31966
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
31967
|
+
else if (Math.random() > 0.5)
|
|
31968
|
+
fallBackAPI.push(fallBackAPISources.shift());
|
|
31969
|
+
else
|
|
31970
|
+
fallBackAPI.push(fallBackAPISources.pop());
|
|
31971
|
+
configStorage[""] = createAPIConfig({ resources: ["https://api.iconify.design"].concat(fallBackAPI) });
|
|
31972
|
+
function getAPIConfig(provider) {
|
|
31973
|
+
return configStorage[provider];
|
|
31974
|
+
}
|
|
31975
|
+
|
|
31976
|
+
// node_modules/@iconify/api-redundancy/dist/index.mjs
|
|
31977
|
+
var defaultConfig = {
|
|
31978
|
+
resources: [],
|
|
31979
|
+
index: 0,
|
|
31980
|
+
timeout: 2000,
|
|
31981
|
+
rotate: 750,
|
|
31982
|
+
random: false,
|
|
31983
|
+
dataAfterTimeout: false
|
|
29226
31984
|
};
|
|
29227
|
-
|
|
31985
|
+
function sendQuery(config, payload, query, done) {
|
|
31986
|
+
const resourcesCount = config.resources.length;
|
|
31987
|
+
const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
|
|
31988
|
+
let resources;
|
|
31989
|
+
if (config.random) {
|
|
31990
|
+
let list = config.resources.slice(0);
|
|
31991
|
+
resources = [];
|
|
31992
|
+
while (list.length > 1) {
|
|
31993
|
+
const nextIndex = Math.floor(Math.random() * list.length);
|
|
31994
|
+
resources.push(list[nextIndex]);
|
|
31995
|
+
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
|
|
31996
|
+
}
|
|
31997
|
+
resources = resources.concat(list);
|
|
31998
|
+
} else {
|
|
31999
|
+
resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
32000
|
+
}
|
|
32001
|
+
const startTime = Date.now();
|
|
32002
|
+
let status = "pending";
|
|
32003
|
+
let queriesSent = 0;
|
|
32004
|
+
let lastError;
|
|
32005
|
+
let timer = null;
|
|
32006
|
+
let queue3 = [];
|
|
32007
|
+
let doneCallbacks = [];
|
|
32008
|
+
if (typeof done === "function") {
|
|
32009
|
+
doneCallbacks.push(done);
|
|
32010
|
+
}
|
|
32011
|
+
function resetTimer() {
|
|
32012
|
+
if (timer) {
|
|
32013
|
+
clearTimeout(timer);
|
|
32014
|
+
timer = null;
|
|
32015
|
+
}
|
|
32016
|
+
}
|
|
32017
|
+
function abort() {
|
|
32018
|
+
if (status === "pending") {
|
|
32019
|
+
status = "aborted";
|
|
32020
|
+
}
|
|
32021
|
+
resetTimer();
|
|
32022
|
+
queue3.forEach((item) => {
|
|
32023
|
+
if (item.status === "pending") {
|
|
32024
|
+
item.status = "aborted";
|
|
32025
|
+
}
|
|
32026
|
+
});
|
|
32027
|
+
queue3 = [];
|
|
32028
|
+
}
|
|
32029
|
+
function subscribe(callback, overwrite) {
|
|
32030
|
+
if (overwrite) {
|
|
32031
|
+
doneCallbacks = [];
|
|
32032
|
+
}
|
|
32033
|
+
if (typeof callback === "function") {
|
|
32034
|
+
doneCallbacks.push(callback);
|
|
32035
|
+
}
|
|
32036
|
+
}
|
|
32037
|
+
function getQueryStatus() {
|
|
32038
|
+
return {
|
|
32039
|
+
startTime,
|
|
32040
|
+
payload,
|
|
32041
|
+
status,
|
|
32042
|
+
queriesSent,
|
|
32043
|
+
queriesPending: queue3.length,
|
|
32044
|
+
subscribe,
|
|
32045
|
+
abort
|
|
32046
|
+
};
|
|
32047
|
+
}
|
|
32048
|
+
function failQuery() {
|
|
32049
|
+
status = "failed";
|
|
32050
|
+
doneCallbacks.forEach((callback) => {
|
|
32051
|
+
callback(undefined, lastError);
|
|
32052
|
+
});
|
|
32053
|
+
}
|
|
32054
|
+
function clearQueue() {
|
|
32055
|
+
queue3.forEach((item) => {
|
|
32056
|
+
if (item.status === "pending") {
|
|
32057
|
+
item.status = "aborted";
|
|
32058
|
+
}
|
|
32059
|
+
});
|
|
32060
|
+
queue3 = [];
|
|
32061
|
+
}
|
|
32062
|
+
function moduleResponse(item, response, data) {
|
|
32063
|
+
const isError = response !== "success";
|
|
32064
|
+
queue3 = queue3.filter((queued) => queued !== item);
|
|
32065
|
+
switch (status) {
|
|
32066
|
+
case "pending":
|
|
32067
|
+
break;
|
|
32068
|
+
case "failed":
|
|
32069
|
+
if (isError || !config.dataAfterTimeout) {
|
|
32070
|
+
return;
|
|
32071
|
+
}
|
|
32072
|
+
break;
|
|
32073
|
+
default:
|
|
32074
|
+
return;
|
|
32075
|
+
}
|
|
32076
|
+
if (response === "abort") {
|
|
32077
|
+
lastError = data;
|
|
32078
|
+
failQuery();
|
|
32079
|
+
return;
|
|
32080
|
+
}
|
|
32081
|
+
if (isError) {
|
|
32082
|
+
lastError = data;
|
|
32083
|
+
if (!queue3.length) {
|
|
32084
|
+
if (!resources.length) {
|
|
32085
|
+
failQuery();
|
|
32086
|
+
} else {
|
|
32087
|
+
execNext();
|
|
32088
|
+
}
|
|
32089
|
+
}
|
|
32090
|
+
return;
|
|
32091
|
+
}
|
|
32092
|
+
resetTimer();
|
|
32093
|
+
clearQueue();
|
|
32094
|
+
if (!config.random) {
|
|
32095
|
+
const index = config.resources.indexOf(item.resource);
|
|
32096
|
+
if (index !== -1 && index !== config.index) {
|
|
32097
|
+
config.index = index;
|
|
32098
|
+
}
|
|
32099
|
+
}
|
|
32100
|
+
status = "completed";
|
|
32101
|
+
doneCallbacks.forEach((callback) => {
|
|
32102
|
+
callback(data);
|
|
32103
|
+
});
|
|
32104
|
+
}
|
|
32105
|
+
function execNext() {
|
|
32106
|
+
if (status !== "pending") {
|
|
32107
|
+
return;
|
|
32108
|
+
}
|
|
32109
|
+
resetTimer();
|
|
32110
|
+
const resource = resources.shift();
|
|
32111
|
+
if (resource === undefined) {
|
|
32112
|
+
if (queue3.length) {
|
|
32113
|
+
timer = setTimeout(() => {
|
|
32114
|
+
resetTimer();
|
|
32115
|
+
if (status === "pending") {
|
|
32116
|
+
clearQueue();
|
|
32117
|
+
failQuery();
|
|
32118
|
+
}
|
|
32119
|
+
}, config.timeout);
|
|
32120
|
+
return;
|
|
32121
|
+
}
|
|
32122
|
+
failQuery();
|
|
32123
|
+
return;
|
|
32124
|
+
}
|
|
32125
|
+
const item = {
|
|
32126
|
+
status: "pending",
|
|
32127
|
+
resource,
|
|
32128
|
+
callback: (status2, data) => {
|
|
32129
|
+
moduleResponse(item, status2, data);
|
|
32130
|
+
}
|
|
32131
|
+
};
|
|
32132
|
+
queue3.push(item);
|
|
32133
|
+
queriesSent++;
|
|
32134
|
+
timer = setTimeout(execNext, config.rotate);
|
|
32135
|
+
query(resource, payload, item.callback);
|
|
32136
|
+
}
|
|
32137
|
+
setTimeout(execNext);
|
|
32138
|
+
return getQueryStatus;
|
|
32139
|
+
}
|
|
32140
|
+
function initRedundancy(cfg) {
|
|
32141
|
+
const config = {
|
|
32142
|
+
...defaultConfig,
|
|
32143
|
+
...cfg
|
|
32144
|
+
};
|
|
32145
|
+
let queries = [];
|
|
32146
|
+
function cleanup() {
|
|
32147
|
+
queries = queries.filter((item) => item().status === "pending");
|
|
32148
|
+
}
|
|
32149
|
+
function query(payload, queryCallback, doneCallback) {
|
|
32150
|
+
const query2 = sendQuery(config, payload, queryCallback, (data, error) => {
|
|
32151
|
+
cleanup();
|
|
32152
|
+
if (doneCallback) {
|
|
32153
|
+
doneCallback(data, error);
|
|
32154
|
+
}
|
|
32155
|
+
});
|
|
32156
|
+
queries.push(query2);
|
|
32157
|
+
return query2;
|
|
32158
|
+
}
|
|
32159
|
+
function find(callback) {
|
|
32160
|
+
return queries.find((value) => {
|
|
32161
|
+
return callback(value);
|
|
32162
|
+
}) || null;
|
|
32163
|
+
}
|
|
32164
|
+
const instance = {
|
|
32165
|
+
query,
|
|
32166
|
+
find,
|
|
32167
|
+
setIndex: (index) => {
|
|
32168
|
+
config.index = index;
|
|
32169
|
+
},
|
|
32170
|
+
getIndex: () => config.index,
|
|
32171
|
+
cleanup
|
|
32172
|
+
};
|
|
32173
|
+
return instance;
|
|
32174
|
+
}
|
|
29228
32175
|
|
|
29229
|
-
//
|
|
29230
|
-
|
|
29231
|
-
|
|
29232
|
-
|
|
29233
|
-
if (
|
|
29234
|
-
|
|
29235
|
-
|
|
29236
|
-
|
|
29237
|
-
|
|
29238
|
-
|
|
29239
|
-
|
|
29240
|
-
|
|
29241
|
-
|
|
32176
|
+
// node_modules/@iconify/core/lib/api/query.js
|
|
32177
|
+
function emptyCallback() {}
|
|
32178
|
+
var redundancyCache = Object.create(null);
|
|
32179
|
+
function getRedundancyCache(provider) {
|
|
32180
|
+
if (!redundancyCache[provider]) {
|
|
32181
|
+
const config = getAPIConfig(provider);
|
|
32182
|
+
if (!config)
|
|
32183
|
+
return;
|
|
32184
|
+
const redundancy = initRedundancy(config);
|
|
32185
|
+
const cachedReundancy = {
|
|
32186
|
+
config,
|
|
32187
|
+
redundancy
|
|
32188
|
+
};
|
|
32189
|
+
redundancyCache[provider] = cachedReundancy;
|
|
32190
|
+
}
|
|
32191
|
+
return redundancyCache[provider];
|
|
32192
|
+
}
|
|
32193
|
+
function sendAPIQuery(target, query, callback) {
|
|
32194
|
+
let redundancy;
|
|
32195
|
+
let send;
|
|
32196
|
+
if (typeof target === "string") {
|
|
32197
|
+
const api = getAPIModule(target);
|
|
32198
|
+
if (!api) {
|
|
32199
|
+
callback(undefined, 424);
|
|
32200
|
+
return emptyCallback;
|
|
32201
|
+
}
|
|
32202
|
+
send = api.send;
|
|
32203
|
+
const cached = getRedundancyCache(target);
|
|
32204
|
+
if (cached)
|
|
32205
|
+
redundancy = cached.redundancy;
|
|
32206
|
+
} else {
|
|
32207
|
+
const config = createAPIConfig(target);
|
|
32208
|
+
if (config) {
|
|
32209
|
+
redundancy = initRedundancy(config);
|
|
32210
|
+
const moduleKey = target.resources ? target.resources[0] : "";
|
|
32211
|
+
const api = getAPIModule(moduleKey);
|
|
32212
|
+
if (api)
|
|
32213
|
+
send = api.send;
|
|
32214
|
+
}
|
|
32215
|
+
}
|
|
32216
|
+
if (!redundancy || !send) {
|
|
32217
|
+
callback(undefined, 424);
|
|
32218
|
+
return emptyCallback;
|
|
32219
|
+
}
|
|
32220
|
+
return redundancy.query(query, send, callback)().abort;
|
|
32221
|
+
}
|
|
32222
|
+
|
|
32223
|
+
// node_modules/@iconify/core/lib/api/icons.js
|
|
32224
|
+
function emptyCallback2() {}
|
|
32225
|
+
function loadedNewIcons(storage2) {
|
|
32226
|
+
if (!storage2.iconsLoaderFlag) {
|
|
32227
|
+
storage2.iconsLoaderFlag = true;
|
|
32228
|
+
setTimeout(() => {
|
|
32229
|
+
storage2.iconsLoaderFlag = false;
|
|
32230
|
+
updateCallbacks(storage2);
|
|
32231
|
+
});
|
|
32232
|
+
}
|
|
32233
|
+
}
|
|
32234
|
+
function checkIconNamesForAPI(icons) {
|
|
32235
|
+
const valid = [];
|
|
32236
|
+
const invalid = [];
|
|
32237
|
+
icons.forEach((name) => {
|
|
32238
|
+
(name.match(matchIconName) ? valid : invalid).push(name);
|
|
32239
|
+
});
|
|
32240
|
+
return {
|
|
32241
|
+
valid,
|
|
32242
|
+
invalid
|
|
29242
32243
|
};
|
|
29243
|
-
|
|
29244
|
-
|
|
29245
|
-
|
|
32244
|
+
}
|
|
32245
|
+
function parseLoaderResponse(storage2, icons, data) {
|
|
32246
|
+
function checkMissing() {
|
|
32247
|
+
const pending = storage2.pendingIcons;
|
|
32248
|
+
icons.forEach((name) => {
|
|
32249
|
+
if (pending)
|
|
32250
|
+
pending.delete(name);
|
|
32251
|
+
if (!storage2.icons[name])
|
|
32252
|
+
storage2.missing.add(name);
|
|
32253
|
+
});
|
|
32254
|
+
}
|
|
32255
|
+
if (data && typeof data === "object")
|
|
32256
|
+
try {
|
|
32257
|
+
const parsed = addIconSet(storage2, data);
|
|
32258
|
+
if (!parsed.length) {
|
|
32259
|
+
checkMissing();
|
|
32260
|
+
return;
|
|
32261
|
+
}
|
|
32262
|
+
} catch (err) {
|
|
32263
|
+
console.error(err);
|
|
32264
|
+
}
|
|
32265
|
+
checkMissing();
|
|
32266
|
+
loadedNewIcons(storage2);
|
|
32267
|
+
}
|
|
32268
|
+
function parsePossiblyAsyncResponse(response, callback) {
|
|
32269
|
+
if (response instanceof Promise)
|
|
32270
|
+
response.then((data) => {
|
|
32271
|
+
callback(data);
|
|
32272
|
+
}).catch(() => {
|
|
32273
|
+
callback(null);
|
|
32274
|
+
});
|
|
32275
|
+
else
|
|
32276
|
+
callback(response);
|
|
32277
|
+
}
|
|
32278
|
+
function loadNewIcons(storage2, icons) {
|
|
32279
|
+
if (!storage2.iconsToLoad)
|
|
32280
|
+
storage2.iconsToLoad = icons;
|
|
32281
|
+
else
|
|
32282
|
+
storage2.iconsToLoad = storage2.iconsToLoad.concat(icons).sort();
|
|
32283
|
+
if (!storage2.iconsQueueFlag) {
|
|
32284
|
+
storage2.iconsQueueFlag = true;
|
|
32285
|
+
setTimeout(() => {
|
|
32286
|
+
storage2.iconsQueueFlag = false;
|
|
32287
|
+
const { provider, prefix } = storage2;
|
|
32288
|
+
const icons$1 = storage2.iconsToLoad;
|
|
32289
|
+
delete storage2.iconsToLoad;
|
|
32290
|
+
if (!icons$1 || !icons$1.length)
|
|
32291
|
+
return;
|
|
32292
|
+
const customIconLoader = storage2.loadIcon;
|
|
32293
|
+
if (storage2.loadIcons && (icons$1.length > 1 || !customIconLoader)) {
|
|
32294
|
+
parsePossiblyAsyncResponse(storage2.loadIcons(icons$1, prefix, provider), (data) => {
|
|
32295
|
+
parseLoaderResponse(storage2, icons$1, data);
|
|
32296
|
+
});
|
|
32297
|
+
return;
|
|
32298
|
+
}
|
|
32299
|
+
if (customIconLoader) {
|
|
32300
|
+
icons$1.forEach((name) => {
|
|
32301
|
+
const response = customIconLoader(name, prefix, provider);
|
|
32302
|
+
parsePossiblyAsyncResponse(response, (data) => {
|
|
32303
|
+
const iconSet = data ? {
|
|
32304
|
+
prefix,
|
|
32305
|
+
icons: { [name]: data }
|
|
32306
|
+
} : null;
|
|
32307
|
+
parseLoaderResponse(storage2, [name], iconSet);
|
|
32308
|
+
});
|
|
32309
|
+
});
|
|
32310
|
+
return;
|
|
32311
|
+
}
|
|
32312
|
+
const { valid, invalid } = checkIconNamesForAPI(icons$1);
|
|
32313
|
+
if (invalid.length)
|
|
32314
|
+
parseLoaderResponse(storage2, invalid, null);
|
|
32315
|
+
if (!valid.length)
|
|
32316
|
+
return;
|
|
32317
|
+
const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
|
|
32318
|
+
if (!api) {
|
|
32319
|
+
parseLoaderResponse(storage2, valid, null);
|
|
32320
|
+
return;
|
|
32321
|
+
}
|
|
32322
|
+
const params = api.prepare(provider, prefix, valid);
|
|
32323
|
+
params.forEach((item) => {
|
|
32324
|
+
sendAPIQuery(provider, item, (data) => {
|
|
32325
|
+
parseLoaderResponse(storage2, item.icons, data);
|
|
32326
|
+
});
|
|
32327
|
+
});
|
|
32328
|
+
});
|
|
32329
|
+
}
|
|
32330
|
+
}
|
|
32331
|
+
var loadIcons = (icons, callback) => {
|
|
32332
|
+
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
|
|
32333
|
+
const sortedIcons = sortIcons(cleanedIcons);
|
|
32334
|
+
if (!sortedIcons.pending.length) {
|
|
32335
|
+
let callCallback = true;
|
|
32336
|
+
if (callback)
|
|
32337
|
+
setTimeout(() => {
|
|
32338
|
+
if (callCallback)
|
|
32339
|
+
callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback2);
|
|
32340
|
+
});
|
|
32341
|
+
return () => {
|
|
32342
|
+
callCallback = false;
|
|
32343
|
+
};
|
|
32344
|
+
}
|
|
32345
|
+
const newIcons = Object.create(null);
|
|
32346
|
+
const sources = [];
|
|
32347
|
+
let lastProvider, lastPrefix;
|
|
32348
|
+
sortedIcons.pending.forEach((icon) => {
|
|
32349
|
+
const { provider, prefix } = icon;
|
|
32350
|
+
if (prefix === lastPrefix && provider === lastProvider)
|
|
32351
|
+
return;
|
|
32352
|
+
lastProvider = provider;
|
|
32353
|
+
lastPrefix = prefix;
|
|
32354
|
+
sources.push(getStorage(provider, prefix));
|
|
32355
|
+
const providerNewIcons = newIcons[provider] || (newIcons[provider] = Object.create(null));
|
|
32356
|
+
if (!providerNewIcons[prefix])
|
|
32357
|
+
providerNewIcons[prefix] = [];
|
|
32358
|
+
});
|
|
32359
|
+
sortedIcons.pending.forEach((icon) => {
|
|
32360
|
+
const { provider, prefix, name } = icon;
|
|
32361
|
+
const storage2 = getStorage(provider, prefix);
|
|
32362
|
+
const pendingQueue = storage2.pendingIcons || (storage2.pendingIcons = /* @__PURE__ */ new Set);
|
|
32363
|
+
if (!pendingQueue.has(name)) {
|
|
32364
|
+
pendingQueue.add(name);
|
|
32365
|
+
newIcons[provider][prefix].push(name);
|
|
32366
|
+
}
|
|
32367
|
+
});
|
|
32368
|
+
sources.forEach((storage2) => {
|
|
32369
|
+
const list = newIcons[storage2.provider][storage2.prefix];
|
|
32370
|
+
if (list.length)
|
|
32371
|
+
loadNewIcons(storage2, list);
|
|
32372
|
+
});
|
|
32373
|
+
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback2;
|
|
32374
|
+
};
|
|
32375
|
+
var loadIcon = (icon) => {
|
|
32376
|
+
return new Promise((fulfill, reject) => {
|
|
32377
|
+
const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
|
|
32378
|
+
if (!iconObj) {
|
|
32379
|
+
reject(icon);
|
|
32380
|
+
return;
|
|
32381
|
+
}
|
|
32382
|
+
loadIcons([iconObj || icon], (loaded) => {
|
|
32383
|
+
if (loaded.length && iconObj) {
|
|
32384
|
+
const data = getIconData(iconObj);
|
|
32385
|
+
if (data) {
|
|
32386
|
+
fulfill({
|
|
32387
|
+
...defaultIconProps,
|
|
32388
|
+
...data
|
|
32389
|
+
});
|
|
32390
|
+
return;
|
|
32391
|
+
}
|
|
32392
|
+
}
|
|
32393
|
+
reject(icon);
|
|
32394
|
+
});
|
|
32395
|
+
});
|
|
29246
32396
|
};
|
|
29247
|
-
var convertYiqToRgb_default = convertYiqToRgb;
|
|
29248
32397
|
|
|
29249
|
-
//
|
|
29250
|
-
var
|
|
29251
|
-
|
|
29252
|
-
|
|
29253
|
-
|
|
29254
|
-
|
|
29255
|
-
|
|
29256
|
-
|
|
29257
|
-
|
|
29258
|
-
|
|
29259
|
-
|
|
29260
|
-
|
|
29261
|
-
|
|
29262
|
-
|
|
29263
|
-
|
|
29264
|
-
|
|
29265
|
-
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
|
|
29269
|
-
|
|
32398
|
+
// node_modules/@iconify/core/lib/api/modules/fetch.js
|
|
32399
|
+
var detectFetch = () => {
|
|
32400
|
+
let callback;
|
|
32401
|
+
try {
|
|
32402
|
+
callback = fetch;
|
|
32403
|
+
if (typeof callback === "function")
|
|
32404
|
+
return callback;
|
|
32405
|
+
} catch (err) {}
|
|
32406
|
+
};
|
|
32407
|
+
var fetchModule = detectFetch();
|
|
32408
|
+
function calculateMaxLength(provider, prefix) {
|
|
32409
|
+
const config = getAPIConfig(provider);
|
|
32410
|
+
if (!config)
|
|
32411
|
+
return 0;
|
|
32412
|
+
let result;
|
|
32413
|
+
if (!config.maxURL)
|
|
32414
|
+
result = 0;
|
|
32415
|
+
else {
|
|
32416
|
+
let maxHostLength = 0;
|
|
32417
|
+
config.resources.forEach((item) => {
|
|
32418
|
+
const host = item;
|
|
32419
|
+
maxHostLength = Math.max(maxHostLength, host.length);
|
|
32420
|
+
});
|
|
32421
|
+
const url = prefix + ".json?icons=";
|
|
32422
|
+
result = config.maxURL - maxHostLength - config.path.length - url.length;
|
|
29270
32423
|
}
|
|
32424
|
+
return result;
|
|
32425
|
+
}
|
|
32426
|
+
function shouldAbort(status) {
|
|
32427
|
+
return status === 404;
|
|
32428
|
+
}
|
|
32429
|
+
var prepare2 = (provider, prefix, icons) => {
|
|
32430
|
+
const results = [];
|
|
32431
|
+
const maxLength = calculateMaxLength(provider, prefix);
|
|
32432
|
+
const type = "icons";
|
|
32433
|
+
let item = {
|
|
32434
|
+
type,
|
|
32435
|
+
provider,
|
|
32436
|
+
prefix,
|
|
32437
|
+
icons: []
|
|
32438
|
+
};
|
|
32439
|
+
let length = 0;
|
|
32440
|
+
icons.forEach((name, index) => {
|
|
32441
|
+
length += name.length + 1;
|
|
32442
|
+
if (length >= maxLength && index > 0) {
|
|
32443
|
+
results.push(item);
|
|
32444
|
+
item = {
|
|
32445
|
+
type,
|
|
32446
|
+
provider,
|
|
32447
|
+
prefix,
|
|
32448
|
+
icons: []
|
|
32449
|
+
};
|
|
32450
|
+
length = name.length;
|
|
32451
|
+
}
|
|
32452
|
+
item.icons.push(name);
|
|
32453
|
+
});
|
|
32454
|
+
results.push(item);
|
|
32455
|
+
return results;
|
|
32456
|
+
};
|
|
32457
|
+
function getPath(provider) {
|
|
32458
|
+
if (typeof provider === "string") {
|
|
32459
|
+
const config = getAPIConfig(provider);
|
|
32460
|
+
if (config)
|
|
32461
|
+
return config.path;
|
|
32462
|
+
}
|
|
32463
|
+
return "/";
|
|
32464
|
+
}
|
|
32465
|
+
var send = (host, params, callback) => {
|
|
32466
|
+
if (!fetchModule) {
|
|
32467
|
+
callback("abort", 424);
|
|
32468
|
+
return;
|
|
32469
|
+
}
|
|
32470
|
+
let path = getPath(params.provider);
|
|
32471
|
+
switch (params.type) {
|
|
32472
|
+
case "icons": {
|
|
32473
|
+
const prefix = params.prefix;
|
|
32474
|
+
const icons = params.icons;
|
|
32475
|
+
const iconsList = icons.join(",");
|
|
32476
|
+
const urlParams = new URLSearchParams({ icons: iconsList });
|
|
32477
|
+
path += prefix + ".json?" + urlParams.toString();
|
|
32478
|
+
break;
|
|
32479
|
+
}
|
|
32480
|
+
case "custom": {
|
|
32481
|
+
const uri = params.uri;
|
|
32482
|
+
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
|
|
32483
|
+
break;
|
|
32484
|
+
}
|
|
32485
|
+
default:
|
|
32486
|
+
callback("abort", 400);
|
|
32487
|
+
return;
|
|
32488
|
+
}
|
|
32489
|
+
let defaultError = 503;
|
|
32490
|
+
fetchModule(host + path).then((response) => {
|
|
32491
|
+
const status = response.status;
|
|
32492
|
+
if (status !== 200) {
|
|
32493
|
+
setTimeout(() => {
|
|
32494
|
+
callback(shouldAbort(status) ? "abort" : "next", status);
|
|
32495
|
+
});
|
|
32496
|
+
return;
|
|
32497
|
+
}
|
|
32498
|
+
defaultError = 501;
|
|
32499
|
+
return response.json();
|
|
32500
|
+
}).then((data) => {
|
|
32501
|
+
if (typeof data !== "object" || data === null) {
|
|
32502
|
+
setTimeout(() => {
|
|
32503
|
+
if (data === 404)
|
|
32504
|
+
callback("abort", data);
|
|
32505
|
+
else
|
|
32506
|
+
callback("next", defaultError);
|
|
32507
|
+
});
|
|
32508
|
+
return;
|
|
32509
|
+
}
|
|
32510
|
+
setTimeout(() => {
|
|
32511
|
+
callback("success", data);
|
|
32512
|
+
});
|
|
32513
|
+
}).catch(() => {
|
|
32514
|
+
callback("next", defaultError);
|
|
32515
|
+
});
|
|
32516
|
+
};
|
|
32517
|
+
var fetchAPIModule = {
|
|
32518
|
+
prepare: prepare2,
|
|
32519
|
+
send
|
|
29271
32520
|
};
|
|
29272
|
-
var definition_default28 = definition28;
|
|
29273
|
-
// packages/cli/node_modules/culori/src/index.js
|
|
29274
|
-
var a98 = useMode(definition_default2);
|
|
29275
|
-
var cubehelix = useMode(definition_default3);
|
|
29276
|
-
var dlab = useMode(definition_default4);
|
|
29277
|
-
var dlch = useMode(definition_default5);
|
|
29278
|
-
var hsi = useMode(definition_default6);
|
|
29279
|
-
var hsl = useMode(definition_default7);
|
|
29280
|
-
var hsv = useMode(definition_default8);
|
|
29281
|
-
var hwb = useMode(definition_default9);
|
|
29282
|
-
var itp = useMode(definition_default10);
|
|
29283
|
-
var jab = useMode(definition_default11);
|
|
29284
|
-
var jch = useMode(definition_default12);
|
|
29285
|
-
var lab = useMode(definition_default13);
|
|
29286
|
-
var lab65 = useMode(definition_default14);
|
|
29287
|
-
var lch = useMode(definition_default15);
|
|
29288
|
-
var lch65 = useMode(definition_default16);
|
|
29289
|
-
var lchuv = useMode(definition_default17);
|
|
29290
|
-
var lrgb = useMode(definition_default18);
|
|
29291
|
-
var luv = useMode(definition_default19);
|
|
29292
|
-
var okhsl = useMode(modeOkhsl_default);
|
|
29293
|
-
var okhsv = useMode(modeOkhsv_default);
|
|
29294
|
-
var oklab = useMode(definition_default20);
|
|
29295
|
-
var oklch = useMode(definition_default21);
|
|
29296
|
-
var p3 = useMode(definition_default22);
|
|
29297
|
-
var prophoto = useMode(definition_default23);
|
|
29298
|
-
var rec2020 = useMode(definition_default24);
|
|
29299
|
-
var rgb = useMode(definition_default);
|
|
29300
|
-
var xyb = useMode(definition_default25);
|
|
29301
|
-
var xyz50 = useMode(definition_default26);
|
|
29302
|
-
var xyz65 = useMode(definition_default27);
|
|
29303
|
-
var yiq = useMode(definition_default28);
|
|
29304
32521
|
|
|
29305
|
-
//
|
|
29306
|
-
var
|
|
29307
|
-
|
|
29308
|
-
|
|
29309
|
-
|
|
29310
|
-
|
|
32522
|
+
// node_modules/@iconify/utils/lib/customisations/defaults.js
|
|
32523
|
+
var defaultIconSizeCustomisations = Object.freeze({
|
|
32524
|
+
width: null,
|
|
32525
|
+
height: null
|
|
32526
|
+
});
|
|
32527
|
+
var defaultIconCustomisations = Object.freeze({
|
|
32528
|
+
...defaultIconSizeCustomisations,
|
|
32529
|
+
...defaultIconTransformations
|
|
32530
|
+
});
|
|
32531
|
+
|
|
32532
|
+
// node_modules/@iconify/utils/lib/svg/size.js
|
|
32533
|
+
var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
32534
|
+
var unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
32535
|
+
function calculateSize(size, ratio, precision) {
|
|
32536
|
+
if (ratio === 1)
|
|
32537
|
+
return size;
|
|
32538
|
+
precision = precision || 100;
|
|
32539
|
+
if (typeof size === "number")
|
|
32540
|
+
return Math.ceil(size * ratio * precision) / precision;
|
|
32541
|
+
if (typeof size !== "string")
|
|
32542
|
+
return size;
|
|
32543
|
+
const oldParts = size.split(unitsSplit);
|
|
32544
|
+
if (oldParts === null || !oldParts.length)
|
|
32545
|
+
return size;
|
|
32546
|
+
const newParts = [];
|
|
32547
|
+
let code = oldParts.shift();
|
|
32548
|
+
let isNumber = unitsTest.test(code);
|
|
32549
|
+
while (true) {
|
|
32550
|
+
if (isNumber) {
|
|
32551
|
+
const num3 = parseFloat(code);
|
|
32552
|
+
if (isNaN(num3))
|
|
32553
|
+
newParts.push(code);
|
|
32554
|
+
else
|
|
32555
|
+
newParts.push(Math.ceil(num3 * ratio * precision) / precision);
|
|
32556
|
+
} else
|
|
32557
|
+
newParts.push(code);
|
|
32558
|
+
code = oldParts.shift();
|
|
32559
|
+
if (code === undefined)
|
|
32560
|
+
return newParts.join("");
|
|
32561
|
+
isNumber = !isNumber;
|
|
32562
|
+
}
|
|
32563
|
+
}
|
|
32564
|
+
|
|
32565
|
+
// node_modules/@iconify/utils/lib/svg/defs.js
|
|
32566
|
+
function splitSVGDefs(content, tag = "defs") {
|
|
32567
|
+
let defs = "";
|
|
32568
|
+
const index = content.indexOf("<" + tag);
|
|
32569
|
+
while (index >= 0) {
|
|
32570
|
+
const start = content.indexOf(">", index);
|
|
32571
|
+
const end = content.indexOf("</" + tag);
|
|
32572
|
+
if (start === -1 || end === -1)
|
|
32573
|
+
break;
|
|
32574
|
+
const endEnd = content.indexOf(">", end);
|
|
32575
|
+
if (endEnd === -1)
|
|
32576
|
+
break;
|
|
32577
|
+
defs += content.slice(start + 1, end).trim();
|
|
32578
|
+
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
|
|
29311
32579
|
}
|
|
29312
|
-
const rgb2 = toRgb(parsed);
|
|
29313
32580
|
return {
|
|
29314
|
-
|
|
29315
|
-
|
|
29316
|
-
b: rgb2?.b ?? 0,
|
|
29317
|
-
a: parsed.alpha ?? 1
|
|
32581
|
+
defs,
|
|
32582
|
+
content
|
|
29318
32583
|
};
|
|
29319
32584
|
}
|
|
32585
|
+
function mergeDefsAndContent(defs, content) {
|
|
32586
|
+
return defs ? "<defs>" + defs + "</defs>" + content : content;
|
|
32587
|
+
}
|
|
32588
|
+
function wrapSVGContent(body, start, end) {
|
|
32589
|
+
const split = splitSVGDefs(body);
|
|
32590
|
+
return mergeDefsAndContent(split.defs, start + split.content + end);
|
|
32591
|
+
}
|
|
29320
32592
|
|
|
29321
|
-
//
|
|
29322
|
-
|
|
29323
|
-
|
|
29324
|
-
|
|
29325
|
-
|
|
29326
|
-
|
|
29327
|
-
|
|
29328
|
-
|
|
29329
|
-
|
|
32593
|
+
// node_modules/@iconify/utils/lib/svg/build.js
|
|
32594
|
+
var isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
32595
|
+
function iconToSVG(icon, customisations) {
|
|
32596
|
+
const fullIcon = {
|
|
32597
|
+
...defaultIconProps,
|
|
32598
|
+
...icon
|
|
32599
|
+
};
|
|
32600
|
+
const fullCustomisations = {
|
|
32601
|
+
...defaultIconCustomisations,
|
|
32602
|
+
...customisations
|
|
32603
|
+
};
|
|
32604
|
+
const box3 = {
|
|
32605
|
+
left: fullIcon.left,
|
|
32606
|
+
top: fullIcon.top,
|
|
32607
|
+
width: fullIcon.width,
|
|
32608
|
+
height: fullIcon.height
|
|
32609
|
+
};
|
|
32610
|
+
let body = fullIcon.body;
|
|
32611
|
+
[fullIcon, fullCustomisations].forEach((props) => {
|
|
32612
|
+
const transformations = [];
|
|
32613
|
+
const hFlip = props.hFlip;
|
|
32614
|
+
const vFlip = props.vFlip;
|
|
32615
|
+
let rotation = props.rotate;
|
|
32616
|
+
if (hFlip)
|
|
32617
|
+
if (vFlip)
|
|
32618
|
+
rotation += 2;
|
|
32619
|
+
else {
|
|
32620
|
+
transformations.push("translate(" + (box3.width + box3.left).toString() + " " + (0 - box3.top).toString() + ")");
|
|
32621
|
+
transformations.push("scale(-1 1)");
|
|
32622
|
+
box3.top = box3.left = 0;
|
|
32623
|
+
}
|
|
32624
|
+
else if (vFlip) {
|
|
32625
|
+
transformations.push("translate(" + (0 - box3.left).toString() + " " + (box3.height + box3.top).toString() + ")");
|
|
32626
|
+
transformations.push("scale(1 -1)");
|
|
32627
|
+
box3.top = box3.left = 0;
|
|
32628
|
+
}
|
|
32629
|
+
let tempValue;
|
|
32630
|
+
if (rotation < 0)
|
|
32631
|
+
rotation -= Math.floor(rotation / 4) * 4;
|
|
32632
|
+
rotation = rotation % 4;
|
|
32633
|
+
switch (rotation) {
|
|
32634
|
+
case 1:
|
|
32635
|
+
tempValue = box3.height / 2 + box3.top;
|
|
32636
|
+
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
32637
|
+
break;
|
|
32638
|
+
case 2:
|
|
32639
|
+
transformations.unshift("rotate(180 " + (box3.width / 2 + box3.left).toString() + " " + (box3.height / 2 + box3.top).toString() + ")");
|
|
32640
|
+
break;
|
|
32641
|
+
case 3:
|
|
32642
|
+
tempValue = box3.width / 2 + box3.left;
|
|
32643
|
+
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
32644
|
+
break;
|
|
32645
|
+
}
|
|
32646
|
+
if (rotation % 2 === 1) {
|
|
32647
|
+
if (box3.left !== box3.top) {
|
|
32648
|
+
tempValue = box3.left;
|
|
32649
|
+
box3.left = box3.top;
|
|
32650
|
+
box3.top = tempValue;
|
|
32651
|
+
}
|
|
32652
|
+
if (box3.width !== box3.height) {
|
|
32653
|
+
tempValue = box3.width;
|
|
32654
|
+
box3.width = box3.height;
|
|
32655
|
+
box3.height = tempValue;
|
|
32656
|
+
}
|
|
32657
|
+
}
|
|
32658
|
+
if (transformations.length)
|
|
32659
|
+
body = wrapSVGContent(body, '<g transform="' + transformations.join(" ") + '">', "</g>");
|
|
32660
|
+
});
|
|
32661
|
+
const customisationsWidth = fullCustomisations.width;
|
|
32662
|
+
const customisationsHeight = fullCustomisations.height;
|
|
32663
|
+
const boxWidth = box3.width;
|
|
32664
|
+
const boxHeight = box3.height;
|
|
32665
|
+
let width;
|
|
32666
|
+
let height;
|
|
32667
|
+
if (customisationsWidth === null) {
|
|
32668
|
+
height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
32669
|
+
width = calculateSize(height, boxWidth / boxHeight);
|
|
32670
|
+
} else {
|
|
32671
|
+
width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
|
|
32672
|
+
height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
32673
|
+
}
|
|
32674
|
+
const attributes = {};
|
|
32675
|
+
const setAttr = (prop, value) => {
|
|
32676
|
+
if (!isUnsetKeyword(value))
|
|
32677
|
+
attributes[prop] = value.toString();
|
|
32678
|
+
};
|
|
32679
|
+
setAttr("width", width);
|
|
32680
|
+
setAttr("height", height);
|
|
32681
|
+
const viewBox = [
|
|
32682
|
+
box3.left,
|
|
32683
|
+
box3.top,
|
|
32684
|
+
boxWidth,
|
|
32685
|
+
boxHeight
|
|
32686
|
+
];
|
|
32687
|
+
attributes.viewBox = viewBox.join(" ");
|
|
32688
|
+
return {
|
|
32689
|
+
attributes,
|
|
32690
|
+
viewBox,
|
|
32691
|
+
body
|
|
32692
|
+
};
|
|
29330
32693
|
}
|
|
29331
|
-
var c6 = (type) => (props) => React.createElement(type, props);
|
|
29332
|
-
var Frame = c6("frame");
|
|
29333
|
-
var Rectangle = c6("rectangle");
|
|
29334
|
-
var Ellipse = c6("ellipse");
|
|
29335
|
-
var Text = c6("text");
|
|
29336
|
-
var Line = c6("line");
|
|
29337
|
-
var Star = c6("star");
|
|
29338
|
-
var Polygon = c6("polygon");
|
|
29339
|
-
var Vector = c6("vector");
|
|
29340
|
-
var Component = c6("component");
|
|
29341
|
-
var Instance = c6("instance");
|
|
29342
|
-
var Group = c6("group");
|
|
29343
|
-
var Page = c6("page");
|
|
29344
|
-
var INTRINSIC_ELEMENTS = [
|
|
29345
|
-
"Frame",
|
|
29346
|
-
"Rectangle",
|
|
29347
|
-
"Ellipse",
|
|
29348
|
-
"Text",
|
|
29349
|
-
"Line",
|
|
29350
|
-
"Star",
|
|
29351
|
-
"Polygon",
|
|
29352
|
-
"Vector",
|
|
29353
|
-
"Component",
|
|
29354
|
-
"Instance",
|
|
29355
|
-
"Group",
|
|
29356
|
-
"Page",
|
|
29357
|
-
"View"
|
|
29358
|
-
];
|
|
29359
32694
|
|
|
29360
|
-
// packages/cli/src/render/
|
|
29361
|
-
|
|
29362
|
-
var
|
|
29363
|
-
|
|
29364
|
-
|
|
32695
|
+
// packages/cli/src/render/icon.ts
|
|
32696
|
+
setAPIModule("", fetchAPIModule);
|
|
32697
|
+
var iconCache = new Map;
|
|
32698
|
+
var rawIconCache = new Map;
|
|
32699
|
+
async function loadRawIcon(name) {
|
|
32700
|
+
if (rawIconCache.has(name)) {
|
|
32701
|
+
return rawIconCache.get(name);
|
|
32702
|
+
}
|
|
32703
|
+
const icon = await loadIcon(name);
|
|
32704
|
+
if (!icon) {
|
|
32705
|
+
return null;
|
|
32706
|
+
}
|
|
32707
|
+
rawIconCache.set(name, icon);
|
|
32708
|
+
return icon;
|
|
29365
32709
|
}
|
|
29366
|
-
function
|
|
29367
|
-
const
|
|
29368
|
-
if (
|
|
29369
|
-
return
|
|
29370
|
-
|
|
29371
|
-
|
|
29372
|
-
|
|
29373
|
-
|
|
32710
|
+
async function loadIconSvg(name, size = 24) {
|
|
32711
|
+
const cacheKey = `${name}@${size}`;
|
|
32712
|
+
if (iconCache.has(cacheKey)) {
|
|
32713
|
+
return iconCache.get(cacheKey);
|
|
32714
|
+
}
|
|
32715
|
+
const icon = await loadRawIcon(name);
|
|
32716
|
+
if (!icon) {
|
|
32717
|
+
return null;
|
|
32718
|
+
}
|
|
32719
|
+
const result = iconToSVG(icon, { height: size, width: size });
|
|
32720
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" ${Object.entries(result.attributes).map(([k6, v3]) => `${k6}="${v3}"`).join(" ")}>${result.body}</svg>`;
|
|
32721
|
+
const data = {
|
|
32722
|
+
svg,
|
|
32723
|
+
width: size,
|
|
32724
|
+
height: size,
|
|
32725
|
+
body: result.body,
|
|
32726
|
+
viewBox: {
|
|
32727
|
+
left: result.viewBox[0],
|
|
32728
|
+
top: result.viewBox[1],
|
|
32729
|
+
width: result.viewBox[2],
|
|
32730
|
+
height: result.viewBox[3]
|
|
32731
|
+
}
|
|
32732
|
+
};
|
|
32733
|
+
iconCache.set(cacheKey, data);
|
|
32734
|
+
return data;
|
|
32735
|
+
}
|
|
32736
|
+
function getIconData2(name, size = 24) {
|
|
32737
|
+
return iconCache.get(`${name}@${size}`) || null;
|
|
32738
|
+
}
|
|
32739
|
+
async function preloadIcons(icons) {
|
|
32740
|
+
await Promise.all(icons.map(({ name, size }) => loadIconSvg(name, size || 24)));
|
|
32741
|
+
}
|
|
32742
|
+
function collectIcons(element) {
|
|
32743
|
+
const icons = [];
|
|
32744
|
+
function traverse(node) {
|
|
32745
|
+
if (!node || typeof node !== "object")
|
|
32746
|
+
return;
|
|
32747
|
+
if (Array.isArray(node)) {
|
|
32748
|
+
node.forEach(traverse);
|
|
29374
32749
|
return;
|
|
29375
32750
|
}
|
|
29376
|
-
const
|
|
29377
|
-
|
|
29378
|
-
|
|
32751
|
+
const el = node;
|
|
32752
|
+
if (!el.type)
|
|
32753
|
+
return;
|
|
32754
|
+
if (el.type === "icon") {
|
|
32755
|
+
const props2 = el.props;
|
|
32756
|
+
if (props2.icon) {
|
|
32757
|
+
icons.push({ name: props2.icon, size: props2.size });
|
|
32758
|
+
}
|
|
32759
|
+
}
|
|
32760
|
+
if (typeof el.type === "function") {
|
|
32761
|
+
try {
|
|
32762
|
+
const Component2 = el.type;
|
|
32763
|
+
const rendered = Component2(el.props);
|
|
32764
|
+
if (rendered)
|
|
32765
|
+
traverse(rendered);
|
|
32766
|
+
} catch {}
|
|
32767
|
+
}
|
|
32768
|
+
const props = el.props;
|
|
32769
|
+
if (props.children) {
|
|
32770
|
+
if (Array.isArray(props.children)) {
|
|
32771
|
+
props.children.forEach(traverse);
|
|
32772
|
+
} else {
|
|
32773
|
+
traverse(props.children);
|
|
32774
|
+
}
|
|
29379
32775
|
}
|
|
29380
32776
|
}
|
|
29381
|
-
|
|
29382
|
-
return
|
|
29383
|
-
}
|
|
29384
|
-
function buildVariantName(props) {
|
|
29385
|
-
return Object.entries(props).map(([k6, v3]) => `${k6}=${v3}`).join(", ");
|
|
29386
|
-
}
|
|
29387
|
-
function buildStateGroupPropertyValueOrders(variants) {
|
|
29388
|
-
return Object.entries(variants).map(([property, values]) => ({
|
|
29389
|
-
property,
|
|
29390
|
-
values: [...values]
|
|
29391
|
-
}));
|
|
32777
|
+
traverse(element);
|
|
32778
|
+
return icons;
|
|
29392
32779
|
}
|
|
29393
32780
|
|
|
29394
32781
|
// packages/cli/src/render/reconciler.ts
|
|
@@ -29402,8 +32789,15 @@ function getPendingComponentSetInstances() {
|
|
|
29402
32789
|
function clearPendingComponentSetInstances() {
|
|
29403
32790
|
pendingComponentSetInstances.length = 0;
|
|
29404
32791
|
}
|
|
32792
|
+
var pendingIcons = [];
|
|
32793
|
+
function getPendingIcons() {
|
|
32794
|
+
return [...pendingIcons];
|
|
32795
|
+
}
|
|
32796
|
+
function clearPendingIcons() {
|
|
32797
|
+
pendingIcons.length = 0;
|
|
32798
|
+
}
|
|
29405
32799
|
function styleToNodeChange(type, props, localID, sessionID, parentGUID, position, textContent) {
|
|
29406
|
-
const style = props.style || {};
|
|
32800
|
+
const style = normalizeStyle(props.style || {});
|
|
29407
32801
|
const name = props.name || type;
|
|
29408
32802
|
const nodeChange = {
|
|
29409
32803
|
guid: { sessionID, localID },
|
|
@@ -29414,6 +32808,9 @@ function styleToNodeChange(type, props, localID, sessionID, parentGUID, position
|
|
|
29414
32808
|
visible: true,
|
|
29415
32809
|
opacity: typeof style.opacity === "number" ? style.opacity : 1
|
|
29416
32810
|
};
|
|
32811
|
+
if (mapType(type) === "FRAME") {
|
|
32812
|
+
nodeChange.clipsContent = false;
|
|
32813
|
+
}
|
|
29417
32814
|
const width = style.width ?? props.width;
|
|
29418
32815
|
const height = style.height ?? props.height;
|
|
29419
32816
|
if (width !== undefined && height !== undefined) {
|
|
@@ -29565,23 +32962,22 @@ function styleToNodeChange(type, props, localID, sessionID, parentGUID, position
|
|
|
29565
32962
|
}
|
|
29566
32963
|
}
|
|
29567
32964
|
if (type.toLowerCase() === "text" && textContent) {
|
|
29568
|
-
|
|
29569
|
-
|
|
29570
|
-
|
|
29571
|
-
nc.textAlignVertical = "TOP";
|
|
32965
|
+
nodeChange.textData = { characters: textContent };
|
|
32966
|
+
nodeChange.textAutoResize = "WIDTH_AND_HEIGHT";
|
|
32967
|
+
nodeChange.textAlignVertical = "TOP";
|
|
29572
32968
|
if (style.fontSize)
|
|
29573
|
-
|
|
29574
|
-
|
|
32969
|
+
nodeChange.fontSize = Number(style.fontSize);
|
|
32970
|
+
nodeChange.lineHeight = { value: 100, units: "PERCENT" };
|
|
29575
32971
|
const family = style.fontFamily || "Inter";
|
|
29576
32972
|
const fontStyle = mapFontWeight(style.fontWeight);
|
|
29577
|
-
|
|
32973
|
+
nodeChange.fontName = {
|
|
29578
32974
|
family,
|
|
29579
32975
|
style: fontStyle,
|
|
29580
32976
|
postscript: `${family}-${fontStyle}`.replace(/\s+/g, "")
|
|
29581
32977
|
};
|
|
29582
32978
|
if (style.textAlign) {
|
|
29583
32979
|
const map = { left: "LEFT", center: "CENTER", right: "RIGHT" };
|
|
29584
|
-
|
|
32980
|
+
nodeChange.textAlignHorizontal = map[style.textAlign] || "LEFT";
|
|
29585
32981
|
}
|
|
29586
32982
|
if (style.color) {
|
|
29587
32983
|
const textColor = style.color;
|
|
@@ -29615,8 +33011,7 @@ function styleToNodeChange(type, props, localID, sessionID, parentGUID, position
|
|
|
29615
33011
|
if (type.toLowerCase() === "instance" && props.componentId) {
|
|
29616
33012
|
const match = String(props.componentId).match(/(\d+):(\d+)/);
|
|
29617
33013
|
if (match) {
|
|
29618
|
-
|
|
29619
|
-
nc.symbolData = {
|
|
33014
|
+
nodeChange.symbolData = {
|
|
29620
33015
|
symbolID: {
|
|
29621
33016
|
sessionID: parseInt(match[1], 10),
|
|
29622
33017
|
localID: parseInt(match[2], 10)
|
|
@@ -29661,7 +33056,31 @@ function mapFontWeight(weight) {
|
|
|
29661
33056
|
};
|
|
29662
33057
|
return map[weight] || "Regular";
|
|
29663
33058
|
}
|
|
29664
|
-
function collectNodeChanges(instance, sessionID, parentGUID, position, result, container) {
|
|
33059
|
+
function collectNodeChanges(instance, sessionID, parentGUID, position, childIndex, result, container) {
|
|
33060
|
+
if (instance.type === "icon") {
|
|
33061
|
+
const props = instance.props;
|
|
33062
|
+
const { icon: iconName, size = 24, color, name: nodeName, style = {} } = props;
|
|
33063
|
+
const iconData = getIconData2(iconName, size);
|
|
33064
|
+
if (!iconData) {
|
|
33065
|
+
consola2.error(`Icon "${iconName}" not found. Did you call preloadIcons()?`);
|
|
33066
|
+
return;
|
|
33067
|
+
}
|
|
33068
|
+
let svg = iconData.svg;
|
|
33069
|
+
if (color) {
|
|
33070
|
+
svg = svg.replace(/currentColor/g, color);
|
|
33071
|
+
} else {
|
|
33072
|
+
svg = svg.replace(/currentColor/g, "#000000");
|
|
33073
|
+
}
|
|
33074
|
+
pendingIcons.push({
|
|
33075
|
+
svg,
|
|
33076
|
+
parentGUID,
|
|
33077
|
+
childIndex,
|
|
33078
|
+
x: style.x || 0,
|
|
33079
|
+
y: style.y || 0,
|
|
33080
|
+
name: nodeName || iconName.replace(":", "/")
|
|
33081
|
+
});
|
|
33082
|
+
return;
|
|
33083
|
+
}
|
|
29665
33084
|
if (instance.type === "__component_instance__") {
|
|
29666
33085
|
const sym = instance.props.__componentSymbol;
|
|
29667
33086
|
const name = instance.props.__componentName;
|
|
@@ -29682,8 +33101,8 @@ function collectNodeChanges(instance, sessionID, parentGUID, position, result, c
|
|
|
29682
33101
|
startLocalID: container.localIDCounter
|
|
29683
33102
|
});
|
|
29684
33103
|
container.localIDCounter = componentResult.nextLocalID;
|
|
29685
|
-
|
|
29686
|
-
|
|
33104
|
+
const rootChange = componentResult.nodeChanges[0];
|
|
33105
|
+
if (rootChange) {
|
|
29687
33106
|
const originalRootGUID = { ...rootChange.guid };
|
|
29688
33107
|
rootChange.guid = componentGUID;
|
|
29689
33108
|
rootChange.type = "SYMBOL";
|
|
@@ -29691,7 +33110,7 @@ function collectNodeChanges(instance, sessionID, parentGUID, position, result, c
|
|
|
29691
33110
|
rootChange.parentIndex = { guid: parentGUID, position };
|
|
29692
33111
|
for (let i3 = 1;i3 < componentResult.nodeChanges.length; i3++) {
|
|
29693
33112
|
const child = componentResult.nodeChanges[i3];
|
|
29694
|
-
if (child.parentIndex?.guid.localID === originalRootGUID.localID && child.parentIndex?.guid.sessionID === originalRootGUID.sessionID) {
|
|
33113
|
+
if (child && child.parentIndex?.guid.localID === originalRootGUID.localID && child.parentIndex?.guid.sessionID === originalRootGUID.sessionID) {
|
|
29695
33114
|
child.parentIndex.guid = componentGUID;
|
|
29696
33115
|
}
|
|
29697
33116
|
}
|
|
@@ -29718,8 +33137,7 @@ function collectNodeChanges(instance, sessionID, parentGUID, position, result, c
|
|
|
29718
33137
|
opacity: 1,
|
|
29719
33138
|
transform: { m00: 1, m01: 0, m02: x3, m10: 0, m11: 1, m12: y5 }
|
|
29720
33139
|
};
|
|
29721
|
-
|
|
29722
|
-
nc.symbolData = { symbolID: componentGUID };
|
|
33140
|
+
instanceChange.symbolData = { symbolID: componentGUID };
|
|
29723
33141
|
result.push(instanceChange);
|
|
29724
33142
|
}
|
|
29725
33143
|
return;
|
|
@@ -29752,13 +33170,12 @@ function collectNodeChanges(instance, sessionID, parentGUID, position, result, c
|
|
|
29752
33170
|
opacity: 1,
|
|
29753
33171
|
size: { x: 1, y: 1 }
|
|
29754
33172
|
};
|
|
29755
|
-
|
|
29756
|
-
|
|
29757
|
-
|
|
29758
|
-
|
|
29759
|
-
|
|
29760
|
-
|
|
29761
|
-
setNc.stackCounterSizing = "RESIZE_TO_FIT";
|
|
33173
|
+
setChange.isStateGroup = true;
|
|
33174
|
+
setChange.stateGroupPropertyValueOrders = buildStateGroupPropertyValueOrders(variants);
|
|
33175
|
+
setChange.stackMode = "HORIZONTAL";
|
|
33176
|
+
setChange.stackSpacing = 20;
|
|
33177
|
+
setChange.stackPrimarySizing = "RESIZE_TO_FIT";
|
|
33178
|
+
setChange.stackCounterSizing = "RESIZE_TO_FIT";
|
|
29762
33179
|
result.push(setChange);
|
|
29763
33180
|
combinations.forEach((combo, i3) => {
|
|
29764
33181
|
const variantName = buildVariantName(combo);
|
|
@@ -29772,8 +33189,8 @@ function collectNodeChanges(instance, sessionID, parentGUID, position, result, c
|
|
|
29772
33189
|
startLocalID: container.localIDCounter
|
|
29773
33190
|
});
|
|
29774
33191
|
container.localIDCounter = variantResult.nextLocalID;
|
|
29775
|
-
|
|
29776
|
-
|
|
33192
|
+
const rootChange = variantResult.nodeChanges[0];
|
|
33193
|
+
if (rootChange) {
|
|
29777
33194
|
const originalRootGUID = { ...rootChange.guid };
|
|
29778
33195
|
rootChange.guid = variantGUID;
|
|
29779
33196
|
rootChange.type = "SYMBOL";
|
|
@@ -29784,7 +33201,7 @@ function collectNodeChanges(instance, sessionID, parentGUID, position, result, c
|
|
|
29784
33201
|
};
|
|
29785
33202
|
for (let j = 1;j < variantResult.nodeChanges.length; j++) {
|
|
29786
33203
|
const child = variantResult.nodeChanges[j];
|
|
29787
|
-
if (child.parentIndex?.guid.localID === originalRootGUID.localID && child.parentIndex?.guid.sessionID === originalRootGUID.sessionID) {
|
|
33204
|
+
if (child && child.parentIndex?.guid.localID === originalRootGUID.localID && child.parentIndex?.guid.sessionID === originalRootGUID.sessionID) {
|
|
29788
33205
|
child.parentIndex.guid = variantGUID;
|
|
29789
33206
|
}
|
|
29790
33207
|
}
|
|
@@ -29827,7 +33244,7 @@ function collectNodeChanges(instance, sessionID, parentGUID, position, result, c
|
|
|
29827
33244
|
const thisGUID = { sessionID, localID: instance.localID };
|
|
29828
33245
|
instance.children.forEach((child, i3) => {
|
|
29829
33246
|
const childPosition = String.fromCharCode(33 + i3 % 90);
|
|
29830
|
-
collectNodeChanges(child, sessionID, thisGUID, childPosition, result, container);
|
|
33247
|
+
collectNodeChanges(child, sessionID, thisGUID, childPosition, i3, result, container);
|
|
29831
33248
|
});
|
|
29832
33249
|
}
|
|
29833
33250
|
var hostConfig = {
|
|
@@ -29966,7 +33383,7 @@ function renderToNodeChanges(element, options) {
|
|
|
29966
33383
|
const nodeChanges = [];
|
|
29967
33384
|
container.children.forEach((child, i3) => {
|
|
29968
33385
|
const position = String.fromCharCode(33 + i3 % 90);
|
|
29969
|
-
collectNodeChanges(child, options.sessionID, options.parentGUID, position, nodeChanges, container);
|
|
33386
|
+
collectNodeChanges(child, options.sessionID, options.parentGUID, position, i3, nodeChanges, container);
|
|
29970
33387
|
});
|
|
29971
33388
|
return {
|
|
29972
33389
|
nodeChanges,
|
|
@@ -29976,8 +33393,9 @@ function renderToNodeChanges(element, options) {
|
|
|
29976
33393
|
function getDefaultVariants(variants) {
|
|
29977
33394
|
const defaults = {};
|
|
29978
33395
|
for (const [key, values] of Object.entries(variants)) {
|
|
29979
|
-
|
|
29980
|
-
|
|
33396
|
+
const firstValue = values[0];
|
|
33397
|
+
if (firstValue !== undefined) {
|
|
33398
|
+
defaults[key] = firstValue;
|
|
29981
33399
|
}
|
|
29982
33400
|
}
|
|
29983
33401
|
return defaults;
|
|
@@ -29990,6 +33408,13 @@ function resetRenderedComponents() {
|
|
|
29990
33408
|
}
|
|
29991
33409
|
// packages/cli/src/commands/render.ts
|
|
29992
33410
|
var import_esbuild = __toESM(require_main(), 1);
|
|
33411
|
+
|
|
33412
|
+
// packages/cli/src/retry.ts
|
|
33413
|
+
function sleep(ms) {
|
|
33414
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
33415
|
+
}
|
|
33416
|
+
|
|
33417
|
+
// packages/cli/src/commands/render.ts
|
|
29993
33418
|
var PROXY_URL2 = process.env.FIGMA_PROXY_URL || "http://localhost:38451";
|
|
29994
33419
|
async function readStdin() {
|
|
29995
33420
|
const chunks = [];
|
|
@@ -30105,9 +33530,11 @@ var render_default = defineCommand({
|
|
|
30105
33530
|
stdin: { type: "boolean", description: "Read TSX from stdin" },
|
|
30106
33531
|
props: { type: "string", description: "JSON props to pass to component" },
|
|
30107
33532
|
parent: { type: "string", description: "Parent node ID (sessionID:localID)" },
|
|
33533
|
+
x: { type: "string", description: "X position of rendered root" },
|
|
33534
|
+
y: { type: "string", description: "Y position of rendered root" },
|
|
30108
33535
|
export: { type: "string", description: "Named export (default: default)" },
|
|
30109
33536
|
json: { type: "boolean", description: "Output as JSON" },
|
|
30110
|
-
|
|
33537
|
+
"dry-run": { type: "boolean", description: "Output NodeChanges without sending to Figma" }
|
|
30111
33538
|
},
|
|
30112
33539
|
async run({ args }) {
|
|
30113
33540
|
if (args.examples) {
|
|
@@ -30184,13 +33611,27 @@ var render_default = defineCommand({
|
|
|
30184
33611
|
}
|
|
30185
33612
|
const props = args.props ? JSON.parse(args.props) : {};
|
|
30186
33613
|
const element = React3.createElement(Component2, props);
|
|
33614
|
+
const icons = collectIcons(element);
|
|
33615
|
+
if (icons.length > 0) {
|
|
33616
|
+
if (!args.json) {
|
|
33617
|
+
console.log(`Preloading ${icons.length} icon(s)...`);
|
|
33618
|
+
}
|
|
33619
|
+
await preloadIcons(icons);
|
|
33620
|
+
}
|
|
30187
33621
|
resetRenderedComponents();
|
|
30188
33622
|
const result = renderToNodeChanges(element, {
|
|
30189
33623
|
sessionID,
|
|
30190
33624
|
parentGUID,
|
|
30191
33625
|
startLocalID: Date.now() % 1e6
|
|
30192
33626
|
});
|
|
30193
|
-
|
|
33627
|
+
const rootNode = result.nodeChanges[0];
|
|
33628
|
+
if ((args.x || args.y) && rootNode?.transform) {
|
|
33629
|
+
if (args.x)
|
|
33630
|
+
rootNode.transform.m02 = Number(args.x);
|
|
33631
|
+
if (args.y)
|
|
33632
|
+
rootNode.transform.m12 = Number(args.y);
|
|
33633
|
+
}
|
|
33634
|
+
if (args["dry-run"]) {
|
|
30194
33635
|
console.log(JSON.stringify(result.nodeChanges, null, 2));
|
|
30195
33636
|
return;
|
|
30196
33637
|
}
|
|
@@ -30199,8 +33640,34 @@ var render_default = defineCommand({
|
|
|
30199
33640
|
}
|
|
30200
33641
|
const pendingInstances = getPendingComponentSetInstances();
|
|
30201
33642
|
clearPendingComponentSetInstances();
|
|
33643
|
+
const pendingIconsList = getPendingIcons();
|
|
33644
|
+
clearPendingIcons();
|
|
30202
33645
|
await sendNodeChanges(result.nodeChanges, pendingInstances);
|
|
30203
|
-
|
|
33646
|
+
if (pendingIconsList.length > 0) {
|
|
33647
|
+
await sleep(100);
|
|
33648
|
+
}
|
|
33649
|
+
for (const icon of pendingIconsList) {
|
|
33650
|
+
try {
|
|
33651
|
+
const parentId = `${icon.parentGUID.sessionID}:${icon.parentGUID.localID}`;
|
|
33652
|
+
await sendCommand("import-svg", {
|
|
33653
|
+
svg: icon.svg,
|
|
33654
|
+
x: icon.x,
|
|
33655
|
+
y: icon.y,
|
|
33656
|
+
parentId,
|
|
33657
|
+
name: icon.name,
|
|
33658
|
+
noFill: true,
|
|
33659
|
+
insertIndex: icon.childIndex
|
|
33660
|
+
});
|
|
33661
|
+
} catch (e6) {
|
|
33662
|
+
consola2.error(`Failed to import icon "${icon.name}":`, e6);
|
|
33663
|
+
}
|
|
33664
|
+
}
|
|
33665
|
+
const firstNode = result.nodeChanges[0];
|
|
33666
|
+
if (!firstNode) {
|
|
33667
|
+
console.error(fail("No nodes rendered"));
|
|
33668
|
+
process.exit(1);
|
|
33669
|
+
}
|
|
33670
|
+
const rootId = `${firstNode.guid.sessionID}:${firstNode.guid.localID}`;
|
|
30204
33671
|
try {
|
|
30205
33672
|
await sendCommand("trigger-layout", {
|
|
30206
33673
|
nodeId: rootId,
|
|
@@ -30510,7 +33977,8 @@ var diff_default = defineCommand({
|
|
|
30510
33977
|
subCommands: {
|
|
30511
33978
|
apply: () => Promise.resolve().then(() => (init_apply2(), exports_apply)).then((m3) => m3.default),
|
|
30512
33979
|
show: () => Promise.resolve().then(() => (init_show(), exports_show)).then((m3) => m3.default),
|
|
30513
|
-
create: () => Promise.resolve().then(() => (init_create2(), exports_create)).then((m3) => m3.default)
|
|
33980
|
+
create: () => Promise.resolve().then(() => (init_create2(), exports_create)).then((m3) => m3.default),
|
|
33981
|
+
visual: () => Promise.resolve().then(() => (init_visual(), exports_visual)).then((m3) => m3.default)
|
|
30514
33982
|
}
|
|
30515
33983
|
});
|
|
30516
33984
|
// packages/cli/src/commands/node/index.ts
|
|
@@ -30847,7 +34315,7 @@ var to_component_default = defineCommand({
|
|
|
30847
34315
|
}
|
|
30848
34316
|
}
|
|
30849
34317
|
} catch (error) {
|
|
30850
|
-
handleError(error
|
|
34318
|
+
handleError(error);
|
|
30851
34319
|
}
|
|
30852
34320
|
}
|
|
30853
34321
|
});
|
|
@@ -31058,9 +34526,9 @@ var rect_default = defineCommand({
|
|
|
31058
34526
|
height: { type: "string", description: "Height", required: true },
|
|
31059
34527
|
name: { type: "string", description: "Name" },
|
|
31060
34528
|
parent: { type: "string", description: "Parent node ID" },
|
|
31061
|
-
fill: { type: "string", description: "Fill color (hex)" },
|
|
31062
|
-
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
31063
|
-
|
|
34529
|
+
fill: { type: "string", description: "Fill color (hex or var:Name)" },
|
|
34530
|
+
stroke: { type: "string", description: "Stroke color (hex or var:Name)" },
|
|
34531
|
+
"stroke-weight": { type: "string", description: "Stroke weight" },
|
|
31064
34532
|
radius: { type: "string", description: "Corner radius" },
|
|
31065
34533
|
opacity: { type: "string", description: "Opacity (0-1)" },
|
|
31066
34534
|
json: { type: "boolean", description: "Output as JSON" }
|
|
@@ -31076,7 +34544,7 @@ var rect_default = defineCommand({
|
|
|
31076
34544
|
parentId: args.parent,
|
|
31077
34545
|
fill: args.fill,
|
|
31078
34546
|
stroke: args.stroke,
|
|
31079
|
-
strokeWeight: args
|
|
34547
|
+
strokeWeight: args["stroke-weight"] ? Number(args["stroke-weight"]) : undefined,
|
|
31080
34548
|
radius: args.radius ? Number(args.radius) : undefined,
|
|
31081
34549
|
opacity: args.opacity ? Number(args.opacity) : undefined
|
|
31082
34550
|
});
|
|
@@ -31099,9 +34567,9 @@ var ellipse_default = defineCommand({
|
|
|
31099
34567
|
height: { type: "string", description: "Height", required: true },
|
|
31100
34568
|
name: { type: "string", description: "Name" },
|
|
31101
34569
|
parent: { type: "string", description: "Parent node ID" },
|
|
31102
|
-
fill: { type: "string", description: "Fill color (hex)" },
|
|
31103
|
-
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
31104
|
-
|
|
34570
|
+
fill: { type: "string", description: "Fill color (hex or var:Name)" },
|
|
34571
|
+
stroke: { type: "string", description: "Stroke color (hex or var:Name)" },
|
|
34572
|
+
"stroke-weight": { type: "string", description: "Stroke weight" },
|
|
31105
34573
|
opacity: { type: "string", description: "Opacity (0-1)" },
|
|
31106
34574
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31107
34575
|
},
|
|
@@ -31116,7 +34584,7 @@ var ellipse_default = defineCommand({
|
|
|
31116
34584
|
parentId: args.parent,
|
|
31117
34585
|
fill: args.fill,
|
|
31118
34586
|
stroke: args.stroke,
|
|
31119
|
-
strokeWeight: args
|
|
34587
|
+
strokeWeight: args["stroke-weight"] ? Number(args["stroke-weight"]) : undefined,
|
|
31120
34588
|
opacity: args.opacity ? Number(args.opacity) : undefined
|
|
31121
34589
|
});
|
|
31122
34590
|
printResult(result, args.json, "create");
|
|
@@ -31137,8 +34605,8 @@ var line_default = defineCommand({
|
|
|
31137
34605
|
length: { type: "string", description: "Length", required: true },
|
|
31138
34606
|
name: { type: "string", description: "Name" },
|
|
31139
34607
|
parent: { type: "string", description: "Parent node ID" },
|
|
31140
|
-
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
31141
|
-
|
|
34608
|
+
stroke: { type: "string", description: "Stroke color (hex or var:Name)" },
|
|
34609
|
+
"stroke-weight": { type: "string", description: "Stroke weight" },
|
|
31142
34610
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31143
34611
|
},
|
|
31144
34612
|
async run({ args }) {
|
|
@@ -31150,7 +34618,7 @@ var line_default = defineCommand({
|
|
|
31150
34618
|
name: args.name,
|
|
31151
34619
|
parentId: args.parent,
|
|
31152
34620
|
stroke: args.stroke,
|
|
31153
|
-
strokeWeight: args
|
|
34621
|
+
strokeWeight: args["stroke-weight"] ? Number(args["stroke-weight"]) : undefined
|
|
31154
34622
|
});
|
|
31155
34623
|
printResult(result, args.json, "create");
|
|
31156
34624
|
} catch (e6) {
|
|
@@ -31171,9 +34639,9 @@ var polygon_default = defineCommand({
|
|
|
31171
34639
|
sides: { type: "string", description: "Number of sides", default: "6" },
|
|
31172
34640
|
name: { type: "string", description: "Name" },
|
|
31173
34641
|
parent: { type: "string", description: "Parent node ID" },
|
|
31174
|
-
fill: { type: "string", description: "Fill color (hex)" },
|
|
31175
|
-
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
31176
|
-
|
|
34642
|
+
fill: { type: "string", description: "Fill color (hex or var:Name)" },
|
|
34643
|
+
stroke: { type: "string", description: "Stroke color (hex or var:Name)" },
|
|
34644
|
+
"stroke-weight": { type: "string", description: "Stroke weight" },
|
|
31177
34645
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31178
34646
|
},
|
|
31179
34647
|
async run({ args }) {
|
|
@@ -31187,7 +34655,7 @@ var polygon_default = defineCommand({
|
|
|
31187
34655
|
parentId: args.parent,
|
|
31188
34656
|
fill: args.fill,
|
|
31189
34657
|
stroke: args.stroke,
|
|
31190
|
-
strokeWeight: args
|
|
34658
|
+
strokeWeight: args["stroke-weight"] ? Number(args["stroke-weight"]) : undefined
|
|
31191
34659
|
});
|
|
31192
34660
|
printResult(result, args.json, "create");
|
|
31193
34661
|
} catch (e6) {
|
|
@@ -31206,12 +34674,12 @@ var star_default = defineCommand({
|
|
|
31206
34674
|
y: { type: "string", description: "Y coordinate", required: true },
|
|
31207
34675
|
size: { type: "string", description: "Size (width/height)", required: true },
|
|
31208
34676
|
points: { type: "string", description: "Number of points", default: "5" },
|
|
31209
|
-
|
|
34677
|
+
"inner-ratio": { type: "string", description: "Inner radius ratio (0-1)", default: "0.5" },
|
|
31210
34678
|
name: { type: "string", description: "Name" },
|
|
31211
34679
|
parent: { type: "string", description: "Parent node ID" },
|
|
31212
|
-
fill: { type: "string", description: "Fill color (hex)" },
|
|
31213
|
-
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
31214
|
-
|
|
34680
|
+
fill: { type: "string", description: "Fill color (hex or var:Name)" },
|
|
34681
|
+
stroke: { type: "string", description: "Stroke color (hex or var:Name)" },
|
|
34682
|
+
"stroke-weight": { type: "string", description: "Stroke weight" },
|
|
31215
34683
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31216
34684
|
},
|
|
31217
34685
|
async run({ args }) {
|
|
@@ -31221,12 +34689,12 @@ var star_default = defineCommand({
|
|
|
31221
34689
|
y: Number(args.y),
|
|
31222
34690
|
size: Number(args.size),
|
|
31223
34691
|
points: Number(args.points),
|
|
31224
|
-
innerRadius: Number(args
|
|
34692
|
+
innerRadius: Number(args["inner-ratio"]),
|
|
31225
34693
|
name: args.name,
|
|
31226
34694
|
parentId: args.parent,
|
|
31227
34695
|
fill: args.fill,
|
|
31228
34696
|
stroke: args.stroke,
|
|
31229
|
-
strokeWeight: args
|
|
34697
|
+
strokeWeight: args["stroke-weight"] ? Number(args["stroke-weight"]) : undefined
|
|
31230
34698
|
});
|
|
31231
34699
|
printResult(result, args.json, "create");
|
|
31232
34700
|
} catch (e6) {
|
|
@@ -31246,9 +34714,9 @@ var vector_default = defineCommand({
|
|
|
31246
34714
|
path: { type: "string", description: "SVG path data", required: true },
|
|
31247
34715
|
name: { type: "string", description: "Name" },
|
|
31248
34716
|
parent: { type: "string", description: "Parent node ID" },
|
|
31249
|
-
fill: { type: "string", description: "Fill color (hex)" },
|
|
31250
|
-
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
31251
|
-
|
|
34717
|
+
fill: { type: "string", description: "Fill color (hex or var:Name)" },
|
|
34718
|
+
stroke: { type: "string", description: "Stroke color (hex or var:Name)" },
|
|
34719
|
+
"stroke-weight": { type: "string", description: "Stroke weight" },
|
|
31252
34720
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31253
34721
|
},
|
|
31254
34722
|
async run({ args }) {
|
|
@@ -31261,7 +34729,7 @@ var vector_default = defineCommand({
|
|
|
31261
34729
|
parentId: args.parent,
|
|
31262
34730
|
fill: args.fill,
|
|
31263
34731
|
stroke: args.stroke,
|
|
31264
|
-
strokeWeight: args
|
|
34732
|
+
strokeWeight: args["stroke-weight"] ? Number(args["stroke-weight"]) : undefined
|
|
31265
34733
|
});
|
|
31266
34734
|
printResult(result, args.json, "create");
|
|
31267
34735
|
} catch (e6) {
|
|
@@ -31282,9 +34750,9 @@ var frame_default = defineCommand({
|
|
|
31282
34750
|
height: { type: "string", description: "Height", required: true },
|
|
31283
34751
|
name: { type: "string", description: "Name" },
|
|
31284
34752
|
parent: { type: "string", description: "Parent node ID" },
|
|
31285
|
-
fill: { type: "string", description: "Fill color (hex)" },
|
|
31286
|
-
stroke: { type: "string", description: "Stroke color (hex)" },
|
|
31287
|
-
|
|
34753
|
+
fill: { type: "string", description: "Fill color (hex or var:Name)" },
|
|
34754
|
+
stroke: { type: "string", description: "Stroke color (hex or var:Name)" },
|
|
34755
|
+
"stroke-weight": { type: "string", description: "Stroke weight" },
|
|
31288
34756
|
radius: { type: "string", description: "Corner radius" },
|
|
31289
34757
|
opacity: { type: "string", description: "Opacity (0-1)" },
|
|
31290
34758
|
layout: { type: "string", description: "Layout mode: HORIZONTAL, VERTICAL, NONE" },
|
|
@@ -31298,7 +34766,8 @@ var frame_default = defineCommand({
|
|
|
31298
34766
|
if (args.padding) {
|
|
31299
34767
|
const parts = args.padding.split(",").map(Number);
|
|
31300
34768
|
if (parts.length === 1) {
|
|
31301
|
-
|
|
34769
|
+
const p4 = parts[0];
|
|
34770
|
+
paddingObj = { top: p4, right: p4, bottom: p4, left: p4 };
|
|
31302
34771
|
} else if (parts.length === 4) {
|
|
31303
34772
|
paddingObj = { top: parts[0], right: parts[1], bottom: parts[2], left: parts[3] };
|
|
31304
34773
|
}
|
|
@@ -31312,7 +34781,7 @@ var frame_default = defineCommand({
|
|
|
31312
34781
|
parentId: args.parent,
|
|
31313
34782
|
fill: args.fill,
|
|
31314
34783
|
stroke: args.stroke,
|
|
31315
|
-
strokeWeight: args
|
|
34784
|
+
strokeWeight: args["stroke-weight"] ? Number(args["stroke-weight"]) : undefined,
|
|
31316
34785
|
radius: args.radius ? Number(args.radius) : undefined,
|
|
31317
34786
|
opacity: args.opacity ? Number(args.opacity) : undefined,
|
|
31318
34787
|
layoutMode: args.layout,
|
|
@@ -31335,10 +34804,10 @@ var text_default = defineCommand({
|
|
|
31335
34804
|
x: { type: "string", description: "X coordinate", required: true },
|
|
31336
34805
|
y: { type: "string", description: "Y coordinate", required: true },
|
|
31337
34806
|
text: { type: "string", description: "Text content", required: true },
|
|
31338
|
-
|
|
31339
|
-
|
|
31340
|
-
|
|
31341
|
-
fill: { type: "string", description: "Text color (hex)" },
|
|
34807
|
+
"font-size": { type: "string", description: "Font size" },
|
|
34808
|
+
"font-family": { type: "string", description: "Font family (default: Inter)" },
|
|
34809
|
+
"font-style": { type: "string", description: "Font style (Regular, Bold, Medium, etc)" },
|
|
34810
|
+
fill: { type: "string", description: "Text color (hex or var:Name)" },
|
|
31342
34811
|
opacity: { type: "string", description: "Opacity (0-1)" },
|
|
31343
34812
|
name: { type: "string", description: "Node name" },
|
|
31344
34813
|
parent: { type: "string", description: "Parent node ID" },
|
|
@@ -31350,9 +34819,9 @@ var text_default = defineCommand({
|
|
|
31350
34819
|
x: Number(args.x),
|
|
31351
34820
|
y: Number(args.y),
|
|
31352
34821
|
text: args.text,
|
|
31353
|
-
fontSize: args
|
|
31354
|
-
fontFamily: args
|
|
31355
|
-
fontStyle: args
|
|
34822
|
+
fontSize: args["font-size"] ? Number(args["font-size"]) : undefined,
|
|
34823
|
+
fontFamily: args["font-family"],
|
|
34824
|
+
fontStyle: args["font-style"],
|
|
31356
34825
|
fill: args.fill,
|
|
31357
34826
|
opacity: args.opacity ? Number(args.opacity) : undefined,
|
|
31358
34827
|
name: args.name,
|
|
@@ -31377,7 +34846,7 @@ var component_default = defineCommand({
|
|
|
31377
34846
|
height: { type: "string", description: "Height", required: true },
|
|
31378
34847
|
name: { type: "string", description: "Name" },
|
|
31379
34848
|
parent: { type: "string", description: "Parent node ID" },
|
|
31380
|
-
fill: { type: "string", description: "Fill color (hex)" },
|
|
34849
|
+
fill: { type: "string", description: "Fill color (hex or var:Name)" },
|
|
31381
34850
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31382
34851
|
},
|
|
31383
34852
|
async run({ args }) {
|
|
@@ -31508,6 +34977,77 @@ var slice_default = defineCommand({
|
|
|
31508
34977
|
}
|
|
31509
34978
|
});
|
|
31510
34979
|
|
|
34980
|
+
// packages/cli/src/commands/create/icon.ts
|
|
34981
|
+
init_dist2();
|
|
34982
|
+
init_client();
|
|
34983
|
+
init_format();
|
|
34984
|
+
var VAR_PREFIX_RE = /^(?:var:|[$])(.+)$/;
|
|
34985
|
+
async function replaceSvgCurrentColor(svg, color) {
|
|
34986
|
+
const rewriter = new HTMLRewriter().on("*", {
|
|
34987
|
+
element(el) {
|
|
34988
|
+
if (el.getAttribute("fill") === "currentColor") {
|
|
34989
|
+
el.setAttribute("fill", color);
|
|
34990
|
+
}
|
|
34991
|
+
if (el.getAttribute("stroke") === "currentColor") {
|
|
34992
|
+
el.setAttribute("stroke", color);
|
|
34993
|
+
}
|
|
34994
|
+
}
|
|
34995
|
+
});
|
|
34996
|
+
return await rewriter.transform(new Response(svg)).text();
|
|
34997
|
+
}
|
|
34998
|
+
var icon_default = defineCommand({
|
|
34999
|
+
meta: { description: "Create an icon from Iconify" },
|
|
35000
|
+
args: {
|
|
35001
|
+
name: { type: "positional", description: "Icon name (e.g., mdi:home, lucide:star)", required: true },
|
|
35002
|
+
x: { type: "string", description: "X coordinate", default: "0" },
|
|
35003
|
+
y: { type: "string", description: "Y coordinate", default: "0" },
|
|
35004
|
+
size: { type: "string", description: "Size in pixels", default: "24" },
|
|
35005
|
+
color: { type: "string", description: "Icon color (hex or var:Name)" },
|
|
35006
|
+
parent: { type: "string", description: "Parent node ID" },
|
|
35007
|
+
component: { type: "boolean", description: "Create as Figma component" },
|
|
35008
|
+
json: { type: "boolean", description: "Output as JSON" }
|
|
35009
|
+
},
|
|
35010
|
+
async run({ args }) {
|
|
35011
|
+
try {
|
|
35012
|
+
const size = Number(args.size);
|
|
35013
|
+
const iconData = await loadIconSvg(args.name, size);
|
|
35014
|
+
if (!iconData) {
|
|
35015
|
+
console.error(fail(`Icon "${args.name}" not found`));
|
|
35016
|
+
process.exit(1);
|
|
35017
|
+
}
|
|
35018
|
+
const varMatch = args.color?.match(VAR_PREFIX_RE);
|
|
35019
|
+
const hexColor = varMatch ? "#000000" : args.color || "#000000";
|
|
35020
|
+
const svg = await replaceSvgCurrentColor(iconData.svg, hexColor);
|
|
35021
|
+
const result = await sendCommand("import-svg", {
|
|
35022
|
+
svg,
|
|
35023
|
+
x: Number(args.x),
|
|
35024
|
+
y: Number(args.y),
|
|
35025
|
+
parentId: args.parent
|
|
35026
|
+
});
|
|
35027
|
+
const iconName = args.name.replace(":", "/");
|
|
35028
|
+
await sendCommand("rename-node", { id: result.id, name: iconName });
|
|
35029
|
+
if (varMatch) {
|
|
35030
|
+
await sendCommand("bind-fill-variable-by-name", {
|
|
35031
|
+
id: result.id,
|
|
35032
|
+
variableName: varMatch[1],
|
|
35033
|
+
recursive: true
|
|
35034
|
+
});
|
|
35035
|
+
}
|
|
35036
|
+
let finalId = result.id;
|
|
35037
|
+
if (args.component) {
|
|
35038
|
+
const componentResult = await sendCommand("convert-to-component", {
|
|
35039
|
+
id: result.id
|
|
35040
|
+
});
|
|
35041
|
+
finalId = componentResult.id;
|
|
35042
|
+
}
|
|
35043
|
+
const finalResult = await sendCommand("get-node-info", { id: finalId });
|
|
35044
|
+
printResult(finalResult, args.json, "create");
|
|
35045
|
+
} catch (e6) {
|
|
35046
|
+
handleError(e6);
|
|
35047
|
+
}
|
|
35048
|
+
}
|
|
35049
|
+
});
|
|
35050
|
+
|
|
31511
35051
|
// packages/cli/src/commands/create/index.ts
|
|
31512
35052
|
var create_default2 = defineCommand({
|
|
31513
35053
|
meta: { description: "Create nodes" },
|
|
@@ -31524,7 +35064,8 @@ var create_default2 = defineCommand({
|
|
|
31524
35064
|
instance: instance_default,
|
|
31525
35065
|
section: section_default,
|
|
31526
35066
|
page: page_default,
|
|
31527
|
-
slice: slice_default
|
|
35067
|
+
slice: slice_default,
|
|
35068
|
+
icon: icon_default
|
|
31528
35069
|
}
|
|
31529
35070
|
});
|
|
31530
35071
|
// packages/cli/src/commands/set/index.ts
|
|
@@ -31537,7 +35078,7 @@ var fill_default = defineCommand({
|
|
|
31537
35078
|
meta: { description: "Set fill color" },
|
|
31538
35079
|
args: {
|
|
31539
35080
|
id: { type: "positional", description: "Node ID", required: true },
|
|
31540
|
-
color: { type: "positional", description: "Color (hex)", required: true },
|
|
35081
|
+
color: { type: "positional", description: "Color (hex or var:Name)", required: true },
|
|
31541
35082
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31542
35083
|
},
|
|
31543
35084
|
async run({ args }) {
|
|
@@ -31557,7 +35098,7 @@ var stroke_default = defineCommand({
|
|
|
31557
35098
|
meta: { description: "Set stroke color and weight" },
|
|
31558
35099
|
args: {
|
|
31559
35100
|
id: { type: "positional", description: "Node ID", required: true },
|
|
31560
|
-
color: { type: "positional", description: "Color (hex)", required: true },
|
|
35101
|
+
color: { type: "positional", description: "Color (hex or var:Name)", required: true },
|
|
31561
35102
|
weight: { type: "string", description: "Stroke weight" },
|
|
31562
35103
|
align: { type: "string", description: "Stroke align: INSIDE, CENTER, OUTSIDE" },
|
|
31563
35104
|
json: { type: "boolean", description: "Output as JSON" }
|
|
@@ -31609,10 +35150,10 @@ var radius_default = defineCommand({
|
|
|
31609
35150
|
args: {
|
|
31610
35151
|
id: { type: "positional", description: "Node ID", required: true },
|
|
31611
35152
|
radius: { type: "string", description: "Uniform radius" },
|
|
31612
|
-
|
|
31613
|
-
|
|
31614
|
-
|
|
31615
|
-
|
|
35153
|
+
"top-left": { type: "string", description: "Top left radius" },
|
|
35154
|
+
"top-right": { type: "string", description: "Top right radius" },
|
|
35155
|
+
"bottom-left": { type: "string", description: "Bottom left radius" },
|
|
35156
|
+
"bottom-right": { type: "string", description: "Bottom right radius" },
|
|
31616
35157
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31617
35158
|
},
|
|
31618
35159
|
async run({ args }) {
|
|
@@ -31620,10 +35161,10 @@ var radius_default = defineCommand({
|
|
|
31620
35161
|
const result = await sendCommand("set-corner-radius", {
|
|
31621
35162
|
id: args.id,
|
|
31622
35163
|
cornerRadius: args.radius ? Number(args.radius) : 0,
|
|
31623
|
-
topLeftRadius: args
|
|
31624
|
-
topRightRadius: args
|
|
31625
|
-
bottomLeftRadius: args
|
|
31626
|
-
bottomRightRadius: args
|
|
35164
|
+
topLeftRadius: args["top-left"] ? Number(args["top-left"]) : undefined,
|
|
35165
|
+
topRightRadius: args["top-right"] ? Number(args["top-right"]) : undefined,
|
|
35166
|
+
bottomLeftRadius: args["bottom-left"] ? Number(args["bottom-left"]) : undefined,
|
|
35167
|
+
bottomRightRadius: args["bottom-right"] ? Number(args["bottom-right"]) : undefined
|
|
31627
35168
|
});
|
|
31628
35169
|
printResult(result, args.json);
|
|
31629
35170
|
} catch (e6) {
|
|
@@ -31659,7 +35200,7 @@ var rotation_default = defineCommand({
|
|
|
31659
35200
|
meta: { description: "Set rotation angle" },
|
|
31660
35201
|
args: {
|
|
31661
35202
|
id: { type: "positional", description: "Node ID", required: true },
|
|
31662
|
-
angle: { type: "
|
|
35203
|
+
angle: { type: "string", description: "Angle in degrees", required: true },
|
|
31663
35204
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31664
35205
|
},
|
|
31665
35206
|
async run({ args }) {
|
|
@@ -31775,7 +35316,7 @@ var font_range_default = defineCommand({
|
|
|
31775
35316
|
family: { type: "string", description: "Font family" },
|
|
31776
35317
|
style: { type: "string", description: "Font style (Regular, Bold, Italic, etc)" },
|
|
31777
35318
|
size: { type: "string", description: "Font size" },
|
|
31778
|
-
color: { type: "string", description: "Text color (hex)" },
|
|
35319
|
+
color: { type: "string", description: "Text color (hex or var:Name)" },
|
|
31779
35320
|
json: { type: "boolean", description: "Output as JSON" }
|
|
31780
35321
|
},
|
|
31781
35322
|
async run({ args }) {
|
|
@@ -31791,7 +35332,7 @@ var font_range_default = defineCommand({
|
|
|
31791
35332
|
});
|
|
31792
35333
|
printResult(result, args.json);
|
|
31793
35334
|
} catch (error) {
|
|
31794
|
-
handleError(error
|
|
35335
|
+
handleError(error);
|
|
31795
35336
|
}
|
|
31796
35337
|
}
|
|
31797
35338
|
});
|
|
@@ -31809,8 +35350,8 @@ var effect_default = defineCommand({
|
|
|
31809
35350
|
required: true
|
|
31810
35351
|
},
|
|
31811
35352
|
radius: { type: "string", description: "Blur radius" },
|
|
31812
|
-
|
|
31813
|
-
|
|
35353
|
+
"offset-x": { type: "string", description: "Shadow offset X" },
|
|
35354
|
+
"offset-y": { type: "string", description: "Shadow offset Y" },
|
|
31814
35355
|
color: { type: "string", description: "Shadow color (hex with alpha)" },
|
|
31815
35356
|
spread: { type: "string", description: "Shadow spread" },
|
|
31816
35357
|
json: { type: "boolean", description: "Output as JSON" }
|
|
@@ -31821,8 +35362,8 @@ var effect_default = defineCommand({
|
|
|
31821
35362
|
id: args.id,
|
|
31822
35363
|
type: args.type,
|
|
31823
35364
|
radius: args.radius ? Number(args.radius) : undefined,
|
|
31824
|
-
offsetX: args
|
|
31825
|
-
offsetY: args
|
|
35365
|
+
offsetX: args["offset-x"] ? Number(args["offset-x"]) : undefined,
|
|
35366
|
+
offsetY: args["offset-y"] ? Number(args["offset-y"]) : undefined,
|
|
31826
35367
|
color: args.color,
|
|
31827
35368
|
spread: args.spread ? Number(args.spread) : undefined
|
|
31828
35369
|
});
|
|
@@ -31847,7 +35388,7 @@ var layout_default = defineCommand({
|
|
|
31847
35388
|
type: "string",
|
|
31848
35389
|
description: "Primary axis alignment: MIN, CENTER, MAX, SPACE_BETWEEN"
|
|
31849
35390
|
},
|
|
31850
|
-
|
|
35391
|
+
"counter-align": {
|
|
31851
35392
|
type: "string",
|
|
31852
35393
|
description: "Counter axis alignment: MIN, CENTER, MAX, BASELINE"
|
|
31853
35394
|
},
|
|
@@ -31860,7 +35401,8 @@ var layout_default = defineCommand({
|
|
|
31860
35401
|
if (args.padding) {
|
|
31861
35402
|
const parts = args.padding.split(",").map(Number);
|
|
31862
35403
|
if (parts.length === 1) {
|
|
31863
|
-
|
|
35404
|
+
const p4 = parts[0];
|
|
35405
|
+
paddingObj = { top: p4, right: p4, bottom: p4, left: p4 };
|
|
31864
35406
|
} else if (parts.length === 4) {
|
|
31865
35407
|
paddingObj = { top: parts[0], right: parts[1], bottom: parts[2], left: parts[3] };
|
|
31866
35408
|
}
|
|
@@ -31871,7 +35413,7 @@ var layout_default = defineCommand({
|
|
|
31871
35413
|
itemSpacing: args.gap ? Number(args.gap) : undefined,
|
|
31872
35414
|
padding: paddingObj,
|
|
31873
35415
|
primaryAlign: args.align,
|
|
31874
|
-
counterAlign: args
|
|
35416
|
+
counterAlign: args["counter-align"],
|
|
31875
35417
|
wrap: args.wrap
|
|
31876
35418
|
});
|
|
31877
35419
|
printResult(result, args.json);
|
|
@@ -32008,20 +35550,20 @@ var minmax_default = defineCommand({
|
|
|
32008
35550
|
meta: { description: "Set min/max width and height constraints" },
|
|
32009
35551
|
args: {
|
|
32010
35552
|
id: { type: "positional", description: "Node ID", required: true },
|
|
32011
|
-
|
|
32012
|
-
|
|
32013
|
-
|
|
32014
|
-
|
|
35553
|
+
"min-width": { type: "string", description: "Minimum width" },
|
|
35554
|
+
"max-width": { type: "string", description: "Maximum width" },
|
|
35555
|
+
"min-height": { type: "string", description: "Minimum height" },
|
|
35556
|
+
"max-height": { type: "string", description: "Maximum height" },
|
|
32015
35557
|
json: { type: "boolean", description: "Output as JSON" }
|
|
32016
35558
|
},
|
|
32017
35559
|
async run({ args }) {
|
|
32018
35560
|
try {
|
|
32019
35561
|
const result = await sendCommand("set-min-max", {
|
|
32020
35562
|
id: args.id,
|
|
32021
|
-
minWidth: args
|
|
32022
|
-
maxWidth: args
|
|
32023
|
-
minHeight: args
|
|
32024
|
-
maxHeight: args
|
|
35563
|
+
minWidth: args["min-width"] ? Number(args["min-width"]) : undefined,
|
|
35564
|
+
maxWidth: args["max-width"] ? Number(args["max-width"]) : undefined,
|
|
35565
|
+
minHeight: args["min-height"] ? Number(args["min-height"]) : undefined,
|
|
35566
|
+
maxHeight: args["max-height"] ? Number(args["max-height"]) : undefined
|
|
32025
35567
|
});
|
|
32026
35568
|
printResult(result, args.json, "update");
|
|
32027
35569
|
} catch (e6) {
|
|
@@ -32377,6 +35919,30 @@ var export_default = defineCommand({
|
|
|
32377
35919
|
// packages/cli/src/commands/page/index.ts
|
|
32378
35920
|
init_dist2();
|
|
32379
35921
|
|
|
35922
|
+
// packages/cli/src/commands/page/current.ts
|
|
35923
|
+
init_dist2();
|
|
35924
|
+
init_client();
|
|
35925
|
+
var current_default = defineCommand({
|
|
35926
|
+
meta: { description: "Get current page" },
|
|
35927
|
+
args: {
|
|
35928
|
+
json: { type: "boolean", description: "Output as JSON" }
|
|
35929
|
+
},
|
|
35930
|
+
async run({ args }) {
|
|
35931
|
+
try {
|
|
35932
|
+
const result = await sendCommand("eval", {
|
|
35933
|
+
code: "return { id: figma.currentPage.id, name: figma.currentPage.name }"
|
|
35934
|
+
});
|
|
35935
|
+
if (args.json) {
|
|
35936
|
+
console.log(JSON.stringify(result, null, 2));
|
|
35937
|
+
} else {
|
|
35938
|
+
console.log(`${result.name} (${result.id})`);
|
|
35939
|
+
}
|
|
35940
|
+
} catch (e6) {
|
|
35941
|
+
handleError(e6);
|
|
35942
|
+
}
|
|
35943
|
+
}
|
|
35944
|
+
});
|
|
35945
|
+
|
|
32380
35946
|
// packages/cli/src/commands/page/list.ts
|
|
32381
35947
|
init_dist2();
|
|
32382
35948
|
init_client();
|
|
@@ -32418,6 +35984,7 @@ var set_default4 = defineCommand({
|
|
|
32418
35984
|
var page_default2 = defineCommand({
|
|
32419
35985
|
meta: { description: "Page operations" },
|
|
32420
35986
|
subCommands: {
|
|
35987
|
+
current: current_default,
|
|
32421
35988
|
list: list_default2,
|
|
32422
35989
|
set: set_default4
|
|
32423
35990
|
}
|
|
@@ -32770,7 +36337,7 @@ var create_paint_default = defineCommand({
|
|
|
32770
36337
|
meta: { description: "Create a paint/color style" },
|
|
32771
36338
|
args: {
|
|
32772
36339
|
name: { type: "positional", description: "Style name", required: true },
|
|
32773
|
-
color: { type: "string", description: "Color (hex)", required: true },
|
|
36340
|
+
color: { type: "string", description: "Color (hex or var:Name)", required: true },
|
|
32774
36341
|
json: { type: "boolean", description: "Output as JSON" }
|
|
32775
36342
|
},
|
|
32776
36343
|
async run({ args }) {
|
|
@@ -32823,8 +36390,8 @@ var create_effect_default = defineCommand({
|
|
|
32823
36390
|
required: true
|
|
32824
36391
|
},
|
|
32825
36392
|
radius: { type: "string", description: "Blur radius" },
|
|
32826
|
-
|
|
32827
|
-
|
|
36393
|
+
"offset-x": { type: "string", description: "Shadow offset X" },
|
|
36394
|
+
"offset-y": { type: "string", description: "Shadow offset Y" },
|
|
32828
36395
|
color: { type: "string", description: "Shadow color (hex with alpha)" },
|
|
32829
36396
|
json: { type: "boolean", description: "Output as JSON" }
|
|
32830
36397
|
},
|
|
@@ -32834,8 +36401,8 @@ var create_effect_default = defineCommand({
|
|
|
32834
36401
|
name: args.name,
|
|
32835
36402
|
type: args.type,
|
|
32836
36403
|
radius: args.radius ? Number(args.radius) : undefined,
|
|
32837
|
-
offsetX: args
|
|
32838
|
-
offsetY: args
|
|
36404
|
+
offsetX: args["offset-x"] ? Number(args["offset-x"]) : undefined,
|
|
36405
|
+
offsetY: args["offset-y"] ? Number(args["offset-y"]) : undefined,
|
|
32839
36406
|
color: args.color
|
|
32840
36407
|
});
|
|
32841
36408
|
printResult(result, args.json);
|
|
@@ -33065,7 +36632,7 @@ var edit_prop_default = defineCommand({
|
|
|
33065
36632
|
args: {
|
|
33066
36633
|
id: { type: "positional", description: "Component ID", required: true },
|
|
33067
36634
|
name: { type: "string", description: "Property name", required: true },
|
|
33068
|
-
|
|
36635
|
+
"new-name": { type: "string", description: "New name" },
|
|
33069
36636
|
default: { type: "string", description: "New default value" },
|
|
33070
36637
|
json: { type: "boolean", description: "Output as JSON" }
|
|
33071
36638
|
},
|
|
@@ -33074,7 +36641,7 @@ var edit_prop_default = defineCommand({
|
|
|
33074
36641
|
const result = await sendCommand("edit-component-property", {
|
|
33075
36642
|
componentId: args.id,
|
|
33076
36643
|
propertyName: args.name,
|
|
33077
|
-
newName: args
|
|
36644
|
+
newName: args["new-name"],
|
|
33078
36645
|
newDefaultValue: args.default
|
|
33079
36646
|
});
|
|
33080
36647
|
printResult(result, args.json, "update");
|
|
@@ -33357,7 +36924,7 @@ var font_default2 = defineCommand({
|
|
|
33357
36924
|
}
|
|
33358
36925
|
});
|
|
33359
36926
|
// package.json
|
|
33360
|
-
var version = "0.
|
|
36927
|
+
var version = "0.7.0";
|
|
33361
36928
|
|
|
33362
36929
|
// packages/cli/src/index.ts
|
|
33363
36930
|
var main = defineCommand({
|