@itwin/core-frontend 5.14.0-dev.12 → 5.14.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/GeoServices.d.ts +3 -0
  3. package/lib/cjs/GeoServices.d.ts.map +1 -1
  4. package/lib/cjs/GeoServices.js +8 -1
  5. package/lib/cjs/GeoServices.js.map +1 -1
  6. package/lib/cjs/extension/ExtensionAdmin.d.ts +0 -2
  7. package/lib/cjs/extension/ExtensionAdmin.d.ts.map +1 -1
  8. package/lib/cjs/extension/ExtensionAdmin.js +44 -22
  9. package/lib/cjs/extension/ExtensionAdmin.js.map +1 -1
  10. package/lib/cjs/extension/providers/RemoteExtensionProvider.d.ts +1 -1
  11. package/lib/cjs/extension/providers/RemoteExtensionProvider.d.ts.map +1 -1
  12. package/lib/cjs/extension/providers/RemoteExtensionProvider.js +2 -2
  13. package/lib/cjs/extension/providers/RemoteExtensionProvider.js.map +1 -1
  14. package/lib/cjs/internal/render/webgl/SceneCompositor.d.ts.map +1 -1
  15. package/lib/cjs/internal/render/webgl/SceneCompositor.js +16 -19
  16. package/lib/cjs/internal/render/webgl/SceneCompositor.js.map +1 -1
  17. package/lib/cjs/internal/render/webgl/Target.d.ts +2 -0
  18. package/lib/cjs/internal/render/webgl/Target.d.ts.map +1 -1
  19. package/lib/cjs/internal/render/webgl/Target.js +1 -0
  20. package/lib/cjs/internal/render/webgl/Target.js.map +1 -1
  21. package/lib/esm/GeoServices.d.ts +3 -0
  22. package/lib/esm/GeoServices.d.ts.map +1 -1
  23. package/lib/esm/GeoServices.js +8 -1
  24. package/lib/esm/GeoServices.js.map +1 -1
  25. package/lib/esm/extension/ExtensionAdmin.d.ts +0 -2
  26. package/lib/esm/extension/ExtensionAdmin.d.ts.map +1 -1
  27. package/lib/esm/extension/ExtensionAdmin.js +44 -22
  28. package/lib/esm/extension/ExtensionAdmin.js.map +1 -1
  29. package/lib/esm/extension/providers/RemoteExtensionProvider.d.ts +1 -1
  30. package/lib/esm/extension/providers/RemoteExtensionProvider.d.ts.map +1 -1
  31. package/lib/esm/extension/providers/RemoteExtensionProvider.js +2 -2
  32. package/lib/esm/extension/providers/RemoteExtensionProvider.js.map +1 -1
  33. package/lib/esm/internal/render/webgl/SceneCompositor.d.ts.map +1 -1
  34. package/lib/esm/internal/render/webgl/SceneCompositor.js +16 -19
  35. package/lib/esm/internal/render/webgl/SceneCompositor.js.map +1 -1
  36. package/lib/esm/internal/render/webgl/Target.d.ts +2 -0
  37. package/lib/esm/internal/render/webgl/Target.d.ts.map +1 -1
  38. package/lib/esm/internal/render/webgl/Target.js +1 -0
  39. package/lib/esm/internal/render/webgl/Target.js.map +1 -1
  40. package/package.json +20 -20
@@ -42,6 +42,7 @@ export class CoordinateConverter {
42
42
  _maxPointsPerRequest;
43
43
  _isIModelClosed;
44
44
  _requestPoints;
45
+ _direction;
45
46
  // If true, [[dispatch]] will schedule another dispatch after it receives a response.
46
47
  // This is needed when all the points requested after the most recent dispatch were included in the currently-in-flight request -
47
48
  // _pending will be empty but new callers will be awaiting the results of the in-flight request.
@@ -66,6 +67,7 @@ export class CoordinateConverter {
66
67
  this._maxPointsPerRequest = Math.max(1, opts.maxPointsPerRequest ?? 300);
67
68
  this._isIModelClosed = opts.isIModelClosed;
68
69
  this._requestPoints = opts.requestPoints;
70
+ this._direction = opts.direction;
69
71
  this._cache = new Dictionary(compareXYAndZ, cloneXYAndZ);
70
72
  this._pending = new SortedArray(compareXYAndZ, false, cloneXYAndZ);
71
73
  this._inflight = new SortedArray(compareXYAndZ, false, cloneXYAndZ);
@@ -100,7 +102,10 @@ export class CoordinateConverter {
100
102
  this._cache.set(requests[j], results[j]);
101
103
  }
102
104
  }).catch((err) => {
103
- Logger.logError(`${FrontendLoggerCategory.Package}.geoservices`, err);
105
+ Logger.logError(`${FrontendLoggerCategory.Package}.geoservices`, err, () => ({
106
+ direction: this._direction,
107
+ pointCount: requests.length,
108
+ }));
104
109
  });
105
110
  promises.push(promise);
106
111
  }
