@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,135 @@
|
|
|
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 { RENDER_COMPONENT, ROOT } from '../../shared/render-constants.js';
|
|
6
|
+
import { hook } from '../../utils.js';
|
|
7
|
+
import { globalCommitContext } from '../background/commit-context.js';
|
|
8
|
+
const PerformanceTimingKeys = [
|
|
9
|
+
'updateSetStateTrigger',
|
|
10
|
+
'updateDiffVdomStart',
|
|
11
|
+
'updateDiffVdomEnd',
|
|
12
|
+
// updateSetStateTrigger, updateDiffVdomStart and updateDiffVdomEnd is deprecated
|
|
13
|
+
'diffVdomStart',
|
|
14
|
+
'diffVdomEnd',
|
|
15
|
+
'packChangesStart',
|
|
16
|
+
'packChangesEnd',
|
|
17
|
+
'parseChangesStart',
|
|
18
|
+
'parseChangesEnd',
|
|
19
|
+
'patchChangesStart',
|
|
20
|
+
'patchChangesEnd',
|
|
21
|
+
'hydrateParsePayloadStart',
|
|
22
|
+
'hydrateParsePayloadEnd',
|
|
23
|
+
'mtsRenderStart',
|
|
24
|
+
'mtsRenderEnd',
|
|
25
|
+
];
|
|
26
|
+
const PerformanceTimingFlags = {
|
|
27
|
+
reactLynxHydrate: 'react_lynx_hydrate',
|
|
28
|
+
};
|
|
29
|
+
const PipelineOrigins = {
|
|
30
|
+
reactLynxHydrate: 'reactLynxHydrate',
|
|
31
|
+
updateTriggeredByBts: 'updateTriggeredByBts',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated used by old timing api(setState timing flag)
|
|
35
|
+
*/
|
|
36
|
+
const PerfSpecificKey = '__lynx_timing_flag';
|
|
37
|
+
let timingFlag;
|
|
38
|
+
let shouldMarkDiffVdomStart = false;
|
|
39
|
+
let shouldMarkDiffVdomEnd = false;
|
|
40
|
+
let globalPipelineOptions;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated used by old timing api(setState timing flag)
|
|
43
|
+
*/
|
|
44
|
+
function markTimingLegacy(key, timingFlag_) {
|
|
45
|
+
switch (key) {
|
|
46
|
+
case 'updateSetStateTrigger': {
|
|
47
|
+
shouldMarkDiffVdomStart = true;
|
|
48
|
+
shouldMarkDiffVdomEnd = true;
|
|
49
|
+
timingFlag = timingFlag_;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case 'updateDiffVdomStart': {
|
|
53
|
+
if (!shouldMarkDiffVdomStart) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
shouldMarkDiffVdomStart = false;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'updateDiffVdomEnd': {
|
|
60
|
+
if (!shouldMarkDiffVdomEnd) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
shouldMarkDiffVdomEnd = false;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
lynx.getNativeApp().markTiming?.(timingFlag, key);
|
|
68
|
+
}
|
|
69
|
+
function beginPipeline(needTimestamps, pipelineOrigin, timingFlag) {
|
|
70
|
+
globalPipelineOptions = lynx.performance?._generatePipelineOptions?.();
|
|
71
|
+
if (globalPipelineOptions) {
|
|
72
|
+
globalPipelineOptions.needTimestamps = needTimestamps;
|
|
73
|
+
globalPipelineOptions.pipelineOrigin = pipelineOrigin;
|
|
74
|
+
globalPipelineOptions.dsl = 'reactLynx';
|
|
75
|
+
switch (pipelineOrigin) {
|
|
76
|
+
case PipelineOrigins.reactLynxHydrate:
|
|
77
|
+
globalPipelineOptions.stage = 'hydrate';
|
|
78
|
+
break;
|
|
79
|
+
case PipelineOrigins.updateTriggeredByBts:
|
|
80
|
+
globalPipelineOptions.stage = 'update';
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
lynx.performance?._onPipelineStart?.(globalPipelineOptions.pipelineID, globalPipelineOptions);
|
|
84
|
+
if (timingFlag) {
|
|
85
|
+
lynx.performance?._bindPipelineIdWithTimingFlag?.(globalPipelineOptions.pipelineID, timingFlag);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function setPipeline(pipeline) {
|
|
90
|
+
globalPipelineOptions = pipeline;
|
|
91
|
+
}
|
|
92
|
+
function markTiming(timestampKey, force) {
|
|
93
|
+
if (globalPipelineOptions && (force || globalPipelineOptions.needTimestamps)) {
|
|
94
|
+
lynx.performance?._markTiming?.(globalPipelineOptions.pipelineID, timestampKey);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function shouldStartUpdatePipeline() {
|
|
98
|
+
return globalCommitContext.ops.length > 0;
|
|
99
|
+
}
|
|
100
|
+
function initTimingAPI() {
|
|
101
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
102
|
+
const helper = () => {
|
|
103
|
+
// Check update ops to make sure this only runs after hydrate
|
|
104
|
+
if (__JS__ && shouldStartUpdatePipeline()) {
|
|
105
|
+
if (!globalPipelineOptions) {
|
|
106
|
+
beginPipeline(false, PipelineOrigins.updateTriggeredByBts);
|
|
107
|
+
markTiming('diffVdomStart', true);
|
|
108
|
+
}
|
|
109
|
+
if (shouldMarkDiffVdomStart) {
|
|
110
|
+
markTimingLegacy('updateDiffVdomStart');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
hook(options, RENDER_COMPONENT, (old, vnode, c) => {
|
|
115
|
+
helper();
|
|
116
|
+
/* v8 ignore start */
|
|
117
|
+
if (old) {
|
|
118
|
+
old(vnode, c);
|
|
119
|
+
}
|
|
120
|
+
/* v8 ignore stop */
|
|
121
|
+
});
|
|
122
|
+
hook(options, ROOT, (old, vnode, parentDom) => {
|
|
123
|
+
helper();
|
|
124
|
+
/* v8 ignore start */
|
|
125
|
+
if (old) {
|
|
126
|
+
old(vnode, parentDom);
|
|
127
|
+
}
|
|
128
|
+
/* v8 ignore stop */
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
export { PerformanceTimingFlags, PipelineOrigins, PerfSpecificKey, markTimingLegacy, initTimingAPI, beginPipeline, markTiming, setPipeline, globalPipelineOptions, };
|
|
135
|
+
//# sourceMappingURL=performance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../src/element-template/lynx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GAEG;AACH,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,qBAAqB,GACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function callDestroyLifetimeFun(): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
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 { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';
|
|
5
|
+
export function callDestroyLifetimeFun() {
|
|
6
|
+
destroyElementTemplateBackgroundRuntime();
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=callDestroyLifetimeFun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callDestroyLifetimeFun.js","sourceRoot":"","sources":["../../../src/element-template/native/callDestroyLifetimeFun.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AAEnF,MAAM,UAAU,sBAAsB;IACpC,uCAAuC,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@lynx-js/react/hooks';
|
|
@@ -0,0 +1,79 @@
|
|
|
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 '@lynx-js/react/hooks';
|
|
5
|
+
import { render } from 'preact';
|
|
6
|
+
import { callDestroyLifetimeFun } from './callDestroyLifetimeFun.js';
|
|
7
|
+
import { injectCalledByNative } from './main-thread-api.js';
|
|
8
|
+
import { installOnMtsDestruction } from './mts-destroy.js';
|
|
9
|
+
import { installElementTemplatePatchListener } from './patch-listener.js';
|
|
10
|
+
import { reloadBackground } from './reload.js';
|
|
11
|
+
import { runWithForceRootRender } from '../../core/forceRootRender.js';
|
|
12
|
+
import { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';
|
|
13
|
+
import { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';
|
|
14
|
+
import { updateCardData } from '../../core/lynx-update-data.js';
|
|
15
|
+
import { installElementTemplateCommitHook } from '../background/commit-hook.js';
|
|
16
|
+
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
17
|
+
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
18
|
+
import { BackgroundElementTemplateInstance } from '../background/instance.js';
|
|
19
|
+
import { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';
|
|
20
|
+
import { initProfileHook } from '../debug/profile.js';
|
|
21
|
+
import { setupLynxEnv } from '../lynx/env.js';
|
|
22
|
+
import { initTimingAPI } from '../lynx/performance.js';
|
|
23
|
+
import { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
24
|
+
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
25
|
+
function forceRootRender() {
|
|
26
|
+
runWithForceRootRender({
|
|
27
|
+
getRootVNode: () => __root.__jsx,
|
|
28
|
+
setRootVNode: (vnode) => {
|
|
29
|
+
// @ts-expect-error: __root.__jsx is a Preact VNode during background force render.
|
|
30
|
+
__root.__jsx = vnode;
|
|
31
|
+
},
|
|
32
|
+
render: () => {
|
|
33
|
+
render(__root.__jsx, __root);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const updateGlobalPropsOptions = {
|
|
38
|
+
forceRerender: forceRootRender,
|
|
39
|
+
};
|
|
40
|
+
function updateGlobalProps(newData) {
|
|
41
|
+
updateGlobalPropsCore(newData, updateGlobalPropsOptions);
|
|
42
|
+
}
|
|
43
|
+
function init() {
|
|
44
|
+
if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {
|
|
45
|
+
initElementTemplatePAPICallAlog();
|
|
46
|
+
}
|
|
47
|
+
if (__MAIN_THREAD__) {
|
|
48
|
+
installMainThreadHooks();
|
|
49
|
+
injectCalledByNative();
|
|
50
|
+
installElementTemplatePatchListener();
|
|
51
|
+
installOnMtsDestruction();
|
|
52
|
+
if (__PROFILE__) {
|
|
53
|
+
initProfileHook();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (__BACKGROUND__) {
|
|
57
|
+
console.log('experimental_useElementTemplate:', __USE_ELEMENT_TEMPLATE__);
|
|
58
|
+
setRoot(new BackgroundElementTemplateInstance('root'));
|
|
59
|
+
setupBackgroundElementTemplateDocument();
|
|
60
|
+
installElementTemplateHydrationListener();
|
|
61
|
+
resetEventStateForRuntime();
|
|
62
|
+
lynxCoreInject.tt.callDestroyLifetimeFun = callDestroyLifetimeFun;
|
|
63
|
+
lynxCoreInject.tt.publishEvent = publishEvent;
|
|
64
|
+
lynxCoreInject.tt.publicComponentEvent = publicComponentEvent;
|
|
65
|
+
lynxCoreInject.tt.updateGlobalProps = updateGlobalProps;
|
|
66
|
+
lynxCoreInject.tt.updateCardData = updateCardData;
|
|
67
|
+
lynxCoreInject.tt.onAppReload = reloadBackground;
|
|
68
|
+
installElementTemplateCommitHook();
|
|
69
|
+
if (process.env['NODE_ENV'] !== 'test') {
|
|
70
|
+
initTimingAPI();
|
|
71
|
+
if (lynx.performance?.isProfileRecording?.()) {
|
|
72
|
+
initProfileHook();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
setupLynxEnv();
|
|
77
|
+
}
|
|
78
|
+
init();
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/native/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DA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EAAE,CAAC,cAAc,GAAG,cAAc,CAAC;QAClD,cAAc,CAAC,EAAE,CAAC,WAAW,GAAG,gBAAgB,CAAC;QACjD,gCAAgC,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,EAAE,CAAC;YACvC,aAAa,EAAE,CAAC;YAChB,IAAI,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;gBAC7C,eAAe,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,YAAY,EAAE,CAAC;AACjB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 { reloadMainThread } from './reload.js';
|
|
5
|
+
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
6
|
+
import { __page, createElementTemplatePage, setupPage } from '../runtime/page/page.js';
|
|
7
|
+
import { renderMainThread, resetMainThreadRootRefs } from '../runtime/render/render-main-thread.js';
|
|
8
|
+
function injectCalledByNative() {
|
|
9
|
+
const calledByNative = {
|
|
10
|
+
renderPage,
|
|
11
|
+
updatePage,
|
|
12
|
+
updateGlobalProps,
|
|
13
|
+
getPageData: function () {
|
|
14
|
+
return null;
|
|
15
|
+
},
|
|
16
|
+
removeComponents: function () { },
|
|
17
|
+
};
|
|
18
|
+
Object.assign(globalThis, calledByNative);
|
|
19
|
+
}
|
|
20
|
+
function renderPage(data) {
|
|
21
|
+
lynx.__initData = data ?? {};
|
|
22
|
+
setupPage(createElementTemplatePage());
|
|
23
|
+
resetMainThreadRootRefs();
|
|
24
|
+
renderMainThread();
|
|
25
|
+
}
|
|
26
|
+
function updatePage(data, options) {
|
|
27
|
+
if (__FIRST_SCREEN_SYNC_TIMING__ !== 'immediately') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (options?.reloadTemplate) {
|
|
31
|
+
reloadMainThread(data, options);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
applyUpdatePageData(data, options);
|
|
35
|
+
__FlushElementTree(__page, options ?? {});
|
|
36
|
+
}
|
|
37
|
+
function updateGlobalProps(_data, options) {
|
|
38
|
+
if (options) {
|
|
39
|
+
__FlushElementTree(__page, options);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
__FlushElementTree();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export { injectCalledByNative };
|
|
49
|
+
//# sourceMappingURL=main-thread-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-api.js","sourceRoot":"","sources":["../../../src/element-template/native/main-thread-api.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAEpG,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAqB;QACvC,UAAU;QACV,UAAU;QACV,iBAAiB;QACjB,WAAW,EAAE;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB,EAAE,cAAkB,CAAC;KACtC,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC;IAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACvC,uBAAuB,EAAE,CAAC;IAC1B,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC,EAAE,OAA0B;IACvF,IAAI,4BAA4B,KAAK,aAAa,EAAE,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,kBAAkB,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAE,OAA0B;IACnE,IAAI,OAAO,EAAE,CAAC;QACZ,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,kBAAkB,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
5
|
+
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
6
|
+
export function installOnMtsDestruction() {
|
|
7
|
+
lynx.getNative?.().addEventListener('__DestroyLifetime', onMtsDestruction);
|
|
8
|
+
}
|
|
9
|
+
export function onMtsDestruction() {
|
|
10
|
+
const performance = lynx.performance;
|
|
11
|
+
performance?.profileStart?.('ReactLynx::onMtsDestruction');
|
|
12
|
+
try {
|
|
13
|
+
destroyElementTemplateMainThreadRuntime();
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
performance?.profileEnd?.();
|
|
17
|
+
lynx.getNative?.().removeEventListener('__DestroyLifetime', onMtsDestruction);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function destroyElementTemplateMainThreadRuntime() {
|
|
21
|
+
let patchListenerResetError;
|
|
22
|
+
let didPatchListenerResetThrow = false;
|
|
23
|
+
try {
|
|
24
|
+
resetElementTemplatePatchListener();
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
patchListenerResetError = error;
|
|
28
|
+
didPatchListenerResetThrow = true;
|
|
29
|
+
}
|
|
30
|
+
// The registry is the main-thread strong-reference owner for ET refs. Clear it
|
|
31
|
+
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
32
|
+
elementTemplateRegistry.clear();
|
|
33
|
+
if (didPatchListenerResetThrow) {
|
|
34
|
+
throw patchListenerResetError;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=mts-destroy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mts-destroy.js","sourceRoot":"","sources":["../../../src/element-template/native/mts-destroy.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACrC,WAAW,EAAE,YAAY,EAAE,CAAC,6BAA6B,CAAC,CAAC;IAC3D,IAAI,CAAC;QACH,uCAAuC,EAAE,CAAC;IAC5C,CAAC;YAAS,CAAC;QACT,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uCAAuC;IACrD,IAAI,uBAAgC,CAAC;IACrC,IAAI,0BAA0B,GAAG,KAAK,CAAC;IACvC,IAAI,CAAC;QACH,iCAAiC,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uBAAuB,GAAG,KAAK,CAAC;QAChC,0BAA0B,GAAG,IAAI,CAAC;IACpC,CAAC;IAED,+EAA+E;IAC/E,iFAAiF;IACjF,uBAAuB,CAAC,KAAK,EAAE,CAAC;IAEhC,IAAI,0BAA0B,EAAE,CAAC;QAC/B,MAAM,uBAAuB,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { getReloadVersion } from '../../core/reload-version.js';
|
|
5
|
+
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
6
|
+
import { markTiming, setPipeline } from '../lynx/performance.js';
|
|
7
|
+
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
8
|
+
import { __page } from '../runtime/page/page.js';
|
|
9
|
+
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
10
|
+
let listener;
|
|
11
|
+
export function installElementTemplatePatchListener() {
|
|
12
|
+
resetElementTemplatePatchListener();
|
|
13
|
+
listener = (event) => {
|
|
14
|
+
const { data } = event;
|
|
15
|
+
const payload = data;
|
|
16
|
+
if (typeof payload?.reloadVersion === 'number' && payload.reloadVersion < getReloadVersion()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const hasOps = Array.isArray(payload?.ops) && payload.ops.length > 0;
|
|
20
|
+
const flushOptions = payload?.flushOptions ?? {};
|
|
21
|
+
const pipelineOptions = flushOptions.pipelineOptions;
|
|
22
|
+
setPipeline(pipelineOptions);
|
|
23
|
+
const flowIds = Array.isArray(payload?.flowIds) && payload.flowIds.length > 0
|
|
24
|
+
? payload.flowIds
|
|
25
|
+
: undefined;
|
|
26
|
+
const shouldProfilePatch = hasOps
|
|
27
|
+
&& !!flowIds
|
|
28
|
+
&& typeof lynx.performance?.profileStart === 'function'
|
|
29
|
+
&& typeof lynx.performance?.profileEnd === 'function';
|
|
30
|
+
if (shouldProfilePatch) {
|
|
31
|
+
lynx.performance.profileStart('ReactLynx::patch', {
|
|
32
|
+
flowId: flowIds[0],
|
|
33
|
+
flowIds,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (hasOps) {
|
|
37
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
38
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
39
|
+
+ JSON.stringify({
|
|
40
|
+
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
41
|
+
flushOptions,
|
|
42
|
+
flowIds,
|
|
43
|
+
}, null, 2));
|
|
44
|
+
}
|
|
45
|
+
markTiming('mtsRenderStart');
|
|
46
|
+
markTiming('parseChangesStart');
|
|
47
|
+
markTiming('parseChangesEnd');
|
|
48
|
+
markTiming('patchChangesStart');
|
|
49
|
+
try {
|
|
50
|
+
applyElementTemplateUpdateCommands(payload.ops);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
markTiming('patchChangesEnd');
|
|
54
|
+
markTiming('mtsRenderEnd');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
__FlushElementTree(__page, flushOptions);
|
|
58
|
+
if (shouldProfilePatch) {
|
|
59
|
+
lynx.performance.profileEnd();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.update, listener);
|
|
63
|
+
}
|
|
64
|
+
export function resetElementTemplatePatchListener() {
|
|
65
|
+
if (listener) {
|
|
66
|
+
lynx.getJSContext().removeEventListener(ElementTemplateLifecycleConstant.update, listener);
|
|
67
|
+
}
|
|
68
|
+
listener = undefined;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=patch-listener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAErF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAEzE,IAAI,QAES,CAAC;AAEd,MAAM,UAAU,mCAAmC;IACjD,iCAAiC,EAAE,CAAC;IAEpC,QAAQ,GAAG,CAAC,KAAwB,EAAE,EAAE;QACtC,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QACvB,MAAM,OAAO,GAAG,IAA0C,CAAC;QAC3D,IAAI,OAAO,OAAO,EAAE,aAAa,KAAK,QAAQ,IAAI,OAAO,CAAC,aAAa,GAAG,gBAAgB,EAAE,EAAE,CAAC;YAC7F,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACrE,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,EAAE,CAAC;QACjD,MA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C,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEzC,IAAI,kBAAkB,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QAChC,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,YAAY,EAAE,CAAC,gBAAgB,CAClC,gCAAgC,CAAC,MAAM,EACvC,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iCAAiC;IAC/C,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,EAAE,CAAC,mBAAmB,CACrC,gCAAgC,CAAC,MAAM,EACvC,QAAQ,CACT,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { render } from 'preact';
|
|
5
|
+
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
6
|
+
import { increaseReloadVersion } from '../../core/reload-version.js';
|
|
7
|
+
import { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';
|
|
8
|
+
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
9
|
+
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
10
|
+
import { BackgroundElementTemplateInstance } from '../background/instance.js';
|
|
11
|
+
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
12
|
+
import { resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
13
|
+
import { __page } from '../runtime/page/page.js';
|
|
14
|
+
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
15
|
+
import { removeMainThreadRootRefs, renderMainThread } from '../runtime/render/render-main-thread.js';
|
|
16
|
+
import { resetTemplateId } from '../runtime/template/handle.js';
|
|
17
|
+
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
18
|
+
export function reloadMainThread(data, options) {
|
|
19
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
20
|
+
profileStart('ReactLynx::reloadMainThread');
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
increaseReloadVersion();
|
|
24
|
+
applyUpdatePageData(data, options);
|
|
25
|
+
elementTemplateRegistry.clear();
|
|
26
|
+
resetTemplateId();
|
|
27
|
+
const oldRoot = __root;
|
|
28
|
+
removeMainThreadRootRefs();
|
|
29
|
+
setRoot({ __jsx: oldRoot.__jsx });
|
|
30
|
+
renderMainThread();
|
|
31
|
+
__FlushElementTree(__page, options);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
35
|
+
profileEnd();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function reloadBackground(updateData) {
|
|
40
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
41
|
+
profileStart('ReactLynx::reloadBackground');
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const jsx = __root.__jsx;
|
|
45
|
+
destroyElementTemplateBackgroundRuntime();
|
|
46
|
+
increaseReloadVersion();
|
|
47
|
+
// Reload creates a new object so InitData Provider / Consumer observers do
|
|
48
|
+
// not retain the pre-reload object identity.
|
|
49
|
+
lynx.__initData = Object.assign({}, lynx.__initData);
|
|
50
|
+
applyUpdatePageData(updateData);
|
|
51
|
+
setRoot(new BackgroundElementTemplateInstance('root'));
|
|
52
|
+
__root.__jsx = jsx;
|
|
53
|
+
setupBackgroundElementTemplateDocument();
|
|
54
|
+
installElementTemplateHydrationListener();
|
|
55
|
+
resetEventStateForRuntime();
|
|
56
|
+
render(jsx, __root);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
60
|
+
profileEnd();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=reload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../../../src/element-template/native/reload.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,UAAU,gBAAgB,CAAC,IAAa,EAAE,OAAyB;IACvE,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,qBAAqB,EAAE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ACtD,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEventValue(handleId: number, attrSlotIndex: number, eventKey?: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export function getEventValue(handleId, attrSlotIndex, eventKey = '') {
|
|
5
|
+
return `${handleId}:${attrSlotIndex}:${eventKey}`;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=event-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-value.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/event-value.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,aAAqB,EACrB,QAAQ,GAAG,EAAE;IAEb,OAAO,GAAG,QAAQ,IAAI,aAAa,IAAI,QAAQ,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type EtEventHandler = (data: EventDataType) => unknown;
|
|
2
|
+
export declare function clearEventState(): void;
|
|
3
|
+
export declare function clearPendingEvents(): void;
|
|
4
|
+
export declare function resetEventStateForRuntime(): void;
|
|
5
|
+
export declare function getEventHandlerForEventValue(eventValue: string): EtEventHandler | undefined;
|
|
6
|
+
export declare function publishEvent(eventValue: string, data: EventDataType): void;
|
|
7
|
+
export declare function publicComponentEvent(_componentId: string, eventValue: string, data: EventDataType): void;
|
|
8
|
+
export declare function flushPendingEvents(): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { backgroundElementTemplateInstanceManager } from '../background/manager.js';
|
|
5
|
+
const pendingEvents = [];
|
|
6
|
+
let queuePendingEvents = false;
|
|
7
|
+
function dispatchEvent(eventValue, data) {
|
|
8
|
+
const handler = backgroundElementTemplateInstanceManager.getRawAttributeValueByEventValue(eventValue);
|
|
9
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
10
|
+
console.alog?.(`[ReactLynxDebug] ElementTemplate BTS received event:\n${JSON.stringify({
|
|
11
|
+
eventValue,
|
|
12
|
+
type: data.type,
|
|
13
|
+
jsFunctionName: typeof handler === 'function' ? handler.name : '',
|
|
14
|
+
hasHandler: typeof handler === 'function',
|
|
15
|
+
}, null, 2)}`);
|
|
16
|
+
}
|
|
17
|
+
if (typeof handler !== 'function') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
handler(data);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
lynx.reportError(error);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
export function clearEventState() {
|
|
29
|
+
clearPendingEvents();
|
|
30
|
+
queuePendingEvents = false;
|
|
31
|
+
}
|
|
32
|
+
export function clearPendingEvents() {
|
|
33
|
+
pendingEvents.length = 0;
|
|
34
|
+
}
|
|
35
|
+
export function resetEventStateForRuntime() {
|
|
36
|
+
clearEventState();
|
|
37
|
+
queuePendingEvents = true;
|
|
38
|
+
}
|
|
39
|
+
export function getEventHandlerForEventValue(eventValue) {
|
|
40
|
+
const handler = backgroundElementTemplateInstanceManager.getRawAttributeValueByEventValue(eventValue);
|
|
41
|
+
return typeof handler === 'function' ? handler : undefined;
|
|
42
|
+
}
|
|
43
|
+
export function publishEvent(eventValue, data) {
|
|
44
|
+
if (dispatchEvent(eventValue, data)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (queuePendingEvents) {
|
|
48
|
+
pendingEvents.push([eventValue, data]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function publicComponentEvent(_componentId, eventValue, data) {
|
|
52
|
+
publishEvent(eventValue, data);
|
|
53
|
+
}
|
|
54
|
+
export function flushPendingEvents() {
|
|
55
|
+
queuePendingEvents = false;
|
|
56
|
+
if (pendingEvents.length === 0) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const events = pendingEvents.splice(0);
|
|
60
|
+
for (const [eventValue, data] of events) {
|
|
61
|
+
dispatchEvent(eventValue, data);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/event.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,wCAAwC,EAAE,MAAM,0BAA0B,CAAC;AAIpF,MAAM,aAAa,GAAqD,EAAE,CAAC;AAC3E,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,SAAS,aAAa,CAAC,UAAkB,EAAE,IAAmB;IAC5D,MAAM,OAAO,GAAG,wCAAwC,CAAC,gCAAgC,CAAC,UAAU,CAAC,CAAC;IACtG,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,EAAE,CACZ,yDACE,IAAI,CAAC,SAAS,CACZ;YACE,UAAU;YACV,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc,EAAE,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACjE,UAAU,EAAE,OAAO,OAAO,KAAK,UAAU;SAC1C,EACD,IAAI,EACJ,CAAC,CAEL,EAAE,CACH,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC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IACD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvC,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;QACxC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SelectorRefProxy } from '../../core/ref.js';
|
|
2
|
+
import type { OrdinaryRef, RefProxyForwardedMethods } from '../../core/ref.js';
|
|
3
|
+
import type { SerializableValue } from '../protocol/types.js';
|
|
4
|
+
export type EtRef = OrdinaryRef<ElementTemplateRefProxy>;
|
|
5
|
+
export declare function getRefValue(handleId: number, attrSlotIndex: number): string;
|
|
6
|
+
export declare function flushDelayedRefUiOps(): void;
|
|
7
|
+
export declare function clearDelayedRefUiOps(): void;
|
|
8
|
+
export declare class ElementTemplateRefProxy extends SelectorRefProxy<ElementTemplateRefProxy> {
|
|
9
|
+
private readonly handleId;
|
|
10
|
+
private readonly attrSlotIndex;
|
|
11
|
+
constructor(handleId: number, attrSlotIndex: number);
|
|
12
|
+
protected createProxyTarget(): ElementTemplateRefProxy;
|
|
13
|
+
protected runOrDelay(task: () => void): void;
|
|
14
|
+
get selector(): string;
|
|
15
|
+
}
|
|
16
|
+
export interface ElementTemplateRefProxy extends RefProxyForwardedMethods<ElementTemplateRefProxy> {
|
|
17
|
+
}
|
|
18
|
+
export declare function getRefFromValue(value: unknown): EtRef | null;
|
|
19
|
+
export declare function getSpreadRefFromValue(value: unknown): EtRef | null | undefined;
|
|
20
|
+
export declare function prepareRefAttrSlot(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null;
|
|
21
|
+
export declare function prepareSpreadRefAttrValue(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null | undefined;
|
|
22
|
+
export declare function queueRefAttrUpdate(oldValue: unknown, newValue: unknown, handleId: number, attrSlotIndex: number): void;
|
|
23
|
+
export declare function flushPendingRefs(): void;
|
|
24
|
+
export declare function clearPendingRefs(): void;
|
|
25
|
+
export declare function hasPendingRefs(): boolean;
|
|
26
|
+
export declare function clearRefState(): void;
|