@itwin/presentation-testing 3.4.0-dev.10 → 3.4.0-dev.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { IModelHostOptions } from "@itwin/core-backend";
1
2
  import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
2
3
  import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from "@itwin/presentation-backend";
3
4
  import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
@@ -6,13 +7,15 @@ export { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps }
6
7
  export interface PresentationTestingInitProps {
7
8
  /** Properties for backend initialization */
8
9
  backendProps?: PresentationBackendProps;
10
+ /** Properties for `IModelHost` */
11
+ backendHostProps?: IModelHostOptions;
9
12
  /** Properties for frontend initialization */
10
13
  frontendProps?: PresentationFrontendProps;
11
14
  /** IModelApp implementation */
12
15
  frontendApp?: {
13
16
  startup: (opts?: IModelAppOptions) => Promise<void>;
14
17
  };
15
- /** IModelApp options */
18
+ /** `IModelApp` options */
16
19
  frontendAppOptions?: IModelAppOptions;
17
20
  }
18
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAErL,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAuBpI,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAEjF,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C,4CAA4C;IAC5C,YAAY,CAAC,EAAE,wBAAwB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GAOG;AACH,eAAO,MAAM,UAAU,qEA8BtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDAuBrB,CAAC"}
@@ -27,9 +27,10 @@ exports.terminate = exports.initialize = exports.PresentationManagerMode = expor
27
27
  /** @packageDocumentation
28
28
  * @module Helpers
29
29
  */
30
+ const path_1 = require("path");
30
31
  const rimraf = __importStar(require("rimraf"));
31
- const core_bentley_1 = require("@itwin/core-bentley");
32
32
  const core_backend_1 = require("@itwin/core-backend");
33
+ const core_bentley_1 = require("@itwin/core-bentley");
33
34
  const core_common_1 = require("@itwin/core-common");
34
35
  const core_frontend_1 = require("@itwin/core-frontend");
35
36
  const presentation_backend_1 = require("@itwin/presentation-backend");
