@mybricks/to-code-taro 1.0.2 → 1.0.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/README.md +58 -0
- package/dist/cjs/core/comlib/_AesEncode.js +115 -0
- package/dist/cjs/core/comlib/_BackTo.js +80 -0
- package/dist/cjs/core/comlib/{Index.js → _CallPhone.js} +29 -16
- package/dist/cjs/core/comlib/_ChooseFile.js +103 -0
- package/dist/cjs/core/comlib/_ChooseMedia.js +70 -0
- package/dist/cjs/core/comlib/_Connector.js +92 -0
- package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +79 -0
- package/dist/cjs/core/comlib/_Format.js +123 -0
- package/dist/cjs/core/comlib/_GetLocation.js +60 -0
- package/dist/cjs/core/comlib/_GetStorage.js +68 -0
- package/dist/cjs/core/comlib/_GetSystemInfo.js +62 -0
- package/dist/cjs/core/comlib/_OpenCamera.js +73 -0
- package/dist/cjs/core/comlib/_OpenPetalMap.js +49 -0
- package/dist/cjs/core/comlib/_OpenUrl.js +62 -0
- package/dist/cjs/core/comlib/_RemoveStorage.js +68 -0
- package/dist/cjs/core/comlib/_Router.js +100 -0
- package/dist/cjs/core/comlib/_ScanQrcode.js +9 -10
- package/dist/cjs/core/comlib/_SetStorage.js +10 -19
- package/dist/cjs/core/comlib/_Share.js +58 -0
- package/dist/cjs/core/comlib/_ShowToast.js +23 -50
- package/dist/cjs/core/comlib/_TextToSpeech.js +120 -0
- package/dist/cjs/core/comlib/_TimerDebounce.js +72 -0
- package/dist/cjs/core/comlib/_TimerDelay.js +63 -0
- package/dist/cjs/core/comlib/_TimerThrottle.js +75 -0
- package/dist/cjs/core/comlib/_Vibrate.js +60 -0
- package/dist/cjs/core/comlib/index.js +111 -0
- package/dist/cjs/core/mybricks/index.js +47 -47
- package/dist/cjs/core/utils/ComContext.js +3 -0
- package/dist/cjs/core/utils/PopupRenderer.js +63 -0
- package/dist/cjs/core/utils/hooks.js +131 -0
- package/dist/cjs/core/utils/index.js +33 -57
- package/dist/cjs/core/utils/pageRouter.js +81 -0
- package/dist/cjs/core/utils/popupRouter.js +98 -0
- package/dist/cjs/core/utils/useContext.js +11 -2
- package/dist/cjs/core/utils/with.js +37 -13
- package/dist/cjs/generate/generateTaroProjectJson.d.ts +3 -14
- package/dist/cjs/generate/generateTaroProjectJson.js +39 -6
- package/dist/cjs/generate/utils/tabBarImages.d.ts +1 -1
- package/dist/cjs/handleCom.d.ts +1 -1
- package/dist/cjs/handleCom.js +91 -177
- package/dist/cjs/handleDom.js +7 -44
- package/dist/cjs/handleExtension.d.ts +2 -2
- package/dist/cjs/handleExtension.js +5 -5
- package/dist/cjs/handleGlobal.d.ts +2 -12
- package/dist/cjs/handleGlobal.js +23 -7
- package/dist/cjs/handleModule.js +3 -3
- package/dist/cjs/handleSlot.d.ts +4 -9
- package/dist/cjs/handleSlot.js +61 -150
- package/dist/cjs/processors/processComEvents.d.ts +9 -0
- package/dist/cjs/processors/processComEvents.js +164 -0
- package/dist/cjs/processors/processModule.d.ts +31 -0
- package/dist/cjs/processors/processModule.js +125 -0
- package/dist/cjs/processors/processScene.d.ts +32 -0
- package/dist/cjs/processors/processScene.js +128 -0
- package/dist/cjs/processors/processSceneLogic.d.ts +4 -0
- package/dist/cjs/processors/processSceneLogic.js +170 -0
- package/dist/cjs/shims-taro.d.ts +20 -0
- package/dist/cjs/taro-template.json +501 -351
- package/dist/cjs/toCodeTaro.d.ts +27 -6
- package/dist/cjs/toCodeTaro.js +68 -340
- package/dist/cjs/utils/builder/buildResult.d.ts +22 -0
- package/dist/cjs/utils/builder/buildResult.js +117 -0
- package/dist/cjs/utils/common/ImportManager.d.ts +19 -0
- package/dist/cjs/utils/common/ImportManager.js +105 -0
- package/dist/cjs/utils/common/helper.d.ts +2 -0
- package/dist/cjs/utils/common/helper.js +31 -0
- package/dist/cjs/utils/common/object.d.ts +5 -0
- package/dist/cjs/utils/common/object.js +58 -0
- package/dist/cjs/utils/common/string.d.ts +8 -0
- package/dist/cjs/utils/common/string.js +46 -0
- package/dist/cjs/utils/{pageConfig → config/content}/converter.js +1 -1
- package/dist/cjs/utils/{pageConfig → config/content}/index.js +9 -9
- package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.js +12 -22
- package/dist/{esm/utils/pageConfig → cjs/utils/config/content}/saveBase64Image.d.ts +1 -1
- package/dist/cjs/utils/{pageConfig → config/content}/saveBase64Image.js +8 -17
- package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.js +9 -32
- package/dist/cjs/utils/config/content/types.js +17 -0
- package/dist/cjs/utils/{pageConfig → config/content}/validator.js +1 -1
- package/dist/{esm/utils → cjs/utils/config}/handlePageConfig.d.ts +3 -2
- package/dist/cjs/utils/{handlePageConfig.js → config/handlePageConfig.js} +7 -6
- package/dist/cjs/utils/context/buildContext.d.ts +24 -0
- package/dist/cjs/utils/context/buildContext.js +65 -0
- package/dist/cjs/utils/context/buildFrameMap.d.ts +16 -0
- package/dist/cjs/utils/context/buildFrameMap.js +106 -0
- package/dist/cjs/utils/context/buildGlobalData.d.ts +13 -0
- package/dist/cjs/utils/context/buildGlobalData.js +58 -0
- package/dist/cjs/utils/context/collectJSModules.d.ts +37 -0
- package/dist/cjs/utils/context/collectJSModules.js +91 -0
- package/dist/cjs/utils/context/createEventQueries.d.ts +45 -0
- package/dist/cjs/utils/context/createEventQueries.js +99 -0
- package/dist/cjs/utils/context/createProvider.d.ts +21 -0
- package/dist/cjs/utils/context/createProvider.js +49 -0
- package/dist/cjs/utils/index.d.ts +10 -62
- package/dist/cjs/utils/index.js +21 -282
- package/dist/cjs/utils/{convertNamespace.js → logic/convertNamespace.js} +1 -1
- package/dist/cjs/utils/{genJSModules.js → logic/genJSModules.js} +1 -1
- package/dist/{esm/utils → cjs/utils/logic}/handleProcess.d.ts +2 -2
- package/dist/cjs/utils/{handleProcess.js → logic/handleProcess.js} +40 -16
- package/dist/cjs/utils/logic/processChildren.d.ts +12 -0
- package/dist/cjs/utils/logic/processChildren.js +82 -0
- package/dist/cjs/utils/style/color.d.ts +4 -0
- package/dist/cjs/utils/style/color.js +45 -0
- package/dist/cjs/utils/style/converter.d.ts +7 -0
- package/dist/cjs/utils/style/converter.js +181 -0
- package/dist/cjs/utils/{getComponentClassName.js → style/getComponentClassName.js} +1 -1
- package/dist/cjs/utils/{pxtransform.js → style/pxtransform.js} +1 -1
- package/dist/cjs/utils/style/types.d.ts +23 -0
- package/dist/cjs/utils/{pageConfig → style}/types.js +1 -1
- package/dist/cjs/utils/{code → templates}/component.js +1 -1
- package/dist/cjs/utils/{code → templates}/index.js +4 -4
- package/dist/cjs/utils/{code → templates}/renderManager.js +1 -1
- package/dist/cjs/utils/{code → templates}/scene.d.ts +3 -1
- package/dist/cjs/utils/{code → templates}/scene.js +17 -5
- package/dist/esm/core/comlib/_AesEncode.js +85 -0
- package/dist/esm/core/comlib/_BackTo.js +66 -0
- package/dist/esm/core/comlib/_CallPhone.js +30 -0
- package/dist/esm/core/comlib/_ChooseFile.js +81 -0
- package/dist/esm/core/comlib/_ChooseMedia.js +38 -0
- package/dist/esm/core/comlib/_Connector.js +60 -0
- package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +56 -0
- package/dist/esm/core/comlib/_Format.js +102 -0
- package/dist/esm/core/comlib/_GetLocation.js +26 -0
- package/dist/esm/core/comlib/_GetStorage.js +44 -0
- package/dist/esm/core/comlib/_GetSystemInfo.js +32 -0
- package/dist/esm/core/comlib/_OpenCamera.js +44 -0
- package/dist/esm/core/comlib/_OpenPetalMap.js +28 -0
- package/dist/esm/core/comlib/_OpenUrl.js +36 -0
- package/dist/esm/core/comlib/_RemoveStorage.js +42 -0
- package/dist/esm/core/comlib/_Router.js +113 -0
- package/dist/esm/core/comlib/_ScanQrcode.js +10 -11
- package/dist/esm/core/comlib/_SetStorage.js +13 -25
- package/dist/esm/core/comlib/_Share.js +28 -0
- package/dist/esm/core/comlib/_ShowToast.js +32 -55
- package/dist/esm/core/comlib/_TextToSpeech.js +117 -0
- package/dist/esm/core/comlib/_TimerDebounce.js +66 -0
- package/dist/esm/core/comlib/_TimerDelay.js +47 -0
- package/dist/esm/core/comlib/_TimerThrottle.js +69 -0
- package/dist/esm/core/comlib/_Vibrate.js +34 -0
- package/dist/esm/core/comlib/index.js +37 -0
- package/dist/esm/core/mybricks/index.js +1 -1
- package/dist/esm/core/utils/ComContext.js +1 -0
- package/dist/esm/core/utils/PopupRenderer.js +27 -0
- package/dist/esm/core/utils/hooks.js +130 -0
- package/dist/esm/core/utils/index.js +8 -57
- package/dist/esm/core/utils/pageRouter.js +69 -0
- package/dist/esm/core/utils/popupRouter.js +116 -0
- package/dist/esm/core/utils/useContext.js +16 -3
- package/dist/esm/core/utils/with.js +62 -19
- package/dist/esm/generate/generateTaroProjectJson.d.ts +3 -14
- package/dist/esm/generate/generateTaroProjectJson.js +62 -24
- package/dist/esm/generate/utils/tabBarImages.d.ts +1 -1
- package/dist/esm/handleCom.d.ts +1 -1
- package/dist/esm/handleCom.js +159 -244
- package/dist/esm/handleDom.js +9 -48
- package/dist/esm/handleExtension.d.ts +2 -2
- package/dist/esm/handleExtension.js +5 -5
- package/dist/esm/handleGlobal.d.ts +2 -12
- package/dist/esm/handleGlobal.js +17 -3
- package/dist/esm/handleModule.js +3 -3
- package/dist/esm/handleSlot.d.ts +4 -9
- package/dist/esm/handleSlot.js +112 -173
- package/dist/esm/processors/processComEvents.d.ts +9 -0
- package/dist/esm/processors/processComEvents.js +167 -0
- package/dist/esm/processors/processModule.d.ts +31 -0
- package/dist/esm/processors/processModule.js +126 -0
- package/dist/esm/processors/processScene.d.ts +32 -0
- package/dist/esm/processors/processScene.js +134 -0
- package/dist/esm/processors/processSceneLogic.d.ts +4 -0
- package/dist/esm/processors/processSceneLogic.js +170 -0
- package/dist/esm/shims-taro.d.ts +20 -0
- package/dist/esm/taro-template.json +501 -351
- package/dist/esm/toCodeTaro.d.ts +27 -6
- package/dist/esm/toCodeTaro.js +110 -395
- package/dist/esm/utils/builder/buildResult.d.ts +22 -0
- package/dist/esm/utils/builder/buildResult.js +82 -0
- package/dist/esm/utils/common/ImportManager.d.ts +19 -0
- package/dist/esm/utils/common/ImportManager.js +103 -0
- package/dist/esm/utils/common/helper.d.ts +2 -0
- package/dist/esm/utils/common/helper.js +4 -0
- package/dist/esm/utils/common/object.d.ts +5 -0
- package/dist/esm/utils/common/object.js +32 -0
- package/dist/esm/utils/common/string.d.ts +8 -0
- package/dist/esm/utils/common/string.js +21 -0
- package/dist/esm/utils/config/content/pageConfig.js +40 -0
- package/dist/{cjs/utils/pageConfig → esm/utils/config/content}/saveBase64Image.d.ts +1 -1
- package/dist/esm/utils/{pageConfig → config/content}/saveBase64Image.js +11 -30
- package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.js +12 -34
- package/dist/{cjs/utils → esm/utils/config}/handlePageConfig.d.ts +3 -2
- package/dist/esm/utils/{handlePageConfig.js → config/handlePageConfig.js} +6 -2
- package/dist/esm/utils/context/buildContext.d.ts +24 -0
- package/dist/esm/utils/context/buildContext.js +53 -0
- package/dist/esm/utils/context/buildFrameMap.d.ts +16 -0
- package/dist/esm/utils/context/buildFrameMap.js +131 -0
- package/dist/esm/utils/context/buildGlobalData.d.ts +13 -0
- package/dist/esm/utils/context/buildGlobalData.js +44 -0
- package/dist/esm/utils/context/collectJSModules.d.ts +37 -0
- package/dist/esm/utils/context/collectJSModules.js +87 -0
- package/dist/esm/utils/context/createEventQueries.d.ts +45 -0
- package/dist/esm/utils/context/createEventQueries.js +99 -0
- package/dist/esm/utils/context/createProvider.d.ts +21 -0
- package/dist/esm/utils/context/createProvider.js +33 -0
- package/dist/esm/utils/index.d.ts +10 -62
- package/dist/esm/utils/index.js +12 -345
- package/dist/{cjs/utils → esm/utils/logic}/handleProcess.d.ts +2 -2
- package/dist/esm/utils/{handleProcess.js → logic/handleProcess.js} +42 -9
- package/dist/esm/utils/logic/processChildren.d.ts +12 -0
- package/dist/esm/utils/logic/processChildren.js +48 -0
- package/dist/esm/utils/style/color.d.ts +4 -0
- package/dist/esm/utils/style/color.js +17 -0
- package/dist/esm/utils/style/converter.d.ts +7 -0
- package/dist/esm/utils/style/converter.js +176 -0
- package/dist/esm/utils/style/types.d.ts +23 -0
- package/dist/esm/utils/style/types.js +1 -0
- package/dist/esm/utils/{code → templates}/scene.d.ts +3 -1
- package/dist/esm/utils/{code → templates}/scene.js +13 -5
- package/package.json +4 -2
- package/dist/esm/core/comlib/Index.js +0 -3
- package/dist/esm/utils/pageConfig/pageConfig.js +0 -60
- /package/dist/cjs/utils/{pageConfig → config/content}/converter.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/index.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/types.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/validator.d.ts +0 -0
- /package/dist/cjs/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
- /package/dist/cjs/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
- /package/dist/cjs/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
- /package/dist/cjs/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
- /package/dist/cjs/utils/{code → templates}/component.d.ts +0 -0
- /package/dist/cjs/utils/{code → templates}/index.d.ts +0 -0
- /package/dist/cjs/utils/{code → templates}/renderManager.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/converter.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/converter.js +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/index.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/index.js +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/types.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/types.js +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/validator.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/validator.js +0 -0
- /package/dist/esm/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
- /package/dist/esm/utils/{convertNamespace.js → logic/convertNamespace.js} +0 -0
- /package/dist/esm/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
- /package/dist/esm/utils/{genJSModules.js → logic/genJSModules.js} +0 -0
- /package/dist/esm/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
- /package/dist/esm/utils/{getComponentClassName.js → style/getComponentClassName.js} +0 -0
- /package/dist/esm/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
- /package/dist/esm/utils/{pxtransform.js → style/pxtransform.js} +0 -0
- /package/dist/esm/utils/{code → templates}/component.d.ts +0 -0
- /package/dist/esm/utils/{code → templates}/component.js +0 -0
- /package/dist/esm/utils/{code → templates}/index.d.ts +0 -0
- /package/dist/esm/utils/{code → templates}/index.js +0 -0
- /package/dist/esm/utils/{code → templates}/renderManager.d.ts +0 -0
- /package/dist/esm/utils/{code → templates}/renderManager.js +0 -0
|
@@ -14,75 +14,51 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
}
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
19
|
|
|
19
20
|
// src/core/utils/index.ts
|
|
20
21
|
var utils_exports = {};
|
|
21
22
|
__export(utils_exports, {
|
|
23
|
+
PopupRenderer: () => import_PopupRenderer.PopupRenderer,
|
|
24
|
+
SUBJECT_SUBSCRIBE: () => import_constant.SUBJECT_SUBSCRIBE,
|
|
25
|
+
SUBJECT_VALUE: () => import_constant.SUBJECT_VALUE,
|
|
22
26
|
WithCom: () => import_with.WithCom,
|
|
23
27
|
WithWrapper: () => import_with.WithWrapper,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
closeActivePopupRouter: () => import_popupRouter.closeActivePopupRouter,
|
|
29
|
+
createFx: () => import_mybricks.createFx,
|
|
30
|
+
createVariable: () => import_mybricks.createVariable,
|
|
31
|
+
merge: () => import_mybricks.merge,
|
|
32
|
+
pageRouter: () => import_pageRouter.pageRouter,
|
|
33
|
+
popupRouter: () => import_popupRouter.popupRouter,
|
|
34
|
+
router: () => import_pageRouter.router,
|
|
35
|
+
subscribePopupRouter: () => import_popupRouter.subscribePopupRouter,
|
|
36
|
+
useAppContext: () => import_ComContext.useAppContext
|
|
27
37
|
});
|
|
28
38
|
module.exports = __toCommonJS(utils_exports);
|
|
29
|
-
|
|
39
|
+
__reExport(utils_exports, require("./hooks"), module.exports);
|
|
30
40
|
var import_with = require("./with");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
}
|
|
41
|
+
var import_PopupRenderer = require("./PopupRenderer");
|
|
42
|
+
var import_pageRouter = require("./pageRouter");
|
|
43
|
+
var import_popupRouter = require("./popupRouter");
|
|
44
|
+
var import_ComContext = require("./ComContext");
|
|
45
|
+
var import_mybricks = require("../mybricks");
|
|
46
|
+
var import_constant = require("../mybricks/constant");
|
|
81
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
48
|
0 && (module.exports = {
|
|
49
|
+
PopupRenderer,
|
|
50
|
+
SUBJECT_SUBSCRIBE,
|
|
51
|
+
SUBJECT_VALUE,
|
|
83
52
|
WithCom,
|
|
84
53
|
WithWrapper,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
closeActivePopupRouter,
|
|
55
|
+
createFx,
|
|
56
|
+
createVariable,
|
|
57
|
+
merge,
|
|
58
|
+
pageRouter,
|
|
59
|
+
popupRouter,
|
|
60
|
+
router,
|
|
61
|
+
subscribePopupRouter,
|
|
62
|
+
useAppContext,
|
|
63
|
+
...require("./hooks")
|
|
88
64
|
});
|
|
@@ -0,0 +1,81 @@
|
|
|
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/pageRouter.ts
|
|
30
|
+
var pageRouter_exports = {};
|
|
31
|
+
__export(pageRouter_exports, {
|
|
32
|
+
pageRouter: () => pageRouter,
|
|
33
|
+
router: () => router
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(pageRouter_exports);
|
|
36
|
+
var import_taro = __toESM(require("@tarojs/taro"));
|
|
37
|
+
var import_mybricks = require("../mybricks");
|
|
38
|
+
var TaroRouter = class {
|
|
39
|
+
constructor() {
|
|
40
|
+
this.paramsBackup = {};
|
|
41
|
+
}
|
|
42
|
+
getParams(name) {
|
|
43
|
+
var _a;
|
|
44
|
+
const instance = import_taro.default.getCurrentInstance();
|
|
45
|
+
let params = ((_a = instance.router) == null ? void 0 : _a.params) || {};
|
|
46
|
+
if (!params.data && this.paramsBackup[name]) {
|
|
47
|
+
params = { data: this.paramsBackup[name] };
|
|
48
|
+
}
|
|
49
|
+
return { value: params };
|
|
50
|
+
}
|
|
51
|
+
push(name, { value }) {
|
|
52
|
+
const url = `/pages/${name}/index`;
|
|
53
|
+
const dataStr = value ? encodeURIComponent(JSON.stringify(value)) : "";
|
|
54
|
+
if (dataStr) {
|
|
55
|
+
this.paramsBackup[name] = dataStr;
|
|
56
|
+
}
|
|
57
|
+
import_taro.default.navigateTo({
|
|
58
|
+
url: `${url}${dataStr ? `?data=${dataStr}` : ""}`
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
replace(name, { value }) {
|
|
62
|
+
const url = `/pages/${name}/index`;
|
|
63
|
+
const dataStr = value ? encodeURIComponent(JSON.stringify(value)) : "";
|
|
64
|
+
if (dataStr) {
|
|
65
|
+
this.paramsBackup[name] = dataStr;
|
|
66
|
+
}
|
|
67
|
+
import_taro.default.redirectTo({
|
|
68
|
+
url: `${url}${dataStr ? `?data=${dataStr}` : ""}`
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
pop() {
|
|
72
|
+
import_taro.default.navigateBack();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var router = new TaroRouter();
|
|
76
|
+
var pageRouter = new import_mybricks.Page(router);
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
pageRouter,
|
|
80
|
+
router
|
|
81
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
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/popupRouter.ts
|
|
20
|
+
var popupRouter_exports = {};
|
|
21
|
+
__export(popupRouter_exports, {
|
|
22
|
+
closeActivePopupRouter: () => closeActivePopupRouter,
|
|
23
|
+
popupRouter: () => popupRouter,
|
|
24
|
+
subscribePopupRouter: () => subscribePopupRouter
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(popupRouter_exports);
|
|
27
|
+
var import_mybricks = require("../mybricks");
|
|
28
|
+
var PopupStore = class {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.activePopup = null;
|
|
31
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
32
|
+
}
|
|
33
|
+
/** 订阅弹窗状态变化 */
|
|
34
|
+
subscribe(listener) {
|
|
35
|
+
this.listeners.add(listener);
|
|
36
|
+
return () => {
|
|
37
|
+
this.listeners.delete(listener);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
notify() {
|
|
41
|
+
this.listeners.forEach(
|
|
42
|
+
(l) => l(
|
|
43
|
+
this.activePopup || {
|
|
44
|
+
visible: false,
|
|
45
|
+
name: "",
|
|
46
|
+
value: null,
|
|
47
|
+
controller: null
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
/** 获取弹窗参数 */
|
|
53
|
+
getParams(name) {
|
|
54
|
+
if (this.activePopup && this.activePopup.name === name) {
|
|
55
|
+
return {
|
|
56
|
+
value: this.activePopup.value,
|
|
57
|
+
controller: this.activePopup.controller
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return { value: null };
|
|
61
|
+
}
|
|
62
|
+
/** 获取当前激活的弹窗名称 */
|
|
63
|
+
getActiveName() {
|
|
64
|
+
var _a;
|
|
65
|
+
return (_a = this.activePopup) == null ? void 0 : _a.name;
|
|
66
|
+
}
|
|
67
|
+
/** 打开弹窗 */
|
|
68
|
+
push(name, { value, controller }) {
|
|
69
|
+
this.activePopup = { visible: true, name, value, controller };
|
|
70
|
+
this.notify();
|
|
71
|
+
}
|
|
72
|
+
/** 行为同 push */
|
|
73
|
+
replace(name, params) {
|
|
74
|
+
this.push(name, params);
|
|
75
|
+
}
|
|
76
|
+
/** 关闭弹窗 */
|
|
77
|
+
pop() {
|
|
78
|
+
this.activePopup = null;
|
|
79
|
+
this.notify();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var popupStore = new PopupStore();
|
|
83
|
+
var subscribePopupRouter = (listener) => {
|
|
84
|
+
return popupStore.subscribe(listener);
|
|
85
|
+
};
|
|
86
|
+
var popupRouter = new import_mybricks.Page(popupStore);
|
|
87
|
+
var closeActivePopupRouter = () => {
|
|
88
|
+
const name = popupStore.getActiveName();
|
|
89
|
+
if (!name)
|
|
90
|
+
return;
|
|
91
|
+
popupRouter.close(name);
|
|
92
|
+
};
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
closeActivePopupRouter,
|
|
96
|
+
popupRouter,
|
|
97
|
+
subscribePopupRouter
|
|
98
|
+
});
|
|
@@ -23,8 +23,15 @@ __export(useContext_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(useContext_exports);
|
|
25
25
|
var import_react = require("react");
|
|
26
|
+
var import_hooks = require("./hooks");
|
|
26
27
|
function useAppCreateContext() {
|
|
27
|
-
const comRefs = (0, import_react.useRef)({});
|
|
28
|
+
const comRefs = (0, import_react.useRef)((0, import_hooks.deepProxy)({}));
|
|
29
|
+
const [popupState, setPopupState] = (0, import_react.useState)({
|
|
30
|
+
visible: false,
|
|
31
|
+
name: "",
|
|
32
|
+
value: null,
|
|
33
|
+
controller: null
|
|
34
|
+
});
|
|
28
35
|
const appContext = {
|
|
29
36
|
canvas: {
|
|
30
37
|
id: "u_7VvVn"
|
|
@@ -44,7 +51,9 @@ function useAppCreateContext() {
|
|
|
44
51
|
};
|
|
45
52
|
return {
|
|
46
53
|
comRefs,
|
|
47
|
-
appContext
|
|
54
|
+
appContext,
|
|
55
|
+
popupState,
|
|
56
|
+
setPopupState
|
|
48
57
|
};
|
|
49
58
|
}
|
|
50
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -38,27 +38,41 @@ var import_components = require("@tarojs/components");
|
|
|
38
38
|
var import_index = require("./index");
|
|
39
39
|
var import_useContext = require("./useContext");
|
|
40
40
|
var import_ComContext = __toESM(require("./ComContext"));
|
|
41
|
+
var import_taro = require("@tarojs/taro");
|
|
41
42
|
var WithCom = (props) => {
|
|
42
43
|
const { component: Component, id = "", data, className, style, ...rest } = props;
|
|
43
44
|
const { comRefs, appContext } = (0, import_ComContext.useAppContext)();
|
|
44
45
|
const env = appContext;
|
|
46
|
+
const isPopup = Component.isPopup;
|
|
45
47
|
const [show, setShow] = (0, import_react.useState)(true);
|
|
46
|
-
(0, import_react.
|
|
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]);
|
|
48
|
+
const [dynamicStyle, setDynamicStyle] = (0, import_react.useState)({});
|
|
57
49
|
const _data = (0, import_index.useModel)(data || {});
|
|
58
|
-
const
|
|
50
|
+
const handlers = {
|
|
51
|
+
_setStyle: (style2) => {
|
|
52
|
+
setDynamicStyle((prev) => ({ ...prev, ...style2 }));
|
|
53
|
+
},
|
|
54
|
+
_setData: (path, value) => {
|
|
55
|
+
const paths = path.split(".");
|
|
56
|
+
let current = _data;
|
|
57
|
+
for (let i = 0; i < paths.length - 1; i++) {
|
|
58
|
+
if (!current[paths[i]])
|
|
59
|
+
current[paths[i]] = {};
|
|
60
|
+
current = current[paths[i]];
|
|
61
|
+
}
|
|
62
|
+
current[paths[paths.length - 1]] = value;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (!isPopup) {
|
|
66
|
+
Object.assign(handlers, {
|
|
67
|
+
show: () => setShow(true),
|
|
68
|
+
hide: () => setShow(false),
|
|
69
|
+
showOrHide: () => setShow((prev) => !prev)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const inputProxy = (0, import_index.useBindInputs)(comRefs, id, handlers);
|
|
59
73
|
const eventProxy = (0, import_index.useBindEvents)(rest);
|
|
60
74
|
comRefs.current[id] = inputProxy;
|
|
61
|
-
return show ? /* @__PURE__ */ import_react.default.createElement(import_components.View, { className, style }, /* @__PURE__ */ import_react.default.createElement(
|
|
75
|
+
return show || isPopup ? /* @__PURE__ */ import_react.default.createElement(import_components.View, { className, style: { ...style, ...dynamicStyle } }, /* @__PURE__ */ import_react.default.createElement(
|
|
62
76
|
Component,
|
|
63
77
|
{
|
|
64
78
|
...rest,
|
|
@@ -74,6 +88,16 @@ var WithCom = (props) => {
|
|
|
74
88
|
var WithWrapper = (Component) => {
|
|
75
89
|
return function WrappedComponent(props) {
|
|
76
90
|
const contextStore = (0, import_useContext.useAppCreateContext)();
|
|
91
|
+
const { setPopupState } = contextStore;
|
|
92
|
+
const isPopup = Component.isPopup;
|
|
93
|
+
(0, import_react.useEffect)(() => {
|
|
94
|
+
return (0, import_index.subscribePopupRouter)((state) => setPopupState(state));
|
|
95
|
+
}, [setPopupState]);
|
|
96
|
+
(0, import_taro.useTabItemTap)(() => {
|
|
97
|
+
if (isPopup)
|
|
98
|
+
return;
|
|
99
|
+
(0, import_index.closeActivePopupRouter)();
|
|
100
|
+
});
|
|
77
101
|
return /* @__PURE__ */ import_react.default.createElement(import_ComContext.default.Provider, { value: contextStore }, /* @__PURE__ */ import_react.default.createElement(Component, { ...props }));
|
|
78
102
|
};
|
|
79
103
|
};
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
+
import type { GenerationResult } from "../toCodeTaro";
|
|
1
2
|
interface FileNode {
|
|
2
3
|
path: string;
|
|
3
4
|
content: string | null;
|
|
4
5
|
children?: FileNode[];
|
|
5
6
|
}
|
|
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
7
|
/**
|
|
19
8
|
* 根据数组生成文件结构 JSON 对象
|
|
20
|
-
* @param
|
|
9
|
+
* @param result 包含 files 和 assets 的生成结果对象
|
|
21
10
|
* @returns 返回文件结构的 JSON 对象数组
|
|
22
11
|
*/
|
|
23
|
-
declare const generateTaroProjectJson: (
|
|
12
|
+
declare const generateTaroProjectJson: (result: GenerationResult) => FileNode[];
|
|
24
13
|
export default generateTaroProjectJson;
|
|
@@ -38,8 +38,9 @@ var import_fileNode = require("./utils/fileNode");
|
|
|
38
38
|
var import_commonDir = require("./utils/commonDir");
|
|
39
39
|
var import_tabBarImages = require("./utils/tabBarImages");
|
|
40
40
|
var import_appConfig = require("./utils/appConfig");
|
|
41
|
-
var generateTaroProjectJson = (
|
|
41
|
+
var generateTaroProjectJson = (result) => {
|
|
42
42
|
var _a;
|
|
43
|
+
const { files = [], assets = {} } = result;
|
|
43
44
|
const templateJsonPath = path.join(__dirname, "../taro-template.json");
|
|
44
45
|
if (!fs.existsSync(templateJsonPath)) {
|
|
45
46
|
throw new Error(`模板文件不存在: ${templateJsonPath}`);
|
|
@@ -57,8 +58,8 @@ var generateTaroProjectJson = (items = []) => {
|
|
|
57
58
|
const commonDir = (0, import_fileNode.ensureDir)(srcDir, "src/common");
|
|
58
59
|
const assetsDir = (0, import_fileNode.ensureDir)(srcDir, "src/assets");
|
|
59
60
|
const tabbarDir = (0, import_fileNode.ensureDir)(assetsDir, "src/assets/tabbar");
|
|
60
|
-
const imageFiles =
|
|
61
|
-
const normalItems =
|
|
61
|
+
const imageFiles = assets.tabBarImages || [];
|
|
62
|
+
const normalItems = files.filter((item) => item.type === "normal");
|
|
62
63
|
const generatedPages = normalItems.map((item) => {
|
|
63
64
|
var _a2;
|
|
64
65
|
const pageName = item.meta.id;
|
|
@@ -90,12 +91,44 @@ ${fileContent}` : fileContent;
|
|
|
90
91
|
};
|
|
91
92
|
});
|
|
92
93
|
pagesDir.children.push(...generatedPages);
|
|
93
|
-
const
|
|
94
|
+
const popupComponentsDir = (0, import_fileNode.ensureDir)(srcDir, "src/popupComponents");
|
|
95
|
+
const popupScenes = files.filter((item) => item.type === "popup" && item.meta);
|
|
96
|
+
popupScenes.forEach((item) => {
|
|
97
|
+
var _a2;
|
|
98
|
+
const popupId = item.meta.id;
|
|
99
|
+
const importCode = ((_a2 = item.importManager) == null ? void 0 : _a2.toCode()) || "";
|
|
100
|
+
const fullContent = `${importCode}
|
|
101
|
+
${item.content || ""}`;
|
|
102
|
+
popupComponentsDir.children.push({
|
|
103
|
+
path: `src/popupComponents/${popupId}`,
|
|
104
|
+
content: null,
|
|
105
|
+
children: [
|
|
106
|
+
{
|
|
107
|
+
path: `src/popupComponents/${popupId}/index.tsx`,
|
|
108
|
+
content: fullContent
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
path: `src/popupComponents/${popupId}/index.less`,
|
|
112
|
+
content: item.cssContent || ""
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const appConfigFile = (_a = srcDir.children) == null ? void 0 : _a.find(
|
|
118
|
+
(node) => node.path === "src/app.config.ts"
|
|
119
|
+
);
|
|
94
120
|
if (appConfigFile) {
|
|
95
|
-
(0, import_appConfig.updateAppConfig)(appConfigFile, normalItems,
|
|
121
|
+
(0, import_appConfig.updateAppConfig)(appConfigFile, normalItems, files);
|
|
96
122
|
}
|
|
97
123
|
(0, import_tabBarImages.handleTabBarImages)(tabbarDir, imageFiles);
|
|
98
|
-
(0, import_commonDir.handleCommonDir)(commonDir,
|
|
124
|
+
(0, import_commonDir.handleCommonDir)(commonDir, files);
|
|
125
|
+
const popupFile = files.find((f) => f.type === "popup" && !f.meta);
|
|
126
|
+
if (popupFile) {
|
|
127
|
+
commonDir.children.push({
|
|
128
|
+
path: `src/common/${popupFile.name}.ts`,
|
|
129
|
+
content: popupFile.content
|
|
130
|
+
});
|
|
131
|
+
}
|
|
99
132
|
return templateJson;
|
|
100
133
|
};
|
|
101
134
|
var generateTaroProjectJson_default = generateTaroProjectJson;
|
package/dist/cjs/handleCom.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImportManager } from "./utils";
|
|
2
|
-
import { RenderManager } from "./utils/
|
|
2
|
+
import { RenderManager } from "./utils/templates/renderManager";
|
|
3
3
|
import type { UI, BaseConfig } from "./toCodeTaro";
|
|
4
4
|
export type Com = Extract<UI["children"][0], {
|
|
5
5
|
type: "com";
|