vite-plugin-taro-runtime 0.7.11 → 0.7.12-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.
Files changed (69) hide show
  1. package/dist/api/dist/tools.d.ts +1 -1
  2. package/dist/api/dist/tools.js +1 -1
  3. package/dist/api/dist/tools.js.map +1 -1
  4. package/dist/components/dist/components/taro-image-core.js +13 -12
  5. package/dist/components/dist/components/taro-scroll-view-core.js +8 -3
  6. package/dist/components/dist/components/taro-web-view-core.js +48 -1
  7. package/dist/components/types/Button.d.ts +7 -0
  8. package/dist/components/types/Image.d.ts +6 -0
  9. package/dist/components/types/Input.d.ts +1 -1
  10. package/dist/components/types/ScrollView.d.ts +5 -0
  11. package/dist/components/types/Textarea.d.ts +1 -1
  12. package/dist/components/types/common.d.ts +24 -1
  13. package/dist/plugin-framework-react/runtime.js +40 -22
  14. package/dist/plugin-framework-react/runtime.js.map +1 -1
  15. package/dist/plugin-platform-h5/definition.json +3 -5
  16. package/dist/plugin-platform-weapp/runtime-utils.js +1 -0
  17. package/dist/plugin-platform-weapp/runtime-utils.js.map +1 -1
  18. package/dist/plugin-platform-weapp/runtime.js +1 -0
  19. package/dist/plugin-platform-weapp/runtime.js.map +1 -1
  20. package/dist/plugin-platform-weapp/types/components.d.ts +1 -0
  21. package/dist/react/index.d.ts +3 -5
  22. package/dist/react/react.esm.js +56 -215
  23. package/dist/react/render.d.ts +9 -13
  24. package/dist/react/renderer-host.d.ts +7 -0
  25. package/dist/runtime/bom/document.js +1 -1
  26. package/dist/runtime/dom/element.js +1 -1
  27. package/dist/runtime/dom/element.js.map +1 -1
  28. package/dist/runtime/dom/nearest-ctx.d.ts +9 -0
  29. package/dist/runtime/dom/nearest-ctx.js +49 -0
  30. package/dist/runtime/dom/nearest-ctx.js.map +1 -0
  31. package/dist/runtime/dom/node.d.ts +3 -1
  32. package/dist/runtime/dom/node.js +10 -0
  33. package/dist/runtime/dom/node.js.map +1 -1
  34. package/dist/runtime/dom/root.d.ts +2 -0
  35. package/dist/runtime/dom/root.js +4 -0
  36. package/dist/runtime/dom/root.js.map +1 -1
  37. package/dist/runtime/dom/style.js +2 -2
  38. package/dist/runtime/dom/style.js.map +1 -1
  39. package/dist/runtime/dsl/common.d.ts +1 -1
  40. package/dist/runtime/dsl/common.js +24 -11
  41. package/dist/runtime/dsl/common.js.map +1 -1
  42. package/dist/runtime/dsl/instance.d.ts +3 -1
  43. package/dist/runtime/index.d.ts +1 -0
  44. package/dist/runtime/index.js +1 -0
  45. package/dist/runtime/index.js.map +1 -1
  46. package/dist/runtime/runtime.esm.d.ts +9 -2
  47. package/dist/runtime/runtime.esm.js +81 -13
  48. package/dist/runtime/runtime.esm.js.map +1 -1
  49. package/dist/taro/package.json +9 -9
  50. package/dist/taro/types/api/device/clipboard.d.ts +5 -0
  51. package/dist/taro/types/api/network/request.d.ts +7 -3
  52. package/dist/taro/types/api/network/upload.d.ts +21 -1
  53. package/dist/taro/types/api/payment/index.d.ts +58 -0
  54. package/dist/taro/types/compile/compiler.d.ts +13 -0
  55. package/dist/taro/types/compile/hooks.d.ts +1 -0
  56. package/dist/taro/types/taro.config.d.ts +64 -0
  57. package/dist/taro-h5/dist/api/base/weapp/app-event.js +15 -5
  58. package/dist/taro-h5/dist/api/base/weapp/app-event.js.map +1 -1
  59. package/dist/taro-h5/dist/api/device/clipboard.js +10 -6
  60. package/dist/taro-h5/dist/api/device/clipboard.js.map +1 -1
  61. package/dist/taro-h5/dist/api/media/map.d.ts +14 -1
  62. package/dist/taro-h5/dist/api/media/map.js +72 -2
  63. package/dist/taro-h5/dist/api/media/map.js.map +1 -1
  64. package/dist/taro-h5/dist/api/taro.d.ts +1 -1
  65. package/dist/taro-h5/dist/api/taro.js +3 -3
  66. package/dist/taro-h5/dist/api/taro.js.map +1 -1
  67. package/dist/taro-h5/dist/api/wxml/IntersectionObserver.js +3 -0
  68. package/dist/taro-h5/dist/api/wxml/IntersectionObserver.js.map +1 -1
  69. package/package.json +16 -16
@@ -1,7 +1,10 @@
1
1
  import { PLATFORM_TYPE, isObject, isEnableTTDom, isString, isFunction, toCamelCase, UNITLESS_PROPERTIES_SET, isNumber, capitalize, internalComponents, isUndefined, noop, isBoolean, hooks, ensure } from '@tarojs/shared';
2
- import { setInnerHTML, FormElement, convertNumber2PX, eventHandlerTTDom, document } from '@tarojs/runtime';
2
+ import { setInnerHTML, convertNumber2PX, eventHandlerTTDom } from '@tarojs/runtime';
3
+ import host from '\0vpt:renderer-host';
4
+ import { version } from 'react';
3
5
  import Reconciler from 'react-reconciler';
4
6
  import {
7
+ ConcurrentRoot,
5
8
  ContinuousEventPriority,
6
9
  DefaultEventPriority,
7
10
  DiscreteEventPriority,
@@ -361,7 +364,7 @@ function getUpdatePayload(dom, oldProps, newProps) {
361
364
  (updatePayload = updatePayload || []).push(i, null);
362
365
  }
363
366
  }
