@mybricks/to-code-taro 1.0.3 → 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.
Files changed (106) hide show
  1. package/dist/cjs/core/comlib/_AesEncode.js +115 -0
  2. package/dist/cjs/core/comlib/_BackTo.js +80 -0
  3. package/dist/cjs/core/comlib/_CallPhone.js +58 -0
  4. package/dist/cjs/core/comlib/_ChooseFile.js +103 -0
  5. package/dist/cjs/core/comlib/_ChooseMedia.js +70 -0
  6. package/dist/cjs/core/comlib/_Connector.js +92 -0
  7. package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +79 -0
  8. package/dist/cjs/core/comlib/_Format.js +123 -0
  9. package/dist/cjs/core/comlib/_GetLocation.js +60 -0
  10. package/dist/cjs/core/comlib/_GetStorage.js +68 -0
  11. package/dist/cjs/core/comlib/_GetSystemInfo.js +62 -0
  12. package/dist/cjs/core/comlib/_OpenCamera.js +73 -0
  13. package/dist/cjs/core/comlib/_OpenPetalMap.js +49 -0
  14. package/dist/cjs/core/comlib/_OpenUrl.js +62 -0
  15. package/dist/cjs/core/comlib/_RemoveStorage.js +68 -0
  16. package/dist/cjs/core/comlib/_Router.js +100 -0
  17. package/dist/cjs/core/comlib/_ScanQrcode.js +9 -10
  18. package/dist/cjs/core/comlib/_SetStorage.js +10 -19
  19. package/dist/cjs/core/comlib/_Share.js +58 -0
  20. package/dist/cjs/core/comlib/_ShowToast.js +23 -50
  21. package/dist/cjs/core/comlib/_TextToSpeech.js +120 -0
  22. package/dist/cjs/core/comlib/_TimerDebounce.js +72 -0
  23. package/dist/cjs/core/comlib/_TimerDelay.js +63 -0
  24. package/dist/cjs/core/comlib/_TimerThrottle.js +75 -0
  25. package/dist/cjs/core/comlib/_Vibrate.js +60 -0
  26. package/dist/cjs/core/comlib/index.js +68 -2
  27. package/dist/cjs/core/utils/ComContext.js +3 -3
  28. package/dist/cjs/core/utils/PopupRenderer.js +63 -0
  29. package/dist/cjs/core/utils/hooks.js +16 -10
  30. package/dist/cjs/core/utils/index.js +15 -3
  31. package/dist/cjs/core/utils/{page.js → pageRouter.js} +28 -14
  32. package/dist/cjs/core/utils/popupRouter.js +98 -0
  33. package/dist/cjs/core/utils/useContext.js +9 -1
  34. package/dist/cjs/core/utils/with.js +37 -13
  35. package/dist/cjs/generate/generateTaroProjectJson.js +30 -0
  36. package/dist/cjs/handleSlot.d.ts +2 -0
  37. package/dist/cjs/handleSlot.js +19 -5
  38. package/dist/cjs/processors/processComEvents.js +47 -5
  39. package/dist/cjs/processors/processScene.js +9 -5
  40. package/dist/cjs/processors/processSceneLogic.js +9 -5
  41. package/dist/cjs/shims-taro.d.ts +20 -0
  42. package/dist/cjs/taro-template.json +493 -351
  43. package/dist/cjs/toCodeTaro.d.ts +1 -1
  44. package/dist/cjs/toCodeTaro.js +13 -1
  45. package/dist/cjs/utils/builder/buildResult.d.ts +1 -0
  46. package/dist/cjs/utils/builder/buildResult.js +26 -0
  47. package/dist/cjs/utils/config/handlePageConfig.d.ts +2 -1
  48. package/dist/cjs/utils/config/handlePageConfig.js +3 -2
  49. package/dist/cjs/utils/context/createEventQueries.js +1 -1
  50. package/dist/cjs/utils/logic/handleProcess.js +26 -5
  51. package/dist/cjs/utils/templates/scene.d.ts +3 -1
  52. package/dist/cjs/utils/templates/scene.js +16 -4
  53. package/dist/esm/core/comlib/_AesEncode.js +85 -0
  54. package/dist/esm/core/comlib/_BackTo.js +66 -0
  55. package/dist/esm/core/comlib/_CallPhone.js +30 -0
  56. package/dist/esm/core/comlib/_ChooseFile.js +81 -0
  57. package/dist/esm/core/comlib/_ChooseMedia.js +38 -0
  58. package/dist/esm/core/comlib/_Connector.js +60 -0
  59. package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +56 -0
  60. package/dist/esm/core/comlib/_Format.js +102 -0
  61. package/dist/esm/core/comlib/_GetLocation.js +26 -0
  62. package/dist/esm/core/comlib/_GetStorage.js +44 -0
  63. package/dist/esm/core/comlib/_GetSystemInfo.js +32 -0
  64. package/dist/esm/core/comlib/_OpenCamera.js +44 -0
  65. package/dist/esm/core/comlib/_OpenPetalMap.js +28 -0
  66. package/dist/esm/core/comlib/_OpenUrl.js +36 -0
  67. package/dist/esm/core/comlib/_RemoveStorage.js +42 -0
  68. package/dist/esm/core/comlib/_Router.js +113 -0
  69. package/dist/esm/core/comlib/_ScanQrcode.js +10 -11
  70. package/dist/esm/core/comlib/_SetStorage.js +13 -25
  71. package/dist/esm/core/comlib/_Share.js +28 -0
  72. package/dist/esm/core/comlib/_ShowToast.js +32 -55
  73. package/dist/esm/core/comlib/_TextToSpeech.js +117 -0
  74. package/dist/esm/core/comlib/_TimerDebounce.js +66 -0
  75. package/dist/esm/core/comlib/_TimerDelay.js +47 -0
  76. package/dist/esm/core/comlib/_TimerThrottle.js +69 -0
  77. package/dist/esm/core/comlib/_Vibrate.js +34 -0
  78. package/dist/esm/core/comlib/index.js +35 -1
  79. package/dist/esm/core/utils/ComContext.js +1 -1
  80. package/dist/esm/core/utils/PopupRenderer.js +27 -0
  81. package/dist/esm/core/utils/hooks.js +22 -10
  82. package/dist/esm/core/utils/index.js +3 -1
  83. package/dist/esm/core/utils/pageRouter.js +69 -0
  84. package/dist/esm/core/utils/popupRouter.js +116 -0
  85. package/dist/esm/core/utils/useContext.js +14 -2
  86. package/dist/esm/core/utils/with.js +62 -19
  87. package/dist/esm/generate/generateTaroProjectJson.js +35 -1
  88. package/dist/esm/handleSlot.d.ts +2 -0
  89. package/dist/esm/handleSlot.js +20 -4
  90. package/dist/esm/processors/processComEvents.js +62 -5
  91. package/dist/esm/processors/processScene.js +11 -3
  92. package/dist/esm/processors/processSceneLogic.js +15 -5
  93. package/dist/esm/shims-taro.d.ts +20 -0
  94. package/dist/esm/taro-template.json +493 -351
  95. package/dist/esm/toCodeTaro.d.ts +1 -1
  96. package/dist/esm/toCodeTaro.js +16 -1
  97. package/dist/esm/utils/builder/buildResult.d.ts +1 -0
  98. package/dist/esm/utils/builder/buildResult.js +21 -0
  99. package/dist/esm/utils/config/handlePageConfig.d.ts +2 -1
  100. package/dist/esm/utils/config/handlePageConfig.js +5 -1
  101. package/dist/esm/utils/context/createEventQueries.js +2 -1
  102. package/dist/esm/utils/logic/handleProcess.js +31 -4
  103. package/dist/esm/utils/templates/scene.d.ts +3 -1
  104. package/dist/esm/utils/templates/scene.js +13 -5
  105. package/package.json +4 -2
  106. package/dist/esm/core/utils/page.js +0 -50
