@itwin/core-common 4.0.0-dev.73 → 4.0.0-dev.75
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.
|
@@ -80,20 +80,24 @@ export interface Localization {
|
|
|
80
80
|
getLocalizedKeys(inputString: string): string;
|
|
81
81
|
/** Register a new Namespace and return a Promise that is fulfilled when the content is loaded.
|
|
82
82
|
* If the namespace is already registered, its Promise will be returned.
|
|
83
|
-
* @param
|
|
83
|
+
* @param namespace - the name of the namespace.
|
|
84
84
|
* @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,
|
|
85
85
|
* based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await
|
|
86
86
|
* fulfillment of returned Promise.
|
|
87
87
|
* @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)
|
|
88
88
|
*/
|
|
89
89
|
registerNamespace(namespace: string): Promise<void>;
|
|
90
|
-
/**
|
|
90
|
+
/** Unregister a namespace.
|
|
91
|
+
* @param namespace - the name of the namespace.
|
|
92
|
+
*/
|
|
91
93
|
unregisterNamespace(namespace: string): void;
|
|
92
94
|
/** @internal */
|
|
93
95
|
getNamespacePromise(name: string): Promise<void> | undefined;
|
|
94
96
|
/** Get the list of available languages for translations */
|
|
95
97
|
getLanguageList(): readonly string[];
|
|
96
|
-
/** Change the language for translations. This overrides the language from the browser, for tests.
|
|
98
|
+
/** Change the language for translations. This overrides the language from the browser, for tests.
|
|
99
|
+
* @param language - the language to change to.
|
|
100
|
+
*/
|
|
97
101
|
changeLanguage(language: string): Promise<void>;
|
|
98
102
|
}
|
|
99
103
|
/** An empty [[Localization]] used if one is not provided to [IModelApp]($frontend). Does not perform localizations (merely returns the key.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localization.d.ts","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC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,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACvC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IACjC,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAQlD,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IACnF,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IACpE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IACvC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IACxC,mBAAmB,IAAI,IAAI;IAC3B,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS;IAChD,eAAe,IAAI,SAAS,MAAM,EAAE;IAC9B,cAAc;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA6GH;;GAEG;AACH,MAAa,iBAAiB;IACrB,KAAK,CAAC,UAAU,KAAoB,CAAC;IACrC,kBAAkB,CAAC,GAAsB;QAC9C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YAC7B,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SACd;QACD,sEAAsE;QACtE,iEAAiE;QACjE,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAG,CAAC;IAClC,CAAC;IACM,+BAA+B,CAAC,UAAkB,EAAE,GAAsB,IAAY,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5H,gBAAgB,CAAC,UAAkB,EAAE,GAAsB,IAAY,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7G,gBAAgB,CAAC,WAAmB,IAAY,OAAO,WAAW,CAAC,CAAC,CAAC;IACrE,KAAK,CAAC,iBAAiB,KAAoB,CAAC;IAC5C,mBAAmB,KAAW,CAAC;IAC/B,mBAAmB,KAAgC,OAAO,SAAS,CAAC,CAAC,CAAC;IACtE,eAAe,KAAwB,OAAO,EAAE,CAAC,CAAC,CAAC;IACnD,KAAK,CAAC,cAAc,KAAK,CAAC;CAClC;AAlBD,8CAkBC","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 Localization\r\n */\r\n\r\n/** Options for Localization\r\n * @public\r\n */\r\nexport interface TranslationOptions {\r\n /** for interpolation values */\r\n [key: string]: any;\r\n /**\r\n * defaultValue to return if a translation was not found\r\n */\r\n defaultValue?: any;\r\n /**\r\n * count value used for plurals\r\n */\r\n count?: number;\r\n /**\r\n * used for contexts (eg. male\\female)\r\n */\r\n context?: any;\r\n /**\r\n * override languages to use\r\n */\r\n lngs?: string[];\r\n /**\r\n * override language to lookup key if not found see fallbacks for details\r\n */\r\n fallbackLng?: string;\r\n}\r\n\r\n/** The interface defining the localization requirements of [IModelApp]($frontend).\r\n * @public\r\n * @extensions\r\n */\r\nexport interface Localization {\r\n /** This method must be called and awaited before using an instance of Localization.\r\n * @param namespaces an array of namespaces to load. There must be at least one namespace, and it\r\n * becomes the default namespace.\r\n * @note IModelApp.startup calls this internally, so you should not call this method directly\r\n * except for Localization instances outside of IModelApp (e.g., for tests.)\r\n */\r\n initialize(namespaces: string[]): Promise<void>;\r\n\r\n /** Return the translated value of a key.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @note The key includes the namespace, which identifies the particular localization file that contains the property,\r\n * followed by a colon, followed by the property in the JSON file.\r\n * For example:\r\n * ``` ts\r\n * const dataString: string = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.BingDataAttribution\");\r\n * ```\r\n * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n */\r\n getLocalizedString(key: string | string[], options?: TranslationOptions): string;\r\n /** Similar to `getLocalizedString` but the namespace is a separate param and the key does not include the namespace.\r\n * @param namespace - the namespace that identifies the particular localization file that contains the property.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n * @deprecated in 3.x. Use `getLocalizedString` instead; providing either a key with a namespace `<namespace>:<key>` or\r\n * including `{ ns: <namespace> }` in the options.\r\n */\r\n getLocalizedStringWithNamespace(namespace: string, key: string | string[], options?: TranslationOptions): string;\r\n /** get the English string for a key. */\r\n getEnglishString(namespace: string, key: string | string[], options?: TranslationOptions): string;\r\n /** Replace all instances of `%{key}` within a string with the translations of those keys.\r\n * For example:\r\n * ``` ts\r\n * \"MyKeys\": {\r\n * \"Key1\": \"First value\",\r\n * \"Key2\": \"Second value\"\r\n * }\r\n * ```\r\n *\r\n * ``` ts\r\n * getLocalizedKeys(\"string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!\"\") // returns \"string with First Value followed by Second Value!\"\r\n * ```\r\n */\r\n getLocalizedKeys(inputString: string): string;\r\n\r\n /** Register a new Namespace and return a Promise that is fulfilled when the content is loaded.\r\n * If the namespace is already registered, its Promise will be returned.\r\n * @param namespace - the name of the namespace.\r\n * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,\r\n * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await\r\n * fulfillment of returned Promise.\r\n * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)\r\n */\r\n registerNamespace(namespace: string): Promise<void>;\r\n\r\n /** Unregister a namespace.\r\n * @param namespace - the name of the namespace.\r\n */\r\n unregisterNamespace(namespace: string): void;\r\n\r\n /** @internal */\r\n getNamespacePromise(name: string): Promise<void> | undefined;\r\n\r\n /** Get the list of available languages for translations */\r\n getLanguageList(): readonly string[];\r\n\r\n /** Change the language for translations. This overrides the language from the browser, for tests.\r\n * @param language - the language to change to.\r\n */\r\n changeLanguage(language: string): Promise<void>;\r\n}\r\n\r\n/** An empty [[Localization]] used if one is not provided to [IModelApp]($frontend). Does not perform localizations (merely returns the key.)\r\n * @public\r\n */\r\nexport class EmptyLocalization implements Localization {\r\n public async initialize(): Promise<void> { }\r\n public getLocalizedString(key: string | string[]): string {\r\n if (typeof (key) !== \"string\") {\r\n key = key[0];\r\n }\r\n // Simulate correct and simple usage of i18next's translation function\r\n // Namely, remove the leading namespace substring if there is one\r\n return key.split(\":\", 2).pop()!;\r\n }\r\n public getLocalizedStringWithNamespace(_namespace: string, key: string | string[]): string { return this.getLocalizedString(key); }\r\n public getEnglishString(_namespace: string, key: string | string[]): string { return this.getLocalizedString(key); }\r\n public getLocalizedKeys(inputString: string): string { return inputString; }\r\n public async registerNamespace(): Promise<void> { }\r\n public unregisterNamespace(): void { }\r\n public getNamespacePromise(): Promise<void> | undefined { return undefined; }\r\n public getLanguageList(): readonly string[] { return []; }\r\n public async changeLanguage() { }\r\n}\r\n"]}
|
|
@@ -80,20 +80,24 @@ export interface Localization {
|
|
|
80
80
|
getLocalizedKeys(inputString: string): string;
|
|
81
81
|
/** Register a new Namespace and return a Promise that is fulfilled when the content is loaded.
|
|
82
82
|
* If the namespace is already registered, its Promise will be returned.
|
|
83
|
-
* @param
|
|
83
|
+
* @param namespace - the name of the namespace.
|
|
84
84
|
* @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,
|
|
85
85
|
* based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await
|
|
86
86
|
* fulfillment of returned Promise.
|
|
87
87
|
* @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)
|
|
88
88
|
*/
|
|
89
89
|
registerNamespace(namespace: string): Promise<void>;
|
|
90
|
-
/**
|
|
90
|
+
/** Unregister a namespace.
|
|
91
|
+
* @param namespace - the name of the namespace.
|
|
92
|
+
*/
|
|
91
93
|
unregisterNamespace(namespace: string): void;
|
|
92
94
|
/** @internal */
|
|
93
95
|
getNamespacePromise(name: string): Promise<void> | undefined;
|
|
94
96
|
/** Get the list of available languages for translations */
|
|
95
97
|
getLanguageList(): readonly string[];
|
|
96
|
-
/** Change the language for translations. This overrides the language from the browser, for tests.
|
|
98
|
+
/** Change the language for translations. This overrides the language from the browser, for tests.
|
|
99
|
+
* @param language - the language to change to.
|
|
100
|
+
*/
|
|
97
101
|
changeLanguage(language: string): Promise<void>;
|
|
98
102
|
}
|
|
99
103
|
/** An empty [[Localization]] used if one is not provided to [IModelApp]($frontend). Does not perform localizations (merely returns the key.)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localization.d.ts","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,UAAU,CAAC,UAAU,EAAE,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,MAAM,EAAE,GAAG,MAAM;IACpE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IACvC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IACxC,mBAAmB,IAAI,IAAI;IAC3B,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS;IAChD,eAAe,IAAI,SAAS,MAAM,EAAE;IAC9B,cAAc;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;
|
|
1
|
+
{"version":3,"file":"Localization.js","sourceRoot":"","sources":["../../src/Localization.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA6GH;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACrB,KAAK,CAAC,UAAU,KAAoB,CAAC;IACrC,kBAAkB,CAAC,GAAsB;QAC9C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YAC7B,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SACd;QACD,sEAAsE;QACtE,iEAAiE;QACjE,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAG,CAAC;IAClC,CAAC;IACM,+BAA+B,CAAC,UAAkB,EAAE,GAAsB,IAAY,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5H,gBAAgB,CAAC,UAAkB,EAAE,GAAsB,IAAY,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7G,gBAAgB,CAAC,WAAmB,IAAY,OAAO,WAAW,CAAC,CAAC,CAAC;IACrE,KAAK,CAAC,iBAAiB,KAAoB,CAAC;IAC5C,mBAAmB,KAAW,CAAC;IAC/B,mBAAmB,KAAgC,OAAO,SAAS,CAAC,CAAC,CAAC;IACtE,eAAe,KAAwB,OAAO,EAAE,CAAC,CAAC,CAAC;IACnD,KAAK,CAAC,cAAc,KAAK,CAAC;CAClC","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 Localization\r\n */\r\n\r\n/** Options for Localization\r\n * @public\r\n */\r\nexport interface TranslationOptions {\r\n /** for interpolation values */\r\n [key: string]: any;\r\n /**\r\n * defaultValue to return if a translation was not found\r\n */\r\n defaultValue?: any;\r\n /**\r\n * count value used for plurals\r\n */\r\n count?: number;\r\n /**\r\n * used for contexts (eg. male\\female)\r\n */\r\n context?: any;\r\n /**\r\n * override languages to use\r\n */\r\n lngs?: string[];\r\n /**\r\n * override language to lookup key if not found see fallbacks for details\r\n */\r\n fallbackLng?: string;\r\n}\r\n\r\n/** The interface defining the localization requirements of [IModelApp]($frontend).\r\n * @public\r\n * @extensions\r\n */\r\nexport interface Localization {\r\n /** This method must be called and awaited before using an instance of Localization.\r\n * @param namespaces an array of namespaces to load. There must be at least one namespace, and it\r\n * becomes the default namespace.\r\n * @note IModelApp.startup calls this internally, so you should not call this method directly\r\n * except for Localization instances outside of IModelApp (e.g., for tests.)\r\n */\r\n initialize(namespaces: string[]): Promise<void>;\r\n\r\n /** Return the translated value of a key.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @note The key includes the namespace, which identifies the particular localization file that contains the property,\r\n * followed by a colon, followed by the property in the JSON file.\r\n * For example:\r\n * ``` ts\r\n * const dataString: string = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.BingDataAttribution\");\r\n * ```\r\n * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n */\r\n getLocalizedString(key: string | string[], options?: TranslationOptions): string;\r\n /** Similar to `getLocalizedString` but the namespace is a separate param and the key does not include the namespace.\r\n * @param namespace - the namespace that identifies the particular localization file that contains the property.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n * @deprecated in 3.x. Use `getLocalizedString` instead; providing either a key with a namespace `<namespace>:<key>` or\r\n * including `{ ns: <namespace> }` in the options.\r\n */\r\n getLocalizedStringWithNamespace(namespace: string, key: string | string[], options?: TranslationOptions): string;\r\n /** get the English string for a key. */\r\n getEnglishString(namespace: string, key: string | string[], options?: TranslationOptions): string;\r\n /** Replace all instances of `%{key}` within a string with the translations of those keys.\r\n * For example:\r\n * ``` ts\r\n * \"MyKeys\": {\r\n * \"Key1\": \"First value\",\r\n * \"Key2\": \"Second value\"\r\n * }\r\n * ```\r\n *\r\n * ``` ts\r\n * getLocalizedKeys(\"string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!\"\") // returns \"string with First Value followed by Second Value!\"\r\n * ```\r\n */\r\n getLocalizedKeys(inputString: string): string;\r\n\r\n /** Register a new Namespace and return a Promise that is fulfilled when the content is loaded.\r\n * If the namespace is already registered, its Promise will be returned.\r\n * @param namespace - the name of the namespace.\r\n * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,\r\n * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await\r\n * fulfillment of returned Promise.\r\n * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)\r\n */\r\n registerNamespace(namespace: string): Promise<void>;\r\n\r\n /** Unregister a namespace.\r\n * @param namespace - the name of the namespace.\r\n */\r\n unregisterNamespace(namespace: string): void;\r\n\r\n /** @internal */\r\n getNamespacePromise(name: string): Promise<void> | undefined;\r\n\r\n /** Get the list of available languages for translations */\r\n getLanguageList(): readonly string[];\r\n\r\n /** Change the language for translations. This overrides the language from the browser, for tests.\r\n * @param language - the language to change to.\r\n */\r\n changeLanguage(language: string): Promise<void>;\r\n}\r\n\r\n/** An empty [[Localization]] used if one is not provided to [IModelApp]($frontend). Does not perform localizations (merely returns the key.)\r\n * @public\r\n */\r\nexport class EmptyLocalization implements Localization {\r\n public async initialize(): Promise<void> { }\r\n public getLocalizedString(key: string | string[]): string {\r\n if (typeof (key) !== \"string\") {\r\n key = key[0];\r\n }\r\n // Simulate correct and simple usage of i18next's translation function\r\n // Namely, remove the leading namespace substring if there is one\r\n return key.split(\":\", 2).pop()!;\r\n }\r\n public getLocalizedStringWithNamespace(_namespace: string, key: string | string[]): string { return this.getLocalizedString(key); }\r\n public getEnglishString(_namespace: string, key: string | string[]): string { return this.getLocalizedString(key); }\r\n public getLocalizedKeys(inputString: string): string { return inputString; }\r\n public async registerNamespace(): Promise<void> { }\r\n public unregisterNamespace(): void { }\r\n public getNamespacePromise(): Promise<void> | undefined { return undefined; }\r\n public getLanguageList(): readonly string[] { return []; }\r\n public async changeLanguage() { }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-common",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.75",
|
|
4
4
|
"description": "iTwin.js components common to frontend and backend",
|
|
5
5
|
"main": "lib/cjs/core-common.js",
|
|
6
6
|
"module": "lib/esm/core-common.js",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"js-base64": "^3.6.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@itwin/core-bentley": "^4.0.0-dev.
|
|
33
|
-
"@itwin/core-geometry": "^4.0.0-dev.
|
|
32
|
+
"@itwin/core-bentley": "^4.0.0-dev.75",
|
|
33
|
+
"@itwin/core-geometry": "^4.0.0-dev.75"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@itwin/build-tools": "4.0.0-dev.
|
|
37
|
-
"@itwin/core-bentley": "4.0.0-dev.
|
|
38
|
-
"@itwin/core-geometry": "4.0.0-dev.
|
|
36
|
+
"@itwin/build-tools": "4.0.0-dev.75",
|
|
37
|
+
"@itwin/core-bentley": "4.0.0-dev.75",
|
|
38
|
+
"@itwin/core-geometry": "4.0.0-dev.75",
|
|
39
39
|
"@itwin/eslint-plugin": "^4.0.0-dev.33",
|
|
40
40
|
"@types/chai": "4.3.1",
|
|
41
41
|
"@types/flatbuffers": "~1.10.0",
|