@builder.io/mitosis 0.0.0-dev-20260605060721
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/dist/src/constants/hooks.d.ts +16 -0
- package/dist/src/constants/hooks.js +19 -0
- package/dist/src/constants/html_tags.d.ts +2 -0
- package/dist/src/constants/html_tags.js +198 -0
- package/dist/src/constants/media-sizes.d.ts +22 -0
- package/dist/src/constants/media-sizes.js +34 -0
- package/dist/src/constants/method-literal-prefix.d.ts +1 -0
- package/dist/src/constants/method-literal-prefix.js +2 -0
- package/dist/src/flow.d.ts +26 -0
- package/dist/src/flow.js +27 -0
- package/dist/src/generators/alpine/generate.d.ts +11 -0
- package/dist/src/generators/alpine/generate.js +201 -0
- package/dist/src/generators/alpine/index.d.ts +2 -0
- package/dist/src/generators/alpine/index.js +18 -0
- package/dist/src/generators/alpine/render-mount-hook.d.ts +2 -0
- package/dist/src/generators/alpine/render-mount-hook.js +17 -0
- package/dist/src/generators/alpine/render-update-hooks.d.ts +5 -0
- package/dist/src/generators/alpine/render-update-hooks.js +44 -0
- package/dist/src/generators/alpine/types.d.ts +12 -0
- package/dist/src/generators/alpine/types.js +2 -0
- package/dist/src/generators/angular/classic/blocks.d.ts +10 -0
- package/dist/src/generators/angular/classic/blocks.js +409 -0
- package/dist/src/generators/angular/classic/component.d.ts +3 -0
- package/dist/src/generators/angular/classic/component.js +356 -0
- package/dist/src/generators/angular/classic/plugins/get-class-properties-plugin.d.ts +2 -0
- package/dist/src/generators/angular/classic/plugins/get-class-properties-plugin.js +138 -0
- package/dist/src/generators/angular/classic/plugins/get-code-processor-plugins.d.ts +8 -0
- package/dist/src/generators/angular/classic/plugins/get-code-processor-plugins.js +60 -0
- package/dist/src/generators/angular/component.d.ts +3 -0
- package/dist/src/generators/angular/component.js +27 -0
- package/dist/src/generators/angular/helpers/format.d.ts +1 -0
- package/dist/src/generators/angular/helpers/format.js +24 -0
- package/dist/src/generators/angular/helpers/get-inputs.d.ts +7 -0
- package/dist/src/generators/angular/helpers/get-inputs.js +18 -0
- package/dist/src/generators/angular/helpers/get-outputs.d.ts +7 -0
- package/dist/src/generators/angular/helpers/get-outputs.js +23 -0
- package/dist/src/generators/angular/helpers/get-refs.d.ts +8 -0
- package/dist/src/generators/angular/helpers/get-refs.js +40 -0
- package/dist/src/generators/angular/helpers/get-styles.d.ts +6 -0
- package/dist/src/generators/angular/helpers/get-styles.js +17 -0
- package/dist/src/generators/angular/helpers/hooks.d.ts +25 -0
- package/dist/src/generators/angular/helpers/hooks.js +59 -0
- package/dist/src/generators/angular/helpers/index.d.ts +33 -0
- package/dist/src/generators/angular/helpers/index.js +221 -0
- package/dist/src/generators/angular/helpers/parse-selector.d.ts +5 -0
- package/dist/src/generators/angular/helpers/parse-selector.js +19 -0
- package/dist/src/generators/angular/index.d.ts +2 -0
- package/dist/src/generators/angular/index.js +18 -0
- package/dist/src/generators/angular/signals/blocks.d.ts +10 -0
- package/dist/src/generators/angular/signals/blocks.js +379 -0
- package/dist/src/generators/angular/signals/component.d.ts +3 -0
- package/dist/src/generators/angular/signals/component.js +377 -0
- package/dist/src/generators/angular/signals/helpers/get-computed.d.ts +6 -0
- package/dist/src/generators/angular/signals/helpers/get-computed.js +79 -0
- package/dist/src/generators/angular/signals/helpers/get-dynamic-template-refs.d.ts +2 -0
- package/dist/src/generators/angular/signals/helpers/get-dynamic-template-refs.js +25 -0
- package/dist/src/generators/angular/signals/helpers/get-inputs.d.ts +7 -0
- package/dist/src/generators/angular/signals/helpers/get-inputs.js +15 -0
- package/dist/src/generators/angular/signals/helpers/index.d.ts +16 -0
- package/dist/src/generators/angular/signals/helpers/index.js +30 -0
- package/dist/src/generators/angular/signals/plugins/get-code-processor-plugins.d.ts +4 -0
- package/dist/src/generators/angular/signals/plugins/get-code-processor-plugins.js +547 -0
- package/dist/src/generators/angular/types.d.ts +72 -0
- package/dist/src/generators/angular/types.js +12 -0
- package/dist/src/generators/builder/generator.d.ts +12 -0
- package/dist/src/generators/builder/generator.js +876 -0
- package/dist/src/generators/builder/index.d.ts +2 -0
- package/dist/src/generators/builder/index.js +18 -0
- package/dist/src/generators/builder/types.d.ts +6 -0
- package/dist/src/generators/builder/types.js +2 -0
- package/dist/src/generators/context/angular.d.ts +9 -0
- package/dist/src/generators/context/angular.js +40 -0
- package/dist/src/generators/context/helpers/context-with-symbol-key.d.ts +5 -0
- package/dist/src/generators/context/helpers/context-with-symbol-key.js +33 -0
- package/dist/src/generators/context/qwik.d.ts +8 -0
- package/dist/src/generators/context/qwik.js +29 -0
- package/dist/src/generators/context/react.d.ts +10 -0
- package/dist/src/generators/context/react.js +30 -0
- package/dist/src/generators/context/rsc.d.ts +12 -0
- package/dist/src/generators/context/rsc.js +32 -0
- package/dist/src/generators/context/solid.d.ts +8 -0
- package/dist/src/generators/context/solid.js +30 -0
- package/dist/src/generators/context/svelte.d.ts +11 -0
- package/dist/src/generators/context/svelte.js +44 -0
- package/dist/src/generators/context/vue.d.ts +3 -0
- package/dist/src/generators/context/vue.js +5 -0
- package/dist/src/generators/helpers/context.d.ts +8 -0
- package/dist/src/generators/helpers/context.js +15 -0
- package/dist/src/generators/helpers/functions.d.ts +2 -0
- package/dist/src/generators/helpers/functions.js +31 -0
- package/dist/src/generators/helpers/minify.d.ts +1 -0
- package/dist/src/generators/helpers/minify.js +20 -0
- package/dist/src/generators/helpers/on-mount.d.ts +5 -0
- package/dist/src/generators/helpers/on-mount.js +25 -0
- package/dist/src/generators/helpers/rsc.d.ts +2 -0
- package/dist/src/generators/helpers/rsc.js +38 -0
- package/dist/src/generators/html/generator.d.ts +4 -0
- package/dist/src/generators/html/generator.js +1232 -0
- package/dist/src/generators/html/index.d.ts +2 -0
- package/dist/src/generators/html/index.js +18 -0
- package/dist/src/generators/html/types.d.ts +6 -0
- package/dist/src/generators/html/types.js +2 -0
- package/dist/src/generators/liquid/generator.d.ts +9 -0
- package/dist/src/generators/liquid/generator.js +161 -0
- package/dist/src/generators/liquid/index.d.ts +2 -0
- package/dist/src/generators/liquid/index.js +18 -0
- package/dist/src/generators/liquid/types.d.ts +5 -0
- package/dist/src/generators/liquid/types.js +2 -0
- package/dist/src/generators/lit/collect-class-string.d.ts +2 -0
- package/dist/src/generators/lit/collect-class-string.js +41 -0
- package/dist/src/generators/lit/generate.d.ts +3 -0
- package/dist/src/generators/lit/generate.js +271 -0
- package/dist/src/generators/lit/index.d.ts +2 -0
- package/dist/src/generators/lit/index.js +18 -0
- package/dist/src/generators/lit/types.d.ts +8 -0
- package/dist/src/generators/lit/types.js +2 -0
- package/dist/src/generators/marko/generate.d.ts +20 -0
- package/dist/src/generators/marko/generate.js +316 -0
- package/dist/src/generators/marko/index.d.ts +2 -0
- package/dist/src/generators/marko/index.js +18 -0
- package/dist/src/generators/marko/types.d.ts +4 -0
- package/dist/src/generators/marko/types.js +2 -0
- package/dist/src/generators/mitosis/generator.d.ts +7 -0
- package/dist/src/generators/mitosis/generator.js +367 -0
- package/dist/src/generators/mitosis/index.d.ts +2 -0
- package/dist/src/generators/mitosis/index.js +18 -0
- package/dist/src/generators/mitosis/types.d.ts +8 -0
- package/dist/src/generators/mitosis/types.js +2 -0
- package/dist/src/generators/qwik/component-generator.d.ts +3 -0
- package/dist/src/generators/qwik/component-generator.js +337 -0
- package/dist/src/generators/qwik/component.d.ts +21 -0
- package/dist/src/generators/qwik/component.js +170 -0
- package/dist/src/generators/qwik/directives.d.ts +24 -0
- package/dist/src/generators/qwik/directives.js +152 -0
- package/dist/src/generators/qwik/helpers/add-prevent-default.d.ts +7 -0
- package/dist/src/generators/qwik/helpers/add-prevent-default.js +33 -0
- package/dist/src/generators/qwik/helpers/convert-method-to-function.d.ts +2 -0
- package/dist/src/generators/qwik/helpers/convert-method-to-function.js +161 -0
- package/dist/src/generators/qwik/helpers/handlers.d.ts +3 -0
- package/dist/src/generators/qwik/helpers/handlers.js +60 -0
- package/dist/src/generators/qwik/helpers/stable-inject.d.ts +5 -0
- package/dist/src/generators/qwik/helpers/stable-inject.js +49 -0
- package/dist/src/generators/qwik/helpers/stable-serialize.d.ts +6 -0
- package/dist/src/generators/qwik/helpers/stable-serialize.js +50 -0
- package/dist/src/generators/qwik/helpers/state.d.ts +32 -0
- package/dist/src/generators/qwik/helpers/state.js +111 -0
- package/dist/src/generators/qwik/helpers/styles.d.ts +7 -0
- package/dist/src/generators/qwik/helpers/styles.js +70 -0
- package/dist/src/generators/qwik/index.d.ts +5 -0
- package/dist/src/generators/qwik/index.js +26 -0
- package/dist/src/generators/qwik/jsx.d.ts +17 -0
- package/dist/src/generators/qwik/jsx.js +223 -0
- package/dist/src/generators/qwik/src-generator.d.ts +83 -0
- package/dist/src/generators/qwik/src-generator.js +575 -0
- package/dist/src/generators/qwik/types.d.ts +14 -0
- package/dist/src/generators/qwik/types.js +2 -0
- package/dist/src/generators/react/blocks.d.ts +4 -0
- package/dist/src/generators/react/blocks.js +332 -0
- package/dist/src/generators/react/generator.d.ts +5 -0
- package/dist/src/generators/react/generator.js +399 -0
- package/dist/src/generators/react/helpers/default-props.d.ts +2 -0
- package/dist/src/generators/react/helpers/default-props.js +21 -0
- package/dist/src/generators/react/helpers/hooks.d.ts +20 -0
- package/dist/src/generators/react/helpers/hooks.js +67 -0
- package/dist/src/generators/react/helpers/index.d.ts +11 -0
- package/dist/src/generators/react/helpers/index.js +97 -0
- package/dist/src/generators/react/helpers/state.d.ts +17 -0
- package/dist/src/generators/react/helpers/state.js +198 -0
- package/dist/src/generators/react/index.d.ts +3 -0
- package/dist/src/generators/react/index.js +21 -0
- package/dist/src/generators/react/types.d.ts +22 -0
- package/dist/src/generators/react/types.js +2 -0
- package/dist/src/generators/react-native/extract-css-var-default-value.d.ts +1 -0
- package/dist/src/generators/react-native/extract-css-var-default-value.js +15 -0
- package/dist/src/generators/react-native/helpers.d.ts +3 -0
- package/dist/src/generators/react-native/helpers.js +133 -0
- package/dist/src/generators/react-native/index.d.ts +8 -0
- package/dist/src/generators/react-native/index.js +286 -0
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.d.ts +4 -0
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +57 -0
- package/dist/src/generators/react-native/types.d.ts +9 -0
- package/dist/src/generators/react-native/types.js +2 -0
- package/dist/src/generators/rsc/generator.d.ts +3 -0
- package/dist/src/generators/rsc/generator.js +77 -0
- package/dist/src/generators/rsc/index.d.ts +2 -0
- package/dist/src/generators/rsc/index.js +18 -0
- package/dist/src/generators/rsc/types.d.ts +5 -0
- package/dist/src/generators/rsc/types.js +2 -0
- package/dist/src/generators/solid/blocks.d.ts +4 -0
- package/dist/src/generators/solid/blocks.js +138 -0
- package/dist/src/generators/solid/helpers/styles.d.ts +3 -0
- package/dist/src/generators/solid/helpers/styles.js +47 -0
- package/dist/src/generators/solid/index.d.ts +4 -0
- package/dist/src/generators/solid/index.js +264 -0
- package/dist/src/generators/solid/state/helpers.d.ts +13 -0
- package/dist/src/generators/solid/state/helpers.js +88 -0
- package/dist/src/generators/solid/state/index.d.ts +1 -0
- package/dist/src/generators/solid/state/index.js +5 -0
- package/dist/src/generators/solid/state/signals.d.ts +7 -0
- package/dist/src/generators/solid/state/signals.js +53 -0
- package/dist/src/generators/solid/state/state.d.ts +14 -0
- package/dist/src/generators/solid/state/state.js +55 -0
- package/dist/src/generators/solid/state/store.d.ts +7 -0
- package/dist/src/generators/solid/state/store.js +76 -0
- package/dist/src/generators/solid/types.d.ts +10 -0
- package/dist/src/generators/solid/types.js +2 -0
- package/dist/src/generators/stencil/blocks.d.ts +9 -0
- package/dist/src/generators/stencil/blocks.js +122 -0
- package/dist/src/generators/stencil/component.d.ts +3 -0
- package/dist/src/generators/stencil/component.js +199 -0
- package/dist/src/generators/stencil/helpers/collect-class-string.d.ts +2 -0
- package/dist/src/generators/stencil/helpers/collect-class-string.js +43 -0
- package/dist/src/generators/stencil/helpers/index.d.ts +37 -0
- package/dist/src/generators/stencil/helpers/index.js +129 -0
- package/dist/src/generators/stencil/index.d.ts +2 -0
- package/dist/src/generators/stencil/index.js +18 -0
- package/dist/src/generators/stencil/plugins/get-code-processor-plugins.d.ts +4 -0
- package/dist/src/generators/stencil/plugins/get-code-processor-plugins.js +25 -0
- package/dist/src/generators/stencil/types.d.ts +37 -0
- package/dist/src/generators/stencil/types.js +2 -0
- package/dist/src/generators/svelte/blocks.d.ts +10 -0
- package/dist/src/generators/svelte/blocks.js +280 -0
- package/dist/src/generators/svelte/helpers.d.ts +6 -0
- package/dist/src/generators/svelte/helpers.js +14 -0
- package/dist/src/generators/svelte/index.d.ts +2 -0
- package/dist/src/generators/svelte/index.js +20 -0
- package/dist/src/generators/svelte/svelte.d.ts +3 -0
- package/dist/src/generators/svelte/svelte.js +412 -0
- package/dist/src/generators/svelte/types.d.ts +5 -0
- package/dist/src/generators/svelte/types.js +2 -0
- package/dist/src/generators/swift/blocks.d.ts +8 -0
- package/dist/src/generators/swift/blocks.js +304 -0
- package/dist/src/generators/swift/generator.d.ts +3 -0
- package/dist/src/generators/swift/generator.js +287 -0
- package/dist/src/generators/swift/helpers.d.ts +42 -0
- package/dist/src/generators/swift/helpers.js +412 -0
- package/dist/src/generators/swift/index.d.ts +2 -0
- package/dist/src/generators/swift/index.js +18 -0
- package/dist/src/generators/swift/types.d.ts +29 -0
- package/dist/src/generators/swift/types.js +2 -0
- package/dist/src/generators/taro/generator.d.ts +8 -0
- package/dist/src/generators/taro/generator.js +168 -0
- package/dist/src/generators/taro/index.d.ts +2 -0
- package/dist/src/generators/taro/index.js +18 -0
- package/dist/src/generators/taro/types.d.ts +3 -0
- package/dist/src/generators/taro/types.js +2 -0
- package/dist/src/generators/template/generator.d.ts +3 -0
- package/dist/src/generators/template/generator.js +131 -0
- package/dist/src/generators/template/index.d.ts +2 -0
- package/dist/src/generators/template/index.js +18 -0
- package/dist/src/generators/template/types.d.ts +4 -0
- package/dist/src/generators/template/types.js +2 -0
- package/dist/src/generators/vue/blocks.d.ts +8 -0
- package/dist/src/generators/vue/blocks.js +217 -0
- package/dist/src/generators/vue/compositionApi.d.ts +3 -0
- package/dist/src/generators/vue/compositionApi.js +128 -0
- package/dist/src/generators/vue/helpers.d.ts +25 -0
- package/dist/src/generators/vue/helpers.js +179 -0
- package/dist/src/generators/vue/index.d.ts +2 -0
- package/dist/src/generators/vue/index.js +18 -0
- package/dist/src/generators/vue/optionsApi.d.ts +3 -0
- package/dist/src/generators/vue/optionsApi.js +210 -0
- package/dist/src/generators/vue/types.d.ts +33 -0
- package/dist/src/generators/vue/types.js +2 -0
- package/dist/src/generators/vue/vue.d.ts +3 -0
- package/dist/src/generators/vue/vue.js +272 -0
- package/dist/src/helpers/apply-meta-tagname.d.ts +2 -0
- package/dist/src/helpers/apply-meta-tagname.js +20 -0
- package/dist/src/helpers/babel-transform.d.ts +7 -0
- package/dist/src/helpers/babel-transform.js +130 -0
- package/dist/src/helpers/bindings.d.ts +6 -0
- package/dist/src/helpers/bindings.js +9 -0
- package/dist/src/helpers/camel-case.d.ts +8 -0
- package/dist/src/helpers/camel-case.js +17 -0
- package/dist/src/helpers/capitalize.d.ts +1 -0
- package/dist/src/helpers/capitalize.js +10 -0
- package/dist/src/helpers/class-components.d.ts +13 -0
- package/dist/src/helpers/class-components.js +51 -0
- package/dist/src/helpers/component-file-extensions.d.ts +50 -0
- package/dist/src/helpers/component-file-extensions.js +141 -0
- package/dist/src/helpers/create-mitosis-component.d.ts +7 -0
- package/dist/src/helpers/create-mitosis-component.js +27 -0
- package/dist/src/helpers/create-mitosis-context.d.ts +4 -0
- package/dist/src/helpers/create-mitosis-context.js +11 -0
- package/dist/src/helpers/create-mitosis-node.d.ts +2 -0
- package/dist/src/helpers/create-mitosis-node.js +14 -0
- package/dist/src/helpers/dash-case.d.ts +1 -0
- package/dist/src/helpers/dash-case.js +6 -0
- package/dist/src/helpers/dedent.d.ts +1 -0
- package/dist/src/helpers/dedent.js +83 -0
- package/dist/src/helpers/event-handlers.d.ts +3 -0
- package/dist/src/helpers/event-handlers.js +115 -0
- package/dist/src/helpers/fast-clone.d.ts +1 -0
- package/dist/src/helpers/fast-clone.js +5 -0
- package/dist/src/helpers/filter-empty-text-nodes.d.ts +3 -0
- package/dist/src/helpers/filter-empty-text-nodes.js +9 -0
- package/dist/src/helpers/generic-format.d.ts +6 -0
- package/dist/src/helpers/generic-format.js +35 -0
- package/dist/src/helpers/get-bindings.d.ts +2 -0
- package/dist/src/helpers/get-bindings.js +16 -0
- package/dist/src/helpers/get-child-components.d.ts +2 -0
- package/dist/src/helpers/get-child-components.js +26 -0
- package/dist/src/helpers/get-components-used.d.ts +2 -0
- package/dist/src/helpers/get-components-used.js +18 -0
- package/dist/src/helpers/get-components.d.ts +2 -0
- package/dist/src/helpers/get-components.js +21 -0
- package/dist/src/helpers/get-custom-imports.d.ts +15 -0
- package/dist/src/helpers/get-custom-imports.js +38 -0
- package/dist/src/helpers/get-function-string.d.ts +1 -0
- package/dist/src/helpers/get-function-string.js +5 -0
- package/dist/src/helpers/get-prop-functions.d.ts +5 -0
- package/dist/src/helpers/get-prop-functions.js +28 -0
- package/dist/src/helpers/get-props-ref.d.ts +2 -0
- package/dist/src/helpers/get-props-ref.js +32 -0
- package/dist/src/helpers/get-props.d.ts +5 -0
- package/dist/src/helpers/get-props.js +41 -0
- package/dist/src/helpers/get-refs.d.ts +2 -0
- package/dist/src/helpers/get-refs.js +21 -0
- package/dist/src/helpers/get-state-object-string.d.ts +20 -0
- package/dist/src/helpers/get-state-object-string.js +86 -0
- package/dist/src/helpers/get-state-used.d.ts +5 -0
- package/dist/src/helpers/get-state-used.js +28 -0
- package/dist/src/helpers/get-styles.d.ts +4 -0
- package/dist/src/helpers/get-styles.js +34 -0
- package/dist/src/helpers/get-tag-name.d.ts +2 -0
- package/dist/src/helpers/get-tag-name.js +7 -0
- package/dist/src/helpers/get-typed-function.d.ts +4 -0
- package/dist/src/helpers/get-typed-function.js +20 -0
- package/dist/src/helpers/getters-to-functions.d.ts +5 -0
- package/dist/src/helpers/getters-to-functions.js +36 -0
- package/dist/src/helpers/handle-missing-state.d.ts +2 -0
- package/dist/src/helpers/handle-missing-state.js +13 -0
- package/dist/src/helpers/has-bindings-text.d.ts +2 -0
- package/dist/src/helpers/has-bindings-text.js +21 -0
- package/dist/src/helpers/has-component.d.ts +2 -0
- package/dist/src/helpers/has-component.js +21 -0
- package/dist/src/helpers/has-props.d.ts +2 -0
- package/dist/src/helpers/has-props.js +19 -0
- package/dist/src/helpers/has-stateful-dom.d.ts +2 -0
- package/dist/src/helpers/has-stateful-dom.js +21 -0
- package/dist/src/helpers/has.d.ts +9 -0
- package/dist/src/helpers/has.js +27 -0
- package/dist/src/helpers/html-escape.d.ts +1 -0
- package/dist/src/helpers/html-escape.js +7 -0
- package/dist/src/helpers/indent.d.ts +1 -0
- package/dist/src/helpers/indent.js +7 -0
- package/dist/src/helpers/is-children.d.ts +6 -0
- package/dist/src/helpers/is-children.js +14 -0
- package/dist/src/helpers/is-component.d.ts +5 -0
- package/dist/src/helpers/is-component.js +8 -0
- package/dist/src/helpers/is-hook-empty.d.ts +2 -0
- package/dist/src/helpers/is-hook-empty.js +14 -0
- package/dist/src/helpers/is-html-attribute.d.ts +4 -0
- package/dist/src/helpers/is-html-attribute.js +371 -0
- package/dist/src/helpers/is-mitosis-node.d.ts +2 -0
- package/dist/src/helpers/is-mitosis-node.js +7 -0
- package/dist/src/helpers/is-root-text-node.d.ts +4 -0
- package/dist/src/helpers/is-root-text-node.js +12 -0
- package/dist/src/helpers/is-upper-case.d.ts +1 -0
- package/dist/src/helpers/is-upper-case.js +5 -0
- package/dist/src/helpers/is-valid-attribute-name.d.ts +1 -0
- package/dist/src/helpers/is-valid-attribute-name.js +7 -0
- package/dist/src/helpers/json.d.ts +3 -0
- package/dist/src/helpers/json.js +17 -0
- package/dist/src/helpers/map-refs.d.ts +9 -0
- package/dist/src/helpers/map-refs.js +91 -0
- package/dist/src/helpers/merge-options.d.ts +19 -0
- package/dist/src/helpers/merge-options.js +35 -0
- package/dist/src/helpers/mitosis-imports.d.ts +5 -0
- package/dist/src/helpers/mitosis-imports.js +48 -0
- package/dist/src/helpers/nodes/for.d.ts +4 -0
- package/dist/src/helpers/nodes/for.js +12 -0
- package/dist/src/helpers/nullable.d.ts +2 -0
- package/dist/src/helpers/nullable.js +5 -0
- package/dist/src/helpers/on-event.d.ts +14 -0
- package/dist/src/helpers/on-event.js +52 -0
- package/dist/src/helpers/output.d.ts +5 -0
- package/dist/src/helpers/output.js +10 -0
- package/dist/src/helpers/parse-node.d.ts +2 -0
- package/dist/src/helpers/parse-node.js +20 -0
- package/dist/src/helpers/parsers.d.ts +9 -0
- package/dist/src/helpers/parsers.js +66 -0
- package/dist/src/helpers/patterns.d.ts +8 -0
- package/dist/src/helpers/patterns.js +17 -0
- package/dist/src/helpers/plugins/process-code/index.d.ts +12 -0
- package/dist/src/helpers/plugins/process-code/index.js +169 -0
- package/dist/src/helpers/plugins/process-code/types.d.ts +7 -0
- package/dist/src/helpers/plugins/process-code/types.js +2 -0
- package/dist/src/helpers/plugins/process-signals.d.ts +22 -0
- package/dist/src/helpers/plugins/process-signals.js +179 -0
- package/dist/src/helpers/plugins/process-target-blocks.d.ts +6 -0
- package/dist/src/helpers/plugins/process-target-blocks.js +59 -0
- package/dist/src/helpers/process-http-requests.d.ts +2 -0
- package/dist/src/helpers/process-http-requests.js +25 -0
- package/dist/src/helpers/remove-surrounding-block.d.ts +6 -0
- package/dist/src/helpers/remove-surrounding-block.js +25 -0
- package/dist/src/helpers/render-imports.d.ts +42 -0
- package/dist/src/helpers/render-imports.js +169 -0
- package/dist/src/helpers/replace-identifiers.d.ts +27 -0
- package/dist/src/helpers/replace-identifiers.js +187 -0
- package/dist/src/helpers/replace-new-lines-in-strings.d.ts +1 -0
- package/dist/src/helpers/replace-new-lines-in-strings.js +26 -0
- package/dist/src/helpers/set.d.ts +7 -0
- package/dist/src/helpers/set.js +24 -0
- package/dist/src/helpers/signals/index.d.ts +1 -0
- package/dist/src/helpers/signals/index.js +17 -0
- package/dist/src/helpers/signals/signals.d.ts +22 -0
- package/dist/src/helpers/signals/signals.js +109 -0
- package/dist/src/helpers/slots.d.ts +5 -0
- package/dist/src/helpers/slots.js +26 -0
- package/dist/src/helpers/state.d.ts +2 -0
- package/dist/src/helpers/state.js +5 -0
- package/dist/src/helpers/strip-meta-properties.d.ts +2 -0
- package/dist/src/helpers/strip-meta-properties.js +26 -0
- package/dist/src/helpers/strip-state-and-props-refs.d.ts +38 -0
- package/dist/src/helpers/strip-state-and-props-refs.js +86 -0
- package/dist/src/helpers/styles/collect-css.d.ts +7 -0
- package/dist/src/helpers/styles/collect-css.js +113 -0
- package/dist/src/helpers/styles/collect-styled-components.d.ts +2 -0
- package/dist/src/helpers/styles/collect-styled-components.js +64 -0
- package/dist/src/helpers/styles/helpers.d.ts +31 -0
- package/dist/src/helpers/styles/helpers.js +90 -0
- package/dist/src/helpers/trace-reference-to-module-path.d.ts +2 -0
- package/dist/src/helpers/trace-reference-to-module-path.js +13 -0
- package/dist/src/helpers/transform-state-setters.d.ts +14 -0
- package/dist/src/helpers/transform-state-setters.js +24 -0
- package/dist/src/helpers/transform-to-jsx.d.ts +4 -0
- package/dist/src/helpers/transform-to-jsx.js +13 -0
- package/dist/src/helpers/traverse-nodes.d.ts +4 -0
- package/dist/src/helpers/traverse-nodes.js +16 -0
- package/dist/src/helpers/try-prettier-format.d.ts +1 -0
- package/dist/src/helpers/try-prettier-format.js +24 -0
- package/dist/src/helpers/typescript-project.d.ts +7 -0
- package/dist/src/helpers/typescript-project.js +63 -0
- package/dist/src/helpers/typescript.d.ts +9 -0
- package/dist/src/helpers/typescript.js +5 -0
- package/dist/src/helpers/web-components/attribute-passing.d.ts +6 -0
- package/dist/src/helpers/web-components/attribute-passing.js +47 -0
- package/dist/src/index.d.ts +96 -0
- package/dist/src/index.js +74 -0
- package/dist/src/modules/plugins.d.ts +25 -0
- package/dist/src/modules/plugins.js +51 -0
- package/dist/src/parsers/angular.d.ts +5 -0
- package/dist/src/parsers/angular.js +154 -0
- package/dist/src/parsers/builder/builder.d.ts +55 -0
- package/dist/src/parsers/builder/builder.js +1198 -0
- package/dist/src/parsers/builder/helpers.d.ts +3 -0
- package/dist/src/parsers/builder/helpers.js +26 -0
- package/dist/src/parsers/builder/index.d.ts +1 -0
- package/dist/src/parsers/builder/index.js +17 -0
- package/dist/src/parsers/context.d.ts +6 -0
- package/dist/src/parsers/context.js +82 -0
- package/dist/src/parsers/jsx/ast.d.ts +5 -0
- package/dist/src/parsers/jsx/ast.js +74 -0
- package/dist/src/parsers/jsx/component-types.d.ts +8 -0
- package/dist/src/parsers/jsx/component-types.js +82 -0
- package/dist/src/parsers/jsx/context.d.ts +6 -0
- package/dist/src/parsers/jsx/context.js +68 -0
- package/dist/src/parsers/jsx/element-parser.d.ts +9 -0
- package/dist/src/parsers/jsx/element-parser.js +418 -0
- package/dist/src/parsers/jsx/exports.d.ts +5 -0
- package/dist/src/parsers/jsx/exports.js +76 -0
- package/dist/src/parsers/jsx/function-parser.d.ts +9 -0
- package/dist/src/parsers/jsx/function-parser.js +360 -0
- package/dist/src/parsers/jsx/helpers.d.ts +17 -0
- package/dist/src/parsers/jsx/helpers.js +85 -0
- package/dist/src/parsers/jsx/hooks/helpers.d.ts +5 -0
- package/dist/src/parsers/jsx/hooks/helpers.js +54 -0
- package/dist/src/parsers/jsx/hooks/index.d.ts +16 -0
- package/dist/src/parsers/jsx/hooks/index.js +96 -0
- package/dist/src/parsers/jsx/hooks/use-metadata.d.ts +9 -0
- package/dist/src/parsers/jsx/hooks/use-metadata.js +184 -0
- package/dist/src/parsers/jsx/hooks/use-target.d.ts +13 -0
- package/dist/src/parsers/jsx/hooks/use-target.js +135 -0
- package/dist/src/parsers/jsx/imports.d.ts +7 -0
- package/dist/src/parsers/jsx/imports.js +23 -0
- package/dist/src/parsers/jsx/index.d.ts +2 -0
- package/dist/src/parsers/jsx/index.js +5 -0
- package/dist/src/parsers/jsx/jsx.d.ts +10 -0
- package/dist/src/parsers/jsx/jsx.js +227 -0
- package/dist/src/parsers/jsx/props-types.d.ts +5 -0
- package/dist/src/parsers/jsx/props-types.js +22 -0
- package/dist/src/parsers/jsx/props.d.ts +2 -0
- package/dist/src/parsers/jsx/props.js +64 -0
- package/dist/src/parsers/jsx/signals.d.ts +9 -0
- package/dist/src/parsers/jsx/signals.js +99 -0
- package/dist/src/parsers/jsx/state.d.ts +17 -0
- package/dist/src/parsers/jsx/state.js +274 -0
- package/dist/src/parsers/jsx/types.d.ts +29 -0
- package/dist/src/parsers/jsx/types.js +2 -0
- package/dist/src/parsers/svelte/css/index.d.ts +3 -0
- package/dist/src/parsers/svelte/css/index.js +8 -0
- package/dist/src/parsers/svelte/helpers/bindings.d.ts +3 -0
- package/dist/src/parsers/svelte/helpers/bindings.js +75 -0
- package/dist/src/parsers/svelte/helpers/children.d.ts +5 -0
- package/dist/src/parsers/svelte/helpers/children.js +22 -0
- package/dist/src/parsers/svelte/helpers/expressions.d.ts +3 -0
- package/dist/src/parsers/svelte/helpers/expressions.js +20 -0
- package/dist/src/parsers/svelte/helpers/hooks.d.ts +2 -0
- package/dist/src/parsers/svelte/helpers/hooks.js +15 -0
- package/dist/src/parsers/svelte/helpers/mitosis-node.d.ts +2 -0
- package/dist/src/parsers/svelte/helpers/mitosis-node.js +16 -0
- package/dist/src/parsers/svelte/helpers/post-process.d.ts +15 -0
- package/dist/src/parsers/svelte/helpers/post-process.js +174 -0
- package/dist/src/parsers/svelte/helpers/string.d.ts +3 -0
- package/dist/src/parsers/svelte/helpers/string.js +26 -0
- package/dist/src/parsers/svelte/html/actions.d.ts +3 -0
- package/dist/src/parsers/svelte/html/actions.js +46 -0
- package/dist/src/parsers/svelte/html/each.d.ts +4 -0
- package/dist/src/parsers/svelte/html/each.js +20 -0
- package/dist/src/parsers/svelte/html/element.d.ts +3 -0
- package/dist/src/parsers/svelte/html/element.js +224 -0
- package/dist/src/parsers/svelte/html/fragment.d.ts +3 -0
- package/dist/src/parsers/svelte/html/fragment.js +16 -0
- package/dist/src/parsers/svelte/html/if-else.d.ts +3 -0
- package/dist/src/parsers/svelte/html/if-else.js +31 -0
- package/dist/src/parsers/svelte/html/index.d.ts +5 -0
- package/dist/src/parsers/svelte/html/index.js +80 -0
- package/dist/src/parsers/svelte/html/mustache-tag.d.ts +3 -0
- package/dist/src/parsers/svelte/html/mustache-tag.js +24 -0
- package/dist/src/parsers/svelte/html/slot.d.ts +3 -0
- package/dist/src/parsers/svelte/html/slot.js +20 -0
- package/dist/src/parsers/svelte/html/text.d.ts +66 -0
- package/dist/src/parsers/svelte/html/text.js +14 -0
- package/dist/src/parsers/svelte/index.d.ts +2 -0
- package/dist/src/parsers/svelte/index.js +59 -0
- package/dist/src/parsers/svelte/instance/context.d.ts +5 -0
- package/dist/src/parsers/svelte/instance/context.js +59 -0
- package/dist/src/parsers/svelte/instance/expressions.d.ts +3 -0
- package/dist/src/parsers/svelte/instance/expressions.js +11 -0
- package/dist/src/parsers/svelte/instance/functions.d.ts +3 -0
- package/dist/src/parsers/svelte/instance/functions.js +66 -0
- package/dist/src/parsers/svelte/instance/hooks.d.ts +5 -0
- package/dist/src/parsers/svelte/instance/hooks.js +32 -0
- package/dist/src/parsers/svelte/instance/imports.d.ts +3 -0
- package/dist/src/parsers/svelte/instance/imports.js +32 -0
- package/dist/src/parsers/svelte/instance/index.d.ts +3 -0
- package/dist/src/parsers/svelte/instance/index.js +123 -0
- package/dist/src/parsers/svelte/instance/properties.d.ts +3 -0
- package/dist/src/parsers/svelte/instance/properties.js +22 -0
- package/dist/src/parsers/svelte/instance/reactive.d.ts +3 -0
- package/dist/src/parsers/svelte/instance/reactive.js +33 -0
- package/dist/src/parsers/svelte/instance/references.d.ts +4 -0
- package/dist/src/parsers/svelte/instance/references.js +68 -0
- package/dist/src/parsers/svelte/instance/statements.d.ts +3 -0
- package/dist/src/parsers/svelte/instance/statements.js +10 -0
- package/dist/src/parsers/svelte/module/index.d.ts +3 -0
- package/dist/src/parsers/svelte/module/index.js +34 -0
- package/dist/src/parsers/svelte/types/index.d.ts +4 -0
- package/dist/src/parsers/svelte/types/index.js +2 -0
- package/dist/src/parsers/svelte/typescript/index.d.ts +7 -0
- package/dist/src/parsers/svelte/typescript/index.js +121 -0
- package/dist/src/plugins/compile-away-builder-components.d.ts +15 -0
- package/dist/src/plugins/compile-away-builder-components.js +609 -0
- package/dist/src/plugins/compile-away-components.d.ts +33 -0
- package/dist/src/plugins/compile-away-components.js +50 -0
- package/dist/src/plugins/map-styles.d.ts +12 -0
- package/dist/src/plugins/map-styles.js +16 -0
- package/dist/src/symbols/symbol-processor.d.ts +20 -0
- package/dist/src/symbols/symbol-processor.js +202 -0
- package/dist/src/targets.d.ts +25 -0
- package/dist/src/targets.js +46 -0
- package/dist/src/types/config.d.ts +103 -0
- package/dist/src/types/config.js +2 -0
- package/dist/src/types/json.d.ts +13 -0
- package/dist/src/types/json.js +2 -0
- package/dist/src/types/metadata.d.ts +55 -0
- package/dist/src/types/metadata.js +2 -0
- package/dist/src/types/mitosis-component.d.ts +162 -0
- package/dist/src/types/mitosis-component.js +2 -0
- package/dist/src/types/mitosis-context.d.ts +6 -0
- package/dist/src/types/mitosis-context.js +2 -0
- package/dist/src/types/mitosis-node.d.ts +117 -0
- package/dist/src/types/mitosis-node.js +12 -0
- package/dist/src/types/mitosis-styles.d.ts +1 -0
- package/dist/src/types/mitosis-styles.js +2 -0
- package/dist/src/types/plugins.d.ts +19 -0
- package/dist/src/types/plugins.js +2 -0
- package/dist/src/types/transpiler.d.ts +48 -0
- package/dist/src/types/transpiler.js +2 -0
- package/jsx-runtime.d.ts +2143 -0
- package/package.json +106 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertJsFunctionToSwift = exports.extractFunctionSignature = exports.getBindingType = exports.camelToSnakeCase = exports.getForEachParams = exports.isForEachBlock = exports.needsScrollView = exports.getEventHandlerName = exports.getStatePropertyTypeAnnotation = exports.cssToSwiftUIModifiers = exports.jsxElementToSwiftUIView = exports.getSwiftType = exports.stripStateAndProps = exports.ensureSwiftStringFormat = exports.convertConsoleLogToPrint = void 0;
|
|
4
|
+
const capitalize_1 = require("../../helpers/capitalize");
|
|
5
|
+
const strip_state_and_props_refs_1 = require("../../helpers/strip-state-and-props-refs");
|
|
6
|
+
// TODO(kyle): use babel here to do ast
|
|
7
|
+
const convertConsoleLogToPrint = (code) => {
|
|
8
|
+
if (!code)
|
|
9
|
+
return code;
|
|
10
|
+
// Match console.log statements with various argument patterns
|
|
11
|
+
return code.replace(/console\.log\s*\(\s*(.*?)\s*\)/g, (match, args) => {
|
|
12
|
+
// Handle empty console.log()
|
|
13
|
+
if (!args.trim()) {
|
|
14
|
+
return 'print()';
|
|
15
|
+
}
|
|
16
|
+
// Simple handling for basic console.log calls
|
|
17
|
+
// For complex cases, we'd need a more sophisticated parser
|
|
18
|
+
return `print(${(0, exports.ensureSwiftStringFormat)(args)})`;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.convertConsoleLogToPrint = convertConsoleLogToPrint;
|
|
22
|
+
// Helper function to ensure Swift strings use double quotes
|
|
23
|
+
const ensureSwiftStringFormat = (code) => {
|
|
24
|
+
if (!code)
|
|
25
|
+
return code;
|
|
26
|
+
// We need a more reliable approach to handle nested quotes
|
|
27
|
+
// This uses a state machine approach to track whether we're inside double quotes
|
|
28
|
+
let result = '';
|
|
29
|
+
let insideDoubleQuotes = false;
|
|
30
|
+
for (let i = 0; i < code.length; i++) {
|
|
31
|
+
const char = code[i];
|
|
32
|
+
const prevChar = i > 0 ? code[i - 1] : '';
|
|
33
|
+
// Handle quote state tracking
|
|
34
|
+
if (char === '"' && prevChar !== '\\') {
|
|
35
|
+
insideDoubleQuotes = !insideDoubleQuotes;
|
|
36
|
+
result += char;
|
|
37
|
+
}
|
|
38
|
+
// Only replace single quotes when not inside double quotes
|
|
39
|
+
else if (char === "'" && prevChar !== '\\' && !insideDoubleQuotes) {
|
|
40
|
+
// Start of a single-quoted string
|
|
41
|
+
result += '"';
|
|
42
|
+
// Find the end of the single-quoted string, accounting for escaped quotes
|
|
43
|
+
let j = i + 1;
|
|
44
|
+
while (j < code.length) {
|
|
45
|
+
if (code[j] === "'" && code[j - 1] !== '\\') {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
j++;
|
|
49
|
+
}
|
|
50
|
+
// Add the string content
|
|
51
|
+
result += code.substring(i + 1, j);
|
|
52
|
+
// Add closing double quote if we found the end
|
|
53
|
+
if (j < code.length) {
|
|
54
|
+
result += '"';
|
|
55
|
+
i = j; // Skip to the end of the single-quoted string
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// If no closing quote was found, just add the single quote as is
|
|
59
|
+
result = result.substring(0, result.length - 1) + "'";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
result += char;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
exports.ensureSwiftStringFormat = ensureSwiftStringFormat;
|
|
69
|
+
const stripStateAndProps = ({ json, options, }) => {
|
|
70
|
+
return (code) => {
|
|
71
|
+
// Convert console.log statements to Swift print
|
|
72
|
+
code = (0, exports.convertConsoleLogToPrint)(code);
|
|
73
|
+
// Ensure Swift strings use double quotes
|
|
74
|
+
code = (0, exports.ensureSwiftStringFormat)(code);
|
|
75
|
+
// In Swift, we use self.propertyName for accessing properties
|
|
76
|
+
return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(code, {
|
|
77
|
+
includeState: true,
|
|
78
|
+
includeProps: true,
|
|
79
|
+
replaceWith: (name) => {
|
|
80
|
+
// In Swift, we access properties with self.propertyName
|
|
81
|
+
return `self.${name}`;
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.stripStateAndProps = stripStateAndProps;
|
|
87
|
+
const getSwiftType = (type) => {
|
|
88
|
+
if (!type)
|
|
89
|
+
return 'Any';
|
|
90
|
+
// Handle array types with proper Swift syntax
|
|
91
|
+
if (type.includes('Array<') || type.includes('[]') || type.toLowerCase().startsWith('array')) {
|
|
92
|
+
// Extract the element type from Array<ElementType>
|
|
93
|
+
let elementType = 'Any';
|
|
94
|
+
// Match different array type patterns
|
|
95
|
+
const arrayMatch = type.match(/Array<([^>]+)>/i) ||
|
|
96
|
+
type.match(/([^[\]]+)\[\]/i) ||
|
|
97
|
+
type.match(/array\s*<([^>]+)>/i);
|
|
98
|
+
if (arrayMatch && arrayMatch[1]) {
|
|
99
|
+
elementType = (0, exports.getSwiftType)(arrayMatch[1].trim());
|
|
100
|
+
}
|
|
101
|
+
// Return Swift array type: [ElementType]
|
|
102
|
+
return `[${elementType}]`;
|
|
103
|
+
}
|
|
104
|
+
// Handle primitive types
|
|
105
|
+
switch (type.toLowerCase()) {
|
|
106
|
+
case 'string':
|
|
107
|
+
return 'String';
|
|
108
|
+
case 'number':
|
|
109
|
+
return 'Double';
|
|
110
|
+
case 'boolean':
|
|
111
|
+
case 'bool':
|
|
112
|
+
return 'Bool';
|
|
113
|
+
case 'any':
|
|
114
|
+
return 'Any';
|
|
115
|
+
case 'void':
|
|
116
|
+
return 'Void';
|
|
117
|
+
case 'object':
|
|
118
|
+
return '[String: Any]';
|
|
119
|
+
case 'null':
|
|
120
|
+
case 'undefined':
|
|
121
|
+
return 'Optional<Any>';
|
|
122
|
+
default:
|
|
123
|
+
// For complex types, return as is with first letter capitalized
|
|
124
|
+
return type.charAt(0).toUpperCase() + type.slice(1);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
exports.getSwiftType = getSwiftType;
|
|
128
|
+
const jsxElementToSwiftUIView = (tagName) => {
|
|
129
|
+
// Map JSX/HTML elements to SwiftUI components
|
|
130
|
+
switch (tagName.toLowerCase()) {
|
|
131
|
+
case 'div':
|
|
132
|
+
return 'VStack';
|
|
133
|
+
case 'span':
|
|
134
|
+
case 'p':
|
|
135
|
+
case 'h1':
|
|
136
|
+
case 'h2':
|
|
137
|
+
case 'h3':
|
|
138
|
+
case 'h4':
|
|
139
|
+
case 'h5':
|
|
140
|
+
case 'h6':
|
|
141
|
+
return 'Text';
|
|
142
|
+
case 'img':
|
|
143
|
+
return 'Image';
|
|
144
|
+
case 'input':
|
|
145
|
+
return 'TextField';
|
|
146
|
+
case 'button':
|
|
147
|
+
return 'Button';
|
|
148
|
+
case 'a':
|
|
149
|
+
return 'Link';
|
|
150
|
+
case 'ul':
|
|
151
|
+
return 'List';
|
|
152
|
+
case 'li':
|
|
153
|
+
return 'Text'; // Will be wrapped in List
|
|
154
|
+
case 'form':
|
|
155
|
+
return 'Form';
|
|
156
|
+
case 'select':
|
|
157
|
+
return 'Picker';
|
|
158
|
+
case 'option':
|
|
159
|
+
return 'Text'; // Options in SwiftUI are part of the Picker content
|
|
160
|
+
default:
|
|
161
|
+
// For custom components or unrecognized tags
|
|
162
|
+
return (0, capitalize_1.capitalize)(tagName);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
exports.jsxElementToSwiftUIView = jsxElementToSwiftUIView;
|
|
166
|
+
const cssToSwiftUIModifiers = (style) => {
|
|
167
|
+
const modifiers = [];
|
|
168
|
+
// Map CSS properties to SwiftUI modifiers
|
|
169
|
+
Object.entries(style).forEach(([key, value]) => {
|
|
170
|
+
switch (key) {
|
|
171
|
+
case 'backgroundColor':
|
|
172
|
+
modifiers.push(`.background(Color("${value}"))`);
|
|
173
|
+
break;
|
|
174
|
+
case 'color':
|
|
175
|
+
modifiers.push(`.foregroundColor(Color("${value}"))`);
|
|
176
|
+
break;
|
|
177
|
+
case 'fontSize':
|
|
178
|
+
const fontSize = parseInt(value);
|
|
179
|
+
if (!isNaN(fontSize)) {
|
|
180
|
+
modifiers.push(`.font(.system(size: ${fontSize}))`);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case 'fontWeight':
|
|
184
|
+
modifiers.push(`.fontWeight(.${value})`);
|
|
185
|
+
break;
|
|
186
|
+
case 'padding':
|
|
187
|
+
modifiers.push(`.padding(${value})`);
|
|
188
|
+
break;
|
|
189
|
+
case 'margin':
|
|
190
|
+
// Swift doesn't have direct margin equivalent, we'll use padding
|
|
191
|
+
modifiers.push(`// Note: 'margin' converted to padding: ${value}`);
|
|
192
|
+
modifiers.push(`.padding(${value})`);
|
|
193
|
+
break;
|
|
194
|
+
case 'width':
|
|
195
|
+
modifiers.push(`.frame(width: ${value})`);
|
|
196
|
+
break;
|
|
197
|
+
case 'height':
|
|
198
|
+
modifiers.push(`.frame(height: ${value})`);
|
|
199
|
+
break;
|
|
200
|
+
// Add more CSS to SwiftUI modifier mappings as needed
|
|
201
|
+
default:
|
|
202
|
+
modifiers.push(`// Unmapped style: ${key}: ${value}`);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return modifiers;
|
|
206
|
+
};
|
|
207
|
+
exports.cssToSwiftUIModifiers = cssToSwiftUIModifiers;
|
|
208
|
+
const getStatePropertyTypeAnnotation = (propertyType, type) => {
|
|
209
|
+
// Use appropriate SwiftUI property wrappers
|
|
210
|
+
switch (propertyType) {
|
|
211
|
+
case 'reactive':
|
|
212
|
+
// For reactive state, use @State for simple values
|
|
213
|
+
// @Observable would be used for classes but requires Swift 5.9+/iOS 17+
|
|
214
|
+
return `@State private var`;
|
|
215
|
+
case 'normal':
|
|
216
|
+
// For normal state, use @State for simple values
|
|
217
|
+
return `@State private var`;
|
|
218
|
+
default:
|
|
219
|
+
// For non-reactive values, use a regular property
|
|
220
|
+
return `var`;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
exports.getStatePropertyTypeAnnotation = getStatePropertyTypeAnnotation;
|
|
224
|
+
const getEventHandlerName = (eventName) => {
|
|
225
|
+
switch (eventName) {
|
|
226
|
+
case 'onClick':
|
|
227
|
+
return 'onTapGesture';
|
|
228
|
+
case 'onChange':
|
|
229
|
+
return 'onChange';
|
|
230
|
+
case 'onInput':
|
|
231
|
+
return 'onEditingChanged';
|
|
232
|
+
case 'onBlur':
|
|
233
|
+
return 'onSubmit';
|
|
234
|
+
case 'onFocus':
|
|
235
|
+
return 'onEditingChanged';
|
|
236
|
+
default:
|
|
237
|
+
return eventName;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
exports.getEventHandlerName = getEventHandlerName;
|
|
241
|
+
const needsScrollView = (json) => {
|
|
242
|
+
// Check if overflow property indicates scrolling
|
|
243
|
+
if (json.properties.style) {
|
|
244
|
+
try {
|
|
245
|
+
const styleObj = JSON.parse(json.properties.style);
|
|
246
|
+
return (styleObj.overflow === 'auto' ||
|
|
247
|
+
styleObj.overflow === 'scroll' ||
|
|
248
|
+
styleObj.overflowY === 'auto' ||
|
|
249
|
+
styleObj.overflowY === 'scroll' ||
|
|
250
|
+
styleObj.overflowX === 'auto' ||
|
|
251
|
+
styleObj.overflowX === 'scroll');
|
|
252
|
+
}
|
|
253
|
+
catch (e) {
|
|
254
|
+
// If style can't be parsed, check for overflow directly in the style string
|
|
255
|
+
const styleStr = json.properties.style;
|
|
256
|
+
return (styleStr.includes('overflow:auto') ||
|
|
257
|
+
styleStr.includes('overflow:scroll') ||
|
|
258
|
+
styleStr.includes('overflow-y:auto') ||
|
|
259
|
+
styleStr.includes('overflow-y:scroll') ||
|
|
260
|
+
styleStr.includes('overflow-x:auto') ||
|
|
261
|
+
styleStr.includes('overflow-x:scroll'));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
};
|
|
266
|
+
exports.needsScrollView = needsScrollView;
|
|
267
|
+
const isForEachBlock = (json) => {
|
|
268
|
+
var _a;
|
|
269
|
+
// Check if this is a ForEach binding using the bindings.each pattern
|
|
270
|
+
return !!((_a = json.bindings.each) === null || _a === void 0 ? void 0 : _a.code);
|
|
271
|
+
};
|
|
272
|
+
exports.isForEachBlock = isForEachBlock;
|
|
273
|
+
const getForEachParams = (json, processCode) => {
|
|
274
|
+
var _a, _b;
|
|
275
|
+
if (!((_a = json.bindings.each) === null || _a === void 0 ? void 0 : _a.code)) {
|
|
276
|
+
return { collection: '', itemName: 'item', indexName: null };
|
|
277
|
+
}
|
|
278
|
+
const eachCode = json.bindings.each.code;
|
|
279
|
+
let itemName = 'item';
|
|
280
|
+
let indexName = null;
|
|
281
|
+
// Extract collection, item name, and index name from each binding
|
|
282
|
+
try {
|
|
283
|
+
// Parse expressions like: items.map(item => ...)
|
|
284
|
+
// or items.map((item, index) => ...)
|
|
285
|
+
const match = eachCode.match(/(\w+)\.map\(\s*(?:\()?([^,)]+)(?:,\s*([^)]+))?\)?/);
|
|
286
|
+
if (match) {
|
|
287
|
+
const collection = processCode(match[1]);
|
|
288
|
+
itemName = match[2].trim();
|
|
289
|
+
indexName = ((_b = match[3]) === null || _b === void 0 ? void 0 : _b.trim()) || null;
|
|
290
|
+
return { collection, itemName, indexName };
|
|
291
|
+
}
|
|
292
|
+
// Fallback to the whole code as collection if pattern doesn't match
|
|
293
|
+
return {
|
|
294
|
+
collection: processCode(eachCode),
|
|
295
|
+
itemName,
|
|
296
|
+
indexName,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
console.warn('Failed to parse each binding:', eachCode);
|
|
301
|
+
return {
|
|
302
|
+
collection: processCode(eachCode),
|
|
303
|
+
itemName,
|
|
304
|
+
indexName,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
exports.getForEachParams = getForEachParams;
|
|
309
|
+
const camelToSnakeCase = (str) => {
|
|
310
|
+
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
311
|
+
};
|
|
312
|
+
exports.camelToSnakeCase = camelToSnakeCase;
|
|
313
|
+
const getBindingType = (key) => {
|
|
314
|
+
if (key.startsWith('bind:')) {
|
|
315
|
+
return key.substring(5);
|
|
316
|
+
}
|
|
317
|
+
return key;
|
|
318
|
+
};
|
|
319
|
+
exports.getBindingType = getBindingType;
|
|
320
|
+
/**
|
|
321
|
+
* Extract function signature information from JavaScript function code
|
|
322
|
+
*/
|
|
323
|
+
const extractFunctionSignature = (code) => {
|
|
324
|
+
// Default values
|
|
325
|
+
let name = '';
|
|
326
|
+
let params = [];
|
|
327
|
+
let returnType = 'Void';
|
|
328
|
+
let body = '';
|
|
329
|
+
// Extract function name, parameters, and body
|
|
330
|
+
const funcMatch = code.match(/(?:function\s+)?([a-zA-Z_$][a-zA-Z0-9_$]*)?\s*\(([^)]*)\)\s*(?:=>)?\s*(?:{([\s\S]*)}|(.*))/);
|
|
331
|
+
if (funcMatch) {
|
|
332
|
+
name = funcMatch[1] || '';
|
|
333
|
+
// Extract parameters
|
|
334
|
+
const paramsStr = funcMatch[2].trim();
|
|
335
|
+
if (paramsStr) {
|
|
336
|
+
params = paramsStr.split(',').map((param) => {
|
|
337
|
+
// Handle TypeScript-style parameter types if present
|
|
338
|
+
const paramParts = param.trim().split(':');
|
|
339
|
+
const paramName = paramParts[0].trim();
|
|
340
|
+
const paramType = paramParts.length > 1 ? (0, exports.getSwiftType)(paramParts[1].trim()) : 'Any';
|
|
341
|
+
return { name: paramName, type: paramType };
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
// Extract function body
|
|
345
|
+
body = funcMatch[3] || funcMatch[4] || '';
|
|
346
|
+
// Try to determine return type from TypeScript annotations or infer from return statements
|
|
347
|
+
const returnTypeMatch = code.match(/\)\s*:\s*([^{]+)/);
|
|
348
|
+
if (returnTypeMatch) {
|
|
349
|
+
returnType = (0, exports.getSwiftType)(returnTypeMatch[1].trim());
|
|
350
|
+
}
|
|
351
|
+
else if (body.includes('return')) {
|
|
352
|
+
// Try to infer from return statements
|
|
353
|
+
const returnValueMatch = body.match(/return\s+(["'].*["']|true|false|\d+|\d+\.\d+|\[.*\])/);
|
|
354
|
+
if (returnValueMatch) {
|
|
355
|
+
const returnValue = returnValueMatch[1];
|
|
356
|
+
if (returnValue.startsWith('"') || returnValue.startsWith("'")) {
|
|
357
|
+
returnType = 'String';
|
|
358
|
+
}
|
|
359
|
+
else if (returnValue === 'true' || returnValue === 'false') {
|
|
360
|
+
returnType = 'Bool';
|
|
361
|
+
}
|
|
362
|
+
else if (returnValue.match(/^\d+$/)) {
|
|
363
|
+
returnType = 'Int';
|
|
364
|
+
}
|
|
365
|
+
else if (returnValue.match(/^\d+\.\d+$/)) {
|
|
366
|
+
returnType = 'Double';
|
|
367
|
+
}
|
|
368
|
+
else if (returnValue.startsWith('[')) {
|
|
369
|
+
returnType = '[Any]';
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return { name, params, returnType, body };
|
|
375
|
+
};
|
|
376
|
+
exports.extractFunctionSignature = extractFunctionSignature;
|
|
377
|
+
/**
|
|
378
|
+
* Convert JavaScript function code to Swift function syntax
|
|
379
|
+
*/
|
|
380
|
+
const convertJsFunctionToSwift = (code, functionName) => {
|
|
381
|
+
// Extract the function signature
|
|
382
|
+
const { name, params, returnType, body } = (0, exports.extractFunctionSignature)(code);
|
|
383
|
+
// Use provided name or extracted name
|
|
384
|
+
const finalName = functionName || name || 'function';
|
|
385
|
+
// Convert function body to Swift
|
|
386
|
+
let swiftBody = body
|
|
387
|
+
// Convert variable declarations
|
|
388
|
+
.replace(/\bvar\s+(\w+)/g, 'var $1')
|
|
389
|
+
.replace(/\blet\s+(\w+)/g, 'let $1')
|
|
390
|
+
.replace(/\bconst\s+(\w+)/g, 'let $1')
|
|
391
|
+
// Convert common array methods
|
|
392
|
+
.replace(/\.push\(/g, '.append(')
|
|
393
|
+
.replace(/\.map\(/g, '.map(')
|
|
394
|
+
.replace(/\.filter\(/g, '.filter(')
|
|
395
|
+
.replace(/\.includes\(/g, '.contains(')
|
|
396
|
+
.replace(/\.indexOf\(/g, '.firstIndex(of: ')
|
|
397
|
+
// Convert null/undefined checks
|
|
398
|
+
.replace(/=== null/g, '== nil')
|
|
399
|
+
.replace(/!== null/g, '!= nil')
|
|
400
|
+
.replace(/=== undefined/g, '== nil')
|
|
401
|
+
.replace(/!== undefined/g, '!= nil')
|
|
402
|
+
// Convert console.log
|
|
403
|
+
.replace(/console\.log\((.+?)\)/g, 'print($1)');
|
|
404
|
+
// Create parameter list with Swift types
|
|
405
|
+
const paramList = params.map((p) => `${p.name}: ${p.type}`).join(', ');
|
|
406
|
+
// Build the Swift function signature
|
|
407
|
+
const signature = `func ${finalName}(${paramList}) -> ${returnType}`;
|
|
408
|
+
// Build the complete Swift function
|
|
409
|
+
const swiftCode = `${signature} {\n ${swiftBody}\n}`;
|
|
410
|
+
return { swiftCode, signature };
|
|
411
|
+
};
|
|
412
|
+
exports.convertJsFunctionToSwift = convertJsFunctionToSwift;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generator"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseTranspilerOptions } from '../../types/transpiler';
|
|
2
|
+
export interface ToSwiftOptions extends BaseTranspilerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Format generated Swift code
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
formatCode?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Include type annotations in Swift code
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
includeTypes?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Type of state management to use
|
|
15
|
+
* @default 'state'
|
|
16
|
+
*/
|
|
17
|
+
stateType?: 'state' | 'stateObject' | 'observable';
|
|
18
|
+
/**
|
|
19
|
+
* Prefix for class names
|
|
20
|
+
* @default ''
|
|
21
|
+
*/
|
|
22
|
+
classPrefix?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to include SwiftUI preview code
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
includePreview?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export type SwiftMetadata = {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToTaroOptions } from '../../generators/taro/types';
|
|
2
|
+
import { ClassStyleMap } from '../../helpers/styles/helpers';
|
|
3
|
+
import { MitosisComponent } from '../../types/mitosis-component';
|
|
4
|
+
import { TranspilerGenerator } from '../../types/transpiler';
|
|
5
|
+
export declare const DEFAULT_Component_SET: Set<string>;
|
|
6
|
+
export declare const collectTaroStyles: (json: MitosisComponent) => ClassStyleMap;
|
|
7
|
+
export declare const TagMap: Record<string, string>;
|
|
8
|
+
export declare const componentToTaro: TranspilerGenerator<Partial<ToTaroOptions>>;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.componentToTaro = exports.TagMap = exports.collectTaroStyles = exports.DEFAULT_Component_SET = void 0;
|
|
7
|
+
const json5_1 = __importDefault(require("json5"));
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
10
|
+
const bindings_1 = require("../../helpers/bindings");
|
|
11
|
+
const fast_clone_1 = require("../../helpers/fast-clone");
|
|
12
|
+
const is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
|
|
13
|
+
const merge_options_1 = require("../../helpers/merge-options");
|
|
14
|
+
const react_1 = require("../react");
|
|
15
|
+
// @tarojs/components
|
|
16
|
+
exports.DEFAULT_Component_SET = new Set([
|
|
17
|
+
'View',
|
|
18
|
+
'Icon',
|
|
19
|
+
'Progress',
|
|
20
|
+
'RichText',
|
|
21
|
+
'Text',
|
|
22
|
+
'Button',
|
|
23
|
+
'Checkbox',
|
|
24
|
+
'CheckboxGroup',
|
|
25
|
+
'Form',
|
|
26
|
+
'Input',
|
|
27
|
+
'Label',
|
|
28
|
+
'Picker',
|
|
29
|
+
'PickerView',
|
|
30
|
+
'PickerViewColumn',
|
|
31
|
+
'Radio',
|
|
32
|
+
'RadioGroup',
|
|
33
|
+
'Slider',
|
|
34
|
+
'Switch',
|
|
35
|
+
'CoverImage',
|
|
36
|
+
'Textarea',
|
|
37
|
+
'CoverView',
|
|
38
|
+
'MovableArea',
|
|
39
|
+
'MovableView',
|
|
40
|
+
'ScrollView',
|
|
41
|
+
'Swiper',
|
|
42
|
+
'SwiperItem',
|
|
43
|
+
'Navigator',
|
|
44
|
+
'Audio',
|
|
45
|
+
'Camera',
|
|
46
|
+
'Image',
|
|
47
|
+
'LivePlayer',
|
|
48
|
+
'Video',
|
|
49
|
+
'Canvas',
|
|
50
|
+
'Ad',
|
|
51
|
+
'WebView',
|
|
52
|
+
'Block',
|
|
53
|
+
'Map',
|
|
54
|
+
'Slot',
|
|
55
|
+
'SlotView',
|
|
56
|
+
'Editor',
|
|
57
|
+
'MatchMedia',
|
|
58
|
+
'FunctionalPageNavigator',
|
|
59
|
+
'LivePusher',
|
|
60
|
+
'OfficialAccount',
|
|
61
|
+
'OpenData',
|
|
62
|
+
'NavigationBar',
|
|
63
|
+
'PageMeta',
|
|
64
|
+
'VoipRoom',
|
|
65
|
+
'AdCustom',
|
|
66
|
+
]);
|
|
67
|
+
// TODO: px to 2 px
|
|
68
|
+
const collectTaroStyles = (json) => {
|
|
69
|
+
const styleMap = {};
|
|
70
|
+
const componentIndexes = {};
|
|
71
|
+
(0, legacy_1.default)(json).forEach(function (item) {
|
|
72
|
+
var _a;
|
|
73
|
+
if (!(0, is_mitosis_node_1.isMitosisNode)(item) || typeof ((_a = item.bindings.css) === null || _a === void 0 ? void 0 : _a.code) !== 'string') {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const value = json5_1.default.parse(item.bindings.css.code);
|
|
77
|
+
delete item.bindings.css;
|
|
78
|
+
if (!(0, lodash_1.size)(value)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
for (const key in value) {
|
|
82
|
+
const propertyValue = value[key];
|
|
83
|
+
// convert px to 2 * px, PX to PX
|
|
84
|
+
if (typeof propertyValue === 'string' && propertyValue.match(/^\d/)) {
|
|
85
|
+
let newValue = parseFloat(propertyValue);
|
|
86
|
+
if (!isNaN(newValue)) {
|
|
87
|
+
if (propertyValue.endsWith('px')) {
|
|
88
|
+
newValue = 2 * newValue;
|
|
89
|
+
value[key] = `${newValue}px`;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
value[key] = newValue;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const componentName = (0, lodash_1.camelCase)(item.name || 'view');
|
|
98
|
+
const index = (componentIndexes[componentName] = (componentIndexes[componentName] || 0) + 1);
|
|
99
|
+
const className = `${componentName}${index}`;
|
|
100
|
+
item.bindings.style = (0, bindings_1.createSingleBinding)({ code: `styles.${className}` });
|
|
101
|
+
styleMap[className] = value;
|
|
102
|
+
});
|
|
103
|
+
return styleMap;
|
|
104
|
+
};
|
|
105
|
+
exports.collectTaroStyles = collectTaroStyles;
|
|
106
|
+
exports.TagMap = {
|
|
107
|
+
span: 'Text',
|
|
108
|
+
button: 'Button',
|
|
109
|
+
input: 'Input',
|
|
110
|
+
img: 'Image',
|
|
111
|
+
form: 'Form',
|
|
112
|
+
textarea: 'Textarea',
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Plugin that handles necessary transformations from React to React Native:
|
|
116
|
+
* - Converts DOM tags to @tarojs/components
|
|
117
|
+
* - Removes redundant `class`/`className` attributes
|
|
118
|
+
*/
|
|
119
|
+
const PROCESS_TARO_PLUGIN = () => ({
|
|
120
|
+
json: {
|
|
121
|
+
pre: (json) => {
|
|
122
|
+
const TaroComponentsImports = { path: '@tarojs/components', imports: {} };
|
|
123
|
+
json.imports.push(TaroComponentsImports);
|
|
124
|
+
(0, legacy_1.default)(json).forEach((node) => {
|
|
125
|
+
var _a, _b, _c, _d;
|
|
126
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
127
|
+
// TODO: More dom tags convert to @tarojs/components
|
|
128
|
+
if (!!exports.TagMap[node.name]) {
|
|
129
|
+
TaroComponentsImports.imports[exports.TagMap[node.name]] = exports.TagMap[node.name];
|
|
130
|
+
node.name = exports.TagMap[node.name];
|
|
131
|
+
}
|
|
132
|
+
else if (node.name.toLowerCase() === node.name) {
|
|
133
|
+
TaroComponentsImports.imports.View = 'View';
|
|
134
|
+
node.name = 'View';
|
|
135
|
+
}
|
|
136
|
+
if (((_a = node.properties._text) === null || _a === void 0 ? void 0 : _a.trim().length) || ((_d = (_c = (_b = node.bindings._text) === null || _b === void 0 ? void 0 : _b.code) === null || _c === void 0 ? void 0 : _c.trim()) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
137
|
+
TaroComponentsImports.imports.Text = 'Text';
|
|
138
|
+
node.name = 'Text';
|
|
139
|
+
}
|
|
140
|
+
if (node.properties.class) {
|
|
141
|
+
delete node.properties.class;
|
|
142
|
+
}
|
|
143
|
+
if (node.properties.className) {
|
|
144
|
+
delete node.properties.className;
|
|
145
|
+
}
|
|
146
|
+
if (node.bindings.class) {
|
|
147
|
+
delete node.bindings.class;
|
|
148
|
+
}
|
|
149
|
+
if (node.bindings.className) {
|
|
150
|
+
delete node.bindings.className;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
const DEFAULT_OPTIONS = {
|
|
158
|
+
stateType: 'useState',
|
|
159
|
+
plugins: [PROCESS_TARO_PLUGIN],
|
|
160
|
+
};
|
|
161
|
+
const componentToTaro = (_options = {}) => ({ component, path }) => {
|
|
162
|
+
const json = (0, fast_clone_1.fastClone)(component);
|
|
163
|
+
const options = (0, merge_options_1.mergeOptions)(DEFAULT_OPTIONS, _options, {
|
|
164
|
+
type: 'taro',
|
|
165
|
+
});
|
|
166
|
+
return (0, react_1.componentToReact)(options)({ component: json, path });
|
|
167
|
+
};
|
|
168
|
+
exports.componentToTaro = componentToTaro;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generator"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|