@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,168 @@
|
|
|
1
|
+
/** @jsxImportSource ../../lepus */
|
|
2
|
+
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import { globalEnvManager } from './utils/envManager';
|
|
6
|
+
import { elementTree, options } from './utils/nativeMethod';
|
|
7
|
+
import { __root } from '../../src/root';
|
|
8
|
+
import { clearPage } from '../../src/snapshot';
|
|
9
|
+
import { gRecycleMap, gSignMap } from '../../src/snapshot/list/list';
|
|
10
|
+
import { DynamicPartType } from '../../src/snapshot/snapshot/dynamicPartType';
|
|
11
|
+
|
|
12
|
+
const ssrIDMap = new Map();
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
globalEnvManager.resetEnv();
|
|
16
|
+
elementTree.clear();
|
|
17
|
+
let ssrID = 0;
|
|
18
|
+
options.onCreateElement = element => {
|
|
19
|
+
element.ssrID = `${ssrID++}`;
|
|
20
|
+
element.toJSON = function() {
|
|
21
|
+
return { ssrID: this.ssrID };
|
|
22
|
+
};
|
|
23
|
+
ssrIDMap.set(element.ssrID, element);
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
delete options.onCreateElement;
|
|
29
|
+
vi.restoreAllMocks();
|
|
30
|
+
vi.unstubAllGlobals();
|
|
31
|
+
clearPage();
|
|
32
|
+
globalEnvManager.resetEnv();
|
|
33
|
+
elementTree.clear();
|
|
34
|
+
ssrIDMap.clear();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Legacy slot codegen keeps the surrounding views and list in one snapshot.
|
|
38
|
+
// The SSR path keeps custom-list-name undefined throughout hydration.
|
|
39
|
+
function WrappedList({ children }) {
|
|
40
|
+
return (
|
|
41
|
+
<view>
|
|
42
|
+
<list id='ssr-list' custom-list-name={undefined} scroll-orientation='horizontal'>
|
|
43
|
+
{children}
|
|
44
|
+
</list>
|
|
45
|
+
</view>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function NestedWrappedList({ children }) {
|
|
50
|
+
return (
|
|
51
|
+
<view>
|
|
52
|
+
<view>
|
|
53
|
+
<list id='ssr-list' custom-list-name={undefined} scroll-orientation='horizontal'>
|
|
54
|
+
{children}
|
|
55
|
+
</list>
|
|
56
|
+
</view>
|
|
57
|
+
</view>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function StoreWithProduct({ shop }) {
|
|
62
|
+
return (
|
|
63
|
+
<view>
|
|
64
|
+
<text>{shop.name}</text>
|
|
65
|
+
</view>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
describe.each([
|
|
70
|
+
{ List: WrappedList, listElementIndex: 1 },
|
|
71
|
+
{ List: NestedWrappedList, listElementIndex: 2 },
|
|
72
|
+
])('SSR list at element index $listElementIndex', ({ List, listElementIndex }) => {
|
|
73
|
+
it.each([0, 3])('hydrates %i items on the list and preserves the snapshot root', itemCount => {
|
|
74
|
+
const shops = Array.from({ length: itemCount }, (_, index) => ({ id: `${index}`, name: `Shop ${index}` }));
|
|
75
|
+
function App() {
|
|
76
|
+
return (
|
|
77
|
+
<List>
|
|
78
|
+
{shops.map(shop => (
|
|
79
|
+
<list-item key={shop.id} item-key={shop.id}>
|
|
80
|
+
<StoreWithProduct shop={shop} />
|
|
81
|
+
</list-item>
|
|
82
|
+
))}
|
|
83
|
+
</List>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
__root.__jsx = <App />;
|
|
88
|
+
renderPage();
|
|
89
|
+
|
|
90
|
+
const holder = __root.childNodes[0];
|
|
91
|
+
const page = __root.__element_root;
|
|
92
|
+
const view = holder.__element_root;
|
|
93
|
+
const list = elementTree.getElementById('ssr-list');
|
|
94
|
+
// Ensure this fixture exercises the coalesced snapshot from the regression.
|
|
95
|
+
expect(holder.__snapshot_def.slot).toEqual([[DynamicPartType.ListChildren, listElementIndex]]);
|
|
96
|
+
expect(holder.__elements[0]).toBe(view);
|
|
97
|
+
expect(holder.__elements[listElementIndex]).toBe(list);
|
|
98
|
+
expect(list.props['custom-list-name']).toBeUndefined();
|
|
99
|
+
const signs = shops.map((_, index) => elementTree.triggerComponentAtIndex(list, index));
|
|
100
|
+
const itemElements = [...list.children];
|
|
101
|
+
const info = ssrEncode();
|
|
102
|
+
|
|
103
|
+
clearPage();
|
|
104
|
+
globalEnvManager.resetEnv();
|
|
105
|
+
// Native SSR elements survive, but their server-side callbacks do not.
|
|
106
|
+
delete list.componentAtIndex;
|
|
107
|
+
delete list.enqueueComponent;
|
|
108
|
+
delete list.componentAtIndexes;
|
|
109
|
+
vi.stubGlobal('__GetPageElement', () => page);
|
|
110
|
+
vi.stubGlobal('__GetTemplateParts', () => Object.fromEntries(ssrIDMap));
|
|
111
|
+
const updateListCallbacks = vi.spyOn(globalThis, '__UpdateListCallbacks');
|
|
112
|
+
|
|
113
|
+
ssrHydrate(info);
|
|
114
|
+
|
|
115
|
+
const hydratedHolder = __root.childNodes[0];
|
|
116
|
+
expect(hydratedHolder.__element_root).toBe(view);
|
|
117
|
+
expect(hydratedHolder.__elements[listElementIndex]).toBe(list);
|
|
118
|
+
expect(page.children).toEqual([view]);
|
|
119
|
+
expect(list.props['custom-list-name']).toBeUndefined();
|
|
120
|
+
expect(updateListCallbacks).toHaveBeenCalledTimes(1);
|
|
121
|
+
expect(updateListCallbacks).toHaveBeenCalledWith(
|
|
122
|
+
list,
|
|
123
|
+
expect.any(Function),
|
|
124
|
+
expect.any(Function),
|
|
125
|
+
expect.any(Function),
|
|
126
|
+
);
|
|
127
|
+
for (const element of hydratedHolder.__elements.slice(0, listElementIndex)) {
|
|
128
|
+
expect(element.componentAtIndex).toBeUndefined();
|
|
129
|
+
expect(element.enqueueComponent).toBeUndefined();
|
|
130
|
+
expect(element.componentAtIndexes).toBeUndefined();
|
|
131
|
+
expect(gSignMap[__GetElementUniqueID(element)]).toBeUndefined();
|
|
132
|
+
expect(gRecycleMap[__GetElementUniqueID(element)]).toBeUndefined();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const listID = __GetElementUniqueID(list);
|
|
136
|
+
expect(gSignMap[listID].size).toBe(itemCount);
|
|
137
|
+
expect(gRecycleMap[listID]).toBeInstanceOf(Map);
|
|
138
|
+
signs.forEach((sign, index) => {
|
|
139
|
+
const child = hydratedHolder.childNodes[index];
|
|
140
|
+
expect(gSignMap[listID].get(sign)).toBe(child);
|
|
141
|
+
expect(gRecycleMap[listID].get(child.type).get(sign)).toBe(child);
|
|
142
|
+
expect(elementTree.triggerComponentAtIndex(list, index)).toBe(sign);
|
|
143
|
+
expect(child.__element_root).toBe(itemElements[index]);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Exercise recycling and the batch callback on the actual native list.
|
|
147
|
+
signs.forEach(sign => elementTree.triggerEnqueueComponent(list, sign));
|
|
148
|
+
const indexes = shops.map((_, index) => index).reverse();
|
|
149
|
+
const operationIDs = indexes.map(index => 100 + index);
|
|
150
|
+
const flushElementTree = vi.spyOn(globalThis, '__FlushElementTree');
|
|
151
|
+
elementTree.triggerComponentAtIndexes(list, indexes, operationIDs, false, false);
|
|
152
|
+
expect(flushElementTree).toHaveBeenLastCalledWith(list, {
|
|
153
|
+
triggerLayout: true,
|
|
154
|
+
operationIDs,
|
|
155
|
+
elementIDs: indexes.map(index => signs[index]),
|
|
156
|
+
listID,
|
|
157
|
+
});
|
|
158
|
+
expect(list.children).toEqual(itemElements);
|
|
159
|
+
|
|
160
|
+
// Subsequent page updates must remove the outer view, not the inner list.
|
|
161
|
+
const removeElement = vi.spyOn(globalThis, '__RemoveElement');
|
|
162
|
+
__root.__jsx = null;
|
|
163
|
+
updatePage({});
|
|
164
|
+
expect(removeElement).toHaveBeenCalledTimes(1);
|
|
165
|
+
expect(removeElement).toHaveBeenCalledWith(page, view);
|
|
166
|
+
expect(page.children).toEqual([]);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/** @jsxImportSource ../../lepus */
|
|
2
|
+
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import { globalEnvManager } from './utils/envManager';
|
|
6
|
+
import { elementTree, options } from './utils/nativeMethod';
|
|
7
|
+
import { __root } from '../../src/root';
|
|
8
|
+
import { clearPage } from '../../src/snapshot';
|
|
9
|
+
import { gRecycleMap, gSignMap } from '../../src/snapshot/list/list';
|
|
10
|
+
import { DynamicPartType } from '../../src/snapshot/snapshot/dynamicPartType';
|
|
11
|
+
|
|
12
|
+
const ssrIDMap = new Map();
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
globalEnvManager.resetEnv();
|
|
16
|
+
elementTree.clear();
|
|
17
|
+
let ssrID = 0;
|
|
18
|
+
options.onCreateElement = element => {
|
|
19
|
+
element.ssrID = `${ssrID++}`;
|
|
20
|
+
element.toJSON = function() {
|
|
21
|
+
return { ssrID: this.ssrID };
|
|
22
|
+
};
|
|
23
|
+
ssrIDMap.set(element.ssrID, element);
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
delete options.onCreateElement;
|
|
29
|
+
vi.restoreAllMocks();
|
|
30
|
+
vi.unstubAllGlobals();
|
|
31
|
+
clearPage();
|
|
32
|
+
globalEnvManager.resetEnv();
|
|
33
|
+
elementTree.clear();
|
|
34
|
+
ssrIDMap.clear();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function findSnapshot(element, snapshot = __root) {
|
|
38
|
+
if (snapshot.__element_root === element) return snapshot;
|
|
39
|
+
for (const child of snapshot.childNodes) {
|
|
40
|
+
const found = findSnapshot(element, child);
|
|
41
|
+
if (found) return found;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function restoreSSR() {
|
|
46
|
+
const page = __root.__element_root;
|
|
47
|
+
const info = ssrEncode();
|
|
48
|
+
clearPage();
|
|
49
|
+
globalEnvManager.resetEnv();
|
|
50
|
+
for (const element of ssrIDMap.values()) {
|
|
51
|
+
if (element.type === 'list') {
|
|
52
|
+
delete element.componentAtIndex;
|
|
53
|
+
delete element.enqueueComponent;
|
|
54
|
+
delete element.componentAtIndexes;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
vi.stubGlobal('__GetPageElement', () => page);
|
|
58
|
+
vi.stubGlobal('__GetTemplateParts', () => Object.fromEntries(ssrIDMap));
|
|
59
|
+
ssrHydrate(info);
|
|
60
|
+
return page;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function StoreWithProduct({ shop }) {
|
|
64
|
+
return (
|
|
65
|
+
<view>
|
|
66
|
+
<text>{shop.name}</text>
|
|
67
|
+
</view>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function ShopList({ shops }) {
|
|
72
|
+
return (
|
|
73
|
+
<list id='ssr-list' custom-list-name={undefined} scroll-orientation='horizontal'>
|
|
74
|
+
{shops.map(shop => (
|
|
75
|
+
<list-item key={shop.id} item-key={shop.id}>
|
|
76
|
+
<StoreWithProduct shop={shop} />
|
|
77
|
+
</list-item>
|
|
78
|
+
))}
|
|
79
|
+
</list>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Compile the nested list inline so separation is performed by the default
|
|
84
|
+
// list transform, rather than by a user-authored component boundary.
|
|
85
|
+
function WrappedList({ shops, nested }) {
|
|
86
|
+
const items = shops.map(shop => (
|
|
87
|
+
<list-item key={shop.id} item-key={shop.id}>
|
|
88
|
+
<StoreWithProduct shop={shop} />
|
|
89
|
+
</list-item>
|
|
90
|
+
));
|
|
91
|
+
return nested
|
|
92
|
+
? (
|
|
93
|
+
<view>
|
|
94
|
+
<view>
|
|
95
|
+
<list id='ssr-list' custom-list-name={undefined}>{items}</list>
|
|
96
|
+
</view>
|
|
97
|
+
</view>
|
|
98
|
+
)
|
|
99
|
+
: (
|
|
100
|
+
<view>
|
|
101
|
+
<list id='ssr-list' custom-list-name={undefined}>{items}</list>
|
|
102
|
+
</view>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function createShops(count) {
|
|
107
|
+
return Array.from({ length: count }, (_, index) => ({ id: `${index}`, name: `Shop ${index}` }));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
describe.each([false, true])('SSR default list slots, nested=%s', nested => {
|
|
111
|
+
it.each([0, 3])('restores callbacks and reuses %i items', count => {
|
|
112
|
+
__root.__jsx = <WrappedList shops={createShops(count)} nested={nested} />;
|
|
113
|
+
renderPage();
|
|
114
|
+
const view = __root.childNodes[0].__element_root;
|
|
115
|
+
const list = elementTree.getElementById('ssr-list');
|
|
116
|
+
expect(findSnapshot(list).__snapshot_def.slot).toEqual([[DynamicPartType.ListSlotV2, 0]]);
|
|
117
|
+
const signs = Array.from({ length: count }, (_, index) => elementTree.triggerComponentAtIndex(list, index));
|
|
118
|
+
const items = [...list.children];
|
|
119
|
+
const updateListCallbacks = vi.spyOn(globalThis, '__UpdateListCallbacks');
|
|
120
|
+
const page = restoreSSR();
|
|
121
|
+
|
|
122
|
+
expect(__root.childNodes[0].__element_root).toBe(view);
|
|
123
|
+
expect(findSnapshot(list).__elements).toEqual([list]);
|
|
124
|
+
expect(updateListCallbacks).toHaveBeenCalledTimes(1);
|
|
125
|
+
expect(updateListCallbacks).toHaveBeenCalledWith(
|
|
126
|
+
list,
|
|
127
|
+
expect.any(Function),
|
|
128
|
+
expect.any(Function),
|
|
129
|
+
expect.any(Function),
|
|
130
|
+
);
|
|
131
|
+
expect(view.componentAtIndex).toBeUndefined();
|
|
132
|
+
expect(gSignMap[__GetElementUniqueID(view)]).toBeUndefined();
|
|
133
|
+
expect(gRecycleMap[__GetElementUniqueID(view)]).toBeUndefined();
|
|
134
|
+
const listID = __GetElementUniqueID(list);
|
|
135
|
+
expect(gSignMap[listID].size).toBe(count);
|
|
136
|
+
expect(gRecycleMap[listID]).toBeInstanceOf(Map);
|
|
137
|
+
signs.forEach((sign, index) => {
|
|
138
|
+
const child = findSnapshot(list).childNodes[index];
|
|
139
|
+
expect(gSignMap[listID].get(sign)).toBe(child);
|
|
140
|
+
expect(gRecycleMap[listID].get(child.type).get(sign)).toBe(child);
|
|
141
|
+
expect(elementTree.triggerComponentAtIndex(list, index)).toBe(sign);
|
|
142
|
+
expect(child.__element_root).toBe(items[index]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
signs.forEach(sign => elementTree.triggerEnqueueComponent(list, sign));
|
|
146
|
+
const indexes = signs.map((_, index) => index).reverse();
|
|
147
|
+
const operationIDs = indexes.map(index => 100 + index);
|
|
148
|
+
const flush = vi.spyOn(globalThis, '__FlushElementTree');
|
|
149
|
+
elementTree.triggerComponentAtIndexes(list, indexes, operationIDs, false, false);
|
|
150
|
+
expect(flush).toHaveBeenLastCalledWith(list, {
|
|
151
|
+
triggerLayout: true,
|
|
152
|
+
operationIDs,
|
|
153
|
+
elementIDs: indexes.map(index => signs[index]),
|
|
154
|
+
listID,
|
|
155
|
+
});
|
|
156
|
+
expect(list.children).toEqual(items);
|
|
157
|
+
|
|
158
|
+
const remove = vi.spyOn(globalThis, '__RemoveElement');
|
|
159
|
+
__root.__jsx = null;
|
|
160
|
+
updatePage({});
|
|
161
|
+
expect(remove).toHaveBeenCalledTimes(1);
|
|
162
|
+
expect(remove).toHaveBeenCalledWith(page, view);
|
|
163
|
+
expect(page.children).toEqual([]);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('preserves sibling slot indexes when updating a hydrated list', () => {
|
|
168
|
+
function App({ shops, header }) {
|
|
169
|
+
return (
|
|
170
|
+
<view id='catalog'>
|
|
171
|
+
{header && <text id='header'>{header}</text>}
|
|
172
|
+
<text id='separator'>Products</text>
|
|
173
|
+
<ShopList shops={shops} />
|
|
174
|
+
<text id='footer'>Footer</text>
|
|
175
|
+
</view>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const shops = createShops(3);
|
|
179
|
+
__root.__jsx = <App shops={shops} />;
|
|
180
|
+
renderPage();
|
|
181
|
+
const list = elementTree.getElementById('ssr-list');
|
|
182
|
+
const catalog = elementTree.getElementById('catalog');
|
|
183
|
+
const slotContainers = [...catalog.children];
|
|
184
|
+
const footer = elementTree.getElementById('footer');
|
|
185
|
+
const signs = shops.map((_, index) => elementTree.triggerComponentAtIndex(list, index));
|
|
186
|
+
const listSlotIndex = findSnapshot(list).__slotIndex;
|
|
187
|
+
expect(listSlotIndex).toBeGreaterThan(0);
|
|
188
|
+
restoreSSR();
|
|
189
|
+
expect(findSnapshot(list).__slotIndex).toBe(listSlotIndex);
|
|
190
|
+
|
|
191
|
+
__root.__jsx = (
|
|
192
|
+
<App shops={[{ ...shops[2], name: 'Updated shop' }, shops[0], { id: 'new', name: 'New shop' }]} header='Header' />
|
|
193
|
+
);
|
|
194
|
+
updatePage({});
|
|
195
|
+
expect(elementTree.getElementById('ssr-list')).toBe(list);
|
|
196
|
+
expect(elementTree.getElementById('footer')).toBe(footer);
|
|
197
|
+
expect(catalog.children).toEqual(slotContainers);
|
|
198
|
+
expect(slotContainers[0].children).toEqual([elementTree.getElementById('header')]);
|
|
199
|
+
expect(slotContainers[2].children).toEqual([list]);
|
|
200
|
+
expect(findSnapshot(list).childNodes.map(child => child.__listItemPlatformInfo['item-key'])).toEqual([
|
|
201
|
+
'2',
|
|
202
|
+
'0',
|
|
203
|
+
'new',
|
|
204
|
+
]);
|
|
205
|
+
expect(elementTree.triggerComponentAtIndex(list, 0)).toBe(signs[2]);
|
|
206
|
+
expect(elementTree.triggerComponentAtIndex(list, 1)).toBe(signs[0]);
|
|
207
|
+
expect(elementTree.triggerComponentAtIndex(list, 2)).toBe(signs[1]);
|
|
208
|
+
expect(list.children.some(item => item.children[0]?.children[0]?.children[0]?.props.text === 'Updated shop')).toBe(
|
|
209
|
+
true,
|
|
210
|
+
);
|
|
211
|
+
});
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
import { render } from 'preact';
|
|
7
|
+
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
8
|
+
|
|
9
|
+
import { replaceCommitHook } from '../../../src/snapshot/lifecycle/patch/commit';
|
|
10
|
+
import { injectUpdateMainThread } from '../../../src/snapshot/lifecycle/patch/updateMainThread';
|
|
11
|
+
import { __root } from '../../../src/root';
|
|
12
|
+
import { setupPage } from '../../../src/snapshot';
|
|
13
|
+
import { destroyWorklet } from '../../../src/snapshot/worklet/destroy';
|
|
14
|
+
import { clearConfigCacheForTesting } from '../../../src/snapshot/worklet/functionality';
|
|
15
|
+
import { captureMainThreadObject } from '../../../src/core/capture-main-thread-object';
|
|
16
|
+
import { defineMainThreadObjectType, useMainThreadObject } from '../../../src/core/main-thread-object';
|
|
17
|
+
import { globalEnvManager } from '../utils/envManager';
|
|
18
|
+
import { injectUpdateMTRefInitValue } from '../../../src/snapshot/worklet/ref/updateInitValue';
|
|
19
|
+
|
|
20
|
+
beforeAll(() => {
|
|
21
|
+
setupPage(__CreatePage('0', 0));
|
|
22
|
+
injectUpdateMainThread();
|
|
23
|
+
injectUpdateMTRefInitValue();
|
|
24
|
+
replaceCommitHook();
|
|
25
|
+
globalThis.lynxWorkletImpl = {
|
|
26
|
+
_refImpl: {
|
|
27
|
+
updateWorkletRef: vi.fn(),
|
|
28
|
+
updateWorkletRefInitValueChanges: vi.fn(),
|
|
29
|
+
registerMainThreadObjectType: vi.fn(),
|
|
30
|
+
clearFirstScreenWorkletRefMap: vi.fn(),
|
|
31
|
+
},
|
|
32
|
+
_runOnBackgroundDelayImpl: {
|
|
33
|
+
runDelayedBackgroundFunctions: vi.fn(),
|
|
34
|
+
},
|
|
35
|
+
_eventDelayImpl: {
|
|
36
|
+
clearDelayedWorklets: vi.fn(),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
globalEnvManager.resetEnv();
|
|
43
|
+
SystemInfo.lynxSdkVersion = '999.999';
|
|
44
|
+
clearConfigCacheForTesting();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
destroyWorklet();
|
|
49
|
+
vi.clearAllMocks();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function renderTestMainThreadObject(initialValue) {
|
|
53
|
+
const type = defineMainThreadObjectType({
|
|
54
|
+
type: '@test/main-thread-object',
|
|
55
|
+
create: value => ({ value }),
|
|
56
|
+
});
|
|
57
|
+
let value;
|
|
58
|
+
const App = () => {
|
|
59
|
+
value = useMainThreadObject(type, initialValue);
|
|
60
|
+
return <view />;
|
|
61
|
+
};
|
|
62
|
+
render(<App />, __root);
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
describe('MainThreadObject', () => {
|
|
67
|
+
it('serializes an opaque typed handle and releases it with the shared id lifecycle', () => {
|
|
68
|
+
globalEnvManager.switchToBackground();
|
|
69
|
+
const dispatchEvent = vi.fn();
|
|
70
|
+
lynx.getCoreContext = () => ({ dispatchEvent });
|
|
71
|
+
const value = renderTestMainThreadObject(42);
|
|
72
|
+
|
|
73
|
+
expect(JSON.parse(JSON.stringify(value))).toEqual({
|
|
74
|
+
_wvid: 1,
|
|
75
|
+
_initValue: 42,
|
|
76
|
+
_type: '@test/main-thread-object',
|
|
77
|
+
});
|
|
78
|
+
expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledWith(
|
|
79
|
+
'rLynxChangeRefInitValue',
|
|
80
|
+
{ data: JSON.stringify([[1, 42, '@test/main-thread-object']]) },
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
lynx.getNativeApp().createJSObjectDestructionObserver.mock.calls[0][0]();
|
|
84
|
+
expect(dispatchEvent).toHaveBeenCalledWith({
|
|
85
|
+
type: 'Lynx.Worklet.releaseWorkletRef',
|
|
86
|
+
data: { id: 1 },
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('preserves opaque handles without changing ordinary member captures', () => {
|
|
91
|
+
globalEnvManager.switchToBackground();
|
|
92
|
+
const value = renderTestMainThreadObject(42);
|
|
93
|
+
|
|
94
|
+
expect(captureMainThreadObject(value)).toBe(value);
|
|
95
|
+
expect(captureMainThreadObject({ value: 42 })).toBeUndefined();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('creates a typed handle through the library-author hook', async () => {
|
|
99
|
+
const definition = {
|
|
100
|
+
type: '@test/counter',
|
|
101
|
+
create: value => ({ value }),
|
|
102
|
+
};
|
|
103
|
+
const type = defineMainThreadObjectType(definition);
|
|
104
|
+
let counter;
|
|
105
|
+
const App = () => {
|
|
106
|
+
counter = useMainThreadObject(type, 42);
|
|
107
|
+
return <view />;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
globalThis.globDynamicComponentEntry = '__Card__';
|
|
111
|
+
globalEnvManager.switchToBackground();
|
|
112
|
+
render(<App />, __root);
|
|
113
|
+
|
|
114
|
+
expect(JSON.parse(JSON.stringify(counter))).toMatchObject({
|
|
115
|
+
_initValue: 42,
|
|
116
|
+
_type: '@test/counter',
|
|
117
|
+
});
|
|
118
|
+
definition.type = '@test/mutated-counter';
|
|
119
|
+
expect(type.type).toBe('@test/counter');
|
|
120
|
+
expect(type).not.toHaveProperty('create');
|
|
121
|
+
expect(type).not.toHaveProperty('dispose');
|
|
122
|
+
const counterHandle = type.downcast(counter);
|
|
123
|
+
expect(counterHandle).toBe(counter);
|
|
124
|
+
expect(counterHandle.creationPayload).toBe(42);
|
|
125
|
+
|
|
126
|
+
const otherType = defineMainThreadObjectType({
|
|
127
|
+
type: '@test/other-counter',
|
|
128
|
+
create: value => ({ value }),
|
|
129
|
+
});
|
|
130
|
+
expect(otherType.downcast(counter)).toBeUndefined();
|
|
131
|
+
expect(otherType.downcast(null)).toBeUndefined();
|
|
132
|
+
expect(otherType.downcast(42)).toBeUndefined();
|
|
133
|
+
expect(otherType.downcast({
|
|
134
|
+
_initValue: 42,
|
|
135
|
+
_type: '@test/other-counter',
|
|
136
|
+
})).toBeUndefined();
|
|
137
|
+
expect(() => counter.get()).toThrow(
|
|
138
|
+
'MainThreadObject handle for "@test/counter" cannot access "get" in the background runtime. Use the object only inside a main-thread function.',
|
|
139
|
+
);
|
|
140
|
+
expect(counter.then).toBeUndefined();
|
|
141
|
+
expect(counter.$$typeof).toBeUndefined();
|
|
142
|
+
expect(counter[Symbol.toStringTag]).toBeUndefined();
|
|
143
|
+
await expect(Promise.resolve(counter)).resolves.toBe(counter);
|
|
144
|
+
expect(() => counter.value = 43).toThrow(
|
|
145
|
+
'MainThreadObject handle for "@test/counter" cannot set "value" in the background runtime. Use the object only inside a main-thread function.',
|
|
146
|
+
);
|
|
147
|
+
expect(() => counter._type = '@test/counter').not.toThrow();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('ensures registration on the first main-thread hook use', () => {
|
|
151
|
+
const create = value => ({ value });
|
|
152
|
+
const register = globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType;
|
|
153
|
+
|
|
154
|
+
globalEnvManager.switchToBackground();
|
|
155
|
+
const definition = {
|
|
156
|
+
type: '@test/retained-module-value',
|
|
157
|
+
create,
|
|
158
|
+
};
|
|
159
|
+
const type = defineMainThreadObjectType(definition);
|
|
160
|
+
expect(register).not.toHaveBeenCalled();
|
|
161
|
+
|
|
162
|
+
// Registration is deferred in the background runtime. Mutating the
|
|
163
|
+
// caller-owned object before the first main-thread use must not change the
|
|
164
|
+
// validated definition retained by the type token.
|
|
165
|
+
definition.type = '@test/mutated-retained-module-value';
|
|
166
|
+
definition.create = value => ({ value: value + 1 });
|
|
167
|
+
|
|
168
|
+
globalEnvManager.switchToMainThread();
|
|
169
|
+
const App = () => {
|
|
170
|
+
useMainThreadObject(type, 42);
|
|
171
|
+
return <view />;
|
|
172
|
+
};
|
|
173
|
+
render(<App />, __root);
|
|
174
|
+
|
|
175
|
+
expect(register).toHaveBeenCalledWith(
|
|
176
|
+
'@test/retained-module-value',
|
|
177
|
+
create,
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('snapshots accessor-backed definition fields before validation', () => {
|
|
182
|
+
let typeReads = 0;
|
|
183
|
+
let createReads = 0;
|
|
184
|
+
const create = value => ({ value });
|
|
185
|
+
const definition = {
|
|
186
|
+
get type() {
|
|
187
|
+
typeReads += 1;
|
|
188
|
+
return typeReads === 1 ? '@test/accessor-definition' : '@test/mutated-definition';
|
|
189
|
+
},
|
|
190
|
+
get create() {
|
|
191
|
+
createReads += 1;
|
|
192
|
+
return createReads === 1 ? create : { _wkltId: 'invalid-create' };
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
globalEnvManager.switchToBackground();
|
|
197
|
+
const type = defineMainThreadObjectType(definition);
|
|
198
|
+
expect(type.type).toBe('@test/accessor-definition');
|
|
199
|
+
expect(typeReads).toBe(1);
|
|
200
|
+
expect(createReads).toBe(1);
|
|
201
|
+
|
|
202
|
+
globalEnvManager.switchToMainThread();
|
|
203
|
+
const App = () => {
|
|
204
|
+
useMainThreadObject(type, 42);
|
|
205
|
+
return <view />;
|
|
206
|
+
};
|
|
207
|
+
render(<App />, __root);
|
|
208
|
+
|
|
209
|
+
expect(globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType)
|
|
210
|
+
.toHaveBeenCalledWith('@test/accessor-definition', create);
|
|
211
|
+
expect(typeReads).toBe(1);
|
|
212
|
+
expect(createReads).toBe(1);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('rejects a forged main-thread object type token', () => {
|
|
216
|
+
globalEnvManager.switchToMainThread();
|
|
217
|
+
const App = () => {
|
|
218
|
+
useMainThreadObject({ type: '@test/forged' }, 42);
|
|
219
|
+
return <view />;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
expect(() => render(<App />, __root)).toThrow(
|
|
223
|
+
'Invalid MainThreadObject type token for "@test/forged". Create it with defineMainThreadObjectType().',
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('uses a plain serializable handle in the main-thread runtime', () => {
|
|
228
|
+
globalEnvManager.switchToMainThread();
|
|
229
|
+
const type = defineMainThreadObjectType({
|
|
230
|
+
type: '@test/main-thread-counter',
|
|
231
|
+
create: value => ({ value }),
|
|
232
|
+
});
|
|
233
|
+
let counter;
|
|
234
|
+
const App = () => {
|
|
235
|
+
counter = useMainThreadObject(type, 42);
|
|
236
|
+
return <view />;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
globalThis.globDynamicComponentEntry = '__Card__';
|
|
240
|
+
render(<App />, __root);
|
|
241
|
+
|
|
242
|
+
expect(JSON.parse(JSON.stringify(counter))).toMatchObject({
|
|
243
|
+
_initValue: 42,
|
|
244
|
+
_type: '@test/main-thread-counter',
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('rejects non-serializable initialization payloads in development', () => {
|
|
249
|
+
globalEnvManager.switchToBackground();
|
|
250
|
+
|
|
251
|
+
expect(() => renderTestMainThreadObject({ nested: { callback() {} } }))
|
|
252
|
+
.toThrow(
|
|
253
|
+
'MainThreadObject initial value for "@test/main-thread-object" must be JSON-serializable; invalid value at $.nested.callback.',
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
const cyclic = {};
|
|
257
|
+
cyclic.self = cyclic;
|
|
258
|
+
expect(() => renderTestMainThreadObject(cyclic)).toThrow(
|
|
259
|
+
'MainThreadObject initial value for "@test/main-thread-object" must be JSON-serializable; invalid value at $.self.',
|
|
260
|
+
);
|
|
261
|
+
expect(() => renderTestMainThreadObject(new Date())).toThrow(
|
|
262
|
+
'MainThreadObject initial value for "@test/main-thread-object" must be JSON-serializable; invalid value at $.',
|
|
263
|
+
);
|
|
264
|
+
expect(() => renderTestMainThreadObject([1, { value: 2 }])).not.toThrow();
|
|
265
|
+
const sparseArray = Array(2);
|
|
266
|
+
sparseArray[1] = 1;
|
|
267
|
+
expect(() => renderTestMainThreadObject(sparseArray)).not.toThrow();
|
|
268
|
+
expect(() => renderTestMainThreadObject([undefined, 1])).toThrow(
|
|
269
|
+
'MainThreadObject initial value for "@test/main-thread-object" must be JSON-serializable; invalid value at $.0.',
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const arrayWithCustomFlatMap = [undefined, 1];
|
|
273
|
+
arrayWithCustomFlatMap.flatMap = () => [];
|
|
274
|
+
expect(() => renderTestMainThreadObject(arrayWithCustomFlatMap)).toThrow(
|
|
275
|
+
'MainThreadObject initial value for "@test/main-thread-object" must be JSON-serializable; invalid value at $.0.',
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('exposes the readonly-typed creation payload without a runtime copy', () => {
|
|
280
|
+
globalEnvManager.switchToBackground();
|
|
281
|
+
const initialValue = { nested: { value: 1 }, values: [2, 3] };
|
|
282
|
+
const value = renderTestMainThreadObject(initialValue);
|
|
283
|
+
const handle = captureMainThreadObject(value);
|
|
284
|
+
|
|
285
|
+
expect(handle).toBeDefined();
|
|
286
|
+
|
|
287
|
+
initialValue.nested.value = 4;
|
|
288
|
+
initialValue.values.push(5);
|
|
289
|
+
|
|
290
|
+
expect(handle.creationPayload).toBe(initialValue);
|
|
291
|
+
expect(Object.isFrozen(handle.creationPayload)).toBe(false);
|
|
292
|
+
expect(handle.creationPayload).toEqual({ nested: { value: 4 }, values: [2, 3, 5] });
|
|
293
|
+
expect(JSON.parse(JSON.stringify(value))._initValue).toEqual({
|
|
294
|
+
nested: { value: 4 },
|
|
295
|
+
values: [2, 3, 5],
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('identifies registered main-thread object handles', () => {
|
|
300
|
+
globalEnvManager.switchToBackground();
|
|
301
|
+
const value = renderTestMainThreadObject({ value: 1 });
|
|
302
|
+
|
|
303
|
+
expect(captureMainThreadObject(value)).toBe(value);
|
|
304
|
+
expect(captureMainThreadObject({ value: 1 })).toBeUndefined();
|
|
305
|
+
});
|
|
306
|
+
});
|