@itwin/core-i18n 4.0.0-dev.24 → 4.0.0-dev.30

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.
@@ -15782,7 +15782,7 @@ function assert(condition, message) {
15782
15782
  condition = condition();
15783
15783
  if (condition)
15784
15784
  return;
15785
- message = message !== null && message !== void 0 ? message : "Programmer Error";
15785
+ message = message ?? "Programmer Error";
15786
15786
  if ("string" !== typeof message)
15787
15787
  message = message();
15788
15788
  throw new Error(`Assert: ${message}`);
@@ -16131,6 +16131,8 @@ var DbResult;
16131
16131
  DbResult[DbResult["BE_SQLITE_ERROR_CouldNotAcquireLocksOrCodes"] = 352321546] = "BE_SQLITE_ERROR_CouldNotAcquireLocksOrCodes";
16132
16132
  /** Recommended that the schemas found in the database be upgraded */
16133
16133
  DbResult[DbResult["BE_SQLITE_ERROR_SchemaUpgradeRecommended"] = 369098762] = "BE_SQLITE_ERROR_SchemaUpgradeRecommended";
16134
+ /** schema update require data transform */
16135
+ DbResult[DbResult["BE_SQLITE_ERROR_DataTransformRequired"] = 385875978] = "BE_SQLITE_ERROR_DataTransformRequired";
16134
16136
  DbResult[DbResult["BE_SQLITE_LOCKED_SHAREDCACHE"] = 262] = "BE_SQLITE_LOCKED_SHAREDCACHE";
16135
16137
  DbResult[DbResult["BE_SQLITE_BUSY_RECOVERY"] = 261] = "BE_SQLITE_BUSY_RECOVERY";
16136
16138
  DbResult[DbResult["BE_SQLITE_CANTOPEN_NOTEMPDIR"] = 270] = "BE_SQLITE_CANTOPEN_NOTEMPDIR";
@@ -16651,6 +16653,7 @@ class BentleyError extends Error {
16651
16653
  case _BeSQLite__WEBPACK_IMPORTED_MODULE_0__.DbResult.BE_SQLITE_IOERR_SHMMAP: return "BE_SQLITE_IOERR_SHMMAP";
16652
16654
  case _BeSQLite__WEBPACK_IMPORTED_MODULE_0__.DbResult.BE_SQLITE_IOERR_SEEK: return "BE_SQLITE_IOERR_SEEK";
16653
16655
  case _BeSQLite__WEBPACK_IMPORTED_MODULE_0__.DbResult.BE_SQLITE_IOERR_DELETE_NOENT: return "BE_SQLITE_IOERR_DELETE_NOENT";
16656
+ case _BeSQLite__WEBPACK_IMPORTED_MODULE_0__.DbResult.BE_SQLITE_ERROR_DataTransformRequired: return "Schema update require to transform data";
16654
16657
  case _BeSQLite__WEBPACK_IMPORTED_MODULE_0__.DbResult.BE_SQLITE_ERROR_FileExists: return "File Exists";
16655
16658
  case _BeSQLite__WEBPACK_IMPORTED_MODULE_0__.DbResult.BE_SQLITE_ERROR_AlreadyOpen: return "Already Open";
16656
16659
  case _BeSQLite__WEBPACK_IMPORTED_MODULE_0__.DbResult.BE_SQLITE_ERROR_NoPropertyTable: return "No Property Table";
@@ -17504,7 +17507,7 @@ var CompressedId64Set;
17504
17507
  * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.
17505
17508
  */
17506
17509
  function decompressSet(compressedIds, out) {
17507
- const set = out !== null && out !== void 0 ? out : new Set();
17510
+ const set = out ?? new Set();
17508
17511
  for (const id of iterable(compressedIds))
17509
17512
  set.add(id);
17510
17513
  return set;
@@ -17521,7 +17524,7 @@ var CompressedId64Set;
17521
17524
  * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.
17522
17525
  */
17523
17526
  function decompressArray(compressedIds, out) {
17524
- const arr = out !== null && out !== void 0 ? out : [];
17527
+ const arr = out ?? [];
17525
17528
  for (const id of iterable(compressedIds))
17526
17529
  arr.push(id);
17527
17530
  return arr;
@@ -17553,7 +17556,7 @@ class MutableCompressedId64Set {
17553
17556
  constructor(ids) {
17554
17557
  this._inserted = new OrderedId64Array();
17555
17558
  this._deleted = new OrderedId64Array();
17556
- this._ids = ids !== null && ids !== void 0 ? ids : "";
17559
+ this._ids = ids ?? "";
17557
17560
  }
17558
17561
  /** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */
17559
17562
  get ids() {
@@ -17587,7 +17590,7 @@ class MutableCompressedId64Set {
17587
17590
  /** Remove all Ids from the set, then add the specified Ids. */
17588
17591
  reset(ids) {
17589
17592
  this.clear();
17590
- this._ids = ids !== null && ids !== void 0 ? ids : "";
17593
+ this._ids = ids ?? "";
17591
17594
  }
17592
17595
  /** Obtain an iterator over the Ids in this set. The Ids are returned in ascending order based on their unsigned 64-bit integer values. */
17593
17596
  [Symbol.iterator]() {
@@ -19361,17 +19364,15 @@ class Logger {
19361
19364
  }
19362
19365
  /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */
19363
19366
  static setLevelDefault(minLevel) {
19364
- var _a;
19365
19367
  this._minLevel = minLevel;
19366
- (_a = this.logLevelChangedFn) === null || _a === void 0 ? void 0 : _a.call(this);
19368
+ this.logLevelChangedFn?.();
19367
19369
  }
19368
19370
  /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the
19369
19371
  * specified category should be displayed.
19370
19372
  */
19371
19373
  static setLevel(category, minLevel) {
19372
- var _a;
19373
19374
  Logger._categoryFilter.set(category, minLevel);
19374
- (_a = this.logLevelChangedFn) === null || _a === void 0 ? void 0 : _a.call(this);
19375
+ this.logLevelChangedFn?.();
19375
19376
  }
19376
19377
  /** Interpret a string as the name of a LogLevel */
19377
19378
  static parseLogLevel(str) {
@@ -19661,7 +19662,7 @@ class PromiseWithAbandon {
19661
19662
  /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */
19662
19663
  async init(msg) {
19663
19664
  return new Promise((resolve, reject) => {
19664
- this.abandon = (message) => reject(new AbandonedError(message !== null && message !== void 0 ? message : msg));
19665
+ this.abandon = (message) => reject(new AbandonedError(message ?? msg));
19665
19666
  this._resolve = resolve;
19666
19667
  });
19667
19668
  }
@@ -21498,17 +21499,16 @@ class Tracing {
21498
21499
  ? Tracing._openTelemetry.context.active()
21499
21500
  : Tracing._openTelemetry.trace.setSpanContext(Tracing._openTelemetry.context.active(), parentContext);
21500
21501
  return Tracing._openTelemetry.context.with(Tracing._openTelemetry.trace.setSpan(parent, Tracing._tracer.startSpan(name, options, Tracing._openTelemetry.context.active())), async () => {
21501
- var _a, _b, _c, _d;
21502
21502
  try {
21503
21503
  return await fn();
21504
21504
  }
21505
21505
  catch (err) {
21506
21506
  if (err instanceof Error) // ignore non-Error throws, such as RpcControlResponse
21507
- (_b = (_a = Tracing._openTelemetry) === null || _a === void 0 ? void 0 : _a.trace.getSpan(Tracing._openTelemetry.context.active())) === null || _b === void 0 ? void 0 : _b.setAttribute("error", true);
21507
+ Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.setAttribute("error", true);
21508
21508
  throw err;
21509
21509
  }
21510
21510
  finally {
21511
- (_d = (_c = Tracing._openTelemetry) === null || _c === void 0 ? void 0 : _c.trace.getSpan(Tracing._openTelemetry.context.active())) === null || _d === void 0 ? void 0 : _d.end();
21511
+ Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.end();
21512
21512
  }
21513
21513
  });
21514
21514
  }
@@ -21527,9 +21527,8 @@ class Tracing {
21527
21527
  }
21528
21528
  static withOpenTelemetry(base, isError = false) {
21529
21529
  return (category, message, metaData) => {
21530
- var _a, _b;
21531
21530
  try {
21532
- (_b = (_a = Tracing._openTelemetry) === null || _a === void 0 ? void 0 : _a.trace.getSpan(Tracing._openTelemetry.context.active())) === null || _b === void 0 ? void 0 : _b.addEvent(message, { ...flattenObject(_Logger__WEBPACK_IMPORTED_MODULE_0__.Logger.getMetaData(metaData)), error: isError });
21531
+ Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.addEvent(message, { ...flattenObject(_Logger__WEBPACK_IMPORTED_MODULE_0__.Logger.getMetaData(metaData)), error: isError });
21533
21532
  }
21534
21533
  catch (_e) { } // avoid throwing random errors (with stack trace mangled by async hooks) when openTelemetry collector doesn't work
21535
21534
  base(category, message, metaData);
@@ -21539,8 +21538,7 @@ class Tracing {
21539
21538
  * @param attributes The attributes to set
21540
21539
  */
21541
21540
  static setAttributes(attributes) {
21542
- var _a, _b;
21543
- (_b = (_a = Tracing._openTelemetry) === null || _a === void 0 ? void 0 : _a.trace.getSpan(Tracing._openTelemetry.context.active())) === null || _b === void 0 ? void 0 : _b.setAttributes(attributes);
21541
+ Tracing._openTelemetry?.trace.getSpan(Tracing._openTelemetry.context.active())?.setAttributes(attributes);
21544
21542
  }
21545
21543
  }
21546
21544
 
@@ -21701,10 +21699,9 @@ __webpack_require__.r(__webpack_exports__);
21701
21699
  class TypedArrayBuilder {
21702
21700
  /** Constructs a new builder from the specified options, with a [[length]] of zero. */
21703
21701
  constructor(constructor, options) {
21704
- var _a, _b;
21705
21702
  this._constructor = constructor;
21706
- this._data = new constructor((_a = options === null || options === void 0 ? void 0 : options.initialCapacity) !== null && _a !== void 0 ? _a : 0);
21707
- this.growthFactor = Math.max(1.0, (_b = options === null || options === void 0 ? void 0 : options.growthFactor) !== null && _b !== void 0 ? _b : 1.5);
21703
+ this._data = new constructor(options?.initialCapacity ?? 0);
21704
+ this.growthFactor = Math.max(1.0, options?.growthFactor ?? 1.5);
21708
21705
  this._length = 0;
21709
21706
  }
21710
21707
  /** The number of elements currently in the array. */
@@ -21832,8 +21829,7 @@ class Uint32ArrayBuilder extends TypedArrayBuilder {
21832
21829
  */
21833
21830
  class UintArrayBuilder extends TypedArrayBuilder {
21834
21831
  constructor(options) {
21835
- var _a;
21836
- super((_a = options === null || options === void 0 ? void 0 : options.initialType) !== null && _a !== void 0 ? _a : Uint8Array, options);
21832
+ super(options?.initialType ?? Uint8Array, options);
21837
21833
  }
21838
21834
  /** The number of bytes (1, 2, or 4) currently allocated per element by the underlying array.
21839
21835
  * This may change as larger values are added to the array.
@@ -22357,19 +22353,18 @@ const DEFAULT_MAX_RETRIES = 1; // a low number prevents wasted time and potentia
22357
22353
  */
22358
22354
  class ITwinLocalization {
22359
22355
  constructor(options) {
22360
- var _a, _b, _c;
22361
22356
  this._namespaces = new Map();
22362
22357
  this.i18next = i18next_1.default.createInstance();
22363
22358
  this._backendOptions = {
22364
- loadPath: (_a = options === null || options === void 0 ? void 0 : options.urlTemplate) !== null && _a !== void 0 ? _a : "locales/{{lng}}/{{ns}}.json",
22359
+ loadPath: options?.urlTemplate ?? "locales/{{lng}}/{{ns}}.json",
22365
22360
  crossDomain: true,
22366
- ...options === null || options === void 0 ? void 0 : options.backendHttpOptions,
22361
+ ...options?.backendHttpOptions,
22367
22362
  };
22368
22363
  this._detectionOptions = {
22369
22364
  order: ["querystring", "navigator", "htmlTag"],
22370
22365
  lookupQuerystring: "lng",
22371
22366
  caches: [],
22372
- ...options === null || options === void 0 ? void 0 : options.detectorOptions,
22367
+ ...options?.detectorOptions,
22373
22368
  };
22374
22369
  this._initOptions = {
22375
22370
  interpolation: { escapeValue: true },
@@ -22377,19 +22372,18 @@ class ITwinLocalization {
22377
22372
  maxRetries: DEFAULT_MAX_RETRIES,
22378
22373
  backend: this._backendOptions,
22379
22374
  detection: this._detectionOptions,
22380
- ...options === null || options === void 0 ? void 0 : options.initOptions,
22375
+ ...options?.initOptions,
22381
22376
  };
22382
22377
  this.i18next
22383
- .use((_b = options === null || options === void 0 ? void 0 : options.detectorPlugin) !== null && _b !== void 0 ? _b : i18next_browser_languagedetector_1.default)
22384
- .use((_c = options === null || options === void 0 ? void 0 : options.backendPlugin) !== null && _c !== void 0 ? _c : i18next_http_backend_1.default)
22378
+ .use(options?.detectorPlugin ?? i18next_browser_languagedetector_1.default)
22379
+ .use(options?.backendPlugin ?? i18next_http_backend_1.default)
22385
22380
  .use(TranslationLogger);
22386
22381
  }
22387
22382
  async initialize(namespaces) {
22388
- var _a;
22389
22383
  // Also consider namespaces passed into constructor
22390
22384
  const initNamespaces = [this._initOptions.ns || []].flat();
22391
22385
  const combinedNamespaces = new Set([...namespaces, ...initNamespaces]); // without duplicates
22392
- const defaultNamespace = (_a = this._initOptions.defaultNS) !== null && _a !== void 0 ? _a : namespaces[0];
22386
+ const defaultNamespace = this._initOptions.defaultNS ?? namespaces[0];
22393
22387
  if (defaultNamespace)
22394
22388
  combinedNamespaces.add(defaultNamespace); // Make sure default namespace is in namespaces list
22395
22389
  const initOptions = {
@@ -22438,7 +22432,7 @@ class ITwinLocalization {
22438
22432
  * @public
22439
22433
  */
22440
22434
  getLocalizedString(key, options) {
22441
- if ((options === null || options === void 0 ? void 0 : options.returnDetails) || (options === null || options === void 0 ? void 0 : options.returnObjects)) {
22435
+ if (options?.returnDetails || options?.returnObjects) {
22442
22436
  throw new Error("Translation key must map to a string, but the given options will result in an object");
22443
22437
  }
22444
22438
  const value = this.i18next.t(key, options);
@@ -22475,7 +22469,7 @@ class ITwinLocalization {
22475
22469
  * @internal
22476
22470
  */
22477
22471
  getEnglishString(namespace, key, options) {
22478
- if ((options === null || options === void 0 ? void 0 : options.returnDetails) || (options === null || options === void 0 ? void 0 : options.returnObjects)) {
22472
+ if (options?.returnDetails || options?.returnObjects) {
22479
22473
  throw new Error("Translation key must map to a string, but the given options will result in an object");
22480
22474
  }
22481
22475
  options = {
@@ -23451,17 +23445,15 @@ describe("ITwinLocalization", () => {
23451
23445
  chai_1.assert.equal(itwinLocalization.i18next.options.defaultNS, undefined);
23452
23446
  });
23453
23447
  it("initialize with single namespace", async () => {
23454
- var _a;
23455
23448
  await itwinLocalization.initialize(["Test"]);
23456
23449
  chai_1.assert.equal(itwinLocalization.i18next.options.defaultNS, "Test");
23457
- chai_1.assert.isTrue((_a = itwinLocalization.i18next.options.ns) === null || _a === void 0 ? void 0 : _a.includes("Test"));
23450
+ chai_1.assert.isTrue(itwinLocalization.i18next.options.ns?.includes("Test"));
23458
23451
  chai_1.assert.equal(itwinLocalization.getLocalizedString("Test:FirstTrivial"), "First level string (test)");
23459
23452
  });
23460
23453
  it("initialize with two namespaces recognizes both namespaces", async () => {
23461
- var _a, _b;
23462
23454
  await itwinLocalization.initialize(["Default", "Test"]);
23463
- chai_1.assert.isTrue((_a = itwinLocalization.i18next.options.ns) === null || _a === void 0 ? void 0 : _a.includes("Default"));
23464
- chai_1.assert.isTrue((_b = itwinLocalization.i18next.options.ns) === null || _b === void 0 ? void 0 : _b.includes("Test"));
23455
+ chai_1.assert.isTrue(itwinLocalization.i18next.options.ns?.includes("Default"));
23456
+ chai_1.assert.isTrue(itwinLocalization.i18next.options.ns?.includes("Test"));
23465
23457
  chai_1.assert.equal(itwinLocalization.getLocalizedString("Default:FirstTrivial"), "First level string (default)");
23466
23458
  chai_1.assert.equal(itwinLocalization.getLocalizedString("Test:FirstTrivial"), "First level string (test)");
23467
23459
  });
@@ -23471,10 +23463,9 @@ describe("ITwinLocalization", () => {
23471
23463
  chai_1.assert.equal(itwinLocalization.getLocalizedString("FirstTrivial"), "First level string (default)");
23472
23464
  });
23473
23465
  it("initialize with duplicate namespace values does not break anything", async () => {
23474
- var _a;
23475
23466
  await itwinLocalization.initialize(["Default", "Default"]);
23476
23467
  chai_1.assert.equal(itwinLocalization.i18next.options.defaultNS, "Default");
23477
- chai_1.assert.isTrue((_a = itwinLocalization.i18next.options.ns) === null || _a === void 0 ? void 0 : _a.includes("Default"));
23468
+ chai_1.assert.isTrue(itwinLocalization.i18next.options.ns?.includes("Default"));
23478
23469
  chai_1.assert.equal(itwinLocalization.getLocalizedString("FirstTrivial"), "First level string (default)");
23479
23470
  chai_1.assert.equal(itwinLocalization.getLocalizedString("Default:FirstTrivial"), "First level string (default)");
23480
23471
  });
@@ -23500,14 +23491,12 @@ describe("ITwinLocalization", () => {
23500
23491
  chai_1.assert.equal(itwinLocalization.i18next.options.defaultNS, "Default");
23501
23492
  });
23502
23493
  it("default namespace is in list of all namespaces initalized with empty array", async () => {
23503
- var _a;
23504
23494
  await itwinLocalization.initialize([]);
23505
- chai_1.assert.isTrue((_a = itwinLocalization.i18next.options.ns) === null || _a === void 0 ? void 0 : _a.includes("Default"));
23495
+ chai_1.assert.isTrue(itwinLocalization.i18next.options.ns?.includes("Default"));
23506
23496
  });
23507
23497
  it("default namespace is in list of all namespaces", async () => {
23508
- var _a;
23509
23498
  await itwinLocalization.initialize(["Test"]);
23510
- chai_1.assert.isTrue((_a = itwinLocalization.i18next.options.ns) === null || _a === void 0 ? void 0 : _a.includes("Default"));
23499
+ chai_1.assert.isTrue(itwinLocalization.i18next.options.ns?.includes("Default"));
23511
23500
  });
23512
23501
  });
23513
23502
  });