@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,64 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.undoPropsDestructure = void 0;
|
|
27
|
+
const babel = __importStar(require("@babel/core"));
|
|
28
|
+
const { types } = babel;
|
|
29
|
+
function undoPropsDestructure(path) {
|
|
30
|
+
const { node } = path;
|
|
31
|
+
if (node.params.length && types.isObjectPattern(node.params[0])) {
|
|
32
|
+
const param = node.params[0];
|
|
33
|
+
const propsMap = param.properties.reduce((pre, cur) => {
|
|
34
|
+
if (types.isObjectProperty(cur) &&
|
|
35
|
+
types.isIdentifier(cur.key) &&
|
|
36
|
+
types.isIdentifier(cur.value)) {
|
|
37
|
+
pre[cur.value.name] = `props.${cur.key.name}`;
|
|
38
|
+
return pre;
|
|
39
|
+
}
|
|
40
|
+
return pre;
|
|
41
|
+
}, {});
|
|
42
|
+
if (param.typeAnnotation) {
|
|
43
|
+
node.params = [
|
|
44
|
+
{
|
|
45
|
+
...babel.types.identifier('props'),
|
|
46
|
+
typeAnnotation: param.typeAnnotation,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
path.replaceWith(node);
|
|
50
|
+
}
|
|
51
|
+
path.traverse({
|
|
52
|
+
JSXExpressionContainer(path) {
|
|
53
|
+
const { node } = path;
|
|
54
|
+
if (types.isIdentifier(node.expression)) {
|
|
55
|
+
const { name } = node.expression;
|
|
56
|
+
if (propsMap[name]) {
|
|
57
|
+
path.replaceWith(babel.types.jsxExpressionContainer(babel.types.identifier(propsMap[name])));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.undoPropsDestructure = undoPropsDestructure;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findSignals = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const typescript_project_1 = require("../../helpers/typescript-project");
|
|
6
|
+
const MITOSIS_IMPORT_PATHS = [
|
|
7
|
+
// actual production path
|
|
8
|
+
'/node_modules/@builder.io/mitosis/',
|
|
9
|
+
// possible path if symlinking mitosis locally
|
|
10
|
+
'/mitosis/packages/core/',
|
|
11
|
+
];
|
|
12
|
+
const findSignals = ({ filePath, project }) => {
|
|
13
|
+
const ast = project.getSourceFileOrThrow(filePath);
|
|
14
|
+
if (ast === undefined) {
|
|
15
|
+
throw new Error('Could not find AST. Please provide a correct `filePath`.');
|
|
16
|
+
}
|
|
17
|
+
const reactiveValues = {
|
|
18
|
+
props: new Set(),
|
|
19
|
+
state: new Set(),
|
|
20
|
+
context: new Set(),
|
|
21
|
+
};
|
|
22
|
+
const propsSymbol = (0, typescript_project_1.getPropsSymbol)(ast);
|
|
23
|
+
const contextSymbols = (0, typescript_project_1.getContextSymbols)(ast);
|
|
24
|
+
const checkIsSignalSymbol = (type) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const symbol = (_a = type.getTargetType()) === null || _a === void 0 ? void 0 : _a.getAliasSymbol();
|
|
27
|
+
if (!symbol || symbol.getName() !== 'Signal')
|
|
28
|
+
return false;
|
|
29
|
+
const compilerSymbol = symbol === null || symbol === void 0 ? void 0 : symbol.compilerSymbol;
|
|
30
|
+
const parent = compilerSymbol.parent;
|
|
31
|
+
if (!parent)
|
|
32
|
+
return false;
|
|
33
|
+
if (MITOSIS_IMPORT_PATHS.some((path) => parent.getName().includes(path))) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
};
|
|
38
|
+
const checkIsOptionalSignal = (node) => {
|
|
39
|
+
let hasUndefined = false;
|
|
40
|
+
let hasSignal = false;
|
|
41
|
+
const perfectMatch = node
|
|
42
|
+
.getType()
|
|
43
|
+
.getUnionTypes()
|
|
44
|
+
.every((type) => {
|
|
45
|
+
if (type.isUndefined()) {
|
|
46
|
+
hasUndefined = true;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
else if (checkIsSignalSymbol(type)) {
|
|
50
|
+
hasSignal = true;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
});
|
|
55
|
+
return perfectMatch && hasUndefined && hasSignal;
|
|
56
|
+
};
|
|
57
|
+
ast.forEachDescendant((parentNode) => {
|
|
58
|
+
if (ts_morph_1.Node.isPropertyAccessExpression(parentNode)) {
|
|
59
|
+
const node = parentNode.getExpression();
|
|
60
|
+
const isOptionalAccess = parentNode.hasQuestionDotToken();
|
|
61
|
+
const isSignal = isOptionalAccess
|
|
62
|
+
? checkIsOptionalSignal(node)
|
|
63
|
+
: checkIsSignalSymbol(node.getType());
|
|
64
|
+
if (!isSignal)
|
|
65
|
+
return;
|
|
66
|
+
let isInsideType = false;
|
|
67
|
+
let isInsideDeclaration = false;
|
|
68
|
+
node.getParentWhile((parent, child) => {
|
|
69
|
+
// stop once we hit the function block
|
|
70
|
+
if (ts_morph_1.Node.isBlock(child) || ts_morph_1.Node.isBlock(parent)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
// crawl up parents to make sure we're not inside a type
|
|
74
|
+
if (ts_morph_1.Node.isTypeNode(parent) || ts_morph_1.Node.isTypeAliasDeclaration(parent)) {
|
|
75
|
+
isInsideType = true;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
});
|
|
80
|
+
if (isInsideType)
|
|
81
|
+
return;
|
|
82
|
+
if (isInsideDeclaration)
|
|
83
|
+
return;
|
|
84
|
+
const nodeSymbol = node.getSymbol();
|
|
85
|
+
if (ts_morph_1.Node.isPropertyAccessExpression(node) &&
|
|
86
|
+
node.getExpression().getSymbol() === propsSymbol) {
|
|
87
|
+
reactiveValues.props.add(node.getNameNode().getText());
|
|
88
|
+
}
|
|
89
|
+
else if (nodeSymbol && contextSymbols.has(nodeSymbol)) {
|
|
90
|
+
reactiveValues.context.add(node.getText());
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
reactiveValues.state.add(node.getText());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return reactiveValues;
|
|
98
|
+
};
|
|
99
|
+
exports.findSignals = findSignals;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MitosisComponent, MitosisState } from '../../types/mitosis-component';
|
|
2
|
+
import { ObjectExpression } from '@babel/types';
|
|
3
|
+
/**
|
|
4
|
+
* Convert state identifiers from React hooks format to the state.* format Mitosis needs
|
|
5
|
+
* e.g.
|
|
6
|
+
* text -> state.text
|
|
7
|
+
* setText(...) -> state.text = ...
|
|
8
|
+
*
|
|
9
|
+
* This also applies to components that use both useState and useStore.
|
|
10
|
+
* e.g.
|
|
11
|
+
* const [foo, setFoo] = useState(1)
|
|
12
|
+
* const store = useStore({
|
|
13
|
+
* bar() { return foo } // becomes bar() { return state.foo }
|
|
14
|
+
* })`
|
|
15
|
+
*/
|
|
16
|
+
export declare function mapStateIdentifiers(json: MitosisComponent, stateProperties: string[]): void;
|
|
17
|
+
export declare const parseStateObjectToMitosisState: (object: ObjectExpression, isState?: boolean) => MitosisState;
|
|
@@ -0,0 +1,274 @@
|
|
|
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.parseStateObjectToMitosisState = exports.mapStateIdentifiers = void 0;
|
|
7
|
+
const babel_transform_1 = require("../../helpers/babel-transform");
|
|
8
|
+
const capitalize_1 = require("../../helpers/capitalize");
|
|
9
|
+
const is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
|
|
10
|
+
const process_code_1 = require("../../helpers/plugins/process-code");
|
|
11
|
+
const replace_identifiers_1 = require("../../helpers/replace-identifiers");
|
|
12
|
+
const core_1 = require("@babel/core");
|
|
13
|
+
const types_1 = require("@babel/types");
|
|
14
|
+
const function_1 = require("fp-ts/lib/function");
|
|
15
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
16
|
+
const helpers_1 = require("./helpers");
|
|
17
|
+
function mapStateIdentifiersInExpression(expression, stateProperties) {
|
|
18
|
+
const setExpressions = stateProperties.map((propertyName) => `set${(0, capitalize_1.capitalize)(propertyName)}`);
|
|
19
|
+
return (0, function_1.pipe)((0, babel_transform_1.babelTransformExpression)(expression, {
|
|
20
|
+
Identifier(path) {
|
|
21
|
+
if (stateProperties.includes(path.node.name)) {
|
|
22
|
+
if (
|
|
23
|
+
// ignore member expressions, as the `stateProperty` is going to be at the module scope.
|
|
24
|
+
!((0, types_1.isMemberExpression)(path.parent) && path.parent.property === path.node) &&
|
|
25
|
+
!((0, types_1.isOptionalMemberExpression)(path.parent) && path.parent.property === path.node) &&
|
|
26
|
+
// ignore declarations of that state property, e.g. `function foo() {}`
|
|
27
|
+
!(0, types_1.isDeclaration)(path.parent) &&
|
|
28
|
+
!(0, types_1.isFunctionDeclaration)(path.parent) &&
|
|
29
|
+
!((0, types_1.isFunctionExpression)(path.parent) && path.parent.id === path.node) &&
|
|
30
|
+
// ignore object keys
|
|
31
|
+
!((0, types_1.isObjectProperty)(path.parent) && path.parent.key === path.node)) {
|
|
32
|
+
let hasTypeParent = false;
|
|
33
|
+
path.findParent((parent) => {
|
|
34
|
+
if ((0, types_1.isTSType)(parent) || (0, types_1.isTSInterfaceBody)(parent)) {
|
|
35
|
+
hasTypeParent = true;
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
});
|
|
40
|
+
if (hasTypeParent) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const newExpression = (0, types_1.memberExpression)((0, types_1.identifier)('state'), (0, types_1.identifier)(path.node.name));
|
|
44
|
+
try {
|
|
45
|
+
path.replaceWith(newExpression);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.error(err);
|
|
49
|
+
// console.log('err: ', {
|
|
50
|
+
// from: generate(path.parent).code,
|
|
51
|
+
// fromChild: generate(path.node).code,
|
|
52
|
+
// to: newExpression,
|
|
53
|
+
// // err,
|
|
54
|
+
// });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
CallExpression(path) {
|
|
60
|
+
if ((0, types_1.isIdentifier)(path.node.callee)) {
|
|
61
|
+
if (setExpressions.includes(path.node.callee.name)) {
|
|
62
|
+
// setFoo -> foo
|
|
63
|
+
const statePropertyName = (0, helpers_1.uncapitalize)(path.node.callee.name.slice(3));
|
|
64
|
+
// setFoo(...) -> state.foo = ...
|
|
65
|
+
path.replaceWith((0, types_1.assignmentExpression)('=', (0, types_1.identifier)(`state.${statePropertyName}`), path.node.arguments[0]));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
}), (code) => code.trim());
|
|
70
|
+
}
|
|
71
|
+
const consolidateClassBindings = (item) => {
|
|
72
|
+
if (item.bindings.className) {
|
|
73
|
+
if (item.bindings.class) {
|
|
74
|
+
// TO-DO: it's too much work to merge 2 bindings, so just remove the old one for now.
|
|
75
|
+
item.bindings.class = item.bindings.className;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
item.bindings.class = item.bindings.className;
|
|
79
|
+
}
|
|
80
|
+
delete item.bindings.className;
|
|
81
|
+
}
|
|
82
|
+
if (item.properties.className) {
|
|
83
|
+
if (item.properties.class) {
|
|
84
|
+
item.properties.class = `${item.properties.class} ${item.properties.className}`;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
item.properties.class = item.properties.className;
|
|
88
|
+
}
|
|
89
|
+
delete item.properties.className;
|
|
90
|
+
}
|
|
91
|
+
if (item.properties.class && item.bindings.class) {
|
|
92
|
+
console.warn(`[${item.name}]: Ended up with both a property and binding for 'class'.`);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Convert state identifiers from React hooks format to the state.* format Mitosis needs
|
|
97
|
+
* e.g.
|
|
98
|
+
* text -> state.text
|
|
99
|
+
* setText(...) -> state.text = ...
|
|
100
|
+
*
|
|
101
|
+
* This also applies to components that use both useState and useStore.
|
|
102
|
+
* e.g.
|
|
103
|
+
* const [foo, setFoo] = useState(1)
|
|
104
|
+
* const store = useStore({
|
|
105
|
+
* bar() { return foo } // becomes bar() { return state.foo }
|
|
106
|
+
* })`
|
|
107
|
+
*/
|
|
108
|
+
function mapStateIdentifiers(json, stateProperties) {
|
|
109
|
+
const plugin = (0, process_code_1.createCodeProcessorPlugin)(() => (code) => mapStateIdentifiersInExpression(code, stateProperties));
|
|
110
|
+
plugin(json);
|
|
111
|
+
for (const key in json.targetBlocks) {
|
|
112
|
+
const targetBlock = json.targetBlocks[key];
|
|
113
|
+
for (const targetBlockKey of Object.keys(targetBlock)) {
|
|
114
|
+
const block = targetBlock[targetBlockKey];
|
|
115
|
+
if (block && 'code' in block) {
|
|
116
|
+
block.code = mapStateIdentifiersInExpression(block.code, stateProperties);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
(0, legacy_1.default)(json).forEach(function (item) {
|
|
121
|
+
// only consolidate bindings for HTML tags, not custom components
|
|
122
|
+
// custom components are always PascalCase, e.g. MyComponent
|
|
123
|
+
// but HTML tags are lowercase, e.g. div
|
|
124
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item) && item.name.toLowerCase() === item.name) {
|
|
125
|
+
consolidateClassBindings(item);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
exports.mapStateIdentifiers = mapStateIdentifiers;
|
|
130
|
+
/**
|
|
131
|
+
* Replaces `this.` with `state.` and trims code
|
|
132
|
+
* @param code origin code
|
|
133
|
+
*/
|
|
134
|
+
const getCleanedStateCode = (code) => {
|
|
135
|
+
return (0, replace_identifiers_1.replaceNodes)({
|
|
136
|
+
code,
|
|
137
|
+
nodeMaps: [
|
|
138
|
+
{
|
|
139
|
+
from: core_1.types.thisExpression(),
|
|
140
|
+
to: core_1.types.identifier('state'),
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
}).trim();
|
|
144
|
+
};
|
|
145
|
+
const processStateObjectSlice = (item) => {
|
|
146
|
+
if ((0, types_1.isObjectProperty)(item)) {
|
|
147
|
+
if ((0, types_1.isFunctionExpression)(item.value)) {
|
|
148
|
+
return {
|
|
149
|
+
code: getCleanedStateCode((0, helpers_1.parseCode)(item.value)),
|
|
150
|
+
type: 'function',
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
else if ((0, types_1.isArrowFunctionExpression)(item.value)) {
|
|
154
|
+
/**
|
|
155
|
+
* Arrow functions are normally converted to object methods to work around
|
|
156
|
+
* limitations with arrow functions in state in frameworks such as Svelte.
|
|
157
|
+
* However, this conversion does not work for async arrow functions due to
|
|
158
|
+
* how we handle parsing in `handleErrorOrExpression` for parsing
|
|
159
|
+
* expressions. That code does not detect async functions in order to apply
|
|
160
|
+
* its parsing workarounds. Even if it did, it does not consider async code
|
|
161
|
+
* when prefixing with "function". This would result in "function async foo()"
|
|
162
|
+
* which is not a valid function expression definition.
|
|
163
|
+
*/
|
|
164
|
+
// TODO ENG-7256 Find a way to do this without diverging code path
|
|
165
|
+
if (item.value.async) {
|
|
166
|
+
const func = (0, types_1.functionExpression)(item.key, item.value.params, item.value.body, false, true);
|
|
167
|
+
return {
|
|
168
|
+
code: (0, helpers_1.parseCode)(func).trim(),
|
|
169
|
+
type: 'function',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const n = (0, types_1.objectMethod)('method', item.key, item.value.params, item.value.body);
|
|
173
|
+
// Replace this. with state. to handle following
|
|
174
|
+
// const state = useStore({ _do: () => {this._active = !!id;}})
|
|
175
|
+
const code = getCleanedStateCode((0, helpers_1.parseCode)(n));
|
|
176
|
+
return {
|
|
177
|
+
code: code,
|
|
178
|
+
type: 'method',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Remove typescript types, e.g. from
|
|
183
|
+
// { foo: ('string' as SomeType) }
|
|
184
|
+
if ((0, types_1.isTSAsExpression)(item.value)) {
|
|
185
|
+
return {
|
|
186
|
+
code: getCleanedStateCode((0, helpers_1.parseCode)(item.value.expression)),
|
|
187
|
+
type: 'property',
|
|
188
|
+
propertyType: 'normal',
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
code: getCleanedStateCode((0, helpers_1.parseCode)(item.value)),
|
|
193
|
+
type: 'property',
|
|
194
|
+
propertyType: 'normal',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if ((0, types_1.isObjectMethod)(item)) {
|
|
199
|
+
// TODO ENG-7256 Find a way to do this without diverging code path
|
|
200
|
+
if (item.async) {
|
|
201
|
+
const func = (0, types_1.functionExpression)(item.key, item.params, item.body, false, true);
|
|
202
|
+
return {
|
|
203
|
+
code: (0, helpers_1.parseCode)(func).trim(),
|
|
204
|
+
type: 'function',
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const method = (0, types_1.objectMethod)(item.kind, item.key, item.params, item.body, false, false, item.async);
|
|
208
|
+
const n = getCleanedStateCode((0, helpers_1.parseCode)({ ...method, returnType: null }));
|
|
209
|
+
const isGetter = item.kind === 'get';
|
|
210
|
+
return {
|
|
211
|
+
code: n,
|
|
212
|
+
type: isGetter ? 'getter' : 'method',
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
throw new Error('Unexpected state value type', item);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const processDefaultPropsSlice = (item) => {
|
|
220
|
+
if ((0, types_1.isObjectProperty)(item)) {
|
|
221
|
+
if ((0, types_1.isFunctionExpression)(item.value) || (0, types_1.isArrowFunctionExpression)(item.value)) {
|
|
222
|
+
return {
|
|
223
|
+
code: (0, helpers_1.parseCode)(item.value),
|
|
224
|
+
type: 'method',
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// Remove typescript types, e.g. from
|
|
229
|
+
// { foo: ('string' as SomeType) }
|
|
230
|
+
if ((0, types_1.isTSAsExpression)(item.value)) {
|
|
231
|
+
return {
|
|
232
|
+
code: (0, helpers_1.parseCode)(item.value.expression),
|
|
233
|
+
type: 'property',
|
|
234
|
+
propertyType: 'normal',
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
code: (0, helpers_1.parseCode)(item.value),
|
|
239
|
+
type: 'property',
|
|
240
|
+
propertyType: 'normal',
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else if ((0, types_1.isObjectMethod)(item)) {
|
|
245
|
+
const n = (0, helpers_1.parseCode)({ ...item, returnType: null });
|
|
246
|
+
const isGetter = item.kind === 'get';
|
|
247
|
+
return {
|
|
248
|
+
code: n,
|
|
249
|
+
type: isGetter ? 'getter' : 'method',
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
throw new Error('Unexpected state value type', item);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const parseStateObjectToMitosisState = (object, isState = true) => {
|
|
257
|
+
const state = {};
|
|
258
|
+
object.properties.forEach((x) => {
|
|
259
|
+
if ((0, types_1.isSpreadElement)(x)) {
|
|
260
|
+
throw new Error('Parse Error: Mitosis cannot consume spread element in state object: ' + x);
|
|
261
|
+
}
|
|
262
|
+
if ((0, types_1.isPrivateName)(x.key)) {
|
|
263
|
+
throw new Error('Parse Error: Mitosis cannot consume private name in state object: ' + x.key);
|
|
264
|
+
}
|
|
265
|
+
if (!(0, types_1.isIdentifier)(x.key) && !(0, types_1.isStringLiteral)(x.key)) {
|
|
266
|
+
throw new Error('Parse Error: Mitosis cannot consume non-identifier and non-string key in state object: ' +
|
|
267
|
+
x.key);
|
|
268
|
+
}
|
|
269
|
+
const keyName = (0, types_1.isStringLiteral)(x.key) ? x.key.value : x.key.name;
|
|
270
|
+
state[keyName] = isState ? processStateObjectSlice(x) : processDefaultPropsSlice(x);
|
|
271
|
+
});
|
|
272
|
+
return state;
|
|
273
|
+
};
|
|
274
|
+
exports.parseStateObjectToMitosisState = parseStateObjectToMitosisState;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MitosisComponent } from '../../types/mitosis-component';
|
|
2
|
+
import { Project } from 'ts-morph';
|
|
3
|
+
export type ParseMitosisOptions = {
|
|
4
|
+
jsonHookNames?: string[];
|
|
5
|
+
compileAwayPackages?: string[];
|
|
6
|
+
typescript: boolean;
|
|
7
|
+
tsProject?: {
|
|
8
|
+
project: Project;
|
|
9
|
+
};
|
|
10
|
+
filePath?: string;
|
|
11
|
+
/**
|
|
12
|
+
* When `true`, the `blocksSlots` field on Mitosis Nodes will be used to transform
|
|
13
|
+
* deeply nested JSX elements found on properties. Note that not every generator
|
|
14
|
+
* supports parsing `blocksSlots`.
|
|
15
|
+
* Defaults to `false`.
|
|
16
|
+
*/
|
|
17
|
+
enableBlocksSlots?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type ResolvedImport = {
|
|
20
|
+
path: string;
|
|
21
|
+
value: string;
|
|
22
|
+
};
|
|
23
|
+
export type Context = {
|
|
24
|
+
cwd?: string;
|
|
25
|
+
builder: {
|
|
26
|
+
component: MitosisComponent;
|
|
27
|
+
resolvedImports?: ResolvedImport[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCss = void 0;
|
|
4
|
+
const parseCss = (ast, json) => {
|
|
5
|
+
var _a;
|
|
6
|
+
json.style = (_a = ast.css) === null || _a === void 0 ? void 0 : _a.content.styles;
|
|
7
|
+
};
|
|
8
|
+
exports.parseCss = parseCss;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processBindings = void 0;
|
|
4
|
+
const bindings_1 = require("../../../helpers/bindings");
|
|
5
|
+
function replaceGroupWithChecked(node, isArray = false) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
if ((_b = (_a = node.bindings.group) === null || _a === void 0 ? void 0 : _a.code) === null || _b === void 0 ? void 0 : _b.length) {
|
|
8
|
+
const bindingValue = (_c = node.bindings.value) === null || _c === void 0 ? void 0 : _c.code;
|
|
9
|
+
const propertyValue = node.properties.value;
|
|
10
|
+
const groupBinding = node.bindings.group.code;
|
|
11
|
+
let code = '';
|
|
12
|
+
if (isArray) {
|
|
13
|
+
code = bindingValue
|
|
14
|
+
? `${groupBinding}.includes(${bindingValue})`
|
|
15
|
+
: `${groupBinding}.includes('${propertyValue}')`;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
code = bindingValue
|
|
19
|
+
? `${groupBinding} === ${bindingValue}`
|
|
20
|
+
: `${groupBinding} === '${propertyValue}'`;
|
|
21
|
+
}
|
|
22
|
+
node.bindings['checked'] = (0, bindings_1.createSingleBinding)({
|
|
23
|
+
code,
|
|
24
|
+
});
|
|
25
|
+
delete node.bindings.group;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/* post-processes bindings
|
|
29
|
+
bind:group https://svelte.dev/docs#template-syntax-element-directives-bind-group
|
|
30
|
+
bind:property https://svelte.dev/docs#template-syntax-component-directives-bind-this
|
|
31
|
+
bind:this https://svelte.dev/docs#template-syntax-component-directives-bind-this
|
|
32
|
+
|
|
33
|
+
- replaces group binding with checked for checkboxes and radios (supported inputs for bind:group)
|
|
34
|
+
- adds onChange for bind:group and bind:property (event.target.value OR event.target.checked)
|
|
35
|
+
*/
|
|
36
|
+
function processBindings(json, node) {
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
38
|
+
let name;
|
|
39
|
+
let target = 'event.target.value';
|
|
40
|
+
let binding = '';
|
|
41
|
+
let isArray = false;
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(node.bindings, 'group')) {
|
|
43
|
+
name = 'group';
|
|
44
|
+
binding = (_b = (_a = node.bindings.group) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '';
|
|
45
|
+
if (binding.startsWith('state.')) {
|
|
46
|
+
const stateObject = json.state[binding.replace(/^state\./, '')];
|
|
47
|
+
isArray = Array.isArray(stateObject === null || stateObject === void 0 ? void 0 : stateObject.code);
|
|
48
|
+
}
|
|
49
|
+
replaceGroupWithChecked(node, isArray);
|
|
50
|
+
if (node.properties.type === 'checkbox' && !node.properties.value) {
|
|
51
|
+
target = 'event.target.checked';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (Object.prototype.hasOwnProperty.call(node.bindings, 'this')) {
|
|
55
|
+
name = 'ref';
|
|
56
|
+
binding = (_d = (_c = node.bindings.this) === null || _c === void 0 ? void 0 : _c.code) !== null && _d !== void 0 ? _d : '';
|
|
57
|
+
}
|
|
58
|
+
else if (Object.prototype.hasOwnProperty.call(node.bindings, 'onChange') &&
|
|
59
|
+
node.properties.type === 'checkbox') {
|
|
60
|
+
target = 'event.target.checked';
|
|
61
|
+
binding = (_f = (_e = node.bindings.onChange) === null || _e === void 0 ? void 0 : _e.code.split('=')[0]) !== null && _f !== void 0 ? _f : '';
|
|
62
|
+
}
|
|
63
|
+
let onChangeCode = `${binding} = ${target}`;
|
|
64
|
+
// If the binding is an array, we should push / splice rather than assigning
|
|
65
|
+
if (isArray) {
|
|
66
|
+
onChangeCode = `event.target.checked ? ${binding}.push(${target}) : ${binding}.splice(${binding}.indexOf(${node.properties.value ? `'${node.properties.value}'` : (_g = node.bindings.value) === null || _g === void 0 ? void 0 : _g.code}), 1)`;
|
|
67
|
+
}
|
|
68
|
+
if (name !== 'ref' && binding) {
|
|
69
|
+
node.bindings['onChange'] = (0, bindings_1.createSingleBinding)({
|
|
70
|
+
code: onChangeCode,
|
|
71
|
+
arguments: ['event'],
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.processBindings = processBindings;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TemplateNode } from '../../../../../node_modules/svelte/types/compiler/interfaces';
|
|
2
|
+
import type { MitosisNode } from '../../../types/mitosis-node';
|
|
3
|
+
import type { SveltosisComponent } from '../types';
|
|
4
|
+
export declare function filterChildren(children: TemplateNode[]): TemplateNode[];
|
|
5
|
+
export declare function parseChildren(json: SveltosisComponent, node: TemplateNode): MitosisNode[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseChildren = exports.filterChildren = void 0;
|
|
4
|
+
const html_1 = require("../html");
|
|
5
|
+
function filterChildren(children) {
|
|
6
|
+
var _a;
|
|
7
|
+
return ((_a = children === null || children === void 0 ? void 0 : children.filter((n) => { var _a; return n.type !== 'Comment' && (n.type !== 'Text' || ((_a = n.data) === null || _a === void 0 ? void 0 : _a.trim().length)); })) !== null && _a !== void 0 ? _a : []);
|
|
8
|
+
}
|
|
9
|
+
exports.filterChildren = filterChildren;
|
|
10
|
+
function parseChildren(json, node) {
|
|
11
|
+
const children = [];
|
|
12
|
+
if (node.children) {
|
|
13
|
+
for (const child of filterChildren(node.children)) {
|
|
14
|
+
const mitosisNode = (0, html_1.parseHtmlNode)(json, child);
|
|
15
|
+
if (mitosisNode) {
|
|
16
|
+
children.push(mitosisNode);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return children;
|
|
21
|
+
}
|
|
22
|
+
exports.parseChildren = parseChildren;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseObjectExpression = void 0;
|
|
4
|
+
const astring_1 = require("astring");
|
|
5
|
+
const references_1 = require("../instance/references");
|
|
6
|
+
function parseObjectExpression(json, node) {
|
|
7
|
+
const properties = node.properties.map((n) => {
|
|
8
|
+
const node_ = n;
|
|
9
|
+
return {
|
|
10
|
+
key: (0, astring_1.generate)(node_.key),
|
|
11
|
+
value: (0, references_1.getParsedValue)(json, node_.value),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
const c = {};
|
|
15
|
+
for (const item of properties) {
|
|
16
|
+
Object.assign(c, { [item.key]: item.value });
|
|
17
|
+
}
|
|
18
|
+
return c;
|
|
19
|
+
}
|
|
20
|
+
exports.parseObjectExpression = parseObjectExpression;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addToOnInitHook = void 0;
|
|
4
|
+
function addToOnInitHook(json, code) {
|
|
5
|
+
var _a;
|
|
6
|
+
if ((_a = json.hooks.onInit) === null || _a === void 0 ? void 0 : _a.code.length) {
|
|
7
|
+
json.hooks.onInit.code += `\n ${code}`;
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
json.hooks.onInit = {
|
|
11
|
+
code,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.addToOnInitHook = addToOnInitHook;
|