@patterkit/cli 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +911 -401
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -12,11 +12,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
12
12
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
13
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
14
|
});
|
|
15
|
-
var __esm = (fn, res) => function __init() {
|
|
16
|
-
|
|
15
|
+
var __esm = (fn, res, err) => function __init() {
|
|
16
|
+
if (err) throw err[0];
|
|
17
|
+
try {
|
|
18
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw err = [e], e;
|
|
21
|
+
}
|
|
17
22
|
};
|
|
18
23
|
var __commonJS = (cb, mod) => function __require3() {
|
|
19
|
-
|
|
24
|
+
try {
|
|
25
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
throw mod = 0, e;
|
|
28
|
+
}
|
|
20
29
|
};
|
|
21
30
|
var __export = (target, all) => {
|
|
22
31
|
for (var name in all)
|
|
@@ -3600,7 +3609,7 @@ var require_worksheet = __commonJS({
|
|
|
3600
3609
|
// =========================================================================
|
|
3601
3610
|
// Worksheet Protection
|
|
3602
3611
|
protect(password, options) {
|
|
3603
|
-
return new Promise((
|
|
3612
|
+
return new Promise((resolve6) => {
|
|
3604
3613
|
this.sheetProtection = {
|
|
3605
3614
|
sheet: true
|
|
3606
3615
|
};
|
|
@@ -3624,7 +3633,7 @@ var require_worksheet = __commonJS({
|
|
|
3624
3633
|
delete this.sheetProtection.spinCount;
|
|
3625
3634
|
}
|
|
3626
3635
|
}
|
|
3627
|
-
|
|
3636
|
+
resolve6();
|
|
3628
3637
|
});
|
|
3629
3638
|
}
|
|
3630
3639
|
unprotect() {
|
|
@@ -6321,8 +6330,8 @@ var require_lib2 = __commonJS({
|
|
|
6321
6330
|
return this;
|
|
6322
6331
|
}
|
|
6323
6332
|
var p = this.constructor;
|
|
6324
|
-
return this.then(
|
|
6325
|
-
function
|
|
6333
|
+
return this.then(resolve7, reject3);
|
|
6334
|
+
function resolve7(value) {
|
|
6326
6335
|
function yes() {
|
|
6327
6336
|
return value;
|
|
6328
6337
|
}
|
|
@@ -6475,8 +6484,8 @@ var require_lib2 = __commonJS({
|
|
|
6475
6484
|
}
|
|
6476
6485
|
return out;
|
|
6477
6486
|
}
|
|
6478
|
-
Promise2.resolve =
|
|
6479
|
-
function
|
|
6487
|
+
Promise2.resolve = resolve6;
|
|
6488
|
+
function resolve6(value) {
|
|
6480
6489
|
if (value instanceof this) {
|
|
6481
6490
|
return value;
|
|
6482
6491
|
}
|
|
@@ -7008,10 +7017,10 @@ var require_utils = __commonJS({
|
|
|
7008
7017
|
var promise = external.Promise.resolve(inputData).then(function(data) {
|
|
7009
7018
|
var isBlob = support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1);
|
|
7010
7019
|
if (isBlob && typeof FileReader !== "undefined") {
|
|
7011
|
-
return new external.Promise(function(
|
|
7020
|
+
return new external.Promise(function(resolve6, reject2) {
|
|
7012
7021
|
var reader = new FileReader();
|
|
7013
7022
|
reader.onload = function(e) {
|
|
7014
|
-
|
|
7023
|
+
resolve6(e.target.result);
|
|
7015
7024
|
};
|
|
7016
7025
|
reader.onerror = function(e) {
|
|
7017
7026
|
reject2(e.target.error);
|
|
@@ -7566,7 +7575,7 @@ var require_StreamHelper = __commonJS({
|
|
|
7566
7575
|
}
|
|
7567
7576
|
}
|
|
7568
7577
|
function accumulate(helper, updateCallback) {
|
|
7569
|
-
return new external.Promise(function(
|
|
7578
|
+
return new external.Promise(function(resolve6, reject2) {
|
|
7570
7579
|
var dataArray = [];
|
|
7571
7580
|
var chunkType = helper._internalType, resultType = helper._outputType, mimeType = helper._mimeType;
|
|
7572
7581
|
helper.on("data", function(data, meta) {
|
|
@@ -7580,7 +7589,7 @@ var require_StreamHelper = __commonJS({
|
|
|
7580
7589
|
}).on("end", function() {
|
|
7581
7590
|
try {
|
|
7582
7591
|
var result = transformZipOutput(resultType, concat2(chunkType, dataArray), mimeType);
|
|
7583
|
-
|
|
7592
|
+
resolve6(result);
|
|
7584
7593
|
} catch (e) {
|
|
7585
7594
|
reject2(e);
|
|
7586
7595
|
}
|
|
@@ -13693,7 +13702,7 @@ var require_load = __commonJS({
|
|
|
13693
13702
|
var Crc32Probe = require_Crc32Probe();
|
|
13694
13703
|
var nodejsUtils = require_nodejsUtils();
|
|
13695
13704
|
function checkEntryCRC32(zipEntry) {
|
|
13696
|
-
return new external.Promise(function(
|
|
13705
|
+
return new external.Promise(function(resolve6, reject2) {
|
|
13697
13706
|
var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
|
|
13698
13707
|
worker.on("error", function(e) {
|
|
13699
13708
|
reject2(e);
|
|
@@ -13701,7 +13710,7 @@ var require_load = __commonJS({
|
|
|
13701
13710
|
if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
|
|
13702
13711
|
reject2(new Error("Corrupted zip : CRC32 mismatch"));
|
|
13703
13712
|
} else {
|
|
13704
|
-
|
|
13713
|
+
resolve6();
|
|
13705
13714
|
}
|
|
13706
13715
|
}).resume();
|
|
13707
13716
|
});
|
|
@@ -14958,14 +14967,14 @@ var require_async_iterator = __commonJS({
|
|
|
14958
14967
|
};
|
|
14959
14968
|
}
|
|
14960
14969
|
function readAndResolve(iter) {
|
|
14961
|
-
var
|
|
14962
|
-
if (
|
|
14970
|
+
var resolve6 = iter[kLastResolve];
|
|
14971
|
+
if (resolve6 !== null) {
|
|
14963
14972
|
var data = iter[kStream].read();
|
|
14964
14973
|
if (data !== null) {
|
|
14965
14974
|
iter[kLastPromise] = null;
|
|
14966
14975
|
iter[kLastResolve] = null;
|
|
14967
14976
|
iter[kLastReject] = null;
|
|
14968
|
-
|
|
14977
|
+
resolve6(createIterResult(data, false));
|
|
14969
14978
|
}
|
|
14970
14979
|
}
|
|
14971
14980
|
}
|
|
@@ -14973,13 +14982,13 @@ var require_async_iterator = __commonJS({
|
|
|
14973
14982
|
process.nextTick(readAndResolve, iter);
|
|
14974
14983
|
}
|
|
14975
14984
|
function wrapForNext(lastPromise, iter) {
|
|
14976
|
-
return function(
|
|
14985
|
+
return function(resolve6, reject2) {
|
|
14977
14986
|
lastPromise.then(function() {
|
|
14978
14987
|
if (iter[kEnded]) {
|
|
14979
|
-
|
|
14988
|
+
resolve6(createIterResult(void 0, true));
|
|
14980
14989
|
return;
|
|
14981
14990
|
}
|
|
14982
|
-
iter[kHandlePromise](
|
|
14991
|
+
iter[kHandlePromise](resolve6, reject2);
|
|
14983
14992
|
}, reject2);
|
|
14984
14993
|
};
|
|
14985
14994
|
}
|
|
@@ -14999,12 +15008,12 @@ var require_async_iterator = __commonJS({
|
|
|
14999
15008
|
return Promise.resolve(createIterResult(void 0, true));
|
|
15000
15009
|
}
|
|
15001
15010
|
if (this[kStream].destroyed) {
|
|
15002
|
-
return new Promise(function(
|
|
15011
|
+
return new Promise(function(resolve6, reject2) {
|
|
15003
15012
|
process.nextTick(function() {
|
|
15004
15013
|
if (_this[kError]) {
|
|
15005
15014
|
reject2(_this[kError]);
|
|
15006
15015
|
} else {
|
|
15007
|
-
|
|
15016
|
+
resolve6(createIterResult(void 0, true));
|
|
15008
15017
|
}
|
|
15009
15018
|
});
|
|
15010
15019
|
});
|
|
@@ -15027,13 +15036,13 @@ var require_async_iterator = __commonJS({
|
|
|
15027
15036
|
return this;
|
|
15028
15037
|
}), _defineProperty2(_Object$setPrototypeO, "return", function _return() {
|
|
15029
15038
|
var _this2 = this;
|
|
15030
|
-
return new Promise(function(
|
|
15039
|
+
return new Promise(function(resolve6, reject2) {
|
|
15031
15040
|
_this2[kStream].destroy(null, function(err) {
|
|
15032
15041
|
if (err) {
|
|
15033
15042
|
reject2(err);
|
|
15034
15043
|
return;
|
|
15035
15044
|
}
|
|
15036
|
-
|
|
15045
|
+
resolve6(createIterResult(void 0, true));
|
|
15037
15046
|
});
|
|
15038
15047
|
});
|
|
15039
15048
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
@@ -15055,15 +15064,15 @@ var require_async_iterator = __commonJS({
|
|
|
15055
15064
|
value: stream2._readableState.endEmitted,
|
|
15056
15065
|
writable: true
|
|
15057
15066
|
}), _defineProperty2(_Object$create, kHandlePromise, {
|
|
15058
|
-
value: function value(
|
|
15067
|
+
value: function value(resolve6, reject2) {
|
|
15059
15068
|
var data = iterator[kStream].read();
|
|
15060
15069
|
if (data) {
|
|
15061
15070
|
iterator[kLastPromise] = null;
|
|
15062
15071
|
iterator[kLastResolve] = null;
|
|
15063
15072
|
iterator[kLastReject] = null;
|
|
15064
|
-
|
|
15073
|
+
resolve6(createIterResult(data, false));
|
|
15065
15074
|
} else {
|
|
15066
|
-
iterator[kLastResolve] =
|
|
15075
|
+
iterator[kLastResolve] = resolve6;
|
|
15067
15076
|
iterator[kLastReject] = reject2;
|
|
15068
15077
|
}
|
|
15069
15078
|
},
|
|
@@ -15082,12 +15091,12 @@ var require_async_iterator = __commonJS({
|
|
|
15082
15091
|
iterator[kError] = err;
|
|
15083
15092
|
return;
|
|
15084
15093
|
}
|
|
15085
|
-
var
|
|
15086
|
-
if (
|
|
15094
|
+
var resolve6 = iterator[kLastResolve];
|
|
15095
|
+
if (resolve6 !== null) {
|
|
15087
15096
|
iterator[kLastPromise] = null;
|
|
15088
15097
|
iterator[kLastResolve] = null;
|
|
15089
15098
|
iterator[kLastReject] = null;
|
|
15090
|
-
|
|
15099
|
+
resolve6(createIterResult(void 0, true));
|
|
15091
15100
|
}
|
|
15092
15101
|
iterator[kEnded] = true;
|
|
15093
15102
|
});
|
|
@@ -15102,7 +15111,7 @@ var require_async_iterator = __commonJS({
|
|
|
15102
15111
|
var require_from = __commonJS({
|
|
15103
15112
|
"../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
|
|
15104
15113
|
"use strict";
|
|
15105
|
-
function asyncGeneratorStep2(gen,
|
|
15114
|
+
function asyncGeneratorStep2(gen, resolve6, reject2, _next, _throw, key2, arg) {
|
|
15106
15115
|
try {
|
|
15107
15116
|
var info = gen[key2](arg);
|
|
15108
15117
|
var value = info.value;
|
|
@@ -15111,7 +15120,7 @@ var require_from = __commonJS({
|
|
|
15111
15120
|
return;
|
|
15112
15121
|
}
|
|
15113
15122
|
if (info.done) {
|
|
15114
|
-
|
|
15123
|
+
resolve6(value);
|
|
15115
15124
|
} else {
|
|
15116
15125
|
Promise.resolve(value).then(_next, _throw);
|
|
15117
15126
|
}
|
|
@@ -15119,13 +15128,13 @@ var require_from = __commonJS({
|
|
|
15119
15128
|
function _asyncToGenerator2(fn) {
|
|
15120
15129
|
return function() {
|
|
15121
15130
|
var self2 = this, args = arguments;
|
|
15122
|
-
return new Promise(function(
|
|
15131
|
+
return new Promise(function(resolve6, reject2) {
|
|
15123
15132
|
var gen = fn.apply(self2, args);
|
|
15124
15133
|
function _next(value) {
|
|
15125
|
-
asyncGeneratorStep2(gen,
|
|
15134
|
+
asyncGeneratorStep2(gen, resolve6, reject2, _next, _throw, "next", value);
|
|
15126
15135
|
}
|
|
15127
15136
|
function _throw(err) {
|
|
15128
|
-
asyncGeneratorStep2(gen,
|
|
15137
|
+
asyncGeneratorStep2(gen, resolve6, reject2, _next, _throw, "throw", err);
|
|
15129
15138
|
}
|
|
15130
15139
|
_next(void 0);
|
|
15131
15140
|
});
|
|
@@ -16214,14 +16223,14 @@ var require_utils2 = __commonJS({
|
|
|
16214
16223
|
nop() {
|
|
16215
16224
|
},
|
|
16216
16225
|
promiseImmediate(value) {
|
|
16217
|
-
return new Promise((
|
|
16226
|
+
return new Promise((resolve6) => {
|
|
16218
16227
|
if (global.setImmediate) {
|
|
16219
16228
|
setImmediate(() => {
|
|
16220
|
-
|
|
16229
|
+
resolve6(value);
|
|
16221
16230
|
});
|
|
16222
16231
|
} else {
|
|
16223
16232
|
setTimeout(() => {
|
|
16224
|
-
|
|
16233
|
+
resolve6(value);
|
|
16225
16234
|
}, 1);
|
|
16226
16235
|
}
|
|
16227
16236
|
});
|
|
@@ -16321,9 +16330,9 @@ var require_utils2 = __commonJS({
|
|
|
16321
16330
|
},
|
|
16322
16331
|
fs: {
|
|
16323
16332
|
exists(path) {
|
|
16324
|
-
return new Promise((
|
|
16333
|
+
return new Promise((resolve6) => {
|
|
16325
16334
|
fs4.access(path, fs4.constants.F_OK, (err) => {
|
|
16326
|
-
|
|
16335
|
+
resolve6(!err);
|
|
16327
16336
|
});
|
|
16328
16337
|
});
|
|
16329
16338
|
}
|
|
@@ -16548,9 +16557,9 @@ var require_stream_buf = __commonJS({
|
|
|
16548
16557
|
},
|
|
16549
16558
|
async _pipe(chunk) {
|
|
16550
16559
|
const write2 = function(pipe) {
|
|
16551
|
-
return new Promise((
|
|
16560
|
+
return new Promise((resolve6) => {
|
|
16552
16561
|
pipe.write(chunk.toBuffer(), () => {
|
|
16553
|
-
|
|
16562
|
+
resolve6();
|
|
16554
16563
|
});
|
|
16555
16564
|
});
|
|
16556
16565
|
};
|
|
@@ -28560,12 +28569,12 @@ var require_xlsx = __commonJS({
|
|
|
28560
28569
|
var VmlNotesXform = require_vml_notes_xform();
|
|
28561
28570
|
var theme1Xml = require_theme1();
|
|
28562
28571
|
function fsReadFileAsync(filename, options) {
|
|
28563
|
-
return new Promise((
|
|
28572
|
+
return new Promise((resolve6, reject2) => {
|
|
28564
28573
|
fs4.readFile(filename, options, (error, data) => {
|
|
28565
28574
|
if (error) {
|
|
28566
28575
|
reject2(error);
|
|
28567
28576
|
} else {
|
|
28568
|
-
|
|
28577
|
+
resolve6(data);
|
|
28569
28578
|
}
|
|
28570
28579
|
});
|
|
28571
28580
|
});
|
|
@@ -28692,7 +28701,7 @@ var require_xlsx = __commonJS({
|
|
|
28692
28701
|
if (lastDot >= 1) {
|
|
28693
28702
|
const extension = filename.substr(lastDot + 1);
|
|
28694
28703
|
const name = filename.substr(0, lastDot);
|
|
28695
|
-
await new Promise((
|
|
28704
|
+
await new Promise((resolve6, reject2) => {
|
|
28696
28705
|
const streamBuf = new StreamBuf();
|
|
28697
28706
|
streamBuf.on("finish", () => {
|
|
28698
28707
|
model.mediaIndex[filename] = model.media.length;
|
|
@@ -28704,7 +28713,7 @@ var require_xlsx = __commonJS({
|
|
|
28704
28713
|
buffer: streamBuf.toBuffer()
|
|
28705
28714
|
};
|
|
28706
28715
|
model.media.push(medium);
|
|
28707
|
-
|
|
28716
|
+
resolve6();
|
|
28708
28717
|
});
|
|
28709
28718
|
entry.on("error", (error) => {
|
|
28710
28719
|
reject2(error);
|
|
@@ -28729,13 +28738,13 @@ var require_xlsx = __commonJS({
|
|
|
28729
28738
|
model.vmlDrawings[`../drawings/${name}.vml`] = vmlDrawing;
|
|
28730
28739
|
}
|
|
28731
28740
|
async _processThemeEntry(entry, model, name) {
|
|
28732
|
-
await new Promise((
|
|
28741
|
+
await new Promise((resolve6, reject2) => {
|
|
28733
28742
|
const stream2 = new StreamBuf();
|
|
28734
28743
|
entry.on("error", reject2);
|
|
28735
28744
|
stream2.on("error", reject2);
|
|
28736
28745
|
stream2.on("finish", () => {
|
|
28737
28746
|
model.themes[name] = stream2.read().toString();
|
|
28738
|
-
|
|
28747
|
+
resolve6();
|
|
28739
28748
|
});
|
|
28740
28749
|
entry.pipe(stream2);
|
|
28741
28750
|
});
|
|
@@ -29043,9 +29052,9 @@ var require_xlsx = __commonJS({
|
|
|
29043
29052
|
});
|
|
29044
29053
|
}
|
|
29045
29054
|
_finalize(zip) {
|
|
29046
|
-
return new Promise((
|
|
29055
|
+
return new Promise((resolve6, reject2) => {
|
|
29047
29056
|
zip.on("finish", () => {
|
|
29048
|
-
|
|
29057
|
+
resolve6(this);
|
|
29049
29058
|
});
|
|
29050
29059
|
zip.on("error", reject2);
|
|
29051
29060
|
zip.finalize();
|
|
@@ -29105,9 +29114,9 @@ var require_xlsx = __commonJS({
|
|
|
29105
29114
|
}
|
|
29106
29115
|
writeFile(filename, options) {
|
|
29107
29116
|
const stream2 = fs4.createWriteStream(filename);
|
|
29108
|
-
return new Promise((
|
|
29117
|
+
return new Promise((resolve6, reject2) => {
|
|
29109
29118
|
stream2.on("finish", () => {
|
|
29110
|
-
|
|
29119
|
+
resolve6();
|
|
29111
29120
|
});
|
|
29112
29121
|
stream2.on("error", (error) => {
|
|
29113
29122
|
reject2(error);
|
|
@@ -33244,7 +33253,7 @@ var require_csv = __commonJS({
|
|
|
33244
33253
|
}
|
|
33245
33254
|
read(stream2, options) {
|
|
33246
33255
|
options = options || {};
|
|
33247
|
-
return new Promise((
|
|
33256
|
+
return new Promise((resolve6, reject2) => {
|
|
33248
33257
|
const worksheet = this.workbook.addWorksheet(options.sheetName);
|
|
33249
33258
|
const dateFormats = options.dateFormats || [
|
|
33250
33259
|
"YYYY-MM-DD[T]HH:mm:ssZ",
|
|
@@ -33284,7 +33293,7 @@ var require_csv = __commonJS({
|
|
|
33284
33293
|
}).on("end", () => {
|
|
33285
33294
|
csvStream.emit("worksheet", worksheet);
|
|
33286
33295
|
});
|
|
33287
|
-
csvStream.on("worksheet",
|
|
33296
|
+
csvStream.on("worksheet", resolve6).on("error", reject2);
|
|
33288
33297
|
stream2.pipe(csvStream);
|
|
33289
33298
|
});
|
|
33290
33299
|
}
|
|
@@ -33297,12 +33306,12 @@ var require_csv = __commonJS({
|
|
|
33297
33306
|
);
|
|
33298
33307
|
}
|
|
33299
33308
|
write(stream2, options) {
|
|
33300
|
-
return new Promise((
|
|
33309
|
+
return new Promise((resolve6, reject2) => {
|
|
33301
33310
|
options = options || {};
|
|
33302
33311
|
const worksheet = this.workbook.getWorksheet(options.sheetName || options.sheetId);
|
|
33303
33312
|
const csvStream = fastCsv.format(options.formatterOptions);
|
|
33304
33313
|
stream2.on("finish", () => {
|
|
33305
|
-
|
|
33314
|
+
resolve6();
|
|
33306
33315
|
});
|
|
33307
33316
|
csvStream.on("error", reject2);
|
|
33308
33317
|
csvStream.pipe(stream2);
|
|
@@ -33651,6 +33660,8 @@ var require_brace_expansion = __commonJS({
|
|
|
33651
33660
|
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
33652
33661
|
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
33653
33662
|
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
33663
|
+
var EXPANSION_MAX = 1e5;
|
|
33664
|
+
var EXPANSION_MAX_LENGTH = 4e6;
|
|
33654
33665
|
function numeric(str) {
|
|
33655
33666
|
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
33656
33667
|
}
|
|
@@ -33684,11 +33695,12 @@ var require_brace_expansion = __commonJS({
|
|
|
33684
33695
|
if (!str)
|
|
33685
33696
|
return [];
|
|
33686
33697
|
options = options || {};
|
|
33687
|
-
var max = options.max == null ?
|
|
33698
|
+
var max = options.max == null ? EXPANSION_MAX : options.max;
|
|
33699
|
+
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
|
33688
33700
|
if (str.substr(0, 2) === "{}") {
|
|
33689
33701
|
str = "\\{\\}" + str.substr(2);
|
|
33690
33702
|
}
|
|
33691
|
-
return expand(escapeBraces(str), max, true).map(unescapeBraces);
|
|
33703
|
+
return expand(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
33692
33704
|
}
|
|
33693
33705
|
function embrace(str) {
|
|
33694
33706
|
return "{" + str + "}";
|
|
@@ -33702,18 +33714,90 @@ var require_brace_expansion = __commonJS({
|
|
|
33702
33714
|
function gte(i, y) {
|
|
33703
33715
|
return i >= y;
|
|
33704
33716
|
}
|
|
33705
|
-
function
|
|
33706
|
-
var
|
|
33707
|
-
var
|
|
33708
|
-
|
|
33709
|
-
|
|
33710
|
-
|
|
33711
|
-
|
|
33712
|
-
|
|
33713
|
-
|
|
33714
|
-
|
|
33717
|
+
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
|
33718
|
+
var out = [];
|
|
33719
|
+
var length = 0;
|
|
33720
|
+
for (var a = 0; a < acc.length; a++) {
|
|
33721
|
+
for (var v = 0; v < values.length; v++) {
|
|
33722
|
+
if (out.length >= max) return out;
|
|
33723
|
+
var expansion = acc[a] + pre + values[v];
|
|
33724
|
+
if (dropEmpties && !expansion) continue;
|
|
33725
|
+
if (length + expansion.length > maxLength) return out;
|
|
33726
|
+
out.push(expansion);
|
|
33727
|
+
length += expansion.length;
|
|
33728
|
+
}
|
|
33729
|
+
}
|
|
33730
|
+
return out;
|
|
33731
|
+
}
|
|
33732
|
+
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
33733
|
+
var n = body.split(/\.\./);
|
|
33734
|
+
var N = [];
|
|
33735
|
+
if (n[0] === void 0 || n[1] === void 0) {
|
|
33736
|
+
return N;
|
|
33737
|
+
}
|
|
33738
|
+
var x = numeric(n[0]);
|
|
33739
|
+
var y = numeric(n[1]);
|
|
33740
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
33741
|
+
var incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
33742
|
+
var test = lte;
|
|
33743
|
+
var reverse = y < x;
|
|
33744
|
+
if (reverse) {
|
|
33745
|
+
incr *= -1;
|
|
33746
|
+
test = gte;
|
|
33747
|
+
}
|
|
33748
|
+
var pad2 = n.some(isPadded);
|
|
33749
|
+
var length = 0;
|
|
33750
|
+
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
|
33751
|
+
var c2;
|
|
33752
|
+
if (isAlphaSequence) {
|
|
33753
|
+
c2 = String.fromCharCode(i);
|
|
33754
|
+
if (c2 === "\\") {
|
|
33755
|
+
c2 = "";
|
|
33756
|
+
}
|
|
33757
|
+
} else {
|
|
33758
|
+
c2 = String(i);
|
|
33759
|
+
if (pad2) {
|
|
33760
|
+
var need = width - c2.length;
|
|
33761
|
+
if (need > 0) {
|
|
33762
|
+
var z = new Array(need + 1).join("0");
|
|
33763
|
+
if (i < 0) {
|
|
33764
|
+
c2 = "-" + z + c2.slice(1);
|
|
33765
|
+
} else {
|
|
33766
|
+
c2 = z + c2;
|
|
33767
|
+
}
|
|
33768
|
+
}
|
|
33769
|
+
}
|
|
33770
|
+
}
|
|
33771
|
+
if (length + c2.length > maxLength) break;
|
|
33772
|
+
N.push(c2);
|
|
33773
|
+
length += c2.length;
|
|
33774
|
+
}
|
|
33775
|
+
return N;
|
|
33776
|
+
}
|
|
33777
|
+
function expand(str, max, maxLength, isTop) {
|
|
33778
|
+
var acc = [""];
|
|
33779
|
+
var dropEmpties = false;
|
|
33780
|
+
var firstGroup = true;
|
|
33781
|
+
for (; ; ) {
|
|
33782
|
+
const m = balanced("{", "}", str);
|
|
33783
|
+
if (!m) {
|
|
33784
|
+
return combine(acc, str, [""], max, maxLength, dropEmpties);
|
|
33785
|
+
}
|
|
33786
|
+
const pre = m.pre;
|
|
33787
|
+
if (/\$$/.test(pre)) {
|
|
33788
|
+
acc = combine(
|
|
33789
|
+
acc,
|
|
33790
|
+
pre + "{" + m.body + "}",
|
|
33791
|
+
[""],
|
|
33792
|
+
max,
|
|
33793
|
+
maxLength,
|
|
33794
|
+
dropEmpties && !m.post.length
|
|
33795
|
+
);
|
|
33796
|
+
firstGroup = false;
|
|
33797
|
+
if (!m.post.length) break;
|
|
33798
|
+
str = m.post;
|
|
33799
|
+
continue;
|
|
33715
33800
|
}
|
|
33716
|
-
} else {
|
|
33717
33801
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
33718
33802
|
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
33719
33803
|
var isSequence = isNumericSequence || isAlphaSequence;
|
|
@@ -33721,74 +33805,69 @@ var require_brace_expansion = __commonJS({
|
|
|
33721
33805
|
if (!isSequence && !isOptions) {
|
|
33722
33806
|
if (m.post.match(/,(?!,).*\}/)) {
|
|
33723
33807
|
str = m.pre + "{" + m.body + escClose + m.post;
|
|
33724
|
-
|
|
33808
|
+
isTop = true;
|
|
33809
|
+
continue;
|
|
33725
33810
|
}
|
|
33726
|
-
return
|
|
33811
|
+
return combine(
|
|
33812
|
+
acc,
|
|
33813
|
+
pre + "{" + m.body + "}" + m.post,
|
|
33814
|
+
[""],
|
|
33815
|
+
max,
|
|
33816
|
+
maxLength,
|
|
33817
|
+
dropEmpties
|
|
33818
|
+
);
|
|
33727
33819
|
}
|
|
33728
|
-
|
|
33820
|
+
if (firstGroup) {
|
|
33821
|
+
dropEmpties = isTop && !isSequence;
|
|
33822
|
+
firstGroup = false;
|
|
33823
|
+
}
|
|
33824
|
+
var values;
|
|
33729
33825
|
if (isSequence) {
|
|
33730
|
-
|
|
33826
|
+
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
33731
33827
|
} else {
|
|
33732
|
-
n = parseCommaParts(m.body);
|
|
33733
|
-
if (n.length === 1) {
|
|
33734
|
-
n = expand(n[0], max, false).map(embrace);
|
|
33828
|
+
var n = parseCommaParts(m.body);
|
|
33829
|
+
if (n.length === 1 && n[0] !== void 0) {
|
|
33830
|
+
n = expand(n[0], max, maxLength, false).map(embrace);
|
|
33735
33831
|
if (n.length === 1) {
|
|
33736
|
-
|
|
33737
|
-
|
|
33738
|
-
|
|
33832
|
+
acc = combine(
|
|
33833
|
+
acc,
|
|
33834
|
+
pre + n[0],
|
|
33835
|
+
[""],
|
|
33836
|
+
max,
|
|
33837
|
+
maxLength,
|
|
33838
|
+
dropEmpties && !m.post.length
|
|
33839
|
+
);
|
|
33840
|
+
if (!m.post.length) break;
|
|
33841
|
+
str = m.post;
|
|
33842
|
+
continue;
|
|
33739
33843
|
}
|
|
33740
33844
|
}
|
|
33741
|
-
|
|
33742
|
-
|
|
33743
|
-
|
|
33744
|
-
|
|
33745
|
-
var y = numeric(n[1]);
|
|
33746
|
-
var width = Math.max(n[0].length, n[1].length);
|
|
33747
|
-
var incr = n.length == 3 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
33748
|
-
var test = lte;
|
|
33749
|
-
var reverse = y < x;
|
|
33750
|
-
if (reverse) {
|
|
33751
|
-
incr *= -1;
|
|
33752
|
-
test = gte;
|
|
33753
|
-
}
|
|
33754
|
-
var pad2 = n.some(isPadded);
|
|
33755
|
-
N = [];
|
|
33756
|
-
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
|
33757
|
-
var c2;
|
|
33758
|
-
if (isAlphaSequence) {
|
|
33759
|
-
c2 = String.fromCharCode(i);
|
|
33760
|
-
if (c2 === "\\")
|
|
33761
|
-
c2 = "";
|
|
33762
|
-
} else {
|
|
33763
|
-
c2 = String(i);
|
|
33764
|
-
if (pad2) {
|
|
33765
|
-
var need = width - c2.length;
|
|
33766
|
-
if (need > 0) {
|
|
33767
|
-
var z = new Array(need + 1).join("0");
|
|
33768
|
-
if (i < 0)
|
|
33769
|
-
c2 = "-" + z + c2.slice(1);
|
|
33770
|
-
else
|
|
33771
|
-
c2 = z + c2;
|
|
33772
|
-
}
|
|
33773
|
-
}
|
|
33845
|
+
var dropsEmpties = dropEmpties && !m.post.length && !pre;
|
|
33846
|
+
for (var d = 0; dropsEmpties && d < acc.length; d++) {
|
|
33847
|
+
if (acc[d]) {
|
|
33848
|
+
dropsEmpties = false;
|
|
33774
33849
|
}
|
|
33775
|
-
N.push(c2);
|
|
33776
33850
|
}
|
|
33777
|
-
|
|
33778
|
-
|
|
33779
|
-
for (var j = 0; j < n.length; j++) {
|
|
33780
|
-
|
|
33781
|
-
|
|
33782
|
-
|
|
33783
|
-
|
|
33784
|
-
|
|
33785
|
-
|
|
33786
|
-
|
|
33787
|
-
|
|
33851
|
+
values = [];
|
|
33852
|
+
var valuesLength = 0;
|
|
33853
|
+
outer: for (var j = 0; j < n.length; j++) {
|
|
33854
|
+
var expanded = expand(n[j], max, maxLength, false);
|
|
33855
|
+
for (var k = 0; k < expanded.length; k++) {
|
|
33856
|
+
var v = expanded[k];
|
|
33857
|
+
if (dropsEmpties && !v) continue;
|
|
33858
|
+
if (values.length >= max || valuesLength + v.length > maxLength) {
|
|
33859
|
+
break outer;
|
|
33860
|
+
}
|
|
33861
|
+
values.push(v);
|
|
33862
|
+
valuesLength += v.length;
|
|
33863
|
+
}
|
|
33788
33864
|
}
|
|
33789
33865
|
}
|
|
33866
|
+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
|
33867
|
+
if (!m.post.length) break;
|
|
33868
|
+
str = m.post;
|
|
33790
33869
|
}
|
|
33791
|
-
return
|
|
33870
|
+
return acc;
|
|
33792
33871
|
}
|
|
33793
33872
|
}
|
|
33794
33873
|
});
|
|
@@ -34455,9 +34534,9 @@ var require_readdir_glob = __commonJS({
|
|
|
34455
34534
|
var fs4 = __require("fs");
|
|
34456
34535
|
var { EventEmitter } = __require("events");
|
|
34457
34536
|
var { Minimatch } = require_minimatch();
|
|
34458
|
-
var { resolve:
|
|
34537
|
+
var { resolve: resolve6 } = __require("path");
|
|
34459
34538
|
function readdir(dir2, strict) {
|
|
34460
|
-
return new Promise((
|
|
34539
|
+
return new Promise((resolve7, reject2) => {
|
|
34461
34540
|
fs4.readdir(dir2, { withFileTypes: true }, (err, files) => {
|
|
34462
34541
|
if (err) {
|
|
34463
34542
|
switch (err.code) {
|
|
@@ -34465,7 +34544,7 @@ var require_readdir_glob = __commonJS({
|
|
|
34465
34544
|
if (strict) {
|
|
34466
34545
|
reject2(err);
|
|
34467
34546
|
} else {
|
|
34468
|
-
|
|
34547
|
+
resolve7([]);
|
|
34469
34548
|
}
|
|
34470
34549
|
break;
|
|
34471
34550
|
case "ENOTSUP":
|
|
@@ -34475,7 +34554,7 @@ var require_readdir_glob = __commonJS({
|
|
|
34475
34554
|
case "ENAMETOOLONG":
|
|
34476
34555
|
// Filename too long
|
|
34477
34556
|
case "UNKNOWN":
|
|
34478
|
-
|
|
34557
|
+
resolve7([]);
|
|
34479
34558
|
break;
|
|
34480
34559
|
case "ELOOP":
|
|
34481
34560
|
// Too many levels of symbolic links
|
|
@@ -34484,30 +34563,30 @@ var require_readdir_glob = __commonJS({
|
|
|
34484
34563
|
break;
|
|
34485
34564
|
}
|
|
34486
34565
|
} else {
|
|
34487
|
-
|
|
34566
|
+
resolve7(files);
|
|
34488
34567
|
}
|
|
34489
34568
|
});
|
|
34490
34569
|
});
|
|
34491
34570
|
}
|
|
34492
34571
|
function stat(file, followSymlinks) {
|
|
34493
|
-
return new Promise((
|
|
34572
|
+
return new Promise((resolve7, reject2) => {
|
|
34494
34573
|
const statFunc = followSymlinks ? fs4.stat : fs4.lstat;
|
|
34495
34574
|
statFunc(file, (err, stats) => {
|
|
34496
34575
|
if (err) {
|
|
34497
34576
|
switch (err.code) {
|
|
34498
34577
|
case "ENOENT":
|
|
34499
34578
|
if (followSymlinks) {
|
|
34500
|
-
|
|
34579
|
+
resolve7(stat(file, false));
|
|
34501
34580
|
} else {
|
|
34502
|
-
|
|
34581
|
+
resolve7(null);
|
|
34503
34582
|
}
|
|
34504
34583
|
break;
|
|
34505
34584
|
default:
|
|
34506
|
-
|
|
34585
|
+
resolve7(null);
|
|
34507
34586
|
break;
|
|
34508
34587
|
}
|
|
34509
34588
|
} else {
|
|
34510
|
-
|
|
34589
|
+
resolve7(stats);
|
|
34511
34590
|
}
|
|
34512
34591
|
});
|
|
34513
34592
|
});
|
|
@@ -34597,7 +34676,7 @@ var require_readdir_glob = __commonJS({
|
|
|
34597
34676
|
(skip) => new Minimatch(skip, { dot: true })
|
|
34598
34677
|
);
|
|
34599
34678
|
}
|
|
34600
|
-
this.iterator = explore(
|
|
34679
|
+
this.iterator = explore(resolve6(cwd || "."), this.options.follow, this.options.stat, this._shouldSkipDirectory.bind(this));
|
|
34601
34680
|
this.paused = false;
|
|
34602
34681
|
this.inactive = false;
|
|
34603
34682
|
this.aborted = false;
|
|
@@ -34851,10 +34930,10 @@ function awaitify(asyncFn, arity) {
|
|
|
34851
34930
|
if (typeof args[arity - 1] === "function") {
|
|
34852
34931
|
return asyncFn.apply(this, args);
|
|
34853
34932
|
}
|
|
34854
|
-
return new Promise((
|
|
34933
|
+
return new Promise((resolve6, reject2) => {
|
|
34855
34934
|
args[arity - 1] = (err, ...cbArgs) => {
|
|
34856
34935
|
if (err) return reject2(err);
|
|
34857
|
-
|
|
34936
|
+
resolve6(cbArgs.length > 1 ? cbArgs : cbArgs[0]);
|
|
34858
34937
|
};
|
|
34859
34938
|
asyncFn.apply(this, args);
|
|
34860
34939
|
});
|
|
@@ -35036,13 +35115,13 @@ function mapSeries(coll, iteratee, callback) {
|
|
|
35036
35115
|
return _asyncMap(eachOfSeries$1, coll, iteratee, callback);
|
|
35037
35116
|
}
|
|
35038
35117
|
function promiseCallback() {
|
|
35039
|
-
let
|
|
35118
|
+
let resolve6, reject2;
|
|
35040
35119
|
function callback(err, ...args) {
|
|
35041
35120
|
if (err) return reject2(err);
|
|
35042
|
-
|
|
35121
|
+
resolve6(args.length > 1 ? args : args[0]);
|
|
35043
35122
|
}
|
|
35044
35123
|
callback[PROMISE_SYMBOL] = new Promise((res, rej) => {
|
|
35045
|
-
|
|
35124
|
+
resolve6 = res, reject2 = rej;
|
|
35046
35125
|
});
|
|
35047
35126
|
return callback;
|
|
35048
35127
|
}
|
|
@@ -35315,8 +35394,8 @@ function queue$1(worker, concurrency, payload) {
|
|
|
35315
35394
|
});
|
|
35316
35395
|
}
|
|
35317
35396
|
if (rejectOnError || !callback) {
|
|
35318
|
-
return new Promise((
|
|
35319
|
-
res =
|
|
35397
|
+
return new Promise((resolve6, reject2) => {
|
|
35398
|
+
res = resolve6;
|
|
35320
35399
|
rej = reject2;
|
|
35321
35400
|
});
|
|
35322
35401
|
}
|
|
@@ -35355,10 +35434,10 @@ function queue$1(worker, concurrency, payload) {
|
|
|
35355
35434
|
}
|
|
35356
35435
|
const eventMethod = (name) => (handler) => {
|
|
35357
35436
|
if (!handler) {
|
|
35358
|
-
return new Promise((
|
|
35437
|
+
return new Promise((resolve6, reject2) => {
|
|
35359
35438
|
once2(name, (err, data) => {
|
|
35360
35439
|
if (err) return reject2(err);
|
|
35361
|
-
|
|
35440
|
+
resolve6(data);
|
|
35362
35441
|
});
|
|
35363
35442
|
});
|
|
35364
35443
|
}
|
|
@@ -41797,6 +41876,8 @@ var require_brace_expansion2 = __commonJS({
|
|
|
41797
41876
|
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
41798
41877
|
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
41799
41878
|
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
41879
|
+
var EXPANSION_MAX = 1e5;
|
|
41880
|
+
var EXPANSION_MAX_LENGTH = 4e6;
|
|
41800
41881
|
function numeric(str) {
|
|
41801
41882
|
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
41802
41883
|
}
|
|
@@ -41830,11 +41911,12 @@ var require_brace_expansion2 = __commonJS({
|
|
|
41830
41911
|
if (!str)
|
|
41831
41912
|
return [];
|
|
41832
41913
|
options = options || {};
|
|
41833
|
-
var max = options.max == null ?
|
|
41914
|
+
var max = options.max == null ? EXPANSION_MAX : options.max;
|
|
41915
|
+
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
|
41834
41916
|
if (str.substr(0, 2) === "{}") {
|
|
41835
41917
|
str = "\\{\\}" + str.substr(2);
|
|
41836
41918
|
}
|
|
41837
|
-
return expand(escapeBraces(str), max, true).map(unescapeBraces);
|
|
41919
|
+
return expand(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
41838
41920
|
}
|
|
41839
41921
|
function embrace(str) {
|
|
41840
41922
|
return "{" + str + "}";
|
|
@@ -41848,86 +41930,175 @@ var require_brace_expansion2 = __commonJS({
|
|
|
41848
41930
|
function gte(i, y) {
|
|
41849
41931
|
return i >= y;
|
|
41850
41932
|
}
|
|
41851
|
-
function
|
|
41852
|
-
var
|
|
41853
|
-
var
|
|
41854
|
-
|
|
41855
|
-
|
|
41856
|
-
|
|
41857
|
-
|
|
41858
|
-
|
|
41859
|
-
|
|
41860
|
-
|
|
41861
|
-
|
|
41862
|
-
|
|
41863
|
-
}
|
|
41864
|
-
return [str];
|
|
41865
|
-
}
|
|
41866
|
-
var n;
|
|
41867
|
-
if (isSequence) {
|
|
41868
|
-
n = m.body.split(/\.\./);
|
|
41869
|
-
} else {
|
|
41870
|
-
n = parseCommaParts(m.body);
|
|
41871
|
-
if (n.length === 1) {
|
|
41872
|
-
n = expand(n[0], max, false).map(embrace);
|
|
41873
|
-
if (n.length === 1) {
|
|
41874
|
-
var post = m.post.length ? expand(m.post, max, false) : [""];
|
|
41875
|
-
return post.map(function(p) {
|
|
41876
|
-
return m.pre + n[0] + p;
|
|
41877
|
-
});
|
|
41878
|
-
}
|
|
41933
|
+
function combine(acc, base, pre, values, max, maxLength, dropEmpties, outBase) {
|
|
41934
|
+
var out = [];
|
|
41935
|
+
var length = 0;
|
|
41936
|
+
for (var a = 0; a < acc.length; a++) {
|
|
41937
|
+
for (var v = 0; v < values.length; v++) {
|
|
41938
|
+
if (out.length >= max) return out;
|
|
41939
|
+
var expansion = acc[a] + pre + values[v];
|
|
41940
|
+
if (dropEmpties && expansion.length === base[a]) continue;
|
|
41941
|
+
if (length + expansion.length > maxLength) return out;
|
|
41942
|
+
out.push(expansion);
|
|
41943
|
+
outBase.push(base[a]);
|
|
41944
|
+
length += expansion.length;
|
|
41879
41945
|
}
|
|
41880
41946
|
}
|
|
41881
|
-
|
|
41882
|
-
|
|
41883
|
-
|
|
41884
|
-
|
|
41885
|
-
|
|
41886
|
-
|
|
41887
|
-
|
|
41888
|
-
|
|
41889
|
-
|
|
41890
|
-
|
|
41891
|
-
|
|
41892
|
-
|
|
41893
|
-
|
|
41894
|
-
|
|
41895
|
-
|
|
41896
|
-
|
|
41897
|
-
|
|
41898
|
-
|
|
41899
|
-
|
|
41900
|
-
|
|
41901
|
-
|
|
41902
|
-
|
|
41903
|
-
|
|
41904
|
-
|
|
41905
|
-
|
|
41906
|
-
|
|
41907
|
-
|
|
41908
|
-
|
|
41909
|
-
|
|
41910
|
-
|
|
41911
|
-
|
|
41912
|
-
|
|
41947
|
+
return out;
|
|
41948
|
+
}
|
|
41949
|
+
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
41950
|
+
var n = body.split(/\.\./);
|
|
41951
|
+
var N = [];
|
|
41952
|
+
if (n[0] === void 0 || n[1] === void 0) {
|
|
41953
|
+
return N;
|
|
41954
|
+
}
|
|
41955
|
+
var x = numeric(n[0]);
|
|
41956
|
+
var y = numeric(n[1]);
|
|
41957
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
41958
|
+
var incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
41959
|
+
var test = lte;
|
|
41960
|
+
var reverse = y < x;
|
|
41961
|
+
if (reverse) {
|
|
41962
|
+
incr *= -1;
|
|
41963
|
+
test = gte;
|
|
41964
|
+
}
|
|
41965
|
+
var pad2 = n.some(isPadded);
|
|
41966
|
+
var length = 0;
|
|
41967
|
+
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
|
41968
|
+
var c2;
|
|
41969
|
+
if (isAlphaSequence) {
|
|
41970
|
+
c2 = String.fromCharCode(i);
|
|
41971
|
+
if (c2 === "\\") {
|
|
41972
|
+
c2 = "";
|
|
41973
|
+
}
|
|
41974
|
+
} else {
|
|
41975
|
+
c2 = String(i);
|
|
41976
|
+
if (pad2) {
|
|
41977
|
+
var need = width - c2.length;
|
|
41978
|
+
if (need > 0) {
|
|
41979
|
+
var z = new Array(need + 1).join("0");
|
|
41980
|
+
if (i < 0) {
|
|
41981
|
+
c2 = "-" + z + c2.slice(1);
|
|
41982
|
+
} else {
|
|
41983
|
+
c2 = z + c2;
|
|
41913
41984
|
}
|
|
41914
41985
|
}
|
|
41915
41986
|
}
|
|
41916
|
-
N.push(c2);
|
|
41917
41987
|
}
|
|
41918
|
-
|
|
41919
|
-
N
|
|
41920
|
-
|
|
41921
|
-
});
|
|
41988
|
+
if (length + c2.length > maxLength) break;
|
|
41989
|
+
N.push(c2);
|
|
41990
|
+
length += c2.length;
|
|
41922
41991
|
}
|
|
41923
|
-
|
|
41924
|
-
|
|
41925
|
-
|
|
41926
|
-
|
|
41927
|
-
|
|
41992
|
+
return N;
|
|
41993
|
+
}
|
|
41994
|
+
function expand(str, max, maxLength, isTop) {
|
|
41995
|
+
var acc = [""];
|
|
41996
|
+
var accBase = [0];
|
|
41997
|
+
var dropEmpties = false;
|
|
41998
|
+
var firstGroup = true;
|
|
41999
|
+
var nextBase;
|
|
42000
|
+
for (; ; ) {
|
|
42001
|
+
var m = balanced("{", "}", str);
|
|
42002
|
+
if (!m) {
|
|
42003
|
+
return combine(acc, accBase, str, [""], max, maxLength, dropEmpties, []);
|
|
42004
|
+
}
|
|
42005
|
+
var pre = m.pre;
|
|
42006
|
+
if (/\$$/.test(pre)) {
|
|
42007
|
+
return combine(acc, accBase, str, [""], max, maxLength, dropEmpties, []);
|
|
42008
|
+
}
|
|
42009
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
42010
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
42011
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
42012
|
+
var isOptions = m.body.indexOf(",") >= 0;
|
|
42013
|
+
if (!isSequence && !isOptions) {
|
|
42014
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
42015
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
42016
|
+
isTop = true;
|
|
42017
|
+
firstGroup = true;
|
|
42018
|
+
dropEmpties = false;
|
|
42019
|
+
accBase = [];
|
|
42020
|
+
for (var b = 0; b < acc.length; b++) {
|
|
42021
|
+
accBase.push(acc[b].length);
|
|
42022
|
+
}
|
|
42023
|
+
continue;
|
|
42024
|
+
}
|
|
42025
|
+
return combine(
|
|
42026
|
+
acc,
|
|
42027
|
+
accBase,
|
|
42028
|
+
pre + "{" + m.body + "}" + m.post,
|
|
42029
|
+
[""],
|
|
42030
|
+
max,
|
|
42031
|
+
maxLength,
|
|
42032
|
+
dropEmpties,
|
|
42033
|
+
[]
|
|
42034
|
+
);
|
|
42035
|
+
}
|
|
42036
|
+
if (firstGroup) {
|
|
42037
|
+
dropEmpties = isTop && !isSequence;
|
|
42038
|
+
firstGroup = false;
|
|
41928
42039
|
}
|
|
42040
|
+
var values;
|
|
42041
|
+
if (isSequence) {
|
|
42042
|
+
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
42043
|
+
} else {
|
|
42044
|
+
var n = parseCommaParts(m.body);
|
|
42045
|
+
if (n.length === 1 && n[0] !== void 0) {
|
|
42046
|
+
n = expand(n[0], max, maxLength, false).map(embrace);
|
|
42047
|
+
if (n.length === 1) {
|
|
42048
|
+
nextBase = [];
|
|
42049
|
+
acc = combine(
|
|
42050
|
+
acc,
|
|
42051
|
+
accBase,
|
|
42052
|
+
pre + n[0],
|
|
42053
|
+
[""],
|
|
42054
|
+
max,
|
|
42055
|
+
maxLength,
|
|
42056
|
+
dropEmpties && !m.post.length,
|
|
42057
|
+
nextBase
|
|
42058
|
+
);
|
|
42059
|
+
accBase = nextBase;
|
|
42060
|
+
if (!m.post.length) break;
|
|
42061
|
+
str = m.post;
|
|
42062
|
+
continue;
|
|
42063
|
+
}
|
|
42064
|
+
}
|
|
42065
|
+
var dropsEmpties = dropEmpties && !m.post.length && !pre;
|
|
42066
|
+
for (var d = 0; dropsEmpties && d < acc.length; d++) {
|
|
42067
|
+
if (acc[d].length !== accBase[d]) {
|
|
42068
|
+
dropsEmpties = false;
|
|
42069
|
+
}
|
|
42070
|
+
}
|
|
42071
|
+
values = [];
|
|
42072
|
+
var valuesLength = 0;
|
|
42073
|
+
outer: for (var j = 0; j < n.length; j++) {
|
|
42074
|
+
var expanded = expand(n[j], max, maxLength, false);
|
|
42075
|
+
for (var k = 0; k < expanded.length; k++) {
|
|
42076
|
+
var v = expanded[k];
|
|
42077
|
+
if (dropsEmpties && !v) continue;
|
|
42078
|
+
if (values.length >= max || valuesLength + v.length > maxLength) {
|
|
42079
|
+
break outer;
|
|
42080
|
+
}
|
|
42081
|
+
values.push(v);
|
|
42082
|
+
valuesLength += v.length;
|
|
42083
|
+
}
|
|
42084
|
+
}
|
|
42085
|
+
}
|
|
42086
|
+
nextBase = [];
|
|
42087
|
+
acc = combine(
|
|
42088
|
+
acc,
|
|
42089
|
+
accBase,
|
|
42090
|
+
pre,
|
|
42091
|
+
values,
|
|
42092
|
+
max,
|
|
42093
|
+
maxLength,
|
|
42094
|
+
dropEmpties && !m.post.length,
|
|
42095
|
+
nextBase
|
|
42096
|
+
);
|
|
42097
|
+
accBase = nextBase;
|
|
42098
|
+
if (!m.post.length) break;
|
|
42099
|
+
str = m.post;
|
|
41929
42100
|
}
|
|
41930
|
-
return
|
|
42101
|
+
return acc;
|
|
41931
42102
|
}
|
|
41932
42103
|
}
|
|
41933
42104
|
});
|
|
@@ -44622,11 +44793,11 @@ var require_core = __commonJS({
|
|
|
44622
44793
|
this._finalize();
|
|
44623
44794
|
}
|
|
44624
44795
|
var self2 = this;
|
|
44625
|
-
return new Promise(function(
|
|
44796
|
+
return new Promise(function(resolve6, reject2) {
|
|
44626
44797
|
var errored;
|
|
44627
44798
|
self2._module.on("end", function() {
|
|
44628
44799
|
if (!errored) {
|
|
44629
|
-
|
|
44800
|
+
resolve6();
|
|
44630
44801
|
}
|
|
44631
44802
|
});
|
|
44632
44803
|
self2._module.on("error", function(err) {
|
|
@@ -48397,7 +48568,7 @@ var require_worksheet_writer = __commonJS({
|
|
|
48397
48568
|
// =========================================================================
|
|
48398
48569
|
// Worksheet Protection
|
|
48399
48570
|
protect(password, options) {
|
|
48400
|
-
return new Promise((
|
|
48571
|
+
return new Promise((resolve6) => {
|
|
48401
48572
|
this.sheetProtection = {
|
|
48402
48573
|
sheet: true
|
|
48403
48574
|
};
|
|
@@ -48421,7 +48592,7 @@ var require_worksheet_writer = __commonJS({
|
|
|
48421
48592
|
delete this.sheetProtection.spinCount;
|
|
48422
48593
|
}
|
|
48423
48594
|
}
|
|
48424
|
-
|
|
48595
|
+
resolve6();
|
|
48425
48596
|
});
|
|
48426
48597
|
}
|
|
48427
48598
|
unprotect() {
|
|
@@ -48640,9 +48811,9 @@ var require_workbook_writer = __commonJS({
|
|
|
48640
48811
|
_commitWorksheets() {
|
|
48641
48812
|
const commitWorksheet = function(worksheet) {
|
|
48642
48813
|
if (!worksheet.committed) {
|
|
48643
|
-
return new Promise((
|
|
48814
|
+
return new Promise((resolve6) => {
|
|
48644
48815
|
worksheet.stream.on("zipped", () => {
|
|
48645
|
-
|
|
48816
|
+
resolve6();
|
|
48646
48817
|
});
|
|
48647
48818
|
worksheet.commit();
|
|
48648
48819
|
});
|
|
@@ -48730,19 +48901,19 @@ var require_workbook_writer = __commonJS({
|
|
|
48730
48901
|
return void 0;
|
|
48731
48902
|
}
|
|
48732
48903
|
addStyles() {
|
|
48733
|
-
return new Promise((
|
|
48904
|
+
return new Promise((resolve6) => {
|
|
48734
48905
|
this.zip.append(this.styles.xml, { name: "xl/styles.xml" });
|
|
48735
|
-
|
|
48906
|
+
resolve6();
|
|
48736
48907
|
});
|
|
48737
48908
|
}
|
|
48738
48909
|
addThemes() {
|
|
48739
|
-
return new Promise((
|
|
48910
|
+
return new Promise((resolve6) => {
|
|
48740
48911
|
this.zip.append(theme1Xml, { name: "xl/theme/theme1.xml" });
|
|
48741
|
-
|
|
48912
|
+
resolve6();
|
|
48742
48913
|
});
|
|
48743
48914
|
}
|
|
48744
48915
|
addOfficeRels() {
|
|
48745
|
-
return new Promise((
|
|
48916
|
+
return new Promise((resolve6) => {
|
|
48746
48917
|
const xform = new RelationshipsXform();
|
|
48747
48918
|
const xml = xform.toXml([
|
|
48748
48919
|
{ Id: "rId1", Type: RelType.OfficeDocument, Target: "xl/workbook.xml" },
|
|
@@ -48750,11 +48921,11 @@ var require_workbook_writer = __commonJS({
|
|
|
48750
48921
|
{ Id: "rId3", Type: RelType.ExtenderProperties, Target: "docProps/app.xml" }
|
|
48751
48922
|
]);
|
|
48752
48923
|
this.zip.append(xml, { name: "/_rels/.rels" });
|
|
48753
|
-
|
|
48924
|
+
resolve6();
|
|
48754
48925
|
});
|
|
48755
48926
|
}
|
|
48756
48927
|
addContentTypes() {
|
|
48757
|
-
return new Promise((
|
|
48928
|
+
return new Promise((resolve6) => {
|
|
48758
48929
|
const model = {
|
|
48759
48930
|
worksheets: this._worksheets.filter(Boolean),
|
|
48760
48931
|
sharedStrings: this.sharedStrings,
|
|
@@ -48764,7 +48935,7 @@ var require_workbook_writer = __commonJS({
|
|
|
48764
48935
|
const xform = new ContentTypesXform();
|
|
48765
48936
|
const xml = xform.toXml(model);
|
|
48766
48937
|
this.zip.append(xml, { name: "[Content_Types].xml" });
|
|
48767
|
-
|
|
48938
|
+
resolve6();
|
|
48768
48939
|
});
|
|
48769
48940
|
}
|
|
48770
48941
|
addMedia() {
|
|
@@ -48789,31 +48960,31 @@ var require_workbook_writer = __commonJS({
|
|
|
48789
48960
|
);
|
|
48790
48961
|
}
|
|
48791
48962
|
addApp() {
|
|
48792
|
-
return new Promise((
|
|
48963
|
+
return new Promise((resolve6) => {
|
|
48793
48964
|
const model = {
|
|
48794
48965
|
worksheets: this._worksheets.filter(Boolean)
|
|
48795
48966
|
};
|
|
48796
48967
|
const xform = new AppXform();
|
|
48797
48968
|
const xml = xform.toXml(model);
|
|
48798
48969
|
this.zip.append(xml, { name: "docProps/app.xml" });
|
|
48799
|
-
|
|
48970
|
+
resolve6();
|
|
48800
48971
|
});
|
|
48801
48972
|
}
|
|
48802
48973
|
addCore() {
|
|
48803
|
-
return new Promise((
|
|
48974
|
+
return new Promise((resolve6) => {
|
|
48804
48975
|
const coreXform = new CoreXform();
|
|
48805
48976
|
const xml = coreXform.toXml(this);
|
|
48806
48977
|
this.zip.append(xml, { name: "docProps/core.xml" });
|
|
48807
|
-
|
|
48978
|
+
resolve6();
|
|
48808
48979
|
});
|
|
48809
48980
|
}
|
|
48810
48981
|
addSharedStrings() {
|
|
48811
48982
|
if (this.sharedStrings.count) {
|
|
48812
|
-
return new Promise((
|
|
48983
|
+
return new Promise((resolve6) => {
|
|
48813
48984
|
const sharedStringsXform = new SharedStringsXform();
|
|
48814
48985
|
const xml = sharedStringsXform.toXml(this.sharedStrings);
|
|
48815
48986
|
this.zip.append(xml, { name: "/xl/sharedStrings.xml" });
|
|
48816
|
-
|
|
48987
|
+
resolve6();
|
|
48817
48988
|
});
|
|
48818
48989
|
}
|
|
48819
48990
|
return Promise.resolve();
|
|
@@ -48841,11 +49012,11 @@ var require_workbook_writer = __commonJS({
|
|
|
48841
49012
|
});
|
|
48842
49013
|
}
|
|
48843
49014
|
});
|
|
48844
|
-
return new Promise((
|
|
49015
|
+
return new Promise((resolve6) => {
|
|
48845
49016
|
const xform = new RelationshipsXform();
|
|
48846
49017
|
const xml = xform.toXml(relationships);
|
|
48847
49018
|
this.zip.append(xml, { name: "/xl/_rels/workbook.xml.rels" });
|
|
48848
|
-
|
|
49019
|
+
resolve6();
|
|
48849
49020
|
});
|
|
48850
49021
|
}
|
|
48851
49022
|
addWorkbook() {
|
|
@@ -48857,18 +49028,18 @@ var require_workbook_writer = __commonJS({
|
|
|
48857
49028
|
properties: {},
|
|
48858
49029
|
calcProperties: {}
|
|
48859
49030
|
};
|
|
48860
|
-
return new Promise((
|
|
49031
|
+
return new Promise((resolve6) => {
|
|
48861
49032
|
const xform = new WorkbookXform();
|
|
48862
49033
|
xform.prepare(model);
|
|
48863
49034
|
zip.append(xform.toXml(model), { name: "/xl/workbook.xml" });
|
|
48864
|
-
|
|
49035
|
+
resolve6();
|
|
48865
49036
|
});
|
|
48866
49037
|
}
|
|
48867
49038
|
_finalize() {
|
|
48868
|
-
return new Promise((
|
|
49039
|
+
return new Promise((resolve6, reject2) => {
|
|
48869
49040
|
this.stream.on("error", reject2);
|
|
48870
49041
|
this.stream.on("finish", () => {
|
|
48871
|
-
|
|
49042
|
+
resolve6(this);
|
|
48872
49043
|
});
|
|
48873
49044
|
this.zip.on("error", reject2);
|
|
48874
49045
|
this.zip.finalize();
|
|
@@ -50802,13 +50973,13 @@ var require_thenables = __commonJS({
|
|
|
50802
50973
|
promise._captureStackTrace();
|
|
50803
50974
|
if (context) context._popContext();
|
|
50804
50975
|
var synchronous = true;
|
|
50805
|
-
var result = util2.tryCatch(then).call(x,
|
|
50976
|
+
var result = util2.tryCatch(then).call(x, resolve6, reject2);
|
|
50806
50977
|
synchronous = false;
|
|
50807
50978
|
if (promise && result === errorObj2) {
|
|
50808
50979
|
promise._rejectCallback(result.e, true, true);
|
|
50809
50980
|
promise = null;
|
|
50810
50981
|
}
|
|
50811
|
-
function
|
|
50982
|
+
function resolve6(value) {
|
|
50812
50983
|
if (!promise) return;
|
|
50813
50984
|
promise._resolveCallback(value);
|
|
50814
50985
|
promise = null;
|
|
@@ -51343,9 +51514,9 @@ var require_debuggability = __commonJS({
|
|
|
51343
51514
|
return false;
|
|
51344
51515
|
}
|
|
51345
51516
|
Promise2.prototype._fireEvent = defaultFireEvent;
|
|
51346
|
-
Promise2.prototype._execute = function(executor,
|
|
51517
|
+
Promise2.prototype._execute = function(executor, resolve6, reject2) {
|
|
51347
51518
|
try {
|
|
51348
|
-
executor(
|
|
51519
|
+
executor(resolve6, reject2);
|
|
51349
51520
|
} catch (e) {
|
|
51350
51521
|
return e;
|
|
51351
51522
|
}
|
|
@@ -51368,10 +51539,10 @@ var require_debuggability = __commonJS({
|
|
|
51368
51539
|
;
|
|
51369
51540
|
;
|
|
51370
51541
|
};
|
|
51371
|
-
function cancellationExecute(executor,
|
|
51542
|
+
function cancellationExecute(executor, resolve6, reject2) {
|
|
51372
51543
|
var promise = this;
|
|
51373
51544
|
try {
|
|
51374
|
-
executor(
|
|
51545
|
+
executor(resolve6, reject2, function(onCancel) {
|
|
51375
51546
|
if (typeof onCancel !== "function") {
|
|
51376
51547
|
throw new TypeError("onCancel must be a function, got: " + util2.toString(onCancel));
|
|
51377
51548
|
}
|
|
@@ -56625,7 +56796,7 @@ var require_PullStream = __commonJS({
|
|
|
56625
56796
|
};
|
|
56626
56797
|
var rejectHandler;
|
|
56627
56798
|
var pullStreamRejectHandler;
|
|
56628
|
-
return new Promise2(function(
|
|
56799
|
+
return new Promise2(function(resolve6, reject2) {
|
|
56629
56800
|
rejectHandler = reject2;
|
|
56630
56801
|
pullStreamRejectHandler = function(e) {
|
|
56631
56802
|
self2.__emittedError = e;
|
|
@@ -56635,7 +56806,7 @@ var require_PullStream = __commonJS({
|
|
|
56635
56806
|
return reject2(new Error("FILE_ENDED"));
|
|
56636
56807
|
self2.once("error", pullStreamRejectHandler);
|
|
56637
56808
|
self2.stream(eof, includeEof).on("error", reject2).pipe(concatStream).on("finish", function() {
|
|
56638
|
-
|
|
56809
|
+
resolve6(buffer2);
|
|
56639
56810
|
}).on("error", reject2);
|
|
56640
56811
|
}).finally(function() {
|
|
56641
56812
|
self2.removeListener("error", rejectHandler);
|
|
@@ -56680,10 +56851,10 @@ var require_BufferStream = __commonJS({
|
|
|
56680
56851
|
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
|
|
56681
56852
|
Stream = require_readable5();
|
|
56682
56853
|
module2.exports = function(entry) {
|
|
56683
|
-
return new Promise2(function(
|
|
56854
|
+
return new Promise2(function(resolve6, reject2) {
|
|
56684
56855
|
var chunks = [];
|
|
56685
56856
|
var bufferStream = Stream.Transform().on("finish", function() {
|
|
56686
|
-
|
|
56857
|
+
resolve6(Buffer2.concat(chunks));
|
|
56687
56858
|
}).on("error", reject2);
|
|
56688
56859
|
bufferStream._transform = function(d, e, cb) {
|
|
56689
56860
|
chunks.push(d);
|
|
@@ -56825,8 +56996,8 @@ var require_parse = __commonJS({
|
|
|
56825
56996
|
__autodraining = true;
|
|
56826
56997
|
var draining2 = entry.pipe(NoopStream());
|
|
56827
56998
|
draining2.promise = function() {
|
|
56828
|
-
return new Promise2(function(
|
|
56829
|
-
draining2.on("finish",
|
|
56999
|
+
return new Promise2(function(resolve6, reject2) {
|
|
57000
|
+
draining2.on("finish", resolve6);
|
|
56830
57001
|
draining2.on("error", reject2);
|
|
56831
57002
|
});
|
|
56832
57003
|
};
|
|
@@ -56881,11 +57052,11 @@ var require_parse = __commonJS({
|
|
|
56881
57052
|
eof = Buffer2.alloc(4);
|
|
56882
57053
|
eof.writeUInt32LE(134695760, 0);
|
|
56883
57054
|
}
|
|
56884
|
-
return new Promise2(function(
|
|
57055
|
+
return new Promise2(function(resolve6, reject2) {
|
|
56885
57056
|
self2.stream(eof).pipe(inflater).on("error", function(err) {
|
|
56886
57057
|
self2.emit("error", err);
|
|
56887
57058
|
}).pipe(entry).on("finish", function() {
|
|
56888
|
-
return fileSizeKnown ? self2._readRecord().then(
|
|
57059
|
+
return fileSizeKnown ? self2._readRecord().then(resolve6).catch(reject2) : self2._processDataDescriptor(entry).then(resolve6).catch(reject2);
|
|
56889
57060
|
});
|
|
56890
57061
|
});
|
|
56891
57062
|
});
|
|
@@ -56927,8 +57098,8 @@ var require_parse = __commonJS({
|
|
|
56927
57098
|
};
|
|
56928
57099
|
Parse.prototype.promise = function() {
|
|
56929
57100
|
var self2 = this;
|
|
56930
|
-
return new Promise2(function(
|
|
56931
|
-
self2.on("finish",
|
|
57101
|
+
return new Promise2(function(resolve6, reject2) {
|
|
57102
|
+
self2.on("finish", resolve6);
|
|
56932
57103
|
self2.on("error", reject2);
|
|
56933
57104
|
});
|
|
56934
57105
|
};
|
|
@@ -60439,8 +60610,8 @@ var require_extract2 = __commonJS({
|
|
|
60439
60610
|
extract.emit("close");
|
|
60440
60611
|
});
|
|
60441
60612
|
extract.promise = function() {
|
|
60442
|
-
return new Promise2(function(
|
|
60443
|
-
extract.on("close",
|
|
60613
|
+
return new Promise2(function(resolve6, reject2) {
|
|
60614
|
+
extract.on("close", resolve6);
|
|
60444
60615
|
extract.on("error", reject2);
|
|
60445
60616
|
});
|
|
60446
60617
|
};
|
|
@@ -61951,8 +62122,8 @@ var require_directory = __commonJS({
|
|
|
61951
62122
|
return;
|
|
61952
62123
|
}
|
|
61953
62124
|
var writer = opts.getWriter ? opts.getWriter({ path: extractPath }) : Writer({ path: extractPath });
|
|
61954
|
-
return new Promise2(function(
|
|
61955
|
-
entry.stream(opts.password).on("error", reject2).pipe(writer).on("close",
|
|
62125
|
+
return new Promise2(function(resolve6, reject2) {
|
|
62126
|
+
entry.stream(opts.password).on("error", reject2).pipe(writer).on("close", resolve6).on("error", reject2);
|
|
61956
62127
|
});
|
|
61957
62128
|
}, { concurrency: opts.concurrency > 1 ? opts.concurrency : 1 });
|
|
61958
62129
|
});
|
|
@@ -62019,12 +62190,12 @@ var require_Open = __commonJS({
|
|
|
62019
62190
|
return fs4.createReadStream(filename, { start: offset, end: length && offset + length });
|
|
62020
62191
|
},
|
|
62021
62192
|
size: function() {
|
|
62022
|
-
return new Promise2(function(
|
|
62193
|
+
return new Promise2(function(resolve6, reject2) {
|
|
62023
62194
|
fs4.stat(filename, function(err, d) {
|
|
62024
62195
|
if (err)
|
|
62025
62196
|
reject2(err);
|
|
62026
62197
|
else
|
|
62027
|
-
|
|
62198
|
+
resolve6(d.size);
|
|
62028
62199
|
});
|
|
62029
62200
|
});
|
|
62030
62201
|
}
|
|
@@ -62045,14 +62216,14 @@ var require_Open = __commonJS({
|
|
|
62045
62216
|
return request(options2);
|
|
62046
62217
|
},
|
|
62047
62218
|
size: function() {
|
|
62048
|
-
return new Promise2(function(
|
|
62219
|
+
return new Promise2(function(resolve6, reject2) {
|
|
62049
62220
|
var req = request(params);
|
|
62050
62221
|
req.on("response", function(d) {
|
|
62051
62222
|
req.abort();
|
|
62052
62223
|
if (!d.headers["content-length"])
|
|
62053
62224
|
reject2(new Error("Missing content length header"));
|
|
62054
62225
|
else
|
|
62055
|
-
|
|
62226
|
+
resolve6(d.headers["content-length"]);
|
|
62056
62227
|
}).on("error", reject2);
|
|
62057
62228
|
});
|
|
62058
62229
|
}
|
|
@@ -62062,12 +62233,12 @@ var require_Open = __commonJS({
|
|
|
62062
62233
|
s3: function(client, params, options) {
|
|
62063
62234
|
var source2 = {
|
|
62064
62235
|
size: function() {
|
|
62065
|
-
return new Promise2(function(
|
|
62236
|
+
return new Promise2(function(resolve6, reject2) {
|
|
62066
62237
|
client.headObject(params, function(err, d) {
|
|
62067
62238
|
if (err)
|
|
62068
62239
|
reject2(err);
|
|
62069
62240
|
else
|
|
62070
|
-
|
|
62241
|
+
resolve6(d.ContentLength);
|
|
62071
62242
|
});
|
|
62072
62243
|
});
|
|
62073
62244
|
},
|
|
@@ -62485,7 +62656,7 @@ var require_iterate_stream = __commonJS({
|
|
|
62485
62656
|
const contents = [];
|
|
62486
62657
|
stream2.on("data", (data) => contents.push(data));
|
|
62487
62658
|
let resolveStreamEndedPromise;
|
|
62488
|
-
const streamEndedPromise = new Promise((
|
|
62659
|
+
const streamEndedPromise = new Promise((resolve6) => resolveStreamEndedPromise = resolve6);
|
|
62489
62660
|
let ended = false;
|
|
62490
62661
|
stream2.on("end", () => {
|
|
62491
62662
|
ended = true;
|
|
@@ -62510,13 +62681,13 @@ var require_iterate_stream = __commonJS({
|
|
|
62510
62681
|
resolveStreamEndedPromise();
|
|
62511
62682
|
};
|
|
62512
62683
|
function once2(eventEmitter, type) {
|
|
62513
|
-
return new Promise((
|
|
62684
|
+
return new Promise((resolve6) => {
|
|
62514
62685
|
let fired = false;
|
|
62515
62686
|
const handler = () => {
|
|
62516
62687
|
if (!fired) {
|
|
62517
62688
|
fired = true;
|
|
62518
62689
|
eventEmitter.removeListener(type, handler);
|
|
62519
|
-
|
|
62690
|
+
resolve6();
|
|
62520
62691
|
}
|
|
62521
62692
|
};
|
|
62522
62693
|
eventEmitter.addListener(type, handler);
|
|
@@ -63043,7 +63214,7 @@ var require_workbook_reader = __commonJS({
|
|
|
63043
63214
|
if (this.sharedStrings && this.workbookRels) {
|
|
63044
63215
|
yield* this._parseWorksheet(iterateStream(entry), sheetNo);
|
|
63045
63216
|
} else {
|
|
63046
|
-
await new Promise((
|
|
63217
|
+
await new Promise((resolve6, reject2) => {
|
|
63047
63218
|
tmp.file((err, path, fd, tempFileCleanupCallback) => {
|
|
63048
63219
|
if (err) {
|
|
63049
63220
|
return reject2(err);
|
|
@@ -63053,7 +63224,7 @@ var require_workbook_reader = __commonJS({
|
|
|
63053
63224
|
tempStream.on("error", reject2);
|
|
63054
63225
|
entry.pipe(tempStream);
|
|
63055
63226
|
return tempStream.on("finish", () => {
|
|
63056
|
-
return
|
|
63227
|
+
return resolve6();
|
|
63057
63228
|
});
|
|
63058
63229
|
});
|
|
63059
63230
|
});
|
|
@@ -64432,9 +64603,9 @@ var require_clone2 = __commonJS({
|
|
|
64432
64603
|
} else if (_instanceof(parent3, nativeSet)) {
|
|
64433
64604
|
child = new nativeSet();
|
|
64434
64605
|
} else if (_instanceof(parent3, nativePromise)) {
|
|
64435
|
-
child = new nativePromise(function(
|
|
64606
|
+
child = new nativePromise(function(resolve6, reject2) {
|
|
64436
64607
|
parent3.then(function(value) {
|
|
64437
|
-
|
|
64608
|
+
resolve6(_clone(value, depth2 - 1));
|
|
64438
64609
|
}, function(err) {
|
|
64439
64610
|
reject2(_clone(err, depth2 - 1));
|
|
64440
64611
|
});
|
|
@@ -193557,7 +193728,7 @@ function stripCaptions(text, open, close) {
|
|
|
193557
193728
|
}
|
|
193558
193729
|
return removed ? collapseCaptionWs(out) : text;
|
|
193559
193730
|
}
|
|
193560
|
-
function interpolate(text,
|
|
193731
|
+
function interpolate(text, resolve6) {
|
|
193561
193732
|
if (text.indexOf("{") < 0) return text;
|
|
193562
193733
|
let out = "";
|
|
193563
193734
|
for (const tok of tokenise2(text)) {
|
|
@@ -193569,7 +193740,7 @@ function interpolate(text, resolve5) {
|
|
|
193569
193740
|
out += tok.raw;
|
|
193570
193741
|
continue;
|
|
193571
193742
|
}
|
|
193572
|
-
const v =
|
|
193743
|
+
const v = resolve6(tok.ref);
|
|
193573
193744
|
out += v === void 0 ? "" : renderSlotValue(v);
|
|
193574
193745
|
}
|
|
193575
193746
|
return out;
|
|
@@ -194028,7 +194199,7 @@ function bundleOutputPath(loaded) {
|
|
|
194028
194199
|
}
|
|
194029
194200
|
|
|
194030
194201
|
// ../ops/src/playable-runtime.ts
|
|
194031
|
-
var PLAYABLE_RUNTIME_JS = '"use strict";var Patterplay=(()=>{var P=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var ue=(s,e)=>{for(var t in e)P(s,t,{get:e[t],enumerable:!0})},ge=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pe(e))!de.call(s,n)&&n!==t&&P(s,n,{get:()=>e[n],enumerable:!(r=le(e,n))||r.enumerable});return s};var fe=s=>ge(P({},"__esModule",{value:!0}),s);var Ie={};ue(Ie,{Engine:()=>B,Flow:()=>v,buildTagIndex:()=>O,effectiveGameData:()=>oe,gameDataFields:()=>ie,gameDataValue:()=>j});function S(s){switch(s[0]){case"b":return{kind:"bool",value:s[1]};case"n":return{kind:"number",value:s[1]};case"s":return{kind:"string",value:s[1]};case"sv":return{kind:"scopedvar",scope:s[1],name:s[2]};case"u":return{kind:"unary",op:s[1],operand:S(s[2])};case"bin":return{kind:"binary",op:s[1],left:S(s[2]),right:S(s[3])};case"call":{let e=s.slice(2).map(S);return{kind:"call",name:s[1],args:e}}case"fd":return{kind:"flagdelta",sign:s[1],name:s[2]}}}var p=class extends Error{constructor(e){super(e),this.name="EvalError"}};function E(s,e,t){let r=new Map(t.scopes.map(i=>[i.token,i.missing??"false"])),n=i=>{switch(i.kind){case"bool":return i.value;case"number":return i.value;case"string":return i.value;case"scopedvar":{let o=e.scopes[i.scope];if(o===void 0)return!1;let a=typeof o.get=="function"?o.get(i.name):o[i.name];if(a===void 0){if(r.get(i.scope)==="throw")throw new p(`@${i.scope}.${i.name} is not declared on the current ${i.scope}.`);return!1}return a}case"call":{let o=t.functions[i.name];if(!o)throw new p(`unknown function \'${i.name}\'`);return o.eval(i.args,{evaluate:n,ctx:e})}case"flagdelta":throw new p("flagdelta node is only valid as an argument to a flag-delta function");case"unary":{if(i.op==="not"){let a=n(i.operand);if(typeof a!="boolean")throw new p(`\'not\' requires a boolean operand, got ${typeof a}`);return!a}let o=n(i.operand);if(typeof o!="number")throw new p(`unary \'-\' requires a numeric operand, got ${typeof o}`);return-o}case"binary":{if(i.op==="and"){let l=n(i.left);if(typeof l!="boolean")throw new p(`\'and\' requires boolean operands, left is ${typeof l}`);if(!l)return!1;let c=n(i.right);if(typeof c!="boolean")throw new p(`\'and\' requires boolean operands, right is ${typeof c}`);return c}if(i.op==="or"){let l=n(i.left);if(typeof l!="boolean")throw new p(`\'or\' requires boolean operands, left is ${typeof l}`);if(l)return!0;let c=n(i.right);if(typeof c!="boolean")throw new p(`\'or\' requires boolean operands, right is ${typeof c}`);return c}let o=n(i.left),a=n(i.right);switch(i.op){case"==":return U(o,a);case"!=":return!U(o,a);case">":return y(o,a,">"),o>a;case">=":return y(o,a,">="),o>=a;case"<":return y(o,a,"<"),o<a;case"<=":return y(o,a,"<="),o<=a;case"+":if(typeof o=="number"&&typeof a=="number"||typeof o=="string"&&typeof a=="string")return o+a;throw new p(`\'+\' requires two numbers or two strings, got ${typeof o} and ${typeof a}`);case"-":return y(o,a,"-"),o-a;case"*":return y(o,a,"*"),o*a;case"/":if(y(o,a,"/"),a===0)throw new p("division by zero");return o/a}}}};return n(s)}function U(s,e){if(Array.isArray(s)||Array.isArray(e)){if(!Array.isArray(s)||!Array.isArray(e)||s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!==e[t])return!1;return!0}return s===e}function y(s,e,t){if(typeof s!="number"||typeof e!="number")throw new p(`\'${t}\' requires numeric operands, got ${typeof s} and ${typeof e}`)}var he={name:"check_flags",count:s=>Math.max(1,s.args.length-1)},me=[he];function W(s,e,t){let r=t?.countingCalls??me;return C(s,t?.want??!0,e,r)}function C(s,e,t,r){if(s.kind==="binary"&&(s.op==="and"||s.op==="or")){let n=C(s.left,e,t,r),i=C(s.right,e,t,r);return s.op==="and"===e?n>0&&i>0?n+i:0:Math.max(n,i)}if(s.kind==="unary"&&s.op==="not")return C(s.operand,!e,t,r);if(s.kind==="call"){let n=r.find(i=>i.name===s.name);if(n){let i=n.count(s),o=t(s);return e?o?i:0:o?0:1}}return t(s)===e?1:0}var w=class{scopes=new Map;defineOwned(e,t){this.assertFree(e);let r={},n=new Map;for(let i of t){let o=i.name.toLowerCase();n.set(o,i),r[o]=i.default??K(i)}return this.scopes.set(e,{kind:"owned",bag:r,decls:n}),this}reseedOwned(e,t){let r=this.scopes.get(e);if(!r||r.kind!=="owned")throw new Error(`\'@${e}\' is not an owned scope`);for(let n of Object.keys(r.bag))delete r.bag[n];r.decls.clear();for(let n of t){let i=n.name.toLowerCase();r.decls.set(i,n),r.bag[i]=n.default??K(n)}return this}defineForeign(e,t,r=[],n=!0){this.assertFree(e);let i=new Map;for(let o of r)i.set(o.name.toLowerCase(),o);return this.scopes.set(e,{kind:"foreign",resolver:t,decls:i,scopeWritable:n}),this}has(e){return this.scopes.has(e)}get(e,t){let r=this.scopes.get(e);if(!r)return;let n=t.toLowerCase();return r.kind==="owned"?r.bag[n]:r.resolver.get(n)}set(e,t,r){let n=this.scopes.get(e);if(!n)throw new Error(`unknown scope \'@${e}\'`);let i=t.toLowerCase();if(!this.writable(n,i))throw new Error(`\'@${e}.${t}\' is read-only`);n.kind==="owned"?n.bag[i]=r:n.resolver.set(i,r)}writable(e,t){return e.kind==="owned"?e.decls.get(t)?.writable??!0:e.resolver.set?e.decls.get(t)?.writable??e.scopeWritable:!1}toEvalContext(e){let t={};for(let[r,n]of this.scopes)t[r]=n.kind==="owned"?n.bag:n.resolver;return{scopes:t,host:e}}toSchema(){let e=new Map;for(let[t,r]of this.scopes){if(r.decls.size===0)continue;let n=new Map;for(let[i,o]of r.decls)n.set(i,{type:o.type,enumValues:o.values});e.set(t,n)}return{properties:e}}save(){let e={};for(let[t,r]of this.scopes)r.kind==="owned"&&(e[t]={...r.bag});return e}load(e){for(let[t,r]of Object.entries(e)){let n=this.scopes.get(t);n?.kind==="owned"&&Object.assign(n.bag,r)}}assertFree(e){if(this.scopes.has(e))throw new Error(`scope \'@${e}\' is already registered`)}};function K(s){if(s.default!==void 0)return s.default;switch(s.type){case"boolean":return!1;case"number":return 0;case"string":return"";case"enum":return s.values?.[0]??"";case"flags":return[]}}function x(s){return s.ctx.host??{}}var T={defaultScope:"patter",scopes:[{token:"patter"},{token:"scene"}],functions:{random:{minArgs:2,maxArgs:2,returnType:"number",eval(s,e){if(s.length!==2)throw new p("random(a, b) requires exactly 2 arguments");let t=x(e).nextRandom;if(!t)throw new p("random() called without a PRNG in context");let r=e.evaluate(s[0]),n=e.evaluate(s[1]);if(typeof r!="number"||typeof n!="number")throw new p("random(a, b) arguments must be numbers");if(!Number.isInteger(r)||!Number.isInteger(n))throw new p("random(a, b) arguments must be integers");let i=Math.min(r,n),o=Math.max(r,n);return Math.floor(t()*(o-i+1))+i}},check_flags:{minArgs:1,returnType:"boolean",flagDeltaArgs:!0,validate:z("check_flags"),eval(s,e){let t=J(s[0],e,"check_flags");for(let r=1;r<s.length;r++){let n=s[r];if(n.kind!=="flagdelta")throw new p("check_flags() flag args must be +flagName or -flagName");if(n.sign==="+"?!t.includes(n.name):t.includes(n.name))return!1}return!0}},set_flags:{minArgs:1,returnType:"flags",flagDeltaArgs:!0,validate:z("set_flags"),eval(s,e){let t=[...J(s[0],e,"set_flags")];for(let r=1;r<s.length;r++){let n=s[r];if(n.kind!=="flagdelta")throw new p("set_flags() flag args must be +flagName or -flagName");if(n.sign==="+")t.includes(n.name)||t.push(n.name);else{let i=t.indexOf(n.name);i>=0&&t.splice(i,1)}}return t}},visits:{minArgs:1,maxArgs:1,returnType:"number",validate:D("visits"),eval:(s,e)=>x(e).visits?.(I(s,e,"visits"))??0},seen:{minArgs:1,maxArgs:1,returnType:"boolean",validate:D("seen"),eval:(s,e)=>(x(e).visits?.(I(s,e,"seen"))??0)>0},patter_visits:{minArgs:1,maxArgs:1,returnType:"number",validate:D("patter_visits"),eval:(s,e)=>x(e).patterVisits?.(I(s,e,"patter_visits"))??0},patter_seen:{minArgs:1,maxArgs:1,returnType:"boolean",validate:D("patter_seen"),eval:(s,e)=>(x(e).patterVisits?.(I(s,e,"patter_seen"))??0)>0}}};function F(s,e){let t=s.replace(/^@/,"").split(".");return t.length===2&&e(t[0])?{scope:t[0],name:t[1].toLowerCase()}:{scope:"patter",name:t.join(".").toLowerCase()}}function I(s,e,t){let r=e.evaluate(s[0]);if(typeof r!="string")throw new p(`${t}(id) requires a string node id`);return r}function D(s){return(e,t)=>{let r=e[0];r&&r.kind!=="string"&&t.report({path:[...t.path,"args",0],kind:"wrong-arg-type",severity:"error",message:`${s}(id): the argument must be a string id literal (a scene / block / node id)`})}}function J(s,e,t){if(!s)throw new p(`${t}() requires at least one argument (the flags variable)`);let r=e.evaluate(s);if(Array.isArray(r))return r;if(r===!1||r===null||r===void 0)return[];throw new p(`${t}() first argument must be a flags property`)}function z(s){return(e,t)=>{if(e.length===0)return;let r=e[0];if(r.kind!=="scopedvar"){t.report({path:[...t.path,"args",0],kind:"wrong-arg-type",severity:"error",message:`${s}(): first argument must be a flags property reference (@name or @scope.name)`});return}let n=t.schema.properties.get(r.scope)?.get(r.name);if(n&&n.type!=="flags"){let i=r.scope===t.defaultScope?r.name:`${r.scope}.${r.name}`;t.report({path:[...t.path,"args",0],kind:"wrong-arg-type",severity:"error",message:`${s}(): \'@${i}\' is not a flags property (got ${n.type})`});return}for(let i=1;i<e.length;i++){let o=e[i];o.kind!=="flagdelta"?t.report({path:[...t.path,"args",i],kind:"wrong-arg-type",severity:"error",message:`${s}(): argument ${i+1} must be +flagName or -flagName`}):n?.type==="flags"&&n.enumValues&&!n.enumValues.includes(o.name)&&t.report({path:[...t.path,"args",i],kind:"unknown-flag-name",severity:"error",message:`${s}(): unknown flag \'${o.name}\'`,reference:o.name})}}}var Se=/^@[A-Za-z0-9_.]+$/;function*ye(s){let e="",t=0;for(;t<s.length;){let r=s[t];if(r==="{"&&s[t+1]==="{"){e+="{",t+=2;continue}if(r==="}"&&s[t+1]==="}"){e+="}",t+=2;continue}if(r==="{"){let n=s.indexOf("}",t+1);if(n!==-1){let i=s.slice(t,n+1),o=s.slice(t+1,n).trim();if(o.startsWith("@")){e&&(yield{kind:"text",value:e},e=""),yield{kind:"slot",raw:i,inner:o,ref:Se.test(o)?o:void 0},t=n+1;continue}e+=i,t=n+1;continue}}e+=r,t+=1}e&&(yield{kind:"text",value:e})}function be(s){return Array.isArray(s)?s.join(", "):typeof s=="boolean"?s?"true":"false":String(s)}function ve(s){return s===" "||s===" "||s===`\n`||s==="\\r"||s==="\\f"||s==="\\v"}function we(s){let e="",t=!1;for(let r of s){if(ve(r)){t=!0;continue}t&&e.length>0&&(e+=" "),t=!1,e+=r}return e}function X(s,e,t){if(e.length===0||s.indexOf(e)<0)return s;let r="",n=0,i=!1;for(;n<s.length;){if(s.startsWith(e,n)){let o=s.indexOf(t,n+e.length);if(o>=0){n=o+t.length,i=!0;continue}r+=s.slice(n);break}r+=s[n],n+=1}return i?we(r):s}function Z(s,e){if(s.indexOf("{")<0)return s;let t="";for(let r of ye(s)){if(r.kind==="text"){t+=r.value;continue}if(!r.ref){t+=r.raw;continue}let n=e(r.ref);t+=n===void 0?"":be(n)}return t}function k(s,e){for(let t of s){e(t);let r=t.children;r&&k(r,e)}}function xe(s){return s.toLowerCase().replace(/[\'\u2019]/g,"").replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function h(s){let e=s.gameId?.trim();return e||xe(s.name)}function G(s){return`cast:${s}`}var V={open:"[",close:"]"},Q="SFX";function R(s){let e=new Set,t=[];for(let r of s)e.has(r)||(e.add(r),t.push(r));return t}function O(s){let e=new Map,t=(r,n)=>{let i=R([...n,...r.tags??[]]);if(e.set(r.id,i),r.type==="group")for(let o of r.children)t(o,i);else for(let o of r.beats??[])e.set(o.id,R([...i,...o.tags??[]]))};for(let r of Object.values(s.scenes)){let n=R(r.tags??[]);e.set(r.id,n);for(let i of r.blocks){let o=R([...n,...i.tags??[]]);e.set(i.id,o);for(let a of i.children)t(a,o)}}return e}var Y=new WeakMap,B=class s{host;defaultSeed;flowsById=new Map;allStrings;currentLocale;sourceDebug;sceneGameIdToId=new Map;blockGameIdToId=new Map;creationOptions;constructor(e,t={}){this.creationOptions=t;let r=t.locale??e.locales.default,n=e.strings;this.allStrings=n,this.currentLocale=r;let i=n[r]??{},o=n[e.locales.default]??{},a=e.localisation,l=a?.mode==="ids"&&!a.sourceDebug;this.sourceDebug=a?.mode==="ids"&&!!a.sourceDebug,this.sourceDebug&&typeof console<"u"&&console.warn("[Patterplay] source-only DEBUG build: strings are the source language for debugging, not a shippable localised build.");let c=new Map;for(let d of e.cast??[])d.displayName&&c.set(d.name,d.displayName);this.defaultSeed=(t.seed??2654435769)>>>0;let u=new Map,g=new Map,L=new Map;for(let[d,m]of Object.entries(e.scenes)){this.sceneGameIdToId.set(h(m),d);let b=new Map;for(let f of m.blocks)g.set(f.id,{sceneId:d}),L.set(f.id,f),b.set(h(f),f.id),k(f.children,q=>u.set(q.id,q));this.blockGameIdToId.set(d,b)}let $=e.properties??[],N=$.filter(d=>d.shared??!0).map(ee),ae=$.filter(d=>!(d.shared??!0)).map(ee),ce=new Set(N.map(d=>d.name.toLowerCase())),A=new w().defineOwned("patter",N),_=new Set;if(t.world){let d=e.scopeRegistry?.scopes.find(b=>b.token==="world"),m=(d?.declarations??[]).map(te);A.defineForeign("world",t.world,m,d?.writable??!0),_.add("world")}for(let d of e.scopeRegistry?.scopes??[]){if(_.has(d.token))continue;let m=(d.declarations??[]).map(te);A.defineForeign(d.token,Ce(d.declarations??[]),m,d.writable??!0)}let H=new Map;for(let[d,m]of Object.entries(e.scenes)){let b=new Set((m.sceneProps??[]).filter(f=>f.shared??!1).map(f=>f.name.toLowerCase()));H.set(d,b)}this.host={bundle:e,emitIds:l,strings:i,defaultStrings:o,castDisplay:c,nodeIndex:u,blockIndex:g,blockById:L,sceneGameIdToId:this.sceneGameIdToId,blockGameIdToId:this.blockGameIdToId,tagIndex:O(e),shared:A,patterSharedDecls:N,patterLocalDecls:ae,patterSharedNames:ce,sceneSharedNames:H,sharedVisits:new Map,sharedSelectors:new Map,stageBags:new Map,customRng:t.rng,onDryChoice:t.onDryChoice,replayPromptOnChoose:t.replayPromptOnChoose??!1,captionsOn:t.closedCaptions??!0,captionOpen:(e.closedCaptions??V).open,captionClose:(e.closedCaptions??V).close,captionCharacter:e.closedCaptions?.character||Q,refSplitCache:new Map}}get locale(){return this.currentLocale}get isSourceDebug(){return this.sourceDebug}setLocale(e){this.currentLocale=e,this.host.strings=this.allStrings[e]??{}}replaceStrings(e){this.allStrings=e.strings,this.host.strings=this.allStrings[this.currentLocale]??{},this.host.defaultStrings=this.allStrings[this.host.bundle.locales.default]??{}}hotSwap(e){let t=this.saveGame(),r=i=>(i.setLocale(this.currentLocale),i.setClosedCaptions(this.host.captionsOn),i),n=new s(e,this.creationOptions);try{return n.loadGame(t),r(n)}catch{let i=new s(e,this.creationOptions);for(let[o,a]of Object.entries(t.flows)){let l=a.cursor.currentSceneId;try{i.openFlow(o,l!==null?{scene:l}:{})}catch{}}return r(i)}}get closedCaptions(){return this.host.captionsOn}setClosedCaptions(e){this.host.captionsOn=e}openFlow(e,t={}){let r=this.resolveSceneRef(t.scene),n=this.resolveBlockRef(r,t.block);this.flowsById.get(e)?.close();let i=new v(e,this.host,t.seed??this.defaultSeed);return this.flowsById.set(e,i),i.start(r,n),i}runFlow(e,t,r){let n=this.flowsById.get(e);if(!n)return this.openFlow(e,{scene:t,block:r}).advanceToStop().played;if(!n.goto(t,r))throw new Error(`runFlow: address not found: ${t}${r===void 0?"":` / ${r}`}`);return n.advanceToStop().played}resolveSceneRef(e){if(e!=null)return this.host.bundle.scenes[e]?e:this.sceneGameIdToId.get(e)??e}resolveBlockRef(e,t){if(t!=null){if(this.host.blockById.has(t))return t;if(e!=null){let r=this.blockGameIdToId.get(e)?.get(t);if(r)return r}return t}}sceneAddress(e){let t=this.host.bundle.scenes[e];return t?h(t):void 0}blockAddress(e){let t=this.host.blockById.get(e);return t?h(t):void 0}tagsForBeat(e){return this.host.tagIndex.get(e)??[]}tagsForScene(e){let t=this.resolveSceneRef(e);return(t!=null?this.host.tagIndex.get(t):void 0)??[]}tagsForBlock(e,t){let r=this.resolveSceneRef(e),n=this.resolveBlockRef(r,t);return(n!=null?this.host.tagIndex.get(n):void 0)??[]}getOutline(){return Object.values(this.host.bundle.scenes).map(e=>({id:e.id,...h(e)?{gameId:h(e)}:{},name:e.name,...this.tagsField(e.id),blocks:e.blocks.map(t=>({id:t.id,...h(t)?{gameId:h(t)}:{},name:t.name,...this.tagsField(t.id),children:t.children.map(r=>this.outlineNode(r))}))}))}getBeatSequence(){let e=[];for(let t of Object.values(this.host.bundle.scenes))for(let r of t.blocks)k(r.children,n=>{if(n.type==="snippet")for(let i of n.beats??[])e.push({sceneId:t.id,blockId:r.id,snippetId:n.id,beat:this.beatInfo(i)})});return e}outlineNode(e){return e.type==="group"?{type:"group",id:e.id,...this.tagsField(e.id),...e.selector?{selector:e.selector}:{},...e.prompt?{prompt:this.beatInfo(e.prompt)}:{},children:e.children.map(t=>this.outlineNode(t))}:{type:"snippet",id:e.id,...this.tagsField(e.id),beats:(e.beats??[]).map(t=>this.beatInfo(t)),...e.jump?{jumpTo:e.jump.to,...e.jump.mode?{jumpMode:e.jump.mode}:{}}:{}}}beatInfo(e){let t=this.host.tagIndex.get(e.id),r={id:e.id,kind:e.kind};if(e.kind==="line"){if(e.character!==void 0){r.character=e.character;let n=this.host.defaultStrings[G(e.character)]??this.host.castDisplay.get(e.character);n!==void 0&&(r.characterName=n)}e.direction!==void 0&&(r.direction=e.direction)}if(e.kind==="line"||e.kind==="text"){let n=this.host.defaultStrings[e.id];n!==void 0&&(r.text=n)}return e.gameData&&Object.keys(e.gameData).length&&(r.gameData=e.gameData),t&&t.length&&(r.tags=t),r}tagsField(e){let t=this.host.tagIndex.get(e);return t&&t.length?{tags:t}:{}}getFlow(e){return this.flowsById.get(e)}flows(){return[...this.flowsById.values()]}closeFlow(e){this.flowsById.get(e)?.close(),this.flowsById.delete(e)}reset(){for(let e of this.flowsById.values())e.close();this.flowsById.clear(),this.host.shared.reseedOwned("patter",this.host.patterSharedDecls),this.host.sharedVisits.clear(),this.host.sharedSelectors.clear(),this.host.stageBags.clear()}getProperty(e){let{scope:t,name:r}=this.splitShared(e);return this.host.shared.get(t,r)}setProperty(e,t){let{scope:r,name:n}=this.splitShared(e);this.host.shared.set(r,n,t)}listProperties(){return this.host.patterSharedDecls.map(e=>({ref:`@${e.name}`,type:e.type,values:e.values,value:this.getProperty(`@${e.name}`),default:ke(e)}))}splitShared(e){let t=this.host.refSplitCache.get(e);if(t||(t=F(e,r=>r==="scene"||this.host.shared.has(r)),this.host.refSplitCache.set(e,t)),t.scope==="scene")throw new Error(`\'${e}\': @scene properties are scene-scoped - read/write them on a Flow, not the Engine`);return t}save(){return this.host.shared.save()}load(e){this.host.shared.load(e)}saveGame(){let e={};for(let[t,r]of this.flowsById)e[t]=r.snapshot();return{version:2,shared:this.host.shared.save(),sharedVisits:Object.fromEntries(this.host.sharedVisits),sharedSelectors:ne(this.host.sharedSelectors),stageBags:Object.fromEntries([...this.host.stageBags].map(([t,r])=>[t,{...r}])),flows:e}}loadGame(e){if(e.version!==2)throw new Error(`unsupported save version: ${e.version}`);this.host.shared.load(e.shared),this.host.sharedVisits.clear();for(let[t,r]of Object.entries(e.sharedVisits??{}))this.host.sharedVisits.set(t,r);this.host.sharedSelectors.clear();for(let[t,r]of se(e.sharedSelectors))this.host.sharedSelectors.set(t,r);this.host.stageBags.clear();for(let[t,r]of Object.entries(e.stageBags??{}))this.host.stageBags.set(t,{...r});this.flowsById.clear();for(let[t,r]of Object.entries(e.flows)){let n=new v(t,this.host,this.defaultSeed);n.restore(r),this.flowsById.set(t,n)}}},v=class{id;host;local;rngState;started=!1;flowEnded=!1;closed=!1;currentSceneId=null;stack=[];activeSnippet=null;beatIndex=0;pendingChoice=null;pendingPromptBeat=null;pendingPromptOwnerId=null;selectors=new Map;visitCounts=new Map;sceneBags=new Map;patterResolver={get:e=>this.host.patterSharedNames.has(e)?this.host.shared.get("patter",e):this.local.get("patter",e),set:(e,t)=>{this.host.patterSharedNames.has(e)?this.host.shared.set("patter",e,t):this.local.set("patter",e,t)}};sceneResolver={get:e=>{let t=this.currentSceneId;return t===null?void 0:(this.host.sceneSharedNames.get(t)?.has(e)?this.host.stageBags.get(t):this.sceneBags.get(t))?.[e]},set:(e,t)=>{let r=this.currentSceneId;if(r===null)return;let n=this.host.sceneSharedNames.get(r)?.has(e)?this.host.stageBags.get(r):this.sceneBags.get(r);n&&(n[e]=t)}};evalCtx;constructor(e,t,r){this.id=e,this.host=t,this.rngState=r>>>0,this.local=this.freshLocal();let n={...t.shared.toEvalContext().scopes};n.patter=this.patterResolver,n.scene=this.sceneResolver,this.evalCtx={scopes:n,host:{nextRandom:this.rng,visits:i=>this.visitCounts.get(i)??0,patterVisits:i=>this.host.sharedVisits.get(i)??0}}}start(e,t){if(this.sceneBags.clear(),this.local=this.freshLocal(),this.selectors.clear(),this.visitCounts.clear(),this.stack=[],this.currentSceneId=null,this.flowEnded=!1,this.activeSnippet=null,this.beatIndex=0,this.pendingChoice=null,this.started=!0,t){let r=this.host.blockIndex.get(t);if(!r)throw new Error(`unknown block: ${t}`);this.enterSceneSetup(r.sceneId),this.stack=[{sceneId:r.sceneId,containerId:t,index:0}],this.enter(t)}else{let r=e??Object.keys(this.host.bundle.scenes)[0],n=r?this.host.bundle.scenes[r]:void 0;if(!n)throw new Error(r?`unknown scene: ${r}`:"no scenes in bundle");this.enterSceneSetup(r);let i=n.blocks[0];i&&(this.stack=[{sceneId:r,containerId:i.id,index:0}],this.enter(i.id))}this.settle()}reset(e,t){this.start(e,t)}goto(e,t){if(this.closed)return!1;if(e==="END")return this.started=!0,this.pendingChoice=null,this.pendingPromptBeat=null,this.pendingPromptOwnerId=null,this.activeSnippet=null,this.beatIndex=0,this.flowEnded=!0,this.stack=[],!0;let r=this.host.sceneGameIdToId.get(e)??(this.host.bundle.scenes[e]?e:void 0);if(r===void 0)return!1;let n;return t!==void 0&&(n=this.host.blockGameIdToId.get(r)?.get(t)??(this.host.blockIndex.get(t)?.sceneId===r?t:void 0),n===void 0)?!1:this.started?(this.pendingChoice=null,this.pendingPromptBeat=null,this.pendingPromptOwnerId=null,this.activeSnippet=null,this.beatIndex=0,this.flowEnded=!1,this.enterTarget(n??r,"jump"),this.settle(),!0):(this.start(r,n),!0)}close(){this.closed=!0,this.flowEnded=!0,this.stack=[],this.activeSnippet=null,this.beatIndex=0,this.pendingChoice=null,this.pendingPromptBeat=null,this.pendingPromptOwnerId=null}get isClosed(){return this.closed}get currentScene(){return this.currentSceneId}advance(){if(this.closed)return{type:"end"};if(!this.started)throw new Error("flow has not been started");if(this.pendingPromptBeat){let e=this.pendingPromptBeat;return this.pendingPromptBeat=null,this.pendingPromptOwnerId=null,this.beatResult(e)}return this.settle(),this.flowEnded?{type:"end"}:this.pendingChoice?{type:"choice",groupId:this.pendingChoice.groupId,options:this.pendingChoice.options}:this.activeSnippet?this.beatResult(this.activeSnippet.beats[this.beatIndex++]):(this.flowEnded=!0,{type:"end"})}advanceToStop(){let e=[];for(;;){let t=this.advance();if(t.type==="choice"||t.type==="end")return{played:e,stop:t};e.push(t)}}settle(){let e=0;for(;;){if(++e>1e4)throw new Error("flow did not settle after 10000 transitions - likely a jump cycle with no deliverable content");if(this.flowEnded||this.pendingChoice)return;if(this.activeSnippet){if(this.beatIndex<(this.activeSnippet.beats?.length??0))return;this.runEffects(this.activeSnippet.onExit);let n=this.activeSnippet.jump;this.activeSnippet=null,this.beatIndex=0,this.resolveJump(n);continue}let t=this.stack[this.stack.length-1];if(!t){this.flowEnded=!0;return}t.sceneId!==this.currentSceneId&&(this.currentSceneId=t.sceneId);let r=this.childrenOf(t.containerId);if(!r){this.stack.pop();continue}for(;t.index<r.length&&!this.eligible(r[t.index]);)t.index++;if(t.index>=r.length){this.stack.pop();continue}this.enterChild(r[t.index++])}}getChoices(){return this.pendingChoice?.options??[]}choose(e){let t=this.pendingChoice;if(!t)throw new Error("no choice is pending");let r=t.options.find(i=>i.id===e);if(!r)throw new Error(`unknown choice option: ${e}`);if(!r.eligible)throw new Error(`choice option is not eligible: ${e}`);let n=t.byId.get(e);this.pendingChoice=null,this.pendingPromptBeat=this.host.replayPromptOnChoose?this.promptBeatOf(n)??null:null,this.pendingPromptOwnerId=this.pendingPromptBeat?n.id:null,this.enterChild(n)}isEnded(){return this.flowEnded}getProperty(e){let{scope:t,name:r}=this.splitRef(e);return t==="patter"?this.patterResolver.get(r):t==="scene"?this.sceneResolver.get(r):this.host.shared.get(t,r)}setProperty(e,t){let{scope:r,name:n}=this.splitRef(e);if(r==="patter")this.patterResolver.set(n,t);else if(r==="scene"){if(this.currentSceneId===null)throw new Error(`\'${e}\': the flow has not entered a scene yet`);this.sceneResolver.set(n,t)}else this.host.shared.set(r,n,t)}snapshot(){return{scopes:this.local.save(),sceneBags:Object.fromEntries([...this.sceneBags].map(([e,t])=>[e,{...t}])),rngState:this.rngState,visits:Object.fromEntries(this.visitCounts),cursor:{flowEnded:this.flowEnded,currentSceneId:this.currentSceneId,stack:this.stack.map(e=>{let t=this.childrenOf(e.containerId)?.[e.index];return t?{...e,nextId:t.id}:{...e}}),activeSnippetId:this.activeSnippet?.id??null,beatIndex:this.beatIndex,pendingChoice:this.pendingChoice?{groupId:this.pendingChoice.groupId,options:this.pendingChoice.options.map(e=>({...e}))}:null,pendingPromptOwnerId:this.pendingPromptOwnerId,selectors:ne(this.selectors)}}}restore(e){this.rngState=e.rngState>>>0,this.visitCounts=new Map(Object.entries(e.visits??{}));let t=e.cursor;if(this.started=!0,this.flowEnded=t.flowEnded,this.beatIndex=t.beatIndex,this.currentSceneId=t.currentSceneId,this.stack=t.stack.map(r=>{let{nextId:n,...i}=r;if(n!==void 0){let o=this.childrenOf(i.containerId)?.findIndex(a=>a.id===n)??-1;if(o>=0)return{...i,index:o}}return{...i}}),this.sceneBags=new Map(Object.entries(e.sceneBags??{}).map(([r,n])=>[r,{...n}])),this.local=this.freshLocal(),this.local.load(e.scopes),this.activeSnippet=null,t.activeSnippetId!==null){let r=this.host.nodeIndex.get(t.activeSnippetId);r&&r.type==="snippet"&&(this.activeSnippet=r)}if(this.selectors=se(t.selectors),this.pendingChoice=null,t.pendingChoice!==null){let r=new Map,n=[];for(let i of t.pendingChoice.options){let o=this.host.nodeIndex.get(i.id);o&&(r.set(i.id,o),n.push({...i}))}n.length>0&&(this.pendingChoice={groupId:t.pendingChoice.groupId,options:n,byId:r})}if(this.pendingPromptBeat=null,this.pendingPromptOwnerId=t.pendingPromptOwnerId??null,this.pendingPromptOwnerId){let r=this.host.nodeIndex.get(this.pendingPromptOwnerId);this.pendingPromptBeat=r?this.promptBeatOf(r)??null:null,this.pendingPromptBeat||(this.pendingPromptOwnerId=null)}}enterSceneSetup(e){let t=this.host.bundle.scenes[e];if(!t)throw new Error(`unknown scene: ${e}`);this.currentSceneId=e,this.enter(e),this.seedScene(t),this.runEffects(t.onEntry)}enterChild(e){if(this.enter(e.id),e.type==="snippet"){this.beginSnippet(e);return}let t=e.selector??"run";if(t==="run"){this.stack.push({sceneId:this.currentSceneId,containerId:e.id,index:0});return}if(t==="choice"){this.setupChoice(e);return}let r=this.selectChild(e);r&&this.enterChild(r)}childrenOf(e){let t=this.host.blockById.get(e);if(t)return t.children;let r=this.host.nodeIndex.get(e);if(r&&r.type==="group")return r.children}beginSnippet(e){this.runEffects(e.onEnter),this.activeSnippet=e,this.beatIndex=0}setupChoice(e){let t=[],r=new Map,n=[];for(let o of e.children){if(o.fallback===!0){n.push(o);continue}if(o.sticky!==!0&&(this.visitCounts.get(o.id)??0)>=1)continue;let a=this.eligible(o),l=o.secretUntilEligible===!0;!a&&l||(t.push({id:o.id,prompt:this.promptFor(o),eligible:a,gameData:o.gameData}),r.set(o.id,o))}if(t.length>0){this.pendingChoice={groupId:e.id,options:t,byId:r};return}let i=n.find(o=>this.eligible(o));if(i){this.enterChild(i);return}this.host.onDryChoice?.(e.id)}resolveJump(e){e&&this.enterTarget(e.to,e.mode==="call"?"call":"jump")}enterTarget(e,t){if(e==="END"){this.flowEnded=!0,this.stack=[];return}let r,n,i=this.host.bundle.scenes[e];if(i){this.enterSceneSetup(e);let a=i.blocks[0];if(!a){t==="jump"&&(this.stack=[]);return}r=e,n=a.id}else{let a=this.host.blockIndex.get(e);if(!a)throw new Error(`jump target not found: ${e}`);a.sceneId!==this.currentSceneId&&this.enterSceneSetup(a.sceneId),r=a.sceneId,n=e}this.enter(n);let o={sceneId:r,containerId:n,index:0};t==="call"?this.stack.push(o):this.stack=[o]}selectChild(e){let t=e.children.filter(n=>this.eligible(n));if(t.length===0)return null;let r=this.selectorState(e);switch(e.selector){case"branch":return t[0];case"sequence":{let n=e.options?.order??"sequential",i=e.options?.exhaust??"once";return n==="shuffle"?this.pickShuffle(t,i,r):n==="specificity"?this.pickSpecificity(t,i,r):this.pickSequential(t,i,r)}default:return null}}pickSequential(e,t,r){let n=e.length,i=r.seq??0;return r.seq=i+1,t==="repeat"?e[i%n]:i<n?e[i]:t==="stick"?e[n-1]:null}pickShuffle(e,t,r){let n=e.length,i=t==="stick",o=()=>(i?e.slice(0,n-1):e).map(g=>g.id);if(r.bag===void 0&&(r.bag=o()),r.bag.length===0){if(t==="once")return null;if(i){let g=e[n-1];return r.last=g.id,g}r.bag=o()}let a=r.bag,l=r.last!==void 0&&a.length>1?a.indexOf(r.last):-1,c=Math.floor(this.rng()*(l>=0?a.length-1:a.length));l>=0&&c>=l&&c++;let u=a[c];return a.splice(c,1),r.last=u,e.find(g=>g.id===u)}pickSpecificity(e,t,r){let n=e;if(t!=="repeat"){r.bag===void 0&&(r.bag=e.map(u=>u.id));let c=new Set(r.bag);if(n=e.filter(u=>c.has(u.id)),n.length===0)return t==="stick"&&r.last!==void 0?e.find(u=>u.id===r.last)??null:null}let i=-1,a=n.map(c=>{let u=this.specScore(c);return u>i&&(i=u),{c,s:u}}).filter(c=>c.s===i).map(c=>c.c),l;if(a.length===1)l=a[0];else{let c=r.last!==void 0?a.findIndex(g=>g.id===r.last):-1,u=Math.floor(this.rng()*(c>=0?a.length-1:a.length));c>=0&&u>=c&&u++,l=a[u]}return t!=="repeat"&&(r.bag=r.bag.filter(c=>c!==l.id)),r.last=l.id,l}specScore(e){return e.condition?this.matchedSpec(this.conditionAst(e.condition),!0):0}matchedSpec(e,t){return W(e,n=>re(E(n,this.evalCtx,T)),{want:t})}selectorState(e){let t=e.shared?this.host.sharedSelectors:this.selectors,r=t.get(e.id);return r||(r={},t.set(e.id,r)),r}runEffects(e){for(let t of e??[])this.setProperty(t.target,this.evalExpr(t.value))}eligible(e){return e.condition?re(this.evalExpr(e.condition)):!0}evalExpr(e){return E(this.conditionAst(e),this.evalCtx,T)}conditionAst(e){let t=Y.get(e);return t||(t=S(e.ast),Y.set(e,t)),t}enter(e){this.visitCounts.set(e,(this.visitCounts.get(e)??0)+1),this.host.sharedVisits.set(e,(this.host.sharedVisits.get(e)??0)+1)}rng=()=>{if(this.host.customRng)return this.host.customRng();let e=this.rngState+1831565813|0;this.rngState=e;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296};beatResult(e){let t=this.host.tagIndex.get(e.id),r=t&&t.length?{tags:t}:{};switch(e.kind){case"gameEvent":return{type:"gameEvent",id:e.id,gameData:e.gameData,...r};case"text":return{type:"text",id:e.id,text:this.interpolate(this.resolveString(e.id)),gameData:e.gameData,...r};case"line":{let n=this.resolveString(e.id),i=!this.host.captionsOn,a=i&&e.character===this.host.captionCharacter?"":this.captionLine(this.host.bundle.voiced?n:this.interpolate(n)),l=i&&a.length===0;return{type:"line",id:e.id,text:a,character:l?void 0:e.character,characterName:l?void 0:this.resolveCharacterName(e.character),direction:l?void 0:e.direction,gameData:e.gameData,...r}}}}interpolate(e){return Z(e,t=>this.getProperty(t))}stripCaptions(e){return X(e,this.host.captionOpen,this.host.captionClose)}captionLine(e){return this.host.captionsOn?e:this.stripCaptions(e)}promptFor(e){let t=this.promptBeatOf(e);if(!t)return;let r=this.interpolate(this.resolveString(t.id));return t.kind==="line"?{kind:"line",text:this.captionLine(r),character:t.character,characterName:this.resolveCharacterName(t.character),direction:t.direction}:{kind:"text",text:r}}promptBeatOf(e){return e.type==="group"&&e.prompt?e.prompt:((e.type==="snippet"?e:this.firstTextSnippetIn(e.children))?.beats??[]).find(r=>r.kind==="line"||r.kind==="text")}firstTextSnippetIn(e){let t;return k(e,r=>{!t&&r.type==="snippet"&&(r.beats??[]).some(n=>n.kind==="line"||n.kind==="text")&&(t=r)}),t}resolveString(e){if(this.host.emitIds)return e;let t=this.host.strings[e];if(t!==void 0)return t;let r=this.host.defaultStrings[e];return r!==void 0?`<Untranslated: ${e}> ${r}`:e}resolveCharacterName(e){if(e===void 0||this.host.emitIds)return;let t=G(e);return this.host.strings[t]??this.host.defaultStrings[t]??this.host.castDisplay.get(e)}splitRef(e){let t=this.host.refSplitCache.get(e);return t||(t=F(e,r=>r==="scene"||this.host.shared.has(r)),this.host.refSplitCache.set(e,t)),t}freshLocal(){return new w().defineOwned("patter",this.host.patterLocalDecls)}seedScene(e){let t=this.host.sceneSharedNames.get(e.id)??new Set;if(!this.sceneBags.has(e.id)){let r={};for(let n of e.sceneProps??[]){let i=n.name.toLowerCase();t.has(i)||(r[i]=M(n))}this.sceneBags.set(e.id,r)}if(!this.host.stageBags.has(e.id)){let r={};for(let n of e.sceneProps??[]){let i=n.name.toLowerCase();t.has(i)&&(r[i]=M(n))}this.host.stageBags.set(e.id,r)}for(let r of e.sceneProps??[]){if(!r.temporary)continue;let n=r.name.toLowerCase(),i=t.has(n)?this.host.stageBags.get(e.id):this.sceneBags.get(e.id);i&&(i[n]=M(r))}}};function ne(s){let e={};for(let[t,r]of s){let n={};r.seq!==void 0&&(n.seq=r.seq),r.bag&&(n.bag=[...r.bag]),r.last!==void 0&&(n.last=r.last),e[t]=n}return e}function se(s){let e=new Map;for(let[t,r]of Object.entries(s??{})){let n={};r.seq!==void 0&&(n.seq=r.seq),r.bag&&(n.bag=[...r.bag]),r.last!==void 0&&(n.last=r.last),e.set(t,n)}return e}function ee(s){return{name:s.name,type:s.type,values:s.values,default:s.default}}function ke(s){if(s.default!==void 0)return s.default;switch(s.type){case"number":return 0;case"string":return"";case"flags":return[];case"enum":return s.values?.[0]??"";default:return!1}}function te(s){return{name:s.name,type:s.type,values:s.values,default:s.default,writable:s.writable}}function Ee(s){if(s.default!==void 0)return s.default;switch(s.type){case"boolean":return!1;case"number":return 0;case"string":return"";case"flags":return[];case"enum":return s.values?.[0]??""}}function Ce(s){let e=new Map;for(let t of s)e.set(t.name,Ee(t));return{get:t=>e.get(t),set:(t,r)=>{e.set(t,r)}}}function M(s){if(s.default!==void 0)return s.default;switch(s.type){case"boolean":return!1;case"number":return 0;case"string":return"";case"flags":return[];case"enum":return s.values?.[0]??""}}function re(s){return typeof s=="boolean"?s:typeof s=="number"?s!==0:typeof s=="string"?s!=="":s.length>0}function ie(s,e){return s.gameDataFields?.[e]??[]}function j(s,e,t){return e&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:s.find(r=>r.name===t)?.default}function oe(s,e){let t={};for(let r of s){let n=j(s,e,r.name);n!==void 0&&(t[r.name]=n)}for(let[r,n]of Object.entries(e??{}))r in t||(t[r]=n);return t}return fe(Ie);})();\n//# sourceMappingURL=patterplay.min.js.map';
|
|
194202
|
+
var PLAYABLE_RUNTIME_JS = '"use strict";var Patterplay=(()=>{var A=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var Se=(n,e)=>{for(var t in e)A(n,t,{get:e[t],enumerable:!0})},ye=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fe(e))!me.call(n,s)&&s!==t&&A(n,s,{get:()=>e[s],enumerable:!(r=he(e,s))||r.enumerable});return n};var ve=n=>ye(A({},"__esModule",{value:!0}),n);var Fe={};Se(Fe,{Engine:()=>O,Flow:()=>b,buildTagIndex:()=>B,describeBundle:()=>le,effectiveGameData:()=>de,gameDataFields:()=>pe,gameDataValue:()=>_});function S(n){switch(n[0]){case"b":return{kind:"bool",value:n[1]};case"n":return{kind:"number",value:n[1]};case"s":return{kind:"string",value:n[1]};case"sv":return{kind:"scopedvar",scope:n[1],name:n[2]};case"u":return{kind:"unary",op:n[1],operand:S(n[2])};case"bin":return{kind:"binary",op:n[1],left:S(n[2]),right:S(n[3])};case"call":{let e=n.slice(2).map(S);return{kind:"call",name:n[1],args:e}}case"fd":return{kind:"flagdelta",sign:n[1],name:n[2]}}}var p=class extends Error{constructor(e){super(e),this.name="EvalError"}};function C(n,e,t){let r=new Map(t.scopes.map(i=>[i.token,i.missing??"false"])),s=i=>{switch(i.kind){case"bool":return i.value;case"number":return i.value;case"string":return i.value;case"scopedvar":{let o=e.scopes[i.scope];if(o===void 0)return!1;let a=typeof o.get=="function"?o.get(i.name):o[i.name];if(a===void 0){if(r.get(i.scope)==="throw")throw new p(`@${i.scope}.${i.name} is not declared on the current ${i.scope}.`);return!1}return a}case"call":{let o=t.functions[i.name];if(!o)throw new p(`unknown function \'${i.name}\'`);return o.eval(i.args,{evaluate:s,ctx:e})}case"flagdelta":throw new p("flagdelta node is only valid as an argument to a flag-delta function");case"unary":{if(i.op==="not"){let a=s(i.operand);if(typeof a!="boolean")throw new p(`\'not\' requires a boolean operand, got ${typeof a}`);return!a}let o=s(i.operand);if(typeof o!="number")throw new p(`unary \'-\' requires a numeric operand, got ${typeof o}`);return-o}case"binary":{if(i.op==="and"){let c=s(i.left);if(typeof c!="boolean")throw new p(`\'and\' requires boolean operands, left is ${typeof c}`);if(!c)return!1;let l=s(i.right);if(typeof l!="boolean")throw new p(`\'and\' requires boolean operands, right is ${typeof l}`);return l}if(i.op==="or"){let c=s(i.left);if(typeof c!="boolean")throw new p(`\'or\' requires boolean operands, left is ${typeof c}`);if(c)return!0;let l=s(i.right);if(typeof l!="boolean")throw new p(`\'or\' requires boolean operands, right is ${typeof l}`);return l}let o=s(i.left),a=s(i.right);switch(i.op){case"==":return J(o,a);case"!=":return!J(o,a);case">":return y(o,a,">"),o>a;case">=":return y(o,a,">="),o>=a;case"<":return y(o,a,"<"),o<a;case"<=":return y(o,a,"<="),o<=a;case"+":if(typeof o=="number"&&typeof a=="number"||typeof o=="string"&&typeof a=="string")return o+a;throw new p(`\'+\' requires two numbers or two strings, got ${typeof o} and ${typeof a}`);case"-":return y(o,a,"-"),o-a;case"*":return y(o,a,"*"),o*a;case"/":if(y(o,a,"/"),a===0)throw new p("division by zero");return o/a}}}};return s(n)}function J(n,e){if(Array.isArray(n)||Array.isArray(e)){if(!Array.isArray(n)||!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}return n===e}function y(n,e,t){if(typeof n!="number"||typeof e!="number")throw new p(`\'${t}\' requires numeric operands, got ${typeof n} and ${typeof e}`)}var be={name:"check_flags",count:n=>Math.max(1,n.args.length-1)},we=[be];function z(n,e,t){let r=t?.countingCalls??we;return E(n,t?.want??!0,e,r)}function E(n,e,t,r){if(n.kind==="binary"&&(n.op==="and"||n.op==="or")){let s=E(n.left,e,t,r),i=E(n.right,e,t,r);return n.op==="and"===e?s>0&&i>0?s+i:0:Math.max(s,i)}if(n.kind==="unary"&&n.op==="not")return E(n.operand,!e,t,r);if(n.kind==="call"){let s=r.find(i=>i.name===n.name);if(s){let i=s.count(n),o=t(n);return e?o?i:0:o?0:1}}return t(n)===e?1:0}var G=class n{values={};decls=new Map;subscribers=new Set;auditors=new Set;norm;constructor(e=[],t){this.norm=t?.normalise??(r=>r.toLowerCase()),this.seed(e)}seed(e){for(let t of e){let r=this.norm(t.name);this.decls.set(r,t),this.values[r]=structuredClone(t.default??Z(t))}}get(e){return this.values[this.norm(e)]}set(e,t,r){let s=this.norm(e);if(this.decls.get(s)?.writable===!1)throw new Error(`\'${e}\' is read-only`);let i={name:s,prev:this.values[s],next:t,silent:r?.silent??!1,reason:r?.reason};this.values[s]=t;for(let o of this.auditors)o(i);if(!i.silent)for(let o of this.subscribers)o(i);return i}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}onAudit(e){return this.auditors.add(e),()=>this.auditors.delete(e)}rows(){return[...this.decls.entries()].map(([e,t])=>X(t,this.get(e),void 0,e))}declarations(){return[...this.decls.values()]}clone(){let e=new n([],{normalise:this.norm});return e.decls=new Map(this.decls),Object.assign(e.values,structuredClone(this.values)),e}reseed(e){for(let t of Object.keys(this.values))delete this.values[t];this.decls.clear(),this.seed(e)}save(){return structuredClone(this.values)}load(e){for(let[t,r]of Object.entries(e))this.values[this.norm(t)]=r}};function X(n,e,t,r){return{name:r??n.name.toLowerCase(),type:n.type,value:e,default:n.default??Z(n),...n.values!==void 0?{values:n.values}:{},writable:t??n.writable??!0}}var F=1,w=class{scopes=new Map;defineOwned(e,t){return this.mountOwned(e,new G(t))}mountOwned(e,t){return this.assertFree(e),this.scopes.set(e,{kind:"owned",bag:t}),this}ownedBag(e){let t=this.scopes.get(e);if(!t||t.kind!=="owned")throw new Error(`\'@${e}\' is not an owned scope`);return t.bag}reseedOwned(e,t){return this.ownedBag(e).reseed(t),this}defineForeign(e,t,r=[],s=!0){this.assertFree(e);let i=new Map;for(let o of r)i.set(o.name.toLowerCase(),o);return this.scopes.set(e,{kind:"foreign",resolver:t,decls:i,scopeWritable:s}),this}has(e){return this.scopes.has(e)}get(e,t){let r=this.scopes.get(e);if(r)return r.kind==="owned"?r.bag.get(t):r.resolver.get(t.toLowerCase())}set(e,t,r){let s=this.scopes.get(e);if(!s)throw new Error(`unknown scope \'@${e}\'`);if(s.kind==="owned"){try{s.bag.set(t,r)}catch{throw new Error(`\'@${e}.${t}\' is read-only`)}return}let i=t.toLowerCase();if(!this.foreignWritable(s,i))throw new Error(`\'@${e}.${t}\' is read-only`);s.resolver.set(i,r)}foreignWritable(e,t){return e.resolver.set?e.decls.get(t)?.writable??e.scopeWritable:!1}listProperties(){let e=[];for(let[t,r]of this.scopes)if(r.kind==="owned")for(let s of r.bag.rows())e.push({scope:t,...s});else for(let s of r.decls.values())e.push({scope:t,...X(s,r.resolver.get(s.name.toLowerCase()),this.foreignWritable(r,s.name.toLowerCase()))});return e}toEvalContext(e){let t={};for(let[r,s]of this.scopes)t[r]=s.kind==="owned"?s.bag.values:s.resolver;return{scopes:t,host:e}}toSchema(){let e=new Map;for(let[t,r]of this.scopes){let s=r.kind==="owned"?r.bag.declarations():[...r.decls.values()];if(s.length===0)continue;let i=new Map;for(let o of s)i.set(o.name.toLowerCase(),{type:o.type,enumValues:o.values});e.set(t,i)}return{properties:e}}save(){let e={};for(let[t,r]of this.scopes)r.kind==="owned"&&(e[t]=r.bag.save());return e}load(e){for(let[t,r]of Object.entries(e)){let s=this.scopes.get(t);s?.kind==="owned"&&s.bag.load(r)}}saveFragment(){return{version:F,scopes:this.save()}}loadFragment(e){if(e.version!==F)throw new Error(`unsupported owned-state fragment version ${e.version} (supported: ${F})`);this.load(e.scopes)}assertFree(e){if(this.scopes.has(e))throw new Error(`scope \'@${e}\' is already registered`)}};function Z(n){if(n.default!==void 0)return n.default;switch(n.type){case"boolean":return!1;case"number":return 0;case"string":return"";case"enum":return n.values?.[0]??"";case"flags":return[]}}function x(n){return n.ctx.host??{}}var T={defaultScope:"patter",scopes:[{token:"patter"},{token:"scene"}],functions:{random:{minArgs:2,maxArgs:2,returnType:"number",eval(n,e){if(n.length!==2)throw new p("random(a, b) requires exactly 2 arguments");let t=x(e).nextRandom;if(!t)throw new p("random() called without a PRNG in context");let r=e.evaluate(n[0]),s=e.evaluate(n[1]);if(typeof r!="number"||typeof s!="number")throw new p("random(a, b) arguments must be numbers");if(!Number.isInteger(r)||!Number.isInteger(s))throw new p("random(a, b) arguments must be integers");let i=Math.min(r,s),o=Math.max(r,s);return Math.floor(t()*(o-i+1))+i}},check_flags:{minArgs:1,returnType:"boolean",flagDeltaArgs:!0,validate:Y("check_flags"),eval(n,e){let t=Q(n[0],e,"check_flags");for(let r=1;r<n.length;r++){let s=n[r];if(s.kind!=="flagdelta")throw new p("check_flags() flag args must be +flagName or -flagName");if(s.sign==="+"?!t.includes(s.name):t.includes(s.name))return!1}return!0}},set_flags:{minArgs:1,returnType:"flags",flagDeltaArgs:!0,validate:Y("set_flags"),eval(n,e){let t=[...Q(n[0],e,"set_flags")];for(let r=1;r<n.length;r++){let s=n[r];if(s.kind!=="flagdelta")throw new p("set_flags() flag args must be +flagName or -flagName");if(s.sign==="+")t.includes(s.name)||t.push(s.name);else{let i=t.indexOf(s.name);i>=0&&t.splice(i,1)}}return t}},visits:{minArgs:1,maxArgs:1,returnType:"number",validate:I("visits"),eval:(n,e)=>x(e).visits?.(D(n,e,"visits"))??0},seen:{minArgs:1,maxArgs:1,returnType:"boolean",validate:I("seen"),eval:(n,e)=>(x(e).visits?.(D(n,e,"seen"))??0)>0},patter_visits:{minArgs:1,maxArgs:1,returnType:"number",validate:I("patter_visits"),eval:(n,e)=>x(e).patterVisits?.(D(n,e,"patter_visits"))??0},patter_seen:{minArgs:1,maxArgs:1,returnType:"boolean",validate:I("patter_seen"),eval:(n,e)=>(x(e).patterVisits?.(D(n,e,"patter_seen"))??0)>0}}};function V(n,e){let t=n.replace(/^@/,"").split(".");return t.length===2&&e(t[0])?{scope:t[0],name:t[1].toLowerCase()}:{scope:"patter",name:t.join(".").toLowerCase()}}function D(n,e,t){let r=e.evaluate(n[0]);if(typeof r!="string")throw new p(`${t}(id) requires a string node id`);return r}function I(n){return(e,t)=>{let r=e[0];r&&r.kind!=="string"&&t.report({path:[...t.path,"args",0],kind:"wrong-arg-type",severity:"error",message:`${n}(id): the argument must be a string id literal (a scene / block / node id)`})}}function Q(n,e,t){if(!n)throw new p(`${t}() requires at least one argument (the flags variable)`);let r=e.evaluate(n);if(Array.isArray(r))return r;if(r===!1||r===null||r===void 0)return[];throw new p(`${t}() first argument must be a flags property`)}function Y(n){return(e,t)=>{if(e.length===0)return;let r=e[0];if(r.kind!=="scopedvar"){t.report({path:[...t.path,"args",0],kind:"wrong-arg-type",severity:"error",message:`${n}(): first argument must be a flags property reference (@name or @scope.name)`});return}let s=t.schema.properties.get(r.scope)?.get(r.name);if(s&&s.type!=="flags"){let i=r.scope===t.defaultScope?r.name:`${r.scope}.${r.name}`;t.report({path:[...t.path,"args",0],kind:"wrong-arg-type",severity:"error",message:`${n}(): \'@${i}\' is not a flags property (got ${s.type})`});return}for(let i=1;i<e.length;i++){let o=e[i];o.kind!=="flagdelta"?t.report({path:[...t.path,"args",i],kind:"wrong-arg-type",severity:"error",message:`${n}(): argument ${i+1} must be +flagName or -flagName`}):s?.type==="flags"&&s.enumValues&&!s.enumValues.includes(o.name)&&t.report({path:[...t.path,"args",i],kind:"unknown-flag-name",severity:"error",message:`${n}(): unknown flag \'${o.name}\'`,reference:o.name})}}}var xe=/^@[A-Za-z0-9_.]+$/;function*ke(n){let e="",t=0;for(;t<n.length;){let r=n[t];if(r==="{"&&n[t+1]==="{"){e+="{",t+=2;continue}if(r==="}"&&n[t+1]==="}"){e+="}",t+=2;continue}if(r==="{"){let s=n.indexOf("}",t+1);if(s!==-1){let i=n.slice(t,s+1),o=n.slice(t+1,s).trim();if(o.startsWith("@")){e&&(yield{kind:"text",value:e},e=""),yield{kind:"slot",raw:i,inner:o,ref:xe.test(o)?o:void 0},t=s+1;continue}e+=i,t=s+1;continue}}e+=r,t+=1}e&&(yield{kind:"text",value:e})}function Ce(n){return Array.isArray(n)?n.join(", "):typeof n=="boolean"?n?"true":"false":String(n)}function Ee(n){return n===" "||n===" "||n===`\n`||n==="\\r"||n==="\\f"||n==="\\v"}function De(n){let e="",t=!1;for(let r of n){if(Ee(r)){t=!0;continue}t&&e.length>0&&(e+=" "),t=!1,e+=r}return e}function ee(n,e,t){if(e.length===0||n.indexOf(e)<0)return n;let r="",s=0,i=!1;for(;s<n.length;){if(n.startsWith(e,s)){let o=n.indexOf(t,s+e.length);if(o>=0){s=o+t.length,i=!0;continue}r+=n.slice(s);break}r+=n[s],s+=1}return i?De(r):n}function te(n,e){if(n.indexOf("{")<0)return n;let t="";for(let r of ke(n)){if(r.kind==="text"){t+=r.value;continue}if(!r.ref){t+=r.raw;continue}let s=e(r.ref);t+=s===void 0?"":Ce(s)}return t}function k(n,e){for(let t of n){e(t);let r=t.children;r&&k(r,e)}}function Ie(n){return n.toLowerCase().replace(/[\'\u2019]/g,"").replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function g(n){let e=n.gameId?.trim();return e||Ie(n.name)}function M(n){return`cast:${n}`}var j={open:"[",close:"]"},re="SFX";function R(n){let e=new Set,t=[];for(let r of n)e.has(r)||(e.add(r),t.push(r));return t}function B(n){let e=new Map,t=(r,s)=>{let i=R([...s,...r.tags??[]]);if(e.set(r.id,i),r.type==="group")for(let o of r.children)t(o,i);else for(let o of r.beats??[])e.set(o.id,R([...i,...o.tags??[]]))};for(let r of Object.values(n.scenes)){let s=R(r.tags??[]);e.set(r.id,s);for(let i of r.blocks){let o=R([...s,...i.tags??[]]);e.set(i.id,o);for(let a of i.children)t(a,o)}}return e}var ne=new WeakMap,O=class n{host;defaultSeed;flowsById=new Map;allStrings;currentLocale;sourceDebug;sceneGameIdToId=new Map;blockGameIdToId=new Map;creationOptions;constructor(e,t={}){this.creationOptions=t;let r=t.locale??e.locales.default,s=e.strings;this.allStrings=s,this.currentLocale=r;let i=s[r]??{},o=s[e.locales.default]??{},a=e.localisation,c=a?.mode==="ids"&&!a.sourceDebug;this.sourceDebug=a?.mode==="ids"&&!!a.sourceDebug,this.sourceDebug&&typeof console<"u"&&console.warn("[Patterplay] source-only DEBUG build: strings are the source language for debugging, not a shippable localised build.");let l=new Map;for(let d of e.cast??[])d.displayName&&l.set(d.name,d.displayName);this.defaultSeed=(t.seed??2654435769)>>>0;let u=new Map,h=new Map,H=new Map;for(let[d,m]of Object.entries(e.scenes)){this.sceneGameIdToId.set(g(m),d);let v=new Map;for(let f of m.blocks)h.set(f.id,{sceneId:d}),H.set(f.id,f),v.set(g(f),f.id),k(f.children,K=>u.set(K.id,K));this.blockGameIdToId.set(d,v)}let q=e.properties??[],P=q.filter(d=>d.shared??!0).map(se),ue=q.filter(d=>!(d.shared??!0)).map(se),ge=new Set(P.map(d=>d.name.toLowerCase())),N=new w().defineOwned("patter",P),U=new Set;if(t.world){let d=e.scopeRegistry?.scopes.find(v=>v.token==="world"),m=(d?.declarations??[]).map(ie);N.defineForeign("world",t.world,m,d?.writable??!0),U.add("world")}for(let d of e.scopeRegistry?.scopes??[]){if(U.has(d.token))continue;let m=(d.declarations??[]).map(ie);N.defineForeign(d.token,Oe(d.declarations??[]),m,d.writable??!0)}let W=new Map;for(let[d,m]of Object.entries(e.scenes)){let v=new Set((m.sceneProps??[]).filter(f=>f.shared??!1).map(f=>f.name.toLowerCase()));W.set(d,v)}this.host={bundle:e,emitIds:c,strings:i,defaultStrings:o,castDisplay:l,nodeIndex:u,blockIndex:h,blockById:H,sceneGameIdToId:this.sceneGameIdToId,blockGameIdToId:this.blockGameIdToId,tagIndex:B(e),shared:N,patterSharedDecls:P,patterLocalDecls:ue,patterSharedNames:ge,sceneSharedNames:W,sharedVisits:new Map,sharedSelectors:new Map,stageBags:new Map,customRng:t.rng,onDryChoice:t.onDryChoice,replayPromptOnChoose:t.replayPromptOnChoose??!1,captionsOn:t.closedCaptions??!0,captionOpen:(e.closedCaptions??j).open,captionClose:(e.closedCaptions??j).close,captionCharacter:e.closedCaptions?.character||re,refSplitCache:new Map}}get locale(){return this.currentLocale}get isSourceDebug(){return this.sourceDebug}setLocale(e){this.currentLocale=e,this.host.strings=this.allStrings[e]??{}}replaceStrings(e){this.allStrings=e.strings,this.host.strings=this.allStrings[this.currentLocale]??{},this.host.defaultStrings=this.allStrings[this.host.bundle.locales.default]??{}}hotSwap(e){let t=this.saveGame(),r=i=>(i.setLocale(this.currentLocale),i.setClosedCaptions(this.host.captionsOn),i),s=new n(e,this.creationOptions);try{return s.loadGame(t),r(s)}catch{let i=new n(e,this.creationOptions);for(let[o,a]of Object.entries(t.flows)){let c=a.cursor.currentSceneId;try{i.openFlow(o,c!==null?{scene:c}:{})}catch{}}return r(i)}}get closedCaptions(){return this.host.captionsOn}setClosedCaptions(e){this.host.captionsOn=e}openFlow(e,t={}){let r=this.resolveSceneRef(t.scene),s=this.resolveBlockRef(r,t.block);this.flowsById.get(e)?.close();let i=new b(e,this.host,t.seed??this.defaultSeed);return this.flowsById.set(e,i),i.start(r,s),i}runFlow(e,t,r){let s=this.flowsById.get(e);if(!s)return this.openFlow(e,{scene:t,block:r}).advanceToStop().played;if(!s.goto(t,r))throw new Error(`runFlow: address not found: ${t}${r===void 0?"":` / ${r}`}`);return s.advanceToStop().played}resolveSceneRef(e){if(e!=null)return this.host.bundle.scenes[e]?e:this.sceneGameIdToId.get(e)??e}resolveBlockRef(e,t){if(t!=null){if(this.host.blockById.has(t))return t;if(e!=null){let r=this.blockGameIdToId.get(e)?.get(t);if(r)return r}return t}}sceneAddress(e){let t=this.host.bundle.scenes[e];return t?g(t):void 0}blockAddress(e){let t=this.host.blockById.get(e);return t?g(t):void 0}tagsForBeat(e){return this.host.tagIndex.get(e)??[]}tagsForScene(e){let t=this.resolveSceneRef(e);return(t!=null?this.host.tagIndex.get(t):void 0)??[]}tagsForBlock(e,t){let r=this.resolveSceneRef(e),s=this.resolveBlockRef(r,t);return(s!=null?this.host.tagIndex.get(s):void 0)??[]}getOutline(){return Object.values(this.host.bundle.scenes).map(e=>({id:e.id,...g(e)?{gameId:g(e)}:{},name:e.name,...this.tagsField(e.id),blocks:e.blocks.map(t=>({id:t.id,...g(t)?{gameId:g(t)}:{},name:t.name,...this.tagsField(t.id),children:t.children.map(r=>this.outlineNode(r))}))}))}getBeatSequence(){let e=[];for(let t of Object.values(this.host.bundle.scenes))for(let r of t.blocks)k(r.children,s=>{if(s.type==="snippet")for(let i of s.beats??[])e.push({sceneId:t.id,blockId:r.id,snippetId:s.id,beat:this.beatInfo(i)})});return e}outlineNode(e){return e.type==="group"?{type:"group",id:e.id,...this.tagsField(e.id),...e.selector?{selector:e.selector}:{},...e.prompt?{prompt:this.beatInfo(e.prompt)}:{},children:e.children.map(t=>this.outlineNode(t))}:{type:"snippet",id:e.id,...this.tagsField(e.id),beats:(e.beats??[]).map(t=>this.beatInfo(t)),...e.jump?{jumpTo:e.jump.to,...e.jump.mode?{jumpMode:e.jump.mode}:{}}:{}}}beatInfo(e){let t=this.host.tagIndex.get(e.id),r={id:e.id,kind:e.kind};if(e.kind==="line"){if(e.character!==void 0){r.character=e.character;let s=this.host.defaultStrings[M(e.character)]??this.host.castDisplay.get(e.character);s!==void 0&&(r.characterName=s)}e.direction!==void 0&&(r.direction=e.direction)}if(e.kind==="line"||e.kind==="text"){let s=this.host.defaultStrings[e.id];s!==void 0&&(r.text=s)}return e.gameData&&Object.keys(e.gameData).length&&(r.gameData=e.gameData),t&&t.length&&(r.tags=t),r}tagsField(e){let t=this.host.tagIndex.get(e);return t&&t.length?{tags:t}:{}}getFlow(e){return this.flowsById.get(e)}flows(){return[...this.flowsById.values()]}closeFlow(e){this.flowsById.get(e)?.close(),this.flowsById.delete(e)}reset(){for(let e of this.flowsById.values())e.close();this.flowsById.clear(),this.host.shared.reseedOwned("patter",this.host.patterSharedDecls),this.host.sharedVisits.clear(),this.host.sharedSelectors.clear(),this.host.stageBags.clear()}getProperty(e){let{scope:t,name:r}=this.splitShared(e);return this.host.shared.get(t,r)}setProperty(e,t){let{scope:r,name:s}=this.splitShared(e);this.host.shared.set(r,s,t)}listProperties(){return this.host.patterSharedDecls.map(e=>({ref:`@${e.name}`,type:e.type,values:e.values,value:this.getProperty(`@${e.name}`),default:Re(e)}))}splitShared(e){let t=this.host.refSplitCache.get(e);if(t||(t=V(e,r=>r==="scene"||this.host.shared.has(r)),this.host.refSplitCache.set(e,t)),t.scope==="scene")throw new Error(`\'${e}\': @scene properties are scene-scoped - read/write them on a Flow, not the Engine`);return t}save(){return this.host.shared.save()}load(e){this.host.shared.load(e)}saveGame(){let e={};for(let[t,r]of this.flowsById)e[t]=r.snapshot();return{version:2,shared:this.host.shared.save(),sharedVisits:Object.fromEntries(this.host.sharedVisits),sharedSelectors:ae(this.host.sharedSelectors),stageBags:Object.fromEntries([...this.host.stageBags].map(([t,r])=>[t,{...r}])),flows:e}}loadGame(e){if(e.version!==2)throw new Error(`unsupported save version: ${e.version}`);this.host.shared.load(e.shared),this.host.sharedVisits.clear();for(let[t,r]of Object.entries(e.sharedVisits??{}))this.host.sharedVisits.set(t,r);this.host.sharedSelectors.clear();for(let[t,r]of ce(e.sharedSelectors))this.host.sharedSelectors.set(t,r);this.host.stageBags.clear();for(let[t,r]of Object.entries(e.stageBags??{}))this.host.stageBags.set(t,{...r});this.flowsById.clear();for(let[t,r]of Object.entries(e.flows)){let s=new b(t,this.host,this.defaultSeed);s.restore(r),this.flowsById.set(t,s)}}},b=class{id;host;local;rngState;started=!1;flowEnded=!1;closed=!1;currentSceneId=null;stack=[];activeSnippet=null;beatIndex=0;pendingChoice=null;pendingPromptBeat=null;pendingPromptOwnerId=null;selectors=new Map;visitCounts=new Map;sceneBags=new Map;patterResolver={get:e=>this.host.patterSharedNames.has(e)?this.host.shared.get("patter",e):this.local.get("patter",e),set:(e,t)=>{this.host.patterSharedNames.has(e)?this.host.shared.set("patter",e,t):this.local.set("patter",e,t)}};sceneResolver={get:e=>{let t=this.currentSceneId;return t===null?void 0:(this.host.sceneSharedNames.get(t)?.has(e)?this.host.stageBags.get(t):this.sceneBags.get(t))?.[e]},set:(e,t)=>{let r=this.currentSceneId;if(r===null)return;let s=this.host.sceneSharedNames.get(r)?.has(e)?this.host.stageBags.get(r):this.sceneBags.get(r);s&&(s[e]=t)}};evalCtx;constructor(e,t,r){this.id=e,this.host=t,this.rngState=r>>>0,this.local=this.freshLocal();let s={...t.shared.toEvalContext().scopes};s.patter=this.patterResolver,s.scene=this.sceneResolver,this.evalCtx={scopes:s,host:{nextRandom:this.rng,visits:i=>this.visitCounts.get(i)??0,patterVisits:i=>this.host.sharedVisits.get(i)??0}}}start(e,t){if(this.sceneBags.clear(),this.local=this.freshLocal(),this.selectors.clear(),this.visitCounts.clear(),this.stack=[],this.currentSceneId=null,this.flowEnded=!1,this.activeSnippet=null,this.beatIndex=0,this.pendingChoice=null,this.started=!0,t){let r=this.host.blockIndex.get(t);if(!r)throw new Error(`unknown block: ${t}`);this.enterSceneSetup(r.sceneId),this.stack=[{sceneId:r.sceneId,containerId:t,index:0}],this.enter(t)}else{let r=e??Object.keys(this.host.bundle.scenes)[0],s=r?this.host.bundle.scenes[r]:void 0;if(!s)throw new Error(r?`unknown scene: ${r}`:"no scenes in bundle");this.enterSceneSetup(r);let i=s.blocks[0];i&&(this.stack=[{sceneId:r,containerId:i.id,index:0}],this.enter(i.id))}this.settle()}reset(e,t){this.start(e,t)}goto(e,t){if(this.closed)return!1;if(e==="END")return this.started=!0,this.pendingChoice=null,this.pendingPromptBeat=null,this.pendingPromptOwnerId=null,this.activeSnippet=null,this.beatIndex=0,this.flowEnded=!0,this.stack=[],!0;let r=this.host.sceneGameIdToId.get(e)??(this.host.bundle.scenes[e]?e:void 0);if(r===void 0)return!1;let s;return t!==void 0&&(s=this.host.blockGameIdToId.get(r)?.get(t)??(this.host.blockIndex.get(t)?.sceneId===r?t:void 0),s===void 0)?!1:this.started?(this.pendingChoice=null,this.pendingPromptBeat=null,this.pendingPromptOwnerId=null,this.activeSnippet=null,this.beatIndex=0,this.flowEnded=!1,this.enterTarget(s??r,"jump"),this.settle(),!0):(this.start(r,s),!0)}close(){this.closed=!0,this.flowEnded=!0,this.stack=[],this.activeSnippet=null,this.beatIndex=0,this.pendingChoice=null,this.pendingPromptBeat=null,this.pendingPromptOwnerId=null}get isClosed(){return this.closed}get currentScene(){return this.currentSceneId}advance(){if(this.closed)return{type:"end"};if(!this.started)throw new Error("flow has not been started");if(this.pendingPromptBeat){let e=this.pendingPromptBeat;return this.pendingPromptBeat=null,this.pendingPromptOwnerId=null,this.beatResult(e)}return this.settle(),this.flowEnded?{type:"end"}:this.pendingChoice?{type:"choice",groupId:this.pendingChoice.groupId,options:this.pendingChoice.options}:this.activeSnippet?this.beatResult(this.activeSnippet.beats[this.beatIndex++]):(this.flowEnded=!0,{type:"end"})}advanceToStop(){let e=[];for(;;){let t=this.advance();if(t.type==="choice"||t.type==="end")return{played:e,stop:t};e.push(t)}}settle(){let e=0;for(;;){if(++e>1e4)throw new Error("flow did not settle after 10000 transitions - likely a jump cycle with no deliverable content");if(this.flowEnded||this.pendingChoice)return;if(this.activeSnippet){if(this.beatIndex<(this.activeSnippet.beats?.length??0))return;this.runEffects(this.activeSnippet.onExit);let s=this.activeSnippet.jump;this.activeSnippet=null,this.beatIndex=0,this.resolveJump(s);continue}let t=this.stack[this.stack.length-1];if(!t){this.flowEnded=!0;return}t.sceneId!==this.currentSceneId&&(this.currentSceneId=t.sceneId);let r=this.childrenOf(t.containerId);if(!r){this.stack.pop();continue}for(;t.index<r.length&&!this.eligible(r[t.index]);)t.index++;if(t.index>=r.length){this.stack.pop();continue}this.enterChild(r[t.index++])}}getChoices(){return this.pendingChoice?.options??[]}choose(e){let t=this.pendingChoice;if(!t)throw new Error("no choice is pending");let r=t.options.find(i=>i.id===e);if(!r)throw new Error(`unknown choice option: ${e}`);if(!r.eligible)throw new Error(`choice option is not eligible: ${e}`);let s=t.byId.get(e);this.pendingChoice=null,this.pendingPromptBeat=this.host.replayPromptOnChoose?this.promptBeatOf(s)??null:null,this.pendingPromptOwnerId=this.pendingPromptBeat?s.id:null,this.enterChild(s)}isEnded(){return this.flowEnded}getProperty(e){let{scope:t,name:r}=this.splitRef(e);return t==="patter"?this.patterResolver.get(r):t==="scene"?this.sceneResolver.get(r):this.host.shared.get(t,r)}setProperty(e,t){let{scope:r,name:s}=this.splitRef(e);if(r==="patter")this.patterResolver.set(s,t);else if(r==="scene"){if(this.currentSceneId===null)throw new Error(`\'${e}\': the flow has not entered a scene yet`);this.sceneResolver.set(s,t)}else this.host.shared.set(r,s,t)}snapshot(){return{scopes:this.local.save(),sceneBags:Object.fromEntries([...this.sceneBags].map(([e,t])=>[e,{...t}])),rngState:this.rngState,visits:Object.fromEntries(this.visitCounts),cursor:{flowEnded:this.flowEnded,currentSceneId:this.currentSceneId,stack:this.stack.map(e=>{let t=this.childrenOf(e.containerId)?.[e.index];return t?{...e,nextId:t.id}:{...e}}),activeSnippetId:this.activeSnippet?.id??null,beatIndex:this.beatIndex,pendingChoice:this.pendingChoice?{groupId:this.pendingChoice.groupId,options:this.pendingChoice.options.map(e=>({...e}))}:null,pendingPromptOwnerId:this.pendingPromptOwnerId,selectors:ae(this.selectors)}}}restore(e){this.rngState=e.rngState>>>0,this.visitCounts=new Map(Object.entries(e.visits??{}));let t=e.cursor;if(this.started=!0,this.flowEnded=t.flowEnded,this.beatIndex=t.beatIndex,this.currentSceneId=t.currentSceneId,this.stack=t.stack.map(r=>{let{nextId:s,...i}=r;if(s!==void 0){let o=this.childrenOf(i.containerId)?.findIndex(a=>a.id===s)??-1;if(o>=0)return{...i,index:o}}return{...i}}),this.sceneBags=new Map(Object.entries(e.sceneBags??{}).map(([r,s])=>[r,{...s}])),this.local=this.freshLocal(),this.local.load(e.scopes),this.activeSnippet=null,t.activeSnippetId!==null){let r=this.host.nodeIndex.get(t.activeSnippetId);r&&r.type==="snippet"&&(this.activeSnippet=r)}if(this.selectors=ce(t.selectors),this.pendingChoice=null,t.pendingChoice!==null){let r=new Map,s=[];for(let i of t.pendingChoice.options){let o=this.host.nodeIndex.get(i.id);o&&(r.set(i.id,o),s.push({...i}))}s.length>0&&(this.pendingChoice={groupId:t.pendingChoice.groupId,options:s,byId:r})}if(this.pendingPromptBeat=null,this.pendingPromptOwnerId=t.pendingPromptOwnerId??null,this.pendingPromptOwnerId){let r=this.host.nodeIndex.get(this.pendingPromptOwnerId);this.pendingPromptBeat=r?this.promptBeatOf(r)??null:null,this.pendingPromptBeat||(this.pendingPromptOwnerId=null)}}enterSceneSetup(e){let t=this.host.bundle.scenes[e];if(!t)throw new Error(`unknown scene: ${e}`);this.currentSceneId=e,this.enter(e),this.seedScene(t),this.runEffects(t.onEntry)}enterChild(e){if(this.enter(e.id),e.type==="snippet"){this.beginSnippet(e);return}let t=e.selector??"run";if(t==="run"){this.stack.push({sceneId:this.currentSceneId,containerId:e.id,index:0});return}if(t==="choice"){this.setupChoice(e);return}let r=this.selectChild(e);r&&this.enterChild(r)}childrenOf(e){let t=this.host.blockById.get(e);if(t)return t.children;let r=this.host.nodeIndex.get(e);if(r&&r.type==="group")return r.children}beginSnippet(e){this.runEffects(e.onEnter),this.activeSnippet=e,this.beatIndex=0}setupChoice(e){let t=[],r=new Map,s=[];for(let o of e.children){if(o.fallback===!0){s.push(o);continue}if(o.sticky!==!0&&(this.visitCounts.get(o.id)??0)>=1)continue;let a=this.eligible(o),c=o.secretUntilEligible===!0;!a&&c||(t.push({id:o.id,prompt:this.promptFor(o),eligible:a,gameData:o.gameData}),r.set(o.id,o))}if(t.length>0){this.pendingChoice={groupId:e.id,options:t,byId:r};return}let i=s.find(o=>this.eligible(o));if(i){this.enterChild(i);return}this.host.onDryChoice?.(e.id)}resolveJump(e){e&&this.enterTarget(e.to,e.mode==="call"?"call":"jump")}enterTarget(e,t){if(e==="END"){this.flowEnded=!0,this.stack=[];return}let r,s,i=this.host.bundle.scenes[e];if(i){this.enterSceneSetup(e);let a=i.blocks[0];if(!a){t==="jump"&&(this.stack=[]);return}r=e,s=a.id}else{let a=this.host.blockIndex.get(e);if(!a)throw new Error(`jump target not found: ${e}`);a.sceneId!==this.currentSceneId&&this.enterSceneSetup(a.sceneId),r=a.sceneId,s=e}this.enter(s);let o={sceneId:r,containerId:s,index:0};t==="call"?this.stack.push(o):this.stack=[o]}selectChild(e){let t=e.children.filter(s=>this.eligible(s));if(t.length===0)return null;let r=this.selectorState(e);switch(e.selector){case"branch":return t[0];case"sequence":{let s=e.options?.order??"sequential",i=e.options?.exhaust??"once";return s==="shuffle"?this.pickShuffle(t,i,r):s==="specificity"?this.pickSpecificity(t,i,r):this.pickSequential(t,i,r)}default:return null}}pickSequential(e,t,r){let s=e.length,i=r.seq??0;return r.seq=i+1,t==="repeat"?e[i%s]:i<s?e[i]:t==="stick"?e[s-1]:null}pickShuffle(e,t,r){let s=e.length,i=t==="stick",o=()=>(i?e.slice(0,s-1):e).map(h=>h.id);if(r.bag===void 0&&(r.bag=o()),r.bag.length===0){if(t==="once")return null;if(i){let h=e[s-1];return r.last=h.id,h}r.bag=o()}let a=r.bag,c=r.last!==void 0&&a.length>1?a.indexOf(r.last):-1,l=Math.floor(this.rng()*(c>=0?a.length-1:a.length));c>=0&&l>=c&&l++;let u=a[l];return a.splice(l,1),r.last=u,e.find(h=>h.id===u)}pickSpecificity(e,t,r){let s=e;if(t!=="repeat"){r.bag===void 0&&(r.bag=e.map(u=>u.id));let l=new Set(r.bag);if(s=e.filter(u=>l.has(u.id)),s.length===0)return t==="stick"&&r.last!==void 0?e.find(u=>u.id===r.last)??null:null}let i=-1,a=s.map(l=>{let u=this.specScore(l);return u>i&&(i=u),{c:l,s:u}}).filter(l=>l.s===i).map(l=>l.c),c;if(a.length===1)c=a[0];else{let l=r.last!==void 0?a.findIndex(h=>h.id===r.last):-1,u=Math.floor(this.rng()*(l>=0?a.length-1:a.length));l>=0&&u>=l&&u++,c=a[u]}return t!=="repeat"&&(r.bag=r.bag.filter(l=>l!==c.id)),r.last=c.id,c}specScore(e){return e.condition?this.matchedSpec(this.conditionAst(e.condition),!0):0}matchedSpec(e,t){return z(e,s=>oe(C(s,this.evalCtx,T)),{want:t})}selectorState(e){let t=e.shared?this.host.sharedSelectors:this.selectors,r=t.get(e.id);return r||(r={},t.set(e.id,r)),r}runEffects(e){for(let t of e??[])this.setProperty(t.target,this.evalExpr(t.value))}eligible(e){return e.condition?oe(this.evalExpr(e.condition)):!0}evalExpr(e){return C(this.conditionAst(e),this.evalCtx,T)}conditionAst(e){let t=ne.get(e);return t||(t=S(e.ast),ne.set(e,t)),t}enter(e){this.visitCounts.set(e,(this.visitCounts.get(e)??0)+1),this.host.sharedVisits.set(e,(this.host.sharedVisits.get(e)??0)+1)}rng=()=>{if(this.host.customRng)return this.host.customRng();let e=this.rngState+1831565813|0;this.rngState=e;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296};beatResult(e){let t=this.host.tagIndex.get(e.id),r=t&&t.length?{tags:t}:{};switch(e.kind){case"gameEvent":return{type:"gameEvent",id:e.id,gameData:e.gameData,...r};case"text":return{type:"text",id:e.id,text:this.interpolate(this.resolveString(e.id)),gameData:e.gameData,...r};case"line":{let s=this.resolveString(e.id),i=!this.host.captionsOn,a=i&&e.character===this.host.captionCharacter?"":this.captionLine(this.host.bundle.voiced?s:this.interpolate(s)),c=i&&a.length===0;return{type:"line",id:e.id,text:a,character:c?void 0:e.character,characterName:c?void 0:this.resolveCharacterName(e.character),direction:c?void 0:e.direction,gameData:e.gameData,...r}}}}interpolate(e){return te(e,t=>this.getProperty(t))}stripCaptions(e){return ee(e,this.host.captionOpen,this.host.captionClose)}captionLine(e){return this.host.captionsOn?e:this.stripCaptions(e)}promptFor(e){let t=this.promptBeatOf(e);if(!t)return;let r=this.interpolate(this.resolveString(t.id));return t.kind==="line"?{kind:"line",text:this.captionLine(r),character:t.character,characterName:this.resolveCharacterName(t.character),direction:t.direction}:{kind:"text",text:r}}promptBeatOf(e){return e.type==="group"&&e.prompt?e.prompt:((e.type==="snippet"?e:this.firstTextSnippetIn(e.children))?.beats??[]).find(r=>r.kind==="line"||r.kind==="text")}firstTextSnippetIn(e){let t;return k(e,r=>{!t&&r.type==="snippet"&&(r.beats??[]).some(s=>s.kind==="line"||s.kind==="text")&&(t=r)}),t}resolveString(e){if(this.host.emitIds)return e;let t=this.host.strings[e];if(t!==void 0)return t;let r=this.host.defaultStrings[e];return r!==void 0?`<Untranslated: ${e}> ${r}`:e}resolveCharacterName(e){if(e===void 0||this.host.emitIds)return;let t=M(e);return this.host.strings[t]??this.host.defaultStrings[t]??this.host.castDisplay.get(e)}splitRef(e){let t=this.host.refSplitCache.get(e);return t||(t=V(e,r=>r==="scene"||this.host.shared.has(r)),this.host.refSplitCache.set(e,t)),t}freshLocal(){return new w().defineOwned("patter",this.host.patterLocalDecls)}seedScene(e){let t=this.host.sceneSharedNames.get(e.id)??new Set;if(!this.sceneBags.has(e.id)){let r={};for(let s of e.sceneProps??[]){let i=s.name.toLowerCase();t.has(i)||(r[i]=L(s))}this.sceneBags.set(e.id,r)}if(!this.host.stageBags.has(e.id)){let r={};for(let s of e.sceneProps??[]){let i=s.name.toLowerCase();t.has(i)&&(r[i]=L(s))}this.host.stageBags.set(e.id,r)}for(let r of e.sceneProps??[]){if(!r.temporary)continue;let s=r.name.toLowerCase(),i=t.has(s)?this.host.stageBags.get(e.id):this.sceneBags.get(e.id);i&&(i[s]=L(r))}}};function ae(n){let e={};for(let[t,r]of n){let s={};r.seq!==void 0&&(s.seq=r.seq),r.bag&&(s.bag=[...r.bag]),r.last!==void 0&&(s.last=r.last),e[t]=s}return e}function ce(n){let e=new Map;for(let[t,r]of Object.entries(n??{})){let s={};r.seq!==void 0&&(s.seq=r.seq),r.bag&&(s.bag=[...r.bag]),r.last!==void 0&&(s.last=r.last),e.set(t,s)}return e}function se(n){return{name:n.name,type:n.type,values:n.values,default:n.default}}function Re(n){if(n.default!==void 0)return n.default;switch(n.type){case"number":return 0;case"string":return"";case"flags":return[];case"enum":return n.values?.[0]??"";default:return!1}}function ie(n){return{name:n.name,type:n.type,values:n.values,default:n.default,writable:n.writable}}function Be(n){if(n.default!==void 0)return n.default;switch(n.type){case"boolean":return!1;case"number":return 0;case"string":return"";case"flags":return[];case"enum":return n.values?.[0]??""}}function Oe(n){let e=r=>r.toLowerCase(),t=new Map;for(let r of n)t.set(e(r.name),Be(r));return{get:r=>t.get(e(r)),set:(r,s)=>{t.set(e(r),s)}}}function L(n){if(n.default!==void 0)return n.default;switch(n.type){case"boolean":return!1;case"number":return 0;case"string":return"";case"flags":return[];case"enum":return n.values?.[0]??""}}function oe(n){return typeof n=="boolean"?n:typeof n=="number"?n!==0:typeof n=="string"?n!=="":n.length>0}var Pe=(n,e)=>n.shared??e;function $(n,e){return{name:n.name,type:n.type,hasDefault:n.default!==void 0,...n.default!==void 0?{default:n.default}:{},shared:Pe(n,e)}}function Ne(n){return{name:n.name,type:n.type,hasDefault:n.default!==void 0,...n.values?{values:[...n.values]}:{},...n.purpose?{purpose:n.purpose}:{}}}function Ae(n,e){e.blocks++;let t=[...n.children];for(;t.length;){let r=t.pop();if(r.type==="group"){e.groups++,r.prompt&&e.prompts++,t.push(...r.children);continue}e.snippets++;for(let s of r.beats??[])e.beats++,s.kind==="gameEvent"&&e.gameEvents++}}function le(n){let e={scenes:0,blocks:0,groups:0,snippets:0,beats:0,prompts:0,gameEvents:0,cast:n.cast?.length??0},t=[],r=[];for(let o of Object.values(n.scenes)){e.scenes++;let a=g(o);t.push({gameId:a,name:o.name,blocks:o.blocks.map(c=>({gameId:g(c),name:c.name}))});for(let c of o.blocks)Ae(c,e);o.sceneProps?.length&&r.push({gameId:a,properties:o.sceneProps.map(c=>$(c,!1))})}let s=(n.scopeRegistry?.scopes??[]).map(o=>({token:o.token,writable:o.writable??!0,opaque:o.declarations===void 0,properties:(o.declarations??[]).map(a=>$(a,!0))})),i=Object.entries(n.gameDataFields??{}).filter(([,o])=>(o?.length??0)>0).map(([o,a])=>({kind:o,fields:(a??[]).map(Ne)}));return{identity:{schema:n.schema,project:n.content.project,...n.content.version!==void 0?{version:n.content.version}:{},...n.content.hash!==void 0?{hash:n.content.hash}:{},...n.content.structureHash!==void 0?{structureHash:n.content.structureHash}:{},voiced:n.voiced,defaultLocale:n.locales.default,locales:[...n.locales.included],localisation:n.localisation?.mode??"embedded",sourceDebug:n.localisation?.sourceDebug??!1},addresses:t,hostScopes:s,properties:{patter:(n.properties??[]).map(o=>$(o,!0)),scene:r},gameData:i,counts:e}}function pe(n,e){return n.gameDataFields?.[e]??[]}function _(n,e,t){return e&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:n.find(r=>r.name===t)?.default}function de(n,e){let t={};for(let r of n){let s=_(n,e,r.name);s!==void 0&&(t[r.name]=s)}for(let[r,s]of Object.entries(e??{}))r in t||(t[r]=s);return t}return ve(Fe);})();\n//# sourceMappingURL=patterplay.min.js.map';
|
|
194032
194203
|
|
|
194033
194204
|
// ../ops/src/export-html.ts
|
|
194034
194205
|
var esc = (s) => s.replace(/[&<>]/g, (c2) => ({ "&": "&", "<": "<", ">": ">" })[c2]);
|
|
@@ -194265,6 +194436,106 @@ function walk(node, want, evalTruthy, countingCalls) {
|
|
|
194265
194436
|
}
|
|
194266
194437
|
|
|
194267
194438
|
// ../../../expr/packages/scoperegistry/src/index.ts
|
|
194439
|
+
var PropertyBag = class _PropertyBag {
|
|
194440
|
+
/** The live values record (stable identity across reseed, so an
|
|
194441
|
+
* EvalContext built over it stays valid). Read-path for evaluation;
|
|
194442
|
+
* writes go through `set` so the firing rule applies. */
|
|
194443
|
+
values = {};
|
|
194444
|
+
decls = /* @__PURE__ */ new Map();
|
|
194445
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
194446
|
+
auditors = /* @__PURE__ */ new Set();
|
|
194447
|
+
/** Name normalisation policy: lowercase by default (the registry's
|
|
194448
|
+
* long-standing contract); a product whose names are case-significant
|
|
194449
|
+
* passes identity. */
|
|
194450
|
+
norm;
|
|
194451
|
+
constructor(declarations = [], opts) {
|
|
194452
|
+
this.norm = opts?.normalise ?? ((n) => n.toLowerCase());
|
|
194453
|
+
this.seed(declarations);
|
|
194454
|
+
}
|
|
194455
|
+
seed(declarations) {
|
|
194456
|
+
for (const d of declarations) {
|
|
194457
|
+
const name = this.norm(d.name);
|
|
194458
|
+
this.decls.set(name, d);
|
|
194459
|
+
this.values[name] = structuredClone(d.default ?? defaultFor(d));
|
|
194460
|
+
}
|
|
194461
|
+
}
|
|
194462
|
+
get(name) {
|
|
194463
|
+
return this.values[this.norm(name)];
|
|
194464
|
+
}
|
|
194465
|
+
/** Write a property. Engine writes (the default) notify subscribers;
|
|
194466
|
+
* pass `silent: true` for a host write, which reaches only the audit
|
|
194467
|
+
* hook. Throws on a read-only property. Returns the change. */
|
|
194468
|
+
set(name, value, opts) {
|
|
194469
|
+
const n = this.norm(name);
|
|
194470
|
+
if (this.decls.get(n)?.writable === false) throw new Error(`'${name}' is read-only`);
|
|
194471
|
+
const change = {
|
|
194472
|
+
name: n,
|
|
194473
|
+
prev: this.values[n],
|
|
194474
|
+
next: value,
|
|
194475
|
+
silent: opts?.silent ?? false,
|
|
194476
|
+
reason: opts?.reason
|
|
194477
|
+
};
|
|
194478
|
+
this.values[n] = value;
|
|
194479
|
+
for (const audit of this.auditors) audit(change);
|
|
194480
|
+
if (!change.silent) for (const fn of this.subscribers) fn(change);
|
|
194481
|
+
return change;
|
|
194482
|
+
}
|
|
194483
|
+
/** Notified of engine (non-silent) writes. Returns the unsubscribe. */
|
|
194484
|
+
subscribe(fn) {
|
|
194485
|
+
this.subscribers.add(fn);
|
|
194486
|
+
return () => this.subscribers.delete(fn);
|
|
194487
|
+
}
|
|
194488
|
+
/** Notified of EVERY write, silent or not. Returns the unsubscribe. */
|
|
194489
|
+
onAudit(fn) {
|
|
194490
|
+
this.auditors.add(fn);
|
|
194491
|
+
return () => this.auditors.delete(fn);
|
|
194492
|
+
}
|
|
194493
|
+
/** Examiner rows: the declared surface only (stray values are storage,
|
|
194494
|
+
* not surface). */
|
|
194495
|
+
rows() {
|
|
194496
|
+
return [...this.decls.entries()].map(([name, d]) => rowFor(d, this.get(name), void 0, name));
|
|
194497
|
+
}
|
|
194498
|
+
declarations() {
|
|
194499
|
+
return [...this.decls.values()];
|
|
194500
|
+
}
|
|
194501
|
+
/** The one sanctioned copy door: values deep-copied, declarations
|
|
194502
|
+
* duplicated, the normalisation policy carried, subscriptions NOT
|
|
194503
|
+
* carried. */
|
|
194504
|
+
clone() {
|
|
194505
|
+
const c2 = new _PropertyBag([], { normalise: this.norm });
|
|
194506
|
+
c2.decls = new Map(this.decls);
|
|
194507
|
+
Object.assign(c2.values, structuredClone(this.values));
|
|
194508
|
+
return c2;
|
|
194509
|
+
}
|
|
194510
|
+
/** Clear and re-seed from new declarations, in place (the values record
|
|
194511
|
+
* keeps its identity, so contexts built over it stay valid). */
|
|
194512
|
+
reseed(declarations) {
|
|
194513
|
+
for (const k of Object.keys(this.values)) delete this.values[k];
|
|
194514
|
+
this.decls.clear();
|
|
194515
|
+
this.seed(declarations);
|
|
194516
|
+
}
|
|
194517
|
+
/** Bare values, ready to embed in a product's save. */
|
|
194518
|
+
save() {
|
|
194519
|
+
return structuredClone(this.values);
|
|
194520
|
+
}
|
|
194521
|
+
/** Lay saved values over the current ones (call after a fresh seed:
|
|
194522
|
+
* orphans land as strays, new declarations keep their defaults; the
|
|
194523
|
+
* product decides whether to prune). Does not fire events. */
|
|
194524
|
+
load(values) {
|
|
194525
|
+
for (const [k, v] of Object.entries(values)) this.values[this.norm(k)] = v;
|
|
194526
|
+
}
|
|
194527
|
+
};
|
|
194528
|
+
function rowFor(d, value, writable, name) {
|
|
194529
|
+
return {
|
|
194530
|
+
name: name ?? d.name.toLowerCase(),
|
|
194531
|
+
type: d.type,
|
|
194532
|
+
value,
|
|
194533
|
+
default: d.default ?? defaultFor(d),
|
|
194534
|
+
...d.values !== void 0 ? { values: d.values } : {},
|
|
194535
|
+
writable: writable ?? d.writable ?? true
|
|
194536
|
+
};
|
|
194537
|
+
}
|
|
194538
|
+
var SAVE_FRAGMENT_VERSION = 1;
|
|
194268
194539
|
var ScopeRegistry = class {
|
|
194269
194540
|
scopes = /* @__PURE__ */ new Map();
|
|
194270
194541
|
/**
|
|
@@ -194273,17 +194544,24 @@ var ScopeRegistry = class {
|
|
|
194273
194544
|
* type-checked (declarations) and serialized by `save`/`load`.
|
|
194274
194545
|
*/
|
|
194275
194546
|
defineOwned(token2, declarations) {
|
|
194547
|
+
return this.mountOwned(token2, new PropertyBag(declarations));
|
|
194548
|
+
}
|
|
194549
|
+
/**
|
|
194550
|
+
* Attach an EXISTING bag as an owned scope - the shared-container move: a
|
|
194551
|
+
* host (or the other product) holds the bag; this registry reads, writes
|
|
194552
|
+
* and lists it like its own, but the holder saves it.
|
|
194553
|
+
*/
|
|
194554
|
+
mountOwned(token2, bag) {
|
|
194276
194555
|
this.assertFree(token2);
|
|
194277
|
-
|
|
194278
|
-
const decls = /* @__PURE__ */ new Map();
|
|
194279
|
-
for (const d of declarations) {
|
|
194280
|
-
const name = d.name.toLowerCase();
|
|
194281
|
-
decls.set(name, d);
|
|
194282
|
-
bag[name] = d.default ?? defaultFor(d);
|
|
194283
|
-
}
|
|
194284
|
-
this.scopes.set(token2, { kind: "owned", bag, decls });
|
|
194556
|
+
this.scopes.set(token2, { kind: "owned", bag });
|
|
194285
194557
|
return this;
|
|
194286
194558
|
}
|
|
194559
|
+
/** An owned scope's bag (subscribe, audit, rows live there). */
|
|
194560
|
+
ownedBag(token2) {
|
|
194561
|
+
const e = this.scopes.get(token2);
|
|
194562
|
+
if (!e || e.kind !== "owned") throw new Error(`'@${token2}' is not an owned scope`);
|
|
194563
|
+
return e.bag;
|
|
194564
|
+
}
|
|
194287
194565
|
/**
|
|
194288
194566
|
* Re-initialise an existing **owned** scope's bag from new declarations,
|
|
194289
194567
|
* clearing its current values. For scope-local state that resets on a context
|
|
@@ -194292,15 +194570,7 @@ var ScopeRegistry = class {
|
|
|
194292
194570
|
* registry stays valid.
|
|
194293
194571
|
*/
|
|
194294
194572
|
reseedOwned(token2, declarations) {
|
|
194295
|
-
|
|
194296
|
-
if (!e || e.kind !== "owned") throw new Error(`'@${token2}' is not an owned scope`);
|
|
194297
|
-
for (const k of Object.keys(e.bag)) delete e.bag[k];
|
|
194298
|
-
e.decls.clear();
|
|
194299
|
-
for (const d of declarations) {
|
|
194300
|
-
const name = d.name.toLowerCase();
|
|
194301
|
-
e.decls.set(name, d);
|
|
194302
|
-
e.bag[name] = d.default ?? defaultFor(d);
|
|
194303
|
-
}
|
|
194573
|
+
this.ownedBag(token2).reseed(declarations);
|
|
194304
194574
|
return this;
|
|
194305
194575
|
}
|
|
194306
194576
|
/**
|
|
@@ -194323,23 +194593,49 @@ var ScopeRegistry = class {
|
|
|
194323
194593
|
get(scope, name) {
|
|
194324
194594
|
const e = this.scopes.get(scope);
|
|
194325
194595
|
if (!e) return void 0;
|
|
194326
|
-
|
|
194327
|
-
return e.kind === "owned" ? e.bag[n] : e.resolver.get(n);
|
|
194596
|
+
return e.kind === "owned" ? e.bag.get(name) : e.resolver.get(name.toLowerCase());
|
|
194328
194597
|
}
|
|
194329
|
-
/** Write a property
|
|
194598
|
+
/** Write a property (an ENGINE write: the bag's subscribers fire; use
|
|
194599
|
+
* the bag directly for silent host writes). Throws on an unknown or
|
|
194600
|
+
* read-only scope/property. */
|
|
194330
194601
|
set(scope, name, value) {
|
|
194331
194602
|
const e = this.scopes.get(scope);
|
|
194332
194603
|
if (!e) throw new Error(`unknown scope '@${scope}'`);
|
|
194604
|
+
if (e.kind === "owned") {
|
|
194605
|
+
try {
|
|
194606
|
+
e.bag.set(name, value);
|
|
194607
|
+
} catch {
|
|
194608
|
+
throw new Error(`'@${scope}.${name}' is read-only`);
|
|
194609
|
+
}
|
|
194610
|
+
return;
|
|
194611
|
+
}
|
|
194333
194612
|
const n = name.toLowerCase();
|
|
194334
|
-
if (!this.
|
|
194335
|
-
|
|
194336
|
-
else e.resolver.set(n, value);
|
|
194613
|
+
if (!this.foreignWritable(e, n)) throw new Error(`'@${scope}.${name}' is read-only`);
|
|
194614
|
+
e.resolver.set(n, value);
|
|
194337
194615
|
}
|
|
194338
|
-
|
|
194339
|
-
if (e.kind === "owned") return e.decls.get(name)?.writable ?? true;
|
|
194616
|
+
foreignWritable(e, name) {
|
|
194340
194617
|
if (!e.resolver.set) return false;
|
|
194341
194618
|
return e.decls.get(name)?.writable ?? e.scopeWritable;
|
|
194342
194619
|
}
|
|
194620
|
+
/** Examiner rows across every scope with a declared surface: owned bags
|
|
194621
|
+
* first, then declared foreign scopes (values read through, writability
|
|
194622
|
+
* reflecting the resolver). Opaque foreign scopes are not listed. */
|
|
194623
|
+
listProperties() {
|
|
194624
|
+
const out = [];
|
|
194625
|
+
for (const [token2, e] of this.scopes) {
|
|
194626
|
+
if (e.kind === "owned") {
|
|
194627
|
+
for (const row of e.bag.rows()) out.push({ scope: token2, ...row });
|
|
194628
|
+
} else {
|
|
194629
|
+
for (const d of e.decls.values()) {
|
|
194630
|
+
out.push({
|
|
194631
|
+
scope: token2,
|
|
194632
|
+
...rowFor(d, e.resolver.get(d.name.toLowerCase()), this.foreignWritable(e, d.name.toLowerCase()))
|
|
194633
|
+
});
|
|
194634
|
+
}
|
|
194635
|
+
}
|
|
194636
|
+
}
|
|
194637
|
+
return out;
|
|
194638
|
+
}
|
|
194343
194639
|
/**
|
|
194344
194640
|
* Build the `EvalContext` expr's `evaluate` consumes: owned scopes as static
|
|
194345
194641
|
* bags, foreign scopes as their resolvers. `host` carries dialect-function
|
|
@@ -194348,7 +194644,7 @@ var ScopeRegistry = class {
|
|
|
194348
194644
|
toEvalContext(host2) {
|
|
194349
194645
|
const scopes = {};
|
|
194350
194646
|
for (const [token2, e] of this.scopes) {
|
|
194351
|
-
scopes[token2] = e.kind === "owned" ? e.bag : e.resolver;
|
|
194647
|
+
scopes[token2] = e.kind === "owned" ? e.bag.values : e.resolver;
|
|
194352
194648
|
}
|
|
194353
194649
|
return { scopes, host: host2 };
|
|
194354
194650
|
}
|
|
@@ -194360,25 +194656,43 @@ var ScopeRegistry = class {
|
|
|
194360
194656
|
toSchema() {
|
|
194361
194657
|
const properties = /* @__PURE__ */ new Map();
|
|
194362
194658
|
for (const [token2, e] of this.scopes) {
|
|
194363
|
-
|
|
194659
|
+
const decls = e.kind === "owned" ? e.bag.declarations() : [...e.decls.values()];
|
|
194660
|
+
if (decls.length === 0) continue;
|
|
194364
194661
|
const m = /* @__PURE__ */ new Map();
|
|
194365
|
-
for (const
|
|
194662
|
+
for (const d of decls) m.set(d.name.toLowerCase(), { type: d.type, enumValues: d.values });
|
|
194366
194663
|
properties.set(token2, m);
|
|
194367
194664
|
}
|
|
194368
194665
|
return { properties };
|
|
194369
194666
|
}
|
|
194370
|
-
/** Serialize **owned** scopes only (foreign scopes are host-owned,
|
|
194667
|
+
/** Serialize **owned** scopes only (foreign scopes are host-owned,
|
|
194668
|
+
* host-saved), as bare bags - the 0.1.x shape, kept stable so existing
|
|
194669
|
+
* consumers' save formats are untouched. A product embedding the
|
|
194670
|
+
* versioned cross-product shape uses `saveFragment`. */
|
|
194371
194671
|
save() {
|
|
194372
194672
|
const out = {};
|
|
194373
|
-
for (const [token2, e] of this.scopes) if (e.kind === "owned") out[token2] =
|
|
194673
|
+
for (const [token2, e] of this.scopes) if (e.kind === "owned") out[token2] = e.bag.save();
|
|
194374
194674
|
return out;
|
|
194375
194675
|
}
|
|
194376
|
-
/** Restore owned-scope values from a `save` blob. Unknown/foreign scopes
|
|
194676
|
+
/** Restore owned-scope values from a `save` blob. Unknown/foreign scopes
|
|
194677
|
+
* are ignored. */
|
|
194377
194678
|
load(blob) {
|
|
194378
194679
|
for (const [token2, vals] of Object.entries(blob)) {
|
|
194379
194680
|
const e = this.scopes.get(token2);
|
|
194380
|
-
if (e?.kind === "owned")
|
|
194681
|
+
if (e?.kind === "owned") e.bag.load(vals);
|
|
194682
|
+
}
|
|
194683
|
+
}
|
|
194684
|
+
/** The versioned owned-state fragment (the one serialisation shape both
|
|
194685
|
+
* product families' save envelopes embed when they adopt the kernel;
|
|
194686
|
+
* design/engine-runtimes.md 3.1). `save()` wrapped with a version stamp. */
|
|
194687
|
+
saveFragment() {
|
|
194688
|
+
return { version: SAVE_FRAGMENT_VERSION, scopes: this.save() };
|
|
194689
|
+
}
|
|
194690
|
+
/** Restore from a versioned fragment; an unsupported version throws. */
|
|
194691
|
+
loadFragment(fragment) {
|
|
194692
|
+
if (fragment.version !== SAVE_FRAGMENT_VERSION) {
|
|
194693
|
+
throw new Error(`unsupported owned-state fragment version ${fragment.version} (supported: ${SAVE_FRAGMENT_VERSION})`);
|
|
194381
194694
|
}
|
|
194695
|
+
this.load(fragment.scopes);
|
|
194382
194696
|
}
|
|
194383
194697
|
assertFree(token2) {
|
|
194384
194698
|
if (this.scopes.has(token2)) throw new Error(`scope '@${token2}' is already registered`);
|
|
@@ -195775,12 +196089,13 @@ function hostScopeDefault(decl) {
|
|
|
195775
196089
|
}
|
|
195776
196090
|
}
|
|
195777
196091
|
function selfBackedResolver(decls) {
|
|
196092
|
+
const key2 = (name) => name.toLowerCase();
|
|
195778
196093
|
const bag = /* @__PURE__ */ new Map();
|
|
195779
|
-
for (const d of decls) bag.set(d.name, hostScopeDefault(d));
|
|
196094
|
+
for (const d of decls) bag.set(key2(d.name), hostScopeDefault(d));
|
|
195780
196095
|
return {
|
|
195781
|
-
get: (name) => bag.get(name),
|
|
196096
|
+
get: (name) => bag.get(key2(name)),
|
|
195782
196097
|
set: (name, value) => {
|
|
195783
|
-
bag.set(name, value);
|
|
196098
|
+
bag.set(key2(name), value);
|
|
195784
196099
|
}
|
|
195785
196100
|
};
|
|
195786
196101
|
}
|
|
@@ -196026,8 +196341,9 @@ function sortValues(values) {
|
|
|
196026
196341
|
return String(a).localeCompare(String(b));
|
|
196027
196342
|
});
|
|
196028
196343
|
}
|
|
196029
|
-
|
|
196030
|
-
|
|
196344
|
+
var DEFAULT_RUNS = 5e3;
|
|
196345
|
+
function* sweep(loaded, options = {}, hooks = {}) {
|
|
196346
|
+
const runs = options.runs ?? DEFAULT_RUNS;
|
|
196031
196347
|
const maxSteps = options.maxSteps ?? 200;
|
|
196032
196348
|
const seed = options.seed ?? 0;
|
|
196033
196349
|
const start = resolveStart(loaded, options);
|
|
@@ -196118,6 +196434,7 @@ function runCoverage(loaded, options = {}, hooks = {}) {
|
|
|
196118
196434
|
termination[term]++;
|
|
196119
196435
|
executed++;
|
|
196120
196436
|
if ((run2 & 255) === 0) hooks.onProgress?.(executed, runs);
|
|
196437
|
+
yield executed;
|
|
196121
196438
|
}
|
|
196122
196439
|
hooks.onProgress?.(executed, runs);
|
|
196123
196440
|
const unwrittenInputs = /* @__PURE__ */ new Set();
|
|
@@ -196161,6 +196478,12 @@ function runCoverage(loaded, options = {}, hooks = {}) {
|
|
|
196161
196478
|
cancelled
|
|
196162
196479
|
};
|
|
196163
196480
|
}
|
|
196481
|
+
function runCoverage(loaded, options = {}, hooks = {}) {
|
|
196482
|
+
const it = sweep(loaded, options, hooks);
|
|
196483
|
+
let step = it.next();
|
|
196484
|
+
while (!step.done) step = it.next();
|
|
196485
|
+
return step.value;
|
|
196486
|
+
}
|
|
196164
196487
|
function renderCoverageText(report, sceneName = (id) => id) {
|
|
196165
196488
|
const out = [];
|
|
196166
196489
|
const t = report.totals;
|
|
@@ -197793,14 +198116,14 @@ var require_events = /* @__PURE__ */ __commonJSMin(((exports2, module2) => {
|
|
|
197793
198116
|
return ret2;
|
|
197794
198117
|
}
|
|
197795
198118
|
function once2(emitter, name) {
|
|
197796
|
-
return new Promise(function(
|
|
198119
|
+
return new Promise(function(resolve6, reject2) {
|
|
197797
198120
|
function errorListener(err) {
|
|
197798
198121
|
emitter.removeListener(name, resolver);
|
|
197799
198122
|
reject2(err);
|
|
197800
198123
|
}
|
|
197801
198124
|
function resolver() {
|
|
197802
198125
|
if (typeof emitter.removeListener === "function") emitter.removeListener("error", errorListener);
|
|
197803
|
-
|
|
198126
|
+
resolve6([].slice.call(arguments));
|
|
197804
198127
|
}
|
|
197805
198128
|
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
|
|
197806
198129
|
if (name !== "error") addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
|
|
@@ -200702,8 +201025,8 @@ var require_util5 = /* @__PURE__ */ __commonJSMin(((exports2) => {
|
|
|
200702
201025
|
}
|
|
200703
201026
|
function fn() {
|
|
200704
201027
|
var promiseResolve, promiseReject;
|
|
200705
|
-
var promise = new Promise(function(
|
|
200706
|
-
promiseResolve =
|
|
201028
|
+
var promise = new Promise(function(resolve6, reject2) {
|
|
201029
|
+
promiseResolve = resolve6;
|
|
200707
201030
|
promiseReject = reject2;
|
|
200708
201031
|
});
|
|
200709
201032
|
var args = [];
|
|
@@ -202069,14 +202392,14 @@ var require_async_iterator2 = /* @__PURE__ */ __commonJSMin(((exports2, module2)
|
|
|
202069
202392
|
};
|
|
202070
202393
|
}
|
|
202071
202394
|
function readAndResolve(iter) {
|
|
202072
|
-
var
|
|
202073
|
-
if (
|
|
202395
|
+
var resolve6 = iter[kLastResolve];
|
|
202396
|
+
if (resolve6 !== null) {
|
|
202074
202397
|
var data = iter[kStream].read();
|
|
202075
202398
|
if (data !== null) {
|
|
202076
202399
|
iter[kLastPromise] = null;
|
|
202077
202400
|
iter[kLastResolve] = null;
|
|
202078
202401
|
iter[kLastReject] = null;
|
|
202079
|
-
|
|
202402
|
+
resolve6(createIterResult(data, false));
|
|
202080
202403
|
}
|
|
202081
202404
|
}
|
|
202082
202405
|
}
|
|
@@ -202084,13 +202407,13 @@ var require_async_iterator2 = /* @__PURE__ */ __commonJSMin(((exports2, module2)
|
|
|
202084
202407
|
process$1.nextTick(readAndResolve, iter);
|
|
202085
202408
|
}
|
|
202086
202409
|
function wrapForNext(lastPromise, iter) {
|
|
202087
|
-
return function(
|
|
202410
|
+
return function(resolve6, reject2) {
|
|
202088
202411
|
lastPromise.then(function() {
|
|
202089
202412
|
if (iter[kEnded]) {
|
|
202090
|
-
|
|
202413
|
+
resolve6(createIterResult(void 0, true));
|
|
202091
202414
|
return;
|
|
202092
202415
|
}
|
|
202093
|
-
iter[kHandlePromise](
|
|
202416
|
+
iter[kHandlePromise](resolve6, reject2);
|
|
202094
202417
|
}, reject2);
|
|
202095
202418
|
};
|
|
202096
202419
|
}
|
|
@@ -202105,10 +202428,10 @@ var require_async_iterator2 = /* @__PURE__ */ __commonJSMin(((exports2, module2)
|
|
|
202105
202428
|
var error = this[kError];
|
|
202106
202429
|
if (error !== null) return Promise.reject(error);
|
|
202107
202430
|
if (this[kEnded]) return Promise.resolve(createIterResult(void 0, true));
|
|
202108
|
-
if (this[kStream].destroyed) return new Promise(function(
|
|
202431
|
+
if (this[kStream].destroyed) return new Promise(function(resolve6, reject2) {
|
|
202109
202432
|
process$1.nextTick(function() {
|
|
202110
202433
|
if (_this[kError]) reject2(_this[kError]);
|
|
202111
|
-
else
|
|
202434
|
+
else resolve6(createIterResult(void 0, true));
|
|
202112
202435
|
});
|
|
202113
202436
|
});
|
|
202114
202437
|
var lastPromise = this[kLastPromise];
|
|
@@ -202126,13 +202449,13 @@ var require_async_iterator2 = /* @__PURE__ */ __commonJSMin(((exports2, module2)
|
|
|
202126
202449
|
return this;
|
|
202127
202450
|
}), _defineProperty2(_Object$setPrototypeO, "return", function _return() {
|
|
202128
202451
|
var _this2 = this;
|
|
202129
|
-
return new Promise(function(
|
|
202452
|
+
return new Promise(function(resolve6, reject2) {
|
|
202130
202453
|
_this2[kStream].destroy(null, function(err) {
|
|
202131
202454
|
if (err) {
|
|
202132
202455
|
reject2(err);
|
|
202133
202456
|
return;
|
|
202134
202457
|
}
|
|
202135
|
-
|
|
202458
|
+
resolve6(createIterResult(void 0, true));
|
|
202136
202459
|
});
|
|
202137
202460
|
});
|
|
202138
202461
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
@@ -202154,15 +202477,15 @@ var require_async_iterator2 = /* @__PURE__ */ __commonJSMin(((exports2, module2)
|
|
|
202154
202477
|
value: stream2._readableState.endEmitted,
|
|
202155
202478
|
writable: true
|
|
202156
202479
|
}), _defineProperty2(_Object$create, kHandlePromise, {
|
|
202157
|
-
value: function value(
|
|
202480
|
+
value: function value(resolve6, reject2) {
|
|
202158
202481
|
var data = iterator[kStream].read();
|
|
202159
202482
|
if (data) {
|
|
202160
202483
|
iterator[kLastPromise] = null;
|
|
202161
202484
|
iterator[kLastResolve] = null;
|
|
202162
202485
|
iterator[kLastReject] = null;
|
|
202163
|
-
|
|
202486
|
+
resolve6(createIterResult(data, false));
|
|
202164
202487
|
} else {
|
|
202165
|
-
iterator[kLastResolve] =
|
|
202488
|
+
iterator[kLastResolve] = resolve6;
|
|
202166
202489
|
iterator[kLastReject] = reject2;
|
|
202167
202490
|
}
|
|
202168
202491
|
},
|
|
@@ -202181,12 +202504,12 @@ var require_async_iterator2 = /* @__PURE__ */ __commonJSMin(((exports2, module2)
|
|
|
202181
202504
|
iterator[kError] = err;
|
|
202182
202505
|
return;
|
|
202183
202506
|
}
|
|
202184
|
-
var
|
|
202185
|
-
if (
|
|
202507
|
+
var resolve6 = iterator[kLastResolve];
|
|
202508
|
+
if (resolve6 !== null) {
|
|
202186
202509
|
iterator[kLastPromise] = null;
|
|
202187
202510
|
iterator[kLastResolve] = null;
|
|
202188
202511
|
iterator[kLastReject] = null;
|
|
202189
|
-
|
|
202512
|
+
resolve6(createIterResult(void 0, true));
|
|
202190
202513
|
}
|
|
202191
202514
|
iterator[kEnded] = true;
|
|
202192
202515
|
});
|
|
@@ -213552,7 +213875,7 @@ var require_xml = /* @__PURE__ */ __commonJSMin(((exports2, module2) => {
|
|
|
213552
213875
|
}
|
|
213553
213876
|
}
|
|
213554
213877
|
function add(value, last2) {
|
|
213555
|
-
format(append,
|
|
213878
|
+
format(append, resolve6(value, indent, indent ? 1 : 0), last2);
|
|
213556
213879
|
}
|
|
213557
213880
|
function end() {
|
|
213558
213881
|
if (stream2) {
|
|
@@ -213591,12 +213914,12 @@ var require_xml = /* @__PURE__ */ __commonJSMin(((exports2, module2) => {
|
|
|
213591
213914
|
return output;
|
|
213592
213915
|
}
|
|
213593
213916
|
function element() {
|
|
213594
|
-
var self2 = { _elem:
|
|
213917
|
+
var self2 = { _elem: resolve6(Array.prototype.slice.call(arguments)) };
|
|
213595
213918
|
self2.push = function(input) {
|
|
213596
213919
|
if (!this.append) throw new Error("not assigned to a parent!");
|
|
213597
213920
|
var that = this;
|
|
213598
213921
|
var indent = this._elem.indent;
|
|
213599
|
-
format(this.append,
|
|
213922
|
+
format(this.append, resolve6(input, indent, this._elem.icount + (indent ? 1 : 0)), function() {
|
|
213600
213923
|
that.append(true);
|
|
213601
213924
|
});
|
|
213602
213925
|
};
|
|
@@ -213609,7 +213932,7 @@ var require_xml = /* @__PURE__ */ __commonJSMin(((exports2, module2) => {
|
|
|
213609
213932
|
function create_indent(character, count) {
|
|
213610
213933
|
return new Array(count || 0).join(character || "");
|
|
213611
213934
|
}
|
|
213612
|
-
function
|
|
213935
|
+
function resolve6(data, indent, indent_count) {
|
|
213613
213936
|
indent_count = indent_count || 0;
|
|
213614
213937
|
var indent_spaces = create_indent(indent, indent_count);
|
|
213615
213938
|
var name;
|
|
@@ -213644,7 +213967,7 @@ var require_xml = /* @__PURE__ */ __commonJSMin(((exports2, module2) => {
|
|
|
213644
213967
|
content.push("");
|
|
213645
213968
|
values.forEach(function(value) {
|
|
213646
213969
|
if (typeof value == "object") if (Object.keys(value)[0] == "_attr") get_attributes(value._attr);
|
|
213647
|
-
else content.push(
|
|
213970
|
+
else content.push(resolve6(value, indent, indent_count + 1));
|
|
213648
213971
|
else {
|
|
213649
213972
|
content.pop();
|
|
213650
213973
|
isStringContent = true;
|
|
@@ -232453,14 +232776,14 @@ var runners = {
|
|
|
232453
232776
|
}
|
|
232454
232777
|
};
|
|
232455
232778
|
var solveArc = function(doc, x, y, coords) {
|
|
232456
|
-
const [rx, ry, rot, large,
|
|
232457
|
-
const segs = arcToSegments(ex, ey, rx, ry, large,
|
|
232779
|
+
const [rx, ry, rot, large, sweep2, ex, ey] = coords;
|
|
232780
|
+
const segs = arcToSegments(ex, ey, rx, ry, large, sweep2, rot, x, y);
|
|
232458
232781
|
for (let seg of segs) {
|
|
232459
232782
|
const bez = segmentToBezier(...seg);
|
|
232460
232783
|
doc.bezierCurveTo(...bez);
|
|
232461
232784
|
}
|
|
232462
232785
|
};
|
|
232463
|
-
var arcToSegments = function(x, y, rx, ry, large,
|
|
232786
|
+
var arcToSegments = function(x, y, rx, ry, large, sweep2, rotateX, ox, oy) {
|
|
232464
232787
|
const th = rotateX * (Math.PI / 180);
|
|
232465
232788
|
const sin_th = Math.sin(th);
|
|
232466
232789
|
const cos_th = Math.cos(th);
|
|
@@ -232488,7 +232811,7 @@ var arcToSegments = function(x, y, rx, ry, large, sweep, rotateX, ox, oy) {
|
|
|
232488
232811
|
sfactor_sq = 0;
|
|
232489
232812
|
}
|
|
232490
232813
|
let sfactor = Math.sqrt(sfactor_sq);
|
|
232491
|
-
if (
|
|
232814
|
+
if (sweep2 === large) {
|
|
232492
232815
|
sfactor = -sfactor;
|
|
232493
232816
|
}
|
|
232494
232817
|
const xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
|
|
@@ -232496,9 +232819,9 @@ var arcToSegments = function(x, y, rx, ry, large, sweep, rotateX, ox, oy) {
|
|
|
232496
232819
|
const th0 = Math.atan2(y0 - yc, x0 - xc);
|
|
232497
232820
|
const th1 = Math.atan2(y1 - yc, x1 - xc);
|
|
232498
232821
|
let th_arc = th1 - th0;
|
|
232499
|
-
if (th_arc < 0 &&
|
|
232822
|
+
if (th_arc < 0 && sweep2 === 1) {
|
|
232500
232823
|
th_arc += 2 * Math.PI;
|
|
232501
|
-
} else if (th_arc > 0 &&
|
|
232824
|
+
} else if (th_arc > 0 && sweep2 === 0) {
|
|
232502
232825
|
th_arc -= 2 * Math.PI;
|
|
232503
232826
|
}
|
|
232504
232827
|
const segments = Math.ceil(Math.abs(th_arc / (Math.PI * 0.5 + 1e-3)));
|
|
@@ -236934,7 +237257,7 @@ var SERIF2 = (bold, italic) => bold && italic ? "Serif-BoldItalic" : bold ? "Ser
|
|
|
236934
237257
|
var isEmoji = (cp) => cp >= 126976 || cp >= 9728 && cp <= 10175;
|
|
236935
237258
|
async function scriptToPdf(doc) {
|
|
236936
237259
|
const { scriptFont: scriptFont2 } = await Promise.resolve().then(() => (init_script_fonts(), script_fonts_exports));
|
|
236937
|
-
return new Promise((
|
|
237260
|
+
return new Promise((resolve6, reject2) => {
|
|
236938
237261
|
const pdf = new PDFDocument({ size: "A4", margins: { top: MARGIN, bottom: MARGIN, left: MARGIN, right: MARGIN }, info: { Title: doc.project, Author: "Patter" } });
|
|
236939
237262
|
pdf.registerFont("Serif", scriptFont2("serif"));
|
|
236940
237263
|
pdf.registerFont("Serif-Bold", scriptFont2("serifBold"));
|
|
@@ -236975,7 +237298,7 @@ async function scriptToPdf(doc) {
|
|
|
236975
237298
|
const bodyPieces = (runs, color, base = {}) => runs.flatMap((r) => r.code ? split(r.text, "Mono", ACCENT) : split(r.text, SERIF2(base.bold || r.bold, base.italic || r.italic), color));
|
|
236976
237299
|
const chunks = [];
|
|
236977
237300
|
pdf.on("data", (c2) => chunks.push(c2));
|
|
236978
|
-
pdf.on("end", () =>
|
|
237301
|
+
pdf.on("end", () => resolve6(Buffer.concat(chunks)));
|
|
236979
237302
|
pdf.on("error", reject2);
|
|
236980
237303
|
const pageRight = pdf.page.width - MARGIN;
|
|
236981
237304
|
const pageBottom = pdf.page.height - MARGIN;
|
|
@@ -237530,7 +237853,7 @@ async function runPack(startPath) {
|
|
|
237530
237853
|
|
|
237531
237854
|
// ../ops/src/unpack.ts
|
|
237532
237855
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
237533
|
-
import { join as join5, normalize, isAbsolute as isAbsolute2, sep as sep3 } from "path";
|
|
237856
|
+
import { join as join5, normalize, isAbsolute as isAbsolute2, resolve as resolve4, sep as sep3 } from "path";
|
|
237534
237857
|
import { existsSync as existsSync3, readFileSync as readFileSync5 } from "fs";
|
|
237535
237858
|
|
|
237536
237859
|
// ../ops/src/merge.ts
|
|
@@ -237570,7 +237893,7 @@ function merge3(base, ours, theirs, id, path, conflicts) {
|
|
|
237570
237893
|
conflicts.push({ id, path, base, ours, theirs, kind: deletedKind(base, ours, theirs) });
|
|
237571
237894
|
return ours;
|
|
237572
237895
|
}
|
|
237573
|
-
function mergeMap(base, ours, theirs, prefix, conflicts,
|
|
237896
|
+
function mergeMap(base, ours, theirs, prefix, conflicts, resolve6) {
|
|
237574
237897
|
const out = {};
|
|
237575
237898
|
for (const k of /* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(ours), ...Object.keys(theirs)])) {
|
|
237576
237899
|
const b = base[k], o = ours[k], t = theirs[k];
|
|
@@ -237579,7 +237902,7 @@ function mergeMap(base, ours, theirs, prefix, conflicts, resolve5) {
|
|
|
237579
237902
|
else if (eq(b, o)) v = t;
|
|
237580
237903
|
else if (eq(b, t)) v = o;
|
|
237581
237904
|
else {
|
|
237582
|
-
const r =
|
|
237905
|
+
const r = resolve6?.(k, b, o, t);
|
|
237583
237906
|
if (r && r.resolved) v = r.value;
|
|
237584
237907
|
else {
|
|
237585
237908
|
conflicts.push({ id: k, path: `${prefix}.${k}`, base: b, ours: o, theirs: t, kind: r ? r.kind : deletedKind(b, o, t) });
|
|
@@ -237854,29 +238177,60 @@ var arrEq = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
|
|
|
237854
238177
|
var MANIFEST = "patter.manifest.json";
|
|
237855
238178
|
var UnsafeEntryError = class extends Error {
|
|
237856
238179
|
};
|
|
237857
|
-
async function
|
|
238180
|
+
async function readDoc(bytes) {
|
|
237858
238181
|
const zip = await import_jszip2.default.loadAsync(bytes);
|
|
237859
|
-
const
|
|
238182
|
+
const shards = /* @__PURE__ */ new Map();
|
|
238183
|
+
let manifest;
|
|
237860
238184
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
237861
|
-
if (entry.dir
|
|
238185
|
+
if (entry.dir) continue;
|
|
238186
|
+
if (name === MANIFEST) {
|
|
238187
|
+
try {
|
|
238188
|
+
manifest = JSON.parse(await entry.async("string"));
|
|
238189
|
+
} catch {
|
|
238190
|
+
}
|
|
238191
|
+
continue;
|
|
238192
|
+
}
|
|
237862
238193
|
if (isUnsafeEntry(name)) throw new UnsafeEntryError(`document entry escapes the target directory: ${name}`);
|
|
237863
|
-
|
|
238194
|
+
shards.set(name, await entry.async("string"));
|
|
237864
238195
|
}
|
|
237865
|
-
return
|
|
238196
|
+
return { shards, manifest };
|
|
238197
|
+
}
|
|
238198
|
+
async function readDocShards(bytes) {
|
|
238199
|
+
return (await readDoc(bytes)).shards;
|
|
237866
238200
|
}
|
|
237867
238201
|
async function runUnpack(bytes, targetDir) {
|
|
237868
238202
|
const shards = await readDocShards(bytes);
|
|
237869
|
-
return [...shards.entries()].map(([name, content]) => ({ path:
|
|
238203
|
+
return [...shards.entries()].map(([name, content]) => ({ path: containedWrite(targetDir, name), content })).sort((a, b) => a.path.localeCompare(b.path));
|
|
238204
|
+
}
|
|
238205
|
+
function checkProvenance(returned, base, target) {
|
|
238206
|
+
const known = [returned, base, target].filter((id) => typeof id === "string" && id !== "");
|
|
238207
|
+
return {
|
|
238208
|
+
...returned !== void 0 ? { returned } : {},
|
|
238209
|
+
...base !== void 0 ? { base } : {},
|
|
238210
|
+
...target !== void 0 ? { target } : {},
|
|
238211
|
+
ok: new Set(known).size <= 1
|
|
238212
|
+
};
|
|
238213
|
+
}
|
|
238214
|
+
function targetProjectId(projectDir) {
|
|
238215
|
+
try {
|
|
238216
|
+
const pf = parseSource(readFileSync5(findProjectFile(projectDir), "utf8"));
|
|
238217
|
+
return pf.project?.id;
|
|
238218
|
+
} catch {
|
|
238219
|
+
return void 0;
|
|
238220
|
+
}
|
|
237870
238221
|
}
|
|
237871
238222
|
async function runUnpackMerge(returnedBytes, baseBytes, projectDir) {
|
|
237872
|
-
const
|
|
237873
|
-
const
|
|
238223
|
+
const returnedDoc = await readDoc(returnedBytes);
|
|
238224
|
+
const baseDoc = await readDoc(baseBytes);
|
|
238225
|
+
const theirs = returnedDoc.shards;
|
|
238226
|
+
const base = baseDoc.shards;
|
|
238227
|
+
const provenance = checkProvenance(returnedDoc.manifest?.project?.id, baseDoc.manifest?.project?.id, targetProjectId(projectDir));
|
|
237874
238228
|
const shards = [];
|
|
237875
238229
|
const writes = [];
|
|
237876
238230
|
const sidecars = [];
|
|
237877
238231
|
let conflicts = 0, warnings = 0;
|
|
237878
238232
|
for (const [rel, theirText] of [...theirs.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
|
|
237879
|
-
const outPath =
|
|
238233
|
+
const outPath = containedWrite(projectDir, rel);
|
|
237880
238234
|
if (!existsSync3(outPath)) {
|
|
237881
238235
|
writes.push({ path: outPath, content: theirText });
|
|
237882
238236
|
shards.push({ path: rel, added: true });
|
|
@@ -237895,16 +238249,24 @@ async function runUnpackMerge(returnedBytes, baseBytes, projectDir) {
|
|
|
237895
238249
|
warnings += result.warnings.length;
|
|
237896
238250
|
shards.push({ path: rel, result, added: false });
|
|
237897
238251
|
}
|
|
237898
|
-
return { shards, writes, sidecars, conflicts, warnings };
|
|
238252
|
+
return { shards, writes, sidecars, conflicts, warnings, provenance };
|
|
237899
238253
|
}
|
|
237900
238254
|
function isUnsafeEntry(name) {
|
|
237901
238255
|
if (isAbsolute2(name) || /^[a-zA-Z]:/.test(name)) return true;
|
|
237902
238256
|
const norm = normalize(name);
|
|
237903
238257
|
return norm === ".." || norm.startsWith(".." + sep3) || norm.startsWith("../");
|
|
237904
238258
|
}
|
|
238259
|
+
function containedWrite(dir2, name) {
|
|
238260
|
+
const root2 = resolve4(dir2);
|
|
238261
|
+
const full = resolve4(join5(dir2, name));
|
|
238262
|
+
if (full !== root2 && !full.startsWith(root2 + sep3)) {
|
|
238263
|
+
throw new UnsafeEntryError(`document entry escapes the target directory: ${name}`);
|
|
238264
|
+
}
|
|
238265
|
+
return full;
|
|
238266
|
+
}
|
|
237905
238267
|
|
|
237906
238268
|
// ../../node_modules/@wildwinter/simple-vc-lib/dist/simpleVcLib.js
|
|
237907
|
-
import { join as join6, dirname as dirname5, resolve as
|
|
238269
|
+
import { join as join6, dirname as dirname5, resolve as resolve5, sep as sep4, basename as basename6 } from "path";
|
|
237908
238270
|
import { existsSync as existsSync4, readFileSync as readFileSync6, statSync as statSync3, unlinkSync, rmSync, renameSync, accessSync, constants, chmodSync, mkdirSync as mkdirSync2, cpSync, readdirSync as readdirSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
237909
238271
|
import { spawnSync, spawn } from "child_process";
|
|
237910
238272
|
var VALID_SYSTEMS = ["git", "perforce", "plastic", "svn", "filesystem"];
|
|
@@ -237959,7 +238321,7 @@ async function runCommandAsync(command, args, options = {}) {
|
|
|
237959
238321
|
const overridden = await _overrideRunner(command, args, options);
|
|
237960
238322
|
return { timedOut: false, ...overridden };
|
|
237961
238323
|
}
|
|
237962
|
-
return new Promise((
|
|
238324
|
+
return new Promise((resolve6) => {
|
|
237963
238325
|
const child = spawn(command, args, { cwd: options.cwd, windowsHide: true });
|
|
237964
238326
|
let stdout = "";
|
|
237965
238327
|
let stderr = "";
|
|
@@ -237981,7 +238343,7 @@ async function runCommandAsync(command, args, options = {}) {
|
|
|
237981
238343
|
if (settled) return;
|
|
237982
238344
|
settled = true;
|
|
237983
238345
|
clearTimeout(timer);
|
|
237984
|
-
|
|
238346
|
+
resolve6(result);
|
|
237985
238347
|
};
|
|
237986
238348
|
child.on("error", (err) => {
|
|
237987
238349
|
finish({ exitCode: -1, output: "", error: stderr.trim() || err.message, timedOut });
|
|
@@ -237997,6 +238359,7 @@ async function runCommandAsync(command, args, options = {}) {
|
|
|
237997
238359
|
});
|
|
237998
238360
|
}
|
|
237999
238361
|
var _rootCache = /* @__PURE__ */ new Map();
|
|
238362
|
+
var _probedCache = /* @__PURE__ */ new Map();
|
|
238000
238363
|
function detectProvider(absPath) {
|
|
238001
238364
|
let dir2;
|
|
238002
238365
|
try {
|
|
@@ -238004,6 +238367,8 @@ function detectProvider(absPath) {
|
|
|
238004
238367
|
} catch {
|
|
238005
238368
|
dir2 = dirname5(absPath);
|
|
238006
238369
|
}
|
|
238370
|
+
const known = _probedCache.get(dir2);
|
|
238371
|
+
if (known !== void 0) return known;
|
|
238007
238372
|
let current = dir2;
|
|
238008
238373
|
while (true) {
|
|
238009
238374
|
if (_rootCache.has(current)) return _rootCache.get(current);
|
|
@@ -238030,8 +238395,9 @@ function detectProvider(absPath) {
|
|
|
238030
238395
|
current = parent2;
|
|
238031
238396
|
}
|
|
238032
238397
|
const p42 = runCommand("p4", ["info"], { timeout: 3e3 });
|
|
238033
|
-
|
|
238034
|
-
|
|
238398
|
+
const answer = p42.exitCode === 0 && p42.output.includes("Client name:") ? "perforce" : "filesystem";
|
|
238399
|
+
_probedCache.set(dir2, answer);
|
|
238400
|
+
return answer;
|
|
238035
238401
|
}
|
|
238036
238402
|
function okResult(message = "") {
|
|
238037
238403
|
return { success: true, status: "ok", message };
|
|
@@ -238067,6 +238433,14 @@ var FilesystemProvider = class {
|
|
|
238067
238433
|
get name() {
|
|
238068
238434
|
return "filesystem";
|
|
238069
238435
|
}
|
|
238436
|
+
/** No version control, so no user. Undefined is the honest answer, not ''. */
|
|
238437
|
+
currentUser() {
|
|
238438
|
+
return void 0;
|
|
238439
|
+
}
|
|
238440
|
+
/** Async twin of {@link currentUser}. */
|
|
238441
|
+
async currentUserAsync() {
|
|
238442
|
+
return void 0;
|
|
238443
|
+
}
|
|
238070
238444
|
prepareToWrite(filePath) {
|
|
238071
238445
|
if (!existsSync4(filePath)) return okResult();
|
|
238072
238446
|
if (isWritable$1(filePath)) return okResult();
|
|
@@ -238142,7 +238516,7 @@ var FilesystemProvider = class {
|
|
|
238142
238516
|
*/
|
|
238143
238517
|
status(filePaths) {
|
|
238144
238518
|
return filePaths.map((filePath) => {
|
|
238145
|
-
const abs =
|
|
238519
|
+
const abs = resolve5(filePath);
|
|
238146
238520
|
return { filePath: abs, system: "filesystem", writable: writableBit(abs) };
|
|
238147
238521
|
});
|
|
238148
238522
|
}
|
|
@@ -238175,20 +238549,48 @@ function git(args, cwd, options = {}) {
|
|
|
238175
238549
|
function gitAsync(args, cwd, options = {}) {
|
|
238176
238550
|
return runCommandAsync("git", gitArgv(args, cwd), { cwd, ...options });
|
|
238177
238551
|
}
|
|
238552
|
+
function gitUserName(cwd) {
|
|
238553
|
+
const r = git(["config", "user.name"], cwd);
|
|
238554
|
+
const name = r.exitCode === 0 ? r.output.trim() : "";
|
|
238555
|
+
return name === "" ? void 0 : name;
|
|
238556
|
+
}
|
|
238557
|
+
async function gitUserNameAsync(cwd) {
|
|
238558
|
+
const r = await gitAsync(["config", "user.name"], cwd);
|
|
238559
|
+
const name = r.exitCode === 0 ? r.output.trim() : "";
|
|
238560
|
+
return name === "" ? void 0 : name;
|
|
238561
|
+
}
|
|
238178
238562
|
function gitArgv(args, cwd) {
|
|
238179
238563
|
const isWindows = process.platform === "win32";
|
|
238180
238564
|
const safeCwd = isWindows ? cwd.replace(/\\/g, "/") : cwd;
|
|
238181
238565
|
const safeArgs = isWindows ? args.map((arg) => typeof arg === "string" ? arg.replace(/\\/g, "/") : arg) : args;
|
|
238182
238566
|
return ["-C", safeCwd, ...safeArgs];
|
|
238183
238567
|
}
|
|
238568
|
+
var _trackedCache = /* @__PURE__ */ new Set();
|
|
238184
238569
|
function isTracked$2(filePath) {
|
|
238570
|
+
const key2 = resolve5(filePath);
|
|
238571
|
+
if (_trackedCache.has(key2)) return true;
|
|
238185
238572
|
const result = git(["ls-files", "--error-unmatch", filePath], dirname5(filePath));
|
|
238573
|
+
if (result.exitCode === 0) _trackedCache.add(key2);
|
|
238186
238574
|
return result.exitCode === 0;
|
|
238187
238575
|
}
|
|
238188
238576
|
async function isTrackedAsync$2(filePath) {
|
|
238577
|
+
const key2 = resolve5(filePath);
|
|
238578
|
+
if (_trackedCache.has(key2)) return true;
|
|
238189
238579
|
const result = await gitAsync(["ls-files", "--error-unmatch", filePath], dirname5(filePath));
|
|
238580
|
+
if (result.exitCode === 0) _trackedCache.add(key2);
|
|
238190
238581
|
return result.exitCode === 0;
|
|
238191
238582
|
}
|
|
238583
|
+
function markTracked(filePath) {
|
|
238584
|
+
_trackedCache.add(resolve5(filePath));
|
|
238585
|
+
}
|
|
238586
|
+
function unmarkTracked(filePath) {
|
|
238587
|
+
_trackedCache.delete(resolve5(filePath));
|
|
238588
|
+
}
|
|
238589
|
+
function unmarkTrackedUnder(folderPath) {
|
|
238590
|
+
const prefix = resolve5(folderPath) + sep4;
|
|
238591
|
+
for (const path of _trackedCache) if (path.startsWith(prefix)) _trackedCache.delete(path);
|
|
238592
|
+
_trackedCache.delete(resolve5(folderPath));
|
|
238593
|
+
}
|
|
238192
238594
|
function isInRepo(dir2) {
|
|
238193
238595
|
return git(["rev-parse", "--git-dir"], dir2).exitCode === 0;
|
|
238194
238596
|
}
|
|
@@ -238199,6 +238601,14 @@ var GitProvider = class {
|
|
|
238199
238601
|
get name() {
|
|
238200
238602
|
return "git";
|
|
238201
238603
|
}
|
|
238604
|
+
/** `git config user.name`, resolved from `cwd` so a repo-local override wins over the global one. */
|
|
238605
|
+
currentUser(cwd = process.cwd()) {
|
|
238606
|
+
return gitUserName(cwd);
|
|
238607
|
+
}
|
|
238608
|
+
/** Async twin of {@link currentUser}. */
|
|
238609
|
+
currentUserAsync(cwd = process.cwd()) {
|
|
238610
|
+
return gitUserNameAsync(cwd);
|
|
238611
|
+
}
|
|
238202
238612
|
prepareToWrite(filePath) {
|
|
238203
238613
|
if (!existsSync4(filePath)) return okResult();
|
|
238204
238614
|
if (isWritable(filePath)) return okResult();
|
|
@@ -238213,7 +238623,10 @@ var GitProvider = class {
|
|
|
238213
238623
|
if (!isInRepo(cwd))
|
|
238214
238624
|
return fs$3.finishedWrite(filePath);
|
|
238215
238625
|
const result = git(["add", filePath], cwd);
|
|
238216
|
-
if (result.exitCode === 0)
|
|
238626
|
+
if (result.exitCode === 0) {
|
|
238627
|
+
markTracked(filePath);
|
|
238628
|
+
return okResult("File added to git");
|
|
238629
|
+
}
|
|
238217
238630
|
const combined = (result.output + " " + result.error).toLowerCase();
|
|
238218
238631
|
if (combined.includes("ignored")) return fs$3.finishedWrite(filePath);
|
|
238219
238632
|
return errorResult("error", `Cannot add '${filePath}' to git: ${result.error || result.output}`);
|
|
@@ -238231,7 +238644,10 @@ var GitProvider = class {
|
|
|
238231
238644
|
if (!await isInRepoAsync(cwd))
|
|
238232
238645
|
return fs$3.finishedWriteAsync(filePath);
|
|
238233
238646
|
const result = await gitAsync(["add", filePath], cwd);
|
|
238234
|
-
if (result.exitCode === 0)
|
|
238647
|
+
if (result.exitCode === 0) {
|
|
238648
|
+
markTracked(filePath);
|
|
238649
|
+
return okResult("File added to git");
|
|
238650
|
+
}
|
|
238235
238651
|
const combined = (result.output + " " + result.error).toLowerCase();
|
|
238236
238652
|
if (combined.includes("ignored")) return fs$3.finishedWriteAsync(filePath);
|
|
238237
238653
|
return errorResult("error", `Cannot add '${filePath}' to git: ${result.error || result.output}`);
|
|
@@ -238241,7 +238657,10 @@ var GitProvider = class {
|
|
|
238241
238657
|
if (!existsSync4(filePath)) return okResult();
|
|
238242
238658
|
if (await isTrackedAsync$2(filePath)) {
|
|
238243
238659
|
const result = await gitAsync(["rm", "--force", filePath], dirname5(filePath));
|
|
238244
|
-
if (result.exitCode === 0)
|
|
238660
|
+
if (result.exitCode === 0) {
|
|
238661
|
+
unmarkTracked(filePath);
|
|
238662
|
+
return okResult();
|
|
238663
|
+
}
|
|
238245
238664
|
return errorResult("error", `Cannot delete '${filePath}' from git: ${result.error || result.output}`);
|
|
238246
238665
|
}
|
|
238247
238666
|
try {
|
|
@@ -238257,6 +238676,7 @@ var GitProvider = class {
|
|
|
238257
238676
|
const listResult = await gitAsync(["ls-files", folderPath], folderPath);
|
|
238258
238677
|
if (listResult.exitCode === 0 && listResult.output.length > 0) {
|
|
238259
238678
|
const rmResult = await gitAsync(["rm", "-r", "--force", folderPath], folderPath);
|
|
238679
|
+
if (rmResult.exitCode === 0) unmarkTrackedUnder(folderPath);
|
|
238260
238680
|
if (rmResult.exitCode !== 0)
|
|
238261
238681
|
return errorResult("error", `Cannot delete folder '${folderPath}' from git: ${rmResult.error || rmResult.output}`);
|
|
238262
238682
|
}
|
|
@@ -238274,7 +238694,11 @@ var GitProvider = class {
|
|
|
238274
238694
|
if (!existsSync4(oldPath)) return okResult();
|
|
238275
238695
|
if (await isTrackedAsync$2(oldPath)) {
|
|
238276
238696
|
const result = await gitAsync(["mv", oldPath, newPath], dirname5(oldPath));
|
|
238277
|
-
if (result.exitCode === 0)
|
|
238697
|
+
if (result.exitCode === 0) {
|
|
238698
|
+
unmarkTracked(oldPath);
|
|
238699
|
+
markTracked(newPath);
|
|
238700
|
+
return okResult();
|
|
238701
|
+
}
|
|
238278
238702
|
return errorResult("error", `Cannot rename '${oldPath}' in git: ${result.error || result.output}`);
|
|
238279
238703
|
}
|
|
238280
238704
|
try {
|
|
@@ -238288,6 +238712,7 @@ var GitProvider = class {
|
|
|
238288
238712
|
async renameFolderAsync(oldPath, newPath) {
|
|
238289
238713
|
if (!existsSync4(oldPath)) return okResult();
|
|
238290
238714
|
const result = await gitAsync(["mv", oldPath, newPath], dirname5(oldPath));
|
|
238715
|
+
unmarkTrackedUnder(oldPath);
|
|
238291
238716
|
if (result.exitCode === 0) return okResult();
|
|
238292
238717
|
try {
|
|
238293
238718
|
renameSync(oldPath, newPath);
|
|
@@ -238300,7 +238725,10 @@ var GitProvider = class {
|
|
|
238300
238725
|
if (!existsSync4(filePath)) return okResult();
|
|
238301
238726
|
if (isTracked$2(filePath)) {
|
|
238302
238727
|
const result = git(["rm", "--force", filePath], dirname5(filePath));
|
|
238303
|
-
if (result.exitCode === 0)
|
|
238728
|
+
if (result.exitCode === 0) {
|
|
238729
|
+
unmarkTracked(filePath);
|
|
238730
|
+
return okResult();
|
|
238731
|
+
}
|
|
238304
238732
|
return errorResult("error", `Cannot delete '${filePath}' from git: ${result.error || result.output}`);
|
|
238305
238733
|
}
|
|
238306
238734
|
try {
|
|
@@ -238314,7 +238742,11 @@ var GitProvider = class {
|
|
|
238314
238742
|
if (!existsSync4(oldPath)) return okResult();
|
|
238315
238743
|
if (isTracked$2(oldPath)) {
|
|
238316
238744
|
const result = git(["mv", oldPath, newPath], dirname5(oldPath));
|
|
238317
|
-
if (result.exitCode === 0)
|
|
238745
|
+
if (result.exitCode === 0) {
|
|
238746
|
+
unmarkTracked(oldPath);
|
|
238747
|
+
markTracked(newPath);
|
|
238748
|
+
return okResult();
|
|
238749
|
+
}
|
|
238318
238750
|
return errorResult("error", `Cannot rename '${oldPath}' in git: ${result.error || result.output}`);
|
|
238319
238751
|
}
|
|
238320
238752
|
try {
|
|
@@ -238327,6 +238759,7 @@ var GitProvider = class {
|
|
|
238327
238759
|
renameFolder(oldPath, newPath) {
|
|
238328
238760
|
if (!existsSync4(oldPath)) return okResult();
|
|
238329
238761
|
const result = git(["mv", oldPath, newPath], dirname5(oldPath));
|
|
238762
|
+
unmarkTrackedUnder(oldPath);
|
|
238330
238763
|
if (result.exitCode === 0) return okResult();
|
|
238331
238764
|
try {
|
|
238332
238765
|
renameSync(oldPath, newPath);
|
|
@@ -238340,6 +238773,7 @@ var GitProvider = class {
|
|
|
238340
238773
|
const listResult = git(["ls-files", folderPath], folderPath);
|
|
238341
238774
|
if (listResult.exitCode === 0 && listResult.output.length > 0) {
|
|
238342
238775
|
const rmResult = git(["rm", "-r", "--force", folderPath], folderPath);
|
|
238776
|
+
if (rmResult.exitCode === 0) unmarkTrackedUnder(folderPath);
|
|
238343
238777
|
if (rmResult.exitCode !== 0) {
|
|
238344
238778
|
return errorResult("error", `Cannot delete folder '${folderPath}' from git: ${rmResult.error || rmResult.output}`);
|
|
238345
238779
|
}
|
|
@@ -238355,22 +238789,31 @@ var GitProvider = class {
|
|
|
238355
238789
|
}
|
|
238356
238790
|
/**
|
|
238357
238791
|
* Status for a batch of files: per repository root, ONE
|
|
238358
|
-
* `git status --porcelain -z` (tracked-ness) plus - when
|
|
238359
|
-
*
|
|
238360
|
-
* git
|
|
238792
|
+
* `git status --porcelain -z` (tracked-ness) plus - only when this repo uses
|
|
238793
|
+
* git-lfs file locking AND `{ remote: true }` was asked - ONE
|
|
238794
|
+
* `git lfs locks --verify --json` (`--verify` splits ours vs theirs).
|
|
238795
|
+
*
|
|
238796
|
+
* `git lfs locks` ALWAYS contacts the lock server (there is no local lock list),
|
|
238797
|
+
* a network round-trip that can trigger a credential prompt (on Windows the
|
|
238798
|
+
* GitHub sign-in window, #26). So a plain git repo - no LFS locking - never hits
|
|
238799
|
+
* the network here, matching a lock-free git workflow's expectation, and even an
|
|
238800
|
+
* LFS-locking repo only pays the round-trip when the caller opts in with `remote`.
|
|
238801
|
+
* Lock use is detected locally by a `lockable` attribute in the repo's
|
|
238802
|
+
* `.gitattributes`; git itself has no locks.
|
|
238361
238803
|
*
|
|
238362
238804
|
* All matching is done on REPO-RELATIVE paths (via `rev-parse --show-prefix`),
|
|
238363
238805
|
* never by joining absolute paths - so symlinked ancestors (macOS `/var` ->
|
|
238364
238806
|
* `/private/var`, `/tmp` -> `/private/tmp`) cannot break the lookup.
|
|
238365
238807
|
*
|
|
238366
238808
|
* @param {string[]} filePaths
|
|
238809
|
+
* @param {import('../vcStatus.js').VCStatusOptions} [options]
|
|
238367
238810
|
* @returns {import('../vcStatus.js').VCFileStatus[]}
|
|
238368
238811
|
*/
|
|
238369
|
-
status(filePaths) {
|
|
238812
|
+
status(filePaths, options = {}) {
|
|
238370
238813
|
const infoByDir = /* @__PURE__ */ new Map();
|
|
238371
238814
|
const groups = /* @__PURE__ */ new Map();
|
|
238372
238815
|
for (const filePath of filePaths) {
|
|
238373
|
-
const abs =
|
|
238816
|
+
const abs = resolve5(filePath);
|
|
238374
238817
|
const dir2 = dirname5(abs);
|
|
238375
238818
|
let info = infoByDir.get(dir2);
|
|
238376
238819
|
if (info === void 0) {
|
|
@@ -238386,20 +238829,21 @@ var GitProvider = class {
|
|
|
238386
238829
|
continue;
|
|
238387
238830
|
}
|
|
238388
238831
|
const st = git(["status", "--porcelain", "-z", "--", ...files.map((f) => f.relKey)], root2, { trim: false });
|
|
238389
|
-
const locks = git(["lfs", "locks", "--verify", "--json"], root2);
|
|
238832
|
+
const locks = shouldQueryLfsLocks(root2, options) ? git(["lfs", "locks", "--verify", "--json"], root2) : NO_LOCKS;
|
|
238390
238833
|
assembleGitStatuses(files, gitStates(st), gitLocks(locks), byInput);
|
|
238391
238834
|
}
|
|
238392
238835
|
return filePaths.map((filePath) => byInput.get(filePath));
|
|
238393
238836
|
}
|
|
238394
238837
|
/**
|
|
238395
238838
|
* Async twin of {@link status}. Within each repo the porcelain status and the
|
|
238396
|
-
* git-lfs lock list are independent, so they run concurrently
|
|
238839
|
+
* git-lfs lock list are independent, so they run concurrently - and the lock
|
|
238840
|
+
* query is gated exactly as in {@link status} (LFS locking in use + `remote`).
|
|
238397
238841
|
*/
|
|
238398
|
-
async statusAsync(filePaths) {
|
|
238842
|
+
async statusAsync(filePaths, options = {}) {
|
|
238399
238843
|
const infoByDir = /* @__PURE__ */ new Map();
|
|
238400
238844
|
const groups = /* @__PURE__ */ new Map();
|
|
238401
238845
|
for (const filePath of filePaths) {
|
|
238402
|
-
const abs =
|
|
238846
|
+
const abs = resolve5(filePath);
|
|
238403
238847
|
const dir2 = dirname5(abs);
|
|
238404
238848
|
let info = infoByDir.get(dir2);
|
|
238405
238849
|
if (info === void 0) {
|
|
@@ -238416,13 +238860,24 @@ var GitProvider = class {
|
|
|
238416
238860
|
}
|
|
238417
238861
|
const [st, locks] = await Promise.all([
|
|
238418
238862
|
gitAsync(["status", "--porcelain", "-z", "--", ...files.map((f) => f.relKey)], root2, { trim: false }),
|
|
238419
|
-
gitAsync(["lfs", "locks", "--verify", "--json"], root2)
|
|
238863
|
+
shouldQueryLfsLocks(root2, options) ? gitAsync(["lfs", "locks", "--verify", "--json"], root2) : Promise.resolve(NO_LOCKS)
|
|
238420
238864
|
]);
|
|
238421
238865
|
assembleGitStatuses(files, gitStates(st), gitLocks(locks), byInput);
|
|
238422
238866
|
}
|
|
238423
238867
|
return filePaths.map((filePath) => byInput.get(filePath));
|
|
238424
238868
|
}
|
|
238425
238869
|
};
|
|
238870
|
+
var NO_LOCKS = { exitCode: 1, output: "", error: "" };
|
|
238871
|
+
function shouldQueryLfsLocks(root2, options) {
|
|
238872
|
+
return options.remote === true && repoUsesLfsLocks(root2);
|
|
238873
|
+
}
|
|
238874
|
+
function repoUsesLfsLocks(root2) {
|
|
238875
|
+
try {
|
|
238876
|
+
return /(^|\s)lockable(\s|$)/m.test(readFileSync6(join6(root2, ".gitattributes"), "utf8"));
|
|
238877
|
+
} catch {
|
|
238878
|
+
return false;
|
|
238879
|
+
}
|
|
238880
|
+
}
|
|
238426
238881
|
function gitDirInfo(result) {
|
|
238427
238882
|
if (result.exitCode === 0) {
|
|
238428
238883
|
const lines = result.output.split("\n");
|
|
@@ -238495,6 +238950,18 @@ function p4(args) {
|
|
|
238495
238950
|
function p4Async(args) {
|
|
238496
238951
|
return runCommandAsync("p4", args);
|
|
238497
238952
|
}
|
|
238953
|
+
function p4UserName() {
|
|
238954
|
+
return parseP4User(p4(["info"]));
|
|
238955
|
+
}
|
|
238956
|
+
async function p4UserNameAsync() {
|
|
238957
|
+
return parseP4User(await p4Async(["info"]));
|
|
238958
|
+
}
|
|
238959
|
+
function parseP4User(result) {
|
|
238960
|
+
if (result.exitCode !== 0) return void 0;
|
|
238961
|
+
const line2 = /^User name:\s*(.+)$/m.exec(result.output);
|
|
238962
|
+
const name = line2?.[1]?.trim() ?? "";
|
|
238963
|
+
return name === "" ? void 0 : name;
|
|
238964
|
+
}
|
|
238498
238965
|
function fstat(filePath) {
|
|
238499
238966
|
const result = p4(["fstat", filePath]);
|
|
238500
238967
|
if (result.exitCode !== 0) return null;
|
|
@@ -238549,6 +239016,14 @@ var PerforceProvider = class {
|
|
|
238549
239016
|
get name() {
|
|
238550
239017
|
return "perforce";
|
|
238551
239018
|
}
|
|
239019
|
+
/** The `User name` p4 reports, which is the name it puts in `lockedBy`. */
|
|
239020
|
+
currentUser() {
|
|
239021
|
+
return p4UserName();
|
|
239022
|
+
}
|
|
239023
|
+
/** Async twin of {@link currentUser}. */
|
|
239024
|
+
currentUserAsync() {
|
|
239025
|
+
return p4UserNameAsync();
|
|
239026
|
+
}
|
|
238552
239027
|
prepareToWrite(filePath) {
|
|
238553
239028
|
if (!existsSync4(filePath)) return okResult();
|
|
238554
239029
|
const info = fstat(filePath);
|
|
@@ -238883,10 +239358,10 @@ function buildPerforceStatuses(output, filePaths) {
|
|
|
238883
239358
|
const byClientFile = /* @__PURE__ */ new Map();
|
|
238884
239359
|
for (const record of records) {
|
|
238885
239360
|
const clientFile = record.fields.get("clientFile");
|
|
238886
|
-
if (clientFile) byClientFile.set(
|
|
239361
|
+
if (clientFile) byClientFile.set(resolve5(clientFile), record);
|
|
238887
239362
|
}
|
|
238888
239363
|
return filePaths.map((filePath) => {
|
|
238889
|
-
const abs =
|
|
239364
|
+
const abs = resolve5(filePath);
|
|
238890
239365
|
const status = { filePath: abs, system: "perforce", writable: writableBit(abs) };
|
|
238891
239366
|
const record = byClientFile.get(abs);
|
|
238892
239367
|
if (!record) {
|
|
@@ -238961,6 +239436,16 @@ var PlasticProvider = class {
|
|
|
238961
239436
|
get name() {
|
|
238962
239437
|
return "plastic";
|
|
238963
239438
|
}
|
|
239439
|
+
/** `cm whoami`, the same call the lock check already makes to tell our lock from someone else's. */
|
|
239440
|
+
currentUser() {
|
|
239441
|
+
const u = plasticWhoami();
|
|
239442
|
+
return u === "" ? void 0 : u;
|
|
239443
|
+
}
|
|
239444
|
+
/** Async twin of {@link currentUser}. */
|
|
239445
|
+
async currentUserAsync() {
|
|
239446
|
+
const u = await plasticWhoamiAsync();
|
|
239447
|
+
return u === "" ? void 0 : u;
|
|
239448
|
+
}
|
|
238964
239449
|
prepareToWrite(filePath) {
|
|
238965
239450
|
if (!existsSync4(filePath)) return okResult();
|
|
238966
239451
|
if (!isTracked$1(filePath)) {
|
|
@@ -239162,7 +239647,7 @@ var PlasticProvider = class {
|
|
|
239162
239647
|
}
|
|
239163
239648
|
};
|
|
239164
239649
|
function plasticStatusArgs(filePaths) {
|
|
239165
|
-
return ["status", "--machinereadable", "--all", "--ignored", ...filePaths.map((p) =>
|
|
239650
|
+
return ["status", "--machinereadable", "--all", "--ignored", ...filePaths.map((p) => resolve5(p))];
|
|
239166
239651
|
}
|
|
239167
239652
|
function buildPlasticBase(result, filePaths) {
|
|
239168
239653
|
const byPath = /* @__PURE__ */ new Map();
|
|
@@ -239172,7 +239657,7 @@ function buildPlasticBase(result, filePaths) {
|
|
|
239172
239657
|
const parsed = parseCmStatusLine(line2);
|
|
239173
239658
|
if (!parsed) continue;
|
|
239174
239659
|
for (const p of parsed.paths) {
|
|
239175
|
-
const abs =
|
|
239660
|
+
const abs = resolve5(p);
|
|
239176
239661
|
byPath.set(abs, parsed.info);
|
|
239177
239662
|
const base = basename6(abs);
|
|
239178
239663
|
if (!byBase.has(base)) byBase.set(base, []);
|
|
@@ -239181,7 +239666,7 @@ function buildPlasticBase(result, filePaths) {
|
|
|
239181
239666
|
}
|
|
239182
239667
|
}
|
|
239183
239668
|
return filePaths.map((filePath) => {
|
|
239184
|
-
const abs =
|
|
239669
|
+
const abs = resolve5(filePath);
|
|
239185
239670
|
const status = { filePath: abs, system: "plastic", writable: writableBit(abs) };
|
|
239186
239671
|
let info = byPath.get(abs);
|
|
239187
239672
|
if (!info) {
|
|
@@ -239288,6 +239773,22 @@ var SvnProvider = class {
|
|
|
239288
239773
|
get name() {
|
|
239289
239774
|
return "svn";
|
|
239290
239775
|
}
|
|
239776
|
+
/**
|
|
239777
|
+
* Undefined, deliberately.
|
|
239778
|
+
*
|
|
239779
|
+
* Unlike the others this provider never learns a username: it tells our lock from someone else's by
|
|
239780
|
+
* comparing the working copy's lock TOKEN against the server's, which needs no identity at all. The
|
|
239781
|
+
* only sources are `svn auth` (1.9+, a human-readable dump whose shape is not a contract) and the
|
|
239782
|
+
* `~/.subversion/auth` cache (an implementation detail of the client). Guessing wrong here is worse
|
|
239783
|
+
* than saying nothing, because the answer seeds an identity box the author then has to correct.
|
|
239784
|
+
*/
|
|
239785
|
+
currentUser() {
|
|
239786
|
+
return void 0;
|
|
239787
|
+
}
|
|
239788
|
+
/** Async twin of {@link currentUser}. */
|
|
239789
|
+
async currentUserAsync() {
|
|
239790
|
+
return void 0;
|
|
239791
|
+
}
|
|
239291
239792
|
prepareToWrite(filePath) {
|
|
239292
239793
|
if (!existsSync4(filePath)) return okResult();
|
|
239293
239794
|
const fsResult = fs3.prepareToWrite(filePath);
|
|
@@ -239475,7 +239976,7 @@ var SvnProvider = class {
|
|
|
239475
239976
|
}
|
|
239476
239977
|
};
|
|
239477
239978
|
function svnStatusArgs(filePaths, options) {
|
|
239478
|
-
const targets = filePaths.map((p) =>
|
|
239979
|
+
const targets = filePaths.map((p) => resolve5(p));
|
|
239479
239980
|
return ["status", "--xml", "-v", ...options.remote ? ["-u"] : [], ...targets];
|
|
239480
239981
|
}
|
|
239481
239982
|
function buildSvnStatuses(output, filePaths) {
|
|
@@ -239485,7 +239986,7 @@ function buildSvnStatuses(output, filePaths) {
|
|
|
239485
239986
|
const entryRe = /<entry\b[^>]*\bpath="([^"]*)"[^>]*>([\s\S]*?)<\/entry>/g;
|
|
239486
239987
|
let m;
|
|
239487
239988
|
while ((m = entryRe.exec(output)) !== null) {
|
|
239488
|
-
const entryPath =
|
|
239989
|
+
const entryPath = resolve5(decodeXmlAttr(m[1]));
|
|
239489
239990
|
const info = parseSvnEntry(m[2]);
|
|
239490
239991
|
if (!info) continue;
|
|
239491
239992
|
byPath.set(entryPath, info);
|
|
@@ -239495,7 +239996,7 @@ function buildSvnStatuses(output, filePaths) {
|
|
|
239495
239996
|
}
|
|
239496
239997
|
}
|
|
239497
239998
|
return filePaths.map((filePath) => {
|
|
239498
|
-
const abs =
|
|
239999
|
+
const abs = resolve5(filePath);
|
|
239499
240000
|
const status = { filePath: abs, system: "svn", writable: writableBit(abs) };
|
|
239500
240001
|
let info = byPath.get(abs);
|
|
239501
240002
|
if (!info) {
|
|
@@ -239569,7 +240070,7 @@ var PROVIDER_MAP = {
|
|
|
239569
240070
|
};
|
|
239570
240071
|
var _overrideProvider = null;
|
|
239571
240072
|
function dirOf(p) {
|
|
239572
|
-
const abs =
|
|
240073
|
+
const abs = resolve5(p);
|
|
239573
240074
|
try {
|
|
239574
240075
|
return statSync3(abs).isDirectory() ? abs : dirname5(abs);
|
|
239575
240076
|
} catch {
|
|
@@ -239584,7 +240085,7 @@ function resolveProvider(filePath) {
|
|
|
239584
240085
|
const factory = PROVIDER_MAP[config.system];
|
|
239585
240086
|
if (factory) return factory();
|
|
239586
240087
|
}
|
|
239587
|
-
const detected = detectProvider(
|
|
240088
|
+
const detected = detectProvider(resolve5(filePath));
|
|
239588
240089
|
return (PROVIDER_MAP[detected] ?? PROVIDER_MAP.filesystem)();
|
|
239589
240090
|
}
|
|
239590
240091
|
function deleteFile(filePath) {
|
|
@@ -239598,14 +240099,15 @@ function writeTextFile(filePath, content, encoding = "utf8", forceWrite = false)
|
|
|
239598
240099
|
} catch {
|
|
239599
240100
|
}
|
|
239600
240101
|
}
|
|
239601
|
-
const
|
|
240102
|
+
const provider = resolveProvider(filePath);
|
|
240103
|
+
const prep = provider.prepareToWrite(filePath);
|
|
239602
240104
|
if (!prep.success) return prep;
|
|
239603
240105
|
try {
|
|
239604
240106
|
writeFileSync2(filePath, content, { encoding });
|
|
239605
240107
|
} catch (e) {
|
|
239606
240108
|
return { success: false, status: "error", message: e.message };
|
|
239607
240109
|
}
|
|
239608
|
-
return
|
|
240110
|
+
return provider.finishedWrite(filePath);
|
|
239609
240111
|
}
|
|
239610
240112
|
function writeBinaryFile(filePath, data, forceWrite = false) {
|
|
239611
240113
|
if (!forceWrite && existsSync4(filePath)) {
|
|
@@ -239616,19 +240118,20 @@ function writeBinaryFile(filePath, data, forceWrite = false) {
|
|
|
239616
240118
|
} catch {
|
|
239617
240119
|
}
|
|
239618
240120
|
}
|
|
239619
|
-
const
|
|
240121
|
+
const provider = resolveProvider(filePath);
|
|
240122
|
+
const prep = provider.prepareToWrite(filePath);
|
|
239620
240123
|
if (!prep.success) return prep;
|
|
239621
240124
|
try {
|
|
239622
240125
|
writeFileSync2(filePath, data);
|
|
239623
240126
|
} catch (e) {
|
|
239624
240127
|
return { success: false, status: "error", message: e.message };
|
|
239625
240128
|
}
|
|
239626
|
-
return
|
|
240129
|
+
return provider.finishedWrite(filePath);
|
|
239627
240130
|
}
|
|
239628
240131
|
function writeTextFiles(files, encoding = "utf8") {
|
|
239629
240132
|
const results = files.map(({ filePath, content }) => {
|
|
239630
240133
|
try {
|
|
239631
|
-
mkdirSync2(dirname5(
|
|
240134
|
+
mkdirSync2(dirname5(resolve5(filePath)), { recursive: true });
|
|
239632
240135
|
} catch (e) {
|
|
239633
240136
|
return { filePath, success: false, status: "error", message: e.message };
|
|
239634
240137
|
}
|
|
@@ -240090,6 +240593,13 @@ ${count} issue(s)`);
|
|
|
240090
240593
|
return 2;
|
|
240091
240594
|
}
|
|
240092
240595
|
const res = await runUnpackMerge(readFileSync7(file), readFileSync7(flags.base), flags.o);
|
|
240596
|
+
if (!res.provenance.ok) {
|
|
240597
|
+
console.error("warning: these do not look like the same project");
|
|
240598
|
+
console.error(` returned pack: ${res.provenance.returned ?? "(no manifest)"}`);
|
|
240599
|
+
console.error(` base pack: ${res.provenance.base ?? "(no manifest)"}`);
|
|
240600
|
+
console.error(` project at -o: ${res.provenance.target ?? "(no project file)"}`);
|
|
240601
|
+
console.error(" merging anyway; expect spurious conflicts if the ancestor is wrong.");
|
|
240602
|
+
}
|
|
240093
240603
|
if (!commitWrites([...res.writes, ...res.sidecars])) return 1;
|
|
240094
240604
|
for (const s of res.shards) {
|
|
240095
240605
|
const n = s.result ? s.result.conflicts.length : 0;
|