@fern-api/fern-api-dev 3.54.1 → 3.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +2721 -206
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -81013,8 +81013,8 @@ var require_graceful_fs = __commonJS({
|
|
|
81013
81013
|
fs34.createReadStream = createReadStream3;
|
|
81014
81014
|
fs34.createWriteStream = createWriteStream7;
|
|
81015
81015
|
var fs$readFile = fs34.readFile;
|
|
81016
|
-
fs34.readFile =
|
|
81017
|
-
function
|
|
81016
|
+
fs34.readFile = readFile89;
|
|
81017
|
+
function readFile89(path86, options2, cb2) {
|
|
81018
81018
|
if (typeof options2 === "function")
|
|
81019
81019
|
cb2 = options2, options2 = null;
|
|
81020
81020
|
return go$readFile(path86, options2, cb2);
|
|
@@ -81030,8 +81030,8 @@ var require_graceful_fs = __commonJS({
|
|
|
81030
81030
|
}
|
|
81031
81031
|
}
|
|
81032
81032
|
var fs$writeFile = fs34.writeFile;
|
|
81033
|
-
fs34.writeFile =
|
|
81034
|
-
function
|
|
81033
|
+
fs34.writeFile = writeFile79;
|
|
81034
|
+
function writeFile79(path86, data2, options2, cb2) {
|
|
81035
81035
|
if (typeof options2 === "function")
|
|
81036
81036
|
cb2 = options2, options2 = null;
|
|
81037
81037
|
return go$writeFile(path86, data2, options2, cb2);
|
|
@@ -1151729,8 +1151729,8 @@ var require_graceful_fs2 = __commonJS({
|
|
|
1151729
1151729
|
fs34.createReadStream = createReadStream3;
|
|
1151730
1151730
|
fs34.createWriteStream = createWriteStream7;
|
|
1151731
1151731
|
var fs$readFile = fs34.readFile;
|
|
1151732
|
-
fs34.readFile =
|
|
1151733
|
-
function
|
|
1151732
|
+
fs34.readFile = readFile89;
|
|
1151733
|
+
function readFile89(path86, options2, cb2) {
|
|
1151734
1151734
|
if (typeof options2 === "function")
|
|
1151735
1151735
|
cb2 = options2, options2 = null;
|
|
1151736
1151736
|
return go$readFile(path86, options2, cb2);
|
|
@@ -1151746,8 +1151746,8 @@ var require_graceful_fs2 = __commonJS({
|
|
|
1151746
1151746
|
}
|
|
1151747
1151747
|
}
|
|
1151748
1151748
|
var fs$writeFile = fs34.writeFile;
|
|
1151749
|
-
fs34.writeFile =
|
|
1151750
|
-
function
|
|
1151749
|
+
fs34.writeFile = writeFile79;
|
|
1151750
|
+
function writeFile79(path86, data2, options2, cb2) {
|
|
1151751
1151751
|
if (typeof options2 === "function")
|
|
1151752
1151752
|
cb2 = options2, options2 = null;
|
|
1151753
1151753
|
return go$writeFile(path86, data2, options2, cb2);
|
|
@@ -1160591,10 +1160591,10 @@ var require_make_dir = __commonJS({
|
|
|
1160591
1160591
|
module4.exports = (input3, opts) => Promise.resolve().then(() => {
|
|
1160592
1160592
|
checkPath(input3);
|
|
1160593
1160593
|
opts = Object.assign({}, defaults3, opts);
|
|
1160594
|
-
const
|
|
1160594
|
+
const mkdir38 = pify(opts.fs.mkdir);
|
|
1160595
1160595
|
const stat3 = pify(opts.fs.stat);
|
|
1160596
1160596
|
const make = (pth) => {
|
|
1160597
|
-
return
|
|
1160597
|
+
return mkdir38(pth, opts.mode).then(() => pth).catch((err) => {
|
|
1160598
1160598
|
if (err.code === "ENOENT") {
|
|
1160599
1160599
|
if (err.message.includes("null bytes") || path86.dirname(pth) === pth) {
|
|
1160600
1160600
|
throw err;
|
|
@@ -1175296,14 +1175296,14 @@ var require_empty = __commonJS({
|
|
|
1175296
1175296
|
var u7 = require_universalify().fromPromise;
|
|
1175297
1175297
|
var fs33 = require_fs();
|
|
1175298
1175298
|
var path86 = require("path");
|
|
1175299
|
-
var
|
|
1175299
|
+
var mkdir38 = require_mkdirs();
|
|
1175300
1175300
|
var remove3 = require_remove2();
|
|
1175301
1175301
|
var emptyDir = u7(async function emptyDir2(dir) {
|
|
1175302
1175302
|
let items;
|
|
1175303
1175303
|
try {
|
|
1175304
1175304
|
items = await fs33.readdir(dir);
|
|
1175305
1175305
|
} catch {
|
|
1175306
|
-
return
|
|
1175306
|
+
return mkdir38.mkdirs(dir);
|
|
1175307
1175307
|
}
|
|
1175308
1175308
|
return Promise.all(items.map((item) => remove3.remove(path86.join(dir, item))));
|
|
1175309
1175309
|
});
|
|
@@ -1175312,7 +1175312,7 @@ var require_empty = __commonJS({
|
|
|
1175312
1175312
|
try {
|
|
1175313
1175313
|
items = fs33.readdirSync(dir);
|
|
1175314
1175314
|
} catch {
|
|
1175315
|
-
return
|
|
1175315
|
+
return mkdir38.mkdirsSync(dir);
|
|
1175316
1175316
|
}
|
|
1175317
1175317
|
items.forEach((item) => {
|
|
1175318
1175318
|
item = path86.join(dir, item);
|
|
@@ -1175335,7 +1175335,7 @@ var require_file = __commonJS({
|
|
|
1175335
1175335
|
var u7 = require_universalify().fromPromise;
|
|
1175336
1175336
|
var path86 = require("path");
|
|
1175337
1175337
|
var fs33 = require_fs();
|
|
1175338
|
-
var
|
|
1175338
|
+
var mkdir38 = require_mkdirs();
|
|
1175339
1175339
|
async function createFile2(file4) {
|
|
1175340
1175340
|
let stats;
|
|
1175341
1175341
|
try {
|
|
@@ -1175349,7 +1175349,7 @@ var require_file = __commonJS({
|
|
|
1175349
1175349
|
dirStats = await fs33.stat(dir);
|
|
1175350
1175350
|
} catch (err) {
|
|
1175351
1175351
|
if (err.code === "ENOENT") {
|
|
1175352
|
-
await
|
|
1175352
|
+
await mkdir38.mkdirs(dir);
|
|
1175353
1175353
|
await fs33.writeFile(file4, "");
|
|
1175354
1175354
|
return;
|
|
1175355
1175355
|
} else {
|
|
@@ -1175375,7 +1175375,7 @@ var require_file = __commonJS({
|
|
|
1175375
1175375
|
fs33.readdirSync(dir);
|
|
1175376
1175376
|
}
|
|
1175377
1175377
|
} catch (err) {
|
|
1175378
|
-
if (err && err.code === "ENOENT")
|
|
1175378
|
+
if (err && err.code === "ENOENT") mkdir38.mkdirsSync(dir);
|
|
1175379
1175379
|
else throw err;
|
|
1175380
1175380
|
}
|
|
1175381
1175381
|
fs33.writeFileSync(file4, "");
|
|
@@ -1175394,7 +1175394,7 @@ var require_link = __commonJS({
|
|
|
1175394
1175394
|
var u7 = require_universalify().fromPromise;
|
|
1175395
1175395
|
var path86 = require("path");
|
|
1175396
1175396
|
var fs33 = require_fs();
|
|
1175397
|
-
var
|
|
1175397
|
+
var mkdir38 = require_mkdirs();
|
|
1175398
1175398
|
var { pathExists: pathExists2 } = require_path_exists();
|
|
1175399
1175399
|
var { areIdentical } = require_stat();
|
|
1175400
1175400
|
async function createLink(srcpath, dstpath) {
|
|
@@ -1175414,7 +1175414,7 @@ var require_link = __commonJS({
|
|
|
1175414
1175414
|
const dir = path86.dirname(dstpath);
|
|
1175415
1175415
|
const dirExists = await pathExists2(dir);
|
|
1175416
1175416
|
if (!dirExists) {
|
|
1175417
|
-
await
|
|
1175417
|
+
await mkdir38.mkdirs(dir);
|
|
1175418
1175418
|
}
|
|
1175419
1175419
|
await fs33.link(srcpath, dstpath);
|
|
1175420
1175420
|
}
|
|
@@ -1175434,7 +1175434,7 @@ var require_link = __commonJS({
|
|
|
1175434
1175434
|
const dir = path86.dirname(dstpath);
|
|
1175435
1175435
|
const dirExists = fs33.existsSync(dir);
|
|
1175436
1175436
|
if (dirExists) return fs33.linkSync(srcpath, dstpath);
|
|
1175437
|
-
|
|
1175437
|
+
mkdir38.mkdirsSync(dir);
|
|
1175438
1175438
|
return fs33.linkSync(srcpath, dstpath);
|
|
1175439
1175439
|
}
|
|
1175440
1175440
|
module4.exports = {
|
|
@@ -1175688,7 +1175688,7 @@ var require_jsonfile = __commonJS({
|
|
|
1175688
1175688
|
}
|
|
1175689
1175689
|
return obj;
|
|
1175690
1175690
|
}
|
|
1175691
|
-
var
|
|
1175691
|
+
var readFile89 = universalify.fromPromise(_readFile);
|
|
1175692
1175692
|
function readFileSync12(file4, options2 = {}) {
|
|
1175693
1175693
|
if (typeof options2 === "string") {
|
|
1175694
1175694
|
options2 = { encoding: options2 };
|
|
@@ -1175713,16 +1175713,16 @@ var require_jsonfile = __commonJS({
|
|
|
1175713
1175713
|
const str3 = stringify5(obj, options2);
|
|
1175714
1175714
|
await universalify.fromCallback(fs33.writeFile)(file4, str3, options2);
|
|
1175715
1175715
|
}
|
|
1175716
|
-
var
|
|
1175716
|
+
var writeFile79 = universalify.fromPromise(_writeFile);
|
|
1175717
1175717
|
function writeFileSync5(file4, obj, options2 = {}) {
|
|
1175718
1175718
|
const fs33 = options2.fs || _fs;
|
|
1175719
1175719
|
const str3 = stringify5(obj, options2);
|
|
1175720
1175720
|
return fs33.writeFileSync(file4, str3, options2);
|
|
1175721
1175721
|
}
|
|
1175722
1175722
|
module4.exports = {
|
|
1175723
|
-
readFile:
|
|
1175723
|
+
readFile: readFile89,
|
|
1175724
1175724
|
readFileSync: readFileSync12,
|
|
1175725
|
-
writeFile:
|
|
1175725
|
+
writeFile: writeFile79,
|
|
1175726
1175726
|
writeFileSync: writeFileSync5
|
|
1175727
1175727
|
};
|
|
1175728
1175728
|
}
|
|
@@ -1175750,19 +1175750,19 @@ var require_output_file = __commonJS({
|
|
|
1175750
1175750
|
var u7 = require_universalify().fromPromise;
|
|
1175751
1175751
|
var fs33 = require_fs();
|
|
1175752
1175752
|
var path86 = require("path");
|
|
1175753
|
-
var
|
|
1175753
|
+
var mkdir38 = require_mkdirs();
|
|
1175754
1175754
|
var pathExists2 = require_path_exists().pathExists;
|
|
1175755
1175755
|
async function outputFile(file4, data2, encoding = "utf-8") {
|
|
1175756
1175756
|
const dir = path86.dirname(file4);
|
|
1175757
1175757
|
if (!await pathExists2(dir)) {
|
|
1175758
|
-
await
|
|
1175758
|
+
await mkdir38.mkdirs(dir);
|
|
1175759
1175759
|
}
|
|
1175760
1175760
|
return fs33.writeFile(file4, data2, encoding);
|
|
1175761
1175761
|
}
|
|
1175762
1175762
|
function outputFileSync(file4, ...args) {
|
|
1175763
1175763
|
const dir = path86.dirname(file4);
|
|
1175764
1175764
|
if (!fs33.existsSync(dir)) {
|
|
1175765
|
-
|
|
1175765
|
+
mkdir38.mkdirsSync(dir);
|
|
1175766
1175766
|
}
|
|
1175767
1175767
|
fs33.writeFileSync(file4, ...args);
|
|
1175768
1175768
|
}
|
|
@@ -1228249,7 +1228249,7 @@ var init_Browser2 = __esm({
|
|
|
1228249
1228249
|
let _createUserContext_decorators;
|
|
1228250
1228250
|
let _installExtension_decorators;
|
|
1228251
1228251
|
let _uninstallExtension_decorators;
|
|
1228252
|
-
return class
|
|
1228252
|
+
return class Browser5 extends _classSuper {
|
|
1228253
1228253
|
static {
|
|
1228254
1228254
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
1228255
1228255
|
__esDecorate19(this, null, _dispose_decorators, { kind: "method", name: "dispose", static: false, private: false, access: { has: (obj) => "dispose" in obj, get: (obj) => obj.dispose }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -1228263,7 +1228263,7 @@ var init_Browser2 = __esm({
|
|
|
1228263
1228263
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1228264
1228264
|
}
|
|
1228265
1228265
|
static async from(session) {
|
|
1228266
|
-
const browser = new
|
|
1228266
|
+
const browser = new Browser5(session);
|
|
1228267
1228267
|
await browser.#initialize();
|
|
1228268
1228268
|
return browser;
|
|
1228269
1228269
|
}
|
|
@@ -1283185,6 +1283185,2094 @@ var require_cjs4 = __commonJS({
|
|
|
1283185
1283185
|
}
|
|
1283186
1283186
|
});
|
|
1283187
1283187
|
|
|
1283188
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/chunkstream.js
|
|
1283189
|
+
var require_chunkstream = __commonJS({
|
|
1283190
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/chunkstream.js"(exports2, module4) {
|
|
1283191
|
+
"use strict";
|
|
1283192
|
+
var util4 = require("util");
|
|
1283193
|
+
var Stream5 = require("stream");
|
|
1283194
|
+
var ChunkStream = module4.exports = function() {
|
|
1283195
|
+
Stream5.call(this);
|
|
1283196
|
+
this._buffers = [];
|
|
1283197
|
+
this._buffered = 0;
|
|
1283198
|
+
this._reads = [];
|
|
1283199
|
+
this._paused = false;
|
|
1283200
|
+
this._encoding = "utf8";
|
|
1283201
|
+
this.writable = true;
|
|
1283202
|
+
};
|
|
1283203
|
+
util4.inherits(ChunkStream, Stream5);
|
|
1283204
|
+
ChunkStream.prototype.read = function(length, callback) {
|
|
1283205
|
+
this._reads.push({
|
|
1283206
|
+
length: Math.abs(length),
|
|
1283207
|
+
// if length < 0 then at most this length
|
|
1283208
|
+
allowLess: length < 0,
|
|
1283209
|
+
func: callback
|
|
1283210
|
+
});
|
|
1283211
|
+
process.nextTick(
|
|
1283212
|
+
function() {
|
|
1283213
|
+
this._process();
|
|
1283214
|
+
if (this._paused && this._reads && this._reads.length > 0) {
|
|
1283215
|
+
this._paused = false;
|
|
1283216
|
+
this.emit("drain");
|
|
1283217
|
+
}
|
|
1283218
|
+
}.bind(this)
|
|
1283219
|
+
);
|
|
1283220
|
+
};
|
|
1283221
|
+
ChunkStream.prototype.write = function(data2, encoding) {
|
|
1283222
|
+
if (!this.writable) {
|
|
1283223
|
+
this.emit("error", new Error("Stream not writable"));
|
|
1283224
|
+
return false;
|
|
1283225
|
+
}
|
|
1283226
|
+
let dataBuffer;
|
|
1283227
|
+
if (Buffer.isBuffer(data2)) {
|
|
1283228
|
+
dataBuffer = data2;
|
|
1283229
|
+
} else {
|
|
1283230
|
+
dataBuffer = Buffer.from(data2, encoding || this._encoding);
|
|
1283231
|
+
}
|
|
1283232
|
+
this._buffers.push(dataBuffer);
|
|
1283233
|
+
this._buffered += dataBuffer.length;
|
|
1283234
|
+
this._process();
|
|
1283235
|
+
if (this._reads && this._reads.length === 0) {
|
|
1283236
|
+
this._paused = true;
|
|
1283237
|
+
}
|
|
1283238
|
+
return this.writable && !this._paused;
|
|
1283239
|
+
};
|
|
1283240
|
+
ChunkStream.prototype.end = function(data2, encoding) {
|
|
1283241
|
+
if (data2) {
|
|
1283242
|
+
this.write(data2, encoding);
|
|
1283243
|
+
}
|
|
1283244
|
+
this.writable = false;
|
|
1283245
|
+
if (!this._buffers) {
|
|
1283246
|
+
return;
|
|
1283247
|
+
}
|
|
1283248
|
+
if (this._buffers.length === 0) {
|
|
1283249
|
+
this._end();
|
|
1283250
|
+
} else {
|
|
1283251
|
+
this._buffers.push(null);
|
|
1283252
|
+
this._process();
|
|
1283253
|
+
}
|
|
1283254
|
+
};
|
|
1283255
|
+
ChunkStream.prototype.destroySoon = ChunkStream.prototype.end;
|
|
1283256
|
+
ChunkStream.prototype._end = function() {
|
|
1283257
|
+
if (this._reads.length > 0) {
|
|
1283258
|
+
this.emit("error", new Error("Unexpected end of input"));
|
|
1283259
|
+
}
|
|
1283260
|
+
this.destroy();
|
|
1283261
|
+
};
|
|
1283262
|
+
ChunkStream.prototype.destroy = function() {
|
|
1283263
|
+
if (!this._buffers) {
|
|
1283264
|
+
return;
|
|
1283265
|
+
}
|
|
1283266
|
+
this.writable = false;
|
|
1283267
|
+
this._reads = null;
|
|
1283268
|
+
this._buffers = null;
|
|
1283269
|
+
this.emit("close");
|
|
1283270
|
+
};
|
|
1283271
|
+
ChunkStream.prototype._processReadAllowingLess = function(read2) {
|
|
1283272
|
+
this._reads.shift();
|
|
1283273
|
+
let smallerBuf = this._buffers[0];
|
|
1283274
|
+
if (smallerBuf.length > read2.length) {
|
|
1283275
|
+
this._buffered -= read2.length;
|
|
1283276
|
+
this._buffers[0] = smallerBuf.slice(read2.length);
|
|
1283277
|
+
read2.func.call(this, smallerBuf.slice(0, read2.length));
|
|
1283278
|
+
} else {
|
|
1283279
|
+
this._buffered -= smallerBuf.length;
|
|
1283280
|
+
this._buffers.shift();
|
|
1283281
|
+
read2.func.call(this, smallerBuf);
|
|
1283282
|
+
}
|
|
1283283
|
+
};
|
|
1283284
|
+
ChunkStream.prototype._processRead = function(read2) {
|
|
1283285
|
+
this._reads.shift();
|
|
1283286
|
+
let pos2 = 0;
|
|
1283287
|
+
let count = 0;
|
|
1283288
|
+
let data2 = Buffer.alloc(read2.length);
|
|
1283289
|
+
while (pos2 < read2.length) {
|
|
1283290
|
+
let buf = this._buffers[count++];
|
|
1283291
|
+
let len = Math.min(buf.length, read2.length - pos2);
|
|
1283292
|
+
buf.copy(data2, pos2, 0, len);
|
|
1283293
|
+
pos2 += len;
|
|
1283294
|
+
if (len !== buf.length) {
|
|
1283295
|
+
this._buffers[--count] = buf.slice(len);
|
|
1283296
|
+
}
|
|
1283297
|
+
}
|
|
1283298
|
+
if (count > 0) {
|
|
1283299
|
+
this._buffers.splice(0, count);
|
|
1283300
|
+
}
|
|
1283301
|
+
this._buffered -= read2.length;
|
|
1283302
|
+
read2.func.call(this, data2);
|
|
1283303
|
+
};
|
|
1283304
|
+
ChunkStream.prototype._process = function() {
|
|
1283305
|
+
try {
|
|
1283306
|
+
while (this._buffered > 0 && this._reads && this._reads.length > 0) {
|
|
1283307
|
+
let read2 = this._reads[0];
|
|
1283308
|
+
if (read2.allowLess) {
|
|
1283309
|
+
this._processReadAllowingLess(read2);
|
|
1283310
|
+
} else if (this._buffered >= read2.length) {
|
|
1283311
|
+
this._processRead(read2);
|
|
1283312
|
+
} else {
|
|
1283313
|
+
break;
|
|
1283314
|
+
}
|
|
1283315
|
+
}
|
|
1283316
|
+
if (this._buffers && !this.writable) {
|
|
1283317
|
+
this._end();
|
|
1283318
|
+
}
|
|
1283319
|
+
} catch (ex) {
|
|
1283320
|
+
this.emit("error", ex);
|
|
1283321
|
+
}
|
|
1283322
|
+
};
|
|
1283323
|
+
}
|
|
1283324
|
+
});
|
|
1283325
|
+
|
|
1283326
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/interlace.js
|
|
1283327
|
+
var require_interlace = __commonJS({
|
|
1283328
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/interlace.js"(exports2) {
|
|
1283329
|
+
"use strict";
|
|
1283330
|
+
var imagePasses = [
|
|
1283331
|
+
{
|
|
1283332
|
+
// pass 1 - 1px
|
|
1283333
|
+
x: [0],
|
|
1283334
|
+
y: [0]
|
|
1283335
|
+
},
|
|
1283336
|
+
{
|
|
1283337
|
+
// pass 2 - 1px
|
|
1283338
|
+
x: [4],
|
|
1283339
|
+
y: [0]
|
|
1283340
|
+
},
|
|
1283341
|
+
{
|
|
1283342
|
+
// pass 3 - 2px
|
|
1283343
|
+
x: [0, 4],
|
|
1283344
|
+
y: [4]
|
|
1283345
|
+
},
|
|
1283346
|
+
{
|
|
1283347
|
+
// pass 4 - 4px
|
|
1283348
|
+
x: [2, 6],
|
|
1283349
|
+
y: [0, 4]
|
|
1283350
|
+
},
|
|
1283351
|
+
{
|
|
1283352
|
+
// pass 5 - 8px
|
|
1283353
|
+
x: [0, 2, 4, 6],
|
|
1283354
|
+
y: [2, 6]
|
|
1283355
|
+
},
|
|
1283356
|
+
{
|
|
1283357
|
+
// pass 6 - 16px
|
|
1283358
|
+
x: [1, 3, 5, 7],
|
|
1283359
|
+
y: [0, 2, 4, 6]
|
|
1283360
|
+
},
|
|
1283361
|
+
{
|
|
1283362
|
+
// pass 7 - 32px
|
|
1283363
|
+
x: [0, 1, 2, 3, 4, 5, 6, 7],
|
|
1283364
|
+
y: [1, 3, 5, 7]
|
|
1283365
|
+
}
|
|
1283366
|
+
];
|
|
1283367
|
+
exports2.getImagePasses = function(width, height3) {
|
|
1283368
|
+
let images = [];
|
|
1283369
|
+
let xLeftOver = width % 8;
|
|
1283370
|
+
let yLeftOver = height3 % 8;
|
|
1283371
|
+
let xRepeats = (width - xLeftOver) / 8;
|
|
1283372
|
+
let yRepeats = (height3 - yLeftOver) / 8;
|
|
1283373
|
+
for (let i11 = 0; i11 < imagePasses.length; i11++) {
|
|
1283374
|
+
let pass = imagePasses[i11];
|
|
1283375
|
+
let passWidth = xRepeats * pass.x.length;
|
|
1283376
|
+
let passHeight = yRepeats * pass.y.length;
|
|
1283377
|
+
for (let j15 = 0; j15 < pass.x.length; j15++) {
|
|
1283378
|
+
if (pass.x[j15] < xLeftOver) {
|
|
1283379
|
+
passWidth++;
|
|
1283380
|
+
} else {
|
|
1283381
|
+
break;
|
|
1283382
|
+
}
|
|
1283383
|
+
}
|
|
1283384
|
+
for (let j15 = 0; j15 < pass.y.length; j15++) {
|
|
1283385
|
+
if (pass.y[j15] < yLeftOver) {
|
|
1283386
|
+
passHeight++;
|
|
1283387
|
+
} else {
|
|
1283388
|
+
break;
|
|
1283389
|
+
}
|
|
1283390
|
+
}
|
|
1283391
|
+
if (passWidth > 0 && passHeight > 0) {
|
|
1283392
|
+
images.push({ width: passWidth, height: passHeight, index: i11 });
|
|
1283393
|
+
}
|
|
1283394
|
+
}
|
|
1283395
|
+
return images;
|
|
1283396
|
+
};
|
|
1283397
|
+
exports2.getInterlaceIterator = function(width) {
|
|
1283398
|
+
return function(x15, y23, pass) {
|
|
1283399
|
+
let outerXLeftOver = x15 % imagePasses[pass].x.length;
|
|
1283400
|
+
let outerX = (x15 - outerXLeftOver) / imagePasses[pass].x.length * 8 + imagePasses[pass].x[outerXLeftOver];
|
|
1283401
|
+
let outerYLeftOver = y23 % imagePasses[pass].y.length;
|
|
1283402
|
+
let outerY = (y23 - outerYLeftOver) / imagePasses[pass].y.length * 8 + imagePasses[pass].y[outerYLeftOver];
|
|
1283403
|
+
return outerX * 4 + outerY * width * 4;
|
|
1283404
|
+
};
|
|
1283405
|
+
};
|
|
1283406
|
+
}
|
|
1283407
|
+
});
|
|
1283408
|
+
|
|
1283409
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/paeth-predictor.js
|
|
1283410
|
+
var require_paeth_predictor = __commonJS({
|
|
1283411
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/paeth-predictor.js"(exports2, module4) {
|
|
1283412
|
+
"use strict";
|
|
1283413
|
+
module4.exports = function paethPredictor(left3, above, upLeft) {
|
|
1283414
|
+
let paeth = left3 + above - upLeft;
|
|
1283415
|
+
let pLeft = Math.abs(paeth - left3);
|
|
1283416
|
+
let pAbove = Math.abs(paeth - above);
|
|
1283417
|
+
let pUpLeft = Math.abs(paeth - upLeft);
|
|
1283418
|
+
if (pLeft <= pAbove && pLeft <= pUpLeft) {
|
|
1283419
|
+
return left3;
|
|
1283420
|
+
}
|
|
1283421
|
+
if (pAbove <= pUpLeft) {
|
|
1283422
|
+
return above;
|
|
1283423
|
+
}
|
|
1283424
|
+
return upLeft;
|
|
1283425
|
+
};
|
|
1283426
|
+
}
|
|
1283427
|
+
});
|
|
1283428
|
+
|
|
1283429
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse.js
|
|
1283430
|
+
var require_filter_parse = __commonJS({
|
|
1283431
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse.js"(exports2, module4) {
|
|
1283432
|
+
"use strict";
|
|
1283433
|
+
var interlaceUtils = require_interlace();
|
|
1283434
|
+
var paethPredictor = require_paeth_predictor();
|
|
1283435
|
+
function getByteWidth(width, bpp, depth) {
|
|
1283436
|
+
let byteWidth = width * bpp;
|
|
1283437
|
+
if (depth !== 8) {
|
|
1283438
|
+
byteWidth = Math.ceil(byteWidth / (8 / depth));
|
|
1283439
|
+
}
|
|
1283440
|
+
return byteWidth;
|
|
1283441
|
+
}
|
|
1283442
|
+
var Filter = module4.exports = function(bitmapInfo, dependencies) {
|
|
1283443
|
+
let width = bitmapInfo.width;
|
|
1283444
|
+
let height3 = bitmapInfo.height;
|
|
1283445
|
+
let interlace = bitmapInfo.interlace;
|
|
1283446
|
+
let bpp = bitmapInfo.bpp;
|
|
1283447
|
+
let depth = bitmapInfo.depth;
|
|
1283448
|
+
this.read = dependencies.read;
|
|
1283449
|
+
this.write = dependencies.write;
|
|
1283450
|
+
this.complete = dependencies.complete;
|
|
1283451
|
+
this._imageIndex = 0;
|
|
1283452
|
+
this._images = [];
|
|
1283453
|
+
if (interlace) {
|
|
1283454
|
+
let passes = interlaceUtils.getImagePasses(width, height3);
|
|
1283455
|
+
for (let i11 = 0; i11 < passes.length; i11++) {
|
|
1283456
|
+
this._images.push({
|
|
1283457
|
+
byteWidth: getByteWidth(passes[i11].width, bpp, depth),
|
|
1283458
|
+
height: passes[i11].height,
|
|
1283459
|
+
lineIndex: 0
|
|
1283460
|
+
});
|
|
1283461
|
+
}
|
|
1283462
|
+
} else {
|
|
1283463
|
+
this._images.push({
|
|
1283464
|
+
byteWidth: getByteWidth(width, bpp, depth),
|
|
1283465
|
+
height: height3,
|
|
1283466
|
+
lineIndex: 0
|
|
1283467
|
+
});
|
|
1283468
|
+
}
|
|
1283469
|
+
if (depth === 8) {
|
|
1283470
|
+
this._xComparison = bpp;
|
|
1283471
|
+
} else if (depth === 16) {
|
|
1283472
|
+
this._xComparison = bpp * 2;
|
|
1283473
|
+
} else {
|
|
1283474
|
+
this._xComparison = 1;
|
|
1283475
|
+
}
|
|
1283476
|
+
};
|
|
1283477
|
+
Filter.prototype.start = function() {
|
|
1283478
|
+
this.read(
|
|
1283479
|
+
this._images[this._imageIndex].byteWidth + 1,
|
|
1283480
|
+
this._reverseFilterLine.bind(this)
|
|
1283481
|
+
);
|
|
1283482
|
+
};
|
|
1283483
|
+
Filter.prototype._unFilterType1 = function(rawData, unfilteredLine, byteWidth) {
|
|
1283484
|
+
let xComparison = this._xComparison;
|
|
1283485
|
+
let xBiggerThan = xComparison - 1;
|
|
1283486
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1283487
|
+
let rawByte = rawData[1 + x15];
|
|
1283488
|
+
let f1Left = x15 > xBiggerThan ? unfilteredLine[x15 - xComparison] : 0;
|
|
1283489
|
+
unfilteredLine[x15] = rawByte + f1Left;
|
|
1283490
|
+
}
|
|
1283491
|
+
};
|
|
1283492
|
+
Filter.prototype._unFilterType2 = function(rawData, unfilteredLine, byteWidth) {
|
|
1283493
|
+
let lastLine3 = this._lastLine;
|
|
1283494
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1283495
|
+
let rawByte = rawData[1 + x15];
|
|
1283496
|
+
let f2Up = lastLine3 ? lastLine3[x15] : 0;
|
|
1283497
|
+
unfilteredLine[x15] = rawByte + f2Up;
|
|
1283498
|
+
}
|
|
1283499
|
+
};
|
|
1283500
|
+
Filter.prototype._unFilterType3 = function(rawData, unfilteredLine, byteWidth) {
|
|
1283501
|
+
let xComparison = this._xComparison;
|
|
1283502
|
+
let xBiggerThan = xComparison - 1;
|
|
1283503
|
+
let lastLine3 = this._lastLine;
|
|
1283504
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1283505
|
+
let rawByte = rawData[1 + x15];
|
|
1283506
|
+
let f3Up = lastLine3 ? lastLine3[x15] : 0;
|
|
1283507
|
+
let f3Left = x15 > xBiggerThan ? unfilteredLine[x15 - xComparison] : 0;
|
|
1283508
|
+
let f3Add = Math.floor((f3Left + f3Up) / 2);
|
|
1283509
|
+
unfilteredLine[x15] = rawByte + f3Add;
|
|
1283510
|
+
}
|
|
1283511
|
+
};
|
|
1283512
|
+
Filter.prototype._unFilterType4 = function(rawData, unfilteredLine, byteWidth) {
|
|
1283513
|
+
let xComparison = this._xComparison;
|
|
1283514
|
+
let xBiggerThan = xComparison - 1;
|
|
1283515
|
+
let lastLine3 = this._lastLine;
|
|
1283516
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1283517
|
+
let rawByte = rawData[1 + x15];
|
|
1283518
|
+
let f4Up = lastLine3 ? lastLine3[x15] : 0;
|
|
1283519
|
+
let f4Left = x15 > xBiggerThan ? unfilteredLine[x15 - xComparison] : 0;
|
|
1283520
|
+
let f4UpLeft = x15 > xBiggerThan && lastLine3 ? lastLine3[x15 - xComparison] : 0;
|
|
1283521
|
+
let f4Add = paethPredictor(f4Left, f4Up, f4UpLeft);
|
|
1283522
|
+
unfilteredLine[x15] = rawByte + f4Add;
|
|
1283523
|
+
}
|
|
1283524
|
+
};
|
|
1283525
|
+
Filter.prototype._reverseFilterLine = function(rawData) {
|
|
1283526
|
+
let filter7 = rawData[0];
|
|
1283527
|
+
let unfilteredLine;
|
|
1283528
|
+
let currentImage = this._images[this._imageIndex];
|
|
1283529
|
+
let byteWidth = currentImage.byteWidth;
|
|
1283530
|
+
if (filter7 === 0) {
|
|
1283531
|
+
unfilteredLine = rawData.slice(1, byteWidth + 1);
|
|
1283532
|
+
} else {
|
|
1283533
|
+
unfilteredLine = Buffer.alloc(byteWidth);
|
|
1283534
|
+
switch (filter7) {
|
|
1283535
|
+
case 1:
|
|
1283536
|
+
this._unFilterType1(rawData, unfilteredLine, byteWidth);
|
|
1283537
|
+
break;
|
|
1283538
|
+
case 2:
|
|
1283539
|
+
this._unFilterType2(rawData, unfilteredLine, byteWidth);
|
|
1283540
|
+
break;
|
|
1283541
|
+
case 3:
|
|
1283542
|
+
this._unFilterType3(rawData, unfilteredLine, byteWidth);
|
|
1283543
|
+
break;
|
|
1283544
|
+
case 4:
|
|
1283545
|
+
this._unFilterType4(rawData, unfilteredLine, byteWidth);
|
|
1283546
|
+
break;
|
|
1283547
|
+
default:
|
|
1283548
|
+
throw new Error("Unrecognised filter type - " + filter7);
|
|
1283549
|
+
}
|
|
1283550
|
+
}
|
|
1283551
|
+
this.write(unfilteredLine);
|
|
1283552
|
+
currentImage.lineIndex++;
|
|
1283553
|
+
if (currentImage.lineIndex >= currentImage.height) {
|
|
1283554
|
+
this._lastLine = null;
|
|
1283555
|
+
this._imageIndex++;
|
|
1283556
|
+
currentImage = this._images[this._imageIndex];
|
|
1283557
|
+
} else {
|
|
1283558
|
+
this._lastLine = unfilteredLine;
|
|
1283559
|
+
}
|
|
1283560
|
+
if (currentImage) {
|
|
1283561
|
+
this.read(currentImage.byteWidth + 1, this._reverseFilterLine.bind(this));
|
|
1283562
|
+
} else {
|
|
1283563
|
+
this._lastLine = null;
|
|
1283564
|
+
this.complete();
|
|
1283565
|
+
}
|
|
1283566
|
+
};
|
|
1283567
|
+
}
|
|
1283568
|
+
});
|
|
1283569
|
+
|
|
1283570
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-async.js
|
|
1283571
|
+
var require_filter_parse_async = __commonJS({
|
|
1283572
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-async.js"(exports2, module4) {
|
|
1283573
|
+
"use strict";
|
|
1283574
|
+
var util4 = require("util");
|
|
1283575
|
+
var ChunkStream = require_chunkstream();
|
|
1283576
|
+
var Filter = require_filter_parse();
|
|
1283577
|
+
var FilterAsync = module4.exports = function(bitmapInfo) {
|
|
1283578
|
+
ChunkStream.call(this);
|
|
1283579
|
+
let buffers = [];
|
|
1283580
|
+
let that = this;
|
|
1283581
|
+
this._filter = new Filter(bitmapInfo, {
|
|
1283582
|
+
read: this.read.bind(this),
|
|
1283583
|
+
write: function(buffer) {
|
|
1283584
|
+
buffers.push(buffer);
|
|
1283585
|
+
},
|
|
1283586
|
+
complete: function() {
|
|
1283587
|
+
that.emit("complete", Buffer.concat(buffers));
|
|
1283588
|
+
}
|
|
1283589
|
+
});
|
|
1283590
|
+
this._filter.start();
|
|
1283591
|
+
};
|
|
1283592
|
+
util4.inherits(FilterAsync, ChunkStream);
|
|
1283593
|
+
}
|
|
1283594
|
+
});
|
|
1283595
|
+
|
|
1283596
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js
|
|
1283597
|
+
var require_constants109 = __commonJS({
|
|
1283598
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/constants.js"(exports2, module4) {
|
|
1283599
|
+
"use strict";
|
|
1283600
|
+
module4.exports = {
|
|
1283601
|
+
PNG_SIGNATURE: [137, 80, 78, 71, 13, 10, 26, 10],
|
|
1283602
|
+
TYPE_IHDR: 1229472850,
|
|
1283603
|
+
TYPE_IEND: 1229278788,
|
|
1283604
|
+
TYPE_IDAT: 1229209940,
|
|
1283605
|
+
TYPE_PLTE: 1347179589,
|
|
1283606
|
+
TYPE_tRNS: 1951551059,
|
|
1283607
|
+
// eslint-disable-line camelcase
|
|
1283608
|
+
TYPE_gAMA: 1732332865,
|
|
1283609
|
+
// eslint-disable-line camelcase
|
|
1283610
|
+
// color-type bits
|
|
1283611
|
+
COLORTYPE_GRAYSCALE: 0,
|
|
1283612
|
+
COLORTYPE_PALETTE: 1,
|
|
1283613
|
+
COLORTYPE_COLOR: 2,
|
|
1283614
|
+
COLORTYPE_ALPHA: 4,
|
|
1283615
|
+
// e.g. grayscale and alpha
|
|
1283616
|
+
// color-type combinations
|
|
1283617
|
+
COLORTYPE_PALETTE_COLOR: 3,
|
|
1283618
|
+
COLORTYPE_COLOR_ALPHA: 6,
|
|
1283619
|
+
COLORTYPE_TO_BPP_MAP: {
|
|
1283620
|
+
0: 1,
|
|
1283621
|
+
2: 3,
|
|
1283622
|
+
3: 1,
|
|
1283623
|
+
4: 2,
|
|
1283624
|
+
6: 4
|
|
1283625
|
+
},
|
|
1283626
|
+
GAMMA_DIVISION: 1e5
|
|
1283627
|
+
};
|
|
1283628
|
+
}
|
|
1283629
|
+
});
|
|
1283630
|
+
|
|
1283631
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/crc.js
|
|
1283632
|
+
var require_crc = __commonJS({
|
|
1283633
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/crc.js"(exports2, module4) {
|
|
1283634
|
+
"use strict";
|
|
1283635
|
+
var crcTable = [];
|
|
1283636
|
+
(function() {
|
|
1283637
|
+
for (let i11 = 0; i11 < 256; i11++) {
|
|
1283638
|
+
let currentCrc = i11;
|
|
1283639
|
+
for (let j15 = 0; j15 < 8; j15++) {
|
|
1283640
|
+
if (currentCrc & 1) {
|
|
1283641
|
+
currentCrc = 3988292384 ^ currentCrc >>> 1;
|
|
1283642
|
+
} else {
|
|
1283643
|
+
currentCrc = currentCrc >>> 1;
|
|
1283644
|
+
}
|
|
1283645
|
+
}
|
|
1283646
|
+
crcTable[i11] = currentCrc;
|
|
1283647
|
+
}
|
|
1283648
|
+
})();
|
|
1283649
|
+
var CrcCalculator = module4.exports = function() {
|
|
1283650
|
+
this._crc = -1;
|
|
1283651
|
+
};
|
|
1283652
|
+
CrcCalculator.prototype.write = function(data2) {
|
|
1283653
|
+
for (let i11 = 0; i11 < data2.length; i11++) {
|
|
1283654
|
+
this._crc = crcTable[(this._crc ^ data2[i11]) & 255] ^ this._crc >>> 8;
|
|
1283655
|
+
}
|
|
1283656
|
+
return true;
|
|
1283657
|
+
};
|
|
1283658
|
+
CrcCalculator.prototype.crc32 = function() {
|
|
1283659
|
+
return this._crc ^ -1;
|
|
1283660
|
+
};
|
|
1283661
|
+
CrcCalculator.crc32 = function(buf) {
|
|
1283662
|
+
let crc = -1;
|
|
1283663
|
+
for (let i11 = 0; i11 < buf.length; i11++) {
|
|
1283664
|
+
crc = crcTable[(crc ^ buf[i11]) & 255] ^ crc >>> 8;
|
|
1283665
|
+
}
|
|
1283666
|
+
return crc ^ -1;
|
|
1283667
|
+
};
|
|
1283668
|
+
}
|
|
1283669
|
+
});
|
|
1283670
|
+
|
|
1283671
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser.js
|
|
1283672
|
+
var require_parser4 = __commonJS({
|
|
1283673
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser.js"(exports2, module4) {
|
|
1283674
|
+
"use strict";
|
|
1283675
|
+
var constants2 = require_constants109();
|
|
1283676
|
+
var CrcCalculator = require_crc();
|
|
1283677
|
+
var Parser8 = module4.exports = function(options2, dependencies) {
|
|
1283678
|
+
this._options = options2;
|
|
1283679
|
+
options2.checkCRC = options2.checkCRC !== false;
|
|
1283680
|
+
this._hasIHDR = false;
|
|
1283681
|
+
this._hasIEND = false;
|
|
1283682
|
+
this._emittedHeadersFinished = false;
|
|
1283683
|
+
this._palette = [];
|
|
1283684
|
+
this._colorType = 0;
|
|
1283685
|
+
this._chunks = {};
|
|
1283686
|
+
this._chunks[constants2.TYPE_IHDR] = this._handleIHDR.bind(this);
|
|
1283687
|
+
this._chunks[constants2.TYPE_IEND] = this._handleIEND.bind(this);
|
|
1283688
|
+
this._chunks[constants2.TYPE_IDAT] = this._handleIDAT.bind(this);
|
|
1283689
|
+
this._chunks[constants2.TYPE_PLTE] = this._handlePLTE.bind(this);
|
|
1283690
|
+
this._chunks[constants2.TYPE_tRNS] = this._handleTRNS.bind(this);
|
|
1283691
|
+
this._chunks[constants2.TYPE_gAMA] = this._handleGAMA.bind(this);
|
|
1283692
|
+
this.read = dependencies.read;
|
|
1283693
|
+
this.error = dependencies.error;
|
|
1283694
|
+
this.metadata = dependencies.metadata;
|
|
1283695
|
+
this.gamma = dependencies.gamma;
|
|
1283696
|
+
this.transColor = dependencies.transColor;
|
|
1283697
|
+
this.palette = dependencies.palette;
|
|
1283698
|
+
this.parsed = dependencies.parsed;
|
|
1283699
|
+
this.inflateData = dependencies.inflateData;
|
|
1283700
|
+
this.finished = dependencies.finished;
|
|
1283701
|
+
this.simpleTransparency = dependencies.simpleTransparency;
|
|
1283702
|
+
this.headersFinished = dependencies.headersFinished || function() {
|
|
1283703
|
+
};
|
|
1283704
|
+
};
|
|
1283705
|
+
Parser8.prototype.start = function() {
|
|
1283706
|
+
this.read(constants2.PNG_SIGNATURE.length, this._parseSignature.bind(this));
|
|
1283707
|
+
};
|
|
1283708
|
+
Parser8.prototype._parseSignature = function(data2) {
|
|
1283709
|
+
let signature = constants2.PNG_SIGNATURE;
|
|
1283710
|
+
for (let i11 = 0; i11 < signature.length; i11++) {
|
|
1283711
|
+
if (data2[i11] !== signature[i11]) {
|
|
1283712
|
+
this.error(new Error("Invalid file signature"));
|
|
1283713
|
+
return;
|
|
1283714
|
+
}
|
|
1283715
|
+
}
|
|
1283716
|
+
this.read(8, this._parseChunkBegin.bind(this));
|
|
1283717
|
+
};
|
|
1283718
|
+
Parser8.prototype._parseChunkBegin = function(data2) {
|
|
1283719
|
+
let length = data2.readUInt32BE(0);
|
|
1283720
|
+
let type8 = data2.readUInt32BE(4);
|
|
1283721
|
+
let name3 = "";
|
|
1283722
|
+
for (let i11 = 4; i11 < 8; i11++) {
|
|
1283723
|
+
name3 += String.fromCharCode(data2[i11]);
|
|
1283724
|
+
}
|
|
1283725
|
+
let ancillary = Boolean(data2[4] & 32);
|
|
1283726
|
+
if (!this._hasIHDR && type8 !== constants2.TYPE_IHDR) {
|
|
1283727
|
+
this.error(new Error("Expected IHDR on beggining"));
|
|
1283728
|
+
return;
|
|
1283729
|
+
}
|
|
1283730
|
+
this._crc = new CrcCalculator();
|
|
1283731
|
+
this._crc.write(Buffer.from(name3));
|
|
1283732
|
+
if (this._chunks[type8]) {
|
|
1283733
|
+
return this._chunks[type8](length);
|
|
1283734
|
+
}
|
|
1283735
|
+
if (!ancillary) {
|
|
1283736
|
+
this.error(new Error("Unsupported critical chunk type " + name3));
|
|
1283737
|
+
return;
|
|
1283738
|
+
}
|
|
1283739
|
+
this.read(length + 4, this._skipChunk.bind(this));
|
|
1283740
|
+
};
|
|
1283741
|
+
Parser8.prototype._skipChunk = function() {
|
|
1283742
|
+
this.read(8, this._parseChunkBegin.bind(this));
|
|
1283743
|
+
};
|
|
1283744
|
+
Parser8.prototype._handleChunkEnd = function() {
|
|
1283745
|
+
this.read(4, this._parseChunkEnd.bind(this));
|
|
1283746
|
+
};
|
|
1283747
|
+
Parser8.prototype._parseChunkEnd = function(data2) {
|
|
1283748
|
+
let fileCrc = data2.readInt32BE(0);
|
|
1283749
|
+
let calcCrc = this._crc.crc32();
|
|
1283750
|
+
if (this._options.checkCRC && calcCrc !== fileCrc) {
|
|
1283751
|
+
this.error(new Error("Crc error - " + fileCrc + " - " + calcCrc));
|
|
1283752
|
+
return;
|
|
1283753
|
+
}
|
|
1283754
|
+
if (!this._hasIEND) {
|
|
1283755
|
+
this.read(8, this._parseChunkBegin.bind(this));
|
|
1283756
|
+
}
|
|
1283757
|
+
};
|
|
1283758
|
+
Parser8.prototype._handleIHDR = function(length) {
|
|
1283759
|
+
this.read(length, this._parseIHDR.bind(this));
|
|
1283760
|
+
};
|
|
1283761
|
+
Parser8.prototype._parseIHDR = function(data2) {
|
|
1283762
|
+
this._crc.write(data2);
|
|
1283763
|
+
let width = data2.readUInt32BE(0);
|
|
1283764
|
+
let height3 = data2.readUInt32BE(4);
|
|
1283765
|
+
let depth = data2[8];
|
|
1283766
|
+
let colorType = data2[9];
|
|
1283767
|
+
let compr = data2[10];
|
|
1283768
|
+
let filter7 = data2[11];
|
|
1283769
|
+
let interlace = data2[12];
|
|
1283770
|
+
if (depth !== 8 && depth !== 4 && depth !== 2 && depth !== 1 && depth !== 16) {
|
|
1283771
|
+
this.error(new Error("Unsupported bit depth " + depth));
|
|
1283772
|
+
return;
|
|
1283773
|
+
}
|
|
1283774
|
+
if (!(colorType in constants2.COLORTYPE_TO_BPP_MAP)) {
|
|
1283775
|
+
this.error(new Error("Unsupported color type"));
|
|
1283776
|
+
return;
|
|
1283777
|
+
}
|
|
1283778
|
+
if (compr !== 0) {
|
|
1283779
|
+
this.error(new Error("Unsupported compression method"));
|
|
1283780
|
+
return;
|
|
1283781
|
+
}
|
|
1283782
|
+
if (filter7 !== 0) {
|
|
1283783
|
+
this.error(new Error("Unsupported filter method"));
|
|
1283784
|
+
return;
|
|
1283785
|
+
}
|
|
1283786
|
+
if (interlace !== 0 && interlace !== 1) {
|
|
1283787
|
+
this.error(new Error("Unsupported interlace method"));
|
|
1283788
|
+
return;
|
|
1283789
|
+
}
|
|
1283790
|
+
this._colorType = colorType;
|
|
1283791
|
+
let bpp = constants2.COLORTYPE_TO_BPP_MAP[this._colorType];
|
|
1283792
|
+
this._hasIHDR = true;
|
|
1283793
|
+
this.metadata({
|
|
1283794
|
+
width,
|
|
1283795
|
+
height: height3,
|
|
1283796
|
+
depth,
|
|
1283797
|
+
interlace: Boolean(interlace),
|
|
1283798
|
+
palette: Boolean(colorType & constants2.COLORTYPE_PALETTE),
|
|
1283799
|
+
color: Boolean(colorType & constants2.COLORTYPE_COLOR),
|
|
1283800
|
+
alpha: Boolean(colorType & constants2.COLORTYPE_ALPHA),
|
|
1283801
|
+
bpp,
|
|
1283802
|
+
colorType
|
|
1283803
|
+
});
|
|
1283804
|
+
this._handleChunkEnd();
|
|
1283805
|
+
};
|
|
1283806
|
+
Parser8.prototype._handlePLTE = function(length) {
|
|
1283807
|
+
this.read(length, this._parsePLTE.bind(this));
|
|
1283808
|
+
};
|
|
1283809
|
+
Parser8.prototype._parsePLTE = function(data2) {
|
|
1283810
|
+
this._crc.write(data2);
|
|
1283811
|
+
let entries10 = Math.floor(data2.length / 3);
|
|
1283812
|
+
for (let i11 = 0; i11 < entries10; i11++) {
|
|
1283813
|
+
this._palette.push([data2[i11 * 3], data2[i11 * 3 + 1], data2[i11 * 3 + 2], 255]);
|
|
1283814
|
+
}
|
|
1283815
|
+
this.palette(this._palette);
|
|
1283816
|
+
this._handleChunkEnd();
|
|
1283817
|
+
};
|
|
1283818
|
+
Parser8.prototype._handleTRNS = function(length) {
|
|
1283819
|
+
this.simpleTransparency();
|
|
1283820
|
+
this.read(length, this._parseTRNS.bind(this));
|
|
1283821
|
+
};
|
|
1283822
|
+
Parser8.prototype._parseTRNS = function(data2) {
|
|
1283823
|
+
this._crc.write(data2);
|
|
1283824
|
+
if (this._colorType === constants2.COLORTYPE_PALETTE_COLOR) {
|
|
1283825
|
+
if (this._palette.length === 0) {
|
|
1283826
|
+
this.error(new Error("Transparency chunk must be after palette"));
|
|
1283827
|
+
return;
|
|
1283828
|
+
}
|
|
1283829
|
+
if (data2.length > this._palette.length) {
|
|
1283830
|
+
this.error(new Error("More transparent colors than palette size"));
|
|
1283831
|
+
return;
|
|
1283832
|
+
}
|
|
1283833
|
+
for (let i11 = 0; i11 < data2.length; i11++) {
|
|
1283834
|
+
this._palette[i11][3] = data2[i11];
|
|
1283835
|
+
}
|
|
1283836
|
+
this.palette(this._palette);
|
|
1283837
|
+
}
|
|
1283838
|
+
if (this._colorType === constants2.COLORTYPE_GRAYSCALE) {
|
|
1283839
|
+
this.transColor([data2.readUInt16BE(0)]);
|
|
1283840
|
+
}
|
|
1283841
|
+
if (this._colorType === constants2.COLORTYPE_COLOR) {
|
|
1283842
|
+
this.transColor([
|
|
1283843
|
+
data2.readUInt16BE(0),
|
|
1283844
|
+
data2.readUInt16BE(2),
|
|
1283845
|
+
data2.readUInt16BE(4)
|
|
1283846
|
+
]);
|
|
1283847
|
+
}
|
|
1283848
|
+
this._handleChunkEnd();
|
|
1283849
|
+
};
|
|
1283850
|
+
Parser8.prototype._handleGAMA = function(length) {
|
|
1283851
|
+
this.read(length, this._parseGAMA.bind(this));
|
|
1283852
|
+
};
|
|
1283853
|
+
Parser8.prototype._parseGAMA = function(data2) {
|
|
1283854
|
+
this._crc.write(data2);
|
|
1283855
|
+
this.gamma(data2.readUInt32BE(0) / constants2.GAMMA_DIVISION);
|
|
1283856
|
+
this._handleChunkEnd();
|
|
1283857
|
+
};
|
|
1283858
|
+
Parser8.prototype._handleIDAT = function(length) {
|
|
1283859
|
+
if (!this._emittedHeadersFinished) {
|
|
1283860
|
+
this._emittedHeadersFinished = true;
|
|
1283861
|
+
this.headersFinished();
|
|
1283862
|
+
}
|
|
1283863
|
+
this.read(-length, this._parseIDAT.bind(this, length));
|
|
1283864
|
+
};
|
|
1283865
|
+
Parser8.prototype._parseIDAT = function(length, data2) {
|
|
1283866
|
+
this._crc.write(data2);
|
|
1283867
|
+
if (this._colorType === constants2.COLORTYPE_PALETTE_COLOR && this._palette.length === 0) {
|
|
1283868
|
+
throw new Error("Expected palette not found");
|
|
1283869
|
+
}
|
|
1283870
|
+
this.inflateData(data2);
|
|
1283871
|
+
let leftOverLength = length - data2.length;
|
|
1283872
|
+
if (leftOverLength > 0) {
|
|
1283873
|
+
this._handleIDAT(leftOverLength);
|
|
1283874
|
+
} else {
|
|
1283875
|
+
this._handleChunkEnd();
|
|
1283876
|
+
}
|
|
1283877
|
+
};
|
|
1283878
|
+
Parser8.prototype._handleIEND = function(length) {
|
|
1283879
|
+
this.read(length, this._parseIEND.bind(this));
|
|
1283880
|
+
};
|
|
1283881
|
+
Parser8.prototype._parseIEND = function(data2) {
|
|
1283882
|
+
this._crc.write(data2);
|
|
1283883
|
+
this._hasIEND = true;
|
|
1283884
|
+
this._handleChunkEnd();
|
|
1283885
|
+
if (this.finished) {
|
|
1283886
|
+
this.finished();
|
|
1283887
|
+
}
|
|
1283888
|
+
};
|
|
1283889
|
+
}
|
|
1283890
|
+
});
|
|
1283891
|
+
|
|
1283892
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitmapper.js
|
|
1283893
|
+
var require_bitmapper = __commonJS({
|
|
1283894
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitmapper.js"(exports2) {
|
|
1283895
|
+
"use strict";
|
|
1283896
|
+
var interlaceUtils = require_interlace();
|
|
1283897
|
+
var pixelBppMapper = [
|
|
1283898
|
+
// 0 - dummy entry
|
|
1283899
|
+
function() {
|
|
1283900
|
+
},
|
|
1283901
|
+
// 1 - L
|
|
1283902
|
+
// 0: 0, 1: 0, 2: 0, 3: 0xff
|
|
1283903
|
+
function(pxData, data2, pxPos, rawPos) {
|
|
1283904
|
+
if (rawPos === data2.length) {
|
|
1283905
|
+
throw new Error("Ran out of data");
|
|
1283906
|
+
}
|
|
1283907
|
+
let pixel = data2[rawPos];
|
|
1283908
|
+
pxData[pxPos] = pixel;
|
|
1283909
|
+
pxData[pxPos + 1] = pixel;
|
|
1283910
|
+
pxData[pxPos + 2] = pixel;
|
|
1283911
|
+
pxData[pxPos + 3] = 255;
|
|
1283912
|
+
},
|
|
1283913
|
+
// 2 - LA
|
|
1283914
|
+
// 0: 0, 1: 0, 2: 0, 3: 1
|
|
1283915
|
+
function(pxData, data2, pxPos, rawPos) {
|
|
1283916
|
+
if (rawPos + 1 >= data2.length) {
|
|
1283917
|
+
throw new Error("Ran out of data");
|
|
1283918
|
+
}
|
|
1283919
|
+
let pixel = data2[rawPos];
|
|
1283920
|
+
pxData[pxPos] = pixel;
|
|
1283921
|
+
pxData[pxPos + 1] = pixel;
|
|
1283922
|
+
pxData[pxPos + 2] = pixel;
|
|
1283923
|
+
pxData[pxPos + 3] = data2[rawPos + 1];
|
|
1283924
|
+
},
|
|
1283925
|
+
// 3 - RGB
|
|
1283926
|
+
// 0: 0, 1: 1, 2: 2, 3: 0xff
|
|
1283927
|
+
function(pxData, data2, pxPos, rawPos) {
|
|
1283928
|
+
if (rawPos + 2 >= data2.length) {
|
|
1283929
|
+
throw new Error("Ran out of data");
|
|
1283930
|
+
}
|
|
1283931
|
+
pxData[pxPos] = data2[rawPos];
|
|
1283932
|
+
pxData[pxPos + 1] = data2[rawPos + 1];
|
|
1283933
|
+
pxData[pxPos + 2] = data2[rawPos + 2];
|
|
1283934
|
+
pxData[pxPos + 3] = 255;
|
|
1283935
|
+
},
|
|
1283936
|
+
// 4 - RGBA
|
|
1283937
|
+
// 0: 0, 1: 1, 2: 2, 3: 3
|
|
1283938
|
+
function(pxData, data2, pxPos, rawPos) {
|
|
1283939
|
+
if (rawPos + 3 >= data2.length) {
|
|
1283940
|
+
throw new Error("Ran out of data");
|
|
1283941
|
+
}
|
|
1283942
|
+
pxData[pxPos] = data2[rawPos];
|
|
1283943
|
+
pxData[pxPos + 1] = data2[rawPos + 1];
|
|
1283944
|
+
pxData[pxPos + 2] = data2[rawPos + 2];
|
|
1283945
|
+
pxData[pxPos + 3] = data2[rawPos + 3];
|
|
1283946
|
+
}
|
|
1283947
|
+
];
|
|
1283948
|
+
var pixelBppCustomMapper = [
|
|
1283949
|
+
// 0 - dummy entry
|
|
1283950
|
+
function() {
|
|
1283951
|
+
},
|
|
1283952
|
+
// 1 - L
|
|
1283953
|
+
// 0: 0, 1: 0, 2: 0, 3: 0xff
|
|
1283954
|
+
function(pxData, pixelData, pxPos, maxBit) {
|
|
1283955
|
+
let pixel = pixelData[0];
|
|
1283956
|
+
pxData[pxPos] = pixel;
|
|
1283957
|
+
pxData[pxPos + 1] = pixel;
|
|
1283958
|
+
pxData[pxPos + 2] = pixel;
|
|
1283959
|
+
pxData[pxPos + 3] = maxBit;
|
|
1283960
|
+
},
|
|
1283961
|
+
// 2 - LA
|
|
1283962
|
+
// 0: 0, 1: 0, 2: 0, 3: 1
|
|
1283963
|
+
function(pxData, pixelData, pxPos) {
|
|
1283964
|
+
let pixel = pixelData[0];
|
|
1283965
|
+
pxData[pxPos] = pixel;
|
|
1283966
|
+
pxData[pxPos + 1] = pixel;
|
|
1283967
|
+
pxData[pxPos + 2] = pixel;
|
|
1283968
|
+
pxData[pxPos + 3] = pixelData[1];
|
|
1283969
|
+
},
|
|
1283970
|
+
// 3 - RGB
|
|
1283971
|
+
// 0: 0, 1: 1, 2: 2, 3: 0xff
|
|
1283972
|
+
function(pxData, pixelData, pxPos, maxBit) {
|
|
1283973
|
+
pxData[pxPos] = pixelData[0];
|
|
1283974
|
+
pxData[pxPos + 1] = pixelData[1];
|
|
1283975
|
+
pxData[pxPos + 2] = pixelData[2];
|
|
1283976
|
+
pxData[pxPos + 3] = maxBit;
|
|
1283977
|
+
},
|
|
1283978
|
+
// 4 - RGBA
|
|
1283979
|
+
// 0: 0, 1: 1, 2: 2, 3: 3
|
|
1283980
|
+
function(pxData, pixelData, pxPos) {
|
|
1283981
|
+
pxData[pxPos] = pixelData[0];
|
|
1283982
|
+
pxData[pxPos + 1] = pixelData[1];
|
|
1283983
|
+
pxData[pxPos + 2] = pixelData[2];
|
|
1283984
|
+
pxData[pxPos + 3] = pixelData[3];
|
|
1283985
|
+
}
|
|
1283986
|
+
];
|
|
1283987
|
+
function bitRetriever(data2, depth) {
|
|
1283988
|
+
let leftOver = [];
|
|
1283989
|
+
let i11 = 0;
|
|
1283990
|
+
function split2() {
|
|
1283991
|
+
if (i11 === data2.length) {
|
|
1283992
|
+
throw new Error("Ran out of data");
|
|
1283993
|
+
}
|
|
1283994
|
+
let byte = data2[i11];
|
|
1283995
|
+
i11++;
|
|
1283996
|
+
let byte8, byte7, byte6, byte5, byte4, byte3, byte2, byte1;
|
|
1283997
|
+
switch (depth) {
|
|
1283998
|
+
default:
|
|
1283999
|
+
throw new Error("unrecognised depth");
|
|
1284000
|
+
case 16:
|
|
1284001
|
+
byte2 = data2[i11];
|
|
1284002
|
+
i11++;
|
|
1284003
|
+
leftOver.push((byte << 8) + byte2);
|
|
1284004
|
+
break;
|
|
1284005
|
+
case 4:
|
|
1284006
|
+
byte2 = byte & 15;
|
|
1284007
|
+
byte1 = byte >> 4;
|
|
1284008
|
+
leftOver.push(byte1, byte2);
|
|
1284009
|
+
break;
|
|
1284010
|
+
case 2:
|
|
1284011
|
+
byte4 = byte & 3;
|
|
1284012
|
+
byte3 = byte >> 2 & 3;
|
|
1284013
|
+
byte2 = byte >> 4 & 3;
|
|
1284014
|
+
byte1 = byte >> 6 & 3;
|
|
1284015
|
+
leftOver.push(byte1, byte2, byte3, byte4);
|
|
1284016
|
+
break;
|
|
1284017
|
+
case 1:
|
|
1284018
|
+
byte8 = byte & 1;
|
|
1284019
|
+
byte7 = byte >> 1 & 1;
|
|
1284020
|
+
byte6 = byte >> 2 & 1;
|
|
1284021
|
+
byte5 = byte >> 3 & 1;
|
|
1284022
|
+
byte4 = byte >> 4 & 1;
|
|
1284023
|
+
byte3 = byte >> 5 & 1;
|
|
1284024
|
+
byte2 = byte >> 6 & 1;
|
|
1284025
|
+
byte1 = byte >> 7 & 1;
|
|
1284026
|
+
leftOver.push(byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8);
|
|
1284027
|
+
break;
|
|
1284028
|
+
}
|
|
1284029
|
+
}
|
|
1284030
|
+
return {
|
|
1284031
|
+
get: function(count) {
|
|
1284032
|
+
while (leftOver.length < count) {
|
|
1284033
|
+
split2();
|
|
1284034
|
+
}
|
|
1284035
|
+
let returner = leftOver.slice(0, count);
|
|
1284036
|
+
leftOver = leftOver.slice(count);
|
|
1284037
|
+
return returner;
|
|
1284038
|
+
},
|
|
1284039
|
+
resetAfterLine: function() {
|
|
1284040
|
+
leftOver.length = 0;
|
|
1284041
|
+
},
|
|
1284042
|
+
end: function() {
|
|
1284043
|
+
if (i11 !== data2.length) {
|
|
1284044
|
+
throw new Error("extra data found");
|
|
1284045
|
+
}
|
|
1284046
|
+
}
|
|
1284047
|
+
};
|
|
1284048
|
+
}
|
|
1284049
|
+
function mapImage8Bit(image3, pxData, getPxPos, bpp, data2, rawPos) {
|
|
1284050
|
+
let imageWidth = image3.width;
|
|
1284051
|
+
let imageHeight = image3.height;
|
|
1284052
|
+
let imagePass = image3.index;
|
|
1284053
|
+
for (let y23 = 0; y23 < imageHeight; y23++) {
|
|
1284054
|
+
for (let x15 = 0; x15 < imageWidth; x15++) {
|
|
1284055
|
+
let pxPos = getPxPos(x15, y23, imagePass);
|
|
1284056
|
+
pixelBppMapper[bpp](pxData, data2, pxPos, rawPos);
|
|
1284057
|
+
rawPos += bpp;
|
|
1284058
|
+
}
|
|
1284059
|
+
}
|
|
1284060
|
+
return rawPos;
|
|
1284061
|
+
}
|
|
1284062
|
+
function mapImageCustomBit(image3, pxData, getPxPos, bpp, bits, maxBit) {
|
|
1284063
|
+
let imageWidth = image3.width;
|
|
1284064
|
+
let imageHeight = image3.height;
|
|
1284065
|
+
let imagePass = image3.index;
|
|
1284066
|
+
for (let y23 = 0; y23 < imageHeight; y23++) {
|
|
1284067
|
+
for (let x15 = 0; x15 < imageWidth; x15++) {
|
|
1284068
|
+
let pixelData = bits.get(bpp);
|
|
1284069
|
+
let pxPos = getPxPos(x15, y23, imagePass);
|
|
1284070
|
+
pixelBppCustomMapper[bpp](pxData, pixelData, pxPos, maxBit);
|
|
1284071
|
+
}
|
|
1284072
|
+
bits.resetAfterLine();
|
|
1284073
|
+
}
|
|
1284074
|
+
}
|
|
1284075
|
+
exports2.dataToBitMap = function(data2, bitmapInfo) {
|
|
1284076
|
+
let width = bitmapInfo.width;
|
|
1284077
|
+
let height3 = bitmapInfo.height;
|
|
1284078
|
+
let depth = bitmapInfo.depth;
|
|
1284079
|
+
let bpp = bitmapInfo.bpp;
|
|
1284080
|
+
let interlace = bitmapInfo.interlace;
|
|
1284081
|
+
let bits;
|
|
1284082
|
+
if (depth !== 8) {
|
|
1284083
|
+
bits = bitRetriever(data2, depth);
|
|
1284084
|
+
}
|
|
1284085
|
+
let pxData;
|
|
1284086
|
+
if (depth <= 8) {
|
|
1284087
|
+
pxData = Buffer.alloc(width * height3 * 4);
|
|
1284088
|
+
} else {
|
|
1284089
|
+
pxData = new Uint16Array(width * height3 * 4);
|
|
1284090
|
+
}
|
|
1284091
|
+
let maxBit = Math.pow(2, depth) - 1;
|
|
1284092
|
+
let rawPos = 0;
|
|
1284093
|
+
let images;
|
|
1284094
|
+
let getPxPos;
|
|
1284095
|
+
if (interlace) {
|
|
1284096
|
+
images = interlaceUtils.getImagePasses(width, height3);
|
|
1284097
|
+
getPxPos = interlaceUtils.getInterlaceIterator(width, height3);
|
|
1284098
|
+
} else {
|
|
1284099
|
+
let nonInterlacedPxPos = 0;
|
|
1284100
|
+
getPxPos = function() {
|
|
1284101
|
+
let returner = nonInterlacedPxPos;
|
|
1284102
|
+
nonInterlacedPxPos += 4;
|
|
1284103
|
+
return returner;
|
|
1284104
|
+
};
|
|
1284105
|
+
images = [{ width, height: height3 }];
|
|
1284106
|
+
}
|
|
1284107
|
+
for (let imageIndex = 0; imageIndex < images.length; imageIndex++) {
|
|
1284108
|
+
if (depth === 8) {
|
|
1284109
|
+
rawPos = mapImage8Bit(
|
|
1284110
|
+
images[imageIndex],
|
|
1284111
|
+
pxData,
|
|
1284112
|
+
getPxPos,
|
|
1284113
|
+
bpp,
|
|
1284114
|
+
data2,
|
|
1284115
|
+
rawPos
|
|
1284116
|
+
);
|
|
1284117
|
+
} else {
|
|
1284118
|
+
mapImageCustomBit(
|
|
1284119
|
+
images[imageIndex],
|
|
1284120
|
+
pxData,
|
|
1284121
|
+
getPxPos,
|
|
1284122
|
+
bpp,
|
|
1284123
|
+
bits,
|
|
1284124
|
+
maxBit
|
|
1284125
|
+
);
|
|
1284126
|
+
}
|
|
1284127
|
+
}
|
|
1284128
|
+
if (depth === 8) {
|
|
1284129
|
+
if (rawPos !== data2.length) {
|
|
1284130
|
+
throw new Error("extra data found");
|
|
1284131
|
+
}
|
|
1284132
|
+
} else {
|
|
1284133
|
+
bits.end();
|
|
1284134
|
+
}
|
|
1284135
|
+
return pxData;
|
|
1284136
|
+
};
|
|
1284137
|
+
}
|
|
1284138
|
+
});
|
|
1284139
|
+
|
|
1284140
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/format-normaliser.js
|
|
1284141
|
+
var require_format_normaliser = __commonJS({
|
|
1284142
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/format-normaliser.js"(exports2, module4) {
|
|
1284143
|
+
"use strict";
|
|
1284144
|
+
function dePalette(indata, outdata, width, height3, palette) {
|
|
1284145
|
+
let pxPos = 0;
|
|
1284146
|
+
for (let y23 = 0; y23 < height3; y23++) {
|
|
1284147
|
+
for (let x15 = 0; x15 < width; x15++) {
|
|
1284148
|
+
let color3 = palette[indata[pxPos]];
|
|
1284149
|
+
if (!color3) {
|
|
1284150
|
+
throw new Error("index " + indata[pxPos] + " not in palette");
|
|
1284151
|
+
}
|
|
1284152
|
+
for (let i11 = 0; i11 < 4; i11++) {
|
|
1284153
|
+
outdata[pxPos + i11] = color3[i11];
|
|
1284154
|
+
}
|
|
1284155
|
+
pxPos += 4;
|
|
1284156
|
+
}
|
|
1284157
|
+
}
|
|
1284158
|
+
}
|
|
1284159
|
+
function replaceTransparentColor(indata, outdata, width, height3, transColor) {
|
|
1284160
|
+
let pxPos = 0;
|
|
1284161
|
+
for (let y23 = 0; y23 < height3; y23++) {
|
|
1284162
|
+
for (let x15 = 0; x15 < width; x15++) {
|
|
1284163
|
+
let makeTrans = false;
|
|
1284164
|
+
if (transColor.length === 1) {
|
|
1284165
|
+
if (transColor[0] === indata[pxPos]) {
|
|
1284166
|
+
makeTrans = true;
|
|
1284167
|
+
}
|
|
1284168
|
+
} else if (transColor[0] === indata[pxPos] && transColor[1] === indata[pxPos + 1] && transColor[2] === indata[pxPos + 2]) {
|
|
1284169
|
+
makeTrans = true;
|
|
1284170
|
+
}
|
|
1284171
|
+
if (makeTrans) {
|
|
1284172
|
+
for (let i11 = 0; i11 < 4; i11++) {
|
|
1284173
|
+
outdata[pxPos + i11] = 0;
|
|
1284174
|
+
}
|
|
1284175
|
+
}
|
|
1284176
|
+
pxPos += 4;
|
|
1284177
|
+
}
|
|
1284178
|
+
}
|
|
1284179
|
+
}
|
|
1284180
|
+
function scaleDepth(indata, outdata, width, height3, depth) {
|
|
1284181
|
+
let maxOutSample = 255;
|
|
1284182
|
+
let maxInSample = Math.pow(2, depth) - 1;
|
|
1284183
|
+
let pxPos = 0;
|
|
1284184
|
+
for (let y23 = 0; y23 < height3; y23++) {
|
|
1284185
|
+
for (let x15 = 0; x15 < width; x15++) {
|
|
1284186
|
+
for (let i11 = 0; i11 < 4; i11++) {
|
|
1284187
|
+
outdata[pxPos + i11] = Math.floor(
|
|
1284188
|
+
indata[pxPos + i11] * maxOutSample / maxInSample + 0.5
|
|
1284189
|
+
);
|
|
1284190
|
+
}
|
|
1284191
|
+
pxPos += 4;
|
|
1284192
|
+
}
|
|
1284193
|
+
}
|
|
1284194
|
+
}
|
|
1284195
|
+
module4.exports = function(indata, imageData, skipRescale = false) {
|
|
1284196
|
+
let depth = imageData.depth;
|
|
1284197
|
+
let width = imageData.width;
|
|
1284198
|
+
let height3 = imageData.height;
|
|
1284199
|
+
let colorType = imageData.colorType;
|
|
1284200
|
+
let transColor = imageData.transColor;
|
|
1284201
|
+
let palette = imageData.palette;
|
|
1284202
|
+
let outdata = indata;
|
|
1284203
|
+
if (colorType === 3) {
|
|
1284204
|
+
dePalette(indata, outdata, width, height3, palette);
|
|
1284205
|
+
} else {
|
|
1284206
|
+
if (transColor) {
|
|
1284207
|
+
replaceTransparentColor(indata, outdata, width, height3, transColor);
|
|
1284208
|
+
}
|
|
1284209
|
+
if (depth !== 8 && !skipRescale) {
|
|
1284210
|
+
if (depth === 16) {
|
|
1284211
|
+
outdata = Buffer.alloc(width * height3 * 4);
|
|
1284212
|
+
}
|
|
1284213
|
+
scaleDepth(indata, outdata, width, height3, depth);
|
|
1284214
|
+
}
|
|
1284215
|
+
}
|
|
1284216
|
+
return outdata;
|
|
1284217
|
+
};
|
|
1284218
|
+
}
|
|
1284219
|
+
});
|
|
1284220
|
+
|
|
1284221
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-async.js
|
|
1284222
|
+
var require_parser_async = __commonJS({
|
|
1284223
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-async.js"(exports2, module4) {
|
|
1284224
|
+
"use strict";
|
|
1284225
|
+
var util4 = require("util");
|
|
1284226
|
+
var zlib4 = require("zlib");
|
|
1284227
|
+
var ChunkStream = require_chunkstream();
|
|
1284228
|
+
var FilterAsync = require_filter_parse_async();
|
|
1284229
|
+
var Parser8 = require_parser4();
|
|
1284230
|
+
var bitmapper = require_bitmapper();
|
|
1284231
|
+
var formatNormaliser = require_format_normaliser();
|
|
1284232
|
+
var ParserAsync = module4.exports = function(options2) {
|
|
1284233
|
+
ChunkStream.call(this);
|
|
1284234
|
+
this._parser = new Parser8(options2, {
|
|
1284235
|
+
read: this.read.bind(this),
|
|
1284236
|
+
error: this._handleError.bind(this),
|
|
1284237
|
+
metadata: this._handleMetaData.bind(this),
|
|
1284238
|
+
gamma: this.emit.bind(this, "gamma"),
|
|
1284239
|
+
palette: this._handlePalette.bind(this),
|
|
1284240
|
+
transColor: this._handleTransColor.bind(this),
|
|
1284241
|
+
finished: this._finished.bind(this),
|
|
1284242
|
+
inflateData: this._inflateData.bind(this),
|
|
1284243
|
+
simpleTransparency: this._simpleTransparency.bind(this),
|
|
1284244
|
+
headersFinished: this._headersFinished.bind(this)
|
|
1284245
|
+
});
|
|
1284246
|
+
this._options = options2;
|
|
1284247
|
+
this.writable = true;
|
|
1284248
|
+
this._parser.start();
|
|
1284249
|
+
};
|
|
1284250
|
+
util4.inherits(ParserAsync, ChunkStream);
|
|
1284251
|
+
ParserAsync.prototype._handleError = function(err) {
|
|
1284252
|
+
this.emit("error", err);
|
|
1284253
|
+
this.writable = false;
|
|
1284254
|
+
this.destroy();
|
|
1284255
|
+
if (this._inflate && this._inflate.destroy) {
|
|
1284256
|
+
this._inflate.destroy();
|
|
1284257
|
+
}
|
|
1284258
|
+
if (this._filter) {
|
|
1284259
|
+
this._filter.destroy();
|
|
1284260
|
+
this._filter.on("error", function() {
|
|
1284261
|
+
});
|
|
1284262
|
+
}
|
|
1284263
|
+
this.errord = true;
|
|
1284264
|
+
};
|
|
1284265
|
+
ParserAsync.prototype._inflateData = function(data2) {
|
|
1284266
|
+
if (!this._inflate) {
|
|
1284267
|
+
if (this._bitmapInfo.interlace) {
|
|
1284268
|
+
this._inflate = zlib4.createInflate();
|
|
1284269
|
+
this._inflate.on("error", this.emit.bind(this, "error"));
|
|
1284270
|
+
this._filter.on("complete", this._complete.bind(this));
|
|
1284271
|
+
this._inflate.pipe(this._filter);
|
|
1284272
|
+
} else {
|
|
1284273
|
+
let rowSize = (this._bitmapInfo.width * this._bitmapInfo.bpp * this._bitmapInfo.depth + 7 >> 3) + 1;
|
|
1284274
|
+
let imageSize2 = rowSize * this._bitmapInfo.height;
|
|
1284275
|
+
let chunkSize = Math.max(imageSize2, zlib4.Z_MIN_CHUNK);
|
|
1284276
|
+
this._inflate = zlib4.createInflate({ chunkSize });
|
|
1284277
|
+
let leftToInflate = imageSize2;
|
|
1284278
|
+
let emitError = this.emit.bind(this, "error");
|
|
1284279
|
+
this._inflate.on("error", function(err) {
|
|
1284280
|
+
if (!leftToInflate) {
|
|
1284281
|
+
return;
|
|
1284282
|
+
}
|
|
1284283
|
+
emitError(err);
|
|
1284284
|
+
});
|
|
1284285
|
+
this._filter.on("complete", this._complete.bind(this));
|
|
1284286
|
+
let filterWrite = this._filter.write.bind(this._filter);
|
|
1284287
|
+
this._inflate.on("data", function(chunk2) {
|
|
1284288
|
+
if (!leftToInflate) {
|
|
1284289
|
+
return;
|
|
1284290
|
+
}
|
|
1284291
|
+
if (chunk2.length > leftToInflate) {
|
|
1284292
|
+
chunk2 = chunk2.slice(0, leftToInflate);
|
|
1284293
|
+
}
|
|
1284294
|
+
leftToInflate -= chunk2.length;
|
|
1284295
|
+
filterWrite(chunk2);
|
|
1284296
|
+
});
|
|
1284297
|
+
this._inflate.on("end", this._filter.end.bind(this._filter));
|
|
1284298
|
+
}
|
|
1284299
|
+
}
|
|
1284300
|
+
this._inflate.write(data2);
|
|
1284301
|
+
};
|
|
1284302
|
+
ParserAsync.prototype._handleMetaData = function(metaData) {
|
|
1284303
|
+
this._metaData = metaData;
|
|
1284304
|
+
this._bitmapInfo = Object.create(metaData);
|
|
1284305
|
+
this._filter = new FilterAsync(this._bitmapInfo);
|
|
1284306
|
+
};
|
|
1284307
|
+
ParserAsync.prototype._handleTransColor = function(transColor) {
|
|
1284308
|
+
this._bitmapInfo.transColor = transColor;
|
|
1284309
|
+
};
|
|
1284310
|
+
ParserAsync.prototype._handlePalette = function(palette) {
|
|
1284311
|
+
this._bitmapInfo.palette = palette;
|
|
1284312
|
+
};
|
|
1284313
|
+
ParserAsync.prototype._simpleTransparency = function() {
|
|
1284314
|
+
this._metaData.alpha = true;
|
|
1284315
|
+
};
|
|
1284316
|
+
ParserAsync.prototype._headersFinished = function() {
|
|
1284317
|
+
this.emit("metadata", this._metaData);
|
|
1284318
|
+
};
|
|
1284319
|
+
ParserAsync.prototype._finished = function() {
|
|
1284320
|
+
if (this.errord) {
|
|
1284321
|
+
return;
|
|
1284322
|
+
}
|
|
1284323
|
+
if (!this._inflate) {
|
|
1284324
|
+
this.emit("error", "No Inflate block");
|
|
1284325
|
+
} else {
|
|
1284326
|
+
this._inflate.end();
|
|
1284327
|
+
}
|
|
1284328
|
+
};
|
|
1284329
|
+
ParserAsync.prototype._complete = function(filteredData) {
|
|
1284330
|
+
if (this.errord) {
|
|
1284331
|
+
return;
|
|
1284332
|
+
}
|
|
1284333
|
+
let normalisedBitmapData;
|
|
1284334
|
+
try {
|
|
1284335
|
+
let bitmapData = bitmapper.dataToBitMap(filteredData, this._bitmapInfo);
|
|
1284336
|
+
normalisedBitmapData = formatNormaliser(
|
|
1284337
|
+
bitmapData,
|
|
1284338
|
+
this._bitmapInfo,
|
|
1284339
|
+
this._options.skipRescale
|
|
1284340
|
+
);
|
|
1284341
|
+
bitmapData = null;
|
|
1284342
|
+
} catch (ex) {
|
|
1284343
|
+
this._handleError(ex);
|
|
1284344
|
+
return;
|
|
1284345
|
+
}
|
|
1284346
|
+
this.emit("parsed", normalisedBitmapData);
|
|
1284347
|
+
};
|
|
1284348
|
+
}
|
|
1284349
|
+
});
|
|
1284350
|
+
|
|
1284351
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitpacker.js
|
|
1284352
|
+
var require_bitpacker = __commonJS({
|
|
1284353
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/bitpacker.js"(exports2, module4) {
|
|
1284354
|
+
"use strict";
|
|
1284355
|
+
var constants2 = require_constants109();
|
|
1284356
|
+
module4.exports = function(dataIn, width, height3, options2) {
|
|
1284357
|
+
let outHasAlpha = [constants2.COLORTYPE_COLOR_ALPHA, constants2.COLORTYPE_ALPHA].indexOf(
|
|
1284358
|
+
options2.colorType
|
|
1284359
|
+
) !== -1;
|
|
1284360
|
+
if (options2.colorType === options2.inputColorType) {
|
|
1284361
|
+
let bigEndian = (function() {
|
|
1284362
|
+
let buffer = new ArrayBuffer(2);
|
|
1284363
|
+
new DataView(buffer).setInt16(
|
|
1284364
|
+
0,
|
|
1284365
|
+
256,
|
|
1284366
|
+
true
|
|
1284367
|
+
/* littleEndian */
|
|
1284368
|
+
);
|
|
1284369
|
+
return new Int16Array(buffer)[0] !== 256;
|
|
1284370
|
+
})();
|
|
1284371
|
+
if (options2.bitDepth === 8 || options2.bitDepth === 16 && bigEndian) {
|
|
1284372
|
+
return dataIn;
|
|
1284373
|
+
}
|
|
1284374
|
+
}
|
|
1284375
|
+
let data2 = options2.bitDepth !== 16 ? dataIn : new Uint16Array(dataIn.buffer);
|
|
1284376
|
+
let maxValue = 255;
|
|
1284377
|
+
let inBpp = constants2.COLORTYPE_TO_BPP_MAP[options2.inputColorType];
|
|
1284378
|
+
if (inBpp === 4 && !options2.inputHasAlpha) {
|
|
1284379
|
+
inBpp = 3;
|
|
1284380
|
+
}
|
|
1284381
|
+
let outBpp = constants2.COLORTYPE_TO_BPP_MAP[options2.colorType];
|
|
1284382
|
+
if (options2.bitDepth === 16) {
|
|
1284383
|
+
maxValue = 65535;
|
|
1284384
|
+
outBpp *= 2;
|
|
1284385
|
+
}
|
|
1284386
|
+
let outData = Buffer.alloc(width * height3 * outBpp);
|
|
1284387
|
+
let inIndex = 0;
|
|
1284388
|
+
let outIndex = 0;
|
|
1284389
|
+
let bgColor = options2.bgColor || {};
|
|
1284390
|
+
if (bgColor.red === void 0) {
|
|
1284391
|
+
bgColor.red = maxValue;
|
|
1284392
|
+
}
|
|
1284393
|
+
if (bgColor.green === void 0) {
|
|
1284394
|
+
bgColor.green = maxValue;
|
|
1284395
|
+
}
|
|
1284396
|
+
if (bgColor.blue === void 0) {
|
|
1284397
|
+
bgColor.blue = maxValue;
|
|
1284398
|
+
}
|
|
1284399
|
+
function getRGBA() {
|
|
1284400
|
+
let red;
|
|
1284401
|
+
let green;
|
|
1284402
|
+
let blue;
|
|
1284403
|
+
let alpha = maxValue;
|
|
1284404
|
+
switch (options2.inputColorType) {
|
|
1284405
|
+
case constants2.COLORTYPE_COLOR_ALPHA:
|
|
1284406
|
+
alpha = data2[inIndex + 3];
|
|
1284407
|
+
red = data2[inIndex];
|
|
1284408
|
+
green = data2[inIndex + 1];
|
|
1284409
|
+
blue = data2[inIndex + 2];
|
|
1284410
|
+
break;
|
|
1284411
|
+
case constants2.COLORTYPE_COLOR:
|
|
1284412
|
+
red = data2[inIndex];
|
|
1284413
|
+
green = data2[inIndex + 1];
|
|
1284414
|
+
blue = data2[inIndex + 2];
|
|
1284415
|
+
break;
|
|
1284416
|
+
case constants2.COLORTYPE_ALPHA:
|
|
1284417
|
+
alpha = data2[inIndex + 1];
|
|
1284418
|
+
red = data2[inIndex];
|
|
1284419
|
+
green = red;
|
|
1284420
|
+
blue = red;
|
|
1284421
|
+
break;
|
|
1284422
|
+
case constants2.COLORTYPE_GRAYSCALE:
|
|
1284423
|
+
red = data2[inIndex];
|
|
1284424
|
+
green = red;
|
|
1284425
|
+
blue = red;
|
|
1284426
|
+
break;
|
|
1284427
|
+
default:
|
|
1284428
|
+
throw new Error(
|
|
1284429
|
+
"input color type:" + options2.inputColorType + " is not supported at present"
|
|
1284430
|
+
);
|
|
1284431
|
+
}
|
|
1284432
|
+
if (options2.inputHasAlpha) {
|
|
1284433
|
+
if (!outHasAlpha) {
|
|
1284434
|
+
alpha /= maxValue;
|
|
1284435
|
+
red = Math.min(
|
|
1284436
|
+
Math.max(Math.round((1 - alpha) * bgColor.red + alpha * red), 0),
|
|
1284437
|
+
maxValue
|
|
1284438
|
+
);
|
|
1284439
|
+
green = Math.min(
|
|
1284440
|
+
Math.max(Math.round((1 - alpha) * bgColor.green + alpha * green), 0),
|
|
1284441
|
+
maxValue
|
|
1284442
|
+
);
|
|
1284443
|
+
blue = Math.min(
|
|
1284444
|
+
Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0),
|
|
1284445
|
+
maxValue
|
|
1284446
|
+
);
|
|
1284447
|
+
}
|
|
1284448
|
+
}
|
|
1284449
|
+
return { red, green, blue, alpha };
|
|
1284450
|
+
}
|
|
1284451
|
+
for (let y23 = 0; y23 < height3; y23++) {
|
|
1284452
|
+
for (let x15 = 0; x15 < width; x15++) {
|
|
1284453
|
+
let rgba = getRGBA(data2, inIndex);
|
|
1284454
|
+
switch (options2.colorType) {
|
|
1284455
|
+
case constants2.COLORTYPE_COLOR_ALPHA:
|
|
1284456
|
+
case constants2.COLORTYPE_COLOR:
|
|
1284457
|
+
if (options2.bitDepth === 8) {
|
|
1284458
|
+
outData[outIndex] = rgba.red;
|
|
1284459
|
+
outData[outIndex + 1] = rgba.green;
|
|
1284460
|
+
outData[outIndex + 2] = rgba.blue;
|
|
1284461
|
+
if (outHasAlpha) {
|
|
1284462
|
+
outData[outIndex + 3] = rgba.alpha;
|
|
1284463
|
+
}
|
|
1284464
|
+
} else {
|
|
1284465
|
+
outData.writeUInt16BE(rgba.red, outIndex);
|
|
1284466
|
+
outData.writeUInt16BE(rgba.green, outIndex + 2);
|
|
1284467
|
+
outData.writeUInt16BE(rgba.blue, outIndex + 4);
|
|
1284468
|
+
if (outHasAlpha) {
|
|
1284469
|
+
outData.writeUInt16BE(rgba.alpha, outIndex + 6);
|
|
1284470
|
+
}
|
|
1284471
|
+
}
|
|
1284472
|
+
break;
|
|
1284473
|
+
case constants2.COLORTYPE_ALPHA:
|
|
1284474
|
+
case constants2.COLORTYPE_GRAYSCALE: {
|
|
1284475
|
+
let grayscale = (rgba.red + rgba.green + rgba.blue) / 3;
|
|
1284476
|
+
if (options2.bitDepth === 8) {
|
|
1284477
|
+
outData[outIndex] = grayscale;
|
|
1284478
|
+
if (outHasAlpha) {
|
|
1284479
|
+
outData[outIndex + 1] = rgba.alpha;
|
|
1284480
|
+
}
|
|
1284481
|
+
} else {
|
|
1284482
|
+
outData.writeUInt16BE(grayscale, outIndex);
|
|
1284483
|
+
if (outHasAlpha) {
|
|
1284484
|
+
outData.writeUInt16BE(rgba.alpha, outIndex + 2);
|
|
1284485
|
+
}
|
|
1284486
|
+
}
|
|
1284487
|
+
break;
|
|
1284488
|
+
}
|
|
1284489
|
+
default:
|
|
1284490
|
+
throw new Error("unrecognised color Type " + options2.colorType);
|
|
1284491
|
+
}
|
|
1284492
|
+
inIndex += inBpp;
|
|
1284493
|
+
outIndex += outBpp;
|
|
1284494
|
+
}
|
|
1284495
|
+
}
|
|
1284496
|
+
return outData;
|
|
1284497
|
+
};
|
|
1284498
|
+
}
|
|
1284499
|
+
});
|
|
1284500
|
+
|
|
1284501
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-pack.js
|
|
1284502
|
+
var require_filter_pack = __commonJS({
|
|
1284503
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-pack.js"(exports2, module4) {
|
|
1284504
|
+
"use strict";
|
|
1284505
|
+
var paethPredictor = require_paeth_predictor();
|
|
1284506
|
+
function filterNone(pxData, pxPos, byteWidth, rawData, rawPos) {
|
|
1284507
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284508
|
+
rawData[rawPos + x15] = pxData[pxPos + x15];
|
|
1284509
|
+
}
|
|
1284510
|
+
}
|
|
1284511
|
+
function filterSumNone(pxData, pxPos, byteWidth) {
|
|
1284512
|
+
let sum = 0;
|
|
1284513
|
+
let length = pxPos + byteWidth;
|
|
1284514
|
+
for (let i11 = pxPos; i11 < length; i11++) {
|
|
1284515
|
+
sum += Math.abs(pxData[i11]);
|
|
1284516
|
+
}
|
|
1284517
|
+
return sum;
|
|
1284518
|
+
}
|
|
1284519
|
+
function filterSub(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
|
|
1284520
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284521
|
+
let left3 = x15 >= bpp ? pxData[pxPos + x15 - bpp] : 0;
|
|
1284522
|
+
let val = pxData[pxPos + x15] - left3;
|
|
1284523
|
+
rawData[rawPos + x15] = val;
|
|
1284524
|
+
}
|
|
1284525
|
+
}
|
|
1284526
|
+
function filterSumSub(pxData, pxPos, byteWidth, bpp) {
|
|
1284527
|
+
let sum = 0;
|
|
1284528
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284529
|
+
let left3 = x15 >= bpp ? pxData[pxPos + x15 - bpp] : 0;
|
|
1284530
|
+
let val = pxData[pxPos + x15] - left3;
|
|
1284531
|
+
sum += Math.abs(val);
|
|
1284532
|
+
}
|
|
1284533
|
+
return sum;
|
|
1284534
|
+
}
|
|
1284535
|
+
function filterUp(pxData, pxPos, byteWidth, rawData, rawPos) {
|
|
1284536
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284537
|
+
let up4 = pxPos > 0 ? pxData[pxPos + x15 - byteWidth] : 0;
|
|
1284538
|
+
let val = pxData[pxPos + x15] - up4;
|
|
1284539
|
+
rawData[rawPos + x15] = val;
|
|
1284540
|
+
}
|
|
1284541
|
+
}
|
|
1284542
|
+
function filterSumUp(pxData, pxPos, byteWidth) {
|
|
1284543
|
+
let sum = 0;
|
|
1284544
|
+
let length = pxPos + byteWidth;
|
|
1284545
|
+
for (let x15 = pxPos; x15 < length; x15++) {
|
|
1284546
|
+
let up4 = pxPos > 0 ? pxData[x15 - byteWidth] : 0;
|
|
1284547
|
+
let val = pxData[x15] - up4;
|
|
1284548
|
+
sum += Math.abs(val);
|
|
1284549
|
+
}
|
|
1284550
|
+
return sum;
|
|
1284551
|
+
}
|
|
1284552
|
+
function filterAvg(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
|
|
1284553
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284554
|
+
let left3 = x15 >= bpp ? pxData[pxPos + x15 - bpp] : 0;
|
|
1284555
|
+
let up4 = pxPos > 0 ? pxData[pxPos + x15 - byteWidth] : 0;
|
|
1284556
|
+
let val = pxData[pxPos + x15] - (left3 + up4 >> 1);
|
|
1284557
|
+
rawData[rawPos + x15] = val;
|
|
1284558
|
+
}
|
|
1284559
|
+
}
|
|
1284560
|
+
function filterSumAvg(pxData, pxPos, byteWidth, bpp) {
|
|
1284561
|
+
let sum = 0;
|
|
1284562
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284563
|
+
let left3 = x15 >= bpp ? pxData[pxPos + x15 - bpp] : 0;
|
|
1284564
|
+
let up4 = pxPos > 0 ? pxData[pxPos + x15 - byteWidth] : 0;
|
|
1284565
|
+
let val = pxData[pxPos + x15] - (left3 + up4 >> 1);
|
|
1284566
|
+
sum += Math.abs(val);
|
|
1284567
|
+
}
|
|
1284568
|
+
return sum;
|
|
1284569
|
+
}
|
|
1284570
|
+
function filterPaeth(pxData, pxPos, byteWidth, rawData, rawPos, bpp) {
|
|
1284571
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284572
|
+
let left3 = x15 >= bpp ? pxData[pxPos + x15 - bpp] : 0;
|
|
1284573
|
+
let up4 = pxPos > 0 ? pxData[pxPos + x15 - byteWidth] : 0;
|
|
1284574
|
+
let upleft = pxPos > 0 && x15 >= bpp ? pxData[pxPos + x15 - (byteWidth + bpp)] : 0;
|
|
1284575
|
+
let val = pxData[pxPos + x15] - paethPredictor(left3, up4, upleft);
|
|
1284576
|
+
rawData[rawPos + x15] = val;
|
|
1284577
|
+
}
|
|
1284578
|
+
}
|
|
1284579
|
+
function filterSumPaeth(pxData, pxPos, byteWidth, bpp) {
|
|
1284580
|
+
let sum = 0;
|
|
1284581
|
+
for (let x15 = 0; x15 < byteWidth; x15++) {
|
|
1284582
|
+
let left3 = x15 >= bpp ? pxData[pxPos + x15 - bpp] : 0;
|
|
1284583
|
+
let up4 = pxPos > 0 ? pxData[pxPos + x15 - byteWidth] : 0;
|
|
1284584
|
+
let upleft = pxPos > 0 && x15 >= bpp ? pxData[pxPos + x15 - (byteWidth + bpp)] : 0;
|
|
1284585
|
+
let val = pxData[pxPos + x15] - paethPredictor(left3, up4, upleft);
|
|
1284586
|
+
sum += Math.abs(val);
|
|
1284587
|
+
}
|
|
1284588
|
+
return sum;
|
|
1284589
|
+
}
|
|
1284590
|
+
var filters = {
|
|
1284591
|
+
0: filterNone,
|
|
1284592
|
+
1: filterSub,
|
|
1284593
|
+
2: filterUp,
|
|
1284594
|
+
3: filterAvg,
|
|
1284595
|
+
4: filterPaeth
|
|
1284596
|
+
};
|
|
1284597
|
+
var filterSums = {
|
|
1284598
|
+
0: filterSumNone,
|
|
1284599
|
+
1: filterSumSub,
|
|
1284600
|
+
2: filterSumUp,
|
|
1284601
|
+
3: filterSumAvg,
|
|
1284602
|
+
4: filterSumPaeth
|
|
1284603
|
+
};
|
|
1284604
|
+
module4.exports = function(pxData, width, height3, options2, bpp) {
|
|
1284605
|
+
let filterTypes;
|
|
1284606
|
+
if (!("filterType" in options2) || options2.filterType === -1) {
|
|
1284607
|
+
filterTypes = [0, 1, 2, 3, 4];
|
|
1284608
|
+
} else if (typeof options2.filterType === "number") {
|
|
1284609
|
+
filterTypes = [options2.filterType];
|
|
1284610
|
+
} else {
|
|
1284611
|
+
throw new Error("unrecognised filter types");
|
|
1284612
|
+
}
|
|
1284613
|
+
if (options2.bitDepth === 16) {
|
|
1284614
|
+
bpp *= 2;
|
|
1284615
|
+
}
|
|
1284616
|
+
let byteWidth = width * bpp;
|
|
1284617
|
+
let rawPos = 0;
|
|
1284618
|
+
let pxPos = 0;
|
|
1284619
|
+
let rawData = Buffer.alloc((byteWidth + 1) * height3);
|
|
1284620
|
+
let sel = filterTypes[0];
|
|
1284621
|
+
for (let y23 = 0; y23 < height3; y23++) {
|
|
1284622
|
+
if (filterTypes.length > 1) {
|
|
1284623
|
+
let min = Infinity;
|
|
1284624
|
+
for (let i11 = 0; i11 < filterTypes.length; i11++) {
|
|
1284625
|
+
let sum = filterSums[filterTypes[i11]](pxData, pxPos, byteWidth, bpp);
|
|
1284626
|
+
if (sum < min) {
|
|
1284627
|
+
sel = filterTypes[i11];
|
|
1284628
|
+
min = sum;
|
|
1284629
|
+
}
|
|
1284630
|
+
}
|
|
1284631
|
+
}
|
|
1284632
|
+
rawData[rawPos] = sel;
|
|
1284633
|
+
rawPos++;
|
|
1284634
|
+
filters[sel](pxData, pxPos, byteWidth, rawData, rawPos, bpp);
|
|
1284635
|
+
rawPos += byteWidth;
|
|
1284636
|
+
pxPos += byteWidth;
|
|
1284637
|
+
}
|
|
1284638
|
+
return rawData;
|
|
1284639
|
+
};
|
|
1284640
|
+
}
|
|
1284641
|
+
});
|
|
1284642
|
+
|
|
1284643
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer.js
|
|
1284644
|
+
var require_packer = __commonJS({
|
|
1284645
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer.js"(exports2, module4) {
|
|
1284646
|
+
"use strict";
|
|
1284647
|
+
var constants2 = require_constants109();
|
|
1284648
|
+
var CrcStream = require_crc();
|
|
1284649
|
+
var bitPacker = require_bitpacker();
|
|
1284650
|
+
var filter7 = require_filter_pack();
|
|
1284651
|
+
var zlib4 = require("zlib");
|
|
1284652
|
+
var Packer = module4.exports = function(options2) {
|
|
1284653
|
+
this._options = options2;
|
|
1284654
|
+
options2.deflateChunkSize = options2.deflateChunkSize || 32 * 1024;
|
|
1284655
|
+
options2.deflateLevel = options2.deflateLevel != null ? options2.deflateLevel : 9;
|
|
1284656
|
+
options2.deflateStrategy = options2.deflateStrategy != null ? options2.deflateStrategy : 3;
|
|
1284657
|
+
options2.inputHasAlpha = options2.inputHasAlpha != null ? options2.inputHasAlpha : true;
|
|
1284658
|
+
options2.deflateFactory = options2.deflateFactory || zlib4.createDeflate;
|
|
1284659
|
+
options2.bitDepth = options2.bitDepth || 8;
|
|
1284660
|
+
options2.colorType = typeof options2.colorType === "number" ? options2.colorType : constants2.COLORTYPE_COLOR_ALPHA;
|
|
1284661
|
+
options2.inputColorType = typeof options2.inputColorType === "number" ? options2.inputColorType : constants2.COLORTYPE_COLOR_ALPHA;
|
|
1284662
|
+
if ([
|
|
1284663
|
+
constants2.COLORTYPE_GRAYSCALE,
|
|
1284664
|
+
constants2.COLORTYPE_COLOR,
|
|
1284665
|
+
constants2.COLORTYPE_COLOR_ALPHA,
|
|
1284666
|
+
constants2.COLORTYPE_ALPHA
|
|
1284667
|
+
].indexOf(options2.colorType) === -1) {
|
|
1284668
|
+
throw new Error(
|
|
1284669
|
+
"option color type:" + options2.colorType + " is not supported at present"
|
|
1284670
|
+
);
|
|
1284671
|
+
}
|
|
1284672
|
+
if ([
|
|
1284673
|
+
constants2.COLORTYPE_GRAYSCALE,
|
|
1284674
|
+
constants2.COLORTYPE_COLOR,
|
|
1284675
|
+
constants2.COLORTYPE_COLOR_ALPHA,
|
|
1284676
|
+
constants2.COLORTYPE_ALPHA
|
|
1284677
|
+
].indexOf(options2.inputColorType) === -1) {
|
|
1284678
|
+
throw new Error(
|
|
1284679
|
+
"option input color type:" + options2.inputColorType + " is not supported at present"
|
|
1284680
|
+
);
|
|
1284681
|
+
}
|
|
1284682
|
+
if (options2.bitDepth !== 8 && options2.bitDepth !== 16) {
|
|
1284683
|
+
throw new Error(
|
|
1284684
|
+
"option bit depth:" + options2.bitDepth + " is not supported at present"
|
|
1284685
|
+
);
|
|
1284686
|
+
}
|
|
1284687
|
+
};
|
|
1284688
|
+
Packer.prototype.getDeflateOptions = function() {
|
|
1284689
|
+
return {
|
|
1284690
|
+
chunkSize: this._options.deflateChunkSize,
|
|
1284691
|
+
level: this._options.deflateLevel,
|
|
1284692
|
+
strategy: this._options.deflateStrategy
|
|
1284693
|
+
};
|
|
1284694
|
+
};
|
|
1284695
|
+
Packer.prototype.createDeflate = function() {
|
|
1284696
|
+
return this._options.deflateFactory(this.getDeflateOptions());
|
|
1284697
|
+
};
|
|
1284698
|
+
Packer.prototype.filterData = function(data2, width, height3) {
|
|
1284699
|
+
let packedData = bitPacker(data2, width, height3, this._options);
|
|
1284700
|
+
let bpp = constants2.COLORTYPE_TO_BPP_MAP[this._options.colorType];
|
|
1284701
|
+
let filteredData = filter7(packedData, width, height3, this._options, bpp);
|
|
1284702
|
+
return filteredData;
|
|
1284703
|
+
};
|
|
1284704
|
+
Packer.prototype._packChunk = function(type8, data2) {
|
|
1284705
|
+
let len = data2 ? data2.length : 0;
|
|
1284706
|
+
let buf = Buffer.alloc(len + 12);
|
|
1284707
|
+
buf.writeUInt32BE(len, 0);
|
|
1284708
|
+
buf.writeUInt32BE(type8, 4);
|
|
1284709
|
+
if (data2) {
|
|
1284710
|
+
data2.copy(buf, 8);
|
|
1284711
|
+
}
|
|
1284712
|
+
buf.writeInt32BE(
|
|
1284713
|
+
CrcStream.crc32(buf.slice(4, buf.length - 4)),
|
|
1284714
|
+
buf.length - 4
|
|
1284715
|
+
);
|
|
1284716
|
+
return buf;
|
|
1284717
|
+
};
|
|
1284718
|
+
Packer.prototype.packGAMA = function(gamma) {
|
|
1284719
|
+
let buf = Buffer.alloc(4);
|
|
1284720
|
+
buf.writeUInt32BE(Math.floor(gamma * constants2.GAMMA_DIVISION), 0);
|
|
1284721
|
+
return this._packChunk(constants2.TYPE_gAMA, buf);
|
|
1284722
|
+
};
|
|
1284723
|
+
Packer.prototype.packIHDR = function(width, height3) {
|
|
1284724
|
+
let buf = Buffer.alloc(13);
|
|
1284725
|
+
buf.writeUInt32BE(width, 0);
|
|
1284726
|
+
buf.writeUInt32BE(height3, 4);
|
|
1284727
|
+
buf[8] = this._options.bitDepth;
|
|
1284728
|
+
buf[9] = this._options.colorType;
|
|
1284729
|
+
buf[10] = 0;
|
|
1284730
|
+
buf[11] = 0;
|
|
1284731
|
+
buf[12] = 0;
|
|
1284732
|
+
return this._packChunk(constants2.TYPE_IHDR, buf);
|
|
1284733
|
+
};
|
|
1284734
|
+
Packer.prototype.packIDAT = function(data2) {
|
|
1284735
|
+
return this._packChunk(constants2.TYPE_IDAT, data2);
|
|
1284736
|
+
};
|
|
1284737
|
+
Packer.prototype.packIEND = function() {
|
|
1284738
|
+
return this._packChunk(constants2.TYPE_IEND, null);
|
|
1284739
|
+
};
|
|
1284740
|
+
}
|
|
1284741
|
+
});
|
|
1284742
|
+
|
|
1284743
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-async.js
|
|
1284744
|
+
var require_packer_async = __commonJS({
|
|
1284745
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-async.js"(exports2, module4) {
|
|
1284746
|
+
"use strict";
|
|
1284747
|
+
var util4 = require("util");
|
|
1284748
|
+
var Stream5 = require("stream");
|
|
1284749
|
+
var constants2 = require_constants109();
|
|
1284750
|
+
var Packer = require_packer();
|
|
1284751
|
+
var PackerAsync = module4.exports = function(opt) {
|
|
1284752
|
+
Stream5.call(this);
|
|
1284753
|
+
let options2 = opt || {};
|
|
1284754
|
+
this._packer = new Packer(options2);
|
|
1284755
|
+
this._deflate = this._packer.createDeflate();
|
|
1284756
|
+
this.readable = true;
|
|
1284757
|
+
};
|
|
1284758
|
+
util4.inherits(PackerAsync, Stream5);
|
|
1284759
|
+
PackerAsync.prototype.pack = function(data2, width, height3, gamma) {
|
|
1284760
|
+
this.emit("data", Buffer.from(constants2.PNG_SIGNATURE));
|
|
1284761
|
+
this.emit("data", this._packer.packIHDR(width, height3));
|
|
1284762
|
+
if (gamma) {
|
|
1284763
|
+
this.emit("data", this._packer.packGAMA(gamma));
|
|
1284764
|
+
}
|
|
1284765
|
+
let filteredData = this._packer.filterData(data2, width, height3);
|
|
1284766
|
+
this._deflate.on("error", this.emit.bind(this, "error"));
|
|
1284767
|
+
this._deflate.on(
|
|
1284768
|
+
"data",
|
|
1284769
|
+
function(compressedData) {
|
|
1284770
|
+
this.emit("data", this._packer.packIDAT(compressedData));
|
|
1284771
|
+
}.bind(this)
|
|
1284772
|
+
);
|
|
1284773
|
+
this._deflate.on(
|
|
1284774
|
+
"end",
|
|
1284775
|
+
function() {
|
|
1284776
|
+
this.emit("data", this._packer.packIEND());
|
|
1284777
|
+
this.emit("end");
|
|
1284778
|
+
}.bind(this)
|
|
1284779
|
+
);
|
|
1284780
|
+
this._deflate.end(filteredData);
|
|
1284781
|
+
};
|
|
1284782
|
+
}
|
|
1284783
|
+
});
|
|
1284784
|
+
|
|
1284785
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-inflate.js
|
|
1284786
|
+
var require_sync_inflate = __commonJS({
|
|
1284787
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-inflate.js"(exports2, module4) {
|
|
1284788
|
+
"use strict";
|
|
1284789
|
+
var assert12 = require("assert").ok;
|
|
1284790
|
+
var zlib4 = require("zlib");
|
|
1284791
|
+
var util4 = require("util");
|
|
1284792
|
+
var kMaxLength = require("buffer").kMaxLength;
|
|
1284793
|
+
function Inflate(opts) {
|
|
1284794
|
+
if (!(this instanceof Inflate)) {
|
|
1284795
|
+
return new Inflate(opts);
|
|
1284796
|
+
}
|
|
1284797
|
+
if (opts && opts.chunkSize < zlib4.Z_MIN_CHUNK) {
|
|
1284798
|
+
opts.chunkSize = zlib4.Z_MIN_CHUNK;
|
|
1284799
|
+
}
|
|
1284800
|
+
zlib4.Inflate.call(this, opts);
|
|
1284801
|
+
this._offset = this._offset === void 0 ? this._outOffset : this._offset;
|
|
1284802
|
+
this._buffer = this._buffer || this._outBuffer;
|
|
1284803
|
+
if (opts && opts.maxLength != null) {
|
|
1284804
|
+
this._maxLength = opts.maxLength;
|
|
1284805
|
+
}
|
|
1284806
|
+
}
|
|
1284807
|
+
function createInflate(opts) {
|
|
1284808
|
+
return new Inflate(opts);
|
|
1284809
|
+
}
|
|
1284810
|
+
function _close2(engine, callback) {
|
|
1284811
|
+
if (callback) {
|
|
1284812
|
+
process.nextTick(callback);
|
|
1284813
|
+
}
|
|
1284814
|
+
if (!engine._handle) {
|
|
1284815
|
+
return;
|
|
1284816
|
+
}
|
|
1284817
|
+
engine._handle.close();
|
|
1284818
|
+
engine._handle = null;
|
|
1284819
|
+
}
|
|
1284820
|
+
Inflate.prototype._processChunk = function(chunk2, flushFlag, asyncCb) {
|
|
1284821
|
+
if (typeof asyncCb === "function") {
|
|
1284822
|
+
return zlib4.Inflate._processChunk.call(this, chunk2, flushFlag, asyncCb);
|
|
1284823
|
+
}
|
|
1284824
|
+
let self2 = this;
|
|
1284825
|
+
let availInBefore = chunk2 && chunk2.length;
|
|
1284826
|
+
let availOutBefore = this._chunkSize - this._offset;
|
|
1284827
|
+
let leftToInflate = this._maxLength;
|
|
1284828
|
+
let inOff = 0;
|
|
1284829
|
+
let buffers = [];
|
|
1284830
|
+
let nread = 0;
|
|
1284831
|
+
let error49;
|
|
1284832
|
+
this.on("error", function(err) {
|
|
1284833
|
+
error49 = err;
|
|
1284834
|
+
});
|
|
1284835
|
+
function handleChunk(availInAfter, availOutAfter) {
|
|
1284836
|
+
if (self2._hadError) {
|
|
1284837
|
+
return;
|
|
1284838
|
+
}
|
|
1284839
|
+
let have = availOutBefore - availOutAfter;
|
|
1284840
|
+
assert12(have >= 0, "have should not go down");
|
|
1284841
|
+
if (have > 0) {
|
|
1284842
|
+
let out = self2._buffer.slice(self2._offset, self2._offset + have);
|
|
1284843
|
+
self2._offset += have;
|
|
1284844
|
+
if (out.length > leftToInflate) {
|
|
1284845
|
+
out = out.slice(0, leftToInflate);
|
|
1284846
|
+
}
|
|
1284847
|
+
buffers.push(out);
|
|
1284848
|
+
nread += out.length;
|
|
1284849
|
+
leftToInflate -= out.length;
|
|
1284850
|
+
if (leftToInflate === 0) {
|
|
1284851
|
+
return false;
|
|
1284852
|
+
}
|
|
1284853
|
+
}
|
|
1284854
|
+
if (availOutAfter === 0 || self2._offset >= self2._chunkSize) {
|
|
1284855
|
+
availOutBefore = self2._chunkSize;
|
|
1284856
|
+
self2._offset = 0;
|
|
1284857
|
+
self2._buffer = Buffer.allocUnsafe(self2._chunkSize);
|
|
1284858
|
+
}
|
|
1284859
|
+
if (availOutAfter === 0) {
|
|
1284860
|
+
inOff += availInBefore - availInAfter;
|
|
1284861
|
+
availInBefore = availInAfter;
|
|
1284862
|
+
return true;
|
|
1284863
|
+
}
|
|
1284864
|
+
return false;
|
|
1284865
|
+
}
|
|
1284866
|
+
assert12(this._handle, "zlib binding closed");
|
|
1284867
|
+
let res;
|
|
1284868
|
+
do {
|
|
1284869
|
+
res = this._handle.writeSync(
|
|
1284870
|
+
flushFlag,
|
|
1284871
|
+
chunk2,
|
|
1284872
|
+
// in
|
|
1284873
|
+
inOff,
|
|
1284874
|
+
// in_off
|
|
1284875
|
+
availInBefore,
|
|
1284876
|
+
// in_len
|
|
1284877
|
+
this._buffer,
|
|
1284878
|
+
// out
|
|
1284879
|
+
this._offset,
|
|
1284880
|
+
//out_off
|
|
1284881
|
+
availOutBefore
|
|
1284882
|
+
);
|
|
1284883
|
+
res = res || this._writeState;
|
|
1284884
|
+
} while (!this._hadError && handleChunk(res[0], res[1]));
|
|
1284885
|
+
if (this._hadError) {
|
|
1284886
|
+
throw error49;
|
|
1284887
|
+
}
|
|
1284888
|
+
if (nread >= kMaxLength) {
|
|
1284889
|
+
_close2(this);
|
|
1284890
|
+
throw new RangeError(
|
|
1284891
|
+
"Cannot create final Buffer. It would be larger than 0x" + kMaxLength.toString(16) + " bytes"
|
|
1284892
|
+
);
|
|
1284893
|
+
}
|
|
1284894
|
+
let buf = Buffer.concat(buffers, nread);
|
|
1284895
|
+
_close2(this);
|
|
1284896
|
+
return buf;
|
|
1284897
|
+
};
|
|
1284898
|
+
util4.inherits(Inflate, zlib4.Inflate);
|
|
1284899
|
+
function zlibBufferSync(engine, buffer) {
|
|
1284900
|
+
if (typeof buffer === "string") {
|
|
1284901
|
+
buffer = Buffer.from(buffer);
|
|
1284902
|
+
}
|
|
1284903
|
+
if (!(buffer instanceof Buffer)) {
|
|
1284904
|
+
throw new TypeError("Not a string or buffer");
|
|
1284905
|
+
}
|
|
1284906
|
+
let flushFlag = engine._finishFlushFlag;
|
|
1284907
|
+
if (flushFlag == null) {
|
|
1284908
|
+
flushFlag = zlib4.Z_FINISH;
|
|
1284909
|
+
}
|
|
1284910
|
+
return engine._processChunk(buffer, flushFlag);
|
|
1284911
|
+
}
|
|
1284912
|
+
function inflateSync(buffer, opts) {
|
|
1284913
|
+
return zlibBufferSync(new Inflate(opts), buffer);
|
|
1284914
|
+
}
|
|
1284915
|
+
module4.exports = exports2 = inflateSync;
|
|
1284916
|
+
exports2.Inflate = Inflate;
|
|
1284917
|
+
exports2.createInflate = createInflate;
|
|
1284918
|
+
exports2.inflateSync = inflateSync;
|
|
1284919
|
+
}
|
|
1284920
|
+
});
|
|
1284921
|
+
|
|
1284922
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-reader.js
|
|
1284923
|
+
var require_sync_reader = __commonJS({
|
|
1284924
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/sync-reader.js"(exports2, module4) {
|
|
1284925
|
+
"use strict";
|
|
1284926
|
+
var SyncReader = module4.exports = function(buffer) {
|
|
1284927
|
+
this._buffer = buffer;
|
|
1284928
|
+
this._reads = [];
|
|
1284929
|
+
};
|
|
1284930
|
+
SyncReader.prototype.read = function(length, callback) {
|
|
1284931
|
+
this._reads.push({
|
|
1284932
|
+
length: Math.abs(length),
|
|
1284933
|
+
// if length < 0 then at most this length
|
|
1284934
|
+
allowLess: length < 0,
|
|
1284935
|
+
func: callback
|
|
1284936
|
+
});
|
|
1284937
|
+
};
|
|
1284938
|
+
SyncReader.prototype.process = function() {
|
|
1284939
|
+
while (this._reads.length > 0 && this._buffer.length) {
|
|
1284940
|
+
let read2 = this._reads[0];
|
|
1284941
|
+
if (this._buffer.length && (this._buffer.length >= read2.length || read2.allowLess)) {
|
|
1284942
|
+
this._reads.shift();
|
|
1284943
|
+
let buf = this._buffer;
|
|
1284944
|
+
this._buffer = buf.slice(read2.length);
|
|
1284945
|
+
read2.func.call(this, buf.slice(0, read2.length));
|
|
1284946
|
+
} else {
|
|
1284947
|
+
break;
|
|
1284948
|
+
}
|
|
1284949
|
+
}
|
|
1284950
|
+
if (this._reads.length > 0) {
|
|
1284951
|
+
throw new Error("There are some read requests waitng on finished stream");
|
|
1284952
|
+
}
|
|
1284953
|
+
if (this._buffer.length > 0) {
|
|
1284954
|
+
throw new Error("unrecognised content at end of stream");
|
|
1284955
|
+
}
|
|
1284956
|
+
};
|
|
1284957
|
+
}
|
|
1284958
|
+
});
|
|
1284959
|
+
|
|
1284960
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-sync.js
|
|
1284961
|
+
var require_filter_parse_sync = __commonJS({
|
|
1284962
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/filter-parse-sync.js"(exports2) {
|
|
1284963
|
+
"use strict";
|
|
1284964
|
+
var SyncReader = require_sync_reader();
|
|
1284965
|
+
var Filter = require_filter_parse();
|
|
1284966
|
+
exports2.process = function(inBuffer, bitmapInfo) {
|
|
1284967
|
+
let outBuffers = [];
|
|
1284968
|
+
let reader = new SyncReader(inBuffer);
|
|
1284969
|
+
let filter7 = new Filter(bitmapInfo, {
|
|
1284970
|
+
read: reader.read.bind(reader),
|
|
1284971
|
+
write: function(bufferPart) {
|
|
1284972
|
+
outBuffers.push(bufferPart);
|
|
1284973
|
+
},
|
|
1284974
|
+
complete: function() {
|
|
1284975
|
+
}
|
|
1284976
|
+
});
|
|
1284977
|
+
filter7.start();
|
|
1284978
|
+
reader.process();
|
|
1284979
|
+
return Buffer.concat(outBuffers);
|
|
1284980
|
+
};
|
|
1284981
|
+
}
|
|
1284982
|
+
});
|
|
1284983
|
+
|
|
1284984
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-sync.js
|
|
1284985
|
+
var require_parser_sync = __commonJS({
|
|
1284986
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/parser-sync.js"(exports2, module4) {
|
|
1284987
|
+
"use strict";
|
|
1284988
|
+
var hasSyncZlib = true;
|
|
1284989
|
+
var zlib4 = require("zlib");
|
|
1284990
|
+
var inflateSync = require_sync_inflate();
|
|
1284991
|
+
if (!zlib4.deflateSync) {
|
|
1284992
|
+
hasSyncZlib = false;
|
|
1284993
|
+
}
|
|
1284994
|
+
var SyncReader = require_sync_reader();
|
|
1284995
|
+
var FilterSync = require_filter_parse_sync();
|
|
1284996
|
+
var Parser8 = require_parser4();
|
|
1284997
|
+
var bitmapper = require_bitmapper();
|
|
1284998
|
+
var formatNormaliser = require_format_normaliser();
|
|
1284999
|
+
module4.exports = function(buffer, options2) {
|
|
1285000
|
+
if (!hasSyncZlib) {
|
|
1285001
|
+
throw new Error(
|
|
1285002
|
+
"To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0"
|
|
1285003
|
+
);
|
|
1285004
|
+
}
|
|
1285005
|
+
let err;
|
|
1285006
|
+
function handleError3(_err_) {
|
|
1285007
|
+
err = _err_;
|
|
1285008
|
+
}
|
|
1285009
|
+
let metaData;
|
|
1285010
|
+
function handleMetaData(_metaData_) {
|
|
1285011
|
+
metaData = _metaData_;
|
|
1285012
|
+
}
|
|
1285013
|
+
function handleTransColor(transColor) {
|
|
1285014
|
+
metaData.transColor = transColor;
|
|
1285015
|
+
}
|
|
1285016
|
+
function handlePalette(palette) {
|
|
1285017
|
+
metaData.palette = palette;
|
|
1285018
|
+
}
|
|
1285019
|
+
function handleSimpleTransparency() {
|
|
1285020
|
+
metaData.alpha = true;
|
|
1285021
|
+
}
|
|
1285022
|
+
let gamma;
|
|
1285023
|
+
function handleGamma(_gamma_) {
|
|
1285024
|
+
gamma = _gamma_;
|
|
1285025
|
+
}
|
|
1285026
|
+
let inflateDataList = [];
|
|
1285027
|
+
function handleInflateData(inflatedData2) {
|
|
1285028
|
+
inflateDataList.push(inflatedData2);
|
|
1285029
|
+
}
|
|
1285030
|
+
let reader = new SyncReader(buffer);
|
|
1285031
|
+
let parser4 = new Parser8(options2, {
|
|
1285032
|
+
read: reader.read.bind(reader),
|
|
1285033
|
+
error: handleError3,
|
|
1285034
|
+
metadata: handleMetaData,
|
|
1285035
|
+
gamma: handleGamma,
|
|
1285036
|
+
palette: handlePalette,
|
|
1285037
|
+
transColor: handleTransColor,
|
|
1285038
|
+
inflateData: handleInflateData,
|
|
1285039
|
+
simpleTransparency: handleSimpleTransparency
|
|
1285040
|
+
});
|
|
1285041
|
+
parser4.start();
|
|
1285042
|
+
reader.process();
|
|
1285043
|
+
if (err) {
|
|
1285044
|
+
throw err;
|
|
1285045
|
+
}
|
|
1285046
|
+
let inflateData = Buffer.concat(inflateDataList);
|
|
1285047
|
+
inflateDataList.length = 0;
|
|
1285048
|
+
let inflatedData;
|
|
1285049
|
+
if (metaData.interlace) {
|
|
1285050
|
+
inflatedData = zlib4.inflateSync(inflateData);
|
|
1285051
|
+
} else {
|
|
1285052
|
+
let rowSize = (metaData.width * metaData.bpp * metaData.depth + 7 >> 3) + 1;
|
|
1285053
|
+
let imageSize2 = rowSize * metaData.height;
|
|
1285054
|
+
inflatedData = inflateSync(inflateData, {
|
|
1285055
|
+
chunkSize: imageSize2,
|
|
1285056
|
+
maxLength: imageSize2
|
|
1285057
|
+
});
|
|
1285058
|
+
}
|
|
1285059
|
+
inflateData = null;
|
|
1285060
|
+
if (!inflatedData || !inflatedData.length) {
|
|
1285061
|
+
throw new Error("bad png - invalid inflate data response");
|
|
1285062
|
+
}
|
|
1285063
|
+
let unfilteredData = FilterSync.process(inflatedData, metaData);
|
|
1285064
|
+
inflateData = null;
|
|
1285065
|
+
let bitmapData = bitmapper.dataToBitMap(unfilteredData, metaData);
|
|
1285066
|
+
unfilteredData = null;
|
|
1285067
|
+
let normalisedBitmapData = formatNormaliser(
|
|
1285068
|
+
bitmapData,
|
|
1285069
|
+
metaData,
|
|
1285070
|
+
options2.skipRescale
|
|
1285071
|
+
);
|
|
1285072
|
+
metaData.data = normalisedBitmapData;
|
|
1285073
|
+
metaData.gamma = gamma || 0;
|
|
1285074
|
+
return metaData;
|
|
1285075
|
+
};
|
|
1285076
|
+
}
|
|
1285077
|
+
});
|
|
1285078
|
+
|
|
1285079
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-sync.js
|
|
1285080
|
+
var require_packer_sync = __commonJS({
|
|
1285081
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/packer-sync.js"(exports2, module4) {
|
|
1285082
|
+
"use strict";
|
|
1285083
|
+
var hasSyncZlib = true;
|
|
1285084
|
+
var zlib4 = require("zlib");
|
|
1285085
|
+
if (!zlib4.deflateSync) {
|
|
1285086
|
+
hasSyncZlib = false;
|
|
1285087
|
+
}
|
|
1285088
|
+
var constants2 = require_constants109();
|
|
1285089
|
+
var Packer = require_packer();
|
|
1285090
|
+
module4.exports = function(metaData, opt) {
|
|
1285091
|
+
if (!hasSyncZlib) {
|
|
1285092
|
+
throw new Error(
|
|
1285093
|
+
"To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0"
|
|
1285094
|
+
);
|
|
1285095
|
+
}
|
|
1285096
|
+
let options2 = opt || {};
|
|
1285097
|
+
let packer = new Packer(options2);
|
|
1285098
|
+
let chunks = [];
|
|
1285099
|
+
chunks.push(Buffer.from(constants2.PNG_SIGNATURE));
|
|
1285100
|
+
chunks.push(packer.packIHDR(metaData.width, metaData.height));
|
|
1285101
|
+
if (metaData.gamma) {
|
|
1285102
|
+
chunks.push(packer.packGAMA(metaData.gamma));
|
|
1285103
|
+
}
|
|
1285104
|
+
let filteredData = packer.filterData(
|
|
1285105
|
+
metaData.data,
|
|
1285106
|
+
metaData.width,
|
|
1285107
|
+
metaData.height
|
|
1285108
|
+
);
|
|
1285109
|
+
let compressedData = zlib4.deflateSync(
|
|
1285110
|
+
filteredData,
|
|
1285111
|
+
packer.getDeflateOptions()
|
|
1285112
|
+
);
|
|
1285113
|
+
filteredData = null;
|
|
1285114
|
+
if (!compressedData || !compressedData.length) {
|
|
1285115
|
+
throw new Error("bad png - invalid compressed data response");
|
|
1285116
|
+
}
|
|
1285117
|
+
chunks.push(packer.packIDAT(compressedData));
|
|
1285118
|
+
chunks.push(packer.packIEND());
|
|
1285119
|
+
return Buffer.concat(chunks);
|
|
1285120
|
+
};
|
|
1285121
|
+
}
|
|
1285122
|
+
});
|
|
1285123
|
+
|
|
1285124
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png-sync.js
|
|
1285125
|
+
var require_png_sync = __commonJS({
|
|
1285126
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png-sync.js"(exports2) {
|
|
1285127
|
+
"use strict";
|
|
1285128
|
+
var parse18 = require_parser_sync();
|
|
1285129
|
+
var pack = require_packer_sync();
|
|
1285130
|
+
exports2.read = function(buffer, options2) {
|
|
1285131
|
+
return parse18(buffer, options2 || {});
|
|
1285132
|
+
};
|
|
1285133
|
+
exports2.write = function(png, options2) {
|
|
1285134
|
+
return pack(png, options2);
|
|
1285135
|
+
};
|
|
1285136
|
+
}
|
|
1285137
|
+
});
|
|
1285138
|
+
|
|
1285139
|
+
// ../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png.js
|
|
1285140
|
+
var require_png2 = __commonJS({
|
|
1285141
|
+
"../../../node_modules/.pnpm/pngjs@7.0.0/node_modules/pngjs/lib/png.js"(exports2) {
|
|
1285142
|
+
"use strict";
|
|
1285143
|
+
var util4 = require("util");
|
|
1285144
|
+
var Stream5 = require("stream");
|
|
1285145
|
+
var Parser8 = require_parser_async();
|
|
1285146
|
+
var Packer = require_packer_async();
|
|
1285147
|
+
var PNGSync = require_png_sync();
|
|
1285148
|
+
var PNG2 = exports2.PNG = function(options2) {
|
|
1285149
|
+
Stream5.call(this);
|
|
1285150
|
+
options2 = options2 || {};
|
|
1285151
|
+
this.width = options2.width | 0;
|
|
1285152
|
+
this.height = options2.height | 0;
|
|
1285153
|
+
this.data = this.width > 0 && this.height > 0 ? Buffer.alloc(4 * this.width * this.height) : null;
|
|
1285154
|
+
if (options2.fill && this.data) {
|
|
1285155
|
+
this.data.fill(0);
|
|
1285156
|
+
}
|
|
1285157
|
+
this.gamma = 0;
|
|
1285158
|
+
this.readable = this.writable = true;
|
|
1285159
|
+
this._parser = new Parser8(options2);
|
|
1285160
|
+
this._parser.on("error", this.emit.bind(this, "error"));
|
|
1285161
|
+
this._parser.on("close", this._handleClose.bind(this));
|
|
1285162
|
+
this._parser.on("metadata", this._metadata.bind(this));
|
|
1285163
|
+
this._parser.on("gamma", this._gamma.bind(this));
|
|
1285164
|
+
this._parser.on(
|
|
1285165
|
+
"parsed",
|
|
1285166
|
+
function(data2) {
|
|
1285167
|
+
this.data = data2;
|
|
1285168
|
+
this.emit("parsed", data2);
|
|
1285169
|
+
}.bind(this)
|
|
1285170
|
+
);
|
|
1285171
|
+
this._packer = new Packer(options2);
|
|
1285172
|
+
this._packer.on("data", this.emit.bind(this, "data"));
|
|
1285173
|
+
this._packer.on("end", this.emit.bind(this, "end"));
|
|
1285174
|
+
this._parser.on("close", this._handleClose.bind(this));
|
|
1285175
|
+
this._packer.on("error", this.emit.bind(this, "error"));
|
|
1285176
|
+
};
|
|
1285177
|
+
util4.inherits(PNG2, Stream5);
|
|
1285178
|
+
PNG2.sync = PNGSync;
|
|
1285179
|
+
PNG2.prototype.pack = function() {
|
|
1285180
|
+
if (!this.data || !this.data.length) {
|
|
1285181
|
+
this.emit("error", "No data provided");
|
|
1285182
|
+
return this;
|
|
1285183
|
+
}
|
|
1285184
|
+
process.nextTick(
|
|
1285185
|
+
function() {
|
|
1285186
|
+
this._packer.pack(this.data, this.width, this.height, this.gamma);
|
|
1285187
|
+
}.bind(this)
|
|
1285188
|
+
);
|
|
1285189
|
+
return this;
|
|
1285190
|
+
};
|
|
1285191
|
+
PNG2.prototype.parse = function(data2, callback) {
|
|
1285192
|
+
if (callback) {
|
|
1285193
|
+
let onParsed, onError2;
|
|
1285194
|
+
onParsed = function(parsedData) {
|
|
1285195
|
+
this.removeListener("error", onError2);
|
|
1285196
|
+
this.data = parsedData;
|
|
1285197
|
+
callback(null, this);
|
|
1285198
|
+
}.bind(this);
|
|
1285199
|
+
onError2 = function(err) {
|
|
1285200
|
+
this.removeListener("parsed", onParsed);
|
|
1285201
|
+
callback(err, null);
|
|
1285202
|
+
}.bind(this);
|
|
1285203
|
+
this.once("parsed", onParsed);
|
|
1285204
|
+
this.once("error", onError2);
|
|
1285205
|
+
}
|
|
1285206
|
+
this.end(data2);
|
|
1285207
|
+
return this;
|
|
1285208
|
+
};
|
|
1285209
|
+
PNG2.prototype.write = function(data2) {
|
|
1285210
|
+
this._parser.write(data2);
|
|
1285211
|
+
return true;
|
|
1285212
|
+
};
|
|
1285213
|
+
PNG2.prototype.end = function(data2) {
|
|
1285214
|
+
this._parser.end(data2);
|
|
1285215
|
+
};
|
|
1285216
|
+
PNG2.prototype._metadata = function(metadata) {
|
|
1285217
|
+
this.width = metadata.width;
|
|
1285218
|
+
this.height = metadata.height;
|
|
1285219
|
+
this.emit("metadata", metadata);
|
|
1285220
|
+
};
|
|
1285221
|
+
PNG2.prototype._gamma = function(gamma) {
|
|
1285222
|
+
this.gamma = gamma;
|
|
1285223
|
+
};
|
|
1285224
|
+
PNG2.prototype._handleClose = function() {
|
|
1285225
|
+
if (!this._parser.writable && !this._packer.readable) {
|
|
1285226
|
+
this.emit("close");
|
|
1285227
|
+
}
|
|
1285228
|
+
};
|
|
1285229
|
+
PNG2.bitblt = function(src, dst, srcX, srcY, width, height3, deltaX, deltaY) {
|
|
1285230
|
+
srcX |= 0;
|
|
1285231
|
+
srcY |= 0;
|
|
1285232
|
+
width |= 0;
|
|
1285233
|
+
height3 |= 0;
|
|
1285234
|
+
deltaX |= 0;
|
|
1285235
|
+
deltaY |= 0;
|
|
1285236
|
+
if (srcX > src.width || srcY > src.height || srcX + width > src.width || srcY + height3 > src.height) {
|
|
1285237
|
+
throw new Error("bitblt reading outside image");
|
|
1285238
|
+
}
|
|
1285239
|
+
if (deltaX > dst.width || deltaY > dst.height || deltaX + width > dst.width || deltaY + height3 > dst.height) {
|
|
1285240
|
+
throw new Error("bitblt writing outside image");
|
|
1285241
|
+
}
|
|
1285242
|
+
for (let y23 = 0; y23 < height3; y23++) {
|
|
1285243
|
+
src.data.copy(
|
|
1285244
|
+
dst.data,
|
|
1285245
|
+
(deltaY + y23) * dst.width + deltaX << 2,
|
|
1285246
|
+
(srcY + y23) * src.width + srcX << 2,
|
|
1285247
|
+
(srcY + y23) * src.width + srcX + width << 2
|
|
1285248
|
+
);
|
|
1285249
|
+
}
|
|
1285250
|
+
};
|
|
1285251
|
+
PNG2.prototype.bitblt = function(dst, srcX, srcY, width, height3, deltaX, deltaY) {
|
|
1285252
|
+
PNG2.bitblt(this, dst, srcX, srcY, width, height3, deltaX, deltaY);
|
|
1285253
|
+
return this;
|
|
1285254
|
+
};
|
|
1285255
|
+
PNG2.adjustGamma = function(src) {
|
|
1285256
|
+
if (src.gamma) {
|
|
1285257
|
+
for (let y23 = 0; y23 < src.height; y23++) {
|
|
1285258
|
+
for (let x15 = 0; x15 < src.width; x15++) {
|
|
1285259
|
+
let idx = src.width * y23 + x15 << 2;
|
|
1285260
|
+
for (let i11 = 0; i11 < 3; i11++) {
|
|
1285261
|
+
let sample = src.data[idx + i11] / 255;
|
|
1285262
|
+
sample = Math.pow(sample, 1 / 2.2 / src.gamma);
|
|
1285263
|
+
src.data[idx + i11] = Math.round(sample * 255);
|
|
1285264
|
+
}
|
|
1285265
|
+
}
|
|
1285266
|
+
}
|
|
1285267
|
+
src.gamma = 0;
|
|
1285268
|
+
}
|
|
1285269
|
+
};
|
|
1285270
|
+
PNG2.prototype.adjustGamma = function() {
|
|
1285271
|
+
PNG2.adjustGamma(this);
|
|
1285272
|
+
};
|
|
1285273
|
+
}
|
|
1285274
|
+
});
|
|
1285275
|
+
|
|
1283188
1285276
|
// ../../../node_modules/.pnpm/validate-npm-package-name@5.0.1/node_modules/validate-npm-package-name/lib/index.js
|
|
1283189
1285277
|
var require_lib20 = __commonJS({
|
|
1283190
1285278
|
"../../../node_modules/.pnpm/validate-npm-package-name@5.0.1/node_modules/validate-npm-package-name/lib/index.js"(exports2, module4) {
|
|
@@ -1286964,7 +1289052,7 @@ var require_errors154 = __commonJS({
|
|
|
1286964
1289052
|
});
|
|
1286965
1289053
|
|
|
1286966
1289054
|
// ../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/core/constants.js
|
|
1286967
|
-
var
|
|
1289055
|
+
var require_constants110 = __commonJS({
|
|
1286968
1289056
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/core/constants.js"(exports2, module4) {
|
|
1286969
1289057
|
"use strict";
|
|
1286970
1289058
|
var headerNameLowerCasedRecord = {};
|
|
@@ -1287085,7 +1289173,7 @@ var require_tree = __commonJS({
|
|
|
1287085
1289173
|
var {
|
|
1287086
1289174
|
wellknownHeaderNames,
|
|
1287087
1289175
|
headerNameLowerCasedRecord
|
|
1287088
|
-
} =
|
|
1289176
|
+
} = require_constants110();
|
|
1287089
1289177
|
var TstNode = class _TstNode {
|
|
1287090
1289178
|
/** @type {any} */
|
|
1287091
1289179
|
value = null;
|
|
@@ -1287232,7 +1289320,7 @@ var require_util10 = __commonJS({
|
|
|
1287232
1289320
|
var { stringify: stringify5 } = require("querystring");
|
|
1287233
1289321
|
var { EventEmitter: EE3 } = require("events");
|
|
1287234
1289322
|
var { InvalidArgumentError } = require_errors154();
|
|
1287235
|
-
var { headerNameLowerCasedRecord } =
|
|
1289323
|
+
var { headerNameLowerCasedRecord } = require_constants110();
|
|
1287236
1289324
|
var { tree } = require_tree();
|
|
1287237
1289325
|
var [nodeMajor, nodeMinor] = process.versions.node.split(".").map((v21) => Number(v21));
|
|
1287238
1289326
|
var BodyAsyncIterable = class {
|
|
@@ -1287933,7 +1290021,7 @@ var require_request4 = __commonJS({
|
|
|
1287933
1290021
|
normalizedMethodRecords
|
|
1287934
1290022
|
} = require_util10();
|
|
1287935
1290023
|
var { channels } = require_diagnostics();
|
|
1287936
|
-
var { headerNameLowerCasedRecord } =
|
|
1290024
|
+
var { headerNameLowerCasedRecord } = require_constants110();
|
|
1287937
1290025
|
var invalidPathRegex = /[^\u0021-\u00ff]/;
|
|
1287938
1290026
|
var kHandler = Symbol("handler");
|
|
1287939
1290027
|
var Request9 = class {
|
|
@@ -1288881,7 +1290969,7 @@ var require_utils20 = __commonJS({
|
|
|
1288881
1290969
|
});
|
|
1288882
1290970
|
|
|
1288883
1290971
|
// ../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/llhttp/constants.js
|
|
1288884
|
-
var
|
|
1290972
|
+
var require_constants111 = __commonJS({
|
|
1288885
1290973
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/llhttp/constants.js"(exports2) {
|
|
1288886
1290974
|
"use strict";
|
|
1288887
1290975
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -1289220,7 +1291308,7 @@ var require_llhttp_simd_wasm = __commonJS({
|
|
|
1289220
1291308
|
});
|
|
1289221
1291309
|
|
|
1289222
1291310
|
// ../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/fetch/constants.js
|
|
1289223
|
-
var
|
|
1291311
|
+
var require_constants112 = __commonJS({
|
|
1289224
1291312
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/fetch/constants.js"(exports2, module4) {
|
|
1289225
1291313
|
"use strict";
|
|
1289226
1291314
|
var corsSafeListedMethods = (
|
|
@@ -1290250,7 +1292338,7 @@ var require_util11 = __commonJS({
|
|
|
1290250
1292338
|
"use strict";
|
|
1290251
1292339
|
var { Transform } = require("stream");
|
|
1290252
1292340
|
var zlib4 = require("zlib");
|
|
1290253
|
-
var { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } =
|
|
1292341
|
+
var { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = require_constants112();
|
|
1290254
1292342
|
var { getGlobalOrigin } = require_global();
|
|
1290255
1292343
|
var { collectASequenceOfCodePoints, collectAnHTTPQuotedString, removeChars, parseMIMEType } = require_data_url();
|
|
1290256
1292344
|
var { performance: performance2 } = require("perf_hooks");
|
|
@@ -1291956,7 +1294044,7 @@ var require_client_h1 = __commonJS({
|
|
|
1291956
1294044
|
kResume,
|
|
1291957
1294045
|
kHTTPContext
|
|
1291958
1294046
|
} = require_symbols();
|
|
1291959
|
-
var constants2 =
|
|
1294047
|
+
var constants2 = require_constants111();
|
|
1291960
1294048
|
var EMPTY_BUF = Buffer.alloc(0);
|
|
1291961
1294049
|
var FastBuffer = Buffer[Symbol.species];
|
|
1291962
1294050
|
var addListener = util4.addListener;
|
|
@@ -1298367,7 +1300455,7 @@ var require_response2 = __commonJS({
|
|
|
1298367
1300455
|
var {
|
|
1298368
1300456
|
redirectStatusSet,
|
|
1298369
1300457
|
nullBodyStatus
|
|
1298370
|
-
} =
|
|
1300458
|
+
} = require_constants112();
|
|
1298371
1300459
|
var { kState, kHeaders } = require_symbols2();
|
|
1298372
1300460
|
var { webidl } = require_webidl();
|
|
1298373
1300461
|
var { FormData: FormData6 } = require_formdata();
|
|
@@ -1298809,7 +1300897,7 @@ var require_request5 = __commonJS({
|
|
|
1298809
1300897
|
requestCredentials,
|
|
1298810
1300898
|
requestCache,
|
|
1298811
1300899
|
requestDuplex
|
|
1298812
|
-
} =
|
|
1300900
|
+
} = require_constants112();
|
|
1298813
1300901
|
var { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util4;
|
|
1298814
1300902
|
var { kHeaders, kSignal, kState, kDispatcher } = require_symbols2();
|
|
1298815
1300903
|
var { webidl } = require_webidl();
|
|
@@ -1299539,7 +1301627,7 @@ var require_fetch = __commonJS({
|
|
|
1299539
1301627
|
safeMethodsSet,
|
|
1299540
1301628
|
requestBodyHeader,
|
|
1299541
1301629
|
subresourceSet
|
|
1299542
|
-
} =
|
|
1301630
|
+
} = require_constants112();
|
|
1299543
1301631
|
var EE3 = require("events");
|
|
1299544
1301632
|
var { Readable: Readable6, pipeline: pipeline5, finished: finished2 } = require("stream");
|
|
1299545
1301633
|
var { addAbortListener, isErrored, isReadable: isReadable2, bufferToLowerCasedHeaderName } = require_util10();
|
|
@@ -1302057,7 +1304145,7 @@ var require_cachestorage = __commonJS({
|
|
|
1302057
1304145
|
});
|
|
1302058
1304146
|
|
|
1302059
1304147
|
// ../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/cookies/constants.js
|
|
1302060
|
-
var
|
|
1304148
|
+
var require_constants113 = __commonJS({
|
|
1302061
1304149
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/cookies/constants.js"(exports2, module4) {
|
|
1302062
1304150
|
"use strict";
|
|
1302063
1304151
|
var maxAttributeValueSize = 1024;
|
|
@@ -1302243,7 +1304331,7 @@ var require_util15 = __commonJS({
|
|
|
1302243
1304331
|
var require_parse5 = __commonJS({
|
|
1302244
1304332
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/cookies/parse.js"(exports2, module4) {
|
|
1302245
1304333
|
"use strict";
|
|
1302246
|
-
var { maxNameValuePairSize, maxAttributeValueSize } =
|
|
1304334
|
+
var { maxNameValuePairSize, maxAttributeValueSize } = require_constants113();
|
|
1302247
1304335
|
var { isCTLExcludingHtab } = require_util15();
|
|
1302248
1304336
|
var { collectASequenceOfCodePointsFast } = require_data_url();
|
|
1302249
1304337
|
var assert12 = require("assert");
|
|
@@ -1302775,7 +1304863,7 @@ var require_events2 = __commonJS({
|
|
|
1302775
1304863
|
});
|
|
1302776
1304864
|
|
|
1302777
1304865
|
// ../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/websocket/constants.js
|
|
1302778
|
-
var
|
|
1304866
|
+
var require_constants114 = __commonJS({
|
|
1302779
1304867
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/websocket/constants.js"(exports2, module4) {
|
|
1302780
1304868
|
"use strict";
|
|
1302781
1304869
|
var uid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
@@ -1302853,7 +1304941,7 @@ var require_util16 = __commonJS({
|
|
|
1302853
1304941
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/websocket/util.js"(exports2, module4) {
|
|
1302854
1304942
|
"use strict";
|
|
1302855
1304943
|
var { kReadyState, kController, kResponse, kBinaryType, kWebSocketURL } = require_symbols5();
|
|
1302856
|
-
var { states, opcodes } =
|
|
1304944
|
+
var { states, opcodes } = require_constants114();
|
|
1302857
1304945
|
var { ErrorEvent, createFastMessageEvent } = require_events2();
|
|
1302858
1304946
|
var { isUtf8 } = require("buffer");
|
|
1302859
1304947
|
var { collectASequenceOfCodePointsFast, removeHTTPWhitespace } = require_data_url();
|
|
@@ -1303021,7 +1305109,7 @@ var require_util16 = __commonJS({
|
|
|
1303021
1305109
|
var require_frame = __commonJS({
|
|
1303022
1305110
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/websocket/frame.js"(exports2, module4) {
|
|
1303023
1305111
|
"use strict";
|
|
1303024
|
-
var { maxUnsigned16Bit } =
|
|
1305112
|
+
var { maxUnsigned16Bit } = require_constants114();
|
|
1303025
1305113
|
var BUFFER_SIZE = 16386;
|
|
1303026
1305114
|
var crypto5;
|
|
1303027
1305115
|
var buffer = null;
|
|
@@ -1303098,7 +1305186,7 @@ var require_frame = __commonJS({
|
|
|
1303098
1305186
|
var require_connection = __commonJS({
|
|
1303099
1305187
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/websocket/connection.js"(exports2, module4) {
|
|
1303100
1305188
|
"use strict";
|
|
1303101
|
-
var { uid, states, sentCloseFrameState, emptyBuffer, opcodes } =
|
|
1305189
|
+
var { uid, states, sentCloseFrameState, emptyBuffer, opcodes } = require_constants114();
|
|
1303102
1305190
|
var {
|
|
1303103
1305191
|
kReadyState,
|
|
1303104
1305192
|
kSentClose,
|
|
@@ -1303340,7 +1305428,7 @@ var require_receiver2 = __commonJS({
|
|
|
1303340
1305428
|
"use strict";
|
|
1303341
1305429
|
var { Writable: Writable2 } = require("stream");
|
|
1303342
1305430
|
var assert12 = require("assert");
|
|
1303343
|
-
var { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } =
|
|
1305431
|
+
var { parserStates, opcodes, states, emptyBuffer, sentCloseFrameState } = require_constants114();
|
|
1303344
1305432
|
var { kReadyState, kSentClose, kResponse, kReceivedClose } = require_symbols5();
|
|
1303345
1305433
|
var { channels } = require_diagnostics();
|
|
1303346
1305434
|
var {
|
|
@@ -1303644,7 +1305732,7 @@ var require_sender2 = __commonJS({
|
|
|
1303644
1305732
|
"../../../node_modules/.pnpm/undici@6.23.0/node_modules/undici/lib/web/websocket/sender.js"(exports2, module4) {
|
|
1303645
1305733
|
"use strict";
|
|
1303646
1305734
|
var { WebsocketFrameSend } = require_frame();
|
|
1303647
|
-
var { opcodes, sendHints } =
|
|
1305735
|
+
var { opcodes, sendHints } = require_constants114();
|
|
1303648
1305736
|
var FixedQueue = require_fixed_queue();
|
|
1303649
1305737
|
var FastBuffer = Buffer[Symbol.species];
|
|
1303650
1305738
|
var SendQueue = class {
|
|
@@ -1303728,7 +1305816,7 @@ var require_websocket67 = __commonJS({
|
|
|
1303728
1305816
|
var { webidl } = require_webidl();
|
|
1303729
1305817
|
var { URLSerializer } = require_data_url();
|
|
1303730
1305818
|
var { environmentSettingsObject } = require_util11();
|
|
1303731
|
-
var { staticPropertyDescriptors, states, sentCloseFrameState, sendHints } =
|
|
1305819
|
+
var { staticPropertyDescriptors, states, sentCloseFrameState, sendHints } = require_constants114();
|
|
1303732
1305820
|
var {
|
|
1303733
1305821
|
kWebSocketURL,
|
|
1303734
1305822
|
kReadyState,
|
|
@@ -1589023,13 +1591111,13 @@ async function removeInvalidAiExamples({ sourceFilePath, context: context2 }) {
|
|
|
1589023
1591111
|
}
|
|
1589024
1591112
|
}
|
|
1589025
1591113
|
}
|
|
1589026
|
-
const { writeFile:
|
|
1591114
|
+
const { writeFile: writeFile79 } = await import("fs/promises");
|
|
1589027
1591115
|
const yamlContent = jsYaml.dump(parsed, {
|
|
1589028
1591116
|
indent: 2,
|
|
1589029
1591117
|
lineWidth: -1,
|
|
1589030
1591118
|
noRefs: true
|
|
1589031
1591119
|
});
|
|
1589032
|
-
await
|
|
1591120
|
+
await writeFile79(overrideFilePath, yamlContent, "utf-8");
|
|
1589033
1591121
|
context2.logger.info(`Removed ${validationResult.invalidCount} invalid AI examples from ai_examples_override.yml`);
|
|
1589034
1591122
|
return {
|
|
1589035
1591123
|
removedCount: validationResult.invalidCount,
|
|
@@ -1652583,7 +1654671,7 @@ var AccessTokenPosthogManager = class {
|
|
|
1652583
1654671
|
properties: {
|
|
1652584
1654672
|
...event,
|
|
1652585
1654673
|
...event.properties,
|
|
1652586
|
-
version: "3.
|
|
1654674
|
+
version: "3.55.0",
|
|
1652587
1654675
|
usingAccessToken: true
|
|
1652588
1654676
|
}
|
|
1652589
1654677
|
});
|
|
@@ -1652633,7 +1654721,7 @@ var UserPosthogManager = class {
|
|
|
1652633
1654721
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
1652634
1654722
|
event: "CLI",
|
|
1652635
1654723
|
properties: {
|
|
1652636
|
-
version: "3.
|
|
1654724
|
+
version: "3.55.0",
|
|
1652637
1654725
|
...event,
|
|
1652638
1654726
|
...event.properties,
|
|
1652639
1654727
|
usingAccessToken: false,
|
|
@@ -1678186,12 +1680274,12 @@ var import_node_path20 = __toESM(require("path"), 1);
|
|
|
1678186
1680274
|
|
|
1678187
1680275
|
// ../../../node_modules/.pnpm/@puppeteer+browsers@2.10.10/node_modules/@puppeteer/browsers/lib/esm/browser-data/types.js
|
|
1678188
1680276
|
var Browser3;
|
|
1678189
|
-
(function(
|
|
1678190
|
-
|
|
1678191
|
-
|
|
1678192
|
-
|
|
1678193
|
-
|
|
1678194
|
-
|
|
1680277
|
+
(function(Browser5) {
|
|
1680278
|
+
Browser5["CHROME"] = "chrome";
|
|
1680279
|
+
Browser5["CHROMEHEADLESSSHELL"] = "chrome-headless-shell";
|
|
1680280
|
+
Browser5["CHROMIUM"] = "chromium";
|
|
1680281
|
+
Browser5["FIREFOX"] = "firefox";
|
|
1680282
|
+
Browser5["CHROMEDRIVER"] = "chromedriver";
|
|
1678195
1680283
|
})(Browser3 || (Browser3 = {}));
|
|
1678196
1680284
|
var BrowserPlatform;
|
|
1678197
1680285
|
(function(BrowserPlatform2) {
|
|
@@ -1685775,7 +1687863,7 @@ var CliContext = class {
|
|
|
1685775
1687863
|
if (false) {
|
|
1685776
1687864
|
this.logger.error("CLI_VERSION is not defined");
|
|
1685777
1687865
|
}
|
|
1685778
|
-
return "3.
|
|
1687866
|
+
return "3.55.0";
|
|
1685779
1687867
|
}
|
|
1685780
1687868
|
getCliName() {
|
|
1685781
1687869
|
if (false) {
|
|
@@ -1688888,7 +1690976,7 @@ var import_path54 = __toESM(require("path"), 1);
|
|
|
1688888
1690976
|
var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
1688889
1690977
|
var LOGS_FOLDER_NAME = "logs";
|
|
1688890
1690978
|
function getCliSource() {
|
|
1688891
|
-
const version7 = "3.
|
|
1690979
|
+
const version7 = "3.55.0";
|
|
1688892
1690980
|
return `cli@${version7}`;
|
|
1688893
1690981
|
}
|
|
1688894
1690982
|
var DebugLogger = class {
|
|
@@ -1704407,7 +1706495,7 @@ var MDX_NODE_TYPES = [
|
|
|
1704407
1706495
|
"mdxTextExpression",
|
|
1704408
1706496
|
"mdxjsEsm"
|
|
1704409
1706497
|
];
|
|
1704410
|
-
function collectLinksAndSources({ readFile:
|
|
1706498
|
+
function collectLinksAndSources({ readFile: readFile89 = (path86) => (0, import_node_fs27.readFileSync)(path86, "utf-8"), ...opts }) {
|
|
1704411
1706499
|
const visitedAbsoluteFilepaths = /* @__PURE__ */ new Set();
|
|
1704412
1706500
|
const contentQueue = [opts];
|
|
1704413
1706501
|
const links = [];
|
|
@@ -1704445,7 +1706533,7 @@ function collectLinksAndSources({ readFile: readFile88 = (path86) => (0, import_
|
|
|
1704445
1706533
|
const resolvedImportPath = resolve5(dirname4(absoluteFilepath), importPath);
|
|
1704446
1706534
|
if (resolvedImportPath.endsWith(".mdx") || resolvedImportPath.endsWith(".md")) {
|
|
1704447
1706535
|
contentQueue.push({
|
|
1704448
|
-
content:
|
|
1706536
|
+
content: readFile89(resolvedImportPath),
|
|
1704449
1706537
|
absoluteFilepath: resolvedImportPath
|
|
1704450
1706538
|
});
|
|
1704451
1706539
|
}
|
|
@@ -1704488,7 +1706576,7 @@ function collectLinksAndSources({ readFile: readFile88 = (path86) => (0, import_
|
|
|
1704488
1706576
|
if (absoluteFilepath && typeof src === "string") {
|
|
1704489
1706577
|
const resolvedImportPath = resolve5(dirname4(absoluteFilepath), src);
|
|
1704490
1706578
|
contentQueue.push({
|
|
1704491
|
-
content:
|
|
1706579
|
+
content: readFile89(resolvedImportPath),
|
|
1704492
1706580
|
absoluteFilepath: resolvedImportPath
|
|
1704493
1706581
|
});
|
|
1704494
1706582
|
}
|
|
@@ -1705869,6 +1707957,395 @@ async function previewDocsWorkspace({
|
|
|
1705869
1707957
|
return;
|
|
1705870
1707958
|
}
|
|
1705871
1707959
|
|
|
1707960
|
+
// src/commands/docs-diff/docsDiff.ts
|
|
1707961
|
+
var import_promises110 = require("fs/promises");
|
|
1707962
|
+
var import_pngjs = __toESM(require_png2(), 1);
|
|
1707963
|
+
async function getSlugForFiles({
|
|
1707964
|
+
previewUrl,
|
|
1707965
|
+
files,
|
|
1707966
|
+
token
|
|
1707967
|
+
}) {
|
|
1707968
|
+
const filesParam = files.join(",");
|
|
1707969
|
+
const url3 = `https://${previewUrl}/api/fern-docs/get-slug-for-file?files=${encodeURIComponent(filesParam)}`;
|
|
1707970
|
+
const response = await fetch(url3, {
|
|
1707971
|
+
method: "GET",
|
|
1707972
|
+
headers: {
|
|
1707973
|
+
FERN_TOKEN: token
|
|
1707974
|
+
}
|
|
1707975
|
+
});
|
|
1707976
|
+
if (!response.ok) {
|
|
1707977
|
+
const errorText = await response.text();
|
|
1707978
|
+
throw new Error(`Failed to get slugs for files: ${response.status} ${response.statusText} - ${errorText}`);
|
|
1707979
|
+
}
|
|
1707980
|
+
return await response.json();
|
|
1707981
|
+
}
|
|
1707982
|
+
async function captureScreenshot({
|
|
1707983
|
+
browser,
|
|
1707984
|
+
url: url3,
|
|
1707985
|
+
outputPath,
|
|
1707986
|
+
token
|
|
1707987
|
+
}) {
|
|
1707988
|
+
const page = await browser.newPage();
|
|
1707989
|
+
try {
|
|
1707990
|
+
await page.setViewport({
|
|
1707991
|
+
width: 1440,
|
|
1707992
|
+
height: 900,
|
|
1707993
|
+
deviceScaleFactor: 2
|
|
1707994
|
+
});
|
|
1707995
|
+
if (token) {
|
|
1707996
|
+
await page.setExtraHTTPHeaders({
|
|
1707997
|
+
FERN_TOKEN: token
|
|
1707998
|
+
});
|
|
1707999
|
+
}
|
|
1708000
|
+
const response = await page.goto(url3, {
|
|
1708001
|
+
waitUntil: "networkidle2",
|
|
1708002
|
+
timeout: 3e4
|
|
1708003
|
+
});
|
|
1708004
|
+
if (!response || response.status() === 404) {
|
|
1708005
|
+
await page.close();
|
|
1708006
|
+
return false;
|
|
1708007
|
+
}
|
|
1708008
|
+
await page.screenshot({
|
|
1708009
|
+
path: outputPath,
|
|
1708010
|
+
fullPage: true
|
|
1708011
|
+
});
|
|
1708012
|
+
await page.close();
|
|
1708013
|
+
return true;
|
|
1708014
|
+
} catch (error49) {
|
|
1708015
|
+
await page.close();
|
|
1708016
|
+
return false;
|
|
1708017
|
+
}
|
|
1708018
|
+
}
|
|
1708019
|
+
function slugToFilename(slug) {
|
|
1708020
|
+
return slug.replace(/\//g, "-");
|
|
1708021
|
+
}
|
|
1708022
|
+
function findChangedRegions(beforeData, afterData, width, height3, threshold = 0.1, minArea = 5e3, gapRows = 200) {
|
|
1708023
|
+
const thresholdValue = Math.floor(threshold * 255);
|
|
1708024
|
+
const rowHasDiff = new Array(height3).fill(false);
|
|
1708025
|
+
for (let y24 = 0; y24 < height3; y24++) {
|
|
1708026
|
+
let has3 = false;
|
|
1708027
|
+
for (let x15 = 0; x15 < width; x15++) {
|
|
1708028
|
+
const idx = (y24 * width + x15) * 4;
|
|
1708029
|
+
const rDiff = Math.abs((beforeData[idx] ?? 0) - (afterData[idx] ?? 0));
|
|
1708030
|
+
const gDiff = Math.abs((beforeData[idx + 1] ?? 0) - (afterData[idx + 1] ?? 0));
|
|
1708031
|
+
const bDiff = Math.abs((beforeData[idx + 2] ?? 0) - (afterData[idx + 2] ?? 0));
|
|
1708032
|
+
if (rDiff > thresholdValue || gDiff > thresholdValue || bDiff > thresholdValue) {
|
|
1708033
|
+
has3 = true;
|
|
1708034
|
+
break;
|
|
1708035
|
+
}
|
|
1708036
|
+
}
|
|
1708037
|
+
rowHasDiff[y24] = has3;
|
|
1708038
|
+
}
|
|
1708039
|
+
const boxes = [];
|
|
1708040
|
+
let y23 = 0;
|
|
1708041
|
+
while (y23 < height3) {
|
|
1708042
|
+
while (y23 < height3 && !rowHasDiff[y23]) {
|
|
1708043
|
+
y23++;
|
|
1708044
|
+
}
|
|
1708045
|
+
if (y23 >= height3) {
|
|
1708046
|
+
break;
|
|
1708047
|
+
}
|
|
1708048
|
+
let startY = y23;
|
|
1708049
|
+
let lastDiffY = y23;
|
|
1708050
|
+
y23++;
|
|
1708051
|
+
while (y23 < height3) {
|
|
1708052
|
+
if (rowHasDiff[y23]) {
|
|
1708053
|
+
lastDiffY = y23;
|
|
1708054
|
+
y23++;
|
|
1708055
|
+
} else {
|
|
1708056
|
+
let gap = 0;
|
|
1708057
|
+
while (y23 < height3 && !rowHasDiff[y23] && gap < gapRows) {
|
|
1708058
|
+
gap++;
|
|
1708059
|
+
y23++;
|
|
1708060
|
+
}
|
|
1708061
|
+
if (y23 < height3 && rowHasDiff[y23]) {
|
|
1708062
|
+
lastDiffY = y23;
|
|
1708063
|
+
y23++;
|
|
1708064
|
+
} else {
|
|
1708065
|
+
break;
|
|
1708066
|
+
}
|
|
1708067
|
+
}
|
|
1708068
|
+
}
|
|
1708069
|
+
const endY = lastDiffY;
|
|
1708070
|
+
let minX = width;
|
|
1708071
|
+
let maxX = 0;
|
|
1708072
|
+
for (let yy = startY; yy <= endY; yy++) {
|
|
1708073
|
+
for (let xx = 0; xx < width; xx++) {
|
|
1708074
|
+
const idx = (yy * width + xx) * 4;
|
|
1708075
|
+
const rDiff = Math.abs((beforeData[idx] ?? 0) - (afterData[idx] ?? 0));
|
|
1708076
|
+
const gDiff = Math.abs((beforeData[idx + 1] ?? 0) - (afterData[idx + 1] ?? 0));
|
|
1708077
|
+
const bDiff = Math.abs((beforeData[idx + 2] ?? 0) - (afterData[idx + 2] ?? 0));
|
|
1708078
|
+
if (rDiff > thresholdValue || gDiff > thresholdValue || bDiff > thresholdValue) {
|
|
1708079
|
+
if (xx < minX) {
|
|
1708080
|
+
minX = xx;
|
|
1708081
|
+
}
|
|
1708082
|
+
if (xx > maxX) {
|
|
1708083
|
+
maxX = xx;
|
|
1708084
|
+
}
|
|
1708085
|
+
}
|
|
1708086
|
+
}
|
|
1708087
|
+
}
|
|
1708088
|
+
if (minX <= maxX) {
|
|
1708089
|
+
const box = { minX, minY: startY, maxX, maxY: endY };
|
|
1708090
|
+
const area = (box.maxX - box.minX) * (box.maxY - box.minY);
|
|
1708091
|
+
if (area >= minArea) {
|
|
1708092
|
+
boxes.push(box);
|
|
1708093
|
+
}
|
|
1708094
|
+
}
|
|
1708095
|
+
}
|
|
1708096
|
+
return boxes;
|
|
1708097
|
+
}
|
|
1708098
|
+
function cropPng(png, box, padding = 50) {
|
|
1708099
|
+
const x1 = Math.max(0, box.minX - padding);
|
|
1708100
|
+
const y1 = Math.max(0, box.minY - padding);
|
|
1708101
|
+
const x23 = Math.min(png.width, box.maxX + padding);
|
|
1708102
|
+
const y23 = Math.min(png.height, box.maxY + padding);
|
|
1708103
|
+
const croppedWidth = x23 - x1;
|
|
1708104
|
+
const croppedHeight = y23 - y1;
|
|
1708105
|
+
const cropped = new import_pngjs.PNG({ width: croppedWidth, height: croppedHeight });
|
|
1708106
|
+
import_pngjs.PNG.bitblt(png, cropped, x1, y1, croppedWidth, croppedHeight, 0, 0);
|
|
1708107
|
+
return cropped;
|
|
1708108
|
+
}
|
|
1708109
|
+
function drawBorder(png, x15, y23, w19, h14, color3, thickness) {
|
|
1708110
|
+
const [r23, g18, b18, a10] = color3;
|
|
1708111
|
+
for (let t2 = 0; t2 < thickness; t2++) {
|
|
1708112
|
+
for (let xx = x15; xx < x15 + w19; xx++) {
|
|
1708113
|
+
const topIdx = ((y23 + t2) * png.width + xx) * 4;
|
|
1708114
|
+
const botIdx = ((y23 + h14 - 1 - t2) * png.width + xx) * 4;
|
|
1708115
|
+
png.data[topIdx] = r23;
|
|
1708116
|
+
png.data[topIdx + 1] = g18;
|
|
1708117
|
+
png.data[topIdx + 2] = b18;
|
|
1708118
|
+
png.data[topIdx + 3] = a10;
|
|
1708119
|
+
png.data[botIdx] = r23;
|
|
1708120
|
+
png.data[botIdx + 1] = g18;
|
|
1708121
|
+
png.data[botIdx + 2] = b18;
|
|
1708122
|
+
png.data[botIdx + 3] = a10;
|
|
1708123
|
+
}
|
|
1708124
|
+
for (let yy = y23; yy < y23 + h14; yy++) {
|
|
1708125
|
+
const leftIdx = (yy * png.width + (x15 + t2)) * 4;
|
|
1708126
|
+
const rightIdx = (yy * png.width + (x15 + w19 - 1 - t2)) * 4;
|
|
1708127
|
+
png.data[leftIdx] = r23;
|
|
1708128
|
+
png.data[leftIdx + 1] = g18;
|
|
1708129
|
+
png.data[leftIdx + 2] = b18;
|
|
1708130
|
+
png.data[leftIdx + 3] = a10;
|
|
1708131
|
+
png.data[rightIdx] = r23;
|
|
1708132
|
+
png.data[rightIdx + 1] = g18;
|
|
1708133
|
+
png.data[rightIdx + 2] = b18;
|
|
1708134
|
+
png.data[rightIdx + 3] = a10;
|
|
1708135
|
+
}
|
|
1708136
|
+
}
|
|
1708137
|
+
}
|
|
1708138
|
+
function createSideBySideComparison(beforePng, afterPng, gap = 20, highlight = true) {
|
|
1708139
|
+
const totalWidth = beforePng.width + gap + afterPng.width;
|
|
1708140
|
+
const totalHeight = Math.max(beforePng.height, afterPng.height);
|
|
1708141
|
+
const combined = new import_pngjs.PNG({ width: totalWidth, height: totalHeight });
|
|
1708142
|
+
combined.data.fill(255);
|
|
1708143
|
+
import_pngjs.PNG.bitblt(beforePng, combined, 0, 0, beforePng.width, beforePng.height, 0, 0);
|
|
1708144
|
+
import_pngjs.PNG.bitblt(afterPng, combined, 0, 0, afterPng.width, afterPng.height, beforePng.width + gap, 0);
|
|
1708145
|
+
if (highlight) {
|
|
1708146
|
+
const color3 = [255, 196, 0, 255];
|
|
1708147
|
+
const thickness = 3;
|
|
1708148
|
+
drawBorder(combined, 0, 0, beforePng.width, beforePng.height, color3, thickness);
|
|
1708149
|
+
drawBorder(combined, beforePng.width + gap, 0, afterPng.width, afterPng.height, color3, thickness);
|
|
1708150
|
+
}
|
|
1708151
|
+
return combined;
|
|
1708152
|
+
}
|
|
1708153
|
+
async function generateComparisons({
|
|
1708154
|
+
beforePath,
|
|
1708155
|
+
afterPath,
|
|
1708156
|
+
comparisonBasePath
|
|
1708157
|
+
}) {
|
|
1708158
|
+
const beforePng = import_pngjs.PNG.sync.read(await (0, import_promises110.readFile)(beforePath));
|
|
1708159
|
+
const afterPng = import_pngjs.PNG.sync.read(await (0, import_promises110.readFile)(afterPath));
|
|
1708160
|
+
const width = Math.max(beforePng.width, afterPng.width);
|
|
1708161
|
+
const height3 = Math.max(beforePng.height, afterPng.height);
|
|
1708162
|
+
const resizedBefore = new import_pngjs.PNG({ width, height: height3 });
|
|
1708163
|
+
const resizedAfter = new import_pngjs.PNG({ width, height: height3 });
|
|
1708164
|
+
resizedBefore.data.fill(255);
|
|
1708165
|
+
resizedAfter.data.fill(255);
|
|
1708166
|
+
import_pngjs.PNG.bitblt(beforePng, resizedBefore, 0, 0, beforePng.width, beforePng.height, 0, 0);
|
|
1708167
|
+
import_pngjs.PNG.bitblt(afterPng, resizedAfter, 0, 0, afterPng.width, afterPng.height, 0, 0);
|
|
1708168
|
+
const beforeData = new Uint8Array(
|
|
1708169
|
+
resizedBefore.data.buffer,
|
|
1708170
|
+
resizedBefore.data.byteOffset,
|
|
1708171
|
+
resizedBefore.data.length
|
|
1708172
|
+
);
|
|
1708173
|
+
const afterData = new Uint8Array(resizedAfter.data.buffer, resizedAfter.data.byteOffset, resizedAfter.data.length);
|
|
1708174
|
+
const regions = findChangedRegions(beforeData, afterData, width, height3);
|
|
1708175
|
+
const results = [];
|
|
1708176
|
+
if (regions.length === 0) {
|
|
1708177
|
+
return results;
|
|
1708178
|
+
}
|
|
1708179
|
+
const base4 = comparisonBasePath.endsWith(".png") ? comparisonBasePath.slice(0, comparisonBasePath.length - 4) : comparisonBasePath;
|
|
1708180
|
+
for (let i11 = 0; i11 < regions.length; i11++) {
|
|
1708181
|
+
const boundingBox = regions[i11];
|
|
1708182
|
+
if (boundingBox == null) {
|
|
1708183
|
+
continue;
|
|
1708184
|
+
}
|
|
1708185
|
+
const boxWidth = boundingBox.maxX - boundingBox.minX;
|
|
1708186
|
+
const boxHeight = boundingBox.maxY - boundingBox.minY;
|
|
1708187
|
+
const changedPixels = boxWidth * boxHeight;
|
|
1708188
|
+
const totalPixels = width * height3;
|
|
1708189
|
+
const changePercent = changedPixels / totalPixels * 100;
|
|
1708190
|
+
const croppedBefore = cropPng(resizedBefore, boundingBox);
|
|
1708191
|
+
const croppedAfter = cropPng(resizedAfter, boundingBox);
|
|
1708192
|
+
const sideBySide = createSideBySideComparison(croppedBefore, croppedAfter, 20, true);
|
|
1708193
|
+
const outPath = `${base4}-region-${i11 + 1}.png`;
|
|
1708194
|
+
const pngBuffer = import_pngjs.PNG.sync.write(sideBySide);
|
|
1708195
|
+
await (0, import_promises110.writeFile)(outPath, new Uint8Array(pngBuffer));
|
|
1708196
|
+
results.push({ changePercent, boundingBox, comparisonPath: outPath });
|
|
1708197
|
+
}
|
|
1708198
|
+
return results;
|
|
1708199
|
+
}
|
|
1708200
|
+
function getProductionUrl(docsConfig) {
|
|
1708201
|
+
if (docsConfig.instances == null || docsConfig.instances.length === 0) {
|
|
1708202
|
+
throw new Error("No docs instances configured in docs.yml");
|
|
1708203
|
+
}
|
|
1708204
|
+
const firstInstance = docsConfig.instances[0];
|
|
1708205
|
+
if (firstInstance == null) {
|
|
1708206
|
+
throw new Error("No docs instances configured in docs.yml");
|
|
1708207
|
+
}
|
|
1708208
|
+
const instanceUrl = firstInstance.url;
|
|
1708209
|
+
if (instanceUrl.startsWith("https://") || instanceUrl.startsWith("http://")) {
|
|
1708210
|
+
return instanceUrl;
|
|
1708211
|
+
}
|
|
1708212
|
+
return `https://${instanceUrl}`;
|
|
1708213
|
+
}
|
|
1708214
|
+
async function docsDiff({
|
|
1708215
|
+
cliContext,
|
|
1708216
|
+
project,
|
|
1708217
|
+
previewUrl,
|
|
1708218
|
+
files,
|
|
1708219
|
+
outputDir
|
|
1708220
|
+
}) {
|
|
1708221
|
+
const docsWorkspace = project.docsWorkspaces;
|
|
1708222
|
+
if (docsWorkspace == null) {
|
|
1708223
|
+
cliContext.failAndThrow("No docs workspace found. Make sure you have a docs.yml file.");
|
|
1708224
|
+
return { diffs: [] };
|
|
1708225
|
+
}
|
|
1708226
|
+
const token = await cliContext.runTask(async (context2) => {
|
|
1708227
|
+
return askToLogin(context2);
|
|
1708228
|
+
});
|
|
1708229
|
+
if (token == null) {
|
|
1708230
|
+
cliContext.failAndThrow("Failed to authenticate. Please run 'fern login' first.");
|
|
1708231
|
+
return { diffs: [] };
|
|
1708232
|
+
}
|
|
1708233
|
+
const fernToken = process.env.FERN_TOKEN ?? token.value;
|
|
1708234
|
+
const productionBaseUrl = getProductionUrl(docsWorkspace.config);
|
|
1708235
|
+
let normalizedPreviewUrl = previewUrl;
|
|
1708236
|
+
if (normalizedPreviewUrl.startsWith("https://")) {
|
|
1708237
|
+
normalizedPreviewUrl = normalizedPreviewUrl.slice(8);
|
|
1708238
|
+
} else if (normalizedPreviewUrl.startsWith("http://")) {
|
|
1708239
|
+
normalizedPreviewUrl = normalizedPreviewUrl.slice(7);
|
|
1708240
|
+
}
|
|
1708241
|
+
const slashIndex = normalizedPreviewUrl.indexOf("/");
|
|
1708242
|
+
if (slashIndex !== -1) {
|
|
1708243
|
+
normalizedPreviewUrl = normalizedPreviewUrl.slice(0, slashIndex);
|
|
1708244
|
+
}
|
|
1708245
|
+
const slugResponse = await cliContext.runTask(async (context2) => {
|
|
1708246
|
+
context2.logger.info(`Resolving slugs for ${files.length} file(s)...`);
|
|
1708247
|
+
return getSlugForFiles({
|
|
1708248
|
+
previewUrl: normalizedPreviewUrl,
|
|
1708249
|
+
files,
|
|
1708250
|
+
token: fernToken
|
|
1708251
|
+
});
|
|
1708252
|
+
});
|
|
1708253
|
+
if (slugResponse.authed) {
|
|
1708254
|
+
cliContext.logger.warn(
|
|
1708255
|
+
"The docs require authentication. Screenshots may not capture the full content without proper auth."
|
|
1708256
|
+
);
|
|
1708257
|
+
}
|
|
1708258
|
+
const outputPath = AbsoluteFilePath2.of(
|
|
1708259
|
+
outputDir.startsWith("/") ? outputDir : join4(cwd(), RelativeFilePath2.of(outputDir))
|
|
1708260
|
+
);
|
|
1708261
|
+
if (!await doesPathExist(outputPath)) {
|
|
1708262
|
+
await (0, import_promises110.mkdir)(outputPath, { recursive: true });
|
|
1708263
|
+
}
|
|
1708264
|
+
const results = [];
|
|
1708265
|
+
await cliContext.runTask(async (context2) => {
|
|
1708266
|
+
context2.logger.info("Starting browser for screenshot capture...");
|
|
1708267
|
+
const browser = await launch3({
|
|
1708268
|
+
headless: true,
|
|
1708269
|
+
args: ["--ignore-certificate-errors", "--no-sandbox", "--disable-setuid-sandbox"]
|
|
1708270
|
+
});
|
|
1708271
|
+
try {
|
|
1708272
|
+
for (const mapping of slugResponse.mappings) {
|
|
1708273
|
+
if (mapping.slug == null) {
|
|
1708274
|
+
context2.logger.warn(`Could not find slug for file: ${mapping.filePath}`);
|
|
1708275
|
+
continue;
|
|
1708276
|
+
}
|
|
1708277
|
+
const slug = mapping.slug;
|
|
1708278
|
+
const filename = slugToFilename(slug);
|
|
1708279
|
+
const beforePath = join4(outputPath, RelativeFilePath2.of(`${filename}-before.png`));
|
|
1708280
|
+
const afterPath = join4(outputPath, RelativeFilePath2.of(`${filename}-after.png`));
|
|
1708281
|
+
const comparisonBasePath = join4(outputPath, RelativeFilePath2.of(`${filename}-comparison.png`));
|
|
1708282
|
+
const productionUrl = `${productionBaseUrl}/${slug}`;
|
|
1708283
|
+
const previewPageUrl = `https://${normalizedPreviewUrl}/${slug}`;
|
|
1708284
|
+
context2.logger.info(`Capturing screenshots for: ${slug}`);
|
|
1708285
|
+
const beforeExists = await captureScreenshot({
|
|
1708286
|
+
browser,
|
|
1708287
|
+
url: productionUrl,
|
|
1708288
|
+
outputPath: beforePath,
|
|
1708289
|
+
token: fernToken
|
|
1708290
|
+
});
|
|
1708291
|
+
const afterExists = await captureScreenshot({
|
|
1708292
|
+
browser,
|
|
1708293
|
+
url: previewPageUrl,
|
|
1708294
|
+
outputPath: afterPath,
|
|
1708295
|
+
token: fernToken
|
|
1708296
|
+
});
|
|
1708297
|
+
if (!afterExists) {
|
|
1708298
|
+
context2.logger.warn(`Could not capture preview page for: ${slug}`);
|
|
1708299
|
+
continue;
|
|
1708300
|
+
}
|
|
1708301
|
+
const isNewPage = !beforeExists;
|
|
1708302
|
+
if (beforeExists) {
|
|
1708303
|
+
const regions = await generateComparisons({
|
|
1708304
|
+
beforePath,
|
|
1708305
|
+
afterPath,
|
|
1708306
|
+
comparisonBasePath
|
|
1708307
|
+
});
|
|
1708308
|
+
if (regions.length === 0) {
|
|
1708309
|
+
context2.logger.info(` No visual changes detected`);
|
|
1708310
|
+
results.push({
|
|
1708311
|
+
file: mapping.filePath,
|
|
1708312
|
+
slug,
|
|
1708313
|
+
comparison: null,
|
|
1708314
|
+
changePercent: 0,
|
|
1708315
|
+
isNewPage
|
|
1708316
|
+
});
|
|
1708317
|
+
} else {
|
|
1708318
|
+
regions.forEach((region, idx) => {
|
|
1708319
|
+
context2.logger.info(
|
|
1708320
|
+
` Region ${idx + 1}: ${region.changePercent.toFixed(2)}% (split & cropped)`
|
|
1708321
|
+
);
|
|
1708322
|
+
results.push({
|
|
1708323
|
+
file: mapping.filePath,
|
|
1708324
|
+
slug,
|
|
1708325
|
+
comparison: region.comparisonPath,
|
|
1708326
|
+
changePercent: region.changePercent,
|
|
1708327
|
+
isNewPage
|
|
1708328
|
+
});
|
|
1708329
|
+
});
|
|
1708330
|
+
}
|
|
1708331
|
+
} else {
|
|
1708332
|
+
context2.logger.info(` New page (no production version)`);
|
|
1708333
|
+
results.push({
|
|
1708334
|
+
file: mapping.filePath,
|
|
1708335
|
+
slug,
|
|
1708336
|
+
comparison: null,
|
|
1708337
|
+
changePercent: null,
|
|
1708338
|
+
isNewPage
|
|
1708339
|
+
});
|
|
1708340
|
+
}
|
|
1708341
|
+
}
|
|
1708342
|
+
} finally {
|
|
1708343
|
+
await browser.close();
|
|
1708344
|
+
}
|
|
1708345
|
+
});
|
|
1708346
|
+
return { diffs: results };
|
|
1708347
|
+
}
|
|
1708348
|
+
|
|
1705872
1708349
|
// src/commands/docs-preview/deleteDocsPreview.ts
|
|
1705873
1708350
|
var PREVIEW_URL_PATTERN = /^[a-z0-9-]+-preview-[a-z0-9-]+\.docs\.buildwithfern\.com$/i;
|
|
1705874
1708351
|
function isPreviewUrl(url3) {
|
|
@@ -1705974,7 +1708451,7 @@ Found ${previewDeployments.length} preview deployment(s):
|
|
|
1705974
1708451
|
}
|
|
1705975
1708452
|
|
|
1705976
1708453
|
// src/commands/downgrade/downgrade.ts
|
|
1705977
|
-
var
|
|
1708454
|
+
var import_promises111 = require("fs/promises");
|
|
1705978
1708455
|
|
|
1705979
1708456
|
// ../../../node_modules/.pnpm/immer@10.1.3/node_modules/immer/dist/immer.mjs
|
|
1705980
1708457
|
var NOTHING = Symbol.for("immer-nothing");
|
|
@@ -1706663,12 +1709140,12 @@ async function downgrade({
|
|
|
1706663
1709140
|
const newProjectConfig = produce(projectConfig.rawConfig, (draft) => {
|
|
1706664
1709141
|
draft.version = targetVersion;
|
|
1706665
1709142
|
});
|
|
1706666
|
-
await (0,
|
|
1709143
|
+
await (0, import_promises111.writeFile)(projectConfig._absolutePath, ensureFinalNewline(JSON.stringify(newProjectConfig, void 0, 2)));
|
|
1706667
1709144
|
cliContext.logger.info(`Updated ${PROJECT_CONFIG_FILENAME} to version ${targetVersion}`);
|
|
1706668
1709145
|
}
|
|
1706669
1709146
|
|
|
1706670
1709147
|
// src/commands/export/generateOpenAPIForWorkspaces.ts
|
|
1706671
|
-
var
|
|
1709148
|
+
var import_promises112 = require("fs/promises");
|
|
1706672
1709149
|
|
|
1706673
1709150
|
// src/commands/export/converters/servicesConverter.ts
|
|
1706674
1709151
|
var import_openapi_types3 = __toESM(require_dist10(), 1);
|
|
@@ -1707921,8 +1710398,8 @@ async function generateOpenAPIForWorkspaces({
|
|
|
1707921
1710398
|
ir: ir14,
|
|
1707922
1710399
|
mode: "openapi"
|
|
1707923
1710400
|
});
|
|
1707924
|
-
await (0,
|
|
1707925
|
-
await (0,
|
|
1710401
|
+
await (0, import_promises112.mkdir)(dirname4(outputPath), { recursive: true });
|
|
1710402
|
+
await (0, import_promises112.writeFile)(
|
|
1707926
1710403
|
outputPath,
|
|
1707927
1710404
|
outputPath.endsWith(".json") ? JSON.stringify(openapi, void 0, indent3) : jsYaml.dump(openapi, { indent: indent3 })
|
|
1707928
1710405
|
);
|
|
@@ -1707961,10 +1710438,10 @@ var APPROVED_DIRECTORIES_FILENAME = "approved-output-directories";
|
|
|
1707961
1710438
|
var LOCAL_STORAGE_FOLDER6 = ".fern-dev";
|
|
1707962
1710439
|
|
|
1707963
1710440
|
// src/commands/generate/checkOutputDirectory.ts
|
|
1707964
|
-
var
|
|
1710441
|
+
var import_promises115 = require("fs/promises");
|
|
1707965
1710442
|
|
|
1707966
1710443
|
// src/persistence/output-directories/getOutputDirectories.ts
|
|
1707967
|
-
var
|
|
1710444
|
+
var import_promises113 = require("fs/promises");
|
|
1707968
1710445
|
|
|
1707969
1710446
|
// src/persistence/output-directories/getPathToOutputDirectoriesFile.ts
|
|
1707970
1710447
|
var import_os9 = require("os");
|
|
@@ -1707983,17 +1710460,17 @@ async function getOutputDirectories() {
|
|
|
1707983
1710460
|
if (!doesOutputDirectoriesFileExist) {
|
|
1707984
1710461
|
return [];
|
|
1707985
1710462
|
}
|
|
1707986
|
-
const outputDirectoriesFileContents = await (0,
|
|
1710463
|
+
const outputDirectoriesFileContents = await (0, import_promises113.readFile)(pathToOutputDirectoriesFile, { encoding: "utf-8" });
|
|
1707987
1710464
|
const outputDirectories = JSON.parse(outputDirectoriesFileContents);
|
|
1707988
1710465
|
return outputDirectories;
|
|
1707989
1710466
|
}
|
|
1707990
1710467
|
|
|
1707991
1710468
|
// src/persistence/output-directories/storeOutputDirectories.ts
|
|
1707992
|
-
var
|
|
1710469
|
+
var import_promises114 = require("fs/promises");
|
|
1707993
1710470
|
var import_path60 = __toESM(require("path"), 1);
|
|
1707994
1710471
|
async function storeOutputDirectories(outputDirectories) {
|
|
1707995
|
-
await (0,
|
|
1707996
|
-
await (0,
|
|
1710472
|
+
await (0, import_promises114.mkdir)(import_path60.default.dirname(getPathToOutputDirectoriesFile()), { recursive: true });
|
|
1710473
|
+
await (0, import_promises114.writeFile)(getPathToOutputDirectoriesFile(), JSON.stringify(outputDirectories, null, 2));
|
|
1707997
1710474
|
}
|
|
1707998
1710475
|
|
|
1707999
1710476
|
// src/commands/generate/checkOutputDirectory.ts
|
|
@@ -1708015,7 +1710492,7 @@ async function checkOutputDirectory(outputPath, cliContext, force) {
|
|
|
1708015
1710492
|
shouldProceed: true
|
|
1708016
1710493
|
};
|
|
1708017
1710494
|
}
|
|
1708018
|
-
const files = await (0,
|
|
1710495
|
+
const files = await (0, import_promises115.readdir)(outputPath);
|
|
1708019
1710496
|
if (files.length === 0) {
|
|
1708020
1710497
|
return {
|
|
1708021
1710498
|
shouldProceed: true
|
|
@@ -1713757,14 +1716234,14 @@ async function validateGeneratorsYmlFile({ contents, allRuleVisitors, cliVersion
|
|
|
1713757
1716234
|
}
|
|
1713758
1716235
|
|
|
1713759
1716236
|
// ../workspace/oss-validator/lib/rules/no-duplicate-overrides/no-duplicate-overrides.js
|
|
1713760
|
-
var
|
|
1716237
|
+
var import_promises116 = require("fs/promises");
|
|
1713761
1716238
|
var NoDuplicateOverridesRule = {
|
|
1713762
1716239
|
name: "no-duplicate-overrides",
|
|
1713763
1716240
|
run: async ({ workspace, specs, context: context2 }) => {
|
|
1713764
1716241
|
const violations = [];
|
|
1713765
1716242
|
const seenMethodsByAudience = /* @__PURE__ */ new Map();
|
|
1713766
1716243
|
for (const spec of specs) {
|
|
1713767
|
-
const contents = (await (0,
|
|
1716244
|
+
const contents = (await (0, import_promises116.readFile)(spec.absoluteFilepath)).toString();
|
|
1713768
1716245
|
if (contents.includes("openapi") || contents.includes("swagger")) {
|
|
1713769
1716246
|
const openAPI = await loadOpenAPI({
|
|
1713770
1716247
|
absolutePathToOpenAPI: spec.absoluteFilepath,
|
|
@@ -1714591,7 +1717068,7 @@ async function generateOpenAPIIrForWorkspaces({
|
|
|
1714591
1717068
|
}
|
|
1714592
1717069
|
|
|
1714593
1717070
|
// src/commands/generate-overrides/compareOpenAPISpecs.ts
|
|
1714594
|
-
var
|
|
1717071
|
+
var import_promises117 = require("fs/promises");
|
|
1714595
1717072
|
async function compareOpenAPISpecs({
|
|
1714596
1717073
|
originalPath,
|
|
1714597
1717074
|
modifiedPath,
|
|
@@ -1714628,12 +1717105,12 @@ async function compareOpenAPISpecs({
|
|
|
1714628
1717105
|
}
|
|
1714629
1717106
|
outputPath = join4(dirname4(originalPath), RelativeFilePath2.of(overridesFilename));
|
|
1714630
1717107
|
}
|
|
1714631
|
-
await (0,
|
|
1717108
|
+
await (0, import_promises117.writeFile)(outputPath, jsYaml.dump(overrides, { lineWidth: -1, noRefs: true }));
|
|
1714632
1717109
|
context2.logger.info(`Overrides written to ${outputPath}`);
|
|
1714633
1717110
|
});
|
|
1714634
1717111
|
}
|
|
1714635
1717112
|
async function loadSpec(filepath, context2) {
|
|
1714636
|
-
const contents = await (0,
|
|
1717113
|
+
const contents = await (0, import_promises117.readFile)(filepath, "utf8");
|
|
1714637
1717114
|
try {
|
|
1714638
1717115
|
return JSON.parse(contents);
|
|
1714639
1717116
|
} catch {
|
|
@@ -1714734,7 +1717211,7 @@ function deepEqual(a10, b18) {
|
|
|
1714734
1717211
|
}
|
|
1714735
1717212
|
|
|
1714736
1717213
|
// src/commands/generate-overrides/writeOverridesForWorkspaces.ts
|
|
1714737
|
-
var
|
|
1717214
|
+
var import_promises118 = require("fs/promises");
|
|
1714738
1717215
|
async function writeOverridesForWorkspaces({
|
|
1714739
1717216
|
project,
|
|
1714740
1717217
|
includeModels,
|
|
@@ -1714759,7 +1717236,7 @@ async function writeOverridesForWorkspaces({
|
|
|
1714759
1717236
|
async function readExistingOverrides(overridesFilepath, context2) {
|
|
1714760
1717237
|
let parsedOverrides = null;
|
|
1714761
1717238
|
try {
|
|
1714762
|
-
const contents = (await (0,
|
|
1717239
|
+
const contents = (await (0, import_promises118.readFile)(overridesFilepath, "utf8")).toString();
|
|
1714763
1717240
|
try {
|
|
1714764
1717241
|
parsedOverrides = JSON.parse(contents);
|
|
1714765
1717242
|
} catch (err) {
|
|
@@ -1714823,7 +1717300,7 @@ async function writeDefinitionForOpenAPIWorkspace({
|
|
|
1714823
1717300
|
overridesFilename = `${nameWithoutExt}-overrides${extension3}`;
|
|
1714824
1717301
|
}
|
|
1714825
1717302
|
}
|
|
1714826
|
-
await (0,
|
|
1717303
|
+
await (0, import_promises118.writeFile)(
|
|
1714827
1717304
|
join4(dirname4(spec.absoluteFilepath), RelativeFilePath2.of(overridesFilename)),
|
|
1714828
1717305
|
jsYaml.dump({ paths, components })
|
|
1714829
1717306
|
);
|
|
@@ -1715188,7 +1717665,7 @@ function convertIRtoJsonSchema(args) {
|
|
|
1715188
1717665
|
}
|
|
1715189
1717666
|
|
|
1715190
1717667
|
// src/commands/jsonschema/generateJsonschemaForWorkspace.ts
|
|
1715191
|
-
var
|
|
1717668
|
+
var import_promises119 = require("fs/promises");
|
|
1715192
1717669
|
async function generateJsonschemaForWorkspaces({
|
|
1715193
1717670
|
typeLocator,
|
|
1715194
1717671
|
project,
|
|
@@ -1715236,9 +1717713,9 @@ async function generateJsonschemaForWorkspaces({
|
|
|
1715236
1717713
|
context: context2
|
|
1715237
1717714
|
});
|
|
1715238
1717715
|
if (!await doesPathExist(dirname4(jsonschemaFilepath))) {
|
|
1715239
|
-
await (0,
|
|
1717716
|
+
await (0, import_promises119.mkdir)(dirname4(jsonschemaFilepath), { recursive: true });
|
|
1715240
1717717
|
}
|
|
1715241
|
-
await (0,
|
|
1717718
|
+
await (0, import_promises119.writeFile)(jsonschemaFilepath, JSON.stringify(jsonSchema, null, 2));
|
|
1715242
1717719
|
context2.logger.info(source_default2.green(`Wrote JSON Schema to ${jsonschemaFilepath}`));
|
|
1715243
1717720
|
});
|
|
1715244
1717721
|
})
|
|
@@ -1715595,7 +1718072,7 @@ async function mockServer({
|
|
|
1715595
1718072
|
|
|
1715596
1718073
|
// src/commands/register/registerWorkspacesV1.ts
|
|
1715597
1718074
|
var import_fiddle_sdk8 = __toESM(require_fiddle_sdk(), 1);
|
|
1715598
|
-
var
|
|
1718075
|
+
var import_promises120 = require("fs/promises");
|
|
1715599
1718076
|
var import_path68 = __toESM(require("path"), 1);
|
|
1715600
1718077
|
var import_tmp_promise17 = __toESM(require_tmp_promise(), 1);
|
|
1715601
1718078
|
async function registerWorkspacesV1({
|
|
@@ -1715644,7 +1718121,7 @@ async function registerWorkspacesV1({
|
|
|
1715644
1718121
|
context2.logger.debug(`Compressing definition at ${tmpDir.path}`);
|
|
1715645
1718122
|
await create2({ file: tarPath, cwd: resolvedWorkspace.absoluteFilePath }, ["."]);
|
|
1715646
1718123
|
context2.logger.info("Uploading definition...");
|
|
1715647
|
-
await axios_default.put(registerApiResponse.body.definitionS3UploadUrl, await (0,
|
|
1718124
|
+
await axios_default.put(registerApiResponse.body.definitionS3UploadUrl, await (0, import_promises120.readFile)(tarPath));
|
|
1715648
1718125
|
context2.logger.info(
|
|
1715649
1718126
|
`Registered @${project.config.organization}/${resolvedWorkspace.definition.rootApiFile.contents.name}:${registerApiResponse.body.version}`
|
|
1715650
1718127
|
);
|
|
@@ -1715782,7 +1718259,7 @@ async function generateDiff({
|
|
|
1715782
1718259
|
}
|
|
1715783
1718260
|
|
|
1715784
1718261
|
// src/commands/self-update/selfUpdate.ts
|
|
1715785
|
-
var
|
|
1718262
|
+
var import_promises121 = require("fs/promises");
|
|
1715786
1718263
|
var import_path69 = require("path");
|
|
1715787
1718264
|
async function getPackageManagerBinDir(logger, pm) {
|
|
1715788
1718265
|
let command3;
|
|
@@ -1715828,7 +1718305,7 @@ async function detectInstallationMethod(logger) {
|
|
|
1715828
1718305
|
logger.debug(`Found fern at: ${fernPath}`);
|
|
1715829
1718306
|
let resolvedPath;
|
|
1715830
1718307
|
try {
|
|
1715831
|
-
resolvedPath = await (0,
|
|
1718308
|
+
resolvedPath = await (0, import_promises121.realpath)(fernPath);
|
|
1715832
1718309
|
logger.debug(`Resolved to: ${resolvedPath}`);
|
|
1715833
1718310
|
} catch (error49) {
|
|
1715834
1718311
|
logger.debug(`Failed to resolve symlink: ${error49}`);
|
|
@@ -1716109,20 +1718586,20 @@ async function generateToken({
|
|
|
1716109
1718586
|
|
|
1716110
1718587
|
// src/commands/upgrade/updateApiSpec.ts
|
|
1716111
1718588
|
var fs32 = __toESM(require("fs"), 1);
|
|
1716112
|
-
var
|
|
1718589
|
+
var import_promises122 = require("fs/promises");
|
|
1716113
1718590
|
var import_stream9 = require("stream");
|
|
1716114
|
-
var
|
|
1718591
|
+
var import_promises123 = require("stream/promises");
|
|
1716115
1718592
|
async function fetchAndWriteFile(url3, path86, logger, indent3) {
|
|
1716116
1718593
|
const resp = await fetch(url3);
|
|
1716117
1718594
|
if (resp.ok && resp.body) {
|
|
1716118
1718595
|
logger.debug("Origin successfully fetched, writing to file");
|
|
1716119
1718596
|
const fileStream = fs32.createWriteStream(path86);
|
|
1716120
|
-
await (0,
|
|
1716121
|
-
const fileContents = await (0,
|
|
1718597
|
+
await (0, import_promises123.finished)(import_stream9.Readable.fromWeb(resp.body).pipe(fileStream));
|
|
1718598
|
+
const fileContents = await (0, import_promises122.readFile)(path86, "utf8");
|
|
1716122
1718599
|
try {
|
|
1716123
|
-
await (0,
|
|
1718600
|
+
await (0, import_promises122.writeFile)(path86, JSON.stringify(JSON.parse(fileContents), void 0, indent3), "utf8");
|
|
1716124
1718601
|
} catch (e6) {
|
|
1716125
|
-
await (0,
|
|
1718602
|
+
await (0, import_promises122.writeFile)(path86, jsYaml.dump(jsYaml.load(fileContents), { indent: indent3 }), "utf8");
|
|
1716126
1718603
|
}
|
|
1716127
1718604
|
logger.debug("File written successfully");
|
|
1716128
1718605
|
}
|
|
@@ -1716218,7 +1718695,7 @@ async function processDefinitions({
|
|
|
1716218
1718695
|
}
|
|
1716219
1718696
|
|
|
1716220
1718697
|
// ../cli-migrations/lib/migrations/0.0.191/discriminant/migration.js
|
|
1716221
|
-
var
|
|
1718698
|
+
var import_promises124 = require("fs/promises");
|
|
1716222
1718699
|
|
|
1716223
1718700
|
// ../cli-migrations/lib/migrations/0.0.191/discriminant/getAllYamlFiles.js
|
|
1716224
1718701
|
var FERN_DIRECTORY2 = "fern";
|
|
@@ -1716252,7 +1718729,7 @@ var migration = {
|
|
|
1716252
1718729
|
try {
|
|
1716253
1718730
|
const fileContents = await getFileContents(yamlFilepath);
|
|
1716254
1718731
|
const newContents = addDiscriminantToFile(fileContents);
|
|
1716255
|
-
await (0,
|
|
1718732
|
+
await (0, import_promises124.writeFile)(yamlFilepath, newContents);
|
|
1716256
1718733
|
} catch (error49) {
|
|
1716257
1718734
|
context2.failAndThrow("Failed to migrate " + yamlFilepath, error49);
|
|
1716258
1718735
|
}
|
|
@@ -1716260,7 +1718737,7 @@ var migration = {
|
|
|
1716260
1718737
|
}
|
|
1716261
1718738
|
};
|
|
1716262
1718739
|
async function getFileContents(filepath) {
|
|
1716263
|
-
const buffer = await (0,
|
|
1718740
|
+
const buffer = await (0, import_promises124.readFile)(filepath);
|
|
1716264
1718741
|
return buffer.toString();
|
|
1716265
1718742
|
}
|
|
1716266
1718743
|
var UNION_REGEX = /^(\s{2,})union:\s*$/gm;
|
|
@@ -1716289,7 +1718766,7 @@ var versionMigrations = {
|
|
|
1716289
1718766
|
var __default = versionMigrations;
|
|
1716290
1718767
|
|
|
1716291
1718768
|
// ../cli-migrations/lib/migrations/0.0.203/union-single-property-key/migration.js
|
|
1716292
|
-
var
|
|
1718769
|
+
var import_promises125 = require("fs/promises");
|
|
1716293
1718770
|
var import_yaml6 = __toESM(require_dist2(), 1);
|
|
1716294
1718771
|
|
|
1716295
1718772
|
// ../cli-migrations/lib/migrations/0.0.203/union-single-property-key/getAllYamlFiles.js
|
|
@@ -1716330,7 +1718807,7 @@ var migration2 = {
|
|
|
1716330
1718807
|
}
|
|
1716331
1718808
|
};
|
|
1716332
1718809
|
async function migrateFile(filepath, context2) {
|
|
1716333
|
-
const contents = await (0,
|
|
1718810
|
+
const contents = await (0, import_promises125.readFile)(filepath);
|
|
1716334
1718811
|
const parsedDocument = import_yaml6.default.parseDocument(contents.toString());
|
|
1716335
1718812
|
const types4 = parsedDocument.get("types");
|
|
1716336
1718813
|
if (types4 == null) {
|
|
@@ -1716362,7 +1718839,7 @@ async function migrateFile(filepath, context2) {
|
|
|
1716362
1718839
|
}
|
|
1716363
1718840
|
}
|
|
1716364
1718841
|
}
|
|
1716365
|
-
await (0,
|
|
1718842
|
+
await (0, import_promises125.writeFile)(filepath, parsedDocument.toString());
|
|
1716366
1718843
|
}
|
|
1716367
1718844
|
|
|
1716368
1718845
|
// ../cli-migrations/lib/migrations/0.0.203/index.js
|
|
@@ -1716373,7 +1718850,7 @@ var versionMigrations2 = {
|
|
|
1716373
1718850
|
var __default2 = versionMigrations2;
|
|
1716374
1718851
|
|
|
1716375
1718852
|
// ../cli-migrations/lib/migrations/0.0.207/add-mode-to-draft-generators/migration.js
|
|
1716376
|
-
var
|
|
1718853
|
+
var import_promises126 = require("fs/promises");
|
|
1716377
1718854
|
var import_yaml7 = __toESM(require_dist2(), 1);
|
|
1716378
1718855
|
|
|
1716379
1718856
|
// ../cli-migrations/lib/migrations/0.0.207/add-mode-to-draft-generators/getAllGeneratorYamlFiles.js
|
|
@@ -1716414,7 +1718891,7 @@ var migration3 = {
|
|
|
1716414
1718891
|
}
|
|
1716415
1718892
|
};
|
|
1716416
1718893
|
async function migrateGeneratorsYml(filepath, context2) {
|
|
1716417
|
-
const contents = await (0,
|
|
1718894
|
+
const contents = await (0, import_promises126.readFile)(filepath);
|
|
1716418
1718895
|
const parsedDocument = import_yaml7.default.parseDocument(contents.toString());
|
|
1716419
1718896
|
const draftGenerators = parsedDocument.get("draft");
|
|
1716420
1718897
|
if (draftGenerators == null) {
|
|
@@ -1716441,7 +1718918,7 @@ async function migrateGeneratorsYml(filepath, context2) {
|
|
|
1716441
1718918
|
draftGenerator.set("output-path", name3.value.includes("openapi") ? "./generated-openapi" : name3.value.includes("postman") ? "./generated-postman" : localOutput);
|
|
1716442
1718919
|
}
|
|
1716443
1718920
|
});
|
|
1716444
|
-
await (0,
|
|
1718921
|
+
await (0, import_promises126.writeFile)(filepath, parsedDocument.toString());
|
|
1716445
1718922
|
}
|
|
1716446
1718923
|
|
|
1716447
1718924
|
// ../cli-migrations/lib/migrations/0.0.207/index.js
|
|
@@ -1716452,7 +1718929,7 @@ var versionMigrations3 = {
|
|
|
1716452
1718929
|
var __default3 = versionMigrations3;
|
|
1716453
1718930
|
|
|
1716454
1718931
|
// ../cli-migrations/lib/migrations/0.0.210/remove-inline-error-declarations/migration.js
|
|
1716455
|
-
var
|
|
1718932
|
+
var import_promises127 = require("fs/promises");
|
|
1716456
1718933
|
var import_yaml8 = __toESM(require_dist2(), 1);
|
|
1716457
1718934
|
|
|
1716458
1718935
|
// ../cli-migrations/lib/migrations/0.0.210/remove-inline-error-declarations/getAllYamlFiles.js
|
|
@@ -1716493,7 +1718970,7 @@ var migration4 = {
|
|
|
1716493
1718970
|
}
|
|
1716494
1718971
|
};
|
|
1716495
1718972
|
async function migrateFile2(filepath, context2) {
|
|
1716496
|
-
const contents = await (0,
|
|
1718973
|
+
const contents = await (0, import_promises127.readFile)(filepath);
|
|
1716497
1718974
|
const parsedDocument = import_yaml8.default.parseDocument(contents.toString());
|
|
1716498
1718975
|
const addType = (typeName, typeDeclaration2) => {
|
|
1716499
1718976
|
const types4 = parsedDocument.get("types");
|
|
@@ -1716537,7 +1719014,7 @@ async function migrateFile2(filepath, context2) {
|
|
|
1716537
1719014
|
}
|
|
1716538
1719015
|
}
|
|
1716539
1719016
|
}
|
|
1716540
|
-
await (0,
|
|
1719017
|
+
await (0, import_promises127.writeFile)(filepath, parsedDocument.toString());
|
|
1716541
1719018
|
}
|
|
1716542
1719019
|
|
|
1716543
1719020
|
// ../cli-migrations/lib/migrations/0.0.210/index.js
|
|
@@ -1716548,7 +1719025,7 @@ var versionMigrations4 = {
|
|
|
1716548
1719025
|
var __default4 = versionMigrations4;
|
|
1716549
1719026
|
|
|
1716550
1719027
|
// ../cli-migrations/lib/migrations/0.0.212/add-publishing-to-release-generators/migration.js
|
|
1716551
|
-
var
|
|
1719028
|
+
var import_promises128 = require("fs/promises");
|
|
1716552
1719029
|
var import_yaml9 = __toESM(require_dist2(), 1);
|
|
1716553
1719030
|
|
|
1716554
1719031
|
// ../cli-migrations/lib/migrations/0.0.212/add-publishing-to-release-generators/getAllGeneratorYamlFiles.js
|
|
@@ -1716589,7 +1719066,7 @@ var migration5 = {
|
|
|
1716589
1719066
|
}
|
|
1716590
1719067
|
};
|
|
1716591
1719068
|
async function migrateGeneratorsYml2(filepath, context2) {
|
|
1716592
|
-
const contents = await (0,
|
|
1719069
|
+
const contents = await (0, import_promises128.readFile)(filepath);
|
|
1716593
1719070
|
const parsedDocument = import_yaml9.default.parseDocument(contents.toString());
|
|
1716594
1719071
|
const releaseGenerators = parsedDocument.get("release");
|
|
1716595
1719072
|
if (releaseGenerators == null) {
|
|
@@ -1716627,7 +1719104,7 @@ async function migrateGeneratorsYml2(filepath, context2) {
|
|
|
1716627
1719104
|
}
|
|
1716628
1719105
|
releaseGenerator.delete("outputs");
|
|
1716629
1719106
|
});
|
|
1716630
|
-
await (0,
|
|
1719107
|
+
await (0, import_promises128.writeFile)(filepath, parsedDocument.toString());
|
|
1716631
1719108
|
}
|
|
1716632
1719109
|
|
|
1716633
1719110
|
// ../cli-migrations/lib/migrations/0.0.212/index.js
|
|
@@ -1716638,7 +1719115,7 @@ var versionMigrations5 = {
|
|
|
1716638
1719115
|
var __default5 = versionMigrations5;
|
|
1716639
1719116
|
|
|
1716640
1719117
|
// ../cli-migrations/lib/migrations/0.0.220/rename-alias-key-to-type/migration.js
|
|
1716641
|
-
var
|
|
1719118
|
+
var import_promises129 = require("fs/promises");
|
|
1716642
1719119
|
|
|
1716643
1719120
|
// ../cli-migrations/lib/migrations/0.0.220/rename-alias-key-to-type/getAllYamlFiles.js
|
|
1716644
1719121
|
var FERN_DIRECTORY7 = "fern";
|
|
@@ -1716669,9 +1719146,9 @@ var migration6 = {
|
|
|
1716669
1719146
|
run: async ({ context: context2 }) => {
|
|
1716670
1719147
|
const yamlFiles = await getAllYamlFiles4(context2);
|
|
1716671
1719148
|
for (const filepath of yamlFiles) {
|
|
1716672
|
-
const contents = await (0,
|
|
1719149
|
+
const contents = await (0, import_promises129.readFile)(filepath);
|
|
1716673
1719150
|
const newContents = contents.toString().replaceAll(" alias:", " type:");
|
|
1716674
|
-
await (0,
|
|
1719151
|
+
await (0, import_promises129.writeFile)(filepath, newContents);
|
|
1716675
1719152
|
}
|
|
1716676
1719153
|
}
|
|
1716677
1719154
|
};
|
|
@@ -1716684,7 +1719161,7 @@ var versionMigrations6 = {
|
|
|
1716684
1719161
|
var __default6 = versionMigrations6;
|
|
1716685
1719162
|
|
|
1716686
1719163
|
// ../cli-migrations/lib/migrations/0.0.221/add-error-discriminant/migration.js
|
|
1716687
|
-
var
|
|
1719164
|
+
var import_promises130 = require("fs/promises");
|
|
1716688
1719165
|
|
|
1716689
1719166
|
// ../cli-migrations/lib/migrations/0.0.221/add-error-discriminant/getAllRootApiYamlFiles.js
|
|
1716690
1719167
|
var FERN_DIRECTORY8 = "fern";
|
|
@@ -1716715,9 +1719192,9 @@ var migration7 = {
|
|
|
1716715
1719192
|
run: async ({ context: context2 }) => {
|
|
1716716
1719193
|
const yamlFiles = await getAllRootApiYamlFiles(context2);
|
|
1716717
1719194
|
for (const filepath of yamlFiles) {
|
|
1716718
|
-
const contents = await (0,
|
|
1719195
|
+
const contents = await (0, import_promises130.readFile)(filepath);
|
|
1716719
1719196
|
const newContents = contents.toString() + "\nerror-discriminant: error";
|
|
1716720
|
-
await (0,
|
|
1719197
|
+
await (0, import_promises130.writeFile)(filepath, newContents);
|
|
1716721
1719198
|
}
|
|
1716722
1719199
|
}
|
|
1716723
1719200
|
};
|
|
@@ -1716730,7 +1719207,7 @@ var versionMigrations7 = {
|
|
|
1716730
1719207
|
var __default7 = versionMigrations7;
|
|
1716731
1719208
|
|
|
1716732
1719209
|
// ../cli-migrations/lib/migrations/0.0.241/add-generator-groups/migration.js
|
|
1716733
|
-
var
|
|
1719210
|
+
var import_promises131 = require("fs/promises");
|
|
1716734
1719211
|
|
|
1716735
1719212
|
// ../cli-migrations/lib/migrations/0.0.241/add-generator-groups/getAllGeneratorYamlFiles.js
|
|
1716736
1719213
|
var FERN_DIRECTORY9 = "fern";
|
|
@@ -1716837,7 +1719314,7 @@ var migration8 = {
|
|
|
1716837
1719314
|
}
|
|
1716838
1719315
|
};
|
|
1716839
1719316
|
async function migrateGeneratorsYml3(filepath) {
|
|
1716840
|
-
const contentsStr = await (0,
|
|
1719317
|
+
const contentsStr = await (0, import_promises131.readFile)(filepath);
|
|
1716841
1719318
|
const contents = jsYaml.load(contentsStr.toString());
|
|
1716842
1719319
|
const oldGeneratorsConfiguration = GeneratorsConfigurationSchema2.parse(contents);
|
|
1716843
1719320
|
let newGeneratorsConfiguration = {};
|
|
@@ -1716855,7 +1719332,7 @@ async function migrateGeneratorsYml3(filepath) {
|
|
|
1716855
1719332
|
generators: oldGeneratorsConfiguration.release.map((releaseGeneratorInvocation) => convertReleaseGeneratorInvocation(releaseGeneratorInvocation))
|
|
1716856
1719333
|
};
|
|
1716857
1719334
|
}
|
|
1716858
|
-
await (0,
|
|
1719335
|
+
await (0, import_promises131.writeFile)(filepath, jsYaml.dump(newGeneratorsConfiguration));
|
|
1716859
1719336
|
}
|
|
1716860
1719337
|
function convertDraftGeneratorInvocation(draftGeneratorInvocation) {
|
|
1716861
1719338
|
const newSchema = {
|
|
@@ -1716930,7 +1719407,7 @@ var versionMigrations8 = {
|
|
|
1716930
1719407
|
var __default8 = versionMigrations8;
|
|
1716931
1719408
|
|
|
1716932
1719409
|
// ../cli-migrations/lib/migrations/0.0.248/add-error-discrimination-config/migration.js
|
|
1716933
|
-
var
|
|
1719410
|
+
var import_promises132 = require("fs/promises");
|
|
1716934
1719411
|
var import_yaml10 = __toESM(require_dist2(), 1);
|
|
1716935
1719412
|
|
|
1716936
1719413
|
// ../cli-migrations/lib/migrations/0.0.248/add-error-discrimination-config/getAllRootApiYamlFiles.js
|
|
@@ -1716971,7 +1719448,7 @@ var migration9 = {
|
|
|
1716971
1719448
|
}
|
|
1716972
1719449
|
};
|
|
1716973
1719450
|
async function migrateRootApiFile(filepath) {
|
|
1716974
|
-
const contents = await (0,
|
|
1719451
|
+
const contents = await (0, import_promises132.readFile)(filepath);
|
|
1716975
1719452
|
const parsedDocument = import_yaml10.default.parseDocument(contents.toString());
|
|
1716976
1719453
|
const errorDiscriminant = parsedDocument.get("error-discriminant", true);
|
|
1716977
1719454
|
if (errorDiscriminant == null || !import_yaml10.default.isScalar(errorDiscriminant) || typeof errorDiscriminant.value !== "string") {
|
|
@@ -1716982,7 +1719459,7 @@ async function migrateRootApiFile(filepath) {
|
|
|
1716982
1719459
|
"property-name": errorDiscriminant.value
|
|
1716983
1719460
|
});
|
|
1716984
1719461
|
parsedDocument.delete("error-discriminant");
|
|
1716985
|
-
await (0,
|
|
1719462
|
+
await (0, import_promises132.writeFile)(filepath, parsedDocument.toString());
|
|
1716986
1719463
|
}
|
|
1716987
1719464
|
|
|
1716988
1719465
|
// ../cli-migrations/lib/migrations/0.0.248/index.js
|
|
@@ -1716993,7 +1719470,7 @@ var versionMigrations9 = {
|
|
|
1716993
1719470
|
var __default9 = versionMigrations9;
|
|
1716994
1719471
|
|
|
1716995
1719472
|
// ../cli-migrations/lib/migrations/0.1.3-rc3/add-inline-requests/migration.js
|
|
1716996
|
-
var
|
|
1719473
|
+
var import_promises133 = require("fs/promises");
|
|
1716997
1719474
|
var import_yaml11 = __toESM(require_dist2(), 1);
|
|
1716998
1719475
|
|
|
1716999
1719476
|
// ../cli-migrations/lib/migrations/0.1.3-rc3/add-inline-requests/getAllYamlFiles.js
|
|
@@ -1717034,7 +1719511,7 @@ var migration10 = {
|
|
|
1717034
1719511
|
}
|
|
1717035
1719512
|
};
|
|
1717036
1719513
|
async function migrateYamlFile(filepath, context2) {
|
|
1717037
|
-
const contents = await (0,
|
|
1719514
|
+
const contents = await (0, import_promises133.readFile)(filepath);
|
|
1717038
1719515
|
const parsedDocument = import_yaml11.default.parseDocument(contents.toString());
|
|
1717039
1719516
|
const services = parsedDocument.get("services");
|
|
1717040
1719517
|
if (services == null) {
|
|
@@ -1717074,7 +1719551,7 @@ async function migrateYamlFile(filepath, context2) {
|
|
|
1717074
1719551
|
context2.failWithoutThrowing("Failed to convert endpoint", e6);
|
|
1717075
1719552
|
}
|
|
1717076
1719553
|
}
|
|
1717077
|
-
await (0,
|
|
1719554
|
+
await (0, import_promises133.writeFile)(filepath, parsedDocument.toString());
|
|
1717078
1719555
|
}
|
|
1717079
1719556
|
}
|
|
1717080
1719557
|
function convertEndpoint21({ document: document4, endpoint: endpoint3 }) {
|
|
@@ -1717153,7 +1719630,7 @@ var versionMigrations10 = {
|
|
|
1717153
1719630
|
var __default10 = versionMigrations10;
|
|
1717154
1719631
|
|
|
1717155
1719632
|
// ../cli-migrations/lib/migrations/0.3.0-rc12/add-value-key-to-type-examples/migration.js
|
|
1717156
|
-
var
|
|
1719633
|
+
var import_promises134 = require("fs/promises");
|
|
1717157
1719634
|
var import_yaml12 = __toESM(require_dist2(), 1);
|
|
1717158
1719635
|
|
|
1717159
1719636
|
// ../cli-migrations/lib/migrations/0.3.0-rc12/add-value-key-to-type-examples/getAllYamlFiles.js
|
|
@@ -1717194,7 +1719671,7 @@ var migration11 = {
|
|
|
1717194
1719671
|
}
|
|
1717195
1719672
|
};
|
|
1717196
1719673
|
async function migrateYamlFile2(filepath, context2) {
|
|
1717197
|
-
const contents = await (0,
|
|
1719674
|
+
const contents = await (0, import_promises134.readFile)(filepath);
|
|
1717198
1719675
|
const parsedDocument = import_yaml12.default.parseDocument(contents.toString());
|
|
1717199
1719676
|
const types4 = parsedDocument.get("types");
|
|
1717200
1719677
|
if (types4 == null) {
|
|
@@ -1717220,7 +1719697,7 @@ async function migrateYamlFile2(filepath, context2) {
|
|
|
1717220
1719697
|
examples.set(i11, { value });
|
|
1717221
1719698
|
}
|
|
1717222
1719699
|
}
|
|
1717223
|
-
await (0,
|
|
1719700
|
+
await (0, import_promises134.writeFile)(filepath, parsedDocument.toString());
|
|
1717224
1719701
|
}
|
|
1717225
1719702
|
|
|
1717226
1719703
|
// ../cli-migrations/lib/migrations/0.3.0-rc12/index.js
|
|
@@ -1717231,7 +1719708,7 @@ var versionMigrations11 = {
|
|
|
1717231
1719708
|
var __default11 = versionMigrations11;
|
|
1717232
1719709
|
|
|
1717233
1719710
|
// ../cli-migrations/lib/migrations/0.3.23/change-services-key-to-service/migration.js
|
|
1717234
|
-
var
|
|
1719711
|
+
var import_promises135 = require("fs/promises");
|
|
1717235
1719712
|
var import_yaml13 = __toESM(require_dist2(), 1);
|
|
1717236
1719713
|
|
|
1717237
1719714
|
// ../cli-migrations/lib/migrations/0.3.23/change-services-key-to-service/getAllYamlFiles.js
|
|
@@ -1717272,7 +1719749,7 @@ var migration12 = {
|
|
|
1717272
1719749
|
}
|
|
1717273
1719750
|
};
|
|
1717274
1719751
|
async function migrateYamlFile3(filepath, context2) {
|
|
1717275
|
-
const contents = await (0,
|
|
1719752
|
+
const contents = await (0, import_promises135.readFile)(filepath);
|
|
1717276
1719753
|
const parsedDocument = import_yaml13.default.parseDocument(contents.toString());
|
|
1717277
1719754
|
if (!import_yaml13.default.isMap(parsedDocument.contents)) {
|
|
1717278
1719755
|
return context2.failAndThrow("File is not a map");
|
|
@@ -1717302,7 +1719779,7 @@ async function migrateYamlFile3(filepath, context2) {
|
|
|
1717302
1719779
|
pair.value = firstService.value;
|
|
1717303
1719780
|
}
|
|
1717304
1719781
|
}
|
|
1717305
|
-
await (0,
|
|
1719782
|
+
await (0, import_promises135.writeFile)(filepath, parsedDocument.toString());
|
|
1717306
1719783
|
}
|
|
1717307
1719784
|
|
|
1717308
1719785
|
// ../cli-migrations/lib/migrations/0.3.23/index.js
|
|
@@ -1717313,7 +1719790,7 @@ var versionMigrations12 = {
|
|
|
1717313
1719790
|
var __default12 = versionMigrations12;
|
|
1717314
1719791
|
|
|
1717315
1719792
|
// ../cli-migrations/lib/migrations/0.5.4/move-service-docs-to-top-level/migration.js
|
|
1717316
|
-
var
|
|
1719793
|
+
var import_promises136 = require("fs/promises");
|
|
1717317
1719794
|
var import_yaml14 = __toESM(require_dist2(), 1);
|
|
1717318
1719795
|
|
|
1717319
1719796
|
// ../cli-migrations/lib/migrations/0.5.4/move-service-docs-to-top-level/getAllYamlFiles.js
|
|
@@ -1717354,7 +1719831,7 @@ var migration13 = {
|
|
|
1717354
1719831
|
}
|
|
1717355
1719832
|
};
|
|
1717356
1719833
|
async function migrateYamlFile4(filepath, context2) {
|
|
1717357
|
-
const contents = await (0,
|
|
1719834
|
+
const contents = await (0, import_promises136.readFile)(filepath);
|
|
1717358
1719835
|
const parsedDocument = import_yaml14.default.parseDocument(contents.toString());
|
|
1717359
1719836
|
if (!import_yaml14.default.isMap(parsedDocument.contents)) {
|
|
1717360
1719837
|
return context2.failAndThrow("File is not a map");
|
|
@@ -1717373,7 +1719850,7 @@ async function migrateYamlFile4(filepath, context2) {
|
|
|
1717373
1719850
|
}
|
|
1717374
1719851
|
service.items.splice(indexOfServiceDocsPair, 1);
|
|
1717375
1719852
|
parsedDocument.contents.items.unshift(docsPair);
|
|
1717376
|
-
await (0,
|
|
1719853
|
+
await (0, import_promises136.writeFile)(filepath, parsedDocument.toString());
|
|
1717377
1719854
|
}
|
|
1717378
1719855
|
|
|
1717379
1719856
|
// ../cli-migrations/lib/migrations/0.5.4/index.js
|
|
@@ -1717384,7 +1719861,7 @@ var versionMigrations13 = {
|
|
|
1717384
1719861
|
var __default13 = versionMigrations13;
|
|
1717385
1719862
|
|
|
1717386
1719863
|
// ../cli-migrations/lib/migrations/0.9.10/add-suffix-to-docs-domain/migration.js
|
|
1717387
|
-
var
|
|
1719864
|
+
var import_promises137 = require("fs/promises");
|
|
1717388
1719865
|
|
|
1717389
1719866
|
// ../cli-migrations/lib/migrations/0.9.10/add-suffix-to-docs-domain/getAllGeneratorYamlFiles.js
|
|
1717390
1719867
|
var FERN_DIRECTORY15 = "fern";
|
|
@@ -1717424,14 +1719901,14 @@ var migration14 = {
|
|
|
1717424
1719901
|
}
|
|
1717425
1719902
|
};
|
|
1717426
1719903
|
async function migrateYamlFile5(filepath) {
|
|
1717427
|
-
const contents = await (0,
|
|
1719904
|
+
const contents = await (0, import_promises137.readFile)(filepath);
|
|
1717428
1719905
|
const domainSuffix = process.env.DOMAIN_SUFFIX ?? "docs.buildwithfern.com";
|
|
1717429
1719906
|
const regex5 = /(docs:\s*domain:\s*)"([^"]*)"/g;
|
|
1717430
1719907
|
const updatedSnapshot = contents.toString().replace(regex5, (_match, _prefix, domain3) => {
|
|
1717431
1719908
|
return `docs:
|
|
1717432
1719909
|
domain: "${domain3}.${domainSuffix}"`;
|
|
1717433
1719910
|
});
|
|
1717434
|
-
await (0,
|
|
1719911
|
+
await (0, import_promises137.writeFile)(filepath, updatedSnapshot.toString());
|
|
1717435
1719912
|
}
|
|
1717436
1719913
|
|
|
1717437
1719914
|
// ../cli-migrations/lib/migrations/0.9.10/index.js
|
|
@@ -1717447,10 +1719924,10 @@ var import_legacy_docs_config = __toESM(require_legacy_docs_config(), 1);
|
|
|
1717447
1719924
|
var LegacyDocsSerializers = __toESM(require_serialization44(), 1);
|
|
1717448
1719925
|
|
|
1717449
1719926
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/docs-config/loadRawDocsConfiguration.js
|
|
1717450
|
-
var
|
|
1719927
|
+
var import_promises138 = require("fs/promises");
|
|
1717451
1719928
|
async function loadRawDocsConfiguration2({ absolutePathToWorkspace }) {
|
|
1717452
1719929
|
const filepath = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
1717453
|
-
const contentsStr = await (0,
|
|
1719930
|
+
const contentsStr = await (0, import_promises138.readFile)(filepath);
|
|
1717454
1719931
|
const contentsParsed = jsYaml.load(contentsStr.toString());
|
|
1717455
1719932
|
const result = await LegacyDocsSerializers.DocsConfiguration.parse(contentsParsed);
|
|
1717456
1719933
|
if (result.ok) {
|
|
@@ -1717468,7 +1719945,7 @@ function getAbsolutePathToDocsFolder({ absolutePathToWorkspace }) {
|
|
|
1717468
1719945
|
}
|
|
1717469
1719946
|
|
|
1717470
1719947
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateDocsAndMultipleAPIs.js
|
|
1717471
|
-
var
|
|
1719948
|
+
var import_promises140 = require("fs/promises");
|
|
1717472
1719949
|
|
|
1717473
1719950
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/docs-config/convertLegacyDocsConfig.js
|
|
1717474
1719951
|
function convertLegacyDocsConfig({ docsConfiguration, docsURLs, apiName }) {
|
|
@@ -1717646,10 +1720123,10 @@ __export(legacy_exports, {
|
|
|
1717646
1720123
|
});
|
|
1717647
1720124
|
|
|
1717648
1720125
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/generators-configuration/loadRawGeneratorsConfiguration.js
|
|
1717649
|
-
var
|
|
1720126
|
+
var import_promises139 = require("fs/promises");
|
|
1717650
1720127
|
async function loadRawGeneratorsConfiguration2({ absolutePathToWorkspace }) {
|
|
1717651
1720128
|
const filepath = getAbsolutePathToGeneratorsConfiguration({ absolutePathToWorkspace });
|
|
1717652
|
-
const contentsStr = await (0,
|
|
1720129
|
+
const contentsStr = await (0, import_promises139.readFile)(filepath);
|
|
1717653
1720130
|
const contentsParsed = jsYaml.load(contentsStr.toString());
|
|
1717654
1720131
|
const result = await legacy_exports.GeneratorsConfigurationSchema.safeParseAsync(contentsParsed);
|
|
1717655
1720132
|
if (result.success) {
|
|
@@ -1717679,7 +1720156,7 @@ function migrateDocsInstances(docsURLs) {
|
|
|
1717679
1720156
|
var APIS_DIRECTORY2 = "apis";
|
|
1717680
1720157
|
async function migrateDocsAndMultipleAPIs({ absolutePathToFernDirectory, workspaces, workspaceContainingDocs }) {
|
|
1717681
1720158
|
const absolutePathToApisDirectory = join4(absolutePathToFernDirectory, RelativeFilePath2.of(APIS_DIRECTORY2));
|
|
1717682
|
-
await (0,
|
|
1720159
|
+
await (0, import_promises140.mkdir)(absolutePathToApisDirectory);
|
|
1717683
1720160
|
for (const workspace of workspaces) {
|
|
1717684
1720161
|
const absolutePathToWorkspace = join4(absolutePathToFernDirectory, RelativeFilePath2.of(workspace));
|
|
1717685
1720162
|
const docsURLs = await migrateAndWriteGeneratorsYml({ absolutePathToWorkspace });
|
|
@@ -1717687,11 +1720164,11 @@ async function migrateDocsAndMultipleAPIs({ absolutePathToFernDirectory, workspa
|
|
|
1717687
1720164
|
await migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiName: workspaceContainingDocs });
|
|
1717688
1720165
|
const absolutePathToDocsFolder = getAbsolutePathToDocsFolder({ absolutePathToWorkspace });
|
|
1717689
1720166
|
await moveFolder({ src: absolutePathToDocsFolder, dest: absolutePathToFernDirectory });
|
|
1717690
|
-
await (0,
|
|
1720167
|
+
await (0, import_promises140.rm)(absolutePathToDocsFolder, { recursive: true });
|
|
1717691
1720168
|
}
|
|
1717692
1720169
|
const absolutePathToNestedWorkspace = join4(absolutePathToApisDirectory, RelativeFilePath2.of(workspace));
|
|
1717693
1720170
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToNestedWorkspace });
|
|
1717694
|
-
await (0,
|
|
1720171
|
+
await (0, import_promises140.rm)(absolutePathToWorkspace, { recursive: true });
|
|
1717695
1720172
|
}
|
|
1717696
1720173
|
}
|
|
1717697
1720174
|
async function migrateAndWriteGeneratorsYml({ absolutePathToWorkspace }) {
|
|
@@ -1717704,7 +1720181,7 @@ async function migrateAndWriteGeneratorsYml({ absolutePathToWorkspace }) {
|
|
|
1717704
1720181
|
generatorsConfiguration,
|
|
1717705
1720182
|
pathModificationStrategy: PathModificationStrategy.Nest
|
|
1717706
1720183
|
});
|
|
1717707
|
-
await (0,
|
|
1720184
|
+
await (0, import_promises140.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
1717708
1720185
|
return convertedResponse.docsURLs;
|
|
1717709
1720186
|
}
|
|
1717710
1720187
|
async function migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiName }) {
|
|
@@ -1717718,19 +1720195,19 @@ async function migrateAndWriteDocsYml({ absolutePathToWorkspace, docsURLs, apiNa
|
|
|
1717718
1720195
|
apiName
|
|
1717719
1720196
|
});
|
|
1717720
1720197
|
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
1717721
|
-
await (0,
|
|
1720198
|
+
await (0, import_promises140.writeFile)(absolutePathToDocsConfig, jsYaml.dump(convertedDocsConfig));
|
|
1717722
1720199
|
}
|
|
1717723
1720200
|
|
|
1717724
1720201
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateDocsAndSingleAPI.js
|
|
1717725
|
-
var
|
|
1720202
|
+
var import_promises141 = require("fs/promises");
|
|
1717726
1720203
|
async function migrateDocsAndSingleAPI({ absolutePathToFernDirectory, absolutePathToWorkspace }) {
|
|
1717727
1720204
|
const docsURLs = await migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace });
|
|
1717728
1720205
|
await migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs });
|
|
1717729
1720206
|
const absolutePathToDocsFolder = getAbsolutePathToDocsFolder({ absolutePathToWorkspace });
|
|
1717730
1720207
|
await moveFolder({ src: absolutePathToDocsFolder, dest: absolutePathToFernDirectory });
|
|
1717731
1720208
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToFernDirectory });
|
|
1717732
|
-
await (0,
|
|
1717733
|
-
await (0,
|
|
1720209
|
+
await (0, import_promises141.rm)(absolutePathToDocsFolder, { recursive: true });
|
|
1720210
|
+
await (0, import_promises141.rm)(absolutePathToWorkspace, { recursive: true });
|
|
1717734
1720211
|
}
|
|
1717735
1720212
|
async function migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs }) {
|
|
1717736
1720213
|
const docsConfiguration = await loadRawDocsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -1717743,7 +1720220,7 @@ async function migrateAndWriteDocsYml2({ absolutePathToWorkspace, docsURLs }) {
|
|
|
1717743
1720220
|
apiName: void 0
|
|
1717744
1720221
|
});
|
|
1717745
1720222
|
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
|
|
1717746
|
-
await (0,
|
|
1720223
|
+
await (0, import_promises141.writeFile)(absolutePathToDocsConfig, jsYaml.dump(convertedDocsConfig));
|
|
1717747
1720224
|
}
|
|
1717748
1720225
|
async function migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace }) {
|
|
1717749
1720226
|
const generatorsConfiguration = await loadRawGeneratorsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -1717755,22 +1720232,22 @@ async function migrateAndWriteGeneratorsYml2({ absolutePathToWorkspace }) {
|
|
|
1717755
1720232
|
generatorsConfiguration,
|
|
1717756
1720233
|
pathModificationStrategy: "MoveUp"
|
|
1717757
1720234
|
});
|
|
1717758
|
-
await (0,
|
|
1720235
|
+
await (0, import_promises141.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
1717759
1720236
|
return convertedResponse.docsURLs;
|
|
1717760
1720237
|
}
|
|
1717761
1720238
|
|
|
1717762
1720239
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateOnlyMultipleAPIs.js
|
|
1717763
|
-
var
|
|
1720240
|
+
var import_promises142 = require("fs/promises");
|
|
1717764
1720241
|
var APIS_DIRECTORY3 = "apis";
|
|
1717765
1720242
|
async function migrateOnlyMultipleAPIs({ absolutePathToFernDirectory, workspaces }) {
|
|
1717766
1720243
|
const absolutePathToApisDirectory = join4(absolutePathToFernDirectory, RelativeFilePath2.of(APIS_DIRECTORY3));
|
|
1717767
|
-
await (0,
|
|
1720244
|
+
await (0, import_promises142.mkdir)(absolutePathToApisDirectory);
|
|
1717768
1720245
|
for (const workspace of workspaces) {
|
|
1717769
1720246
|
const absolutePathToWorkspace = join4(absolutePathToFernDirectory, RelativeFilePath2.of(workspace));
|
|
1717770
1720247
|
await migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace });
|
|
1717771
1720248
|
const absolutePathToNestedWorkspace = join4(absolutePathToApisDirectory, RelativeFilePath2.of(workspace));
|
|
1717772
1720249
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToNestedWorkspace });
|
|
1717773
|
-
await (0,
|
|
1720250
|
+
await (0, import_promises142.rm)(absolutePathToWorkspace, { recursive: true });
|
|
1717774
1720251
|
}
|
|
1717775
1720252
|
}
|
|
1717776
1720253
|
async function migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace }) {
|
|
@@ -1717783,15 +1720260,15 @@ async function migrateAndWriteGeneratorsYml3({ absolutePathToWorkspace }) {
|
|
|
1717783
1720260
|
generatorsConfiguration,
|
|
1717784
1720261
|
pathModificationStrategy: PathModificationStrategy.Nest
|
|
1717785
1720262
|
});
|
|
1717786
|
-
await (0,
|
|
1720263
|
+
await (0, import_promises142.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
1717787
1720264
|
}
|
|
1717788
1720265
|
|
|
1717789
1720266
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migrateOnlySingleAPI.js
|
|
1717790
|
-
var
|
|
1720267
|
+
var import_promises143 = require("fs/promises");
|
|
1717791
1720268
|
async function migrateOnlySingleAPI({ absolutePathToFernDirectory, absolutePathToWorkspace }) {
|
|
1717792
1720269
|
await migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace });
|
|
1717793
1720270
|
await moveFolder({ src: absolutePathToWorkspace, dest: absolutePathToFernDirectory });
|
|
1717794
|
-
await (0,
|
|
1720271
|
+
await (0, import_promises143.rm)(absolutePathToWorkspace, { recursive: true });
|
|
1717795
1720272
|
}
|
|
1717796
1720273
|
async function migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace }) {
|
|
1717797
1720274
|
const generatorsConfiguration = await loadRawGeneratorsConfiguration2({ absolutePathToWorkspace });
|
|
@@ -1717803,7 +1720280,7 @@ async function migrateAndWriteGeneratorsYml4({ absolutePathToWorkspace }) {
|
|
|
1717803
1720280
|
generatorsConfiguration,
|
|
1717804
1720281
|
pathModificationStrategy: "MoveUp"
|
|
1717805
1720282
|
});
|
|
1717806
|
-
await (0,
|
|
1720283
|
+
await (0, import_promises143.writeFile)(absolutePathToGeneratorsConfiguration, jsYaml.dump(convertedResponse.value));
|
|
1717807
1720284
|
}
|
|
1717808
1720285
|
|
|
1717809
1720286
|
// ../cli-migrations/lib/migrations/0.15.0-rc0/update-directory-structure/migration.js
|
|
@@ -1717880,7 +1720357,7 @@ var versionMigrations15 = {
|
|
|
1717880
1720357
|
var __default15 = versionMigrations15;
|
|
1717881
1720358
|
|
|
1717882
1720359
|
// ../cli-migrations/lib/migrations/0.41.0-rc0/require-generators-yml/migration.js
|
|
1717883
|
-
var
|
|
1720360
|
+
var import_promises144 = require("fs/promises");
|
|
1717884
1720361
|
var import_yaml15 = __toESM(require_dist2(), 1);
|
|
1717885
1720362
|
var migration16 = {
|
|
1717886
1720363
|
name: "require-generators-yml",
|
|
@@ -1717923,7 +1720400,7 @@ async function addApiConfigurationToSingleWorkspace({ absolutePathToFernDirector
|
|
|
1717923
1720400
|
if (existingGeneratorsYml == null) {
|
|
1717924
1720401
|
if (openapiDirectory != null && openapiDirectory.contents[0] != null) {
|
|
1717925
1720402
|
const absolutePathToGeneratorsYml = join4(absoluteFilepathToWorkspace, RelativeFilePath2.of("generators.yml"));
|
|
1717926
|
-
await (0,
|
|
1720403
|
+
await (0, import_promises144.writeFile)(absolutePathToGeneratorsYml, jsYaml.dump({
|
|
1717927
1720404
|
api: {
|
|
1717928
1720405
|
path: join4(relativize(absolutePathToFernDirectory, absoluteFilepathToWorkspace), RelativeFilePath2.of(openapiDirectory.name), RelativeFilePath2.of(openapiDirectory.contents[0]?.name))
|
|
1717929
1720406
|
}
|
|
@@ -1717938,7 +1720415,7 @@ async function addApiConfigurationToSingleWorkspace({ absolutePathToFernDirector
|
|
|
1717938
1720415
|
parsedDocument.set("api", {
|
|
1717939
1720416
|
path: join4(relativize(absolutePathToFernDirectory, absoluteFilepathToWorkspace), RelativeFilePath2.of(openapiDirectory.name), RelativeFilePath2.of(openapiDirectory.contents[0]?.name))
|
|
1717940
1720417
|
});
|
|
1717941
|
-
await (0,
|
|
1720418
|
+
await (0, import_promises144.writeFile)(existingGeneratorsYml.absolutePath, parsedDocument.toString());
|
|
1717942
1720419
|
context2.logger.info(source_default2.green(`Updated ${existingGeneratorsYml.absolutePath}`));
|
|
1717943
1720420
|
}
|
|
1717944
1720421
|
}
|
|
@@ -1717965,7 +1720442,7 @@ var versionMigrations16 = {
|
|
|
1717965
1720442
|
var __default16 = versionMigrations16;
|
|
1717966
1720443
|
|
|
1717967
1720444
|
// ../cli-migrations/lib/migrations/0.54.0-rc0/use-generators-yml-specs/migration.js
|
|
1717968
|
-
var
|
|
1720445
|
+
var import_promises145 = require("fs/promises");
|
|
1717969
1720446
|
var import_yaml16 = __toESM(require_dist2(), 1);
|
|
1717970
1720447
|
var migration17 = {
|
|
1717971
1720448
|
name: "generators-yml-use-api-specs",
|
|
@@ -1718145,7 +1720622,7 @@ async function addApiConfigurationToSingleWorkspace2({ absoluteFilepathToWorkspa
|
|
|
1718145
1720622
|
if (schemaComment && documentToWrite.indexOf(schemaComment) === -1) {
|
|
1718146
1720623
|
documentToWrite = `${schemaComment}${documentToWrite}`;
|
|
1718147
1720624
|
}
|
|
1718148
|
-
await (0,
|
|
1720625
|
+
await (0, import_promises145.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
1718149
1720626
|
context2.logger.info(source_default2.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
1718150
1720627
|
}
|
|
1718151
1720628
|
async function parseApiSpec({ oldSpec, absoluteFilepathToWorkspace, files, directories, context: context2, namespace }) {
|
|
@@ -1718192,7 +1720669,7 @@ async function parseApiSpec({ oldSpec, absoluteFilepathToWorkspace, files, direc
|
|
|
1718192
1720669
|
}
|
|
1718193
1720670
|
let specContent;
|
|
1718194
1720671
|
try {
|
|
1718195
|
-
const fileContents = await (0,
|
|
1720672
|
+
const fileContents = await (0, import_promises145.readFile)(absoluteSpecPath, { encoding: "utf-8" });
|
|
1718196
1720673
|
specContent = jsYaml.load(fileContents);
|
|
1718197
1720674
|
} catch (e6) {
|
|
1718198
1720675
|
context2.logger.warn(`Failed to read API spec file ${spec.path}. Error: ${e6}. Skipping...`);
|
|
@@ -1718295,7 +1720772,7 @@ var versionMigrations17 = {
|
|
|
1718295
1720772
|
var __default17 = versionMigrations17;
|
|
1718296
1720773
|
|
|
1718297
1720774
|
// ../cli-migrations/lib/migrations/0.82.1/add-path-parameter-order-setting/migration.js
|
|
1718298
|
-
var
|
|
1720775
|
+
var import_promises146 = require("fs/promises");
|
|
1718299
1720776
|
var migration18 = {
|
|
1718300
1720777
|
name: "add-path-parameter-order-setting",
|
|
1718301
1720778
|
summary: `Adds the 'path-parameter-order' setting to existing API configurations to maintain backwards compatibility.
|
|
@@ -1718383,7 +1720860,7 @@ async function updateGeneratorsYml({ context: context2, files }) {
|
|
|
1718383
1720860
|
documentToWrite = `${schemaComment}
|
|
1718384
1720861
|
${documentToWrite}`;
|
|
1718385
1720862
|
}
|
|
1718386
|
-
await (0,
|
|
1720863
|
+
await (0, import_promises146.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
1718387
1720864
|
context2.logger.info(source_default2.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
1718388
1720865
|
}
|
|
1718389
1720866
|
async function getFilesAndDirectories3(absoluteFilepath) {
|
|
@@ -1718419,7 +1720896,7 @@ var versionMigrations18 = {
|
|
|
1718419
1720896
|
var __default18 = versionMigrations18;
|
|
1718420
1720897
|
|
|
1718421
1720898
|
// ../cli-migrations/lib/migrations/1.0.0/update-settings-defaults/migration.js
|
|
1718422
|
-
var
|
|
1720899
|
+
var import_promises147 = require("fs/promises");
|
|
1718423
1720900
|
var migration19 = {
|
|
1718424
1720901
|
name: "update-1_0_0-defaults",
|
|
1718425
1720902
|
summary: `The defaults of the API spec settings have changed.
|
|
@@ -1718594,7 +1721071,7 @@ async function updateGeneratorsYml2({ context: context2, files }) {
|
|
|
1718594
1721071
|
documentToWrite = `${schemaComment}
|
|
1718595
1721072
|
${documentToWrite}`;
|
|
1718596
1721073
|
}
|
|
1718597
|
-
await (0,
|
|
1721074
|
+
await (0, import_promises147.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
1718598
1721075
|
context2.logger.info(source_default2.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
1718599
1721076
|
}
|
|
1718600
1721077
|
async function getFilesAndDirectories4(absoluteFilepath) {
|
|
@@ -1718663,7 +1721140,7 @@ var versionMigrations19 = {
|
|
|
1718663
1721140
|
var __default19 = versionMigrations19;
|
|
1718664
1721141
|
|
|
1718665
1721142
|
// ../cli-migrations/lib/migrations/2.0.0-rc0/update-settings-defaults/migration.js
|
|
1718666
|
-
var
|
|
1721143
|
+
var import_promises148 = require("fs/promises");
|
|
1718667
1721144
|
var migration20 = {
|
|
1718668
1721145
|
name: "update-2_0_0-defaults",
|
|
1718669
1721146
|
summary: `The default of 'coerce-enums-to-literals' has changed from true to false.
|
|
@@ -1718838,7 +1721315,7 @@ async function updateGeneratorsYml3({ context: context2, files }) {
|
|
|
1718838
1721315
|
documentToWrite = `${schemaComment}
|
|
1718839
1721316
|
${documentToWrite}`;
|
|
1718840
1721317
|
}
|
|
1718841
|
-
await (0,
|
|
1721318
|
+
await (0, import_promises148.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
1718842
1721319
|
context2.logger.info(source_default2.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
1718843
1721320
|
}
|
|
1718844
1721321
|
async function getFilesAndDirectories5(absoluteFilepath) {
|
|
@@ -1718884,7 +1721361,7 @@ var versionMigrations20 = {
|
|
|
1718884
1721361
|
var __default20 = versionMigrations20;
|
|
1718885
1721362
|
|
|
1718886
1721363
|
// ../cli-migrations/lib/migrations/2.13.0/migrate-deprecated-generator-api-settings/migration.js
|
|
1718887
|
-
var
|
|
1721364
|
+
var import_promises149 = require("fs/promises");
|
|
1718888
1721365
|
var migration21 = {
|
|
1718889
1721366
|
name: "migrate-deprecated-generator-api-settings",
|
|
1718890
1721367
|
summary: `Migrates deprecated generator-level API settings keys to their new equivalents:
|
|
@@ -1718975,7 +1721452,7 @@ async function updateGeneratorsYml4({ context: context2, files }) {
|
|
|
1718975
1721452
|
documentToWrite = `${schemaComment}
|
|
1718976
1721453
|
${documentToWrite}`;
|
|
1718977
1721454
|
}
|
|
1718978
|
-
await (0,
|
|
1721455
|
+
await (0, import_promises149.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
1718979
1721456
|
context2.logger.info(source_default2.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
1718980
1721457
|
}
|
|
1718981
1721458
|
function migrateDeprecatedSettings(settings, context2) {
|
|
@@ -1719021,7 +1721498,7 @@ var versionMigrations21 = {
|
|
|
1719021
1721498
|
var __default21 = versionMigrations21;
|
|
1719022
1721499
|
|
|
1719023
1721500
|
// ../cli-migrations/lib/migrations/3.0.0/enable-smart-casing/migration.js
|
|
1719024
|
-
var
|
|
1721501
|
+
var import_promises150 = require("fs/promises");
|
|
1719025
1721502
|
var migration22 = {
|
|
1719026
1721503
|
name: "enable-smart-casing",
|
|
1719027
1721504
|
summary: `Sets 'smart-casing: false' for existing generators to preserve backwards compatibility.
|
|
@@ -1719105,7 +1721582,7 @@ async function updateGeneratorsYml5({ context: context2, files }) {
|
|
|
1719105
1721582
|
documentToWrite = `${schemaComment}
|
|
1719106
1721583
|
${documentToWrite}`;
|
|
1719107
1721584
|
}
|
|
1719108
|
-
await (0,
|
|
1721585
|
+
await (0, import_promises150.writeFile)(generatorsYmlFile.absolutePath, documentToWrite);
|
|
1719109
1721586
|
context2.logger.info(source_default2.green(`Updated ${generatorsYmlFile.absolutePath}`));
|
|
1719110
1721587
|
}
|
|
1719111
1721588
|
function setSmartCasingFalseIfNotConfigured(generator, context2) {
|
|
@@ -1719246,7 +1721723,7 @@ ${source_default2.dim(migration23.summary)}`
|
|
|
1719246
1721723
|
}
|
|
1719247
1721724
|
|
|
1719248
1721725
|
// src/commands/upgrade/upgrade.ts
|
|
1719249
|
-
var
|
|
1721726
|
+
var import_promises151 = require("fs/promises");
|
|
1719250
1721727
|
|
|
1719251
1721728
|
// src/cwd.ts
|
|
1719252
1721729
|
var FERN_CWD_ENV_VAR = "FERN_CWD";
|
|
@@ -1719563,7 +1722040,7 @@ async function upgrade({
|
|
|
1719563
1722040
|
const newProjectConfig = produce(projectConfig2.rawConfig, (draft) => {
|
|
1719564
1722041
|
draft.version = resolvedTargetVersion;
|
|
1719565
1722042
|
});
|
|
1719566
|
-
await (0,
|
|
1722043
|
+
await (0, import_promises151.writeFile)(
|
|
1719567
1722044
|
projectConfig2._absolutePath,
|
|
1719568
1722045
|
ensureFinalNewline2(JSON.stringify(newProjectConfig, void 0, 2))
|
|
1719569
1722046
|
);
|
|
@@ -1719989,7 +1722466,7 @@ async function validateWorkspaces({
|
|
|
1719989
1722466
|
}
|
|
1719990
1722467
|
|
|
1719991
1722468
|
// src/commands/write-definition/writeDefinitionForWorkspaces.ts
|
|
1719992
|
-
var
|
|
1722469
|
+
var import_promises152 = require("fs/promises");
|
|
1719993
1722470
|
var import_path70 = __toESM(require("path"), 1);
|
|
1719994
1722471
|
async function writeDefinitionForWorkspaces({
|
|
1719995
1722472
|
project,
|
|
@@ -1720070,27 +1722547,27 @@ async function writeFernDefinition({
|
|
|
1720070
1722547
|
return a10.localeCompare(b18);
|
|
1720071
1722548
|
};
|
|
1720072
1722549
|
if (await doesPathExist(absolutePathToOutputDirectory)) {
|
|
1720073
|
-
await (0,
|
|
1722550
|
+
await (0, import_promises152.rm)(absolutePathToOutputDirectory, { recursive: true });
|
|
1720074
1722551
|
}
|
|
1720075
|
-
await (0,
|
|
1720076
|
-
await (0,
|
|
1722552
|
+
await (0, import_promises152.mkdir)(absolutePathToOutputDirectory, { recursive: true });
|
|
1722553
|
+
await (0, import_promises152.writeFile)(
|
|
1720077
1722554
|
join4(absolutePathToOutputDirectory, RelativeFilePath2.of(ROOT_API_FILENAME)),
|
|
1720078
1722555
|
jsYaml.dump(definition3.rootApiFile.contents, { sortKeys })
|
|
1720079
1722556
|
);
|
|
1720080
1722557
|
for (const [relativePath, packageMarker] of Object.entries(definition3.packageMarkers)) {
|
|
1720081
1722558
|
const absoluteFilepath = join4(absolutePathToOutputDirectory, RelativeFilePath2.of(relativePath));
|
|
1720082
|
-
await (0,
|
|
1720083
|
-
await (0,
|
|
1722559
|
+
await (0, import_promises152.mkdir)(dirname4(absoluteFilepath), { recursive: true });
|
|
1722560
|
+
await (0, import_promises152.writeFile)(absoluteFilepath, jsYaml.dump(packageMarker.contents, { sortKeys }));
|
|
1720084
1722561
|
}
|
|
1720085
1722562
|
for (const [relativePath, definitionFile] of Object.entries(definition3.namedDefinitionFiles)) {
|
|
1720086
1722563
|
const absoluteFilepath = join4(absolutePathToOutputDirectory, RelativeFilePath2.of(relativePath));
|
|
1720087
|
-
await (0,
|
|
1720088
|
-
await (0,
|
|
1722564
|
+
await (0, import_promises152.mkdir)(dirname4(absoluteFilepath), { recursive: true });
|
|
1722565
|
+
await (0, import_promises152.writeFile)(absoluteFilepath, jsYaml.dump(definitionFile.contents, { sortKeys }));
|
|
1720089
1722566
|
}
|
|
1720090
1722567
|
}
|
|
1720091
1722568
|
|
|
1720092
1722569
|
// src/commands/write-docs-definition/writeDocsDefinitionForProject.ts
|
|
1720093
|
-
var
|
|
1722570
|
+
var import_promises153 = require("fs/promises");
|
|
1720094
1722571
|
async function writeDocsDefinitionForProject({
|
|
1720095
1722572
|
project,
|
|
1720096
1722573
|
outputPath,
|
|
@@ -1720122,7 +1722599,7 @@ async function writeDocsDefinitionForProject({
|
|
|
1720122
1722599
|
targetAudiences: docsWorkspace.config.instances[0]?.audiences ? Array.isArray(docsWorkspace.config.instances[0].audiences) ? docsWorkspace.config.instances[0].audiences : [docsWorkspace.config.instances[0].audiences] : void 0
|
|
1720123
1722600
|
});
|
|
1720124
1722601
|
const docsDefinition = await docsResolver.resolve();
|
|
1720125
|
-
await (0,
|
|
1722602
|
+
await (0, import_promises153.writeFile)(AbsoluteFilePath2.of(outputPath), JSON.stringify(docsDefinition, null, 2));
|
|
1720126
1722603
|
context2.logger.info(source_default2.green(`Docs definition written to ${outputPath}`));
|
|
1720127
1722604
|
});
|
|
1720128
1722605
|
}
|
|
@@ -1720130,7 +1722607,7 @@ async function writeDocsDefinitionForProject({
|
|
|
1720130
1722607
|
// src/commands/write-translation/writeTranslationForProject.ts
|
|
1720131
1722608
|
var import_cli_progress2 = __toESM(require_cli_progress(), 1);
|
|
1720132
1722609
|
var import_fs26 = require("fs");
|
|
1720133
|
-
var
|
|
1722610
|
+
var import_promises157 = require("fs/promises");
|
|
1720134
1722611
|
var import_is_ci2 = __toESM(require_is_ci(), 1);
|
|
1720135
1722612
|
var import_path73 = __toESM(require("path"), 1);
|
|
1720136
1722613
|
|
|
@@ -1720615,7 +1723092,7 @@ function shouldProcessFile(filePath, stub) {
|
|
|
1720615
1723092
|
}
|
|
1720616
1723093
|
|
|
1720617
1723094
|
// src/commands/write-translation/docs-config-utils.ts
|
|
1720618
|
-
var
|
|
1723095
|
+
var import_promises154 = require("fs/promises");
|
|
1720619
1723096
|
|
|
1720620
1723097
|
// src/commands/write-translation/url-utils.ts
|
|
1720621
1723098
|
function addLanguageSuffixToUrl(url3, language) {
|
|
@@ -1720772,7 +1723249,7 @@ async function createLanguageSpecificDocsConfig({
|
|
|
1720772
1723249
|
stub = false
|
|
1720773
1723250
|
}) {
|
|
1720774
1723251
|
try {
|
|
1720775
|
-
const originalConfigContent = await (0,
|
|
1723252
|
+
const originalConfigContent = await (0, import_promises154.readFile)(originalDocsConfigPath, "utf-8");
|
|
1720776
1723253
|
const transformation = {
|
|
1720777
1723254
|
filePath: DOCS_CONFIGURATION_FILENAME,
|
|
1720778
1723255
|
language,
|
|
@@ -1720786,7 +1723263,7 @@ async function createLanguageSpecificDocsConfig({
|
|
|
1720786
1723263
|
const modifiedConfigContent = jsYaml.dump(modifiedConfig, {
|
|
1720787
1723264
|
sortKeys: false
|
|
1720788
1723265
|
});
|
|
1720789
|
-
await (0,
|
|
1723266
|
+
await (0, import_promises154.writeFile)(modifiedConfigPath, modifiedConfigContent, "utf-8");
|
|
1720790
1723267
|
context2.logger.debug(`Created language-specific docs config: ${modifiedConfigPath}`);
|
|
1720791
1723268
|
} catch (error49) {
|
|
1720792
1723269
|
if (error49 instanceof Error && error49.message.includes("403")) {
|
|
@@ -1720798,11 +1723275,11 @@ async function createLanguageSpecificDocsConfig({
|
|
|
1720798
1723275
|
|
|
1720799
1723276
|
// src/commands/write-translation/file-collection-utils.ts
|
|
1720800
1723277
|
var import_fs24 = require("fs");
|
|
1720801
|
-
var
|
|
1723278
|
+
var import_promises155 = require("fs/promises");
|
|
1720802
1723279
|
var import_path71 = __toESM(require("path"), 1);
|
|
1720803
1723280
|
async function collectFiles(baseDirectory, relativeBase) {
|
|
1720804
1723281
|
const discoveredFiles = {};
|
|
1720805
|
-
const entries10 = await (0,
|
|
1723282
|
+
const entries10 = await (0, import_promises155.readdir)(baseDirectory);
|
|
1720806
1723283
|
for (const entry of entries10) {
|
|
1720807
1723284
|
if (entry === "translations") {
|
|
1720808
1723285
|
continue;
|
|
@@ -1720825,7 +1723302,7 @@ async function collectFiles(baseDirectory, relativeBase) {
|
|
|
1720825
1723302
|
// src/commands/write-translation/hash-utils.ts
|
|
1720826
1723303
|
var import_crypto10 = require("crypto");
|
|
1720827
1723304
|
var import_fs25 = require("fs");
|
|
1720828
|
-
var
|
|
1723305
|
+
var import_promises156 = require("fs/promises");
|
|
1720829
1723306
|
var import_path72 = __toESM(require("path"), 1);
|
|
1720830
1723307
|
function calculateContentHash(content5) {
|
|
1720831
1723308
|
return (0, import_crypto10.createHash)("sha256").update(content5, "utf-8").digest("hex");
|
|
@@ -1720836,7 +1723313,7 @@ async function loadHashMappings(translationsDirectory) {
|
|
|
1720836
1723313
|
return {};
|
|
1720837
1723314
|
}
|
|
1720838
1723315
|
try {
|
|
1720839
|
-
const hashesContent = await (0,
|
|
1723316
|
+
const hashesContent = await (0, import_promises156.readFile)(hashesFilePath, "utf-8");
|
|
1720840
1723317
|
const parsed = JSON.parse(hashesContent);
|
|
1720841
1723318
|
const { _comment, ...hashMappings } = parsed;
|
|
1720842
1723319
|
return hashMappings;
|
|
@@ -1720857,11 +1723334,11 @@ async function saveHashMappings(translationsDirectory, hashMappings) {
|
|
|
1720857
1723334
|
_comment: "This file is auto-generated by Fern to track source file changes for translation purposes. Do not edit manually - it will be overwritten on the next translation update.",
|
|
1720858
1723335
|
...sortedMappings
|
|
1720859
1723336
|
};
|
|
1720860
|
-
await (0,
|
|
1723337
|
+
await (0, import_promises156.writeFile)(hashesFilePath, JSON.stringify(fileContent, null, 2), "utf-8");
|
|
1720861
1723338
|
}
|
|
1720862
1723339
|
async function hasFileChanged(filePath, relativePath, previousHashes) {
|
|
1720863
1723340
|
try {
|
|
1720864
|
-
const content5 = await (0,
|
|
1723341
|
+
const content5 = await (0, import_promises156.readFile)(filePath, "utf-8");
|
|
1720865
1723342
|
const currentHash = calculateContentHash(content5);
|
|
1720866
1723343
|
const previousHash = previousHashes[relativePath];
|
|
1720867
1723344
|
return currentHash !== previousHash;
|
|
@@ -1720914,7 +1723391,7 @@ async function writeTranslationForProject({
|
|
|
1720914
1723391
|
}
|
|
1720915
1723392
|
if (!(0, import_fs26.existsSync)(translationsDirectory)) {
|
|
1720916
1723393
|
context2.logger.debug(`Creating translations directory at: ${translationsDirectory}`);
|
|
1720917
|
-
await (0,
|
|
1723394
|
+
await (0, import_promises157.mkdir)(translationsDirectory, { recursive: true });
|
|
1720918
1723395
|
}
|
|
1720919
1723396
|
const languageStats = {};
|
|
1720920
1723397
|
const targetLanguages = languages.filter((lang) => lang !== sourceLanguage);
|
|
@@ -1720927,7 +1723404,7 @@ async function writeTranslationForProject({
|
|
|
1720927
1723404
|
RelativeFilePath2.of("fern")
|
|
1720928
1723405
|
);
|
|
1720929
1723406
|
if (!(0, import_fs26.existsSync)(languageDirectory)) {
|
|
1720930
|
-
await (0,
|
|
1723407
|
+
await (0, import_promises157.mkdir)(languageDirectory, { recursive: true });
|
|
1720931
1723408
|
}
|
|
1720932
1723409
|
languageStats[language] = {
|
|
1720933
1723410
|
filesProcessed: 0,
|
|
@@ -1721029,7 +1723506,7 @@ async function writeTranslationForProject({
|
|
|
1721029
1723506
|
`[COMPLETED] ${DOCS_CONFIGURATION_FILENAME} -> ${language}/${DOCS_CONFIGURATION_FILENAME}`
|
|
1721030
1723507
|
);
|
|
1721031
1723508
|
}
|
|
1721032
|
-
const originalConfigContent = await (0,
|
|
1723509
|
+
const originalConfigContent = await (0, import_promises157.readFile)(originalDocsConfigPath, "utf-8");
|
|
1721033
1723510
|
await updateAndSaveHashForFile(
|
|
1721034
1723511
|
translationsDirectory,
|
|
1721035
1723512
|
hashMappings,
|
|
@@ -1721074,7 +1723551,7 @@ async function writeTranslationForProject({
|
|
|
1721074
1723551
|
continue;
|
|
1721075
1723552
|
}
|
|
1721076
1723553
|
cliContext.logger.debug(`[PROCESSING] ${relativePath} (detected changes)`);
|
|
1721077
|
-
const originalContent = await (0,
|
|
1723554
|
+
const originalContent = await (0, import_promises157.readFile)(filePath, "utf-8");
|
|
1721078
1723555
|
await updateAndSaveHashForFile(translationsDirectory, hashMappings, relativePath, originalContent);
|
|
1721079
1723556
|
const sourceStats = languageStats[sourceLanguage];
|
|
1721080
1723557
|
if (sourceStats) {
|
|
@@ -1721099,7 +1723576,7 @@ async function writeTranslationForProject({
|
|
|
1721099
1723576
|
const destPath = join4(languageDirectory, relativePath);
|
|
1721100
1723577
|
const destDir = import_path73.default.dirname(destPath);
|
|
1721101
1723578
|
if (!(0, import_fs26.existsSync)(destDir)) {
|
|
1721102
|
-
await (0,
|
|
1723579
|
+
await (0, import_promises157.mkdir)(destDir, { recursive: true });
|
|
1721103
1723580
|
}
|
|
1721104
1723581
|
const transformation = {
|
|
1721105
1723582
|
filePath: relativePath,
|
|
@@ -1721112,7 +1723589,7 @@ async function writeTranslationForProject({
|
|
|
1721112
1723589
|
cliContext,
|
|
1721113
1723590
|
stub
|
|
1721114
1723591
|
});
|
|
1721115
|
-
await (0,
|
|
1723592
|
+
await (0, import_promises157.writeFile)(destPath, transformedContent, "utf-8");
|
|
1721116
1723593
|
const languageStatsForLang = languageStats[language];
|
|
1721117
1723594
|
if (languageStatsForLang) {
|
|
1721118
1723595
|
languageStatsForLang.filesProcessed++;
|
|
@@ -1721143,9 +1723620,9 @@ async function writeTranslationForProject({
|
|
|
1721143
1723620
|
const destPath = join4(languageDirectory, relativePath);
|
|
1721144
1723621
|
const destDir = import_path73.default.dirname(destPath);
|
|
1721145
1723622
|
if (!(0, import_fs26.existsSync)(destDir)) {
|
|
1721146
|
-
await (0,
|
|
1723623
|
+
await (0, import_promises157.mkdir)(destDir, { recursive: true });
|
|
1721147
1723624
|
}
|
|
1721148
|
-
await (0,
|
|
1723625
|
+
await (0, import_promises157.copyFile)(filePath, destPath);
|
|
1721149
1723626
|
assetsCopied++;
|
|
1721150
1723627
|
cliContext.logger.debug(`[ASSET COPIED] ${relativePath} -> ${language}/${relativePath}`);
|
|
1721151
1723628
|
}
|
|
@@ -1722529,9 +1725006,47 @@ function addDocsCommand(cli, cliContext) {
|
|
|
1722529
1725006
|
addDocsDevCommand(yargs, cliContext);
|
|
1722530
1725007
|
addDocsBrokenLinksCommand(yargs, cliContext);
|
|
1722531
1725008
|
addDocsPreviewCommand(yargs, cliContext);
|
|
1725009
|
+
addDocsDiffCommand(yargs, cliContext);
|
|
1722532
1725010
|
return yargs;
|
|
1722533
1725011
|
});
|
|
1722534
1725012
|
}
|
|
1725013
|
+
function addDocsDiffCommand(cli, cliContext) {
|
|
1725014
|
+
cli.command(
|
|
1725015
|
+
"diff <preview-url> <files..>",
|
|
1725016
|
+
"Generate visual diffs between preview and production docs pages",
|
|
1725017
|
+
(yargs) => yargs.positional("preview-url", {
|
|
1725018
|
+
type: "string",
|
|
1725019
|
+
description: "The preview deployment URL (e.g. acme-preview-abc123.docs.buildwithfern.com)",
|
|
1725020
|
+
demandOption: true
|
|
1725021
|
+
}).positional("files", {
|
|
1725022
|
+
type: "string",
|
|
1725023
|
+
array: true,
|
|
1725024
|
+
description: "File paths to generate diffs for (e.g. fern/pages/intro.mdx)",
|
|
1725025
|
+
demandOption: true
|
|
1725026
|
+
}).option("output", {
|
|
1725027
|
+
type: "string",
|
|
1725028
|
+
default: ".fern/diff",
|
|
1725029
|
+
description: "Output directory for diff images"
|
|
1725030
|
+
}),
|
|
1725031
|
+
async (argv) => {
|
|
1725032
|
+
await cliContext.instrumentPostHogEvent({
|
|
1725033
|
+
command: "fern docs diff"
|
|
1725034
|
+
});
|
|
1725035
|
+
const project = await loadProjectAndRegisterWorkspacesWithContext(cliContext, {
|
|
1725036
|
+
commandLineApiWorkspace: void 0,
|
|
1725037
|
+
defaultToAllApiWorkspaces: true
|
|
1725038
|
+
});
|
|
1725039
|
+
const result = await docsDiff({
|
|
1725040
|
+
cliContext,
|
|
1725041
|
+
project,
|
|
1725042
|
+
previewUrl: argv.previewUrl,
|
|
1725043
|
+
files: argv.files ?? [],
|
|
1725044
|
+
outputDir: argv.output
|
|
1725045
|
+
});
|
|
1725046
|
+
cliContext.logger.info(JSON.stringify(result, null, 2));
|
|
1725047
|
+
}
|
|
1725048
|
+
);
|
|
1725049
|
+
}
|
|
1722535
1725050
|
function addDocsPreviewCommand(cli, cliContext) {
|
|
1722536
1725051
|
cli.command("preview", "Commands for managing preview deployments", (yargs) => {
|
|
1722537
1725052
|
addDocsPreviewListCommand(yargs, cliContext);
|