@itwin/core-mobile 4.0.0-dev.7 → 4.0.0-dev.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/lib/cjs/MobileBackend.d.ts +7 -7
  3. package/lib/cjs/MobileBackend.js +28 -24
  4. package/lib/cjs/MobileBackend.js.map +1 -1
  5. package/lib/cjs/MobileFrontend.d.ts +5 -5
  6. package/lib/cjs/MobileFrontend.js +25 -21
  7. package/lib/cjs/MobileFrontend.js.map +1 -1
  8. package/lib/cjs/__DOC_ONLY__.d.ts +33 -33
  9. package/lib/cjs/__DOC_ONLY__.js +56 -52
  10. package/lib/cjs/__DOC_ONLY__.js.map +1 -1
  11. package/lib/cjs/backend/MobileAuthorizationBackend.d.ts +17 -17
  12. package/lib/cjs/backend/MobileAuthorizationBackend.js +46 -46
  13. package/lib/cjs/backend/MobileAuthorizationBackend.js.map +1 -1
  14. package/lib/cjs/backend/MobileFileHandler.d.ts +112 -112
  15. package/lib/cjs/backend/MobileFileHandler.js +263 -263
  16. package/lib/cjs/backend/MobileHost.d.ts +72 -72
  17. package/lib/cjs/backend/MobileHost.d.ts.map +1 -1
  18. package/lib/cjs/backend/MobileHost.js +155 -156
  19. package/lib/cjs/backend/MobileHost.js.map +1 -1
  20. package/lib/cjs/backend/MobileRpcServer.d.ts +19 -19
  21. package/lib/cjs/backend/MobileRpcServer.js +156 -156
  22. package/lib/cjs/backend/MobileRpcServer.js.map +1 -1
  23. package/lib/cjs/backend/Request.d.ts +149 -149
  24. package/lib/cjs/backend/Request.d.ts.map +1 -1
  25. package/lib/cjs/backend/Request.js +267 -267
  26. package/lib/cjs/common/MobileAppChannel.d.ts +4 -4
  27. package/lib/cjs/common/MobileAppChannel.js +11 -11
  28. package/lib/cjs/common/MobileAppProps.d.ts +35 -35
  29. package/lib/cjs/common/MobileAppProps.d.ts.map +1 -1
  30. package/lib/cjs/common/MobileAppProps.js +26 -26
  31. package/lib/cjs/common/MobileEventLoop.d.ts +11 -11
  32. package/lib/cjs/common/MobileEventLoop.js +30 -30
  33. package/lib/cjs/common/MobileEventLoop.js.map +1 -1
  34. package/lib/cjs/common/MobileIpc.d.ts +17 -17
  35. package/lib/cjs/common/MobileIpc.js +70 -70
  36. package/lib/cjs/common/MobilePush.d.ts +20 -20
  37. package/lib/cjs/common/MobilePush.js +53 -53
  38. package/lib/cjs/common/MobilePush.js.map +1 -1
  39. package/lib/cjs/common/MobileRpcManager.d.ts +40 -40
  40. package/lib/cjs/common/MobileRpcManager.js +110 -110
  41. package/lib/cjs/common/MobileRpcManager.js.map +1 -1
  42. package/lib/cjs/common/MobileRpcProtocol.d.ts +58 -58
  43. package/lib/cjs/common/MobileRpcProtocol.d.ts.map +1 -1
  44. package/lib/cjs/common/MobileRpcProtocol.js +277 -277
  45. package/lib/cjs/common/MobileRpcProtocol.js.map +1 -1
  46. package/lib/cjs/common/MobileRpcRequest.d.ts +20 -20
  47. package/lib/cjs/common/MobileRpcRequest.js +50 -50
  48. package/lib/cjs/frontend/MobileApp.d.ts +23 -23
  49. package/lib/cjs/frontend/MobileApp.d.ts.map +1 -1
  50. package/lib/cjs/frontend/MobileApp.js +79 -80
  51. package/lib/cjs/frontend/MobileApp.js.map +1 -1
  52. package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts +17 -17
  53. package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts.map +1 -1
  54. package/lib/cjs/frontend/MobileAuthorizationFrontend.js +54 -46
  55. package/lib/cjs/frontend/MobileAuthorizationFrontend.js.map +1 -1
  56. package/lib/cjs/test/ios/MobilePlatform.test.d.ts +1 -1
  57. package/lib/cjs/test/ios/MobilePlatform.test.js +84 -84
  58. package/package.json +18 -18
