@etsoo/appscript 1.5.50 → 1.5.51

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,10 +1,29 @@
1
- import { zhHans } from '../../src';
1
+ import { en, zhHans } from '../../src';
2
+
3
+ test('Tests for en', async () => {
4
+ const e = en(
5
+ { nameB: 'Name for Business' },
6
+ new Promise((resolve) => resolve({ no: 'No override' }))
7
+ );
8
+
9
+ expect(e.name).toBe('en');
10
+
11
+ const resources =
12
+ typeof e.resources === 'object' ? e.resources : await e.resources();
13
+
14
+ expect(resources.name).toBe('Name');
15
+ expect(resources.nameB).toBe('Name for Business');
16
+ expect(resources.no).toBe('No override');
17
+ });
2
18
 
3
19
  test('Tests for zhHans', async () => {
4
20
  const zh = zhHans(
5
21
  { nameB: '名称覆盖' },
6
22
  new Promise((resolve) => resolve({ no: 'No override' }))
7
23
  );
24
+
25
+ expect(zh.name).toBe('zh-Hans');
26
+
8
27
  const resources =
9
28
  typeof zh.resources === 'object' ? zh.resources : await zh.resources();
10
29
 
@@ -1,12 +1,13 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, DomUtils } from '@etsoo/shared';
2
2
  /**
3
3
  * Culture utilities
4
4
  */
5
5
  export declare namespace CultureUtils {
6
6
  /**
7
7
  * Make culture
8
+ * @param cultureMaker Culture maker
8
9
  * @param resources Resources
9
10
  * @returns Culture
10
11
  */
11
- function make(...resources: (object | (() => Promise<object>))[]): DataTypes.CultureDefinition<DataTypes.StringRecord>;
12
+ function make(cultureMaker: typeof DomUtils.zhHans, ...resources: (object | (() => Promise<object>))[]): DataTypes.CultureDefinition<DataTypes.StringRecord>;
12
13
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CultureUtils = void 0;
4
- const shared_1 = require("@etsoo/shared");
5
4
  /**
6
5
  * Culture utilities
7
6
  */
@@ -9,11 +8,12 @@ var CultureUtils;
9
8
  (function (CultureUtils) {
10
9
  /**
11
10
  * Make culture
11
+ * @param cultureMaker Culture maker
12
12
  * @param resources Resources
13
13
  * @returns Culture
14
14
  */
15
- function make(...resources) {
16
- return shared_1.DomUtils.zhHans(async () => {
15
+ function make(cultureMaker, ...resources) {
16
+ return cultureMaker(async () => {
17
17
  const rs = await Promise.all(resources.map((resource) => new Promise((resolve) => {
18
18
  if (typeof resource === 'object') {
19
19
  resolve(resource);
@@ -1,11 +1,12 @@
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
5
  const CultureUtils_1 = require("./CultureUtils");
5
6
  /**
6
7
  * Get en neutral culture
7
8
  * @param localResources Local resources
8
9
  * @returns Full culture
9
10
  */
10
- const en = (...resources) => CultureUtils_1.CultureUtils.make(import('./en.json'), ...resources);
11
+ const en = (...resources) => CultureUtils_1.CultureUtils.make(shared_1.DomUtils.en, import('./en.json'), ...resources);
11
12
  exports.en = en;
@@ -1,11 +1,12 @@
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
5
  const CultureUtils_1 = require("./CultureUtils");
5
6
  /**
6
7
  * Get zh-Hans neutral cultrue
7
8
  * @param localResources Local resources
8
9
  * @returns Full culture
9
10
  */
10
- const zhHans = (...resources) => CultureUtils_1.CultureUtils.make(import('./zh-Hans.json'), ...resources);
11
+ const zhHans = (...resources) => CultureUtils_1.CultureUtils.make(shared_1.DomUtils.zhHans, import('./zh-Hans.json'), ...resources);
11
12
  exports.zhHans = zhHans;
@@ -1,11 +1,12 @@
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
5
  const CultureUtils_1 = require("./CultureUtils");
5
6
  /**
6
7
  * Get zh-Hant neutral cultrue
7
8
  * @param localResources Local resources
8
9
  * @returns Full culture
9
10
  */
10
- const zhHant = (...resources) => CultureUtils_1.CultureUtils.make(import('./zh-Hant.json'), ...resources);
11
+ const zhHant = (...resources) => CultureUtils_1.CultureUtils.make(shared_1.DomUtils.zhHant, import('./zh-Hant.json'), ...resources);
11
12
  exports.zhHant = zhHant;
@@ -1,12 +1,13 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, DomUtils } from '@etsoo/shared';
2
2
  /**
3
3
  * Culture utilities
4
4
  */
5
5
  export declare namespace CultureUtils {
6
6
  /**
7
7
  * Make culture
8
+ * @param cultureMaker Culture maker
8
9
  * @param resources Resources
9
10
  * @returns Culture
10
11
  */
11
- function make(...resources: (object | (() => Promise<object>))[]): DataTypes.CultureDefinition<DataTypes.StringRecord>;
12
+ function make(cultureMaker: typeof DomUtils.zhHans, ...resources: (object | (() => Promise<object>))[]): DataTypes.CultureDefinition<DataTypes.StringRecord>;
12
13
  }
@@ -1,4 +1,3 @@
1
- import { DomUtils } from '@etsoo/shared';
2
1
  /**
3
2
  * Culture utilities
4
3
  */
@@ -6,11 +5,12 @@ export var CultureUtils;
6
5
  (function (CultureUtils) {
7
6
  /**
8
7
  * Make culture
8
+ * @param cultureMaker Culture maker
9
9
  * @param resources Resources
10
10
  * @returns Culture
11
11
  */
12
- function make(...resources) {
13
- return DomUtils.zhHans(async () => {
12
+ function make(cultureMaker, ...resources) {
13
+ return cultureMaker(async () => {
14
14
  const rs = await Promise.all(resources.map((resource) => new Promise((resolve) => {
15
15
  if (typeof resource === 'object') {
16
16
  resolve(resource);
@@ -1,7 +1,8 @@
1
+ import { DomUtils } from '@etsoo/shared';
1
2
  import { CultureUtils } from './CultureUtils';
2
3
  /**
3
4
  * Get en neutral culture
4
5
  * @param localResources Local resources
5
6
  * @returns Full culture
6
7
  */
7
- export const en = (...resources) => CultureUtils.make(import('./en.json'), ...resources);
8
+ export const en = (...resources) => CultureUtils.make(DomUtils.en, import('./en.json'), ...resources);
@@ -1,7 +1,8 @@
1
+ import { DomUtils } from '@etsoo/shared';
1
2
  import { CultureUtils } from './CultureUtils';
2
3
  /**
3
4
  * Get zh-Hans neutral cultrue
4
5
  * @param localResources Local resources
5
6
  * @returns Full culture
6
7
  */
7
- export const zhHans = (...resources) => CultureUtils.make(import('./zh-Hans.json'), ...resources);
8
+ export const zhHans = (...resources) => CultureUtils.make(DomUtils.zhHans, import('./zh-Hans.json'), ...resources);
@@ -1,7 +1,8 @@
1
+ import { DomUtils } from '@etsoo/shared';
1
2
  import { CultureUtils } from './CultureUtils';
2
3
  /**
3
4
  * Get zh-Hant neutral cultrue
4
5
  * @param localResources Local resources
5
6
  * @returns Full culture
6
7
  */
7
- export const zhHant = (...resources) => CultureUtils.make(import('./zh-Hant.json'), ...resources);
8
+ export const zhHant = (...resources) => CultureUtils.make(DomUtils.zhHant, import('./zh-Hant.json'), ...resources);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.50",
3
+ "version": "1.5.51",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -52,9 +52,9 @@
52
52
  },
53
53
  "homepage": "https://github.com/ETSOO/AppScript#readme",
54
54
  "dependencies": {
55
- "@etsoo/notificationbase": "^1.1.49",
56
- "@etsoo/restclient": "^1.1.11",
57
- "@etsoo/shared": "^1.2.48",
55
+ "@etsoo/notificationbase": "^1.1.50",
56
+ "@etsoo/restclient": "^1.1.12",
57
+ "@etsoo/shared": "^1.2.49",
58
58
  "crypto-js": "^4.2.0"
59
59
  },
60
60
  "devDependencies": {
@@ -6,11 +6,15 @@ import { DataTypes, DomUtils } from '@etsoo/shared';
6
6
  export namespace CultureUtils {
7
7
  /**
8
8
  * Make culture
9
+ * @param cultureMaker Culture maker
9
10
  * @param resources Resources
10
11
  * @returns Culture
11
12
  */
12
- export function make(...resources: (object | (() => Promise<object>))[]) {
13
- return DomUtils.zhHans(async () => {
13
+ export function make(
14
+ cultureMaker: typeof DomUtils.zhHans,
15
+ ...resources: (object | (() => Promise<object>))[]
16
+ ) {
17
+ return cultureMaker(async () => {
14
18
  const rs = await Promise.all(
15
19
  resources.map(
16
20
  (resource) =>
package/src/i18n/en.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DomUtils } from '@etsoo/shared';
1
2
  import { CultureUtils } from './CultureUtils';
2
3
 
3
4
  /**
@@ -6,4 +7,4 @@ import { CultureUtils } from './CultureUtils';
6
7
  * @returns Full culture
7
8
  */
8
9
  export const en = (...resources: (object | (() => Promise<object>))[]) =>
9
- CultureUtils.make(import('./en.json'), ...resources);
10
+ CultureUtils.make(DomUtils.en, import('./en.json'), ...resources);
@@ -1,3 +1,4 @@
1
+ import { DomUtils } from '@etsoo/shared';
1
2
  import { CultureUtils } from './CultureUtils';
2
3
 
3
4
  /**
@@ -6,4 +7,4 @@ import { CultureUtils } from './CultureUtils';
6
7
  * @returns Full culture
7
8
  */
8
9
  export const zhHans = (...resources: (object | (() => Promise<object>))[]) =>
9
- CultureUtils.make(import('./zh-Hans.json'), ...resources);
10
+ CultureUtils.make(DomUtils.zhHans, import('./zh-Hans.json'), ...resources);
@@ -1,3 +1,4 @@
1
+ import { DomUtils } from '@etsoo/shared';
1
2
  import { CultureUtils } from './CultureUtils';
2
3
 
3
4
  /**
@@ -6,4 +7,4 @@ import { CultureUtils } from './CultureUtils';
6
7
  * @returns Full culture
7
8
  */
8
9
  export const zhHant = (...resources: (object | (() => Promise<object>))[]) =>
9
- CultureUtils.make(import('./zh-Hant.json'), ...resources);
10
+ CultureUtils.make(DomUtils.zhHant, import('./zh-Hant.json'), ...resources);