@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/base/system.ts +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +16 -8
- package/dist/apis/device/memory.ts +10 -3
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/media/image/index.ts +1 -1
- package/dist/apis/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +146 -78
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +42 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +5 -5
- package/dist/apis/ui/tab-bar.ts +3 -3
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +68 -68
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +81 -102
- package/dist/components-harmony-ets/form.ets +54 -45
- package/dist/components-harmony-ets/icon.ets +34 -50
- package/dist/components-harmony-ets/image.ets +35 -45
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +51 -67
- package/dist/components-harmony-ets/label.ets +73 -53
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +124 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +74 -77
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +82 -104
- package/dist/components-harmony-ets/richText.ets +20 -68
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +67 -103
- package/dist/components-harmony-ets/slider.ets +23 -47
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +396 -0
- package/dist/components-harmony-ets/swiper.ets +64 -53
- package/dist/components-harmony-ets/switch.ets +44 -55
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +134 -75
- package/dist/components-harmony-ets/textArea.ets +54 -62
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
- package/dist/components-harmony-ets/utils/flexManager.ets +76 -8
- package/dist/components-harmony-ets/utils/helper.ets +20 -7
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +178 -63
- package/dist/components-harmony-ets/video.ets +37 -54
- package/dist/components-harmony-ets/view.ets +63 -94
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +199 -58
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +29 -19
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +334 -57
- package/dist/runtime-ets/dom/element/form.ts +32 -26
- package/dist/runtime-ets/dom/element/index.ts +33 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +242 -0
- package/dist/runtime-ets/dom/element/normal.ts +36 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -4
- package/dist/runtime-ets/dom/element/webView.ts +68 -0
- package/dist/runtime-ets/dom/event.ts +2 -4
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +62 -27
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +98 -518
- package/dist/runtime-ets/dom/stylesheet/type.ts +92 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +74 -16
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +77 -12
- package/dist/runtime-ets/utils/info.ts +4 -2
- package/dist/runtime-framework/react/app.ts +17 -22
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +1 -2
- package/dist/runtime-framework/react/native-page.ts +421 -0
- package/dist/runtime-framework/react/page.ts +4 -9
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -30
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +510 -237
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +510 -237
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +3 -1
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /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,6 +67,91 @@ 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';
|
|
@@ -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(
|
|
172
|
-
|
|
173
|
-
|
|
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(
|
|
179
|
-
return __awaiter(this,
|
|
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 = [];
|
|
@@ -231,14 +319,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
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
|
-
|
|
326
|
+
that.modifyViteConfig();
|
|
237
327
|
},
|
|
238
328
|
});
|
|
239
329
|
ctx.onBuildFinish(() => {
|
|
240
330
|
const outDir = path__namespace.resolve(process.cwd(), config.outputRoot);
|
|
241
|
-
|
|
331
|
+
that.handleResourceEmit(outDir);
|
|
242
332
|
});
|
|
243
333
|
}
|
|
244
334
|
get framework() {
|
|
@@ -250,6 +340,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
250
340
|
get apiLibrary() {
|
|
251
341
|
return path__namespace.resolve(__dirname, './apis');
|
|
252
342
|
}
|
|
343
|
+
get apiEntry() {
|
|
344
|
+
return this.apiEntryList;
|
|
345
|
+
}
|
|
253
346
|
get componentLibrary() {
|
|
254
347
|
return path__namespace.resolve(__dirname, './components-harmony-ets');
|
|
255
348
|
}
|
|
@@ -286,8 +379,8 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
286
379
|
return;
|
|
287
380
|
if (this.excludeLibraries.some(e => typeof e === 'string' ? e === lib : e.test(lib)))
|
|
288
381
|
return;
|
|
382
|
+
const { outputRoot, chorePackagePrefix } = this.ctx.runOpts.config;
|
|
289
383
|
if (sync) {
|
|
290
|
-
const { outputRoot } = this.ctx.runOpts.config;
|
|
291
384
|
const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES);
|
|
292
385
|
// FIXME 不支持 alias 配置
|
|
293
386
|
const libName = lib;
|
|
@@ -335,9 +428,10 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
335
428
|
}
|
|
336
429
|
if (ext) {
|
|
337
430
|
const code = helper.fs.readFileSync(lib, { encoding: 'utf8' });
|
|
338
|
-
if ((/(?:import\s|from\s|require\()['"]([\\/.][^'"\s]+)['"]\)?/g.test(code)
|
|
339
|
-
|
|
340
|
-
|
|
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: 文件包含包内引用的依赖
|
|
341
435
|
const pkgPath = path__namespace.relative(libName, libDir);
|
|
342
436
|
if (new RegExp(`^index(${this.extensions.map(e => e.replace('.', '\\.')).join('|')})$`).test(pkgPath)) {
|
|
343
437
|
// Note: 入口为 index 场景
|
|
@@ -364,8 +458,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
364
458
|
? path__namespace.join(path__namespace.dirname(target), `${basename}${ext}`)
|
|
365
459
|
: path__namespace.join(target, `index${isDTS ? '.d.ts' : ext}`);
|
|
366
460
|
}
|
|
367
|
-
else
|
|
368
|
-
|
|
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
|
+
}
|
|
369
471
|
}
|
|
370
472
|
}
|
|
371
473
|
}
|
|
@@ -380,12 +482,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
380
482
|
}
|
|
381
483
|
else if (stat.isFile()) {
|
|
382
484
|
let code = helper.fs.readFileSync(lib, { encoding: 'utf8' });
|
|
485
|
+
if (this.apiEntry.some(e => e.test(lib))) {
|
|
486
|
+
code = apiLoader(code);
|
|
487
|
+
}
|
|
383
488
|
if (this.extensions.includes(path__namespace.extname(lib))) {
|
|
384
|
-
|
|
489
|
+
// Note: 查询 externals 内的依赖,并将它们添加到 externalDeps 中
|
|
490
|
+
code = code.replace(/(?:import\s|from\s|require\()['"]([^\\/.][^'"\s]+)['"]\)?/g, (src, p1) => {
|
|
385
491
|
const { outputRoot } = this.ctx.runOpts.config;
|
|
386
492
|
const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES, p1);
|
|
387
493
|
const relativePath = parseRelativePath(path__namespace.dirname(target), targetPath);
|
|
388
|
-
if (
|
|
494
|
+
if (this.harmonyScope.every(e => !e.test(p1))) {
|
|
389
495
|
if (this.indexOfLibraries(p1) === -1 && !/\.(d\.ts|flow\.js)$/.test(lib)) {
|
|
390
496
|
this.externalDeps.push([p1, new RegExp(`^${p1.replace(/([-\\/$])/g, '\\$1')}$`)]);
|
|
391
497
|
this.moveLibraries(p1, targetPath, path__namespace.dirname(lib), true);
|
|
@@ -394,18 +500,29 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
394
500
|
}
|
|
395
501
|
return src;
|
|
396
502
|
});
|
|
397
|
-
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$' });
|
|
398
506
|
if ([/(@tarojs[\\/]runtime|taro-runtime)[\\/]dist/].some(e => e.test(lib))) {
|
|
399
507
|
define.global = 'globalThis';
|
|
400
508
|
}
|
|
401
|
-
code = this.replaceDefineValue(code, define);
|
|
402
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
|
+
}
|
|
403
513
|
if (['.ts'].includes(ext)) {
|
|
404
514
|
code = '// @ts-nocheck\n' + code;
|
|
405
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
|
+
}
|
|
406
521
|
}
|
|
407
|
-
|
|
408
|
-
|
|
522
|
+
// Note: 传入 chorePackagePrefix 时,不生成核心依赖库
|
|
523
|
+
if (!chorePackagePrefix) {
|
|
524
|
+
if (/tarojs[\\/]taro[\\/]types[\\/]index.d.ts/.test(target)) {
|
|
525
|
+
code = `/// <reference path="global.d.ts" />
|
|
409
526
|
|
|
410
527
|
/// <reference path="taro.api.d.ts" />
|
|
411
528
|
/// <reference path="taro.component.d.ts" />
|
|
@@ -425,14 +542,15 @@ declare global {
|
|
|
425
542
|
const defineAppConfig: (config: Taro.Config) => Taro.Config
|
|
426
543
|
const definePageConfig: (config: Taro.Config) => Taro.Config
|
|
427
544
|
}`;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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
|
+
}
|
|
436
554
|
}
|
|
437
555
|
}
|
|
438
556
|
else if (stat.isSymbolicLink()) {
|
|
@@ -440,9 +558,13 @@ declare global {
|
|
|
440
558
|
this.moveLibraries(realPath, target, basedir);
|
|
441
559
|
}
|
|
442
560
|
}
|
|
443
|
-
replaceDefineValue(code, define) {
|
|
561
|
+
replaceDefineValue(code, define, ext = '.js') {
|
|
444
562
|
Object.keys(define).forEach(key => {
|
|
445
|
-
|
|
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);
|
|
446
568
|
});
|
|
447
569
|
return code;
|
|
448
570
|
}
|
|
@@ -454,15 +576,15 @@ declare global {
|
|
|
454
576
|
const that = this;
|
|
455
577
|
const { appPath } = that.ctx.paths;
|
|
456
578
|
const { config } = that.ctx.runOpts;
|
|
457
|
-
const { outputRoot } = config;
|
|
579
|
+
const { outputRoot, ohPackage = {}, chorePackagePrefix } = config;
|
|
458
580
|
if (!that.framework.includes('vue')) {
|
|
459
581
|
that.excludeLibraries.push(/\bvue\b/);
|
|
460
582
|
}
|
|
461
583
|
// @ts-ignore
|
|
462
584
|
if (that.framework === 'solid') {
|
|
463
585
|
that.externalDeps.push([
|
|
464
|
-
'@tarojs/plugin-framework-react/dist/
|
|
465
|
-
/^@tarojs\/plugin-framework-react\/dist\/
|
|
586
|
+
'@tarojs/plugin-framework-react/dist/reconciler',
|
|
587
|
+
/^@tarojs\/plugin-framework-react\/dist\/reconciler$/,
|
|
466
588
|
path__namespace.join(this.runtimeFrameworkLibrary, 'reconciler')
|
|
467
589
|
]);
|
|
468
590
|
that.externalDeps.push([
|
|
@@ -470,11 +592,29 @@ declare global {
|
|
|
470
592
|
/^solid-js\/universal$/,
|
|
471
593
|
]);
|
|
472
594
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
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
|
+
};
|
|
478
618
|
}
|
|
479
619
|
// Note: 映射 Taro 相关依赖到注入 taro 目录
|
|
480
620
|
if (that.indexOfLibraries(source) > -1) {
|
|
@@ -505,19 +645,18 @@ declare global {
|
|
|
505
645
|
}
|
|
506
646
|
function injectLoaderMeta() {
|
|
507
647
|
return {
|
|
508
|
-
name: 'taro:vite-
|
|
648
|
+
name: 'taro:vite-loader-meta',
|
|
509
649
|
buildStart() {
|
|
510
650
|
return __awaiter(this, void 0, void 0, function* () {
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
const compiler = info === null || info === void 0 ? void 0 : info.meta.viteCompilerContext;
|
|
651
|
+
const { getViteHarmonyCompilerContext } = that.ctx.runnerUtils;
|
|
652
|
+
const compiler = getViteHarmonyCompilerContext(this);
|
|
514
653
|
if (compiler) {
|
|
515
654
|
switch (that.framework) {
|
|
516
655
|
// @ts-ignore
|
|
517
656
|
case 'solid':
|
|
518
657
|
compiler.loaderMeta || (compiler.loaderMeta = {});
|
|
519
658
|
compiler.loaderMeta.importFrameworkStatement = ``;
|
|
520
|
-
compiler.mockAppStatement = `
|
|
659
|
+
compiler.loaderMeta.mockAppStatement = `
|
|
521
660
|
function App(props) {
|
|
522
661
|
return null
|
|
523
662
|
}
|
|
@@ -552,7 +691,7 @@ function App(props) {
|
|
|
552
691
|
isFile: (file) => {
|
|
553
692
|
try {
|
|
554
693
|
const stat = helper.fs.lstatSync(file);
|
|
555
|
-
return stat.isFile() || (file.endsWith(mediaPath) && stat.isDirectory());
|
|
694
|
+
return stat.isFile() || (file.endsWith(mediaPath.replace('/', path__namespace.sep)) && stat.isDirectory());
|
|
556
695
|
}
|
|
557
696
|
catch (_) { } // eslint-disable-line no-empty
|
|
558
697
|
return false;
|
|
@@ -913,7 +1052,7 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
913
1052
|
* 等鸿蒙支持 template 后需要重构
|
|
914
1053
|
*/
|
|
915
1054
|
addEntry() {
|
|
916
|
-
this.ctx.onCompilerMake((
|
|
1055
|
+
this.ctx.onCompilerMake((_a) => __awaiter(this, [_a], void 0, function* ({ compilation, plugin }) {
|
|
917
1056
|
// container/index.hml
|
|
918
1057
|
const filePath = path.resolve(__dirname, 'template/container');
|
|
919
1058
|
plugin.addEntry(filePath, 'container/index', helper.META_TYPE.STATIC);
|
|
@@ -1053,7 +1192,7 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1053
1192
|
const outDir = path.join(compsOutDir, name);
|
|
1054
1193
|
helper.fs.copy(src, outDir);
|
|
1055
1194
|
});
|
|
1056
|
-
this.
|
|
1195
|
+
this.modifyHostPackage(config.harmony);
|
|
1057
1196
|
});
|
|
1058
1197
|
}
|
|
1059
1198
|
modifyWebpackConfig() {
|
|
@@ -1116,13 +1255,13 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1116
1255
|
console.warn(helper.chalk.red('设置鸿蒙 Hap 配置失败:', err));
|
|
1117
1256
|
});
|
|
1118
1257
|
}
|
|
1119
|
-
|
|
1120
|
-
return __awaiter(this,
|
|
1258
|
+
modifyHostPackage(_a) {
|
|
1259
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, hapName = 'entry' }) {
|
|
1260
|
+
const packageJsonFile = path.join(projectPath, hapName, 'package.json');
|
|
1121
1261
|
const hmsDeps = {
|
|
1122
1262
|
'@hmscore/hms-js-base': '^6.1.0-300',
|
|
1123
1263
|
'@hmscore/hms-jsb-account': '^1.0.300'
|
|
1124
1264
|
};
|
|
1125
|
-
const packageJsonFile = path.resolve(dest, '../../../../../package.json');
|
|
1126
1265
|
const isExists = yield helper.fs.pathExists(packageJsonFile);
|
|
1127
1266
|
if (!isExists)
|
|
1128
1267
|
return;
|
|
@@ -1139,9 +1278,10 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1139
1278
|
}
|
|
1140
1279
|
packageJson = JSON.stringify(packageJson);
|
|
1141
1280
|
yield helper.fs.writeFile(packageJsonFile, packageJson);
|
|
1281
|
+
return packageJson;
|
|
1142
1282
|
});
|
|
1143
1283
|
}
|
|
1144
|
-
getChunkEntryModule(compilation, chunk, compiler = '
|
|
1284
|
+
getChunkEntryModule(compilation, chunk, compiler = 'webpack5') {
|
|
1145
1285
|
if (compiler === 'webpack5') {
|
|
1146
1286
|
const chunkGraph = compilation.chunkGraph;
|
|
1147
1287
|
const entryModules = Array.from(chunkGraph.getChunkEntryModulesIterable(chunk));
|
|
@@ -1182,8 +1322,8 @@ var index = (ctx, options = {}) => {
|
|
|
1182
1322
|
ctx.registerPlatform({
|
|
1183
1323
|
name: PLATFORM_NAME,
|
|
1184
1324
|
useConfigName: options.useConfigName || PLATFORM_NAME,
|
|
1185
|
-
fn(
|
|
1186
|
-
return __awaiter(this,
|
|
1325
|
+
fn(_a) {
|
|
1326
|
+
return __awaiter(this, arguments, void 0, function* ({ config }) {
|
|
1187
1327
|
const program = new Harmony$2(ctx, config);
|
|
1188
1328
|
yield program.start();
|
|
1189
1329
|
});
|
|
@@ -1207,6 +1347,7 @@ function assertHarmonyConfig(ctx, config) {
|
|
|
1207
1347
|
}
|
|
1208
1348
|
}
|
|
1209
1349
|
|
|
1350
|
+
exports.HarmonyOS_ArkTS = Harmony$1;
|
|
1210
1351
|
exports.HarmonyOS_JSUI = Harmony;
|
|
1211
1352
|
exports.default = index;
|
|
1212
1353
|
//# sourceMappingURL=index.js.map
|