@lynx-js/react 0.125.0 → 0.126.1
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 +63 -0
- package/LICENSE +202 -0
- package/components/.gitignore +3 -0
- package/components/.npmignore +5 -0
- package/components/lib/Page.js +4 -2
- package/components/lib/Page.js.map +1 -1
- package/components/src/Page.ts +4 -2
- package/components/tsconfig.json +17 -0
- package/components/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -2
- package/refresh/.gitignore +1 -0
- package/refresh/.npmignore +3 -0
- package/refresh/.turbo/turbo-build.log +9 -0
- package/refresh/package.json +21 -0
- package/refresh/rslib.config.ts +24 -0
- package/refresh/tsconfig.json +4 -0
- package/refresh/turbo.json +16 -0
- package/runtime/.gitignore +4 -0
- package/runtime/.npmignore +15 -0
- package/runtime/.prettierrc +6 -0
- package/runtime/.turbo/turbo-build.log +1 -0
- package/runtime/CHANGELOG.md +7 -0
- package/runtime/__test__/core/background-function.test.ts +133 -0
- package/runtime/__test__/core/commit-context.test.ts +37 -0
- package/runtime/__test__/core/forceRootRender.test.ts +65 -0
- package/runtime/__test__/core/globalProps.test.ts +141 -0
- package/runtime/__test__/core/hooks/mainThread.test.tsx +279 -0
- package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +168 -0
- package/runtime/__test__/core/lynx-data-processors.test.ts +131 -0
- package/runtime/__test__/core/lynx-page-data.test.ts +62 -0
- package/runtime/__test__/core/lynx-update-data.test.ts +97 -0
- package/runtime/__test__/core/main-thread-function.test.ts +13 -0
- package/runtime/__test__/core/main-thread-ref.test.ts +102 -0
- package/runtime/__test__/core/ref.test.ts +261 -0
- package/runtime/__test__/core/reload-version.test.ts +14 -0
- package/runtime/__test__/core/thread-function-call.test.ts +182 -0
- package/runtime/__test__/element-template/debug/alog.test.ts +214 -0
- package/runtime/__test__/element-template/debug/elementPAPICall.test.ts +157 -0
- package/runtime/__test__/element-template/debug/profile-hook.test.tsx +67 -0
- package/runtime/__test__/element-template/debug/profile-installation.test.tsx +49 -0
- package/runtime/__test__/element-template/fixtures/background/event/conditional-direct-event/index.tsx +8 -0
- package/runtime/__test__/element-template/fixtures/background/event/direct-event/index.tsx +7 -0
- package/runtime/__test__/element-template/fixtures/background/event/main-thread-direct-event/index.tsx +11 -0
- package/runtime/__test__/element-template/fixtures/background/event/main-thread-run-on-background-event/index.tsx +14 -0
- package/runtime/__test__/element-template/fixtures/background/event/spread-event/index.tsx +20 -0
- package/runtime/__test__/element-template/fixtures/background/global-props/direct-read/index.tsx +7 -0
- package/runtime/__test__/element-template/fixtures/background/global-props/event-hook/index.tsx +34 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsx +584 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/output.txt +11 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/output.txt +12 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/output.txt +13 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/output.txt +12 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/output.txt +10 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/output.txt +13 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/output.txt +13 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/output.txt +10 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/output.txt +3 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/output.txt +13 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/output.txt +10 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txt +39 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txt +16 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txt +3 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/output.txt +11 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txt +16 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/output.txt +4 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txt +12 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txt +10 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txt +10 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/output.txt +22 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/output.txt +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/root-key-mismatch-reconciles/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/root-key-mismatch-reconciles/output.txt +24 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/output.txt +5 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/index.tsx +14 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt +20 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/index.tsx +39 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt +20 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/index.tsx +38 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt +29 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/index.tsx +40 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/output.txt +12 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/index.tsx +14 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +22 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/index.tsx +14 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/output.txt +13 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/index.tsx +34 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/output.txt +12 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/index.tsx +18 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt +16 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/index.tsx +33 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt +26 -0
- package/runtime/__test__/element-template/fixtures/background/init-data/update/index.tsx +11 -0
- package/runtime/__test__/element-template/fixtures/background/instance/_shared.ts +30 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/does-not-emit-patch-when-attrs-reference-reused/case.ts +24 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/does-not-emit-patch-when-attrs-reference-reused/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/emits-bundle-url-in-create-template/case.ts +11 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/emits-bundle-url-in-create-template/output.txt +8 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/case.ts +11 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-non-object-attrs-entry-as-empty-object/case.ts +23 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-non-object-attrs-entry-as-empty-object/output.txt +6 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/case.ts +23 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/output.txt +6 -0
- package/runtime/__test__/element-template/fixtures/background/main-thread-function/run-on-main-thread/index.tsx +24 -0
- package/runtime/__test__/element-template/fixtures/background/ref/direct-ref/index.tsx +7 -0
- package/runtime/__test__/element-template/fixtures/background/ref/multi-ref/index.tsx +20 -0
- package/runtime/__test__/element-template/fixtures/background/ref/spread-ref/index.tsx +14 -0
- package/runtime/__test__/element-template/fixtures/background/ref/unsupported-ref/index.tsx +12 -0
- package/runtime/__test__/element-template/fixtures/background/render/_shared.tsx +85 -0
- package/runtime/__test__/element-template/fixtures/background/render/constructs-shadow-tree/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/render/constructs-shadow-tree/output.txt +7 -0
- package/runtime/__test__/element-template/fixtures/background/render/supports-slot-component-materiality/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/background/render/supports-slot-component-materiality/output.txt +13 -0
- package/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-list/index.tsx +15 -0
- package/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-subtree-list/index.tsx +19 -0
- package/runtime/__test__/element-template/fixtures/background/update/sparse/compiled-element-slot/index.tsx +26 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/_shared.tsx +169 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/output.txt +14 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/output.txt +8 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/output.txt +10 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/output.txt +28 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/source.tsx +15 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/case.tsx +5 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/output.txt +19 -0
- package/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/source.tsx +8 -0
- package/runtime/__test__/element-template/fixtures/page/render-page/case.tsx +41 -0
- package/runtime/__test__/element-template/fixtures/page/render-page/native-log.txt +31 -0
- package/runtime/__test__/element-template/fixtures/page/render-page/output.txt +5 -0
- package/runtime/__test__/element-template/fixtures/page-compiled/authored-page/index.tsx +67 -0
- package/runtime/__test__/element-template/fixtures/patch/_shared.tsx +270 -0
- package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/after-jsx.txt +7 -0
- package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/before-jsx.txt +8 -0
- package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/case.tsx +100 -0
- package/runtime/__test__/element-template/fixtures/patch/props-update/after-jsx.txt +3 -0
- package/runtime/__test__/element-template/fixtures/patch/props-update/before-jsx.txt +3 -0
- package/runtime/__test__/element-template/fixtures/patch/props-update/case.tsx +42 -0
- package/runtime/__test__/element-template/fixtures/patch/props-update/ops.txt +8 -0
- package/runtime/__test__/element-template/fixtures/patch/state-update/after-jsx.txt +3 -0
- package/runtime/__test__/element-template/fixtures/patch/state-update/before-jsx.txt +3 -0
- package/runtime/__test__/element-template/fixtures/patch/state-update/case.tsx +64 -0
- package/runtime/__test__/element-template/fixtures/patch/state-update/ops.txt +8 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/after-jsx.txt +7 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/before-jsx.txt +6 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/index.tsx +39 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/ops.txt +14 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/after-jsx.txt +10 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/before-jsx.txt +9 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/index.tsx +47 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/ops.txt +34 -0
- package/runtime/__test__/element-template/fixtures/render/child-siblings/index.js.txt +21 -0
- package/runtime/__test__/element-template/fixtures/render/child-siblings/index.tsx +16 -0
- package/runtime/__test__/element-template/fixtures/render/child-siblings/output.txt +8 -0
- package/runtime/__test__/element-template/fixtures/render/child-siblings/papi.txt +128 -0
- package/runtime/__test__/element-template/fixtures/render/child-siblings/templates.json.txt +66 -0
- package/runtime/__test__/element-template/fixtures/render/component/index.js.txt +12 -0
- package/runtime/__test__/element-template/fixtures/render/component/index.tsx +17 -0
- package/runtime/__test__/element-template/fixtures/render/component/output.txt +7 -0
- package/runtime/__test__/element-template/fixtures/render/component/papi.txt +67 -0
- package/runtime/__test__/element-template/fixtures/render/component/templates.json.txt +68 -0
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/index.js.txt +16 -0
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/index.tsx +18 -0
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/output.txt +6 -0
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/papi.txt +85 -0
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/templates.json.txt +78 -0
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/fixture.config.json +5 -0
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/index.js.txt +6 -0
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/index.tsx +9 -0
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/output.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/papi.txt +25 -0
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/templates.json.txt +57 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/index.js.txt +18 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/index.tsx +13 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/output.txt +17 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/papi.txt +214 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/templates.json.txt +63 -0
- package/runtime/__test__/element-template/fixtures/render/mixed-children/index.js.txt +15 -0
- package/runtime/__test__/element-template/fixtures/render/mixed-children/index.tsx +15 -0
- package/runtime/__test__/element-template/fixtures/render/mixed-children/output.txt +7 -0
- package/runtime/__test__/element-template/fixtures/render/mixed-children/papi.txt +86 -0
- package/runtime/__test__/element-template/fixtures/render/mixed-children/templates.json.txt +51 -0
- package/runtime/__test__/element-template/fixtures/render/multiple-text/index.js.txt +23 -0
- package/runtime/__test__/element-template/fixtures/render/multiple-text/index.tsx +22 -0
- package/runtime/__test__/element-template/fixtures/render/multiple-text/output.txt +38 -0
- package/runtime/__test__/element-template/fixtures/render/multiple-text/papi.txt +454 -0
- package/runtime/__test__/element-template/fixtures/render/multiple-text/templates.json.txt +131 -0
- package/runtime/__test__/element-template/fixtures/render/nested-templates/index.js.txt +19 -0
- package/runtime/__test__/element-template/fixtures/render/nested-templates/index.tsx +19 -0
- package/runtime/__test__/element-template/fixtures/render/nested-templates/output.txt +5 -0
- package/runtime/__test__/element-template/fixtures/render/nested-templates/papi.txt +80 -0
- package/runtime/__test__/element-template/fixtures/render/nested-templates/templates.json.txt +34 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/_shared.ts +131 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/appends-root-text-via-append-element/case.ts +19 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/appends-root-text-via-append-element/native-log.txt +27 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/appends-root-text-via-append-element/output.txt +12 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/creates-template-from-attrs-and-slot-text/case.ts +39 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/creates-template-from-attrs-and-slot-text/native-log.txt +49 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/creates-template-from-attrs-and-slot-text/output.txt +34 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-template-children-in-the-same-slot/case.ts +34 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-template-children-in-the-same-slot/native-log.txt +56 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-template-children-in-the-same-slot/output.txt +11 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-text-nodes-in-the-same-slot/case.ts +29 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-text-nodes-in-the-same-slot/native-log.txt +64 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-text-nodes-in-the-same-slot/output.txt +20 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/inserts-nested-templates-into-parent-slots/case.ts +42 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/inserts-nested-templates-into-parent-slots/native-log.txt +84 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/inserts-nested-templates-into-parent-slots/output.txt +42 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/keeps-slot-children-separated-and-ordered/case.ts +31 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/keeps-slot-children-separated-and-ordered/native-log.txt +66 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/keeps-slot-children-separated-and-ordered/output.txt +41 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/passes-bundle-url-to-native-create/case.ts +20 -0
- package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/passes-bundle-url-to-native-create/native-log.txt +25 -0
- package/runtime/__test__/element-template/fixtures/render/react-example/index.js.txt +39 -0
- package/runtime/__test__/element-template/fixtures/render/react-example/index.tsx +51 -0
- package/runtime/__test__/element-template/fixtures/render/react-example/output.txt +24 -0
- package/runtime/__test__/element-template/fixtures/render/react-example/papi.txt +70 -0
- package/runtime/__test__/element-template/fixtures/render/react-example/templates.json.txt +280 -0
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/index.js.txt +14 -0
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/index.tsx +17 -0
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/output.txt +10 -0
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/papi.txt +81 -0
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/templates.json.txt +97 -0
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/index.js.txt +28 -0
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/index.tsx +28 -0
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/output.txt +12 -0
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/papi.txt +144 -0
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/templates.json.txt +57 -0
- package/runtime/__test__/element-template/imports/global-props-api.test.ts +23 -0
- package/runtime/__test__/element-template/imports/init-data-api.test.ts +19 -0
- package/runtime/__test__/element-template/imports/jsx-runtime.test.ts +76 -0
- package/runtime/__test__/element-template/imports/legacy-react-runtime.test.ts +100 -0
- package/runtime/__test__/element-template/imports/main-thread-ref-api.test.ts +10 -0
- package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +415 -0
- package/runtime/__test__/element-template/imports/register-data-processors.test.ts +34 -0
- package/runtime/__test__/element-template/imports/suspense-lazy.test.ts +295 -0
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +35 -0
- package/runtime/__test__/element-template/lynx/env.test.ts +242 -0
- package/runtime/__test__/element-template/lynx/lazy-bundle.test.ts +294 -0
- package/runtime/__test__/element-template/lynx/performance.test.ts +161 -0
- package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +107 -0
- package/runtime/__test__/element-template/native/index.test.ts +224 -0
- package/runtime/__test__/element-template/native/init-timing-api.test.ts +29 -0
- package/runtime/__test__/element-template/native/main-thread-api.test.ts +202 -0
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +226 -0
- package/runtime/__test__/element-template/native/reload.test.ts +588 -0
- package/runtime/__test__/element-template/runtime/background/adapter/background-adapter.et.test.tsx +65 -0
- package/runtime/__test__/element-template/runtime/background/commit-context.test.ts +91 -0
- package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +800 -0
- package/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +867 -0
- package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +220 -0
- package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +173 -0
- package/runtime/__test__/element-template/runtime/background/hydrate/compiled-fixtures.test.ts +43 -0
- package/runtime/__test__/element-template/runtime/background/hydrate/fixtures.test.ts +16 -0
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +2179 -0
- package/runtime/__test__/element-template/runtime/background/init-data/compiled-fixtures.test.tsx +129 -0
- package/runtime/__test__/element-template/runtime/background/instance/fixtures.test.ts +16 -0
- package/runtime/__test__/element-template/runtime/background/instance.test.ts +2751 -0
- package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +287 -0
- package/runtime/__test__/element-template/runtime/background/manager.test.ts +142 -0
- package/runtime/__test__/element-template/runtime/background/page-root-hydrate.test.ts +75 -0
- package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +339 -0
- package/runtime/__test__/element-template/runtime/background/reload.test.ts +79 -0
- package/runtime/__test__/element-template/runtime/background/render/fixtures.test.ts +16 -0
- package/runtime/__test__/element-template/runtime/background/render/preact.test.tsx +268 -0
- package/runtime/__test__/element-template/runtime/background/root-render.test.tsx +265 -0
- package/runtime/__test__/element-template/runtime/background/suspense.test.tsx +940 -0
- package/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx +277 -0
- package/runtime/__test__/element-template/runtime/background/update/sparse-fixtures.test.tsx +163 -0
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +127 -0
- package/runtime/__test__/element-template/runtime/hydration/fixtures.test.ts +16 -0
- package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +1249 -0
- package/runtime/__test__/element-template/runtime/page/authored-page.test.ts +35 -0
- package/runtime/__test__/element-template/runtime/page/compiled-fixtures.test.tsx +560 -0
- package/runtime/__test__/element-template/runtime/page/fixtures.test.ts +16 -0
- package/runtime/__test__/element-template/runtime/page/page.test.ts +25 -0
- package/runtime/__test__/element-template/runtime/page/root-instance.test.ts +25 -0
- package/runtime/__test__/element-template/runtime/patch/compiled-fixtures.test.ts +40 -0
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +3704 -0
- package/runtime/__test__/element-template/runtime/patch/fixtures.test.ts +16 -0
- package/runtime/__test__/element-template/runtime/patch/patch-listener-alog.test.ts +80 -0
- package/runtime/__test__/element-template/runtime/patch/update-fixture-helper.test.tsx +40 -0
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +203 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/event.test.ts +183 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts +246 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/ref.test.ts +155 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +160 -0
- package/runtime/__test__/element-template/runtime/protocol/template-type.test.ts +40 -0
- package/runtime/__test__/element-template/runtime/render/fixtures.test.ts +18 -0
- package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +143 -0
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +377 -0
- package/runtime/__test__/element-template/runtime/render/render-opcodes-into-element-template.et.test.tsx +791 -0
- package/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx +522 -0
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +564 -0
- package/runtime/__test__/element-template/runtime/template/element-template-attr-slot-plan.test.ts +373 -0
- package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +228 -0
- package/runtime/__test__/element-template/runtime/template/element-template-registry.test.ts +65 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +567 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-function.test.ts +280 -0
- package/runtime/__test__/element-template/test-utils/debug/compiledFixtureApp.ts +26 -0
- package/runtime/__test__/element-template/test-utils/debug/compiledFixtureCompiler.ts +76 -0
- package/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts +74 -0
- package/runtime/__test__/element-template/test-utils/debug/compiledFixtureRegistry.ts +22 -0
- package/runtime/__test__/element-template/test-utils/debug/compiledHydrationScenario.ts +82 -0
- package/runtime/__test__/element-template/test-utils/debug/compiledThreadRunner.ts +70 -0
- package/runtime/__test__/element-template/test-utils/debug/envManager.ts +96 -0
- package/runtime/__test__/element-template/test-utils/debug/fixtureRunner.ts +284 -0
- package/runtime/__test__/element-template/test-utils/debug/hydrate.ts +23 -0
- package/runtime/__test__/element-template/test-utils/debug/registry.ts +43 -0
- package/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts +337 -0
- package/runtime/__test__/element-template/test-utils/debug/serializer.ts +79 -0
- package/runtime/__test__/element-template/test-utils/debug/updateRunner.test.tsx +148 -0
- package/runtime/__test__/element-template/test-utils/debug/updateRunner.ts +303 -0
- package/runtime/__test__/element-template/test-utils/mock/globals.js +35 -0
- package/runtime/__test__/element-template/test-utils/mock/jscontext-mock.test.ts +142 -0
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/context.ts +305 -0
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.test.ts +187 -0
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.ts +745 -0
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +432 -0
- package/runtime/__test__/element-template/test-utils/mock/performance.js +68 -0
- package/runtime/__test__/element-template/test-utils/setup.js +100 -0
- package/runtime/__test__/element-template/vitest.config.ts +128 -0
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +198 -0
- package/runtime/__test__/shared/profile.test.ts +88 -0
- package/runtime/__test__/snapshot/alog/elementPAPICall.test.js +50 -0
- package/runtime/__test__/snapshot/attribute-name.test.ts +78 -0
- package/runtime/__test__/snapshot/basic.test.jsx +718 -0
- package/runtime/__test__/snapshot/children.test.jsx +476 -0
- package/runtime/__test__/snapshot/clone.test.jsx +959 -0
- package/runtime/__test__/snapshot/commit-context.test.ts +29 -0
- package/runtime/__test__/snapshot/compat/export.test.jsx +42 -0
- package/runtime/__test__/snapshot/compat/hooks.test.jsx +45 -0
- package/runtime/__test__/snapshot/compat/initData.test.jsx +195 -0
- package/runtime/__test__/snapshot/compat/use-insertion-effect.test.jsx +128 -0
- package/runtime/__test__/snapshot/compat/use.test.jsx +111 -0
- package/runtime/__test__/snapshot/compat.test.jsx +199 -0
- package/runtime/__test__/snapshot/createElement.test.jsx +1352 -0
- package/runtime/__test__/snapshot/createSuspender.jsx +26 -0
- package/runtime/__test__/snapshot/css/compat.test.jsx +164 -0
- package/runtime/__test__/snapshot/css/remove-scoped-lazy-bundle.test.jsx +40 -0
- package/runtime/__test__/snapshot/css/remove-scoped-main-bundle.test.jsx +27 -0
- package/runtime/__test__/snapshot/css/scoped-lazy-bundle.test.jsx +45 -0
- package/runtime/__test__/snapshot/css/scoped-main-bundle.test.jsx +36 -0
- package/runtime/__test__/snapshot/debug/backgroundSnapshot-profile.test.jsx +366 -0
- package/runtime/__test__/snapshot/debug/children-with-same-key.test.jsx +43 -0
- package/runtime/__test__/snapshot/debug/describeInvalidValue.test.ts +32 -0
- package/runtime/__test__/snapshot/debug/formatPatch.test.ts +89 -0
- package/runtime/__test__/snapshot/debug/hooks-in-render.test.jsx +13 -0
- package/runtime/__test__/snapshot/debug/hooks-invalid-args.test.jsx +42 -0
- package/runtime/__test__/snapshot/debug/jsx-twice.test.jsx +55 -0
- package/runtime/__test__/snapshot/debug/missing-suspense.test.jsx +35 -0
- package/runtime/__test__/snapshot/debug/object-as-child.test.jsx +35 -0
- package/runtime/__test__/snapshot/debug/printSnapshot.test.jsx +155 -0
- package/runtime/__test__/snapshot/debug/profile.test.jsx +348 -0
- package/runtime/__test__/snapshot/debug/react-hooks-profile.test.jsx +285 -0
- package/runtime/__test__/snapshot/debug/set-state-in-ctor.test.jsx +40 -0
- package/runtime/__test__/snapshot/debug/too-many-rerenders.test.jsx +33 -0
- package/runtime/__test__/snapshot/debug/undefined-component.test.jsx +40 -0
- package/runtime/__test__/snapshot/debug/vnodeSource.test.ts +120 -0
- package/runtime/__test__/snapshot/delayed-lifecycle-events.test.jsx +62 -0
- package/runtime/__test__/snapshot/dynamicPartType.test.jsx +690 -0
- package/runtime/__test__/snapshot/element.test.jsx +46 -0
- package/runtime/__test__/snapshot/event.test.jsx +1294 -0
- package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +86 -0
- package/runtime/__test__/snapshot/gesture/processGesture.test.ts +326 -0
- package/runtime/__test__/snapshot/gesture.test.jsx +1446 -0
- package/runtime/__test__/snapshot/hydrate.test.jsx +372 -0
- package/runtime/__test__/snapshot/jsx-runtime-lepus.test.jsx +89 -0
- package/runtime/__test__/snapshot/lazy.test.js +203 -0
- package/runtime/__test__/snapshot/legacySlot.legacy-slot.test.jsx +437 -0
- package/runtime/__test__/snapshot/lifecycle/commitHook.test.jsx +112 -0
- package/runtime/__test__/snapshot/lifecycle/destroy.test.jsx +47 -0
- package/runtime/__test__/snapshot/lifecycle/emptyPatch.test.jsx +104 -0
- package/runtime/__test__/snapshot/lifecycle/isRendering.test.jsx +114 -0
- package/runtime/__test__/snapshot/lifecycle/reload.test.jsx +1908 -0
- package/runtime/__test__/snapshot/lifecycle/reloadBG.jsx +79 -0
- package/runtime/__test__/snapshot/lifecycle/reloadMT.jsx +76 -0
- package/runtime/__test__/snapshot/lifecycle/resetPageDataError.test.jsx +79 -0
- package/runtime/__test__/snapshot/lifecycle/updateData.test.jsx +1688 -0
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +226 -0
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +382 -0
- package/runtime/__test__/snapshot/lifecycle.test.jsx +675 -0
- package/runtime/__test__/snapshot/list.test.jsx +4956 -0
- package/runtime/__test__/snapshot/lynx/component-compat.test.ts +188 -0
- package/runtime/__test__/snapshot/lynx/dynamic-import.test.ts +111 -0
- package/runtime/__test__/snapshot/lynx/injectLepusMethods.test.jsx +81 -0
- package/runtime/__test__/snapshot/lynx/lazy-bundle-fetchbundle.test.js +659 -0
- package/runtime/__test__/snapshot/lynx/lazy-bundle.test.js +576 -0
- package/runtime/__test__/snapshot/lynx/portals.test.jsx +677 -0
- package/runtime/__test__/snapshot/lynx/prepareLazyBundleMTS.test.js +212 -0
- package/runtime/__test__/snapshot/lynx/processEvalResult.test.js +23 -0
- package/runtime/__test__/snapshot/lynx/runtime-backend.test.ts +81 -0
- package/runtime/__test__/snapshot/lynx/suspense.test.jsx +1641 -0
- package/runtime/__test__/snapshot/lynx/timing.test.jsx +1011 -0
- package/runtime/__test__/snapshot/lynx-data-processors.test.ts +3 -0
- package/runtime/__test__/snapshot/lynxQueueMicrotask.test.jsx +38 -0
- package/runtime/__test__/snapshot/mtf-execid-churn.test.jsx +216 -0
- package/runtime/__test__/snapshot/page.test.jsx +417 -0
- package/runtime/__test__/snapshot/preact.test.jsx +930 -0
- package/runtime/__test__/snapshot/ref-parity.test.jsx +78 -0
- package/runtime/__test__/snapshot/ref.test.jsx +2368 -0
- package/runtime/__test__/snapshot/render.test.jsx +148 -0
- package/runtime/__test__/snapshot/renderToOpcodes.test.jsx +1618 -0
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +1798 -0
- package/runtime/__test__/snapshot/spread.test.jsx +771 -0
- package/runtime/__test__/snapshot/ssr.test.jsx +574 -0
- package/runtime/__test__/snapshot/use-main-thread.test.jsx +141 -0
- package/runtime/__test__/snapshot/utils/debug.js +41 -0
- package/runtime/__test__/snapshot/utils/envManager.ts +109 -0
- package/runtime/__test__/snapshot/utils/globals.js +224 -0
- package/runtime/__test__/snapshot/utils/inject.ts +31 -0
- package/runtime/__test__/snapshot/utils/jsModule.ts +49 -0
- package/runtime/__test__/snapshot/utils/nativeMethod.ts +498 -0
- package/runtime/__test__/snapshot/utils/runtimeProxy.test.js +36 -0
- package/runtime/__test__/snapshot/utils/runtimeProxy.ts +73 -0
- package/runtime/__test__/snapshot/utils/setup.js +72 -0
- package/runtime/__test__/snapshot/worklet/onPost.test.js +30 -0
- package/runtime/__test__/snapshot/worklet/runOnBackground.test.js +234 -0
- package/runtime/__test__/snapshot/worklet/runOnMainThread.test.jsx +402 -0
- package/runtime/__test__/snapshot/worklet/transform.test.js +35 -0
- package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +292 -0
- package/runtime/__test__/snapshot/workletEvent.test.jsx +1286 -0
- package/runtime/__test__/snapshot/workletLifecycle.test.ts +198 -0
- package/runtime/__test__/snapshot/workletRef.test.jsx +831 -0
- package/runtime/__test__/snapshot/workletRefBG.jsx +95 -0
- package/runtime/__test__/snapshot/workletRefMT.jsx +99 -0
- package/runtime/__test__/test-utils/lynx-event-emitter.ts +63 -0
- package/runtime/__test__/tsconfig.json +9 -0
- package/runtime/__test__/worklet-runtime/api/element.test.js +274 -0
- package/runtime/__test__/worklet-runtime/delayWorkletEvent.test.js +89 -0
- package/runtime/__test__/worklet-runtime/eventPropagation.test.js +89 -0
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +89 -0
- package/runtime/__test__/worklet-runtime/mainThreadFlushLoopGuard.test.js +235 -0
- package/runtime/__test__/worklet-runtime/observers.test.js +119 -0
- package/runtime/__test__/worklet-runtime/profile.test.js +27 -0
- package/runtime/__test__/worklet-runtime/runOnBackground.test.js +186 -0
- package/runtime/__test__/worklet-runtime/runOnMainThread.test.js +66 -0
- package/runtime/__test__/worklet-runtime/workletRef.test.js +328 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +534 -0
- package/runtime/compat/index.d.ts +48 -1
- package/runtime/compat/index.js +7 -3
- package/runtime/lazy/compat.js +2 -0
- package/runtime/lazy/element-template-internal.js +35 -0
- package/runtime/lazy/element-template-jsx-dev-runtime.js +19 -0
- package/runtime/lazy/element-template-jsx-runtime.js +14 -0
- package/runtime/lazy/element-template.js +53 -0
- package/runtime/lazy/internal.js +2 -1
- package/runtime/lepus/index.js +2 -2
- package/runtime/lepus/jsx-runtime/index.js +3 -8
- package/runtime/lib/core/component.js +3 -3
- package/runtime/lib/core/component.js.map +1 -1
- package/runtime/lib/core/forceRootRender.js +3 -2
- package/runtime/lib/core/forceRootRender.js.map +1 -1
- package/runtime/lib/core/globalProps.js +1 -1
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/core/hooks/mainThreadImpl.js +2 -0
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/main-thread-ref.js +1 -1
- package/runtime/lib/core/main-thread-ref.js.map +1 -1
- package/runtime/lib/core/ref.d.ts +7 -5
- package/runtime/lib/core/ref.js +22 -11
- package/runtime/lib/core/ref.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.d.ts +5 -1
- package/runtime/lib/element-template/background/attr-slots.js +17 -6
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-context.d.ts +1 -1
- package/runtime/lib/element-template/background/commit-context.js +8 -9
- package/runtime/lib/element-template/background/commit-context.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +60 -51
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +4 -1
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +34 -38
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +18 -10
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +7 -5
- package/runtime/lib/element-template/background/instance.js +79 -38
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/background/page-root-hydrate.js +1 -1
- package/runtime/lib/element-template/background/page-root-hydrate.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.d.ts +10 -4
- package/runtime/lib/element-template/debug/alog.js +22 -9
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/profile.js +2 -2
- package/runtime/lib/element-template/debug/profile.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +1 -0
- package/runtime/lib/element-template/internal.js +1 -0
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/jsx-runtime/index.d.ts +3 -1
- package/runtime/lib/element-template/jsx-runtime/index.js +2 -4
- package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js +1 -2
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +2 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +9 -7
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js +3 -3
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +15 -7
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +21 -3
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/ref.d.ts +3 -1
- package/runtime/lib/element-template/prop-adapters/ref.js +2 -2
- package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +1 -4
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +2 -0
- package/runtime/lib/element-template/protocol/opcodes.js +2 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +45 -22
- package/runtime/lib/element-template/runtime/list/list.d.ts +5 -5
- package/runtime/lib/element-template/runtime/list/list.js +8 -7
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/authored-page.js +17 -2
- package/runtime/lib/element-template/runtime/page/authored-page.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/page.d.ts +3 -3
- package/runtime/lib/element-template/runtime/page/page.js +1 -1
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +78 -50
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +7 -5
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-opcodes.d.ts +3 -1
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +47 -38
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +19 -17
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +3 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +39 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +5 -3
- package/runtime/lib/element-template/runtime/template/handle.js +14 -6
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +16 -7
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +133 -55
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +4 -0
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +30 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/registry.d.ts +6 -6
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -1
- package/runtime/lib/internal.js +1 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/shared/attribute-name.js +1 -2
- package/runtime/lib/shared/attribute-name.js.map +1 -1
- package/runtime/lib/shared/component-stack.js +2 -1
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/shared/render-constants.d.ts +4 -2
- package/runtime/lib/shared/render-constants.js +6 -2
- package/runtime/lib/shared/render-constants.js.map +1 -1
- package/runtime/lib/snapshot/alog/render.js +1 -0
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +2 -2
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js +1 -0
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +5 -2
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lynx/children.js +1 -2
- package/runtime/lib/snapshot/lynx/children.js.map +1 -1
- package/runtime/lib/snapshot/lynx/env.js +1 -1
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/suspense.js +1 -1
- package/runtime/lib/snapshot/lynx/suspense.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.js +5 -5
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +12 -13
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +23 -25
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js +1 -3
- package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/ref.d.ts +3 -2
- package/runtime/lib/snapshot/snapshot/ref.js +4 -7
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/snapshot.js +5 -0
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js +2 -8
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/utils.d.ts +9 -0
- package/runtime/lib/utils.js +27 -0
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +5 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js +7 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js +2 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/package.json +37 -0
- package/runtime/src/core/background-function/exec-map.ts +44 -0
- package/runtime/src/core/background-function/handle.ts +31 -0
- package/runtime/src/core/background-function/run-on-background.ts +151 -0
- package/runtime/src/core/commit-context.ts +26 -0
- package/runtime/src/core/compat/legacy-react-runtime.ts +39 -0
- package/runtime/src/core/compat/lynxComponent.ts +91 -0
- package/runtime/src/core/component.ts +152 -0
- package/runtime/src/core/forceRootRender.ts +52 -0
- package/runtime/src/core/globalProps.ts +111 -0
- package/runtime/src/core/hooks/mainThread.ts +9 -0
- package/runtime/src/core/hooks/mainThreadImpl.ts +226 -0
- package/runtime/src/core/hooks/react.ts +172 -0
- package/runtime/src/core/hooks/useLynxGlobalEventListener.ts +59 -0
- package/runtime/src/core/initData.ts +191 -0
- package/runtime/src/core/lynx/dynamic-import.ts +37 -0
- package/runtime/src/core/lynx/lazy-bundle.ts +352 -0
- package/runtime/src/core/lynx/runtime-backend.ts +30 -0
- package/runtime/src/core/lynx-data-processors.ts +85 -0
- package/runtime/src/core/lynx-page-data.ts +22 -0
- package/runtime/src/core/lynx-update-data.ts +47 -0
- package/runtime/src/core/main-thread-function.ts +12 -0
- package/runtime/src/core/main-thread-ref-init-value.ts +29 -0
- package/runtime/src/core/main-thread-ref.ts +225 -0
- package/runtime/src/core/mts-capability.ts +21 -0
- package/runtime/src/core/performance.ts +186 -0
- package/runtime/src/core/ref.ts +181 -0
- package/runtime/src/core/reload-version.ts +13 -0
- package/runtime/src/core/runtime-destroy.ts +22 -0
- package/runtime/src/core/thread-function-call/main-thread.ts +81 -0
- package/runtime/src/core/thread-function-call/return-value.ts +77 -0
- package/runtime/src/document.ts +86 -0
- package/runtime/src/element-template/background/attr-slots.ts +132 -0
- package/runtime/src/element-template/background/commit-context.ts +47 -0
- package/runtime/src/element-template/background/commit-hook.ts +211 -0
- package/runtime/src/element-template/background/destroy.ts +34 -0
- package/runtime/src/element-template/background/document.ts +41 -0
- package/runtime/src/element-template/background/hydrate.ts +605 -0
- package/runtime/src/element-template/background/hydration-listener.ts +198 -0
- package/runtime/src/element-template/background/instance.ts +820 -0
- package/runtime/src/element-template/background/manager.ts +89 -0
- package/runtime/src/element-template/background/page-root-hydrate.ts +23 -0
- package/runtime/src/element-template/background/render-scope.ts +52 -0
- package/runtime/src/element-template/client/root.ts +71 -0
- package/runtime/src/element-template/debug/alog.ts +238 -0
- package/runtime/src/element-template/debug/elementPAPICall.ts +89 -0
- package/runtime/src/element-template/debug/profile.ts +194 -0
- package/runtime/src/element-template/hydration-map.ts +13 -0
- package/runtime/src/element-template/index.ts +138 -0
- package/runtime/src/element-template/internal.ts +69 -0
- package/runtime/src/element-template/jsx-dev-runtime/index.ts +4 -0
- package/runtime/src/element-template/jsx-runtime/index.ts +86 -0
- package/runtime/src/element-template/lynx/env.ts +59 -0
- package/runtime/src/element-template/lynx/performance.ts +20 -0
- package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +10 -0
- package/runtime/src/element-template/native/index.ts +92 -0
- package/runtime/src/element-template/native/main-thread-api.ts +55 -0
- package/runtime/src/element-template/native/mts-destroy.ts +46 -0
- package/runtime/src/element-template/native/patch-listener.ts +136 -0
- package/runtime/src/element-template/native/reload-background.ts +43 -0
- package/runtime/src/element-template/native/reload-main-thread.ts +76 -0
- package/runtime/src/element-template/prop-adapters/event-value.ts +11 -0
- package/runtime/src/element-template/prop-adapters/event.ts +87 -0
- package/runtime/src/element-template/prop-adapters/ref.ts +148 -0
- package/runtime/src/element-template/prop-adapters/spread.ts +66 -0
- package/runtime/src/element-template/protocol/lifecycle-constant.ts +8 -0
- package/runtime/src/element-template/protocol/opcodes.ts +18 -0
- package/runtime/src/element-template/protocol/page.ts +7 -0
- package/runtime/src/element-template/protocol/template-type.ts +56 -0
- package/runtime/src/element-template/protocol/types.ts +229 -0
- package/runtime/src/element-template/protocol/update-event.ts +46 -0
- package/runtime/src/element-template/runtime/list/list.ts +829 -0
- package/runtime/src/element-template/runtime/page/authored-page.ts +53 -0
- package/runtime/src/element-template/runtime/page/page.ts +21 -0
- package/runtime/src/element-template/runtime/page/root-instance.ts +25 -0
- package/runtime/src/element-template/runtime/patch.ts +517 -0
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +81 -0
- package/runtime/src/element-template/runtime/render/render-opcodes.ts +313 -0
- package/runtime/src/element-template/runtime/render/render-to-opcodes.ts +411 -0
- package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +153 -0
- package/runtime/src/element-template/runtime/template/handle.ts +95 -0
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +48 -0
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +242 -0
- package/runtime/src/element-template/runtime/template/main-thread-event-ctx.ts +46 -0
- package/runtime/src/element-template/runtime/template/main-thread-function.ts +32 -0
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +95 -0
- package/runtime/src/element-template/runtime/template/registry.ts +72 -0
- package/runtime/src/element-template/runtime/template/typed-attributes.ts +25 -0
- package/runtime/src/element-template/runtime-backend-marker.ts +7 -0
- package/runtime/src/element-template/types.d.ts +128 -0
- package/runtime/src/index.ts +95 -0
- package/runtime/src/internal.ts +102 -0
- package/runtime/src/lynx-api.ts +563 -0
- package/runtime/src/lynx.ts +93 -0
- package/runtime/src/root.ts +38 -0
- package/runtime/src/runtime-backend-marker.ts +7 -0
- package/runtime/src/shared/attribute-name.ts +109 -0
- package/runtime/src/shared/component-stack.ts +168 -0
- package/runtime/src/shared/index-map.ts +26 -0
- package/runtime/src/shared/profile.ts +36 -0
- package/runtime/src/shared/render-constants.ts +42 -0
- package/runtime/src/snapshot/alog/elementPAPICall.ts +132 -0
- package/runtime/src/snapshot/alog/index.ts +8 -0
- package/runtime/src/snapshot/alog/render.ts +33 -0
- package/runtime/src/snapshot/compat/componentIs.ts +30 -0
- package/runtime/src/snapshot/debug/debug.ts +9 -0
- package/runtime/src/snapshot/debug/describeInvalidValue.ts +25 -0
- package/runtime/src/snapshot/debug/formatPatch.ts +28 -0
- package/runtime/src/snapshot/debug/printSnapshot.ts +63 -0
- package/runtime/src/snapshot/debug/profileHooks.ts +271 -0
- package/runtime/src/snapshot/debug/vnodeSource.ts +82 -0
- package/runtime/src/snapshot/gesture/processGesture.ts +274 -0
- package/runtime/src/snapshot/gesture/processGestureBagkround.ts +94 -0
- package/runtime/src/snapshot/gesture/types.ts +46 -0
- package/runtime/src/snapshot/index.ts +5 -0
- package/runtime/src/snapshot/lifecycle/constant.ts +29 -0
- package/runtime/src/snapshot/lifecycle/destroy.ts +38 -0
- package/runtime/src/snapshot/lifecycle/event/delayEvents.ts +11 -0
- package/runtime/src/snapshot/lifecycle/event/delayLifecycleEvents.ts +15 -0
- package/runtime/src/snapshot/lifecycle/event/firstScreenSync.ts +97 -0
- package/runtime/src/snapshot/lifecycle/isRendering.ts +27 -0
- package/runtime/src/snapshot/lifecycle/patch/commit.ts +278 -0
- package/runtime/src/snapshot/lifecycle/patch/error.ts +66 -0
- package/runtime/src/snapshot/lifecycle/patch/globalState.ts +16 -0
- package/runtime/src/snapshot/lifecycle/patch/isMainThreadHydrating.ts +13 -0
- package/runtime/src/snapshot/lifecycle/patch/nodesRefApply.ts +119 -0
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +97 -0
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +170 -0
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +115 -0
- package/runtime/src/snapshot/lifecycle/ref/delay.ts +82 -0
- package/runtime/src/snapshot/lifecycle/reload.ts +95 -0
- package/runtime/src/snapshot/lifecycle/render.ts +36 -0
- package/runtime/src/snapshot/list/list.ts +320 -0
- package/runtime/src/snapshot/list/listUpdateInfo.ts +265 -0
- package/runtime/src/snapshot/list/pendingListUpdates.ts +44 -0
- package/runtime/src/snapshot/lynx/calledByNative.ts +180 -0
- package/runtime/src/snapshot/lynx/children.ts +40 -0
- package/runtime/src/snapshot/lynx/element.ts +217 -0
- package/runtime/src/snapshot/lynx/env.ts +58 -0
- package/runtime/src/snapshot/lynx/injectLepusMethods.ts +53 -0
- package/runtime/src/snapshot/lynx/lazyBundleConstants.ts +9 -0
- package/runtime/src/snapshot/lynx/nodesRef.ts +47 -0
- package/runtime/src/snapshot/lynx/performance.ts +20 -0
- package/runtime/src/snapshot/lynx/portals.ts +203 -0
- package/runtime/src/snapshot/lynx/portalsPending.ts +62 -0
- package/runtime/src/snapshot/lynx/prepareLazyBundleMTS.ts +68 -0
- package/runtime/src/snapshot/lynx/runWithForce.ts +18 -0
- package/runtime/src/snapshot/lynx/suspense.ts +58 -0
- package/runtime/src/snapshot/lynx/tt.ts +281 -0
- package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +465 -0
- package/runtime/src/snapshot/renderToOpcodes/index.ts +445 -0
- package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +155 -0
- package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +822 -0
- package/runtime/src/snapshot/snapshot/constants.ts +27 -0
- package/runtime/src/snapshot/snapshot/definition.ts +258 -0
- package/runtime/src/snapshot/snapshot/dynamicPartType.ts +40 -0
- package/runtime/src/snapshot/snapshot/event.ts +33 -0
- package/runtime/src/snapshot/snapshot/gesture.ts +31 -0
- package/runtime/src/snapshot/snapshot/index.ts +8 -0
- package/runtime/src/snapshot/snapshot/list.ts +66 -0
- package/runtime/src/snapshot/snapshot/platformInfo.ts +109 -0
- package/runtime/src/snapshot/snapshot/reconstructInstanceTree.ts +46 -0
- package/runtime/src/snapshot/snapshot/ref.ts +116 -0
- package/runtime/src/snapshot/snapshot/snapshot.ts +627 -0
- package/runtime/src/snapshot/snapshot/snapshotCreatorMap.ts +33 -0
- package/runtime/src/snapshot/snapshot/snapshotInstanceHydrationMap.ts +17 -0
- package/runtime/src/snapshot/snapshot/snapshotInstanceManager.ts +22 -0
- package/runtime/src/snapshot/snapshot/spread.ts +378 -0
- package/runtime/src/snapshot/snapshot/types.ts +29 -0
- package/runtime/src/snapshot/snapshot/utils.ts +59 -0
- package/runtime/src/snapshot/snapshot/workletEvent.ts +73 -0
- package/runtime/src/snapshot/snapshot/workletRef.ts +97 -0
- package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +37 -0
- package/runtime/src/snapshot/worklet/ctx.ts +22 -0
- package/runtime/src/snapshot/worklet/destroy.ts +14 -0
- package/runtime/src/snapshot/worklet/functionality.ts +22 -0
- package/runtime/src/snapshot/worklet/hmr.ts +34 -0
- package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +30 -0
- package/runtime/src/utils.ts +134 -0
- package/runtime/src/worklet-runtime/api/animation/animation.ts +48 -0
- package/runtime/src/worklet-runtime/api/animation/effect.ts +20 -0
- package/runtime/src/worklet-runtime/api/element.ts +152 -0
- package/runtime/src/worklet-runtime/api/lepusQuerySelector.ts +34 -0
- package/runtime/src/worklet-runtime/api/lynxApi.ts +42 -0
- package/runtime/src/worklet-runtime/bindings/bindings.ts +91 -0
- package/runtime/src/worklet-runtime/bindings/events.ts +29 -0
- package/runtime/src/worklet-runtime/bindings/index.ts +12 -0
- package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
- package/runtime/src/worklet-runtime/bindings/observers.ts +61 -0
- package/runtime/src/worklet-runtime/bindings/types.ts +84 -0
- package/runtime/src/worklet-runtime/delayRunOnBackground.ts +51 -0
- package/runtime/src/worklet-runtime/delayWorkletEvent.ts +70 -0
- package/runtime/src/worklet-runtime/eomImpl.ts +14 -0
- package/runtime/src/worklet-runtime/eventPropagation.ts +56 -0
- package/runtime/src/worklet-runtime/global.ts +28 -0
- package/runtime/src/worklet-runtime/hydrate.ts +113 -0
- package/runtime/src/worklet-runtime/index.ts +12 -0
- package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +69 -0
- package/runtime/src/worklet-runtime/listeners.ts +28 -0
- package/runtime/src/worklet-runtime/runOnMainThread.ts +21 -0
- package/runtime/src/worklet-runtime/types/dev.d.ts +4 -0
- package/runtime/src/worklet-runtime/types/elementApi.d.ts +97 -0
- package/runtime/src/worklet-runtime/types/runtimeProxy.d.ts +32 -0
- package/runtime/src/worklet-runtime/types/systeminfo.d.ts +19 -0
- package/runtime/src/worklet-runtime/utils/mainThreadFlushLoopGuard.ts +87 -0
- package/runtime/src/worklet-runtime/utils/profile.ts +20 -0
- package/runtime/src/worklet-runtime/utils/version.ts +11 -0
- package/runtime/src/worklet-runtime/workletRef.ts +119 -0
- package/runtime/src/worklet-runtime/workletRuntime.ts +215 -0
- package/runtime/tsconfig.json +30 -0
- package/runtime/turbo.json +21 -0
- package/runtime/types/internal-preact.d.ts +67 -0
- package/runtime/types/types.d.ts +339 -0
- package/runtime/vitest.config.ts +181 -0
- package/runtime/worklet-runtime/dev.js +1 -1
- package/testing-library/.npmignore +6 -0
- package/testing-library/.turbo/turbo-build.log +28 -0
- package/testing-library/README.md +109 -0
- package/testing-library/dist/env/index.js +1 -2
- package/testing-library/dist/index.d.ts +1 -1
- package/testing-library/dist/rstest-config.d.ts +15 -1
- package/testing-library/dist/rstest-config.js +38 -5
- package/testing-library/dist/setupFiles/common/runtime-setup.js +3 -3
- package/testing-library/etc/react-lynx-testing-library.api.md +71 -0
- package/testing-library/loaders/jsx-loader.js +49 -0
- package/testing-library/node_modules/.bin/rsbuild +55 -0
- package/testing-library/node_modules/.bin/rspeedy +55 -0
- package/testing-library/node_modules/.bin/rstest +55 -0
- package/testing-library/package.json +28 -0
- package/testing-library/rslib.config.ts +97 -0
- package/testing-library/rstest.config.ts +44 -0
- package/testing-library/src/__tests__/3.1/text.test.jsx +109 -0
- package/testing-library/src/__tests__/act.test.jsx +348 -0
- package/testing-library/src/__tests__/alog.test.jsx +813 -0
- package/testing-library/src/__tests__/auto-cleanup-skip.test.jsx +25 -0
- package/testing-library/src/__tests__/auto-cleanup.test.jsx +12 -0
- package/testing-library/src/__tests__/background-only.test.jsx +45 -0
- package/testing-library/src/__tests__/button.test.jsx +25 -0
- package/testing-library/src/__tests__/cleanup.test.jsx +29 -0
- package/testing-library/src/__tests__/css/index.test.jsx +47 -0
- package/testing-library/src/__tests__/css/style1.css +3 -0
- package/testing-library/src/__tests__/css/style2.css +3 -0
- package/testing-library/src/__tests__/css/style3.module.css +3 -0
- package/testing-library/src/__tests__/dom-reuse.test.jsx +1515 -0
- package/testing-library/src/__tests__/end-to-end.test.jsx +212 -0
- package/testing-library/src/__tests__/events.test.jsx +368 -0
- package/testing-library/src/__tests__/lazy-bundle/LazyComponent.jsx +4 -0
- package/testing-library/src/__tests__/lazy-bundle/index.test.jsx +598 -0
- package/testing-library/src/__tests__/list.test.jsx +1015 -0
- package/testing-library/src/__tests__/lynx.test.jsx +85 -0
- package/testing-library/src/__tests__/portals.test.jsx +1303 -0
- package/testing-library/src/__tests__/preact-signals.test.jsx +190 -0
- package/testing-library/src/__tests__/raw-text.test.jsx +59 -0
- package/testing-library/src/__tests__/ref.test.jsx +573 -0
- package/testing-library/src/__tests__/remove-element.test.jsx +68 -0
- package/testing-library/src/__tests__/render.test.jsx +296 -0
- package/testing-library/src/__tests__/renderComponent.test.jsx +344 -0
- package/testing-library/src/__tests__/renderHook.test.jsx +61 -0
- package/testing-library/src/__tests__/rerender.test.jsx +62 -0
- package/testing-library/src/__tests__/rstest-config.test.js +31 -0
- package/testing-library/src/__tests__/slot-jsx.test.jsx +965 -0
- package/testing-library/src/__tests__/spread.test.jsx +212 -0
- package/testing-library/src/__tests__/stopwatch.test.jsx +80 -0
- package/testing-library/src/__tests__/text.test.jsx +130 -0
- package/testing-library/src/__tests__/worklet.test.jsx +618 -0
- package/testing-library/src/entry.ts +2 -0
- package/testing-library/src/env/index.ts +2 -0
- package/testing-library/src/env/rstest.ts +7 -0
- package/testing-library/src/env/vitest.ts +27 -0
- package/testing-library/src/fire-event.ts +199 -0
- package/testing-library/src/index.jsx +25 -0
- package/testing-library/src/plugins/index.ts +2 -0
- package/testing-library/src/plugins/vitest.ts +387 -0
- package/testing-library/src/pure.jsx +159 -0
- package/testing-library/src/rstest-config.ts +173 -0
- package/testing-library/src/setupFiles/common/bootstrap.js +6 -0
- package/testing-library/src/setupFiles/common/runtime-setup.js +142 -0
- package/testing-library/src/setupFiles/inner/rstest.js +13 -0
- package/testing-library/src/setupFiles/inner/vitest.js +17 -0
- package/testing-library/src/setupFiles/rstest.js +30 -0
- package/testing-library/src/setupFiles/vitest.js +29 -0
- package/testing-library/src/vitest.config.ts +14 -0
- package/testing-library/tsconfig.json +16 -0
- package/testing-library/turbo.json +21 -0
- package/testing-library/types/entry.d.ts +1 -1
- package/testing-library/vitest-polyfill.cjs +6 -0
- package/testing-library/vitest.3.1.config.ts +17 -0
- package/testing-library/vitest.config.ts +14 -0
- package/transform/.cargo/config.toml +2 -0
- package/transform/.gitignore +6 -0
- package/transform/.npmignore +8 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +252 -0
- package/transform/Cargo.toml +45 -0
- package/transform/__test__/background-only.spec.js +222 -0
- package/transform/__test__/basic.bench.js +80 -0
- package/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js +18 -0
- package/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.js +18 -0
- package/transform/__test__/css/__snapshots__/transform-all-css-scoped-none.js +18 -0
- package/transform/__test__/css/__snapshots__/transform-imports-css-scoped-all.js +24 -0
- package/transform/__test__/css/__snapshots__/transform-imports-css-scoped-modules.js +24 -0
- package/transform/__test__/css/__snapshots__/transform-imports-css-scoped-none.js +24 -0
- package/transform/__test__/css/__snapshots__/transform-imports-defaults.js +5 -0
- package/transform/__test__/css/__snapshots__/transform-imports-without-jsx-css-scoped-all.js +5 -0
- package/transform/__test__/css/__snapshots__/transform-imports-without-jsx-css-scoped-modules.js +5 -0
- package/transform/__test__/css/__snapshots__/transform-imports-without-jsx-css-scoped-none.js +5 -0
- package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js +50 -0
- package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all.js +50 -0
- package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules-lazy-bundle.js +50 -0
- package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.js +50 -0
- package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none-lazy-bundle.js +50 -0
- package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none.js +50 -0
- package/transform/__test__/css/__snapshots__/transform-jsx-defaults.js +50 -0
- package/transform/__test__/css/css-scope.spec.js +209 -0
- package/transform/__test__/css/inline-style.spec.js +53 -0
- package/transform/__test__/css/object-lit-style.spec.js +293 -0
- package/transform/__test__/defines.spec.js +321 -0
- package/transform/__test__/fixture.spec.js +2496 -0
- package/transform/__test__/typescript.spec.js +97 -0
- package/transform/build.rs +11 -0
- package/transform/crates/swc_plugin_background_only/Cargo.toml +13 -0
- package/transform/crates/swc_plugin_background_only/lib.rs +326 -0
- package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/defaults_to_null_without_fallback.js +5 -0
- package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/desugars_nested_background_only.js +5 -0
- package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/desugars_to_thread_conditional_in_child_position.js +8 -0
- package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/desugars_to_thread_conditional_in_expression_position.js +3 -0
- package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/keeps_the_fragment_for_a_lone_text_child.js +3 -0
- package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/renders_nothing_for_empty_children.js +5 -0
- package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/unwraps_a_lone_child_past_layout_and_comments.js +3 -0
- package/transform/crates/swc_plugin_compat/Cargo.toml +24 -0
- package/transform/crates/swc_plugin_compat/is_component_class.rs +51 -0
- package/transform/crates/swc_plugin_compat/lib.rs +1885 -0
- package/transform/crates/swc_plugin_compat/napi.rs +526 -0
- package/transform/crates/swc_plugin_compat/simplify_ctor_like_react_lynx_2.rs +172 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element.js +17 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element_compiler_only.js +16 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element_embedded.js +2 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element_embedded_compiler_only.js +1 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_is_import.js +3 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_change_runtime_pkg.js +1 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_handle_recursive.js +4 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_left_no_remove_component_element_attr.js +1 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_handle_jsx_member_expression.js +1 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_rename_view_in_scope.js +6 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_rename_view_redeclaration.js +4 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_transform_event_props_when_disabled.js +1 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_remove_component_attr_regex.js +8 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_rename_view.js +1 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor.js +9 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_correct_order.js +10 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_not_remain_local_decls.js +9 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_not_remain_local_decls_with_macro.js +19 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_not_remain_local_decls_with_spread.js +12 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_transform_event_props_1.js +1 -0
- package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_transform_event_props_2.js +1 -0
- package/transform/crates/swc_plugin_css_scope/Cargo.toml +18 -0
- package/transform/crates/swc_plugin_css_scope/lib.rs +327 -0
- package/transform/crates/swc_plugin_css_scope/napi.rs +144 -0
- package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_all_transform_imports.js +5 -0
- package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_all_transform_imports_without_jsx.js +4 -0
- package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_modules_transform_imports.js +5 -0
- package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_modules_transform_imports_without_jsx.js +4 -0
- package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_none_transform_imports.js +5 -0
- package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_none_transform_imports_without_jsx.js +4 -0
- package/transform/crates/swc_plugin_define_dce/Cargo.toml +15 -0
- package/transform/crates/swc_plugin_define_dce/lib.rs +21 -0
- package/transform/crates/swc_plugin_define_dce/napi.rs +79 -0
- package/transform/crates/swc_plugin_directive_dce/Cargo.toml +18 -0
- package/transform/crates/swc_plugin_directive_dce/lib.rs +489 -0
- package/transform/crates/swc_plugin_directive_dce/napi.rs +65 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_do_nothing_in_mixed_target.js +6 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_do_nothing_when_arrow_function_return_directive.js +1 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_async_arrow_with_background_only_directive.js +1 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_background_only_generator_forms.js +7 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_fn_body_in_component_props.js +1 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_fn_decl.js +1 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_but_keep_constructor.js +6 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_class_method.js +4 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_class_property.js +4 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_embedded.js +5 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_native_modules_in_default_params.js +1 -0
- package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_transpiled_async_arrow_with_background_only_generator.js +1 -0
- package/transform/crates/swc_plugin_dynamic_import/Cargo.toml +18 -0
- package/transform/crates/swc_plugin_dynamic_import/lib.rs +408 -0
- package/transform/crates/swc_plugin_dynamic_import/napi.rs +89 -0
- package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_import_lazy_bundle.js +4 -0
- package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_import_lazy_import.js +9 -0
- package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_not_import_lazy.js +3 -0
- package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_transform_import_call.js +61 -0
- package/transform/crates/swc_plugin_element_template/Cargo.toml +29 -0
- package/transform/crates/swc_plugin_element_template/asset.rs +64 -0
- package/transform/crates/swc_plugin_element_template/attr_name.rs +77 -0
- package/transform/crates/swc_plugin_element_template/extractor.rs +484 -0
- package/transform/crates/swc_plugin_element_template/lib.rs +734 -0
- package/transform/crates/swc_plugin_element_template/lowering.rs +125 -0
- package/transform/crates/swc_plugin_element_template/napi.rs +168 -0
- package/transform/crates/swc_plugin_element_template/template_attribute.rs +31 -0
- package/transform/crates/swc_plugin_element_template/template_definition.rs +375 -0
- package/transform/crates/swc_plugin_element_template/template_identity.rs +160 -0
- package/transform/crates/swc_plugin_element_template/template_slot.rs +81 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_generate_attribute_slots_for_dynamic_attributes.snap +81 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_background_conditional_attributes.snap +44 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_boolean_and_number_attributes.snap +62 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_complex_text_structure.snap +120 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dataset_attributes.snap +62 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_deeply_nested_user_components.snap +54 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dynamic_class_attributes.snap +57 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_events_js.snap +57 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_events_lepus.snap +57 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_id_attributes.snap +57 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_inline_styles.snap +82 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_interpolated_text_with_siblings_js.snap +85 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_interpolated_text_with_siblings_lepus.snap +85 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_mixed_content.snap +82 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_nested_structure_and_dynamic_content.snap +143 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_refs_js.snap +52 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_refs_lepus.snap +52 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_sibling_user_components.snap +69 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_spread_attributes.snap +56 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_user_component.snap +54 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_isolate_arrays_with_child_slot_placeholder.snap +56 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_keep_code_and_template_attribute_slots_in_sync_for_spread.snap +66 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_element_template_simple_lepus.snap +52 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_template_with_static_attributes.snap +62 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_template_structure_complex.snap +69 -0
- package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_text_attribute_and_child_text_slots.snap +70 -0
- package/transform/crates/swc_plugin_element_template/tests/element_template.rs +1207 -0
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +930 -0
- package/transform/crates/swc_plugin_inject/Cargo.toml +18 -0
- package/transform/crates/swc_plugin_inject/lib.rs +344 -0
- package/transform/crates/swc_plugin_inject/napi.rs +150 -0
- package/transform/crates/swc_plugin_inject/tests/__swc_snapshots__/lib.rs/should_inject.js +8 -0
- package/transform/crates/swc_plugin_inject/tests/__swc_snapshots__/lib.rs/should_inject_callee.js +1 -0
- package/transform/crates/swc_plugin_list/Cargo.toml +15 -0
- package/transform/crates/swc_plugin_list/legacy_slot.rs +410 -0
- package/transform/crates/swc_plugin_list/lib.rs +631 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/basic_list_legacy_slot.js +61 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/basic_list_toplevel_legacy_slot.js +40 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/basic_list_with_fragment_legacy_slot.js +65 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_in_view_legacy_slot.js +6 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_in_view_with_snapshot_legacy_slot.js +49 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_item_deferred_in_list_legacy_slot.js +5 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_item_deferred_with_children_with_snapshot_legacy_slot.js +95 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/basic_list.js +53 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js +40 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js +57 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_not_transform_list_item_with_defer_false.js +1 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view.js +6 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_snapshot.js +54 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling.js +7 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling_nested.js +16 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling_with_snapshot.js +65 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling_with_snapshot_nested.js +138 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_basic.js +2 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_in_list.js +5 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children.js +6 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js +95 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_not_deferred.js +1 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_when_defer_is_expr.js +4 -0
- package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_with_spread_deferred.js +2 -0
- package/transform/crates/swc_plugin_shake/Cargo.toml +20 -0
- package/transform/crates/swc_plugin_shake/is_component_class.rs +66 -0
- package/transform/crates/swc_plugin_shake/lib.rs +908 -0
- package/transform/crates/swc_plugin_shake/napi.rs +220 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/only_shake_class_like_react_component_class.js +10 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_access_inside_class_property_iife.js +11 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_constructor_and_used.js +12 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_indirect.js +12 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_render_and_used.js +11 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_state_and_remove_other.js +8 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_use_effect_call_from_custom_runtime.js +6 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_with_nested_class.js +11 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_not_remove_call_in_scope_id.js +5 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_not_remove_in_scope_id.js +5 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_not_remove_test_with_other_runtime.js +3 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_call.js +4 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_call_by_local_name.js +4 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_param.js +4 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_param_by_local_name.js +4 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_default_and_namespace_runtime_import_calls.js +6 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_default_and_namespace_runtime_import_params.js +6 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_test.js +5 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_unused_indirect.js +5 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_use_effect_call.js +8 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_use_effect_param.js +8 -0
- package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_replace_use_effect_call_with_undefined.js +2 -0
- package/transform/crates/swc_plugin_snapshot/Cargo.toml +25 -0
- package/transform/crates/swc_plugin_snapshot/attr_name.rs +84 -0
- package/transform/crates/swc_plugin_snapshot/legacy_slot.rs +2201 -0
- package/transform/crates/swc_plugin_snapshot/lib.rs +3495 -0
- package/transform/crates/swc_plugin_snapshot/napi.rs +184 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_legacy_slot.js +10 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_with_static_sibling_jsx_dev_legacy_slot.js +35 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_with_static_sibling_jsx_legacy_slot.js +27 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_with_static_sibling_legacy_slot.js +24 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_expr_container_legacy_slot.js +10 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_expr_container_with_static_sibling_legacy_slot.js +24 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_spread_list_item_legacy_slot.js +42 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/full_static_children_map_jsx_legacy_slot.js +44 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/page_component_legacy_slot.js +15 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/page_element_dev_legacy_slot.js +16 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/page_element_legacy_slot.js +16 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_create_raw_text_node_for_text_node_legacy_slot.js +55 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_emit_list_item_platform_info_marker_for_spread_props_legacy_slot.js +32 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_inject_implicit_flatten_legacy_slot.js +67 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_not_wrap_dynamic_part.js +29 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_wrap_dynamic_key_legacy_slot.js +54 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_wrap_dynamic_part.js +34 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js +10 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js +24 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js +27 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js +35 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js +26 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js +10 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js +24 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js +25 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js +16 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js +21 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js +45 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js +30 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread_list_item.js +30 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js +31 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/empty_module.js +1 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/external_bundle_uses_card_entry_name.js +16 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js +19 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.js +28 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js +25 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js +25 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js +26 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.js +11 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js +11 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js +24 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js +15 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js +16 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js +16 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_create_raw_text_node_for_text_node.js +47 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_emit_list_item_platform_info_marker_for_non_zero_value_index.js +25 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_emit_list_item_platform_info_marker_for_spread_props.js +22 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.js +55 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js +71 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js +71 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js +69 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.js +69 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js +59 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_set_attribute_for_text_node.js +44 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js +69 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js +21 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js +46 -0
- package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js +35 -0
- package/transform/crates/swc_plugin_text/Cargo.toml +14 -0
- package/transform/crates/swc_plugin_text/lib.rs +93 -0
- package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_keep_children_for_dynamic_or_multiple_text.js +9 -0
- package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_transform_single_static_text_to_text_attr.js +8 -0
- package/transform/crates/swc_plugin_worklet/Cargo.toml +24 -0
- package/transform/crates/swc_plugin_worklet/decl_collect.rs +226 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +460 -0
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +326 -0
- package/transform/crates/swc_plugin_worklet/globals.rs +104 -0
- package/transform/crates/swc_plugin_worklet/hash.rs +29 -0
- package/transform/crates/swc_plugin_worklet/lib.rs +2869 -0
- package/transform/crates/swc_plugin_worklet/napi.rs +116 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/class_in_worklet_1.js +3 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_inner_ident.js +13 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_outer_ident.js +13 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +12 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +35 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_ident_from_this_js.js +6 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_ident_from_this_lepus.js +15 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_idents_outside_of_ctx.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +29 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +54 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_3_js.js +12 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_3_lepus.js +89 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_4_js.js +3 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_4_lepus.js +13 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +23 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +46 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_handle_renamed_import_shadowing_js.js +16 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_globals.js +15 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_type_annotations.js +22 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_destructure_from_closure.js +12 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_catch_clause_params.js +17 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_ident_from_this.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_idents_inside_of_ctx.js +24 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_constructor.js +7 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_getter_and_setter.js +13 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_recursively.js +23 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_when_wrong_directives.js +14 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_default_import_js.js +12 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js +12 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_lepus.js +23 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_namespace_import_js.js +12 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_string_key_js.js +12 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_arrow_function.js +15 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_fn_decl_js.js +6 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_fn_decl_lepus.js +16 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_function_expr.js +15 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_js.js +11 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_js_capture_values.js +11 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_lepus.js +17 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_js.js +14 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_js_capture_values.js +11 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_lepus.js +21 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_js.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_lepus.js +18 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_property_js.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_property_lepus.js +17 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +15 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_fn_in_run_on_js_js.js +10 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_fn_in_run_on_js_lepus.js +25 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_general.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +34 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_alias.js +20 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general.js +20 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general_mixed.js +20 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets.js +29 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets_in_func.js +31 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_ui_worklet_js.js +6 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_ui_worklet_lepus.js +15 -0
- package/transform/crates/swc_plugin_worklet/worklet_type.rs +24 -0
- package/transform/crates/swc_plugins_shared/Cargo.toml +27 -0
- package/transform/crates/swc_plugins_shared/css.rs +64 -0
- package/transform/crates/swc_plugins_shared/defines.rs +51 -0
- package/transform/crates/swc_plugins_shared/engine_version.rs +50 -0
- package/transform/crates/swc_plugins_shared/jsx_helpers.rs +451 -0
- package/transform/crates/swc_plugins_shared/lib.rs +12 -0
- package/transform/crates/swc_plugins_shared/lynx_event.rs +159 -0
- package/transform/crates/swc_plugins_shared/target.rs +66 -0
- package/transform/crates/swc_plugins_shared/target_napi.rs +69 -0
- package/transform/crates/swc_plugins_shared/transform_mode.rs +61 -0
- package/transform/crates/swc_plugins_shared/transform_mode_napi.rs +72 -0
- package/transform/crates/swc_plugins_shared/utils.rs +149 -0
- package/transform/dist/wasm.cjs +1 -1
- package/transform/node_modules/.bin/esbuild +46 -0
- package/transform/node_modules/.bin/napi +55 -0
- package/transform/package.json +42 -0
- package/transform/rspack-napi/lib/index.d.ts +32 -0
- package/transform/rspack-napi/lib/index.js +96 -0
- package/transform/rspack-napi/lib/index.js.map +1 -0
- package/transform/rspack-napi/package.json +25 -0
- package/transform/rspack-napi/src/index.ts +161 -0
- package/transform/rspack-napi/tsconfig.json +17 -0
- package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -0
- package/transform/scripts/build_wasm.js +55 -0
- package/transform/src/bundle.rs +249 -0
- package/transform/src/esbuild.rs +201 -0
- package/transform/src/lib.rs +1197 -0
- package/transform/src/swc_plugin_compat_post/mod.rs +143 -0
- package/transform/src/swc_plugin_extract_str/mod.rs +382 -0
- package/transform/src/swc_plugin_refresh/mod.rs +546 -0
- package/transform/src/swc_plugin_transform_builtin_attribute_names/mod.rs +286 -0
- package/transform/src/swc_plugin_worklet_post_process/mod.rs +100 -0
- package/transform/src/wasm.js +39 -0
- package/transform/swc-plugin-reactlynx/.cargo/config.toml +9 -0
- package/transform/swc-plugin-reactlynx/.gitignore +2 -0
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +346 -0
- package/transform/swc-plugin-reactlynx/Cargo.toml +30 -0
- package/transform/swc-plugin-reactlynx/build.js +27 -0
- package/transform/swc-plugin-reactlynx/index.d.ts +273 -0
- package/transform/swc-plugin-reactlynx/package.json +22 -0
- package/transform/swc-plugin-reactlynx/src/lib.rs +606 -0
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx/turbo.json +18 -0
- package/transform/swc-plugin-reactlynx-compat/.cargo/config.toml +9 -0
- package/transform/swc-plugin-reactlynx-compat/.gitignore +2 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +256 -0
- package/transform/swc-plugin-reactlynx-compat/Cargo.toml +17 -0
- package/transform/swc-plugin-reactlynx-compat/build.js +27 -0
- package/transform/swc-plugin-reactlynx-compat/index.d.ts +326 -0
- package/transform/swc-plugin-reactlynx-compat/package.json +22 -0
- package/transform/swc-plugin-reactlynx-compat/src/lib.rs +15 -0
- package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/turbo.json +18 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_compat_post/mod.rs/should_compat_dark_mode.js +3 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_compat_post/mod.rs/should_compat_dark_mode_custom_theme_expr.js +3 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_extract_str/mod.rs/should_extract_str.js +21 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_extract_str/mod.rs/should_extract_str_with_arr.js +20 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_extract_str/mod.rs/should_extract_tpl_str.js +9 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_basic.js +4 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_custom_library.js +4 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_function_parameter.js +4 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_computed.js +4 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_default.js +4 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_named_computed.js +4 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_namespace_computed.js +4 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_init_value.js +10 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_local_ident.js +8 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_multiple_index.js +21 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_worklet_post_process/mod.rs/should_transform_worklet.js +12 -0
- package/transform/tests/__swc_snapshots__/src/swc_plugin_worklet_post_process/mod.rs/should_transform_worklet_2.js +14 -0
- package/transform/turbo.json +38 -0
- package/transform/vitest.config.ts +19 -0
|
@@ -0,0 +1,4956 @@
|
|
|
1
|
+
/** @jsxImportSource ../../lepus */
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { elementTree, nativeMethodQueue } from './utils/nativeMethod';
|
|
5
|
+
import { hydrate } from '../../src/snapshot/renderToOpcodes/hydrate';
|
|
6
|
+
import { __pendingListUpdates } from '../../src/snapshot/list/pendingListUpdates';
|
|
7
|
+
import { SnapshotInstance, snapshotInstanceManager } from '../../src/snapshot';
|
|
8
|
+
import { __root } from '../../src/root';
|
|
9
|
+
import { globalEnvManager } from './utils/envManager';
|
|
10
|
+
import { gRecycleMap, gSignMap } from '../../src/snapshot/list/list';
|
|
11
|
+
|
|
12
|
+
const HOLE = null;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
// snapshotManager.values.clear();
|
|
16
|
+
__pendingListUpdates.clearAttachedLists();
|
|
17
|
+
snapshotInstanceManager.clear();
|
|
18
|
+
snapshotInstanceManager.nextId = 0;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
elementTree.clear();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('list', () => {
|
|
26
|
+
const s = __SNAPSHOT__(
|
|
27
|
+
<view>
|
|
28
|
+
<text>Hello</text>
|
|
29
|
+
{HOLE}
|
|
30
|
+
</view>,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
it('list top-level', async function() {
|
|
34
|
+
const s1 = __SNAPSHOT__(<list>{HOLE}</list>);
|
|
35
|
+
const s2 = __SNAPSHOT__(<text>World</text>);
|
|
36
|
+
|
|
37
|
+
const a = new SnapshotInstance(s);
|
|
38
|
+
a.ensureElements();
|
|
39
|
+
|
|
40
|
+
const b = new SnapshotInstance(s1);
|
|
41
|
+
const c = new SnapshotInstance(s2);
|
|
42
|
+
|
|
43
|
+
a.insertBefore(b);
|
|
44
|
+
a.insertBefore(c);
|
|
45
|
+
|
|
46
|
+
const d1 = new SnapshotInstance(s2);
|
|
47
|
+
const d2 = new SnapshotInstance(s2);
|
|
48
|
+
const d3 = new SnapshotInstance(s2);
|
|
49
|
+
b.insertBefore(d1);
|
|
50
|
+
b.insertBefore(d2);
|
|
51
|
+
b.insertBefore(d3);
|
|
52
|
+
|
|
53
|
+
expect(a.__element_root).toMatchInlineSnapshot(`
|
|
54
|
+
<view>
|
|
55
|
+
<text>
|
|
56
|
+
<raw-text
|
|
57
|
+
text="Hello"
|
|
58
|
+
/>
|
|
59
|
+
</text>
|
|
60
|
+
<wrapper>
|
|
61
|
+
<list />
|
|
62
|
+
<text>
|
|
63
|
+
<raw-text
|
|
64
|
+
text="World"
|
|
65
|
+
/>
|
|
66
|
+
</text>
|
|
67
|
+
</wrapper>
|
|
68
|
+
</view>
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
expect(b.childNodes.length).toMatchInlineSnapshot(`3`);
|
|
72
|
+
|
|
73
|
+
b.insertBefore(d3); // take no effects
|
|
74
|
+
b.removeChild(d3);
|
|
75
|
+
expect(b.childNodes.length).toMatchInlineSnapshot(`2`);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should be able to insertBefore into list snapshot instance', async function() {
|
|
79
|
+
const s1 = __SNAPSHOT__(
|
|
80
|
+
<view>
|
|
81
|
+
<text>111</text>
|
|
82
|
+
{HOLE}
|
|
83
|
+
</view>,
|
|
84
|
+
);
|
|
85
|
+
const s11 = __SNAPSHOT__(
|
|
86
|
+
<list>{HOLE}</list>,
|
|
87
|
+
);
|
|
88
|
+
const s2 = __SNAPSHOT__(<text>World</text>);
|
|
89
|
+
const s3 = __SNAPSHOT__(
|
|
90
|
+
<list-item item-key={1}>
|
|
91
|
+
<text>World</text>
|
|
92
|
+
</list-item>,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const a = new SnapshotInstance(s);
|
|
96
|
+
a.ensureElements();
|
|
97
|
+
|
|
98
|
+
const b = new SnapshotInstance(s1);
|
|
99
|
+
const b1 = new SnapshotInstance(s11);
|
|
100
|
+
const c = new SnapshotInstance(s2);
|
|
101
|
+
|
|
102
|
+
a.insertBefore(b);
|
|
103
|
+
b.insertBefore(b1);
|
|
104
|
+
a.insertBefore(c);
|
|
105
|
+
|
|
106
|
+
const d1 = new SnapshotInstance(s3);
|
|
107
|
+
const d2 = new SnapshotInstance(s3);
|
|
108
|
+
const d3 = new SnapshotInstance(s3);
|
|
109
|
+
b1.insertBefore(d1);
|
|
110
|
+
b1.insertBefore(d2);
|
|
111
|
+
b1.insertBefore(d3);
|
|
112
|
+
|
|
113
|
+
expect(a.__element_root).toMatchInlineSnapshot(`
|
|
114
|
+
<view>
|
|
115
|
+
<text>
|
|
116
|
+
<raw-text
|
|
117
|
+
text="Hello"
|
|
118
|
+
/>
|
|
119
|
+
</text>
|
|
120
|
+
<wrapper>
|
|
121
|
+
<view>
|
|
122
|
+
<text>
|
|
123
|
+
<raw-text
|
|
124
|
+
text="111"
|
|
125
|
+
/>
|
|
126
|
+
</text>
|
|
127
|
+
<wrapper>
|
|
128
|
+
<list />
|
|
129
|
+
</wrapper>
|
|
130
|
+
</view>
|
|
131
|
+
<text>
|
|
132
|
+
<raw-text
|
|
133
|
+
text="World"
|
|
134
|
+
/>
|
|
135
|
+
</text>
|
|
136
|
+
</wrapper>
|
|
137
|
+
</view>
|
|
138
|
+
`);
|
|
139
|
+
|
|
140
|
+
expect(b1.childNodes.length).toMatchInlineSnapshot(`3`);
|
|
141
|
+
|
|
142
|
+
b.insertBefore(d2);
|
|
143
|
+
b.removeChild(d2);
|
|
144
|
+
expect(b1.childNodes.length).toMatchInlineSnapshot(`2`);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('list slot count > 1 (the wrapper should be generated)', async function() {
|
|
148
|
+
const s1 = __SNAPSHOT__(
|
|
149
|
+
<view>
|
|
150
|
+
<text>111</text>
|
|
151
|
+
{HOLE}
|
|
152
|
+
{HOLE}
|
|
153
|
+
</view>,
|
|
154
|
+
);
|
|
155
|
+
const s11 = __SNAPSHOT__(
|
|
156
|
+
<list>
|
|
157
|
+
{HOLE}
|
|
158
|
+
<list-item></list-item>
|
|
159
|
+
</list>,
|
|
160
|
+
);
|
|
161
|
+
const s2 = __SNAPSHOT__(<text>World</text>);
|
|
162
|
+
|
|
163
|
+
const a = new SnapshotInstance(s);
|
|
164
|
+
a.ensureElements();
|
|
165
|
+
|
|
166
|
+
const b = new SnapshotInstance(s1);
|
|
167
|
+
const b1 = new SnapshotInstance(s11);
|
|
168
|
+
const c = new SnapshotInstance(s2);
|
|
169
|
+
|
|
170
|
+
a.insertBefore(b);
|
|
171
|
+
b.insertBefore(b1);
|
|
172
|
+
a.insertBefore(c);
|
|
173
|
+
|
|
174
|
+
expect(a.__element_root).toMatchInlineSnapshot(`
|
|
175
|
+
<view>
|
|
176
|
+
<text>
|
|
177
|
+
<raw-text
|
|
178
|
+
text="Hello"
|
|
179
|
+
/>
|
|
180
|
+
</text>
|
|
181
|
+
<wrapper>
|
|
182
|
+
<view>
|
|
183
|
+
<text>
|
|
184
|
+
<raw-text
|
|
185
|
+
text="111"
|
|
186
|
+
/>
|
|
187
|
+
</text>
|
|
188
|
+
<wrapper>
|
|
189
|
+
<list />
|
|
190
|
+
</wrapper>
|
|
191
|
+
</view>
|
|
192
|
+
<text>
|
|
193
|
+
<raw-text
|
|
194
|
+
text="World"
|
|
195
|
+
/>
|
|
196
|
+
</text>
|
|
197
|
+
</wrapper>
|
|
198
|
+
</view>
|
|
199
|
+
`);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe(`list "update-list-info"`, () => {
|
|
204
|
+
const s = __SNAPSHOT__(
|
|
205
|
+
<view>
|
|
206
|
+
<text>Hello</text>
|
|
207
|
+
{HOLE}
|
|
208
|
+
</view>,
|
|
209
|
+
);
|
|
210
|
+
it(`"update-list-info" should work when insertBefore and removeChild`, async function() {
|
|
211
|
+
const s1 = __SNAPSHOT__(
|
|
212
|
+
<view>
|
|
213
|
+
<text>111</text>
|
|
214
|
+
{HOLE}
|
|
215
|
+
</view>,
|
|
216
|
+
);
|
|
217
|
+
const s11 = __SNAPSHOT__(
|
|
218
|
+
<list>{HOLE}</list>,
|
|
219
|
+
);
|
|
220
|
+
const s2 = __SNAPSHOT__(<text>World</text>);
|
|
221
|
+
const s3 = __SNAPSHOT__(
|
|
222
|
+
<list-item item-key={1}>
|
|
223
|
+
<text>World</text>
|
|
224
|
+
</list-item>,
|
|
225
|
+
);
|
|
226
|
+
const s4 = __SNAPSHOT__(
|
|
227
|
+
<list-item item-key={4}>
|
|
228
|
+
<text>Lynx</text>
|
|
229
|
+
</list-item>,
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const a = new SnapshotInstance(s);
|
|
233
|
+
a.ensureElements();
|
|
234
|
+
|
|
235
|
+
const b = new SnapshotInstance(s1);
|
|
236
|
+
const b1 = new SnapshotInstance(s11);
|
|
237
|
+
const c = new SnapshotInstance(s2);
|
|
238
|
+
|
|
239
|
+
a.insertBefore(b);
|
|
240
|
+
b.insertBefore(b1);
|
|
241
|
+
a.insertBefore(c);
|
|
242
|
+
|
|
243
|
+
const d1 = new SnapshotInstance(s3);
|
|
244
|
+
const d2 = new SnapshotInstance(s3);
|
|
245
|
+
const d3 = new SnapshotInstance(s3);
|
|
246
|
+
b1.insertBefore(d1);
|
|
247
|
+
b1.insertBefore(d2);
|
|
248
|
+
b1.insertBefore(d3);
|
|
249
|
+
|
|
250
|
+
expect(b1.childNodes.length).toMatchInlineSnapshot(`3`);
|
|
251
|
+
|
|
252
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
253
|
+
{
|
|
254
|
+
"-8": [
|
|
255
|
+
{
|
|
256
|
+
"insertAction": [
|
|
257
|
+
{
|
|
258
|
+
"position": 0,
|
|
259
|
+
"type": "__snapshot_a94a8_test_16",
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"position": 1,
|
|
263
|
+
"type": "__snapshot_a94a8_test_16",
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"position": 2,
|
|
267
|
+
"type": "__snapshot_a94a8_test_16",
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
"removeAction": [],
|
|
271
|
+
"updateAction": [],
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
}
|
|
275
|
+
`);
|
|
276
|
+
|
|
277
|
+
{
|
|
278
|
+
__pendingListUpdates.clearAttachedLists();
|
|
279
|
+
const d4 = new SnapshotInstance(s3);
|
|
280
|
+
const d5 = new SnapshotInstance(s3);
|
|
281
|
+
const d6 = new SnapshotInstance(s4);
|
|
282
|
+
const d7 = new SnapshotInstance(s4);
|
|
283
|
+
b1.insertBefore(d4);
|
|
284
|
+
b1.insertBefore(d5, d2);
|
|
285
|
+
b1.insertBefore(d6, d2);
|
|
286
|
+
b1.insertBefore(d7, d2);
|
|
287
|
+
b1.removeChild(d2);
|
|
288
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
289
|
+
{
|
|
290
|
+
"-8": [
|
|
291
|
+
{
|
|
292
|
+
"insertAction": [
|
|
293
|
+
{
|
|
294
|
+
"position": 1,
|
|
295
|
+
"type": "__snapshot_a94a8_test_16",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"position": 2,
|
|
299
|
+
"type": "__snapshot_a94a8_test_17",
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"position": 3,
|
|
303
|
+
"type": "__snapshot_a94a8_test_17",
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"position": 5,
|
|
307
|
+
"type": "__snapshot_a94a8_test_16",
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
"removeAction": [
|
|
311
|
+
1,
|
|
312
|
+
],
|
|
313
|
+
"updateAction": [],
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
}
|
|
317
|
+
`);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
{
|
|
321
|
+
__pendingListUpdates.clearAttachedLists();
|
|
322
|
+
b1.insertBefore(d3); // move
|
|
323
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
324
|
+
{
|
|
325
|
+
"-8": [
|
|
326
|
+
{
|
|
327
|
+
"insertAction": [
|
|
328
|
+
{
|
|
329
|
+
"position": 5,
|
|
330
|
+
"type": "__snapshot_a94a8_test_16",
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
"removeAction": [
|
|
334
|
+
4,
|
|
335
|
+
],
|
|
336
|
+
"updateAction": [],
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
}
|
|
340
|
+
`);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it(`"update-list-info" should work when setAttribute`, () => {
|
|
345
|
+
const s1 = __SNAPSHOT__(
|
|
346
|
+
<view>
|
|
347
|
+
<text>111</text>
|
|
348
|
+
{HOLE}
|
|
349
|
+
</view>,
|
|
350
|
+
);
|
|
351
|
+
const s11 = __SNAPSHOT__(
|
|
352
|
+
<list>{HOLE}</list>,
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
const b = new SnapshotInstance(s1);
|
|
356
|
+
b.ensureElements();
|
|
357
|
+
|
|
358
|
+
const b1 = new SnapshotInstance(s11);
|
|
359
|
+
b.insertBefore(b1);
|
|
360
|
+
|
|
361
|
+
const s3 = __SNAPSHOT__(
|
|
362
|
+
<list-item item-key={HOLE}>
|
|
363
|
+
<text>World</text>
|
|
364
|
+
</list-item>,
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
const d1 = new SnapshotInstance(s3);
|
|
368
|
+
const d2 = new SnapshotInstance(s3);
|
|
369
|
+
const d3 = new SnapshotInstance(s3);
|
|
370
|
+
b1.insertBefore(d1);
|
|
371
|
+
b1.insertBefore(d2);
|
|
372
|
+
b1.insertBefore(d3);
|
|
373
|
+
__pendingListUpdates.clearAttachedLists();
|
|
374
|
+
|
|
375
|
+
d1.setAttribute(0, { 'item-key': 1 });
|
|
376
|
+
d3.setAttribute(0, { 'item-key': 3 });
|
|
377
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
378
|
+
{
|
|
379
|
+
"-4": [
|
|
380
|
+
{
|
|
381
|
+
"insertAction": [],
|
|
382
|
+
"removeAction": [],
|
|
383
|
+
"updateAction": [
|
|
384
|
+
{
|
|
385
|
+
"flush": false,
|
|
386
|
+
"from": 0,
|
|
387
|
+
"item-key": 1,
|
|
388
|
+
"to": 0,
|
|
389
|
+
"type": "__snapshot_a94a8_test_20",
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"flush": false,
|
|
393
|
+
"from": 2,
|
|
394
|
+
"item-key": 3,
|
|
395
|
+
"to": 2,
|
|
396
|
+
"type": "__snapshot_a94a8_test_20",
|
|
397
|
+
},
|
|
398
|
+
],
|
|
399
|
+
},
|
|
400
|
+
],
|
|
401
|
+
}
|
|
402
|
+
`);
|
|
403
|
+
|
|
404
|
+
__pendingListUpdates.clearAttachedLists();
|
|
405
|
+
|
|
406
|
+
const d4 = new SnapshotInstance(s3);
|
|
407
|
+
const d5 = new SnapshotInstance(s3);
|
|
408
|
+
|
|
409
|
+
b1.insertBefore(d4, d2);
|
|
410
|
+
b1.insertBefore(d5, d2);
|
|
411
|
+
d2.setAttribute(0, { 'item-key': 2 });
|
|
412
|
+
|
|
413
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
414
|
+
{
|
|
415
|
+
"-4": [
|
|
416
|
+
{
|
|
417
|
+
"insertAction": [
|
|
418
|
+
{
|
|
419
|
+
"position": 1,
|
|
420
|
+
"type": "__snapshot_a94a8_test_20",
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"position": 2,
|
|
424
|
+
"type": "__snapshot_a94a8_test_20",
|
|
425
|
+
},
|
|
426
|
+
],
|
|
427
|
+
"removeAction": [],
|
|
428
|
+
"updateAction": [
|
|
429
|
+
{
|
|
430
|
+
"flush": false,
|
|
431
|
+
"from": 3,
|
|
432
|
+
"item-key": 2,
|
|
433
|
+
"to": 3,
|
|
434
|
+
"type": "__snapshot_a94a8_test_20",
|
|
435
|
+
},
|
|
436
|
+
],
|
|
437
|
+
},
|
|
438
|
+
],
|
|
439
|
+
}
|
|
440
|
+
`);
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
describe(`list componentAtIndex`, () => {
|
|
445
|
+
const s = __SNAPSHOT__(
|
|
446
|
+
<view>
|
|
447
|
+
<text>Hello</text>
|
|
448
|
+
{HOLE}
|
|
449
|
+
</view>,
|
|
450
|
+
);
|
|
451
|
+
const s1 = __SNAPSHOT__(
|
|
452
|
+
<view>
|
|
453
|
+
<text>111</text>
|
|
454
|
+
{HOLE}
|
|
455
|
+
</view>,
|
|
456
|
+
);
|
|
457
|
+
const s11 = __SNAPSHOT__(
|
|
458
|
+
<list id='list'>{HOLE}</list>,
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
const s3 = __SNAPSHOT__(
|
|
462
|
+
<list-item item-key={HOLE}>
|
|
463
|
+
<text>World</text>
|
|
464
|
+
</list-item>,
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
it('basic componentAtIndex after insert', () => {
|
|
468
|
+
const b = new SnapshotInstance(s1);
|
|
469
|
+
b.ensureElements();
|
|
470
|
+
const b1 = new SnapshotInstance(s11);
|
|
471
|
+
b.insertBefore(b1);
|
|
472
|
+
const listRef = b1.__elements[0];
|
|
473
|
+
|
|
474
|
+
const d1 = new SnapshotInstance(s3);
|
|
475
|
+
const d2 = new SnapshotInstance(s3);
|
|
476
|
+
const d3 = new SnapshotInstance(s3);
|
|
477
|
+
b1.insertBefore(d1);
|
|
478
|
+
b1.insertBefore(d2);
|
|
479
|
+
b1.insertBefore(d3);
|
|
480
|
+
|
|
481
|
+
// initial there is no child, because "update-list-info" is not flush
|
|
482
|
+
expect(() => {
|
|
483
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
484
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: childCtx not found]`);
|
|
485
|
+
|
|
486
|
+
// only call componentAtIndex after flush
|
|
487
|
+
__pendingListUpdates.flush();
|
|
488
|
+
expect(elementTree.triggerComponentAtIndex(listRef, 0)).toMatchInlineSnapshot(`5`);
|
|
489
|
+
expect(elementTree.triggerComponentAtIndex(listRef, 1)).toMatchInlineSnapshot(`8`);
|
|
490
|
+
expect(elementTree.triggerComponentAtIndex(listRef, 2)).toMatchInlineSnapshot(`11`);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it('remove list si', () => {
|
|
494
|
+
const a = new SnapshotInstance(s);
|
|
495
|
+
a.ensureElements();
|
|
496
|
+
|
|
497
|
+
const b = new SnapshotInstance(s1);
|
|
498
|
+
a.insertBefore(b);
|
|
499
|
+
const b1 = new SnapshotInstance(s11);
|
|
500
|
+
b.insertBefore(b1);
|
|
501
|
+
const listRef = b1.__elements[0];
|
|
502
|
+
expect(() => {
|
|
503
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
504
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: childCtx not found]`);
|
|
505
|
+
|
|
506
|
+
const d1 = new SnapshotInstance(s3);
|
|
507
|
+
const d2 = new SnapshotInstance(s3);
|
|
508
|
+
const d3 = new SnapshotInstance(s3);
|
|
509
|
+
b1.insertBefore(d1);
|
|
510
|
+
b1.insertBefore(d2);
|
|
511
|
+
b1.insertBefore(d3);
|
|
512
|
+
__pendingListUpdates.flush();
|
|
513
|
+
|
|
514
|
+
b.removeChild(b1);
|
|
515
|
+
expect(listRef.componentAtIndex()).toBe(-1);
|
|
516
|
+
expect(listRef.enqueueComponent()).toBeUndefined();
|
|
517
|
+
expect(listRef.componentAtIndexes()).toBeUndefined();
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it('should reuse and hydrate', () => {
|
|
521
|
+
const b = new SnapshotInstance(s1);
|
|
522
|
+
b.ensureElements();
|
|
523
|
+
const b1 = new SnapshotInstance(s11);
|
|
524
|
+
b.insertBefore(b1);
|
|
525
|
+
const listRef = b1.__elements[0];
|
|
526
|
+
|
|
527
|
+
const s3 = __SNAPSHOT__(
|
|
528
|
+
<list-item item-key={HOLE}>
|
|
529
|
+
<text bindtap={HOLE}>
|
|
530
|
+
<raw-text text={HOLE} />
|
|
531
|
+
</text>
|
|
532
|
+
</list-item>,
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
const c0 = new SnapshotInstance(s3);
|
|
536
|
+
const c1 = new SnapshotInstance(s3);
|
|
537
|
+
const c2 = new SnapshotInstance(s3);
|
|
538
|
+
const c3 = new SnapshotInstance(s3);
|
|
539
|
+
const c4 = new SnapshotInstance(s3);
|
|
540
|
+
const c5 = new SnapshotInstance(s3);
|
|
541
|
+
b1.insertBefore(c0);
|
|
542
|
+
b1.insertBefore(c1);
|
|
543
|
+
b1.insertBefore(c2);
|
|
544
|
+
b1.insertBefore(c3);
|
|
545
|
+
b1.insertBefore(c4);
|
|
546
|
+
b1.insertBefore(c5);
|
|
547
|
+
|
|
548
|
+
// item-key
|
|
549
|
+
c0.setAttribute(0, { 'item-key': 'key-0' });
|
|
550
|
+
c1.setAttribute(0, { 'item-key': 'key-1' });
|
|
551
|
+
c2.setAttribute(0, { 'item-key': 'key-2' });
|
|
552
|
+
c3.setAttribute(0, { 'item-key': 'key-3' });
|
|
553
|
+
c4.setAttribute(0, { 'item-key': 'key-4' });
|
|
554
|
+
c5.setAttribute(0, { 'item-key': 'key-5' });
|
|
555
|
+
|
|
556
|
+
// event
|
|
557
|
+
c0.setAttribute(1, 1);
|
|
558
|
+
c1.setAttribute(1, 1);
|
|
559
|
+
c2.setAttribute(1, 1);
|
|
560
|
+
c3.setAttribute(1, 1);
|
|
561
|
+
c4.setAttribute(1, 1);
|
|
562
|
+
c5.setAttribute(1, 1);
|
|
563
|
+
|
|
564
|
+
// text
|
|
565
|
+
c0.setAttribute(2, '0');
|
|
566
|
+
c1.setAttribute(2, '1');
|
|
567
|
+
c2.setAttribute(2, '2');
|
|
568
|
+
c3.setAttribute(2, '3');
|
|
569
|
+
c4.setAttribute(2, '4');
|
|
570
|
+
c5.setAttribute(2, '5');
|
|
571
|
+
|
|
572
|
+
__pendingListUpdates.flush();
|
|
573
|
+
|
|
574
|
+
{
|
|
575
|
+
const component = [];
|
|
576
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
577
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
578
|
+
component[2] = elementTree.triggerComponentAtIndex(listRef, 2);
|
|
579
|
+
component[3] = elementTree.triggerComponentAtIndex(listRef, 3);
|
|
580
|
+
|
|
581
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
582
|
+
component[4] = elementTree.triggerComponentAtIndex(listRef, 4);
|
|
583
|
+
expect(component[4]).toBe(component[0]);
|
|
584
|
+
|
|
585
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
586
|
+
component[5] = elementTree.triggerComponentAtIndex(listRef, 5);
|
|
587
|
+
expect(component[5]).toBe(component[1]);
|
|
588
|
+
|
|
589
|
+
// should ignore
|
|
590
|
+
elementTree.triggerEnqueueComponent(listRef, 99999);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
expect(listRef).toMatchInlineSnapshot(`
|
|
594
|
+
<list
|
|
595
|
+
id="list"
|
|
596
|
+
update-list-info={
|
|
597
|
+
[
|
|
598
|
+
{
|
|
599
|
+
"insertAction": [
|
|
600
|
+
{
|
|
601
|
+
"item-key": "key-0",
|
|
602
|
+
"position": 0,
|
|
603
|
+
"type": "__snapshot_a94a8_test_25",
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
"item-key": "key-1",
|
|
607
|
+
"position": 1,
|
|
608
|
+
"type": "__snapshot_a94a8_test_25",
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
"item-key": "key-2",
|
|
612
|
+
"position": 2,
|
|
613
|
+
"type": "__snapshot_a94a8_test_25",
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
"item-key": "key-3",
|
|
617
|
+
"position": 3,
|
|
618
|
+
"type": "__snapshot_a94a8_test_25",
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"item-key": "key-4",
|
|
622
|
+
"position": 4,
|
|
623
|
+
"type": "__snapshot_a94a8_test_25",
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"item-key": "key-5",
|
|
627
|
+
"position": 5,
|
|
628
|
+
"type": "__snapshot_a94a8_test_25",
|
|
629
|
+
},
|
|
630
|
+
],
|
|
631
|
+
"removeAction": [],
|
|
632
|
+
"updateAction": [],
|
|
633
|
+
},
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
>
|
|
637
|
+
<list-item
|
|
638
|
+
item-key="key-4"
|
|
639
|
+
>
|
|
640
|
+
<text
|
|
641
|
+
event={
|
|
642
|
+
{
|
|
643
|
+
"bindEvent:tap": "-8:1:",
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
>
|
|
647
|
+
<raw-text
|
|
648
|
+
text="4"
|
|
649
|
+
/>
|
|
650
|
+
</text>
|
|
651
|
+
</list-item>
|
|
652
|
+
<list-item
|
|
653
|
+
item-key="key-5"
|
|
654
|
+
>
|
|
655
|
+
<text
|
|
656
|
+
event={
|
|
657
|
+
{
|
|
658
|
+
"bindEvent:tap": "-9:1:",
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
>
|
|
662
|
+
<raw-text
|
|
663
|
+
text="5"
|
|
664
|
+
/>
|
|
665
|
+
</text>
|
|
666
|
+
</list-item>
|
|
667
|
+
<list-item
|
|
668
|
+
item-key="key-2"
|
|
669
|
+
>
|
|
670
|
+
<text
|
|
671
|
+
event={
|
|
672
|
+
{
|
|
673
|
+
"bindEvent:tap": "-6:1:",
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
>
|
|
677
|
+
<raw-text
|
|
678
|
+
text="2"
|
|
679
|
+
/>
|
|
680
|
+
</text>
|
|
681
|
+
</list-item>
|
|
682
|
+
<list-item
|
|
683
|
+
item-key="key-3"
|
|
684
|
+
>
|
|
685
|
+
<text
|
|
686
|
+
event={
|
|
687
|
+
{
|
|
688
|
+
"bindEvent:tap": "-7:1:",
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
>
|
|
692
|
+
<raw-text
|
|
693
|
+
text="3"
|
|
694
|
+
/>
|
|
695
|
+
</text>
|
|
696
|
+
</list-item>
|
|
697
|
+
</list>
|
|
698
|
+
`);
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
const _s3 = __SNAPSHOT__(<list-item item-key={HOLE}>{HOLE}</list-item>);
|
|
702
|
+
const _s4 = __SNAPSHOT__(<text>Hello</text>);
|
|
703
|
+
const _s5 = __SNAPSHOT__(<text>World</text>);
|
|
704
|
+
it('should reuse and hydrate - with childNodes', () => {
|
|
705
|
+
const b = new SnapshotInstance(s1);
|
|
706
|
+
b.ensureElements();
|
|
707
|
+
const b1 = new SnapshotInstance(s11);
|
|
708
|
+
b1.__slotIndex = 0;
|
|
709
|
+
b.insertBefore(b1);
|
|
710
|
+
const listRef = b1.__elements[0];
|
|
711
|
+
|
|
712
|
+
const c0 = new SnapshotInstance(_s3);
|
|
713
|
+
c0.__slotIndex = 0;
|
|
714
|
+
const c1 = new SnapshotInstance(_s3);
|
|
715
|
+
c1.__slotIndex = 0;
|
|
716
|
+
const c2 = new SnapshotInstance(_s3);
|
|
717
|
+
c2.__slotIndex = 0;
|
|
718
|
+
b1.insertBefore(c0);
|
|
719
|
+
b1.insertBefore(c1);
|
|
720
|
+
b1.insertBefore(c2);
|
|
721
|
+
|
|
722
|
+
const c0_d0 = new SnapshotInstance(_s4);
|
|
723
|
+
c0_d0.__slotIndex = 0;
|
|
724
|
+
const c0_d1 = new SnapshotInstance(_s5);
|
|
725
|
+
c0_d1.__slotIndex = 0;
|
|
726
|
+
c0.insertBefore(c0_d0);
|
|
727
|
+
c0.insertBefore(c0_d1);
|
|
728
|
+
|
|
729
|
+
const c1_d0 = new SnapshotInstance(_s4);
|
|
730
|
+
c1_d0.__slotIndex = 0;
|
|
731
|
+
c1.insertBefore(c1_d0);
|
|
732
|
+
|
|
733
|
+
const c2_d0 = new SnapshotInstance(_s5);
|
|
734
|
+
c2_d0.__slotIndex = 0;
|
|
735
|
+
c2.insertBefore(c2_d0);
|
|
736
|
+
|
|
737
|
+
__pendingListUpdates.flush();
|
|
738
|
+
|
|
739
|
+
const component = [];
|
|
740
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
741
|
+
|
|
742
|
+
expect(__FirstElement(listRef)).toMatchInlineSnapshot(`
|
|
743
|
+
<list-item>
|
|
744
|
+
<text>
|
|
745
|
+
<raw-text
|
|
746
|
+
text="Hello"
|
|
747
|
+
/>
|
|
748
|
+
</text>
|
|
749
|
+
<text>
|
|
750
|
+
<raw-text
|
|
751
|
+
text="World"
|
|
752
|
+
/>
|
|
753
|
+
</text>
|
|
754
|
+
</list-item>
|
|
755
|
+
`);
|
|
756
|
+
|
|
757
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
758
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
759
|
+
expect(component[1]).toBe(component[0]);
|
|
760
|
+
|
|
761
|
+
expect(__FirstElement(listRef)).toMatchInlineSnapshot(`
|
|
762
|
+
<list-item>
|
|
763
|
+
<text>
|
|
764
|
+
<raw-text
|
|
765
|
+
text="Hello"
|
|
766
|
+
/>
|
|
767
|
+
</text>
|
|
768
|
+
</list-item>
|
|
769
|
+
`);
|
|
770
|
+
|
|
771
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
772
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
773
|
+
expect(component[0]).toBe(component[1]);
|
|
774
|
+
|
|
775
|
+
expect(__FirstElement(listRef)).toMatchInlineSnapshot(`
|
|
776
|
+
<list-item>
|
|
777
|
+
<text>
|
|
778
|
+
<raw-text
|
|
779
|
+
text="Hello"
|
|
780
|
+
/>
|
|
781
|
+
</text>
|
|
782
|
+
<text>
|
|
783
|
+
<raw-text
|
|
784
|
+
text="World"
|
|
785
|
+
/>
|
|
786
|
+
</text>
|
|
787
|
+
</list-item>
|
|
788
|
+
`);
|
|
789
|
+
|
|
790
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
791
|
+
component[2] = elementTree.triggerComponentAtIndex(listRef, 2);
|
|
792
|
+
|
|
793
|
+
expect(__FirstElement(listRef)).toMatchInlineSnapshot(`
|
|
794
|
+
<list-item>
|
|
795
|
+
<text>
|
|
796
|
+
<raw-text
|
|
797
|
+
text="World"
|
|
798
|
+
/>
|
|
799
|
+
</text>
|
|
800
|
+
</list-item>
|
|
801
|
+
`);
|
|
802
|
+
|
|
803
|
+
elementTree.triggerEnqueueComponent(listRef, component[2]);
|
|
804
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
805
|
+
|
|
806
|
+
expect(__FirstElement(listRef)).toMatchInlineSnapshot(`
|
|
807
|
+
<list-item>
|
|
808
|
+
<text>
|
|
809
|
+
<raw-text
|
|
810
|
+
text="Hello"
|
|
811
|
+
/>
|
|
812
|
+
</text>
|
|
813
|
+
<text>
|
|
814
|
+
<raw-text
|
|
815
|
+
text="World"
|
|
816
|
+
/>
|
|
817
|
+
</text>
|
|
818
|
+
</list-item>
|
|
819
|
+
`);
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
it('should reuse and hydrate - with childNodes - move', () => {
|
|
823
|
+
const b = new SnapshotInstance(s1);
|
|
824
|
+
b.ensureElements();
|
|
825
|
+
const b1 = new SnapshotInstance(s11);
|
|
826
|
+
b.insertBefore(b1);
|
|
827
|
+
const listRef = b1.__elements[0];
|
|
828
|
+
|
|
829
|
+
const s3 = __SNAPSHOT__(<list-item item-key={HOLE}>{HOLE}</list-item>);
|
|
830
|
+
const s4 = __SNAPSHOT__(<text>Hello</text>);
|
|
831
|
+
const s5 = __SNAPSHOT__(<text>World</text>);
|
|
832
|
+
const s6 = __SNAPSHOT__(<text>!</text>);
|
|
833
|
+
|
|
834
|
+
const c0 = new SnapshotInstance(s3);
|
|
835
|
+
c0.__slotIndex = 0;
|
|
836
|
+
const c1 = new SnapshotInstance(s3);
|
|
837
|
+
c1.__slotIndex = 0;
|
|
838
|
+
b1.insertBefore(c0);
|
|
839
|
+
b1.insertBefore(c1);
|
|
840
|
+
|
|
841
|
+
const c0_d0 = new SnapshotInstance(s4);
|
|
842
|
+
c0_d0.__slotIndex = 0;
|
|
843
|
+
const c0_d1 = new SnapshotInstance(s5);
|
|
844
|
+
c0_d1.__slotIndex = 0;
|
|
845
|
+
const c0_d2 = new SnapshotInstance(s6);
|
|
846
|
+
c0_d2.__slotIndex = 0;
|
|
847
|
+
const c0_d0_ = new SnapshotInstance(s4);
|
|
848
|
+
c0_d0_.__slotIndex = 0;
|
|
849
|
+
c0.insertBefore(c0_d0);
|
|
850
|
+
c0.insertBefore(c0_d1);
|
|
851
|
+
c0.insertBefore(c0_d2);
|
|
852
|
+
c0.insertBefore(c0_d0_);
|
|
853
|
+
|
|
854
|
+
const c1_d0 = new SnapshotInstance(s4);
|
|
855
|
+
c1_d0.__slotIndex = 0;
|
|
856
|
+
const c1_d1 = new SnapshotInstance(s5);
|
|
857
|
+
c1_d1.__slotIndex = 0;
|
|
858
|
+
const c1_d2 = new SnapshotInstance(s6);
|
|
859
|
+
c1_d2.__slotIndex = 0;
|
|
860
|
+
const c1_d0_ = new SnapshotInstance(s4);
|
|
861
|
+
c1_d0_.__slotIndex = 0;
|
|
862
|
+
c1.insertBefore(c1_d0);
|
|
863
|
+
c1.insertBefore(c1_d2);
|
|
864
|
+
c1.insertBefore(c1_d1);
|
|
865
|
+
c1.insertBefore(c1_d0_);
|
|
866
|
+
|
|
867
|
+
__pendingListUpdates.flush();
|
|
868
|
+
|
|
869
|
+
const component = [];
|
|
870
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
871
|
+
|
|
872
|
+
expect(listRef).toMatchInlineSnapshot(`
|
|
873
|
+
<list
|
|
874
|
+
id="list"
|
|
875
|
+
update-list-info={
|
|
876
|
+
[
|
|
877
|
+
{
|
|
878
|
+
"insertAction": [
|
|
879
|
+
{
|
|
880
|
+
"position": 0,
|
|
881
|
+
"type": "__snapshot_a94a8_test_29",
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
"position": 1,
|
|
885
|
+
"type": "__snapshot_a94a8_test_29",
|
|
886
|
+
},
|
|
887
|
+
],
|
|
888
|
+
"removeAction": [],
|
|
889
|
+
"updateAction": [],
|
|
890
|
+
},
|
|
891
|
+
]
|
|
892
|
+
}
|
|
893
|
+
>
|
|
894
|
+
<list-item>
|
|
895
|
+
<text>
|
|
896
|
+
<raw-text
|
|
897
|
+
text="Hello"
|
|
898
|
+
/>
|
|
899
|
+
</text>
|
|
900
|
+
<text>
|
|
901
|
+
<raw-text
|
|
902
|
+
text="World"
|
|
903
|
+
/>
|
|
904
|
+
</text>
|
|
905
|
+
<text>
|
|
906
|
+
<raw-text
|
|
907
|
+
text="!"
|
|
908
|
+
/>
|
|
909
|
+
</text>
|
|
910
|
+
<text>
|
|
911
|
+
<raw-text
|
|
912
|
+
text="Hello"
|
|
913
|
+
/>
|
|
914
|
+
</text>
|
|
915
|
+
</list-item>
|
|
916
|
+
</list>
|
|
917
|
+
`);
|
|
918
|
+
|
|
919
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
920
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
921
|
+
expect(component[1]).toBe(component[0]);
|
|
922
|
+
|
|
923
|
+
expect(listRef).toMatchInlineSnapshot(`
|
|
924
|
+
<list
|
|
925
|
+
id="list"
|
|
926
|
+
update-list-info={
|
|
927
|
+
[
|
|
928
|
+
{
|
|
929
|
+
"insertAction": [
|
|
930
|
+
{
|
|
931
|
+
"position": 0,
|
|
932
|
+
"type": "__snapshot_a94a8_test_29",
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
"position": 1,
|
|
936
|
+
"type": "__snapshot_a94a8_test_29",
|
|
937
|
+
},
|
|
938
|
+
],
|
|
939
|
+
"removeAction": [],
|
|
940
|
+
"updateAction": [],
|
|
941
|
+
},
|
|
942
|
+
]
|
|
943
|
+
}
|
|
944
|
+
>
|
|
945
|
+
<list-item>
|
|
946
|
+
<text>
|
|
947
|
+
<raw-text
|
|
948
|
+
text="Hello"
|
|
949
|
+
/>
|
|
950
|
+
</text>
|
|
951
|
+
<text>
|
|
952
|
+
<raw-text
|
|
953
|
+
text="!"
|
|
954
|
+
/>
|
|
955
|
+
</text>
|
|
956
|
+
<text>
|
|
957
|
+
<raw-text
|
|
958
|
+
text="World"
|
|
959
|
+
/>
|
|
960
|
+
</text>
|
|
961
|
+
<text>
|
|
962
|
+
<raw-text
|
|
963
|
+
text="Hello"
|
|
964
|
+
/>
|
|
965
|
+
</text>
|
|
966
|
+
</list-item>
|
|
967
|
+
</list>
|
|
968
|
+
`);
|
|
969
|
+
|
|
970
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
971
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
972
|
+
expect(component[0]).toBe(component[1]);
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
it('should reuse and hydrate - item removed can be reused correctly', () => {
|
|
976
|
+
const b = new SnapshotInstance(s1);
|
|
977
|
+
b.ensureElements();
|
|
978
|
+
const b1 = new SnapshotInstance(s11);
|
|
979
|
+
b.insertBefore(b1);
|
|
980
|
+
const listRef = b1.__elements[0];
|
|
981
|
+
|
|
982
|
+
const c0 = new SnapshotInstance(_s3);
|
|
983
|
+
const c1 = new SnapshotInstance(_s3);
|
|
984
|
+
const c2 = new SnapshotInstance(_s3);
|
|
985
|
+
const c3 = new SnapshotInstance(_s3);
|
|
986
|
+
const c4 = new SnapshotInstance(_s3);
|
|
987
|
+
const c5 = new SnapshotInstance(_s3);
|
|
988
|
+
|
|
989
|
+
[c0, c1, c2, c3, c4, c5].forEach(c => {
|
|
990
|
+
const d0 = new SnapshotInstance(_s4);
|
|
991
|
+
const d1 = new SnapshotInstance(_s4);
|
|
992
|
+
const d2 = new SnapshotInstance(_s4);
|
|
993
|
+
const d3 = new SnapshotInstance(_s4);
|
|
994
|
+
|
|
995
|
+
c.insertBefore(d0);
|
|
996
|
+
c.insertBefore(d1);
|
|
997
|
+
c.insertBefore(d2);
|
|
998
|
+
c.insertBefore(d3);
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
b1.insertBefore(c0);
|
|
1002
|
+
b1.insertBefore(c1);
|
|
1003
|
+
b1.insertBefore(c2);
|
|
1004
|
+
b1.insertBefore(c3);
|
|
1005
|
+
b1.insertBefore(c4);
|
|
1006
|
+
b1.insertBefore(c5);
|
|
1007
|
+
|
|
1008
|
+
// item-key
|
|
1009
|
+
c0.setAttribute(0, { 'item-key': 'key-0' });
|
|
1010
|
+
c1.setAttribute(0, { 'item-key': 'key-1' });
|
|
1011
|
+
c2.setAttribute(0, { 'item-key': 'key-2' });
|
|
1012
|
+
c3.setAttribute(0, { 'item-key': 'key-3' });
|
|
1013
|
+
c4.setAttribute(0, { 'item-key': 'key-4' });
|
|
1014
|
+
c5.setAttribute(0, { 'item-key': 'key-5' });
|
|
1015
|
+
|
|
1016
|
+
__pendingListUpdates.flush();
|
|
1017
|
+
|
|
1018
|
+
const component = [];
|
|
1019
|
+
{
|
|
1020
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
1021
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
1022
|
+
component[2] = elementTree.triggerComponentAtIndex(listRef, 2);
|
|
1023
|
+
component[3] = elementTree.triggerComponentAtIndex(listRef, 3);
|
|
1024
|
+
|
|
1025
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
1026
|
+
component[4] = elementTree.triggerComponentAtIndex(listRef, 4);
|
|
1027
|
+
expect(component[4]).toBe(component[0]);
|
|
1028
|
+
|
|
1029
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
1030
|
+
component[5] = elementTree.triggerComponentAtIndex(listRef, 5);
|
|
1031
|
+
expect(component[5]).toBe(component[1]);
|
|
1032
|
+
|
|
1033
|
+
// should ignore
|
|
1034
|
+
elementTree.triggerEnqueueComponent(listRef, 99999);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
b1.removeChild(c3);
|
|
1038
|
+
__pendingListUpdates.flush();
|
|
1039
|
+
elementTree.triggerEnqueueComponent(listRef, component[3]);
|
|
1040
|
+
|
|
1041
|
+
nativeMethodQueue.clear();
|
|
1042
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
1043
|
+
|
|
1044
|
+
expect(nativeMethodQueue).toMatchInlineSnapshot(`
|
|
1045
|
+
[
|
|
1046
|
+
[
|
|
1047
|
+
"__SetAttribute",
|
|
1048
|
+
[
|
|
1049
|
+
<list-item
|
|
1050
|
+
item-key="key-1"
|
|
1051
|
+
>
|
|
1052
|
+
<text>
|
|
1053
|
+
<raw-text
|
|
1054
|
+
text="Hello"
|
|
1055
|
+
/>
|
|
1056
|
+
</text>
|
|
1057
|
+
<text>
|
|
1058
|
+
<raw-text
|
|
1059
|
+
text="Hello"
|
|
1060
|
+
/>
|
|
1061
|
+
</text>
|
|
1062
|
+
<text>
|
|
1063
|
+
<raw-text
|
|
1064
|
+
text="Hello"
|
|
1065
|
+
/>
|
|
1066
|
+
</text>
|
|
1067
|
+
<text>
|
|
1068
|
+
<raw-text
|
|
1069
|
+
text="Hello"
|
|
1070
|
+
/>
|
|
1071
|
+
</text>
|
|
1072
|
+
</list-item>,
|
|
1073
|
+
"item-key",
|
|
1074
|
+
"key-1",
|
|
1075
|
+
],
|
|
1076
|
+
],
|
|
1077
|
+
[
|
|
1078
|
+
"__FlushElementTree",
|
|
1079
|
+
[
|
|
1080
|
+
<list-item
|
|
1081
|
+
item-key="key-1"
|
|
1082
|
+
>
|
|
1083
|
+
<text>
|
|
1084
|
+
<raw-text
|
|
1085
|
+
text="Hello"
|
|
1086
|
+
/>
|
|
1087
|
+
</text>
|
|
1088
|
+
<text>
|
|
1089
|
+
<raw-text
|
|
1090
|
+
text="Hello"
|
|
1091
|
+
/>
|
|
1092
|
+
</text>
|
|
1093
|
+
<text>
|
|
1094
|
+
<raw-text
|
|
1095
|
+
text="Hello"
|
|
1096
|
+
/>
|
|
1097
|
+
</text>
|
|
1098
|
+
<text>
|
|
1099
|
+
<raw-text
|
|
1100
|
+
text="Hello"
|
|
1101
|
+
/>
|
|
1102
|
+
</text>
|
|
1103
|
+
</list-item>,
|
|
1104
|
+
{
|
|
1105
|
+
"elementID": 32,
|
|
1106
|
+
"listID": 4,
|
|
1107
|
+
"operationID": undefined,
|
|
1108
|
+
"triggerLayout": true,
|
|
1109
|
+
},
|
|
1110
|
+
],
|
|
1111
|
+
],
|
|
1112
|
+
]
|
|
1113
|
+
`);
|
|
1114
|
+
});
|
|
1115
|
+
|
|
1116
|
+
it('should reuse and hydrate - with slot', () => {
|
|
1117
|
+
const b = new SnapshotInstance(s1);
|
|
1118
|
+
b.ensureElements();
|
|
1119
|
+
const b1 = new SnapshotInstance(s11);
|
|
1120
|
+
b.insertBefore(b1);
|
|
1121
|
+
const listRef = b1.__elements[0];
|
|
1122
|
+
|
|
1123
|
+
const s3 = __SNAPSHOT__(
|
|
1124
|
+
<list-item item-key={HOLE}>
|
|
1125
|
+
{HOLE}!{HOLE}
|
|
1126
|
+
</list-item>,
|
|
1127
|
+
);
|
|
1128
|
+
const x = <view id='!'>{HOLE}</view>;
|
|
1129
|
+
const slot = __SNAPSHOT__(<view id='!'>{HOLE}</view>);
|
|
1130
|
+
const slotInner = __SNAPSHOT__(<text />);
|
|
1131
|
+
|
|
1132
|
+
const c0 = new SnapshotInstance(s3);
|
|
1133
|
+
const c1 = new SnapshotInstance(s3);
|
|
1134
|
+
b1.insertBefore(c0);
|
|
1135
|
+
b1.insertBefore(c1);
|
|
1136
|
+
|
|
1137
|
+
const c0_d0 = new SnapshotInstance(slot);
|
|
1138
|
+
c0_d0.__slotIndex = 0;
|
|
1139
|
+
c0_d0.insertBefore(new SnapshotInstance(slotInner));
|
|
1140
|
+
const c0_d1 = new SnapshotInstance(slot);
|
|
1141
|
+
c0_d1.__slotIndex = 1;
|
|
1142
|
+
c0_d1.insertBefore(new SnapshotInstance(slotInner));
|
|
1143
|
+
c0.insertBefore(c0_d0);
|
|
1144
|
+
c0.insertBefore(c0_d1);
|
|
1145
|
+
|
|
1146
|
+
const c1_d0 = new SnapshotInstance(slot);
|
|
1147
|
+
c1_d0.insertBefore(new SnapshotInstance(slotInner));
|
|
1148
|
+
const c1_d1 = new SnapshotInstance(slot);
|
|
1149
|
+
c1_d1.insertBefore(new SnapshotInstance(slotInner));
|
|
1150
|
+
c1.insertBefore(c1_d0);
|
|
1151
|
+
c1.insertBefore(c1_d1);
|
|
1152
|
+
|
|
1153
|
+
__pendingListUpdates.flush();
|
|
1154
|
+
|
|
1155
|
+
const component = [];
|
|
1156
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
1157
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
1158
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
1159
|
+
expect(component[1]).toBe(component[0]);
|
|
1160
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
1161
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
1162
|
+
expect(component[0]).toBe(component[1]);
|
|
1163
|
+
|
|
1164
|
+
expect(listRef).toMatchInlineSnapshot(`
|
|
1165
|
+
<list
|
|
1166
|
+
id="list"
|
|
1167
|
+
update-list-info={
|
|
1168
|
+
[
|
|
1169
|
+
{
|
|
1170
|
+
"insertAction": [
|
|
1171
|
+
{
|
|
1172
|
+
"position": 0,
|
|
1173
|
+
"type": "__snapshot_a94a8_test_33",
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
"position": 1,
|
|
1177
|
+
"type": "__snapshot_a94a8_test_33",
|
|
1178
|
+
},
|
|
1179
|
+
],
|
|
1180
|
+
"removeAction": [],
|
|
1181
|
+
"updateAction": [],
|
|
1182
|
+
},
|
|
1183
|
+
]
|
|
1184
|
+
}
|
|
1185
|
+
>
|
|
1186
|
+
<list-item>
|
|
1187
|
+
<wrapper>
|
|
1188
|
+
<view
|
|
1189
|
+
id="!"
|
|
1190
|
+
>
|
|
1191
|
+
<text />
|
|
1192
|
+
</view>
|
|
1193
|
+
</wrapper>
|
|
1194
|
+
<raw-text
|
|
1195
|
+
text="!"
|
|
1196
|
+
/>
|
|
1197
|
+
<wrapper>
|
|
1198
|
+
<view
|
|
1199
|
+
id="!"
|
|
1200
|
+
>
|
|
1201
|
+
<text />
|
|
1202
|
+
</view>
|
|
1203
|
+
</wrapper>
|
|
1204
|
+
</list-item>
|
|
1205
|
+
</list>
|
|
1206
|
+
`);
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1209
|
+
it('should handle continuous componentAtIndex on same index', () => {
|
|
1210
|
+
const b = new SnapshotInstance(s1);
|
|
1211
|
+
b.ensureElements();
|
|
1212
|
+
const b1 = new SnapshotInstance(s11);
|
|
1213
|
+
b.insertBefore(b1);
|
|
1214
|
+
const listRef = b1.__elements[0];
|
|
1215
|
+
|
|
1216
|
+
const s3 = __SNAPSHOT__(
|
|
1217
|
+
<list-item item-key={HOLE}>
|
|
1218
|
+
<text>World</text>
|
|
1219
|
+
</list-item>,
|
|
1220
|
+
);
|
|
1221
|
+
|
|
1222
|
+
const d1 = new SnapshotInstance(s3);
|
|
1223
|
+
const d2 = new SnapshotInstance(s3);
|
|
1224
|
+
const d3 = new SnapshotInstance(s3);
|
|
1225
|
+
b1.insertBefore(d1);
|
|
1226
|
+
b1.insertBefore(d2);
|
|
1227
|
+
b1.insertBefore(d3);
|
|
1228
|
+
|
|
1229
|
+
// initial there is no child, because "update-list-info" is not flush
|
|
1230
|
+
expect(() => {
|
|
1231
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
1232
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: childCtx not found]`);
|
|
1233
|
+
|
|
1234
|
+
// only call componentAtIndex after flush
|
|
1235
|
+
__pendingListUpdates.flush();
|
|
1236
|
+
expect(elementTree.triggerComponentAtIndex(listRef, 0)).toMatchInlineSnapshot(`5`);
|
|
1237
|
+
expect(elementTree.triggerComponentAtIndex(listRef, 0)).toMatchInlineSnapshot(`8`); // should return a new uiSign
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
it('should handle continuous componentAtIndex on same index - self reuse', () => {
|
|
1241
|
+
const b = new SnapshotInstance(s1);
|
|
1242
|
+
b.ensureElements();
|
|
1243
|
+
const b1 = new SnapshotInstance(s11);
|
|
1244
|
+
b.insertBefore(b1);
|
|
1245
|
+
const listRef = b1.__elements[0];
|
|
1246
|
+
|
|
1247
|
+
const s3 = __SNAPSHOT__(
|
|
1248
|
+
<list-item item-key={HOLE}>
|
|
1249
|
+
<text>World</text>
|
|
1250
|
+
</list-item>,
|
|
1251
|
+
);
|
|
1252
|
+
|
|
1253
|
+
const d1 = new SnapshotInstance(s3);
|
|
1254
|
+
const d2 = new SnapshotInstance(s3);
|
|
1255
|
+
const d3 = new SnapshotInstance(s3);
|
|
1256
|
+
b1.insertBefore(d1);
|
|
1257
|
+
b1.insertBefore(d2);
|
|
1258
|
+
b1.insertBefore(d3);
|
|
1259
|
+
|
|
1260
|
+
// initial there is no child, because "update-list-info" is not flush
|
|
1261
|
+
expect(() => {
|
|
1262
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
1263
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: childCtx not found]`);
|
|
1264
|
+
|
|
1265
|
+
// only call componentAtIndex after flush
|
|
1266
|
+
__pendingListUpdates.flush();
|
|
1267
|
+
let uiSign;
|
|
1268
|
+
expect(uiSign = elementTree.triggerComponentAtIndex(listRef, 0)).toMatchInlineSnapshot(`5`);
|
|
1269
|
+
elementTree.triggerEnqueueComponent(listRef, uiSign);
|
|
1270
|
+
expect(elementTree.triggerComponentAtIndex(listRef, 0)).toMatchInlineSnapshot(`5`); // should reuse self
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
it('should handle componentAtIndex when `enableReuseNotification` is true', () => {
|
|
1274
|
+
const b = new SnapshotInstance(s1);
|
|
1275
|
+
b.ensureElements();
|
|
1276
|
+
const b1 = new SnapshotInstance(s11);
|
|
1277
|
+
b.insertBefore(b1);
|
|
1278
|
+
const listRef = b1.__elements[0];
|
|
1279
|
+
|
|
1280
|
+
const s3 = __SNAPSHOT__(
|
|
1281
|
+
<list-item item-key={HOLE}>
|
|
1282
|
+
<text>World</text>
|
|
1283
|
+
</list-item>,
|
|
1284
|
+
);
|
|
1285
|
+
|
|
1286
|
+
const d0 = new SnapshotInstance(s3);
|
|
1287
|
+
const d1 = new SnapshotInstance(s3);
|
|
1288
|
+
const d2 = new SnapshotInstance(s3);
|
|
1289
|
+
const d3 = new SnapshotInstance(s3);
|
|
1290
|
+
const d4 = new SnapshotInstance(s3);
|
|
1291
|
+
const d5 = new SnapshotInstance(s3);
|
|
1292
|
+
d0.setAttribute(0, { 'item-key': '0' });
|
|
1293
|
+
d1.setAttribute(0, { 'item-key': '1' });
|
|
1294
|
+
d2.setAttribute(0, { 'item-key': '2' });
|
|
1295
|
+
d3.setAttribute(0, { 'item-key': '3' });
|
|
1296
|
+
d4.setAttribute(0, { 'item-key': '4' });
|
|
1297
|
+
d5.setAttribute(0, { 'item-key': '5' });
|
|
1298
|
+
b1.insertBefore(d0);
|
|
1299
|
+
b1.insertBefore(d1);
|
|
1300
|
+
b1.insertBefore(d2);
|
|
1301
|
+
b1.insertBefore(d3);
|
|
1302
|
+
b1.insertBefore(d4);
|
|
1303
|
+
b1.insertBefore(d5);
|
|
1304
|
+
|
|
1305
|
+
__pendingListUpdates.flush();
|
|
1306
|
+
|
|
1307
|
+
const fn = vi.fn();
|
|
1308
|
+
const __original = globalThis.__FlushElementTree;
|
|
1309
|
+
globalThis.__FlushElementTree = (_, options = {}) => {
|
|
1310
|
+
const { elementID, listReuseNotification: { itemKey } = {} } = options;
|
|
1311
|
+
fn(elementID, itemKey);
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
{
|
|
1315
|
+
const component = [];
|
|
1316
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0, undefined, true);
|
|
1317
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1, undefined, true);
|
|
1318
|
+
component[2] = elementTree.triggerComponentAtIndex(listRef, 2, undefined, true);
|
|
1319
|
+
component[3] = elementTree.triggerComponentAtIndex(listRef, 3, undefined, true);
|
|
1320
|
+
|
|
1321
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
1322
|
+
component[4] = elementTree.triggerComponentAtIndex(listRef, 4, undefined, true);
|
|
1323
|
+
expect(component[4]).toBe(component[0]);
|
|
1324
|
+
|
|
1325
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
1326
|
+
component[5] = elementTree.triggerComponentAtIndex(listRef, 5, undefined, true);
|
|
1327
|
+
expect(component[5]).toBe(component[1]);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
globalThis.__FlushElementTree = __original;
|
|
1331
|
+
|
|
1332
|
+
expect(fn.mock.calls).toMatchInlineSnapshot(`
|
|
1333
|
+
[
|
|
1334
|
+
[
|
|
1335
|
+
5,
|
|
1336
|
+
undefined,
|
|
1337
|
+
],
|
|
1338
|
+
[
|
|
1339
|
+
8,
|
|
1340
|
+
undefined,
|
|
1341
|
+
],
|
|
1342
|
+
[
|
|
1343
|
+
11,
|
|
1344
|
+
undefined,
|
|
1345
|
+
],
|
|
1346
|
+
[
|
|
1347
|
+
14,
|
|
1348
|
+
undefined,
|
|
1349
|
+
],
|
|
1350
|
+
[
|
|
1351
|
+
5,
|
|
1352
|
+
"4",
|
|
1353
|
+
],
|
|
1354
|
+
[
|
|
1355
|
+
8,
|
|
1356
|
+
"5",
|
|
1357
|
+
],
|
|
1358
|
+
]
|
|
1359
|
+
`);
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
it('should handle componentAtIndex when there is `reuse-identifier`', () => {
|
|
1363
|
+
const b = new SnapshotInstance(s1);
|
|
1364
|
+
b.ensureElements();
|
|
1365
|
+
const b1 = new SnapshotInstance(s11);
|
|
1366
|
+
b.insertBefore(b1);
|
|
1367
|
+
const listRef = b1.__elements[0];
|
|
1368
|
+
|
|
1369
|
+
const d0 = new SnapshotInstance(s3);
|
|
1370
|
+
const d1 = new SnapshotInstance(s3);
|
|
1371
|
+
const d2 = new SnapshotInstance(s3);
|
|
1372
|
+
const d3 = new SnapshotInstance(s3);
|
|
1373
|
+
const d4 = new SnapshotInstance(s3);
|
|
1374
|
+
const d5 = new SnapshotInstance(s3);
|
|
1375
|
+
|
|
1376
|
+
d0.setAttribute(0, { 'item-key': '0', 'reuse-identifier': 'a' });
|
|
1377
|
+
d1.setAttribute(0, { 'item-key': '1', 'reuse-identifier': 'a' });
|
|
1378
|
+
d2.setAttribute(0, { 'item-key': '2', 'reuse-identifier': 'a' });
|
|
1379
|
+
d3.setAttribute(0, { 'item-key': '3', 'reuse-identifier': 'b' });
|
|
1380
|
+
d4.setAttribute(0, { 'item-key': '4', 'reuse-identifier': 'b' });
|
|
1381
|
+
d5.setAttribute(0, { 'item-key': '5', 'reuse-identifier': 'b' });
|
|
1382
|
+
|
|
1383
|
+
b1.insertBefore(d0);
|
|
1384
|
+
b1.insertBefore(d1);
|
|
1385
|
+
b1.insertBefore(d2);
|
|
1386
|
+
b1.insertBefore(d3);
|
|
1387
|
+
b1.insertBefore(d4);
|
|
1388
|
+
b1.insertBefore(d5);
|
|
1389
|
+
|
|
1390
|
+
__pendingListUpdates.flush();
|
|
1391
|
+
|
|
1392
|
+
{
|
|
1393
|
+
const component = [];
|
|
1394
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
1395
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
1396
|
+
|
|
1397
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
1398
|
+
|
|
1399
|
+
// 3 cannot reuse 0, but 2 can
|
|
1400
|
+
component[3] = elementTree.triggerComponentAtIndex(listRef, 3);
|
|
1401
|
+
expect(component[3]).not.toBe(component[0]);
|
|
1402
|
+
component[2] = elementTree.triggerComponentAtIndex(listRef, 2);
|
|
1403
|
+
expect(component[2]).toBe(component[0]);
|
|
1404
|
+
|
|
1405
|
+
elementTree.triggerEnqueueComponent(listRef, component[3]);
|
|
1406
|
+
// 5 can reuse 3
|
|
1407
|
+
component[5] = elementTree.triggerComponentAtIndex(listRef, 5);
|
|
1408
|
+
expect(component[5]).toBe(component[3]);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
// reuse-identifier should not be visible from element
|
|
1412
|
+
expect(__FirstElement(listRef)).toMatchInlineSnapshot(`
|
|
1413
|
+
<list-item
|
|
1414
|
+
item-key="2"
|
|
1415
|
+
>
|
|
1416
|
+
<text>
|
|
1417
|
+
<raw-text
|
|
1418
|
+
text="World"
|
|
1419
|
+
/>
|
|
1420
|
+
</text>
|
|
1421
|
+
</list-item>
|
|
1422
|
+
`);
|
|
1423
|
+
});
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1426
|
+
describe('list reload', () => {
|
|
1427
|
+
const s1 = __SNAPSHOT__(
|
|
1428
|
+
<view>
|
|
1429
|
+
<text>111</text>
|
|
1430
|
+
{HOLE}
|
|
1431
|
+
</view>,
|
|
1432
|
+
);
|
|
1433
|
+
const s11 = __SNAPSHOT__(
|
|
1434
|
+
<list id='list'>{HOLE}</list>,
|
|
1435
|
+
);
|
|
1436
|
+
|
|
1437
|
+
it('For same-type list-item with different item-key, do an insert + remove so the SDK detects it.', () => {
|
|
1438
|
+
const b = new SnapshotInstance(s1);
|
|
1439
|
+
b.ensureElements();
|
|
1440
|
+
const root = b.__element_root;
|
|
1441
|
+
const b1 = new SnapshotInstance(s11);
|
|
1442
|
+
b1.__slotIndex = 0;
|
|
1443
|
+
b.insertBefore(b1);
|
|
1444
|
+
|
|
1445
|
+
const s3 = __SNAPSHOT__(
|
|
1446
|
+
<list-item item-key={HOLE}>
|
|
1447
|
+
<text>World</text>
|
|
1448
|
+
</list-item>,
|
|
1449
|
+
);
|
|
1450
|
+
|
|
1451
|
+
const d1 = new SnapshotInstance(s3); // a
|
|
1452
|
+
d1.__slotIndex = 0;
|
|
1453
|
+
const d2 = new SnapshotInstance(s3); // b
|
|
1454
|
+
d2.__slotIndex = 0;
|
|
1455
|
+
const d3 = new SnapshotInstance(s3); // c
|
|
1456
|
+
d3.__slotIndex = 0;
|
|
1457
|
+
const d4 = new SnapshotInstance(s3); // d
|
|
1458
|
+
d4.__slotIndex = 0;
|
|
1459
|
+
|
|
1460
|
+
d1.setAttribute(0, { 'item-key': 'a' });
|
|
1461
|
+
d2.setAttribute(0, { 'item-key': 'b' });
|
|
1462
|
+
d3.setAttribute(0, { 'item-key': 'c' });
|
|
1463
|
+
d4.setAttribute(0, { 'item-key': 'd' });
|
|
1464
|
+
b1.insertBefore(d1);
|
|
1465
|
+
b1.insertBefore(d2);
|
|
1466
|
+
b1.insertBefore(d3);
|
|
1467
|
+
b1.insertBefore(d4);
|
|
1468
|
+
|
|
1469
|
+
__pendingListUpdates.flush();
|
|
1470
|
+
|
|
1471
|
+
const bb = new SnapshotInstance(s1);
|
|
1472
|
+
{
|
|
1473
|
+
const bb1 = new SnapshotInstance(s11);
|
|
1474
|
+
bb1.__slotIndex = 0;
|
|
1475
|
+
bb.insertBefore(bb1);
|
|
1476
|
+
const d1 = new SnapshotInstance(s3); // a1
|
|
1477
|
+
d1.__slotIndex = 0;
|
|
1478
|
+
const d2 = new SnapshotInstance(s3); // b1
|
|
1479
|
+
d2.__slotIndex = 0;
|
|
1480
|
+
const d3 = new SnapshotInstance(s3); // c1
|
|
1481
|
+
d3.__slotIndex = 0;
|
|
1482
|
+
const d4 = new SnapshotInstance(s3); // d1
|
|
1483
|
+
d4.__slotIndex = 0;
|
|
1484
|
+
d1.setAttribute(0, { 'item-key': 'a1' });
|
|
1485
|
+
d2.setAttribute(0, { 'item-key': 'b1' });
|
|
1486
|
+
d3.setAttribute(0, { 'item-key': 'c1' });
|
|
1487
|
+
d4.setAttribute(0, { 'item-key': 'd1' });
|
|
1488
|
+
bb1.insertBefore(d1);
|
|
1489
|
+
bb1.insertBefore(d2);
|
|
1490
|
+
bb1.insertBefore(d3);
|
|
1491
|
+
bb1.insertBefore(d4);
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
hydrate(b, bb);
|
|
1495
|
+
b.unRenderElements();
|
|
1496
|
+
|
|
1497
|
+
expect(root).toMatchInlineSnapshot(`
|
|
1498
|
+
<view>
|
|
1499
|
+
<text>
|
|
1500
|
+
<raw-text
|
|
1501
|
+
text="111"
|
|
1502
|
+
/>
|
|
1503
|
+
</text>
|
|
1504
|
+
<wrapper>
|
|
1505
|
+
<list
|
|
1506
|
+
id="list"
|
|
1507
|
+
update-list-info={
|
|
1508
|
+
[
|
|
1509
|
+
{
|
|
1510
|
+
"insertAction": [
|
|
1511
|
+
{
|
|
1512
|
+
"item-key": "a",
|
|
1513
|
+
"position": 0,
|
|
1514
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
"item-key": "b",
|
|
1518
|
+
"position": 1,
|
|
1519
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1520
|
+
},
|
|
1521
|
+
{
|
|
1522
|
+
"item-key": "c",
|
|
1523
|
+
"position": 2,
|
|
1524
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1525
|
+
},
|
|
1526
|
+
{
|
|
1527
|
+
"item-key": "d",
|
|
1528
|
+
"position": 3,
|
|
1529
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1530
|
+
},
|
|
1531
|
+
],
|
|
1532
|
+
"removeAction": [],
|
|
1533
|
+
"updateAction": [],
|
|
1534
|
+
},
|
|
1535
|
+
{
|
|
1536
|
+
"insertAction": [
|
|
1537
|
+
{
|
|
1538
|
+
"item-key": "a1",
|
|
1539
|
+
"position": 0,
|
|
1540
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1541
|
+
},
|
|
1542
|
+
{
|
|
1543
|
+
"item-key": "b1",
|
|
1544
|
+
"position": 1,
|
|
1545
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1546
|
+
},
|
|
1547
|
+
{
|
|
1548
|
+
"item-key": "c1",
|
|
1549
|
+
"position": 2,
|
|
1550
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
"item-key": "d1",
|
|
1554
|
+
"position": 3,
|
|
1555
|
+
"type": "__snapshot_a94a8_test_42",
|
|
1556
|
+
},
|
|
1557
|
+
],
|
|
1558
|
+
"removeAction": [
|
|
1559
|
+
0,
|
|
1560
|
+
1,
|
|
1561
|
+
2,
|
|
1562
|
+
3,
|
|
1563
|
+
],
|
|
1564
|
+
"updateAction": [],
|
|
1565
|
+
},
|
|
1566
|
+
]
|
|
1567
|
+
}
|
|
1568
|
+
/>
|
|
1569
|
+
</wrapper>
|
|
1570
|
+
</view>
|
|
1571
|
+
`);
|
|
1572
|
+
});
|
|
1573
|
+
|
|
1574
|
+
it('list-item with same type - remove', () => {
|
|
1575
|
+
const b = new SnapshotInstance(s1);
|
|
1576
|
+
b.ensureElements();
|
|
1577
|
+
const root = b.__element_root;
|
|
1578
|
+
|
|
1579
|
+
const b1 = new SnapshotInstance(s11);
|
|
1580
|
+
b1.__slotIndex = 0;
|
|
1581
|
+
b.insertBefore(b1);
|
|
1582
|
+
|
|
1583
|
+
const s3 = __SNAPSHOT__(
|
|
1584
|
+
<list-item item-key={HOLE}>
|
|
1585
|
+
<text>World</text>
|
|
1586
|
+
</list-item>,
|
|
1587
|
+
);
|
|
1588
|
+
|
|
1589
|
+
const d1 = new SnapshotInstance(s3);
|
|
1590
|
+
d1.__slotIndex = 0;
|
|
1591
|
+
const d2 = new SnapshotInstance(s3);
|
|
1592
|
+
d2.__slotIndex = 0;
|
|
1593
|
+
const d3 = new SnapshotInstance(s3);
|
|
1594
|
+
d3.__slotIndex = 0;
|
|
1595
|
+
b1.insertBefore(d1);
|
|
1596
|
+
b1.insertBefore(d2);
|
|
1597
|
+
b1.insertBefore(d3);
|
|
1598
|
+
|
|
1599
|
+
__pendingListUpdates.flush();
|
|
1600
|
+
|
|
1601
|
+
const bb = new SnapshotInstance(s1);
|
|
1602
|
+
{
|
|
1603
|
+
const b1 = new SnapshotInstance(s11);
|
|
1604
|
+
b1.__slotIndex = 0;
|
|
1605
|
+
bb.insertBefore(b1);
|
|
1606
|
+
|
|
1607
|
+
const d1 = new SnapshotInstance(s3);
|
|
1608
|
+
d1.__slotIndex = 0;
|
|
1609
|
+
const d2 = new SnapshotInstance(s3);
|
|
1610
|
+
d2.__slotIndex = 0;
|
|
1611
|
+
b1.insertBefore(d1);
|
|
1612
|
+
b1.insertBefore(d2);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
hydrate(b, bb);
|
|
1616
|
+
b.unRenderElements();
|
|
1617
|
+
|
|
1618
|
+
expect(root).toMatchInlineSnapshot(`
|
|
1619
|
+
<view>
|
|
1620
|
+
<text>
|
|
1621
|
+
<raw-text
|
|
1622
|
+
text="111"
|
|
1623
|
+
/>
|
|
1624
|
+
</text>
|
|
1625
|
+
<wrapper>
|
|
1626
|
+
<list
|
|
1627
|
+
id="list"
|
|
1628
|
+
update-list-info={
|
|
1629
|
+
[
|
|
1630
|
+
{
|
|
1631
|
+
"insertAction": [
|
|
1632
|
+
{
|
|
1633
|
+
"position": 0,
|
|
1634
|
+
"type": "__snapshot_a94a8_test_43",
|
|
1635
|
+
},
|
|
1636
|
+
{
|
|
1637
|
+
"position": 1,
|
|
1638
|
+
"type": "__snapshot_a94a8_test_43",
|
|
1639
|
+
},
|
|
1640
|
+
{
|
|
1641
|
+
"position": 2,
|
|
1642
|
+
"type": "__snapshot_a94a8_test_43",
|
|
1643
|
+
},
|
|
1644
|
+
],
|
|
1645
|
+
"removeAction": [],
|
|
1646
|
+
"updateAction": [],
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
"insertAction": [],
|
|
1650
|
+
"removeAction": [
|
|
1651
|
+
2,
|
|
1652
|
+
],
|
|
1653
|
+
"updateAction": [],
|
|
1654
|
+
},
|
|
1655
|
+
]
|
|
1656
|
+
}
|
|
1657
|
+
/>
|
|
1658
|
+
</wrapper>
|
|
1659
|
+
</view>
|
|
1660
|
+
`);
|
|
1661
|
+
|
|
1662
|
+
// go back to test insert
|
|
1663
|
+
hydrate(bb, b);
|
|
1664
|
+
bb.unRenderElements();
|
|
1665
|
+
expect(root).toMatchInlineSnapshot(`
|
|
1666
|
+
<view>
|
|
1667
|
+
<text>
|
|
1668
|
+
<raw-text
|
|
1669
|
+
text="111"
|
|
1670
|
+
/>
|
|
1671
|
+
</text>
|
|
1672
|
+
<wrapper>
|
|
1673
|
+
<list
|
|
1674
|
+
id="list"
|
|
1675
|
+
update-list-info={
|
|
1676
|
+
[
|
|
1677
|
+
{
|
|
1678
|
+
"insertAction": [
|
|
1679
|
+
{
|
|
1680
|
+
"position": 0,
|
|
1681
|
+
"type": "__snapshot_a94a8_test_43",
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
"position": 1,
|
|
1685
|
+
"type": "__snapshot_a94a8_test_43",
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
"position": 2,
|
|
1689
|
+
"type": "__snapshot_a94a8_test_43",
|
|
1690
|
+
},
|
|
1691
|
+
],
|
|
1692
|
+
"removeAction": [],
|
|
1693
|
+
"updateAction": [],
|
|
1694
|
+
},
|
|
1695
|
+
{
|
|
1696
|
+
"insertAction": [],
|
|
1697
|
+
"removeAction": [
|
|
1698
|
+
2,
|
|
1699
|
+
],
|
|
1700
|
+
"updateAction": [],
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
"insertAction": [
|
|
1704
|
+
{
|
|
1705
|
+
"position": 2,
|
|
1706
|
+
"type": "__snapshot_a94a8_test_43",
|
|
1707
|
+
},
|
|
1708
|
+
],
|
|
1709
|
+
"removeAction": [],
|
|
1710
|
+
"updateAction": [],
|
|
1711
|
+
},
|
|
1712
|
+
]
|
|
1713
|
+
}
|
|
1714
|
+
/>
|
|
1715
|
+
</wrapper>
|
|
1716
|
+
</view>
|
|
1717
|
+
`);
|
|
1718
|
+
});
|
|
1719
|
+
|
|
1720
|
+
it('list-item with same type - move', () => {
|
|
1721
|
+
const b = new SnapshotInstance(s1);
|
|
1722
|
+
b.ensureElements();
|
|
1723
|
+
const root = b.__element_root;
|
|
1724
|
+
|
|
1725
|
+
const b1 = new SnapshotInstance(s11);
|
|
1726
|
+
b1.__slotIndex = 0;
|
|
1727
|
+
b.insertBefore(b1);
|
|
1728
|
+
const listRef = b1.__elements[0];
|
|
1729
|
+
|
|
1730
|
+
const s3 = __SNAPSHOT__(
|
|
1731
|
+
<list-item item-key={HOLE}>
|
|
1732
|
+
<text>World</text>
|
|
1733
|
+
</list-item>,
|
|
1734
|
+
);
|
|
1735
|
+
|
|
1736
|
+
const s4 = __SNAPSHOT__(
|
|
1737
|
+
<list-item item-key={HOLE}>
|
|
1738
|
+
<text>Hello</text>
|
|
1739
|
+
</list-item>,
|
|
1740
|
+
);
|
|
1741
|
+
|
|
1742
|
+
const d1 = new SnapshotInstance(s3); // a
|
|
1743
|
+
d1.__slotIndex = 0;
|
|
1744
|
+
const d2 = new SnapshotInstance(s3); // b
|
|
1745
|
+
d2.__slotIndex = 0;
|
|
1746
|
+
const d3 = new SnapshotInstance(s4); // c
|
|
1747
|
+
d3.__slotIndex = 0;
|
|
1748
|
+
const d4 = new SnapshotInstance(s3); // d
|
|
1749
|
+
d4.__slotIndex = 0;
|
|
1750
|
+
|
|
1751
|
+
d1.setAttribute(0, { 'item-key': 'a' });
|
|
1752
|
+
d2.setAttribute(0, { 'item-key': 'b' });
|
|
1753
|
+
d3.setAttribute(0, { 'item-key': 'c' });
|
|
1754
|
+
d4.setAttribute(0, { 'item-key': 'd' });
|
|
1755
|
+
b1.insertBefore(d1);
|
|
1756
|
+
b1.insertBefore(d2);
|
|
1757
|
+
b1.insertBefore(d3);
|
|
1758
|
+
b1.insertBefore(d4);
|
|
1759
|
+
|
|
1760
|
+
__pendingListUpdates.flush();
|
|
1761
|
+
|
|
1762
|
+
const bb = new SnapshotInstance(s1);
|
|
1763
|
+
const bb1 = new SnapshotInstance(s11);
|
|
1764
|
+
bb1.__slotIndex = 0;
|
|
1765
|
+
bb.insertBefore(bb1);
|
|
1766
|
+
{
|
|
1767
|
+
const d1 = new SnapshotInstance(s3); // a
|
|
1768
|
+
d1.__slotIndex = 0;
|
|
1769
|
+
const d2 = new SnapshotInstance(s4); // c
|
|
1770
|
+
d2.__slotIndex = 0;
|
|
1771
|
+
const d3 = new SnapshotInstance(s3); // b
|
|
1772
|
+
d3.__slotIndex = 0;
|
|
1773
|
+
const d4 = new SnapshotInstance(s3); // d
|
|
1774
|
+
d4.__slotIndex = 0;
|
|
1775
|
+
d1.setAttribute(0, { 'item-key': 'a' });
|
|
1776
|
+
d2.setAttribute(0, { 'item-key': 'c' });
|
|
1777
|
+
d3.setAttribute(0, { 'item-key': 'b' });
|
|
1778
|
+
d4.setAttribute(0, { 'item-key': 'd' });
|
|
1779
|
+
bb1.insertBefore(d1);
|
|
1780
|
+
bb1.insertBefore(d2);
|
|
1781
|
+
bb1.insertBefore(d3);
|
|
1782
|
+
bb1.insertBefore(d4);
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
hydrate(b, bb);
|
|
1786
|
+
b.unRenderElements();
|
|
1787
|
+
|
|
1788
|
+
expect(root).toMatchInlineSnapshot(`
|
|
1789
|
+
<view>
|
|
1790
|
+
<text>
|
|
1791
|
+
<raw-text
|
|
1792
|
+
text="111"
|
|
1793
|
+
/>
|
|
1794
|
+
</text>
|
|
1795
|
+
<wrapper>
|
|
1796
|
+
<list
|
|
1797
|
+
id="list"
|
|
1798
|
+
update-list-info={
|
|
1799
|
+
[
|
|
1800
|
+
{
|
|
1801
|
+
"insertAction": [
|
|
1802
|
+
{
|
|
1803
|
+
"item-key": "a",
|
|
1804
|
+
"position": 0,
|
|
1805
|
+
"type": "__snapshot_a94a8_test_44",
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
"item-key": "b",
|
|
1809
|
+
"position": 1,
|
|
1810
|
+
"type": "__snapshot_a94a8_test_44",
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
"item-key": "c",
|
|
1814
|
+
"position": 2,
|
|
1815
|
+
"type": "__snapshot_a94a8_test_45",
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
"item-key": "d",
|
|
1819
|
+
"position": 3,
|
|
1820
|
+
"type": "__snapshot_a94a8_test_44",
|
|
1821
|
+
},
|
|
1822
|
+
],
|
|
1823
|
+
"removeAction": [],
|
|
1824
|
+
"updateAction": [],
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
"insertAction": [
|
|
1828
|
+
{
|
|
1829
|
+
"item-key": "b",
|
|
1830
|
+
"position": 2,
|
|
1831
|
+
"type": "__snapshot_a94a8_test_44",
|
|
1832
|
+
},
|
|
1833
|
+
],
|
|
1834
|
+
"removeAction": [
|
|
1835
|
+
1,
|
|
1836
|
+
],
|
|
1837
|
+
"updateAction": [],
|
|
1838
|
+
},
|
|
1839
|
+
]
|
|
1840
|
+
}
|
|
1841
|
+
/>
|
|
1842
|
+
</wrapper>
|
|
1843
|
+
</view>
|
|
1844
|
+
`);
|
|
1845
|
+
});
|
|
1846
|
+
|
|
1847
|
+
it('list-item with same type - with one list-item rendered', () => {
|
|
1848
|
+
const b = new SnapshotInstance(s1);
|
|
1849
|
+
b.ensureElements();
|
|
1850
|
+
const b1 = new SnapshotInstance(s11);
|
|
1851
|
+
b1.__slotIndex = 0;
|
|
1852
|
+
b.insertBefore(b1);
|
|
1853
|
+
const root = b.__elements[0];
|
|
1854
|
+
const listRef = b1.__elements[0];
|
|
1855
|
+
|
|
1856
|
+
const s3 = __SNAPSHOT__(
|
|
1857
|
+
<list-item item-key={HOLE}>
|
|
1858
|
+
<text>World</text>
|
|
1859
|
+
</list-item>,
|
|
1860
|
+
);
|
|
1861
|
+
|
|
1862
|
+
const d1 = new SnapshotInstance(s3);
|
|
1863
|
+
d1.__slotIndex = 0;
|
|
1864
|
+
const d2 = new SnapshotInstance(s3);
|
|
1865
|
+
d2.__slotIndex = 0;
|
|
1866
|
+
const d3 = new SnapshotInstance(s3);
|
|
1867
|
+
d3.__slotIndex = 0;
|
|
1868
|
+
b1.insertBefore(d1);
|
|
1869
|
+
b1.insertBefore(d2);
|
|
1870
|
+
b1.insertBefore(d3);
|
|
1871
|
+
|
|
1872
|
+
__pendingListUpdates.flush();
|
|
1873
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
1874
|
+
|
|
1875
|
+
const bb = new SnapshotInstance(s1);
|
|
1876
|
+
{
|
|
1877
|
+
const b1 = new SnapshotInstance(s11);
|
|
1878
|
+
b1.__slotIndex = 0;
|
|
1879
|
+
bb.insertBefore(b1);
|
|
1880
|
+
|
|
1881
|
+
const d1 = new SnapshotInstance(s3);
|
|
1882
|
+
d1.__slotIndex = 0;
|
|
1883
|
+
const d2 = new SnapshotInstance(s3);
|
|
1884
|
+
d2.__slotIndex = 0;
|
|
1885
|
+
const d3 = new SnapshotInstance(s3);
|
|
1886
|
+
d3.__slotIndex = 0;
|
|
1887
|
+
b1.insertBefore(d1);
|
|
1888
|
+
b1.insertBefore(d2);
|
|
1889
|
+
b1.insertBefore(d3);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
hydrate(b, bb);
|
|
1893
|
+
b.unRenderElements();
|
|
1894
|
+
|
|
1895
|
+
// The one rendered <list-item/> should be removed and reinserted
|
|
1896
|
+
expect(root).toMatchInlineSnapshot(`
|
|
1897
|
+
<view>
|
|
1898
|
+
<text>
|
|
1899
|
+
<raw-text
|
|
1900
|
+
text="111"
|
|
1901
|
+
/>
|
|
1902
|
+
</text>
|
|
1903
|
+
<wrapper>
|
|
1904
|
+
<list
|
|
1905
|
+
id="list"
|
|
1906
|
+
update-list-info={
|
|
1907
|
+
[
|
|
1908
|
+
{
|
|
1909
|
+
"insertAction": [
|
|
1910
|
+
{
|
|
1911
|
+
"position": 0,
|
|
1912
|
+
"type": "__snapshot_a94a8_test_46",
|
|
1913
|
+
},
|
|
1914
|
+
{
|
|
1915
|
+
"position": 1,
|
|
1916
|
+
"type": "__snapshot_a94a8_test_46",
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
"position": 2,
|
|
1920
|
+
"type": "__snapshot_a94a8_test_46",
|
|
1921
|
+
},
|
|
1922
|
+
],
|
|
1923
|
+
"removeAction": [],
|
|
1924
|
+
"updateAction": [],
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
"insertAction": [],
|
|
1928
|
+
"removeAction": [],
|
|
1929
|
+
"updateAction": [],
|
|
1930
|
+
},
|
|
1931
|
+
]
|
|
1932
|
+
}
|
|
1933
|
+
>
|
|
1934
|
+
<list-item>
|
|
1935
|
+
<text>
|
|
1936
|
+
<raw-text
|
|
1937
|
+
text="World"
|
|
1938
|
+
/>
|
|
1939
|
+
</text>
|
|
1940
|
+
</list-item>
|
|
1941
|
+
</list>
|
|
1942
|
+
</wrapper>
|
|
1943
|
+
</view>
|
|
1944
|
+
`);
|
|
1945
|
+
});
|
|
1946
|
+
|
|
1947
|
+
it('list-item with same type - platformInfo change', () => {
|
|
1948
|
+
const b = new SnapshotInstance(s1);
|
|
1949
|
+
b.ensureElements();
|
|
1950
|
+
|
|
1951
|
+
const b1 = new SnapshotInstance(s11);
|
|
1952
|
+
b1.__slotIndex = 0;
|
|
1953
|
+
b.insertBefore(b1);
|
|
1954
|
+
|
|
1955
|
+
const root = b.__elements[0];
|
|
1956
|
+
const listRef = b1.__elements[0];
|
|
1957
|
+
|
|
1958
|
+
const s3 = __SNAPSHOT__(
|
|
1959
|
+
<list-item item-key={HOLE}>
|
|
1960
|
+
<text>World</text>
|
|
1961
|
+
</list-item>,
|
|
1962
|
+
);
|
|
1963
|
+
|
|
1964
|
+
const d1 = new SnapshotInstance(s3);
|
|
1965
|
+
d1.__slotIndex = 0;
|
|
1966
|
+
const d2 = new SnapshotInstance(s3);
|
|
1967
|
+
d2.__slotIndex = 0;
|
|
1968
|
+
const d3 = new SnapshotInstance(s3);
|
|
1969
|
+
d3.__slotIndex = 0;
|
|
1970
|
+
d1.setAttribute(0, { 'item-key': '1', 'full-span': true });
|
|
1971
|
+
d2.setAttribute(0, { 'item-key': '2', 'full-span': true });
|
|
1972
|
+
d3.setAttribute(0, { 'item-key': '3', 'full-span': true });
|
|
1973
|
+
b1.insertBefore(d1);
|
|
1974
|
+
b1.insertBefore(d2);
|
|
1975
|
+
b1.insertBefore(d3);
|
|
1976
|
+
|
|
1977
|
+
__pendingListUpdates.flush();
|
|
1978
|
+
|
|
1979
|
+
const bb = new SnapshotInstance(s1);
|
|
1980
|
+
{
|
|
1981
|
+
const b1 = new SnapshotInstance(s11);
|
|
1982
|
+
b1.__slotIndex = 0;
|
|
1983
|
+
bb.insertBefore(b1);
|
|
1984
|
+
|
|
1985
|
+
const d1 = new SnapshotInstance(s3);
|
|
1986
|
+
d1.__slotIndex = 0;
|
|
1987
|
+
const d2 = new SnapshotInstance(s3);
|
|
1988
|
+
d2.__slotIndex = 0;
|
|
1989
|
+
const d3 = new SnapshotInstance(s3);
|
|
1990
|
+
d3.__slotIndex = 0;
|
|
1991
|
+
d1.setAttribute(0, { 'item-key': '1', 'full-span': true });
|
|
1992
|
+
d2.setAttribute(0, { 'item-key': '2', 'full-span': false });
|
|
1993
|
+
d3.setAttribute(0, { 'item-key': '3', 'full-span': true });
|
|
1994
|
+
b1.insertBefore(d1);
|
|
1995
|
+
b1.insertBefore(d2);
|
|
1996
|
+
b1.insertBefore(d3);
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
hydrate(b, bb);
|
|
2000
|
+
b.unRenderElements();
|
|
2001
|
+
|
|
2002
|
+
expect(root).toMatchInlineSnapshot(`
|
|
2003
|
+
<view>
|
|
2004
|
+
<text>
|
|
2005
|
+
<raw-text
|
|
2006
|
+
text="111"
|
|
2007
|
+
/>
|
|
2008
|
+
</text>
|
|
2009
|
+
<wrapper>
|
|
2010
|
+
<list
|
|
2011
|
+
id="list"
|
|
2012
|
+
update-list-info={
|
|
2013
|
+
[
|
|
2014
|
+
{
|
|
2015
|
+
"insertAction": [
|
|
2016
|
+
{
|
|
2017
|
+
"full-span": true,
|
|
2018
|
+
"item-key": "1",
|
|
2019
|
+
"position": 0,
|
|
2020
|
+
"type": "__snapshot_a94a8_test_47",
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
"full-span": true,
|
|
2024
|
+
"item-key": "2",
|
|
2025
|
+
"position": 1,
|
|
2026
|
+
"type": "__snapshot_a94a8_test_47",
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
"full-span": true,
|
|
2030
|
+
"item-key": "3",
|
|
2031
|
+
"position": 2,
|
|
2032
|
+
"type": "__snapshot_a94a8_test_47",
|
|
2033
|
+
},
|
|
2034
|
+
],
|
|
2035
|
+
"removeAction": [],
|
|
2036
|
+
"updateAction": [],
|
|
2037
|
+
},
|
|
2038
|
+
{
|
|
2039
|
+
"insertAction": [],
|
|
2040
|
+
"removeAction": [],
|
|
2041
|
+
"updateAction": [
|
|
2042
|
+
{
|
|
2043
|
+
"flush": false,
|
|
2044
|
+
"from": 1,
|
|
2045
|
+
"full-span": false,
|
|
2046
|
+
"item-key": "2",
|
|
2047
|
+
"to": 1,
|
|
2048
|
+
"type": "__snapshot_a94a8_test_47",
|
|
2049
|
+
},
|
|
2050
|
+
],
|
|
2051
|
+
},
|
|
2052
|
+
]
|
|
2053
|
+
}
|
|
2054
|
+
/>
|
|
2055
|
+
</wrapper>
|
|
2056
|
+
</view>
|
|
2057
|
+
`);
|
|
2058
|
+
});
|
|
2059
|
+
|
|
2060
|
+
it('list-item with different type', () => {
|
|
2061
|
+
const b = new SnapshotInstance(s1);
|
|
2062
|
+
b.ensureElements();
|
|
2063
|
+
const b1 = new SnapshotInstance(s11);
|
|
2064
|
+
b1.__slotIndex = 0;
|
|
2065
|
+
b.insertBefore(b1);
|
|
2066
|
+
const root = b.__elements[0];
|
|
2067
|
+
const listRef = b1.__elements[0];
|
|
2068
|
+
|
|
2069
|
+
const s3 = __SNAPSHOT__(
|
|
2070
|
+
<list-item item-key={HOLE}>
|
|
2071
|
+
<text>World</text>
|
|
2072
|
+
</list-item>,
|
|
2073
|
+
);
|
|
2074
|
+
|
|
2075
|
+
const s3_alt = __SNAPSHOT__(
|
|
2076
|
+
<list-item item-key={HOLE}>
|
|
2077
|
+
<text>W0r1d</text>
|
|
2078
|
+
</list-item>,
|
|
2079
|
+
);
|
|
2080
|
+
|
|
2081
|
+
const d1 = new SnapshotInstance(s3);
|
|
2082
|
+
d1.__slotIndex = 0;
|
|
2083
|
+
const d2 = new SnapshotInstance(s3);
|
|
2084
|
+
d2.__slotIndex = 0;
|
|
2085
|
+
const d3 = new SnapshotInstance(s3);
|
|
2086
|
+
d3.__slotIndex = 0;
|
|
2087
|
+
const d4 = new SnapshotInstance(s3);
|
|
2088
|
+
d4.__slotIndex = 0;
|
|
2089
|
+
b1.insertBefore(d1);
|
|
2090
|
+
b1.insertBefore(d2);
|
|
2091
|
+
b1.insertBefore(d3);
|
|
2092
|
+
b1.insertBefore(d4);
|
|
2093
|
+
|
|
2094
|
+
__pendingListUpdates.flush();
|
|
2095
|
+
const uiSign0 = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
2096
|
+
elementTree.triggerComponentAtIndex(listRef, 1); // make a rendered list-item
|
|
2097
|
+
const uiSign2 = elementTree.triggerComponentAtIndex(listRef, 2);
|
|
2098
|
+
elementTree.triggerEnqueueComponent(listRef, uiSign2); // make a rendered list-item which is enqueued
|
|
2099
|
+
|
|
2100
|
+
const listID = __GetElementUniqueID(listRef);
|
|
2101
|
+
const signMap = gSignMap[listID];
|
|
2102
|
+
const recycleMap = gRecycleMap[listID];
|
|
2103
|
+
const recycleSignMap = recycleMap.get(s3);
|
|
2104
|
+
|
|
2105
|
+
expect(signMap.get(__GetElementUniqueID(d1.__element_root))).toBe(d1);
|
|
2106
|
+
expect(signMap.get(__GetElementUniqueID(d2.__element_root))).toBe(d2);
|
|
2107
|
+
expect(signMap.get(__GetElementUniqueID(d3.__element_root))).toBe(d3);
|
|
2108
|
+
expect(recycleSignMap.get(__GetElementUniqueID(d3.__element_root))).toBe(d3);
|
|
2109
|
+
|
|
2110
|
+
const bb = new SnapshotInstance(s1);
|
|
2111
|
+
const bb1 = new SnapshotInstance(s11);
|
|
2112
|
+
bb1.__slotIndex = 0;
|
|
2113
|
+
bb.insertBefore(bb1);
|
|
2114
|
+
const d1_ = new SnapshotInstance(s3_alt);
|
|
2115
|
+
d1_.__slotIndex = 0;
|
|
2116
|
+
const d2_ = new SnapshotInstance(s3);
|
|
2117
|
+
d2_.__slotIndex = 0;
|
|
2118
|
+
const d3_ = new SnapshotInstance(s3);
|
|
2119
|
+
d3_.__slotIndex = 0;
|
|
2120
|
+
const d4_ = new SnapshotInstance(s3);
|
|
2121
|
+
d4_.__slotIndex = 0;
|
|
2122
|
+
bb1.insertBefore(d1_);
|
|
2123
|
+
bb1.insertBefore(d2_);
|
|
2124
|
+
bb1.insertBefore(d3_);
|
|
2125
|
+
bb1.insertBefore(d4_);
|
|
2126
|
+
|
|
2127
|
+
hydrate(b, bb);
|
|
2128
|
+
b.unRenderElements();
|
|
2129
|
+
|
|
2130
|
+
// Should only update `list-item` in the recycling pool
|
|
2131
|
+
// Should not add the on-screen `list-item` to the recycling pool,
|
|
2132
|
+
expect([...recycleSignMap.keys()]).toStrictEqual([__GetElementUniqueID(d3.__element_root)]);
|
|
2133
|
+
expect(recycleSignMap.get(__GetElementUniqueID(d3.__element_root))).not.toBe(d3);
|
|
2134
|
+
|
|
2135
|
+
// The one rendered <list-item/> should be removed
|
|
2136
|
+
expect(root).toMatchInlineSnapshot(`
|
|
2137
|
+
<view>
|
|
2138
|
+
<text>
|
|
2139
|
+
<raw-text
|
|
2140
|
+
text="111"
|
|
2141
|
+
/>
|
|
2142
|
+
</text>
|
|
2143
|
+
<wrapper>
|
|
2144
|
+
<list
|
|
2145
|
+
id="list"
|
|
2146
|
+
update-list-info={
|
|
2147
|
+
[
|
|
2148
|
+
{
|
|
2149
|
+
"insertAction": [
|
|
2150
|
+
{
|
|
2151
|
+
"position": 0,
|
|
2152
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2153
|
+
},
|
|
2154
|
+
{
|
|
2155
|
+
"position": 1,
|
|
2156
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2157
|
+
},
|
|
2158
|
+
{
|
|
2159
|
+
"position": 2,
|
|
2160
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2161
|
+
},
|
|
2162
|
+
{
|
|
2163
|
+
"position": 3,
|
|
2164
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2165
|
+
},
|
|
2166
|
+
],
|
|
2167
|
+
"removeAction": [],
|
|
2168
|
+
"updateAction": [],
|
|
2169
|
+
},
|
|
2170
|
+
{
|
|
2171
|
+
"insertAction": [
|
|
2172
|
+
{
|
|
2173
|
+
"position": 0,
|
|
2174
|
+
"type": "__snapshot_a94a8_test_49",
|
|
2175
|
+
},
|
|
2176
|
+
],
|
|
2177
|
+
"removeAction": [
|
|
2178
|
+
3,
|
|
2179
|
+
],
|
|
2180
|
+
"updateAction": [],
|
|
2181
|
+
},
|
|
2182
|
+
]
|
|
2183
|
+
}
|
|
2184
|
+
>
|
|
2185
|
+
<list-item>
|
|
2186
|
+
<text>
|
|
2187
|
+
<raw-text
|
|
2188
|
+
text="World"
|
|
2189
|
+
/>
|
|
2190
|
+
</text>
|
|
2191
|
+
</list-item>
|
|
2192
|
+
<list-item>
|
|
2193
|
+
<text>
|
|
2194
|
+
<raw-text
|
|
2195
|
+
text="World"
|
|
2196
|
+
/>
|
|
2197
|
+
</text>
|
|
2198
|
+
</list-item>
|
|
2199
|
+
<list-item>
|
|
2200
|
+
<text>
|
|
2201
|
+
<raw-text
|
|
2202
|
+
text="World"
|
|
2203
|
+
/>
|
|
2204
|
+
</text>
|
|
2205
|
+
</list-item>
|
|
2206
|
+
</list>
|
|
2207
|
+
</wrapper>
|
|
2208
|
+
</view>
|
|
2209
|
+
`);
|
|
2210
|
+
|
|
2211
|
+
// simulate behaviors of Lynx Engine
|
|
2212
|
+
{
|
|
2213
|
+
// a enqueueComponent should be triggered because the removeAction above
|
|
2214
|
+
elementTree.triggerEnqueueComponent(listRef, uiSign0);
|
|
2215
|
+
// and a componentAtIndex should be triggered because of the insertAction above
|
|
2216
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
2217
|
+
}
|
|
2218
|
+
// the pool should have two items now
|
|
2219
|
+
expect(root).toMatchInlineSnapshot(`
|
|
2220
|
+
<view>
|
|
2221
|
+
<text>
|
|
2222
|
+
<raw-text
|
|
2223
|
+
text="111"
|
|
2224
|
+
/>
|
|
2225
|
+
</text>
|
|
2226
|
+
<wrapper>
|
|
2227
|
+
<list
|
|
2228
|
+
id="list"
|
|
2229
|
+
update-list-info={
|
|
2230
|
+
[
|
|
2231
|
+
{
|
|
2232
|
+
"insertAction": [
|
|
2233
|
+
{
|
|
2234
|
+
"position": 0,
|
|
2235
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
"position": 1,
|
|
2239
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
"position": 2,
|
|
2243
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2244
|
+
},
|
|
2245
|
+
{
|
|
2246
|
+
"position": 3,
|
|
2247
|
+
"type": "__snapshot_a94a8_test_48",
|
|
2248
|
+
},
|
|
2249
|
+
],
|
|
2250
|
+
"removeAction": [],
|
|
2251
|
+
"updateAction": [],
|
|
2252
|
+
},
|
|
2253
|
+
{
|
|
2254
|
+
"insertAction": [
|
|
2255
|
+
{
|
|
2256
|
+
"position": 0,
|
|
2257
|
+
"type": "__snapshot_a94a8_test_49",
|
|
2258
|
+
},
|
|
2259
|
+
],
|
|
2260
|
+
"removeAction": [
|
|
2261
|
+
3,
|
|
2262
|
+
],
|
|
2263
|
+
"updateAction": [],
|
|
2264
|
+
},
|
|
2265
|
+
]
|
|
2266
|
+
}
|
|
2267
|
+
>
|
|
2268
|
+
<list-item>
|
|
2269
|
+
<text>
|
|
2270
|
+
<raw-text
|
|
2271
|
+
text="World"
|
|
2272
|
+
/>
|
|
2273
|
+
</text>
|
|
2274
|
+
</list-item>
|
|
2275
|
+
<list-item>
|
|
2276
|
+
<text>
|
|
2277
|
+
<raw-text
|
|
2278
|
+
text="World"
|
|
2279
|
+
/>
|
|
2280
|
+
</text>
|
|
2281
|
+
</list-item>
|
|
2282
|
+
<list-item>
|
|
2283
|
+
<text>
|
|
2284
|
+
<raw-text
|
|
2285
|
+
text="World"
|
|
2286
|
+
/>
|
|
2287
|
+
</text>
|
|
2288
|
+
</list-item>
|
|
2289
|
+
<list-item>
|
|
2290
|
+
<text>
|
|
2291
|
+
<raw-text
|
|
2292
|
+
text="W0r1d"
|
|
2293
|
+
/>
|
|
2294
|
+
</text>
|
|
2295
|
+
</list-item>
|
|
2296
|
+
</list>
|
|
2297
|
+
</wrapper>
|
|
2298
|
+
</view>
|
|
2299
|
+
`);
|
|
2300
|
+
|
|
2301
|
+
expect(signMap.get(__GetElementUniqueID(d1_.__element_root))).toBe(d1_);
|
|
2302
|
+
expect(signMap.get(__GetElementUniqueID(d1.__element_root))).toBe(d2_); // note: d1 is reused by d2_
|
|
2303
|
+
expect(signMap.get(__GetElementUniqueID(d2_.__element_root))).toBe(d2_);
|
|
2304
|
+
expect(signMap.get(__GetElementUniqueID(d3_.__element_root))).toBe(d3_);
|
|
2305
|
+
// d1 was enqueued as well, so it should be in the recycling pool
|
|
2306
|
+
expect([...recycleSignMap.keys()]).toStrictEqual([
|
|
2307
|
+
__GetElementUniqueID(d3.__element_root),
|
|
2308
|
+
__GetElementUniqueID(d1.__element_root),
|
|
2309
|
+
]);
|
|
2310
|
+
});
|
|
2311
|
+
});
|
|
2312
|
+
|
|
2313
|
+
describe('list hydrate', () => {
|
|
2314
|
+
it('should not modify values of old ctx', () => {
|
|
2315
|
+
const s1 = __SNAPSHOT__(<view attr={HOLE} />);
|
|
2316
|
+
|
|
2317
|
+
const b = new SnapshotInstance(s1);
|
|
2318
|
+
b.ensureElements();
|
|
2319
|
+
b.setAttribute(0, '111');
|
|
2320
|
+
expect(b.__element_root).toMatchInlineSnapshot(`
|
|
2321
|
+
<view
|
|
2322
|
+
attr="111"
|
|
2323
|
+
/>
|
|
2324
|
+
`);
|
|
2325
|
+
|
|
2326
|
+
const bb = new SnapshotInstance(s1);
|
|
2327
|
+
bb.ensureElements();
|
|
2328
|
+
bb.setAttribute(0, '222');
|
|
2329
|
+
expect(bb.__element_root).toMatchInlineSnapshot(`
|
|
2330
|
+
<view
|
|
2331
|
+
attr="222"
|
|
2332
|
+
/>
|
|
2333
|
+
`);
|
|
2334
|
+
|
|
2335
|
+
hydrate(b, bb);
|
|
2336
|
+
expect(b.__values).toMatchInlineSnapshot(`
|
|
2337
|
+
[
|
|
2338
|
+
"111",
|
|
2339
|
+
]
|
|
2340
|
+
`);
|
|
2341
|
+
expect(b.__element_root).toMatchInlineSnapshot(`
|
|
2342
|
+
<view
|
|
2343
|
+
attr="222"
|
|
2344
|
+
/>
|
|
2345
|
+
`);
|
|
2346
|
+
});
|
|
2347
|
+
});
|
|
2348
|
+
|
|
2349
|
+
describe('list bug', () => {
|
|
2350
|
+
const s = __SNAPSHOT__(
|
|
2351
|
+
<view>
|
|
2352
|
+
<text>Hello</text>
|
|
2353
|
+
{HOLE}
|
|
2354
|
+
</view>,
|
|
2355
|
+
);
|
|
2356
|
+
|
|
2357
|
+
it(`"update-list-info" should have full "updateAction" under some condition`, async function() {
|
|
2358
|
+
SystemInfo.lynxSdkVersion = '2.16';
|
|
2359
|
+
|
|
2360
|
+
const s1 = __SNAPSHOT__(
|
|
2361
|
+
<view>
|
|
2362
|
+
<text>111</text>
|
|
2363
|
+
{HOLE}
|
|
2364
|
+
</view>,
|
|
2365
|
+
);
|
|
2366
|
+
const s11 = __SNAPSHOT__(
|
|
2367
|
+
<list custom-list-name='list-container'>{HOLE}</list>,
|
|
2368
|
+
);
|
|
2369
|
+
const s2 = __SNAPSHOT__(<text>World</text>);
|
|
2370
|
+
const s3 = __SNAPSHOT__(
|
|
2371
|
+
<list-item item-key={1}>
|
|
2372
|
+
<text>World</text>
|
|
2373
|
+
</list-item>,
|
|
2374
|
+
);
|
|
2375
|
+
|
|
2376
|
+
const a = new SnapshotInstance(s);
|
|
2377
|
+
a.ensureElements();
|
|
2378
|
+
|
|
2379
|
+
const b = new SnapshotInstance(s1);
|
|
2380
|
+
const b1 = new SnapshotInstance(s11);
|
|
2381
|
+
|
|
2382
|
+
b.insertBefore(b1);
|
|
2383
|
+
|
|
2384
|
+
const c = new SnapshotInstance(s2);
|
|
2385
|
+
|
|
2386
|
+
a.insertBefore(b);
|
|
2387
|
+
a.insertBefore(c);
|
|
2388
|
+
|
|
2389
|
+
const d1 = new SnapshotInstance(s3);
|
|
2390
|
+
const d2 = new SnapshotInstance(s3);
|
|
2391
|
+
const d3 = new SnapshotInstance(s3);
|
|
2392
|
+
b1.insertBefore(d1);
|
|
2393
|
+
b1.insertBefore(d2);
|
|
2394
|
+
b1.insertBefore(d3);
|
|
2395
|
+
|
|
2396
|
+
expect(b1.childNodes.length).toMatchInlineSnapshot(`3`);
|
|
2397
|
+
|
|
2398
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
2399
|
+
{
|
|
2400
|
+
"-7": [
|
|
2401
|
+
{
|
|
2402
|
+
"insertAction": [
|
|
2403
|
+
{
|
|
2404
|
+
"position": 0,
|
|
2405
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2406
|
+
},
|
|
2407
|
+
{
|
|
2408
|
+
"position": 1,
|
|
2409
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2410
|
+
},
|
|
2411
|
+
{
|
|
2412
|
+
"position": 2,
|
|
2413
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2414
|
+
},
|
|
2415
|
+
],
|
|
2416
|
+
"removeAction": [],
|
|
2417
|
+
"updateAction": [
|
|
2418
|
+
{
|
|
2419
|
+
"flush": false,
|
|
2420
|
+
"from": 0,
|
|
2421
|
+
"to": 0,
|
|
2422
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2423
|
+
},
|
|
2424
|
+
{
|
|
2425
|
+
"flush": false,
|
|
2426
|
+
"from": 1,
|
|
2427
|
+
"to": 1,
|
|
2428
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2429
|
+
},
|
|
2430
|
+
{
|
|
2431
|
+
"flush": false,
|
|
2432
|
+
"from": 2,
|
|
2433
|
+
"to": 2,
|
|
2434
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2435
|
+
},
|
|
2436
|
+
],
|
|
2437
|
+
},
|
|
2438
|
+
],
|
|
2439
|
+
}
|
|
2440
|
+
`);
|
|
2441
|
+
|
|
2442
|
+
{
|
|
2443
|
+
__pendingListUpdates.clearAttachedLists();
|
|
2444
|
+
b1.insertBefore(d3); // move
|
|
2445
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
2446
|
+
{
|
|
2447
|
+
"-7": [
|
|
2448
|
+
{
|
|
2449
|
+
"insertAction": [
|
|
2450
|
+
{
|
|
2451
|
+
"position": 2,
|
|
2452
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2453
|
+
},
|
|
2454
|
+
],
|
|
2455
|
+
"removeAction": [
|
|
2456
|
+
2,
|
|
2457
|
+
],
|
|
2458
|
+
"updateAction": [
|
|
2459
|
+
{
|
|
2460
|
+
"flush": false,
|
|
2461
|
+
"from": 0,
|
|
2462
|
+
"to": 0,
|
|
2463
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2464
|
+
},
|
|
2465
|
+
{
|
|
2466
|
+
"flush": false,
|
|
2467
|
+
"from": 1,
|
|
2468
|
+
"to": 1,
|
|
2469
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2470
|
+
},
|
|
2471
|
+
{
|
|
2472
|
+
"flush": false,
|
|
2473
|
+
"from": 2,
|
|
2474
|
+
"to": 2,
|
|
2475
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2476
|
+
},
|
|
2477
|
+
],
|
|
2478
|
+
},
|
|
2479
|
+
],
|
|
2480
|
+
}
|
|
2481
|
+
`);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
{
|
|
2485
|
+
__pendingListUpdates.clearAttachedLists();
|
|
2486
|
+
b1.removeChild(d3); // move
|
|
2487
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
2488
|
+
{
|
|
2489
|
+
"-7": [
|
|
2490
|
+
{
|
|
2491
|
+
"insertAction": [],
|
|
2492
|
+
"removeAction": [
|
|
2493
|
+
2,
|
|
2494
|
+
],
|
|
2495
|
+
"updateAction": [
|
|
2496
|
+
{
|
|
2497
|
+
"flush": false,
|
|
2498
|
+
"from": 0,
|
|
2499
|
+
"to": 0,
|
|
2500
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2501
|
+
},
|
|
2502
|
+
{
|
|
2503
|
+
"flush": false,
|
|
2504
|
+
"from": 1,
|
|
2505
|
+
"to": 1,
|
|
2506
|
+
"type": "__snapshot_a94a8_test_55",
|
|
2507
|
+
},
|
|
2508
|
+
],
|
|
2509
|
+
},
|
|
2510
|
+
],
|
|
2511
|
+
}
|
|
2512
|
+
`);
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
SystemInfo.lynxSdkVersion = undefined;
|
|
2516
|
+
});
|
|
2517
|
+
});
|
|
2518
|
+
|
|
2519
|
+
describe('list-item JSXSpread', () => {
|
|
2520
|
+
const s1 = __SNAPSHOT__(
|
|
2521
|
+
<view>
|
|
2522
|
+
<text>111</text>
|
|
2523
|
+
{HOLE}
|
|
2524
|
+
</view>,
|
|
2525
|
+
);
|
|
2526
|
+
const s11 = __SNAPSHOT__(
|
|
2527
|
+
<list id='list'>{HOLE}</list>,
|
|
2528
|
+
);
|
|
2529
|
+
|
|
2530
|
+
it('list-item with same type - platformInfo change', () => {
|
|
2531
|
+
const b = new SnapshotInstance(s1);
|
|
2532
|
+
b.ensureElements();
|
|
2533
|
+
|
|
2534
|
+
const b1 = new SnapshotInstance(s11);
|
|
2535
|
+
b1.__slotIndex = 0;
|
|
2536
|
+
b.insertBefore(b1);
|
|
2537
|
+
|
|
2538
|
+
const root = b.__elements[0];
|
|
2539
|
+
const listRef = b1.__elements[0];
|
|
2540
|
+
|
|
2541
|
+
const s3 = __SNAPSHOT__(
|
|
2542
|
+
<list-item {...HOLE}>
|
|
2543
|
+
<text>World</text>
|
|
2544
|
+
</list-item>,
|
|
2545
|
+
);
|
|
2546
|
+
|
|
2547
|
+
{
|
|
2548
|
+
const d1 = new SnapshotInstance(s3);
|
|
2549
|
+
d1.__slotIndex = 0;
|
|
2550
|
+
const d2 = new SnapshotInstance(s3);
|
|
2551
|
+
d2.__slotIndex = 0;
|
|
2552
|
+
const d3 = new SnapshotInstance(s3);
|
|
2553
|
+
d3.__slotIndex = 0;
|
|
2554
|
+
b1.insertBefore(d1);
|
|
2555
|
+
b1.insertBefore(d2);
|
|
2556
|
+
b1.insertBefore(d3);
|
|
2557
|
+
|
|
2558
|
+
d1.setAttribute(0, { 'item-key': '1', 'full-span': true, 'recyclable': true });
|
|
2559
|
+
d2.setAttribute(0, { 'item-key': '2', 'full-span': true, 'recyclable': true });
|
|
2560
|
+
d3.setAttribute(0, { 'item-key': '3', 'full-span': true, 'recyclable': true });
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
__pendingListUpdates.flush();
|
|
2564
|
+
|
|
2565
|
+
const bb = new SnapshotInstance(s1);
|
|
2566
|
+
|
|
2567
|
+
const bb1 = new SnapshotInstance(s11);
|
|
2568
|
+
bb1.__slotIndex = 0;
|
|
2569
|
+
bb.insertBefore(bb1);
|
|
2570
|
+
|
|
2571
|
+
const d1 = new SnapshotInstance(s3);
|
|
2572
|
+
d1.__slotIndex = 0;
|
|
2573
|
+
const d2 = new SnapshotInstance(s3);
|
|
2574
|
+
d2.__slotIndex = 0;
|
|
2575
|
+
const d3 = new SnapshotInstance(s3);
|
|
2576
|
+
d3.__slotIndex = 0;
|
|
2577
|
+
bb1.insertBefore(d1);
|
|
2578
|
+
bb1.insertBefore(d2);
|
|
2579
|
+
bb1.insertBefore(d3);
|
|
2580
|
+
|
|
2581
|
+
d1.setAttribute(0, { 'item-key': '1', 'full-span': true, 'recyclable': false });
|
|
2582
|
+
d2.setAttribute(0, { 'item-key': '2', 'full-span': false, 'recyclable': false });
|
|
2583
|
+
d3.setAttribute(0, { 'item-key': '3', 'full-span': true, 'recyclable': false });
|
|
2584
|
+
|
|
2585
|
+
hydrate(b, bb);
|
|
2586
|
+
b.unRenderElements();
|
|
2587
|
+
|
|
2588
|
+
expect(root).toMatchInlineSnapshot(`
|
|
2589
|
+
<view>
|
|
2590
|
+
<text>
|
|
2591
|
+
<raw-text
|
|
2592
|
+
text="111"
|
|
2593
|
+
/>
|
|
2594
|
+
</text>
|
|
2595
|
+
<wrapper>
|
|
2596
|
+
<list
|
|
2597
|
+
id="list"
|
|
2598
|
+
update-list-info={
|
|
2599
|
+
[
|
|
2600
|
+
{
|
|
2601
|
+
"insertAction": [
|
|
2602
|
+
{
|
|
2603
|
+
"full-span": true,
|
|
2604
|
+
"item-key": "1",
|
|
2605
|
+
"position": 0,
|
|
2606
|
+
"recyclable": true,
|
|
2607
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2608
|
+
},
|
|
2609
|
+
{
|
|
2610
|
+
"full-span": true,
|
|
2611
|
+
"item-key": "2",
|
|
2612
|
+
"position": 1,
|
|
2613
|
+
"recyclable": true,
|
|
2614
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2615
|
+
},
|
|
2616
|
+
{
|
|
2617
|
+
"full-span": true,
|
|
2618
|
+
"item-key": "3",
|
|
2619
|
+
"position": 2,
|
|
2620
|
+
"recyclable": true,
|
|
2621
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2622
|
+
},
|
|
2623
|
+
],
|
|
2624
|
+
"removeAction": [],
|
|
2625
|
+
"updateAction": [],
|
|
2626
|
+
},
|
|
2627
|
+
{
|
|
2628
|
+
"insertAction": [],
|
|
2629
|
+
"removeAction": [],
|
|
2630
|
+
"updateAction": [
|
|
2631
|
+
{
|
|
2632
|
+
"flush": false,
|
|
2633
|
+
"from": 0,
|
|
2634
|
+
"full-span": true,
|
|
2635
|
+
"item-key": "1",
|
|
2636
|
+
"recyclable": false,
|
|
2637
|
+
"to": 0,
|
|
2638
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2639
|
+
},
|
|
2640
|
+
{
|
|
2641
|
+
"flush": false,
|
|
2642
|
+
"from": 1,
|
|
2643
|
+
"full-span": false,
|
|
2644
|
+
"item-key": "2",
|
|
2645
|
+
"recyclable": false,
|
|
2646
|
+
"to": 1,
|
|
2647
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2648
|
+
},
|
|
2649
|
+
{
|
|
2650
|
+
"flush": false,
|
|
2651
|
+
"from": 2,
|
|
2652
|
+
"full-span": true,
|
|
2653
|
+
"item-key": "3",
|
|
2654
|
+
"recyclable": false,
|
|
2655
|
+
"to": 2,
|
|
2656
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2657
|
+
},
|
|
2658
|
+
],
|
|
2659
|
+
},
|
|
2660
|
+
]
|
|
2661
|
+
}
|
|
2662
|
+
/>
|
|
2663
|
+
</wrapper>
|
|
2664
|
+
</view>
|
|
2665
|
+
`);
|
|
2666
|
+
|
|
2667
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
2668
|
+
d1.setAttribute(0, { 'item-key': '1', 'full-span': true, 'sticky-top': 100 });
|
|
2669
|
+
expect(root).toMatchInlineSnapshot(`
|
|
2670
|
+
<view>
|
|
2671
|
+
<text>
|
|
2672
|
+
<raw-text
|
|
2673
|
+
text="111"
|
|
2674
|
+
/>
|
|
2675
|
+
</text>
|
|
2676
|
+
<wrapper>
|
|
2677
|
+
<list
|
|
2678
|
+
id="list"
|
|
2679
|
+
update-list-info={
|
|
2680
|
+
[
|
|
2681
|
+
{
|
|
2682
|
+
"insertAction": [
|
|
2683
|
+
{
|
|
2684
|
+
"full-span": true,
|
|
2685
|
+
"item-key": "1",
|
|
2686
|
+
"position": 0,
|
|
2687
|
+
"recyclable": true,
|
|
2688
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
"full-span": true,
|
|
2692
|
+
"item-key": "2",
|
|
2693
|
+
"position": 1,
|
|
2694
|
+
"recyclable": true,
|
|
2695
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2696
|
+
},
|
|
2697
|
+
{
|
|
2698
|
+
"full-span": true,
|
|
2699
|
+
"item-key": "3",
|
|
2700
|
+
"position": 2,
|
|
2701
|
+
"recyclable": true,
|
|
2702
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2703
|
+
},
|
|
2704
|
+
],
|
|
2705
|
+
"removeAction": [],
|
|
2706
|
+
"updateAction": [],
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
"insertAction": [],
|
|
2710
|
+
"removeAction": [],
|
|
2711
|
+
"updateAction": [
|
|
2712
|
+
{
|
|
2713
|
+
"flush": false,
|
|
2714
|
+
"from": 0,
|
|
2715
|
+
"full-span": true,
|
|
2716
|
+
"item-key": "1",
|
|
2717
|
+
"recyclable": false,
|
|
2718
|
+
"to": 0,
|
|
2719
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2720
|
+
},
|
|
2721
|
+
{
|
|
2722
|
+
"flush": false,
|
|
2723
|
+
"from": 1,
|
|
2724
|
+
"full-span": false,
|
|
2725
|
+
"item-key": "2",
|
|
2726
|
+
"recyclable": false,
|
|
2727
|
+
"to": 1,
|
|
2728
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2729
|
+
},
|
|
2730
|
+
{
|
|
2731
|
+
"flush": false,
|
|
2732
|
+
"from": 2,
|
|
2733
|
+
"full-span": true,
|
|
2734
|
+
"item-key": "3",
|
|
2735
|
+
"recyclable": false,
|
|
2736
|
+
"to": 2,
|
|
2737
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2738
|
+
},
|
|
2739
|
+
],
|
|
2740
|
+
},
|
|
2741
|
+
]
|
|
2742
|
+
}
|
|
2743
|
+
>
|
|
2744
|
+
<list-item
|
|
2745
|
+
full-span={true}
|
|
2746
|
+
item-key="1"
|
|
2747
|
+
sticky-top={100}
|
|
2748
|
+
>
|
|
2749
|
+
<text>
|
|
2750
|
+
<raw-text
|
|
2751
|
+
text="World"
|
|
2752
|
+
/>
|
|
2753
|
+
</text>
|
|
2754
|
+
</list-item>
|
|
2755
|
+
</list>
|
|
2756
|
+
</wrapper>
|
|
2757
|
+
</view>
|
|
2758
|
+
`);
|
|
2759
|
+
|
|
2760
|
+
d1.setAttribute(0, { 'item-key': '1', 'full-span': true });
|
|
2761
|
+
expect(root).toMatchInlineSnapshot(`
|
|
2762
|
+
<view>
|
|
2763
|
+
<text>
|
|
2764
|
+
<raw-text
|
|
2765
|
+
text="111"
|
|
2766
|
+
/>
|
|
2767
|
+
</text>
|
|
2768
|
+
<wrapper>
|
|
2769
|
+
<list
|
|
2770
|
+
id="list"
|
|
2771
|
+
update-list-info={
|
|
2772
|
+
[
|
|
2773
|
+
{
|
|
2774
|
+
"insertAction": [
|
|
2775
|
+
{
|
|
2776
|
+
"full-span": true,
|
|
2777
|
+
"item-key": "1",
|
|
2778
|
+
"position": 0,
|
|
2779
|
+
"recyclable": true,
|
|
2780
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2781
|
+
},
|
|
2782
|
+
{
|
|
2783
|
+
"full-span": true,
|
|
2784
|
+
"item-key": "2",
|
|
2785
|
+
"position": 1,
|
|
2786
|
+
"recyclable": true,
|
|
2787
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2788
|
+
},
|
|
2789
|
+
{
|
|
2790
|
+
"full-span": true,
|
|
2791
|
+
"item-key": "3",
|
|
2792
|
+
"position": 2,
|
|
2793
|
+
"recyclable": true,
|
|
2794
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2795
|
+
},
|
|
2796
|
+
],
|
|
2797
|
+
"removeAction": [],
|
|
2798
|
+
"updateAction": [],
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
"insertAction": [],
|
|
2802
|
+
"removeAction": [],
|
|
2803
|
+
"updateAction": [
|
|
2804
|
+
{
|
|
2805
|
+
"flush": false,
|
|
2806
|
+
"from": 0,
|
|
2807
|
+
"full-span": true,
|
|
2808
|
+
"item-key": "1",
|
|
2809
|
+
"recyclable": false,
|
|
2810
|
+
"to": 0,
|
|
2811
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2812
|
+
},
|
|
2813
|
+
{
|
|
2814
|
+
"flush": false,
|
|
2815
|
+
"from": 1,
|
|
2816
|
+
"full-span": false,
|
|
2817
|
+
"item-key": "2",
|
|
2818
|
+
"recyclable": false,
|
|
2819
|
+
"to": 1,
|
|
2820
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2821
|
+
},
|
|
2822
|
+
{
|
|
2823
|
+
"flush": false,
|
|
2824
|
+
"from": 2,
|
|
2825
|
+
"full-span": true,
|
|
2826
|
+
"item-key": "3",
|
|
2827
|
+
"recyclable": false,
|
|
2828
|
+
"to": 2,
|
|
2829
|
+
"type": "__snapshot_a94a8_test_58",
|
|
2830
|
+
},
|
|
2831
|
+
],
|
|
2832
|
+
},
|
|
2833
|
+
]
|
|
2834
|
+
}
|
|
2835
|
+
>
|
|
2836
|
+
<list-item
|
|
2837
|
+
full-span={true}
|
|
2838
|
+
item-key="1"
|
|
2839
|
+
sticky-top={100}
|
|
2840
|
+
>
|
|
2841
|
+
<text>
|
|
2842
|
+
<raw-text
|
|
2843
|
+
text="World"
|
|
2844
|
+
/>
|
|
2845
|
+
</text>
|
|
2846
|
+
</list-item>
|
|
2847
|
+
</list>
|
|
2848
|
+
</wrapper>
|
|
2849
|
+
</view>
|
|
2850
|
+
`);
|
|
2851
|
+
});
|
|
2852
|
+
});
|
|
2853
|
+
|
|
2854
|
+
describe('list-item with platform info attributes', () => {
|
|
2855
|
+
const s1 = __SNAPSHOT__(
|
|
2856
|
+
<view>
|
|
2857
|
+
<text>111</text>
|
|
2858
|
+
{HOLE}
|
|
2859
|
+
</view>,
|
|
2860
|
+
);
|
|
2861
|
+
const s11 = __SNAPSHOT__(
|
|
2862
|
+
<list id='list'>{HOLE}</list>,
|
|
2863
|
+
);
|
|
2864
|
+
|
|
2865
|
+
const s3 = __SNAPSHOT__(
|
|
2866
|
+
<list-item
|
|
2867
|
+
item-key={HOLE}
|
|
2868
|
+
reuse-identifier={HOLE}
|
|
2869
|
+
full-span={HOLE}
|
|
2870
|
+
sticky-top={HOLE}
|
|
2871
|
+
sticky-bottom={HOLE}
|
|
2872
|
+
estimated-height={HOLE}
|
|
2873
|
+
estimated-height-px={HOLE}
|
|
2874
|
+
estimated-main-axis-size-px={HOLE}
|
|
2875
|
+
recyclable={HOLE}
|
|
2876
|
+
>
|
|
2877
|
+
<text>World</text>
|
|
2878
|
+
</list-item>,
|
|
2879
|
+
);
|
|
2880
|
+
|
|
2881
|
+
it('basic list-item with platform info attributes', () => {
|
|
2882
|
+
const b = new SnapshotInstance(s1);
|
|
2883
|
+
b.ensureElements();
|
|
2884
|
+
|
|
2885
|
+
const b1 = new SnapshotInstance(s11);
|
|
2886
|
+
b.insertBefore(b1);
|
|
2887
|
+
|
|
2888
|
+
const root = b.__elements[0];
|
|
2889
|
+
const listRef = b1.__elements[0];
|
|
2890
|
+
|
|
2891
|
+
{
|
|
2892
|
+
const d0 = new SnapshotInstance(s3);
|
|
2893
|
+
const d1 = new SnapshotInstance(s3);
|
|
2894
|
+
const d2 = new SnapshotInstance(s3);
|
|
2895
|
+
b1.insertBefore(d0);
|
|
2896
|
+
b1.insertBefore(d1);
|
|
2897
|
+
b1.insertBefore(d2);
|
|
2898
|
+
|
|
2899
|
+
d0.setAttribute(0, {
|
|
2900
|
+
'item-key': 'list-item-0',
|
|
2901
|
+
'reuse-identifier': 'A',
|
|
2902
|
+
'full-span': true,
|
|
2903
|
+
'sticky-top': true,
|
|
2904
|
+
'sticky-bottom': false,
|
|
2905
|
+
'estimated-height': 100,
|
|
2906
|
+
'estimated-height-px': 100,
|
|
2907
|
+
'estimated-main-axis-size-px': 100,
|
|
2908
|
+
'recyclable': false,
|
|
2909
|
+
});
|
|
2910
|
+
d1.setAttribute(0, {
|
|
2911
|
+
'item-key': 'list-item-1',
|
|
2912
|
+
'reuse-identifier': 'A',
|
|
2913
|
+
'full-span': false,
|
|
2914
|
+
'sticky-top': false,
|
|
2915
|
+
'sticky-bottom': false,
|
|
2916
|
+
'estimated-height': 100,
|
|
2917
|
+
'estimated-height-px': 100,
|
|
2918
|
+
'estimated-main-axis-size-px': 100,
|
|
2919
|
+
'recyclable': true,
|
|
2920
|
+
});
|
|
2921
|
+
d2.setAttribute(0, {
|
|
2922
|
+
'item-key': 'list-item-2',
|
|
2923
|
+
'reuse-identifier': 'A',
|
|
2924
|
+
'full-span': true,
|
|
2925
|
+
'sticky-top': false,
|
|
2926
|
+
'sticky-bottom': true,
|
|
2927
|
+
'estimated-height': 100,
|
|
2928
|
+
'estimated-height-px': 100,
|
|
2929
|
+
'estimated-main-axis-size-px': 100,
|
|
2930
|
+
'recyclable': false,
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2934
|
+
__pendingListUpdates.flush();
|
|
2935
|
+
|
|
2936
|
+
expect(root).toMatchInlineSnapshot(`
|
|
2937
|
+
<view>
|
|
2938
|
+
<text>
|
|
2939
|
+
<raw-text
|
|
2940
|
+
text="111"
|
|
2941
|
+
/>
|
|
2942
|
+
</text>
|
|
2943
|
+
<wrapper>
|
|
2944
|
+
<list
|
|
2945
|
+
id="list"
|
|
2946
|
+
update-list-info={
|
|
2947
|
+
[
|
|
2948
|
+
{
|
|
2949
|
+
"insertAction": [
|
|
2950
|
+
{
|
|
2951
|
+
"estimated-height": 100,
|
|
2952
|
+
"estimated-height-px": 100,
|
|
2953
|
+
"estimated-main-axis-size-px": 100,
|
|
2954
|
+
"full-span": true,
|
|
2955
|
+
"item-key": "list-item-0",
|
|
2956
|
+
"position": 0,
|
|
2957
|
+
"recyclable": false,
|
|
2958
|
+
"reuse-identifier": "A",
|
|
2959
|
+
"sticky-bottom": false,
|
|
2960
|
+
"sticky-top": true,
|
|
2961
|
+
"type": "__snapshot_a94a8_test_61",
|
|
2962
|
+
},
|
|
2963
|
+
{
|
|
2964
|
+
"estimated-height": 100,
|
|
2965
|
+
"estimated-height-px": 100,
|
|
2966
|
+
"estimated-main-axis-size-px": 100,
|
|
2967
|
+
"full-span": false,
|
|
2968
|
+
"item-key": "list-item-1",
|
|
2969
|
+
"position": 1,
|
|
2970
|
+
"recyclable": true,
|
|
2971
|
+
"reuse-identifier": "A",
|
|
2972
|
+
"sticky-bottom": false,
|
|
2973
|
+
"sticky-top": false,
|
|
2974
|
+
"type": "__snapshot_a94a8_test_61",
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
"estimated-height": 100,
|
|
2978
|
+
"estimated-height-px": 100,
|
|
2979
|
+
"estimated-main-axis-size-px": 100,
|
|
2980
|
+
"full-span": true,
|
|
2981
|
+
"item-key": "list-item-2",
|
|
2982
|
+
"position": 2,
|
|
2983
|
+
"recyclable": false,
|
|
2984
|
+
"reuse-identifier": "A",
|
|
2985
|
+
"sticky-bottom": true,
|
|
2986
|
+
"sticky-top": false,
|
|
2987
|
+
"type": "__snapshot_a94a8_test_61",
|
|
2988
|
+
},
|
|
2989
|
+
],
|
|
2990
|
+
"removeAction": [],
|
|
2991
|
+
"updateAction": [],
|
|
2992
|
+
},
|
|
2993
|
+
]
|
|
2994
|
+
}
|
|
2995
|
+
/>
|
|
2996
|
+
</wrapper>
|
|
2997
|
+
</view>
|
|
2998
|
+
`);
|
|
2999
|
+
|
|
3000
|
+
{
|
|
3001
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
3002
|
+
elementTree.triggerComponentAtIndex(listRef, 1);
|
|
3003
|
+
elementTree.triggerComponentAtIndex(listRef, 2);
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
// All virtual attributes: recyclable and reuse-identifier should not be set to list-item element.
|
|
3007
|
+
expect(listRef).toMatchInlineSnapshot(`
|
|
3008
|
+
<list
|
|
3009
|
+
id="list"
|
|
3010
|
+
update-list-info={
|
|
3011
|
+
[
|
|
3012
|
+
{
|
|
3013
|
+
"insertAction": [
|
|
3014
|
+
{
|
|
3015
|
+
"estimated-height": 100,
|
|
3016
|
+
"estimated-height-px": 100,
|
|
3017
|
+
"estimated-main-axis-size-px": 100,
|
|
3018
|
+
"full-span": true,
|
|
3019
|
+
"item-key": "list-item-0",
|
|
3020
|
+
"position": 0,
|
|
3021
|
+
"recyclable": false,
|
|
3022
|
+
"reuse-identifier": "A",
|
|
3023
|
+
"sticky-bottom": false,
|
|
3024
|
+
"sticky-top": true,
|
|
3025
|
+
"type": "__snapshot_a94a8_test_61",
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
"estimated-height": 100,
|
|
3029
|
+
"estimated-height-px": 100,
|
|
3030
|
+
"estimated-main-axis-size-px": 100,
|
|
3031
|
+
"full-span": false,
|
|
3032
|
+
"item-key": "list-item-1",
|
|
3033
|
+
"position": 1,
|
|
3034
|
+
"recyclable": true,
|
|
3035
|
+
"reuse-identifier": "A",
|
|
3036
|
+
"sticky-bottom": false,
|
|
3037
|
+
"sticky-top": false,
|
|
3038
|
+
"type": "__snapshot_a94a8_test_61",
|
|
3039
|
+
},
|
|
3040
|
+
{
|
|
3041
|
+
"estimated-height": 100,
|
|
3042
|
+
"estimated-height-px": 100,
|
|
3043
|
+
"estimated-main-axis-size-px": 100,
|
|
3044
|
+
"full-span": true,
|
|
3045
|
+
"item-key": "list-item-2",
|
|
3046
|
+
"position": 2,
|
|
3047
|
+
"recyclable": false,
|
|
3048
|
+
"reuse-identifier": "A",
|
|
3049
|
+
"sticky-bottom": true,
|
|
3050
|
+
"sticky-top": false,
|
|
3051
|
+
"type": "__snapshot_a94a8_test_61",
|
|
3052
|
+
},
|
|
3053
|
+
],
|
|
3054
|
+
"removeAction": [],
|
|
3055
|
+
"updateAction": [],
|
|
3056
|
+
},
|
|
3057
|
+
]
|
|
3058
|
+
}
|
|
3059
|
+
>
|
|
3060
|
+
<list-item
|
|
3061
|
+
estimated-height={100}
|
|
3062
|
+
estimated-height-px={100}
|
|
3063
|
+
estimated-main-axis-size-px={100}
|
|
3064
|
+
full-span={true}
|
|
3065
|
+
item-key="list-item-0"
|
|
3066
|
+
sticky-bottom={false}
|
|
3067
|
+
sticky-top={true}
|
|
3068
|
+
>
|
|
3069
|
+
<text>
|
|
3070
|
+
<raw-text
|
|
3071
|
+
text="World"
|
|
3072
|
+
/>
|
|
3073
|
+
</text>
|
|
3074
|
+
</list-item>
|
|
3075
|
+
<list-item
|
|
3076
|
+
estimated-height={100}
|
|
3077
|
+
estimated-height-px={100}
|
|
3078
|
+
estimated-main-axis-size-px={100}
|
|
3079
|
+
full-span={false}
|
|
3080
|
+
item-key="list-item-1"
|
|
3081
|
+
sticky-bottom={false}
|
|
3082
|
+
sticky-top={false}
|
|
3083
|
+
>
|
|
3084
|
+
<text>
|
|
3085
|
+
<raw-text
|
|
3086
|
+
text="World"
|
|
3087
|
+
/>
|
|
3088
|
+
</text>
|
|
3089
|
+
</list-item>
|
|
3090
|
+
<list-item
|
|
3091
|
+
estimated-height={100}
|
|
3092
|
+
estimated-height-px={100}
|
|
3093
|
+
estimated-main-axis-size-px={100}
|
|
3094
|
+
full-span={true}
|
|
3095
|
+
item-key="list-item-2"
|
|
3096
|
+
sticky-bottom={true}
|
|
3097
|
+
sticky-top={false}
|
|
3098
|
+
>
|
|
3099
|
+
<text>
|
|
3100
|
+
<raw-text
|
|
3101
|
+
text="World"
|
|
3102
|
+
/>
|
|
3103
|
+
</text>
|
|
3104
|
+
</list-item>
|
|
3105
|
+
</list>
|
|
3106
|
+
`);
|
|
3107
|
+
});
|
|
3108
|
+
});
|
|
3109
|
+
|
|
3110
|
+
describe('list componentAtIndexes', () => {
|
|
3111
|
+
const s0 = __SNAPSHOT__(
|
|
3112
|
+
<view>
|
|
3113
|
+
<text>111</text>
|
|
3114
|
+
{HOLE}
|
|
3115
|
+
</view>,
|
|
3116
|
+
);
|
|
3117
|
+
const s01 = __SNAPSHOT__(
|
|
3118
|
+
<list id='list'>{HOLE}</list>,
|
|
3119
|
+
);
|
|
3120
|
+
|
|
3121
|
+
const s1 = __SNAPSHOT__(
|
|
3122
|
+
<list-item item-key={HOLE}>
|
|
3123
|
+
<text>World</text>
|
|
3124
|
+
</list-item>,
|
|
3125
|
+
);
|
|
3126
|
+
|
|
3127
|
+
it('basic componentAtIndexes with async flush', () => {
|
|
3128
|
+
const b = new SnapshotInstance(s0);
|
|
3129
|
+
b.ensureElements();
|
|
3130
|
+
const b1 = new SnapshotInstance(s01);
|
|
3131
|
+
b.insertBefore(b1);
|
|
3132
|
+
const listRef = b1.__elements[0];
|
|
3133
|
+
|
|
3134
|
+
const d0 = new SnapshotInstance(s1);
|
|
3135
|
+
const d1 = new SnapshotInstance(s1);
|
|
3136
|
+
const d2 = new SnapshotInstance(s1);
|
|
3137
|
+
d0.setAttribute(0, { 'item-key': 'list-item-0' });
|
|
3138
|
+
d1.setAttribute(0, { 'item-key': 'list-item-1' });
|
|
3139
|
+
d2.setAttribute(0, { 'item-key': 'list-item-2' });
|
|
3140
|
+
b1.insertBefore(d0);
|
|
3141
|
+
b1.insertBefore(d1);
|
|
3142
|
+
b1.insertBefore(d2);
|
|
3143
|
+
__pendingListUpdates.flush();
|
|
3144
|
+
|
|
3145
|
+
const fn = vi.fn();
|
|
3146
|
+
const __original = globalThis.__FlushElementTree;
|
|
3147
|
+
globalThis.__FlushElementTree = (_, options = {}) => {
|
|
3148
|
+
fn(options);
|
|
3149
|
+
};
|
|
3150
|
+
|
|
3151
|
+
{
|
|
3152
|
+
const cellIndexes = [0, 1, 2];
|
|
3153
|
+
const operationIDs = [0, 1, 2];
|
|
3154
|
+
const enableReuseNotification = false;
|
|
3155
|
+
const asyncFlush = true;
|
|
3156
|
+
elementTree.triggerComponentAtIndexes(listRef, cellIndexes, operationIDs, enableReuseNotification, asyncFlush);
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
globalThis.__FlushElementTree = __original;
|
|
3160
|
+
expect(fn.mock.calls).toMatchInlineSnapshot(`
|
|
3161
|
+
[
|
|
3162
|
+
[
|
|
3163
|
+
{
|
|
3164
|
+
"asyncFlush": true,
|
|
3165
|
+
},
|
|
3166
|
+
],
|
|
3167
|
+
[
|
|
3168
|
+
{
|
|
3169
|
+
"asyncFlush": true,
|
|
3170
|
+
},
|
|
3171
|
+
],
|
|
3172
|
+
[
|
|
3173
|
+
{
|
|
3174
|
+
"asyncFlush": true,
|
|
3175
|
+
},
|
|
3176
|
+
],
|
|
3177
|
+
[
|
|
3178
|
+
{
|
|
3179
|
+
"elementIDs": [
|
|
3180
|
+
5,
|
|
3181
|
+
8,
|
|
3182
|
+
11,
|
|
3183
|
+
],
|
|
3184
|
+
"listID": 4,
|
|
3185
|
+
"operationIDs": [
|
|
3186
|
+
0,
|
|
3187
|
+
1,
|
|
3188
|
+
2,
|
|
3189
|
+
],
|
|
3190
|
+
"triggerLayout": true,
|
|
3191
|
+
},
|
|
3192
|
+
],
|
|
3193
|
+
]
|
|
3194
|
+
`);
|
|
3195
|
+
|
|
3196
|
+
{
|
|
3197
|
+
const cellIndexes = [3];
|
|
3198
|
+
const operationIDs = [3];
|
|
3199
|
+
const enableReuseNotification = false;
|
|
3200
|
+
const asyncFlush = true;
|
|
3201
|
+
expect(() => {
|
|
3202
|
+
elementTree.triggerComponentAtIndexes(listRef, cellIndexes, operationIDs, enableReuseNotification, asyncFlush);
|
|
3203
|
+
}).toThrowErrorMatchingInlineSnapshot(`[Error: childCtx not found]`);
|
|
3204
|
+
}
|
|
3205
|
+
});
|
|
3206
|
+
|
|
3207
|
+
it('basic componentAtIndexes with no async flush', () => {
|
|
3208
|
+
const b = new SnapshotInstance(s0);
|
|
3209
|
+
b.ensureElements();
|
|
3210
|
+
const b1 = new SnapshotInstance(s01);
|
|
3211
|
+
b.insertBefore(b1);
|
|
3212
|
+
const listRef = b1.__elements[0];
|
|
3213
|
+
|
|
3214
|
+
const d0 = new SnapshotInstance(s1);
|
|
3215
|
+
const d1 = new SnapshotInstance(s1);
|
|
3216
|
+
const d2 = new SnapshotInstance(s1);
|
|
3217
|
+
d0.setAttribute(0, { 'item-key': 'list-item-0' });
|
|
3218
|
+
d1.setAttribute(0, { 'item-key': 'list-item-1' });
|
|
3219
|
+
d2.setAttribute(0, { 'item-key': 'list-item-2' });
|
|
3220
|
+
b1.insertBefore(d0);
|
|
3221
|
+
b1.insertBefore(d1);
|
|
3222
|
+
b1.insertBefore(d2);
|
|
3223
|
+
__pendingListUpdates.flush();
|
|
3224
|
+
|
|
3225
|
+
const fn = vi.fn();
|
|
3226
|
+
const __original = globalThis.__FlushElementTree;
|
|
3227
|
+
globalThis.__FlushElementTree = (_, options = {}) => {
|
|
3228
|
+
fn(options);
|
|
3229
|
+
};
|
|
3230
|
+
|
|
3231
|
+
{
|
|
3232
|
+
const cellIndexes = [0, 1, 2];
|
|
3233
|
+
const enableReuseNotification = false;
|
|
3234
|
+
const asyncFlush = false;
|
|
3235
|
+
elementTree.triggerComponentAtIndexes(listRef, cellIndexes, [11, 22, 33], enableReuseNotification, asyncFlush);
|
|
3236
|
+
}
|
|
3237
|
+
|
|
3238
|
+
globalThis.__FlushElementTree = __original;
|
|
3239
|
+
expect(fn.mock.calls).toMatchInlineSnapshot(`
|
|
3240
|
+
[
|
|
3241
|
+
[
|
|
3242
|
+
{
|
|
3243
|
+
"elementIDs": [
|
|
3244
|
+
5,
|
|
3245
|
+
8,
|
|
3246
|
+
11,
|
|
3247
|
+
],
|
|
3248
|
+
"listID": 4,
|
|
3249
|
+
"operationIDs": [
|
|
3250
|
+
11,
|
|
3251
|
+
22,
|
|
3252
|
+
33,
|
|
3253
|
+
],
|
|
3254
|
+
"triggerLayout": true,
|
|
3255
|
+
},
|
|
3256
|
+
],
|
|
3257
|
+
]
|
|
3258
|
+
`);
|
|
3259
|
+
});
|
|
3260
|
+
|
|
3261
|
+
it('basic componentAtIndexes with async flush and `enableReuseNotification` is true', () => {
|
|
3262
|
+
const b = new SnapshotInstance(s0);
|
|
3263
|
+
b.ensureElements();
|
|
3264
|
+
const b1 = new SnapshotInstance(s01);
|
|
3265
|
+
b.insertBefore(b1);
|
|
3266
|
+
const listRef = b1.__elements[0];
|
|
3267
|
+
const d0 = new SnapshotInstance(s1);
|
|
3268
|
+
const d1 = new SnapshotInstance(s1);
|
|
3269
|
+
const d2 = new SnapshotInstance(s1);
|
|
3270
|
+
const d3 = new SnapshotInstance(s1);
|
|
3271
|
+
const d4 = new SnapshotInstance(s1);
|
|
3272
|
+
const d5 = new SnapshotInstance(s1);
|
|
3273
|
+
d0.setAttribute(0, { 'item-key': 'list-item-0' });
|
|
3274
|
+
d1.setAttribute(0, { 'item-key': 'list-item-1' });
|
|
3275
|
+
d2.setAttribute(0, { 'item-key': 'list-item-2' });
|
|
3276
|
+
d3.setAttribute(0, { 'item-key': 'list-item-3' });
|
|
3277
|
+
d4.setAttribute(0, { 'item-key': 'list-item-4' });
|
|
3278
|
+
d5.setAttribute(0, { 'item-key': 'list-item-5' });
|
|
3279
|
+
b1.insertBefore(d0);
|
|
3280
|
+
b1.insertBefore(d1);
|
|
3281
|
+
b1.insertBefore(d2);
|
|
3282
|
+
b1.insertBefore(d3);
|
|
3283
|
+
b1.insertBefore(d4);
|
|
3284
|
+
b1.insertBefore(d5);
|
|
3285
|
+
__pendingListUpdates.flush();
|
|
3286
|
+
|
|
3287
|
+
{
|
|
3288
|
+
const component = [];
|
|
3289
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
3290
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
3291
|
+
component[2] = elementTree.triggerComponentAtIndex(listRef, 2);
|
|
3292
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
3293
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
3294
|
+
elementTree.triggerEnqueueComponent(listRef, component[2]);
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
const fn = vi.fn();
|
|
3298
|
+
const __original = globalThis.__FlushElementTree;
|
|
3299
|
+
globalThis.__FlushElementTree = (_, options = {}) => {
|
|
3300
|
+
const { listReuseNotification } = options;
|
|
3301
|
+
if (listReuseNotification !== undefined) {
|
|
3302
|
+
listReuseNotification['listElement'] = undefined;
|
|
3303
|
+
}
|
|
3304
|
+
fn(options);
|
|
3305
|
+
};
|
|
3306
|
+
|
|
3307
|
+
{
|
|
3308
|
+
const cellIndexes = [3, 4, 5];
|
|
3309
|
+
const operationIDs = [3, 4, 5];
|
|
3310
|
+
const enableReuseNotification = true;
|
|
3311
|
+
const asyncFlush = true;
|
|
3312
|
+
elementTree.triggerComponentAtIndexes(listRef, cellIndexes, operationIDs, enableReuseNotification, asyncFlush);
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
globalThis.__FlushElementTree = __original;
|
|
3316
|
+
expect(fn.mock.calls).toMatchInlineSnapshot(`
|
|
3317
|
+
[
|
|
3318
|
+
[
|
|
3319
|
+
{
|
|
3320
|
+
"asyncFlush": true,
|
|
3321
|
+
"listReuseNotification": {
|
|
3322
|
+
"itemKey": "list-item-3",
|
|
3323
|
+
"listElement": undefined,
|
|
3324
|
+
},
|
|
3325
|
+
},
|
|
3326
|
+
],
|
|
3327
|
+
[
|
|
3328
|
+
{
|
|
3329
|
+
"asyncFlush": true,
|
|
3330
|
+
"listReuseNotification": {
|
|
3331
|
+
"itemKey": "list-item-4",
|
|
3332
|
+
"listElement": undefined,
|
|
3333
|
+
},
|
|
3334
|
+
},
|
|
3335
|
+
],
|
|
3336
|
+
[
|
|
3337
|
+
{
|
|
3338
|
+
"asyncFlush": true,
|
|
3339
|
+
"listReuseNotification": {
|
|
3340
|
+
"itemKey": "list-item-5",
|
|
3341
|
+
"listElement": undefined,
|
|
3342
|
+
},
|
|
3343
|
+
},
|
|
3344
|
+
],
|
|
3345
|
+
[
|
|
3346
|
+
{
|
|
3347
|
+
"elementIDs": [
|
|
3348
|
+
5,
|
|
3349
|
+
8,
|
|
3350
|
+
11,
|
|
3351
|
+
],
|
|
3352
|
+
"listID": 4,
|
|
3353
|
+
"operationIDs": [
|
|
3354
|
+
3,
|
|
3355
|
+
4,
|
|
3356
|
+
5,
|
|
3357
|
+
],
|
|
3358
|
+
"triggerLayout": true,
|
|
3359
|
+
},
|
|
3360
|
+
],
|
|
3361
|
+
]
|
|
3362
|
+
`);
|
|
3363
|
+
});
|
|
3364
|
+
|
|
3365
|
+
it('should handle continuous componentAtIndexes on same index - self reuse', () => {
|
|
3366
|
+
const b = new SnapshotInstance(s0);
|
|
3367
|
+
b.ensureElements();
|
|
3368
|
+
const b1 = new SnapshotInstance(s01);
|
|
3369
|
+
b.insertBefore(b1);
|
|
3370
|
+
const listRef = b1.__elements[0];
|
|
3371
|
+
const d0 = new SnapshotInstance(s1);
|
|
3372
|
+
const d1 = new SnapshotInstance(s1);
|
|
3373
|
+
const d2 = new SnapshotInstance(s1);
|
|
3374
|
+
d0.setAttribute(0, { 'item-key': 'list-item-0' });
|
|
3375
|
+
d1.setAttribute(0, { 'item-key': 'list-item-1' });
|
|
3376
|
+
d2.setAttribute(0, { 'item-key': 'list-item-2' });
|
|
3377
|
+
b1.insertBefore(d0);
|
|
3378
|
+
b1.insertBefore(d1);
|
|
3379
|
+
b1.insertBefore(d2);
|
|
3380
|
+
__pendingListUpdates.flush();
|
|
3381
|
+
|
|
3382
|
+
{
|
|
3383
|
+
const component = [];
|
|
3384
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
3385
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
3386
|
+
component[2] = elementTree.triggerComponentAtIndex(listRef, 2);
|
|
3387
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
3388
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
3389
|
+
elementTree.triggerEnqueueComponent(listRef, component[2]);
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
const fn = vi.fn();
|
|
3393
|
+
const __original = globalThis.__FlushElementTree;
|
|
3394
|
+
globalThis.__FlushElementTree = (_, options = {}) => {
|
|
3395
|
+
fn(options);
|
|
3396
|
+
};
|
|
3397
|
+
|
|
3398
|
+
{
|
|
3399
|
+
const cellIndexes = [0, 1, 2];
|
|
3400
|
+
const operationIDs = [0, 1, 2];
|
|
3401
|
+
const enableReuseNotification = false;
|
|
3402
|
+
const asyncFlush = true;
|
|
3403
|
+
elementTree.triggerComponentAtIndexes(listRef, cellIndexes, operationIDs, enableReuseNotification, asyncFlush);
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
globalThis.__FlushElementTree = __original;
|
|
3407
|
+
expect(fn.mock.calls).toMatchInlineSnapshot(`
|
|
3408
|
+
[
|
|
3409
|
+
[
|
|
3410
|
+
{
|
|
3411
|
+
"asyncFlush": true,
|
|
3412
|
+
},
|
|
3413
|
+
],
|
|
3414
|
+
[
|
|
3415
|
+
{
|
|
3416
|
+
"asyncFlush": true,
|
|
3417
|
+
},
|
|
3418
|
+
],
|
|
3419
|
+
[
|
|
3420
|
+
{
|
|
3421
|
+
"asyncFlush": true,
|
|
3422
|
+
},
|
|
3423
|
+
],
|
|
3424
|
+
[
|
|
3425
|
+
{
|
|
3426
|
+
"elementIDs": [
|
|
3427
|
+
5,
|
|
3428
|
+
8,
|
|
3429
|
+
11,
|
|
3430
|
+
],
|
|
3431
|
+
"listID": 4,
|
|
3432
|
+
"operationIDs": [
|
|
3433
|
+
0,
|
|
3434
|
+
1,
|
|
3435
|
+
2,
|
|
3436
|
+
],
|
|
3437
|
+
"triggerLayout": true,
|
|
3438
|
+
},
|
|
3439
|
+
],
|
|
3440
|
+
]
|
|
3441
|
+
`);
|
|
3442
|
+
});
|
|
3443
|
+
|
|
3444
|
+
it('should update signMap before __FlushElementTree', () => {
|
|
3445
|
+
const b = new SnapshotInstance(s0);
|
|
3446
|
+
b.ensureElements();
|
|
3447
|
+
const b1 = new SnapshotInstance(s01);
|
|
3448
|
+
b.insertBefore(b1);
|
|
3449
|
+
const listRef = b1.__elements[0];
|
|
3450
|
+
const d0 = new SnapshotInstance(s1);
|
|
3451
|
+
const d1 = new SnapshotInstance(s1);
|
|
3452
|
+
const d2 = new SnapshotInstance(s1);
|
|
3453
|
+
d0.setAttribute(0, { 'item-key': 'list-item-0' });
|
|
3454
|
+
d1.setAttribute(0, { 'item-key': 'list-item-1' });
|
|
3455
|
+
d2.setAttribute(0, { 'item-key': 'list-item-2' });
|
|
3456
|
+
b1.insertBefore(d0);
|
|
3457
|
+
b1.insertBefore(d1);
|
|
3458
|
+
b1.insertBefore(d2);
|
|
3459
|
+
__pendingListUpdates.flush();
|
|
3460
|
+
|
|
3461
|
+
const listID = __GetElementUniqueID(listRef);
|
|
3462
|
+
const signMap = gSignMap[listID];
|
|
3463
|
+
const recycleMap = gRecycleMap[listID];
|
|
3464
|
+
|
|
3465
|
+
{
|
|
3466
|
+
const flushElementTreeSpy = vi.spyOn(globalThis, '__FlushElementTree');
|
|
3467
|
+
const signMapSetSpy = vi.spyOn(signMap, 'set');
|
|
3468
|
+
|
|
3469
|
+
const component = [];
|
|
3470
|
+
component[0] = elementTree.triggerComponentAtIndex(listRef, 0);
|
|
3471
|
+
component[1] = elementTree.triggerComponentAtIndex(listRef, 1);
|
|
3472
|
+
elementTree.triggerEnqueueComponent(listRef, component[0]);
|
|
3473
|
+
elementTree.triggerEnqueueComponent(listRef, component[1]);
|
|
3474
|
+
// no reuse occurs
|
|
3475
|
+
expect(signMapSetSpy).toHaveBeenCalled();
|
|
3476
|
+
expect(flushElementTreeSpy).toHaveBeenCalled();
|
|
3477
|
+
expect(signMapSetSpy.mock.invocationCallOrder[0])
|
|
3478
|
+
.toBeLessThan(flushElementTreeSpy.mock.invocationCallOrder[0]);
|
|
3479
|
+
|
|
3480
|
+
flushElementTreeSpy.mockRestore();
|
|
3481
|
+
signMapSetSpy.mockRestore();
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
// re-spy
|
|
3485
|
+
const flushElementTreeSpy = vi.spyOn(globalThis, '__FlushElementTree');
|
|
3486
|
+
const signMapSetSpy = vi.spyOn(signMap, 'set');
|
|
3487
|
+
const recycleSignMap = recycleMap.get(s1);
|
|
3488
|
+
expect(Array.from(recycleSignMap.keys()).length).toBe(2);
|
|
3489
|
+
// reuse occurs
|
|
3490
|
+
elementTree.triggerComponentAtIndex(listRef, 2);
|
|
3491
|
+
expect(signMapSetSpy).toHaveBeenCalled();
|
|
3492
|
+
expect(flushElementTreeSpy).toHaveBeenCalled();
|
|
3493
|
+
expect(signMapSetSpy.mock.invocationCallOrder[0])
|
|
3494
|
+
.toBeLessThan(flushElementTreeSpy.mock.invocationCallOrder[0]);
|
|
3495
|
+
|
|
3496
|
+
flushElementTreeSpy.mockRestore();
|
|
3497
|
+
signMapSetSpy.mockRestore();
|
|
3498
|
+
});
|
|
3499
|
+
});
|
|
3500
|
+
|
|
3501
|
+
describe('list-item with "defer" attribute', () => {
|
|
3502
|
+
beforeEach(() => {
|
|
3503
|
+
globalEnvManager.resetEnv();
|
|
3504
|
+
elementTree.clear();
|
|
3505
|
+
vi.useFakeTimers();
|
|
3506
|
+
});
|
|
3507
|
+
|
|
3508
|
+
it('basic deferred <list-item/>', async () => {
|
|
3509
|
+
const _F1 = vi.fn();
|
|
3510
|
+
|
|
3511
|
+
const jsx = (
|
|
3512
|
+
<list id='list' custom-list-name='list-container'>
|
|
3513
|
+
<list-item item-key='1' defer>
|
|
3514
|
+
<_F1 />
|
|
3515
|
+
</list-item>
|
|
3516
|
+
</list>
|
|
3517
|
+
);
|
|
3518
|
+
const child = __SNAPSHOT__(<text>Hello World</text>);
|
|
3519
|
+
|
|
3520
|
+
__root.__jsx = jsx;
|
|
3521
|
+
|
|
3522
|
+
renderPage();
|
|
3523
|
+
|
|
3524
|
+
expect(_F1).toBeCalledTimes(0);
|
|
3525
|
+
expect(__root.__element_root).toMatchInlineSnapshot(`
|
|
3526
|
+
<page
|
|
3527
|
+
cssId="default-entry-from-native:0"
|
|
3528
|
+
>
|
|
3529
|
+
<list
|
|
3530
|
+
custom-list-name="list-container"
|
|
3531
|
+
id="list"
|
|
3532
|
+
update-list-info={
|
|
3533
|
+
[
|
|
3534
|
+
{
|
|
3535
|
+
"insertAction": [
|
|
3536
|
+
{
|
|
3537
|
+
"item-key": "1",
|
|
3538
|
+
"position": 0,
|
|
3539
|
+
"type": "__snapshot_a94a8_test_66",
|
|
3540
|
+
},
|
|
3541
|
+
],
|
|
3542
|
+
"removeAction": [],
|
|
3543
|
+
"updateAction": [],
|
|
3544
|
+
},
|
|
3545
|
+
]
|
|
3546
|
+
}
|
|
3547
|
+
/>
|
|
3548
|
+
</page>
|
|
3549
|
+
`);
|
|
3550
|
+
|
|
3551
|
+
__pendingListUpdates.flush();
|
|
3552
|
+
|
|
3553
|
+
const listRef = elementTree.getElementById('list');
|
|
3554
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
3555
|
+
|
|
3556
|
+
const p = __root.__firstChild.__firstChild.__extraProps['isReady'];
|
|
3557
|
+
__root.__firstChild.__firstChild.__extraProps['isReady'] = 1;
|
|
3558
|
+
__root.__firstChild.__firstChild.insertBefore(new SnapshotInstance(child));
|
|
3559
|
+
const uiSign = await p;
|
|
3560
|
+
|
|
3561
|
+
expect(uiSign).toBeTypeOf('number');
|
|
3562
|
+
expect(__root.__element_root).toMatchInlineSnapshot(`
|
|
3563
|
+
<page
|
|
3564
|
+
cssId="default-entry-from-native:0"
|
|
3565
|
+
>
|
|
3566
|
+
<list
|
|
3567
|
+
custom-list-name="list-container"
|
|
3568
|
+
id="list"
|
|
3569
|
+
update-list-info={
|
|
3570
|
+
[
|
|
3571
|
+
{
|
|
3572
|
+
"insertAction": [
|
|
3573
|
+
{
|
|
3574
|
+
"item-key": "1",
|
|
3575
|
+
"position": 0,
|
|
3576
|
+
"type": "__snapshot_a94a8_test_66",
|
|
3577
|
+
},
|
|
3578
|
+
],
|
|
3579
|
+
"removeAction": [],
|
|
3580
|
+
"updateAction": [],
|
|
3581
|
+
},
|
|
3582
|
+
]
|
|
3583
|
+
}
|
|
3584
|
+
>
|
|
3585
|
+
<list-item
|
|
3586
|
+
item-key="1"
|
|
3587
|
+
>
|
|
3588
|
+
<text>
|
|
3589
|
+
<raw-text
|
|
3590
|
+
text="Hello World"
|
|
3591
|
+
/>
|
|
3592
|
+
</text>
|
|
3593
|
+
</list-item>
|
|
3594
|
+
</list>
|
|
3595
|
+
</page>
|
|
3596
|
+
`);
|
|
3597
|
+
});
|
|
3598
|
+
|
|
3599
|
+
it('basic deferred <list-item/> - componentAtIndex continuously should throw', async () => {
|
|
3600
|
+
const _F1 = vi.fn();
|
|
3601
|
+
|
|
3602
|
+
const jsx = (
|
|
3603
|
+
<list id='list' custom-list-name='list-container'>
|
|
3604
|
+
<list-item item-key='1' defer>
|
|
3605
|
+
<_F1 />
|
|
3606
|
+
</list-item>
|
|
3607
|
+
</list>
|
|
3608
|
+
);
|
|
3609
|
+
__root.__jsx = jsx;
|
|
3610
|
+
|
|
3611
|
+
renderPage();
|
|
3612
|
+
__pendingListUpdates.flush();
|
|
3613
|
+
|
|
3614
|
+
const listRef = elementTree.getElementById('list');
|
|
3615
|
+
elementTree.triggerComponentAtIndex(listRef, 0, 11);
|
|
3616
|
+
expect(() => elementTree.triggerComponentAtIndex(listRef, 0, 22)).toThrowErrorMatchingInlineSnapshot(
|
|
3617
|
+
`[Error: componentAtIndex was called on a pending deferred list item]`,
|
|
3618
|
+
);
|
|
3619
|
+
});
|
|
3620
|
+
|
|
3621
|
+
it('basic deferred <list-item/> - componentAtIndexes', async () => {
|
|
3622
|
+
const _F1 = vi.fn();
|
|
3623
|
+
|
|
3624
|
+
const jsx = (
|
|
3625
|
+
<list id='list' custom-list-name='list-container'>
|
|
3626
|
+
<list-item item-key='0'>
|
|
3627
|
+
<_F1 />
|
|
3628
|
+
</list-item>
|
|
3629
|
+
<list-item item-key='1' defer>
|
|
3630
|
+
<_F1 />
|
|
3631
|
+
</list-item>
|
|
3632
|
+
<list-item item-key='2' defer>
|
|
3633
|
+
<_F1 />
|
|
3634
|
+
</list-item>
|
|
3635
|
+
</list>
|
|
3636
|
+
);
|
|
3637
|
+
__root.__jsx = jsx;
|
|
3638
|
+
|
|
3639
|
+
renderPage();
|
|
3640
|
+
__pendingListUpdates.flush();
|
|
3641
|
+
|
|
3642
|
+
const listRef = elementTree.getElementById('list');
|
|
3643
|
+
const __FlushElementTree = vi.fn();
|
|
3644
|
+
vi.stubGlobal('__FlushElementTree', __FlushElementTree);
|
|
3645
|
+
elementTree.triggerComponentAtIndexes(listRef, [0, 1, 2], [11, 22, 33], false, true);
|
|
3646
|
+
|
|
3647
|
+
// a list-item which is not deferred should trigger two flush
|
|
3648
|
+
expect(__FlushElementTree.mock.calls).toMatchInlineSnapshot(`
|
|
3649
|
+
[
|
|
3650
|
+
[
|
|
3651
|
+
<list-item
|
|
3652
|
+
item-key="0"
|
|
3653
|
+
/>,
|
|
3654
|
+
{
|
|
3655
|
+
"asyncFlush": true,
|
|
3656
|
+
},
|
|
3657
|
+
],
|
|
3658
|
+
[
|
|
3659
|
+
<list
|
|
3660
|
+
custom-list-name="list-container"
|
|
3661
|
+
id="list"
|
|
3662
|
+
update-list-info={
|
|
3663
|
+
[
|
|
3664
|
+
{
|
|
3665
|
+
"insertAction": [
|
|
3666
|
+
{
|
|
3667
|
+
"item-key": "0",
|
|
3668
|
+
"position": 0,
|
|
3669
|
+
"type": "__snapshot_a94a8_test_71",
|
|
3670
|
+
},
|
|
3671
|
+
{
|
|
3672
|
+
"item-key": "1",
|
|
3673
|
+
"position": 1,
|
|
3674
|
+
"type": "__snapshot_a94a8_test_72",
|
|
3675
|
+
},
|
|
3676
|
+
{
|
|
3677
|
+
"item-key": "2",
|
|
3678
|
+
"position": 2,
|
|
3679
|
+
"type": "__snapshot_a94a8_test_73",
|
|
3680
|
+
},
|
|
3681
|
+
],
|
|
3682
|
+
"removeAction": [],
|
|
3683
|
+
"updateAction": [],
|
|
3684
|
+
},
|
|
3685
|
+
]
|
|
3686
|
+
}
|
|
3687
|
+
>
|
|
3688
|
+
<list-item
|
|
3689
|
+
item-key="0"
|
|
3690
|
+
/>
|
|
3691
|
+
</list>,
|
|
3692
|
+
{
|
|
3693
|
+
"elementIDs": [
|
|
3694
|
+
2,
|
|
3695
|
+
-1,
|
|
3696
|
+
-1,
|
|
3697
|
+
],
|
|
3698
|
+
"listID": 1,
|
|
3699
|
+
"operationIDs": [
|
|
3700
|
+
11,
|
|
3701
|
+
22,
|
|
3702
|
+
33,
|
|
3703
|
+
],
|
|
3704
|
+
"triggerLayout": true,
|
|
3705
|
+
},
|
|
3706
|
+
],
|
|
3707
|
+
]
|
|
3708
|
+
`);
|
|
3709
|
+
__FlushElementTree.mockClear();
|
|
3710
|
+
|
|
3711
|
+
const ps = __root.__firstChild.childNodes.map(c => c.__extraProps?.['isReady']);
|
|
3712
|
+
|
|
3713
|
+
__root.__firstChild.childNodes[1].__extraProps['isReady'] = 1;
|
|
3714
|
+
__root.__firstChild.childNodes[2].__extraProps['isReady'] = 1;
|
|
3715
|
+
|
|
3716
|
+
await Promise.all(ps);
|
|
3717
|
+
expect(__FlushElementTree.mock.calls).toMatchInlineSnapshot(`
|
|
3718
|
+
[
|
|
3719
|
+
[
|
|
3720
|
+
<list-item
|
|
3721
|
+
item-key="1"
|
|
3722
|
+
/>,
|
|
3723
|
+
{
|
|
3724
|
+
"elementID": 3,
|
|
3725
|
+
"listID": 1,
|
|
3726
|
+
"operationID": 22,
|
|
3727
|
+
"triggerLayout": true,
|
|
3728
|
+
},
|
|
3729
|
+
],
|
|
3730
|
+
[
|
|
3731
|
+
<list-item
|
|
3732
|
+
item-key="2"
|
|
3733
|
+
/>,
|
|
3734
|
+
{
|
|
3735
|
+
"elementID": 4,
|
|
3736
|
+
"listID": 1,
|
|
3737
|
+
"operationID": 33,
|
|
3738
|
+
"triggerLayout": true,
|
|
3739
|
+
},
|
|
3740
|
+
],
|
|
3741
|
+
[
|
|
3742
|
+
<list
|
|
3743
|
+
custom-list-name="list-container"
|
|
3744
|
+
id="list"
|
|
3745
|
+
update-list-info={
|
|
3746
|
+
[
|
|
3747
|
+
{
|
|
3748
|
+
"insertAction": [
|
|
3749
|
+
{
|
|
3750
|
+
"item-key": "0",
|
|
3751
|
+
"position": 0,
|
|
3752
|
+
"type": "__snapshot_a94a8_test_71",
|
|
3753
|
+
},
|
|
3754
|
+
{
|
|
3755
|
+
"item-key": "1",
|
|
3756
|
+
"position": 1,
|
|
3757
|
+
"type": "__snapshot_a94a8_test_72",
|
|
3758
|
+
},
|
|
3759
|
+
{
|
|
3760
|
+
"item-key": "2",
|
|
3761
|
+
"position": 2,
|
|
3762
|
+
"type": "__snapshot_a94a8_test_73",
|
|
3763
|
+
},
|
|
3764
|
+
],
|
|
3765
|
+
"removeAction": [],
|
|
3766
|
+
"updateAction": [],
|
|
3767
|
+
},
|
|
3768
|
+
]
|
|
3769
|
+
}
|
|
3770
|
+
>
|
|
3771
|
+
<list-item
|
|
3772
|
+
item-key="0"
|
|
3773
|
+
/>
|
|
3774
|
+
<list-item
|
|
3775
|
+
item-key="1"
|
|
3776
|
+
/>
|
|
3777
|
+
<list-item
|
|
3778
|
+
item-key="2"
|
|
3779
|
+
/>
|
|
3780
|
+
</list>,
|
|
3781
|
+
{
|
|
3782
|
+
"elementIDs": [
|
|
3783
|
+
2,
|
|
3784
|
+
3,
|
|
3785
|
+
4,
|
|
3786
|
+
],
|
|
3787
|
+
"listID": 1,
|
|
3788
|
+
"operationIDs": [
|
|
3789
|
+
11,
|
|
3790
|
+
22,
|
|
3791
|
+
33,
|
|
3792
|
+
],
|
|
3793
|
+
"triggerLayout": true,
|
|
3794
|
+
},
|
|
3795
|
+
],
|
|
3796
|
+
]
|
|
3797
|
+
`);
|
|
3798
|
+
});
|
|
3799
|
+
|
|
3800
|
+
it('basic deferred <list-item/> - should unmount when reused', async () => {
|
|
3801
|
+
const _F1 = vi.fn();
|
|
3802
|
+
|
|
3803
|
+
const child = __SNAPSHOT__(<text>Hello World</text>);
|
|
3804
|
+
const jsx = (
|
|
3805
|
+
<list id='list' custom-list-name='list-container'>
|
|
3806
|
+
{[0, 1, 2].map((v) => (
|
|
3807
|
+
<list-item item-key={`${v}`} defer>
|
|
3808
|
+
<_F1 />
|
|
3809
|
+
</list-item>
|
|
3810
|
+
))}
|
|
3811
|
+
</list>
|
|
3812
|
+
);
|
|
3813
|
+
|
|
3814
|
+
__root.__jsx = jsx;
|
|
3815
|
+
|
|
3816
|
+
renderPage();
|
|
3817
|
+
|
|
3818
|
+
expect(_F1).toBeCalledTimes(0);
|
|
3819
|
+
expect(__root.__element_root).toMatchInlineSnapshot(`
|
|
3820
|
+
<page
|
|
3821
|
+
cssId="default-entry-from-native:0"
|
|
3822
|
+
>
|
|
3823
|
+
<list
|
|
3824
|
+
custom-list-name="list-container"
|
|
3825
|
+
id="list"
|
|
3826
|
+
update-list-info={
|
|
3827
|
+
[
|
|
3828
|
+
{
|
|
3829
|
+
"insertAction": [
|
|
3830
|
+
{
|
|
3831
|
+
"item-key": "0",
|
|
3832
|
+
"position": 0,
|
|
3833
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3834
|
+
},
|
|
3835
|
+
{
|
|
3836
|
+
"item-key": "1",
|
|
3837
|
+
"position": 1,
|
|
3838
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3839
|
+
},
|
|
3840
|
+
{
|
|
3841
|
+
"item-key": "2",
|
|
3842
|
+
"position": 2,
|
|
3843
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3844
|
+
},
|
|
3845
|
+
],
|
|
3846
|
+
"removeAction": [],
|
|
3847
|
+
"updateAction": [],
|
|
3848
|
+
},
|
|
3849
|
+
]
|
|
3850
|
+
}
|
|
3851
|
+
/>
|
|
3852
|
+
</page>
|
|
3853
|
+
`);
|
|
3854
|
+
|
|
3855
|
+
__pendingListUpdates.flush();
|
|
3856
|
+
|
|
3857
|
+
const listRef = elementTree.getElementById('list');
|
|
3858
|
+
elementTree.triggerComponentAtIndex(listRef, 0);
|
|
3859
|
+
|
|
3860
|
+
const p = __root.__firstChild.__firstChild.__extraProps['isReady'];
|
|
3861
|
+
__root.__firstChild.__firstChild.__extraProps['isReady'] = 1;
|
|
3862
|
+
__root.__firstChild.__firstChild.insertBefore(new SnapshotInstance(child));
|
|
3863
|
+
const uiSign = await p;
|
|
3864
|
+
|
|
3865
|
+
expect(uiSign).toBeTypeOf('number');
|
|
3866
|
+
expect(__root.__element_root).toMatchInlineSnapshot(`
|
|
3867
|
+
<page
|
|
3868
|
+
cssId="default-entry-from-native:0"
|
|
3869
|
+
>
|
|
3870
|
+
<list
|
|
3871
|
+
custom-list-name="list-container"
|
|
3872
|
+
id="list"
|
|
3873
|
+
update-list-info={
|
|
3874
|
+
[
|
|
3875
|
+
{
|
|
3876
|
+
"insertAction": [
|
|
3877
|
+
{
|
|
3878
|
+
"item-key": "0",
|
|
3879
|
+
"position": 0,
|
|
3880
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3881
|
+
},
|
|
3882
|
+
{
|
|
3883
|
+
"item-key": "1",
|
|
3884
|
+
"position": 1,
|
|
3885
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3886
|
+
},
|
|
3887
|
+
{
|
|
3888
|
+
"item-key": "2",
|
|
3889
|
+
"position": 2,
|
|
3890
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3891
|
+
},
|
|
3892
|
+
],
|
|
3893
|
+
"removeAction": [],
|
|
3894
|
+
"updateAction": [],
|
|
3895
|
+
},
|
|
3896
|
+
]
|
|
3897
|
+
}
|
|
3898
|
+
>
|
|
3899
|
+
<list-item
|
|
3900
|
+
item-key="0"
|
|
3901
|
+
>
|
|
3902
|
+
<text>
|
|
3903
|
+
<raw-text
|
|
3904
|
+
text="Hello World"
|
|
3905
|
+
/>
|
|
3906
|
+
</text>
|
|
3907
|
+
</list-item>
|
|
3908
|
+
</list>
|
|
3909
|
+
</page>
|
|
3910
|
+
`);
|
|
3911
|
+
|
|
3912
|
+
elementTree.triggerEnqueueComponent(listRef, uiSign);
|
|
3913
|
+
|
|
3914
|
+
{
|
|
3915
|
+
globalThis.__OnLifecycleEvent.mockClear();
|
|
3916
|
+
elementTree.triggerComponentAtIndex(listRef, 1);
|
|
3917
|
+
const item = __root.__firstChild.__firstChild.__nextSibling;
|
|
3918
|
+
const p = item.__extraProps['isReady'];
|
|
3919
|
+
item.__extraProps['isReady'] = 1;
|
|
3920
|
+
item.insertBefore(new SnapshotInstance(child));
|
|
3921
|
+
const uiSign2 = await p;
|
|
3922
|
+
|
|
3923
|
+
expect(uiSign2).toBeTypeOf('number');
|
|
3924
|
+
expect(uiSign2).toBe(uiSign);
|
|
3925
|
+
expect(__root.__element_root).toMatchInlineSnapshot(`
|
|
3926
|
+
<page
|
|
3927
|
+
cssId="default-entry-from-native:0"
|
|
3928
|
+
>
|
|
3929
|
+
<list
|
|
3930
|
+
custom-list-name="list-container"
|
|
3931
|
+
id="list"
|
|
3932
|
+
update-list-info={
|
|
3933
|
+
[
|
|
3934
|
+
{
|
|
3935
|
+
"insertAction": [
|
|
3936
|
+
{
|
|
3937
|
+
"item-key": "0",
|
|
3938
|
+
"position": 0,
|
|
3939
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3940
|
+
},
|
|
3941
|
+
{
|
|
3942
|
+
"item-key": "1",
|
|
3943
|
+
"position": 1,
|
|
3944
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3945
|
+
},
|
|
3946
|
+
{
|
|
3947
|
+
"item-key": "2",
|
|
3948
|
+
"position": 2,
|
|
3949
|
+
"type": "__snapshot_a94a8_test_76",
|
|
3950
|
+
},
|
|
3951
|
+
],
|
|
3952
|
+
"removeAction": [],
|
|
3953
|
+
"updateAction": [],
|
|
3954
|
+
},
|
|
3955
|
+
]
|
|
3956
|
+
}
|
|
3957
|
+
>
|
|
3958
|
+
<list-item
|
|
3959
|
+
item-key="1"
|
|
3960
|
+
>
|
|
3961
|
+
<text>
|
|
3962
|
+
<raw-text
|
|
3963
|
+
text="Hello World"
|
|
3964
|
+
/>
|
|
3965
|
+
</text>
|
|
3966
|
+
</list-item>
|
|
3967
|
+
</list>
|
|
3968
|
+
</page>
|
|
3969
|
+
`);
|
|
3970
|
+
|
|
3971
|
+
expect(globalThis.__OnLifecycleEvent.mock.calls).toMatchInlineSnapshot(`
|
|
3972
|
+
[
|
|
3973
|
+
[
|
|
3974
|
+
[
|
|
3975
|
+
"rLynxPublishEvent",
|
|
3976
|
+
{
|
|
3977
|
+
"data": {},
|
|
3978
|
+
"handlerName": "-7:__extraProps:onComponentAtIndex",
|
|
3979
|
+
},
|
|
3980
|
+
],
|
|
3981
|
+
],
|
|
3982
|
+
[
|
|
3983
|
+
[
|
|
3984
|
+
"rLynxPublishEvent",
|
|
3985
|
+
{
|
|
3986
|
+
"data": {},
|
|
3987
|
+
"handlerName": "-5:__extraProps:onRecycleComponent",
|
|
3988
|
+
},
|
|
3989
|
+
],
|
|
3990
|
+
],
|
|
3991
|
+
]
|
|
3992
|
+
`);
|
|
3993
|
+
}
|
|
3994
|
+
});
|
|
3995
|
+
|
|
3996
|
+
it('should throw without custom-list-name="list-container"', async () => {
|
|
3997
|
+
const _F1 = vi.fn();
|
|
3998
|
+
|
|
3999
|
+
const jsx = (
|
|
4000
|
+
<list id='list'>
|
|
4001
|
+
{[0, 1, 2].map((v) => (
|
|
4002
|
+
<list-item item-key={`${v}`} defer>
|
|
4003
|
+
<_F1 />
|
|
4004
|
+
</list-item>
|
|
4005
|
+
))}
|
|
4006
|
+
</list>
|
|
4007
|
+
);
|
|
4008
|
+
|
|
4009
|
+
__root.__jsx = jsx;
|
|
4010
|
+
|
|
4011
|
+
renderPage();
|
|
4012
|
+
|
|
4013
|
+
expect(_F1).toBeCalledTimes(0);
|
|
4014
|
+
|
|
4015
|
+
__pendingListUpdates.flush();
|
|
4016
|
+
|
|
4017
|
+
const listRef = elementTree.getElementById('list');
|
|
4018
|
+
expect(() => elementTree.triggerComponentAtIndex(listRef, 0)).toThrowErrorMatchingInlineSnapshot(
|
|
4019
|
+
`[Error: Unsupported: \`<list-item/>\` with \`defer={true}\` must be used with \`<list custom-list-name="list-container"/>\`]`,
|
|
4020
|
+
);
|
|
4021
|
+
});
|
|
4022
|
+
});
|
|
4023
|
+
|
|
4024
|
+
describe('nested list', () => {
|
|
4025
|
+
const s = __SNAPSHOT__(
|
|
4026
|
+
<view>
|
|
4027
|
+
<text>Hello</text>
|
|
4028
|
+
{HOLE}
|
|
4029
|
+
</view>,
|
|
4030
|
+
);
|
|
4031
|
+
|
|
4032
|
+
it('nested list should work', () => {
|
|
4033
|
+
const s1 = __SNAPSHOT__(
|
|
4034
|
+
<view>
|
|
4035
|
+
<text>s1</text>
|
|
4036
|
+
{HOLE}
|
|
4037
|
+
</view>,
|
|
4038
|
+
);
|
|
4039
|
+
const s11 = __SNAPSHOT__(
|
|
4040
|
+
<list>{HOLE}</list>,
|
|
4041
|
+
);
|
|
4042
|
+
const s2 = __SNAPSHOT__(
|
|
4043
|
+
<list-item>
|
|
4044
|
+
<text>s2</text>
|
|
4045
|
+
{HOLE}
|
|
4046
|
+
</list-item>,
|
|
4047
|
+
);
|
|
4048
|
+
const s21 = __SNAPSHOT__(
|
|
4049
|
+
<list>{HOLE}</list>,
|
|
4050
|
+
);
|
|
4051
|
+
const s3 = __SNAPSHOT__(
|
|
4052
|
+
<list-item>
|
|
4053
|
+
<text>s3</text>
|
|
4054
|
+
</list-item>,
|
|
4055
|
+
);
|
|
4056
|
+
|
|
4057
|
+
const a = new SnapshotInstance(s);
|
|
4058
|
+
|
|
4059
|
+
const b = new SnapshotInstance(s1);
|
|
4060
|
+
a.insertBefore(b);
|
|
4061
|
+
|
|
4062
|
+
const b1 = new SnapshotInstance(s11);
|
|
4063
|
+
b.insertBefore(b1);
|
|
4064
|
+
|
|
4065
|
+
b.ensureElements();
|
|
4066
|
+
const parentListRef = b1.__elements[0];
|
|
4067
|
+
|
|
4068
|
+
const c1 = new SnapshotInstance(s2);
|
|
4069
|
+
const c11 = new SnapshotInstance(s21);
|
|
4070
|
+
const c2 = new SnapshotInstance(s2);
|
|
4071
|
+
const c21 = new SnapshotInstance(s21);
|
|
4072
|
+
const c3 = new SnapshotInstance(s2);
|
|
4073
|
+
const c31 = new SnapshotInstance(s21);
|
|
4074
|
+
c1.insertBefore(c11);
|
|
4075
|
+
c2.insertBefore(c21);
|
|
4076
|
+
c3.insertBefore(c31);
|
|
4077
|
+
b1.insertBefore(c1);
|
|
4078
|
+
b1.insertBefore(c2);
|
|
4079
|
+
b1.insertBefore(c3);
|
|
4080
|
+
|
|
4081
|
+
const d1 = new SnapshotInstance(s3);
|
|
4082
|
+
c11.insertBefore(d1);
|
|
4083
|
+
|
|
4084
|
+
const d2 = new SnapshotInstance(s3);
|
|
4085
|
+
c21.insertBefore(d2);
|
|
4086
|
+
|
|
4087
|
+
const d3 = new SnapshotInstance(s3);
|
|
4088
|
+
c31.insertBefore(d3);
|
|
4089
|
+
|
|
4090
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
4091
|
+
{
|
|
4092
|
+
"-10": [
|
|
4093
|
+
{
|
|
4094
|
+
"insertAction": [
|
|
4095
|
+
{
|
|
4096
|
+
"position": 0,
|
|
4097
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4098
|
+
},
|
|
4099
|
+
],
|
|
4100
|
+
"removeAction": [],
|
|
4101
|
+
"updateAction": [],
|
|
4102
|
+
},
|
|
4103
|
+
],
|
|
4104
|
+
"-12": [
|
|
4105
|
+
{
|
|
4106
|
+
"insertAction": [
|
|
4107
|
+
{
|
|
4108
|
+
"position": 0,
|
|
4109
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4110
|
+
},
|
|
4111
|
+
],
|
|
4112
|
+
"removeAction": [],
|
|
4113
|
+
"updateAction": [],
|
|
4114
|
+
},
|
|
4115
|
+
],
|
|
4116
|
+
"-14": [
|
|
4117
|
+
{
|
|
4118
|
+
"insertAction": [
|
|
4119
|
+
{
|
|
4120
|
+
"position": 0,
|
|
4121
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4122
|
+
},
|
|
4123
|
+
],
|
|
4124
|
+
"removeAction": [],
|
|
4125
|
+
"updateAction": [],
|
|
4126
|
+
},
|
|
4127
|
+
],
|
|
4128
|
+
"-8": [
|
|
4129
|
+
{
|
|
4130
|
+
"insertAction": [
|
|
4131
|
+
{
|
|
4132
|
+
"position": 0,
|
|
4133
|
+
"type": "__snapshot_a94a8_test_82",
|
|
4134
|
+
},
|
|
4135
|
+
{
|
|
4136
|
+
"position": 1,
|
|
4137
|
+
"type": "__snapshot_a94a8_test_82",
|
|
4138
|
+
},
|
|
4139
|
+
{
|
|
4140
|
+
"position": 2,
|
|
4141
|
+
"type": "__snapshot_a94a8_test_82",
|
|
4142
|
+
},
|
|
4143
|
+
],
|
|
4144
|
+
"removeAction": [],
|
|
4145
|
+
"updateAction": [],
|
|
4146
|
+
},
|
|
4147
|
+
],
|
|
4148
|
+
}
|
|
4149
|
+
`);
|
|
4150
|
+
expect(parentListRef).toMatchInlineSnapshot(`<list />`);
|
|
4151
|
+
|
|
4152
|
+
__pendingListUpdates.flush();
|
|
4153
|
+
// children list should not be cleared
|
|
4154
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
4155
|
+
{
|
|
4156
|
+
"-10": [
|
|
4157
|
+
{
|
|
4158
|
+
"insertAction": [
|
|
4159
|
+
{
|
|
4160
|
+
"position": 0,
|
|
4161
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4162
|
+
},
|
|
4163
|
+
],
|
|
4164
|
+
"removeAction": [],
|
|
4165
|
+
"updateAction": [],
|
|
4166
|
+
},
|
|
4167
|
+
],
|
|
4168
|
+
"-12": [
|
|
4169
|
+
{
|
|
4170
|
+
"insertAction": [
|
|
4171
|
+
{
|
|
4172
|
+
"position": 0,
|
|
4173
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4174
|
+
},
|
|
4175
|
+
],
|
|
4176
|
+
"removeAction": [],
|
|
4177
|
+
"updateAction": [],
|
|
4178
|
+
},
|
|
4179
|
+
],
|
|
4180
|
+
"-14": [
|
|
4181
|
+
{
|
|
4182
|
+
"insertAction": [
|
|
4183
|
+
{
|
|
4184
|
+
"position": 0,
|
|
4185
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4186
|
+
},
|
|
4187
|
+
],
|
|
4188
|
+
"removeAction": [],
|
|
4189
|
+
"updateAction": [],
|
|
4190
|
+
},
|
|
4191
|
+
],
|
|
4192
|
+
}
|
|
4193
|
+
`);
|
|
4194
|
+
|
|
4195
|
+
expect(elementTree.triggerComponentAtIndex(parentListRef, 0)).toMatchInlineSnapshot(`5`);
|
|
4196
|
+
expect(elementTree.triggerComponentAtIndex(parentListRef, 1)).toMatchInlineSnapshot(`10`);
|
|
4197
|
+
expect(elementTree.triggerComponentAtIndex(parentListRef, 2)).toMatchInlineSnapshot(`15`);
|
|
4198
|
+
|
|
4199
|
+
__pendingListUpdates.flush();
|
|
4200
|
+
// all lists should be cleared
|
|
4201
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`{}`);
|
|
4202
|
+
|
|
4203
|
+
const childListRef1 = c11.__elements[0];
|
|
4204
|
+
const childListRef2 = c21.__elements[0];
|
|
4205
|
+
const childListRef3 = c31.__elements[0];
|
|
4206
|
+
expect(elementTree.triggerComponentAtIndex(childListRef1, 0)).toMatchInlineSnapshot(`20`);
|
|
4207
|
+
expect(elementTree.triggerComponentAtIndex(childListRef2, 0)).toMatchInlineSnapshot(`23`);
|
|
4208
|
+
expect(elementTree.triggerComponentAtIndex(childListRef3, 0)).toMatchInlineSnapshot(`26`);
|
|
4209
|
+
|
|
4210
|
+
expect(elementTree).toMatchInlineSnapshot(`
|
|
4211
|
+
"<view>
|
|
4212
|
+
<text>
|
|
4213
|
+
<raw-text
|
|
4214
|
+
text="s1"
|
|
4215
|
+
/>
|
|
4216
|
+
</text>
|
|
4217
|
+
<wrapper>
|
|
4218
|
+
<list
|
|
4219
|
+
update-list-info={
|
|
4220
|
+
Array [
|
|
4221
|
+
Object {
|
|
4222
|
+
"insertAction": Array [
|
|
4223
|
+
Object {
|
|
4224
|
+
"position": 0,
|
|
4225
|
+
"type": "__snapshot_a94a8_test_82",
|
|
4226
|
+
},
|
|
4227
|
+
Object {
|
|
4228
|
+
"position": 1,
|
|
4229
|
+
"type": "__snapshot_a94a8_test_82",
|
|
4230
|
+
},
|
|
4231
|
+
Object {
|
|
4232
|
+
"position": 2,
|
|
4233
|
+
"type": "__snapshot_a94a8_test_82",
|
|
4234
|
+
},
|
|
4235
|
+
],
|
|
4236
|
+
"removeAction": Array [],
|
|
4237
|
+
"updateAction": Array [],
|
|
4238
|
+
},
|
|
4239
|
+
]
|
|
4240
|
+
}
|
|
4241
|
+
>
|
|
4242
|
+
<list-item>
|
|
4243
|
+
<text>
|
|
4244
|
+
<raw-text
|
|
4245
|
+
text="s2"
|
|
4246
|
+
/>
|
|
4247
|
+
</text>
|
|
4248
|
+
<wrapper>
|
|
4249
|
+
<list
|
|
4250
|
+
update-list-info={
|
|
4251
|
+
Array [
|
|
4252
|
+
Object {
|
|
4253
|
+
"insertAction": Array [
|
|
4254
|
+
Object {
|
|
4255
|
+
"position": 0,
|
|
4256
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4257
|
+
},
|
|
4258
|
+
],
|
|
4259
|
+
"removeAction": Array [],
|
|
4260
|
+
"updateAction": Array [],
|
|
4261
|
+
},
|
|
4262
|
+
]
|
|
4263
|
+
}
|
|
4264
|
+
>
|
|
4265
|
+
<list-item>
|
|
4266
|
+
<text>
|
|
4267
|
+
<raw-text
|
|
4268
|
+
text="s3"
|
|
4269
|
+
/>
|
|
4270
|
+
</text>
|
|
4271
|
+
</list-item>
|
|
4272
|
+
</list>
|
|
4273
|
+
</wrapper>
|
|
4274
|
+
</list-item>
|
|
4275
|
+
<list-item>
|
|
4276
|
+
<text>
|
|
4277
|
+
<raw-text
|
|
4278
|
+
text="s2"
|
|
4279
|
+
/>
|
|
4280
|
+
</text>
|
|
4281
|
+
<wrapper>
|
|
4282
|
+
<list
|
|
4283
|
+
update-list-info={
|
|
4284
|
+
Array [
|
|
4285
|
+
Object {
|
|
4286
|
+
"insertAction": Array [
|
|
4287
|
+
Object {
|
|
4288
|
+
"position": 0,
|
|
4289
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4290
|
+
},
|
|
4291
|
+
],
|
|
4292
|
+
"removeAction": Array [],
|
|
4293
|
+
"updateAction": Array [],
|
|
4294
|
+
},
|
|
4295
|
+
]
|
|
4296
|
+
}
|
|
4297
|
+
>
|
|
4298
|
+
<list-item>
|
|
4299
|
+
<text>
|
|
4300
|
+
<raw-text
|
|
4301
|
+
text="s3"
|
|
4302
|
+
/>
|
|
4303
|
+
</text>
|
|
4304
|
+
</list-item>
|
|
4305
|
+
</list>
|
|
4306
|
+
</wrapper>
|
|
4307
|
+
</list-item>
|
|
4308
|
+
<list-item>
|
|
4309
|
+
<text>
|
|
4310
|
+
<raw-text
|
|
4311
|
+
text="s2"
|
|
4312
|
+
/>
|
|
4313
|
+
</text>
|
|
4314
|
+
<wrapper>
|
|
4315
|
+
<list
|
|
4316
|
+
update-list-info={
|
|
4317
|
+
Array [
|
|
4318
|
+
Object {
|
|
4319
|
+
"insertAction": Array [
|
|
4320
|
+
Object {
|
|
4321
|
+
"position": 0,
|
|
4322
|
+
"type": "__snapshot_a94a8_test_84",
|
|
4323
|
+
},
|
|
4324
|
+
],
|
|
4325
|
+
"removeAction": Array [],
|
|
4326
|
+
"updateAction": Array [],
|
|
4327
|
+
},
|
|
4328
|
+
]
|
|
4329
|
+
}
|
|
4330
|
+
>
|
|
4331
|
+
<list-item>
|
|
4332
|
+
<text>
|
|
4333
|
+
<raw-text
|
|
4334
|
+
text="s3"
|
|
4335
|
+
/>
|
|
4336
|
+
</text>
|
|
4337
|
+
</list-item>
|
|
4338
|
+
</list>
|
|
4339
|
+
</wrapper>
|
|
4340
|
+
</list-item>
|
|
4341
|
+
</list>
|
|
4342
|
+
</wrapper>
|
|
4343
|
+
</view>"
|
|
4344
|
+
`);
|
|
4345
|
+
});
|
|
4346
|
+
|
|
4347
|
+
it('should record lazily created nested lists', () => {
|
|
4348
|
+
const s1 = __SNAPSHOT__(
|
|
4349
|
+
<view>
|
|
4350
|
+
<text>s1</text>
|
|
4351
|
+
{HOLE}
|
|
4352
|
+
</view>,
|
|
4353
|
+
);
|
|
4354
|
+
const s11 = __SNAPSHOT__(
|
|
4355
|
+
<list>{HOLE}</list>,
|
|
4356
|
+
);
|
|
4357
|
+
const s2 = __SNAPSHOT__(
|
|
4358
|
+
<list-item>
|
|
4359
|
+
<text>s2</text>
|
|
4360
|
+
{HOLE}
|
|
4361
|
+
</list-item>,
|
|
4362
|
+
);
|
|
4363
|
+
const s21 = __SNAPSHOT__(
|
|
4364
|
+
<list>{HOLE}</list>,
|
|
4365
|
+
);
|
|
4366
|
+
const s3 = __SNAPSHOT__(
|
|
4367
|
+
<list-item>
|
|
4368
|
+
<text>s3</text>
|
|
4369
|
+
</list-item>,
|
|
4370
|
+
);
|
|
4371
|
+
|
|
4372
|
+
const a = new SnapshotInstance(s);
|
|
4373
|
+
const b = new SnapshotInstance(s1);
|
|
4374
|
+
a.insertBefore(b);
|
|
4375
|
+
const b1 = new SnapshotInstance(s11);
|
|
4376
|
+
b.insertBefore(b1);
|
|
4377
|
+
b.ensureElements();
|
|
4378
|
+
const parentListRef = b1.__elements[0];
|
|
4379
|
+
|
|
4380
|
+
const c1 = new SnapshotInstance(s2);
|
|
4381
|
+
const c11 = new SnapshotInstance(s21);
|
|
4382
|
+
c1.insertBefore(c11);
|
|
4383
|
+
const c2 = new SnapshotInstance(s2);
|
|
4384
|
+
const c21 = new SnapshotInstance(s21);
|
|
4385
|
+
c2.insertBefore(c21);
|
|
4386
|
+
const c3 = new SnapshotInstance(s2);
|
|
4387
|
+
const c31 = new SnapshotInstance(s21);
|
|
4388
|
+
c3.insertBefore(c31);
|
|
4389
|
+
b1.insertBefore(c1);
|
|
4390
|
+
b1.insertBefore(c2);
|
|
4391
|
+
b1.insertBefore(c3);
|
|
4392
|
+
|
|
4393
|
+
const d1 = new SnapshotInstance(s3);
|
|
4394
|
+
c11.insertBefore(d1);
|
|
4395
|
+
|
|
4396
|
+
const d2 = new SnapshotInstance(s3);
|
|
4397
|
+
c21.insertBefore(d2);
|
|
4398
|
+
|
|
4399
|
+
const d3 = new SnapshotInstance(s3);
|
|
4400
|
+
c31.insertBefore(d3);
|
|
4401
|
+
__pendingListUpdates.flush();
|
|
4402
|
+
|
|
4403
|
+
expect(__pendingListUpdates.values).toMatchInlineSnapshot(`
|
|
4404
|
+
{
|
|
4405
|
+
"-10": [
|
|
4406
|
+
{
|
|
4407
|
+
"insertAction": [
|
|
4408
|
+
{
|
|
4409
|
+
"position": 0,
|
|
4410
|
+
"type": "__snapshot_a94a8_test_89",
|
|
4411
|
+
},
|
|
4412
|
+
],
|
|
4413
|
+
"removeAction": [],
|
|
4414
|
+
"updateAction": [],
|
|
4415
|
+
},
|
|
4416
|
+
],
|
|
4417
|
+
"-12": [
|
|
4418
|
+
{
|
|
4419
|
+
"insertAction": [
|
|
4420
|
+
{
|
|
4421
|
+
"position": 0,
|
|
4422
|
+
"type": "__snapshot_a94a8_test_89",
|
|
4423
|
+
},
|
|
4424
|
+
],
|
|
4425
|
+
"removeAction": [],
|
|
4426
|
+
"updateAction": [],
|
|
4427
|
+
},
|
|
4428
|
+
],
|
|
4429
|
+
"-14": [
|
|
4430
|
+
{
|
|
4431
|
+
"insertAction": [
|
|
4432
|
+
{
|
|
4433
|
+
"position": 0,
|
|
4434
|
+
"type": "__snapshot_a94a8_test_89",
|
|
4435
|
+
},
|
|
4436
|
+
],
|
|
4437
|
+
"removeAction": [],
|
|
4438
|
+
"updateAction": [],
|
|
4439
|
+
},
|
|
4440
|
+
],
|
|
4441
|
+
}
|
|
4442
|
+
`);
|
|
4443
|
+
|
|
4444
|
+
elementTree.triggerComponentAtIndex(parentListRef, 0);
|
|
4445
|
+
elementTree.triggerComponentAtIndex(parentListRef, 1);
|
|
4446
|
+
// enqueue c1
|
|
4447
|
+
elementTree.triggerEnqueueComponent(parentListRef, 0);
|
|
4448
|
+
// c3 reuse c1
|
|
4449
|
+
elementTree.triggerComponentAtIndex(parentListRef, 2);
|
|
4450
|
+
// c1 re-create
|
|
4451
|
+
elementTree.triggerComponentAtIndex(parentListRef, 0);
|
|
4452
|
+
// should have 4 list-item now
|
|
4453
|
+
expect(parentListRef).toMatchInlineSnapshot(`
|
|
4454
|
+
<list
|
|
4455
|
+
update-list-info={
|
|
4456
|
+
[
|
|
4457
|
+
{
|
|
4458
|
+
"insertAction": [
|
|
4459
|
+
{
|
|
4460
|
+
"position": 0,
|
|
4461
|
+
"type": "__snapshot_a94a8_test_87",
|
|
4462
|
+
},
|
|
4463
|
+
{
|
|
4464
|
+
"position": 1,
|
|
4465
|
+
"type": "__snapshot_a94a8_test_87",
|
|
4466
|
+
},
|
|
4467
|
+
{
|
|
4468
|
+
"position": 2,
|
|
4469
|
+
"type": "__snapshot_a94a8_test_87",
|
|
4470
|
+
},
|
|
4471
|
+
],
|
|
4472
|
+
"removeAction": [],
|
|
4473
|
+
"updateAction": [],
|
|
4474
|
+
},
|
|
4475
|
+
]
|
|
4476
|
+
}
|
|
4477
|
+
>
|
|
4478
|
+
<list-item>
|
|
4479
|
+
<text>
|
|
4480
|
+
<raw-text
|
|
4481
|
+
text="s2"
|
|
4482
|
+
/>
|
|
4483
|
+
</text>
|
|
4484
|
+
<wrapper>
|
|
4485
|
+
<list
|
|
4486
|
+
update-list-info={
|
|
4487
|
+
[
|
|
4488
|
+
{
|
|
4489
|
+
"insertAction": [
|
|
4490
|
+
{
|
|
4491
|
+
"position": 0,
|
|
4492
|
+
"type": "__snapshot_a94a8_test_89",
|
|
4493
|
+
},
|
|
4494
|
+
],
|
|
4495
|
+
"removeAction": [],
|
|
4496
|
+
"updateAction": [],
|
|
4497
|
+
},
|
|
4498
|
+
]
|
|
4499
|
+
}
|
|
4500
|
+
/>
|
|
4501
|
+
</wrapper>
|
|
4502
|
+
</list-item>
|
|
4503
|
+
<list-item>
|
|
4504
|
+
<text>
|
|
4505
|
+
<raw-text
|
|
4506
|
+
text="s2"
|
|
4507
|
+
/>
|
|
4508
|
+
</text>
|
|
4509
|
+
<wrapper>
|
|
4510
|
+
<list
|
|
4511
|
+
update-list-info={
|
|
4512
|
+
[
|
|
4513
|
+
{
|
|
4514
|
+
"insertAction": [
|
|
4515
|
+
{
|
|
4516
|
+
"position": 0,
|
|
4517
|
+
"type": "__snapshot_a94a8_test_89",
|
|
4518
|
+
},
|
|
4519
|
+
],
|
|
4520
|
+
"removeAction": [],
|
|
4521
|
+
"updateAction": [],
|
|
4522
|
+
},
|
|
4523
|
+
]
|
|
4524
|
+
}
|
|
4525
|
+
/>
|
|
4526
|
+
</wrapper>
|
|
4527
|
+
</list-item>
|
|
4528
|
+
<list-item>
|
|
4529
|
+
<text>
|
|
4530
|
+
<raw-text
|
|
4531
|
+
text="s2"
|
|
4532
|
+
/>
|
|
4533
|
+
</text>
|
|
4534
|
+
<wrapper>
|
|
4535
|
+
<list
|
|
4536
|
+
update-list-info={
|
|
4537
|
+
[
|
|
4538
|
+
{
|
|
4539
|
+
"insertAction": [
|
|
4540
|
+
{
|
|
4541
|
+
"position": 0,
|
|
4542
|
+
"type": "__snapshot_a94a8_test_89",
|
|
4543
|
+
},
|
|
4544
|
+
],
|
|
4545
|
+
"removeAction": [],
|
|
4546
|
+
"updateAction": [],
|
|
4547
|
+
},
|
|
4548
|
+
]
|
|
4549
|
+
}
|
|
4550
|
+
/>
|
|
4551
|
+
</wrapper>
|
|
4552
|
+
</list-item>
|
|
4553
|
+
<list-item>
|
|
4554
|
+
<text>
|
|
4555
|
+
<raw-text
|
|
4556
|
+
text="s2"
|
|
4557
|
+
/>
|
|
4558
|
+
</text>
|
|
4559
|
+
<wrapper>
|
|
4560
|
+
<list
|
|
4561
|
+
update-list-info={
|
|
4562
|
+
[
|
|
4563
|
+
{
|
|
4564
|
+
"insertAction": [
|
|
4565
|
+
{
|
|
4566
|
+
"position": 0,
|
|
4567
|
+
"type": "__snapshot_a94a8_test_89",
|
|
4568
|
+
},
|
|
4569
|
+
],
|
|
4570
|
+
"removeAction": [
|
|
4571
|
+
0,
|
|
4572
|
+
],
|
|
4573
|
+
"updateAction": [],
|
|
4574
|
+
},
|
|
4575
|
+
]
|
|
4576
|
+
}
|
|
4577
|
+
/>
|
|
4578
|
+
</wrapper>
|
|
4579
|
+
</list-item>
|
|
4580
|
+
</list>
|
|
4581
|
+
`);
|
|
4582
|
+
});
|
|
4583
|
+
|
|
4584
|
+
it('should clear attached lists & should flush during ensureElements', () => {
|
|
4585
|
+
const s1 = __SNAPSHOT__(
|
|
4586
|
+
<view>
|
|
4587
|
+
<text>s1</text>
|
|
4588
|
+
{HOLE}
|
|
4589
|
+
</view>,
|
|
4590
|
+
);
|
|
4591
|
+
const s11 = __SNAPSHOT__(
|
|
4592
|
+
<list>{HOLE}</list>,
|
|
4593
|
+
);
|
|
4594
|
+
const s2 = __SNAPSHOT__(
|
|
4595
|
+
<list-item>
|
|
4596
|
+
<text>s2</text>
|
|
4597
|
+
{HOLE}
|
|
4598
|
+
</list-item>,
|
|
4599
|
+
);
|
|
4600
|
+
const s21 = __SNAPSHOT__(
|
|
4601
|
+
<list>{HOLE}</list>,
|
|
4602
|
+
);
|
|
4603
|
+
const s3 = __SNAPSHOT__(
|
|
4604
|
+
<list-item>
|
|
4605
|
+
<text>s3</text>
|
|
4606
|
+
</list-item>,
|
|
4607
|
+
);
|
|
4608
|
+
|
|
4609
|
+
const a = new SnapshotInstance(s);
|
|
4610
|
+
|
|
4611
|
+
const b = new SnapshotInstance(s1);
|
|
4612
|
+
a.insertBefore(b);
|
|
4613
|
+
b.ensureElements();
|
|
4614
|
+
const b1 = new SnapshotInstance(s11);
|
|
4615
|
+
b.insertBefore(b1);
|
|
4616
|
+
|
|
4617
|
+
const c1 = new SnapshotInstance(s2);
|
|
4618
|
+
const c11 = new SnapshotInstance(s21);
|
|
4619
|
+
c1.insertBefore(c11);
|
|
4620
|
+
const c2 = new SnapshotInstance(s2);
|
|
4621
|
+
const c21 = new SnapshotInstance(s21);
|
|
4622
|
+
c2.insertBefore(c21);
|
|
4623
|
+
const c3 = new SnapshotInstance(s2);
|
|
4624
|
+
const c31 = new SnapshotInstance(s21);
|
|
4625
|
+
c3.insertBefore(c31);
|
|
4626
|
+
b1.insertBefore(c1);
|
|
4627
|
+
b1.insertBefore(c2);
|
|
4628
|
+
b1.insertBefore(c3);
|
|
4629
|
+
|
|
4630
|
+
const d1 = new SnapshotInstance(s3);
|
|
4631
|
+
c11.insertBefore(d1);
|
|
4632
|
+
|
|
4633
|
+
const d2 = new SnapshotInstance(s3);
|
|
4634
|
+
c21.insertBefore(d2);
|
|
4635
|
+
|
|
4636
|
+
const d3 = new SnapshotInstance(s3);
|
|
4637
|
+
c31.insertBefore(d3);
|
|
4638
|
+
|
|
4639
|
+
expect(Object.keys(__pendingListUpdates.values).length).toBe(4);
|
|
4640
|
+
|
|
4641
|
+
__pendingListUpdates.clearAttachedLists();
|
|
4642
|
+
// should only clear the parent list
|
|
4643
|
+
expect(Object.keys(__pendingListUpdates.values).length).toBe(3);
|
|
4644
|
+
|
|
4645
|
+
// list-item will recursively ensureElements
|
|
4646
|
+
// if a list-item contains a nested list as its child,
|
|
4647
|
+
// that nested list should be flushed during ensureElements
|
|
4648
|
+
c1.ensureElements();
|
|
4649
|
+
expect(Object.keys(__pendingListUpdates.values).length).toBe(2);
|
|
4650
|
+
});
|
|
4651
|
+
});
|
|
4652
|
+
|
|
4653
|
+
describe('update-list-info diagnostics', () => {
|
|
4654
|
+
const s1 = __SNAPSHOT__(
|
|
4655
|
+
<view>
|
|
4656
|
+
<text>111</text>
|
|
4657
|
+
{HOLE}
|
|
4658
|
+
</view>,
|
|
4659
|
+
);
|
|
4660
|
+
const s11 = __SNAPSHOT__(
|
|
4661
|
+
<list>{HOLE}</list>,
|
|
4662
|
+
);
|
|
4663
|
+
|
|
4664
|
+
function createEmptyListHydrationPair() {
|
|
4665
|
+
const before = new SnapshotInstance(s1);
|
|
4666
|
+
before.ensureElements();
|
|
4667
|
+
const beforeList = new SnapshotInstance(s11);
|
|
4668
|
+
beforeList.__slotIndex = 0;
|
|
4669
|
+
before.insertBefore(beforeList);
|
|
4670
|
+
__pendingListUpdates.flush();
|
|
4671
|
+
|
|
4672
|
+
const after = new SnapshotInstance(s1);
|
|
4673
|
+
const afterList = new SnapshotInstance(s11);
|
|
4674
|
+
afterList.__slotIndex = 0;
|
|
4675
|
+
after.insertBefore(afterList);
|
|
4676
|
+
|
|
4677
|
+
return { after, before };
|
|
4678
|
+
}
|
|
4679
|
+
|
|
4680
|
+
it('flush & hydrate', () => {
|
|
4681
|
+
const b = new SnapshotInstance(s1);
|
|
4682
|
+
b.ensureElements();
|
|
4683
|
+
const b1 = new SnapshotInstance(s11);
|
|
4684
|
+
b1.__slotIndex = 0;
|
|
4685
|
+
b.insertBefore(b1);
|
|
4686
|
+
|
|
4687
|
+
const s3 = __SNAPSHOT__(
|
|
4688
|
+
<list-item item-key={HOLE}>
|
|
4689
|
+
<text>World</text>
|
|
4690
|
+
</list-item>,
|
|
4691
|
+
);
|
|
4692
|
+
|
|
4693
|
+
const d1 = new SnapshotInstance(s3);
|
|
4694
|
+
d1.__slotIndex = 0;
|
|
4695
|
+
const d2 = new SnapshotInstance(s3);
|
|
4696
|
+
d2.__slotIndex = 0;
|
|
4697
|
+
const d3 = new SnapshotInstance(s3);
|
|
4698
|
+
d3.__slotIndex = 0;
|
|
4699
|
+
|
|
4700
|
+
b1.insertBefore(d1);
|
|
4701
|
+
b1.insertBefore(d2);
|
|
4702
|
+
b1.insertBefore(d3);
|
|
4703
|
+
|
|
4704
|
+
console.alog.mockClear();
|
|
4705
|
+
__pendingListUpdates.flush();
|
|
4706
|
+
|
|
4707
|
+
const bb = new SnapshotInstance(s1);
|
|
4708
|
+
const bb1 = new SnapshotInstance(s11);
|
|
4709
|
+
bb1.__slotIndex = 0;
|
|
4710
|
+
bb.insertBefore(bb1);
|
|
4711
|
+
{
|
|
4712
|
+
const d1 = new SnapshotInstance(s3);
|
|
4713
|
+
d1.__slotIndex = 0;
|
|
4714
|
+
const d2 = new SnapshotInstance(s3);
|
|
4715
|
+
d2.__slotIndex = 0;
|
|
4716
|
+
bb1.insertBefore(d1);
|
|
4717
|
+
bb1.insertBefore(d2);
|
|
4718
|
+
}
|
|
4719
|
+
|
|
4720
|
+
hydrate(b, bb);
|
|
4721
|
+
|
|
4722
|
+
expect(lynx.performance.profileStart).toHaveBeenCalled();
|
|
4723
|
+
expect(lynx.performance.profileStart.mock.calls).toMatchInlineSnapshot(`
|
|
4724
|
+
[
|
|
4725
|
+
[
|
|
4726
|
+
"ReactLynx::listFlush::updateListInfo",
|
|
4727
|
+
{
|
|
4728
|
+
"args": {
|
|
4729
|
+
"list id": "4",
|
|
4730
|
+
"update list info": "{"insertAction":[{"position":0,"type":"__snapshot_a94a8_test_97"},{"position":1,"type":"__snapshot_a94a8_test_97"},{"position":2,"type":"__snapshot_a94a8_test_97"}],"removeAction":[],"updateAction":[]}",
|
|
4731
|
+
},
|
|
4732
|
+
},
|
|
4733
|
+
],
|
|
4734
|
+
[
|
|
4735
|
+
"ReactLynx::listHydrate::updateListInfo",
|
|
4736
|
+
{
|
|
4737
|
+
"args": {
|
|
4738
|
+
"list id": "4",
|
|
4739
|
+
"update list info": "{"insertAction":[],"removeAction":[2],"updateAction":[]}",
|
|
4740
|
+
},
|
|
4741
|
+
},
|
|
4742
|
+
],
|
|
4743
|
+
]
|
|
4744
|
+
`);
|
|
4745
|
+
|
|
4746
|
+
expect(console.alog).toHaveBeenCalledTimes(2);
|
|
4747
|
+
const flushAlogPrefix = '[ReactLynxDebug] ReactLynx::listFlush::updateListInfo:\n';
|
|
4748
|
+
const flushAlogMessage = console.alog.mock.calls[0][0];
|
|
4749
|
+
expect(flushAlogMessage.startsWith(flushAlogPrefix)).toBe(true);
|
|
4750
|
+
expect(JSON.parse(flushAlogMessage.slice(flushAlogPrefix.length))).toEqual({
|
|
4751
|
+
listID: 4,
|
|
4752
|
+
updateListInfo: {
|
|
4753
|
+
insertAction: [
|
|
4754
|
+
{ position: 0, type: s3 },
|
|
4755
|
+
{ position: 1, type: s3 },
|
|
4756
|
+
{ position: 2, type: s3 },
|
|
4757
|
+
],
|
|
4758
|
+
removeAction: [],
|
|
4759
|
+
updateAction: [],
|
|
4760
|
+
},
|
|
4761
|
+
});
|
|
4762
|
+
|
|
4763
|
+
const hydrateAlogPrefix = '[ReactLynxDebug] ReactLynx::listHydrate::updateListInfo:\n';
|
|
4764
|
+
const hydrateAlogMessage = console.alog.mock.calls[1][0];
|
|
4765
|
+
expect(hydrateAlogMessage.startsWith(hydrateAlogPrefix)).toBe(true);
|
|
4766
|
+
expect(JSON.parse(hydrateAlogMessage.slice(hydrateAlogPrefix.length))).toEqual({
|
|
4767
|
+
listID: 4,
|
|
4768
|
+
updateListInfo: {
|
|
4769
|
+
insertAction: [],
|
|
4770
|
+
removeAction: [2],
|
|
4771
|
+
updateAction: [],
|
|
4772
|
+
},
|
|
4773
|
+
});
|
|
4774
|
+
});
|
|
4775
|
+
|
|
4776
|
+
it('skips alog when disabled or undefined', () => {
|
|
4777
|
+
const originalAlogFlag = globalThis.__ALOG__;
|
|
4778
|
+
try {
|
|
4779
|
+
for (const alogFlag of [false, undefined]) {
|
|
4780
|
+
globalThis.__ALOG__ = alogFlag;
|
|
4781
|
+
console.alog.mockClear();
|
|
4782
|
+
const { after, before } = createEmptyListHydrationPair();
|
|
4783
|
+
|
|
4784
|
+
hydrate(before, after);
|
|
4785
|
+
|
|
4786
|
+
expect(console.alog).not.toHaveBeenCalled();
|
|
4787
|
+
}
|
|
4788
|
+
} finally {
|
|
4789
|
+
globalThis.__ALOG__ = originalAlogFlag;
|
|
4790
|
+
}
|
|
4791
|
+
});
|
|
4792
|
+
|
|
4793
|
+
it('keeps alog optional', () => {
|
|
4794
|
+
const originalAlog = console.alog;
|
|
4795
|
+
console.alog = undefined;
|
|
4796
|
+
try {
|
|
4797
|
+
const { after, before } = createEmptyListHydrationPair();
|
|
4798
|
+
expect(() => hydrate(before, after)).not.toThrow();
|
|
4799
|
+
} finally {
|
|
4800
|
+
console.alog = originalAlog;
|
|
4801
|
+
}
|
|
4802
|
+
});
|
|
4803
|
+
});
|
|
4804
|
+
|
|
4805
|
+
describe('clear __UpdateListCallbacks', () => {
|
|
4806
|
+
it('should register __DestroyLifetime listener and clear callbacks when triggered', () => {
|
|
4807
|
+
const s1 = __SNAPSHOT__(
|
|
4808
|
+
<view>
|
|
4809
|
+
<text>test</text>
|
|
4810
|
+
{HOLE}
|
|
4811
|
+
</view>,
|
|
4812
|
+
);
|
|
4813
|
+
const s11 = __SNAPSHOT__(
|
|
4814
|
+
<list>{HOLE}</list>,
|
|
4815
|
+
);
|
|
4816
|
+
|
|
4817
|
+
const a = new SnapshotInstance(s1);
|
|
4818
|
+
a.ensureElements();
|
|
4819
|
+
const a1 = new SnapshotInstance(s11);
|
|
4820
|
+
a1.__slotIndex = 0;
|
|
4821
|
+
a.insertBefore(a1);
|
|
4822
|
+
|
|
4823
|
+
expect(lynx.getNative().addEventListener).toHaveBeenCalledWith(
|
|
4824
|
+
'__DestroyLifetime',
|
|
4825
|
+
expect.any(Function),
|
|
4826
|
+
);
|
|
4827
|
+
|
|
4828
|
+
const listElement = a1.__elements[0];
|
|
4829
|
+
expect(listElement.componentAtIndex).not.toBeNull();
|
|
4830
|
+
expect(listElement.enqueueComponent).not.toBeNull();
|
|
4831
|
+
expect(listElement.componentAtIndexes).not.toBeNull();
|
|
4832
|
+
|
|
4833
|
+
lynx.getNative().dispatchEvent({ type: '__DestroyLifetime', data: {} });
|
|
4834
|
+
|
|
4835
|
+
expect(listElement.componentAtIndex).toBeNull();
|
|
4836
|
+
expect(listElement.enqueueComponent).toBeNull();
|
|
4837
|
+
expect(listElement.componentAtIndexes).toBeNull();
|
|
4838
|
+
});
|
|
4839
|
+
|
|
4840
|
+
it('should remove __DestroyLifetime listener when list is destroyed via removeChild', () => {
|
|
4841
|
+
const s0 = __SNAPSHOT__(
|
|
4842
|
+
<view>
|
|
4843
|
+
{HOLE}
|
|
4844
|
+
</view>,
|
|
4845
|
+
);
|
|
4846
|
+
const s1 = __SNAPSHOT__(
|
|
4847
|
+
<view>
|
|
4848
|
+
<text>test</text>
|
|
4849
|
+
{HOLE}
|
|
4850
|
+
</view>,
|
|
4851
|
+
);
|
|
4852
|
+
const s11 = __SNAPSHOT__(
|
|
4853
|
+
<list>{HOLE}</list>,
|
|
4854
|
+
);
|
|
4855
|
+
|
|
4856
|
+
const root = new SnapshotInstance(s0);
|
|
4857
|
+
root.ensureElements();
|
|
4858
|
+
|
|
4859
|
+
const a = new SnapshotInstance(s1);
|
|
4860
|
+
root.insertBefore(a);
|
|
4861
|
+
const a1 = new SnapshotInstance(s11);
|
|
4862
|
+
a1.__slotIndex = 0;
|
|
4863
|
+
a.insertBefore(a1);
|
|
4864
|
+
|
|
4865
|
+
expect(lynx.getNative().addEventListener).toHaveBeenCalledWith(
|
|
4866
|
+
'__DestroyLifetime',
|
|
4867
|
+
expect.any(Function),
|
|
4868
|
+
);
|
|
4869
|
+
|
|
4870
|
+
const listElement = a1.__elements[0];
|
|
4871
|
+
expect(listElement.componentAtIndex).not.toBeNull();
|
|
4872
|
+
expect(listElement.enqueueComponent).not.toBeNull();
|
|
4873
|
+
expect(listElement.componentAtIndexes).not.toBeNull();
|
|
4874
|
+
|
|
4875
|
+
root.removeChild(a);
|
|
4876
|
+
|
|
4877
|
+
expect(lynx.getNative().removeEventListener).toHaveBeenCalledWith(
|
|
4878
|
+
'__DestroyLifetime',
|
|
4879
|
+
expect.any(Function),
|
|
4880
|
+
);
|
|
4881
|
+
|
|
4882
|
+
expect(listElement.componentAtIndex()).toBe(-1);
|
|
4883
|
+
expect(listElement.enqueueComponent()).toBeUndefined();
|
|
4884
|
+
expect(listElement.componentAtIndexes()).toBeUndefined();
|
|
4885
|
+
});
|
|
4886
|
+
});
|
|
4887
|
+
|
|
4888
|
+
describe('destroy list after element transfer', () => {
|
|
4889
|
+
it('does not destroy a list after its elements are transferred', () => {
|
|
4890
|
+
const parentSnapshot = __SNAPSHOT__(<view>{HOLE}</view>);
|
|
4891
|
+
const childSnapshot = __SNAPSHOT__(<view>{HOLE}</view>);
|
|
4892
|
+
const listSnapshot = __SNAPSHOT__(<list>{HOLE}</list>);
|
|
4893
|
+
|
|
4894
|
+
const parent = new SnapshotInstance(parentSnapshot, 101);
|
|
4895
|
+
const child = new SnapshotInstance(childSnapshot, 102);
|
|
4896
|
+
const list = new SnapshotInstance(listSnapshot, 103);
|
|
4897
|
+
parent.ensureElements();
|
|
4898
|
+
parent.insertBefore(child);
|
|
4899
|
+
child.insertBefore(list);
|
|
4900
|
+
|
|
4901
|
+
const listElement = list.__elements[0];
|
|
4902
|
+
const listID = __GetElementUniqueID(listElement);
|
|
4903
|
+
|
|
4904
|
+
const renderedOwner = parent.takeElements();
|
|
4905
|
+
const transferredChild = renderedOwner.childNodes[0];
|
|
4906
|
+
const transferredList = transferredChild.childNodes[0];
|
|
4907
|
+
|
|
4908
|
+
expect(list.__elements).toBeUndefined();
|
|
4909
|
+
expect(transferredList.__elements[0]).toBe(listElement);
|
|
4910
|
+
expect(() => parent.removeChild(child)).not.toThrow();
|
|
4911
|
+
expect(gSignMap[listID]).toBeDefined();
|
|
4912
|
+
expect(gRecycleMap[listID]).toBeDefined();
|
|
4913
|
+
|
|
4914
|
+
renderedOwner.removeChild(transferredChild);
|
|
4915
|
+
expect(gSignMap[listID]).toBeUndefined();
|
|
4916
|
+
expect(gRecycleMap[listID]).toBeUndefined();
|
|
4917
|
+
});
|
|
4918
|
+
});
|
|
4919
|
+
|
|
4920
|
+
describe('list worklet ref lifecycle', () => {
|
|
4921
|
+
it('unrefs worklet refs when a list child is logically removed', () => {
|
|
4922
|
+
const listSnapshot = __SNAPSHOT__(<list>{HOLE}</list>);
|
|
4923
|
+
const itemSnapshot = __SNAPSHOT__(<list-item />);
|
|
4924
|
+
const list = new SnapshotInstance(listSnapshot);
|
|
4925
|
+
const item = new SnapshotInstance(itemSnapshot);
|
|
4926
|
+
const replacement = new SnapshotInstance(itemSnapshot);
|
|
4927
|
+
const workletRef = { _wvid: 1 };
|
|
4928
|
+
const updateWorkletRef = vi.fn();
|
|
4929
|
+
const previousWorkletImpl = globalThis.lynxWorkletImpl;
|
|
4930
|
+
|
|
4931
|
+
globalThis.lynxWorkletImpl = {
|
|
4932
|
+
...previousWorkletImpl,
|
|
4933
|
+
_refImpl: {
|
|
4934
|
+
...previousWorkletImpl?._refImpl,
|
|
4935
|
+
updateWorkletRef,
|
|
4936
|
+
},
|
|
4937
|
+
};
|
|
4938
|
+
|
|
4939
|
+
try {
|
|
4940
|
+
item.__worklet_ref_set = new Set([workletRef]);
|
|
4941
|
+
__pendingListUpdates.runWithoutUpdates(() => {
|
|
4942
|
+
list.insertBefore(item);
|
|
4943
|
+
list.removeChild(item);
|
|
4944
|
+
});
|
|
4945
|
+
|
|
4946
|
+
expect(updateWorkletRef).toHaveBeenCalledTimes(1);
|
|
4947
|
+
expect(updateWorkletRef).toHaveBeenCalledWith(workletRef, null);
|
|
4948
|
+
|
|
4949
|
+
// A recycled native element may still be hydrated later.
|
|
4950
|
+
hydrate(item, replacement);
|
|
4951
|
+
expect(updateWorkletRef).toHaveBeenCalledTimes(1);
|
|
4952
|
+
} finally {
|
|
4953
|
+
globalThis.lynxWorkletImpl = previousWorkletImpl;
|
|
4954
|
+
}
|
|
4955
|
+
});
|
|
4956
|
+
});
|