@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
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { h } from 'preact';
|
|
6
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { renderToElementTemplate } from '../../../../src/element-template/runtime/render/render-direct.js';
|
|
9
|
+
import { __ElementTemplatePage } from '../../../../src/element-template/runtime/page/authored-page.js';
|
|
9
10
|
import {
|
|
10
11
|
destroyAllElementTemplateListStates,
|
|
11
12
|
flushInitialElementTemplateListUpdates,
|
|
@@ -19,18 +20,8 @@ import {
|
|
|
19
20
|
adaptSpreadAttrSlot,
|
|
20
21
|
clearEtAttrPlanMap,
|
|
21
22
|
} from '../../../../src/element-template/runtime/template/attr-slot-plan.js';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
__OpBegin,
|
|
25
|
-
__OpEnd,
|
|
26
|
-
__OpPageEnd,
|
|
27
|
-
__OpPageStart,
|
|
28
|
-
__OpSlot,
|
|
29
|
-
__OpText,
|
|
30
|
-
renderToString,
|
|
31
|
-
} from '../../../../src/element-template/runtime/render/render-to-opcodes.js';
|
|
32
|
-
|
|
33
|
-
describe('renderOpcodesIntoElementTemplate', () => {
|
|
23
|
+
|
|
24
|
+
describe('direct renderer native contracts', () => {
|
|
34
25
|
const createElementTemplate = vi.fn();
|
|
35
26
|
const createTypedElementTemplate = vi.fn();
|
|
36
27
|
const getElementUniqueID = vi.fn();
|
|
@@ -38,7 +29,6 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
38
29
|
const removeNodeFromElementTemplate = vi.fn();
|
|
39
30
|
const flushElementTree = vi.fn();
|
|
40
31
|
const addEvent = vi.fn();
|
|
41
|
-
const onLifecycleEvent = vi.fn();
|
|
42
32
|
|
|
43
33
|
beforeEach(() => {
|
|
44
34
|
createElementTemplate.mockReset();
|
|
@@ -48,7 +38,6 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
48
38
|
removeNodeFromElementTemplate.mockReset();
|
|
49
39
|
flushElementTree.mockReset();
|
|
50
40
|
addEvent.mockReset();
|
|
51
|
-
onLifecycleEvent.mockReset();
|
|
52
41
|
getElementUniqueID.mockImplementation((node: { __mockNativeId?: number }) => node.__mockNativeId);
|
|
53
42
|
vi.stubGlobal('__CreateElementTemplate', createElementTemplate);
|
|
54
43
|
vi.stubGlobal('__CreateTypedElementTemplate', createTypedElementTemplate);
|
|
@@ -57,7 +46,6 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
57
46
|
vi.stubGlobal('__RemoveNodeFromElementTemplate', removeNodeFromElementTemplate);
|
|
58
47
|
vi.stubGlobal('__FlushElementTree', flushElementTree);
|
|
59
48
|
vi.stubGlobal('__AddEvent', addEvent);
|
|
60
|
-
vi.stubGlobal('__OnLifecycleEvent', onLifecycleEvent);
|
|
61
49
|
elementTemplateRegistry.clear();
|
|
62
50
|
destroyAllElementTemplateListStates();
|
|
63
51
|
clearEtAttrPlanMap();
|
|
@@ -69,17 +57,11 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
69
57
|
clearEtAttrPlanMap();
|
|
70
58
|
});
|
|
71
59
|
|
|
72
|
-
it('throws when popping the root frame', () => {
|
|
73
|
-
expect(() => renderOpcodesIntoElementTemplate([__OpEnd])).toThrow(
|
|
74
|
-
'Popped root frame',
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
60
|
it('creates root text through the builtin raw-text template with a handle id', () => {
|
|
79
61
|
const rootTextRef = { kind: 'text-ref' };
|
|
80
62
|
createElementTemplate.mockReturnValue(rootTextRef);
|
|
81
63
|
|
|
82
|
-
const result =
|
|
64
|
+
const result = renderToElementTemplate('hello');
|
|
83
65
|
|
|
84
66
|
expect(result.rootRefs).toEqual([rootTextRef]);
|
|
85
67
|
expect(result.pageAttributes).toBeNull();
|
|
@@ -94,44 +76,18 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
94
76
|
expect(elementTemplateRegistry.get(-1)).toBe(rootTextRef);
|
|
95
77
|
});
|
|
96
78
|
|
|
97
|
-
it('returns singleton page attrs from the
|
|
79
|
+
it('returns singleton page attrs from the authored page', () => {
|
|
98
80
|
const attributes = { id: 'screen' };
|
|
99
81
|
|
|
100
|
-
const result =
|
|
101
|
-
__OpPageStart,
|
|
102
|
-
attributes,
|
|
103
|
-
]);
|
|
82
|
+
const result = renderToElementTemplate(h(__ElementTemplatePage, { attributes }));
|
|
104
83
|
|
|
105
|
-
expect(result).
|
|
84
|
+
expect(result).toMatchObject({
|
|
106
85
|
pageAttributes: attributes,
|
|
107
86
|
rootRefs: [],
|
|
108
87
|
rootSubtreeHandles: [],
|
|
109
88
|
});
|
|
110
89
|
});
|
|
111
90
|
|
|
112
|
-
it('rejects page attrs inside a materialized host', () => {
|
|
113
|
-
expect(() =>
|
|
114
|
-
renderOpcodesIntoElementTemplate([
|
|
115
|
-
__OpBegin,
|
|
116
|
-
{ type: '_et_parent' },
|
|
117
|
-
__OpPageStart,
|
|
118
|
-
{ id: 'nested' },
|
|
119
|
-
__OpEnd,
|
|
120
|
-
])
|
|
121
|
-
).toThrow('must be the outermost element');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('rejects more than one page attr instruction', () => {
|
|
125
|
-
expect(() =>
|
|
126
|
-
renderOpcodesIntoElementTemplate([
|
|
127
|
-
__OpPageStart,
|
|
128
|
-
{ id: 'first' },
|
|
129
|
-
__OpPageStart,
|
|
130
|
-
{ id: 'second' },
|
|
131
|
-
])
|
|
132
|
-
).toThrow('does not support multiple authored <page /> elements');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
91
|
it('materializes multiple roots inside one outermost page', () => {
|
|
136
92
|
const firstRootRef = { kind: 'first-root-ref' };
|
|
137
93
|
const secondRootRef = { kind: 'second-root-ref' };
|
|
@@ -140,56 +96,17 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
140
96
|
.mockReturnValueOnce(firstRootRef)
|
|
141
97
|
.mockReturnValueOnce(secondRootRef);
|
|
142
98
|
|
|
143
|
-
const result =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
__OpBegin,
|
|
147
|
-
{ type: '_et_first_root' },
|
|
148
|
-
__OpEnd,
|
|
149
|
-
__OpBegin,
|
|
150
|
-
{ type: '_et_second_root' },
|
|
151
|
-
__OpEnd,
|
|
152
|
-
__OpPageEnd,
|
|
153
|
-
]);
|
|
99
|
+
const result = renderToElementTemplate(
|
|
100
|
+
h(__ElementTemplatePage, { attributes, $0: [h('_et_first_root', {}), h('_et_second_root', {})] }),
|
|
101
|
+
);
|
|
154
102
|
|
|
155
|
-
expect(result).
|
|
103
|
+
expect(result).toMatchObject({
|
|
156
104
|
pageAttributes: attributes,
|
|
157
105
|
rootRefs: [firstRootRef, secondRootRef],
|
|
158
106
|
rootSubtreeHandles: [[], []],
|
|
159
107
|
});
|
|
160
108
|
});
|
|
161
109
|
|
|
162
|
-
it.each([
|
|
163
|
-
[
|
|
164
|
-
__OpBegin,
|
|
165
|
-
{ type: '_et_before_page' },
|
|
166
|
-
__OpEnd,
|
|
167
|
-
__OpPageStart,
|
|
168
|
-
{ id: 'page' },
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
__OpPageStart,
|
|
172
|
-
{ id: 'page' },
|
|
173
|
-
__OpPageEnd,
|
|
174
|
-
__OpBegin,
|
|
175
|
-
{ type: '_et_after_page' },
|
|
176
|
-
__OpEnd,
|
|
177
|
-
],
|
|
178
|
-
[
|
|
179
|
-
__OpPageStart,
|
|
180
|
-
{ id: 'page' },
|
|
181
|
-
__OpPageEnd,
|
|
182
|
-
__OpText,
|
|
183
|
-
'outside page',
|
|
184
|
-
],
|
|
185
|
-
])('rejects a materialized root sibling outside page', (...opcodes) => {
|
|
186
|
-
createElementTemplate.mockReturnValue({ kind: 'root-ref' });
|
|
187
|
-
|
|
188
|
-
expect(() => renderOpcodesIntoElementTemplate(opcodes)).toThrow(
|
|
189
|
-
'must wrap all materialized roots',
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
110
|
it('creates exact list through typed native create with slot-0 refs as listChildren', () => {
|
|
194
111
|
const itemRef = { kind: 'item-ref' };
|
|
195
112
|
const listRef = { kind: 'list-ref' };
|
|
@@ -202,18 +119,9 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
202
119
|
createElementTemplate.mockReturnValueOnce(itemRef);
|
|
203
120
|
createTypedElementTemplate.mockReturnValueOnce(listRef);
|
|
204
121
|
|
|
205
|
-
const result =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
__OpAttr,
|
|
209
|
-
attributes,
|
|
210
|
-
__OpSlot,
|
|
211
|
-
0,
|
|
212
|
-
__OpBegin,
|
|
213
|
-
{ type: '_et_item', props: { __listItemPlatformInfo: { 'item-key': 'a' } } },
|
|
214
|
-
__OpEnd,
|
|
215
|
-
__OpEnd,
|
|
216
|
-
]);
|
|
122
|
+
const result = renderToElementTemplate(
|
|
123
|
+
h('list', { attributes, $0: h('_et_item', { __listItemPlatformInfo: { 'item-key': 'a' } }) }),
|
|
124
|
+
);
|
|
217
125
|
|
|
218
126
|
expect(result.rootRefs).toEqual([listRef]);
|
|
219
127
|
expect(result.rootSubtreeHandles).toEqual([[]]);
|
|
@@ -260,7 +168,7 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
260
168
|
expect(elementTemplateRegistry.get(-2)).toBe(listRef);
|
|
261
169
|
});
|
|
262
170
|
|
|
263
|
-
it('keeps compiled and typed attributes separate across nested
|
|
171
|
+
it('keeps compiled and typed attributes separate across nested hosts', () => {
|
|
264
172
|
const itemRef = { kind: 'item-ref' };
|
|
265
173
|
const listRef = { kind: 'list-ref' };
|
|
266
174
|
const parentRef = { kind: 'parent-ref' };
|
|
@@ -272,7 +180,7 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
272
180
|
createElementTemplate.mockReturnValueOnce(itemRef).mockReturnValueOnce(parentRef);
|
|
273
181
|
createTypedElementTemplate.mockReturnValueOnce(listRef);
|
|
274
182
|
|
|
275
|
-
const result =
|
|
183
|
+
const result = renderToElementTemplate(
|
|
276
184
|
h('_et_parent', {
|
|
277
185
|
attributeSlots: parentAttributes,
|
|
278
186
|
$0: h('list', {
|
|
@@ -283,8 +191,7 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
283
191
|
}),
|
|
284
192
|
}),
|
|
285
193
|
}),
|
|
286
|
-
|
|
287
|
-
));
|
|
194
|
+
);
|
|
288
195
|
|
|
289
196
|
expect(result.rootRefs).toEqual([parentRef]);
|
|
290
197
|
expect(createElementTemplate).toHaveBeenNthCalledWith(1, '_et_item', null, itemAttributes, null, -1);
|
|
@@ -316,16 +223,16 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
316
223
|
expect(addEvent).not.toHaveBeenCalled();
|
|
317
224
|
});
|
|
318
225
|
|
|
319
|
-
it('resets attribute payloads when
|
|
226
|
+
it('resets attribute payloads when siblings switch host types', () => {
|
|
320
227
|
createElementTemplate.mockImplementation(type => ({ type }));
|
|
321
228
|
createTypedElementTemplate.mockImplementation(type => ({ type }));
|
|
322
229
|
|
|
323
|
-
|
|
230
|
+
renderToElementTemplate([
|
|
324
231
|
h('_et_with_attrs', { attributeSlots: ['compiled'] }),
|
|
325
232
|
h('list', {}),
|
|
326
233
|
h('list', { attributes: { id: 'typed' } }),
|
|
327
234
|
h('_et_without_attrs', {}),
|
|
328
|
-
]
|
|
235
|
+
]);
|
|
329
236
|
|
|
330
237
|
expect(createElementTemplate).toHaveBeenNthCalledWith(1, '_et_with_attrs', null, ['compiled'], null, -1);
|
|
331
238
|
expect(createTypedElementTemplate).toHaveBeenNthCalledWith(
|
|
@@ -360,11 +267,7 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
360
267
|
const listRef = { kind: 'list-ref' };
|
|
361
268
|
createTypedElementTemplate.mockReturnValueOnce(listRef);
|
|
362
269
|
|
|
363
|
-
const result =
|
|
364
|
-
__OpBegin,
|
|
365
|
-
{ type: 'list' },
|
|
366
|
-
__OpEnd,
|
|
367
|
-
]);
|
|
270
|
+
const result = renderToElementTemplate(h('list', {}));
|
|
368
271
|
|
|
369
272
|
expect(result.rootRefs).toEqual([listRef]);
|
|
370
273
|
expect(result.rootSubtreeHandles).toEqual([[]]);
|
|
@@ -404,21 +307,15 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
404
307
|
.mockReturnValueOnce(itemBRef);
|
|
405
308
|
createTypedElementTemplate.mockReturnValueOnce(listRef);
|
|
406
309
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
__OpEnd,
|
|
417
|
-
__OpBegin,
|
|
418
|
-
{ type: '_et_item_b', props: { __listItemPlatformInfo: { 'item-key': 'b' } } },
|
|
419
|
-
__OpEnd,
|
|
420
|
-
__OpEnd,
|
|
421
|
-
]);
|
|
310
|
+
renderToElementTemplate(
|
|
311
|
+
h('list', {
|
|
312
|
+
attributes: {},
|
|
313
|
+
$0: [
|
|
314
|
+
h('_et_item_a', { __listItemPlatformInfo: { 'item-key': 'a' } }),
|
|
315
|
+
h('_et_item_b', { __listItemPlatformInfo: { 'item-key': 'b' } }),
|
|
316
|
+
],
|
|
317
|
+
}),
|
|
318
|
+
);
|
|
422
319
|
|
|
423
320
|
const attrs = createTypedElementTemplate.mock.calls[0]![1] as Record<string, (...args: unknown[]) => unknown>;
|
|
424
321
|
const componentAtIndex = attrs['component-at-index']!;
|
|
@@ -495,81 +392,6 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
495
392
|
]);
|
|
496
393
|
});
|
|
497
394
|
|
|
498
|
-
it('rejects non-list-item roots in typed list logical children', () => {
|
|
499
|
-
expect(() =>
|
|
500
|
-
renderOpcodesIntoElementTemplate([
|
|
501
|
-
__OpBegin,
|
|
502
|
-
{ type: 'list' },
|
|
503
|
-
__OpSlot,
|
|
504
|
-
0,
|
|
505
|
-
__OpBegin,
|
|
506
|
-
{ type: '_et_view', props: {} },
|
|
507
|
-
__OpEnd,
|
|
508
|
-
__OpEnd,
|
|
509
|
-
])
|
|
510
|
-
).toThrow('Element Template typed list received a non-list-item root in logical slot $0.');
|
|
511
|
-
expect(createElementTemplate).not.toHaveBeenCalled();
|
|
512
|
-
expect(createTypedElementTemplate).not.toHaveBeenCalled();
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
it('rejects text roots in typed list logical children', () => {
|
|
516
|
-
expect(() =>
|
|
517
|
-
renderOpcodesIntoElementTemplate([
|
|
518
|
-
__OpBegin,
|
|
519
|
-
{ type: 'list' },
|
|
520
|
-
__OpSlot,
|
|
521
|
-
0,
|
|
522
|
-
__OpText,
|
|
523
|
-
'row',
|
|
524
|
-
__OpEnd,
|
|
525
|
-
])
|
|
526
|
-
).toThrow('Element Template typed list received text logical child.');
|
|
527
|
-
expect(createElementTemplate).not.toHaveBeenCalled();
|
|
528
|
-
expect(createTypedElementTemplate).not.toHaveBeenCalled();
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
it('rejects non-zero typed list logical slot opcodes in development', () => {
|
|
532
|
-
expect(() =>
|
|
533
|
-
renderOpcodesIntoElementTemplate([
|
|
534
|
-
__OpBegin,
|
|
535
|
-
{ type: 'list' },
|
|
536
|
-
__OpSlot,
|
|
537
|
-
1,
|
|
538
|
-
__OpBegin,
|
|
539
|
-
{ type: '_et_item', props: { __listItemPlatformInfo: { 'item-key': 'a' } } },
|
|
540
|
-
__OpEnd,
|
|
541
|
-
__OpEnd,
|
|
542
|
-
])
|
|
543
|
-
).toThrow('Element Template typed list only supports logical slot $0.');
|
|
544
|
-
expect(createElementTemplate).not.toHaveBeenCalled();
|
|
545
|
-
expect(createTypedElementTemplate).not.toHaveBeenCalled();
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
it('rejects deferred list item markers instead of entering Snapshot deferred flow', () => {
|
|
549
|
-
expect(() =>
|
|
550
|
-
renderOpcodesIntoElementTemplate([
|
|
551
|
-
__OpBegin,
|
|
552
|
-
{ type: 'list' },
|
|
553
|
-
__OpSlot,
|
|
554
|
-
0,
|
|
555
|
-
__OpBegin,
|
|
556
|
-
{
|
|
557
|
-
type: '_et_item',
|
|
558
|
-
props: {
|
|
559
|
-
__listItemPlatformInfo: { 'item-key': 'late' },
|
|
560
|
-
isReady: 0,
|
|
561
|
-
},
|
|
562
|
-
},
|
|
563
|
-
__OpEnd,
|
|
564
|
-
__OpEnd,
|
|
565
|
-
])
|
|
566
|
-
).toThrow('Element Template typed list does not support deferred list items.');
|
|
567
|
-
expect(createElementTemplate).not.toHaveBeenCalled();
|
|
568
|
-
expect(createTypedElementTemplate).not.toHaveBeenCalled();
|
|
569
|
-
expect(flushElementTree).not.toHaveBeenCalled();
|
|
570
|
-
expect(onLifecycleEvent).not.toHaveBeenCalled();
|
|
571
|
-
});
|
|
572
|
-
|
|
573
395
|
it('prepares direct event slots before native create', () => {
|
|
574
396
|
const rootRef = { kind: 'root-ref' };
|
|
575
397
|
const handleTap = vi.fn();
|
|
@@ -581,13 +403,7 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
581
403
|
adaptEventAttrSlot,
|
|
582
404
|
];
|
|
583
405
|
|
|
584
|
-
const result =
|
|
585
|
-
__OpBegin,
|
|
586
|
-
{ type: '_et_event' },
|
|
587
|
-
__OpAttr,
|
|
588
|
-
[handleTap, 'title', 1],
|
|
589
|
-
__OpEnd,
|
|
590
|
-
]);
|
|
406
|
+
const result = renderToElementTemplate(h('_et_event', { attributeSlots: [handleTap, 'title', 1] }));
|
|
591
407
|
|
|
592
408
|
expect(result.rootRefs).toEqual([rootRef]);
|
|
593
409
|
expect(createElementTemplate).toHaveBeenCalledWith(
|
|
@@ -605,11 +421,7 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
605
421
|
createElementTemplate.mockReturnValue(rootRef);
|
|
606
422
|
__etAttrPlanMap._et_event = [0, adaptEventAttrSlot];
|
|
607
423
|
|
|
608
|
-
|
|
609
|
-
__OpBegin,
|
|
610
|
-
{ type: '_et_event' },
|
|
611
|
-
__OpEnd,
|
|
612
|
-
]);
|
|
424
|
+
renderToElementTemplate(h('_et_event', {}));
|
|
613
425
|
|
|
614
426
|
expect(createElementTemplate).toHaveBeenCalledWith(
|
|
615
427
|
'_et_event',
|
|
@@ -634,13 +446,7 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
634
446
|
adaptEventAttrSlot,
|
|
635
447
|
];
|
|
636
448
|
|
|
637
|
-
|
|
638
|
-
__OpBegin,
|
|
639
|
-
{ type: '_et_event' },
|
|
640
|
-
__OpAttr,
|
|
641
|
-
[null, undefined, false, true],
|
|
642
|
-
__OpEnd,
|
|
643
|
-
]);
|
|
449
|
+
renderToElementTemplate(h('_et_event', { attributeSlots: [null, undefined, false, true] }));
|
|
644
450
|
|
|
645
451
|
expect(createElementTemplate).toHaveBeenCalledWith(
|
|
646
452
|
'_et_event',
|
|
@@ -652,39 +458,13 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
652
458
|
expect(addEvent).not.toHaveBeenCalled();
|
|
653
459
|
});
|
|
654
460
|
|
|
655
|
-
it('prepares attr plan slots when the opcode omits attributeSlots', () => {
|
|
656
|
-
const rootRef = { kind: 'root-ref' };
|
|
657
|
-
createElementTemplate.mockReturnValue(rootRef);
|
|
658
|
-
__etAttrPlanMap._et_event = [0, adaptEventAttrSlot];
|
|
659
|
-
|
|
660
|
-
renderOpcodesIntoElementTemplate([
|
|
661
|
-
__OpBegin,
|
|
662
|
-
{ type: '_et_event' },
|
|
663
|
-
__OpEnd,
|
|
664
|
-
]);
|
|
665
|
-
|
|
666
|
-
expect(createElementTemplate).toHaveBeenCalledWith(
|
|
667
|
-
'_et_event',
|
|
668
|
-
null,
|
|
669
|
-
[null],
|
|
670
|
-
null,
|
|
671
|
-
-1,
|
|
672
|
-
);
|
|
673
|
-
});
|
|
674
|
-
|
|
675
461
|
it('prepares direct ref values before native create', () => {
|
|
676
462
|
const rootRef = { kind: 'root-ref' };
|
|
677
463
|
const ref = vi.fn();
|
|
678
464
|
createElementTemplate.mockReturnValue(rootRef);
|
|
679
465
|
__etAttrPlanMap._et_ref = [0, adaptRefAttrSlot];
|
|
680
466
|
|
|
681
|
-
|
|
682
|
-
__OpBegin,
|
|
683
|
-
{ type: '_et_ref' },
|
|
684
|
-
__OpAttr,
|
|
685
|
-
[ref],
|
|
686
|
-
__OpEnd,
|
|
687
|
-
]);
|
|
467
|
+
renderToElementTemplate(h('_et_ref', { attributeSlots: [ref] }));
|
|
688
468
|
|
|
689
469
|
expect(createElementTemplate).toHaveBeenCalledWith(
|
|
690
470
|
'_et_ref',
|
|
@@ -702,20 +482,18 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
702
482
|
createElementTemplate.mockReturnValue(rootRef);
|
|
703
483
|
__etAttrPlanMap._et_spread = [0, adaptSpreadAttrSlot];
|
|
704
484
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
__OpEnd,
|
|
718
|
-
]);
|
|
485
|
+
renderToElementTemplate(
|
|
486
|
+
h('_et_spread', {
|
|
487
|
+
attributeSlots: [{
|
|
488
|
+
id: 'cta',
|
|
489
|
+
className: 'primary',
|
|
490
|
+
__self: 'debug-self',
|
|
491
|
+
__source: { fileName: 'app.tsx' },
|
|
492
|
+
bindtap: handleTap,
|
|
493
|
+
catchtouchstart: false,
|
|
494
|
+
}],
|
|
495
|
+
}),
|
|
496
|
+
);
|
|
719
497
|
|
|
720
498
|
expect(createElementTemplate).toHaveBeenCalledWith(
|
|
721
499
|
'_et_spread',
|
|
@@ -733,18 +511,9 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
733
511
|
createElementTemplate.mockReturnValue(rootRef);
|
|
734
512
|
__etAttrPlanMap._et_spread = [0, adaptSpreadAttrSlot];
|
|
735
513
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
__OpAttr,
|
|
740
|
-
[{
|
|
741
|
-
id: 'cta',
|
|
742
|
-
ref,
|
|
743
|
-
'main-thread:ref': vi.fn(),
|
|
744
|
-
'worklet:ref': vi.fn(),
|
|
745
|
-
}],
|
|
746
|
-
__OpEnd,
|
|
747
|
-
]);
|
|
514
|
+
renderToElementTemplate(
|
|
515
|
+
h('_et_spread', { attributeSlots: [{ id: 'cta', ref, 'main-thread:ref': vi.fn(), 'worklet:ref': vi.fn() }] }),
|
|
516
|
+
);
|
|
748
517
|
|
|
749
518
|
expect(createElementTemplate).toHaveBeenCalledWith(
|
|
750
519
|
'_et_spread',
|
|
@@ -755,37 +524,4 @@ describe('renderOpcodesIntoElementTemplate', () => {
|
|
|
755
524
|
);
|
|
756
525
|
expect(ref).not.toHaveBeenCalled();
|
|
757
526
|
});
|
|
758
|
-
|
|
759
|
-
it('throws when text is emitted outside of a child slot', () => {
|
|
760
|
-
expect(() =>
|
|
761
|
-
renderOpcodesIntoElementTemplate([
|
|
762
|
-
__OpBegin,
|
|
763
|
-
{ type: '_et_parent' },
|
|
764
|
-
__OpText,
|
|
765
|
-
'hello',
|
|
766
|
-
__OpEnd,
|
|
767
|
-
])
|
|
768
|
-
).toThrow('Template \'_et_parent\' received a text child outside of any child slot.');
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
it('throws when an element child is emitted outside of a child slot', () => {
|
|
772
|
-
expect(() =>
|
|
773
|
-
renderOpcodesIntoElementTemplate([
|
|
774
|
-
__OpBegin,
|
|
775
|
-
{ type: '_et_parent' },
|
|
776
|
-
__OpBegin,
|
|
777
|
-
{ type: '_et_child' },
|
|
778
|
-
__OpSlot,
|
|
779
|
-
0,
|
|
780
|
-
__OpEnd,
|
|
781
|
-
__OpEnd,
|
|
782
|
-
])
|
|
783
|
-
).toThrow('Template \'_et_parent\' received a child outside of any child slot.');
|
|
784
|
-
});
|
|
785
|
-
|
|
786
|
-
it('throws on unknown opcodes', () => {
|
|
787
|
-
expect(() => renderOpcodesIntoElementTemplate([999])).toThrow(
|
|
788
|
-
'Unknown opcode: 999',
|
|
789
|
-
);
|
|
790
|
-
});
|
|
791
527
|
});
|