@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10

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 (239) hide show
  1. package/dist/apis/apis.ts +6 -2
  2. package/dist/apis/base/crypto.ts +4 -0
  3. package/dist/apis/base/debug.ts +5 -0
  4. package/dist/apis/base/index.ts +9 -1
  5. package/dist/apis/base/performance.ts +8 -0
  6. package/dist/apis/base/system.ts +74 -21
  7. package/dist/apis/base/update.ts +5 -0
  8. package/dist/apis/base/weapp/app-event.ts +75 -0
  9. package/dist/apis/base/weapp/life-cycle.ts +21 -0
  10. package/dist/apis/canvas/index.ts +27 -0
  11. package/dist/apis/data-analysis/index.ts +6 -0
  12. package/dist/apis/device/accelerometer.ts +2 -1
  13. package/dist/apis/device/accessibility.ts +4 -0
  14. package/dist/apis/device/battery.ts +2 -2
  15. package/dist/apis/device/bluetooth-ble.ts +19 -0
  16. package/dist/apis/device/bluetooth-peripheral.ts +6 -0
  17. package/dist/apis/device/bluetooth.ts +16 -0
  18. package/dist/apis/device/calendar.ts +5 -0
  19. package/dist/apis/device/clipboard.ts +17 -9
  20. package/dist/apis/device/compass.ts +21 -0
  21. package/dist/apis/device/contact.ts +5 -0
  22. package/dist/apis/device/crypto.ts +4 -0
  23. package/dist/apis/device/gyroscope.ts +7 -0
  24. package/dist/apis/device/iBeacon.ts +10 -0
  25. package/dist/apis/device/index.ts +15 -0
  26. package/dist/apis/device/keyboard.ts +2 -1
  27. package/dist/apis/device/memory.ts +10 -3
  28. package/dist/apis/device/motion.ts +6 -0
  29. package/dist/apis/device/network.ts +26 -9
  30. package/dist/apis/device/nfc.ts +10 -0
  31. package/dist/apis/device/phone.ts +2 -1
  32. package/dist/apis/device/scan.ts +4 -0
  33. package/dist/apis/device/screen.ts +2 -1
  34. package/dist/apis/device/sms.ts +4 -0
  35. package/dist/apis/device/vibrate.ts +19 -11
  36. package/dist/apis/device/wifi.ts +15 -0
  37. package/dist/apis/ext/index.ts +5 -0
  38. package/dist/apis/files/index.ts +2 -1
  39. package/dist/apis/files/manager.ts +2 -1
  40. package/dist/apis/framework/index.ts +3 -8
  41. package/dist/apis/index.ts +27 -17
  42. package/dist/apis/location/index.ts +61 -68
  43. package/dist/apis/media/EditorContext.ts +32 -0
  44. package/dist/apis/media/audio/index.ts +18 -0
  45. package/dist/apis/media/background-audio/index.ts +16 -0
  46. package/dist/apis/media/camera.ts +16 -0
  47. package/dist/apis/media/common.ts +2 -1
  48. package/dist/apis/media/{image.ts → image/index.ts} +4 -3
  49. package/dist/apis/media/index.ts +10 -0
  50. package/dist/apis/media/live.ts +5 -0
  51. package/dist/apis/media/map.ts +4 -0
  52. package/dist/apis/media/media-recorder.ts +4 -0
  53. package/dist/apis/media/recorder.ts +6 -0
  54. package/dist/apis/media/video/VideoContext.ts +68 -0
  55. package/dist/apis/media/{video.ts → video/index.ts} +13 -2
  56. package/dist/apis/media/video-decoder.ts +4 -0
  57. package/dist/apis/media/video-processing.ts +4 -0
  58. package/dist/apis/media/voip.ts +19 -0
  59. package/dist/apis/network/index.ts +3 -0
  60. package/dist/apis/network/mdns.ts +13 -0
  61. package/dist/apis/network/request.ts +7 -6
  62. package/dist/apis/network/tcp.ts +4 -0
  63. package/dist/apis/network/udp.ts +4 -0
  64. package/dist/apis/network/webSocket.ts +2 -6
  65. package/dist/apis/open-api/account.ts +4 -0
  66. package/dist/apis/open-api/address.ts +4 -0
  67. package/dist/apis/open-api/authorize.ts +5 -0
  68. package/dist/apis/open-api/card.ts +5 -0
  69. package/dist/apis/open-api/channels-live.ts +11 -0
  70. package/dist/apis/open-api/customer-service.ts +4 -0
  71. package/dist/apis/open-api/device-voip.ts +5 -0
  72. package/dist/apis/open-api/facial.ts +7 -0
  73. package/dist/apis/open-api/favorites.ts +5 -0
  74. package/dist/apis/open-api/group.ts +4 -0
  75. package/dist/apis/open-api/index.ts +20 -6
  76. package/dist/apis/open-api/invoice.ts +5 -0
  77. package/dist/apis/open-api/license-plate.ts +4 -0
  78. package/dist/apis/open-api/login.ts +6 -0
  79. package/dist/apis/open-api/my-miniprogram.ts +4 -0
  80. package/dist/apis/open-api/privacy.ts +7 -0
  81. package/dist/apis/open-api/red-package.ts +4 -0
  82. package/dist/apis/open-api/settings.ts +5 -0
  83. package/dist/apis/open-api/soter.ts +6 -0
  84. package/dist/apis/open-api/subscribe-message.ts +6 -0
  85. package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
  86. package/dist/apis/open-api/werun.ts +5 -0
  87. package/dist/apis/payment/index.ts +6 -0
  88. package/dist/apis/route/index.ts +19 -28
  89. package/dist/apis/share/index.ts +33 -0
  90. package/dist/apis/storage/background-fetch.ts +7 -0
  91. package/dist/apis/storage/cache-manager.ts +4 -0
  92. package/dist/apis/storage/index.ts +158 -88
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +4 -19
  96. package/dist/apis/ui/custom-component.ts +8 -0
  97. package/dist/apis/ui/fonts.ts +4 -0
  98. package/dist/apis/ui/index.ts +8 -10
  99. package/dist/apis/ui/interaction/index.ts +45 -59
  100. package/dist/apis/ui/menu.ts +4 -0
  101. package/dist/apis/ui/navigation-bar/index.ts +60 -21
  102. package/dist/apis/ui/pull-down-refresh.ts +10 -4
  103. package/dist/apis/{page → ui/scroll}/index.ts +32 -27
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/utils/index.ts +1 -1
  109. package/dist/apis/worker/index.ts +4 -0
  110. package/dist/apis/wxml/IntersectionObserver.ts +24 -25
  111. package/dist/apis/wxml/index.ts +7 -2
  112. package/dist/apis/wxml/nodesRef.ts +2 -2
  113. package/dist/apis/wxml/selectorQuery.ts +29 -17
  114. package/dist/components-harmony-ets/button.ets +106 -80
  115. package/dist/components-harmony-ets/canvas.ets +51 -0
  116. package/dist/components-harmony-ets/checkbox.ets +82 -148
  117. package/dist/components-harmony-ets/form.ets +45 -132
  118. package/dist/components-harmony-ets/icon.ets +66 -69
  119. package/dist/components-harmony-ets/image.ets +26 -61
  120. package/dist/components-harmony-ets/index.ets +92 -0
  121. package/dist/components-harmony-ets/innerHtml.ets +7 -70
  122. package/dist/components-harmony-ets/input.ets +60 -146
  123. package/dist/components-harmony-ets/label.ets +86 -92
  124. package/dist/components-harmony-ets/listView.ets +26 -0
  125. package/dist/components-harmony-ets/movableArea.ets +124 -0
  126. package/dist/components-harmony-ets/movableView.ets +93 -0
  127. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  128. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  129. package/dist/components-harmony-ets/picker.ets +172 -198
  130. package/dist/components-harmony-ets/progress.ets +52 -0
  131. package/dist/components-harmony-ets/pseudo.ets +80 -0
  132. package/dist/components-harmony-ets/radio.ets +85 -155
  133. package/dist/components-harmony-ets/richText.ets +15 -87
  134. package/dist/components-harmony-ets/scrollList.ets +94 -0
  135. package/dist/components-harmony-ets/scrollView.ets +81 -149
  136. package/dist/components-harmony-ets/slider.ets +47 -94
  137. package/dist/components-harmony-ets/stickySection.ets +42 -0
  138. package/dist/components-harmony-ets/style.ets +396 -0
  139. package/dist/components-harmony-ets/swiper.ets +51 -151
  140. package/dist/components-harmony-ets/switch.ets +35 -76
  141. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  142. package/dist/components-harmony-ets/text.ets +131 -76
  143. package/dist/components-harmony-ets/textArea.ets +64 -140
  144. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  145. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  146. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  147. package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
  148. package/dist/components-harmony-ets/utils/helper.ets +18 -65
  149. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  150. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  151. package/dist/components-harmony-ets/utils/index.ts +55 -51
  152. package/dist/components-harmony-ets/utils/styles.ets +177 -65
  153. package/dist/components-harmony-ets/video.ets +70 -116
  154. package/dist/components-harmony-ets/view.ets +58 -64
  155. package/dist/components-harmony-ets/webView.ets +56 -0
  156. package/dist/index.d.ts +152 -0
  157. package/dist/index.js +230 -60
  158. package/dist/index.js.map +1 -1
  159. package/dist/runtime-ets/bom/document.ts +6 -4
  160. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  161. package/dist/runtime-ets/bom/window.ts +9 -2
  162. package/dist/runtime-ets/current.ts +3 -0
  163. package/dist/runtime-ets/dom/bind.ts +96 -0
  164. package/dist/runtime-ets/dom/class-list.ts +4 -6
  165. package/dist/runtime-ets/dom/comment.ts +1 -2
  166. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  167. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
  168. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  169. package/dist/runtime-ets/dom/document.ts +36 -51
  170. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  171. package/dist/runtime-ets/dom/element/element.ts +439 -0
  172. package/dist/runtime-ets/dom/element/form.ts +403 -0
  173. package/dist/runtime-ets/dom/element/index.ts +120 -0
  174. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  175. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  176. package/dist/runtime-ets/dom/element/normal.ts +103 -0
  177. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  178. package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
  179. package/dist/runtime-ets/dom/element/text.ts +10 -0
  180. package/dist/runtime-ets/dom/element/video.ts +50 -0
  181. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  182. package/dist/runtime-ets/dom/event.ts +26 -5
  183. package/dist/runtime-ets/dom/eventTarget.ts +3 -3
  184. package/dist/runtime-ets/dom/node.ts +114 -49
  185. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  186. package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
  187. package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
  188. package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
  189. package/dist/runtime-ets/index.ts +2 -3
  190. package/dist/runtime-ets/interface/event.ts +3 -2
  191. package/dist/runtime-ets/utils/index.ts +87 -17
  192. package/dist/runtime-ets/utils/info.ts +21 -47
  193. package/dist/runtime-framework/react/app.ts +20 -28
  194. package/dist/runtime-framework/react/hooks.ts +3 -4
  195. package/dist/runtime-framework/react/index.ts +1 -2
  196. package/dist/runtime-framework/react/native-page.ts +421 -0
  197. package/dist/runtime-framework/react/page.ts +5 -17
  198. package/dist/runtime-framework/solid/app.ts +25 -45
  199. package/dist/runtime-framework/solid/connect.ts +21 -3
  200. package/dist/runtime-framework/solid/hooks.ts +17 -12
  201. package/dist/runtime-framework/solid/index.ts +6 -2
  202. package/dist/runtime-framework/solid/page.ts +84 -36
  203. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  204. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  205. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  206. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  207. package/dist/runtime-utils.d.ts +827 -0
  208. package/dist/runtime-utils.js +1633 -549
  209. package/dist/runtime-utils.js.map +1 -1
  210. package/dist/runtime.d.ts +1 -0
  211. package/dist/runtime.js +1633 -549
  212. package/dist/runtime.js.map +1 -1
  213. package/index.js +3 -1
  214. package/package.json +14 -15
  215. package/static/media/cancel.svg +1 -0
  216. package/static/media/circle.svg +1 -0
  217. package/static/media/clear.svg +1 -0
  218. package/static/media/download.svg +1 -0
  219. package/static/media/info.svg +1 -0
  220. package/static/media/info_circle.svg +1 -0
  221. package/static/media/search.svg +1 -0
  222. package/static/media/success.svg +1 -0
  223. package/static/media/success_no_circle.svg +1 -0
  224. package/static/media/taro_arrow_left.svg +1 -0
  225. package/static/media/taro_home.svg +1 -0
  226. package/static/media/waiting.svg +1 -0
  227. package/static/media/warn.svg +1 -0
  228. package/types/harmony.d.ts +4 -0
  229. package/types/index.d.ts +4 -0
  230. package/types/runtime.d.ts +7 -1
  231. package/LICENSE +0 -160
  232. package/dist/components-harmony-ets/base.ets +0 -63
  233. package/dist/components-harmony-ets/element.ets +0 -223
  234. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  235. package/dist/runtime-ets/dom/element.ts +0 -457
  236. package/dist/runtime-ets/dom/text.ts +0 -19
  237. package/dist/runtime-ets/utils/bind.ts +0 -35
  238. package/types/api.d.ts +0 -4
  239. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