@@ -29,17 +29,83 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/core/comlib/index.ts
30
30
  var comlib_exports = {};
31
31
  __export(comlib_exports, {
32
+ mybricks_taro_aesEncode: () => import_AesEncode.default,
33
+ mybricks_taro_backTo: () => import_BackTo.default,
34
+ mybricks_taro_callPhone: () => import_CallPhone.default,
35
+ mybricks_taro_chooseFile: () => import_ChooseFile.default,
36
+ mybricks_taro_chooseMedia: () => import_ChooseMedia.default,
37
+ mybricks_taro_connector: () => import_Connector.default,
38
+ mybricks_taro_connectorGlobalHeaders: () => import_ConnectorGlobalHeaders.default,
39
+ mybricks_taro_format: () => import_Format.default,
40
+ mybricks_taro_getLocation: () => import_GetLocation.default,
41
+ mybricks_taro_getStorage: () => import_GetStorage.default,
42
+ mybricks_taro_getSystemInfo: () => import_GetSystemInfo.default,
43
+ mybricks_taro_openCamera: () => import_OpenCamera.default,
44
+ mybricks_taro_openPetalMap: () => import_OpenPetalMap.default,
45
+ mybricks_taro_openUrl: () => import_OpenUrl.default,
46
+ mybricks_taro_removeStorage: () => import_RemoveStorage.default,
47
+ mybricks_taro_router: () => import_Router.default,
32
48
  mybricks_taro_scanQrcode: () => import_ScanQrcode.default,
33
49
  mybricks_taro_setStorage: () => import_SetStorage.default,
34
- mybricks_taro_showToast: () => import_ShowToast.default
50
+ mybricks_taro_share: () => import_Share.default,
51
+ mybricks_taro_showToast: () => import_ShowToast.default,
52
+ mybricks_taro_textToSpeech: () => import_TextToSpeech.default,
53
+ mybricks_taro_timerDebounce: () => import_TimerDebounce.default,
54
+ mybricks_taro_timerDelay: () => import_TimerDelay.default,
55
+ mybricks_taro_timerThrottle: () => import_TimerThrottle.default,
56
+ mybricks_taro_vibrate: () => import_Vibrate.default
35
57
  });
