@itwin/frontend-tiles 4.10.0-dev.11 → 4.10.0-dev.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log - @itwin/frontend-tiles
2
2
 
3
- This log was last generated on Wed, 25 Sep 2024 20:12:30 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 03 Oct 2024 19:17:08 GMT and should not be manually modified.
4
+
5
+ ## 4.9.3
6
+ Thu, 03 Oct 2024 19:15:45 GMT
7
+
8
+ ### Updates
9
+
10
+ - Improve performance by querying for no more than 5 exports.
11
+
12
+ ## 4.9.2
13
+ Wed, 02 Oct 2024 15:14:43 GMT
14
+
15
+ _Version update only_
4
16
 
5
17
  ## 4.9.1
6
18
  Wed, 25 Sep 2024 20:10:58 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicRepresentationProvider.d.ts","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAS,MAAM,qBAAqB,CAAC;AAIzD;;GAEG;AAEH,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtE;;;GAGG;AAEH,oBAAY,2BAA2B;IACrC,UAAU,gBAAgB;IAC1B,QAAQ,aAAa;IACrB,UAAU,gBAAgB;IAC1B,MAAM,WAAW;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;MAEE;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sGAAsG;IACtG,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;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F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,kCAAkC,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAsCvH"}
1
+ {"version":3,"file":"GraphicRepresentationProvider.d.ts","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AAI1D;;GAEG;AAEH,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtE;;;GAGG;AAEH,oBAAY,2BAA2B;IACrC,UAAU,gBAAgB;IAC1B,QAAQ,aAAa;IACrB,UAAU,gBAAgB;IAC1B,MAAM,WAAW;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;MAEE;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sGAAsG;IACtG,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CAKxB,GAAG,CAAC;IACH,MAAM,EAAE,IAAI,CAAC,2BAA2B,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IAChF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG;IACF,MAAM,EAAE,2BAA2B,CAAC,QAAQ,CAAC;IAC7C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAAC;AAkBH;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,yDAAyD;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oIAAoI;IACpI,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAuB,2BAA2B,CAAC,IAAI,EAAE,+BAA+B,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CA4EtI;AAED;;GAEG;AACH,MAAM,WAAW,kCAAkC;IACjD,wDAAwD;IACxD,WAAW,EAAE,WAAW,CAAC;IACzB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,kCAAkC,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAsCvH"}
@@ -23,7 +23,7 @@ var GraphicRepresentationStatus;
23
23
  /** Creates a URL used to query for Graphic Representations */
