@etsoo/appscript 1.5.86 → 1.5.88

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.
@@ -48,6 +48,8 @@ test("Tests for encrypt / decrypt", async () => {
48
48
  const input = "Hello, world!";
49
49
  const passphrase = "My password";
50
50
 
51
+ await new Promise((resolve) => setTimeout(resolve, 100));
52
+
51
53
  // Act
52
54
  const encrypted = app.encrypt(input, passphrase);
53
55
  const plain = app.decrypt(encrypted, passphrase);
@@ -59,6 +61,8 @@ test("Tests for encryptEnhanced / decryptEnhanced", async () => {
59
61
  const input = "Hello, world!";
60
62
  const passphrase = "My password";
61
63
 
64
+ await new Promise((resolve) => setTimeout(resolve, 100));
65
+
62
66
  // Act
63
67
  const encrypted = app.encryptEnhanced(input, passphrase);
64
68
  const plain = app.decryptEnhanced(encrypted, passphrase);
@@ -56,7 +56,7 @@ var container = new NotificationContainerTest((update) => {});
56
56
 
57
57
  // Is local test (integration test)
58
58
  // Make sure your local environment is ready
59
- export const isLocalTest = process.env.NODE_ENV === "local";
59
+ export const isLocalTest = vi.stubEnv("NODE_ENV", "local");
60
60
 
61
61
  // Test application class
62
62
  export class TestApp extends CoreApp<
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "Node10",
4
+ "module": "ES2020",
5
+ "moduleResolution": "bundler",
6
6
  "allowJs": false,
7
- "skipLibCheck": true,
7
+ "skipLibCheck": false,
8
8
  "esModuleInterop": true,
9
9
  "allowSyntheticDefaultImports": true,
10
10
  "strict": true,
@@ -12,7 +12,8 @@
12
12
  "resolveJsonModule": true,
13
13
  "isolatedModules": true,
14
14
  "noEmit": true,
15
- "declaration": true
15
+ "declaration": true,
16
+ "types": ["vitest/globals"]
16
17
  },
17
18
  "include": [".."]
18
19
  }
@@ -603,8 +603,9 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
603
603
  * Refresh token with success
604
604
  * @param user User data
605
605
  * @param token Refresh token
606
+ * @param callback Callback
606
607
  */
607
- protected refreshTokenSucceed(user: U, token: string): Promise<void>;
608
+ protected refreshTokenSucceed(user: U, token: string, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
608
609
  /**
609
610
  * Setup callback
610
611
  */
@@ -1421,9 +1421,7 @@ class CoreApp {
1421
1421
  }
1422
1422
  else {
1423
1423
  // Further processing
1424
- await this.refreshTokenSucceed(result.data, token);
1425
- // Callback
1426
- callback?.(true);
1424
+ await this.refreshTokenSucceed(result.data, token, callback);
1427
1425
  // Exit
1428
1426
  return;
1429
1427
  }
@@ -1460,10 +1458,13 @@ class CoreApp {
1460
1458
  * Refresh token with success
1461
1459
  * @param user User data
1462
1460
  * @param token Refresh token
1461
+ * @param callback Callback
1463
1462
  */
1464
- async refreshTokenSucceed(user, token) {
1463
+ async refreshTokenSucceed(user, token, callback) {
1465
1464
  // User login
1466
1465
  this.userLogin(user, token);
1466
+ // Callback
1467
+ callback?.(true);
1467
1468
  }
1468
1469
  /**
1469
1470
  * Setup callback
@@ -603,8 +603,9 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
603
603
  * Refresh token with success
604
604
  * @param user User data
605
605
  * @param token Refresh token
606
+ * @param callback Callback
606
607
  */
607
- protected refreshTokenSucceed(user: U, token: string): Promise<void>;
608
+ protected refreshTokenSucceed(user: U, token: string, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
608
609
  /**
609
610
  * Setup callback
610
611
  */
@@ -1418,9 +1418,7 @@ export class CoreApp {
1418
1418
  }
1419
1419
  else {
1420
1420
  // Further processing
1421
- await this.refreshTokenSucceed(result.data, token);
1422
- // Callback
1423
- callback?.(true);
1421
+ await this.refreshTokenSucceed(result.data, token, callback);
1424
1422
  // Exit
1425
1423
  return;
1426
1424
  }
@@ -1457,10 +1455,13 @@ export class CoreApp {
1457
1455
  * Refresh token with success
1458
1456
  * @param user User data
1459
1457
  * @param token Refresh token
1458
+ * @param callback Callback
1460
1459
  */
1461
- async refreshTokenSucceed(user, token) {
1460
+ async refreshTokenSucceed(user, token, callback) {
1462
1461
  // User login
1463
1462
  this.userLogin(user, token);
1463
+ // Callback
1464
+ callback?.(true);
1464
1465
  }
1465
1466
  /**
1466
1467
  * Setup callback
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.86",
3
+ "version": "1.5.88",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -13,27 +13,7 @@
13
13
  },
14
14
  "scripts": {
15
15
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
16
- "format": "prettier --write src/**/*.ts",
17
- "lint": "eslint --ext .ts src/",
18
- "test": "jest",
19
- "test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand"
20
- },
21
- "jest": {
22
- "automock": false,
23
- "testMatch": [
24
- "<rootDir>/__tests__/**/*.ts"
25
- ],
26
- "testPathIgnorePatterns": [
27
- "<rootDir>/__tests__/app/TestApp.ts"
28
- ],
29
- "testEnvironment": "jsdom",
30
- "transform": {
31
- ".+\\.jsx?$": "babel-jest",
32
- ".+\\.tsx?$": "ts-jest"
33
- },
34
- "transformIgnorePatterns": [
35
- "/node_modules/(?!@etsoo/).+\\.js$"
36
- ]
16
+ "test": "vitest"
37
17
  },
38
18
  "repository": {
39
19
  "type": "git",
@@ -48,16 +28,16 @@
48
28
  "青岛亿速思维",
49
29
  "上海亿商"
50
30
  ],
51
- "author": "Garry Xiao",
31
+ "author": "ETSOO",
52
32
  "license": "MIT",
53
33
  "bugs": {
54
34
  "url": "https://github.com/ETSOO/AppScript/issues"
55
35
  },
56
36
  "homepage": "https://github.com/ETSOO/AppScript#readme",
57
37
  "dependencies": {
58
- "@etsoo/notificationbase": "^1.1.54",
59
- "@etsoo/restclient": "^1.1.17",
60
- "@etsoo/shared": "^1.2.55",
38
+ "@etsoo/notificationbase": "^1.1.55",
39
+ "@etsoo/restclient": "^1.1.18",
40
+ "@etsoo/shared": "^1.2.57",
61
41
  "crypto-js": "^4.2.0"
62
42
  },
63
43
  "devDependencies": {
@@ -67,10 +47,9 @@
67
47
  "@babel/preset-env": "^7.26.0",
68
48
  "@babel/runtime-corejs3": "^7.26.0",
69
49
  "@types/crypto-js": "^4.2.2",
70
- "@types/jest": "^29.5.14",
71
- "jest": "^29.7.0",
72
- "jest-environment-jsdom": "^29.7.0",
73
- "ts-jest": "^29.2.5",
74
- "typescript": "^5.7.2"
50
+ "@vitejs/plugin-react": "^4.3.4",
51
+ "jsdom": "^26.0.0",
52
+ "typescript": "^5.7.3",
53
+ "vitest": "^2.1.8"
75
54
  }
76
55
  }
@@ -1937,10 +1937,7 @@ export abstract class CoreApp<
1937
1937
  };
1938
1938
  } else {
1939
1939
  // Further processing
1940
- await this.refreshTokenSucceed(result.data, token);
1941
-
1942
- // Callback
1943
- callback?.(true);
1940
+ await this.refreshTokenSucceed(result.data, token, callback);
1944
1941
 
1945
1942
  // Exit
1946
1943
  return;
@@ -1980,10 +1977,18 @@ export abstract class CoreApp<
1980
1977
  * Refresh token with success
1981
1978
  * @param user User data
1982
1979
  * @param token Refresh token
1980
+ * @param callback Callback
1983
1981
  */
1984
- protected async refreshTokenSucceed(user: U, token: string) {
1982
+ protected async refreshTokenSucceed(
1983
+ user: U,
1984
+ token: string,
1985
+ callback?: (result?: boolean | IActionResult) => boolean | void
1986
+ ) {
1985
1987
  // User login
1986
1988
  this.userLogin(user, token);
1989
+
1990
+ // Callback
1991
+ callback?.(true);
1987
1992
  }
1988
1993
 
1989
1994
  /**
package/tsconfig.json CHANGED
@@ -3,8 +3,8 @@
3
3
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
4
  "target": "ES2020",
5
5
  "allowJs": false,
6
- "module": "ESNext",
7
- "moduleResolution": "Node10",
6
+ "module": "ES2020",
7
+ "moduleResolution": "bundler",
8
8
  "resolveJsonModule": true,
9
9
  "isolatedModules": true,
10
10
  "outDir": "./lib/mjs",
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "vitest/config";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ test: {
7
+ globals: true,
8
+ environment: "jsdom",
9
+ include: ["__tests__/**/*.ts(x)?"],
10
+ exclude: ["__tests__/app/TestApp.ts"]
11
+ }
12
+ });