36
58
  module.exports = __toCommonJS(comlib_exports);
37
59
  var import_ShowToast = __toESM(require("./_ShowToast"));
38
60
  var import_ScanQrcode = __toESM(require("./_ScanQrcode"));
39
61
  var import_SetStorage = __toESM(require("./_SetStorage"));
62
+ var import_GetStorage = __toESM(require("./_GetStorage"));
63
+ var import_RemoveStorage = __toESM(require("./_RemoveStorage"));
64
+ var import_GetLocation = __toESM(require("./_GetLocation"));
65
+ var import_Vibrate = __toESM(require("./_Vibrate"));
66
+ var import_CallPhone = __toESM(require("./_CallPhone"));
67
+ var import_OpenCamera = __toESM(require("./_OpenCamera"));
68
+ var import_OpenUrl = __toESM(require("./_OpenUrl"));
69
+ var import_Share = __toESM(require("./_Share"));
70
+ var import_GetSystemInfo = __toESM(require("./_GetSystemInfo"));
71
+ var import_AesEncode = __toESM(require("./_AesEncode"));
72
+ var import_Format = __toESM(require("./_Format"));
73
+ var import_ChooseFile = __toESM(require("./_ChooseFile"));
74
+ var import_ChooseMedia = __toESM(require("./_ChooseMedia"));
75
+ var import_Connector = __toESM(require("./_Connector"));
76
+ var import_ConnectorGlobalHeaders = __toESM(require("./_ConnectorGlobalHeaders"));
77
+ var import_BackTo = __toESM(require("./_BackTo"));
78
+ var import_Router = __toESM(require("./_Router"));
79
+ var import_OpenPetalMap = __toESM(require("./_OpenPetalMap"));
80
+ var import_TextToSpeech = __toESM(require("./_TextToSpeech"));
81
+ var import_TimerDebounce = __toESM(require("./_TimerDebounce"));
82
+ var import_TimerDelay = __toESM(require("./_TimerDelay"));
83
+ var import_TimerThrottle = __toESM(require("./_TimerThrottle"));
40
84
  // Annotate the CommonJS export names for ESM import in node:
