@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,71 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Implements the IFR (Instant First-Frame Rendering) on main thread.
|
|
6
|
+
*/
|
|
7
|
+
import { renderOpcodesIntoElementTemplate } from './render-opcodes.js';
|
|
8
|
+
import { render as renderToString } from './render-to-opcodes.js';
|
|
9
|
+
import { getReloadVersion } from '../../../core/reload-version.js';
|
|
10
|
+
import { profileEnd, profileStart } from '../../debug/profile.js';
|
|
11
|
+
import { ElementTemplateLifecycleConstant } from '../../protocol/lifecycle-constant.js';
|
|
12
|
+
import { insertRootIntoPage, removeRootFromPage } from '../page/page.js';
|
|
13
|
+
import { __root } from '../page/root-instance.js';
|
|
14
|
+
// ET reload reuses the native page, so the main-thread render path owns the
|
|
15
|
+
// root refs it appended and can remove only those roots before rebuilding.
|
|
16
|
+
let mainThreadRootRefs = [];
|
|
17
|
+
function resetMainThreadRootRefs() {
|
|
18
|
+
mainThreadRootRefs = [];
|
|
19
|
+
}
|
|
20
|
+
function removeMainThreadRootRefs() {
|
|
21
|
+
const rootRefs = mainThreadRootRefs;
|
|
22
|
+
mainThreadRootRefs = [];
|
|
23
|
+
for (const rootRef of rootRefs) {
|
|
24
|
+
removeRootFromPage(rootRef);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function renderMainThread() {
|
|
28
|
+
let opcodes;
|
|
29
|
+
profileStart('ReactLynx::renderMainThread');
|
|
30
|
+
try {
|
|
31
|
+
opcodes = renderToString(__root.__jsx, undefined);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
lynx.reportError(e);
|
|
35
|
+
opcodes = [];
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
profileEnd();
|
|
39
|
+
}
|
|
40
|
+
profileStart('ReactLynx::renderOpcodes');
|
|
41
|
+
try {
|
|
42
|
+
const { rootRefs } = renderOpcodesIntoElementTemplate(opcodes);
|
|
43
|
+
for (const rootRef of rootRefs) {
|
|
44
|
+
insertRootIntoPage(rootRef);
|
|
45
|
+
}
|
|
46
|
+
mainThreadRootRefs = rootRefs;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
profileEnd();
|
|
50
|
+
}
|
|
51
|
+
profileStart('ReactLynx::packSerializedETInstance');
|
|
52
|
+
try {
|
|
53
|
+
const instances = [];
|
|
54
|
+
for (const rootRef of mainThreadRootRefs) {
|
|
55
|
+
instances.push(__SerializeElementTemplate(rootRef));
|
|
56
|
+
}
|
|
57
|
+
const payload = {
|
|
58
|
+
instances,
|
|
59
|
+
reloadVersion: getReloadVersion(),
|
|
60
|
+
};
|
|
61
|
+
lynx.getJSContext().dispatchEvent({
|
|
62
|
+
type: ElementTemplateLifecycleConstant.hydrate,
|
|
63
|
+
data: payload,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
profileEnd();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export { removeMainThreadRootRefs, renderMainThread, resetMainThreadRootRefs };
|
|
71
|
+
//# sourceMappingURL=render-main-thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-main-thread.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;GAEG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sCAAsC,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,4EAA4E;AAC5E,2EAA2E;AAC3E,IAAI,kBAAkB,GAAiB,EAAE,CAAC;AAE1C,SAAS,uBAAuB;IAC9B,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,wBAAwB;IAC/B,MAAM,QA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,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,UAAU,EAAE,CAAC;IACf,CAAC;AACH,CAAC;AAED,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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 { __OpAttr, __OpBegin, __OpEnd, __OpSlot, __OpText } from './render-to-opcodes.js';
|
|
5
|
+
import { __etAttrPlanMap } from '../template/attr-slot-plan.js';
|
|
6
|
+
import { createElementTemplateWithReservedHandle, reserveElementTemplateId } from '../template/handle.js';
|
|
7
|
+
const BUILTIN_RAW_TEXT_TEMPLATE_KEY = '_et_builtin_raw_text';
|
|
8
|
+
function appendChildToParent(parentTemplateKey, parentActiveElementSlot, rootRefs, elementRef) {
|
|
9
|
+
/* v8 ignore start -- stackTop is always rooted with `null`, never `undefined`. */
|
|
10
|
+
if (parentTemplateKey === undefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
/* v8 ignore end */
|
|
14
|
+
if (parentTemplateKey === null) {
|
|
15
|
+
rootRefs.push(elementRef);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!parentActiveElementSlot) {
|
|
19
|
+
throw new Error(`Template '${parentTemplateKey}' received a child outside of any element slot.`);
|
|
20
|
+
}
|
|
21
|
+
parentActiveElementSlot.push(elementRef);
|
|
22
|
+
}
|
|
23
|
+
export function renderOpcodesIntoElementTemplate(opcodes) {
|
|
24
|
+
const rootRefs = [];
|
|
25
|
+
const templateKeyStack = [null];
|
|
26
|
+
const attributeSlotsStack = [undefined];
|
|
27
|
+
const elementSlotsStack = [undefined];
|
|
28
|
+
const activeElementSlotStack = [undefined];
|
|
29
|
+
let stackTop = 0;
|
|
30
|
+
for (let i = 0; i < opcodes.length;) {
|
|
31
|
+
const opcode = opcodes[i];
|
|
32
|
+
switch (opcode) {
|
|
33
|
+
case __OpBegin: {
|
|
34
|
+
const vnode = opcodes[i + 1];
|
|
35
|
+
stackTop += 1;
|
|
36
|
+
templateKeyStack[stackTop] = vnode.type;
|
|
37
|
+
attributeSlotsStack[stackTop] = undefined;
|
|
38
|
+
elementSlotsStack[stackTop] = undefined;
|
|
39
|
+
activeElementSlotStack[stackTop] = undefined;
|
|
40
|
+
i += 2;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case __OpEnd: {
|
|
44
|
+
if (stackTop === 0) {
|
|
45
|
+
throw new Error('Instruction mismatch: Popped root frame at __OpEnd');
|
|
46
|
+
}
|
|
47
|
+
const templateKey = templateKeyStack[stackTop];
|
|
48
|
+
const attributeSlots = attributeSlotsStack[stackTop];
|
|
49
|
+
const elementSlots = elementSlotsStack[stackTop];
|
|
50
|
+
stackTop -= 1;
|
|
51
|
+
// If templateKey is null, it means we popped the root frame?
|
|
52
|
+
// But __OpEnd should pair with __OpBegin.
|
|
53
|
+
// The Root frame is manually pushed and has no __OpBegin.
|
|
54
|
+
// So we should never pop the Root frame via __OpEnd unless there's an extra End.
|
|
55
|
+
if (templateKey === null) {
|
|
56
|
+
// This should effectively not happen if opcodes are balanced?
|
|
57
|
+
// Actually, if we are at root, and opcode has __OpEnd, it implies we are closing a component.
|
|
58
|
+
// The structure is: Root -> [Begin ... End] -> Root.
|
|
59
|
+
// Wait, if opcodes list ends, loop finishes.
|
|
60
|
+
// __OpEnd corresponds to a component.
|
|
61
|
+
// So if we pop, we must get a valid component frame.
|
|
62
|
+
/* v8 ignore start -- the synthetic root frame cannot be popped by balanced opcodes. */
|
|
63
|
+
throw new Error('Instruction mismatch: Popped root frame at __OpEnd');
|
|
64
|
+
/* v8 ignore end */
|
|
65
|
+
}
|
|
66
|
+
const concreteTemplateKey = templateKey;
|
|
67
|
+
const parentTemplateKey = templateKeyStack[stackTop];
|
|
68
|
+
const parentActiveElementSlot = activeElementSlotStack[stackTop];
|
|
69
|
+
const attrPlan = __etAttrPlanMap[concreteTemplateKey];
|
|
70
|
+
const handleId = reserveElementTemplateId();
|
|
71
|
+
let elementRef;
|
|
72
|
+
if (attrPlan === undefined) {
|
|
73
|
+
elementRef = createElementTemplateWithReservedHandle(handleId, concreteTemplateKey, null, attributeSlots ?? null, elementSlots ?? null);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const preparedAttributeSlots = attributeSlots?.slice() ?? [];
|
|
77
|
+
for (let planIndex = 0; planIndex < attrPlan.length; planIndex += 2) {
|
|
78
|
+
const attrSlotIndex = attrPlan[planIndex];
|
|
79
|
+
const adapter = attrPlan[planIndex + 1];
|
|
80
|
+
preparedAttributeSlots[attrSlotIndex] = adapter(handleId, attrSlotIndex, preparedAttributeSlots[attrSlotIndex]);
|
|
81
|
+
}
|
|
82
|
+
elementRef = createElementTemplateWithReservedHandle(handleId, concreteTemplateKey, null, preparedAttributeSlots, elementSlots ?? null);
|
|
83
|
+
}
|
|
84
|
+
appendChildToParent(parentTemplateKey, parentActiveElementSlot, rootRefs, elementRef);
|
|
85
|
+
i += 1;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case __OpAttr: {
|
|
89
|
+
const name = opcodes[i + 1];
|
|
90
|
+
const value = opcodes[i + 2];
|
|
91
|
+
if (name === 'attributeSlots') {
|
|
92
|
+
attributeSlotsStack[stackTop] = value;
|
|
93
|
+
}
|
|
94
|
+
i += 3;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case __OpSlot: {
|
|
98
|
+
const slotId = opcodes[i + 1];
|
|
99
|
+
const elementSlots = elementSlotsStack[stackTop] ?? (elementSlotsStack[stackTop] = []);
|
|
100
|
+
const activeElementSlot = elementSlots[slotId] = [];
|
|
101
|
+
activeElementSlotStack[stackTop] = activeElementSlot;
|
|
102
|
+
i += 2;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case __OpText: {
|
|
106
|
+
const text = opcodes[i + 1];
|
|
107
|
+
const handleId = reserveElementTemplateId();
|
|
108
|
+
const textRef = createElementTemplateWithReservedHandle(handleId, BUILTIN_RAW_TEXT_TEMPLATE_KEY, null, [String(text)], []);
|
|
109
|
+
const parentTemplateKey = templateKeyStack[stackTop];
|
|
110
|
+
if (parentTemplateKey === null) {
|
|
111
|
+
rootRefs.push(textRef);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const activeElementSlot = activeElementSlotStack[stackTop];
|
|
115
|
+
if (!activeElementSlot) {
|
|
116
|
+
throw new Error(`Template '${parentTemplateKey}' received a text child outside of any element slot.`);
|
|
117
|
+
}
|
|
118
|
+
activeElementSlot.push(textRef);
|
|
119
|
+
}
|
|
120
|
+
i += 2;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
// Unknown opcode, maybe skip? or throw?
|
|
125
|
+
// renderToString loop increments manually.
|
|
126
|
+
// If we hit here, something is desync.
|
|
127
|
+
throw new Error(`Unknown opcode: ${opcode}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
rootRefs,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=render-opcodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-opcodes.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-opcodes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,uCAAuC,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAE1G,MAAM,6BAA6B,GAAG,sBA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J,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render Preact JSX + Components to an HTML string.
|
|
3
|
+
* @param {VNode} vnode JSX Element / VNode to render
|
|
4
|
+
* @param {object} [context] Initial root context object
|
|
5
|
+
*/
|
|
6
|
+
export declare function renderToString(vnode: any, context: any): any[];
|
|
7
|
+
export declare const __OpBegin = 0;
|
|
8
|
+
export declare const __OpEnd = 1;
|
|
9
|
+
export declare const __OpAttr = 2;
|
|
10
|
+
export declare const __OpText = 3;
|
|
11
|
+
export declare const __OpSlot = 4;
|
|
12
|
+
export default renderToString;
|
|
13
|
+
export declare const render: typeof renderToString;
|
|
14
|
+
export declare const renderToStaticMarkup: typeof renderToString;
|
|
@@ -0,0 +1,278 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Implements rendering to opcodes.
|
|
6
|
+
* This module is modified from preact-render-to-string@6.0.3 to generate
|
|
7
|
+
* opcodes instead of HTML strings for Lynx.
|
|
8
|
+
*/
|
|
9
|
+
// @ts-nocheck
|
|
10
|
+
import { Fragment, h, options } from 'preact';
|
|
11
|
+
import { CHILDREN, COMMIT, COMPONENT, DIFF, DIFF2, DIFFED, DIRTY, NEXT_STATE, PARENT, RENDER, SKIP_EFFECTS, VNODE, } from '../../../shared/render-constants.js';
|
|
12
|
+
/** @typedef {import('preact').VNode} VNode */
|
|
13
|
+
const EMPTY_ARR = [];
|
|
14
|
+
const isArray = /* @__PURE__ */ Array.isArray;
|
|
15
|
+
const assign = /* @__PURE__ */ Object.assign;
|
|
16
|
+
// Global state for the current render pass
|
|
17
|
+
let beforeDiff, beforeDiff2, afterDiff, renderHook, ummountHook;
|
|
18
|
+
/**
|
|
19
|
+
* Render Preact JSX + Components to an HTML string.
|
|
20
|
+
* @param {VNode} vnode JSX Element / VNode to render
|
|
21
|
+
* @param {object} [context] Initial root context object
|
|
22
|
+
*/
|
|
23
|
+
export function renderToString(vnode, context) {
|
|
24
|
+
// Performance optimization: `renderToString` is synchronous and we
|
|
25
|
+
// therefore don't execute any effects. To do that we pass an empty
|
|
26
|
+
// array to `options._commit` (`__c`). But we can go one step further
|
|
27
|
+
// and avoid a lot of dirty checks and allocations by setting
|
|
28
|
+
// `options._skipEffects` (`__s`) too.
|
|
29
|
+
const previousSkipEffects = options[SKIP_EFFECTS];
|
|
30
|
+
options[SKIP_EFFECTS] = true;
|
|
31
|
+
// store options hooks once before each synchronous render call
|
|
32
|
+
beforeDiff = options[DIFF];
|
|
33
|
+
beforeDiff2 = options[DIFF2];
|
|
34
|
+
afterDiff = options[DIFFED];
|
|
35
|
+
renderHook = options[RENDER];
|
|
36
|
+
ummountHook = options.unmount;
|
|
37
|
+
const parent = h(Fragment, null);
|
|
38
|
+
parent[CHILDREN] = [vnode];
|
|
39
|
+
const opcodes = [];
|
|
40
|
+
try {
|
|
41
|
+
_renderToString(vnode, context || EMPTY_OBJ, parent, opcodes);
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
// options._commit, we don't schedule any effects in this library right now,
|
|
45
|
+
// so we can pass an empty queue to this hook.
|
|
46
|
+
if (options[COMMIT])
|
|
47
|
+
options[COMMIT](vnode, EMPTY_ARR);
|
|
48
|
+
options[SKIP_EFFECTS] = previousSkipEffects;
|
|
49
|
+
EMPTY_ARR.length = 0;
|
|
50
|
+
}
|
|
51
|
+
return opcodes;
|
|
52
|
+
}
|
|
53
|
+
// Installed as setState/forceUpdate for function components
|
|
54
|
+
/* v8 ignore start */
|
|
55
|
+
function markAsDirty() {
|
|
56
|
+
this.__d = true;
|
|
57
|
+
}
|
|
58
|
+
/* v8 ignore stop */
|
|
59
|
+
const EMPTY_OBJ = {};
|
|
60
|
+
export const __OpBegin = 0;
|
|
61
|
+
export const __OpEnd = 1;
|
|
62
|
+
export const __OpAttr = 2;
|
|
63
|
+
export const __OpText = 3;
|
|
64
|
+
export const __OpSlot = 4;
|
|
65
|
+
/**
|
|
66
|
+
* @param {VNode} vnode
|
|
67
|
+
* @param {Record<string, unknown>} context
|
|
68
|
+
*/
|
|
69
|
+
function renderClassComponent(vnode, context) {
|
|
70
|
+
const type = /** @type {import("preact").ComponentClass<typeof vnode.props>} */ (vnode.type);
|
|
71
|
+
let c;
|
|
72
|
+
if (vnode[COMPONENT]) {
|
|
73
|
+
c = vnode[COMPONENT];
|
|
74
|
+
c.state = c[NEXT_STATE];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
c = new type(vnode.props, context);
|
|
78
|
+
}
|
|
79
|
+
vnode[COMPONENT] = c;
|
|
80
|
+
c[VNODE] = vnode;
|
|
81
|
+
c.props = vnode.props;
|
|
82
|
+
c.context = context;
|
|
83
|
+
// turn off stateful re-rendering:
|
|
84
|
+
c[DIRTY] = true;
|
|
85
|
+
if (c.state == null)
|
|
86
|
+
c.state = EMPTY_OBJ;
|
|
87
|
+
if (c[NEXT_STATE] == null) {
|
|
88
|
+
c[NEXT_STATE] = c.state;
|
|
89
|
+
}
|
|
90
|
+
if (type.getDerivedStateFromProps) {
|
|
91
|
+
c.state = assign({}, c.state, type.getDerivedStateFromProps(c.props, c.state));
|
|
92
|
+
}
|
|
93
|
+
if (renderHook)
|
|
94
|
+
renderHook(vnode);
|
|
95
|
+
return c.render(c.props, c.state, context);
|
|
96
|
+
}
|
|
97
|
+
function cleanupVNode(vnode) {
|
|
98
|
+
if (afterDiff)
|
|
99
|
+
afterDiff(vnode);
|
|
100
|
+
vnode[PARENT] = undefined;
|
|
101
|
+
if (ummountHook)
|
|
102
|
+
ummountHook(vnode);
|
|
103
|
+
}
|
|
104
|
+
function shouldRenderEtChild(child) {
|
|
105
|
+
return child != null && child !== false && child !== true;
|
|
106
|
+
}
|
|
107
|
+
function isCompiledEtHostType(type) {
|
|
108
|
+
return type.startsWith('_et_')
|
|
109
|
+
|| type.includes(':_et_');
|
|
110
|
+
}
|
|
111
|
+
function renderEtSlotArray(slotChildrenById, context, vnode, opcodes) {
|
|
112
|
+
for (let slotId = 0; slotId < slotChildrenById.length; slotId += 1) {
|
|
113
|
+
const slotChildren = slotChildrenById[slotId];
|
|
114
|
+
if (!shouldRenderEtChild(slotChildren)) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
opcodes.push(__OpSlot, slotId);
|
|
118
|
+
_renderToString(slotChildren, context, vnode, opcodes);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function renderComponentVNode(vnode, type, props, context, opcodes) {
|
|
122
|
+
let cctx = context;
|
|
123
|
+
let rendered;
|
|
124
|
+
let component;
|
|
125
|
+
const opcodesLength = opcodes.length;
|
|
126
|
+
if (type === Fragment) {
|
|
127
|
+
rendered = props.children;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const contextType = type.contextType;
|
|
131
|
+
if (contextType != null) {
|
|
132
|
+
const provider = context[contextType.__c];
|
|
133
|
+
cctx = provider ? provider.props.value : contextType.__;
|
|
134
|
+
}
|
|
135
|
+
if (type.prototype && typeof type.prototype.render === 'function') {
|
|
136
|
+
rendered = /**#__NOINLINE__**/ renderClassComponent(vnode, cctx);
|
|
137
|
+
component = vnode[COMPONENT];
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
component = {
|
|
141
|
+
__v: vnode,
|
|
142
|
+
props,
|
|
143
|
+
context: cctx,
|
|
144
|
+
// silently drop state updates
|
|
145
|
+
setState: markAsDirty,
|
|
146
|
+
forceUpdate: markAsDirty,
|
|
147
|
+
__d: true,
|
|
148
|
+
// hooks
|
|
149
|
+
__h: [],
|
|
150
|
+
};
|
|
151
|
+
vnode[COMPONENT] = component;
|
|
152
|
+
component.constructor = type;
|
|
153
|
+
component.render = doRender;
|
|
154
|
+
let count = 0;
|
|
155
|
+
while (component[DIRTY] && count++ < 25) {
|
|
156
|
+
component[DIRTY] = false;
|
|
157
|
+
if (renderHook)
|
|
158
|
+
renderHook(vnode);
|
|
159
|
+
rendered = component.render(props, component.state, cctx);
|
|
160
|
+
}
|
|
161
|
+
component[DIRTY] = true;
|
|
162
|
+
}
|
|
163
|
+
if (component.getChildContext != null) {
|
|
164
|
+
context = assign({}, context, component.getChildContext());
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const isTopLevelFragment = rendered != null && rendered.type === Fragment
|
|
168
|
+
&& rendered.key == null;
|
|
169
|
+
rendered = isTopLevelFragment ? rendered.props.children : rendered;
|
|
170
|
+
try {
|
|
171
|
+
_renderToString(rendered, context, vnode, opcodes);
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
if (e && typeof e === 'object' && e.then && component && /* _childDidSuspend */ component.__c) {
|
|
175
|
+
component.setState({ /* _suspended */ __a: true });
|
|
176
|
+
if (component[DIRTY]) {
|
|
177
|
+
rendered = renderClassComponent(vnode, context);
|
|
178
|
+
component = vnode[COMPONENT];
|
|
179
|
+
opcodes.length = opcodesLength;
|
|
180
|
+
_renderToString(rendered, context, vnode, opcodes);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
cleanupVNode(vnode);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function renderCompiledEtHostVNode(vnode, props, context, opcodes) {
|
|
192
|
+
opcodes.push(__OpBegin, vnode);
|
|
193
|
+
const attributeSlots = props.attributeSlots;
|
|
194
|
+
if (attributeSlots !== undefined) {
|
|
195
|
+
opcodes.push(__OpAttr, 'attributeSlots', attributeSlots);
|
|
196
|
+
}
|
|
197
|
+
// ET host nodes are compiler-generated; `swc_plugin_element_template`
|
|
198
|
+
// (lowering.rs) emits dynamic children as `$N` named props only — no
|
|
199
|
+
// `children` prop is produced — so the renderer only consumes `$N`.
|
|
200
|
+
let elementSlots;
|
|
201
|
+
for (const name in props) {
|
|
202
|
+
if (name.startsWith('$')) {
|
|
203
|
+
(elementSlots ??= [])[+name.slice(1)] = props[name];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (elementSlots !== undefined) {
|
|
207
|
+
renderEtSlotArray(elementSlots, context, vnode, opcodes);
|
|
208
|
+
}
|
|
209
|
+
cleanupVNode(vnode);
|
|
210
|
+
opcodes.push(__OpEnd);
|
|
211
|
+
}
|
|
212
|
+
function renderStringHostVNode(type, vnode, props, context, opcodes) {
|
|
213
|
+
if (__DEV__ && !isCompiledEtHostType(type)) {
|
|
214
|
+
cleanupVNode(vnode);
|
|
215
|
+
throw new Error(`Element Template main-thread renderer received an uncompiled host vnode: ${type}`);
|
|
216
|
+
}
|
|
217
|
+
renderCompiledEtHostVNode(vnode, props, context, opcodes);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Recursively render VNodes to HTML.
|
|
221
|
+
* @param {VNode|any} vnode
|
|
222
|
+
* @param {any} context
|
|
223
|
+
* @param {VNode} parent
|
|
224
|
+
* @param opcodes
|
|
225
|
+
*/
|
|
226
|
+
function _renderToString(vnode, context, parent, opcodes) {
|
|
227
|
+
// Ignore non-rendered VNodes/values
|
|
228
|
+
if (vnode == null || vnode === true || vnode === false || vnode === '') {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
// Text VNodes: escape as HTML
|
|
232
|
+
if (typeof vnode !== 'object') {
|
|
233
|
+
if (typeof vnode === 'function')
|
|
234
|
+
return;
|
|
235
|
+
opcodes.push(__OpText, vnode + '');
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
// Recurse into children / Arrays
|
|
239
|
+
if (isArray(vnode)) {
|
|
240
|
+
parent[CHILDREN] = vnode;
|
|
241
|
+
for (let i = 0; i < vnode.length; i++) {
|
|
242
|
+
const child = vnode[i];
|
|
243
|
+
if (child == null || typeof child === 'boolean')
|
|
244
|
+
continue;
|
|
245
|
+
_renderToString(child, context, parent, opcodes);
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
// VNodes have {constructor:undefined} to prevent JSON injection:
|
|
250
|
+
// if (vnode.constructor !== undefined) return;
|
|
251
|
+
vnode[PARENT] = parent;
|
|
252
|
+
if (beforeDiff)
|
|
253
|
+
beforeDiff(vnode);
|
|
254
|
+
if (beforeDiff2)
|
|
255
|
+
beforeDiff2(vnode, EMPTY_OBJ);
|
|
256
|
+
let type = vnode.type, props = vnode.props;
|
|
257
|
+
// Invoke rendering on Components
|
|
258
|
+
if (typeof type === 'function') {
|
|
259
|
+
renderComponentVNode(vnode, type, props, context, opcodes);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (typeof type === 'string') {
|
|
263
|
+
renderStringHostVNode(type, vnode, props, context, opcodes);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (__DEV__) {
|
|
267
|
+
cleanupVNode(vnode);
|
|
268
|
+
throw new Error('Element Template main-thread renderer received an invalid vnode.');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** The `.render()` method for a PFC backing instance. */
|
|
272
|
+
function doRender(props, state, context) {
|
|
273
|
+
return this.constructor(props, context);
|
|
274
|
+
}
|
|
275
|
+
export default renderToString;
|
|
276
|
+
export const render = renderToString;
|
|
277
|
+
export const renderToStaticMarkup = renderToString;
|
|
278
|
+
//# sourceMappingURL=render-to-opcodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-to-opcodes.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-to-opcodes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;GAIG;AAEH,cAAc;AAEd,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,IAAI,EACJ,KAAK,EACL,MAAM,EACN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AAC;AAC9B,MAAM,CAAC,MAAM,MAAM,GAA0B,cAAc,CAAC;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAA0B,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SpreadAttrAdapterContext } from '../../prop-adapters/spread.js';
|
|
2
|
+
import type { SerializableValue } from '../../protocol/types.js';
|
|
3
|
+
export interface EtAttrAdapterContext extends SpreadAttrAdapterContext {
|
|
4
|
+
}
|
|
5
|
+
export type EtAttrAdapter = (handleId: number, attrSlotIndex: number, value: unknown, context?: EtAttrAdapterContext) => SerializableValue | null;
|
|
6
|
+
export type EtAttrPlan = (number | EtAttrAdapter)[];
|
|
7
|
+
export type EtAttrPlanMap = Record<string, EtAttrPlan | undefined>;
|
|
8
|
+
export declare const __etAttrPlanMap: EtAttrPlanMap;
|
|
9
|
+
export declare function adaptEventAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, _context?: EtAttrAdapterContext): SerializableValue | null;
|
|
10
|
+
export declare function adaptRefAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, _context?: EtAttrAdapterContext): SerializableValue | null;
|
|
11
|
+
export declare function adaptSpreadAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, context?: EtAttrAdapterContext): SerializableValue | null;
|
|
12
|
+
export declare function clearEtAttrPlanMap(): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2025 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 { getEventValue } from '../../prop-adapters/event-value.js';
|
|
5
|
+
import { prepareRefAttrSlot } from '../../prop-adapters/ref.js';
|
|
6
|
+
import { prepareSpreadAttrSlot } from '../../prop-adapters/spread.js';
|
|
7
|
+
export const __etAttrPlanMap = Object.create(null);
|
|
8
|
+
export function adaptEventAttrSlot(handleId, attrSlotIndex, value, _context) {
|
|
9
|
+
if (value === null || value === undefined || value === false) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return getEventValue(handleId, attrSlotIndex);
|
|
13
|
+
}
|
|
14
|
+
export function adaptRefAttrSlot(handleId, attrSlotIndex, value, _context) {
|
|
15
|
+
return prepareRefAttrSlot(handleId, attrSlotIndex, value);
|
|
16
|
+
}
|
|
17
|
+
export function adaptSpreadAttrSlot(handleId, attrSlotIndex, value, context) {
|
|
18
|
+
return prepareSpreadAttrSlot(handleId, attrSlotIndex, value, context);
|
|
19
|
+
}
|
|
20
|
+
export function clearEtAttrPlanMap() {
|
|
21
|
+
// The compiled output assigns into the exported side table directly, so the
|
|
22
|
+
// object identity must stay stable when tests or teardown clear state.
|
|
23
|
+
for (const templateKey in __etAttrPlanMap) {
|
|
24
|
+
delete __etAttrPlanMap[templateKey];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=attr-slot-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attr-slot-plan.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/attr-slot-plan.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAoBtE,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAkB,CAAC;AAEpE,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,aAAqB,EACrB,KAAc,EACd,QAA+B;IAE/B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,QAAgB,EAChB,aAAqB,EACrB,KAAc,EACd,QAA+B;IAE/B,OAAO,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,aAAqB,EACrB,KAAc,EACd,OAA8B;IAE9B,OAAO,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,4EAA4E;IAC5E,uEAAuE;IACvE,KAAK,MAAM,WAAW,IAAI,eAAe,EAAE,CAAC;QAC1C,OAAO,eAAe,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SerializableValue } from '../../protocol/types.js';
|
|
2
|
+
export declare function reserveElementTemplateId(): number;
|
|
3
|
+
export declare function createElementTemplateWithReservedHandle(handleId: number, templateKey: string, bundleUrl: string | null | undefined, attributeSlots: SerializableValue[] | null | undefined, elementSlots: ElementRef[][] | null | undefined): ElementRef;
|
|
4
|
+
export declare function resetTemplateId(): void;
|
|
5
|
+
export declare function destroyElementTemplateId(id: number): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2025 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 { deleteElementTemplateNativeRef, setElementTemplateNativeRef } from './registry.js';
|
|
5
|
+
// Main-thread IFR allocates ids as consecutive negative integers.
|
|
6
|
+
let nextId = -1;
|
|
7
|
+
export function reserveElementTemplateId() {
|
|
8
|
+
const id = nextId--;
|
|
9
|
+
return id;
|
|
10
|
+
}
|
|
11
|
+
export function createElementTemplateWithReservedHandle(handleId, templateKey, bundleUrl, attributeSlots, elementSlots) {
|
|
12
|
+
const nativeRef = __CreateElementTemplate(templateKey, bundleUrl, attributeSlots, elementSlots, handleId);
|
|
13
|
+
setElementTemplateNativeRef(handleId, nativeRef);
|
|
14
|
+
return nativeRef;
|
|
15
|
+
}
|
|
16
|
+
export function resetTemplateId() {
|
|
17
|
+
nextId = -1;
|
|
18
|
+
}
|
|
19
|
+
export function destroyElementTemplateId(id) {
|
|
20
|
+
deleteElementTemplateNativeRef(id);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/handle.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAG5F,kEAAkE;AAClE,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;AAEhB,MAAM,UAAU,wBAAwB;IACtC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,QAAgB,EAChB,WAAmB,EACnB,SAAoC,EACpC,cAAsD,EACtD,YAA+C;IAE/C,MAAM,SAAS,GAAG,uBAAuB,CACvC,WAAW,EACX,SAAS,EACT,cAAc,EACd,YAAY,EACZ,QAAQ,CACT,CAAC;IACF,2BAA2B,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,CAAC,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EAAU;IACjD,8BAA8B,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function setElementTemplateNativeRef(id: number, nativeRef: ElementRef): void;
|
|
2
|
+
export declare function getElementTemplateNativeRef(id: number): ElementRef | undefined;
|
|
3
|
+
export declare function hasElementTemplateNativeRef(id: number): boolean;
|
|
4
|
+
export declare function deleteElementTemplateNativeRef(id: number): void;
|
|
5
|
+
export declare function clearElementTemplateNativeRefRegistry(): void;
|
|
6
|
+
export interface ElementTemplateRegistryFacade {
|
|
7
|
+
set: (id: number, nativeRef: ElementRef) => void;
|
|
8
|
+
get: (id: number) => ElementRef | undefined;
|
|
9
|
+
has: (id: number) => boolean;
|
|
10
|
+
delete: (id: number) => void;
|
|
11
|
+
clear: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const elementTemplateRegistry: ElementTemplateRegistryFacade;
|