@lynx-js/react 0.126.1 → 0.126.2
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 +22 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/refresh/.turbo/turbo-build.log +3 -3
- package/refresh/dist/index.js +1 -2
- package/refresh/package.json +1 -1
- 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/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/suspense-lazy.test.ts +52 -7
- 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/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/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/lazy.test.js +44 -9
- package/runtime/__test__/snapshot/lifecycle/reloadGc.test.jsx +66 -0
- package/runtime/__test__/snapshot/lynx/runtime-version.test.ts +140 -0
- package/runtime/__test__/snapshot/spread.test.jsx +22 -15
- package/runtime/__test__/snapshot/ssr.legacy-slot.test.jsx +168 -0
- package/runtime/__test__/snapshot/ssr.list.test.jsx +211 -0
- package/runtime/__test__/worklet-runtime/hydrate.test.js +92 -0
- package/runtime/__test__/worklet-runtime/runOnBackground.test.js +8 -6
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +3 -2
- package/runtime/lazy/element-template-import.js +0 -4
- package/runtime/lazy/element-template-internal.js +18 -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 +1 -3
- package/runtime/lazy/import.js +0 -4
- package/runtime/lazy/internal.js +15 -1
- package/runtime/lazy/target.js +0 -21
- package/runtime/lib/core/hooks/react.d.ts +2 -0
- package/runtime/lib/core/hooks/react.js +2 -0
- package/runtime/lib/core/hooks/react.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/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 +1 -1
- package/runtime/lib/element-template/index.js +1 -1
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +4 -1
- package/runtime/lib/element-template/internal.js +6 -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/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.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 +3 -1
- package/runtime/lib/internal.js +5 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +15 -6
- package/runtime/lib/lynx-api.js +13 -4
- package/runtime/lib/lynx-api.js.map +1 -1
- 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/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/element.d.ts +2 -0
- package/runtime/lib/snapshot/lynx/element.js +2 -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/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +5 -14
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/src/core/hooks/react.ts +2 -0
- package/runtime/src/core/lynx/runtime-version.ts +62 -0
- 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 +1 -1
- package/runtime/src/element-template/internal.ts +12 -1
- package/runtime/src/element-template/native/index.ts +4 -0
- 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 +10 -1
- package/runtime/src/lynx-api.ts +15 -6
- 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/reload.ts +4 -0
- package/runtime/src/snapshot/lynx/calledByNative.ts +4 -0
- package/runtime/src/snapshot/lynx/element.ts +2 -0
- package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +2 -1
- package/runtime/src/worklet-runtime/bindings/types.ts +1 -1
- package/runtime/src/worklet-runtime/hydrate.ts +1 -1
- package/runtime/src/worklet-runtime/workletRuntime.ts +5 -14
- package/runtime/types/types.d.ts +2 -0
- package/runtime/worklet-runtime/dev.js +4 -16
- 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 +2 -2
- 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/node_modules/.bin/rsbuild +19 -6
- package/testing-library/node_modules/.bin/rspeedy +17 -4
- package/testing-library/node_modules/.bin/rstest +19 -6
- package/testing-library/package.json +2 -2
- package/testing-library/src/__tests__/reload/reloadGc.test.jsx +64 -0
- package/testing-library/src/__tests__/reload/reloadTemplate.js +39 -0
- package/testing-library/types/entry.d.ts +2 -2
- package/transform/.turbo/turbo-build$colon$wasm.log +68 -56
- package/transform/__test__/fixture.spec.js +17 -20
- 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_plugins_shared/jsx_helpers.rs +8 -4
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +7 -6
- package/transform/node_modules/.bin/esbuild +17 -4
- package/transform/node_modules/.bin/napi +17 -4
- 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 +310 -114
- 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 +10 -208
- 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/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/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 → runtime-marker.d.ts} +0 -0
- /package/runtime/lib/{runtime-backend-marker.d.ts → runtime-marker.d.ts} +0 -0
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* Implements the IFR (Instant First-Frame Rendering) on main thread.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import { render as renderToString } from './render-to-opcodes.js';
|
|
9
|
+
import { renderToElementTemplate } from './render-direct.js';
|
|
11
10
|
import { getReloadVersion } from '../../../core/reload-version.js';
|
|
12
11
|
import { profileEnd, profileStart } from '../../debug/profile.js';
|
|
13
12
|
import { ElementTemplateLifecycleConstant } from '../../protocol/lifecycle-constant.js';
|
|
@@ -21,20 +20,22 @@ import { getElementTemplateNativeRef } from '../template/registry.js';
|
|
|
21
20
|
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';
|
|
22
21
|
|
|
23
22
|
function renderMainThread(): void {
|
|
24
|
-
let
|
|
23
|
+
let rendered;
|
|
25
24
|
profileStart('ReactLynx::renderMainThread');
|
|
26
25
|
try {
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
rendered = renderToElementTemplate(__root.__jsx, undefined);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
// Like Snapshot, any failure during synchronous rendering is reported at
|
|
29
|
+
// the lifecycle boundary before committing an empty result.
|
|
30
|
+
lynx.reportError(error as Error);
|
|
31
|
+
rendered = { pageAttributes: null, rootRefs: [], rootSubtreeHandles: [] };
|
|
31
32
|
} finally {
|
|
32
33
|
profileEnd();
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
profileStart('ReactLynx::
|
|
36
|
+
profileStart('ReactLynx::commitElementTemplate');
|
|
36
37
|
try {
|
|
37
|
-
const { pageAttributes, rootRefs, rootSubtreeHandles } =
|
|
38
|
+
const { pageAttributes, rootRefs, rootSubtreeHandles } = rendered;
|
|
38
39
|
__SetAttributeOfElementTemplate(__page, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, pageAttributes);
|
|
39
40
|
for (let index = 0; index < rootRefs.length; index += 1) {
|
|
40
41
|
const rootRef = rootRefs[index]!;
|
|
@@ -22,6 +22,10 @@ import type {
|
|
|
22
22
|
// Main-thread IFR allocates ids as consecutive negative integers.
|
|
23
23
|
let nextId = -1;
|
|
24
24
|
|
|
25
|
+
export function getNextElementTemplateId(): number {
|
|
26
|
+
return nextId;
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
export function reserveElementTemplateId(): number {
|
|
26
30
|
const id = nextId--;
|
|
27
31
|
return id;
|
|
@@ -33,9 +37,13 @@ export function createElementTemplateWithReservedHandle(
|
|
|
33
37
|
bundleUrl: string | null | undefined,
|
|
34
38
|
attributeSlots: SerializableValue[] | null | undefined,
|
|
35
39
|
childSlots: RuntimeChildSlots | null | undefined,
|
|
40
|
+
hasDynamicAttributes = true,
|
|
36
41
|
): ElementTemplateHandle {
|
|
37
|
-
|
|
38
|
-
const
|
|
42
|
+
// Adapter-free compiled hosts need neither dynamic state nor native slot preparation.
|
|
43
|
+
const templateType = hasDynamicAttributes ? elementTemplateTypeTag(templateKey, bundleUrl) : undefined;
|
|
44
|
+
const nativeAttributeSlots = templateType === undefined
|
|
45
|
+
? attributeSlots
|
|
46
|
+
: prepareMainThreadDynamicAttrSlotsForNative(templateType, attributeSlots);
|
|
39
47
|
const nativeRef = __CreateElementTemplate(
|
|
40
48
|
templateKey,
|
|
41
49
|
bundleUrl,
|
|
@@ -45,11 +53,13 @@ export function createElementTemplateWithReservedHandle(
|
|
|
45
53
|
);
|
|
46
54
|
if (nativeRef) {
|
|
47
55
|
setElementTemplateNativeRef(handleId, nativeRef);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
if (templateType !== undefined) {
|
|
57
|
+
initializeMainThreadDynamicAttrSlots(
|
|
58
|
+
handleId,
|
|
59
|
+
templateType,
|
|
60
|
+
attributeSlots,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
53
63
|
}
|
|
54
64
|
return nativeRef;
|
|
55
65
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
|
|
5
|
+
// Side-effect entry that registers this bundle's runtime markers (backend,
|
|
6
|
+
// version, ...) on load. Imported once by the element-template runtime entry
|
|
7
|
+
// so later-loaded lazy bundles register their own markers too.
|
|
8
|
+
|
|
9
|
+
import { RUNTIME_BACKEND_ELEMENT_TEMPLATE, registerRuntimeBackend } from '../core/lynx/runtime-backend.js';
|
|
10
|
+
import { registerRuntimeVersion } from '../core/lynx/runtime-version.js';
|
|
11
|
+
|
|
12
|
+
registerRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
13
|
+
// An older `react-webpack-plugin` may not stamp `__RUNTIME_VERSION__`. Guard
|
|
14
|
+
// with `typeof` so referencing it does not throw when the define is missing.
|
|
15
|
+
registerRuntimeVersion(
|
|
16
|
+
typeof __RUNTIME_VERSION__ === 'undefined' ? undefined : __RUNTIME_VERSION__,
|
|
17
|
+
);
|
package/runtime/src/index.ts
CHANGED
package/runtime/src/internal.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Suspense, createElement, lazy, cloneElement as preactCloneElement } from 'preact/compat';
|
|
6
6
|
import type { FC } from 'react';
|
|
7
7
|
|
|
8
|
-
import './runtime-
|
|
8
|
+
import './runtime-marker.js';
|
|
9
9
|
import './lynx.js';
|
|
10
10
|
|
|
11
11
|
import { useMemo } from './core/hooks/react.js';
|
|
@@ -73,6 +73,15 @@ export type { Options } from 'preact';
|
|
|
73
73
|
|
|
74
74
|
export { loadDynamicJS, __dynamicImport } from './core/lynx/dynamic-import.js';
|
|
75
75
|
|
|
76
|
+
// Re-exported so lazy bundle shells can reach the host runtime APIs
|
|
77
|
+
// via `target[sExportsReactInternal]`.
|
|
78
|
+
export { registerRuntimeVersion, getRuntimeVersion } from './core/lynx/runtime-version.js';
|
|
79
|
+
export {
|
|
80
|
+
RUNTIME_BACKEND_ELEMENT_TEMPLATE,
|
|
81
|
+
RUNTIME_BACKEND_SNAPSHOT,
|
|
82
|
+
registerRuntimeBackend,
|
|
83
|
+
} from './core/lynx/runtime-backend.js';
|
|
84
|
+
|
|
76
85
|
export { withInitDataInState } from './core/initData.js';
|
|
77
86
|
|
|
78
87
|
export { wrapWithLynxComponent } from './core/compat/lynxComponent.js';
|
package/runtime/src/lynx-api.ts
CHANGED
|
@@ -207,6 +207,7 @@ export const InitDataConsumer: Consumer<InitData> = /* @__PURE__ */ _InitData.Co
|
|
|
207
207
|
* }
|
|
208
208
|
* ```
|
|
209
209
|
*
|
|
210
|
+
* @function
|
|
210
211
|
* @public
|
|
211
212
|
*/
|
|
212
213
|
export const useInitData: () => InitData = /* @__PURE__ */ _InitData.use();
|
|
@@ -221,6 +222,7 @@ export const useInitData: () => InitData = /* @__PURE__ */ _InitData.use();
|
|
|
221
222
|
* })
|
|
222
223
|
* }
|
|
223
224
|
* ```
|
|
225
|
+
* @function
|
|
224
226
|
* @public
|
|
225
227
|
*/
|
|
226
228
|
export const useInitDataChanged: (callback: (data: InitData) => void) => void = /* @__PURE__ */ _InitData.useChanged();
|
|
@@ -235,12 +237,15 @@ const _GlobalProps = /* @__PURE__ */ createGlobalProps<GlobalProps>({
|
|
|
235
237
|
});
|
|
236
238
|
|
|
237
239
|
/**
|
|
238
|
-
* The {@link https://react.dev/reference/react/createContext#provider | Provider} Component that provide `lynx.__globalProps
|
|
239
|
-
*
|
|
240
|
+
* The {@link https://react.dev/reference/react/createContext#provider | Provider} Component that provide `lynx.__globalProps`.
|
|
241
|
+
* Only needed with `globalPropsMode: 'event'`; in the default `'reactive'` mode it renders its children directly
|
|
242
|
+
* and updates come from a full re-render.
|
|
240
243
|
* @group Components
|
|
241
244
|
*
|
|
242
245
|
* @example
|
|
243
246
|
*
|
|
247
|
+
* With `globalPropsMode: 'event'`:
|
|
248
|
+
*
|
|
244
249
|
* ```ts
|
|
245
250
|
* import { root } from "@lynx-js/react"
|
|
246
251
|
*
|
|
@@ -265,7 +270,8 @@ export const GlobalPropsProvider: FC<{ children?: ReactNode | undefined }> = /*
|
|
|
265
270
|
|
|
266
271
|
/**
|
|
267
272
|
* The {@link https://react.dev/reference/react/createContext#consumer | Consumer} Component that provide `lynx.__globalProps`.
|
|
268
|
-
*
|
|
273
|
+
* Only needed with `globalPropsMode: 'event'`, together with {@link GlobalPropsProvider}; in the default `'reactive'` mode
|
|
274
|
+
* it calls `children` with `lynx.__globalProps` directly and updates come from a full re-render.
|
|
269
275
|
* @group Components
|
|
270
276
|
* @public
|
|
271
277
|
*/
|
|
@@ -274,7 +280,8 @@ export const GlobalPropsConsumer: Consumer<GlobalProps> = /* @__PURE__ */ _Globa
|
|
|
274
280
|
|
|
275
281
|
/**
|
|
276
282
|
* A React Hooks for you to get `lynx.__globalProps`.
|
|
277
|
-
*
|
|
283
|
+
* With `globalPropsMode: 'event'`, the component re-renders when `lynx.__globalProps` changes;
|
|
284
|
+
* in the default `'reactive'` mode, updates arrive through a full re-render.
|
|
278
285
|
*
|
|
279
286
|
* @example
|
|
280
287
|
*
|
|
@@ -286,6 +293,7 @@ export const GlobalPropsConsumer: Consumer<GlobalProps> = /* @__PURE__ */ _Globa
|
|
|
286
293
|
* }
|
|
287
294
|
* ```
|
|
288
295
|
*
|
|
296
|
+
* @function
|
|
289
297
|
* @public
|
|
290
298
|
*/
|
|
291
299
|
export const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.use();
|
|
@@ -302,6 +310,7 @@ export const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.us
|
|
|
302
310
|
* })
|
|
303
311
|
* }
|
|
304
312
|
* ```
|
|
313
|
+
* @function
|
|
305
314
|
* @public
|
|
306
315
|
*/
|
|
307
316
|
export const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void = /* @__PURE__ */ _GlobalProps
|
|
@@ -523,7 +532,7 @@ export interface Lynx {
|
|
|
523
532
|
* they can achieve it by extends interface `InitDataRaw` and `InitData`.
|
|
524
533
|
*
|
|
525
534
|
* ```ts
|
|
526
|
-
* import {
|
|
535
|
+
* import { useInitData } from "@lynx-js/react"
|
|
527
536
|
*
|
|
528
537
|
* interface AnotherExistingInterface {
|
|
529
538
|
* someAnotherPropertyFromExistingInterface: number
|
|
@@ -535,7 +544,7 @@ export interface Lynx {
|
|
|
535
544
|
* }
|
|
536
545
|
* }
|
|
537
546
|
*
|
|
538
|
-
*
|
|
547
|
+
* lynx.registerDataProcessors({
|
|
539
548
|
* defaultDataProcessor: () => {
|
|
540
549
|
* return {
|
|
541
550
|
* someCustomProperty: 'value', // will be typed
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
|
|
5
|
+
// Side-effect entry that registers this bundle's runtime markers (backend,
|
|
6
|
+
// version, ...) on load. Imported once by the runtime entry so later-loaded
|
|
7
|
+
// lazy bundles register their own markers too.
|
|
8
|
+
|
|
9
|
+
import { RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend } from './core/lynx/runtime-backend.js';
|
|
10
|
+
import { registerRuntimeVersion } from './core/lynx/runtime-version.js';
|
|
11
|
+
|
|
12
|
+
registerRuntimeBackend(RUNTIME_BACKEND_SNAPSHOT);
|
|
13
|
+
// An older `react-webpack-plugin` may not stamp `__RUNTIME_VERSION__`. Guard
|
|
14
|
+
// with `typeof` so referencing it does not throw when the define is missing.
|
|
15
|
+
registerRuntimeVersion(
|
|
16
|
+
typeof __RUNTIME_VERSION__ === 'undefined' ? undefined : __RUNTIME_VERSION__,
|
|
17
|
+
);
|
|
@@ -154,7 +154,11 @@ export function setupComponentStack(): void {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
options.vnode = (vnode: PatchedVNode) => {
|
|
157
|
-
|
|
157
|
+
// Scheduled component updates clone the vnode before entering its render scope.
|
|
158
|
+
// Preserve the original owner when Preact invokes this hook for that clone.
|
|
159
|
+
if (vnode._owner === undefined) {
|
|
160
|
+
vnode._owner = ownerStack.length > 0 ? ownerStack[ownerStack.length - 1]! : null;
|
|
161
|
+
}
|
|
158
162
|
if (oldVNode) oldVNode(vnode);
|
|
159
163
|
};
|
|
160
164
|
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
VALUE,
|
|
23
23
|
VNODE,
|
|
24
24
|
} from '../../shared/render-constants.js';
|
|
25
|
-
import { getDisplayName
|
|
25
|
+
import { getDisplayName } from '../../utils.js';
|
|
26
26
|
import { globalPatchOptions } from '../lifecycle/patch/commit.js';
|
|
27
27
|
import { __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';
|
|
28
28
|
|
|
@@ -103,33 +103,35 @@ export function initProfileHook(): void {
|
|
|
103
103
|
type PatchedComponent = Component & { [sFlowID]?: number };
|
|
104
104
|
|
|
105
105
|
if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
old?.call(this, state, callback);
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
107
|
+
const oldSetState = Component.prototype.setState;
|
|
108
|
+
Component.prototype.setState = function(this: PatchedComponent & { [NEXT_STATE]: unknown }, state, callback) {
|
|
109
|
+
oldSetState?.call(this, state, callback);
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
if (this[BITS] & COMPONENT_DIRTY) {
|
|
112
|
+
const type = this[VNODE]!.type;
|
|
113
|
+
const isClassComponent = typeof type === 'function' && ('prototype' in type)
|
|
114
|
+
&& ('render' in type.prototype);
|
|
116
115
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
116
|
+
if (isClassComponent) {
|
|
117
|
+
profileMark('ReactLynx::setState', {
|
|
118
|
+
flowId: this[sFlowID] ??= profileFlowId(),
|
|
119
|
+
args: buildSetStateProfileMarkArgs(
|
|
120
|
+
type,
|
|
121
|
+
this.state,
|
|
122
|
+
this[NEXT_STATE],
|
|
123
|
+
),
|
|
124
|
+
});
|
|
127
125
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
126
|
+
}
|
|
127
|
+
};
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
|
|
130
|
+
// These hot callbacks have fixed signatures; avoid collecting and spreading
|
|
131
|
+
// an argument array for every host and component visited.
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
133
|
+
const oldDiff2 = options[DIFF2];
|
|
134
|
+
options[DIFF2] = (vnode, oldVNode) => {
|
|
133
135
|
// We only add profiling trace for Component
|
|
134
136
|
if (typeof vnode.type === 'function') {
|
|
135
137
|
const profileOptions: TraceOption = {};
|
|
@@ -152,10 +154,12 @@ export function initProfileHook(): void {
|
|
|
152
154
|
profileOptions,
|
|
153
155
|
);
|
|
154
156
|
}
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
+
oldDiff2?.(vnode, oldVNode);
|
|
158
|
+
};
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
161
|
+
const oldDiffed = options[DIFFED];
|
|
162
|
+
options[DIFFED] = vnode => {
|
|
159
163
|
if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
|
|
160
164
|
const hooks = vnode[COMPONENT]?.[HOOKS];
|
|
161
165
|
const hookList = hooks?.[LIST];
|
|
@@ -205,11 +209,13 @@ export function initProfileHook(): void {
|
|
|
205
209
|
if (typeof vnode.type === 'function') {
|
|
206
210
|
profileEnd(); // for options[DIFF2]
|
|
207
211
|
}
|
|
208
|
-
|
|
209
|
-
}
|
|
212
|
+
oldDiffed?.(vnode);
|
|
213
|
+
};
|
|
210
214
|
|
|
211
215
|
if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
|
|
212
|
-
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
217
|
+
const oldCommit = options[COMMIT];
|
|
218
|
+
options[COMMIT] = (vnode, commitQueue) => {
|
|
213
219
|
profileStart('ReactLynx::commit', {
|
|
214
220
|
...globalPatchOptions.flowIds
|
|
215
221
|
? {
|
|
@@ -218,14 +224,16 @@ export function initProfileHook(): void {
|
|
|
218
224
|
}
|
|
219
225
|
: {},
|
|
220
226
|
});
|
|
221
|
-
|
|
227
|
+
oldCommit?.(vnode, commitQueue);
|
|
222
228
|
profileEnd();
|
|
223
|
-
}
|
|
229
|
+
};
|
|
224
230
|
}
|
|
225
231
|
}
|
|
226
232
|
|
|
227
233
|
// Profile the user-provided `render`.
|
|
228
|
-
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
235
|
+
const oldRender = options[RENDER];
|
|
236
|
+
options[RENDER] = (vnode: VNode) => {
|
|
229
237
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
230
238
|
const originalRender = vnode[COMPONENT]!.render;
|
|
231
239
|
vnode[COMPONENT]!.render = function render(this, props, state, context) {
|
|
@@ -237,22 +245,26 @@ export function initProfileHook(): void {
|
|
|
237
245
|
vnode[COMPONENT]!.render = originalRender;
|
|
238
246
|
}
|
|
239
247
|
};
|
|
240
|
-
|
|
241
|
-
}
|
|
248
|
+
oldRender?.(vnode);
|
|
249
|
+
};
|
|
242
250
|
|
|
243
251
|
if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
|
|
244
252
|
const sPatchLength = Symbol('PATCH_LENGTH');
|
|
245
253
|
|
|
246
254
|
type PatchedVNode = VNode & { [sPatchLength]?: number };
|
|
247
255
|
|
|
248
|
-
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
257
|
+
const oldDiff = options[DIFF];
|
|
258
|
+
options[DIFF] = (vnode: PatchedVNode) => {
|
|
249
259
|
if (typeof vnode.type === 'function' && __globalSnapshotPatch) {
|
|
250
260
|
vnode[sPatchLength] = __globalSnapshotPatch.length;
|
|
251
261
|
}
|
|
252
|
-
|
|
253
|
-
}
|
|
262
|
+
oldDiff?.(vnode);
|
|
263
|
+
};
|
|
254
264
|
|
|
255
|
-
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
266
|
+
const oldPatchDiffed = options[DIFFED];
|
|
267
|
+
options[DIFFED] = (vnode: PatchedVNode) => {
|
|
256
268
|
if (typeof vnode.type === 'function') {
|
|
257
269
|
const patchLength = vnode[sPatchLength];
|
|
258
270
|
delete vnode[sPatchLength];
|
|
@@ -265,7 +277,7 @@ export function initProfileHook(): void {
|
|
|
265
277
|
});
|
|
266
278
|
}
|
|
267
279
|
}
|
|
268
|
-
|
|
269
|
-
}
|
|
280
|
+
oldPatchDiffed?.(vnode);
|
|
281
|
+
};
|
|
270
282
|
}
|
|
271
283
|
}
|
|
@@ -52,6 +52,10 @@ function reloadMainThread(data: unknown, options: UpdatePageOption): void {
|
|
|
52
52
|
__pendingListUpdates.flush();
|
|
53
53
|
applyRefQueue();
|
|
54
54
|
|
|
55
|
+
if (typeof lepusng_gc === 'function') {
|
|
56
|
+
lepusng_gc();
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
if (isFirstScreenSynced) {
|
|
56
60
|
__OnLifecycleEvent([
|
|
57
61
|
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
@@ -161,6 +161,10 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
161
161
|
|
|
162
162
|
flushOptions.triggerDataUpdated = true;
|
|
163
163
|
markTiming('updateDiffVdomEnd');
|
|
164
|
+
|
|
165
|
+
if (typeof lepusng_gc === 'function') {
|
|
166
|
+
lepusng_gc();
|
|
167
|
+
}
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
__FlushElementTree(__page, flushOptions);
|
|
@@ -107,6 +107,7 @@ function pickChildrenProps(
|
|
|
107
107
|
/**
|
|
108
108
|
* Creates a ReactLynx element using the snapshot runtime.
|
|
109
109
|
*
|
|
110
|
+
* @function
|
|
110
111
|
* @public
|
|
111
112
|
*/
|
|
112
113
|
export const createElement =
|
|
@@ -143,6 +144,7 @@ export const createElement =
|
|
|
143
144
|
/**
|
|
144
145
|
* Clones a ReactLynx element using the snapshot runtime.
|
|
145
146
|
*
|
|
147
|
+
* @function
|
|
146
148
|
* @public
|
|
147
149
|
*/
|
|
148
150
|
export const cloneElement =
|
|
@@ -47,7 +47,8 @@ export function ssrHydrateByOpcodes(
|
|
|
47
47
|
delete top.__pendingElements;
|
|
48
48
|
|
|
49
49
|
if (top.__snapshot_def.isListHolder) {
|
|
50
|
-
const
|
|
50
|
+
const [, elementIndex] = top.__snapshot_def.slot[0]!;
|
|
51
|
+
const listElement = top.__elements[elementIndex]!;
|
|
51
52
|
const listElementUniqueID = __GetElementUniqueID(listElement);
|
|
52
53
|
const signMap = gSignMap[listElementUniqueID] = new Map();
|
|
53
54
|
gRecycleMap[listElementUniqueID] = new Map();
|
|
@@ -52,7 +52,7 @@ function hydrateCtxImpl(
|
|
|
52
52
|
);
|
|
53
53
|
} else {
|
|
54
54
|
const firstScreenValue = typeof firstScreenCtxObj[key] === 'function'
|
|
55
|
-
? (firstScreenCtxObj[key] as {
|
|
55
|
+
? (firstScreenCtxObj[key] as { boundCtx?: object }).boundCtx as ClosureValueType
|
|
56
56
|
: firstScreenCtxObj[key];
|
|
57
57
|
hydrateCtxImpl(ctxObj[key], firstScreenValue, execId);
|
|
58
58
|
}
|
|
@@ -180,15 +180,14 @@ const transformWorkletInner = (
|
|
|
180
180
|
if (isWorklet) {
|
|
181
181
|
const isRootWorklet = subObj === ctx;
|
|
182
182
|
const boundCtx = { ...subObj };
|
|
183
|
-
//
|
|
184
|
-
//
|
|
183
|
+
// Keep the original context collectible. PrimJS traces WeakMap values even
|
|
184
|
+
// when their keys are otherwise unreachable, so the cached function must not point back to its key.
|
|
185
185
|
obj[key] = lynxWorkletImpl._workletMap[(subObj as Worklet)._wkltId]!
|
|
186
186
|
.bind(boundCtx);
|
|
187
187
|
if (!isRootWorklet) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
188
|
+
// Hydration needs the same context that the function already owns through bind().
|
|
189
|
+
// The original nested context can disappear after its parent replaces it with this function.
|
|
190
|
+
obj[key].boundCtx = boundCtx;
|
|
192
191
|
}
|
|
193
192
|
continue;
|
|
194
193
|
}
|
|
@@ -204,12 +203,4 @@ const transformWorkletInner = (
|
|
|
204
203
|
}
|
|
205
204
|
};
|
|
206
205
|
|
|
207
|
-
function createWeakCtxRef(ctx: object): WeakRef<object> | undefined {
|
|
208
|
-
try {
|
|
209
|
-
return new WeakRef(ctx);
|
|
210
|
-
} catch {
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
206
|
export { initWorklet };
|
package/runtime/types/types.d.ts
CHANGED
|
@@ -27,12 +27,14 @@ declare global {
|
|
|
27
27
|
declare const __BACKGROUND__: boolean;
|
|
28
28
|
declare const __MAIN_THREAD__: boolean;
|
|
29
29
|
declare const __PROFILE__: boolean;
|
|
30
|
+
declare const lepusng_gc: (() => void) | undefined;
|
|
30
31
|
declare const __REACT_DEVTOOL__: boolean | undefined;
|
|
31
32
|
declare const __ALOG__: boolean | undefined;
|
|
32
33
|
declare const __ALOG_ELEMENT_API__: boolean | undefined;
|
|
33
34
|
declare const __ENABLE_SSR__: boolean;
|
|
34
35
|
declare const __GLOBAL_PROPS_MODE__: 'reactive' | 'event' | undefined;
|
|
35
36
|
declare const __LAZY_BUNDLE_FETCHER__: 'FetchBundle' | 'QueryComponent';
|
|
37
|
+
declare const __RUNTIME_VERSION__: string | undefined;
|
|
36
38
|
declare function __CreatePage(componentId: string, cssId: number): FiberElement;
|
|
37
39
|
declare function __CreateElement(
|
|
38
40
|
tag: string,
|