@itwin/core-i18n 5.15.0-dev.12 → 5.15.0-dev.14
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.
|
@@ -17339,6 +17339,7 @@ function assert(condition, message) {
|
|
|
17339
17339
|
"use strict";
|
|
17340
17340
|
__webpack_require__.r(__webpack_exports__);
|
|
17341
17341
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
17342
|
+
/* harmony export */ BeAsyncEvent: () => (/* binding */ BeAsyncEvent),
|
|
17342
17343
|
/* harmony export */ BeEvent: () => (/* binding */ BeEvent),
|
|
17343
17344
|
/* harmony export */ BeEventList: () => (/* binding */ BeEventList),
|
|
17344
17345
|
/* harmony export */ BeUiEvent: () => (/* binding */ BeUiEvent),
|
|
@@ -17426,8 +17427,13 @@ class BeEvent {
|
|
|
17426
17427
|
dropped = true;
|
|
17427
17428
|
}
|
|
17428
17429
|
else {
|
|
17430
|
+
const listener = context.listener;
|
|
17431
|
+
if (context.once) {
|
|
17432
|
+
context.listener = undefined;
|
|
17433
|
+
dropped = true;
|
|
17434
|
+
}
|
|
17429
17435
|
try {
|
|
17430
|
-
|
|
17436
|
+
listener.apply(context.scope, args);
|
|
17431
17437
|
}
|
|
17432
17438
|
catch (e) {
|
|
17433
17439
|
_UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(e);
|
|
@@ -17436,10 +17442,6 @@ class BeEvent {
|
|
|
17436
17442
|
// listener was removed during its own callback
|
|
17437
17443
|
dropped = true;
|
|
17438
17444
|
}
|
|
17439
|
-
else if (context.once) {
|
|
17440
|
-
context.listener = undefined;
|
|
17441
|
-
dropped = true;
|
|
17442
|
-
}
|
|
17443
17445
|
}
|
|
17444
17446
|
}
|
|
17445
17447
|
this._emitDepth--;
|
|
@@ -17483,8 +17485,6 @@ class BeUiEvent extends BeEvent {
|
|
|
17483
17485
|
*/
|
|
17484
17486
|
class BeUnorderedEvent {
|
|
17485
17487
|
_listeners = new Set();
|
|
17486
|
-
_emitDepth = 0;
|
|
17487
|
-
_hasTombstones = false;
|
|
17488
17488
|
/** The number of listeners currently subscribed to the event.
|
|
17489
17489
|
* @note During `raiseEvent()`, this may include listeners that have been removed or are one-shot
|
|
17490
17490
|
* but are awaiting deferred cleanup. The count is accurate outside of `raiseEvent()`.
|
|
@@ -17514,43 +17514,26 @@ class BeUnorderedEvent {
|
|
|
17514
17514
|
}
|
|
17515
17515
|
/** Remove a specific context entry, deferring during emit. */
|
|
17516
17516
|
_removeCtx(ctx) {
|
|
17517
|
-
|
|
17518
|
-
ctx.listener = undefined; // tombstone for deferred cleanup
|
|
17519
|
-
this._hasTombstones = true;
|
|
17520
|
-
}
|
|
17521
|
-
else {
|
|
17522
|
-
this._listeners.delete(ctx);
|
|
17523
|
-
}
|
|
17517
|
+
this._listeners.delete(ctx);
|
|
17524
17518
|
}
|
|
17525
17519
|
/**
|
|
17526
17520
|
* Raises the event by calling each registered listener with the supplied arguments.
|
|
17527
17521
|
* @param args This method takes any number of parameters and passes them through to the listeners.
|
|
17528
17522
|
*/
|
|
17529
17523
|
raiseEvent(...args) {
|
|
17530
|
-
this._emitDepth++;
|
|
17531
17524
|
for (const ctx of this._listeners) {
|
|
17532
17525
|
if (!ctx.listener) {
|
|
17533
17526
|
continue;
|
|
17534
17527
|
}
|
|
17528
|
+
if (ctx.once) {
|
|
17529
|
+
this._listeners.delete(ctx);
|
|
17530
|
+
}
|
|
17535
17531
|
try {
|
|
17536
17532
|
ctx.listener.apply(ctx.scope, args);
|
|
17537
17533
|
}
|
|
17538
17534
|
catch (e) {
|
|
17539
17535
|
_UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(e);
|
|
17540
17536
|
}
|
|
17541
|
-
if (ctx.listener && ctx.once) {
|
|
17542
|
-
ctx.listener = undefined;
|
|
17543
|
-
this._hasTombstones = true;
|
|
17544
|
-
}
|
|
17545
|
-
}
|
|
17546
|
-
this._emitDepth--;
|
|
17547
|
-
// Only clean up tombstoned entries when we're back at the outermost emit
|
|
17548
|
-
if (this._hasTombstones && this._emitDepth === 0) {
|
|
17549
|
-
this._hasTombstones = false;
|
|
17550
|
-
for (const ctx of this._listeners) {
|
|
17551
|
-
if (ctx.listener === undefined)
|
|
17552
|
-
this._listeners.delete(ctx);
|
|
17553
|
-
}
|
|
17554
17537
|
}
|
|
17555
17538
|
}
|
|
17556
17539
|
/** Clear all listeners from this BeUnorderedEvent.
|
|
@@ -17566,6 +17549,108 @@ class BeUnorderedUiEvent extends BeUnorderedEvent {
|
|
|
17566
17549
|
/** Raises event with single strongly typed argument. */
|
|
17567
17550
|
emit(args) { this.raiseEvent(args); }
|
|
17568
17551
|
}
|
|
17552
|
+
/**
|
|
17553
|
+
* Manages a set of *listeners* for a particular event and notifies them when the event is raised.
|
|
17554
|
+
* Each listener is async (return a Promise<void>). The listeners may be invoked in series
|
|
17555
|
+
* or concurrently depending on the configuration of the instance.
|
|
17556
|
+
*
|
|
17557
|
+
* Like [[BeUnorderedEvent]], this class uses a `Set` internally to support more performant removal
|
|
17558
|
+
* of old listeners. When a listener is removed during emit, it is marked for deferred removal instead
|
|
17559
|
+
* of mutating the set immediately. Despite the "unordered" implication, items in a `Set` are enumerated
|
|
17560
|
+
* in insertion order, which means that this class invokes the listeners in insertion order.
|
|
17561
|
+
*
|
|
17562
|
+
* Listeners are managed exclusively through the disposal closure returned by [[addListener]] and
|
|
17563
|
+
* [[addOnce]]. There is no `removeListener` or `has` method — callers must capture the returned
|
|
17564
|
+
* closure to unsubscribe.
|
|
17565
|
+
* @beta
|
|
17566
|
+
*/
|
|
17567
|
+
class BeAsyncEvent {
|
|
17568
|
+
_listeners = new Set();
|
|
17569
|
+
_concurrent = false;
|
|
17570
|
+
_promiseRejectionIsUnexpected = false;
|
|
17571
|
+
constructor(options) {
|
|
17572
|
+
if (options?.concurrent)
|
|
17573
|
+
this._concurrent = true;
|
|
17574
|
+
if (options?.promiseRejectionIsUnexpected)
|
|
17575
|
+
this._promiseRejectionIsUnexpected = true;
|
|
17576
|
+
}
|
|
17577
|
+
/** The number of listeners currently subscribed to the event.
|
|
17578
|
+
* @note During `raiseEvent()`, this may include listeners that have been removed or are one-shot
|
|
17579
|
+
* but are awaiting deferred cleanup. The count is accurate outside of `raiseEvent()`.
|
|
17580
|
+
*/
|
|
17581
|
+
get numberOfListeners() { return this._listeners.size; }
|
|
17582
|
+
/**
|
|
17583
|
+
* Registers a Listener to be executed whenever this event is raised.
|
|
17584
|
+
* @param listener The function to be executed when the event is raised.
|
|
17585
|
+
* @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.
|
|
17586
|
+
* @returns A function that will remove this event listener in O(1).
|
|
17587
|
+
*/
|
|
17588
|
+
addListener(listener, scope) {
|
|
17589
|
+
const ctx = { listener, scope, once: false };
|
|
17590
|
+
this._listeners.add(ctx);
|
|
17591
|
+
return () => this._removeCtx(ctx);
|
|
17592
|
+
}
|
|
17593
|
+
/**
|
|
17594
|
+
* Registers a callback function to be executed *only once* when the event is raised.
|
|
17595
|
+
* @param listener The function to be executed once when the event is raised.
|
|
17596
|
+
* @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.
|
|
17597
|
+
* @returns A function that will remove this event listener in O(1).
|
|
17598
|
+
*/
|
|
17599
|
+
addOnce(listener, scope) {
|
|
17600
|
+
const ctx = { listener, scope, once: true };
|
|
17601
|
+
this._listeners.add(ctx);
|
|
17602
|
+
return () => this._removeCtx(ctx);
|
|
17603
|
+
}
|
|
17604
|
+
/** Remove a specific context entry, deferring during emit. */
|
|
17605
|
+
_removeCtx(ctx) {
|
|
17606
|
+
this._listeners.delete(ctx);
|
|
17607
|
+
}
|
|
17608
|
+
/**
|
|
17609
|
+
* Raises the event by calling each registered listener with the supplied arguments.
|
|
17610
|
+
*
|
|
17611
|
+
* See [[BeAsyncEventOptions]] for options that control the behavior of this method.
|
|
17612
|
+
*
|
|
17613
|
+
* @param args This method takes any number of parameters and passes them through to the listeners.
|
|
17614
|
+
* @returns A Promise that settles when the event invocation is complete.
|
|
17615
|
+
*/
|
|
17616
|
+
async raiseEvent(...args) {
|
|
17617
|
+
const promises = [];
|
|
17618
|
+
// Wrapper to ensure that an exception thrown immediately by a listener is captured as a rejected promise rather than
|
|
17619
|
+
// allowed to propagate as an exception. A well-behaved Promise-returning function should never throw, but
|
|
17620
|
+
// this defends against the poorly-behaved ones. In Node 23+ we could use `Promise.try` instead.
|
|
17621
|
+
const invoke = async (ctx, args) => {
|
|
17622
|
+
if (!ctx.listener)
|
|
17623
|
+
return;
|
|
17624
|
+
await ctx.listener.apply(ctx.scope, args);
|
|
17625
|
+
};
|
|
17626
|
+
for (const ctx of this._listeners) {
|
|
17627
|
+
if (!ctx.listener)
|
|
17628
|
+
continue;
|
|
17629
|
+
if (ctx.once) {
|
|
17630
|
+
// Set guarantees this is safe during iteration.
|
|
17631
|
+
this._listeners.delete(ctx);
|
|
17632
|
+
}
|
|
17633
|
+
let promise = invoke(ctx, args);
|
|
17634
|
+
if (this._promiseRejectionIsUnexpected)
|
|
17635
|
+
promise = promise.catch(reason => _UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(reason));
|
|
17636
|
+
if (this._concurrent)
|
|
17637
|
+
promises.push(promise);
|
|
17638
|
+
else
|
|
17639
|
+
await promise;
|
|
17640
|
+
}
|
|
17641
|
+
if (this._concurrent) {
|
|
17642
|
+
const result = await Promise.allSettled(promises);
|
|
17643
|
+
const firstRejection = result.find(r => r.status === "rejected");
|
|
17644
|
+
if (firstRejection)
|
|
17645
|
+
throw firstRejection.reason;
|
|
17646
|
+
}
|
|
17647
|
+
}
|
|
17648
|
+
/** Clear all listeners from this BeAsyncEvent.
|
|
17649
|
+
* @note If called during `raiseEvent`, remaining listeners in the current iteration are skipped
|
|
17650
|
+
* immediately rather than being tombstoned.
|
|
17651
|
+
*/
|
|
17652
|
+
clear() { this._listeners.clear(); }
|
|
17653
|
+
}
|
|
17569
17654
|
/**
|
|
17570
17655
|
* A list of BeEvent objects, accessible by an event name.
|
|
17571
17656
|
* This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.
|
|
@@ -20122,16 +20207,18 @@ var Id64;
|
|
|
20122
20207
|
Id64.getFirst = getFirst;
|
|
20123
20208
|
/** Return the number of [[Id64String]]s represented by an [[Id64Arg]]. */
|
|
20124
20209
|
function sizeOf(arg) {
|
|
20125
|
-
return typeof arg === "string" ? 1 :
|
|
20210
|
+
return typeof arg === "string" ? 1 : "size" in arg ? arg.size : arg.length;
|
|
20126
20211
|
}
|
|
20127
20212
|
Id64.sizeOf = sizeOf;
|
|
20128
20213
|
/** Returns true if the [[Id64Arg]] contains the specified Id. */
|
|
20129
20214
|
function has(arg, id) {
|
|
20130
|
-
if (typeof arg === "string")
|
|
20215
|
+
if (typeof arg === "string") {
|
|
20131
20216
|
return arg === id;
|
|
20132
|
-
|
|
20133
|
-
|
|
20134
|
-
|
|
20217
|
+
}
|
|
20218
|
+
if ("has" in arg) {
|
|
20219
|
+
return arg.has(id);
|
|
20220
|
+
}
|
|
20221
|
+
return -1 !== arg.indexOf(id);
|
|
20135
20222
|
}
|
|
20136
20223
|
Id64.has = has;
|
|
20137
20224
|
/** The string representation of an invalid Id. */
|
|
@@ -24201,6 +24288,7 @@ class YieldManager {
|
|
|
24201
24288
|
__webpack_require__.r(__webpack_exports__);
|
|
24202
24289
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
24203
24290
|
/* harmony export */ AbandonedError: () => (/* reexport safe */ _OneAtATimeAction__WEBPACK_IMPORTED_MODULE_22__.AbandonedError),
|
|
24291
|
+
/* harmony export */ BeAsyncEvent: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeAsyncEvent),
|
|
24204
24292
|
/* harmony export */ BeDuration: () => (/* reexport safe */ _Time__WEBPACK_IMPORTED_MODULE_30__.BeDuration),
|
|
24205
24293
|
/* harmony export */ BeEvent: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeEvent),
|
|
24206
24294
|
/* harmony export */ BeEventList: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeEventList),
|