@mybricks/to-code-taro 1.0.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.
- package/dist/cjs/abstractEventTypeDef.d.ts +11 -0
- package/dist/cjs/abstractEventTypeDef.js +93 -0
- package/dist/cjs/core/comlib/Index.js +45 -0
- package/dist/cjs/core/comlib/_ScanQrcode.js +60 -0
- package/dist/cjs/core/comlib/_SetStorage.js +76 -0
- package/dist/cjs/core/comlib/_ShowToast.js +96 -0
- package/dist/cjs/core/mybricks/MyBricksDescriptor.js +213 -0
- package/dist/cjs/core/mybricks/Subject.js +115 -0
- package/dist/cjs/core/mybricks/constant.js +70 -0
- package/dist/cjs/core/mybricks/context.js +33 -0
- package/dist/cjs/core/mybricks/createEnv.js +39 -0
- package/dist/cjs/core/mybricks/createJSHandle.js +150 -0
- package/dist/cjs/core/mybricks/createModuleEventsHandle.js +49 -0
- package/dist/cjs/core/mybricks/createReactiveInputHandler.js +63 -0
- package/dist/cjs/core/mybricks/event.js +70 -0
- package/dist/cjs/core/mybricks/index.js +871 -0
- package/dist/cjs/core/mybricks/log.js +38 -0
- package/dist/cjs/core/mybricks/utils.js +69 -0
- package/dist/cjs/core/mybricks/variables.js +217 -0
- package/dist/cjs/core/utils/ComContext.js +39 -0
- package/dist/cjs/core/utils/index.js +88 -0
- package/dist/cjs/core/utils/useContext.js +53 -0
- package/dist/cjs/core/utils/with.js +84 -0
- package/dist/cjs/generate/generateTaroProjectJson.d.ts +24 -0
- package/dist/cjs/generate/generateTaroProjectJson.js +101 -0
- package/dist/cjs/generate/generateTaroTempalteJson.d.ts +15 -0
- package/dist/cjs/generate/generateTaroTempalteJson.js +103 -0
- package/dist/cjs/generate/utils/appConfig.d.ts +21 -0
- package/dist/cjs/generate/utils/appConfig.js +47 -0
- package/dist/cjs/generate/utils/commonDir.d.ts +21 -0
- package/dist/cjs/generate/utils/commonDir.js +50 -0
- package/dist/cjs/generate/utils/fileNode.d.ts +17 -0
- package/dist/cjs/generate/utils/fileNode.js +57 -0
- package/dist/cjs/generate/utils/index.d.ts +7 -0
- package/dist/cjs/generate/utils/index.js +29 -0
- package/dist/cjs/generate/utils/tabBarImages.d.ts +14 -0
- package/dist/cjs/generate/utils/tabBarImages.js +36 -0
- package/dist/cjs/handleCom.d.ts +31 -0
- package/dist/cjs/handleCom.js +260 -0
- package/dist/cjs/handleDom.d.ts +19 -0
- package/dist/cjs/handleDom.js +86 -0
- package/dist/cjs/handleExtension.d.ts +10 -0
- package/dist/cjs/handleExtension.js +300 -0
- package/dist/cjs/handleGlobal.d.ts +21 -0
- package/dist/cjs/handleGlobal.js +155 -0
- package/dist/cjs/handleModule.d.ts +15 -0
- package/dist/cjs/handleModule.js +108 -0
- package/dist/cjs/handleSlot.d.ts +27 -0
- package/dist/cjs/handleSlot.js +197 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/taro-template.json +5370 -0
- package/dist/cjs/toCodeTaro.d.ts +130 -0
- package/dist/cjs/toCodeTaro.js +427 -0
- package/dist/cjs/utils/code/component.d.ts +19 -0
- package/dist/cjs/utils/code/component.js +85 -0
- package/dist/cjs/utils/code/index.d.ts +18 -0
- package/dist/cjs/utils/code/index.js +71 -0
- package/dist/cjs/utils/code/renderManager.d.ts +22 -0
- package/dist/cjs/utils/code/renderManager.js +80 -0
- package/dist/cjs/utils/code/scene.d.ts +19 -0
- package/dist/cjs/utils/code/scene.js +82 -0
- package/dist/cjs/utils/convertNamespace.d.ts +11 -0
- package/dist/cjs/utils/convertNamespace.js +43 -0
- package/dist/cjs/utils/genJSModules.d.ts +12 -0
- package/dist/cjs/utils/genJSModules.js +116 -0
- package/dist/cjs/utils/getComponentClassName.d.ts +16 -0
- package/dist/cjs/utils/getComponentClassName.js +47 -0
- package/dist/cjs/utils/handlePageConfig.d.ts +24 -0
- package/dist/cjs/utils/handlePageConfig.js +73 -0
- package/dist/cjs/utils/handleProcess.d.ts +9 -0
- package/dist/cjs/utils/handleProcess.js +370 -0
- package/dist/cjs/utils/index.d.ts +62 -0
- package/dist/cjs/utils/index.js +321 -0
- package/dist/cjs/utils/pageConfig/converter.d.ts +17 -0
- package/dist/cjs/utils/pageConfig/converter.js +83 -0
- package/dist/cjs/utils/pageConfig/index.d.ts +10 -0
- package/dist/cjs/utils/pageConfig/index.js +33 -0
- package/dist/cjs/utils/pageConfig/pageConfig.d.ts +10 -0
- package/dist/cjs/utils/pageConfig/pageConfig.js +87 -0
- package/dist/cjs/utils/pageConfig/saveBase64Image.d.ts +14 -0
- package/dist/cjs/utils/pageConfig/saveBase64Image.js +81 -0
- package/dist/cjs/utils/pageConfig/tabBarConfig.d.ts +13 -0
- package/dist/cjs/utils/pageConfig/tabBarConfig.js +74 -0
- package/dist/cjs/utils/pageConfig/types.d.ts +68 -0
- package/dist/cjs/utils/pageConfig/types.js +17 -0
- package/dist/cjs/utils/pageConfig/validator.d.ts +13 -0
- package/dist/cjs/utils/pageConfig/validator.js +67 -0
- package/dist/cjs/utils/pxtransform.d.ts +28 -0
- package/dist/cjs/utils/pxtransform.js +102 -0
- package/dist/esm/abstractEventTypeDef.d.ts +11 -0
- package/dist/esm/abstractEventTypeDef.js +63 -0
- package/dist/esm/core/comlib/Index.js +3 -0
- package/dist/esm/core/comlib/_ScanQrcode.js +27 -0
- package/dist/esm/core/comlib/_SetStorage.js +52 -0
- package/dist/esm/core/comlib/_ShowToast.js +68 -0
- package/dist/esm/core/mybricks/MyBricksDescriptor.js +232 -0
- package/dist/esm/core/mybricks/Subject.js +143 -0
- package/dist/esm/core/mybricks/constant.js +18 -0
- package/dist/esm/core/mybricks/context.js +5 -0
- package/dist/esm/core/mybricks/createEnv.js +9 -0
- package/dist/esm/core/mybricks/createJSHandle.js +138 -0
- package/dist/esm/core/mybricks/createModuleEventsHandle.js +26 -0
- package/dist/esm/core/mybricks/createReactiveInputHandler.js +40 -0
- package/dist/esm/core/mybricks/event.js +44 -0
- package/dist/esm/core/mybricks/index.js +952 -0
- package/dist/esm/core/mybricks/log.js +12 -0
- package/dist/esm/core/mybricks/utils.js +41 -0
- package/dist/esm/core/mybricks/variables.js +190 -0
- package/dist/esm/core/utils/ComContext.js +10 -0
- package/dist/esm/core/utils/index.js +57 -0
- package/dist/esm/core/utils/useContext.js +24 -0
- package/dist/esm/core/utils/with.js +67 -0
- package/dist/esm/generate/generateTaroProjectJson.d.ts +24 -0
- package/dist/esm/generate/generateTaroProjectJson.js +102 -0
- package/dist/esm/generate/generateTaroTempalteJson.d.ts +15 -0
- package/dist/esm/generate/generateTaroTempalteJson.js +94 -0
- package/dist/esm/generate/utils/appConfig.d.ts +21 -0
- package/dist/esm/generate/utils/appConfig.js +30 -0
- package/dist/esm/generate/utils/commonDir.d.ts +21 -0
- package/dist/esm/generate/utils/commonDir.js +36 -0
- package/dist/esm/generate/utils/fileNode.d.ts +17 -0
- package/dist/esm/generate/utils/fileNode.js +49 -0
- package/dist/esm/generate/utils/index.d.ts +7 -0
- package/dist/esm/generate/utils/index.js +8 -0
- package/dist/esm/generate/utils/tabBarImages.d.ts +14 -0
- package/dist/esm/generate/utils/tabBarImages.js +15 -0
- package/dist/esm/handleCom.d.ts +31 -0
- package/dist/esm/handleCom.js +297 -0
- package/dist/esm/handleDom.d.ts +19 -0
- package/dist/esm/handleDom.js +63 -0
- package/dist/esm/handleExtension.d.ts +10 -0
- package/dist/esm/handleExtension.js +243 -0
- package/dist/esm/handleGlobal.d.ts +21 -0
- package/dist/esm/handleGlobal.js +117 -0
- package/dist/esm/handleModule.d.ts +15 -0
- package/dist/esm/handleModule.js +78 -0
- package/dist/esm/handleSlot.d.ts +27 -0
- package/dist/esm/handleSlot.js +205 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/taro-template.json +5370 -0
- package/dist/esm/toCodeTaro.d.ts +130 -0
- package/dist/esm/toCodeTaro.js +452 -0
- package/dist/esm/utils/code/component.d.ts +19 -0
- package/dist/esm/utils/code/component.js +54 -0
- package/dist/esm/utils/code/index.d.ts +18 -0
- package/dist/esm/utils/code/index.js +51 -0
- package/dist/esm/utils/code/renderManager.d.ts +22 -0
- package/dist/esm/utils/code/renderManager.js +62 -0
- package/dist/esm/utils/code/scene.d.ts +19 -0
- package/dist/esm/utils/code/scene.js +47 -0
- package/dist/esm/utils/convertNamespace.d.ts +11 -0
- package/dist/esm/utils/convertNamespace.js +27 -0
- package/dist/esm/utils/genJSModules.d.ts +12 -0
- package/dist/esm/utils/genJSModules.js +44 -0
- package/dist/esm/utils/getComponentClassName.d.ts +16 -0
- package/dist/esm/utils/getComponentClassName.js +37 -0
- package/dist/esm/utils/handlePageConfig.d.ts +24 -0
- package/dist/esm/utils/handlePageConfig.js +68 -0
- package/dist/esm/utils/handleProcess.d.ts +9 -0
- package/dist/esm/utils/handleProcess.js +379 -0
- package/dist/esm/utils/index.d.ts +62 -0
- package/dist/esm/utils/index.js +345 -0
- package/dist/esm/utils/pageConfig/converter.d.ts +17 -0
- package/dist/esm/utils/pageConfig/converter.js +105 -0
- package/dist/esm/utils/pageConfig/index.d.ts +10 -0
- package/dist/esm/utils/pageConfig/index.js +11 -0
- package/dist/esm/utils/pageConfig/pageConfig.d.ts +10 -0
- package/dist/esm/utils/pageConfig/pageConfig.js +60 -0
- package/dist/esm/utils/pageConfig/saveBase64Image.d.ts +14 -0
- package/dist/esm/utils/pageConfig/saveBase64Image.js +105 -0
- package/dist/esm/utils/pageConfig/tabBarConfig.d.ts +13 -0
- package/dist/esm/utils/pageConfig/tabBarConfig.js +82 -0
- package/dist/esm/utils/pageConfig/types.d.ts +68 -0
- package/dist/esm/utils/pageConfig/types.js +1 -0
- package/dist/esm/utils/pageConfig/validator.d.ts +13 -0
- package/dist/esm/utils/pageConfig/validator.js +64 -0
- package/dist/esm/utils/pxtransform.d.ts +28 -0
- package/dist/esm/utils/pxtransform.js +121 -0
- package/package.json +74 -0
|
@@ -0,0 +1,38 @@
|
|
|
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/log.js
|
|
20
|
+
var log_exports = {};
|
|
21
|
+
__export(log_exports, {
|
|
22
|
+
log: () => log,
|
|
23
|
+
logger: () => logger
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(log_exports);
|
|
26
|
+
var log = (...args) => {
|
|
27
|
+
console.log("[MyBricks]", ...args);
|
|
28
|
+
};
|
|
29
|
+
var logger = {
|
|
30
|
+
info: log,
|
|
31
|
+
warn: log,
|
|
32
|
+
error: log
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
log,
|
|
37
|
+
logger
|
|
38
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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/utils.js
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
isObject: () => isObject,
|
|
23
|
+
safeGetByPath: () => safeGetByPath,
|
|
24
|
+
safeSetByPath: () => safeSetByPath
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(utils_exports);
|
|
27
|
+
var safeSetByPath = (params) => {
|
|
28
|
+
const { data, path, value } = params;
|
|
29
|
+
const nextIndex = path.length - 1;
|
|
30
|
+
let current = data;
|
|
31
|
+
let errorFlag = false;
|
|
32
|
+
for (let i = 0; i < nextIndex; i++) {
|
|
33
|
+
try {
|
|
34
|
+
current = current[path[i]];
|
|
35
|
+
} catch (error) {
|
|
36
|
+
errorFlag = true;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!errorFlag) {
|
|
41
|
+
current[path[nextIndex]] = value;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var safeGetByPath = (params) => {
|
|
45
|
+
const { data, path } = params;
|
|
46
|
+
let current = data;
|
|
47
|
+
let errorFlag = false;
|
|
48
|
+
for (let i = 0; i < path.length; i++) {
|
|
49
|
+
try {
|
|
50
|
+
current = current[path[i]];
|
|
51
|
+
} catch (error) {
|
|
52
|
+
errorFlag = true;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!errorFlag) {
|
|
57
|
+
return current;
|
|
58
|
+
}
|
|
59
|
+
return void 0;
|
|
60
|
+
};
|
|
61
|
+
var isObject = (value) => {
|
|
62
|
+
return value && typeof value === "object";
|
|
63
|
+
};
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
isObject,
|
|
67
|
+
safeGetByPath,
|
|
68
|
+
safeSetByPath
|
|
69
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
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/variables.js
|
|
20
|
+
var variables_exports = {};
|
|
21
|
+
__export(variables_exports, {
|
|
22
|
+
createVariable: () => createVariable,
|
|
23
|
+
createVars: () => createVars
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(variables_exports);
|
|
26
|
+
var import_Subject = require("./Subject");
|
|
27
|
+
var import_context = require("./context");
|
|
28
|
+
var import_utils = require("./utils");
|
|
29
|
+
var import_constant = require("./constant");
|
|
30
|
+
var createVariable = (...args) => {
|
|
31
|
+
const hasDefaultValue = args.length > 0;
|
|
32
|
+
const initValue = args[0];
|
|
33
|
+
const value = new import_Subject.Subject();
|
|
34
|
+
if (hasDefaultValue) {
|
|
35
|
+
value[import_constant.SUBJECT_NEXT](initValue);
|
|
36
|
+
}
|
|
37
|
+
const ref = {
|
|
38
|
+
value,
|
|
39
|
+
callBacksMap: /* @__PURE__ */ new Map(),
|
|
40
|
+
// 注册change后,设置一个subject,用于触发change
|
|
41
|
+
changeValues: /* @__PURE__ */ new Set(),
|
|
42
|
+
// change到上述subject的映射
|
|
43
|
+
changeValuesMap: /* @__PURE__ */ new Map()
|
|
44
|
+
};
|
|
45
|
+
const variable = {
|
|
46
|
+
/** 读取 */
|
|
47
|
+
get(value2, path) {
|
|
48
|
+
const nextValue = new import_Subject.Subject();
|
|
49
|
+
const next = () => {
|
|
50
|
+
nextValue[import_constant.SUBJECT_NEXT](path ? (0, import_utils.safeGetByPath)({
|
|
51
|
+
data: ref.value[import_constant.SUBJECT_VALUE],
|
|
52
|
+
path: path.split(".")
|
|
53
|
+
}) : ref.value[import_constant.SUBJECT_VALUE]);
|
|
54
|
+
};
|
|
55
|
+
if (value2 == null ? void 0 : value2[import_constant.SUBJECT_SUBSCRIBE]) {
|
|
56
|
+
value2[import_constant.SUBJECT_SUBSCRIBE](() => {
|
|
57
|
+
next();
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
next();
|
|
61
|
+
}
|
|
62
|
+
return nextValue;
|
|
63
|
+
},
|
|
64
|
+
/** 赋值 */
|
|
65
|
+
set(value2, path) {
|
|
66
|
+
const nextValue = new import_Subject.Subject();
|
|
67
|
+
const next = (value3, extra) => {
|
|
68
|
+
if (path) {
|
|
69
|
+
const isEmpty = ref.value[import_constant.SUBJECT_EMPTY];
|
|
70
|
+
if (isEmpty) {
|
|
71
|
+
ref.value[import_constant.SUBJECT_SETVALUE]({});
|
|
72
|
+
}
|
|
73
|
+
(0, import_utils.safeSetByPath)({
|
|
74
|
+
data: ref.value[import_constant.SUBJECT_VALUE],
|
|
75
|
+
path: path.split("."),
|
|
76
|
+
value: value3
|
|
77
|
+
});
|
|
78
|
+
value3 = ref.value[import_constant.SUBJECT_VALUE];
|
|
79
|
+
}
|
|
80
|
+
ref.value[import_constant.SUBJECT_NEXT](value3, extra);
|
|
81
|
+
ref.changeValues.forEach((changeValue) => {
|
|
82
|
+
changeValue[import_constant.SUBJECT_NEXT](value3, extra);
|
|
83
|
+
});
|
|
84
|
+
nextValue[import_constant.SUBJECT_NEXT](value3, extra);
|
|
85
|
+
};
|
|
86
|
+
if (value2 == null ? void 0 : value2[import_constant.SUBJECT_SUBSCRIBE]) {
|
|
87
|
+
value2[import_constant.SUBJECT_SUBSCRIBE]((value3, extra) => {
|
|
88
|
+
next(value3, extra);
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
next(value2);
|
|
92
|
+
}
|
|
93
|
+
return nextValue;
|
|
94
|
+
},
|
|
95
|
+
/** 重置 */
|
|
96
|
+
reset(value2) {
|
|
97
|
+
const nextValue = new import_Subject.Subject();
|
|
98
|
+
const next = () => {
|
|
99
|
+
ref.value[import_constant.SUBJECT_NEXT](initValue);
|
|
100
|
+
ref.changeValues.forEach((changeValue) => {
|
|
101
|
+
changeValue[import_constant.SUBJECT_NEXT](initValue);
|
|
102
|
+
});
|
|
103
|
+
nextValue[import_constant.SUBJECT_NEXT](initValue);
|
|
104
|
+
};
|
|
105
|
+
if (value2 == null ? void 0 : value2[import_constant.SUBJECT_SUBSCRIBE]) {
|
|
106
|
+
value2[import_constant.SUBJECT_SUBSCRIBE](() => {
|
|
107
|
+
next();
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
next();
|
|
111
|
+
}
|
|
112
|
+
return nextValue;
|
|
113
|
+
},
|
|
114
|
+
/** 值变更监听 */
|
|
115
|
+
changed() {
|
|
116
|
+
const changeValue = new import_Subject.Subject();
|
|
117
|
+
ref.changeValues.add(changeValue);
|
|
118
|
+
const result = {
|
|
119
|
+
destroy() {
|
|
120
|
+
ref.changeValues.delete(changeValue);
|
|
121
|
+
},
|
|
122
|
+
[import_constant.SUBJECT_SUBSCRIBE](next) {
|
|
123
|
+
changeValue[import_constant.SUBJECT_SUBSCRIBE](next);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
if (import_context.context.apiRun) {
|
|
127
|
+
if (!import_context.context.apiRunVariablesSubject[import_context.context.apiRun]) {
|
|
128
|
+
import_context.context.apiRunVariablesSubject[import_context.context.apiRun] = [result];
|
|
129
|
+
} else {
|
|
130
|
+
import_context.context.apiRunVariablesSubject[import_context.context.apiRun].push(result);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
},
|
|
135
|
+
bind(callBack) {
|
|
136
|
+
if (!ref.callBacksMap.has("")) {
|
|
137
|
+
ref.callBacksMap.set("", /* @__PURE__ */ new Set());
|
|
138
|
+
}
|
|
139
|
+
const callBacks = ref.callBacksMap.get("");
|
|
140
|
+
callBacks.add(callBack);
|
|
141
|
+
callBack(ref.value[import_constant.SUBJECT_VALUE]);
|
|
142
|
+
},
|
|
143
|
+
ext() {
|
|
144
|
+
return {
|
|
145
|
+
setValue(value2) {
|
|
146
|
+
variable.set(value2);
|
|
147
|
+
},
|
|
148
|
+
getValue() {
|
|
149
|
+
return ref.value[import_constant.SUBJECT_VALUE];
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
registerChange(change) {
|
|
154
|
+
const changeValue = new import_Subject.Subject();
|
|
155
|
+
change(changeValue);
|
|
156
|
+
ref.changeValues.add(changeValue);
|
|
157
|
+
ref.changeValuesMap.set(change, changeValue);
|
|
158
|
+
if (!ref.value[import_constant.SUBJECT_EMPTY]) {
|
|
159
|
+
changeValue[import_constant.SUBJECT_NEXT](ref.value[import_constant.SUBJECT_VALUE]);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
unregisterChange(change) {
|
|
163
|
+
const changeValue = ref.changeValuesMap.get(change);
|
|
164
|
+
ref.changeValues.delete(changeValue);
|
|
165
|
+
ref.changeValuesMap.delete(change);
|
|
166
|
+
},
|
|
167
|
+
// 内置的赋值操作
|
|
168
|
+
setTrue() {
|
|
169
|
+
return variable.set(true);
|
|
170
|
+
},
|
|
171
|
+
setFalse() {
|
|
172
|
+
return variable.set(false);
|
|
173
|
+
},
|
|
174
|
+
setAryAdd(value2) {
|
|
175
|
+
const nextValue = new import_Subject.Subject();
|
|
176
|
+
if (Array.isArray(ref.value[import_constant.SUBJECT_VALUE])) {
|
|
177
|
+
const next = (value3) => {
|
|
178
|
+
const arrayValue = ref.value[import_constant.SUBJECT_VALUE].concat(value3);
|
|
179
|
+
ref.value[import_constant.SUBJECT_NEXT](arrayValue);
|
|
180
|
+
ref.changeValues.forEach((changeValue) => {
|
|
181
|
+
changeValue[import_constant.SUBJECT_NEXT](value3);
|
|
182
|
+
});
|
|
183
|
+
nextValue[import_constant.SUBJECT_NEXT](arrayValue);
|
|
184
|
+
};
|
|
185
|
+
if (value2 == null ? void 0 : value2[import_constant.SUBJECT_SUBSCRIBE]) {
|
|
186
|
+
value2[import_constant.SUBJECT_SUBSCRIBE]((value3) => {
|
|
187
|
+
next(value3);
|
|
188
|
+
});
|
|
189
|
+
} else {
|
|
190
|
+
next(value2);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return nextValue;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
return new Proxy({}, {
|
|
197
|
+
get(_, key) {
|
|
198
|
+
return variable[key];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
var createVars = (vars) => {
|
|
203
|
+
return new Proxy(vars, {
|
|
204
|
+
get(target, key) {
|
|
205
|
+
const value = target[key];
|
|
206
|
+
if (value) {
|
|
207
|
+
return value.get()[import_constant.SUBJECT_VALUE];
|
|
208
|
+
}
|
|
209
|
+
return value;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
214
|
+
0 && (module.exports = {
|
|
215
|
+
createVariable,
|
|
216
|
+
createVars
|
|
217
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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/utils/ComContext.tsx
|
|
20
|
+
var ComContext_exports = {};
|
|
21
|
+
__export(ComContext_exports, {
|
|
22
|
+
default: () => ComContext_default,
|
|
23
|
+
useAppContext: () => useAppContext
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ComContext_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var ComContext = (0, import_react.createContext)(void 0);
|
|
28
|
+
function useAppContext() {
|
|
29
|
+
const context = (0, import_react.useContext)(ComContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("useAppContext must be used within a ComContext.Provider");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
var ComContext_default = ComContext;
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
useAppContext
|
|
39
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
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/utils/index.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
WithCom: () => import_with.WithCom,
|
|
23
|
+
WithWrapper: () => import_with.WithWrapper,
|
|
24
|
+
useBindEvents: () => useBindEvents,
|
|
25
|
+
useBindInputs: () => useBindInputs,
|
|
26
|
+
useModel: () => useModel
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_with = require("./with");
|
|
31
|
+
function useModel(rawData) {
|
|
32
|
+
const [, forceUpdate] = (0, import_react.useState)({});
|
|
33
|
+
const dataRef = (0, import_react.useRef)(rawData || {});
|
|
34
|
+
return (0, import_react.useMemo)(() => {
|
|
35
|
+
return new Proxy(dataRef.current, {
|
|
36
|
+
get(target, key) {
|
|
37
|
+
return Reflect.get(target, key);
|
|
38
|
+
},
|
|
39
|
+
set(target, key, value) {
|
|
40
|
+
const result = Reflect.set(target, key, value);
|
|
41
|
+
forceUpdate({});
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
46
|
+
}
|
|
47
|
+
function useBindInputs(scope, id) {
|
|
48
|
+
return (0, import_react.useMemo)(() => {
|
|
49
|
+
const controller = scope[id] = scope[id] || {};
|
|
50
|
+
return new Proxy({}, {
|
|
51
|
+
get: (_target, pin) => {
|
|
52
|
+
return (arg) => {
|
|
53
|
+
if (typeof arg === "function") {
|
|
54
|
+
controller[pin] = arg;
|
|
55
|
+
} else {
|
|
56
|
+
const callback = controller[pin];
|
|
57
|
+
if (typeof callback === "function") {
|
|
58
|
+
callback(arg);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}, [scope, id]);
|
|
65
|
+
}
|
|
66
|
+
function useBindEvents(props) {
|
|
67
|
+
return (0, import_react.useMemo)(() => {
|
|
68
|
+
const _events = {};
|
|
69
|
+
Object.keys(props).forEach((key) => {
|
|
70
|
+
if (key.startsWith("on")) {
|
|
71
|
+
const handler = props[key];
|
|
72
|
+
if (typeof handler === "function") {
|
|
73
|
+
_events[key] = handler;
|
|
74
|
+
_events[key].getConnections = () => [1];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return _events;
|
|
79
|
+
}, [props]);
|
|
80
|
+
}
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
WithCom,
|
|
84
|
+
WithWrapper,
|
|
85
|
+
useBindEvents,
|
|
86
|
+
useBindInputs,
|
|
87
|
+
useModel
|
|
88
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
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/utils/useContext.ts
|
|
20
|
+
var useContext_exports = {};
|
|
21
|
+
__export(useContext_exports, {
|
|
22
|
+
useAppCreateContext: () => useAppCreateContext
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useContext_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
function useAppCreateContext() {
|
|
27
|
+
const comRefs = (0, import_react.useRef)({});
|
|
28
|
+
const appContext = {
|
|
29
|
+
canvas: {
|
|
30
|
+
id: "u_7VvVn"
|
|
31
|
+
// 使用 data 中的 id
|
|
32
|
+
},
|
|
33
|
+
runtime: {
|
|
34
|
+
debug: false
|
|
35
|
+
},
|
|
36
|
+
edit: false,
|
|
37
|
+
isH5: false,
|
|
38
|
+
isDesigner: false,
|
|
39
|
+
isPreview: false,
|
|
40
|
+
isRelease: false,
|
|
41
|
+
isDebug: false,
|
|
42
|
+
isLocal: false,
|
|
43
|
+
isTest: false
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
comRefs,
|
|
47
|
+
appContext
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
useAppCreateContext
|
|
53
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/core/utils/with.tsx
|
|
30
|
+
var with_exports = {};
|
|
31
|
+
__export(with_exports, {
|
|
32
|
+
WithCom: () => WithCom,
|
|
33
|
+
WithWrapper: () => WithWrapper
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(with_exports);
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_components = require("@tarojs/components");
|
|
38
|
+
var import_index = require("./index");
|
|
39
|
+
var import_useContext = require("./useContext");
|
|
40
|
+
var import_ComContext = __toESM(require("./ComContext"));
|
|
41
|
+
var WithCom = (props) => {
|
|
42
|
+
const { component: Component, id = "", data, className, style, ...rest } = props;
|
|
43
|
+
const { comRefs, appContext } = (0, import_ComContext.useAppContext)();
|
|
44
|
+
const env = appContext;
|
|
45
|
+
const [show, setShow] = (0, import_react.useState)(true);
|
|
46
|
+
(0, import_react.useEffect)(() => {
|
|
47
|
+
comRefs.current[id].hide(() => {
|
|
48
|
+
setShow(false);
|
|
49
|
+
});
|
|
50
|
+
comRefs.current[id].show(() => {
|
|
51
|
+
setShow(true);
|
|
52
|
+
});
|
|
53
|
+
comRefs.current[id].showOrHide(() => {
|
|
54
|
+
setShow((prev) => !prev);
|
|
55
|
+
});
|
|
56
|
+
}, [comRefs]);
|
|
57
|
+
const _data = (0, import_index.useModel)(data || {});
|
|
58
|
+
const inputProxy = (0, import_index.useBindInputs)(comRefs, id);
|
|
59
|
+
const eventProxy = (0, import_index.useBindEvents)(rest);
|
|
60
|
+
comRefs.current[id] = inputProxy;
|
|
61
|
+
return show ? /* @__PURE__ */ import_react.default.createElement(import_components.View, { className, style }, /* @__PURE__ */ import_react.default.createElement(
|
|
62
|
+
Component,
|
|
63
|
+
{
|
|
64
|
+
...rest,
|
|
65
|
+
inputs: inputProxy,
|
|
66
|
+
outputs: eventProxy,
|
|
67
|
+
data: _data,
|
|
68
|
+
env,
|
|
69
|
+
id,
|
|
70
|
+
style
|
|
71
|
+
}
|
|
72
|
+
)) : null;
|
|
73
|
+
};
|
|
74
|
+
var WithWrapper = (Component) => {
|
|
75
|
+
return function WrappedComponent(props) {
|
|
76
|
+
const contextStore = (0, import_useContext.useAppCreateContext)();
|
|
77
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ComContext.default.Provider, { value: contextStore }, /* @__PURE__ */ import_react.default.createElement(Component, { ...props }));
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
WithCom,
|
|
83
|
+
WithWrapper
|
|
84
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface FileNode {
|
|
2
|
+
path: string;
|
|
3
|
+
content: string | null;
|
|
4
|
+
children?: FileNode[];
|
|
5
|
+
}
|
|
6
|
+
interface GenerateItem {
|
|
7
|
+
type: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
cssContent?: string;
|
|
10
|
+
pageConfigContent?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
importManager?: {
|
|
13
|
+
toCode: () => string;
|
|
14
|
+
};
|
|
15
|
+
tabBarConfig?: string;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 根据数组生成文件结构 JSON 对象
|
|
20
|
+
* @param items 包含 content、cssContent、pageConfigContent、tabBarConfig 等信息的数组
|
|
21
|
+
* @returns 返回文件结构的 JSON 对象数组
|
|
22
|
+
*/
|
|
23
|
+
declare const generateTaroProjectJson: (items?: GenerateItem[]) => FileNode[];
|
|
24
|
+
export default generateTaroProjectJson;
|