@itwin/ecschema-rpcinterface-tests 3.7.1 → 3.7.2

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.
@@ -189548,7 +189548,7 @@ class ViewLookAndMove extends ViewNavigate {
189548
189548
  super.onCleanup();
189549
189549
  this.releasePointerLock();
189550
189550
  }
189551
- pointerLockChangeEvent() {
189551
+ async pointerLockChangeEvent() {
189552
189552
  const vp = this.viewTool.viewport;
189553
189553
  if (undefined !== vp && document.pointerLockElement === vp.canvas) {
189554
189554
  vp.npcToView(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.NpcCenter, this._anchorPtView); // Display indicator in the middle of the view for pointer lock...
@@ -189557,7 +189557,11 @@ class ViewLookAndMove extends ViewNavigate {
189557
189557
  vp.invalidateDecorations();
189558
189558
  }
189559
189559
  else {
189560
- this._havePointerLock = false;
189560
+ // If ESC is used to disable pointer lock, exit the tool instead of continuing in drag mode...
189561
+ if (this._havePointerLock && this.viewTool.inDynamicUpdate)
189562
+ await this.viewTool.exitTool();
189563
+ else
189564
+ this._havePointerLock = false;
189561
189565
  }
189562
189566
  }
189563
189567
  requestPointerLock(enable) {
@@ -189580,7 +189584,7 @@ class ViewLookAndMove extends ViewNavigate {
189580
189584
  // NOTE: Chrome appears to be the only browser that doesn't require pointer lock to be requested from an engagement event like click.
189581
189585
  // Currently pointer lock is requested for "click" and not "mousedown" since we don't want pointer lock for drag operation.
189582
189586
  if (undefined === this._pointerLockChangeListener) {
189583
- this._pointerLockChangeListener = () => this.pointerLockChangeEvent();
189587
+ this._pointerLockChangeListener = async () => this.pointerLockChangeEvent();
189584
189588
  document.addEventListener("pointerlockchange", this._pointerLockChangeListener, false);
189585
189589
  }
189586
189590
  if (undefined === this._pointerLockClickEngagementListener) {
@@ -189825,23 +189829,6 @@ class ViewLookAndMove extends ViewNavigate {
189825
189829
  vp.viewToNpc(vp.npcToView(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.NpcCenter), this._lastReadPt);
189826
189830
  this._lastReadPt.z = ViewManip.getFocusPlaneNpc(vp);
189827
189831
  vp.npcToWorld(this._lastReadPt, this._lastReadPt);
189828
- // Rotate view to look straight down...
189829
- // const frust = vp.getWorldFrustum();
189830
- // const saveFrustum = frust.clone();
189831
- // const viewUp = vp.view.getYVector();
189832
- // const viewDir = vp.view.getZVector(); viewDir.scaleInPlace(-1);
189833
- // const worldUp = Vector3d.unitZ();
189834
- // const viewAngle = worldUp.angleTo(viewUp).radians;
189835
- // const pitchAngle = Angle.createRadians((-Math.PI / 2) - (viewDir.z < 0 ? -viewAngle : viewAngle));
189836
- // const pitchMatrix = Matrix3d.createRotationAroundVector(Vector3d.unitX(), pitchAngle)!;
189837
- // const pitchTimesView = pitchMatrix.multiplyMatrixMatrix(vp.rotation);
189838
- // const invViewRot = vp.rotation.inverse()!;
189839
- // const inverseViewTimesPitchTimesView = invViewRot.multiplyMatrixMatrix(pitchTimesView);
189840
- // const transform = Transform.createFixedPointAndMatrix(view.getEyePoint(), inverseViewTimesPitchTimesView);
189841
- // frust.multiply(transform);
189842
- // vp.setupViewFromFrustum(frust);
189843
- // this.computeCollisionData(vp, eyePt);
189844
- // vp.setupViewFromFrustum(saveFrustum);
189845
189832
  this.computeCollisionData(vp, eyePt);
189846
189833
  }
189847
189834
  if (undefined === this._currentContour || this._currentContour.numPoints() < 2 || positionInput.z <= 0.0)
@@ -190193,22 +190180,6 @@ class ViewLookAndMove extends ViewNavigate {
190193
190180
  super.drawHandle(context, hasFocus);
190194
190181
  if (!hasFocus || context.viewport !== this.viewTool.viewport)
190195
190182
  return;
190196
- // if (undefined !== this._currentContour && this._currentContour.numPoints() > 0) {
190197
- // const builder = context.createGraphicBuilder(GraphicType.WorldOverlay);
190198
- // const color = context.viewport.getContrastToBackgroundColor();
190199
- // builder.setSymbology(color, color, 8);
190200
- // if (this._currentContour.numPoints() > 1)
190201
- // builder.addLineString(this._currentContour.points);
190202
- // else
190203
- // builder.addPointString(this._currentContour.points);
190204
- // builder.setSymbology(ColorDef.blue, color, 15);
190205
- // builder.addPointString([this._lastReadPt]);
190206
- // if (this._lastReference) {
190207
- // builder.setSymbology(ColorDef.green, color, 15);
190208
- // builder.addPointString([this._lastReference.getOriginRef()]);
190209
- // }
190210
- // context.addDecorationFromBuilder(builder);
190211
- // }
190212
190183
  if (_ToolSettings__WEBPACK_IMPORTED_MODULE_22__.ToolSettings.walkCollisions && this.viewTool.inDynamicUpdate) {
190213
190184
  const position = this._anchorPtView.clone();
190214
190185
  position.x = Math.floor(position.x) + 0.5;
@@ -274421,230 +274392,230 @@ __webpack_require__.r(__webpack_exports__);
274421
274392
  /* harmony import */ var i18next_browser_languagedetector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! i18next-browser-languagedetector */ "../../common/temp/node_modules/.pnpm/i18next-browser-languagedetector@6.1.8/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js");
274422
274393
  /* harmony import */ var i18next_http_backend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! i18next-http-backend */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@1.4.5/node_modules/i18next-http-backend/esm/index.js");
274423
274394
  /* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
274424
- /*---------------------------------------------------------------------------------------------
274425
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
274426
- * See LICENSE.md in the project root for license terms and full copyright notice.
274427
- *--------------------------------------------------------------------------------------------*/
274428
- /** @packageDocumentation
274429
- * @module Localization
274430
- */
274431
-
274432
-
274433
-
274434
-
274435
- const DEFAULT_MAX_RETRIES = 1; // a low number prevents wasted time and potential timeouts when requesting localization files throws an error
274436
- /** Supplies localizations for iTwin.js
274437
- * @note this class uses the [i18next](https://www.i18next.com/) package.
274438
- * @public
274439
- */
274440
- class ITwinLocalization {
274441
- constructor(options) {
274442
- var _a, _b, _c;
274443
- this._namespaces = new Map();
274444
- this.i18next = i18next__WEBPACK_IMPORTED_MODULE_0__["default"].createInstance();
274445
- this._backendOptions = {
274446
- loadPath: (_a = options === null || options === void 0 ? void 0 : options.urlTemplate) !== null && _a !== void 0 ? _a : "locales/{{lng}}/{{ns}}.json",
274447
- crossDomain: true,
274448
- ...options === null || options === void 0 ? void 0 : options.backendHttpOptions,
274449
- };
274450
- this._detectionOptions = {
274451
- order: ["querystring", "navigator", "htmlTag"],
274452
- lookupQuerystring: "lng",
274453
- caches: [],
274454
- ...options === null || options === void 0 ? void 0 : options.detectorOptions,
274455
- };
274456
- this._initOptions = {
274457
- interpolation: { escapeValue: true },
274458
- fallbackLng: "en",
274459
- maxRetries: DEFAULT_MAX_RETRIES,
274460
- backend: this._backendOptions,
274461
- detection: this._detectionOptions,
274462
- ...options === null || options === void 0 ? void 0 : options.initOptions,
274463
- };
274464
- this.i18next
274465
- .use((_b = options === null || options === void 0 ? void 0 : options.detectorPlugin) !== null && _b !== void 0 ? _b : i18next_browser_languagedetector__WEBPACK_IMPORTED_MODULE_1__["default"])
274466
- .use((_c = options === null || options === void 0 ? void 0 : options.backendPlugin) !== null && _c !== void 0 ? _c : i18next_http_backend__WEBPACK_IMPORTED_MODULE_2__["default"])
274467
- .use(TranslationLogger);
274468
- }
274469
- async initialize(namespaces) {
274470
- var _a;
274471
- // Also consider namespaces passed into constructor
274472
- const initNamespaces = [this._initOptions.ns || []].flat();
274473
- const combinedNamespaces = new Set([...namespaces, ...initNamespaces]); // without duplicates
274474
- const defaultNamespace = (_a = this._initOptions.defaultNS) !== null && _a !== void 0 ? _a : namespaces[0];
274475
- if (defaultNamespace)
274476
- combinedNamespaces.add(defaultNamespace); // Make sure default namespace is in namespaces list
274477
- const initOptions = {
274478
- ...this._initOptions,
274479
- defaultNS: defaultNamespace,
274480
- ns: [...combinedNamespaces],
274481
- };
274482
- // if in a development environment, set debugging
274483
- if (false)
274484
- {}
274485
- const initPromise = this.i18next.init(initOptions);
274486
- for (const ns of namespaces)
274487
- this._namespaces.set(ns, initPromise);
274488
- return initPromise;
274489
- }
274490
- /** Replace all instances of `%{key}` within a string with the translations of those keys.
274491
- * For example:
274492
- * ``` ts
274493
- * "MyKeys": {
274494
- * "Key1": "First value",
274495
- * "Key2": "Second value"
274496
- * }
274497
- * ```
274498
- *
274499
- * ``` ts
274500
- * i18.translateKeys("string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!"") // returns "string with First Value followed by Second Value!"
274501
- * ```
274502
- * @param line The input line, potentially containing %{keys}.
274503
- * @returns The line with all %{keys} translated
274504
- * @public
274505
- */
274506
- getLocalizedKeys(line) {
274507
- return line.replace(/\%\{(.+?)\}/g, (_match, tag) => this.getLocalizedString(tag));
274508
- }
274509
- /** Return the translated value of a key.
274510
- * @param key - the key that matches a property in the JSON localization file.
274511
- * @note The key includes the namespace, which identifies the particular localization file that contains the property,
274512
- * followed by a colon, followed by the property in the JSON file.
274513
- * For example:
274514
- * ``` ts
274515
- * const dataString: string = IModelApp.localization.getLocalizedString("iModelJs:BackgroundMap.BingDataAttribution");
274516
- * ```
274517
- * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.
274518
- * @returns The string corresponding to the first key that resolves.
274519
- * @throws Error if no keys resolve to a string.
274520
- * @public
274521
- */
274522
- getLocalizedString(key, options) {
274523
- if ((options === null || options === void 0 ? void 0 : options.returnDetails) || (options === null || options === void 0 ? void 0 : options.returnObjects)) {
274524
- throw new Error("Translation key must map to a string, but the given options will result in an object");
274525
- }
274526
- const value = this.i18next.t(key, options);
274527
- if (typeof value !== "string") {
274528
- throw new Error("Translation key(s) string not found");
274529
- }
274530
- return value;
274531
- }
274532
- /** Similar to `getLocalizedString` but the default namespace is a separate parameter and the key does not need
274533
- * to include a namespace. If a key includes a namespace, that namespace will be used for interpolating that key.
274534
- * @param namespace - the namespace that identifies the particular localization file that contains the property.
274535
- * @param key - the key that matches a property in the JSON localization file.
274536
- * @returns The string corresponding to the first key that resolves.
274537
- * @throws Error if no keys resolve to a string.
274538
- * @internal
274539
- */
274540
- getLocalizedStringWithNamespace(namespace, key, options) {
274541
- let fullKey = "";
274542
- if (typeof key === "string") {
274543
- fullKey = `${namespace}:${key}`;
274544
- }
274545
- else {
274546
- fullKey = key.map((subKey) => {
274547
- return `${namespace}:${subKey}`;
274548
- });
274549
- }
274550
- return this.getLocalizedString(fullKey, options);
274551
- }
274552
- /** Gets the English translation.
274553
- * @param namespace - the namespace that identifies the particular localization file that contains the property.
274554
- * @param key - the key that matches a property in the JSON localization file.
274555
- * @returns The string corresponding to the first key that resolves.
274556
- * @throws Error if no keys resolve to a string.
274557
- * @internal
274558
- */
274559
- getEnglishString(namespace, key, options) {
274560
- if ((options === null || options === void 0 ? void 0 : options.returnDetails) || (options === null || options === void 0 ? void 0 : options.returnObjects)) {
274561
- throw new Error("Translation key must map to a string, but the given options will result in an object");
274562
- }
274563
- options = {
274564
- ...options,
274565
- ns: namespace, // ensure namespace argument is used
274566
- };
274567
- const en = this.i18next.getFixedT("en", namespace);
274568
- const str = en(key, options);
274569
- if (typeof str !== "string")
274570
- throw new Error("Translation key(s) not found");
274571
- return str;
274572
- }
274573
- /** Get the promise for an already registered Namespace.
274574
- * @param name - the name of the namespace
274575
- * @public
274576
- */
274577
- getNamespacePromise(name) {
274578
- return this._namespaces.get(name);
274579
- }
274580
- /** @internal */
274581
- getLanguageList() {
274582
- return this.i18next.languages;
274583
- }
274584
- /** override the language detected in the browser */
274585
- async changeLanguage(language) {
274586
- return this.i18next.changeLanguage(language);
274587
- }
274588
- /** Register a new Namespace and return it. If the namespace is already registered, it will be returned.
274589
- * @param name - the name of the namespace, which is the base name of the JSON file that contains the localization properties.
274590
- * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,
274591
- * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await
274592
- * fulfillment of the readPromise Promise property of the returned LocalizationNamespace.
274593
- * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)
274594
- * @public
274595
- */
274596
- async registerNamespace(name) {
274597
- const existing = this._namespaces.get(name);
274598
- if (existing !== undefined)
274599
- return existing;
274600
- const theReadPromise = new Promise((resolve) => {
274601
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
274602
- this.i18next.loadNamespaces(name, (err) => {
274603
- if (!err)
274604
- return resolve();
274605
- // Here we got a non-null err object.
274606
- // This method is called when the system has attempted to load the resources for the namespaces for each possible locale.
274607
- // For example 'fr-ca' might be the most specific locale, in which case 'fr' and 'en' are fallback locales.
274608
- // Using Backend from i18next-http-backend, err will be an array of strings of each namespace it tried to read and its locale.
274609
- // There might be errs for some other namespaces as well as this one. We resolve the promise unless there's an error for each possible locale.
274610
- let locales = this.getLanguageList().map((thisLocale) => `/${thisLocale}/`);
274611
- try {
274612
- for (const thisError of err) {
274613
- if (typeof thisError === "string")
274614
- locales = locales.filter((thisLocale) => !thisError.includes(thisLocale));
274615
- }
274616
- }
274617
- catch (e) {
274618
- locales = [];
274619
- }
274620
- // if we removed every locale from the array, it wasn't loaded.
274621
- if (locales.length === 0)
274622
- _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logError("i18n", `No resources for namespace ${name} could be loaded`);
274623
- resolve();
274624
- });
274625
- });
274626
- this._namespaces.set(name, theReadPromise);
274627
- return theReadPromise;
274628
- }
274629
- /** @internal */
274630
- unregisterNamespace(name) {
274631
- this._namespaces.delete(name);
274632
- }
274633
- }
274634
- class TranslationLogger {
274635
- log(args) { _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logInfo("i18n", this.createLogMessage(args)); }
274636
- warn(args) { _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logWarning("i18n", this.createLogMessage(args)); }
274637
- error(args) { _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logError("i18n", this.createLogMessage(args)); }
274638
- createLogMessage(args) {
274639
- let message = args[0];
274640
- for (let i = 1; i < args.length; ++i) {
274641
- if (typeof args[i] === "string")
274642
- message += `\n ${args[i]}`;
274643
- }
274644
- return message;
274645
- }
274646
- }
274647
- TranslationLogger.type = "logger";
274395
+ /*---------------------------------------------------------------------------------------------
274396
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
274397
+ * See LICENSE.md in the project root for license terms and full copyright notice.
274398
+ *--------------------------------------------------------------------------------------------*/
274399
+ /** @packageDocumentation
274400
+ * @module Localization
274401
+ */
274402
+
274403
+
274404
+
274405
+
274406
+ const DEFAULT_MAX_RETRIES = 1; // a low number prevents wasted time and potential timeouts when requesting localization files throws an error
274407
+ /** Supplies localizations for iTwin.js
274408
+ * @note this class uses the [i18next](https://www.i18next.com/) package.
274409
+ * @public
274410
+ */
274411
+ class ITwinLocalization {
274412
+ constructor(options) {
274413
+ var _a, _b, _c;
274414
+ this._namespaces = new Map();
274415
+ this.i18next = i18next__WEBPACK_IMPORTED_MODULE_0__["default"].createInstance();
274416
+ this._backendOptions = {
274417
+ loadPath: (_a = options === null || options === void 0 ? void 0 : options.urlTemplate) !== null && _a !== void 0 ? _a : "locales/{{lng}}/{{ns}}.json",
274418
+ crossDomain: true,
274419
+ ...options === null || options === void 0 ? void 0 : options.backendHttpOptions,
274420
+ };
274421
+ this._detectionOptions = {
274422
+ order: ["querystring", "navigator", "htmlTag"],
274423
+ lookupQuerystring: "lng",
274424
+ caches: [],
274425
+ ...options === null || options === void 0 ? void 0 : options.detectorOptions,
274426
+ };
274427
+ this._initOptions = {
274428
+ interpolation: { escapeValue: true },
274429
+ fallbackLng: "en",
274430
+ maxRetries: DEFAULT_MAX_RETRIES,
274431
+ backend: this._backendOptions,
274432
+ detection: this._detectionOptions,
274433
+ ...options === null || options === void 0 ? void 0 : options.initOptions,
274434
+ };
274435
+ this.i18next
274436
+ .use((_b = options === null || options === void 0 ? void 0 : options.detectorPlugin) !== null && _b !== void 0 ? _b : i18next_browser_languagedetector__WEBPACK_IMPORTED_MODULE_1__["default"])
274437
+ .use((_c = options === null || options === void 0 ? void 0 : options.backendPlugin) !== null && _c !== void 0 ? _c : i18next_http_backend__WEBPACK_IMPORTED_MODULE_2__["default"])
274438
+ .use(TranslationLogger);
274439
+ }
274440
+ async initialize(namespaces) {
274441
+ var _a;
274442
+ // Also consider namespaces passed into constructor
274443
+ const initNamespaces = [this._initOptions.ns || []].flat();
274444
+ const combinedNamespaces = new Set([...namespaces, ...initNamespaces]); // without duplicates
274445
+ const defaultNamespace = (_a = this._initOptions.defaultNS) !== null && _a !== void 0 ? _a : namespaces[0];
274446
+ if (defaultNamespace)
274447
+ combinedNamespaces.add(defaultNamespace); // Make sure default namespace is in namespaces list
274448
+ const initOptions = {
274449
+ ...this._initOptions,
274450
+ defaultNS: defaultNamespace,
274451
+ ns: [...combinedNamespaces],
274452
+ };
274453
+ // if in a development environment, set debugging
274454
+ if (false)
274455
+ {}
274456
+ const initPromise = this.i18next.init(initOptions);
274457
+ for (const ns of namespaces)
274458
+ this._namespaces.set(ns, initPromise);
274459
+ return initPromise;
274460
+ }
274461
+ /** Replace all instances of `%{key}` within a string with the translations of those keys.
274462
+ * For example:
274463
+ * ``` ts
274464
+ * "MyKeys": {
274465
+ * "Key1": "First value",
274466
+ * "Key2": "Second value"
274467
+ * }
274468
+ * ```
274469
+ *
274470
+ * ``` ts
274471
+ * i18.translateKeys("string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!"") // returns "string with First Value followed by Second Value!"
274472
+ * ```
274473
+ * @param line The input line, potentially containing %{keys}.
274474
+ * @returns The line with all %{keys} translated
274475
+ * @public
274476
+ */
274477
+ getLocalizedKeys(line) {
274478
+ return line.replace(/\%\{(.+?)\}/g, (_match, tag) => this.getLocalizedString(tag));
274479
+ }
274480
+ /** Return the translated value of a key.
274481
+ * @param key - the key that matches a property in the JSON localization file.
274482
+ * @note The key includes the namespace, which identifies the particular localization file that contains the property,
274483
+ * followed by a colon, followed by the property in the JSON file.
274484
+ * For example:
274485
+ * ``` ts
274486
+ * const dataString: string = IModelApp.localization.getLocalizedString("iModelJs:BackgroundMap.BingDataAttribution");
274487
+ * ```
274488
+ * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.
274489
+ * @returns The string corresponding to the first key that resolves.
274490
+ * @throws Error if no keys resolve to a string.
274491
+ * @public
274492
+ */
274493
+ getLocalizedString(key, options) {
274494
+ if ((options === null || options === void 0 ? void 0 : options.returnDetails) || (options === null || options === void 0 ? void 0 : options.returnObjects)) {
274495
+ throw new Error("Translation key must map to a string, but the given options will result in an object");
274496
+ }
274497
+ const value = this.i18next.t(key, options);
274498
+ if (typeof value !== "string") {
274499
+ throw new Error("Translation key(s) string not found");
274500
+ }
274501
+ return value;
274502
+ }
274503
+ /** Similar to `getLocalizedString` but the default namespace is a separate parameter and the key does not need
274504
+ * to include a namespace. If a key includes a namespace, that namespace will be used for interpolating that key.
274505
+ * @param namespace - the namespace that identifies the particular localization file that contains the property.
274506
+ * @param key - the key that matches a property in the JSON localization file.
274507
+ * @returns The string corresponding to the first key that resolves.
274508
+ * @throws Error if no keys resolve to a string.
274509
+ * @internal
274510
+ */
274511
+ getLocalizedStringWithNamespace(namespace, key, options) {
274512
+ let fullKey = "";
274513
+ if (typeof key === "string") {
274514
+ fullKey = `${namespace}:${key}`;
274515
+ }
274516
+ else {
274517
+ fullKey = key.map((subKey) => {
274518
+ return `${namespace}:${subKey}`;
274519
+ });
274520
+ }
274521
+ return this.getLocalizedString(fullKey, options);
274522
+ }
274523
+ /** Gets the English translation.
274524
+ * @param namespace - the namespace that identifies the particular localization file that contains the property.
274525
+ * @param key - the key that matches a property in the JSON localization file.
274526
+ * @returns The string corresponding to the first key that resolves.
274527
+ * @throws Error if no keys resolve to a string.
274528
+ * @internal
274529
+ */
274530
+ getEnglishString(namespace, key, options) {
274531
+ if ((options === null || options === void 0 ? void 0 : options.returnDetails) || (options === null || options === void 0 ? void 0 : options.returnObjects)) {
274532
+ throw new Error("Translation key must map to a string, but the given options will result in an object");
274533
+ }
274534
+ options = {
274535
+ ...options,
274536
+ ns: namespace, // ensure namespace argument is used
274537
+ };
274538
+ const en = this.i18next.getFixedT("en", namespace);
274539
+ const str = en(key, options);
274540
+ if (typeof str !== "string")
274541
+ throw new Error("Translation key(s) not found");
274542
+ return str;
274543
+ }
274544
+ /** Get the promise for an already registered Namespace.
274545
+ * @param name - the name of the namespace
274546
+ * @public
274547
+ */
274548
+ getNamespacePromise(name) {
274549
+ return this._namespaces.get(name);
274550
+ }
274551
+ /** @internal */
274552
+ getLanguageList() {
274553
+ return this.i18next.languages;
274554
+ }
274555
+ /** override the language detected in the browser */
274556
+ async changeLanguage(language) {
274557
+ return this.i18next.changeLanguage(language);
274558
+ }
274559
+ /** Register a new Namespace and return it. If the namespace is already registered, it will be returned.
274560
+ * @param name - the name of the namespace, which is the base name of the JSON file that contains the localization properties.
274561
+ * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,
274562
+ * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await
274563
+ * fulfillment of the readPromise Promise property of the returned LocalizationNamespace.
274564
+ * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)
274565
+ * @public
274566
+ */
274567
+ async registerNamespace(name) {
274568
+ const existing = this._namespaces.get(name);
274569
+ if (existing !== undefined)
274570
+ return existing;
274571
+ const theReadPromise = new Promise((resolve) => {
274572
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
274573
+ this.i18next.loadNamespaces(name, (err) => {
274574
+ if (!err)
274575
+ return resolve();
274576
+ // Here we got a non-null err object.
274577
+ // This method is called when the system has attempted to load the resources for the namespaces for each possible locale.
274578
+ // For example 'fr-ca' might be the most specific locale, in which case 'fr' and 'en' are fallback locales.
274579
+ // Using Backend from i18next-http-backend, err will be an array of strings of each namespace it tried to read and its locale.
274580
+ // There might be errs for some other namespaces as well as this one. We resolve the promise unless there's an error for each possible locale.
274581
+ let locales = this.getLanguageList().map((thisLocale) => `/${thisLocale}/`);
274582
+ try {
274583
+ for (const thisError of err) {
274584
+ if (typeof thisError === "string")
274585
+ locales = locales.filter((thisLocale) => !thisError.includes(thisLocale));
274586
+ }
274587
+ }
274588
+ catch (e) {
274589
+ locales = [];
274590
+ }
274591
+ // if we removed every locale from the array, it wasn't loaded.
274592
+ if (locales.length === 0)
274593
+ _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logError("i18n", `No resources for namespace ${name} could be loaded`);
274594
+ resolve();
274595
+ });
274596
+ });
274597
+ this._namespaces.set(name, theReadPromise);
274598
+ return theReadPromise;
274599
+ }
274600
+ /** @internal */
274601
+ unregisterNamespace(name) {
274602
+ this._namespaces.delete(name);
274603
+ }
274604
+ }
274605
+ class TranslationLogger {
274606
+ log(args) { _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logInfo("i18n", this.createLogMessage(args)); }
274607
+ warn(args) { _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logWarning("i18n", this.createLogMessage(args)); }
274608
+ error(args) { _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_3__.Logger.logError("i18n", this.createLogMessage(args)); }
274609
+ createLogMessage(args) {
274610
+ let message = args[0];
274611
+ for (let i = 1; i < args.length; ++i) {
274612
+ if (typeof args[i] === "string")
274613
+ message += `\n ${args[i]}`;
274614
+ }
274615
+ return message;
274616
+ }
274617
+ }
274618
+ TranslationLogger.type = "logger";
274648
274619
 
274649
274620
 
274650
274621
  /***/ }),
@@ -274661,17 +274632,17 @@ __webpack_require__.r(__webpack_exports__);
274661
274632
  /* harmony export */ "ITwinLocalization": () => (/* reexport safe */ _ITwinLocalization__WEBPACK_IMPORTED_MODULE_0__.ITwinLocalization)
274662
274633
  /* harmony export */ });
274663
274634
  /* harmony import */ var _ITwinLocalization__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ITwinLocalization */ "../../core/i18n/lib/esm/ITwinLocalization.js");
274664
- /*---------------------------------------------------------------------------------------------
274665
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
274666
- * See LICENSE.md in the project root for license terms and full copyright notice.
274667
- *--------------------------------------------------------------------------------------------*/
274668
-
274669
- /** @docs-package-description
274670
- * The core-i18n package contains classes related to internationalization and localization.
274671
- */
274672
- /** @docs-group-description Localization
274673
- * Classes for internationalization and localization of your app.
274674
- */
274635
+ /*---------------------------------------------------------------------------------------------
274636
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
274637
+ * See LICENSE.md in the project root for license terms and full copyright notice.
274638
+ *--------------------------------------------------------------------------------------------*/
274639
+
274640
+ /** @docs-package-description
274641
+ * The core-i18n package contains classes related to internationalization and localization.
274642
+ */
274643
+ /** @docs-group-description Localization
274644
+ * Classes for internationalization and localization of your app.
274645
+ */
274675
274646
 
274676
274647
 
274677
274648
  /***/ }),
