@kubb/core 1.13.0 → 1.14.0-canary.20231020T164632
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/index.cjs +98 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -42
- package/dist/index.d.ts +20 -42
- package/dist/index.js +98 -91
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -210,61 +210,61 @@ async function timeout(ms) {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
var Queue = class {
|
|
213
|
-
queue = [];
|
|
214
|
-
workerCount = 0;
|
|
215
|
-
maxParallel;
|
|
216
|
-
debug = false;
|
|
213
|
+
#queue = [];
|
|
214
|
+
#workerCount = 0;
|
|
215
|
+
#maxParallel;
|
|
216
|
+
#debug = false;
|
|
217
217
|
constructor(maxParallel, debug = false) {
|
|
218
|
-
this
|
|
219
|
-
this
|
|
218
|
+
this.#maxParallel = maxParallel;
|
|
219
|
+
this.#debug = debug;
|
|
220
220
|
}
|
|
221
221
|
run(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
222
222
|
return new Promise((resolve, reject) => {
|
|
223
223
|
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
224
224
|
options.controller?.signal.addEventListener("abort", () => {
|
|
225
|
-
this
|
|
225
|
+
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
226
226
|
reject("Aborted");
|
|
227
227
|
});
|
|
228
|
-
this
|
|
229
|
-
this
|
|
228
|
+
this.#queue.push(item);
|
|
229
|
+
this.#work();
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
runSync(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
233
233
|
new Promise((resolve, reject) => {
|
|
234
234
|
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
235
235
|
options.controller?.signal.addEventListener("abort", () => {
|
|
236
|
-
this
|
|
236
|
+
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
237
237
|
});
|
|
238
|
-
this
|
|
239
|
-
this
|
|
238
|
+
this.#queue.push(item);
|
|
239
|
+
this.#work();
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
get hasJobs() {
|
|
243
|
-
return this
|
|
243
|
+
return this.#workerCount > 0 || this.#queue.length > 0;
|
|
244
244
|
}
|
|
245
245
|
get count() {
|
|
246
|
-
return this
|
|
246
|
+
return this.#workerCount;
|
|
247
247
|
}
|
|
248
|
-
work() {
|
|
249
|
-
if (this
|
|
248
|
+
#work() {
|
|
249
|
+
if (this.#workerCount >= this.#maxParallel) {
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
-
this
|
|
252
|
+
this.#workerCount++;
|
|
253
253
|
let entry;
|
|
254
|
-
while (entry = this
|
|
254
|
+
while (entry = this.#queue.shift()) {
|
|
255
255
|
const { reject, resolve, job, name, description } = entry;
|
|
256
|
-
if (this
|
|
256
|
+
if (this.#debug) {
|
|
257
257
|
perf_hooks.performance.mark(name + "_start");
|
|
258
258
|
}
|
|
259
259
|
job().then((result) => {
|
|
260
260
|
resolve(result);
|
|
261
|
-
if (this
|
|
261
|
+
if (this.#debug) {
|
|
262
262
|
perf_hooks.performance.mark(name + "_stop");
|
|
263
263
|
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
264
264
|
}
|
|
265
265
|
}).catch((err) => reject(err));
|
|
266
266
|
}
|
|
267
|
-
this
|
|
267
|
+
this.#workerCount--;
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
270
|
|
|
@@ -987,13 +987,13 @@ function getEnvSource(source, env) {
|
|
|
987
987
|
|
|
988
988
|
// src/managers/fileManager/FileManager.ts
|
|
989
989
|
var FileManager = class {
|
|
990
|
-
cache = /* @__PURE__ */ new Map();
|
|
991
|
-
task;
|
|
992
|
-
queue;
|
|
990
|
+
#cache = /* @__PURE__ */ new Map();
|
|
991
|
+
#task;
|
|
992
|
+
#queue;
|
|
993
993
|
constructor(options) {
|
|
994
994
|
if (options) {
|
|
995
|
-
this
|
|
996
|
-
this
|
|
995
|
+
this.#task = options.task;
|
|
996
|
+
this.#queue = options.queue;
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
999
|
get extensions() {
|
|
@@ -1001,23 +1001,23 @@ var FileManager = class {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
get files() {
|
|
1003
1003
|
const files = [];
|
|
1004
|
-
this
|
|
1004
|
+
this.#cache.forEach((item) => {
|
|
1005
1005
|
files.push(...item.flat(1));
|
|
1006
1006
|
});
|
|
1007
1007
|
return files;
|
|
1008
1008
|
}
|
|
1009
1009
|
get isExecuting() {
|
|
1010
|
-
return this
|
|
1010
|
+
return this.#queue?.hasJobs ?? false;
|
|
1011
1011
|
}
|
|
1012
1012
|
async add(file) {
|
|
1013
1013
|
const controller = new AbortController();
|
|
1014
1014
|
const resolvedFile = { id: crypto__default.default.randomUUID(), ...file };
|
|
1015
|
-
this
|
|
1016
|
-
if (this
|
|
1015
|
+
this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
1016
|
+
if (this.#queue) {
|
|
1017
1017
|
try {
|
|
1018
|
-
await this
|
|
1018
|
+
await this.#queue.run(
|
|
1019
1019
|
async () => {
|
|
1020
|
-
return this
|
|
1020
|
+
return this.#task?.(resolvedFile);
|
|
1021
1021
|
},
|
|
1022
1022
|
{ controller }
|
|
1023
1023
|
);
|
|
@@ -1028,10 +1028,10 @@ var FileManager = class {
|
|
|
1028
1028
|
return resolvedFile;
|
|
1029
1029
|
}
|
|
1030
1030
|
addOrAppend(file) {
|
|
1031
|
-
const previousCaches = this
|
|
1031
|
+
const previousCaches = this.#cache.get(file.path);
|
|
1032
1032
|
const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
|
|
1033
1033
|
if (previousCache) {
|
|
1034
|
-
this
|
|
1034
|
+
this.#cache.delete(previousCache.path);
|
|
1035
1035
|
return this.add({
|
|
1036
1036
|
...file,
|
|
1037
1037
|
source: previousCache.source && file.source ? `${previousCache.source}
|
|
@@ -1043,38 +1043,38 @@ ${file.source}` : "",
|
|
|
1043
1043
|
}
|
|
1044
1044
|
return this.add(file);
|
|
1045
1045
|
}
|
|
1046
|
-
append(path3, file) {
|
|
1047
|
-
const previousFiles = this
|
|
1048
|
-
this
|
|
1046
|
+
#append(path3, file) {
|
|
1047
|
+
const previousFiles = this.#cache.get(path3) || [];
|
|
1048
|
+
this.#cache.set(path3, [...previousFiles, file]);
|
|
1049
1049
|
}
|
|
1050
1050
|
getCacheByUUID(UUID) {
|
|
1051
1051
|
let cache;
|
|
1052
|
-
this
|
|
1052
|
+
this.#cache.forEach((files) => {
|
|
1053
1053
|
cache = files.find((item) => item.id === UUID);
|
|
1054
1054
|
});
|
|
1055
1055
|
return cache;
|
|
1056
1056
|
}
|
|
1057
1057
|
get(path3) {
|
|
1058
|
-
return this
|
|
1058
|
+
return this.#cache.get(path3);
|
|
1059
1059
|
}
|
|
1060
1060
|
remove(path3) {
|
|
1061
1061
|
const cacheItem = this.get(path3);
|
|
1062
1062
|
if (!cacheItem) {
|
|
1063
1063
|
return;
|
|
1064
1064
|
}
|
|
1065
|
-
this
|
|
1065
|
+
this.#cache.delete(path3);
|
|
1066
1066
|
}
|
|
1067
1067
|
async write(...params) {
|
|
1068
|
-
if (this
|
|
1069
|
-
return this
|
|
1068
|
+
if (this.#queue) {
|
|
1069
|
+
return this.#queue.run(async () => {
|
|
1070
1070
|
return write(...params);
|
|
1071
1071
|
});
|
|
1072
1072
|
}
|
|
1073
1073
|
return write(...params);
|
|
1074
1074
|
}
|
|
1075
1075
|
async read(...params) {
|
|
1076
|
-
if (this
|
|
1077
|
-
return this
|
|
1076
|
+
if (this.#queue) {
|
|
1077
|
+
return this.#queue.run(async () => {
|
|
1078
1078
|
return read(...params);
|
|
1079
1079
|
});
|
|
1080
1080
|
}
|
|
@@ -1138,20 +1138,20 @@ var definePlugin = createPlugin((options) => {
|
|
|
1138
1138
|
});
|
|
1139
1139
|
var EventEmitter = class {
|
|
1140
1140
|
constructor() {
|
|
1141
|
-
this
|
|
1141
|
+
this.#emitter.setMaxListeners(100);
|
|
1142
1142
|
}
|
|
1143
|
-
emitter = new events.EventEmitter();
|
|
1143
|
+
#emitter = new events.EventEmitter();
|
|
1144
1144
|
emit(eventName, ...eventArg) {
|
|
1145
|
-
this
|
|
1145
|
+
this.#emitter.emit(eventName, ...eventArg);
|
|
1146
1146
|
}
|
|
1147
1147
|
on(eventName, handler) {
|
|
1148
|
-
this
|
|
1148
|
+
this.#emitter.on(eventName, handler);
|
|
1149
1149
|
}
|
|
1150
1150
|
off(eventName, handler) {
|
|
1151
|
-
this
|
|
1151
|
+
this.#emitter.off(eventName, handler);
|
|
1152
1152
|
}
|
|
1153
1153
|
removeAll() {
|
|
1154
|
-
this
|
|
1154
|
+
this.#emitter.removeAllListeners();
|
|
1155
1155
|
}
|
|
1156
1156
|
};
|
|
1157
1157
|
|
|
@@ -1224,7 +1224,7 @@ var PluginManager = class {
|
|
|
1224
1224
|
queue;
|
|
1225
1225
|
executed = [];
|
|
1226
1226
|
logger;
|
|
1227
|
-
core;
|
|
1227
|
+
#core;
|
|
1228
1228
|
constructor(config, options) {
|
|
1229
1229
|
this.logger = options.logger;
|
|
1230
1230
|
this.queue = new Queue(100, options.debug);
|
|
@@ -1236,11 +1236,11 @@ var PluginManager = class {
|
|
|
1236
1236
|
fileManager: this.fileManager,
|
|
1237
1237
|
resolvePath: this.resolvePath.bind(this),
|
|
1238
1238
|
resolveName: this.resolveName.bind(this),
|
|
1239
|
-
getPlugins: this
|
|
1239
|
+
getPlugins: this.#getSortedPlugins.bind(this)
|
|
1240
1240
|
});
|
|
1241
|
-
this
|
|
1242
|
-
this.plugins = [this
|
|
1243
|
-
const convertedApi = pluginParser(plugin, this
|
|
1241
|
+
this.#core = pluginParser(core, core.api.call(null));
|
|
1242
|
+
this.plugins = [this.#core, ...config.plugins || []].reduce((prev, plugin) => {
|
|
1243
|
+
const convertedApi = pluginParser(plugin, this.#core?.api);
|
|
1244
1244
|
if (convertedApi) {
|
|
1245
1245
|
return [...prev, convertedApi];
|
|
1246
1246
|
}
|
|
@@ -1288,7 +1288,7 @@ var PluginManager = class {
|
|
|
1288
1288
|
parameters
|
|
1289
1289
|
}) {
|
|
1290
1290
|
const plugin = this.getPlugin(hookName, pluginName2);
|
|
1291
|
-
return this
|
|
1291
|
+
return this.#execute({
|
|
1292
1292
|
strategy: "hookFirst",
|
|
1293
1293
|
hookName,
|
|
1294
1294
|
parameters,
|
|
@@ -1301,7 +1301,7 @@ var PluginManager = class {
|
|
|
1301
1301
|
parameters
|
|
1302
1302
|
}) {
|
|
1303
1303
|
const plugin = this.getPlugin(hookName, pluginName2);
|
|
1304
|
-
return this
|
|
1304
|
+
return this.#executeSync({
|
|
1305
1305
|
strategy: "hookFirst",
|
|
1306
1306
|
hookName,
|
|
1307
1307
|
parameters,
|
|
@@ -1318,7 +1318,7 @@ var PluginManager = class {
|
|
|
1318
1318
|
skipped
|
|
1319
1319
|
}) {
|
|
1320
1320
|
let promise = Promise.resolve(null);
|
|
1321
|
-
for (const plugin of this
|
|
1321
|
+
for (const plugin of this.#getSortedPlugins()) {
|
|
1322
1322
|
if (skipped && skipped.has(plugin)) {
|
|
1323
1323
|
continue;
|
|
1324
1324
|
}
|
|
@@ -1326,7 +1326,7 @@ var PluginManager = class {
|
|
|
1326
1326
|
if (parseResult?.result != null) {
|
|
1327
1327
|
return parseResult;
|
|
1328
1328
|
}
|
|
1329
|
-
const value = await this
|
|
1329
|
+
const value = await this.#execute({
|
|
1330
1330
|
strategy: "hookFirst",
|
|
1331
1331
|
hookName,
|
|
1332
1332
|
parameters,
|
|
@@ -1350,12 +1350,12 @@ var PluginManager = class {
|
|
|
1350
1350
|
skipped
|
|
1351
1351
|
}) {
|
|
1352
1352
|
let parseResult = null;
|
|
1353
|
-
for (const plugin of this
|
|
1353
|
+
for (const plugin of this.#getSortedPlugins()) {
|
|
1354
1354
|
if (skipped && skipped.has(plugin)) {
|
|
1355
1355
|
continue;
|
|
1356
1356
|
}
|
|
1357
1357
|
parseResult = {
|
|
1358
|
-
result: this
|
|
1358
|
+
result: this.#executeSync({
|
|
1359
1359
|
strategy: "hookFirst",
|
|
1360
1360
|
hookName,
|
|
1361
1361
|
parameters,
|
|
@@ -1378,8 +1378,8 @@ var PluginManager = class {
|
|
|
1378
1378
|
parameters
|
|
1379
1379
|
}) {
|
|
1380
1380
|
const parallelPromises = [];
|
|
1381
|
-
for (const plugin of this
|
|
1382
|
-
const promise = this
|
|
1381
|
+
for (const plugin of this.#getSortedPlugins()) {
|
|
1382
|
+
const promise = this.#execute({ strategy: "hookParallel", hookName, parameters, plugin });
|
|
1383
1383
|
if (promise) {
|
|
1384
1384
|
parallelPromises.push(promise);
|
|
1385
1385
|
}
|
|
@@ -1407,16 +1407,16 @@ var PluginManager = class {
|
|
|
1407
1407
|
}) {
|
|
1408
1408
|
const [argument0, ...rest] = parameters;
|
|
1409
1409
|
let promise = Promise.resolve(argument0);
|
|
1410
|
-
for (const plugin of this
|
|
1410
|
+
for (const plugin of this.#getSortedPlugins()) {
|
|
1411
1411
|
promise = promise.then((arg0) => {
|
|
1412
|
-
const value = this
|
|
1412
|
+
const value = this.#execute({
|
|
1413
1413
|
strategy: "hookReduceArg0",
|
|
1414
1414
|
hookName,
|
|
1415
1415
|
parameters: [arg0, ...rest],
|
|
1416
1416
|
plugin
|
|
1417
1417
|
});
|
|
1418
1418
|
return value;
|
|
1419
|
-
}).then((result) => reduce.call(this
|
|
1419
|
+
}).then((result) => reduce.call(this.#core.api, argument0, result, plugin));
|
|
1420
1420
|
}
|
|
1421
1421
|
return promise;
|
|
1422
1422
|
}
|
|
@@ -1425,9 +1425,9 @@ var PluginManager = class {
|
|
|
1425
1425
|
*/
|
|
1426
1426
|
hookSeq({ hookName, parameters }) {
|
|
1427
1427
|
let promise = Promise.resolve();
|
|
1428
|
-
for (const plugin of this
|
|
1428
|
+
for (const plugin of this.#getSortedPlugins()) {
|
|
1429
1429
|
promise = promise.then(
|
|
1430
|
-
() => this
|
|
1430
|
+
() => this.#execute({
|
|
1431
1431
|
strategy: "hookSeq",
|
|
1432
1432
|
hookName,
|
|
1433
1433
|
parameters,
|
|
@@ -1437,7 +1437,7 @@ var PluginManager = class {
|
|
|
1437
1437
|
}
|
|
1438
1438
|
return promise.then(noReturn);
|
|
1439
1439
|
}
|
|
1440
|
-
getSortedPlugins(hookName) {
|
|
1440
|
+
#getSortedPlugins(hookName) {
|
|
1441
1441
|
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
1442
1442
|
if (hookName) {
|
|
1443
1443
|
return plugins.filter((item) => item[hookName]);
|
|
@@ -1448,11 +1448,11 @@ var PluginManager = class {
|
|
|
1448
1448
|
const plugins = [...this.plugins];
|
|
1449
1449
|
const pluginByPluginName = plugins.find((item) => item.name === pluginName2 && item[hookName]);
|
|
1450
1450
|
if (!pluginByPluginName) {
|
|
1451
|
-
return this
|
|
1451
|
+
return this.#core;
|
|
1452
1452
|
}
|
|
1453
1453
|
return pluginByPluginName;
|
|
1454
1454
|
}
|
|
1455
|
-
addExecutedToCallStack(executer) {
|
|
1455
|
+
#addExecutedToCallStack(executer) {
|
|
1456
1456
|
if (executer) {
|
|
1457
1457
|
this.eventEmitter.emit("execute", executer);
|
|
1458
1458
|
this.executed.push(executer);
|
|
@@ -1465,7 +1465,7 @@ var PluginManager = class {
|
|
|
1465
1465
|
* @param plugin The actual pluginObject to run.
|
|
1466
1466
|
*/
|
|
1467
1467
|
// Implementation signature
|
|
1468
|
-
execute({
|
|
1468
|
+
#execute({
|
|
1469
1469
|
strategy,
|
|
1470
1470
|
hookName,
|
|
1471
1471
|
parameters,
|
|
@@ -1479,7 +1479,7 @@ var PluginManager = class {
|
|
|
1479
1479
|
this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1480
1480
|
const task = Promise.resolve().then(() => {
|
|
1481
1481
|
if (typeof hook === "function") {
|
|
1482
|
-
const possiblePromiseResult = hook.apply(this
|
|
1482
|
+
const possiblePromiseResult = hook.apply(this.#core.api, parameters);
|
|
1483
1483
|
if (isPromise(possiblePromiseResult)) {
|
|
1484
1484
|
return Promise.resolve(possiblePromiseResult);
|
|
1485
1485
|
}
|
|
@@ -1490,10 +1490,10 @@ var PluginManager = class {
|
|
|
1490
1490
|
output = result;
|
|
1491
1491
|
return result;
|
|
1492
1492
|
}).catch((e) => {
|
|
1493
|
-
this
|
|
1493
|
+
this.#catcher(e, plugin, hookName);
|
|
1494
1494
|
return null;
|
|
1495
1495
|
}).finally(() => {
|
|
1496
|
-
this
|
|
1496
|
+
this.#addExecutedToCallStack({
|
|
1497
1497
|
parameters,
|
|
1498
1498
|
output,
|
|
1499
1499
|
strategy,
|
|
@@ -1510,7 +1510,7 @@ var PluginManager = class {
|
|
|
1510
1510
|
* @param plugin The acutal plugin
|
|
1511
1511
|
* @param replaceContext When passed, the plugin context can be overridden.
|
|
1512
1512
|
*/
|
|
1513
|
-
executeSync({
|
|
1513
|
+
#executeSync({
|
|
1514
1514
|
strategy,
|
|
1515
1515
|
hookName,
|
|
1516
1516
|
parameters,
|
|
@@ -1524,17 +1524,17 @@ var PluginManager = class {
|
|
|
1524
1524
|
this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1525
1525
|
try {
|
|
1526
1526
|
if (typeof hook === "function") {
|
|
1527
|
-
const fn = hook.apply(this
|
|
1527
|
+
const fn = hook.apply(this.#core.api, parameters);
|
|
1528
1528
|
output = fn;
|
|
1529
1529
|
return fn;
|
|
1530
1530
|
}
|
|
1531
1531
|
output = hook;
|
|
1532
1532
|
return hook;
|
|
1533
1533
|
} catch (e) {
|
|
1534
|
-
this
|
|
1534
|
+
this.#catcher(e, plugin, hookName);
|
|
1535
1535
|
return null;
|
|
1536
1536
|
} finally {
|
|
1537
|
-
this
|
|
1537
|
+
this.#addExecutedToCallStack({
|
|
1538
1538
|
parameters,
|
|
1539
1539
|
output,
|
|
1540
1540
|
strategy,
|
|
@@ -1543,7 +1543,7 @@ var PluginManager = class {
|
|
|
1543
1543
|
});
|
|
1544
1544
|
}
|
|
1545
1545
|
}
|
|
1546
|
-
catcher(e, plugin, hookName) {
|
|
1546
|
+
#catcher(e, plugin, hookName) {
|
|
1547
1547
|
const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
|
|
1548
1548
|
`;
|
|
1549
1549
|
const pluginError = new PluginError(text, { cause: e, pluginManager: this });
|
|
@@ -1935,14 +1935,14 @@ function findUpSync(name, options = {}) {
|
|
|
1935
1935
|
return matches[0];
|
|
1936
1936
|
}
|
|
1937
1937
|
var PackageManager = class {
|
|
1938
|
-
cwd;
|
|
1938
|
+
#cwd;
|
|
1939
1939
|
constructor(workspace = process.cwd()) {
|
|
1940
|
-
this
|
|
1940
|
+
this.#cwd = workspace;
|
|
1941
1941
|
return this;
|
|
1942
1942
|
}
|
|
1943
1943
|
async getPackageJSON() {
|
|
1944
1944
|
const pkgPath = await findUp(["package.json"], {
|
|
1945
|
-
cwd: this
|
|
1945
|
+
cwd: this.#cwd
|
|
1946
1946
|
});
|
|
1947
1947
|
if (!pkgPath) {
|
|
1948
1948
|
return void 0;
|
|
@@ -1951,7 +1951,7 @@ var PackageManager = class {
|
|
|
1951
1951
|
}
|
|
1952
1952
|
getPackageJSONSync() {
|
|
1953
1953
|
const pkgPath = findUpSync(["package.json"], {
|
|
1954
|
-
cwd: this
|
|
1954
|
+
cwd: this.#cwd
|
|
1955
1955
|
});
|
|
1956
1956
|
if (!pkgPath) {
|
|
1957
1957
|
return void 0;
|
|
@@ -1998,18 +1998,25 @@ var PackageManager = class {
|
|
|
1998
1998
|
|
|
1999
1999
|
// src/generators/Generator.ts
|
|
2000
2000
|
var Generator = class {
|
|
2001
|
-
|
|
2002
|
-
|
|
2001
|
+
#options = {};
|
|
2002
|
+
#context = {};
|
|
2003
|
+
constructor(options, context) {
|
|
2004
|
+
if (context) {
|
|
2005
|
+
this.#context = context;
|
|
2006
|
+
}
|
|
2003
2007
|
if (options) {
|
|
2004
|
-
this
|
|
2005
|
-
...this._options,
|
|
2006
|
-
...options
|
|
2007
|
-
};
|
|
2008
|
+
this.#options = options;
|
|
2008
2009
|
}
|
|
2009
2010
|
return this;
|
|
2010
2011
|
}
|
|
2011
2012
|
get options() {
|
|
2012
|
-
return this
|
|
2013
|
+
return this.#options;
|
|
2014
|
+
}
|
|
2015
|
+
get context() {
|
|
2016
|
+
return this.#context;
|
|
2017
|
+
}
|
|
2018
|
+
set options(options) {
|
|
2019
|
+
this.#options = { ...this.#options, ...options };
|
|
2013
2020
|
}
|
|
2014
2021
|
};
|
|
2015
2022
|
|