@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { MAIN_BUNDLE_URL_SENTINEL, elementTemplateIdentityKey, parseElementTemplateType, } from '../../protocol/template-type.js';
|
|
5
|
+
import { composeElementTemplateListAttributes, createElementTemplateListState, markElementTemplateListDestroyed, registerElementTemplateListItem, registerElementTemplateListState, } from '../list/list.js';
|
|
6
|
+
import { __etAttrPlanMap, hasMainThreadRefAttrSlot } from '../template/attr-slot-plan.js';
|
|
7
|
+
import { createElementTemplateWithReservedHandle, createTypedElementTemplateWithReservedHandle, destroyElementTemplateId, getNextElementTemplateId, } from '../template/handle.js';
|
|
8
|
+
import { prepareTypedElementAttributes } from '../template/typed-attributes.js';
|
|
9
|
+
const TYPED_LIST_HOST_TYPE = 'list';
|
|
10
|
+
const EMPTY_LIST_ITEM_UIDS = [];
|
|
11
|
+
export function discardRenderedHostsSince(checkpoint) {
|
|
12
|
+
const end = getNextElementTemplateId();
|
|
13
|
+
// Synchronous first-screen creation allocates consecutive negative IDs.
|
|
14
|
+
// Release abandoned native refs and side tables without reusing those IDs.
|
|
15
|
+
for (let uid = checkpoint; uid > end; uid--) {
|
|
16
|
+
markElementTemplateListDestroyed(uid);
|
|
17
|
+
destroyElementTemplateId(uid);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function createRenderedHost(handleId, type, attributes, childSlots, listItemUids, materializationHandles, listItemPlatformInfo, host) {
|
|
21
|
+
if (type === TYPED_LIST_HOST_TYPE) {
|
|
22
|
+
const listChildren = childSlots?.[0] ?? [];
|
|
23
|
+
const preparedTypedAttributes = prepareTypedElementAttributes(handleId, attributes);
|
|
24
|
+
const listState = createElementTemplateListState(listItemUids ?? EMPTY_LIST_ITEM_UIDS, preparedTypedAttributes);
|
|
25
|
+
const attrsWithCallbacks = composeElementTemplateListAttributes(undefined, listState);
|
|
26
|
+
const elementRef = createTypedElementTemplateWithReservedHandle(handleId, TYPED_LIST_HOST_TYPE, attrsWithCallbacks, null, { listChildren });
|
|
27
|
+
registerElementTemplateListState(handleId, listState, true, elementRef);
|
|
28
|
+
return elementRef;
|
|
29
|
+
}
|
|
30
|
+
const plain = host?.plain === true;
|
|
31
|
+
const attrPlan = plain ? undefined : __etAttrPlanMap[type];
|
|
32
|
+
const attributeSlots = attributes;
|
|
33
|
+
let preparedAttributeSlots = attributeSlots ?? null;
|
|
34
|
+
if (attrPlan !== undefined) {
|
|
35
|
+
preparedAttributeSlots = attributeSlots?.slice() ?? [];
|
|
36
|
+
for (let planIndex = 0; planIndex < attrPlan.length; planIndex += 2) {
|
|
37
|
+
const attrSlotIndex = attrPlan[planIndex];
|
|
38
|
+
const adapter = attrPlan[planIndex + 1];
|
|
39
|
+
preparedAttributeSlots[attrSlotIndex] = adapter(handleId, attrSlotIndex, preparedAttributeSlots[attrSlotIndex]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Compact hosts carry bundle identity captured when their template is defined.
|
|
43
|
+
const identity = host ?? parseElementTemplateType(type);
|
|
44
|
+
const templateKey = identity.templateKey;
|
|
45
|
+
const bundleUrl = identity.bundleUrl === MAIN_BUNDLE_URL_SENTINEL ? null : identity.bundleUrl;
|
|
46
|
+
const hasMainThreadRef = !plain && /* #__NOINLINE__ */ hasMainThreadRefAttrSlot(type);
|
|
47
|
+
const elementRef = createElementTemplateWithReservedHandle(handleId, templateKey, bundleUrl, preparedAttributeSlots, childSlots ?? null, !plain);
|
|
48
|
+
if (hasMainThreadRef) {
|
|
49
|
+
materializationHandles.push({
|
|
50
|
+
uid: handleId,
|
|
51
|
+
ref: elementRef,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (listItemPlatformInfo !== undefined) {
|
|
55
|
+
registerElementTemplateListItem(handleId, elementRef, {
|
|
56
|
+
// The native list identifies items by the same identity the template
|
|
57
|
+
// was registered under (sentinel stripped for the main card), so the
|
|
58
|
+
// update path (`resolveTypedListItem`) stays consistent with it.
|
|
59
|
+
templateKey: elementTemplateIdentityKey(templateKey, bundleUrl),
|
|
60
|
+
platformInfo: listItemPlatformInfo,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return elementRef;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=create-rendered-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-rendered-host.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/create-rendered-host.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,oCAAoC,EACpC,8BAA8B,EAC9B,gCAAgC,EAChC,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE1F,OAAO,EACL,uCAAuC,EACvC,4CAA4C,EAC5C,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,oBAAoB,GAAsB,EAAE,CAAC;AAInD,MAAM,UAAU,yBAAyB,CAAC,UAAkB;IAC1D,MAAM,GAAG,GAAG,wBAAwB,EAAE,CAAC;IACvC,wEAAwE;IACxE,2EAA2E;IAC3E,KAAK,IAAI,GAAG,GAAG,UAAU,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;QAC5C,gCAAgC,CAAC,GAAG,CAAC,CAAC;QACtC,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,IAAY,EACZ,UAA4B,EAC5B,UAAiD,EACjD,YAAkC,EAClC,sBAA4D,EAC5D,oBAAwD,EACxD,IAA0B;IAE1B,IAAI,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAClC,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC3C,MAAM,uBAAuB,GAAG,6BA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AC,CAAC;IACxD,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;IACzC,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,KAAK,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC9F,MAAM,gBAAgB,GAAG,CAAC,KAAK,IAAI,mBAAmB,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACtF,MAAM,UAAU,GAAG,uCAAuC,CACxD,QAAQ,EACR,WAAW,EACX,SAAS,EACT,sBAAsB,EACtB,UAAU,IAAI,IAAI,EAClB,CAAC,KAAK,CACP,CAAC;IACF,IAAI,gBAAgB,EAAE,CAAC;QACrB,sBAAsB,CAAC,IAAI,CAAC;YAC1B,GAAG,EAAE,QAAQ;YACb,GAAG,EAAE,UAAU;SAChB,CAAC,CAAC;IACL,CAAC;IACD,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACvC,+BAA+B,CAAC,QAAQ,EAAE,UAAU,EAAE;YACpD,qEAAqE;YACrE,qEAAqE;YACrE,iEAAiE;YACjE,WAAW,EAAE,0BAA0B,CAAC,WAAW,EAAE,SAAS,CAAC;YAC/D,YAAY,EAAE,oBAAoB;SACnC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SerializableValue } from '../../protocol/types.js';
|
|
2
|
+
import type { ETListItemPlatformInfo } from '../list/list.js';
|
|
3
|
+
/** Compiler-owned first-screen data. Construction does not create native nodes. */
|
|
4
|
+
export declare function __etHost(type: string, templateKey: string, bundleUrl: string, key: unknown, attributeSlots: SerializableValue[] | undefined, slotChildren: unknown[] | undefined, __listItemPlatformInfo: ETListItemPlatformInfo | undefined, plain?: true): ElementTemplateHost;
|
|
5
|
+
export interface ElementTemplateHost {
|
|
6
|
+
plain?: true | undefined;
|
|
7
|
+
type: string;
|
|
8
|
+
templateKey: string;
|
|
9
|
+
bundleUrl: string;
|
|
10
|
+
key: unknown;
|
|
11
|
+
attributeSlots: SerializableValue[] | undefined;
|
|
12
|
+
slotChildren: unknown[] | undefined;
|
|
13
|
+
__listItemPlatformInfo?: ETListItemPlatformInfo | undefined;
|
|
14
|
+
props?: {
|
|
15
|
+
attributeSlots: SerializableValue[] | undefined;
|
|
16
|
+
children: unknown[] | undefined;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright 2024 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
|
+
/** Compiler-owned first-screen data. Construction does not create native nodes. */
|
|
5
|
+
export function __etHost(type, templateKey, bundleUrl, key, attributeSlots, slotChildren, __listItemPlatformInfo,
|
|
6
|
+
// Set only when the compiler proves no attribute adapters or list-item setup are needed.
|
|
7
|
+
plain) {
|
|
8
|
+
const host = {
|
|
9
|
+
type,
|
|
10
|
+
templateKey,
|
|
11
|
+
bundleUrl,
|
|
12
|
+
key,
|
|
13
|
+
attributeSlots,
|
|
14
|
+
slotChildren,
|
|
15
|
+
__listItemPlatformInfo,
|
|
16
|
+
plain,
|
|
17
|
+
};
|
|
18
|
+
if (__DEV__) {
|
|
19
|
+
// Preact debug formats host props in diagnostics such as duplicate keys.
|
|
20
|
+
// The renderer consumes the compact fields in both development and production.
|
|
21
|
+
host.props = { attributeSlots, children: slotChildren };
|
|
22
|
+
}
|
|
23
|
+
return host;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/host.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAK1D,mFAAmF;AACnF,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,WAAmB,EACnB,SAAiB,EACjB,GAAY,EACZ,cAA+C,EAC/C,YAAmC,EACnC,sBAA0D;AAC1D,yFAAyF;AACzF,KAAY;IAEZ,MAAM,IAAI,GAAwB;QAChC,IAAI;QACJ,WAAW;QACX,SAAS;QACT,GAAG;QACH,cAAc;QACd,YAAY;QACZ,sBAAsB;QACtB,KAAK;KACN,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,yEAAyE;QACzE,+EAA+E;QAC/E,IAAI,CAAC,KAAK,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare let beforeDiff: ((vnode: unknown) => void) | undefined;
|
|
2
|
+
export declare let beforeDiff2: ((vnode: unknown, context: Record<string, unknown>) => void) | undefined;
|
|
3
|
+
export declare function renderWithHooks(vnode: unknown, context: unknown, output: unknown[], renderVNode: Function, result: unknown): unknown[];
|
|
4
|
+
export declare const EMPTY_OBJ: Record<string, unknown>;
|
|
5
|
+
export declare function cleanupVNode(vnode: unknown): void;
|
|
6
|
+
export declare function renderComponentVNode(vnode: unknown, type: unknown, props: unknown, context: unknown, output: unknown[], renderVNode: Function, result: unknown, parentType?: string, subtreeHandles?: unknown[], listItemUids?: number[]): void;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// Copyright 2024 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
|
+
* Synchronous component traversal for Element Template rendering.
|
|
6
|
+
* This module is modified from preact-render-to-string@6.0.3 to generate
|
|
7
|
+
* host output instead of HTML strings for Lynx.
|
|
8
|
+
*/
|
|
9
|
+
// @ts-nocheck
|
|
10
|
+
import { Fragment, h, options } from 'preact';
|
|
11
|
+
import { discardRenderedHostsSince } from './create-rendered-host.js';
|
|
12
|
+
import { getNextElementTemplateId } from '../template/handle.js';
|
|
13
|
+
import { BITS, CHILDREN, COMMIT, COMPONENT, COMPONENT_DIRTY, DIFF, DIFF2, DIFFED, GLOBAL_CONTEXT, NEXT_STATE, PARENT, RENDER, SKIP_EFFECTS, VNODE, } from '../../../shared/render-constants.js';
|
|
14
|
+
/** @typedef {import('preact').VNode} VNode */
|
|
15
|
+
const EMPTY_ARR = [];
|
|
16
|
+
const assign = /* @__PURE__ */ Object.assign;
|
|
17
|
+
// Global state for the current render pass
|
|
18
|
+
export let beforeDiff;
|
|
19
|
+
export let beforeDiff2;
|
|
20
|
+
let afterDiff, renderHook, ummountHook;
|
|
21
|
+
export function renderWithHooks(vnode, context, output, renderVNode, result) {
|
|
22
|
+
// Performance optimization: main-thread rendering is synchronous and we
|
|
23
|
+
// therefore don't execute any effects. To do that we pass an empty
|
|
24
|
+
// array to `options._commit` (`__c`). But we can go one step further
|
|
25
|
+
// and avoid a lot of dirty checks and allocations by setting
|
|
26
|
+
// `options._skipEffects` (`__s`) too.
|
|
27
|
+
const previousSkipEffects = options[SKIP_EFFECTS];
|
|
28
|
+
options[SKIP_EFFECTS] = true;
|
|
29
|
+
// store options hooks once before each synchronous render call
|
|
30
|
+
beforeDiff = options[DIFF];
|
|
31
|
+
beforeDiff2 = options[DIFF2];
|
|
32
|
+
afterDiff = options[DIFFED];
|
|
33
|
+
renderHook = options[RENDER];
|
|
34
|
+
ummountHook = options.unmount;
|
|
35
|
+
const parent = h(Fragment, null);
|
|
36
|
+
parent[CHILDREN] = [vnode];
|
|
37
|
+
try {
|
|
38
|
+
renderVNode(vnode, context || EMPTY_OBJ, parent, output, result);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
// options._commit, we don't schedule any effects in this library right now,
|
|
42
|
+
// so we can pass an empty queue to this hook.
|
|
43
|
+
if (options[COMMIT])
|
|
44
|
+
options[COMMIT](vnode, EMPTY_ARR);
|
|
45
|
+
options[SKIP_EFFECTS] = previousSkipEffects;
|
|
46
|
+
EMPTY_ARR.length = 0;
|
|
47
|
+
}
|
|
48
|
+
return output;
|
|
49
|
+
}
|
|
50
|
+
// Installed as setState/forceUpdate for function components
|
|
51
|
+
/* v8 ignore start */
|
|
52
|
+
function markAsDirty() {
|
|
53
|
+
this[BITS] |= COMPONENT_DIRTY;
|
|
54
|
+
}
|
|
55
|
+
/* v8 ignore stop */
|
|
56
|
+
export const EMPTY_OBJ = {};
|
|
57
|
+
/**
|
|
58
|
+
* @param {VNode} vnode
|
|
59
|
+
* @param {Record<string, unknown>} context
|
|
60
|
+
*/
|
|
61
|
+
function renderClassComponent(vnode, context, globalContext) {
|
|
62
|
+
const type = /** @type {import("preact").ComponentClass<typeof vnode.props>} */ (vnode.type);
|
|
63
|
+
let c;
|
|
64
|
+
if (vnode[COMPONENT]) {
|
|
65
|
+
c = vnode[COMPONENT];
|
|
66
|
+
c.state = c[NEXT_STATE];
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
c = new type(vnode.props, context);
|
|
70
|
+
}
|
|
71
|
+
vnode[COMPONENT] = c;
|
|
72
|
+
c[VNODE] = vnode;
|
|
73
|
+
c.props = vnode.props;
|
|
74
|
+
c.context = context;
|
|
75
|
+
c[GLOBAL_CONTEXT] = globalContext;
|
|
76
|
+
// turn off stateful re-rendering:
|
|
77
|
+
c[BITS] |= COMPONENT_DIRTY;
|
|
78
|
+
if (c.state == null)
|
|
79
|
+
c.state = EMPTY_OBJ;
|
|
80
|
+
if (c[NEXT_STATE] == null) {
|
|
81
|
+
c[NEXT_STATE] = c.state;
|
|
82
|
+
}
|
|
83
|
+
if (type.getDerivedStateFromProps) {
|
|
84
|
+
c.state = assign({}, c.state, type.getDerivedStateFromProps(c.props, c.state));
|
|
85
|
+
}
|
|
86
|
+
if (renderHook)
|
|
87
|
+
renderHook(vnode);
|
|
88
|
+
return c.render(c.props, c.state, context);
|
|
89
|
+
}
|
|
90
|
+
export function cleanupVNode(vnode) {
|
|
91
|
+
if (afterDiff)
|
|
92
|
+
afterDiff(vnode);
|
|
93
|
+
vnode[PARENT] = undefined;
|
|
94
|
+
if (ummountHook)
|
|
95
|
+
ummountHook(vnode);
|
|
96
|
+
}
|
|
97
|
+
export function renderComponentVNode(vnode, type, props, context, output, renderVNode, result, parentType, subtreeHandles, listItemUids) {
|
|
98
|
+
let cctx = context;
|
|
99
|
+
let rendered;
|
|
100
|
+
let component;
|
|
101
|
+
const outputLength = output.length;
|
|
102
|
+
if (type === Fragment) {
|
|
103
|
+
rendered = props.children;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const contextType = type.contextType;
|
|
107
|
+
if (contextType != null) {
|
|
108
|
+
const provider = context[contextType.__c];
|
|
109
|
+
cctx = provider ? provider.props.value : contextType.__;
|
|
110
|
+
}
|
|
111
|
+
if (type.prototype && typeof type.prototype.render === 'function') {
|
|
112
|
+
rendered = /**#__NOINLINE__**/ renderClassComponent(vnode, cctx, context);
|
|
113
|
+
component = vnode[COMPONENT];
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
component = {
|
|
117
|
+
__v: vnode,
|
|
118
|
+
props,
|
|
119
|
+
context: cctx,
|
|
120
|
+
[GLOBAL_CONTEXT]: context,
|
|
121
|
+
// silently drop state updates
|
|
122
|
+
setState: markAsDirty,
|
|
123
|
+
forceUpdate: markAsDirty,
|
|
124
|
+
__g: COMPONENT_DIRTY,
|
|
125
|
+
// hooks
|
|
126
|
+
__h: [],
|
|
127
|
+
};
|
|
128
|
+
vnode[COMPONENT] = component;
|
|
129
|
+
component.constructor = type;
|
|
130
|
+
component.render = doRender;
|
|
131
|
+
let count = 0;
|
|
132
|
+
while (component[BITS] & COMPONENT_DIRTY && count++ < 25) {
|
|
133
|
+
component[BITS] &= ~COMPONENT_DIRTY;
|
|
134
|
+
if (renderHook)
|
|
135
|
+
renderHook(vnode);
|
|
136
|
+
rendered = component.render(props, component.state, cctx);
|
|
137
|
+
}
|
|
138
|
+
component[BITS] |= COMPONENT_DIRTY;
|
|
139
|
+
}
|
|
140
|
+
if (component.getChildContext != null) {
|
|
141
|
+
context = assign({}, context, component.getChildContext());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const isTopLevelFragment = rendered != null && rendered.type === Fragment
|
|
145
|
+
&& rendered.key == null;
|
|
146
|
+
rendered = isTopLevelFragment ? rendered.props.children : rendered;
|
|
147
|
+
// A Suspense boundary owns the IDs allocated while rendering its children,
|
|
148
|
+
// as well as the entries added to the enclosing commit collectors.
|
|
149
|
+
const checkpoint = component && component.__c
|
|
150
|
+
? {
|
|
151
|
+
rootSubtreeHandlesLength: result.rootSubtreeHandles.length,
|
|
152
|
+
subtreeHandlesLength: subtreeHandles?.length,
|
|
153
|
+
listItemUidsLength: listItemUids?.length,
|
|
154
|
+
nextId: getNextElementTemplateId(),
|
|
155
|
+
pageAttributes: result.pageAttributes,
|
|
156
|
+
isInsideAuthoredPage: result.isInsideAuthoredPage,
|
|
157
|
+
}
|
|
158
|
+
: undefined;
|
|
159
|
+
try {
|
|
160
|
+
renderVNode(rendered, context, vnode, output, result, parentType, subtreeHandles, listItemUids);
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
if (checkpoint && e && typeof e === 'object' && e.then) {
|
|
164
|
+
component.setState({ /* _suspended */ __a: true });
|
|
165
|
+
rendered = renderClassComponent(vnode, context, context);
|
|
166
|
+
output.length = outputLength;
|
|
167
|
+
result.rootSubtreeHandles.length = checkpoint.rootSubtreeHandlesLength;
|
|
168
|
+
if (subtreeHandles)
|
|
169
|
+
subtreeHandles.length = checkpoint.subtreeHandlesLength;
|
|
170
|
+
if (listItemUids)
|
|
171
|
+
listItemUids.length = checkpoint.listItemUidsLength;
|
|
172
|
+
discardRenderedHostsSince(checkpoint.nextId);
|
|
173
|
+
result.pageAttributes = checkpoint.pageAttributes;
|
|
174
|
+
if (__DEV__)
|
|
175
|
+
result.isInsideAuthoredPage = checkpoint.isInsideAuthoredPage;
|
|
176
|
+
renderVNode(rendered, context, vnode, output, result, parentType, subtreeHandles, listItemUids);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw e;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
cleanupVNode(vnode);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** The `.render()` method for a PFC backing instance. */
|
|
187
|
+
function doRender(props, state, context) {
|
|
188
|
+
return this.constructor(props, context);
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=render-components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-components.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-components.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;GAIG;AAEH,cAAc;AAEd,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,SAAS,EACT,eAAe,EACf,IAAI,EACJ,KAAK,EACL,MAAM,EACN,cAAc,EACd,UAAU,EACV,MAAM,EACN,MAAM,EACN,YAAY,EACZ,KAAK,GACN,MAAM,qCAAqC,CAAC;AAE7C,8CAA8C;AAE9C,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC;AAE7C,2CAA2C;AAC3C,MAAM,CAAC,IAAI,UAAkD,CAAC;AAC9D,MAAM,CAAC,IAAI,WAAqF,CAAC;AACjG,IAAI,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC;AAEvC,MAAM,UAAU,eAAe,CAC7B,KAAc,EACd,OAAgB,EAChB,MAAiB,EACj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,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAClG,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAED,yDAAyD;AACzD,SAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO;IACrC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
package/runtime/lib/element-template/runtime/render/{render-opcodes.d.ts → render-direct.d.ts}
RENAMED
|
@@ -5,4 +5,6 @@ export interface MainThreadCreateResult {
|
|
|
5
5
|
rootRefs: ElementTemplateHandle[];
|
|
6
6
|
rootSubtreeHandles: MainThreadDynamicAttrSubtreeHandle[][];
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
type RenderContext = Record<string, unknown>;
|
|
9
|
+
export declare function renderToElementTemplate(vnode: unknown, context?: RenderContext | null): MainThreadCreateResult;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { createRenderedHost, discardRenderedHostsSince } from './create-rendered-host.js';
|
|
5
|
+
import { EMPTY_OBJ, beforeDiff, beforeDiff2, cleanupVNode, renderComponentVNode, renderWithHooks, } from './render-components.js';
|
|
6
|
+
import { CHILDREN, PARENT } from '../../../shared/render-constants.js';
|
|
7
|
+
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID } from '../../protocol/page.js';
|
|
8
|
+
import { clearPendingElementTemplateListItems } from '../list/list.js';
|
|
9
|
+
import { __ElementTemplatePage } from '../page/authored-page.js';
|
|
10
|
+
import { createElementTemplateWithReservedHandle, getNextElementTemplateId, reserveElementTemplateId, } from '../template/handle.js';
|
|
11
|
+
import { prepareTypedElementAttributes } from '../template/typed-attributes.js';
|
|
12
|
+
const isArray = /* @__PURE__ */ Array.isArray;
|
|
13
|
+
export function renderToElementTemplate(vnode, context) {
|
|
14
|
+
const checkpoint = getNextElementTemplateId();
|
|
15
|
+
const result = {
|
|
16
|
+
pageAttributes: undefined,
|
|
17
|
+
rootRefs: [],
|
|
18
|
+
rootSubtreeHandles: [],
|
|
19
|
+
};
|
|
20
|
+
if (__DEV__) {
|
|
21
|
+
result.isInsideAuthoredPage = false;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
/* #__NOINLINE__ */ renderWithHooks(vnode, context, result.rootRefs, renderDirect, result);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
discardRenderedHostsSince(checkpoint);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
// Completed lists consume their item records. Anything left belongs to
|
|
32
|
+
// abandoned content, including children discarded by Suspense.
|
|
33
|
+
clearPendingElementTemplateListItems();
|
|
34
|
+
}
|
|
35
|
+
result.pageAttributes ??= null;
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function validateRoot(result, parentType) {
|
|
39
|
+
if (parentType === undefined && result.pageAttributes !== undefined
|
|
40
|
+
&& !result.isInsideAuthoredPage) {
|
|
41
|
+
throw new Error('Element Template authored <page /> must wrap all materialized roots.');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function renderHost(vnode, context, output, result, parentType, parentSubtreeHandles, parentListItemUids) {
|
|
45
|
+
const type = vnode.type;
|
|
46
|
+
const props = vnode.templateKey === undefined ? vnode.props : vnode;
|
|
47
|
+
const isList = type === 'list';
|
|
48
|
+
const attributes = (isList ? props['attributes'] : props['attributeSlots']);
|
|
49
|
+
const listItemPlatformInfo = props['__listItemPlatformInfo'];
|
|
50
|
+
let deferredListItemMarker = false;
|
|
51
|
+
if (__DEV__) {
|
|
52
|
+
deferredListItemMarker = props['isReady'] !== undefined;
|
|
53
|
+
validateRoot(result, parentType);
|
|
54
|
+
}
|
|
55
|
+
if (!isList && !(type.startsWith('_et_') || type.includes(':_et_'))) {
|
|
56
|
+
cleanupVNode(vnode);
|
|
57
|
+
throw new Error(`Element Template main-thread renderer received an uncompiled host vnode: ${type}`);
|
|
58
|
+
}
|
|
59
|
+
// Recursive locals retain the inputs until children finish. Only native
|
|
60
|
+
// child arrays and the root/list-item ref collector survive this call.
|
|
61
|
+
const subtreeHandles = parentType === undefined || parentType === 'list' ? [] : parentSubtreeHandles;
|
|
62
|
+
let childSlots;
|
|
63
|
+
let listItemUids;
|
|
64
|
+
if (isList) {
|
|
65
|
+
try {
|
|
66
|
+
if (__DEV__) {
|
|
67
|
+
for (const name in props) {
|
|
68
|
+
if (name.startsWith('$') && name !== '$0') {
|
|
69
|
+
throw new Error('Element Template typed list only supports logical slot $0.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const children = props['$0'];
|
|
74
|
+
if (children != null && children !== true && children !== false) {
|
|
75
|
+
const refs = [];
|
|
76
|
+
childSlots = [refs];
|
|
77
|
+
listItemUids = [];
|
|
78
|
+
renderDirect(children, context, vnode, refs, result, type, subtreeHandles, listItemUids);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
cleanupVNode(vnode);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Ordered inputs belong to the caller. Named inputs are collected into a
|
|
87
|
+
// renderer-owned array that can also hold the resulting native refs.
|
|
88
|
+
let childrenBySlot = props['slotChildren'];
|
|
89
|
+
if (vnode.templateKey === undefined && childrenBySlot === undefined) {
|
|
90
|
+
for (const name in props) {
|
|
91
|
+
if (name.startsWith('$')) {
|
|
92
|
+
const children = props[name];
|
|
93
|
+
if (children == null || children === true || children === false)
|
|
94
|
+
continue;
|
|
95
|
+
(childrenBySlot ??= [])[+name.slice(1)] = children;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
childSlots = childrenBySlot;
|
|
99
|
+
}
|
|
100
|
+
if (childrenBySlot !== undefined) {
|
|
101
|
+
for (let slotId = 0; slotId < childrenBySlot.length; slotId++) {
|
|
102
|
+
const children = childrenBySlot[slotId];
|
|
103
|
+
if (children == null || children === true || children === false)
|
|
104
|
+
continue;
|
|
105
|
+
const refs = (childSlots ??= [])[slotId] = [];
|
|
106
|
+
renderDirect(children, context, vnode, refs, result, type, subtreeHandles, undefined);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
cleanupVNode(vnode);
|
|
110
|
+
}
|
|
111
|
+
if (__DEV__ && !isList && parentType === 'list') {
|
|
112
|
+
if (deferredListItemMarker) {
|
|
113
|
+
throw new Error('Element Template typed list does not support deferred list items.');
|
|
114
|
+
}
|
|
115
|
+
if (listItemPlatformInfo === undefined) {
|
|
116
|
+
throw new Error('Element Template typed list received a non-list-item root in logical slot $0.');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const uid = reserveElementTemplateId();
|
|
120
|
+
const ref = /* #__NOINLINE__ */ createRenderedHost(uid, type, attributes, childSlots, listItemUids, subtreeHandles, listItemPlatformInfo, vnode.templateKey === undefined ? undefined : vnode);
|
|
121
|
+
output.push(ref);
|
|
122
|
+
if (parentType === undefined) {
|
|
123
|
+
result.rootSubtreeHandles.push(isList ? [] : subtreeHandles);
|
|
124
|
+
}
|
|
125
|
+
else if (parentListItemUids !== undefined) {
|
|
126
|
+
parentListItemUids.push(uid);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function renderDirect(value, context, parent, output, result, parentType, subtreeHandles, listItemUids) {
|
|
130
|
+
if (value == null || value === true || value === false || value === '')
|
|
131
|
+
return;
|
|
132
|
+
if (typeof value !== 'object') {
|
|
133
|
+
if (typeof value === 'function')
|
|
134
|
+
return;
|
|
135
|
+
if (__DEV__) {
|
|
136
|
+
validateRoot(result, parentType);
|
|
137
|
+
if (parentType === 'list') {
|
|
138
|
+
throw new Error('Element Template typed list received text logical child.');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
output.push(createElementTemplateWithReservedHandle(reserveElementTemplateId(), '_et_builtin_raw_text', null, [value + ''], []));
|
|
142
|
+
if (parentType === undefined)
|
|
143
|
+
result.rootSubtreeHandles.push([]);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (isArray(value)) {
|
|
147
|
+
parent[CHILDREN] = value;
|
|
148
|
+
for (let index = 0; index < value.length; index++) {
|
|
149
|
+
const child = value[index];
|
|
150
|
+
if (child == null || typeof child === 'boolean')
|
|
151
|
+
continue;
|
|
152
|
+
renderDirect(child, context, parent, output, result, parentType, subtreeHandles, listItemUids);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const vnode = value;
|
|
157
|
+
vnode[PARENT] = parent;
|
|
158
|
+
if (beforeDiff)
|
|
159
|
+
beforeDiff(vnode);
|
|
160
|
+
if (beforeDiff2)
|
|
161
|
+
beforeDiff2(vnode, EMPTY_OBJ);
|
|
162
|
+
const type = vnode.type;
|
|
163
|
+
const props = vnode.props;
|
|
164
|
+
if (typeof type === 'function') {
|
|
165
|
+
if (type === __ElementTemplatePage) {
|
|
166
|
+
if (__DEV__) {
|
|
167
|
+
if (parentType !== undefined) {
|
|
168
|
+
throw new Error('Element Template authored <page /> must be the outermost element.');
|
|
169
|
+
}
|
|
170
|
+
if (result.pageAttributes !== undefined) {
|
|
171
|
+
throw new Error('Element Template does not support multiple authored <page /> elements.');
|
|
172
|
+
}
|
|
173
|
+
if (result.rootRefs.length !== 0) {
|
|
174
|
+
throw new Error('Element Template authored <page /> must wrap all materialized roots.');
|
|
175
|
+
}
|
|
176
|
+
result.isInsideAuthoredPage = true;
|
|
177
|
+
}
|
|
178
|
+
result.pageAttributes = prepareTypedElementAttributes(ELEMENT_TEMPLATE_PAGE_HANDLE_ID, props['attributes']);
|
|
179
|
+
}
|
|
180
|
+
/* #__NOINLINE__ */ renderComponentVNode(vnode, type, props, context, output, renderDirect, result, parentType, subtreeHandles, listItemUids);
|
|
181
|
+
if (__DEV__ && type === __ElementTemplatePage)
|
|
182
|
+
result.isInsideAuthoredPage = false;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (typeof type === 'string') {
|
|
186
|
+
/* #__NOINLINE__ */ renderHost(vnode, context, output, result, parentType, subtreeHandles, listItemUids);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (__DEV__) {
|
|
190
|
+
cleanupVNode(vnode);
|
|
191
|
+
throw new Error('Element Template main-thread renderer received an invalid vnode.');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=render-direct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-direct.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-direct.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAG1F,OAAO,EACL,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,EAAE,oCAAoC,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,uCAAuC,EACvC,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAuBhF,MAAM,OAAO,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AAC;QACF,IAAI,OAAO,IAAI,IAAI,KAAK,qBAAqB;YAAE,MAAM,CAAC,oBAAoB,GAAG,KAAK,CAAC;QACnF,OAAO;IACT,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,mBAAmB,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QACzG,OAAO;IACT,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Implements the IFR (Instant First-Frame Rendering) on main thread.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { render as renderToString } from './render-to-opcodes.js';
|
|
7
|
+
import { renderToElementTemplate } from './render-direct.js';
|
|
9
8
|
import { getReloadVersion } from '../../../core/reload-version.js';
|
|
10
9
|
import { profileEnd, profileStart } from '../../debug/profile.js';
|
|
11
10
|
import { ElementTemplateLifecycleConstant } from '../../protocol/lifecycle-constant.js';
|
|
@@ -17,21 +16,23 @@ import { insertElementTemplateSubtree } from '../template/handle.js';
|
|
|
17
16
|
import { getElementTemplateNativeRef } from '../template/registry.js';
|
|
18
17
|
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';
|
|
19
18
|
function renderMainThread() {
|
|
20
|
-
let
|
|
19
|
+
let rendered;
|
|
21
20
|
profileStart('ReactLynx::renderMainThread');
|
|
22
21
|
try {
|
|
23
|
-
|
|
22
|
+
rendered = renderToElementTemplate(__root.__jsx, undefined);
|
|
24
23
|
}
|
|
25
|
-
catch (
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
catch (error) {
|
|
25
|
+
// Like Snapshot, any failure during synchronous rendering is reported at
|
|
26
|
+
// the lifecycle boundary before committing an empty result.
|
|
27
|
+
lynx.reportError(error);
|
|
28
|
+
rendered = { pageAttributes: null, rootRefs: [], rootSubtreeHandles: [] };
|
|
28
29
|
}
|
|
29
30
|
finally {
|
|
30
31
|
profileEnd();
|
|
31
32
|
}
|
|
32
|
-
profileStart('ReactLynx::
|
|
33
|
+
profileStart('ReactLynx::commitElementTemplate');
|
|
33
34
|
try {
|
|
34
|
-
const { pageAttributes, rootRefs, rootSubtreeHandles } =
|
|
35
|
+
const { pageAttributes, rootRefs, rootSubtreeHandles } = rendered;
|
|
35
36
|
__SetAttributeOfElementTemplate(__page, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, pageAttributes);
|
|
36
37
|
for (let index = 0; index < rootRefs.length; index += 1) {
|
|
37
38
|
const rootRef = rootRefs[index];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-main-thread.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;GAEG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"render-main-thread.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,qCAAqC,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,sCAAsC,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,MAA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AAC;QACT,UAAU,EAAE,CAAC;IACf,CAAC;IAED,YAAY,CAAC,qCAAqC,CAAC,CAAC;IACpD,IAAI,CAAC;QACH,MAAM,OAAO,GAAwC;YACnD,IAAI,EAAE,0BAA0B,CAAC,MAAM,CAAuB;YAC9D,aAAa,EAAE,gBAAgB,EAAE;SAClC,CAAC;QAEF,IAAI,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC;YAChC,IAAI,EAAE,gCAAgC,CAAC,OAAO;YAC9C,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,UAAU,EAAE,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,OAAO,GAAG,sCAAsC,EAAE,CAAC;IACzD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,2BAA2B,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxD,IAAI,OAAO,EAAE,CAAC;YACZ,+BAA+B,CAAC,OAAO,EAAE,mCAAmC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { MainThreadDynamicAttrSubtreeHandle } from './main-thread-dynamic-attr-state.js';
|
|
2
2
|
import type { RuntimeChildSlots, RuntimeOptions, RuntimeTypedElementAttributes, RuntimeTypedListOptions, SerializableValue } from '../../protocol/types.js';
|
|
3
|
+
export declare function getNextElementTemplateId(): number;
|
|
3
4
|
export declare function reserveElementTemplateId(): number;
|
|
4
|
-
export declare function createElementTemplateWithReservedHandle(handleId: number, templateKey: string, bundleUrl: string | null | undefined, attributeSlots: SerializableValue[] | null | undefined, childSlots: RuntimeChildSlots | null | undefined): ElementTemplateHandle;
|
|
5
|
+
export declare function createElementTemplateWithReservedHandle(handleId: number, templateKey: string, bundleUrl: string | null | undefined, attributeSlots: SerializableValue[] | null | undefined, childSlots: RuntimeChildSlots | null | undefined, hasDynamicAttributes?: boolean): ElementTemplateHandle;
|
|
5
6
|
export declare function createTypedElementTemplateWithReservedHandle(handleId: number, type: string, attributes: RuntimeTypedElementAttributes | null | undefined, childSlots: RuntimeChildSlots | null | undefined, options: RuntimeOptions | RuntimeTypedListOptions | null | undefined): ElementTemplateHandle;
|
|
6
7
|
export declare function insertElementTemplateSubtree(targetRef: ElementTemplateHandle, childSlotIndex: number, childRef: ElementTemplateHandle, referenceRef: ElementTemplateHandle | null, subtreeHandles: readonly MainThreadDynamicAttrSubtreeHandle[] | null): void;
|
|
7
8
|
export declare function resetTemplateId(): void;
|