24
24
  function createGraphicRepresentationsQueryUrl(args) {
25
25
  const prefix = args.urlPrefix ?? "";
26
- let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc`;
26
+ let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc&$top=5`;
27
27
  if (args.changeId)
28
28
  url = `${url}&changesetId=${args.changeId}`;
29
29
  if (args.enableCDN)
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicRepresentationProvider.js","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAAyD;AACzD,sDAAkD;AAClD,wDAAuE;AAQvE;;;GAGG;AACH,mHAAmH;AACnH,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,yDAA0B,CAAA;IAC1B,oDAAqB,CAAA;IACrB,yDAA0B,CAAA;IAC1B,gDAAiB,CAAA;AACnB,CAAC,EALW,2BAA2B,2CAA3B,2BAA2B,QAKtC;AAyDD,8DAA8D;AAC9D,SAAS,oCAAoC,CAAC,IAA0G;IACtJ,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACpC,IAAI,GAAG,GAAG,WAAW,MAAM,yCAAyC,IAAI,CAAC,QAAQ,qBAAqB,CAAC;IACvG,IAAI,IAAI,CAAC,QAAQ;QACf,GAAG,GAAG,GAAG,GAAG,gBAAgB,IAAI,CAAC,QAAQ,EAAE,CAAC;IAE9C,IAAI,IAAI,CAAC,SAAS;QAChB,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC;IAEvB,MAAM,WAAW,GAAG,yBAAS,CAAC,SAAS,CAAC,6BAA6B,CAAC,QAAQ,EAAE,CAAC;IACjF,GAAG,GAAG,GAAG,GAAG,gBAAgB,WAAW,YAAY,oCAAoB,eAAe,IAAI,CAAC,UAAU,EAAE,CAAC;IAExG,OAAO,GAAG,CAAC;AACb,CAAC;AA0BD;;GAEG;AACI,KAAK,SAAS,CAAC,CAAC,2BAA2B,CAAC,IAAqC;IAgCtF,MAAM,OAAO,GAAG;QACd,mEAAmE;QACnE,aAAa,EAAE,IAAI,CAAC,WAAW;QAC/B,mEAAmE;QACnE,MAAM,EAAE,gDAA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AAS,CAAC,UAAU,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1C,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,2BAA2B,CAAC,SAAS,CAAC,EAAE,CAAC;YAChE,YAAY,GAAG,IAAI,CAAC;YACpB,qBAAM,CAAC,OAAO,CAAC,+BAAc,EAAE,2BAA2B,IAAI,CAAC,UAAU,CAAC,EAAE,gBAAgB,IAAI,CAAC,UAAU,CAAC,QAAQ,+BAA+B,CAAC,CAAC;YACrJ,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,qBAAM,CAAC,OAAO,CAAC,+BAAc,EAAE,qCAAqC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1F,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,GAAG,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,QAAQ,eAAe,CAAC;IAC9C,OAAO,GAAG,CAAC;AACb,CAAC;AAtCD,wEAsCC","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\r\nimport { AccessToken, Logger} from \"@itwin/core-bentley\";\r\nimport { loggerCategory} from \"../LoggerCategory\";\r\nimport { IModelApp, ITWINJS_CORE_VERSION } from \"@itwin/core-frontend\";\r\n\r\n/** The expected format of the Graphic Representation\r\n * @beta\r\n */\r\n/* eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents */\r\nexport type GraphicRepresentationFormat = \"IMDL\" | \"3DTILES\" | string;\r\n\r\n/** Graphic representations are generated from Data Sources.\r\n * The status of a Graphic Representation indicates the progress of that generation process.\r\n * @beta\r\n */\r\n// ###TODO this needs to be expanded to include more statuses, and/or \"failed\" needs to be replaced with \"invalid\".\r\nexport enum GraphicRepresentationStatus {\r\n InProgress = \"In progress\",\r\n Complete = \"Complete\",\r\n NotStarted = \"Not started\",\r\n Failed = \"Failed\",\r\n}\r\n\r\n/**\r\n * Represents a data source for a graphic representation.\r\n * A data source is usually higher-fidelity and contains more information, but may not be as well suited for visualization\r\n * as a graphic representation.\r\n * @beta\r\n */\r\nexport interface DataSource {\r\n /** The iTwinId associated with the DataSource */\r\n iTwinId: string;\r\n /** The unique identifier of a DataSource.\r\n * For example, a DataSource of type \"IMODEL\" has an iModelId which would be attributed to this value.\r\n */\r\n id: string;\r\n /** The unique identifier for a specific version of a DataSource.\r\n * For example, if a specific version of an iModel is desired, the iModel's changesetId would be attributed to this value.\r\n */\r\n changeId?: string;\r\n /** The type of the data source. For example, a DataSource can be of type \"IMODEL\" or \"RealityData\" */\r\n type: string;\r\n}\r\n\r\n/** Represents a visual representation of a data source, for example a 3d tileset.\r\n * A data source can be an iModel, reality data, or other kind of graphical data.\r\n * @see [[queryGraphicRepresentations]] for its construction as a representation of the data produced by a query of data sources.\r\n * @beta\r\n */\r\nexport type GraphicRepresentation = {\r\n /** The display name of the Graphic Representation */\r\n displayName: string;\r\n /** The unique identifier for the Graphic Representation */\r\n representationId: string;\r\n /** The status of the generation of the Graphic Representation from its Data Source.\r\n * @see [[GraphicRepresentationStatus]] for possible values.\r\n */\r\n status: GraphicRepresentationStatus;\r\n /** The expected format of the Graphic Representation\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** The data source that the representation originates from.\r\n * For example, a GraphicRepresentation in the 3D Tiles format might have a dataSource that is a specific iModel changeset.\r\n */\r\n dataSource: DataSource;\r\n /** The url of the graphic representation\r\n * @note The url can only be guaranteed to be valid if the status is complete.\r\n * Therefore, the url is optional if the status is not complete, and required if the status is complete.\r\n */\r\n} & ({\r\n status: Omit<GraphicRepresentationStatus, GraphicRepresentationStatus.Complete>;\r\n url?: string;\r\n} | {\r\n status: GraphicRepresentationStatus.Complete;\r\n url: string;\r\n});\r\n\r\n/** Creates a URL used to query for Graphic Representations */\r\nfunction createGraphicRepresentationsQueryUrl(args: { sourceId: string, sourceType: string, urlPrefix?: string, changeId?: string, enableCDN?: boolean }): string {\r\n const prefix = args.urlPrefix ?? \"\";\r\n let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc`;\r\n if (args.changeId)\r\n url = `${url}&changesetId=${args.changeId}`;\r\n\r\n if (args.enableCDN)\r\n url = `${url}&cdn=1`;\r\n\r\n const tileVersion = IModelApp.tileAdmin.maximumMajorTileFormatVersion.toString();\r\n url = `${url}&tileVersion=${tileVersion}&iTwinJS=${ITWINJS_CORE_VERSION}&exportType=${args.sourceType}`;\r\n\r\n return url;\r\n}\r\n\r\n/** Arguments supplied to [[queryGraphicRepresentations]].\r\n * @beta\r\n */\r\nexport interface QueryGraphicRepresentationsArgs {\r\n /** The token used to access the data source provider. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The Data Source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, exports whose status is not \"Complete\" (indicating the export successfully finished) will be included in the results */\r\n includeIncomplete?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Query Graphic Representations matching the specified criteria, sorted from most-recently- to least-recently-produced.\r\n * @beta\r\n */\r\nexport async function* queryGraphicRepresentations(args: QueryGraphicRepresentationsArgs): AsyncIterableIterator<GraphicRepresentation> {\r\n interface ServiceJsonResponse {\r\n id: string;\r\n displayName: string;\r\n status: GraphicRepresentationStatus;\r\n request: {\r\n iModelId: string;\r\n changesetId: string;\r\n exportType: string;\r\n geometryOptions: any;\r\n viewDefinitionFilter: any;\r\n };\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links?: {\r\n mesh: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n interface ServiceJsonResponses {\r\n exports: ServiceJsonResponse[];\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links: {\r\n next?: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n const headers = {\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Authorization: args.accessToken,\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Accept: \"application/vnd.bentley.itwin-platform.v1+json\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Prefer: \"return=representation\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n SessionId: args.sessionId,\r\n };\r\n\r\n let url: string | undefined = createGraphicRepresentationsQueryUrl({ sourceId: args.dataSource.id, sourceType: args.dataSource.type, urlPrefix: args.urlPrefix, changeId: args.dataSource.changeId, enableCDN: args.enableCDN });\r\n while (url) {\r\n let result;\r\n try {\r\n const response = await fetch(url, { headers });\r\n result = await response.json() as ServiceJsonResponses;\r\n } catch (err) {\r\n Logger.logException(loggerCategory, err);\r\n Logger.logError(loggerCategory, `Failed loading Graphics Data for Source ${args.dataSource.id}`);\r\n break;\r\n }\r\n\r\n const foundSources = result.exports.filter((x) => x.request.exportType === args.dataSource.type && (args.includeIncomplete || x.status === GraphicRepresentationStatus.Complete));\r\n for (const foundSource of foundSources) {\r\n const graphicRepresentation: GraphicRepresentation = {\r\n displayName: foundSource.displayName,\r\n representationId: foundSource.id,\r\n status: foundSource.status,\r\n format: args.format,\r\n url: foundSource._links?.mesh.href,\r\n dataSource: {\r\n iTwinId: args.dataSource.iTwinId,\r\n id: foundSource.request.iModelId,\r\n changeId: foundSource.request.changesetId,\r\n type: foundSource.request.exportType,\r\n },\r\n };\r\n\r\n yield graphicRepresentation;\r\n }\r\n\r\n url = result._links.next?.href;\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[obtainGraphicRepresentationUrl]].\r\n * @beta\r\n */\r\nexport interface ObtainGraphicRepresentationUrlArgs {\r\n /** The token used to access the mesh export service. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The data source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, only data produced for a specific data source version will be considered;\r\n * otherwise, if no data sources are found with the specified version,the most recent data source version will be used.\r\n */\r\n requireExactVersion?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Obtains a URL pointing to a Graphic Representation.\r\n * [[queryGraphicRepresentations]] is used to obtain a list of available representations. By default, the list is sorted from most to least recently-created.\r\n * The first representation matching the source version is selected; or, if no such representation exists, the first representation in the list is selected.\r\n * @returns A URL from which the tileset can be loaded, or `undefined` if no appropriate URL could be obtained.\r\n * @beta\r\n */\r\nexport async function obtainGraphicRepresentationUrl(args: ObtainGraphicRepresentationUrlArgs): Promise<URL | undefined> {\r\n if (!args.dataSource.id) {\r\n Logger.logInfo(loggerCategory, \"Cannot obtain Graphics Data from a source without an Id\");\r\n return undefined;\r\n }\r\n\r\n const queryArgs: QueryGraphicRepresentationsArgs = {\r\n accessToken: args.accessToken,\r\n sessionId: args.sessionId,\r\n dataSource: args.dataSource,\r\n format: args.format,\r\n urlPrefix: args.urlPrefix,\r\n enableCDN: args.enableCDN,\r\n };\r\n\r\n let selectedData;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n break;\r\n }\r\n\r\n if (!selectedData && !args.requireExactVersion) {\r\n queryArgs.dataSource.changeId = undefined;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n Logger.logInfo(loggerCategory, `No data for Data Source ${args.dataSource.id} for version ${args.dataSource.changeId}; falling back to most recent`);\r\n break;\r\n }\r\n }\r\n\r\n if ((!selectedData) || (!selectedData.url)) {\r\n Logger.logInfo(loggerCategory, `No data available for Data Source ${args.dataSource.id}`);\r\n return undefined;\r\n }\r\n\r\n const url = new URL(selectedData.url);\r\n url.pathname = `${url.pathname}/tileset.json`;\r\n return url;\r\n}\r\n"]}
1
+ {"version":3,"file":"GraphicRepresentationProvider.js","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAA0D;AAC1D,sDAAmD;AACnD,wDAAuE;AAQvE;;;GAGG;AACH,mHAAmH;AACnH,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,yDAA0B,CAAA;IAC1B,oDAAqB,CAAA;IACrB,yDAA0B,CAAA;IAC1B,gDAAiB,CAAA;AACnB,CAAC,EALW,2BAA2B,2CAA3B,2BAA2B,QAKtC;AAyDD,8DAA8D;AAC9D,SAAS,oCAAoC,CAAC,IAA0G;IACtJ,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACpC,IAAI,GAAG,GAAG,WAAW,MAAM,yCAAyC,IAAI,CAAC,QAAQ,4BAA4B,CAAC;IAC9G,IAAI,IAAI,CAAC,QAAQ;QACf,GAAG,GAAG,GAAG,GAAG,gBAAgB,IAAI,CAAC,QAAQ,EAAE,CAAC;IAE9C,IAAI,IAAI,CAAC,SAAS;QAChB,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC;IAEvB,MAAM,WAAW,GAAG,yBAAS,CAAC,SAAS,CAAC,6BAA6B,CAAC,QAAQ,EAAE,CAAC;IACjF,G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,IAAI,CAAC,SAAS;QACzB,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC;IAEF,IAAI,YAAY,CAAC;IACjB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,2BAA2B,CAAC,SAAS,CAAC,EAAE,CAAC;QAChE,YAAY,GAAG,IAAI,CAAC;QACpB,MAAM;IACR,CAAC;IAED,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC/C,SAAS,CAAC,UAAU,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1C,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,2BAA2B,CAAC,SAAS,CAAC,EAAE,CAAC;YAChE,YAAY,GAAG,IAAI,CAAC;YACpB,qBAAM,CAAC,OAAO,CAAC,+BAAc,EAAE,2BAA2B,IAAI,CAAC,UAAU,CAAC,EAAE,gBAAgB,IAAI,CAAC,UAAU,CAAC,QAAQ,+BAA+B,CAAC,CAAC;YACrJ,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,qBAAM,CAAC,OAAO,CAAC,+BAAc,EAAE,qCAAqC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1F,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,GAAG,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,QAAQ,eAAe,CAAC;IAC9C,OAAO,GAAG,CAAC;AACb,CAAC;AAtCD,wEAsCC","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\r\nimport { AccessToken, Logger } from \"@itwin/core-bentley\";\r\nimport { loggerCategory } from \"../LoggerCategory\";\r\nimport { IModelApp, ITWINJS_CORE_VERSION } from \"@itwin/core-frontend\";\r\n\r\n/** The expected format of the Graphic Representation\r\n * @beta\r\n */\r\n/* eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents */\r\nexport type GraphicRepresentationFormat = \"IMDL\" | \"3DTILES\" | string;\r\n\r\n/** Graphic representations are generated from Data Sources.\r\n * The status of a Graphic Representation indicates the progress of that generation process.\r\n * @beta\r\n */\r\n// ###TODO this needs to be expanded to include more statuses, and/or \"failed\" needs to be replaced with \"invalid\".\r\nexport enum GraphicRepresentationStatus {\r\n InProgress = \"In progress\",\r\n Complete = \"Complete\",\r\n NotStarted = \"Not started\",\r\n Failed = \"Failed\",\r\n}\r\n\r\n/**\r\n * Represents a data source for a graphic representation.\r\n * A data source is usually higher-fidelity and contains more information, but may not be as well suited for visualization\r\n * as a graphic representation.\r\n * @beta\r\n */\r\nexport interface DataSource {\r\n /** The iTwinId associated with the DataSource */\r\n iTwinId: string;\r\n /** The unique identifier of a DataSource.\r\n * For example, a DataSource of type \"IMODEL\" has an iModelId which would be attributed to this value.\r\n */\r\n id: string;\r\n /** The unique identifier for a specific version of a DataSource.\r\n * For example, if a specific version of an iModel is desired, the iModel's changesetId would be attributed to this value.\r\n */\r\n changeId?: string;\r\n /** The type of the data source. For example, a DataSource can be of type \"IMODEL\" or \"RealityData\" */\r\n type: string;\r\n}\r\n\r\n/** Represents a visual representation of a data source, for example a 3d tileset.\r\n * A data source can be an iModel, reality data, or other kind of graphical data.\r\n * @see [[queryGraphicRepresentations]] for its construction as a representation of the data produced by a query of data sources.\r\n * @beta\r\n */\r\nexport type GraphicRepresentation = {\r\n /** The display name of the Graphic Representation */\r\n displayName: string;\r\n /** The unique identifier for the Graphic Representation */\r\n representationId: string;\r\n /** The status of the generation of the Graphic Representation from its Data Source.\r\n * @see [[GraphicRepresentationStatus]] for possible values.\r\n */\r\n status: GraphicRepresentationStatus;\r\n /** The expected format of the Graphic Representation\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** The data source that the representation originates from.\r\n * For example, a GraphicRepresentation in the 3D Tiles format might have a dataSource that is a specific iModel changeset.\r\n */\r\n dataSource: DataSource;\r\n /** The url of the graphic representation\r\n * @note The url can only be guaranteed to be valid if the status is complete.\r\n * Therefore, the url is optional if the status is not complete, and required if the status is complete.\r\n */\r\n} & ({\r\n status: Omit<GraphicRepresentationStatus, GraphicRepresentationStatus.Complete>;\r\n url?: string;\r\n} | {\r\n status: GraphicRepresentationStatus.Complete;\r\n url: string;\r\n});\r\n\r\n/** Creates a URL used to query for Graphic Representations */\r\nfunction createGraphicRepresentationsQueryUrl(args: { sourceId: string, sourceType: string, urlPrefix?: string, changeId?: string, enableCDN?: boolean }): string {\r\n const prefix = args.urlPrefix ?? \"\";\r\n let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc&$top=5`;\r\n if (args.changeId)\r\n url = `${url}&changesetId=${args.changeId}`;\r\n\r\n if (args.enableCDN)\r\n url = `${url}&cdn=1`;\r\n\r\n const tileVersion = IModelApp.tileAdmin.maximumMajorTileFormatVersion.toString();\r\n url = `${url}&tileVersion=${tileVersion}&iTwinJS=${ITWINJS_CORE_VERSION}&exportType=${args.sourceType}`;\r\n\r\n return url;\r\n}\r\n\r\n/** Arguments supplied to [[queryGraphicRepresentations]].\r\n * @beta\r\n */\r\nexport interface QueryGraphicRepresentationsArgs {\r\n /** The token used to access the data source provider. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The Data Source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, exports whose status is not \"Complete\" (indicating the export successfully finished) will be included in the results */\r\n includeIncomplete?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Query Graphic Representations matching the specified criteria, sorted from most-recently- to least-recently-produced.\r\n * @beta\r\n */\r\nexport async function* queryGraphicRepresentations(args: QueryGraphicRepresentationsArgs): AsyncIterableIterator<GraphicRepresentation> {\r\n interface ServiceJsonResponse {\r\n id: string;\r\n displayName: string;\r\n status: GraphicRepresentationStatus;\r\n request: {\r\n iModelId: string;\r\n changesetId: string;\r\n exportType: string;\r\n geometryOptions: any;\r\n viewDefinitionFilter: any;\r\n };\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links?: {\r\n mesh: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n interface ServiceJsonResponses {\r\n exports: ServiceJsonResponse[];\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links: {\r\n next?: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n const headers = {\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Authorization: args.accessToken,\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Accept: \"application/vnd.bentley.itwin-platform.v1+json\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Prefer: \"return=representation\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n SessionId: args.sessionId,\r\n };\r\n\r\n let url: string | undefined = createGraphicRepresentationsQueryUrl({ sourceId: args.dataSource.id, sourceType: args.dataSource.type, urlPrefix: args.urlPrefix, changeId: args.dataSource.changeId, enableCDN: args.enableCDN });\r\n while (url) {\r\n let result;\r\n try {\r\n const response = await fetch(url, { headers });\r\n result = await response.json() as ServiceJsonResponses;\r\n } catch (err) {\r\n Logger.logException(loggerCategory, err);\r\n Logger.logError(loggerCategory, `Failed loading Graphics Data for Source ${args.dataSource.id}`);\r\n break;\r\n }\r\n\r\n const foundSources = result.exports.filter((x) => x.request.exportType === args.dataSource.type && (args.includeIncomplete || x.status === GraphicRepresentationStatus.Complete));\r\n for (const foundSource of foundSources) {\r\n const graphicRepresentation: GraphicRepresentation = {\r\n displayName: foundSource.displayName,\r\n representationId: foundSource.id,\r\n status: foundSource.status,\r\n format: args.format,\r\n url: foundSource._links?.mesh.href,\r\n dataSource: {\r\n iTwinId: args.dataSource.iTwinId,\r\n id: foundSource.request.iModelId,\r\n changeId: foundSource.request.changesetId,\r\n type: foundSource.request.exportType,\r\n },\r\n };\r\n\r\n yield graphicRepresentation;\r\n }\r\n\r\n url = result._links.next?.href;\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[obtainGraphicRepresentationUrl]].\r\n * @beta\r\n */\r\nexport interface ObtainGraphicRepresentationUrlArgs {\r\n /** The token used to access the mesh export service. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The data source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, only data produced for a specific data source version will be considered;\r\n * otherwise, if no data sources are found with the specified version,the most recent data source version will be used.\r\n */\r\n requireExactVersion?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Obtains a URL pointing to a Graphic Representation.\r\n * [[queryGraphicRepresentations]] is used to obtain a list of available representations. By default, the list is sorted from most to least recently-created.\r\n * The first representation matching the source version is selected; or, if no such representation exists, the first representation in the list is selected.\r\n * @returns A URL from which the tileset can be loaded, or `undefined` if no appropriate URL could be obtained.\r\n * @beta\r\n */\r\nexport async function obtainGraphicRepresentationUrl(args: ObtainGraphicRepresentationUrlArgs): Promise<URL | undefined> {\r\n if (!args.dataSource.id) {\r\n Logger.logInfo(loggerCategory, \"Cannot obtain Graphics Data from a source without an Id\");\r\n return undefined;\r\n }\r\n\r\n const queryArgs: QueryGraphicRepresentationsArgs = {\r\n accessToken: args.accessToken,\r\n sessionId: args.sessionId,\r\n dataSource: args.dataSource,\r\n format: args.format,\r\n urlPrefix: args.urlPrefix,\r\n enableCDN: args.enableCDN,\r\n };\r\n\r\n let selectedData;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n break;\r\n }\r\n\r\n if (!selectedData && !args.requireExactVersion) {\r\n queryArgs.dataSource.changeId = undefined;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n Logger.logInfo(loggerCategory, `No data for Data Source ${args.dataSource.id} for version ${args.dataSource.changeId}; falling back to most recent`);\r\n break;\r\n }\r\n }\r\n\r\n if ((!selectedData) || (!selectedData.url)) {\r\n Logger.logInfo(loggerCategory, `No data available for Data Source ${args.dataSource.id}`);\r\n return undefined;\r\n }\r\n\r\n const url = new URL(selectedData.url);\r\n url.pathname = `${url.pathname}/tileset.json`;\r\n return url;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicRepresentationProvider.d.ts","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAS,MAAM,qBAAqB,CAAC;AAIzD;;GAEG;AAEH,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtE;;;GAGG;AAEH,oBAAY,2BAA2B;IACrC,UAAU,gBAAgB;IAC1B,QAAQ,aAAa;IACrB,UAAU,gBAAgB;IAC1B,MAAM,WAAW;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;MAEE;IACF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CAAC;IACvB;;OAEG;IACH,MAAM,EAAG,2BAA2B,CAAC;IACrC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,kCAAkC,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAsCvH"}
1
+ {"version":3,"file":"GraphicRepresentationProvider.d.ts","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AAI1D;;GAEG;AAEH,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtE;;;GAGG;AAEH,oBAAY,2BAA2B;IACrC,UAAU,gBAAgB;IAC1B,QAAQ,aAAa;IACrB,UAAU,gBAAgB;IAC1B,MAAM,WAAW;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;MAEE;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sGAAsG;IACtG,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CAKxB,GAAG,CAAC;IACH,MAAM,EAAE,IAAI,CAAC,2BAA2B,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IAChF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG;IACF,MAAM,EAAE,2BAA2B,CAAC,QAAQ,CAAC;IAC7C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAAC;AAkBH;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,yDAAyD;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oIAAoI;IACpI,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAuB,2BAA2B,CAAC,IAAI,EAAE,+BAA+B,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CA4EtI;AAED;;GAEG;AACH,MAAM,WAAW,kCAAkC;IACjD,wDAAwD;IACxD,WAAW,EAAE,WAAW,CAAC;IACzB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,2BAA2B,CAAC;IACpC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,kCAAkC,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAsCvH"}
@@ -20,7 +20,7 @@ export var GraphicRepresentationStatus;
20
20
  /** Creates a URL used to query for Graphic Representations */
