@tarojs/react 3.5.0-beta.2 → 3.5.0-beta.5

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.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/props.ts","../src/reconciler.ts","../src/render.ts","../src/index.ts"],"sourcesContent":["import { FormElement, Style, TaroElement } from '@tarojs/runtime'\nimport { capitalize, internalComponents, isFunction, isNumber, isObject, isString, toCamelCase } from '@tarojs/shared'\n\nexport type Props = Record<string, unknown>\n\nfunction isEventName (s: string) {\n return s[0] === 'o' && s[1] === 'n'\n}\n\nconst IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i\n\nexport function updateProps (dom: TaroElement, oldProps: Props, newProps: Props) {\n let i: string\n\n for (i in oldProps) {\n if (!(i in newProps)) {\n setProperty(dom, i, null, oldProps[i])\n }\n }\n const isFormElement = dom instanceof FormElement\n for (i in newProps) {\n if (oldProps[i] !== newProps[i] || (isFormElement && i === 'value')) {\n setProperty(dom, i, newProps[i], oldProps[i])\n }\n }\n}\n\n// function eventProxy (e: CommonEvent) {\n// const el = document.getElementById(e.currentTarget.id)\n// const handlers = el!.__handlers[e.type]\n// handlers[0](e)\n// }\n\nfunction setEvent (dom: TaroElement, name: string, value: unknown, oldValue?: unknown) {\n const isCapture = name.endsWith('Capture')\n let eventName = name.toLowerCase().slice(2)\n if (isCapture) {\n eventName = eventName.slice(0, -7)\n }\n\n const compName = capitalize(toCamelCase(dom.tagName.toLowerCase()))\n\n if (eventName === 'click' && compName in internalComponents) {\n eventName = 'tap'\n }\n\n if (isFunction(value)) {\n if (oldValue) {\n dom.removeEventListener(eventName, oldValue as any, false)\n dom.addEventListener(eventName, value, { isCapture, sideEffect: false })\n } else {\n dom.addEventListener(eventName, value, isCapture)\n }\n } else {\n dom.removeEventListener(eventName, oldValue as any)\n }\n}\n\nfunction setStyle (style: Style, key: string, value: string | number) {\n if (key[0] === '-') {\n style.setProperty(key, value.toString())\n }\n\n style[key] =\n isNumber(value) && IS_NON_DIMENSIONAL.test(key) === false\n ? value + 'px'\n : value == null\n ? ''\n : value\n}\n\ntype StyleValue = Record<string, string | number>\ninterface DangerouslySetInnerHTML {\n __html?: string\n}\n\nfunction setProperty (dom: TaroElement, name: string, value: unknown, oldValue?: unknown) {\n name = name === 'className' ? 'class' : name\n\n if (\n name === 'key' ||\n name === 'children' ||\n name === 'ref'\n ) {\n // skip\n } else if (name === 'style') {\n const style = dom.style\n if (isString(value)) {\n style.cssText = value\n } else {\n if (isString(oldValue)) {\n style.cssText = ''\n oldValue = null\n }\n\n if (isObject<StyleValue>(oldValue)) {\n for (const i in oldValue) {\n if (!(value && i in (value as StyleValue))) {\n setStyle(style, i, '')\n }\n }\n }\n\n if (isObject<StyleValue>(value)) {\n for (const i in value) {\n if (!oldValue || value[i] !== (oldValue as StyleValue)[i]) {\n setStyle(style, i, value[i])\n }\n }\n }\n }\n } else if (isEventName(name)) {\n setEvent(dom, name, value, oldValue)\n } else if (name === 'dangerouslySetInnerHTML') {\n const newHtml = (value as DangerouslySetInnerHTML)?.__html ?? ''\n const oldHtml = (oldValue as DangerouslySetInnerHTML)?.__html ?? ''\n if (newHtml || oldHtml) {\n if (oldHtml !== newHtml) {\n dom.innerHTML = newHtml\n }\n }\n } else if (!isFunction(value)) {\n if (value == null) {\n dom.removeAttribute(name)\n } else {\n dom.setAttribute(name, value as string)\n }\n }\n}\n","/* eslint-disable @typescript-eslint/indent */\nimport { document, TaroElement, TaroText } from '@tarojs/runtime'\nimport { EMPTY_ARR, isBoolean, isUndefined, noop } from '@tarojs/shared'\nimport Reconciler, { HostConfig } from 'react-reconciler'\nimport * as scheduler from 'scheduler'\n\nimport { Props, updateProps } from './props'\n\nconst {\n unstable_now: now\n} = scheduler\n\nfunction returnFalse () {\n return false\n}\n\nconst hostConfig: HostConfig<\n string, // Type\n Props, // Props\n TaroElement, // Container\n TaroElement, // Instance\n TaroText, // TextInstance\n TaroElement, // SuspenseInstance\n TaroElement, // HydratableInstance\n TaroElement, // PublicInstance\n Record<string, any>, // HostContext\n string[], // UpdatePayload\n unknown, // ChildSet\n unknown, // TimeoutHandle\n unknown // NoTimeout\n> & {\n hideInstance (instance: TaroElement): void\n unhideInstance (instance: TaroElement, props): void\n getCurrentEventPriority(): number\n detachDeletedInstance(): void\n} = {\n createInstance (type) {\n return document.createElement(type)\n },\n\n createTextInstance (text) {\n return document.createTextNode(text)\n },\n\n getPublicInstance (inst: TaroElement) {\n return inst\n },\n\n getRootHostContext () {\n return {}\n },\n\n getChildHostContext () {\n return {}\n },\n\n getCurrentEventPriority () {\n // 因 @types/react-reconciler 未更新,ts会报错,这里直接返回16\n return 16 // import { DefaultEventPriority } from 'react-reconciler/constants'\n },\n\n detachDeletedInstance () {\n // noop\n },\n\n appendChild (parent, child) {\n parent.appendChild(child)\n },\n\n appendInitialChild (parent, child) {\n parent.appendChild(child)\n },\n\n appendChildToContainer (parent, child) {\n parent.appendChild(child)\n },\n\n removeChild (parent, child) {\n parent.removeChild(child)\n },\n\n removeChildFromContainer (parent, child) {\n parent.removeChild(child)\n },\n\n insertBefore (parent, child, refChild) {\n parent.insertBefore(child, refChild)\n },\n\n insertInContainerBefore (parent, child, refChild) {\n parent.insertBefore(child, refChild)\n },\n\n commitTextUpdate (textInst, _, newText) {\n textInst.nodeValue = newText\n },\n\n finalizeInitialChildren (dom, _, props) {\n updateProps(dom, {}, props)\n return false\n },\n\n prepareUpdate () {\n return EMPTY_ARR\n },\n\n commitUpdate (dom, _payload, _type, oldProps, newProps) {\n updateProps(dom, oldProps, newProps)\n },\n\n hideInstance (instance) {\n const style = instance.style\n style.setProperty('display', 'none')\n },\n\n unhideInstance (instance, props) {\n const styleProp = props.style\n let display = styleProp?.hasOwnProperty('display') ? styleProp.display : null\n display = display == null || isBoolean(display) || display === '' ? '' : ('' + display).trim()\n // eslint-disable-next-line dot-notation\n instance.style['display'] = display\n },\n\n clearContainer (element) {\n if (element.childNodes.length > 0) {\n element.textContent = ''\n }\n },\n\n queueMicrotask: !isUndefined(Promise)\n ? callback =>\n Promise.resolve(null)\n .then(callback)\n .catch(function (error) {\n setTimeout(() => {\n throw error\n })\n })\n : setTimeout,\n\n shouldSetTextContent: returnFalse,\n prepareForCommit (..._: any[]) { return null },\n resetAfterCommit: noop,\n commitMount: noop,\n now,\n cancelTimeout: clearTimeout,\n scheduleTimeout: setTimeout,\n preparePortalMount: noop,\n noTimeout: -1,\n supportsMutation: true,\n supportsPersistence: false,\n isPrimaryRenderer: true,\n supportsHydration: false\n}\n\nconst TaroReconciler = Reconciler(hostConfig)\n\nif (process.env.NODE_ENV !== 'production') {\n const foundDevTools = TaroReconciler.injectIntoDevTools({\n bundleType: 1,\n version: '18.0.0',\n rendererPackageName: 'taro-react'\n })\n if (!foundDevTools) {\n // eslint-disable-next-line no-console\n console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://reactjs.org/link/react-devtools', 'font-weight:bold')\n }\n}\n\nexport {\n TaroReconciler\n}\n","import { TaroElement } from '@tarojs/runtime'\nimport { ReactNode } from 'react'\nimport { OpaqueRoot } from 'react-reconciler'\n\nimport { TaroReconciler } from './reconciler'\n\nexport const ContainerMap: WeakMap<TaroElement, Root> = new WeakMap()\n\ntype Renderer = typeof TaroReconciler\n\nexport type Callback = () => void | null | undefined\n\nclass Root {\n private renderer: Renderer\n private internalRoot: OpaqueRoot\n\n public constructor (renderer: Renderer, domContainer: TaroElement, isConcurrentRoot = false) {\n this.renderer = renderer\n /** ConcurrentRoot & LegacyRoot: react-reconciler/src/ReactRootTags.js */\n this.internalRoot = renderer.createContainer(domContainer, isConcurrentRoot ? 1 : 0, false, null)\n }\n\n public render (children: ReactNode, cb: Callback) {\n const { renderer, internalRoot } = this\n renderer.updateContainer(children, internalRoot, null, cb)\n return renderer.getPublicRootInstance(internalRoot)\n }\n\n public unmount (cb: Callback) {\n this.renderer.updateContainer(null, this.internalRoot, null, cb)\n }\n}\n\nexport function render (element: ReactNode, domContainer: TaroElement, cb: Callback) {\n const oldRoot = ContainerMap.get(domContainer)\n if (oldRoot != null) {\n return oldRoot.render(element, cb)\n }\n\n const root = new Root(TaroReconciler, domContainer)\n ContainerMap.set(domContainer, root)\n return root.render(element, cb)\n}\n\nexport function createRoot (domContainer: TaroElement) {\n const oldRoot = ContainerMap.get(domContainer)\n if (oldRoot != null) {\n return oldRoot\n }\n const root = new Root(TaroReconciler, domContainer, true)\n ContainerMap.set(domContainer, root)\n return root\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { TaroElement } from '@tarojs/runtime'\nimport { ensure, isFunction } from '@tarojs/shared'\nimport { ReactNode } from 'react'\n\nimport { TaroReconciler } from './reconciler'\nimport { ContainerMap, createRoot, render } from './render'\n\nconst unstable_batchedUpdates = TaroReconciler.batchedUpdates\n\nfunction unmountComponentAtNode (dom: TaroElement) {\n ensure(dom && [1, 8, 9, 11].includes(dom.nodeType), 'unmountComponentAtNode(...): Target container is not a DOM element.')\n\n const root = ContainerMap.get(dom)\n\n if (!root) return false\n\n unstable_batchedUpdates(() => {\n root.unmount(() => {\n ContainerMap.delete(dom)\n })\n }, null)\n\n return true\n}\n\nfunction findDOMNode (comp?: TaroElement | ReactNode) {\n if (comp == null) {\n return null\n }\n\n const nodeType = (comp as TaroElement).nodeType\n if (nodeType === 1 || nodeType === 3) {\n return comp\n }\n\n return TaroReconciler.findHostInstance(comp as Record<string, any>)\n}\n\nconst portalType = isFunction(Symbol) && Symbol.for\n ? Symbol.for('react.portal')\n : 0xeaca\n\nfunction createPortal (\n children: ReactNode,\n containerInfo: TaroElement,\n key?: string\n) {\n return {\n $$typeof: portalType,\n key: key == null ? null : String(key),\n children,\n containerInfo,\n implementation: null\n }\n}\n\nexport {\n createPortal,\n createRoot,\n findDOMNode,\n render,\n unmountComponentAtNode,\n unstable_batchedUpdates\n}\n\nexport default {\n render,\n createRoot,\n unstable_batchedUpdates,\n unmountComponentAtNode,\n findDOMNode,\n createPortal\n}\n"],"names":["const","let","FormElement","capitalize","toCamelCase","internalComponents","isFunction","isNumber","isString","isObject","i","scheduler","document","EMPTY_ARR","isBoolean","isUndefined","noop","Reconciler","ensure"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,WAAW,CAAE,CAAS,EAAA;AAC7B,IAAA,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAA;AACrC,CAAC;AAEDA,IAAM,kBAAkB,GAAG,6DAA6D,CAAA;SAExE,WAAW,CAAE,GAAgB,EAAE,QAAe,EAAE,QAAe,EAAA;AAC7E,IAAAC,IAAI,CAAS,CAAA;IAEb,KAAK,CAAC,IAAI,QAAQ,EAAE;AAClB,QAAA,IAAI,EAAE,CAAC,IAAI,QAAQ,CAAC,EAAE;AACpB,YAAA,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AACvC,SAAA;AACF,KAAA;AACD,IAAAD,IAAM,aAAa,GAAG,GAAG,YAAYE,mBAAW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ACjD,MAAE,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;MAC1B,MAAM,CAAA;AAEV,SAAS,YAAY,CACnB,QAAmB,EACnB,aAA0B,EAC1B,GAAY,EAAA;IAEZ,OAAO;AACL,QAAA,QAAQ,EAAE,UAAU;AACpB,QAAA,GAAG,EAAE,GAAG,IAAI,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;kBACrC,QAAQ;uBACR,aAAa;AACb,QAAA,cAAc,EAAE,IAAI;KACrB,CAAA;AACH,CAAC;AAWD,YAAe;YACb,MAAM;gBACN,UAAU;6BACV,uBAAuB;4BACvB,sBAAsB;iBACtB,WAAW;kBACX,YAAY;CACb;;;;;;;;;;"}
package/dist/react.esm.js CHANGED
@@ -1,311 +1,310 @@
1
+ import { isString, isObject, isFunction, capitalize, toCamelCase, internalComponents, isNumber, EMPTY_ARR, isBoolean, isUndefined, noop, ensure } from '@tarojs/shared';
2
+ import { FormElement, document } from '@tarojs/runtime';
1
3
  import Reconciler from 'react-reconciler';
