@mybricks/to-code-taro 1.1.8 → 1.2.2
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/dist/cjs/generate/generateTaroProjectJson.js +11 -11
- package/dist/cjs/handleModule.js +1 -1
- package/dist/cjs/taro-template.json +6 -6008
- package/dist/cjs/utils/logic/handleProcess.js +1 -1
- package/dist/esm/generate/generateTaroProjectJson.js +12 -12
- package/dist/esm/handleModule.js +1 -1
- package/dist/esm/taro-template.json +6 -6008
- package/dist/esm/utils/logic/handleProcess.js +1 -1
- package/package.json +3 -9
- package/README.md +0 -58
- package/dist/cjs/core/mybricks/MyBricksDescriptor.js +0 -213
- package/dist/cjs/core/mybricks/Subject.js +0 -119
- package/dist/cjs/core/mybricks/constant.js +0 -70
- package/dist/cjs/core/mybricks/context.js +0 -33
- package/dist/cjs/core/mybricks/createEnv.js +0 -39
- package/dist/cjs/core/mybricks/createJSHandle.js +0 -191
- package/dist/cjs/core/mybricks/createModuleEventsHandle.js +0 -49
- package/dist/cjs/core/mybricks/createReactiveInputHandler.js +0 -63
- package/dist/cjs/core/mybricks/event.js +0 -70
- package/dist/cjs/core/mybricks/index.js +0 -871
- package/dist/cjs/core/mybricks/log.js +0 -37
- package/dist/cjs/core/mybricks/utils.js +0 -69
- package/dist/cjs/core/mybricks/variables.js +0 -217
- package/dist/cjs/core/utils/ComContext.js +0 -51
- package/dist/cjs/core/utils/PopupRenderer.js +0 -63
- package/dist/cjs/core/utils/comRefResolver.js +0 -112
- package/dist/cjs/core/utils/event.js +0 -53
- package/dist/cjs/core/utils/hooks.js +0 -238
- package/dist/cjs/core/utils/index.js +0 -77
- package/dist/cjs/core/utils/pageRouter.js +0 -104
- package/dist/cjs/core/utils/pool.js +0 -63
- package/dist/cjs/core/utils/popupRouter.js +0 -98
- package/dist/cjs/core/utils/slots.js +0 -183
- package/dist/cjs/core/utils/tabbar.js +0 -56
- package/dist/cjs/core/utils/useContext.js +0 -112
- package/dist/cjs/core/utils/with.js +0 -109
- package/dist/esm/core/mybricks/MyBricksDescriptor.js +0 -232
- package/dist/esm/core/mybricks/Subject.js +0 -149
- package/dist/esm/core/mybricks/constant.js +0 -18
- package/dist/esm/core/mybricks/context.js +0 -5
- package/dist/esm/core/mybricks/createEnv.js +0 -9
- package/dist/esm/core/mybricks/createJSHandle.js +0 -189
- package/dist/esm/core/mybricks/createModuleEventsHandle.js +0 -26
- package/dist/esm/core/mybricks/createReactiveInputHandler.js +0 -40
- package/dist/esm/core/mybricks/event.js +0 -44
- package/dist/esm/core/mybricks/index.js +0 -952
- package/dist/esm/core/mybricks/log.js +0 -8
- package/dist/esm/core/mybricks/utils.js +0 -41
- package/dist/esm/core/mybricks/variables.js +0 -190
- package/dist/esm/core/utils/ComContext.js +0 -16
- package/dist/esm/core/utils/PopupRenderer.js +0 -27
- package/dist/esm/core/utils/comRefResolver.js +0 -134
- package/dist/esm/core/utils/event.js +0 -32
- package/dist/esm/core/utils/hooks.js +0 -287
- package/dist/esm/core/utils/index.js +0 -12
- package/dist/esm/core/utils/pageRouter.js +0 -112
- package/dist/esm/core/utils/pool.js +0 -52
- package/dist/esm/core/utils/popupRouter.js +0 -117
- package/dist/esm/core/utils/slots.js +0 -194
- package/dist/esm/core/utils/tabbar.js +0 -47
- package/dist/esm/core/utils/useContext.js +0 -100
- package/dist/esm/core/utils/with.js +0 -115
|
@@ -483,7 +483,7 @@ var generateJsApiComponentCode = function generateJsApiComponentCode(params) {
|
|
|
483
483
|
|
|
484
484
|
// 导入 createJSHandle
|
|
485
485
|
config.addParentDependencyImport({
|
|
486
|
-
packageName: "
|
|
486
|
+
packageName: "@mybricks/taro-core",
|
|
487
487
|
dependencyNames: ["createJSHandle"],
|
|
488
488
|
importType: "named"
|
|
489
489
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mybricks/to-code-taro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "To code for Taro",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -8,15 +8,8 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "father dev",
|
|
10
10
|
"build": "father build",
|
|
11
|
-
"gen": "tsx src/generateFiles.ts",
|
|
12
11
|
"build:deps": "father prebundle",
|
|
13
|
-
"
|
|
14
|
-
"test": "tsx test/index.ts",
|
|
15
|
-
"test:project": "tsx test/genProject.ts",
|
|
16
|
-
"test:template": "tsx test/genTemplate.ts",
|
|
17
|
-
"test:watch": "ts-node-dev --respawn test/index.ts",
|
|
18
|
-
"test:harmony": "tsx test/write-harmony-output.ts",
|
|
19
|
-
"test:taro": "tsx test/write-taro-output.ts"
|
|
12
|
+
"release": "node scripts/prepublish.js"
|
|
20
13
|
},
|
|
21
14
|
"repository": {
|
|
22
15
|
"type": "git",
|
|
@@ -48,6 +41,7 @@
|
|
|
48
41
|
"@types/react": "^18.0.0",
|
|
49
42
|
"csstype": "^3.1.3",
|
|
50
43
|
"father": "^4.5.1",
|
|
44
|
+
"inquirer": "^9.3.8",
|
|
51
45
|
"ts-node": "^10.9.2",
|
|
52
46
|
"ts-node-dev": "^2.0.0",
|
|
53
47
|
"tsx": "^4.21.0",
|
package/README.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# MyBricks To Code Taro
|
|
2
|
-
|
|
3
|
-
MyBricks Taro 代码生成插件,负责将 MyBricks 的 DSL (JSON) 转换为完整的 Taro 项目代码。
|
|
4
|
-
|
|
5
|
-
## 核心功能
|
|
6
|
-
|
|
7
|
-
- **DSL 转换**: 解析 MyBricks 协议,生成符合 Taro 规范的 TSX、Less 和配置。
|
|
8
|
-
- **项目组装**: 基于内置模板,自动生成完整的 Taro 项目文件结构。
|
|
9
|
-
- **依赖管理**: 自动分析并注入页面所需的组件和工具库依赖。
|
|
10
|
-
- **响应式支持**: 深度集成 MyBricks 逻辑流,支持变量、Fx、事件流与页面生命周期的自动绑定。
|
|
11
|
-
|
|
12
|
-
## 开发指南
|
|
13
|
-
|
|
14
|
-
### 常用命令
|
|
15
|
-
|
|
16
|
-
#### 1. 开发模式
|
|
17
|
-
```bash
|
|
18
|
-
npm run dev
|
|
19
|
-
```
|
|
20
|
-
启动 `father dev`,在开发过程中实时编译代码。
|
|
21
|
-
|
|
22
|
-
#### 2. 项目构建
|
|
23
|
-
```bash
|
|
24
|
-
npm run build
|
|
25
|
-
```
|
|
26
|
-
执行生产环境构建,生成 `dist` 目录下的产物。
|
|
27
|
-
|
|
28
|
-
#### 3. 运行通用测试
|
|
29
|
-
```bash
|
|
30
|
-
npm run test
|
|
31
|
-
```
|
|
32
|
-
运行 `test/index.ts`,验证核心转换逻辑是否正确(不输出物理文件)。
|
|
33
|
-
|
|
34
|
-
#### 4. 生成测试项目 (常用)
|
|
35
|
-
```bash
|
|
36
|
-
npm run test:project
|
|
37
|
-
```
|
|
38
|
-
执行 `test/genProject.ts`,根据 `test/test-data.json` 生成完整的物理 Taro 项目。
|
|
39
|
-
生成的产物将放在 `src/_output/project` 目录下,您可以直接将该目录拷贝到 Taro 开发环境中运行。
|
|
40
|
-
|
|
41
|
-
#### 5. 重新生成项目模板
|
|
42
|
-
```bash
|
|
43
|
-
npm run test:template
|
|
44
|
-
```
|
|
45
|
-
执行 `test/genTemplate.ts`。当您修改了 `src/_template` 目录下的基础模板文件后,**必须运行此命令**,以同步更新 `src/taro-template.json`。这个 JSON 文件是生成完整项目时的骨架。
|
|
46
|
-
|
|
47
|
-
## 项目结构
|
|
48
|
-
|
|
49
|
-
- `src/core`: 运行时核心工具库(由生成项目引用)。
|
|
50
|
-
- `src/utils`: 生成器内部使用的各种转换工具。
|
|
51
|
-
- `src/processors`: 场景、模块、事件等具体维度的处理逻辑。
|
|
52
|
-
- `src/_template`: 项目生成的基础骨架模板。
|
|
53
|
-
- `test/`: 包含测试数据和用于验证生成的脚本。
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
MyBricks Team
|
|
58
|
-
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/core/mybricks/MyBricksDescriptor.js
|
|
20
|
-
var MyBricksDescriptor_exports = {};
|
|
21
|
-
__export(MyBricksDescriptor_exports, {
|
|
22
|
-
MyBricksDescriptor: () => MyBricksDescriptor
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(MyBricksDescriptor_exports);
|
|
25
|
-
var import_constant = require("./constant");
|
|
26
|
-
var import_createModuleEventsHandle = require("./createModuleEventsHandle");
|
|
27
|
-
var import_log = require("./log");
|
|
28
|
-
var DEFAULT_GETVAR_RESULT = {
|
|
29
|
-
setValue(value) {
|
|
30
|
-
(0, import_log.log)("setValue - 变量未定义,请检查");
|
|
31
|
-
},
|
|
32
|
-
getValue() {
|
|
33
|
-
(0, import_log.log)("getValue - 变量未定义,请检查");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var getVar = ({ that, varName }) => {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
const myBricksDescriptor = that[import_constant.MYBRICKS_DESCRIPTOR];
|
|
40
|
-
if (!myBricksDescriptor) {
|
|
41
|
-
return DEFAULT_GETVAR_RESULT;
|
|
42
|
-
}
|
|
43
|
-
const { vars, params, parent } = myBricksDescriptor;
|
|
44
|
-
const var0 = vars == null ? void 0 : vars[varName];
|
|
45
|
-
if (var0) {
|
|
46
|
-
return var0.ext();
|
|
47
|
-
}
|
|
48
|
-
if (["page", "popup", "module"].includes(params.type)) {
|
|
49
|
-
const var02 = (_b = (_a = params.appContext) == null ? void 0 : _a.globalVars) == null ? void 0 : _b[varName];
|
|
50
|
-
if (var02) {
|
|
51
|
-
return var02.ext();
|
|
52
|
-
}
|
|
53
|
-
return DEFAULT_GETVAR_RESULT;
|
|
54
|
-
}
|
|
55
|
-
return getVar({ that: parent, varName });
|
|
56
|
-
};
|
|
57
|
-
var DEFAULT_GETOUTPUT_RESULT = {
|
|
58
|
-
setValue(value) {
|
|
59
|
-
(0, import_log.log)("setValue - 输出未定义,请检查");
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var getOutput = ({ that, outputName }) => {
|
|
63
|
-
var _a;
|
|
64
|
-
const myBricksDescriptor = that[import_constant.MYBRICKS_DESCRIPTOR];
|
|
65
|
-
if (!myBricksDescriptor) {
|
|
66
|
-
return DEFAULT_GETOUTPUT_RESULT;
|
|
67
|
-
}
|
|
68
|
-
const { params, controller, parent } = myBricksDescriptor;
|
|
69
|
-
const { type, outputNameMap, pageId } = params;
|
|
70
|
-
const outputKey = outputNameMap ? outputNameMap[outputName] || outputName : outputName;
|
|
71
|
-
if (type === "module") {
|
|
72
|
-
if ((_a = controller.events) == null ? void 0 : _a[outputKey]) {
|
|
73
|
-
return {
|
|
74
|
-
setValue(value) {
|
|
75
|
-
var _a2;
|
|
76
|
-
(_a2 = controller.events) == null ? void 0 : _a2[outputKey](value);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
} else if (type === "popup") {
|
|
81
|
-
if (["commit", "apply", "cancel", "close"].includes(outputKey)) {
|
|
82
|
-
return {
|
|
83
|
-
setValue(value) {
|
|
84
|
-
var _a2, _b;
|
|
85
|
-
(_b = (_a2 = params.appContext) == null ? void 0 : _a2.page) == null ? void 0 : _b[outputKey](pageId, value);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
} else if (type === "slot") {
|
|
90
|
-
if (that.params.outputs && outputKey in that.params.outputs) {
|
|
91
|
-
return {
|
|
92
|
-
setValue(value) {
|
|
93
|
-
that.params.outputs[outputKey](value);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (["page", "popup", "module"].includes(type)) {
|
|
99
|
-
return DEFAULT_GETOUTPUT_RESULT;
|
|
100
|
-
}
|
|
101
|
-
return getOutput({ that: parent, outputName });
|
|
102
|
-
};
|
|
103
|
-
var DEFAULT_GETINPUT_RESULT = {
|
|
104
|
-
getValue(value) {
|
|
105
|
-
(0, import_log.log)("getValue - 输入未定义,请检查");
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var getInput = ({ that, inputName }) => {
|
|
109
|
-
const myBricksDescriptor = that[import_constant.MYBRICKS_DESCRIPTOR];
|
|
110
|
-
if (!myBricksDescriptor) {
|
|
111
|
-
return DEFAULT_GETINPUT_RESULT;
|
|
112
|
-
}
|
|
113
|
-
const { params, controller, parent } = myBricksDescriptor;
|
|
114
|
-
const { type, inputNameMap, pageId } = params;
|
|
115
|
-
const inputKey = (inputNameMap ? inputNameMap[inputName] : inputName) || inputName;
|
|
116
|
-
if (type === "slot") {
|
|
117
|
-
if (inputKey in that.params.inputValues) {
|
|
118
|
-
return {
|
|
119
|
-
getValue() {
|
|
120
|
-
return that.params.inputValues[inputKey];
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
} else if (type === "page" || type === "popup") {
|
|
125
|
-
if (inputKey === "open") {
|
|
126
|
-
return {
|
|
127
|
-
getValue() {
|
|
128
|
-
var _a, _b, _c;
|
|
129
|
-
return (_c = (_b = (_a = params.appContext) == null ? void 0 : _a.page) == null ? void 0 : _b.getParams(pageId)) == null ? void 0 : _c[import_constant.SUBJECT_VALUE];
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
return DEFAULT_GETINPUT_RESULT;
|
|
134
|
-
} else if (type === "module") {
|
|
135
|
-
return {
|
|
136
|
-
getValue() {
|
|
137
|
-
var _a, _b;
|
|
138
|
-
if (inputKey in controller.data) {
|
|
139
|
-
return controller.data[inputKey];
|
|
140
|
-
}
|
|
141
|
-
return (_b = (_a = controller.controller) == null ? void 0 : _a[inputKey]) == null ? void 0 : _b[import_constant.SUBJECT_VALUE];
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
if (["page", "popup", "module"].includes(type)) {
|
|
146
|
-
return DEFAULT_GETINPUT_RESULT;
|
|
147
|
-
}
|
|
148
|
-
return getInput({ that: parent, inputName });
|
|
149
|
-
};
|
|
150
|
-
function MyBricksDescriptor(params) {
|
|
151
|
-
return (target, key, descriptor) => {
|
|
152
|
-
const originalMethod = descriptor.value;
|
|
153
|
-
descriptor.value = function(...args) {
|
|
154
|
-
let controller = null;
|
|
155
|
-
let vars = null;
|
|
156
|
-
Object.keys(this.__proto__).filter((key2) => !key2.startsWith("__ob_")).forEach((key2) => {
|
|
157
|
-
const value = this[key2];
|
|
158
|
-
if (value == null ? void 0 : value[import_constant.BASECONTROLLER_MARK]) {
|
|
159
|
-
const descriptor2 = Object.getOwnPropertyDescriptor(this, key2);
|
|
160
|
-
if (!(descriptor2 == null ? void 0 : descriptor2.get)) {
|
|
161
|
-
controller = value;
|
|
162
|
-
}
|
|
163
|
-
} else if (value == null ? void 0 : value[import_constant.VARS_MARK]) {
|
|
164
|
-
const descriptor2 = Object.getOwnPropertyDescriptor(this, key2);
|
|
165
|
-
if (!(descriptor2 == null ? void 0 : descriptor2.get)) {
|
|
166
|
-
vars = value;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
this[import_constant.MYBRICKS_DESCRIPTOR] = {
|
|
171
|
-
controller,
|
|
172
|
-
vars,
|
|
173
|
-
params,
|
|
174
|
-
parent: this.getParent()
|
|
175
|
-
};
|
|
176
|
-
if (controller) {
|
|
177
|
-
if (this.events) {
|
|
178
|
-
controller.events = (0, import_createModuleEventsHandle.createModuleEventsHandle)({ that: this, appContext: params.appContext });
|
|
179
|
-
}
|
|
180
|
-
if (this.data) {
|
|
181
|
-
controller.data = this.data;
|
|
182
|
-
}
|
|
183
|
-
if (this.controller) {
|
|
184
|
-
controller.controller = this.controller;
|
|
185
|
-
}
|
|
186
|
-
const classController = controller;
|
|
187
|
-
Object.getOwnPropertyNames(classController).forEach((key2) => {
|
|
188
|
-
const controllerContext = classController[key2][import_constant.CONTROLLER_CONTEXT];
|
|
189
|
-
if (controllerContext) {
|
|
190
|
-
controllerContext["this"] = this;
|
|
191
|
-
controllerContext["getVar"] = (varName) => {
|
|
192
|
-
return getVar({ that: this, varName });
|
|
193
|
-
};
|
|
194
|
-
controllerContext["getOutput"] = (outputName) => {
|
|
195
|
-
return getOutput({ that: this, outputName });
|
|
196
|
-
};
|
|
197
|
-
controllerContext["getInput"] = (inputName) => {
|
|
198
|
-
return getInput({ that: this, inputName });
|
|
199
|
-
};
|
|
200
|
-
controllerContext["appContext"] = params.appContext;
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
const result = originalMethod.apply(this, args);
|
|
205
|
-
return result;
|
|
206
|
-
};
|
|
207
|
-
return descriptor;
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
211
|
-
0 && (module.exports = {
|
|
212
|
-
MyBricksDescriptor
|
|
213
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/core/mybricks/Subject.js
|
|
20
|
-
var Subject_exports = {};
|
|
21
|
-
__export(Subject_exports, {
|
|
22
|
-
Subject: () => Subject
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(Subject_exports);
|
|
25
|
-
var import_log = require("./log");
|
|
26
|
-
var import_constant = require("./constant");
|
|
27
|
-
var Subject = class {
|
|
28
|
-
_values = [];
|
|
29
|
-
_observers = /* @__PURE__ */ new Set();
|
|
30
|
-
_log = void 0;
|
|
31
|
-
_empty = true;
|
|
32
|
-
constructor(params = {}) {
|
|
33
|
-
this._log = params.log;
|
|
34
|
-
this._subjectNextCache = {};
|
|
35
|
-
return new Proxy(this, {
|
|
36
|
-
get(target, prop) {
|
|
37
|
-
if (prop in target) {
|
|
38
|
-
return target[prop];
|
|
39
|
-
}
|
|
40
|
-
if (!target._subjectNextCache[prop]) {
|
|
41
|
-
const subjectNext = new SubjectNext(prop);
|
|
42
|
-
target[import_constant.SUBJECT_SUBSCRIBE]((value, extra) => {
|
|
43
|
-
subjectNext[import_constant.SUBJECT_NEXT](value, extra);
|
|
44
|
-
});
|
|
45
|
-
target._subjectNextCache[prop] = subjectNext;
|
|
46
|
-
}
|
|
47
|
-
return target._subjectNextCache[prop];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
get [import_constant.SUBJECT_VALUE]() {
|
|
52
|
-
return this._values[0];
|
|
53
|
-
}
|
|
54
|
-
get [import_constant.SUBJECT_EMPTY]() {
|
|
55
|
-
return this._empty;
|
|
56
|
-
}
|
|
57
|
-
[import_constant.SUBJECT_SETVALUE](value) {
|
|
58
|
-
this._values[0] = value;
|
|
59
|
-
this._empty = false;
|
|
60
|
-
}
|
|
61
|
-
[import_constant.SUBJECT_NEXT](value, extra) {
|
|
62
|
-
(0, import_log.log)(this._log, JSON.stringify(value));
|
|
63
|
-
this._values[0] = value;
|
|
64
|
-
this._empty = false;
|
|
65
|
-
this._observers.forEach((observer) => observer(value, extra));
|
|
66
|
-
}
|
|
67
|
-
[import_constant.SUBJECT_SUBSCRIBE](observer) {
|
|
68
|
-
if (this._values.length) {
|
|
69
|
-
observer(this._values[0]);
|
|
70
|
-
}
|
|
71
|
-
this._observers.add(observer);
|
|
72
|
-
}
|
|
73
|
-
[import_constant.SUBJECT_UNSUBSCRIBE](observer) {
|
|
74
|
-
this._observers.delete(observer);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
function getValueNextByPath(params) {
|
|
78
|
-
const { value, path } = params;
|
|
79
|
-
let current = value;
|
|
80
|
-
for (const key of path) {
|
|
81
|
-
if (current === null || current === void 0) {
|
|
82
|
-
return void 0;
|
|
83
|
-
}
|
|
84
|
-
current = current[key];
|
|
85
|
-
}
|
|
86
|
-
return current;
|
|
87
|
-
}
|
|
88
|
-
var SubjectNext = class extends Subject {
|
|
89
|
-
_path = [];
|
|
90
|
-
constructor(path) {
|
|
91
|
-
super();
|
|
92
|
-
this._path.push(path);
|
|
93
|
-
return new Proxy(this, {
|
|
94
|
-
get(target, prop) {
|
|
95
|
-
if (prop in target) {
|
|
96
|
-
return target[prop];
|
|
97
|
-
}
|
|
98
|
-
target._path.push(prop);
|
|
99
|
-
return target;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
[import_constant.SUBJECT_NEXT](value, extra) {
|
|
104
|
-
this._values[0] = value;
|
|
105
|
-
this._empty = false;
|
|
106
|
-
const nextValue = getValueNextByPath({ value, path: this._path });
|
|
107
|
-
this._observers.forEach((observer) => observer(nextValue, extra));
|
|
108
|
-
}
|
|
109
|
-
[import_constant.SUBJECT_SUBSCRIBE](observer) {
|
|
110
|
-
if (this._values.length) {
|
|
111
|
-
observer(getValueNextByPath({ value: this._values[0], path: this._path }));
|
|
112
|
-
}
|
|
113
|
-
this._observers.add(observer);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
-
0 && (module.exports = {
|
|
118
|
-
Subject
|
|
119
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/core/mybricks/constant.js
|
|
20
|
-
var constant_exports = {};
|
|
21
|
-
__export(constant_exports, {
|
|
22
|
-
BASECONTROLLER_MARK: () => BASECONTROLLER_MARK,
|
|
23
|
-
CONTROLLER_CONTEXT: () => CONTROLLER_CONTEXT,
|
|
24
|
-
EXCUTE_TYPE_KEY: () => EXCUTE_TYPE_KEY,
|
|
25
|
-
EXCUTE_TYPE_VALUE: () => EXCUTE_TYPE_VALUE,
|
|
26
|
-
EXE_TITLE_MAP: () => EXE_TITLE_MAP,
|
|
27
|
-
MYBRICKS_DESCRIPTOR: () => MYBRICKS_DESCRIPTOR,
|
|
28
|
-
SUBJECT_EMPTY: () => SUBJECT_EMPTY,
|
|
29
|
-
SUBJECT_NEXT: () => SUBJECT_NEXT,
|
|
30
|
-
SUBJECT_SETVALUE: () => SUBJECT_SETVALUE,
|
|
31
|
-
SUBJECT_SUBSCRIBE: () => SUBJECT_SUBSCRIBE,
|
|
32
|
-
SUBJECT_UNSUBSCRIBE: () => SUBJECT_UNSUBSCRIBE,
|
|
33
|
-
SUBJECT_VALUE: () => SUBJECT_VALUE,
|
|
34
|
-
VARS_MARK: () => VARS_MARK
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(constant_exports);
|
|
37
|
-
var SUBJECT_NEXT = Symbol("SUBJECT_NEXT");
|
|
38
|
-
var SUBJECT_VALUE = Symbol("SUBJECT_VALUE");
|
|
39
|
-
var SUBJECT_SUBSCRIBE = Symbol("SUBJECT_SUBSCRIBE");
|
|
40
|
-
var SUBJECT_UNSUBSCRIBE = Symbol("SUBJECT_UNSUBSCRIBE");
|
|
41
|
-
var SUBJECT_EMPTY = Symbol("SUBJECT_EMPTY");
|
|
42
|
-
var SUBJECT_SETVALUE = Symbol("SUBJECT_SETVALUE");
|
|
43
|
-
var VARS_MARK = Symbol("VARS_MARK");
|
|
44
|
-
var BASECONTROLLER_MARK = Symbol("BASECONTROLLER_MARK");
|
|
45
|
-
var MYBRICKS_DESCRIPTOR = Symbol("MYBRICKS_DESCRIPTOR");
|
|
46
|
-
var EXE_TITLE_MAP = {
|
|
47
|
-
output: "输出",
|
|
48
|
-
input: "输入"
|
|
49
|
-
};
|
|
50
|
-
var CONTROLLER_CONTEXT = Symbol("CONTROLLER_CONTEXT");
|
|
51
|
-
var EXCUTE_TYPE_KEY = Symbol("EXCUTE_TYPE_KEY");
|
|
52
|
-
var EXCUTE_TYPE_VALUE = {
|
|
53
|
-
DATACHANGED: Symbol("DATACHANGED")
|
|
54
|
-
};
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
BASECONTROLLER_MARK,
|
|
58
|
-
CONTROLLER_CONTEXT,
|
|
59
|
-
EXCUTE_TYPE_KEY,
|
|
60
|
-
EXCUTE_TYPE_VALUE,
|
|
61
|
-
EXE_TITLE_MAP,
|
|
62
|
-
MYBRICKS_DESCRIPTOR,
|
|
63
|
-
SUBJECT_EMPTY,
|
|
64
|
-
SUBJECT_NEXT,
|
|
65
|
-
SUBJECT_SETVALUE,
|
|
66
|
-
SUBJECT_SUBSCRIBE,
|
|
67
|
-
SUBJECT_UNSUBSCRIBE,
|
|
68
|
-
SUBJECT_VALUE,
|
|
69
|
-
VARS_MARK
|
|
70
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/core/mybricks/context.js
|
|
20
|
-
var context_exports = {};
|
|
21
|
-
__export(context_exports, {
|
|
22
|
-
context: () => context
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(context_exports);
|
|
25
|
-
var context = {
|
|
26
|
-
/** [TODO] 记录API调用过程中变量的监听,调用回调后销毁 */
|
|
27
|
-
apiRun: null,
|
|
28
|
-
apiRunVariablesSubject: {}
|
|
29
|
-
};
|
|
30
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 && (module.exports = {
|
|
32
|
-
context
|
|
33
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/core/mybricks/createEnv.js
|
|
20
|
-
var createEnv_exports = {};
|
|
21
|
-
__export(createEnv_exports, {
|
|
22
|
-
_createEnv: () => _createEnv,
|
|
23
|
-
createEnv: () => createEnv
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(createEnv_exports);
|
|
26
|
-
var import_constant = require("./constant");
|
|
27
|
-
var createEnv = (params) => {
|
|
28
|
-
var _a;
|
|
29
|
-
return (_a = params.controller[import_constant.CONTROLLER_CONTEXT].appContext) == null ? void 0 : _a.env;
|
|
30
|
-
};
|
|
31
|
-
var _createEnv = (params) => {
|
|
32
|
-
var _a;
|
|
33
|
-
return (_a = params.controller[import_constant.CONTROLLER_CONTEXT].appContext) == null ? void 0 : _a._env;
|
|
34
|
-
};
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
_createEnv,
|
|
38
|
-
createEnv
|
|
39
|
-
});
|