41
85
  0 && (module.exports = {
86
+ mybricks_taro_aesEncode,
87
+ mybricks_taro_backTo,
88
+ mybricks_taro_callPhone,
89
+ mybricks_taro_chooseFile,
90
+ mybricks_taro_chooseMedia,
91
+ mybricks_taro_connector,
92
+ mybricks_taro_connectorGlobalHeaders,
93
+ mybricks_taro_format,
94
+ mybricks_taro_getLocation,
95
+ mybricks_taro_getStorage,
96
+ mybricks_taro_getSystemInfo,
97
+ mybricks_taro_openCamera,
98
+ mybricks_taro_openPetalMap,
99
+ mybricks_taro_openUrl,
100
+ mybricks_taro_removeStorage,
101
+ mybricks_taro_router,
42
102
  mybricks_taro_scanQrcode,
43
103
  mybricks_taro_setStorage,
44
- mybricks_taro_showToast
104
+ mybricks_taro_share,
105
+ mybricks_taro_showToast,
106
+ mybricks_taro_textToSpeech,
107
+ mybricks_taro_timerDebounce,
108
+ mybricks_taro_timerDelay,
109
+ mybricks_taro_timerThrottle,
110
+ mybricks_taro_vibrate
45
111
  });
@@ -20,12 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var ComContext_exports = {};
21
21
  __export(ComContext_exports, {
22
22
  default: () => ComContext_default,
23
- page: () => import_page.page,
23
+ pageRouter: () => import_pageRouter.pageRouter,
24
24
  useAppContext: () => useAppContext
25
25
  });
26
26
  module.exports = __toCommonJS(ComContext_exports);
27
27
  var import_react = require("react");
28
- var import_page = require("./page");
28
+ var import_pageRouter = require("./pageRouter");
29
29
  var ComContext = (0, import_react.createContext)(void 0);