@@ -1,47 +1,55 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module OIDC
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.MobileAuthorizationFrontend = void 0;
11
- const MobileApp_1 = require("./MobileApp");
12
- /** Utility to provide and cache auth tokens from native mobile apps to IModelApp.
13
- * @internal
14
- */
15
- class MobileAuthorizationFrontend {
16
- constructor() {
17
- this._accessToken = "";
18
- this._expiryBuffer = 60 * 10; // ten minutes
19
- this._fetchingToken = false;
20
- }
21
- get _hasExpired() {
22
- return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;
23
- }
24
- async getAccessToken() {
25
- if (this._fetchingToken) {
26
- return Promise.reject(); // short-circuits any recursive use of this function
27
- }
28
- if (this._accessToken && !this._hasExpired) {
29
- return this._accessToken;
30
- }
31
- else {
32
- this._fetchingToken = true;
33
- const result = await MobileApp_1.MobileApp.callBackend("getAccessToken");
34
- this._accessToken = result[0];
35
- if (result[1])
36
- this._expirationDate = new Date(result[1]);
37
- this._fetchingToken = false;
38
- return this._accessToken;
39
- }
40
- }
41
- setAccessToken(accessToken, expirationDate) {
42
- this._accessToken = accessToken !== null && accessToken !== void 0 ? accessToken : "";
43
- this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;
44
- }
45
- }
46
- exports.MobileAuthorizationFrontend = MobileAuthorizationFrontend;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module OIDC
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MobileAuthorizationFrontend = void 0;
11
+ const MobileApp_1 = require("./MobileApp");
12
+ /** Utility to provide and cache auth tokens from native mobile apps to IModelApp.
13
+ * @internal
14
+ */
15
+ class MobileAuthorizationFrontend {
16
+ constructor() {
17
+ this._accessToken = "";
18
+ this._expiryBuffer = 60 * 10; // ten minutes
19
+ this._fetchingToken = false;
20
+ }
21
+ get _hasExpired() {
22
+ return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;
23
+ }
24
+ async getAccessToken() {
25
+ if (this._fetchingToken) {
26
+ // NOTE: This function is from the AuthorizationClient interface. That interface documents
27
+ // this function to return an empty string if no token is available, NOT throw an exception.
28
+ return ""; // short-circuits any recursive use of this function
29
+ }
30
+ if (this._accessToken && !this._hasExpired) {
31
+ return this._accessToken;
32
+ }
33
+ else {
34
+ try {
35
+ this._fetchingToken = true;
36
+ const result = await MobileApp_1.MobileApp.callBackend("getAccessToken");
37
+ this._accessToken = result[0];
38
+ this._expirationDate = result[1] ? new Date(result[1]) : undefined;
39
+ return this._accessToken;
40
+ }
41
+ catch (_ex) {
42
+ return "";
43
+ }
44
+ finally {
45
+ this._fetchingToken = false;
46
+ }
47
+ }
48
+ }
49
+ setAccessToken(accessToken, expirationDate) {
50
+ this._accessToken = accessToken ?? "";
51
+ this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;
52
+ }
53
+ }
54
+ exports.MobileAuthorizationFrontend = MobileAuthorizationFrontend;
47
55
  //# sourceMappingURL=MobileAuthorizationFrontend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAuthorizationFrontend.js","sourceRoot":"","sources":["../../../src/frontend/MobileAuthorizationFrontend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,2CAAwC;AAExC;;GAEG;AACH,MAAa,2BAA2B;IAAxC;QACU,iBAAY,GAAgB,EAAE,CAAC;QAE/B,kBAAa,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,cAAc;QACvC,mBAAc,GAAG,KAAK,CAAC;IA4BjC,CAAC;IA1BC,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IACxH,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,oDAAoD;SAC9E;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAC1C,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;aAAM;YACL,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,MAAM,MAAM,GAAG,MAAM,qBAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;YAC7D,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,MAAM,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAC5B,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;IACH,CAAC;IAEM,cAAc,CAAC,WAAoB,EAAE,cAAuB;QACjE,IAAI,CAAC,YAAY,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;CACF;AAhCD,kEAgCC","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 OIDC\r\n */\r\n\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient } from \"@itwin/core-common\";\r\nimport { MobileApp } from \"./MobileApp\";\r\n\r\n/** Utility to provide and cache auth tokens from native mobile apps to IModelApp.\r\n * @internal\r\n */\r\nexport class MobileAuthorizationFrontend implements AuthorizationClient {\r\n private _accessToken: AccessToken = \"\";\r\n private _expirationDate: Date | undefined;\r\n private _expiryBuffer = 60 * 10; // ten minutes\r\n private _fetchingToken = false;\r\n\r\n private get _hasExpired(): boolean {\r\n return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (this._fetchingToken) {\r\n return Promise.reject(); // short-circuits any recursive use of this function\r\n }\r\n\r\n if (this._accessToken && !this._hasExpired) {\r\n return this._accessToken;\r\n } else {\r\n this._fetchingToken = true;\r\n const result = await MobileApp.callBackend(\"getAccessToken\");\r\n this._accessToken = result[0];\r\n if (result[1])\r\n this._expirationDate = new Date(result[1]);\r\n this._fetchingToken = false;\r\n return this._accessToken;\r\n }\r\n }\r\n\r\n public setAccessToken(accessToken?: string, expirationDate?: string) {\r\n this._accessToken = accessToken ?? \"\";\r\n this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MobileAuthorizationFrontend.js","sourceRoot":"","sources":["../../../src/frontend/MobileAuthorizationFrontend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,2CAAwC;AAExC;;GAEG;AACH,MAAa,2BAA2B;IAAxC;QACU,iBAAY,GAAgB,EAAE,CAAC;QAE/B,kBAAa,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,cAAc;QACvC,mBAAc,GAAG,KAAK,CAAC;IAkCjC,CAAC;IAhCC,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IACxH,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,0FAA0F;YAC1F,4FAA4F;YAC5F,OAAO,EAAE,CAAC,CAAC,oDAAoD;SAChE;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAC1C,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;aAAM;YACL,IAAI;gBACF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;gBAC3B,MAAM,MAAM,GAAG,MAAM,qBAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;gBAC7D,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBACnE,OAAO,IAAI,CAAC,YAAY,CAAC;aAC1B;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,EAAE,CAAC;aACX;oBAAS;gBACR,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;aAC7B;SACF;IACH,CAAC;IAEM,cAAc,CAAC,WAAoB,EAAE,cAAuB;QACjE,IAAI,CAAC,YAAY,GAAG,WAAW,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;CACF;AAtCD,kEAsCC","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 OIDC\r\n */\r\n\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient } from \"@itwin/core-common\";\r\nimport { MobileApp } from \"./MobileApp\";\r\n\r\n/** Utility to provide and cache auth tokens from native mobile apps to IModelApp.\r\n * @internal\r\n */\r\nexport class MobileAuthorizationFrontend implements AuthorizationClient {\r\n private _accessToken: AccessToken = \"\";\r\n private _expirationDate: Date | undefined;\r\n private _expiryBuffer = 60 * 10; // ten minutes\r\n private _fetchingToken = false;\r\n\r\n private get _hasExpired(): boolean {\r\n return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (this._fetchingToken) {\r\n // NOTE: This function is from the AuthorizationClient interface. That interface documents\r\n // this function to return an empty string if no token is available, NOT throw an exception.\r\n return \"\"; // short-circuits any recursive use of this function\r\n }\r\n\r\n if (this._accessToken && !this._hasExpired) {\r\n return this._accessToken;\r\n } else {\r\n try {\r\n this._fetchingToken = true;\r\n const result = await MobileApp.callBackend(\"getAccessToken\");\r\n this._accessToken = result[0];\r\n this._expirationDate = result[1] ? new Date(result[1]) : undefined;\r\n return this._accessToken;\r\n } catch (_ex) {\r\n return \"\";\r\n } finally {\r\n this._fetchingToken = false;\r\n }\r\n }\r\n }\r\n\r\n public setAccessToken(accessToken?: string, expirationDate?: string) {\r\n this._accessToken = accessToken ?? \"\";\r\n this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;\r\n }\r\n}\r\n"]}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=MobilePlatform.test.d.ts.map
