@lynx-js/react 0.126.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 +16 -0
- package/LICENSE +202 -0
- package/components/.gitignore +3 -0
- package/components/.npmignore +5 -0
- package/components/tsconfig.json +17 -0
- package/components/tsconfig.tsbuildinfo +1 -0
- package/package.json +5 -1
- 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 +1 -1
- 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/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 +3 -1
- package/runtime/lib/element-template/background/attr-slots.js +5 -5
- 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/hydrate.js +19 -17
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +4 -4
- package/runtime/lib/element-template/background/instance.js +10 -10
- 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 +4 -4
- package/runtime/lib/element-template/debug/alog.js +8 -8
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +3 -1
- 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 +1 -2
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +3 -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/protocol/types.d.ts +27 -20
- 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/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 +35 -40
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -2
- 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 +1 -1
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +21 -21
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +10 -8
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +4 -4
- package/runtime/lib/element-template/runtime/template/handle.js +6 -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 +2 -2
- 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 +1 -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/shared/render-constants.d.ts +1 -0
- package/runtime/lib/shared/render-constants.js +1 -0
- package/runtime/lib/shared/render-constants.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +5 -3
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +18 -25
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.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/tsconfig.tsbuildinfo +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/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/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/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,2869 @@
|
|
|
1
|
+
mod decl_collect;
|
|
2
|
+
mod extract_ident;
|
|
3
|
+
mod gen_stmt;
|
|
4
|
+
mod globals;
|
|
5
|
+
mod hash;
|
|
6
|
+
mod worklet_type;
|
|
7
|
+
|
|
8
|
+
use extract_ident::{ExtractingIdentsCollector, ExtractingIdentsCollectorConfig};
|
|
9
|
+
use gen_stmt::StmtGen;
|
|
10
|
+
use hash::WorkletHash;
|
|
11
|
+
use rustc_hash::FxHashSet;
|
|
12
|
+
use serde::Deserialize;
|
|
13
|
+
use std::collections::HashSet;
|
|
14
|
+
use std::vec;
|
|
15
|
+
use swc_core::common::util::take::Take;
|
|
16
|
+
use swc_core::common::{errors::HANDLER, Span, Spanned, DUMMY_SP};
|
|
17
|
+
use swc_core::ecma::ast::*;
|
|
18
|
+
use swc_core::ecma::utils::{prepend_stmts, private_ident};
|
|
19
|
+
use swc_core::ecma::visit::VisitMutWith;
|
|
20
|
+
use swc_core::ecma::visit::{noop_visit_mut_type, VisitMut};
|
|
21
|
+
use swc_core::quote;
|
|
22
|
+
use worklet_type::WorkletType;
|
|
23
|
+
|
|
24
|
+
use swc_plugins_shared::{
|
|
25
|
+
defines::{collect_define, collect_unmergeable_define, DefineKind, DefinesCollector},
|
|
26
|
+
target::TransformTarget,
|
|
27
|
+
transform_mode::TransformMode,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
#[cfg(feature = "napi")]
|
|
31
|
+
pub mod napi;
|
|
32
|
+
|
|
33
|
+
#[derive(Deserialize, Clone, Debug, PartialEq)]
|
|
34
|
+
#[serde(rename_all = "camelCase")]
|
|
35
|
+
pub struct WorkletVisitorConfig {
|
|
36
|
+
/// @public
|
|
37
|
+
/// During the compilation of worklet, when extracting external variable identifiers,
|
|
38
|
+
/// global identifiers available in lepus context need to be ignored.
|
|
39
|
+
/// In addition to the default lepus global identifier list provided by the compiler,
|
|
40
|
+
/// users can customize the global identifier list through this option.
|
|
41
|
+
/// This configuration will take effect together with the default lepus global identifier list.
|
|
42
|
+
pub custom_global_ident_names: Option<Vec<String>>,
|
|
43
|
+
/// @internal
|
|
44
|
+
pub filename: String,
|
|
45
|
+
/// @internal
|
|
46
|
+
pub target: TransformTarget,
|
|
47
|
+
pub runtime_pkg: String,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
impl Default for WorkletVisitorConfig {
|
|
51
|
+
fn default() -> Self {
|
|
52
|
+
WorkletVisitorConfig {
|
|
53
|
+
filename: "index.js".into(),
|
|
54
|
+
target: TransformTarget::LEPUS,
|
|
55
|
+
custom_global_ident_names: None,
|
|
56
|
+
runtime_pkg: "NoDiff".into(),
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
pub struct WorkletVisitor {
|
|
62
|
+
mode: TransformMode,
|
|
63
|
+
content_hash: String,
|
|
64
|
+
cfg: WorkletVisitorConfig,
|
|
65
|
+
stmts_to_insert_at_top_level: Vec<Stmt>,
|
|
66
|
+
named_imports: HashSet<String>,
|
|
67
|
+
hasher: WorkletHash,
|
|
68
|
+
shared_identifiers: FxHashSet<Id>,
|
|
69
|
+
worklet_runtime_loaded: bool,
|
|
70
|
+
worklet_runtime_loaded_ident: Ident,
|
|
71
|
+
defines_collector: Option<DefinesCollector>,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
impl Default for WorkletVisitor {
|
|
75
|
+
fn default() -> Self {
|
|
76
|
+
WorkletVisitor::new(TransformMode::Production, WorkletVisitorConfig::default())
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
impl VisitMut for WorkletVisitor {
|
|
81
|
+
noop_visit_mut_type!();
|
|
82
|
+
|
|
83
|
+
fn visit_mut_class_member(&mut self, n: &mut ClassMember) {
|
|
84
|
+
match n {
|
|
85
|
+
ClassMember::Method(_) => {
|
|
86
|
+
if n.as_method().unwrap().kind != MethodKind::Method {
|
|
87
|
+
n.visit_mut_children_with(self);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let worklet_type = match n.as_mut_method().unwrap().function.body {
|
|
92
|
+
None => None,
|
|
93
|
+
Some(ref mut body) => self.check_is_worklet_block(body),
|
|
94
|
+
};
|
|
95
|
+
if worklet_type.is_none() {
|
|
96
|
+
n.visit_mut_children_with(self);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let mut collector = ExtractingIdentsCollector::new(ExtractingIdentsCollectorConfig {
|
|
101
|
+
custom_global_ident_names: self.cfg.custom_global_ident_names.clone(),
|
|
102
|
+
shared_identifiers: Some(self.shared_identifiers.clone()),
|
|
103
|
+
});
|
|
104
|
+
n.visit_mut_with(&mut collector);
|
|
105
|
+
|
|
106
|
+
let should_use_getter = self.cfg.target == TransformTarget::JS
|
|
107
|
+
&& !n.as_method().unwrap().is_static
|
|
108
|
+
&& (collector.has_extracted_this_props()
|
|
109
|
+
|| collector.has_extracted_values_props()
|
|
110
|
+
|| collector.has_extracted_js_fns());
|
|
111
|
+
|
|
112
|
+
let hash = self.hasher.gen(&self.cfg.filename, &self.content_hash);
|
|
113
|
+
let collect_main_thread = self.defines_collector.is_some();
|
|
114
|
+
let collected_hash = collect_main_thread.then(|| hash.clone());
|
|
115
|
+
let m = n.as_method().unwrap().clone();
|
|
116
|
+
let original_function = m.function.clone();
|
|
117
|
+
let (worklet_object_expr, register_worklet_stmt, main_thread_stmt) =
|
|
118
|
+
StmtGen::transform_worklet(
|
|
119
|
+
self.mode,
|
|
120
|
+
worklet_type.unwrap(),
|
|
121
|
+
hash,
|
|
122
|
+
self.cfg.target,
|
|
123
|
+
m.key
|
|
124
|
+
.clone()
|
|
125
|
+
.ident()
|
|
126
|
+
.unwrap_or(Ident::dummy().into())
|
|
127
|
+
.into(),
|
|
128
|
+
m.function,
|
|
129
|
+
&mut collector,
|
|
130
|
+
true,
|
|
131
|
+
&mut self.named_imports,
|
|
132
|
+
self.worklet_runtime_loaded_ident.clone(),
|
|
133
|
+
collect_main_thread,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// For JS worklets, the ctx object is later converted to a function by `transformWorklet(..)`
|
|
137
|
+
// and invoked with `this` bound to the ctx object (not the component instance). Therefore,
|
|
138
|
+
// extracted `this.xxx` values become snapshot-like values on the ctx.
|
|
139
|
+
//
|
|
140
|
+
// If we emit a class field initializer (`onTapLepus = { ... a: this.a }`), that snapshot is
|
|
141
|
+
// computed once during construction, and `this.a` inside the worklet will keep reading the
|
|
142
|
+
// old value from the ctx. To keep `this.xxx` in sync for class components, generate a
|
|
143
|
+
// getter so the ctx object is re-created whenever `this.onTapLepus` is read (e.g. each
|
|
144
|
+
// render).
|
|
145
|
+
if should_use_getter {
|
|
146
|
+
let mut getter_fn = (*original_function).clone();
|
|
147
|
+
getter_fn.params = vec![];
|
|
148
|
+
getter_fn.is_async = false;
|
|
149
|
+
getter_fn.is_generator = false;
|
|
150
|
+
getter_fn.type_params = None;
|
|
151
|
+
getter_fn.return_type = None;
|
|
152
|
+
getter_fn.body = Some(FunctionBody {
|
|
153
|
+
span: DUMMY_SP,
|
|
154
|
+
stmts: vec![ReturnStmt {
|
|
155
|
+
span: DUMMY_SP,
|
|
156
|
+
arg: Some(worklet_object_expr),
|
|
157
|
+
}
|
|
158
|
+
.into()],
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
*n = ClassMethod {
|
|
162
|
+
span: m.span,
|
|
163
|
+
key: m.key,
|
|
164
|
+
function: getter_fn.into(),
|
|
165
|
+
kind: MethodKind::Getter,
|
|
166
|
+
is_static: false,
|
|
167
|
+
accessibility: m.accessibility,
|
|
168
|
+
is_abstract: m.is_abstract,
|
|
169
|
+
is_optional: m.is_optional,
|
|
170
|
+
is_override: m.is_override,
|
|
171
|
+
}
|
|
172
|
+
.into();
|
|
173
|
+
} else {
|
|
174
|
+
*n = ClassProp {
|
|
175
|
+
span: m.span,
|
|
176
|
+
key: m.key,
|
|
177
|
+
value: worklet_object_expr.into(),
|
|
178
|
+
declare: false,
|
|
179
|
+
is_abstract: m.is_abstract,
|
|
180
|
+
decorators: vec![],
|
|
181
|
+
definite: false,
|
|
182
|
+
type_ann: None,
|
|
183
|
+
is_static: m.is_static,
|
|
184
|
+
accessibility: m.accessibility,
|
|
185
|
+
is_optional: m.is_optional,
|
|
186
|
+
is_override: m.is_override,
|
|
187
|
+
readonly: false,
|
|
188
|
+
}
|
|
189
|
+
.into();
|
|
190
|
+
}
|
|
191
|
+
self.collect_worklet_define(
|
|
192
|
+
collected_hash,
|
|
193
|
+
main_thread_stmt,
|
|
194
|
+
collector.saw_shared_identifiers(),
|
|
195
|
+
);
|
|
196
|
+
self
|
|
197
|
+
.stmts_to_insert_at_top_level
|
|
198
|
+
.push(register_worklet_stmt);
|
|
199
|
+
}
|
|
200
|
+
ClassMember::ClassProp(p) => {
|
|
201
|
+
if self.cfg.target != TransformTarget::JS || p.is_static || p.value.is_none() {
|
|
202
|
+
n.visit_mut_children_with(self);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let value = p.value.as_mut().unwrap();
|
|
207
|
+
let worklet_type: Option<WorkletType> = match value.as_mut() {
|
|
208
|
+
Expr::Arrow(arrow) if arrow.body.is_function_body() => {
|
|
209
|
+
self.check_is_worklet_block(arrow.body.as_mut_function_body().unwrap())
|
|
210
|
+
}
|
|
211
|
+
Expr::Fn(FnExpr { function, .. }) if function.body.is_some() => {
|
|
212
|
+
self.check_is_worklet_block(function.body.as_mut().unwrap())
|
|
213
|
+
}
|
|
214
|
+
_ => None,
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
if worklet_type.is_none() {
|
|
218
|
+
n.visit_mut_children_with(self);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let mut collector = ExtractingIdentsCollector::new(ExtractingIdentsCollectorConfig {
|
|
223
|
+
custom_global_ident_names: self.cfg.custom_global_ident_names.clone(),
|
|
224
|
+
shared_identifiers: Some(self.shared_identifiers.clone()),
|
|
225
|
+
});
|
|
226
|
+
value.visit_mut_with(&mut collector);
|
|
227
|
+
|
|
228
|
+
let function: Box<Function> = match value.as_ref() {
|
|
229
|
+
Expr::Arrow(arrow) if arrow.body.is_function_body() => Box::new(Function {
|
|
230
|
+
ctxt: arrow.ctxt,
|
|
231
|
+
body: arrow.body.as_function_body().unwrap().clone().into(),
|
|
232
|
+
span: arrow.span,
|
|
233
|
+
return_type: arrow.return_type.clone(),
|
|
234
|
+
is_async: arrow.is_async,
|
|
235
|
+
is_generator: arrow.is_generator,
|
|
236
|
+
type_params: arrow.type_params.clone(),
|
|
237
|
+
decorators: vec![],
|
|
238
|
+
this_param: None,
|
|
239
|
+
params: arrow.params.iter().cloned().map(|p| p.into()).collect(),
|
|
240
|
+
}),
|
|
241
|
+
Expr::Fn(FnExpr { function, .. }) => function.clone(),
|
|
242
|
+
_ => unreachable!("worklet_type was checked to be a class property function"),
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
let should_use_getter = collector.has_extracted_this_props()
|
|
246
|
+
|| collector.has_extracted_values_props()
|
|
247
|
+
|| collector.has_extracted_js_fns();
|
|
248
|
+
|
|
249
|
+
let hash = self.hasher.gen(&self.cfg.filename, &self.content_hash);
|
|
250
|
+
let collect_main_thread = self.defines_collector.is_some();
|
|
251
|
+
let collected_hash = collect_main_thread.then(|| hash.clone());
|
|
252
|
+
let (worklet_object_expr, register_worklet_stmt, main_thread_stmt) =
|
|
253
|
+
StmtGen::transform_worklet(
|
|
254
|
+
self.mode,
|
|
255
|
+
worklet_type.unwrap(),
|
|
256
|
+
hash,
|
|
257
|
+
self.cfg.target,
|
|
258
|
+
p.key
|
|
259
|
+
.clone()
|
|
260
|
+
.ident()
|
|
261
|
+
.unwrap_or(Ident::dummy().into())
|
|
262
|
+
.into(),
|
|
263
|
+
function,
|
|
264
|
+
&mut collector,
|
|
265
|
+
true,
|
|
266
|
+
&mut self.named_imports,
|
|
267
|
+
self.worklet_runtime_loaded_ident.clone(),
|
|
268
|
+
collect_main_thread,
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
if should_use_getter {
|
|
272
|
+
let getter_fn: Function = Function {
|
|
273
|
+
ctxt: Default::default(),
|
|
274
|
+
span: DUMMY_SP,
|
|
275
|
+
params: vec![],
|
|
276
|
+
decorators: vec![],
|
|
277
|
+
this_param: None,
|
|
278
|
+
body: Some(FunctionBody {
|
|
279
|
+
span: DUMMY_SP,
|
|
280
|
+
stmts: vec![ReturnStmt {
|
|
281
|
+
span: DUMMY_SP,
|
|
282
|
+
arg: Some(worklet_object_expr),
|
|
283
|
+
}
|
|
284
|
+
.into()],
|
|
285
|
+
}),
|
|
286
|
+
is_generator: false,
|
|
287
|
+
is_async: false,
|
|
288
|
+
type_params: None,
|
|
289
|
+
return_type: None,
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
*n = ClassMethod {
|
|
293
|
+
span: p.span,
|
|
294
|
+
key: p.key.clone(),
|
|
295
|
+
function: getter_fn.into(),
|
|
296
|
+
kind: MethodKind::Getter,
|
|
297
|
+
is_static: false,
|
|
298
|
+
accessibility: p.accessibility,
|
|
299
|
+
is_abstract: p.is_abstract,
|
|
300
|
+
is_optional: p.is_optional,
|
|
301
|
+
is_override: p.is_override,
|
|
302
|
+
}
|
|
303
|
+
.into();
|
|
304
|
+
} else {
|
|
305
|
+
p.value = Some(worklet_object_expr);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
self.collect_worklet_define(
|
|
309
|
+
collected_hash,
|
|
310
|
+
main_thread_stmt,
|
|
311
|
+
collector.saw_shared_identifiers(),
|
|
312
|
+
);
|
|
313
|
+
self
|
|
314
|
+
.stmts_to_insert_at_top_level
|
|
315
|
+
.push(register_worklet_stmt);
|
|
316
|
+
}
|
|
317
|
+
_ => {
|
|
318
|
+
n.visit_mut_children_with(self);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
fn visit_mut_decl(&mut self, n: &mut Decl) {
|
|
324
|
+
if !n.is_fn_decl() {
|
|
325
|
+
n.visit_mut_children_with(self);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
let worklet_type = match n.as_mut_fn_decl().unwrap().function.body {
|
|
329
|
+
None => None,
|
|
330
|
+
Some(ref mut body) => self.check_is_worklet_block(body),
|
|
331
|
+
};
|
|
332
|
+
if worklet_type.is_none() {
|
|
333
|
+
n.visit_mut_children_with(self);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let mut collector = ExtractingIdentsCollector::new(ExtractingIdentsCollectorConfig {
|
|
338
|
+
custom_global_ident_names: self.cfg.custom_global_ident_names.clone(),
|
|
339
|
+
shared_identifiers: Some(self.shared_identifiers.clone()),
|
|
340
|
+
});
|
|
341
|
+
n.visit_mut_with(&mut collector);
|
|
342
|
+
|
|
343
|
+
let hash = self.hasher.gen(&self.cfg.filename, &self.content_hash);
|
|
344
|
+
let collect_main_thread = self.defines_collector.is_some();
|
|
345
|
+
let collected_hash = collect_main_thread.then(|| hash.clone());
|
|
346
|
+
let (worklet_object_expr, register_worklet_stmt, main_thread_stmt) = StmtGen::transform_worklet(
|
|
347
|
+
self.mode,
|
|
348
|
+
worklet_type.unwrap(),
|
|
349
|
+
hash,
|
|
350
|
+
self.cfg.target,
|
|
351
|
+
n.as_fn_decl().unwrap().ident.clone(),
|
|
352
|
+
n.as_fn_decl().unwrap().function.clone(),
|
|
353
|
+
&mut collector,
|
|
354
|
+
false,
|
|
355
|
+
&mut self.named_imports,
|
|
356
|
+
self.worklet_runtime_loaded_ident.clone(),
|
|
357
|
+
collect_main_thread,
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
*n = VarDecl {
|
|
361
|
+
ctxt: n.as_fn_decl().unwrap().ident.ctxt,
|
|
362
|
+
span: n.as_fn_decl().unwrap().ident.span,
|
|
363
|
+
kind: VarDeclKind::Let,
|
|
364
|
+
declare: false,
|
|
365
|
+
decls: vec![VarDeclarator {
|
|
366
|
+
span: n.as_fn_decl().unwrap().ident.span,
|
|
367
|
+
definite: false,
|
|
368
|
+
name: n.as_fn_decl().unwrap().ident.clone().into(),
|
|
369
|
+
init: worklet_object_expr.into(),
|
|
370
|
+
}],
|
|
371
|
+
}
|
|
372
|
+
.into();
|
|
373
|
+
self.collect_worklet_define(
|
|
374
|
+
collected_hash,
|
|
375
|
+
main_thread_stmt,
|
|
376
|
+
collector.saw_shared_identifiers(),
|
|
377
|
+
);
|
|
378
|
+
self
|
|
379
|
+
.stmts_to_insert_at_top_level
|
|
380
|
+
.push(register_worklet_stmt);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
fn visit_mut_expr(&mut self, n: &mut Expr) {
|
|
384
|
+
match n {
|
|
385
|
+
Expr::Arrow(ArrowExpr { body, .. }) if body.is_function_body() => {
|
|
386
|
+
let worklet_type = self.check_is_worklet_block(
|
|
387
|
+
n.as_mut_arrow()
|
|
388
|
+
.unwrap()
|
|
389
|
+
.body
|
|
390
|
+
.as_mut_function_body()
|
|
391
|
+
.unwrap(),
|
|
392
|
+
);
|
|
393
|
+
if worklet_type.is_none() {
|
|
394
|
+
n.visit_mut_children_with(self);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
let mut collector = ExtractingIdentsCollector::new(ExtractingIdentsCollectorConfig {
|
|
399
|
+
custom_global_ident_names: self.cfg.custom_global_ident_names.clone(),
|
|
400
|
+
shared_identifiers: Some(self.shared_identifiers.clone()),
|
|
401
|
+
});
|
|
402
|
+
n.visit_mut_with(&mut collector);
|
|
403
|
+
|
|
404
|
+
let hash = self.hasher.gen(&self.cfg.filename, &self.content_hash);
|
|
405
|
+
let collect_main_thread = self.defines_collector.is_some();
|
|
406
|
+
let collected_hash = collect_main_thread.then(|| hash.clone());
|
|
407
|
+
let (worklet_object_expr, register_worklet_stmt, main_thread_stmt) =
|
|
408
|
+
StmtGen::transform_worklet(
|
|
409
|
+
self.mode,
|
|
410
|
+
worklet_type.unwrap(),
|
|
411
|
+
hash,
|
|
412
|
+
self.cfg.target,
|
|
413
|
+
Ident::dummy(),
|
|
414
|
+
Box::new(Function {
|
|
415
|
+
ctxt: n.as_mut_arrow().unwrap().ctxt,
|
|
416
|
+
body: n
|
|
417
|
+
.as_mut_arrow()
|
|
418
|
+
.unwrap()
|
|
419
|
+
.body
|
|
420
|
+
.as_function_body()
|
|
421
|
+
.unwrap()
|
|
422
|
+
.clone()
|
|
423
|
+
.into(),
|
|
424
|
+
span: n.as_mut_arrow().unwrap().span,
|
|
425
|
+
return_type: n.as_mut_arrow().unwrap().return_type.clone(),
|
|
426
|
+
is_async: n.as_mut_arrow().unwrap().is_async,
|
|
427
|
+
is_generator: n.as_mut_arrow().unwrap().is_generator,
|
|
428
|
+
type_params: n.as_mut_arrow().unwrap().type_params.clone(),
|
|
429
|
+
decorators: vec![],
|
|
430
|
+
this_param: None,
|
|
431
|
+
params: n
|
|
432
|
+
.as_mut_arrow()
|
|
433
|
+
.unwrap()
|
|
434
|
+
.params
|
|
435
|
+
.iter()
|
|
436
|
+
.map(|p| p.clone().into())
|
|
437
|
+
.collect(),
|
|
438
|
+
}),
|
|
439
|
+
&mut collector,
|
|
440
|
+
false,
|
|
441
|
+
&mut self.named_imports,
|
|
442
|
+
self.worklet_runtime_loaded_ident.clone(),
|
|
443
|
+
collect_main_thread,
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
*n = *worklet_object_expr;
|
|
447
|
+
self.collect_worklet_define(
|
|
448
|
+
collected_hash,
|
|
449
|
+
main_thread_stmt,
|
|
450
|
+
collector.saw_shared_identifiers(),
|
|
451
|
+
);
|
|
452
|
+
self
|
|
453
|
+
.stmts_to_insert_at_top_level
|
|
454
|
+
.push(register_worklet_stmt);
|
|
455
|
+
}
|
|
456
|
+
Expr::Fn(_) if n.as_fn_expr().unwrap().function.body.is_some() => {
|
|
457
|
+
let worklet_type =
|
|
458
|
+
self.check_is_worklet_block(n.as_mut_fn_expr().unwrap().function.body.as_mut().unwrap());
|
|
459
|
+
if worklet_type.is_none() {
|
|
460
|
+
n.visit_mut_children_with(self);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
let mut collector = ExtractingIdentsCollector::new(ExtractingIdentsCollectorConfig {
|
|
465
|
+
custom_global_ident_names: self.cfg.custom_global_ident_names.clone(),
|
|
466
|
+
shared_identifiers: Some(self.shared_identifiers.clone()),
|
|
467
|
+
});
|
|
468
|
+
n.visit_mut_with(&mut collector);
|
|
469
|
+
|
|
470
|
+
let hash = self.hasher.gen(&self.cfg.filename, &self.content_hash);
|
|
471
|
+
let collect_main_thread = self.defines_collector.is_some();
|
|
472
|
+
let collected_hash = collect_main_thread.then(|| hash.clone());
|
|
473
|
+
let (worklet_object_expr, register_worklet_stmt, main_thread_stmt) =
|
|
474
|
+
StmtGen::transform_worklet(
|
|
475
|
+
self.mode,
|
|
476
|
+
worklet_type.unwrap(),
|
|
477
|
+
hash,
|
|
478
|
+
self.cfg.target,
|
|
479
|
+
Ident::dummy(),
|
|
480
|
+
n.as_mut_fn_expr().unwrap().function.take(),
|
|
481
|
+
&mut collector,
|
|
482
|
+
false,
|
|
483
|
+
&mut self.named_imports,
|
|
484
|
+
self.worklet_runtime_loaded_ident.clone(),
|
|
485
|
+
collect_main_thread,
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
*n = *worklet_object_expr;
|
|
489
|
+
self.collect_worklet_define(
|
|
490
|
+
collected_hash,
|
|
491
|
+
main_thread_stmt,
|
|
492
|
+
collector.saw_shared_identifiers(),
|
|
493
|
+
);
|
|
494
|
+
self
|
|
495
|
+
.stmts_to_insert_at_top_level
|
|
496
|
+
.push(register_worklet_stmt);
|
|
497
|
+
}
|
|
498
|
+
_ => {
|
|
499
|
+
n.visit_mut_children_with(self);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
fn visit_mut_module_decl(&mut self, n: &mut ModuleDecl) {
|
|
505
|
+
if !matches!(
|
|
506
|
+
n,
|
|
507
|
+
ModuleDecl::ExportDefaultDecl(ExportDefaultDecl {
|
|
508
|
+
decl: DefaultDecl::Fn(_),
|
|
509
|
+
..
|
|
510
|
+
})
|
|
511
|
+
) || n
|
|
512
|
+
.as_export_default_decl()
|
|
513
|
+
.unwrap()
|
|
514
|
+
.decl
|
|
515
|
+
.as_fn_expr()
|
|
516
|
+
.unwrap()
|
|
517
|
+
.function
|
|
518
|
+
.body
|
|
519
|
+
.is_none()
|
|
520
|
+
{
|
|
521
|
+
n.visit_mut_children_with(self);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
let worklet_type = self.check_is_worklet_block(
|
|
526
|
+
n.as_mut_export_default_decl()
|
|
527
|
+
.unwrap()
|
|
528
|
+
.decl
|
|
529
|
+
.as_mut_fn_expr()
|
|
530
|
+
.unwrap()
|
|
531
|
+
.function
|
|
532
|
+
.body
|
|
533
|
+
.as_mut()
|
|
534
|
+
.unwrap(),
|
|
535
|
+
);
|
|
536
|
+
if worklet_type.is_none() {
|
|
537
|
+
n.visit_mut_children_with(self);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
let mut collector = ExtractingIdentsCollector::new(ExtractingIdentsCollectorConfig {
|
|
542
|
+
custom_global_ident_names: self.cfg.custom_global_ident_names.clone(),
|
|
543
|
+
shared_identifiers: Some(self.shared_identifiers.clone()),
|
|
544
|
+
});
|
|
545
|
+
n.as_mut_export_default_decl()
|
|
546
|
+
.unwrap()
|
|
547
|
+
.decl
|
|
548
|
+
.as_mut_fn_expr()
|
|
549
|
+
.unwrap()
|
|
550
|
+
.visit_mut_with(&mut collector);
|
|
551
|
+
|
|
552
|
+
let hash = self.hasher.gen(&self.cfg.filename, &self.content_hash);
|
|
553
|
+
let collect_main_thread = self.defines_collector.is_some();
|
|
554
|
+
let collected_hash = collect_main_thread.then(|| hash.clone());
|
|
555
|
+
let (worklet_object_expr, register_worklet_stmt, main_thread_stmt) = StmtGen::transform_worklet(
|
|
556
|
+
self.mode,
|
|
557
|
+
worklet_type.unwrap(),
|
|
558
|
+
hash,
|
|
559
|
+
self.cfg.target,
|
|
560
|
+
Ident::dummy(),
|
|
561
|
+
n.as_mut_export_default_decl()
|
|
562
|
+
.unwrap()
|
|
563
|
+
.decl
|
|
564
|
+
.as_mut_fn_expr()
|
|
565
|
+
.unwrap()
|
|
566
|
+
.function
|
|
567
|
+
.take(),
|
|
568
|
+
&mut collector,
|
|
569
|
+
false,
|
|
570
|
+
&mut self.named_imports,
|
|
571
|
+
self.worklet_runtime_loaded_ident.clone(),
|
|
572
|
+
collect_main_thread,
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
*n = ModuleDecl::ExportDefaultExpr(ExportDefaultExpr {
|
|
576
|
+
span: n.span(),
|
|
577
|
+
expr: worklet_object_expr,
|
|
578
|
+
});
|
|
579
|
+
self.collect_worklet_define(
|
|
580
|
+
collected_hash,
|
|
581
|
+
main_thread_stmt,
|
|
582
|
+
collector.saw_shared_identifiers(),
|
|
583
|
+
);
|
|
584
|
+
self
|
|
585
|
+
.stmts_to_insert_at_top_level
|
|
586
|
+
.push(register_worklet_stmt);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
|
|
590
|
+
n.visit_mut_children_with(self);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
fn visit_mut_module(&mut self, n: &mut Module) {
|
|
594
|
+
// First process imports to detect shared-runtime modules
|
|
595
|
+
for item in &n.body {
|
|
596
|
+
if let ModuleItem::ModuleDecl(ModuleDecl::Import(import_decl)) = item {
|
|
597
|
+
if is_shared_runtime_import(import_decl) {
|
|
598
|
+
for specifier in &import_decl.specifiers {
|
|
599
|
+
match specifier {
|
|
600
|
+
ImportSpecifier::Named(named) => {
|
|
601
|
+
self.shared_identifiers.insert(named.local.to_id());
|
|
602
|
+
}
|
|
603
|
+
ImportSpecifier::Default(default) => {
|
|
604
|
+
self.shared_identifiers.insert(default.local.to_id());
|
|
605
|
+
}
|
|
606
|
+
ImportSpecifier::Namespace(ns) => {
|
|
607
|
+
self.shared_identifiers.insert(ns.local.to_id());
|
|
608
|
+
}
|
|
609
|
+
#[cfg(swc_ast_unknown)]
|
|
610
|
+
_ => panic!("unknown node"),
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
n.visit_mut_children_with(self);
|
|
618
|
+
|
|
619
|
+
// Add global loadWorkletRuntime call if needed
|
|
620
|
+
if self.named_imports.contains("loadWorkletRuntime") && !self.worklet_runtime_loaded {
|
|
621
|
+
self.stmts_to_insert_at_top_level.insert(
|
|
622
|
+
0,
|
|
623
|
+
quote!("const $loaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry)" as Stmt, loaded = self.worklet_runtime_loaded_ident.clone()),
|
|
624
|
+
);
|
|
625
|
+
self.worklet_runtime_loaded = true;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
let mut specifiers = self.named_imports.iter().collect::<Vec<_>>();
|
|
629
|
+
|
|
630
|
+
if !specifiers.is_empty() {
|
|
631
|
+
// Sort to keep the output consistent
|
|
632
|
+
specifiers.sort();
|
|
633
|
+
|
|
634
|
+
prepend_stmts(
|
|
635
|
+
&mut n.body,
|
|
636
|
+
vec![
|
|
637
|
+
ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
|
|
638
|
+
span: DUMMY_SP,
|
|
639
|
+
phase: ImportPhase::Evaluation,
|
|
640
|
+
specifiers: specifiers
|
|
641
|
+
.iter()
|
|
642
|
+
.map(|imported| {
|
|
643
|
+
ImportSpecifier::Named(ImportNamedSpecifier {
|
|
644
|
+
span: DUMMY_SP,
|
|
645
|
+
is_type_only: false,
|
|
646
|
+
local: Ident {
|
|
647
|
+
ctxt: Default::default(),
|
|
648
|
+
span: DUMMY_SP,
|
|
649
|
+
sym: format!("__{imported}").into(),
|
|
650
|
+
optional: false,
|
|
651
|
+
},
|
|
652
|
+
imported: Some(ModuleExportName::Ident(Ident {
|
|
653
|
+
ctxt: Default::default(),
|
|
654
|
+
span: DUMMY_SP,
|
|
655
|
+
sym: imported.as_str().into(),
|
|
656
|
+
optional: false,
|
|
657
|
+
})),
|
|
658
|
+
})
|
|
659
|
+
})
|
|
660
|
+
.collect::<Vec<_>>(),
|
|
661
|
+
src: Box::new(Str {
|
|
662
|
+
span: DUMMY_SP,
|
|
663
|
+
raw: None,
|
|
664
|
+
value: self.cfg.runtime_pkg.clone().into(),
|
|
665
|
+
}),
|
|
666
|
+
type_only: Default::default(),
|
|
667
|
+
with: Default::default(),
|
|
668
|
+
})),
|
|
669
|
+
ModuleItem::Stmt(Stmt::Decl(Decl::Var(Box::new(VarDecl {
|
|
670
|
+
ctxt: Default::default(),
|
|
671
|
+
span: DUMMY_SP,
|
|
672
|
+
kind: VarDeclKind::Var,
|
|
673
|
+
declare: false,
|
|
674
|
+
decls: specifiers
|
|
675
|
+
.into_iter()
|
|
676
|
+
.map(|name| VarDeclarator {
|
|
677
|
+
span: DUMMY_SP,
|
|
678
|
+
name: Pat::Ident(
|
|
679
|
+
Ident {
|
|
680
|
+
ctxt: Default::default(),
|
|
681
|
+
span: DUMMY_SP,
|
|
682
|
+
sym: name.as_str().into(),
|
|
683
|
+
optional: false,
|
|
684
|
+
}
|
|
685
|
+
.into(),
|
|
686
|
+
),
|
|
687
|
+
init: Some(Box::new(Expr::Ident(Ident {
|
|
688
|
+
ctxt: Default::default(),
|
|
689
|
+
span: DUMMY_SP,
|
|
690
|
+
sym: format!("__{name}").into(),
|
|
691
|
+
optional: false,
|
|
692
|
+
}))),
|
|
693
|
+
definite: false,
|
|
694
|
+
})
|
|
695
|
+
.collect(),
|
|
696
|
+
})))),
|
|
697
|
+
]
|
|
698
|
+
.into_iter(),
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
// Add statements to insert at top level after processing all items
|
|
702
|
+
n.body.extend(
|
|
703
|
+
self
|
|
704
|
+
.stmts_to_insert_at_top_level
|
|
705
|
+
.iter_mut()
|
|
706
|
+
.filter(|stmt| !stmt.is_empty())
|
|
707
|
+
.map(|stmt| stmt.take().into()),
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const INVALID_RUNTIME_MSG: &str = "Invalid runtime value. Only 'shared' is supported.";
|
|
713
|
+
|
|
714
|
+
fn emit_invalid_runtime_error(span: Span) {
|
|
715
|
+
HANDLER.with(|handler| {
|
|
716
|
+
handler.struct_span_err(span, INVALID_RUNTIME_MSG).emit();
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
fn validate_runtime_value(expr: &Expr) -> bool {
|
|
721
|
+
match expr {
|
|
722
|
+
Expr::Lit(Lit::Str(value)) => {
|
|
723
|
+
if value.value == "shared" {
|
|
724
|
+
true
|
|
725
|
+
} else {
|
|
726
|
+
emit_invalid_runtime_error(value.span);
|
|
727
|
+
false
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
_ => {
|
|
731
|
+
emit_invalid_runtime_error(expr.span());
|
|
732
|
+
false
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
fn is_shared_runtime_import(import_decl: &ImportDecl) -> bool {
|
|
738
|
+
if let Some(with_clause) = &import_decl.with {
|
|
739
|
+
// Check if the with clause contains runtime: "shared"
|
|
740
|
+
for prop in &with_clause.props {
|
|
741
|
+
if let PropOrSpread::Prop(prop) = prop {
|
|
742
|
+
if let Prop::KeyValue(kv) = &**prop {
|
|
743
|
+
match &kv.key {
|
|
744
|
+
PropName::Ident(key) if key.sym == "runtime" => {
|
|
745
|
+
return validate_runtime_value(&kv.value);
|
|
746
|
+
}
|
|
747
|
+
PropName::Str(s) if s.value == "runtime" => {
|
|
748
|
+
return validate_runtime_value(&kv.value);
|
|
749
|
+
}
|
|
750
|
+
_ => {}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
false
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
impl WorkletVisitor {
|
|
760
|
+
pub fn with_content_hash(mut self, content_hash: String) -> Self {
|
|
761
|
+
self.content_hash = content_hash;
|
|
762
|
+
self
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
pub fn new(mode: TransformMode, cfg: WorkletVisitorConfig) -> Self {
|
|
766
|
+
WorkletVisitor {
|
|
767
|
+
mode,
|
|
768
|
+
content_hash: "test".into(),
|
|
769
|
+
cfg,
|
|
770
|
+
stmts_to_insert_at_top_level: vec![],
|
|
771
|
+
hasher: WorkletHash::new(),
|
|
772
|
+
named_imports: HashSet::default(),
|
|
773
|
+
shared_identifiers: FxHashSet::default(),
|
|
774
|
+
worklet_runtime_loaded: false,
|
|
775
|
+
worklet_runtime_loaded_ident: private_ident!("__workletRuntimeLoaded"),
|
|
776
|
+
defines_collector: None,
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
pub fn with_defines_collector(mut self, collector: DefinesCollector) -> Self {
|
|
781
|
+
self.defines_collector = Some(collector);
|
|
782
|
+
self
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
fn collect_worklet_define(
|
|
786
|
+
&mut self,
|
|
787
|
+
hash: Option<String>,
|
|
788
|
+
stmt: Option<Stmt>,
|
|
789
|
+
closes_over_shared_import: bool,
|
|
790
|
+
) {
|
|
791
|
+
let (Some(hash), Some(stmt)) = (hash, stmt) else {
|
|
792
|
+
return;
|
|
793
|
+
};
|
|
794
|
+
if closes_over_shared_import {
|
|
795
|
+
collect_unmergeable_define(&self.defines_collector, DefineKind::Worklet, hash);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
let guard = quote!(
|
|
799
|
+
"const $loaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry)" as Stmt,
|
|
800
|
+
loaded = self.worklet_runtime_loaded_ident.clone(),
|
|
801
|
+
);
|
|
802
|
+
collect_define(
|
|
803
|
+
&self.defines_collector,
|
|
804
|
+
DefineKind::Worklet,
|
|
805
|
+
hash,
|
|
806
|
+
vec![ModuleItem::Stmt(guard), ModuleItem::Stmt(stmt)],
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
fn check_is_worklet_block(&self, n: &mut FunctionBody) -> Option<WorkletType> {
|
|
811
|
+
let FunctionBody { stmts, .. } = n;
|
|
812
|
+
if !stmts.is_empty() {
|
|
813
|
+
match &mut stmts[0] {
|
|
814
|
+
Stmt::Expr(ExprStmt { expr, span: _ }) => match &mut **expr {
|
|
815
|
+
Expr::Lit(Lit::Str(str)) => {
|
|
816
|
+
WorkletType::from_directive(str.value.to_string_lossy().into_owned())
|
|
817
|
+
}
|
|
818
|
+
_ => None,
|
|
819
|
+
},
|
|
820
|
+
_ => None,
|
|
821
|
+
}
|
|
822
|
+
} else {
|
|
823
|
+
None
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
#[cfg(test)]
|
|
829
|
+
mod tests {
|
|
830
|
+
use crate::{TransformMode, TransformTarget, WorkletVisitor, WorkletVisitorConfig};
|
|
831
|
+
use swc_core::common::Mark;
|
|
832
|
+
use swc_core::ecma::parser::TsSyntax;
|
|
833
|
+
use swc_core::ecma::transforms::base::hygiene::hygiene;
|
|
834
|
+
use swc_core::ecma::transforms::base::resolver;
|
|
835
|
+
use swc_core::{
|
|
836
|
+
ecma::parser::Syntax,
|
|
837
|
+
ecma::visit::visit_mut_pass,
|
|
838
|
+
ecma::{parser::EsSyntax, transforms::testing::test},
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
test!(
|
|
842
|
+
module,
|
|
843
|
+
Syntax::Typescript(TsSyntax {
|
|
844
|
+
..Default::default()
|
|
845
|
+
}),
|
|
846
|
+
|_| (
|
|
847
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
848
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
849
|
+
TransformMode::Test,
|
|
850
|
+
WorkletVisitorConfig {
|
|
851
|
+
filename: "index.js".into(),
|
|
852
|
+
target: TransformTarget::LEPUS,
|
|
853
|
+
custom_global_ident_names: None,
|
|
854
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
855
|
+
}
|
|
856
|
+
)),
|
|
857
|
+
hygiene()
|
|
858
|
+
),
|
|
859
|
+
should_transform_lepus_general,
|
|
860
|
+
r#"
|
|
861
|
+
function worklet(event: Event) {
|
|
862
|
+
"main thread";
|
|
863
|
+
console.log(y1);
|
|
864
|
+
console.log(this.y1);
|
|
865
|
+
let a: object = y1;
|
|
866
|
+
}
|
|
867
|
+
"#
|
|
868
|
+
);
|
|
869
|
+
|
|
870
|
+
test!(
|
|
871
|
+
module,
|
|
872
|
+
Syntax::Typescript(TsSyntax {
|
|
873
|
+
..Default::default()
|
|
874
|
+
}),
|
|
875
|
+
|_| (
|
|
876
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
877
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
878
|
+
TransformMode::Test,
|
|
879
|
+
WorkletVisitorConfig {
|
|
880
|
+
filename: "index.js".into(),
|
|
881
|
+
target: TransformTarget::LEPUS,
|
|
882
|
+
custom_global_ident_names: None,
|
|
883
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
884
|
+
}
|
|
885
|
+
)),
|
|
886
|
+
hygiene()
|
|
887
|
+
),
|
|
888
|
+
should_transform_lepus_alias,
|
|
889
|
+
r#"
|
|
890
|
+
function worklet(event: Event) {
|
|
891
|
+
"main-thread";
|
|
892
|
+
console.log(y1);
|
|
893
|
+
console.log(this.y1);
|
|
894
|
+
let a: object = y1;
|
|
895
|
+
}
|
|
896
|
+
"#
|
|
897
|
+
);
|
|
898
|
+
|
|
899
|
+
test!(
|
|
900
|
+
module,
|
|
901
|
+
Syntax::Typescript(TsSyntax {
|
|
902
|
+
..Default::default()
|
|
903
|
+
}),
|
|
904
|
+
|_| (
|
|
905
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
906
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
907
|
+
TransformMode::Test,
|
|
908
|
+
WorkletVisitorConfig {
|
|
909
|
+
filename: "index.js".into(),
|
|
910
|
+
target: TransformTarget::MIXED,
|
|
911
|
+
custom_global_ident_names: None,
|
|
912
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
913
|
+
}
|
|
914
|
+
)),
|
|
915
|
+
hygiene()
|
|
916
|
+
),
|
|
917
|
+
should_transform_lepus_general_mixed,
|
|
918
|
+
r#"
|
|
919
|
+
function worklet(event: Event) {
|
|
920
|
+
"main thread";
|
|
921
|
+
console.log(y1);
|
|
922
|
+
console.log(this.y1);
|
|
923
|
+
let a: object = y1;
|
|
924
|
+
}
|
|
925
|
+
"#
|
|
926
|
+
);
|
|
927
|
+
|
|
928
|
+
test!(
|
|
929
|
+
module,
|
|
930
|
+
Syntax::Typescript(TsSyntax {
|
|
931
|
+
..Default::default()
|
|
932
|
+
}),
|
|
933
|
+
|_| (
|
|
934
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
935
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
936
|
+
TransformMode::Test,
|
|
937
|
+
WorkletVisitorConfig {
|
|
938
|
+
filename: "index.js".into(),
|
|
939
|
+
target: TransformTarget::JS,
|
|
940
|
+
custom_global_ident_names: None,
|
|
941
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
942
|
+
}
|
|
943
|
+
)),
|
|
944
|
+
hygiene()
|
|
945
|
+
),
|
|
946
|
+
should_transform_js_general,
|
|
947
|
+
r#"
|
|
948
|
+
function worklet(event: Event) {
|
|
949
|
+
"main thread";
|
|
950
|
+
console.log(y1);
|
|
951
|
+
console.log(this.y1);
|
|
952
|
+
let a: object = y1;
|
|
953
|
+
}
|
|
954
|
+
"#
|
|
955
|
+
);
|
|
956
|
+
|
|
957
|
+
test!(
|
|
958
|
+
module,
|
|
959
|
+
Syntax::Es(EsSyntax {
|
|
960
|
+
..Default::default()
|
|
961
|
+
}),
|
|
962
|
+
|_| (
|
|
963
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
964
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
965
|
+
TransformMode::Test,
|
|
966
|
+
WorkletVisitorConfig {
|
|
967
|
+
filename: "index.js".into(),
|
|
968
|
+
target: TransformTarget::LEPUS,
|
|
969
|
+
custom_global_ident_names: None,
|
|
970
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
971
|
+
}
|
|
972
|
+
)),
|
|
973
|
+
hygiene()
|
|
974
|
+
),
|
|
975
|
+
should_transform_lepus,
|
|
976
|
+
r#"
|
|
977
|
+
function X(event) {
|
|
978
|
+
"main thread";
|
|
979
|
+
console.log(y1[y2 + 1]);
|
|
980
|
+
if (
|
|
981
|
+
{
|
|
982
|
+
x: 345,
|
|
983
|
+
}.x.value
|
|
984
|
+
) {
|
|
985
|
+
console.log(y3);
|
|
986
|
+
}
|
|
987
|
+
let a = y4;
|
|
988
|
+
const { b, c = y8 } = y5;
|
|
989
|
+
a, b, c;
|
|
990
|
+
y6.m = y7;
|
|
991
|
+
function xxx() {}
|
|
992
|
+
}
|
|
993
|
+
"#
|
|
994
|
+
);
|
|
995
|
+
|
|
996
|
+
test!(
|
|
997
|
+
module,
|
|
998
|
+
Syntax::Es(EsSyntax {
|
|
999
|
+
..Default::default()
|
|
1000
|
+
}),
|
|
1001
|
+
|_| (
|
|
1002
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1003
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1004
|
+
TransformMode::Test,
|
|
1005
|
+
WorkletVisitorConfig {
|
|
1006
|
+
filename: "index.js".into(),
|
|
1007
|
+
target: TransformTarget::JS,
|
|
1008
|
+
custom_global_ident_names: None,
|
|
1009
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1010
|
+
}
|
|
1011
|
+
)),
|
|
1012
|
+
hygiene()
|
|
1013
|
+
),
|
|
1014
|
+
should_transform_js,
|
|
1015
|
+
r#"
|
|
1016
|
+
function X(event) {
|
|
1017
|
+
"main thread";
|
|
1018
|
+
console.log(y1[y2 + 1]);
|
|
1019
|
+
if (
|
|
1020
|
+
{
|
|
1021
|
+
x: 345,
|
|
1022
|
+
}.x.value
|
|
1023
|
+
) {
|
|
1024
|
+
console.log(y3);
|
|
1025
|
+
}
|
|
1026
|
+
let a = y4;
|
|
1027
|
+
const { b, c = y8 } = y5;
|
|
1028
|
+
a, b, c;
|
|
1029
|
+
y6.m = y7;
|
|
1030
|
+
function xxx() {}
|
|
1031
|
+
}
|
|
1032
|
+
"#
|
|
1033
|
+
);
|
|
1034
|
+
|
|
1035
|
+
test!(
|
|
1036
|
+
module,
|
|
1037
|
+
Syntax::Typescript(TsSyntax {
|
|
1038
|
+
..Default::default()
|
|
1039
|
+
}),
|
|
1040
|
+
|_| (
|
|
1041
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1042
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1043
|
+
TransformMode::Test,
|
|
1044
|
+
WorkletVisitorConfig {
|
|
1045
|
+
filename: "index.js".into(),
|
|
1046
|
+
target: TransformTarget::JS,
|
|
1047
|
+
custom_global_ident_names: None,
|
|
1048
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1049
|
+
}
|
|
1050
|
+
)),
|
|
1051
|
+
hygiene()
|
|
1052
|
+
),
|
|
1053
|
+
should_skip_shared_identifiers_js,
|
|
1054
|
+
r#"
|
|
1055
|
+
import { sharedRuntime } from './utils.js' with {
|
|
1056
|
+
runtime: "shared"
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
function worklet(event: Event) {
|
|
1060
|
+
"main thread";
|
|
1061
|
+
console.log(sharedRuntime);
|
|
1062
|
+
console.log(this.y1);
|
|
1063
|
+
let a: object = y1;
|
|
1064
|
+
}
|
|
1065
|
+
"#
|
|
1066
|
+
);
|
|
1067
|
+
|
|
1068
|
+
// default import should also be treated as shared-runtime and skipped from capture
|
|
1069
|
+
test!(
|
|
1070
|
+
module,
|
|
1071
|
+
Syntax::Typescript(TsSyntax {
|
|
1072
|
+
..Default::default()
|
|
1073
|
+
}),
|
|
1074
|
+
|_| (
|
|
1075
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1076
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1077
|
+
TransformMode::Test,
|
|
1078
|
+
WorkletVisitorConfig {
|
|
1079
|
+
filename: "index.js".into(),
|
|
1080
|
+
target: TransformTarget::JS,
|
|
1081
|
+
custom_global_ident_names: None,
|
|
1082
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1083
|
+
}
|
|
1084
|
+
)),
|
|
1085
|
+
hygiene()
|
|
1086
|
+
),
|
|
1087
|
+
should_skip_shared_identifiers_default_import_js,
|
|
1088
|
+
r#"
|
|
1089
|
+
import sharedRuntime from './utils.js' with {
|
|
1090
|
+
runtime: "shared"
|
|
1091
|
+
};
|
|
1092
|
+
|
|
1093
|
+
function worklet(event: Event) {
|
|
1094
|
+
"main thread";
|
|
1095
|
+
console.log(sharedRuntime);
|
|
1096
|
+
console.log(this.y1);
|
|
1097
|
+
let a: object = y1;
|
|
1098
|
+
}
|
|
1099
|
+
"#
|
|
1100
|
+
);
|
|
1101
|
+
|
|
1102
|
+
// namespace import should be skipped from capture
|
|
1103
|
+
test!(
|
|
1104
|
+
module,
|
|
1105
|
+
Syntax::Typescript(TsSyntax {
|
|
1106
|
+
..Default::default()
|
|
1107
|
+
}),
|
|
1108
|
+
|_| (
|
|
1109
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1110
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1111
|
+
TransformMode::Test,
|
|
1112
|
+
WorkletVisitorConfig {
|
|
1113
|
+
filename: "index.js".into(),
|
|
1114
|
+
target: TransformTarget::JS,
|
|
1115
|
+
custom_global_ident_names: None,
|
|
1116
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1117
|
+
}
|
|
1118
|
+
)),
|
|
1119
|
+
hygiene()
|
|
1120
|
+
),
|
|
1121
|
+
should_skip_shared_identifiers_namespace_import_js,
|
|
1122
|
+
r#"
|
|
1123
|
+
import * as SR from './utils.js' with {
|
|
1124
|
+
runtime: "shared"
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
function worklet(event: Event) {
|
|
1128
|
+
"main thread";
|
|
1129
|
+
console.log(SR);
|
|
1130
|
+
console.log(this.y1);
|
|
1131
|
+
let a: object = y1;
|
|
1132
|
+
}
|
|
1133
|
+
"#
|
|
1134
|
+
);
|
|
1135
|
+
|
|
1136
|
+
// with clause key can be string literal
|
|
1137
|
+
test!(
|
|
1138
|
+
module,
|
|
1139
|
+
Syntax::Typescript(TsSyntax {
|
|
1140
|
+
..Default::default()
|
|
1141
|
+
}),
|
|
1142
|
+
|_| (
|
|
1143
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1144
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1145
|
+
TransformMode::Test,
|
|
1146
|
+
WorkletVisitorConfig {
|
|
1147
|
+
filename: "index.js".into(),
|
|
1148
|
+
target: TransformTarget::JS,
|
|
1149
|
+
custom_global_ident_names: None,
|
|
1150
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1151
|
+
}
|
|
1152
|
+
)),
|
|
1153
|
+
hygiene()
|
|
1154
|
+
),
|
|
1155
|
+
should_skip_shared_identifiers_string_key_js,
|
|
1156
|
+
r#"
|
|
1157
|
+
import { sharedRuntime as sr } from './utils.js' with {
|
|
1158
|
+
"runtime": "shared"
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
function worklet(event: Event) {
|
|
1162
|
+
"main thread";
|
|
1163
|
+
console.log(sr);
|
|
1164
|
+
console.log(this.y1);
|
|
1165
|
+
let a: object = y1;
|
|
1166
|
+
}
|
|
1167
|
+
"#
|
|
1168
|
+
);
|
|
1169
|
+
|
|
1170
|
+
test!(
|
|
1171
|
+
module,
|
|
1172
|
+
Syntax::Typescript(TsSyntax {
|
|
1173
|
+
..Default::default()
|
|
1174
|
+
}),
|
|
1175
|
+
|_| (
|
|
1176
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1177
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1178
|
+
TransformMode::Test,
|
|
1179
|
+
WorkletVisitorConfig {
|
|
1180
|
+
filename: "index.js".into(),
|
|
1181
|
+
target: TransformTarget::JS,
|
|
1182
|
+
custom_global_ident_names: None,
|
|
1183
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1184
|
+
}
|
|
1185
|
+
)),
|
|
1186
|
+
hygiene()
|
|
1187
|
+
),
|
|
1188
|
+
should_handle_renamed_import_shadowing_js,
|
|
1189
|
+
r#"
|
|
1190
|
+
import { sharedRuntime as sr } from './utils.js' with {
|
|
1191
|
+
runtime: "shared"
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
(function() {
|
|
1195
|
+
let sr = y1;
|
|
1196
|
+
function worklet(event: Event) {
|
|
1197
|
+
"main thread";
|
|
1198
|
+
console.log(sr);
|
|
1199
|
+
console.log(this.y1);
|
|
1200
|
+
let a: object = y1;
|
|
1201
|
+
}
|
|
1202
|
+
})();
|
|
1203
|
+
"#
|
|
1204
|
+
);
|
|
1205
|
+
|
|
1206
|
+
test!(
|
|
1207
|
+
module,
|
|
1208
|
+
Syntax::Typescript(TsSyntax {
|
|
1209
|
+
..Default::default()
|
|
1210
|
+
}),
|
|
1211
|
+
|_| (
|
|
1212
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1213
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1214
|
+
TransformMode::Test,
|
|
1215
|
+
WorkletVisitorConfig {
|
|
1216
|
+
filename: "index.js".into(),
|
|
1217
|
+
target: TransformTarget::LEPUS,
|
|
1218
|
+
custom_global_ident_names: None,
|
|
1219
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1220
|
+
}
|
|
1221
|
+
)),
|
|
1222
|
+
hygiene()
|
|
1223
|
+
),
|
|
1224
|
+
should_skip_shared_identifiers_lepus,
|
|
1225
|
+
r#"
|
|
1226
|
+
import { sharedRuntime } from './utils.js' with {
|
|
1227
|
+
runtime: "shared"
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
function worklet(event: Event) {
|
|
1231
|
+
"main thread";
|
|
1232
|
+
console.log(sharedRuntime);
|
|
1233
|
+
console.log(this.y1);
|
|
1234
|
+
let a: object = y1;
|
|
1235
|
+
}
|
|
1236
|
+
"#
|
|
1237
|
+
);
|
|
1238
|
+
|
|
1239
|
+
test!(
|
|
1240
|
+
module,
|
|
1241
|
+
Syntax::Es(EsSyntax {
|
|
1242
|
+
..Default::default()
|
|
1243
|
+
}),
|
|
1244
|
+
|_| (
|
|
1245
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1246
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1247
|
+
TransformMode::Test,
|
|
1248
|
+
WorkletVisitorConfig {
|
|
1249
|
+
filename: "index.js".into(),
|
|
1250
|
+
target: TransformTarget::LEPUS,
|
|
1251
|
+
custom_global_ident_names: None,
|
|
1252
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1253
|
+
}
|
|
1254
|
+
)),
|
|
1255
|
+
hygiene()
|
|
1256
|
+
),
|
|
1257
|
+
should_transform_multiple_worklets,
|
|
1258
|
+
r#"
|
|
1259
|
+
function X(event) {
|
|
1260
|
+
"main thread";
|
|
1261
|
+
console.log(y1[y2 + 1]);
|
|
1262
|
+
}
|
|
1263
|
+
function Y(event) {
|
|
1264
|
+
"main thread";
|
|
1265
|
+
console.log(z1[z2 + 1]);
|
|
1266
|
+
}
|
|
1267
|
+
"#
|
|
1268
|
+
);
|
|
1269
|
+
|
|
1270
|
+
test!(
|
|
1271
|
+
module,
|
|
1272
|
+
Syntax::Es(EsSyntax {
|
|
1273
|
+
..Default::default()
|
|
1274
|
+
}),
|
|
1275
|
+
|_| (
|
|
1276
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1277
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1278
|
+
TransformMode::Test,
|
|
1279
|
+
WorkletVisitorConfig {
|
|
1280
|
+
filename: "index.js".into(),
|
|
1281
|
+
target: TransformTarget::LEPUS,
|
|
1282
|
+
custom_global_ident_names: None,
|
|
1283
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1284
|
+
}
|
|
1285
|
+
)),
|
|
1286
|
+
hygiene()
|
|
1287
|
+
),
|
|
1288
|
+
should_transform_multiple_worklets_in_func,
|
|
1289
|
+
r#"
|
|
1290
|
+
function App() {
|
|
1291
|
+
function X(event) {
|
|
1292
|
+
"main thread";
|
|
1293
|
+
console.log(y1[y2 + 1]);
|
|
1294
|
+
}
|
|
1295
|
+
function Y(event) {
|
|
1296
|
+
"main thread";
|
|
1297
|
+
console.log(z1[z2 + 1]);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
"#
|
|
1301
|
+
);
|
|
1302
|
+
|
|
1303
|
+
test!(
|
|
1304
|
+
module,
|
|
1305
|
+
Syntax::Es(EsSyntax {
|
|
1306
|
+
..Default::default()
|
|
1307
|
+
}),
|
|
1308
|
+
|_| (
|
|
1309
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1310
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1311
|
+
TransformMode::Test,
|
|
1312
|
+
WorkletVisitorConfig {
|
|
1313
|
+
filename: "index.js".into(),
|
|
1314
|
+
target: TransformTarget::LEPUS,
|
|
1315
|
+
custom_global_ident_names: None,
|
|
1316
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1317
|
+
}
|
|
1318
|
+
)),
|
|
1319
|
+
hygiene()
|
|
1320
|
+
),
|
|
1321
|
+
should_transform_arrow_function,
|
|
1322
|
+
r#"
|
|
1323
|
+
let X = (event) => {
|
|
1324
|
+
"main thread";
|
|
1325
|
+
console.log(y1[y2 + 1]);
|
|
1326
|
+
}
|
|
1327
|
+
"#
|
|
1328
|
+
);
|
|
1329
|
+
|
|
1330
|
+
test!(
|
|
1331
|
+
module,
|
|
1332
|
+
Syntax::Es(EsSyntax {
|
|
1333
|
+
..Default::default()
|
|
1334
|
+
}),
|
|
1335
|
+
|_| (
|
|
1336
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1337
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1338
|
+
TransformMode::Test,
|
|
1339
|
+
WorkletVisitorConfig {
|
|
1340
|
+
filename: "index.js".into(),
|
|
1341
|
+
target: TransformTarget::LEPUS,
|
|
1342
|
+
custom_global_ident_names: None,
|
|
1343
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1344
|
+
}
|
|
1345
|
+
)),
|
|
1346
|
+
hygiene()
|
|
1347
|
+
),
|
|
1348
|
+
should_transform_function_expr,
|
|
1349
|
+
r#"
|
|
1350
|
+
let X = function (event) {
|
|
1351
|
+
"main thread";
|
|
1352
|
+
console.log(y1[y2 + 1]);
|
|
1353
|
+
}
|
|
1354
|
+
"#
|
|
1355
|
+
);
|
|
1356
|
+
|
|
1357
|
+
test!(
|
|
1358
|
+
module,
|
|
1359
|
+
Syntax::Es(EsSyntax {
|
|
1360
|
+
..Default::default()
|
|
1361
|
+
}),
|
|
1362
|
+
|_| (
|
|
1363
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1364
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1365
|
+
TransformMode::Test,
|
|
1366
|
+
WorkletVisitorConfig {
|
|
1367
|
+
filename: "index.js".into(),
|
|
1368
|
+
target: TransformTarget::LEPUS,
|
|
1369
|
+
custom_global_ident_names: None,
|
|
1370
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1371
|
+
}
|
|
1372
|
+
)),
|
|
1373
|
+
hygiene()
|
|
1374
|
+
),
|
|
1375
|
+
should_transform_in_class_lepus,
|
|
1376
|
+
r#"
|
|
1377
|
+
class App extends Component {
|
|
1378
|
+
a = 1;
|
|
1379
|
+
|
|
1380
|
+
onTapLepus(event) {
|
|
1381
|
+
"main thread";
|
|
1382
|
+
console.log(this.a);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
"#
|
|
1386
|
+
);
|
|
1387
|
+
|
|
1388
|
+
test!(
|
|
1389
|
+
module,
|
|
1390
|
+
Syntax::Es(EsSyntax {
|
|
1391
|
+
..Default::default()
|
|
1392
|
+
}),
|
|
1393
|
+
|_| (
|
|
1394
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1395
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1396
|
+
TransformMode::Test,
|
|
1397
|
+
WorkletVisitorConfig {
|
|
1398
|
+
filename: "index.js".into(),
|
|
1399
|
+
target: TransformTarget::JS,
|
|
1400
|
+
custom_global_ident_names: None,
|
|
1401
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1402
|
+
}
|
|
1403
|
+
)),
|
|
1404
|
+
hygiene()
|
|
1405
|
+
),
|
|
1406
|
+
should_transform_in_class_js,
|
|
1407
|
+
r#"
|
|
1408
|
+
class App extends Component {
|
|
1409
|
+
a = 1;
|
|
1410
|
+
|
|
1411
|
+
onTapLepus(event) {
|
|
1412
|
+
"main thread";
|
|
1413
|
+
console.log(this.a);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
"#
|
|
1417
|
+
);
|
|
1418
|
+
|
|
1419
|
+
test!(
|
|
1420
|
+
module,
|
|
1421
|
+
Syntax::Es(EsSyntax {
|
|
1422
|
+
..Default::default()
|
|
1423
|
+
}),
|
|
1424
|
+
|_| (
|
|
1425
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1426
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1427
|
+
TransformMode::Test,
|
|
1428
|
+
WorkletVisitorConfig {
|
|
1429
|
+
filename: "index.js".into(),
|
|
1430
|
+
target: TransformTarget::JS,
|
|
1431
|
+
custom_global_ident_names: None,
|
|
1432
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1433
|
+
}
|
|
1434
|
+
)),
|
|
1435
|
+
hygiene()
|
|
1436
|
+
),
|
|
1437
|
+
should_transform_in_class_js_capture_values,
|
|
1438
|
+
r#"
|
|
1439
|
+
let a = 1;
|
|
1440
|
+
class App extends Component {
|
|
1441
|
+
onTapLepus(event) {
|
|
1442
|
+
"main thread";
|
|
1443
|
+
console.log(a);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
"#
|
|
1447
|
+
);
|
|
1448
|
+
|
|
1449
|
+
test!(
|
|
1450
|
+
module,
|
|
1451
|
+
Syntax::Es(EsSyntax {
|
|
1452
|
+
..Default::default()
|
|
1453
|
+
}),
|
|
1454
|
+
|_| (
|
|
1455
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1456
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1457
|
+
TransformMode::Test,
|
|
1458
|
+
WorkletVisitorConfig {
|
|
1459
|
+
filename: "index.js".into(),
|
|
1460
|
+
target: TransformTarget::LEPUS,
|
|
1461
|
+
custom_global_ident_names: None,
|
|
1462
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1463
|
+
}
|
|
1464
|
+
)),
|
|
1465
|
+
hygiene()
|
|
1466
|
+
),
|
|
1467
|
+
should_transform_in_class_static_lepus,
|
|
1468
|
+
r#"
|
|
1469
|
+
let a = 1;
|
|
1470
|
+
class App extends Component {
|
|
1471
|
+
static onTapLepus(event) {
|
|
1472
|
+
"main thread";
|
|
1473
|
+
console.log(a);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
"#
|
|
1477
|
+
);
|
|
1478
|
+
|
|
1479
|
+
test!(
|
|
1480
|
+
module,
|
|
1481
|
+
Syntax::Es(EsSyntax {
|
|
1482
|
+
..Default::default()
|
|
1483
|
+
}),
|
|
1484
|
+
|_| (
|
|
1485
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1486
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1487
|
+
TransformMode::Test,
|
|
1488
|
+
WorkletVisitorConfig {
|
|
1489
|
+
filename: "index.js".into(),
|
|
1490
|
+
target: TransformTarget::JS,
|
|
1491
|
+
custom_global_ident_names: None,
|
|
1492
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1493
|
+
}
|
|
1494
|
+
)),
|
|
1495
|
+
hygiene()
|
|
1496
|
+
),
|
|
1497
|
+
should_transform_in_class_static_js,
|
|
1498
|
+
r#"
|
|
1499
|
+
let a = 1;
|
|
1500
|
+
class App extends Component {
|
|
1501
|
+
static onTapLepus(event) {
|
|
1502
|
+
"main thread";
|
|
1503
|
+
console.log(a);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
"#
|
|
1507
|
+
);
|
|
1508
|
+
|
|
1509
|
+
test!(
|
|
1510
|
+
module,
|
|
1511
|
+
Syntax::Es(EsSyntax {
|
|
1512
|
+
..Default::default()
|
|
1513
|
+
}),
|
|
1514
|
+
|_| (
|
|
1515
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1516
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1517
|
+
TransformMode::Test,
|
|
1518
|
+
WorkletVisitorConfig {
|
|
1519
|
+
filename: "index.js".into(),
|
|
1520
|
+
target: TransformTarget::LEPUS,
|
|
1521
|
+
custom_global_ident_names: None,
|
|
1522
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1523
|
+
}
|
|
1524
|
+
)),
|
|
1525
|
+
hygiene()
|
|
1526
|
+
),
|
|
1527
|
+
should_transform_in_class_property_lepus,
|
|
1528
|
+
r#"
|
|
1529
|
+
let a = 1;
|
|
1530
|
+
class App extends Component {
|
|
1531
|
+
onTapLepus = (event) => {
|
|
1532
|
+
"main thread";
|
|
1533
|
+
console.log(a);
|
|
1534
|
+
console.log(this.a);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
"#
|
|
1538
|
+
);
|
|
1539
|
+
|
|
1540
|
+
test!(
|
|
1541
|
+
module,
|
|
1542
|
+
Syntax::Es(EsSyntax {
|
|
1543
|
+
..Default::default()
|
|
1544
|
+
}),
|
|
1545
|
+
|_| (
|
|
1546
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1547
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1548
|
+
TransformMode::Test,
|
|
1549
|
+
WorkletVisitorConfig {
|
|
1550
|
+
filename: "index.js".into(),
|
|
1551
|
+
target: TransformTarget::JS,
|
|
1552
|
+
custom_global_ident_names: None,
|
|
1553
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1554
|
+
}
|
|
1555
|
+
)),
|
|
1556
|
+
hygiene()
|
|
1557
|
+
),
|
|
1558
|
+
should_transform_in_class_property_js,
|
|
1559
|
+
r#"
|
|
1560
|
+
let a = 1;
|
|
1561
|
+
class App extends Component {
|
|
1562
|
+
onTapLepus = (event) => {
|
|
1563
|
+
"main thread";
|
|
1564
|
+
console.log(a);
|
|
1565
|
+
console.log(this.a);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
"#
|
|
1569
|
+
);
|
|
1570
|
+
|
|
1571
|
+
test!(
|
|
1572
|
+
module,
|
|
1573
|
+
Syntax::Es(EsSyntax {
|
|
1574
|
+
..Default::default()
|
|
1575
|
+
}),
|
|
1576
|
+
|_| (
|
|
1577
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1578
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1579
|
+
TransformMode::Test,
|
|
1580
|
+
WorkletVisitorConfig {
|
|
1581
|
+
filename: "index.js".into(),
|
|
1582
|
+
target: TransformTarget::JS,
|
|
1583
|
+
custom_global_ident_names: None,
|
|
1584
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1585
|
+
}
|
|
1586
|
+
)),
|
|
1587
|
+
hygiene()
|
|
1588
|
+
),
|
|
1589
|
+
should_transform_in_class_property_js_capture_values,
|
|
1590
|
+
r#"
|
|
1591
|
+
let a = 1;
|
|
1592
|
+
class App extends Component {
|
|
1593
|
+
onTapLepus = (event) => {
|
|
1594
|
+
"main thread";
|
|
1595
|
+
console.log(a);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
"#
|
|
1599
|
+
);
|
|
1600
|
+
|
|
1601
|
+
test!(
|
|
1602
|
+
module,
|
|
1603
|
+
Syntax::Es(EsSyntax {
|
|
1604
|
+
..Default::default()
|
|
1605
|
+
}),
|
|
1606
|
+
|_| (
|
|
1607
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1608
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1609
|
+
TransformMode::Test,
|
|
1610
|
+
WorkletVisitorConfig {
|
|
1611
|
+
filename: "index.js".into(),
|
|
1612
|
+
target: TransformTarget::LEPUS,
|
|
1613
|
+
custom_global_ident_names: None,
|
|
1614
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1615
|
+
}
|
|
1616
|
+
)),
|
|
1617
|
+
hygiene()
|
|
1618
|
+
),
|
|
1619
|
+
should_transform_in_class_static_property_lepus,
|
|
1620
|
+
r#"
|
|
1621
|
+
let a = 1;
|
|
1622
|
+
class App extends Component {
|
|
1623
|
+
static onTapLepus = (event) => {
|
|
1624
|
+
"main thread";
|
|
1625
|
+
console.log(a);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
"#
|
|
1629
|
+
);
|
|
1630
|
+
|
|
1631
|
+
test!(
|
|
1632
|
+
module,
|
|
1633
|
+
Syntax::Es(EsSyntax {
|
|
1634
|
+
..Default::default()
|
|
1635
|
+
}),
|
|
1636
|
+
|_| (
|
|
1637
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1638
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1639
|
+
TransformMode::Test,
|
|
1640
|
+
WorkletVisitorConfig {
|
|
1641
|
+
filename: "index.js".into(),
|
|
1642
|
+
target: TransformTarget::JS,
|
|
1643
|
+
custom_global_ident_names: None,
|
|
1644
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1645
|
+
}
|
|
1646
|
+
)),
|
|
1647
|
+
hygiene()
|
|
1648
|
+
),
|
|
1649
|
+
should_transform_in_class_static_property_js,
|
|
1650
|
+
r#"
|
|
1651
|
+
let a = 1;
|
|
1652
|
+
class App extends Component {
|
|
1653
|
+
static onTapLepus = (event) => {
|
|
1654
|
+
"main thread";
|
|
1655
|
+
console.log(a);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
"#
|
|
1659
|
+
);
|
|
1660
|
+
|
|
1661
|
+
test!(
|
|
1662
|
+
module,
|
|
1663
|
+
Syntax::Es(EsSyntax {
|
|
1664
|
+
..Default::default()
|
|
1665
|
+
}),
|
|
1666
|
+
|_| (
|
|
1667
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1668
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1669
|
+
TransformMode::Test,
|
|
1670
|
+
WorkletVisitorConfig {
|
|
1671
|
+
filename: "index.js".into(),
|
|
1672
|
+
target: TransformTarget::LEPUS,
|
|
1673
|
+
custom_global_ident_names: None,
|
|
1674
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1675
|
+
}
|
|
1676
|
+
)),
|
|
1677
|
+
hygiene()
|
|
1678
|
+
),
|
|
1679
|
+
should_not_transform_recursively,
|
|
1680
|
+
r#"
|
|
1681
|
+
function X() {
|
|
1682
|
+
"main thread";
|
|
1683
|
+
console.log(y1[y2 + 1]);
|
|
1684
|
+
function Y() {
|
|
1685
|
+
"main thread";
|
|
1686
|
+
console.log(y1[y2 + 1]);
|
|
1687
|
+
console.log(z1[z2 + 1]);
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
"#
|
|
1691
|
+
);
|
|
1692
|
+
|
|
1693
|
+
test!(
|
|
1694
|
+
module,
|
|
1695
|
+
Syntax::Es(EsSyntax {
|
|
1696
|
+
..Default::default()
|
|
1697
|
+
}),
|
|
1698
|
+
|_| (
|
|
1699
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1700
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1701
|
+
TransformMode::Test,
|
|
1702
|
+
WorkletVisitorConfig {
|
|
1703
|
+
filename: "index.js".into(),
|
|
1704
|
+
target: TransformTarget::LEPUS,
|
|
1705
|
+
custom_global_ident_names: None,
|
|
1706
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1707
|
+
}
|
|
1708
|
+
)),
|
|
1709
|
+
hygiene()
|
|
1710
|
+
),
|
|
1711
|
+
should_not_transform_when_wrong_directives,
|
|
1712
|
+
r#"
|
|
1713
|
+
function X() {
|
|
1714
|
+
"main threads";
|
|
1715
|
+
console.log(y1[y2 + 1]);
|
|
1716
|
+
}
|
|
1717
|
+
function Y() {
|
|
1718
|
+
console.log(y1[y2 + 1]);
|
|
1719
|
+
}
|
|
1720
|
+
function Z() {
|
|
1721
|
+
console.log("main thread");
|
|
1722
|
+
}
|
|
1723
|
+
function A() {
|
|
1724
|
+
console.log("");
|
|
1725
|
+
"main thread";
|
|
1726
|
+
}
|
|
1727
|
+
"#
|
|
1728
|
+
);
|
|
1729
|
+
|
|
1730
|
+
test!(
|
|
1731
|
+
module,
|
|
1732
|
+
Syntax::Es(EsSyntax {
|
|
1733
|
+
..Default::default()
|
|
1734
|
+
}),
|
|
1735
|
+
|_| (
|
|
1736
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1737
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1738
|
+
TransformMode::Test,
|
|
1739
|
+
WorkletVisitorConfig {
|
|
1740
|
+
filename: "index.js".into(),
|
|
1741
|
+
target: TransformTarget::JS,
|
|
1742
|
+
custom_global_ident_names: None,
|
|
1743
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1744
|
+
}
|
|
1745
|
+
)),
|
|
1746
|
+
hygiene()
|
|
1747
|
+
),
|
|
1748
|
+
should_not_transform_getter_and_setter,
|
|
1749
|
+
r#"
|
|
1750
|
+
let a = 1;
|
|
1751
|
+
class App extends Component {
|
|
1752
|
+
get x() {
|
|
1753
|
+
"main thread";
|
|
1754
|
+
return a;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
class Bpp extends Component {
|
|
1758
|
+
set x(n) {
|
|
1759
|
+
"main thread";
|
|
1760
|
+
this.a = n;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
"#
|
|
1764
|
+
);
|
|
1765
|
+
|
|
1766
|
+
test!(
|
|
1767
|
+
module,
|
|
1768
|
+
Syntax::Es(EsSyntax {
|
|
1769
|
+
..Default::default()
|
|
1770
|
+
}),
|
|
1771
|
+
|_| (
|
|
1772
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1773
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1774
|
+
TransformMode::Test,
|
|
1775
|
+
WorkletVisitorConfig {
|
|
1776
|
+
filename: "index.js".into(),
|
|
1777
|
+
target: TransformTarget::JS,
|
|
1778
|
+
custom_global_ident_names: None,
|
|
1779
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1780
|
+
}
|
|
1781
|
+
)),
|
|
1782
|
+
hygiene()
|
|
1783
|
+
),
|
|
1784
|
+
should_not_transform_constructor,
|
|
1785
|
+
r#"
|
|
1786
|
+
let a = 1;
|
|
1787
|
+
class App extends Component {
|
|
1788
|
+
constructor() {
|
|
1789
|
+
"main thread";
|
|
1790
|
+
return a;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
"#
|
|
1794
|
+
);
|
|
1795
|
+
|
|
1796
|
+
test!(
|
|
1797
|
+
module,
|
|
1798
|
+
Syntax::Es(EsSyntax {
|
|
1799
|
+
..Default::default()
|
|
1800
|
+
}),
|
|
1801
|
+
|_| (
|
|
1802
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1803
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1804
|
+
TransformMode::Test,
|
|
1805
|
+
WorkletVisitorConfig {
|
|
1806
|
+
filename: "index.js".into(),
|
|
1807
|
+
target: TransformTarget::LEPUS,
|
|
1808
|
+
custom_global_ident_names: None,
|
|
1809
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1810
|
+
}
|
|
1811
|
+
)),
|
|
1812
|
+
hygiene()
|
|
1813
|
+
),
|
|
1814
|
+
should_not_destructure_from_closure,
|
|
1815
|
+
r#"
|
|
1816
|
+
function Y(n) {
|
|
1817
|
+
"main thread";
|
|
1818
|
+
let a = 123;
|
|
1819
|
+
n;
|
|
1820
|
+
}
|
|
1821
|
+
"#
|
|
1822
|
+
);
|
|
1823
|
+
|
|
1824
|
+
test!(
|
|
1825
|
+
module,
|
|
1826
|
+
Syntax::Es(EsSyntax {
|
|
1827
|
+
..Default::default()
|
|
1828
|
+
}),
|
|
1829
|
+
|_| (
|
|
1830
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1831
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1832
|
+
TransformMode::Test,
|
|
1833
|
+
WorkletVisitorConfig {
|
|
1834
|
+
filename: "index.js".into(),
|
|
1835
|
+
target: TransformTarget::LEPUS,
|
|
1836
|
+
custom_global_ident_names: None,
|
|
1837
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1838
|
+
}
|
|
1839
|
+
)),
|
|
1840
|
+
hygiene()
|
|
1841
|
+
),
|
|
1842
|
+
should_capture_env_lepus,
|
|
1843
|
+
r#"
|
|
1844
|
+
function Y() {
|
|
1845
|
+
"main thread";
|
|
1846
|
+
let a = 123;
|
|
1847
|
+
const b = [ a, ...y1];
|
|
1848
|
+
const c = { a, y2, ...y3, ...{ d: 233, e: y4 } };
|
|
1849
|
+
return y5.r;
|
|
1850
|
+
}
|
|
1851
|
+
"#
|
|
1852
|
+
);
|
|
1853
|
+
|
|
1854
|
+
test!(
|
|
1855
|
+
module,
|
|
1856
|
+
Syntax::Es(EsSyntax {
|
|
1857
|
+
..Default::default()
|
|
1858
|
+
}),
|
|
1859
|
+
|_| (
|
|
1860
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1861
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1862
|
+
TransformMode::Test,
|
|
1863
|
+
WorkletVisitorConfig {
|
|
1864
|
+
filename: "index.js".into(),
|
|
1865
|
+
target: TransformTarget::JS,
|
|
1866
|
+
custom_global_ident_names: None,
|
|
1867
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1868
|
+
}
|
|
1869
|
+
)),
|
|
1870
|
+
hygiene()
|
|
1871
|
+
),
|
|
1872
|
+
should_capture_env_js,
|
|
1873
|
+
r#"
|
|
1874
|
+
function Y() {
|
|
1875
|
+
"main thread";
|
|
1876
|
+
let a = 123;
|
|
1877
|
+
const b = [ a, ...y1];
|
|
1878
|
+
const c = { a, y2, ...y3, ...{ d: 233, e: y4 } };
|
|
1879
|
+
return y5.r;
|
|
1880
|
+
}
|
|
1881
|
+
"#
|
|
1882
|
+
);
|
|
1883
|
+
|
|
1884
|
+
test!(
|
|
1885
|
+
module,
|
|
1886
|
+
Syntax::Es(EsSyntax {
|
|
1887
|
+
..Default::default()
|
|
1888
|
+
}),
|
|
1889
|
+
|_| (
|
|
1890
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1891
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1892
|
+
TransformMode::Test,
|
|
1893
|
+
WorkletVisitorConfig {
|
|
1894
|
+
filename: "index.js".into(),
|
|
1895
|
+
target: TransformTarget::LEPUS,
|
|
1896
|
+
custom_global_ident_names: Some(vec!["myCustomGlobal".to_string()]),
|
|
1897
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1898
|
+
}
|
|
1899
|
+
)),
|
|
1900
|
+
hygiene()
|
|
1901
|
+
),
|
|
1902
|
+
should_not_capture_globals,
|
|
1903
|
+
r#"
|
|
1904
|
+
function Y() {
|
|
1905
|
+
"main thread";
|
|
1906
|
+
console.log(111);
|
|
1907
|
+
setTimeout(() => {});
|
|
1908
|
+
lynx.querySelector();
|
|
1909
|
+
SystemInfo.version;
|
|
1910
|
+
myCustomGlobal;
|
|
1911
|
+
}
|
|
1912
|
+
"#
|
|
1913
|
+
);
|
|
1914
|
+
|
|
1915
|
+
test!(
|
|
1916
|
+
module,
|
|
1917
|
+
Syntax::Typescript(TsSyntax {
|
|
1918
|
+
..Default::default()
|
|
1919
|
+
}),
|
|
1920
|
+
|_| (
|
|
1921
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1922
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1923
|
+
TransformMode::Test,
|
|
1924
|
+
WorkletVisitorConfig {
|
|
1925
|
+
filename: "index.ts".into(),
|
|
1926
|
+
target: TransformTarget::LEPUS,
|
|
1927
|
+
custom_global_ident_names: None,
|
|
1928
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1929
|
+
}
|
|
1930
|
+
)),
|
|
1931
|
+
hygiene()
|
|
1932
|
+
),
|
|
1933
|
+
should_not_capture_type_annotations,
|
|
1934
|
+
r#"
|
|
1935
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
1936
|
+
"main thread";
|
|
1937
|
+
type XXXX = YYYY;
|
|
1938
|
+
class N {};
|
|
1939
|
+
let a: AClass = 0;
|
|
1940
|
+
console.log(a);
|
|
1941
|
+
event.target.setStyle("background-color", wv.current % 2 ? "blue" : "green");
|
|
1942
|
+
event.target.setStyle("height", "200px");
|
|
1943
|
+
}
|
|
1944
|
+
"#
|
|
1945
|
+
);
|
|
1946
|
+
|
|
1947
|
+
test!(
|
|
1948
|
+
module,
|
|
1949
|
+
Syntax::Typescript(TsSyntax {
|
|
1950
|
+
..Default::default()
|
|
1951
|
+
}),
|
|
1952
|
+
|_| (
|
|
1953
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1954
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1955
|
+
TransformMode::Test,
|
|
1956
|
+
WorkletVisitorConfig {
|
|
1957
|
+
filename: "index.ts".into(),
|
|
1958
|
+
target: TransformTarget::JS,
|
|
1959
|
+
custom_global_ident_names: None,
|
|
1960
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1961
|
+
}
|
|
1962
|
+
)),
|
|
1963
|
+
hygiene()
|
|
1964
|
+
),
|
|
1965
|
+
should_transform_js_fn_in_run_on_js_js,
|
|
1966
|
+
r#"
|
|
1967
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
1968
|
+
"main thread";
|
|
1969
|
+
runOnBackground(fn1);
|
|
1970
|
+
runOnBackground(obj.fn2);
|
|
1971
|
+
runOnBackground(obj[fn3]);
|
|
1972
|
+
}
|
|
1973
|
+
"#
|
|
1974
|
+
);
|
|
1975
|
+
|
|
1976
|
+
test!(
|
|
1977
|
+
module,
|
|
1978
|
+
Syntax::Typescript(TsSyntax {
|
|
1979
|
+
..Default::default()
|
|
1980
|
+
}),
|
|
1981
|
+
|_| (
|
|
1982
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
1983
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
1984
|
+
TransformMode::Test,
|
|
1985
|
+
WorkletVisitorConfig {
|
|
1986
|
+
filename: "index.ts".into(),
|
|
1987
|
+
target: TransformTarget::LEPUS,
|
|
1988
|
+
custom_global_ident_names: None,
|
|
1989
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
1990
|
+
}
|
|
1991
|
+
)),
|
|
1992
|
+
hygiene()
|
|
1993
|
+
),
|
|
1994
|
+
should_transform_js_fn_in_run_on_js_lepus,
|
|
1995
|
+
r#"
|
|
1996
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
1997
|
+
"main thread";
|
|
1998
|
+
runOnBackground(fn1);
|
|
1999
|
+
runOnBackground(obj.fn2);
|
|
2000
|
+
runOnBackground(obj[fn3]);
|
|
2001
|
+
}
|
|
2002
|
+
"#
|
|
2003
|
+
);
|
|
2004
|
+
|
|
2005
|
+
test!(
|
|
2006
|
+
module,
|
|
2007
|
+
Syntax::Typescript(TsSyntax {
|
|
2008
|
+
..Default::default()
|
|
2009
|
+
}),
|
|
2010
|
+
|_| (
|
|
2011
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2012
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2013
|
+
TransformMode::Test,
|
|
2014
|
+
WorkletVisitorConfig {
|
|
2015
|
+
filename: "index.ts".into(),
|
|
2016
|
+
target: TransformTarget::JS,
|
|
2017
|
+
custom_global_ident_names: None,
|
|
2018
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2019
|
+
}
|
|
2020
|
+
)),
|
|
2021
|
+
hygiene()
|
|
2022
|
+
),
|
|
2023
|
+
should_extract_idents_outside_of_ctx,
|
|
2024
|
+
r#"
|
|
2025
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2026
|
+
"main thread";
|
|
2027
|
+
if(true) {
|
|
2028
|
+
let a = 1;
|
|
2029
|
+
a;
|
|
2030
|
+
}
|
|
2031
|
+
a;
|
|
2032
|
+
function fn(m, x) {
|
|
2033
|
+
let b = 1;
|
|
2034
|
+
m;
|
|
2035
|
+
x;
|
|
2036
|
+
b;
|
|
2037
|
+
}
|
|
2038
|
+
m;
|
|
2039
|
+
b;
|
|
2040
|
+
c;
|
|
2041
|
+
}
|
|
2042
|
+
"#
|
|
2043
|
+
);
|
|
2044
|
+
|
|
2045
|
+
test!(
|
|
2046
|
+
module,
|
|
2047
|
+
Syntax::Typescript(TsSyntax {
|
|
2048
|
+
..Default::default()
|
|
2049
|
+
}),
|
|
2050
|
+
|_| (
|
|
2051
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2052
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2053
|
+
TransformMode::Test,
|
|
2054
|
+
WorkletVisitorConfig {
|
|
2055
|
+
filename: "index.ts".into(),
|
|
2056
|
+
target: TransformTarget::LEPUS,
|
|
2057
|
+
custom_global_ident_names: None,
|
|
2058
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2059
|
+
}
|
|
2060
|
+
)),
|
|
2061
|
+
hygiene()
|
|
2062
|
+
),
|
|
2063
|
+
should_not_extract_idents_inside_of_ctx,
|
|
2064
|
+
r#"
|
|
2065
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2066
|
+
"main thread";
|
|
2067
|
+
if(true) {
|
|
2068
|
+
let a = 1;
|
|
2069
|
+
a;
|
|
2070
|
+
}
|
|
2071
|
+
function f(e) {
|
|
2072
|
+
f;
|
|
2073
|
+
e;
|
|
2074
|
+
}
|
|
2075
|
+
if(true) {
|
|
2076
|
+
var b = 1;
|
|
2077
|
+
b;
|
|
2078
|
+
}
|
|
2079
|
+
b;
|
|
2080
|
+
f;
|
|
2081
|
+
}
|
|
2082
|
+
"#
|
|
2083
|
+
);
|
|
2084
|
+
|
|
2085
|
+
test!(
|
|
2086
|
+
module,
|
|
2087
|
+
Syntax::Typescript(TsSyntax {
|
|
2088
|
+
..Default::default()
|
|
2089
|
+
}),
|
|
2090
|
+
|_| (
|
|
2091
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2092
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2093
|
+
TransformMode::Test,
|
|
2094
|
+
WorkletVisitorConfig {
|
|
2095
|
+
filename: "index.ts".into(),
|
|
2096
|
+
target: TransformTarget::LEPUS,
|
|
2097
|
+
custom_global_ident_names: None,
|
|
2098
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2099
|
+
}
|
|
2100
|
+
)),
|
|
2101
|
+
hygiene()
|
|
2102
|
+
),
|
|
2103
|
+
should_not_extract_catch_clause_params,
|
|
2104
|
+
r#"
|
|
2105
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2106
|
+
"main thread";
|
|
2107
|
+
try {} catch(e) {}
|
|
2108
|
+
try {} catch({f, g}) {}
|
|
2109
|
+
g;
|
|
2110
|
+
}
|
|
2111
|
+
"#
|
|
2112
|
+
);
|
|
2113
|
+
|
|
2114
|
+
test!(
|
|
2115
|
+
module,
|
|
2116
|
+
Syntax::Typescript(TsSyntax {
|
|
2117
|
+
..Default::default()
|
|
2118
|
+
}),
|
|
2119
|
+
|_| (
|
|
2120
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2121
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2122
|
+
TransformMode::Test,
|
|
2123
|
+
WorkletVisitorConfig {
|
|
2124
|
+
filename: "index.ts".into(),
|
|
2125
|
+
target: TransformTarget::LEPUS,
|
|
2126
|
+
custom_global_ident_names: None,
|
|
2127
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2128
|
+
}
|
|
2129
|
+
)),
|
|
2130
|
+
hygiene()
|
|
2131
|
+
),
|
|
2132
|
+
should_extract_ident_from_this_lepus,
|
|
2133
|
+
r#"
|
|
2134
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2135
|
+
"main thread";
|
|
2136
|
+
let a = 1;
|
|
2137
|
+
this.a;
|
|
2138
|
+
}
|
|
2139
|
+
"#
|
|
2140
|
+
);
|
|
2141
|
+
|
|
2142
|
+
test!(
|
|
2143
|
+
module,
|
|
2144
|
+
Syntax::Typescript(TsSyntax {
|
|
2145
|
+
..Default::default()
|
|
2146
|
+
}),
|
|
2147
|
+
|_| (
|
|
2148
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2149
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2150
|
+
TransformMode::Test,
|
|
2151
|
+
WorkletVisitorConfig {
|
|
2152
|
+
filename: "index.ts".into(),
|
|
2153
|
+
target: TransformTarget::JS,
|
|
2154
|
+
custom_global_ident_names: None,
|
|
2155
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2156
|
+
}
|
|
2157
|
+
)),
|
|
2158
|
+
hygiene()
|
|
2159
|
+
),
|
|
2160
|
+
should_extract_ident_from_this_js,
|
|
2161
|
+
r#"
|
|
2162
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2163
|
+
"main thread";
|
|
2164
|
+
let a = 1;
|
|
2165
|
+
this.a;
|
|
2166
|
+
}
|
|
2167
|
+
"#
|
|
2168
|
+
);
|
|
2169
|
+
|
|
2170
|
+
test!(
|
|
2171
|
+
module,
|
|
2172
|
+
Syntax::Typescript(TsSyntax {
|
|
2173
|
+
..Default::default()
|
|
2174
|
+
}),
|
|
2175
|
+
|_| (
|
|
2176
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2177
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2178
|
+
TransformMode::Test,
|
|
2179
|
+
WorkletVisitorConfig {
|
|
2180
|
+
filename: "index.ts".into(),
|
|
2181
|
+
target: TransformTarget::JS,
|
|
2182
|
+
custom_global_ident_names: None,
|
|
2183
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2184
|
+
}
|
|
2185
|
+
)),
|
|
2186
|
+
hygiene()
|
|
2187
|
+
),
|
|
2188
|
+
should_not_extract_ident_from_this,
|
|
2189
|
+
r#"
|
|
2190
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2191
|
+
"main thread";
|
|
2192
|
+
class C {
|
|
2193
|
+
a = 1;
|
|
2194
|
+
b = 1;
|
|
2195
|
+
c = 1;
|
|
2196
|
+
d = 1;
|
|
2197
|
+
constructor() {
|
|
2198
|
+
this.b;
|
|
2199
|
+
}
|
|
2200
|
+
get GET() {
|
|
2201
|
+
return this.c;
|
|
2202
|
+
}
|
|
2203
|
+
set SET(v) {
|
|
2204
|
+
this.d;
|
|
2205
|
+
}
|
|
2206
|
+
f() {
|
|
2207
|
+
this.a;
|
|
2208
|
+
}
|
|
2209
|
+
x = 1;
|
|
2210
|
+
}
|
|
2211
|
+
function g() {
|
|
2212
|
+
this.b;
|
|
2213
|
+
}
|
|
2214
|
+
x;
|
|
2215
|
+
() => {
|
|
2216
|
+
this.y;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
"#
|
|
2220
|
+
);
|
|
2221
|
+
|
|
2222
|
+
test!(
|
|
2223
|
+
module,
|
|
2224
|
+
Syntax::Typescript(TsSyntax {
|
|
2225
|
+
..Default::default()
|
|
2226
|
+
}),
|
|
2227
|
+
|_| (
|
|
2228
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2229
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2230
|
+
TransformMode::Test,
|
|
2231
|
+
WorkletVisitorConfig {
|
|
2232
|
+
filename: "index.ts".into(),
|
|
2233
|
+
target: TransformTarget::JS,
|
|
2234
|
+
custom_global_ident_names: None,
|
|
2235
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2236
|
+
}
|
|
2237
|
+
)),
|
|
2238
|
+
hygiene()
|
|
2239
|
+
),
|
|
2240
|
+
should_transform_ui_worklet_js,
|
|
2241
|
+
r#"
|
|
2242
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2243
|
+
"use worklet";
|
|
2244
|
+
a;
|
|
2245
|
+
}
|
|
2246
|
+
"#
|
|
2247
|
+
);
|
|
2248
|
+
|
|
2249
|
+
test!(
|
|
2250
|
+
module,
|
|
2251
|
+
Syntax::Typescript(TsSyntax {
|
|
2252
|
+
..Default::default()
|
|
2253
|
+
}),
|
|
2254
|
+
|_| (
|
|
2255
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2256
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2257
|
+
TransformMode::Test,
|
|
2258
|
+
WorkletVisitorConfig {
|
|
2259
|
+
filename: "index.ts".into(),
|
|
2260
|
+
target: TransformTarget::LEPUS,
|
|
2261
|
+
custom_global_ident_names: None,
|
|
2262
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2263
|
+
}
|
|
2264
|
+
)),
|
|
2265
|
+
hygiene()
|
|
2266
|
+
),
|
|
2267
|
+
should_transform_ui_worklet_lepus,
|
|
2268
|
+
r#"
|
|
2269
|
+
function onTapLepus(event: ReactLynx.Worklet.ITouchEvent) {
|
|
2270
|
+
"use worklet";
|
|
2271
|
+
a;
|
|
2272
|
+
}
|
|
2273
|
+
"#
|
|
2274
|
+
);
|
|
2275
|
+
|
|
2276
|
+
test!(
|
|
2277
|
+
module,
|
|
2278
|
+
Syntax::Typescript(TsSyntax {
|
|
2279
|
+
..Default::default()
|
|
2280
|
+
}),
|
|
2281
|
+
|_| (
|
|
2282
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2283
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2284
|
+
TransformMode::Test,
|
|
2285
|
+
WorkletVisitorConfig {
|
|
2286
|
+
filename: "index.ts".into(),
|
|
2287
|
+
target: TransformTarget::JS,
|
|
2288
|
+
custom_global_ident_names: None,
|
|
2289
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2290
|
+
}
|
|
2291
|
+
)),
|
|
2292
|
+
hygiene()
|
|
2293
|
+
),
|
|
2294
|
+
class_in_worklet_1,
|
|
2295
|
+
r#"
|
|
2296
|
+
function onTapLepus() {
|
|
2297
|
+
"main thread";
|
|
2298
|
+
class C {
|
|
2299
|
+
onUpdate: (progress: number) => number;
|
|
2300
|
+
|
|
2301
|
+
constructor() {
|
|
2302
|
+
this.b;
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
f() {
|
|
2306
|
+
const progress = undefined;
|
|
2307
|
+
this.onUpdate(progress);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
"#
|
|
2312
|
+
);
|
|
2313
|
+
|
|
2314
|
+
test!(
|
|
2315
|
+
module,
|
|
2316
|
+
Syntax::Typescript(TsSyntax {
|
|
2317
|
+
..Default::default()
|
|
2318
|
+
}),
|
|
2319
|
+
|_| (
|
|
2320
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2321
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2322
|
+
TransformMode::Test,
|
|
2323
|
+
WorkletVisitorConfig {
|
|
2324
|
+
filename: "index.ts".into(),
|
|
2325
|
+
target: TransformTarget::JS,
|
|
2326
|
+
custom_global_ident_names: None,
|
|
2327
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2328
|
+
}
|
|
2329
|
+
)),
|
|
2330
|
+
hygiene()
|
|
2331
|
+
),
|
|
2332
|
+
should_extract_member_expr_js,
|
|
2333
|
+
r#"
|
|
2334
|
+
function onTapLepus() {
|
|
2335
|
+
"main thread";
|
|
2336
|
+
aaaa.bbbb[cccc.dddd].eeee;
|
|
2337
|
+
aaaa.bbbb[cccc.dddd].eeee;
|
|
2338
|
+
aaaa.bbbb[cccc.dddd].eeee;
|
|
2339
|
+
hhhh.iiii.current.jjjj;
|
|
2340
|
+
hhhh.iiii.current.jjjj;
|
|
2341
|
+
llll.mmmm.nnnn;
|
|
2342
|
+
llll.mmmm;
|
|
2343
|
+
llll;
|
|
2344
|
+
oooo.pppp.qqqq;
|
|
2345
|
+
oooo.pppp;
|
|
2346
|
+
oooo.qqqq;
|
|
2347
|
+
rrrr;
|
|
2348
|
+
rrrr.ssss;
|
|
2349
|
+
rrrr.ssss.tttt;
|
|
2350
|
+
uuuu["__??__"];
|
|
2351
|
+
}
|
|
2352
|
+
"#
|
|
2353
|
+
);
|
|
2354
|
+
|
|
2355
|
+
test!(
|
|
2356
|
+
module,
|
|
2357
|
+
Syntax::Typescript(TsSyntax {
|
|
2358
|
+
..Default::default()
|
|
2359
|
+
}),
|
|
2360
|
+
|_| (
|
|
2361
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2362
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2363
|
+
TransformMode::Test,
|
|
2364
|
+
WorkletVisitorConfig {
|
|
2365
|
+
filename: "index.ts".into(),
|
|
2366
|
+
target: TransformTarget::LEPUS,
|
|
2367
|
+
custom_global_ident_names: None,
|
|
2368
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2369
|
+
}
|
|
2370
|
+
)),
|
|
2371
|
+
hygiene()
|
|
2372
|
+
),
|
|
2373
|
+
should_extract_member_expr_lepus,
|
|
2374
|
+
r#"
|
|
2375
|
+
function onTapLepus() {
|
|
2376
|
+
"main thread";
|
|
2377
|
+
aaaa.bbbb[cccc.dddd].eeee;
|
|
2378
|
+
aaaa.bbbb[cccc.dddd].eeee;
|
|
2379
|
+
aaaa.bbbb[cccc.dddd].eeee;
|
|
2380
|
+
hhhh.iiii.current.jjjj;
|
|
2381
|
+
hhhh.iiii.current.jjjj;
|
|
2382
|
+
llll.mmmm.nnnn;
|
|
2383
|
+
llll.mmmm;
|
|
2384
|
+
llll;
|
|
2385
|
+
oooo.pppp.qqqq;
|
|
2386
|
+
oooo.pppp;
|
|
2387
|
+
oooo.qqqq;
|
|
2388
|
+
rrrr;
|
|
2389
|
+
rrrr.ssss;
|
|
2390
|
+
rrrr.ssss.tttt;
|
|
2391
|
+
uuuu["__??__"];
|
|
2392
|
+
}
|
|
2393
|
+
"#
|
|
2394
|
+
);
|
|
2395
|
+
|
|
2396
|
+
test!(
|
|
2397
|
+
module,
|
|
2398
|
+
Syntax::Typescript(TsSyntax {
|
|
2399
|
+
..Default::default()
|
|
2400
|
+
}),
|
|
2401
|
+
|_| (
|
|
2402
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2403
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2404
|
+
TransformMode::Test,
|
|
2405
|
+
WorkletVisitorConfig {
|
|
2406
|
+
filename: "index.ts".into(),
|
|
2407
|
+
target: TransformTarget::JS,
|
|
2408
|
+
custom_global_ident_names: None,
|
|
2409
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2410
|
+
}
|
|
2411
|
+
)),
|
|
2412
|
+
hygiene()
|
|
2413
|
+
),
|
|
2414
|
+
should_extract_member_expr_2_js,
|
|
2415
|
+
r#"
|
|
2416
|
+
function onTapLepus() {
|
|
2417
|
+
"main thread";
|
|
2418
|
+
this.aaaa;
|
|
2419
|
+
this.aaaa;
|
|
2420
|
+
this.bbbb.cccc.dddd;
|
|
2421
|
+
this.bbbb.cccc.dddd;
|
|
2422
|
+
this.eeee.ffff.gggg;
|
|
2423
|
+
this.eeee;
|
|
2424
|
+
this.ffff;
|
|
2425
|
+
this.eeee.ffff.gggg;
|
|
2426
|
+
this.hhhh.iiii.jjjj;
|
|
2427
|
+
this.hhhh['iiii'];
|
|
2428
|
+
this.hhhh.kkkk;
|
|
2429
|
+
this.hhhh.iiii.jjjj;
|
|
2430
|
+
this.llll[this.mmmm.nnnn['oooo']];
|
|
2431
|
+
aaaa;
|
|
2432
|
+
bbbb;
|
|
2433
|
+
eeee;
|
|
2434
|
+
ffff;
|
|
2435
|
+
}
|
|
2436
|
+
"#
|
|
2437
|
+
);
|
|
2438
|
+
|
|
2439
|
+
test!(
|
|
2440
|
+
module,
|
|
2441
|
+
Syntax::Typescript(TsSyntax {
|
|
2442
|
+
..Default::default()
|
|
2443
|
+
}),
|
|
2444
|
+
|_| (
|
|
2445
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2446
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2447
|
+
TransformMode::Test,
|
|
2448
|
+
WorkletVisitorConfig {
|
|
2449
|
+
filename: "index.ts".into(),
|
|
2450
|
+
target: TransformTarget::LEPUS,
|
|
2451
|
+
custom_global_ident_names: None,
|
|
2452
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2453
|
+
}
|
|
2454
|
+
)),
|
|
2455
|
+
hygiene()
|
|
2456
|
+
),
|
|
2457
|
+
should_extract_member_expr_2_lepus,
|
|
2458
|
+
r#"
|
|
2459
|
+
function onTapLepus() {
|
|
2460
|
+
"main thread";
|
|
2461
|
+
this.aaaa;
|
|
2462
|
+
this.aaaa;
|
|
2463
|
+
this.bbbb.cccc.dddd;
|
|
2464
|
+
this.bbbb.cccc.dddd;
|
|
2465
|
+
this.eeee.ffff.gggg;
|
|
2466
|
+
this.eeee;
|
|
2467
|
+
this.ffff;
|
|
2468
|
+
this.eeee.ffff.gggg;
|
|
2469
|
+
this.hhhh.iiii.jjjj;
|
|
2470
|
+
this.hhhh['iiii'];
|
|
2471
|
+
this.hhhh.kkkk;
|
|
2472
|
+
this.hhhh.iiii.jjjj;
|
|
2473
|
+
this.llll[this.mmmm.nnnn['oooo']];
|
|
2474
|
+
aaaa;
|
|
2475
|
+
bbbb;
|
|
2476
|
+
eeee;
|
|
2477
|
+
ffff;
|
|
2478
|
+
}
|
|
2479
|
+
"#
|
|
2480
|
+
);
|
|
2481
|
+
|
|
2482
|
+
test!(
|
|
2483
|
+
module,
|
|
2484
|
+
Syntax::Typescript(TsSyntax {
|
|
2485
|
+
..Default::default()
|
|
2486
|
+
}),
|
|
2487
|
+
|_| (
|
|
2488
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2489
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2490
|
+
TransformMode::Test,
|
|
2491
|
+
WorkletVisitorConfig {
|
|
2492
|
+
filename: "index.ts".into(),
|
|
2493
|
+
target: TransformTarget::JS,
|
|
2494
|
+
custom_global_ident_names: None,
|
|
2495
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2496
|
+
}
|
|
2497
|
+
)),
|
|
2498
|
+
hygiene()
|
|
2499
|
+
),
|
|
2500
|
+
should_extract_member_expr_3_js,
|
|
2501
|
+
r#"
|
|
2502
|
+
function enableScroll(enable: boolean) {
|
|
2503
|
+
'main thread';
|
|
2504
|
+
lynx
|
|
2505
|
+
.querySelector(`#${containerID}`)
|
|
2506
|
+
?.setAttribute('enable-scroll', enable);
|
|
2507
|
+
(a + b).c.d;
|
|
2508
|
+
({e: f}).e;
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
function makeVelocityIfRequired(nodeRef: MainThreadRef<Velocity>, velocity: boolean) {
|
|
2512
|
+
'main thread';
|
|
2513
|
+
|
|
2514
|
+
class Velocity implements Velocity {
|
|
2515
|
+
constructor(velocity: boolean) {
|
|
2516
|
+
this.enabled = velocity;
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
positionQueue = [];
|
|
2520
|
+
timeQueue = [];
|
|
2521
|
+
enabled = true;
|
|
2522
|
+
|
|
2523
|
+
reset = () => {
|
|
2524
|
+
this.positionQueue = [];
|
|
2525
|
+
this.timeQueue = [];
|
|
2526
|
+
};
|
|
2527
|
+
|
|
2528
|
+
getVelocity = () => {
|
|
2529
|
+
if (!this.enabled) {
|
|
2530
|
+
return {
|
|
2531
|
+
velocity: 0,
|
|
2532
|
+
direction: 0,
|
|
2533
|
+
};
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
this.pruneQueue(500);
|
|
2537
|
+
|
|
2538
|
+
const { length } = this.timeQueue;
|
|
2539
|
+
if (length < 2) {
|
|
2540
|
+
return {
|
|
2541
|
+
velocity: 0,
|
|
2542
|
+
direction: 1,
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
const distance = this.positionQueue[length - 1] - this.positionQueue[0];
|
|
2547
|
+
const time = (this.timeQueue[length - 1] - this.timeQueue[0]) / 1000;
|
|
2548
|
+
|
|
2549
|
+
return {
|
|
2550
|
+
velocity: distance / time,
|
|
2551
|
+
direction: distance > 0 ? 1 : -1,
|
|
2552
|
+
};
|
|
2553
|
+
};
|
|
2554
|
+
|
|
2555
|
+
updatePosition = (position: number) => {
|
|
2556
|
+
if (!this.enabled) {
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
this.positionQueue.push(position);
|
|
2560
|
+
this.timeQueue.push(Date.now());
|
|
2561
|
+
this.pruneQueue(50);
|
|
2562
|
+
console.log('updatePosition done', position);
|
|
2563
|
+
};
|
|
2564
|
+
|
|
2565
|
+
pruneQueue = (ms: number) => {
|
|
2566
|
+
if (!this.enabled) {
|
|
2567
|
+
return;
|
|
2568
|
+
}
|
|
2569
|
+
const nowTs = Date.now();
|
|
2570
|
+
// pull old values off of the queue
|
|
2571
|
+
while (this.timeQueue.length && this.timeQueue[0] < nowTs - ms) {
|
|
2572
|
+
this.timeQueue.shift();
|
|
2573
|
+
this.positionQueue.shift();
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
if (nodeRef && nodeRef.current) {
|
|
2579
|
+
nodeRef.current.reset();
|
|
2580
|
+
return nodeRef.current;
|
|
2581
|
+
} else {
|
|
2582
|
+
return new Velocity(velocity);
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
"#
|
|
2586
|
+
);
|
|
2587
|
+
|
|
2588
|
+
test!(
|
|
2589
|
+
module,
|
|
2590
|
+
Syntax::Typescript(TsSyntax {
|
|
2591
|
+
..Default::default()
|
|
2592
|
+
}),
|
|
2593
|
+
|_| (
|
|
2594
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2595
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2596
|
+
TransformMode::Test,
|
|
2597
|
+
WorkletVisitorConfig {
|
|
2598
|
+
filename: "index.ts".into(),
|
|
2599
|
+
target: TransformTarget::LEPUS,
|
|
2600
|
+
custom_global_ident_names: None,
|
|
2601
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2602
|
+
}
|
|
2603
|
+
)),
|
|
2604
|
+
hygiene()
|
|
2605
|
+
),
|
|
2606
|
+
should_extract_member_expr_3_lepus,
|
|
2607
|
+
r#"
|
|
2608
|
+
function enableScroll(enable: boolean) {
|
|
2609
|
+
'main thread';
|
|
2610
|
+
lynx
|
|
2611
|
+
.querySelector(`#${containerID}`)
|
|
2612
|
+
?.setAttribute('enable-scroll', enable);
|
|
2613
|
+
(a + b).c.d;
|
|
2614
|
+
({e: f}).e;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
function makeVelocityIfRequired(nodeRef: MainThreadRef<Velocity>, velocity: boolean) {
|
|
2618
|
+
'main thread';
|
|
2619
|
+
|
|
2620
|
+
class Velocity implements Velocity {
|
|
2621
|
+
constructor(velocity: boolean) {
|
|
2622
|
+
this.enabled = velocity;
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
positionQueue = [];
|
|
2626
|
+
timeQueue = [];
|
|
2627
|
+
enabled = true;
|
|
2628
|
+
|
|
2629
|
+
reset = () => {
|
|
2630
|
+
this.positionQueue = [];
|
|
2631
|
+
this.timeQueue = [];
|
|
2632
|
+
};
|
|
2633
|
+
|
|
2634
|
+
getVelocity = () => {
|
|
2635
|
+
if (!this.enabled) {
|
|
2636
|
+
return {
|
|
2637
|
+
velocity: 0,
|
|
2638
|
+
direction: 0,
|
|
2639
|
+
};
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
this.pruneQueue(500);
|
|
2643
|
+
|
|
2644
|
+
const { length } = this.timeQueue;
|
|
2645
|
+
if (length < 2) {
|
|
2646
|
+
return {
|
|
2647
|
+
velocity: 0,
|
|
2648
|
+
direction: 1,
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
const distance = this.positionQueue[length - 1] - this.positionQueue[0];
|
|
2653
|
+
const time = (this.timeQueue[length - 1] - this.timeQueue[0]) / 1000;
|
|
2654
|
+
|
|
2655
|
+
return {
|
|
2656
|
+
velocity: distance / time,
|
|
2657
|
+
direction: distance > 0 ? 1 : -1,
|
|
2658
|
+
};
|
|
2659
|
+
};
|
|
2660
|
+
|
|
2661
|
+
updatePosition = (position: number) => {
|
|
2662
|
+
if (!this.enabled) {
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
this.positionQueue.push(position);
|
|
2666
|
+
this.timeQueue.push(Date.now());
|
|
2667
|
+
this.pruneQueue(50);
|
|
2668
|
+
console.log('updatePosition done', position);
|
|
2669
|
+
};
|
|
2670
|
+
|
|
2671
|
+
pruneQueue = (ms: number) => {
|
|
2672
|
+
if (!this.enabled) {
|
|
2673
|
+
return;
|
|
2674
|
+
}
|
|
2675
|
+
const nowTs = Date.now();
|
|
2676
|
+
// pull old values off of the queue
|
|
2677
|
+
while (this.timeQueue.length && this.timeQueue[0] < nowTs - ms) {
|
|
2678
|
+
this.timeQueue.shift();
|
|
2679
|
+
this.positionQueue.shift();
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
if (nodeRef && nodeRef.current) {
|
|
2685
|
+
nodeRef.current.reset();
|
|
2686
|
+
return nodeRef.current;
|
|
2687
|
+
} else {
|
|
2688
|
+
return new Velocity(velocity);
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
"#
|
|
2692
|
+
);
|
|
2693
|
+
|
|
2694
|
+
test!(
|
|
2695
|
+
module,
|
|
2696
|
+
Syntax::Typescript(TsSyntax {
|
|
2697
|
+
..Default::default()
|
|
2698
|
+
}),
|
|
2699
|
+
|_| (
|
|
2700
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2701
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2702
|
+
TransformMode::Test,
|
|
2703
|
+
WorkletVisitorConfig {
|
|
2704
|
+
filename: "index.ts".into(),
|
|
2705
|
+
target: TransformTarget::JS,
|
|
2706
|
+
custom_global_ident_names: None,
|
|
2707
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2708
|
+
}
|
|
2709
|
+
)),
|
|
2710
|
+
hygiene()
|
|
2711
|
+
),
|
|
2712
|
+
should_extract_member_expr_4_js,
|
|
2713
|
+
r#"
|
|
2714
|
+
function enableScroll(enable: boolean) {
|
|
2715
|
+
'main thread';
|
|
2716
|
+
function x() {
|
|
2717
|
+
this.a;
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
"#
|
|
2722
|
+
);
|
|
2723
|
+
|
|
2724
|
+
test!(
|
|
2725
|
+
module,
|
|
2726
|
+
Syntax::Typescript(TsSyntax {
|
|
2727
|
+
..Default::default()
|
|
2728
|
+
}),
|
|
2729
|
+
|_| (
|
|
2730
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2731
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2732
|
+
TransformMode::Test,
|
|
2733
|
+
WorkletVisitorConfig {
|
|
2734
|
+
filename: "index.ts".into(),
|
|
2735
|
+
target: TransformTarget::LEPUS,
|
|
2736
|
+
custom_global_ident_names: None,
|
|
2737
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2738
|
+
}
|
|
2739
|
+
)),
|
|
2740
|
+
hygiene()
|
|
2741
|
+
),
|
|
2742
|
+
should_extract_member_expr_4_lepus,
|
|
2743
|
+
r#"
|
|
2744
|
+
function enableScroll(enable: boolean) {
|
|
2745
|
+
'main thread';
|
|
2746
|
+
function x() {
|
|
2747
|
+
this.a;
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
"#
|
|
2751
|
+
);
|
|
2752
|
+
|
|
2753
|
+
test!(
|
|
2754
|
+
module,
|
|
2755
|
+
Syntax::Typescript(TsSyntax {
|
|
2756
|
+
..Default::default()
|
|
2757
|
+
}),
|
|
2758
|
+
|_| (
|
|
2759
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2760
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2761
|
+
TransformMode::Test,
|
|
2762
|
+
WorkletVisitorConfig {
|
|
2763
|
+
filename: "index.ts".into(),
|
|
2764
|
+
target: TransformTarget::LEPUS,
|
|
2765
|
+
custom_global_ident_names: None,
|
|
2766
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2767
|
+
}
|
|
2768
|
+
)),
|
|
2769
|
+
hygiene()
|
|
2770
|
+
),
|
|
2771
|
+
should_transform_fn_decl_lepus,
|
|
2772
|
+
r#"
|
|
2773
|
+
export default function useExposure(exposureArgs) {
|
|
2774
|
+
'main thread';
|
|
2775
|
+
console.log('useExposure2');
|
|
2776
|
+
console.log(exposureArgs);
|
|
2777
|
+
x;
|
|
2778
|
+
}
|
|
2779
|
+
"#
|
|
2780
|
+
);
|
|
2781
|
+
|
|
2782
|
+
test!(
|
|
2783
|
+
module,
|
|
2784
|
+
Syntax::Typescript(TsSyntax {
|
|
2785
|
+
..Default::default()
|
|
2786
|
+
}),
|
|
2787
|
+
|_| (
|
|
2788
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2789
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2790
|
+
TransformMode::Test,
|
|
2791
|
+
WorkletVisitorConfig {
|
|
2792
|
+
filename: "index.ts".into(),
|
|
2793
|
+
target: TransformTarget::JS,
|
|
2794
|
+
custom_global_ident_names: None,
|
|
2795
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2796
|
+
}
|
|
2797
|
+
)),
|
|
2798
|
+
hygiene()
|
|
2799
|
+
),
|
|
2800
|
+
should_transform_fn_decl_js,
|
|
2801
|
+
r#"
|
|
2802
|
+
export default function useExposure(exposureArgs) {
|
|
2803
|
+
'main thread';
|
|
2804
|
+
console.log('useExposure2');
|
|
2805
|
+
console.log(exposureArgs);
|
|
2806
|
+
x;
|
|
2807
|
+
}
|
|
2808
|
+
"#
|
|
2809
|
+
);
|
|
2810
|
+
|
|
2811
|
+
test!(
|
|
2812
|
+
module,
|
|
2813
|
+
Syntax::Typescript(TsSyntax {
|
|
2814
|
+
..Default::default()
|
|
2815
|
+
}),
|
|
2816
|
+
|_| (
|
|
2817
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2818
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2819
|
+
TransformMode::Test,
|
|
2820
|
+
WorkletVisitorConfig {
|
|
2821
|
+
filename: "index.ts".into(),
|
|
2822
|
+
target: TransformTarget::LEPUS,
|
|
2823
|
+
custom_global_ident_names: None,
|
|
2824
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2825
|
+
}
|
|
2826
|
+
)),
|
|
2827
|
+
hygiene()
|
|
2828
|
+
),
|
|
2829
|
+
should_add_worklet_runtime_ident_with_outer_ident,
|
|
2830
|
+
r#"
|
|
2831
|
+
const __workletRuntimeLoaded = false;
|
|
2832
|
+
console.log(__workletRuntimeLoaded);
|
|
2833
|
+
|
|
2834
|
+
function foo() {
|
|
2835
|
+
"main thread";
|
|
2836
|
+
return 1;
|
|
2837
|
+
}
|
|
2838
|
+
"#
|
|
2839
|
+
);
|
|
2840
|
+
|
|
2841
|
+
test!(
|
|
2842
|
+
module,
|
|
2843
|
+
Syntax::Typescript(TsSyntax {
|
|
2844
|
+
..Default::default()
|
|
2845
|
+
}),
|
|
2846
|
+
|_| (
|
|
2847
|
+
resolver(Mark::new(), Mark::new(), true),
|
|
2848
|
+
visit_mut_pass(WorkletVisitor::new(
|
|
2849
|
+
TransformMode::Test,
|
|
2850
|
+
WorkletVisitorConfig {
|
|
2851
|
+
filename: "index.ts".into(),
|
|
2852
|
+
target: TransformTarget::LEPUS,
|
|
2853
|
+
custom_global_ident_names: None,
|
|
2854
|
+
runtime_pkg: "@lynx-js/react".into(),
|
|
2855
|
+
}
|
|
2856
|
+
)),
|
|
2857
|
+
hygiene()
|
|
2858
|
+
),
|
|
2859
|
+
should_add_worklet_runtime_ident_with_inner_ident,
|
|
2860
|
+
r#"
|
|
2861
|
+
function foo() {
|
|
2862
|
+
"main thread";
|
|
2863
|
+
const __workletRuntimeLoaded = false;
|
|
2864
|
+
console.log(__workletRuntimeLoaded);
|
|
2865
|
+
return 1;
|
|
2866
|
+
}
|
|
2867
|
+
"#
|
|
2868
|
+
);
|
|
2869
|
+
}
|