364
- const isFormElement = dom instanceof FormElement;
367
+ const isFormElement = host.isFormElement(dom);
365
368
  for (i in newProps) {
366
369
  if (oldProps[i] !== newProps[i] || (isFormElement && i === 'value')) {
367
370
  // 如果都是 style,且 style 里面的值相等,则无需记录到 payload 中
@@ -599,6 +602,7 @@ function styleObjectToCss(style) {
599
602
  }
600
603
 
601
604
  /* eslint-disable @typescript-eslint/indent */
605
+ // React and native event dispatch share this scoped priority; nested dispatch restores its caller's priority.
602
606
  let taroCurrentUpdatePriority = NoEventPriority;
603
607
  const taroNotPendingTransition = null;
604
608
  const taroHostTransitionContext = {
@@ -611,105 +615,6 @@ const taroHostTransitionContext = {
611
615
  };
612
616
  taroHostTransitionContext.Provider = taroHostTransitionContext;
613
617
  taroHostTransitionContext.Consumer = taroHostTransitionContext;
614
- /**
615
- * WX VPT Page outlet projection
616
- * -----------------------------
617
- * VPT retains one React ownership tree while WX exposes one independent setData surface per native Page. The singleton App
618
- * host records live in each Page's `app` data, the current Page records live in `page`, and Page WXML supplies its own template
619
- * as the default light-DOM slot of the virtual recursive App component. Taro restarts deep template recursion through nested
620
- * `comp` components. At every such native component boundary the slot must be forwarded only through the App branch that
621
- * contains the VPT Page outlet rendered for React's `{children}`: forwarding through all sibling branches creates duplicate
622
- * unnamed slot consumers, while forwarding through none loses the Page.
623
- *
624
- * `vo` is the compact, branch-local answer to "does this App subtree contain the VPT Page outlet?". WXML reads only `i.vo`,
625
- * so its decision is O(1) and it never scans descendants or receives Page data. This renderer owns `vo` rather than Taro's
626
- * hydrate or root scheduler because React's commit boundary is the first point where every host mutation has completed and
627
- * the final parent chain is authoritative. TaroElement already supports arbitrary properties: setAttribute updates
628
- * node.props and queues the normal granular `app.*.vo` path. Structural Taro payloads are lazy functions flushed by setTimeout, so they run
629
- * after resetAfterCommit and naturally serialize the same final `vo` props. There is consequently no projection-specific
630
- * hydration mode, update-path translation, or full App snapshot.
631
- *
632
- * High-level commit flow:
633
- * 1. React applies all Taro host insertions, removals, and reparenting synchronously.
634
- * 2. resetAfterCommit obtains the unique VPT Page outlet and walks parentNode from that outlet to the App root.
635
- * 3. The unchanged root-side suffix is skipped; old leaf-side nodes receive vo=false and new ones receive vo=true.
636
- * 4. Ordinary Taro attribute updates join structural updates in the already scheduled App batch.
637
- * 5. Lazy hydration observes node.props.vo, and the App batch fans out unchanged to every retained native Page.
638
- *
639
- * The App root stores the only persistent projection state as a VPT Page outlet-to-root node array. It contains O(D)
640
- * references, where D is outlet depth, so index 0 is the outlet represented by the latest queued native batch. A normal commit
641
- * performs an O(D) parent walk and raw array comparison and emits no native data when the spine is unchanged. A move touches
642
- * only the leaf-side portions outside the common root-side suffix and never depends on total App size W or Page size. React
643
- * can replace a host when moving it across parents; only then (and during initialization) a single O(W) search finds the new
644
- * VPT Page outlet. WXML still performs one constant-time boolean check per recursive boundary.
645
- */
646
- const VPT_PAGE_OUTLET = 'vpt_page_outlet';
647
- const VPT_PAGE_OUTLET_BRANCH = 'vo';
648
- const vptPageOutletSpineKey = Symbol('vptPageOutletSpine');
649
- /** Finds the VPT Page outlet only during initialization or after React replaced the cached VPT Page outlet host. */
650
- function findVptPageOutlet(node) {
651
- if (node.nodeName === VPT_PAGE_OUTLET)
652
- return node;
653
- const children = node.childNodes;
654
- for (let index = 0; index < children.length; index++) {
655
- const vptPageOutlet = findVptPageOutlet(children[index]);
656
- if (vptPageOutlet)
657
- return vptPageOutlet;
658
- }
659
- }
660
- /** Builds the final ancestor identity array from the VPT Page outlet to the App root. */
661
- function collectVptPageOutletSpine(container, vptPageOutlet) {
662
- // This local array is filled once in parent-link order, then retained unchanged as the next VPT Page outlet spine.
663
- const spine = [];
664
- for (let node = vptPageOutlet; node !== container; node = node.parentNode) {
665
- spine.push(node);
666
- }
667
- return spine;
668
- }
669
- /** Reconciles VPT Page outlet branch membership through ordinary Taro host props after one complete React commit. */
670
- function reconcileVptPageOutletSpine(container) {
671
- // Other React roots, including standalone Page/component roots, do not own the singleton VPT App-view projection.
672
- if (!container.parentNode || container.parentNode.nodeName !== 'container')
673
- return;
674
- const previousSpine = container[vptPageOutletSpineKey] || [];
675
- const previousVptPageOutlet = previousSpine[0];
676
- /*
677
- * Reuse the cached VPT Page outlet while it remains under this App root. Cross-parent React reconciliation may replace
678
- * the host rather than reparent its Taro node, so a detached cache entry requires one search of the committed tree.
679
- */
680
- const vptPageOutlet = previousVptPageOutlet && previousVptPageOutlet._root === container
681
- ? previousVptPageOutlet
682
- : findVptPageOutlet(container);
683
- ensure(vptPageOutlet, 'App must render children exactly once.');
684
- const currentSpine = collectVptPageOutletSpine(container, vptPageOutlet);
685
- /*
686
- * VPT Page outlet parent chains are stored outlet-to-root, so equal nodes form a root-side suffix. These mutable indexes
687
- * walk that suffix once without iterator, callback, Set, or intermediate-array allocation; the remaining prefixes are the
688
- * only candidates whose branch marker can differ.
689
- */
690
- let previousIndex = previousSpine.length - 1;
691
- let currentIndex = currentSpine.length - 1;
692
- while (previousIndex >= 0 && currentIndex >= 0 && previousSpine[previousIndex] === currentSpine[currentIndex]) {
693
- previousIndex--;
694
- currentIndex--;
695
- }
696
- /*
697
- * Detached old nodes are already removed by their parent's structural payload. Surviving nodes in the changed old prefix
698
- * still have native records, so clear their marker through Taro's ordinary attribute queue.
699
- */
700
- for (let index = 0; index <= previousIndex; index++) {
701
- const node = previousSpine[index];
702
- if (node._root === container) {
703
- node.setAttribute(VPT_PAGE_OUTLET_BRANCH, false);
704
- }
705
- }
706
- // Write the changed current prefix after clearing the old prefix so any surviving moved identity ends with vo=true.
707
- for (let index = 0; index <= currentIndex; index++) {
708
- currentSpine[index].setAttribute(VPT_PAGE_OUTLET_BRANCH, true);
709
- }
710
- // This is the sole persistent VPT projection state: the ancestor identities in the latest queued native App batch.
711
- container[vptPageOutletSpineKey] = currentSpine;
712
- }
713
618
  const hostConfig = {
714
619
  // React 19 react-reconciler host config additions.
715
620
  setCurrentUpdatePriority(priority) {
@@ -758,16 +663,11 @@ const hostConfig = {
758
663
  prepareForCommit(..._) {
759
664
  return null;
760
665
  },
761
- /*
762
- * React invokes this synchronously after host mutations and before returning from the commit. Taro defers evaluation of
763
- * structural hydrate functions with setTimeout, so VPT Page outlet branch props written here are batched and visible to
764
- * every compact record serialized for this commit.
765
- */
766
666
  resetAfterCommit(container) {
767
- reconcileVptPageOutletSpine(container);
667
+ host.afterCommit(container);
768
668
  },
769
- createInstance(type, props, _rootContainerInstance, _hostContext, internalInstanceHandle) {
770
- const element = document.createElement(type);
669
+ createInstance(type, props, container, context, internalInstanceHandle) {
670
+ const element = host.createElement(container, context, type);
771
671
  precacheFiberNode(internalInstanceHandle, element);
772
672
  updateFiberProps(element, props);
773
673
  return element;
@@ -777,7 +677,7 @@ const hostConfig = {
777
677
  },
778
678
  finalizeInitialChildren(dom, type, props) {
779
679
  let newProps = props;
780
- if (dom instanceof FormElement) {
680
+ if (host.isFormElement(dom)) {
781
681
  const [defaultName, defaultKey] = ['switch', 'checkbox', 'radio'].includes(type) ? ['checked', 'defaultChecked'] : ['value', 'defaultValue'];
782
682
  if (props.hasOwnProperty(defaultKey)) {
783
683
  newProps = Object.assign(Object.assign({}, newProps), { [defaultName]: props[defaultKey] });
@@ -790,14 +690,11 @@ const hostConfig = {
790
690
  }
791
691
  return false;
792
692
  },
793
- prepareUpdate(instance, _, oldProps, newProps) {
794
- return getUpdatePayload(instance, oldProps, newProps);
795
- },
796
693
  shouldSetTextContent() {
797
694
  return false;
798
695
  },
799
- createTextInstance(text, _rootContainerInstance, _hostContext, internalInstanceHandle) {
800
- const textNode = document.createTextNode(text);
696
+ createTextInstance(text, container, context, internalInstanceHandle) {
697
+ const textNode = host.createText(container, context, text);
801
698
  precacheFiberNode(internalInstanceHandle, textNode);
802
699
  return textNode;
803
700
  },
@@ -815,9 +712,6 @@ const hostConfig = {
815
712
  preparePortalMount: noop,
816
713
  prepareScopeUpdate: noop,
817
714
  getInstanceFromScope: () => null,
818
- getCurrentEventPriority() {
819
- return DefaultEventPriority;
820
- },
821
715
  detachDeletedInstance: noop,
822
716
  // -------------------
823
717
  // Microtasks
@@ -847,11 +741,8 @@ const hostConfig = {
847
741
  textInst.nodeValue = newText;
848
742
  },
849
743
  commitMount: noop,
850
- commitUpdate(dom, updatePayloadOrType, maybeOldProps, maybeNewProps, maybeFiber) {
851
- const isReact19Signature = typeof updatePayloadOrType === 'string';
852
- const oldProps = isReact19Signature ? maybeOldProps : maybeNewProps;
853
- const newProps = isReact19Signature ? maybeNewProps : maybeFiber;
854
- const updatePayload = isReact19Signature ? getUpdatePayload(dom, oldProps, newProps) : updatePayloadOrType;
744
+ commitUpdate(dom, _type, oldProps, newProps) {
745
+ const updatePayload = getUpdatePayload(dom, oldProps, newProps);
855
746
  if (!updatePayload)
856
747
  return;
857
748
  // payload 只包含 children 的时候,不应该再继续触发后续的属性比较和更新的逻辑了
@@ -897,8 +788,8 @@ const hostConfig = {
897
788
  }
898
789
  };
899
790
  const TaroReconciler = Reconciler(hostConfig);
900
- TaroReconciler.flushSync = TaroReconciler.flushSync || TaroReconciler.flushSyncFromReconciler || TaroReconciler.flushSyncWork;
901
- TaroReconciler.runWithPriority = TaroReconciler.runWithPriority || ((priority, fn) => {
791
+ // react-reconciler 0.34 delegates native event priority to the host, not a runWithPriority export.
792
+ function runWithPriority(priority, fn) {
902
793
  const previousPriority = hostConfig.getCurrentUpdatePriority();
903
794
  try {
904
795
  hostConfig.setCurrentUpdatePriority(priority);
@@ -907,11 +798,11 @@ TaroReconciler.runWithPriority = TaroReconciler.runWithPriority || ((priority, f
907
798
  finally {
908
799
  hostConfig.setCurrentUpdatePriority(previousPriority);
909
800
  }
910
- });
801
+ }
911
802
  if (process.env.NODE_ENV !== 'production') {
912
803
  const foundDevTools = TaroReconciler.injectIntoDevTools({
913
804
  bundleType: 1,
914
- version: '18.0.0',
805
+ version,
915
806
  rendererPackageName: 'taro-react'
916
807
  });
917
808
  if (!foundDevTools) {
@@ -959,7 +850,7 @@ function needsStateRestore() {
959
850
  function finishEventHandler() {
960
851
  const controlledComponentsHavePendingUpdates = needsStateRestore();
961
852
  if (controlledComponentsHavePendingUpdates) {
962
- TaroReconciler.flushSync();
853
+ TaroReconciler.flushSyncWork();
963
854
  restoreStateIfNeeded();
964
855
  }
965
856
  }
@@ -995,92 +886,55 @@ function restoreStateOfTarget(item) {
995
886
  }
996
887
  }
997
888
 
889
+ // Native teardown looks up the one concurrent root per host; unmount removes its entry after the commit.
998
890
  const ContainerMap = new WeakMap();
999
- class Root {
1000
- constructor(renderer, domContainer, options) {
1001
- this.renderer = renderer;
1002
- this.initInternalRoot(renderer, domContainer, options);
891
+ function reportRootError(error) {
892
+ console.error(error);
893
+ }
894
+ function reportCaughtError(error, errorInfo) {
895
+ console.error(error);
896
+ if (errorInfo.componentStack) {
897
+ console.error(errorInfo.componentStack);
1003
898
  }
1004
- initInternalRoot(renderer, domContainer, options) {
1005
- // Since react-reconciler v0.27, createContainer need more parameters
1006
- // @see:https://github.com/facebook/react/blob/0b974418c9a56f6c560298560265dcf4b65784bc/packages/react-reconciler/src/ReactFiberReconciler.js#L248
1007
- const containerInfo = domContainer;
1008
- if (options) {
1009
- const tag = 1; // ConcurrentRoot
1010
- const concurrentUpdatesByDefaultOverride = false;
1011
- let isStrictMode = false;
1012
- let identifierPrefix = '';
1013
- let onUncaughtError = (error) => console.error(error);
1014
- let onCaughtError = (error, errorInfo) => {
1015
- console.error(error);
1016
- if (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.componentStack) {
1017
- console.error(errorInfo.componentStack);
1018
- }
1019
- };
1020
- let onRecoverableError = (error) => console.error(error);
1021
- const onDefaultTransitionIndicator = null;
1022
- if (options.unstable_strictMode === true) {
1023
- isStrictMode = true;
1024
- }
1025
- if (options.identifierPrefix !== undefined) {
1026
- identifierPrefix = options.identifierPrefix;
1027
- }
1028
- if (options.onUncaughtError !== undefined) {
1029
- onUncaughtError = options.onUncaughtError;
1030
- }
1031
- if (options.onCaughtError !== undefined) {
1032
- onCaughtError = options.onCaughtError;
1033
- }
1034
- if (options.onRecoverableError !== undefined) {
1035
- onRecoverableError = options.onRecoverableError;
1036
- }
1037
- this.internalRoot = renderer.createContainer(containerInfo, tag, null, // hydrationCallbacks
1038
- isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, onDefaultTransitionIndicator);
1039
- }
1040
- else {
1041
- const tag = 0; // LegacyRoot
1042
- this.internalRoot = renderer.createContainer(containerInfo, tag, null, // hydrationCallbacks
1043
- false, // isStrictMode
1044
- false, // concurrentUpdatesByDefaultOverride,
1045
- '', // identifierPrefix
1046
- (error) => console.error(error), // onUncaughtError
1047
- (error) => console.error(error), // onCaughtError
1048
- (error) => console.error(error), // onRecoverableError
899
+ }
900
+ class Root {
901
+ constructor(domContainer, options) {
902
+ this.domContainer = domContainer;
903
+ this.internalRoot = TaroReconciler.createContainer(
904
+ domContainer,
905
+ ConcurrentRoot,
906
+ null, // hydrationCallbacks
907
+ options.unstable_strictMode === true,
908
+ false, // concurrentUpdatesByDefaultOverride
909
+ options.identifierPrefix ?? '',
910
+ options.onUncaughtError ?? reportRootError,
911
+ options.onCaughtError ?? reportCaughtError,
912
+ options.onRecoverableError ?? reportRootError,
1049
913
  null // onDefaultTransitionIndicator
1050
- );
1051
- }
914
+ );
1052
915
  }
1053
916
  render(children, cb) {
1054
- const { renderer, internalRoot } = this;
1055
- renderer.updateContainer(children, internalRoot, null, cb);
1056
- return renderer.getPublicRootInstance(internalRoot);
917
+ TaroReconciler.updateContainer(children, this.internalRoot, null, cb);
1057
918
  }
1058
919
  unmount(cb) {
1059
- this.renderer.updateContainer(null, this.internalRoot, null, cb);
1060
- }
1061
- }
1062
- function render(element, domContainer, cb) {
1063
- const oldRoot = ContainerMap.get(domContainer);
1064
- if (oldRoot != null) {
1065
- return oldRoot.render(element, cb);
920
+ TaroReconciler.updateContainer(null, this.internalRoot, null, () => {
921
+ ContainerMap.delete(this.domContainer);
922
+ this.domContainer[internalContainerInstanceKey] = null;
923
+ cb?.();
924
+ });
1066
925
  }
1067
- const root = new Root(TaroReconciler, domContainer);
1068
- ContainerMap.set(domContainer, root);
1069
- return root.render(element, cb);
1070
926
  }
1071
- function createRoot(domContainer, options = {}) {
1072
- var _a;
927
+ function createRoot(domContainer, options) {
1073
928
  const oldRoot = ContainerMap.get(domContainer);
1074
929
  if (oldRoot != null) {
1075
930
  return oldRoot;
1076
931
  }
1077
- // options should be an object
1078
- const root = new Root(TaroReconciler, domContainer, options);
932
+ const root = new Root(domContainer, options ?? {});
1079
933
  ContainerMap.set(domContainer, root);
1080
- markContainerAsRoot((_a = root === null || root === void 0 ? void 0 : root.internalRoot) === null || _a === void 0 ? void 0 : _a.current, domContainer);
934
+ markContainerAsRoot(root.internalRoot.current, domContainer);
1081
935
  hooks.tap('dispatchTaroEvent', (e, node) => {
1082
936
  const eventPriority = getEventPriority(e.type);
1083
- TaroReconciler.runWithPriority(eventPriority, () => {
937
+ runWithPriority(eventPriority, () => {
1084
938
  node.dispatchEvent(e);
1085
939
  });
1086
940
  });
@@ -1121,22 +975,10 @@ function unmountComponentAtNode(dom) {
1121
975
  if (!root)
1122
976
  return false;
1123
977
  unstable_batchedUpdates(() => {
1124
- root.unmount(() => {
1125
- ContainerMap.delete(dom);
1126
- });
978
+ root.unmount();
1127
979
  }, null);
1128
980
  return true;
1129
981
  }
1130
- function findDOMNode(comp) {
1131
- if (comp == null) {
1132
- return null;
1133
- }
1134
- const nodeType = comp.nodeType;
1135
- if (nodeType === 1 || nodeType === 3) {
1136
- return comp;
1137
- }
1138
- return TaroReconciler.findHostInstance(comp);
1139
- }
1140
982
  const portalType = isFunction(Symbol) && Symbol.for
1141
983
  ? Symbol.for('react.portal')
1142
984
  : 0xeaca;
@@ -1149,17 +991,16 @@ function createPortal(children, containerInfo, key) {
1149
991
  implementation: null
1150
992
  };
1151
993
  }
1152
- const flushSync = TaroReconciler.flushSync;
994
+ // Public flushSync runs a callback at synchronous priority; controlled-input restoration only flushes queued sync work.
995
+ const flushSync = TaroReconciler.flushSyncFromReconciler;
1153
996
  var index = {
1154
- render,
1155
997
  flushSync,
1156
998
  createRoot,
1157
999
  unstable_batchedUpdates,
1158
1000
  unmountComponentAtNode,
1159
- findDOMNode,
1160
1001
  createPortal,
1161
1002
  internalInstanceKey
1162
1003
  };
1163
1004
 
1164
- export { createPortal, createRoot, index as default, findDOMNode, flushSync, internalInstanceKey, render, unmountComponentAtNode, unstable_batchedUpdates };
1005
+ export { createPortal, createRoot, index as default, flushSync, internalInstanceKey, unmountComponentAtNode, unstable_batchedUpdates };
1165
1006
  //# sourceMappingURL=react.esm.js.map
@@ -1,25 +1,21 @@
1
- import { TaroReconciler } from './reconciler';
2
1
  import type { TaroElement } from 'vite-plugin-taro-runtime/runtime/mini';
3
- import type { ReactNode } from 'react';
2
+ import type { ErrorInfo, ReactNode } from 'react';
4
3
  import type { OpaqueRoot } from 'react-reconciler';
5
4
  export declare const ContainerMap: WeakMap<TaroElement, Root>;
6
- type Renderer = typeof TaroReconciler;
7
5
  type CreateRootOptions = {
8
6
  unstable_strictMode?: boolean;
9
- unstable_concurrentUpdatesByDefault?: boolean;
10
- unstable_transitionCallbacks?: any;
11
7
  identifierPrefix?: string;
12
- onRecoverableError?: (error: any) => void;
8
+ onUncaughtError?: (error: unknown, errorInfo: ErrorInfo) => void;
9
+ onCaughtError?: (error: unknown, errorInfo: ErrorInfo) => void;
10
+ onRecoverableError?: (error: unknown, errorInfo: ErrorInfo) => void;
13
11
  };
14
- export type Callback = () => void | null | undefined;
12
+ export type Callback = () => void;
15
13
  declare class Root {
16
- private renderer;
14
+ private domContainer;
17
15
  internalRoot: OpaqueRoot;
18
- constructor(renderer: Renderer, domContainer: TaroElement, options?: CreateRootOptions);
19
- private initInternalRoot;
20
- render(children: ReactNode, cb: Callback): TaroElement | import("react").Component<any, any, any> | null;
21
- unmount(cb: Callback): void;
16
+ constructor(domContainer: TaroElement, options: CreateRootOptions);
17
+ render(children: ReactNode, cb?: Callback): void;
18
+ unmount(cb?: Callback): void;
22
19
  }
23
- export declare function render(element: ReactNode, domContainer: TaroElement, cb: Callback): TaroElement | import("react").Component<any, any, any> | null;
24
20
  export declare function createRoot(domContainer: TaroElement, options?: CreateRootOptions): Root;
25
21
  export {};
@@ -0,0 +1,7 @@
1
+ /** Host-owned creation, form classification and post-commit work for the shared React renderer. */
2
+ export type RendererHost<Container, Context, Element, Text> = Readonly<{
3
+ createElement(container: Container, context: Context, type: string): Element
4
+ createText(container: Container, context: Context, text: string): Text
5
+ isFormElement(element: Element): boolean
6
+ afterCommit(container: Container): void
7
+ }>
@@ -28,7 +28,7 @@ function createDocument() {
28
28
  * same React container and keeps the same id, but can now batch app.* updates through its own ctx just as each Page root
29
29
  * batches page.* updates. Reusing the host itself removes the need for a detached scheduler node.
30
30
  *
31
- * Taro and the framework locate this container by id; the pinned 4.2.1 runtime has no behavior branching on an APP
31
+ * Taro and the framework locate this container by id; the pinned 4.3.0 runtime has no behavior branching on an APP
32
32
  * nodeName or APP tagName. App snapshots hydrate the container's children rather than the container record itself, so
33
33
  * ROOT is never emitted as a native layout node. The observable change is limited to unsupported code directly
34
34
  * inspecting #app.nodeName/tagName or using this support fork with upstream templates. H5 loads the untouched
@@ -300,7 +300,7 @@ class TaroElement extends TaroNode {
300
300
  hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias);
301
301
  if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
302
302
  const componentsAlias = getComponentsAlias();
303
- const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
303
+ const value = name === VIEW && !isHasExtractProp(this) ? PURE_VIEW : `static-${name}`;
304
304
  const valueAlias = componentsAlias[value]._num;
305
305
  this.enqueueUpdate({
306
306
  path: `${this._path}.${"nn" /* Shortcuts.NodeName */}`,
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","sources":["../../../src/dom/element.ts"],"sourcesContent":["import { EMPTY_OBJ, hooks, isArray, isFunction, isObject, isString, isUndefined, Shortcuts, toCamelCase, warn } from '@tarojs/shared'\n\nimport {\n CATCH_VIEW,\n CATCHMOVE,\n CLASS,\n CLICK_VIEW,\n EVENT_CALLBACK_RESULT,\n FOCUS,\n ID,\n PROPERTY_THRESHOLD,\n PURE_VIEW,\n STATIC_VIEW,\n STYLE,\n VIEW\n} from '../constants'\nimport { MutationObserver, MutationRecordType } from '../dom-external/mutation-observer'\nimport { extend, getComponentsAlias, isElement, isHasExtractProp, shortcutAttr } from '../utils'\nimport { ClassList } from './class-list'\nimport { eventSource } from './event-source'\nimport { TaroNode } from './node'\nimport { NodeType } from './node_types'\nimport { Style } from './style'\nimport { treeToArray } from './tree'\n\nimport type { Attributes, TFunc } from '../interface'\nimport type { TaroEvent } from './event'\n\nexport class TaroElement extends TaroNode {\n public ctx?\n public tagName: string\n public props: Record<string, any> = {}\n public style: Style\n public dataset: Record<string, unknown> = EMPTY_OBJ\n public innerHTML: string\n\n public constructor () {\n super()\n this.nodeType = NodeType.ELEMENT_NODE\n this.style = new Style(this)\n hooks.call('patchElement', this)\n }\n\n private _stopPropagation (event: TaroEvent) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let target = this\n // eslint-disable-next-line no-cond-assign\n while ((target = target.parentNode as this)) {\n const listeners = target.__handlers[event.type]\n\n if (!isArray(listeners)) {\n continue\n }\n\n for (let i = listeners.length; i--;) {\n const l = listeners[i]\n l._stop = true\n }\n }\n }\n\n public get id (): string {\n return this.getAttribute(ID)!\n }\n\n public set id (val: string) {\n this.setAttribute(ID, val)\n }\n\n public get className (): string {\n return this.getAttribute(CLASS) || ''\n }\n\n public set className (val: string) {\n this.setAttribute(CLASS, val)\n }\n\n public get cssText (): string {\n return this.getAttribute(STYLE) || ''\n }\n\n public get classList (): ClassList {\n return new ClassList(this.className, this)\n }\n\n public get children (): TaroElement[] {\n return this.childNodes.filter(isElement)\n }\n\n public get attributes (): Attributes[] {\n const props = this.props\n const propKeys = Object.keys(props)\n const style = this.style.cssText\n const attrs = propKeys.map(key => ({ name: key, value: props[key] }))\n return attrs.concat(style ? { name: STYLE, value: style } : [])\n }\n\n public get textContent (): string {\n let text = ''\n const childNodes = this.childNodes\n\n for (let i = 0; i < childNodes.length; i++) {\n text += childNodes[i].textContent\n }\n\n return text\n }\n\n public set textContent (text: string) {\n super.textContent = text\n }\n\n public hasAttribute (qualifiedName: string): boolean {\n return !isUndefined(this.props[qualifiedName])\n }\n\n public hasAttributes (): boolean {\n return this.attributes.length > 0\n }\n\n public get focus () {\n return function () {\n this.setAttribute(FOCUS, true)\n }\n }\n\n // 兼容 Vue3,详情请见:https://github.com/NervJS/taro/issues/10579\n public set focus (value) {\n this.setAttribute(FOCUS, value)\n }\n\n public blur () {\n this.setAttribute(FOCUS, false)\n }\n\n public setAttribute (qualifiedName: string, value: any): void {\n process.env.NODE_ENV !== 'production' && warn(\n isString(value) && value.length > PROPERTY_THRESHOLD,\n `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`\n )\n\n const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded()\n\n if (qualifiedName !== STYLE) {\n MutationObserver.record({\n target: this,\n type: MutationRecordType.ATTRIBUTES,\n attributeName: qualifiedName,\n oldValue: this.getAttribute(qualifiedName)\n })\n }\n\n switch (qualifiedName) {\n case STYLE:\n this.style.cssText = value as string\n break\n case ID:\n if (this.uid !== this.sid) {\n // eventSource[sid] 永远保留,直到组件卸载\n // eventSource[uid] 可变\n eventSource.delete(this.uid)\n }\n value = String(value)\n this.props[qualifiedName] = this.uid = value\n eventSource.set(value, this)\n break\n default:\n this.props[qualifiedName] = value as string\n\n if (qualifiedName.startsWith('data-')) {\n if (this.dataset === EMPTY_OBJ) {\n this.dataset = Object.create(null)\n }\n this.dataset[toCamelCase(qualifiedName.replace(/^data-/, ''))] = value\n }\n break\n }\n\n // Serialization\n if (!this._root) return\n\n const componentsAlias = getComponentsAlias()\n const _alias = componentsAlias[this.nodeName]\n const viewAlias = componentsAlias[VIEW]._num\n const clickViewAlias = componentsAlias[CLICK_VIEW]._num\n const staticViewAlias = componentsAlias[STATIC_VIEW]._num\n const catchViewAlias = componentsAlias[CATCH_VIEW]._num\n const _path = this._path\n\n qualifiedName = shortcutAttr(qualifiedName)\n\n const qualifiedNameInCamelCase = toCamelCase(qualifiedName)\n const payload = {\n path: `${_path}.${qualifiedNameInCamelCase}`,\n value: isFunction(value) ? () => value : value\n }\n\n hooks.call('modifySetAttrPayload', this, qualifiedName, payload, componentsAlias)\n\n if (_alias) {\n const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName\n payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`\n }\n\n this.enqueueUpdate(payload)\n\n if (this.nodeName === VIEW) {\n if (qualifiedNameInCamelCase === CATCHMOVE) {\n // catchMove = true: catch-view\n // catchMove = false: view or click-view or static-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: value ? catchViewAlias : (\n this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)\n )\n })\n } else if (isPureView && isHasExtractProp(this)) {\n // pure-view => static-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: staticViewAlias\n })\n }\n }\n }\n\n public removeAttribute (qualifiedName: string) {\n const isStaticView = this.nodeName === VIEW && isHasExtractProp(this) && !this.isAnyEventBinded()\n\n MutationObserver.record({\n target: this,\n type: MutationRecordType.ATTRIBUTES,\n attributeName: qualifiedName,\n oldValue: this.getAttribute(qualifiedName)\n })\n\n if (qualifiedName === STYLE) {\n this.style.cssText = ''\n } else {\n const isInterrupt = hooks.call('onRemoveAttribute', this, qualifiedName)\n if (isInterrupt) {\n return\n }\n\n if (!this.props.hasOwnProperty(qualifiedName)) {\n return\n }\n delete this.props[qualifiedName]\n }\n\n // Serialization\n if (!this._root) return\n\n const componentsAlias = getComponentsAlias()\n const _alias = componentsAlias[this.nodeName]\n const viewAlias = componentsAlias[VIEW]._num\n const staticViewAlias = componentsAlias[STATIC_VIEW]._num\n const pureViewAlias = componentsAlias[PURE_VIEW]._num\n const clickViewAlias = componentsAlias[CLICK_VIEW]._num\n const _path = this._path\n\n qualifiedName = shortcutAttr(qualifiedName)\n\n const qualifiedNameInCamelCase = toCamelCase(qualifiedName)\n const payload = {\n path: `${_path}.${qualifiedNameInCamelCase}`,\n value: ''\n }\n\n hooks.call('modifyRmAttrPayload', this, qualifiedName, payload, componentsAlias)\n\n if (_alias) {\n const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName\n payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`\n }\n\n this.enqueueUpdate(payload)\n\n if (this.nodeName === VIEW) {\n if (qualifiedNameInCamelCase === CATCHMOVE) {\n // catch-view => view or click-view or static-view or pure-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))\n })\n } else if (isStaticView && !isHasExtractProp(this)) {\n // static-view => pure-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: pureViewAlias\n })\n }\n }\n }\n\n public getAttribute (qualifiedName: string): string {\n const attr = qualifiedName === STYLE ? this.style.cssText : this.props[qualifiedName]\n return attr ?? ''\n }\n\n public getElementsByTagName (tagName: string): TaroElement[] {\n return treeToArray(this, (el) => {\n return el.nodeName === tagName || (tagName === '*' && this !== el)\n })\n }\n\n public getElementsByClassName (className: string): TaroElement[] {\n const classNames = className.trim().split(/\\s+/)\n\n return treeToArray(this, (el) => {\n const classList = el.classList\n return classNames.every(c => classList.contains(c))\n })\n }\n\n public dispatchEvent (event: TaroEvent): boolean {\n const cancelable = event.cancelable\n\n const listeners = this.__handlers[event.type]\n\n if (!isArray(listeners)) {\n return false\n }\n\n for (let i = listeners.length; i--;) {\n const listener = listeners[i]\n let result: unknown\n if (listener._stop) {\n listener._stop = false\n } else {\n hooks.call('modifyDispatchEvent', event, this)\n result = listener.call(this, event)\n }\n if ((result === false || event._end) && cancelable) {\n event.defaultPrevented = true\n }\n\n if (!isUndefined(result) && event.mpEvent) {\n const res = hooks.call('modifyTaroEventReturn', this, event, result)\n if (res) { event.mpEvent[EVENT_CALLBACK_RESULT] = result }\n }\n\n if (event._end && event._stop) {\n break\n }\n }\n\n if (event._stop) {\n this._stopPropagation(event)\n }\n\n return listeners != null\n }\n\n public addEventListener (type, handler, options) {\n const name = this.nodeName\n const SPECIAL_NODES = hooks.call('getSpecialNodes')!\n\n let sideEffect = true\n if (isObject<Record<string, any>>(options) && options.sideEffect === false) {\n sideEffect = false\n delete options.sideEffect\n }\n\n hooks.call('modifyAddEventListener', this, sideEffect, getComponentsAlias)\n\n if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {\n const componentsAlias = getComponentsAlias()\n const alias = componentsAlias[name]._num\n this.enqueueUpdate({\n path: `${this._path}.${Shortcuts.NodeName}`,\n value: alias\n })\n }\n\n super.addEventListener(type, handler, options)\n }\n\n public removeEventListener (type, handler, sideEffect = true) {\n super.removeEventListener(type, handler)\n\n const name = this.nodeName\n const SPECIAL_NODES = hooks.call('getSpecialNodes')!\n\n hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias)\n\n if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {\n const componentsAlias = getComponentsAlias()\n const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`\n const valueAlias = componentsAlias[value]._num\n this.enqueueUpdate({\n path: `${this._path}.${Shortcuts.NodeName}`,\n value: valueAlias\n })\n }\n }\n\n static extend (methodName: string, options: TFunc | Record<string, any>) {\n extend(TaroElement, methodName, options)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AA4BM,MAAO,WAAY,SAAQ,QAAQ,CAAA;AAQvC,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;QANF,IAAK,CAAA,KAAA,GAAwB,EAAE;QAE/B,IAAO,CAAA,OAAA,GAA4B,SAAS;QAKjD,IAAI,CAAC,QAAQ,GAAA,CAAA;QACb,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC;AAC5B,QAAA,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC;;AAG1B,IAAA,gBAAgB,CAAE,KAAgB,EAAA;;QAExC,IAAI,MAAM,GAAG,IAAI;;QAEjB,QAAQ,MAAM,GAAG,MAAM,CAAC,UAAkB,GAAG;YAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;AAE/C,YAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBACvB;;YAGF,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG;AACnC,gBAAA,MAAM,CAAC,GAAG,SAAS,CAAC,CAA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,IAAI,CAAC,GAAG,EAAE,EAAE;AACxF,YAAA,MAAM,eAAe,GAAG,kBAAkB,EAAE;AAC5C,YAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAU,OAAA,EAAA,IAAI,EAAE,GAAG,CAAQ,KAAA,EAAA,IAAI,EAAE;YACxE,MAAM,UAAU,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,IAAI;YAC9C,IAAI,CAAC,aAAa,CAAC;AACjB,gBAAA,IAAI,EAAE,CAAG,EAAA,IAAI,CAAC,KAAK,CAAA,CAAA,EAAI,8BAAoB,CAAA;AAC3C,gBAAA,KAAK,EAAE;AACR,aAAA,CAAC;;;AAIN,IAAA,OAAO,MAAM,CAAE,UAAkB,EAAE,OAAoC,EAAA;AACrE,QAAA,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC;;AAE3C;;;;"}
1
+ {"version":3,"file":"element.js","sources":["../../../src/dom/element.ts"],"sourcesContent":["import { EMPTY_OBJ, hooks, isArray, isFunction, isObject, isString, isUndefined, Shortcuts, toCamelCase, warn } from '@tarojs/shared'\n\nimport {\n CATCH_VIEW,\n CATCHMOVE,\n CLASS,\n CLICK_VIEW,\n EVENT_CALLBACK_RESULT,\n FOCUS,\n ID,\n PROPERTY_THRESHOLD,\n PURE_VIEW,\n STATIC_VIEW,\n STYLE,\n VIEW\n} from '../constants'\nimport { MutationObserver, MutationRecordType } from '../dom-external/mutation-observer'\nimport { extend, getComponentsAlias, isElement, isHasExtractProp, shortcutAttr } from '../utils'\nimport { ClassList } from './class-list'\nimport { eventSource } from './event-source'\nimport { TaroNode } from './node'\nimport { NodeType } from './node_types'\nimport { Style } from './style'\nimport { treeToArray } from './tree'\n\nimport type { Attributes, TFunc } from '../interface'\nimport type { TaroEvent } from './event'\n\nexport class TaroElement extends TaroNode {\n public ctx?\n public tagName: string\n public props: Record<string, any> = {}\n public style: Style\n public dataset: Record<string, unknown> = EMPTY_OBJ\n public innerHTML: string\n\n public constructor () {\n super()\n this.nodeType = NodeType.ELEMENT_NODE\n this.style = new Style(this)\n hooks.call('patchElement', this)\n }\n\n private _stopPropagation (event: TaroEvent) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let target = this\n // eslint-disable-next-line no-cond-assign\n while ((target = target.parentNode as this)) {\n const listeners = target.__handlers[event.type]\n\n if (!isArray(listeners)) {\n continue\n }\n\n for (let i = listeners.length; i--;) {\n const l = listeners[i]\n l._stop = true\n }\n }\n }\n\n public get id (): string {\n return this.getAttribute(ID)!\n }\n\n public set id (val: string) {\n this.setAttribute(ID, val)\n }\n\n public get className (): string {\n return this.getAttribute(CLASS) || ''\n }\n\n public set className (val: string) {\n this.setAttribute(CLASS, val)\n }\n\n public get cssText (): string {\n return this.getAttribute(STYLE) || ''\n }\n\n public get classList (): ClassList {\n return new ClassList(this.className, this)\n }\n\n public get children (): TaroElement[] {\n return this.childNodes.filter(isElement)\n }\n\n public get attributes (): Attributes[] {\n const props = this.props\n const propKeys = Object.keys(props)\n const style = this.style.cssText\n const attrs = propKeys.map(key => ({ name: key, value: props[key] }))\n return attrs.concat(style ? { name: STYLE, value: style } : [])\n }\n\n public get textContent (): string {\n let text = ''\n const childNodes = this.childNodes\n\n for (let i = 0; i < childNodes.length; i++) {\n text += childNodes[i].textContent\n }\n\n return text\n }\n\n public set textContent (text: string) {\n super.textContent = text\n }\n\n public hasAttribute (qualifiedName: string): boolean {\n return !isUndefined(this.props[qualifiedName])\n }\n\n public hasAttributes (): boolean {\n return this.attributes.length > 0\n }\n\n public get focus () {\n return function () {\n this.setAttribute(FOCUS, true)\n }\n }\n\n // 兼容 Vue3,详情请见:https://github.com/NervJS/taro/issues/10579\n public set focus (value) {\n this.setAttribute(FOCUS, value)\n }\n\n public blur () {\n this.setAttribute(FOCUS, false)\n }\n\n public setAttribute (qualifiedName: string, value: any): void {\n process.env.NODE_ENV !== 'production' && warn(\n isString(value) && value.length > PROPERTY_THRESHOLD,\n `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`\n )\n\n const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded()\n\n if (qualifiedName !== STYLE) {\n MutationObserver.record({\n target: this,\n type: MutationRecordType.ATTRIBUTES,\n attributeName: qualifiedName,\n oldValue: this.getAttribute(qualifiedName)\n })\n }\n\n switch (qualifiedName) {\n case STYLE:\n this.style.cssText = value as string\n break\n case ID:\n if (this.uid !== this.sid) {\n // eventSource[sid] 永远保留,直到组件卸载\n // eventSource[uid] 可变\n eventSource.delete(this.uid)\n }\n value = String(value)\n this.props[qualifiedName] = this.uid = value\n eventSource.set(value, this)\n break\n default:\n this.props[qualifiedName] = value as string\n\n if (qualifiedName.startsWith('data-')) {\n if (this.dataset === EMPTY_OBJ) {\n this.dataset = Object.create(null)\n }\n this.dataset[toCamelCase(qualifiedName.replace(/^data-/, ''))] = value\n }\n break\n }\n\n // Serialization\n if (!this._root) return\n\n const componentsAlias = getComponentsAlias()\n const _alias = componentsAlias[this.nodeName]\n const viewAlias = componentsAlias[VIEW]._num\n const clickViewAlias = componentsAlias[CLICK_VIEW]._num\n const staticViewAlias = componentsAlias[STATIC_VIEW]._num\n const catchViewAlias = componentsAlias[CATCH_VIEW]._num\n const _path = this._path\n\n qualifiedName = shortcutAttr(qualifiedName)\n\n const qualifiedNameInCamelCase = toCamelCase(qualifiedName)\n const payload = {\n path: `${_path}.${qualifiedNameInCamelCase}`,\n value: isFunction(value) ? () => value : value\n }\n\n hooks.call('modifySetAttrPayload', this, qualifiedName, payload, componentsAlias)\n\n if (_alias) {\n const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName\n payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`\n }\n\n this.enqueueUpdate(payload)\n\n if (this.nodeName === VIEW) {\n if (qualifiedNameInCamelCase === CATCHMOVE) {\n // catchMove = true: catch-view\n // catchMove = false: view or click-view or static-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: value ? catchViewAlias : (\n this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)\n )\n })\n } else if (isPureView && isHasExtractProp(this)) {\n // pure-view => static-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: staticViewAlias\n })\n }\n }\n }\n\n public removeAttribute (qualifiedName: string) {\n const isStaticView = this.nodeName === VIEW && isHasExtractProp(this) && !this.isAnyEventBinded()\n\n MutationObserver.record({\n target: this,\n type: MutationRecordType.ATTRIBUTES,\n attributeName: qualifiedName,\n oldValue: this.getAttribute(qualifiedName)\n })\n\n if (qualifiedName === STYLE) {\n this.style.cssText = ''\n } else {\n const isInterrupt = hooks.call('onRemoveAttribute', this, qualifiedName)\n if (isInterrupt) {\n return\n }\n\n if (!this.props.hasOwnProperty(qualifiedName)) {\n return\n }\n delete this.props[qualifiedName]\n }\n\n // Serialization\n if (!this._root) return\n\n const componentsAlias = getComponentsAlias()\n const _alias = componentsAlias[this.nodeName]\n const viewAlias = componentsAlias[VIEW]._num\n const staticViewAlias = componentsAlias[STATIC_VIEW]._num\n const pureViewAlias = componentsAlias[PURE_VIEW]._num\n const clickViewAlias = componentsAlias[CLICK_VIEW]._num\n const _path = this._path\n\n qualifiedName = shortcutAttr(qualifiedName)\n\n const qualifiedNameInCamelCase = toCamelCase(qualifiedName)\n const payload = {\n path: `${_path}.${qualifiedNameInCamelCase}`,\n value: ''\n }\n\n hooks.call('modifyRmAttrPayload', this, qualifiedName, payload, componentsAlias)\n\n if (_alias) {\n const qualifiedNameAlias = _alias[qualifiedNameInCamelCase] || qualifiedName\n payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`\n }\n\n this.enqueueUpdate(payload)\n\n if (this.nodeName === VIEW) {\n if (qualifiedNameInCamelCase === CATCHMOVE) {\n // catch-view => view or click-view or static-view or pure-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))\n })\n } else if (isStaticView && !isHasExtractProp(this)) {\n // static-view => pure-view\n this.enqueueUpdate({\n path: `${_path}.${Shortcuts.NodeName}`,\n value: pureViewAlias\n })\n }\n }\n }\n\n public getAttribute (qualifiedName: string): string {\n const attr = qualifiedName === STYLE ? this.style.cssText : this.props[qualifiedName]\n return attr ?? ''\n }\n\n public getElementsByTagName (tagName: string): TaroElement[] {\n return treeToArray(this, (el) => {\n return el.nodeName === tagName || (tagName === '*' && this !== el)\n })\n }\n\n public getElementsByClassName (className: string): TaroElement[] {\n const classNames = className.trim().split(/\\s+/)\n\n return treeToArray(this, (el) => {\n const classList = el.classList\n return classNames.every(c => classList.contains(c))\n })\n }\n\n public dispatchEvent (event: TaroEvent): boolean {\n const cancelable = event.cancelable\n\n const listeners = this.__handlers[event.type]\n\n if (!isArray(listeners)) {\n return false\n }\n\n for (let i = listeners.length; i--;) {\n const listener = listeners[i]\n let result: unknown\n if (listener._stop) {\n listener._stop = false\n } else {\n hooks.call('modifyDispatchEvent', event, this)\n result = listener.call(this, event)\n }\n if ((result === false || event._end) && cancelable) {\n event.defaultPrevented = true\n }\n\n if (!isUndefined(result) && event.mpEvent) {\n const res = hooks.call('modifyTaroEventReturn', this, event, result)\n if (res) { event.mpEvent[EVENT_CALLBACK_RESULT] = result }\n }\n\n if (event._end && event._stop) {\n break\n }\n }\n\n if (event._stop) {\n this._stopPropagation(event)\n }\n\n return listeners != null\n }\n\n public addEventListener (type, handler, options) {\n const name = this.nodeName\n const SPECIAL_NODES = hooks.call('getSpecialNodes')!\n\n let sideEffect = true\n if (isObject<Record<string, any>>(options) && options.sideEffect === false) {\n sideEffect = false\n delete options.sideEffect\n }\n\n hooks.call('modifyAddEventListener', this, sideEffect, getComponentsAlias)\n\n if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {\n const componentsAlias = getComponentsAlias()\n const alias = componentsAlias[name]._num\n this.enqueueUpdate({\n path: `${this._path}.${Shortcuts.NodeName}`,\n value: alias\n })\n }\n\n super.addEventListener(type, handler, options)\n }\n\n public removeEventListener (type, handler, sideEffect = true) {\n super.removeEventListener(type, handler)\n\n const name = this.nodeName\n const SPECIAL_NODES = hooks.call('getSpecialNodes')!\n\n hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias)\n\n if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {\n const componentsAlias = getComponentsAlias()\n const value = name === VIEW && !isHasExtractProp(this) ? PURE_VIEW : `static-${name}`\n const valueAlias = componentsAlias[value]._num\n this.enqueueUpdate({\n path: `${this._path}.${Shortcuts.NodeName}`,\n value: valueAlias\n })\n }\n }\n\n static extend (methodName: string, options: TFunc | Record<string, any>) {\n extend(TaroElement, methodName, options)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AA4BM,MAAO,WAAY,SAAQ,QAAQ,CAAA;AAQvC,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;QANF,IAAK,CAAA,KAAA,GAAwB,EAAE;QAE/B,IAAO,CAAA,OAAA,GAA4B,SAAS;QAKjD,IAAI,CAAC,QAAQ,GAAA,CAAA;QACb,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC;AAC5B,QAAA,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC;;AAG1B,IAAA,gBAAgB,CAAE,KAAgB,EAAA;;QAExC,IAAI,MAAM,GAAG,IAAI;;QAEjB,QAAQ,MAAM,GAAG,MAAM,CAAC,UAAkB,GAAG;YAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;AAE/C,YAAA,IAAI,CAAC,OAAO,CAAC,SAAS,C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,IAAI,EAAE,UAAU,EAAE,kBAAkB,CAAC;QAE7E,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE;AACxF,YAAA,MAAM,eAAe,GAAG,kBAAkB,EAAE;YAC5C,MAAM,KAAK,GAAG,IAAI,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,SAAS,GAAG,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE;YACrF,MAAM,UAAU,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,IAAI;YAC9C,IAAI,CAAC,aAAa,CAAC;AACjB,gBAAA,IAAI,EAAE,CAAG,EAAA,IAAI,CAAC,KAAK,CAAA,CAAA,EAAI,8BAAoB,CAAA;AAC3C,gBAAA,KAAK,EAAE;AACR,aAAA,CAAC;;;AAIN,IAAA,OAAO,MAAM,CAAE,UAAkB,EAAE,OAAoC,EAAA;AACrE,QAAA,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC;;AAE3C;;;;"}
@@ -0,0 +1,9 @@
1
+ import { MpInstance } from '../interface/hydrate.js';
2
+ import { TaroNode } from './node.js';
3
+ import { TaroRootElement } from './root.js';
4
+
5
+ declare function isNearestCtxEnv(): boolean;
6
+ declare function getNearestCtx(node: TaroNode): MpInstance | null | undefined;
7
+ declare function bumpNearestCtxEpochForRoot(root: TaroRootElement | null | undefined): void;
8
+
9
+ export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv };
@@ -0,0 +1,49 @@
1
+ const nearestCtxCache = new WeakMap();
2
+ function isNearestCtxEnv() {
3
+ return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd';
4
+ }
5
+ function getNearestCtx(node) {
6
+ if (!isNearestCtxEnv()) {
7
+ return undefined;
8
+ }
9
+ const root = node._root;
10
+ if (root == null) {
11
+ return null;
12
+ }
13
+ const cached = nearestCtxCache.get(node);
14
+ if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {
15
+ return cached.value;
16
+ }
17
+ const value = resolveNearestCtxValue(node, root);
18
+ nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch });
19
+ return value;
20
+ }
21
+ function resolveNearestCtxValue(node, root) {
22
+ var _a;
23
+ if (node.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
24
+ const ctx = node.ctx;
25
+ if (ctx != null)
26
+ return ctx;
27
+ }
28
+ let current = node.parentNode;
29
+ while (current) {
30
+ if (current.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
31
+ const ctx = current.ctx;
32
+ if (ctx != null)
33
+ return ctx;
34
+ }
35
+ current = current.parentNode;
36
+ }
37
+ return (_a = root.ctx) !== null && _a !== void 0 ? _a : null;
38
+ }
39
+ function bumpNearestCtxEpochForRoot(root) {
40
+ if (!isNearestCtxEnv() || root == null) {
41
+ return;
42
+ }
43
+ if (typeof root.bumpNearestCtxEpoch === 'function') {
44
+ root.bumpNearestCtxEpoch();
45
+ }
46
+ }
47
+
48
+ export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv };
49
+ //# sourceMappingURL=nearest-ctx.js.map