@mybricks/to-code-taro 1.1.0 → 1.1.4
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/core/comlib/{index.js → Index.js} +6 -6
- package/dist/cjs/core/utils/PopupRenderer.js +1 -1
- package/dist/cjs/core/utils/hooks.js +102 -38
- package/dist/cjs/core/utils/slots.js +11 -4
- package/dist/cjs/core/utils/useContext.js +6 -4
- package/dist/cjs/core/utils/with.js +3 -3
- package/dist/cjs/generate/generateTaroProjectJson.js +36 -11
- package/dist/cjs/generate/utils/commonDir.js +14 -10
- package/dist/cjs/generate/utils/pageImages.d.ts +14 -0
- package/dist/cjs/generate/utils/pageImages.js +36 -0
- package/dist/cjs/handleCom.js +37 -14
- package/dist/cjs/handleDom.d.ts +2 -0
- package/dist/cjs/handleDom.js +5 -2
- package/dist/cjs/handleGlobal.js +4 -2
- package/dist/cjs/handleSlot.d.ts +3 -0
- package/dist/cjs/handleSlot.js +38 -10
- package/dist/cjs/processors/processScene.js +3 -1
- package/dist/cjs/taro-template.json +313 -13
- package/dist/cjs/toCodeTaro.d.ts +4 -1
- package/dist/cjs/toCodeTaro.js +80 -1
- package/dist/cjs/utils/builder/buildResult.js +3 -16
- package/dist/cjs/utils/config/content/converter.js +2 -2
- package/dist/cjs/utils/config/content/pageConfig.js +4 -1
- package/dist/cjs/utils/config/content/saveBase64Image.d.ts +10 -0
- package/dist/cjs/utils/config/content/saveBase64Image.js +44 -3
- package/dist/cjs/utils/config/content/tabBarConfig.js +8 -2
- package/dist/cjs/utils/config/handlePageConfig.js +5 -3
- package/dist/cjs/utils/context/collectJSModules.d.ts +4 -0
- package/dist/cjs/utils/context/collectJSModules.js +4 -2
- package/dist/cjs/utils/logic/genJSModules.d.ts +8 -4
- package/dist/cjs/utils/logic/genJSModules.js +31 -33
- package/dist/cjs/utils/logic/handleProcess.js +4 -4
- package/dist/cjs/utils/logic/processChildren.d.ts +14 -1
- package/dist/cjs/utils/logic/processChildren.js +30 -6
- package/dist/cjs/utils/style/converter.js +34 -72
- package/dist/cjs/utils/templates/index.d.ts +1 -0
- package/dist/cjs/utils/templates/index.js +11 -2
- package/dist/cjs/utils/templates/renderManager.d.ts +4 -0
- package/dist/cjs/utils/templates/renderManager.js +10 -3
- package/dist/cjs/utils/templates/scene.js +13 -1
- package/dist/esm/core/comlib/{index.js → Index.js} +1 -1
- package/dist/esm/core/utils/PopupRenderer.js +1 -1
- package/dist/esm/core/utils/hooks.js +137 -53
- package/dist/esm/core/utils/popupRouter.js +2 -1
- package/dist/esm/core/utils/slots.js +24 -22
- package/dist/esm/core/utils/useContext.js +8 -10
- package/dist/esm/core/utils/with.js +3 -3
- package/dist/esm/generate/generateTaroProjectJson.js +28 -8
- package/dist/esm/generate/utils/commonDir.js +18 -14
- package/dist/esm/generate/utils/pageImages.d.ts +14 -0
- package/dist/esm/generate/utils/pageImages.d.ts.map +1 -0
- package/dist/esm/generate/utils/pageImages.js +15 -0
- package/dist/esm/handleCom.js +44 -17
- package/dist/esm/handleDom.d.ts +2 -0
- package/dist/esm/handleDom.js +6 -4
- package/dist/esm/handleGlobal.js +4 -2
- package/dist/esm/handleSlot.d.ts +3 -0
- package/dist/esm/handleSlot.js +57 -12
- package/dist/esm/processors/processComEvents.d.ts.map +1 -0
- package/dist/esm/processors/processScene.d.ts.map +1 -1
- package/dist/esm/processors/processScene.js +13 -3
- package/dist/esm/processors/processSceneLogic.d.ts.map +1 -0
- package/dist/esm/taro-template.json +313 -13
- package/dist/esm/toCodeTaro.d.ts +4 -1
- package/dist/esm/toCodeTaro.d.ts.map +1 -1
- package/dist/esm/toCodeTaro.js +89 -4
- package/dist/esm/utils/builder/buildResult.d.ts.map +1 -1
- package/dist/esm/utils/builder/buildResult.js +5 -14
- package/dist/esm/utils/common/helper.d.ts.map +1 -0
- package/dist/esm/utils/config/content/converter.js +2 -2
- package/dist/esm/utils/config/content/pageConfig.js +4 -1
- package/dist/esm/utils/config/content/saveBase64Image.d.ts +10 -0
- package/dist/esm/utils/config/content/saveBase64Image.js +42 -1
- package/dist/esm/utils/config/content/tabBarConfig.js +7 -2
- package/dist/esm/utils/config/handlePageConfig.d.ts.map +1 -1
- package/dist/esm/utils/config/handlePageConfig.js +5 -3
- package/dist/esm/utils/context/collectJSModules.d.ts +4 -0
- package/dist/esm/utils/context/collectJSModules.d.ts.map +1 -1
- package/dist/esm/utils/context/collectJSModules.js +1 -1
- package/dist/esm/utils/logic/genJSModules.d.ts +8 -4
- package/dist/esm/utils/logic/genJSModules.d.ts.map +1 -1
- package/dist/esm/utils/logic/genJSModules.js +16 -27
- package/dist/esm/utils/logic/handleProcess.js +4 -4
- package/dist/esm/utils/logic/processChildren.d.ts +14 -1
- package/dist/esm/utils/logic/processChildren.js +45 -8
- package/dist/esm/utils/style/converter.js +57 -106
- package/dist/esm/utils/templates/index.d.ts +1 -0
- package/dist/esm/utils/templates/index.js +9 -2
- package/dist/esm/utils/templates/renderManager.d.ts +4 -0
- package/dist/esm/utils/templates/renderManager.js +17 -4
- package/dist/esm/utils/templates/scene.js +8 -2
- package/package.json +1 -1
- package/dist/esm/generate/generateTaroProjectJson.d.ts.map +0 -1
- package/dist/esm/generate/utils/commonDir.d.ts.map +0 -1
- package/dist/esm/handleDom.d.ts.map +0 -1
- package/dist/esm/handleGlobal.d.ts.map +0 -1
- package/dist/esm/utils/config/content/converter.d.ts.map +0 -1
- package/dist/esm/utils/config/content/pageConfig.d.ts.map +0 -1
- package/dist/esm/utils/config/content/saveBase64Image.d.ts.map +0 -1
- package/dist/esm/utils/config/content/tabBarConfig.d.ts.map +0 -1
- package/dist/esm/utils/logic/processChildren.d.ts.map +0 -1
|
@@ -26,11 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// src/core/comlib/
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
29
|
+
// src/core/comlib/Index.ts
|
|
30
|
+
var Index_exports = {};
|
|
31
|
+
__export(Index_exports, {
|
|
32
32
|
mybricks_taro_aesEncode: () => import_AesEncode.default,
|
|
33
|
-
mybricks_taro_backTo: () => import_BackTo.default,
|
|
34
33
|
mybricks_taro_callPhone: () => import_CallPhone.default,
|
|
35
34
|
mybricks_taro_chooseFile: () => import_ChooseFile.default,
|
|
36
35
|
mybricks_taro_chooseMedia: () => import_ChooseMedia.default,
|
|
@@ -41,6 +40,7 @@ __export(comlib_exports, {
|
|
|
41
40
|
mybricks_taro_getStorage: () => import_GetStorage.default,
|
|
42
41
|
mybricks_taro_getSystemInfo: () => import_GetSystemInfo.default,
|
|
43
42
|
mybricks_taro_modal: () => import_Modal.default,
|
|
43
|
+
mybricks_taro_navigateBack: () => import_BackTo.default,
|
|
44
44
|
mybricks_taro_openCamera: () => import_OpenCamera.default,
|
|
45
45
|
mybricks_taro_openPetalMap: () => import_OpenPetalMap.default,
|
|
46
46
|
mybricks_taro_openUrl: () => import_OpenUrl.default,
|
|
@@ -56,7 +56,7 @@ __export(comlib_exports, {
|
|
|
56
56
|
mybricks_taro_timerThrottle: () => import_TimerThrottle.default,
|
|
57
57
|
mybricks_taro_vibrate: () => import_Vibrate.default
|
|
58
58
|
});
|
|
59
|
-
module.exports = __toCommonJS(
|
|
59
|
+
module.exports = __toCommonJS(Index_exports);
|
|
60
60
|
var import_ShowToast = __toESM(require("./_ShowToast"));
|
|
61
61
|
var import_ScanQrcode = __toESM(require("./_ScanQrcode"));
|
|
62
62
|
var import_SetStorage = __toESM(require("./_SetStorage"));
|
|
@@ -86,7 +86,6 @@ var import_TimerThrottle = __toESM(require("./_TimerThrottle"));
|
|
|
86
86
|
// Annotate the CommonJS export names for ESM import in node:
|
|
87
87
|
0 && (module.exports = {
|
|
88
88
|
mybricks_taro_aesEncode,
|
|
89
|
-
mybricks_taro_backTo,
|
|
90
89
|
mybricks_taro_callPhone,
|
|
91
90
|
mybricks_taro_chooseFile,
|
|
92
91
|
mybricks_taro_chooseMedia,
|
|
@@ -97,6 +96,7 @@ var import_TimerThrottle = __toESM(require("./_TimerThrottle"));
|
|
|
97
96
|
mybricks_taro_getStorage,
|
|
98
97
|
mybricks_taro_getSystemInfo,
|
|
99
98
|
mybricks_taro_modal,
|
|
99
|
+
mybricks_taro_navigateBack,
|
|
100
100
|
mybricks_taro_openCamera,
|
|
101
101
|
mybricks_taro_openPetalMap,
|
|
102
102
|
mybricks_taro_openUrl,
|
|
@@ -39,7 +39,7 @@ var PopupRenderer = ({ popupMap }) => {
|
|
|
39
39
|
const { popupState } = (0, import_ComContext.useAppContext)();
|
|
40
40
|
const ActivePopup = popupState.visible && popupMap[popupState.name] ? popupMap[popupState.name] : null;
|
|
41
41
|
if (!ActivePopup)
|
|
42
|
-
return null;
|
|
42
|
+
return /* @__PURE__ */ import_react.default.createElement(import_components.View, null);
|
|
43
43
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
44
44
|
import_components.View,
|
|
45
45
|
{
|
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var hooks_exports = {};
|
|
21
21
|
__export(hooks_exports, {
|
|
22
22
|
deepProxy: () => deepProxy,
|
|
23
|
+
proxyRefs: () => proxyRefs,
|
|
23
24
|
useBindEvents: () => useBindEvents,
|
|
24
25
|
useBindInputs: () => useBindInputs,
|
|
25
26
|
useModel: () => useModel
|
|
@@ -27,17 +28,17 @@ __export(hooks_exports, {
|
|
|
27
28
|
module.exports = __toCommonJS(hooks_exports);
|
|
28
29
|
var import_react = require("react");
|
|
29
30
|
var import_createReactiveInputHandler = require("../mybricks/createReactiveInputHandler");
|
|
31
|
+
var import_ComContext = require("./ComContext");
|
|
30
32
|
function deepProxy(target, onSet) {
|
|
31
|
-
if (target === null || typeof target !== "object" || target.__isProxy)
|
|
33
|
+
if (target === null || typeof target !== "object" || target.__isProxy)
|
|
32
34
|
return target;
|
|
33
|
-
}
|
|
34
35
|
return new Proxy(target, {
|
|
35
36
|
get(obj, prop) {
|
|
36
37
|
if (prop === "__isProxy")
|
|
37
38
|
return true;
|
|
38
39
|
if (prop === "toJSON")
|
|
39
40
|
return () => obj;
|
|
40
|
-
|
|
41
|
+
const value = obj[prop];
|
|
41
42
|
if (typeof value === "object" && value !== null && !value.__isProxy) {
|
|
42
43
|
obj[prop] = deepProxy(value, onSet);
|
|
43
44
|
}
|
|
@@ -45,8 +46,7 @@ function deepProxy(target, onSet) {
|
|
|
45
46
|
},
|
|
46
47
|
set(obj, prop, value) {
|
|
47
48
|
const result = Reflect.set(obj, prop, value);
|
|
48
|
-
|
|
49
|
-
onSet();
|
|
49
|
+
onSet == null ? void 0 : onSet();
|
|
50
50
|
return result;
|
|
51
51
|
}
|
|
52
52
|
});
|
|
@@ -54,74 +54,137 @@ function deepProxy(target, onSet) {
|
|
|
54
54
|
function useModel(rawData) {
|
|
55
55
|
const [, forceUpdate] = (0, import_react.useState)({});
|
|
56
56
|
const dataRef = (0, import_react.useRef)(rawData || {});
|
|
57
|
-
return (0, import_react.useMemo)(() => {
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
return (0, import_react.useMemo)(() => deepProxy(dataRef.current, () => forceUpdate({})), []);
|
|
58
|
+
}
|
|
59
|
+
function proxyRefs(target, parentComRefs, globalTodoPool) {
|
|
60
|
+
return new Proxy(target, {
|
|
61
|
+
get(obj, prop) {
|
|
62
|
+
if (prop === "__isProxy")
|
|
63
|
+
return true;
|
|
64
|
+
if (prop === "toJSON")
|
|
65
|
+
return () => obj;
|
|
66
|
+
if (typeof prop === "string" && prop.startsWith("u_") && obj[prop] === void 0) {
|
|
67
|
+
return obj[prop] = new Proxy({ __isShadow: true }, {
|
|
68
|
+
get(_, method) {
|
|
69
|
+
if (method === "__isShadow")
|
|
70
|
+
return true;
|
|
71
|
+
return (...args) => {
|
|
72
|
+
if (!(globalTodoPool instanceof Map))
|
|
73
|
+
return;
|
|
74
|
+
const instances = globalTodoPool.get(prop) || [];
|
|
75
|
+
if (!globalTodoPool.has(prop))
|
|
76
|
+
globalTodoPool.set(prop, instances);
|
|
77
|
+
const index = obj.$index ?? 0;
|
|
78
|
+
const todo = instances[index] || (instances[index] = {});
|
|
79
|
+
todo[method] = args;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return obj[prop];
|
|
85
|
+
},
|
|
86
|
+
set(obj, prop, value) {
|
|
87
|
+
const result = Reflect.set(obj, prop, value);
|
|
88
|
+
const isRealRef = typeof prop === "string" && !prop.startsWith("$") && (value == null ? void 0 : value.__isShadow) !== true;
|
|
89
|
+
if (isRealRef && (parentComRefs == null ? void 0 : parentComRefs.current)) {
|
|
90
|
+
try {
|
|
91
|
+
parentComRefs.current[prop] = value;
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
},
|
|
97
|
+
deleteProperty(obj, prop) {
|
|
98
|
+
const result = Reflect.deleteProperty(obj, prop);
|
|
99
|
+
const isRealRef = typeof prop === "string" && !prop.startsWith("$");
|
|
100
|
+
if (isRealRef && (parentComRefs == null ? void 0 : parentComRefs.current)) {
|
|
101
|
+
try {
|
|
102
|
+
delete parentComRefs.current[prop];
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
60
109
|
}
|
|
61
110
|
function useBindInputs(scope, id, initialHandlers) {
|
|
111
|
+
var _a, _b;
|
|
62
112
|
const handlersRef = (0, import_react.useRef)({ ...initialHandlers });
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
113
|
+
const { globalTodoInputs } = (0, import_ComContext.useAppContext)();
|
|
114
|
+
const parentSlot = (0, import_ComContext.useParentSlot)();
|
|
115
|
+
const index = ((_b = (_a = parentSlot == null ? void 0 : parentSlot.params) == null ? void 0 : _a.inputValues) == null ? void 0 : _b.index) ?? 0;
|
|
116
|
+
(0, import_react.useEffect)(() => {
|
|
117
|
+
return () => {
|
|
118
|
+
if (scope == null ? void 0 : scope.current) {
|
|
119
|
+
delete scope.current[id];
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}, [scope, id]);
|
|
66
123
|
return (0, import_react.useMemo)(() => {
|
|
67
124
|
const proxy = new Proxy({}, {
|
|
68
|
-
get: (
|
|
125
|
+
get: (target, pin) => {
|
|
126
|
+
if (pin === "__isShadow")
|
|
127
|
+
return false;
|
|
128
|
+
if (pin === "toJSON")
|
|
129
|
+
return () => target;
|
|
69
130
|
return (arg, ...args) => {
|
|
70
131
|
if (typeof arg === "function") {
|
|
71
132
|
handlersRef.current[pin] = arg;
|
|
133
|
+
const instances = globalTodoInputs == null ? void 0 : globalTodoInputs.get(id);
|
|
134
|
+
const todo = (instances == null ? void 0 : instances[index]) || (instances == null ? void 0 : instances[0]);
|
|
135
|
+
if (todo == null ? void 0 : todo[pin]) {
|
|
136
|
+
const pendingArgs = todo[pin];
|
|
137
|
+
if (pin === "_setData") {
|
|
138
|
+
arg(...pendingArgs);
|
|
139
|
+
} else {
|
|
140
|
+
(0, import_createReactiveInputHandler.createReactiveInputHandler)({ input: arg, value: pendingArgs[0], rels: {}, title: id });
|
|
141
|
+
}
|
|
142
|
+
delete todo[pin];
|
|
143
|
+
const hasTasks = instances == null ? void 0 : instances.some((inst) => inst && Object.keys(inst).length > 0);
|
|
144
|
+
if (!hasTasks)
|
|
145
|
+
globalTodoInputs.delete(id);
|
|
146
|
+
}
|
|
72
147
|
} else {
|
|
73
148
|
const handler = handlersRef.current[pin];
|
|
74
149
|
if (typeof handler === "function") {
|
|
75
|
-
|
|
76
|
-
return handler(arg, ...args);
|
|
77
|
-
}
|
|
78
|
-
return (0, import_createReactiveInputHandler.createReactiveInputHandler)({
|
|
79
|
-
input: handler,
|
|
80
|
-
value: arg,
|
|
81
|
-
rels: {},
|
|
82
|
-
// 这里可以扩展 output 关联
|
|
83
|
-
title: id
|
|
84
|
-
});
|
|
150
|
+
return pin === "_setData" ? handler(arg, ...args) : (0, import_createReactiveInputHandler.createReactiveInputHandler)({ input: handler, value: arg, rels: {}, title: id });
|
|
85
151
|
}
|
|
86
152
|
}
|
|
87
153
|
};
|
|
88
154
|
}
|
|
89
155
|
});
|
|
90
|
-
if (scope
|
|
156
|
+
if (scope == null ? void 0 : scope.current)
|
|
91
157
|
scope.current[id] = proxy;
|
|
158
|
+
if (initialHandlers) {
|
|
159
|
+
Object.keys(initialHandlers).forEach((pin) => proxy[pin](initialHandlers[pin]));
|
|
92
160
|
}
|
|
93
161
|
return proxy;
|
|
94
|
-
}, [scope, id]);
|
|
162
|
+
}, [scope, id, globalTodoInputs, index]);
|
|
95
163
|
}
|
|
96
164
|
function useBindEvents(props, context) {
|
|
97
165
|
return (0, import_react.useMemo)(() => {
|
|
98
|
-
const
|
|
166
|
+
const events = {};
|
|
99
167
|
Object.keys(props).forEach((key) => {
|
|
100
168
|
if (typeof props[key] === "function") {
|
|
101
169
|
const handler = props[key];
|
|
102
|
-
const wrapped = (
|
|
170
|
+
const wrapped = (original) => {
|
|
103
171
|
var _a, _b;
|
|
104
|
-
const value = ((_b = (_a = context == null ? void 0 : context.parentSlot) == null ? void 0 : _a.params) == null ? void 0 : _b.itemWrap) ? {
|
|
105
|
-
id: context.id,
|
|
106
|
-
name: context.name,
|
|
107
|
-
value: originalValue
|
|
108
|
-
} : originalValue;
|
|
172
|
+
const value = ((_b = (_a = context == null ? void 0 : context.parentSlot) == null ? void 0 : _a.params) == null ? void 0 : _b.itemWrap) ? { id: context.id, name: context.name, value: original } : original;
|
|
109
173
|
return handler(value);
|
|
110
174
|
};
|
|
111
175
|
wrapped.getConnections = () => [{ id: "default" }];
|
|
112
|
-
|
|
176
|
+
events[key] = wrapped;
|
|
113
177
|
}
|
|
114
178
|
});
|
|
115
|
-
return new Proxy(
|
|
179
|
+
return new Proxy(events, {
|
|
116
180
|
get(target, key) {
|
|
117
181
|
if (typeof key === "string" && key.startsWith("on")) {
|
|
118
|
-
if (target[key])
|
|
182
|
+
if (target[key])
|
|
119
183
|
return target[key];
|
|
120
|
-
|
|
121
|
-
const emptyFn = () => {
|
|
184
|
+
const fn = () => {
|
|
122
185
|
};
|
|
123
|
-
|
|
124
|
-
return
|
|
186
|
+
fn.getConnections = () => [];
|
|
187
|
+
return fn;
|
|
125
188
|
}
|
|
126
189
|
return target[key];
|
|
127
190
|
}
|
|
@@ -131,6 +194,7 @@ function useBindEvents(props, context) {
|
|
|
131
194
|
// Annotate the CommonJS export names for ESM import in node:
|
|
132
195
|
0 && (module.exports = {
|
|
133
196
|
deepProxy,
|
|
197
|
+
proxyRefs,
|
|
134
198
|
useBindEvents,
|
|
135
199
|
useBindInputs,
|
|
136
200
|
useModel
|
|
@@ -37,6 +37,11 @@ module.exports = __toCommonJS(slots_exports);
|
|
|
37
37
|
var import_react = __toESM(require("react"));
|
|
38
38
|
var import_ComContext = __toESM(require("./ComContext"));
|
|
39
39
|
var import_createReactiveInputHandler = require("../mybricks/createReactiveInputHandler");
|
|
40
|
+
var import_hooks = require("./hooks");
|
|
41
|
+
function createPenetratingComRefs(parentComRefs, globalTodoPool, index = 0) {
|
|
42
|
+
const localTarget = { $inputs: {}, $outputs: {}, $index: index };
|
|
43
|
+
return { current: (0, import_hooks.proxyRefs)(localTarget, parentComRefs, globalTodoPool) };
|
|
44
|
+
}
|
|
40
45
|
function SlotParamsBridge(props) {
|
|
41
46
|
var _a, _b;
|
|
42
47
|
const parentSlot = (0, import_ComContext.useParentSlot)();
|
|
@@ -71,6 +76,7 @@ function createChannelProxy(title) {
|
|
|
71
76
|
);
|
|
72
77
|
}
|
|
73
78
|
function useEnhancedSlots(rawSlots, id) {
|
|
79
|
+
const { comRefs: parentComRefs, globalTodoInputs } = (0, import_ComContext.useAppContext)();
|
|
74
80
|
const slotStoreRef = (0, import_react.useRef)({});
|
|
75
81
|
return (0, import_react.useMemo)(() => {
|
|
76
82
|
if (!rawSlots)
|
|
@@ -84,15 +90,16 @@ function useEnhancedSlots(rawSlots, id) {
|
|
|
84
90
|
_scopedComRefs: {},
|
|
85
91
|
_render: void 0,
|
|
86
92
|
render: (params) => {
|
|
87
|
-
var _a, _b, _c, _d;
|
|
93
|
+
var _a, _b, _c, _d, _e;
|
|
88
94
|
const r = state._render;
|
|
89
95
|
const rawScope = (params == null ? void 0 : params.key) ?? ((_a = params == null ? void 0 : params.inputValues) == null ? void 0 : _a.index) ?? ((_c = (_b = params == null ? void 0 : params.inputValues) == null ? void 0 : _b.itemData) == null ? void 0 : _c.id);
|
|
90
96
|
if (rawScope === void 0 || rawScope === null) {
|
|
91
97
|
return /* @__PURE__ */ import_react.default.createElement(SlotParamsBridge, { state, params, render: r });
|
|
92
98
|
}
|
|
93
99
|
const scopeId = `${id}.${slotKey}::${String(rawScope)}`;
|
|
94
|
-
const
|
|
95
|
-
|
|
100
|
+
const index = ((_d = params == null ? void 0 : params.inputValues) == null ? void 0 : _d.index) ?? 0;
|
|
101
|
+
const scopedComRefs = (_e = state._scopedComRefs)[scopeId] || (_e[scopeId] = createPenetratingComRefs(parentComRefs, globalTodoInputs, index));
|
|
102
|
+
return /* @__PURE__ */ import_react.default.createElement(ScopedComContextProvider, { comRefs: scopedComRefs, scopeId }, /* @__PURE__ */ import_react.default.createElement(SlotParamsBridge, { state, params, render: r }));
|
|
96
103
|
}
|
|
97
104
|
});
|
|
98
105
|
state._render = slotDef == null ? void 0 : slotDef.render;
|
|
@@ -105,7 +112,7 @@ function useEnhancedSlots(rawSlots, id) {
|
|
|
105
112
|
};
|
|
106
113
|
});
|
|
107
114
|
return nextSlots;
|
|
108
|
-
}, [rawSlots, id]);
|
|
115
|
+
}, [rawSlots, id, parentComRefs, globalTodoInputs]);
|
|
109
116
|
}
|
|
110
117
|
function ScopedComContextProvider(props) {
|
|
111
118
|
const parent = (0, import_ComContext.useAppContext)();
|
|
@@ -24,8 +24,10 @@ __export(useContext_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(useContext_exports);
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
var import_hooks = require("./hooks");
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var GLOBAL_TODO_POOL = /* @__PURE__ */ new Map();
|
|
28
|
+
function useAppCreateContext(id) {
|
|
29
|
+
const globalTodoInputs = (0, import_react.useRef)(GLOBAL_TODO_POOL);
|
|
30
|
+
const comRefs = (0, import_react.useRef)((0, import_hooks.proxyRefs)({ $inputs: {}, $outputs: {} }, void 0, globalTodoInputs.current));
|
|
29
31
|
const $vars = (0, import_react.useRef)({});
|
|
30
32
|
const $fxs = (0, import_react.useRef)({});
|
|
31
33
|
const [popupState, setPopupState] = (0, import_react.useState)({
|
|
@@ -36,8 +38,7 @@ function useAppCreateContext() {
|
|
|
36
38
|
});
|
|
37
39
|
const appContext = (0, import_react.useRef)({
|
|
38
40
|
canvas: {
|
|
39
|
-
id
|
|
40
|
-
// 使用 data 中的 id
|
|
41
|
+
id
|
|
41
42
|
},
|
|
42
43
|
runtime: {
|
|
43
44
|
debug: false
|
|
@@ -57,6 +58,7 @@ function useAppCreateContext() {
|
|
|
57
58
|
comRefs,
|
|
58
59
|
$vars,
|
|
59
60
|
$fxs,
|
|
61
|
+
globalTodoInputs: globalTodoInputs.current,
|
|
60
62
|
appContext,
|
|
61
63
|
popupState,
|
|
62
64
|
setPopupState
|
|
@@ -109,11 +109,11 @@ var WithCom = (props) => {
|
|
|
109
109
|
style
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
return show || isPopup ? /* @__PURE__ */ import_react.default.createElement(import_components.View, { className, style: { ...style, ...dynamicStyle } }, jsx) : null;
|
|
112
|
+
return show || isPopup ? /* @__PURE__ */ import_react.default.createElement(import_components.View, { className, style: { ...style, ...dynamicStyle } }, jsx, props.children) : null;
|
|
113
113
|
};
|
|
114
|
-
var WithWrapper = (Component) => {
|
|
114
|
+
var WithWrapper = (id, Component) => {
|
|
115
115
|
return function WrappedComponent(props) {
|
|
116
|
-
const contextStore = (0, import_useContext.useAppCreateContext)();
|
|
116
|
+
const contextStore = (0, import_useContext.useAppCreateContext)(id);
|
|
117
117
|
const { setPopupState } = contextStore;
|
|
118
118
|
const isPopup = Component.isPopup;
|
|
119
119
|
(0, import_react.useEffect)(() => {
|
|
@@ -37,7 +37,9 @@ var path = __toESM(require("path"));
|
|
|
37
37
|
var import_fileNode = require("./utils/fileNode");
|
|
38
38
|
var import_commonDir = require("./utils/commonDir");
|
|
39
39
|
var import_tabBarImages = require("./utils/tabBarImages");
|
|
40
|
+
var import_pageImages = require("./utils/pageImages");
|
|
40
41
|
var import_appConfig = require("./utils/appConfig");
|
|
42
|
+
var import_genJSModules = require("../utils/logic/genJSModules");
|
|
41
43
|
var generateTaroProjectJson = (result) => {
|
|
42
44
|
var _a, _b;
|
|
43
45
|
const { files = [], assets = {} } = result;
|
|
@@ -59,6 +61,7 @@ var generateTaroProjectJson = (result) => {
|
|
|
59
61
|
const assetsDir = (0, import_fileNode.ensureDir)(srcDir, "src/assets");
|
|
60
62
|
const tabbarDir = (0, import_fileNode.ensureDir)(assetsDir, "src/assets/tabbar");
|
|
61
63
|
const imageFiles = assets.tabBarImages || [];
|
|
64
|
+
const pageImages = assets.pageImages || [];
|
|
62
65
|
const normalItems = files.filter((item) => item.type === "normal");
|
|
63
66
|
const generatedPages = normalItems.map((item) => {
|
|
64
67
|
var _a2;
|
|
@@ -84,6 +87,16 @@ ${fileContent}` : fileContent;
|
|
|
84
87
|
content: fullContent
|
|
85
88
|
}
|
|
86
89
|
];
|
|
90
|
+
if (item.jsModules && item.jsModules.length > 0) {
|
|
91
|
+
pageChildren.push({
|
|
92
|
+
path: `src/pages/${pageName}/index.jsModules.ts`,
|
|
93
|
+
content: (0, import_genJSModules.genScopedJSModules)(
|
|
94
|
+
item.jsModules,
|
|
95
|
+
"@/core/mybricks/index",
|
|
96
|
+
"@/common/jsModulesRuntime"
|
|
97
|
+
)
|
|
98
|
+
});
|
|
99
|
+
}
|
|
87
100
|
return {
|
|
88
101
|
path: `src/pages/${pageName}`,
|
|
89
102
|
content: null,
|
|
@@ -99,19 +112,30 @@ ${fileContent}` : fileContent;
|
|
|
99
112
|
const importCode = ((_a2 = item.importManager) == null ? void 0 : _a2.toCode()) || "";
|
|
100
113
|
const fullContent = `${importCode}
|
|
101
114
|
${item.content || ""}`;
|
|
115
|
+
const popupChildren = [
|
|
116
|
+
{
|
|
117
|
+
path: `src/popupComponents/${popupId}/index.tsx`,
|
|
118
|
+
content: fullContent
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
path: `src/popupComponents/${popupId}/index.global.less`,
|
|
122
|
+
content: item.cssContent || ""
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
if (item.jsModules && item.jsModules.length > 0) {
|
|
126
|
+
popupChildren.push({
|
|
127
|
+
path: `src/popupComponents/${popupId}/index.jsModules.ts`,
|
|
128
|
+
content: (0, import_genJSModules.genScopedJSModules)(
|
|
129
|
+
item.jsModules,
|
|
130
|
+
"@/core/mybricks/index",
|
|
131
|
+
"@/common/jsModulesRuntime"
|
|
132
|
+
)
|
|
133
|
+
});
|
|
134
|
+
}
|
|
102
135
|
popupComponentsDir.children.push({
|
|
103
136
|
path: `src/popupComponents/${popupId}`,
|
|
104
137
|
content: null,
|
|
105
|
-
children:
|
|
106
|
-
{
|
|
107
|
-
path: `src/popupComponents/${popupId}/index.tsx`,
|
|
108
|
-
content: fullContent
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
path: `src/popupComponents/${popupId}/index.global.less`,
|
|
112
|
-
content: item.cssContent || ""
|
|
113
|
-
}
|
|
114
|
-
]
|
|
138
|
+
children: popupChildren
|
|
115
139
|
});
|
|
116
140
|
});
|
|
117
141
|
const appConfigFile = (_a = srcDir.children) == null ? void 0 : _a.find(
|
|
@@ -121,9 +145,10 @@ ${item.content || ""}`;
|
|
|
121
145
|
(0, import_appConfig.updateAppConfig)(appConfigFile, normalItems, files);
|
|
122
146
|
}
|
|
123
147
|
(0, import_tabBarImages.handleTabBarImages)(tabbarDir, imageFiles);
|
|
148
|
+
(0, import_pageImages.handlePageImages)(assetsDir, pageImages);
|
|
124
149
|
const CUSTOM_TAB_BAR_CONFIG_PATH = "src/custom-tab-bar/mybricks/tabbar-config.ts";
|
|
125
150
|
const customTabBarItem = files.find((item) => item.type === "customTabBar");
|
|
126
|
-
if (customTabBarItem.content) {
|
|
151
|
+
if (customTabBarItem == null ? void 0 : customTabBarItem.content) {
|
|
127
152
|
const customTabBarDir = (0, import_fileNode.ensureDir)(srcDir, "src/custom-tab-bar");
|
|
128
153
|
const mybricksDir = (0, import_fileNode.ensureDir)(customTabBarDir, "src/custom-tab-bar/mybricks");
|
|
129
154
|
const tabbarConfigFileIndex = (_b = mybricksDir.children) == null ? void 0 : _b.findIndex(
|
|
@@ -23,24 +23,28 @@ __export(commonDir_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(commonDir_exports);
|
|
25
25
|
function handleCommonDir(commonDir, items) {
|
|
26
|
-
var _a;
|
|
26
|
+
var _a, _b;
|
|
27
27
|
commonDir.children = commonDir.children || [];
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const importCode = ((_a =
|
|
31
|
-
const fileContent =
|
|
28
|
+
const jsModulesRuntimeItem = items.find((item) => item.type === "jsModulesRuntime");
|
|
29
|
+
if (jsModulesRuntimeItem) {
|
|
30
|
+
const importCode = ((_a = jsModulesRuntimeItem.importManager) == null ? void 0 : _a.toCode()) || "";
|
|
31
|
+
const fileContent = jsModulesRuntimeItem.content || "";
|
|
32
32
|
const fullContent = importCode ? `${importCode}
|
|
33
33
|
${fileContent}` : fileContent;
|
|
34
34
|
commonDir.children.push({
|
|
35
|
-
path: "src/common/
|
|
35
|
+
path: "src/common/jsModulesRuntime.ts",
|
|
36
36
|
content: fullContent
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
39
|
+
const globalItem = items.find((item) => item.type === "global");
|
|
40
|
+
if (globalItem) {
|
|
41
|
+
const importCode = ((_b = globalItem.importManager) == null ? void 0 : _b.toCode()) || "";
|
|
42
|
+
const fileContent = globalItem.content || "";
|
|
43
|
+
const fullContent = importCode ? `${importCode}
|
|
44
|
+
${fileContent}` : fileContent;
|
|
41
45
|
commonDir.children.push({
|
|
42
|
-
path: "src/common/
|
|
43
|
-
content:
|
|
46
|
+
path: "src/common/global.ts",
|
|
47
|
+
content: fullContent
|
|
44
48
|
});
|
|
45
49
|
}
|
|
46
50
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页面图片文件处理工具
|
|
3
|
+
*/
|
|
4
|
+
import type { ImageFileInfo } from '../../utils/config/content';
|
|
5
|
+
interface FileNode {
|
|
6
|
+
path: string;
|
|
7
|
+
content: string | null;
|
|
8
|
+
children?: FileNode[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 处理页面 base64 图片文件
|
|
12
|
+
*/
|
|
13
|
+
export declare function handlePageImages(assetsDir: FileNode, imageFiles: ImageFileInfo[]): void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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/generate/utils/pageImages.ts
|
|
20
|
+
var pageImages_exports = {};
|
|
21
|
+
__export(pageImages_exports, {
|
|
22
|
+
handlePageImages: () => handlePageImages
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(pageImages_exports);
|
|
25
|
+
function handlePageImages(assetsDir, imageFiles) {
|
|
26
|
+
imageFiles.forEach((imageFile) => {
|
|
27
|
+
assetsDir.children.push({
|
|
28
|
+
path: imageFile.filePath,
|
|
29
|
+
content: imageFile.fileContent.toString("base64")
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
handlePageImages
|
|
36
|
+
});
|