@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,140 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
5
|
+
|
|
6
|
+
import { getRuntimeVersion, registerRuntimeVersion, sRuntimeVersion } from '../../../src/core/lynx/runtime-version.js';
|
|
7
|
+
|
|
8
|
+
function restoreDescriptor(
|
|
9
|
+
target: typeof globalThis & Record<symbol, unknown>,
|
|
10
|
+
symbol: symbol,
|
|
11
|
+
descriptor: PropertyDescriptor | undefined,
|
|
12
|
+
): void {
|
|
13
|
+
if (descriptor) {
|
|
14
|
+
Object.defineProperty(target, symbol, descriptor);
|
|
15
|
+
} else {
|
|
16
|
+
delete target[symbol];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('runtime version marker', () => {
|
|
21
|
+
let originalLynxDescriptor: PropertyDescriptor | undefined;
|
|
22
|
+
let originalGlobalDescriptor: PropertyDescriptor | undefined;
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
originalLynxDescriptor = Object.getOwnPropertyDescriptor(lynx, sRuntimeVersion);
|
|
26
|
+
originalGlobalDescriptor = Object.getOwnPropertyDescriptor(globalThis, sRuntimeVersion);
|
|
27
|
+
delete (lynx as typeof lynx & Record<symbol, unknown>)[sRuntimeVersion];
|
|
28
|
+
delete (globalThis as typeof globalThis & Record<symbol, unknown>)[sRuntimeVersion];
|
|
29
|
+
vi.stubGlobal('__LEPUS__', false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
restoreDescriptor(
|
|
34
|
+
lynx as typeof lynx & Record<symbol, unknown>,
|
|
35
|
+
sRuntimeVersion,
|
|
36
|
+
originalLynxDescriptor,
|
|
37
|
+
);
|
|
38
|
+
restoreDescriptor(
|
|
39
|
+
globalThis as typeof globalThis & Record<symbol, unknown>,
|
|
40
|
+
sRuntimeVersion,
|
|
41
|
+
originalGlobalDescriptor,
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('registerRuntimeVersion', () => {
|
|
46
|
+
test('records the runtime version on the background target', () => {
|
|
47
|
+
registerRuntimeVersion('0.126.1');
|
|
48
|
+
|
|
49
|
+
expect((lynx as typeof lynx & Record<symbol, unknown>)[sRuntimeVersion]).toBe(
|
|
50
|
+
'0.126.1',
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('records the runtime version on the main-thread target', () => {
|
|
55
|
+
vi.stubGlobal('__LEPUS__', true);
|
|
56
|
+
|
|
57
|
+
registerRuntimeVersion('0.126.1');
|
|
58
|
+
|
|
59
|
+
expect((globalThis as typeof globalThis & Record<symbol, unknown>)[sRuntimeVersion]).toBe(
|
|
60
|
+
'0.126.1',
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('does nothing when the version is not stamped', () => {
|
|
65
|
+
registerRuntimeVersion(undefined);
|
|
66
|
+
|
|
67
|
+
expect(getRuntimeVersion()).toBeUndefined();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('keeps the host version when a lazy bundle registers later', () => {
|
|
71
|
+
// Host registers first.
|
|
72
|
+
registerRuntimeVersion('1.2.0');
|
|
73
|
+
|
|
74
|
+
// A later lazy bundle must not overwrite the host's recorded version.
|
|
75
|
+
registerRuntimeVersion('2.0.0');
|
|
76
|
+
expect(getRuntimeVersion()).toBe('1.2.0');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('logs the runtime version into Alog on registration', () => {
|
|
80
|
+
const alog = vi.fn();
|
|
81
|
+
vi.stubGlobal('console', { ...console, alog });
|
|
82
|
+
|
|
83
|
+
registerRuntimeVersion('0.126.1');
|
|
84
|
+
|
|
85
|
+
expect(alog).toHaveBeenCalledWith(
|
|
86
|
+
'[ReactLynx] new runtime version: 0.126.1',
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('logs both the recorded and the incoming version for later lazy bundles', () => {
|
|
91
|
+
const alog = vi.fn();
|
|
92
|
+
vi.stubGlobal('console', { ...console, alog });
|
|
93
|
+
|
|
94
|
+
registerRuntimeVersion('1.2.0');
|
|
95
|
+
registerRuntimeVersion('2.0.0');
|
|
96
|
+
|
|
97
|
+
expect(alog).toHaveBeenNthCalledWith(
|
|
98
|
+
1,
|
|
99
|
+
'[ReactLynx] new runtime version: 1.2.0',
|
|
100
|
+
);
|
|
101
|
+
expect(alog).toHaveBeenNthCalledWith(
|
|
102
|
+
2,
|
|
103
|
+
'[ReactLynx] new runtime version: 2.0.0, current version: 1.2.0',
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('does not log when the version is not stamped', () => {
|
|
108
|
+
const alog = vi.fn();
|
|
109
|
+
vi.stubGlobal('console', { ...console, alog });
|
|
110
|
+
|
|
111
|
+
registerRuntimeVersion(undefined);
|
|
112
|
+
|
|
113
|
+
expect(alog).not.toHaveBeenCalled();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('does not log on the main-thread build', () => {
|
|
117
|
+
vi.stubGlobal('__JS__', false);
|
|
118
|
+
const alog = vi.fn();
|
|
119
|
+
vi.stubGlobal('console', { ...console, alog });
|
|
120
|
+
|
|
121
|
+
registerRuntimeVersion('0.126.1');
|
|
122
|
+
|
|
123
|
+
expect(alog).not.toHaveBeenCalled();
|
|
124
|
+
// The version is still recorded so `getRuntimeVersion` keeps working.
|
|
125
|
+
expect(getRuntimeVersion()).toBe('0.126.1');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('getRuntimeVersion', () => {
|
|
130
|
+
test('returns undefined before any registration', () => {
|
|
131
|
+
expect(getRuntimeVersion()).toBeUndefined();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('returns the recorded host version', () => {
|
|
135
|
+
registerRuntimeVersion('0.126.1');
|
|
136
|
+
|
|
137
|
+
expect(getRuntimeVersion()).toBe('0.126.1');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
@@ -103,7 +103,7 @@ describe('createElement', () => {
|
|
|
103
103
|
`);
|
|
104
104
|
|
|
105
105
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
106
|
-
snapshotPatchApply(patch);
|
|
106
|
+
snapshotPatchApply(patch, 42, false);
|
|
107
107
|
expect(snapshotInstanceManager.values.size).toEqual(3);
|
|
108
108
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
109
109
|
si1.ensureElements();
|
|
@@ -158,7 +158,7 @@ describe('insertBefore', () => {
|
|
|
158
158
|
`);
|
|
159
159
|
|
|
160
160
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
161
|
-
snapshotPatchApply(patch);
|
|
161
|
+
snapshotPatchApply(patch, 42, false);
|
|
162
162
|
expect(snapshotInstanceManager.values.size).toEqual(3);
|
|
163
163
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
164
164
|
si1.ensureElements();
|
|
@@ -272,7 +272,7 @@ describe('insertBefore', () => {
|
|
|
272
272
|
`);
|
|
273
273
|
|
|
274
274
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
275
|
-
snapshotPatchApply(patch);
|
|
275
|
+
snapshotPatchApply(patch, 42, false);
|
|
276
276
|
expect(snapshotInstanceManager.values.size).toEqual(4);
|
|
277
277
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
278
278
|
si1.ensureElements();
|
|
@@ -352,23 +352,23 @@ describe('insertBefore', () => {
|
|
|
352
352
|
`);
|
|
353
353
|
|
|
354
354
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
355
|
-
snapshotPatchApply(patch);
|
|
355
|
+
snapshotPatchApply(patch, 42, false);
|
|
356
356
|
expect(_ReportError.mock.calls).toMatchInlineSnapshot(`
|
|
357
357
|
[
|
|
358
358
|
[
|
|
359
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
359
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, child: { id: 100, snapshot type: 'null', missing: true }, operation: 'InsertBefore', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
360
360
|
{
|
|
361
361
|
"errorCode": 1101,
|
|
362
362
|
},
|
|
363
363
|
],
|
|
364
364
|
[
|
|
365
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
365
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: { id: 100, snapshot type: 'null', missing: true }, child: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, operation: 'InsertBefore', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
366
366
|
{
|
|
367
367
|
"errorCode": 1101,
|
|
368
368
|
},
|
|
369
369
|
],
|
|
370
370
|
[
|
|
371
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: '__snapshot_a94a8_test_3'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
371
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: '__snapshot_a94a8_test_3', parent: { id: 4, snapshot type: '__snapshot_a94a8_test_3', missing: true }, child: { id: 100, snapshot type: 'null', missing: true }, operation: 'InsertBefore', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
372
372
|
{
|
|
373
373
|
"errorCode": 1101,
|
|
374
374
|
},
|
|
@@ -402,7 +402,7 @@ describe('removeChild', () => {
|
|
|
402
402
|
const bsi2 = new BackgroundSnapshotInstance(snapshot2);
|
|
403
403
|
bsi1.insertBefore(bsi2);
|
|
404
404
|
let patch = takeGlobalSnapshotPatch();
|
|
405
|
-
snapshotPatchApply(patch);
|
|
405
|
+
snapshotPatchApply(patch, 42, false);
|
|
406
406
|
|
|
407
407
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
408
408
|
si1.ensureElements();
|
|
@@ -434,7 +434,7 @@ describe('removeChild', () => {
|
|
|
434
434
|
3,
|
|
435
435
|
]
|
|
436
436
|
`);
|
|
437
|
-
snapshotPatchApply(patch);
|
|
437
|
+
snapshotPatchApply(patch, 42, false);
|
|
438
438
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
439
439
|
<view>
|
|
440
440
|
<text>
|
|
@@ -454,7 +454,7 @@ describe('removeChild', () => {
|
|
|
454
454
|
bsi1.insertBefore(bsi2);
|
|
455
455
|
bsi1.insertBefore(bsi3);
|
|
456
456
|
let patch = takeGlobalSnapshotPatch();
|
|
457
|
-
snapshotPatchApply(patch);
|
|
457
|
+
snapshotPatchApply(patch, 42, false);
|
|
458
458
|
|
|
459
459
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
460
460
|
si1.ensureElements();
|
|
@@ -493,7 +493,7 @@ describe('removeChild', () => {
|
|
|
493
493
|
3,
|
|
494
494
|
]
|
|
495
495
|
`);
|
|
496
|
-
snapshotPatchApply(patch);
|
|
496
|
+
snapshotPatchApply(patch, 42, false);
|
|
497
497
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
498
498
|
<view>
|
|
499
499
|
<text>
|
|
@@ -525,19 +525,19 @@ describe('removeChild', () => {
|
|
|
525
525
|
1,
|
|
526
526
|
]
|
|
527
527
|
`);
|
|
528
|
-
snapshotPatchApply(patch);
|
|
528
|
+
snapshotPatchApply(patch, 42, false);
|
|
529
529
|
expect(_ReportError).toHaveBeenCalledTimes(2);
|
|
530
530
|
|
|
531
531
|
expect(_ReportError.mock.calls).toMatchInlineSnapshot(`
|
|
532
532
|
[
|
|
533
533
|
[
|
|
534
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
534
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root', parent: { id: 1, snapshot type: 'root', missing: true }, child: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, operation: 'RemoveChild', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
535
535
|
{
|
|
536
536
|
"errorCode": 1101,
|
|
537
537
|
},
|
|
538
538
|
],
|
|
539
539
|
[
|
|
540
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
540
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root', parent: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, child: { id: 1, snapshot type: 'root', missing: true }, operation: 'RemoveChild', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
541
541
|
{
|
|
542
542
|
"errorCode": 1101,
|
|
543
543
|
},
|
|
@@ -572,7 +572,7 @@ describe('removeChild', () => {
|
|
|
572
572
|
4,
|
|
573
573
|
]
|
|
574
574
|
`);
|
|
575
|
-
snapshotPatchApply(patch);
|
|
575
|
+
snapshotPatchApply(patch, 42, false);
|
|
576
576
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
577
577
|
<view>
|
|
578
578
|
<text>
|
|
@@ -613,7 +613,7 @@ describe('setAttribute', () => {
|
|
|
613
613
|
`);
|
|
614
614
|
|
|
615
615
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
616
|
-
snapshotPatchApply(patch);
|
|
616
|
+
snapshotPatchApply(patch, 42, false);
|
|
617
617
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
618
618
|
si1.ensureElements();
|
|
619
619
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
@@ -647,7 +647,7 @@ describe('setAttribute', () => {
|
|
|
647
647
|
`);
|
|
648
648
|
|
|
649
649
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
650
|
-
snapshotPatchApply(patch);
|
|
650
|
+
snapshotPatchApply(patch, 42, false);
|
|
651
651
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
652
652
|
si1.ensureElements();
|
|
653
653
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
@@ -683,7 +683,7 @@ describe('setAttribute', () => {
|
|
|
683
683
|
patch.push(SnapshotOperation.SetAttributes, 2, ['attr 3', 'attr 4']);
|
|
684
684
|
|
|
685
685
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
686
|
-
snapshotPatchApply(patch);
|
|
686
|
+
snapshotPatchApply(patch, 42, false);
|
|
687
687
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
688
688
|
si1.ensureElements();
|
|
689
689
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
@@ -718,12 +718,12 @@ describe('setAttribute', () => {
|
|
|
718
718
|
patch.push(SnapshotOperation.SetAttributes, 2, ['attr 3', 'attr 4']);
|
|
719
719
|
|
|
720
720
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
721
|
-
snapshotPatchApply(patch);
|
|
721
|
+
snapshotPatchApply(patch, 42, false);
|
|
722
722
|
expect(_ReportError).toHaveBeenCalledTimes(1);
|
|
723
723
|
expect(_ReportError.mock.calls).toMatchInlineSnapshot(`
|
|
724
724
|
[
|
|
725
725
|
[
|
|
726
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
726
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: null, operation: 'SetAttributes', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
727
727
|
{
|
|
728
728
|
"errorCode": 1101,
|
|
729
729
|
},
|
|
@@ -762,12 +762,12 @@ describe('setAttribute', () => {
|
|
|
762
762
|
`);
|
|
763
763
|
|
|
764
764
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
765
|
-
snapshotPatchApply(patch);
|
|
765
|
+
snapshotPatchApply(patch, 42, false);
|
|
766
766
|
expect(_ReportError).toHaveBeenCalledTimes(1);
|
|
767
767
|
|
|
768
768
|
expect(_ReportError.mock.calls[0]).toMatchInlineSnapshot(`
|
|
769
769
|
[
|
|
770
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
770
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: null, operation: 'SetAttribute', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
771
771
|
{
|
|
772
772
|
"errorCode": 1101,
|
|
773
773
|
},
|
|
@@ -864,7 +864,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
864
864
|
delete snapshotCreatorMap[uniqID1];
|
|
865
865
|
|
|
866
866
|
// Apply patches in main thread
|
|
867
|
-
snapshotPatchApply(patch);
|
|
867
|
+
snapshotPatchApply(patch, 42, false);
|
|
868
868
|
new SnapshotInstance(uniqID1);
|
|
869
869
|
|
|
870
870
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -969,7 +969,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
969
969
|
const fn = vi.fn();
|
|
970
970
|
vi.stubGlobal('__SetCSSId', fn);
|
|
971
971
|
// Apply patches in main thread
|
|
972
|
-
snapshotPatchApply(patch);
|
|
972
|
+
snapshotPatchApply(patch, 42, false);
|
|
973
973
|
new SnapshotInstance(uniqID1);
|
|
974
974
|
|
|
975
975
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1029,11 +1029,15 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1029
1029
|
|
|
1030
1030
|
expect(snapshotCreatorMap[uniqID1].toString()).toContain('[native code]');
|
|
1031
1031
|
expect(() =>
|
|
1032
|
-
snapshotPatchApply(
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1032
|
+
snapshotPatchApply(
|
|
1033
|
+
[
|
|
1034
|
+
SnapshotOperation.DEV_ONLY_SetSnapshotEntryName,
|
|
1035
|
+
uniqID1,
|
|
1036
|
+
'https://example.com/lazy-bundle.js',
|
|
1037
|
+
],
|
|
1038
|
+
42,
|
|
1039
|
+
false,
|
|
1040
|
+
)
|
|
1037
1041
|
).not.toThrow();
|
|
1038
1042
|
});
|
|
1039
1043
|
|
|
@@ -1048,11 +1052,15 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1048
1052
|
|
|
1049
1053
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
1050
1054
|
expect(() =>
|
|
1051
|
-
snapshotPatchApply(
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1055
|
+
snapshotPatchApply(
|
|
1056
|
+
[
|
|
1057
|
+
SnapshotOperation.DEV_ONLY_SetSnapshotEntryName,
|
|
1058
|
+
uniqID1,
|
|
1059
|
+
'https://example.com/lazy-bundle.js',
|
|
1060
|
+
],
|
|
1061
|
+
42,
|
|
1062
|
+
false,
|
|
1063
|
+
)
|
|
1056
1064
|
).not.toThrow();
|
|
1057
1065
|
expect(warn).toHaveBeenCalledTimes(1);
|
|
1058
1066
|
warn.mockRestore();
|
|
@@ -1060,11 +1068,15 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1060
1068
|
|
|
1061
1069
|
it('with a creator that is missing', () => {
|
|
1062
1070
|
expect(() =>
|
|
1063
|
-
snapshotPatchApply(
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1071
|
+
snapshotPatchApply(
|
|
1072
|
+
[
|
|
1073
|
+
SnapshotOperation.DEV_ONLY_SetSnapshotEntryName,
|
|
1074
|
+
'first-screen-lazy-missing',
|
|
1075
|
+
'https://example.com/lazy-bundle.js',
|
|
1076
|
+
],
|
|
1077
|
+
42,
|
|
1078
|
+
false,
|
|
1079
|
+
)
|
|
1068
1080
|
).not.toThrow();
|
|
1069
1081
|
});
|
|
1070
1082
|
|
|
@@ -1141,7 +1153,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1141
1153
|
delete snapshotCreatorMap[uniqID1];
|
|
1142
1154
|
|
|
1143
1155
|
// Apply patches in main thread
|
|
1144
|
-
snapshotPatchApply(patch);
|
|
1156
|
+
snapshotPatchApply(patch, 42, false);
|
|
1145
1157
|
new SnapshotInstance(uniqID1);
|
|
1146
1158
|
|
|
1147
1159
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1236,7 +1248,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1236
1248
|
delete snapshotCreatorMap[uniqID1];
|
|
1237
1249
|
|
|
1238
1250
|
// Apply patches in main thread
|
|
1239
|
-
snapshotPatchApply(patch);
|
|
1251
|
+
snapshotPatchApply(patch, 42, false);
|
|
1240
1252
|
new SnapshotInstance(uniqID1);
|
|
1241
1253
|
|
|
1242
1254
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1326,7 +1338,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1326
1338
|
delete snapshotCreatorMap[uniqID1];
|
|
1327
1339
|
|
|
1328
1340
|
// Apply patches in main thread
|
|
1329
|
-
snapshotPatchApply(patch);
|
|
1341
|
+
snapshotPatchApply(patch, 42, false);
|
|
1330
1342
|
new SnapshotInstance(uniqID1);
|
|
1331
1343
|
|
|
1332
1344
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1416,7 +1428,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1416
1428
|
const fn = vi.fn();
|
|
1417
1429
|
vi.stubGlobal('__SetCSSId', fn);
|
|
1418
1430
|
// Apply patches in main thread
|
|
1419
|
-
snapshotPatchApply(patch);
|
|
1431
|
+
snapshotPatchApply(patch, 42, false);
|
|
1420
1432
|
new SnapshotInstance(uniqID1);
|
|
1421
1433
|
|
|
1422
1434
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1608,7 +1620,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1608
1620
|
snapshotManager.values.delete(uniqID1);
|
|
1609
1621
|
delete snapshotCreatorMap[uniqID1];
|
|
1610
1622
|
|
|
1611
|
-
snapshotPatchApply(patch);
|
|
1623
|
+
snapshotPatchApply(patch, 42, false);
|
|
1612
1624
|
new SnapshotInstance(uniqID1);
|
|
1613
1625
|
|
|
1614
1626
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1645,7 +1657,7 @@ describe.skip('DEV_ONLY_RegisterWorklet', () => {
|
|
|
1645
1657
|
`);
|
|
1646
1658
|
|
|
1647
1659
|
// Apply patches in main thread
|
|
1648
|
-
snapshotPatchApply(patch);
|
|
1660
|
+
snapshotPatchApply(patch, 42, false);
|
|
1649
1661
|
|
|
1650
1662
|
expect(globalThis.registerWorklet).toBeCalledTimes(1);
|
|
1651
1663
|
expect(globalThis.registerWorklet.mock.calls[0][0]).toMatch('main-thread');
|
|
@@ -1668,7 +1680,7 @@ describe('list', () => {
|
|
|
1668
1680
|
let patch;
|
|
1669
1681
|
patch = takeGlobalSnapshotPatch();
|
|
1670
1682
|
expect(patch.length).toMatchInlineSnapshot(`3`);
|
|
1671
|
-
snapshotPatchApply(patch);
|
|
1683
|
+
snapshotPatchApply(patch, 42, false);
|
|
1672
1684
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
1673
1685
|
si1.ensureElements();
|
|
1674
1686
|
|
|
@@ -1677,7 +1689,7 @@ describe('list', () => {
|
|
|
1677
1689
|
bsi1.insertBefore(bsi2);
|
|
1678
1690
|
patch = takeGlobalSnapshotPatch();
|
|
1679
1691
|
expect(patch.length).toMatchInlineSnapshot(`11`);
|
|
1680
|
-
snapshotPatchApply(patch);
|
|
1692
|
+
snapshotPatchApply(patch, 42, false);
|
|
1681
1693
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
1682
1694
|
<view>
|
|
1683
1695
|
<text>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
4
|
// LICENSE file in the root directory of this source tree.
|
|
5
5
|
*/
|
|
6
|
-
import { render } from 'preact';
|
|
6
|
+
import { options, render } from 'preact';
|
|
7
7
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
8
8
|
|
|
9
9
|
import { useState } from '../../src/index';
|
|
@@ -210,7 +210,7 @@ describe('spreadUpdate', () => {
|
|
|
210
210
|
render(<Comp />, scratchBackground);
|
|
211
211
|
patch = hydrate(JSON.parse(JSON.stringify(scratch)), scratchBackground);
|
|
212
212
|
globalEnvManager.switchToMainThread();
|
|
213
|
-
snapshotPatchApply(patch);
|
|
213
|
+
snapshotPatchApply(patch, 42, false);
|
|
214
214
|
globalEnvManager.switchToBackground();
|
|
215
215
|
initGlobalSnapshotPatch();
|
|
216
216
|
|
|
@@ -237,7 +237,7 @@ describe('spreadUpdate', () => {
|
|
|
237
237
|
`);
|
|
238
238
|
|
|
239
239
|
globalEnvManager.switchToMainThread();
|
|
240
|
-
snapshotPatchApply(patch);
|
|
240
|
+
snapshotPatchApply(patch, 42, false);
|
|
241
241
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
242
242
|
<page
|
|
243
243
|
cssId="default-entry-from-native:0"
|
|
@@ -314,7 +314,7 @@ describe('spreadUpdate', () => {
|
|
|
314
314
|
// this update could be removed later
|
|
315
315
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
316
316
|
globalEnvManager.switchToMainThread();
|
|
317
|
-
snapshotPatchApply(patch);
|
|
317
|
+
snapshotPatchApply(patch, 42, false);
|
|
318
318
|
globalEnvManager.switchToBackground();
|
|
319
319
|
initGlobalSnapshotPatch();
|
|
320
320
|
setSpread_({
|
|
@@ -340,7 +340,7 @@ describe('spreadUpdate', () => {
|
|
|
340
340
|
`);
|
|
341
341
|
|
|
342
342
|
globalEnvManager.switchToMainThread();
|
|
343
|
-
snapshotPatchApply(patch);
|
|
343
|
+
snapshotPatchApply(patch, 42, false);
|
|
344
344
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
345
345
|
<page
|
|
346
346
|
cssId="default-entry-from-native:0"
|
|
@@ -417,7 +417,7 @@ describe('spreadUpdate', () => {
|
|
|
417
417
|
// this update could be removed later
|
|
418
418
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
419
419
|
globalEnvManager.switchToMainThread();
|
|
420
|
-
snapshotPatchApply(patch);
|
|
420
|
+
snapshotPatchApply(patch, 42, false);
|
|
421
421
|
globalEnvManager.switchToBackground();
|
|
422
422
|
initGlobalSnapshotPatch();
|
|
423
423
|
setSpread_({});
|
|
@@ -433,7 +433,7 @@ describe('spreadUpdate', () => {
|
|
|
433
433
|
`);
|
|
434
434
|
|
|
435
435
|
globalEnvManager.switchToMainThread();
|
|
436
|
-
snapshotPatchApply(patch);
|
|
436
|
+
snapshotPatchApply(patch, 42, false);
|
|
437
437
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
438
438
|
<page
|
|
439
439
|
cssId="default-entry-from-native:0"
|
|
@@ -502,7 +502,7 @@ describe('spreadUpdate', () => {
|
|
|
502
502
|
// this update could be removed later
|
|
503
503
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
504
504
|
globalEnvManager.switchToMainThread();
|
|
505
|
-
snapshotPatchApply(patch);
|
|
505
|
+
snapshotPatchApply(patch, 42, false);
|
|
506
506
|
globalEnvManager.switchToBackground();
|
|
507
507
|
initGlobalSnapshotPatch();
|
|
508
508
|
setSpread_(null);
|
|
@@ -518,7 +518,7 @@ describe('spreadUpdate', () => {
|
|
|
518
518
|
`);
|
|
519
519
|
|
|
520
520
|
globalEnvManager.switchToMainThread();
|
|
521
|
-
snapshotPatchApply(patch);
|
|
521
|
+
snapshotPatchApply(patch, 42, false);
|
|
522
522
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
523
523
|
<page
|
|
524
524
|
cssId="default-entry-from-native:0"
|
|
@@ -625,7 +625,7 @@ describe('spreadUpdate', () => {
|
|
|
625
625
|
// this update could be removed later
|
|
626
626
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
627
627
|
globalEnvManager.switchToMainThread();
|
|
628
|
-
snapshotPatchApply(patch);
|
|
628
|
+
snapshotPatchApply(patch, 42, false);
|
|
629
629
|
globalEnvManager.switchToBackground();
|
|
630
630
|
initGlobalSnapshotPatch();
|
|
631
631
|
setSpread_({});
|
|
@@ -645,7 +645,7 @@ describe('spreadUpdate', () => {
|
|
|
645
645
|
`);
|
|
646
646
|
|
|
647
647
|
globalEnvManager.switchToMainThread();
|
|
648
|
-
snapshotPatchApply(patch);
|
|
648
|
+
snapshotPatchApply(patch, 42, false);
|
|
649
649
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
650
650
|
<page
|
|
651
651
|
cssId="default-entry-from-native:0"
|
|
@@ -690,7 +690,7 @@ describe('spreadUpdate', () => {
|
|
|
690
690
|
`);
|
|
691
691
|
});
|
|
692
692
|
|
|
693
|
-
it('circular reference', async () => {
|
|
693
|
+
it.each(['root', 'scheduled'])('circular reference during %s render', async (renderMode) => {
|
|
694
694
|
await import('../../src/lynx');
|
|
695
695
|
let patch;
|
|
696
696
|
let setSpread_;
|
|
@@ -723,19 +723,26 @@ describe('spreadUpdate', () => {
|
|
|
723
723
|
render(<Comp />, scratchBackground);
|
|
724
724
|
|
|
725
725
|
initGlobalSnapshotPatch();
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
726
|
+
const previousDebounce = options.debounceRendering;
|
|
727
|
+
let flushScheduledRender;
|
|
728
|
+
options.debounceRendering = callback => {
|
|
729
|
+
flushScheduledRender = callback;
|
|
730
|
+
};
|
|
731
|
+
try {
|
|
732
|
+
setSpread_(a);
|
|
733
|
+
|
|
734
|
+
expect(() => {
|
|
735
|
+
if (renderMode === 'scheduled') {
|
|
736
|
+
flushScheduledRender();
|
|
737
|
+
} else {
|
|
738
|
+
render(<Comp />, scratchBackground);
|
|
739
|
+
}
|
|
740
|
+
}).toThrowError(/Converting circular structure to JSON[\s\S]*in Bar\n in Comp\n$/);
|
|
741
|
+
patch = takeGlobalSnapshotPatch();
|
|
742
|
+
expect(patch).toEqual([]);
|
|
743
|
+
} finally {
|
|
744
|
+
options.debounceRendering = previousDebounce;
|
|
745
|
+
}
|
|
739
746
|
});
|
|
740
747
|
|
|
741
748
|
it('should remove __self and __source when spreading props onto element', async function() {
|