@tarojs/runtime 3.7.0-alpha.7 → 3.7.0-beta.1
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 +135 -66
- package/dist/runtime.cjs.js +108 -51
- package/dist/runtime.esm.d.ts +135 -66
- package/dist/runtime.esm.js +29 -18
- package/dist/runtime.esm.js.map +1 -1
- package/dist/runtime.h5.d.ts +135 -66
- package/dist/runtime.h5.js +105 -38
- package/package.json +2 -2
package/dist/runtime.cjs.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;
|
|
@@ -708,4 +777,4 @@ declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
|
|
|
708
777
|
declare const options: Options;
|
|
709
778
|
declare const incrementId: () => () => string;
|
|
710
779
|
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 };
|
|
780
|
+
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, 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.cjs.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
var shared = require('@tarojs/shared');
|
|
4
4
|
|
|
5
5
|
var PROPERTY_THRESHOLD = 2046;
|
|
6
|
+
var TARO_RUNTIME = 'Taro runtime';
|
|
7
|
+
var HOOKS_APP_ID = 'taro-app';
|
|
6
8
|
var SET_DATA = '小程序 setData';
|
|
7
9
|
var PAGE_INIT = '页面初始化';
|
|
8
10
|
var ROOT_STR = 'root';
|
|
@@ -35,6 +37,8 @@ var CONFIRM = 'confirm';
|
|
|
35
37
|
var TIME_STAMP = 'timeStamp';
|
|
36
38
|
var KEY_CODE = 'keyCode';
|
|
37
39
|
var TOUCHMOVE = 'touchmove';
|
|
40
|
+
var DATE = 'Date';
|
|
41
|
+
var SET_TIMEOUT = 'setTimeout';
|
|
38
42
|
var CATCHMOVE = 'catchMove';
|
|
39
43
|
var CATCH_VIEW = 'catch-view';
|
|
40
44
|
var COMMENT = 'comment';
|
|
@@ -50,13 +54,13 @@ var A = 'a';
|
|
|
50
54
|
/**
|
|
51
55
|
* 页面上下文切换时的行为
|
|
52
56
|
*/
|
|
53
|
-
|
|
57
|
+
exports.CONTEXT_ACTIONS = void 0;
|
|
54
58
|
(function (CONTEXT_ACTIONS) {
|
|
55
59
|
CONTEXT_ACTIONS["INIT"] = "0";
|
|
56
60
|
CONTEXT_ACTIONS["RESTORE"] = "1";
|
|
57
61
|
CONTEXT_ACTIONS["RECOVER"] = "2";
|
|
58
62
|
CONTEXT_ACTIONS["DESTORY"] = "3";
|
|
59
|
-
})(CONTEXT_ACTIONS || (CONTEXT_ACTIONS = {}));
|
|
63
|
+
})(exports.CONTEXT_ACTIONS || (exports.CONTEXT_ACTIONS = {}));
|
|
60
64
|
|
|
61
65
|
var observers = [];
|
|
62
66
|
/**
|
|
@@ -427,6 +431,7 @@ var componentsAlias;
|
|
|
427
431
|
function hydrate(node) {
|
|
428
432
|
var obj;
|
|
429
433
|
|
|
434
|
+
var _a;
|
|
430
435
|
if (!componentsAlias) {
|
|
431
436
|
// 初始化 componentsAlias
|
|
432
437
|
componentsAlias = getComponentsAlias();
|
|
@@ -437,7 +442,7 @@ function hydrate(node) {
|
|
|
437
442
|
}
|
|
438
443
|
var nodeName = node.nodeName;
|
|
439
444
|
if (isText(node)) {
|
|
440
|
-
return ( obj = {}, obj["v" /* Shortcuts.Text */] = node.nodeValue, obj["nn" /* Shortcuts.NodeName */] = componentsAlias[nodeName]._num, obj );
|
|
445
|
+
return ( obj = {}, obj["v" /* Shortcuts.Text */] = node.nodeValue, obj["nn" /* Shortcuts.NodeName */] = ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8', obj );
|
|
441
446
|
}
|
|
442
447
|
var data = {};
|
|
443
448
|
data["nn" /* Shortcuts.NodeName */] = nodeName;
|
|
@@ -2537,13 +2542,13 @@ TaroEvent.prototype.preventDefault = function preventDefault () {
|
|
|
2537
2542
|
this.defaultPrevented = true;
|
|
2538
2543
|
};
|
|
2539
2544
|
prototypeAccessors$1.target.get = function () {
|
|
2540
|
-
var _a, _b;
|
|
2545
|
+
var _a, _b, _c;
|
|
2541
2546
|
var cacheTarget = this.cacheTarget;
|
|
2542
2547
|
if (!cacheTarget) {
|
|
2543
2548
|
var target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
|
|
2544
|
-
var element = env.document.getElementById(target.id);
|
|
2549
|
+
var element = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
|
|
2545
2550
|
target.dataset = element !== null ? element.dataset : shared.EMPTY_OBJ;
|
|
2546
|
-
for (var key in (
|
|
2551
|
+
for (var key in (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail) {
|
|
2547
2552
|
target[key] = this.mpEvent.detail[key];
|
|
2548
2553
|
}
|
|
2549
2554
|
this.cacheTarget = target;
|
|
@@ -2554,19 +2559,19 @@ prototypeAccessors$1.target.get = function () {
|
|
|
2554
2559
|
}
|
|
2555
2560
|
};
|
|
2556
2561
|
prototypeAccessors$1.currentTarget.get = function () {
|
|
2557
|
-
var _a, _b, _c, _d;
|
|
2562
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2558
2563
|
var cacheCurrentTarget = this.cacheCurrentTarget;
|
|
2559
2564
|
if (!cacheCurrentTarget) {
|
|
2560
2565
|
var doc = env.document;
|
|
2561
2566
|
var currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
|
|
2562
|
-
var element = doc.getElementById(currentTarget.id);
|
|
2563
|
-
var targetElement = doc.getElementById(((_c = (
|
|
2567
|
+
var element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
|
|
2568
|
+
var 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);
|
|
2564
2569
|
if (element === null || (element && element === targetElement)) {
|
|
2565
2570
|
this.cacheCurrentTarget = this.target;
|
|
2566
2571
|
return this.target;
|
|
2567
2572
|
}
|
|
2568
2573
|
currentTarget.dataset = element.dataset;
|
|
2569
|
-
for (var key in (
|
|
2574
|
+
for (var key in (_h = this.mpEvent) === null || _h === void 0 ? void 0 : _h.detail) {
|
|
2570
2575
|
currentTarget[key] = this.mpEvent.detail[key];
|
|
2571
2576
|
}
|
|
2572
2577
|
this.cacheCurrentTarget = currentTarget;
|
|
@@ -3393,18 +3398,6 @@ var AnchorElement = /*@__PURE__*/(function (TaroElement) {
|
|
|
3393
3398
|
return AnchorElement;
|
|
3394
3399
|
}(TaroElement));
|
|
3395
3400
|
|
|
3396
|
-
var CustomWrapperElement = /*@__PURE__*/(function (TaroElement) {
|
|
3397
|
-
function CustomWrapperElement () {
|
|
3398
|
-
TaroElement.apply(this, arguments);
|
|
3399
|
-
}if ( TaroElement ) CustomWrapperElement.__proto__ = TaroElement;
|
|
3400
|
-
CustomWrapperElement.prototype = Object.create( TaroElement && TaroElement.prototype );
|
|
3401
|
-
CustomWrapperElement.prototype.constructor = CustomWrapperElement;
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
return CustomWrapperElement;
|
|
3406
|
-
}(TaroElement));
|
|
3407
|
-
|
|
3408
3401
|
var TaroDocument = /*@__PURE__*/(function (TaroElement) {
|
|
3409
3402
|
function TaroDocument() {
|
|
3410
3403
|
TaroElement.call(this);
|
|
@@ -3431,9 +3424,6 @@ var TaroDocument = /*@__PURE__*/(function (TaroElement) {
|
|
|
3431
3424
|
case nodeName === A:
|
|
3432
3425
|
element = new AnchorElement();
|
|
3433
3426
|
break;
|
|
3434
|
-
case nodeName === CUSTOM_WRAPPER:
|
|
3435
|
-
element = new CustomWrapperElement();
|
|
3436
|
-
break;
|
|
3437
3427
|
default:
|
|
3438
3428
|
element = new TaroElement();
|
|
3439
3429
|
break;
|
|
@@ -3578,17 +3568,17 @@ var History = /*@__PURE__*/(function (Events) {
|
|
|
3578
3568
|
__classPrivateFieldGet(this$1$1, _History_instances, "m", _History_reset).call(this$1$1, href);
|
|
3579
3569
|
}, null);
|
|
3580
3570
|
// 切换上下文行为
|
|
3581
|
-
this.on(CONTEXT_ACTIONS.INIT, function () {
|
|
3571
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, function () {
|
|
3582
3572
|
__classPrivateFieldGet(this$1$1, _History_instances, "m", _History_reset).call(this$1$1);
|
|
3583
3573
|
}, null);
|
|
3584
|
-
this.on(CONTEXT_ACTIONS.RESTORE, function (pageId) {
|
|
3574
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, function (pageId) {
|
|
3585
3575
|
cache$1.set(pageId, {
|
|
3586
3576
|
location: __classPrivateFieldGet(this$1$1, _History_location, "f"),
|
|
3587
3577
|
stack: __classPrivateFieldGet(this$1$1, _History_stack, "f").slice(),
|
|
3588
3578
|
cur: __classPrivateFieldGet(this$1$1, _History_cur, "f")
|
|
3589
3579
|
});
|
|
3590
3580
|
}, null);
|
|
3591
|
-
this.on(CONTEXT_ACTIONS.RECOVER, function (pageId) {
|
|
3581
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, function (pageId) {
|
|
3592
3582
|
if (cache$1.has(pageId)) {
|
|
3593
3583
|
var ctx = cache$1.get(pageId);
|
|
3594
3584
|
__classPrivateFieldSet(this$1$1, _History_location, ctx.location, "f");
|
|
@@ -3596,7 +3586,7 @@ var History = /*@__PURE__*/(function (Events) {
|
|
|
3596
3586
|
__classPrivateFieldSet(this$1$1, _History_cur, ctx.cur, "f");
|
|
3597
3587
|
}
|
|
3598
3588
|
}, null);
|
|
3599
|
-
this.on(CONTEXT_ACTIONS.DESTORY, function (pageId) {
|
|
3589
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, function (pageId) {
|
|
3600
3590
|
cache$1.delete(pageId);
|
|
3601
3591
|
}, null);
|
|
3602
3592
|
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
@@ -3706,15 +3696,15 @@ var Location = /*@__PURE__*/(function (Events) {
|
|
|
3706
3696
|
__classPrivateFieldSet(this$1$1, _Location_noCheckUrl, false, "f");
|
|
3707
3697
|
}, null);
|
|
3708
3698
|
// 切换上下文行为
|
|
3709
|
-
this.on(CONTEXT_ACTIONS.INIT, function () {
|
|
3699
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, function () {
|
|
3710
3700
|
__classPrivateFieldGet(this$1$1, _Location_instances, "m", _Location_reset).call(this$1$1);
|
|
3711
3701
|
}, null);
|
|
3712
|
-
this.on(CONTEXT_ACTIONS.RESTORE, function (pageId) {
|
|
3702
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, function (pageId) {
|
|
3713
3703
|
cache.set(pageId, {
|
|
3714
3704
|
lastHref: this$1$1.href,
|
|
3715
3705
|
});
|
|
3716
3706
|
}, null);
|
|
3717
|
-
this.on(CONTEXT_ACTIONS.RECOVER, function (pageId) {
|
|
3707
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, function (pageId) {
|
|
3718
3708
|
// 数据恢复时,不需要执行跳转
|
|
3719
3709
|
if (cache.has(pageId)) {
|
|
3720
3710
|
var ctx = cache.get(pageId);
|
|
@@ -3723,7 +3713,7 @@ var Location = /*@__PURE__*/(function (Events) {
|
|
|
3723
3713
|
__classPrivateFieldSet(this$1$1, _Location_noCheckUrl, false, "f");
|
|
3724
3714
|
}
|
|
3725
3715
|
}, null);
|
|
3726
|
-
this.on(CONTEXT_ACTIONS.DESTORY, function (pageId) {
|
|
3716
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, function (pageId) {
|
|
3727
3717
|
cache.delete(pageId);
|
|
3728
3718
|
}, null);
|
|
3729
3719
|
}
|
|
@@ -4024,24 +4014,24 @@ if (process.env.TARO_ENV && !shared.isWebPlatform()) {
|
|
|
4024
4014
|
Window.prototype.initEvent = function initEvent () {
|
|
4025
4015
|
var _location = this.location;
|
|
4026
4016
|
var _history = this.history;
|
|
4027
|
-
this.on(CONTEXT_ACTIONS.INIT, function (pageId) {
|
|
4017
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, function (pageId) {
|
|
4028
4018
|
// 页面onload,为该页面建立新的上下文信息
|
|
4029
|
-
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
4019
|
+
_location.trigger(exports.CONTEXT_ACTIONS.INIT, pageId);
|
|
4030
4020
|
}, null);
|
|
4031
|
-
this.on(CONTEXT_ACTIONS.RECOVER, function (pageId) {
|
|
4021
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, function (pageId) {
|
|
4032
4022
|
// 页面onshow,恢复当前页面的上下文信息
|
|
4033
|
-
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
4034
|
-
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
4023
|
+
_location.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
|
|
4024
|
+
_history.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
|
|
4035
4025
|
}, null);
|
|
4036
|
-
this.on(CONTEXT_ACTIONS.RESTORE, function (pageId) {
|
|
4026
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, function (pageId) {
|
|
4037
4027
|
// 页面onhide,缓存当前页面的上下文信息
|
|
4038
|
-
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
4039
|
-
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
4028
|
+
_location.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
|
|
4029
|
+
_history.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
|
|
4040
4030
|
}, null);
|
|
4041
|
-
this.on(CONTEXT_ACTIONS.DESTORY, function (pageId) {
|
|
4031
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, function (pageId) {
|
|
4042
4032
|
// 页面onunload,清除当前页面的上下文信息
|
|
4043
|
-
_location.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
4044
|
-
_history.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
4033
|
+
_location.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
|
|
4034
|
+
_history.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
|
|
4045
4035
|
}, null);
|
|
4046
4036
|
};
|
|
4047
4037
|
prototypeAccessors.document.get = function () {
|
|
@@ -4212,7 +4202,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4212
4202
|
setCurrentRouter(this);
|
|
4213
4203
|
// 初始化当前页面的上下文信息
|
|
4214
4204
|
if (!isWeb) {
|
|
4215
|
-
exports.window.trigger(CONTEXT_ACTIONS.INIT, $taroPath);
|
|
4205
|
+
exports.window.trigger(exports.CONTEXT_ACTIONS.INIT, $taroPath);
|
|
4216
4206
|
}
|
|
4217
4207
|
var mount = function () {
|
|
4218
4208
|
Current.app.mount(component, $taroPath, function () {
|
|
@@ -4240,7 +4230,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4240
4230
|
var $taroPath = this.$taroPath;
|
|
4241
4231
|
// 销毁当前页面的上下文信息
|
|
4242
4232
|
if (!isWeb) {
|
|
4243
|
-
exports.window.trigger(CONTEXT_ACTIONS.DESTORY, $taroPath);
|
|
4233
|
+
exports.window.trigger(exports.CONTEXT_ACTIONS.DESTORY, $taroPath);
|
|
4244
4234
|
}
|
|
4245
4235
|
// 触发onUnload生命周期
|
|
4246
4236
|
safeExecute($taroPath, ONUNLOAD);
|
|
@@ -4279,7 +4269,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4279
4269
|
setCurrentRouter(this$1$1);
|
|
4280
4270
|
// 恢复上下文信息
|
|
4281
4271
|
if (!isWeb) {
|
|
4282
|
-
exports.window.trigger(CONTEXT_ACTIONS.RECOVER, this$1$1.$taroPath);
|
|
4272
|
+
exports.window.trigger(exports.CONTEXT_ACTIONS.RECOVER, this$1$1.$taroPath);
|
|
4283
4273
|
}
|
|
4284
4274
|
// 触发生命周期
|
|
4285
4275
|
safeExecute(this$1$1.$taroPath, ON_SHOW, options);
|
|
@@ -4290,7 +4280,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4290
4280
|
config[ONHIDE] = function () {
|
|
4291
4281
|
// 缓存当前页面上下文信息
|
|
4292
4282
|
if (!isWeb) {
|
|
4293
|
-
exports.window.trigger(CONTEXT_ACTIONS.RESTORE, this.$taroPath);
|
|
4283
|
+
exports.window.trigger(exports.CONTEXT_ACTIONS.RESTORE, this.$taroPath);
|
|
4294
4284
|
}
|
|
4295
4285
|
// 设置 Current 的 page 和 router
|
|
4296
4286
|
if (Current.page === this) {
|
|
@@ -4303,11 +4293,24 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4303
4293
|
eventCenter.trigger(getOnHideEventKey(id));
|
|
4304
4294
|
};
|
|
4305
4295
|
LIFECYCLES.forEach(function (lifecycle) {
|
|
4296
|
+
var isDefer = false;
|
|
4297
|
+
lifecycle = lifecycle.replace(/^defer:/, function () {
|
|
4298
|
+
isDefer = true;
|
|
4299
|
+
return '';
|
|
4300
|
+
});
|
|
4306
4301
|
config[lifecycle] = function () {
|
|
4302
|
+
var arguments$1 = arguments;
|
|
4303
|
+
var this$1$1 = this;
|
|
4307
4304
|
var i = arguments.length, argsArray = Array(i);
|
|
4308
4305
|
while ( i-- ) argsArray[i] = arguments[i];
|
|
4309
4306
|
|
|
4310
|
-
return safeExecute.apply(void 0, [ this.$taroPath, lifecycle ].concat(
|
|
4307
|
+
var exec = function () { return safeExecute.apply(void 0, [ this$1$1.$taroPath, lifecycle ].concat( arguments$1 )); };
|
|
4308
|
+
if (isDefer) {
|
|
4309
|
+
hasLoaded.then(exec);
|
|
4310
|
+
}
|
|
4311
|
+
else {
|
|
4312
|
+
return exec();
|
|
4313
|
+
}
|
|
4311
4314
|
};
|
|
4312
4315
|
});
|
|
4313
4316
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
@@ -4353,7 +4356,8 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4353
4356
|
|
|
4354
4357
|
var _a;
|
|
4355
4358
|
perf.start(PAGE_INIT);
|
|
4356
|
-
|
|
4359
|
+
this.pageIdCache = ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId();
|
|
4360
|
+
var path = getPath(id, { id: this.pageIdCache });
|
|
4357
4361
|
Current.app.mount(component, path, function () {
|
|
4358
4362
|
componentElement = env.document.getElementById(path);
|
|
4359
4363
|
shared.ensure(componentElement !== null, '没有找到组件实例。');
|
|
@@ -4366,7 +4370,7 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4366
4370
|
});
|
|
4367
4371
|
};
|
|
4368
4372
|
config[DETACHED] = function () {
|
|
4369
|
-
var path = getPath(id, { id: this.
|
|
4373
|
+
var path = getPath(id, { id: this.pageIdCache });
|
|
4370
4374
|
Current.app.unmount(path, function () {
|
|
4371
4375
|
instances.delete(path);
|
|
4372
4376
|
if (componentElement) {
|
|
@@ -4483,31 +4487,84 @@ Object.defineProperty(exports, 'hooks', {
|
|
|
4483
4487
|
enumerable: true,
|
|
4484
4488
|
get: function () { return shared.hooks; }
|
|
4485
4489
|
});
|
|
4490
|
+
exports.A = A;
|
|
4491
|
+
exports.APP = APP;
|
|
4492
|
+
exports.BEHAVIORS = BEHAVIORS;
|
|
4493
|
+
exports.BODY = BODY;
|
|
4494
|
+
exports.CATCHMOVE = CATCHMOVE;
|
|
4495
|
+
exports.CATCH_VIEW = CATCH_VIEW;
|
|
4496
|
+
exports.CHANGE = CHANGE;
|
|
4497
|
+
exports.CLASS = CLASS;
|
|
4498
|
+
exports.COMMENT = COMMENT;
|
|
4499
|
+
exports.CONFIRM = CONFIRM;
|
|
4500
|
+
exports.CONTAINER = CONTAINER;
|
|
4501
|
+
exports.CURRENT_TARGET = CURRENT_TARGET;
|
|
4502
|
+
exports.CUSTOM_WRAPPER = CUSTOM_WRAPPER;
|
|
4486
4503
|
exports.Current = Current;
|
|
4504
|
+
exports.DATASET = DATASET;
|
|
4505
|
+
exports.DATE = DATE;
|
|
4506
|
+
exports.DOCUMENT_ELEMENT_NAME = DOCUMENT_ELEMENT_NAME;
|
|
4507
|
+
exports.DOCUMENT_FRAGMENT = DOCUMENT_FRAGMENT;
|
|
4508
|
+
exports.EVENT_CALLBACK_RESULT = EVENT_CALLBACK_RESULT;
|
|
4509
|
+
exports.EXTERNAL_CLASSES = EXTERNAL_CLASSES;
|
|
4510
|
+
exports.FOCUS = FOCUS;
|
|
4487
4511
|
exports.FormElement = FormElement;
|
|
4512
|
+
exports.HEAD = HEAD;
|
|
4513
|
+
exports.HOOKS_APP_ID = HOOKS_APP_ID;
|
|
4514
|
+
exports.HTML = HTML;
|
|
4488
4515
|
exports.History = History;
|
|
4516
|
+
exports.ID = ID;
|
|
4517
|
+
exports.INPUT = INPUT;
|
|
4518
|
+
exports.KEY_CODE = KEY_CODE;
|
|
4489
4519
|
exports.Location = Location;
|
|
4490
4520
|
exports.MutationObserver = MutationObserver;
|
|
4521
|
+
exports.OBJECT = OBJECT;
|
|
4522
|
+
exports.ON_HIDE = ON_HIDE;
|
|
4523
|
+
exports.ON_LOAD = ON_LOAD;
|
|
4524
|
+
exports.ON_READY = ON_READY;
|
|
4525
|
+
exports.ON_SHOW = ON_SHOW;
|
|
4526
|
+
exports.OPTIONS = OPTIONS;
|
|
4527
|
+
exports.PAGE_INIT = PAGE_INIT;
|
|
4528
|
+
exports.PROPERTY_THRESHOLD = PROPERTY_THRESHOLD;
|
|
4529
|
+
exports.PROPS = PROPS;
|
|
4530
|
+
exports.PURE_VIEW = PURE_VIEW;
|
|
4531
|
+
exports.ROOT_STR = ROOT_STR;
|
|
4532
|
+
exports.SET_DATA = SET_DATA;
|
|
4533
|
+
exports.SET_TIMEOUT = SET_TIMEOUT;
|
|
4534
|
+
exports.STATIC_VIEW = STATIC_VIEW;
|
|
4535
|
+
exports.STYLE = STYLE;
|
|
4491
4536
|
exports.SVGElement = SVGElement;
|
|
4492
4537
|
exports.Style = Style;
|
|
4538
|
+
exports.TARGET = TARGET;
|
|
4539
|
+
exports.TARO_RUNTIME = TARO_RUNTIME;
|
|
4540
|
+
exports.TIME_STAMP = TIME_STAMP;
|
|
4541
|
+
exports.TOUCHMOVE = TOUCHMOVE;
|
|
4542
|
+
exports.TYPE = TYPE;
|
|
4493
4543
|
exports.TaroElement = TaroElement;
|
|
4494
4544
|
exports.TaroEvent = TaroEvent;
|
|
4495
4545
|
exports.TaroNode = TaroNode;
|
|
4496
4546
|
exports.TaroRootElement = TaroRootElement;
|
|
4497
4547
|
exports.TaroText = TaroText;
|
|
4548
|
+
exports.UID = UID;
|
|
4498
4549
|
exports.URL = URL;
|
|
4499
4550
|
exports.URLSearchParams = URLSearchParams;
|
|
4551
|
+
exports.VALUE = VALUE;
|
|
4552
|
+
exports.VIEW = VIEW;
|
|
4500
4553
|
exports.addLeadingSlash = addLeadingSlash;
|
|
4501
4554
|
exports.cancelAnimationFrame = _caf;
|
|
4502
4555
|
exports.createComponentConfig = createComponentConfig;
|
|
4503
4556
|
exports.createEvent = createEvent;
|
|
4504
4557
|
exports.createPageConfig = createPageConfig;
|
|
4505
4558
|
exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
|
|
4559
|
+
exports.env = env;
|
|
4506
4560
|
exports.eventCenter = eventCenter;
|
|
4507
4561
|
exports.eventHandler = eventHandler;
|
|
4508
4562
|
exports.eventSource = eventSource;
|
|
4509
4563
|
exports.getComputedStyle = getComputedStyle;
|
|
4510
4564
|
exports.getCurrentInstance = getCurrentInstance;
|
|
4565
|
+
exports.getOnHideEventKey = getOnHideEventKey;
|
|
4566
|
+
exports.getOnReadyEventKey = getOnReadyEventKey;
|
|
4567
|
+
exports.getOnShowEventKey = getOnShowEventKey;
|
|
4511
4568
|
exports.getPageInstance = getPageInstance;
|
|
4512
4569
|
exports.getPath = getPath;
|
|
4513
4570
|
exports.history = history;
|