@itwin/core-frontend 3.2.1 → 3.2.4

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 (102) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/lib/cjs/DisplayStyleState.d.ts +68 -17
  3. package/lib/cjs/DisplayStyleState.d.ts.map +1 -1
  4. package/lib/cjs/DisplayStyleState.js +66 -20
  5. package/lib/cjs/DisplayStyleState.js.map +1 -1
  6. package/lib/cjs/IModelApp.d.ts.map +1 -1
  7. package/lib/cjs/IModelApp.js +1 -1
  8. package/lib/cjs/IModelApp.js.map +1 -1
  9. package/lib/cjs/extension/ExtensionAdmin.d.ts +5 -2
  10. package/lib/cjs/extension/ExtensionAdmin.d.ts.map +1 -1
  11. package/lib/cjs/extension/ExtensionAdmin.js +24 -6
  12. package/lib/cjs/extension/ExtensionAdmin.js.map +1 -1
  13. package/lib/cjs/extension/providers/ExtensionServiceClient.d.ts +8 -6
  14. package/lib/cjs/extension/providers/ExtensionServiceClient.d.ts.map +1 -1
  15. package/lib/cjs/extension/providers/ExtensionServiceClient.js +13 -6
  16. package/lib/cjs/extension/providers/ExtensionServiceClient.js.map +1 -1
  17. package/lib/cjs/extension/providers/RemoteExtensionProvider.d.ts +0 -2
  18. package/lib/cjs/extension/providers/RemoteExtensionProvider.d.ts.map +1 -1
  19. package/lib/cjs/extension/providers/RemoteExtensionProvider.js +9 -22
  20. package/lib/cjs/extension/providers/RemoteExtensionProvider.js.map +1 -1
  21. package/lib/cjs/extension/providers/ServiceExtensionProvider.d.ts +4 -6
  22. package/lib/cjs/extension/providers/ServiceExtensionProvider.d.ts.map +1 -1
  23. package/lib/cjs/extension/providers/ServiceExtensionProvider.js +11 -22
  24. package/lib/cjs/extension/providers/ServiceExtensionProvider.js.map +1 -1
  25. package/lib/cjs/render/RenderSystem.d.ts +5 -0
  26. package/lib/cjs/render/RenderSystem.d.ts.map +1 -1
  27. package/lib/cjs/render/RenderSystem.js.map +1 -1
  28. package/lib/cjs/render/webgl/ShaderProgram.js +1 -1
  29. package/lib/cjs/render/webgl/ShaderProgram.js.map +1 -1
  30. package/lib/cjs/render/webgl/UniformHandle.d.ts +2 -1
  31. package/lib/cjs/render/webgl/UniformHandle.d.ts.map +1 -1
  32. package/lib/cjs/render/webgl/UniformHandle.js +15 -3
  33. package/lib/cjs/render/webgl/UniformHandle.js.map +1 -1
  34. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  35. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +46 -2
  36. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  37. package/lib/cjs/tile/map/MapCartoRectangle.d.ts +1 -0
  38. package/lib/cjs/tile/map/MapCartoRectangle.d.ts.map +1 -1
  39. package/lib/cjs/tile/map/MapCartoRectangle.js +1 -0
  40. package/lib/cjs/tile/map/MapCartoRectangle.js.map +1 -1
  41. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts +2 -1
  42. package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  43. package/lib/cjs/tile/map/MapLayerFormatRegistry.js.map +1 -1
  44. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +2 -0
  45. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  46. package/lib/cjs/tile/map/MapLayerImageryProvider.js +23 -9
  47. package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
  48. package/lib/cjs/tile/map/MapLayerSources.d.ts +14 -9
  49. package/lib/cjs/tile/map/MapLayerSources.d.ts.map +1 -1
  50. package/lib/cjs/tile/map/MapLayerSources.js +14 -6
  51. package/lib/cjs/tile/map/MapLayerSources.js.map +1 -1
  52. package/lib/esm/DisplayStyleState.d.ts +68 -17
  53. package/lib/esm/DisplayStyleState.d.ts.map +1 -1
  54. package/lib/esm/DisplayStyleState.js +66 -20
  55. package/lib/esm/DisplayStyleState.js.map +1 -1
  56. package/lib/esm/IModelApp.d.ts.map +1 -1
  57. package/lib/esm/IModelApp.js +2 -2
  58. package/lib/esm/IModelApp.js.map +1 -1
  59. package/lib/esm/extension/ExtensionAdmin.d.ts +5 -2
  60. package/lib/esm/extension/ExtensionAdmin.d.ts.map +1 -1
  61. package/lib/esm/extension/ExtensionAdmin.js +24 -6
  62. package/lib/esm/extension/ExtensionAdmin.js.map +1 -1
  63. package/lib/esm/extension/providers/ExtensionServiceClient.d.ts +8 -6
  64. package/lib/esm/extension/providers/ExtensionServiceClient.d.ts.map +1 -1
  65. package/lib/esm/extension/providers/ExtensionServiceClient.js +13 -6
  66. package/lib/esm/extension/providers/ExtensionServiceClient.js.map +1 -1
  67. package/lib/esm/extension/providers/RemoteExtensionProvider.d.ts +0 -2
  68. package/lib/esm/extension/providers/RemoteExtensionProvider.d.ts.map +1 -1
  69. package/lib/esm/extension/providers/RemoteExtensionProvider.js +9 -22
  70. package/lib/esm/extension/providers/RemoteExtensionProvider.js.map +1 -1
  71. package/lib/esm/extension/providers/ServiceExtensionProvider.d.ts +4 -6
  72. package/lib/esm/extension/providers/ServiceExtensionProvider.d.ts.map +1 -1
  73. package/lib/esm/extension/providers/ServiceExtensionProvider.js +11 -22
  74. package/lib/esm/extension/providers/ServiceExtensionProvider.js.map +1 -1
  75. package/lib/esm/render/RenderSystem.d.ts +5 -0
  76. package/lib/esm/render/RenderSystem.d.ts.map +1 -1
  77. package/lib/esm/render/RenderSystem.js.map +1 -1
  78. package/lib/esm/render/webgl/ShaderProgram.js +1 -1
  79. package/lib/esm/render/webgl/ShaderProgram.js.map +1 -1
  80. package/lib/esm/render/webgl/UniformHandle.d.ts +2 -1
  81. package/lib/esm/render/webgl/UniformHandle.d.ts.map +1 -1
  82. package/lib/esm/render/webgl/UniformHandle.js +15 -3
  83. package/lib/esm/render/webgl/UniformHandle.js.map +1 -1
  84. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  85. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +46 -2
  86. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  87. package/lib/esm/tile/map/MapCartoRectangle.d.ts +1 -0
  88. package/lib/esm/tile/map/MapCartoRectangle.d.ts.map +1 -1
  89. package/lib/esm/tile/map/MapCartoRectangle.js +1 -0
  90. package/lib/esm/tile/map/MapCartoRectangle.js.map +1 -1
  91. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts +2 -1
  92. package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
  93. package/lib/esm/tile/map/MapLayerFormatRegistry.js.map +1 -1
  94. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +2 -0
  95. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  96. package/lib/esm/tile/map/MapLayerImageryProvider.js +24 -10
  97. package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
  98. package/lib/esm/tile/map/MapLayerSources.d.ts +14 -9
  99. package/lib/esm/tile/map/MapLayerSources.d.ts.map +1 -1
  100. package/lib/esm/tile/map/MapLayerSources.js +14 -6
  101. package/lib/esm/tile/map/MapLayerSources.js.map +1 -1
  102. package/package.json +20 -20
