@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,3495 @@
|
|
|
1
|
+
use serde::Deserialize;
|
|
2
|
+
use std::{
|
|
3
|
+
cell::RefCell,
|
|
4
|
+
collections::{HashMap, HashSet},
|
|
5
|
+
rc::Rc,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
use once_cell::sync::Lazy;
|
|
9
|
+
use swc_core::{
|
|
10
|
+
common::{
|
|
11
|
+
comments::{CommentKind, Comments},
|
|
12
|
+
errors::HANDLER,
|
|
13
|
+
sync::Lrc,
|
|
14
|
+
util::take::Take,
|
|
15
|
+
Mark, SourceMap, Span, Spanned, SyntaxContext, DUMMY_SP,
|
|
16
|
+
},
|
|
17
|
+
ecma::{
|
|
18
|
+
ast::{JSXExpr, *},
|
|
19
|
+
utils::{is_literal, prepend_stmt, private_ident},
|
|
20
|
+
visit::{VisitMut, VisitMutWith},
|
|
21
|
+
},
|
|
22
|
+
quote, quote_expr,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
mod attr_name;
|
|
26
|
+
mod legacy_slot;
|
|
27
|
+
|
|
28
|
+
#[cfg(feature = "napi")]
|
|
29
|
+
pub mod napi;
|
|
30
|
+
|
|
31
|
+
use swc_plugins_shared::{
|
|
32
|
+
css::get_string_inline_style_from_literal,
|
|
33
|
+
defines::{collect_define, DefineKind, DefinesCollector},
|
|
34
|
+
jsx_helpers::{
|
|
35
|
+
jsx_attr_name, jsx_attr_to_prop, jsx_attr_value, jsx_children_to_expr, jsx_has_dynamic_key,
|
|
36
|
+
jsx_is_children_full_dynamic, jsx_is_custom, jsx_is_list, jsx_is_list_item, jsx_name,
|
|
37
|
+
jsx_props_to_obj, jsx_text_to_str, transform_jsx_attr_str,
|
|
38
|
+
},
|
|
39
|
+
target::TransformTarget,
|
|
40
|
+
transform_mode::TransformMode,
|
|
41
|
+
utils::{calc_hash, calc_hash_number},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
use self::attr_name::AttrName;
|
|
45
|
+
|
|
46
|
+
// impl From<i32> for Expr {
|
|
47
|
+
// fn from(value: i32) -> Self {
|
|
48
|
+
// Expr::Lit(Lit::Num(Number {
|
|
49
|
+
// span: DUMMY_SP,
|
|
50
|
+
// value: value as f64,
|
|
51
|
+
// raw: None,
|
|
52
|
+
// }))
|
|
53
|
+
// }
|
|
54
|
+
// }
|
|
55
|
+
|
|
56
|
+
static WRAPPER_NODE: Lazy<JSXElement> = Lazy::new(|| JSXElement {
|
|
57
|
+
span: DUMMY_SP,
|
|
58
|
+
opening: JSXOpeningElement {
|
|
59
|
+
span: DUMMY_SP,
|
|
60
|
+
name: JSXElementName::Ident(Ident::new(
|
|
61
|
+
"wrapper".into(),
|
|
62
|
+
DUMMY_SP,
|
|
63
|
+
SyntaxContext::default(),
|
|
64
|
+
)),
|
|
65
|
+
attrs: vec![],
|
|
66
|
+
self_closing: true,
|
|
67
|
+
type_args: None,
|
|
68
|
+
},
|
|
69
|
+
closing: None,
|
|
70
|
+
children: vec![],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
static WRAPPER_NODE_2: Lazy<JSXElement> = Lazy::new(|| JSXElement {
|
|
74
|
+
span: DUMMY_SP,
|
|
75
|
+
opening: JSXOpeningElement {
|
|
76
|
+
span: DUMMY_SP,
|
|
77
|
+
name: JSXElementName::Ident(Ident::new(
|
|
78
|
+
"wrapper".into(),
|
|
79
|
+
DUMMY_SP,
|
|
80
|
+
SyntaxContext::default(),
|
|
81
|
+
)),
|
|
82
|
+
attrs: vec![],
|
|
83
|
+
self_closing: false,
|
|
84
|
+
type_args: None,
|
|
85
|
+
},
|
|
86
|
+
closing: Some(JSXClosingElement {
|
|
87
|
+
span: DUMMY_SP,
|
|
88
|
+
name: JSXElementName::Ident(Ident::new(
|
|
89
|
+
"wrapper".into(),
|
|
90
|
+
DUMMY_SP,
|
|
91
|
+
SyntaxContext::default(),
|
|
92
|
+
)),
|
|
93
|
+
}),
|
|
94
|
+
children: vec![],
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
static NO_FLATTEN_ATTRIBUTES: Lazy<HashSet<String>> = Lazy::new(|| {
|
|
98
|
+
HashSet::from([
|
|
99
|
+
"name".to_string(),
|
|
100
|
+
"clip-radius".to_string(),
|
|
101
|
+
"overlap".to_string(),
|
|
102
|
+
"exposure-scene".to_string(),
|
|
103
|
+
"exposure-id".to_string(),
|
|
104
|
+
])
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
#[derive(Clone, Debug, Deserialize)]
|
|
108
|
+
pub struct UISourceMapRecord {
|
|
109
|
+
pub ui_source_map: i32,
|
|
110
|
+
pub line_number: u32,
|
|
111
|
+
pub column_number: u32,
|
|
112
|
+
pub snapshot_id: String,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#[derive(Debug)]
|
|
116
|
+
pub enum DynamicPart {
|
|
117
|
+
Attr(Expr, i32, AttrName),
|
|
118
|
+
Spread(Expr, i32, bool),
|
|
119
|
+
Slot(Expr, i32),
|
|
120
|
+
ListSlot(Expr, i32),
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
pub fn i32_to_expr(i: &i32) -> Expr {
|
|
124
|
+
Expr::Lit(Lit::Num(Number {
|
|
125
|
+
span: DUMMY_SP,
|
|
126
|
+
value: *i as f64,
|
|
127
|
+
raw: None,
|
|
128
|
+
}))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
pub fn bool_to_expr(b: &bool) -> Expr {
|
|
132
|
+
Expr::Lit(Lit::Bool(Bool {
|
|
133
|
+
span: DUMMY_SP,
|
|
134
|
+
value: *b,
|
|
135
|
+
}))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
fn bool_jsx_attr(value: bool) -> JSXAttrValue {
|
|
139
|
+
JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
140
|
+
span: DUMMY_SP,
|
|
141
|
+
expr: JSXExpr::Expr(Box::new(Expr::Lit(Lit::Bool(Bool {
|
|
142
|
+
span: DUMMY_SP,
|
|
143
|
+
value,
|
|
144
|
+
})))),
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
impl DynamicPart {
|
|
149
|
+
fn to_updater(&self, runtime_id: Expr, target: TransformTarget, exp_index: i32) -> Expr {
|
|
150
|
+
match target {
|
|
151
|
+
TransformTarget::LEPUS | TransformTarget::MIXED => match self {
|
|
152
|
+
DynamicPart::Attr(_, element_index, attr_name) => match attr_name {
|
|
153
|
+
AttrName::Attr(name) => quote!(
|
|
154
|
+
"function (ctx) {
|
|
155
|
+
if (ctx.__elements) {
|
|
156
|
+
__SetAttribute(ctx.__elements[$element_index], $name, ctx.__values[$exp_index]);
|
|
157
|
+
}
|
|
158
|
+
}" as Expr,
|
|
159
|
+
name: Expr = Expr::Lit(Lit::Str(name.clone().into())),
|
|
160
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
161
|
+
exp_index: Expr = i32_to_expr(&exp_index),
|
|
162
|
+
),
|
|
163
|
+
AttrName::TimingFlag => quote!(
|
|
164
|
+
"function (ctx) {
|
|
165
|
+
if (ctx.__elements) {
|
|
166
|
+
__SetAttribute(ctx.__elements[$element_index], '__lynx_timing_flag', ctx.__values[$exp_index].__ltf);
|
|
167
|
+
}
|
|
168
|
+
}" as Expr,
|
|
169
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
170
|
+
exp_index: Expr = i32_to_expr(&exp_index),
|
|
171
|
+
),
|
|
172
|
+
AttrName::Dataset(name) => quote!(
|
|
173
|
+
"function (ctx) {
|
|
174
|
+
if (ctx.__elements) {
|
|
175
|
+
__AddDataset(ctx.__elements[$element_index], $name, ctx.__values[$exp_index]);
|
|
176
|
+
}
|
|
177
|
+
}" as Expr,
|
|
178
|
+
name: Expr = Expr::Lit(Lit::Str(name.clone().into())),
|
|
179
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
180
|
+
exp_index: Expr = i32_to_expr(&exp_index),
|
|
181
|
+
),
|
|
182
|
+
AttrName::Style => quote!(
|
|
183
|
+
"function (ctx) {
|
|
184
|
+
if (ctx.__elements) {
|
|
185
|
+
__SetInlineStyles(ctx.__elements[$element_index], ctx.__values[$exp_index]);
|
|
186
|
+
}
|
|
187
|
+
}" as Expr,
|
|
188
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
189
|
+
exp_index: Expr = i32_to_expr(&exp_index),
|
|
190
|
+
),
|
|
191
|
+
AttrName::Class => quote!(
|
|
192
|
+
"function (ctx) {
|
|
193
|
+
if (ctx.__elements) {
|
|
194
|
+
__SetClasses(ctx.__elements[$element_index], ctx.__values[$exp_index] || '');
|
|
195
|
+
}
|
|
196
|
+
}" as Expr,
|
|
197
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
198
|
+
exp_index: Expr = i32_to_expr(&exp_index),
|
|
199
|
+
),
|
|
200
|
+
AttrName::ID => quote!(
|
|
201
|
+
"function (ctx) {
|
|
202
|
+
if (ctx.__elements) {
|
|
203
|
+
__SetID(ctx.__elements[$element_index], ctx.__values[$exp_index]);
|
|
204
|
+
}
|
|
205
|
+
}" as Expr,
|
|
206
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
207
|
+
exp_index: Expr = i32_to_expr(&exp_index),
|
|
208
|
+
),
|
|
209
|
+
AttrName::Event(event_type, event_name) => quote!(
|
|
210
|
+
"(snapshot, index, oldValue) => $runtime_id.updateEvent(snapshot, index, oldValue, $element_index, $event_type, $event_name, '')" as Expr,
|
|
211
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
212
|
+
event_type: Expr = Expr::Lit(Lit::Str(event_type.clone().into())),
|
|
213
|
+
event_name: Expr = Expr::Lit(Lit::Str(event_name.clone().into())),
|
|
214
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
215
|
+
),
|
|
216
|
+
AttrName::WorkletEvent(worklet_type, event_type, event_name) => quote!(
|
|
217
|
+
"(snapshot, index, oldValue) => $runtime_id.updateWorkletEvent(snapshot, index, oldValue, $element_index, $worklet_type, $event_type, $event_name)" as Expr,
|
|
218
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
219
|
+
worklet_type: Expr = Expr::Lit(Lit::Str(worklet_type.clone().into())),
|
|
220
|
+
event_type: Expr = Expr::Lit(Lit::Str(event_type.clone().into())),
|
|
221
|
+
event_name: Expr = Expr::Lit(Lit::Str(event_name.clone().into())),
|
|
222
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
223
|
+
),
|
|
224
|
+
AttrName::Ref => quote!(
|
|
225
|
+
"(snapshot, index, oldValue) => $runtime_id.updateRef(snapshot, index, oldValue, $element_index)" as Expr,
|
|
226
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
227
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
228
|
+
),
|
|
229
|
+
AttrName::WorkletRef(worklet_type) => quote!(
|
|
230
|
+
"(snapshot, index, oldValue) => $runtime_id.updateWorkletRef(snapshot, index, oldValue, $element_index, $worklet_type)" as Expr,
|
|
231
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
232
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
233
|
+
worklet_type: Expr = Expr::Lit(Lit::Str(worklet_type.clone().into())),
|
|
234
|
+
),
|
|
235
|
+
AttrName::ListItemPlatformInfo => quote!(
|
|
236
|
+
"(snapshot, index, oldValue) => $runtime_id.updateListItemPlatformInfo(snapshot, index, oldValue, $element_index)" as Expr,
|
|
237
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
238
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
239
|
+
),
|
|
240
|
+
AttrName::Gesture(ns) => quote!(
|
|
241
|
+
"(snapshot, index, oldValue) => $runtime_id.updateGesture(snapshot, index, oldValue, $element_index, $ns)" as Expr,
|
|
242
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
243
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
244
|
+
ns: Expr = Expr::Lit(Lit::Str(ns.clone().into())),
|
|
245
|
+
),
|
|
246
|
+
},
|
|
247
|
+
DynamicPart::Spread(_, element_index, is_list_item) => quote!(
|
|
248
|
+
"(snapshot, index, oldValue) => $runtime_id.updateSpread(snapshot, index, oldValue, $element_index, $is_list_item)" as Expr,
|
|
249
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
250
|
+
element_index: Expr = i32_to_expr(element_index),
|
|
251
|
+
is_list_item: Expr = bool_to_expr(is_list_item)
|
|
252
|
+
),
|
|
253
|
+
DynamicPart::Slot(_, _) => Expr::Lit(Lit::Null(Null { span: DUMMY_SP })),
|
|
254
|
+
DynamicPart::ListSlot(_, _) => Expr::Lit(Lit::Null(Null { span: DUMMY_SP })),
|
|
255
|
+
},
|
|
256
|
+
TransformTarget::JS => Expr::Lit(Lit::Null(Null { span: DUMMY_SP })),
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
pub struct DynamicPartExtractor<'a, V, F>
|
|
262
|
+
where
|
|
263
|
+
V: VisitMut,
|
|
264
|
+
F: Fn(Span) -> Expr,
|
|
265
|
+
{
|
|
266
|
+
page_id: Lazy<Ident>,
|
|
267
|
+
runtime_id: Expr,
|
|
268
|
+
parent_element: Option<Ident>,
|
|
269
|
+
element_index: i32,
|
|
270
|
+
element_ids: HashMap<i32, Ident>,
|
|
271
|
+
static_stmts: Vec<RefCell<Stmt>>,
|
|
272
|
+
si_id: Lazy<Ident>,
|
|
273
|
+
snapshot_creator: Option<Function>,
|
|
274
|
+
dynamic_parts: Vec<DynamicPart>,
|
|
275
|
+
dynamic_part_visitor: &'a mut V,
|
|
276
|
+
key: Option<JSXAttrValue>,
|
|
277
|
+
enable_ui_source_map: bool,
|
|
278
|
+
node_index_fn: F,
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
impl<'a, V, F> DynamicPartExtractor<'a, V, F>
|
|
282
|
+
where
|
|
283
|
+
V: VisitMut,
|
|
284
|
+
F: Fn(Span) -> Expr,
|
|
285
|
+
{
|
|
286
|
+
fn new(
|
|
287
|
+
runtime_id: Expr,
|
|
288
|
+
dynamic_part_visitor: &'a mut V,
|
|
289
|
+
enable_ui_source_map: bool,
|
|
290
|
+
node_index_fn: F,
|
|
291
|
+
) -> Self {
|
|
292
|
+
DynamicPartExtractor {
|
|
293
|
+
page_id: Lazy::new(|| private_ident!("pageId")),
|
|
294
|
+
runtime_id,
|
|
295
|
+
parent_element: None,
|
|
296
|
+
element_index: 0,
|
|
297
|
+
element_ids: HashMap::new(),
|
|
298
|
+
static_stmts: vec![],
|
|
299
|
+
si_id: Lazy::new(|| private_ident!("snapshotInstance")),
|
|
300
|
+
snapshot_creator: None,
|
|
301
|
+
dynamic_parts: vec![],
|
|
302
|
+
dynamic_part_visitor,
|
|
303
|
+
key: None,
|
|
304
|
+
enable_ui_source_map,
|
|
305
|
+
node_index_fn,
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
fn node_index_expr_from_span(&self, span: Span) -> Expr {
|
|
310
|
+
(self.node_index_fn)(span)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
fn node_index_config_expr(&self, span: Span) -> Expr {
|
|
314
|
+
Expr::Object(ObjectLit {
|
|
315
|
+
span: DUMMY_SP,
|
|
316
|
+
props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
|
|
317
|
+
key: PropName::Ident(IdentName::new("nodeIndex".into(), DUMMY_SP)),
|
|
318
|
+
value: Box::new(self.node_index_expr_from_span(span)),
|
|
319
|
+
})))],
|
|
320
|
+
})
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
fn static_stmt_from_create_call(
|
|
324
|
+
&self,
|
|
325
|
+
element: Ident,
|
|
326
|
+
callee: &str,
|
|
327
|
+
mut args: Vec<Expr>,
|
|
328
|
+
span: Span,
|
|
329
|
+
) -> Stmt {
|
|
330
|
+
if self.enable_ui_source_map {
|
|
331
|
+
args.push(self.node_index_config_expr(span));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
Stmt::Decl(Decl::Var(Box::new(VarDecl {
|
|
335
|
+
ctxt: SyntaxContext::default(),
|
|
336
|
+
span: DUMMY_SP,
|
|
337
|
+
kind: VarDeclKind::Const,
|
|
338
|
+
declare: false,
|
|
339
|
+
decls: vec![VarDeclarator {
|
|
340
|
+
span: DUMMY_SP,
|
|
341
|
+
definite: false,
|
|
342
|
+
name: Pat::Ident(element.into()),
|
|
343
|
+
init: Some(Box::new(Expr::Call(CallExpr {
|
|
344
|
+
ctxt: SyntaxContext::default(),
|
|
345
|
+
span: DUMMY_SP,
|
|
346
|
+
callee: Callee::Expr(Box::new(Expr::Ident(
|
|
347
|
+
IdentName::new(callee.into(), DUMMY_SP).into(),
|
|
348
|
+
))),
|
|
349
|
+
args: args
|
|
350
|
+
.into_iter()
|
|
351
|
+
.map(|expr| ExprOrSpread {
|
|
352
|
+
spread: None,
|
|
353
|
+
expr: Box::new(expr),
|
|
354
|
+
})
|
|
355
|
+
.collect(),
|
|
356
|
+
type_args: None,
|
|
357
|
+
}))),
|
|
358
|
+
}],
|
|
359
|
+
})))
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
fn static_stmt_from_jsx_element(&mut self, n: &JSXElement, el: Ident) -> Stmt {
|
|
363
|
+
let mut static_stmt: Stmt = Stmt::Empty(EmptyStmt { span: DUMMY_SP });
|
|
364
|
+
|
|
365
|
+
if let Expr::Lit(Lit::Str(str)) = *jsx_name(n.opening.name.clone()) {
|
|
366
|
+
let tag = str.value.to_string_lossy();
|
|
367
|
+
match tag.as_ref() {
|
|
368
|
+
"view" => {
|
|
369
|
+
static_stmt = self.static_stmt_from_create_call(
|
|
370
|
+
el.clone(),
|
|
371
|
+
"__CreateView",
|
|
372
|
+
vec![Expr::Ident(self.page_id.clone())],
|
|
373
|
+
n.opening.span,
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
"scroll-view" => {
|
|
377
|
+
static_stmt = self.static_stmt_from_create_call(
|
|
378
|
+
el.clone(),
|
|
379
|
+
"__CreateScrollView",
|
|
380
|
+
vec![Expr::Ident(self.page_id.clone())],
|
|
381
|
+
n.opening.span,
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
"x-scroll-view" => {
|
|
385
|
+
static_stmt = self.static_stmt_from_create_call(
|
|
386
|
+
el.clone(),
|
|
387
|
+
"__CreateScrollView",
|
|
388
|
+
vec![Expr::Ident(self.page_id.clone())],
|
|
389
|
+
n.opening.span,
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
"image" => {
|
|
393
|
+
static_stmt = self.static_stmt_from_create_call(
|
|
394
|
+
el.clone(),
|
|
395
|
+
"__CreateImage",
|
|
396
|
+
vec![Expr::Ident(self.page_id.clone())],
|
|
397
|
+
n.opening.span,
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
"text" => {
|
|
401
|
+
static_stmt = self.static_stmt_from_create_call(
|
|
402
|
+
el.clone(),
|
|
403
|
+
"__CreateText",
|
|
404
|
+
vec![Expr::Ident(self.page_id.clone())],
|
|
405
|
+
n.opening.span,
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
"wrapper" => {
|
|
409
|
+
static_stmt = quote!(
|
|
410
|
+
r#"const $element = __CreateWrapperElement($page_id)"# as Stmt,
|
|
411
|
+
element = el.clone(),
|
|
412
|
+
page_id = self.page_id.clone(),
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
"list" => {
|
|
416
|
+
static_stmt = quote!(
|
|
417
|
+
r#"const $element = $runtime_id.snapshotCreateList($page_id, $si_id, $element_index)"#
|
|
418
|
+
as Stmt,
|
|
419
|
+
element = el.clone(),
|
|
420
|
+
runtime_id: Expr = self.runtime_id.clone(),
|
|
421
|
+
page_id = self.page_id.clone(),
|
|
422
|
+
si_id = self.si_id.clone(),
|
|
423
|
+
element_index: Expr = Expr::Lit(Lit::Num(Number { span: DUMMY_SP, value: self.element_index as f64, raw: None })),
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
"frame" => {
|
|
427
|
+
static_stmt = self.static_stmt_from_create_call(
|
|
428
|
+
el.clone(),
|
|
429
|
+
"__CreateFrame",
|
|
430
|
+
vec![Expr::Ident(self.page_id.clone())],
|
|
431
|
+
n.opening.span,
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
_ => {
|
|
435
|
+
static_stmt = self.static_stmt_from_create_call(
|
|
436
|
+
el.clone(),
|
|
437
|
+
"__CreateElement",
|
|
438
|
+
vec![Expr::Lit(Lit::Str(str)), Expr::Ident(self.page_id.clone())],
|
|
439
|
+
n.opening.span,
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
static_stmt
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
impl<V, F> VisitMut for DynamicPartExtractor<'_, V, F>
|
|
450
|
+
where
|
|
451
|
+
V: VisitMut,
|
|
452
|
+
F: Fn(Span) -> Expr,
|
|
453
|
+
{
|
|
454
|
+
fn visit_mut_jsx_element_childs(&mut self, n: &mut Vec<JSXElementChild>) {
|
|
455
|
+
if n.is_empty() {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// merge dynamic parts together to reduce wrapper node count
|
|
460
|
+
|
|
461
|
+
let mut merged_children: Vec<JSXElementChild> = vec![];
|
|
462
|
+
let mut current_chunk: Vec<JSXElementChild> = vec![];
|
|
463
|
+
|
|
464
|
+
for mut child in n.take() {
|
|
465
|
+
let should_merge: bool;
|
|
466
|
+
match child {
|
|
467
|
+
JSXElementChild::JSXText(ref text) => {
|
|
468
|
+
if jsx_text_to_str(&text.value).is_empty() {
|
|
469
|
+
should_merge = current_chunk.is_empty();
|
|
470
|
+
} else {
|
|
471
|
+
should_merge = true;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
JSXElementChild::JSXElement(ref element) => {
|
|
475
|
+
should_merge = !jsx_is_custom(element);
|
|
476
|
+
}
|
|
477
|
+
JSXElementChild::JSXExprContainer(JSXExprContainer {
|
|
478
|
+
expr: JSXExpr::Expr(ref _expr),
|
|
479
|
+
..
|
|
480
|
+
}) => {
|
|
481
|
+
should_merge = false;
|
|
482
|
+
}
|
|
483
|
+
JSXElementChild::JSXFragment(_)
|
|
484
|
+
| JSXElementChild::JSXExprContainer(JSXExprContainer {
|
|
485
|
+
expr: JSXExpr::JSXEmptyExpr(_),
|
|
486
|
+
..
|
|
487
|
+
}) => {
|
|
488
|
+
should_merge = true;
|
|
489
|
+
}
|
|
490
|
+
JSXElementChild::JSXSpreadChild(_) => {
|
|
491
|
+
unreachable!("JSXSpreadChild is not supported yet");
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if should_merge {
|
|
496
|
+
if !current_chunk.is_empty() {
|
|
497
|
+
current_chunk.visit_mut_with(self.dynamic_part_visitor);
|
|
498
|
+
self.dynamic_parts.push(DynamicPart::Slot(
|
|
499
|
+
jsx_children_to_expr(current_chunk.take()),
|
|
500
|
+
self.element_index,
|
|
501
|
+
));
|
|
502
|
+
|
|
503
|
+
let mut child = JSXElementChild::JSXElement(Box::new(WRAPPER_NODE_2.clone()));
|
|
504
|
+
child.visit_mut_with(self);
|
|
505
|
+
merged_children.push(child);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
child.visit_mut_with(self);
|
|
509
|
+
merged_children.push(child);
|
|
510
|
+
} else {
|
|
511
|
+
current_chunk.push(child);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if !current_chunk.is_empty() {
|
|
516
|
+
current_chunk.visit_mut_with(self.dynamic_part_visitor);
|
|
517
|
+
self.dynamic_parts.push(DynamicPart::Slot(
|
|
518
|
+
jsx_children_to_expr(current_chunk.take()),
|
|
519
|
+
self.element_index,
|
|
520
|
+
));
|
|
521
|
+
|
|
522
|
+
let mut child = JSXElementChild::JSXElement(Box::new(WRAPPER_NODE_2.clone()));
|
|
523
|
+
child.visit_mut_with(self);
|
|
524
|
+
merged_children.push(child);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
*n = merged_children;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
fn visit_mut_jsx_element(&mut self, n: &mut JSXElement) {
|
|
531
|
+
if !jsx_is_custom(n) {
|
|
532
|
+
match Lazy::<Ident>::get(&self.page_id) {
|
|
533
|
+
Some(_) => {}
|
|
534
|
+
None => {
|
|
535
|
+
self.static_stmts.push(RefCell::new(quote!(
|
|
536
|
+
r#"const $page_id = $runtime_id.__pageId"# as Stmt,
|
|
537
|
+
page_id = self.page_id.clone(),
|
|
538
|
+
runtime_id: Expr = self.runtime_id.clone(),
|
|
539
|
+
)));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
let el = private_ident!("el");
|
|
544
|
+
self.element_ids.insert(self.element_index, el.clone());
|
|
545
|
+
|
|
546
|
+
if (jsx_has_dynamic_key(n)) && self.parent_element.is_some() {
|
|
547
|
+
n.visit_mut_with(self.dynamic_part_visitor);
|
|
548
|
+
let expr = Expr::JSXElement(Box::new(n.take()));
|
|
549
|
+
|
|
550
|
+
if jsx_is_list(n) {
|
|
551
|
+
self
|
|
552
|
+
.dynamic_parts
|
|
553
|
+
.push(DynamicPart::ListSlot(expr, self.element_index));
|
|
554
|
+
} else {
|
|
555
|
+
self
|
|
556
|
+
.dynamic_parts
|
|
557
|
+
.push(DynamicPart::Slot(expr, self.element_index));
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
*n = WRAPPER_NODE_2.clone();
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
let static_stmt = self.static_stmt_from_jsx_element(n, el.clone());
|
|
564
|
+
let static_stmt = RefCell::new(static_stmt);
|
|
565
|
+
self.static_stmts.push(static_stmt.clone());
|
|
566
|
+
|
|
567
|
+
{
|
|
568
|
+
let mut flatten = None;
|
|
569
|
+
for attr in &n.opening.attrs {
|
|
570
|
+
if let JSXAttrOrSpread::JSXAttr(attr) = attr {
|
|
571
|
+
let name = jsx_attr_name(&attr.name.clone()).to_string();
|
|
572
|
+
if NO_FLATTEN_ATTRIBUTES.contains(&name) {
|
|
573
|
+
flatten = Some(JSXAttrOrSpread::JSXAttr(JSXAttr {
|
|
574
|
+
span: DUMMY_SP,
|
|
575
|
+
name: JSXAttrName::Ident(IdentName::new("flatten".into(), DUMMY_SP)),
|
|
576
|
+
value: Some(bool_jsx_attr(false)),
|
|
577
|
+
}));
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if let Some(flatten) = flatten {
|
|
584
|
+
let mut has_origin_flatten = false;
|
|
585
|
+
for attr in &mut n.opening.attrs {
|
|
586
|
+
if let JSXAttrOrSpread::JSXAttr(attr) = attr {
|
|
587
|
+
let name = jsx_attr_name(&attr.name.clone()).to_string();
|
|
588
|
+
if name == *"flatten" {
|
|
589
|
+
attr.value = Some(bool_jsx_attr(false));
|
|
590
|
+
has_origin_flatten = true;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if !has_origin_flatten {
|
|
595
|
+
n.opening.attrs.push(flatten);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
let has_spread_element = n
|
|
601
|
+
.opening
|
|
602
|
+
.attrs
|
|
603
|
+
.iter()
|
|
604
|
+
.any(|attr_or_spread| match attr_or_spread {
|
|
605
|
+
JSXAttrOrSpread::SpreadElement(_) => true,
|
|
606
|
+
JSXAttrOrSpread::JSXAttr(_) => false,
|
|
607
|
+
#[cfg(swc_ast_unknown)]
|
|
608
|
+
_ => panic!("unknown node"),
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
let is_list_item = jsx_is_list_item(n);
|
|
612
|
+
if is_list_item {
|
|
613
|
+
if has_spread_element {
|
|
614
|
+
} else {
|
|
615
|
+
let mut list_item_platform_info: Vec<JSXAttr> = vec![];
|
|
616
|
+
n.opening.attrs.retain_mut(|attr_or_spread| {
|
|
617
|
+
match attr_or_spread {
|
|
618
|
+
JSXAttrOrSpread::JSXAttr(attr) => {
|
|
619
|
+
if let JSXAttrName::Ident(id) = &attr.name {
|
|
620
|
+
match id.sym.to_string().as_str() {
|
|
621
|
+
"reuse-identifier"
|
|
622
|
+
| "full-span"
|
|
623
|
+
| "item-key"
|
|
624
|
+
| "sticky-top"
|
|
625
|
+
| "sticky-bottom"
|
|
626
|
+
| "estimated-height"
|
|
627
|
+
| "estimated-height-px"
|
|
628
|
+
| "estimated-main-axis-size-px"
|
|
629
|
+
| "recyclable" => {
|
|
630
|
+
list_item_platform_info.push(attr.clone());
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
633
|
+
&_ => {}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
JSXAttrOrSpread::SpreadElement(_spread) => {
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
#[cfg(swc_ast_unknown)]
|
|
641
|
+
_ => panic!("unknown node"),
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
true
|
|
645
|
+
});
|
|
646
|
+
if !list_item_platform_info.is_empty() {
|
|
647
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
648
|
+
Expr::Object(ObjectLit {
|
|
649
|
+
span: DUMMY_SP,
|
|
650
|
+
props: list_item_platform_info
|
|
651
|
+
.iter()
|
|
652
|
+
.map(jsx_attr_to_prop)
|
|
653
|
+
.collect(),
|
|
654
|
+
}),
|
|
655
|
+
self.element_index,
|
|
656
|
+
AttrName::ListItemPlatformInfo,
|
|
657
|
+
));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// pick key from n.opening.attrs
|
|
663
|
+
n.opening
|
|
664
|
+
.attrs
|
|
665
|
+
.retain_mut(|attr_or_spread| match attr_or_spread {
|
|
666
|
+
JSXAttrOrSpread::SpreadElement(_) => true,
|
|
667
|
+
JSXAttrOrSpread::JSXAttr(JSXAttr { name, value, .. }) => match name {
|
|
668
|
+
JSXAttrName::Ident(ident_name) => match ident_name.sym.as_ref() {
|
|
669
|
+
"key" => {
|
|
670
|
+
if self.parent_element.is_none() {
|
|
671
|
+
self.key = value.take();
|
|
672
|
+
}
|
|
673
|
+
false
|
|
674
|
+
}
|
|
675
|
+
_ => true,
|
|
676
|
+
},
|
|
677
|
+
JSXAttrName::JSXNamespacedName(_) => true,
|
|
678
|
+
#[cfg(swc_ast_unknown)]
|
|
679
|
+
_ => panic!("unknown node"),
|
|
680
|
+
},
|
|
681
|
+
#[cfg(swc_ast_unknown)]
|
|
682
|
+
_ => panic!("unknown node"),
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
if has_spread_element {
|
|
686
|
+
// TODO: avoid clone
|
|
687
|
+
let mut spread_obj = jsx_props_to_obj(n).unwrap();
|
|
688
|
+
spread_obj.props.push(
|
|
689
|
+
Prop::KeyValue(KeyValueProp {
|
|
690
|
+
key: PropName::Ident(IdentName::new("__spread".into(), DUMMY_SP)),
|
|
691
|
+
value: Expr::Lit(Lit::Bool(true.into())).into(),
|
|
692
|
+
})
|
|
693
|
+
.into(),
|
|
694
|
+
);
|
|
695
|
+
self.dynamic_parts.push(DynamicPart::Spread(
|
|
696
|
+
Expr::Object(spread_obj),
|
|
697
|
+
self.element_index,
|
|
698
|
+
is_list_item,
|
|
699
|
+
));
|
|
700
|
+
} else {
|
|
701
|
+
let el = Expr::Ident(el.clone());
|
|
702
|
+
|
|
703
|
+
n.opening
|
|
704
|
+
.attrs
|
|
705
|
+
.iter_mut()
|
|
706
|
+
.for_each(|attr_or_spread| match attr_or_spread {
|
|
707
|
+
JSXAttrOrSpread::SpreadElement(_) => todo!(),
|
|
708
|
+
JSXAttrOrSpread::JSXAttr(JSXAttr { name, value, .. }) => {
|
|
709
|
+
match name {
|
|
710
|
+
JSXAttrName::Ident(ident_name) => {
|
|
711
|
+
let attr_name = AttrName::from(<IdentName as Into<Ident>>::into(ident_name.clone()));
|
|
712
|
+
match &attr_name {
|
|
713
|
+
AttrName::Attr(name) => {
|
|
714
|
+
match value {
|
|
715
|
+
None => {
|
|
716
|
+
let stmt = quote!(
|
|
717
|
+
r#"__SetAttribute($element, $name, $value)"# as Stmt,
|
|
718
|
+
element: Expr = el.clone(),
|
|
719
|
+
name: Expr = name.clone().into(),
|
|
720
|
+
value: Expr = Expr::Lit(Lit::Bool(Bool {span: DUMMY_SP, value: true}))
|
|
721
|
+
);
|
|
722
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
723
|
+
}
|
|
724
|
+
Some(JSXAttrValue::Str(s)) => {
|
|
725
|
+
let value = transform_jsx_attr_str(&s.value);
|
|
726
|
+
let stmt = quote!(
|
|
727
|
+
r#"__SetAttribute($element, $name, $value)"# as Stmt,
|
|
728
|
+
element: Expr = el.clone(),
|
|
729
|
+
name: Expr = name.clone().into(),
|
|
730
|
+
value: Expr = Expr::Lit(Lit::Str(Str { span: s.span, value: value.into(), raw: None }))
|
|
731
|
+
);
|
|
732
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
733
|
+
}
|
|
734
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
735
|
+
expr: JSXExpr::Expr(expr),
|
|
736
|
+
..
|
|
737
|
+
})) => {
|
|
738
|
+
// expr.map_with_mut(|value| {
|
|
739
|
+
// value.fold_with(self.dynamic_part_visitor)
|
|
740
|
+
// });
|
|
741
|
+
match &**expr {
|
|
742
|
+
Expr::Lit(value) => {
|
|
743
|
+
let stmt = quote!(
|
|
744
|
+
r#"__SetAttribute($element, $name, $value)"# as Stmt,
|
|
745
|
+
element: Expr = el.clone(),
|
|
746
|
+
name: Expr = name.clone().into(),
|
|
747
|
+
value: Expr = Expr::Lit(value.clone())
|
|
748
|
+
);
|
|
749
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
750
|
+
}
|
|
751
|
+
_ => {
|
|
752
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
753
|
+
*expr.clone(),
|
|
754
|
+
self.element_index,
|
|
755
|
+
attr_name.clone(),
|
|
756
|
+
));
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
761
|
+
expr: JSXExpr::JSXEmptyExpr(_),
|
|
762
|
+
..
|
|
763
|
+
})) => {}
|
|
764
|
+
Some(JSXAttrValue::JSXElement(_)) => unreachable!("Unexpected JSXElement in JSX attribute value - not supported"),
|
|
765
|
+
Some(JSXAttrValue::JSXFragment(_)) => unreachable!("Unexpected JSXFragment in JSX attribute value - not supported"),
|
|
766
|
+
#[cfg(swc_ast_unknown)]
|
|
767
|
+
_ => panic!("unknown node"),
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
AttrName::Dataset(name) => {
|
|
771
|
+
match value {
|
|
772
|
+
None => {
|
|
773
|
+
let stmt = quote!(
|
|
774
|
+
r#"__AddDataset($element, $name, $value)"# as Stmt,
|
|
775
|
+
element: Expr = el.clone(),
|
|
776
|
+
name: Expr = name.clone().into(),
|
|
777
|
+
value: Expr = Expr::Lit(Lit::Bool(Bool {span: DUMMY_SP, value: true}))
|
|
778
|
+
);
|
|
779
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
780
|
+
}
|
|
781
|
+
Some(JSXAttrValue::Str(s)) => {
|
|
782
|
+
let value = transform_jsx_attr_str(&s.value);
|
|
783
|
+
let stmt = quote!(
|
|
784
|
+
r#"__AddDataset($element, $name, $value)"# as Stmt,
|
|
785
|
+
element: Expr = el.clone(),
|
|
786
|
+
name: Expr = name.clone().into(),
|
|
787
|
+
value: Expr = Expr::Lit(Lit::Str(Str { span: s.span, value: value.into(), raw: None }))
|
|
788
|
+
);
|
|
789
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
790
|
+
}
|
|
791
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
792
|
+
expr: JSXExpr::Expr(expr),
|
|
793
|
+
..
|
|
794
|
+
})) => {
|
|
795
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
796
|
+
*expr.clone(),
|
|
797
|
+
self.element_index,
|
|
798
|
+
attr_name.clone(),
|
|
799
|
+
));
|
|
800
|
+
}
|
|
801
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
802
|
+
expr: JSXExpr::JSXEmptyExpr(_),
|
|
803
|
+
..
|
|
804
|
+
})) => {}
|
|
805
|
+
Some(JSXAttrValue::JSXElement(_)) => unreachable!("Unexpected JSXElement in JSX attribute value - not supported"),
|
|
806
|
+
Some(JSXAttrValue::JSXFragment(_)) => unreachable!("Unexpected JSXFragment in JSX attribute value - not supported"),
|
|
807
|
+
#[cfg(swc_ast_unknown)]
|
|
808
|
+
_ => panic!("unknown node"),
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
AttrName::Event(..) | AttrName::Ref => {
|
|
812
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
813
|
+
*jsx_attr_value((*value).clone()),
|
|
814
|
+
self.element_index,
|
|
815
|
+
attr_name.clone(),
|
|
816
|
+
));
|
|
817
|
+
}
|
|
818
|
+
AttrName::TimingFlag => {
|
|
819
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
820
|
+
*quote_expr!("{__ltf: $flag}", flag: Expr = *jsx_attr_value((*value).clone())),
|
|
821
|
+
self.element_index,
|
|
822
|
+
attr_name.clone(),
|
|
823
|
+
));
|
|
824
|
+
}
|
|
825
|
+
AttrName::Style => {
|
|
826
|
+
match value {
|
|
827
|
+
None => {}
|
|
828
|
+
Some(JSXAttrValue::Str(s)) => {
|
|
829
|
+
// <view style="width: 100rpx" />;
|
|
830
|
+
let value = transform_jsx_attr_str(&s.value);
|
|
831
|
+
let stmt = quote!(
|
|
832
|
+
r#"__SetInlineStyles($element, $value)"# as Stmt,
|
|
833
|
+
element: Expr = el.clone(),
|
|
834
|
+
value: Expr = Expr::Lit(Lit::Str(Str { span: s.span, value: value.into(), raw: None }))
|
|
835
|
+
);
|
|
836
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
837
|
+
}
|
|
838
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
839
|
+
expr: JSXExpr::Expr(expr),
|
|
840
|
+
span,
|
|
841
|
+
..
|
|
842
|
+
})) => {
|
|
843
|
+
let expr = &**expr;
|
|
844
|
+
if is_literal(expr) {
|
|
845
|
+
if let Some(s) = get_string_inline_style_from_literal(expr, span) {
|
|
846
|
+
// <view style={{backgroundColor: "red"}} />;
|
|
847
|
+
// <view style={`background-color: red;`} />;
|
|
848
|
+
let s = Lit::Str(Str {
|
|
849
|
+
span: *span,
|
|
850
|
+
value: s.into(),
|
|
851
|
+
raw: None,
|
|
852
|
+
});
|
|
853
|
+
let stmt = quote!(
|
|
854
|
+
r#"__SetInlineStyles($element, $value)"# as Stmt,
|
|
855
|
+
element: Expr = el.clone(),
|
|
856
|
+
value: Expr = Expr::Lit(s)
|
|
857
|
+
);
|
|
858
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
859
|
+
}
|
|
860
|
+
} else {
|
|
861
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
862
|
+
expr.clone(),
|
|
863
|
+
self.element_index,
|
|
864
|
+
attr_name.clone(),
|
|
865
|
+
));
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
869
|
+
expr: JSXExpr::JSXEmptyExpr(_),
|
|
870
|
+
..
|
|
871
|
+
})) => {}
|
|
872
|
+
Some(JSXAttrValue::JSXElement(_)) => unreachable!("Unexpected JSXElement in JSX attribute value - not supported"),
|
|
873
|
+
Some(JSXAttrValue::JSXFragment(_)) => unreachable!("Unexpected JSXFragment in JSX attribute value - not supported"),
|
|
874
|
+
#[cfg(swc_ast_unknown)]
|
|
875
|
+
_ => panic!("unknown node"),
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
AttrName::Class => {
|
|
879
|
+
match value {
|
|
880
|
+
None => {}
|
|
881
|
+
Some(JSXAttrValue::Str(s)) => {
|
|
882
|
+
let value = transform_jsx_attr_str(&s.value);
|
|
883
|
+
let stmt = quote!(
|
|
884
|
+
r#"__SetClasses($element, $value)"# as Stmt,
|
|
885
|
+
element: Expr = el.clone(),
|
|
886
|
+
value: Expr = Expr::Lit(Lit::Str(Str { span: s.span, value: value.into(), raw: None }))
|
|
887
|
+
);
|
|
888
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
889
|
+
}
|
|
890
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
891
|
+
expr: JSXExpr::Expr(expr),
|
|
892
|
+
..
|
|
893
|
+
})) => match &**expr {
|
|
894
|
+
Expr::Lit(value) => {
|
|
895
|
+
let stmt = quote!(
|
|
896
|
+
r#"__SetClasses($element, $value)"# as Stmt,
|
|
897
|
+
element: Expr = el.clone(),
|
|
898
|
+
value: Expr = Expr::Lit(value.clone())
|
|
899
|
+
);
|
|
900
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
901
|
+
}
|
|
902
|
+
_ => {
|
|
903
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
904
|
+
*expr.clone(),
|
|
905
|
+
self.element_index,
|
|
906
|
+
attr_name.clone(),
|
|
907
|
+
));
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
911
|
+
expr: JSXExpr::JSXEmptyExpr(_),
|
|
912
|
+
..
|
|
913
|
+
})) => {}
|
|
914
|
+
Some(JSXAttrValue::JSXElement(_)) => unreachable!("Unexpected JSXElement in JSX attribute value - not supported"),
|
|
915
|
+
Some(JSXAttrValue::JSXFragment(_)) => unreachable!("Unexpected JSXFragment in JSX attribute value - not supported"),
|
|
916
|
+
#[cfg(swc_ast_unknown)]
|
|
917
|
+
_ => panic!("unknown node"),
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
AttrName::ID => {
|
|
921
|
+
match value {
|
|
922
|
+
None => {}
|
|
923
|
+
Some(JSXAttrValue::Str(s)) => {
|
|
924
|
+
let value = transform_jsx_attr_str(&s.value);
|
|
925
|
+
let stmt = quote!(
|
|
926
|
+
r#"__SetID($element, $value)"# as Stmt,
|
|
927
|
+
element: Expr = el.clone(),
|
|
928
|
+
value: Expr = Expr::Lit(Lit::Str(Str { span: s.span, value: value.into(), raw: None }))
|
|
929
|
+
);
|
|
930
|
+
self.static_stmts.push(RefCell::new(stmt));
|
|
931
|
+
}
|
|
932
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
933
|
+
expr: JSXExpr::Expr(expr),
|
|
934
|
+
..
|
|
935
|
+
})) => {
|
|
936
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
937
|
+
*expr.clone(),
|
|
938
|
+
self.element_index,
|
|
939
|
+
attr_name,
|
|
940
|
+
));
|
|
941
|
+
}
|
|
942
|
+
Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
943
|
+
expr: JSXExpr::JSXEmptyExpr(_),
|
|
944
|
+
..
|
|
945
|
+
})) => {}
|
|
946
|
+
Some(JSXAttrValue::JSXElement(_)) => unreachable!("Unexpected JSXElement in JSX attribute value - not supported"),
|
|
947
|
+
Some(JSXAttrValue::JSXFragment(_)) => unreachable!("Unexpected JSXFragment in JSX attribute value - not supported"),
|
|
948
|
+
#[cfg(swc_ast_unknown)]
|
|
949
|
+
_ => panic!("unknown node"),
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
AttrName::ListItemPlatformInfo => unreachable!("Unexpected ListItemPlatformInfo attribute in static JSX processing"),
|
|
953
|
+
AttrName::WorkletEvent(..) | AttrName::WorkletRef(..) => {
|
|
954
|
+
unreachable!("A worklet event should have an attribute namespace.")
|
|
955
|
+
}
|
|
956
|
+
AttrName::Gesture(..) => {
|
|
957
|
+
unreachable!("A gesture should have an attribute namespace.")
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
JSXAttrName::JSXNamespacedName(JSXNamespacedName { ns, name, .. }) => {
|
|
962
|
+
let attr_name: AttrName = AttrName::from_ns(ns.clone().into(), name.clone().into());
|
|
963
|
+
match attr_name {
|
|
964
|
+
AttrName::WorkletEvent(..) | AttrName::WorkletRef(..) => {
|
|
965
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
966
|
+
*jsx_attr_value((*value).clone()),
|
|
967
|
+
self.element_index,
|
|
968
|
+
attr_name.clone(),
|
|
969
|
+
));
|
|
970
|
+
}
|
|
971
|
+
AttrName::Gesture(..) => {
|
|
972
|
+
self.dynamic_parts.push(DynamicPart::Attr(
|
|
973
|
+
*jsx_attr_value((*value).clone()),
|
|
974
|
+
self.element_index,
|
|
975
|
+
attr_name.clone(),
|
|
976
|
+
));
|
|
977
|
+
}
|
|
978
|
+
_ => todo!(),
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
#[cfg(swc_ast_unknown)]
|
|
982
|
+
_ => panic!("unknown node"),
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
#[cfg(swc_ast_unknown)]
|
|
986
|
+
_ => panic!("unknown node"),
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
if let Some(parent_el) = &self.parent_element {
|
|
991
|
+
self.static_stmts.push(RefCell::new(quote!(
|
|
992
|
+
r#"__AppendElement($parent, $child)"# as Stmt,
|
|
993
|
+
parent: Ident = parent_el.clone(),
|
|
994
|
+
child: Ident = el.clone(),
|
|
995
|
+
)));
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
let is_children_full_dynamic = jsx_is_children_full_dynamic(n);
|
|
999
|
+
|
|
1000
|
+
if !is_children_full_dynamic {
|
|
1001
|
+
self.element_index += 1;
|
|
1002
|
+
|
|
1003
|
+
let pre_parent_element = self.parent_element.take();
|
|
1004
|
+
self.parent_element = Some(el.clone());
|
|
1005
|
+
n.children.visit_mut_with(self);
|
|
1006
|
+
self.parent_element = pre_parent_element;
|
|
1007
|
+
} else {
|
|
1008
|
+
n.children.visit_mut_with(self.dynamic_part_visitor);
|
|
1009
|
+
let children_expr = jsx_children_to_expr(n.children.take());
|
|
1010
|
+
if jsx_is_list(n) {
|
|
1011
|
+
self
|
|
1012
|
+
.dynamic_parts
|
|
1013
|
+
.push(DynamicPart::ListSlot(children_expr, self.element_index));
|
|
1014
|
+
} else {
|
|
1015
|
+
self
|
|
1016
|
+
.dynamic_parts
|
|
1017
|
+
.push(DynamicPart::Slot(children_expr, self.element_index));
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
self.element_index += 1;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
if self.parent_element.is_none() {
|
|
1024
|
+
let elements = Expr::Array(ArrayLit {
|
|
1025
|
+
span: DUMMY_SP,
|
|
1026
|
+
elems: (0..self.element_ids.len())
|
|
1027
|
+
.step_by(1)
|
|
1028
|
+
.map(|e| e as i32)
|
|
1029
|
+
.map(|e| {
|
|
1030
|
+
Some(ExprOrSpread {
|
|
1031
|
+
spread: None,
|
|
1032
|
+
expr: Box::new(Expr::Ident(self.element_ids[&e].clone())),
|
|
1033
|
+
})
|
|
1034
|
+
})
|
|
1035
|
+
.collect(),
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
self.static_stmts.push(RefCell::new(quote!(
|
|
1039
|
+
r#"return $elements;"# as Stmt,
|
|
1040
|
+
elements: Expr = elements,
|
|
1041
|
+
)));
|
|
1042
|
+
|
|
1043
|
+
self.snapshot_creator = Some(Function {
|
|
1044
|
+
ctxt: SyntaxContext::default(),
|
|
1045
|
+
params: match Lazy::<Ident>::get(&self.si_id) {
|
|
1046
|
+
Some(_) => vec![Param {
|
|
1047
|
+
span: DUMMY_SP,
|
|
1048
|
+
decorators: vec![],
|
|
1049
|
+
pat: Pat::Ident(BindingIdent {
|
|
1050
|
+
id: self.si_id.take(),
|
|
1051
|
+
type_ann: None,
|
|
1052
|
+
}),
|
|
1053
|
+
}],
|
|
1054
|
+
None => vec![],
|
|
1055
|
+
},
|
|
1056
|
+
decorators: vec![],
|
|
1057
|
+
this_param: None,
|
|
1058
|
+
span: DUMMY_SP,
|
|
1059
|
+
body: Some(FunctionBody {
|
|
1060
|
+
span: DUMMY_SP,
|
|
1061
|
+
stmts: self
|
|
1062
|
+
.static_stmts
|
|
1063
|
+
.take()
|
|
1064
|
+
.into_iter()
|
|
1065
|
+
.map(|mut stmt| stmt.get_mut().take())
|
|
1066
|
+
.collect(),
|
|
1067
|
+
}),
|
|
1068
|
+
is_generator: false,
|
|
1069
|
+
is_async: false,
|
|
1070
|
+
type_params: None,
|
|
1071
|
+
return_type: None,
|
|
1072
|
+
});
|
|
1073
|
+
};
|
|
1074
|
+
} else {
|
|
1075
|
+
n.visit_mut_children_with(self.dynamic_part_visitor);
|
|
1076
|
+
|
|
1077
|
+
if self.parent_element.is_some() {
|
|
1078
|
+
self.dynamic_parts.push(DynamicPart::Slot(
|
|
1079
|
+
Expr::JSXElement(Box::new(n.take())),
|
|
1080
|
+
self.element_index,
|
|
1081
|
+
));
|
|
1082
|
+
|
|
1083
|
+
// self.element_index += 1;
|
|
1084
|
+
*n = WRAPPER_NODE.clone();
|
|
1085
|
+
n.visit_mut_with(self);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
fn visit_mut_jsx_text(&mut self, n: &mut JSXText) {
|
|
1091
|
+
let t = jsx_text_to_str(&n.value);
|
|
1092
|
+
|
|
1093
|
+
if !t.is_empty() {
|
|
1094
|
+
let el = private_ident!("el");
|
|
1095
|
+
self.element_ids.insert(self.element_index, el.clone());
|
|
1096
|
+
|
|
1097
|
+
self.static_stmts.push(RefCell::new(quote!(
|
|
1098
|
+
r#"const $element = __CreateRawText($t)"# as Stmt,
|
|
1099
|
+
element = el.clone(),
|
|
1100
|
+
t: Expr = t.into(),
|
|
1101
|
+
)));
|
|
1102
|
+
|
|
1103
|
+
if let Some(parent_el) = &self.parent_element {
|
|
1104
|
+
self.static_stmts.push(RefCell::new(quote!(
|
|
1105
|
+
r#"__AppendElement($parent, $child)"# as Stmt,
|
|
1106
|
+
parent: Ident = parent_el.clone(),
|
|
1107
|
+
child: Ident = el.clone(),
|
|
1108
|
+
)));
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1111
|
+
self.element_index += 1;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/// @internal
|
|
1117
|
+
#[derive(Deserialize, PartialEq, Clone, Debug)]
|
|
1118
|
+
#[serde(rename_all = "camelCase")]
|
|
1119
|
+
pub struct JSXTransformerConfig {
|
|
1120
|
+
/// @internal
|
|
1121
|
+
pub preserve_jsx: bool,
|
|
1122
|
+
/// @internal
|
|
1123
|
+
pub runtime_pkg: String,
|
|
1124
|
+
/// @internal
|
|
1125
|
+
pub jsx_import_source: Option<String>,
|
|
1126
|
+
/// @internal
|
|
1127
|
+
pub filename: String,
|
|
1128
|
+
/// @internal
|
|
1129
|
+
pub target: TransformTarget,
|
|
1130
|
+
/// @internal
|
|
1131
|
+
#[serde(default)]
|
|
1132
|
+
pub enable_ui_source_map: bool,
|
|
1133
|
+
/// @internal
|
|
1134
|
+
pub is_dynamic_component: Option<bool>,
|
|
1135
|
+
/// @internal
|
|
1136
|
+
#[serde(default)]
|
|
1137
|
+
pub is_external_bundle: Option<bool>,
|
|
1138
|
+
/// Compile dynamic children with the frozen legacy (pre-SlotV2) codegen in
|
|
1139
|
+
/// `legacy_slot.rs` so the output runs on legacy runtimes without `SlotV2`
|
|
1140
|
+
/// support (< 0.120.0).
|
|
1141
|
+
/// @internal
|
|
1142
|
+
#[serde(default)]
|
|
1143
|
+
pub legacy_slot: Option<bool>,
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
impl Default for JSXTransformerConfig {
|
|
1147
|
+
fn default() -> Self {
|
|
1148
|
+
Self {
|
|
1149
|
+
preserve_jsx: false,
|
|
1150
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1151
|
+
jsx_import_source: Some("@lynx-js/react".into()),
|
|
1152
|
+
filename: Default::default(),
|
|
1153
|
+
target: TransformTarget::LEPUS,
|
|
1154
|
+
enable_ui_source_map: false,
|
|
1155
|
+
is_dynamic_component: Some(false),
|
|
1156
|
+
is_external_bundle: Some(false),
|
|
1157
|
+
legacy_slot: Some(false),
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
#[allow(clippy::too_many_arguments)]
|
|
1163
|
+
pub(crate) fn build_snapshot_registration(
|
|
1164
|
+
dev_creator_param: bool,
|
|
1165
|
+
runtime_id: Expr,
|
|
1166
|
+
creator_runtime_expr: Expr,
|
|
1167
|
+
creator_runtime_id: Ident,
|
|
1168
|
+
snapshot_id: Ident,
|
|
1169
|
+
snapshot_creator: Expr,
|
|
1170
|
+
snapshot_dynamic_parts_def: Expr,
|
|
1171
|
+
slot: Expr,
|
|
1172
|
+
css_id: Expr,
|
|
1173
|
+
entry_name: Expr,
|
|
1174
|
+
snapshot_refs_and_spread_index: Expr,
|
|
1175
|
+
) -> Expr {
|
|
1176
|
+
if dev_creator_param {
|
|
1177
|
+
quote!(
|
|
1178
|
+
r#"$runtime_id.snapshotCreatorMap[$snapshot_id] = ($snapshot_id, $creator_runtime) => $creator_runtime_ref.createSnapshot(
|
|
1179
|
+
$snapshot_id,
|
|
1180
|
+
$snapshot_creator,
|
|
1181
|
+
$snapshot_dynamic_parts_def,
|
|
1182
|
+
$slot,
|
|
1183
|
+
$css_id,
|
|
1184
|
+
$entry_name,
|
|
1185
|
+
$snapshot_refs_and_spread_index,
|
|
1186
|
+
true
|
|
1187
|
+
)"# as Expr,
|
|
1188
|
+
runtime_id: Expr = runtime_id,
|
|
1189
|
+
creator_runtime = creator_runtime_id,
|
|
1190
|
+
creator_runtime_ref: Expr = creator_runtime_expr,
|
|
1191
|
+
snapshot_id = snapshot_id,
|
|
1192
|
+
entry_name: Expr = entry_name,
|
|
1193
|
+
snapshot_creator: Expr = snapshot_creator,
|
|
1194
|
+
snapshot_dynamic_parts_def: Expr = snapshot_dynamic_parts_def,
|
|
1195
|
+
slot: Expr = slot,
|
|
1196
|
+
css_id: Expr = css_id,
|
|
1197
|
+
snapshot_refs_and_spread_index: Expr = snapshot_refs_and_spread_index,
|
|
1198
|
+
)
|
|
1199
|
+
} else {
|
|
1200
|
+
quote!(
|
|
1201
|
+
r#"$runtime_id.snapshotCreatorMap[$snapshot_id] = ($snapshot_id) => $runtime_id.createSnapshot(
|
|
1202
|
+
$snapshot_id,
|
|
1203
|
+
$snapshot_creator,
|
|
1204
|
+
$snapshot_dynamic_parts_def,
|
|
1205
|
+
$slot,
|
|
1206
|
+
$css_id,
|
|
1207
|
+
$entry_name,
|
|
1208
|
+
$snapshot_refs_and_spread_index,
|
|
1209
|
+
true
|
|
1210
|
+
)"# as Expr,
|
|
1211
|
+
runtime_id: Expr = runtime_id,
|
|
1212
|
+
snapshot_id = snapshot_id,
|
|
1213
|
+
entry_name: Expr = entry_name,
|
|
1214
|
+
snapshot_creator: Expr = snapshot_creator,
|
|
1215
|
+
snapshot_dynamic_parts_def: Expr = snapshot_dynamic_parts_def,
|
|
1216
|
+
slot: Expr = slot,
|
|
1217
|
+
css_id: Expr = css_id,
|
|
1218
|
+
snapshot_refs_and_spread_index: Expr = snapshot_refs_and_spread_index,
|
|
1219
|
+
)
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
pub struct JSXTransformer<C>
|
|
1224
|
+
where
|
|
1225
|
+
C: Comments + Clone,
|
|
1226
|
+
{
|
|
1227
|
+
// react_transformer: Box<dyn Fold>,
|
|
1228
|
+
cfg: JSXTransformerConfig,
|
|
1229
|
+
filename_hash: String,
|
|
1230
|
+
content_hash: String,
|
|
1231
|
+
runtime_id: Lazy<Expr>,
|
|
1232
|
+
dev_creator_param: bool,
|
|
1233
|
+
runtime_components_ident: Ident,
|
|
1234
|
+
runtime_components_module_item: Option<ModuleItem>,
|
|
1235
|
+
css_id_value: Option<Expr>,
|
|
1236
|
+
snapshot_counter: u32,
|
|
1237
|
+
current_snapshot_defs: Vec<ModuleItem>,
|
|
1238
|
+
current_snapshot_id: Option<Ident>,
|
|
1239
|
+
defines_collector: Option<DefinesCollector>,
|
|
1240
|
+
comments: Option<C>,
|
|
1241
|
+
pub ui_source_map_records: Rc<RefCell<Vec<UISourceMapRecord>>>,
|
|
1242
|
+
pub source_map: Option<Lrc<SourceMap>>,
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
impl<C> JSXTransformer<C>
|
|
1246
|
+
where
|
|
1247
|
+
C: Comments + Clone,
|
|
1248
|
+
{
|
|
1249
|
+
pub fn with_content_hash(mut self, content_hash: String) -> Self {
|
|
1250
|
+
self.content_hash = content_hash;
|
|
1251
|
+
self
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
pub fn with_defines_collector(mut self, collector: DefinesCollector) -> Self {
|
|
1255
|
+
self.defines_collector = Some(collector);
|
|
1256
|
+
self
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
pub fn new(
|
|
1260
|
+
cfg: JSXTransformerConfig,
|
|
1261
|
+
comments: Option<C>,
|
|
1262
|
+
mode: TransformMode,
|
|
1263
|
+
source_map: Option<Lrc<SourceMap>>,
|
|
1264
|
+
) -> Self {
|
|
1265
|
+
JSXTransformer {
|
|
1266
|
+
filename_hash: calc_hash(&cfg.filename.clone()),
|
|
1267
|
+
content_hash: "test".into(),
|
|
1268
|
+
// Bound via the `import * as ReactLynx from <cfg.runtime_pkg>` prepended
|
|
1269
|
+
// in `visit_mut_module` — no dev-only `require()`, so promise (async)
|
|
1270
|
+
// externals are awaited through the regular import machinery.
|
|
1271
|
+
runtime_id: Lazy::new(|| Expr::Ident(private_ident!("ReactLynx"))),
|
|
1272
|
+
// Dev creators are stringified for cross-thread HMR
|
|
1273
|
+
// (`DEV_ONLY_AddSnapshot`) and take the runtime as an arrow parameter
|
|
1274
|
+
// instead of capturing module bindings. Production creators keep the
|
|
1275
|
+
// module-scope reference, which stays statically tree-shakeable.
|
|
1276
|
+
dev_creator_param: matches!(mode, TransformMode::Development),
|
|
1277
|
+
runtime_components_ident: private_ident!("ReactLynxRuntimeComponents"),
|
|
1278
|
+
runtime_components_module_item: None,
|
|
1279
|
+
cfg,
|
|
1280
|
+
css_id_value: None,
|
|
1281
|
+
snapshot_counter: 0,
|
|
1282
|
+
current_snapshot_defs: vec![],
|
|
1283
|
+
current_snapshot_id: None,
|
|
1284
|
+
defines_collector: None,
|
|
1285
|
+
comments,
|
|
1286
|
+
ui_source_map_records: Rc::new(RefCell::new(vec![])),
|
|
1287
|
+
source_map,
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
fn parse_directives(&mut self, span: Span) {
|
|
1292
|
+
self.comments.with_leading(span.lo, |comments| {
|
|
1293
|
+
for cmt in comments {
|
|
1294
|
+
if cmt.kind != CommentKind::Block {
|
|
1295
|
+
continue;
|
|
1296
|
+
}
|
|
1297
|
+
for line in cmt.text.lines() {
|
|
1298
|
+
let mut line = line.trim();
|
|
1299
|
+
if line.starts_with('*') {
|
|
1300
|
+
line = line[1..].trim();
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
if !line.starts_with("@jsx") {
|
|
1304
|
+
continue;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
let mut words = line.split_whitespace();
|
|
1308
|
+
loop {
|
|
1309
|
+
let pragma = words.next();
|
|
1310
|
+
if pragma.is_none() {
|
|
1311
|
+
break;
|
|
1312
|
+
}
|
|
1313
|
+
let val = words.next();
|
|
1314
|
+
if let Some("@jsxCSSId") = pragma {
|
|
1315
|
+
if let Some(css_id) = val {
|
|
1316
|
+
self.css_id_value = Some(Expr::Lit(Lit::Num(
|
|
1317
|
+
css_id
|
|
1318
|
+
.parse::<f64>()
|
|
1319
|
+
.expect("should have numeric cssId")
|
|
1320
|
+
.into(),
|
|
1321
|
+
)));
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
impl<C> VisitMut for JSXTransformer<C>
|
|
1332
|
+
where
|
|
1333
|
+
C: Comments + Clone,
|
|
1334
|
+
{
|
|
1335
|
+
fn visit_mut_jsx_element(&mut self, node: &mut JSXElement) {
|
|
1336
|
+
match *jsx_name(node.opening.name.clone()) {
|
|
1337
|
+
Expr::Lit(lit) => {
|
|
1338
|
+
if let Lit::Str(s) = &lit {
|
|
1339
|
+
let tag = s.value.to_string_lossy();
|
|
1340
|
+
let tag_str = tag.as_ref();
|
|
1341
|
+
if tag_str == "wrapper" {
|
|
1342
|
+
return node.visit_mut_children_with(self);
|
|
1343
|
+
}
|
|
1344
|
+
if tag_str == "page" {
|
|
1345
|
+
if self.runtime_components_module_item.is_none() {
|
|
1346
|
+
self.runtime_components_module_item = Some(quote!(
|
|
1347
|
+
r#"import * as $runtime_components_ident from '@lynx-js/react/runtime-components';"#
|
|
1348
|
+
as ModuleItem,
|
|
1349
|
+
runtime_components_ident = self.runtime_components_ident.clone(),
|
|
1350
|
+
));
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
if let JSXElementName::Ident(_ident) = &mut node.opening.name {
|
|
1354
|
+
node.opening.name = JSXElementName::JSXMemberExpr(JSXMemberExpr {
|
|
1355
|
+
obj: JSXObject::Ident(self.runtime_components_ident.clone()),
|
|
1356
|
+
prop: private_ident!("Page").into(),
|
|
1357
|
+
span: node.opening.span,
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
if let Some(JSXClosingElement { name, .. }) = &mut node.closing {
|
|
1361
|
+
if let JSXElementName::Ident(ident) = name {
|
|
1362
|
+
*name = JSXElementName::JSXMemberExpr(JSXMemberExpr {
|
|
1363
|
+
obj: JSXObject::Ident(self.runtime_components_ident.clone()),
|
|
1364
|
+
prop: private_ident!("Page").into(),
|
|
1365
|
+
span: ident.span(),
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
return node.visit_mut_children_with(self);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
if tag_str == "component" {
|
|
1374
|
+
HANDLER.with(|handler| {
|
|
1375
|
+
handler
|
|
1376
|
+
.struct_span_err(node.opening.name.span(), "<component /> is not supported")
|
|
1377
|
+
.emit()
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
_ => {
|
|
1383
|
+
return node.visit_mut_children_with(self);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
if matches!(self.cfg.legacy_slot, Some(true)) {
|
|
1388
|
+
// Frozen pre-SlotV2 codegen lives entirely in legacy_slot.rs; keep the
|
|
1389
|
+
// default (SlotV2) pipeline below free of legacy concerns.
|
|
1390
|
+
return legacy_slot::transform_jsx_element(self, node);
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
self.snapshot_counter += 1;
|
|
1394
|
+
|
|
1395
|
+
let snapshot_uid = format!(
|
|
1396
|
+
"__snapshot_{}_{}_{}",
|
|
1397
|
+
self.filename_hash, self.content_hash, self.snapshot_counter
|
|
1398
|
+
);
|
|
1399
|
+
let snapshot_id = Ident::new(
|
|
1400
|
+
// format!("__snapshot_{}", snapshot_uid).into(),
|
|
1401
|
+
snapshot_uid.clone().into(),
|
|
1402
|
+
DUMMY_SP,
|
|
1403
|
+
SyntaxContext::default().apply_mark(Mark::fresh(Mark::root())),
|
|
1404
|
+
);
|
|
1405
|
+
|
|
1406
|
+
let target = self.cfg.target;
|
|
1407
|
+
let collecting = self.defines_collector.is_some();
|
|
1408
|
+
let runtime_id = self.runtime_id.clone();
|
|
1409
|
+
// In dev the creator arrow is stringified for cross-thread HMR
|
|
1410
|
+
// (`DEV_ONLY_AddSnapshot`), so everything inside it references the runtime
|
|
1411
|
+
// through the arrow's own parameter; in production it keeps the
|
|
1412
|
+
// module-scope import binding (statically tree-shakeable).
|
|
1413
|
+
let creator_runtime_id = private_ident!("__runtime__");
|
|
1414
|
+
let creator_runtime_expr = if self.dev_creator_param {
|
|
1415
|
+
// `__runtime__` is passed by runtimes that pass `SnapshotCreator`'s
|
|
1416
|
+
// second argument; the inline `require` keeps the compiled output
|
|
1417
|
+
// working on older runtimes that still call creators with a single
|
|
1418
|
+
// argument (they load synchronously, so the pending-promise issue the
|
|
1419
|
+
// parameter solves cannot occur there).
|
|
1420
|
+
// TODO(compat): drop the `require` fallback once runtimes without
|
|
1421
|
+
// `snapshotCreatorRuntime` are out of support.
|
|
1422
|
+
quote!(
|
|
1423
|
+
"($creator_runtime || require($runtime_pkg))" as Expr,
|
|
1424
|
+
creator_runtime = creator_runtime_id.clone(),
|
|
1425
|
+
runtime_pkg: Expr = Expr::Lit(Lit::Str(self.cfg.runtime_pkg.clone().into())),
|
|
1426
|
+
)
|
|
1427
|
+
} else {
|
|
1428
|
+
self.runtime_id.clone()
|
|
1429
|
+
};
|
|
1430
|
+
let filename_hash = self.filename_hash.clone();
|
|
1431
|
+
let content_hash = self.content_hash.clone();
|
|
1432
|
+
let ui_source_map_records = self.ui_source_map_records.clone();
|
|
1433
|
+
let snapshot_uid_for_captured = snapshot_uid.clone();
|
|
1434
|
+
let source_map = self.source_map.clone();
|
|
1435
|
+
let node_index_fn = move |span: Span| {
|
|
1436
|
+
let ui_source_map =
|
|
1437
|
+
calc_hash_number(&format!("{}:{}:{}", filename_hash, content_hash, span.lo.0));
|
|
1438
|
+
|
|
1439
|
+
// record ui source map entry
|
|
1440
|
+
let mut line_number = 0;
|
|
1441
|
+
let mut column_number = 0;
|
|
1442
|
+
if span.lo.0 > 0 {
|
|
1443
|
+
if let Some(cm) = &source_map {
|
|
1444
|
+
let loc = cm.lookup_char_pos(span.lo);
|
|
1445
|
+
line_number = loc.line as u32;
|
|
1446
|
+
column_number = loc.col.0 as u32 + 1;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
ui_source_map_records.borrow_mut().push(UISourceMapRecord {
|
|
1450
|
+
ui_source_map,
|
|
1451
|
+
line_number,
|
|
1452
|
+
column_number,
|
|
1453
|
+
snapshot_id: snapshot_uid_for_captured.clone(),
|
|
1454
|
+
});
|
|
1455
|
+
|
|
1456
|
+
Expr::Lit(Lit::Num(Number {
|
|
1457
|
+
span: DUMMY_SP,
|
|
1458
|
+
value: ui_source_map as f64,
|
|
1459
|
+
raw: None,
|
|
1460
|
+
}))
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
let mut dynamic_part_extractor = DynamicPartExtractor::new(
|
|
1464
|
+
creator_runtime_expr.clone(),
|
|
1465
|
+
self,
|
|
1466
|
+
self.cfg.enable_ui_source_map,
|
|
1467
|
+
node_index_fn,
|
|
1468
|
+
);
|
|
1469
|
+
|
|
1470
|
+
node.visit_mut_with(&mut dynamic_part_extractor);
|
|
1471
|
+
|
|
1472
|
+
let mut snapshot_values: Vec<Option<ExprOrSpread>> = vec![];
|
|
1473
|
+
let mut snapshot_values_has_attr = false;
|
|
1474
|
+
let mut snapshot_attrs: Vec<JSXAttrOrSpread> = vec![];
|
|
1475
|
+
let mut snapshot_children: Vec<Expr> = vec![];
|
|
1476
|
+
let mut snapshot_dynamic_part_def: Vec<Option<ExprOrSpread>> = vec![];
|
|
1477
|
+
let mut snapshot_dynamic_part_def_mt: Vec<Option<ExprOrSpread>> = vec![];
|
|
1478
|
+
let mut snapshot_refs_and_spread_index: Vec<Option<ExprOrSpread>> = vec![];
|
|
1479
|
+
let mut snapshot_slot_def: Vec<Option<ExprOrSpread>> = vec![];
|
|
1480
|
+
let mut list_item_platform_info_index: Option<i32> = None;
|
|
1481
|
+
|
|
1482
|
+
if let Some(key) = dynamic_part_extractor.key {
|
|
1483
|
+
snapshot_attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr {
|
|
1484
|
+
span: DUMMY_SP,
|
|
1485
|
+
name: JSXAttrName::Ident(IdentName::new("key".into(), DUMMY_SP)),
|
|
1486
|
+
value: Some(key),
|
|
1487
|
+
}));
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
let (dynamic_part_attr, dynamic_part_children): (Vec<_>, Vec<_>) = dynamic_part_extractor
|
|
1491
|
+
.dynamic_parts
|
|
1492
|
+
.into_iter()
|
|
1493
|
+
.partition(|dynamic_part| match dynamic_part {
|
|
1494
|
+
DynamicPart::Attr(_, _, _) | DynamicPart::Spread(_, _, _) => true,
|
|
1495
|
+
DynamicPart::Slot(_, _) | DynamicPart::ListSlot(_, _) => false,
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
dynamic_part_attr.into_iter().for_each(|dynamic_part| {
|
|
1499
|
+
match &dynamic_part {
|
|
1500
|
+
DynamicPart::Attr(_, _, _) | DynamicPart::Spread(_, _, _) => {
|
|
1501
|
+
if let DynamicPart::Attr(_, _, AttrName::Ref) | DynamicPart::Spread(_, _, _) =
|
|
1502
|
+
dynamic_part
|
|
1503
|
+
{
|
|
1504
|
+
snapshot_refs_and_spread_index.push(Some(
|
|
1505
|
+
Expr::Lit(Lit::Num(snapshot_dynamic_part_def.len().into())).into(),
|
|
1506
|
+
));
|
|
1507
|
+
}
|
|
1508
|
+
let updater_index = snapshot_dynamic_part_def.len() as i32;
|
|
1509
|
+
let updater = |target: TransformTarget| ExprOrSpread {
|
|
1510
|
+
spread: None,
|
|
1511
|
+
expr: Box::new(dynamic_part.to_updater(
|
|
1512
|
+
creator_runtime_expr.clone(),
|
|
1513
|
+
target,
|
|
1514
|
+
updater_index,
|
|
1515
|
+
)),
|
|
1516
|
+
};
|
|
1517
|
+
if collecting {
|
|
1518
|
+
snapshot_dynamic_part_def_mt.push(Some(updater(TransformTarget::LEPUS)));
|
|
1519
|
+
}
|
|
1520
|
+
snapshot_dynamic_part_def.push(Some(updater(target)));
|
|
1521
|
+
}
|
|
1522
|
+
DynamicPart::Slot(_, _) => {}
|
|
1523
|
+
DynamicPart::ListSlot(_, _) => {}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
match dynamic_part {
|
|
1527
|
+
DynamicPart::Attr(value, _, attr_name) => {
|
|
1528
|
+
if matches!(attr_name, AttrName::ListItemPlatformInfo) {
|
|
1529
|
+
list_item_platform_info_index = Some(snapshot_values.len() as i32);
|
|
1530
|
+
}
|
|
1531
|
+
snapshot_values.push(Some(ExprOrSpread {
|
|
1532
|
+
spread: None,
|
|
1533
|
+
expr: Box::new(if let AttrName::Event(_, _) = attr_name {
|
|
1534
|
+
if target == TransformTarget::LEPUS {
|
|
1535
|
+
quote!("1" as Expr)
|
|
1536
|
+
} else {
|
|
1537
|
+
value
|
|
1538
|
+
}
|
|
1539
|
+
} else if let AttrName::Ref = attr_name {
|
|
1540
|
+
if target == TransformTarget::LEPUS {
|
|
1541
|
+
quote!("1" as Expr)
|
|
1542
|
+
} else {
|
|
1543
|
+
quote!(
|
|
1544
|
+
"$runtime_id.transformRef($value)" as Expr,
|
|
1545
|
+
runtime_id: Expr = runtime_id.clone(),
|
|
1546
|
+
value: Expr = value,
|
|
1547
|
+
)
|
|
1548
|
+
}
|
|
1549
|
+
} else {
|
|
1550
|
+
value
|
|
1551
|
+
}),
|
|
1552
|
+
}));
|
|
1553
|
+
snapshot_values_has_attr = true;
|
|
1554
|
+
}
|
|
1555
|
+
DynamicPart::Spread(value, _, is_list_item) => {
|
|
1556
|
+
if is_list_item {
|
|
1557
|
+
list_item_platform_info_index = Some(snapshot_values.len() as i32);
|
|
1558
|
+
}
|
|
1559
|
+
snapshot_values.push(Some(ExprOrSpread {
|
|
1560
|
+
spread: None,
|
|
1561
|
+
expr: Box::new(value),
|
|
1562
|
+
}));
|
|
1563
|
+
snapshot_values_has_attr = true;
|
|
1564
|
+
}
|
|
1565
|
+
DynamicPart::ListSlot(_, _) => {}
|
|
1566
|
+
DynamicPart::Slot(_, _) => {}
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
|
|
1570
|
+
let slot_expr = match (dynamic_part_children.len(), dynamic_part_children.first()) {
|
|
1571
|
+
(0, _) => Expr::Lit(Lit::Null(Null { span: DUMMY_SP })),
|
|
1572
|
+
(1, Some(DynamicPart::Slot(expr, 0))) => {
|
|
1573
|
+
snapshot_children.push(expr.clone());
|
|
1574
|
+
quote!(
|
|
1575
|
+
"$runtime_id.__DynamicPartSlotV2_0" as Expr,
|
|
1576
|
+
runtime_id: Expr = creator_runtime_expr.clone(),
|
|
1577
|
+
)
|
|
1578
|
+
}
|
|
1579
|
+
_ => {
|
|
1580
|
+
dynamic_part_children
|
|
1581
|
+
.into_iter()
|
|
1582
|
+
.for_each(|dynamic_part| match dynamic_part {
|
|
1583
|
+
DynamicPart::Attr(_, _, _) => {}
|
|
1584
|
+
DynamicPart::Spread(_, _, _) => {}
|
|
1585
|
+
DynamicPart::ListSlot(expr, element_index) => {
|
|
1586
|
+
snapshot_children.push(expr);
|
|
1587
|
+
snapshot_slot_def.push(Some(ExprOrSpread {
|
|
1588
|
+
spread: None,
|
|
1589
|
+
expr: Box::new(quote!(
|
|
1590
|
+
"[$runtime_id.__DynamicPartListSlotV2, $element_index]" as Expr,
|
|
1591
|
+
runtime_id: Expr = creator_runtime_expr.clone(),
|
|
1592
|
+
element_index: Expr = i32_to_expr(&element_index),
|
|
1593
|
+
)),
|
|
1594
|
+
}));
|
|
1595
|
+
}
|
|
1596
|
+
DynamicPart::Slot(expr, element_index) => {
|
|
1597
|
+
snapshot_children.push(expr);
|
|
1598
|
+
snapshot_slot_def.push(Some(ExprOrSpread {
|
|
1599
|
+
spread: None,
|
|
1600
|
+
expr: Box::new(quote!(
|
|
1601
|
+
"[$runtime_id.__DynamicPartSlotV2, $element_index]" as Expr,
|
|
1602
|
+
runtime_id: Expr = creator_runtime_expr.clone(),
|
|
1603
|
+
element_index: Expr = i32_to_expr(&element_index),
|
|
1604
|
+
)),
|
|
1605
|
+
}));
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
|
|
1609
|
+
Expr::Array(ArrayLit {
|
|
1610
|
+
span: DUMMY_SP,
|
|
1611
|
+
elems: snapshot_slot_def,
|
|
1612
|
+
})
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
let snapshot_creator_fn = dynamic_part_extractor.snapshot_creator.unwrap();
|
|
1617
|
+
let snapshot_creator_mt = collecting.then(|| {
|
|
1618
|
+
Expr::Fn(FnExpr {
|
|
1619
|
+
ident: None,
|
|
1620
|
+
function: Box::new(snapshot_creator_fn.clone()),
|
|
1621
|
+
})
|
|
1622
|
+
});
|
|
1623
|
+
let snapshot_creator = if target == TransformTarget::JS {
|
|
1624
|
+
Expr::Lit(Lit::Null(Null { span: DUMMY_SP }))
|
|
1625
|
+
} else {
|
|
1626
|
+
Expr::Fn(FnExpr {
|
|
1627
|
+
ident: None,
|
|
1628
|
+
function: Box::new(snapshot_creator_fn),
|
|
1629
|
+
})
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1632
|
+
// External bundles have no `globDynamicComponentEntry` in scope; use the
|
|
1633
|
+
// `__Card__` entry-name literal.
|
|
1634
|
+
let entry_name: Expr = if matches!(self.cfg.is_external_bundle, Some(true))
|
|
1635
|
+
&& !matches!(self.cfg.is_dynamic_component, Some(true))
|
|
1636
|
+
{
|
|
1637
|
+
Expr::Lit(Lit::Str("__Card__".into()))
|
|
1638
|
+
} else {
|
|
1639
|
+
Expr::Ident("globDynamicComponentEntry".into())
|
|
1640
|
+
};
|
|
1641
|
+
|
|
1642
|
+
let snapshot_dynamic_parts_def: Expr = match (target, snapshot_dynamic_part_def.len()) {
|
|
1643
|
+
(TransformTarget::JS, _) | (_, 0) => Expr::Lit(Lit::Null(Null { span: DUMMY_SP })),
|
|
1644
|
+
_ => Expr::Array(ArrayLit {
|
|
1645
|
+
span: DUMMY_SP,
|
|
1646
|
+
elems: snapshot_dynamic_part_def,
|
|
1647
|
+
}),
|
|
1648
|
+
};
|
|
1649
|
+
let snapshot_dynamic_parts_def_mt: Expr = match snapshot_dynamic_part_def_mt.len() {
|
|
1650
|
+
0 => Expr::Lit(Lit::Null(Null { span: DUMMY_SP })),
|
|
1651
|
+
_ => Expr::Array(ArrayLit {
|
|
1652
|
+
span: DUMMY_SP,
|
|
1653
|
+
elems: snapshot_dynamic_part_def_mt,
|
|
1654
|
+
}),
|
|
1655
|
+
};
|
|
1656
|
+
let css_id: Expr = match &self.css_id_value {
|
|
1657
|
+
Some(css_id_expr) => css_id_expr.clone(),
|
|
1658
|
+
// We use `undefined` here since runtime will skip `__SetCSSId` when `cssId === undefined && entryName === undefined`
|
|
1659
|
+
None => Expr::Ident("undefined".into()),
|
|
1660
|
+
};
|
|
1661
|
+
let snapshot_refs_and_spread_index: Expr = match snapshot_refs_and_spread_index.len() {
|
|
1662
|
+
0 => Expr::Lit(Lit::Null(Null { span: DUMMY_SP })),
|
|
1663
|
+
_ => Expr::Array(ArrayLit {
|
|
1664
|
+
span: DUMMY_SP,
|
|
1665
|
+
elems: snapshot_refs_and_spread_index,
|
|
1666
|
+
}),
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
let snapshot_create_call_mt = snapshot_creator_mt.map(|snapshot_creator_mt| {
|
|
1670
|
+
build_snapshot_registration(
|
|
1671
|
+
self.dev_creator_param,
|
|
1672
|
+
self.runtime_id.clone(),
|
|
1673
|
+
creator_runtime_expr.clone(),
|
|
1674
|
+
creator_runtime_id.clone(),
|
|
1675
|
+
snapshot_id.clone(),
|
|
1676
|
+
snapshot_creator_mt,
|
|
1677
|
+
snapshot_dynamic_parts_def_mt,
|
|
1678
|
+
slot_expr.clone(),
|
|
1679
|
+
css_id.clone(),
|
|
1680
|
+
entry_name.clone(),
|
|
1681
|
+
snapshot_refs_and_spread_index.clone(),
|
|
1682
|
+
)
|
|
1683
|
+
});
|
|
1684
|
+
let snapshot_create_call = build_snapshot_registration(
|
|
1685
|
+
self.dev_creator_param,
|
|
1686
|
+
self.runtime_id.clone(),
|
|
1687
|
+
creator_runtime_expr,
|
|
1688
|
+
creator_runtime_id,
|
|
1689
|
+
snapshot_id.clone(),
|
|
1690
|
+
snapshot_creator,
|
|
1691
|
+
snapshot_dynamic_parts_def,
|
|
1692
|
+
slot_expr,
|
|
1693
|
+
css_id,
|
|
1694
|
+
entry_name,
|
|
1695
|
+
snapshot_refs_and_spread_index,
|
|
1696
|
+
);
|
|
1697
|
+
|
|
1698
|
+
let mut entry_snapshot_uid = quote!("$snapshot_uid" as Expr, snapshot_uid: Expr = Expr::Lit(Lit::Str(snapshot_uid.clone().into())));
|
|
1699
|
+
if matches!(self.cfg.is_dynamic_component, Some(true)) {
|
|
1700
|
+
entry_snapshot_uid = quote!("`${globDynamicComponentEntry}:${$snapshot_uid}`" as Expr, snapshot_uid: Expr = Expr::Lit(Lit::Str(snapshot_uid.clone().into())));
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
let entry_snapshot_uid_def = ModuleItem::Stmt(quote!(
|
|
1704
|
+
r#"const $snapshot_id = $entry_snapshot_uid"#
|
|
1705
|
+
as Stmt,
|
|
1706
|
+
snapshot_id = snapshot_id.clone(),
|
|
1707
|
+
entry_snapshot_uid: Expr = entry_snapshot_uid.clone(),
|
|
1708
|
+
));
|
|
1709
|
+
let snapshot_def = ModuleItem::Stmt(quote!(
|
|
1710
|
+
r#"$snapshot_create_call"#
|
|
1711
|
+
as Stmt,
|
|
1712
|
+
snapshot_create_call: Expr = snapshot_create_call,
|
|
1713
|
+
));
|
|
1714
|
+
|
|
1715
|
+
if let Some(snapshot_create_call_mt) = snapshot_create_call_mt {
|
|
1716
|
+
collect_define(
|
|
1717
|
+
&self.defines_collector,
|
|
1718
|
+
DefineKind::Snapshot,
|
|
1719
|
+
snapshot_uid,
|
|
1720
|
+
vec![
|
|
1721
|
+
entry_snapshot_uid_def.clone(),
|
|
1722
|
+
ModuleItem::Stmt(quote!(
|
|
1723
|
+
r#"$snapshot_create_call"# as Stmt,
|
|
1724
|
+
snapshot_create_call: Expr = snapshot_create_call_mt,
|
|
1725
|
+
)),
|
|
1726
|
+
],
|
|
1727
|
+
);
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
self.current_snapshot_id = Some(snapshot_id.clone());
|
|
1731
|
+
self.current_snapshot_defs.push(entry_snapshot_uid_def);
|
|
1732
|
+
self.current_snapshot_defs.push(snapshot_def);
|
|
1733
|
+
|
|
1734
|
+
*node =
|
|
1735
|
+
JSXElement {
|
|
1736
|
+
span: node.span(),
|
|
1737
|
+
opening: JSXOpeningElement {
|
|
1738
|
+
name: JSXElementName::Ident(snapshot_id.clone()),
|
|
1739
|
+
span: node.span,
|
|
1740
|
+
attrs: {
|
|
1741
|
+
if snapshot_values_has_attr {
|
|
1742
|
+
snapshot_attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr {
|
|
1743
|
+
span: DUMMY_SP,
|
|
1744
|
+
name: JSXAttrName::Ident(IdentName::new("values".into(), DUMMY_SP)),
|
|
1745
|
+
value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
1746
|
+
span: DUMMY_SP,
|
|
1747
|
+
expr: JSXExpr::Expr(Box::new(Expr::Array(ArrayLit {
|
|
1748
|
+
span: DUMMY_SP,
|
|
1749
|
+
elems: snapshot_values,
|
|
1750
|
+
}))),
|
|
1751
|
+
})),
|
|
1752
|
+
}))
|
|
1753
|
+
};
|
|
1754
|
+
if let Some(index) = list_item_platform_info_index {
|
|
1755
|
+
snapshot_attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr {
|
|
1756
|
+
span: DUMMY_SP,
|
|
1757
|
+
name: JSXAttrName::Ident(IdentName::new(
|
|
1758
|
+
"__listItemPlatformInfoIndex".into(),
|
|
1759
|
+
DUMMY_SP,
|
|
1760
|
+
)),
|
|
1761
|
+
value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
1762
|
+
span: DUMMY_SP,
|
|
1763
|
+
expr: JSXExpr::Expr(Box::new(i32_to_expr(&index))),
|
|
1764
|
+
})),
|
|
1765
|
+
}))
|
|
1766
|
+
}
|
|
1767
|
+
snapshot_attrs.extend(snapshot_children.iter_mut().enumerate().map(
|
|
1768
|
+
|(index, child)| {
|
|
1769
|
+
JSXAttrOrSpread::JSXAttr(JSXAttr {
|
|
1770
|
+
span: DUMMY_SP,
|
|
1771
|
+
name: JSXAttrName::Ident(IdentName::new(format!("${index}").into(), DUMMY_SP)),
|
|
1772
|
+
value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
|
|
1773
|
+
span: DUMMY_SP,
|
|
1774
|
+
expr: JSXExpr::Expr(Box::new(child.take())),
|
|
1775
|
+
})),
|
|
1776
|
+
})
|
|
1777
|
+
},
|
|
1778
|
+
));
|
|
1779
|
+
snapshot_attrs
|
|
1780
|
+
},
|
|
1781
|
+
self_closing: true,
|
|
1782
|
+
type_args: None,
|
|
1783
|
+
},
|
|
1784
|
+
children: vec![],
|
|
1785
|
+
closing: None,
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
|
|
1790
|
+
let mut new_items: Vec<ModuleItem> = Vec::with_capacity(n.len());
|
|
1791
|
+
for mut item in n.take() {
|
|
1792
|
+
item.visit_mut_with(self);
|
|
1793
|
+
new_items.extend(self.current_snapshot_defs.take());
|
|
1794
|
+
new_items.push(item);
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
if let Some(module_item) = &self.runtime_components_module_item {
|
|
1798
|
+
new_items.insert(0, module_item.clone());
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
*n = new_items;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
fn visit_mut_module(&mut self, n: &mut Module) {
|
|
1805
|
+
self.parse_directives(n.span);
|
|
1806
|
+
for item in &n.body {
|
|
1807
|
+
let span = item.span();
|
|
1808
|
+
self.parse_directives(span);
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
if self.css_id_value.is_none() && matches!(self.cfg.is_dynamic_component, Some(true)) {
|
|
1812
|
+
self.css_id_value = Some(Expr::Lit(Lit::Num(0.into())));
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
n.visit_mut_children_with(self);
|
|
1816
|
+
|
|
1817
|
+
if let Expr::Ident(runtime_id) = &*self.runtime_id {
|
|
1818
|
+
if self.snapshot_counter > 0 {
|
|
1819
|
+
prepend_stmt(
|
|
1820
|
+
&mut n.body,
|
|
1821
|
+
ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
|
|
1822
|
+
span: DUMMY_SP,
|
|
1823
|
+
specifiers: vec![ImportSpecifier::Namespace(ImportStarAsSpecifier {
|
|
1824
|
+
span: DUMMY_SP,
|
|
1825
|
+
local: runtime_id.clone(),
|
|
1826
|
+
})],
|
|
1827
|
+
src: Box::new(Str {
|
|
1828
|
+
span: DUMMY_SP,
|
|
1829
|
+
raw: None,
|
|
1830
|
+
value: self.cfg.runtime_pkg.clone().into(),
|
|
1831
|
+
}),
|
|
1832
|
+
type_only: Default::default(),
|
|
1833
|
+
// asserts: Default::default(),
|
|
1834
|
+
with: Default::default(),
|
|
1835
|
+
phase: ImportPhase::Evaluation,
|
|
1836
|
+
})),
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
// #[plugin_transform]
|
|
1844
|
+
// pub fn process_transform(program: Program, metadata: TransformPluginProgramMetadata) -> Program {
|
|
1845
|
+
// let filename = metadata
|
|
1846
|
+
// .get_context(&TransformPluginMetadataContextKind::Filename)
|
|
1847
|
+
// .unwrap();
|
|
1848
|
+
|
|
1849
|
+
// program.fold_with(&mut JSXTransformer {
|
|
1850
|
+
// // filename: "index.js".into(),
|
|
1851
|
+
// filename,
|
|
1852
|
+
// snapshot_counter: 0,
|
|
1853
|
+
// current_snapshot_defs: vec![],
|
|
1854
|
+
// })
|
|
1855
|
+
// }
|
|
1856
|
+
|
|
1857
|
+
#[cfg(test)]
|
|
1858
|
+
mod tests {
|
|
1859
|
+
use swc_core::{
|
|
1860
|
+
common::{comments::SingleThreadedComments, Mark},
|
|
1861
|
+
ecma::{
|
|
1862
|
+
parser::{EsSyntax, Syntax},
|
|
1863
|
+
transforms::{
|
|
1864
|
+
base::resolver,
|
|
1865
|
+
react,
|
|
1866
|
+
testing::{test, Tester},
|
|
1867
|
+
},
|
|
1868
|
+
visit::visit_mut_pass,
|
|
1869
|
+
},
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
use std::{cell::RefCell, rc::Rc};
|
|
1873
|
+
|
|
1874
|
+
use crate::JSXTransformer;
|
|
1875
|
+
use swc_plugins_shared::{
|
|
1876
|
+
defines::{DefineKind, DefinesCollector},
|
|
1877
|
+
target::TransformTarget,
|
|
1878
|
+
transform_mode::TransformMode,
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
#[test]
|
|
1882
|
+
fn should_collect_main_thread_defines_while_targeting_js() {
|
|
1883
|
+
Tester::run(|tester| {
|
|
1884
|
+
let top_level_mark = Mark::new();
|
|
1885
|
+
let unresolved_mark = Mark::new();
|
|
1886
|
+
let collector: DefinesCollector = Rc::new(RefCell::new(vec![]));
|
|
1887
|
+
|
|
1888
|
+
tester.apply_transform(
|
|
1889
|
+
(
|
|
1890
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
1891
|
+
visit_mut_pass(
|
|
1892
|
+
JSXTransformer::<&SingleThreadedComments>::new(
|
|
1893
|
+
super::JSXTransformerConfig {
|
|
1894
|
+
preserve_jsx: false,
|
|
1895
|
+
target: TransformTarget::JS,
|
|
1896
|
+
..Default::default()
|
|
1897
|
+
},
|
|
1898
|
+
None,
|
|
1899
|
+
TransformMode::Test,
|
|
1900
|
+
Some(tester.cm.clone()),
|
|
1901
|
+
)
|
|
1902
|
+
.with_defines_collector(collector.clone()),
|
|
1903
|
+
),
|
|
1904
|
+
),
|
|
1905
|
+
"input.js",
|
|
1906
|
+
Syntax::Es(EsSyntax {
|
|
1907
|
+
jsx: true,
|
|
1908
|
+
..Default::default()
|
|
1909
|
+
}),
|
|
1910
|
+
Some(true),
|
|
1911
|
+
r#"function App() { return <view><text>hi</text></view>; }"#,
|
|
1912
|
+
)?;
|
|
1913
|
+
|
|
1914
|
+
let defines = collector.borrow();
|
|
1915
|
+
assert_eq!(defines.len(), 1);
|
|
1916
|
+
assert_eq!(defines[0].kind, DefineKind::Snapshot);
|
|
1917
|
+
assert!(defines[0].id.starts_with("__snapshot_"));
|
|
1918
|
+
let collected = format!("{:?}", defines[0].items);
|
|
1919
|
+
assert!(collected.contains("__CreateView"));
|
|
1920
|
+
assert!(collected.contains("__CreateText"));
|
|
1921
|
+
|
|
1922
|
+
Ok(())
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
#[test]
|
|
1927
|
+
fn should_leave_the_emitted_code_unchanged_while_collecting() {
|
|
1928
|
+
Tester::run(|tester| {
|
|
1929
|
+
let comments = Rc::new(SingleThreadedComments::default());
|
|
1930
|
+
let source = r#"function App() { return <view><text>hi</text></view>; }"#;
|
|
1931
|
+
|
|
1932
|
+
let mut transform = |collector: Option<DefinesCollector>| {
|
|
1933
|
+
let top_level_mark = Mark::new();
|
|
1934
|
+
let unresolved_mark = Mark::new();
|
|
1935
|
+
let transformer = JSXTransformer::<&SingleThreadedComments>::new(
|
|
1936
|
+
super::JSXTransformerConfig {
|
|
1937
|
+
preserve_jsx: false,
|
|
1938
|
+
target: TransformTarget::JS,
|
|
1939
|
+
..Default::default()
|
|
1940
|
+
},
|
|
1941
|
+
None,
|
|
1942
|
+
TransformMode::Test,
|
|
1943
|
+
Some(tester.cm.clone()),
|
|
1944
|
+
);
|
|
1945
|
+
let transformer = match collector {
|
|
1946
|
+
Some(collector) => transformer.with_defines_collector(collector),
|
|
1947
|
+
None => transformer,
|
|
1948
|
+
};
|
|
1949
|
+
|
|
1950
|
+
tester
|
|
1951
|
+
.apply_transform(
|
|
1952
|
+
(
|
|
1953
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
1954
|
+
visit_mut_pass(transformer),
|
|
1955
|
+
),
|
|
1956
|
+
"input.js",
|
|
1957
|
+
Syntax::Es(EsSyntax {
|
|
1958
|
+
jsx: true,
|
|
1959
|
+
..Default::default()
|
|
1960
|
+
}),
|
|
1961
|
+
Some(true),
|
|
1962
|
+
source,
|
|
1963
|
+
)
|
|
1964
|
+
.map(|program| tester.print(&program, &comments))
|
|
1965
|
+
};
|
|
1966
|
+
|
|
1967
|
+
let emitted = transform(None)?;
|
|
1968
|
+
let emitted_while_collecting = transform(Some(Rc::new(RefCell::new(vec![]))))?;
|
|
1969
|
+
|
|
1970
|
+
assert_eq!(emitted, emitted_while_collecting);
|
|
1971
|
+
|
|
1972
|
+
Ok(())
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
#[test]
|
|
1977
|
+
fn should_keep_jsx_in_children_prop_map_callback_scope() {
|
|
1978
|
+
Tester::run(|tester| {
|
|
1979
|
+
let top_level_mark = Mark::new();
|
|
1980
|
+
let unresolved_mark = Mark::new();
|
|
1981
|
+
|
|
1982
|
+
let program = tester.apply_transform(
|
|
1983
|
+
(
|
|
1984
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
1985
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
1986
|
+
super::JSXTransformerConfig {
|
|
1987
|
+
preserve_jsx: false,
|
|
1988
|
+
target: TransformTarget::MIXED,
|
|
1989
|
+
..Default::default()
|
|
1990
|
+
},
|
|
1991
|
+
None,
|
|
1992
|
+
TransformMode::Test,
|
|
1993
|
+
Some(tester.cm.clone()),
|
|
1994
|
+
)),
|
|
1995
|
+
react::react::<&SingleThreadedComments>(
|
|
1996
|
+
tester.cm.clone(),
|
|
1997
|
+
None,
|
|
1998
|
+
react::Options {
|
|
1999
|
+
next: Some(false),
|
|
2000
|
+
runtime: Some(react::Runtime::Automatic),
|
|
2001
|
+
import_source: Some("@lynx-js/react".into()),
|
|
2002
|
+
pragma: None,
|
|
2003
|
+
pragma_frag: None,
|
|
2004
|
+
throw_if_namespace: None,
|
|
2005
|
+
development: Some(false),
|
|
2006
|
+
refresh: None,
|
|
2007
|
+
..Default::default()
|
|
2008
|
+
},
|
|
2009
|
+
top_level_mark,
|
|
2010
|
+
unresolved_mark,
|
|
2011
|
+
),
|
|
2012
|
+
),
|
|
2013
|
+
"input.js",
|
|
2014
|
+
Syntax::Es(EsSyntax {
|
|
2015
|
+
jsx: true,
|
|
2016
|
+
..Default::default()
|
|
2017
|
+
}),
|
|
2018
|
+
Some(true),
|
|
2019
|
+
r#"
|
|
2020
|
+
const render_data_array = ['1', '2', '3'];
|
|
2021
|
+
|
|
2022
|
+
export function App() {
|
|
2023
|
+
return (
|
|
2024
|
+
<view
|
|
2025
|
+
children={render_data_array.map((item, index123, array123) => (
|
|
2026
|
+
<text key={item}>{array123[index123]}</text>
|
|
2027
|
+
))}
|
|
2028
|
+
/>
|
|
2029
|
+
);
|
|
2030
|
+
}
|
|
2031
|
+
"#,
|
|
2032
|
+
)?;
|
|
2033
|
+
|
|
2034
|
+
let comments = tester.comments.clone();
|
|
2035
|
+
let output = tester.print(&program, &comments);
|
|
2036
|
+
assert!(
|
|
2037
|
+
output.contains("render_data_array.map((item, index123, array123)=>")
|
|
2038
|
+
&& output.contains("_jsx(\"text\""),
|
|
2039
|
+
"the JSX in children={{...}} should stay inside the map callback; output:\n{output}",
|
|
2040
|
+
);
|
|
2041
|
+
assert!(
|
|
2042
|
+
!output.contains("$0: array123[index123]"),
|
|
2043
|
+
"snapshot child slots must not capture map callback locals outside their scope; output:\n{output}",
|
|
2044
|
+
);
|
|
2045
|
+
|
|
2046
|
+
Ok(())
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
#[test]
|
|
2051
|
+
fn should_emit_list_item_platform_info_marker_without_repeating_values() {
|
|
2052
|
+
Tester::run(|tester| {
|
|
2053
|
+
let top_level_mark = Mark::new();
|
|
2054
|
+
let unresolved_mark = Mark::new();
|
|
2055
|
+
|
|
2056
|
+
let program = tester.apply_transform(
|
|
2057
|
+
(
|
|
2058
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2059
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
2060
|
+
super::JSXTransformerConfig {
|
|
2061
|
+
preserve_jsx: true,
|
|
2062
|
+
target: TransformTarget::MIXED,
|
|
2063
|
+
..Default::default()
|
|
2064
|
+
},
|
|
2065
|
+
None,
|
|
2066
|
+
TransformMode::Test,
|
|
2067
|
+
Some(tester.cm.clone()),
|
|
2068
|
+
)),
|
|
2069
|
+
),
|
|
2070
|
+
"input.js",
|
|
2071
|
+
Syntax::Es(EsSyntax {
|
|
2072
|
+
jsx: true,
|
|
2073
|
+
..Default::default()
|
|
2074
|
+
}),
|
|
2075
|
+
Some(true),
|
|
2076
|
+
r#"
|
|
2077
|
+
const node = (
|
|
2078
|
+
<list>
|
|
2079
|
+
<list-item item-key={getItemKey()} full-span />
|
|
2080
|
+
</list>
|
|
2081
|
+
);
|
|
2082
|
+
"#,
|
|
2083
|
+
)?;
|
|
2084
|
+
|
|
2085
|
+
let comments = tester.comments.clone();
|
|
2086
|
+
let output = tester.print(&program, &comments);
|
|
2087
|
+
assert!(
|
|
2088
|
+
output.contains("__listItemPlatformInfoIndex={0}"),
|
|
2089
|
+
"list-item snapshot JSX should carry the platform-info value index; output:\n{output}",
|
|
2090
|
+
);
|
|
2091
|
+
assert_eq!(
|
|
2092
|
+
output.matches("getItemKey").count(),
|
|
2093
|
+
1,
|
|
2094
|
+
"platform info marker must not duplicate dynamic expression evaluation; output:\n{output}",
|
|
2095
|
+
);
|
|
2096
|
+
|
|
2097
|
+
Ok(())
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
test!(
|
|
2102
|
+
module,
|
|
2103
|
+
Syntax::Es(EsSyntax {
|
|
2104
|
+
jsx: true,
|
|
2105
|
+
..Default::default()
|
|
2106
|
+
}),
|
|
2107
|
+
|t| {
|
|
2108
|
+
let unresolved_mark = Mark::new();
|
|
2109
|
+
let top_level_mark = Mark::new();
|
|
2110
|
+
|
|
2111
|
+
(
|
|
2112
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2113
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2114
|
+
super::JSXTransformerConfig {
|
|
2115
|
+
preserve_jsx: true,
|
|
2116
|
+
enable_ui_source_map: true,
|
|
2117
|
+
..Default::default()
|
|
2118
|
+
},
|
|
2119
|
+
Some(t.comments.clone()),
|
|
2120
|
+
TransformMode::Test,
|
|
2121
|
+
Some(t.cm.clone()),
|
|
2122
|
+
)),
|
|
2123
|
+
)
|
|
2124
|
+
},
|
|
2125
|
+
basic_full_static,
|
|
2126
|
+
// Input codes
|
|
2127
|
+
r#"
|
|
2128
|
+
<view>
|
|
2129
|
+
<text>!!!</text>
|
|
2130
|
+
<frame/>
|
|
2131
|
+
</view>
|
|
2132
|
+
"#
|
|
2133
|
+
);
|
|
2134
|
+
|
|
2135
|
+
test!(
|
|
2136
|
+
module,
|
|
2137
|
+
Syntax::Es(EsSyntax {
|
|
2138
|
+
jsx: true,
|
|
2139
|
+
..Default::default()
|
|
2140
|
+
}),
|
|
2141
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2142
|
+
super::JSXTransformerConfig {
|
|
2143
|
+
preserve_jsx: true,
|
|
2144
|
+
target: TransformTarget::MIXED,
|
|
2145
|
+
..Default::default()
|
|
2146
|
+
},
|
|
2147
|
+
Some(t.comments.clone()),
|
|
2148
|
+
TransformMode::Test,
|
|
2149
|
+
Some(t.cm.clone()),
|
|
2150
|
+
)),
|
|
2151
|
+
should_emit_list_item_platform_info_marker_for_non_zero_value_index,
|
|
2152
|
+
// Input codes
|
|
2153
|
+
r#"
|
|
2154
|
+
const node = (
|
|
2155
|
+
<view id={getViewId()}>
|
|
2156
|
+
<list-item item-key={getItemKey()} />
|
|
2157
|
+
</view>
|
|
2158
|
+
);
|
|
2159
|
+
"#
|
|
2160
|
+
);
|
|
2161
|
+
|
|
2162
|
+
test!(
|
|
2163
|
+
module,
|
|
2164
|
+
Syntax::Es(EsSyntax {
|
|
2165
|
+
jsx: true,
|
|
2166
|
+
..Default::default()
|
|
2167
|
+
}),
|
|
2168
|
+
|t| {
|
|
2169
|
+
let unresolved_mark = Mark::new();
|
|
2170
|
+
let top_level_mark = Mark::new();
|
|
2171
|
+
|
|
2172
|
+
(
|
|
2173
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2174
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2175
|
+
super::JSXTransformerConfig {
|
|
2176
|
+
preserve_jsx: true,
|
|
2177
|
+
target: TransformTarget::MIXED,
|
|
2178
|
+
..Default::default()
|
|
2179
|
+
},
|
|
2180
|
+
Some(t.comments.clone()),
|
|
2181
|
+
TransformMode::Test,
|
|
2182
|
+
Some(t.cm.clone()),
|
|
2183
|
+
)),
|
|
2184
|
+
)
|
|
2185
|
+
},
|
|
2186
|
+
should_emit_list_item_platform_info_marker_for_spread_props,
|
|
2187
|
+
// Input codes
|
|
2188
|
+
r#"
|
|
2189
|
+
const node = (
|
|
2190
|
+
<list>
|
|
2191
|
+
<list-item {...getProps()} />
|
|
2192
|
+
</list>
|
|
2193
|
+
);
|
|
2194
|
+
"#
|
|
2195
|
+
);
|
|
2196
|
+
|
|
2197
|
+
test!(
|
|
2198
|
+
module,
|
|
2199
|
+
Syntax::Es(EsSyntax {
|
|
2200
|
+
jsx: true,
|
|
2201
|
+
..Default::default()
|
|
2202
|
+
}),
|
|
2203
|
+
|t| {
|
|
2204
|
+
let unresolved_mark = Mark::new();
|
|
2205
|
+
let top_level_mark = Mark::new();
|
|
2206
|
+
|
|
2207
|
+
(
|
|
2208
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2209
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2210
|
+
super::JSXTransformerConfig {
|
|
2211
|
+
preserve_jsx: true,
|
|
2212
|
+
enable_ui_source_map: true,
|
|
2213
|
+
..Default::default()
|
|
2214
|
+
},
|
|
2215
|
+
Some(t.comments.clone()),
|
|
2216
|
+
TransformMode::Test,
|
|
2217
|
+
Some(t.cm.clone()),
|
|
2218
|
+
)),
|
|
2219
|
+
)
|
|
2220
|
+
},
|
|
2221
|
+
full_static_children_self_close,
|
|
2222
|
+
// Input codes
|
|
2223
|
+
r#"
|
|
2224
|
+
<view className="parent">
|
|
2225
|
+
<view className="child"/>
|
|
2226
|
+
<view className="child"/>
|
|
2227
|
+
</view>
|
|
2228
|
+
"#
|
|
2229
|
+
);
|
|
2230
|
+
|
|
2231
|
+
test!(
|
|
2232
|
+
module,
|
|
2233
|
+
Syntax::Es(EsSyntax {
|
|
2234
|
+
jsx: true,
|
|
2235
|
+
..Default::default()
|
|
2236
|
+
}),
|
|
2237
|
+
|t| {
|
|
2238
|
+
let unresolved_mark = Mark::new();
|
|
2239
|
+
let top_level_mark = Mark::new();
|
|
2240
|
+
|
|
2241
|
+
(
|
|
2242
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2243
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2244
|
+
super::JSXTransformerConfig {
|
|
2245
|
+
preserve_jsx: true,
|
|
2246
|
+
enable_ui_source_map: true,
|
|
2247
|
+
..Default::default()
|
|
2248
|
+
},
|
|
2249
|
+
Some(t.comments.clone()),
|
|
2250
|
+
TransformMode::Test,
|
|
2251
|
+
Some(t.cm.clone()),
|
|
2252
|
+
)),
|
|
2253
|
+
)
|
|
2254
|
+
},
|
|
2255
|
+
full_static_children_new_line,
|
|
2256
|
+
// Input codes
|
|
2257
|
+
r#"
|
|
2258
|
+
<view className="parent">
|
|
2259
|
+
<view className="child">
|
|
2260
|
+
</view>
|
|
2261
|
+
<view className="child">
|
|
2262
|
+
</view>
|
|
2263
|
+
</view>
|
|
2264
|
+
"#
|
|
2265
|
+
);
|
|
2266
|
+
|
|
2267
|
+
test!(
|
|
2268
|
+
module,
|
|
2269
|
+
Syntax::Es(EsSyntax {
|
|
2270
|
+
jsx: true,
|
|
2271
|
+
..Default::default()
|
|
2272
|
+
}),
|
|
2273
|
+
|t| {
|
|
2274
|
+
let unresolved_mark = Mark::new();
|
|
2275
|
+
let top_level_mark = Mark::new();
|
|
2276
|
+
|
|
2277
|
+
(
|
|
2278
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2279
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2280
|
+
super::JSXTransformerConfig {
|
|
2281
|
+
preserve_jsx: true,
|
|
2282
|
+
..Default::default()
|
|
2283
|
+
},
|
|
2284
|
+
Some(t.comments.clone()),
|
|
2285
|
+
TransformMode::Test,
|
|
2286
|
+
Some(t.cm.clone()),
|
|
2287
|
+
)),
|
|
2288
|
+
)
|
|
2289
|
+
},
|
|
2290
|
+
full_static_children_comments,
|
|
2291
|
+
// Input codes
|
|
2292
|
+
r#"
|
|
2293
|
+
<view className="parent">
|
|
2294
|
+
<view className="child">
|
|
2295
|
+
{/** foo */}
|
|
2296
|
+
</view>
|
|
2297
|
+
<view className="child">
|
|
2298
|
+
{/** bar */}
|
|
2299
|
+
</view>
|
|
2300
|
+
</view>
|
|
2301
|
+
"#
|
|
2302
|
+
);
|
|
2303
|
+
|
|
2304
|
+
test!(
|
|
2305
|
+
module,
|
|
2306
|
+
Syntax::Es(EsSyntax {
|
|
2307
|
+
jsx: true,
|
|
2308
|
+
..Default::default()
|
|
2309
|
+
}),
|
|
2310
|
+
|t| {
|
|
2311
|
+
let unresolved_mark = Mark::new();
|
|
2312
|
+
let top_level_mark = Mark::new();
|
|
2313
|
+
|
|
2314
|
+
(
|
|
2315
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2316
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2317
|
+
super::JSXTransformerConfig {
|
|
2318
|
+
preserve_jsx: true,
|
|
2319
|
+
..Default::default()
|
|
2320
|
+
},
|
|
2321
|
+
Some(t.comments.clone()),
|
|
2322
|
+
TransformMode::Test,
|
|
2323
|
+
Some(t.cm.clone()),
|
|
2324
|
+
)),
|
|
2325
|
+
)
|
|
2326
|
+
},
|
|
2327
|
+
full_static_children_map_jsx,
|
|
2328
|
+
// Input codes
|
|
2329
|
+
r#"
|
|
2330
|
+
<view className="parent">
|
|
2331
|
+
<view className="child">{[].map(() => null)}</view>
|
|
2332
|
+
<view className="child">{[].map(() => null)}</view>
|
|
2333
|
+
</view>
|
|
2334
|
+
"#
|
|
2335
|
+
);
|
|
2336
|
+
|
|
2337
|
+
test!(
|
|
2338
|
+
module,
|
|
2339
|
+
Syntax::Es(EsSyntax {
|
|
2340
|
+
jsx: true,
|
|
2341
|
+
..Default::default()
|
|
2342
|
+
}),
|
|
2343
|
+
|t| {
|
|
2344
|
+
let unresolved_mark = Mark::new();
|
|
2345
|
+
let top_level_mark = Mark::new();
|
|
2346
|
+
|
|
2347
|
+
(
|
|
2348
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2349
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2350
|
+
super::JSXTransformerConfig {
|
|
2351
|
+
preserve_jsx: true,
|
|
2352
|
+
..Default::default()
|
|
2353
|
+
},
|
|
2354
|
+
Some(t.comments.clone()),
|
|
2355
|
+
TransformMode::Test,
|
|
2356
|
+
Some(t.cm.clone()),
|
|
2357
|
+
)),
|
|
2358
|
+
)
|
|
2359
|
+
},
|
|
2360
|
+
basic_full_static_snapshot_extract,
|
|
2361
|
+
// Input codes
|
|
2362
|
+
r#"let s = __SNAPSHOT__(<view><text>!!!</text></view>);"#
|
|
2363
|
+
);
|
|
2364
|
+
|
|
2365
|
+
test!(
|
|
2366
|
+
module,
|
|
2367
|
+
Syntax::Es(EsSyntax {
|
|
2368
|
+
jsx: true,
|
|
2369
|
+
..Default::default()
|
|
2370
|
+
}),
|
|
2371
|
+
|t| {
|
|
2372
|
+
let unresolved_mark = Mark::new();
|
|
2373
|
+
let top_level_mark = Mark::new();
|
|
2374
|
+
|
|
2375
|
+
(
|
|
2376
|
+
resolver(unresolved_mark, top_level_mark, true),
|
|
2377
|
+
visit_mut_pass(JSXTransformer::new(
|
|
2378
|
+
super::JSXTransformerConfig {
|
|
2379
|
+
preserve_jsx: true,
|
|
2380
|
+
..Default::default()
|
|
2381
|
+
},
|
|
2382
|
+
Some(t.comments.clone()),
|
|
2383
|
+
TransformMode::Test,
|
|
2384
|
+
Some(t.cm.clone()),
|
|
2385
|
+
)),
|
|
2386
|
+
)
|
|
2387
|
+
},
|
|
2388
|
+
basic_full_static_snapshot_extract_it,
|
|
2389
|
+
// Input codes
|
|
2390
|
+
r#"
|
|
2391
|
+
it('basic', async function() {
|
|
2392
|
+
const run = withEnv(function() {
|
|
2393
|
+
let s = __SNAPSHOT__(<view><text>!!!</text></view>);
|
|
2394
|
+
});
|
|
2395
|
+
await run();
|
|
2396
|
+
});
|
|
2397
|
+
"#
|
|
2398
|
+
);
|
|
2399
|
+
|
|
2400
|
+
test!(
|
|
2401
|
+
module,
|
|
2402
|
+
Syntax::Es(EsSyntax {
|
|
2403
|
+
jsx: true,
|
|
2404
|
+
..Default::default()
|
|
2405
|
+
}),
|
|
2406
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2407
|
+
super::JSXTransformerConfig {
|
|
2408
|
+
preserve_jsx: true,
|
|
2409
|
+
..Default::default()
|
|
2410
|
+
},
|
|
2411
|
+
Some(t.comments.clone()),
|
|
2412
|
+
TransformMode::Test,
|
|
2413
|
+
Some(t.cm.clone()),
|
|
2414
|
+
)),
|
|
2415
|
+
basic_component,
|
|
2416
|
+
// Input codes
|
|
2417
|
+
r#"
|
|
2418
|
+
<view>
|
|
2419
|
+
<A/>
|
|
2420
|
+
</view>
|
|
2421
|
+
"#
|
|
2422
|
+
);
|
|
2423
|
+
|
|
2424
|
+
test!(
|
|
2425
|
+
module,
|
|
2426
|
+
Syntax::Es(EsSyntax {
|
|
2427
|
+
jsx: true,
|
|
2428
|
+
..Default::default()
|
|
2429
|
+
}),
|
|
2430
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2431
|
+
super::JSXTransformerConfig {
|
|
2432
|
+
preserve_jsx: true,
|
|
2433
|
+
..Default::default()
|
|
2434
|
+
},
|
|
2435
|
+
Some(t.comments.clone()),
|
|
2436
|
+
TransformMode::Test,
|
|
2437
|
+
Some(t.cm.clone()),
|
|
2438
|
+
)),
|
|
2439
|
+
page_component,
|
|
2440
|
+
// Input codes
|
|
2441
|
+
r#"
|
|
2442
|
+
<Page custom-key-str="custom-value" custom-key-var={customVariable} class="classValue" data-attr={dataAttr}>
|
|
2443
|
+
<view>
|
|
2444
|
+
<Page/>
|
|
2445
|
+
<A/>
|
|
2446
|
+
</view>
|
|
2447
|
+
</Page>
|
|
2448
|
+
"#
|
|
2449
|
+
);
|
|
2450
|
+
|
|
2451
|
+
test!(
|
|
2452
|
+
module,
|
|
2453
|
+
Syntax::Es(EsSyntax {
|
|
2454
|
+
jsx: true,
|
|
2455
|
+
..Default::default()
|
|
2456
|
+
}),
|
|
2457
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2458
|
+
super::JSXTransformerConfig {
|
|
2459
|
+
preserve_jsx: true,
|
|
2460
|
+
..Default::default()
|
|
2461
|
+
},
|
|
2462
|
+
Some(t.comments.clone()),
|
|
2463
|
+
TransformMode::Development,
|
|
2464
|
+
Some(t.cm.clone()),
|
|
2465
|
+
)),
|
|
2466
|
+
page_element_dev,
|
|
2467
|
+
// Input codes
|
|
2468
|
+
r#"
|
|
2469
|
+
<page custom-key-str="custom-value" custom-key-var={customVariable} class="classValue" data-attr={dataAttr}>
|
|
2470
|
+
<view>
|
|
2471
|
+
<page />
|
|
2472
|
+
<A/>
|
|
2473
|
+
</view>
|
|
2474
|
+
</page>
|
|
2475
|
+
"#
|
|
2476
|
+
);
|
|
2477
|
+
|
|
2478
|
+
test!(
|
|
2479
|
+
module,
|
|
2480
|
+
Syntax::Es(EsSyntax {
|
|
2481
|
+
jsx: true,
|
|
2482
|
+
..Default::default()
|
|
2483
|
+
}),
|
|
2484
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2485
|
+
super::JSXTransformerConfig {
|
|
2486
|
+
preserve_jsx: true,
|
|
2487
|
+
..Default::default()
|
|
2488
|
+
},
|
|
2489
|
+
Some(t.comments.clone()),
|
|
2490
|
+
TransformMode::Test,
|
|
2491
|
+
Some(t.cm.clone()),
|
|
2492
|
+
)),
|
|
2493
|
+
page_element,
|
|
2494
|
+
// Input codes
|
|
2495
|
+
r#"
|
|
2496
|
+
<page custom-key-str="custom-value" custom-key-var={customVariable} class="classValue" data-attr={dataAttr}>
|
|
2497
|
+
<view>
|
|
2498
|
+
<page />
|
|
2499
|
+
<A/>
|
|
2500
|
+
</view>
|
|
2501
|
+
</page>
|
|
2502
|
+
"#
|
|
2503
|
+
);
|
|
2504
|
+
|
|
2505
|
+
test!(
|
|
2506
|
+
module,
|
|
2507
|
+
Syntax::Es(EsSyntax {
|
|
2508
|
+
jsx: true,
|
|
2509
|
+
..Default::default()
|
|
2510
|
+
}),
|
|
2511
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2512
|
+
super::JSXTransformerConfig {
|
|
2513
|
+
preserve_jsx: true,
|
|
2514
|
+
..Default::default()
|
|
2515
|
+
},
|
|
2516
|
+
Some(t.comments.clone()),
|
|
2517
|
+
TransformMode::Test,
|
|
2518
|
+
Some(t.cm.clone()),
|
|
2519
|
+
)),
|
|
2520
|
+
basic_component_with_static_sibling,
|
|
2521
|
+
// Input codes
|
|
2522
|
+
r#"
|
|
2523
|
+
<view>
|
|
2524
|
+
<text>!!!</text>
|
|
2525
|
+
<A/>
|
|
2526
|
+
</view>
|
|
2527
|
+
"#
|
|
2528
|
+
);
|
|
2529
|
+
|
|
2530
|
+
test!(
|
|
2531
|
+
module,
|
|
2532
|
+
Syntax::Es(EsSyntax {
|
|
2533
|
+
jsx: true,
|
|
2534
|
+
..Default::default()
|
|
2535
|
+
}),
|
|
2536
|
+
|t| {
|
|
2537
|
+
let top_level_mark = Mark::new();
|
|
2538
|
+
let unresolved_mark = Mark::new();
|
|
2539
|
+
(
|
|
2540
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
2541
|
+
super::JSXTransformerConfig {
|
|
2542
|
+
preserve_jsx: false,
|
|
2543
|
+
..Default::default()
|
|
2544
|
+
},
|
|
2545
|
+
None,
|
|
2546
|
+
TransformMode::Test,
|
|
2547
|
+
Some(t.cm.clone()),
|
|
2548
|
+
)),
|
|
2549
|
+
react::react::<&SingleThreadedComments>(
|
|
2550
|
+
t.cm.clone(),
|
|
2551
|
+
None,
|
|
2552
|
+
react::Options {
|
|
2553
|
+
next: Some(false),
|
|
2554
|
+
runtime: Some(react::Runtime::Automatic),
|
|
2555
|
+
import_source: Some("@lynx-js/react".into()),
|
|
2556
|
+
pragma: None,
|
|
2557
|
+
pragma_frag: None,
|
|
2558
|
+
throw_if_namespace: None,
|
|
2559
|
+
development: Some(false),
|
|
2560
|
+
refresh: None,
|
|
2561
|
+
..Default::default()
|
|
2562
|
+
},
|
|
2563
|
+
top_level_mark,
|
|
2564
|
+
unresolved_mark,
|
|
2565
|
+
),
|
|
2566
|
+
)
|
|
2567
|
+
},
|
|
2568
|
+
basic_component_with_static_sibling_jsx,
|
|
2569
|
+
// Input codes
|
|
2570
|
+
r#"
|
|
2571
|
+
<view>
|
|
2572
|
+
<text>!!!</text>
|
|
2573
|
+
<A/>
|
|
2574
|
+
</view>
|
|
2575
|
+
"#
|
|
2576
|
+
);
|
|
2577
|
+
|
|
2578
|
+
test!(
|
|
2579
|
+
module,
|
|
2580
|
+
Syntax::Es(EsSyntax {
|
|
2581
|
+
jsx: true,
|
|
2582
|
+
..Default::default()
|
|
2583
|
+
}),
|
|
2584
|
+
|t| {
|
|
2585
|
+
let top_level_mark = Mark::new();
|
|
2586
|
+
let unresolved_mark = Mark::new();
|
|
2587
|
+
(
|
|
2588
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
2589
|
+
super::JSXTransformerConfig {
|
|
2590
|
+
preserve_jsx: false,
|
|
2591
|
+
..Default::default()
|
|
2592
|
+
},
|
|
2593
|
+
None,
|
|
2594
|
+
TransformMode::Test,
|
|
2595
|
+
Some(t.cm.clone()),
|
|
2596
|
+
)),
|
|
2597
|
+
react::react::<&SingleThreadedComments>(
|
|
2598
|
+
t.cm.clone(),
|
|
2599
|
+
None,
|
|
2600
|
+
react::Options {
|
|
2601
|
+
next: Some(false),
|
|
2602
|
+
runtime: Some(react::Runtime::Automatic),
|
|
2603
|
+
import_source: Some("@lynx-js/react".into()),
|
|
2604
|
+
pragma: None,
|
|
2605
|
+
pragma_frag: None,
|
|
2606
|
+
throw_if_namespace: None,
|
|
2607
|
+
development: Some(true),
|
|
2608
|
+
refresh: None,
|
|
2609
|
+
..Default::default()
|
|
2610
|
+
},
|
|
2611
|
+
top_level_mark,
|
|
2612
|
+
unresolved_mark,
|
|
2613
|
+
),
|
|
2614
|
+
)
|
|
2615
|
+
},
|
|
2616
|
+
basic_component_with_static_sibling_jsx_dev,
|
|
2617
|
+
// Input codes
|
|
2618
|
+
r#"
|
|
2619
|
+
<view>
|
|
2620
|
+
<text>!!!</text>
|
|
2621
|
+
<A/>
|
|
2622
|
+
</view>
|
|
2623
|
+
"#
|
|
2624
|
+
);
|
|
2625
|
+
|
|
2626
|
+
test!(
|
|
2627
|
+
module,
|
|
2628
|
+
Syntax::Es(EsSyntax {
|
|
2629
|
+
jsx: true,
|
|
2630
|
+
..Default::default()
|
|
2631
|
+
}),
|
|
2632
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2633
|
+
super::JSXTransformerConfig {
|
|
2634
|
+
preserve_jsx: true,
|
|
2635
|
+
..Default::default()
|
|
2636
|
+
},
|
|
2637
|
+
Some(t.comments.clone()),
|
|
2638
|
+
TransformMode::Test,
|
|
2639
|
+
Some(t.cm.clone()),
|
|
2640
|
+
)),
|
|
2641
|
+
basic_expr_container,
|
|
2642
|
+
// Input codes
|
|
2643
|
+
r#"
|
|
2644
|
+
<view>
|
|
2645
|
+
{a}
|
|
2646
|
+
</view>
|
|
2647
|
+
"#
|
|
2648
|
+
);
|
|
2649
|
+
|
|
2650
|
+
test!(
|
|
2651
|
+
module,
|
|
2652
|
+
Syntax::Es(EsSyntax {
|
|
2653
|
+
jsx: true,
|
|
2654
|
+
..Default::default()
|
|
2655
|
+
}),
|
|
2656
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2657
|
+
super::JSXTransformerConfig {
|
|
2658
|
+
preserve_jsx: true,
|
|
2659
|
+
..Default::default()
|
|
2660
|
+
},
|
|
2661
|
+
Some(t.comments.clone()),
|
|
2662
|
+
TransformMode::Test,
|
|
2663
|
+
Some(t.cm.clone()),
|
|
2664
|
+
)),
|
|
2665
|
+
basic_expr_container_with_static_sibling,
|
|
2666
|
+
// Input codes
|
|
2667
|
+
r#"
|
|
2668
|
+
<view>
|
|
2669
|
+
<text>!!!</text>
|
|
2670
|
+
{a}
|
|
2671
|
+
</view>
|
|
2672
|
+
"#
|
|
2673
|
+
);
|
|
2674
|
+
|
|
2675
|
+
test!(
|
|
2676
|
+
module,
|
|
2677
|
+
Syntax::Es(EsSyntax {
|
|
2678
|
+
jsx: true,
|
|
2679
|
+
..Default::default()
|
|
2680
|
+
}),
|
|
2681
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2682
|
+
super::JSXTransformerConfig {
|
|
2683
|
+
preserve_jsx: true,
|
|
2684
|
+
..Default::default()
|
|
2685
|
+
},
|
|
2686
|
+
Some(t.comments.clone()),
|
|
2687
|
+
TransformMode::Test,
|
|
2688
|
+
Some(t.cm.clone()),
|
|
2689
|
+
)),
|
|
2690
|
+
should_inject_implicit_flatten,
|
|
2691
|
+
// Input codes
|
|
2692
|
+
r#"
|
|
2693
|
+
<view>
|
|
2694
|
+
<view className={'commdityV1Wrapper'}>
|
|
2695
|
+
<view id={id} className={'dotComm'} />
|
|
2696
|
+
<view className={'commdityV1TextWrapper'}>
|
|
2697
|
+
<view className={'commdityV1TextVerticalWrapper'}>
|
|
2698
|
+
<ItemTextWithTag/>
|
|
2699
|
+
{desc}
|
|
2700
|
+
</view>
|
|
2701
|
+
{unit}
|
|
2702
|
+
</view>
|
|
2703
|
+
{unit}
|
|
2704
|
+
{unit}
|
|
2705
|
+
</view>
|
|
2706
|
+
</view>;
|
|
2707
|
+
"#
|
|
2708
|
+
);
|
|
2709
|
+
|
|
2710
|
+
test!(
|
|
2711
|
+
module,
|
|
2712
|
+
Syntax::Es(EsSyntax {
|
|
2713
|
+
jsx: true,
|
|
2714
|
+
..Default::default()
|
|
2715
|
+
}),
|
|
2716
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2717
|
+
super::JSXTransformerConfig {
|
|
2718
|
+
preserve_jsx: true,
|
|
2719
|
+
..Default::default()
|
|
2720
|
+
},
|
|
2721
|
+
Some(t.comments.clone()),
|
|
2722
|
+
TransformMode::Test,
|
|
2723
|
+
Some(t.cm.clone()),
|
|
2724
|
+
)),
|
|
2725
|
+
should_static_extract_inline_style,
|
|
2726
|
+
// Input codes
|
|
2727
|
+
r#"
|
|
2728
|
+
<view style={{
|
|
2729
|
+
backgroundColor: 'red',
|
|
2730
|
+
width: '100%',
|
|
2731
|
+
height: '100%',
|
|
2732
|
+
display: 'flex',
|
|
2733
|
+
justifyContent: 'center',
|
|
2734
|
+
alignItems: 'center',
|
|
2735
|
+
borderRadius: '50%',
|
|
2736
|
+
opacity: 0.5,
|
|
2737
|
+
}} />;
|
|
2738
|
+
<view style="background-color: red;" />;
|
|
2739
|
+
"#
|
|
2740
|
+
);
|
|
2741
|
+
|
|
2742
|
+
test!(
|
|
2743
|
+
module,
|
|
2744
|
+
Syntax::Es(EsSyntax {
|
|
2745
|
+
jsx: true,
|
|
2746
|
+
..Default::default()
|
|
2747
|
+
}),
|
|
2748
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2749
|
+
super::JSXTransformerConfig {
|
|
2750
|
+
preserve_jsx: true,
|
|
2751
|
+
..Default::default()
|
|
2752
|
+
},
|
|
2753
|
+
Some(t.comments.clone()),
|
|
2754
|
+
TransformMode::Test,
|
|
2755
|
+
Some(t.cm.clone()),
|
|
2756
|
+
)),
|
|
2757
|
+
should_static_extract_dynamic_inline_style,
|
|
2758
|
+
// Input codes
|
|
2759
|
+
r#"
|
|
2760
|
+
<view style={`background-color: red;`} />;
|
|
2761
|
+
<view style={`background-color: red; width: ${w};`} />;
|
|
2762
|
+
<view style={{backgroundColor: "red", width: w, height: "100rpx"}} />;
|
|
2763
|
+
<view style={{backgroundColor: "red", ...style}} />;
|
|
2764
|
+
"#
|
|
2765
|
+
);
|
|
2766
|
+
|
|
2767
|
+
test!(
|
|
2768
|
+
module,
|
|
2769
|
+
Syntax::Es(EsSyntax {
|
|
2770
|
+
jsx: true,
|
|
2771
|
+
..Default::default()
|
|
2772
|
+
}),
|
|
2773
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2774
|
+
super::JSXTransformerConfig {
|
|
2775
|
+
preserve_jsx: true,
|
|
2776
|
+
..Default::default()
|
|
2777
|
+
},
|
|
2778
|
+
Some(t.comments.clone()),
|
|
2779
|
+
TransformMode::Test,
|
|
2780
|
+
Some(t.cm.clone()),
|
|
2781
|
+
)),
|
|
2782
|
+
should_extract_css_id_without_css_id,
|
|
2783
|
+
// Input codes
|
|
2784
|
+
r#"
|
|
2785
|
+
<view style={`background-color: red;`} />;
|
|
2786
|
+
<view style={`background-color: red; width: ${w};`} />;
|
|
2787
|
+
<view style={{backgroundColor: "red", width: w, height: "100rpx"}} />;
|
|
2788
|
+
<view style={{backgroundColor: "red", ...style}} />;
|
|
2789
|
+
"#
|
|
2790
|
+
);
|
|
2791
|
+
|
|
2792
|
+
test!(
|
|
2793
|
+
module,
|
|
2794
|
+
Syntax::Es(EsSyntax {
|
|
2795
|
+
jsx: true,
|
|
2796
|
+
..Default::default()
|
|
2797
|
+
}),
|
|
2798
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2799
|
+
super::JSXTransformerConfig {
|
|
2800
|
+
preserve_jsx: true,
|
|
2801
|
+
..Default::default()
|
|
2802
|
+
},
|
|
2803
|
+
Some(t.comments.clone()),
|
|
2804
|
+
TransformMode::Test,
|
|
2805
|
+
Some(t.cm.clone()),
|
|
2806
|
+
)),
|
|
2807
|
+
should_extract_css_id,
|
|
2808
|
+
// Input codes
|
|
2809
|
+
r#"
|
|
2810
|
+
/**
|
|
2811
|
+
* @jsxCSSId 100
|
|
2812
|
+
*/
|
|
2813
|
+
<view style={`background-color: red;`} />;
|
|
2814
|
+
<view style={`background-color: red; width: ${w};`} />;
|
|
2815
|
+
<view style={{backgroundColor: "red", width: w, height: "100rpx"}} />;
|
|
2816
|
+
<view style={{backgroundColor: "red", ...style}} />;
|
|
2817
|
+
"#
|
|
2818
|
+
);
|
|
2819
|
+
|
|
2820
|
+
test!(
|
|
2821
|
+
module,
|
|
2822
|
+
Syntax::Es(EsSyntax {
|
|
2823
|
+
jsx: true,
|
|
2824
|
+
..Default::default()
|
|
2825
|
+
}),
|
|
2826
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2827
|
+
super::JSXTransformerConfig {
|
|
2828
|
+
preserve_jsx: true,
|
|
2829
|
+
is_dynamic_component: Some(true),
|
|
2830
|
+
..Default::default()
|
|
2831
|
+
},
|
|
2832
|
+
Some(t.comments.clone()),
|
|
2833
|
+
TransformMode::Test,
|
|
2834
|
+
Some(t.cm.clone()),
|
|
2835
|
+
)),
|
|
2836
|
+
should_extract_css_id_dynamic_component,
|
|
2837
|
+
// Input codes
|
|
2838
|
+
r#"
|
|
2839
|
+
/**
|
|
2840
|
+
* @jsxCSSId 100
|
|
2841
|
+
*/
|
|
2842
|
+
<view style={`background-color: red;`} />;
|
|
2843
|
+
<view style={`background-color: red; width: ${w};`} />;
|
|
2844
|
+
<view style={{backgroundColor: "red", width: w, height: "100rpx"}} />;
|
|
2845
|
+
<view style={{backgroundColor: "red", ...style}} />;
|
|
2846
|
+
"#
|
|
2847
|
+
);
|
|
2848
|
+
|
|
2849
|
+
// External bundles use the `"__Card__"` entry-name literal in `createSnapshot`.
|
|
2850
|
+
test!(
|
|
2851
|
+
module,
|
|
2852
|
+
Syntax::Es(EsSyntax {
|
|
2853
|
+
jsx: true,
|
|
2854
|
+
..Default::default()
|
|
2855
|
+
}),
|
|
2856
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2857
|
+
super::JSXTransformerConfig {
|
|
2858
|
+
is_external_bundle: Some(true),
|
|
2859
|
+
..Default::default()
|
|
2860
|
+
},
|
|
2861
|
+
Some(t.comments.clone()),
|
|
2862
|
+
TransformMode::Test,
|
|
2863
|
+
Some(t.cm.clone()),
|
|
2864
|
+
)),
|
|
2865
|
+
external_bundle_uses_card_entry_name,
|
|
2866
|
+
// Input codes
|
|
2867
|
+
r#"
|
|
2868
|
+
<view><text>hello</text></view>;
|
|
2869
|
+
"#
|
|
2870
|
+
);
|
|
2871
|
+
|
|
2872
|
+
test!(
|
|
2873
|
+
module,
|
|
2874
|
+
Syntax::Es(EsSyntax {
|
|
2875
|
+
jsx: true,
|
|
2876
|
+
..Default::default()
|
|
2877
|
+
}),
|
|
2878
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
2879
|
+
super::JSXTransformerConfig {
|
|
2880
|
+
preserve_jsx: true,
|
|
2881
|
+
is_dynamic_component: Some(true),
|
|
2882
|
+
..Default::default()
|
|
2883
|
+
},
|
|
2884
|
+
Some(t.comments.clone()),
|
|
2885
|
+
TransformMode::Test,
|
|
2886
|
+
Some(t.cm.clone()),
|
|
2887
|
+
)),
|
|
2888
|
+
should_extract_css_id_dynamic_component_without_css_id,
|
|
2889
|
+
// Input codes
|
|
2890
|
+
r#"
|
|
2891
|
+
<view style={`background-color: red;`} />;
|
|
2892
|
+
<view style={`background-color: red; width: ${w};`} />;
|
|
2893
|
+
<view style={{backgroundColor: "red", width: w, height: "100rpx"}} />;
|
|
2894
|
+
<view style={{backgroundColor: "red", ...style}} />;
|
|
2895
|
+
"#
|
|
2896
|
+
);
|
|
2897
|
+
|
|
2898
|
+
test!(
|
|
2899
|
+
module,
|
|
2900
|
+
Syntax::Es(EsSyntax {
|
|
2901
|
+
jsx: true,
|
|
2902
|
+
..Default::default()
|
|
2903
|
+
}),
|
|
2904
|
+
|t| {
|
|
2905
|
+
let top_level_mark = Mark::new();
|
|
2906
|
+
let unresolved_mark = Mark::new();
|
|
2907
|
+
(
|
|
2908
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
2909
|
+
super::JSXTransformerConfig {
|
|
2910
|
+
preserve_jsx: false,
|
|
2911
|
+
..Default::default()
|
|
2912
|
+
},
|
|
2913
|
+
None,
|
|
2914
|
+
TransformMode::Test,
|
|
2915
|
+
Some(t.cm.clone()),
|
|
2916
|
+
)),
|
|
2917
|
+
react::react::<&SingleThreadedComments>(
|
|
2918
|
+
t.cm.clone(),
|
|
2919
|
+
None,
|
|
2920
|
+
react::Options {
|
|
2921
|
+
next: Some(false),
|
|
2922
|
+
runtime: Some(react::Runtime::Automatic),
|
|
2923
|
+
import_source: Some("@lynx-js/react".into()),
|
|
2924
|
+
pragma: None,
|
|
2925
|
+
pragma_frag: None,
|
|
2926
|
+
throw_if_namespace: None,
|
|
2927
|
+
development: Some(false),
|
|
2928
|
+
refresh: None,
|
|
2929
|
+
..Default::default()
|
|
2930
|
+
},
|
|
2931
|
+
top_level_mark,
|
|
2932
|
+
unresolved_mark,
|
|
2933
|
+
),
|
|
2934
|
+
)
|
|
2935
|
+
},
|
|
2936
|
+
basic_spread,
|
|
2937
|
+
// Input codes
|
|
2938
|
+
r#"
|
|
2939
|
+
<view>
|
|
2940
|
+
<text before={"bbb"} {...obj} after={"aaa"}>!!!</text>
|
|
2941
|
+
</view>
|
|
2942
|
+
"#
|
|
2943
|
+
);
|
|
2944
|
+
|
|
2945
|
+
test!(
|
|
2946
|
+
module,
|
|
2947
|
+
Syntax::Es(EsSyntax {
|
|
2948
|
+
jsx: true,
|
|
2949
|
+
..Default::default()
|
|
2950
|
+
}),
|
|
2951
|
+
|t| {
|
|
2952
|
+
let top_level_mark = Mark::new();
|
|
2953
|
+
let unresolved_mark = Mark::new();
|
|
2954
|
+
(
|
|
2955
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
2956
|
+
super::JSXTransformerConfig {
|
|
2957
|
+
preserve_jsx: false,
|
|
2958
|
+
..Default::default()
|
|
2959
|
+
},
|
|
2960
|
+
None,
|
|
2961
|
+
TransformMode::Test,
|
|
2962
|
+
Some(t.cm.clone()),
|
|
2963
|
+
)),
|
|
2964
|
+
react::react::<&SingleThreadedComments>(
|
|
2965
|
+
t.cm.clone(),
|
|
2966
|
+
None,
|
|
2967
|
+
react::Options {
|
|
2968
|
+
next: Some(false),
|
|
2969
|
+
runtime: Some(react::Runtime::Automatic),
|
|
2970
|
+
import_source: Some("@lynx-js/react".into()),
|
|
2971
|
+
pragma: None,
|
|
2972
|
+
pragma_frag: None,
|
|
2973
|
+
throw_if_namespace: None,
|
|
2974
|
+
development: Some(false),
|
|
2975
|
+
refresh: None,
|
|
2976
|
+
..Default::default()
|
|
2977
|
+
},
|
|
2978
|
+
top_level_mark,
|
|
2979
|
+
unresolved_mark,
|
|
2980
|
+
),
|
|
2981
|
+
)
|
|
2982
|
+
},
|
|
2983
|
+
basic_spread_list_item,
|
|
2984
|
+
// Input codes
|
|
2985
|
+
r#"
|
|
2986
|
+
<list>
|
|
2987
|
+
<list-item key="hello" item-key="world" {...obj}>!!!</list-item>
|
|
2988
|
+
</list>
|
|
2989
|
+
"#
|
|
2990
|
+
);
|
|
2991
|
+
|
|
2992
|
+
test!(
|
|
2993
|
+
module,
|
|
2994
|
+
Syntax::Es(EsSyntax {
|
|
2995
|
+
jsx: true,
|
|
2996
|
+
..Default::default()
|
|
2997
|
+
}),
|
|
2998
|
+
|_| {
|
|
2999
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3000
|
+
super::JSXTransformerConfig {
|
|
3001
|
+
preserve_jsx: false,
|
|
3002
|
+
..Default::default()
|
|
3003
|
+
},
|
|
3004
|
+
None,
|
|
3005
|
+
TransformMode::Test,
|
|
3006
|
+
None,
|
|
3007
|
+
))
|
|
3008
|
+
},
|
|
3009
|
+
inline_style_literal,
|
|
3010
|
+
// Input codes
|
|
3011
|
+
r#"
|
|
3012
|
+
<view style={{ color: "red", 'height': "100px", flexShrink: 1 }}>
|
|
3013
|
+
</view>
|
|
3014
|
+
"#
|
|
3015
|
+
);
|
|
3016
|
+
|
|
3017
|
+
test!(
|
|
3018
|
+
module,
|
|
3019
|
+
Syntax::Es(EsSyntax {
|
|
3020
|
+
jsx: true,
|
|
3021
|
+
..Default::default()
|
|
3022
|
+
}),
|
|
3023
|
+
|_| {
|
|
3024
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3025
|
+
super::JSXTransformerConfig {
|
|
3026
|
+
preserve_jsx: false,
|
|
3027
|
+
..Default::default()
|
|
3028
|
+
},
|
|
3029
|
+
None,
|
|
3030
|
+
TransformMode::Test,
|
|
3031
|
+
None,
|
|
3032
|
+
))
|
|
3033
|
+
},
|
|
3034
|
+
inline_style_literal_unknown_property,
|
|
3035
|
+
// Input codes
|
|
3036
|
+
r#"
|
|
3037
|
+
<view style={{ unknown: "red", height: "100px", display: 'linear', 'unknown-foo': 'bar' }}>
|
|
3038
|
+
</view>
|
|
3039
|
+
"#
|
|
3040
|
+
);
|
|
3041
|
+
|
|
3042
|
+
test!(
|
|
3043
|
+
module,
|
|
3044
|
+
Syntax::Es(EsSyntax {
|
|
3045
|
+
jsx: true,
|
|
3046
|
+
..Default::default()
|
|
3047
|
+
}),
|
|
3048
|
+
|_| {
|
|
3049
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3050
|
+
super::JSXTransformerConfig {
|
|
3051
|
+
preserve_jsx: false,
|
|
3052
|
+
..Default::default()
|
|
3053
|
+
},
|
|
3054
|
+
None,
|
|
3055
|
+
TransformMode::Test,
|
|
3056
|
+
None,
|
|
3057
|
+
))
|
|
3058
|
+
},
|
|
3059
|
+
empty_module,
|
|
3060
|
+
// Input codes
|
|
3061
|
+
r#"
|
|
3062
|
+
console.log('hello, world')
|
|
3063
|
+
"#
|
|
3064
|
+
);
|
|
3065
|
+
|
|
3066
|
+
test!(
|
|
3067
|
+
module,
|
|
3068
|
+
Syntax::Es(EsSyntax {
|
|
3069
|
+
jsx: true,
|
|
3070
|
+
..Default::default()
|
|
3071
|
+
}),
|
|
3072
|
+
|_| {
|
|
3073
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3074
|
+
super::JSXTransformerConfig {
|
|
3075
|
+
preserve_jsx: false,
|
|
3076
|
+
runtime_pkg: "@lynx-js/react/internal".into(),
|
|
3077
|
+
..Default::default()
|
|
3078
|
+
},
|
|
3079
|
+
None,
|
|
3080
|
+
TransformMode::Development,
|
|
3081
|
+
None,
|
|
3082
|
+
))
|
|
3083
|
+
},
|
|
3084
|
+
mode_development_spread,
|
|
3085
|
+
// Input codes
|
|
3086
|
+
r#"
|
|
3087
|
+
<view {...{ style: { height: "100px" }}} main-thread:bindtap={xxx}>
|
|
3088
|
+
</view>
|
|
3089
|
+
"#
|
|
3090
|
+
);
|
|
3091
|
+
|
|
3092
|
+
test!(
|
|
3093
|
+
module,
|
|
3094
|
+
Syntax::Es(EsSyntax {
|
|
3095
|
+
jsx: true,
|
|
3096
|
+
..Default::default()
|
|
3097
|
+
}),
|
|
3098
|
+
|t| {
|
|
3099
|
+
let top_level_mark = Mark::new();
|
|
3100
|
+
let unresolved_mark = Mark::new();
|
|
3101
|
+
(
|
|
3102
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3103
|
+
super::JSXTransformerConfig {
|
|
3104
|
+
preserve_jsx: false,
|
|
3105
|
+
target: TransformTarget::MIXED,
|
|
3106
|
+
..Default::default()
|
|
3107
|
+
},
|
|
3108
|
+
None,
|
|
3109
|
+
TransformMode::Development,
|
|
3110
|
+
Some(t.cm.clone()),
|
|
3111
|
+
)),
|
|
3112
|
+
react::react::<&SingleThreadedComments>(
|
|
3113
|
+
t.cm.clone(),
|
|
3114
|
+
None,
|
|
3115
|
+
react::Options {
|
|
3116
|
+
next: Some(false),
|
|
3117
|
+
runtime: Some(react::Runtime::Automatic),
|
|
3118
|
+
import_source: Some("@lynx-js/react".into()),
|
|
3119
|
+
pragma: None,
|
|
3120
|
+
pragma_frag: None,
|
|
3121
|
+
throw_if_namespace: None,
|
|
3122
|
+
development: Some(false),
|
|
3123
|
+
refresh: None,
|
|
3124
|
+
..Default::default()
|
|
3125
|
+
},
|
|
3126
|
+
top_level_mark,
|
|
3127
|
+
unresolved_mark,
|
|
3128
|
+
),
|
|
3129
|
+
)
|
|
3130
|
+
},
|
|
3131
|
+
basic_event,
|
|
3132
|
+
// Input codes
|
|
3133
|
+
r#"
|
|
3134
|
+
function Comp() {
|
|
3135
|
+
const handleTap = () => {}
|
|
3136
|
+
return (
|
|
3137
|
+
<view>
|
|
3138
|
+
<text bindtap={handleTap}>1</text>
|
|
3139
|
+
</view>
|
|
3140
|
+
)
|
|
3141
|
+
}
|
|
3142
|
+
"#
|
|
3143
|
+
);
|
|
3144
|
+
|
|
3145
|
+
test!(
|
|
3146
|
+
module,
|
|
3147
|
+
Syntax::Es(EsSyntax {
|
|
3148
|
+
jsx: true,
|
|
3149
|
+
..Default::default()
|
|
3150
|
+
}),
|
|
3151
|
+
|t| {
|
|
3152
|
+
let top_level_mark = Mark::new();
|
|
3153
|
+
let unresolved_mark = Mark::new();
|
|
3154
|
+
(
|
|
3155
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3156
|
+
super::JSXTransformerConfig {
|
|
3157
|
+
preserve_jsx: false,
|
|
3158
|
+
target: TransformTarget::MIXED,
|
|
3159
|
+
..Default::default()
|
|
3160
|
+
},
|
|
3161
|
+
None,
|
|
3162
|
+
TransformMode::Development,
|
|
3163
|
+
Some(t.cm.clone()),
|
|
3164
|
+
)),
|
|
3165
|
+
react::react::<&SingleThreadedComments>(
|
|
3166
|
+
t.cm.clone(),
|
|
3167
|
+
None,
|
|
3168
|
+
react::Options {
|
|
3169
|
+
next: Some(false),
|
|
3170
|
+
runtime: Some(react::Runtime::Automatic),
|
|
3171
|
+
import_source: Some("@lynx-js/react".into()),
|
|
3172
|
+
pragma: None,
|
|
3173
|
+
pragma_frag: None,
|
|
3174
|
+
throw_if_namespace: None,
|
|
3175
|
+
development: Some(false),
|
|
3176
|
+
refresh: None,
|
|
3177
|
+
..Default::default()
|
|
3178
|
+
},
|
|
3179
|
+
top_level_mark,
|
|
3180
|
+
unresolved_mark,
|
|
3181
|
+
),
|
|
3182
|
+
)
|
|
3183
|
+
},
|
|
3184
|
+
basic_ref,
|
|
3185
|
+
// Input codes
|
|
3186
|
+
r#"
|
|
3187
|
+
function Comp() {
|
|
3188
|
+
const handleRef = () => {}
|
|
3189
|
+
return (
|
|
3190
|
+
<view>
|
|
3191
|
+
<text ref={handleRef}>1</text>
|
|
3192
|
+
<text bindtap={handleRef}>2</text>
|
|
3193
|
+
<text ref={handleRef}>3</text>
|
|
3194
|
+
</view>
|
|
3195
|
+
)
|
|
3196
|
+
}
|
|
3197
|
+
"#
|
|
3198
|
+
);
|
|
3199
|
+
|
|
3200
|
+
test!(
|
|
3201
|
+
module,
|
|
3202
|
+
Syntax::Es(EsSyntax {
|
|
3203
|
+
jsx: true,
|
|
3204
|
+
..Default::default()
|
|
3205
|
+
}),
|
|
3206
|
+
|t| {
|
|
3207
|
+
let top_level_mark = Mark::new();
|
|
3208
|
+
let unresolved_mark = Mark::new();
|
|
3209
|
+
(
|
|
3210
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3211
|
+
super::JSXTransformerConfig {
|
|
3212
|
+
preserve_jsx: false,
|
|
3213
|
+
target: TransformTarget::MIXED,
|
|
3214
|
+
..Default::default()
|
|
3215
|
+
},
|
|
3216
|
+
None,
|
|
3217
|
+
TransformMode::Development,
|
|
3218
|
+
Some(t.cm.clone()),
|
|
3219
|
+
)),
|
|
3220
|
+
react::react::<&SingleThreadedComments>(
|
|
3221
|
+
t.cm.clone(),
|
|
3222
|
+
None,
|
|
3223
|
+
react::Options {
|
|
3224
|
+
next: Some(false),
|
|
3225
|
+
runtime: Some(react::Runtime::Automatic),
|
|
3226
|
+
import_source: Some("@lynx-js/react".into()),
|
|
3227
|
+
pragma: None,
|
|
3228
|
+
pragma_frag: None,
|
|
3229
|
+
throw_if_namespace: None,
|
|
3230
|
+
development: Some(false),
|
|
3231
|
+
refresh: None,
|
|
3232
|
+
..Default::default()
|
|
3233
|
+
},
|
|
3234
|
+
top_level_mark,
|
|
3235
|
+
unresolved_mark,
|
|
3236
|
+
),
|
|
3237
|
+
)
|
|
3238
|
+
},
|
|
3239
|
+
worklet,
|
|
3240
|
+
// Input codes
|
|
3241
|
+
r#"
|
|
3242
|
+
function Comp() {
|
|
3243
|
+
const handleTap = () => {}
|
|
3244
|
+
const handleRef = () => {}
|
|
3245
|
+
return (
|
|
3246
|
+
<view>
|
|
3247
|
+
<text main-thread:bindtap={handleTap}>1</text>
|
|
3248
|
+
<text main-thread:ref={handleRef}>1</text>
|
|
3249
|
+
</view>
|
|
3250
|
+
)
|
|
3251
|
+
}
|
|
3252
|
+
"#
|
|
3253
|
+
);
|
|
3254
|
+
|
|
3255
|
+
test!(
|
|
3256
|
+
module,
|
|
3257
|
+
Syntax::Es(EsSyntax {
|
|
3258
|
+
jsx: true,
|
|
3259
|
+
..Default::default()
|
|
3260
|
+
}),
|
|
3261
|
+
|t| {
|
|
3262
|
+
let top_level_mark = Mark::new();
|
|
3263
|
+
let unresolved_mark = Mark::new();
|
|
3264
|
+
(
|
|
3265
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3266
|
+
super::JSXTransformerConfig {
|
|
3267
|
+
preserve_jsx: false,
|
|
3268
|
+
target: TransformTarget::MIXED,
|
|
3269
|
+
..Default::default()
|
|
3270
|
+
},
|
|
3271
|
+
None,
|
|
3272
|
+
TransformMode::Development,
|
|
3273
|
+
Some(t.cm.clone()),
|
|
3274
|
+
)),
|
|
3275
|
+
react::react::<&SingleThreadedComments>(
|
|
3276
|
+
t.cm.clone(),
|
|
3277
|
+
None,
|
|
3278
|
+
react::Options {
|
|
3279
|
+
next: Some(false),
|
|
3280
|
+
runtime: Some(react::Runtime::Automatic),
|
|
3281
|
+
import_source: Some("@lynx-js/react".into()),
|
|
3282
|
+
pragma: None,
|
|
3283
|
+
pragma_frag: None,
|
|
3284
|
+
throw_if_namespace: None,
|
|
3285
|
+
development: Some(false),
|
|
3286
|
+
refresh: None,
|
|
3287
|
+
..Default::default()
|
|
3288
|
+
},
|
|
3289
|
+
top_level_mark,
|
|
3290
|
+
unresolved_mark,
|
|
3291
|
+
),
|
|
3292
|
+
)
|
|
3293
|
+
},
|
|
3294
|
+
gesture,
|
|
3295
|
+
// Input codes
|
|
3296
|
+
r#"
|
|
3297
|
+
function Comp() {
|
|
3298
|
+
const gesture = {}
|
|
3299
|
+
return (
|
|
3300
|
+
<view>
|
|
3301
|
+
<text main-thread:gesture={gesture}>1</text>
|
|
3302
|
+
</view>
|
|
3303
|
+
)
|
|
3304
|
+
}
|
|
3305
|
+
"#
|
|
3306
|
+
);
|
|
3307
|
+
|
|
3308
|
+
test!(
|
|
3309
|
+
module,
|
|
3310
|
+
Syntax::Es(EsSyntax {
|
|
3311
|
+
jsx: true,
|
|
3312
|
+
..Default::default()
|
|
3313
|
+
}),
|
|
3314
|
+
|t| {
|
|
3315
|
+
let top_level_mark = Mark::new();
|
|
3316
|
+
let unresolved_mark = Mark::new();
|
|
3317
|
+
(
|
|
3318
|
+
visit_mut_pass(JSXTransformer::<&SingleThreadedComments>::new(
|
|
3319
|
+
super::JSXTransformerConfig {
|
|
3320
|
+
preserve_jsx: false,
|
|
3321
|
+
target: TransformTarget::MIXED,
|
|
3322
|
+
..Default::default()
|
|
3323
|
+
},
|
|
3324
|
+
None,
|
|
3325
|
+
TransformMode::Development,
|
|
3326
|
+
Some(t.cm.clone()),
|
|
3327
|
+
)),
|
|
3328
|
+
react::react::<&SingleThreadedComments>(
|
|
3329
|
+
t.cm.clone(),
|
|
3330
|
+
None,
|
|
3331
|
+
react::Options {
|
|
3332
|
+
next: Some(false),
|
|
3333
|
+
runtime: Some(react::Runtime::Automatic),
|
|
3334
|
+
import_source: Some("@lynx-js/react".into()),
|
|
3335
|
+
pragma: None,
|
|
3336
|
+
pragma_frag: None,
|
|
3337
|
+
throw_if_namespace: None,
|
|
3338
|
+
development: Some(false),
|
|
3339
|
+
refresh: None,
|
|
3340
|
+
..Default::default()
|
|
3341
|
+
},
|
|
3342
|
+
top_level_mark,
|
|
3343
|
+
unresolved_mark,
|
|
3344
|
+
),
|
|
3345
|
+
)
|
|
3346
|
+
},
|
|
3347
|
+
basic_timing_flag,
|
|
3348
|
+
// Input codes
|
|
3349
|
+
r#"
|
|
3350
|
+
function Comp() {
|
|
3351
|
+
return (
|
|
3352
|
+
<view>
|
|
3353
|
+
<text __lynx_timing_flag={'timing_flag'}>1</text>
|
|
3354
|
+
</view>
|
|
3355
|
+
)
|
|
3356
|
+
}
|
|
3357
|
+
"#
|
|
3358
|
+
);
|
|
3359
|
+
|
|
3360
|
+
test!(
|
|
3361
|
+
module,
|
|
3362
|
+
Syntax::Es(EsSyntax {
|
|
3363
|
+
jsx: true,
|
|
3364
|
+
..Default::default()
|
|
3365
|
+
}),
|
|
3366
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
3367
|
+
super::JSXTransformerConfig {
|
|
3368
|
+
preserve_jsx: true,
|
|
3369
|
+
..Default::default()
|
|
3370
|
+
},
|
|
3371
|
+
Some(t.comments.clone()),
|
|
3372
|
+
TransformMode::Test,
|
|
3373
|
+
Some(t.cm.clone()),
|
|
3374
|
+
)),
|
|
3375
|
+
should_escape_newline_character,
|
|
3376
|
+
// Input codes
|
|
3377
|
+
r#"
|
|
3378
|
+
<view>
|
|
3379
|
+
<view className="123
|
|
3380
|
+
456"></view>
|
|
3381
|
+
<view className="123
|
|
3382
|
+
456"></view>
|
|
3383
|
+
<view className="123
|
|
3384
|
+
|
|
3385
|
+
456"></view>
|
|
3386
|
+
<view className="123\n456"></view>
|
|
3387
|
+
<view className="123 456"></view>
|
|
3388
|
+
<view className="123 456"></view>
|
|
3389
|
+
<view className="123\t456"></view>
|
|
3390
|
+
<svg
|
|
3391
|
+
content='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
3392
|
+
<path d="M14.3723 11.9999L7.53902 5.16659C7.34376 4.97133 7.34376 4.65475 7.53902 4.45948L8.45826 3.54025C8.65353 3.34498 8.97011 3.34498 9.16537 3.54025L17.2714 11.6463C17.4667 11.8416 17.4667 12.1582 17.2714 12.3534L9.16537 20.4595C8.97011 20.6547 8.65353 20.6547 8.45826 20.4595L7.53902 19.5402C7.34376 19.345 7.34376 19.0284 7.53903 18.8331L14.3723 11.9999Z" fill="white"/>
|
|
3393
|
+
</svg>'
|
|
3394
|
+
style={{
|
|
3395
|
+
width: "24rpx",
|
|
3396
|
+
height: "24rpx",
|
|
3397
|
+
opacity: "0.4",
|
|
3398
|
+
}}
|
|
3399
|
+
id="x
|
|
3400
|
+
y"
|
|
3401
|
+
data-attr="x
|
|
3402
|
+
y"
|
|
3403
|
+
__lynx_timing_flag="
|
|
3404
|
+
aaaaa
|
|
3405
|
+
"
|
|
3406
|
+
></svg>
|
|
3407
|
+
</view>
|
|
3408
|
+
"#
|
|
3409
|
+
);
|
|
3410
|
+
|
|
3411
|
+
test!(
|
|
3412
|
+
module,
|
|
3413
|
+
Syntax::Es(EsSyntax {
|
|
3414
|
+
jsx: true,
|
|
3415
|
+
..Default::default()
|
|
3416
|
+
}),
|
|
3417
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
3418
|
+
super::JSXTransformerConfig {
|
|
3419
|
+
preserve_jsx: true,
|
|
3420
|
+
..Default::default()
|
|
3421
|
+
},
|
|
3422
|
+
Some(t.comments.clone()),
|
|
3423
|
+
TransformMode::Test,
|
|
3424
|
+
Some(t.cm.clone()),
|
|
3425
|
+
)),
|
|
3426
|
+
should_wrap_dynamic_key,
|
|
3427
|
+
// Input codes
|
|
3428
|
+
r#"
|
|
3429
|
+
<view>
|
|
3430
|
+
<text>Hello, ReactLynx, {hello}</text>
|
|
3431
|
+
<text key={hello}>{hello}</text>
|
|
3432
|
+
<text key="hello">{hello}</text>
|
|
3433
|
+
</view>
|
|
3434
|
+
"#
|
|
3435
|
+
);
|
|
3436
|
+
|
|
3437
|
+
test!(
|
|
3438
|
+
module,
|
|
3439
|
+
Syntax::Es(EsSyntax {
|
|
3440
|
+
jsx: true,
|
|
3441
|
+
..Default::default()
|
|
3442
|
+
}),
|
|
3443
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
3444
|
+
super::JSXTransformerConfig {
|
|
3445
|
+
preserve_jsx: true,
|
|
3446
|
+
..Default::default()
|
|
3447
|
+
},
|
|
3448
|
+
Some(t.comments.clone()),
|
|
3449
|
+
TransformMode::Test,
|
|
3450
|
+
Some(t.cm.clone()),
|
|
3451
|
+
)),
|
|
3452
|
+
should_set_attribute_for_text_node,
|
|
3453
|
+
// Input codes
|
|
3454
|
+
r#"
|
|
3455
|
+
<view>
|
|
3456
|
+
<text text="Hello World 0"></text>
|
|
3457
|
+
<text text=" "></text>
|
|
3458
|
+
<text></text>
|
|
3459
|
+
<text class="hello" text="Hello World 1"></text>
|
|
3460
|
+
<text {...attrs} text="Hello World 2"></text>
|
|
3461
|
+
<text text="Hello Lynx" text="Hello World 3"></text>
|
|
3462
|
+
</view>
|
|
3463
|
+
"#
|
|
3464
|
+
);
|
|
3465
|
+
|
|
3466
|
+
test!(
|
|
3467
|
+
module,
|
|
3468
|
+
Syntax::Es(EsSyntax {
|
|
3469
|
+
jsx: true,
|
|
3470
|
+
..Default::default()
|
|
3471
|
+
}),
|
|
3472
|
+
|t| visit_mut_pass(JSXTransformer::new(
|
|
3473
|
+
super::JSXTransformerConfig {
|
|
3474
|
+
preserve_jsx: true,
|
|
3475
|
+
..Default::default()
|
|
3476
|
+
},
|
|
3477
|
+
Some(t.comments.clone()),
|
|
3478
|
+
TransformMode::Test,
|
|
3479
|
+
Some(t.cm.clone()),
|
|
3480
|
+
)),
|
|
3481
|
+
should_create_raw_text_node_for_text_node,
|
|
3482
|
+
// Input codes
|
|
3483
|
+
r#"
|
|
3484
|
+
<view>
|
|
3485
|
+
<text>{hello}, ReactLynx 1</text>
|
|
3486
|
+
<text>{hello}</text>
|
|
3487
|
+
<text>
|
|
3488
|
+
Hello
|
|
3489
|
+
<text text="ReactLynx 2"></text>
|
|
3490
|
+
</text>
|
|
3491
|
+
<x-text>Hello, ReactLynx 3</x-text>
|
|
3492
|
+
</view>
|
|
3493
|
+
"#
|
|
3494
|
+
);
|
|
3495
|
+
}
|