@tarojs/plugin-platform-harmony-ets 4.0.0-beta.44 → 4.0.0-beta.46
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/storage/index.ts +60 -50
- package/dist/components-harmony-ets/checkbox.ets +1 -1
- package/dist/components-harmony-ets/form.ets +1 -1
- package/dist/components-harmony-ets/label.ets +1 -1
- package/dist/components-harmony-ets/movableArea.ets +1 -1
- package/dist/components-harmony-ets/movableView.ets +1 -1
- package/dist/components-harmony-ets/radio.ets +1 -1
- package/dist/components-harmony-ets/style.ets +58 -54
- package/dist/components-harmony-ets/utils/flexManager.ets +5 -0
- package/dist/components-harmony-ets/view.ets +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/bind.ts +1 -3
- package/dist/runtime-ets/dom/element/element.ts +82 -1
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +4 -0
- package/dist/runtime-utils.js +57 -47
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +57 -47
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
|
@@ -14,6 +14,7 @@ import type Taro from '@tarojs/taro/types'
|
|
|
14
14
|
let context
|
|
15
15
|
let kvManager: distributedKVStore.KVManager
|
|
16
16
|
let kvStore: distributedKVStore.SingleKVStore
|
|
17
|
+
let kvStorePromise: Promise<void>
|
|
17
18
|
|
|
18
19
|
(Current as any).contextPromise.then((ctx) => {
|
|
19
20
|
context = ctx
|
|
@@ -38,13 +39,16 @@ let kvStore: distributedKVStore.SingleKVStore
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
kvStorePromise = new Promise(resolve => {
|
|
43
|
+
kvManager.getKVStore<distributedKVStore.SingleKVStore>(`${data.appInfo.uid}Store`, options, (err, store: distributedKVStore.SingleKVStore) => {
|
|
44
|
+
if (err) {
|
|
45
|
+
console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
kvStore = store
|
|
49
|
+
// 请确保获取到键值数据库实例后,再进行相关数据操作
|
|
50
|
+
resolve()
|
|
51
|
+
})
|
|
48
52
|
})
|
|
49
53
|
} catch (e) {
|
|
50
54
|
console.error(`Failed to create KVManager. Code:${e.code},message:${e.message}`)
|
|
@@ -58,7 +62,7 @@ const storageSchema = {
|
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
function checkContextExist (api: string, isAsync = false) {
|
|
61
|
-
if (!context
|
|
65
|
+
if (!context) {
|
|
62
66
|
const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`
|
|
63
67
|
if (isAsync) {
|
|
64
68
|
return {
|
|
@@ -91,21 +95,23 @@ export function getStorage<T = any> (options: Taro.getStorage.Option<T>) {
|
|
|
91
95
|
const handle = new MethodHandler<{data: any}>({ name, success, fail, complete })
|
|
92
96
|
|
|
93
97
|
return new Promise((resolve, reject) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
kvStore = kvStore as distributedKVStore.SingleKVStore
|
|
102
|
-
kvStore.get(key, (err, data) => {
|
|
103
|
-
if (err) {
|
|
104
|
-
handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject })
|
|
105
|
-
return
|
|
98
|
+
kvStorePromise.then(() => {
|
|
99
|
+
try {
|
|
100
|
+
validateParams(name, options, storageSchema)
|
|
101
|
+
} catch (error) {
|
|
102
|
+
const res = { errMsg: error.message }
|
|
103
|
+
return handle.fail(res, { resolve, reject })
|
|
106
104
|
}
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
|
|
106
|
+
kvStore = kvStore as distributedKVStore.SingleKVStore
|
|
107
|
+
kvStore.get(key, (err, data) => {
|
|
108
|
+
if (err) {
|
|
109
|
+
handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject })
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
handle.success({ data }, { resolve, reject })
|
|
114
|
+
})
|
|
109
115
|
})
|
|
110
116
|
})
|
|
111
117
|
}
|
|
@@ -122,21 +128,23 @@ export function setStorage (options: Taro.setStorage.Option) {
|
|
|
122
128
|
const handle = new MethodHandler({ name, success, fail, complete })
|
|
123
129
|
|
|
124
130
|
return new Promise((resolve, reject) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
kvStore = kvStore as distributedKVStore.SingleKVStore
|
|
133
|
-
kvStore.put(key, data, (err) => {
|
|
134
|
-
if (err) {
|
|
135
|
-
handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject })
|
|
136
|
-
return
|
|
131
|
+
kvStorePromise.then(() => {
|
|
132
|
+
try {
|
|
133
|
+
validateParams(name, options, storageSchema)
|
|
134
|
+
} catch (error) {
|
|
135
|
+
const res = { errMsg: error.message }
|
|
136
|
+
return handle.fail(res, { resolve, reject })
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
|
|
139
|
+
kvStore = kvStore as distributedKVStore.SingleKVStore
|
|
140
|
+
kvStore.put(key, data, (err) => {
|
|
141
|
+
if (err) {
|
|
142
|
+
handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject })
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
handle.success({}, { resolve, reject })
|
|
147
|
+
})
|
|
140
148
|
})
|
|
141
149
|
})
|
|
142
150
|
}
|
|
@@ -153,21 +161,23 @@ export function removeStorage (options: Taro.removeStorage.Option) {
|
|
|
153
161
|
const handle = new MethodHandler({ name, success, fail, complete })
|
|
154
162
|
|
|
155
163
|
return new Promise((resolve, reject) => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
kvStore = kvStore as distributedKVStore.SingleKVStore
|
|
164
|
-
kvStore.delete(key, (err) => {
|
|
165
|
-
if (err) {
|
|
166
|
-
handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject })
|
|
167
|
-
return
|
|
164
|
+
kvStorePromise.then(() => {
|
|
165
|
+
try {
|
|
166
|
+
validateParams(name, options, storageSchema)
|
|
167
|
+
} catch (error) {
|
|
168
|
+
const res = { errMsg: error.message }
|
|
169
|
+
return handle.fail(res, { resolve, reject })
|
|
168
170
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
|
|
172
|
+
kvStore = kvStore as distributedKVStore.SingleKVStore
|
|
173
|
+
kvStore.delete(key, (err) => {
|
|
174
|
+
if (err) {
|
|
175
|
+
handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject })
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
handle.success({}, { resolve, reject })
|
|
180
|
+
})
|
|
171
181
|
})
|
|
172
182
|
})
|
|
173
183
|
}
|
|
@@ -127,7 +127,7 @@ export struct TaroCheckboxGroup {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
build() {
|
|
130
|
-
if (
|
|
130
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
131
131
|
Flex(FlexManager.flexOptions(this.node)) {
|
|
132
132
|
this.createLazyChildren(this.node)
|
|
133
133
|
}
|
|
@@ -36,6 +36,11 @@ class TextStyleModify implements AttributeModifier<TextAttribute> {
|
|
|
36
36
|
|
|
37
37
|
setAnimationStyle (overwriteStyle: Record<string, TaroAny>) {
|
|
38
38
|
this.overwriteStyle = overwriteStyle
|
|
39
|
+
if (this.style && this.overwriteStyle) {
|
|
40
|
+
Object.keys(this.overwriteStyle).forEach(key => {
|
|
41
|
+
this.style![key] = this.overwriteStyle[key]
|
|
42
|
+
})
|
|
43
|
+
}
|
|
39
44
|
return this
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -43,12 +48,12 @@ class TextStyleModify implements AttributeModifier<TextAttribute> {
|
|
|
43
48
|
if (this.node && this.style) {
|
|
44
49
|
if (this.withNormal) {
|
|
45
50
|
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
51
|
+
setTransformAttributeIntoInstance(instance, this.style || {})
|
|
46
52
|
}
|
|
47
53
|
setNormalTextAttributeIntoInstance(instance, this.style, this.node)
|
|
48
54
|
setSpecialTextAttributeIntoInstance(instance, this.style, this.node)
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
|
|
@@ -87,9 +92,8 @@ class CommonStyleModify implements AttributeModifier<CommonAttribute> {
|
|
|
87
92
|
applyNormalAttribute(instance: CommonAttribute): void {
|
|
88
93
|
if (this.node && this.style) {
|
|
89
94
|
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
95
|
+
setTransformAttributeIntoInstance(instance, this.style || {})
|
|
90
96
|
}
|
|
91
|
-
|
|
92
|
-
setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
|
|
@@ -123,9 +127,9 @@ class RowStyleModify extends CommonStyleModify {
|
|
|
123
127
|
instance.alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
|
|
124
128
|
instance.justifyContent(FlexManager.justifyContent(this.node))
|
|
125
129
|
}
|
|
130
|
+
setTransformAttributeIntoInstance(instance, this.style || {})
|
|
126
131
|
}
|
|
127
132
|
|
|
128
|
-
setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
|
|
@@ -143,34 +147,34 @@ class ColumnStyleModify extends CommonStyleModify {
|
|
|
143
147
|
instance.alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
|
|
144
148
|
instance.justifyContent(FlexManager.justifyContent(this.node))
|
|
145
149
|
}
|
|
150
|
+
setTransformAttributeIntoInstance(instance, this.style || {})
|
|
146
151
|
}
|
|
147
152
|
|
|
148
|
-
setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
155
|
|
|
152
|
-
export function
|
|
156
|
+
export function setTransformAttributeIntoInstance(instance: CommonAttribute, style: TaroStyleType) {
|
|
153
157
|
// Animation 需要提前和 @State 变量绑定才能产生动画效果,因此不能做 if else 判断
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
158
|
+
instance.translate({
|
|
159
|
+
x: style.transform?.Translate?.x,
|
|
160
|
+
y: style.transform?.Translate?.y,
|
|
161
|
+
z: style.transform?.Translate?.z,
|
|
162
|
+
})
|
|
163
|
+
instance.scale({
|
|
164
|
+
x: style.transform?.Scale?.x,
|
|
165
|
+
y: style.transform?.Scale?.y,
|
|
166
|
+
z: style.transform?.Scale?.z,
|
|
167
|
+
centerX: style.transformOrigin?.x || 0,
|
|
168
|
+
centerY: style.transformOrigin?.y || 0,
|
|
169
|
+
})
|
|
170
|
+
instance.rotate({
|
|
171
|
+
x: style.transform?.Rotate?.x,
|
|
172
|
+
y: style.transform?.Rotate?.y,
|
|
173
|
+
z: style.transform?.Rotate?.z,
|
|
174
|
+
centerX: style.transformOrigin?.x || 0,
|
|
175
|
+
centerY: style.transformOrigin?.y || 0,
|
|
176
|
+
angle: style.transform?.Rotate?.angle || 0,
|
|
177
|
+
})
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
export function setNormalTextAttributeIntoInstance(instance: TextAttribute | SpanAttribute, style: HarmonyStyle, node?: TaroTextElement | null) {
|
|
@@ -366,34 +370,34 @@ export function setNormalAttributeIntoInstance(instance: CommonAttribute, style:
|
|
|
366
370
|
// 为了适应position不设置z-index也能高于同层级组件,估且让设置了z-index的会更高一级
|
|
367
371
|
instance.zIndex(style.zIndex + 1)
|
|
368
372
|
}
|
|
369
|
-
if (!isUndefined(style.transform)) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
373
|
+
// if (!isUndefined(style.transform)) {
|
|
374
|
+
// if (style.transform.Translate) {
|
|
375
|
+
// instance.translate({
|
|
376
|
+
// x: style.transform.Translate.x || 0,
|
|
377
|
+
// y: style.transform.Translate.y || 0,
|
|
378
|
+
// z: style.transform.Translate.z || 0,
|
|
379
|
+
// })
|
|
380
|
+
// }
|
|
381
|
+
// if (style.transform.Scale) {
|
|
382
|
+
// instance.scale({
|
|
383
|
+
// x: style.transform.Scale.x || 0,
|
|
384
|
+
// y: style.transform.Scale.y || 0,
|
|
385
|
+
// z: style.transform.Scale.z || 0,
|
|
386
|
+
// centerX: style.transformOrigin?.x || 0,
|
|
387
|
+
// centerY: style.transformOrigin?.y || 0,
|
|
388
|
+
// })
|
|
389
|
+
// }
|
|
390
|
+
// if (style.transform.Rotate) {
|
|
391
|
+
// instance.rotate({
|
|
392
|
+
// x: style.transform.Rotate.x || 0,
|
|
393
|
+
// y: style.transform.Rotate.y || 0,
|
|
394
|
+
// z: style.transform.Rotate.z || 0,
|
|
395
|
+
// centerX: style.transformOrigin?.x || 0,
|
|
396
|
+
// centerY: style.transformOrigin?.y || 0,
|
|
397
|
+
// angle: style.transform.Rotate.angle
|
|
398
|
+
// })
|
|
399
|
+
// }
|
|
400
|
+
// }
|
|
397
401
|
}
|
|
398
402
|
|
|
399
403
|
export const pseudoModify = new PseudoStyleModify()
|
|
@@ -37,6 +37,11 @@ class FlexManager {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
static useFlexLayout (node: TaroElement): boolean {
|
|
41
|
+
const hmStyle: HarmonyStyle = getNormalAttributes(node) || {}
|
|
42
|
+
return !isUndefined(hmStyle.flexWrap) || [ItemAlign.Stretch, ItemAlign.Baseline].indexOf(hmStyle.alignItems!) !== -1
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
static flexOptions (node: TaroElement): IFlexOptions {
|
|
41
46
|
const hmStyle: HarmonyStyle = getNormalAttributes(node) || {}
|
|
42
47
|
const isFlex = FlexManager.isFlexNode(node)
|
|
@@ -23,7 +23,7 @@ export default struct TaroView {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
build () {
|
|
26
|
-
if (
|
|
26
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
27
27
|
Flex(FlexManager.flexOptions(this.node)) {
|
|
28
28
|
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
29
29
|
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
package/dist/index.js
CHANGED
|
@@ -507,7 +507,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
507
507
|
define.global = 'globalThis';
|
|
508
508
|
}
|
|
509
509
|
const ext = path__namespace.extname(target);
|
|
510
|
-
|
|
510
|
+
if (![/d\.e?tsx?$/, /\.(json|md)$/].some(e => e.test(target))) {
|
|
511
|
+
code = this.replaceDefineValue(code, define, ext);
|
|
512
|
+
}
|
|
511
513
|
if (['.ts'].includes(ext)) {
|
|
512
514
|
code = '// @ts-nocheck\n' + code;
|
|
513
515
|
}
|