2
4
  import * as scheduler from 'scheduler';
3
- import { FormElement, document } from '@tarojs/runtime';
4
- import { isString, isObject, isFunction, capitalize, toCamelCase, internalComponents, isNumber, EMPTY_ARR, isBoolean, isUndefined, noop, ensure } from '@tarojs/shared';
5
5
 
6
- function isEventName(s) {
7
- return s[0] === 'o' && s[1] === 'n';
8
- }
9
- const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
10
- function updateProps(dom, oldProps, newProps) {
11
- let i;
12
- for (i in oldProps) {
13
- if (!(i in newProps)) {
14
- setProperty(dom, i, null, oldProps[i]);
15
- }
16
- }
17
- const isFormElement = dom instanceof FormElement;
18
- for (i in newProps) {
19
- if (oldProps[i] !== newProps[i] || (isFormElement && i === 'value')) {
20
- setProperty(dom, i, newProps[i], oldProps[i]);
21
- }
22
- }
23
- }
24
- // function eventProxy (e: CommonEvent) {
25
- // const el = document.getElementById(e.currentTarget.id)
26
- // const handlers = el!.__handlers[e.type]
27
- // handlers[0](e)
28
- // }
29
- function setEvent(dom, name, value, oldValue) {
30
- const isCapture = name.endsWith('Capture');
31
- let eventName = name.toLowerCase().slice(2);
32
- if (isCapture) {
33
- eventName = eventName.slice(0, -7);
34
- }
35
- const compName = capitalize(toCamelCase(dom.tagName.toLowerCase()));
36
- if (eventName === 'click' && compName in internalComponents) {
37
- eventName = 'tap';
38
- }
39
- if (isFunction(value)) {
40
- if (oldValue) {
41
- dom.removeEventListener(eventName, oldValue, false);
42
- dom.addEventListener(eventName, value, { isCapture, sideEffect: false });
43
- }
44
- else {
45
- dom.addEventListener(eventName, value, isCapture);
46
- }
47
- }
48
- else {
49
- dom.removeEventListener(eventName, oldValue);
50
- }
51
- }
52
- function setStyle(style, key, value) {
53
- if (key[0] === '-') {
54
- style.setProperty(key, value.toString());
55
- }
56
- style[key] =
57
- isNumber(value) && IS_NON_DIMENSIONAL.test(key) === false
58
- ? value + 'px'
59
- : value == null
60
- ? ''
61
- : value;
62
- }
63
- function setProperty(dom, name, value, oldValue) {
64
- var _a, _b;
65
- name = name === 'className' ? 'class' : name;
66
- if (name === 'key' ||
67
- name === 'children' ||
68
- name === 'ref') ;
69
- else if (name === 'style') {
70
- const style = dom.style;
71
- if (isString(value)) {
72
- style.cssText = value;
73
- }
74
- else {
75
- if (isString(oldValue)) {
76
- style.cssText = '';
77
- oldValue = null;
78
- }
79
- if (isObject(oldValue)) {
80
- for (const i in oldValue) {
81
- if (!(value && i in value)) {
82
- setStyle(style, i, '');
83
- }
84
- }
85
- }
86
- if (isObject(value)) {
87
- for (const i in value) {
88
- if (!oldValue || value[i] !== oldValue[i]) {
89
- setStyle(style, i, value[i]);
90
- }
91
- }
92
- }
93
- }
94
- }
95
- else if (isEventName(name)) {
96
- setEvent(dom, name, value, oldValue);
97
- }
98
- else if (name === 'dangerouslySetInnerHTML') {
99
- const newHtml = (_a = value === null || value === void 0 ? void 0 : value.__html) !== null && _a !== void 0 ? _a : '';
100
- const oldHtml = (_b = oldValue === null || oldValue === void 0 ? void 0 : oldValue.__html) !== null && _b !== void 0 ? _b : '';
101
- if (newHtml || oldHtml) {
102
- if (oldHtml !== newHtml) {
103
- dom.innerHTML = newHtml;
104
- }
105
- }
106
- }
107
- else if (!isFunction(value)) {
108
- if (value == null) {
109
- dom.removeAttribute(name);
110
- }
111
- else {
112
- dom.setAttribute(name, value);
113
- }
114
- }
6
+ function isEventName(s) {
7
+ return s[0] === 'o' && s[1] === 'n';
8
+ }
9
+ const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
10
+ function updateProps(dom, oldProps, newProps) {
11
+ let i;
12
+ for (i in oldProps) {
13
+ if (!(i in newProps)) {
14
+ setProperty(dom, i, null, oldProps[i]);
15
+ }
16
+ }
17
+ const isFormElement = dom instanceof FormElement;
18
+ for (i in newProps) {
19
+ if (oldProps[i] !== newProps[i] || (isFormElement && i === 'value')) {
20
+ setProperty(dom, i, newProps[i], oldProps[i]);
21
+ }
22
+ }
23
+ }
24
+ // function eventProxy (e: CommonEvent) {
25
+ // const el = document.getElementById(e.currentTarget.id)
26
+ // const handlers = el!.__handlers[e.type]
27
+ // handlers[0](e)
28
+ // }
29
+ function setEvent(dom, name, value, oldValue) {
30
+ const isCapture = name.endsWith('Capture');
31
+ let eventName = name.toLowerCase().slice(2);
32
+ if (isCapture) {
33
+ eventName = eventName.slice(0, -7);
34
+ }
35
+ const compName = capitalize(toCamelCase(dom.tagName.toLowerCase()));
36
+ if (eventName === 'click' && compName in internalComponents) {
37
+ eventName = 'tap';
38
+ }
39
+ if (isFunction(value)) {
40
+ if (oldValue) {
41
+ dom.removeEventListener(eventName, oldValue, false);
42
+ dom.addEventListener(eventName, value, { isCapture, sideEffect: false });
43
+ }
44
+ else {
45
+ dom.addEventListener(eventName, value, isCapture);
46
+ }
47
+ }
48
+ else {
49
+ dom.removeEventListener(eventName, oldValue);
50
+ }
51
+ }
52
+ function setStyle(style, key, value) {
53
+ if (key[0] === '-') {
54
+ style.setProperty(key, value.toString());
55
+ }
56
+ style[key] =
57
+ isNumber(value) && IS_NON_DIMENSIONAL.test(key) === false
58
+ ? value + 'px'
59
+ : value == null
60
+ ? ''
61
+ : value;
62
+ }
63
+ function setProperty(dom, name, value, oldValue) {
64
+ var _a, _b;
65
+ name = name === 'className' ? 'class' : name;
66
+ if (name === 'key' ||
67
+ name === 'children' ||
68
+ name === 'ref') ;
69
+ else if (name === 'style') {
70
+ const style = dom.style;
71
+ if (isString(value)) {
72
+ style.cssText = value;
73
+ }
74
+ else {
75
+ if (isString(oldValue)) {
76
+ style.cssText = '';
77
+ oldValue = null;
78
+ }
79
+ if (isObject(oldValue)) {
80
+ for (const i in oldValue) {
81
+ if (!(value && i in value)) {
82
+ setStyle(style, i, '');
83
+ }
84
+ }
85
+ }
86
+ if (isObject(value)) {
87
+ for (const i in value) {
88
+ if (!oldValue || value[i] !== oldValue[i]) {
89
+ setStyle(style, i, value[i]);
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ else if (isEventName(name)) {
96
+ setEvent(dom, name, value, oldValue);
97
+ }
98
+ else if (name === 'dangerouslySetInnerHTML') {
99
+ const newHtml = (_a = value === null || value === void 0 ? void 0 : value.__html) !== null && _a !== void 0 ? _a : '';
100
+ const oldHtml = (_b = oldValue === null || oldValue === void 0 ? void 0 : oldValue.__html) !== null && _b !== void 0 ? _b : '';
101
+ if (newHtml || oldHtml) {
102
+ if (oldHtml !== newHtml) {
103
+ dom.innerHTML = newHtml;
104
+ }
105
+ }
106
+ }
107
+ else if (!isFunction(value)) {
108
+ if (value == null) {
109
+ dom.removeAttribute(name);
110
+ }
111
+ else {
112
+ dom.setAttribute(name, value);
113
+ }
114
+ }
115
115
  }
116
116
 
117
- /* eslint-disable @typescript-eslint/indent */
118
- const { unstable_now: now } = scheduler;
119
- function returnFalse() {
120
- return false;
121
- }
122
- const hostConfig = {
123
- createInstance(type) {
124
- return document.createElement(type);
125
- },
126
- createTextInstance(text) {
127
- return document.createTextNode(text);
128
- },
129
- getPublicInstance(inst) {
130
- return inst;
131
- },
132
- getRootHostContext() {
133
- return {};
134
- },
135
- getChildHostContext() {
136
- return {};
137
- },
138
- getCurrentEventPriority() {
139
- // 因 @types/react-reconciler 未更新,ts会报错,这里直接返回16
140
- return 16; // import { DefaultEventPriority } from 'react-reconciler/constants'
141
- },
142
- detachDeletedInstance() {
143
- // noop
144
- },
145
- appendChild(parent, child) {
146
- parent.appendChild(child);
147
- },
148
- appendInitialChild(parent, child) {
149
- parent.appendChild(child);
150
- },
151
- appendChildToContainer(parent, child) {
152
- parent.appendChild(child);
153
- },
154
- removeChild(parent, child) {
155
- parent.removeChild(child);
156
- },
157
- removeChildFromContainer(parent, child) {
158
- parent.removeChild(child);
159
- },
160
- insertBefore(parent, child, refChild) {
161
- parent.insertBefore(child, refChild);
162
- },
163
- insertInContainerBefore(parent, child, refChild) {
164
- parent.insertBefore(child, refChild);
165
- },
166
- commitTextUpdate(textInst, _, newText) {
167
- textInst.nodeValue = newText;
168
- },
169
- finalizeInitialChildren(dom, _, props) {
170
- updateProps(dom, {}, props);
171
- return false;
172
- },
173
- prepareUpdate() {
174
- return EMPTY_ARR;
175
- },
176
- commitUpdate(dom, _payload, _type, oldProps, newProps) {
177
- updateProps(dom, oldProps, newProps);
178
- },
179
- hideInstance(instance) {
180
- const style = instance.style;
181
- style.setProperty('display', 'none');
182
- },
183
- unhideInstance(instance, props) {
184
- const styleProp = props.style;
185
- let display = (styleProp === null || styleProp === void 0 ? void 0 : styleProp.hasOwnProperty('display')) ? styleProp.display : null;
186
- display = display == null || isBoolean(display) || display === '' ? '' : ('' + display).trim();
187
- // eslint-disable-next-line dot-notation
188
- instance.style['display'] = display;
189
- },
190
- clearContainer(element) {
191
- if (element.childNodes.length > 0) {
192
- element.textContent = '';
193
- }
194
- },
195
- queueMicrotask: !isUndefined(Promise)
196
- ? callback => Promise.resolve(null)
197
- .then(callback)
198
- .catch(function (error) {
199
- setTimeout(() => {
200
- throw error;
201
- });
202
- })
203
- : setTimeout,
204
- shouldSetTextContent: returnFalse,
205
- prepareForCommit(..._) { return null; },
206
- resetAfterCommit: noop,
207
- commitMount: noop,
208
- now,
209
- cancelTimeout: clearTimeout,
210
- scheduleTimeout: setTimeout,
211
- preparePortalMount: noop,
212
- noTimeout: -1,
213
- supportsMutation: true,
214
- supportsPersistence: false,
215
- isPrimaryRenderer: true,
216
- supportsHydration: false
217
- };
218
- const TaroReconciler = Reconciler(hostConfig);
219
- if (process.env.NODE_ENV !== 'production') {
220
- const foundDevTools = TaroReconciler.injectIntoDevTools({
221
- bundleType: 1,
222
- version: '18.0.0',
223
- rendererPackageName: 'taro-react'
224
- });
225
- if (!foundDevTools) {
226
- // eslint-disable-next-line no-console
227
- console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://reactjs.org/link/react-devtools', 'font-weight:bold');
228
- }
117
+ /* eslint-disable @typescript-eslint/indent */
118
+ const { unstable_now: now } = scheduler;
119
+ function returnFalse() {
120
+ return false;
121
+ }
122
+ const hostConfig = {
123
+ createInstance(type) {
124
+ return document.createElement(type);
125
+ },
126
+ createTextInstance(text) {
127
+ return document.createTextNode(text);
128
+ },
129
+ getPublicInstance(inst) {
130
+ return inst;
131
+ },
132
+ getRootHostContext() {
133
+ return {};
134
+ },
135
+ getChildHostContext() {
136
+ return {};
137
+ },
138
+ getCurrentEventPriority() {
139
+ // 因 @types/react-reconciler 未更新,ts会报错,这里直接返回16
140
+ return 16; // import { DefaultEventPriority } from 'react-reconciler/constants'
141
+ },
142
+ detachDeletedInstance() {
143
+ // noop
144
+ },
145
+ appendChild(parent, child) {
146
+ parent.appendChild(child);
147
+ },
148
+ appendInitialChild(parent, child) {
149
+ parent.appendChild(child);
150
+ },
151
+ appendChildToContainer(parent, child) {
152
+ parent.appendChild(child);
153
+ },
154
+ removeChild(parent, child) {
155
+ parent.removeChild(child);
156
+ },
157
+ removeChildFromContainer(parent, child) {
158
+ parent.removeChild(child);
159
+ },
160
+ insertBefore(parent, child, refChild) {
161
+ parent.insertBefore(child, refChild);
162
+ },
163
+ insertInContainerBefore(parent, child, refChild) {
164
+ parent.insertBefore(child, refChild);
165
+ },
166
+ commitTextUpdate(textInst, _, newText) {
167
+ textInst.nodeValue = newText;
168
+ },
169
+ finalizeInitialChildren(dom, _, props) {
170
+ updateProps(dom, {}, props);
171
+ return false;
172
+ },
173
+ prepareUpdate() {
174
+ return EMPTY_ARR;
175
+ },
176
+ commitUpdate(dom, _payload, _type, oldProps, newProps) {
177
+ updateProps(dom, oldProps, newProps);
178
+ },
179
+ hideInstance(instance) {
180
+ const style = instance.style;
181
+ style.setProperty('display', 'none');
182
+ },
183
+ unhideInstance(instance, props) {
184
+ const styleProp = props.style;
185
+ let display = (styleProp === null || styleProp === void 0 ? void 0 : styleProp.hasOwnProperty('display')) ? styleProp.display : null;
186
+ display = display == null || isBoolean(display) || display === '' ? '' : ('' + display).trim();
187
+ // eslint-disable-next-line dot-notation
188
+ instance.style['display'] = display;
189
+ },
190
+ clearContainer(element) {
191
+ if (element.childNodes.length > 0) {
192
+ element.textContent = '';
193
+ }
194
+ },
195
+ queueMicrotask: !isUndefined(Promise)
196
+ ? callback => Promise.resolve(null)
197
+ .then(callback)
198
+ .catch(function (error) {
199
+ setTimeout(() => {
200
+ throw error;
201
+ });
202
+ })
203
+ : setTimeout,
204
+ shouldSetTextContent: returnFalse,
205
+ prepareForCommit(..._) { return null; },
206
+ resetAfterCommit: noop,
207
+ commitMount: noop,
208
+ now,
209
+ cancelTimeout: clearTimeout,
210
+ scheduleTimeout: setTimeout,
211
+ preparePortalMount: noop,
212
+ noTimeout: -1,
213
+ supportsMutation: true,
214
+ supportsPersistence: false,
215
+ isPrimaryRenderer: true,
216
+ supportsHydration: false
217
+ };
218
+ const TaroReconciler = Reconciler(hostConfig);
219
+ if (process.env.NODE_ENV !== 'production') {
220
+ const foundDevTools = TaroReconciler.injectIntoDevTools({
221
+ bundleType: 1,
222
+ version: '18.0.0',
223
+ rendererPackageName: 'taro-react'
224
+ });
225
+ if (!foundDevTools) {
226
+ // eslint-disable-next-line no-console
227
+ console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://reactjs.org/link/react-devtools', 'font-weight:bold');
228
+ }
229
229
  }
230
230
 
231
- const ContainerMap = new WeakMap();
232
- class Root {
233
- constructor(renderer, domContainer, isConcurrentRoot = false) {
234
- this.renderer = renderer;
235
- /** ConcurrentRoot & LegacyRoot: react-reconciler/src/ReactRootTags.js */
236
- this.internalRoot = renderer.createContainer(domContainer, isConcurrentRoot ? 1 : 0, false, null);
237
- }
238
- render(children, cb) {
239
- const { renderer, internalRoot } = this;
240
- renderer.updateContainer(children, internalRoot, null, cb);
241
- return renderer.getPublicRootInstance(internalRoot);
242
- }
243
- unmount(cb) {
244
- this.renderer.updateContainer(null, this.internalRoot, null, cb);
245
- }
246
- }
247
- function render(element, domContainer, cb) {
248
- const oldRoot = ContainerMap.get(domContainer);
249
- if (oldRoot != null) {
250
- return oldRoot.render(element, cb);
251
- }
252
- const root = new Root(TaroReconciler, domContainer);
253
- ContainerMap.set(domContainer, root);
254
- return root.render(element, cb);
255
- }
256
- function createRoot(domContainer) {
257
- const oldRoot = ContainerMap.get(domContainer);
258
- if (oldRoot != null) {
259
- return oldRoot;
260
- }
261
- const root = new Root(TaroReconciler, domContainer, true);
262
- ContainerMap.set(domContainer, root);
263
- return root;
231
+ const ContainerMap = new WeakMap();
232
+ class Root {
233
+ constructor(renderer, domContainer, isConcurrentRoot = false) {
234
+ this.renderer = renderer;
235
+ /** ConcurrentRoot & LegacyRoot: react-reconciler/src/ReactRootTags.js */
236
+ this.internalRoot = renderer.createContainer(domContainer, isConcurrentRoot ? 1 : 0, false, null);
237
+ }
238
+ render(children, cb) {
239
+ const { renderer, internalRoot } = this;
240
+ renderer.updateContainer(children, internalRoot, null, cb);
241
+ return renderer.getPublicRootInstance(internalRoot);
242
+ }
243
+ unmount(cb) {
244
+ this.renderer.updateContainer(null, this.internalRoot, null, cb);
245
+ }
246
+ }
247
+ function render(element, domContainer, cb) {
248
+ const oldRoot = ContainerMap.get(domContainer);
249
+ if (oldRoot != null) {
250
+ return oldRoot.render(element, cb);
251
+ }
252
+ const root = new Root(TaroReconciler, domContainer);
253
+ ContainerMap.set(domContainer, root);
254
+ return root.render(element, cb);
255
+ }
256
+ function createRoot(domContainer) {
257
+ const oldRoot = ContainerMap.get(domContainer);
258
+ if (oldRoot != null) {
259
+ return oldRoot;
260
+ }
261
+ const root = new Root(TaroReconciler, domContainer, true);
262
+ ContainerMap.set(domContainer, root);
263
+ return root;
264
264
  }
265
265
 
266
- /* eslint-disable @typescript-eslint/no-unused-vars */
267
- const unstable_batchedUpdates = TaroReconciler.batchedUpdates;
268
- function unmountComponentAtNode(dom) {
269
- ensure(dom && [1, 8, 9, 11].includes(dom.nodeType), 'unmountComponentAtNode(...): Target container is not a DOM element.');
270
- const root = ContainerMap.get(dom);
271
- if (!root)
272
- return false;
273
- unstable_batchedUpdates(() => {
274
- root.unmount(() => {
275
- ContainerMap.delete(dom);
276
- });
277
- }, null);
278
- return true;
279
- }
280
- function findDOMNode(comp) {
281
- if (comp == null) {
282
- return null;
283
- }
284
- const nodeType = comp.nodeType;
285
- if (nodeType === 1 || nodeType === 3) {
286
- return comp;
287
- }
288
- return TaroReconciler.findHostInstance(comp);
289
- }
290
- const portalType = isFunction(Symbol) && Symbol.for
291
- ? Symbol.for('react.portal')
292
- : 0xeaca;
293
- function createPortal(children, containerInfo, key) {
294
- return {
295
- $$typeof: portalType,
296
- key: key == null ? null : String(key),
297
- children,
298
- containerInfo,
299
- implementation: null
300
- };
301
- }
302
- var index = {
303
- render,
304
- createRoot,
305
- unstable_batchedUpdates,
306
- unmountComponentAtNode,
307
- findDOMNode,
308
- createPortal
266
+ const unstable_batchedUpdates = TaroReconciler.batchedUpdates;
267
+ function unmountComponentAtNode(dom) {
268
+ ensure(dom && [1, 8, 9, 11].includes(dom.nodeType), 'unmountComponentAtNode(...): Target container is not a DOM element.');
269
+ const root = ContainerMap.get(dom);
270
+ if (!root)
271
+ return false;
272
+ unstable_batchedUpdates(() => {
273
+ root.unmount(() => {
274
+ ContainerMap.delete(dom);
275
+ });
276
+ }, null);
277
+ return true;
278
+ }
279
+ function findDOMNode(comp) {
280
+ if (comp == null) {
281
+ return null;
282
+ }
283
+ const nodeType = comp.nodeType;
284
+ if (nodeType === 1 || nodeType === 3) {
285
+ return comp;
286
+ }
287
+ return TaroReconciler.findHostInstance(comp);
288
+ }
289
+ const portalType = isFunction(Symbol) && Symbol.for
290
+ ? Symbol.for('react.portal')
291
+ : 0xeaca;
292
+ function createPortal(children, containerInfo, key) {
293
+ return {
294
+ $$typeof: portalType,
295
+ key: key == null ? null : String(key),
296
+ children,
297
+ containerInfo,
298
+ implementation: null
299
+ };
300
+ }
301
+ var index = {
302
+ render,
303
+ createRoot,
304
+ unstable_batchedUpdates,
305
+ unmountComponentAtNode,
306
+ findDOMNode,
307
+ createPortal
309
308
  };
310
309
 
311
310
  export { createPortal, createRoot, index as default, findDOMNode, render, unmountComponentAtNode, unstable_batchedUpdates };