@tarojs/runtime 4.2.1-beta.2 → 4.2.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.d.ts CHANGED
@@ -12,7 +12,6 @@ export { taroHistoryProvider as history, taroLocationProvider as location, taroW
12
12
  export { TaroElement } from './dom/element.js';
13
13
  export { TaroEvent, createEvent, eventHandler, eventHandlerTTDom } from './dom/event.js';
14
14
  export { FormElement } from './dom/form.js';
15
- export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv } from './dom/nearest-ctx.js';
16
15
  export { TaroNode } from './dom/node.js';
17
16
  export { TaroRootElement } from './dom/root.js';
18
17
  export { Style } from './dom/style.js';
package/dist/index.js CHANGED
@@ -13,7 +13,6 @@ export { taroHistoryProvider as history, taroLocationProvider as location, taroW
13
13
  export { TaroElement } from './dom/element.js';
14
14
  export { TaroEvent, createEvent, eventHandler, eventHandlerTTDom } from './dom/event.js';
15
15
  export { FormElement } from './dom/form.js';
16
- export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv } from './dom/nearest-ctx.js';
17
16
  export { TaroNode } from './dom/node.js';
18
17
  export { TaroRootElement } from './dom/root.js';
19
18
  export { Style } from './dom/style.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -242,11 +242,9 @@ declare class TaroRootElement extends TaroElement {
242
242
  private updateCallbacks;
243
243
  pendingUpdate: boolean;
244
244
  ctx: null | MpInstance;
245
- nearestCtxEpoch: number;
246
245
  constructor();
247
246
  get _path(): string;
248
247
  get _root(): TaroRootElement;
249
- bumpNearestCtxEpoch(): void;
250
248
  scheduleTask(fn: TFunc): void;
251
249
  enqueueUpdate(payload: UpdatePayload): void;
252
250
  performUpdate(initRender?: boolean, prerender?: TFunc): void;
