@etsoo/appscript 1.5.36 → 1.5.38

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.
@@ -0,0 +1,14 @@
1
+ import { zhHans } from '../../src';
2
+
3
+ test('Tests for zhHans', async () => {
4
+ const zh = zhHans(
5
+ { nameB: '名称覆盖' },
6
+ new Promise((resolve) => resolve({ no: 'No override' }))
7
+ );
8
+ const resources =
9
+ typeof zh.resources === 'object' ? zh.resources : await zh.resources();
10
+
11
+ expect(resources.name).toBe('姓名');
12
+ expect(resources.nameB).toBe('名称覆盖');
13
+ expect(resources.no).toBe('No override');
14
+ });
@@ -1610,7 +1610,7 @@ class CoreApp {
1610
1610
  }
1611
1611
  // Is web way?
1612
1612
  // Pass the true embedded status from parent to child (Both conditions are true)
1613
- if (isWeb && embedded && globalThis.self !== globalThis.parent) {
1613
+ if (isWeb && embedded && globalThis.self === globalThis.parent) {
1614
1614
  embedded = false;
1615
1615
  }
1616
1616
  // Ignore the same value
@@ -0,0 +1,12 @@
1
+ import { DataTypes } from '@etsoo/shared';
2
+ /**
3
+ * Culture utilities
4
+ */
5
+ export declare namespace CultureUtils {
6
+ /**
7
+ * Make culture
8
+ * @param resources Resources
9
+ * @returns Culture
10
+ */
11
+ function make(...resources: (object | (() => Promise<object>))[]): DataTypes.CultureDefinition<DataTypes.StringRecord>;
12
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CultureUtils = void 0;
4
+ const shared_1 = require("@etsoo/shared");
5
+ /**
6
+ * Culture utilities
7
+ */
8
+ var CultureUtils;
9
+ (function (CultureUtils) {
10
+ /**
11
+ * Make culture
12
+ * @param resources Resources
13
+ * @returns Culture
14
+ */
15
+ function make(...resources) {
16
+ return shared_1.DomUtils.zhHans(async () => {
17
+ const rs = await Promise.all([
18
+ ...resources.map((resource) => new Promise((resolve) => {
19
+ if (typeof resource === 'object') {
20
+ resolve(resource);
21
+ }
22
+ else {
23
+ resource().then((result) => resolve(result));
24
+ }
25
+ }))
26
+ ]);
27
+ return rs.reduce((prev, curr) => ({
28
+ ...prev,
29
+ ...curr
30
+ }));
31
+ });
32
+ }
33
+ CultureUtils.make = make;
34
+ })(CultureUtils || (exports.CultureUtils = CultureUtils = {}));
@@ -1,7 +1,6 @@
1
- import { DataTypes } from '@etsoo/shared';
2
1
  /**
3
2
  * Get en neutral culture
4
3
  * @param localResources Local resources
5
4
  * @returns Full culture
6
5
  */
7
- export declare const en: (resources: object | (() => Promise<object>)) => DataTypes.CultureDefinition<DataTypes.StringRecord>;
6
+ export declare const en: (...resources: (object | (() => Promise<object>))[]) => import("@etsoo/shared").DataTypes.CultureDefinition<import("@etsoo/shared").DataTypes.StringRecord>;
@@ -1,24 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.en = void 0;
4
- const shared_1 = require("@etsoo/shared");
4
+ const CultureUtils_1 = require("./CultureUtils");
5
5
  /**
6
6
  * Get en neutral culture
7
7
  * @param localResources Local resources
8
8
  * @returns Full culture
9
9
  */
10
- const en = (resources) => shared_1.DomUtils.en(async () => {
11
- const [r1, r2] = await Promise.all([
12
- import('./en.json'),
13
- new Promise((resolve) => {
14
- if (typeof resources === 'object') {
15
- resolve(resources);
16
- }
17
- else {
18
- resources().then((result) => resolve(result));
19
- }
20
- })
21
- ]);
22
- return { ...r1, ...r2 };
23
- });
10
+ const en = (...resources) => CultureUtils_1.CultureUtils.make(import('./en.json'), ...resources);
24
11
  exports.en = en;
@@ -1,7 +1,6 @@
1
- import { DataTypes } from '@etsoo/shared';
2
1
  /**
3
2
  * Get zh-Hans neutral cultrue
4
3
  * @param localResources Local resources
5
4
  * @returns Full culture
6
5
  */
7
- export declare const zhHans: (resources: object | (() => Promise<object>)) => DataTypes.CultureDefinition<DataTypes.StringRecord>;
6
+ export declare const zhHans: (...resources: (object | (() => Promise<object>))[]) => import("@etsoo/shared").DataTypes.CultureDefinition<import("@etsoo/shared").DataTypes.StringRecord>;
@@ -1,24 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.zhHans = void 0;
4
- const shared_1 = require("@etsoo/shared");
4
+ const CultureUtils_1 = require("./CultureUtils");
5
5
  /**
6
6
  * Get zh-Hans neutral cultrue
7
7
  * @param localResources Local resources
8
8
  * @returns Full culture
9
9
  */
10
- const zhHans = (resources) => shared_1.DomUtils.zhHans(async () => {
11
- const [r1, r2] = await Promise.all([
12
- import('./zh-Hans.json'),
13
- new Promise((resolve) => {
14
- if (typeof resources === 'object') {
15
- resolve(resources);
16
- }
17
- else {
18
- resources().then((result) => resolve(result));
19
- }
20
- })
21
- ]);
22
- return { ...r1, ...r2 };
23
- });
10
+ const zhHans = (...resources) => CultureUtils_1.CultureUtils.make(import('./zh-Hans.json'), ...resources);
24
11
  exports.zhHans = zhHans;
@@ -1,7 +1,6 @@
1
- import { DataTypes } from '@etsoo/shared';
2
1
  /**
3
2
  * Get zh-Hant neutral cultrue
4
3
  * @param localResources Local resources
5
4
  * @returns Full culture
6
5
  */
7
- export declare const zhHant: (resources: object | (() => Promise<object>)) => DataTypes.CultureDefinition<DataTypes.StringRecord>;
6
+ export declare const zhHant: (...resources: (object | (() => Promise<object>))[]) => import("@etsoo/shared").DataTypes.CultureDefinition<import("@etsoo/shared").DataTypes.StringRecord>;
@@ -1,24 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.zhHant = void 0;
4
- const shared_1 = require("@etsoo/shared");
4
+ const CultureUtils_1 = require("./CultureUtils");
5
5
  /**
6
6
  * Get zh-Hant neutral cultrue
7
7
  * @param localResources Local resources
8
8
  * @returns Full culture
9
9
  */
10
- const zhHant = (resources) => shared_1.DomUtils.zhHant(async () => {
11
- const [r1, r2] = await Promise.all([
12
- import('./zh-Hant.json'),
13
- new Promise((resolve) => {
14
- if (typeof resources === 'object') {
15
- resolve(resources);
16
- }
17
- else {
18
- resources().then((result) => resolve(result));
19
- }
20
- })
21
- ]);
22
- return { ...r1, ...r2 };
23
- });
10
+ const zhHant = (...resources) => CultureUtils_1.CultureUtils.make(import('./zh-Hant.json'), ...resources);
24
11
  exports.zhHant = zhHant;
@@ -71,6 +71,7 @@ export * from './erp/EntityApi';
71
71
  export * from './erp/MemberApi';
72
72
  export * from './erp/OrgApi';
73
73
  export * from './erp/PublicApi';
74
+ export * from './i18n/CultureUtils';
74
75
  export * from './i18n/en';
75
76
  export * from './i18n/zhHans';
76
77
  export * from './i18n/zhHant';
package/lib/cjs/index.js CHANGED
@@ -98,6 +98,7 @@ __exportStar(require("./erp/MemberApi"), exports);
98
98
  __exportStar(require("./erp/OrgApi"), exports);
99
99
  __exportStar(require("./erp/PublicApi"), exports);
100
100
  // i18n
101
+ __exportStar(require("./i18n/CultureUtils"), exports);
101
102
  __exportStar(require("./i18n/en"), exports);
102
103
  __exportStar(require("./i18n/zhHans"), exports);
103
104
  __exportStar(require("./i18n/zhHant"), exports);
@@ -1607,7 +1607,7 @@ export class CoreApp {
1607
1607
  }
1608
1608
  // Is web way?
1609
1609
  // Pass the true embedded status from parent to child (Both conditions are true)
1610
- if (isWeb && embedded && globalThis.self !== globalThis.parent) {
1610
+ if (isWeb && embedded && globalThis.self === globalThis.parent) {
1611
1611
  embedded = false;
1612
1612
  }
1613
1613
  // Ignore the same value
@@ -0,0 +1,12 @@
1
+ import { DataTypes } from '@etsoo/shared';
2
+ /**
3
+ * Culture utilities
4
+ */
5
+ export declare namespace CultureUtils {
6
+ /**
7
+ * Make culture
8
+ * @param resources Resources
9
+ * @returns Culture
10
+ */
11
+ function make(...resources: (object | (() => Promise<object>))[]): DataTypes.CultureDefinition<DataTypes.StringRecord>;
12
+ }
@@ -0,0 +1,31 @@
1
+ import { DomUtils } from '@etsoo/shared';
2
+ /**
3
+ * Culture utilities
4
+ */
5
+ export var CultureUtils;
6
+ (function (CultureUtils) {
7
+ /**
8
+ * Make culture
9
+ * @param resources Resources
10
+ * @returns Culture
11
+ */
12
+ function make(...resources) {
13
+ return DomUtils.zhHans(async () => {
14
+ const rs = await Promise.all([
15
+ ...resources.map((resource) => new Promise((resolve) => {
16
+ if (typeof resource === 'object') {
17
+ resolve(resource);
18
+ }
19
+ else {
20
+ resource().then((result) => resolve(result));
21
+ }
22
+ }))
23
+ ]);
24
+ return rs.reduce((prev, curr) => ({
25
+ ...prev,
26
+ ...curr
27
+ }));
28
+ });
29
+ }
30
+ CultureUtils.make = make;
31
+ })(CultureUtils || (CultureUtils = {}));
@@ -1,7 +1,6 @@
1
- import { DataTypes } from '@etsoo/shared';
2
1
  /**
3
2
  * Get en neutral culture
4
3
  * @param localResources Local resources
5
4
  * @returns Full culture
6
5
  */
7
- export declare const en: (resources: object | (() => Promise<object>)) => DataTypes.CultureDefinition<DataTypes.StringRecord>;
6
+ export declare const en: (...resources: (object | (() => Promise<object>))[]) => import("@etsoo/shared").DataTypes.CultureDefinition<import("@etsoo/shared").DataTypes.StringRecord>;
@@ -1,20 +1,7 @@
1
- import { DomUtils } from '@etsoo/shared';
1
+ import { CultureUtils } from './CultureUtils';
2
2
  /**
3
3
  * Get en neutral culture
4
4
  * @param localResources Local resources
5
5
  * @returns Full culture
6
6
  */
7
- export const en = (resources) => DomUtils.en(async () => {
8
- const [r1, r2] = await Promise.all([
9
- import('./en.json'),
10
- new Promise((resolve) => {
11
- if (typeof resources === 'object') {
12
- resolve(resources);
13
- }
14
- else {
15
- resources().then((result) => resolve(result));
16
- }
17
- })
18
- ]);
19
- return { ...r1, ...r2 };
20
- });
7
+ export const en = (...resources) => CultureUtils.make(import('./en.json'), ...resources);
@@ -1,7 +1,6 @@
1
- import { DataTypes } from '@etsoo/shared';
2
1
  /**
3
2
  * Get zh-Hans neutral cultrue
4
3
  * @param localResources Local resources
5
4
  * @returns Full culture
6
5
  */
7
- export declare const zhHans: (resources: object | (() => Promise<object>)) => DataTypes.CultureDefinition<DataTypes.StringRecord>;
6
+ export declare const zhHans: (...resources: (object | (() => Promise<object>))[]) => import("@etsoo/shared").DataTypes.CultureDefinition<import("@etsoo/shared").DataTypes.StringRecord>;
@@ -1,20 +1,7 @@
1
- import { DomUtils } from '@etsoo/shared';
1
+ import { CultureUtils } from './CultureUtils';
2
2
  /**
3
3
  * Get zh-Hans neutral cultrue
4
4
  * @param localResources Local resources
5
5
  * @returns Full culture
6
6
  */
7
- export const zhHans = (resources) => DomUtils.zhHans(async () => {
8
- const [r1, r2] = await Promise.all([
9
- import('./zh-Hans.json'),
10
- new Promise((resolve) => {
11
- if (typeof resources === 'object') {
12
- resolve(resources);
13
- }
14
- else {
15
- resources().then((result) => resolve(result));
16
- }
17
- })
18
- ]);
19
- return { ...r1, ...r2 };
20
- });
7
+ export const zhHans = (...resources) => CultureUtils.make(import('./zh-Hans.json'), ...resources);
@@ -1,7 +1,6 @@
1
- import { DataTypes } from '@etsoo/shared';
2
1
  /**
3
2
  * Get zh-Hant neutral cultrue
4
3
  * @param localResources Local resources
5
4
  * @returns Full culture
6
5
  */
7
- export declare const zhHant: (resources: object | (() => Promise<object>)) => DataTypes.CultureDefinition<DataTypes.StringRecord>;
6
+ export declare const zhHant: (...resources: (object | (() => Promise<object>))[]) => import("@etsoo/shared").DataTypes.CultureDefinition<import("@etsoo/shared").DataTypes.StringRecord>;
@@ -1,20 +1,7 @@
1
- import { DomUtils } from '@etsoo/shared';
1
+ import { CultureUtils } from './CultureUtils';
2
2
  /**
3
3
  * Get zh-Hant neutral cultrue
4
4
  * @param localResources Local resources
5
5
  * @returns Full culture
6
6
  */
7
- export const zhHant = (resources) => DomUtils.zhHant(async () => {
8
- const [r1, r2] = await Promise.all([
9
- import('./zh-Hant.json'),
10
- new Promise((resolve) => {
11
- if (typeof resources === 'object') {
12
- resolve(resources);
13
- }
14
- else {
15
- resources().then((result) => resolve(result));
16
- }
17
- })
18
- ]);
19
- return { ...r1, ...r2 };
20
- });
7
+ export const zhHant = (...resources) => CultureUtils.make(import('./zh-Hant.json'), ...resources);
@@ -71,6 +71,7 @@ export * from './erp/EntityApi';
71
71
  export * from './erp/MemberApi';
72
72
  export * from './erp/OrgApi';
73
73
  export * from './erp/PublicApi';
74
+ export * from './i18n/CultureUtils';
74
75
  export * from './i18n/en';
75
76
  export * from './i18n/zhHans';
76
77
  export * from './i18n/zhHant';
package/lib/mjs/index.js CHANGED
@@ -81,6 +81,7 @@ export * from './erp/MemberApi';
81
81
  export * from './erp/OrgApi';
82
82
  export * from './erp/PublicApi';
83
83
  // i18n
84
+ export * from './i18n/CultureUtils';
84
85
  export * from './i18n/en';
85
86
  export * from './i18n/zhHans';
86
87
  export * from './i18n/zhHant';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.36",
3
+ "version": "1.5.38",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -2198,7 +2198,7 @@ export abstract class CoreApp<
2198
2198
 
2199
2199
  // Is web way?
2200
2200
  // Pass the true embedded status from parent to child (Both conditions are true)
2201
- if (isWeb && embedded && globalThis.self !== globalThis.parent) {
2201
+ if (isWeb && embedded && globalThis.self === globalThis.parent) {
2202
2202
  embedded = false;
2203
2203
  }
2204
2204
 
@@ -0,0 +1,32 @@
1
+ import { DataTypes, DomUtils } from '@etsoo/shared';
2
+
3
+ /**
4
+ * Culture utilities
5
+ */
6
+ export namespace CultureUtils {
7
+ /**
8
+ * Make culture
9
+ * @param resources Resources
10
+ * @returns Culture
11
+ */
12
+ export function make(...resources: (object | (() => Promise<object>))[]) {
13
+ return DomUtils.zhHans(async () => {
14
+ const rs = await Promise.all([
15
+ ...resources.map(
16
+ (resource) =>
17
+ new Promise<object>((resolve) => {
18
+ if (typeof resource === 'object') {
19
+ resolve(resource);
20
+ } else {
21
+ resource().then((result) => resolve(result));
22
+ }
23
+ })
24
+ )
25
+ ]);
26
+ return rs.reduce((prev, curr) => ({
27
+ ...prev,
28
+ ...curr
29
+ })) as DataTypes.StringRecord;
30
+ });
31
+ }
32
+ }
package/src/i18n/en.ts CHANGED
@@ -1,21 +1,9 @@
1
- import { DataTypes, DomUtils } from '@etsoo/shared';
1
+ import { CultureUtils } from './CultureUtils';
2
2
 
3
3
  /**
4
4
  * Get en neutral culture
5
5
  * @param localResources Local resources
6
6
  * @returns Full culture
7
7
  */
8
- export const en = (resources: object | (() => Promise<object>)) =>
9
- DomUtils.en(async () => {
10
- const [r1, r2] = await Promise.all([
11
- import('./en.json'),
12
- new Promise<object>((resolve) => {
13
- if (typeof resources === 'object') {
14
- resolve(resources);
15
- } else {
16
- resources().then((result) => resolve(result));
17
- }
18
- })
19
- ]);
20
- return { ...r1, ...r2 } as DataTypes.StringRecord;
21
- });
8
+ export const en = (...resources: (object | (() => Promise<object>))[]) =>
9
+ CultureUtils.make(import('./en.json'), ...resources);
@@ -1,21 +1,9 @@
1
- import { DataTypes, DomUtils } from '@etsoo/shared';
1
+ import { CultureUtils } from './CultureUtils';
2
2
 
3
3
  /**
4
4
  * Get zh-Hans neutral cultrue
5
5
  * @param localResources Local resources
6
6
  * @returns Full culture
7
7
  */
8
- export const zhHans = (resources: object | (() => Promise<object>)) =>
9
- DomUtils.zhHans(async () => {
10
- const [r1, r2] = await Promise.all([
11
- import('./zh-Hans.json'),
12
- new Promise<object>((resolve) => {
13
- if (typeof resources === 'object') {
14
- resolve(resources);
15
- } else {
16
- resources().then((result) => resolve(result));
17
- }
18
- })
19
- ]);
20
- return { ...r1, ...r2 } as DataTypes.StringRecord;
21
- });
8
+ export const zhHans = (...resources: (object | (() => Promise<object>))[]) =>
9
+ CultureUtils.make(import('./zh-Hans.json'), ...resources);
@@ -1,21 +1,9 @@
1
- import { DataTypes, DomUtils } from '@etsoo/shared';
1
+ import { CultureUtils } from './CultureUtils';
2
2
 
3
3
  /**
4
4
  * Get zh-Hant neutral cultrue
5
5
  * @param localResources Local resources
6
6
  * @returns Full culture
7
7
  */
8
- export const zhHant = (resources: object | (() => Promise<object>)) =>
9
- DomUtils.zhHant(async () => {
10
- const [r1, r2] = await Promise.all([
11
- import('./zh-Hant.json'),
12
- new Promise<object>((resolve) => {
13
- if (typeof resources === 'object') {
14
- resolve(resources);
15
- } else {
16
- resources().then((result) => resolve(result));
17
- }
18
- })
19
- ]);
20
- return { ...r1, ...r2 } as DataTypes.StringRecord;
21
- });
8
+ export const zhHant = (...resources: (object | (() => Promise<object>))[]) =>
9
+ CultureUtils.make(import('./zh-Hant.json'), ...resources);
package/src/index.ts CHANGED
@@ -90,6 +90,7 @@ export * from './erp/OrgApi';
90
90
  export * from './erp/PublicApi';
91
91
 
92
92
  // i18n
93
+ export * from './i18n/CultureUtils';
93
94
  export * from './i18n/en';
94
95
  export * from './i18n/zhHans';
95
96
  export * from './i18n/zhHant';