@ibiz-template/core 0.2.4 → 0.2.6

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.
package/out/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from '@microsoft/fetch-event-source';
3
3
  export * from './command';
4
4
  export * from './constant';
5
5
  export { IBizContext } from './context';
6
+ export { IBizParams } from './params/params';
6
7
  export { Environment } from './environment/environment';
7
8
  export * from './error';
8
9
  export * from './interface';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,+BAA+B,CAAC;AAE9C,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,+BAA+B,CAAC;AAE9C,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/out/index.js CHANGED
@@ -3,6 +3,7 @@ export * from '@microsoft/fetch-event-source';
3
3
  export * from './command';
4
4
  export * from './constant';
5
5
  export { IBizContext } from './context';
6
+ export { IBizParams } from './params/params';
6
7
  export { Environment } from './environment/environment';
7
8
  export * from './error';
8
9
  export * from './interface';
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 视图参数类
3
+ * @author lxm
4
+ * @date 2023-10-27 03:39:12
5
+ * @export
6
+ * @class IBizParams
7
+ * @implements {IParams}
8
+ */
9
+ export declare class IBizParams implements IParams {
10
+ [key: string | symbol]: any;
11
+ /**
12
+ * 自身的属性
13
+ * @author lxm
14
+ * @date 2023-10-27 04:09:25
15
+ * @protected
16
+ * @type {IParams}
17
+ */
18
+ protected _params: IParams;
19
+ /**
20
+ * 父视图参数
21
+ * @author lxm
22
+ * @date 2023-10-27 04:08:59
23
+ * @protected
24
+ * @type {IParams}
25
+ */
26
+ protected _parent?: IParams;
27
+ constructor(params?: IParams, parent?: IParams);
28
+ /**
29
+ * 创建代理
30
+ *
31
+ * @author lxm
32
+ * @date 2023-10-27 03:53:14
33
+ * @protected
34
+ * @return {*} {IBizParams}
35
+ */
36
+ protected createProxy(): IBizParams;
37
+ /**
38
+ * 在不改变对象引用的情况下,重置视图参数
39
+ * 等效于重新实例化,但是引用不变
40
+ * @author lxm
41
+ * @date 2023-10-27 05:24:45
42
+ * @param {IParams} [params]
43
+ * @param {IParams} [parent]
44
+ */
45
+ reset(params?: IParams, parent?: IParams): void;
46
+ /**
47
+ * 销毁上下文,避免内存泄漏
48
+ *
49
+ * @author lxm
50
+ * @date 2023-10-27 03:57:44
51
+ */
52
+ destroy(): void;
53
+ }
54
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/params/params.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,qBAAa,UAAW,YAAW,OAAO;IAExC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAE5B;;;;;;OAMG;IACH,UAAkB,OAAO,EAAE,OAAO,CAAC;IAEnC;;;;;;OAMG;IACH,UAAkB,OAAO,CAAC,EAAE,OAAO,CAAC;gBAExB,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO;IAoB9C;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,IAAI,UAAU;IAmDnC;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAK/C;;;;;OAKG;IACH,OAAO,IAAI,IAAI;CAIhB"}
@@ -0,0 +1,106 @@
1
+ /* eslint-disable no-constructor-return */
2
+ /**
3
+ * 视图参数类
4
+ * @author lxm
5
+ * @date 2023-10-27 03:39:12
6
+ * @export
7
+ * @class IBizParams
8
+ * @implements {IParams}
9
+ */
10
+ export class IBizParams {
11
+ constructor(params, parent) {
12
+ // 定义私有变量,存放父视图参数源对象
13
+ Object.defineProperty(this, '_parent', {
14
+ enumerable: false,
15
+ configurable: true,
16
+ writable: true,
17
+ value: parent,
18
+ });
19
+ // 定义私有变量,用于存储对父已有视图参数的修改。
20
+ Object.defineProperty(this, '_params', {
21
+ enumerable: false,
22
+ configurable: true,
23
+ writable: true,
24
+ value: params || {},
25
+ });
26
+ return this.createProxy();
27
+ }
28
+ /**
29
+ * 创建代理
30
+ *
31
+ * @author lxm
32
+ * @date 2023-10-27 03:53:14
33
+ * @protected
34
+ * @return {*} {IBizParams}
35
+ */
36
+ createProxy() {
37
+ // 更新属性,缺的补充定义
38
+ function updateKeyDefine(target, keys) {
39
+ keys.forEach(key => {
40
+ if (!Object.prototype.hasOwnProperty.call(target, key)) {
41
+ Object.defineProperty(target, key, {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: undefined,
46
+ });
47
+ }
48
+ });
49
+ }
50
+ return new Proxy(this, {
51
+ set(target, p, value) {
52
+ if (['_params', '_parent'].includes(p)) {
53
+ target[p] = value;
54
+ }
55
+ else {
56
+ target._params[p] = value;
57
+ }
58
+ return true;
59
+ },
60
+ get(target, p, _receiver) {
61
+ if (target[p] !== undefined) {
62
+ return target[p];
63
+ }
64
+ if (target._params[p] !== undefined) {
65
+ return target._params[p];
66
+ }
67
+ if (target._parent && target._parent[p] !== undefined) {
68
+ return target._parent[p];
69
+ }
70
+ },
71
+ ownKeys(target) {
72
+ // 整合所有并排重
73
+ const allKeys = [
74
+ ...new Set([
75
+ ...Object.keys(target._params),
76
+ ...Object.keys(target._parent || {}),
77
+ ]),
78
+ ];
79
+ updateKeyDefine(target, allKeys);
80
+ return allKeys;
81
+ },
82
+ });
83
+ }
84
+ /**
85
+ * 在不改变对象引用的情况下,重置视图参数
86
+ * 等效于重新实例化,但是引用不变
87
+ * @author lxm
88
+ * @date 2023-10-27 05:24:45
89
+ * @param {IParams} [params]
90
+ * @param {IParams} [parent]
91
+ */
92
+ reset(params, parent) {
93
+ this._params = params || {};
94
+ this._parent = parent;
95
+ }
96
+ /**
97
+ * 销毁上下文,避免内存泄漏
98
+ *
99
+ * @author lxm
100
+ * @date 2023-10-27 03:57:44
101
+ */
102
+ destroy() {
103
+ this._params = {};
104
+ this._parent = undefined;
105
+ }
106
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/core",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "核心包",
5
5
  "type": "module",
6
6
  "main": "out/index.js",
@@ -50,5 +50,5 @@
50
50
  "qx-util": "^0.4.8",
51
51
  "ramda": "^0.29.0"
52
52
  },
