@tarojs/runtime 4.1.8 → 4.1.9-beta.0
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/README.md +2 -2
- package/dist/bom/history.js +1 -1
- package/dist/bom/history.js.map +1 -1
- package/dist/bom/location.js +1 -1
- package/dist/bom/location.js.map +1 -1
- package/dist/bom/window.d.ts +0 -1
- package/dist/bom/window.js +8 -8
- package/dist/bom/window.js.map +1 -1
- package/dist/constants/index.d.ts +1 -4
- package/dist/constants/index.js +2 -4
- package/dist/constants/index.js.map +1 -1
- package/dist/dom/event.js +2 -2
- package/dist/dom/event.js.map +1 -1
- package/dist/dom-external/inner-html/parser.js +2 -2
- package/dist/dom-external/inner-html/parser.js.map +1 -1
- package/dist/dom-external/inner-html/{scaner.js → scanner.js} +4 -4
- package/dist/dom-external/inner-html/scanner.js.map +1 -0
- package/dist/dsl/common.js +1 -1
- package/dist/dsl/common.js.map +1 -1
- package/dist/index.cjs.d.ts +3 -7
- package/dist/index.cjs.js +18 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime.esm.d.ts +3 -7
- package/dist/runtime.esm.js +18 -20
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +4 -5
- package/dist/dom-external/inner-html/scaner.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { hydrate } from './hydrate.js';
|
|
|
27
27
|
export { nextTick } from './next-tick.js';
|
|
28
28
|
export { options } from './options.js';
|
|
29
29
|
export { perf } from './perf.js';
|
|
30
|
-
export { convertNumber2PX, customWrapperCache, extend, getComponentsAlias, incrementId, isComment, isElement, isHasExtractProp,
|
|
30
|
+
export { convertNumber2PX, customWrapperCache, extend, getComponentsAlias, incrementId, isComment, isElement, isHasExtractProp, isParentBound, isText, shortcutAttr } from './utils/index.js';
|
|
31
31
|
export { AppInstance, Instance, PageInstance, PageLifeCycle, PageProps, ReactAppInstance, ReactPageComponent, ReactPageInstance } from './dsl/instance.js';
|
|
32
32
|
export { KeyFrame, ScrollTimelineOption } from './interface/animate.js';
|
|
33
33
|
export { Attributes } from './interface/element.js';
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export { hydrate } from './hydrate.js';
|
|
|
28
28
|
export { nextTick } from './next-tick.js';
|
|
29
29
|
export { options } from './options.js';
|
|
30
30
|
export { perf } from './perf.js';
|
|
31
|
-
export { convertNumber2PX, customWrapperCache, extend, getComponentsAlias, incrementId, isComment, isElement, isHasExtractProp,
|
|
31
|
+
export { convertNumber2PX, customWrapperCache, extend, getComponentsAlias, incrementId, isComment, isElement, isHasExtractProp, isParentBound, isText, shortcutAttr } from './utils/index.js';
|
|
32
32
|
export { handlePolyfill } from './polyfill/index.js';
|
|
33
33
|
export { debounce, throttle } from './utils/lodash.js';
|
|
34
34
|
export { addLeadingSlash, getCurrentPage, getHomePage, hasBasename, stripBasename, stripSuffix, stripTrailing } from './utils/router.js';
|
package/dist/runtime.esm.d.ts
CHANGED
|
@@ -585,7 +585,6 @@ declare class TaroWindow extends Events {
|
|
|
585
585
|
setTimeout(...args: Parameters<typeof setTimeout>): NodeJS.Timeout;
|
|
586
586
|
clearTimeout(...args: Parameters<typeof clearTimeout>): void;
|
|
587
587
|
}
|
|
588
|
-
|
|
589
588
|
declare const taroWindowProvider: TaroWindow;
|
|
590
589
|
declare const taroLocationProvider: TaroLocation;
|
|
591
590
|
declare const taroHistoryProvider: TaroHistory;
|
|
@@ -727,14 +726,11 @@ declare const EXTERNAL_CLASSES = "externalClasses";
|
|
|
727
726
|
declare const EVENT_CALLBACK_RESULT = "e_result";
|
|
728
727
|
declare const BEHAVIORS = "behaviors";
|
|
729
728
|
declare const A = "a";
|
|
730
|
-
/**
|
|
731
|
-
* 页面上下文切换时的行为
|
|
732
|
-
*/
|
|
733
729
|
declare enum CONTEXT_ACTIONS {
|
|
734
730
|
INIT = "0",
|
|
735
731
|
RESTORE = "1",
|
|
736
732
|
RECOVER = "2",
|
|
737
|
-
|
|
733
|
+
DESTROY = "3"
|
|
738
734
|
}
|
|
739
735
|
|
|
740
736
|
interface Instance<T = Record<string, any>> extends Component$1<T>, Show, PageInstance {
|
|
@@ -905,7 +901,7 @@ declare function isHasExtractProp(el: TaroElement): boolean;
|
|
|
905
901
|
* @param node 当前组件
|
|
906
902
|
* @param type 事件类型
|
|
907
903
|
*/
|
|
908
|
-
declare function
|
|
904
|
+
declare function isParentBound(node: TaroElement | null, type: string): boolean;
|
|
909
905
|
declare function shortcutAttr(key: string): string;
|
|
910
906
|
declare const customWrapperCache: Map<string, Record<string, any>>;
|
|
911
907
|
interface Ctor {
|
|
@@ -917,5 +913,5 @@ declare function convertNumber2PX(value: number): string;
|
|
|
917
913
|
|
|
918
914
|
declare function handlePolyfill(): void;
|
|
919
915
|
|
|
920
|
-
export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, 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, TaroURLProvider as URL, URLSearchParams$1 as URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp,
|
|
916
|
+
export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, 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, TaroURLProvider as URL, URLSearchParams$1 as URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
|
|
921
917
|
export type { AddEventListenerOptions, AppInstance, Attributes, DataTree, EventHandler, EventListenerOptions, EventOptions, EventsType, HydratedData, Instance, KeyFrame, MiniData, MiniElementData, MiniTextData, MpEvent, MpInstance, Options$2 as Options, PageConfig, PageInstance, PageLifeCycle, PageProps, ReactAppInstance, ReactPageComponent, ReactPageInstance, ScrollTimelineOption, TFunc, UpdatePayload, UpdatePayloadValue };
|
package/dist/runtime.esm.js
CHANGED
|
@@ -53,15 +53,13 @@ const EXTERNAL_CLASSES = 'externalClasses';
|
|
|
53
53
|
const EVENT_CALLBACK_RESULT = 'e_result';
|
|
54
54
|
const BEHAVIORS = 'behaviors';
|
|
55
55
|
const A = 'a';
|
|
56
|
-
|
|
57
|
-
* 页面上下文切换时的行为
|
|
58
|
-
*/
|
|
56
|
+
// 页面上下文切换时的行为
|
|
59
57
|
var CONTEXT_ACTIONS;
|
|
60
58
|
(function (CONTEXT_ACTIONS) {
|
|
61
59
|
CONTEXT_ACTIONS["INIT"] = "0";
|
|
62
60
|
CONTEXT_ACTIONS["RESTORE"] = "1";
|
|
63
61
|
CONTEXT_ACTIONS["RECOVER"] = "2";
|
|
64
|
-
CONTEXT_ACTIONS["
|
|
62
|
+
CONTEXT_ACTIONS["DESTROY"] = "3";
|
|
65
63
|
})(CONTEXT_ACTIONS || (CONTEXT_ACTIONS = {}));
|
|
66
64
|
|
|
67
65
|
const observers = [];
|
|
@@ -312,7 +310,7 @@ class TaroHistory extends Events {
|
|
|
312
310
|
__classPrivateFieldSet(this, _TaroHistory_cur, ctx.cur, "f");
|
|
313
311
|
}
|
|
314
312
|
}, null);
|
|
315
|
-
this.on(CONTEXT_ACTIONS.
|
|
313
|
+
this.on(CONTEXT_ACTIONS.DESTROY, (pageId) => {
|
|
316
314
|
cache$1.delete(pageId);
|
|
317
315
|
}, null);
|
|
318
316
|
__classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this);
|
|
@@ -766,7 +764,7 @@ class TaroLocation extends Events {
|
|
|
766
764
|
__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, false, "f");
|
|
767
765
|
}
|
|
768
766
|
}, null);
|
|
769
|
-
this.on(CONTEXT_ACTIONS.
|
|
767
|
+
this.on(CONTEXT_ACTIONS.DESTROY, (pageId) => {
|
|
770
768
|
cache.delete(pageId);
|
|
771
769
|
}, null);
|
|
772
770
|
}
|
|
@@ -1043,23 +1041,23 @@ class TaroWindow extends Events {
|
|
|
1043
1041
|
const _location = this.location;
|
|
1044
1042
|
const _history = this.history;
|
|
1045
1043
|
this.on(CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
1046
|
-
// 页面onload,为该页面建立新的上下文信息
|
|
1044
|
+
// 页面 onload,为该页面建立新的上下文信息
|
|
1047
1045
|
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
1048
1046
|
}, null);
|
|
1049
1047
|
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
1050
|
-
// 页面onshow,恢复当前页面的上下文信息
|
|
1048
|
+
// 页面 onshow,恢复当前页面的上下文信息
|
|
1051
1049
|
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
1052
1050
|
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
1053
1051
|
}, null);
|
|
1054
1052
|
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
1055
|
-
// 页面onhide,缓存当前页面的上下文信息
|
|
1053
|
+
// 页面 onhide,缓存当前页面的上下文信息
|
|
1056
1054
|
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
1057
1055
|
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
1058
1056
|
}, null);
|
|
1059
|
-
this.on(CONTEXT_ACTIONS.
|
|
1060
|
-
// 页面onunload,清除当前页面的上下文信息
|
|
1061
|
-
_location.trigger(CONTEXT_ACTIONS.
|
|
1062
|
-
_history.trigger(CONTEXT_ACTIONS.
|
|
1057
|
+
this.on(CONTEXT_ACTIONS.DESTROY, (pageId) => {
|
|
1058
|
+
// 页面 onunload,清除当前页面的上下文信息
|
|
1059
|
+
_location.trigger(CONTEXT_ACTIONS.DESTROY, pageId);
|
|
1060
|
+
_history.trigger(CONTEXT_ACTIONS.DESTROY, pageId);
|
|
1063
1061
|
}, null);
|
|
1064
1062
|
}
|
|
1065
1063
|
get document() {
|
|
@@ -1156,7 +1154,7 @@ function isHasExtractProp(el) {
|
|
|
1156
1154
|
* @param node 当前组件
|
|
1157
1155
|
* @param type 事件类型
|
|
1158
1156
|
*/
|
|
1159
|
-
function
|
|
1157
|
+
function isParentBound(node, type) {
|
|
1160
1158
|
var _a;
|
|
1161
1159
|
while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
|
|
1162
1160
|
if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
|
|
@@ -2512,7 +2510,7 @@ function isWordEnd(cursor, wordBegin, html) {
|
|
|
2512
2510
|
if (!isWhitespaceChar(html.charAt(cursor)))
|
|
2513
2511
|
return false;
|
|
2514
2512
|
const len = html.length;
|
|
2515
|
-
//
|
|
2513
|
+
// backward
|
|
2516
2514
|
for (let i = cursor - 1; i > wordBegin; i--) {
|
|
2517
2515
|
const char = html.charAt(i);
|
|
2518
2516
|
if (!isWhitespaceChar(char)) {
|
|
@@ -2531,7 +2529,7 @@ function isWordEnd(cursor, wordBegin, html) {
|
|
|
2531
2529
|
}
|
|
2532
2530
|
}
|
|
2533
2531
|
}
|
|
2534
|
-
class
|
|
2532
|
+
class Scanner {
|
|
2535
2533
|
constructor(html) {
|
|
2536
2534
|
this.tokens = [];
|
|
2537
2535
|
this.position = initPosition();
|
|
@@ -3123,7 +3121,7 @@ function format(children, document, styleOptions, parent) {
|
|
|
3123
3121
|
function parser(html, document) {
|
|
3124
3122
|
const styleTagParser = new StyleTagParser();
|
|
3125
3123
|
html = styleTagParser.extractStyle(html);
|
|
3126
|
-
const tokens = new
|
|
3124
|
+
const tokens = new Scanner(html).scan();
|
|
3127
3125
|
const root = { tagName: '', children: [], type: 'element', attributes: [] };
|
|
3128
3126
|
const state = { tokens, cursor: 0, stack: [root] };
|
|
3129
3127
|
parse(state);
|
|
@@ -3494,7 +3492,7 @@ function eventHandler(event) {
|
|
|
3494
3492
|
if (hooks.isExist('batchedEventUpdates')) {
|
|
3495
3493
|
const type = event.type;
|
|
3496
3494
|
if (!hooks.call('isBubbleEvents', type) ||
|
|
3497
|
-
!
|
|
3495
|
+
!isParentBound(node, type) ||
|
|
3498
3496
|
(type === TOUCHMOVE && !!node.props.catchMove)) {
|
|
3499
3497
|
// 最上层组件统一 batchUpdate
|
|
3500
3498
|
hooks.call('batchedEventUpdates', () => {
|
|
@@ -4080,7 +4078,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4080
4078
|
const $taroPath = this.$taroPath;
|
|
4081
4079
|
// 销毁当前页面的上下文信息
|
|
4082
4080
|
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4083
|
-
taroWindowProvider.trigger(CONTEXT_ACTIONS.
|
|
4081
|
+
taroWindowProvider.trigger(CONTEXT_ACTIONS.DESTROY, $taroPath);
|
|
4084
4082
|
}
|
|
4085
4083
|
// 触发onUnload生命周期
|
|
4086
4084
|
safeExecute($taroPath, ONUNLOAD);
|
|
@@ -5104,5 +5102,5 @@ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFOR
|
|
|
5104
5102
|
handlePolyfill();
|
|
5105
5103
|
}
|
|
5106
5104
|
|
|
5107
|
-
export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, 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$1 as 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, TaroURLProvider as URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp,
|
|
5105
|
+
export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, 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$1 as 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, TaroURLProvider as URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
|
|
5108
5106
|
//# sourceMappingURL=runtime.esm.js.map
|