@itwin/ecschema-rpcinterface-tests 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.
@@ -18311,6 +18311,7 @@ function assert(condition, message) {
18311
18311
  "use strict";
18312
18312
  __webpack_require__.r(__webpack_exports__);
18313
18313
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
18314
+ /* harmony export */ BeAsyncEvent: () => (/* binding */ BeAsyncEvent),
18314
18315
  /* harmony export */ BeEvent: () => (/* binding */ BeEvent),
18315
18316
  /* harmony export */ BeEventList: () => (/* binding */ BeEventList),
18316
18317
  /* harmony export */ BeUiEvent: () => (/* binding */ BeUiEvent),
@@ -18398,8 +18399,13 @@ class BeEvent {
18398
18399
  dropped = true;
18399
18400
  }
18400
18401
  else {
18402
+ const listener = context.listener;
18403
+ if (context.once) {
18404
+ context.listener = undefined;
18405
+ dropped = true;
18406
+ }
18401
18407
  try {
18402
- context.listener.apply(context.scope, args);
18408
+ listener.apply(context.scope, args);
18403
18409
  }
18404
18410
  catch (e) {
18405
18411
  _UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(e);
@@ -18408,10 +18414,6 @@ class BeEvent {
18408
18414
  // listener was removed during its own callback
18409
18415
  dropped = true;
18410
18416
  }
18411
- else if (context.once) {
18412
- context.listener = undefined;
18413
- dropped = true;
18414
- }
18415
18417
  }
18416
18418
  }
18417
18419
  this._emitDepth--;
@@ -18455,8 +18457,6 @@ class BeUiEvent extends BeEvent {
18455
18457
  */
18456
18458
  class BeUnorderedEvent {
18457
18459
  _listeners = new Set();
18458
- _emitDepth = 0;
18459
- _hasTombstones = false;
18460
18460
  /** The number of listeners currently subscribed to the event.
18461
18461
  * @note During `raiseEvent()`, this may include listeners that have been removed or are one-shot
18462
18462
  * but are awaiting deferred cleanup. The count is accurate outside of `raiseEvent()`.
@@ -18486,43 +18486,26 @@ class BeUnorderedEvent {
18486
18486
  }
18487
18487
  /** Remove a specific context entry, deferring during emit. */
18488
18488
  _removeCtx(ctx) {
18489
- if (this._emitDepth > 0) {
18490
- ctx.listener = undefined; // tombstone for deferred cleanup
18491
- this._hasTombstones = true;
18492
- }
18493
- else {
18494
- this._listeners.delete(ctx);
18495
- }
18489
+ this._listeners.delete(ctx);
18496
18490
  }
18497
18491
  /**
18498
18492
  * Raises the event by calling each registered listener with the supplied arguments.
18499
18493
  * @param args This method takes any number of parameters and passes them through to the listeners.
18500
18494
  */
18501
18495
  raiseEvent(...args) {
18502
- this._emitDepth++;
18503
18496
  for (const ctx of this._listeners) {
18504
18497
  if (!ctx.listener) {
18505
18498
  continue;
18506
18499
  }
18500
+ if (ctx.once) {
18501
+ this._listeners.delete(ctx);
18502
+ }
18507
18503
  try {
18508
18504
  ctx.listener.apply(ctx.scope, args);
18509
18505
  }
18510
18506
  catch (e) {
18511
18507
  _UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(e);
18512
18508
  }
18513
- if (ctx.listener && ctx.once) {
18514
- ctx.listener = undefined;
18515
- this._hasTombstones = true;
18516
- }
18517
- }
18518
- this._emitDepth--;
18519
- // Only clean up tombstoned entries when we're back at the outermost emit
18520
- if (this._hasTombstones && this._emitDepth === 0) {
18521
- this._hasTombstones = false;
18522
- for (const ctx of this._listeners) {
18523
- if (ctx.listener === undefined)
18524
- this._listeners.delete(ctx);
18525
- }
18526
18509
  }
18527
18510
  }
18528
18511
  /** Clear all listeners from this BeUnorderedEvent.
@@ -18538,6 +18521,108 @@ class BeUnorderedUiEvent extends BeUnorderedEvent {
18538
18521
  /** Raises event with single strongly typed argument. */
18539
18522
  emit(args) { this.raiseEvent(args); }
18540
18523
  }
18524
+ /**
18525
+ * Manages a set of *listeners* for a particular event and notifies them when the event is raised.
18526
+ * Each listener is async (return a Promise<void>). The listeners may be invoked in series
18527
+ * or concurrently depending on the configuration of the instance.
18528
+ *
18529
+ * Like [[BeUnorderedEvent]], this class uses a `Set` internally to support more performant removal
18530
+ * of old listeners. When a listener is removed during emit, it is marked for deferred removal instead
18531
+ * of mutating the set immediately. Despite the "unordered" implication, items in a `Set` are enumerated
18532
+ * in insertion order, which means that this class invokes the listeners in insertion order.
18533
+ *
18534
+ * Listeners are managed exclusively through the disposal closure returned by [[addListener]] and
18535
+ * [[addOnce]]. There is no `removeListener` or `has` method — callers must capture the returned
18536
+ * closure to unsubscribe.
18537
+ * @beta
18538
+ */
18539
+ class BeAsyncEvent {
18540
+ _listeners = new Set();
18541
+ _concurrent = false;
18542
+ _promiseRejectionIsUnexpected = false;
18543
+ constructor(options) {
18544
+ if (options?.concurrent)
18545
+ this._concurrent = true;
18546
+ if (options?.promiseRejectionIsUnexpected)
18547
+ this._promiseRejectionIsUnexpected = true;
18548
+ }
18549
+ /** The number of listeners currently subscribed to the event.
18550
+ * @note During `raiseEvent()`, this may include listeners that have been removed or are one-shot
18551
+ * but are awaiting deferred cleanup. The count is accurate outside of `raiseEvent()`.
18552
+ */
18553
+ get numberOfListeners() { return this._listeners.size; }
18554
+ /**
18555
+ * Registers a Listener to be executed whenever this event is raised.
18556
+ * @param listener The function to be executed when the event is raised.
18557
+ * @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.
18558
+ * @returns A function that will remove this event listener in O(1).
18559
+ */
18560
+ addListener(listener, scope) {
18561
+ const ctx = { listener, scope, once: false };
18562
+ this._listeners.add(ctx);
18563
+ return () => this._removeCtx(ctx);
18564
+ }
18565
+ /**
18566
+ * Registers a callback function to be executed *only once* when the event is raised.
18567
+ * @param listener The function to be executed once when the event is raised.
18568
+ * @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.
18569
+ * @returns A function that will remove this event listener in O(1).
18570
+ */
18571
+ addOnce(listener, scope) {
18572
+ const ctx = { listener, scope, once: true };
18573
+ this._listeners.add(ctx);
18574
+ return () => this._removeCtx(ctx);
18575
+ }
18576
+ /** Remove a specific context entry, deferring during emit. */
18577
+ _removeCtx(ctx) {
18578
+ this._listeners.delete(ctx);
18579
+ }
18580
+ /**
18581
+ * Raises the event by calling each registered listener with the supplied arguments.
18582
+ *
18583
+ * See [[BeAsyncEventOptions]] for options that control the behavior of this method.
18584
+ *
18585
+ * @param args This method takes any number of parameters and passes them through to the listeners.
18586
+ * @returns A Promise that settles when the event invocation is complete.
18587
+ */
18588
+ async raiseEvent(...args) {
18589
+ const promises = [];
18590
+ // Wrapper to ensure that an exception thrown immediately by a listener is captured as a rejected promise rather than
18591
+ // allowed to propagate as an exception. A well-behaved Promise-returning function should never throw, but
18592
+ // this defends against the poorly-behaved ones. In Node 23+ we could use `Promise.try` instead.
18593
+ const invoke = async (ctx, args) => {
18594
+ if (!ctx.listener)
18595
+ return;
18596
+ await ctx.listener.apply(ctx.scope, args);
18597
+ };
18598
+ for (const ctx of this._listeners) {
18599
+ if (!ctx.listener)
18600
+ continue;
18601
+ if (ctx.once) {
18602
+ // Set guarantees this is safe during iteration.
18603
+ this._listeners.delete(ctx);
18604
+ }
18605
+ let promise = invoke(ctx, args);
18606
+ if (this._promiseRejectionIsUnexpected)
18607
+ promise = promise.catch(reason => _UnexpectedErrors__WEBPACK_IMPORTED_MODULE_0__.UnexpectedErrors.handle(reason));
18608
+ if (this._concurrent)
18609
+ promises.push(promise);
18610
+ else
18611
+ await promise;
18612
+ }
18613
+ if (this._concurrent) {
18614
+ const result = await Promise.allSettled(promises);
18615
+ const firstRejection = result.find(r => r.status === "rejected");
18616
+ if (firstRejection)
18617
+ throw firstRejection.reason;
18618
+ }
18619
+ }
18620
+ /** Clear all listeners from this BeAsyncEvent.
18621
+ * @note If called during `raiseEvent`, remaining listeners in the current iteration are skipped
18622
+ * immediately rather than being tombstoned.
18623
+ */
18624
+ clear() { this._listeners.clear(); }
18625
+ }
18541
18626
  /**
18542
18627
  * A list of BeEvent objects, accessible by an event name.
18543
18628
  * This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.
@@ -21094,16 +21179,18 @@ var Id64;
21094
21179
  Id64.getFirst = getFirst;
21095
21180
  /** Return the number of [[Id64String]]s represented by an [[Id64Arg]]. */
21096
21181
  function sizeOf(arg) {
21097
- return typeof arg === "string" ? 1 : (Array.isArray(arg) ? arg.length : arg.size);
21182
+ return typeof arg === "string" ? 1 : "size" in arg ? arg.size : arg.length;
21098
21183
  }
21099
21184
  Id64.sizeOf = sizeOf;
21100
21185
  /** Returns true if the [[Id64Arg]] contains the specified Id. */
21101
21186
  function has(arg, id) {
21102
- if (typeof arg === "string")
21187
+ if (typeof arg === "string") {
21103
21188
  return arg === id;
21104
- if (Array.isArray(arg))
21105
- return -1 !== arg.indexOf(id);
21106
- return arg.has(id);
21189
+ }
21190
+ if ("has" in arg) {
21191
+ return arg.has(id);
21192
+ }
21193
+ return -1 !== arg.indexOf(id);
21107
21194
  }
21108
21195
  Id64.has = has;
21109
21196
  /** The string representation of an invalid Id. */
@@ -25173,6 +25260,7 @@ class YieldManager {
25173
25260
  __webpack_require__.r(__webpack_exports__);
25174
25261
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
25175
25262
  /* harmony export */ AbandonedError: () => (/* reexport safe */ _OneAtATimeAction__WEBPACK_IMPORTED_MODULE_22__.AbandonedError),
25263
+ /* harmony export */ BeAsyncEvent: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeAsyncEvent),
25176
25264
  /* harmony export */ BeDuration: () => (/* reexport safe */ _Time__WEBPACK_IMPORTED_MODULE_30__.BeDuration),
25177
25265
  /* harmony export */ BeEvent: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeEvent),
25178
25266
  /* harmony export */ BeEventList: () => (/* reexport safe */ _BeEvent__WEBPACK_IMPORTED_MODULE_2__.BeEventList),
@@ -57777,8 +57865,7 @@ class RpcInvocation {
57777
57865
  return;
57778
57866
  for (let i = 0; i !== parameters.length; ++i) {
57779
57867
  const parameter = parameters[i];
57780
- const isToken = typeof (parameter) === "object" && parameter !== null && parameter.hasOwnProperty("iModelId") && parameter.hasOwnProperty("iTwinId");
57781
- if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {
57868
+ if (this.protocol.checkToken && !this.operation.policy.allowTokenMismatch && RpcInvocation.isTokenParameter(parameter, i)) {
57782
57869
  const inflated = this.protocol.inflateToken(parameter, this.request);
57783
57870
  parameters[i] = inflated;
57784
57871
  if (!RpcInvocation.compareTokens(parameter, inflated)) {
@@ -57792,9 +57879,20 @@ class RpcInvocation {
57792
57879
  }
57793
57880
  }
57794
57881
  }
57882
+ /** Determine whether an operation parameter is an [[IModelRpcProps]]. Every property of the token other than `key` is optional
57883
+ * and all of them are supplied by the caller, so the first parameter is treated as a token if it has *any* of the identifying properties.
57884
+ */
57885
+ static isTokenParameter(parameter, index) {
57886
+ if (typeof parameter !== "object" || parameter === null || Array.isArray(parameter))
57887
+ return false;
57888
+ const has = (prop) => Object.prototype.hasOwnProperty.call(parameter, prop);
57889
+ if (has("iModelId") && has("iTwinId"))
57890
+ return true;
57891
+ return 0 === index && (has("key") || has("iModelId") || has("iTwinId"));
57892
+ }
57795
57893
  static compareTokens(a, b) {
57796
57894
  return a.key === b.key &&
57797
- a.iTwinId === b.iTwinId &&
57895
+ (undefined === a.iTwinId || a.iTwinId === b.iTwinId) &&
57798
57896
  a.iModelId === b.iModelId &&
57799
57897
  (undefined === a.changeset || (a.changeset.id === b.changeset?.id));
57800
57898
  }
@@ -337611,7 +337709,7 @@ class WMS {
337611
337709
  (module) {
337612
337710
 
337613
337711
  "use strict";
337614
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.15.0-dev.13","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 && npm run -s build:esm && npm run -s build:workers && npm run -s copy:draco","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 ES2022 --outDir lib/esm","clean":"rimraf -g 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","copy:draco":"cpx \\"./node_modules/@loaders.gl/draco/dist/libs/*\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts && npm run -s extract","extract":"betools extract --fileExt=ts --extractFrom=./src/test/example-code --recursive --out=../../generated-docs/extract","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run build:test-worker && vitest --run","cover":"npm run build:test-worker && vitest --run","build:test-worker":"vite build --config ./src/test/worker/vite.config.mts 1>&2","build:workers":"rimraf lib/workers/webpack && vite build --config ./src/workers/ImdlParser/vite.config.mts 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//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":{"@bentley/aec-units-schema":"^1.0.3","@bentley/formats-schema":"^1.0.0","@bentley/units-schema":"^1.0.12","@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/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/object-storage-core":"^3.0.4","@itwin/eslint-plugin":"^6.0.0","@types/node":"~20.17.0","@types/sinon":"^17.0.2","@vitest/browser-playwright":"^4.1.10","@vitest/coverage-v8":"^4.1.10","cpx2":"^8.0.0","eslint":"^9.31.0","playwright":"~1.56.1","rimraf":"^6.0.1","sinon":"^17.0.2","typescript":"~5.6.2","vite":"^6.4.3","vitest":"^4.1.10"},"//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/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^4.4.5","@loaders.gl/draco":"^4.4.5","fuse.js":"^3.3.0","wms-capabilities":"0.6.0"}}');
337712
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.15.0-dev.15","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 && npm run -s build:esm && npm run -s build:workers && npm run -s copy:draco","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 ES2022 --outDir lib/esm","clean":"rimraf -g 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","copy:draco":"cpx \\"./node_modules/@loaders.gl/draco/dist/libs/*\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts && npm run -s extract","extract":"betools extract --fileExt=ts --extractFrom=./src/test/example-code --recursive --out=../../generated-docs/extract","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run build:test-worker && vitest --run","cover":"npm run build:test-worker && vitest --run","build:test-worker":"vite build --config ./src/test/worker/vite.config.mts 1>&2","build:workers":"rimraf lib/workers/webpack && vite build --config ./src/workers/ImdlParser/vite.config.mts 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//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":{"@bentley/aec-units-schema":"^1.0.3","@bentley/formats-schema":"^1.0.0","@bentley/units-schema":"^1.0.12","@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/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/object-storage-core":"^3.0.4","@itwin/eslint-plugin":"^6.0.0","@types/node":"~20.17.0","@types/sinon":"^17.0.2","@vitest/browser-playwright":"^4.1.10","@vitest/coverage-v8":"^4.1.10","cpx2":"^8.0.0","eslint":"^9.31.0","playwright":"~1.56.1","rimraf":"^6.0.1","sinon":"^17.0.2","typescript":"~5.6.2","vite":"^6.4.4","vitest":"^4.1.10"},"//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/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^4.4.5","@loaders.gl/draco":"^4.4.5","fuse.js":"^3.3.0","wms-capabilities":"0.6.0"}}');
337615
337713
 
337616
337714
  /***/ },
337617
337715