53
- "gitHead": "6aac74058a5bb708860cb9d40afe5640e53662e4"
53
+ "gitHead": "9e2ff8788567c10c7f048f95797e1a533b0027e8"
54
54
  }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export * from '@microsoft/fetch-event-source';
5
5
  export * from './command';
6
6
  export * from './constant';
7
7
  export { IBizContext } from './context';
8
+ export { IBizParams } from './params/params';
8
9
  export { Environment } from './environment/environment';
9
10
  export * from './error';
10
11
  export * from './interface';
@@ -0,0 +1,134 @@
1
+ /* eslint-disable no-constructor-return */
2
+ /**
3
+ * 视图参数类
4
+ * @author lxm
5
+ * @date 2023-10-27 03:39:12
6
+ * @export
7
+ * @class IBizParams
8
+ * @implements {IParams}
9
+ */
10
+ export class IBizParams implements IParams {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ [key: string | symbol]: any;
13
+
14
+ /**
15
+ * 自身的属性
16
+ * @author lxm
17
+ * @date 2023-10-27 04:09:25
18
+ * @protected
19
+ * @type {IParams}
20
+ */
21
+ protected declare _params: IParams;
22
+
23
+ /**
24
+ * 父视图参数
25
+ * @author lxm
26
+ * @date 2023-10-27 04:08:59
27
+ * @protected
28
+ * @type {IParams}
29
+ */
30
+ protected declare _parent?: IParams;
31
+
32
+ constructor(params?: IParams, parent?: IParams) {
33
+ // 定义私有变量,存放父视图参数源对象
34
+ Object.defineProperty(this, '_parent', {
35
+ enumerable: false,
36
+ configurable: true,
37
+ writable: true,
38
+ value: parent,
39
+ });
40
+
41
+ // 定义私有变量,用于存储对父已有视图参数的修改。
42
+ Object.defineProperty(this, '_params', {
43
+ enumerable: false,
44
+ configurable: true,
45
+ writable: true,
46
+ value: params || {},
47
+ });
48
+
49
+ return this.createProxy();
50
+ }
51
+
52
+ /**
53
+ * 创建代理
54
+ *
55
+ * @author lxm
56
+ * @date 2023-10-27 03:53:14
57
+ * @protected
58
+ * @return {*} {IBizParams}
59
+ */
60
+ protected createProxy(): IBizParams {
61
+ // 更新属性,缺的补充定义
62
+ function updateKeyDefine(target: IParams, keys: string[]): void {
63
+ keys.forEach(key => {
64
+ if (!Object.prototype.hasOwnProperty.call(target, key)) {
65
+ Object.defineProperty(target, key, {
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true,
69
+ value: undefined,
70
+ });
71
+ }
72
+ });
73
+ }
74
+
75
+ return new Proxy(this, {
76
+ set(target: IBizParams, p: string, value: unknown): boolean {
77
+ if (['_params', '_parent'].includes(p)) {
78
+ target[p] = value;
79
+ } else {
80
+ target._params[p] = value;
81
+ }
82
+ return true;
83
+ },
84
+
85
+ get(target: IBizParams, p: string | symbol, _receiver: unknown): unknown {
86
+ if (target[p] !== undefined) {
87
+ return target[p];
88
+ }
89
+ if (target._params[p] !== undefined) {
90
+ return target._params[p];
91
+ }
92
+ if (target._parent && target._parent[p] !== undefined) {
93
+ return target._parent[p];
94
+ }
95
+ },
96
+
97
+ ownKeys(target: IBizParams): ArrayLike<string | symbol> {
98
+ // 整合所有并排重
99
+ const allKeys = [
100
+ ...new Set([
101
+ ...Object.keys(target._params),
102
+ ...Object.keys(target._parent || {}),
103
+ ]),
104
+ ];
105
+ updateKeyDefine(target, allKeys);
106
+ return allKeys;
107
+ },
108
+ });
109
+ }
110
+
111
+ /**
112
+ * 在不改变对象引用的情况下,重置视图参数
113
+ * 等效于重新实例化,但是引用不变
114
+ * @author lxm
115
+ * @date 2023-10-27 05:24:45
116
+ * @param {IParams} [params]
117
+ * @param {IParams} [parent]
118
+ */
119
+ reset(params?: IParams, parent?: IParams): void {
120
+ this._params = params || {};
121
+ this._parent = parent;
122
+ }
123
+
124
+ /**
125
+ * 销毁上下文,避免内存泄漏
126
+ *
127
+ * @author lxm
128
+ * @date 2023-10-27 03:57:44
129
+ */
130
+ destroy(): void {
131
+ this._params = {};
132
+ this._parent = undefined;
133
+ }
134
+ }