@tarojs/runtime 4.0.6 → 4.0.7-alpha.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/index.js CHANGED
@@ -19,7 +19,7 @@ export { Style } from './dom/style.js';
19
19
  export { SVGElement } from './dom/svg.js';
20
20
  export { TaroText } from './dom/text.js';
21
21
  export { MutationObserver } from './dom-external/mutation-observer/index.js';
22
- export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, FOCUS, HEAD, HOOKS_APP_ID, HTML, ID, INPUT, KEY_CODE, 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, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, UID, VALUE, VIEW } from './constants/index.js';
22
+ export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, FOCUS, HEAD, HOOKS_APP_ID, HTML, ID, INPUT, KEY_CODE, 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, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, UID, VALUE, VIEW } from './constants/index.js';
23
23
  export { Current, getCurrentInstance } from './current.js';
24
24
  export { eventSource } from './dom/event-source.js';
25
25
  export { createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify } from './dsl/common.js';
@@ -141,6 +141,7 @@ declare class TaroEventTarget {
141
141
  addEventListener(type: string, handler: EventHandler, options?: boolean | AddEventListenerOptions): void;
142
142
  removeEventListener(type: string, handler: EventHandler): void;
143
143
  isAnyEventBinded(): boolean;
144
+ isOnlyClickBinded(): boolean;
144
145
  }
145
146
  declare class TaroRootElement extends TaroElement {
146
147
  private updatePayloads;
@@ -150,6 +151,7 @@ declare class TaroRootElement extends TaroElement {
150
151
  constructor();
151
152
  get _path(): string;
152
153
  get _root(): TaroRootElement;
154
+ scheduleTask(fn: TFunc): void;
153
155
  enqueueUpdate(payload: UpdatePayload): void;
154
156
  performUpdate(initRender?: boolean, prerender?: TFunc): void;
155
157
  enqueueUpdateCallback(cb: TFunc, ctx?: Record<string, any>): void;
@@ -626,6 +628,7 @@ declare const SET_TIMEOUT = "setTimeout";
626
628
  declare const COMPILE_MODE = "compileMode";
627
629
  declare const CATCHMOVE = "catchMove";
628
630
  declare const CATCH_VIEW = "catch-view";
631
+ declare const CLICK_VIEW = "click-view";
629
632
  declare const COMMENT = "comment";
630
633
  declare const ON_LOAD = "onLoad";
631
634
  declare const ON_READY = "onReady";
@@ -807,4 +810,4 @@ declare const getHomePage: (path?: string, basename?: string, customRoutes?: Rec
807
810
  declare const getCurrentPage: (routerMode?: string, basename?: string) => string;
808
811
  declare function handlePolyfill(): void;
809
812
  export { hooks } from '@tarojs/shared';
810
- export { taroDocumentProvider as document, taroGetComputedStyleProvider as getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, TaroURLProvider as URL, URLSearchParams, taroHistoryProvider as history, taroLocationProvider as location, taroWindowProvider as 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, COMPILE_MODE, 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, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, perf, incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, throttle, debounce, addLeadingSlash, hasBasename, stripBasename, stripTrailing, stripSuffix, getHomePage, getCurrentPage, Instance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniTextData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$1 as Options, TFunc, PageConfig, handlePolyfill };
813
+ export { taroDocumentProvider as document, taroGetComputedStyleProvider as getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, TaroURLProvider as URL, URLSearchParams, taroHistoryProvider as history, taroLocationProvider as location, taroWindowProvider as 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, COMPILE_MODE, CATCHMOVE, CATCH_VIEW, CLICK_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, perf, incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, throttle, debounce, addLeadingSlash, hasBasename, stripBasename, stripTrailing, stripSuffix, getHomePage, getCurrentPage, Instance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniTextData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$1 as Options, TFunc, PageConfig, handlePolyfill };
@@ -42,6 +42,7 @@ const SET_TIMEOUT = 'setTimeout';
42
42
  const COMPILE_MODE = 'compileMode';
43
43
  const CATCHMOVE = 'catchMove';
44
44
  const CATCH_VIEW = 'catch-view';
45
+ const CLICK_VIEW = 'click-view';
45
46
  const COMMENT = 'comment';
46
47
  const ON_LOAD = 'onLoad';
47
48
  const ON_READY = 'onReady';
@@ -1340,6 +1341,9 @@ function hydrate(node) {
1340
1341
  data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
1341
1342
  }
1342
1343
  }
1344
+ if (nodeName === VIEW && node.isOnlyClickBinded()) {
1345
+ data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
1346
+ }
1343
1347
  const { props } = node;
1344
1348
  for (const prop in props) {
1345
1349
  const propInCamelCase = toCamelCase(prop);
@@ -1461,6 +1465,11 @@ class TaroEventTarget {
1461
1465
  const isAnyEventBinded = Object.keys(handlers).find(key => handlers[key].length);
1462
1466
  return Boolean(isAnyEventBinded);
1463
1467
  }
1468
+ isOnlyClickBinded() {
1469
+ const handlers = this.__handlers;
1470
+ const isOnlyClickBinded = handlers.tap && Object.keys(handlers).length === 1;
1471
+ return Boolean(isOnlyClickBinded);
1472
+ }
1464
1473
  }
1465
1474
 
1466
1475
  const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
@@ -3619,6 +3628,20 @@ class TaroRootElement extends TaroElement {
3619
3628
  get _root() {
3620
3629
  return this;
3621
3630
  }
3631
+ scheduleTask(fn) {
3632
+ if (isFunction(Promise)) {
3633
+ Promise.resolve()
3634
+ .then(fn)
3635
+ .catch((error) => {
3636
+ setTimeout(() => {
3637
+ throw error;
3638
+ });
3639
+ });
3640
+ }
3641
+ else {
3642
+ setTimeout(fn);
3643
+ }
3644
+ }
3622
3645
  enqueueUpdate(payload) {
3623
3646
  this.updatePayloads.push(payload);
3624
3647
  if (!this.pendingUpdate && this.ctx) {
@@ -3628,7 +3651,7 @@ class TaroRootElement extends TaroElement {
3628
3651
  performUpdate(initRender = false, prerender) {
3629
3652
  this.pendingUpdate = true;
3630
3653
  const ctx = hooks.call('proxyToRaw', this.ctx);
3631
- setTimeout(() => {
3654
+ this.scheduleTask(() => {
3632
3655
  const setDataMark = `${SET_DATA} 开始时间戳 ${Date.now()}`;
3633
3656
  perf.start(setDataMark);
3634
3657
  const data = Object.create(null);
@@ -3711,7 +3734,7 @@ class TaroRootElement extends TaroElement {
3711
3734
  }
3712
3735
  ctx.setData(normalUpdate, cb);
3713
3736
  }
3714
- }, 0);
3737
+ });
3715
3738
  }
3716
3739
  enqueueUpdateCallback(cb, ctx) {
3717
3740
  this.updateCallbacks.push(() => {
@@ -5065,5 +5088,5 @@ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFOR
5065
5088
  handlePolyfill();
5066
5089
  }
5067
5090
 
5068
- export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, 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, isParentBinded, 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 };
5091
+ 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, isParentBinded, 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 };
5069
5092
  //# sourceMappingURL=runtime.esm.js.map