@mybricks/to-code-taro 1.1.2 → 1.1.5

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 (129) hide show
  1. package/dist/cjs/core/comlib/_Connector.js +49 -62
  2. package/dist/cjs/core/mybricks/createJSHandle.js +2 -1
  3. package/dist/cjs/core/utils/PopupRenderer.js +1 -1
  4. package/dist/cjs/core/utils/hooks.js +97 -38
  5. package/dist/cjs/core/utils/index.js +3 -0
  6. package/dist/cjs/core/utils/pool.js +63 -0
  7. package/dist/cjs/core/utils/slots.js +12 -5
  8. package/dist/cjs/core/utils/useContext.js +10 -6
  9. package/dist/cjs/core/utils/with.js +3 -3
  10. package/dist/cjs/generate/generateTaroProjectJson.js +15 -4
  11. package/dist/cjs/generate/utils/commonDir.js +12 -1
  12. package/dist/cjs/generate/utils/pageImages.d.ts +14 -0
  13. package/dist/cjs/generate/utils/pageImages.js +36 -0
  14. package/dist/cjs/handleCom.js +37 -14
  15. package/dist/cjs/handleDom.d.ts +2 -0
  16. package/dist/cjs/handleDom.js +5 -2
  17. package/dist/cjs/handleGlobal.js +4 -2
  18. package/dist/cjs/handleSlot.d.ts +3 -0
  19. package/dist/cjs/handleSlot.js +31 -7
  20. package/dist/cjs/taro-template.json +1258 -946
  21. package/dist/cjs/toCodeTaro.d.ts +2 -1
  22. package/dist/cjs/toCodeTaro.js +82 -1
  23. package/dist/cjs/utils/builder/buildResult.d.ts +1 -0
  24. package/dist/cjs/utils/builder/buildResult.js +53 -0
  25. package/dist/cjs/utils/config/content/converter.js +2 -2
  26. package/dist/cjs/utils/config/content/pageConfig.js +4 -1
  27. package/dist/cjs/utils/config/content/saveBase64Image.d.ts +10 -0
  28. package/dist/cjs/utils/config/content/saveBase64Image.js +44 -3
  29. package/dist/cjs/utils/config/content/tabBarConfig.js +8 -2
  30. package/dist/cjs/utils/context/buildContext.d.ts +7 -0
  31. package/dist/cjs/utils/context/buildContext.js +11 -0
  32. package/dist/cjs/utils/logic/handleProcess.js +3 -3
  33. package/dist/cjs/utils/logic/processChildren.d.ts +14 -1
  34. package/dist/cjs/utils/logic/processChildren.js +30 -6
  35. package/dist/cjs/utils/style/converter.js +34 -72
  36. package/dist/cjs/utils/templates/index.d.ts +1 -0
  37. package/dist/cjs/utils/templates/index.js +11 -2
  38. package/dist/cjs/utils/templates/renderManager.d.ts +4 -0
  39. package/dist/cjs/utils/templates/renderManager.js +10 -5
  40. package/dist/cjs/utils/templates/scene.js +2 -0
  41. package/dist/esm/core/comlib/_Connector.js +71 -54
  42. package/dist/esm/core/mybricks/createJSHandle.js +2 -1
  43. package/dist/esm/core/utils/PopupRenderer.js +1 -1
  44. package/dist/esm/core/utils/hooks.js +130 -53
  45. package/dist/esm/core/utils/index.js +1 -0
  46. package/dist/esm/core/utils/pool.js +52 -0
  47. package/dist/esm/core/utils/popupRouter.js +2 -1
  48. package/dist/esm/core/utils/slots.js +25 -23
  49. package/dist/esm/core/utils/useContext.js +19 -12
  50. package/dist/esm/core/utils/with.js +3 -3
  51. package/dist/esm/generate/generateTaroProjectJson.js +19 -2
  52. package/dist/esm/generate/utils/commonDir.js +15 -0
  53. package/dist/esm/generate/utils/pageImages.d.ts +14 -0
  54. package/dist/esm/generate/utils/pageImages.js +15 -0
  55. package/dist/esm/handleCom.js +44 -17
  56. package/dist/esm/handleDom.d.ts +2 -0
  57. package/dist/esm/handleDom.js +6 -4
  58. package/dist/esm/handleGlobal.js +4 -2
  59. package/dist/esm/handleSlot.d.ts +3 -0
  60. package/dist/esm/handleSlot.js +52 -10
  61. package/dist/esm/taro-template.json +1258 -946
  62. package/dist/esm/toCodeTaro.d.ts +2 -1
  63. package/dist/esm/toCodeTaro.js +92 -5
  64. package/dist/esm/utils/builder/buildResult.d.ts +1 -0
  65. package/dist/esm/utils/builder/buildResult.js +41 -1
  66. package/dist/esm/utils/config/content/converter.js +2 -2
  67. package/dist/esm/utils/config/content/pageConfig.js +4 -1
  68. package/dist/esm/utils/config/content/saveBase64Image.d.ts +10 -0
  69. package/dist/esm/utils/config/content/saveBase64Image.js +42 -1
  70. package/dist/esm/utils/config/content/tabBarConfig.js +7 -2
  71. package/dist/esm/utils/context/buildContext.d.ts +7 -0
  72. package/dist/esm/utils/context/buildContext.js +12 -0
  73. package/dist/esm/utils/logic/handleProcess.js +3 -3
  74. package/dist/esm/utils/logic/processChildren.d.ts +14 -1
  75. package/dist/esm/utils/logic/processChildren.js +45 -8
  76. package/dist/esm/utils/style/converter.js +57 -106
  77. package/dist/esm/utils/templates/index.d.ts +1 -0
  78. package/dist/esm/utils/templates/index.js +9 -2
  79. package/dist/esm/utils/templates/renderManager.d.ts +4 -0
  80. package/dist/esm/utils/templates/renderManager.js +19 -5
  81. package/dist/esm/utils/templates/scene.js +1 -0
  82. package/package.json +1 -1
  83. package/dist/esm/abstractEventTypeDef.d.ts.map +0 -1
  84. package/dist/esm/generate/generateTaroTempalteJson.d.ts.map +0 -1
  85. package/dist/esm/generate/utils/appConfig.d.ts.map +0 -1
  86. package/dist/esm/generate/utils/commonDir.d.ts.map +0 -1
  87. package/dist/esm/generate/utils/fileNode.d.ts.map +0 -1
  88. package/dist/esm/generate/utils/index.d.ts.map +0 -1
  89. package/dist/esm/generate/utils/tabBarImages.d.ts.map +0 -1
  90. package/dist/esm/handleCom.d.ts.map +0 -1
  91. package/dist/esm/handleDom.d.ts.map +0 -1
  92. package/dist/esm/handleExtension.d.ts.map +0 -1
  93. package/dist/esm/handleGlobal.d.ts.map +0 -1
  94. package/dist/esm/handleModule.d.ts.map +0 -1
  95. package/dist/esm/index.d.ts.map +0 -1
  96. package/dist/esm/processors/processComEvents.d.ts.map +0 -1
  97. package/dist/esm/processors/processModule.d.ts.map +0 -1
  98. package/dist/esm/processors/processScene.d.ts.map +0 -1
  99. package/dist/esm/processors/processSceneLogic.d.ts.map +0 -1
  100. package/dist/esm/toCodeTaro.d.ts.map +0 -1
  101. package/dist/esm/utils/builder/buildResult.d.ts.map +0 -1
  102. package/dist/esm/utils/common/ImportManager.d.ts.map +0 -1
  103. package/dist/esm/utils/common/helper.d.ts.map +0 -1
  104. package/dist/esm/utils/common/object.d.ts.map +0 -1
  105. package/dist/esm/utils/common/string.d.ts.map +0 -1
  106. package/dist/esm/utils/config/content/converter.d.ts.map +0 -1
  107. package/dist/esm/utils/config/content/index.d.ts.map +0 -1
  108. package/dist/esm/utils/config/content/pageConfig.d.ts.map +0 -1
  109. package/dist/esm/utils/config/content/saveBase64Image.d.ts.map +0 -1
  110. package/dist/esm/utils/config/content/tabBarConfig.d.ts.map +0 -1
  111. package/dist/esm/utils/config/content/types.d.ts.map +0 -1
  112. package/dist/esm/utils/config/content/validator.d.ts.map +0 -1
  113. package/dist/esm/utils/context/buildContext.d.ts.map +0 -1
  114. package/dist/esm/utils/context/buildFrameMap.d.ts.map +0 -1
  115. package/dist/esm/utils/context/buildGlobalData.d.ts.map +0 -1
  116. package/dist/esm/utils/context/collectJSModules.d.ts.map +0 -1
  117. package/dist/esm/utils/context/createEventQueries.d.ts.map +0 -1
  118. package/dist/esm/utils/context/createProvider.d.ts.map +0 -1
  119. package/dist/esm/utils/index.d.ts.map +0 -1
  120. package/dist/esm/utils/logic/convertNamespace.d.ts.map +0 -1
  121. package/dist/esm/utils/logic/handleProcess.d.ts.map +0 -1
  122. package/dist/esm/utils/logic/processChildren.d.ts.map +0 -1
  123. package/dist/esm/utils/style/color.d.ts.map +0 -1
  124. package/dist/esm/utils/style/getComponentClassName.d.ts.map +0 -1
  125. package/dist/esm/utils/style/pxtransform.d.ts.map +0 -1
  126. package/dist/esm/utils/style/types.d.ts.map +0 -1
  127. package/dist/esm/utils/templates/component.d.ts.map +0 -1
  128. package/dist/esm/utils/templates/index.d.ts.map +0 -1
  129. package/dist/esm/utils/templates/renderManager.d.ts.map +0 -1
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
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
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
 