@@ -37,7 +38,6 @@ Object.defineProperty(exports, "HierarchyCacheMode", { enumerable: true, get: fu
37
38
  Object.defineProperty(exports, "PresentationManagerMode", { enumerable: true, get: function () { return presentation_backend_1.PresentationManagerMode; } });
38
39
  const presentation_common_1 = require("@itwin/presentation-common");
39
40
  const presentation_frontend_1 = require("@itwin/presentation-frontend");
40
- const path_1 = require("path");
41
41
  function initializeRpcInterfaces(interfaces) {
42
42
  const config = class extends core_common_1.RpcDefaultConfiguration {
43
43
  constructor() {
@@ -78,7 +78,7 @@ const initialize = async (props) => {
78
78
  props.backendProps = (_a = props.backendProps) !== null && _a !== void 0 ? _a : {};
79
79
  if (!props.backendProps.id)
80
80
  props.backendProps.id = `test-${core_bentley_1.Guid.createValue()}`;
81
- await core_backend_1.IModelHost.startup({ cacheDir: (0, path_1.join)(__dirname, ".cache") });
81
+ await core_backend_1.IModelHost.startup({ cacheDir: (0, path_1.join)(__dirname, ".cache"), ...props.backendHostProps });
82
82
  presentation_backend_1.Presentation.initialize(props.backendProps);
83
83
  // init frontend
84
84
  if (!props.frontendApp)
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;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AG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,0CAAE,SAAS,CAAC;IAEtE,oBAAoB;IACpB,mCAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,yBAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB;QAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEzC,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB","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 Helpers\r\n */\r\nimport * as rimraf from \"rimraf\";\r\nimport { Guid } from \"@itwin/core-bentley\";\r\nimport { IModelHost } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\r\nimport { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from \"@itwin/presentation-backend\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\r\nimport { join } from \"path\";\r\n\r\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\r\n const config = class extends RpcDefaultConfiguration {\r\n public override interfaces: any = () => interfaces;\r\n };\r\n\r\n for (const definition of interfaces)\r\n RpcConfiguration.assign(definition, () => config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n try {\r\n RpcConfiguration.initializeInterfaces(instance);\r\n } catch {\r\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\r\n // multiple different tests want to set up rpc interfaces\r\n }\r\n}\r\n\r\nlet isInitialized = false;\r\n\r\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\r\n\r\n/** @public */\r\nexport interface PresentationTestingInitProps {\r\n /** Properties for backend initialization */\r\n backendProps?: PresentationBackendProps;\r\n /** Properties for frontend initialization */\r\n frontendProps?: PresentationFrontendProps;\r\n /** IModelApp implementation */\r\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\r\n /** IModelApp options */\r\n frontendAppOptions?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * Initialize the framework for presentation testing. The function sets up backend,\r\n * frontend and RPC communication between them.\r\n *\r\n * @see `terminate`\r\n *\r\n * @public\r\n */\r\nexport const initialize = async (props?: PresentationTestingInitProps) => {\r\n if (isInitialized)\r\n return;\r\n\r\n if (!props)\r\n props = {};\r\n\r\n // set up rpc interfaces\r\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\r\n\r\n // init backend\r\n // make sure backend gets assigned an id which puts its resources into a unique directory\r\n props.backendProps = props.backendProps ?? {};\r\n if (!props.backendProps.id)\r\n props.backendProps.id = `test-${Guid.createValue()}`;\r\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\") });\r\n PresentationBackend.initialize(props.backendProps);\r\n\r\n // init frontend\r\n if (!props.frontendApp)\r\n props.frontendApp = NoRenderApp;\r\n await props.frontendApp.startup(props.frontendAppOptions);\r\n const defaultFrontendProps: PresentationFrontendProps = {\r\n presentation: {\r\n activeLocale: IModelApp.localization.getLanguageList()[0],\r\n },\r\n };\r\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\r\n\r\n isInitialized = true;\r\n};\r\n\r\n/**\r\n * Undoes the setup made by `initialize`.\r\n * @param frontendApp IModelApp implementation\r\n *\r\n * @see `initialize`\r\n *\r\n * @public\r\n */\r\nexport const terminate = async (frontendApp = IModelApp) => {\r\n if (!isInitialized)\r\n return;\r\n\r\n // store directory that needs to be cleaned-up\r\n let hierarchiesCacheDirectory: string | undefined;\r\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\r\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\r\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\r\n\r\n // terminate backend\r\n PresentationBackend.terminate();\r\n await IModelHost.shutdown();\r\n if (hierarchiesCacheDirectory)\r\n rimraf.sync(hierarchiesCacheDirectory);\r\n\r\n // terminate frontend\r\n PresentationFrontend.terminate();\r\n await frontendApp.shutdown();\r\n\r\n isInitialized = false;\r\n};\r\n"]}
1
+ {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,+BAA4B;AAC5B,+CAAiC;AACjC,sDAAoE;AACpE,sDAA2C;AAC3C,oDAE4B;AAC5B,wDAAgF;AAChF,sEAEqC;AAwB5B,mGAzBP,yCAAkB,OAyBO;AAAE,wGAzBoF,8CAAuB,OAyBpF;AAvBpD,oEAAsE;AACtE,wEAAoI;AAEpI,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,qCAAuB;QAArC;;YACG,eAAU,GAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;QACrD,CAAC;KAAA,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,UAAU;QACjC,8BAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC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AC,CAAC;SAC1D;KACF,CAAC;IACF,MAAM,oCAAoB,CAAC,UAAU,CAAC,EAAE,GAAG,oBAAoB,EAAE,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;IAE3F,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC,CAAC;AA9BW,QAAA,UAAU,cA8BrB;AAEF;;;;;;;GAOG;AACI,MAAM,SAAS,GAAG,KAAK,EAAE,WAAW,GAAG,yBAAS,EAAE,EAAE;;IACzD,IAAI,CAAC,aAAa;QAChB,OAAO;IAET,8CAA8C;IAC9C,IAAI,yBAA6C,CAAC;IAClD,MAAM,sBAAsB,GAAG,MAAA,MAAA,mCAAmB,CAAC,SAAS,0CAAE,OAAO,0CAAE,WAAW,CAAC;IACnF,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,yCAAkB,CAAC,IAAI;QAC1D,yBAAyB,GAAG,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,SAAS,CAAC;SAC3D,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,yCAAkB,CAAC,MAAM;QACjE,yBAAyB,GAAG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,0CAAE,SAAS,CAAC;IAEtE,oBAAoB;IACpB,mCAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,yBAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB;QAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEzC,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB","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 Helpers\r\n */\r\nimport { join } from \"path\";\r\nimport * as rimraf from \"rimraf\";\r\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\r\nimport { Guid } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\r\nimport {\r\n HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode,\r\n} from \"@itwin/presentation-backend\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\r\n\r\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\r\n const config = class extends RpcDefaultConfiguration {\r\n public override interfaces: any = () => interfaces;\r\n };\r\n\r\n for (const definition of interfaces)\r\n RpcConfiguration.assign(definition, () => config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n try {\r\n RpcConfiguration.initializeInterfaces(instance);\r\n } catch {\r\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\r\n // multiple different tests want to set up rpc interfaces\r\n }\r\n}\r\n\r\nlet isInitialized = false;\r\n\r\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\r\n\r\n/** @public */\r\nexport interface PresentationTestingInitProps {\r\n /** Properties for backend initialization */\r\n backendProps?: PresentationBackendProps;\r\n /** Properties for `IModelHost` */\r\n backendHostProps?: IModelHostOptions;\r\n /** Properties for frontend initialization */\r\n frontendProps?: PresentationFrontendProps;\r\n /** IModelApp implementation */\r\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\r\n /** `IModelApp` options */\r\n frontendAppOptions?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * Initialize the framework for presentation testing. The function sets up backend,\r\n * frontend and RPC communication between them.\r\n *\r\n * @see `terminate`\r\n *\r\n * @public\r\n */\r\nexport const initialize = async (props?: PresentationTestingInitProps) => {\r\n if (isInitialized)\r\n return;\r\n\r\n if (!props)\r\n props = {};\r\n\r\n // set up rpc interfaces\r\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\r\n\r\n // init backend\r\n // make sure backend gets assigned an id which puts its resources into a unique directory\r\n props.backendProps = props.backendProps ?? {};\r\n if (!props.backendProps.id)\r\n props.backendProps.id = `test-${Guid.createValue()}`;\r\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\r\n PresentationBackend.initialize(props.backendProps);\r\n\r\n // init frontend\r\n if (!props.frontendApp)\r\n props.frontendApp = NoRenderApp;\r\n await props.frontendApp.startup(props.frontendAppOptions);\r\n const defaultFrontendProps: PresentationFrontendProps = {\r\n presentation: {\r\n activeLocale: IModelApp.localization.getLanguageList()[0],\r\n },\r\n };\r\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\r\n\r\n isInitialized = true;\r\n};\r\n\r\n/**\r\n * Undoes the setup made by `initialize`.\r\n * @param frontendApp IModelApp implementation\r\n *\r\n * @see `initialize`\r\n *\r\n * @public\r\n */\r\nexport const terminate = async (frontendApp = IModelApp) => {\r\n if (!isInitialized)\r\n return;\r\n\r\n // store directory that needs to be cleaned-up\r\n let hierarchiesCacheDirectory: string | undefined;\r\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\r\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\r\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\r\n\r\n // terminate backend\r\n PresentationBackend.terminate();\r\n await IModelHost.shutdown();\r\n if (hierarchiesCacheDirectory)\r\n rimraf.sync(hierarchiesCacheDirectory);\r\n\r\n // terminate frontend\r\n PresentationFrontend.terminate();\r\n await frontendApp.shutdown();\r\n\r\n isInitialized = false;\r\n};\r\n"]}
@@ -1,3 +1,4 @@
1
+ import { IModelHostOptions } from "@itwin/core-backend";
1
2
  import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
2
3
  import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from "@itwin/presentation-backend";
3
4
  import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
@@ -6,13 +7,15 @@ export { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps }
6
7
  export interface PresentationTestingInitProps {
7
8
  /** Properties for backend initialization */
8
9
  backendProps?: PresentationBackendProps;
10
+ /** Properties for `IModelHost` */
11
+ backendHostProps?: IModelHostOptions;
9
12
  /** Properties for frontend initialization */
10
13
  frontendProps?: PresentationFrontendProps;
11
14
  /** IModelApp implementation */
12
15
  frontendApp?: {
13
16
  startup: (opts?: IModelAppOptions) => Promise<void>;
14
17
  };
15
- /** IModelApp options */
18
+ /** `IModelApp` options */
16
19
  frontendAppOptions?: IModelAppOptions;
17
20
  }
18
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAErL,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAuBpI,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,E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,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IACtE,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,qEA8BtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDAuBrB,CAAC"}
@@ -5,15 +5,15 @@
5
5
  /** @packageDocumentation
6
6
  * @module Helpers
7
7
  */
8
+ import { join } from "path";
8
9
  import * as rimraf from "rimraf";
9
- import { Guid } from "@itwin/core-bentley";
10
10
  import { IModelHost } from "@itwin/core-backend";
11
+ import { Guid } from "@itwin/core-bentley";
11
12
  import { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, SnapshotIModelRpcInterface, } from "@itwin/core-common";
12
13
  import { IModelApp, NoRenderApp } from "@itwin/core-frontend";
13
- import { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerMode } from "@itwin/presentation-backend";
14
+ import { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerMode, } from "@itwin/presentation-backend";
14
15
  import { PresentationRpcInterface } from "@itwin/presentation-common";
15
16
  import { Presentation as PresentationFrontend } from "@itwin/presentation-frontend";
16
- import { join } from "path";
17
17
  function initializeRpcInterfaces(interfaces) {
18
18
  const config = class extends RpcDefaultConfiguration {
19
19
  constructor() {
@@ -55,7 +55,7 @@ export const initialize = async (props) => {
55
55
  props.backendProps = (_a = props.backendProps) !== null && _a !== void 0 ? _a : {};
56
56
  if (!props.backendProps.id)
57
57
  props.backendProps.id = `test-${Guid.createValue()}`;
58
- await IModelHost.startup({ cacheDir: join(__dirname, ".cache") });
58
+ await IModelHost.startup({ cacheDir: join(__dirname, ".cache"), ...props.backendHostProps });
59
59
  PresentationBackend.initialize(props.backendProps);
60
60
  // init frontend
61
61
  if (!props.frontendApp)
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"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,yBAA6C,CAAC;IAClD,MAAM,sBAAsB,GAAG,MAAA,MAAA,mBAAmB,CAAC,SAAS,0CAAE,OAAO,0CAAE,WAAW,CAAC;IACnF,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,kBAAkB,CAAC,IAAI;QAC1D,yBAAyB,GAAG,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,SAAS,CAAC;SAC3D,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,kBAAkB,CAAC,MAAM;QACjE,yBAAyB,GAAG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,0CAAE,SAAS,CAAC;IAEtE,oBAAoB;IACpB,mBAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB;QAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEzC,qBAAqB;IACrB,oBAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,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/** @packageDocumentation\r\n * @module Helpers\r\n */\r\nimport * as rimraf from \"rimraf\";\r\nimport { Guid } from \"@itwin/core-bentley\";\r\nimport { IModelHost } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\r\nimport { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from \"@itwin/presentation-backend\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\r\nimport { join } from \"path\";\r\n\r\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\r\n const config = class extends RpcDefaultConfiguration {\r\n public override interfaces: any = () => interfaces;\r\n };\r\n\r\n for (const definition of interfaces)\r\n RpcConfiguration.assign(definition, () => config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n try {\r\n RpcConfiguration.initializeInterfaces(instance);\r\n } catch {\r\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\r\n // multiple different tests want to set up rpc interfaces\r\n }\r\n}\r\n\r\nlet isInitialized = false;\r\n\r\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\r\n\r\n/** @public */\r\nexport interface PresentationTestingInitProps {\r\n /** Properties for backend initialization */\r\n backendProps?: PresentationBackendProps;\r\n /** Properties for frontend initialization */\r\n frontendProps?: PresentationFrontendProps;\r\n /** IModelApp implementation */\r\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\r\n /** IModelApp options */\r\n frontendAppOptions?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * Initialize the framework for presentation testing. The function sets up backend,\r\n * frontend and RPC communication between them.\r\n *\r\n * @see `terminate`\r\n *\r\n * @public\r\n */\r\nexport const initialize = async (props?: PresentationTestingInitProps) => {\r\n if (isInitialized)\r\n return;\r\n\r\n if (!props)\r\n props = {};\r\n\r\n // set up rpc interfaces\r\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\r\n\r\n // init backend\r\n // make sure backend gets assigned an id which puts its resources into a unique directory\r\n props.backendProps = props.backendProps ?? {};\r\n if (!props.backendProps.id)\r\n props.backendProps.id = `test-${Guid.createValue()}`;\r\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\") });\r\n PresentationBackend.initialize(props.backendProps);\r\n\r\n // init frontend\r\n if (!props.frontendApp)\r\n props.frontendApp = NoRenderApp;\r\n await props.frontendApp.startup(props.frontendAppOptions);\r\n const defaultFrontendProps: PresentationFrontendProps = {\r\n presentation: {\r\n activeLocale: IModelApp.localization.getLanguageList()[0],\r\n },\r\n };\r\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\r\n\r\n isInitialized = true;\r\n};\r\n\r\n/**\r\n * Undoes the setup made by `initialize`.\r\n * @param frontendApp IModelApp implementation\r\n *\r\n * @see `initialize`\r\n *\r\n * @public\r\n */\r\nexport const terminate = async (frontendApp = IModelApp) => {\r\n if (!isInitialized)\r\n return;\r\n\r\n // store directory that needs to be cleaned-up\r\n let hierarchiesCacheDirectory: string | undefined;\r\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\r\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\r\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\r\n\r\n // terminate backend\r\n PresentationBackend.terminate();\r\n await IModelHost.shutdown();\r\n if (hierarchiesCacheDirectory)\r\n rimraf.sync(hierarchiesCacheDirectory);\r\n\r\n // terminate frontend\r\n PresentationFrontend.terminate();\r\n await frontendApp.shutdown();\r\n\r\n isInitialized = false;\r\n};\r\n"]}
1
+ {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,UAAU,EAAqB,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,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,kBAAkB,CAAC,IAAI;QAC1D,yBAAyB,GAAG,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,SAAS,CAAC;SAC3D,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,kBAAkB,CAAC,MAAM;QACjE,yBAAyB,GAAG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,0CAAE,SAAS,CAAC;IAEtE,oBAAoB;IACpB,mBAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB;QAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEzC,qBAAqB;IACrB,oBAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,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/** @packageDocumentation\r\n * @module Helpers\r\n */\r\nimport { join } from \"path\";\r\nimport * as rimraf from \"rimraf\";\r\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\r\nimport { Guid } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\r\nimport {\r\n HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode,\r\n} from \"@itwin/presentation-backend\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\r\n\r\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\r\n const config = class extends RpcDefaultConfiguration {\r\n public override interfaces: any = () => interfaces;\r\n };\r\n\r\n for (const definition of interfaces)\r\n RpcConfiguration.assign(definition, () => config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n try {\r\n RpcConfiguration.initializeInterfaces(instance);\r\n } catch {\r\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\r\n // multiple different tests want to set up rpc interfaces\r\n }\r\n}\r\n\r\nlet isInitialized = false;\r\n\r\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\r\n\r\n/** @public */\r\nexport interface PresentationTestingInitProps {\r\n /** Properties for backend initialization */\r\n backendProps?: PresentationBackendProps;\r\n /** Properties for `IModelHost` */\r\n backendHostProps?: IModelHostOptions;\r\n /** Properties for frontend initialization */\r\n frontendProps?: PresentationFrontendProps;\r\n /** IModelApp implementation */\r\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\r\n /** `IModelApp` options */\r\n frontendAppOptions?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * Initialize the framework for presentation testing. The function sets up backend,\r\n * frontend and RPC communication between them.\r\n *\r\n * @see `terminate`\r\n *\r\n * @public\r\n */\r\nexport const initialize = async (props?: PresentationTestingInitProps) => {\r\n if (isInitialized)\r\n return;\r\n\r\n if (!props)\r\n props = {};\r\n\r\n // set up rpc interfaces\r\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\r\n\r\n // init backend\r\n // make sure backend gets assigned an id which puts its resources into a unique directory\r\n props.backendProps = props.backendProps ?? {};\r\n if (!props.backendProps.id)\r\n props.backendProps.id = `test-${Guid.createValue()}`;\r\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\r\n PresentationBackend.initialize(props.backendProps);\r\n\r\n // init frontend\r\n if (!props.frontendApp)\r\n props.frontendApp = NoRenderApp;\r\n await props.frontendApp.startup(props.frontendAppOptions);\r\n const defaultFrontendProps: PresentationFrontendProps = {\r\n presentation: {\r\n activeLocale: IModelApp.localization.getLanguageList()[0],\r\n },\r\n };\r\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\r\n\r\n isInitialized = true;\r\n};\r\n\r\n/**\r\n * Undoes the setup made by `initialize`.\r\n * @param frontendApp IModelApp implementation\r\n *\r\n * @see `initialize`\r\n *\r\n * @public\r\n */\r\nexport const terminate = async (frontendApp = IModelApp) => {\r\n if (!isInitialized)\r\n return;\r\n\r\n // store directory that needs to be cleaned-up\r\n let hierarchiesCacheDirectory: string | undefined;\r\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\r\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\r\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\r\n\r\n // terminate backend\r\n PresentationBackend.terminate();\r\n await IModelHost.shutdown();\r\n if (hierarchiesCacheDirectory)\r\n rimraf.sync(hierarchiesCacheDirectory);\r\n\r\n // terminate frontend\r\n PresentationFrontend.terminate();\r\n await frontendApp.shutdown();\r\n\r\n isInitialized = false;\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/presentation-testing",
3
- "version": "3.4.0-dev.10",
3
+ "version": "3.4.0-dev.15",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,18 +25,18 @@
25
25
  "ignore-styles": "^5.0.1"
26
26
  },
27
27
  "dependencies": {
28
- "@itwin/appui-abstract": "3.4.0-dev.10",
29
- "@itwin/build-tools": "3.4.0-dev.10",
30
- "@itwin/components-react": "3.4.0-dev.10",
31
- "@itwin/core-backend": "3.4.0-dev.10",
32
- "@itwin/core-bentley": "3.4.0-dev.10",
33
- "@itwin/core-common": "3.4.0-dev.10",
34
- "@itwin/core-frontend": "3.4.0-dev.10",
35
- "@itwin/eslint-plugin": "3.4.0-dev.10",
36
- "@itwin/presentation-backend": "3.4.0-dev.10",
37
- "@itwin/presentation-common": "3.4.0-dev.10",
38
- "@itwin/presentation-components": "3.4.0-dev.10",
39
- "@itwin/presentation-frontend": "3.4.0-dev.10",
28
+ "@itwin/appui-abstract": "3.4.0-dev.15",
29
+ "@itwin/build-tools": "3.4.0-dev.15",
30
+ "@itwin/components-react": "3.4.0-dev.15",
31
+ "@itwin/core-backend": "3.4.0-dev.15",
32
+ "@itwin/core-bentley": "3.4.0-dev.15",
33
+ "@itwin/core-common": "3.4.0-dev.15",
34
+ "@itwin/core-frontend": "3.4.0-dev.15",
35
+ "@itwin/eslint-plugin": "3.4.0-dev.15",
36
+ "@itwin/presentation-backend": "3.4.0-dev.15",
37
+ "@itwin/presentation-common": "3.4.0-dev.15",
38
+ "@itwin/presentation-components": "3.4.0-dev.15",
39
+ "@itwin/presentation-frontend": "3.4.0-dev.15",
40
40
  "@types/chai": "4.3.1",
41
41
  "@types/chai-as-promised": "^7",
42
42
  "@types/chai-jest-snapshot": "^1.3.0",