@weapp-vite/react 0.2.11 → 0.2.12

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 (21) hide show
  1. package/dist/dev/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/defineProperty.mjs +1 -1
  2. package/dist/dev/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPrimitive.mjs +1 -1
  3. package/dist/dev/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPropertyKey.mjs +1 -1
  4. package/dist/dev/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/typeof.mjs +1 -1
  5. package/dist/dev/hostTree/index.mjs +1 -1
  6. package/dist/dev/hostTree/nodes.mjs +1 -1
  7. package/dist/dev/hostTree/staticBindings.mjs +1 -1
  8. package/dist/dev/package.mjs +7 -0
  9. package/dist/dev/package.mjs.map +1 -0
  10. package/dist/dev/renderer.mjs +13 -2
  11. package/dist/dev/renderer.mjs.map +1 -1
  12. package/dist/hostTree/index.mjs +1 -1
  13. package/dist/hostTree/nodes.mjs +1 -1
  14. package/dist/hostTree/staticBindings.mjs +1 -1
  15. package/dist/package.mjs +1 -0
  16. package/dist/renderer.mjs +1 -1
  17. package/package.json +5 -4
  18. /package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/defineProperty.mjs +0 -0
  19. /package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPrimitive.mjs +0 -0
  20. /package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPropertyKey.mjs +0 -0
  21. /package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/typeof.mjs +0 -0
@@ -1,6 +1,6 @@
1
1
  import toPropertyKey from "./toPropertyKey.mjs";
2
2
 
