@ibiz-template/core 0.0.1-alpha.0

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,32 @@
1
+ import { IContext } from '../interface';
2
+ /**
3
+ * 上下文处理类
4
+ *
5
+ * @author chitanda
6
+ * @date 2022-07-14 10:07:24
7
+ * @export
8
+ * @class IBizContext
9
+ */
10
+ export declare class IBizContext implements IContext {
11
+ context: IContext;
12
+ [key: string | symbol]: any;
13
+ /**
14
+ * 父上下文
15
+ *
16
+ * @author chitanda
17
+ * @date 2022-07-14 10:07:06
18
+ * @protected
19
+ * @type {(IBizContext | null)}
20
+ */
21
+ protected readonly _parent: IBizContext | null;
22
+ /**
23
+ * Creates an instance of IBizContext.
24
+ *
25
+ * @author chitanda
26
+ * @date 2022-07-14 10:07:15
27
+ * @param {IContext} [context={}]
28
+ * @param {IBizContext} [parent]
29
+ */
30
+ constructor(context?: IContext, parent?: IBizContext);
31
+ }
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAwBxC;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,QAAQ;IAoBvB,OAAO,EAAE,QAAQ;IAnBpC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAC5B;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAQ;IAEtD;;;;;;;OAOG;gBACgB,OAAO,GAAE,QAAa,EAAE,MAAM,CAAC,EAAE,WAAW;CAMhE"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * 代理处理
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-07-14 10:07:45
6
+ * @class IBizContextProxyHandle
7
+ * @implements {ProxyHandler<IBizContext>}
8
+ */
9
+ class IBizContextProxyHandle {
10
+ set(target, p, value) {
11
+ return (target.context[p] = value);
12
+ }
13
+ get(target, p, _receiver) {
14
+ if (target.context[p]) {
15
+ return target.context[p];
16
+ }
17
+ if (target._parent) {
18
+ return target._parent[p];
19
+ }
20
+ }
21
+ }
22
+ /**
23
+ * 上下文处理类
24
+ *
25
+ * @author chitanda
26
+ * @date 2022-07-14 10:07:24
27
+ * @export
28
+ * @class IBizContext
29
+ */
30
+ export class IBizContext {
31
+ /**
32
+ * Creates an instance of IBizContext.
33
+ *
34
+ * @author chitanda
35
+ * @date 2022-07-14 10:07:15
36
+ * @param {IContext} [context={}]
37
+ * @param {IBizContext} [parent]
38
+ */
39
+ constructor(context = {}, parent) {
40
+ this.context = context;
41
+ /**
42
+ * 父上下文
43
+ *
44
+ * @author chitanda
45
+ * @date 2022-07-14 10:07:06
46
+ * @protected
47
+ * @type {(IBizContext | null)}
48
+ */
49
+ this._parent = null;
50
+ if (parent) {
51
+ this._parent = parent;
52
+ }
53
+ return new Proxy(this, new IBizContextProxyHandle());
54
+ }
55
+ }
package/out/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function run(): void;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,GAAG,IAAI,IAAI,CAM1B"}
package/out/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import { IBizContext } from './context';
2
+ export function run() {
3
+ const p = new IBizContext({ a: 1, b: 2 });
4
+ const c = new IBizContext({ c: 3 }, p);
5
+ console.log(c.a); // 1
6
+ console.log(c.b); // 2
7
+ console.log(c.c); // 3
8
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 上下文接口
3
+ *
4
+ * @author chitanda
5
+ * @date 2022-07-14 10:07:32
6
+ * @export
7
+ * @interface IContext
8
+ */
9
+ export interface IContext {
10
+ [key: string | symbol]: any;
11
+ }
12
+ //# sourceMappingURL=i-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i-context.d.ts","sourceRoot":"","sources":["../../../src/interface/i-context/i-context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC7B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { IContext } from './i-context/i-context';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interface/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@ibiz-template/core",
3
+ "version": "0.0.1-alpha.0",
4
+ "description": "核心逻辑包",
5
+ "main": "out/index.js",
6
+ "types": "out/types/index.d.ts",
7
+ "files": [
8
+ "out"
9
+ ],
10
+ "scripts": {
11
+ "dev": "tsc --watch",
12
+ "build": "npm run lint && npm run clean && tsc --build",
13
+ "lint": "eslint src/**/*.ts",
14
+ "clean": "rimraf out",
15
+ "publish:next": "npm run build && npm publish --access public --tag next",
16
+ "publish:npm": "npm run build && npm publish --access public"
17
+ },
18
+ "author": "chitanda",
19
+ "license": "MIT",
20
+ "dependencies": {}
21
+ }