@@ -270,7 +268,6 @@ declare class TaroNode extends TaroEventTarget {
270
268
  private updateChildNodes;
271
269
  private updateSingleChild;
272
270
  get _root(): TaroRootElement | null;
273
- get _scope(): MpInstance | null | undefined;
274
271
  protected findIndex(refChild: TaroNode): number;
275
272
  get _path(): string;
276
273
  get nextSibling(): TaroNode | null;
@@ -594,10 +591,6 @@ declare const taroWindowProvider: TaroWindow;
594
591
  declare const taroLocationProvider: TaroLocation;
595
592
  declare const taroHistoryProvider: TaroHistory;
596
593
 
597
- declare function isNearestCtxEnv(): boolean;
598
- declare function getNearestCtx(node: TaroNode): MpInstance | null | undefined;
599
- declare function bumpNearestCtxEpochForRoot(root: TaroRootElement | null | undefined): void;
600
-
601
594
  declare class SVGElement extends TaroElement {
602
595
  }
603
596
 
@@ -868,7 +861,7 @@ declare function getOnShowEventKey(path: string): string;
868
861
  declare function getOnHideEventKey(path: string): string;
869
862
  declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
870
863
  declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
871
- declare function createRecursiveComponentConfig(componentName?: string, forceCustomWrapper?: boolean): any;
864
+ declare function createRecursiveComponentConfig(componentName?: string): any;
872
865
 
873
866
  /**
874
867
  * React also has a fancy function's name for this: `hydrate()`.
@@ -924,5 +917,5 @@ declare function convertNumber2PX(value: number): string;
924
917
 
925
918
  declare function handlePolyfill(): void;
926
919
 
927
- 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, bumpNearestCtxEpochForRoot, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventHandlerTTDom, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getNearestCtx, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isNearestCtxEnv, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, setInnerHTML, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
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, eventHandlerTTDom, 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, setInnerHTML, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
928
921
  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 };
@@ -1472,53 +1472,6 @@ class TaroEventTarget {
1472
1472
  }
1473
1473
  }
1474
1474
 
1475
- const nearestCtxCache = new WeakMap();
1476
- function isNearestCtxEnv() {
1477
- return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd';
1478
- }
1479
- function getNearestCtx(node) {
1480
- if (!isNearestCtxEnv()) {
1481
- return undefined;
1482
- }
1483
- const root = node._root;
1484
- if (root == null) {
1485
- return null;
1486
- }
1487
- const cached = nearestCtxCache.get(node);
1488
- if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {
1489
- return cached.value;
1490
- }
1491
- const value = resolveNearestCtxValue(node, root);
1492
- nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch });
1493
- return value;
1494
- }
1495
- function resolveNearestCtxValue(node, root) {
1496
- var _a;
1497
- if (node.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
1498
- const ctx = node.ctx;
1499
- if (ctx != null)
1500
- return ctx;
1501
- }
1502
- let current = node.parentNode;
1503
- while (current) {
1504
- if (current.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
1505
- const ctx = current.ctx;
1506
- if (ctx != null)
1507
- return ctx;
1508
- }
1509
- current = current.parentNode;
1510
- }
1511
- return (_a = root.ctx) !== null && _a !== void 0 ? _a : null;
1512
- }
1513
- function bumpNearestCtxEpochForRoot(root) {
1514
- if (!isNearestCtxEnv() || root == null) {
1515
- return;
1516
- }
1517
- if (typeof root.bumpNearestCtxEpoch === 'function') {
1518
- root.bumpNearestCtxEpoch();
1519
- }
1520
- }
1521
-
1522
1475
  const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
1523
1476
  const nodeId = incrementId();
1524
1477
  class TaroNode extends TaroEventTarget {
@@ -1558,9 +1511,6 @@ class TaroNode extends TaroEventTarget {
1558
1511
  var _a;
1559
1512
  return ((_a = this.parentNode) === null || _a === void 0 ? void 0 : _a._root) || null;
1560
1513
  }
1561
- get _scope() {
1562
- return getNearestCtx(this);
1563
- }
1564
1514
  findIndex(refChild) {
1565
1515
  const index = this.childNodes.indexOf(refChild);
1566
1516
  ensure(index !== -1, 'The node to be replaced is not a child of this node.');
@@ -1706,9 +1656,6 @@ class TaroNode extends TaroEventTarget {
1706
1656
  }
1707
1657
  }
1708
1658
  }
1709
- if (this._root) {
1710
- bumpNearestCtxEpochForRoot(this._root);
1711
- }
1712
1659
  MutationObserver$1.record({
1713
1660
  type: "childList" /* MutationRecordType.CHILD_LIST */,
1714
1661
  target: this,
@@ -1785,9 +1732,6 @@ class TaroNode extends TaroEventTarget {
1785
1732
  if (this._root && doUpdate !== false) {
1786
1733
  this.updateChildNodes();
1787
1734
  }
1788
- if (this._root) {
1789
- bumpNearestCtxEpochForRoot(this._root);
1790
- }
1791
1735
  return child;
1792
1736
  }
1793
1737
  remove(options) {
@@ -3699,7 +3643,6 @@ class TaroRootElement extends TaroElement {
3699
3643
  this.updateCallbacks = [];
3700
3644
  this.pendingUpdate = false;
3701
3645
  this.ctx = null;
3702
- this.nearestCtxEpoch = 0;
3703
3646
  this.nodeName = ROOT_STR;
3704
3647
  this.tagName = ROOT_STR.toUpperCase();
3705
3648
  }
@@ -3709,9 +3652,6 @@ class TaroRootElement extends TaroElement {
3709
3652
  get _root() {
3710
3653
  return this;
3711
3654
  }
3712
- bumpNearestCtxEpoch() {
3713
- this.nearestCtxEpoch++;
3714
- }
3715
3655
  scheduleTask(fn) {
3716
3656
  // 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题
3717
3657
  setTimeout(fn);
@@ -4083,8 +4023,13 @@ function createTTDomDocument() {
4083
4023
  el.setAttribute = function (name, value) {
4084
4024
  const result = originalSetAttribute(name, value);
4085
4025
  // 处理 catchMove 属性
4086
- if (name === 'catchMove' && value) {
4087
- el.addEventListener('catchtouchmove', emptyFunction);
4026
+ if (name === 'catchMove') {
4027
+ if (value) {
4028
+ el.addEventListener('catchtouchmove', emptyFunction);
4029
+ }
4030
+ else {
4031
+ el.removeEventListener('catchtouchmove', emptyFunction);
4032
+ }
4088
4033
  }
4089
4034
  return result;
4090
4035
  };
@@ -4303,7 +4248,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
4303
4248
  unmounting = false;
4304
4249
  instances.delete($taroPath);
4305
4250
  if (pageElement) {
4306
- bumpNearestCtxEpochForRoot(pageElement);
4307
4251
  pageElement.ctx = null;
4308
4252
  pageElement = null;
4309
4253
  }
@@ -4466,10 +4410,10 @@ function createComponentConfig(component, componentName, data) {
4466
4410
  });
4467
4411
  return config;
4468
4412
  }
4469
- function createRecursiveComponentConfig(componentName, forceCustomWrapper = false) {
4413
+ function createRecursiveComponentConfig(componentName) {
4470
4414
  const isCustomWrapper = componentName === CUSTOM_WRAPPER;
4471
4415
  const [ATTACHED, DETACHED] = hooks.call('getMiniLifecycleImpl').component;
4472
- const lifeCycles = isCustomWrapper || forceCustomWrapper
4416
+ const lifeCycles = isCustomWrapper
4473
4417
  ? {
4474
4418
  [ATTACHED]() {
4475
4419
  var _a, _b;
@@ -4478,13 +4422,10 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
4478
4422
  }
4479
4423
  const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
4480
4424
  if (isString(componentId)) {
4481
- if (isCustomWrapper) {
4482
- customWrapperCache.set(componentId, this);
4483
- }
4425
+ customWrapperCache.set(componentId, this);
4484
4426
  const el = env.document.getElementById(componentId);
4485
4427
  if (el) {
4486
4428
  el.ctx = this;
4487
- bumpNearestCtxEpochForRoot(el._root);
4488
4429
  }
4489
4430
  }
4490
4431
  },
@@ -4495,13 +4436,10 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
4495
4436
  }
4496
4437
  const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
4497
4438
  if (isString(componentId)) {
4498
- if (isCustomWrapper) {
4499
- customWrapperCache.delete(componentId);
4500
- }
4439
+ customWrapperCache.delete(componentId);
4501
4440
  const el = env.document.getElementById(componentId);
4502
4441
  if (el) {
4503
4442
  el.ctx = null;
4504
- bumpNearestCtxEpochForRoot(el._root);
4505
4443
  }
4506
4444
  }
4507
4445
  }
@@ -4525,7 +4463,7 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
4525
4463
  }
4526
4464
  }, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
4527
4465
  eh: eventHandler
4528
- } }, lifeCycles), { isCustomWrapper, forceCustomWrapper });
4466
+ } }, lifeCycles), { isCustomWrapper });
4529
4467
  }
4530
4468
 
4531
4469
  const TIMEOUT = 100;
@@ -5337,5 +5275,5 @@ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFOR
5337
5275
  handlePolyfill();
5338
5276
  }
5339
5277
 
5340
- 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, bumpNearestCtxEpochForRoot, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventHandlerTTDom, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getNearestCtx, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isNearestCtxEnv, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, setInnerHTML, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
5278
+ 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, eventHandlerTTDom, 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, setInnerHTML, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
5341
5279
  //# sourceMappingURL=runtime.esm.js.map