3
- //#region \0@oxc-project+runtime@0.151.0/helpers/esm/defineProperty.js
3
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
4
4
  function _defineProperty(e, r, t) {
5
5
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
6
6
  value: t,
@@ -1,6 +1,6 @@
1
1
  import _typeof from "./typeof.mjs";
2
2
 
3
- //#region \0@oxc-project+runtime@0.151.0/helpers/esm/toPrimitive.js
3
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
4
4
  function toPrimitive(t, r) {
5
5
  if ("object" != _typeof(t) || !t) return t;
6
6
  var e = t[Symbol.toPrimitive];
@@ -1,7 +1,7 @@
1
1
  import _typeof from "./typeof.mjs";
2
2
  import toPrimitive from "./toPrimitive.mjs";
3
3
 
4
- //#region \0@oxc-project+runtime@0.151.0/helpers/esm/toPropertyKey.js
4
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
5
5
  function toPropertyKey(t) {
6
6
  var i = toPrimitive(t, "string");
7
7
  return "symbol" == _typeof(i) ? i : i + "";
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.151.0/helpers/esm/typeof.js
1
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
2
2
  function _typeof(o) {
3
3
  "@babel/helpers - typeof";
4
4
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -1,5 +1,5 @@
1
1
  import { hasSerializedPropChanges } from "./serialization.mjs";
2
- import _defineProperty from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/defineProperty.mjs";
2
+ import _defineProperty from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.mjs";
3
3
  import { HostElement, HostText, attachHostNode } from "./nodes.mjs";
4
4
  import { StaticBindingState, hasStaticBindingChanges, readStaticSlot } from "./staticBindings.mjs";
5
5
  import { WEAPP_REACT_ROOT_DATA_KEY, WEAPP_REACT_SLOTS_DATA_KEY } from "@weapp-core/constants";
@@ -1,5 +1,5 @@
1
1
  import { serializeProps, serializeStyle } from "./serialization.mjs";
2
- import _defineProperty from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/defineProperty.mjs";
2
+ import _defineProperty from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.mjs";
3
3
 
4
4
  //#region src/hostTree/nodes.ts
5
5
  function attach(parent, child, index) {
@@ -1,5 +1,5 @@
1
1
  import { serializeStyle } from "./serialization.mjs";
2
- import _defineProperty from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/defineProperty.mjs";
2
+ import _defineProperty from "../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.mjs";
3
3
 
4
4
  //#region src/hostTree/staticBindings.ts
5
5
  function isTextNode(node) {
@@ -0,0 +1,7 @@
1
+ //#region package.json
2
+ var name = "@weapp-vite/react";
3
+ var version = "0.2.12";
4
+
5
+ //#endregion
6
+ export { name, version };
7
+ //# sourceMappingURL=package.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.mjs","names":[],"sources":["../../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,3 +1,4 @@
1
+ import { name, version } from "./package.mjs";
1
2
  import { HostElement, HostText } from "./hostTree/nodes.mjs";
2
3
  import { HostRoot } from "./hostTree/index.mjs";
3
4
  import { dispatchHostEvent } from "./event.mjs";
@@ -28,6 +29,10 @@ const hostConfig = {
28
29
  parent.append(child, false);
29
30
  },
30
31
  beforeActiveInstanceBlur() {},
32
+ bindToConsole(methodName, args) {
33
+ const method = console[methodName];
34
+ return typeof method === "function" ? method.bind(console, ...args) : () => {};
35
+ },
31
36
  cancelTimeout: clearTimeout,
32
37
  clearContainer(container) {
33
38
  container.clear();
@@ -47,6 +52,7 @@ const hostConfig = {
47
52
  return new HostText(root, root.nextSid(), text);
48
53
  },
49
54
  detachDeletedInstance() {},
55
+ extraDevToolsConfig: null,
50
56
  finalizeInitialChildren() {
51
57
  return false;
52
58
  },
@@ -124,6 +130,8 @@ const hostConfig = {
124
130
  removeChildFromContainer(parent, child) {
125
131
  parent.remove(child);
126
132
  },
133
+ rendererPackageName: name,
134
+ rendererVersion: version,
127
135
  resetAfterCommit(container) {
128
136
  container.flush();
129
137
  },
@@ -146,7 +154,10 @@ const hostConfig = {
146
154
  supportsMutation: true,
147
155
  supportsPersistence: false,
148
156
  suspendInstance() {},
149
- startSuspendingCommit() {},
157
+ suspendOnActiveViewTransition() {},
158
+ startSuspendingCommit() {
159
+ return null;
160
+ },
150
161
  trackSchedulerEvent() {},
151
162
  unhideInstance(instance, props) {
152
163
  instance.updateProps(props);
@@ -165,7 +176,7 @@ function createContainer(root) {
165
176
  throw error;
166
177
  }, () => {}, (error) => {
167
178
  throw error;
168
- }, () => {});
179
+ }, () => {}, null);
169
180
  }
170
181
  function createReactMiniProgramRoot(adapter, options = {}) {
171
182
  const root = new HostRoot(adapter, options.renderMode);
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.mjs","names":[],"sources":["../../src/renderer.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { HostRenderMode } from './hostTree'\nimport type { HostProps, MiniProgramEventLike, MiniProgramPageAdapter } from './types'\nimport { createContext } from 'react'\nimport Reconciler from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants'\nimport { dispatchHostEvent } from './event'\nimport { HostElement, HostRoot, HostText } from './hostTree'\n\nfunction propsChanged(previous: HostProps, next: HostProps) {\n const previousKeys = Object.keys(previous).filter(key => key !== 'children')\n const nextKeys = Object.keys(next).filter(key => key !== 'children')\n if (previousKeys.length !== nextKeys.length) {\n return true\n }\n return nextKeys.some(key => previous[key] !== next[key])\n}\n\ntype HostContext = Record<string, never>\ntype HostNode = HostElement | HostText\ntype MiniProgramHostConfig = Reconciler.HostConfig<\n string,\n HostProps,\n HostRoot,\n HostElement,\n HostText,\n never,\n never,\n never,\n HostNode,\n HostContext,\n never,\n ReturnType<typeof setTimeout>,\n -1,\n null\n>\n\ninterface React19HostConfigExtensions {\n getSuspendedCommitReason: () => null\n maySuspendCommitInSyncRender: () => false\n maySuspendCommitOnUpdate: () => false\n}\n\nlet currentUpdatePriority = NoEventPriority\nconst hostContext: HostContext = {}\n\nconst hostConfig: MiniProgramHostConfig & React19HostConfigExtensions = {\n HostTransitionContext: createContext(null) as never,\n NotPendingTransition: null,\n afterActiveInstanceBlur() {},\n appendChild(parent: HostElement, child: HostElement | HostText) {\n parent.append(child)\n },\n appendChildToContainer(parent: HostRoot, child: HostElement | HostText) {\n parent.append(child)\n },\n appendInitialChild(parent: HostElement, child: HostElement | HostText) {\n parent.append(child, false)\n },\n beforeActiveInstanceBlur() {},\n cancelTimeout: clearTimeout,\n clearContainer(container: HostRoot) {\n container.clear()\n },\n commitMount() {},\n commitTextUpdate(text: HostText, _previous: string, next: string) {\n text.setValue(next)\n },\n commitUpdate(\n element: HostElement,\n _type: string,\n previous: HostProps,\n next: HostProps,\n ) {\n if (!propsChanged(previous, next)) {\n return\n }\n element.updateProps(next, element.root.shouldNotifyPropUpdate(previous, next))\n },\n createInstance(type: string, props: HostProps, root: HostRoot) {\n return new HostElement(root, root.createElementSid(props), type, props)\n },\n createTextInstance(text: string, root: HostRoot) {\n return new HostText(root, root.nextSid(), text)\n },\n detachDeletedInstance() {},\n finalizeInitialChildren() {\n return false\n },\n getChildHostContext(parentContext: HostContext) {\n return parentContext\n },\n getCurrentUpdatePriority() {\n return currentUpdatePriority\n },\n getInstanceFromNode() {\n return null\n },\n getInstanceFromScope() {\n return null\n },\n getPublicInstance(instance: HostElement | HostText) {\n return instance\n },\n getRootHostContext(): HostContext {\n return hostContext\n },\n getSuspendedCommitReason() {\n return null\n },\n hideInstance(instance: HostElement) {\n instance.updateProps({\n ...instance.props,\n hidden: true,\n })\n },\n hideTextInstance(instance: HostText) {\n instance.setValue('')\n },\n insertBefore(parent: HostElement, child: HostElement | HostText, before: HostElement | HostText) {\n parent.insertBefore(child, before)\n },\n insertInContainerBefore(parent: HostRoot, child: HostElement | HostText, before: HostElement | HostText) {\n parent.insertBefore(child, before)\n },\n isPrimaryRenderer: true,\n maySuspendCommit() {\n return false\n },\n maySuspendCommitInSyncRender() {\n return false\n },\n maySuspendCommitOnUpdate() {\n return false\n },\n noTimeout: -1,\n preloadInstance() {\n return true\n },\n prepareForCommit() {\n return null\n },\n preparePortalMount() {},\n prepareScopeUpdate() {},\n requestPostPaintCallback(callback: (time: number) => void) {\n setTimeout(() => callback(Date.now()), 0)\n },\n resetFormInstance() {},\n resolveEventTimeStamp() {\n return -1.1\n },\n resolveEventType() {\n return null\n },\n resolveUpdatePriority() {\n return currentUpdatePriority === NoEventPriority ? DefaultEventPriority : currentUpdatePriority\n },\n removeChild(parent: HostElement, child: HostElement | HostText) {\n parent.remove(child)\n },\n removeChildFromContainer(parent: HostRoot, child: HostElement | HostText) {\n parent.remove(child)\n },\n resetAfterCommit(container: HostRoot) {\n container.flush()\n },\n resetTextContent() {},\n scheduleMicrotask(callback: () => void) {\n Promise.resolve().then(callback)\n },\n scheduleTimeout: setTimeout,\n setCurrentUpdatePriority(priority: number) {\n currentUpdatePriority = priority\n },\n shouldAttemptEagerTransition() {\n return false\n },\n shouldSetTextContent() {\n return false\n },\n supportsHydration: false,\n supportsMicrotasks: true,\n supportsMutation: true,\n supportsPersistence: false,\n suspendInstance() {},\n startSuspendingCommit() {},\n trackSchedulerEvent() {},\n unhideInstance(instance: HostElement, props: HostProps) {\n instance.updateProps(props)\n },\n unhideTextInstance(instance: HostText, text: string) {\n instance.setValue(text)\n },\n waitForCommitToBeReady() {\n return null\n },\n warnsIfNotActing: true,\n}\n\nconst renderer = Reconciler(hostConfig)\n\nexport interface ReactMiniProgramRoot {\n dispatchEvent: (event: MiniProgramEventLike) => void\n flush: () => void\n getSnapshot: () => ReturnType<HostRoot['snapshot']>\n render: (element: ReactNode) => void\n unmount: () => void\n}\n\nexport interface ReactMiniProgramRootOptions {\n renderMode?: HostRenderMode\n}\n\nfunction createContainer(root: HostRoot) {\n return renderer.createContainer(\n root,\n 0,\n null,\n false,\n false,\n '',\n (error) => {\n throw error\n },\n () => {},\n (error) => {\n throw error\n },\n () => {},\n )\n}\n\nexport function createReactMiniProgramRoot(\n adapter: MiniProgramPageAdapter,\n options: ReactMiniProgramRootOptions = {},\n): ReactMiniProgramRoot {\n const root = new HostRoot(adapter, options.renderMode)\n const container = createContainer(root)\n\n return {\n dispatchEvent(event) {\n renderer.flushSyncFromReconciler(() => dispatchHostEvent(root, event))\n root.assertStaticTemplateValid()\n root.flush()\n },\n flush() {\n renderer.flushSyncFromReconciler()\n root.flush()\n },\n getSnapshot() {\n return root.snapshot()\n },\n render(element) {\n renderer.updateContainerSync(element, container, null)\n renderer.flushSyncWork()\n root.assertStaticTemplateValid()\n root.flush()\n },\n unmount() {\n root.beginUnmount()\n renderer.updateContainerSync(null, container, null)\n renderer.flushSyncWork()\n root.flush()\n },\n }\n}\n"],"mappings":";;;;;;;;AASA,SAAS,aAAa,UAAqB,MAAiB;CAC1D,MAAM,eAAe,OAAO,KAAK,QAAQ,CAAC,CAAC,QAAO,QAAO,QAAQ,UAAU;CAC3E,MAAM,WAAW,OAAO,KAAK,IAAI,CAAC,CAAC,QAAO,QAAO,QAAQ,UAAU;CACnE,IAAI,aAAa,WAAW,SAAS,QACnC,OAAO;CAET,OAAO,SAAS,MAAK,QAAO,SAAS,SAAS,KAAK,IAAI;AACzD;AA2BA,IAAI,wBAAwB;AAC5B,MAAM,cAA2B,CAAC;AAElC,MAAM,aAAkE;CACtE,uBAAuB,cAAc,IAAI;CACzC,sBAAsB;CACtB,0BAA0B,CAAC;CAC3B,YAAY,QAAqB,OAA+B;EAC9D,OAAO,OAAO,KAAK;CACrB;CACA,uBAAuB,QAAkB,OAA+B;EACtE,OAAO,OAAO,KAAK;CACrB;CACA,mBAAmB,QAAqB,OAA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,YAAY,gBAAgB,IAAI;CAEtC,OAAO;EACL,cAAc,OAAO;GACnB,SAAS,8BAA8B,kBAAkB,MAAM,KAAK,CAAC;GACrE,KAAK,0BAA0B;GAC/B,KAAK,MAAM;EACb;EACA,QAAQ;GACN,SAAS,wBAAwB;GACjC,KAAK,MAAM;EACb;EACA,cAAc;GACZ,OAAO,KAAK,SAAS;EACvB;EACA,OAAO,SAAS;GACd,SAAS,oBAAoB,SAAS,WAAW,IAAI;GACrD,SAAS,cAAc;GACvB,KAAK,0BAA0B;GAC/B,KAAK,MAAM;EACb;EACA,UAAU;GACR,KAAK,aAAa;GAClB,SAAS,oBAAoB,MAAM,WAAW,IAAI;GAClD,SAAS,cAAc;GACvB,KAAK,MAAM;EACb;CACF;AACF"}
1
+ {"version":3,"file":"renderer.mjs","names":[],"sources":["../../src/renderer.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { HostRenderMode } from './hostTree'\nimport type { HostProps, MiniProgramEventLike, MiniProgramPageAdapter } from './types'\nimport { createContext } from 'react'\nimport Reconciler from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants'\nimport { name as rendererPackageName, version as rendererVersion } from '../package.json'\nimport { dispatchHostEvent } from './event'\nimport { HostElement, HostRoot, HostText } from './hostTree'\n\nfunction propsChanged(previous: HostProps, next: HostProps) {\n const previousKeys = Object.keys(previous).filter(key => key !== 'children')\n const nextKeys = Object.keys(next).filter(key => key !== 'children')\n if (previousKeys.length !== nextKeys.length) {\n return true\n }\n return nextKeys.some(key => previous[key] !== next[key])\n}\n\ntype HostContext = Record<string, never>\ntype HostNode = HostElement | HostText\ntype MiniProgramHostConfig = Reconciler.HostConfig<\n string,\n HostProps,\n HostRoot,\n HostElement,\n HostText,\n never,\n never,\n never,\n never,\n HostNode,\n HostContext,\n never,\n ReturnType<typeof setTimeout>,\n -1,\n null,\n null,\n never,\n never,\n never,\n never\n>\n\nlet currentUpdatePriority = NoEventPriority\nconst hostContext: HostContext = {}\n\nconst hostConfig: MiniProgramHostConfig = {\n HostTransitionContext: createContext(null) as never,\n NotPendingTransition: null,\n afterActiveInstanceBlur() {},\n appendChild(parent: HostElement, child: HostElement | HostText) {\n parent.append(child)\n },\n appendChildToContainer(parent: HostRoot, child: HostElement | HostText) {\n parent.append(child)\n },\n appendInitialChild(parent: HostElement, child: HostElement | HostText) {\n parent.append(child, false)\n },\n beforeActiveInstanceBlur() {},\n bindToConsole(methodName, args) {\n // eslint-disable-next-line no-console -- Reconciler 的日志重放需要保留宿主 console 的方法和调用接收者。\n const method: unknown = console[methodName as keyof typeof console]\n return typeof method === 'function' ? method.bind(console, ...args) : () => {}\n },\n cancelTimeout: clearTimeout,\n clearContainer(container: HostRoot) {\n container.clear()\n },\n commitMount() {},\n commitTextUpdate(text: HostText, _previous: string, next: string) {\n text.setValue(next)\n },\n commitUpdate(\n element: HostElement,\n _type: string,\n previous: HostProps,\n next: HostProps,\n ) {\n if (!propsChanged(previous, next)) {\n return\n }\n element.updateProps(next, element.root.shouldNotifyPropUpdate(previous, next))\n },\n createInstance(type: string, props: HostProps, root: HostRoot) {\n return new HostElement(root, root.createElementSid(props), type, props)\n },\n createTextInstance(text: string, root: HostRoot) {\n return new HostText(root, root.nextSid(), text)\n },\n detachDeletedInstance() {},\n extraDevToolsConfig: null,\n finalizeInitialChildren() {\n return false\n },\n getChildHostContext(parentContext: HostContext) {\n return parentContext\n },\n getCurrentUpdatePriority() {\n return currentUpdatePriority\n },\n getInstanceFromNode() {\n return null\n },\n getInstanceFromScope() {\n return null\n },\n getPublicInstance(instance: HostElement | HostText) {\n return instance\n },\n getRootHostContext(): HostContext {\n return hostContext\n },\n getSuspendedCommitReason() {\n return null\n },\n hideInstance(instance: HostElement) {\n instance.updateProps({\n ...instance.props,\n hidden: true,\n })\n },\n hideTextInstance(instance: HostText) {\n instance.setValue('')\n },\n insertBefore(parent: HostElement, child: HostElement | HostText, before: HostElement | HostText) {\n parent.insertBefore(child, before)\n },\n insertInContainerBefore(parent: HostRoot, child: HostElement | HostText, before: HostElement | HostText) {\n parent.insertBefore(child, before)\n },\n isPrimaryRenderer: true,\n maySuspendCommit() {\n return false\n },\n maySuspendCommitInSyncRender() {\n return false\n },\n maySuspendCommitOnUpdate() {\n return false\n },\n noTimeout: -1,\n preloadInstance() {\n return true\n },\n prepareForCommit() {\n return null\n },\n preparePortalMount() {},\n prepareScopeUpdate() {},\n requestPostPaintCallback(callback: (time: number) => void) {\n setTimeout(() => callback(Date.now()), 0)\n },\n resetFormInstance() {},\n resolveEventTimeStamp() {\n return -1.1\n },\n resolveEventType() {\n return null\n },\n resolveUpdatePriority() {\n return currentUpdatePriority === NoEventPriority ? DefaultEventPriority : currentUpdatePriority\n },\n removeChild(parent: HostElement, child: HostElement | HostText) {\n parent.remove(child)\n },\n removeChildFromContainer(parent: HostRoot, child: HostElement | HostText) {\n parent.remove(child)\n },\n rendererPackageName,\n rendererVersion,\n resetAfterCommit(container: HostRoot) {\n container.flush()\n },\n resetTextContent() {},\n scheduleMicrotask(callback: () => void) {\n Promise.resolve().then(callback)\n },\n scheduleTimeout: setTimeout,\n setCurrentUpdatePriority(priority: number) {\n currentUpdatePriority = priority\n },\n shouldAttemptEagerTransition() {\n return false\n },\n shouldSetTextContent() {\n return false\n },\n supportsHydration: false,\n supportsMicrotasks: true,\n supportsMutation: true,\n supportsPersistence: false,\n suspendInstance() {},\n suspendOnActiveViewTransition() {},\n startSuspendingCommit() {\n return null\n },\n trackSchedulerEvent() {},\n unhideInstance(instance: HostElement, props: HostProps) {\n instance.updateProps(props)\n },\n unhideTextInstance(instance: HostText, text: string) {\n instance.setValue(text)\n },\n waitForCommitToBeReady() {\n return null\n },\n warnsIfNotActing: true,\n}\n\nconst renderer = Reconciler(hostConfig)\n\nexport interface ReactMiniProgramRoot {\n dispatchEvent: (event: MiniProgramEventLike) => void\n flush: () => void\n getSnapshot: () => ReturnType<HostRoot['snapshot']>\n render: (element: ReactNode) => void\n unmount: () => void\n}\n\nexport interface ReactMiniProgramRootOptions {\n renderMode?: HostRenderMode\n}\n\nfunction createContainer(root: HostRoot) {\n return renderer.createContainer(\n root,\n 0,\n null,\n false,\n false,\n '',\n (error) => {\n throw error\n },\n () => {},\n (error) => {\n throw error\n },\n () => {},\n null,\n )\n}\n\nexport function createReactMiniProgramRoot(\n adapter: MiniProgramPageAdapter,\n options: ReactMiniProgramRootOptions = {},\n): ReactMiniProgramRoot {\n const root = new HostRoot(adapter, options.renderMode)\n const container = createContainer(root)\n\n return {\n dispatchEvent(event) {\n renderer.flushSyncFromReconciler(() => dispatchHostEvent(root, event))\n root.assertStaticTemplateValid()\n root.flush()\n },\n flush() {\n renderer.flushSyncFromReconciler()\n root.flush()\n },\n getSnapshot() {\n return root.snapshot()\n },\n render(element) {\n renderer.updateContainerSync(element, container, null)\n renderer.flushSyncWork()\n root.assertStaticTemplateValid()\n root.flush()\n },\n unmount() {\n root.beginUnmount()\n renderer.updateContainerSync(null, container, null)\n renderer.flushSyncWork()\n root.flush()\n },\n }\n}\n"],"mappings":";;;;;;;;;AAUA,SAAS,aAAa,UAAqB,MAAiB;CAC1D,MAAM,eAAe,OAAO,KAAK,QAAQ,CAAC,CAAC,QAAO,QAAO,QAAQ,UAAU;CAC3E,MAAM,WAAW,OAAO,KAAK,IAAI,CAAC,CAAC,QAAO,QAAO,QAAQ,UAAU;CACnE,IAAI,aAAa,WAAW,SAAS,QACnC,OAAO;CAET,OAAO,SAAS,MAAK,QAAO,SAAS,SAAS,KAAK,IAAI;AACzD;AA2BA,IAAI,wBAAwB;AAC5B,MAAM,cAA2B,CAAC;AAElC,MAAM,aAAoC;CACxC,uBAAuB,cAAc,IAAI;CACzC,sBAAsB;CACtB,0BAA0B,CAAC;CAC3B,YAAY,QAAqB,OAA+B;EAC9D,OAAO,OAAO,KAAK;CACrB;CACA,uBAAuB,QAAkB,OAA+B;EACtE,OAAO,OAAO,KAAK;CACrB;CACA,mBAAmB,QAAqB,OAA+B;EACrE,OAAO,OAAO,O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SACM,CAAC,IACN,UAAU;EACT,MAAM;CACR,SACM,CAAC,GACP,IACF;AACF;AAEA,SAAgB,2BACd,SACA,UAAuC,CAAC,GAClB;CACtB,MAAM,OAAO,IAAI,SAAS,SAAS,QAAQ,UAAU;CACrD,MAAM,YAAY,gBAAgB,IAAI;CAEtC,OAAO;EACL,cAAc,OAAO;GACnB,SAAS,8BAA8B,kBAAkB,MAAM,KAAK,CAAC;GACrE,KAAK,0BAA0B;GAC/B,KAAK,MAAM;EACb;EACA,QAAQ;GACN,SAAS,wBAAwB;GACjC,KAAK,MAAM;EACb;EACA,cAAc;GACZ,OAAO,KAAK,SAAS;EACvB;EACA,OAAO,SAAS;GACd,SAAS,oBAAoB,SAAS,WAAW,IAAI;GACrD,SAAS,cAAc;GACvB,KAAK,0BAA0B;GAC/B,KAAK,MAAM;EACb;EACA,UAAU;GACR,KAAK,aAAa;GAClB,SAAS,oBAAoB,MAAM,WAAW,IAAI;GAClD,SAAS,cAAc;GACvB,KAAK,MAAM;EACb;CACF;AACF"}
@@ -1 +1 @@
1
- import{hasSerializedPropChanges as e}from"./serialization.mjs";import t from"../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/defineProperty.mjs";import{HostElement as n,HostText as r,attachHostNode as i}from"./nodes.mjs";import{StaticBindingState as a,hasStaticBindingChanges as o,readStaticSlot as s}from"./staticBindings.mjs";import{WEAPP_REACT_ROOT_DATA_KEY as c,WEAPP_REACT_SLOTS_DATA_KEY as l}from"@weapp-core/constants";var u=class r{constructor(e,n=`tree`){t(this,`children`,[]),t(this,`renderMode`,void 0),t(this,`dirtyNodes`,/* @__PURE__ */ new Set),t(this,`dirtyStructures`,/* @__PURE__ */ new Set),t(this,`mounted`,!1),t(this,`nodeId`,0),t(this,`nodes`,/* @__PURE__ */ new Map),t(this,`pendingFlush`,!1),t(this,`adapter`,void 0),t(this,`staticBindings`,new a),t(this,`staticMismatch`,void 0),t(this,`unmounting`,!1),this.adapter=e,this.renderMode=n}beginUnmount(){this.unmounting=!0}assertStaticTemplateValid(){if(!this.staticMismatch)return;let e=this.staticMismatch;throw this.staticMismatch=void 0,e}createElementSid(e){return this.renderMode===`static-bindings`?s(e):this.nextSid()}nextSid(){return this.nodeId+=1,`r${this.nodeId}`}register(e){if(this.renderMode===`static-bindings`&&e instanceof n&&this.nodes.has(e.sid))throw Error(`static template slot 冲突:${e.sid}`);this.nodes.set(e.sid,e)}unregisterTree(e){this.nodes.delete(e.sid),e instanceof n&&e.children.forEach(e=>this.unregisterTree(e))}getNode(e){return this.nodes.get(e)}append(e){i(this,e),this.markStructure(this)}insertBefore(e,t){let n=this.children.indexOf(t);i(this,e,n<0?void 0:n),this.markStructure(this)}remove(e){let t=this.children.indexOf(e);t<0||(this.children.splice(t,1),e.parent=null,this.unregisterTree(e),this.markStructure(this))}clear(){this.children.forEach(e=>this.unregisterTree(e)),this.children.length=0,this.markStructure(this)}markNode(e){this.dirtyNodes.add(e),this.scheduleFlush()}markElementProps(e,t,n){if(this.renderMode===`static-bindings`){this.staticBindings.markProps(e,t,n),this.scheduleFlush();return}this.markNode(e)}markStaticText(e){this.staticBindings.markField(e,`text`),this.scheduleFlush()}markStructure(e){if(this.renderMode===`static-bindings`){this.mounted&&!this.unmounting&&(this.staticMismatch=/* @__PURE__ */ Error(`static template 运行时结构发生变化,需要切换 dynamic island fallback`));return}this.dirtyStructures.add(e),this.scheduleFlush()}scheduleFlush(){this.pendingFlush||(this.pendingFlush=!0,Promise.resolve().then(()=>this.flush()))}pathOf(e){if(e instanceof r)return`root`;let t=e.parent;if(!t)return;let n=this.pathOf(t),i=t.children.indexOf(e);return n&&i>=0?`${n}.cn[${i}]`:void 0}hasStructuralAncestor(e){let t=e.parent;for(;t;){if(this.dirtyStructures.has(t))return!0;t=t instanceof n?t.parent:null}return!1}snapshot(){return{cn:this.children.map(e=>e.serialize())}}shouldNotifyPropUpdate(t,n){return this.renderMode===`static-bindings`?o(t,n):e(t,n)}staticElements(){return Array.from(this.nodes.values()).filter(e=>e instanceof n)}flushStaticBindings(){if(this.staticMismatch){this.staticBindings.clear();return}if(!this.mounted){this.mounted=!0,this.staticBindings.clear(),this.adapter.setData({[l]:this.staticBindings.snapshot(this.staticElements())});return}let e=this.staticBindings.takePayload();Object.keys(e).length>0&&!this.unmounting&&this.adapter.setData(e)}flush(){if(this.pendingFlush=!1,this.renderMode===`static-bindings`){this.flushStaticBindings();return}if(!this.mounted){this.mounted=!0,this.dirtyNodes.clear(),this.dirtyStructures.clear(),this.adapter.setData({[c]:this.snapshot()});return}let e={};for(let t of this.dirtyStructures){let n=this.pathOf(t);n&&(e[`${n}.cn`]=t.children.map(e=>e.serialize()))}for(let t of this.dirtyNodes){if(this.hasStructuralAncestor(t))continue;let n=this.pathOf(t);n&&(e[n]=t.serialize())}this.dirtyNodes.clear(),this.dirtyStructures.clear(),Object.keys(e).length>0&&this.adapter.setData(e)}};export{n as HostElement,u as HostRoot,r as HostText};
1
+ import{hasSerializedPropChanges as e}from"./serialization.mjs";import t from"../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.mjs";import{HostElement as n,HostText as r,attachHostNode as i}from"./nodes.mjs";import{StaticBindingState as a,hasStaticBindingChanges as o,readStaticSlot as s}from"./staticBindings.mjs";import{WEAPP_REACT_ROOT_DATA_KEY as c,WEAPP_REACT_SLOTS_DATA_KEY as l}from"@weapp-core/constants";var u=class r{constructor(e,n=`tree`){t(this,`children`,[]),t(this,`renderMode`,void 0),t(this,`dirtyNodes`,/* @__PURE__ */ new Set),t(this,`dirtyStructures`,/* @__PURE__ */ new Set),t(this,`mounted`,!1),t(this,`nodeId`,0),t(this,`nodes`,/* @__PURE__ */ new Map),t(this,`pendingFlush`,!1),t(this,`adapter`,void 0),t(this,`staticBindings`,new a),t(this,`staticMismatch`,void 0),t(this,`unmounting`,!1),this.adapter=e,this.renderMode=n}beginUnmount(){this.unmounting=!0}assertStaticTemplateValid(){if(!this.staticMismatch)return;let e=this.staticMismatch;throw this.staticMismatch=void 0,e}createElementSid(e){return this.renderMode===`static-bindings`?s(e):this.nextSid()}nextSid(){return this.nodeId+=1,`r${this.nodeId}`}register(e){if(this.renderMode===`static-bindings`&&e instanceof n&&this.nodes.has(e.sid))throw Error(`static template slot 冲突:${e.sid}`);this.nodes.set(e.sid,e)}unregisterTree(e){this.nodes.delete(e.sid),e instanceof n&&e.children.forEach(e=>this.unregisterTree(e))}getNode(e){return this.nodes.get(e)}append(e){i(this,e),this.markStructure(this)}insertBefore(e,t){let n=this.children.indexOf(t);i(this,e,n<0?void 0:n),this.markStructure(this)}remove(e){let t=this.children.indexOf(e);t<0||(this.children.splice(t,1),e.parent=null,this.unregisterTree(e),this.markStructure(this))}clear(){this.children.forEach(e=>this.unregisterTree(e)),this.children.length=0,this.markStructure(this)}markNode(e){this.dirtyNodes.add(e),this.scheduleFlush()}markElementProps(e,t,n){this.renderMode===`static-bindings`?(this.staticBindings.markProps(e,t,n),this.scheduleFlush()):this.markNode(e)}markStaticText(e){this.staticBindings.markField(e,`text`),this.scheduleFlush()}markStructure(e){this.renderMode===`static-bindings`?this.mounted&&!this.unmounting&&(this.staticMismatch=/* @__PURE__ */ Error(`static template 运行时结构发生变化,需要切换 dynamic island fallback`)):(this.dirtyStructures.add(e),this.scheduleFlush())}scheduleFlush(){this.pendingFlush||(this.pendingFlush=!0,Promise.resolve().then(()=>this.flush()))}pathOf(e){if(e instanceof r)return`root`;let t=e.parent;if(!t)return;let n=this.pathOf(t),i=t.children.indexOf(e);return n&&i>=0?`${n}.cn[${i}]`:void 0}hasStructuralAncestor(e){let t=e.parent;for(;t;){if(this.dirtyStructures.has(t))return!0;t=t instanceof n?t.parent:null}return!1}snapshot(){return{cn:this.children.map(e=>e.serialize())}}shouldNotifyPropUpdate(t,n){return this.renderMode===`static-bindings`?o(t,n):e(t,n)}staticElements(){return Array.from(this.nodes.values()).filter(e=>e instanceof n)}flushStaticBindings(){if(this.staticMismatch){this.staticBindings.clear();return}if(!this.mounted){this.mounted=!0,this.staticBindings.clear(),this.adapter.setData({[l]:this.staticBindings.snapshot(this.staticElements())});return}let e=this.staticBindings.takePayload();Object.keys(e).length>0&&!this.unmounting&&this.adapter.setData(e)}flush(){if(this.pendingFlush=!1,this.renderMode===`static-bindings`){this.flushStaticBindings();return}if(!this.mounted){this.mounted=!0,this.dirtyNodes.clear(),this.dirtyStructures.clear(),this.adapter.setData({[c]:this.snapshot()});return}let e={};for(let t of this.dirtyStructures){let n=this.pathOf(t);n&&(e[`${n}.cn`]=t.children.map(e=>e.serialize()))}for(let t of this.dirtyNodes){if(this.hasStructuralAncestor(t))continue;let n=this.pathOf(t);n&&(e[n]=t.serialize())}this.dirtyNodes.clear(),this.dirtyStructures.clear(),Object.keys(e).length>0&&this.adapter.setData(e)}};export{n as HostElement,u as HostRoot,r as HostText};
@@ -1 +1 @@
1
- import{serializeProps as e,serializeStyle as t}from"./serialization.mjs";import n from"../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/defineProperty.mjs";function r(e,t,n){if(t.parent){let e=t.parent.children.indexOf(t);e>=0&&t.parent.children.splice(e,1)}t.parent=e,n===void 0?e.children.push(t):e.children.splice(n,0,t)}var i=class{constructor(e,t,r){n(this,`parent`,null),n(this,`root`,void 0),n(this,`sid`,void 0),n(this,`value`,void 0),this.root=e,this.sid=t,this.value=r,e.register(this)}serialize(){return{nn:`#text`,sid:this.sid,v:this.value}}setValue(e){e!==this.value&&(this.value=e,this.root.renderMode===`static-bindings`&&this.parent&&`props`in this.parent?this.root.markStaticText(this.parent):this.root.markNode(this))}},a=class{constructor(e,t,r,i){n(this,`children`,[]),n(this,`parent`,null),n(this,`props`,void 0),n(this,`root`,void 0),n(this,`sid`,void 0),n(this,`type`,void 0),this.props=i,this.root=e,this.sid=t,this.type=r,e.register(this)}append(e,t=!0){r(this,e),t&&this.root.markStructure(this)}insertBefore(e,t){let n=this.children.indexOf(t);r(this,e,n<0?void 0:n),this.root.markStructure(this)}remove(e){let t=this.children.indexOf(e);t<0||(this.children.splice(t,1),e.parent=null,this.root.unregisterTree(e),this.root.markStructure(this))}serialize(){var n;let r=(n=this.props.className)==null?this.props.class:n,i={nn:this.type,sid:this.sid};this.children.length>0&&(i.cn=this.children.map(e=>e.serialize())),typeof r==`string`&&r&&(i.cl=r);let a=t(this.props.style);a&&(i.st=a);let o=e(this.props);return o&&(i.p=o),i}updateProps(e,t=!0){let n=this.props;this.props=e,t&&this.root.markElementProps(this,n,e)}};function o(e,t,n){r(e,t,n)}export{a as HostElement,i as HostText,o as attachHostNode};
1
+ import{serializeProps as e,serializeStyle as t}from"./serialization.mjs";import n from"../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.mjs";function r(e,t,n){if(t.parent){let e=t.parent.children.indexOf(t);e>=0&&t.parent.children.splice(e,1)}t.parent=e,n===void 0?e.children.push(t):e.children.splice(n,0,t)}var i=class{constructor(e,t,r){n(this,`parent`,null),n(this,`root`,void 0),n(this,`sid`,void 0),n(this,`value`,void 0),this.root=e,this.sid=t,this.value=r,e.register(this)}serialize(){return{nn:`#text`,sid:this.sid,v:this.value}}setValue(e){e!==this.value&&(this.value=e,this.root.renderMode===`static-bindings`&&this.parent&&`props`in this.parent?this.root.markStaticText(this.parent):this.root.markNode(this))}},a=class{constructor(e,t,r,i){n(this,`children`,[]),n(this,`parent`,null),n(this,`props`,void 0),n(this,`root`,void 0),n(this,`sid`,void 0),n(this,`type`,void 0),this.props=i,this.root=e,this.sid=t,this.type=r,e.register(this)}append(e,t=!0){r(this,e),t&&this.root.markStructure(this)}insertBefore(e,t){let n=this.children.indexOf(t);r(this,e,n<0?void 0:n),this.root.markStructure(this)}remove(e){let t=this.children.indexOf(e);t<0||(this.children.splice(t,1),e.parent=null,this.root.unregisterTree(e),this.root.markStructure(this))}serialize(){var n;let r=(n=this.props.className)==null?this.props.class:n,i={nn:this.type,sid:this.sid};this.children.length>0&&(i.cn=this.children.map(e=>e.serialize())),typeof r==`string`&&r&&(i.cl=r);let a=t(this.props.style);a&&(i.st=a);let o=e(this.props);return o&&(i.p=o),i}updateProps(e,t=!0){let n=this.props;this.props=e,t&&this.root.markElementProps(this,n,e)}};function o(e,t,n){r(e,t,n)}export{a as HostElement,i as HostText,o as attachHostNode};
@@ -1 +1 @@
1
- import{serializeStyle as e}from"./serialization.mjs";import t from"../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/defineProperty.mjs";function n(e){return`value`in e}function r(e){return n(e)?e.value:e.children.map(r).join(``)}function i(e){let t=e.__bindingFields;return typeof t==`string`&&t?t.split(`,`).filter(Boolean):[]}function a(e){let t=e.__slot;if(typeof t!=`string`||!t)throw Error(`static template host node 缺少编译期 __slot`);return t}function o(t,n,i=t.props){if(n===`text`)return t.children.map(r).join(``);if(n===`className`){var a,o;return(a=(o=i.className)==null?i.class:o)==null?``:a}if(n===`style`){var s;return(s=e(i.style))==null?``:s}return i[n]}function s(t,n){return i(n).some(r=>{if(r===`text`)return!1;if(r===`className`){var i,a;return((i=t.className)==null?t.class:i)!==((a=n.className)==null?n.class:a)}return r===`style`?e(t.style)!==e(n.style):t[r]!==n[r]})}var c=class{constructor(){t(this,`dirty`,/* @__PURE__ */ new Map)}clear(){this.dirty.clear()}markField(e,t){let n=this.dirty.get(e);n||(n=/* @__PURE__ */ new Set,this.dirty.set(e,n)),n.add(t)}markProps(e,t,n){for(let r of i(n))r!==`text`&&o(e,r,t)!==o(e,r,n)&&this.markField(e,r)}snapshot(e){let t={};for(let n of e){let e=i(n.props);if(e.length===0)continue;let r={};for(let t of e)r[t]=o(n,t);t[n.sid]=r}return t}takePayload(){let e={};for(let[t,n]of this.dirty)for(let r of n)e[`slots.${t.sid}.${r}`]=o(t,r);return this.dirty.clear(),e}};export{c as StaticBindingState,s as hasStaticBindingChanges,i as readStaticBindingFields,a as readStaticSlot};
1
+ import{serializeStyle as e}from"./serialization.mjs";import t from"../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.mjs";function n(e){return`value`in e}function r(e){return n(e)?e.value:e.children.map(r).join(``)}function i(e){let t=e.__bindingFields;return typeof t==`string`&&t?t.split(`,`).filter(Boolean):[]}function a(e){let t=e.__slot;if(typeof t!=`string`||!t)throw Error(`static template host node 缺少编译期 __slot`);return t}function o(t,n,i=t.props){if(n===`text`)return t.children.map(r).join(``);if(n===`className`){var a,o;return(a=(o=i.className)==null?i.class:o)==null?``:a}if(n===`style`){var s;return(s=e(i.style))==null?``:s}return i[n]}function s(t,n){return i(n).some(r=>{if(r===`text`)return!1;if(r===`className`){var i,a;return((i=t.className)==null?t.class:i)!==((a=n.className)==null?n.class:a)}return r===`style`?e(t.style)!==e(n.style):t[r]!==n[r]})}var c=class{constructor(){t(this,`dirty`,/* @__PURE__ */ new Map)}clear(){this.dirty.clear()}markField(e,t){let n=this.dirty.get(e);n||(n=/* @__PURE__ */ new Set,this.dirty.set(e,n)),n.add(t)}markProps(e,t,n){for(let r of i(n))r!==`text`&&o(e,r,t)!==o(e,r,n)&&this.markField(e,r)}snapshot(e){let t={};for(let n of e){let e=i(n.props);if(e.length===0)continue;let r={};for(let t of e)r[t]=o(n,t);t[n.sid]=r}return t}takePayload(){let e={};for(let[t,n]of this.dirty)for(let r of n)e[`slots.${t.sid}.${r}`]=o(t,r);return this.dirty.clear(),e}};export{c as StaticBindingState,s as hasStaticBindingChanges,i as readStaticBindingFields,a as readStaticSlot};
@@ -0,0 +1 @@
1
+ var e=`@weapp-vite/react`,t=`0.2.12`;export{e as name,t as version};
package/dist/renderer.mjs CHANGED
@@ -1 +1 @@
1
- import{HostElement as e,HostText as t}from"./hostTree/nodes.mjs";import{HostRoot as n}from"./hostTree/index.mjs";import{dispatchHostEvent as r}from"./event.mjs";import{createContext as i}from"react";import a from"react-reconciler";import{DefaultEventPriority as o,NoEventPriority as s}from"react-reconciler/constants.js";function c(e,t){let n=Object.keys(e).filter(e=>e!==`children`),r=Object.keys(t).filter(e=>e!==`children`);return n.length!==r.length||r.some(n=>e[n]!==t[n])}let l=s;const u={},d={HostTransitionContext:i(null),NotPendingTransition:null,afterActiveInstanceBlur(){},appendChild(e,t){e.append(t)},appendChildToContainer(e,t){e.append(t)},appendInitialChild(e,t){e.append(t,!1)},beforeActiveInstanceBlur(){},cancelTimeout:clearTimeout,clearContainer(e){e.clear()},commitMount(){},commitTextUpdate(e,t,n){e.setValue(n)},commitUpdate(e,t,n,r){c(n,r)&&e.updateProps(r,e.root.shouldNotifyPropUpdate(n,r))},createInstance(t,n,r){return new e(r,r.createElementSid(n),t,n)},createTextInstance(e,n){return new t(n,n.nextSid(),e)},detachDeletedInstance(){},finalizeInitialChildren(){return!1},getChildHostContext(e){return e},getCurrentUpdatePriority(){return l},getInstanceFromNode(){return null},getInstanceFromScope(){return null},getPublicInstance(e){return e},getRootHostContext(){return u},getSuspendedCommitReason(){return null},hideInstance(e){e.updateProps({...e.props,hidden:!0})},hideTextInstance(e){e.setValue(``)},insertBefore(e,t,n){e.insertBefore(t,n)},insertInContainerBefore(e,t,n){e.insertBefore(t,n)},isPrimaryRenderer:!0,maySuspendCommit(){return!1},maySuspendCommitInSyncRender(){return!1},maySuspendCommitOnUpdate(){return!1},noTimeout:-1,preloadInstance(){return!0},prepareForCommit(){return null},preparePortalMount(){},prepareScopeUpdate(){},requestPostPaintCallback(e){setTimeout(()=>e(Date.now()),0)},resetFormInstance(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return l===s?o:l},removeChild(e,t){e.remove(t)},removeChildFromContainer(e,t){e.remove(t)},resetAfterCommit(e){e.flush()},resetTextContent(){},scheduleMicrotask(e){Promise.resolve().then(e)},scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){l=e},shouldAttemptEagerTransition(){return!1},shouldSetTextContent(){return!1},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},startSuspendingCommit(){},trackSchedulerEvent(){},unhideInstance(e,t){e.updateProps(t)},unhideTextInstance(e,t){e.setValue(t)},waitForCommitToBeReady(){return null},warnsIfNotActing:!0},f=a(d);function p(e){return f.createContainer(e,0,null,!1,!1,``,e=>{throw e},()=>{},e=>{throw e},()=>{})}function m(e,t={}){let i=new n(e,t.renderMode),a=p(i);return{dispatchEvent(e){f.flushSyncFromReconciler(()=>r(i,e)),i.assertStaticTemplateValid(),i.flush()},flush(){f.flushSyncFromReconciler(),i.flush()},getSnapshot(){return i.snapshot()},render(e){f.updateContainerSync(e,a,null),f.flushSyncWork(),i.assertStaticTemplateValid(),i.flush()},unmount(){i.beginUnmount(),f.updateContainerSync(null,a,null),f.flushSyncWork(),i.flush()}}}export{m as createReactMiniProgramRoot};
1
+ import{name as e,version as t}from"./package.mjs";import{HostElement as n,HostText as r}from"./hostTree/nodes.mjs";import{HostRoot as i}from"./hostTree/index.mjs";import{dispatchHostEvent as a}from"./event.mjs";import{createContext as o}from"react";import s from"react-reconciler";import{DefaultEventPriority as c,NoEventPriority as l}from"react-reconciler/constants.js";function u(e,t){let n=Object.keys(e).filter(e=>e!==`children`),r=Object.keys(t).filter(e=>e!==`children`);return n.length!==r.length||r.some(n=>e[n]!==t[n])}let d=l;const f={},p={HostTransitionContext:o(null),NotPendingTransition:null,afterActiveInstanceBlur(){},appendChild(e,t){e.append(t)},appendChildToContainer(e,t){e.append(t)},appendInitialChild(e,t){e.append(t,!1)},beforeActiveInstanceBlur(){},bindToConsole(e,t){let n=console[e];return typeof n==`function`?n.bind(console,...t):()=>{}},cancelTimeout:clearTimeout,clearContainer(e){e.clear()},commitMount(){},commitTextUpdate(e,t,n){e.setValue(n)},commitUpdate(e,t,n,r){u(n,r)&&e.updateProps(r,e.root.shouldNotifyPropUpdate(n,r))},createInstance(e,t,r){return new n(r,r.createElementSid(t),e,t)},createTextInstance(e,t){return new r(t,t.nextSid(),e)},detachDeletedInstance(){},extraDevToolsConfig:null,finalizeInitialChildren(){return!1},getChildHostContext(e){return e},getCurrentUpdatePriority(){return d},getInstanceFromNode(){return null},getInstanceFromScope(){return null},getPublicInstance(e){return e},getRootHostContext(){return f},getSuspendedCommitReason(){return null},hideInstance(e){e.updateProps({...e.props,hidden:!0})},hideTextInstance(e){e.setValue(``)},insertBefore(e,t,n){e.insertBefore(t,n)},insertInContainerBefore(e,t,n){e.insertBefore(t,n)},isPrimaryRenderer:!0,maySuspendCommit(){return!1},maySuspendCommitInSyncRender(){return!1},maySuspendCommitOnUpdate(){return!1},noTimeout:-1,preloadInstance(){return!0},prepareForCommit(){return null},preparePortalMount(){},prepareScopeUpdate(){},requestPostPaintCallback(e){setTimeout(()=>e(Date.now()),0)},resetFormInstance(){},resolveEventTimeStamp(){return-1.1},resolveEventType(){return null},resolveUpdatePriority(){return d===l?c:d},removeChild(e,t){e.remove(t)},removeChildFromContainer(e,t){e.remove(t)},rendererPackageName:e,rendererVersion:t,resetAfterCommit(e){e.flush()},resetTextContent(){},scheduleMicrotask(e){Promise.resolve().then(e)},scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){d=e},shouldAttemptEagerTransition(){return!1},shouldSetTextContent(){return!1},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance(){},suspendOnActiveViewTransition(){},startSuspendingCommit(){return null},trackSchedulerEvent(){},unhideInstance(e,t){e.updateProps(t)},unhideTextInstance(e,t){e.setValue(t)},waitForCommitToBeReady(){return null},warnsIfNotActing:!0},m=s(p);function h(e){return m.createContainer(e,0,null,!1,!1,``,e=>{throw e},()=>{},e=>{throw e},()=>{},null)}function g(e,t={}){let n=new i(e,t.renderMode),r=h(n);return{dispatchEvent(e){m.flushSyncFromReconciler(()=>a(n,e)),n.assertStaticTemplateValid(),n.flush()},flush(){m.flushSyncFromReconciler(),n.flush()},getSnapshot(){return n.snapshot()},render(e){m.updateContainerSync(e,r,null),m.flushSyncWork(),n.assertStaticTemplateValid(),n.flush()},unmount(){n.beginUnmount(),m.updateContainerSync(null,r,null),m.flushSyncWork(),n.flush()}}}export{g as createReactMiniProgramRoot};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-vite/react",
3
3
  "type": "module",
4
- "version": "0.2.11",
4
+ "version": "0.2.12",
5
5
  "description": "React 19 runtime for weapp-vite mini programs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/weapp-vite/weapp-vite#readme",
@@ -61,11 +61,11 @@
61
61
  "react-reconciler": "0.34.0"
62
62
  },
63
63
  "dependencies": {
64
- "@weapp-core/constants": "0.3.0"
64
+ "@weapp-core/constants": "0.3.1"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/react": "19.3.0",
68
- "@types/react-reconciler": "0.33.0",
68
+ "@types/react-reconciler": "0.33.1",
69
69
  "miniprogram-api-typings": "^5.2.3",
70
70
  "react": "19.3.0",
71
71
  "react-reconciler": "0.34.0"
@@ -75,7 +75,8 @@
75
75
  "build": "tsdown",
76
76
  "build:types": "tsdown --dts",
77
77
  "test": "vitest run",
78
- "test:types": "tsd",
78
+ "test:types": "pnpm run test:types:check",
79
+ "test:types:check": "tsd --files \"test-d/**/*.test-d.ts\"",
79
80
  "typecheck": "tsc --noEmit",
80
81
  "lint": "eslint .",
81
82
  "lint:fix": "eslint . --fix"