@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,418 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.jsxElementToJson = void 0;
|
|
30
|
+
const babel = __importStar(require("@babel/core"));
|
|
31
|
+
const generator_1 = __importDefault(require("@babel/generator"));
|
|
32
|
+
const function_1 = require("fp-ts/lib/function");
|
|
33
|
+
const json5_1 = __importDefault(require("json5"));
|
|
34
|
+
const bindings_1 = require("../../helpers/bindings");
|
|
35
|
+
const create_mitosis_node_1 = require("../../helpers/create-mitosis-node");
|
|
36
|
+
const nullable_1 = require("../../helpers/nullable");
|
|
37
|
+
const helpers_1 = require("./helpers");
|
|
38
|
+
const { types } = babel;
|
|
39
|
+
const getBodyExpression = (node) => {
|
|
40
|
+
if (types.isArrowFunctionExpression(node) || types.isFunctionExpression(node)) {
|
|
41
|
+
const callback = node.body;
|
|
42
|
+
if (callback.type === 'BlockStatement') {
|
|
43
|
+
for (const statement of callback.body) {
|
|
44
|
+
if (statement.type === 'ReturnStatement') {
|
|
45
|
+
return statement.argument;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return callback;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
};
|
|
55
|
+
const getForArguments = (params) => {
|
|
56
|
+
const [forName, indexName, collectionName] = params
|
|
57
|
+
.filter((param) => types.isIdentifier(param))
|
|
58
|
+
.map((param) => param.name)
|
|
59
|
+
.filter(nullable_1.checkIsDefined);
|
|
60
|
+
return {
|
|
61
|
+
forName,
|
|
62
|
+
collectionName,
|
|
63
|
+
indexName,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Parses a JSX element into a MitosisNode.
|
|
68
|
+
*/
|
|
69
|
+
const jsxElementToJson = (node, options) => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (types.isJSXText(node)) {
|
|
72
|
+
const value = typeof ((_a = node.extra) === null || _a === void 0 ? void 0 : _a.raw) === 'string' ? node.extra.raw : node.value;
|
|
73
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
74
|
+
properties: {
|
|
75
|
+
_text: value,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (types.isJSXEmptyExpression(node)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (types.isJSXExpressionContainer(node)) {
|
|
83
|
+
return (0, exports.jsxElementToJson)(node.expression, options);
|
|
84
|
+
}
|
|
85
|
+
if ((types.isCallExpression(node) || types.isOptionalCallExpression(node)) &&
|
|
86
|
+
(node.callee.type === 'MemberExpression' || node.callee.type === 'OptionalMemberExpression')) {
|
|
87
|
+
const isMap = node.callee.property.type === 'Identifier' && node.callee.property.name === 'map';
|
|
88
|
+
const isArrayFrom = node.callee.property.type === 'Identifier' &&
|
|
89
|
+
node.callee.property.name === 'from' &&
|
|
90
|
+
node.callee.object.type === 'Identifier' &&
|
|
91
|
+
node.callee.object.name === 'Array';
|
|
92
|
+
if (isMap) {
|
|
93
|
+
const callback = node.arguments[0];
|
|
94
|
+
const bodyExpression = getBodyExpression(callback);
|
|
95
|
+
if (bodyExpression) {
|
|
96
|
+
const forArguments = getForArguments(callback.params);
|
|
97
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
98
|
+
name: 'For',
|
|
99
|
+
bindings: {
|
|
100
|
+
each: (0, bindings_1.createSingleBinding)({
|
|
101
|
+
code: (0, generator_1.default)(node.callee.object, {
|
|
102
|
+
compact: true,
|
|
103
|
+
}).code,
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
scope: forArguments,
|
|
107
|
+
children: [(0, exports.jsxElementToJson)(bodyExpression, options)].filter(nullable_1.checkIsDefined),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (isArrayFrom) {
|
|
112
|
+
// Array.from
|
|
113
|
+
const each = node.arguments[0];
|
|
114
|
+
const callback = node.arguments[1];
|
|
115
|
+
const bodyExpression = getBodyExpression(callback);
|
|
116
|
+
if (bodyExpression) {
|
|
117
|
+
const forArguments = getForArguments(callback.params);
|
|
118
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
119
|
+
name: 'For',
|
|
120
|
+
bindings: {
|
|
121
|
+
each: (0, bindings_1.createSingleBinding)({
|
|
122
|
+
code: (0, generator_1.default)({
|
|
123
|
+
...node,
|
|
124
|
+
arguments: [each],
|
|
125
|
+
}, {
|
|
126
|
+
compact: true,
|
|
127
|
+
}).code,
|
|
128
|
+
}),
|
|
129
|
+
},
|
|
130
|
+
scope: forArguments,
|
|
131
|
+
children: [(0, exports.jsxElementToJson)(bodyExpression, options)],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else if (types.isLogicalExpression(node)) {
|
|
137
|
+
// {foo && <div />} -> <Show when={foo}>...</Show>
|
|
138
|
+
if (node.operator === '&&') {
|
|
139
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
140
|
+
name: 'Show',
|
|
141
|
+
bindings: {
|
|
142
|
+
when: (0, bindings_1.createSingleBinding)({
|
|
143
|
+
code: (0, generator_1.default)(node.left, {
|
|
144
|
+
compact: true,
|
|
145
|
+
}).code,
|
|
146
|
+
}),
|
|
147
|
+
},
|
|
148
|
+
children: [(0, exports.jsxElementToJson)(node.right, options)].filter(nullable_1.checkIsDefined),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// TODO: good warning system for unsupported operators
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (types.isConditionalExpression(node)) {
|
|
156
|
+
// {foo ? <div /> : <span />} -> <Show when={foo} else={<span />}>...</Show>
|
|
157
|
+
const child = (0, exports.jsxElementToJson)(node.consequent, options);
|
|
158
|
+
const elseCase = (0, exports.jsxElementToJson)(node.alternate, options);
|
|
159
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
160
|
+
name: 'Show',
|
|
161
|
+
meta: {
|
|
162
|
+
...((0, nullable_1.checkIsDefined)(elseCase) ? { else: elseCase } : undefined),
|
|
163
|
+
},
|
|
164
|
+
bindings: {
|
|
165
|
+
when: (0, bindings_1.createSingleBinding)({ code: (0, generator_1.default)(node.test, { compact: true }).code }),
|
|
166
|
+
},
|
|
167
|
+
children: child === null ? [] : [child],
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else if (types.isJSXFragment(node)) {
|
|
171
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
172
|
+
name: 'Fragment',
|
|
173
|
+
children: node.children
|
|
174
|
+
.map((child) => (0, exports.jsxElementToJson)(child, options))
|
|
175
|
+
.filter(nullable_1.checkIsDefined),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
else if (types.isJSXSpreadChild(node)) {
|
|
179
|
+
// TODO: support spread attributes
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
else if (types.isNullLiteral(node) || types.isBooleanLiteral(node)) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
else if (types.isNumericLiteral(node)) {
|
|
186
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
187
|
+
properties: {
|
|
188
|
+
_text: String(node.value),
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
else if (types.isStringLiteral(node)) {
|
|
193
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
194
|
+
properties: {
|
|
195
|
+
_text: node.value,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
if (!types.isJSXElement(node)) {
|
|
200
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
201
|
+
bindings: {
|
|
202
|
+
_text: (0, bindings_1.createSingleBinding)({ code: (0, generator_1.default)(node, { compact: true }).code }),
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
const nodeName = (0, generator_1.default)(node.openingElement.name).code;
|
|
207
|
+
if (nodeName === 'Show') {
|
|
208
|
+
const whenAttr = node.openingElement.attributes.find((item) => types.isJSXAttribute(item) && item.name.name === 'when');
|
|
209
|
+
const elseAttr = node.openingElement.attributes.find((item) => types.isJSXAttribute(item) && item.name.name === 'else');
|
|
210
|
+
const whenValue = whenAttr && types.isJSXExpressionContainer(whenAttr.value)
|
|
211
|
+
? (0, generator_1.default)(whenAttr.value.expression, { compact: true }).code
|
|
212
|
+
: undefined;
|
|
213
|
+
const elseValue = elseAttr &&
|
|
214
|
+
types.isJSXExpressionContainer(elseAttr.value) &&
|
|
215
|
+
(0, exports.jsxElementToJson)(elseAttr.value.expression, options);
|
|
216
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
217
|
+
name: 'Show',
|
|
218
|
+
meta: {
|
|
219
|
+
else: elseValue || undefined,
|
|
220
|
+
},
|
|
221
|
+
bindings: {
|
|
222
|
+
...(whenValue ? { when: (0, bindings_1.createSingleBinding)({ code: whenValue }) } : {}),
|
|
223
|
+
},
|
|
224
|
+
children: node.children
|
|
225
|
+
.map((child) => (0, exports.jsxElementToJson)(child, options))
|
|
226
|
+
.filter(nullable_1.checkIsDefined),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
// <For ...> control flow component
|
|
230
|
+
if (nodeName === 'For') {
|
|
231
|
+
const child = node.children.find((item) => types.isJSXExpressionContainer(item));
|
|
232
|
+
if ((0, nullable_1.checkIsDefined)(child)) {
|
|
233
|
+
const childExpression = child.expression;
|
|
234
|
+
if (types.isArrowFunctionExpression(childExpression)) {
|
|
235
|
+
const forArguments = getForArguments(childExpression === null || childExpression === void 0 ? void 0 : childExpression.params);
|
|
236
|
+
const forCode = (0, function_1.pipe)(node.openingElement.attributes[0], (attr) => {
|
|
237
|
+
if (types.isJSXAttribute(attr) && types.isJSXExpressionContainer(attr.value)) {
|
|
238
|
+
return (0, generator_1.default)(attr.value.expression, { compact: true }).code;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// TO-DO: is an empty string valid here?
|
|
242
|
+
return '';
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
246
|
+
name: 'For',
|
|
247
|
+
bindings: {
|
|
248
|
+
each: (0, bindings_1.createSingleBinding)({
|
|
249
|
+
code: forCode,
|
|
250
|
+
}),
|
|
251
|
+
},
|
|
252
|
+
scope: forArguments,
|
|
253
|
+
children: [(0, exports.jsxElementToJson)(childExpression.body, options)],
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// const properties: MitosisNode['properties'] = {}
|
|
259
|
+
// const bindings: MitosisNode['bindings'] = {}
|
|
260
|
+
// const slots: MitosisNode['slots'] = {}
|
|
261
|
+
const { bindings, properties, slots, blocksSlots } = node.openingElement.attributes.reduce((memo, item) => {
|
|
262
|
+
if (types.isJSXAttribute(item)) {
|
|
263
|
+
const key = (0, helpers_1.transformAttributeName)(item.name.name);
|
|
264
|
+
const value = item.value;
|
|
265
|
+
// <Foo myProp />
|
|
266
|
+
if (value === null) {
|
|
267
|
+
memo.bindings[key] = (0, bindings_1.createSingleBinding)({ code: 'true' });
|
|
268
|
+
return memo;
|
|
269
|
+
}
|
|
270
|
+
// <Foo myProp="hello" />
|
|
271
|
+
if (types.isStringLiteral(value)) {
|
|
272
|
+
memo.properties[key] = value.value;
|
|
273
|
+
return memo;
|
|
274
|
+
}
|
|
275
|
+
if (!types.isJSXExpressionContainer(value))
|
|
276
|
+
return memo;
|
|
277
|
+
const { expression } = value;
|
|
278
|
+
if (types.isStringLiteral(expression)) {
|
|
279
|
+
// <Foo myProp={"hello"} />
|
|
280
|
+
memo.properties[key] = expression.value;
|
|
281
|
+
}
|
|
282
|
+
else if (key.startsWith('on') && types.isArrowFunctionExpression(expression)) {
|
|
283
|
+
// <Foo myProp={() => {}} />
|
|
284
|
+
const args = expression.params.map((node) => node === null || node === void 0 ? void 0 : node.name);
|
|
285
|
+
memo.bindings[key] = (0, bindings_1.createSingleBinding)({
|
|
286
|
+
code: (0, generator_1.default)(expression.body, { compact: true }).code,
|
|
287
|
+
async: expression.async === true ? true : undefined,
|
|
288
|
+
arguments: args.length ? args : undefined,
|
|
289
|
+
bindingType: 'function',
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
else if (/^on[A-Z]/.test(key) && types.isExpression(expression)) {
|
|
293
|
+
// regex ignores props that happen to start with "on" but are not handlers
|
|
294
|
+
// <Foo onClick={state.handler} />
|
|
295
|
+
const call = types.callExpression(expression, []);
|
|
296
|
+
memo.bindings[key] = (0, bindings_1.createSingleBinding)({
|
|
297
|
+
code: (0, generator_1.default)(call, { compact: true }).code,
|
|
298
|
+
bindingType: 'function',
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
else if (types.isJSXElement(expression) || types.isJSXFragment(expression)) {
|
|
302
|
+
// <Foo myProp={<MoreMitosisNode><div /></MoreMitosisNode>} />
|
|
303
|
+
// <Foo myProp={<><Node /><Node /></>} />
|
|
304
|
+
const slotNode = (0, exports.jsxElementToJson)(expression, options);
|
|
305
|
+
if (!slotNode)
|
|
306
|
+
return memo;
|
|
307
|
+
memo.slots[key] = [slotNode];
|
|
308
|
+
// Temporarily keep the slot as a binding until we migrate generators to use the slots.
|
|
309
|
+
memo.bindings[key] = (0, bindings_1.createSingleBinding)({
|
|
310
|
+
code: (0, generator_1.default)(expression, { compact: true }).code,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
if (options.enableBlocksSlots &&
|
|
315
|
+
(types.isArrayExpression(expression) || types.isObjectExpression(expression))) {
|
|
316
|
+
/**
|
|
317
|
+
* Find any deeply nested JSX Elements, convert them to Mitosis nodes
|
|
318
|
+
* then store them in "replacements" to later do a string substitution
|
|
319
|
+
* to swap out the stringified JSX with stringified Mitosis nodes.
|
|
320
|
+
*
|
|
321
|
+
* Object expressions need to wrapped in an expression statement (e.g. `({... })`)
|
|
322
|
+
* otherwise Babel generate will fail.
|
|
323
|
+
*/
|
|
324
|
+
const code = types.isObjectExpression(expression)
|
|
325
|
+
? (0, generator_1.default)(types.expressionStatement(expression)).code
|
|
326
|
+
: (0, generator_1.default)(expression).code;
|
|
327
|
+
const replacements = [];
|
|
328
|
+
(0, helpers_1.babelDefaultTransform)(code, {
|
|
329
|
+
JSXElement(path) {
|
|
330
|
+
const { start, end } = path.node;
|
|
331
|
+
if (start == null || end == null) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const node = (0, exports.jsxElementToJson)(path.node, options);
|
|
335
|
+
if (!node)
|
|
336
|
+
return;
|
|
337
|
+
/**
|
|
338
|
+
* Perform replacements in the reverse order in which we saw them
|
|
339
|
+
* otherwise start/end indices will quickly become incorrect.
|
|
340
|
+
*/
|
|
341
|
+
replacements.unshift({
|
|
342
|
+
start,
|
|
343
|
+
end,
|
|
344
|
+
node,
|
|
345
|
+
});
|
|
346
|
+
/**
|
|
347
|
+
* babelTransform will keep iterating into deeper nodes. However,
|
|
348
|
+
* the "jsxElementToJson" call above will handle deeper nodes.
|
|
349
|
+
* Replace the path will null so we do not accidentally process
|
|
350
|
+
* child nodes multiple times.
|
|
351
|
+
*/
|
|
352
|
+
path.replaceWith(types.nullLiteral());
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
// If no replacements then this is just a regular binding
|
|
356
|
+
if (replacements.length > 0) {
|
|
357
|
+
// Replace stringified JSX (e.g. <Foo></Foo>) with stringified Mitosis JSON
|
|
358
|
+
let replacedCode = code;
|
|
359
|
+
replacements.forEach(({ start, end, node }) => {
|
|
360
|
+
replacedCode =
|
|
361
|
+
replacedCode.substring(0, start) +
|
|
362
|
+
JSON.stringify(node) +
|
|
363
|
+
replacedCode.substring(end);
|
|
364
|
+
});
|
|
365
|
+
let finalCode = replacedCode;
|
|
366
|
+
if (types.isObjectExpression(expression)) {
|
|
367
|
+
/**
|
|
368
|
+
* Remove the ( and ); surrounding the expression because we just want
|
|
369
|
+
* a valid JS object instead.
|
|
370
|
+
*/
|
|
371
|
+
const match = replacedCode.match(/\(([\s\S]*?)\);/);
|
|
372
|
+
if (match) {
|
|
373
|
+
finalCode = match[1];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* The result should be a valid array of objects. Use json5 to parse
|
|
378
|
+
* as not every key will be wrapped in quotes, so a normal JSON.parse
|
|
379
|
+
* will fail.
|
|
380
|
+
*/
|
|
381
|
+
memo.blocksSlots[key] = json5_1.default.parse(finalCode);
|
|
382
|
+
return memo;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
memo.bindings[key] = (0, bindings_1.createSingleBinding)({
|
|
386
|
+
code: (0, generator_1.default)(expression, { compact: true }).code,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return memo;
|
|
390
|
+
}
|
|
391
|
+
else if (types.isJSXSpreadAttribute(item)) {
|
|
392
|
+
// TODO: potentially like Vue store bindings and properties as array of key value pairs
|
|
393
|
+
// too so can do this accurately when order matters. Also tempting to not support spread,
|
|
394
|
+
// as some frameworks do not support it (e.g. Angular) tho Angular may be the only one
|
|
395
|
+
const { code: key } = (0, generator_1.default)(item.argument, { compact: true });
|
|
396
|
+
memo.bindings[key] = {
|
|
397
|
+
code: types.stringLiteral((0, generator_1.default)(item.argument, { compact: true }).code).value,
|
|
398
|
+
type: 'spread',
|
|
399
|
+
spreadType: 'normal',
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
return memo;
|
|
403
|
+
}, {
|
|
404
|
+
bindings: {},
|
|
405
|
+
properties: {},
|
|
406
|
+
slots: {},
|
|
407
|
+
blocksSlots: {},
|
|
408
|
+
});
|
|
409
|
+
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
410
|
+
name: nodeName,
|
|
411
|
+
properties,
|
|
412
|
+
bindings,
|
|
413
|
+
children: node.children.map((child) => (0, exports.jsxElementToJson)(child, options)).filter(nullable_1.checkIsDefined),
|
|
414
|
+
slots: Object.keys(slots).length > 0 ? slots : undefined,
|
|
415
|
+
blocksSlots: Object.keys(blocksSlots).length > 0 ? blocksSlots : undefined,
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
exports.jsxElementToJson = jsxElementToJson;
|
|
@@ -0,0 +1,76 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.generateExports = void 0;
|
|
30
|
+
const babel = __importStar(require("@babel/core"));
|
|
31
|
+
const generator_1 = __importDefault(require("@babel/generator"));
|
|
32
|
+
const component_types_1 = require("./component-types");
|
|
33
|
+
const helpers_1 = require("./helpers");
|
|
34
|
+
const { types } = babel;
|
|
35
|
+
const generateExports = (path) => {
|
|
36
|
+
const exportsOrLocalVariables = path.node.body.filter((statement) => !(0, helpers_1.isImportOrDefaultExport)(statement) &&
|
|
37
|
+
!(0, component_types_1.isTypeOrInterface)(statement) &&
|
|
38
|
+
!types.isExpressionStatement(statement));
|
|
39
|
+
return exportsOrLocalVariables.reduce((pre, node) => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
let name, isFunction;
|
|
42
|
+
if (babel.types.isExportNamedDeclaration(node)) {
|
|
43
|
+
if (babel.types.isVariableDeclaration(node.declaration) &&
|
|
44
|
+
babel.types.isIdentifier(node.declaration.declarations[0].id)) {
|
|
45
|
+
name = node.declaration.declarations[0].id.name;
|
|
46
|
+
isFunction = babel.types.isFunction(node.declaration.declarations[0].init);
|
|
47
|
+
}
|
|
48
|
+
if (babel.types.isFunctionDeclaration(node.declaration)) {
|
|
49
|
+
name = (_a = node.declaration.id) === null || _a === void 0 ? void 0 : _a.name;
|
|
50
|
+
isFunction = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (babel.types.isVariableDeclaration(node) &&
|
|
55
|
+
babel.types.isIdentifier(node.declarations[0].id)) {
|
|
56
|
+
name = node.declarations[0].id.name;
|
|
57
|
+
isFunction = babel.types.isFunction(node.declarations[0].init);
|
|
58
|
+
}
|
|
59
|
+
if (babel.types.isFunctionDeclaration(node)) {
|
|
60
|
+
name = (_b = node.id) === null || _b === void 0 ? void 0 : _b.name;
|
|
61
|
+
isFunction = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (name) {
|
|
65
|
+
pre[name] = {
|
|
66
|
+
code: (0, generator_1.default)(node).code,
|
|
67
|
+
isFunction,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.warn('Could not parse export or variable: ignoring node', node);
|
|
72
|
+
}
|
|
73
|
+
return pre;
|
|
74
|
+
}, {});
|
|
75
|
+
};
|
|
76
|
+
exports.generateExports = generateExports;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as babel from '@babel/core';
|
|
2
|
+
import { JSONOrNode } from '../../types/json';
|
|
3
|
+
import type { Context, ParseMitosisOptions } from './types';
|
|
4
|
+
declare const types: typeof babel.types;
|
|
5
|
+
/**
|
|
6
|
+
* Parses function declarations within the Mitosis copmonent's body to JSON
|
|
7
|
+
*/
|
|
8
|
+
export declare const componentFunctionToJson: (node: babel.types.FunctionDeclaration, context: Context, stateToScope: string[], options: Partial<ParseMitosisOptions>) => JSONOrNode;
|
|
9
|
+
export {};
|