@@ -196,10 +201,12 @@ export class GeoConverter {
196
201
  constructor(opts) {
197
202
  const isIModelClosed = opts.isIModelClosed;
198
203
  this._geoToIModel = new CoordinateConverter({
204
+ direction: "geoToIModel",
199
205
  isIModelClosed,
200
206
  requestPoints: async (geoCoords) => opts.toIModelCoords({ source: opts.datum, geoCoords }),
201
207
  });
202
208
  this._iModelToGeo = new CoordinateConverter({
209
+ direction: "iModelToGeo",
203
210
  isIModelClosed,
204
211
  requestPoints: async (iModelCoords) => opts.fromIModelCoords({ target: opts.datum, iModelCoords }),
205
212
  });
@@ -1 +1 @@
1
- {"version":3,"file":"GeoServices.js","sourceRoot":"","sources":["../../src/GeoServices.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,qBAAqB;AACrB,OAAO,EACL,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GACjD,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACoD,cAAc,EACvE,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAazE,SAAS,aAAa,CAAC,GAAW,EAAE,GAAW;IAC7C,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;AAC1C,CAAC;AAUD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,mBAAmB;IACX,MAAM,CAAsC;IACrD,MAAM,GA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,KAAK,EAAE,SAAS,CAAC,CAAC;YAElC,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC5C,IAAI,SAAS,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;oBACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\n// cspell:ignore GCRS\r\nimport {\r\n assert, BeEvent, Dictionary, Logger, SortedArray,\r\n} from \"@itwin/core-bentley\";\r\nimport { WritableXYAndZ, XYAndZ, XYZProps } from \"@itwin/core-geometry\";\r\nimport {\r\n GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeoCoordStatus, GeographicCRSProps, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps,\r\n IModelReadRpcInterface, PointWithStatus,\r\n} from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\n\r\n/** Options used to create a [[CoordinateConverter]].\r\n * @internal exported strictly for tests.\r\n */\r\nexport interface CoordinateConverterOptions {\r\n isIModelClosed: () => boolean;\r\n /** Asynchronously convert each point. The resultant array should have the same number and order of points as the input. */\r\n requestPoints: (points: XYAndZ[]) => Promise<PointWithStatus[]>;\r\n /** Maximum number of points to include in each request. Default: 300. */\r\n maxPointsPerRequest?: number;\r\n}\r\n\r\nfunction compareXYAndZ(lhs: XYAndZ, rhs: XYAndZ): number {\r\n return lhs.x - rhs.x || lhs.y - rhs.y || lhs.z - rhs.z;\r\n}\r\n\r\nfunction cloneXYAndZ(xyz: XYAndZ): XYAndZ {\r\n return { x: xyz.x, y: xyz.y, z: xyz.z };\r\n}\r\n\r\ntype CoordinateConverterState =\r\n // No pending requests.\r\n \"idle\" |\r\n // We have scheduled a requestAnimationFrame to dispatch all pending requests.\r\n \"scheduled\" |\r\n // We have dispatched all requests that were pending at the most recent requestAnimationFrame callback.\r\n \"in-flight\";\r\n\r\n/** Performs conversion of coordinates from one coordinate system to another.\r\n * A [[GeoConverter]] has a pair of these for converting between iModel coordinates and geographic coordinates.\r\n * Uses a cache to avoid repeatedly requesting the same points, and a batching strategy to avoid making frequent small requests.\r\n * The cache stores every point that was ever converted by [[convert]]. It is currently permitted to grow to unbounded size.\r\n * The batching works as follows:\r\n * When a conversion is requested via [[convert]], if all the requested points are in the cache, they are returned immediately.\r\n * Otherwise, any points not in the cache and not in the current in-flight request (if any) are placed onto the queue of pending requests.\r\n * A pending request is scheduled if one hasn't already been scheduled, via requestAnimationFrame.\r\n * In the animation frame callback, the pending requests are split into batches of no more than options.maxPointsPerRequest and dispatched to the backend.\r\n * Once the response is received, the results are loaded into and returned from the cache.\r\n * If more calls to convert occurred while the request was in flight, another request is dispatched.\r\n * @internal exported strictly for tests.\r\n */\r\nexport class CoordinateConverter {\r\n protected readonly _cache: Dictionary<XYAndZ, PointWithStatus>;\r\n protected _state: CoordinateConverterState = \"idle\";\r\n // The accumulated set of points to be converted by the next request.\r\n protected _pending: SortedArray<XYAndZ>;\r\n // The set of points that were included in the current in-flight request, if any.\r\n protected _inflight: SortedArray<XYAndZ>;\r\n // An event fired when the next request completes.\r\n protected _onCompleted = new BeEvent<() => void>();\r\n // Used for creating cache keys (XYAndZ) from XYZProps without having to allocate temporary objects.\r\n protected readonly _scratchXYZ = { x: 0, y: 0, z: 0 };\r\n protected readonly _maxPointsPerRequest: number;\r\n protected readonly _isIModelClosed: () => boolean;\r\n protected readonly _requestPoints: (points: XYAndZ[]) => Promise<PointWithStatus[]>;\r\n // If true, [[dispatch]] will schedule another dispatch after it receives a response.\r\n // This is needed when all the points requested after the most recent dispatch were included in the currently-in-flight request -\r\n // _pending will be empty but new callers will be awaiting the results of the in-flight request.\r\n protected _redispatchOnCompletion = false;\r\n\r\n public get isIdle(): boolean {\r\n return \"idle\" === this._state;\r\n }\r\n\r\n protected toXYAndZ(input: XYZProps, output: WritableXYAndZ): XYAndZ {\r\n if (Array.isArray(input)) {\r\n output.x = input[0] ?? 0;\r\n output.y = input[1] ?? 0;\r\n output.z = input[2] ?? 0;\r\n } else {\r\n output.x = input.x ?? 0;\r\n output.y = input.y ?? 0;\r\n output.z = input.z ?? 0;\r\n }\r\n\r\n return output;\r\n }\r\n\r\n public constructor(opts: CoordinateConverterOptions) {\r\n this._maxPointsPerRequest = Math.max(1, opts.maxPointsPerRequest ?? 300);\r\n this._isIModelClosed = opts.isIModelClosed;\r\n this._requestPoints = opts.requestPoints;\r\n\r\n this._cache = new Dictionary<XYAndZ, PointWithStatus>(compareXYAndZ, cloneXYAndZ);\r\n this._pending = new SortedArray<XYAndZ>(compareXYAndZ, false, cloneXYAndZ);\r\n this._inflight = new SortedArray<XYAndZ>(compareXYAndZ, false, cloneXYAndZ);\r\n }\r\n\r\n protected async dispatch(): Promise<void> {\r\n assert(this._state === \"scheduled\");\r\n if (this._isIModelClosed() || this._pending.isEmpty) {\r\n this._state = \"idle\";\r\n this._onCompleted.raiseEvent();\r\n return;\r\n }\r\n\r\n this._state = \"in-flight\";\r\n\r\n // Ensure subsequently-enqueued requests listen for the *next* response to be received.\r\n const onCompleted = this._onCompleted;\r\n this._onCompleted = new BeEvent<() => void>();\r\n\r\n // Pending requests are now in flight. Start a new list of pending requests. It's cheaper to swap than to allocate new objects.\r\n const inflight = this._pending;\r\n this._pending = this._inflight;\r\n assert(this._pending.isEmpty);\r\n this._inflight = inflight;\r\n\r\n // Split requests if necessary to avoid requesting more than the maximum allowed number of points.\r\n const promises: Array<Promise<void>> = [];\r\n for (let i = 0; i < inflight.length; i += this._maxPointsPerRequest) {\r\n const requests = inflight.slice(i, i + this._maxPointsPerRequest).extractArray();\r\n const promise = this._requestPoints(requests).then((results) => {\r\n if (this._isIModelClosed())\r\n return;\r\n\r\n if (results.length !== requests.length)\r\n Logger.logError(`${FrontendLoggerCategory.Package}.geoservices`, `requested conversion of ${requests.length} points, but received ${results.length} points`);\r\n\r\n for (let j = 0; j < results.length; j++) {\r\n if (j < requests.length)\r\n this._cache.set(requests[j], results[j]);\r\n }\r\n }).catch((err) => {\r\n Logger.logError(`${FrontendLoggerCategory.Package}.geoservices`, err);\r\n });\r\n\r\n promises.push(promise);\r\n }\r\n\r\n await Promise.all(promises);\r\n\r\n assert(this._state === \"in-flight\");\r\n this._state = \"idle\";\r\n this._inflight.clear();\r\n\r\n // If any more pending conversions arrived while awaiting this request, schedule another request.\r\n if (!this._pending.isEmpty || this._redispatchOnCompletion) {\r\n this._redispatchOnCompletion = false;\r\n this.scheduleDispatch(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n // Resolve promises of all callers who were awaiting this request.\r\n onCompleted.raiseEvent();\r\n }\r\n\r\n // Add any points not present in cache to pending request list.\r\n // Return the number of points present in cache.\r\n protected enqueue(points: XYZProps[]): number {\r\n let numInCache = 0;\r\n for (const point of points) {\r\n const xyz = this.toXYAndZ(point, this._scratchXYZ);\r\n if (this._cache.get(xyz))\r\n ++numInCache;\r\n else if (this._inflight.contains(xyz))\r\n this._redispatchOnCompletion = true;\r\n else\r\n this._pending.insert(xyz);\r\n }\r\n\r\n return numInCache;\r\n }\r\n\r\n // Obtain converted points from the cache. The assumption is that every point in `inputs` is already present in the cache.\r\n // Any point not present will be returned unconverted with an error status.\r\n protected getFromCache(inputs: XYZProps[]): PointWithStatus[] {\r\n const outputs: PointWithStatus[] = [];\r\n for (const input of inputs) {\r\n const xyz = this.toXYAndZ(input, this._scratchXYZ);\r\n let output = this._cache.get(xyz);\r\n if (!output)\r\n output = { p: { ...xyz }, s: GeoCoordStatus.CSMapError };\r\n\r\n outputs.push(output);\r\n }\r\n\r\n return outputs;\r\n }\r\n\r\n protected async scheduleDispatch(): Promise<void> {\r\n if (\"idle\" === this._state) {\r\n this._state = \"scheduled\";\r\n requestAnimationFrame(() => {\r\n this.dispatch(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n });\r\n }\r\n\r\n return new Promise((resolve) => {\r\n this._onCompleted.addOnce(() => resolve());\r\n });\r\n }\r\n\r\n public async convert(inputs: XYZProps[]): Promise<{ points: PointWithStatus[], fromCache: number }> {\r\n const fromCache = this.enqueue(inputs);\r\n assert(fromCache >= 0);\r\n assert(fromCache <= inputs.length);\r\n\r\n if (fromCache === inputs.length)\r\n return { points: this.getFromCache(inputs), fromCache };\r\n\r\n await this.scheduleDispatch();\r\n\r\n return { points: this.getFromCache(inputs), fromCache };\r\n }\r\n\r\n public findCached(inputs: XYZProps[]): CachedIModelCoordinatesResponseProps {\r\n const result: Array<PointWithStatus | undefined> = [];\r\n let missing: XYZProps[] | undefined;\r\n for (const input of inputs) {\r\n const key = this.toXYAndZ(input, this._scratchXYZ);\r\n const output = this._cache.get(key);\r\n result.push(output);\r\n if (!output) {\r\n if (!missing)\r\n missing = [];\r\n\r\n missing.push(input);\r\n }\r\n }\r\n\r\n return { result, missing };\r\n }\r\n}\r\n\r\n/** Response to a request to obtain imodel coordinates from cache.\r\n * @internal\r\n */\r\nexport interface CachedIModelCoordinatesResponseProps {\r\n /** An array of the same length as the input array, with undefined entries at indices corresponding to points not found in cache. */\r\n result: Array<PointWithStatus | undefined>;\r\n /** An array of points in the input array which were not found in the cache, or undefined if all points were found in the cache. */\r\n missing?: XYZProps[];\r\n}\r\n\r\n/** Options used to create a [[GeoConverter]].\r\n * @internal exported strictly for tests.\r\n */\r\nexport interface GeoConverterOptions {\r\n readonly datum: string;\r\n isIModelClosed: () => boolean;\r\n toIModelCoords: (request: IModelCoordinatesRequestProps) => Promise<PointWithStatus[]>;\r\n fromIModelCoords: (request: GeoCoordinatesRequestProps) => Promise<PointWithStatus[]>;\r\n}\r\n\r\n/** An object capable of communicating with the backend to convert between coordinates in a geographic coordinate system and coordinates in an [[IModelConnection]]'s own coordinate system.\r\n * @see [[GeoServices.getConverter]] to obtain a converter.\r\n * @see [GeographicCRS]($common) for more information about geographic coordinate reference systems.\r\n * @public\r\n */\r\nexport class GeoConverter {\r\n private readonly _geoToIModel: CoordinateConverter;\r\n private readonly _iModelToGeo: CoordinateConverter;\r\n /** Used for removing this converter from GeoServices' cache after all requests are completed.\r\n * @internal\r\n */\r\n public readonly onAllRequestsCompleted = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n constructor(opts: GeoConverterOptions) {\r\n const isIModelClosed = opts.isIModelClosed;\r\n this._geoToIModel = new CoordinateConverter({\r\n isIModelClosed,\r\n requestPoints: async (geoCoords: XYAndZ[]) => opts.toIModelCoords({ source: opts.datum, geoCoords }),\r\n });\r\n\r\n this._iModelToGeo = new CoordinateConverter({\r\n isIModelClosed,\r\n requestPoints: async (iModelCoords: XYAndZ[]) => opts.fromIModelCoords({ target: opts.datum, iModelCoords }),\r\n });\r\n }\r\n\r\n /** Convert the specified geographic coordinates into iModel coordinates. */\r\n public async convertToIModelCoords(geoPoints: XYZProps[]): Promise<PointWithStatus[]> {\r\n const result = await this.getIModelCoordinatesFromGeoCoordinates(geoPoints);\r\n return result.iModelCoords;\r\n }\r\n\r\n /** Convert the specified iModel coordinates into geographic coordinates. */\r\n public async convertFromIModelCoords(iModelCoords: XYZProps[]): Promise<PointWithStatus[]> {\r\n const result = await this.getGeoCoordinatesFromIModelCoordinates(iModelCoords);\r\n return result.geoCoords;\r\n }\r\n\r\n /** @internal */\r\n public async getIModelCoordinatesFromGeoCoordinates(geoPoints: XYZProps[]): Promise<IModelCoordinatesResponseProps> {\r\n const result = await this._geoToIModel.convert(geoPoints);\r\n this.checkCompletion();\r\n return {\r\n iModelCoords: result.points,\r\n fromCache: result.fromCache,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public async getGeoCoordinatesFromIModelCoordinates(iModelPoints: XYZProps[]): Promise<GeoCoordinatesResponseProps> {\r\n const result = await this._iModelToGeo.convert(iModelPoints);\r\n this.checkCompletion();\r\n return {\r\n geoCoords: result.points,\r\n fromCache: result.fromCache,\r\n };\r\n }\r\n\r\n private checkCompletion(): void {\r\n if (this._geoToIModel.isIdle && this._iModelToGeo.isIdle)\r\n this.onAllRequestsCompleted.raiseEvent();\r\n }\r\n\r\n /** @internal */\r\n public getCachedIModelCoordinatesFromGeoCoordinates(geoPoints: XYZProps[]): CachedIModelCoordinatesResponseProps {\r\n return this._geoToIModel.findCached(geoPoints);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type GeoServicesOptions = Omit<GeoConverterOptions, \"datum\">;\r\n\r\n/** The Geographic Services available for an [[IModelConnection]].\r\n * @see [[IModelConnection.geoServices]] to obtain the GeoServices for a specific iModel.\r\n * @public\r\n */\r\nexport class GeoServices {\r\n private readonly _options: GeoServicesOptions;\r\n /** Each GeoConverter has its own independent request queue and cache of previously-converted points.\r\n * Some callers like RealityTileTree obtain a single GeoConverter and reuse it throughout their own lifetime. Therefore they benefit from both batching and caching, and\r\n * the cache gets deleted once the RealityTileTree becomes disused.\r\n *\r\n * Other callers like IModelConnection.spatialToCartographic obtain a new GeoConverter every time they need one, use it to convert a single point(!), and then discard the converter.\r\n * This entirely prevents batching - e.g., calling spatialToCartographic 20 times in one frame results in 20 http requests.\r\n * To address that, we cache each GeoConverter returned by getConverter until it has converted at least one point and has no further outstanding conversion requests.\r\n * In this way, the converter lives for as long as (and no longer than) any caller is awaiting conversion to/from its datum - it and its cache are deleted once it becomes disused.\r\n * This makes the coordinate caching generally less useful, but at least bounded - and maximizes batching of requests.\r\n */\r\n private readonly _cache = new Map<string, GeoConverter>();\r\n\r\n /** @internal */\r\n public constructor(options: GeoServicesOptions) {\r\n this._options = options;\r\n }\r\n\r\n /** @internal */\r\n public static createForIModel(iModel: IModelConnection): GeoServices {\r\n return new GeoServices({\r\n isIModelClosed: () => iModel.isClosed,\r\n toIModelCoords: async (request) => {\r\n const rpc = IModelReadRpcInterface.getClientForRouting(iModel.routingContext.token);\r\n const response = await rpc.getIModelCoordinatesFromGeoCoordinates(iModel.getRpcProps(), request);\r\n return response.iModelCoords;\r\n },\r\n fromIModelCoords: async (request) => {\r\n const rpc = IModelReadRpcInterface.getClientForRouting(iModel.routingContext.token);\r\n const response = await rpc.getGeoCoordinatesFromIModelCoordinates(iModel.getRpcProps(), request);\r\n return response.geoCoords;\r\n },\r\n });\r\n }\r\n\r\n /** Obtain a converter that can convert between a geographic coordinate system and the iModel's own coordinate system.\r\n * @param datumOrGCRS The name or JSON representation of the geographic coordinate system datum - for example, \"WGS84\".\r\n * @returns a converter, or `undefined` if the iModel is not open.\r\n * @note A [[BlankConnection]] has no connection to a backend, so it is never \"open\"; therefore it always returns `undefined`.\r\n */\r\n public getConverter(datumOrGCRS?: string | GeographicCRSProps): GeoConverter | undefined {\r\n if (this._options.isIModelClosed())\r\n return undefined;\r\n\r\n const datum = (typeof datumOrGCRS === \"object\" ? JSON.stringify(datumOrGCRS) : datumOrGCRS) ?? \"\";\r\n\r\n let converter = this._cache.get(datum);\r\n if (!converter) {\r\n converter = new GeoConverter({ ...this._options, datum });\r\n this._cache.set(datum, converter);\r\n\r\n converter.onAllRequestsCompleted.addOnce(() => {\r\n if (converter === this._cache.get(datum))\r\n this._cache.delete(datum);\r\n });\r\n }\r\n\r\n return converter;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"GeoServices.js","sourceRoot":"","sources":["../../src/GeoServices.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,qBAAqB;AACrB,OAAO,EACL,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GACjD,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACoD,cAAc,EACvE,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,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C,CAAC;gBACpF,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,sCAAsC,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;gBACjG,OAAO,QAAQ,CAAC,SAAS,CAAC;YAC5B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,WAAyC;QAC3D,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;YAChC,OAAO,SAAS,CAAC;QAEnB,MAAM,KAAK,GAAG,CAAC,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAElG,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS,GAAG,IAAI,YAAY,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAElC,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC5C,IAAI,SAAS,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;oBACtC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\n// cspell:ignore GCRS\r\nimport {\r\n assert, BeEvent, Dictionary, Logger, SortedArray,\r\n} from \"@itwin/core-bentley\";\r\nimport { WritableXYAndZ, XYAndZ, XYZProps } from \"@itwin/core-geometry\";\r\nimport {\r\n GeoCoordinatesRequestProps, GeoCoordinatesResponseProps, GeoCoordStatus, GeographicCRSProps, IModelCoordinatesRequestProps, IModelCoordinatesResponseProps,\r\n IModelReadRpcInterface, PointWithStatus,\r\n} from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { FrontendLoggerCategory } from \"./common/FrontendLoggerCategory\";\r\n\r\n/** Options used to create a [[CoordinateConverter]].\r\n * @internal exported strictly for tests.\r\n */\r\nexport interface CoordinateConverterOptions {\r\n /** Conversion direction included in error diagnostics. */\r\n direction: \"geoToIModel\" | \"iModelToGeo\";\r\n isIModelClosed: () => boolean;\r\n /** Asynchronously convert each point. The resultant array should have the same number and order of points as the input. */\r\n requestPoints: (points: XYAndZ[]) => Promise<PointWithStatus[]>;\r\n /** Maximum number of points to include in each request. Default: 300. */\r\n maxPointsPerRequest?: number;\r\n}\r\n\r\nfunction compareXYAndZ(lhs: XYAndZ, rhs: XYAndZ): number {\r\n return lhs.x - rhs.x || lhs.y - rhs.y || lhs.z - rhs.z;\r\n}\r\n\r\nfunction cloneXYAndZ(xyz: XYAndZ): XYAndZ {\r\n return { x: xyz.x, y: xyz.y, z: xyz.z };\r\n}\r\n\r\ntype CoordinateConverterState =\r\n // No pending requests.\r\n \"idle\" |\r\n // We have scheduled a requestAnimationFrame to dispatch all pending requests.\r\n \"scheduled\" |\r\n // We have dispatched all requests that were pending at the most recent requestAnimationFrame callback.\r\n \"in-flight\";\r\n\r\n/** Performs conversion of coordinates from one coordinate system to another.\r\n * A [[GeoConverter]] has a pair of these for converting between iModel coordinates and geographic coordinates.\r\n * Uses a cache to avoid repeatedly requesting the same points, and a batching strategy to avoid making frequent small requests.\r\n * The cache stores every point that was ever converted by [[convert]]. It is currently permitted to grow to unbounded size.\r\n * The batching works as follows:\r\n * When a conversion is requested via [[convert]], if all the requested points are in the cache, they are returned immediately.\r\n * Otherwise, any points not in the cache and not in the current in-flight request (if any) are placed onto the queue of pending requests.\r\n * A pending request is scheduled if one hasn't already been scheduled, via requestAnimationFrame.\r\n * In the animation frame callback, the pending requests are split into batches of no more than options.maxPointsPerRequest and dispatched to the backend.\r\n * Once the response is received, the results are loaded into and returned from the cache.\r\n * If more calls to convert occurred while the request was in flight, another request is dispatched.\r\n * @internal exported strictly for tests.\r\n */\r\nexport class CoordinateConverter {\r\n protected readonly _cache: Dictionary<XYAndZ, PointWithStatus>;\r\n protected _state: CoordinateConverterState = \"idle\";\r\n // The accumulated set of points to be converted by the next request.\r\n protected _pending: SortedArray<XYAndZ>;\r\n // The set of points that were included in the current in-flight request, if any.\r\n protected _inflight: SortedArray<XYAndZ>;\r\n // An event fired when the next request completes.\r\n protected _onCompleted = new BeEvent<() => void>();\r\n // Used for creating cache keys (XYAndZ) from XYZProps without having to allocate temporary objects.\r\n protected readonly _scratchXYZ = { x: 0, y: 0, z: 0 };\r\n protected readonly _maxPointsPerRequest: number;\r\n protected readonly _isIModelClosed: () => boolean;\r\n protected readonly _requestPoints: (points: XYAndZ[]) => Promise<PointWithStatus[]>;\r\n private readonly _direction: CoordinateConverterOptions[\"direction\"];\r\n // If true, [[dispatch]] will schedule another dispatch after it receives a response.\r\n // This is needed when all the points requested after the most recent dispatch were included in the currently-in-flight request -\r\n // _pending will be empty but new callers will be awaiting the results of the in-flight request.\r\n protected _redispatchOnCompletion = false;\r\n\r\n public get isIdle(): boolean {\r\n return \"idle\" === this._state;\r\n }\r\n\r\n protected toXYAndZ(input: XYZProps, output: WritableXYAndZ): XYAndZ {\r\n if (Array.isArray(input)) {\r\n output.x = input[0] ?? 0;\r\n output.y = input[1] ?? 0;\r\n output.z = input[2] ?? 0;\r\n } else {\r\n output.x = input.x ?? 0;\r\n output.y = input.y ?? 0;\r\n output.z = input.z ?? 0;\r\n }\r\n\r\n return output;\r\n }\r\n\r\n public constructor(opts: CoordinateConverterOptions) {\r\n this._maxPointsPerRequest = Math.max(1, opts.maxPointsPerRequest ?? 300);\r\n this._isIModelClosed = opts.isIModelClosed;\r\n this._requestPoints = opts.requestPoints;\r\n this._direction = opts.direction;\r\n\r\n this._cache = new Dictionary<XYAndZ, PointWithStatus>(compareXYAndZ, cloneXYAndZ);\r\n this._pending = new SortedArray<XYAndZ>(compareXYAndZ, false, cloneXYAndZ);\r\n this._inflight = new SortedArray<XYAndZ>(compareXYAndZ, false, cloneXYAndZ);\r\n }\r\n\r\n protected async dispatch(): Promise<void> {\r\n assert(this._state === \"scheduled\");\r\n if (this._isIModelClosed() || this._pending.isEmpty) {\r\n this._state = \"idle\";\r\n this._onCompleted.raiseEvent();\r\n return;\r\n }\r\n\r\n this._state = \"in-flight\";\r\n\r\n // Ensure subsequently-enqueued requests listen for the *next* response to be received.\r\n const onCompleted = this._onCompleted;\r\n this._onCompleted = new BeEvent<() => void>();\r\n\r\n // Pending requests are now in flight. Start a new list of pending requests. It's cheaper to swap than to allocate new objects.\r\n const inflight = this._pending;\r\n this._pending = this._inflight;\r\n assert(this._pending.isEmpty);\r\n this._inflight = inflight;\r\n\r\n // Split requests if necessary to avoid requesting more than the maximum allowed number of points.\r\n const promises: Array<Promise<void>> = [];\r\n for (let i = 0; i < inflight.length; i += this._maxPointsPerRequest) {\r\n const requests = inflight.slice(i, i + this._maxPointsPerRequest).extractArray();\r\n const promise = this._requestPoints(requests).then((results) => {\r\n if (this._isIModelClosed())\r\n return;\r\n\r\n if (results.length !== requests.length)\r\n Logger.logError(`${FrontendLoggerCategory.Package}.geoservices`, `requested conversion of ${requests.length} points, but received ${results.length} points`);\r\n\r\n for (let j = 0; j < results.length; j++) {\r\n if (j < requests.length)\r\n this._cache.set(requests[j], results[j]);\r\n }\r\n }).catch((err) => {\r\n Logger.logError(`${FrontendLoggerCategory.Package}.geoservices`, err, () => ({\r\n direction: this._direction,\r\n pointCount: requests.length,\r\n }));\r\n });\r\n\r\n promises.push(promise);\r\n }\r\n\r\n await Promise.all(promises);\r\n\r\n assert(this._state === \"in-flight\");\r\n this._state = \"idle\";\r\n this._inflight.clear();\r\n\r\n // If any more pending conversions arrived while awaiting this request, schedule another request.\r\n if (!this._pending.isEmpty || this._redispatchOnCompletion) {\r\n this._redispatchOnCompletion = false;\r\n this.scheduleDispatch(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n // Resolve promises of all callers who were awaiting this request.\r\n onCompleted.raiseEvent();\r\n }\r\n\r\n // Add any points not present in cache to pending request list.\r\n // Return the number of points present in cache.\r\n protected enqueue(points: XYZProps[]): number {\r\n let numInCache = 0;\r\n for (const point of points) {\r\n const xyz = this.toXYAndZ(point, this._scratchXYZ);\r\n if (this._cache.get(xyz))\r\n ++numInCache;\r\n else if (this._inflight.contains(xyz))\r\n this._redispatchOnCompletion = true;\r\n else\r\n this._pending.insert(xyz);\r\n }\r\n\r\n return numInCache;\r\n }\r\n\r\n // Obtain converted points from the cache. The assumption is that every point in `inputs` is already present in the cache.\r\n // Any point not present will be returned unconverted with an error status.\r\n protected getFromCache(inputs: XYZProps[]): PointWithStatus[] {\r\n const outputs: PointWithStatus[] = [];\r\n for (const input of inputs) {\r\n const xyz = this.toXYAndZ(input, this._scratchXYZ);\r\n let output = this._cache.get(xyz);\r\n if (!output)\r\n output = { p: { ...xyz }, s: GeoCoordStatus.CSMapError };\r\n\r\n outputs.push(output);\r\n }\r\n\r\n return outputs;\r\n }\r\n\r\n protected async scheduleDispatch(): Promise<void> {\r\n if (\"idle\" === this._state) {\r\n this._state = \"scheduled\";\r\n requestAnimationFrame(() => {\r\n this.dispatch(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n });\r\n }\r\n\r\n return new Promise((resolve) => {\r\n this._onCompleted.addOnce(() => resolve());\r\n });\r\n }\r\n\r\n public async convert(inputs: XYZProps[]): Promise<{ points: PointWithStatus[], fromCache: number }> {\r\n const fromCache = this.enqueue(inputs);\r\n assert(fromCache >= 0);\r\n assert(fromCache <= inputs.length);\r\n\r\n if (fromCache === inputs.length)\r\n return { points: this.getFromCache(inputs), fromCache };\r\n\r\n await this.scheduleDispatch();\r\n\r\n return { points: this.getFromCache(inputs), fromCache };\r\n }\r\n\r\n public findCached(inputs: XYZProps[]): CachedIModelCoordinatesResponseProps {\r\n const result: Array<PointWithStatus | undefined> = [];\r\n let missing: XYZProps[] | undefined;\r\n for (const input of inputs) {\r\n const key = this.toXYAndZ(input, this._scratchXYZ);\r\n const output = this._cache.get(key);\r\n result.push(output);\r\n if (!output) {\r\n if (!missing)\r\n missing = [];\r\n\r\n missing.push(input);\r\n }\r\n }\r\n\r\n return { result, missing };\r\n }\r\n}\r\n\r\n/** Response to a request to obtain imodel coordinates from cache.\r\n * @internal\r\n */\r\nexport interface CachedIModelCoordinatesResponseProps {\r\n /** An array of the same length as the input array, with undefined entries at indices corresponding to points not found in cache. */\r\n result: Array<PointWithStatus | undefined>;\r\n /** An array of points in the input array which were not found in the cache, or undefined if all points were found in the cache. */\r\n missing?: XYZProps[];\r\n}\r\n\r\n/** Options used to create a [[GeoConverter]].\r\n * @internal exported strictly for tests.\r\n */\r\nexport interface GeoConverterOptions {\r\n readonly datum: string;\r\n isIModelClosed: () => boolean;\r\n toIModelCoords: (request: IModelCoordinatesRequestProps) => Promise<PointWithStatus[]>;\r\n fromIModelCoords: (request: GeoCoordinatesRequestProps) => Promise<PointWithStatus[]>;\r\n}\r\n\r\n/** An object capable of communicating with the backend to convert between coordinates in a geographic coordinate system and coordinates in an [[IModelConnection]]'s own coordinate system.\r\n * @see [[GeoServices.getConverter]] to obtain a converter.\r\n * @see [GeographicCRS]($common) for more information about geographic coordinate reference systems.\r\n * @public\r\n */\r\nexport class GeoConverter {\r\n private readonly _geoToIModel: CoordinateConverter;\r\n private readonly _iModelToGeo: CoordinateConverter;\r\n /** Used for removing this converter from GeoServices' cache after all requests are completed.\r\n * @internal\r\n */\r\n public readonly onAllRequestsCompleted = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n constructor(opts: GeoConverterOptions) {\r\n const isIModelClosed = opts.isIModelClosed;\r\n this._geoToIModel = new CoordinateConverter({\r\n direction: \"geoToIModel\",\r\n isIModelClosed,\r\n requestPoints: async (geoCoords: XYAndZ[]) => opts.toIModelCoords({ source: opts.datum, geoCoords }),\r\n });\r\n\r\n this._iModelToGeo = new CoordinateConverter({\r\n direction: \"iModelToGeo\",\r\n isIModelClosed,\r\n requestPoints: async (iModelCoords: XYAndZ[]) => opts.fromIModelCoords({ target: opts.datum, iModelCoords }),\r\n });\r\n }\r\n\r\n /** Convert the specified geographic coordinates into iModel coordinates. */\r\n public async convertToIModelCoords(geoPoints: XYZProps[]): Promise<PointWithStatus[]> {\r\n const result = await this.getIModelCoordinatesFromGeoCoordinates(geoPoints);\r\n return result.iModelCoords;\r\n }\r\n\r\n /** Convert the specified iModel coordinates into geographic coordinates. */\r\n public async convertFromIModelCoords(iModelCoords: XYZProps[]): Promise<PointWithStatus[]> {\r\n const result = await this.getGeoCoordinatesFromIModelCoordinates(iModelCoords);\r\n return result.geoCoords;\r\n }\r\n\r\n /** @internal */\r\n public async getIModelCoordinatesFromGeoCoordinates(geoPoints: XYZProps[]): Promise<IModelCoordinatesResponseProps> {\r\n const result = await this._geoToIModel.convert(geoPoints);\r\n this.checkCompletion();\r\n return {\r\n iModelCoords: result.points,\r\n fromCache: result.fromCache,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public async getGeoCoordinatesFromIModelCoordinates(iModelPoints: XYZProps[]): Promise<GeoCoordinatesResponseProps> {\r\n const result = await this._iModelToGeo.convert(iModelPoints);\r\n this.checkCompletion();\r\n return {\r\n geoCoords: result.points,\r\n fromCache: result.fromCache,\r\n };\r\n }\r\n\r\n private checkCompletion(): void {\r\n if (this._geoToIModel.isIdle && this._iModelToGeo.isIdle)\r\n this.onAllRequestsCompleted.raiseEvent();\r\n }\r\n\r\n /** @internal */\r\n public getCachedIModelCoordinatesFromGeoCoordinates(geoPoints: XYZProps[]): CachedIModelCoordinatesResponseProps {\r\n return this._geoToIModel.findCached(geoPoints);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type GeoServicesOptions = Omit<GeoConverterOptions, \"datum\">;\r\n\r\n/** The Geographic Services available for an [[IModelConnection]].\r\n * @see [[IModelConnection.geoServices]] to obtain the GeoServices for a specific iModel.\r\n * @public\r\n */\r\nexport class GeoServices {\r\n private readonly _options: GeoServicesOptions;\r\n /** Each GeoConverter has its own independent request queue and cache of previously-converted points.\r\n * Some callers like RealityTileTree obtain a single GeoConverter and reuse it throughout their own lifetime. Therefore they benefit from both batching and caching, and\r\n * the cache gets deleted once the RealityTileTree becomes disused.\r\n *\r\n * Other callers like IModelConnection.spatialToCartographic obtain a new GeoConverter every time they need one, use it to convert a single point(!), and then discard the converter.\r\n * This entirely prevents batching - e.g., calling spatialToCartographic 20 times in one frame results in 20 http requests.\r\n * To address that, we cache each GeoConverter returned by getConverter until it has converted at least one point and has no further outstanding conversion requests.\r\n * In this way, the converter lives for as long as (and no longer than) any caller is awaiting conversion to/from its datum - it and its cache are deleted once it becomes disused.\r\n * This makes the coordinate caching generally less useful, but at least bounded - and maximizes batching of requests.\r\n */\r\n private readonly _cache = new Map<string, GeoConverter>();\r\n\r\n /** @internal */\r\n public constructor(options: GeoServicesOptions) {\r\n this._options = options;\r\n }\r\n\r\n /** @internal */\r\n public static createForIModel(iModel: IModelConnection): GeoServices {\r\n return new GeoServices({\r\n isIModelClosed: () => iModel.isClosed,\r\n toIModelCoords: async (request) => {\r\n const rpc = IModelReadRpcInterface.getClientForRouting(iModel.routingContext.token);\r\n const response = await rpc.getIModelCoordinatesFromGeoCoordinates(iModel.getRpcProps(), request);\r\n return response.iModelCoords;\r\n },\r\n fromIModelCoords: async (request) => {\r\n const rpc = IModelReadRpcInterface.getClientForRouting(iModel.routingContext.token);\r\n const response = await rpc.getGeoCoordinatesFromIModelCoordinates(iModel.getRpcProps(), request);\r\n return response.geoCoords;\r\n },\r\n });\r\n }\r\n\r\n /** Obtain a converter that can convert between a geographic coordinate system and the iModel's own coordinate system.\r\n * @param datumOrGCRS The name or JSON representation of the geographic coordinate system datum - for example, \"WGS84\".\r\n * @returns a converter, or `undefined` if the iModel is not open.\r\n * @note A [[BlankConnection]] has no connection to a backend, so it is never \"open\"; therefore it always returns `undefined`.\r\n */\r\n public getConverter(datumOrGCRS?: string | GeographicCRSProps): GeoConverter | undefined {\r\n if (this._options.isIModelClosed())\r\n return undefined;\r\n\r\n const datum = (typeof datumOrGCRS === \"object\" ? JSON.stringify(datumOrGCRS) : datumOrGCRS) ?? \"\";\r\n\r\n let converter = this._cache.get(datum);\r\n if (!converter) {\r\n converter = new GeoConverter({ ...this._options, datum });\r\n this._cache.set(datum, converter);\r\n\r\n converter.onAllRequestsCompleted.addOnce(() => {\r\n if (converter === this._cache.get(datum))\r\n this._cache.delete(datum);\r\n });\r\n }\r\n\r\n return converter;\r\n }\r\n}\r\n"]}
@@ -34,8 +34,6 @@ export declare class ExtensionAdmin {
34
34
  * @param hostUrl (string) Accepts both URLs and hostnames (e.g., http://localhost:3000, yourdomain.com, https://www.yourdomain.com, etc.).
35
35
  */
36
36
  registerHost(hostUrl: string): void;
37
- /** Returns the hostname of an input string. Throws an error if input is not a valid hostname (or URL). */
38
- private getHostName;
39
37
  /** Loops over all enabled Extensions and triggers each one if the provided event is defined. */
40
38
  private activateExtensionEvents;
41
39
  /** Executes the extension. Catches and logs any errors (so that an extension will not crash the main application). */
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionAdmin.d.ts","sourceRoot":"","sources":["../../../src/extension/ExtensionAdmin.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA4BxE;;;GAGG;AACH,qBAAa,cAAc;IACzB,2GAA2G;IAC3G,OAAO,CAAC,WAAW,CAA0E;IAC7F,OAAO,CAAC,MAAM,CAAW;IAEzB;;OAEG;IACI,SAAS,sBAEd;;IAMF;;;;;OAKG;IACU,YAAY,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBrE;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAM3E;;;;OAIG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM;IAOnC,0GAA0G;IAC1G,OAAO,CAAC,WAAW;IAgBnB,gGAAgG;YAClF,uBAAuB;IAarC,sHAAsH;YACxG,QAAQ;CAOvB"}
1
+ {"version":3,"file":"ExtensionAdmin.d.ts","sourceRoot":"","sources":["../../../src/extension/ExtensionAdmin.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA0DxE;;;GAGG;AACH,qBAAa,cAAc;IACzB,2GAA2G;IAC3G,OAAO,CAAC,WAAW,CAA0E;IAC7F,OAAO,CAAC,MAAM,CAAW;IAEzB;;OAEG;IACI,SAAS,sBAEd;;IAMF;;;;;OAKG;IACU,YAAY,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBrE;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAM3E;;;;OAIG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM;IAOnC,gGAAgG;YAClF,uBAAuB;IAarC,sHAAsH;YACxG,QAAQ;CAOvB"}
@@ -7,6 +7,45 @@
7
7
  */
8
8
  import { Logger } from "@itwin/core-bentley";
9
9
  import { FrontendLoggerCategory } from "../common/FrontendLoggerCategory";
10
+ /** The Extensions loading system has the following goals:
11
+ * 1. Only fetch what is needed when it is required
12
+ * 1. Load a manifest file
13
+ * 2. Load the the main module when necessary (usually at an activation event)
14
+ * 2. Download the extension's files
15
+ *
16
+ * 3 ways to load an Extension into the system:
17
+ *
18
+ * 1. Load both the Extension Manifest and import the main module of the extension from a local file/package.
19
+ * 2. A minimum set of properties to get the manifest and javascript from a remote server.
20
+ * 3. A minimum set of properties to get the manifest and javascript from Bentley's Extension Service.
21
+ *
22
+ * An Extension must be added to ExtensionAdmin before it can be executed during activation events.
23
+ */
24
+ /**
25
+ * Normalizes hostnames for comparison.
26
+ * @returns The normalized hostname of a URL or bare hostname.
27
+ * @throws Error if the input cannot be parsed, or does not contain a hostname.
28
+ */
29
+ function normalizeHostname(input) {
30
+ const invalid = () => new Error(`"${input}" is not a valid URL or hostname (i.e. http://localhost:3000, yourdomain.com, etc.).`);
31
+ // inputs without a scheme (e.g., https://) will throw an error in the URL constructor
32
+ const inputWithScheme = /^[a-z][a-z0-9+\-.]*:\/\//i.test(input) ? input : `https://${input}`;
33
+ let hostname;
34
+ try {
35
+ hostname = new URL(inputWithScheme).hostname.toLowerCase();
36
+ }
37
+ catch {
38
+ throw invalid();
39
+ }
40
+ // strip only a leading "www." label - removing "www" anywhere would make unrelated
41
+ // hosts like "wwwexample.com" compare equal to "example.com"
42
+ const normalized = hostname.startsWith("www.") ? hostname.substring("www.".length) : hostname;
43
+ // schemes with an optional or opaque host (e.g. file:///, data:) parse successfully but carry no
44
+ // hostname, and an input of just "www." normalizes to nothing. Neither can identify a host.
45
+ if (normalized.length === 0)
46
+ throw invalid();
47
+ return normalized;
48
+ }
10
49
  /** The Extension Admin controls the list of currently loaded Extensions.
11
50
  *
12
51
  * @alpha
@@ -31,10 +70,10 @@ export class ExtensionAdmin {
31
70
  * @alpha
32
71
  */
33
72
  async addExtension(provider) {
34
- if (provider.hostname) {
35
- const hostName = provider.hostname;
36
- if (this._hosts.length > 0 && this._hosts.indexOf(hostName) < 0) {
37
- throw new Error(`Error loading extension: ${hostName} was not registered.`);
73
+ if (provider.hostname !== undefined && this._hosts.length > 0) {
74
+ const hostname = normalizeHostname(provider.hostname);
75
+ if (this._hosts.indexOf(hostname) < 0) {
76
+ throw new Error(`Error loading extension: ${provider.hostname} was not registered.`);
38
77
  }
39
78
  }
40
79
  try {
@@ -65,28 +104,11 @@ export class ExtensionAdmin {
65
104
  * @param hostUrl (string) Accepts both URLs and hostnames (e.g., http://localhost:3000, yourdomain.com, https://www.yourdomain.com, etc.).
66
105
  */
67
106
  registerHost(hostUrl) {
68
- const hostname = this.getHostName(hostUrl);
107
+ const hostname = normalizeHostname(hostUrl);
69
108
  if (this._hosts.indexOf(hostname) < 0) {
70
109
  this._hosts.push(hostname);
71
110
  }
72
111
  }
73
- /** Returns the hostname of an input string. Throws an error if input is not a valid hostname (or URL). */
74
- getHostName(inputUrl) {
75
- // inputs without a protocol (e.g., http://) will throw an error in URL constructor
76
- const inputWithProtocol = /(http|https):\/\//.test(inputUrl) ?
77
- inputUrl :
78
- `https://${inputUrl}`;
79
- try {
80
- const hostname = new URL(inputWithProtocol).hostname.replace("www.", "");
81
- return hostname;
82
- }
83
- catch (e) {
84
- if (e instanceof TypeError) {
85
- throw new Error("Argument hostUrl should be a valid URL or hostname (i.e. http://localhost:3000, yourdomain.com, etc.).");
86
- }
87
- throw e;
88
- }
89
- }
90
112
  /** Loops over all enabled Extensions and triggers each one if the provided event is defined. */
91
113
  async activateExtensionEvents(event) {
92
114
  for (const extension of this._extensions.values()) {
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionAdmin.js","sourceRoot":"","sources":["../../../src/extension/ExtensionAdmin.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AA6B1E;;;GAGG;AACH,MAAM,OAAO,cAAc;IACzB,2GAA2G;IACnG,WAAW,GAAoC,IAAI,GAAG,EAA8B,CAAC;IACrF,MAAM,CAAW;IAEzB;;OAEG;IACI,SAAS,GAAG,KAAK,IAAI,EAAE;QAC5B,MAAM,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,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AC;QACH,CAAC;IACH,CAAC;IAED,sHAAsH;IAC9G,KAAK,CAAC,QAAQ,CAAC,SAA6B;QAClD,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC,UAAU,EAAE,6BAA6B,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3H,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Extensions\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\n\r\nimport { FrontendLoggerCategory } from \"../common/FrontendLoggerCategory\";\r\nimport type { ExtensionManifest, ExtensionProvider } from \"./Extension\";\r\n\r\n/** The Extensions loading system has the following goals:\r\n * 1. Only fetch what is needed when it is required\r\n * 1. Load a manifest file\r\n * 2. Load the the main module when necessary (usually at an activation event)\r\n * 2. Download the extension's files\r\n *\r\n * 3 ways to load an Extension into the system:\r\n *\r\n * 1. Load both the Extension Manifest and import the main module of the extension from a local file/package.\r\n * 2. A minimum set of properties to get the manifest and javascript from a remote server.\r\n * 3. A minimum set of properties to get the manifest and javascript from Bentley's Extension Service.\r\n *\r\n * An Extension must be added to ExtensionAdmin before it can be executed during activation events.\r\n */\r\n\r\n/**\r\n * A \"ready to use\" Extension (contains a manifest object and an extension provider to help execute).\r\n * Will be used as the type for in-memory extensions in the ExtensionAdmin\r\n */\r\ninterface InstalledExtension {\r\n /** An extension provider that has been added to ExtensionAdmin */\r\n provider: ExtensionProvider;\r\n /** The manifest (package.json) of the extension */\r\n manifest: ExtensionManifest;\r\n}\r\n\r\n/** The Extension Admin controls the list of currently loaded Extensions.\r\n *\r\n * @alpha\r\n */\r\nexport class ExtensionAdmin {\r\n /** Defines the set of extensions that are currently known and can be invoked during activation events. */\r\n private _extensions: Map<string, InstalledExtension> = new Map<string, InstalledExtension>();\r\n private _hosts: string[];\r\n\r\n /** Fired when an Extension has been added or removed.\r\n * @internal\r\n */\r\n public onStartup = async () => {\r\n await this.activateExtensionEvents(\"onStartup\");\r\n };\r\n\r\n public constructor() {\r\n this._hosts = [];\r\n }\r\n\r\n /**\r\n * Adds an extension.\r\n * The manifest will be fetched and the extension will be activated on an activation event.\r\n * @param provider\r\n * @alpha\r\n */\r\n public async addExtension(provider: ExtensionProvider): Promise<void> {\r\n if (provider.hostname) {\r\n const hostName = provider.hostname;\r\n if (this._hosts.length > 0 && this._hosts.indexOf(hostName) < 0) {\r\n throw new Error(`Error loading extension: ${hostName} was not registered.`);\r\n }\r\n }\r\n try {\r\n const manifest = await provider.getManifest();\r\n this._extensions.set(manifest.name, {\r\n manifest,\r\n provider,\r\n });\r\n // TODO - temporary fix to execute the missed startup event\r\n if (manifest.activationEvents.includes(\"onStartup\"))\r\n provider.execute(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n } catch (e) {\r\n throw new Error(`Failed to get extension manifest ${provider.hostname ? `at ${provider.hostname}` : \"\"}: ${String(e)}`);\r\n }\r\n }\r\n\r\n /**\r\n * Adds a list of extensions\r\n * @param providers\r\n * @alpha\r\n */\r\n public async addExtensions(providers: ExtensionProvider[]): Promise<void[]> {\r\n return Promise.all(\r\n providers.map(async (provider) => this.addExtension(provider)),\r\n );\r\n }\r\n\r\n /**\r\n * Registers a hostname for an extension.\r\n * Once a hostname has been registered, only remote extensions from registered hosts are permitted to be added.\r\n * @param hostUrl (string) Accepts both URLs and hostnames (e.g., http://localhost:3000, yourdomain.com, https://www.yourdomain.com, etc.).\r\n */\r\n public registerHost(hostUrl: string) {\r\n const hostname = this.getHostName(hostUrl);\r\n if (this._hosts.indexOf(hostname) < 0) {\r\n this._hosts.push(hostname);\r\n }\r\n }\r\n\r\n /** Returns the hostname of an input string. Throws an error if input is not a valid hostname (or URL). */\r\n private getHostName(inputUrl: string): string {\r\n // inputs without a protocol (e.g., http://) will throw an error in URL constructor\r\n const inputWithProtocol = /(http|https):\\/\\//.test(inputUrl) ?\r\n inputUrl :\r\n `https://${inputUrl}`;\r\n try {\r\n const hostname = new URL(inputWithProtocol).hostname.replace(\"www.\", \"\");\r\n return hostname;\r\n } catch (e) {\r\n if (e instanceof TypeError) {\r\n throw new Error(\"Argument hostUrl should be a valid URL or hostname (i.e. http://localhost:3000, yourdomain.com, etc.).\");\r\n }\r\n throw e;\r\n }\r\n }\r\n\r\n /** Loops over all enabled Extensions and triggers each one if the provided event is defined. */\r\n private async activateExtensionEvents(event: string) {\r\n for (const extension of this._extensions.values()) {\r\n if (!extension.manifest.activationEvents)\r\n continue;\r\n\r\n for (const activationEvent of extension.manifest.activationEvents) {\r\n if (activationEvent === event) {\r\n this._execute(extension); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Executes the extension. Catches and logs any errors (so that an extension will not crash the main application). */\r\n private async _execute(extension: InstalledExtension) {\r\n try {\r\n await extension.provider.execute();\r\n } catch (e) {\r\n Logger.logError(FrontendLoggerCategory.Extensions, `Error executing extension ${extension.manifest.name}: ${String(e)}`);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExtensionAdmin.js","sourceRoot":"","sources":["../../../src/extension/ExtensionAdmin.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG1E;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,KAAa;IACtC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAI,KAAK,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B,CAAC;IACH,CAAC;IAED,gGAAgG;IACxF,KAAK,CAAC,uBAAuB,CAAC,KAAa;QACjD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB;gBACtC,SAAS;YAEX,KAAK,MAAM,eAAe,IAAI,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;gBAClE,IAAI,eAAe,KAAK,KAAK,EAAE,CAAC;oBAC9B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,8DAA8D;gBAC1F,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,sHAAsH;IAC9G,KAAK,CAAC,QAAQ,CAAC,SAA6B;QAClD,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC,UAAU,EAAE,6BAA6B,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3H,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Extensions\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\n\r\nimport { FrontendLoggerCategory } from \"../common/FrontendLoggerCategory\";\r\nimport type { ExtensionManifest, ExtensionProvider } from \"./Extension\";\r\n\r\n/** The Extensions loading system has the following goals:\r\n * 1. Only fetch what is needed when it is required\r\n * 1. Load a manifest file\r\n * 2. Load the the main module when necessary (usually at an activation event)\r\n * 2. Download the extension's files\r\n *\r\n * 3 ways to load an Extension into the system:\r\n *\r\n * 1. Load both the Extension Manifest and import the main module of the extension from a local file/package.\r\n * 2. A minimum set of properties to get the manifest and javascript from a remote server.\r\n * 3. A minimum set of properties to get the manifest and javascript from Bentley's Extension Service.\r\n *\r\n * An Extension must be added to ExtensionAdmin before it can be executed during activation events.\r\n */\r\n\r\n/**\r\n * Normalizes hostnames for comparison.\r\n * @returns The normalized hostname of a URL or bare hostname.\r\n * @throws Error if the input cannot be parsed, or does not contain a hostname.\r\n */\r\nfunction normalizeHostname(input: string): string {\r\n const invalid = () => new Error(`\"${input}\" is not a valid URL or hostname (i.e. http://localhost:3000, yourdomain.com, etc.).`);\r\n\r\n // inputs without a scheme (e.g., https://) will throw an error in the URL constructor\r\n const inputWithScheme = /^[a-z][a-z0-9+\\-.]*:\\/\\//i.test(input) ? input : `https://${input}`;\r\n\r\n let hostname;\r\n try {\r\n hostname = new URL(inputWithScheme).hostname.toLowerCase();\r\n } catch {\r\n throw invalid();\r\n }\r\n\r\n // strip only a leading \"www.\" label - removing \"www\" anywhere would make unrelated\r\n // hosts like \"wwwexample.com\" compare equal to \"example.com\"\r\n const normalized = hostname.startsWith(\"www.\") ? hostname.substring(\"www.\".length) : hostname;\r\n\r\n // schemes with an optional or opaque host (e.g. file:///, data:) parse successfully but carry no\r\n // hostname, and an input of just \"www.\" normalizes to nothing. Neither can identify a host.\r\n if (normalized.length === 0)\r\n throw invalid();\r\n\r\n return normalized;\r\n}\r\n\r\n/**\r\n * A \"ready to use\" Extension (contains a manifest object and an extension provider to help execute).\r\n * Will be used as the type for in-memory extensions in the ExtensionAdmin\r\n */\r\ninterface InstalledExtension {\r\n /** An extension provider that has been added to ExtensionAdmin */\r\n provider: ExtensionProvider;\r\n /** The manifest (package.json) of the extension */\r\n manifest: ExtensionManifest;\r\n}\r\n\r\n/** The Extension Admin controls the list of currently loaded Extensions.\r\n *\r\n * @alpha\r\n */\r\nexport class ExtensionAdmin {\r\n /** Defines the set of extensions that are currently known and can be invoked during activation events. */\r\n private _extensions: Map<string, InstalledExtension> = new Map<string, InstalledExtension>();\r\n private _hosts: string[];\r\n\r\n /** Fired when an Extension has been added or removed.\r\n * @internal\r\n */\r\n public onStartup = async () => {\r\n await this.activateExtensionEvents(\"onStartup\");\r\n };\r\n\r\n public constructor() {\r\n this._hosts = [];\r\n }\r\n\r\n /**\r\n * Adds an extension.\r\n * The manifest will be fetched and the extension will be activated on an activation event.\r\n * @param provider\r\n * @alpha\r\n */\r\n public async addExtension(provider: ExtensionProvider): Promise<void> {\r\n if (provider.hostname !== undefined && this._hosts.length > 0) {\r\n const hostname = normalizeHostname(provider.hostname);\r\n if (this._hosts.indexOf(hostname) < 0) {\r\n throw new Error(`Error loading extension: ${provider.hostname} was not registered.`);\r\n }\r\n }\r\n try {\r\n const manifest = await provider.getManifest();\r\n this._extensions.set(manifest.name, {\r\n manifest,\r\n provider,\r\n });\r\n // TODO - temporary fix to execute the missed startup event\r\n if (manifest.activationEvents.includes(\"onStartup\"))\r\n provider.execute(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n } catch (e) {\r\n throw new Error(`Failed to get extension manifest ${provider.hostname ? `at ${provider.hostname}` : \"\"}: ${String(e)}`);\r\n }\r\n }\r\n\r\n /**\r\n * Adds a list of extensions\r\n * @param providers\r\n * @alpha\r\n */\r\n public async addExtensions(providers: ExtensionProvider[]): Promise<void[]> {\r\n return Promise.all(\r\n providers.map(async (provider) => this.addExtension(provider)),\r\n );\r\n }\r\n\r\n /**\r\n * Registers a hostname for an extension.\r\n * Once a hostname has been registered, only remote extensions from registered hosts are permitted to be added.\r\n * @param hostUrl (string) Accepts both URLs and hostnames (e.g., http://localhost:3000, yourdomain.com, https://www.yourdomain.com, etc.).\r\n */\r\n public registerHost(hostUrl: string) {\r\n const hostname = normalizeHostname(hostUrl);\r\n if (this._hosts.indexOf(hostname) < 0) {\r\n this._hosts.push(hostname);\r\n }\r\n }\r\n\r\n /** Loops over all enabled Extensions and triggers each one if the provided event is defined. */\r\n private async activateExtensionEvents(event: string) {\r\n for (const extension of this._extensions.values()) {\r\n if (!extension.manifest.activationEvents)\r\n continue;\r\n\r\n for (const activationEvent of extension.manifest.activationEvents) {\r\n if (activationEvent === event) {\r\n this._execute(extension); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Executes the extension. Catches and logs any errors (so that an extension will not crash the main application). */\r\n private async _execute(extension: InstalledExtension) {\r\n try {\r\n await extension.provider.execute();\r\n } catch (e) {\r\n Logger.logError(FrontendLoggerCategory.Extensions, `Error executing extension ${extension.manifest.name}: ${String(e)}`);\r\n }\r\n }\r\n}\r\n"]}
@@ -17,7 +17,7 @@ export interface RemoteExtensionProviderProps {
17
17
  */
18
18
  export declare class RemoteExtensionProvider implements ExtensionProvider {
19
19
  private readonly _props;
20
- /** The name of the server where the extension is hosted. */
20
+ /** The hostname of the server where the extension is hosted. */
21
21
  readonly hostname: string;
22
22
  constructor(_props: RemoteExtensionProviderProps);
23
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteExtensionProvider.d.ts","sourceRoot":"","sources":["../../../../src/extension/providers/RemoteExtensionProvider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAItB;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,iBAAiB;IAInD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,4DAA4D;IAC5D,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAEJ,MAAM,EAAE,4BAA4B;IAIjE;;;OAGG;IACU,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvC;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAIvD"}
1
+ {"version":3,"file":"RemoteExtensionProvider.d.ts","sourceRoot":"","sources":["../../../../src/extension/providers/RemoteExtensionProvider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAItB;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,iBAAiB;IAInD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,gEAAgE;IAChE,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAEJ,MAAM,EAAE,4BAA4B;IAIjE;;;OAGG;IACU,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvC;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAIvD"}
@@ -8,11 +8,11 @@ import { loadScript } from "./ExtensionLoadScript";
8
8
  */
9
9
  export class RemoteExtensionProvider {
10
10
  _props;
11
- /** The name of the server where the extension is hosted. */
11
+ /** The hostname of the server where the extension is hosted. */
12
12
  hostname;
13
13
  constructor(_props) {
14
14
  this._props = _props;
15
- this.hostname = new URL(this._props.jsUrl).hostname.replace("www", "");
15
+ this.hostname = new URL(this._props.jsUrl).hostname;
16
16
  }
17
17
  /**
18
18
  * Attempts to execute an extension.
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteExtensionProvider.js","sourceRoot":"","sources":["../../../../src/extension/providers/RemoteExtensionProvider.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAanD;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAIL;IAH7B,4DAA4D;IAC5C,QAAQ,CAAS;IAEjC,YAA6B,MAAoC;QAApC,WAAM,GAAN,MAAM,CAA8B;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW;QACtB,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport type {\r\n ExtensionManifest,\r\n ExtensionProvider,\r\n} from \"../Extension\";\r\nimport { request } from \"../../request/Request\";\r\nimport { loadScript } from \"./ExtensionLoadScript\";\r\n\r\n/**\r\n * Required props for a remote extension provider\r\n * @alpha\r\n */\r\nexport interface RemoteExtensionProviderProps {\r\n /** URL where the extension entry point can be loaded from */\r\n jsUrl: string;\r\n /** URL where the manifest (package.json) can be loaded from */\r\n manifestUrl: string;\r\n}\r\n\r\n/**\r\n * Implements a \"remote\" extension.\r\n * Remote extensions are hosted on an external server.\r\n * The execute() and getManifest() methods are used by the ExtensionAdmin to load and execute the extension.\r\n * @alpha\r\n */\r\nexport class RemoteExtensionProvider implements ExtensionProvider {\r\n /** The name of the server where the extension is hosted. */\r\n public readonly hostname: string;\r\n\r\n constructor(private readonly _props: RemoteExtensionProviderProps) {\r\n this.hostname = new URL(this._props.jsUrl).hostname.replace(\"www\", \"\");\r\n }\r\n\r\n /**\r\n * Attempts to execute an extension.\r\n * Throws an error if the provided jsUrl is not accessible.\r\n */\r\n public async execute(): Promise<string> {\r\n return loadScript(this._props.jsUrl);\r\n }\r\n\r\n /**\r\n * Attempts to fetch an extension's manifest (package.json) file.\r\n * Throws an error if the provided manifestUrl is not accessible.\r\n */\r\n public async getManifest(): Promise<ExtensionManifest> {\r\n return request(this._props.manifestUrl, \"json\");\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"RemoteExtensionProvider.js","sourceRoot":"","sources":["../../../../src/extension/providers/RemoteExtensionProvider.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAanD;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAIL;IAH7B,gEAAgE;IAChD,QAAQ,CAAS;IAEjC,YAA6B,MAAoC;QAApC,WAAM,GAAN,MAAM,CAA8B;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;IACtD,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW;QACtB,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport type {\r\n ExtensionManifest,\r\n ExtensionProvider,\r\n} from \"../Extension\";\r\nimport { request } from \"../../request/Request\";\r\nimport { loadScript } from \"./ExtensionLoadScript\";\r\n\r\n/**\r\n * Required props for a remote extension provider\r\n * @alpha\r\n */\r\nexport interface RemoteExtensionProviderProps {\r\n /** URL where the extension entry point can be loaded from */\r\n jsUrl: string;\r\n /** URL where the manifest (package.json) can be loaded from */\r\n manifestUrl: string;\r\n}\r\n\r\n/**\r\n * Implements a \"remote\" extension.\r\n * Remote extensions are hosted on an external server.\r\n * The execute() and getManifest() methods are used by the ExtensionAdmin to load and execute the extension.\r\n * @alpha\r\n */\r\nexport class RemoteExtensionProvider implements ExtensionProvider {\r\n /** The hostname of the server where the extension is hosted. */\r\n public readonly hostname: string;\r\n\r\n constructor(private readonly _props: RemoteExtensionProviderProps) {\r\n this.hostname = new URL(this._props.jsUrl).hostname;\r\n }\r\n\r\n /**\r\n * Attempts to execute an extension.\r\n * Throws an error if the provided jsUrl is not accessible.\r\n */\r\n public async execute(): Promise<string> {\r\n return loadScript(this._props.jsUrl);\r\n }\r\n\r\n /**\r\n * Attempts to fetch an extension's manifest (package.json) file.\r\n * Throws an error if the provided manifestUrl is not accessible.\r\n */\r\n public async getManifest(): Promise<ExtensionManifest> {\r\n return request(this._props.manifestUrl, \"json\");\r\n }\r\n\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SceneCompositor.d.ts","sourceRoot":"","sources":["../../../../../src/internal/render/webgl/SceneCompositor.ts"],"names":[],"mappings":"AAIA;;GAEG;AASH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAC2D,cAAc,EAE/E,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAe,WAAW,EAAE,MAAM,eAAe,CAAC;AAIzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAI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CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;aACtD,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;aAC3D,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,qBAAqB,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;aAC9F,iBAAiB,IAAI,IAAI;IAEzC,8GAA8G;IAC9G,aAAoB,oBAAoB,IAAI,WAAW,CAAC;IAExD,aAAoB,UAAU,IAAI,aAAa,CAAC;IAChD,aAAoB,aAAa,IAAI,aAAa,CAAC;IACnD,aAAoB,gBAAgB,IAAI,MAAM,CAAC;IAE/C,IAAW,eAAe,IAAI,OAAO,CAAkC;IAEvE,SAAS,aAAa,MAAM,EAAE,MAAM;WAOtB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;aAIrC,iBAAiB,CAAC,KAAK,EAAE,YAAY,CAAC,UAAU,GAAG,IAAI;CACxE"}
@@ -227,8 +227,8 @@ class FrameBuffers {
227
227
  idsAndZComposite;
228
228
  idsAndAltZComposite;
229
229
  edlDrawCol;
230
- init(textures, depth, depthMS) {
231
- if (!this.initPotentialMSFbos(textures, depth, depthMS))
230
+ init(textures, depth, depthMS, boundColor) {
231
+ if (!this.initPotentialMSFbos(textures, depth, depthMS, boundColor))
232
232
  return false;
233
233
  this.depthAndOrder = FrameBuffer.create([expectDefined(textures.depthAndOrder)], depth);
234
234
  this.hilite = FrameBuffer.create([expectDefined(textures.hilite)], depth);
@@ -236,7 +236,7 @@ class FrameBuffers {
236
236
  if (!this.depthAndOrder || !this.hilite || !this.hiliteUsingStencil)
237
237
  return false;
238
238
  assert(undefined === this.opaqueAll);
239
- if (!this.initPotentialMSMRTFbos(textures, depth, depthMS))
239
+ if (!this.initPotentialMSMRTFbos(textures, depth, depthMS, boundColor))
240
240
  return false;
241
241
  assert(undefined !== textures.accumulation && undefined !== textures.revealage);
242
242
  const colors = [textures.accumulation, textures.revealage];
@@ -253,9 +253,8 @@ class FrameBuffers {
253
253
  && undefined !== this.clearTranslucent
254
254
  && undefined !== this.pingPong;
255
255
  }
256
- initPotentialMSFbos(textures, depth, depthMS) {
257
- const boundColor = System.instance.frameBufferStack.currentColorBuffer;
258
- assert(undefined !== boundColor && undefined !== textures.color);
256
+ initPotentialMSFbos(textures, depth, depthMS, boundColor) {
257
+ assert(undefined !== textures.color);
259
258
  if (undefined === depthMS) {
260
259
  this.opaqueColor = FrameBuffer.create([boundColor], depth);
261
260
  this.opaqueAndCompositeColor = FrameBuffer.create([textures.color], depth);
@@ -268,10 +267,8 @@ class FrameBuffers {
268
267
  return undefined !== this.opaqueColor
269
268
  && undefined !== this.opaqueAndCompositeColor;
270
269
  }
271
- initPotentialMSMRTFbos(textures, depth, depthMs) {
272
- const boundColor = System.instance.frameBufferStack.currentColorBuffer;
273
- assert(undefined !== boundColor &&
274
- undefined !== textures.color &&
270
+ initPotentialMSMRTFbos(textures, depth, depthMs, boundColor) {
271
+ assert(undefined !== textures.color &&
275
272
  undefined !== textures.featureId &&
276
273
  undefined !== textures.depthAndOrder &&
277
274
  undefined !== textures.accumulation &&
@@ -385,23 +382,23 @@ class FrameBuffers {
385
382
  this.idsAndAltZComposite = dispose(this.idsAndAltZComposite);
386
383
  }
387
384
  }
388
- enableMultiSampling(textures, depth, depthMS) {
385
+ enableMultiSampling(textures, depth, depthMS, boundColor) {
389
386
  this.opaqueColor = dispose(this.opaqueColor);
390
387
  this.opaqueAndCompositeColor = dispose(this.opaqueAndCompositeColor);
391
- let rVal = this.initPotentialMSFbos(textures, depth, depthMS);
388
+ let rVal = this.initPotentialMSFbos(textures, depth, depthMS, boundColor);
392
389
  this.opaqueAll = dispose(this.opaqueAll);
393
390
  this.opaqueAndCompositeAll = dispose(this.opaqueAndCompositeAll);
394
- rVal = this.initPotentialMSMRTFbos(textures, depth, depthMS);
391
+ rVal = this.initPotentialMSMRTFbos(textures, depth, depthMS, boundColor);
395
392
  return rVal;
396
393
  }
397
- disableMultiSampling(textures, depth) {
394
+ disableMultiSampling(textures, depth, boundColor) {
398
395
  this.opaqueAll = dispose(this.opaqueAll);
399
396
  this.opaqueAndCompositeAll = dispose(this.opaqueAndCompositeAll);
400
- if (!this.initPotentialMSMRTFbos(textures, depth, undefined))
397
+ if (!this.initPotentialMSMRTFbos(textures, depth, undefined, boundColor))
401
398
  return false;
402
399
  this.opaqueColor = dispose(this.opaqueColor);
403
400
  this.opaqueAndCompositeColor = dispose(this.opaqueAndCompositeColor);
404
- return this.initPotentialMSFbos(textures, depth, undefined);
401
+ return this.initPotentialMSFbos(textures, depth, undefined, boundColor);
405
402
  }
406
403
  get isDisposed() {
407
404
  return undefined === this.opaqueColor && undefined === this.opaqueAndCompositeColor && undefined === this.depthAndOrder
@@ -1444,7 +1441,7 @@ class Compositor extends SceneCompositor {
1444
1441
  this._depthMS = undefined;
1445
1442
  if (this._depth !== undefined) {
1446
1443
  return this._textures.init(this._width, this._height, this._antialiasSamples)
1447
- && this._fbos.init(this._textures, this._depth, this._depthMS)
1444
+ && this._fbos.init(this._textures, this._depth, this._depthMS, expectDefined(this.target.outputColorTexture))
1448
1445
  && this._geom.init(this._textures)
1449
1446
  && this.eyeDomeLighting.init(this._width, this._height, this._depth);
1450
1447
  }
@@ -1459,11 +1456,11 @@ class Compositor extends SceneCompositor {
1459
1456
  if (!this._textures.enableMultiSampling(this._width, this._height, this._antialiasSamples))
1460
1457
  return false;
1461
1458
  assert(undefined !== this._depth && undefined !== this._depthMS);
1462
- return this._fbos.enableMultiSampling(this._textures, this._depth, this._depthMS);
1459
+ return this._fbos.enableMultiSampling(this._textures, this._depth, this._depthMS, expectDefined(this.target.outputColorTexture));
1463
1460
  }
1464
1461
  disableMultiSampling() {
1465
1462
  assert(undefined !== this._depth);
1466
- if (!this._fbos.disableMultiSampling(this._textures, this._depth))
1463
+ if (!this._fbos.disableMultiSampling(this._textures, this._depth, expectDefined(this.target.outputColorTexture)))
1467
1464
  return false;
1468
1465
  // Want to disable multisampling without deleting & reallocating other stuff.
1469
1466
  this._depthMS = dispose(this._depthMS);