@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
|
@@ -17,7 +17,7 @@ afterEach(() => {
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
describe('runOnBackground', () => {
|
|
20
|
-
it('should
|
|
20
|
+
it('should expose the bound copy without retaining the original nested context', () => {
|
|
21
21
|
const childCtx = {
|
|
22
22
|
_wkltId: 'child',
|
|
23
23
|
};
|
|
@@ -29,15 +29,17 @@ describe('runOnBackground', () => {
|
|
|
29
29
|
globalThis.registerWorklet('main-thread', 'parent', function() {
|
|
30
30
|
return this.child;
|
|
31
31
|
});
|
|
32
|
-
globalThis.registerWorklet('main-thread', 'child', function() {
|
|
32
|
+
globalThis.registerWorklet('main-thread', 'child', function() {
|
|
33
|
+
return this;
|
|
34
|
+
});
|
|
33
35
|
|
|
34
36
|
const childWorklet = globalThis.runWorklet(parentCtx, []);
|
|
35
|
-
expect(childWorklet).
|
|
37
|
+
expect(childWorklet.boundCtx).toBe(childWorklet());
|
|
38
|
+
expect(childWorklet.boundCtx).not.toBe(childCtx);
|
|
36
39
|
expect(childWorklet).not.toHaveProperty('ctx');
|
|
37
|
-
expect(childWorklet.ctxRef.deref()).toBe(childCtx);
|
|
38
40
|
});
|
|
39
41
|
|
|
40
|
-
it('should hydrate nested worklet ctx from
|
|
42
|
+
it('should hydrate nested worklet ctx from its bound context', () => {
|
|
41
43
|
const firstScreenChildCtx = {
|
|
42
44
|
_wkltId: 'child',
|
|
43
45
|
_jsFn: {
|
|
@@ -47,7 +49,7 @@ describe('runOnBackground', () => {
|
|
|
47
49
|
const firstScreenWorklet = {
|
|
48
50
|
_wkltId: 'parent',
|
|
49
51
|
child: Object.assign(function() {}, {
|
|
50
|
-
|
|
52
|
+
boundCtx: firstScreenChildCtx,
|
|
51
53
|
}),
|
|
52
54
|
};
|
|
53
55
|
const worklet = {
|
|
@@ -171,7 +171,7 @@ describe('Worklet', () => {
|
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
-
it('
|
|
174
|
+
it('supports nested worklet contexts that cannot be weakly referenced', () => {
|
|
175
175
|
initWorklet();
|
|
176
176
|
|
|
177
177
|
const NativeWeakRef = globalThis.WeakRef;
|
|
@@ -201,7 +201,8 @@ describe('Worklet', () => {
|
|
|
201
201
|
const childWorklet = globalThis.runWorklet(parentCtx, []);
|
|
202
202
|
|
|
203
203
|
expect(childWorklet()).toBe(2);
|
|
204
|
-
expect(childWorklet).not.
|
|
204
|
+
expect(childWorklet.boundCtx).not.toBe(childCtx);
|
|
205
|
+
expect(childWorklet.boundCtx.token).toBe(2);
|
|
205
206
|
} finally {
|
|
206
207
|
globalThis.WeakRef = NativeWeakRef;
|
|
207
208
|
}
|
|
@@ -9,8 +9,6 @@ import * as ReactJSXRuntime from '@lynx-js/react/jsx-runtime';
|
|
|
9
9
|
import * as ReactLegacyReactRuntime from '@lynx-js/react/legacy-react-runtime';
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
RUNTIME_BACKEND_ELEMENT_TEMPLATE,
|
|
13
|
-
registerLazyRuntimeBackend,
|
|
14
12
|
sExportsJSXDevRuntime,
|
|
15
13
|
sExportsJSXRuntime,
|
|
16
14
|
sExportsLegacyReactRuntime,
|
|
@@ -21,8 +19,6 @@ import {
|
|
|
21
19
|
target,
|
|
22
20
|
} from './target.js';
|
|
23
21
|
|
|
24
|
-
registerLazyRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
25
|
-
|
|
26
22
|
Object.defineProperty(target, sExportsReact, {
|
|
27
23
|
value: ReactAPIs,
|
|
28
24
|
enumerable: false,
|
|
@@ -2,34 +2,44 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
sExportsReactInternal,
|
|
9
|
-
target,
|
|
10
|
-
} from './target.js';
|
|
5
|
+
import { sExportsReactInternal, target } from './target.js';
|
|
6
|
+
|
|
7
|
+
const ReactInternal = target[sExportsReactInternal];
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
// Use the host implementation while registering the standalone bundle's
|
|
10
|
+
// backend and build-time runtime version. Older hosts may not export them.
|
|
11
|
+
ReactInternal.registerRuntimeBackend?.(
|
|
12
|
+
ReactInternal.RUNTIME_BACKEND_ELEMENT_TEMPLATE,
|
|
13
|
+
);
|
|
14
|
+
ReactInternal.registerRuntimeVersion?.(
|
|
15
|
+
typeof __RUNTIME_VERSION__ === 'undefined' ? undefined : __RUNTIME_VERSION__,
|
|
16
|
+
);
|
|
13
17
|
|
|
14
18
|
export const {
|
|
15
19
|
Component,
|
|
20
|
+
RUNTIME_BACKEND_ELEMENT_TEMPLATE,
|
|
21
|
+
RUNTIME_BACKEND_SNAPSHOT,
|
|
16
22
|
SnapshotInstance,
|
|
17
23
|
__ElementTemplatePage,
|
|
18
24
|
__dynamicImport,
|
|
19
25
|
__etAttrPlanMap,
|
|
26
|
+
__etHost,
|
|
20
27
|
__root,
|
|
21
28
|
adaptEventAttrSlot,
|
|
22
29
|
adaptMTEventAttrSlot,
|
|
23
30
|
adaptMTRefAttrSlot,
|
|
24
31
|
adaptRefAttrSlot,
|
|
25
32
|
adaptSpreadAttrSlot,
|
|
33
|
+
getRuntimeVersion,
|
|
26
34
|
loadDynamicJS,
|
|
27
35
|
loadLazyBundle,
|
|
28
36
|
loadWorkletRuntime,
|
|
29
37
|
options,
|
|
30
38
|
process,
|
|
39
|
+
registerRuntimeBackend,
|
|
40
|
+
registerRuntimeVersion,
|
|
31
41
|
registerWorkletOnBackground,
|
|
32
42
|
transformToWorklet,
|
|
33
43
|
withInitDataInState,
|
|
34
44
|
wrapWithLynxComponent,
|
|
35
|
-
} =
|
|
45
|
+
} = ReactInternal;
|
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
RUNTIME_BACKEND_ELEMENT_TEMPLATE,
|
|
7
|
-
registerLazyRuntimeBackend,
|
|
8
|
-
sExportsJSXDevRuntime,
|
|
9
|
-
target,
|
|
10
|
-
} from './target.js';
|
|
11
|
-
|
|
12
|
-
registerLazyRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
5
|
+
import { sExportsJSXDevRuntime, target } from './target.js';
|
|
13
6
|
|
|
14
7
|
export const {
|
|
15
8
|
Fragment,
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
registerLazyRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
5
|
+
import { sExportsJSXRuntime, target } from './target.js';
|
|
8
6
|
|
|
9
7
|
export const {
|
|
10
8
|
Fragment,
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
registerLazyRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
5
|
+
import { sExportsReact, target } from './target.js';
|
|
8
6
|
|
|
9
7
|
export const {
|
|
10
8
|
Children,
|
package/runtime/lazy/import.js
CHANGED
|
@@ -10,8 +10,6 @@ import * as ReactLegacyReactRuntime from '@lynx-js/react/legacy-react-runtime';
|
|
|
10
10
|
import * as ReactLepusAPIs from '@lynx-js/react/lepus';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
-
RUNTIME_BACKEND_SNAPSHOT,
|
|
14
|
-
registerLazyRuntimeBackend,
|
|
15
13
|
sExportsJSXDevRuntime,
|
|
16
14
|
sExportsJSXRuntime,
|
|
17
15
|
sExportsLegacyReactRuntime,
|
|
@@ -22,8 +20,6 @@ import {
|
|
|
22
20
|
target,
|
|
23
21
|
} from './target.js';
|
|
24
22
|
|
|
25
|
-
registerLazyRuntimeBackend(RUNTIME_BACKEND_SNAPSHOT);
|
|
26
|
-
|
|
27
23
|
Object.defineProperty(target, sExportsReact, {
|
|
28
24
|
value: ReactAPIs,
|
|
29
25
|
enumerable: false,
|
package/runtime/lazy/internal.js
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { sExportsReactInternal, target } from './target.js';
|
|
6
6
|
|
|
7
|
+
const ReactInternal = target[sExportsReactInternal];
|
|
8
|
+
|
|
9
|
+
// Use the host implementation while registering the standalone bundle's
|
|
10
|
+
// backend and build-time runtime version. Older hosts may not export them.
|
|
11
|
+
ReactInternal.registerRuntimeBackend?.(ReactInternal.RUNTIME_BACKEND_SNAPSHOT);
|
|
12
|
+
ReactInternal.registerRuntimeVersion?.(
|
|
13
|
+
typeof __RUNTIME_VERSION__ === 'undefined' ? undefined : __RUNTIME_VERSION__,
|
|
14
|
+
);
|
|
15
|
+
|
|
7
16
|
export const {
|
|
8
17
|
BackgroundSnapshotInstance,
|
|
9
18
|
CHILDREN,
|
|
@@ -16,6 +25,8 @@ export const {
|
|
|
16
25
|
FLAGS,
|
|
17
26
|
INDEX,
|
|
18
27
|
PARENT,
|
|
28
|
+
RUNTIME_BACKEND_ELEMENT_TEMPLATE,
|
|
29
|
+
RUNTIME_BACKEND_SNAPSHOT,
|
|
19
30
|
__ComponentIsPolyfill,
|
|
20
31
|
__DynamicPartChildren,
|
|
21
32
|
__DynamicPartChildren_0,
|
|
@@ -30,12 +41,15 @@ export const {
|
|
|
30
41
|
__pageId,
|
|
31
42
|
__root,
|
|
32
43
|
createSnapshot,
|
|
44
|
+
getRuntimeVersion,
|
|
33
45
|
loadDynamicJS,
|
|
34
46
|
loadLazyBundle,
|
|
35
47
|
loadWorkletRuntime,
|
|
36
48
|
options,
|
|
37
49
|
preactCloneElement,
|
|
38
50
|
process,
|
|
51
|
+
registerRuntimeBackend,
|
|
52
|
+
registerRuntimeVersion,
|
|
39
53
|
registerWorkletOnBackground,
|
|
40
54
|
snapshotCreateList,
|
|
41
55
|
snapshotManager,
|
|
@@ -52,7 +66,7 @@ export const {
|
|
|
52
66
|
updateWorkletRef,
|
|
53
67
|
withInitDataInState,
|
|
54
68
|
wrapWithLynxComponent,
|
|
55
|
-
} =
|
|
69
|
+
} = ReactInternal;
|
|
56
70
|
|
|
57
71
|
/* v8 ignore start */
|
|
58
72
|
if (__DEV__ && !snapshotCreatorMap) {
|
package/runtime/lazy/target.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
export const target = __LEPUS__ ? globalThis : lynx;
|
|
5
5
|
|
|
6
|
-
export const RUNTIME_BACKEND_SNAPSHOT = 'Snapshot';
|
|
7
|
-
export const RUNTIME_BACKEND_ELEMENT_TEMPLATE = 'Element Template';
|
|
8
6
|
export const sRuntimeBackend = Symbol.for('__REACT_LYNX_RUNTIME_BACKEND__');
|
|
9
7
|
|
|
10
8
|
export const sExportsReact = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react)');
|
|
@@ -14,22 +12,3 @@ export const sExportsReactInternal = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js
|
|
|
14
12
|
export const sExportsJSXRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/jsx-runtime)');
|
|
15
13
|
export const sExportsJSXDevRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/jsx-dev-runtime)');
|
|
16
14
|
export const sExportsLegacyReactRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/legacy-react-runtime)');
|
|
17
|
-
|
|
18
|
-
export function registerLazyRuntimeBackend(backend) {
|
|
19
|
-
const currentBackend = target[sRuntimeBackend];
|
|
20
|
-
|
|
21
|
-
if (currentBackend !== undefined && currentBackend !== backend) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
`ReactLynx runtime backend mismatch: the current template uses ${
|
|
24
|
-
String(currentBackend)
|
|
25
|
-
}, but this bundle was built for ${backend}. Snapshot and Element Template templates cannot share lazy bundles. Rebuild the main template and lazy bundle with the same elementTemplate setting.`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(target, sRuntimeBackend, {
|
|
30
|
-
value: backend,
|
|
31
|
-
enumerable: false,
|
|
32
|
-
writable: false,
|
|
33
|
-
configurable: true,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
@@ -8,6 +8,7 @@ declare const useState: typeof usePreactState;
|
|
|
8
8
|
* @param effect - Imperative function that can return a cleanup function
|
|
9
9
|
* @param deps - If present, effect will only activate if the values in the list change (using ===).
|
|
10
10
|
*
|
|
11
|
+
* @function
|
|
11
12
|
* @public
|
|
12
13
|
*/
|
|
13
14
|
declare const useEffect: (effect: EffectCallback, deps?: DependencyList) => void;
|
|
@@ -19,6 +20,7 @@ declare const useEffect: (effect: EffectCallback, deps?: DependencyList) => void
|
|
|
19
20
|
* @param effect - Imperative function that can return a cleanup function
|
|
20
21
|
* @param deps - If present, effect will only activate if the values in the list change (using ===).
|
|
21
22
|
*
|
|
23
|
+
* @function
|
|
22
24
|
* @public
|
|
23
25
|
*
|
|
24
26
|
* @deprecated `useLayoutEffect` in the background thread cannot offer the precise timing for reading layout information and synchronously re-render, which is different from React.
|
|
@@ -96,6 +96,7 @@ const useState = (__BACKGROUND__ && isProfiling)
|
|
|
96
96
|
* @param effect - Imperative function that can return a cleanup function
|
|
97
97
|
* @param deps - If present, effect will only activate if the values in the list change (using ===).
|
|
98
98
|
*
|
|
99
|
+
* @function
|
|
99
100
|
* @public
|
|
100
101
|
*/
|
|
101
102
|
const useEffect = (__BACKGROUND__ && isProfiling)
|
|
@@ -109,6 +110,7 @@ const useEffect = (__BACKGROUND__ && isProfiling)
|
|
|
109
110
|
* @param effect - Imperative function that can return a cleanup function
|
|
110
111
|
* @param deps - If present, effect will only activate if the values in the list change (using ===).
|
|
111
112
|
*
|
|
113
|
+
* @function
|
|
112
114
|
* @public
|
|
113
115
|
*
|
|
114
116
|
* @deprecated `useLayoutEffect` in the background thread cannot offer the precise timing for reading layout information and synchronously re-render, which is different from React.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/core/hooks/react.ts"],"names":[],"mappings":"AAAA,wDAAwD;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GAAG,CAAC,eAAe,EAAE,cAA4C,CAAC,CAAC;IAE1F,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,QAAQ,GAA0B,CAAC,cAAc,IAAI,WAAW,CAAC;IACrE,CAAC,CAAC,mBAA4C;IAC9C,CAAC,CAAC,cAAc,CAAC;AAEnB;;;;;;;;;GASG;AACH,MAAM,SAAS,GAA4D,CAAC,cAAc,IAAI,WAAW,CAAC;IACxG,CAAC,CAAC,iBAAiB;IACnB,CAAC,CAAC,eAAe,CAAC;AAEpB;;;;;;;;;;;;GAYG;AACH,MAAM,eAAe,GAA4D,CAAC,cAAc,IAAI,WAAW,CAAC;IAC9G,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,eAAe,CAAC;AAEpB,OAAO;AACL,SAAS;AACT,QAAQ,EACR,UAAU,EACV,MAAM,EACN,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,GACN,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const sRuntimeVersion: symbol;
|
|
2
|
+
/**
|
|
3
|
+
* Record the `@lynx-js/react` runtime version compiled into this bundle.
|
|
4
|
+
*
|
|
5
|
+
* Every lazy bundle bundles its own copy of the `@lynx-js/react` runtime. The
|
|
6
|
+
* host template is loaded first, so the first registration wins and the
|
|
7
|
+
* recorded value reflects the host's runtime version. This function only
|
|
8
|
+
* records the version so it is available for later inspection; it does not
|
|
9
|
+
* compare versions or throw.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerRuntimeVersion(version: string | undefined): void;
|
|
12
|
+
/**
|
|
13
|
+
* Read the `@lynx-js/react` runtime version recorded by the host template, or
|
|
14
|
+
* `undefined` when the host was built by a plugin that does not stamp it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRuntimeVersion(): string | undefined;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
export const sRuntimeVersion = Symbol.for('__REACT_LYNX_RUNTIME_VERSION__');
|
|
5
|
+
function getTarget() {
|
|
6
|
+
return (__LEPUS__ ? globalThis : lynx);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Record the `@lynx-js/react` runtime version compiled into this bundle.
|
|
10
|
+
*
|
|
11
|
+
* Every lazy bundle bundles its own copy of the `@lynx-js/react` runtime. The
|
|
12
|
+
* host template is loaded first, so the first registration wins and the
|
|
13
|
+
* recorded value reflects the host's runtime version. This function only
|
|
14
|
+
* records the version so it is available for later inspection; it does not
|
|
15
|
+
* compare versions or throw.
|
|
16
|
+
*/
|
|
17
|
+
export function registerRuntimeVersion(version) {
|
|
18
|
+
// Older versions of the build plugin do not stamp `__RUNTIME_VERSION__`, so
|
|
19
|
+
// there is nothing to record.
|
|
20
|
+
if (!version) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const target = getTarget();
|
|
24
|
+
const currentVersion = target[sRuntimeVersion];
|
|
25
|
+
// Log host and bundle versions so online reports can diagnose mismatches.
|
|
26
|
+
// Only emit on the background thread — the main-thread copy would be a
|
|
27
|
+
// duplicate report of the same values.
|
|
28
|
+
// TODO: on repeated registration, compare and surface a compatibility check.
|
|
29
|
+
if (__JS__) {
|
|
30
|
+
console.alog?.(`[ReactLynx] new runtime version: ${version}${currentVersion === undefined ? '' : `, current version: ${currentVersion}`}`);
|
|
31
|
+
}
|
|
32
|
+
// The host registers first; keep its version and let later lazy bundles be
|
|
33
|
+
// no-ops so the recorded value always represents the host runtime.
|
|
34
|
+
if (currentVersion !== undefined) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(target, sRuntimeVersion, {
|
|
38
|
+
value: version,
|
|
39
|
+
enumerable: false,
|
|
40
|
+
writable: false,
|
|
41
|
+
configurable: true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Read the `@lynx-js/react` runtime version recorded by the host template, or
|
|
46
|
+
* `undefined` when the host was built by a plugin that does not stamp it.
|
|
47
|
+
*/
|
|
48
|
+
export function getRuntimeVersion() {
|
|
49
|
+
return getTarget()[sRuntimeVersion];
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=runtime-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-version.js","sourceRoot":"","sources":["../../../src/core/lynx/runtime-version.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAEpF,SAAS,SAAS;IAChB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAgD,CAAC;AACxF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA2B;IAChE,4EAA4E;IAC5E,8BAA8B;IAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,CAAuB,CAAC;IAErE,0EAA0E;IAC1E,uEAAuE;IACvE,uCAAuC;IACvC,6EAA6E;IAC7E,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,EAAE,CACZ,oCAAoC,OAAO,GACzC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,sBAAsB,cAAc,EAC1E,EAAE,CACH,CAAC;IACJ,CAAC;IAED,2EAA2E;IAC3E,mEAAmE;IACnE,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE;QAC7C,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,SAAS,EAAE,CAAC,eAAe,CAAuB,CAAC;AAC5D,CAAC"}
|
|
@@ -2,6 +2,6 @@ import { BackgroundElementTemplateInstance } from './instance.js';
|
|
|
2
2
|
export interface BackgroundElementTemplateDocument {
|
|
3
3
|
createElement(type: string): BackgroundElementTemplateInstance;
|
|
4
4
|
createElementNS(ns: string, type: string): BackgroundElementTemplateInstance;
|
|
5
|
-
createTextNode(text: string): BackgroundElementTemplateInstance;
|
|
5
|
+
createTextNode(text: string | number): BackgroundElementTemplateInstance;
|
|
6
6
|
}
|
|
7
7
|
export declare function setupBackgroundElementTemplateDocument(): BackgroundElementTemplateDocument;
|
|
@@ -18,7 +18,7 @@ export function setupBackgroundElementTemplateDocument() {
|
|
|
18
18
|
return new BackgroundElementTemplateInstance(type);
|
|
19
19
|
},
|
|
20
20
|
createTextNode(text) {
|
|
21
|
-
return new BackgroundElementTemplateInstance(BUILTIN_RAW_TEXT_TEMPLATE_KEY, [text]);
|
|
21
|
+
return new BackgroundElementTemplateInstance(BUILTIN_RAW_TEXT_TEMPLATE_KEY, [String(text)]);
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
options.document = doc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/element-template/background/document.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,eAAe,CAAC;AAQvB,MAAM,UAAU,sCAAsC;IACpD,MAAM,GAAG,GAAG;QACV,aAAa,CAAC,IAAY;YACxB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,qCAAqC,EAAE,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,eAAe,CAAC,GAAW,EAAE,IAAY;YACvC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,qCAAqC,EAAE,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/element-template/background/document.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,eAAe,CAAC;AAQvB,MAAM,UAAU,sCAAsC;IACpD,MAAM,GAAG,GAAG;QACV,aAAa,CAAC,IAAY;YACxB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,qCAAqC,EAAE,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,eAAe,CAAC,GAAW,EAAE,IAAY;YACvC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,qCAAqC,EAAE,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,cAAc,CAAC,IAAqB;YAClC,OAAO,IAAI,iCAAiC,CAAC,6BAA6B,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9F,CAAC;KACF,CAAC;IAEF,OAAO,CAAC,QAAQ,GAAG,GAA0B,CAAC;IAE9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -19,7 +19,13 @@ const COMPONENT_AT_INDEXES_ATTR = 'component-at-indexes';
|
|
|
19
19
|
const ENQUEUE_COMPONENT_ATTR = 'enqueue-component';
|
|
20
20
|
const UPDATE_LIST_INFO_ATTR = 'update-list-info';
|
|
21
21
|
export function hydrateRootChildrenIntoContext(serializedChildren, root) {
|
|
22
|
-
|
|
22
|
+
try {
|
|
23
|
+
return hydrateChildListIntoContext(ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, serializedChildren, root.childNodes);
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
// Template identities only need caching for this synchronous hydration pass.
|
|
27
|
+
backgroundHydrateKeys.clear();
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
30
|
function isSerializedCompiledNode(serialized) {
|
|
25
31
|
return typeof serialized.templateKey === 'string';
|
|
@@ -30,7 +36,6 @@ function isSerializedTypedListNode(serialized) {
|
|
|
30
36
|
function hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildren) {
|
|
31
37
|
let lastPlacedIndex = 0;
|
|
32
38
|
const result = {
|
|
33
|
-
hasChanges: false,
|
|
34
39
|
insertions: {},
|
|
35
40
|
insertionCount: 0,
|
|
36
41
|
removals: [],
|
|
@@ -48,8 +53,7 @@ function hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildr
|
|
|
48
53
|
// Normalize the background instance's full `${entry}:${key}` type tag to the
|
|
49
54
|
// same native identity the serialized side uses (sentinel folded to the main
|
|
50
55
|
// card), so main-card nodes match regardless of the `__Card__` prefix.
|
|
51
|
-
const
|
|
52
|
-
const backgroundKey = elementTemplateIdentityKey(parsedBackgroundType.templateKey, parsedBackgroundType.bundleUrl);
|
|
56
|
+
const backgroundKey = getBackgroundNodeHydrateKey(backgroundChild.type);
|
|
53
57
|
const serializedCandidates = serializedByNodeKey[backgroundKey];
|
|
54
58
|
const candidateCursor = serializedCursorByNodeKey[backgroundKey] ?? 0;
|
|
55
59
|
const matchedSerialized = serializedCandidates?.[candidateCursor];
|
|
@@ -61,7 +65,6 @@ function hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildr
|
|
|
61
65
|
}
|
|
62
66
|
if (oldIndex < lastPlacedIndex) {
|
|
63
67
|
result.moves[oldIndex] = { toIndex: i, instance: backgroundChild };
|
|
64
|
-
result.hasChanges = true;
|
|
65
68
|
}
|
|
66
69
|
else {
|
|
67
70
|
lastPlacedIndex = oldIndex;
|
|
@@ -70,7 +73,6 @@ function hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildr
|
|
|
70
73
|
else {
|
|
71
74
|
result.insertions[i] = backgroundChild;
|
|
72
75
|
result.insertionCount += 1;
|
|
73
|
-
result.hasChanges = true;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
for (const key in serializedByNodeKey) {
|
|
@@ -78,7 +80,6 @@ function hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildr
|
|
|
78
80
|
const candidateCursor = serializedCursorByNodeKey[key] ?? 0;
|
|
79
81
|
for (let i = candidateCursor; i < candidates.length; i += 1) {
|
|
80
82
|
result.removals.push(candidates[i][1]);
|
|
81
|
-
result.hasChanges = true;
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
return result;
|
|
@@ -98,11 +99,16 @@ function hydrateCompiledInstance(serialized, instance) {
|
|
|
98
99
|
if (!bindHydrationHandleId(instance, handleId, serialized.templateKey)) {
|
|
99
100
|
return false;
|
|
100
101
|
}
|
|
101
|
-
instance.
|
|
102
|
-
|
|
102
|
+
if (serialized.attributeSlots?.length || instance.attributeSlots.length) {
|
|
103
|
+
instance.prepareAttributeSlotsForHydration();
|
|
104
|
+
hydrateAttributeSlots(instance.type, handleId, serialized.attributeSlots ?? [], instance.attributeSlots);
|
|
105
|
+
}
|
|
103
106
|
if (serialized.templateKey === BUILTIN_RAW_TEXT_TEMPLATE_KEY) {
|
|
104
107
|
return true;
|
|
105
108
|
}
|
|
109
|
+
if (!serialized.childSlots?.length && !instance.firstChild) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
106
112
|
const serializedChildSlots = serialized.childSlots ?? [];
|
|
107
113
|
const backgroundChildSlots = instance.childSlots;
|
|
108
114
|
// Snapshot hydrates dynamic children through slot-filtered lists. Keeping ET
|
|
@@ -121,6 +127,17 @@ function hydrateCompiledInstance(serialized, instance) {
|
|
|
121
127
|
}
|
|
122
128
|
return true;
|
|
123
129
|
}
|
|
130
|
+
const backgroundHydrateKeys = new Map();
|
|
131
|
+
function getBackgroundNodeHydrateKey(type) {
|
|
132
|
+
const cached = backgroundHydrateKeys.get(type);
|
|
133
|
+
if (cached !== undefined) {
|
|
134
|
+
return cached;
|
|
135
|
+
}
|
|
136
|
+
const parsed = parseElementTemplateType(type);
|
|
137
|
+
const key = elementTemplateIdentityKey(parsed.templateKey, parsed.bundleUrl);
|
|
138
|
+
backgroundHydrateKeys.set(type, key);
|
|
139
|
+
return key;
|
|
140
|
+
}
|
|
124
141
|
function getSerializedNodeHydrateKey(serialized) {
|
|
125
142
|
if (!isSerializedCompiledNode(serialized)) {
|
|
126
143
|
return serialized.tag;
|
|
@@ -189,13 +206,31 @@ function hydrateChildListIntoContext(targetHandleId, slotId, serializedChildren,
|
|
|
189
206
|
}
|
|
190
207
|
return true;
|
|
191
208
|
}
|
|
209
|
+
// Preserve the full matcher’s FIFO pairing while avoiding its temporary
|
|
210
|
+
// structures when every child already occupies the matching slot position.
|
|
211
|
+
const length = serializedChildren.length;
|
|
212
|
+
if (length === backgroundChildren.length) {
|
|
213
|
+
let samePairwise = true;
|
|
214
|
+
for (let i = 0; i < length; i += 1) {
|
|
215
|
+
if (getSerializedNodeHydrateKey(serializedChildren[i])
|
|
216
|
+
!== getBackgroundNodeHydrateKey(backgroundChildren[i].type)) {
|
|
217
|
+
samePairwise = false;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (samePairwise) {
|
|
222
|
+
for (let i = 0; i < length; i += 1) {
|
|
223
|
+
if (!hydrateInstance(serializedChildren[i], backgroundChildren[i])) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
192
230
|
const listDiff = hydrateMatchingChildrenAndDiffSlot(serializedChildren, backgroundChildren);
|
|
193
231
|
if (listDiff === null) {
|
|
194
232
|
return false;
|
|
195
233
|
}
|
|
196
|
-
if (!listDiff.hasChanges) {
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
234
|
// Hydrate emits patches directly here. Replaying against serialized order
|
|
200
235
|
// keeps insert targets in the main-thread slot without reshaping background.
|
|
201
236
|
const removalIndexes = new Set(listDiff.removals);
|
|
@@ -390,17 +425,14 @@ function hydrateAttributeSlots(templateType, handleId, beforeSlots, afterSlots)
|
|
|
390
425
|
const slotCount = Math.max(beforeSlots.length, afterSlots.length);
|
|
391
426
|
const slotKinds = getMainThreadDynamicAttrSlotKinds(templateType);
|
|
392
427
|
for (let slotIndex = 0; slotIndex < slotCount; slotIndex += 1) {
|
|
393
|
-
|
|
394
|
-
const
|
|
428
|
+
// Native serialization and background preparation may represent an absent slot differently.
|
|
429
|
+
const beforeValue = beforeSlots[slotIndex] ?? null;
|
|
430
|
+
const afterValue = afterSlots[slotIndex] ?? null;
|
|
395
431
|
if (!shouldForceMainThreadHydrateSlot(slotKinds?.get(slotIndex), afterValue)
|
|
396
432
|
&& isDirectOrDeepEqual(beforeValue, afterValue)) {
|
|
397
433
|
continue;
|
|
398
434
|
}
|
|
399
|
-
|
|
400
|
-
// JSON serialization turns undefined array slots into null on the main-thread payload.
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
globalCommitContext.ops.push(getAttributeSlotUpdateOp(templateType, slotIndex), handleId, slotIndex, afterValue ?? null);
|
|
435
|
+
globalCommitContext.ops.push(getAttributeSlotUpdateOp(templateType, slotIndex), handleId, slotIndex, afterValue);
|
|
404
436
|
}
|
|
405
437
|
}
|
|
406
438
|
function shouldForceMainThreadHydrateSlot(slotKind, value) {
|