@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,198 @@
|
|
|
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.getDefaultImport = exports.getReactVariantStateString = exports.getReactVariantStateImportString = exports.updateStateSettersInCode = exports.updateStateSetters = exports.getUseStateCode = exports.processHookCode = void 0;
|
|
7
|
+
const capitalize_1 = require("../../../helpers/capitalize");
|
|
8
|
+
const get_function_string_1 = require("../../../helpers/get-function-string");
|
|
9
|
+
const get_state_object_string_1 = require("../../../helpers/get-state-object-string");
|
|
10
|
+
const get_typed_function_1 = require("../../../helpers/get-typed-function");
|
|
11
|
+
const is_mitosis_node_1 = require("../../../helpers/is-mitosis-node");
|
|
12
|
+
const patterns_1 = require("../../../helpers/patterns");
|
|
13
|
+
const transform_state_setters_1 = require("../../../helpers/transform-state-setters");
|
|
14
|
+
const core_1 = require("@babel/core");
|
|
15
|
+
const function_1 = require("fp-ts/lib/function");
|
|
16
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
17
|
+
const helpers_1 = require("../helpers");
|
|
18
|
+
/**
|
|
19
|
+
* Removes all `this.` references.
|
|
20
|
+
*/
|
|
21
|
+
const stripThisRefs = (str, options) => {
|
|
22
|
+
if (options.stateType !== 'useState') {
|
|
23
|
+
return str;
|
|
24
|
+
}
|
|
25
|
+
return str.replace(/this\.([a-zA-Z_\$0-9]+)/g, '$1');
|
|
26
|
+
};
|
|
27
|
+
const processHookCode = ({ str, options }) => (0, helpers_1.processBinding)((0, exports.updateStateSettersInCode)(str, options), options);
|
|
28
|
+
exports.processHookCode = processHookCode;
|
|
29
|
+
const valueMapper = (options) => (val) => {
|
|
30
|
+
const x = (0, exports.processHookCode)({ str: val, options });
|
|
31
|
+
return stripThisRefs(x, options);
|
|
32
|
+
};
|
|
33
|
+
const getSetStateFnName = (stateName) => `set${(0, capitalize_1.capitalize)(stateName)}`;
|
|
34
|
+
const processStateValue = (options) => {
|
|
35
|
+
const mapValue = valueMapper(options);
|
|
36
|
+
return ([key, stateVal]) => {
|
|
37
|
+
if (!stateVal) {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
let value = stateVal.code || '';
|
|
41
|
+
const type = stateVal.type;
|
|
42
|
+
const typeParameter = stateVal.typeParameter;
|
|
43
|
+
const stateType = options.typescript && stateVal.typeParameter ? `<${stateVal.typeParameter}>` : '';
|
|
44
|
+
let result = '';
|
|
45
|
+
if (type === 'getter') {
|
|
46
|
+
result = (0, function_1.pipe)(value, patterns_1.replaceGetterWithFunction, mapValue);
|
|
47
|
+
}
|
|
48
|
+
else if (type === 'function') {
|
|
49
|
+
result = mapValue(value);
|
|
50
|
+
}
|
|
51
|
+
else if (type === 'method') {
|
|
52
|
+
result = (0, function_1.pipe)(value, patterns_1.prefixWithFunction, mapValue);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return `const [${key}, ${getSetStateFnName(key)}] = useState${stateType}(() => (${mapValue(value)}))`;
|
|
56
|
+
}
|
|
57
|
+
return (0, get_typed_function_1.getTypedFunction)(result, options.typescript, typeParameter);
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const getUseStateCode = (json, options) => {
|
|
61
|
+
const lineItemDelimiter = '\n\n\n';
|
|
62
|
+
const stringifiedState = Object.entries(json.state).map(processStateValue(options));
|
|
63
|
+
return stringifiedState.join(lineItemDelimiter);
|
|
64
|
+
};
|
|
65
|
+
exports.getUseStateCode = getUseStateCode;
|
|
66
|
+
const updateStateSetters = (json, options) => {
|
|
67
|
+
if (options.stateType !== 'useState') {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
(0, legacy_1.default)(json).forEach(function (item) {
|
|
71
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
72
|
+
for (const key in item.bindings) {
|
|
73
|
+
let values = item.bindings[key];
|
|
74
|
+
const newValue = (0, exports.updateStateSettersInCode)(values === null || values === void 0 ? void 0 : values.code, options);
|
|
75
|
+
if (newValue !== (values === null || values === void 0 ? void 0 : values.code)) {
|
|
76
|
+
item.bindings[key] = {
|
|
77
|
+
...values,
|
|
78
|
+
code: newValue,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
exports.updateStateSetters = updateStateSetters;
|
|
86
|
+
const updateStateSettersInCode = (value, options) => {
|
|
87
|
+
if (options.stateType !== 'useState') {
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
return (0, transform_state_setters_1.transformStateSetters)({
|
|
91
|
+
value,
|
|
92
|
+
transformer: ({ path, propertyName }) => core_1.types.callExpression(core_1.types.identifier(getSetStateFnName(propertyName)), [path.node.right]),
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
exports.updateStateSettersInCode = updateStateSettersInCode;
|
|
96
|
+
const getReactVariantStateImportString = (hasState, options) => {
|
|
97
|
+
return !hasState
|
|
98
|
+
? ''
|
|
99
|
+
: options.stateType === 'valtio'
|
|
100
|
+
? `import { useLocalProxy } from 'valtio/utils';`
|
|
101
|
+
: options.stateType === 'solid'
|
|
102
|
+
? `import { useMutable } from 'react-solid-state';`
|
|
103
|
+
: options.stateType === 'mobx'
|
|
104
|
+
? `import { useLocalObservable, observer } from 'mobx-react-lite';`
|
|
105
|
+
: '';
|
|
106
|
+
};
|
|
107
|
+
exports.getReactVariantStateImportString = getReactVariantStateImportString;
|
|
108
|
+
const getReactVariantStateString = ({ hasState, options, json, useStateCode, }) => hasState
|
|
109
|
+
? options.stateType === 'mobx'
|
|
110
|
+
? `const state = useLocalObservable(() => (${(0, get_state_object_string_1.getStateObjectStringFromComponent)(json)}));`
|
|
111
|
+
: options.stateType === 'useState'
|
|
112
|
+
? useStateCode
|
|
113
|
+
: options.stateType === 'solid'
|
|
114
|
+
? `const state = useMutable(${(0, get_state_object_string_1.getStateObjectStringFromComponent)(json)});`
|
|
115
|
+
: options.stateType === 'builder'
|
|
116
|
+
? `const state = useBuilderState(${(0, get_state_object_string_1.getStateObjectStringFromComponent)(json)});`
|
|
117
|
+
: options.stateType === 'variables'
|
|
118
|
+
? (0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
|
|
119
|
+
format: 'variables',
|
|
120
|
+
keyPrefix: 'const',
|
|
121
|
+
valueMapper: (code, type, _, key) => {
|
|
122
|
+
if (key) {
|
|
123
|
+
const constPrefix = !code.startsWith('function') ? `${key} = ` : '';
|
|
124
|
+
if (type === 'getter')
|
|
125
|
+
return `${constPrefix}${(0, get_function_string_1.getFunctionString)(code.replace('get ', ''))}`;
|
|
126
|
+
if (type === 'function')
|
|
127
|
+
return code.startsWith('async') ? code : `${constPrefix}${(0, get_function_string_1.getFunctionString)(code)}`;
|
|
128
|
+
}
|
|
129
|
+
return code;
|
|
130
|
+
},
|
|
131
|
+
})
|
|
132
|
+
: `const state = useLocalProxy(${(0, get_state_object_string_1.getStateObjectStringFromComponent)(json)});`
|
|
133
|
+
: '';
|
|
134
|
+
exports.getReactVariantStateString = getReactVariantStateString;
|
|
135
|
+
const getDefaultImport = (options, json) => {
|
|
136
|
+
const { preact, type } = options;
|
|
137
|
+
if (preact) {
|
|
138
|
+
return `
|
|
139
|
+
/** @jsx h */
|
|
140
|
+
import { h, Fragment } from 'preact';
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
if (type === 'native') {
|
|
144
|
+
const namesUsed = new Set(), knownImports = new Set();
|
|
145
|
+
json.imports.forEach((imported) => {
|
|
146
|
+
if (imported.imports) {
|
|
147
|
+
Object.keys(imported.imports).forEach((name) => {
|
|
148
|
+
knownImports.add(name);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
(0, legacy_1.default)(json).forEach((node) => {
|
|
153
|
+
var _a, _b, _c, _d;
|
|
154
|
+
if (!(0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// ReactNative has a special case for converting _text to Text
|
|
158
|
+
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)) {
|
|
159
|
+
namesUsed.add('Text');
|
|
160
|
+
}
|
|
161
|
+
if (node.properties.style || node.bindings.style) {
|
|
162
|
+
namesUsed.add('StyleSheet');
|
|
163
|
+
}
|
|
164
|
+
if (node.name === 'TouchableOpacity' &&
|
|
165
|
+
('href' in node.bindings || 'href' in node.properties)) {
|
|
166
|
+
namesUsed.add('Linking');
|
|
167
|
+
}
|
|
168
|
+
namesUsed.add(node.name);
|
|
169
|
+
});
|
|
170
|
+
const components = [
|
|
171
|
+
'FlatList',
|
|
172
|
+
'ScrollView',
|
|
173
|
+
'View',
|
|
174
|
+
'StyleSheet',
|
|
175
|
+
'Image',
|
|
176
|
+
'Text',
|
|
177
|
+
'Pressable',
|
|
178
|
+
'TextInput',
|
|
179
|
+
'TouchableOpacity',
|
|
180
|
+
'Button',
|
|
181
|
+
'Linking',
|
|
182
|
+
].filter((name) => {
|
|
183
|
+
// Ony import if the name is used and not imported from somewhere else
|
|
184
|
+
return namesUsed.has(name) && !knownImports.has(name);
|
|
185
|
+
});
|
|
186
|
+
return `
|
|
187
|
+
import * as React from 'react';
|
|
188
|
+
import { ${components.join(', ')} } from 'react-native';
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
if (type === 'taro') {
|
|
192
|
+
return `
|
|
193
|
+
import * as React from 'react';
|
|
194
|
+
`;
|
|
195
|
+
}
|
|
196
|
+
return "import * as React from 'react';";
|
|
197
|
+
};
|
|
198
|
+
exports.getDefaultImport = getDefaultImport;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
exports.blockToReact = void 0;
|
|
18
|
+
var blocks_1 = require("./blocks");
|
|
19
|
+
Object.defineProperty(exports, "blockToReact", { enumerable: true, get: function () { return blocks_1.blockToReact; } });
|
|
20
|
+
__exportStar(require("./generator"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseTranspilerOptions } from '../../types/transpiler';
|
|
2
|
+
export interface ToReactOptions extends BaseTranspilerOptions {
|
|
3
|
+
stylesType: 'emotion' | 'styled-components' | 'styled-jsx' | 'react-native' | 'style-tag' | 'twrnc' | 'native-wind';
|
|
4
|
+
styleTagsPlacement?: 'top' | 'bottom';
|
|
5
|
+
stateType: 'useState' | 'mobx' | 'valtio' | 'solid' | 'builder' | 'variables';
|
|
6
|
+
format?: 'lite' | 'safe';
|
|
7
|
+
type: 'dom' | 'native' | 'taro';
|
|
8
|
+
preact?: boolean;
|
|
9
|
+
sanitizeReactNative?: boolean;
|
|
10
|
+
rsc?: boolean;
|
|
11
|
+
forwardRef?: string;
|
|
12
|
+
experimental?: any;
|
|
13
|
+
/**
|
|
14
|
+
* For RSC, normal React context is currently not supported, so provide a prop drilling
|
|
15
|
+
* option
|
|
16
|
+
*/
|
|
17
|
+
contextType?: 'context' | 'prop-drill';
|
|
18
|
+
addUseClientDirectiveIfNeeded?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type ReactMetadata = {
|
|
21
|
+
forwardRef?: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractCssVarDefaultValue(value: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractCssVarDefaultValue = void 0;
|
|
4
|
+
function extractCssVarDefaultValue(value) {
|
|
5
|
+
// Regular expression to find var() expressions
|
|
6
|
+
const varRegex = /var\(--[^,]+?,\s*([^)]+)\)/;
|
|
7
|
+
// Function to replace var() with its fallback
|
|
8
|
+
let newValue = value;
|
|
9
|
+
let match;
|
|
10
|
+
while ((match = newValue.match(varRegex))) {
|
|
11
|
+
newValue = newValue.replace(match[0], match[1].trim());
|
|
12
|
+
}
|
|
13
|
+
return newValue;
|
|
14
|
+
}
|
|
15
|
+
exports.extractCssVarDefaultValue = extractCssVarDefaultValue;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanReactNativeBlockStyles = void 0;
|
|
4
|
+
const extract_css_var_default_value_1 = require("./extract-css-var-default-value");
|
|
5
|
+
const lengthPattern = /^-?\d*\.?\d+(px|%)?$/;
|
|
6
|
+
const pixelPattern = /^-?\d*\.?\d+(px)?$/;
|
|
7
|
+
const numberPattern = /^-?\d*\.?\d+$/;
|
|
8
|
+
const colorPattern = /^(#[0-9A-Fa-f]{3,8}|(rgb|hsl)a?\(.*\)|[a-zA-Z]+)$/;
|
|
9
|
+
// List of unsupported properties in React Native
|
|
10
|
+
const unsupportedProps = [
|
|
11
|
+
'textShadow',
|
|
12
|
+
'boxShadow',
|
|
13
|
+
'transition',
|
|
14
|
+
'cursor',
|
|
15
|
+
'filter',
|
|
16
|
+
'overflowX',
|
|
17
|
+
'overflowY',
|
|
18
|
+
'animation',
|
|
19
|
+
'backgroundImage',
|
|
20
|
+
'backgroundPosition',
|
|
21
|
+
'backgroundSize',
|
|
22
|
+
'backgroundRepeat',
|
|
23
|
+
'whiteSpace',
|
|
24
|
+
];
|
|
25
|
+
// Ensure CSS property value is valid for React Native
|
|
26
|
+
function validateReactNativeCssProperty(key, value) {
|
|
27
|
+
const cssProperties = {
|
|
28
|
+
width: (value) => lengthPattern.test(value),
|
|
29
|
+
height: (value) => lengthPattern.test(value),
|
|
30
|
+
backgroundColor: (value) => pixelPattern.test(value) || /^#[0-9A-Fa-f]{6}/.test(value),
|
|
31
|
+
minWidth: (value) => lengthPattern.test(value) || value === 'auto',
|
|
32
|
+
maxWidth: (value) => lengthPattern.test(value) || value === 'auto',
|
|
33
|
+
minHeight: (value) => lengthPattern.test(value) || value === 'auto',
|
|
34
|
+
maxHeight: (value) => lengthPattern.test(value) || value === 'auto',
|
|
35
|
+
aspectRatio: (value) => numberPattern.test(value) || /^\d+\/\d+$/.test(value),
|
|
36
|
+
// Flexbox Properties
|
|
37
|
+
flex: (value) => numberPattern.test(value),
|
|
38
|
+
flexBasis: (value) => lengthPattern.test(value) || value === 'auto',
|
|
39
|
+
flexDirection: (value) => ['row', 'row-reverse', 'column', 'column-reverse'].includes(value),
|
|
40
|
+
flexGrow: (value) => numberPattern.test(value),
|
|
41
|
+
flexShrink: (value) => numberPattern.test(value),
|
|
42
|
+
flexWrap: (value) => ['wrap', 'nowrap', 'wrap-reverse'].includes(value),
|
|
43
|
+
// Alignment Properties
|
|
44
|
+
alignContent: (value) => ['flex-start', 'flex-end', 'center', 'stretch', 'space-between', 'space-around'].includes(value),
|
|
45
|
+
alignItems: (value) => ['flex-start', 'flex-end', 'center', 'stretch', 'baseline'].includes(value),
|
|
46
|
+
alignSelf: (value) => ['auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline'].includes(value),
|
|
47
|
+
justifyContent: (value) => [
|
|
48
|
+
'flex-start',
|
|
49
|
+
'flex-end',
|
|
50
|
+
'center',
|
|
51
|
+
'space-between',
|
|
52
|
+
'space-around',
|
|
53
|
+
'space-evenly',
|
|
54
|
+
].includes(value),
|
|
55
|
+
// Text Properties
|
|
56
|
+
color: (value) => colorPattern.test(value),
|
|
57
|
+
fontFamily: () => true, // Any string is valid
|
|
58
|
+
fontSize: (value) => pixelPattern.test(value),
|
|
59
|
+
fontStyle: (value) => ['normal', 'italic'].includes(value),
|
|
60
|
+
fontWeight: (value) => ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'].includes(value),
|
|
61
|
+
display: (value) => ['none', 'flex'].includes(value),
|
|
62
|
+
};
|
|
63
|
+
// If the property is not explicitly defined, consider it valid
|
|
64
|
+
if (!cssProperties[key])
|
|
65
|
+
return true;
|
|
66
|
+
// Convert number to string for validation
|
|
67
|
+
const stringValue = typeof value === 'number' ? value.toString() : value;
|
|
68
|
+
return cssProperties[key](stringValue);
|
|
69
|
+
}
|
|
70
|
+
// Clean up shorthand and unsupported styles for React Native
|
|
71
|
+
function cleanReactNativeBlockStyles(styles) {
|
|
72
|
+
return Object.entries(styles).reduce((acc, [key, value]) => {
|
|
73
|
+
var _a;
|
|
74
|
+
// Remove unsupported properties
|
|
75
|
+
if (unsupportedProps.includes(key))
|
|
76
|
+
return acc;
|
|
77
|
+
// Handle CSS variables
|
|
78
|
+
if (typeof value === 'string' && value.includes('var(')) {
|
|
79
|
+
value = (_a = (0, extract_css_var_default_value_1.extractCssVarDefaultValue)(value)) !== null && _a !== void 0 ? _a : value;
|
|
80
|
+
}
|
|
81
|
+
// Parse pixel units
|
|
82
|
+
if (typeof value === 'string') {
|
|
83
|
+
const pixelMatch = value.match(/^(-?\d+(\.\d+)?)px$/);
|
|
84
|
+
if (pixelMatch)
|
|
85
|
+
value = parseFloat(pixelMatch[1]);
|
|
86
|
+
}
|
|
87
|
+
// Handle shorthand properties
|
|
88
|
+
if (key === 'margin' || key === 'padding') {
|
|
89
|
+
return { ...acc, ...expandShorthand(key, value) };
|
|
90
|
+
}
|
|
91
|
+
// Convert 'background' to 'backgroundColor'
|
|
92
|
+
if (key === 'background' && typeof value === 'string') {
|
|
93
|
+
acc.backgroundColor = value;
|
|
94
|
+
return { ...acc, backgroundColor: value };
|
|
95
|
+
}
|
|
96
|
+
// Handle borderRadius
|
|
97
|
+
if (key === 'borderRadius' && typeof value === 'string') {
|
|
98
|
+
return { ...acc, ...expandBorderRadius(value) };
|
|
99
|
+
}
|
|
100
|
+
// Handle invalid display values
|
|
101
|
+
if (key === 'display' && value !== 'flex' && value !== 'none') {
|
|
102
|
+
return acc;
|
|
103
|
+
}
|
|
104
|
+
// Validate and add the property
|
|
105
|
+
if (validateReactNativeCssProperty(key, value)) {
|
|
106
|
+
acc[key] = value;
|
|
107
|
+
}
|
|
108
|
+
return acc;
|
|
109
|
+
}, {});
|
|
110
|
+
}
|
|
111
|
+
exports.cleanReactNativeBlockStyles = cleanReactNativeBlockStyles;
|
|
112
|
+
function expandShorthand(property, value) {
|
|
113
|
+
if (typeof value !== 'string')
|
|
114
|
+
return { [property]: value };
|
|
115
|
+
const values = value.split(' ').map((v) => parseFloat(v) || 0);
|
|
116
|
+
const [top, right = top, bottom = top, left = right] = values;
|
|
117
|
+
return {
|
|
118
|
+
[`${property}Top`]: top,
|
|
119
|
+
[`${property}Right`]: right,
|
|
120
|
+
[`${property}Bottom`]: bottom,
|
|
121
|
+
[`${property}Left`]: left,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function expandBorderRadius(value) {
|
|
125
|
+
const values = value.split(' ').map((v) => parseInt(v, 10));
|
|
126
|
+
const [topLeft, topRight = topLeft, bottomRight = topLeft, bottomLeft = topRight] = values;
|
|
127
|
+
return {
|
|
128
|
+
borderTopLeftRadius: topLeft,
|
|
129
|
+
borderTopRightRadius: topRight,
|
|
130
|
+
borderBottomRightRadius: bottomRight,
|
|
131
|
+
borderBottomLeftRadius: bottomLeft,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToReactNativeOptions } from '../../generators/react-native/types';
|
|
2
|
+
import { ClassStyleMap } from '../../helpers/styles/helpers';
|
|
3
|
+
import { MitosisComponent } from '../../types/mitosis-component';
|
|
4
|
+
import { TranspilerGenerator } from '../../types/transpiler';
|
|
5
|
+
import { ToReactOptions } from '../react';
|
|
6
|
+
export declare const collectReactNativeStyles: (json: MitosisComponent, options: ToReactOptions) => ClassStyleMap;
|
|
7
|
+
export declare const componentToReactNative: TranspilerGenerator<Partial<ToReactNativeOptions>>;
|
|
8
|
+
export * from './types';
|