@tarojs/plugin-platform-harmony-ets 4.0.0-beta.70 → 4.0.0-beta.71
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/device/clipboard.ts +15 -15
- package/dist/components-harmony-ets/utils/flexManager.ets +3 -1
- package/dist/runtime-ets/dom/node.ts +1 -1
- package/dist/runtime-framework/react/native-page.ts +121 -63
- package/dist/runtime-utils.js +16 -15
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +16 -15
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
|
@@ -28,9 +28,20 @@ export const setClipboardData: typeof Taro.setClipboardData = function (options)
|
|
|
28
28
|
|
|
29
29
|
return new Promise((resolve, reject) => {
|
|
30
30
|
const systemPasteboard = pasteboard.getSystemPasteboard()
|
|
31
|
-
const pasteData = pasteboard.
|
|
31
|
+
const pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, data)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
try {
|
|
34
|
+
systemPasteboard.setDataSync(pasteData)
|
|
35
|
+
promptAction.showToast({
|
|
36
|
+
message: '内容已复制',
|
|
37
|
+
duration: 1500,
|
|
38
|
+
bottom: '50%',
|
|
39
|
+
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
40
|
+
})
|
|
41
|
+
return handle.success({
|
|
42
|
+
data,
|
|
43
|
+
}, { resolve, reject })
|
|
44
|
+
} catch (error) {
|
|
34
45
|
if (error) {
|
|
35
46
|
console.error('Failed to set PasteData. Cause: ' + JSON.stringify(error))
|
|
36
47
|
res = {
|
|
@@ -38,19 +49,8 @@ export const setClipboardData: typeof Taro.setClipboardData = function (options)
|
|
|
38
49
|
error: error
|
|
39
50
|
}
|
|
40
51
|
callAsyncFail(reject, res, options)
|
|
41
|
-
} else {
|
|
42
|
-
promptAction.showToast({
|
|
43
|
-
message: '内容已复制',
|
|
44
|
-
duration: 1500,
|
|
45
|
-
bottom: '50%',
|
|
46
|
-
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
return handle.success({
|
|
50
|
-
data,
|
|
51
|
-
}, { resolve, reject })
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|
|
54
54
|
})
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -62,7 +62,7 @@ export const getClipboardData: typeof Taro.getClipboardData = function (options)
|
|
|
62
62
|
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete })
|
|
63
63
|
return new Promise((resolve, reject) => {
|
|
64
64
|
const systemPasteboard = pasteboard.getSystemPasteboard()
|
|
65
|
-
systemPasteboard.
|
|
65
|
+
systemPasteboard.getData((error, pasteData) => { // callback 形式调用异步接口
|
|
66
66
|
if (error) {
|
|
67
67
|
console.error('Failed to obtain PasteData. Cause: ' + JSON.stringify(error))
|
|
68
68
|
return handle.fail({
|
|
@@ -39,7 +39,9 @@ class FlexManager {
|
|
|
39
39
|
|
|
40
40
|
static useFlexLayout (node: TaroElement): boolean {
|
|
41
41
|
const hmStyle: HarmonyStyle = getNormalAttributes(node) || {}
|
|
42
|
-
|
|
42
|
+
const isReverse = hmStyle.flexDirection && [FlexDirection.RowReverse, FlexDirection.ColumnReverse].indexOf(hmStyle.flexDirection) !== -1;
|
|
43
|
+
const isUnknownAlign = [ItemAlign.Stretch, ItemAlign.Baseline].indexOf(hmStyle.alignItems!) !== -1;
|
|
44
|
+
return !isUndefined(hmStyle.flexWrap) || isReverse || isUnknownAlign;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
static flexOptions (node: TaroElement): IFlexOptions {
|
|
@@ -273,7 +273,7 @@ function checkIsCompileModeAndInstallAfterDOMAction (node: TaroNode, parentNode:
|
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
function checkIsCompileModeAndUninstallAfterDOMAction (node: TaroNode) {
|
|
276
|
-
if (!node._isCompileMode || !
|
|
276
|
+
if (!node._isCompileMode || !node?._instance) return
|
|
277
277
|
|
|
278
278
|
node._instance.dynamicCenter?.uninstall?.(node)
|
|
279
279
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getPath,
|
|
13
13
|
injectPageInstance,
|
|
14
14
|
removePageInstance,
|
|
15
|
-
safeExecute
|
|
15
|
+
safeExecute,
|
|
16
16
|
} from './page'
|
|
17
17
|
import { EMPTY_OBJ, incrementId, isClassComponent } from './utils'
|
|
18
18
|
|
|
@@ -65,22 +65,20 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
render () {
|
|
68
|
-
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.props.renderComponent(this.ctx)
|
|
76
|
-
)
|
|
68
|
+
return h(
|
|
69
|
+
'view',
|
|
70
|
+
{
|
|
71
|
+
ref: this.root,
|
|
72
|
+
id: this.props.compId,
|
|
73
|
+
},
|
|
74
|
+
this.props.renderComponent(this.ctx)
|
|
77
75
|
)
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
class Entry extends R.Component<Record<any, any>, IEntryState> {
|
|
82
80
|
state: IEntryState = {
|
|
83
|
-
components: []
|
|
81
|
+
components: [],
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
componentDidMount () {
|
|
@@ -106,10 +104,12 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
|
|
|
106
104
|
mount (Component, compId, getCtx, cb?) {
|
|
107
105
|
const isReactComponent = isClassComponent(R, Component)
|
|
108
106
|
const inject = (node?: any) => node && injectPageInstance(node, compId)
|
|
109
|
-
const refs = isReactComponent
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
const refs = isReactComponent
|
|
108
|
+
? { ref: inject }
|
|
109
|
+
: {
|
|
110
|
+
forwardedRef: inject,
|
|
111
|
+
reactReduxForwardedRef: inject,
|
|
112
|
+
}
|
|
113
113
|
if (reactMeta.PageContext === EMPTY_OBJ) {
|
|
114
114
|
reactMeta.PageContext = R.createContext('')
|
|
115
115
|
}
|
|
@@ -123,42 +123,43 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
|
|
|
123
123
|
return h(
|
|
124
124
|
reactMeta.PageContext.Provider,
|
|
125
125
|
{ value: compId },
|
|
126
|
-
h(
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
$scope: ctx
|
|
133
|
-
}
|
|
134
|
-
)
|
|
126
|
+
h(Component, {
|
|
127
|
+
// TODO: 传递 Props
|
|
128
|
+
...(ctx.props || {}),
|
|
129
|
+
...refs,
|
|
130
|
+
$scope: ctx,
|
|
131
|
+
})
|
|
135
132
|
)
|
|
136
|
-
}
|
|
137
|
-
})
|
|
133
|
+
},
|
|
134
|
+
}),
|
|
138
135
|
}
|
|
139
|
-
this.setState(
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
this.setState(
|
|
137
|
+
{
|
|
138
|
+
components: [...this.state.components, item],
|
|
139
|
+
},
|
|
140
|
+
() => cb && cb()
|
|
141
|
+
)
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
unmount (compId, cb?) {
|
|
145
145
|
const components = this.state.components
|
|
146
|
-
const index = components.findIndex(item => item.compId === compId)
|
|
146
|
+
const index = components.findIndex((item) => item.compId === compId)
|
|
147
147
|
const next = [...components.slice(0, index), ...components.slice(index + 1)]
|
|
148
|
-
this.setState(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
this.setState(
|
|
149
|
+
{
|
|
150
|
+
components: next,
|
|
151
|
+
},
|
|
152
|
+
() => {
|
|
153
|
+
removePageInstance(compId)
|
|
154
|
+
cb && cb()
|
|
155
|
+
}
|
|
156
|
+
)
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
render () {
|
|
157
160
|
const components = this.state.components
|
|
158
161
|
|
|
159
|
-
return (
|
|
160
|
-
components.map(({ element }) => element)
|
|
161
|
-
)
|
|
162
|
+
return components.map(({ element }) => element)
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
|
|
@@ -173,26 +174,22 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
|
|
|
173
174
|
app = nativeApp
|
|
174
175
|
}
|
|
175
176
|
// eslint-disable-next-line react/no-deprecated
|
|
176
|
-
ReactDOM.render(
|
|
177
|
-
h(Entry, {}),
|
|
178
|
-
app
|
|
179
|
-
)
|
|
177
|
+
ReactDOM.render(h(Entry, {}), app)
|
|
180
178
|
}
|
|
181
179
|
|
|
182
|
-
export function createNativePageConfig (
|
|
180
|
+
export function createNativePageConfig (
|
|
181
|
+
Component,
|
|
182
|
+
pageName: string,
|
|
183
|
+
react: typeof React,
|
|
184
|
+
reactDOM: typeof ReactDOM,
|
|
185
|
+
pageConfig
|
|
186
|
+
) {
|
|
183
187
|
reactMeta.R = react
|
|
184
188
|
h = react.createElement
|
|
185
189
|
ReactDOM = reactDOM
|
|
186
190
|
setReconciler(ReactDOM)
|
|
187
|
-
const [
|
|
188
|
-
|
|
189
|
-
ONUNLOAD,
|
|
190
|
-
ONREADY,
|
|
191
|
-
ONSHOW,
|
|
192
|
-
ONHIDE,
|
|
193
|
-
LIFECYCLES,
|
|
194
|
-
SIDE_EFFECT_LIFECYCLES
|
|
195
|
-
] = hooks.call('getMiniLifecycleImpl')!.page
|
|
191
|
+
const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] =
|
|
192
|
+
hooks.call('getMiniLifecycleImpl')!.page
|
|
196
193
|
let unmounting = false
|
|
197
194
|
let prepareMountList: (() => void)[] = []
|
|
198
195
|
let pageElement: TaroElement | null = null
|
|
@@ -207,7 +204,7 @@ export function createNativePageConfig (Component, pageName: string, react: type
|
|
|
207
204
|
$taroPath: page.$taroPath,
|
|
208
205
|
onReady: getOnReadyEventKey(id),
|
|
209
206
|
onShow: getOnShowEventKey(id),
|
|
210
|
-
onHide: getOnHideEventKey(id)
|
|
207
|
+
onHide: getOnHideEventKey(id),
|
|
211
208
|
}
|
|
212
209
|
if (!isUndefined(page.exitState)) {
|
|
213
210
|
Current.router.exitState = page.exitState
|
|
@@ -217,12 +214,14 @@ export function createNativePageConfig (Component, pageName: string, react: type
|
|
|
217
214
|
const pageObj: Record<string, any> = {
|
|
218
215
|
options: pageConfig,
|
|
219
216
|
[ONLOAD] (options: Readonly<Record<string, unknown>> = {}, cb?: TFunc) {
|
|
220
|
-
hasLoaded = new Promise(resolve => {
|
|
217
|
+
hasLoaded = new Promise((resolve) => {
|
|
218
|
+
loadResolver = resolve
|
|
219
|
+
})
|
|
221
220
|
Current.page = this as any
|
|
222
221
|
this.config = pageConfig || {}
|
|
223
222
|
// this.$taroPath 是页面唯一标识
|
|
224
223
|
const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() })
|
|
225
|
-
const $taroPath = this.$taroPath = getPath(id, uniqueOptions)
|
|
224
|
+
const $taroPath = (this.$taroPath = getPath(id, uniqueOptions))
|
|
226
225
|
|
|
227
226
|
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
|
|
228
227
|
if (this.$taroParams == null) {
|
|
@@ -250,7 +249,7 @@ export function createNativePageConfig (Component, pageName: string, react: type
|
|
|
250
249
|
ReactDOM,
|
|
251
250
|
cb: () => {
|
|
252
251
|
Current.app!.mount!(Component, $taroPath, () => this, mountCallback)
|
|
253
|
-
}
|
|
252
|
+
},
|
|
254
253
|
})
|
|
255
254
|
} else {
|
|
256
255
|
Current.app!.mount!(Component, $taroPath, () => this, mountCallback)
|
|
@@ -279,7 +278,7 @@ export function createNativePageConfig (Component, pageName: string, react: type
|
|
|
279
278
|
pageElement = null
|
|
280
279
|
}
|
|
281
280
|
if (prepareMountList.length) {
|
|
282
|
-
prepareMountList.forEach(fn => fn())
|
|
281
|
+
prepareMountList.forEach((fn) => fn())
|
|
283
282
|
prepareMountList = []
|
|
284
283
|
}
|
|
285
284
|
})
|
|
@@ -337,11 +336,8 @@ export function createNativePageConfig (Component, pageName: string, react: type
|
|
|
337
336
|
})
|
|
338
337
|
|
|
339
338
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
340
|
-
SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
|
|
341
|
-
if (Component[lifecycle] ||
|
|
342
|
-
Component.prototype?.[lifecycle] ||
|
|
343
|
-
Component[lifecycle.replace(/^on/, 'enable')]
|
|
344
|
-
) {
|
|
339
|
+
SIDE_EFFECT_LIFECYCLES.forEach((lifecycle) => {
|
|
340
|
+
if (Component[lifecycle] || Component.prototype?.[lifecycle] || Component[lifecycle.replace(/^on/, 'enable')]) {
|
|
345
341
|
pageObj[lifecycle] = function (...args) {
|
|
346
342
|
const target = args[0]?.target
|
|
347
343
|
if (target?.id) {
|
|
@@ -360,3 +356,65 @@ export function createNativePageConfig (Component, pageName: string, react: type
|
|
|
360
356
|
|
|
361
357
|
return pageObj
|
|
362
358
|
}
|
|
359
|
+
|
|
360
|
+
export function createNativeComponentConfig (
|
|
361
|
+
Component,
|
|
362
|
+
react: typeof React,
|
|
363
|
+
reactdom,
|
|
364
|
+
componentConfig
|
|
365
|
+
) {
|
|
366
|
+
reactMeta.R = react
|
|
367
|
+
h = react.createElement
|
|
368
|
+
ReactDOM = reactdom
|
|
369
|
+
setReconciler(ReactDOM)
|
|
370
|
+
const { isNewBlended } = componentConfig
|
|
371
|
+
|
|
372
|
+
const componentObj: Record<string, any> = {
|
|
373
|
+
options: componentConfig,
|
|
374
|
+
onLoad (
|
|
375
|
+
options: Readonly<Record<string, unknown>> = {}, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
376
|
+
cb?: TFunc
|
|
377
|
+
) {
|
|
378
|
+
const app = isNewBlended ? nativeComponentApp : Current.app
|
|
379
|
+
|
|
380
|
+
const mountComponent = () => {
|
|
381
|
+
const compId = (this.compId = getNativeCompId())
|
|
382
|
+
|
|
383
|
+
this.config = componentConfig
|
|
384
|
+
app!.mount!(
|
|
385
|
+
Component,
|
|
386
|
+
compId,
|
|
387
|
+
() => this,
|
|
388
|
+
() => {
|
|
389
|
+
const el = document.getElementById(compId)
|
|
390
|
+
|
|
391
|
+
if (!el) {
|
|
392
|
+
throw new Error(`没有找到组件实例。`)
|
|
393
|
+
} else {
|
|
394
|
+
el.ctx = this
|
|
395
|
+
cb && cb(el)
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (!app) {
|
|
402
|
+
initNativeComponentEntry({
|
|
403
|
+
R: react,
|
|
404
|
+
ReactDOM,
|
|
405
|
+
isDefaultEntryDom: !isNewBlended,
|
|
406
|
+
cb: mountComponent,
|
|
407
|
+
})
|
|
408
|
+
} else {
|
|
409
|
+
mountComponent()
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
onUnload () {
|
|
414
|
+
const app = isNewBlended ? nativeComponentApp : Current.app
|
|
415
|
+
app!.unmount!(this.compId)
|
|
416
|
+
},
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return componentObj
|
|
420
|
+
}
|
package/dist/runtime-utils.js
CHANGED
|
@@ -659,8 +659,20 @@ const setClipboardData = function (options) {
|
|
|
659
659
|
}
|
|
660
660
|
return new Promise((resolve, reject) => {
|
|
661
661
|
const systemPasteboard = pasteboard.getSystemPasteboard();
|
|
662
|
-
const pasteData = pasteboard.
|
|
663
|
-
|
|
662
|
+
const pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, data);
|
|
663
|
+
try {
|
|
664
|
+
systemPasteboard.setDataSync(pasteData);
|
|
665
|
+
promptAction.showToast({
|
|
666
|
+
message: '内容已复制',
|
|
667
|
+
duration: 1500,
|
|
668
|
+
bottom: '50%',
|
|
669
|
+
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
670
|
+
});
|
|
671
|
+
return handle.success({
|
|
672
|
+
data,
|
|
673
|
+
}, { resolve, reject });
|
|
674
|
+
}
|
|
675
|
+
catch (error) {
|
|
664
676
|
if (error) {
|
|
665
677
|
console.error('Failed to set PasteData. Cause: ' + JSON.stringify(error));
|
|
666
678
|
res = {
|
|
@@ -669,18 +681,7 @@ const setClipboardData = function (options) {
|
|
|
669
681
|
};
|
|
670
682
|
callAsyncFail(reject, res, options);
|
|
671
683
|
}
|
|
672
|
-
|
|
673
|
-
promptAction.showToast({
|
|
674
|
-
message: '内容已复制',
|
|
675
|
-
duration: 1500,
|
|
676
|
-
bottom: '50%',
|
|
677
|
-
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
678
|
-
});
|
|
679
|
-
return handle.success({
|
|
680
|
-
data,
|
|
681
|
-
}, { resolve, reject });
|
|
682
|
-
}
|
|
683
|
-
});
|
|
684
|
+
}
|
|
684
685
|
});
|
|
685
686
|
};
|
|
686
687
|
/**
|
|
@@ -691,7 +692,7 @@ const getClipboardData = function (options) {
|
|
|
691
692
|
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
|
|
692
693
|
return new Promise((resolve, reject) => {
|
|
693
694
|
const systemPasteboard = pasteboard.getSystemPasteboard();
|
|
694
|
-
systemPasteboard.
|
|
695
|
+
systemPasteboard.getData((error, pasteData) => {
|
|
695
696
|
if (error) {
|
|
696
697
|
console.error('Failed to obtain PasteData. Cause: ' + JSON.stringify(error));
|
|
697
698
|
return handle.fail({
|