@@ -1 +1 @@
1
- {"version":3,"file":"IModelApp.js","sourceRoot":"","sources":["../../src/IModelApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,cAAc;AACd,8DAA8D;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAiB,CAAC,CAAC,8CAA8C;AACnI,MAAM,gBAAgB,GAAG,6HAA6H,CAAC;AAEvJ,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAe,UAAU,EAAE,OAAO,EAA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C,CAAC;IACvF,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,qBAAqB;QAClC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;QAC5C,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC/D,OAAO,cAAc,CAAC;IACxB,CAAC;;;AApjBc,sBAAY,GAAG,KAAM,CAAA;AAgBrB,wBAAc,GAAG,KAAM,CAAA;AACvB,6BAAmB,GAAG,KAAM,CAAA;AAC5B,4BAAkB,GAA2B,UAAU,CAAC,WAAW,CAAC,CAAC,CAAE,CAAA;AAWtF,yEAAyE;AAClD,0BAAgB,GAAG,IAAI,OAAO,EAAe,CAAA;AAEpE;;GAEG;AACoB,wBAAc,GAAG,IAAI,OAAO,EAAe,CAAA;AAIlE,6CAA6C;AACtB,eAAK,GAAG,IAAI,YAAY,EAAG,CAAA;AA6DlD;;GAEG;AACoB,mBAAS,GAAqB,IAAI,gBAAgB,EAAG,CAAA;AAE5E,aAAa;AACU,wBAAc,GAAG,EAAI,CAAC,qBAAqB,EAAG,CAAA;AAErE,gDAAgD;AACjC,wBAAc,GAAG,IAAI,GAAG,EAA+B,CAAA","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 IModelApp\r\n */\r\n\r\n/** @public */\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nexport const ITWINJS_CORE_VERSION = require(\"../../package.json\").version as string; // require resolves from the lib/{cjs,esm} dir\r\nconst COPYRIGHT_NOTICE = 'Copyright © 2017-2022 <a href=\"https://www.bentley.com\" target=\"_blank\" rel=\"noopener noreferrer\">Bentley Systems, Inc.</a>';\r\n\r\nimport { TelemetryManager } from \"@itwin/core-telemetry\";\r\nimport { UiAdmin } from \"@itwin/appui-abstract\";\r\nimport { AccessToken, BeDuration, BeEvent, BentleyStatus, DbResult, dispose, Guid, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport {\r\n AuthorizationClient, IModelStatus, Localization, RealityDataAccess, RpcConfiguration, RpcInterfaceDefinition, RpcRequest, SerializedRpcActivity,\r\n} from \"@itwin/core-common\";\r\nimport { ITwinLocalization } from \"@itwin/core-i18n\";\r\nimport { queryRenderCompatibility, WebGLRenderCompatibilityInfo } from \"@itwin/webgl-compatibility\";\r\nimport { AccuDraw } from \"./AccuDraw\";\r\nimport { AccuSnap } from \"./AccuSnap\";\r\nimport * as auxCoordState from \"./AuxCoordSys\";\r\nimport * as categorySelectorState from \"./CategorySelectorState\";\r\nimport { ExtensionAdmin } from \"./extension/ExtensionAdmin\";\r\nimport * as displayStyleState from \"./DisplayStyleState\";\r\nimport * as drawingViewState from \"./DrawingViewState\";\r\nimport { ElementLocateManager } from \"./ElementLocateManager\";\r\nimport { EntityState } from \"./EntityState\";\r\nimport { FrontendHubAccess } from \"./FrontendHubAccess\";\r\nimport { FrontendLoggerCategory } from \"./FrontendLoggerCategory\";\r\nimport * as modelselector from \"./ModelSelectorState\";\r\nimport * as modelState from \"./ModelState\";\r\nimport { NotificationManager } from \"./NotificationManager\";\r\nimport { QuantityFormatter } from \"./quantity-formatting/QuantityFormatter\";\r\nimport { RenderSystem } from \"./render/RenderSystem\";\r\nimport { System } from \"./render/webgl/System\";\r\nimport * as sheetState from \"./SheetViewState\";\r\nimport * as spatialViewState from \"./SpatialViewState\";\r\nimport { TentativePoint } from \"./TentativePoint\";\r\nimport { MapLayerFormatRegistry, MapLayerOptions, TileAdmin } from \"./tile/internal\";\r\nimport * as accudrawTool from \"./tools/AccuDrawTool\";\r\nimport * as clipViewTool from \"./tools/ClipViewTool\";\r\nimport * as idleTool from \"./tools/IdleTool\";\r\nimport * as measureTool from \"./tools/MeasureTool\";\r\nimport * as selectTool from \"./tools/SelectTool\";\r\nimport { ToolRegistry } from \"./tools/Tool\";\r\nimport { ToolAdmin } from \"./tools/ToolAdmin\";\r\nimport * as viewTool from \"./tools/ViewTool\";\r\nimport { UserPreferencesAccess } from \"./UserPreferences\";\r\nimport { ViewManager } from \"./ViewManager\";\r\nimport * as viewState from \"./ViewState\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nrequire(\"./IModeljs-css\");\r\n\r\n// cSpell:ignore noopener noreferrer gprid forin nbsp csrf xsrf\r\n\r\n/** Options that can be supplied with [[IModelAppOptions]] to customize frontend security.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface FrontendSecurityOptions {\r\n /** Configures protection from Cross Site Request Forgery attacks. */\r\n readonly csrfProtection?: {\r\n /** If enabled, IModelApp will extract the CSRF token for the current session from the document's cookies and send it with each request as a header value. */\r\n readonly enabled: boolean;\r\n /** Defaults to XSRF-TOKEN. */\r\n readonly cookieName?: string;\r\n /** Defaults to X-XSRF-TOKEN. */\r\n readonly headerName?: string;\r\n };\r\n}\r\n\r\n/** Options that can be supplied to [[IModelApp.startup]] to customize frontend behavior.\r\n * @public\r\n */\r\nexport interface IModelAppOptions {\r\n /** If present, supplies the [[FrontendHubAccess]] for this session. */\r\n hubAccess?: FrontendHubAccess;\r\n /** If present, supplies the Id of this application. Applications must set this to the Bentley Global Product Registry Id (GPRID) for usage logging. */\r\n applicationId?: string;\r\n /** If present, supplies the version of this application. Must be set for usage logging. */\r\n applicationVersion?: string;\r\n /** If present, supplies the [[UserPreferencesAccess]] for this session.\r\n * @beta\r\n */\r\n userPreferences?: UserPreferencesAccess;\r\n /** If present, supplies the [[ViewManager]] for this session. */\r\n viewManager?: ViewManager;\r\n /** If present, supplies Map Layer Options for this session such as Azure Access Keys\r\n * @beta\r\n */\r\n mapLayerOptions?: MapLayerOptions;\r\n /** If present, supplies the properties with which to initialize the [[TileAdmin]] for this session. */\r\n tileAdmin?: TileAdmin.Props;\r\n /** If present, supplies the [[NotificationManager]] for this session. */\r\n notifications?: NotificationManager;\r\n /** If present, supplies the [[ToolAdmin]] for this session. */\r\n toolAdmin?: ToolAdmin;\r\n /** If present, supplies the [[AccuDraw]] for this session.\r\n * @internal\r\n */\r\n accuDraw?: AccuDraw;\r\n /** If present, supplies the [[AccuSnap]] for this session. */\r\n accuSnap?: AccuSnap;\r\n /** If present, supplies the [[Localization]] for this session. Defaults to [ITwinLocalization]($i18n). */\r\n localization?: Localization;\r\n /** If present, supplies the authorization information for various frontend APIs */\r\n authorizationClient?: AuthorizationClient;\r\n /** If present, supplies security options for the frontend. */\r\n security?: FrontendSecurityOptions;\r\n /** @internal */\r\n sessionId?: GuidString;\r\n /** @internal */\r\n locateManager?: ElementLocateManager;\r\n /** @internal */\r\n tentativePoint?: TentativePoint;\r\n /** @internal */\r\n quantityFormatter?: QuantityFormatter;\r\n /** If present, supplies an implementation of the render system, or options for initializing the default render system. */\r\n renderSys?: RenderSystem | RenderSystem.Options;\r\n /** If present, supplies the [[UiAdmin]] for this session. */\r\n uiAdmin?: UiAdmin;\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n /** @beta */\r\n realityDataAccess?: RealityDataAccess;\r\n /** If present, overrides where public assets are fetched. The default is to fetch assets relative to the current URL.\r\n * The path should always end with a trailing `/`.\r\n * @beta\r\n */\r\n publicPath?: string;\r\n}\r\n\r\n/** Options for [[IModelApp.makeModalDiv]]\r\n * @internal\r\n */\r\nexport interface ModalOptions {\r\n /** Width for the Modal dialog box. */\r\n width?: number;\r\n /** The dialog should be dismissed if the user clicks anywhere or hits Enter or Escape on the keyboard. */\r\n autoClose?: boolean;\r\n /** Show an 'x' in the upper right corner to close the dialog */\r\n closeBox?: boolean;\r\n /** The parent for the semi transparent *darkening* div. If not present, use `document.body` */\r\n rootDiv?: HTMLElement;\r\n}\r\n\r\n/** Return type for [[IModelApp.makeModalDiv]]\r\n * @internal\r\n */\r\nexport interface ModalReturn {\r\n /** The modal HTMLDivElement created. */\r\n modal: HTMLDivElement;\r\n /** A function that can be set as an event handler to stop the modal dialog. This can be used if `autoClose` or `closeBox` are not enabled. */\r\n stop: (_ev: Event) => void;\r\n}\r\n\r\n/** We hang the IModelApp object off the global `window` object in IModelApp.startup for debugging purposes.\r\n * It's removed in IModelApp.shutdown.\r\n */\r\ninterface IModelAppForDebugger {\r\n iModelAppForDebugger?: typeof IModelApp;\r\n}\r\n\r\n/**\r\n * Global singleton that connects the user interface with the iTwin.js services. There can be only one IModelApp active in a session. All\r\n * members of IModelApp are static, and it serves as a singleton object for gaining access to session information.\r\n *\r\n * Before any interactive operations may be performed by the `@itwin/core-frontend package`, [[IModelApp.startup]] must be called and awaited.\r\n * Applications may customize the frontend behavior of iTwin.js by supplying options to [[IModelApp.startup]].\r\n *\r\n * @public\r\n */\r\nexport class IModelApp {\r\n private static _initialized = false;\r\n private static _accuDraw: AccuDraw;\r\n private static _accuSnap: AccuSnap;\r\n private static _applicationId: string;\r\n private static _applicationVersion: string;\r\n private static _localization: Localization;\r\n private static _locateManager: ElementLocateManager;\r\n private static _notifications: NotificationManager;\r\n private static _quantityFormatter: QuantityFormatter;\r\n private static _renderSystem?: RenderSystem;\r\n private static _userPreferences?: UserPreferencesAccess;\r\n private static _tentativePoint: TentativePoint;\r\n private static _tileAdmin: TileAdmin;\r\n private static _toolAdmin: ToolAdmin;\r\n private static _viewManager: ViewManager;\r\n private static _uiAdmin: UiAdmin;\r\n private static _wantEventLoop = false;\r\n private static _animationRequested = false;\r\n private static _animationInterval: BeDuration | undefined = BeDuration.fromSeconds(1);\r\n private static _animationIntervalId?: number;\r\n private static _securityOptions: FrontendSecurityOptions;\r\n private static _mapLayerFormatRegistry: MapLayerFormatRegistry;\r\n private static _hubAccess?: FrontendHubAccess;\r\n private static _realityDataAccess?: RealityDataAccess;\r\n private static _publicPath: string;\r\n\r\n // No instances of IModelApp may be created. All members are static and must be on the singleton object IModelApp.\r\n protected constructor() { }\r\n\r\n /** Event raised just before the frontend IModelApp is to be shut down */\r\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\r\n\r\n /** Event raised after IModelApp is finished starting up.\r\n * @internal\r\n */\r\n public static readonly onAfterStartup = new BeEvent<() => void>();\r\n\r\n /** Provides authorization information for various frontend APIs */\r\n public static authorizationClient?: AuthorizationClient;\r\n /** The [[ToolRegistry]] for this session. */\r\n public static readonly tools = new ToolRegistry();\r\n /** A uniqueId for this session */\r\n public static sessionId: GuidString;\r\n /** The [[MapLayerProviderRegistry]] for this session.\r\n * @internal\r\n */\r\n public static get mapLayerFormatRegistry(): MapLayerFormatRegistry { return this._mapLayerFormatRegistry; }\r\n /** The [[RenderSystem]] for this session. */\r\n public static get renderSystem(): RenderSystem { return this._renderSystem!; }\r\n /** The [[ViewManager]] for this session. */\r\n public static get viewManager(): ViewManager { return this._viewManager; }\r\n\r\n /** The [[NotificationManager]] for this session. */\r\n public static get notifications(): NotificationManager { return this._notifications; }\r\n /** The [[TileAdmin]] for this session. */\r\n public static get tileAdmin(): TileAdmin { return this._tileAdmin; }\r\n /** The [[QuantityFormatter]] for this session. */\r\n public static get quantityFormatter(): QuantityFormatter { return this._quantityFormatter; }\r\n /** The [[ToolAdmin]] for this session. */\r\n public static get toolAdmin(): ToolAdmin { return this._toolAdmin; }\r\n /** The [[AccuDraw]] for this session.\r\n * @internal\r\n */\r\n public static get accuDraw(): AccuDraw { return this._accuDraw; }\r\n /** The [[AccuSnap]] for this session. */\r\n public static get accuSnap(): AccuSnap { return this._accuSnap; }\r\n public static get locateManager(): ElementLocateManager { return this._locateManager; }\r\n /** @internal */\r\n public static get tentativePoint(): TentativePoint { return this._tentativePoint; }\r\n /** The [[Localization]] for this session. */\r\n public static get localization(): Localization { return this._localization; }\r\n /** The [[UserPreferencesAccess]] for this session.\r\n * @beta\r\n */\r\n public static get userPreferences(): UserPreferencesAccess | undefined { return this._userPreferences; }\r\n /** The Id of this application. Applications must set this to the Global Product Registry ID (GPRID) for usage logging. */\r\n public static get applicationId(): string { return this._applicationId; }\r\n /** The version of this application. Must be set for usage logging. */\r\n public static get applicationVersion(): string { return this._applicationVersion; }\r\n /** @internal */\r\n public static get initialized() { return this._initialized; }\r\n\r\n /** Provides access to the IModelHub implementation for this IModelApp.\r\n * @internal\r\n */\r\n public static get hubAccess(): FrontendHubAccess | undefined { return this._hubAccess; }\r\n /** Provides access to the RealityData service implementation for this IModelApp\r\n * @beta\r\n */\r\n public static get realityDataAccess(): RealityDataAccess | undefined { return this._realityDataAccess; }\r\n\r\n /** @internal */\r\n public static get hasRenderSystem() { return this._renderSystem !== undefined && this._renderSystem.isValid; }\r\n /** The [[UiAdmin]] for this session. */\r\n public static get uiAdmin() { return this._uiAdmin; }\r\n /** The requested security options for the frontend. */\r\n public static get securityOptions() { return this._securityOptions; }\r\n /** The root URL for the assets 'public' folder.\r\n * @beta\r\n */\r\n public static get publicPath() { return this._publicPath; }\r\n /** The [[TelemetryManager]] for this session\r\n * @internal\r\n */\r\n public static readonly telemetry: TelemetryManager = new TelemetryManager();\r\n\r\n /** @alpha */\r\n public static readonly extensionAdmin = this._createExtensionAdmin();\r\n\r\n /** Map of classFullName to EntityState class */\r\n private static _entityClasses = new Map<string, typeof EntityState>();\r\n\r\n /** Register all of the subclasses of EntityState from a module.\r\n * @internal\r\n */\r\n public static registerModuleEntities(moduleObj: any) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisEntityState = moduleObj[thisMember];\r\n if (thisEntityState.prototype instanceof EntityState) {\r\n this.registerEntityState(thisEntityState.classFullName, thisEntityState);\r\n }\r\n }\r\n }\r\n\r\n /** Register an EntityState class by its classFullName\r\n * @internal\r\n */\r\n public static registerEntityState(classFullName: string, classType: typeof EntityState) {\r\n const lowerName = classFullName.toLowerCase();\r\n if (this._entityClasses.has(lowerName)) {\r\n const errMsg = `Class ${classFullName} is already registered. Make sure static schemaName and className members are correct on class ${classType.name}`;\r\n Logger.logError(FrontendLoggerCategory.IModelConnection, errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._entityClasses.set(lowerName, classType);\r\n }\r\n\r\n /** @internal */\r\n public static lookupEntityClass(classFullName: string) { return this._entityClasses.get(classFullName.toLowerCase()); }\r\n\r\n /**\r\n * Obtain WebGL rendering compatibility information for the client system. This information describes whether the client meets the\r\n * minimum rendering capabilities. It also describes whether the system lacks any optional capabilities that could improve quality\r\n * and/or performance.\r\n */\r\n public static queryRenderCompatibility(): WebGLRenderCompatibilityInfo {\r\n if (undefined === System.instance || undefined === System.instance.options.useWebGL2)\r\n return queryRenderCompatibility(true, System.createContext);\r\n else\r\n return queryRenderCompatibility(System.instance.options.useWebGL2, System.createContext);\r\n }\r\n\r\n /**\r\n * This method must be called before any other `@itwin/core-frontend` methods are used.\r\n * Somewhere in your startup code, call [[IModelApp.startup]]. E.g.:\r\n * ``` ts\r\n * await IModelApp.startup( {applicationId: myAppId} );\r\n * ```\r\n * @param opts The options for configuring IModelApp\r\n */\r\n public static async startup(opts?: IModelAppOptions): Promise<void> {\r\n if (this._initialized)\r\n return; // we're already initialized, do nothing.\r\n this._initialized = true;\r\n\r\n opts = opts ?? {};\r\n this._securityOptions = opts.security ?? {};\r\n\r\n if (process.env.NODE_ENV === \"development\") {\r\n // Make IModelApp globally accessible for debugging purposes. We'll remove it on shutdown.\r\n (window as IModelAppForDebugger).iModelAppForDebugger = this;\r\n }\r\n\r\n this.sessionId = opts.sessionId ?? Guid.createValue();\r\n this._applicationId = opts.applicationId ?? \"2686\"; // Default to product id of iTwin.js\r\n this._applicationVersion = opts.applicationVersion ?? \"1.0.0\";\r\n this.authorizationClient = opts.authorizationClient;\r\n this._hubAccess = opts.hubAccess;\r\n\r\n this._setupRpcRequestContext();\r\n\r\n this._localization = opts.localization ?? new ITwinLocalization();\r\n const toolsNs = \"CoreTools\";\r\n await this.localization.initialize([\"iModelJs\", toolsNs]);\r\n [\r\n selectTool,\r\n idleTool,\r\n viewTool,\r\n clipViewTool,\r\n measureTool,\r\n accudrawTool,\r\n ].forEach((tool) => this.tools.registerModule(tool, toolsNs));\r\n\r\n this.registerEntityState(EntityState.classFullName, EntityState);\r\n [\r\n modelState,\r\n sheetState,\r\n viewState,\r\n drawingViewState,\r\n spatialViewState,\r\n displayStyleState,\r\n modelselector,\r\n categorySelectorState,\r\n auxCoordState,\r\n ].forEach((module) => this.registerModuleEntities(module));\r\n\r\n this._renderSystem = (opts.renderSys instanceof RenderSystem) ? opts.renderSys : this.createRenderSys(opts.renderSys);\r\n if (opts.userPreferences)\r\n this._userPreferences = opts.userPreferences;\r\n this._viewManager = opts.viewManager ?? new ViewManager();\r\n this._tileAdmin = await TileAdmin.create(opts.tileAdmin);\r\n this._notifications = opts.notifications ?? new NotificationManager();\r\n this._toolAdmin = opts.toolAdmin ?? new ToolAdmin();\r\n this._accuDraw = opts.accuDraw ?? new AccuDraw();\r\n this._accuSnap = opts.accuSnap ?? new AccuSnap();\r\n this._locateManager = opts.locateManager ?? new ElementLocateManager();\r\n this._tentativePoint = opts.tentativePoint ?? new TentativePoint();\r\n this._quantityFormatter = opts.quantityFormatter ?? new QuantityFormatter();\r\n this._uiAdmin = opts.uiAdmin ?? new UiAdmin();\r\n this._mapLayerFormatRegistry = new MapLayerFormatRegistry(opts.mapLayerOptions);\r\n this._realityDataAccess = opts.realityDataAccess;\r\n this._publicPath = opts.publicPath ?? \"\";\r\n\r\n [\r\n this.renderSystem,\r\n this.viewManager,\r\n this.toolAdmin,\r\n this.accuDraw,\r\n this.accuSnap,\r\n this.locateManager,\r\n this.tentativePoint,\r\n this.uiAdmin,\r\n ].forEach((sys) => sys.onInitialized());\r\n\r\n await this.quantityFormatter.onInitialized();\r\n this.onAfterStartup.raiseEvent();\r\n }\r\n\r\n /** Must be called before the application exits to release any held resources. */\r\n public static async shutdown() {\r\n if (!this._initialized)\r\n return;\r\n\r\n // notify listeners that this IModelApp is about to be shut down.\r\n this.onBeforeShutdown.raiseEvent();\r\n this.onBeforeShutdown.clear();\r\n\r\n if (process.env.NODE_ENV === \"development\") {\r\n (window as IModelAppForDebugger).iModelAppForDebugger = undefined;\r\n }\r\n\r\n this._wantEventLoop = false;\r\n window.removeEventListener(\"resize\", IModelApp.requestNextAnimation);\r\n this.clearIntervalAnimation();\r\n [this.toolAdmin, this.viewManager, this.tileAdmin].forEach((sys) => sys.onShutDown());\r\n this.tools.shutdown();\r\n this._renderSystem = dispose(this._renderSystem);\r\n this._entityClasses.clear();\r\n this.authorizationClient = undefined;\r\n this._initialized = false;\r\n this.onAfterStartup.clear();\r\n }\r\n\r\n /** Controls how frequently the application polls for changes that may require a new animation frame to be requested.\r\n * Such changes include resizing a Viewport or changing the device pixel ratio by zooming in or out in the browser.\r\n * The default interval is 1 second. It may be desirable to override the default for specific apps and/or devices.\r\n * - Increasing the interval can conserve battery life on battery-powered devices at the expense of slower response to resize events.\r\n * - An application that only displays a single Viewport whose dimensions only change when the dimensions of the application window change, and which does not support changing application zoom level, could disable the interval altogether.\r\n * @param interval The interval at which to poll for changes. If undefined (or negative), the application will never poll. If zero, the application will poll as frequently as possible.\r\n * @beta\r\n */\r\n public static get animationInterval(): BeDuration | undefined { return IModelApp._animationInterval; }\r\n public static set animationInterval(interval: BeDuration | undefined) {\r\n if (undefined !== interval && interval.isTowardsPast)\r\n interval = undefined;\r\n\r\n if (interval !== IModelApp._animationInterval) {\r\n IModelApp._animationInterval = interval;\r\n if (IModelApp._wantEventLoop)\r\n IModelApp.requestIntervalAnimation();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static requestNextAnimation() {\r\n if (!IModelApp._animationRequested) {\r\n IModelApp._animationRequested = true;\r\n requestAnimationFrame(IModelApp.eventLoop);\r\n }\r\n }\r\n\r\n /** @internal */\r\n private static clearIntervalAnimation(): void {\r\n if (undefined !== IModelApp._animationIntervalId) {\r\n window.clearInterval(IModelApp._animationIntervalId);\r\n IModelApp._animationIntervalId = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n private static requestIntervalAnimation(): void {\r\n IModelApp.clearIntervalAnimation();\r\n\r\n if (undefined !== IModelApp.animationInterval)\r\n IModelApp._animationIntervalId = window.setInterval(() => {\r\n IModelApp.requestNextAnimation();\r\n }, IModelApp.animationInterval.milliseconds);\r\n }\r\n\r\n /** @internal */\r\n public static startEventLoop() {\r\n if (!IModelApp._wantEventLoop) {\r\n IModelApp._wantEventLoop = true;\r\n window.addEventListener(\"resize\", IModelApp.requestNextAnimation);\r\n IModelApp.requestIntervalAnimation();\r\n IModelApp.requestNextAnimation();\r\n }\r\n }\r\n\r\n /** Strictly for tests. @internal */\r\n public static stopEventLoop() {\r\n this._wantEventLoop = false;\r\n }\r\n\r\n /** The main event processing loop for Tools and rendering. */\r\n private static eventLoop() {\r\n IModelApp._animationRequested = false;\r\n if (!IModelApp._wantEventLoop) // flag turned on at startup\r\n return;\r\n\r\n try {\r\n IModelApp.toolAdmin.processEvent(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n IModelApp.viewManager.renderLoop();\r\n IModelApp.tileAdmin.process();\r\n } catch (exception) {\r\n ToolAdmin.exceptionHandler(exception); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n IModelApp._wantEventLoop = false;\r\n IModelApp._animationRequested = true; // unrecoverable after exception, don't request any further frames.\r\n window.removeEventListener(\"resize\", IModelApp.requestNextAnimation);\r\n }\r\n }\r\n\r\n /** Get the user's access token for this IModelApp, or a blank string if none is available.\r\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\r\n * returned by this method may change over time throughout the course of a session.\r\n */\r\n public static async getAccessToken(): Promise<AccessToken> {\r\n try {\r\n return (await this.authorizationClient?.getAccessToken()) ?? \"\";\r\n } catch (e) {\r\n return \"\";\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static createRenderSys(opts?: RenderSystem.Options): RenderSystem { return System.create(opts); }\r\n\r\n private static _setupRpcRequestContext() {\r\n RpcConfiguration.requestContext.getId = (_request: RpcRequest): string => {\r\n return Guid.createValue();\r\n };\r\n\r\n RpcConfiguration.requestContext.serialize = async (_request: RpcRequest): Promise<SerializedRpcActivity> => {\r\n const id = _request.id;\r\n const serialized: SerializedRpcActivity = {\r\n id,\r\n applicationId: this.applicationId,\r\n applicationVersion: this.applicationVersion,\r\n sessionId: this.sessionId,\r\n authorization: await this.getAccessToken(),\r\n };\r\n\r\n const csrf = IModelApp.securityOptions.csrfProtection;\r\n if (csrf && csrf.enabled) {\r\n const cookieName = csrf.cookieName || \"XSRF-TOKEN\";\r\n const cookieValue = document.cookie.split(\"; \").find((r) => r.startsWith(`${cookieName}=`));\r\n\r\n if (cookieValue) {\r\n const headerName = csrf.headerName || \"X-XSRF-TOKEN\";\r\n const headerValue = cookieValue.split(\"=\")[1];\r\n serialized.csrfToken = { headerName, headerValue };\r\n }\r\n }\r\n\r\n return serialized;\r\n };\r\n }\r\n\r\n /** Shortcut for creating an HTMLElement with optional parent, className, id, innerHTML, innerText\r\n * @internal\r\n */\r\n public static makeHTMLElement<K extends keyof HTMLElementTagNameMap>(type: K, opt?: {\r\n /** The parent for the new HTMLElement */\r\n parent?: HTMLElement;\r\n /** The className for the new HTMLElement */\r\n className?: string;\r\n /** The Id for the new HTMLElement */\r\n id?: string;\r\n /** innerHTML for the new HTMLElement */\r\n innerHTML?: string;\r\n /** innerText for the new HTMLElement */\r\n innerText?: string;\r\n }) {\r\n const el = document.createElement(type);\r\n if (undefined !== opt) {\r\n if (undefined !== opt.className)\r\n el.className = opt.className;\r\n if (undefined !== opt.id)\r\n el.id = opt.id;\r\n if (undefined !== opt.innerHTML)\r\n el.innerHTML = opt.innerHTML;\r\n if (undefined !== opt.innerText)\r\n el.innerText = opt.innerText;\r\n if (undefined !== opt.parent)\r\n opt.parent.appendChild(el);\r\n }\r\n return el;\r\n }\r\n\r\n /** Make a modal dialog on top of the root of the application. The returned HTMLDivElement will be placed topmost, all other application\r\n * windows will be covered with a semi-transparent background that intercepts all key/mouse/touch events until the modal is dismissed.\r\n * @param options The options that describe how the modal should work.\r\n * @internal\r\n */\r\n public static makeModalDiv(options: ModalOptions): ModalReturn {\r\n const root = options.rootDiv ? options.rootDiv : document.body;\r\n // create the overlay div to \"black out\" the application to indicate everything is inactive until the modal has been dismissed.\r\n const overlay = IModelApp.makeHTMLElement(\"div\", { parent: root, className: \"imodeljs-modal-overlay\" });\r\n overlay.tabIndex = -1; // so we can catch keystroke events\r\n\r\n // function to remove modal dialog\r\n const stop = (ev: Event) => { root.removeChild(overlay); ev.stopPropagation(); };\r\n\r\n if (options.autoClose) {\r\n overlay.onclick = overlay.oncontextmenu = stop;\r\n overlay.onkeydown = overlay.onkeyup = (ev: KeyboardEvent) => { // ignore all keystrokes other than enter and escape\r\n switch (ev.key) {\r\n case \"Enter\":\r\n case \"Escape\":\r\n stop(ev);\r\n return;\r\n }\r\n ev.stopPropagation();\r\n };\r\n overlay.focus();\r\n }\r\n\r\n const modal = IModelApp.makeHTMLElement(\"div\", { parent: overlay, className: \"imodeljs-modal\" });\r\n if (undefined !== options.width) {\r\n modal.style.width = `${options.width}px`;\r\n // allow the dialog to be smaller than the width\r\n modal.style.maxWidth = `min(100% - (2 * var(--width-border)), ${options.width}px)`;\r\n }\r\n if (options.closeBox) {\r\n const close = IModelApp.makeHTMLElement(\"p\", { parent: modal, className: \"imodeljs-modal-close\" });\r\n close.innerText = \"\\u00d7\"; // unicode \"times\" symbol\r\n close.onclick = stop;\r\n }\r\n\r\n return { modal, stop };\r\n }\r\n\r\n /** Applications may implement this method to supply a Logo Card.\r\n * @beta\r\n */\r\n public static applicationLogoCard?: () => HTMLTableRowElement;\r\n\r\n /** Make a new Logo Card. Call this method from your implementation of [[IModelApp.applicationLogoCard]]\r\n * @param opts Options for Logo Card\r\n * @beta\r\n */\r\n public static makeLogoCard(\r\n opts: {\r\n /** The heading to be put at the top of this logo card inside an <h2>. May include HTML. */\r\n heading: string | HTMLElement;\r\n /** The URL or HTMLImageElement for the icon on this logo card. */\r\n iconSrc?: string | HTMLImageElement;\r\n /** The width of the icon, if `iconSrc` is a string. Default is 64. */\r\n iconWidth?: number;\r\n /** A *notice* string to be shown on the logo card. May include HTML. */\r\n notice?: string | HTMLElement;\r\n }): HTMLTableRowElement {\r\n const card = IModelApp.makeHTMLElement(\"tr\");\r\n const iconCell = IModelApp.makeHTMLElement(\"td\", { parent: card, className: \"logo-card-logo\" });\r\n if (undefined !== opts.iconSrc) {\r\n if (typeof opts.iconSrc === \"string\") {\r\n const logo = IModelApp.makeHTMLElement(\"img\");\r\n logo.src = opts.iconSrc;\r\n logo.width = opts.iconWidth ? opts.iconWidth : 64;\r\n opts.iconSrc = logo;\r\n }\r\n iconCell.appendChild(opts.iconSrc);\r\n }\r\n const noticeCell = IModelApp.makeHTMLElement(\"td\", { parent: card, className: \"logo-card-message\" });\r\n if (undefined !== opts.heading) {\r\n if (typeof opts.heading === \"string\")\r\n IModelApp.makeHTMLElement(\"h2\", { parent: noticeCell, innerHTML: opts.heading, className: \"logo-card-header\" });\r\n else\r\n noticeCell.appendChild(opts.heading);\r\n }\r\n if (undefined !== opts.notice) {\r\n if (typeof opts.notice === \"string\")\r\n IModelApp.makeHTMLElement(\"p\", { parent: noticeCell, innerHTML: opts.notice, className: \"logo-cards\" });\r\n else\r\n noticeCell.appendChild(opts.notice);\r\n }\r\n return card;\r\n }\r\n\r\n /** Make the logo card for the library itself. This card gets placed at the top of the stack.\r\n * @internal\r\n */\r\n public static makeIModelJsLogoCard() {\r\n return this.makeLogoCard({\r\n iconSrc: `${this.publicPath}images/about-imodeljs.svg`,\r\n heading: `<span style=\"font-weight:normal\">${this.localization.getLocalizedString(\"iModelJs:Notices.PoweredBy\")}</span>&nbsp;iTwin.js`,\r\n notice: `${ITWINJS_CORE_VERSION}<br>${COPYRIGHT_NOTICE}`,\r\n });\r\n }\r\n\r\n /** Format the tooltip strings returned by [[IModelConnection.getToolTipMessage]].\r\n * @alpha\r\n */\r\n public static formatElementToolTip(msg: string[]): HTMLElement {\r\n let out = \"\";\r\n msg.forEach((line) => out += `${IModelApp.localization?.getLocalizedKeys(line)}<br>`);\r\n const div = document.createElement(\"div\");\r\n div.innerHTML = out;\r\n return div;\r\n }\r\n\r\n /** Localize an error status\r\n * @param status one of the status values from [BentleyStatus]($core-bentley), [IModelStatus]($core-bentley) or [DbResult]($core-bentley)\r\n * @returns a localized error message\r\n * @beta\r\n */\r\n public static translateStatus(status: number) {\r\n let key: { scope: string, val: string, status?: string };\r\n if (typeof status !== \"number\") {\r\n key = { scope: \"Errors\", val: \"IllegalValue\" };\r\n } else {\r\n key = { scope: \"BentleyStatus\", val: BentleyStatus[status] };\r\n if (!key.val)\r\n key = { scope: \"IModelStatus\", val: IModelStatus[status] };\r\n if (!key.val)\r\n key = { scope: \"DbResult\", val: DbResult[status] };\r\n if (!key.val)\r\n key = { scope: \"Errors\", val: \"Status\", status: status.toString() };\r\n }\r\n\r\n return this.localization.getLocalizedString(`iModelJs:${key.scope}.${key.val}`, key);\r\n }\r\n\r\n /**\r\n * Creates an instance of the ExtensionAdmin\r\n * and registers an event to execute after startup is complete\r\n * @returns an instance of ExtensionAdmin\r\n */\r\n private static _createExtensionAdmin(): ExtensionAdmin {\r\n const extensionAdmin = new ExtensionAdmin();\r\n IModelApp.onAfterStartup.addListener(extensionAdmin.onStartup);\r\n return extensionAdmin;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelApp.js","sourceRoot":"","sources":["../../src/IModelApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,cAAc;AACd,8DAA8D;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAiB,CAAC,CAAC,8CAA8C;AACnI,MAAM,gBAAgB,GAAG,6HAA6H,CAAC;AAEvJ,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAe,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAc,MAAM,EAAE,eAAe,EAAE,MAAM,qBAAqB,CA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C;IAED;;;;OAIG;IACK,MAAM,CAAC,qBAAqB;QAClC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;QAC5C,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC/D,OAAO,cAAc,CAAC;IACxB,CAAC;;;AApjBc,sBAAY,GAAG,KAAM,CAAA;AAgBrB,wBAAc,GAAG,KAAM,CAAA;AACvB,6BAAmB,GAAG,KAAM,CAAA;AAC5B,4BAAkB,GAA2B,UAAU,CAAC,WAAW,CAAC,CAAC,CAAE,CAAA;AAWtF,yEAAyE;AAClD,0BAAgB,GAAG,IAAI,OAAO,EAAe,CAAA;AAEpE;;GAEG;AACoB,wBAAc,GAAG,IAAI,OAAO,EAAe,CAAA;AAIlE,6CAA6C;AACtB,eAAK,GAAG,IAAI,YAAY,EAAG,CAAA;AA6DlD;;GAEG;AACoB,mBAAS,GAAqB,IAAI,gBAAgB,EAAG,CAAA;AAE5E,aAAa;AACU,wBAAc,GAAG,EAAI,CAAC,qBAAqB,EAAG,CAAA;AAErE,gDAAgD;AACjC,wBAAc,GAAG,IAAI,GAAG,EAA+B,CAAA","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 IModelApp\r\n */\r\n\r\n/** @public */\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nexport const ITWINJS_CORE_VERSION = require(\"../../package.json\").version as string; // require resolves from the lib/{cjs,esm} dir\r\nconst COPYRIGHT_NOTICE = 'Copyright © 2017-2022 <a href=\"https://www.bentley.com\" target=\"_blank\" rel=\"noopener noreferrer\">Bentley Systems, Inc.</a>';\r\n\r\nimport { TelemetryManager } from \"@itwin/core-telemetry\";\r\nimport { UiAdmin } from \"@itwin/appui-abstract\";\r\nimport { AccessToken, BeDuration, BeEvent, BentleyStatus, DbResult, dispose, Guid, GuidString, Logger, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport {\r\n AuthorizationClient, IModelStatus, Localization, RealityDataAccess, RpcConfiguration, RpcInterfaceDefinition, RpcRequest, SerializedRpcActivity,\r\n} from \"@itwin/core-common\";\r\nimport { ITwinLocalization } from \"@itwin/core-i18n\";\r\nimport { queryRenderCompatibility, WebGLRenderCompatibilityInfo } from \"@itwin/webgl-compatibility\";\r\nimport { AccuDraw } from \"./AccuDraw\";\r\nimport { AccuSnap } from \"./AccuSnap\";\r\nimport * as auxCoordState from \"./AuxCoordSys\";\r\nimport * as categorySelectorState from \"./CategorySelectorState\";\r\nimport { ExtensionAdmin } from \"./extension/ExtensionAdmin\";\r\nimport * as displayStyleState from \"./DisplayStyleState\";\r\nimport * as drawingViewState from \"./DrawingViewState\";\r\nimport { ElementLocateManager } from \"./ElementLocateManager\";\r\nimport { EntityState } from \"./EntityState\";\r\nimport { FrontendHubAccess } from \"./FrontendHubAccess\";\r\nimport { FrontendLoggerCategory } from \"./FrontendLoggerCategory\";\r\nimport * as modelselector from \"./ModelSelectorState\";\r\nimport * as modelState from \"./ModelState\";\r\nimport { NotificationManager } from \"./NotificationManager\";\r\nimport { QuantityFormatter } from \"./quantity-formatting/QuantityFormatter\";\r\nimport { RenderSystem } from \"./render/RenderSystem\";\r\nimport { System } from \"./render/webgl/System\";\r\nimport * as sheetState from \"./SheetViewState\";\r\nimport * as spatialViewState from \"./SpatialViewState\";\r\nimport { TentativePoint } from \"./TentativePoint\";\r\nimport { MapLayerFormatRegistry, MapLayerOptions, TileAdmin } from \"./tile/internal\";\r\nimport * as accudrawTool from \"./tools/AccuDrawTool\";\r\nimport * as clipViewTool from \"./tools/ClipViewTool\";\r\nimport * as idleTool from \"./tools/IdleTool\";\r\nimport * as measureTool from \"./tools/MeasureTool\";\r\nimport * as selectTool from \"./tools/SelectTool\";\r\nimport { ToolRegistry } from \"./tools/Tool\";\r\nimport { ToolAdmin } from \"./tools/ToolAdmin\";\r\nimport * as viewTool from \"./tools/ViewTool\";\r\nimport { UserPreferencesAccess } from \"./UserPreferences\";\r\nimport { ViewManager } from \"./ViewManager\";\r\nimport * as viewState from \"./ViewState\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-var-requires\r\nrequire(\"./IModeljs-css\");\r\n\r\n// cSpell:ignore noopener noreferrer gprid forin nbsp csrf xsrf\r\n\r\n/** Options that can be supplied with [[IModelAppOptions]] to customize frontend security.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface FrontendSecurityOptions {\r\n /** Configures protection from Cross Site Request Forgery attacks. */\r\n readonly csrfProtection?: {\r\n /** If enabled, IModelApp will extract the CSRF token for the current session from the document's cookies and send it with each request as a header value. */\r\n readonly enabled: boolean;\r\n /** Defaults to XSRF-TOKEN. */\r\n readonly cookieName?: string;\r\n /** Defaults to X-XSRF-TOKEN. */\r\n readonly headerName?: string;\r\n };\r\n}\r\n\r\n/** Options that can be supplied to [[IModelApp.startup]] to customize frontend behavior.\r\n * @public\r\n */\r\nexport interface IModelAppOptions {\r\n /** If present, supplies the [[FrontendHubAccess]] for this session. */\r\n hubAccess?: FrontendHubAccess;\r\n /** If present, supplies the Id of this application. Applications must set this to the Bentley Global Product Registry Id (GPRID) for usage logging. */\r\n applicationId?: string;\r\n /** If present, supplies the version of this application. Must be set for usage logging. */\r\n applicationVersion?: string;\r\n /** If present, supplies the [[UserPreferencesAccess]] for this session.\r\n * @beta\r\n */\r\n userPreferences?: UserPreferencesAccess;\r\n /** If present, supplies the [[ViewManager]] for this session. */\r\n viewManager?: ViewManager;\r\n /** If present, supplies Map Layer Options for this session such as Azure Access Keys\r\n * @beta\r\n */\r\n mapLayerOptions?: MapLayerOptions;\r\n /** If present, supplies the properties with which to initialize the [[TileAdmin]] for this session. */\r\n tileAdmin?: TileAdmin.Props;\r\n /** If present, supplies the [[NotificationManager]] for this session. */\r\n notifications?: NotificationManager;\r\n /** If present, supplies the [[ToolAdmin]] for this session. */\r\n toolAdmin?: ToolAdmin;\r\n /** If present, supplies the [[AccuDraw]] for this session.\r\n * @internal\r\n */\r\n accuDraw?: AccuDraw;\r\n /** If present, supplies the [[AccuSnap]] for this session. */\r\n accuSnap?: AccuSnap;\r\n /** If present, supplies the [[Localization]] for this session. Defaults to [ITwinLocalization]($i18n). */\r\n localization?: Localization;\r\n /** If present, supplies the authorization information for various frontend APIs */\r\n authorizationClient?: AuthorizationClient;\r\n /** If present, supplies security options for the frontend. */\r\n security?: FrontendSecurityOptions;\r\n /** @internal */\r\n sessionId?: GuidString;\r\n /** @internal */\r\n locateManager?: ElementLocateManager;\r\n /** @internal */\r\n tentativePoint?: TentativePoint;\r\n /** @internal */\r\n quantityFormatter?: QuantityFormatter;\r\n /** If present, supplies an implementation of the render system, or options for initializing the default render system. */\r\n renderSys?: RenderSystem | RenderSystem.Options;\r\n /** If present, supplies the [[UiAdmin]] for this session. */\r\n uiAdmin?: UiAdmin;\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n /** @beta */\r\n realityDataAccess?: RealityDataAccess;\r\n /** If present, overrides where public assets are fetched. The default is to fetch assets relative to the current URL.\r\n * The path should always end with a trailing `/`.\r\n * @beta\r\n */\r\n publicPath?: string;\r\n}\r\n\r\n/** Options for [[IModelApp.makeModalDiv]]\r\n * @internal\r\n */\r\nexport interface ModalOptions {\r\n /** Width for the Modal dialog box. */\r\n width?: number;\r\n /** The dialog should be dismissed if the user clicks anywhere or hits Enter or Escape on the keyboard. */\r\n autoClose?: boolean;\r\n /** Show an 'x' in the upper right corner to close the dialog */\r\n closeBox?: boolean;\r\n /** The parent for the semi transparent *darkening* div. If not present, use `document.body` */\r\n rootDiv?: HTMLElement;\r\n}\r\n\r\n/** Return type for [[IModelApp.makeModalDiv]]\r\n * @internal\r\n */\r\nexport interface ModalReturn {\r\n /** The modal HTMLDivElement created. */\r\n modal: HTMLDivElement;\r\n /** A function that can be set as an event handler to stop the modal dialog. This can be used if `autoClose` or `closeBox` are not enabled. */\r\n stop: (_ev: Event) => void;\r\n}\r\n\r\n/** We hang the IModelApp object off the global `window` object in IModelApp.startup for debugging purposes.\r\n * It's removed in IModelApp.shutdown.\r\n */\r\ninterface IModelAppForDebugger {\r\n iModelAppForDebugger?: typeof IModelApp;\r\n}\r\n\r\n/**\r\n * Global singleton that connects the user interface with the iTwin.js services. There can be only one IModelApp active in a session. All\r\n * members of IModelApp are static, and it serves as a singleton object for gaining access to session information.\r\n *\r\n * Before any interactive operations may be performed by the `@itwin/core-frontend package`, [[IModelApp.startup]] must be called and awaited.\r\n * Applications may customize the frontend behavior of iTwin.js by supplying options to [[IModelApp.startup]].\r\n *\r\n * @public\r\n */\r\nexport class IModelApp {\r\n private static _initialized = false;\r\n private static _accuDraw: AccuDraw;\r\n private static _accuSnap: AccuSnap;\r\n private static _applicationId: string;\r\n private static _applicationVersion: string;\r\n private static _localization: Localization;\r\n private static _locateManager: ElementLocateManager;\r\n private static _notifications: NotificationManager;\r\n private static _quantityFormatter: QuantityFormatter;\r\n private static _renderSystem?: RenderSystem;\r\n private static _userPreferences?: UserPreferencesAccess;\r\n private static _tentativePoint: TentativePoint;\r\n private static _tileAdmin: TileAdmin;\r\n private static _toolAdmin: ToolAdmin;\r\n private static _viewManager: ViewManager;\r\n private static _uiAdmin: UiAdmin;\r\n private static _wantEventLoop = false;\r\n private static _animationRequested = false;\r\n private static _animationInterval: BeDuration | undefined = BeDuration.fromSeconds(1);\r\n private static _animationIntervalId?: number;\r\n private static _securityOptions: FrontendSecurityOptions;\r\n private static _mapLayerFormatRegistry: MapLayerFormatRegistry;\r\n private static _hubAccess?: FrontendHubAccess;\r\n private static _realityDataAccess?: RealityDataAccess;\r\n private static _publicPath: string;\r\n\r\n // No instances of IModelApp may be created. All members are static and must be on the singleton object IModelApp.\r\n protected constructor() { }\r\n\r\n /** Event raised just before the frontend IModelApp is to be shut down */\r\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\r\n\r\n /** Event raised after IModelApp is finished starting up.\r\n * @internal\r\n */\r\n public static readonly onAfterStartup = new BeEvent<() => void>();\r\n\r\n /** Provides authorization information for various frontend APIs */\r\n public static authorizationClient?: AuthorizationClient;\r\n /** The [[ToolRegistry]] for this session. */\r\n public static readonly tools = new ToolRegistry();\r\n /** A uniqueId for this session */\r\n public static sessionId: GuidString;\r\n /** The [[MapLayerProviderRegistry]] for this session.\r\n * @internal\r\n */\r\n public static get mapLayerFormatRegistry(): MapLayerFormatRegistry { return this._mapLayerFormatRegistry; }\r\n /** The [[RenderSystem]] for this session. */\r\n public static get renderSystem(): RenderSystem { return this._renderSystem!; }\r\n /** The [[ViewManager]] for this session. */\r\n public static get viewManager(): ViewManager { return this._viewManager; }\r\n\r\n /** The [[NotificationManager]] for this session. */\r\n public static get notifications(): NotificationManager { return this._notifications; }\r\n /** The [[TileAdmin]] for this session. */\r\n public static get tileAdmin(): TileAdmin { return this._tileAdmin; }\r\n /** The [[QuantityFormatter]] for this session. */\r\n public static get quantityFormatter(): QuantityFormatter { return this._quantityFormatter; }\r\n /** The [[ToolAdmin]] for this session. */\r\n public static get toolAdmin(): ToolAdmin { return this._toolAdmin; }\r\n /** The [[AccuDraw]] for this session.\r\n * @internal\r\n */\r\n public static get accuDraw(): AccuDraw { return this._accuDraw; }\r\n /** The [[AccuSnap]] for this session. */\r\n public static get accuSnap(): AccuSnap { return this._accuSnap; }\r\n public static get locateManager(): ElementLocateManager { return this._locateManager; }\r\n /** @internal */\r\n public static get tentativePoint(): TentativePoint { return this._tentativePoint; }\r\n /** The [[Localization]] for this session. */\r\n public static get localization(): Localization { return this._localization; }\r\n /** The [[UserPreferencesAccess]] for this session.\r\n * @beta\r\n */\r\n public static get userPreferences(): UserPreferencesAccess | undefined { return this._userPreferences; }\r\n /** The Id of this application. Applications must set this to the Global Product Registry ID (GPRID) for usage logging. */\r\n public static get applicationId(): string { return this._applicationId; }\r\n /** The version of this application. Must be set for usage logging. */\r\n public static get applicationVersion(): string { return this._applicationVersion; }\r\n /** @internal */\r\n public static get initialized() { return this._initialized; }\r\n\r\n /** Provides access to the IModelHub implementation for this IModelApp.\r\n * @internal\r\n */\r\n public static get hubAccess(): FrontendHubAccess | undefined { return this._hubAccess; }\r\n /** Provides access to the RealityData service implementation for this IModelApp\r\n * @beta\r\n */\r\n public static get realityDataAccess(): RealityDataAccess | undefined { return this._realityDataAccess; }\r\n\r\n /** @internal */\r\n public static get hasRenderSystem() { return this._renderSystem !== undefined && this._renderSystem.isValid; }\r\n /** The [[UiAdmin]] for this session. */\r\n public static get uiAdmin() { return this._uiAdmin; }\r\n /** The requested security options for the frontend. */\r\n public static get securityOptions() { return this._securityOptions; }\r\n /** The root URL for the assets 'public' folder.\r\n * @beta\r\n */\r\n public static get publicPath() { return this._publicPath; }\r\n /** The [[TelemetryManager]] for this session\r\n * @internal\r\n */\r\n public static readonly telemetry: TelemetryManager = new TelemetryManager();\r\n\r\n /** @alpha */\r\n public static readonly extensionAdmin = this._createExtensionAdmin();\r\n\r\n /** Map of classFullName to EntityState class */\r\n private static _entityClasses = new Map<string, typeof EntityState>();\r\n\r\n /** Register all of the subclasses of EntityState from a module.\r\n * @internal\r\n */\r\n public static registerModuleEntities(moduleObj: any) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisEntityState = moduleObj[thisMember];\r\n if (thisEntityState.prototype instanceof EntityState) {\r\n this.registerEntityState(thisEntityState.classFullName, thisEntityState);\r\n }\r\n }\r\n }\r\n\r\n /** Register an EntityState class by its classFullName\r\n * @internal\r\n */\r\n public static registerEntityState(classFullName: string, classType: typeof EntityState) {\r\n const lowerName = classFullName.toLowerCase();\r\n if (this._entityClasses.has(lowerName)) {\r\n const errMsg = `Class ${classFullName} is already registered. Make sure static schemaName and className members are correct on class ${classType.name}`;\r\n Logger.logError(FrontendLoggerCategory.IModelConnection, errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._entityClasses.set(lowerName, classType);\r\n }\r\n\r\n /** @internal */\r\n public static lookupEntityClass(classFullName: string) { return this._entityClasses.get(classFullName.toLowerCase()); }\r\n\r\n /**\r\n * Obtain WebGL rendering compatibility information for the client system. This information describes whether the client meets the\r\n * minimum rendering capabilities. It also describes whether the system lacks any optional capabilities that could improve quality\r\n * and/or performance.\r\n */\r\n public static queryRenderCompatibility(): WebGLRenderCompatibilityInfo {\r\n if (undefined === System.instance || undefined === System.instance.options.useWebGL2)\r\n return queryRenderCompatibility(true, System.createContext);\r\n else\r\n return queryRenderCompatibility(System.instance.options.useWebGL2, System.createContext);\r\n }\r\n\r\n /**\r\n * This method must be called before any other `@itwin/core-frontend` methods are used.\r\n * Somewhere in your startup code, call [[IModelApp.startup]]. E.g.:\r\n * ``` ts\r\n * await IModelApp.startup( {applicationId: myAppId} );\r\n * ```\r\n * @param opts The options for configuring IModelApp\r\n */\r\n public static async startup(opts?: IModelAppOptions): Promise<void> {\r\n if (this._initialized)\r\n return; // we're already initialized, do nothing.\r\n this._initialized = true;\r\n\r\n opts = opts ?? {};\r\n this._securityOptions = opts.security ?? {};\r\n\r\n if (process.env.NODE_ENV === \"development\") {\r\n // Make IModelApp globally accessible for debugging purposes. We'll remove it on shutdown.\r\n (window as IModelAppForDebugger).iModelAppForDebugger = this;\r\n }\r\n\r\n this.sessionId = opts.sessionId ?? Guid.createValue();\r\n this._applicationId = opts.applicationId ?? \"2686\"; // Default to product id of iTwin.js\r\n this._applicationVersion = opts.applicationVersion ?? \"1.0.0\";\r\n this.authorizationClient = opts.authorizationClient;\r\n this._hubAccess = opts.hubAccess;\r\n\r\n this._setupRpcRequestContext();\r\n\r\n this._localization = opts.localization ?? new ITwinLocalization();\r\n const toolsNs = \"CoreTools\";\r\n await this.localization.initialize([\"iModelJs\", toolsNs]);\r\n [\r\n selectTool,\r\n idleTool,\r\n viewTool,\r\n clipViewTool,\r\n measureTool,\r\n accudrawTool,\r\n ].forEach((tool) => this.tools.registerModule(tool, toolsNs));\r\n\r\n this.registerEntityState(EntityState.classFullName, EntityState);\r\n [\r\n modelState,\r\n sheetState,\r\n viewState,\r\n drawingViewState,\r\n spatialViewState,\r\n displayStyleState,\r\n modelselector,\r\n categorySelectorState,\r\n auxCoordState,\r\n ].forEach((module) => this.registerModuleEntities(module));\r\n\r\n this._renderSystem = (opts.renderSys instanceof RenderSystem) ? opts.renderSys : this.createRenderSys(opts.renderSys);\r\n if (opts.userPreferences)\r\n this._userPreferences = opts.userPreferences;\r\n this._viewManager = opts.viewManager ?? new ViewManager();\r\n this._tileAdmin = await TileAdmin.create(opts.tileAdmin);\r\n this._notifications = opts.notifications ?? new NotificationManager();\r\n this._toolAdmin = opts.toolAdmin ?? new ToolAdmin();\r\n this._accuDraw = opts.accuDraw ?? new AccuDraw();\r\n this._accuSnap = opts.accuSnap ?? new AccuSnap();\r\n this._locateManager = opts.locateManager ?? new ElementLocateManager();\r\n this._tentativePoint = opts.tentativePoint ?? new TentativePoint();\r\n this._quantityFormatter = opts.quantityFormatter ?? new QuantityFormatter();\r\n this._uiAdmin = opts.uiAdmin ?? new UiAdmin();\r\n this._mapLayerFormatRegistry = new MapLayerFormatRegistry(opts.mapLayerOptions);\r\n this._realityDataAccess = opts.realityDataAccess;\r\n this._publicPath = opts.publicPath ?? \"\";\r\n\r\n [\r\n this.renderSystem,\r\n this.viewManager,\r\n this.toolAdmin,\r\n this.accuDraw,\r\n this.accuSnap,\r\n this.locateManager,\r\n this.tentativePoint,\r\n this.uiAdmin,\r\n ].forEach((sys) => sys.onInitialized());\r\n\r\n await this.quantityFormatter.onInitialized();\r\n this.onAfterStartup.raiseEvent();\r\n }\r\n\r\n /** Must be called before the application exits to release any held resources. */\r\n public static async shutdown() {\r\n if (!this._initialized)\r\n return;\r\n\r\n // notify listeners that this IModelApp is about to be shut down.\r\n this.onBeforeShutdown.raiseEvent();\r\n this.onBeforeShutdown.clear();\r\n\r\n if (process.env.NODE_ENV === \"development\") {\r\n (window as IModelAppForDebugger).iModelAppForDebugger = undefined;\r\n }\r\n\r\n this._wantEventLoop = false;\r\n window.removeEventListener(\"resize\", IModelApp.requestNextAnimation);\r\n this.clearIntervalAnimation();\r\n [this.toolAdmin, this.viewManager, this.tileAdmin].forEach((sys) => sys.onShutDown());\r\n this.tools.shutdown();\r\n this._renderSystem = dispose(this._renderSystem);\r\n this._entityClasses.clear();\r\n this.authorizationClient = undefined;\r\n this._initialized = false;\r\n this.onAfterStartup.clear();\r\n }\r\n\r\n /** Controls how frequently the application polls for changes that may require a new animation frame to be requested.\r\n * Such changes include resizing a Viewport or changing the device pixel ratio by zooming in or out in the browser.\r\n * The default interval is 1 second. It may be desirable to override the default for specific apps and/or devices.\r\n * - Increasing the interval can conserve battery life on battery-powered devices at the expense of slower response to resize events.\r\n * - An application that only displays a single Viewport whose dimensions only change when the dimensions of the application window change, and which does not support changing application zoom level, could disable the interval altogether.\r\n * @param interval The interval at which to poll for changes. If undefined (or negative), the application will never poll. If zero, the application will poll as frequently as possible.\r\n * @beta\r\n */\r\n public static get animationInterval(): BeDuration | undefined { return IModelApp._animationInterval; }\r\n public static set animationInterval(interval: BeDuration | undefined) {\r\n if (undefined !== interval && interval.isTowardsPast)\r\n interval = undefined;\r\n\r\n if (interval !== IModelApp._animationInterval) {\r\n IModelApp._animationInterval = interval;\r\n if (IModelApp._wantEventLoop)\r\n IModelApp.requestIntervalAnimation();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static requestNextAnimation() {\r\n if (!IModelApp._animationRequested) {\r\n IModelApp._animationRequested = true;\r\n requestAnimationFrame(IModelApp.eventLoop);\r\n }\r\n }\r\n\r\n /** @internal */\r\n private static clearIntervalAnimation(): void {\r\n if (undefined !== IModelApp._animationIntervalId) {\r\n window.clearInterval(IModelApp._animationIntervalId);\r\n IModelApp._animationIntervalId = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n private static requestIntervalAnimation(): void {\r\n IModelApp.clearIntervalAnimation();\r\n\r\n if (undefined !== IModelApp.animationInterval)\r\n IModelApp._animationIntervalId = window.setInterval(() => {\r\n IModelApp.requestNextAnimation();\r\n }, IModelApp.animationInterval.milliseconds);\r\n }\r\n\r\n /** @internal */\r\n public static startEventLoop() {\r\n if (!IModelApp._wantEventLoop) {\r\n IModelApp._wantEventLoop = true;\r\n window.addEventListener(\"resize\", IModelApp.requestNextAnimation);\r\n IModelApp.requestIntervalAnimation();\r\n IModelApp.requestNextAnimation();\r\n }\r\n }\r\n\r\n /** Strictly for tests. @internal */\r\n public static stopEventLoop() {\r\n this._wantEventLoop = false;\r\n }\r\n\r\n /** The main event processing loop for Tools and rendering. */\r\n private static eventLoop() {\r\n IModelApp._animationRequested = false;\r\n if (!IModelApp._wantEventLoop) // flag turned on at startup\r\n return;\r\n\r\n try {\r\n IModelApp.toolAdmin.processEvent(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n IModelApp.viewManager.renderLoop();\r\n IModelApp.tileAdmin.process();\r\n } catch (exception) {\r\n ToolAdmin.exceptionHandler(exception); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n IModelApp._wantEventLoop = false;\r\n IModelApp._animationRequested = true; // unrecoverable after exception, don't request any further frames.\r\n window.removeEventListener(\"resize\", IModelApp.requestNextAnimation);\r\n }\r\n }\r\n\r\n /** Get the user's access token for this IModelApp, or a blank string if none is available.\r\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\r\n * returned by this method may change over time throughout the course of a session.\r\n */\r\n public static async getAccessToken(): Promise<AccessToken> {\r\n try {\r\n return (await this.authorizationClient?.getAccessToken()) ?? \"\";\r\n } catch (e) {\r\n return \"\";\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static createRenderSys(opts?: RenderSystem.Options): RenderSystem { return System.create(opts); }\r\n\r\n private static _setupRpcRequestContext() {\r\n RpcConfiguration.requestContext.getId = (_request: RpcRequest): string => {\r\n return Guid.createValue();\r\n };\r\n\r\n RpcConfiguration.requestContext.serialize = async (_request: RpcRequest): Promise<SerializedRpcActivity> => {\r\n const id = _request.id;\r\n const serialized: SerializedRpcActivity = {\r\n id,\r\n applicationId: this.applicationId,\r\n applicationVersion: this.applicationVersion,\r\n sessionId: this.sessionId,\r\n authorization: ProcessDetector.isMobileAppFrontend ? \"\" : await this.getAccessToken(),\r\n };\r\n\r\n const csrf = IModelApp.securityOptions.csrfProtection;\r\n if (csrf && csrf.enabled) {\r\n const cookieName = csrf.cookieName || \"XSRF-TOKEN\";\r\n const cookieValue = document.cookie.split(\"; \").find((r) => r.startsWith(`${cookieName}=`));\r\n\r\n if (cookieValue) {\r\n const headerName = csrf.headerName || \"X-XSRF-TOKEN\";\r\n const headerValue = cookieValue.split(\"=\")[1];\r\n serialized.csrfToken = { headerName, headerValue };\r\n }\r\n }\r\n\r\n return serialized;\r\n };\r\n }\r\n\r\n /** Shortcut for creating an HTMLElement with optional parent, className, id, innerHTML, innerText\r\n * @internal\r\n */\r\n public static makeHTMLElement<K extends keyof HTMLElementTagNameMap>(type: K, opt?: {\r\n /** The parent for the new HTMLElement */\r\n parent?: HTMLElement;\r\n /** The className for the new HTMLElement */\r\n className?: string;\r\n /** The Id for the new HTMLElement */\r\n id?: string;\r\n /** innerHTML for the new HTMLElement */\r\n innerHTML?: string;\r\n /** innerText for the new HTMLElement */\r\n innerText?: string;\r\n }) {\r\n const el = document.createElement(type);\r\n if (undefined !== opt) {\r\n if (undefined !== opt.className)\r\n el.className = opt.className;\r\n if (undefined !== opt.id)\r\n el.id = opt.id;\r\n if (undefined !== opt.innerHTML)\r\n el.innerHTML = opt.innerHTML;\r\n if (undefined !== opt.innerText)\r\n el.innerText = opt.innerText;\r\n if (undefined !== opt.parent)\r\n opt.parent.appendChild(el);\r\n }\r\n return el;\r\n }\r\n\r\n /** Make a modal dialog on top of the root of the application. The returned HTMLDivElement will be placed topmost, all other application\r\n * windows will be covered with a semi-transparent background that intercepts all key/mouse/touch events until the modal is dismissed.\r\n * @param options The options that describe how the modal should work.\r\n * @internal\r\n */\r\n public static makeModalDiv(options: ModalOptions): ModalReturn {\r\n const root = options.rootDiv ? options.rootDiv : document.body;\r\n // create the overlay div to \"black out\" the application to indicate everything is inactive until the modal has been dismissed.\r\n const overlay = IModelApp.makeHTMLElement(\"div\", { parent: root, className: \"imodeljs-modal-overlay\" });\r\n overlay.tabIndex = -1; // so we can catch keystroke events\r\n\r\n // function to remove modal dialog\r\n const stop = (ev: Event) => { root.removeChild(overlay); ev.stopPropagation(); };\r\n\r\n if (options.autoClose) {\r\n overlay.onclick = overlay.oncontextmenu = stop;\r\n overlay.onkeydown = overlay.onkeyup = (ev: KeyboardEvent) => { // ignore all keystrokes other than enter and escape\r\n switch (ev.key) {\r\n case \"Enter\":\r\n case \"Escape\":\r\n stop(ev);\r\n return;\r\n }\r\n ev.stopPropagation();\r\n };\r\n overlay.focus();\r\n }\r\n\r\n const modal = IModelApp.makeHTMLElement(\"div\", { parent: overlay, className: \"imodeljs-modal\" });\r\n if (undefined !== options.width) {\r\n modal.style.width = `${options.width}px`;\r\n // allow the dialog to be smaller than the width\r\n modal.style.maxWidth = `min(100% - (2 * var(--width-border)), ${options.width}px)`;\r\n }\r\n if (options.closeBox) {\r\n const close = IModelApp.makeHTMLElement(\"p\", { parent: modal, className: \"imodeljs-modal-close\" });\r\n close.innerText = \"\\u00d7\"; // unicode \"times\" symbol\r\n close.onclick = stop;\r\n }\r\n\r\n return { modal, stop };\r\n }\r\n\r\n /** Applications may implement this method to supply a Logo Card.\r\n * @beta\r\n */\r\n public static applicationLogoCard?: () => HTMLTableRowElement;\r\n\r\n /** Make a new Logo Card. Call this method from your implementation of [[IModelApp.applicationLogoCard]]\r\n * @param opts Options for Logo Card\r\n * @beta\r\n */\r\n public static makeLogoCard(\r\n opts: {\r\n /** The heading to be put at the top of this logo card inside an <h2>. May include HTML. */\r\n heading: string | HTMLElement;\r\n /** The URL or HTMLImageElement for the icon on this logo card. */\r\n iconSrc?: string | HTMLImageElement;\r\n /** The width of the icon, if `iconSrc` is a string. Default is 64. */\r\n iconWidth?: number;\r\n /** A *notice* string to be shown on the logo card. May include HTML. */\r\n notice?: string | HTMLElement;\r\n }): HTMLTableRowElement {\r\n const card = IModelApp.makeHTMLElement(\"tr\");\r\n const iconCell = IModelApp.makeHTMLElement(\"td\", { parent: card, className: \"logo-card-logo\" });\r\n if (undefined !== opts.iconSrc) {\r\n if (typeof opts.iconSrc === \"string\") {\r\n const logo = IModelApp.makeHTMLElement(\"img\");\r\n logo.src = opts.iconSrc;\r\n logo.width = opts.iconWidth ? opts.iconWidth : 64;\r\n opts.iconSrc = logo;\r\n }\r\n iconCell.appendChild(opts.iconSrc);\r\n }\r\n const noticeCell = IModelApp.makeHTMLElement(\"td\", { parent: card, className: \"logo-card-message\" });\r\n if (undefined !== opts.heading) {\r\n if (typeof opts.heading === \"string\")\r\n IModelApp.makeHTMLElement(\"h2\", { parent: noticeCell, innerHTML: opts.heading, className: \"logo-card-header\" });\r\n else\r\n noticeCell.appendChild(opts.heading);\r\n }\r\n if (undefined !== opts.notice) {\r\n if (typeof opts.notice === \"string\")\r\n IModelApp.makeHTMLElement(\"p\", { parent: noticeCell, innerHTML: opts.notice, className: \"logo-cards\" });\r\n else\r\n noticeCell.appendChild(opts.notice);\r\n }\r\n return card;\r\n }\r\n\r\n /** Make the logo card for the library itself. This card gets placed at the top of the stack.\r\n * @internal\r\n */\r\n public static makeIModelJsLogoCard() {\r\n return this.makeLogoCard({\r\n iconSrc: `${this.publicPath}images/about-imodeljs.svg`,\r\n heading: `<span style=\"font-weight:normal\">${this.localization.getLocalizedString(\"iModelJs:Notices.PoweredBy\")}</span>&nbsp;iTwin.js`,\r\n notice: `${ITWINJS_CORE_VERSION}<br>${COPYRIGHT_NOTICE}`,\r\n });\r\n }\r\n\r\n /** Format the tooltip strings returned by [[IModelConnection.getToolTipMessage]].\r\n * @alpha\r\n */\r\n public static formatElementToolTip(msg: string[]): HTMLElement {\r\n let out = \"\";\r\n msg.forEach((line) => out += `${IModelApp.localization?.getLocalizedKeys(line)}<br>`);\r\n const div = document.createElement(\"div\");\r\n div.innerHTML = out;\r\n return div;\r\n }\r\n\r\n /** Localize an error status\r\n * @param status one of the status values from [BentleyStatus]($core-bentley), [IModelStatus]($core-bentley) or [DbResult]($core-bentley)\r\n * @returns a localized error message\r\n * @beta\r\n */\r\n public static translateStatus(status: number) {\r\n let key: { scope: string, val: string, status?: string };\r\n if (typeof status !== \"number\") {\r\n key = { scope: \"Errors\", val: \"IllegalValue\" };\r\n } else {\r\n key = { scope: \"BentleyStatus\", val: BentleyStatus[status] };\r\n if (!key.val)\r\n key = { scope: \"IModelStatus\", val: IModelStatus[status] };\r\n if (!key.val)\r\n key = { scope: \"DbResult\", val: DbResult[status] };\r\n if (!key.val)\r\n key = { scope: \"Errors\", val: \"Status\", status: status.toString() };\r\n }\r\n\r\n return this.localization.getLocalizedString(`iModelJs:${key.scope}.${key.val}`, key);\r\n }\r\n\r\n /**\r\n * Creates an instance of the ExtensionAdmin\r\n * and registers an event to execute after startup is complete\r\n * @returns an instance of ExtensionAdmin\r\n */\r\n private static _createExtensionAdmin(): ExtensionAdmin {\r\n const extensionAdmin = new ExtensionAdmin();\r\n IModelApp.onAfterStartup.addListener(extensionAdmin.onStartup);\r\n return extensionAdmin;\r\n }\r\n}\r\n"]}
@@ -29,10 +29,13 @@ export declare class ExtensionAdmin {
29
29
  */
30
30
  addExtensions(providers: ExtensionProvider[]): Promise<void[]>;
31
31
  /**
32
- * Register a url (hostname) for extension hosting (i.e. https://localhost:3000, https://www.yourdomain.com, etc.)
33
- * @param hostUrl
32
+ * Registers a hostname for an extension.
33
+ * Once a hostname has been registered, only remote extensions from registered hosts are permitted to be added.
34
+ * @param hostUrl (string) Accepts both URLs and hostnames (e.g., http://localhost:3000, yourdomain.com, https://www.yourdomain.com, etc.).
34
35
  */
35
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;
36
39
  /** Loops over all enabled Extensions and triggers each one if the provided event is defined. */
37
40
  private activateExtensionEvents;
38
41
  /** 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;;;OAGG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM;IAOnC,gGAAgG;YAClF,uBAAuB;IAWrC,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;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;IAWrC,sHAAsH;YACxG,QAAQ;CAOvB"}
@@ -47,7 +47,7 @@ export class ExtensionAdmin {
47
47
  provider.execute(); // eslint-disable-line @typescript-eslint/no-floating-promises
48
48
  }
49
49
  catch (e) {
50
- throw new Error(`Failed to get manifest from extension: ${e}`);
50
+ throw new Error(`Failed to get extension manifest ${provider.hostname ? `at ${provider.hostname}` : ""}: ${e}`);
51
51
  }
52
52
  }
53
53
  /**
@@ -59,13 +59,31 @@ export class ExtensionAdmin {
59
59
  return Promise.all(providers.map(async (provider) => this.addExtension(provider)));
60
60
  }
61
61
  /**
62
- * Register a url (hostname) for extension hosting (i.e. https://localhost:3000, https://www.yourdomain.com, etc.)
63
- * @param hostUrl
62
+ * Registers a hostname for an extension.
63
+ * Once a hostname has been registered, only remote extensions from registered hosts are permitted to be added.
64
+ * @param hostUrl (string) Accepts both URLs and hostnames (e.g., http://localhost:3000, yourdomain.com, https://www.yourdomain.com, etc.).
64
65
  */
65
66
  registerHost(hostUrl) {
66
- const url = new URL(hostUrl).hostname.replace("www", "");
67
- if (this._hosts.indexOf(url) < 0) {
68
- this._hosts.push(url);
67
+ const hostname = this.getHostName(hostUrl);
68
+ if (this._hosts.indexOf(hostname) < 0) {
69
+ this._hosts.push(hostname);
70
+ }
71
+ }
72
+ /** Returns the hostname of an input string. Throws an error if input is not a valid hostname (or URL). */
73
+ getHostName(inputUrl) {
74
+ // inputs without a protocol (e.g., http://) will throw an error in URL constructor
75
+ const inputWithProtocol = /(http|https):\/\//.test(inputUrl) ?
76
+ inputUrl :
77
+ `https://${inputUrl}`;
78
+ try {
79
+ const hostname = new URL(inputWithProtocol).hostname.replace("www.", "");
80
+ return hostname;
81
+ }
82
+ catch (e) {
83
+ if (e instanceof TypeError) {
84
+ throw new Error("Argument hostUrl should be a valid URL or hostname (i.e. http://localhost:3000, yourdomain.com, etc.).");
85
+ }
86
+ throw e;
69
87
  }
70
88
  }
71
89
  /** Loops over all enabled Extensions and triggers each one if the provided event is defined. */
@@ -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,2BAA2B,CAAC;AA6BnE;;;GAGG;AACH,MAAM,OAAO,cAAc;IAYzB;QAXA,2GAA2G;QACnG,gBAAW,GAAoC,IAAI,GAAG,EAA8B,CAAC;QAG7F;;WAEG;QACI,cAAS,GAAG,KAAK,IAAI,EAAE;YAC5B,MAAM,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC,CAAC;QAGA,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,YAAY,CAAC,QAA2B;QACnD,IAAI,QAAQ,CAAC,QAAQ,EAAE;YACrB,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;YACnC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC/D,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,sBAAsB,CAAC,CAAC;aAC7E;SACF;QACD,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC9C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE;gBAClC,QAAQ;gBACR,QAAQ;aACT,CAAC,CAAC;YACH,2DAA2D;YAC3D,IAAI,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACjD,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,8DAA8D;SACr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SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;SAClH;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 \"../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 manifest from extension: ${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 * Register a url (hostname) for extension hosting (i.e. https://localhost:3000, https://www.yourdomain.com, etc.)\r\n * @param hostUrl\r\n */\r\n public registerHost(hostUrl: string) {\r\n const url = new URL(hostUrl).hostname.replace(\"www\", \"\");\r\n if (this._hosts.indexOf(url) < 0) {\r\n this._hosts.push(url);\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) continue;\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}: ${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,2BAA2B,CAAC;AA6BnE;;;GAGG;AACH,MAAM,OAAO,cAAc;IAYzB;QAXA,2GAA2G;QACnG,gBAAW,GAAoC,IAAI,GAAG,EAA8B,CAAC;QAG7F;;WAEG;QACI,cAAS,GAAG,KAAK,IAAI,EAAE;YAC5B,MAAM,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC,CAAC;QAGA,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,YAAY,CAAC,QAA2B;QACnD,IAAI,QAAQ,CAAC,QAAQ,EAAE;YACrB,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;YACnC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC/D,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,sBAAsB,CAAC,CAAC;aAC7E;SACF;QACD,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC9C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE;gBAClC,QAAQ;gBACR,QAAQ;aACT,CAAC,CAAC;YACH,2DAA2D;YAC3D,IAAI,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACjD,QAA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,CAAC;IAED,gGAAgG;IACxF,KAAK,CAAC,uBAAuB,CAAC,KAAa;QACjD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE;YACjD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB;gBAAE,SAAS;YACnD,KAAK,MAAM,eAAe,IAAI,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE;gBACjE,IAAI,eAAe,KAAK,KAAK,EAAE;oBAC7B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,8DAA8D;iBACzF;aACF;SACF;IACH,CAAC;IAED,sHAAsH;IAC9G,KAAK,CAAC,QAAQ,CAAC,SAA6B;QAClD,IAAI;YACF,MAAM,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;SACpC;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC,UAAU,EAAE,6BAA6B,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;SAClH;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 \"../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}` : \"\"}: ${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) continue;\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}: ${e}`);\r\n }\r\n }\r\n}\r\n"]}
@@ -34,19 +34,21 @@ export declare class ExtensionClient {
34
34
  private get _endpoint();
35
35
  private parseExtensionMetadataArray;
36
36
  /**
37
- * Gets information on extensions. If extensionName is undefined, will return all extensions in the context.
38
- * If it's defined, will return all versions of that extension.
39
- * @param iTwinId Context Id
37
+ * Gets information on extensions. If extensionName is undefined, will return all extensions in the iTwin.
38
+ * If extensionName is defined, will return all versions of that extension.
39
+ * If iTwinId is undefined, will default to the public extensions.
40
40
  * @param extensionName Extension name (optional)
41
+ * @param iTwinId iTwin Id (optional)
41
42
  */
42
- getExtensions(accessToken: AccessToken, iTwinId: string, extensionName?: string): Promise<ExtensionMetadata[]>;
43
+ getExtensions(accessToken: AccessToken, extensionName?: string, iTwinId?: string): Promise<ExtensionMetadata[]>;
43
44
  /**
44
45
  * Gets information about an extension's specific version
45
- * @param iTwinId iTwin Id
46
+ * If iTwinId is undefined, will assume the extension was published publicly.
46
47
  * @param extensionName Extension name
47
48
  * @param version Extension version
49
+ * @param iTwinId iTwin Id (optional)
48
50
  */
49
- getExtensionMetadata(accessToken: AccessToken, iTwinId: string, extensionName: string, version: string): Promise<ExtensionMetadata | undefined>;
51
+ getExtensionMetadata(accessToken: AccessToken, extensionName: string, version: string, iTwinId?: string): Promise<ExtensionMetadata | undefined>;
50
52
  }
51
53
  export {};
52
54
  //# sourceMappingURL=ExtensionServiceClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionServiceClient.d.ts","sourceRoot":"","sources":["../../../../src/extension/providers/ExtensionServiceClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIlD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,qBAAqB;IAC7B,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,QAAQ;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,IAAI,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;;IAKlC,OAAO,KAAK,SAAS,GAWpB;IAED,OAAO,CAAC,2BAA2B;IAcnC;;;;;OAKG;IACU,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAa3H;;;;;OAKG;IACU,oBAAoB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;CAe7J"}
1
+ {"version":3,"file":"ExtensionServiceClient.d.ts","sourceRoot":"","sources":["../../../../src/extension/providers/ExtensionServiceClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAQ,MAAM,qBAAqB,CAAC;AAIxD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,qBAAqB;IAC7B,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,QAAQ;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,IAAI,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;;IAKlC,OAAO,KAAK,SAAS,GAWpB;IAED,OAAO,CAAC,2BAA2B;IAcnC;;;;;;OAMG;IACU,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,SAAa,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAahI;;;;;;OAMG;IACU,oBAAoB,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,SAAa,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;CAelK"}
@@ -1,3 +1,8 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { Guid } from "@itwin/core-bentley";
1
6
  import { request } from "../../request/Request";
2
7
  /**
3
8
  * Client for querying, publishing and deleting iModel.js Extensions.
@@ -32,12 +37,13 @@ export class ExtensionClient {
32
37
  return ret;
33
38
  }
34
39
  /**
35
- * Gets information on extensions. If extensionName is undefined, will return all extensions in the context.
36
- * If it's defined, will return all versions of that extension.
37
- * @param iTwinId Context Id
40
+ * Gets information on extensions. If extensionName is undefined, will return all extensions in the iTwin.
41
+ * If extensionName is defined, will return all versions of that extension.
42
+ * If iTwinId is undefined, will default to the public extensions.
38
43
  * @param extensionName Extension name (optional)
44
+ * @param iTwinId iTwin Id (optional)
39
45
  */
40
- async getExtensions(accessToken, iTwinId, extensionName) {
46
+ async getExtensions(accessToken, extensionName, iTwinId = Guid.empty) {
41
47
  const options = { method: "GET" };
42
48
  options.headers = { authorization: accessToken };
43
49
  const response = await request(`${this._endpoint}${iTwinId}/IModelExtension/${extensionName !== null && extensionName !== void 0 ? extensionName : ""}`, options);
@@ -49,11 +55,12 @@ export class ExtensionClient {
49
55
  }
50
56
  /**
51
57
  * Gets information about an extension's specific version
52
- * @param iTwinId iTwin Id
58
+ * If iTwinId is undefined, will assume the extension was published publicly.
53
59
  * @param extensionName Extension name
54
60
  * @param version Extension version
61
+ * @param iTwinId iTwin Id (optional)
55
62
  */
56
- async getExtensionMetadata(accessToken, iTwinId, extensionName, version) {
63
+ async getExtensionMetadata(accessToken, extensionName, version, iTwinId = Guid.empty) {
57
64
  const options = { method: "GET" };
58
65
  options.headers = { authorization: accessToken };
59
66
  const response = await request(`${this._endpoint}${iTwinId}/IModelExtension/${extensionName}/${version}`, options);
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionServiceClient.js","sourceRoot":"","sources":["../../../../src/extension/providers/ExtensionServiceClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAkB,MAAM,uBAAuB,CAAC;AA2BhE;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IAE1B;QACE,IAAI,CAAC,QAAQ,GAAG,iDAAiD,CAAC;IACpE,CAAC;IAED,IAAY,SAAS;QACnB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAC3C,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,MAAM;YACR,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;QAExD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;YACjC,OAAO,CAAC,QAAQ,IAAI,GAAG,CAAC;QAE1B,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC;QAC5B,OAAO,OAAO,CAAC,QAAQ,EAA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AM,KAAK,IAAI,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,EAAE;QAE1G,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,UAAU,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACjD,MAAM,EAAE,MAAA,UAAU,CAAC,MAAM,mCAAI,OAAO;KACrC,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAe;IACvC,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,UAAU,CAAC,GAAG,KAAK,QAAQ;QACpE,UAAU,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,UAAU,CAAC,SAAS,KAAK,QAAQ;QAC9E,UAAU,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,OAAO,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,UAAU,CAAC,QAAQ,KAAK,IAAI,CAAC,EAAE;QAEhH,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,OAAO,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QACvC,QAAQ,EAAE,UAAU,CAAC,QAAQ;KAC9B,CAAC;AACJ,CAAC","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 { AccessToken } from \"@itwin/core-bentley\";\r\n\r\nimport { request, RequestOptions } from \"../../request/Request\";\r\n\r\n/** Structure of extensions from the ExtensionService\r\n * @internal\r\n */\r\nexport interface ExtensionMetadata {\r\n contextId: string;\r\n extensionName: string;\r\n version: string;\r\n files: FileInfo[];\r\n uploadedBy: string;\r\n timestamp: Date;\r\n status: ExtensionUploadStatus;\r\n isPublic: boolean;\r\n}\r\n\r\ninterface ExtensionUploadStatus {\r\n updateTime: Date;\r\n status: string;\r\n}\r\n\r\ninterface FileInfo {\r\n url: string;\r\n expires: Date;\r\n checksum: string;\r\n}\r\n\r\n/**\r\n * Client for querying, publishing and deleting iModel.js Extensions.\r\n *\r\n * The `imodel-extension-service-api` OIDC scope is required for all operations and the `imodel-extension-service:modify` is\r\n * required for modification operations (modify, publish, and deleting).\r\n * @alpha\r\n */\r\nexport class ExtensionClient {\r\n private readonly _baseUrl: string;\r\n public constructor() {\r\n this._baseUrl = \"https://api.bentley.com/iModelExtensionService/\";\r\n }\r\n\r\n private get _endpoint(): string {\r\n const prefix = process.env.IMJS_URL_PREFIX;\r\n const baseUrl = new URL(this._baseUrl);\r\n if (prefix)\r\n baseUrl.hostname = prefix + new URL(baseUrl).hostname;\r\n\r\n if (!baseUrl.pathname.endsWith(\"/\"))\r\n baseUrl.pathname += \"/\";\r\n\r\n baseUrl.pathname += \"v1.0/\";\r\n return baseUrl.toString();\r\n }\r\n\r\n private parseExtensionMetadataArray(json: any): ExtensionMetadata[] {\r\n if (!(json instanceof Array))\r\n return [];\r\n\r\n const ret: ExtensionMetadata[] = [];\r\n json.forEach((extensionJson) => {\r\n const extension = extensionMetadataFromJSON(extensionJson);\r\n if (extension !== undefined)\r\n ret.push(extension);\r\n });\r\n\r\n return ret;\r\n }\r\n\r\n /**\r\n * Gets information on extensions. If extensionName is undefined, will return all extensions in the context.\r\n * If it's defined, will return all versions of that extension.\r\n * @param iTwinId Context Id\r\n * @param extensionName Extension name (optional)\r\n */\r\n public async getExtensions(accessToken: AccessToken, iTwinId: string, extensionName?: string): Promise<ExtensionMetadata[]> {\r\n const options: RequestOptions = { method: \"GET\" };\r\n options.headers = { authorization: accessToken };\r\n const response = await request(`${this._endpoint}${iTwinId}/IModelExtension/${extensionName ?? \"\"}`, options);\r\n if (response.status !== 200)\r\n throw new Error(`Server returned status: ${response.status}, message: ${response.body.message}`);\r\n\r\n if (!(response.body instanceof Array) || response.body.length < 1)\r\n return [];\r\n\r\n return this.parseExtensionMetadataArray(response.body);\r\n }\r\n\r\n /**\r\n * Gets information about an extension's specific version\r\n * @param iTwinId iTwin Id\r\n * @param extensionName Extension name\r\n * @param version Extension version\r\n */\r\n public async getExtensionMetadata(accessToken: AccessToken, iTwinId: string, extensionName: string, version: string): Promise<ExtensionMetadata | undefined> {\r\n\r\n const options: RequestOptions = { method: \"GET\" };\r\n options.headers = { authorization: accessToken };\r\n const response = await request(`${this._endpoint}${iTwinId}/IModelExtension/${extensionName}/${version}`, options);\r\n if (response.status !== 200)\r\n throw new Error(`Server returned status: ${response.status}, message: ${response.body.message}`);\r\n\r\n if (!(response.body instanceof Array) || response.body.length < 1)\r\n return undefined;\r\n if (response.body.length > 1)\r\n throw new Error(\"Server returned too many extensions\");\r\n\r\n return extensionMetadataFromJSON(response.body[0]);\r\n }\r\n}\r\n\r\n/**\r\n * Validates JSON and returns ExtensionMetadata\r\n */\r\nfunction extensionMetadataFromJSON(jsonObject: any): ExtensionMetadata | undefined {\r\n if (jsonObject.contextId === undefined || typeof jsonObject.contextId !== \"string\" ||\r\n jsonObject.extensionName === undefined || typeof jsonObject.extensionName !== \"string\" ||\r\n jsonObject.version === undefined || typeof jsonObject.version !== \"string\" ||\r\n jsonObject.files === undefined || !(jsonObject.files instanceof Array) ||\r\n jsonObject.uploadedBy === undefined || typeof jsonObject.uploadedBy !== \"string\" ||\r\n jsonObject.timestamp === undefined || typeof jsonObject.timestamp !== \"string\" ||\r\n jsonObject.isPublic === undefined || typeof jsonObject.isPublic !== \"boolean\" ||\r\n jsonObject.extensionStatus === undefined) {\r\n\r\n return undefined;\r\n }\r\n\r\n const status = statusFromJSON(jsonObject.extensionStatus);\r\n if (status === undefined)\r\n return undefined;\r\n\r\n const files = new Array(jsonObject.files.length);\r\n for (let i = 0; i < jsonObject.files.length; i++) {\r\n const parsed = fileInfoFromJSON(jsonObject.files[i]);\r\n if (parsed === undefined)\r\n return undefined;\r\n files[i] = parsed;\r\n }\r\n\r\n return {\r\n contextId: jsonObject.contextId,\r\n extensionName: jsonObject.extensionName,\r\n version: jsonObject.version,\r\n files,\r\n uploadedBy: jsonObject.uploadedBy,\r\n timestamp: new Date(jsonObject.timestamp),\r\n isPublic: jsonObject.isPublic,\r\n status,\r\n };\r\n}\r\n\r\nfunction statusFromJSON(jsonObject: any) {\r\n if (jsonObject.statusUpdateTime === undefined || typeof jsonObject.statusUpdateTime !== \"string\" ||\r\n jsonObject.status === undefined || (jsonObject.status !== null && typeof jsonObject.status !== \"string\")) {\r\n\r\n return undefined;\r\n }\r\n\r\n return {\r\n updateTime: new Date(jsonObject.statusUpdateTime),\r\n status: jsonObject.status ?? \"Valid\",\r\n };\r\n}\r\n\r\nfunction fileInfoFromJSON(jsonObject: any) {\r\n if (jsonObject.url === undefined || typeof jsonObject.url !== \"string\" ||\r\n jsonObject.expiresAt === undefined || typeof jsonObject.expiresAt !== \"string\" ||\r\n jsonObject.checksum === undefined || (typeof jsonObject.checksum !== \"string\" && jsonObject.checksum !== null)) {\r\n\r\n return undefined;\r\n }\r\n\r\n return {\r\n url: jsonObject.url,\r\n expires: new Date(jsonObject.expiresAt),\r\n checksum: jsonObject.checksum,\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"ExtensionServiceClient.js","sourceRoot":"","sources":["../../../../src/extension/providers/ExtensionServiceClient.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAe,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAkB,MAAM,uBAAuB,CAAC;AA2BhE;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IAE1B;QACE,IAAI,CAAC,QAAQ,GAAG,iDAAiD,CAAC;IACpE,CAAC;IAED,IAAY,SAAS;QACnB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAC3C,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,MAAM;YACR,OAAO,CAAC,QA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C,SAAS,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QACzC,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,MAAM;KACP,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,UAAe;;IACrC,IAAI,UAAU,CAAC,gBAAgB,KAAK,SAAS,IAAI,OAAO,UAAU,CAAC,gBAAgB,KAAK,QAAQ;QAC9F,UAAU,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,IAAI,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,EAAE;QAE1G,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,UAAU,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACjD,MAAM,EAAE,MAAA,UAAU,CAAC,MAAM,mCAAI,OAAO;KACrC,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAe;IACvC,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,UAAU,CAAC,GAAG,KAAK,QAAQ;QACpE,UAAU,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,UAAU,CAAC,SAAS,KAAK,QAAQ;QAC9E,UAAU,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,OAAO,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,UAAU,CAAC,QAAQ,KAAK,IAAI,CAAC,EAAE;QAEhH,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,OAAO,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QACvC,QAAQ,EAAE,UAAU,CAAC,QAAQ;KAC9B,CAAC;AACJ,CAAC","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 { AccessToken, Guid } from \"@itwin/core-bentley\";\r\n\r\nimport { request, RequestOptions } from \"../../request/Request\";\r\n\r\n/** Structure of extensions from the ExtensionService\r\n * @internal\r\n */\r\nexport interface ExtensionMetadata {\r\n contextId: string;\r\n extensionName: string;\r\n version: string;\r\n files: FileInfo[];\r\n uploadedBy: string;\r\n timestamp: Date;\r\n status: ExtensionUploadStatus;\r\n isPublic: boolean;\r\n}\r\n\r\ninterface ExtensionUploadStatus {\r\n updateTime: Date;\r\n status: string;\r\n}\r\n\r\ninterface FileInfo {\r\n url: string;\r\n expires: Date;\r\n checksum: string;\r\n}\r\n\r\n/**\r\n * Client for querying, publishing and deleting iModel.js Extensions.\r\n *\r\n * The `imodel-extension-service-api` OIDC scope is required for all operations and the `imodel-extension-service:modify` is\r\n * required for modification operations (modify, publish, and deleting).\r\n * @alpha\r\n */\r\nexport class ExtensionClient {\r\n private readonly _baseUrl: string;\r\n public constructor() {\r\n this._baseUrl = \"https://api.bentley.com/iModelExtensionService/\";\r\n }\r\n\r\n private get _endpoint(): string {\r\n const prefix = process.env.IMJS_URL_PREFIX;\r\n const baseUrl = new URL(this._baseUrl);\r\n if (prefix)\r\n baseUrl.hostname = prefix + new URL(baseUrl).hostname;\r\n\r\n if (!baseUrl.pathname.endsWith(\"/\"))\r\n baseUrl.pathname += \"/\";\r\n\r\n baseUrl.pathname += \"v1.0/\";\r\n return baseUrl.toString();\r\n }\r\n\r\n private parseExtensionMetadataArray(json: any): ExtensionMetadata[] {\r\n if (!(json instanceof Array))\r\n return [];\r\n\r\n const ret: ExtensionMetadata[] = [];\r\n json.forEach((extensionJson) => {\r\n const extension = extensionMetadataFromJSON(extensionJson);\r\n if (extension !== undefined)\r\n ret.push(extension);\r\n });\r\n\r\n return ret;\r\n }\r\n\r\n /**\r\n * Gets information on extensions. If extensionName is undefined, will return all extensions in the iTwin.\r\n * If extensionName is defined, will return all versions of that extension.\r\n * If iTwinId is undefined, will default to the public extensions.\r\n * @param extensionName Extension name (optional)\r\n * @param iTwinId iTwin Id (optional)\r\n */\r\n public async getExtensions(accessToken: AccessToken, extensionName?: string, iTwinId = Guid.empty): Promise<ExtensionMetadata[]> {\r\n const options: RequestOptions = { method: \"GET\" };\r\n options.headers = { authorization: accessToken };\r\n const response = await request(`${this._endpoint}${iTwinId}/IModelExtension/${extensionName ?? \"\"}`, options);\r\n if (response.status !== 200)\r\n throw new Error(`Server returned status: ${response.status}, message: ${response.body.message}`);\r\n\r\n if (!(response.body instanceof Array) || response.body.length < 1)\r\n return [];\r\n\r\n return this.parseExtensionMetadataArray(response.body);\r\n }\r\n\r\n /**\r\n * Gets information about an extension's specific version\r\n * If iTwinId is undefined, will assume the extension was published publicly.\r\n * @param extensionName Extension name\r\n * @param version Extension version\r\n * @param iTwinId iTwin Id (optional)\r\n */\r\n public async getExtensionMetadata(accessToken: AccessToken, extensionName: string, version: string, iTwinId = Guid.empty): Promise<ExtensionMetadata | undefined> {\r\n\r\n const options: RequestOptions = { method: \"GET\" };\r\n options.headers = { authorization: accessToken };\r\n const response = await request(`${this._endpoint}${iTwinId}/IModelExtension/${extensionName}/${version}`, options);\r\n if (response.status !== 200)\r\n throw new Error(`Server returned status: ${response.status}, message: ${response.body.message}`);\r\n\r\n if (!(response.body instanceof Array) || response.body.length < 1)\r\n return undefined;\r\n if (response.body.length > 1)\r\n throw new Error(\"Server returned too many extensions\");\r\n\r\n return extensionMetadataFromJSON(response.body[0]);\r\n }\r\n}\r\n\r\n/**\r\n * Validates JSON and returns ExtensionMetadata\r\n */\r\nfunction extensionMetadataFromJSON(jsonObject: any): ExtensionMetadata | undefined {\r\n if (jsonObject.contextId === undefined || typeof jsonObject.contextId !== \"string\" ||\r\n jsonObject.extensionName === undefined || typeof jsonObject.extensionName !== \"string\" ||\r\n jsonObject.version === undefined || typeof jsonObject.version !== \"string\" ||\r\n jsonObject.files === undefined || !(jsonObject.files instanceof Array) ||\r\n jsonObject.uploadedBy === undefined || typeof jsonObject.uploadedBy !== \"string\" ||\r\n jsonObject.timestamp === undefined || typeof jsonObject.timestamp !== \"string\" ||\r\n jsonObject.isPublic === undefined || typeof jsonObject.isPublic !== \"boolean\" ||\r\n jsonObject.extensionStatus === undefined) {\r\n\r\n return undefined;\r\n }\r\n\r\n const status = statusFromJSON(jsonObject.extensionStatus);\r\n if (status === undefined)\r\n return undefined;\r\n\r\n const files = new Array(jsonObject.files.length);\r\n for (let i = 0; i < jsonObject.files.length; i++) {\r\n const parsed = fileInfoFromJSON(jsonObject.files[i]);\r\n if (parsed === undefined)\r\n return undefined;\r\n files[i] = parsed;\r\n }\r\n\r\n return {\r\n contextId: jsonObject.contextId,\r\n extensionName: jsonObject.extensionName,\r\n version: jsonObject.version,\r\n files,\r\n uploadedBy: jsonObject.uploadedBy,\r\n timestamp: new Date(jsonObject.timestamp),\r\n isPublic: jsonObject.isPublic,\r\n status,\r\n };\r\n}\r\n\r\nfunction statusFromJSON(jsonObject: any) {\r\n if (jsonObject.statusUpdateTime === undefined || typeof jsonObject.statusUpdateTime !== \"string\" ||\r\n jsonObject.status === undefined || (jsonObject.status !== null && typeof jsonObject.status !== \"string\")) {\r\n\r\n return undefined;\r\n }\r\n\r\n return {\r\n updateTime: new Date(jsonObject.statusUpdateTime),\r\n status: jsonObject.status ?? \"Valid\",\r\n };\r\n}\r\n\r\nfunction fileInfoFromJSON(jsonObject: any) {\r\n if (jsonObject.url === undefined || typeof jsonObject.url !== \"string\" ||\r\n jsonObject.expiresAt === undefined || typeof jsonObject.expiresAt !== \"string\" ||\r\n jsonObject.checksum === undefined || (typeof jsonObject.checksum !== \"string\" && jsonObject.checksum !== null)) {\r\n\r\n return undefined;\r\n }\r\n\r\n return {\r\n url: jsonObject.url,\r\n expires: new Date(jsonObject.expiresAt),\r\n checksum: jsonObject.checksum,\r\n };\r\n}\r\n"]}
@@ -30,7 +30,5 @@ export declare class RemoteExtensionProvider implements ExtensionProvider {
30
30
  * Throws an error if the provided manifestUrl is not accessible.
31
31
  */
32
32
  getManifest(): Promise<ExtensionManifest>;
33
- /** Checks if url actually exists */
34
- private _exists;
35
33
  }
36
34
  //# sourceMappingURL=RemoteExtensionProvider.d.ts.map
@@ -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;AAGtB;;;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;IAQvC;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAQtD,oCAAoC;YACtB,OAAO;CAWtB"}
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;CAWvD"}
@@ -1,3 +1,4 @@
1
+ import { request } from "../../request/Request";
1
2
  import { loadScript } from "./ExtensionLoadScript";
2
3
  /**
3
4
  * Implements a "remote" extension.
@@ -15,10 +16,6 @@ export class RemoteExtensionProvider {
15
16
  * Throws an error if the provided jsUrl is not accessible.
16
17
  */
17
18
  async execute() {
18
- const doesUrlExist = await this._exists(this._props.jsUrl);
19
- if (!doesUrlExist) {
20
- throw new Error(`Extension at ${this._props.jsUrl} could not be found.`);
21
- }
22
19
  return loadScript(this._props.jsUrl);
23
20
  }
24
21
  /**
@@ -26,24 +23,14 @@ export class RemoteExtensionProvider {
26
23
  * Throws an error if the provided manifestUrl is not accessible.
27
24
  */
28
25
  async getManifest() {
29
- const doesUrlExist = await this._exists(this._props.manifestUrl);
30
- if (!doesUrlExist) {
31
- throw new Error(`Manifest at ${this._props.manifestUrl} could not be found.`);
32
- }
33
- return (await fetch(this._props.manifestUrl)).json();
34
- }
35
- /** Checks if url actually exists */
36
- async _exists(url) {
37
- let exists = false;
38
- try {
39
- const response = await fetch(url, { method: "HEAD" });
40
- if (response.status === 200)
41
- exists = true;
42
- }
43
- catch (error) {
44
- exists = false;
45
- }
46
- return exists;
26
+ const options = { method: "GET" };
27
+ const response = await request(this._props.manifestUrl, options);
28
+ const data = response.body || (() => {
29
+ if (!response.text)
30
+ throw new Error("Manifest file was empty.");
31
+ return JSON.parse(response.text);
32
+ })();
33
+ return data;
47
34
  }
48
35
  }
49
36
  //# sourceMappingURL=RemoteExtensionProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteExtensionProvider.js","sourceRoot":"","sources":["../../../../src/extension/providers/RemoteExtensionProvider.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAanD;;;;;G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OAAO,KAAK,EAAE;YACd,MAAM,GAAG,KAAK,CAAC;SAChB;QACD,OAAO,MAAM,CAAC;IAChB,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\nimport type {\r\n ExtensionManifest,\r\n ExtensionProvider,\r\n} from \"../Extension\";\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 const doesUrlExist = await this._exists(this._props.jsUrl);\r\n if (!doesUrlExist) {\r\n throw new Error(`Extension at ${this._props.jsUrl} could not be found.`);\r\n }\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 const doesUrlExist = await this._exists(this._props.manifestUrl);\r\n if (!doesUrlExist) {\r\n throw new Error(`Manifest at ${this._props.manifestUrl} could not be found.`);\r\n }\r\n return (await fetch(this._props.manifestUrl)).json();\r\n }\r\n\r\n /** Checks if url actually exists */\r\n private async _exists(url: string): Promise<boolean> {\r\n let exists = false;\r\n try {\r\n const response = await fetch(url, { method: \"HEAD\" });\r\n if (response.status === 200)\r\n exists = true;\r\n } catch (error) {\r\n exists = false;\r\n }\r\n return exists;\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,EAAkB,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAanD;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAIlC,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,MAAM,OAAO,GAAmB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE;YAClC,IAAI,CAAC,QAAQ,CAAC,IAAI;gBAChB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,CAAC;IACd,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, RequestOptions } 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 const options: RequestOptions = { method: \"GET\" };\r\n const response = await request(this._props.manifestUrl, options);\r\n const data = response.body || (() => {\r\n if (!response.text)\r\n throw new Error(\"Manifest file was empty.\");\r\n return JSON.parse(response.text);\r\n })();\r\n return data;\r\n }\r\n\r\n}\r\n"]}