@lynx-js/react 0.126.1 → 0.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/docs/directives.md +90 -0
- package/docs/global-events.md +50 -0
- package/docs/import-attributes.md +43 -0
- package/docs/macros.md +285 -0
- package/package.json +4 -3
- package/refresh/.turbo/turbo-build.log +4 -4
- package/refresh/dist/index.js +27 -8
- package/refresh/package.json +2 -2
- package/runtime/__test__/core/main-thread-object.test.js +149 -0
- package/runtime/__test__/element-template/debug/profile-installation.test.tsx +97 -1
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +1 -1
- package/runtime/__test__/element-template/fixtures/background/main-thread-function/run-on-main-thread/index.tsx +26 -3
- package/runtime/__test__/element-template/fixtures/render/child-siblings/index.js.txt +15 -11
- package/runtime/__test__/element-template/fixtures/render/component/index.js.txt +8 -7
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/index.js.txt +14 -10
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/index.js.txt +4 -3
- package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/_shared.ts +2 -9
- package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/case.ts +2 -4
- package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/case.ts +20 -0
- package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-template-children-in-the-same-slot/case.ts +3 -16
- package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/case.ts +18 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/case.ts +20 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/case.ts +18 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/case.ts +15 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/index.js.txt +12 -11
- package/runtime/__test__/element-template/fixtures/render/mixed-children/index.js.txt +8 -7
- package/runtime/__test__/element-template/fixtures/render/multiple-text/index.js.txt +15 -13
- package/runtime/__test__/element-template/fixtures/render/nested-templates/index.js.txt +9 -7
- package/runtime/__test__/element-template/fixtures/render/react-example/index.js.txt +17 -20
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/index.js.txt +13 -10
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/index.js.txt +14 -11
- package/runtime/__test__/element-template/imports/main-thread-object-api.test.ts +10 -0
- package/runtime/__test__/element-template/imports/suspense-lazy.test.ts +52 -7
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +3 -0
- package/runtime/__test__/element-template/native/reload.test.ts +10 -26
- package/runtime/__test__/element-template/runtime/background/component-stack.test.tsx +76 -0
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +87 -43
- package/runtime/__test__/element-template/runtime/background/instance.test.ts +14 -0
- package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +4 -0
- package/runtime/__test__/element-template/runtime/render/compact-host-debug.test.ts +57 -0
- package/runtime/__test__/element-template/runtime/render/compact-host.test.ts +199 -0
- package/runtime/__test__/element-template/runtime/render/render-components.test.jsx +292 -0
- package/runtime/__test__/element-template/runtime/render/{render-opcodes-into-element-template.et.test.tsx → render-direct-native.test.tsx} +50 -314
- package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +378 -0
- package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +491 -0
- package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +2 -28
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +21 -35
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +6 -5
- package/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts +4 -4
- package/runtime/__test__/element-template/vitest.config.ts +2 -1
- package/runtime/__test__/snapshot/ctxNotFound.test.ts +271 -0
- package/runtime/__test__/snapshot/debug/main-thread-children-with-same-key.test.ts +28 -0
- package/runtime/__test__/snapshot/debug/profile.test.jsx +108 -3
- package/runtime/__test__/snapshot/event.test.jsx +7 -7
- package/runtime/__test__/snapshot/lazy.test.js +114 -7
- package/runtime/__test__/snapshot/lifecycle/reloadGc.test.jsx +66 -0
- package/runtime/__test__/snapshot/lynx/portals.test.jsx +75 -37
- package/runtime/__test__/snapshot/lynx/runtime-version.test.ts +140 -0
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +59 -47
- package/runtime/__test__/snapshot/spread.test.jsx +32 -25
- package/runtime/__test__/snapshot/ssr.legacy-slot.test.jsx +168 -0
- package/runtime/__test__/snapshot/ssr.list.test.jsx +211 -0
- package/runtime/__test__/snapshot/worklet/main-thread-object.test.jsx +306 -0
- package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +1 -0
- package/runtime/__test__/worklet-runtime/hydrate.test.js +92 -0
- package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +182 -0
- package/runtime/__test__/worklet-runtime/object-methods.test.js +60 -0
- package/runtime/__test__/worklet-runtime/runOnBackground.test.js +8 -6
- package/runtime/__test__/worklet-runtime/workletRef.test.js +362 -2
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +249 -3
- package/runtime/lazy/compat.js +2 -0
- package/runtime/lazy/element-template-import.js +0 -4
- package/runtime/lazy/element-template-internal.js +19 -8
- package/runtime/lazy/element-template-jsx-dev-runtime.js +1 -8
- package/runtime/lazy/element-template-jsx-runtime.js +1 -3
- package/runtime/lazy/element-template.js +3 -3
- package/runtime/lazy/import.js +0 -4
- package/runtime/lazy/internal.js +17 -1
- package/runtime/lazy/react.js +2 -0
- package/runtime/lazy/target.js +0 -21
- package/runtime/lib/core/background-function/run-on-background.d.ts +16 -0
- package/runtime/lib/core/background-function/run-on-background.js +16 -0
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/core/capture-main-thread-object.js +16 -0
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -0
- package/runtime/lib/core/globalProps.d.ts +2 -0
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/core/hooks/react.d.ts +6 -0
- package/runtime/lib/core/hooks/react.js +6 -0
- package/runtime/lib/core/hooks/react.js.map +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.d.ts +2 -0
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js +2 -0
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -1
- package/runtime/lib/core/initData.d.ts +2 -0
- package/runtime/lib/core/initData.js +2 -0
- package/runtime/lib/core/initData.js.map +1 -1
- package/runtime/lib/core/lynx/runtime-version.d.ts +16 -0
- package/runtime/lib/core/lynx/runtime-version.js +51 -0
- package/runtime/lib/core/lynx/runtime-version.js.map +1 -0
- package/runtime/lib/core/main-thread-object-handle-registry.d.ts +3 -0
- package/runtime/lib/core/main-thread-object-handle-registry.js +17 -0
- package/runtime/lib/core/main-thread-object-handle-registry.js.map +1 -0
- package/runtime/lib/core/main-thread-object.d.ts +77 -0
- package/runtime/lib/core/main-thread-object.js +261 -0
- package/runtime/lib/core/main-thread-object.js.map +1 -0
- package/runtime/lib/core/main-thread-ref-id.js +14 -0
- package/runtime/lib/core/main-thread-ref-id.js.map +1 -0
- package/runtime/lib/core/main-thread-ref-init-value.d.ts +1 -1
- package/runtime/lib/core/main-thread-ref-init-value.js +4 -2
- package/runtime/lib/core/main-thread-ref-init-value.js.map +1 -1
- package/runtime/lib/core/main-thread-ref.d.ts +4 -0
- package/runtime/lib/core/main-thread-ref.js +5 -8
- package/runtime/lib/core/main-thread-ref.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/document.d.ts +1 -1
- package/runtime/lib/element-template/background/document.js +1 -1
- package/runtime/lib/element-template/background/document.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +51 -19
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/instance.js +5 -6
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/debug/profile.js +38 -22
- package/runtime/lib/element-template/debug/profile.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +3 -1
- package/runtime/lib/element-template/index.js +2 -1
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +5 -1
- package/runtime/lib/element-template/internal.js +7 -1
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +4 -0
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +1 -1
- package/runtime/lib/element-template/runtime/list/list.d.ts +1 -0
- package/runtime/lib/element-template/runtime/list/list.js +3 -0
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/create-rendered-host.d.ts +7 -0
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js +65 -0
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/host.d.ts +18 -0
- package/runtime/lib/element-template/runtime/render/host.js +25 -0
- package/runtime/lib/element-template/runtime/render/host.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-components.d.ts +6 -0
- package/runtime/lib/element-template/runtime/render/render-components.js +190 -0
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/{render-opcodes.d.ts → render-direct.d.ts} +3 -1
- package/runtime/lib/element-template/runtime/render/render-direct.js +194 -0
- package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +10 -9
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +2 -1
- package/runtime/lib/element-template/runtime/template/handle.js +12 -4
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime-marker.d.ts +1 -0
- package/runtime/lib/element-template/runtime-marker.js +13 -0
- package/runtime/lib/element-template/runtime-marker.js.map +1 -0
- package/runtime/lib/index.d.ts +1 -1
- package/runtime/lib/index.js +1 -1
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +4 -1
- package/runtime/lib/internal.js +6 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +49 -6
- package/runtime/lib/lynx-api.js +34 -4
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.js +4 -1
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/runtime-marker.d.ts +1 -0
- package/runtime/lib/runtime-marker.js +13 -0
- package/runtime/lib/runtime-marker.js.map +1 -0
- package/runtime/lib/shared/component-stack.js +5 -1
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +38 -22
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/error.d.ts +11 -1
- package/runtime/lib/snapshot/lifecycle/patch/error.js +24 -16
- package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.d.ts +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +29 -7
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +2 -2
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js +3 -0
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +3 -0
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/lynx/children.d.ts +2 -0
- package/runtime/lib/snapshot/lynx/children.js.map +1 -1
- package/runtime/lib/snapshot/lynx/element.d.ts +10 -0
- package/runtime/lib/snapshot/lynx/element.js +6 -0
- package/runtime/lib/snapshot/lynx/element.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +2 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +2 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +2 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +3 -3
- package/runtime/lib/worklet-runtime/bindings/bindings.js +9 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.d.ts +3 -6
- package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +27 -8
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.d.ts +8 -0
- package/runtime/lib/worklet-runtime/mainThreadObject.js +67 -0
- package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -0
- package/runtime/lib/worklet-runtime/workletRef.d.ts +11 -7
- package/runtime/lib/worklet-runtime/workletRef.js +72 -9
- package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +69 -19
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/package.json +2 -3
- package/runtime/src/core/background-function/run-on-background.ts +16 -0
- package/runtime/src/core/capture-main-thread-object.ts +17 -0
- package/runtime/src/core/globalProps.ts +2 -0
- package/runtime/src/core/hooks/react.ts +6 -0
- package/runtime/src/core/hooks/useLynxGlobalEventListener.ts +2 -0
- package/runtime/src/core/initData.ts +2 -0
- package/runtime/src/core/lynx/runtime-version.ts +62 -0
- package/runtime/src/core/main-thread-object-handle-registry.ts +25 -0
- package/runtime/src/core/main-thread-object.ts +387 -0
- package/runtime/src/core/main-thread-ref-id.ts +16 -0
- package/runtime/src/core/main-thread-ref-init-value.ts +12 -4
- package/runtime/src/core/main-thread-ref.ts +7 -8
- package/runtime/src/element-template/background/commit-hook.ts +1 -1
- package/runtime/src/element-template/background/document.ts +3 -3
- package/runtime/src/element-template/background/hydrate.ts +61 -29
- package/runtime/src/element-template/background/instance.ts +5 -6
- package/runtime/src/element-template/debug/profile.ts +48 -36
- package/runtime/src/element-template/index.ts +7 -1
- package/runtime/src/element-template/internal.ts +14 -1
- package/runtime/src/element-template/native/index.ts +4 -0
- package/runtime/src/element-template/protocol/types.ts +1 -1
- package/runtime/src/element-template/runtime/list/list.ts +4 -0
- package/runtime/src/element-template/runtime/render/create-rendered-host.ts +126 -0
- package/runtime/src/element-template/runtime/render/host.ts +51 -0
- package/runtime/src/element-template/runtime/render/render-components.ts +255 -0
- package/runtime/src/element-template/runtime/render/render-direct.ts +275 -0
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +10 -9
- package/runtime/src/element-template/runtime/template/handle.ts +17 -7
- package/runtime/src/element-template/runtime-marker.ts +17 -0
- package/runtime/src/index.ts +1 -1
- package/runtime/src/internal.ts +11 -1
- package/runtime/src/lynx-api.ts +53 -6
- package/runtime/src/lynx.ts +5 -1
- package/runtime/src/runtime-marker.ts +17 -0
- package/runtime/src/shared/component-stack.ts +5 -1
- package/runtime/src/snapshot/debug/profileHooks.ts +52 -40
- package/runtime/src/snapshot/lifecycle/patch/error.ts +36 -19
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +29 -7
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +2 -2
- package/runtime/src/snapshot/lifecycle/reload.ts +4 -0
- package/runtime/src/snapshot/lynx/calledByNative.ts +4 -0
- package/runtime/src/snapshot/lynx/children.ts +2 -0
- package/runtime/src/snapshot/lynx/element.ts +10 -0
- package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +2 -1
- package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +2 -0
- package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +1 -1
- package/runtime/src/worklet-runtime/bindings/bindings.ts +17 -2
- package/runtime/src/worklet-runtime/bindings/types.ts +7 -11
- package/runtime/src/worklet-runtime/hydrate.ts +44 -11
- package/runtime/src/worklet-runtime/mainThreadObject.ts +117 -0
- package/runtime/src/worklet-runtime/workletRef.ts +120 -19
- package/runtime/src/worklet-runtime/workletRuntime.ts +84 -21
- package/runtime/types/types.d.ts +2 -0
- package/runtime/worklet-runtime/dev.js +155 -30
- package/runtime/worklet-runtime/main.js +1 -1
- package/testing-library/.turbo/turbo-build.log +12 -12
- package/testing-library/dist/env/index.js +2 -2
- package/testing-library/dist/index.d.ts +167 -4
- package/testing-library/dist/plugins/index.js +1 -1
- package/testing-library/dist/pure.js +45 -44
- package/testing-library/etc/react-lynx-testing-library.api.md +1 -1
- package/testing-library/package.json +4 -3
- package/testing-library/src/__tests__/lynx.test.jsx +1 -1
- package/testing-library/src/__tests__/reload/reloadGc.test.jsx +64 -0
- package/testing-library/src/__tests__/reload/reloadTemplate.js +39 -0
- package/testing-library/src/__tests__/worklet.test.jsx +46 -1
- package/testing-library/tsconfig.docs.json +9 -0
- package/testing-library/typedoc.json +22 -0
- package/testing-library/types/entry.d.ts +2 -2
- package/transform/.turbo/turbo-build$colon$wasm.log +151 -67
- package/transform/__test__/fixture.spec.js +89 -50
- package/transform/__test__/object-methods.spec.js +84 -0
- package/transform/__test__/text.spec.js +75 -0
- package/transform/crates/swc_plugin_compat/lib.rs +4 -3
- package/transform/crates/swc_plugin_compat/napi.rs +4 -3
- package/transform/crates/swc_plugin_define_dce/napi.rs +1 -1
- package/transform/crates/swc_plugin_dynamic_import/lib.rs +105 -3
- package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_suffix_webpack_chunk_name.js +5 -0
- package/transform/crates/swc_plugin_element_template/host_lowering.rs +111 -0
- package/transform/crates/swc_plugin_element_template/lib.rs +41 -5
- package/transform/crates/swc_plugin_element_template/lowering.rs +39 -7
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_generate_attribute_slots_for_dynamic_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_background_conditional_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_boolean_and_number_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_complex_text_structure.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dataset_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_deeply_nested_user_components.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dynamic_class_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_events_lepus.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_id_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_inline_styles.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_interpolated_text_with_siblings_lepus.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_mixed_content.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_nested_structure_and_dynamic_content.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_refs_lepus.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_sibling_user_components.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_spread_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_user_component.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_isolate_arrays_with_child_slot_placeholder.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_keep_code_and_template_attribute_slots_in_sync_for_spread.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_element_template_simple_lepus.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_template_with_static_attributes.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_template_structure_complex.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_text_attribute_and_child_text_slots.snap +1 -1
- package/transform/crates/swc_plugin_element_template/tests/element_template.rs +70 -66
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +94 -8
- package/transform/crates/swc_plugin_shake/lib.rs +1 -1
- package/transform/crates/swc_plugin_shake/napi.rs +1 -1
- package/transform/crates/swc_plugin_text/lib.rs +57 -16
- package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_keep_children_for_dynamic_or_multiple_text.js +13 -0
- package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_transform_string_expressions_to_text_attr.js +13 -0
- package/transform/crates/swc_plugin_worklet/decl_collect.rs +10 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +14 -0
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +202 -3
- package/transform/crates/swc_plugin_worklet/lib.rs +468 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +8 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +10 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_js.js +27 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_lepus.js +45 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +16 -14
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +16 -16
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +7 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +7 -7
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_computed_object_method_key_lepus.js +24 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_object_method_local_decls_lepus.js +16 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +42 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +58 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +3 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_js.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_lepus.js +16 -0
- package/transform/crates/swc_plugins_shared/jsx_helpers.rs +8 -4
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +7 -6
- package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
- package/transform/src/swc_plugin_extract_str/mod.rs +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +63 -270
- package/transform/swc-plugin-reactlynx/index.d.ts +2 -2
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +306 -170
- package/transform/swc-plugin-reactlynx-compat/index.d.ts +3 -3
- package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
- package/transform/vitest.config.ts +5 -1
- package/types/react.docs.d.ts +130 -11
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/creates-template-from-attrs-and-slot-text/case.ts +0 -39
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-text-nodes-in-the-same-slot/case.ts +0 -29
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/inserts-nested-templates-into-parent-slots/case.ts +0 -42
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/keeps-slot-children-separated-and-ordered/case.ts +0 -31
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/passes-bundle-url-to-native-create/case.ts +0 -20
- package/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx +0 -522
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +0 -216
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +0 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +0 -16
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +0 -324
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +0 -1
- package/runtime/lib/element-template/runtime-backend-marker.js +0 -6
- package/runtime/lib/element-template/runtime-backend-marker.js.map +0 -1
- package/runtime/lib/runtime-backend-marker.js +0 -6
- package/runtime/lib/runtime-backend-marker.js.map +0 -1
- package/runtime/src/element-template/runtime/render/render-opcodes.ts +0 -313
- package/runtime/src/element-template/runtime/render/render-to-opcodes.ts +0 -411
- package/runtime/src/element-template/runtime-backend-marker.ts +0 -7
- package/runtime/src/runtime-backend-marker.ts +0 -7
- package/testing-library/node_modules/.bin/rsbuild +0 -55
- package/testing-library/node_modules/.bin/rspeedy +0 -55
- package/testing-library/node_modules/.bin/rstest +0 -55
- package/transform/node_modules/.bin/esbuild +0 -46
- package/transform/node_modules/.bin/napi +0 -55
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/native-log.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/output.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/creates-template-from-attrs-and-slot-text/native-log.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/creates-template-from-attrs-and-slot-text/output.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-template-children-in-the-same-slot/native-log.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-template-children-in-the-same-slot/output.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-text-nodes-in-the-same-slot/native-log.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-text-nodes-in-the-same-slot/output.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/inserts-nested-templates-into-parent-slots/native-log.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/inserts-nested-templates-into-parent-slots/output.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/keeps-slot-children-separated-and-ordered/native-log.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/keeps-slot-children-separated-and-ordered/output.txt +0 -0
- /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/passes-bundle-url-to-native-create/native-log.txt +0 -0
- /package/runtime/lib/{element-template/runtime-backend-marker.d.ts → core/capture-main-thread-object.d.ts} +0 -0
- /package/runtime/lib/{runtime-backend-marker.d.ts → core/main-thread-ref-id.d.ts} +0 -0
|
@@ -1,411 +0,0 @@
|
|
|
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
|
-
/**
|
|
6
|
-
* Implements rendering to opcodes.
|
|
7
|
-
* This module is modified from preact-render-to-string@6.0.3 to generate
|
|
8
|
-
* opcodes instead of HTML strings for Lynx.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// @ts-nocheck
|
|
12
|
-
|
|
13
|
-
import { Fragment, h, options } from 'preact';
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
BITS,
|
|
17
|
-
CHILDREN,
|
|
18
|
-
COMMIT,
|
|
19
|
-
COMPONENT,
|
|
20
|
-
COMPONENT_DIRTY,
|
|
21
|
-
DIFF,
|
|
22
|
-
DIFF2,
|
|
23
|
-
DIFFED,
|
|
24
|
-
GLOBAL_CONTEXT,
|
|
25
|
-
NEXT_STATE,
|
|
26
|
-
PARENT,
|
|
27
|
-
RENDER,
|
|
28
|
-
SKIP_EFFECTS,
|
|
29
|
-
VNODE,
|
|
30
|
-
} from '../../../shared/render-constants.js';
|
|
31
|
-
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID } from '../../protocol/page.js';
|
|
32
|
-
import { __ElementTemplatePage } from '../page/authored-page.js';
|
|
33
|
-
import { prepareTypedElementAttributes } from '../template/typed-attributes.js';
|
|
34
|
-
|
|
35
|
-
/** @typedef {import('preact').VNode} VNode */
|
|
36
|
-
|
|
37
|
-
const EMPTY_ARR = [];
|
|
38
|
-
const isArray = /* @__PURE__ */ Array.isArray;
|
|
39
|
-
const assign = /* @__PURE__ */ Object.assign;
|
|
40
|
-
|
|
41
|
-
// Global state for the current render pass
|
|
42
|
-
let beforeDiff, beforeDiff2, afterDiff, renderHook, ummountHook;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Render Preact JSX + Components to an HTML string.
|
|
46
|
-
* @param {VNode} vnode JSX Element / VNode to render
|
|
47
|
-
* @param {object} [context] Initial root context object
|
|
48
|
-
*/
|
|
49
|
-
export function renderToString(vnode: any, context: any): any[] {
|
|
50
|
-
// Performance optimization: `renderToString` is synchronous and we
|
|
51
|
-
// therefore don't execute any effects. To do that we pass an empty
|
|
52
|
-
// array to `options._commit` (`__c`). But we can go one step further
|
|
53
|
-
// and avoid a lot of dirty checks and allocations by setting
|
|
54
|
-
// `options._skipEffects` (`__s`) too.
|
|
55
|
-
const previousSkipEffects = options[SKIP_EFFECTS];
|
|
56
|
-
options[SKIP_EFFECTS] = true;
|
|
57
|
-
|
|
58
|
-
// store options hooks once before each synchronous render call
|
|
59
|
-
beforeDiff = options[DIFF];
|
|
60
|
-
beforeDiff2 = options[DIFF2];
|
|
61
|
-
afterDiff = options[DIFFED];
|
|
62
|
-
renderHook = options[RENDER];
|
|
63
|
-
ummountHook = options.unmount;
|
|
64
|
-
|
|
65
|
-
const parent = h(Fragment, null);
|
|
66
|
-
parent[CHILDREN] = [vnode];
|
|
67
|
-
|
|
68
|
-
const opcodes = [];
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
_renderToString(
|
|
72
|
-
vnode,
|
|
73
|
-
context || EMPTY_OBJ,
|
|
74
|
-
parent,
|
|
75
|
-
opcodes,
|
|
76
|
-
);
|
|
77
|
-
} finally {
|
|
78
|
-
// options._commit, we don't schedule any effects in this library right now,
|
|
79
|
-
// so we can pass an empty queue to this hook.
|
|
80
|
-
if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);
|
|
81
|
-
options[SKIP_EFFECTS] = previousSkipEffects;
|
|
82
|
-
EMPTY_ARR.length = 0;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return opcodes;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Installed as setState/forceUpdate for function components
|
|
89
|
-
/* v8 ignore start */
|
|
90
|
-
function markAsDirty() {
|
|
91
|
-
this[BITS] |= COMPONENT_DIRTY;
|
|
92
|
-
}
|
|
93
|
-
/* v8 ignore stop */
|
|
94
|
-
|
|
95
|
-
const EMPTY_OBJ = {};
|
|
96
|
-
const TYPED_LIST_HOST_TYPE = 'list';
|
|
97
|
-
const TYPED_LIST_LOGICAL_SLOT_PROP = '$0';
|
|
98
|
-
|
|
99
|
-
export const __OpBegin = 0;
|
|
100
|
-
export const __OpEnd = 1;
|
|
101
|
-
export const __OpAttr = 2;
|
|
102
|
-
export const __OpText = 3;
|
|
103
|
-
export const __OpSlot = 4;
|
|
104
|
-
export const __OpPageStart = 5;
|
|
105
|
-
export const __OpPageEnd = 6;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @param {VNode} vnode
|
|
109
|
-
* @param {Record<string, unknown>} context
|
|
110
|
-
*/
|
|
111
|
-
function renderClassComponent(vnode, context, globalContext) {
|
|
112
|
-
const type = /** @type {import("preact").ComponentClass<typeof vnode.props>} */ (vnode.type);
|
|
113
|
-
|
|
114
|
-
let c;
|
|
115
|
-
if (vnode[COMPONENT]) {
|
|
116
|
-
c = vnode[COMPONENT];
|
|
117
|
-
c.state = c[NEXT_STATE];
|
|
118
|
-
} else {
|
|
119
|
-
c = new type(vnode.props, context);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
vnode[COMPONENT] = c;
|
|
123
|
-
c[VNODE] = vnode;
|
|
124
|
-
|
|
125
|
-
c.props = vnode.props;
|
|
126
|
-
c.context = context;
|
|
127
|
-
c[GLOBAL_CONTEXT] = globalContext;
|
|
128
|
-
// turn off stateful re-rendering:
|
|
129
|
-
c[BITS] |= COMPONENT_DIRTY;
|
|
130
|
-
|
|
131
|
-
if (c.state == null) c.state = EMPTY_OBJ;
|
|
132
|
-
|
|
133
|
-
if (c[NEXT_STATE] == null) {
|
|
134
|
-
c[NEXT_STATE] = c.state;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (type.getDerivedStateFromProps) {
|
|
138
|
-
c.state = assign(
|
|
139
|
-
{},
|
|
140
|
-
c.state,
|
|
141
|
-
type.getDerivedStateFromProps(c.props, c.state),
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (renderHook) renderHook(vnode);
|
|
146
|
-
|
|
147
|
-
return c.render(c.props, c.state, context);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function cleanupVNode(vnode) {
|
|
151
|
-
if (afterDiff) afterDiff(vnode);
|
|
152
|
-
vnode[PARENT] = undefined;
|
|
153
|
-
if (ummountHook) ummountHook(vnode);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function shouldRenderEtChild(child) {
|
|
157
|
-
return child != null && child !== false && child !== true;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function isCompiledEtHostType(type) {
|
|
161
|
-
return type.startsWith('_et_')
|
|
162
|
-
|| type.includes(':_et_');
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function renderEtSlotArray(slotChildrenById, context, vnode, opcodes) {
|
|
166
|
-
for (let slotId = 0; slotId < slotChildrenById.length; slotId += 1) {
|
|
167
|
-
const slotChildren = slotChildrenById[slotId];
|
|
168
|
-
if (!shouldRenderEtChild(slotChildren)) {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
opcodes.push(__OpSlot, slotId);
|
|
172
|
-
_renderToString(slotChildren, context, vnode, opcodes);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function renderComponentVNode(
|
|
177
|
-
vnode,
|
|
178
|
-
type,
|
|
179
|
-
props,
|
|
180
|
-
context,
|
|
181
|
-
opcodes,
|
|
182
|
-
) {
|
|
183
|
-
let cctx = context;
|
|
184
|
-
let rendered;
|
|
185
|
-
let component;
|
|
186
|
-
const opcodesLength = opcodes.length;
|
|
187
|
-
|
|
188
|
-
if (type === Fragment) {
|
|
189
|
-
rendered = props.children;
|
|
190
|
-
} else {
|
|
191
|
-
const contextType = type.contextType;
|
|
192
|
-
if (contextType != null) {
|
|
193
|
-
const provider = context[contextType.__c];
|
|
194
|
-
cctx = provider ? provider.props.value : contextType.__;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (type.prototype && typeof type.prototype.render === 'function') {
|
|
198
|
-
rendered = /**#__NOINLINE__**/ renderClassComponent(vnode, cctx, context);
|
|
199
|
-
component = vnode[COMPONENT];
|
|
200
|
-
} else {
|
|
201
|
-
component = {
|
|
202
|
-
__v: vnode,
|
|
203
|
-
props,
|
|
204
|
-
context: cctx,
|
|
205
|
-
[GLOBAL_CONTEXT]: context,
|
|
206
|
-
// silently drop state updates
|
|
207
|
-
setState: markAsDirty,
|
|
208
|
-
forceUpdate: markAsDirty,
|
|
209
|
-
__g: COMPONENT_DIRTY,
|
|
210
|
-
// hooks
|
|
211
|
-
__h: [],
|
|
212
|
-
};
|
|
213
|
-
vnode[COMPONENT] = component;
|
|
214
|
-
component.constructor = type;
|
|
215
|
-
component.render = doRender;
|
|
216
|
-
|
|
217
|
-
let count = 0;
|
|
218
|
-
while (component[BITS] & COMPONENT_DIRTY && count++ < 25) {
|
|
219
|
-
component[BITS] &= ~COMPONENT_DIRTY;
|
|
220
|
-
|
|
221
|
-
if (renderHook) renderHook(vnode);
|
|
222
|
-
|
|
223
|
-
rendered = component.render(props, component.state, cctx);
|
|
224
|
-
}
|
|
225
|
-
component[BITS] |= COMPONENT_DIRTY;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (component.getChildContext != null) {
|
|
229
|
-
context = assign({}, context, component.getChildContext());
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const isTopLevelFragment = rendered != null && rendered.type === Fragment
|
|
234
|
-
&& rendered.key == null;
|
|
235
|
-
rendered = isTopLevelFragment ? rendered.props.children : rendered;
|
|
236
|
-
|
|
237
|
-
try {
|
|
238
|
-
_renderToString(rendered, context, vnode, opcodes);
|
|
239
|
-
} catch (e) {
|
|
240
|
-
if (e && typeof e === 'object' && e.then && component && /* _childDidSuspend */ component.__c) {
|
|
241
|
-
component.setState({ /* _suspended */ __a: true });
|
|
242
|
-
|
|
243
|
-
if (component[BITS] & COMPONENT_DIRTY) {
|
|
244
|
-
rendered = renderClassComponent(vnode, context, context);
|
|
245
|
-
component = vnode[COMPONENT];
|
|
246
|
-
|
|
247
|
-
opcodes.length = opcodesLength;
|
|
248
|
-
_renderToString(rendered, context, vnode, opcodes);
|
|
249
|
-
}
|
|
250
|
-
} else {
|
|
251
|
-
throw e;
|
|
252
|
-
}
|
|
253
|
-
} finally {
|
|
254
|
-
cleanupVNode(vnode);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function renderCompiledEtHostVNode(vnode, props, context, opcodes) {
|
|
259
|
-
opcodes.push(__OpBegin, vnode);
|
|
260
|
-
|
|
261
|
-
const attributeSlots = props.attributeSlots;
|
|
262
|
-
if (attributeSlots !== undefined) {
|
|
263
|
-
opcodes.push(__OpAttr, attributeSlots);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// ET host nodes are compiler-generated; `swc_plugin_element_template`
|
|
267
|
-
// (lowering.rs) emits dynamic children as `$N` named props only — no
|
|
268
|
-
// `children` prop is produced — so the renderer only consumes `$N`.
|
|
269
|
-
let childSlots: unknown[] | undefined;
|
|
270
|
-
for (const name in props) {
|
|
271
|
-
if (name.startsWith('$')) {
|
|
272
|
-
(childSlots ??= [])[+name.slice(1)] = props[name];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (childSlots !== undefined) {
|
|
276
|
-
renderEtSlotArray(childSlots, context, vnode, opcodes);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
cleanupVNode(vnode);
|
|
280
|
-
opcodes.push(__OpEnd);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function renderTypedListHostVNode(vnode, props, context, opcodes) {
|
|
284
|
-
opcodes.push(__OpBegin, vnode);
|
|
285
|
-
|
|
286
|
-
try {
|
|
287
|
-
if (__DEV__) {
|
|
288
|
-
for (const name in props) {
|
|
289
|
-
if (name.startsWith('$') && name !== TYPED_LIST_LOGICAL_SLOT_PROP) {
|
|
290
|
-
throw new Error('Element Template typed list only supports logical slot $0.');
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const attributes = props.attributes;
|
|
296
|
-
if (attributes !== undefined) {
|
|
297
|
-
opcodes.push(__OpAttr, attributes);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const listChildren = props[TYPED_LIST_LOGICAL_SLOT_PROP];
|
|
301
|
-
if (shouldRenderEtChild(listChildren)) {
|
|
302
|
-
opcodes.push(__OpSlot, 0);
|
|
303
|
-
_renderToString(listChildren, context, vnode, opcodes);
|
|
304
|
-
}
|
|
305
|
-
} finally {
|
|
306
|
-
cleanupVNode(vnode);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
opcodes.push(__OpEnd);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function renderStringHostVNode(type, vnode, props, context, opcodes) {
|
|
313
|
-
if (type === TYPED_LIST_HOST_TYPE) {
|
|
314
|
-
renderTypedListHostVNode(vnode, props, context, opcodes);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (!isCompiledEtHostType(type)) {
|
|
319
|
-
cleanupVNode(vnode);
|
|
320
|
-
throw new Error(
|
|
321
|
-
`Element Template main-thread renderer received an uncompiled host vnode: ${type}`,
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
renderCompiledEtHostVNode(vnode, props, context, opcodes);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Recursively render VNodes to HTML.
|
|
330
|
-
* @param {VNode|any} vnode
|
|
331
|
-
* @param {any} context
|
|
332
|
-
* @param {VNode} parent
|
|
333
|
-
* @param opcodes
|
|
334
|
-
*/
|
|
335
|
-
function _renderToString(
|
|
336
|
-
vnode,
|
|
337
|
-
context,
|
|
338
|
-
parent,
|
|
339
|
-
opcodes,
|
|
340
|
-
) {
|
|
341
|
-
// Ignore non-rendered VNodes/values
|
|
342
|
-
if (vnode == null || vnode === true || vnode === false || vnode === '') {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Text VNodes: escape as HTML
|
|
347
|
-
if (typeof vnode !== 'object') {
|
|
348
|
-
if (typeof vnode === 'function') return;
|
|
349
|
-
|
|
350
|
-
opcodes.push(__OpText, vnode + '');
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// Recurse into children / Arrays
|
|
355
|
-
if (isArray(vnode)) {
|
|
356
|
-
parent[CHILDREN] = vnode;
|
|
357
|
-
for (let i = 0; i < vnode.length; i++) {
|
|
358
|
-
const child = vnode[i];
|
|
359
|
-
if (child == null || typeof child === 'boolean') continue;
|
|
360
|
-
|
|
361
|
-
_renderToString(child, context, parent, opcodes);
|
|
362
|
-
}
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// VNodes have {constructor:undefined} to prevent JSON injection:
|
|
367
|
-
// if (vnode.constructor !== undefined) return;
|
|
368
|
-
|
|
369
|
-
vnode[PARENT] = parent;
|
|
370
|
-
if (beforeDiff) beforeDiff(vnode);
|
|
371
|
-
if (beforeDiff2) beforeDiff2(vnode, EMPTY_OBJ);
|
|
372
|
-
|
|
373
|
-
let type = vnode.type,
|
|
374
|
-
props = vnode.props;
|
|
375
|
-
|
|
376
|
-
// Invoke rendering on Components
|
|
377
|
-
if (typeof type === 'function') {
|
|
378
|
-
if (type === __ElementTemplatePage) {
|
|
379
|
-
opcodes.push(
|
|
380
|
-
__OpPageStart,
|
|
381
|
-
prepareTypedElementAttributes(ELEMENT_TEMPLATE_PAGE_HANDLE_ID, props.attributes),
|
|
382
|
-
);
|
|
383
|
-
renderComponentVNode(vnode, type, props, context, opcodes);
|
|
384
|
-
if (__DEV__) {
|
|
385
|
-
opcodes.push(__OpPageEnd);
|
|
386
|
-
}
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
renderComponentVNode(vnode, type, props, context, opcodes);
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (typeof type === 'string') {
|
|
394
|
-
renderStringHostVNode(type, vnode, props, context, opcodes);
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (__DEV__) {
|
|
399
|
-
cleanupVNode(vnode);
|
|
400
|
-
throw new Error('Element Template main-thread renderer received an invalid vnode.');
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/** The `.render()` method for a PFC backing instance. */
|
|
405
|
-
function doRender(props, state, context) {
|
|
406
|
-
return this.constructor(props, context);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export default renderToString;
|
|
410
|
-
export const render: typeof renderToString = renderToString;
|
|
411
|
-
export const renderToStaticMarkup: typeof renderToString = renderToString;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
|
|
5
|
-
import { RUNTIME_BACKEND_ELEMENT_TEMPLATE, registerRuntimeBackend } from '../core/lynx/runtime-backend.js';
|
|
6
|
-
|
|
7
|
-
registerRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
|
|
5
|
-
import { RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend } from './core/lynx/runtime-backend.js';
|
|
6
|
-
|
|
7
|
-
registerRuntimeBackend(RUNTIME_BACKEND_SNAPSHOT);
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Resolve $0 through symlinks so basedir is the shim's real directory.
|
|
3
|
-
# Cap hops at the kernel's ELOOP limit so a cycle cannot hang the shim.
|
|
4
|
-
link="$0"
|
|
5
|
-
hops=0
|
|
6
|
-
while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
|
|
7
|
-
hops=$((hops+1))
|
|
8
|
-
target=$(readlink "$link")
|
|
9
|
-
case "$target" in
|
|
10
|
-
/*) link="$target" ;;
|
|
11
|
-
*) link="$(dirname "$link")/$target" ;;
|
|
12
|
-
esac
|
|
13
|
-
done
|
|
14
|
-
basedir=$(dirname "$(echo "$link" | sed -e 's,\\,/,g')")
|
|
15
|
-
basedir_win="$basedir"
|
|
16
|
-
exe=""
|
|
17
|
-
msys=""
|
|
18
|
-
|
|
19
|
-
case `uname -a` in
|
|
20
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
21
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
22
|
-
basedir_win=`cygpath -w "$basedir"`
|
|
23
|
-
fi
|
|
24
|
-
exe=".exe"
|
|
25
|
-
msys="true"
|
|
26
|
-
;;
|
|
27
|
-
*WSL2*)
|
|
28
|
-
if command -v wslpath > /dev/null 2>&1; then
|
|
29
|
-
basedir_win="$(wslpath -w "$basedir" 2> /dev/null)"
|
|
30
|
-
if [ $? -ne 0 ] || [ -z "$basedir_win" ]; then
|
|
31
|
-
basedir_win="$basedir"
|
|
32
|
-
else
|
|
33
|
-
exe=".exe"
|
|
34
|
-
fi
|
|
35
|
-
fi
|
|
36
|
-
;;
|
|
37
|
-
esac
|
|
38
|
-
|
|
39
|
-
if [ -z "$NODE_PATH" ]; then
|
|
40
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rsbuild+core@2.2.4_core-js@3.50.0/node_modules/@rsbuild/core/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rsbuild+core@2.2.4_core-js@3.50.0/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules"
|
|
41
|
-
else
|
|
42
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rsbuild+core@2.2.4_core-js@3.50.0/node_modules/@rsbuild/core/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rsbuild+core@2.2.4_core-js@3.50.0/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
43
|
-
fi
|
|
44
|
-
if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
|
|
45
|
-
exec "$basedir/node.exe" "$basedir_win/../@rsbuild/core/bin/rsbuild.js" "$@"
|
|
46
|
-
elif [ -x "$basedir/node" ]; then
|
|
47
|
-
exec "$basedir/node" "$basedir/../@rsbuild/core/bin/rsbuild.js" "$@"
|
|
48
|
-
elif command -v node >/dev/null 2>&1; then
|
|
49
|
-
exec node "$basedir/../@rsbuild/core/bin/rsbuild.js" "$@"
|
|
50
|
-
elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
|
|
51
|
-
exec node.exe "$basedir_win/../@rsbuild/core/bin/rsbuild.js" "$@"
|
|
52
|
-
else
|
|
53
|
-
exec node "$basedir/../@rsbuild/core/bin/rsbuild.js" "$@"
|
|
54
|
-
fi
|
|
55
|
-
# cmd-shim-target=/home/runner/work/lynx-stack/lynx-stack/packages/react/testing-library/node_modules/@rsbuild/core/./bin/rsbuild.js
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Resolve $0 through symlinks so basedir is the shim's real directory.
|
|
3
|
-
# Cap hops at the kernel's ELOOP limit so a cycle cannot hang the shim.
|
|
4
|
-
link="$0"
|
|
5
|
-
hops=0
|
|
6
|
-
while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
|
|
7
|
-
hops=$((hops+1))
|
|
8
|
-
target=$(readlink "$link")
|
|
9
|
-
case "$target" in
|
|
10
|
-
/*) link="$target" ;;
|
|
11
|
-
*) link="$(dirname "$link")/$target" ;;
|
|
12
|
-
esac
|
|
13
|
-
done
|
|
14
|
-
basedir=$(dirname "$(echo "$link" | sed -e 's,\\,/,g')")
|
|
15
|
-
basedir_win="$basedir"
|
|
16
|
-
exe=""
|
|
17
|
-
msys=""
|
|
18
|
-
|
|
19
|
-
case `uname -a` in
|
|
20
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
21
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
22
|
-
basedir_win=`cygpath -w "$basedir"`
|
|
23
|
-
fi
|
|
24
|
-
exe=".exe"
|
|
25
|
-
msys="true"
|
|
26
|
-
;;
|
|
27
|
-
*WSL2*)
|
|
28
|
-
if command -v wslpath > /dev/null 2>&1; then
|
|
29
|
-
basedir_win="$(wslpath -w "$basedir" 2> /dev/null)"
|
|
30
|
-
if [ $? -ne 0 ] || [ -z "$basedir_win" ]; then
|
|
31
|
-
basedir_win="$basedir"
|
|
32
|
-
else
|
|
33
|
-
exe=".exe"
|
|
34
|
-
fi
|
|
35
|
-
fi
|
|
36
|
-
;;
|
|
37
|
-
esac
|
|
38
|
-
|
|
39
|
-
if [ -z "$NODE_PATH" ]; then
|
|
40
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules"
|
|
41
|
-
else
|
|
42
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
43
|
-
fi
|
|
44
|
-
if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
|
|
45
|
-
exec "$basedir/node.exe" "$basedir_win/../@lynx-js/rspeedy/bin/rspeedy-for-dev.js" "$@"
|
|
46
|
-
elif [ -x "$basedir/node" ]; then
|
|
47
|
-
exec "$basedir/node" "$basedir/../@lynx-js/rspeedy/bin/rspeedy-for-dev.js" "$@"
|
|
48
|
-
elif command -v node >/dev/null 2>&1; then
|
|
49
|
-
exec node "$basedir/../@lynx-js/rspeedy/bin/rspeedy-for-dev.js" "$@"
|
|
50
|
-
elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
|
|
51
|
-
exec node.exe "$basedir_win/../@lynx-js/rspeedy/bin/rspeedy-for-dev.js" "$@"
|
|
52
|
-
else
|
|
53
|
-
exec node "$basedir/../@lynx-js/rspeedy/bin/rspeedy-for-dev.js" "$@"
|
|
54
|
-
fi
|
|
55
|
-
# cmd-shim-target=/home/runner/work/lynx-stack/lynx-stack/packages/react/testing-library/node_modules/@lynx-js/rspeedy/./bin/rspeedy-for-dev.js
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Resolve $0 through symlinks so basedir is the shim's real directory.
|
|
3
|
-
# Cap hops at the kernel's ELOOP limit so a cycle cannot hang the shim.
|
|
4
|
-
link="$0"
|
|
5
|
-
hops=0
|
|
6
|
-
while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
|
|
7
|
-
hops=$((hops+1))
|
|
8
|
-
target=$(readlink "$link")
|
|
9
|
-
case "$target" in
|
|
10
|
-
/*) link="$target" ;;
|
|
11
|
-
*) link="$(dirname "$link")/$target" ;;
|
|
12
|
-
esac
|
|
13
|
-
done
|
|
14
|
-
basedir=$(dirname "$(echo "$link" | sed -e 's,\\,/,g')")
|
|
15
|
-
basedir_win="$basedir"
|
|
16
|
-
exe=""
|
|
17
|
-
msys=""
|
|
18
|
-
|
|
19
|
-
case `uname -a` in
|
|
20
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
21
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
22
|
-
basedir_win=`cygpath -w "$basedir"`
|
|
23
|
-
fi
|
|
24
|
-
exe=".exe"
|
|
25
|
-
msys="true"
|
|
26
|
-
;;
|
|
27
|
-
*WSL2*)
|
|
28
|
-
if command -v wslpath > /dev/null 2>&1; then
|
|
29
|
-
basedir_win="$(wslpath -w "$basedir" 2> /dev/null)"
|
|
30
|
-
if [ $? -ne 0 ] || [ -z "$basedir_win" ]; then
|
|
31
|
-
basedir_win="$basedir"
|
|
32
|
-
else
|
|
33
|
-
exe=".exe"
|
|
34
|
-
fi
|
|
35
|
-
fi
|
|
36
|
-
;;
|
|
37
|
-
esac
|
|
38
|
-
|
|
39
|
-
if [ -z "$NODE_PATH" ]; then
|
|
40
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rstest+core@0.11.12_core-js@3.50.0_happy-dom@20.14.0_jsdom@30.0.1/node_modules/@rstest/core/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rstest+core@0.11.12_core-js@3.50.0_happy-dom@20.14.0_jsdom@30.0.1/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules"
|
|
41
|
-
else
|
|
42
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rstest+core@0.11.12_core-js@3.50.0_happy-dom@20.14.0_jsdom@30.0.1/node_modules/@rstest/core/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/@rstest+core@0.11.12_core-js@3.50.0_happy-dom@20.14.0_jsdom@30.0.1/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
43
|
-
fi
|
|
44
|
-
if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
|
|
45
|
-
exec "$basedir/node.exe" "$basedir_win/../@rstest/core/bin/rstest.js" "$@"
|
|
46
|
-
elif [ -x "$basedir/node" ]; then
|
|
47
|
-
exec "$basedir/node" "$basedir/../@rstest/core/bin/rstest.js" "$@"
|
|
48
|
-
elif command -v node >/dev/null 2>&1; then
|
|
49
|
-
exec node "$basedir/../@rstest/core/bin/rstest.js" "$@"
|
|
50
|
-
elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
|
|
51
|
-
exec node.exe "$basedir_win/../@rstest/core/bin/rstest.js" "$@"
|
|
52
|
-
else
|
|
53
|
-
exec node "$basedir/../@rstest/core/bin/rstest.js" "$@"
|
|
54
|
-
fi
|
|
55
|
-
# cmd-shim-target=/home/runner/work/lynx-stack/lynx-stack/packages/react/testing-library/node_modules/@rstest/core/./bin/rstest.js
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Resolve $0 through symlinks so basedir is the shim's real directory.
|
|
3
|
-
# Cap hops at the kernel's ELOOP limit so a cycle cannot hang the shim.
|
|
4
|
-
link="$0"
|
|
5
|
-
hops=0
|
|
6
|
-
while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
|
|
7
|
-
hops=$((hops+1))
|
|
8
|
-
target=$(readlink "$link")
|
|
9
|
-
case "$target" in
|
|
10
|
-
/*) link="$target" ;;
|
|
11
|
-
*) link="$(dirname "$link")/$target" ;;
|
|
12
|
-
esac
|
|
13
|
-
done
|
|
14
|
-
basedir=$(dirname "$(echo "$link" | sed -e 's,\\,/,g')")
|
|
15
|
-
basedir_win="$basedir"
|
|
16
|
-
exe=""
|
|
17
|
-
msys=""
|
|
18
|
-
|
|
19
|
-
case `uname -a` in
|
|
20
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
21
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
22
|
-
basedir_win=`cygpath -w "$basedir"`
|
|
23
|
-
fi
|
|
24
|
-
exe=".exe"
|
|
25
|
-
msys="true"
|
|
26
|
-
;;
|
|
27
|
-
*WSL2*)
|
|
28
|
-
if command -v wslpath > /dev/null 2>&1; then
|
|
29
|
-
basedir_win="$(wslpath -w "$basedir" 2> /dev/null)"
|
|
30
|
-
if [ $? -ne 0 ] || [ -z "$basedir_win" ]; then
|
|
31
|
-
basedir_win="$basedir"
|
|
32
|
-
else
|
|
33
|
-
exe=".exe"
|
|
34
|
-
fi
|
|
35
|
-
fi
|
|
36
|
-
;;
|
|
37
|
-
esac
|
|
38
|
-
|
|
39
|
-
if [ -z "$NODE_PATH" ]; then
|
|
40
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/esbuild@0.28.1/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules"
|
|
41
|
-
else
|
|
42
|
-
export NODE_PATH="/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/esbuild@0.28.1/node_modules/esbuild/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/esbuild@0.28.1/node_modules:/home/runner/work/lynx-stack/lynx-stack/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
43
|
-
fi
|
|
44
|
-
exec "$basedir/../esbuild/bin/esbuild" "$@"
|
|
45
|
-
exit $?
|
|
46
|
-
# cmd-shim-target=/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/node_modules/esbuild/bin/esbuild
|