29
19
  // src/core/comlib/_Connector.ts
@@ -32,61 +22,58 @@ __export(Connector_exports, {
32
22
  default: () => Connector_default
33
23
  });
34
24
  module.exports = __toCommonJS(Connector_exports);
35
- var import_taro = __toESM(require("@tarojs/taro"));
36
- var Connector_default = (context) => {
37
- var _a;
38
- const data = context.data;
39
- const inputs = context.inputs;
40
- const outputs = context.outputs;
41
- (_a = inputs.request) == null ? void 0 : _a.call(inputs, (val) => {
25
+ function callCon({ env, data, inputs, outputs, onError }, params = {}) {
26
+ if (data.connector || data.dynamicConfig) {
42
27
  try {
43
- const config = {
44
- method: (val == null ? void 0 : val.method) || data.method || "GET",
45
- url: (val == null ? void 0 : val.url) || data.url,
46
- header: (val == null ? void 0 : val.headers) || data.headers || {},
47
- data: (val == null ? void 0 : val.data) || data.data,
48
- timeout: (val == null ? void 0 : val.timeout) || data.timeout,
49
- dataType: (val == null ? void 0 : val.dataType) || data.dataType || "json",
50
- responseType: (val == null ? void 0 : val.responseType) || data.responseType || "text"
28
+ let finnalConnector = {
29
+ ...data.connector || {},
30
+ outputSchema: data.outputSchema
51
31
  };
52
- if (!config.url) {
53
- outputs.onFail("请求URL不能为空");
54
- return;
32
+ if (data.dynamicConfig) {
33
+ finnalConnector = data.dynamicConfig;
55
34
  }
56
- if (!/^https?:\/\//.test(config.url)) {
57
- outputs.onFail("URL格式不正确,请以http://或https://开头");
58
- return;
35
+ if (data.timeout) {
36
+ finnalConnector.timeout = data.timeout;
59
37
  }
60
- import_taro.default.request({
61
- ...config,
62
- success: (res) => {
63
- if (res.statusCode >= 200 && res.statusCode < 300) {
64
- outputs.onSuccess({
65
- data: res.data,
66
- statusCode: res.statusCode,
67
- header: res.header
68
- });
69
- } else {
70
- outputs.onFail({
71
- message: `请求失败: ${res.statusCode}`,
72
- statusCode: res.statusCode,
73
- data: res.data
74
- });
75
- }
76
- },
77
- fail: (err) => {
78
- outputs.onFail({
79
- message: err.errMsg || "网络请求失败",
80
- error: err
81
- });
82
- }
83
- });
84
- } catch (error) {
85
- console.error("网络请求失败:", error);
86
- outputs.onFail({
87
- message: (error == null ? void 0 : error.message) || "网络请求失败",
88
- error
38
+ env.request(finnalConnector, params, {
39
+ ...data.connectorConfig || {},
40
+ outputSchema: finnalConnector == null ? void 0 : finnalConnector.outputSchema,
41
+ isMultipleOutputs: true
42
+ }).then((val) => {
43
+ outputs[(val == null ? void 0 : val.__OUTPUT_ID__) ?? "then"](
44
+ (val == null ? void 0 : val.__ORIGIN_RESPONSE__) ?? val
45
+ );
46
+ }).catch((err) => {
47
+ outputs["catch"](err);
89
48
  });
49
+ } catch (ex) {
50
+ console.error(ex);
51
+ outputs["catch"](`执行错误 ${ex.message || ex}`);
90
52
  }
91
- });
92
- };
53
+ } else {
54
+ outputs["catch"](`没有选择接口`);
55
+ }
56
+ }
57
+ function isPlainObject(value) {
58
+ if (typeof value !== "object" || value === null)
59
+ return false;
60
+ let proto = Object.getPrototypeOf(value);
61
+ if (proto === null)
62
+ return true;
63
+ return proto === Object.prototype;
64
+ }
65
+ function Connector_default({ env, data, inputs, outputs, onError }) {
66
+ if (!env.runtime) {
67
+ return;
68
+ }
69
+ if (data.immediate) {
70
+ callCon({ env, data, outputs });
71
+ } else {
72
+ inputs["call"]((params) => {
73
+ if (!isPlainObject(params)) {
74
+ params = {};
75
+ }
76
+ callCon({ env, data, outputs, onError }, params);
77
+ });
78
+ }
79
+ }
@@ -71,7 +71,8 @@ var createJSHandle = (fn, options) => {
71
71
  inputs,
72
72
  outputs,
73
73
  logger: import_log.logger,
74
- env: appContext == null ? void 0 : appContext.env
74
+ env: appContext == null ? void 0 : appContext.env,
75
+ appContext
75
76
  });
76
77
  const isJsMultipleInputs = props.inputs[0] ? validateJsMultipleInputs(props.inputs[0]) : false;
77
78
  const exeOutputs = new Proxy(
@@ -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,18 @@ __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");
32
+ var import_pool = require("./pool");
30
33
  function deepProxy(target, onSet) {
31
- if (target === null || typeof target !== "object" || target.__isProxy) {
34
+ if (target === null || typeof target !== "object" || target.__isProxy)
32
35
  return target;
33
- }
34
36
  return new Proxy(target, {
35
37
  get(obj, prop) {
36
38
  if (prop === "__isProxy")
37
39
  return true;
38
40
  if (prop === "toJSON")
39
41
  return () => obj;
40
- let value = obj[prop];
42
+ const value = obj[prop];
41
43
  if (typeof value === "object" && value !== null && !value.__isProxy) {
42
44
  obj[prop] = deepProxy(value, onSet);
43
45
  }
@@ -45,8 +47,7 @@ function deepProxy(target, onSet) {
45
47
  },
46
48
  set(obj, prop, value) {
47
49
  const result = Reflect.set(obj, prop, value);
48
- if (onSet)
49
- onSet();
50
+ onSet == null ? void 0 : onSet();
50
51
  return result;
51
52
  }
52
53
  });
@@ -54,74 +55,131 @@ function deepProxy(target, onSet) {
54
55
  function useModel(rawData) {
55
56
  const [, forceUpdate] = (0, import_react.useState)({});
56
57
  const dataRef = (0, import_react.useRef)(rawData || {});
57
- return (0, import_react.useMemo)(() => {
58
- return deepProxy(dataRef.current, () => forceUpdate({}));
59
- }, []);
58
+ return (0, import_react.useMemo)(() => deepProxy(dataRef.current, () => forceUpdate({})), []);
59
+ }
60
+ function proxyRefs(target, parentComRefs, todoPool) {
61
+ return new Proxy(target, {
62
+ get(obj, prop) {
63
+ var _a;
64
+ if (prop === "__isProxy")
65
+ return true;
66
+ if (prop === "toJSON")
67
+ return () => obj;
68
+ if (typeof prop === "string" && prop.startsWith("u_") && obj[prop] === void 0) {
69
+ if (((_a = parentComRefs == null ? void 0 : parentComRefs.current) == null ? void 0 : _a[prop]) && !parentComRefs.current[prop].__isShadow) {
70
+ return parentComRefs.current[prop];
71
+ }
72
+ const currentIndex = obj.$index ?? 0;
73
+ return obj[prop] = new Proxy({ __isShadow: true }, {
74
+ get(_, method) {
75
+ if (method === "__isShadow")
76
+ return true;
77
+ return (...args) => {
78
+ if (!(todoPool instanceof import_pool.TodoPool))
79
+ return;
80
+ todoPool.push(prop, currentIndex, method, args);
81
+ };
82
+ }
83
+ });
84
+ }
85
+ return obj[prop];
86
+ },
87
+ set(obj, prop, value) {
88
+ const result = Reflect.set(obj, prop, value);
89
+ const isRealRef = typeof prop === "string" && !prop.startsWith("$") && (value == null ? void 0 : value.__isShadow) !== true;
90
+ if (isRealRef && (parentComRefs == null ? void 0 : parentComRefs.current)) {
91
+ try {
92
+ parentComRefs.current[prop] = value;
93
+ } catch {
94
+ }
95
+ }
96
+ return result;
97
+ },
98
+ deleteProperty(obj, prop) {
99
+ const result = Reflect.deleteProperty(obj, prop);
100
+ const isRealRef = typeof prop === "string" && !prop.startsWith("$");
101
+ if (isRealRef && (parentComRefs == null ? void 0 : parentComRefs.current)) {
102
+ try {
103
+ delete parentComRefs.current[prop];
104
+ } catch {
105
+ }
106
+ }
107
+ return result;
108
+ }
109
+ });
60
110
  }
61
111
  function useBindInputs(scope, id, initialHandlers) {
112
+ var _a, _b;
62
113
  const handlersRef = (0, import_react.useRef)({ ...initialHandlers });
63
- if (initialHandlers) {
64
- Object.assign(handlersRef.current, initialHandlers);
65
- }
114
+ const { todoPool } = (0, import_ComContext.useAppContext)();
115
+ const parentSlot = (0, import_ComContext.useParentSlot)();
116
+ const index = ((_b = (_a = parentSlot == null ? void 0 : parentSlot.params) == null ? void 0 : _a.inputValues) == null ? void 0 : _b.index) ?? 0;
117
+ (0, import_react.useEffect)(() => {
118
+ return () => {
119
+ if (scope == null ? void 0 : scope.current) {
120
+ delete scope.current[id];
121
+ }
122
+ };
123
+ }, [scope, id]);
66
124
  return (0, import_react.useMemo)(() => {
67
125
  const proxy = new Proxy({}, {
68
- get: (_target, pin) => {
126
+ get: (target, pin) => {
127
+ if (pin === "__isShadow")
128
+ return false;
129
+ if (pin === "toJSON")
130
+ return () => target;
69
131
  return (arg, ...args) => {
70
132
  if (typeof arg === "function") {
71
133
  handlersRef.current[pin] = arg;
134
+ const pendingArgs = todoPool == null ? void 0 : todoPool.pop(id, index, pin);
135
+ if (pendingArgs) {
136
+ if (pin === "_setData") {
137
+ arg(...pendingArgs);
138
+ } else {
139
+ (0, import_createReactiveInputHandler.createReactiveInputHandler)({ input: arg, value: pendingArgs[0], rels: {}, title: id });
140
+ }
141
+ }
72
142
  } else {
73
143
  const handler = handlersRef.current[pin];
74
144
  if (typeof handler === "function") {
75
- if (pin === "_setData") {
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
- });
145
+ return pin === "_setData" ? handler(arg, ...args) : (0, import_createReactiveInputHandler.createReactiveInputHandler)({ input: handler, value: arg, rels: {}, title: id });
85
146
  }
86
147
  }
87
148
  };
88
149
  }
89
150
  });
90
- if (scope && scope.current) {
151
+ if (scope == null ? void 0 : scope.current)
91
152
  scope.current[id] = proxy;
153
+ if (initialHandlers) {
154
+ Object.keys(initialHandlers).forEach((pin) => proxy[pin](initialHandlers[pin]));
92
155
  }
93
156
  return proxy;
94
- }, [scope, id]);
157
+ }, [scope, id, todoPool, index]);
95
158
  }
96
159
  function useBindEvents(props, context) {
97
160
  return (0, import_react.useMemo)(() => {
98
- const _events = {};
161
+ const events = {};
99
162
  Object.keys(props).forEach((key) => {
100
163
  if (typeof props[key] === "function") {
101
164
  const handler = props[key];
102
- const wrapped = (originalValue) => {
165
+ const wrapped = (original) => {
103
166
  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;
167
+ 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
168
  return handler(value);
110
169
  };
111
170
  wrapped.getConnections = () => [{ id: "default" }];
112
- _events[key] = wrapped;
171
+ events[key] = wrapped;
113
172
  }
114
173
  });
115
- return new Proxy(_events, {
174
+ return new Proxy(events, {
116
175
  get(target, key) {
117
176
  if (typeof key === "string" && key.startsWith("on")) {
118
- if (target[key]) {
177
+ if (target[key])
119
178
  return target[key];
120
- }
121
- const emptyFn = () => {
179
+ const fn = () => {
122
180
  };
123
- emptyFn.getConnections = () => [];
124
- return emptyFn;
181
+ fn.getConnections = () => [];
182
+ return fn;
125
183
  }
126
184
  return target[key];
127
185
  }
@@ -131,6 +189,7 @@ function useBindEvents(props, context) {
131
189
  // Annotate the CommonJS export names for ESM import in node:
132
190
  0 && (module.exports = {
133
191
  deepProxy,
192
+ proxyRefs,
134
193
  useBindEvents,
135
194
  useBindInputs,
136
195
  useModel
@@ -24,6 +24,7 @@ __export(utils_exports, {
24
24
  SUBJECT_SUBSCRIBE: () => import_constant.SUBJECT_SUBSCRIBE,
25
25
  SUBJECT_VALUE: () => import_constant.SUBJECT_VALUE,
26
26
  SlotProvider: () => import_ComContext.SlotProvider,
27
+ TodoPool: () => import_pool.TodoPool,
27
28
  WithCom: () => import_with.WithCom,
28
29
  WithWrapper: () => import_with.WithWrapper,
29
30
  closeActivePopupRouter: () => import_popupRouter.closeActivePopupRouter,
@@ -39,6 +40,7 @@ __export(utils_exports, {
39
40
  });
40
41
  module.exports = __toCommonJS(utils_exports);
41
42
  __reExport(utils_exports, require("./hooks"), module.exports);
43
+ var import_pool = require("./pool");
42
44
  var import_with = require("./with");
43
45
  var import_PopupRenderer = require("./PopupRenderer");
44
46
  var import_pageRouter = require("./pageRouter");
@@ -54,6 +56,7 @@ __reExport(utils_exports, require("./slots"), module.exports);
54
56
  SUBJECT_SUBSCRIBE,
55
57
  SUBJECT_VALUE,
56
58
  SlotProvider,
59
+ TodoPool,
57
60
  WithCom,
58
61
  WithWrapper,
59
62
  closeActivePopupRouter,
@@ -0,0 +1,63 @@
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/pool.ts
20
+ var pool_exports = {};
21
+ __export(pool_exports, {
22
+ TodoPool: () => TodoPool
23
+ });
24
+ module.exports = __toCommonJS(pool_exports);
25
+ var TodoPool = class {
26
+ constructor() {
27
+ this.pool = /* @__PURE__ */ new Map();
28
+ }
29
+ /** 存:记录待执行指令 */
30
+ push(id, index, method, args) {
31
+ if (!this.pool.has(id)) {
32
+ this.pool.set(id, /* @__PURE__ */ new Map());
33
+ }
34
+ const instances = this.pool.get(id);
35
+ if (!instances.has(index)) {
36
+ instances.set(index, {});
37
+ }
38
+ instances.get(index)[method] = args;
39
+ }
40
+ /** 取:获取并物理删除指令 */
41
+ pop(id, index, method) {
42
+ const instances = this.pool.get(id);
43
+ if (!instances)
44
+ return void 0;
45
+ const todo = instances.get(index);
46
+ if (todo && todo[method]) {
47
+ const args = todo[method];
48
+ delete todo[method];
49
+ if (Object.keys(todo).length === 0) {
50
+ instances.delete(index);
51
+ }
52
+ if (instances.size === 0) {
53
+ this.pool.delete(id);
54
+ }
55
+ return args;
56
+ }
57
+ return void 0;
58
+ }
59
+ };
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ TodoPool
63
+ });
@@ -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, todoPool, index = 0) {
42
+ const localTarget = { $inputs: {}, $outputs: {}, $index: index };
43
+ return { current: (0, import_hooks.proxyRefs)(localTarget, parentComRefs, todoPool) };
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, todoPool } = (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;
88
94
  const r = state._render;
89
- 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);
95
+ const rawScope = ((_a = params == null ? void 0 : params.inputValues) == null ? void 0 : _a.index) ?? (params == null ? void 0 : params.key);
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 scopedComRefs = (_d = state._scopedComRefs)[scopeId] || (_d[scopeId] = { current: { $inputs: {}, $outputs: {} } });
95
- return /* @__PURE__ */ import_react.default.createElement(import_ComContext.SlotProvider, { value: { ...state, params } }, /* @__PURE__ */ import_react.default.createElement(ScopedComContextProvider, { comRefs: scopedComRefs, scopeId }, /* @__PURE__ */ import_react.default.createElement(SlotParamsBridge, { state, params, render: r })));
100
+ const index = ((_b = params == null ? void 0 : params.inputValues) == null ? void 0 : _b.index) ?? 0;
101
+ const scopedComRefs = (_c = state._scopedComRefs)[scopeId] || (_c[scopeId] = createPenetratingComRefs(parentComRefs, todoPool, 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, todoPool]);
109
116
  }
110
117
  function ScopedComContextProvider(props) {
111
118
  const parent = (0, import_ComContext.useAppContext)();
@@ -24,8 +24,11 @@ __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
- function useAppCreateContext() {
28
- const comRefs = (0, import_react.useRef)((0, import_hooks.deepProxy)({ $inputs: {}, $outputs: {} }));
27
+ var import_pool = require("./pool");
28
+ var import_request = require("@/common/request");
29
+ function useAppCreateContext(id) {
30
+ const todoPool = (0, import_react.useMemo)(() => new import_pool.TodoPool(), []);
31
+ const comRefs = (0, import_react.useRef)((0, import_hooks.proxyRefs)({ $inputs: {}, $outputs: {} }, void 0, todoPool));
29
32
  const $vars = (0, import_react.useRef)({});
30
33
  const $fxs = (0, import_react.useRef)({});
31
34
  const [popupState, setPopupState] = (0, import_react.useState)({
@@ -36,11 +39,11 @@ function useAppCreateContext() {
36
39
  });
37
40
  const appContext = (0, import_react.useRef)({
38
41
  canvas: {
39
- id: "u_7VvVn"
40
- // 使用 data 中的 id
42
+ id
41
43
  },
42
- runtime: {
43
- debug: false
44
+ env: {
45
+ runtime: true,
46
+ request: (connector, params, config) => (0, import_request.request)(connector, params, config, { $vars })
44
47
  },
45
48
  edit: false,
46
49
  isH5: false,
@@ -57,6 +60,7 @@ function useAppCreateContext() {
57
60
  comRefs,
58
61
  $vars,
59
62
  $fxs,
63
+ todoPool,
60
64
  appContext,
61
65
  popupState,
62
66
  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,6 +37,7 @@ 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");
41
42
  var import_genJSModules = require("../utils/logic/genJSModules");
42
43
  var generateTaroProjectJson = (result) => {
@@ -60,6 +61,7 @@ var generateTaroProjectJson = (result) => {
60
61
  const assetsDir = (0, import_fileNode.ensureDir)(srcDir, "src/assets");
61
62
  const tabbarDir = (0, import_fileNode.ensureDir)(assetsDir, "src/assets/tabbar");
62
63
  const imageFiles = assets.tabBarImages || [];
64
+ const pageImages = assets.pageImages || [];
63
65
  const normalItems = files.filter((item) => item.type === "normal");
64
66
  const generatedPages = normalItems.map((item) => {
65
67
  var _a2;
@@ -90,8 +92,8 @@ ${fileContent}` : fileContent;
90
92
  path: `src/pages/${pageName}/index.jsModules.ts`,
91
93
  content: (0, import_genJSModules.genScopedJSModules)(
92
94
  item.jsModules,
93
- "../../core/mybricks/index",
94
- "../../common/jsModulesRuntime"
95
+ "@/core/mybricks/index",
96
+ "@/common/jsModulesRuntime"
95
97
  )
96
98
  });
97
99
  }
@@ -125,8 +127,8 @@ ${item.content || ""}`;
125
127
  path: `src/popupComponents/${popupId}/index.jsModules.ts`,
126
128
  content: (0, import_genJSModules.genScopedJSModules)(
127
129
  item.jsModules,
128
- "../../core/mybricks/index",
129
- "../../common/jsModulesRuntime"
130
+ "@/core/mybricks/index",
131
+ "@/common/jsModulesRuntime"
130
132
  )
131
133
  });
132
134
  }
@@ -143,6 +145,7 @@ ${item.content || ""}`;
143
145
  (0, import_appConfig.updateAppConfig)(appConfigFile, normalItems, files);
144
146
  }
145
147
  (0, import_tabBarImages.handleTabBarImages)(tabbarDir, imageFiles);
148
+ (0, import_pageImages.handlePageImages)(assetsDir, pageImages);
146
149
  const CUSTOM_TAB_BAR_CONFIG_PATH = "src/custom-tab-bar/mybricks/tabbar-config.ts";
147
150
  const customTabBarItem = files.find((item) => item.type === "customTabBar");
148
151
  if (customTabBarItem == null ? void 0 : customTabBarItem.content) {
@@ -161,6 +164,14 @@ ${item.content || ""}`;
161
164
  }
162
165
  }
163
166
  (0, import_commonDir.handleCommonDir)(commonDir, files);
167
+ const apiItem = files.find((item) => item.type === "connector-api");
168
+ if (apiItem) {
169
+ commonDir.children = commonDir.children || [];
170
+ commonDir.children.push({
171
+ path: "src/common/api.ts",
172
+ content: apiItem.content
173
+ });
174
+ }
164
175
  const popupFile = files.find((f) => f.type === "popup" && !f.meta);
165
176
  if (popupFile) {
166
177
  commonDir.children.push({
@@ -23,7 +23,7 @@ __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
28
  const jsModulesRuntimeItem = items.find((item) => item.type === "jsModulesRuntime");
29
29
  if (jsModulesRuntimeItem) {
@@ -36,6 +36,17 @@ ${fileContent}` : fileContent;
36
36
  content: fullContent
37
37
  });
38
38
  }
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;
45
+ commonDir.children.push({
46
+ path: "src/common/global.ts",
47
+ content: fullContent
48
+ });
49
+ }
39
50
  }
40
51
  // Annotate the CommonJS export names for ESM import in node:
41
52
  0 && (module.exports = {
@@ -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 {};