package/dist/index.js CHANGED
@@ -4,10 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var helper = require('@tarojs/helper');
6
6
  var path = require('node:path');
7
- var runnerUtils = require('@tarojs/runner-utils');
8
- var shared = require('@tarojs/shared');
9
7
  var service = require('@tarojs/service');
10
8
  var _package = require('@tarojs/service/dist/utils/package');
9
+ var shared = require('@tarojs/shared');
11
10
  var webpackSources = require('webpack-sources');
12
11
  var template = require('@tarojs/shared/dist/template');
13
12
 
@@ -44,7 +43,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
44
43
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45
44
  PERFORMANCE OF THIS SOFTWARE.
46
45
  ***************************************************************************** */
47
- /* global Reflect, Promise */
46
+ /* global Reflect, Promise, SuppressedError, Symbol */
48
47
 
49
48
 
50
49
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -68,10 +67,95 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
68
67
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
69
68
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
70
69
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
70
+ }
71
+
72
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
73
+ var e = new Error(message);
74
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
75
+ };
76
+
77
+ function apiLoader(str) {
78
+ return `import {
79
+ useAddToFavorites,
80
+ useDidHide,
81
+ useDidShow,
82
+ useError,
83
+ useLaunch,
84
+ useLoad,
85
+ useOptionMenuClick,
86
+ usePageNotFound,
87
+ usePageScroll,
88
+ usePullDownRefresh,
89
+ usePullIntercept,
90
+ useReachBottom,
91
+ useReady,
92
+ useResize,
93
+ useRouter,
94
+ useSaveExitState,
95
+ useShareAppMessage,
96
+ useShareTimeline,
97
+ useTabItemTap,
98
+ useTitleClick,
99
+ useScope,
100
+ useUnhandledRejection,
101
+ useUnload
102
+ } from '@tarojs/plugin-framework-react/dist/runtime'
103
+ ${str}
104
+
105
+ taro.useAddToFavorites = useAddToFavorites
106
+ taro.useDidHide = useDidHide
107
+ taro.useDidShow = useDidShow
108
+ taro.useError = useError
109
+ taro.useLaunch = useLaunch
110
+ taro.useLoad = useLoad
111
+ taro.useOptionMenuClick = useOptionMenuClick
112
+ taro.usePageNotFound = usePageNotFound
113
+ taro.usePageScroll = usePageScroll
114
+ taro.usePullDownRefresh = usePullDownRefresh
115
+ taro.usePullIntercept = usePullIntercept
116
+ taro.useReachBottom = useReachBottom
117
+ taro.useReady = useReady
118
+ taro.useResize = useResize
119
+ taro.useRouter = useRouter
120
+ taro.useSaveExitState = useSaveExitState
121
+ taro.useShareAppMessage = useShareAppMessage
122
+ taro.useShareTimeline = useShareTimeline
123
+ taro.useTabItemTap = useTabItemTap
124
+ taro.useTitleClick = useTitleClick
125
+ taro.useScope = useScope
126
+ taro.useUnhandledRejection = useUnhandledRejection
127
+ taro.useUnload = useUnload
128
+
129
+ export {
130
+ useAddToFavorites,
131
+ useDidHide,
132
+ useDidShow,
133
+ useError,
134
+ useLaunch,
135
+ useLoad,
136
+ useOptionMenuClick,
137
+ usePageNotFound,
138
+ usePageScroll,
139
+ usePullDownRefresh,
140
+ usePullIntercept,
141
+ useReachBottom,
142
+ useReady,
143
+ useResize,
144
+ useRouter,
145
+ useSaveExitState,
146
+ useShareAppMessage,
147
+ useShareTimeline,
148
+ useTabItemTap,
149
+ useTitleClick,
150
+ useScope,
151
+ useUnhandledRejection,
152
+ useUnload
153
+ }
154
+ `;
71
155
  }
