@itwin/core-i18n 5.15.0-dev.13 → 5.15.0-dev.15
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.
|
@@ -15011,6 +15011,7 @@ function assert(condition, message) {
|
|
|
15011
15011
|
"use strict";
|
|
15012
15012
|
__webpack_require__.r(__webpack_exports__);
|
|
15013
15013
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
15014
|
+
/* harmony export */ BeAsyncEvent: () => (/* binding */ BeAsyncEvent),
|
|
15014
15015
|
/* harmony export */ BeEvent: () => (/* binding */ BeEvent),
|
|
15015
15016
|
/* harmony export */ BeEventList: () => (/* binding */ BeEventList),
|
|
15016
15017
|
/* harmony export */ BeUiEvent: () => (/* binding */ BeUiEvent),
|
|
@@ -15098,8 +15099,13 @@ class BeEvent {
|
|
|
15098
15099
|
dropped = true;
|
|
15099
15100
|
}
|
|
15100
15101
|
else {
|
|
15102
|
+
const listener = context.listener;
|
|
15103
|
+
if (context.once) {
|
|
15104
|
+
context.listener = undefined;
|
|
15105
|
+
dropped = true;
|
|
15106
|
+
}
|
|
15101
15107
|
try {
|
|
15102
|
-
|
|
15108
|
+
listener.apply(context.scope, args);
|
|
15103
15109
|
}
|
|
15104
15110
|
catch (e) {
|
|
15105
15111
|
_UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(e);
|
|
@@ -15108,10 +15114,6 @@ class BeEvent {
|
|
|
15108
15114
|
// listener was removed during its own callback
|
|
15109
15115
|
dropped = true;
|
|
15110
15116
|
}
|
|
15111
|
-
else if (context.once) {
|
|
15112
|
-
context.listener = undefined;
|
|
15113
|
-
dropped = true;
|
|
15114
|
-
}
|
|
15115
15117
|
}
|
|
15116
15118
|
}
|
|
15117
15119
|
this._emitDepth--;
|
|
@@ -15155,8 +15157,6 @@ class BeUiEvent extends BeEvent {
|
|
|
15155
15157
|
*/
|
|
15156
15158
|
class BeUnorderedEvent {
|
|
15157
15159
|
_listeners = new Set();
|
|
15158
|
-
_emitDepth = 0;
|
|
15159
|
-
_hasTombstones = false;
|
|
15160
15160
|
/** The number of listeners currently subscribed to the event.
|
|
15161
15161
|
* @note During `raiseEvent()`, this may include listeners that have been removed or are one-shot
|
|
15162
15162
|
* but are awaiting deferred cleanup. The count is accurate outside of `raiseEvent()`.
|
|
@@ -15186,43 +15186,26 @@ class BeUnorderedEvent {
|
|
|
15186
15186
|
}
|
|
15187
15187
|
/** Remove a specific context entry, deferring during emit. */
|
|
15188
15188
|
_removeCtx(ctx) {
|
|
15189
|
-
|
|
15190
|
-
ctx.listener = undefined; // tombstone for deferred cleanup
|
|
15191
|
-
this._hasTombstones = true;
|
|
15192
|
-
}
|
|
15193
|
-
else {
|
|
15194
|
-
this._listeners.delete(ctx);
|
|
15195
|
-
}
|
|
15189
|
+
this._listeners.delete(ctx);
|
|
15196
15190
|
}
|
|
15197
15191
|
/**
|
|
15198
15192
|
* Raises the event by calling each registered listener with the supplied arguments.
|
|
15199
15193
|
* @param args This method takes any number of parameters and passes them through to the listeners.
|
|
15200
15194
|
*/
|
|
15201
15195
|
raiseEvent(...args) {
|
|
15202
|
-
this._emitDepth++;
|
|
15203
15196
|
for (const ctx of this._listeners) {
|
|
15204
15197
|
if (!ctx.listener) {
|
|
15205
15198
|
continue;
|
|
15206
15199
|
}
|
|
15200
|
+
if (ctx.once) {
|
|
15201
|
+
this._listeners.delete(ctx);
|
|
15202
|
+
}
|
|
15207
15203
|
try {
|
|
15208
15204
|
ctx.listener.apply(ctx.scope, args);
|
|
15209
15205
|
}
|
|
15210
15206
|
catch (e) {
|
|
15211
15207
|
_UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(e);
|
|
15212
15208
|
}
|
|
15213
|
-
if (ctx.listener && ctx.once) {
|
|
15214
|
-
ctx.listener = undefined;
|
|
15215
|
-
this._hasTombstones = true;
|
|
15216
|
-
}
|
|
15217
|
-
}
|
|
15218
|
-
this._emitDepth--;
|
|
15219
|
-
// Only clean up tombstoned entries when we're back at the outermost emit
|
|
15220
|
-
if (this._hasTombstones && this._emitDepth === 0) {
|
|
15221
|
-
this._hasTombstones = false;
|
|
15222
|
-
for (const ctx of this._listeners) {
|
|
15223
|
-
if (ctx.listener === undefined)
|
|
15224
|
-
this._listeners.delete(ctx);
|
|
15225
|
-
}
|
|
15226
15209
|
}
|
|
15227
15210
|
}
|
|
15228
15211
|
/** Clear all listeners from this BeUnorderedEvent.
|
|
@@ -15238,6 +15221,108 @@ class BeUnorderedUiEvent extends BeUnorderedEvent {
|
|
|
15238
15221
|
/** Raises event with single strongly typed argument. */
|
|
15239
15222
|
emit(args) { this.raiseEvent(args); }
|
|
15240
15223
|
}
|
|
15224
|
+
/**
|
|
15225
|
+
* Manages a set of *listeners* for a particular event and notifies them when the event is raised.
|
|
15226
|
+
* Each listener is async (return a Promise<void>). The listeners may be invoked in series
|
|
15227
|
+
* or concurrently depending on the configuration of the instance.
|
|
15228
|
+
*
|
|
15229
|
+
* Like [[BeUnorderedEvent]], this class uses a `Set` internally to support more performant removal
|
|
15230
|
+
* of old listeners. When a listener is removed during emit, it is marked for deferred removal instead
|
|
15231
|
+
* of mutating the set immediately. Despite the "unordered" implication, items in a `Set` are enumerated
|
|
15232
|
+
* in insertion order, which means that this class invokes the listeners in insertion order.
|
|
15233
|
+
*
|
|
15234
|
+
* Listeners are managed exclusively through the disposal closure returned by [[addListener]] and
|
|
15235
|
+
* [[addOnce]]. There is no `removeListener` or `has` method — callers must capture the returned
|
|
15236
|
+
* closure to unsubscribe.
|
|
15237
|
+
* @beta
|
|
15238
|
+
*/
|
|
15239
|
+
class BeAsyncEvent {
|
|
15240
|
+
_listeners = new Set();
|
|
15241
|
+
_concurrent = false;
|
|
15242
|
+
_promiseRejectionIsUnexpected = false;
|
|
15243
|
+
constructor(options) {
|
|
15244
|
+
if (options?.concurrent)
|
|
15245
|
+
this._concurrent = true;
|
|
15246
|
+
if (options?.promiseRejectionIsUnexpected)
|
|
15247
|
+
this._promiseRejectionIsUnexpected = true;
|
|
15248
|
+
}
|
|
15249
|
+
/** The number of listeners currently subscribed to the event.
|
|
15250
|
+
* @note During `raiseEvent()`, this may include listeners that have been removed or are one-shot
|
|
15251
|
+
* but are awaiting deferred cleanup. The count is accurate outside of `raiseEvent()`.
|
|
15252
|
+
*/
|
|
15253
|
+
get numberOfListeners() { return this._listeners.size; }
|
|
15254
|
+
/**
|
|
15255
|
+
* Registers a Listener to be executed whenever this event is raised.
|
|
15256
|
+
* @param listener The function to be executed when the event is raised.
|
|
15257
|
+
* @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.
|
|
15258
|
+
* @returns A function that will remove this event listener in O(1).
|
|
15259
|
+
*/
|
|
15260
|
+
addListener(listener, scope) {
|
|
15261
|
+
const ctx = { listener, scope, once: false };
|
|
15262
|
+
this._listeners.add(ctx);
|
|
15263
|
+
return () => this._removeCtx(ctx);
|
|
15264
|
+
}
|
|
15265
|
+
/**
|
|
15266
|
+
* Registers a callback function to be executed *only once* when the event is raised.
|
|
15267
|
+
* @param listener The function to be executed once when the event is raised.
|
|
15268
|
+
* @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.
|
|
15269
|
+
* @returns A function that will remove this event listener in O(1).
|
|
15270
|
+
*/
|
|
15271
|
+
addOnce(listener, scope) {
|
|
15272
|
+
const ctx = { listener, scope, once: true };
|
|
15273
|
+
this._listeners.add(ctx);
|
|
15274
|
+
return () => this._removeCtx(ctx);
|
|
15275
|
+
}
|
|
15276
|
+
/** Remove a specific context entry, deferring during emit. */
|
|
15277
|
+
_removeCtx(ctx) {
|
|
15278
|
+
this._listeners.delete(ctx);
|
|
15279
|
+
}
|
|
15280
|
+
/**
|
|
15281
|
+
* Raises the event by calling each registered listener with the supplied arguments.
|
|
15282
|
+
*
|
|
15283
|
+
* See [[BeAsyncEventOptions]] for options that control the behavior of this method.
|
|
15284
|
+
*
|
|
15285
|
+
* @param args This method takes any number of parameters and passes them through to the listeners.
|
|
15286
|
+
* @returns A Promise that settles when the event invocation is complete.
|
|
15287
|
+
*/
|
|
15288
|
+
async raiseEvent(...args) {
|
|
15289
|
+
const promises = [];
|
|
15290
|
+
// Wrapper to ensure that an exception thrown immediately by a listener is captured as a rejected promise rather than
|
|
15291
|
+
// allowed to propagate as an exception. A well-behaved Promise-returning function should never throw, but
|
|
15292
|
+
// this defends against the poorly-behaved ones. In Node 23+ we could use `Promise.try` instead.
|
|
15293
|
+
const invoke = async (ctx, args) => {
|
|
15294
|
+
if (!ctx.listener)
|
|
15295
|
+
return;
|
|
15296
|
+
await ctx.listener.apply(ctx.scope, args);
|
|
15297
|
+
};
|
|
15298
|
+
for (const ctx of this._listeners) {
|
|
15299
|
+
if (!ctx.listener)
|
|
15300
|
+
continue;
|
|
15301
|
+
if (ctx.once) {
|
|
15302
|
+
// Set guarantees this is safe during iteration.
|
|
15303
|
+
this._listeners.delete(ctx);
|
|
15304
|
+
}
|
|
15305
|
+
let promise = invoke(ctx, args);
|
|
15306
|
+
if (this._promiseRejectionIsUnexpected)
|
|
15307
|
+
promise = promise.catch(reason => _UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(reason));
|
|
15308
|
+
if (this._concurrent)
|
|
15309
|
+
promises.push(promise);
|
|
15310
|
+
else
|
|
15311
|
+
await promise;
|
|
15312
|
+
}
|
|
15313
|
+
if (this._concurrent) {
|
|
15314
|
+
const result = await Promise.allSettled(promises);
|
|
15315
|
+
const firstRejection = result.find(r => r.status === "rejected");
|
|
15316
|
+
if (firstRejection)
|
|
15317
|
+
throw firstRejection.reason;
|
|
15318
|
+
}
|
|
15319
|
+
}
|
|
15320
|
+
/** Clear all listeners from this BeAsyncEvent.
|
|
15321
|
+
* @note If called during `raiseEvent`, remaining listeners in the current iteration are skipped
|
|
15322
|
+
* immediately rather than being tombstoned.
|
|
15323
|
+
*/
|
|
15324
|
+
clear() { this._listeners.clear(); }
|
|
15325
|
+
}
|
|
15241
15326
|
/**
|
|
15242
15327
|
* A list of BeEvent objects, accessible by an event name.
|
|
15243
15328
|
* This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.
|
|
@@ -17794,16 +17879,18 @@ var Id64;
|
|
|
17794
17879
|
Id64.getFirst = getFirst;
|
|
17795
17880
|
/** Return the number of [[Id64String]]s represented by an [[Id64Arg]]. */
|
|
17796
17881
|
function sizeOf(arg) {
|
|
17797
|
-
return typeof arg === "string" ? 1 :
|
|
17882
|
+
return typeof arg === "string" ? 1 : "size" in arg ? arg.size : arg.length;
|
|
17798
17883
|
}
|
|
17799
17884
|
Id64.sizeOf = sizeOf;
|
|
17800
17885
|
/** Returns true if the [[Id64Arg]] contains the specified Id. */
|
|
17801
17886
|
function has(arg, id) {
|
|
17802
|
-
if (typeof arg === "string")
|
|
17887
|
+
if (typeof arg === "string") {
|
|
17803
17888
|
return arg === id;
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17889
|
+
}
|
|
17890
|
+
if ("has" in arg) {
|
|
17891
|
+
return arg.has(id);
|
|
17892
|
+
}
|
|
17893
|
+
return -1 !== arg.indexOf(id);
|
|
17807
17894
|
}
|
|
17808
17895
|
Id64.has = has;
|
|
17809
17896
|
/** The string representation of an invalid Id. */
|
|
@@ -21873,6 +21960,7 @@ class YieldManager {
|
|
|
21873
21960
|
__webpack_require__.r(__webpack_exports__);
|
|
21874
21961
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
21875
21962
|
/* harmony export */ AbandonedError: () => (/* reexport safe */ _OneAtATimeAction__WEBPACK_IMPORTED_MODULE_22__.AbandonedError),
|
|
21963
|
+
/* harmony export */ BeAsyncEvent: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeAsyncEvent),
|
|
21876
21964
|
/* harmony export */ BeDuration: () => (/* reexport safe */ _Time__WEBPACK_IMPORTED_MODULE_30__.BeDuration),
|
|
21877
21965
|
/* harmony export */ BeEvent: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeEvent),
|
|
21878
21966
|
/* harmony export */ BeEventList: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeEventList),
|