@@ -1,85 +1,85 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
- * See LICENSE.md in the project root for license terms and full copyright notice.
6
- *--------------------------------------------------------------------------------------------*/
7
- const chai_1 = require("chai");
8
- const fs = require("fs-extra");
9
- const os = require("os");
10
- const path = require("path");
11
- const outputDir = path.join(os.tmpdir(), "output");
12
- describe("IOS Platform Test", () => {
13
- it("Filesystem (Uint8Array) - writeFileSync, appendFileSync and readFileSync", () => {
14
- const testDir = path.join(outputDir, "mobile-introp");
15
- const testFile = path.join(testDir, "test.bin");
16
- if (fs.existsSync(testDir)) {
17
- fs.unlinkSync(testDir);
18
- }
19
- fs.mkdirSync(testDir);
20
- chai_1.assert.isTrue(fs.existsSync(testDir));
21
- const testArray = new Uint8Array(1024);
22
- for (let i = 0; i < testArray.length; i++) {
23
- testArray[i] = i % 255;
24
- }
25
- fs.writeFileSync(testFile, testArray);
26
- // binary test
27
- const outArray = fs.readFileSync(testFile, { encoding: null });
28
- chai_1.assert.equal(outArray.length, testArray.length, "array size must match");
29
- for (let i = 0; i < testArray.length; i++) {
30
- chai_1.assert.equal(testArray[i], outArray[i], `content at offset ${i} missmatch`);
31
- }
32
- chai_1.assert.equal(fs.lstatSync(testFile).size, testArray.length, "file size must match");
33
- fs.appendFileSync(testFile, testArray);
34
- // binary test
35
- const outArrayx2 = fs.readFileSync(testFile, { encoding: null });
36
- chai_1.assert.equal(outArrayx2.length, testArray.length * 2, "array size must match after append");
37
- for (let i = 0; i < testArray.length; i++) {
38
- chai_1.assert.equal(testArray[i], outArrayx2[i], `content at offset ${i} missmatch after append`);
39
- }
40
- // check append
41
- for (let k = 0; k < testArray.length; k++) {
42
- chai_1.assert.equal(testArray[k], outArrayx2[k + testArray.length], `content at offset ${k} missmatch after append`);
43
- }
44
- chai_1.assert.equal(fs.lstatSync(testFile).size, testArray.length * 2, "file size must match after append");
45
- fs.unlinkSync(testFile);
46
- chai_1.assert.isFalse(fs.existsSync(testFile));
47
- });
48
- it("Filesystem (string) - writeFileSync, appendFileSync and readFileSync", () => {
49
- const testDir = path.join(outputDir, "mobile-introp");
50
- const testFile = path.join(testDir, "test.bin");
51
- if (fs.existsSync(testDir)) {
52
- fs.unlinkSync(testDir);
53
- }
54
- fs.mkdirSync(testDir);
55
- chai_1.assert.isTrue(fs.existsSync(testDir));
56
- const testString = "*".repeat(1024);
57
- fs.writeFileSync(testFile, testString);
58
- // string test
59
- const outString = fs.readFileSync(testFile, { encoding: "utf-8" });
60
- chai_1.assert.equal(testString, outString);
61
- fs.appendFileSync(testFile, testString);
62
- const outStringx2 = fs.readFileSync(testFile, { encoding: "utf-8" });
63
- chai_1.assert.equal(testString.length * 2, outStringx2.length);
64
- chai_1.assert.equal(testString + testString, outStringx2);
65
- fs.unlinkSync(testFile);
66
- chai_1.assert.isFalse(fs.existsSync(testFile));
67
- });
68
- /*
69
- - (bool) existsSync: (NSString*)path;
70
- - (void) unlinkSync: (NSString*)path;
71
- - (void) removeSync: (NSString*)path;
72
- - (void) mkdirSync: (NSString*)path;
73
- - (void) rmdirSync: (NSString*)path;
74
- - (void) appendFileSync: (NSString*)path :(JSValue*)data;
75
- - (NSArray<NSString*>*) readdirSync: (NSString*)path;
76
- - (void) writeFileSync: (NSString*)path :(JSValue*)content;
77
- - (void) copySync: (NSString*)fromPath :(NSString*)toPath;
78
- - (JSValue*) lstatSync: (JSValue*)path;
79
- - (JSValue*) readFileSync: (JSValue*)path :(JSValue*)options;
80
- - (JSValue*) istatSync: (JSValue*)path;
81
- - (NSString*) realpathSync: (JSValue*)path :(JSValue*)options;
82
- - (void) closeSync: (JSValue*)fd;
83
- - (JSValue*) openSync: (NSString*)path :(NSString*)flags :(JSValue*)mode; */
84
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*---------------------------------------------------------------------------------------------
4
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
+ * See LICENSE.md in the project root for license terms and full copyright notice.
6
+ *--------------------------------------------------------------------------------------------*/
7
+ const chai_1 = require("chai");
8
+ const fs = require("fs-extra");
9
+ const os = require("os");
10
+ const path = require("path");
11
+ const outputDir = path.join(os.tmpdir(), "output");
12
+ describe("IOS Platform Test", () => {
13
+ it("Filesystem (Uint8Array) - writeFileSync, appendFileSync and readFileSync", () => {
14
+ const testDir = path.join(outputDir, "mobile-introp");
15
+ const testFile = path.join(testDir, "test.bin");
16
+ if (fs.existsSync(testDir)) {
17
+ fs.unlinkSync(testDir);
18
+ }
19
+ fs.mkdirSync(testDir);
20
+ chai_1.assert.isTrue(fs.existsSync(testDir));
21
+ const testArray = new Uint8Array(1024);
22
+ for (let i = 0; i < testArray.length; i++) {
23
+ testArray[i] = i % 255;
24
+ }
25
+ fs.writeFileSync(testFile, testArray);
26
+ // binary test
27
+ const outArray = fs.readFileSync(testFile, { encoding: null });
28
+ chai_1.assert.equal(outArray.length, testArray.length, "array size must match");
29
+ for (let i = 0; i < testArray.length; i++) {
30
+ chai_1.assert.equal(testArray[i], outArray[i], `content at offset ${i} missmatch`);
31
+ }
32
+ chai_1.assert.equal(fs.lstatSync(testFile).size, testArray.length, "file size must match");
33
+ fs.appendFileSync(testFile, testArray);
34
+ // binary test
35
+ const outArrayx2 = fs.readFileSync(testFile, { encoding: null });
36
+ chai_1.assert.equal(outArrayx2.length, testArray.length * 2, "array size must match after append");
37
+ for (let i = 0; i < testArray.length; i++) {
38
+ chai_1.assert.equal(testArray[i], outArrayx2[i], `content at offset ${i} missmatch after append`);
39
+ }
40
+ // check append
41
+ for (let k = 0; k < testArray.length; k++) {
42
+ chai_1.assert.equal(testArray[k], outArrayx2[k + testArray.length], `content at offset ${k} missmatch after append`);
43
+ }
44
+ chai_1.assert.equal(fs.lstatSync(testFile).size, testArray.length * 2, "file size must match after append");
45
+ fs.unlinkSync(testFile);
46
+ chai_1.assert.isFalse(fs.existsSync(testFile));
47
+ });
48
+ it("Filesystem (string) - writeFileSync, appendFileSync and readFileSync", () => {
49
+ const testDir = path.join(outputDir, "mobile-introp");
50
+ const testFile = path.join(testDir, "test.bin");
51
+ if (fs.existsSync(testDir)) {
52
+ fs.unlinkSync(testDir);
53
+ }
54
+ fs.mkdirSync(testDir);
55
+ chai_1.assert.isTrue(fs.existsSync(testDir));
56
+ const testString = "*".repeat(1024);
57
+ fs.writeFileSync(testFile, testString);
58
+ // string test
59
+ const outString = fs.readFileSync(testFile, { encoding: "utf-8" });
60
+ chai_1.assert.equal(testString, outString);
61
+ fs.appendFileSync(testFile, testString);
62
+ const outStringx2 = fs.readFileSync(testFile, { encoding: "utf-8" });
63
+ chai_1.assert.equal(testString.length * 2, outStringx2.length);
64
+ chai_1.assert.equal(testString + testString, outStringx2);
65
+ fs.unlinkSync(testFile);
66
+ chai_1.assert.isFalse(fs.existsSync(testFile));
67
+ });
68
+ /*
69
+ - (bool) existsSync: (NSString*)path;
70
+ - (void) unlinkSync: (NSString*)path;
71
+ - (void) removeSync: (NSString*)path;
72
+ - (void) mkdirSync: (NSString*)path;
73
+ - (void) rmdirSync: (NSString*)path;
74
+ - (void) appendFileSync: (NSString*)path :(JSValue*)data;
75
+ - (NSArray<NSString*>*) readdirSync: (NSString*)path;
76
+ - (void) writeFileSync: (NSString*)path :(JSValue*)content;
77
+ - (void) copySync: (NSString*)fromPath :(NSString*)toPath;
78
+ - (JSValue*) lstatSync: (JSValue*)path;
79
+ - (JSValue*) readFileSync: (JSValue*)path :(JSValue*)options;
80
+ - (JSValue*) istatSync: (JSValue*)path;
81
+ - (NSString*) realpathSync: (JSValue*)path :(JSValue*)options;
82
+ - (void) closeSync: (JSValue*)fd;
83
+ - (JSValue*) openSync: (NSString*)path :(NSString*)flags :(JSValue*)mode; */
84
+ });
85
85
  //# sourceMappingURL=MobilePlatform.test.js.map
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@itwin/core-mobile",
3
- "version": "4.0.0-dev.7",
3
+ "version": "4.0.0-dev.70",
4
4
  "description": "iTwin.js MobileHost and MobileApp",
5
5
  "license": "MIT",
6
6
  "engines": {
7
- "node": ">=16.13.0 < 19.0"
7
+ "node": "^18.0.0"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/iTwin/itwinjs-core/tree/master/core/core-mobile"
11
+ "url": "https://github.com/iTwin/itwinjs-core.git",
12
+ "directory": "core/mobile"
12
13
  },
13
14
  "keywords": [
14
15
  "Bentley",
@@ -21,11 +22,11 @@
21
22
  "url": "http://www.bentley.com"
22
23
  },
23
24
  "peerDependencies": {
24
- "@itwin/core-backend": "^4.0.0-dev.7",
25
- "@itwin/core-bentley": "^4.0.0-dev.7",
26
- "@itwin/core-common": "^4.0.0-dev.7",
27
- "@itwin/core-frontend": "^4.0.0-dev.7",
28
- "@itwin/presentation-common": "^4.0.0-dev.7"
25
+ "@itwin/core-backend": "^4.0.0-dev.70",
26
+ "@itwin/core-bentley": "^4.0.0-dev.70",
27
+ "@itwin/core-common": "^4.0.0-dev.70",
28
+ "@itwin/core-frontend": "^4.0.0-dev.70",
29
+ "@itwin/presentation-common": "^4.0.0-dev.70"
29
30
  },
30
31
  "dependencies": {
31
32
  "deep-assign": "^2.0.0",
@@ -36,19 +37,19 @@
36
37
  "ws": "^7.5.3"
37
38
  },
38
39
  "devDependencies": {
39
- "@itwin/build-tools": "4.0.0-dev.7",
40
- "@itwin/core-backend": "4.0.0-dev.7",
41
- "@itwin/core-bentley": "4.0.0-dev.7",
42
- "@itwin/core-common": "4.0.0-dev.7",
43
- "@itwin/core-frontend": "4.0.0-dev.7",
44
- "@itwin/eslint-plugin": "4.0.0-dev.7",
45
- "@itwin/presentation-common": "4.0.0-dev.7",
40
+ "@itwin/build-tools": "4.0.0-dev.70",
41
+ "@itwin/core-backend": "4.0.0-dev.70",
42
+ "@itwin/core-bentley": "4.0.0-dev.70",
43
+ "@itwin/core-common": "4.0.0-dev.70",
44
+ "@itwin/core-frontend": "4.0.0-dev.70",
45
+ "@itwin/eslint-plugin": "^4.0.0-dev.32",
46
+ "@itwin/presentation-common": "4.0.0-dev.70",
46
47
  "@types/chai": "4.3.1",
47
48
  "@types/deep-assign": "^0.1.0",
48
49
  "@types/fs-extra": "^4.0.7",
49
50
  "@types/lodash": "^4.14.0",
50
51
  "@types/mocha": "^8.2.2",
51
- "@types/node": "18.11.5",
52
+ "@types/node": "^18.11.5",
52
53
  "@types/qs": "^6.5.0",
53
54
  "@types/superagent": "^4.1.14",
54
55
  "@types/ws": "^7.0.0",
@@ -60,7 +61,7 @@
60
61
  "js-base64": "^3.6.1",
61
62
  "mocha": "^10.0.0",
62
63
  "rimraf": "^3.0.2",
63
- "typescript": "~4.4.0"
64
+ "typescript": "~5.0.2"
64
65
  },
65
66
  "eslintConfig": {
66
67
  "plugins": [
@@ -70,7 +71,6 @@
70
71
  },
71
72
  "scripts": {
72
73
  "build": "npm run -s build:cjs",
73
- "build:ci": "npm run -s build",
74
74
  "build:cjs": "tsc 1>&2 --outDir lib/cjs",
75
75
  "clean": "rimraf lib .rush/temp/package-deps*.json",
76
76
  "docs": "betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/core-mobile/file.json --tsIndexFile=./__DOC_ONLY__.ts --onlyJson",