@lynx-js/react 0.127.0 → 0.129.0
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 +38 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -14
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/entry-re-eval.test.ts +161 -0
- package/runtime/__test__/core/reload-scoped-dual-thread-communication.test.ts +129 -0
- package/runtime/__test__/core/thread-function-call.test.ts +1 -0
- package/runtime/__test__/element-template/fixtures/background/render/_shared.tsx +2 -0
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -1
- package/runtime/__test__/element-template/native/index.test.ts +8 -0
- package/runtime/__test__/element-template/native/main-thread-ref-init-value.test.ts +100 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +101 -0
- package/runtime/__test__/element-template/native/reload.test.ts +50 -1
- package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +104 -47
- package/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +39 -48
- package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +14 -10
- package/runtime/__test__/element-template/runtime/background/re-eval-reload.test.ts +69 -0
- package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +31 -5
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +17 -3
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +8 -3
- package/runtime/__test__/element-template/runtime/template/main-thread-function.test.ts +89 -2
- package/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts +5 -0
- package/runtime/__test__/element-template/test-utils/mock/globals.js +6 -0
- package/runtime/__test__/element-template/vitest.config.ts +4 -0
- package/runtime/__test__/snapshot/lifecycle/re-eval-reload.test.jsx +114 -0
- package/runtime/__test__/snapshot/lifecycle/reload-background-function.test.jsx +169 -0
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-background.test.jsx +63 -0
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-main-thread.test.jsx +103 -0
- package/runtime/__test__/snapshot/lifecycle.test.jsx +61 -1
- package/runtime/__test__/snapshot/lynx/lazy-effect-scheduling.test.jsx +105 -0
- package/runtime/__test__/snapshot/ssr.test.jsx +2 -2
- package/runtime/__test__/snapshot/worklet/runOnBackground.test.js +6 -11
- package/runtime/__test__/snapshot/worklet/runOnMainThread.test.jsx +1 -1
- package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +24 -1
- package/runtime/__test__/worklet-runtime/initEntry.test.js +109 -0
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +15 -1
- package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +46 -0
- package/runtime/__test__/worklet-runtime/object-methods.test.js +2 -3
- package/runtime/__test__/worklet-runtime/runOnMainThread.test.js +3 -3
- package/runtime/lazy/element-template-internal.js +0 -1
- package/runtime/lazy/internal.js +0 -1
- package/runtime/lib/core/background-function/exec-map.d.ts +2 -0
- package/runtime/lib/core/background-function/exec-map.js +7 -0
- package/runtime/lib/core/background-function/exec-map.js.map +1 -1
- package/runtime/lib/core/background-function/handle.js.map +1 -1
- package/runtime/lib/core/background-function/run-on-background.js +15 -16
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
- package/runtime/lib/core/card-lifetime.d.ts +5 -0
- package/runtime/lib/core/card-lifetime.js +17 -0
- package/runtime/lib/core/card-lifetime.js.map +1 -0
- package/runtime/lib/core/commit-context.js.map +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
- package/runtime/lib/core/compat/lynxComponent.js.map +1 -1
- package/runtime/lib/core/component.js.map +1 -1
- package/runtime/lib/core/entry-reload.d.ts +7 -0
- package/runtime/lib/core/entry-reload.js +49 -0
- package/runtime/lib/core/entry-reload.js.map +1 -0
- package/runtime/lib/core/forceRootRender.js.map +1 -1
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/core/hooks/mainThread.js.map +1 -1
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -1
- package/runtime/lib/core/hooks/react.js.map +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -1
- package/runtime/lib/core/initData.js.map +1 -1
- package/runtime/lib/core/lynx/dynamic-import.js.map +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js +4 -1
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/lynx/runtime-backend.js.map +1 -1
- package/runtime/lib/core/lynx/runtime-version.js.map +1 -1
- package/runtime/lib/core/lynx-data-processors.js.map +1 -1
- package/runtime/lib/core/lynx-page-data.js.map +1 -1
- package/runtime/lib/core/lynx-update-data.js.map +1 -1
- package/runtime/lib/core/main-thread-function.js.map +1 -1
- package/runtime/lib/core/main-thread-object-handle-registry.js.map +1 -1
- package/runtime/lib/core/main-thread-object.js +1 -4
- package/runtime/lib/core/main-thread-object.js.map +1 -1
- package/runtime/lib/core/main-thread-ref-id.js +4 -4
- package/runtime/lib/core/main-thread-ref-id.js.map +1 -1
- package/runtime/lib/core/main-thread-ref-init-value.js.map +1 -1
- package/runtime/lib/core/main-thread-ref.js.map +1 -1
- package/runtime/lib/core/mts-capability.js.map +1 -1
- package/runtime/lib/core/performance.js.map +1 -1
- package/runtime/lib/core/ref.js.map +1 -1
- package/runtime/lib/core/reload-scoped-event.d.ts +5 -0
- package/runtime/lib/core/reload-scoped-event.js +26 -0
- package/runtime/lib/core/reload-scoped-event.js.map +1 -0
- package/runtime/lib/core/reload-version.js +4 -3
- package/runtime/lib/core/reload-version.js.map +1 -1
- package/runtime/lib/core/runtime-destroy.d.ts +2 -0
- package/runtime/lib/core/runtime-destroy.js +9 -0
- package/runtime/lib/core/runtime-destroy.js.map +1 -1
- package/runtime/lib/core/thread-function-call/main-thread.js +5 -4
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/core/thread-function-call/return-value.js +6 -5
- package/runtime/lib/core/thread-function-call/return-value.js.map +1 -1
- package/runtime/lib/document.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-context.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +19 -16
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/document.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +2 -6
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/background/manager.js.map +1 -1
- package/runtime/lib/element-template/background/page-root-hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/render-scope.js.map +1 -1
- package/runtime/lib/element-template/client/root.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -1
- package/runtime/lib/element-template/debug/profile.js.map +1 -1
- package/runtime/lib/element-template/hydration-map.js.map +1 -1
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +0 -1
- package/runtime/lib/element-template/internal.js +0 -1
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/jsx-dev-runtime/index.js.map +1 -1
- package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/lynx/performance.js.map +1 -1
- package/runtime/lib/element-template/main-thread-ref-init-value.d.ts +3 -0
- package/runtime/lib/element-template/main-thread-ref-init-value.js +38 -0
- package/runtime/lib/element-template/main-thread-ref-init-value.js.map +1 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +2 -0
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +2 -0
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +1 -4
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.d.ts +1 -1
- package/runtime/lib/element-template/native/reload-background.js +12 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.d.ts +6 -0
- package/runtime/lib/element-template/native/reload-main-thread.js +18 -2
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/event-value.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/event.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +2 -1
- package/runtime/lib/element-template/protocol/lifecycle-constant.js +1 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/page.js.map +1 -1
- package/runtime/lib/element-template/protocol/template-type.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +0 -2
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/protocol/update-event.js.map +1 -1
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/authored-page.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/host.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
- package/runtime/lib/element-template/runtime-marker.js.map +1 -1
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +0 -1
- package/runtime/lib/internal.js +0 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/root.js.map +1 -1
- package/runtime/lib/runtime-marker.js.map +1 -1
- package/runtime/lib/shared/attribute-name.js.map +1 -1
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/shared/index-map.d.ts +4 -1
- package/runtime/lib/shared/index-map.js +5 -2
- package/runtime/lib/shared/index-map.js.map +1 -1
- package/runtime/lib/shared/profile.js.map +1 -1
- package/runtime/lib/shared/render-constants.js.map +1 -1
- package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -1
- package/runtime/lib/snapshot/alog/index.js.map +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/compat/componentIs.js.map +1 -1
- package/runtime/lib/snapshot/debug/debug.js.map +1 -1
- package/runtime/lib/snapshot/debug/describeInvalidValue.js.map +1 -1
- package/runtime/lib/snapshot/debug/formatPatch.js.map +1 -1
- package/runtime/lib/snapshot/debug/printSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
- package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -1
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +1 -1
- package/runtime/lib/snapshot/gesture/types.js.map +1 -1
- package/runtime/lib/snapshot/index.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +6 -0
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/delayEvents.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/delayLifecycleEvents.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.d.ts +6 -2
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js +21 -18
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/globalState.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/isMainThreadHydrating.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.d.ts +9 -2
- package/runtime/lib/snapshot/lifecycle/reload.js +29 -8
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/render.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +3 -2
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/list/pendingListUpdates.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +3 -3
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/lynx/children.js.map +1 -1
- package/runtime/lib/snapshot/lynx/element.js.map +1 -1
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -1
- package/runtime/lib/snapshot/lynx/lazyBundleConstants.js.map +1 -1
- package/runtime/lib/snapshot/lynx/nodesRef.js.map +1 -1
- package/runtime/lib/snapshot/lynx/performance.js.map +1 -1
- package/runtime/lib/snapshot/lynx/portals.js.map +1 -1
- package/runtime/lib/snapshot/lynx/portalsPending.js.map +1 -1
- package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js.map +1 -1
- package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -1
- package/runtime/lib/snapshot/lynx/suspense.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/constants.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/event.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/index.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/list.js +2 -1
- package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.d.ts +4 -2
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js +11 -11
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/types.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +1 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +6 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ctx.d.ts +1 -1
- package/runtime/lib/snapshot/worklet/ctx.js +6 -1
- package/runtime/lib/snapshot/worklet/ctx.js.map +1 -1
- package/runtime/lib/snapshot/worklet/destroy.js.map +1 -1
- package/runtime/lib/snapshot/worklet/functionality.js.map +1 -1
- package/runtime/lib/snapshot/worklet/hmr.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js +6 -0
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/animation/animation.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/animation/effect.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/element.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/lepusQuerySelector.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/lynxApi.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/events.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/index.d.ts +0 -1
- package/runtime/lib/worklet-runtime/bindings/index.js +0 -1
- package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js +3 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +1 -1
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js.map +1 -1
- package/runtime/lib/worklet-runtime/eomImpl.js.map +1 -1
- package/runtime/lib/worklet-runtime/eventPropagation.js.map +1 -1
- package/runtime/lib/worklet-runtime/global.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/index.js +6 -0
- package/runtime/lib/worklet-runtime/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +2 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/listeners.js +2 -2
- package/runtime/lib/worklet-runtime/listeners.js.map +1 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.js +3 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -1
- package/runtime/lib/worklet-runtime/runOnMainThread.js +4 -3
- package/runtime/lib/worklet-runtime/runOnMainThread.js.map +1 -1
- package/runtime/lib/worklet-runtime/utils/mainThreadFlushLoopGuard.js.map +1 -1
- package/runtime/lib/worklet-runtime/utils/profile.js.map +1 -1
- package/runtime/lib/worklet-runtime/utils/version.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/src/core/background-function/exec-map.ts +9 -0
- package/runtime/src/core/background-function/run-on-background.ts +14 -16
- package/runtime/src/core/card-lifetime.ts +18 -0
- package/runtime/src/core/entry-reload.ts +63 -0
- package/runtime/src/core/lynx/lazy-bundle.ts +4 -1
- package/runtime/src/core/main-thread-object.ts +1 -8
- package/runtime/src/core/main-thread-ref-id.ts +5 -4
- package/runtime/src/core/reload-scoped-event.ts +35 -0
- package/runtime/src/core/reload-version.ts +5 -3
- package/runtime/src/core/runtime-destroy.ts +11 -0
- package/runtime/src/core/thread-function-call/main-thread.ts +4 -4
- package/runtime/src/core/thread-function-call/return-value.ts +6 -5
- package/runtime/src/element-template/background/commit-hook.ts +20 -17
- package/runtime/src/element-template/background/hydration-listener.ts +2 -6
- package/runtime/src/element-template/internal.ts +0 -1
- package/runtime/src/element-template/main-thread-ref-init-value.ts +44 -0
- package/runtime/src/element-template/native/index.ts +2 -0
- package/runtime/src/element-template/native/mts-destroy.ts +3 -0
- package/runtime/src/element-template/native/patch-listener.ts +0 -5
- package/runtime/src/element-template/native/reload-background.ts +13 -1
- package/runtime/src/element-template/native/reload-main-thread.ts +30 -2
- package/runtime/src/element-template/protocol/lifecycle-constant.ts +1 -0
- package/runtime/src/element-template/protocol/types.ts +0 -2
- package/runtime/src/internal.ts +0 -1
- package/runtime/src/shared/index-map.ts +3 -2
- package/runtime/src/snapshot/lifecycle/destroy.ts +7 -0
- package/runtime/src/snapshot/lifecycle/event/firstScreenSync.ts +26 -19
- package/runtime/src/snapshot/lifecycle/reload.ts +47 -11
- package/runtime/src/snapshot/list/list.ts +9 -2
- package/runtime/src/snapshot/lynx/calledByNative.ts +3 -4
- package/runtime/src/snapshot/snapshot/list.ts +5 -1
- package/runtime/src/snapshot/snapshot/snapshotInstanceManager.ts +19 -12
- package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +10 -1
- package/runtime/src/snapshot/worklet/ctx.ts +10 -1
- package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +6 -0
- package/runtime/src/worklet-runtime/README.md +13 -0
- package/runtime/src/worklet-runtime/bindings/index.ts +0 -1
- package/runtime/src/worklet-runtime/delayRunOnBackground.ts +3 -1
- package/runtime/src/worklet-runtime/index.ts +7 -0
- package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +2 -1
- package/runtime/src/worklet-runtime/listeners.ts +4 -7
- package/runtime/src/worklet-runtime/mainThreadObject.ts +2 -1
- package/runtime/src/worklet-runtime/runOnMainThread.ts +4 -3
- package/runtime/tsconfig.json +2 -0
- package/runtime/types/types.d.ts +3 -1
- package/runtime/vitest.config.ts +4 -0
- package/testing-library/.turbo/turbo-build.log +12 -12
- package/testing-library/dist/env/index.js +3 -15
- package/testing-library/dist/plugins/index.js +10 -0
- package/testing-library/dist/rstest-config.js +15 -0
- package/testing-library/dist/setupFiles/common/worklet-runtime-init.js +11 -0
- package/testing-library/rstest.config.ts +3 -0
- package/testing-library/src/__tests__/rstest-config.test.js +34 -1
- package/testing-library/src/__tests__/worklet.test.jsx +51 -37
- package/testing-library/src/plugins/vitest.ts +5 -1
- package/testing-library/src/rstest-config.ts +17 -1
- package/testing-library/src/setupFiles/common/worklet-runtime-init.js +22 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +345 -150
- package/transform/__test__/defines.spec.js +187 -12
- package/transform/__test__/fixture.spec.js +166 -48
- package/transform/__test__/object-methods.spec.js +1 -3
- package/transform/crates/swc_plugin_worklet/definition_imports.rs +97 -0
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +26 -10
- package/transform/crates/swc_plugin_worklet/lib.rs +138 -153
- package/transform/crates/swc_plugin_worklet/napi.rs +10 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +4 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_lepus.js +3 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_ident_from_this_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +4 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_3_lepus.js +3 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_4_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +4 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_computed_object_method_key_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_globals.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_object_method_local_decls_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_type_annotations.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_destructure_from_closure.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_catch_clause_params.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_idents_inside_of_ctx.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_recursively.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +6 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_arrow_function.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_fn_decl_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_function_expr.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_property_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_fn_in_run_on_js_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +4 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_alias.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general_mixed.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets.js +3 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets_in_func.js +3 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_ui_worklet_lepus.js +2 -4
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +27 -1
- package/transform/src/lib.rs +354 -23
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +53 -52
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +63 -293
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +0 -8
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +0 -23
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +0 -1
- package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +0 -25
- package/runtime/worklet-runtime/dev.js +0 -775
- package/runtime/worklet-runtime/main.js +0 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_inner_ident.js +0 -13
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_outer_ident.js +0 -13
|
@@ -4,12 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
import { IndexMap } from '../../shared/index-map.js';
|
|
6
6
|
import type { JsFnHandle, Worklet } from '../../worklet-runtime/bindings/types.js';
|
|
7
|
+
import { cardLifetime } from '../card-lifetime.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Keeps the background-thread worklet ctx alive while main thread still holds
|
|
10
11
|
* a handle to one of its background functions.
|
|
11
12
|
*/
|
|
12
13
|
export class BackgroundFunctionExecMap extends IndexMap<Worklet> {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(cardLifetime('backgroundFunctionCtxId', () => ({ lastIndex: 0 })));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public clear(): void {
|
|
19
|
+
this.indexMap.clear();
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
public override add(worklet: Worklet): number {
|
|
14
23
|
const execId = super.add(worklet);
|
|
15
24
|
worklet._execId = execId;
|
|
@@ -8,7 +8,8 @@ import { delayRunOnBackground } from '../../worklet-runtime/bindings/bindings.js
|
|
|
8
8
|
import { WorkletEvents } from '../../worklet-runtime/bindings/events.js';
|
|
9
9
|
import type { RunWorkletCtxRetData } from '../../worklet-runtime/bindings/events.js';
|
|
10
10
|
import type { ClosureValueType, JsFnHandle, Worklet } from '../../worklet-runtime/bindings/types.js';
|
|
11
|
-
import {
|
|
11
|
+
import { addReloadScopedEventListener, dispatchReloadScopedEvent } from '../reload-scoped-event.js';
|
|
12
|
+
import { isRuntimeDestroyed, registerDestroyTask } from '../runtime-destroy.js';
|
|
12
13
|
import { onFunctionCall } from '../thread-function-call/return-value.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -26,19 +27,19 @@ let unregisterBackgroundFunctionCleanup: (() => void) | undefined;
|
|
|
26
27
|
|
|
27
28
|
function initBackgroundFunctionRuntime(): void {
|
|
28
29
|
'background only';
|
|
29
|
-
if (
|
|
30
|
+
if (cleanupBackgroundFunctionRuntime) {
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
execIdMap
|
|
34
|
+
execIdMap ??= new BackgroundFunctionExecMap();
|
|
34
35
|
const context = lynx.getCoreContext();
|
|
35
|
-
context
|
|
36
|
+
const removeListener = addReloadScopedEventListener(context, WorkletEvents.runOnBackground, runBackgroundFunction);
|
|
36
37
|
context.addEventListener(WorkletEvents.releaseBackgroundWorkletCtx, releaseBackgroundFunctionCtx);
|
|
37
38
|
|
|
38
39
|
cleanupBackgroundFunctionRuntime = () => {
|
|
39
|
-
|
|
40
|
+
removeListener();
|
|
40
41
|
context.removeEventListener(WorkletEvents.releaseBackgroundWorkletCtx, releaseBackgroundFunctionCtx);
|
|
41
|
-
execIdMap
|
|
42
|
+
execIdMap!.clear();
|
|
42
43
|
cleanupBackgroundFunctionRuntime = undefined;
|
|
43
44
|
};
|
|
44
45
|
}
|
|
@@ -46,21 +47,17 @@ function initBackgroundFunctionRuntime(): void {
|
|
|
46
47
|
/**
|
|
47
48
|
* @internal
|
|
48
49
|
*/
|
|
49
|
-
export function runBackgroundFunction(
|
|
50
|
+
export function runBackgroundFunction(data: RunOnBackgroundData): void {
|
|
50
51
|
'background only';
|
|
51
|
-
const data = JSON.parse(event.data as string) as RunOnBackgroundData;
|
|
52
52
|
const obj = execIdMap!.findJsFnHandle(data.obj._execId!, data.obj._jsFnId!);
|
|
53
53
|
const f = obj?._fn;
|
|
54
54
|
if (!f) {
|
|
55
55
|
throw new Error('runOnBackground: JS function not found: ' + JSON.stringify(data.obj));
|
|
56
56
|
}
|
|
57
57
|
const returnValue = f(...data.params);
|
|
58
|
-
lynx.getCoreContext()
|
|
58
|
+
dispatchReloadScopedEvent(lynx.getCoreContext(), {
|
|
59
59
|
type: WorkletEvents.FunctionCallRet,
|
|
60
|
-
data:
|
|
61
|
-
resolveId: data.resolveId,
|
|
62
|
-
returnValue,
|
|
63
|
-
} as RunWorkletCtxRetData),
|
|
60
|
+
data: { resolveId: data.resolveId, returnValue } satisfies RunWorkletCtxRetData,
|
|
64
61
|
});
|
|
65
62
|
}
|
|
66
63
|
|
|
@@ -133,6 +130,7 @@ export function runOnBackground<R, Fn extends (...args: any[]) => R>(
|
|
|
133
130
|
}
|
|
134
131
|
return async (...params: ClosureValueType[]): Promise<R> => {
|
|
135
132
|
return new Promise((resolve) => {
|
|
133
|
+
if (isRuntimeDestroyed()) return;
|
|
136
134
|
const resolveId = onFunctionCall(resolve);
|
|
137
135
|
|
|
138
136
|
if (obj._isFirstScreen) {
|
|
@@ -153,15 +151,15 @@ function dispatchRunBackgroundFunctionEvent(
|
|
|
153
151
|
execId: number,
|
|
154
152
|
resolveId: number,
|
|
155
153
|
): void {
|
|
156
|
-
lynx.getJSContext()
|
|
154
|
+
dispatchReloadScopedEvent(lynx.getJSContext(), {
|
|
157
155
|
type: WorkletEvents.runOnBackground,
|
|
158
|
-
data:
|
|
156
|
+
data: {
|
|
159
157
|
obj: {
|
|
160
158
|
_jsFnId: fnId,
|
|
161
159
|
_execId: execId,
|
|
162
160
|
},
|
|
163
161
|
params,
|
|
164
162
|
resolveId,
|
|
165
|
-
} as RunOnBackgroundData
|
|
163
|
+
} as RunOnBackgroundData,
|
|
166
164
|
});
|
|
167
165
|
}
|
|
@@ -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
|
+
|
|
5
|
+
const storeKey = Symbol.for('__REACT_LYNX_CARD_LIFETIME__');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Module-level state that survives an entry re-evaluation, for state tied to
|
|
9
|
+
* native objects that outlive the entry or IDs that late messages may carry.
|
|
10
|
+
*/
|
|
11
|
+
export function cardLifetime<T extends object>(key: string, init: () => T): T {
|
|
12
|
+
if (typeof __EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__ === 'undefined' || !__EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__) {
|
|
13
|
+
return init();
|
|
14
|
+
}
|
|
15
|
+
const host = lynx as unknown as Record<symbol, Record<string, object> | undefined>;
|
|
16
|
+
const store = host[storeKey] ??= {};
|
|
17
|
+
return (store[key] ??= init()) as T;
|
|
18
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
|
|
5
|
+
import { increaseReloadVersion } from './reload-version.js';
|
|
6
|
+
import { destroyRuntime } from './runtime-destroy.js';
|
|
7
|
+
|
|
8
|
+
const supportsReEvalKey = Symbol.for('__LYNX_ENTRY_SUPPORTS_RE_EVAL__');
|
|
9
|
+
const reloaderKey = Symbol.for('__LYNX_MAIN_THREAD_ENTRY_RELOADER__');
|
|
10
|
+
const completerKey = Symbol.for('__LYNX_MAIN_THREAD_RELOAD_COMPLETER__');
|
|
11
|
+
const externalGlobalKey = Symbol.for('__LYNX_EXTERNAL_GLOBAL__');
|
|
12
|
+
|
|
13
|
+
const host = () => lynx as unknown as Record<symbol, unknown>;
|
|
14
|
+
|
|
15
|
+
function isEntryReEvalEnabled(): boolean {
|
|
16
|
+
return typeof __EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__ !== 'undefined'
|
|
17
|
+
&& __EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__
|
|
18
|
+
&& host()[supportsReEvalKey] === true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function canReEvalMainThreadEntry(): boolean {
|
|
22
|
+
return isEntryReEvalEnabled() && typeof host()[reloaderKey] === 'function';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function canReEvalBackgroundEntry(): boolean {
|
|
26
|
+
return isEntryReEvalEnabled() && typeof lynx.getApp().reloadCard === 'function';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Lets the entry being evaluated finish a reload started by the previous one. */
|
|
30
|
+
export function installMainThreadReloadCompleter<Handoff>(complete: (handoff: Handoff) => void): void {
|
|
31
|
+
if (
|
|
32
|
+
typeof __MAIN_THREAD__ !== 'undefined' && __MAIN_THREAD__
|
|
33
|
+
&& typeof __EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__ !== 'undefined' && __EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__
|
|
34
|
+
) {
|
|
35
|
+
host()[completerKey] = complete;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function reEvalMainThreadEntry<Handoff>(handoff: Handoff): void {
|
|
40
|
+
// Evaluating the entry resets `__initData`.
|
|
41
|
+
const initData = lynx.__initData;
|
|
42
|
+
destroyRuntime();
|
|
43
|
+
Reflect.deleteProperty(lynx, externalGlobalKey);
|
|
44
|
+
(host()[reloaderKey] as () => void)();
|
|
45
|
+
lynx.__initData = initData;
|
|
46
|
+
(host()[completerKey] as (handoff: Handoff) => void)(handoff);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @param retire - stops this entry from sending work to the main thread */
|
|
50
|
+
export function reEvalBackgroundEntry(
|
|
51
|
+
updateData: Record<string, unknown>,
|
|
52
|
+
options: Record<string, unknown> | undefined,
|
|
53
|
+
retire: () => void,
|
|
54
|
+
): void {
|
|
55
|
+
const data = Object.assign({}, lynx.__initData, updateData);
|
|
56
|
+
destroyRuntime();
|
|
57
|
+
increaseReloadVersion();
|
|
58
|
+
retire();
|
|
59
|
+
const app = lynx.getApp();
|
|
60
|
+
app.callDestroyLifetimeFun();
|
|
61
|
+
Reflect.deleteProperty(lynx, externalGlobalKey);
|
|
62
|
+
app.reloadCard!(data, options);
|
|
63
|
+
}
|
|
@@ -62,7 +62,10 @@ export const makeSyncThen = function<T>(result: T): Promise<T>['then'] {
|
|
|
62
62
|
// );
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
// The Lynx Promise polyfill shares resolved promises for primitive values.
|
|
66
|
+
// Own this promise before replacing `then`, or an undefined callback
|
|
67
|
+
// result would make unrelated Promise.resolve().then(...) calls synchronous.
|
|
68
|
+
const p = new Promise<TR1>(resolve => resolve(ret));
|
|
66
69
|
|
|
67
70
|
const then = makeSyncThen(ret as TR1);
|
|
68
71
|
p.then = then as Promise<Awaited<TR1>>['then'];
|
|
@@ -2,11 +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
|
|
|
5
|
-
import {
|
|
6
|
-
WorkletEvents,
|
|
7
|
-
loadWorkletRuntime,
|
|
8
|
-
registerMainThreadObjectType,
|
|
9
|
-
} from '@lynx-js/react/worklet-runtime/bindings';
|
|
5
|
+
import { WorkletEvents, registerMainThreadObjectType } from '@lynx-js/react/worklet-runtime/bindings';
|
|
10
6
|
import type { Worklet, WorkletRefImpl } from '@lynx-js/react/worklet-runtime/bindings';
|
|
11
7
|
|
|
12
8
|
import { useMemo } from './hooks/react.js';
|
|
@@ -228,9 +224,6 @@ function registerMainThreadObjectDefinition<I, O extends object>(
|
|
|
228
224
|
return;
|
|
229
225
|
}
|
|
230
226
|
|
|
231
|
-
const schema = (globalThis as { globDynamicComponentEntry?: string })
|
|
232
|
-
.globDynamicComponentEntry;
|
|
233
|
-
loadWorkletRuntime(schema);
|
|
234
227
|
registerMainThreadObjectType(
|
|
235
228
|
definition.type,
|
|
236
229
|
definition.create as ((initialValue: unknown) => object) | Worklet,
|
|
@@ -2,15 +2,16 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
import { cardLifetime } from './card-lifetime.js';
|
|
6
|
+
|
|
7
|
+
const lastId = /*#__PURE__*/ cardLifetime('mainThreadRefId', () => ({ bg: 0, mt: 0 }));
|
|
7
8
|
|
|
8
9
|
/** @internal */
|
|
9
10
|
export function allocateMainThreadRefId(): number {
|
|
10
|
-
return __JS__ ? ++
|
|
11
|
+
return __JS__ ? ++lastId.bg : --lastId.mt;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/** @internal */
|
|
14
15
|
export function clearMainThreadRefIdsForTesting(): void {
|
|
15
|
-
|
|
16
|
+
lastId.bg = lastId.mt = 0;
|
|
16
17
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
|
|
5
|
+
import { getReloadVersion } from './reload-version.js';
|
|
6
|
+
|
|
7
|
+
interface ReloadScope {
|
|
8
|
+
reloadVersion?: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function dispatchReloadScopedEvent(context: RuntimeProxy, event: { type: string; data: object }): void {
|
|
12
|
+
context.dispatchEvent({
|
|
13
|
+
type: event.type,
|
|
14
|
+
data: JSON.stringify({ ...event.data, reloadVersion: getReloadVersion() }),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Deliver parsed payloads only while their page is current. Return cleanup for
|
|
19
|
+
// the actual registered wrapper, so callers need no listener identity registry.
|
|
20
|
+
export function addReloadScopedEventListener<T>(
|
|
21
|
+
context: RuntimeProxy,
|
|
22
|
+
type: string,
|
|
23
|
+
listener: (data: T) => void,
|
|
24
|
+
): () => void {
|
|
25
|
+
const handle = (event: RuntimeProxy.Event): void => {
|
|
26
|
+
const data = JSON.parse(event.data as string) as T & ReloadScope;
|
|
27
|
+
// Unversioned events belong to the initial page only.
|
|
28
|
+
if ((data.reloadVersion ?? 0) !== getReloadVersion()) return;
|
|
29
|
+
listener(data);
|
|
30
|
+
};
|
|
31
|
+
context.addEventListener(type, handle);
|
|
32
|
+
return () => {
|
|
33
|
+
context.removeEventListener(type, handle);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -2,12 +2,14 @@
|
|
|
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
|
-
|
|
5
|
+
import { cardLifetime } from './card-lifetime.js';
|
|
6
|
+
|
|
7
|
+
const state = /*#__PURE__*/ cardLifetime('reloadVersion', () => ({ value: 0 }));
|
|
6
8
|
|
|
7
9
|
export function getReloadVersion(): number {
|
|
8
|
-
return
|
|
10
|
+
return state.value;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export function increaseReloadVersion(): number {
|
|
12
|
-
return ++
|
|
14
|
+
return ++state.value;
|
|
13
15
|
}
|
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
type DestroyTask = () => void;
|
|
6
6
|
|
|
7
7
|
const destroyTasks = new Set<DestroyTask>();
|
|
8
|
+
let destroyed = false;
|
|
9
|
+
|
|
10
|
+
// Calls from a retired entry stay pending: settling them would run its continuations.
|
|
11
|
+
export function isRuntimeDestroyed(): boolean {
|
|
12
|
+
return destroyed;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function destroyRuntime(): void {
|
|
16
|
+
destroyed = true;
|
|
17
|
+
runDestroyTasks();
|
|
18
|
+
}
|
|
8
19
|
|
|
9
20
|
export function registerDestroyTask(task: DestroyTask): () => void {
|
|
10
21
|
destroyTasks.add(task);
|
|
@@ -10,6 +10,8 @@ import type { Worklet } from '../../worklet-runtime/bindings/types.js';
|
|
|
10
10
|
import { registerBackgroundFunctionCtx } from '../background-function/run-on-background.js';
|
|
11
11
|
import { isMainThreadFunction } from '../main-thread-function.js';
|
|
12
12
|
import { isMtsEnabled } from '../mts-capability.js';
|
|
13
|
+
import { dispatchReloadScopedEvent } from '../reload-scoped-event.js';
|
|
14
|
+
import { isRuntimeDestroyed } from '../runtime-destroy.js';
|
|
13
15
|
|
|
14
16
|
interface RunOnMainThreadOptions {
|
|
15
17
|
shouldDispatchRunOnMainThreadDirectly: () => boolean;
|
|
@@ -44,6 +46,7 @@ export function createRunOnMainThread(
|
|
|
44
46
|
}
|
|
45
47
|
return async (...params: Parameters<Fn>): Promise<R> => {
|
|
46
48
|
return new Promise((resolve) => {
|
|
49
|
+
if (isRuntimeDestroyed()) return;
|
|
47
50
|
const worklet = fn as unknown as Worklet;
|
|
48
51
|
prepareMainThreadFunctionCtx(worklet);
|
|
49
52
|
const data = {
|
|
@@ -74,8 +77,5 @@ function prepareMainThreadFunctionCtx(worklet: unknown): void {
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
function dispatchRunOnMainThreadEvent(data: RunWorkletCtxData): void {
|
|
77
|
-
lynx.getCoreContext().
|
|
78
|
-
type: WorkletEvents.runWorkletCtx,
|
|
79
|
-
data: JSON.stringify(data),
|
|
80
|
-
});
|
|
80
|
+
dispatchReloadScopedEvent(lynx.getCoreContext(), { type: WorkletEvents.runWorkletCtx, data });
|
|
81
81
|
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import { IndexMap } from '../../shared/index-map.js';
|
|
6
6
|
import { WorkletEvents } from '../../worklet-runtime/bindings/events.js';
|
|
7
7
|
import type { RunWorkletCtxRetData } from '../../worklet-runtime/bindings/events.js';
|
|
8
|
+
import { cardLifetime } from '../card-lifetime.js';
|
|
9
|
+
import { addReloadScopedEventListener } from '../reload-scoped-event.js';
|
|
8
10
|
import { registerDestroyTask } from '../runtime-destroy.js';
|
|
9
11
|
|
|
10
12
|
let resolveMap: IndexMap<(value: any) => void> | undefined;
|
|
@@ -14,11 +16,11 @@ let unregisterReturnValueCleanup: (() => void) | undefined;
|
|
|
14
16
|
function initReturnValueListener(): void {
|
|
15
17
|
const context: RuntimeProxy = __JS__ ? lynx.getCoreContext() : lynx.getJSContext();
|
|
16
18
|
|
|
17
|
-
resolveMap = new IndexMap();
|
|
18
|
-
context
|
|
19
|
+
resolveMap = new IndexMap(cardLifetime('functionCallId', () => ({ lastIndex: 0 })));
|
|
20
|
+
const removeListener = addReloadScopedEventListener(context, WorkletEvents.FunctionCallRet, onFunctionCallRet);
|
|
19
21
|
|
|
20
22
|
cleanupReturnValueListener = () => {
|
|
21
|
-
|
|
23
|
+
removeListener();
|
|
22
24
|
resolveMap = undefined;
|
|
23
25
|
cleanupReturnValueListener = undefined;
|
|
24
26
|
};
|
|
@@ -62,8 +64,7 @@ export function dropFunctionCallReturnIds(resolveIds: readonly number[]): void {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
function onFunctionCallRet(
|
|
66
|
-
const data = JSON.parse(event.data as string) as RunWorkletCtxRetData;
|
|
67
|
+
function onFunctionCallRet(data: RunWorkletCtxRetData): void {
|
|
67
68
|
const map = resolveMap;
|
|
68
69
|
if (!map) {
|
|
69
70
|
return;
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from './commit-context.js';
|
|
12
12
|
import type { BackgroundElementTemplateInstance } from './instance.js';
|
|
13
13
|
import { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';
|
|
14
|
-
import { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init-value.js';
|
|
15
14
|
import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';
|
|
16
15
|
import { getReloadVersion } from '../../core/reload-version.js';
|
|
17
16
|
import {
|
|
@@ -21,9 +20,9 @@ import {
|
|
|
21
20
|
import { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';
|
|
22
21
|
import { COMMIT } from '../../shared/render-constants.js';
|
|
23
22
|
import { hook, isEmptyObject } from '../../utils.js';
|
|
24
|
-
import type { MainThreadRefInitValuePatch } from '../../worklet-runtime/bindings/types.js';
|
|
25
23
|
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
26
24
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
25
|
+
import { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';
|
|
27
26
|
import { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';
|
|
28
27
|
import { createElementTemplateUpdateEvent } from '../protocol/update-event.js';
|
|
29
28
|
|
|
@@ -68,14 +67,12 @@ export function cancelElementTemplateRemovedSubtreeCleanup(): void {
|
|
|
68
67
|
scheduledRemovedSubtreeCleanupTimers.clear();
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
function flushElementTemplateCommitChanges(
|
|
70
|
+
function flushElementTemplateCommitChanges(): void {
|
|
72
71
|
const hasNativeOps = globalCommitContext.ops.length > 0;
|
|
73
72
|
const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;
|
|
74
|
-
const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;
|
|
75
73
|
const hasUpdatePayload = hasNativeOps
|
|
76
74
|
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
77
|
-
|| hasDelayedRunOnMainThread
|
|
78
|
-
|| hasMainThreadRefInitValuePatch;
|
|
75
|
+
|| hasDelayedRunOnMainThread;
|
|
79
76
|
const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];
|
|
80
77
|
if (hasUpdatePayload) {
|
|
81
78
|
markTimingLegacy('updateDiffVdomEnd');
|
|
@@ -115,7 +112,6 @@ function flushElementTemplateCommitChanges(mainThreadRefInitValuePatch: MainThre
|
|
|
115
112
|
flushOptions: globalCommitContext.flushOptions,
|
|
116
113
|
flowIds: globalCommitContext.flowIds,
|
|
117
114
|
delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,
|
|
118
|
-
mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,
|
|
119
115
|
},
|
|
120
116
|
null,
|
|
121
117
|
2,
|
|
@@ -129,9 +125,6 @@ function flushElementTemplateCommitChanges(mainThreadRefInitValuePatch: MainThre
|
|
|
129
125
|
reloadVersion: getReloadVersion(),
|
|
130
126
|
flowIds: globalCommitContext.flowIds,
|
|
131
127
|
delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,
|
|
132
|
-
mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch
|
|
133
|
-
? mainThreadRefInitValuePatch
|
|
134
|
-
: undefined,
|
|
135
128
|
});
|
|
136
129
|
} catch (error) {
|
|
137
130
|
if (delayedRunOnMainThreadPayload) {
|
|
@@ -166,23 +159,33 @@ export function installElementTemplateCommitHook(): void {
|
|
|
166
159
|
hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {
|
|
167
160
|
if (__BACKGROUND__) {
|
|
168
161
|
clearElementTemplateRenderScope();
|
|
162
|
+
try {
|
|
163
|
+
sendMTRefInitValueToMainThread();
|
|
164
|
+
} catch (error) {
|
|
165
|
+
const removedSubtreesAwaitingTeardown = takeRemovedSubtreesForPostDispatchTeardown();
|
|
166
|
+
dropFunctionCallReturnIds(takeDelayedRunOnMainThreadData().map(data => data.resolveId));
|
|
167
|
+
clearPendingRefs();
|
|
168
|
+
resetGlobalCommitContext();
|
|
169
|
+
setPipeline(undefined);
|
|
170
|
+
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {
|
|
172
176
|
// User effects can run before ET hydrate arrives, so ordinary refs must be
|
|
173
177
|
// attached on the background commit even though native UI ops are delayed.
|
|
174
178
|
flushPendingRefs();
|
|
175
|
-
} else if (
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
} else if (
|
|
180
|
+
__BACKGROUND__ && hasHydrated
|
|
181
|
+
&& (
|
|
178
182
|
globalCommitContext.ops.length > 0
|
|
179
183
|
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
180
184
|
|| hasPendingRefs()
|
|
181
185
|
|| delayedRunOnMainThreadData.length > 0
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
+
)
|
|
187
|
+
) {
|
|
188
|
+
flushElementTemplateCommitChanges();
|
|
186
189
|
}
|
|
187
190
|
|
|
188
191
|
originalCommit?.(vnode, commitQueue);
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
import { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';
|
|
31
31
|
import { formatElementTemplateUpdateCommands, printElementTemplateTreeToString } from '../debug/alog.js';
|
|
32
32
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
33
|
+
import { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';
|
|
33
34
|
import { clearPendingEvents, flushPendingEvents } from '../prop-adapters/event.js';
|
|
34
35
|
import { clearDelayedRefUiOps, clearPendingRefs, flushDelayedRefUiOps } from '../prop-adapters/ref.js';
|
|
35
36
|
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
@@ -107,8 +108,6 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
107
108
|
const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread
|
|
108
109
|
? takeDelayedRunOnMainThreadData()
|
|
109
110
|
: undefined;
|
|
110
|
-
const mainThreadRefInitValuePatch = takeMainThreadRefInitValuePatch();
|
|
111
|
-
const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;
|
|
112
111
|
const pipelineOptions = globalPipelineOptions;
|
|
113
112
|
if (pipelineOptions) {
|
|
114
113
|
globalCommitContext.flushOptions.pipelineOptions = pipelineOptions;
|
|
@@ -122,6 +121,7 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
122
121
|
}
|
|
123
122
|
markTiming('packChangesStart');
|
|
124
123
|
try {
|
|
124
|
+
sendMTRefInitValueToMainThread();
|
|
125
125
|
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
126
126
|
console.alog?.(
|
|
127
127
|
'[ReactLynxDebug] ElementTemplate hydrate update commands:\n'
|
|
@@ -132,7 +132,6 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
132
132
|
flowIds: globalCommitContext.flowIds,
|
|
133
133
|
isHydration: true,
|
|
134
134
|
delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,
|
|
135
|
-
mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,
|
|
136
135
|
},
|
|
137
136
|
null,
|
|
138
137
|
2,
|
|
@@ -146,9 +145,6 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
146
145
|
reloadVersion: getReloadVersion(),
|
|
147
146
|
flowIds: globalCommitContext.flowIds,
|
|
148
147
|
delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,
|
|
149
|
-
mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch
|
|
150
|
-
? mainThreadRefInitValuePatch
|
|
151
|
-
: undefined,
|
|
152
148
|
});
|
|
153
149
|
} catch (error) {
|
|
154
150
|
if (delayedRunOnMainThreadPayload) {
|
|
@@ -59,7 +59,6 @@ export { wrapWithLynxComponent } from '../core/compat/lynxComponent.js';
|
|
|
59
59
|
export { loadLazyBundle } from '../core/lynx/lazy-bundle.js';
|
|
60
60
|
|
|
61
61
|
export { transformToWorklet } from './runtime/template/main-thread-background-function.js';
|
|
62
|
-
export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
|
|
63
62
|
|
|
64
63
|
export { captureMainThreadObject } from '../core/capture-main-thread-object.js';
|
|
65
64
|
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
|
|
5
|
+
import { updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime/bindings';
|
|
6
|
+
import type { MainThreadRefInitValuePatch } from '@lynx-js/react/worklet-runtime/bindings';
|
|
7
|
+
|
|
8
|
+
import { takeMainThreadRefInitValuePatch } from '../core/main-thread-ref-init-value.js';
|
|
9
|
+
import { ElementTemplateLifecycleConstant } from './protocol/lifecycle-constant.js';
|
|
10
|
+
|
|
11
|
+
let listener: ((event: RuntimeProxy.Event) => void) | undefined;
|
|
12
|
+
|
|
13
|
+
export function installElementTemplateRefInitValueListener(): void {
|
|
14
|
+
resetElementTemplateRefInitValueListener();
|
|
15
|
+
listener = (event) => {
|
|
16
|
+
const data = event.data as string;
|
|
17
|
+
const patch = JSON.parse(data) as MainThreadRefInitValuePatch;
|
|
18
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
19
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate MTS updateMTRefInitValue:\n' + data);
|
|
20
|
+
}
|
|
21
|
+
// Ref initialization outlives UI patches and must not be filtered by reloadVersion.
|
|
22
|
+
updateWorkletRefInitValueChanges(patch);
|
|
23
|
+
};
|
|
24
|
+
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function resetElementTemplateRefInitValueListener(): void {
|
|
28
|
+
if (listener) {
|
|
29
|
+
lynx.getJSContext().removeEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);
|
|
30
|
+
}
|
|
31
|
+
listener = undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function sendMTRefInitValueToMainThread(): void {
|
|
35
|
+
const patch = takeMainThreadRefInitValuePatch();
|
|
36
|
+
if (patch.length === 0) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const data = JSON.stringify(patch);
|
|
40
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
41
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS sendMTRefInitValue:\n' + data);
|
|
42
|
+
}
|
|
43
|
+
lynx.getCoreContext().dispatchEvent({ type: ElementTemplateLifecycleConstant.updateMTRefInitValue, data });
|
|
44
|
+
}
|
|
@@ -25,6 +25,7 @@ import { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';
|
|
|
25
25
|
import { initProfileHook } from '../debug/profile.js';
|
|
26
26
|
import { setupLynxEnv } from '../lynx/env.js';
|
|
27
27
|
import { initTimingAPI } from '../lynx/performance.js';
|
|
28
|
+
import { installElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
28
29
|
import { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
29
30
|
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
30
31
|
|
|
@@ -57,6 +58,7 @@ function init(): void {
|
|
|
57
58
|
if (__MAIN_THREAD__) {
|
|
58
59
|
installMainThreadHooks();
|
|
59
60
|
injectCalledByNative();
|
|
61
|
+
installElementTemplateRefInitValueListener();
|
|
60
62
|
installElementTemplatePatchListener();
|
|
61
63
|
installOnMtsDestruction();
|
|
62
64
|
if (__PROFILE__) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
5
|
import { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
6
|
+
import { resetElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
6
7
|
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
7
8
|
import { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
|
|
8
9
|
import { clearMainThreadDynamicAttrState } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
@@ -33,6 +34,8 @@ export function destroyElementTemplateMainThreadRuntime(): void {
|
|
|
33
34
|
didPatchListenerResetThrow = true;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
resetElementTemplateRefInitValueListener();
|
|
38
|
+
|
|
36
39
|
// The registry is the main-thread strong-reference owner for ET refs. Clear it
|
|
37
40
|
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
38
41
|
destroyAllElementTemplateListStates();
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
flushDelayedRunOnBackgroundFunctions,
|
|
9
9
|
runRunOnMainThreadTask,
|
|
10
10
|
setEomShouldFlushElementTree,
|
|
11
|
-
updateWorkletRefInitValueChanges,
|
|
12
11
|
} from '@lynx-js/react/worklet-runtime/bindings';
|
|
13
12
|
|
|
14
13
|
import { markTiming, setPipeline } from '../../core/performance.js';
|
|
@@ -45,10 +44,6 @@ export function installElementTemplatePatchListener(): void {
|
|
|
45
44
|
const payload = JSON.parse(event.data.payload) as ElementTemplateUpdateCommitContext;
|
|
46
45
|
markTiming('parseChangesEnd');
|
|
47
46
|
|
|
48
|
-
if (payload.mainThreadRefInitValuePatch?.length) {
|
|
49
|
-
updateWorkletRefInitValueChanges(payload.mainThreadRefInitValuePatch);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
if (
|
|
53
48
|
typeof patchOptions.reloadVersion === 'number'
|
|
54
49
|
&& patchOptions.reloadVersion < getReloadVersion()
|