30
30
  function useAppContext() {
31
31
  const context = (0, import_react.useContext)(ComContext);
@@ -37,6 +37,6 @@ function useAppContext() {
37
37
  var ComContext_default = ComContext;
38
38
  // Annotate the CommonJS export names for ESM import in node:
39
39
  0 && (module.exports = {
40
- page,
40
+ pageRouter,
41
41
  useAppContext
42
42
  });
@@ -0,0 +1,63 @@
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/PopupRenderer.tsx
30
+ var PopupRenderer_exports = {};
31
+ __export(PopupRenderer_exports, {
32
+ PopupRenderer: () => PopupRenderer
33
+ });
34
+ module.exports = __toCommonJS(PopupRenderer_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_components = require("@tarojs/components");
37
+ var import_ComContext = require("./ComContext");
38
+ var PopupRenderer = ({ popupMap }) => {
39
+ const { popupState } = (0, import_ComContext.useAppContext)();
40
+ const ActivePopup = popupState.visible && popupMap[popupState.name] ? popupMap[popupState.name] : null;
41
+ if (!ActivePopup)
42
+ return null;
43
+ return /* @__PURE__ */ import_react.default.createElement(
44
+ import_components.View,
45
+ {
46
+ className: "global-popup-container",
47
+ style: {
48
+ position: "fixed",
49
+ top: 0,
50
+ left: 0,
51
+ right: 0,
52
+ bottom: 0,
53
+ zIndex: 999999,
54
+ pointerEvents: "auto"
55
+ }
56
+ },
57
+ /* @__PURE__ */ import_react.default.createElement(import_components.View, { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ import_react.default.createElement(ActivePopup, null))
58
+ );
59
+ };
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ PopupRenderer
63
+ });
@@ -26,7 +26,7 @@ __export(hooks_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(hooks_exports);
28
28
  var import_react = require("react");
29
- var import_constant = require("../mybricks/constant");
29
+ var import_createReactiveInputHandler = require("../mybricks/createReactiveInputHandler");
30
30
  function deepProxy(target, onSet) {
31
31
  if (target === null || typeof target !== "object" || target.__isProxy) {
32
32
  return target;
@@ -62,24 +62,30 @@ function useModel(rawData) {
62
62
  return deepProxy(dataRef.current, () => forceUpdate({}));
63
63
  }, []);
64
64
  }
65
- function useBindInputs(scope, id) {
66
- const handlersRef = (0, import_react.useRef)({});
65
+ function useBindInputs(scope, id, initialHandlers) {
66
+ const handlersRef = (0, import_react.useRef)({ ...initialHandlers });
67
+ if (initialHandlers) {
68
+ Object.assign(handlersRef.current, initialHandlers);
69
+ }
67
70
  return (0, import_react.useMemo)(() => {
68
71
  const proxy = new Proxy({}, {
69
72
  get: (_target, pin) => {
70
- return (arg) => {
73
+ return (arg, ...args) => {
71
74
  if (typeof arg === "function") {
72
75
  handlersRef.current[pin] = arg;
73
76
  } else {
74
77
  const handler = handlersRef.current[pin];
75
78
  if (typeof handler === "function") {
76
- if (arg && arg[import_constant.SUBJECT_SUBSCRIBE]) {
77
- arg[import_constant.SUBJECT_SUBSCRIBE]((val) => {
78
- handler(val);
79
- });
80
- } else {
81
- handler(arg);
79
+ if (pin === "_setData") {
80
+ return handler(arg, ...args);
82
81
  }
82
+ return (0, import_createReactiveInputHandler.createReactiveInputHandler)({
83
+ input: handler,
84
+ value: arg,
85
+ rels: {},
86
+ // 这里可以扩展 output 关联
87
+ title: id
88
+ });
83
89
  }
84
90
  }
85
91
  };
@@ -20,33 +20,45 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/core/utils/index.ts
21
21
  var utils_exports = {};
22
22
  __export(utils_exports, {
23
+ PopupRenderer: () => import_PopupRenderer.PopupRenderer,
23
24
  SUBJECT_SUBSCRIBE: () => import_constant.SUBJECT_SUBSCRIBE,
24
25
  SUBJECT_VALUE: () => import_constant.SUBJECT_VALUE,
25
26
  WithCom: () => import_with.WithCom,
26
27
  WithWrapper: () => import_with.WithWrapper,
28
+ closeActivePopupRouter: () => import_popupRouter.closeActivePopupRouter,
27
29
  createFx: () => import_mybricks.createFx,
28
30
  createVariable: () => import_mybricks.createVariable,
29
31
  merge: () => import_mybricks.merge,
30
- page: () => import_page.page,
32
+ pageRouter: () => import_pageRouter.pageRouter,
33
+ popupRouter: () => import_popupRouter.popupRouter,
34
+ router: () => import_pageRouter.router,
35
+ subscribePopupRouter: () => import_popupRouter.subscribePopupRouter,
31
36
  useAppContext: () => import_ComContext.useAppContext
32
37
  });
33
38
  module.exports = __toCommonJS(utils_exports);
34
39
  __reExport(utils_exports, require("./hooks"), module.exports);
35
40
  var import_with = require("./with");
36
- var import_page = require("./page");
41
+ var import_PopupRenderer = require("./PopupRenderer");
42
+ var import_pageRouter = require("./pageRouter");
43
+ var import_popupRouter = require("./popupRouter");
37
44
  var import_ComContext = require("./ComContext");
38
45
  var import_mybricks = require("../mybricks");
39
46
  var import_constant = require("../mybricks/constant");
40
47
  // Annotate the CommonJS export names for ESM import in node:
41
48
  0 && (module.exports = {
49
+ PopupRenderer,
42
50
  SUBJECT_SUBSCRIBE,
43
51
  SUBJECT_VALUE,
44
52
  WithCom,
45
53
  WithWrapper,
54
+ closeActivePopupRouter,
46
55
  createFx,
47
56
  createVariable,
48
57
  merge,
49
- page,
58
+ pageRouter,
59
+ popupRouter,
60
+ router,
61
+ subscribePopupRouter,
50
62
  useAppContext,
51
63
  ...require("./hooks")
52
64
  });
@@ -26,42 +26,56 @@ 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/utils/page.ts
30
- var page_exports = {};
31
- __export(page_exports, {
32
- page: () => page
29
+ // src/core/utils/pageRouter.ts
30
+ var pageRouter_exports = {};
31
+ __export(pageRouter_exports, {
32
+ pageRouter: () => pageRouter,
33
+ router: () => router
33
34
  });
34
- module.exports = __toCommonJS(page_exports);
35
+ module.exports = __toCommonJS(pageRouter_exports);
35
36
  var import_taro = __toESM(require("@tarojs/taro"));
36
37
  var import_mybricks = require("../mybricks");
37
38
  var TaroRouter = class {
39
+ constructor() {
40
+ this.paramsBackup = {};
41
+ }
38
42
  getParams(name) {
39
43
  var _a;
40
44
  const instance = import_taro.default.getCurrentInstance();
41
- return {
42
- value: (_a = instance.router) == null ? void 0 : _a.params
43
- };
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 };
44
50
  }
45
51
  push(name, { value }) {
46
52
  const url = `/pages/${name}/index`;
47
- const queryString = value ? `?data=${encodeURIComponent(JSON.stringify(value))}` : "";
53
+ const dataStr = value ? encodeURIComponent(JSON.stringify(value)) : "";
54
+ if (dataStr) {
55
+ this.paramsBackup[name] = dataStr;
56
+ }
48
57
  import_taro.default.navigateTo({
49
- url: url + queryString
58
+ url: `${url}${dataStr ? `?data=${dataStr}` : ""}`
50
59
  });
51
60
  }
52
61
  replace(name, { value }) {
53
62
  const url = `/pages/${name}/index`;
54
- const queryString = value ? `?data=${encodeURIComponent(JSON.stringify(value))}` : "";
63
+ const dataStr = value ? encodeURIComponent(JSON.stringify(value)) : "";
64
+ if (dataStr) {
65
+ this.paramsBackup[name] = dataStr;
66
+ }
55
67
  import_taro.default.redirectTo({
56
- url: url + queryString
68
+ url: `${url}${dataStr ? `?data=${dataStr}` : ""}`
57
69
  });
58
70
  }
59
71
  pop() {
60
72
  import_taro.default.navigateBack();
61
73
  }
62
74
  };
63
- var page = new import_mybricks.Page(new TaroRouter());
75
+ var router = new TaroRouter();
76
+ var pageRouter = new import_mybricks.Page(router);
64
77
  // Annotate the CommonJS export names for ESM import in node:
65
78
  0 && (module.exports = {
66
- page
79
+ pageRouter,
80
+ router
67
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
+ });
@@ -26,6 +26,12 @@ var import_react = require("react");
26
26
  var import_hooks = require("./hooks");
27
27
  function useAppCreateContext() {
28
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
+ });
29
35
  const appContext = {
30
36
  canvas: {
31
37
  id: "u_7VvVn"
@@ -45,7 +51,9 @@ function useAppCreateContext() {
45
51
  };
46
52
  return {
47
53
  comRefs,
48
- appContext
54
+ appContext,
55
+ popupState,
56
+ setPopupState
49
57
  };
50
58
  }
51
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.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]);
48
+ const [dynamicStyle, setDynamicStyle] = (0, import_react.useState)({});
57
49
  const _data = (0, import_index.useModel)(data || {});
58
- const inputProxy = (0, import_index.useBindInputs)(comRefs, id);
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
  };
@@ -91,6 +91,29 @@ ${fileContent}` : fileContent;
91
91
  };
92
92
  });
93
93
  pagesDir.children.push(...generatedPages);
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
+ });
94
117
  const appConfigFile = (_a = srcDir.children) == null ? void 0 : _a.find(
95
118
  (node) => node.path === "src/app.config.ts"
96
119
  );
@@ -99,6 +122,13 @@ ${fileContent}` : fileContent;
99
122
  }
100
123
  (0, import_tabBarImages.handleTabBarImages)(tabbarDir, imageFiles);
101
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
+ }
102
132
  return templateJson;
103
133
  };
104
134
  var generateTaroProjectJson_default = generateTaroProjectJson;
@@ -8,6 +8,8 @@ interface HandleSlotConfig extends BaseConfig {
8
8
  checkIsRoot: () => boolean;
9
9
  renderManager?: RenderManager;
10
10
  addJSModule?: (module: any) => void;
11
+ isPopup?: boolean;
12
+ hasPopups?: boolean;
11
13
  }
12
14
  declare const handleSlot: (ui: UI, config: HandleSlotConfig) => {
13
15
  js: string;
@@ -44,7 +44,7 @@ var handleSlot = (ui, config) => {
44
44
  addParentDependencyImport: addDependencyImport,
45
45
  renderManager
46
46
  });
47
- const effectCode = (0, import_processSceneLogic.processSceneLogic)(ui, config, addDependencyImport);
47
+ let effectCode = (0, import_processSceneLogic.processSceneLogic)(ui, config, addDependencyImport);
48
48
  let cssContent = ((0, import_utils.convertStyleAryToCss)((_b = props.style) == null ? void 0 : _b.styleAry, slotId) || "") + (childResults.cssContent ? "\n" + childResults.cssContent : "");
49
49
  let renderCodeBlock = isRoot && renderManager ? renderManager.toCode((0, import_utils.indentation)(config.codeStyle.indent)) : "";
50
50
  const combinedJsCode = `${envDefineCode}${childResults.js}${renderCodeBlock ? `
@@ -63,13 +63,21 @@ ${renderCodeBlock}` : ""}${(0, import_scene.wrapInEffect)(indent2, effectCode)}`
63
63
  };
64
64
  };
65
65
  var setupImports = (addImport, config, isRoot) => {
66
- const utilsPkg = config.getUtilsPackageName();
67
- const comPkg = config.getComponentPackageName();
66
+ const importParams = { isPopup: config.isPopup };
67
+ const utilsPkg = config.getUtilsPackageName(importParams);
68
+ const comPkg = config.getComponentPackageName(importParams);
68
69
  addImport({ packageName: "react", dependencyNames: ["useRef", "useEffect", "useState"], importType: "named" });
69
70
  addImport({ packageName: "@tarojs/components", dependencyNames: ["View"], importType: "named" });
70
- addImport({ packageName: utilsPkg, dependencyNames: ["WithCom", "WithWrapper"], importType: "named" });
71
+ const dependencyNames = ["WithCom", "WithWrapper"];
72
+ if (isRoot && config.hasPopups) {
73
+ dependencyNames.push("PopupRenderer");
74
+ }
75
+ addImport({ packageName: utilsPkg, dependencyNames, importType: "named" });
71
76
  addImport({ packageName: comPkg, dependencyNames: ["useAppContext"], importType: "named" });
72
77
  if (isRoot) {
78
+ if (config.hasPopups) {
79
+ addImport({ packageName: "../../common/popup", dependencyNames: ["POPUP_MAP", "POPUP_IDS"], importType: "named" });
80
+ }
73
81
  addImport({ packageName: "./index.less", dependencyNames: [], importType: "module" });
74
82
  }
75
83
  };
@@ -88,7 +96,13 @@ var finalizeRootComponent = (ui, config, importManager, combinedJsCode, uiResult
88
96
  const fileName = ((_a = config.getFileName) == null ? void 0 : _a.call(config, ui.meta.slotId)) || ui.meta.title || "index";
89
97
  const componentId = ((_b = ui.meta) == null ? void 0 : _b.id) || ui.id || ((_c = ui.meta) == null ? void 0 : _c.slotId) || "Index";
90
98
  const componentName = `I${String(componentId).replace(/[^a-zA-Z0-9]/g, "_")}`;
91
- const componentCode = (0, import_scene.genComponentTemplate)({ componentName, combinedJsCode, uiResult });
99
+ const componentCode = (0, import_scene.genComponentTemplate)({
100
+ componentName,
101
+ combinedJsCode,
102
+ uiResult,
103
+ isPopup: config.isPopup,
104
+ hasPopups: config.hasPopups
105
+ });
92
106
  config.add({ importManager, content: componentCode, cssContent, name: fileName });
93
107
  };
94
108
  var handleSlot_default = handleSlot;