mtranserver 4.0.19 → 4.0.20

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/main.js CHANGED
@@ -6171,11 +6171,11 @@ class Stack {
6171
6171
  return this.heap[--this.length];
6172
6172
  }
6173
6173
  }
6174
- var perf, warned, PROCESS, emitWarning = (msg, type, code, fn) => {
6174
+ var defaultPerf, warned, PROCESS, emitWarning = (msg, type, code, fn) => {
6175
6175
  typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
6176
6176
  }, AC, AS, shouldWarn = (code) => !warned.has(code), TYPE, isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n), getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null, ZeroArray, LRUCache;
6177
6177
  var init_esm2 = __esm(() => {
6178
- perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
6178
+ defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
6179
6179
  warned = new Set;
6180
6180
  PROCESS = typeof process === "object" && !!process ? process : {};
6181
6181
  AC = globalThis.AbortController;
@@ -6225,9 +6225,14 @@ var init_esm2 = __esm(() => {
6225
6225
  #max;
6226
6226
  #maxSize;
6227
6227
  #dispose;
6228
+ #onInsert;
6228
6229
  #disposeAfter;
6229
6230
  #fetchMethod;
6230
6231
  #memoMethod;
6232
+ #perf;
6233
+ get perf() {
6234
+ return this.#perf;
6235
+ }
6231
6236
  ttl;
6232
6237
  ttlResolution;
6233
6238
  ttlAutopurge;
@@ -6257,13 +6262,16 @@ var init_esm2 = __esm(() => {
6257
6262
  #sizes;
6258
6263
  #starts;
6259
6264
  #ttls;
6265
+ #autopurgeTimers;
6260
6266
  #hasDispose;
6261
6267
  #hasFetchMethod;
6262
6268
  #hasDisposeAfter;
6269
+ #hasOnInsert;
6263
6270
  static unsafeExposeInternals(c) {
6264
6271
  return {
6265
6272
  starts: c.#starts,
6266
6273
  ttls: c.#ttls,
6274
+ autopurgeTimers: c.#autopurgeTimers,
6267
6275
  sizes: c.#sizes,
6268
6276
  keyMap: c.#keyMap,
6269
6277
  keyList: c.#keyList,
@@ -6306,11 +6314,20 @@ var init_esm2 = __esm(() => {
6306
6314
  get dispose() {
6307
6315
  return this.#dispose;
6308
6316
  }
6317
+ get onInsert() {
6318
+ return this.#onInsert;
6319
+ }
6309
6320
  get disposeAfter() {
6310
6321
  return this.#disposeAfter;
6311
6322
  }
6312
6323
  constructor(options) {
6313
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
6324
+ const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options;
6325
+ if (perf !== undefined) {
6326
+ if (typeof perf?.now !== "function") {
6327
+ throw new TypeError("perf option must have a now() method if specified");
6328
+ }
6329
+ }
6330
+ this.#perf = perf ?? defaultPerf;
6314
6331
  if (max !== 0 && !isPosInt(max)) {
6315
6332
  throw new TypeError("max option must be a nonnegative integer");
6316
6333
  }
@@ -6352,6 +6369,9 @@ var init_esm2 = __esm(() => {
6352
6369
  if (typeof dispose === "function") {
6353
6370
  this.#dispose = dispose;
6354
6371
  }
6372
+ if (typeof onInsert === "function") {
6373
+ this.#onInsert = onInsert;
6374
+ }
6355
6375
  if (typeof disposeAfter === "function") {
6356
6376
  this.#disposeAfter = disposeAfter;
6357
6377
  this.#disposed = [];
@@ -6360,6 +6380,7 @@ var init_esm2 = __esm(() => {
6360
6380
  this.#disposed = undefined;
6361
6381
  }
6362
6382
  this.#hasDispose = !!this.#dispose;
6383
+ this.#hasOnInsert = !!this.#onInsert;
6363
6384
  this.#hasDisposeAfter = !!this.#disposeAfter;
6364
6385
  this.noDisposeOnSet = !!noDisposeOnSet;
6365
6386
  this.noUpdateTTL = !!noUpdateTTL;
@@ -6411,10 +6432,16 @@ var init_esm2 = __esm(() => {
6411
6432
  const starts = new ZeroArray(this.#max);
6412
6433
  this.#ttls = ttls;
6413
6434
  this.#starts = starts;
6414
- this.#setItemTTL = (index, ttl, start = perf.now()) => {
6435
+ const purgeTimers = this.ttlAutopurge ? new Array(this.#max) : undefined;
6436
+ this.#autopurgeTimers = purgeTimers;
6437
+ this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
6415
6438
  starts[index] = ttl !== 0 ? start : 0;
6416
6439
  ttls[index] = ttl;
6417
- if (ttl !== 0 && this.ttlAutopurge) {
6440
+ if (purgeTimers?.[index]) {
6441
+ clearTimeout(purgeTimers[index]);
6442
+ purgeTimers[index] = undefined;
6443
+ }
6444
+ if (ttl !== 0 && purgeTimers) {
6418
6445
  const t = setTimeout(() => {
6419
6446
  if (this.#isStale(index)) {
6420
6447
  this.#delete(this.#keyList[index], "expire");
@@ -6423,10 +6450,11 @@ var init_esm2 = __esm(() => {
6423
6450
  if (t.unref) {
6424
6451
  t.unref();
6425
6452
  }
6453
+ purgeTimers[index] = t;
6426
6454
  }
6427
6455
  };
6428
6456
  this.#updateItemAge = (index) => {
6429
- starts[index] = ttls[index] !== 0 ? perf.now() : 0;
6457
+ starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
6430
6458
  };
6431
6459
  this.#statusTTL = (status, index) => {
6432
6460
  if (ttls[index]) {
@@ -6443,7 +6471,7 @@ var init_esm2 = __esm(() => {
6443
6471
  };
6444
6472
  let cachedNow = 0;
6445
6473
  const getNow = () => {
6446
- const n = perf.now();
6474
+ const n = this.#perf.now();
6447
6475
  if (this.ttlResolution > 0) {
6448
6476
  cachedNow = n;
6449
6477
  const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
@@ -6665,7 +6693,7 @@ var init_esm2 = __esm(() => {
6665
6693
  const ttl = this.#ttls[i];
6666
6694
  const start = this.#starts[i];
6667
6695
  if (ttl && start) {
6668
- const remain = ttl - (perf.now() - start);
6696
+ const remain = ttl - (this.#perf.now() - start);
6669
6697
  entry.ttl = remain;
6670
6698
  entry.start = Date.now();
6671
6699
  }
@@ -6686,7 +6714,7 @@ var init_esm2 = __esm(() => {
6686
6714
  const entry = { value };
6687
6715
  if (this.#ttls && this.#starts) {
6688
6716
  entry.ttl = this.#ttls[i];
6689
- const age = perf.now() - this.#starts[i];
6717
+ const age = this.#perf.now() - this.#starts[i];
6690
6718
  entry.start = Math.floor(Date.now() - age);
6691
6719
  }
6692
6720
  if (this.#sizes) {
@@ -6701,7 +6729,7 @@ var init_esm2 = __esm(() => {
6701
6729
  for (const [key, entry] of arr) {
6702
6730
  if (entry.start) {
6703
6731
  const age = Date.now() - entry.start;
6704
- entry.start = perf.now() - age;
6732
+ entry.start = this.#perf.now() - age;
6705
6733
  }
6706
6734
  this.set(key, entry.value, entry);
6707
6735
  }
@@ -6736,6 +6764,9 @@ var init_esm2 = __esm(() => {
6736
6764
  if (status)
6737
6765
  status.set = "add";
6738
6766
  noUpdateTTL = false;
6767
+ if (this.#hasOnInsert) {
6768
+ this.#onInsert?.(v, k, "add");
6769
+ }
6739
6770
  } else {
6740
6771
  this.#moveToTail(index);
6741
6772
  const oldVal = this.#valList[index];
@@ -6771,6 +6802,9 @@ var init_esm2 = __esm(() => {
6771
6802
  } else if (status) {
6772
6803
  status.set = "update";
6773
6804
  }
6805
+ if (this.#hasOnInsert) {
6806
+ this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
6807
+ }
6774
6808
  }
6775
6809
  if (ttl !== 0 && !this.#ttls) {
6776
6810
  this.#initializeTTLTracking();
@@ -6829,6 +6863,10 @@ var init_esm2 = __esm(() => {
6829
6863
  }
6830
6864
  }
6831
6865
  this.#removeItemSize(head);
6866
+ if (this.#autopurgeTimers?.[head]) {
6867
+ clearTimeout(this.#autopurgeTimers[head]);
6868
+ this.#autopurgeTimers[head] = undefined;
6869
+ }
6832
6870
  if (free) {
6833
6871
  this.#keyList[head] = undefined;
6834
6872
  this.#valList[head] = undefined;
@@ -6911,9 +6949,10 @@ var init_esm2 = __esm(() => {
6911
6949
  return fetchFail(ac.signal.reason);
6912
6950
  }
6913
6951
  const bf2 = p;
6914
- if (this.#valList[index] === p) {
6952
+ const vl = this.#valList[index];
6953
+ if (vl === p || ignoreAbort && updateCache && vl === undefined) {
6915
6954
  if (v2 === undefined) {
6916
- if (bf2.__staleWhileFetching) {
6955
+ if (bf2.__staleWhileFetching !== undefined) {
6917
6956
  this.#valList[index] = bf2.__staleWhileFetching;
6918
6957
  } else {
6919
6958
  this.#delete(k, "fetch");
@@ -7162,6 +7201,10 @@ var init_esm2 = __esm(() => {
7162
7201
  if (this.#size !== 0) {
7163
7202
  const index = this.#keyMap.get(k);
7164
7203
  if (index !== undefined) {
7204
+ if (this.#autopurgeTimers?.[index]) {
7205
+ clearTimeout(this.#autopurgeTimers?.[index]);
7206
+ this.#autopurgeTimers[index] = undefined;
7207
+ }
7165
7208
  deleted = true;
7166
7209
  if (this.#size === 1) {
7167
7210
  this.#clear(reason);
@@ -7229,6 +7272,11 @@ var init_esm2 = __esm(() => {
7229
7272
  if (this.#ttls && this.#starts) {
7230
7273
  this.#ttls.fill(0);
7231
7274
  this.#starts.fill(0);
7275
+ for (const t of this.#autopurgeTimers ?? []) {
7276
+ if (t !== undefined)
7277
+ clearTimeout(t);
7278
+ }
7279
+ this.#autopurgeTimers?.fill(undefined);
7232
7280
  }
7233
7281
  if (this.#sizes) {
7234
7282
  this.#sizes.fill(0);
@@ -193920,11 +193968,11 @@ var require_decoratorUtils = __commonJS((exports) => {
193920
193968
  }
193921
193969
  });
193922
193970
 
193923
- // node_modules/lru-cache/dist/commonjs/index.js
193971
+ // node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js
193924
193972
  var require_commonjs2 = __commonJS((exports) => {
193925
193973
  Object.defineProperty(exports, "__esModule", { value: true });
193926
193974
  exports.LRUCache = undefined;
193927
- var perf2 = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
193975
+ var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
193928
193976
  var warned2 = new Set;
193929
193977
  var PROCESS2 = typeof process === "object" && !!process ? process : {};
193930
193978
  var emitWarning2 = (msg, type, code, fn) => {
@@ -194196,7 +194244,7 @@ var require_commonjs2 = __commonJS((exports) => {
194196
194244
  const starts = new ZeroArray2(this.#max);
194197
194245
  this.#ttls = ttls;
194198
194246
  this.#starts = starts;
194199
- this.#setItemTTL = (index, ttl, start = perf2.now()) => {
194247
+ this.#setItemTTL = (index, ttl, start = perf.now()) => {
194200
194248
  starts[index] = ttl !== 0 ? start : 0;
194201
194249
  ttls[index] = ttl;
194202
194250
  if (ttl !== 0 && this.ttlAutopurge) {
@@ -194211,7 +194259,7 @@ var require_commonjs2 = __commonJS((exports) => {
194211
194259
  }
194212
194260
  };
194213
194261
  this.#updateItemAge = (index) => {
194214
- starts[index] = ttls[index] !== 0 ? perf2.now() : 0;
194262
+ starts[index] = ttls[index] !== 0 ? perf.now() : 0;
194215
194263
  };
194216
194264
  this.#statusTTL = (status, index) => {
194217
194265
  if (ttls[index]) {
@@ -194228,7 +194276,7 @@ var require_commonjs2 = __commonJS((exports) => {
194228
194276
  };
194229
194277
  let cachedNow = 0;
194230
194278
  const getNow = () => {
194231
- const n = perf2.now();
194279
+ const n = perf.now();
194232
194280
  if (this.ttlResolution > 0) {
194233
194281
  cachedNow = n;
194234
194282
  const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
@@ -194450,7 +194498,7 @@ var require_commonjs2 = __commonJS((exports) => {
194450
194498
  const ttl = this.#ttls[i];
194451
194499
  const start = this.#starts[i];
194452
194500
  if (ttl && start) {
194453
- const remain = ttl - (perf2.now() - start);
194501
+ const remain = ttl - (perf.now() - start);
194454
194502
  entry.ttl = remain;
194455
194503
  entry.start = Date.now();
194456
194504
  }
@@ -194471,7 +194519,7 @@ var require_commonjs2 = __commonJS((exports) => {
194471
194519
  const entry = { value };
194472
194520
  if (this.#ttls && this.#starts) {
194473
194521
  entry.ttl = this.#ttls[i];
194474
- const age = perf2.now() - this.#starts[i];
194522
+ const age = perf.now() - this.#starts[i];
194475
194523
  entry.start = Math.floor(Date.now() - age);
194476
194524
  }
194477
194525
  if (this.#sizes) {
@@ -194486,7 +194534,7 @@ var require_commonjs2 = __commonJS((exports) => {
194486
194534
  for (const [key, entry] of arr) {
194487
194535
  if (entry.start) {
194488
194536
  const age = Date.now() - entry.start;
194489
- entry.start = perf2.now() - age;
194537
+ entry.start = perf.now() - age;
194490
194538
  }
194491
194539
  this.set(key, entry.value, entry);
194492
194540
  }
@@ -214379,7 +214427,7 @@ __export(exports_version, {
214379
214427
  function getVersion() {
214380
214428
  return VERSION;
214381
214429
  }
214382
- var VERSION = "4.0.19";
214430
+ var VERSION = "4.0.20";
214383
214431
 
214384
214432
  // src/server/index.ts
214385
214433
  init_config();
@@ -216016,7 +216064,7 @@ var swagger_default = {
216016
216064
  },
216017
216065
  info: {
216018
216066
  title: "MTranServer API",
216019
- version: "4.0.19",
216067
+ version: "4.0.20",
216020
216068
  description: "Translation server API",
216021
216069
  license: {
216022
216070
  name: "Apache-2.0"
@@ -216861,5 +216909,5 @@ run().catch((error2) => {
216861
216909
  fatal("Failed to start server:", error2);
216862
216910
  });
216863
216911
 
216864
- //# debugId=7CD90E83C77CE50C64756E2164756E21
216912
+ //# debugId=91A4B0E803737D0C64756E2164756E21
216865
216913
  //# sourceMappingURL=main.js.map