21
21
  function createGraphicRepresentationsQueryUrl(args) {
22
22
  const prefix = args.urlPrefix ?? "";
23
- let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc`;
23
+ let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc&$top=5`;
24
24
  if (args.changeId)
25
25
  url = `${url}&changesetId=${args.changeId}`;
26
26
  if (args.enableCDN)
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicRepresentationProvider.js","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAe,MAAM,EAAC,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQvE;;;GAGG;AACH,mHAAmH;AACnH,MAAM,CAAN,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,yDAA0B,CAAA;IAC1B,oDAAqB,CAAA;IACrB,yDAA0B,CAAA;IAC1B,gDAAiB,CAAA;AACnB,CAAC,EALW,2BAA2B,KAA3B,2BAA2B,QAKtC;AAyDD,8DAA8D;AAC9D,SAAS,oCAAoC,CAAC,IAA0G;IACtJ,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACpC,IAAI,GAAG,GAAG,WAAW,MAAM,yCAAyC,IAAI,CAAC,QAAQ,qBAAqB,CAAC;IACvG,IAAI,IAAI,CAAC,QAAQ;QACf,GAAG,GAAG,GAAG,GAAG,gBAAgB,IAAI,CAAC,QAAQ,EAAE,CAAC;IAE9C,IAAI,IAAI,CAAC,SAAS;QAChB,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC;IAEvB,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,6BAA6B,CAAC,QAAQ,EAAE,CAAC;IACjF,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AE,IAAI,CAAC,SAAS;QACzB,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC;IAEF,IAAI,YAAY,CAAC;IACjB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,2BAA2B,CAAC,SAAS,CAAC,EAAE,CAAC;QAChE,YAAY,GAAG,IAAI,CAAC;QACpB,MAAM;IACR,CAAC;IAED,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC/C,SAAS,CAAC,UAAU,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1C,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,2BAA2B,CAAC,SAAS,CAAC,EAAE,CAAC;YAChE,YAAY,GAAG,IAAI,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,2BAA2B,IAAI,CAAC,UAAU,CAAC,EAAE,gBAAgB,IAAI,CAAC,UAAU,CAAC,QAAQ,+BAA+B,CAAC,CAAC;YACrJ,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,qCAAqC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1F,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,GAAG,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,QAAQ,eAAe,CAAC;IAC9C,OAAO,GAAG,CAAC;AACb,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\n\r\nimport { AccessToken, Logger} from \"@itwin/core-bentley\";\r\nimport { loggerCategory} from \"../LoggerCategory\";\r\nimport { IModelApp, ITWINJS_CORE_VERSION } from \"@itwin/core-frontend\";\r\n\r\n/** The expected format of the Graphic Representation\r\n * @beta\r\n */\r\n/* eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents */\r\nexport type GraphicRepresentationFormat = \"IMDL\" | \"3DTILES\" | string;\r\n\r\n/** Graphic representations are generated from Data Sources.\r\n * The status of a Graphic Representation indicates the progress of that generation process.\r\n * @beta\r\n */\r\n// ###TODO this needs to be expanded to include more statuses, and/or \"failed\" needs to be replaced with \"invalid\".\r\nexport enum GraphicRepresentationStatus {\r\n InProgress = \"In progress\",\r\n Complete = \"Complete\",\r\n NotStarted = \"Not started\",\r\n Failed = \"Failed\",\r\n}\r\n\r\n/**\r\n * Represents a data source for a graphic representation.\r\n * A data source is usually higher-fidelity and contains more information, but may not be as well suited for visualization\r\n * as a graphic representation.\r\n * @beta\r\n */\r\nexport interface DataSource {\r\n /** The iTwinId associated with the DataSource */\r\n iTwinId: string;\r\n /** The unique identifier of a DataSource.\r\n * For example, a DataSource of type \"IMODEL\" has an iModelId which would be attributed to this value.\r\n */\r\n id: string;\r\n /** The unique identifier for a specific version of a DataSource.\r\n * For example, if a specific version of an iModel is desired, the iModel's changesetId would be attributed to this value.\r\n */\r\n changeId?: string;\r\n /** The type of the data source. For example, a DataSource can be of type \"IMODEL\" or \"RealityData\" */\r\n type: string;\r\n}\r\n\r\n/** Represents a visual representation of a data source, for example a 3d tileset.\r\n * A data source can be an iModel, reality data, or other kind of graphical data.\r\n * @see [[queryGraphicRepresentations]] for its construction as a representation of the data produced by a query of data sources.\r\n * @beta\r\n */\r\nexport type GraphicRepresentation = {\r\n /** The display name of the Graphic Representation */\r\n displayName: string;\r\n /** The unique identifier for the Graphic Representation */\r\n representationId: string;\r\n /** The status of the generation of the Graphic Representation from its Data Source.\r\n * @see [[GraphicRepresentationStatus]] for possible values.\r\n */\r\n status: GraphicRepresentationStatus;\r\n /** The expected format of the Graphic Representation\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** The data source that the representation originates from.\r\n * For example, a GraphicRepresentation in the 3D Tiles format might have a dataSource that is a specific iModel changeset.\r\n */\r\n dataSource: DataSource;\r\n /** The url of the graphic representation\r\n * @note The url can only be guaranteed to be valid if the status is complete.\r\n * Therefore, the url is optional if the status is not complete, and required if the status is complete.\r\n */\r\n} & ({\r\n status: Omit<GraphicRepresentationStatus, GraphicRepresentationStatus.Complete>;\r\n url?: string;\r\n} | {\r\n status: GraphicRepresentationStatus.Complete;\r\n url: string;\r\n});\r\n\r\n/** Creates a URL used to query for Graphic Representations */\r\nfunction createGraphicRepresentationsQueryUrl(args: { sourceId: string, sourceType: string, urlPrefix?: string, changeId?: string, enableCDN?: boolean }): string {\r\n const prefix = args.urlPrefix ?? \"\";\r\n let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc`;\r\n if (args.changeId)\r\n url = `${url}&changesetId=${args.changeId}`;\r\n\r\n if (args.enableCDN)\r\n url = `${url}&cdn=1`;\r\n\r\n const tileVersion = IModelApp.tileAdmin.maximumMajorTileFormatVersion.toString();\r\n url = `${url}&tileVersion=${tileVersion}&iTwinJS=${ITWINJS_CORE_VERSION}&exportType=${args.sourceType}`;\r\n\r\n return url;\r\n}\r\n\r\n/** Arguments supplied to [[queryGraphicRepresentations]].\r\n * @beta\r\n */\r\nexport interface QueryGraphicRepresentationsArgs {\r\n /** The token used to access the data source provider. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The Data Source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, exports whose status is not \"Complete\" (indicating the export successfully finished) will be included in the results */\r\n includeIncomplete?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Query Graphic Representations matching the specified criteria, sorted from most-recently- to least-recently-produced.\r\n * @beta\r\n */\r\nexport async function* queryGraphicRepresentations(args: QueryGraphicRepresentationsArgs): AsyncIterableIterator<GraphicRepresentation> {\r\n interface ServiceJsonResponse {\r\n id: string;\r\n displayName: string;\r\n status: GraphicRepresentationStatus;\r\n request: {\r\n iModelId: string;\r\n changesetId: string;\r\n exportType: string;\r\n geometryOptions: any;\r\n viewDefinitionFilter: any;\r\n };\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links?: {\r\n mesh: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n interface ServiceJsonResponses {\r\n exports: ServiceJsonResponse[];\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links: {\r\n next?: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n const headers = {\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Authorization: args.accessToken,\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Accept: \"application/vnd.bentley.itwin-platform.v1+json\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Prefer: \"return=representation\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n SessionId: args.sessionId,\r\n };\r\n\r\n let url: string | undefined = createGraphicRepresentationsQueryUrl({ sourceId: args.dataSource.id, sourceType: args.dataSource.type, urlPrefix: args.urlPrefix, changeId: args.dataSource.changeId, enableCDN: args.enableCDN });\r\n while (url) {\r\n let result;\r\n try {\r\n const response = await fetch(url, { headers });\r\n result = await response.json() as ServiceJsonResponses;\r\n } catch (err) {\r\n Logger.logException(loggerCategory, err);\r\n Logger.logError(loggerCategory, `Failed loading Graphics Data for Source ${args.dataSource.id}`);\r\n break;\r\n }\r\n\r\n const foundSources = result.exports.filter((x) => x.request.exportType === args.dataSource.type && (args.includeIncomplete || x.status === GraphicRepresentationStatus.Complete));\r\n for (const foundSource of foundSources) {\r\n const graphicRepresentation: GraphicRepresentation = {\r\n displayName: foundSource.displayName,\r\n representationId: foundSource.id,\r\n status: foundSource.status,\r\n format: args.format,\r\n url: foundSource._links?.mesh.href,\r\n dataSource: {\r\n iTwinId: args.dataSource.iTwinId,\r\n id: foundSource.request.iModelId,\r\n changeId: foundSource.request.changesetId,\r\n type: foundSource.request.exportType,\r\n },\r\n };\r\n\r\n yield graphicRepresentation;\r\n }\r\n\r\n url = result._links.next?.href;\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[obtainGraphicRepresentationUrl]].\r\n * @beta\r\n */\r\nexport interface ObtainGraphicRepresentationUrlArgs {\r\n /** The token used to access the mesh export service. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The data source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, only data produced for a specific data source version will be considered;\r\n * otherwise, if no data sources are found with the specified version,the most recent data source version will be used.\r\n */\r\n requireExactVersion?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Obtains a URL pointing to a Graphic Representation.\r\n * [[queryGraphicRepresentations]] is used to obtain a list of available representations. By default, the list is sorted from most to least recently-created.\r\n * The first representation matching the source version is selected; or, if no such representation exists, the first representation in the list is selected.\r\n * @returns A URL from which the tileset can be loaded, or `undefined` if no appropriate URL could be obtained.\r\n * @beta\r\n */\r\nexport async function obtainGraphicRepresentationUrl(args: ObtainGraphicRepresentationUrlArgs): Promise<URL | undefined> {\r\n if (!args.dataSource.id) {\r\n Logger.logInfo(loggerCategory, \"Cannot obtain Graphics Data from a source without an Id\");\r\n return undefined;\r\n }\r\n\r\n const queryArgs: QueryGraphicRepresentationsArgs = {\r\n accessToken: args.accessToken,\r\n sessionId: args.sessionId,\r\n dataSource: args.dataSource,\r\n format: args.format,\r\n urlPrefix: args.urlPrefix,\r\n enableCDN: args.enableCDN,\r\n };\r\n\r\n let selectedData;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n break;\r\n }\r\n\r\n if (!selectedData && !args.requireExactVersion) {\r\n queryArgs.dataSource.changeId = undefined;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n Logger.logInfo(loggerCategory, `No data for Data Source ${args.dataSource.id} for version ${args.dataSource.changeId}; falling back to most recent`);\r\n break;\r\n }\r\n }\r\n\r\n if ((!selectedData) || (!selectedData.url)) {\r\n Logger.logInfo(loggerCategory, `No data available for Data Source ${args.dataSource.id}`);\r\n return undefined;\r\n }\r\n\r\n const url = new URL(selectedData.url);\r\n url.pathname = `${url.pathname}/tileset.json`;\r\n return url;\r\n}\r\n"]}
1
+ {"version":3,"file":"GraphicRepresentationProvider.js","sourceRoot":"","sources":["../../../src/GraphicsProvider/GraphicRepresentationProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAe,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQvE;;;GAGG;AACH,mHAAmH;AACnH,MAAM,CAAN,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,yDAA0B,CAAA;IAC1B,oDAAqB,CAAA;IACrB,yDAA0B,CAAA;IAC1B,gDAAiB,CAAA;AACnB,CAAC,EALW,2BAA2B,KAA3B,2BAA2B,QAKtC;AAyDD,8DAA8D;AAC9D,SAAS,oCAAoC,CAAC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AC,CAAC;QAC1F,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,GAAG,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,QAAQ,eAAe,CAAC;IAC9C,OAAO,GAAG,CAAC;AACb,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\n\r\nimport { AccessToken, Logger } from \"@itwin/core-bentley\";\r\nimport { loggerCategory } from \"../LoggerCategory\";\r\nimport { IModelApp, ITWINJS_CORE_VERSION } from \"@itwin/core-frontend\";\r\n\r\n/** The expected format of the Graphic Representation\r\n * @beta\r\n */\r\n/* eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents */\r\nexport type GraphicRepresentationFormat = \"IMDL\" | \"3DTILES\" | string;\r\n\r\n/** Graphic representations are generated from Data Sources.\r\n * The status of a Graphic Representation indicates the progress of that generation process.\r\n * @beta\r\n */\r\n// ###TODO this needs to be expanded to include more statuses, and/or \"failed\" needs to be replaced with \"invalid\".\r\nexport enum GraphicRepresentationStatus {\r\n InProgress = \"In progress\",\r\n Complete = \"Complete\",\r\n NotStarted = \"Not started\",\r\n Failed = \"Failed\",\r\n}\r\n\r\n/**\r\n * Represents a data source for a graphic representation.\r\n * A data source is usually higher-fidelity and contains more information, but may not be as well suited for visualization\r\n * as a graphic representation.\r\n * @beta\r\n */\r\nexport interface DataSource {\r\n /** The iTwinId associated with the DataSource */\r\n iTwinId: string;\r\n /** The unique identifier of a DataSource.\r\n * For example, a DataSource of type \"IMODEL\" has an iModelId which would be attributed to this value.\r\n */\r\n id: string;\r\n /** The unique identifier for a specific version of a DataSource.\r\n * For example, if a specific version of an iModel is desired, the iModel's changesetId would be attributed to this value.\r\n */\r\n changeId?: string;\r\n /** The type of the data source. For example, a DataSource can be of type \"IMODEL\" or \"RealityData\" */\r\n type: string;\r\n}\r\n\r\n/** Represents a visual representation of a data source, for example a 3d tileset.\r\n * A data source can be an iModel, reality data, or other kind of graphical data.\r\n * @see [[queryGraphicRepresentations]] for its construction as a representation of the data produced by a query of data sources.\r\n * @beta\r\n */\r\nexport type GraphicRepresentation = {\r\n /** The display name of the Graphic Representation */\r\n displayName: string;\r\n /** The unique identifier for the Graphic Representation */\r\n representationId: string;\r\n /** The status of the generation of the Graphic Representation from its Data Source.\r\n * @see [[GraphicRepresentationStatus]] for possible values.\r\n */\r\n status: GraphicRepresentationStatus;\r\n /** The expected format of the Graphic Representation\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** The data source that the representation originates from.\r\n * For example, a GraphicRepresentation in the 3D Tiles format might have a dataSource that is a specific iModel changeset.\r\n */\r\n dataSource: DataSource;\r\n /** The url of the graphic representation\r\n * @note The url can only be guaranteed to be valid if the status is complete.\r\n * Therefore, the url is optional if the status is not complete, and required if the status is complete.\r\n */\r\n} & ({\r\n status: Omit<GraphicRepresentationStatus, GraphicRepresentationStatus.Complete>;\r\n url?: string;\r\n} | {\r\n status: GraphicRepresentationStatus.Complete;\r\n url: string;\r\n});\r\n\r\n/** Creates a URL used to query for Graphic Representations */\r\nfunction createGraphicRepresentationsQueryUrl(args: { sourceId: string, sourceType: string, urlPrefix?: string, changeId?: string, enableCDN?: boolean }): string {\r\n const prefix = args.urlPrefix ?? \"\";\r\n let url = `https://${prefix}api.bentley.com/mesh-export/?iModelId=${args.sourceId}&$orderBy=date:desc&$top=5`;\r\n if (args.changeId)\r\n url = `${url}&changesetId=${args.changeId}`;\r\n\r\n if (args.enableCDN)\r\n url = `${url}&cdn=1`;\r\n\r\n const tileVersion = IModelApp.tileAdmin.maximumMajorTileFormatVersion.toString();\r\n url = `${url}&tileVersion=${tileVersion}&iTwinJS=${ITWINJS_CORE_VERSION}&exportType=${args.sourceType}`;\r\n\r\n return url;\r\n}\r\n\r\n/** Arguments supplied to [[queryGraphicRepresentations]].\r\n * @beta\r\n */\r\nexport interface QueryGraphicRepresentationsArgs {\r\n /** The token used to access the data source provider. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The Data Source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, exports whose status is not \"Complete\" (indicating the export successfully finished) will be included in the results */\r\n includeIncomplete?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Query Graphic Representations matching the specified criteria, sorted from most-recently- to least-recently-produced.\r\n * @beta\r\n */\r\nexport async function* queryGraphicRepresentations(args: QueryGraphicRepresentationsArgs): AsyncIterableIterator<GraphicRepresentation> {\r\n interface ServiceJsonResponse {\r\n id: string;\r\n displayName: string;\r\n status: GraphicRepresentationStatus;\r\n request: {\r\n iModelId: string;\r\n changesetId: string;\r\n exportType: string;\r\n geometryOptions: any;\r\n viewDefinitionFilter: any;\r\n };\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links?: {\r\n mesh: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n interface ServiceJsonResponses {\r\n exports: ServiceJsonResponse[];\r\n\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n _links: {\r\n next?: {\r\n href: string;\r\n };\r\n };\r\n }\r\n\r\n const headers = {\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Authorization: args.accessToken,\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Accept: \"application/vnd.bentley.itwin-platform.v1+json\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n Prefer: \"return=representation\",\r\n /* eslint-disable-next-line @typescript-eslint/naming-convention */\r\n SessionId: args.sessionId,\r\n };\r\n\r\n let url: string | undefined = createGraphicRepresentationsQueryUrl({ sourceId: args.dataSource.id, sourceType: args.dataSource.type, urlPrefix: args.urlPrefix, changeId: args.dataSource.changeId, enableCDN: args.enableCDN });\r\n while (url) {\r\n let result;\r\n try {\r\n const response = await fetch(url, { headers });\r\n result = await response.json() as ServiceJsonResponses;\r\n } catch (err) {\r\n Logger.logException(loggerCategory, err);\r\n Logger.logError(loggerCategory, `Failed loading Graphics Data for Source ${args.dataSource.id}`);\r\n break;\r\n }\r\n\r\n const foundSources = result.exports.filter((x) => x.request.exportType === args.dataSource.type && (args.includeIncomplete || x.status === GraphicRepresentationStatus.Complete));\r\n for (const foundSource of foundSources) {\r\n const graphicRepresentation: GraphicRepresentation = {\r\n displayName: foundSource.displayName,\r\n representationId: foundSource.id,\r\n status: foundSource.status,\r\n format: args.format,\r\n url: foundSource._links?.mesh.href,\r\n dataSource: {\r\n iTwinId: args.dataSource.iTwinId,\r\n id: foundSource.request.iModelId,\r\n changeId: foundSource.request.changesetId,\r\n type: foundSource.request.exportType,\r\n },\r\n };\r\n\r\n yield graphicRepresentation;\r\n }\r\n\r\n url = result._links.next?.href;\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[obtainGraphicRepresentationUrl]].\r\n * @beta\r\n */\r\nexport interface ObtainGraphicRepresentationUrlArgs {\r\n /** The token used to access the mesh export service. */\r\n accessToken: AccessToken;\r\n /** The unique identifier for the session in which this data source was queried.\r\n * A possible value is IModelApp.sessionId.\r\n */\r\n sessionId: string;\r\n /** The data source for which to query the graphic representations */\r\n dataSource: DataSource;\r\n /** The expected format of the graphic representations\r\n * @see [[GraphicRepresentationFormat]] for possible values.\r\n */\r\n format: GraphicRepresentationFormat;\r\n /** Chiefly used in testing environments. */\r\n urlPrefix?: string;\r\n /** If true, only data produced for a specific data source version will be considered;\r\n * otherwise, if no data sources are found with the specified version,the most recent data source version will be used.\r\n */\r\n requireExactVersion?: boolean;\r\n /** If true, enables a CDN (content delivery network) to access tiles faster. */\r\n enableCDN?: boolean;\r\n}\r\n\r\n/** Obtains a URL pointing to a Graphic Representation.\r\n * [[queryGraphicRepresentations]] is used to obtain a list of available representations. By default, the list is sorted from most to least recently-created.\r\n * The first representation matching the source version is selected; or, if no such representation exists, the first representation in the list is selected.\r\n * @returns A URL from which the tileset can be loaded, or `undefined` if no appropriate URL could be obtained.\r\n * @beta\r\n */\r\nexport async function obtainGraphicRepresentationUrl(args: ObtainGraphicRepresentationUrlArgs): Promise<URL | undefined> {\r\n if (!args.dataSource.id) {\r\n Logger.logInfo(loggerCategory, \"Cannot obtain Graphics Data from a source without an Id\");\r\n return undefined;\r\n }\r\n\r\n const queryArgs: QueryGraphicRepresentationsArgs = {\r\n accessToken: args.accessToken,\r\n sessionId: args.sessionId,\r\n dataSource: args.dataSource,\r\n format: args.format,\r\n urlPrefix: args.urlPrefix,\r\n enableCDN: args.enableCDN,\r\n };\r\n\r\n let selectedData;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n break;\r\n }\r\n\r\n if (!selectedData && !args.requireExactVersion) {\r\n queryArgs.dataSource.changeId = undefined;\r\n for await (const data of queryGraphicRepresentations(queryArgs)) {\r\n selectedData = data;\r\n Logger.logInfo(loggerCategory, `No data for Data Source ${args.dataSource.id} for version ${args.dataSource.changeId}; falling back to most recent`);\r\n break;\r\n }\r\n }\r\n\r\n if ((!selectedData) || (!selectedData.url)) {\r\n Logger.logInfo(loggerCategory, `No data available for Data Source ${args.dataSource.id}`);\r\n return undefined;\r\n }\r\n\r\n const url = new URL(selectedData.url);\r\n url.pathname = `${url.pathname}/tileset.json`;\r\n return url;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/frontend-tiles",
3
- "version": "4.10.0-dev.11",
3
+ "version": "4.10.0-dev.14",
4
4
  "description": "Experimental alternative technique for visualizing the contents of iModels",
5
5
  "main": "lib/cjs/frontend-tiles.js",
6
6
  "module": "lib/esm/frontend-tiles.js",
@@ -21,10 +21,10 @@
21
21
  "url": "http://www.bentley.com"
22
22
  },
23
23
  "peerDependencies": {
24
- "@itwin/core-frontend": "4.10.0-dev.11",
25
- "@itwin/core-bentley": "4.10.0-dev.11",
26
- "@itwin/core-geometry": "4.10.0-dev.11",
27
- "@itwin/core-common": "4.10.0-dev.11"
24
+ "@itwin/core-common": "4.10.0-dev.14",
25
+ "@itwin/core-geometry": "4.10.0-dev.14",
26
+ "@itwin/core-bentley": "4.10.0-dev.14",
27
+ "@itwin/core-frontend": "4.10.0-dev.14"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@itwin/eslint-plugin": "^4.0.2",
@@ -45,12 +45,12 @@
45
45
  "source-map-loader": "^4.0.0",
46
46
  "typescript": "~5.3.3",
47
47
  "webpack": "^5.76.0",
48
- "@itwin/core-bentley": "4.10.0-dev.11",
49
- "@itwin/build-tools": "4.10.0-dev.11",
50
- "@itwin/certa": "4.10.0-dev.11",
51
- "@itwin/core-common": "4.10.0-dev.11",
52
- "@itwin/core-geometry": "4.10.0-dev.11",
53
- "@itwin/core-frontend": "4.10.0-dev.11"
48
+ "@itwin/build-tools": "4.10.0-dev.14",
49
+ "@itwin/core-bentley": "4.10.0-dev.14",
50
+ "@itwin/certa": "4.10.0-dev.14",
51
+ "@itwin/core-common": "4.10.0-dev.14",
52
+ "@itwin/core-frontend": "4.10.0-dev.14",
53
+ "@itwin/core-geometry": "4.10.0-dev.14"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "npm run -s build:cjs && npm run -s build:esm",