@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,10 +1,11 @@
|
|
|
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 { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
getFromWorkletRefMap,
|
|
8
|
+
isHydratedWorkletValue,
|
|
8
9
|
removeValueFromWorkletRefMap,
|
|
9
10
|
updateWorkletRefInitValueChanges,
|
|
10
11
|
} from '../../src/worklet-runtime/workletRef';
|
|
@@ -25,6 +26,361 @@ afterEach(() => {
|
|
|
25
26
|
delete globalThis.lynxWorkletImpl;
|
|
26
27
|
});
|
|
27
28
|
|
|
29
|
+
describe('MainThreadObject integration with the worklet ref map', () => {
|
|
30
|
+
it('continues applying a patch after a MainThreadObject factory error', () => {
|
|
31
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
32
|
+
'@test/throws',
|
|
33
|
+
() => {
|
|
34
|
+
throw new Error('factory failed');
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(() => {
|
|
39
|
+
updateWorkletRefInitValueChanges([
|
|
40
|
+
[10, 42, '@test/throws'],
|
|
41
|
+
[11, 'unrelated MainThreadRef'],
|
|
42
|
+
]);
|
|
43
|
+
}).toThrow('factory failed');
|
|
44
|
+
expect(getFromWorkletRefMap({ _wvid: 11 }).current).toBe(
|
|
45
|
+
'unrelated MainThreadRef',
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('hydrates a used first-screen main-thread object into the background id', () => {
|
|
50
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
51
|
+
'@test/value',
|
|
52
|
+
value => ({ get: () => value }),
|
|
53
|
+
);
|
|
54
|
+
const firstScreenWorklet = {
|
|
55
|
+
_wkltId: 'typed-value',
|
|
56
|
+
_c: {
|
|
57
|
+
value: {
|
|
58
|
+
_wvid: -1,
|
|
59
|
+
_initValue: 42,
|
|
60
|
+
_type: '@test/value',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
const worklet = {
|
|
65
|
+
_wkltId: 'typed-value',
|
|
66
|
+
_c: {
|
|
67
|
+
value: {
|
|
68
|
+
_wvid: 1,
|
|
69
|
+
_initValue: 42,
|
|
70
|
+
_type: '@test/value',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
globalThis.registerWorklet('main-thread', 'typed-value', function() {
|
|
75
|
+
return this._c.value.get();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(globalThis.runWorklet(firstScreenWorklet, [])).toBe(42);
|
|
79
|
+
const firstScreenValue = firstScreenWorklet._c.value;
|
|
80
|
+
updateWorkletRefInitValueChanges([[1, 42, '@test/value']]);
|
|
81
|
+
const redundantValue = getFromWorkletRefMap({ _wvid: 1 });
|
|
82
|
+
expect(isHydratedWorkletValue(redundantValue)).toBe(true);
|
|
83
|
+
globalThis.lynxWorkletImpl._hydrateCtx(worklet, firstScreenWorklet);
|
|
84
|
+
|
|
85
|
+
expect(getFromWorkletRefMap({ _wvid: 1 })).toBe(firstScreenValue);
|
|
86
|
+
// Removing a runtime-owned reference must not revoke a retained target's brand.
|
|
87
|
+
expect(isHydratedWorkletValue(redundantValue)).toBe(true);
|
|
88
|
+
expect(isHydratedWorkletValue(firstScreenValue)).toBe(true);
|
|
89
|
+
|
|
90
|
+
removeValueFromWorkletRefMap(1);
|
|
91
|
+
expect(getFromWorkletRefMap({ _wvid: 1 })).toBeUndefined();
|
|
92
|
+
expect(isHydratedWorkletValue(firstScreenValue)).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('does not hydrate an unused first-screen main-thread object', () => {
|
|
96
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
97
|
+
'@test/unused-value',
|
|
98
|
+
value => ({ value }),
|
|
99
|
+
);
|
|
100
|
+
const firstScreenWorklet = {
|
|
101
|
+
_wkltId: 'unused-typed-value',
|
|
102
|
+
_c: {
|
|
103
|
+
value: {
|
|
104
|
+
_wvid: -1,
|
|
105
|
+
_initValue: 42,
|
|
106
|
+
_type: '@test/unused-value',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
const worklet = {
|
|
111
|
+
_wkltId: 'unused-typed-value',
|
|
112
|
+
_c: {
|
|
113
|
+
value: {
|
|
114
|
+
_wvid: 1,
|
|
115
|
+
_initValue: 42,
|
|
116
|
+
_type: '@test/unused-value',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
globalThis.lynxWorkletImpl._hydrateCtx(worklet, firstScreenWorklet);
|
|
122
|
+
|
|
123
|
+
expect(getFromWorkletRefMap({ _wvid: 1 })).toBeUndefined();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('hydrates a compatible mutable worklet value through the typed path', () => {
|
|
127
|
+
const firstScreenWorklet = {
|
|
128
|
+
_wkltId: 'typed-mutable-value',
|
|
129
|
+
_c: {
|
|
130
|
+
value: {
|
|
131
|
+
_wvid: -1,
|
|
132
|
+
_initValue: { nested: { _wvid: -2, _initValue: 42, _type: 'main-thread' } },
|
|
133
|
+
_type: 'main-thread',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
const worklet = {
|
|
138
|
+
_wkltId: 'typed-mutable-value',
|
|
139
|
+
_c: {
|
|
140
|
+
value: {
|
|
141
|
+
_wvid: 1,
|
|
142
|
+
_initValue: 42,
|
|
143
|
+
_type: 'main-thread',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
globalThis.registerWorklet('main-thread', 'typed-mutable-value', function() {
|
|
148
|
+
return this._c.value.current;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
globalThis.runWorklet(firstScreenWorklet, []);
|
|
152
|
+
const firstScreenValue = firstScreenWorklet._c.value;
|
|
153
|
+
expect(firstScreenValue.current.nested.current).toBe(42);
|
|
154
|
+
globalThis.lynxWorkletImpl._hydrateCtx(worklet, firstScreenWorklet);
|
|
155
|
+
|
|
156
|
+
expect(getFromWorkletRefMap({ _wvid: 1 })).toBe(firstScreenValue);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('releases first-screen map references without revoking retained target metadata', () => {
|
|
160
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
161
|
+
'@test/abandoned',
|
|
162
|
+
value => ({ value }),
|
|
163
|
+
);
|
|
164
|
+
const firstScreenWorklet = {
|
|
165
|
+
_wkltId: 'abandoned-typed-value',
|
|
166
|
+
_c: {
|
|
167
|
+
value: {
|
|
168
|
+
_wvid: -1,
|
|
169
|
+
_initValue: 42,
|
|
170
|
+
_type: '@test/abandoned',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
globalThis.registerWorklet('main-thread', 'abandoned-typed-value', function() {
|
|
175
|
+
return this._c.value;
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const value = globalThis.runWorklet(firstScreenWorklet, []);
|
|
179
|
+
expect(isHydratedWorkletValue(value)).toBe(true);
|
|
180
|
+
|
|
181
|
+
globalThis.lynxWorkletImpl._refImpl.clearFirstScreenWorkletRefMap();
|
|
182
|
+
expect(globalThis.lynxWorkletImpl._refImpl._firstScreenWorkletRefMap).toEqual({});
|
|
183
|
+
expect(isHydratedWorkletValue(value)).toBe(true);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('keeps released typed objects distinct from mutable cells while they remain reachable', () => {
|
|
187
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
188
|
+
'@test/mutable-cell-shaped-object',
|
|
189
|
+
() => ({ _wvid: 91, current: 0 }),
|
|
190
|
+
);
|
|
191
|
+
updateWorkletRefInitValueChanges([
|
|
192
|
+
[91, null, '@test/mutable-cell-shaped-object'],
|
|
193
|
+
]);
|
|
194
|
+
const value = getFromWorkletRefMap({ _wvid: 91 });
|
|
195
|
+
expect(isHydratedWorkletValue(value)).toBe(true);
|
|
196
|
+
|
|
197
|
+
removeValueFromWorkletRefMap(91);
|
|
198
|
+
|
|
199
|
+
expect(getFromWorkletRefMap({ _wvid: 91 })).toBeUndefined();
|
|
200
|
+
// A retained target cannot be reclassified from its user-owned properties.
|
|
201
|
+
globalThis.lynxWorkletImpl._refImpl._workletRefMap[92] = value;
|
|
202
|
+
expect(() => updateWorkletRefInitValueChanges([[92, null, 'main-thread']])).toThrow(
|
|
203
|
+
'Worklet value kind mismatch',
|
|
204
|
+
);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('does not hydrate worklet metadata found inside object payloads', () => {
|
|
208
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
209
|
+
'@test/atomic-hydration-payload',
|
|
210
|
+
value => ({ value }),
|
|
211
|
+
);
|
|
212
|
+
const unrelatedRef = { _wvid: 3, current: 'unrelated' };
|
|
213
|
+
globalThis.lynxWorkletImpl._refImpl._workletRefMap[3] = unrelatedRef;
|
|
214
|
+
const payload = { _wvid: 3, current: 'payload' };
|
|
215
|
+
const worklet = {
|
|
216
|
+
_wkltId: 'atomic-hydration-payload',
|
|
217
|
+
_c: {
|
|
218
|
+
value: {
|
|
219
|
+
_wvid: 92,
|
|
220
|
+
_initValue: payload,
|
|
221
|
+
_type: '@test/atomic-hydration-payload',
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
const firstScreenWorklet = {
|
|
226
|
+
_wkltId: 'atomic-hydration-payload',
|
|
227
|
+
_c: {
|
|
228
|
+
value: {
|
|
229
|
+
_wvid: -92,
|
|
230
|
+
_initValue: payload,
|
|
231
|
+
_type: '@test/atomic-hydration-payload',
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
globalThis.lynxWorkletImpl._hydrateCtx(worklet, firstScreenWorklet);
|
|
237
|
+
|
|
238
|
+
expect(globalThis.lynxWorkletImpl._refImpl._workletRefMap[3]).toBe(
|
|
239
|
+
unrelatedRef,
|
|
240
|
+
);
|
|
241
|
+
expect(getFromWorkletRefMap({ _wvid: 92 })).toBeUndefined();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('rejects different typed-object keys at the same hydration path', () => {
|
|
245
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
246
|
+
'@test/main-type',
|
|
247
|
+
value => ({ value }),
|
|
248
|
+
);
|
|
249
|
+
const firstScreenWorklet = {
|
|
250
|
+
_wkltId: 'macro-typed-value',
|
|
251
|
+
_c: {
|
|
252
|
+
value: {
|
|
253
|
+
_wvid: -1,
|
|
254
|
+
_initValue: 1,
|
|
255
|
+
_type: '@test/main-type',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
const worklet = {
|
|
260
|
+
_wkltId: 'macro-typed-value',
|
|
261
|
+
_c: {
|
|
262
|
+
value: {
|
|
263
|
+
_wvid: 1,
|
|
264
|
+
_initValue: 2,
|
|
265
|
+
_type: '@test/background-type',
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
globalThis.registerWorklet('main-thread', 'macro-typed-value', function() {
|
|
270
|
+
return this._c.value.value;
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
expect(globalThis.runWorklet(firstScreenWorklet, [])).toBe(1);
|
|
274
|
+
expect(() => {
|
|
275
|
+
globalThis.lynxWorkletImpl._hydrateCtx(worklet, firstScreenWorklet);
|
|
276
|
+
}).toThrow(
|
|
277
|
+
'MainThreadObject type mismatch during hydration for handle 1: background handle expects type "@test/background-type", but the main-thread target is type "@test/main-type".',
|
|
278
|
+
);
|
|
279
|
+
expect(getFromWorkletRefMap({ _wvid: 1 })).toBeUndefined();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('rejects typed-object and mutable-cell kind mismatches during hydration', () => {
|
|
283
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
284
|
+
'@test/value',
|
|
285
|
+
value => ({ value }),
|
|
286
|
+
);
|
|
287
|
+
const firstScreenWorklet = {
|
|
288
|
+
_wkltId: 'kind-mismatch',
|
|
289
|
+
_c: {
|
|
290
|
+
value: {
|
|
291
|
+
_wvid: -1,
|
|
292
|
+
_initValue: 1,
|
|
293
|
+
_type: '@test/value',
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
const worklet = {
|
|
298
|
+
_wkltId: 'kind-mismatch',
|
|
299
|
+
_c: {
|
|
300
|
+
value: {
|
|
301
|
+
_wvid: 1,
|
|
302
|
+
_initValue: 1,
|
|
303
|
+
_type: 'main-thread',
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
globalThis.registerWorklet('main-thread', 'kind-mismatch', function() {
|
|
308
|
+
return this._c.value.value;
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
globalThis.runWorklet(firstScreenWorklet, []);
|
|
312
|
+
expect(() => {
|
|
313
|
+
globalThis.lynxWorkletImpl._hydrateCtx(worklet, firstScreenWorklet);
|
|
314
|
+
}).toThrow(
|
|
315
|
+
'Worklet value kind mismatch during hydration for handle 1: background handle expects mutable-cell, but the main-thread target is typed-object.',
|
|
316
|
+
);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('validates an existing hydrated target when applying initialization patches', () => {
|
|
320
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
321
|
+
'@test/value',
|
|
322
|
+
value => ({ value }),
|
|
323
|
+
);
|
|
324
|
+
const firstScreenWorklet = {
|
|
325
|
+
_wkltId: 'patch-validation',
|
|
326
|
+
_c: {
|
|
327
|
+
value: {
|
|
328
|
+
_wvid: -1,
|
|
329
|
+
_initValue: 1,
|
|
330
|
+
_type: '@test/value',
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
const worklet = {
|
|
335
|
+
_wkltId: 'patch-validation',
|
|
336
|
+
_c: {
|
|
337
|
+
value: {
|
|
338
|
+
_wvid: 1,
|
|
339
|
+
_initValue: 1,
|
|
340
|
+
_type: '@test/value',
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
globalThis.registerWorklet('main-thread', 'patch-validation', function() {
|
|
345
|
+
return this._c.value.value;
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
globalThis.runWorklet(firstScreenWorklet, []);
|
|
349
|
+
globalThis.lynxWorkletImpl._hydrateCtx(worklet, firstScreenWorklet);
|
|
350
|
+
expect(() => {
|
|
351
|
+
updateWorkletRefInitValueChanges([[1, 1, '@test/other-value']]);
|
|
352
|
+
}).toThrow(
|
|
353
|
+
'MainThreadObject type mismatch during initialization patch for handle 1: background handle expects type "@test/other-value", but the main-thread target is type "@test/value".',
|
|
354
|
+
);
|
|
355
|
+
const hydratedValue = getFromWorkletRefMap({ _wvid: 1 });
|
|
356
|
+
expect(hydratedValue).toBe(firstScreenWorklet._c.value);
|
|
357
|
+
updateWorkletRefInitValueChanges([[1, 1, '@test/value']]);
|
|
358
|
+
expect(getFromWorkletRefMap({ _wvid: 1 })).toBe(hydratedValue);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it('rejects an existing target without worklet-value metadata', () => {
|
|
362
|
+
globalThis.lynxWorkletImpl._refImpl._workletRefMap[1] = {};
|
|
363
|
+
|
|
364
|
+
expect(() => {
|
|
365
|
+
updateWorkletRefInitValueChanges([[1, 'value']]);
|
|
366
|
+
}).toThrow(
|
|
367
|
+
'Cannot apply MainThreadObject initialization patch for handle 1: the existing target has no worklet-value metadata.',
|
|
368
|
+
);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('does not mistake a source MainThreadRef accessor for a mutable cell', () => {
|
|
372
|
+
const sourceHandle = Object.create({
|
|
373
|
+
get current() {
|
|
374
|
+
throw new Error('source accessor must not be read');
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
sourceHandle._wvid = -1;
|
|
378
|
+
|
|
379
|
+
expect(isHydratedWorkletValue(sourceHandle)).toBe(false);
|
|
380
|
+
expect(isHydratedWorkletValue({ _wvid: -1, current: null })).toBe(true);
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
28
384
|
describe('WorkletRef', () => {
|
|
29
385
|
it('should create, get, update & remove', () => {
|
|
30
386
|
updateWorkletRefInitValueChanges([[1, 'ref1'], [2, 'ref2']]);
|
|
@@ -45,8 +401,12 @@ describe('WorkletRef', () => {
|
|
|
45
401
|
_wvid: 2,
|
|
46
402
|
}, null);
|
|
47
403
|
expect(getFromWorkletRefMap({ _wvid: 2 }).current).toBe(null);
|
|
48
|
-
});
|
|
49
404
|
|
|
405
|
+
globalThis.lynxWorkletImpl._refImpl._workletRefMap[99] = null;
|
|
406
|
+
expect(() => removeValueFromWorkletRefMap(99)).not.toThrow();
|
|
407
|
+
globalThis.lynxWorkletImpl._refImpl._workletRefMap[98] = {};
|
|
408
|
+
expect(() => removeValueFromWorkletRefMap(98)).not.toThrow();
|
|
409
|
+
});
|
|
50
410
|
it('should create, get and update at first screen', () => {
|
|
51
411
|
getFromWorkletRefMap({ _wvid: -1 }).current = 'ref1';
|
|
52
412
|
getFromWorkletRefMap({ _wvid: -2 }).current = 'ref2';
|
|
@@ -6,7 +6,12 @@ import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
6
6
|
import { Element } from '../../src/worklet-runtime/api/element';
|
|
7
7
|
import { initApiEnv } from '../../src/worklet-runtime/api/lynxApi';
|
|
8
8
|
import { RunWorkletSource } from '../../src/worklet-runtime/bindings/types';
|
|
9
|
-
import {
|
|
9
|
+
import { hydrateCtx } from '../../src/worklet-runtime/hydrate';
|
|
10
|
+
import {
|
|
11
|
+
getFromWorkletRefMap,
|
|
12
|
+
removeValueFromWorkletRefMap,
|
|
13
|
+
updateWorkletRefInitValueChanges,
|
|
14
|
+
} from '../../src/worklet-runtime/workletRef';
|
|
10
15
|
import { initWorklet } from '../../src/worklet-runtime/workletRuntime';
|
|
11
16
|
|
|
12
17
|
describe('Worklet', () => {
|
|
@@ -27,6 +32,35 @@ describe('Worklet', () => {
|
|
|
27
32
|
consoleMock.mockReset();
|
|
28
33
|
});
|
|
29
34
|
|
|
35
|
+
it.each(['cycle', 'metadata', 'proxy'])('preserves realized %s targets in shared captures', (kind) => {
|
|
36
|
+
initWorklet();
|
|
37
|
+
const value = kind === 'proxy'
|
|
38
|
+
? new Proxy({}, {
|
|
39
|
+
get() {
|
|
40
|
+
throw new Error('target must remain opaque');
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
: kind === 'metadata'
|
|
44
|
+
? { nested: { _wvid: 999 }, _wkltId: 'user-data' }
|
|
45
|
+
: {};
|
|
46
|
+
if (kind === 'cycle') value.self = value;
|
|
47
|
+
lynxWorkletImpl._refImpl.registerMainThreadObjectType('@test/shared', () => value);
|
|
48
|
+
updateWorkletRefInitValueChanges([[1, null, '@test/shared'], [2, null, '@test/shared']]);
|
|
49
|
+
registerWorklet('main-thread', 'shared', function() {
|
|
50
|
+
return this._c.holder.value;
|
|
51
|
+
});
|
|
52
|
+
const holder = { value: { _wvid: 2, _type: '@test/shared', _initValue: null } };
|
|
53
|
+
expect(runWorklet({ _wkltId: 'shared', _c: { holder } }, [])).toBe(value);
|
|
54
|
+
removeValueFromWorkletRefMap(1);
|
|
55
|
+
expect(lynxWorkletImpl._refImpl._workletRefMap[1]).toBeUndefined();
|
|
56
|
+
expect(getFromWorkletRefMap({ _wvid: 2 })).toBe(value);
|
|
57
|
+
expect(() => updateWorkletRefInitValueChanges([[2, null, '@test/shared']])).not.toThrow();
|
|
58
|
+
expect(getFromWorkletRefMap({ _wvid: -1, _type: '@test/shared', _initValue: null })).toBe(value);
|
|
59
|
+
lynxWorkletImpl._refImpl.clearFirstScreenWorkletRefMap();
|
|
60
|
+
expect(runWorklet({ _wkltId: 'shared', _c: { holder } }, [])).toBe(value);
|
|
61
|
+
if (kind === 'metadata') expect(value.nested).toEqual({ _wvid: 999 });
|
|
62
|
+
});
|
|
63
|
+
|
|
30
64
|
it('worklet should be called', () => {
|
|
31
65
|
initWorklet();
|
|
32
66
|
|
|
@@ -39,6 +73,148 @@ describe('Worklet', () => {
|
|
|
39
73
|
expect(fn).toBeCalled();
|
|
40
74
|
});
|
|
41
75
|
|
|
76
|
+
it.each([
|
|
77
|
+
{ withSetter: false, configurable: false },
|
|
78
|
+
{ withSetter: false, configurable: true },
|
|
79
|
+
{ withSetter: true, configurable: false },
|
|
80
|
+
{ withSetter: true, configurable: true },
|
|
81
|
+
])(
|
|
82
|
+
'captures a typed target getter (setter: $withSetter, configurable: $configurable)',
|
|
83
|
+
({ withSetter, configurable }) => {
|
|
84
|
+
initWorklet();
|
|
85
|
+
lynxWorkletImpl._refImpl.registerMainThreadObjectType('@test/getter', value => ({ value }));
|
|
86
|
+
updateWorkletRefInitValueChanges([[1, 'first', '@test/getter'], [2, 'second', '@test/getter']]);
|
|
87
|
+
const getter = vi.fn(function() {
|
|
88
|
+
return { _wvid: this.id, _type: '@test/getter', _initValue: null };
|
|
89
|
+
});
|
|
90
|
+
const setter = vi.fn();
|
|
91
|
+
const source = { id: 1 };
|
|
92
|
+
const descriptor = {
|
|
93
|
+
get: getter,
|
|
94
|
+
...(withSetter ? { set: setter } : {}),
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable,
|
|
97
|
+
};
|
|
98
|
+
Object.defineProperty(source, 'target', descriptor);
|
|
99
|
+
Object.defineProperty(source, 'aliasTarget', descriptor);
|
|
100
|
+
registerWorklet('main-thread', 'getter-parent', function() {
|
|
101
|
+
return [this._c.holder.source.target, this._c.holder.source.aliasTarget];
|
|
102
|
+
});
|
|
103
|
+
const holder = {
|
|
104
|
+
get source() {
|
|
105
|
+
return source;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
const capture = () => runWorklet({ _wkltId: 'getter-parent', _c: { holder } }, []);
|
|
109
|
+
const first = capture();
|
|
110
|
+
source.id = 2;
|
|
111
|
+
const second = capture();
|
|
112
|
+
expect(first[0]).toBe(getFromWorkletRefMap({ _wvid: 1 }));
|
|
113
|
+
expect(first[1]).toBe(first[0]);
|
|
114
|
+
expect(second[0]).toBe(getFromWorkletRefMap({ _wvid: 2 }));
|
|
115
|
+
expect(second[1]).toBe(second[0]);
|
|
116
|
+
expect(getter).toHaveBeenCalledTimes(4);
|
|
117
|
+
expect(setter).not.toHaveBeenCalled();
|
|
118
|
+
expect(holder.source).toBe(source);
|
|
119
|
+
expect(Object.getOwnPropertyDescriptor(source, 'target').get).toBe(getter);
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
it.each(['direct', 'nested', 'array'])('snapshots a %s method getter without consuming the source', (kind) => {
|
|
124
|
+
initWorklet();
|
|
125
|
+
const getter = vi.fn(function() {
|
|
126
|
+
return { _wkltId: 'method', value: this.value };
|
|
127
|
+
});
|
|
128
|
+
const source = { value: 1 };
|
|
129
|
+
Object.defineProperty(source, 'method', { get: getter, enumerable: true, configurable: true });
|
|
130
|
+
const holder = kind === 'direct' ? source : kind === 'array' ? [source] : { source };
|
|
131
|
+
registerWorklet('main-thread', 'method', function() {
|
|
132
|
+
return this.value;
|
|
133
|
+
});
|
|
134
|
+
registerWorklet('main-thread', 'parent', function() {
|
|
135
|
+
return this._c.holder;
|
|
136
|
+
});
|
|
137
|
+
const capture = () => runWorklet({ _wkltId: 'parent', _c: { holder } }, []);
|
|
138
|
+
const method = captured =>
|
|
139
|
+
kind === 'direct' ? captured.method : kind === 'array' ? captured[0].method : captured.source.method;
|
|
140
|
+
const first = capture();
|
|
141
|
+
expect(getter).toHaveBeenCalledTimes(1);
|
|
142
|
+
expect(method(first)()).toBe(1);
|
|
143
|
+
source.value = 2;
|
|
144
|
+
const second = capture();
|
|
145
|
+
expect(getter).toHaveBeenCalledTimes(2);
|
|
146
|
+
expect(method(second)()).toBe(2);
|
|
147
|
+
expect(method(first)()).toBe(1);
|
|
148
|
+
expect(Object.getOwnPropertyDescriptor(source, 'method').get).toBe(getter);
|
|
149
|
+
if (kind === 'nested') expect(holder.source).toBe(source);
|
|
150
|
+
if (kind === 'array') expect(Array.isArray(first)).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it.each(['root', 'captured'])('copies sibling nested worklet captures on the %s context', (placement) => {
|
|
154
|
+
initWorklet();
|
|
155
|
+
const getter = vi.fn(function() {
|
|
156
|
+
return { _wkltId: 'method', value: this.value };
|
|
157
|
+
});
|
|
158
|
+
const source = { value: 1 };
|
|
159
|
+
Object.defineProperty(source, 'method', { get: getter, enumerable: true, configurable: true });
|
|
160
|
+
const nested = { _wkltId: 'nested', _c: { source } };
|
|
161
|
+
const siblings = { first: nested, second: nested };
|
|
162
|
+
registerWorklet('main-thread', 'method', function() {
|
|
163
|
+
return this.value;
|
|
164
|
+
});
|
|
165
|
+
registerWorklet('main-thread', 'nested', function() {
|
|
166
|
+
return this._c.source.method();
|
|
167
|
+
});
|
|
168
|
+
registerWorklet('main-thread', 'parent', function() {
|
|
169
|
+
return this._c ? this._c.siblings : this;
|
|
170
|
+
});
|
|
171
|
+
const capture = () =>
|
|
172
|
+
runWorklet(
|
|
173
|
+
placement === 'root'
|
|
174
|
+
? { _wkltId: 'parent', ...siblings }
|
|
175
|
+
: { _wkltId: 'parent', _c: { siblings } },
|
|
176
|
+
[],
|
|
177
|
+
);
|
|
178
|
+
const first = capture();
|
|
179
|
+
expect(first.first()).toBe(1);
|
|
180
|
+
expect(first.second()).toBe(1);
|
|
181
|
+
expect(getter).toHaveBeenCalledTimes(2);
|
|
182
|
+
expect(siblings.first).toBe(nested);
|
|
183
|
+
expect(siblings.second).toBe(nested);
|
|
184
|
+
expect(nested._c.source).toBe(source);
|
|
185
|
+
source.value = 2;
|
|
186
|
+
const second = capture();
|
|
187
|
+
expect(second.first()).toBe(2);
|
|
188
|
+
expect(second.second()).toBe(2);
|
|
189
|
+
expect(first.first()).toBe(1);
|
|
190
|
+
expect(first.second()).toBe(1);
|
|
191
|
+
expect(getter).toHaveBeenCalledTimes(4);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('hydrates the executed method getter context without reading the source again', () => {
|
|
195
|
+
initWorklet();
|
|
196
|
+
const getter = vi.fn(() => ({ _wkltId: 'method', _jsFn: { callback: { _isFirstScreen: true } } }));
|
|
197
|
+
const source = {};
|
|
198
|
+
Object.defineProperty(source, 'method', { get: getter, enumerable: true, configurable: true });
|
|
199
|
+
registerWorklet('main-thread', 'method', function() {
|
|
200
|
+
return this._jsFn.callback;
|
|
201
|
+
});
|
|
202
|
+
registerWorklet('main-thread', 'parent', function() {
|
|
203
|
+
return this._c.source.method;
|
|
204
|
+
});
|
|
205
|
+
const firstScreen = { _wkltId: 'parent', _c: { source } };
|
|
206
|
+
const method = runWorklet(firstScreen, []);
|
|
207
|
+
const executedHandle = method();
|
|
208
|
+
expect(method.boundCtx._jsFn.callback).toBe(executedHandle);
|
|
209
|
+
hydrateCtx({
|
|
210
|
+
_wkltId: 'parent',
|
|
211
|
+
_execId: 8,
|
|
212
|
+
_c: { source: { method: { _wkltId: 'method', _jsFn: { callback: { _jsFnId: 3 } } } } },
|
|
213
|
+
}, firstScreen);
|
|
214
|
+
expect(executedHandle).toMatchObject({ _isFirstScreen: false, _jsFnId: 3, _execId: 8 });
|
|
215
|
+
expect(getter).toHaveBeenCalledTimes(1);
|
|
216
|
+
});
|
|
217
|
+
|
|
42
218
|
it('latest registration should win when the same worklet id is reused', () => {
|
|
43
219
|
initWorklet();
|
|
44
220
|
|
|
@@ -171,7 +347,7 @@ describe('Worklet', () => {
|
|
|
171
347
|
}
|
|
172
348
|
});
|
|
173
349
|
|
|
174
|
-
it('
|
|
350
|
+
it('supports nested worklet contexts that cannot be weakly referenced', () => {
|
|
175
351
|
initWorklet();
|
|
176
352
|
|
|
177
353
|
const NativeWeakRef = globalThis.WeakRef;
|
|
@@ -201,7 +377,8 @@ describe('Worklet', () => {
|
|
|
201
377
|
const childWorklet = globalThis.runWorklet(parentCtx, []);
|
|
202
378
|
|
|
203
379
|
expect(childWorklet()).toBe(2);
|
|
204
|
-
expect(childWorklet).not.
|
|
380
|
+
expect(childWorklet.boundCtx).not.toBe(childCtx);
|
|
381
|
+
expect(childWorklet.boundCtx.token).toBe(2);
|
|
205
382
|
} finally {
|
|
206
383
|
globalThis.WeakRef = NativeWeakRef;
|
|
207
384
|
}
|
|
@@ -262,6 +439,75 @@ describe('Worklet', () => {
|
|
|
262
439
|
expect(value).toBe(5);
|
|
263
440
|
});
|
|
264
441
|
|
|
442
|
+
it('treats MainThreadObject descriptors as atomic user payloads', () => {
|
|
443
|
+
initWorklet();
|
|
444
|
+
|
|
445
|
+
const initialValue = {
|
|
446
|
+
workletRefLike: { _wvid: 999 },
|
|
447
|
+
workletLike: { _wkltId: 'payload-worklet' },
|
|
448
|
+
jsFunctionLike: { _jsFnId: 999 },
|
|
449
|
+
elementLike: { elementRefptr: 'payload-element' },
|
|
450
|
+
};
|
|
451
|
+
let deepValue = initialValue;
|
|
452
|
+
for (let index = 0; index < 1000; index++) {
|
|
453
|
+
deepValue.next = {};
|
|
454
|
+
deepValue = deepValue.next;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const create = vi.fn(value => ({ initialValue: value }));
|
|
458
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
459
|
+
'@test/atomic-payload',
|
|
460
|
+
create,
|
|
461
|
+
);
|
|
462
|
+
globalThis.registerWorklet('main-thread', 'atomic-payload', function(value) {
|
|
463
|
+
return value;
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
const value = globalThis.runWorklet({ _wkltId: 'atomic-payload' }, [{
|
|
467
|
+
_wvid: -1,
|
|
468
|
+
_initValue: initialValue,
|
|
469
|
+
_type: '@test/atomic-payload',
|
|
470
|
+
}]);
|
|
471
|
+
|
|
472
|
+
expect(create).toHaveBeenCalledOnce();
|
|
473
|
+
expect(create).toHaveBeenCalledWith(initialValue);
|
|
474
|
+
expect(value.initialValue).toBe(initialValue);
|
|
475
|
+
expect(initialValue.workletRefLike).toEqual({ _wvid: 999 });
|
|
476
|
+
expect(initialValue.workletLike).toEqual({ _wkltId: 'payload-worklet' });
|
|
477
|
+
expect(initialValue.jsFunctionLike).toEqual({ _jsFnId: 999 });
|
|
478
|
+
expect(initialValue.elementLike).toEqual({ elementRefptr: 'payload-element' });
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it('reuses one realized MainThreadObject for repeated parameter descriptors', () => {
|
|
482
|
+
initWorklet();
|
|
483
|
+
|
|
484
|
+
const create = vi.fn(value => ({ value }));
|
|
485
|
+
globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(
|
|
486
|
+
'@test/repeated-parameter',
|
|
487
|
+
create,
|
|
488
|
+
);
|
|
489
|
+
globalThis.registerWorklet('main-thread', 'repeated-parameter', function(value) {
|
|
490
|
+
return value;
|
|
491
|
+
});
|
|
492
|
+
const descriptor = {
|
|
493
|
+
_wvid: -2,
|
|
494
|
+
_initValue: 42,
|
|
495
|
+
_type: '@test/repeated-parameter',
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const first = globalThis.runWorklet(
|
|
499
|
+
{ _wkltId: 'repeated-parameter' },
|
|
500
|
+
[descriptor],
|
|
501
|
+
);
|
|
502
|
+
const second = globalThis.runWorklet(
|
|
503
|
+
{ _wkltId: 'repeated-parameter' },
|
|
504
|
+
[descriptor],
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
expect(second).toBe(first);
|
|
508
|
+
expect(create).toHaveBeenCalledOnce();
|
|
509
|
+
});
|
|
510
|
+
|
|
265
511
|
it('should support various types of parameters', async () => {
|
|
266
512
|
initWorklet();
|
|
267
513
|
|
package/runtime/lazy/compat.js
CHANGED
|
@@ -20,6 +20,7 @@ export const {
|
|
|
20
20
|
createElement,
|
|
21
21
|
createPortal,
|
|
22
22
|
createRef,
|
|
23
|
+
defineMainThreadObjectType,
|
|
23
24
|
forwardRef,
|
|
24
25
|
isValidElement,
|
|
25
26
|
lazy,
|
|
@@ -42,6 +43,7 @@ export const {
|
|
|
42
43
|
useLynxGlobalEventListener,
|
|
43
44
|
useLayoutEffect,
|
|
44
45
|
useMainThreadRef,
|
|
46
|
+
useMainThreadObject,
|
|
45
47
|
useMemo,
|
|
46
48
|
useReducer,
|
|
47
49
|
useRef,
|