@lynx-js/react 0.120.0 → 0.121.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/package.json +36 -8
- package/runtime/lazy/compat.js +1 -0
- package/runtime/lazy/react.js +1 -0
- package/runtime/lib/core/commit-context.d.ts +8 -0
- package/runtime/lib/core/commit-context.js +18 -0
- package/runtime/lib/core/commit-context.js.map +1 -0
- package/runtime/lib/core/forceRootRender.d.ts +7 -0
- package/runtime/lib/core/forceRootRender.js +40 -0
- package/runtime/lib/core/forceRootRender.js.map +1 -0
- package/runtime/lib/core/globalProps.d.ts +31 -0
- package/runtime/lib/core/globalProps.js +55 -0
- package/runtime/lib/core/globalProps.js.map +1 -0
- package/runtime/lib/core/hooks/mainThread.d.ts +1 -0
- package/runtime/lib/core/hooks/mainThread.js +7 -0
- package/runtime/lib/core/hooks/mainThread.js.map +1 -0
- package/runtime/lib/{snapshot/hooks/mainThread.d.ts → core/hooks/mainThreadImpl.d.ts} +2 -1
- package/runtime/lib/{snapshot/hooks/mainThread.js → core/hooks/mainThreadImpl.js} +45 -34
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -0
- package/runtime/lib/{snapshot → core}/hooks/react.js +1 -1
- package/runtime/lib/core/hooks/react.js.map +1 -0
- package/runtime/lib/{snapshot → core}/hooks/useLynxGlobalEventListener.d.ts +1 -1
- package/runtime/lib/{snapshot → core}/hooks/useLynxGlobalEventListener.js +2 -2
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -0
- package/runtime/lib/{snapshot/compat → core}/initData.d.ts +2 -2
- package/runtime/lib/{snapshot/compat → core}/initData.js +4 -5
- package/runtime/lib/core/initData.js.map +1 -0
- package/runtime/lib/core/lynx-data-processors.d.ts +2 -0
- package/runtime/lib/core/lynx-data-processors.js +53 -0
- package/runtime/lib/core/lynx-data-processors.js.map +1 -0
- package/runtime/lib/core/lynx-page-data.d.ts +1 -0
- package/runtime/lib/core/lynx-page-data.js +14 -0
- package/runtime/lib/core/lynx-page-data.js.map +1 -0
- package/runtime/lib/core/lynx-update-data.d.ts +11 -0
- package/runtime/lib/core/lynx-update-data.js +21 -0
- package/runtime/lib/core/lynx-update-data.js.map +1 -0
- package/runtime/lib/core/ref.d.ts +37 -0
- package/runtime/lib/core/ref.js +108 -0
- package/runtime/lib/core/ref.js.map +1 -0
- package/runtime/lib/core/reload-version.d.ts +2 -0
- package/runtime/lib/{snapshot/lifecycle/pass.js → core/reload-version.js} +4 -5
- package/runtime/lib/core/reload-version.js.map +1 -0
- package/runtime/lib/element-template/background/attr-slots.d.ts +7 -0
- package/runtime/lib/element-template/background/attr-slots.js +67 -0
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -0
- package/runtime/lib/element-template/background/commit-context.d.ts +13 -0
- package/runtime/lib/element-template/background/commit-context.js +22 -0
- package/runtime/lib/element-template/background/commit-context.js.map +1 -0
- package/runtime/lib/element-template/background/commit-hook.d.ts +7 -0
- package/runtime/lib/element-template/background/commit-hook.js +121 -0
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -0
- package/runtime/lib/element-template/background/destroy.d.ts +1 -0
- package/runtime/lib/element-template/background/destroy.js +20 -0
- package/runtime/lib/element-template/background/destroy.js.map +1 -0
- package/runtime/lib/element-template/background/document.d.ts +7 -0
- package/runtime/lib/element-template/background/document.js +21 -0
- package/runtime/lib/element-template/background/document.js.map +1 -0
- package/runtime/lib/element-template/background/hydrate.d.ts +4 -0
- package/runtime/lib/element-template/background/hydrate.js +236 -0
- package/runtime/lib/element-template/background/hydrate.js.map +1 -0
- package/runtime/lib/element-template/background/hydration-listener.d.ts +2 -0
- package/runtime/lib/element-template/background/hydration-listener.js +139 -0
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -0
- package/runtime/lib/element-template/background/instance.d.ts +41 -0
- package/runtime/lib/element-template/background/instance.js +347 -0
- package/runtime/lib/element-template/background/instance.js.map +1 -0
- package/runtime/lib/element-template/background/manager.d.ts +10 -0
- package/runtime/lib/element-template/background/manager.js +60 -0
- package/runtime/lib/element-template/background/manager.js.map +1 -0
- package/runtime/lib/element-template/client/root.d.ts +43 -0
- package/runtime/lib/element-template/client/root.js +30 -0
- package/runtime/lib/element-template/client/root.js.map +1 -0
- package/runtime/lib/element-template/debug/alog.d.ts +41 -0
- package/runtime/lib/element-template/debug/alog.js +103 -0
- package/runtime/lib/element-template/debug/alog.js.map +1 -0
- package/runtime/lib/element-template/debug/elementPAPICall.d.ts +1 -0
- package/runtime/lib/element-template/debug/elementPAPICall.js +79 -0
- package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -0
- package/runtime/lib/element-template/debug/profile.d.ts +3 -0
- package/runtime/lib/element-template/debug/profile.js +141 -0
- package/runtime/lib/element-template/debug/profile.js.map +1 -0
- package/runtime/lib/element-template/hydration-map.d.ts +5 -0
- package/runtime/lib/element-template/hydration-map.js +12 -0
- package/runtime/lib/element-template/hydration-map.js.map +1 -0
- package/runtime/lib/element-template/index.d.ts +28 -0
- package/runtime/lib/element-template/index.js +75 -0
- package/runtime/lib/element-template/index.js.map +1 -0
- package/runtime/lib/element-template/internal.d.ts +6 -0
- package/runtime/lib/element-template/internal.js +43 -0
- package/runtime/lib/element-template/internal.js.map +1 -0
- package/runtime/lib/element-template/jsx-dev-runtime/index.d.ts +1 -0
- package/runtime/lib/element-template/jsx-dev-runtime/index.js +5 -0
- package/runtime/lib/element-template/jsx-dev-runtime/index.js.map +1 -0
- package/runtime/lib/element-template/jsx-runtime/index.d.ts +19 -0
- package/runtime/lib/element-template/jsx-runtime/index.js +60 -0
- package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -0
- package/runtime/lib/element-template/lynx/env.d.ts +1 -0
- package/runtime/lib/element-template/lynx/env.js +46 -0
- package/runtime/lib/element-template/lynx/env.js.map +1 -0
- package/runtime/lib/element-template/lynx/performance.d.ts +23 -0
- package/runtime/lib/element-template/lynx/performance.js +135 -0
- package/runtime/lib/element-template/lynx/performance.js.map +1 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.d.ts +1 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +8 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -0
- package/runtime/lib/element-template/native/index.d.ts +1 -0
- package/runtime/lib/element-template/native/index.js +79 -0
- package/runtime/lib/element-template/native/index.js.map +1 -0
- package/runtime/lib/element-template/native/main-thread-api.d.ts +2 -0
- package/runtime/lib/element-template/native/main-thread-api.js +49 -0
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -0
- package/runtime/lib/element-template/native/mts-destroy.d.ts +3 -0
- package/runtime/lib/element-template/native/mts-destroy.js +37 -0
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -0
- package/runtime/lib/element-template/native/patch-listener.d.ts +2 -0
- package/runtime/lib/element-template/native/patch-listener.js +70 -0
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -0
- package/runtime/lib/element-template/native/reload.d.ts +2 -0
- package/runtime/lib/element-template/native/reload.js +64 -0
- package/runtime/lib/element-template/native/reload.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/event-value.d.ts +1 -0
- package/runtime/lib/element-template/prop-adapters/event-value.js +7 -0
- package/runtime/lib/element-template/prop-adapters/event-value.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/event.d.ts +8 -0
- package/runtime/lib/element-template/prop-adapters/event.js +64 -0
- package/runtime/lib/element-template/prop-adapters/event.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/ref.d.ts +26 -0
- package/runtime/lib/element-template/prop-adapters/ref.js +107 -0
- package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.d.ts +5 -0
- package/runtime/lib/element-template/prop-adapters/spread.js +52 -0
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +4 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.js +9 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -0
- package/runtime/lib/element-template/protocol/opcodes.d.ts +8 -0
- package/runtime/lib/element-template/protocol/opcodes.js +11 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -0
- package/runtime/lib/element-template/protocol/types.d.ts +98 -0
- package/runtime/lib/element-template/protocol/types.js +5 -0
- package/runtime/lib/element-template/protocol/types.js.map +1 -0
- package/runtime/lib/element-template/runtime/page/page.d.ts +5 -0
- package/runtime/lib/element-template/runtime/page/page.js +20 -0
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -0
- package/runtime/lib/element-template/runtime/page/root-instance.d.ts +10 -0
- package/runtime/lib/element-template/runtime/page/root-instance.js +17 -0
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -0
- package/runtime/lib/element-template/runtime/patch.d.ts +3 -0
- package/runtime/lib/element-template/runtime/patch.js +214 -0
- package/runtime/lib/element-template/runtime/patch.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.d.ts +4 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +71 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.d.ts +4 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +134 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +14 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +278 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +12 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +27 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/handle.d.ts +5 -0
- package/runtime/lib/element-template/runtime/template/handle.js +22 -0
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/registry.d.ts +13 -0
- package/runtime/lib/element-template/runtime/template/registry.js +46 -0
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -0
- package/runtime/lib/index.d.ts +5 -3
- package/runtime/lib/index.js +7 -4
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +3 -4
- package/runtime/lib/internal.js +4 -5
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +4 -9
- package/runtime/lib/lynx-api.js +11 -48
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.d.ts +1 -1
- package/runtime/lib/lynx.js +3 -3
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/{snapshot/debug → shared}/component-stack.js +1 -1
- package/runtime/lib/shared/component-stack.js.map +1 -0
- package/runtime/lib/{snapshot/debug → shared}/profile.js +6 -4
- package/runtime/lib/shared/profile.js.map +1 -0
- package/runtime/lib/{snapshot/renderToOpcodes/constants.js → shared/render-constants.js} +1 -1
- package/runtime/lib/shared/render-constants.js.map +1 -0
- package/runtime/lib/snapshot/alog/elementPAPICall.js +1 -1
- package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -1
- package/runtime/lib/snapshot/alog/render.js +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js +2 -2
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
- package/runtime/lib/snapshot/gesture/processGesture.d.ts +2 -0
- package/runtime/lib/snapshot/gesture/processGesture.js +16 -1
- package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -1
- package/runtime/lib/snapshot/legacy-react-runtime/index.d.ts +2 -2
- package/runtime/lib/snapshot/legacy-react-runtime/index.js +2 -2
- package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/jsReady.js +1 -1
- package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.d.ts +0 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +5 -10
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.d.ts +15 -0
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js +102 -0
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +2 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +17 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +26 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +7 -13
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +12 -31
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js +3 -3
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/render.js +1 -1
- package/runtime/lib/snapshot/lifecycle/render.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +5 -2
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js +4 -3
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +2 -8
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/lynx/component.js +3 -3
- package/runtime/lib/snapshot/lynx/component.js.map +1 -1
- package/runtime/lib/snapshot/lynx/element.d.ts +6 -0
- package/runtime/lib/snapshot/lynx/element.js +35 -0
- package/runtime/lib/snapshot/lynx/element.js.map +1 -0
- package/runtime/lib/snapshot/lynx/env.js +5 -51
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/nodesRef.d.ts +6 -0
- package/runtime/lib/snapshot/lynx/nodesRef.js +31 -0
- package/runtime/lib/snapshot/lynx/nodesRef.js.map +1 -0
- package/runtime/lib/snapshot/lynx/performance.js +1 -1
- package/runtime/lib/snapshot/lynx/performance.js.map +1 -1
- package/runtime/lib/snapshot/lynx/portals.d.ts +9 -0
- package/runtime/lib/snapshot/lynx/portals.js +120 -0
- package/runtime/lib/snapshot/lynx/portals.js.map +1 -0
- package/runtime/lib/snapshot/lynx/portalsPending.d.ts +10 -0
- package/runtime/lib/snapshot/lynx/portalsPending.js +38 -0
- package/runtime/lib/snapshot/lynx/portalsPending.js.map +1 -0
- package/runtime/lib/snapshot/lynx/runWithForce.js +9 -39
- package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.js +11 -31
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +23 -24
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/constants.d.ts +4 -0
- package/runtime/lib/snapshot/snapshot/constants.js +4 -0
- package/runtime/lib/snapshot/snapshot/constants.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/definition.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/definition.js +49 -1
- package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/dynamicPartType.d.ts +12 -0
- package/runtime/lib/snapshot/snapshot/dynamicPartType.js +12 -0
- package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/event.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/event.js +0 -4
- package/runtime/lib/snapshot/snapshot/event.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/gesture.js +9 -3
- package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/list.js +1 -1
- package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.d.ts +14 -0
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js +27 -0
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/ref.d.ts +3 -5
- package/runtime/lib/snapshot/snapshot/ref.js +16 -59
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js +62 -3
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js +32 -1
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/utils.d.ts +1 -3
- package/runtime/lib/snapshot/snapshot/utils.js +5 -0
- package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletEvent.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/workletEvent.js +10 -5
- package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletRef.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/workletRef.js +6 -3
- package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/workletRef.js +1 -1
- package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/utils.js +1 -1
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/observers.js +5 -3
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +1 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +5 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +2 -3
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/worklet-runtime/dev.js +9 -5
- package/runtime/worklet-runtime/main.js +1 -1
- package/testing-library/dist/env/index.js +27 -15
- package/testing-library/dist/fire-event.d.ts +21 -7
- package/testing-library/dist/index.d.ts +2 -0
- package/testing-library/dist/plugins/index.js +12 -1
- package/testing-library/dist/pure.js +27 -9
- package/testing-library/dist/type-entry/index.js +0 -0
- package/transform/dist/wasm.cjs +833 -285
- package/transform/index.d.ts +28 -1
- package/types/react.docs.d.ts +9 -1
- package/refresh/.gitignore +0 -1
- package/refresh/.npmignore +0 -3
- package/refresh/.turbo/turbo-build.log +0 -12
- package/refresh/package.json +0 -20
- package/refresh/rslib.config.ts +0 -24
- package/refresh/tsconfig.json +0 -4
- package/refresh/turbo.json +0 -15
- package/runtime/lib/snapshot/compat/initData.js.map +0 -1
- package/runtime/lib/snapshot/debug/component-stack.js.map +0 -1
- package/runtime/lib/snapshot/debug/profile.js.map +0 -1
- package/runtime/lib/snapshot/hooks/mainThread.js.map +0 -1
- package/runtime/lib/snapshot/hooks/react.js.map +0 -1
- package/runtime/lib/snapshot/hooks/useLynxGlobalEventListener.js.map +0 -1
- package/runtime/lib/snapshot/lifecycle/pass.d.ts +0 -3
- package/runtime/lib/snapshot/lifecycle/pass.js.map +0 -1
- package/runtime/lib/snapshot/renderToOpcodes/constants.js.map +0 -1
- package/testing-library/README.md +0 -109
- /package/runtime/lib/{snapshot → core}/hooks/react.d.ts +0 -0
- /package/runtime/lib/{snapshot/debug → shared}/component-stack.d.ts +0 -0
- /package/runtime/lib/{snapshot/debug → shared}/profile.d.ts +0 -0
- /package/runtime/lib/{snapshot/renderToOpcodes/constants.d.ts → shared/render-constants.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.121.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Disable vnode reuse of different slot index in preact's diff, fixing a bug that `__RemoveElement` was called with mismatched parent and child element. ([#2664](https://github.com/lynx-family/lynx-stack/pull/2664))
|
|
8
|
+
|
|
9
|
+
- Fix list update indices when existing items are updated after inserting siblings before them. ([#2518](https://github.com/lynx-family/lynx-stack/pull/2518))
|
|
10
|
+
|
|
11
|
+
## 0.121.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- Support `React.createElement(type, props, children)` API. ([#2360](https://github.com/lynx-family/lynx-stack/pull/2360))
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
React.createElement('view', { style }, <text>hello</text>);
|
|
19
|
+
// equivalent to
|
|
20
|
+
<view style={style}>
|
|
21
|
+
<text>hello</text>
|
|
22
|
+
</view>;
|
|
23
|
+
|
|
24
|
+
React.createElement(MyComponent, { style }, <view />);
|
|
25
|
+
// equivalent to
|
|
26
|
+
<MyComponent style={style}>
|
|
27
|
+
<view />
|
|
28
|
+
</MyComponent>;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Clear transient snapshot child props when removed snapshot subtrees are detached, preventing compiled `$*` child references from retaining deleted list holder or list item subtrees after removal. ([#2590](https://github.com/lynx-family/lynx-stack/pull/2590))
|
|
34
|
+
|
|
35
|
+
- Add `createPortal` for rendering a subtree into a different ReactLynx element identified by a `NodesRef`. ([#2543](https://github.com/lynx-family/lynx-stack/pull/2543))
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
function App() {
|
|
39
|
+
const [host, setHost] = useState(null);
|
|
40
|
+
return (
|
|
41
|
+
<view>
|
|
42
|
+
<view ref={setHost} />
|
|
43
|
+
{host && createPortal(<text>hi</text>, host)}
|
|
44
|
+
</view>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- Default `fireEvent` to `bubbles: true` for the TouchEvent family in testing-library to match Lynx runtime semantics, and stop reassigning the read-only `Event.prototype` accessors which threw `TypeError` in strict mode. ([#2532](https://github.com/lynx-family/lynx-stack/pull/2532))
|
|
50
|
+
|
|
51
|
+
- Set `bundle-url` on lazy bundle border elements. ([#2537](https://github.com/lynx-family/lynx-stack/pull/2537))
|
|
52
|
+
|
|
53
|
+
- Stop warning when `runWorklet` receives an invalid or missing main-thread function object. Invalid worklet contexts are still ignored, but nullish handler values no longer produce noisy `MainThreadFunction: Invalid function object` console output. ([#2586](https://github.com/lynx-family/lynx-stack/pull/2586))
|
|
54
|
+
|
|
55
|
+
- Retain main-thread worklet context references before offscreen snapshot elements are materialized, so event, ref, gesture, and spread callbacks stay alive until the DOM update path can attach them. ([#2592](https://github.com/lynx-family/lynx-stack/pull/2592))
|
|
56
|
+
|
|
57
|
+
- Update the @lynx-js/tasm dependency to 0.0.39 and align React template attribute descriptors with it. ([#2643](https://github.com/lynx-family/lynx-stack/pull/2643))
|
|
58
|
+
|
|
59
|
+
- Avoid retaining transformed nested worklet contexts after worklet transformation. ([#2591](https://github.com/lynx-family/lynx-stack/pull/2591))
|
|
60
|
+
|
|
61
|
+
Nested worklets transformed by the worklet runtime now keep their context recovery metadata through a weak reference, preventing cached transformed worklet functions from keeping list-item worklet contexts alive.
|
|
62
|
+
|
|
3
63
|
## 0.120.0
|
|
4
64
|
|
|
5
65
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.121.1",
|
|
4
4
|
"description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,6 +37,22 @@
|
|
|
37
37
|
"types": "./runtime/lib/document.d.ts",
|
|
38
38
|
"default": "./runtime/lib/document.js"
|
|
39
39
|
},
|
|
40
|
+
"./element-template": {
|
|
41
|
+
"types": "./runtime/lib/element-template/index.d.ts",
|
|
42
|
+
"default": "./runtime/lib/element-template/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./element-template/internal": {
|
|
45
|
+
"types": "./runtime/lib/element-template/internal.d.ts",
|
|
46
|
+
"default": "./runtime/lib/element-template/internal.js"
|
|
47
|
+
},
|
|
48
|
+
"./element-template/jsx-runtime": {
|
|
49
|
+
"types": "./runtime/lib/element-template/jsx-runtime/index.d.ts",
|
|
50
|
+
"default": "./runtime/lib/element-template/jsx-runtime/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./element-template/jsx-dev-runtime": {
|
|
53
|
+
"types": "./runtime/lib/element-template/jsx-dev-runtime/index.d.ts",
|
|
54
|
+
"default": "./runtime/lib/element-template/jsx-dev-runtime/index.js"
|
|
55
|
+
},
|
|
40
56
|
"./jsx-runtime": {
|
|
41
57
|
"types": "./runtime/jsx-runtime/index.d.ts",
|
|
42
58
|
"lazy": "./runtime/lazy/jsx-runtime.js",
|
|
@@ -56,12 +72,12 @@
|
|
|
56
72
|
"default": "./runtime/lepus/jsx-runtime/index.js"
|
|
57
73
|
},
|
|
58
74
|
"./hooks": {
|
|
59
|
-
"types": "./runtime/lib/
|
|
60
|
-
"default": "./runtime/lib/
|
|
75
|
+
"types": "./runtime/lib/core/hooks/react.d.ts",
|
|
76
|
+
"default": "./runtime/lib/core/hooks/react.js"
|
|
61
77
|
},
|
|
62
78
|
"./lepus/hooks": {
|
|
63
|
-
"types": "./runtime/lib/
|
|
64
|
-
"default": "./runtime/lib/
|
|
79
|
+
"types": "./runtime/lib/core/hooks/react.d.ts",
|
|
80
|
+
"default": "./runtime/lib/core/hooks/mainThread.js"
|
|
65
81
|
},
|
|
66
82
|
"./lepus": {
|
|
67
83
|
"types": "./runtime/lepus/index.d.ts",
|
|
@@ -132,10 +148,10 @@
|
|
|
132
148
|
"./runtime/lazy/import.d.ts"
|
|
133
149
|
],
|
|
134
150
|
"hooks": [
|
|
135
|
-
"./runtime/lib/
|
|
151
|
+
"./runtime/lib/core/hooks/react.d.ts"
|
|
136
152
|
],
|
|
137
153
|
"lepus/hooks": [
|
|
138
|
-
"./runtime/lib/
|
|
154
|
+
"./runtime/lib/core/hooks/react.d.ts"
|
|
139
155
|
],
|
|
140
156
|
"internal": [
|
|
141
157
|
"./runtime/lib/internal.d.ts"
|
|
@@ -143,6 +159,18 @@
|
|
|
143
159
|
"internal/document": [
|
|
144
160
|
"./runtime/lib/document.d.ts"
|
|
145
161
|
],
|
|
162
|
+
"element-template": [
|
|
163
|
+
"./runtime/lib/element-template/index.d.ts"
|
|
164
|
+
],
|
|
165
|
+
"element-template/internal": [
|
|
166
|
+
"./runtime/lib/element-template/internal.d.ts"
|
|
167
|
+
],
|
|
168
|
+
"element-template/jsx-runtime": [
|
|
169
|
+
"./runtime/lib/element-template/jsx-runtime/index.d.ts"
|
|
170
|
+
],
|
|
171
|
+
"element-template/jsx-dev-runtime": [
|
|
172
|
+
"./runtime/lib/element-template/jsx-dev-runtime/index.d.ts"
|
|
173
|
+
],
|
|
146
174
|
"jsx-runtime": [
|
|
147
175
|
"./runtime/jsx-runtime/index.d.ts"
|
|
148
176
|
],
|
|
@@ -192,7 +220,7 @@
|
|
|
192
220
|
"README.zh.md"
|
|
193
221
|
],
|
|
194
222
|
"dependencies": {
|
|
195
|
-
"preact": "npm:@lynx-js/internal-preact@10.29.1-
|
|
223
|
+
"preact": "npm:@lynx-js/internal-preact@10.29.1-20260519060144-e6da44c"
|
|
196
224
|
},
|
|
197
225
|
"devDependencies": {
|
|
198
226
|
"@lynx-js/types": "3.7.0",
|
package/runtime/lazy/compat.js
CHANGED
package/runtime/lazy/react.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface GlobalCommitContext<Ops = unknown[]> {
|
|
2
|
+
ops: Ops;
|
|
3
|
+
flushOptions: FlushOptions;
|
|
4
|
+
flowIds?: number[];
|
|
5
|
+
}
|
|
6
|
+
export declare const globalCommitContext: GlobalCommitContext;
|
|
7
|
+
export declare function resetGlobalCommitContext(): void;
|
|
8
|
+
export declare function takeGlobalFlushOptions(): FlushOptions;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export const globalCommitContext = {
|
|
5
|
+
ops: [],
|
|
6
|
+
flushOptions: {},
|
|
7
|
+
};
|
|
8
|
+
export function resetGlobalCommitContext() {
|
|
9
|
+
globalCommitContext.ops = [];
|
|
10
|
+
globalCommitContext.flushOptions = {};
|
|
11
|
+
delete globalCommitContext.flowIds;
|
|
12
|
+
}
|
|
13
|
+
export function takeGlobalFlushOptions() {
|
|
14
|
+
const flushOptions = globalCommitContext.flushOptions;
|
|
15
|
+
globalCommitContext.flushOptions = {};
|
|
16
|
+
return flushOptions;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=commit-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-context.js","sourceRoot":"","sources":["../../src/core/commit-context.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAQ1D,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACtD,GAAG,EAAE,EAAE;IACP,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,CAAC,GAAG,GAAG,EAAE,CAAC;IAC7B,mBAAmB,CAAC,YAAY,GAAG,EAAE,CAAC;IACtC,OAAO,mBAAmB,CAAC,OAAO,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;IACtD,mBAAmB,CAAC,YAAY,GAAG,EAAE,CAAC;IACtC,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VNode } from 'preact';
|
|
2
|
+
export interface ForceRootRenderOptions {
|
|
3
|
+
getRootVNode: () => unknown;
|
|
4
|
+
setRootVNode: (vnode: VNode) => void;
|
|
5
|
+
render: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function runWithForceRootRender({ getRootVNode, setRootVNode, render }: ForceRootRenderOptions): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { options as preactOptions } from 'preact';
|
|
5
|
+
import { COMPONENT, DIFF2, FORCE, ORIGINAL } from '../shared/render-constants.js';
|
|
6
|
+
export function runWithForceRootRender({ getRootVNode, setRootVNode, render }) {
|
|
7
|
+
// Preact can skip root render if `_original` is unchanged; bumping it keeps
|
|
8
|
+
// backend force renders aligned with Preact's own rerender path.
|
|
9
|
+
const rootVNode = getRootVNode();
|
|
10
|
+
if (rootVNode) {
|
|
11
|
+
const newVNode = Object.assign({}, rootVNode);
|
|
12
|
+
if (newVNode[ORIGINAL] != null) {
|
|
13
|
+
newVNode[ORIGINAL] += 1;
|
|
14
|
+
setRootVNode(newVNode);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const oldDiff = preactOptions[DIFF2];
|
|
18
|
+
preactOptions[DIFF2] = (vnode, oldVNode) => {
|
|
19
|
+
/* v8 ignore start */
|
|
20
|
+
if (oldDiff) {
|
|
21
|
+
oldDiff(vnode, oldVNode);
|
|
22
|
+
}
|
|
23
|
+
/* v8 ignore stop */
|
|
24
|
+
const c = oldVNode[COMPONENT];
|
|
25
|
+
if (c) {
|
|
26
|
+
c[FORCE] = true;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// mount phase of a new Component
|
|
30
|
+
// `isNew` is true, no need to set FORCE
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
render();
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
preactOptions[DIFF2] = oldDiff;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=forceRootRender.js.map
|
|
@@ -0,0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AAC;YAAS,CAAC;QACT,aAAa,CAAC,KAAK,CAAC,GAAG,OAAkD,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Consumer, Provider } from 'preact';
|
|
2
|
+
import type { useLynxGlobalEventListener } from './hooks/useLynxGlobalEventListener.js';
|
|
3
|
+
type Getter<T> = {
|
|
4
|
+
[key in keyof T]: () => T[key];
|
|
5
|
+
};
|
|
6
|
+
interface GlobalPropsRuntimeDeps {
|
|
7
|
+
createContext: typeof import('preact').createContext;
|
|
8
|
+
useState: typeof import('preact/hooks').useState;
|
|
9
|
+
createElement: typeof import('preact/compat').createElement;
|
|
10
|
+
useLynxGlobalEventListener: typeof useLynxGlobalEventListener;
|
|
11
|
+
}
|
|
12
|
+
interface GlobalPropsApi<Data> {
|
|
13
|
+
Provider: Provider<Data>;
|
|
14
|
+
Consumer: Consumer<Data>;
|
|
15
|
+
use: () => Data;
|
|
16
|
+
useChanged: (callback: (data: Data) => void) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The interface you can extends so that the `useGlobalProps` returning value can be customized
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface GlobalProps {
|
|
24
|
+
}
|
|
25
|
+
export interface UpdateGlobalPropsOptions {
|
|
26
|
+
forceRerender?: (() => void) | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare function isGlobalPropsEventMode(): boolean;
|
|
29
|
+
export declare function createGlobalProps<Data = GlobalProps>(deps: GlobalPropsRuntimeDeps): Getter<GlobalPropsApi<Data>>;
|
|
30
|
+
export declare function updateGlobalProps(newData: Record<string, any>, { forceRerender }?: UpdateGlobalPropsOptions): void;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { factory } from './initData.js';
|
|
2
|
+
export function isGlobalPropsEventMode() {
|
|
3
|
+
return typeof __GLOBAL_PROPS_MODE__ !== 'undefined' && __GLOBAL_PROPS_MODE__ === 'event';
|
|
4
|
+
}
|
|
5
|
+
export function createGlobalProps(deps) {
|
|
6
|
+
return isGlobalPropsEventMode()
|
|
7
|
+
? /* @__PURE__ */ factory(deps, '__globalProps', 'onGlobalPropsChanged')
|
|
8
|
+
: /* @__PURE__ */ createFallbackGlobalProps(deps.useLynxGlobalEventListener);
|
|
9
|
+
}
|
|
10
|
+
export function updateGlobalProps(newData, { forceRerender } = {}) {
|
|
11
|
+
if (isGlobalPropsEventMode()) {
|
|
12
|
+
// COW keeps Provider / Consumer state readers aligned in event mode.
|
|
13
|
+
lynx.__globalProps = Object.assign({}, lynx.__globalProps, newData);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
Object.assign(lynx.__globalProps, newData);
|
|
17
|
+
if (forceRerender) {
|
|
18
|
+
void Promise.resolve().then(forceRerender);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
lynxCoreInject.tt.GlobalEventEmitter.emit('onGlobalPropsChanged', [lynx.__globalProps]);
|
|
22
|
+
}
|
|
23
|
+
function warnGlobalPropsMode() {
|
|
24
|
+
if (typeof __LEPUS__ !== 'undefined' && !__LEPUS__ && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
25
|
+
console.warn(`No need to use this API when 'globalPropsMode' is not 'event', `
|
|
26
|
+
+ `updates will be triggered automatically by full re-render. `
|
|
27
|
+
+ `Please set 'globalPropsMode' to 'event' to enable optimized updates.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function FallbackProvider({ children }) {
|
|
31
|
+
warnGlobalPropsMode();
|
|
32
|
+
return children;
|
|
33
|
+
}
|
|
34
|
+
function FallbackConsumer({ children }) {
|
|
35
|
+
warnGlobalPropsMode();
|
|
36
|
+
return children(lynx.__globalProps);
|
|
37
|
+
}
|
|
38
|
+
function useFallbackGlobalProps() {
|
|
39
|
+
warnGlobalPropsMode();
|
|
40
|
+
return lynx.__globalProps;
|
|
41
|
+
}
|
|
42
|
+
function createFallbackGlobalProps(useListener) {
|
|
43
|
+
const useChanged = (callback) => {
|
|
44
|
+
if (typeof __LEPUS__ === 'undefined' || !__LEPUS__) {
|
|
45
|
+
useListener('onGlobalPropsChanged', callback);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
Provider: () => FallbackProvider,
|
|
50
|
+
Consumer: () => FallbackConsumer,
|
|
51
|
+
use: () => useFallbackGlobalProps,
|
|
52
|
+
useChanged: () => useChanged,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=globalProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalProps.js","sourceRoot":"","sources":["../../src/core/globalProps.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA+BxC,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,qBAAqB,KAAK,WAAW,IAAI,qBAAqB,KAAK,OAAO,CAAC;AAC3F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAA4B;IAE5B,OAAO,sBAAsB,EAAE;QAC7B,CAAC,CAAC,eAAe,CAAC,OAAO,CACvB,IAAI,EACJ,eAAe,EACf,sBAAsB,CACvB;QACD,CAAC,CAAC,eAAe,CAAC,yBAAyB,CAAO,IAAI,CAAC,0BAA0B,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,OAA4B,EAC5B,EAAE,aAAa,KAA+B,EAAE;IAEhD,IAAI,sBAAsB,EAAE,EAAE,CAAC;QAC7B,qEAAqE;QACrE,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,aAAa,EAAE,CAAC;Y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CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mainThreadImpl.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { installMainThreadHooks } from './mainThreadImpl.js';
|
|
5
|
+
installMainThreadHooks();
|
|
6
|
+
export * from './mainThreadImpl.js';
|
|
7
|
+
//# sourceMappingURL=mainThread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mainThread.js","sourceRoot":"","sources":["../../../src/core/hooks/mainThread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,sBAAsB,EAAE,CAAC;AAEzB,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ErrorInfo, PreactContext } from 'preact';
|
|
2
2
|
import type { Dispatch, useEffect as useEffectType, useErrorBoundary as useErrorBoundaryType, useImperativeHandle as useImperativeHandleType, useLayoutEffect as useLayoutEffectType } from 'preact/hooks';
|
|
3
|
+
declare function installMainThreadHooks(): void;
|
|
3
4
|
declare function useState<S>(initialState: S | (() => S)): [S, Dispatch<unknown>];
|
|
4
5
|
declare function useReducer<S, A>(_reducer: (prevState: S, action: A) => S, initialState: S | (() => S), init?: (initialState: S) => S): [S, Dispatch<A>];
|
|
5
6
|
declare function useRef<T>(initialValue?: T): {
|
|
@@ -14,4 +15,4 @@ declare function useId(): string;
|
|
|
14
15
|
declare const useEffect: typeof useEffectType;
|
|
15
16
|
declare const useLayoutEffect: typeof useLayoutEffectType;
|
|
16
17
|
declare const useImperativeHandle: typeof useImperativeHandleType;
|
|
17
|
-
export { useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
|
|
18
|
+
export { installMainThreadHooks, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
|
|
@@ -2,48 +2,59 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
/**
|
|
5
|
-
* Implements hooks in main thread.
|
|
5
|
+
* Implements hooks in the main thread.
|
|
6
6
|
* This module is modified from preact/hooks
|
|
7
7
|
*
|
|
8
8
|
* internal-preact/hooks/dist/hooks.mjs
|
|
9
9
|
*/
|
|
10
10
|
import { options } from 'preact';
|
|
11
|
+
import { CHILDREN, COMPONENT, DIFF, DIFFED, HOOK, HOOKS, LIST, MASK, PARENT, PENDING_EFFECTS, RENDER, ROOT, VALUE, VNODE, } from '../../shared/render-constants.js';
|
|
11
12
|
import { noop } from '../../utils.js';
|
|
12
|
-
import { CHILDREN, COMPONENT, DIFF, DIFFED, HOOK, HOOKS, LIST, MASK, PARENT, PENDING_EFFECTS, RENDER, ROOT, VALUE, VNODE, } from '../renderToOpcodes/constants.js';
|
|
13
13
|
let currentIndex;
|
|
14
14
|
let currentComponent;
|
|
15
15
|
let currentHook;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
/* v8 ignore start */
|
|
26
|
-
options[ROOT] = function (vnode, parentDom) {
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
28
|
-
if (vnode && parentDom[CHILDREN] && parentDom[CHILDREN][MASK]) {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
30
|
-
vnode[MASK] = parentDom[CHILDREN][MASK];
|
|
16
|
+
let hooksInstalled = false;
|
|
17
|
+
let oldBeforeDiff;
|
|
18
|
+
let oldBeforeRender;
|
|
19
|
+
let oldAfterDiff;
|
|
20
|
+
let oldRoot;
|
|
21
|
+
function installMainThreadHooks() {
|
|
22
|
+
if (hooksInstalled) {
|
|
23
|
+
return;
|
|
31
24
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
options[
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
hooksInstalled = true;
|
|
26
|
+
oldBeforeDiff = options[DIFF];
|
|
27
|
+
oldBeforeRender = options[RENDER];
|
|
28
|
+
oldAfterDiff = options[DIFFED];
|
|
29
|
+
oldRoot = options[ROOT];
|
|
30
|
+
options[DIFF] = function (vnode) {
|
|
31
|
+
currentComponent = null;
|
|
32
|
+
if (oldBeforeDiff)
|
|
33
|
+
oldBeforeDiff(vnode);
|
|
34
|
+
};
|
|
35
|
+
/* v8 ignore start */
|
|
36
|
+
options[ROOT] = function (vnode, parentDom) {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
38
|
+
if (vnode && parentDom[CHILDREN] && parentDom[CHILDREN][MASK]) {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
40
|
+
vnode[MASK] = parentDom[CHILDREN][MASK];
|
|
41
|
+
}
|
|
42
|
+
if (oldRoot)
|
|
43
|
+
oldRoot(vnode, parentDom);
|
|
44
|
+
};
|
|
45
|
+
/* v8 ignore stop */
|
|
46
|
+
options[RENDER] = function (vnode) {
|
|
47
|
+
if (oldBeforeRender)
|
|
48
|
+
oldBeforeRender(vnode);
|
|
49
|
+
currentComponent = vnode[COMPONENT];
|
|
50
|
+
currentIndex = 0;
|
|
51
|
+
};
|
|
52
|
+
options[DIFFED] = function (vnode) {
|
|
53
|
+
if (oldAfterDiff)
|
|
54
|
+
oldAfterDiff(vnode);
|
|
55
|
+
currentComponent = null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
47
58
|
function getHookState(index, type) {
|
|
48
59
|
if (options[HOOK]) {
|
|
49
60
|
options[HOOK](currentComponent, index, currentHook || type);
|
|
@@ -148,5 +159,5 @@ function useId() {
|
|
|
148
159
|
const useEffect = noop;
|
|
149
160
|
const useLayoutEffect = noop;
|
|
150
161
|
const useImperativeHandle = noop;
|
|
151
|
-
export { useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
|
|
152
|
-
//# sourceMappingURL=
|
|
162
|
+
export { installMainThreadHooks, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, };
|
|
163
|
+
//# sourceMappingURL=mainThreadImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mainThreadImpl.js","sourceRoot":"","sources":["../../../src/core/hooks/mainThreadImpl.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAUjC,OAAO,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,eAAe,EACf,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,GACN,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,IAAI,YAAoB,CAAC;AACzB,IAAI,gBAA8C,CAAC;AACnD,IAAI,WAAmB,CAAC;AACxB,IAAI,cAAc,GAAG,KAAK,CAAC;AAC3B,IAAI,aAAiD,CAAC;AACtD,IAAI,eAAmD,CAAC;AACxD,IAAI,YAAgD,C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,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAW,CAAC;AAChC,CAAC;AAED,mBAAmB;AACnB,MAAM,SAAS,GAAG,IAA4B,CAAC;AAC/C,MAAM,eAAe,GAAG,IAAkC,CAAC;AAC3D,MAAM,mBAAmB,GAAG,IAAsC,CAAC;AAEnE,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,GACT,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { useCallback, useContext, useDebugValue, useErrorBoundary, useId, useImperativeHandle, useMemo, useEffect as usePreactEffect, useState as usePreactState, useReducer, useRef, } from 'preact/hooks';
|
|
5
|
-
import { isProfiling, profileEnd, profileFlowId, profileStart } from '
|
|
5
|
+
import { isProfiling, profileEnd, profileFlowId, profileStart } from '../../shared/profile.js';
|
|
6
6
|
// Cache profiled wrappers by the original preact setter to preserve stable
|
|
7
7
|
// identity without introducing extra hooks in component render flow.
|
|
8
8
|
const stateSetterTraceCache = /* @__PURE__ */ isProfiling
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/core/hooks/react.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,mBAAmB,EACnB,OAAO,EACP,SAAS,IAAI,eAAe,EAC5B,QAAQ,IAAI,cAAc,EAC1B,UAAU,EACV,MAAM,GACP,MAAM,cAAc,CAAC;AAMtB,OAAO,E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CAAC;QACd,YAAY,CAAC,oCAAoC,EAAE,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC;YACH,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;gBAAS,CAAC;YACT,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,CAA0C,CAAC;IAC5C,qBAAqB,EAAE,GAAG,CAAC,eAAe,EAAE,cAA4C,CAAC,CAAC;IAE1F,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,QAAQ,GAA0B,CAAC,cAAc,IAAI,WAAW,CAAC;IACrE,CAAC,CAAC,mBAA4C;IAC9C,CAAC,CAAC,cAAc,CAAC;AAEnB;;;;;;;;GAQG;AACH,MAAM,SAAS,GAA4D,CAAC,cAAc,IAAI,WAAW,CAAC;IACxG,CAAC,CAAC,iBAAiB;IACnB,CAAC,CAAC,eAAe,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,MAAM,eAAe,GAA4D,CAAC,cAAc,IAAI,WAAW,CAAC;IAC9G,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,eAAe,CAAC;AAEpB,OAAO;AACL,SAAS;AACT,QAAQ,EACR,UAAU,EACV,MAAM,EACN,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,GACN,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { useEffect, useMemo, useRef } from '
|
|
4
|
+
import { useEffect, useMemo, useRef } from '@lynx-js/react/hooks';
|
|
5
5
|
/**
|
|
6
|
-
* `useLynxGlobalEventListener`
|
|
6
|
+
* `useLynxGlobalEventListener` helps you `addListener` as early as possible.
|
|
7
7
|
*
|
|
8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CAAC;AACT,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Consumer, Context, Provider } from 'preact';
|
|
2
2
|
import type { ComponentClass } from 'react';
|
|
3
|
-
import { useLynxGlobalEventListener } from '
|
|
3
|
+
import type { useLynxGlobalEventListener } from './hooks/useLynxGlobalEventListener.js';
|
|
4
4
|
type Getter<T> = {
|
|
5
5
|
[key in keyof T]: () => T[key];
|
|
6
6
|
};
|
|
7
7
|
export declare function factory<Data>({ createContext, useState, createElement, useLynxGlobalEventListener: useListener }: {
|
|
8
8
|
createContext: typeof import('preact').createContext;
|
|
9
9
|
useState: typeof import('preact/hooks').useState;
|
|
10
|
-
createElement: typeof import('preact').createElement;
|
|
10
|
+
createElement: typeof import('preact/compat').createElement;
|
|
11
11
|
useLynxGlobalEventListener: typeof useLynxGlobalEventListener;
|
|
12
12
|
}, prop: '__globalProps' | '__initData', eventName: string): Getter<{
|
|
13
13
|
Context: Context<Data>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { globalFlushOptions } from '../lifecycle/patch/commit.js';
|
|
1
|
+
import { globalCommitContext } from './commit-context.js';
|
|
3
2
|
// for better reuse if runtime is changed
|
|
4
3
|
export function factory({ createContext, useState, createElement, useLynxGlobalEventListener: useListener }, prop, eventName) {
|
|
5
4
|
const Context = createContext({});
|
|
@@ -7,7 +6,7 @@ export function factory({ createContext, useState, createElement, useLynxGlobalE
|
|
|
7
6
|
const [__, set] = useState(lynx[prop]);
|
|
8
7
|
const handleChange = () => {
|
|
9
8
|
if (prop === '__initData') {
|
|
10
|
-
|
|
9
|
+
globalCommitContext.flushOptions.triggerDataUpdated = true;
|
|
11
10
|
}
|
|
12
11
|
set(lynx[prop]);
|
|
13
12
|
};
|
|
@@ -21,7 +20,7 @@ export function factory({ createContext, useState, createElement, useLynxGlobalE
|
|
|
21
20
|
const [__, set] = useState(lynx[prop]);
|
|
22
21
|
useChanged(() => {
|
|
23
22
|
if (prop === '__initData') {
|
|
24
|
-
|
|
23
|
+
globalCommitContext.flushOptions.triggerDataUpdated = true;
|
|
25
24
|
}
|
|
26
25
|
set(lynx[prop]);
|
|
27
26
|
});
|
|
@@ -84,7 +83,7 @@ export function withInitDataInState(App) {
|
|
|
84
83
|
if (!__LEPUS__) {
|
|
85
84
|
lynx.getJSModule('GlobalEventEmitter').addListener('onDataChanged', this.h = (...args) => {
|
|
86
85
|
const [newData] = args;
|
|
87
|
-
|
|
86
|
+
globalCommitContext.flushOptions.triggerDataUpdated = true;
|
|
88
87
|
this.setState(newData);
|
|
89
88
|
});
|
|
90
89
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initData.js","sourceRoot":"","sources":["../../src/core/initData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAO1D,yCAAyC;AACzC,MAAM,UAAU,OAAO,CACrB,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,0BAA0B,EAAE,WAAW,EAKhF,EACD,IAAoC,EACpC,SAAiB;IAQjB,MAAM,OAAO,GAAG,aAAa,CAAC,EAAU,CAAC,CAAC;IAE1C,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAoC,EAAE,EAAE;QAClE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAO,IAAI,CAAC,IAAI,CAAS,CAAC,CAAC;QAErD,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1B,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,GAAG,IAAI,CAAC;YAC7D,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAS,CAAC,CAAC;QAC1B,CAAC,CAAC;QAEF,UAAU,CAAC,YAAY,CAAC,CAAC;QAEzB,OAAO,aAAa,CAClB,OAAO,CAAC,QAAQ,EAChB;YACE,KAAK,EAAE,EAAE;SAC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