@tarojs/runtime 3.6.6-alpha.1 → 3.6.6-alpha.3
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/bom/history.d.ts +1 -1
- package/dist/dom/class-list.d.ts +8 -6
- package/dist/dom/form.d.ts +2 -0
- package/dist/dsl/instance.d.ts +2 -0
- package/dist/runtime.esm.d.ts +13 -7
- package/dist/runtime.esm.js +101 -34
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/bom/history.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class History extends Events {
|
|
|
18
18
|
#private;
|
|
19
19
|
constructor(location: LocationType.Location, options: Options);
|
|
20
20
|
get length(): number;
|
|
21
|
-
get state():
|
|
21
|
+
get state(): Record<string, any> | null;
|
|
22
22
|
go(delta: number): void;
|
|
23
23
|
back(): void;
|
|
24
24
|
forward(): void;
|
package/dist/dom/class-list.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { TaroElement } from './element';
|
|
2
|
-
export declare class ClassList
|
|
2
|
+
export declare class ClassList {
|
|
3
3
|
private el;
|
|
4
|
+
private tokenList;
|
|
4
5
|
constructor(className: string, el: TaroElement);
|
|
5
6
|
get value(): string;
|
|
6
|
-
add(s: string): this;
|
|
7
7
|
get length(): number;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
add(): void;
|
|
9
|
+
remove(): void;
|
|
10
|
+
contains(token: string): boolean;
|
|
11
|
+
toggle(token: string, force: boolean): boolean;
|
|
12
|
+
replace(token: string, replacement_token: string): void;
|
|
12
13
|
toString(): string;
|
|
14
|
+
private checkTokenIsValid;
|
|
13
15
|
private _update;
|
|
14
16
|
}
|
package/dist/dom/form.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TaroElement } from './element';
|
|
2
2
|
import type { TaroEvent } from './event';
|
|
3
3
|
export declare class FormElement extends TaroElement {
|
|
4
|
+
get type(): string;
|
|
5
|
+
set type(val: string);
|
|
4
6
|
get value(): string | boolean | number | any[];
|
|
5
7
|
set value(val: string | boolean | number | any[]);
|
|
6
8
|
dispatchEvent(event: TaroEvent): boolean;
|
package/dist/dsl/instance.d.ts
CHANGED
package/dist/runtime.esm.d.ts
CHANGED
|
@@ -6,17 +6,19 @@ import { Component as Vue3Component } from "@vue/runtime-core";
|
|
|
6
6
|
import { Component, ComponentClass } from "react";
|
|
7
7
|
import { CombinedVueInstance } from "vue/types/vue";
|
|
8
8
|
declare let document: any;
|
|
9
|
-
declare class ClassList
|
|
9
|
+
declare class ClassList {
|
|
10
10
|
private el;
|
|
11
|
+
private tokenList;
|
|
11
12
|
constructor(className: string, el: TaroElement);
|
|
12
13
|
get value(): string;
|
|
13
|
-
add(s: string): this;
|
|
14
14
|
get length(): number;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
add(): void;
|
|
16
|
+
remove(): void;
|
|
17
|
+
contains(token: string): boolean;
|
|
18
|
+
toggle(token: string, force: boolean): boolean;
|
|
19
|
+
replace(token: string, replacement_token: string): void;
|
|
19
20
|
toString(): string;
|
|
21
|
+
private checkTokenIsValid;
|
|
20
22
|
private _update;
|
|
21
23
|
}
|
|
22
24
|
interface Attributes {
|
|
@@ -129,6 +131,8 @@ declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroE
|
|
|
129
131
|
// 小程序的事件代理回调函数
|
|
130
132
|
declare function eventHandler(event: MpEvent): any;
|
|
131
133
|
declare class FormElement extends TaroElement {
|
|
134
|
+
get type(): string;
|
|
135
|
+
set type(val: string);
|
|
132
136
|
get value(): string | boolean | number | any[];
|
|
133
137
|
set value(val: string | boolean | number | any[]);
|
|
134
138
|
dispatchEvent(event: TaroEvent): boolean;
|
|
@@ -405,7 +409,7 @@ declare class History extends Events {
|
|
|
405
409
|
constructor(location: LocationType.Location, options: Options$0);
|
|
406
410
|
/* public property */
|
|
407
411
|
get length(): number;
|
|
408
|
-
get state():
|
|
412
|
+
get state(): Record<string, any> | null;
|
|
409
413
|
/* public method */
|
|
410
414
|
go(delta: number): void;
|
|
411
415
|
back(): void;
|
|
@@ -639,6 +643,8 @@ interface PageInstance extends PageLifeCycle {
|
|
|
639
643
|
path?: string;
|
|
640
644
|
/** 页面的组件选项 */
|
|
641
645
|
options?: Record<string, unknown>;
|
|
646
|
+
/** 页面渲染引擎类型 */
|
|
647
|
+
renderer?: "webview" | "skyline";
|
|
642
648
|
}
|
|
643
649
|
interface Show {
|
|
644
650
|
componentDidShow?(): void;
|
package/dist/runtime.esm.js
CHANGED
|
@@ -283,46 +283,90 @@ function getComponentsAlias() {
|
|
|
283
283
|
return componentsAlias$1;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
class ClassList
|
|
286
|
+
class ClassList {
|
|
287
287
|
constructor(className, el) {
|
|
288
|
-
|
|
289
|
-
className.trim().split(/\s+/).forEach(super.add.bind(this));
|
|
288
|
+
this.tokenList = [];
|
|
290
289
|
this.el = el;
|
|
290
|
+
className.trim().split(/\s+/).forEach(token => this.tokenList.push(token));
|
|
291
291
|
}
|
|
292
292
|
get value() {
|
|
293
|
-
return
|
|
294
|
-
}
|
|
295
|
-
add(s) {
|
|
296
|
-
super.add(s);
|
|
297
|
-
this._update();
|
|
298
|
-
return this;
|
|
293
|
+
return this.toString();
|
|
299
294
|
}
|
|
300
295
|
get length() {
|
|
301
|
-
return this.
|
|
296
|
+
return this.tokenList.length;
|
|
297
|
+
}
|
|
298
|
+
add() {
|
|
299
|
+
let index = 0;
|
|
300
|
+
let updated = false;
|
|
301
|
+
const tokens = arguments;
|
|
302
|
+
const length = tokens.length;
|
|
303
|
+
const tokenList = this.tokenList;
|
|
304
|
+
do {
|
|
305
|
+
const token = tokens[index];
|
|
306
|
+
if (this.checkTokenIsValid(token) && !~tokenList.indexOf(token)) {
|
|
307
|
+
tokenList.push(token);
|
|
308
|
+
updated = true;
|
|
309
|
+
}
|
|
310
|
+
} while (++index < length);
|
|
311
|
+
if (updated) {
|
|
312
|
+
this._update();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
remove() {
|
|
316
|
+
let i = 0;
|
|
317
|
+
let updated = false;
|
|
318
|
+
const tokens = arguments;
|
|
319
|
+
const length = tokens.length;
|
|
320
|
+
const tokenList = this.tokenList;
|
|
321
|
+
do {
|
|
322
|
+
const token = tokens[i] + '';
|
|
323
|
+
if (!this.checkTokenIsValid(token))
|
|
324
|
+
continue;
|
|
325
|
+
const index = tokenList.indexOf(token);
|
|
326
|
+
if (~tokenList.indexOf(token)) {
|
|
327
|
+
tokenList.splice(index, 1);
|
|
328
|
+
updated = true;
|
|
329
|
+
}
|
|
330
|
+
} while (++i < length);
|
|
331
|
+
if (updated) {
|
|
332
|
+
this._update();
|
|
333
|
+
}
|
|
302
334
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
335
|
+
contains(token) {
|
|
336
|
+
if (!this.checkTokenIsValid(token))
|
|
337
|
+
return false;
|
|
338
|
+
return !!~this.tokenList.indexOf(token);
|
|
306
339
|
}
|
|
307
|
-
toggle(
|
|
308
|
-
|
|
309
|
-
|
|
340
|
+
toggle(token, force) {
|
|
341
|
+
const result = this.contains(token);
|
|
342
|
+
const method = result ? force !== true && 'remove' : force !== false && 'add';
|
|
343
|
+
if (method) {
|
|
344
|
+
// @ts-ignore
|
|
345
|
+
this[method](token);
|
|
346
|
+
}
|
|
347
|
+
if (force === true || force === false) {
|
|
348
|
+
return force;
|
|
310
349
|
}
|
|
311
350
|
else {
|
|
312
|
-
|
|
351
|
+
return !result;
|
|
313
352
|
}
|
|
314
|
-
this._update();
|
|
315
|
-
}
|
|
316
|
-
replace(s1, s2) {
|
|
317
|
-
super.delete(s1);
|
|
318
|
-
super.add(s2);
|
|
319
|
-
this._update();
|
|
320
353
|
}
|
|
321
|
-
|
|
322
|
-
|
|
354
|
+
replace(token, replacement_token) {
|
|
355
|
+
if (!this.checkTokenIsValid(token) || !this.checkTokenIsValid(replacement_token))
|
|
356
|
+
return;
|
|
357
|
+
const index = this.tokenList.indexOf(token);
|
|
358
|
+
if (~index) {
|
|
359
|
+
this.tokenList.splice(index, 1, replacement_token);
|
|
360
|
+
this._update();
|
|
361
|
+
}
|
|
323
362
|
}
|
|
324
363
|
toString() {
|
|
325
|
-
return this.
|
|
364
|
+
return this.tokenList.filter(v => v !== '').join(' ');
|
|
365
|
+
}
|
|
366
|
+
checkTokenIsValid(token) {
|
|
367
|
+
if (token === '' || /\s/.test(token))
|
|
368
|
+
return false;
|
|
369
|
+
return true;
|
|
326
370
|
}
|
|
327
371
|
_update() {
|
|
328
372
|
this.el.className = this.value;
|
|
@@ -803,7 +847,8 @@ const styleProperties = [
|
|
|
803
847
|
'widows',
|
|
804
848
|
'width',
|
|
805
849
|
'zIndex',
|
|
806
|
-
'pointerEvents'
|
|
850
|
+
'pointerEvents',
|
|
851
|
+
'aspectRatio'
|
|
807
852
|
/** 非常用 style */
|
|
808
853
|
// 'azimuth',
|
|
809
854
|
// 'backfaceVisibility',
|
|
@@ -971,10 +1016,12 @@ function setStyle(newVal, styleKey) {
|
|
|
971
1016
|
}
|
|
972
1017
|
!this._pending && enqueueUpdate(this);
|
|
973
1018
|
}
|
|
974
|
-
function initStyle(ctor) {
|
|
1019
|
+
function initStyle(ctor, styleProperties) {
|
|
975
1020
|
const properties = {};
|
|
976
1021
|
for (let i = 0; i < styleProperties.length; i++) {
|
|
977
1022
|
const styleKey = styleProperties[i];
|
|
1023
|
+
if (ctor[styleKey])
|
|
1024
|
+
return;
|
|
978
1025
|
properties[styleKey] = {
|
|
979
1026
|
get() {
|
|
980
1027
|
const val = this._value[styleKey];
|
|
@@ -1085,7 +1132,17 @@ class Style {
|
|
|
1085
1132
|
return value;
|
|
1086
1133
|
}
|
|
1087
1134
|
}
|
|
1088
|
-
initStyle(Style);
|
|
1135
|
+
initStyle(Style, styleProperties);
|
|
1136
|
+
hooks.tap('injectNewStyleProperties', (newStyleProperties) => {
|
|
1137
|
+
if (isArray(newStyleProperties)) {
|
|
1138
|
+
initStyle(Style, newStyleProperties);
|
|
1139
|
+
}
|
|
1140
|
+
else {
|
|
1141
|
+
if (typeof newStyleProperties !== 'string')
|
|
1142
|
+
return;
|
|
1143
|
+
initStyle(Style, [newStyleProperties]);
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1089
1146
|
|
|
1090
1147
|
function returnTrue() {
|
|
1091
1148
|
return true;
|
|
@@ -1104,7 +1161,9 @@ function treeToArray(root, predict) {
|
|
|
1104
1161
|
}
|
|
1105
1162
|
function following(el, root) {
|
|
1106
1163
|
const firstChild = el.firstChild;
|
|
1107
|
-
|
|
1164
|
+
const isElmentTypeValid = el.nodeType === 1 /* NodeType.ELEMENT_NODE */ || el.nodeType === 9 /* NodeType.DOCUMENT_NODE */;
|
|
1165
|
+
// 如果当前 el 不是 element 或 document 元素,则可以直接不递归他的子元素了
|
|
1166
|
+
if (firstChild && isElmentTypeValid) {
|
|
1108
1167
|
return firstChild;
|
|
1109
1168
|
}
|
|
1110
1169
|
let current = el;
|
|
@@ -1345,10 +1404,10 @@ class TaroElement extends TaroNode {
|
|
|
1345
1404
|
});
|
|
1346
1405
|
}
|
|
1347
1406
|
getElementsByClassName(className) {
|
|
1407
|
+
const classNames = className.trim().split(/\s+/);
|
|
1348
1408
|
return treeToArray(this, (el) => {
|
|
1349
1409
|
const classList = el.classList;
|
|
1350
|
-
|
|
1351
|
-
return classNames.every(c => classList.has(c));
|
|
1410
|
+
return classNames.every(c => classList.contains(c));
|
|
1352
1411
|
});
|
|
1353
1412
|
}
|
|
1354
1413
|
dispatchEvent(event) {
|
|
@@ -2458,7 +2517,8 @@ function eventHandler(event) {
|
|
|
2458
2517
|
const dispatch = () => {
|
|
2459
2518
|
const e = createEvent(event, node);
|
|
2460
2519
|
hooks.call('modifyTaroEvent', e, node);
|
|
2461
|
-
|
|
2520
|
+
hooks.call('dispatchTaroEvent', e, node);
|
|
2521
|
+
hooks.call('dispatchTaroEventFinish', e, node);
|
|
2462
2522
|
};
|
|
2463
2523
|
if (hooks.isExist('batchedEventUpdates')) {
|
|
2464
2524
|
const type = event.type;
|
|
@@ -2488,6 +2548,13 @@ function eventHandler(event) {
|
|
|
2488
2548
|
}
|
|
2489
2549
|
|
|
2490
2550
|
class FormElement extends TaroElement {
|
|
2551
|
+
get type() {
|
|
2552
|
+
var _a;
|
|
2553
|
+
return (_a = this.props[TYPE]) !== null && _a !== void 0 ? _a : '';
|
|
2554
|
+
}
|
|
2555
|
+
set type(val) {
|
|
2556
|
+
this.setAttribute(TYPE, val);
|
|
2557
|
+
}
|
|
2491
2558
|
get value() {
|
|
2492
2559
|
// eslint-disable-next-line dot-notation
|
|
2493
2560
|
const val = this.props[VALUE];
|
|
@@ -3333,7 +3400,7 @@ class History extends Events {
|
|
|
3333
3400
|
return __classPrivateFieldGet(this, _History_stack, "f").length;
|
|
3334
3401
|
}
|
|
3335
3402
|
get state() {
|
|
3336
|
-
return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")];
|
|
3403
|
+
return __classPrivateFieldGet(this, _History_stack, "f")[__classPrivateFieldGet(this, _History_cur, "f")].state;
|
|
3337
3404
|
}
|
|
3338
3405
|
/* public method */
|
|
3339
3406
|
go(delta) {
|