@tscircuit/cli 0.1.1526 → 0.1.1528
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/dist/cli/build/build.worker.js +73 -7
- package/dist/cli/main.js +155 -2735
- package/dist/cli/snapshot/snapshot.worker.js +158 -2786
- package/dist/lib/index.js +12 -10
- package/package.json +9 -8
package/dist/cli/main.js
CHANGED
|
@@ -8645,15 +8645,16 @@ var require_range = __commonJS((exports2, module2) => {
|
|
|
8645
8645
|
};
|
|
8646
8646
|
var replaceTilde = (comp, options) => {
|
|
8647
8647
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
8648
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
8648
8649
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
8649
8650
|
debug("tilde", comp, _, M, m, p, pr);
|
|
8650
8651
|
let ret;
|
|
8651
8652
|
if (isX(M)) {
|
|
8652
8653
|
ret = "";
|
|
8653
8654
|
} else if (isX(m)) {
|
|
8654
|
-
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
8655
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
8655
8656
|
} else if (isX(p)) {
|
|
8656
|
-
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
8657
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
8657
8658
|
} else if (pr) {
|
|
8658
8659
|
debug("replaceTilde pr", pr);
|
|
8659
8660
|
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
@@ -47012,15 +47013,15 @@ var init_chunk_SK323GHE = __esm(() => {
|
|
|
47012
47013
|
var exports_dist_VYXUNJDT = {};
|
|
47013
47014
|
__export2(exports_dist_VYXUNJDT, {
|
|
47014
47015
|
isSimulationVoltageProbe: () => isSimulationVoltageProbe,
|
|
47015
|
-
isSimulationTransientVoltageGraph: () =>
|
|
47016
|
-
isSimulationExperiment: () =>
|
|
47016
|
+
isSimulationTransientVoltageGraph: () => isSimulationTransientVoltageGraph2,
|
|
47017
|
+
isSimulationExperiment: () => isSimulationExperiment2,
|
|
47017
47018
|
getSoftwareUsedString: () => getSoftwareUsedString,
|
|
47018
47019
|
createSvgObjectsForSchComponentPortHovers: () => createSvgObjectsForSchComponentPortHovers,
|
|
47019
47020
|
createErrorTextOverlay: () => createErrorTextOverlay,
|
|
47020
47021
|
convertCircuitJsonToSolderPasteMask: () => convertCircuitJsonToSolderPasteMask,
|
|
47021
|
-
convertCircuitJsonToSimulationGraphSvg: () =>
|
|
47022
|
+
convertCircuitJsonToSimulationGraphSvg: () => convertCircuitJsonToSimulationGraphSvg2,
|
|
47022
47023
|
convertCircuitJsonToSchematicSvg: () => convertCircuitJsonToSchematicSvg3,
|
|
47023
|
-
convertCircuitJsonToSchematicSimulationSvg: () =>
|
|
47024
|
+
convertCircuitJsonToSchematicSimulationSvg: () => convertCircuitJsonToSchematicSimulationSvg2,
|
|
47024
47025
|
convertCircuitJsonToPinoutSvg: () => convertCircuitJsonToPinoutSvg,
|
|
47025
47026
|
convertCircuitJsonToPcbSvg: () => convertCircuitJsonToPcbSvg3,
|
|
47026
47027
|
convertCircuitJsonToAssemblySvg: () => convertCircuitJsonToAssemblySvg,
|
|
@@ -56881,16 +56882,16 @@ function convertCircuitJsonToSchematicSvg3(circuitJson, options) {
|
|
|
56881
56882
|
};
|
|
56882
56883
|
return stringify(svgObject);
|
|
56883
56884
|
}
|
|
56884
|
-
function
|
|
56885
|
+
function isSimulationTransientVoltageGraph2(value) {
|
|
56885
56886
|
return value?.type === "simulation_transient_voltage_graph";
|
|
56886
56887
|
}
|
|
56887
|
-
function
|
|
56888
|
+
function isSimulationExperiment2(value) {
|
|
56888
56889
|
return value?.type === "simulation_experiment";
|
|
56889
56890
|
}
|
|
56890
56891
|
function isSimulationVoltageProbe(value) {
|
|
56891
56892
|
return value?.type === "simulation_voltage_probe";
|
|
56892
56893
|
}
|
|
56893
|
-
function
|
|
56894
|
+
function convertCircuitJsonToSimulationGraphSvg2({
|
|
56894
56895
|
circuitJson,
|
|
56895
56896
|
simulation_experiment_id,
|
|
56896
56897
|
simulation_transient_voltage_graph_ids,
|
|
@@ -56899,8 +56900,8 @@ function convertCircuitJsonToSimulationGraphSvg({
|
|
|
56899
56900
|
includeVersion
|
|
56900
56901
|
}) {
|
|
56901
56902
|
const selectedIds = simulation_transient_voltage_graph_ids ? new Set(simulation_transient_voltage_graph_ids) : null;
|
|
56902
|
-
const experiment = circuitJson.find((element) =>
|
|
56903
|
-
const graphs = circuitJson.filter((element) =>
|
|
56903
|
+
const experiment = circuitJson.find((element) => isSimulationExperiment2(element) && element.simulation_experiment_id === simulation_experiment_id);
|
|
56904
|
+
const graphs = circuitJson.filter((element) => isSimulationTransientVoltageGraph2(element) && element.simulation_experiment_id === simulation_experiment_id && (!selectedIds || selectedIds.has(element.simulation_transient_voltage_graph_id)));
|
|
56904
56905
|
if (graphs.length === 0) {
|
|
56905
56906
|
throw new Error(`No simulation_transient_voltage_graph elements found for simulation_experiment_id "${simulation_experiment_id}"`);
|
|
56906
56907
|
}
|
|
@@ -57430,7 +57431,7 @@ function textNode(value) {
|
|
|
57430
57431
|
children: []
|
|
57431
57432
|
};
|
|
57432
57433
|
}
|
|
57433
|
-
function
|
|
57434
|
+
function convertCircuitJsonToSchematicSimulationSvg2({
|
|
57434
57435
|
circuitJson,
|
|
57435
57436
|
simulation_experiment_id,
|
|
57436
57437
|
simulation_transient_voltage_graph_ids,
|
|
@@ -57442,7 +57443,7 @@ function convertCircuitJsonToSchematicSimulationSvg({
|
|
|
57442
57443
|
graphAboveSchematic = false,
|
|
57443
57444
|
showErrorsInTextOverlay
|
|
57444
57445
|
}) {
|
|
57445
|
-
const schematicElements = circuitJson.filter((element) => !
|
|
57446
|
+
const schematicElements = circuitJson.filter((element) => !isSimulationExperiment2(element) && !isSimulationTransientVoltageGraph2(element));
|
|
57446
57447
|
const clampedRatio = clamp01(schematicHeightRatio);
|
|
57447
57448
|
const rawSchematicHeight = Math.max(1, height * clampedRatio);
|
|
57448
57449
|
const rawSimulationHeight = Math.max(1, height - rawSchematicHeight);
|
|
@@ -57457,7 +57458,7 @@ function convertCircuitJsonToSchematicSimulationSvg({
|
|
|
57457
57458
|
includeVersion: false,
|
|
57458
57459
|
showErrorsInTextOverlay
|
|
57459
57460
|
});
|
|
57460
|
-
const simulationSvg =
|
|
57461
|
+
const simulationSvg = convertCircuitJsonToSimulationGraphSvg2({
|
|
57461
57462
|
circuitJson,
|
|
57462
57463
|
simulation_experiment_id,
|
|
57463
57464
|
simulation_transient_voltage_graph_ids,
|
|
@@ -100767,7 +100768,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
|
100767
100768
|
// lib/getVersion.ts
|
|
100768
100769
|
import { createRequire as createRequire2 } from "node:module";
|
|
100769
100770
|
// package.json
|
|
100770
|
-
var version = "0.1.
|
|
100771
|
+
var version = "0.1.1527";
|
|
100771
100772
|
var package_default = {
|
|
100772
100773
|
name: "@tscircuit/cli",
|
|
100773
100774
|
version,
|
|
@@ -100782,14 +100783,15 @@ var package_default = {
|
|
|
100782
100783
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.6",
|
|
100783
100784
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.1",
|
|
100784
100785
|
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#b6d5fe675adc26a2fc988aa081e6fb51e6bf696a",
|
|
100785
|
-
"@tscircuit/
|
|
100786
|
+
"@tscircuit/eecircuit-engine": "https://jscdn.tscircuit.com/@tscircuit/eecircuit-engine/1.7.4.tgz",
|
|
100787
|
+
"@tscircuit/eval": "^0.0.933",
|
|
100786
100788
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
100787
100789
|
"@tscircuit/fake-ul-kicad-proxy": "github:tscircuit/fake-ul-kicad-proxy#d174c33c1b17a52d7a9dc3c2b5506d6fd593bed7",
|
|
100788
100790
|
"@tscircuit/file-server": "^0.0.32",
|
|
100789
|
-
"@tscircuit/image-utils": "^0.0.
|
|
100790
|
-
"@tscircuit/krt-wasm": "^0.1.
|
|
100791
|
+
"@tscircuit/image-utils": "^0.0.8",
|
|
100792
|
+
"@tscircuit/krt-wasm": "^0.1.6",
|
|
100791
100793
|
"@tscircuit/math-utils": "0.0.36",
|
|
100792
|
-
"@tscircuit/props": "^0.0.
|
|
100794
|
+
"@tscircuit/props": "^0.0.551",
|
|
100793
100795
|
"@tscircuit/runframe": "^0.0.2101",
|
|
100794
100796
|
"@tscircuit/schematic-match-adapt": "^0.0.22",
|
|
100795
100797
|
"@tscircuit/ti-parts-engine": "github:tscircuit/ti-parts-engine#cead194495b8fbfb73a88b5995ce86a4b61a9d04",
|
|
@@ -100804,13 +100806,13 @@ var package_default = {
|
|
|
100804
100806
|
"@types/semver": "^7.5.8",
|
|
100805
100807
|
"bun-match-svg": "^0.0.12",
|
|
100806
100808
|
chokidar: "4.0.1",
|
|
100807
|
-
"circuit-json": "^0.0.
|
|
100809
|
+
"circuit-json": "^0.0.437",
|
|
100808
100810
|
"circuit-json-to-bom-csv": "^0.0.7",
|
|
100809
100811
|
"circuit-json-to-gerber": "^0.0.51",
|
|
100810
100812
|
"circuit-json-to-kicad": "0.0.153",
|
|
100811
100813
|
"circuit-json-to-pnp-csv": "^0.0.7",
|
|
100812
100814
|
"circuit-json-to-readable-netlist": "^0.0.15",
|
|
100813
|
-
"circuit-json-to-spice": "^0.0.
|
|
100815
|
+
"circuit-json-to-spice": "^0.0.39",
|
|
100814
100816
|
"circuit-json-to-step": "^0.0.36",
|
|
100815
100817
|
"circuit-json-to-tscircuit": "^0.0.35",
|
|
100816
100818
|
"circuit-json-trace-length-analysis": "github:tscircuit/circuit-json-trace-length-analysis#2b44792a40df0ca83b6bfb6ac95ed5e35e7168b8",
|
|
@@ -100843,7 +100845,7 @@ var package_default = {
|
|
|
100843
100845
|
semver: "^7.6.3",
|
|
100844
100846
|
stepts: "^0.0.3",
|
|
100845
100847
|
tempy: "^3.1.0",
|
|
100846
|
-
tscircuit: "0.0.
|
|
100848
|
+
tscircuit: "0.0.1911-libonly",
|
|
100847
100849
|
tsx: "^4.7.1",
|
|
100848
100850
|
"typed-ky": "^0.0.4",
|
|
100849
100851
|
zod: "^3.23.8"
|
|
@@ -114490,7 +114492,57 @@ async function loadLocalStepModelFsMap(circuitJson) {
|
|
|
114490
114492
|
return fsMap;
|
|
114491
114493
|
}
|
|
114492
114494
|
|
|
114495
|
+
// lib/shared/simulation-svg-assets.ts
|
|
114496
|
+
import {
|
|
114497
|
+
convertCircuitJsonToSchematicSimulationSvg,
|
|
114498
|
+
convertCircuitJsonToSimulationGraphSvg,
|
|
114499
|
+
isSimulationExperiment,
|
|
114500
|
+
isSimulationTransientVoltageGraph
|
|
114501
|
+
} from "circuit-to-svg";
|
|
114502
|
+
var getSimulationSvgInputs = (circuitJson) => {
|
|
114503
|
+
const simulationExperiment = circuitJson.find(isSimulationExperiment);
|
|
114504
|
+
if (!simulationExperiment)
|
|
114505
|
+
return;
|
|
114506
|
+
const simulationTransientVoltageGraphIds = circuitJson.filter((element) => isSimulationTransientVoltageGraph(element) && element.simulation_experiment_id === simulationExperiment.simulation_experiment_id).map((element) => element.simulation_transient_voltage_graph_id);
|
|
114507
|
+
if (simulationTransientVoltageGraphIds.length === 0)
|
|
114508
|
+
return;
|
|
114509
|
+
return {
|
|
114510
|
+
simulation_experiment_id: simulationExperiment.simulation_experiment_id,
|
|
114511
|
+
simulation_transient_voltage_graph_ids: simulationTransientVoltageGraphIds
|
|
114512
|
+
};
|
|
114513
|
+
};
|
|
114514
|
+
var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
|
|
114515
|
+
const simulationSvgInputs = getSimulationSvgInputs(circuitJson);
|
|
114516
|
+
if (!simulationSvgInputs)
|
|
114517
|
+
return;
|
|
114518
|
+
return {
|
|
114519
|
+
simulationSvg: convertCircuitJsonToSimulationGraphSvg({
|
|
114520
|
+
circuitJson,
|
|
114521
|
+
...simulationSvgInputs
|
|
114522
|
+
}),
|
|
114523
|
+
schematicSimulationSvg: convertCircuitJsonToSchematicSimulationSvg({
|
|
114524
|
+
circuitJson,
|
|
114525
|
+
...simulationSvgInputs
|
|
114526
|
+
})
|
|
114527
|
+
};
|
|
114528
|
+
};
|
|
114529
|
+
|
|
114493
114530
|
// cli/build/worker-output-generators.ts
|
|
114531
|
+
var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageFormats) => {
|
|
114532
|
+
if (!imageFormats.simulationSvgs && !imageFormats.simulationSchematicSvgs) {
|
|
114533
|
+
return false;
|
|
114534
|
+
}
|
|
114535
|
+
const simulationSvgAssets = getSimulationSvgAssetsFromCircuitJson(circuitJson);
|
|
114536
|
+
if (!simulationSvgAssets)
|
|
114537
|
+
return false;
|
|
114538
|
+
if (imageFormats.simulationSvgs) {
|
|
114539
|
+
fs29.writeFileSync(path32.join(outputDir, "simulation.svg"), simulationSvgAssets.simulationSvg, "utf-8");
|
|
114540
|
+
}
|
|
114541
|
+
if (imageFormats.simulationSchematicSvgs) {
|
|
114542
|
+
fs29.writeFileSync(path32.join(outputDir, "simulation-schematic.svg"), simulationSvgAssets.schematicSimulationSvg, "utf-8");
|
|
114543
|
+
}
|
|
114544
|
+
return true;
|
|
114545
|
+
};
|
|
114494
114546
|
var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
|
|
114495
114547
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
114496
114548
|
const glbBuffer = await convertCircuitJsonToGltf2(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
@@ -114522,6 +114574,7 @@ var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
|
114522
114574
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
114523
114575
|
fs29.writeFileSync(path32.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
114524
114576
|
}
|
|
114577
|
+
writeSimulationSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
|
|
114525
114578
|
if (imageFormats.threeDPngs) {
|
|
114526
114579
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
114527
114580
|
const glbBuffer = await convertCircuitJsonToGltf2(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
@@ -114705,6 +114758,21 @@ var generatePreviewAssets = async ({
|
|
|
114705
114758
|
console.error(`${prefix}Failed to generate schematic SVG:`, error);
|
|
114706
114759
|
}
|
|
114707
114760
|
}
|
|
114761
|
+
if (imageFormats.simulationSvgs || imageFormats.simulationSchematicSvgs) {
|
|
114762
|
+
try {
|
|
114763
|
+
const wroteSimulationSvgs = writeSimulationSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
|
|
114764
|
+
if (wroteSimulationSvgs) {
|
|
114765
|
+
if (imageFormats.simulationSvgs) {
|
|
114766
|
+
console.log(`${prefix}Written simulation.svg`);
|
|
114767
|
+
}
|
|
114768
|
+
if (imageFormats.simulationSchematicSvgs) {
|
|
114769
|
+
console.log(`${prefix}Written simulation-schematic.svg`);
|
|
114770
|
+
}
|
|
114771
|
+
}
|
|
114772
|
+
} catch (error) {
|
|
114773
|
+
console.error(`${prefix}Failed to generate simulation SVGs:`, error);
|
|
114774
|
+
}
|
|
114775
|
+
}
|
|
114708
114776
|
if (imageFormats.threeDPngs) {
|
|
114709
114777
|
try {
|
|
114710
114778
|
console.log(`${prefix}Converting circuit to GLB...`);
|
|
@@ -115125,16 +115193,20 @@ var DEFAULT_IMAGE_FORMAT_SELECTION = {
|
|
|
115125
115193
|
threeDPngs: true,
|
|
115126
115194
|
pcbPngs: false,
|
|
115127
115195
|
pcbSvgs: true,
|
|
115128
|
-
schematicSvgs: true
|
|
115196
|
+
schematicSvgs: true,
|
|
115197
|
+
simulationSvgs: false,
|
|
115198
|
+
simulationSchematicSvgs: false
|
|
115129
115199
|
};
|
|
115130
115200
|
var EMPTY_IMAGE_FORMAT_SELECTION = {
|
|
115131
115201
|
threeDPngs: false,
|
|
115132
115202
|
pcbPngs: false,
|
|
115133
115203
|
pcbSvgs: false,
|
|
115134
|
-
schematicSvgs: false
|
|
115204
|
+
schematicSvgs: false,
|
|
115205
|
+
simulationSvgs: false,
|
|
115206
|
+
simulationSchematicSvgs: false
|
|
115135
115207
|
};
|
|
115136
|
-
var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbPngs || selection.pcbSvgs || selection.schematicSvgs;
|
|
115137
|
-
var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.pcbPng || options?.svgs || options?.pcbSvgs || options?.schematicSvgs);
|
|
115208
|
+
var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbPngs || selection.pcbSvgs || selection.schematicSvgs || selection.simulationSvgs || selection.simulationSchematicSvgs;
|
|
115209
|
+
var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.pcbPng || options?.svgs || options?.pcbSvgs || options?.simulationSvgs || options?.simulationSchematicSvgs || options?.schematicSvgs);
|
|
115138
115210
|
var hasEstablishedOutputFlags = (options) => Boolean(options?.["3d"] || options?.["3dPng"] || options?.pcbOnly || options?.schematicOnly);
|
|
115139
115211
|
var resolveImageFormatSelection = (options) => {
|
|
115140
115212
|
const hasNewFlags = hasNewOutputFlags(options);
|
|
@@ -115151,7 +115223,9 @@ var resolveImageFormatSelection = (options) => {
|
|
|
115151
115223
|
threeDPngs: Boolean(options?.["3d"] || options?.["3dPng"]),
|
|
115152
115224
|
pcbPngs: false,
|
|
115153
115225
|
pcbSvgs: true,
|
|
115154
|
-
schematicSvgs: true
|
|
115226
|
+
schematicSvgs: true,
|
|
115227
|
+
simulationSvgs: false,
|
|
115228
|
+
simulationSchematicSvgs: false
|
|
115155
115229
|
};
|
|
115156
115230
|
if (options?.pcbOnly && !options?.schematicOnly) {
|
|
115157
115231
|
selection2.schematicSvgs = false;
|
|
@@ -115167,6 +115241,8 @@ var resolveImageFormatSelection = (options) => {
|
|
|
115167
115241
|
if (options?.svgs) {
|
|
115168
115242
|
selection.pcbSvgs = true;
|
|
115169
115243
|
selection.schematicSvgs = true;
|
|
115244
|
+
selection.simulationSvgs = true;
|
|
115245
|
+
selection.simulationSchematicSvgs = true;
|
|
115170
115246
|
}
|
|
115171
115247
|
if (options?.pcbSvgs) {
|
|
115172
115248
|
selection.pcbSvgs = true;
|
|
@@ -115177,6 +115253,12 @@ var resolveImageFormatSelection = (options) => {
|
|
|
115177
115253
|
if (options?.schematicSvgs) {
|
|
115178
115254
|
selection.schematicSvgs = true;
|
|
115179
115255
|
}
|
|
115256
|
+
if (options?.simulationSvgs) {
|
|
115257
|
+
selection.simulationSvgs = true;
|
|
115258
|
+
}
|
|
115259
|
+
if (options?.simulationSchematicSvgs) {
|
|
115260
|
+
selection.simulationSchematicSvgs = true;
|
|
115261
|
+
}
|
|
115180
115262
|
if (options?.pngs || options?.["3d"] || options?.["3dPng"]) {
|
|
115181
115263
|
selection.threeDPngs = true;
|
|
115182
115264
|
}
|
|
@@ -115951,7 +116033,7 @@ var getOutputDirName = (relativePath) => {
|
|
|
115951
116033
|
return relativePath.replace(/(\.board|\.circuit)?\.tsx$/, "").replace(/\.circuit\.json$/, "");
|
|
115952
116034
|
};
|
|
115953
116035
|
var registerBuild = (program2) => {
|
|
115954
|
-
program2.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--ignore-netlist-drc", "Ignore netlist DRC errors/warnings").option("--ignore-pin-specification-drc", "Ignore pin-specification DRC errors/warnings").option("--ignore-placement-drc", "Ignore placement DRC errors/warnings").option("--ignore-routing-drc", "Ignore routing DRC errors/warnings").option("--ignore-config", "Ignore options from tscircuit.config.json").option("--disable-pcb", "Disable PCB outputs").option("--routing-disabled", "Disable routing during circuit generation").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--pngs", "Generate PNG outputs during build generation").option("--pcb-png", "Generate PCB PNG outputs during build generation").option("--svgs", "Generate SVG outputs during build generation").option("--pcb-svgs", "Generate PCB SVG outputs during build generation").option("--schematic-svgs", "Generate schematic SVG outputs during build generation").option("--3d-png", "Generate 3D PNG outputs during build generation").option("--3d", "Generate 3D PNG outputs during build generation").option("--pcb-only", "Generate only PCB SVG outputs during build generation").option("--schematic-only", "Generate only schematic SVG outputs during build generation").option("--kicad-project", "Generate KiCad project directories for each successful build output").option("--kicad-project-zip", "Generate a zipped KiCad project for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--kicad-library-name <name>", "Specify the name of the KiCad library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--show-courtyards", "Show courtyard outlines in PCB SVG outputs").option("--glbs", "Generate GLB 3D model files for every successful build").option("--step", "Generate STEP 3D model files for every successful build").option("--profile", "Log per-circuit circuit.json generation time during build").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").option("--inject-props <json>", "Inject JSON props into the built file's default export").option("--inject-props-file <path>", "Inject JSON props from a file into the built file's default export").action(async (file, options) => {
|
|
116036
|
+
program2.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--ignore-netlist-drc", "Ignore netlist DRC errors/warnings").option("--ignore-pin-specification-drc", "Ignore pin-specification DRC errors/warnings").option("--ignore-placement-drc", "Ignore placement DRC errors/warnings").option("--ignore-routing-drc", "Ignore routing DRC errors/warnings").option("--ignore-config", "Ignore options from tscircuit.config.json").option("--disable-pcb", "Disable PCB outputs").option("--routing-disabled", "Disable routing during circuit generation").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--pngs", "Generate PNG outputs during build generation").option("--pcb-png", "Generate PCB PNG outputs during build generation").option("--svgs", "Generate SVG outputs during build generation").option("--pcb-svgs", "Generate PCB SVG outputs during build generation").option("--schematic-svgs", "Generate schematic SVG outputs during build generation").option("--simulation-svgs", "Generate simulation graph SVG outputs during build generation").option("--simulation-schematic-svgs", "Generate schematic simulation SVG outputs during build generation").option("--3d-png", "Generate 3D PNG outputs during build generation").option("--3d", "Generate 3D PNG outputs during build generation").option("--pcb-only", "Generate only PCB SVG outputs during build generation").option("--schematic-only", "Generate only schematic SVG outputs during build generation").option("--kicad-project", "Generate KiCad project directories for each successful build output").option("--kicad-project-zip", "Generate a zipped KiCad project for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--kicad-library-name <name>", "Specify the name of the KiCad library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--show-courtyards", "Show courtyard outlines in PCB SVG outputs").option("--glbs", "Generate GLB 3D model files for every successful build").option("--step", "Generate STEP 3D model files for every successful build").option("--profile", "Log per-circuit circuit.json generation time during build").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").option("--inject-props <json>", "Inject JSON props into the built file's default export").option("--inject-props-file <path>", "Inject JSON props from a file into the built file's default export").action(async (file, options) => {
|
|
115955
116037
|
try {
|
|
115956
116038
|
const transpileExplicitlyRequested = options?.transpile === true;
|
|
115957
116039
|
const resolvedRoot = path42.resolve(process.cwd());
|
|
@@ -116430,6 +116512,8 @@ var registerBuild = (program2) => {
|
|
|
116430
116512
|
resolvedOptions?.svgs && "svgs",
|
|
116431
116513
|
resolvedOptions?.pcbSvgs && "pcb-svgs",
|
|
116432
116514
|
resolvedOptions?.schematicSvgs && "schematic-svgs",
|
|
116515
|
+
resolvedOptions?.simulationSvgs && "simulation-svgs",
|
|
116516
|
+
resolvedOptions?.simulationSchematicSvgs && "simulation-schematic-svgs",
|
|
116433
116517
|
resolvedOptions?.["3dPng"] && "3d-png",
|
|
116434
116518
|
resolvedOptions?.["3d"] && "3d",
|
|
116435
116519
|
resolvedOptions?.pcbOnly && "pcb-only",
|
|
@@ -278277,2718 +278361,25 @@ import {
|
|
|
278277
278361
|
} from "circuit-to-svg";
|
|
278278
278362
|
import { renderGLTFToPNGFromGLB as renderGLTFToPNGFromGLB3 } from "poppygl";
|
|
278279
278363
|
|
|
278280
|
-
// node_modules/@tscircuit/image-utils/dist/looks-same.js
|
|
278281
|
-
import { readFile as readFile2, writeFile } from "fs/promises";
|
|
278282
|
-
|
|
278283
|
-
// node_modules/color-diff/lib/convert.js
|
|
278284
|
-
function rgbaToLab(c3, bc2) {
|
|
278285
|
-
bc2 = normalize7(bc2 || { R: 255, G: 255, B: 255 });
|
|
278286
|
-
c3 = normalize7(c3);
|
|
278287
|
-
let newC = c3;
|
|
278288
|
-
if (c3.A !== undefined) {
|
|
278289
|
-
newC = {
|
|
278290
|
-
R: bc2.R + (c3.R - bc2.R) * c3.A,
|
|
278291
|
-
G: bc2.G + (c3.G - bc2.G) * c3.A,
|
|
278292
|
-
B: bc2.B + (c3.B - bc2.B) * c3.A
|
|
278293
|
-
};
|
|
278294
|
-
}
|
|
278295
|
-
return xyzToLab(rgbToXyz(newC));
|
|
278296
|
-
}
|
|
278297
|
-
function rgbToXyz(c3) {
|
|
278298
|
-
let R4 = c3.R / 255;
|
|
278299
|
-
let G4 = c3.G / 255;
|
|
278300
|
-
let B4 = c3.B / 255;
|
|
278301
|
-
if (R4 > 0.04045)
|
|
278302
|
-
R4 = Math.pow((R4 + 0.055) / 1.055, 2.4);
|
|
278303
|
-
else
|
|
278304
|
-
R4 = R4 / 12.92;
|
|
278305
|
-
if (G4 > 0.04045)
|
|
278306
|
-
G4 = Math.pow((G4 + 0.055) / 1.055, 2.4);
|
|
278307
|
-
else
|
|
278308
|
-
G4 = G4 / 12.92;
|
|
278309
|
-
if (B4 > 0.04045)
|
|
278310
|
-
B4 = Math.pow((B4 + 0.055) / 1.055, 2.4);
|
|
278311
|
-
else
|
|
278312
|
-
B4 = B4 / 12.92;
|
|
278313
|
-
R4 *= 100;
|
|
278314
|
-
G4 *= 100;
|
|
278315
|
-
B4 *= 100;
|
|
278316
|
-
const X4 = R4 * 0.4124 + G4 * 0.3576 + B4 * 0.1805;
|
|
278317
|
-
const Y4 = R4 * 0.2126 + G4 * 0.7152 + B4 * 0.0722;
|
|
278318
|
-
const Z4 = R4 * 0.0193 + G4 * 0.1192 + B4 * 0.9505;
|
|
278319
|
-
return { X: X4, Y: Y4, Z: Z4 };
|
|
278320
|
-
}
|
|
278321
|
-
function xyzToLab(c3) {
|
|
278322
|
-
const refY = 100;
|
|
278323
|
-
const refZ = 108.883;
|
|
278324
|
-
const refX = 95.047;
|
|
278325
|
-
let Y4 = c3.Y / refY;
|
|
278326
|
-
let Z4 = c3.Z / refZ;
|
|
278327
|
-
let X4 = c3.X / refX;
|
|
278328
|
-
if (X4 > 0.008856)
|
|
278329
|
-
X4 = Math.pow(X4, 1 / 3);
|
|
278330
|
-
else
|
|
278331
|
-
X4 = 7.787 * X4 + 16 / 116;
|
|
278332
|
-
if (Y4 > 0.008856)
|
|
278333
|
-
Y4 = Math.pow(Y4, 1 / 3);
|
|
278334
|
-
else
|
|
278335
|
-
Y4 = 7.787 * Y4 + 16 / 116;
|
|
278336
|
-
if (Z4 > 0.008856)
|
|
278337
|
-
Z4 = Math.pow(Z4, 1 / 3);
|
|
278338
|
-
else
|
|
278339
|
-
Z4 = 7.787 * Z4 + 16 / 116;
|
|
278340
|
-
const L3 = 116 * Y4 - 16;
|
|
278341
|
-
const a2 = 500 * (X4 - Y4);
|
|
278342
|
-
const b = 200 * (Y4 - Z4);
|
|
278343
|
-
return { L: L3, a: a2, b };
|
|
278344
|
-
}
|
|
278345
|
-
function normalize7(c3) {
|
|
278346
|
-
let r4, g6, b, a2;
|
|
278347
|
-
if ("R" in c3) {
|
|
278348
|
-
r4 = c3.R;
|
|
278349
|
-
g6 = c3.G;
|
|
278350
|
-
b = c3.B;
|
|
278351
|
-
a2 = c3.A;
|
|
278352
|
-
} else {
|
|
278353
|
-
r4 = c3.r;
|
|
278354
|
-
g6 = c3.g;
|
|
278355
|
-
b = c3.b;
|
|
278356
|
-
a2 = c3.a;
|
|
278357
|
-
}
|
|
278358
|
-
const normalizedC = { R: r4, G: g6, B: b };
|
|
278359
|
-
if (a2 !== undefined)
|
|
278360
|
-
normalizedC.A = a2;
|
|
278361
|
-
return normalizedC;
|
|
278362
|
-
}
|
|
278363
|
-
|
|
278364
|
-
// node_modules/color-diff/lib/diff.js
|
|
278365
|
-
function ciede2000(c12, c22, bc2) {
|
|
278366
|
-
if ("R" in c12 || "r" in c12) {
|
|
278367
|
-
c12 = rgbaToLab(c12, bc2);
|
|
278368
|
-
}
|
|
278369
|
-
if ("R" in c22 || "r" in c22) {
|
|
278370
|
-
c22 = rgbaToLab(c22, bc2);
|
|
278371
|
-
}
|
|
278372
|
-
const L12 = c12.L;
|
|
278373
|
-
const a12 = c12.a;
|
|
278374
|
-
const b12 = c12.b;
|
|
278375
|
-
const L23 = c22.L;
|
|
278376
|
-
const a2 = c22.a;
|
|
278377
|
-
const b22 = c22.b;
|
|
278378
|
-
const kL = 1;
|
|
278379
|
-
const kC = 1;
|
|
278380
|
-
const kH = 1;
|
|
278381
|
-
const C12 = Math.sqrt(Math.pow(a12, 2) + Math.pow(b12, 2));
|
|
278382
|
-
const C22 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b22, 2));
|
|
278383
|
-
const aC1C2 = (C12 + C22) / 2;
|
|
278384
|
-
const G4 = 0.5 * (1 - Math.sqrt(Math.pow(aC1C2, 7) / (Math.pow(aC1C2, 7) + Math.pow(25, 7))));
|
|
278385
|
-
const a1p = (1 + G4) * a12;
|
|
278386
|
-
const a2p = (1 + G4) * a2;
|
|
278387
|
-
const C1p = Math.sqrt(Math.pow(a1p, 2) + Math.pow(b12, 2));
|
|
278388
|
-
const C2p = Math.sqrt(Math.pow(a2p, 2) + Math.pow(b22, 2));
|
|
278389
|
-
const h1p = hpF(b12, a1p);
|
|
278390
|
-
const h2p = hpF(b22, a2p);
|
|
278391
|
-
const dLp = L23 - L12;
|
|
278392
|
-
const dCp = C2p - C1p;
|
|
278393
|
-
const dhp = dhpF(C12, C22, h1p, h2p);
|
|
278394
|
-
const dHp = 2 * Math.sqrt(C1p * C2p) * Math.sin(radians(dhp) / 2);
|
|
278395
|
-
const aL = (L12 + L23) / 2;
|
|
278396
|
-
const aCp = (C1p + C2p) / 2;
|
|
278397
|
-
const aHp = aHpF(C12, C22, h1p, h2p);
|
|
278398
|
-
const T4 = 1 - 0.17 * Math.cos(radians(aHp - 30)) + 0.24 * Math.cos(radians(2 * aHp)) + 0.32 * Math.cos(radians(3 * aHp + 6)) - 0.2 * Math.cos(radians(4 * aHp - 63));
|
|
278399
|
-
const dRo = 30 * Math.exp(-Math.pow((aHp - 275) / 25, 2));
|
|
278400
|
-
const RC = Math.sqrt(Math.pow(aCp, 7) / (Math.pow(aCp, 7) + Math.pow(25, 7)));
|
|
278401
|
-
const SL = 1 + 0.015 * Math.pow(aL - 50, 2) / Math.sqrt(20 + Math.pow(aL - 50, 2));
|
|
278402
|
-
const SC = 1 + 0.045 * aCp;
|
|
278403
|
-
const SH = 1 + 0.015 * aCp * T4;
|
|
278404
|
-
const RT = -2 * RC * Math.sin(radians(2 * dRo));
|
|
278405
|
-
const dE = Math.sqrt(Math.pow(dLp / (SL * kL), 2) + Math.pow(dCp / (SC * kC), 2) + Math.pow(dHp / (SH * kH), 2) + RT * (dCp / (SC * kC)) * (dHp / (SH * kH)));
|
|
278406
|
-
return dE;
|
|
278407
|
-
}
|
|
278408
|
-
function degrees(n3) {
|
|
278409
|
-
return n3 * (180 / Math.PI);
|
|
278410
|
-
}
|
|
278411
|
-
function radians(n3) {
|
|
278412
|
-
return n3 * (Math.PI / 180);
|
|
278413
|
-
}
|
|
278414
|
-
function hpF(x3, y4) {
|
|
278415
|
-
if (x3 === 0 && y4 === 0)
|
|
278416
|
-
return 0;
|
|
278417
|
-
else {
|
|
278418
|
-
const tmphp = degrees(Math.atan2(x3, y4));
|
|
278419
|
-
if (tmphp >= 0)
|
|
278420
|
-
return tmphp;
|
|
278421
|
-
else
|
|
278422
|
-
return tmphp + 360;
|
|
278423
|
-
}
|
|
278424
|
-
}
|
|
278425
|
-
function dhpF(C12, C22, h1p, h2p) {
|
|
278426
|
-
if (C12 * C22 === 0)
|
|
278427
|
-
return 0;
|
|
278428
|
-
else if (Math.abs(h2p - h1p) <= 180)
|
|
278429
|
-
return h2p - h1p;
|
|
278430
|
-
else if (h2p - h1p > 180)
|
|
278431
|
-
return h2p - h1p - 360;
|
|
278432
|
-
else if (h2p - h1p < -180)
|
|
278433
|
-
return h2p - h1p + 360;
|
|
278434
|
-
else
|
|
278435
|
-
throw new Error;
|
|
278436
|
-
}
|
|
278437
|
-
function aHpF(C12, C22, h1p, h2p) {
|
|
278438
|
-
if (C12 * C22 === 0)
|
|
278439
|
-
return h1p + h2p;
|
|
278440
|
-
else if (Math.abs(h1p - h2p) <= 180)
|
|
278441
|
-
return (h1p + h2p) / 2;
|
|
278442
|
-
else if (Math.abs(h1p - h2p) > 180 && h1p + h2p < 360)
|
|
278443
|
-
return (h1p + h2p + 360) / 2;
|
|
278444
|
-
else if (Math.abs(h1p - h2p) > 180 && h1p + h2p >= 360)
|
|
278445
|
-
return (h1p + h2p - 360) / 2;
|
|
278446
|
-
else
|
|
278447
|
-
throw new Error;
|
|
278448
|
-
}
|
|
278449
|
-
|
|
278450
|
-
// node_modules/color-diff/index.js
|
|
278451
|
-
function rgb_to_lab(c3) {
|
|
278452
|
-
return rgbaToLab(c3);
|
|
278453
|
-
}
|
|
278454
|
-
|
|
278455
|
-
// node_modules/fflate/esm/index.mjs
|
|
278456
|
-
import { createRequire as createRequire4 } from "module";
|
|
278457
|
-
var require3 = createRequire4("/");
|
|
278458
|
-
var _a3;
|
|
278459
|
-
var Worker2;
|
|
278460
|
-
var isMarkedAsUntransferable;
|
|
278461
|
-
try {
|
|
278462
|
-
_a3 = require3("worker_threads"), Worker2 = _a3.Worker, isMarkedAsUntransferable = _a3.isMarkedAsUntransferable;
|
|
278463
|
-
} catch (e4) {}
|
|
278464
|
-
var u8 = Uint8Array;
|
|
278465
|
-
var u16 = Uint16Array;
|
|
278466
|
-
var i32 = Int32Array;
|
|
278467
|
-
var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]);
|
|
278468
|
-
var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]);
|
|
278469
|
-
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
278470
|
-
var freb = function(eb, start) {
|
|
278471
|
-
var b = new u16(31);
|
|
278472
|
-
for (var i2 = 0;i2 < 31; ++i2) {
|
|
278473
|
-
b[i2] = start += 1 << eb[i2 - 1];
|
|
278474
|
-
}
|
|
278475
|
-
var r4 = new i32(b[30]);
|
|
278476
|
-
for (var i2 = 1;i2 < 30; ++i2) {
|
|
278477
|
-
for (var j4 = b[i2];j4 < b[i2 + 1]; ++j4) {
|
|
278478
|
-
r4[j4] = j4 - b[i2] << 5 | i2;
|
|
278479
|
-
}
|
|
278480
|
-
}
|
|
278481
|
-
return { b, r: r4 };
|
|
278482
|
-
};
|
|
278483
|
-
var _a3 = freb(fleb, 2);
|
|
278484
|
-
var fl3 = _a3.b;
|
|
278485
|
-
var revfl = _a3.r;
|
|
278486
|
-
fl3[28] = 258, revfl[258] = 28;
|
|
278487
|
-
var _b2 = freb(fdeb, 0);
|
|
278488
|
-
var fd3 = _b2.b;
|
|
278489
|
-
var revfd = _b2.r;
|
|
278490
|
-
var rev = new u16(32768);
|
|
278491
|
-
for (i2 = 0;i2 < 32768; ++i2) {
|
|
278492
|
-
x3 = (i2 & 43690) >> 1 | (i2 & 21845) << 1;
|
|
278493
|
-
x3 = (x3 & 52428) >> 2 | (x3 & 13107) << 2;
|
|
278494
|
-
x3 = (x3 & 61680) >> 4 | (x3 & 3855) << 4;
|
|
278495
|
-
rev[i2] = ((x3 & 65280) >> 8 | (x3 & 255) << 8) >> 1;
|
|
278496
|
-
}
|
|
278497
|
-
var x3;
|
|
278498
|
-
var i2;
|
|
278499
|
-
var hMap = function(cd3, mb2, r4) {
|
|
278500
|
-
var s2 = cd3.length;
|
|
278501
|
-
var i3 = 0;
|
|
278502
|
-
var l3 = new u16(mb2);
|
|
278503
|
-
for (;i3 < s2; ++i3) {
|
|
278504
|
-
if (cd3[i3])
|
|
278505
|
-
++l3[cd3[i3] - 1];
|
|
278506
|
-
}
|
|
278507
|
-
var le3 = new u16(mb2);
|
|
278508
|
-
for (i3 = 1;i3 < mb2; ++i3) {
|
|
278509
|
-
le3[i3] = le3[i3 - 1] + l3[i3 - 1] << 1;
|
|
278510
|
-
}
|
|
278511
|
-
var co3;
|
|
278512
|
-
if (r4) {
|
|
278513
|
-
co3 = new u16(1 << mb2);
|
|
278514
|
-
var rvb = 15 - mb2;
|
|
278515
|
-
for (i3 = 0;i3 < s2; ++i3) {
|
|
278516
|
-
if (cd3[i3]) {
|
|
278517
|
-
var sv = i3 << 4 | cd3[i3];
|
|
278518
|
-
var r_1 = mb2 - cd3[i3];
|
|
278519
|
-
var v3 = le3[cd3[i3] - 1]++ << r_1;
|
|
278520
|
-
for (var m3 = v3 | (1 << r_1) - 1;v3 <= m3; ++v3) {
|
|
278521
|
-
co3[rev[v3] >> rvb] = sv;
|
|
278522
|
-
}
|
|
278523
|
-
}
|
|
278524
|
-
}
|
|
278525
|
-
} else {
|
|
278526
|
-
co3 = new u16(s2);
|
|
278527
|
-
for (i3 = 0;i3 < s2; ++i3) {
|
|
278528
|
-
if (cd3[i3]) {
|
|
278529
|
-
co3[i3] = rev[le3[cd3[i3] - 1]++] >> 15 - cd3[i3];
|
|
278530
|
-
}
|
|
278531
|
-
}
|
|
278532
|
-
}
|
|
278533
|
-
return co3;
|
|
278534
|
-
};
|
|
278535
|
-
var flt = new u8(288);
|
|
278536
|
-
for (i2 = 0;i2 < 144; ++i2)
|
|
278537
|
-
flt[i2] = 8;
|
|
278538
|
-
var i2;
|
|
278539
|
-
for (i2 = 144;i2 < 256; ++i2)
|
|
278540
|
-
flt[i2] = 9;
|
|
278541
|
-
var i2;
|
|
278542
|
-
for (i2 = 256;i2 < 280; ++i2)
|
|
278543
|
-
flt[i2] = 7;
|
|
278544
|
-
var i2;
|
|
278545
|
-
for (i2 = 280;i2 < 288; ++i2)
|
|
278546
|
-
flt[i2] = 8;
|
|
278547
|
-
var i2;
|
|
278548
|
-
var fdt = new u8(32);
|
|
278549
|
-
for (i2 = 0;i2 < 32; ++i2)
|
|
278550
|
-
fdt[i2] = 5;
|
|
278551
|
-
var i2;
|
|
278552
|
-
var flm = /* @__PURE__ */ hMap(flt, 9, 0);
|
|
278553
|
-
var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
|
|
278554
|
-
var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
|
|
278555
|
-
var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
|
|
278556
|
-
var max = function(a2) {
|
|
278557
|
-
var m3 = a2[0];
|
|
278558
|
-
for (var i3 = 1;i3 < a2.length; ++i3) {
|
|
278559
|
-
if (a2[i3] > m3)
|
|
278560
|
-
m3 = a2[i3];
|
|
278561
|
-
}
|
|
278562
|
-
return m3;
|
|
278563
|
-
};
|
|
278564
|
-
var bits = function(d3, p3, m3) {
|
|
278565
|
-
var o3 = p3 / 8 | 0;
|
|
278566
|
-
return (d3[o3] | d3[o3 + 1] << 8) >> (p3 & 7) & m3;
|
|
278567
|
-
};
|
|
278568
|
-
var bits16 = function(d3, p3) {
|
|
278569
|
-
var o3 = p3 / 8 | 0;
|
|
278570
|
-
return (d3[o3] | d3[o3 + 1] << 8 | d3[o3 + 2] << 16) >> (p3 & 7);
|
|
278571
|
-
};
|
|
278572
|
-
var shft = function(p3) {
|
|
278573
|
-
return (p3 + 7) / 8 | 0;
|
|
278574
|
-
};
|
|
278575
|
-
var slc = function(v3, s2, e4) {
|
|
278576
|
-
if (s2 == null || s2 < 0)
|
|
278577
|
-
s2 = 0;
|
|
278578
|
-
if (e4 == null || e4 > v3.length)
|
|
278579
|
-
e4 = v3.length;
|
|
278580
|
-
return new u8(v3.subarray(s2, e4));
|
|
278581
|
-
};
|
|
278582
|
-
var ec2 = [
|
|
278583
|
-
"unexpected EOF",
|
|
278584
|
-
"invalid block type",
|
|
278585
|
-
"invalid length/literal",
|
|
278586
|
-
"invalid distance",
|
|
278587
|
-
"stream finished",
|
|
278588
|
-
"no stream handler",
|
|
278589
|
-
,
|
|
278590
|
-
"no callback",
|
|
278591
|
-
"invalid UTF-8 data",
|
|
278592
|
-
"extra field too long",
|
|
278593
|
-
"date not in range 1980-2099",
|
|
278594
|
-
"filename too long",
|
|
278595
|
-
"stream finishing",
|
|
278596
|
-
"invalid zip data"
|
|
278597
|
-
];
|
|
278598
|
-
var err = function(ind, msg, nt3) {
|
|
278599
|
-
var e4 = new Error(msg || ec2[ind]);
|
|
278600
|
-
e4.code = ind;
|
|
278601
|
-
if (Error.captureStackTrace)
|
|
278602
|
-
Error.captureStackTrace(e4, err);
|
|
278603
|
-
if (!nt3)
|
|
278604
|
-
throw e4;
|
|
278605
|
-
return e4;
|
|
278606
|
-
};
|
|
278607
|
-
var inflt = function(dat, st3, buf, dict) {
|
|
278608
|
-
var sl3 = dat.length, dl3 = dict ? dict.length : 0;
|
|
278609
|
-
if (!sl3 || st3.f && !st3.l)
|
|
278610
|
-
return buf || new u8(0);
|
|
278611
|
-
var noBuf = !buf;
|
|
278612
|
-
var resize = noBuf || st3.i != 2;
|
|
278613
|
-
var noSt = st3.i;
|
|
278614
|
-
if (noBuf)
|
|
278615
|
-
buf = new u8(sl3 * 3);
|
|
278616
|
-
var cbuf = function(l4) {
|
|
278617
|
-
var bl3 = buf.length;
|
|
278618
|
-
if (l4 > bl3) {
|
|
278619
|
-
var nbuf = new u8(Math.max(bl3 * 2, l4));
|
|
278620
|
-
nbuf.set(buf);
|
|
278621
|
-
buf = nbuf;
|
|
278622
|
-
}
|
|
278623
|
-
};
|
|
278624
|
-
var final = st3.f || 0, pos = st3.p || 0, bt3 = st3.b || 0, lm2 = st3.l, dm2 = st3.d, lbt = st3.m, dbt = st3.n;
|
|
278625
|
-
var tbts = sl3 * 8;
|
|
278626
|
-
do {
|
|
278627
|
-
if (!lm2) {
|
|
278628
|
-
final = bits(dat, pos, 1);
|
|
278629
|
-
var type = bits(dat, pos + 1, 3);
|
|
278630
|
-
pos += 3;
|
|
278631
|
-
if (!type) {
|
|
278632
|
-
var s2 = shft(pos) + 4, l3 = dat[s2 - 4] | dat[s2 - 3] << 8, t17 = s2 + l3;
|
|
278633
|
-
if (t17 > sl3) {
|
|
278634
|
-
if (noSt)
|
|
278635
|
-
err(0);
|
|
278636
|
-
break;
|
|
278637
|
-
}
|
|
278638
|
-
if (resize)
|
|
278639
|
-
cbuf(bt3 + l3);
|
|
278640
|
-
buf.set(dat.subarray(s2, t17), bt3);
|
|
278641
|
-
st3.b = bt3 += l3, st3.p = pos = t17 * 8, st3.f = final;
|
|
278642
|
-
continue;
|
|
278643
|
-
} else if (type == 1)
|
|
278644
|
-
lm2 = flrm, dm2 = fdrm, lbt = 9, dbt = 5;
|
|
278645
|
-
else if (type == 2) {
|
|
278646
|
-
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
278647
|
-
var tl3 = hLit + bits(dat, pos + 5, 31) + 1;
|
|
278648
|
-
pos += 14;
|
|
278649
|
-
var ldt = new u8(tl3);
|
|
278650
|
-
var clt = new u8(19);
|
|
278651
|
-
for (var i3 = 0;i3 < hcLen; ++i3) {
|
|
278652
|
-
clt[clim[i3]] = bits(dat, pos + i3 * 3, 7);
|
|
278653
|
-
}
|
|
278654
|
-
pos += hcLen * 3;
|
|
278655
|
-
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
278656
|
-
var clm = hMap(clt, clb, 1);
|
|
278657
|
-
for (var i3 = 0;i3 < tl3; ) {
|
|
278658
|
-
var r4 = clm[bits(dat, pos, clbmsk)];
|
|
278659
|
-
pos += r4 & 15;
|
|
278660
|
-
var s2 = r4 >> 4;
|
|
278661
|
-
if (s2 < 16) {
|
|
278662
|
-
ldt[i3++] = s2;
|
|
278663
|
-
} else {
|
|
278664
|
-
var c3 = 0, n3 = 0;
|
|
278665
|
-
if (s2 == 16)
|
|
278666
|
-
n3 = 3 + bits(dat, pos, 3), pos += 2, c3 = ldt[i3 - 1];
|
|
278667
|
-
else if (s2 == 17)
|
|
278668
|
-
n3 = 3 + bits(dat, pos, 7), pos += 3;
|
|
278669
|
-
else if (s2 == 18)
|
|
278670
|
-
n3 = 11 + bits(dat, pos, 127), pos += 7;
|
|
278671
|
-
while (n3--)
|
|
278672
|
-
ldt[i3++] = c3;
|
|
278673
|
-
}
|
|
278674
|
-
}
|
|
278675
|
-
var lt3 = ldt.subarray(0, hLit), dt3 = ldt.subarray(hLit);
|
|
278676
|
-
lbt = max(lt3);
|
|
278677
|
-
dbt = max(dt3);
|
|
278678
|
-
lm2 = hMap(lt3, lbt, 1);
|
|
278679
|
-
dm2 = hMap(dt3, dbt, 1);
|
|
278680
|
-
} else
|
|
278681
|
-
err(1);
|
|
278682
|
-
if (pos > tbts) {
|
|
278683
|
-
if (noSt)
|
|
278684
|
-
err(0);
|
|
278685
|
-
break;
|
|
278686
|
-
}
|
|
278687
|
-
}
|
|
278688
|
-
if (resize)
|
|
278689
|
-
cbuf(bt3 + 131072);
|
|
278690
|
-
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
278691
|
-
var lpos = pos;
|
|
278692
|
-
for (;; lpos = pos) {
|
|
278693
|
-
var c3 = lm2[bits16(dat, pos) & lms], sym = c3 >> 4;
|
|
278694
|
-
pos += c3 & 15;
|
|
278695
|
-
if (pos > tbts) {
|
|
278696
|
-
if (noSt)
|
|
278697
|
-
err(0);
|
|
278698
|
-
break;
|
|
278699
|
-
}
|
|
278700
|
-
if (!c3)
|
|
278701
|
-
err(2);
|
|
278702
|
-
if (sym < 256)
|
|
278703
|
-
buf[bt3++] = sym;
|
|
278704
|
-
else if (sym == 256) {
|
|
278705
|
-
lpos = pos, lm2 = null;
|
|
278706
|
-
break;
|
|
278707
|
-
} else {
|
|
278708
|
-
var add = sym - 254;
|
|
278709
|
-
if (sym > 264) {
|
|
278710
|
-
var i3 = sym - 257, b = fleb[i3];
|
|
278711
|
-
add = bits(dat, pos, (1 << b) - 1) + fl3[i3];
|
|
278712
|
-
pos += b;
|
|
278713
|
-
}
|
|
278714
|
-
var d3 = dm2[bits16(dat, pos) & dms], dsym = d3 >> 4;
|
|
278715
|
-
if (!d3)
|
|
278716
|
-
err(3);
|
|
278717
|
-
pos += d3 & 15;
|
|
278718
|
-
var dt3 = fd3[dsym];
|
|
278719
|
-
if (dsym > 3) {
|
|
278720
|
-
var b = fdeb[dsym];
|
|
278721
|
-
dt3 += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
278722
|
-
}
|
|
278723
|
-
if (pos > tbts) {
|
|
278724
|
-
if (noSt)
|
|
278725
|
-
err(0);
|
|
278726
|
-
break;
|
|
278727
|
-
}
|
|
278728
|
-
if (resize)
|
|
278729
|
-
cbuf(bt3 + 131072);
|
|
278730
|
-
var end = bt3 + add;
|
|
278731
|
-
if (bt3 < dt3) {
|
|
278732
|
-
var shift = dl3 - dt3, dend = Math.min(dt3, end);
|
|
278733
|
-
if (shift + bt3 < 0)
|
|
278734
|
-
err(3);
|
|
278735
|
-
for (;bt3 < dend; ++bt3)
|
|
278736
|
-
buf[bt3] = dict[shift + bt3];
|
|
278737
|
-
}
|
|
278738
|
-
for (;bt3 < end; ++bt3)
|
|
278739
|
-
buf[bt3] = buf[bt3 - dt3];
|
|
278740
|
-
}
|
|
278741
|
-
}
|
|
278742
|
-
st3.l = lm2, st3.p = lpos, st3.b = bt3, st3.f = final;
|
|
278743
|
-
if (lm2)
|
|
278744
|
-
final = 1, st3.m = lbt, st3.d = dm2, st3.n = dbt;
|
|
278745
|
-
} while (!final);
|
|
278746
|
-
return bt3 != buf.length && noBuf ? slc(buf, 0, bt3) : buf.subarray(0, bt3);
|
|
278747
|
-
};
|
|
278748
|
-
var wbits = function(d3, p3, v3) {
|
|
278749
|
-
v3 <<= p3 & 7;
|
|
278750
|
-
var o3 = p3 / 8 | 0;
|
|
278751
|
-
d3[o3] |= v3;
|
|
278752
|
-
d3[o3 + 1] |= v3 >> 8;
|
|
278753
|
-
};
|
|
278754
|
-
var wbits16 = function(d3, p3, v3) {
|
|
278755
|
-
v3 <<= p3 & 7;
|
|
278756
|
-
var o3 = p3 / 8 | 0;
|
|
278757
|
-
d3[o3] |= v3;
|
|
278758
|
-
d3[o3 + 1] |= v3 >> 8;
|
|
278759
|
-
d3[o3 + 2] |= v3 >> 16;
|
|
278760
|
-
};
|
|
278761
|
-
var hTree = function(d3, mb2) {
|
|
278762
|
-
var t17 = [];
|
|
278763
|
-
for (var i3 = 0;i3 < d3.length; ++i3) {
|
|
278764
|
-
if (d3[i3])
|
|
278765
|
-
t17.push({ s: i3, f: d3[i3] });
|
|
278766
|
-
}
|
|
278767
|
-
var s2 = t17.length;
|
|
278768
|
-
var t23 = t17.slice();
|
|
278769
|
-
if (!s2)
|
|
278770
|
-
return { t: et3, l: 0 };
|
|
278771
|
-
if (s2 == 1) {
|
|
278772
|
-
var v3 = new u8(t17[0].s + 1);
|
|
278773
|
-
v3[t17[0].s] = 1;
|
|
278774
|
-
return { t: v3, l: 1 };
|
|
278775
|
-
}
|
|
278776
|
-
t17.sort(function(a2, b) {
|
|
278777
|
-
return a2.f - b.f;
|
|
278778
|
-
});
|
|
278779
|
-
t17.push({ s: -1, f: 25001 });
|
|
278780
|
-
var l3 = t17[0], r4 = t17[1], i02 = 0, i12 = 1, i22 = 2;
|
|
278781
|
-
t17[0] = { s: -1, f: l3.f + r4.f, l: l3, r: r4 };
|
|
278782
|
-
while (i12 != s2 - 1) {
|
|
278783
|
-
l3 = t17[t17[i02].f < t17[i22].f ? i02++ : i22++];
|
|
278784
|
-
r4 = t17[i02 != i12 && t17[i02].f < t17[i22].f ? i02++ : i22++];
|
|
278785
|
-
t17[i12++] = { s: -1, f: l3.f + r4.f, l: l3, r: r4 };
|
|
278786
|
-
}
|
|
278787
|
-
var maxSym = t23[0].s;
|
|
278788
|
-
for (var i3 = 1;i3 < s2; ++i3) {
|
|
278789
|
-
if (t23[i3].s > maxSym)
|
|
278790
|
-
maxSym = t23[i3].s;
|
|
278791
|
-
}
|
|
278792
|
-
var tr3 = new u16(maxSym + 1);
|
|
278793
|
-
var mbt = ln3(t17[i12 - 1], tr3, 0);
|
|
278794
|
-
if (mbt > mb2) {
|
|
278795
|
-
var i3 = 0, dt3 = 0;
|
|
278796
|
-
var lft = mbt - mb2, cst = 1 << lft;
|
|
278797
|
-
t23.sort(function(a2, b) {
|
|
278798
|
-
return tr3[b.s] - tr3[a2.s] || a2.f - b.f;
|
|
278799
|
-
});
|
|
278800
|
-
for (;i3 < s2; ++i3) {
|
|
278801
|
-
var i2_1 = t23[i3].s;
|
|
278802
|
-
if (tr3[i2_1] > mb2) {
|
|
278803
|
-
dt3 += cst - (1 << mbt - tr3[i2_1]);
|
|
278804
|
-
tr3[i2_1] = mb2;
|
|
278805
|
-
} else
|
|
278806
|
-
break;
|
|
278807
|
-
}
|
|
278808
|
-
dt3 >>= lft;
|
|
278809
|
-
while (dt3 > 0) {
|
|
278810
|
-
var i2_2 = t23[i3].s;
|
|
278811
|
-
if (tr3[i2_2] < mb2)
|
|
278812
|
-
dt3 -= 1 << mb2 - tr3[i2_2]++ - 1;
|
|
278813
|
-
else
|
|
278814
|
-
++i3;
|
|
278815
|
-
}
|
|
278816
|
-
for (;i3 >= 0 && dt3; --i3) {
|
|
278817
|
-
var i2_3 = t23[i3].s;
|
|
278818
|
-
if (tr3[i2_3] == mb2) {
|
|
278819
|
-
--tr3[i2_3];
|
|
278820
|
-
++dt3;
|
|
278821
|
-
}
|
|
278822
|
-
}
|
|
278823
|
-
mbt = mb2;
|
|
278824
|
-
}
|
|
278825
|
-
return { t: new u8(tr3), l: mbt };
|
|
278826
|
-
};
|
|
278827
|
-
var ln3 = function(n3, l3, d3) {
|
|
278828
|
-
return n3.s == -1 ? Math.max(ln3(n3.l, l3, d3 + 1), ln3(n3.r, l3, d3 + 1)) : l3[n3.s] = d3;
|
|
278829
|
-
};
|
|
278830
|
-
var lc3 = function(c3) {
|
|
278831
|
-
var s2 = c3.length;
|
|
278832
|
-
while (s2 && !c3[--s2])
|
|
278833
|
-
;
|
|
278834
|
-
var cl3 = new u16(++s2);
|
|
278835
|
-
var cli = 0, cln = c3[0], cls = 1;
|
|
278836
|
-
var w4 = function(v3) {
|
|
278837
|
-
cl3[cli++] = v3;
|
|
278838
|
-
};
|
|
278839
|
-
for (var i3 = 1;i3 <= s2; ++i3) {
|
|
278840
|
-
if (c3[i3] == cln && i3 != s2)
|
|
278841
|
-
++cls;
|
|
278842
|
-
else {
|
|
278843
|
-
if (!cln && cls > 2) {
|
|
278844
|
-
for (;cls > 138; cls -= 138)
|
|
278845
|
-
w4(32754);
|
|
278846
|
-
if (cls > 2) {
|
|
278847
|
-
w4(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
|
|
278848
|
-
cls = 0;
|
|
278849
|
-
}
|
|
278850
|
-
} else if (cls > 3) {
|
|
278851
|
-
w4(cln), --cls;
|
|
278852
|
-
for (;cls > 6; cls -= 6)
|
|
278853
|
-
w4(8304);
|
|
278854
|
-
if (cls > 2)
|
|
278855
|
-
w4(cls - 3 << 5 | 8208), cls = 0;
|
|
278856
|
-
}
|
|
278857
|
-
while (cls--)
|
|
278858
|
-
w4(cln);
|
|
278859
|
-
cls = 1;
|
|
278860
|
-
cln = c3[i3];
|
|
278861
|
-
}
|
|
278862
|
-
}
|
|
278863
|
-
return { c: cl3.subarray(0, cli), n: s2 };
|
|
278864
|
-
};
|
|
278865
|
-
var clen = function(cf3, cl3) {
|
|
278866
|
-
var l3 = 0;
|
|
278867
|
-
for (var i3 = 0;i3 < cl3.length; ++i3)
|
|
278868
|
-
l3 += cf3[i3] * cl3[i3];
|
|
278869
|
-
return l3;
|
|
278870
|
-
};
|
|
278871
|
-
var wfblk = function(out, pos, dat) {
|
|
278872
|
-
var s2 = dat.length;
|
|
278873
|
-
var o3 = shft(pos + 2);
|
|
278874
|
-
out[o3] = s2 & 255;
|
|
278875
|
-
out[o3 + 1] = s2 >> 8;
|
|
278876
|
-
out[o3 + 2] = out[o3] ^ 255;
|
|
278877
|
-
out[o3 + 3] = out[o3 + 1] ^ 255;
|
|
278878
|
-
for (var i3 = 0;i3 < s2; ++i3)
|
|
278879
|
-
out[o3 + i3 + 4] = dat[i3];
|
|
278880
|
-
return (o3 + 4 + s2) * 8;
|
|
278881
|
-
};
|
|
278882
|
-
var wblk = function(dat, out, final, syms, lf3, df3, eb, li3, bs3, bl3, p3) {
|
|
278883
|
-
wbits(out, p3++, final);
|
|
278884
|
-
++lf3[256];
|
|
278885
|
-
var _a4 = hTree(lf3, 15), dlt = _a4.t, mlb = _a4.l;
|
|
278886
|
-
var _b3 = hTree(df3, 15), ddt = _b3.t, mdb = _b3.l;
|
|
278887
|
-
var _c3 = lc3(dlt), lclt = _c3.c, nlc = _c3.n;
|
|
278888
|
-
var _d3 = lc3(ddt), lcdt = _d3.c, ndc = _d3.n;
|
|
278889
|
-
var lcfreq = new u16(19);
|
|
278890
|
-
for (var i3 = 0;i3 < lclt.length; ++i3)
|
|
278891
|
-
++lcfreq[lclt[i3] & 31];
|
|
278892
|
-
for (var i3 = 0;i3 < lcdt.length; ++i3)
|
|
278893
|
-
++lcfreq[lcdt[i3] & 31];
|
|
278894
|
-
var _e3 = hTree(lcfreq, 7), lct = _e3.t, mlcb = _e3.l;
|
|
278895
|
-
var nlcc = 19;
|
|
278896
|
-
for (;nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
|
|
278897
|
-
;
|
|
278898
|
-
var flen = bl3 + 5 << 3;
|
|
278899
|
-
var ftlen = clen(lf3, flt) + clen(df3, fdt) + eb;
|
|
278900
|
-
var dtlen = clen(lf3, dlt) + clen(df3, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
|
|
278901
|
-
if (bs3 >= 0 && flen <= ftlen && flen <= dtlen)
|
|
278902
|
-
return wfblk(out, p3, dat.subarray(bs3, bs3 + bl3));
|
|
278903
|
-
var lm2, ll3, dm2, dl3;
|
|
278904
|
-
wbits(out, p3, 1 + (dtlen < ftlen)), p3 += 2;
|
|
278905
|
-
if (dtlen < ftlen) {
|
|
278906
|
-
lm2 = hMap(dlt, mlb, 0), ll3 = dlt, dm2 = hMap(ddt, mdb, 0), dl3 = ddt;
|
|
278907
|
-
var llm = hMap(lct, mlcb, 0);
|
|
278908
|
-
wbits(out, p3, nlc - 257);
|
|
278909
|
-
wbits(out, p3 + 5, ndc - 1);
|
|
278910
|
-
wbits(out, p3 + 10, nlcc - 4);
|
|
278911
|
-
p3 += 14;
|
|
278912
|
-
for (var i3 = 0;i3 < nlcc; ++i3)
|
|
278913
|
-
wbits(out, p3 + 3 * i3, lct[clim[i3]]);
|
|
278914
|
-
p3 += 3 * nlcc;
|
|
278915
|
-
var lcts = [lclt, lcdt];
|
|
278916
|
-
for (var it3 = 0;it3 < 2; ++it3) {
|
|
278917
|
-
var clct = lcts[it3];
|
|
278918
|
-
for (var i3 = 0;i3 < clct.length; ++i3) {
|
|
278919
|
-
var len = clct[i3] & 31;
|
|
278920
|
-
wbits(out, p3, llm[len]), p3 += lct[len];
|
|
278921
|
-
if (len > 15)
|
|
278922
|
-
wbits(out, p3, clct[i3] >> 5 & 127), p3 += clct[i3] >> 12;
|
|
278923
|
-
}
|
|
278924
|
-
}
|
|
278925
|
-
} else {
|
|
278926
|
-
lm2 = flm, ll3 = flt, dm2 = fdm, dl3 = fdt;
|
|
278927
|
-
}
|
|
278928
|
-
for (var i3 = 0;i3 < li3; ++i3) {
|
|
278929
|
-
var sym = syms[i3];
|
|
278930
|
-
if (sym > 255) {
|
|
278931
|
-
var len = sym >> 18 & 31;
|
|
278932
|
-
wbits16(out, p3, lm2[len + 257]), p3 += ll3[len + 257];
|
|
278933
|
-
if (len > 7)
|
|
278934
|
-
wbits(out, p3, sym >> 23 & 31), p3 += fleb[len];
|
|
278935
|
-
var dst = sym & 31;
|
|
278936
|
-
wbits16(out, p3, dm2[dst]), p3 += dl3[dst];
|
|
278937
|
-
if (dst > 3)
|
|
278938
|
-
wbits16(out, p3, sym >> 5 & 8191), p3 += fdeb[dst];
|
|
278939
|
-
} else {
|
|
278940
|
-
wbits16(out, p3, lm2[sym]), p3 += ll3[sym];
|
|
278941
|
-
}
|
|
278942
|
-
}
|
|
278943
|
-
wbits16(out, p3, lm2[256]);
|
|
278944
|
-
return p3 + ll3[256];
|
|
278945
|
-
};
|
|
278946
|
-
var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
|
|
278947
|
-
var et3 = /* @__PURE__ */ new u8(0);
|
|
278948
|
-
var dflt = function(dat, lvl, plvl, pre, post, st3) {
|
|
278949
|
-
var s2 = st3.z || dat.length;
|
|
278950
|
-
var o3 = new u8(pre + s2 + 5 * (1 + Math.ceil(s2 / 7000)) + post);
|
|
278951
|
-
var w4 = o3.subarray(pre, o3.length - post);
|
|
278952
|
-
var lst = st3.l;
|
|
278953
|
-
var pos = (st3.r || 0) & 7;
|
|
278954
|
-
if (lvl) {
|
|
278955
|
-
if (pos)
|
|
278956
|
-
w4[0] = st3.r >> 3;
|
|
278957
|
-
var opt = deo[lvl - 1];
|
|
278958
|
-
var n3 = opt >> 13, c3 = opt & 8191;
|
|
278959
|
-
var msk_1 = (1 << plvl) - 1;
|
|
278960
|
-
var prev = st3.p || new u16(32768), head = st3.h || new u16(msk_1 + 1);
|
|
278961
|
-
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
|
|
278962
|
-
var hsh = function(i4) {
|
|
278963
|
-
return (dat[i4] ^ dat[i4 + 1] << bs1_1 ^ dat[i4 + 2] << bs2_1) & msk_1;
|
|
278964
|
-
};
|
|
278965
|
-
var syms = new i32(25000);
|
|
278966
|
-
var lf3 = new u16(288), df3 = new u16(32);
|
|
278967
|
-
var lc_1 = 0, eb = 0, i3 = st3.i || 0, li3 = 0, wi3 = st3.w || 0, bs3 = 0;
|
|
278968
|
-
for (;i3 + 2 < s2; ++i3) {
|
|
278969
|
-
var hv = hsh(i3);
|
|
278970
|
-
var imod = i3 & 32767, pimod = head[hv];
|
|
278971
|
-
prev[imod] = pimod;
|
|
278972
|
-
head[hv] = imod;
|
|
278973
|
-
if (wi3 <= i3) {
|
|
278974
|
-
var rem = s2 - i3;
|
|
278975
|
-
if ((lc_1 > 7000 || li3 > 24576) && (rem > 423 || !lst)) {
|
|
278976
|
-
pos = wblk(dat, w4, 0, syms, lf3, df3, eb, li3, bs3, i3 - bs3, pos);
|
|
278977
|
-
li3 = lc_1 = eb = 0, bs3 = i3;
|
|
278978
|
-
for (var j4 = 0;j4 < 286; ++j4)
|
|
278979
|
-
lf3[j4] = 0;
|
|
278980
|
-
for (var j4 = 0;j4 < 30; ++j4)
|
|
278981
|
-
df3[j4] = 0;
|
|
278982
|
-
}
|
|
278983
|
-
var l3 = 2, d3 = 0, ch_1 = c3, dif = imod - pimod & 32767;
|
|
278984
|
-
if (rem > 2 && hv == hsh(i3 - dif)) {
|
|
278985
|
-
var maxn = Math.min(n3, rem) - 1;
|
|
278986
|
-
var maxd = Math.min(32767, i3);
|
|
278987
|
-
var ml3 = Math.min(258, rem);
|
|
278988
|
-
while (dif <= maxd && --ch_1 && imod != pimod) {
|
|
278989
|
-
if (dat[i3 + l3] == dat[i3 + l3 - dif]) {
|
|
278990
|
-
var nl3 = 0;
|
|
278991
|
-
for (;nl3 < ml3 && dat[i3 + nl3] == dat[i3 + nl3 - dif]; ++nl3)
|
|
278992
|
-
;
|
|
278993
|
-
if (nl3 > l3) {
|
|
278994
|
-
l3 = nl3, d3 = dif;
|
|
278995
|
-
if (nl3 > maxn)
|
|
278996
|
-
break;
|
|
278997
|
-
var mmd = Math.min(dif, nl3 - 2);
|
|
278998
|
-
var md2 = 0;
|
|
278999
|
-
for (var j4 = 0;j4 < mmd; ++j4) {
|
|
279000
|
-
var ti3 = i3 - dif + j4 & 32767;
|
|
279001
|
-
var pti = prev[ti3];
|
|
279002
|
-
var cd3 = ti3 - pti & 32767;
|
|
279003
|
-
if (cd3 > md2)
|
|
279004
|
-
md2 = cd3, pimod = ti3;
|
|
279005
|
-
}
|
|
279006
|
-
}
|
|
279007
|
-
}
|
|
279008
|
-
imod = pimod, pimod = prev[imod];
|
|
279009
|
-
dif += imod - pimod & 32767;
|
|
279010
|
-
}
|
|
279011
|
-
}
|
|
279012
|
-
if (d3) {
|
|
279013
|
-
syms[li3++] = 268435456 | revfl[l3] << 18 | revfd[d3];
|
|
279014
|
-
var lin = revfl[l3] & 31, din = revfd[d3] & 31;
|
|
279015
|
-
eb += fleb[lin] + fdeb[din];
|
|
279016
|
-
++lf3[257 + lin];
|
|
279017
|
-
++df3[din];
|
|
279018
|
-
wi3 = i3 + l3;
|
|
279019
|
-
++lc_1;
|
|
279020
|
-
} else {
|
|
279021
|
-
syms[li3++] = dat[i3];
|
|
279022
|
-
++lf3[dat[i3]];
|
|
279023
|
-
}
|
|
279024
|
-
}
|
|
279025
|
-
}
|
|
279026
|
-
for (i3 = Math.max(i3, wi3);i3 < s2; ++i3) {
|
|
279027
|
-
syms[li3++] = dat[i3];
|
|
279028
|
-
++lf3[dat[i3]];
|
|
279029
|
-
}
|
|
279030
|
-
pos = wblk(dat, w4, lst, syms, lf3, df3, eb, li3, bs3, i3 - bs3, pos);
|
|
279031
|
-
if (!lst) {
|
|
279032
|
-
st3.r = pos & 7 | w4[pos / 8 | 0] << 3;
|
|
279033
|
-
pos -= 7;
|
|
279034
|
-
st3.h = head, st3.p = prev, st3.i = i3, st3.w = wi3;
|
|
279035
|
-
}
|
|
279036
|
-
} else {
|
|
279037
|
-
for (var i3 = st3.w || 0;i3 < s2 + lst; i3 += 65535) {
|
|
279038
|
-
var e4 = i3 + 65535;
|
|
279039
|
-
if (e4 >= s2) {
|
|
279040
|
-
w4[pos / 8 | 0] = lst;
|
|
279041
|
-
e4 = s2;
|
|
279042
|
-
}
|
|
279043
|
-
pos = wfblk(w4, pos + 1, dat.subarray(i3, e4));
|
|
279044
|
-
}
|
|
279045
|
-
st3.i = s2;
|
|
279046
|
-
}
|
|
279047
|
-
return slc(o3, 0, pre + shft(pos) + post);
|
|
279048
|
-
};
|
|
279049
|
-
var adler = function() {
|
|
279050
|
-
var a2 = 1, b = 0;
|
|
279051
|
-
return {
|
|
279052
|
-
p: function(d3) {
|
|
279053
|
-
var n3 = a2, m3 = b;
|
|
279054
|
-
var l3 = d3.length | 0;
|
|
279055
|
-
for (var i3 = 0;i3 != l3; ) {
|
|
279056
|
-
var e4 = Math.min(i3 + 2655, l3);
|
|
279057
|
-
for (;i3 < e4; ++i3)
|
|
279058
|
-
m3 += n3 += d3[i3];
|
|
279059
|
-
n3 = (n3 & 65535) + 15 * (n3 >> 16), m3 = (m3 & 65535) + 15 * (m3 >> 16);
|
|
279060
|
-
}
|
|
279061
|
-
a2 = n3, b = m3;
|
|
279062
|
-
},
|
|
279063
|
-
d: function() {
|
|
279064
|
-
a2 %= 65521, b %= 65521;
|
|
279065
|
-
return (a2 & 255) << 24 | (a2 & 65280) << 8 | (b & 255) << 8 | b >> 8;
|
|
279066
|
-
}
|
|
279067
|
-
};
|
|
279068
|
-
};
|
|
279069
|
-
var dopt = function(dat, opt, pre, post, st3) {
|
|
279070
|
-
if (!st3) {
|
|
279071
|
-
st3 = { l: 1 };
|
|
279072
|
-
if (opt.dictionary) {
|
|
279073
|
-
var dict = opt.dictionary.subarray(-32768);
|
|
279074
|
-
var newDat = new u8(dict.length + dat.length);
|
|
279075
|
-
newDat.set(dict);
|
|
279076
|
-
newDat.set(dat, dict.length);
|
|
279077
|
-
dat = newDat;
|
|
279078
|
-
st3.w = dict.length;
|
|
279079
|
-
}
|
|
279080
|
-
}
|
|
279081
|
-
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st3.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st3);
|
|
279082
|
-
};
|
|
279083
|
-
var wbytes = function(d3, b, v3) {
|
|
279084
|
-
for (;v3; ++b)
|
|
279085
|
-
d3[b] = v3, v3 >>>= 8;
|
|
279086
|
-
};
|
|
279087
|
-
var zlh = function(c3, o3) {
|
|
279088
|
-
var lv = o3.level, fl4 = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;
|
|
279089
|
-
c3[0] = 120, c3[1] = fl4 << 6 | (o3.dictionary && 32);
|
|
279090
|
-
c3[1] |= 31 - (c3[0] << 8 | c3[1]) % 31;
|
|
279091
|
-
if (o3.dictionary) {
|
|
279092
|
-
var h4 = adler();
|
|
279093
|
-
h4.p(o3.dictionary);
|
|
279094
|
-
wbytes(c3, 2, h4.d());
|
|
279095
|
-
}
|
|
279096
|
-
};
|
|
279097
|
-
var zls = function(d3, dict) {
|
|
279098
|
-
if ((d3[0] & 15) != 8 || d3[0] >> 4 > 7 || (d3[0] << 8 | d3[1]) % 31)
|
|
279099
|
-
err(6, "invalid zlib data");
|
|
279100
|
-
if ((d3[1] >> 5 & 1) == +!dict)
|
|
279101
|
-
err(6, "invalid zlib data: " + (d3[1] & 32 ? "need" : "unexpected") + " dictionary");
|
|
279102
|
-
return (d3[1] >> 3 & 4) + 2;
|
|
279103
|
-
};
|
|
279104
|
-
var Inflate = /* @__PURE__ */ function() {
|
|
279105
|
-
function Inflate2(opts, cb2) {
|
|
279106
|
-
if (typeof opts == "function")
|
|
279107
|
-
cb2 = opts, opts = {};
|
|
279108
|
-
this.ondata = cb2;
|
|
279109
|
-
var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);
|
|
279110
|
-
this.s = { i: 0, b: dict ? dict.length : 0 };
|
|
279111
|
-
this.o = new u8(32768);
|
|
279112
|
-
this.p = new u8(0);
|
|
279113
|
-
if (dict)
|
|
279114
|
-
this.o.set(dict);
|
|
279115
|
-
}
|
|
279116
|
-
Inflate2.prototype.e = function(c3) {
|
|
279117
|
-
if (!this.ondata)
|
|
279118
|
-
err(5);
|
|
279119
|
-
if (this.d)
|
|
279120
|
-
err(4);
|
|
279121
|
-
if (!this.p.length)
|
|
279122
|
-
this.p = c3;
|
|
279123
|
-
else if (c3.length) {
|
|
279124
|
-
var n3 = new u8(this.p.length + c3.length);
|
|
279125
|
-
n3.set(this.p), n3.set(c3, this.p.length), this.p = n3;
|
|
279126
|
-
}
|
|
279127
|
-
};
|
|
279128
|
-
Inflate2.prototype.c = function(final) {
|
|
279129
|
-
this.s.i = +(this.d = final || false);
|
|
279130
|
-
var bts = this.s.b;
|
|
279131
|
-
var dt3 = inflt(this.p, this.s, this.o);
|
|
279132
|
-
this.ondata(slc(dt3, bts, this.s.b), this.d);
|
|
279133
|
-
this.o = slc(dt3, this.s.b - 32768), this.s.b = this.o.length;
|
|
279134
|
-
this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
|
|
279135
|
-
};
|
|
279136
|
-
Inflate2.prototype.push = function(chunk, final) {
|
|
279137
|
-
this.e(chunk), this.c(final);
|
|
279138
|
-
};
|
|
279139
|
-
return Inflate2;
|
|
279140
|
-
}();
|
|
279141
|
-
function zlibSync(data, opts) {
|
|
279142
|
-
if (!opts)
|
|
279143
|
-
opts = {};
|
|
279144
|
-
var a2 = adler();
|
|
279145
|
-
a2.p(data);
|
|
279146
|
-
var d3 = dopt(data, opts, opts.dictionary ? 6 : 2, 4);
|
|
279147
|
-
return zlh(d3, opts), wbytes(d3, d3.length - 4, a2.d()), d3;
|
|
279148
|
-
}
|
|
279149
|
-
var Unzlib = /* @__PURE__ */ function() {
|
|
279150
|
-
function Unzlib2(opts, cb2) {
|
|
279151
|
-
Inflate.call(this, opts, cb2);
|
|
279152
|
-
this.v = opts && opts.dictionary ? 2 : 1;
|
|
279153
|
-
}
|
|
279154
|
-
Unzlib2.prototype.push = function(chunk, final) {
|
|
279155
|
-
Inflate.prototype.e.call(this, chunk);
|
|
279156
|
-
if (this.v) {
|
|
279157
|
-
if (this.p.length < 6 && !final)
|
|
279158
|
-
return;
|
|
279159
|
-
this.p = this.p.subarray(zls(this.p, this.v - 1)), this.v = 0;
|
|
279160
|
-
}
|
|
279161
|
-
if (final) {
|
|
279162
|
-
if (this.p.length < 4)
|
|
279163
|
-
err(6, "invalid zlib data");
|
|
279164
|
-
this.p = this.p.subarray(0, -4);
|
|
279165
|
-
}
|
|
279166
|
-
Inflate.prototype.c.call(this, final);
|
|
279167
|
-
};
|
|
279168
|
-
return Unzlib2;
|
|
279169
|
-
}();
|
|
279170
|
-
function unzlibSync(data, opts) {
|
|
279171
|
-
return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
279172
|
-
}
|
|
279173
|
-
var td3 = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder;
|
|
279174
|
-
var tds = 0;
|
|
279175
|
-
try {
|
|
279176
|
-
td3.decode(et3, { stream: true });
|
|
279177
|
-
tds = 1;
|
|
279178
|
-
} catch (e4) {}
|
|
279179
|
-
|
|
279180
|
-
// node_modules/iobuffer/lib/text.js
|
|
279181
|
-
function decode(bytes, encoding = "utf8") {
|
|
279182
|
-
const decoder = new TextDecoder(encoding);
|
|
279183
|
-
return decoder.decode(bytes);
|
|
279184
|
-
}
|
|
279185
|
-
var encoder = new TextEncoder;
|
|
279186
|
-
function encode(str) {
|
|
279187
|
-
return encoder.encode(str);
|
|
279188
|
-
}
|
|
279189
|
-
|
|
279190
|
-
// node_modules/iobuffer/lib/iobuffer.js
|
|
279191
|
-
var defaultByteLength = 1024 * 8;
|
|
279192
|
-
var hostBigEndian = (() => {
|
|
279193
|
-
const array = new Uint8Array(4);
|
|
279194
|
-
const view = new Uint32Array(array.buffer);
|
|
279195
|
-
return !((view[0] = 1) & array[0]);
|
|
279196
|
-
})();
|
|
279197
|
-
var typedArrays = {
|
|
279198
|
-
int8: globalThis.Int8Array,
|
|
279199
|
-
uint8: globalThis.Uint8Array,
|
|
279200
|
-
int16: globalThis.Int16Array,
|
|
279201
|
-
uint16: globalThis.Uint16Array,
|
|
279202
|
-
int32: globalThis.Int32Array,
|
|
279203
|
-
uint32: globalThis.Uint32Array,
|
|
279204
|
-
uint64: globalThis.BigUint64Array,
|
|
279205
|
-
int64: globalThis.BigInt64Array,
|
|
279206
|
-
float32: globalThis.Float32Array,
|
|
279207
|
-
float64: globalThis.Float64Array
|
|
279208
|
-
};
|
|
279209
|
-
|
|
279210
|
-
class IOBuffer {
|
|
279211
|
-
buffer;
|
|
279212
|
-
byteLength;
|
|
279213
|
-
byteOffset;
|
|
279214
|
-
length;
|
|
279215
|
-
offset;
|
|
279216
|
-
lastWrittenByte;
|
|
279217
|
-
littleEndian;
|
|
279218
|
-
_data;
|
|
279219
|
-
_mark;
|
|
279220
|
-
_marks;
|
|
279221
|
-
constructor(data = defaultByteLength, options = {}) {
|
|
279222
|
-
let dataIsGiven = false;
|
|
279223
|
-
if (typeof data === "number") {
|
|
279224
|
-
data = new ArrayBuffer(data);
|
|
279225
|
-
} else {
|
|
279226
|
-
dataIsGiven = true;
|
|
279227
|
-
this.lastWrittenByte = data.byteLength;
|
|
279228
|
-
}
|
|
279229
|
-
const offset = options.offset ? options.offset >>> 0 : 0;
|
|
279230
|
-
const byteLength = data.byteLength - offset;
|
|
279231
|
-
let dvOffset = offset;
|
|
279232
|
-
if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {
|
|
279233
|
-
if (data.byteLength !== data.buffer.byteLength) {
|
|
279234
|
-
dvOffset = data.byteOffset + offset;
|
|
279235
|
-
}
|
|
279236
|
-
data = data.buffer;
|
|
279237
|
-
}
|
|
279238
|
-
if (dataIsGiven) {
|
|
279239
|
-
this.lastWrittenByte = byteLength;
|
|
279240
|
-
} else {
|
|
279241
|
-
this.lastWrittenByte = 0;
|
|
279242
|
-
}
|
|
279243
|
-
this.buffer = data;
|
|
279244
|
-
this.length = byteLength;
|
|
279245
|
-
this.byteLength = byteLength;
|
|
279246
|
-
this.byteOffset = dvOffset;
|
|
279247
|
-
this.offset = 0;
|
|
279248
|
-
this.littleEndian = true;
|
|
279249
|
-
this._data = new DataView(this.buffer, dvOffset, byteLength);
|
|
279250
|
-
this._mark = 0;
|
|
279251
|
-
this._marks = [];
|
|
279252
|
-
}
|
|
279253
|
-
available(byteLength = 1) {
|
|
279254
|
-
return this.offset + byteLength <= this.length;
|
|
279255
|
-
}
|
|
279256
|
-
isLittleEndian() {
|
|
279257
|
-
return this.littleEndian;
|
|
279258
|
-
}
|
|
279259
|
-
setLittleEndian() {
|
|
279260
|
-
this.littleEndian = true;
|
|
279261
|
-
return this;
|
|
279262
|
-
}
|
|
279263
|
-
isBigEndian() {
|
|
279264
|
-
return !this.littleEndian;
|
|
279265
|
-
}
|
|
279266
|
-
setBigEndian() {
|
|
279267
|
-
this.littleEndian = false;
|
|
279268
|
-
return this;
|
|
279269
|
-
}
|
|
279270
|
-
skip(n3 = 1) {
|
|
279271
|
-
this.offset += n3;
|
|
279272
|
-
return this;
|
|
279273
|
-
}
|
|
279274
|
-
back(n3 = 1) {
|
|
279275
|
-
this.offset -= n3;
|
|
279276
|
-
return this;
|
|
279277
|
-
}
|
|
279278
|
-
seek(offset) {
|
|
279279
|
-
this.offset = offset;
|
|
279280
|
-
return this;
|
|
279281
|
-
}
|
|
279282
|
-
mark() {
|
|
279283
|
-
this._mark = this.offset;
|
|
279284
|
-
return this;
|
|
279285
|
-
}
|
|
279286
|
-
reset() {
|
|
279287
|
-
this.offset = this._mark;
|
|
279288
|
-
return this;
|
|
279289
|
-
}
|
|
279290
|
-
pushMark() {
|
|
279291
|
-
this._marks.push(this.offset);
|
|
279292
|
-
return this;
|
|
279293
|
-
}
|
|
279294
|
-
popMark() {
|
|
279295
|
-
const offset = this._marks.pop();
|
|
279296
|
-
if (offset === undefined) {
|
|
279297
|
-
throw new Error("Mark stack empty");
|
|
279298
|
-
}
|
|
279299
|
-
this.seek(offset);
|
|
279300
|
-
return this;
|
|
279301
|
-
}
|
|
279302
|
-
rewind() {
|
|
279303
|
-
this.offset = 0;
|
|
279304
|
-
return this;
|
|
279305
|
-
}
|
|
279306
|
-
ensureAvailable(byteLength = 1) {
|
|
279307
|
-
if (!this.available(byteLength)) {
|
|
279308
|
-
const lengthNeeded = this.offset + byteLength;
|
|
279309
|
-
const newLength = lengthNeeded * 2;
|
|
279310
|
-
const newArray = new Uint8Array(newLength);
|
|
279311
|
-
newArray.set(new Uint8Array(this.buffer));
|
|
279312
|
-
this.buffer = newArray.buffer;
|
|
279313
|
-
this.length = newLength;
|
|
279314
|
-
this.byteLength = newLength;
|
|
279315
|
-
this._data = new DataView(this.buffer);
|
|
279316
|
-
}
|
|
279317
|
-
return this;
|
|
279318
|
-
}
|
|
279319
|
-
readBoolean() {
|
|
279320
|
-
return this.readUint8() !== 0;
|
|
279321
|
-
}
|
|
279322
|
-
readInt8() {
|
|
279323
|
-
return this._data.getInt8(this.offset++);
|
|
279324
|
-
}
|
|
279325
|
-
readUint8() {
|
|
279326
|
-
return this._data.getUint8(this.offset++);
|
|
279327
|
-
}
|
|
279328
|
-
readByte() {
|
|
279329
|
-
return this.readUint8();
|
|
279330
|
-
}
|
|
279331
|
-
readBytes(n3 = 1) {
|
|
279332
|
-
return this.readArray(n3, "uint8");
|
|
279333
|
-
}
|
|
279334
|
-
readArray(size4, type) {
|
|
279335
|
-
const bytes = typedArrays[type].BYTES_PER_ELEMENT * size4;
|
|
279336
|
-
const offset = this.byteOffset + this.offset;
|
|
279337
|
-
const slice = this.buffer.slice(offset, offset + bytes);
|
|
279338
|
-
if (this.littleEndian === hostBigEndian && type !== "uint8" && type !== "int8") {
|
|
279339
|
-
const slice2 = new Uint8Array(this.buffer.slice(offset, offset + bytes));
|
|
279340
|
-
slice2.reverse();
|
|
279341
|
-
const returnArray2 = new typedArrays[type](slice2.buffer);
|
|
279342
|
-
this.offset += bytes;
|
|
279343
|
-
returnArray2.reverse();
|
|
279344
|
-
return returnArray2;
|
|
279345
|
-
}
|
|
279346
|
-
const returnArray = new typedArrays[type](slice);
|
|
279347
|
-
this.offset += bytes;
|
|
279348
|
-
return returnArray;
|
|
279349
|
-
}
|
|
279350
|
-
readInt16() {
|
|
279351
|
-
const value = this._data.getInt16(this.offset, this.littleEndian);
|
|
279352
|
-
this.offset += 2;
|
|
279353
|
-
return value;
|
|
279354
|
-
}
|
|
279355
|
-
readUint16() {
|
|
279356
|
-
const value = this._data.getUint16(this.offset, this.littleEndian);
|
|
279357
|
-
this.offset += 2;
|
|
279358
|
-
return value;
|
|
279359
|
-
}
|
|
279360
|
-
readInt32() {
|
|
279361
|
-
const value = this._data.getInt32(this.offset, this.littleEndian);
|
|
279362
|
-
this.offset += 4;
|
|
279363
|
-
return value;
|
|
279364
|
-
}
|
|
279365
|
-
readUint32() {
|
|
279366
|
-
const value = this._data.getUint32(this.offset, this.littleEndian);
|
|
279367
|
-
this.offset += 4;
|
|
279368
|
-
return value;
|
|
279369
|
-
}
|
|
279370
|
-
readFloat32() {
|
|
279371
|
-
const value = this._data.getFloat32(this.offset, this.littleEndian);
|
|
279372
|
-
this.offset += 4;
|
|
279373
|
-
return value;
|
|
279374
|
-
}
|
|
279375
|
-
readFloat64() {
|
|
279376
|
-
const value = this._data.getFloat64(this.offset, this.littleEndian);
|
|
279377
|
-
this.offset += 8;
|
|
279378
|
-
return value;
|
|
279379
|
-
}
|
|
279380
|
-
readBigInt64() {
|
|
279381
|
-
const value = this._data.getBigInt64(this.offset, this.littleEndian);
|
|
279382
|
-
this.offset += 8;
|
|
279383
|
-
return value;
|
|
279384
|
-
}
|
|
279385
|
-
readBigUint64() {
|
|
279386
|
-
const value = this._data.getBigUint64(this.offset, this.littleEndian);
|
|
279387
|
-
this.offset += 8;
|
|
279388
|
-
return value;
|
|
279389
|
-
}
|
|
279390
|
-
readChar() {
|
|
279391
|
-
return String.fromCharCode(this.readInt8());
|
|
279392
|
-
}
|
|
279393
|
-
readChars(n3 = 1) {
|
|
279394
|
-
let result = "";
|
|
279395
|
-
for (let i3 = 0;i3 < n3; i3++) {
|
|
279396
|
-
result += this.readChar();
|
|
279397
|
-
}
|
|
279398
|
-
return result;
|
|
279399
|
-
}
|
|
279400
|
-
readUtf8(n3 = 1) {
|
|
279401
|
-
return decode(this.readBytes(n3));
|
|
279402
|
-
}
|
|
279403
|
-
decodeText(n3 = 1, encoding = "utf8") {
|
|
279404
|
-
return decode(this.readBytes(n3), encoding);
|
|
279405
|
-
}
|
|
279406
|
-
writeBoolean(value) {
|
|
279407
|
-
this.writeUint8(value ? 255 : 0);
|
|
279408
|
-
return this;
|
|
279409
|
-
}
|
|
279410
|
-
writeInt8(value) {
|
|
279411
|
-
this.ensureAvailable(1);
|
|
279412
|
-
this._data.setInt8(this.offset++, value);
|
|
279413
|
-
this._updateLastWrittenByte();
|
|
279414
|
-
return this;
|
|
279415
|
-
}
|
|
279416
|
-
writeUint8(value) {
|
|
279417
|
-
this.ensureAvailable(1);
|
|
279418
|
-
this._data.setUint8(this.offset++, value);
|
|
279419
|
-
this._updateLastWrittenByte();
|
|
279420
|
-
return this;
|
|
279421
|
-
}
|
|
279422
|
-
writeByte(value) {
|
|
279423
|
-
return this.writeUint8(value);
|
|
279424
|
-
}
|
|
279425
|
-
writeBytes(bytes) {
|
|
279426
|
-
this.ensureAvailable(bytes.length);
|
|
279427
|
-
for (let i3 = 0;i3 < bytes.length; i3++) {
|
|
279428
|
-
this._data.setUint8(this.offset++, bytes[i3]);
|
|
279429
|
-
}
|
|
279430
|
-
this._updateLastWrittenByte();
|
|
279431
|
-
return this;
|
|
279432
|
-
}
|
|
279433
|
-
writeInt16(value) {
|
|
279434
|
-
this.ensureAvailable(2);
|
|
279435
|
-
this._data.setInt16(this.offset, value, this.littleEndian);
|
|
279436
|
-
this.offset += 2;
|
|
279437
|
-
this._updateLastWrittenByte();
|
|
279438
|
-
return this;
|
|
279439
|
-
}
|
|
279440
|
-
writeUint16(value) {
|
|
279441
|
-
this.ensureAvailable(2);
|
|
279442
|
-
this._data.setUint16(this.offset, value, this.littleEndian);
|
|
279443
|
-
this.offset += 2;
|
|
279444
|
-
this._updateLastWrittenByte();
|
|
279445
|
-
return this;
|
|
279446
|
-
}
|
|
279447
|
-
writeInt32(value) {
|
|
279448
|
-
this.ensureAvailable(4);
|
|
279449
|
-
this._data.setInt32(this.offset, value, this.littleEndian);
|
|
279450
|
-
this.offset += 4;
|
|
279451
|
-
this._updateLastWrittenByte();
|
|
279452
|
-
return this;
|
|
279453
|
-
}
|
|
279454
|
-
writeUint32(value) {
|
|
279455
|
-
this.ensureAvailable(4);
|
|
279456
|
-
this._data.setUint32(this.offset, value, this.littleEndian);
|
|
279457
|
-
this.offset += 4;
|
|
279458
|
-
this._updateLastWrittenByte();
|
|
279459
|
-
return this;
|
|
279460
|
-
}
|
|
279461
|
-
writeFloat32(value) {
|
|
279462
|
-
this.ensureAvailable(4);
|
|
279463
|
-
this._data.setFloat32(this.offset, value, this.littleEndian);
|
|
279464
|
-
this.offset += 4;
|
|
279465
|
-
this._updateLastWrittenByte();
|
|
279466
|
-
return this;
|
|
279467
|
-
}
|
|
279468
|
-
writeFloat64(value) {
|
|
279469
|
-
this.ensureAvailable(8);
|
|
279470
|
-
this._data.setFloat64(this.offset, value, this.littleEndian);
|
|
279471
|
-
this.offset += 8;
|
|
279472
|
-
this._updateLastWrittenByte();
|
|
279473
|
-
return this;
|
|
279474
|
-
}
|
|
279475
|
-
writeBigInt64(value) {
|
|
279476
|
-
this.ensureAvailable(8);
|
|
279477
|
-
this._data.setBigInt64(this.offset, value, this.littleEndian);
|
|
279478
|
-
this.offset += 8;
|
|
279479
|
-
this._updateLastWrittenByte();
|
|
279480
|
-
return this;
|
|
279481
|
-
}
|
|
279482
|
-
writeBigUint64(value) {
|
|
279483
|
-
this.ensureAvailable(8);
|
|
279484
|
-
this._data.setBigUint64(this.offset, value, this.littleEndian);
|
|
279485
|
-
this.offset += 8;
|
|
279486
|
-
this._updateLastWrittenByte();
|
|
279487
|
-
return this;
|
|
279488
|
-
}
|
|
279489
|
-
writeChar(str) {
|
|
279490
|
-
return this.writeUint8(str.charCodeAt(0));
|
|
279491
|
-
}
|
|
279492
|
-
writeChars(str) {
|
|
279493
|
-
for (let i3 = 0;i3 < str.length; i3++) {
|
|
279494
|
-
this.writeUint8(str.charCodeAt(i3));
|
|
279495
|
-
}
|
|
279496
|
-
return this;
|
|
279497
|
-
}
|
|
279498
|
-
writeUtf8(str) {
|
|
279499
|
-
return this.writeBytes(encode(str));
|
|
279500
|
-
}
|
|
279501
|
-
toArray() {
|
|
279502
|
-
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
|
|
279503
|
-
}
|
|
279504
|
-
getWrittenByteLength() {
|
|
279505
|
-
return this.lastWrittenByte - this.byteOffset;
|
|
279506
|
-
}
|
|
279507
|
-
_updateLastWrittenByte() {
|
|
279508
|
-
if (this.offset > this.lastWrittenByte) {
|
|
279509
|
-
this.lastWrittenByte = this.offset;
|
|
279510
|
-
}
|
|
279511
|
-
}
|
|
279512
|
-
}
|
|
279513
|
-
|
|
279514
|
-
// node_modules/fast-png/lib/helpers/crc.js
|
|
279515
|
-
var crcTable = [];
|
|
279516
|
-
for (let n3 = 0;n3 < 256; n3++) {
|
|
279517
|
-
let c3 = n3;
|
|
279518
|
-
for (let k4 = 0;k4 < 8; k4++) {
|
|
279519
|
-
if (c3 & 1) {
|
|
279520
|
-
c3 = 3988292384 ^ c3 >>> 1;
|
|
279521
|
-
} else {
|
|
279522
|
-
c3 = c3 >>> 1;
|
|
279523
|
-
}
|
|
279524
|
-
}
|
|
279525
|
-
crcTable[n3] = c3;
|
|
279526
|
-
}
|
|
279527
|
-
var initialCrc = 4294967295;
|
|
279528
|
-
function updateCrc(currentCrc, data, length4) {
|
|
279529
|
-
let c3 = currentCrc;
|
|
279530
|
-
for (let n3 = 0;n3 < length4; n3++) {
|
|
279531
|
-
c3 = crcTable[(c3 ^ data[n3]) & 255] ^ c3 >>> 8;
|
|
279532
|
-
}
|
|
279533
|
-
return c3;
|
|
279534
|
-
}
|
|
279535
|
-
function crc(data, length4) {
|
|
279536
|
-
return (updateCrc(initialCrc, data, length4) ^ initialCrc) >>> 0;
|
|
279537
|
-
}
|
|
279538
|
-
function checkCrc(buffer, crcLength, chunkName) {
|
|
279539
|
-
const expectedCrc = buffer.readUint32();
|
|
279540
|
-
const actualCrc = crc(new Uint8Array(buffer.buffer, buffer.byteOffset + buffer.offset - crcLength - 4, crcLength), crcLength);
|
|
279541
|
-
if (actualCrc !== expectedCrc) {
|
|
279542
|
-
throw new Error(`CRC mismatch for chunk ${chunkName}. Expected ${expectedCrc}, found ${actualCrc}`);
|
|
279543
|
-
}
|
|
279544
|
-
}
|
|
279545
|
-
function writeCrc(buffer, length4) {
|
|
279546
|
-
buffer.writeUint32(crc(new Uint8Array(buffer.buffer, buffer.byteOffset + buffer.offset - length4, length4), length4));
|
|
279547
|
-
}
|
|
279548
|
-
|
|
279549
|
-
// node_modules/fast-png/lib/helpers/unfilter.js
|
|
279550
|
-
function unfilterNone(currentLine, newLine, bytesPerLine) {
|
|
279551
|
-
for (let i3 = 0;i3 < bytesPerLine; i3++) {
|
|
279552
|
-
newLine[i3] = currentLine[i3];
|
|
279553
|
-
}
|
|
279554
|
-
}
|
|
279555
|
-
function unfilterSub(currentLine, newLine, bytesPerLine, bytesPerPixel) {
|
|
279556
|
-
let i3 = 0;
|
|
279557
|
-
for (;i3 < bytesPerPixel; i3++) {
|
|
279558
|
-
newLine[i3] = currentLine[i3];
|
|
279559
|
-
}
|
|
279560
|
-
for (;i3 < bytesPerLine; i3++) {
|
|
279561
|
-
newLine[i3] = currentLine[i3] + newLine[i3 - bytesPerPixel] & 255;
|
|
279562
|
-
}
|
|
279563
|
-
}
|
|
279564
|
-
function unfilterUp(currentLine, newLine, prevLine, bytesPerLine) {
|
|
279565
|
-
let i3 = 0;
|
|
279566
|
-
if (prevLine.length === 0) {
|
|
279567
|
-
for (;i3 < bytesPerLine; i3++) {
|
|
279568
|
-
newLine[i3] = currentLine[i3];
|
|
279569
|
-
}
|
|
279570
|
-
} else {
|
|
279571
|
-
for (;i3 < bytesPerLine; i3++) {
|
|
279572
|
-
newLine[i3] = currentLine[i3] + prevLine[i3] & 255;
|
|
279573
|
-
}
|
|
279574
|
-
}
|
|
279575
|
-
}
|
|
279576
|
-
function unfilterAverage(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel) {
|
|
279577
|
-
let i3 = 0;
|
|
279578
|
-
if (prevLine.length === 0) {
|
|
279579
|
-
for (;i3 < bytesPerPixel; i3++) {
|
|
279580
|
-
newLine[i3] = currentLine[i3];
|
|
279581
|
-
}
|
|
279582
|
-
for (;i3 < bytesPerLine; i3++) {
|
|
279583
|
-
newLine[i3] = currentLine[i3] + (newLine[i3 - bytesPerPixel] >> 1) & 255;
|
|
279584
|
-
}
|
|
279585
|
-
} else {
|
|
279586
|
-
for (;i3 < bytesPerPixel; i3++) {
|
|
279587
|
-
newLine[i3] = currentLine[i3] + (prevLine[i3] >> 1) & 255;
|
|
279588
|
-
}
|
|
279589
|
-
for (;i3 < bytesPerLine; i3++) {
|
|
279590
|
-
newLine[i3] = currentLine[i3] + (newLine[i3 - bytesPerPixel] + prevLine[i3] >> 1) & 255;
|
|
279591
|
-
}
|
|
279592
|
-
}
|
|
279593
|
-
}
|
|
279594
|
-
function unfilterPaeth(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel) {
|
|
279595
|
-
let i3 = 0;
|
|
279596
|
-
if (prevLine.length === 0) {
|
|
279597
|
-
for (;i3 < bytesPerPixel; i3++) {
|
|
279598
|
-
newLine[i3] = currentLine[i3];
|
|
279599
|
-
}
|
|
279600
|
-
for (;i3 < bytesPerLine; i3++) {
|
|
279601
|
-
newLine[i3] = currentLine[i3] + newLine[i3 - bytesPerPixel] & 255;
|
|
279602
|
-
}
|
|
279603
|
-
} else {
|
|
279604
|
-
for (;i3 < bytesPerPixel; i3++) {
|
|
279605
|
-
newLine[i3] = currentLine[i3] + prevLine[i3] & 255;
|
|
279606
|
-
}
|
|
279607
|
-
for (;i3 < bytesPerLine; i3++) {
|
|
279608
|
-
newLine[i3] = currentLine[i3] + paethPredictor(newLine[i3 - bytesPerPixel], prevLine[i3], prevLine[i3 - bytesPerPixel]) & 255;
|
|
279609
|
-
}
|
|
279610
|
-
}
|
|
279611
|
-
}
|
|
279612
|
-
function paethPredictor(a2, b, c3) {
|
|
279613
|
-
const p3 = a2 + b - c3;
|
|
279614
|
-
const pa3 = Math.abs(p3 - a2);
|
|
279615
|
-
const pb = Math.abs(p3 - b);
|
|
279616
|
-
const pc3 = Math.abs(p3 - c3);
|
|
279617
|
-
if (pa3 <= pb && pa3 <= pc3)
|
|
279618
|
-
return a2;
|
|
279619
|
-
else if (pb <= pc3)
|
|
279620
|
-
return b;
|
|
279621
|
-
else
|
|
279622
|
-
return c3;
|
|
279623
|
-
}
|
|
279624
|
-
|
|
279625
|
-
// node_modules/fast-png/lib/helpers/apply_unfilter.js
|
|
279626
|
-
function applyUnfilter(filterType, currentLine, newLine, prevLine, passLineBytes, bytesPerPixel) {
|
|
279627
|
-
switch (filterType) {
|
|
279628
|
-
case 0:
|
|
279629
|
-
unfilterNone(currentLine, newLine, passLineBytes);
|
|
279630
|
-
break;
|
|
279631
|
-
case 1:
|
|
279632
|
-
unfilterSub(currentLine, newLine, passLineBytes, bytesPerPixel);
|
|
279633
|
-
break;
|
|
279634
|
-
case 2:
|
|
279635
|
-
unfilterUp(currentLine, newLine, prevLine, passLineBytes);
|
|
279636
|
-
break;
|
|
279637
|
-
case 3:
|
|
279638
|
-
unfilterAverage(currentLine, newLine, prevLine, passLineBytes, bytesPerPixel);
|
|
279639
|
-
break;
|
|
279640
|
-
case 4:
|
|
279641
|
-
unfilterPaeth(currentLine, newLine, prevLine, passLineBytes, bytesPerPixel);
|
|
279642
|
-
break;
|
|
279643
|
-
default:
|
|
279644
|
-
throw new Error(`Unsupported filter: ${filterType}`);
|
|
279645
|
-
}
|
|
279646
|
-
}
|
|
279647
|
-
|
|
279648
|
-
// node_modules/fast-png/lib/helpers/decode_interlace_adam7.js
|
|
279649
|
-
var uint16 = new Uint16Array([255]);
|
|
279650
|
-
var uint8 = new Uint8Array(uint16.buffer);
|
|
279651
|
-
var osIsLittleEndian = uint8[0] === 255;
|
|
279652
|
-
function decodeInterlaceAdam7(params2) {
|
|
279653
|
-
const { data, width, height, channels, depth } = params2;
|
|
279654
|
-
const passes = [
|
|
279655
|
-
{ x: 0, y: 0, xStep: 8, yStep: 8 },
|
|
279656
|
-
{ x: 4, y: 0, xStep: 8, yStep: 8 },
|
|
279657
|
-
{ x: 0, y: 4, xStep: 4, yStep: 8 },
|
|
279658
|
-
{ x: 2, y: 0, xStep: 4, yStep: 4 },
|
|
279659
|
-
{ x: 0, y: 2, xStep: 2, yStep: 4 },
|
|
279660
|
-
{ x: 1, y: 0, xStep: 2, yStep: 2 },
|
|
279661
|
-
{ x: 0, y: 1, xStep: 1, yStep: 2 }
|
|
279662
|
-
];
|
|
279663
|
-
const bytesPerPixel = Math.ceil(depth / 8) * channels;
|
|
279664
|
-
const resultData = new Uint8Array(height * width * bytesPerPixel);
|
|
279665
|
-
let offset = 0;
|
|
279666
|
-
for (let passIndex = 0;passIndex < 7; passIndex++) {
|
|
279667
|
-
const pass = passes[passIndex];
|
|
279668
|
-
const passWidth = Math.ceil((width - pass.x) / pass.xStep);
|
|
279669
|
-
const passHeight = Math.ceil((height - pass.y) / pass.yStep);
|
|
279670
|
-
if (passWidth <= 0 || passHeight <= 0)
|
|
279671
|
-
continue;
|
|
279672
|
-
const passLineBytes = passWidth * bytesPerPixel;
|
|
279673
|
-
const prevLine = new Uint8Array(passLineBytes);
|
|
279674
|
-
for (let y4 = 0;y4 < passHeight; y4++) {
|
|
279675
|
-
const filterType = data[offset++];
|
|
279676
|
-
const currentLine = data.subarray(offset, offset + passLineBytes);
|
|
279677
|
-
offset += passLineBytes;
|
|
279678
|
-
const newLine = new Uint8Array(passLineBytes);
|
|
279679
|
-
applyUnfilter(filterType, currentLine, newLine, prevLine, passLineBytes, bytesPerPixel);
|
|
279680
|
-
prevLine.set(newLine);
|
|
279681
|
-
for (let x4 = 0;x4 < passWidth; x4++) {
|
|
279682
|
-
const outputX = pass.x + x4 * pass.xStep;
|
|
279683
|
-
const outputY = pass.y + y4 * pass.yStep;
|
|
279684
|
-
if (outputX >= width || outputY >= height)
|
|
279685
|
-
continue;
|
|
279686
|
-
for (let i3 = 0;i3 < bytesPerPixel; i3++) {
|
|
279687
|
-
resultData[(outputY * width + outputX) * bytesPerPixel + i3] = newLine[x4 * bytesPerPixel + i3];
|
|
279688
|
-
}
|
|
279689
|
-
}
|
|
279690
|
-
}
|
|
279691
|
-
}
|
|
279692
|
-
if (depth === 16) {
|
|
279693
|
-
const uint16Data = new Uint16Array(resultData.buffer);
|
|
279694
|
-
if (osIsLittleEndian) {
|
|
279695
|
-
for (let k4 = 0;k4 < uint16Data.length; k4++) {
|
|
279696
|
-
uint16Data[k4] = swap16(uint16Data[k4]);
|
|
279697
|
-
}
|
|
279698
|
-
}
|
|
279699
|
-
return uint16Data;
|
|
279700
|
-
} else {
|
|
279701
|
-
return resultData;
|
|
279702
|
-
}
|
|
279703
|
-
}
|
|
279704
|
-
function swap16(val) {
|
|
279705
|
-
return (val & 255) << 8 | val >> 8 & 255;
|
|
279706
|
-
}
|
|
279707
|
-
|
|
279708
|
-
// node_modules/fast-png/lib/helpers/decode_interlace_null.js
|
|
279709
|
-
var uint162 = new Uint16Array([255]);
|
|
279710
|
-
var uint82 = new Uint8Array(uint162.buffer);
|
|
279711
|
-
var osIsLittleEndian2 = uint82[0] === 255;
|
|
279712
|
-
var empty = new Uint8Array(0);
|
|
279713
|
-
function decodeInterlaceNull(params2) {
|
|
279714
|
-
const { data, width, height, channels, depth } = params2;
|
|
279715
|
-
const bytesPerPixel = Math.ceil(depth / 8) * channels;
|
|
279716
|
-
const bytesPerLine = Math.ceil(depth / 8 * channels * width);
|
|
279717
|
-
const newData = new Uint8Array(height * bytesPerLine);
|
|
279718
|
-
let prevLine = empty;
|
|
279719
|
-
let offset = 0;
|
|
279720
|
-
let currentLine;
|
|
279721
|
-
let newLine;
|
|
279722
|
-
for (let i3 = 0;i3 < height; i3++) {
|
|
279723
|
-
currentLine = data.subarray(offset + 1, offset + 1 + bytesPerLine);
|
|
279724
|
-
newLine = newData.subarray(i3 * bytesPerLine, (i3 + 1) * bytesPerLine);
|
|
279725
|
-
switch (data[offset]) {
|
|
279726
|
-
case 0:
|
|
279727
|
-
unfilterNone(currentLine, newLine, bytesPerLine);
|
|
279728
|
-
break;
|
|
279729
|
-
case 1:
|
|
279730
|
-
unfilterSub(currentLine, newLine, bytesPerLine, bytesPerPixel);
|
|
279731
|
-
break;
|
|
279732
|
-
case 2:
|
|
279733
|
-
unfilterUp(currentLine, newLine, prevLine, bytesPerLine);
|
|
279734
|
-
break;
|
|
279735
|
-
case 3:
|
|
279736
|
-
unfilterAverage(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel);
|
|
279737
|
-
break;
|
|
279738
|
-
case 4:
|
|
279739
|
-
unfilterPaeth(currentLine, newLine, prevLine, bytesPerLine, bytesPerPixel);
|
|
279740
|
-
break;
|
|
279741
|
-
default:
|
|
279742
|
-
throw new Error(`Unsupported filter: ${data[offset]}`);
|
|
279743
|
-
}
|
|
279744
|
-
prevLine = newLine;
|
|
279745
|
-
offset += bytesPerLine + 1;
|
|
279746
|
-
}
|
|
279747
|
-
if (depth === 16) {
|
|
279748
|
-
const uint16Data = new Uint16Array(newData.buffer);
|
|
279749
|
-
if (osIsLittleEndian2) {
|
|
279750
|
-
for (let k4 = 0;k4 < uint16Data.length; k4++) {
|
|
279751
|
-
uint16Data[k4] = swap162(uint16Data[k4]);
|
|
279752
|
-
}
|
|
279753
|
-
}
|
|
279754
|
-
return uint16Data;
|
|
279755
|
-
} else {
|
|
279756
|
-
return newData;
|
|
279757
|
-
}
|
|
279758
|
-
}
|
|
279759
|
-
function swap162(val) {
|
|
279760
|
-
return (val & 255) << 8 | val >> 8 & 255;
|
|
279761
|
-
}
|
|
279762
|
-
|
|
279763
|
-
// node_modules/fast-png/lib/helpers/signature.js
|
|
279764
|
-
var pngSignature = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
|
|
279765
|
-
function writeSignature(buffer) {
|
|
279766
|
-
buffer.writeBytes(pngSignature);
|
|
279767
|
-
}
|
|
279768
|
-
function checkSignature(buffer) {
|
|
279769
|
-
if (!hasPngSignature(buffer.readBytes(pngSignature.length))) {
|
|
279770
|
-
throw new Error("wrong PNG signature");
|
|
279771
|
-
}
|
|
279772
|
-
}
|
|
279773
|
-
function hasPngSignature(array) {
|
|
279774
|
-
if (array.length < pngSignature.length) {
|
|
279775
|
-
return false;
|
|
279776
|
-
}
|
|
279777
|
-
for (let i3 = 0;i3 < pngSignature.length; i3++) {
|
|
279778
|
-
if (array[i3] !== pngSignature[i3]) {
|
|
279779
|
-
return false;
|
|
279780
|
-
}
|
|
279781
|
-
}
|
|
279782
|
-
return true;
|
|
279783
|
-
}
|
|
279784
|
-
|
|
279785
|
-
// node_modules/fast-png/lib/helpers/text.js
|
|
279786
|
-
var textChunkName = "tEXt";
|
|
279787
|
-
var NULL = 0;
|
|
279788
|
-
var latin1Decoder = new TextDecoder("latin1");
|
|
279789
|
-
function validateKeyword(keyword) {
|
|
279790
|
-
validateLatin1(keyword);
|
|
279791
|
-
if (keyword.length === 0 || keyword.length > 79) {
|
|
279792
|
-
throw new Error("keyword length must be between 1 and 79");
|
|
279793
|
-
}
|
|
279794
|
-
}
|
|
279795
|
-
var latin1Regex = /^[\u0000-\u00FF]*$/;
|
|
279796
|
-
function validateLatin1(text) {
|
|
279797
|
-
if (!latin1Regex.test(text)) {
|
|
279798
|
-
throw new Error("invalid latin1 text");
|
|
279799
|
-
}
|
|
279800
|
-
}
|
|
279801
|
-
function decodetEXt(text, buffer, length4) {
|
|
279802
|
-
const keyword = readKeyword(buffer);
|
|
279803
|
-
text[keyword] = readLatin1(buffer, length4 - keyword.length - 1);
|
|
279804
|
-
}
|
|
279805
|
-
function encodetEXt(buffer, keyword, text) {
|
|
279806
|
-
validateKeyword(keyword);
|
|
279807
|
-
validateLatin1(text);
|
|
279808
|
-
const length4 = keyword.length + 1 + text.length;
|
|
279809
|
-
buffer.writeUint32(length4);
|
|
279810
|
-
buffer.writeChars(textChunkName);
|
|
279811
|
-
buffer.writeChars(keyword);
|
|
279812
|
-
buffer.writeByte(NULL);
|
|
279813
|
-
buffer.writeChars(text);
|
|
279814
|
-
writeCrc(buffer, length4 + 4);
|
|
279815
|
-
}
|
|
279816
|
-
function readKeyword(buffer) {
|
|
279817
|
-
buffer.mark();
|
|
279818
|
-
while (buffer.readByte() !== NULL) {}
|
|
279819
|
-
const end = buffer.offset;
|
|
279820
|
-
buffer.reset();
|
|
279821
|
-
const keyword = latin1Decoder.decode(buffer.readBytes(end - buffer.offset - 1));
|
|
279822
|
-
buffer.skip(1);
|
|
279823
|
-
validateKeyword(keyword);
|
|
279824
|
-
return keyword;
|
|
279825
|
-
}
|
|
279826
|
-
function readLatin1(buffer, length4) {
|
|
279827
|
-
return latin1Decoder.decode(buffer.readBytes(length4));
|
|
279828
|
-
}
|
|
279829
|
-
|
|
279830
|
-
// node_modules/fast-png/lib/internal_types.js
|
|
279831
|
-
var ColorType = {
|
|
279832
|
-
UNKNOWN: -1,
|
|
279833
|
-
GREYSCALE: 0,
|
|
279834
|
-
TRUECOLOUR: 2,
|
|
279835
|
-
INDEXED_COLOUR: 3,
|
|
279836
|
-
GREYSCALE_ALPHA: 4,
|
|
279837
|
-
TRUECOLOUR_ALPHA: 6
|
|
279838
|
-
};
|
|
279839
|
-
var CompressionMethod = {
|
|
279840
|
-
UNKNOWN: -1,
|
|
279841
|
-
DEFLATE: 0
|
|
279842
|
-
};
|
|
279843
|
-
var FilterMethod = {
|
|
279844
|
-
UNKNOWN: -1,
|
|
279845
|
-
ADAPTIVE: 0
|
|
279846
|
-
};
|
|
279847
|
-
var InterlaceMethod = {
|
|
279848
|
-
UNKNOWN: -1,
|
|
279849
|
-
NO_INTERLACE: 0,
|
|
279850
|
-
ADAM7: 1
|
|
279851
|
-
};
|
|
279852
|
-
var DisposeOpType = {
|
|
279853
|
-
NONE: 0,
|
|
279854
|
-
BACKGROUND: 1,
|
|
279855
|
-
PREVIOUS: 2
|
|
279856
|
-
};
|
|
279857
|
-
var BlendOpType = {
|
|
279858
|
-
SOURCE: 0,
|
|
279859
|
-
OVER: 1
|
|
279860
|
-
};
|
|
279861
|
-
|
|
279862
|
-
// node_modules/fast-png/lib/png_decoder.js
|
|
279863
|
-
class PngDecoder extends IOBuffer {
|
|
279864
|
-
_checkCrc;
|
|
279865
|
-
_inflator;
|
|
279866
|
-
_png;
|
|
279867
|
-
_apng;
|
|
279868
|
-
_end;
|
|
279869
|
-
_hasPalette;
|
|
279870
|
-
_palette;
|
|
279871
|
-
_hasTransparency;
|
|
279872
|
-
_transparency;
|
|
279873
|
-
_compressionMethod;
|
|
279874
|
-
_filterMethod;
|
|
279875
|
-
_interlaceMethod;
|
|
279876
|
-
_colorType;
|
|
279877
|
-
_isAnimated;
|
|
279878
|
-
_numberOfFrames;
|
|
279879
|
-
_numberOfPlays;
|
|
279880
|
-
_frames;
|
|
279881
|
-
_writingDataChunks;
|
|
279882
|
-
_chunks;
|
|
279883
|
-
_inflatorResult;
|
|
279884
|
-
constructor(data, options = {}) {
|
|
279885
|
-
super(data);
|
|
279886
|
-
const { checkCrc: checkCrc2 = false } = options;
|
|
279887
|
-
this._checkCrc = checkCrc2;
|
|
279888
|
-
this._inflator = new Unzlib((chunk, final) => {
|
|
279889
|
-
this._chunks.push(chunk);
|
|
279890
|
-
if (final) {
|
|
279891
|
-
const totalLength = this._chunks.reduce((sum, c3) => sum + c3.length, 0);
|
|
279892
|
-
this._inflatorResult = new Uint8Array(totalLength);
|
|
279893
|
-
let offset = 0;
|
|
279894
|
-
for (const chunk2 of this._chunks) {
|
|
279895
|
-
this._inflatorResult.set(chunk2, offset);
|
|
279896
|
-
offset += chunk2.length;
|
|
279897
|
-
}
|
|
279898
|
-
this._chunks = [];
|
|
279899
|
-
}
|
|
279900
|
-
});
|
|
279901
|
-
this._chunks = [];
|
|
279902
|
-
this._png = {
|
|
279903
|
-
width: -1,
|
|
279904
|
-
height: -1,
|
|
279905
|
-
channels: -1,
|
|
279906
|
-
data: new Uint8Array(0),
|
|
279907
|
-
depth: 1,
|
|
279908
|
-
text: {}
|
|
279909
|
-
};
|
|
279910
|
-
this._apng = {
|
|
279911
|
-
width: -1,
|
|
279912
|
-
height: -1,
|
|
279913
|
-
channels: -1,
|
|
279914
|
-
depth: 1,
|
|
279915
|
-
numberOfFrames: 1,
|
|
279916
|
-
numberOfPlays: 0,
|
|
279917
|
-
text: {},
|
|
279918
|
-
frames: []
|
|
279919
|
-
};
|
|
279920
|
-
this._end = false;
|
|
279921
|
-
this._hasPalette = false;
|
|
279922
|
-
this._palette = [];
|
|
279923
|
-
this._hasTransparency = false;
|
|
279924
|
-
this._transparency = new Uint16Array(0);
|
|
279925
|
-
this._compressionMethod = CompressionMethod.UNKNOWN;
|
|
279926
|
-
this._filterMethod = FilterMethod.UNKNOWN;
|
|
279927
|
-
this._interlaceMethod = InterlaceMethod.UNKNOWN;
|
|
279928
|
-
this._colorType = ColorType.UNKNOWN;
|
|
279929
|
-
this._isAnimated = false;
|
|
279930
|
-
this._numberOfFrames = 1;
|
|
279931
|
-
this._numberOfPlays = 0;
|
|
279932
|
-
this._frames = [];
|
|
279933
|
-
this._writingDataChunks = false;
|
|
279934
|
-
this._inflatorResult = new Uint8Array(0);
|
|
279935
|
-
this.setBigEndian();
|
|
279936
|
-
}
|
|
279937
|
-
decode() {
|
|
279938
|
-
checkSignature(this);
|
|
279939
|
-
while (!this._end) {
|
|
279940
|
-
const length4 = this.readUint32();
|
|
279941
|
-
const type = this.readChars(4);
|
|
279942
|
-
this.decodeChunk(length4, type);
|
|
279943
|
-
}
|
|
279944
|
-
this._inflator.push(new Uint8Array(0), true);
|
|
279945
|
-
this.decodeImage();
|
|
279946
|
-
return this._png;
|
|
279947
|
-
}
|
|
279948
|
-
decodeApng() {
|
|
279949
|
-
checkSignature(this);
|
|
279950
|
-
while (!this._end) {
|
|
279951
|
-
const length4 = this.readUint32();
|
|
279952
|
-
const type = this.readChars(4);
|
|
279953
|
-
this.decodeApngChunk(length4, type);
|
|
279954
|
-
}
|
|
279955
|
-
this.decodeApngImage();
|
|
279956
|
-
return this._apng;
|
|
279957
|
-
}
|
|
279958
|
-
decodeChunk(length4, type) {
|
|
279959
|
-
const offset = this.offset;
|
|
279960
|
-
switch (type) {
|
|
279961
|
-
case "IHDR":
|
|
279962
|
-
this.decodeIHDR();
|
|
279963
|
-
break;
|
|
279964
|
-
case "PLTE":
|
|
279965
|
-
this.decodePLTE(length4);
|
|
279966
|
-
break;
|
|
279967
|
-
case "IDAT":
|
|
279968
|
-
this.decodeIDAT(length4);
|
|
279969
|
-
break;
|
|
279970
|
-
case "IEND":
|
|
279971
|
-
this._end = true;
|
|
279972
|
-
break;
|
|
279973
|
-
case "tRNS":
|
|
279974
|
-
this.decodetRNS(length4);
|
|
279975
|
-
break;
|
|
279976
|
-
case "iCCP":
|
|
279977
|
-
this.decodeiCCP(length4);
|
|
279978
|
-
break;
|
|
279979
|
-
case textChunkName:
|
|
279980
|
-
decodetEXt(this._png.text, this, length4);
|
|
279981
|
-
break;
|
|
279982
|
-
case "pHYs":
|
|
279983
|
-
this.decodepHYs();
|
|
279984
|
-
break;
|
|
279985
|
-
default:
|
|
279986
|
-
this.skip(length4);
|
|
279987
|
-
break;
|
|
279988
|
-
}
|
|
279989
|
-
if (this.offset - offset !== length4) {
|
|
279990
|
-
throw new Error(`Length mismatch while decoding chunk ${type}`);
|
|
279991
|
-
}
|
|
279992
|
-
if (this._checkCrc) {
|
|
279993
|
-
checkCrc(this, length4 + 4, type);
|
|
279994
|
-
} else {
|
|
279995
|
-
this.skip(4);
|
|
279996
|
-
}
|
|
279997
|
-
}
|
|
279998
|
-
decodeApngChunk(length4, type) {
|
|
279999
|
-
const offset = this.offset;
|
|
280000
|
-
if (type !== "fdAT" && type !== "IDAT" && this._writingDataChunks) {
|
|
280001
|
-
this.pushDataToFrame();
|
|
280002
|
-
}
|
|
280003
|
-
switch (type) {
|
|
280004
|
-
case "acTL":
|
|
280005
|
-
this.decodeACTL();
|
|
280006
|
-
break;
|
|
280007
|
-
case "fcTL":
|
|
280008
|
-
this.decodeFCTL();
|
|
280009
|
-
break;
|
|
280010
|
-
case "fdAT":
|
|
280011
|
-
this.decodeFDAT(length4);
|
|
280012
|
-
break;
|
|
280013
|
-
default:
|
|
280014
|
-
this.decodeChunk(length4, type);
|
|
280015
|
-
this.offset = offset + length4;
|
|
280016
|
-
break;
|
|
280017
|
-
}
|
|
280018
|
-
if (this.offset - offset !== length4) {
|
|
280019
|
-
throw new Error(`Length mismatch while decoding chunk ${type}`);
|
|
280020
|
-
}
|
|
280021
|
-
if (this._checkCrc) {
|
|
280022
|
-
checkCrc(this, length4 + 4, type);
|
|
280023
|
-
} else {
|
|
280024
|
-
this.skip(4);
|
|
280025
|
-
}
|
|
280026
|
-
}
|
|
280027
|
-
decodeIHDR() {
|
|
280028
|
-
const image = this._png;
|
|
280029
|
-
image.width = this.readUint32();
|
|
280030
|
-
image.height = this.readUint32();
|
|
280031
|
-
image.depth = checkBitDepth(this.readUint8());
|
|
280032
|
-
const colorType = this.readUint8();
|
|
280033
|
-
this._colorType = colorType;
|
|
280034
|
-
let channels;
|
|
280035
|
-
switch (colorType) {
|
|
280036
|
-
case ColorType.GREYSCALE:
|
|
280037
|
-
channels = 1;
|
|
280038
|
-
break;
|
|
280039
|
-
case ColorType.TRUECOLOUR:
|
|
280040
|
-
channels = 3;
|
|
280041
|
-
break;
|
|
280042
|
-
case ColorType.INDEXED_COLOUR:
|
|
280043
|
-
channels = 1;
|
|
280044
|
-
break;
|
|
280045
|
-
case ColorType.GREYSCALE_ALPHA:
|
|
280046
|
-
channels = 2;
|
|
280047
|
-
break;
|
|
280048
|
-
case ColorType.TRUECOLOUR_ALPHA:
|
|
280049
|
-
channels = 4;
|
|
280050
|
-
break;
|
|
280051
|
-
case ColorType.UNKNOWN:
|
|
280052
|
-
default:
|
|
280053
|
-
throw new Error(`Unknown color type: ${colorType}`);
|
|
280054
|
-
}
|
|
280055
|
-
this._png.channels = channels;
|
|
280056
|
-
this._compressionMethod = this.readUint8();
|
|
280057
|
-
if (this._compressionMethod !== CompressionMethod.DEFLATE) {
|
|
280058
|
-
throw new Error(`Unsupported compression method: ${this._compressionMethod}`);
|
|
280059
|
-
}
|
|
280060
|
-
this._filterMethod = this.readUint8();
|
|
280061
|
-
this._interlaceMethod = this.readUint8();
|
|
280062
|
-
}
|
|
280063
|
-
decodeACTL() {
|
|
280064
|
-
this._numberOfFrames = this.readUint32();
|
|
280065
|
-
this._numberOfPlays = this.readUint32();
|
|
280066
|
-
this._isAnimated = true;
|
|
280067
|
-
}
|
|
280068
|
-
decodeFCTL() {
|
|
280069
|
-
const image = {
|
|
280070
|
-
sequenceNumber: this.readUint32(),
|
|
280071
|
-
width: this.readUint32(),
|
|
280072
|
-
height: this.readUint32(),
|
|
280073
|
-
xOffset: this.readUint32(),
|
|
280074
|
-
yOffset: this.readUint32(),
|
|
280075
|
-
delayNumber: this.readUint16(),
|
|
280076
|
-
delayDenominator: this.readUint16(),
|
|
280077
|
-
disposeOp: this.readUint8(),
|
|
280078
|
-
blendOp: this.readUint8(),
|
|
280079
|
-
data: new Uint8Array(0)
|
|
280080
|
-
};
|
|
280081
|
-
this._frames.push(image);
|
|
280082
|
-
}
|
|
280083
|
-
decodePLTE(length4) {
|
|
280084
|
-
if (length4 % 3 !== 0) {
|
|
280085
|
-
throw new RangeError(`PLTE field length must be a multiple of 3. Got ${length4}`);
|
|
280086
|
-
}
|
|
280087
|
-
const l3 = length4 / 3;
|
|
280088
|
-
this._hasPalette = true;
|
|
280089
|
-
const palette = [];
|
|
280090
|
-
this._palette = palette;
|
|
280091
|
-
for (let i3 = 0;i3 < l3; i3++) {
|
|
280092
|
-
palette.push([this.readUint8(), this.readUint8(), this.readUint8()]);
|
|
280093
|
-
}
|
|
280094
|
-
}
|
|
280095
|
-
decodeIDAT(length4) {
|
|
280096
|
-
this._writingDataChunks = true;
|
|
280097
|
-
const dataLength = length4;
|
|
280098
|
-
const dataOffset = this.offset + this.byteOffset;
|
|
280099
|
-
try {
|
|
280100
|
-
this._inflator.push(new Uint8Array(this.buffer, dataOffset, dataLength), false);
|
|
280101
|
-
} catch (error) {
|
|
280102
|
-
throw new Error("Error while decompressing the data:", { cause: error });
|
|
280103
|
-
}
|
|
280104
|
-
this.skip(length4);
|
|
280105
|
-
}
|
|
280106
|
-
decodeFDAT(length4) {
|
|
280107
|
-
this._writingDataChunks = true;
|
|
280108
|
-
let dataLength = length4;
|
|
280109
|
-
let dataOffset = this.offset + this.byteOffset;
|
|
280110
|
-
dataOffset += 4;
|
|
280111
|
-
dataLength -= 4;
|
|
280112
|
-
try {
|
|
280113
|
-
this._inflator.push(new Uint8Array(this.buffer, dataOffset, dataLength), false);
|
|
280114
|
-
} catch (error) {
|
|
280115
|
-
throw new Error("Error while decompressing the data:", { cause: error });
|
|
280116
|
-
}
|
|
280117
|
-
this.skip(length4);
|
|
280118
|
-
}
|
|
280119
|
-
decodetRNS(length4) {
|
|
280120
|
-
switch (this._colorType) {
|
|
280121
|
-
case ColorType.GREYSCALE:
|
|
280122
|
-
case ColorType.TRUECOLOUR: {
|
|
280123
|
-
if (length4 % 2 !== 0) {
|
|
280124
|
-
throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${length4}`);
|
|
280125
|
-
}
|
|
280126
|
-
if (length4 / 2 > this._png.width * this._png.height) {
|
|
280127
|
-
throw new Error(`tRNS chunk contains more alpha values than there are pixels (${length4 / 2} vs ${this._png.width * this._png.height})`);
|
|
280128
|
-
}
|
|
280129
|
-
this._hasTransparency = true;
|
|
280130
|
-
this._transparency = new Uint16Array(length4 / 2);
|
|
280131
|
-
for (let i3 = 0;i3 < length4 / 2; i3++) {
|
|
280132
|
-
this._transparency[i3] = this.readUint16();
|
|
280133
|
-
}
|
|
280134
|
-
break;
|
|
280135
|
-
}
|
|
280136
|
-
case ColorType.INDEXED_COLOUR: {
|
|
280137
|
-
if (length4 > this._palette.length) {
|
|
280138
|
-
throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${length4} vs ${this._palette.length})`);
|
|
280139
|
-
}
|
|
280140
|
-
let i3 = 0;
|
|
280141
|
-
for (;i3 < length4; i3++) {
|
|
280142
|
-
const alpha = this.readByte();
|
|
280143
|
-
this._palette[i3].push(alpha);
|
|
280144
|
-
}
|
|
280145
|
-
for (;i3 < this._palette.length; i3++) {
|
|
280146
|
-
this._palette[i3].push(255);
|
|
280147
|
-
}
|
|
280148
|
-
break;
|
|
280149
|
-
}
|
|
280150
|
-
case ColorType.UNKNOWN:
|
|
280151
|
-
case ColorType.GREYSCALE_ALPHA:
|
|
280152
|
-
case ColorType.TRUECOLOUR_ALPHA:
|
|
280153
|
-
default: {
|
|
280154
|
-
throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`);
|
|
280155
|
-
}
|
|
280156
|
-
}
|
|
280157
|
-
}
|
|
280158
|
-
decodeiCCP(length4) {
|
|
280159
|
-
const name = readKeyword(this);
|
|
280160
|
-
const compressionMethod = this.readUint8();
|
|
280161
|
-
if (compressionMethod !== CompressionMethod.DEFLATE) {
|
|
280162
|
-
throw new Error(`Unsupported iCCP compression method: ${compressionMethod}`);
|
|
280163
|
-
}
|
|
280164
|
-
const compressedProfile = this.readBytes(length4 - name.length - 2);
|
|
280165
|
-
this._png.iccEmbeddedProfile = {
|
|
280166
|
-
name,
|
|
280167
|
-
profile: unzlibSync(compressedProfile)
|
|
280168
|
-
};
|
|
280169
|
-
}
|
|
280170
|
-
decodepHYs() {
|
|
280171
|
-
const ppuX = this.readUint32();
|
|
280172
|
-
const ppuY = this.readUint32();
|
|
280173
|
-
const unitSpecifier = this.readByte();
|
|
280174
|
-
this._png.resolution = {
|
|
280175
|
-
x: ppuX,
|
|
280176
|
-
y: ppuY,
|
|
280177
|
-
unit: unitSpecifier
|
|
280178
|
-
};
|
|
280179
|
-
}
|
|
280180
|
-
decodeApngImage() {
|
|
280181
|
-
this._apng.width = this._png.width;
|
|
280182
|
-
this._apng.height = this._png.height;
|
|
280183
|
-
this._apng.channels = this._png.channels;
|
|
280184
|
-
this._apng.depth = this._png.depth;
|
|
280185
|
-
this._apng.numberOfFrames = this._numberOfFrames;
|
|
280186
|
-
this._apng.numberOfPlays = this._numberOfPlays;
|
|
280187
|
-
this._apng.text = this._png.text;
|
|
280188
|
-
this._apng.resolution = this._png.resolution;
|
|
280189
|
-
for (let i3 = 0;i3 < this._numberOfFrames; i3++) {
|
|
280190
|
-
const newFrame = {
|
|
280191
|
-
sequenceNumber: this._frames[i3].sequenceNumber,
|
|
280192
|
-
delayNumber: this._frames[i3].delayNumber,
|
|
280193
|
-
delayDenominator: this._frames[i3].delayDenominator,
|
|
280194
|
-
data: this._apng.depth === 8 ? new Uint8Array(this._apng.width * this._apng.height * this._apng.channels) : new Uint16Array(this._apng.width * this._apng.height * this._apng.channels)
|
|
280195
|
-
};
|
|
280196
|
-
const frame = this._frames.at(i3);
|
|
280197
|
-
if (frame) {
|
|
280198
|
-
frame.data = decodeInterlaceNull({
|
|
280199
|
-
data: frame.data,
|
|
280200
|
-
width: frame.width,
|
|
280201
|
-
height: frame.height,
|
|
280202
|
-
channels: this._apng.channels,
|
|
280203
|
-
depth: this._apng.depth
|
|
280204
|
-
});
|
|
280205
|
-
if (this._hasPalette) {
|
|
280206
|
-
this._apng.palette = this._palette;
|
|
280207
|
-
}
|
|
280208
|
-
if (this._hasTransparency) {
|
|
280209
|
-
this._apng.transparency = this._transparency;
|
|
280210
|
-
}
|
|
280211
|
-
if (i3 === 0 || frame.xOffset === 0 && frame.yOffset === 0 && frame.width === this._png.width && frame.height === this._png.height) {
|
|
280212
|
-
newFrame.data = frame.data;
|
|
280213
|
-
} else {
|
|
280214
|
-
const prevFrame = this._apng.frames.at(i3 - 1);
|
|
280215
|
-
this.disposeFrame(frame, prevFrame, newFrame);
|
|
280216
|
-
this.addFrameDataToCanvas(newFrame, frame);
|
|
280217
|
-
}
|
|
280218
|
-
this._apng.frames.push(newFrame);
|
|
280219
|
-
}
|
|
280220
|
-
}
|
|
280221
|
-
return this._apng;
|
|
280222
|
-
}
|
|
280223
|
-
disposeFrame(frame, prevFrame, imageFrame) {
|
|
280224
|
-
switch (frame.disposeOp) {
|
|
280225
|
-
case DisposeOpType.NONE:
|
|
280226
|
-
break;
|
|
280227
|
-
case DisposeOpType.BACKGROUND:
|
|
280228
|
-
for (let row = 0;row < this._png.height; row++) {
|
|
280229
|
-
for (let col = 0;col < this._png.width; col++) {
|
|
280230
|
-
const index = (row * frame.width + col) * this._png.channels;
|
|
280231
|
-
for (let channel = 0;channel < this._png.channels; channel++) {
|
|
280232
|
-
imageFrame.data[index + channel] = 0;
|
|
280233
|
-
}
|
|
280234
|
-
}
|
|
280235
|
-
}
|
|
280236
|
-
break;
|
|
280237
|
-
case DisposeOpType.PREVIOUS:
|
|
280238
|
-
imageFrame.data.set(prevFrame.data);
|
|
280239
|
-
break;
|
|
280240
|
-
default:
|
|
280241
|
-
throw new Error("Unknown disposeOp");
|
|
280242
|
-
}
|
|
280243
|
-
}
|
|
280244
|
-
addFrameDataToCanvas(imageFrame, frame) {
|
|
280245
|
-
const maxValue = 1 << this._png.depth;
|
|
280246
|
-
const calculatePixelIndices = (row, col) => {
|
|
280247
|
-
const index = ((row + frame.yOffset) * this._png.width + frame.xOffset + col) * this._png.channels;
|
|
280248
|
-
const frameIndex = (row * frame.width + col) * this._png.channels;
|
|
280249
|
-
return { index, frameIndex };
|
|
280250
|
-
};
|
|
280251
|
-
switch (frame.blendOp) {
|
|
280252
|
-
case BlendOpType.SOURCE:
|
|
280253
|
-
for (let row = 0;row < frame.height; row++) {
|
|
280254
|
-
for (let col = 0;col < frame.width; col++) {
|
|
280255
|
-
const { index, frameIndex } = calculatePixelIndices(row, col);
|
|
280256
|
-
for (let channel = 0;channel < this._png.channels; channel++) {
|
|
280257
|
-
imageFrame.data[index + channel] = frame.data[frameIndex + channel];
|
|
280258
|
-
}
|
|
280259
|
-
}
|
|
280260
|
-
}
|
|
280261
|
-
break;
|
|
280262
|
-
case BlendOpType.OVER:
|
|
280263
|
-
for (let row = 0;row < frame.height; row++) {
|
|
280264
|
-
for (let col = 0;col < frame.width; col++) {
|
|
280265
|
-
const { index, frameIndex } = calculatePixelIndices(row, col);
|
|
280266
|
-
for (let channel = 0;channel < this._png.channels; channel++) {
|
|
280267
|
-
const sourceAlpha = frame.data[frameIndex + this._png.channels - 1] / maxValue;
|
|
280268
|
-
const foregroundValue = channel % (this._png.channels - 1) === 0 ? 1 : frame.data[frameIndex + channel];
|
|
280269
|
-
const value = Math.floor(sourceAlpha * foregroundValue + (1 - sourceAlpha) * imageFrame.data[index + channel]);
|
|
280270
|
-
imageFrame.data[index + channel] += value;
|
|
280271
|
-
}
|
|
280272
|
-
}
|
|
280273
|
-
}
|
|
280274
|
-
break;
|
|
280275
|
-
default:
|
|
280276
|
-
throw new Error("Unknown blendOp");
|
|
280277
|
-
}
|
|
280278
|
-
}
|
|
280279
|
-
decodeImage() {
|
|
280280
|
-
const data = this._inflatorResult;
|
|
280281
|
-
if (this._filterMethod !== FilterMethod.ADAPTIVE) {
|
|
280282
|
-
throw new Error(`Filter method ${this._filterMethod} not supported`);
|
|
280283
|
-
}
|
|
280284
|
-
if (this._interlaceMethod === InterlaceMethod.NO_INTERLACE) {
|
|
280285
|
-
this._png.data = decodeInterlaceNull({
|
|
280286
|
-
data,
|
|
280287
|
-
width: this._png.width,
|
|
280288
|
-
height: this._png.height,
|
|
280289
|
-
channels: this._png.channels,
|
|
280290
|
-
depth: this._png.depth
|
|
280291
|
-
});
|
|
280292
|
-
} else if (this._interlaceMethod === InterlaceMethod.ADAM7) {
|
|
280293
|
-
this._png.data = decodeInterlaceAdam7({
|
|
280294
|
-
data,
|
|
280295
|
-
width: this._png.width,
|
|
280296
|
-
height: this._png.height,
|
|
280297
|
-
channels: this._png.channels,
|
|
280298
|
-
depth: this._png.depth
|
|
280299
|
-
});
|
|
280300
|
-
} else {
|
|
280301
|
-
throw new Error(`Interlace method ${this._interlaceMethod} not supported`);
|
|
280302
|
-
}
|
|
280303
|
-
if (this._hasPalette) {
|
|
280304
|
-
this._png.palette = this._palette;
|
|
280305
|
-
}
|
|
280306
|
-
if (this._hasTransparency) {
|
|
280307
|
-
this._png.transparency = this._transparency;
|
|
280308
|
-
}
|
|
280309
|
-
}
|
|
280310
|
-
pushDataToFrame() {
|
|
280311
|
-
this._inflator.push(new Uint8Array(0), true);
|
|
280312
|
-
const result = this._inflatorResult;
|
|
280313
|
-
const lastFrame = this._frames.at(-1);
|
|
280314
|
-
if (lastFrame) {
|
|
280315
|
-
lastFrame.data = result;
|
|
280316
|
-
} else {
|
|
280317
|
-
this._frames.push({
|
|
280318
|
-
sequenceNumber: 0,
|
|
280319
|
-
width: this._png.width,
|
|
280320
|
-
height: this._png.height,
|
|
280321
|
-
xOffset: 0,
|
|
280322
|
-
yOffset: 0,
|
|
280323
|
-
delayNumber: 0,
|
|
280324
|
-
delayDenominator: 0,
|
|
280325
|
-
disposeOp: DisposeOpType.NONE,
|
|
280326
|
-
blendOp: BlendOpType.SOURCE,
|
|
280327
|
-
data: result
|
|
280328
|
-
});
|
|
280329
|
-
}
|
|
280330
|
-
this._inflator = new Unzlib((chunk, final) => {
|
|
280331
|
-
this._chunks.push(chunk);
|
|
280332
|
-
if (final) {
|
|
280333
|
-
const totalLength = this._chunks.reduce((sum, c3) => sum + c3.length, 0);
|
|
280334
|
-
this._inflatorResult = new Uint8Array(totalLength);
|
|
280335
|
-
let offset = 0;
|
|
280336
|
-
for (const chunk2 of this._chunks) {
|
|
280337
|
-
this._inflatorResult.set(chunk2, offset);
|
|
280338
|
-
offset += chunk2.length;
|
|
280339
|
-
}
|
|
280340
|
-
this._chunks = [];
|
|
280341
|
-
}
|
|
280342
|
-
});
|
|
280343
|
-
this._chunks = [];
|
|
280344
|
-
this._writingDataChunks = false;
|
|
280345
|
-
}
|
|
280346
|
-
}
|
|
280347
|
-
function checkBitDepth(value) {
|
|
280348
|
-
if (value !== 1 && value !== 2 && value !== 4 && value !== 8 && value !== 16) {
|
|
280349
|
-
throw new Error(`invalid bit depth: ${value}`);
|
|
280350
|
-
}
|
|
280351
|
-
return value;
|
|
280352
|
-
}
|
|
280353
|
-
|
|
280354
|
-
// node_modules/fast-png/lib/png_encoder.js
|
|
280355
|
-
var defaultZlibOptions = {
|
|
280356
|
-
level: 3
|
|
280357
|
-
};
|
|
280358
|
-
|
|
280359
|
-
class PngEncoder extends IOBuffer {
|
|
280360
|
-
_png;
|
|
280361
|
-
_zlibOptions;
|
|
280362
|
-
_colorType;
|
|
280363
|
-
_interlaceMethod;
|
|
280364
|
-
constructor(data, options = {}) {
|
|
280365
|
-
super();
|
|
280366
|
-
this._colorType = ColorType.UNKNOWN;
|
|
280367
|
-
this._zlibOptions = { ...defaultZlibOptions, ...options.zlib };
|
|
280368
|
-
this._png = this._checkData(data);
|
|
280369
|
-
this._interlaceMethod = (options.interlace === "Adam7" ? InterlaceMethod.ADAM7 : InterlaceMethod.NO_INTERLACE) ?? InterlaceMethod.NO_INTERLACE;
|
|
280370
|
-
this.setBigEndian();
|
|
280371
|
-
}
|
|
280372
|
-
encode() {
|
|
280373
|
-
writeSignature(this);
|
|
280374
|
-
this.encodeIHDR();
|
|
280375
|
-
if (this._png.palette) {
|
|
280376
|
-
this.encodePLTE();
|
|
280377
|
-
if (this._png.palette[0].length === 4) {
|
|
280378
|
-
this.encodeTRNS();
|
|
280379
|
-
}
|
|
280380
|
-
}
|
|
280381
|
-
this.encodeData();
|
|
280382
|
-
if (this._png.text) {
|
|
280383
|
-
for (const [keyword, text] of Object.entries(this._png.text)) {
|
|
280384
|
-
encodetEXt(this, keyword, text);
|
|
280385
|
-
}
|
|
280386
|
-
}
|
|
280387
|
-
this.encodeIEND();
|
|
280388
|
-
return this.toArray();
|
|
280389
|
-
}
|
|
280390
|
-
encodeIHDR() {
|
|
280391
|
-
this.writeUint32(13);
|
|
280392
|
-
this.writeChars("IHDR");
|
|
280393
|
-
this.writeUint32(this._png.width);
|
|
280394
|
-
this.writeUint32(this._png.height);
|
|
280395
|
-
this.writeByte(this._png.depth);
|
|
280396
|
-
this.writeByte(this._colorType);
|
|
280397
|
-
this.writeByte(CompressionMethod.DEFLATE);
|
|
280398
|
-
this.writeByte(FilterMethod.ADAPTIVE);
|
|
280399
|
-
this.writeByte(this._interlaceMethod);
|
|
280400
|
-
writeCrc(this, 17);
|
|
280401
|
-
}
|
|
280402
|
-
encodeIEND() {
|
|
280403
|
-
this.writeUint32(0);
|
|
280404
|
-
this.writeChars("IEND");
|
|
280405
|
-
writeCrc(this, 4);
|
|
280406
|
-
}
|
|
280407
|
-
encodePLTE() {
|
|
280408
|
-
const paletteLength = this._png.palette?.length * 3;
|
|
280409
|
-
this.writeUint32(paletteLength);
|
|
280410
|
-
this.writeChars("PLTE");
|
|
280411
|
-
for (const color of this._png.palette) {
|
|
280412
|
-
this.writeByte(color[0]);
|
|
280413
|
-
this.writeByte(color[1]);
|
|
280414
|
-
this.writeByte(color[2]);
|
|
280415
|
-
}
|
|
280416
|
-
writeCrc(this, 4 + paletteLength);
|
|
280417
|
-
}
|
|
280418
|
-
encodeTRNS() {
|
|
280419
|
-
const alpha = this._png.palette.filter((color) => {
|
|
280420
|
-
return color.at(-1) !== 255;
|
|
280421
|
-
});
|
|
280422
|
-
this.writeUint32(alpha.length);
|
|
280423
|
-
this.writeChars("tRNS");
|
|
280424
|
-
for (const el3 of alpha) {
|
|
280425
|
-
this.writeByte(el3.at(-1));
|
|
280426
|
-
}
|
|
280427
|
-
writeCrc(this, 4 + alpha.length);
|
|
280428
|
-
}
|
|
280429
|
-
encodeIDAT(data) {
|
|
280430
|
-
this.writeUint32(data.length);
|
|
280431
|
-
this.writeChars("IDAT");
|
|
280432
|
-
this.writeBytes(data);
|
|
280433
|
-
writeCrc(this, data.length + 4);
|
|
280434
|
-
}
|
|
280435
|
-
encodeData() {
|
|
280436
|
-
const { width, height, channels, depth, data } = this._png;
|
|
280437
|
-
const slotsPerLine = depth <= 8 ? Math.ceil(width * depth / 8) * channels : Math.ceil(width * depth / 8 * channels / 2);
|
|
280438
|
-
const newData = new IOBuffer().setBigEndian();
|
|
280439
|
-
let offset = 0;
|
|
280440
|
-
if (this._interlaceMethod === InterlaceMethod.NO_INTERLACE) {
|
|
280441
|
-
for (let i3 = 0;i3 < height; i3++) {
|
|
280442
|
-
newData.writeByte(0);
|
|
280443
|
-
if (depth === 16) {
|
|
280444
|
-
offset = writeDataUint16(data, newData, slotsPerLine, offset);
|
|
280445
|
-
} else {
|
|
280446
|
-
offset = writeDataBytes(data, newData, slotsPerLine, offset);
|
|
280447
|
-
}
|
|
280448
|
-
}
|
|
280449
|
-
} else if (this._interlaceMethod === InterlaceMethod.ADAM7) {
|
|
280450
|
-
offset = writeDataInterlaced(this._png, data, newData, offset);
|
|
280451
|
-
}
|
|
280452
|
-
const buffer = newData.toArray();
|
|
280453
|
-
const compressed = zlibSync(buffer, this._zlibOptions);
|
|
280454
|
-
this.encodeIDAT(compressed);
|
|
280455
|
-
}
|
|
280456
|
-
_checkData(data) {
|
|
280457
|
-
const { colorType, channels, depth } = getColorType(data, data.palette);
|
|
280458
|
-
const png = {
|
|
280459
|
-
width: checkInteger(data.width, "width"),
|
|
280460
|
-
height: checkInteger(data.height, "height"),
|
|
280461
|
-
channels,
|
|
280462
|
-
data: data.data,
|
|
280463
|
-
depth,
|
|
280464
|
-
text: data.text,
|
|
280465
|
-
palette: data.palette
|
|
280466
|
-
};
|
|
280467
|
-
this._colorType = colorType;
|
|
280468
|
-
const expectedSize = depth < 8 ? Math.ceil(png.width * depth / 8) * png.height * channels : png.width * png.height * channels;
|
|
280469
|
-
if (png.data.length !== expectedSize) {
|
|
280470
|
-
throw new RangeError(`wrong data size. Found ${png.data.length}, expected ${expectedSize}`);
|
|
280471
|
-
}
|
|
280472
|
-
return png;
|
|
280473
|
-
}
|
|
280474
|
-
}
|
|
280475
|
-
function checkInteger(value, name) {
|
|
280476
|
-
if (Number.isInteger(value) && value > 0) {
|
|
280477
|
-
return value;
|
|
280478
|
-
}
|
|
280479
|
-
throw new TypeError(`${name} must be a positive integer`);
|
|
280480
|
-
}
|
|
280481
|
-
function getColorType(data, palette) {
|
|
280482
|
-
const { channels = 4, depth = 8 } = data;
|
|
280483
|
-
if (channels !== 4 && channels !== 3 && channels !== 2 && channels !== 1) {
|
|
280484
|
-
throw new RangeError(`unsupported number of channels: ${channels}`);
|
|
280485
|
-
}
|
|
280486
|
-
const returnValue = {
|
|
280487
|
-
channels,
|
|
280488
|
-
depth,
|
|
280489
|
-
colorType: ColorType.UNKNOWN
|
|
280490
|
-
};
|
|
280491
|
-
switch (channels) {
|
|
280492
|
-
case 4:
|
|
280493
|
-
returnValue.colorType = ColorType.TRUECOLOUR_ALPHA;
|
|
280494
|
-
break;
|
|
280495
|
-
case 3:
|
|
280496
|
-
returnValue.colorType = ColorType.TRUECOLOUR;
|
|
280497
|
-
break;
|
|
280498
|
-
case 1:
|
|
280499
|
-
if (palette) {
|
|
280500
|
-
returnValue.colorType = ColorType.INDEXED_COLOUR;
|
|
280501
|
-
} else {
|
|
280502
|
-
returnValue.colorType = ColorType.GREYSCALE;
|
|
280503
|
-
}
|
|
280504
|
-
break;
|
|
280505
|
-
case 2:
|
|
280506
|
-
returnValue.colorType = ColorType.GREYSCALE_ALPHA;
|
|
280507
|
-
break;
|
|
280508
|
-
default:
|
|
280509
|
-
throw new Error("unsupported number of channels");
|
|
280510
|
-
}
|
|
280511
|
-
return returnValue;
|
|
280512
|
-
}
|
|
280513
|
-
function writeDataBytes(data, newData, slotsPerLine, offset) {
|
|
280514
|
-
for (let j4 = 0;j4 < slotsPerLine; j4++) {
|
|
280515
|
-
newData.writeByte(data[offset++]);
|
|
280516
|
-
}
|
|
280517
|
-
return offset;
|
|
280518
|
-
}
|
|
280519
|
-
function writeDataInterlaced(imageData, data, newData, offset) {
|
|
280520
|
-
const passes = [
|
|
280521
|
-
{ x: 0, y: 0, xStep: 8, yStep: 8 },
|
|
280522
|
-
{ x: 4, y: 0, xStep: 8, yStep: 8 },
|
|
280523
|
-
{ x: 0, y: 4, xStep: 4, yStep: 8 },
|
|
280524
|
-
{ x: 2, y: 0, xStep: 4, yStep: 4 },
|
|
280525
|
-
{ x: 0, y: 2, xStep: 2, yStep: 4 },
|
|
280526
|
-
{ x: 1, y: 0, xStep: 2, yStep: 2 },
|
|
280527
|
-
{ x: 0, y: 1, xStep: 1, yStep: 2 }
|
|
280528
|
-
];
|
|
280529
|
-
const { width, height, channels, depth } = imageData;
|
|
280530
|
-
let pixelSize;
|
|
280531
|
-
if (depth === 16) {
|
|
280532
|
-
pixelSize = channels * depth / 8 / 2;
|
|
280533
|
-
} else {
|
|
280534
|
-
pixelSize = channels * depth / 8;
|
|
280535
|
-
}
|
|
280536
|
-
for (let passIndex = 0;passIndex < 7; passIndex++) {
|
|
280537
|
-
const pass = passes[passIndex];
|
|
280538
|
-
const passWidth = Math.floor((width - pass.x + pass.xStep - 1) / pass.xStep);
|
|
280539
|
-
const passHeight = Math.floor((height - pass.y + pass.yStep - 1) / pass.yStep);
|
|
280540
|
-
if (passWidth <= 0 || passHeight <= 0)
|
|
280541
|
-
continue;
|
|
280542
|
-
const passLineBytes = passWidth * pixelSize;
|
|
280543
|
-
for (let y4 = 0;y4 < passHeight; y4++) {
|
|
280544
|
-
const imageY = pass.y + y4 * pass.yStep;
|
|
280545
|
-
const rawScanline = depth <= 8 ? new Uint8Array(passLineBytes) : new Uint16Array(passLineBytes);
|
|
280546
|
-
let rawOffset = 0;
|
|
280547
|
-
for (let x4 = 0;x4 < passWidth; x4++) {
|
|
280548
|
-
const imageX = pass.x + x4 * pass.xStep;
|
|
280549
|
-
if (imageX < width && imageY < height) {
|
|
280550
|
-
const srcPos = (imageY * width + imageX) * pixelSize;
|
|
280551
|
-
for (let i3 = 0;i3 < pixelSize; i3++) {
|
|
280552
|
-
rawScanline[rawOffset++] = data[srcPos + i3];
|
|
280553
|
-
}
|
|
280554
|
-
}
|
|
280555
|
-
}
|
|
280556
|
-
newData.writeByte(0);
|
|
280557
|
-
if (depth === 8) {
|
|
280558
|
-
newData.writeBytes(rawScanline);
|
|
280559
|
-
} else if (depth === 16) {
|
|
280560
|
-
for (const value of rawScanline) {
|
|
280561
|
-
newData.writeByte(value >> 8 & 255);
|
|
280562
|
-
newData.writeByte(value & 255);
|
|
280563
|
-
}
|
|
280564
|
-
}
|
|
280565
|
-
}
|
|
280566
|
-
}
|
|
280567
|
-
return offset;
|
|
280568
|
-
}
|
|
280569
|
-
function writeDataUint16(data, newData, slotsPerLine, offset) {
|
|
280570
|
-
for (let j4 = 0;j4 < slotsPerLine; j4++) {
|
|
280571
|
-
newData.writeUint16(data[offset++]);
|
|
280572
|
-
}
|
|
280573
|
-
return offset;
|
|
280574
|
-
}
|
|
280575
|
-
|
|
280576
|
-
// node_modules/fast-png/lib/index.js
|
|
280577
|
-
function decodePng(data, options) {
|
|
280578
|
-
const decoder = new PngDecoder(data, options);
|
|
280579
|
-
return decoder.decode();
|
|
280580
|
-
}
|
|
280581
|
-
function encodePng(png, options) {
|
|
280582
|
-
const encoder2 = new PngEncoder(png, options);
|
|
280583
|
-
return encoder2.encode();
|
|
280584
|
-
}
|
|
280585
|
-
|
|
280586
|
-
// node_modules/@tscircuit/image-utils/dist/looks-same.js
|
|
280587
|
-
var DEFAULT_TOLERANCE = 2.3;
|
|
280588
|
-
var DEFAULT_HIGHLIGHT = { R: 255, G: 0, B: 255 };
|
|
280589
|
-
var areColorsSame = ({
|
|
280590
|
-
color1,
|
|
280591
|
-
color2
|
|
280592
|
-
}) => {
|
|
280593
|
-
return color1.R === color2.R && color1.G === color2.G && color1.B === color2.B;
|
|
280594
|
-
};
|
|
280595
|
-
var parsePng = (buffer) => {
|
|
280596
|
-
try {
|
|
280597
|
-
const png = decodePng(buffer);
|
|
280598
|
-
if (png.depth !== 8)
|
|
280599
|
-
return null;
|
|
280600
|
-
const channels = png.channels;
|
|
280601
|
-
const source = png.data;
|
|
280602
|
-
const rgba = new Uint8Array(png.width * png.height * 4);
|
|
280603
|
-
if (channels === 4) {
|
|
280604
|
-
rgba.set(source);
|
|
280605
|
-
} else if (channels === 3) {
|
|
280606
|
-
for (let i3 = 0, j4 = 0;i3 < source.length; i3 += 3, j4 += 4) {
|
|
280607
|
-
rgba[j4] = source[i3];
|
|
280608
|
-
rgba[j4 + 1] = source[i3 + 1];
|
|
280609
|
-
rgba[j4 + 2] = source[i3 + 2];
|
|
280610
|
-
rgba[j4 + 3] = 255;
|
|
280611
|
-
}
|
|
280612
|
-
} else {
|
|
280613
|
-
return null;
|
|
280614
|
-
}
|
|
280615
|
-
return {
|
|
280616
|
-
width: png.width,
|
|
280617
|
-
height: png.height,
|
|
280618
|
-
data: rgba,
|
|
280619
|
-
getPixel: (x4, y4) => {
|
|
280620
|
-
const index = (y4 * png.width + x4) * 4;
|
|
280621
|
-
return {
|
|
280622
|
-
R: rgba[index],
|
|
280623
|
-
G: rgba[index + 1],
|
|
280624
|
-
B: rgba[index + 2]
|
|
280625
|
-
};
|
|
280626
|
-
}
|
|
280627
|
-
};
|
|
280628
|
-
} catch {
|
|
280629
|
-
return null;
|
|
280630
|
-
}
|
|
280631
|
-
};
|
|
280632
|
-
var getBuffer = async (input) => {
|
|
280633
|
-
if (Buffer.isBuffer(input))
|
|
280634
|
-
return input;
|
|
280635
|
-
return readFile2(input);
|
|
280636
|
-
};
|
|
280637
|
-
var parseHexColor = (color) => {
|
|
280638
|
-
if (!color)
|
|
280639
|
-
return DEFAULT_HIGHLIGHT;
|
|
280640
|
-
const match = /^#?([0-9a-fA-F]{6})$/.exec(color.trim());
|
|
280641
|
-
if (!match)
|
|
280642
|
-
return DEFAULT_HIGHLIGHT;
|
|
280643
|
-
const hex = match[1];
|
|
280644
|
-
return {
|
|
280645
|
-
R: Number.parseInt(hex.slice(0, 2), 16),
|
|
280646
|
-
G: Number.parseInt(hex.slice(2, 4), 16),
|
|
280647
|
-
B: Number.parseInt(hex.slice(4, 6), 16)
|
|
280648
|
-
};
|
|
280649
|
-
};
|
|
280650
|
-
var makeCIEDE2000Comparator = (tolerance) => {
|
|
280651
|
-
const upperBound = tolerance * 6.2;
|
|
280652
|
-
const lowerBound = tolerance * 0.695;
|
|
280653
|
-
let rgbColor1 = null;
|
|
280654
|
-
let rgbColor2 = null;
|
|
280655
|
-
let labColor1 = null;
|
|
280656
|
-
let labColor2 = null;
|
|
280657
|
-
return (data) => {
|
|
280658
|
-
if (areColorsSame(data)) {
|
|
280659
|
-
return true;
|
|
280660
|
-
}
|
|
280661
|
-
let lab1 = null;
|
|
280662
|
-
let lab2 = null;
|
|
280663
|
-
if (rgbColor1 && areColorsSame({ color1: data.color1, color2: rgbColor1 })) {
|
|
280664
|
-
lab1 = labColor1;
|
|
280665
|
-
} else if (rgbColor2 && areColorsSame({ color1: data.color1, color2: rgbColor2 })) {
|
|
280666
|
-
lab1 = labColor2;
|
|
280667
|
-
}
|
|
280668
|
-
if (rgbColor1 && areColorsSame({ color1: data.color2, color2: rgbColor1 })) {
|
|
280669
|
-
lab2 = labColor1;
|
|
280670
|
-
} else if (rgbColor2 && areColorsSame({ color1: data.color2, color2: rgbColor2 })) {
|
|
280671
|
-
lab2 = labColor2;
|
|
280672
|
-
}
|
|
280673
|
-
if (!lab1) {
|
|
280674
|
-
lab1 = rgb_to_lab(data.color1);
|
|
280675
|
-
rgbColor1 = data.color1;
|
|
280676
|
-
labColor1 = lab1;
|
|
280677
|
-
}
|
|
280678
|
-
if (!lab2) {
|
|
280679
|
-
lab2 = rgb_to_lab(data.color2);
|
|
280680
|
-
rgbColor2 = data.color2;
|
|
280681
|
-
labColor2 = lab2;
|
|
280682
|
-
}
|
|
280683
|
-
const cie76 = Math.sqrt((lab1.L - lab2.L) * (lab1.L - lab2.L) + (lab1.a - lab2.a) * (lab1.a - lab2.a) + (lab1.b - lab2.b) * (lab1.b - lab2.b));
|
|
280684
|
-
if (cie76 >= upperBound)
|
|
280685
|
-
return false;
|
|
280686
|
-
if (cie76 <= lowerBound)
|
|
280687
|
-
return true;
|
|
280688
|
-
return ciede2000(lab1, lab2) < tolerance;
|
|
280689
|
-
};
|
|
280690
|
-
};
|
|
280691
|
-
var AntialiasingComparator = class {
|
|
280692
|
-
_baseComparator;
|
|
280693
|
-
_img1;
|
|
280694
|
-
_img2;
|
|
280695
|
-
_brightnessTolerance;
|
|
280696
|
-
constructor(baseComparator, img1, img2, { antialiasingTolerance = 0 }) {
|
|
280697
|
-
this._baseComparator = baseComparator;
|
|
280698
|
-
this._img1 = img1;
|
|
280699
|
-
this._img2 = img2;
|
|
280700
|
-
this._brightnessTolerance = antialiasingTolerance;
|
|
280701
|
-
}
|
|
280702
|
-
compare(data) {
|
|
280703
|
-
return this._baseComparator(data) || this._checkIsAntialiased(data);
|
|
280704
|
-
}
|
|
280705
|
-
_checkIsAntialiased(data) {
|
|
280706
|
-
return this._isAntialiased(this._img2, data.x, data.y, data, this._img1) || this._isAntialiased(this._img1, data.x, data.y, data, this._img2);
|
|
280707
|
-
}
|
|
280708
|
-
_isAntialiased(img1, x12, y12, data, img2) {
|
|
280709
|
-
const color1 = img1.getPixel(x12, y12);
|
|
280710
|
-
const x02 = Math.max(x12 - 1, 0);
|
|
280711
|
-
const y02 = Math.max(y12 - 1, 0);
|
|
280712
|
-
const x23 = Math.min(x12 + 1, data.width - 1);
|
|
280713
|
-
const y23 = Math.min(y12 + 1, data.height - 1);
|
|
280714
|
-
const checkExtremePixels = !img2;
|
|
280715
|
-
const brightnessTolerance = checkExtremePixels ? this._brightnessTolerance : 0;
|
|
280716
|
-
let zeroes = 0;
|
|
280717
|
-
let positives = 0;
|
|
280718
|
-
let negatives = 0;
|
|
280719
|
-
let min = 0;
|
|
280720
|
-
let max2 = 0;
|
|
280721
|
-
let minX = 0;
|
|
280722
|
-
let minY = 0;
|
|
280723
|
-
let maxX = 0;
|
|
280724
|
-
let maxY = 0;
|
|
280725
|
-
for (let y4 = y02;y4 <= y23; y4 += 1) {
|
|
280726
|
-
for (let x4 = x02;x4 <= x23; x4 += 1) {
|
|
280727
|
-
if (x4 === x12 && y4 === y12)
|
|
280728
|
-
continue;
|
|
280729
|
-
const delta = this._brightnessDelta(img1.getPixel(x4, y4), color1);
|
|
280730
|
-
if (Math.abs(delta) <= brightnessTolerance) {
|
|
280731
|
-
zeroes += 1;
|
|
280732
|
-
} else if (delta > brightnessTolerance) {
|
|
280733
|
-
positives += 1;
|
|
280734
|
-
} else {
|
|
280735
|
-
negatives += 1;
|
|
280736
|
-
}
|
|
280737
|
-
if (zeroes > 2)
|
|
280738
|
-
return false;
|
|
280739
|
-
if (checkExtremePixels)
|
|
280740
|
-
continue;
|
|
280741
|
-
if (delta < min) {
|
|
280742
|
-
min = delta;
|
|
280743
|
-
minX = x4;
|
|
280744
|
-
minY = y4;
|
|
280745
|
-
}
|
|
280746
|
-
if (delta > max2) {
|
|
280747
|
-
max2 = delta;
|
|
280748
|
-
maxX = x4;
|
|
280749
|
-
maxY = y4;
|
|
280750
|
-
}
|
|
280751
|
-
}
|
|
280752
|
-
}
|
|
280753
|
-
if (checkExtremePixels)
|
|
280754
|
-
return true;
|
|
280755
|
-
if (negatives === 0 || positives === 0)
|
|
280756
|
-
return false;
|
|
280757
|
-
return !this._isAntialiased(img1, minX, minY, data) && !this._isAntialiased(img2, minX, minY, data) || !this._isAntialiased(img1, maxX, maxY, data) && !this._isAntialiased(img2, maxX, maxY, data);
|
|
280758
|
-
}
|
|
280759
|
-
_brightnessDelta(color1, color2) {
|
|
280760
|
-
return color1.R * 0.29889531 + color1.G * 0.58662247 + color1.B * 0.11448223 - (color2.R * 0.29889531 + color2.G * 0.58662247 + color2.B * 0.11448223);
|
|
280761
|
-
}
|
|
280762
|
-
};
|
|
280763
|
-
var IgnoreCaretComparator = class {
|
|
280764
|
-
pixelRatio;
|
|
280765
|
-
caretTopLeft = null;
|
|
280766
|
-
caretBottomRight = null;
|
|
280767
|
-
_baseComparator;
|
|
280768
|
-
_state = "init";
|
|
280769
|
-
constructor(baseComparator, pixelRatio) {
|
|
280770
|
-
this.pixelRatio = pixelRatio ? Math.floor(pixelRatio) : 1;
|
|
280771
|
-
this._baseComparator = baseComparator;
|
|
280772
|
-
}
|
|
280773
|
-
compare(data) {
|
|
280774
|
-
return this._baseComparator(data) || this._checkIsCaret(data);
|
|
280775
|
-
}
|
|
280776
|
-
_checkIsCaret(data) {
|
|
280777
|
-
if (this._state === "caretDetected") {
|
|
280778
|
-
return this.caretTopLeft !== null && this.caretBottomRight !== null && data.x >= this.caretTopLeft.x && data.x <= this.caretBottomRight.x && data.y >= this.caretTopLeft.y && data.y <= this.caretBottomRight.y;
|
|
280779
|
-
}
|
|
280780
|
-
if (this.caretTopLeft && this.caretBottomRight && data.x >= this.caretTopLeft.x && data.x <= this.caretBottomRight.x && data.y >= this.caretTopLeft.y && data.y <= this.caretBottomRight.y) {
|
|
280781
|
-
return true;
|
|
280782
|
-
}
|
|
280783
|
-
const lastCaretPoint = this._getLastCaretPoint(data);
|
|
280784
|
-
if (!this._looksLikeCaret({ x: data.x, y: data.y }, lastCaretPoint)) {
|
|
280785
|
-
return false;
|
|
280786
|
-
}
|
|
280787
|
-
this.caretTopLeft = { x: data.x, y: data.y };
|
|
280788
|
-
this.caretBottomRight = lastCaretPoint;
|
|
280789
|
-
this._state = "caretDetected";
|
|
280790
|
-
return true;
|
|
280791
|
-
}
|
|
280792
|
-
_getLastCaretPoint(data) {
|
|
280793
|
-
let currPoint = { x: data.x, y: data.y };
|
|
280794
|
-
while (true) {
|
|
280795
|
-
const nextPoint = this._getNextCaretPoint({ x: data.x, y: data.y }, currPoint);
|
|
280796
|
-
if (this._isPointOutsideImages(nextPoint, data) || this._areColorsSame(nextPoint, data)) {
|
|
280797
|
-
return currPoint;
|
|
280798
|
-
}
|
|
280799
|
-
currPoint = nextPoint;
|
|
280800
|
-
}
|
|
280801
|
-
}
|
|
280802
|
-
_isPointOutsideImages(point6, data) {
|
|
280803
|
-
return point6.x >= data.minWidth || point6.y >= data.minHeight;
|
|
280804
|
-
}
|
|
280805
|
-
_areColorsSame(point6, data) {
|
|
280806
|
-
const color1 = data.img1.getPixel(point6.x, point6.y);
|
|
280807
|
-
const color2 = data.img2.getPixel(point6.x, point6.y);
|
|
280808
|
-
return areColorsSame({ color1, color2 });
|
|
280809
|
-
}
|
|
280810
|
-
_getNextCaretPoint(firstCaretPoint, currPoint) {
|
|
280811
|
-
const nextX = currPoint.x + 1;
|
|
280812
|
-
return nextX < firstCaretPoint.x + this.pixelRatio ? { x: nextX, y: currPoint.y } : { x: firstCaretPoint.x, y: currPoint.y + 1 };
|
|
280813
|
-
}
|
|
280814
|
-
_looksLikeCaret(firstCaretPoint, lastCaretPoint) {
|
|
280815
|
-
return this._caretHeight(firstCaretPoint, lastCaretPoint) > 1 && this._caretWidth(firstCaretPoint, lastCaretPoint) === this.pixelRatio;
|
|
280816
|
-
}
|
|
280817
|
-
_caretHeight(firstCaretPoint, lastCaretPoint) {
|
|
280818
|
-
return lastCaretPoint.y - firstCaretPoint.y + 1;
|
|
280819
|
-
}
|
|
280820
|
-
_caretWidth(firstCaretPoint, lastCaretPoint) {
|
|
280821
|
-
return lastCaretPoint.x - firstCaretPoint.x + 1;
|
|
280822
|
-
}
|
|
280823
|
-
};
|
|
280824
|
-
var prepareOptions = (options = {}) => {
|
|
280825
|
-
if (options.strict && options.tolerance !== undefined) {
|
|
280826
|
-
throw new TypeError('Unable to use "strict" and "tolerance" options together');
|
|
280827
|
-
}
|
|
280828
|
-
if (options.percentThreshold !== undefined && (!Number.isFinite(options.percentThreshold) || options.percentThreshold < 0)) {
|
|
280829
|
-
throw new TypeError('Expected "percentThreshold" to be a non-negative number');
|
|
280830
|
-
}
|
|
280831
|
-
return {
|
|
280832
|
-
strict: Boolean(options.strict),
|
|
280833
|
-
tolerance: options.tolerance ?? DEFAULT_TOLERANCE,
|
|
280834
|
-
ignoreCaret: options.ignoreCaret ?? true,
|
|
280835
|
-
ignoreAntialiasing: options.ignoreAntialiasing ?? true,
|
|
280836
|
-
antialiasingTolerance: options.antialiasingTolerance ?? 0,
|
|
280837
|
-
pixelRatio: options.pixelRatio
|
|
280838
|
-
};
|
|
280839
|
-
};
|
|
280840
|
-
var createComparator = (img1, img2, options) => {
|
|
280841
|
-
let comparator = options.strict ? (data) => areColorsSame(data) : makeCIEDE2000Comparator(options.tolerance);
|
|
280842
|
-
if (options.ignoreAntialiasing) {
|
|
280843
|
-
const antialiasingComparator = new AntialiasingComparator(comparator, img1, img2, options);
|
|
280844
|
-
comparator = (data) => antialiasingComparator.compare(data);
|
|
280845
|
-
}
|
|
280846
|
-
if (options.ignoreCaret) {
|
|
280847
|
-
const caretComparator = new IgnoreCaretComparator(comparator, options.pixelRatio);
|
|
280848
|
-
comparator = (data) => caretComparator.compare(data);
|
|
280849
|
-
}
|
|
280850
|
-
return comparator;
|
|
280851
|
-
};
|
|
280852
|
-
var compare = async (buffer1, buffer2, options) => {
|
|
280853
|
-
const reference = parsePng(buffer1);
|
|
280854
|
-
const current4 = parsePng(buffer2);
|
|
280855
|
-
if (!reference || !current4) {
|
|
280856
|
-
return { equal: buffer1.equals(buffer2) };
|
|
280857
|
-
}
|
|
280858
|
-
const comparator = createComparator(reference, current4, options);
|
|
280859
|
-
const width = Math.max(reference.width, current4.width);
|
|
280860
|
-
const height = Math.max(reference.height, current4.height);
|
|
280861
|
-
const minWidth = Math.min(reference.width, current4.width);
|
|
280862
|
-
const minHeight = Math.min(reference.height, current4.height);
|
|
280863
|
-
const totalPixels = width * height;
|
|
280864
|
-
let differentPixels = 0;
|
|
280865
|
-
for (let y4 = 0;y4 < height; y4 += 1) {
|
|
280866
|
-
for (let x4 = 0;x4 < width; x4 += 1) {
|
|
280867
|
-
if (x4 >= minWidth || y4 >= minHeight) {
|
|
280868
|
-
differentPixels += 1;
|
|
280869
|
-
continue;
|
|
280870
|
-
}
|
|
280871
|
-
const color1 = reference.getPixel(x4, y4);
|
|
280872
|
-
const color2 = current4.getPixel(x4, y4);
|
|
280873
|
-
const same = areColorsSame({ color1, color2 }) || comparator({
|
|
280874
|
-
color1,
|
|
280875
|
-
color2,
|
|
280876
|
-
img1: reference,
|
|
280877
|
-
img2: current4,
|
|
280878
|
-
x: x4,
|
|
280879
|
-
y: y4,
|
|
280880
|
-
width,
|
|
280881
|
-
height,
|
|
280882
|
-
minWidth,
|
|
280883
|
-
minHeight
|
|
280884
|
-
});
|
|
280885
|
-
if (!same) {
|
|
280886
|
-
differentPixels += 1;
|
|
280887
|
-
}
|
|
280888
|
-
}
|
|
280889
|
-
}
|
|
280890
|
-
return {
|
|
280891
|
-
equal: differentPixels === 0,
|
|
280892
|
-
differentPixels,
|
|
280893
|
-
totalPixels
|
|
280894
|
-
};
|
|
280895
|
-
};
|
|
280896
|
-
var looksSameImpl = async (reference, current4, options = {}) => {
|
|
280897
|
-
const prepared = prepareOptions(options);
|
|
280898
|
-
const referenceBuffer = await getBuffer(reference);
|
|
280899
|
-
const currentBuffer = await getBuffer(current4);
|
|
280900
|
-
return compare(referenceBuffer, currentBuffer, prepared);
|
|
280901
|
-
};
|
|
280902
|
-
var createDiff = async ({
|
|
280903
|
-
reference,
|
|
280904
|
-
current: current4,
|
|
280905
|
-
diff: diff2,
|
|
280906
|
-
highlightColor,
|
|
280907
|
-
...options
|
|
280908
|
-
}) => {
|
|
280909
|
-
const prepared = prepareOptions(options);
|
|
280910
|
-
const referenceBuffer = await getBuffer(reference);
|
|
280911
|
-
const currentBuffer = await getBuffer(current4);
|
|
280912
|
-
const referencePng = parsePng(referenceBuffer);
|
|
280913
|
-
const currentPng = parsePng(currentBuffer);
|
|
280914
|
-
if (!(diff2.endsWith(".png") && referencePng && currentPng)) {
|
|
280915
|
-
await writeFile(diff2, currentBuffer);
|
|
280916
|
-
return;
|
|
280917
|
-
}
|
|
280918
|
-
const comparator = createComparator(referencePng, currentPng, prepared);
|
|
280919
|
-
const width = Math.max(referencePng.width, currentPng.width);
|
|
280920
|
-
const height = Math.max(referencePng.height, currentPng.height);
|
|
280921
|
-
const minWidth = Math.min(referencePng.width, currentPng.width);
|
|
280922
|
-
const minHeight = Math.min(referencePng.height, currentPng.height);
|
|
280923
|
-
const highlight = parseHexColor(highlightColor);
|
|
280924
|
-
const diffData = new Uint8Array(width * height * 4);
|
|
280925
|
-
for (let y4 = 0;y4 < height; y4 += 1) {
|
|
280926
|
-
for (let x4 = 0;x4 < width; x4 += 1) {
|
|
280927
|
-
const index = (y4 * width + x4) * 4;
|
|
280928
|
-
if (x4 >= minWidth || y4 >= minHeight) {
|
|
280929
|
-
diffData[index] = highlight.R;
|
|
280930
|
-
diffData[index + 1] = highlight.G;
|
|
280931
|
-
diffData[index + 2] = highlight.B;
|
|
280932
|
-
diffData[index + 3] = 255;
|
|
280933
|
-
continue;
|
|
280934
|
-
}
|
|
280935
|
-
const color1 = referencePng.getPixel(x4, y4);
|
|
280936
|
-
const color2 = currentPng.getPixel(x4, y4);
|
|
280937
|
-
const same = areColorsSame({ color1, color2 }) || comparator({
|
|
280938
|
-
color1,
|
|
280939
|
-
color2,
|
|
280940
|
-
img1: referencePng,
|
|
280941
|
-
img2: currentPng,
|
|
280942
|
-
x: x4,
|
|
280943
|
-
y: y4,
|
|
280944
|
-
width,
|
|
280945
|
-
height,
|
|
280946
|
-
minWidth,
|
|
280947
|
-
minHeight
|
|
280948
|
-
});
|
|
280949
|
-
if (same) {
|
|
280950
|
-
diffData[index] = color1.R;
|
|
280951
|
-
diffData[index + 1] = color1.G;
|
|
280952
|
-
diffData[index + 2] = color1.B;
|
|
280953
|
-
diffData[index + 3] = 255;
|
|
280954
|
-
} else {
|
|
280955
|
-
diffData[index] = highlight.R;
|
|
280956
|
-
diffData[index + 1] = highlight.G;
|
|
280957
|
-
diffData[index + 2] = highlight.B;
|
|
280958
|
-
diffData[index + 3] = 255;
|
|
280959
|
-
}
|
|
280960
|
-
}
|
|
280961
|
-
}
|
|
280962
|
-
const encoded = encodePng({
|
|
280963
|
-
width,
|
|
280964
|
-
height,
|
|
280965
|
-
data: diffData,
|
|
280966
|
-
channels: 4,
|
|
280967
|
-
depth: 8
|
|
280968
|
-
});
|
|
280969
|
-
await writeFile(diff2, Buffer.from(encoded));
|
|
280970
|
-
};
|
|
280971
|
-
var looksSame = Object.assign(looksSameImpl, { createDiff });
|
|
280972
|
-
var looks_same_default = looksSame;
|
|
280973
|
-
|
|
280974
278364
|
// lib/shared/compare-images.ts
|
|
278365
|
+
import looksSame from "@tscircuit/image-utils/looks-same";
|
|
280975
278366
|
import fs64 from "node:fs/promises";
|
|
280976
|
-
var compareAndCreateDiff = async (buffer1, buffer2, diffPath,
|
|
278367
|
+
var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
|
|
280977
278368
|
const b12 = Buffer.from(buffer1);
|
|
280978
278369
|
const b22 = Buffer.from(buffer2);
|
|
280979
|
-
const { equal: equal2 } = await
|
|
278370
|
+
const { equal: equal2 } = await looksSame(b12, b22, {
|
|
280980
278371
|
strict: false,
|
|
280981
278372
|
tolerance: 2
|
|
280982
278373
|
});
|
|
280983
|
-
if (!equal2 &&
|
|
278374
|
+
if (!equal2 && createDiff) {
|
|
280984
278375
|
if (diffPath.endsWith(".png")) {
|
|
280985
|
-
await
|
|
278376
|
+
const diffBuffer = await looksSame.createDiff({
|
|
280986
278377
|
reference: b12,
|
|
280987
278378
|
current: b22,
|
|
280988
|
-
diff: diffPath,
|
|
280989
278379
|
highlightColor: "#ff00ff",
|
|
280990
278380
|
tolerance: 2
|
|
280991
278381
|
});
|
|
278382
|
+
await fs64.writeFile(diffPath, diffBuffer);
|
|
280992
278383
|
} else {
|
|
280993
278384
|
await fs64.writeFile(diffPath, buffer2);
|
|
280994
278385
|
}
|
|
@@ -281008,7 +278399,7 @@ var processSnapshotFile = async ({
|
|
|
281008
278399
|
forceUpdate,
|
|
281009
278400
|
platformConfig: platformConfig2,
|
|
281010
278401
|
pcbSnapshotSettings,
|
|
281011
|
-
createDiff
|
|
278402
|
+
createDiff,
|
|
281012
278403
|
cameraPreset,
|
|
281013
278404
|
pcbLayer
|
|
281014
278405
|
}) => {
|
|
@@ -281020,6 +278411,7 @@ var processSnapshotFile = async ({
|
|
|
281020
278411
|
let circuitJson;
|
|
281021
278412
|
let pcbSvg;
|
|
281022
278413
|
let schSvg;
|
|
278414
|
+
let simulationSvgAssets;
|
|
281023
278415
|
try {
|
|
281024
278416
|
if (isCircuitJsonFile(file)) {
|
|
281025
278417
|
const parsed = JSON.parse(fs65.readFileSync(file, "utf-8"));
|
|
@@ -281078,6 +278470,22 @@ var processSnapshotFile = async ({
|
|
|
281078
278470
|
errorMessage: kleur_default.red(`
|
|
281079
278471
|
❌ Failed to generate schematic SVG for ${relativeFilePath}:
|
|
281080
278472
|
`) + kleur_default.red(` ${errorMessage}
|
|
278473
|
+
`)
|
|
278474
|
+
};
|
|
278475
|
+
}
|
|
278476
|
+
try {
|
|
278477
|
+
simulationSvgAssets = getSimulationSvgAssetsFromCircuitJson(circuitJson);
|
|
278478
|
+
} catch (error) {
|
|
278479
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
278480
|
+
return {
|
|
278481
|
+
ok: false,
|
|
278482
|
+
didUpdate: false,
|
|
278483
|
+
successPaths,
|
|
278484
|
+
warningMessages,
|
|
278485
|
+
mismatches,
|
|
278486
|
+
errorMessage: kleur_default.red(`
|
|
278487
|
+
❌ Failed to generate simulation SVGs for ${relativeFilePath}:
|
|
278488
|
+
`) + kleur_default.red(` ${errorMessage}
|
|
281081
278489
|
`)
|
|
281082
278490
|
};
|
|
281083
278491
|
}
|
|
@@ -281154,6 +278562,18 @@ var processSnapshotFile = async ({
|
|
|
281154
278562
|
if (threeD && png3d) {
|
|
281155
278563
|
snapshots.push({ type: "3d", content: png3d, isBinary: true });
|
|
281156
278564
|
}
|
|
278565
|
+
if (!pcbOnly && !schematicOnly && simulationSvgAssets) {
|
|
278566
|
+
snapshots.push({
|
|
278567
|
+
type: "simulation",
|
|
278568
|
+
content: simulationSvgAssets.simulationSvg,
|
|
278569
|
+
isBinary: false
|
|
278570
|
+
});
|
|
278571
|
+
snapshots.push({
|
|
278572
|
+
type: "schematic-simulation",
|
|
278573
|
+
content: simulationSvgAssets.schematicSimulationSvg,
|
|
278574
|
+
isBinary: false
|
|
278575
|
+
});
|
|
278576
|
+
}
|
|
281157
278577
|
for (const snapshot of snapshots) {
|
|
281158
278578
|
const { type } = snapshot;
|
|
281159
278579
|
const is3d = type === "3d";
|
|
@@ -281170,7 +278590,7 @@ var processSnapshotFile = async ({
|
|
|
281170
278590
|
const oldContentBuffer = fs65.readFileSync(snapPath);
|
|
281171
278591
|
let equal2;
|
|
281172
278592
|
let diffPath;
|
|
281173
|
-
if (
|
|
278593
|
+
if (createDiff) {
|
|
281174
278594
|
diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
281175
278595
|
const comparison = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath, true);
|
|
281176
278596
|
equal2 = comparison.equal;
|
|
@@ -281218,7 +278638,7 @@ var snapshotProject = async ({
|
|
|
281218
278638
|
onSuccess = (msg) => console.log(msg),
|
|
281219
278639
|
platformConfig: platformConfig2,
|
|
281220
278640
|
pcbSnapshotSettingsOverride,
|
|
281221
|
-
createDiff
|
|
278641
|
+
createDiff = false,
|
|
281222
278642
|
cameraPreset,
|
|
281223
278643
|
pcbLayer,
|
|
281224
278644
|
concurrency = 1
|
|
@@ -281293,7 +278713,7 @@ var snapshotProject = async ({
|
|
|
281293
278713
|
forceUpdate,
|
|
281294
278714
|
platformConfig: platformConfig2,
|
|
281295
278715
|
pcbSnapshotSettings,
|
|
281296
|
-
createDiff
|
|
278716
|
+
createDiff,
|
|
281297
278717
|
cameraPreset,
|
|
281298
278718
|
pcbLayer
|
|
281299
278719
|
},
|
|
@@ -281333,7 +278753,7 @@ var snapshotProject = async ({
|
|
|
281333
278753
|
forceUpdate,
|
|
281334
278754
|
platformConfig: mergedPlatformConfig,
|
|
281335
278755
|
pcbSnapshotSettings,
|
|
281336
|
-
createDiff
|
|
278756
|
+
createDiff,
|
|
281337
278757
|
cameraPreset,
|
|
281338
278758
|
pcbLayer
|
|
281339
278759
|
});
|
|
@@ -281558,13 +278978,13 @@ program2.command("version").description("Print CLI version").option("--verbose",
|
|
|
281558
278978
|
console.log(getVersion({ verbose: options.verbose }));
|
|
281559
278979
|
});
|
|
281560
278980
|
if (process.argv.length === 2) {
|
|
281561
|
-
import_perfect_cli.perfectCli(program2, process.argv).catch((
|
|
281562
|
-
if (
|
|
278981
|
+
import_perfect_cli.perfectCli(program2, process.argv).catch((err) => {
|
|
278982
|
+
if (err instanceof Error && err.name === "TypeError") {
|
|
281563
278983
|
console.error(`
|
|
281564
278984
|
Aborted.`);
|
|
281565
278985
|
process.exit(130);
|
|
281566
278986
|
}
|
|
281567
|
-
throw
|
|
278987
|
+
throw err;
|
|
281568
278988
|
});
|
|
281569
278989
|
} else {
|
|
281570
278990
|
program2.parse();
|