@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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { profileEnd, profileStart } from '../shared/profile.js';
|
|
2
|
+
export function createProcessData(dataProcessorDefinition) {
|
|
3
|
+
let hasDefaultDataProcessorExecuted = false;
|
|
4
|
+
return (data, processorName) => {
|
|
5
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
6
|
+
profileStart('processData');
|
|
7
|
+
}
|
|
8
|
+
let result;
|
|
9
|
+
try {
|
|
10
|
+
if (processorName) {
|
|
11
|
+
result = dataProcessorDefinition?.dataProcessors?.[processorName]?.(data) ?? data;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
result = dataProcessorDefinition?.defaultDataProcessor?.(data) ?? data;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
lynx.reportError(error);
|
|
19
|
+
result = {};
|
|
20
|
+
}
|
|
21
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
22
|
+
profileEnd();
|
|
23
|
+
}
|
|
24
|
+
if (!hasDefaultDataProcessorExecuted) {
|
|
25
|
+
result = appendInitDataMetadata(result);
|
|
26
|
+
}
|
|
27
|
+
if (!processorName) {
|
|
28
|
+
hasDefaultDataProcessorExecuted = true;
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function appendInitDataMetadata(result) {
|
|
34
|
+
// @ts-expect-error todo: add types to i18n logic
|
|
35
|
+
const i18nResourceTranslation = globalThis.__I18N_RESOURCE_TRANSLATION__;
|
|
36
|
+
if (i18nResourceTranslation) {
|
|
37
|
+
result = {
|
|
38
|
+
...result,
|
|
39
|
+
__I18N_RESOURCE_TRANSLATION__: i18nResourceTranslation,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// @ts-expect-error todo: add types to __EXTRACT_STR__
|
|
43
|
+
if (__EXTRACT_STR__) {
|
|
44
|
+
// @ts-expect-error todo: add types to __EXTRACT_STR__
|
|
45
|
+
const extractStrIdentFlag = __EXTRACT_STR_IDENT_FLAG__;
|
|
46
|
+
result = {
|
|
47
|
+
...result,
|
|
48
|
+
_EXTRACT_STR: extractStrIdentFlag,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=lynx-data-processors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx-data-processors.js","s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EAAE,CAAC;QAC5B,MAAM,GAAG;YACP,GAAG,MAAM;YACT,6BAA6B,EAAE,uBAAuB;SACvD,CAAC;IACJ,CAAC;IAED,sDAAsD;IACtD,IAAI,eAAe,EAAE,CAAC;QACpB,sDAAsD;QACtD,MAAM,mBAAmB,GAAY,0BAA0B,CAAC;QAChE,MAAM,GAAG;YACP,GAAG,MAAM;YACT,YAAY,EAAE,mBAAmB;SAClC,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function applyUpdatePageData(data: unknown, options?: Pick<UpdatePageOption, 'resetPageData'>): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { isEmptyObject } from '../utils.js';
|
|
5
|
+
export function applyUpdatePageData(data, options) {
|
|
6
|
+
if (options?.resetPageData) {
|
|
7
|
+
lynx.__initData = {};
|
|
8
|
+
}
|
|
9
|
+
if (typeof data == 'object' && data !== null && !isEmptyObject(data)) {
|
|
10
|
+
lynx.__initData ??= {};
|
|
11
|
+
Object.assign(lynx.__initData, data);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=lynx-page-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx-page-data.js","sourceRoot":"","sources":["../../src/core/lynx-page-data.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,UAAU,mBAAmB,CAAC,IAAa,EAAE,OAAiD;IAClG,IAAI,OAAO,EAAE,aAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,IAAI,OAAO,IAAI,IAAI,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,IAAI,CAAC,UAAU,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const NativeUpdateDataType: {
|
|
2
|
+
readonly UPDATE: 0;
|
|
3
|
+
readonly RESET: 1;
|
|
4
|
+
};
|
|
5
|
+
export type NativeUpdateDataType = (typeof NativeUpdateDataType)[keyof typeof NativeUpdateDataType];
|
|
6
|
+
export interface NativeUpdateDataOptions {
|
|
7
|
+
type?: NativeUpdateDataType | undefined;
|
|
8
|
+
}
|
|
9
|
+
type InitDataPatch = Record<string, any>;
|
|
10
|
+
export declare function updateCardData(newData: InitDataPatch, options?: NativeUpdateDataOptions): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
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 NativeUpdateDataType = {
|
|
5
|
+
UPDATE: 0,
|
|
6
|
+
RESET: 1,
|
|
7
|
+
};
|
|
8
|
+
export function updateCardData(newData, options) {
|
|
9
|
+
const { ['__lynx_timing_flag']: performanceTimingFlag, ...restNewData } = newData;
|
|
10
|
+
if (performanceTimingFlag) {
|
|
11
|
+
lynx.reportError(new Error(`Received unsupported updateData with \`__lynx_timing_flag\` (value "${performanceTimingFlag}"), the timing flag is ignored`));
|
|
12
|
+
}
|
|
13
|
+
const { type = NativeUpdateDataType.UPDATE } = options ?? {};
|
|
14
|
+
if (type == NativeUpdateDataType.RESET) {
|
|
15
|
+
lynx.__initData = {};
|
|
16
|
+
}
|
|
17
|
+
// COW keeps provider/consumer readers aligned with Snapshot updateData behavior.
|
|
18
|
+
lynx.__initData = Object.assign({}, lynx.__initData, restNewData);
|
|
19
|
+
lynx.getJSModule('GlobalEventEmitter').emit('onDataChanged', [restNewData]);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=lynx-update-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynx-update-data.js","sourceRoot":"","sources":["../../src/core/lynx-update-data.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;CACA,CAAC;AAUX,MAAM,UAAU,cAAc,CAC5B,OAAsB,EACtB,OAAiC;IAEjC,MAAM,EAAE,CAAC,oBAAoB,CAAC,EAAE,qBAAqB,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;IAClF,IAAI,qBAAqB,EAAE,CAAC;QAC1B,IAAI,CAAC,WAAW,CACd,IAAI,KAAK,CACP,uEAAuE,qBAAqB,gCAAgC,CAC7H,CACF,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC7D,IAAI,IAAI,IAAI,oBAAoB,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,iFAAiF;IACjF,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAElE,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { NodesRef } from '@lynx-js/types';
|
|
2
|
+
export type RefCleanup = (() => void) | void;
|
|
3
|
+
export type RefCallback<T> = ((ref: T | null) => RefCleanup) & {
|
|
4
|
+
_unmount?: RefCleanup;
|
|
5
|
+
};
|
|
6
|
+
export interface RefObject<T> {
|
|
7
|
+
current: T | null;
|
|
8
|
+
}
|
|
9
|
+
export type OrdinaryRef<T> = RefCallback<T> | RefObject<T>;
|
|
10
|
+
type FunctionPropertyNames<T> = {
|
|
11
|
+
[K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? K : never;
|
|
12
|
+
}[keyof T];
|
|
13
|
+
export type ForwardableNodesRefMethod = Exclude<FunctionPropertyNames<NodesRef>, 'exec'>;
|
|
14
|
+
export type RefProxyForwardedMethods<TProxy> = {
|
|
15
|
+
[K in ForwardableNodesRefMethod]: (...args: Parameters<NodesRef[K]>) => TProxy;
|
|
16
|
+
};
|
|
17
|
+
export declare function assertValidRef<T>(value: unknown): OrdinaryRef<T>;
|
|
18
|
+
export declare function normalizeRefValue<T>(value: unknown): OrdinaryRef<T> | null | undefined;
|
|
19
|
+
export declare function applyOrdinaryRef<T>(ref: OrdinaryRef<T>, value: T | null): void;
|
|
20
|
+
export declare class OrdinaryRefEffectQueue<TProxy, TToken> {
|
|
21
|
+
private readonly refsToClear;
|
|
22
|
+
private readonly refsToApply;
|
|
23
|
+
queue(oldRef: OrdinaryRef<TProxy> | null | undefined, newRef: OrdinaryRef<TProxy> | null | undefined, token: TToken): void;
|
|
24
|
+
flush(createValue: (token: TToken) => TProxy): void;
|
|
25
|
+
clear(): void;
|
|
26
|
+
hasPending(): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare abstract class SelectorRefProxy<TProxy extends SelectorRefProxy<TProxy>> {
|
|
29
|
+
private task;
|
|
30
|
+
protected createProxy(): TProxy;
|
|
31
|
+
protected abstract createProxyTarget(): TProxy;
|
|
32
|
+
protected abstract runOrDelay(task: () => void): void;
|
|
33
|
+
abstract get selector(): string;
|
|
34
|
+
private setTask;
|
|
35
|
+
exec(): void;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
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 function assertValidRef(value) {
|
|
5
|
+
if (typeof value === 'function'
|
|
6
|
+
|| (typeof value === 'object' && value !== null && 'current' in value)) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
throw new Error(`Elements' "ref" property should be a function, or an object created `
|
|
10
|
+
+ `by createRef(), but got [${typeof value}] instead`);
|
|
11
|
+
}
|
|
12
|
+
export function normalizeRefValue(value) {
|
|
13
|
+
if (value === null || value === undefined) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
return assertValidRef(value);
|
|
17
|
+
}
|
|
18
|
+
export function applyOrdinaryRef(ref, value) {
|
|
19
|
+
try {
|
|
20
|
+
if (typeof ref === 'function') {
|
|
21
|
+
const cleanup = ref._unmount;
|
|
22
|
+
const hasCleanup = typeof cleanup === 'function';
|
|
23
|
+
if (hasCleanup) {
|
|
24
|
+
cleanup();
|
|
25
|
+
}
|
|
26
|
+
ref._unmount = undefined;
|
|
27
|
+
if (!hasCleanup || value !== null) {
|
|
28
|
+
const nextCleanup = ref(value);
|
|
29
|
+
if (typeof nextCleanup === 'function') {
|
|
30
|
+
ref._unmount = nextCleanup;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
ref.current = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
lynx.reportError(error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Keeps the Snapshot/ET ordinary ref ordering shared without owning backend
|
|
43
|
+
// timing: each backend decides when to queue/flush and how to build the proxy.
|
|
44
|
+
export class OrdinaryRefEffectQueue {
|
|
45
|
+
refsToClear = [];
|
|
46
|
+
refsToApply = [];
|
|
47
|
+
queue(oldRef, newRef, token) {
|
|
48
|
+
if (oldRef === newRef) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (oldRef) {
|
|
52
|
+
this.refsToClear.push(oldRef);
|
|
53
|
+
}
|
|
54
|
+
if (newRef) {
|
|
55
|
+
this.refsToApply.push([newRef, token]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
flush(createValue) {
|
|
59
|
+
// Ref callbacks can synchronously trigger more work; detach this batch from
|
|
60
|
+
// the queue before invoking user code so later effects stay in the next batch.
|
|
61
|
+
const refsToClearNow = this.refsToClear.splice(0);
|
|
62
|
+
const refsToApplyNow = this.refsToApply.splice(0);
|
|
63
|
+
for (const ref of refsToClearNow) {
|
|
64
|
+
applyOrdinaryRef(ref, null);
|
|
65
|
+
}
|
|
66
|
+
for (const [ref, token] of refsToApplyNow) {
|
|
67
|
+
applyOrdinaryRef(ref, createValue(token));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
clear() {
|
|
71
|
+
this.refsToClear.length = 0;
|
|
72
|
+
this.refsToApply.length = 0;
|
|
73
|
+
}
|
|
74
|
+
hasPending() {
|
|
75
|
+
return this.refsToClear.length > 0 || this.refsToApply.length > 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class SelectorRefProxy {
|
|
79
|
+
task;
|
|
80
|
+
createProxy() {
|
|
81
|
+
return new Proxy(this, {
|
|
82
|
+
get: (target, prop, receiver) => {
|
|
83
|
+
if (typeof prop === 'symbol'
|
|
84
|
+
|| prop === 'then'
|
|
85
|
+
|| prop in target
|
|
86
|
+
|| typeof prop !== 'string') {
|
|
87
|
+
return Reflect.get(target, prop, receiver);
|
|
88
|
+
}
|
|
89
|
+
return (...args) => {
|
|
90
|
+
return target.createProxyTarget().setTask(prop, args);
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
setTask(method, args) {
|
|
96
|
+
this.task = (nodesRef) => {
|
|
97
|
+
const nodesRefMethod = nodesRef[method];
|
|
98
|
+
return nodesRefMethod.apply(nodesRef, args);
|
|
99
|
+
};
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
exec() {
|
|
103
|
+
this.runOrDelay(() => {
|
|
104
|
+
this.task(lynx.createSelectorQuery().select(this.selector)).exec();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../src/core/ref.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAwB1D,MAAM,UAAU,cAAc,CAAI,KAAc;IAC9C,IACE,OAAO,KAAK,KAAK,UAAU;WACxB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,IAAI,KAAK,CAAC,EACtE,CAAC;QACD,OAAO,KAAuB,CAAC;IACjC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,sEAAsE;UAClE,4BAA4B,OAAO,KAAK,WAAW,CACxD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,KAAc;IACjD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,cAAc,CAAI,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,GAAmB,EACnB,KAAe;IAEf,IAAI,CAAC;QACH,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC;YAC7B,MAAM,UAAU,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC;YACjD,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,E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AO,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC;QACF,OAAO,IAAyB,CAAC;IACnC,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE;YACnB,IAAI,CAAC,IAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2026 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
4
|
let reloadVersion = 0;
|
|
5
|
-
function getReloadVersion() {
|
|
5
|
+
export function getReloadVersion() {
|
|
6
6
|
return reloadVersion;
|
|
7
7
|
}
|
|
8
|
-
function increaseReloadVersion() {
|
|
8
|
+
export function increaseReloadVersion() {
|
|
9
9
|
return ++reloadVersion;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=pass.js.map
|
|
11
|
+
//# sourceMappingURL=reload-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload-version.js","sourceRoot":"","sources":["../../src/core/reload-version.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,EAAE,aAAa,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SerializableValue } from '../protocol/types.js';
|
|
2
|
+
export interface PrepareAttributeSlotsOptions {
|
|
3
|
+
previousRawSlots?: readonly unknown[];
|
|
4
|
+
queueRefEffects?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function prepareAttributeSlots(templateKey: string, handleId: number, rawSlots: readonly unknown[], options?: PrepareAttributeSlotsOptions): SerializableValue[];
|
|
7
|
+
export declare function queueRefAttributeSlotUpdates(templateKey: string, handleId: number, previousRawSlots?: readonly unknown[], nextRawSlots?: readonly unknown[]): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { getSpreadRefFromValue, queueRefAttrUpdate } from '../prop-adapters/ref.js';
|
|
5
|
+
import { __etAttrPlanMap, adaptRefAttrSlot, adaptSpreadAttrSlot } from '../runtime/template/attr-slot-plan.js';
|
|
6
|
+
function normalizeAttributeSlots(rawSlots) {
|
|
7
|
+
let normalizedSlots;
|
|
8
|
+
for (let slotIndex = 0; slotIndex < rawSlots.length; slotIndex += 1) {
|
|
9
|
+
const rawSlot = rawSlots[slotIndex];
|
|
10
|
+
if (rawSlot !== undefined) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
normalizedSlots ??= rawSlots.slice();
|
|
14
|
+
normalizedSlots[slotIndex] = null;
|
|
15
|
+
}
|
|
16
|
+
return normalizedSlots ?? rawSlots;
|
|
17
|
+
}
|
|
18
|
+
function queuePlannedRefAttributeSlotUpdates(handleId, attrPlan, previousRawSlots, nextRawSlots) {
|
|
19
|
+
for (let planIndex = 0; planIndex < attrPlan.length; planIndex += 2) {
|
|
20
|
+
const attrSlotIndex = attrPlan[planIndex];
|
|
21
|
+
const adapter = attrPlan[planIndex + 1];
|
|
22
|
+
if (adapter === adaptRefAttrSlot) {
|
|
23
|
+
queueRefAttrUpdate(previousRawSlots?.[attrSlotIndex], nextRawSlots?.[attrSlotIndex], handleId, attrSlotIndex);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (adapter === adaptSpreadAttrSlot) {
|
|
27
|
+
const previousSpreadRef = getSpreadRefFromValue(previousRawSlots?.[attrSlotIndex]);
|
|
28
|
+
const nextSpreadRef = getSpreadRefFromValue(nextRawSlots?.[attrSlotIndex]);
|
|
29
|
+
if (previousSpreadRef === undefined && nextSpreadRef === undefined) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
queueRefAttrUpdate(previousSpreadRef, nextSpreadRef ?? null, handleId, attrSlotIndex);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function prepareAttributeSlots(templateKey, handleId, rawSlots, options) {
|
|
37
|
+
const attrPlan = __etAttrPlanMap[templateKey];
|
|
38
|
+
if (!attrPlan || attrPlan.length === 0) {
|
|
39
|
+
return normalizeAttributeSlots(rawSlots);
|
|
40
|
+
}
|
|
41
|
+
const normalizedSlots = normalizeAttributeSlots(rawSlots);
|
|
42
|
+
const preparedSlots = normalizedSlots === rawSlots
|
|
43
|
+
? rawSlots.slice()
|
|
44
|
+
: normalizedSlots;
|
|
45
|
+
const shouldQueueRefEffects = options?.queueRefEffects === true;
|
|
46
|
+
const previousRawSlots = options?.previousRawSlots;
|
|
47
|
+
for (let planIndex = 0; planIndex < attrPlan.length; planIndex += 2) {
|
|
48
|
+
const attrSlotIndex = attrPlan[planIndex];
|
|
49
|
+
const adapter = attrPlan[planIndex + 1];
|
|
50
|
+
const rawValue = rawSlots[attrSlotIndex];
|
|
51
|
+
preparedSlots[attrSlotIndex] = adapter(handleId, attrSlotIndex, rawValue);
|
|
52
|
+
}
|
|
53
|
+
if (shouldQueueRefEffects) {
|
|
54
|
+
// Ref effects compare raw user refs, not prepared marker strings or the
|
|
55
|
+
// spread wrapper object.
|
|
56
|
+
queuePlannedRefAttributeSlotUpdates(handleId, attrPlan, previousRawSlots, rawSlots);
|
|
57
|
+
}
|
|
58
|
+
return preparedSlots;
|
|
59
|
+
}
|
|
60
|
+
export function queueRefAttributeSlotUpdates(templateKey, handleId, previousRawSlots, nextRawSlots) {
|
|
61
|
+
const attrPlan = __etAttrPlanMap[templateKey];
|
|
62
|
+
if (!attrPlan || attrPlan.length === 0) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
queuePlannedRefAttributeSlotUpdates(handleId, attrPlan, previousRawSlots, nextRawSlots);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=attr-slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attr-slots.js","sourceRoot":"","sources":["../../../src/element-template/background/attr-slots.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAQ/G,SAAS,uBAAuB,CAAC,QAA4B;IAC3D,IAAI,eAAgD,CAAC;IACrD,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,eAAe,KAAK,QAAQ,CAAC,KAAK,EAAyB,CAAC;QAC5D,eAAe,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACpC,CAAC;IACD,OAAO,eAAe,IAAI,QAA+B,CAAC;AAC5D,CAAC;AAED,SAAS,mCAAmC,CAC1C,QAAgB,EAChB,QAA6C,EAC7C,gBAAqC,EACrC,YAAiC;IAEjC,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE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eAAe,KAAK,IAAI,CAAC;IAChE,MAAM,gBAAgB,GAAG,OAAO,EAAE,gBAAgB,CAAC;IACnD,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAW,CAAC;QACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAkB,CAAC;QACzD,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;QACzC,aAAa,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,qBAAqB,EAAE,CAAC;QAC1B,wEAAwE;QACxE,yBAAyB;QACzB,mCAAmC,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACtF,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,WAAmB,EACnB,QAAgB,EAChB,gBAAqC,EACrC,YAAiC;IAEjC,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO;IACT,CAAC;IAED,mCAAmC,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BackgroundElementTemplateInstance } from './instance.js';
|
|
2
|
+
import type { ElementTemplateUpdateCommitContext } from '../protocol/types.js';
|
|
3
|
+
interface ElementTemplateCommitNonPayloadState {
|
|
4
|
+
removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[];
|
|
5
|
+
}
|
|
6
|
+
type ElementTemplateGlobalCommitContext = ElementTemplateUpdateCommitContext & {
|
|
7
|
+
nonPayload: ElementTemplateCommitNonPayloadState;
|
|
8
|
+
};
|
|
9
|
+
export declare const globalCommitContext: ElementTemplateGlobalCommitContext;
|
|
10
|
+
export declare function resetGlobalCommitContext(): void;
|
|
11
|
+
export declare function markRemovedSubtreeForPostDispatchTeardown(root: BackgroundElementTemplateInstance): void;
|
|
12
|
+
export declare function takeRemovedSubtreesForPostDispatchTeardown(): BackgroundElementTemplateInstance[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { globalCommitContext as coreGlobalCommitContext, resetGlobalCommitContext as resetCoreGlobalCommitContext, } from '../../core/commit-context.js';
|
|
2
|
+
const nonPayload = {
|
|
3
|
+
removedSubtreesAwaitingTeardown: [],
|
|
4
|
+
};
|
|
5
|
+
export const globalCommitContext = coreGlobalCommitContext;
|
|
6
|
+
globalCommitContext.nonPayload = nonPayload;
|
|
7
|
+
export function resetGlobalCommitContext() {
|
|
8
|
+
resetCoreGlobalCommitContext();
|
|
9
|
+
nonPayload.removedSubtreesAwaitingTeardown = [];
|
|
10
|
+
}
|
|
11
|
+
export function markRemovedSubtreeForPostDispatchTeardown(root) {
|
|
12
|
+
const { removedSubtreesAwaitingTeardown } = globalCommitContext.nonPayload;
|
|
13
|
+
if (!removedSubtreesAwaitingTeardown.includes(root)) {
|
|
14
|
+
removedSubtreesAwaitingTeardown.push(root);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function takeRemovedSubtreesForPostDispatchTeardown() {
|
|
18
|
+
const removedSubtreesAwaitingTeardown = globalCommitContext.nonPayload.removedSubtreesAwaitingTeardown;
|
|
19
|
+
globalCommitContext.nonPayload.removedSubtreesAwaitingTeardown = [];
|
|
20
|
+
return removedSubtreesAwaitingTeardown;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=commit-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-context.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-context.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,wBAAwB,IAAI,4BAA4B,GACzD,MAAM,8BAA8B,CAAC;AActC,MAAM,UAAU,GAAyC;IACvD,+BAA+B,EAAE,EAAE;CACpC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAwE,CAAC;AAE5G,mBAAmB,CAAC,UAAU,GAAG,UAAU,CAAC;AAE5C,MAAM,UAAU,wBAAwB;IACtC,4BAA4B,EAAE,CAAC;IAC/B,UAAU,CAAC,+BAA+B,GAAG,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,yCAAyC,CACvD,IAAuC;IAEvC,MAAM,EAAE,+BAA+B,EAAE,GAAG,mBAAmB,CAAC,UAAU,CAAC;IAC3E,IAAI,CAAC,+BAA+B,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0CAA0C;IACxD,MAAM,+BAA+B,GAAG,mBAAmB,CAAC,UAAU,CAAC,+BAA+B,CAAC;IACvG,mBAAmB,CAAC,UAAU,CAAC,+BAA+B,GAAG,EAAE,CAAC;IACpE,OAAO,+BAA+B,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BackgroundElementTemplateInstance } from './instance.js';
|
|
2
|
+
export declare function markElementTemplateHydrated(): void;
|
|
3
|
+
export declare function isElementTemplateHydrated(): boolean;
|
|
4
|
+
export declare function resetElementTemplateCommitState(): void;
|
|
5
|
+
export declare function scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[]): void;
|
|
6
|
+
export declare function cancelElementTemplateRemovedSubtreeCleanup(): void;
|
|
7
|
+
export declare function installElementTemplateCommitHook(): void;
|
|
@@ -0,0 +1,121 @@
|
|
|
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 } from 'preact';
|
|
5
|
+
import { globalCommitContext, resetGlobalCommitContext, takeRemovedSubtreesForPostDispatchTeardown, } from './commit-context.js';
|
|
6
|
+
import { getReloadVersion } from '../../core/reload-version.js';
|
|
7
|
+
import { COMMIT } from '../../shared/render-constants.js';
|
|
8
|
+
import { hook, isEmptyObject } from '../../utils.js';
|
|
9
|
+
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
10
|
+
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
11
|
+
import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../lynx/performance.js';
|
|
12
|
+
import { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';
|
|
13
|
+
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
14
|
+
let installed = false;
|
|
15
|
+
let hasHydrated = false;
|
|
16
|
+
const scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set();
|
|
17
|
+
export function markElementTemplateHydrated() {
|
|
18
|
+
hasHydrated = true;
|
|
19
|
+
}
|
|
20
|
+
export function isElementTemplateHydrated() {
|
|
21
|
+
return hasHydrated;
|
|
22
|
+
}
|
|
23
|
+
export function resetElementTemplateCommitState() {
|
|
24
|
+
hasHydrated = false;
|
|
25
|
+
resetGlobalCommitContext();
|
|
26
|
+
}
|
|
27
|
+
export function scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown) {
|
|
28
|
+
if (removedSubtreesAwaitingTeardown.length === 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const timer = setTimeout(() => {
|
|
32
|
+
scheduledRemovedSubtreeCleanupTimers.delete(timer);
|
|
33
|
+
for (const root of removedSubtreesAwaitingTeardown) {
|
|
34
|
+
root.tearDown();
|
|
35
|
+
}
|
|
36
|
+
}, 10000);
|
|
37
|
+
scheduledRemovedSubtreeCleanupTimers.add(timer);
|
|
38
|
+
}
|
|
39
|
+
export function cancelElementTemplateRemovedSubtreeCleanup() {
|
|
40
|
+
for (const timer of scheduledRemovedSubtreeCleanupTimers) {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
}
|
|
43
|
+
scheduledRemovedSubtreeCleanupTimers.clear();
|
|
44
|
+
}
|
|
45
|
+
export function installElementTemplateCommitHook() {
|
|
46
|
+
if (installed) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
installed = true;
|
|
50
|
+
hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {
|
|
51
|
+
if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {
|
|
52
|
+
// User effects can run before ET hydrate arrives, so ordinary refs must be
|
|
53
|
+
// attached on the background commit even though native UI ops are delayed.
|
|
54
|
+
flushPendingRefs();
|
|
55
|
+
}
|
|
56
|
+
else if (__BACKGROUND__ && hasHydrated
|
|
57
|
+
&& (globalCommitContext.ops.length > 0
|
|
58
|
+
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
59
|
+
|| hasPendingRefs())) {
|
|
60
|
+
const hasNativeOps = globalCommitContext.ops.length > 0;
|
|
61
|
+
const hasUpdatePayload = hasNativeOps || !isEmptyObject(globalCommitContext.flushOptions);
|
|
62
|
+
const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];
|
|
63
|
+
let didFlushRefs = false;
|
|
64
|
+
try {
|
|
65
|
+
if (hasUpdatePayload) {
|
|
66
|
+
markTimingLegacy('updateDiffVdomEnd');
|
|
67
|
+
markTiming('diffVdomEnd');
|
|
68
|
+
if (__PROFILE__) {
|
|
69
|
+
profileStart('ReactLynx::commitChanges');
|
|
70
|
+
}
|
|
71
|
+
markTiming('packChangesStart');
|
|
72
|
+
if (globalPipelineOptions) {
|
|
73
|
+
globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;
|
|
74
|
+
}
|
|
75
|
+
markTiming('packChangesEnd');
|
|
76
|
+
if (globalPipelineOptions) {
|
|
77
|
+
setPipeline(undefined);
|
|
78
|
+
}
|
|
79
|
+
if (__PROFILE__) {
|
|
80
|
+
profileEnd();
|
|
81
|
+
}
|
|
82
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
83
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS update:\n'
|
|
84
|
+
+ JSON.stringify({
|
|
85
|
+
ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),
|
|
86
|
+
flushOptions: globalCommitContext.flushOptions,
|
|
87
|
+
flowIds: globalCommitContext.flowIds,
|
|
88
|
+
}, null, 2));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (hasUpdatePayload) {
|
|
92
|
+
lynx.getCoreContext().dispatchEvent({
|
|
93
|
+
type: ElementTemplateLifecycleConstant.update,
|
|
94
|
+
data: {
|
|
95
|
+
ops: globalCommitContext.ops,
|
|
96
|
+
flushOptions: globalCommitContext.flushOptions,
|
|
97
|
+
flowIds: globalCommitContext.flowIds,
|
|
98
|
+
reloadVersion: getReloadVersion(),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// When native ops exist, patch first so a newly attached ref observes the
|
|
103
|
+
// committed native state. Ref-only commits still flush through this path.
|
|
104
|
+
flushPendingRefs();
|
|
105
|
+
didFlushRefs = true;
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
if (!didFlushRefs) {
|
|
109
|
+
clearPendingRefs();
|
|
110
|
+
}
|
|
111
|
+
resetGlobalCommitContext();
|
|
112
|
+
// Match Snapshot's cleanup boundary: start the delayed teardown only
|
|
113
|
+
// after the bridge dispatch attempt, so background JS objects are not
|
|
114
|
+
// torn down before main-thread detach observes the same commit.
|
|
115
|
+
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
originalCommit?.(vnode, commitQueue);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=commit-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1G,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAErF,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,MAAM,oCAAoC,GAAG,aAAa,CAAC,IAAI,GAAG,EAAiC,CAAC;AAEpG,MAAM,UAAU,2BAA2B;IACzC,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO,WAAW,CAAC;AACrB,C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AAE,CAAC,aAAa,CAAC;wBAClC,IAAI,EAAE,gCAAgC,CAAC,MAAM;wBAC7C,IAAI,EAAE;4BACJ,GAAG,EAAE,mBAAmB,CAAC,GAAG;4BAC5B,YAAY,EAAE,mBAAmB,CAAC,YAAY;4BAC9C,OAAO,EAAE,mBAAmB,CAAC,OAAO;4BACpC,aAAa,EAAE,gBAAgB,EAAE;yBAClC;qBACF,CAAC,CAAC;gBACL,CAAC;gBACD,0EAA0E;gBAC1E,0EAA0E;gBAC1E,gBAAgB,EAAE,CAAC;gBACnB,YAAY,GAAG,IAAI,CAAC;YACtB,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,YAAY,EAAE,CAAC;oBAClB,gBAAgB,EAAE,CAAC;gBACrB,CAAC;gBACD,wBAAwB,EAAE,CAAC;gBAC3B,qEAAqE;gBACrE,sEAAsE;gBACtE,gEAAgE;gBAChE,4CAA4C,CAAC,+BAA+B,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;QAED,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function destroyElementTemplateBackgroundRuntime(): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { render } from 'preact';
|
|
2
|
+
import { cancelElementTemplateRemovedSubtreeCleanup, resetElementTemplateCommitState } from './commit-hook.js';
|
|
3
|
+
import { resetElementTemplateHydrationListener } from './hydration-listener.js';
|
|
4
|
+
import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
5
|
+
import { clearEventState } from '../prop-adapters/event.js';
|
|
6
|
+
import { clearRefState, flushPendingRefs } from '../prop-adapters/ref.js';
|
|
7
|
+
import { __root } from '../runtime/page/root-instance.js';
|
|
8
|
+
export function destroyElementTemplateBackgroundRuntime() {
|
|
9
|
+
resetElementTemplateHydrationListener();
|
|
10
|
+
cancelElementTemplateRemovedSubtreeCleanup();
|
|
11
|
+
render(null, __root);
|
|
12
|
+
// Run user cleanup before dropping the backend side tables; after clearRefState
|
|
13
|
+
// the raw ref ownership needed to detach callbacks is gone.
|
|
14
|
+
flushPendingRefs();
|
|
15
|
+
resetElementTemplateCommitState();
|
|
16
|
+
clearEventState();
|
|
17
|
+
clearRefState();
|
|
18
|
+
backgroundElementTemplateInstanceManager.clear();
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=destroy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/element-template/background/destroy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,0CAA0C,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAE1D,MAAM,UAAU,uCAAuC;IACrD,qCAAqC,EAAE,CAAC;IACxC,0CAA0C,EAAE,CAAC;IAE7C,MAAM,CAAC,IAAI,EAAE,MAAkC,CAAC,CAAC;IACjD,gFAAgF;IAChF,4DAA4D;IAC5D,gBAAgB,EAAE,CAAC;IAEnB,+BAA+B,EAAE,CAAC;IAClC,eAAe,EAAE,CAAC;IAClB,aAAa,EAAE,CAAC;IAChB,wCAAwC,CAAC,KAAK,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BackgroundElementTemplateInstance } from './instance.js';
|
|
2
|
+
export interface BackgroundElementTemplateDocument {
|
|
3
|
+
createElement(type: string): BackgroundElementTemplateInstance;
|
|
4
|
+
createElementNS(ns: string, type: string): BackgroundElementTemplateInstance;
|
|
5
|
+
createTextNode(text: string): BackgroundElementTemplateInstance;
|
|
6
|
+
}
|
|
7
|
+
export declare function setupBackgroundElementTemplateDocument(): BackgroundElementTemplateDocument;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2024 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 } from 'preact';
|
|
5
|
+
import { BUILTIN_RAW_TEXT_TEMPLATE_KEY, BackgroundElementTemplateInstance } from './instance.js';
|
|
6
|
+
export function setupBackgroundElementTemplateDocument() {
|
|
7
|
+
const doc = {
|
|
8
|
+
createElement(type) {
|
|
9
|
+
return new BackgroundElementTemplateInstance(type);
|
|
10
|
+
},
|
|
11
|
+
createElementNS(_ns, type) {
|
|
12
|
+
return new BackgroundElementTemplateInstance(type);
|
|
13
|
+
},
|
|
14
|
+
createTextNode(text) {
|
|
15
|
+
return new BackgroundElementTemplateInstance(BUILTIN_RAW_TEXT_TEMPLATE_KEY, [text]);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
options.document = doc;
|
|
19
|
+
return doc;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/element-template/background/document.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,6BAA6B,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAQjG,MAAM,UAAU,sCAAsC;IACpD,MAAM,GAAG,GAAG;QACV,aAAa,CAAC,IAAY;YACxB,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,eAAe,CAAC,GAAW,EAAE,IAAY;YACvC,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,cAAc,CAAC,IAAY;YACzB,OAAO,IAAI,iCAAiC,CAAC,6BAA6B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;IAEF,OAAO,CAAC,QAAQ,GAAG,GAA0B,CAAC;IAE9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BackgroundElementTemplateInstance } from './instance.js';
|
|
2
|
+
import type { ElementTemplateUpdateCommandStream, SerializedElementTemplate } from '../protocol/types.js';
|
|
3
|
+
export declare function hydrate(serialized: SerializedElementTemplate, instance: BackgroundElementTemplateInstance): ElementTemplateUpdateCommandStream;
|
|
4
|
+
export declare function hydrateIntoContext(serialized: SerializedElementTemplate, instance: BackgroundElementTemplateInstance): boolean;
|