@tarojs/runtime 3.7.0-canary.1 → 3.7.0-canary.2
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 +136 -66
- package/dist/runtime.cjs.js +148 -59
- package/dist/runtime.esm.d.ts +136 -66
- package/dist/runtime.esm.js +59 -28
- package/dist/runtime.esm.js.map +1 -1
- package/dist/runtime.h5.d.ts +136 -66
- package/dist/runtime.h5.js +136 -48
- package/package.json +4 -4
package/dist/runtime.esm.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,6 @@ 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 isHasExtractProp(el: TaroElement): boolean;
|
|
710
780
|
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 };
|
|
781
|
+
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, isHasExtractProp, 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.esm.js
CHANGED
|
@@ -2,6 +2,8 @@ import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalC
|
|
|
2
2
|
export { Events, hooks } from '@tarojs/shared';
|
|
3
3
|
|
|
4
4
|
const PROPERTY_THRESHOLD = 2046;
|
|
5
|
+
const TARO_RUNTIME = 'Taro runtime';
|
|
6
|
+
const HOOKS_APP_ID = 'taro-app';
|
|
5
7
|
const SET_DATA = '小程序 setData';
|
|
6
8
|
const PAGE_INIT = '页面初始化';
|
|
7
9
|
const ROOT_STR = 'root';
|
|
@@ -34,6 +36,8 @@ const CONFIRM = 'confirm';
|
|
|
34
36
|
const TIME_STAMP = 'timeStamp';
|
|
35
37
|
const KEY_CODE = 'keyCode';
|
|
36
38
|
const TOUCHMOVE = 'touchmove';
|
|
39
|
+
const DATE = 'Date';
|
|
40
|
+
const SET_TIMEOUT = 'setTimeout';
|
|
37
41
|
const CATCHMOVE = 'catchMove';
|
|
38
42
|
const CATCH_VIEW = 'catch-view';
|
|
39
43
|
const COMMENT = 'comment';
|
|
@@ -170,7 +174,7 @@ class MutationObserver {
|
|
|
170
174
|
}
|
|
171
175
|
else {
|
|
172
176
|
if (process.env.NODE_ENV !== 'production') {
|
|
173
|
-
console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.enableMutationObserver: true\'');
|
|
177
|
+
console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.runtime.enableMutationObserver: true\'');
|
|
174
178
|
}
|
|
175
179
|
this.core = {
|
|
176
180
|
observe: noop,
|
|
@@ -244,15 +248,15 @@ function isHasExtractProp(el) {
|
|
|
244
248
|
*/
|
|
245
249
|
function isParentBinded(node, type) {
|
|
246
250
|
var _a;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
|
|
252
|
+
if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
else if ((_a = node.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
256
|
+
return true;
|
|
252
257
|
}
|
|
253
|
-
node = node.parentElement;
|
|
254
258
|
}
|
|
255
|
-
return
|
|
259
|
+
return false;
|
|
256
260
|
}
|
|
257
261
|
function shortcutAttr(key) {
|
|
258
262
|
switch (key) {
|
|
@@ -403,6 +407,7 @@ let componentsAlias;
|
|
|
403
407
|
* it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
|
|
404
408
|
*/
|
|
405
409
|
function hydrate(node) {
|
|
410
|
+
var _a;
|
|
406
411
|
if (!componentsAlias) {
|
|
407
412
|
// 初始化 componentsAlias
|
|
408
413
|
componentsAlias = getComponentsAlias();
|
|
@@ -414,8 +419,9 @@ function hydrate(node) {
|
|
|
414
419
|
const nodeName = node.nodeName;
|
|
415
420
|
if (isText(node)) {
|
|
416
421
|
return {
|
|
422
|
+
sid: node.sid,
|
|
417
423
|
["v" /* Shortcuts.Text */]: node.nodeValue,
|
|
418
|
-
["nn" /* Shortcuts.NodeName */]: componentsAlias[nodeName]._num
|
|
424
|
+
["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
|
|
419
425
|
};
|
|
420
426
|
}
|
|
421
427
|
const data = {
|
|
@@ -461,7 +467,7 @@ function hydrate(node) {
|
|
|
461
467
|
if (cssText !== '' && nodeName !== 'swiper-item') {
|
|
462
468
|
data["st" /* Shortcuts.Style */] = cssText;
|
|
463
469
|
}
|
|
464
|
-
hooks.call('modifyHydrateData', data);
|
|
470
|
+
hooks.call('modifyHydrateData', data, node);
|
|
465
471
|
const nn = data["nn" /* Shortcuts.NodeName */];
|
|
466
472
|
const componentAlias = componentsAlias[nn];
|
|
467
473
|
if (componentAlias) {
|
|
@@ -473,7 +479,8 @@ function hydrate(node) {
|
|
|
473
479
|
}
|
|
474
480
|
}
|
|
475
481
|
}
|
|
476
|
-
|
|
482
|
+
const resData = hooks.call('transferHydrateData', data, node, componentAlias);
|
|
483
|
+
return resData || data;
|
|
477
484
|
}
|
|
478
485
|
|
|
479
486
|
class TaroEventTarget {
|
|
@@ -1038,7 +1045,7 @@ function setStyle(newVal, styleKey) {
|
|
|
1038
1045
|
if (old === newVal)
|
|
1039
1046
|
return;
|
|
1040
1047
|
!this._pending && recordCss(this);
|
|
1041
|
-
if (isNull(newVal) || isUndefined(newVal)) {
|
|
1048
|
+
if (isNull(newVal) || isUndefined(newVal) || newVal === '') {
|
|
1042
1049
|
this._usedStyleProp.delete(styleKey);
|
|
1043
1050
|
delete this._value[styleKey];
|
|
1044
1051
|
}
|
|
@@ -1484,6 +1491,7 @@ class TaroElement extends TaroNode {
|
|
|
1484
1491
|
sideEffect = false;
|
|
1485
1492
|
delete options.sideEffect;
|
|
1486
1493
|
}
|
|
1494
|
+
hooks.call('modifyAddEventListener', this, sideEffect, getComponentsAlias);
|
|
1487
1495
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1488
1496
|
const componentsAlias = getComponentsAlias();
|
|
1489
1497
|
const alias = componentsAlias[name]._num;
|
|
@@ -1498,6 +1506,7 @@ class TaroElement extends TaroNode {
|
|
|
1498
1506
|
super.removeEventListener(type, handler);
|
|
1499
1507
|
const name = this.nodeName;
|
|
1500
1508
|
const SPECIAL_NODES = hooks.call('getSpecialNodes');
|
|
1509
|
+
hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias);
|
|
1501
1510
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1502
1511
|
const componentsAlias = getComponentsAlias();
|
|
1503
1512
|
const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
|
|
@@ -2462,13 +2471,14 @@ class TaroEvent {
|
|
|
2462
2471
|
this.defaultPrevented = true;
|
|
2463
2472
|
}
|
|
2464
2473
|
get target() {
|
|
2465
|
-
var _a, _b;
|
|
2474
|
+
var _a, _b, _c, _d;
|
|
2466
2475
|
const cacheTarget = this.cacheTarget;
|
|
2467
2476
|
if (!cacheTarget) {
|
|
2468
2477
|
const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
|
|
2469
|
-
|
|
2478
|
+
// Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
|
|
2479
|
+
const element = env.document.getElementById(((_b = target.targetDataset) === null || _b === void 0 ? void 0 : _b.sid) || ((_c = target.dataset) === null || _c === void 0 ? void 0 : _c.sid) || target.id || null);
|
|
2470
2480
|
target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
|
|
2471
|
-
for (const key in (
|
|
2481
|
+
for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
|
|
2472
2482
|
target[key] = this.mpEvent.detail[key];
|
|
2473
2483
|
}
|
|
2474
2484
|
this.cacheTarget = target;
|
|
@@ -2479,19 +2489,19 @@ class TaroEvent {
|
|
|
2479
2489
|
}
|
|
2480
2490
|
}
|
|
2481
2491
|
get currentTarget() {
|
|
2482
|
-
var _a, _b, _c, _d;
|
|
2492
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2483
2493
|
const cacheCurrentTarget = this.cacheCurrentTarget;
|
|
2484
2494
|
if (!cacheCurrentTarget) {
|
|
2485
2495
|
const doc = env.document;
|
|
2486
2496
|
const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
|
|
2487
|
-
const element = doc.getElementById(currentTarget.id);
|
|
2488
|
-
const targetElement = doc.getElementById(((_c = (
|
|
2497
|
+
const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
|
|
2498
|
+
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);
|
|
2489
2499
|
if (element === null || (element && element === targetElement)) {
|
|
2490
2500
|
this.cacheCurrentTarget = this.target;
|
|
2491
2501
|
return this.target;
|
|
2492
2502
|
}
|
|
2493
2503
|
currentTarget.dataset = element.dataset;
|
|
2494
|
-
for (const key in (
|
|
2504
|
+
for (const key in (_h = this.mpEvent) === null || _h === void 0 ? void 0 : _h.detail) {
|
|
2495
2505
|
currentTarget[key] = this.mpEvent.detail[key];
|
|
2496
2506
|
}
|
|
2497
2507
|
this.cacheCurrentTarget = currentTarget;
|
|
@@ -3240,7 +3250,15 @@ class AnchorElement extends TaroElement {
|
|
|
3240
3250
|
}
|
|
3241
3251
|
}
|
|
3242
3252
|
|
|
3243
|
-
class
|
|
3253
|
+
class TransferElement extends TaroElement {
|
|
3254
|
+
constructor(dataName) {
|
|
3255
|
+
super();
|
|
3256
|
+
this.dataName = dataName;
|
|
3257
|
+
this.isTransferElement = true;
|
|
3258
|
+
}
|
|
3259
|
+
get _path() {
|
|
3260
|
+
return this.dataName;
|
|
3261
|
+
}
|
|
3244
3262
|
}
|
|
3245
3263
|
|
|
3246
3264
|
class TaroDocument extends TaroElement {
|
|
@@ -3263,8 +3281,9 @@ class TaroDocument extends TaroElement {
|
|
|
3263
3281
|
case nodeName === A:
|
|
3264
3282
|
element = new AnchorElement();
|
|
3265
3283
|
break;
|
|
3266
|
-
case nodeName ===
|
|
3267
|
-
|
|
3284
|
+
case nodeName === 'page-meta':
|
|
3285
|
+
case nodeName === 'navigation-bar':
|
|
3286
|
+
element = new TransferElement(toCamelCase(nodeName));
|
|
3268
3287
|
break;
|
|
3269
3288
|
default:
|
|
3270
3289
|
element = new TaroElement();
|
|
@@ -4056,8 +4075,19 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4056
4075
|
}
|
|
4057
4076
|
};
|
|
4058
4077
|
LIFECYCLES.forEach((lifecycle) => {
|
|
4078
|
+
let isDefer = false;
|
|
4079
|
+
lifecycle = lifecycle.replace(/^defer:/, () => {
|
|
4080
|
+
isDefer = true;
|
|
4081
|
+
return '';
|
|
4082
|
+
});
|
|
4059
4083
|
config[lifecycle] = function () {
|
|
4060
|
-
|
|
4084
|
+
const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
4085
|
+
if (isDefer) {
|
|
4086
|
+
hasLoaded.then(exec);
|
|
4087
|
+
}
|
|
4088
|
+
else {
|
|
4089
|
+
return exec();
|
|
4090
|
+
}
|
|
4061
4091
|
};
|
|
4062
4092
|
});
|
|
4063
4093
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
@@ -4096,7 +4126,8 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4096
4126
|
[ATTACHED]() {
|
|
4097
4127
|
var _a;
|
|
4098
4128
|
perf.start(PAGE_INIT);
|
|
4099
|
-
|
|
4129
|
+
this.pageIdCache = ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId();
|
|
4130
|
+
const path = getPath(id, { id: this.pageIdCache });
|
|
4100
4131
|
Current.app.mount(component, path, () => {
|
|
4101
4132
|
componentElement = env.document.getElementById(path);
|
|
4102
4133
|
ensure(componentElement !== null, '没有找到组件实例。');
|
|
@@ -4109,7 +4140,7 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4109
4140
|
});
|
|
4110
4141
|
},
|
|
4111
4142
|
[DETACHED]() {
|
|
4112
|
-
const path = getPath(id, { id: this.
|
|
4143
|
+
const path = getPath(id, { id: this.pageIdCache });
|
|
4113
4144
|
Current.app.unmount(path, () => {
|
|
4114
4145
|
instances.delete(path);
|
|
4115
4146
|
if (componentElement) {
|
|
@@ -4159,7 +4190,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4159
4190
|
}
|
|
4160
4191
|
}
|
|
4161
4192
|
: EMPTY_OBJ;
|
|
4162
|
-
return Object.assign({ properties: {
|
|
4193
|
+
return hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
|
|
4163
4194
|
i: {
|
|
4164
4195
|
type: Object,
|
|
4165
4196
|
value: {
|
|
@@ -4175,7 +4206,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4175
4206
|
virtualHost: !isCustomWrapper
|
|
4176
4207
|
}, methods: {
|
|
4177
4208
|
eh: eventHandler
|
|
4178
|
-
} }, lifeCycles);
|
|
4209
|
+
} }, lifeCycles), { isCustomWrapper });
|
|
4179
4210
|
}
|
|
4180
4211
|
|
|
4181
4212
|
const TIMEOUT = 100;
|
|
@@ -4220,5 +4251,5 @@ const nextTick = (cb, ctx) => {
|
|
|
4220
4251
|
next();
|
|
4221
4252
|
};
|
|
4222
4253
|
|
|
4223
|
-
export { Current, FormElement, History, Location, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, URL, URLSearchParams, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, getPath, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
|
|
4254
|
+
export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, COMMENT, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, env, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, history, hydrate, incrementId, injectPageInstance, isHasExtractProp, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
|
|
4224
4255
|
//# sourceMappingURL=runtime.esm.js.map
|