@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.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;
|
|
@@ -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.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. */
|
|
@@ -349,6 +356,7 @@ let componentsAlias;
|
|
|
349
356
|
* it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
|
|
350
357
|
*/
|
|
351
358
|
function hydrate(node) {
|
|
359
|
+
var _a;
|
|
352
360
|
if (!componentsAlias) {
|
|
353
361
|
// 初始化 componentsAlias
|
|
354
362
|
componentsAlias = getComponentsAlias();
|
|
@@ -361,7 +369,7 @@ function hydrate(node) {
|
|
|
361
369
|
if (isText(node)) {
|
|
362
370
|
return {
|
|
363
371
|
["v" /* Shortcuts.Text */]: node.nodeValue,
|
|
364
|
-
["nn" /* Shortcuts.NodeName */]: componentsAlias[nodeName]._num
|
|
372
|
+
["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
|
|
365
373
|
};
|
|
366
374
|
}
|
|
367
375
|
const data = {
|
|
@@ -1522,13 +1530,13 @@ class TaroEvent {
|
|
|
1522
1530
|
this.defaultPrevented = true;
|
|
1523
1531
|
}
|
|
1524
1532
|
get target() {
|
|
1525
|
-
var _a, _b;
|
|
1533
|
+
var _a, _b, _c;
|
|
1526
1534
|
const cacheTarget = this.cacheTarget;
|
|
1527
1535
|
if (!cacheTarget) {
|
|
1528
1536
|
const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
|
|
1529
|
-
const element = env.document.getElementById(target.id);
|
|
1537
|
+
const element = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
|
|
1530
1538
|
target.dataset = element !== null ? element.dataset : shared.EMPTY_OBJ;
|
|
1531
|
-
for (const key in (
|
|
1539
|
+
for (const key in (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail) {
|
|
1532
1540
|
target[key] = this.mpEvent.detail[key];
|
|
1533
1541
|
}
|
|
1534
1542
|
this.cacheTarget = target;
|
|
@@ -1539,19 +1547,19 @@ class TaroEvent {
|
|
|
1539
1547
|
}
|
|
1540
1548
|
}
|
|
1541
1549
|
get currentTarget() {
|
|
1542
|
-
var _a, _b, _c, _d;
|
|
1550
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1543
1551
|
const cacheCurrentTarget = this.cacheCurrentTarget;
|
|
1544
1552
|
if (!cacheCurrentTarget) {
|
|
1545
1553
|
const doc = env.document;
|
|
1546
1554
|
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 = (
|
|
1555
|
+
const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
|
|
1556
|
+
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
1557
|
if (element === null || (element && element === targetElement)) {
|
|
1550
1558
|
this.cacheCurrentTarget = this.target;
|
|
1551
1559
|
return this.target;
|
|
1552
1560
|
}
|
|
1553
1561
|
currentTarget.dataset = element.dataset;
|
|
1554
|
-
for (const key in (
|
|
1562
|
+
for (const key in (_h = this.mpEvent) === null || _h === void 0 ? void 0 : _h.detail) {
|
|
1555
1563
|
currentTarget[key] = this.mpEvent.detail[key];
|
|
1556
1564
|
}
|
|
1557
1565
|
this.cacheCurrentTarget = currentTarget;
|
|
@@ -2300,9 +2308,6 @@ class AnchorElement extends TaroElement {
|
|
|
2300
2308
|
}
|
|
2301
2309
|
}
|
|
2302
2310
|
|
|
2303
|
-
class CustomWrapperElement extends TaroElement {
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
2311
|
class TaroDocument extends TaroElement {
|
|
2307
2312
|
constructor() {
|
|
2308
2313
|
super();
|
|
@@ -2323,9 +2328,6 @@ class TaroDocument extends TaroElement {
|
|
|
2323
2328
|
case nodeName === A:
|
|
2324
2329
|
element = new AnchorElement();
|
|
2325
2330
|
break;
|
|
2326
|
-
case nodeName === CUSTOM_WRAPPER:
|
|
2327
|
-
element = new CustomWrapperElement();
|
|
2328
|
-
break;
|
|
2329
2331
|
default:
|
|
2330
2332
|
element = new TaroElement();
|
|
2331
2333
|
break;
|
|
@@ -2466,17 +2468,17 @@ class History extends shared.Events {
|
|
|
2466
2468
|
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this, href);
|
|
2467
2469
|
}, null);
|
|
2468
2470
|
// 切换上下文行为
|
|
2469
|
-
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
2471
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, () => {
|
|
2470
2472
|
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
2471
2473
|
}, null);
|
|
2472
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2474
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2473
2475
|
cache$1.set(pageId, {
|
|
2474
2476
|
location: __classPrivateFieldGet(this, _History_location, "f"),
|
|
2475
2477
|
stack: __classPrivateFieldGet(this, _History_stack, "f").slice(),
|
|
2476
2478
|
cur: __classPrivateFieldGet(this, _History_cur, "f")
|
|
2477
2479
|
});
|
|
2478
2480
|
}, null);
|
|
2479
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2481
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2480
2482
|
if (cache$1.has(pageId)) {
|
|
2481
2483
|
const ctx = cache$1.get(pageId);
|
|
2482
2484
|
__classPrivateFieldSet(this, _History_location, ctx.location, "f");
|
|
@@ -2484,7 +2486,7 @@ class History extends shared.Events {
|
|
|
2484
2486
|
__classPrivateFieldSet(this, _History_cur, ctx.cur, "f");
|
|
2485
2487
|
}
|
|
2486
2488
|
}, null);
|
|
2487
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2489
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2488
2490
|
cache$1.delete(pageId);
|
|
2489
2491
|
}, null);
|
|
2490
2492
|
__classPrivateFieldGet(this, _History_instances, "m", _History_reset).call(this);
|
|
@@ -2580,15 +2582,15 @@ class Location extends shared.Events {
|
|
|
2580
2582
|
__classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
|
|
2581
2583
|
}, null);
|
|
2582
2584
|
// 切换上下文行为
|
|
2583
|
-
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
2585
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, () => {
|
|
2584
2586
|
__classPrivateFieldGet(this, _Location_instances, "m", _Location_reset).call(this);
|
|
2585
2587
|
}, null);
|
|
2586
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2588
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2587
2589
|
cache.set(pageId, {
|
|
2588
2590
|
lastHref: this.href,
|
|
2589
2591
|
});
|
|
2590
2592
|
}, null);
|
|
2591
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2593
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2592
2594
|
// 数据恢复时,不需要执行跳转
|
|
2593
2595
|
if (cache.has(pageId)) {
|
|
2594
2596
|
const ctx = cache.get(pageId);
|
|
@@ -2597,7 +2599,7 @@ class Location extends shared.Events {
|
|
|
2597
2599
|
__classPrivateFieldSet(this, _Location_noCheckUrl, false, "f");
|
|
2598
2600
|
}
|
|
2599
2601
|
}, null);
|
|
2600
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2602
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2601
2603
|
cache.delete(pageId);
|
|
2602
2604
|
}, null);
|
|
2603
2605
|
}
|
|
@@ -2855,24 +2857,24 @@ if (process.env.TARO_ENV && !true) {
|
|
|
2855
2857
|
initEvent() {
|
|
2856
2858
|
const _location = this.location;
|
|
2857
2859
|
const _history = this.history;
|
|
2858
|
-
this.on(CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
2860
|
+
this.on(exports.CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
2859
2861
|
// 页面onload,为该页面建立新的上下文信息
|
|
2860
|
-
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
2862
|
+
_location.trigger(exports.CONTEXT_ACTIONS.INIT, pageId);
|
|
2861
2863
|
}, null);
|
|
2862
|
-
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2864
|
+
this.on(exports.CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
2863
2865
|
// 页面onshow,恢复当前页面的上下文信息
|
|
2864
|
-
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2865
|
-
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2866
|
+
_location.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2867
|
+
_history.trigger(exports.CONTEXT_ACTIONS.RECOVER, pageId);
|
|
2866
2868
|
}, null);
|
|
2867
|
-
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2869
|
+
this.on(exports.CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
2868
2870
|
// 页面onhide,缓存当前页面的上下文信息
|
|
2869
|
-
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2870
|
-
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2871
|
+
_location.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2872
|
+
_history.trigger(exports.CONTEXT_ACTIONS.RESTORE, pageId);
|
|
2871
2873
|
}, null);
|
|
2872
|
-
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2874
|
+
this.on(exports.CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
2873
2875
|
// 页面onunload,清除当前页面的上下文信息
|
|
2874
|
-
_location.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2875
|
-
_history.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2876
|
+
_location.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2877
|
+
_history.trigger(exports.CONTEXT_ACTIONS.DESTORY, pageId);
|
|
2876
2878
|
}, null);
|
|
2877
2879
|
}
|
|
2878
2880
|
get document() {
|
|
@@ -3074,8 +3076,19 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3074
3076
|
}
|
|
3075
3077
|
};
|
|
3076
3078
|
LIFECYCLES.forEach((lifecycle) => {
|
|
3079
|
+
let isDefer = false;
|
|
3080
|
+
lifecycle = lifecycle.replace(/^defer:/, () => {
|
|
3081
|
+
isDefer = true;
|
|
3082
|
+
return '';
|
|
3083
|
+
});
|
|
3077
3084
|
config[lifecycle] = function () {
|
|
3078
|
-
|
|
3085
|
+
const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
3086
|
+
if (isDefer) {
|
|
3087
|
+
hasLoaded.then(exec);
|
|
3088
|
+
}
|
|
3089
|
+
else {
|
|
3090
|
+
return exec();
|
|
3091
|
+
}
|
|
3079
3092
|
};
|
|
3080
3093
|
});
|
|
3081
3094
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
@@ -3114,7 +3127,8 @@ function createComponentConfig(component, componentName, data) {
|
|
|
3114
3127
|
[ATTACHED]() {
|
|
3115
3128
|
var _a;
|
|
3116
3129
|
perf.start(PAGE_INIT);
|
|
3117
|
-
|
|
3130
|
+
this.pageIdCache = ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId();
|
|
3131
|
+
const path = getPath(id, { id: this.pageIdCache });
|
|
3118
3132
|
Current.app.mount(component, path, () => {
|
|
3119
3133
|
componentElement = env.document.getElementById(path);
|
|
3120
3134
|
shared.ensure(componentElement !== null, '没有找到组件实例。');
|
|
@@ -3123,7 +3137,7 @@ function createComponentConfig(component, componentName, data) {
|
|
|
3123
3137
|
});
|
|
3124
3138
|
},
|
|
3125
3139
|
[DETACHED]() {
|
|
3126
|
-
const path = getPath(id, { id: this.
|
|
3140
|
+
const path = getPath(id, { id: this.pageIdCache });
|
|
3127
3141
|
Current.app.unmount(path, () => {
|
|
3128
3142
|
instances.delete(path);
|
|
3129
3143
|
if (componentElement) {
|
|
@@ -3239,31 +3253,84 @@ Object.defineProperty(exports, 'hooks', {
|
|
|
3239
3253
|
enumerable: true,
|
|
3240
3254
|
get: function () { return shared.hooks; }
|
|
3241
3255
|
});
|
|
3256
|
+
exports.A = A;
|
|
3257
|
+
exports.APP = APP;
|
|
3258
|
+
exports.BEHAVIORS = BEHAVIORS;
|
|
3259
|
+
exports.BODY = BODY;
|
|
3260
|
+
exports.CATCHMOVE = CATCHMOVE;
|
|
3261
|
+
exports.CATCH_VIEW = CATCH_VIEW;
|
|
3262
|
+
exports.CHANGE = CHANGE;
|
|
3263
|
+
exports.CLASS = CLASS;
|
|
3264
|
+
exports.COMMENT = COMMENT;
|
|
3265
|
+
exports.CONFIRM = CONFIRM;
|
|
3266
|
+
exports.CONTAINER = CONTAINER;
|
|
3267
|
+
exports.CURRENT_TARGET = CURRENT_TARGET;
|
|
3268
|
+
exports.CUSTOM_WRAPPER = CUSTOM_WRAPPER;
|
|
3242
3269
|
exports.Current = Current;
|
|
3270
|
+
exports.DATASET = DATASET;
|
|
3271
|
+
exports.DATE = DATE;
|
|
3272
|
+
exports.DOCUMENT_ELEMENT_NAME = DOCUMENT_ELEMENT_NAME;
|
|
3273
|
+
exports.DOCUMENT_FRAGMENT = DOCUMENT_FRAGMENT;
|
|
3274
|
+
exports.EVENT_CALLBACK_RESULT = EVENT_CALLBACK_RESULT;
|
|
3275
|
+
exports.EXTERNAL_CLASSES = EXTERNAL_CLASSES;
|
|
3276
|
+
exports.FOCUS = FOCUS;
|
|
3243
3277
|
exports.FormElement = FormElement;
|
|
3278
|
+
exports.HEAD = HEAD;
|
|
3279
|
+
exports.HOOKS_APP_ID = HOOKS_APP_ID;
|
|
3280
|
+
exports.HTML = HTML;
|
|
3244
3281
|
exports.History = History;
|
|
3282
|
+
exports.ID = ID;
|
|
3283
|
+
exports.INPUT = INPUT;
|
|
3284
|
+
exports.KEY_CODE = KEY_CODE;
|
|
3245
3285
|
exports.Location = Location;
|
|
3246
3286
|
exports.MutationObserver = MutationObserver;
|
|
3287
|
+
exports.OBJECT = OBJECT;
|
|
3288
|
+
exports.ON_HIDE = ON_HIDE;
|
|
3289
|
+
exports.ON_LOAD = ON_LOAD;
|
|
3290
|
+
exports.ON_READY = ON_READY;
|
|
3291
|
+
exports.ON_SHOW = ON_SHOW;
|
|
3292
|
+
exports.OPTIONS = OPTIONS;
|
|
3293
|
+
exports.PAGE_INIT = PAGE_INIT;
|
|
3294
|
+
exports.PROPERTY_THRESHOLD = PROPERTY_THRESHOLD;
|
|
3295
|
+
exports.PROPS = PROPS;
|
|
3296
|
+
exports.PURE_VIEW = PURE_VIEW;
|
|
3297
|
+
exports.ROOT_STR = ROOT_STR;
|
|
3298
|
+
exports.SET_DATA = SET_DATA;
|
|
3299
|
+
exports.SET_TIMEOUT = SET_TIMEOUT;
|
|
3300
|
+
exports.STATIC_VIEW = STATIC_VIEW;
|
|
3301
|
+
exports.STYLE = STYLE;
|
|
3247
3302
|
exports.SVGElement = SVGElement;
|
|
3248
3303
|
exports.Style = Style;
|
|
3304
|
+
exports.TARGET = TARGET;
|
|
3305
|
+
exports.TARO_RUNTIME = TARO_RUNTIME;
|
|
3306
|
+
exports.TIME_STAMP = TIME_STAMP;
|
|
3307
|
+
exports.TOUCHMOVE = TOUCHMOVE;
|
|
3308
|
+
exports.TYPE = TYPE;
|
|
3249
3309
|
exports.TaroElement = TaroElement;
|
|
3250
3310
|
exports.TaroEvent = TaroEvent;
|
|
3251
3311
|
exports.TaroNode = TaroNode;
|
|
3252
3312
|
exports.TaroRootElement = TaroRootElement;
|
|
3253
3313
|
exports.TaroText = TaroText;
|
|
3314
|
+
exports.UID = UID;
|
|
3254
3315
|
exports.URL = URL;
|
|
3255
3316
|
exports.URLSearchParams = URLSearchParams;
|
|
3317
|
+
exports.VALUE = VALUE;
|
|
3318
|
+
exports.VIEW = VIEW;
|
|
3256
3319
|
exports.addLeadingSlash = addLeadingSlash;
|
|
3257
3320
|
exports.cancelAnimationFrame = _caf;
|
|
3258
3321
|
exports.createComponentConfig = createComponentConfig;
|
|
3259
3322
|
exports.createEvent = createEvent;
|
|
3260
3323
|
exports.createPageConfig = createPageConfig;
|
|
3261
3324
|
exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
|
|
3325
|
+
exports.env = env;
|
|
3262
3326
|
exports.eventCenter = eventCenter;
|
|
3263
3327
|
exports.eventHandler = eventHandler;
|
|
3264
3328
|
exports.eventSource = eventSource;
|
|
3265
3329
|
exports.getComputedStyle = getComputedStyle;
|
|
3266
3330
|
exports.getCurrentInstance = getCurrentInstance;
|
|
3331
|
+
exports.getOnHideEventKey = getOnHideEventKey;
|
|
3332
|
+
exports.getOnReadyEventKey = getOnReadyEventKey;
|
|
3333
|
+
exports.getOnShowEventKey = getOnShowEventKey;
|
|
3267
3334
|
exports.getPageInstance = getPageInstance;
|
|
3268
3335
|
exports.getPath = getPath;
|
|
3269
3336
|
exports.history = history;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/runtime",
|
|
3
|
-
"version": "3.7.0-
|
|
3
|
+
"version": "3.7.0-beta.1",
|
|
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-
|
|
23
|
+
"@tarojs/shared": "3.7.0-beta.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@rollup/plugin-buble": "^0.21.3",
|