@@ -305284,7 +305255,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.21.4","description":"P
305284
305255
  /***/ ((module) => {
305285
305256
 
305286
305257
  "use strict";
305287
- module.exports = JSON.parse('{"name":"@itwin/core-frontend","version":"3.7.1","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs","build:ci":"npm run -s build && npm run -s build:esm","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2020 --outDir lib/esm","clean":"rimraf lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","docs":"betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/primitives,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-eslintrc -c \\"../../tools/eslint-plugin/dist/configs/extension-exports-config.js\\" \\"./src/**/*.ts\\" 1>&2","lint":"eslint -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run -s webpackTests && certa -r chrome","cover":"npm -s test","test:debug":"certa -r chrome --debug","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core/tree/master/core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:^3.7.1","@itwin/core-bentley":"workspace:^3.7.1","@itwin/core-common":"workspace:^3.7.1","@itwin/core-geometry":"workspace:^3.7.1","@itwin/core-orbitgt":"workspace:^3.7.1","@itwin/core-quantity":"workspace:^3.7.1","@itwin/webgl-compatibility":"workspace:^3.7.1"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/certa":"workspace:*","@itwin/eslint-plugin":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@types/chai":"4.3.1","@types/chai-as-promised":"^7","@types/deep-assign":"^0.1.0","@types/lodash":"^4.14.0","@types/mocha":"^8.2.2","@types/node":"18.11.5","@types/qs":"^6.5.0","@types/semver":"7.3.10","@types/superagent":"^4.1.14","@types/sinon":"^9.0.0","babel-loader":"~8.2.5","babel-plugin-istanbul":"~6.1.1","chai":"^4.1.2","chai-as-promised":"^7","cpx2":"^3.0.0","eslint":"^7.11.0","glob":"^7.1.2","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^3.0.2","sinon":"^9.0.2","source-map-loader":"^4.0.0","typescript":"~4.4.0","webpack":"^5.76.0"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/object-storage-azure":"~1.4.0","@itwin/cloud-agnostic-core":"~1.4.0","@itwin/object-storage-core":"~1.4.0","@itwin/core-i18n":"workspace:*","@itwin/core-telemetry":"workspace:*","@loaders.gl/core":"^3.1.6","@loaders.gl/draco":"^3.1.6","deep-assign":"^2.0.0","fuse.js":"^3.3.0","lodash":"^4.17.10","qs":"^6.5.3","semver":"^7.3.5","superagent":"^7.1.5","wms-capabilities":"0.4.0","reflect-metadata":"0.1.13"},"nyc":{"extends":"./node_modules/@itwin/build-tools/.nycrc"},"eslintConfig":{"plugins":["@itwin"],"extends":"plugin:@itwin/itwinjs-recommended","rules":{"@itwin/no-internal-barrel-imports":["error",{"required-barrel-modules":["./src/tile/internal.ts"]}],"@itwin/public-extension-exports":["error",{"releaseTags":["public","preview"],"outputApiFile":false}]},"overrides":[{"files":["*.test.ts","*.test.tsx","**/test/**/*.ts"],"rules":{"@itwin/no-internal-barrel-imports":"off"}}]}}');
305258
+ module.exports = JSON.parse('{"name":"@itwin/core-frontend","version":"3.7.2","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs","build:ci":"npm run -s build && npm run -s build:esm","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2020 --outDir lib/esm","clean":"rimraf lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","docs":"betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/primitives,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-eslintrc -c \\"../../tools/eslint-plugin/dist/configs/extension-exports-config.js\\" \\"./src/**/*.ts\\" 1>&2","lint":"eslint -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run -s webpackTests && certa -r chrome","cover":"npm -s test","test:debug":"certa -r chrome --debug","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core/tree/master/core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:^3.7.2","@itwin/core-bentley":"workspace:^3.7.2","@itwin/core-common":"workspace:^3.7.2","@itwin/core-geometry":"workspace:^3.7.2","@itwin/core-orbitgt":"workspace:^3.7.2","@itwin/core-quantity":"workspace:^3.7.2","@itwin/webgl-compatibility":"workspace:^3.7.2"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/certa":"workspace:*","@itwin/eslint-plugin":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@types/chai":"4.3.1","@types/chai-as-promised":"^7","@types/deep-assign":"^0.1.0","@types/lodash":"^4.14.0","@types/mocha":"^8.2.2","@types/node":"18.11.5","@types/qs":"^6.5.0","@types/semver":"7.3.10","@types/superagent":"^4.1.14","@types/sinon":"^9.0.0","babel-loader":"~8.2.5","babel-plugin-istanbul":"~6.1.1","chai":"^4.1.2","chai-as-promised":"^7","cpx2":"^3.0.0","eslint":"^7.11.0","glob":"^7.1.2","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^3.0.2","sinon":"^9.0.2","source-map-loader":"^4.0.0","typescript":"~4.4.0","webpack":"^5.76.0"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/object-storage-azure":"~1.4.0","@itwin/cloud-agnostic-core":"~1.4.0","@itwin/object-storage-core":"~1.4.0","@itwin/core-i18n":"workspace:*","@itwin/core-telemetry":"workspace:*","@loaders.gl/core":"^3.1.6","@loaders.gl/draco":"^3.1.6","deep-assign":"^2.0.0","fuse.js":"^3.3.0","lodash":"^4.17.10","qs":"^6.5.3","semver":"^7.3.5","superagent":"^7.1.5","wms-capabilities":"0.4.0","reflect-metadata":"0.1.13"},"nyc":{"extends":"./node_modules/@itwin/build-tools/.nycrc"},"eslintConfig":{"plugins":["@itwin"],"extends":"plugin:@itwin/itwinjs-recommended","rules":{"@itwin/no-internal-barrel-imports":["error",{"required-barrel-modules":["./src/tile/internal.ts"]}],"@itwin/public-extension-exports":["error",{"releaseTags":["public","preview"],"outputApiFile":false}]},"overrides":[{"files":["*.test.ts","*.test.tsx","**/test/**/*.ts"],"rules":{"@itwin/no-internal-barrel-imports":"off"}}]}}');
305288
305259
 
305289
305260
  /***/ })
305290
305261