72
156
 
73
157
  const PLATFORM_NAME = 'harmony';
74
- const PACKAGE_NAME = '@tarojs/plugin-platform-harmony';
158
+ const PACKAGE_NAME = '@tarojs/plugin-platform-harmony-ets';
75
159
  const PLUGIN_NAME = 'TaroHarmony';
76
160
  const HARMONY_SCOPES = [/^@system\./, /^@ohos\./, /^@hmscore\//];
77
161
 
@@ -95,8 +179,8 @@ class TaroPlatformHarmony extends service.TaroPlatform {
95
179
  * 2. 输出编译提示
96
180
  */
97
181
  setup() {
98
- var _a, _b;
99
182
  return __awaiter(this, void 0, void 0, function* () {
183
+ var _a, _b;
100
184
  yield this.setupTransaction.perform(this.setupHarmonyApp, this);
101
185
  (_b = (_a = this.ctx).onSetupClose) === null || _b === void 0 ? void 0 : _b.call(_a, this);
102
186
  });
@@ -152,6 +236,7 @@ class TaroPlatformHarmony extends service.TaroPlatform {
152
236
  * @param extraOptions 需要额外合入 Options 的配置项
153
237
  */
154
238
  getOptions(extraOptions = {}) {
239
+ var _a, _b, _c;
155
240
  const { ctx } = this;
156
241
  const { recursiveMerge } = ctx.helper;
157
242
  const config = recursiveMerge(Object.assign({}, this.config), {
@@ -159,24 +244,25 @@ class TaroPlatformHarmony extends service.TaroPlatform {
159
244
  FRAMEWORK: JSON.stringify(this.config.framework),
160
245
  TARO_ENV: JSON.stringify(this.platform),
161
246
  TARO_PLATFORM: JSON.stringify(this.platformType),
162
- TARO_VERSION: JSON.stringify(_package.getPkgVersion())
247
+ TARO_VERSION: JSON.stringify(_package.getPkgVersion()),
248
+ SUPPORT_TARO_POLYFILL: 'disabled',
163
249
  },
164
250
  });
165
- return Object.assign(Object.assign(Object.assign({}, config), { buildAdapter: config.platform, fileType: this.fileType, platformType: this.platformType, useETS: this.useETS, useJSON5: this.useJSON5 }), extraOptions);
251
+ return Object.assign(Object.assign(Object.assign({}, config), { buildAdapter: config.platform, fileType: this.fileType, platformType: this.platformType, useETS: this.useETS, useJSON5: this.useJSON5, isPure: Boolean((_c = (_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.runOpts) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.args) === null || _c === void 0 ? void 0 : _c.pure) }), extraOptions);
166
252
  }
167
253
  /**
168
254
  * 调用 runner 开始编译
169
255
  * @param extraOptions 需要额外传入 runner 的配置项
170
256
  */
171
- build(extraOptions = {}) {
172
- var _a, _b;
173
- return __awaiter(this, void 0, void 0, function* () {
257
+ build() {
258
+ return __awaiter(this, arguments, void 0, function* (extraOptions = {}) {
259
+ var _a, _b;
174
260
  (_b = (_a = this.ctx).onBuildInit) === null || _b === void 0 ? void 0 : _b.call(_a, this);
175
261
  yield this.buildTransaction.perform(this.buildHarmonyApp, this, extraOptions);
176
262
  });
177
263
  }
178
- buildHarmonyApp(extraOptions = {}) {
179
- return __awaiter(this, void 0, void 0, function* () {
264
+ buildHarmonyApp() {
265
+ return __awaiter(this, arguments, void 0, function* (extraOptions = {}) {
180
266
  const runner = yield this.getRunner();
181
267
  const options = this.getOptions(Object.assign({
182
268
  runtimePath: this.runtimePath,
@@ -199,7 +285,6 @@ class TaroPlatformHarmony extends service.TaroPlatform {
199
285
  var _Harmony_defineConstants;
200
286
  const frameworkAlias = {
201
287
  solid: 'solid',
202
- vue: 'vue2',
203
288
  vue3: 'vue3',
204
289
  };
205
290
  let Harmony$1 = class Harmony extends TaroPlatformHarmony {
@@ -217,6 +302,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
217
302
  this.useJSON5 = true;
218
303
  this.runtimePath = [];
219
304
  this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-harmony-ets`;
305
+ this.apiEntryList = [
306
+ /(@tarojs[\\/]plugin-platform-harmony-ets|taro-platform-harmony)[\\/]dist[\\/]apis[\\/]index\.ts/,
307
+ ];
220
308
  _Harmony_defineConstants.set(this, {});
221
309
  this.extensions = ['.js', '.jsx', '.ts', '.tsx', '.cjs', '.mjs', '.mts', '.vue', '.ets', '.d.ts'];
222
310
  this.excludeLibraries = [];
@@ -224,18 +312,24 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
224
312
  ['@tarojs/components/types', /^@tarojs[\\/]components[\\/]types/],
225
313
  ['@tarojs/components', /^@tarojs[\\/]components([\\/].+)?$/, this.componentLibrary],
226
314
  ['@tarojs/react', /^@tarojs[\\/]react$/],
227
- ['@tarojs/runtime', /^@tarojs[\\/]runtime$/, this.runtimeLibrary],
315
+ ['@tarojs/runtime', /^@tarojs[\\/]runtime([\\/]ets[\\/].*)?$/, this.runtimeLibrary],
228
316
  ['@tarojs/taro/types', /^@tarojs[\\/]taro[\\/]types/],
229
317
  ['@tarojs/taro', /^@tarojs[\\/]taro$/, this.apiLibrary],
230
318
  ['@tarojs/plugin-framework-react/dist/runtime', /^@tarojs[\\/]plugin-framework-react[\\/]dist[\\/]runtime$/, this.runtimeFrameworkLibrary],
231
319
  ['react', /^react$|react[\\/]cjs/],
232
320
  ['react/jsx-runtime', /^react[\\/]jsx-runtime$/], // Note: React 环境下自动注入,避免重复
233
321
  ];
322
+ this.harmonyScope = [...HARMONY_SCOPES];
323
+ const that = this;
234
324
  this.setupTransaction.addWrapper({
235
325
  close() {
236
- this.modifyViteConfig();
326
+ that.modifyViteConfig();
237
327
  },
238
328
  });
329
+ ctx.onBuildFinish(() => {
330
+ const outDir = path__namespace.resolve(process.cwd(), config.outputRoot);
331
+ that.handleResourceEmit(outDir);
332
+ });
239
333
  }
240
334
  get framework() {
241
335
  return this.ctx.initialConfig.framework || 'react';
@@ -246,6 +340,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
246
340
  get apiLibrary() {
247
341
  return path__namespace.resolve(__dirname, './apis');
248
342
  }
343
+ get apiEntry() {
344
+ return this.apiEntryList;
345
+ }
249
346
  get componentLibrary() {
250
347
  return path__namespace.resolve(__dirname, './components-harmony-ets');
251
348
  }
@@ -282,8 +379,8 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
282
379
  return;
283
380
  if (this.excludeLibraries.some(e => typeof e === 'string' ? e === lib : e.test(lib)))
284
381
  return;
382
+ const { outputRoot, chorePackagePrefix } = this.ctx.runOpts.config;
285
383
  if (sync) {
286
- const { outputRoot } = this.ctx.runOpts.config;
287
384
  const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES);
288
385
  // FIXME 不支持 alias 配置
289
386
  const libName = lib;
@@ -312,6 +409,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
312
409
  basedir,
313
410
  extensions: this.extensions,
314
411
  mainFields: [...helper.defaultMainFields],
412
+ preserveSymlinks: false,
315
413
  });
316
414
  if (!typePath) {
317
415
  typeName = path__namespace.join(path__namespace.dirname(lib), `${basename}.d.ts`);
@@ -319,6 +417,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
319
417
  basedir,
320
418
  extensions: this.extensions,
321
419
  mainFields: [...helper.defaultMainFields],
420
+ preserveSymlinks: false,
322
421
  });
323
422
  }
324
423
  if (typePath) {
@@ -329,9 +428,10 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
329
428
  }
330
429
  if (ext) {
331
430
  const code = helper.fs.readFileSync(lib, { encoding: 'utf8' });
332
- if ((/(?:import\s|from\s|require\()['"]([\\/.][^'"\s]+)['"]\)?/g.test(code)
333
- || /\/{3}\s<reference\spath=['"][^'"\s]+['"]\s\/>/g.test(code))
334
- && `${libName}${path__namespace.extname(libDir)}` !== libDir) {
431
+ if ((/(?:import\s|from\s|require\()['"]([\\/.][^'"\s]+)['"]\)?/g.test(code) ||
432
+ /\/{3}\s<reference\spath=['"][^'"\s]+['"]\s\/>/g.test(code)) &&
433
+ `${libName}${path__namespace.extname(libDir)}` !== libDir) {
434
+ // Note: 文件包含包内引用的依赖
335
435
  const pkgPath = path__namespace.relative(libName, libDir);
336
436
  if (new RegExp(`^index(${this.extensions.map(e => e.replace('.', '\\.')).join('|')})$`).test(pkgPath)) {
337
437
  // Note: 入口为 index 场景
@@ -345,7 +445,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
345
445
  else {
346
446
  // FIXME 多级目录,可能存在入口不为 index 或者引用一级目录文件的情况,需要额外处理
347
447
  const dir = path__namespace.dirname(pkgPath);
348
- target = path__namespace.join(target, dir);
448
+ if (libDir.includes(helper.NODE_MODULES)) {
449
+ target = path__namespace.join(target, dir);
450
+ }
349
451
  lib = path__namespace.dirname(lib);
350
452
  }
351
453
  }
@@ -356,8 +458,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
356
458
  ? path__namespace.join(path__namespace.dirname(target), `${basename}${ext}`)
357
459
  : path__namespace.join(target, `index${isDTS ? '.d.ts' : ext}`);
358
460
  }
359
- else if (libDir !== path__namespace.relative(targetPath, target)) {
360
- target = path__namespace.join(targetPath, libDir);
461
+ else {
462
+ const libPath = path__namespace.relative(targetPath, target);
463
+ if (libDir !== libPath) {
464
+ if (path__namespace.relative(libPath, libDir).startsWith('.')) {
465
+ target = path__namespace.join(targetPath, libDir);
466
+ }
467
+ else {
468
+ target = path__namespace.join(targetPath, libName, `index${ext}`);
469
+ }
470
+ }
361
471
  }
362
472
  }
363
473
  }
@@ -372,13 +482,17 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
372
482
  }
373
483
  else if (stat.isFile()) {
374
484
  let code = helper.fs.readFileSync(lib, { encoding: 'utf8' });
485
+ if (this.apiEntry.some(e => e.test(lib))) {
486
+ code = apiLoader(code);
487
+ }
375
488
  if (this.extensions.includes(path__namespace.extname(lib))) {
376
- code = code.replace(/(?:import\s|from\s|require\()['"]([^.][^'"\s]+)['"]\)?/g, (src, p1) => {
489
+ // Note: 查询 externals 内的依赖,并将它们添加到 externalDeps
490
+ code = code.replace(/(?:import\s|from\s|require\()['"]([^\\/.][^'"\s]+)['"]\)?/g, (src, p1) => {
377
491
  const { outputRoot } = this.ctx.runOpts.config;
378
492
  const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES, p1);
379
493
  const relativePath = parseRelativePath(path__namespace.dirname(target), targetPath);
380
- if (HARMONY_SCOPES.every(e => !e.test(p1))) {
381
- if (this.indexOfLibraries(p1) === -1) {
494
+ if (this.harmonyScope.every(e => !e.test(p1))) {
495
+ if (this.indexOfLibraries(p1) === -1 && !/\.(d\.ts|flow\.js)$/.test(lib)) {
382
496
  this.externalDeps.push([p1, new RegExp(`^${p1.replace(/([-\\/$])/g, '\\$1')}$`)]);
383
497
  this.moveLibraries(p1, targetPath, path__namespace.dirname(lib), true);
384
498
  }
@@ -386,18 +500,29 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
386
500
  }
387
501
  return src;
388
502
  });
389
- const define = Object.assign({}, this.defineConstants);
503
+ const define = Object.assign(Object.assign({}, this.defineConstants), {
504
+ // Note: React 开发环境可能调用 stack 可能导致 appWrapper 实例变更
505
+ 'ReactDebugCurrentFrame.getCurrentStack': 'ReactDebugCurrentFrame.getCurrentStack$' });
390
506
  if ([/(@tarojs[\\/]runtime|taro-runtime)[\\/]dist/].some(e => e.test(lib))) {
391
507
  define.global = 'globalThis';
392
508
  }
393
- code = this.replaceDefineValue(code, define);
394
509
  const ext = path__namespace.extname(target);
510
+ if (![/d\.e?tsx?$/, /\.(json|map|md)$/].some(e => e.test(target))) {
511
+ code = this.replaceDefineValue(code, define, ext);
512
+ }
395
513
  if (['.ts'].includes(ext)) {
396
514
  code = '// @ts-nocheck\n' + code;
397
515
  }
516
+ // 处理嵌套样式的编译,需要针对ReactElement进行props操作,dev模式下会Object.freeze,所以需要在开发模式下注入Object.freeze来覆盖解锁
517
+ // 处理的方法再taro-platform-harmony/src/runtime-ets/dom/cssNesting: ele.props.style = declaration
518
+ if (/react\/jsx-runtime/.test(lib) && process.env.NODE_ENV === 'development') {
519
+ code = 'Object.freeze = (obj) => obj \n' + code;
520
+ }
398
521
  }
399
- if (/tarojs[\\/]taro[\\/]types[\\/]index.d.ts/.test(target)) {
400
- code = `/// <reference path="global.d.ts" />
522
+ // Note: 传入 chorePackagePrefix 时,不生成核心依赖库
523
+ if (!chorePackagePrefix) {
524
+ if (/tarojs[\\/]taro[\\/]types[\\/]index.d.ts/.test(target)) {
525
+ code = `/// <reference path="global.d.ts" />
401
526
 
402
527
  /// <reference path="taro.api.d.ts" />
403
528
  /// <reference path="taro.component.d.ts" />
@@ -417,14 +542,15 @@ declare global {
417
542
  const defineAppConfig: (config: Taro.Config) => Taro.Config
418
543
  const definePageConfig: (config: Taro.Config) => Taro.Config
419
544
  }`;
420
- }
421
- try {
422
- const targetPath = target.replace(new RegExp(`\\b${helper.NODE_MODULES}\\b`), 'npm');
423
- helper.fs.ensureDirSync(path__namespace.dirname(targetPath));
424
- helper.fs.writeFileSync(targetPath, code);
425
- }
426
- catch (e) {
427
- console.error(`[taro-arkts] inject ${lib} to ${target} failed`, e);
545
+ }
546
+ try {
547
+ const targetPath = target.replace(new RegExp(`\\b${helper.NODE_MODULES}\\b`), 'npm');
548
+ helper.fs.ensureDirSync(path__namespace.dirname(targetPath));
549
+ helper.fs.writeFileSync(targetPath, code);
550
+ }
551
+ catch (e) {
552
+ console.error(`[taro-arkts] inject ${lib} to ${target} failed`, e);
553
+ }
428
554
  }
429
555
  }
430
556
  else if (stat.isSymbolicLink()) {
@@ -432,9 +558,13 @@ declare global {
432
558
  this.moveLibraries(realPath, target, basedir);
433
559
  }
434
560
  }
435
- replaceDefineValue(code, define) {
561
+ replaceDefineValue(code, define, ext = '.js') {
436
562
  Object.keys(define).forEach(key => {
437
- code = code.replace(new RegExp(`\\b${key}\\b`, 'g'), define[key]);
563
+ let value = define[key];
564
+ if (/^['"`].*['"`]$/.test(value) && ['.ts', '.tsx', '.ets'].includes(ext)) {
565
+ value = `(${value} as string)`;
566
+ }
567
+ code = code.replace(new RegExp(`\\b${key}\\b`, 'g'), value);
438
568
  });
439
569
  return code;
440
570
  }
@@ -446,15 +576,15 @@ declare global {
446
576
  const that = this;
447
577
  const { appPath } = that.ctx.paths;
448
578
  const { config } = that.ctx.runOpts;
449
- const { outputRoot } = config;
579
+ const { outputRoot, ohPackage = {}, chorePackagePrefix } = config;
450
580
  if (!that.framework.includes('vue')) {
451
581
  that.excludeLibraries.push(/\bvue\b/);
452
582
  }
453
583
  // @ts-ignore
454
584
  if (that.framework === 'solid') {
455
585
  that.externalDeps.push([
456
- '@tarojs/plugin-framework-react/dist/runtime/reconciler',
457
- /^@tarojs\/plugin-framework-react\/dist\/runtime\/reconciler$/,
586
+ '@tarojs/plugin-framework-react/dist/reconciler',
587
+ /^@tarojs\/plugin-framework-react\/dist\/reconciler$/,
458
588
  path__namespace.join(this.runtimeFrameworkLibrary, 'reconciler')
459
589
  ]);
460
590
  that.externalDeps.push([
@@ -462,11 +592,29 @@ declare global {
462
592
  /^solid-js\/universal$/,
463
593
  ]);
464
594
  }
465
- function modifyResolveId({ source = '', importer = '', options = {}, name = 'modifyResolveId', resolve }) {
466
- if (shared.isFunction(resolve)) {
467
- if (source === that.runtimePath || that.runtimePath.includes(source)) {
468
- return resolve('@tarojs/runtime', importer, options);
469
- }
595
+ const externals = Object.keys(ohPackage.dependencies || []).concat(Object.keys(ohPackage.devDependencies || []));
596
+ function modifyResolveId({ source = '', name = 'modifyResolveId' }) {
597
+ if (externals.includes(source)) {
598
+ return {
599
+ external: true,
600
+ id: source,
601
+ resolvedBy: name,
602
+ };
603
+ }
604
+ else if (source.includes('css_variables')) {
605
+ return {
606
+ external: true,
607
+ id: path__namespace.join(outputRoot, 'css_variables'),
608
+ moduleSideEffects: 'no-treeshake',
609
+ resolvedBy: name,
610
+ };
611
+ }
612
+ if (chorePackagePrefix && that.indexOfLibraries(source) > -1) {
613
+ return {
614
+ external: true,
615
+ id: path__namespace.join(chorePackagePrefix, source),
616
+ resolvedBy: name,
617
+ };
470
618
  }
471
619
  // Note: 映射 Taro 相关依赖到注入 taro 目录
472
620
  if (that.indexOfLibraries(source) > -1) {
@@ -497,19 +645,18 @@ declare global {
497
645
  }
498
646
  function injectLoaderMeta() {
499
647
  return {
500
- name: 'taro:vite-h5-loader-meta',
648
+ name: 'taro:vite-loader-meta',
501
649
  buildStart() {
502
650
  return __awaiter(this, void 0, void 0, function* () {
503
- yield this.load({ id: runnerUtils.VITE_COMPILER_LABEL });
504
- const info = this.getModuleInfo(runnerUtils.VITE_COMPILER_LABEL);
505
- const compiler = info === null || info === void 0 ? void 0 : info.meta.viteCompilerContext;
651
+ const { getViteHarmonyCompilerContext } = that.ctx.runnerUtils;
652
+ const compiler = getViteHarmonyCompilerContext(this);
506
653
  if (compiler) {
507
654
  switch (that.framework) {
508
655
  // @ts-ignore
509
656
  case 'solid':
510
657
  compiler.loaderMeta || (compiler.loaderMeta = {});
511
658
  compiler.loaderMeta.importFrameworkStatement = ``;
512
- compiler.mockAppStatement = `
659
+ compiler.loaderMeta.mockAppStatement = `
513
660
  function App(props) {
514
661
  return null
515
662
  }
@@ -533,6 +680,27 @@ function App(props) {
533
680
  viteConfig.plugins.push(externalPlugin(), injectLoaderMeta());
534
681
  });
535
682
  }
683
+ handleResourceEmit(outDir, basedir = this.ctx.paths.appPath) {
684
+ const resources = path__namespace.resolve(outDir, '..', 'resources');
685
+ const mediaPath = 'static/media';
686
+ const mediaSource = helper.resolveSync(`${PACKAGE_NAME}/${mediaPath}`, {
687
+ basedir,
688
+ extensions: this.extensions,
689
+ mainFields: [...helper.defaultMainFields],
690
+ preserveSymlinks: false,
691
+ isFile: (file) => {
692
+ try {
693
+ const stat = helper.fs.lstatSync(file);
694
+ return stat.isFile() || (file.endsWith(mediaPath.replace('/', path__namespace.sep)) && stat.isDirectory());
695
+ }
696
+ catch (_) { } // eslint-disable-line no-empty
697
+ return false;
698
+ }
699
+ });
700
+ if (mediaSource) {
701
+ this.moveLibraries(mediaSource, path__namespace.join(resources, 'base/media'), basedir);
702
+ }
703
+ }
536
704
  };
537
705
  _Harmony_defineConstants = new WeakMap();
538
706
 
@@ -884,7 +1052,7 @@ class Harmony extends service.TaroPlatformBase {
884
1052
  * 等鸿蒙支持 template 后需要重构
885
1053
  */
886
1054
  addEntry() {
887
- this.ctx.onCompilerMake(({ compilation, plugin }) => __awaiter(this, void 0, void 0, function* () {
1055
+ this.ctx.onCompilerMake((_a) => __awaiter(this, [_a], void 0, function* ({ compilation, plugin }) {
888
1056
  // container/index.hml
889
1057
  const filePath = path.resolve(__dirname, 'template/container');
890
1058
  plugin.addEntry(filePath, 'container/index', helper.META_TYPE.STATIC);
@@ -1024,7 +1192,7 @@ class Harmony extends service.TaroPlatformBase {
1024
1192
  const outDir = path.join(compsOutDir, name);
1025
1193
  helper.fs.copy(src, outDir);
1026
1194
  });
1027
- this.modifyHostPackageDep(outDir);
1195
+ this.modifyHostPackage(config.harmony);
1028
1196
  });
1029
1197
  }
1030
1198
  modifyWebpackConfig() {
@@ -1087,13 +1255,13 @@ class Harmony extends service.TaroPlatformBase {
1087
1255
  console.warn(helper.chalk.red('设置鸿蒙 Hap 配置失败:', err));
1088
1256
  });
1089
1257
  }
1090
- modifyHostPackageDep(dest) {
1091
- return __awaiter(this, void 0, void 0, function* () {
1258
+ modifyHostPackage(_a) {
1259
+ return __awaiter(this, arguments, void 0, function* ({ projectPath, hapName = 'entry' }) {
1260
+ const packageJsonFile = path.join(projectPath, hapName, 'package.json');
1092
1261
  const hmsDeps = {
1093
1262
  '@hmscore/hms-js-base': '^6.1.0-300',
1094
1263
  '@hmscore/hms-jsb-account': '^1.0.300'
1095
1264
  };
1096
- const packageJsonFile = path.resolve(dest, '../../../../../package.json');
1097
1265
  const isExists = yield helper.fs.pathExists(packageJsonFile);
1098
1266
  if (!isExists)
1099
1267
  return;
@@ -1110,9 +1278,10 @@ class Harmony extends service.TaroPlatformBase {
1110
1278
  }
1111
1279
  packageJson = JSON.stringify(packageJson);
1112
1280
  yield helper.fs.writeFile(packageJsonFile, packageJson);
1281
+ return packageJson;
1113
1282
  });
1114
1283
  }
1115
- getChunkEntryModule(compilation, chunk, compiler = 'webpack4') {
1284
+ getChunkEntryModule(compilation, chunk, compiler = 'webpack5') {
1116
1285
  if (compiler === 'webpack5') {
1117
1286
  const chunkGraph = compilation.chunkGraph;
1118
1287
  const entryModules = Array.from(chunkGraph.getChunkEntryModulesIterable(chunk));
@@ -1153,8 +1322,8 @@ var index = (ctx, options = {}) => {
1153
1322
  ctx.registerPlatform({
1154
1323
  name: PLATFORM_NAME,
1155
1324
  useConfigName: options.useConfigName || PLATFORM_NAME,
1156
- fn({ config }) {
1157
- return __awaiter(this, void 0, void 0, function* () {
1325
+ fn(_a) {
1326
+ return __awaiter(this, arguments, void 0, function* ({ config }) {
1158
1327
  const program = new Harmony$2(ctx, config);
1159
1328
  yield program.start();
1160
1329
  });
@@ -1178,6 +1347,7 @@ function assertHarmonyConfig(ctx, config) {
1178
1347
  }
1179
1348
  }
1180
1349
 
1350
+ exports.HarmonyOS_ArkTS = Harmony$1;
1181
1351
  exports.HarmonyOS_JSUI = Harmony;
1182
1352
  exports.default = index;
1183
1353
  //# sourceMappingURL=index.js.map