@tarojs/runtime 3.7.0-alpha.7 → 3.7.0-alpha.8
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/runtime.cjs.d.ts +153 -66
- package/dist/runtime.cjs.js +121 -51
- package/dist/runtime.esm.d.ts +153 -66
- package/dist/runtime.esm.js +32 -18
- package/dist/runtime.esm.js.map +1 -1
- package/dist/runtime.h5.d.ts +153 -66
- package/dist/runtime.h5.js +118 -38
- package/package.json +2 -2
package/dist/runtime.h5.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { ComponentOptions, VNode } from "vue";
|
|
|
5
5
|
import { Component as Vue3Component } from "@vue/runtime-core";
|
|
6
6
|
import { Component, ComponentClass } from "react";
|
|
7
7
|
import { CombinedVueInstance } from "vue/types/vue";
|
|
8
|
-
declare let document: any;
|
|
9
8
|
declare class ClassList {
|
|
10
9
|
private el;
|
|
11
10
|
private tokenList;
|
|
@@ -104,70 +103,6 @@ declare class TaroText extends TaroNode {
|
|
|
104
103
|
set data(text: string);
|
|
105
104
|
get data(): string;
|
|
106
105
|
}
|
|
107
|
-
// Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
|
|
108
|
-
declare class TaroEvent {
|
|
109
|
-
private cacheTarget;
|
|
110
|
-
private cacheCurrentTarget;
|
|
111
|
-
type: string;
|
|
112
|
-
bubbles: boolean;
|
|
113
|
-
cancelable: boolean;
|
|
114
|
-
_stop: boolean;
|
|
115
|
-
_end: boolean;
|
|
116
|
-
defaultPrevented: boolean;
|
|
117
|
-
// Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
|
|
118
|
-
button: number;
|
|
119
|
-
// timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
|
|
120
|
-
// here use hi-res timestamp
|
|
121
|
-
timeStamp: number;
|
|
122
|
-
mpEvent: MpEvent | undefined;
|
|
123
|
-
constructor(type: string, opts: EventOptions, event?: MpEvent);
|
|
124
|
-
stopPropagation(): void;
|
|
125
|
-
stopImmediatePropagation(): void;
|
|
126
|
-
preventDefault(): void;
|
|
127
|
-
get target(): any;
|
|
128
|
-
get currentTarget(): any;
|
|
129
|
-
}
|
|
130
|
-
declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroEvent;
|
|
131
|
-
// 小程序的事件代理回调函数
|
|
132
|
-
declare function eventHandler(event: MpEvent): any;
|
|
133
|
-
declare class FormElement extends TaroElement {
|
|
134
|
-
get type(): string;
|
|
135
|
-
set type(val: string);
|
|
136
|
-
get value(): string | boolean | number | any[];
|
|
137
|
-
set value(val: string | boolean | number | any[]);
|
|
138
|
-
dispatchEvent(event: TaroEvent): boolean;
|
|
139
|
-
}
|
|
140
|
-
declare class TaroRootElement extends TaroElement {
|
|
141
|
-
private updatePayloads;
|
|
142
|
-
private updateCallbacks;
|
|
143
|
-
pendingUpdate: boolean;
|
|
144
|
-
ctx: null | MpInstance;
|
|
145
|
-
constructor();
|
|
146
|
-
get _path(): string;
|
|
147
|
-
get _root(): TaroRootElement;
|
|
148
|
-
enqueueUpdate(payload: UpdatePayload): void;
|
|
149
|
-
performUpdate(initRender?: boolean, prerender?: Func): void;
|
|
150
|
-
enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
|
|
151
|
-
flushUpdateCallback(): void;
|
|
152
|
-
}
|
|
153
|
-
declare class TaroDocument extends TaroElement {
|
|
154
|
-
documentElement: TaroElement;
|
|
155
|
-
head: TaroElement;
|
|
156
|
-
body: TaroElement;
|
|
157
|
-
createEvent: typeof createEvent;
|
|
158
|
-
constructor();
|
|
159
|
-
createElement(type: string): TaroElement | TaroRootElement | FormElement;
|
|
160
|
-
// an ugly fake createElementNS to deal with @vue/runtime-dom's
|
|
161
|
-
// support mounting app to svg container since vue@3.0.8
|
|
162
|
-
createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
|
|
163
|
-
createTextNode(text: string): TaroText;
|
|
164
|
-
getElementById<T extends TaroElement>(id: string | undefined | null): T | null;
|
|
165
|
-
querySelector<T extends TaroElement>(query: string): T | null;
|
|
166
|
-
querySelectorAll(): never[];
|
|
167
|
-
// @TODO: @PERF: 在 hydrate 移除掉空的 node
|
|
168
|
-
createComment(): TaroText;
|
|
169
|
-
get defaultView(): any;
|
|
170
|
-
}
|
|
171
106
|
interface Node {
|
|
172
107
|
type: string;
|
|
173
108
|
}
|
|
@@ -207,6 +142,19 @@ declare class TaroEventTarget {
|
|
|
207
142
|
removeEventListener(type: string, handler: EventHandler): void;
|
|
208
143
|
isAnyEventBinded(): boolean;
|
|
209
144
|
}
|
|
145
|
+
declare class TaroRootElement extends TaroElement {
|
|
146
|
+
private updatePayloads;
|
|
147
|
+
private updateCallbacks;
|
|
148
|
+
pendingUpdate: boolean;
|
|
149
|
+
ctx: null | MpInstance;
|
|
150
|
+
constructor();
|
|
151
|
+
get _path(): string;
|
|
152
|
+
get _root(): TaroRootElement;
|
|
153
|
+
enqueueUpdate(payload: UpdatePayload): void;
|
|
154
|
+
performUpdate(initRender?: boolean, prerender?: Func): void;
|
|
155
|
+
enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
|
|
156
|
+
flushUpdateCallback(): void;
|
|
157
|
+
}
|
|
210
158
|
interface RemoveChildOptions {
|
|
211
159
|
cleanRef?: boolean;
|
|
212
160
|
doUpdate?: boolean;
|
|
@@ -290,7 +238,34 @@ declare class Style {
|
|
|
290
238
|
removeProperty(propertyName: string): string;
|
|
291
239
|
getPropertyValue(propertyName: string): any;
|
|
292
240
|
}
|
|
241
|
+
// Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
|
|
242
|
+
declare class TaroEvent {
|
|
243
|
+
private cacheTarget;
|
|
244
|
+
private cacheCurrentTarget;
|
|
245
|
+
type: string;
|
|
246
|
+
bubbles: boolean;
|
|
247
|
+
cancelable: boolean;
|
|
248
|
+
_stop: boolean;
|
|
249
|
+
_end: boolean;
|
|
250
|
+
defaultPrevented: boolean;
|
|
251
|
+
// Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
|
|
252
|
+
button: number;
|
|
253
|
+
// timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
|
|
254
|
+
// here use hi-res timestamp
|
|
255
|
+
timeStamp: number;
|
|
256
|
+
mpEvent: MpEvent | undefined;
|
|
257
|
+
constructor(type: string, opts: EventOptions, event?: MpEvent);
|
|
258
|
+
stopPropagation(): void;
|
|
259
|
+
stopImmediatePropagation(): void;
|
|
260
|
+
preventDefault(): void;
|
|
261
|
+
get target(): any;
|
|
262
|
+
get currentTarget(): any;
|
|
263
|
+
}
|
|
264
|
+
declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroEvent;
|
|
265
|
+
// 小程序的事件代理回调函数
|
|
266
|
+
declare function eventHandler(event: MpEvent): any;
|
|
293
267
|
declare class TaroElement extends TaroNode {
|
|
268
|
+
ctx?: any;
|
|
294
269
|
tagName: string;
|
|
295
270
|
props: Record<string, any>;
|
|
296
271
|
style: Style;
|
|
@@ -324,6 +299,37 @@ declare class TaroElement extends TaroNode {
|
|
|
324
299
|
removeEventListener(type: any, handler: any, sideEffect?: boolean): void;
|
|
325
300
|
static extend(methodName: string, options: Func | Record<string, any>): void;
|
|
326
301
|
}
|
|
302
|
+
declare class FormElement extends TaroElement {
|
|
303
|
+
get type(): string;
|
|
304
|
+
set type(val: string);
|
|
305
|
+
get value(): string | boolean | number | any[];
|
|
306
|
+
set value(val: string | boolean | number | any[]);
|
|
307
|
+
dispatchEvent(event: TaroEvent): boolean;
|
|
308
|
+
}
|
|
309
|
+
declare class TaroDocument extends TaroElement {
|
|
310
|
+
documentElement: TaroElement;
|
|
311
|
+
head: TaroElement;
|
|
312
|
+
body: TaroElement;
|
|
313
|
+
createEvent: typeof createEvent;
|
|
314
|
+
constructor();
|
|
315
|
+
createElement(type: string): TaroElement | TaroRootElement | FormElement;
|
|
316
|
+
// an ugly fake createElementNS to deal with @vue/runtime-dom's
|
|
317
|
+
// support mounting app to svg container since vue@3.0.8
|
|
318
|
+
createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
|
|
319
|
+
createTextNode(text: string): TaroText;
|
|
320
|
+
getElementById<T extends TaroElement>(id: string | undefined | null): T | null;
|
|
321
|
+
querySelector<T extends TaroElement>(query: string): T | null;
|
|
322
|
+
querySelectorAll(): never[];
|
|
323
|
+
// @TODO: @PERF: 在 hydrate 移除掉空的 node
|
|
324
|
+
createComment(): TaroText;
|
|
325
|
+
get defaultView(): any;
|
|
326
|
+
}
|
|
327
|
+
interface Env {
|
|
328
|
+
window: any;
|
|
329
|
+
document: TaroDocument;
|
|
330
|
+
}
|
|
331
|
+
declare const env: Env;
|
|
332
|
+
declare let document: any;
|
|
327
333
|
declare function getComputedStyle(element: TaroElement): Style;
|
|
328
334
|
declare const eventCenter: Events;
|
|
329
335
|
type EventsType = typeof Events;
|
|
@@ -583,8 +589,67 @@ declare class MutationObserver {
|
|
|
583
589
|
takeRecords(): MutationRecord[];
|
|
584
590
|
static record(record: MutationRecord): void;
|
|
585
591
|
}
|
|
592
|
+
declare const PROPERTY_THRESHOLD = 2046;
|
|
593
|
+
declare const TARO_RUNTIME = "Taro runtime";
|
|
594
|
+
declare const HOOKS_APP_ID = "taro-app";
|
|
595
|
+
declare const SET_DATA = "\u5C0F\u7A0B\u5E8F setData";
|
|
596
|
+
declare const PAGE_INIT = "\u9875\u9762\u521D\u59CB\u5316";
|
|
597
|
+
declare const ROOT_STR = "root";
|
|
598
|
+
declare const HTML = "html";
|
|
599
|
+
declare const HEAD = "head";
|
|
600
|
+
declare const BODY = "body";
|
|
601
|
+
declare const APP = "app";
|
|
602
|
+
declare const CONTAINER = "container";
|
|
603
|
+
declare const DOCUMENT_ELEMENT_NAME = "#document";
|
|
604
|
+
declare const DOCUMENT_FRAGMENT = "document-fragment";
|
|
605
|
+
declare const ID = "id";
|
|
606
|
+
declare const UID = "uid";
|
|
607
|
+
declare const CLASS = "class";
|
|
608
|
+
declare const STYLE = "style";
|
|
609
|
+
declare const FOCUS = "focus";
|
|
610
|
+
declare const VIEW = "view";
|
|
611
|
+
declare const STATIC_VIEW = "static-view";
|
|
612
|
+
declare const PURE_VIEW = "pure-view";
|
|
613
|
+
declare const PROPS = "props";
|
|
614
|
+
declare const DATASET = "dataset";
|
|
615
|
+
declare const OBJECT = "object";
|
|
616
|
+
declare const VALUE = "value";
|
|
617
|
+
declare const INPUT = "input";
|
|
618
|
+
declare const CHANGE = "change";
|
|
619
|
+
declare const CUSTOM_WRAPPER = "custom-wrapper";
|
|
620
|
+
declare const TARGET = "target";
|
|
621
|
+
declare const CURRENT_TARGET = "currentTarget";
|
|
622
|
+
declare const TYPE = "type";
|
|
623
|
+
declare const CONFIRM = "confirm";
|
|
624
|
+
declare const TIME_STAMP = "timeStamp";
|
|
625
|
+
declare const KEY_CODE = "keyCode";
|
|
626
|
+
declare const TOUCHMOVE = "touchmove";
|
|
627
|
+
declare const DATE = "Date";
|
|
628
|
+
declare const SET_TIMEOUT = "setTimeout";
|
|
629
|
+
declare const CATCHMOVE = "catchMove";
|
|
630
|
+
declare const CATCH_VIEW = "catch-view";
|
|
631
|
+
declare const COMMENT = "comment";
|
|
632
|
+
declare const ON_LOAD = "onLoad";
|
|
633
|
+
declare const ON_READY = "onReady";
|
|
634
|
+
declare const ON_SHOW = "onShow";
|
|
635
|
+
declare const ON_HIDE = "onHide";
|
|
636
|
+
declare const OPTIONS = "options";
|
|
637
|
+
declare const EXTERNAL_CLASSES = "externalClasses";
|
|
638
|
+
declare const EVENT_CALLBACK_RESULT = "e_result";
|
|
639
|
+
declare const BEHAVIORS = "behaviors";
|
|
640
|
+
declare const A = "a";
|
|
641
|
+
/**
|
|
642
|
+
* 页面上下文切换时的行为
|
|
643
|
+
*/
|
|
644
|
+
declare enum CONTEXT_ACTIONS {
|
|
645
|
+
INIT = "0",
|
|
646
|
+
RESTORE = "1",
|
|
647
|
+
RECOVER = "2",
|
|
648
|
+
DESTORY = "3"
|
|
649
|
+
}
|
|
586
650
|
interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInstance {
|
|
587
651
|
tid?: string;
|
|
652
|
+
node?: TaroElement;
|
|
588
653
|
$forceUpdate?(): void;
|
|
589
654
|
$nextTick?(cb: () => void): void;
|
|
590
655
|
$options: Instance;
|
|
@@ -656,6 +721,7 @@ interface Show {
|
|
|
656
721
|
interface AppInstance extends Show {
|
|
657
722
|
componentDidShow?(options?: Record<string, unknown>): void;
|
|
658
723
|
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
|
|
724
|
+
mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, getCtx: (...args: any[]) => void, cb: (...args: any[]) => void): void;
|
|
659
725
|
onError?(error: string): void;
|
|
660
726
|
onLaunch?(options?: Record<string, unknown>): void;
|
|
661
727
|
onPageNotFound?(res: any): void;
|
|
@@ -694,6 +760,9 @@ declare function addLeadingSlash(path?: string): string;
|
|
|
694
760
|
declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
|
|
695
761
|
declare function stringify(obj?: Record<string, unknown>): string;
|
|
696
762
|
declare function getPath(id: string, options?: Record<string, unknown>): string;
|
|
763
|
+
declare function getOnReadyEventKey(path: string): string;
|
|
764
|
+
declare function getOnShowEventKey(path: string): string;
|
|
765
|
+
declare function getOnHideEventKey(path: string): string;
|
|
697
766
|
declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
|
|
698
767
|
declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
|
|
699
768
|
declare function createRecursiveComponentConfig(componentName?: string): any;
|
|
@@ -707,5 +776,23 @@ declare function hydrate(node: TaroElement | TaroText): MiniData;
|
|
|
707
776
|
declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
|
|
708
777
|
declare const options: Options;
|
|
709
778
|
declare const incrementId: () => () => string;
|
|
779
|
+
declare function isElement(node: TaroNode): node is TaroElement;
|
|
780
|
+
declare function isText(node: TaroNode): node is TaroText;
|
|
781
|
+
declare function isComment(node: TaroNode): boolean;
|
|
782
|
+
declare function isHasExtractProp(el: TaroElement): boolean;
|
|
783
|
+
/**
|
|
784
|
+
* 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
|
|
785
|
+
* @param node 当前组件
|
|
786
|
+
* @param type 事件类型
|
|
787
|
+
*/
|
|
788
|
+
declare function isParentBinded(node: TaroElement | null, type: string): boolean;
|
|
789
|
+
declare function shortcutAttr(key: string): string;
|
|
790
|
+
declare const customWrapperCache: Map<string, Record<string, any>>;
|
|
791
|
+
interface Ctor {
|
|
792
|
+
new (...args: any[]): any;
|
|
793
|
+
}
|
|
794
|
+
declare function extend(ctor: Ctor, methodName: string, options: Func | Record<string, any>): void;
|
|
795
|
+
declare function getComponentsAlias(): any;
|
|
796
|
+
declare function convertNumber2PX(value: number): string;
|
|
710
797
|
export { hooks } from '@tarojs/shared';
|
|
711
|
-
export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
|
|
798
|
+
export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, env, PROPERTY_THRESHOLD, TARO_RUNTIME, HOOKS_APP_ID, SET_DATA, PAGE_INIT, ROOT_STR, HTML, HEAD, BODY, APP, CONTAINER, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, ID, UID, CLASS, STYLE, FOCUS, VIEW, STATIC_VIEW, PURE_VIEW, PROPS, DATASET, OBJECT, VALUE, INPUT, CHANGE, CUSTOM_WRAPPER, TARGET, CURRENT_TARGET, TYPE, CONFIRM, TIME_STAMP, KEY_CODE, TOUCHMOVE, DATE, SET_TIMEOUT, CATCHMOVE, CATCH_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
|
package/dist/runtime.h5.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
var shared = require('@tarojs/shared');
|
|
4
4
|
|
|
5
5
|
const PROPERTY_THRESHOLD = 2046;
|
|
6
|
+
const TARO_RUNTIME = 'Taro runtime';
|
|
7
|
+
const HOOKS_APP_ID = 'taro-app';
|
|
6
8
|
const SET_DATA = '小程序 setData';
|
|
7
9
|
const PAGE_INIT = '页面初始化';
|
|
8
10
|
const ROOT_STR = 'root';
|
|
@@ -21,6 +23,9 @@ const FOCUS = 'focus';
|
|
|
21
23
|
const VIEW = 'view';
|
|
22
24
|
const STATIC_VIEW = 'static-view';
|
|
23
25
|
const PURE_VIEW = 'pure-view';
|
|
26
|
+
const PROPS = 'props';
|
|
27
|
+
const DATASET = 'dataset';
|
|
28
|
+
const OBJECT = 'object';
|
|
24
29
|
const VALUE = 'value';
|
|
25
30
|
const INPUT = 'input';
|
|
26
31
|
const CHANGE = 'change';
|
|
@@ -32,6 +37,8 @@ const CONFIRM = 'confirm';
|
|
|
32
37
|
const TIME_STAMP = 'timeStamp';
|
|
33
38
|
const KEY_CODE = 'keyCode';
|
|
34
39
|
const TOUCHMOVE = 'touchmove';
|
|
40
|
+
const DATE = 'Date';
|
|
41
|
+
const SET_TIMEOUT = 'setTimeout';
|
|
35
42
|
const CATCHMOVE = 'catchMove';
|
|
36
43
|
const CATCH_VIEW = 'catch-view';
|
|
37
44
|
const COMMENT = 'comment';
|
|
@@ -47,13 +54,13 @@ const A = 'a';
|
|
|
47
54
|
/**
|
|
48
55
|
* 页面上下文切换时的行为
|
|
49
56
|
*/
|
|
50
|
-
|
|
57
|
+
exports.CONTEXT_ACTIONS = void 0;
|
|
51
58
|
(function (CONTEXT_ACTIONS) {
|
|
52
59
|
CONTEXT_ACTIONS["INIT"] = "0";
|
|
53
60
|
CONTEXT_ACTIONS["RESTORE"] = "1";
|
|
54
61
|
CONTEXT_ACTIONS["RECOVER"] = "2";
|
|
55
62
|
CONTEXT_ACTIONS["DESTORY"] = "3";
|
|
56
|
-
})(CONTEXT_ACTIONS || (CONTEXT_ACTIONS = {}));
|
|
63
|
+
})(exports.CONTEXT_ACTIONS || (exports.CONTEXT_ACTIONS = {}));
|
|
57
64
|
|
|
58
65
|
const observers = [];
|
|
59
66
|
/** Match two TaroNodes by sid. */
|
|
@@ -229,6 +236,9 @@ function getComponentsAlias() {
|
|
|
229
236
|
}
|
|
230
237
|
return componentsAlias$1;
|
|
231
238
|
}
|
|
239
|
+
function convertNumber2PX(value) {
|
|
240
|
+
return value + 'px';
|
|
241
|
+
}
|
|
232
242
|
|
|
233
243
|
class ClassList {
|
|
234
244
|
constructor(className, el) {
|
|
@@ -349,6 +359,7 @@ let componentsAlias;
|
|
|
349
359
|
* it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
|
|
350
360
|
*/
|
|
351
361
|
function hydrate(node) {
|
|
362
|
+
var _a;
|
|
352
363
|
if (!componentsAlias) {
|
|
353
364
|
// 初始化 componentsAlias
|
|
354
365
|
componentsAlias = getComponentsAlias();
|
|
@@ -361,7 +372,7 @@ function hydrate(node) {
|
|
|
361
372
|
if (isText(node)) {
|
|
362
373
|
return {
|
|
363
374
|
["v" /* Shortcuts.Text */]: node.nodeValue,
|
|
364
|
-
["nn" /* Shortcuts.NodeName */]: componentsAlias[nodeName]._num
|
|
375
|
+
["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
|
|
365
376
|
};
|
|
366
377
|
}
|
|
367
378
|
const data = {
|
|
@@ -1522,13 +1533,13 @@ class TaroEvent {
|
|
|
1522
1533
|
this.defaultPrevented = true;
|
|
1523
1534
|
}
|
|
1524
1535
|
get target() {
|
|
1525
|
-
var _a, _b;
|
|
1536
|
+
var _a, _b, _c;
|
|
1526
1537
|
const cacheTarget = this.cacheTarget;
|
|
1527
1538
|
if (!cacheTarget) {
|
|
1528
1539
|
const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
|
|
1529
|
-
const element = env.document.getElementById(target.id);
|
|
1540
|
+
const element = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
|
|
1530
1541
|
target.dataset = element !== null ? element.dataset : shared.EMPTY_OBJ;
|
|
1531
|
-
for (const key in (
|
|
1542
|
+
for (const key in (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail) {
|
|
1532
1543
|
target[key] = this.mpEvent.detail[key];
|
|
1533
1544
|
}
|
|
1534
1545
|
this.cacheTarget = target;
|
|
@@ -1539,19 +1550,19 @@ class TaroEvent {
|
|
|
1539
1550
|
}
|
|
1540
1551
|
}
|
|
1541
1552
|
get currentTarget() {
|
|
1542
|
-
var _a, _b, _c, _d;
|
|
1553
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1543
1554
|
const cacheCurrentTarget = this.cacheCurrentTarget;
|
|
1544
1555
|
if (!cacheCurrentTarget) {
|
|
1545
1556
|
const doc = env.document;
|
|
1546
1557
|
const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
|
|
1547
|
-
const element = doc.getElementById(currentTarget.id);
|
|
1548
|
-
const targetElement = doc.getElementById(((_c = (
|
|
1558
|
+
const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
|
|
1559
|
+
const targetElement = doc.getElementById(((_e = (_d = (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.sid) || ((_g = (_f = this.mpEvent) === null || _f === void 0 ? void 0 : _f.target) === null || _g === void 0 ? void 0 : _g.id) || null);
|
|
1549
1560
|
if (element === null || (element && element === targetElement)) {
|
|
1550
1561
|
this.cacheCurrentTarget = this.target;
|
|
1551
1562
|
return this.target;
|
|
1552
1563
|
}
|
|
1553
1564
|
currentTarget.dataset = element.dataset;
|
|
1554
|
-
for (const key in (
|
|
1565
|
+
for (const key in (_h = this.mpEvent) === null || _h === void 0 ? void 0 : _h.detail) {
|
|
1555
1566
|
currentTarget[key] = this.mpEvent.detail[key];
|
|
1556
1567
|
}
|
|
1557
1568
|
this.cacheCurrentTarget = currentTarget;
|
|
@@ -2300,9 +2311,6 @@ class AnchorElement extends TaroElement {
|
|
|
2300
2311
|
}
|
|
2301
2312
|
}
|
|
2302
2313
|
|
|
2303
|
-
class CustomWrapperElement extends TaroElement {
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
2314
|
class TaroDocument extends TaroElement {
|
|
2307
2315
|
constructor() {
|
|
2308
2316
|
super();
|
|
@@ -2323,9 +2331,6 @@ class TaroDocument extends TaroElement {
|
|
|
2323
2331
|
case nodeName === A:
|
|
2324
2332
|
element = new AnchorElement();
|
|
2325
2333
|
break;
|
|
2326
|
-
case nodeName === CUSTOM_WRAPPER:
|
|
2327
|
-
element = new CustomWrapperElement();
|
|
2328
|
-
break;
|
|
2329
2334
|
default:
|
|
2330
2335
|
element = new TaroElement();
|
|
2331
2336
|
break;
|
|
@@ -2466,17 +2471,17 @@ class History extends shared.Events {
|
|
|
2466
2471
|
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this, href);
|
|
2467
2472
|
}, null);
|
|
2468
2473
|
// 切换上下文行为
|
|
2469
|
-
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
2474
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, () => {
|
|
2470
2475
|
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
2471
2476
|
}, null);
|
|
2472
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2477
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2473
2478
|
cache$1.set(pageId, {
|
|
2474
2479
|
location: __classPrivateFieldGet(this, _History_location, "f"),
|
|
2475
2480
|
stack: __classPrivateFieldGet(this, _History_stack, "f").slice(),
|
|
2476
2481
|
cur: __classPrivateFieldGet(this, _History_cur, "f")
|
|
2477
2482
|
});
|
|
2478
2483
|
}, null);
|
|
2479
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2484
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2480
2485
|
if (cache$1.has(pageId)) {
|
|
2481
2486
|
const ctx = cache$1.get(pageId);
|
|
2482
2487
|
__classPrivateFieldSet(this, _History_location, ctx.location, "f");
|
|
@@ -2484,7 +2489,7 @@ class History extends shared.Events {
|
|
|
2484
2489
|
__classPrivateFieldSet(this, _History_cur, ctx.cur, "f");
|
|
2485
2490
|
}
|
|
2486
2491
|
}, null);
|
|
2487
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2492
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2488
2493
|
cache$1.delete(pageId);
|
|
2489
2494
|
}, null);
|
|
2490
2495
|
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
@@ -2580,15 +2585,15 @@ class Location extends shared.Events {
|
|
|
2580
2585
|
__classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
|
|
2581
2586
|
}, null);
|
|
2582
2587
|
// 切换上下文行为
|
|
2583
|
-
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
2588
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, () => {
|
|
2584
2589
|
__classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
|
|
2585
2590
|
}, null);
|
|
2586
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2591
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2587
2592
|
cache.set(pageId, {
|
|
2588
2593
|
lastHref: this.href,
|
|
2589
2594
|
});
|
|
2590
2595
|
}, null);
|
|
2591
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2596
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2592
2597
|
// 数据恢复时,不需要执行跳转
|
|
2593
2598
|
if (cache.has(pageId)) {
|
|
2594
2599
|
const ctx = cache.get(pageId);
|
|
@@ -2597,7 +2602,7 @@ class Location extends shared.Events {
|
|
|
2597
2602
|
__classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
|
|
2598
2603
|
}
|
|
2599
2604
|
}, null);
|
|
2600
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2605
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2601
2606
|
cache.delete(pageId);
|
|
2602
2607
|
}, null);
|
|
2603
2608
|
}
|
|
@@ -2855,24 +2860,24 @@ if (process.env.TARO_ENV && !true) {
|
|
|
2855
2860
|
initEvent() {
|
|
2856
2861
|
const _location = this.location;
|
|
2857
2862
|
const _history = this.history;
|
|
2858
|
-
this.on(CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
2863
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
2859
2864
|
// 页面onload,为该页面建立新的上下文信息
|
|
2860
|
-
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
2865
|
+
_location.trigger(exports.CONTEXT_ACTIONS.INIT, pageId);
|
|
2861
2866
|
}, null);
|
|
2862
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2867
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2863
2868
|
// 页面onshow,恢复当前页面的上下文信息
|
|
2864
|
-
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2865
|
-
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2869
|
+
_location.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2870
|
+
_history.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2866
2871
|
}, null);
|
|
2867
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2872
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2868
2873
|
// 页面onhide,缓存当前页面的上下文信息
|
|
2869
|
-
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2870
|
-
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2874
|
+
_location.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2875
|
+
_history.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2871
2876
|
}, null);
|
|
2872
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2877
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2873
2878
|
// 页面onunload,清除当前页面的上下文信息
|
|
2874
|
-
_location.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2875
|
-
_history.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2879
|
+
_location.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2880
|
+
_history.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2876
2881
|
}, null);
|
|
2877
2882
|
}
|
|
2878
2883
|
get document() {
|
|
@@ -3074,8 +3079,19 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3074
3079
|
}
|
|
3075
3080
|
};
|
|
3076
3081
|
LIFECYCLES.forEach((lifecycle) => {
|
|
3082
|
+
let isDefer = false;
|
|
3083
|
+
lifecycle = lifecycle.replace(/^defer:/, () => {
|
|
3084
|
+
isDefer = true;
|
|
3085
|
+
return '';
|
|
3086
|
+
});
|
|
3077
3087
|
config[lifecycle] = function () {
|
|
3078
|
-
|
|
3088
|
+
const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
3089
|
+
if (isDefer) {
|
|
3090
|
+
hasLoaded.then(exec);
|
|
3091
|
+
}
|
|
3092
|
+
else {
|
|
3093
|
+
return exec();
|
|
3094
|
+
}
|
|
3079
3095
|
};
|
|
3080
3096
|
});
|
|
3081
3097
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
@@ -3114,7 +3130,8 @@ function createComponentConfig(component, componentName, data) {
|
|
|
3114
3130
|
[ATTACHED]() {
|
|
3115
3131
|
var _a;
|
|
3116
3132
|
perf.start(PAGE_INIT);
|
|
3117
|
-
|
|
3133
|
+
this.pageIdCache = ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId();
|
|
3134
|
+
const path = getPath(id, { id: this.pageIdCache });
|
|
3118
3135
|
Current.app.mount(component, path, () => {
|
|
3119
3136
|
componentElement = env.document.getElementById(path);
|
|
3120
3137
|
shared.ensure(componentElement !== null, '没有找到组件实例。');
|
|
@@ -3123,7 +3140,7 @@ function createComponentConfig(component, componentName, data) {
|
|
|
3123
3140
|
});
|
|
3124
3141
|
},
|
|
3125
3142
|
[DETACHED]() {
|
|
3126
|
-
const path = getPath(id, { id: this.
|
|
3143
|
+
const path = getPath(id, { id: this.pageIdCache });
|
|
3127
3144
|
Current.app.unmount(path, () => {
|
|
3128
3145
|
instances.delete(path);
|
|
3129
3146
|
if (componentElement) {
|
|
@@ -3239,37 +3256,99 @@ Object.defineProperty(exports, 'hooks', {
|
|
|
3239
3256
|
enumerable: true,
|
|
3240
3257
|
get: function () { return shared.hooks; }
|
|
3241
3258
|
});
|
|
3259
|
+
exports.A = A;
|
|
3260
|
+
exports.APP = APP;
|
|
3261
|
+
exports.BEHAVIORS = BEHAVIORS;
|
|
3262
|
+
exports.BODY = BODY;
|
|
3263
|
+
exports.CATCHMOVE = CATCHMOVE;
|
|
3264
|
+
exports.CATCH_VIEW = CATCH_VIEW;
|
|
3265
|
+
exports.CHANGE = CHANGE;
|
|
3266
|
+
exports.CLASS = CLASS;
|
|
3267
|
+
exports.COMMENT = COMMENT;
|
|
3268
|
+
exports.CONFIRM = CONFIRM;
|
|
3269
|
+
exports.CONTAINER = CONTAINER;
|
|
3270
|
+
exports.CURRENT_TARGET = CURRENT_TARGET;
|
|
3271
|
+
exports.CUSTOM_WRAPPER = CUSTOM_WRAPPER;
|
|
3242
3272
|
exports.Current = Current;
|
|
3273
|
+
exports.DATASET = DATASET;
|
|
3274
|
+
exports.DATE = DATE;
|
|
3275
|
+
exports.DOCUMENT_ELEMENT_NAME = DOCUMENT_ELEMENT_NAME;
|
|
3276
|
+
exports.DOCUMENT_FRAGMENT = DOCUMENT_FRAGMENT;
|
|
3277
|
+
exports.EVENT_CALLBACK_RESULT = EVENT_CALLBACK_RESULT;
|
|
3278
|
+
exports.EXTERNAL_CLASSES = EXTERNAL_CLASSES;
|
|
3279
|
+
exports.FOCUS = FOCUS;
|
|
3243
3280
|
exports.FormElement = FormElement;
|
|
3281
|
+
exports.HEAD = HEAD;
|
|
3282
|
+
exports.HOOKS_APP_ID = HOOKS_APP_ID;
|
|
3283
|
+
exports.HTML = HTML;
|
|
3244
3284
|
exports.History = History;
|
|
3285
|
+
exports.ID = ID;
|
|
3286
|
+
exports.INPUT = INPUT;
|
|
3287
|
+
exports.KEY_CODE = KEY_CODE;
|
|
3245
3288
|
exports.Location = Location;
|
|
3246
3289
|
exports.MutationObserver = MutationObserver;
|
|
3290
|
+
exports.OBJECT = OBJECT;
|
|
3291
|
+
exports.ON_HIDE = ON_HIDE;
|
|
3292
|
+
exports.ON_LOAD = ON_LOAD;
|
|
3293
|
+
exports.ON_READY = ON_READY;
|
|
3294
|
+
exports.ON_SHOW = ON_SHOW;
|
|
3295
|
+
exports.OPTIONS = OPTIONS;
|
|
3296
|
+
exports.PAGE_INIT = PAGE_INIT;
|
|
3297
|
+
exports.PROPERTY_THRESHOLD = PROPERTY_THRESHOLD;
|
|
3298
|
+
exports.PROPS = PROPS;
|
|
3299
|
+
exports.PURE_VIEW = PURE_VIEW;
|
|
3300
|
+
exports.ROOT_STR = ROOT_STR;
|
|
3301
|
+
exports.SET_DATA = SET_DATA;
|
|
3302
|
+
exports.SET_TIMEOUT = SET_TIMEOUT;
|
|
3303
|
+
exports.STATIC_VIEW = STATIC_VIEW;
|
|
3304
|
+
exports.STYLE = STYLE;
|
|
3247
3305
|
exports.SVGElement = SVGElement;
|
|
3248
3306
|
exports.Style = Style;
|
|
3307
|
+
exports.TARGET = TARGET;
|
|
3308
|
+
exports.TARO_RUNTIME = TARO_RUNTIME;
|
|
3309
|
+
exports.TIME_STAMP = TIME_STAMP;
|
|
3310
|
+
exports.TOUCHMOVE = TOUCHMOVE;
|
|
3311
|
+
exports.TYPE = TYPE;
|
|
3249
3312
|
exports.TaroElement = TaroElement;
|
|
3250
3313
|
exports.TaroEvent = TaroEvent;
|
|
3251
3314
|
exports.TaroNode = TaroNode;
|
|
3252
3315
|
exports.TaroRootElement = TaroRootElement;
|
|
3253
3316
|
exports.TaroText = TaroText;
|
|
3317
|
+
exports.UID = UID;
|
|
3254
3318
|
exports.URL = URL;
|
|
3255
3319
|
exports.URLSearchParams = URLSearchParams;
|
|
3320
|
+
exports.VALUE = VALUE;
|
|
3321
|
+
exports.VIEW = VIEW;
|
|
3256
3322
|
exports.addLeadingSlash = addLeadingSlash;
|
|
3257
3323
|
exports.cancelAnimationFrame = _caf;
|
|
3324
|
+
exports.convertNumber2PX = convertNumber2PX;
|
|
3258
3325
|
exports.createComponentConfig = createComponentConfig;
|
|
3259
3326
|
exports.createEvent = createEvent;
|
|
3260
3327
|
exports.createPageConfig = createPageConfig;
|
|
3261
3328
|
exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
|
|
3329
|
+
exports.customWrapperCache = customWrapperCache;
|
|
3330
|
+
exports.env = env;
|
|
3262
3331
|
exports.eventCenter = eventCenter;
|
|
3263
3332
|
exports.eventHandler = eventHandler;
|
|
3264
3333
|
exports.eventSource = eventSource;
|
|
3334
|
+
exports.extend = extend;
|
|
3335
|
+
exports.getComponentsAlias = getComponentsAlias;
|
|
3265
3336
|
exports.getComputedStyle = getComputedStyle;
|
|
3266
3337
|
exports.getCurrentInstance = getCurrentInstance;
|
|
3338
|
+
exports.getOnHideEventKey = getOnHideEventKey;
|
|
3339
|
+
exports.getOnReadyEventKey = getOnReadyEventKey;
|
|
3340
|
+
exports.getOnShowEventKey = getOnShowEventKey;
|
|
3267
3341
|
exports.getPageInstance = getPageInstance;
|
|
3268
3342
|
exports.getPath = getPath;
|
|
3269
3343
|
exports.history = history;
|
|
3270
3344
|
exports.hydrate = hydrate;
|
|
3271
3345
|
exports.incrementId = incrementId;
|
|
3272
3346
|
exports.injectPageInstance = injectPageInstance;
|
|
3347
|
+
exports.isComment = isComment;
|
|
3348
|
+
exports.isElement = isElement;
|
|
3349
|
+
exports.isHasExtractProp = isHasExtractProp;
|
|
3350
|
+
exports.isParentBinded = isParentBinded;
|
|
3351
|
+
exports.isText = isText;
|
|
3273
3352
|
exports.location = location;
|
|
3274
3353
|
exports.navigator = nav;
|
|
3275
3354
|
exports.nextTick = nextTick;
|
|
@@ -3278,4 +3357,5 @@ exports.parseUrl = parseUrl;
|
|
|
3278
3357
|
exports.removePageInstance = removePageInstance;
|
|
3279
3358
|
exports.requestAnimationFrame = _raf;
|
|
3280
3359
|
exports.safeExecute = safeExecute;
|
|
3360
|
+
exports.shortcutAttr = shortcutAttr;
|
|
3281
3361
|
exports.stringify = stringify;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/runtime",
|
|
3
|
-
"version": "3.7.0-alpha.
|
|
3
|
+
"version": "3.7.0-alpha.8",
|
|
4
4
|
"description": "taro runtime for mini apps.",
|
|
5
5
|
"main:h5": "dist/runtime.h5.js",
|
|
6
6
|
"main": "dist/runtime.esm.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"lodash-es": "4.17.21",
|
|
23
|
-
"@tarojs/shared": "3.7.0-alpha.
|
|
23
|
+
"@tarojs/shared": "3.7.0-alpha.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@rollup/plugin-buble": "^0.21.3",
|