@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
|
@@ -0,0 +1,194 @@
|
|
|
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 { createRenderedHost, discardRenderedHostsSince } from './create-rendered-host.js';
|
|
5
|
+
import { EMPTY_OBJ, beforeDiff, beforeDiff2, cleanupVNode, renderComponentVNode, renderWithHooks, } from './render-components.js';
|
|
6
|
+
import { CHILDREN, PARENT } from '../../../shared/render-constants.js';
|
|
7
|
+
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID } from '../../protocol/page.js';
|
|
8
|
+
import { clearPendingElementTemplateListItems } from '../list/list.js';
|
|
9
|
+
import { __ElementTemplatePage } from '../page/authored-page.js';
|
|
10
|
+
import { createElementTemplateWithReservedHandle, getNextElementTemplateId, reserveElementTemplateId, } from '../template/handle.js';
|
|
11
|
+
import { prepareTypedElementAttributes } from '../template/typed-attributes.js';
|
|
12
|
+
const isArray = /* @__PURE__ */ Array.isArray;
|
|
13
|
+
export function renderToElementTemplate(vnode, context) {
|
|
14
|
+
const checkpoint = getNextElementTemplateId();
|
|
15
|
+
const result = {
|
|
16
|
+
pageAttributes: undefined,
|
|
17
|
+
rootRefs: [],
|
|
18
|
+
rootSubtreeHandles: [],
|
|
19
|
+
};
|
|
20
|
+
if (__DEV__) {
|
|
21
|
+
result.isInsideAuthoredPage = false;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
/* #__NOINLINE__ */ renderWithHooks(vnode, context, result.rootRefs, renderDirect, result);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
discardRenderedHostsSince(checkpoint);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
// Completed lists consume their item records. Anything left belongs to
|
|
32
|
+
// abandoned content, including children discarded by Suspense.
|
|
33
|
+
clearPendingElementTemplateListItems();
|
|
34
|
+
}
|
|
35
|
+
result.pageAttributes ??= null;
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function validateRoot(result, parentType) {
|
|
39
|
+
if (parentType === undefined && result.pageAttributes !== undefined
|
|
40
|
+
&& !result.isInsideAuthoredPage) {
|
|
41
|
+
throw new Error('Element Template authored <page /> must wrap all materialized roots.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function renderHost(vnode, context, output, result, parentType, parentSubtreeHandles, parentListItemUids) {
|
|
45
|
+
const type = vnode.type;
|
|
46
|
+
const props = vnode.templateKey === undefined ? vnode.props : vnode;
|
|
47
|
+
const isList = type === 'list';
|
|
48
|
+
const attributes = (isList ? props['attributes'] : props['attributeSlots']);
|
|
49
|
+
const listItemPlatformInfo = props['__listItemPlatformInfo'];
|
|
50
|
+
let deferredListItemMarker = false;
|
|
51
|
+
if (__DEV__) {
|
|
52
|
+
deferredListItemMarker = props['isReady'] !== undefined;
|
|
53
|
+
validateRoot(result, parentType);
|
|
54
|
+
}
|
|
55
|
+
if (!isList && !(type.startsWith('_et_') || type.includes(':_et_'))) {
|
|
56
|
+
cleanupVNode(vnode);
|
|
57
|
+
throw new Error(`Element Template main-thread renderer received an uncompiled host vnode: ${type}`);
|
|
58
|
+
}
|
|
59
|
+
// Recursive locals retain the inputs until children finish. Only native
|
|
60
|
+
// child arrays and the root/list-item ref collector survive this call.
|
|
61
|
+
const subtreeHandles = parentType === undefined || parentType === 'list' ? [] : parentSubtreeHandles;
|
|
62
|
+
let childSlots;
|
|
63
|
+
let listItemUids;
|
|
64
|
+
if (isList) {
|
|
65
|
+
try {
|
|
66
|
+
if (__DEV__) {
|
|
67
|
+
for (const name in props) {
|
|
68
|
+
if (name.startsWith('$') && name !== '$0') {
|
|
69
|
+
throw new Error('Element Template typed list only supports logical slot $0.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const children = props['$0'];
|
|
74
|
+
if (children != null && children !== true && children !== false) {
|
|
75
|
+
const refs = [];
|
|
76
|
+
childSlots = [refs];
|
|
77
|
+
listItemUids = [];
|
|
78
|
+
renderDirect(children, context, vnode, refs, result, type, subtreeHandles, listItemUids);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
cleanupVNode(vnode);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Ordered inputs belong to the caller. Named inputs are collected into a
|
|
87
|
+
// renderer-owned array that can also hold the resulting native refs.
|
|
88
|
+
let childrenBySlot = props['slotChildren'];
|
|
89
|
+
if (vnode.templateKey === undefined && childrenBySlot === undefined) {
|
|
90
|
+
for (const name in props) {
|
|
91
|
+
if (name.startsWith('$')) {
|
|
92
|
+
const children = props[name];
|
|
93
|
+
if (children == null || children === true || children === false)
|
|
94
|
+
continue;
|
|
95
|
+
(childrenBySlot ??= [])[+name.slice(1)] = children;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
childSlots = childrenBySlot;
|
|
99
|
+
}
|
|
100
|
+
if (childrenBySlot !== undefined) {
|
|
101
|
+
for (let slotId = 0; slotId < childrenBySlot.length; slotId++) {
|
|
102
|
+
const children = childrenBySlot[slotId];
|
|
103
|
+
if (children == null || children === true || children === false)
|
|
104
|
+
continue;
|
|
105
|
+
const refs = (childSlots ??= [])[slotId] = [];
|
|
106
|
+
renderDirect(children, context, vnode, refs, result, type, subtreeHandles, undefined);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
cleanupVNode(vnode);
|
|
110
|
+
}
|
|
111
|
+
if (__DEV__ && !isList && parentType === 'list') {
|
|
112
|
+
if (deferredListItemMarker) {
|
|
113
|
+
throw new Error('Element Template typed list does not support deferred list items.');
|
|
114
|
+
}
|
|
115
|
+
if (listItemPlatformInfo === undefined) {
|
|
116
|
+
throw new Error('Element Template typed list received a non-list-item root in logical slot $0.');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const uid = reserveElementTemplateId();
|
|
120
|
+
const ref = /* #__NOINLINE__ */ createRenderedHost(uid, type, attributes, childSlots, listItemUids, subtreeHandles, listItemPlatformInfo, vnode.templateKey === undefined ? undefined : vnode);
|
|
121
|
+
output.push(ref);
|
|
122
|
+
if (parentType === undefined) {
|
|
123
|
+
result.rootSubtreeHandles.push(isList ? [] : subtreeHandles);
|
|
124
|
+
}
|
|
125
|
+
else if (parentListItemUids !== undefined) {
|
|
126
|
+
parentListItemUids.push(uid);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function renderDirect(value, context, parent, output, result, parentType, subtreeHandles, listItemUids) {
|
|
130
|
+
if (value == null || value === true || value === false || value === '')
|
|
131
|
+
return;
|
|
132
|
+
if (typeof value !== 'object') {
|
|
133
|
+
if (typeof value === 'function')
|
|
134
|
+
return;
|
|
135
|
+
if (__DEV__) {
|
|
136
|
+
validateRoot(result, parentType);
|
|
137
|
+
if (parentType === 'list') {
|
|
138
|
+
throw new Error('Element Template typed list received text logical child.');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
output.push(createElementTemplateWithReservedHandle(reserveElementTemplateId(), '_et_builtin_raw_text', null, [value + ''], []));
|
|
142
|
+
if (parentType === undefined)
|
|
143
|
+
result.rootSubtreeHandles.push([]);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (isArray(value)) {
|
|
147
|
+
parent[CHILDREN] = value;
|
|
148
|
+
for (let index = 0; index < value.length; index++) {
|
|
149
|
+
const child = value[index];
|
|
150
|
+
if (child == null || typeof child === 'boolean')
|
|
151
|
+
continue;
|
|
152
|
+
renderDirect(child, context, parent, output, result, parentType, subtreeHandles, listItemUids);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const vnode = value;
|
|
157
|
+
vnode[PARENT] = parent;
|
|
158
|
+
if (beforeDiff)
|
|
159
|
+
beforeDiff(vnode);
|
|
160
|
+
if (beforeDiff2)
|
|
161
|
+
beforeDiff2(vnode, EMPTY_OBJ);
|
|
162
|
+
const type = vnode.type;
|
|
163
|
+
const props = vnode.props;
|
|
164
|
+
if (typeof type === 'function') {
|
|
165
|
+
if (type === __ElementTemplatePage) {
|
|
166
|
+
if (__DEV__) {
|
|
167
|
+
if (parentType !== undefined) {
|
|
168
|
+
throw new Error('Element Template authored <page /> must be the outermost element.');
|
|
169
|
+
}
|
|
170
|
+
if (result.pageAttributes !== undefined) {
|
|
171
|
+
throw new Error('Element Template does not support multiple authored <page /> elements.');
|
|
172
|
+
}
|
|
173
|
+
if (result.rootRefs.length !== 0) {
|
|
174
|
+
throw new Error('Element Template authored <page /> must wrap all materialized roots.');
|
|
175
|
+
}
|
|
176
|
+
result.isInsideAuthoredPage = true;
|
|
177
|
+
}
|
|
178
|
+
result.pageAttributes = prepareTypedElementAttributes(ELEMENT_TEMPLATE_PAGE_HANDLE_ID, props['attributes']);
|
|
179
|
+
}
|
|
180
|
+
/* #__NOINLINE__ */ renderComponentVNode(vnode, type, props, context, output, renderDirect, result, parentType, subtreeHandles, listItemUids);
|
|
181
|
+
if (__DEV__ && type === __ElementTemplatePage)
|
|
182
|
+
result.isInsideAuthoredPage = false;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (typeof type === 'string') {
|
|
186
|
+
/* #__NOINLINE__ */ renderHost(vnode, context, output, result, parentType, subtreeHandles, listItemUids);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (__DEV__) {
|
|
190
|
+
cleanupVNode(vnode);
|
|
191
|
+
throw new Error('Element Template main-thread renderer received an invalid vnode.');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=render-direct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-direct.js","sourceRoot":"","sources":["../../../../src/element-template/runt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oBAC7B,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;gBACvF,CAAC;gBACD,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;oBACxC,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;gBAC5F,CAAC;gBACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACjC,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;gBAC1F,CAAC;gBACD,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACrC,CAAC;YACD,MAAM,CAAC,cAAc,GAAG,6BAA6B,CACnD,+BAA+B,EAC/B,KAAK,CAAC,YAAY,CAA8C,CACjE,CAAC;QACJ,CAAC;QACD,mBAAmB,CAAC,oBAAoB,CACtC,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACP,MAAM,EACN,YAAY,EACZ,MAAM,EACN,UAAU,EACV,cAAc,EACd,YAAY,CACb,CAAC;QACF,IAAI,OAAO,IAAI,IAAI,KAAK,qBAAqB;YAAE,MAAM,CAAC,oBAAoB,GAAG,KAAK,CAAC;QACnF,OAAO;IACT,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,mBAAmB,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QACzG,OAAO;IACT,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Implements the IFR (Instant First-Frame Rendering) on main thread.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { render as renderToString } from './render-to-opcodes.js';
|
|
7
|
+
import { renderToElementTemplate } from './render-direct.js';
|
|
9
8
|
import { getReloadVersion } from '../../../core/reload-version.js';
|
|
10
9
|
import { profileEnd, profileStart } from '../../debug/profile.js';
|
|
11
10
|
import { ElementTemplateLifecycleConstant } from '../../protocol/lifecycle-constant.js';
|
|
@@ -17,21 +16,23 @@ import { insertElementTemplateSubtree } from '../template/handle.js';
|
|
|
17
16
|
import { getElementTemplateNativeRef } from '../template/registry.js';
|
|
18
17
|
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';
|
|
19
18
|
function renderMainThread() {
|
|
20
|
-
let
|
|
19
|
+
let rendered;
|
|
21
20
|
profileStart('ReactLynx::renderMainThread');
|
|
22
21
|
try {
|
|
23
|
-
|
|
22
|
+
rendered = renderToElementTemplate(__root.__jsx, undefined);
|
|
24
23
|
}
|
|
25
|
-
catch (
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
catch (error) {
|
|
25
|
+
// Like Snapshot, any failure during synchronous rendering is reported at
|
|
26
|
+
// the lifecycle boundary before committing an empty result.
|
|
27
|
+
lynx.reportError(error);
|
|
28
|
+
rendered = { pageAttributes: null, rootRefs: [], rootSubtreeHandles: [] };
|
|
28
29
|
}
|
|
29
30
|
finally {
|
|
30
31
|
profileEnd();
|
|
31
32
|
}
|
|
32
|
-
profileStart('ReactLynx::
|
|
33
|
+
profileStart('ReactLynx::commitElementTemplate');
|
|
33
34
|
try {
|
|
34
|
-
const { pageAttributes, rootRefs, rootSubtreeHandles } =
|
|
35
|
+
const { pageAttributes, rootRefs, rootSubtreeHandles } = rendered;
|
|
35
36
|
__SetAttributeOfElementTemplate(__page, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, pageAttributes);
|
|
36
37
|
for (let index = 0; index < rootRefs.length; index += 1) {
|
|
37
38
|
const rootRef = rootRefs[index];
|
|
@@ -1 +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,
|
|
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,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,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;AACxF,OAAO,EAAE,qCAAqC,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,sCAAsC,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AAEtF,SAAS,gBAAgB;IACvB,IAAI,QAAQ,CAAC;IACb,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC5C,IAAI,CAAC;QACH,QAAQ,GAAG,uBAAuB,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yEAAyE;QACzE,4DAA4D;QAC5D,IAAI,CAAC,WAAW,CAAC,KAAc,CAAC,CAAC;QACjC,QAAQ,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,EA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,OAAO,CAAC,KAAK,CAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,2BAA2B,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxD,IAAI,OAAO,EAAE,CAAC;YACZ,+BAA+B,CAAC,OAAO,EAAE,mCAAmC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { MainThreadDynamicAttrSubtreeHandle } from './main-thread-dynamic-attr-state.js';
|
|
2
2
|
import type { RuntimeChildSlots, RuntimeOptions, RuntimeTypedElementAttributes, RuntimeTypedListOptions, SerializableValue } from '../../protocol/types.js';
|
|
3
|
+
export declare function getNextElementTemplateId(): number;
|
|
3
4
|
export declare function reserveElementTemplateId(): number;
|
|
4
|
-
export declare function createElementTemplateWithReservedHandle(handleId: number, templateKey: string, bundleUrl: string | null | undefined, attributeSlots: SerializableValue[] | null | undefined, childSlots: RuntimeChildSlots | null | undefined): ElementTemplateHandle;
|
|
5
|
+
export declare function createElementTemplateWithReservedHandle(handleId: number, templateKey: string, bundleUrl: string | null | undefined, attributeSlots: SerializableValue[] | null | undefined, childSlots: RuntimeChildSlots | null | undefined, hasDynamicAttributes?: boolean): ElementTemplateHandle;
|
|
5
6
|
export declare function createTypedElementTemplateWithReservedHandle(handleId: number, type: string, attributes: RuntimeTypedElementAttributes | null | undefined, childSlots: RuntimeChildSlots | null | undefined, options: RuntimeOptions | RuntimeTypedListOptions | null | undefined): ElementTemplateHandle;
|
|
6
7
|
export declare function insertElementTemplateSubtree(targetRef: ElementTemplateHandle, childSlotIndex: number, childRef: ElementTemplateHandle, referenceRef: ElementTemplateHandle | null, subtreeHandles: readonly MainThreadDynamicAttrSubtreeHandle[] | null): void;
|
|
7
8
|
export declare function resetTemplateId(): void;
|
|
@@ -6,17 +6,25 @@ import { deleteElementTemplateNativeRef, setElementTemplateNativeRef } from './r
|
|
|
6
6
|
import { elementTemplateTypeTag } from '../../protocol/template-type.js';
|
|
7
7
|
// Main-thread IFR allocates ids as consecutive negative integers.
|
|
8
8
|
let nextId = -1;
|
|
9
|
+
export function getNextElementTemplateId() {
|
|
10
|
+
return nextId;
|
|
11
|
+
}
|
|
9
12
|
export function reserveElementTemplateId() {
|
|
10
13
|
const id = nextId--;
|
|
11
14
|
return id;
|
|
12
15
|
}
|
|
13
|
-
export function createElementTemplateWithReservedHandle(handleId, templateKey, bundleUrl, attributeSlots, childSlots) {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
+
export function createElementTemplateWithReservedHandle(handleId, templateKey, bundleUrl, attributeSlots, childSlots, hasDynamicAttributes = true) {
|
|
17
|
+
// Adapter-free compiled hosts need neither dynamic state nor native slot preparation.
|
|
18
|
+
const templateType = hasDynamicAttributes ? elementTemplateTypeTag(templateKey, bundleUrl) : undefined;
|
|
19
|
+
const nativeAttributeSlots = templateType === undefined
|
|
20
|
+
? attributeSlots
|
|
21
|
+
: prepareMainThreadDynamicAttrSlotsForNative(templateType, attributeSlots);
|
|
16
22
|
const nativeRef = __CreateElementTemplate(templateKey, bundleUrl, nativeAttributeSlots, childSlots, handleId);
|
|
17
23
|
if (nativeRef) {
|
|
18
24
|
setElementTemplateNativeRef(handleId, nativeRef);
|
|
19
|
-
|
|
25
|
+
if (templateType !== undefined) {
|
|
26
|
+
initializeMainThreadDynamicAttrSlots(handleId, templateType, attributeSlots);
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
29
|
return nativeRef;
|
|
22
30
|
}
|
|
@@ -1 +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,EACL,yCAAyC,EACzC,0CAA0C,EAC1C,oCAAoC,EACpC,0CAA0C,GAC3C,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AASzE,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,UAAgD;
|
|
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,EACL,yCAAyC,EACzC,0CAA0C,EAC1C,oCAAoC,EACpC,0CAA0C,GAC3C,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,8BAA8B,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AASzE,kEAAkE;AAClE,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;AAEhB,MAAM,UAAU,wBAAwB;IACtC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,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,UAAgD,EAChD,oBAAoB,GAAG,IAAI;IAE3B,sFAAsF;IACtF,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,CAAC,sBAAsB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACvG,MAAM,oBAAoB,GAAG,YAAY,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+1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
// Side-effect entry that registers this bundle's runtime markers (backend,
|
|
5
|
+
// version, ...) on load. Imported once by the element-template runtime entry
|
|
6
|
+
// so later-loaded lazy bundles register their own markers too.
|
|
7
|
+
import { RUNTIME_BACKEND_ELEMENT_TEMPLATE, registerRuntimeBackend } from '../core/lynx/runtime-backend.js';
|
|
8
|
+
import { registerRuntimeVersion } from '../core/lynx/runtime-version.js';
|
|
9
|
+
registerRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
10
|
+
// An older `react-webpack-plugin` may not stamp `__RUNTIME_VERSION__`. Guard
|
|
11
|
+
// with `typeof` so referencing it does not throw when the define is missing.
|
|
12
|
+
registerRuntimeVersion(typeof __RUNTIME_VERSION__ === 'undefined' ? undefined : __RUNTIME_VERSION__);
|
|
13
|
+
//# sourceMappingURL=runtime-marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-marker.js","sourceRoot":"","sources":["../../src/element-template/runtime-marker.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,2EAA2E;AAC3E,6EAA6E;AAC7E,+DAA+D;AAE/D,OAAO,EAAE,gCAAgC,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,sBAAsB,CAAC,gCAAgC,CAAC,CAAC;AACzD,6EAA6E;AAC7E,6EAA6E;AAC7E,sBAAsB,CACpB,OAAO,mBAAmB,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAC7E,CAAC"}
|
package/runtime/lib/index.d.ts
CHANGED
package/runtime/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import './runtime-
|
|
4
|
+
import './runtime-marker.js';
|
|
5
5
|
import './lynx.js';
|
|
6
6
|
import { Component, Fragment, PureComponent, createContext, createRef, forwardRef, isValidElement, lazy, memo, useSyncExternalStore, } from 'preact/compat';
|
|
7
7
|
import { installComponentCompat } from './core/component.js';
|
package/runtime/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,WAAW,CAAC;AACnB,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKvD,sBAAsB,EAAE,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AAEtC;;GAEG;AACH,eAAe;IACb,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,SAAS;IACT,eAAe;IACf,MAAM;IACN,mBAAmB;IACnB,OAAO;IACP,WAAW;IACX,UAAU;IACV,aAAa;IACb,oBAAoB;IAEpB,aAAa;IACb,SAAS;IACT,QAAQ;IACR,cAAc;IACd,QAAQ;IACR,SAAS;IACT,aAAa;IACb,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,IAAI;IACJ,aAAa;IACb,YAAY;IACZ,YAAY;CACb,CAAC;AAEF,OAAO,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,YAAY,GACb,CAAC;AAEF,cAAc,eAAe,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cloneElement as preactCloneElement } from 'preact/compat';
|
|
2
|
-
import './runtime-
|
|
2
|
+
import './runtime-marker.js';
|
|
3
3
|
import './lynx.js';
|
|
4
4
|
import { __root } from './root.js';
|
|
5
5
|
import { BackgroundSnapshotInstance } from './snapshot/snapshot/backgroundSnapshot.js';
|
|
@@ -28,9 +28,12 @@ export { preactCloneElement };
|
|
|
28
28
|
export { options, Component, process, } from 'preact';
|
|
29
29
|
export type { Options } from 'preact';
|
|
30
30
|
export { loadDynamicJS, __dynamicImport } from './core/lynx/dynamic-import.js';
|
|
31
|
+
export { registerRuntimeVersion, getRuntimeVersion } from './core/lynx/runtime-version.js';
|
|
32
|
+
export { RUNTIME_BACKEND_ELEMENT_TEMPLATE, RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend, } from './core/lynx/runtime-backend.js';
|
|
31
33
|
export { withInitDataInState } from './core/initData.js';
|
|
32
34
|
export { wrapWithLynxComponent } from './core/compat/lynxComponent.js';
|
|
33
35
|
export { loadLazyBundle } from './core/lynx/lazy-bundle.js';
|
|
34
36
|
export { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';
|
|
35
37
|
export { registerWorkletOnBackground } from './snapshot/worklet/hmr.js';
|
|
36
38
|
export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
|
|
39
|
+
export { captureMainThreadObject } from './core/capture-main-thread-object.js';
|
package/runtime/lib/internal.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { Suspense, createElement, lazy, cloneElement as preactCloneElement } from 'preact/compat';
|
|
5
|
-
import './runtime-
|
|
5
|
+
import './runtime-marker.js';
|
|
6
6
|
import './lynx.js';
|
|
7
7
|
import { useMemo } from './core/hooks/react.js';
|
|
8
8
|
import { loadLazyBundle } from './core/lynx/lazy-bundle.js';
|
|
@@ -38,6 +38,10 @@ export { options,
|
|
|
38
38
|
// Component is not an internal API, but refresh needs it from 'react/internal'
|
|
39
39
|
Component, process, } from 'preact';
|
|
40
40
|
export { loadDynamicJS, __dynamicImport } from './core/lynx/dynamic-import.js';
|
|
41
|
+
// Re-exported so lazy bundle shells can reach the host runtime APIs
|
|
42
|
+
// via `target[sExportsReactInternal]`.
|
|
43
|
+
export { registerRuntimeVersion, getRuntimeVersion } from './core/lynx/runtime-version.js';
|
|
44
|
+
export { RUNTIME_BACKEND_ELEMENT_TEMPLATE, RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend, } from './core/lynx/runtime-backend.js';
|
|
41
45
|
export { withInitDataInState } from './core/initData.js';
|
|
42
46
|
export { wrapWithLynxComponent } from './core/compat/lynxComponent.js';
|
|
43
47
|
/**
|
|
@@ -50,6 +54,7 @@ export { loadLazyBundle } from './core/lynx/lazy-bundle.js';
|
|
|
50
54
|
export { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';
|
|
51
55
|
export { registerWorkletOnBackground } from './snapshot/worklet/hmr.js';
|
|
52
56
|
export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
|
|
57
|
+
export { captureMainThreadObject } from './core/capture-main-thread-object.js';
|
|
53
58
|
if (__DEV__) {
|
|
54
59
|
// Dev snapshot creators take the runtime as a parameter (they are
|
|
55
60
|
// stringified for cross-thread HMR and must not capture module bindings);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGlG,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGlG,OAAO,qBAAqB,CAAC;AAC7B,OAAO,WAAW,CAAC;AAEnB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,qBAAqB,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,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AC1E,0EAA0E;IAC1E,yEAAyE;IACzE,yBAAyB,CAAC,qBAAqB,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -4,6 +4,8 @@ import { withInitDataInState } from './core/initData.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* The default root exported by `@lynx-js/react` for you to render a JSX
|
|
6
6
|
* @public
|
|
7
|
+
*
|
|
8
|
+
* @group Types
|
|
7
9
|
*/
|
|
8
10
|
export interface Root {
|
|
9
11
|
/**
|
|
@@ -67,6 +69,8 @@ export interface Root {
|
|
|
67
69
|
* ```
|
|
68
70
|
*
|
|
69
71
|
* @public
|
|
72
|
+
*
|
|
73
|
+
* @group Functions
|
|
70
74
|
*/
|
|
71
75
|
export declare const root: Root;
|
|
72
76
|
/**
|
|
@@ -86,6 +90,8 @@ export declare const root: Root;
|
|
|
86
90
|
* ```
|
|
87
91
|
*
|
|
88
92
|
* @public
|
|
93
|
+
*
|
|
94
|
+
* @group Functions
|
|
89
95
|
*/
|
|
90
96
|
export declare function markFirstScreenSyncReady(): void;
|
|
91
97
|
/**
|
|
@@ -113,6 +119,8 @@ export declare function markFirstScreenSyncReady(): void;
|
|
|
113
119
|
* ```
|
|
114
120
|
*
|
|
115
121
|
* @public
|
|
122
|
+
*
|
|
123
|
+
* @function
|
|
116
124
|
*/
|
|
117
125
|
export declare const InitDataProvider: FC<{
|
|
118
126
|
children?: ReactNode | undefined;
|
|
@@ -122,6 +130,8 @@ export declare const InitDataProvider: FC<{
|
|
|
122
130
|
* This should be used with {@link InitDataProvider}
|
|
123
131
|
* @group Components
|
|
124
132
|
* @public
|
|
133
|
+
*
|
|
134
|
+
* @function
|
|
125
135
|
*/
|
|
126
136
|
export declare const InitDataConsumer: Consumer<InitData>;
|
|
127
137
|
/**
|
|
@@ -138,7 +148,10 @@ export declare const InitDataConsumer: Consumer<InitData>;
|
|
|
138
148
|
* }
|
|
139
149
|
* ```
|
|
140
150
|
*
|
|
151
|
+
* @function
|
|
141
152
|
* @public
|
|
153
|
+
*
|
|
154
|
+
* @group Hooks
|
|
142
155
|
*/
|
|
143
156
|
export declare const useInitData: () => InitData;
|
|
144
157
|
/**
|
|
@@ -152,17 +165,23 @@ export declare const useInitData: () => InitData;
|
|
|
152
165
|
* })
|
|
153
166
|
* }
|
|
154
167
|
* ```
|
|
168
|
+
* @function
|
|
155
169
|
* @public
|
|
170
|
+
*
|
|
171
|
+
* @group Hooks
|
|
156
172
|
*/
|
|
157
173
|
export declare const useInitDataChanged: (callback: (data: InitData) => void) => void;
|
|
158
174
|
export type { GlobalProps } from './core/globalProps.js';
|
|
159
175
|
/**
|
|
160
|
-
* The {@link https://react.dev/reference/react/createContext#provider | Provider} Component that provide `lynx.__globalProps
|
|
161
|
-
*
|
|
176
|
+
* The {@link https://react.dev/reference/react/createContext#provider | Provider} Component that provide `lynx.__globalProps`.
|
|
177
|
+
* Only needed with `globalPropsMode: 'event'`; in the default `'reactive'` mode it renders its children directly
|
|
178
|
+
* and updates come from a full re-render.
|
|
162
179
|
* @group Components
|
|
163
180
|
*
|
|
164
181
|
* @example
|
|
165
182
|
*
|
|
183
|
+
* With `globalPropsMode: 'event'`:
|
|
184
|
+
*
|
|
166
185
|
* ```ts
|
|
167
186
|
* import { root } from "@lynx-js/react"
|
|
168
187
|
*
|
|
@@ -181,20 +200,26 @@ export type { GlobalProps } from './core/globalProps.js';
|
|
|
181
200
|
* ```
|
|
182
201
|
*
|
|
183
202
|
* @public
|
|
203
|
+
*
|
|
204
|
+
* @function
|
|
184
205
|
*/
|
|
185
206
|
export declare const GlobalPropsProvider: FC<{
|
|
186
207
|
children?: ReactNode | undefined;
|
|
187
208
|
}>;
|
|
188
209
|
/**
|
|
189
210
|
* The {@link https://react.dev/reference/react/createContext#consumer | Consumer} Component that provide `lynx.__globalProps`.
|
|
190
|
-
*
|
|
211
|
+
* Only needed with `globalPropsMode: 'event'`, together with {@link GlobalPropsProvider}; in the default `'reactive'` mode
|
|
212
|
+
* it calls `children` with `lynx.__globalProps` directly and updates come from a full re-render.
|
|
191
213
|
* @group Components
|
|
192
214
|
* @public
|
|
215
|
+
*
|
|
216
|
+
* @function
|
|
193
217
|
*/
|
|
194
218
|
export declare const GlobalPropsConsumer: Consumer<GlobalProps>;
|
|
195
219
|
/**
|
|
196
220
|
* A React Hooks for you to get `lynx.__globalProps`.
|
|
197
|
-
*
|
|
221
|
+
* With `globalPropsMode: 'event'`, the component re-renders when `lynx.__globalProps` changes;
|
|
222
|
+
* in the default `'reactive'` mode, updates arrive through a full re-render.
|
|
198
223
|
*
|
|
199
224
|
* @example
|
|
200
225
|
*
|
|
@@ -206,7 +231,10 @@ export declare const GlobalPropsConsumer: Consumer<GlobalProps>;
|
|
|
206
231
|
* }
|
|
207
232
|
* ```
|
|
208
233
|
*
|
|
234
|
+
* @function
|
|
209
235
|
* @public
|
|
236
|
+
*
|
|
237
|
+
* @group Hooks
|
|
210
238
|
*/
|
|
211
239
|
export declare const useGlobalProps: () => GlobalProps;
|
|
212
240
|
/**
|
|
@@ -221,7 +249,10 @@ export declare const useGlobalProps: () => GlobalProps;
|
|
|
221
249
|
* })
|
|
222
250
|
* }
|
|
223
251
|
* ```
|
|
252
|
+
* @function
|
|
224
253
|
* @public
|
|
254
|
+
*
|
|
255
|
+
* @group Hooks
|
|
225
256
|
*/
|
|
226
257
|
export declare const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void;
|
|
227
258
|
/**
|
|
@@ -230,6 +261,8 @@ export declare const useGlobalPropsChanged: (callback: (data: GlobalProps) => vo
|
|
|
230
261
|
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
231
262
|
*
|
|
232
263
|
* @public
|
|
264
|
+
*
|
|
265
|
+
* @group Types
|
|
233
266
|
*/
|
|
234
267
|
export interface InitDataRaw {
|
|
235
268
|
}
|
|
@@ -239,6 +272,8 @@ export interface InitDataRaw {
|
|
|
239
272
|
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
240
273
|
*
|
|
241
274
|
* @public
|
|
275
|
+
*
|
|
276
|
+
* @group Types
|
|
242
277
|
*/
|
|
243
278
|
export interface InitData {
|
|
244
279
|
}
|
|
@@ -273,6 +308,8 @@ export { withInitDataInState };
|
|
|
273
308
|
* ```
|
|
274
309
|
*
|
|
275
310
|
* @public
|
|
311
|
+
*
|
|
312
|
+
* @group Types
|
|
276
313
|
*/
|
|
277
314
|
export interface DataProcessors {
|
|
278
315
|
/**
|
|
@@ -323,6 +360,8 @@ export interface DataProcessors {
|
|
|
323
360
|
/**
|
|
324
361
|
* Definition of DataProcessor(s)
|
|
325
362
|
* @public
|
|
363
|
+
*
|
|
364
|
+
* @group Types
|
|
326
365
|
*/
|
|
327
366
|
export interface DataProcessorDefinition {
|
|
328
367
|
/**
|
|
@@ -354,6 +393,8 @@ export interface DataProcessorDefinition {
|
|
|
354
393
|
* ```
|
|
355
394
|
*
|
|
356
395
|
* @public
|
|
396
|
+
*
|
|
397
|
+
* @group Types
|
|
357
398
|
*/
|
|
358
399
|
export interface Lynx {
|
|
359
400
|
/**
|
|
@@ -439,7 +480,7 @@ export interface Lynx {
|
|
|
439
480
|
* they can achieve it by extends interface `InitDataRaw` and `InitData`.
|
|
440
481
|
*
|
|
441
482
|
* ```ts
|
|
442
|
-
* import {
|
|
483
|
+
* import { useInitData } from "@lynx-js/react"
|
|
443
484
|
*
|
|
444
485
|
* interface AnotherExistingInterface {
|
|
445
486
|
* someAnotherPropertyFromExistingInterface: number
|
|
@@ -451,7 +492,7 @@ export interface Lynx {
|
|
|
451
492
|
* }
|
|
452
493
|
* }
|
|
453
494
|
*
|
|
454
|
-
*
|
|
495
|
+
* lynx.registerDataProcessors({
|
|
455
496
|
* defaultDataProcessor: () => {
|
|
456
497
|
* return {
|
|
457
498
|
* someCustomProperty: 'value', // will be typed
|
|
@@ -476,3 +517,5 @@ export { useLynxGlobalEventListener } from './core/hooks/useLynxGlobalEventListe
|
|
|
476
517
|
export { runOnBackground } from './core/background-function/run-on-background.js';
|
|
477
518
|
export { runOnMainThread } from './snapshot/worklet/call/runOnMainThread.js';
|
|
478
519
|
export { MainThreadRef, useMainThreadRef } from './core/main-thread-ref.js';
|
|
520
|
+
export { defineMainThreadObjectType, useMainThreadObject } from './core/main-thread-object.js';
|
|
521
|
+
export type { MainThreadObjectHandle, MainThreadObjectType, MainThreadObjectTypeDefinition, } from './core/main-thread-object.js';
|