@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,547 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCodeProcessorPlugins = void 0;
|
|
4
|
+
const get_computed_1 = require("../../../../generators/angular/signals/helpers/get-computed");
|
|
5
|
+
const babel_transform_1 = require("../../../../helpers/babel-transform");
|
|
6
|
+
const class_components_1 = require("../../../../helpers/class-components");
|
|
7
|
+
const event_handlers_1 = require("../../../../helpers/event-handlers");
|
|
8
|
+
const process_code_1 = require("../../../../helpers/plugins/process-code");
|
|
9
|
+
const symbol_processor_1 = require("../../../../symbols/symbol-processor");
|
|
10
|
+
const mitosis_node_1 = require("../../../../types/mitosis-node");
|
|
11
|
+
const types_1 = require("@babel/types");
|
|
12
|
+
// Helper functions for handling nested state updates
|
|
13
|
+
const getBaseObject = (node) => {
|
|
14
|
+
if (!node)
|
|
15
|
+
return null;
|
|
16
|
+
if (!(0, types_1.isMemberExpression)(node))
|
|
17
|
+
return node;
|
|
18
|
+
return getBaseObject(node.object);
|
|
19
|
+
};
|
|
20
|
+
const getPropertyFromStateChain = (node) => {
|
|
21
|
+
// Start at the leftmost object and traverse up to find the first property after 'state'
|
|
22
|
+
let current = node;
|
|
23
|
+
while ((0, types_1.isMemberExpression)(current)) {
|
|
24
|
+
if ((0, types_1.isMemberExpression)(current.object) &&
|
|
25
|
+
(0, types_1.isIdentifier)(current.object.object) &&
|
|
26
|
+
current.object.object.name === 'state' &&
|
|
27
|
+
(0, types_1.isIdentifier)(current.object.property)) {
|
|
28
|
+
return current.object.property.name;
|
|
29
|
+
}
|
|
30
|
+
current = current.object;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
const getNestedPath = (node, topLevelProp) => {
|
|
35
|
+
const path = [];
|
|
36
|
+
let current = node;
|
|
37
|
+
// Collect all property names starting after the top-level property
|
|
38
|
+
let foundTopLevel = false;
|
|
39
|
+
while ((0, types_1.isMemberExpression)(current)) {
|
|
40
|
+
if ((0, types_1.isIdentifier)(current.property)) {
|
|
41
|
+
path.unshift(current.property.name);
|
|
42
|
+
}
|
|
43
|
+
if ((0, types_1.isMemberExpression)(current.object) &&
|
|
44
|
+
(0, types_1.isIdentifier)(current.object.object) &&
|
|
45
|
+
current.object.object.name === 'state' &&
|
|
46
|
+
(0, types_1.isIdentifier)(current.object.property) &&
|
|
47
|
+
current.object.property.name === topLevelProp) {
|
|
48
|
+
foundTopLevel = true;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
current = current.object;
|
|
52
|
+
}
|
|
53
|
+
return foundTopLevel ? path : [];
|
|
54
|
+
};
|
|
55
|
+
const buildPathAccess = (baseParam, propertyPath) => {
|
|
56
|
+
return propertyPath.reduce((acc, prop) => {
|
|
57
|
+
return (0, types_1.memberExpression)(acc, (0, types_1.identifier)(prop));
|
|
58
|
+
}, baseParam);
|
|
59
|
+
};
|
|
60
|
+
const isStateOrPropsExpression = (path) => {
|
|
61
|
+
return ((0, types_1.isMemberExpression)(path.node) &&
|
|
62
|
+
(0, types_1.isIdentifier)(path.node.object) &&
|
|
63
|
+
(0, types_1.isIdentifier)(path.node.property) &&
|
|
64
|
+
(path.node.object.name === 'props' || path.node.object.name === 'state'));
|
|
65
|
+
};
|
|
66
|
+
const isAFunctionOrMethod = (json, path) => {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
return (json &&
|
|
69
|
+
(0, types_1.isIdentifier)(path.node.object) &&
|
|
70
|
+
(0, types_1.isIdentifier)(path.node.property) &&
|
|
71
|
+
path.node.object.name === 'state' &&
|
|
72
|
+
json.state &&
|
|
73
|
+
typeof path.node.property.name === 'string' &&
|
|
74
|
+
json.state[path.node.property.name] &&
|
|
75
|
+
((_a = json.state[path.node.property.name]) === null || _a === void 0 ? void 0 : _a.type) &&
|
|
76
|
+
(((_b = json.state[path.node.property.name]) === null || _b === void 0 ? void 0 : _b.type) === 'method' ||
|
|
77
|
+
((_c = json.state[path.node.property.name]) === null || _c === void 0 ? void 0 : _c.type) === 'function'));
|
|
78
|
+
};
|
|
79
|
+
const handleAssignmentExpression = (path) => {
|
|
80
|
+
if ((0, types_1.isMemberExpression)(path.node.left) &&
|
|
81
|
+
(0, types_1.isIdentifier)(path.node.left.object) &&
|
|
82
|
+
(0, types_1.isIdentifier)(path.node.left.property) &&
|
|
83
|
+
path.node.left.object.name === 'state') {
|
|
84
|
+
const root = (0, types_1.memberExpression)(path.node.left, (0, types_1.identifier)('set'));
|
|
85
|
+
root.extra = { ...root.extra, updateExpression: true };
|
|
86
|
+
const call = (0, types_1.callExpression)(root, [path.node.right]);
|
|
87
|
+
path.replaceWith(call);
|
|
88
|
+
}
|
|
89
|
+
else if ((0, types_1.isMemberExpression)(path.node.left) &&
|
|
90
|
+
path.node.left.computed &&
|
|
91
|
+
(((0, types_1.isMemberExpression)(path.node.left.object) &&
|
|
92
|
+
(0, types_1.isIdentifier)(path.node.left.object.object) &&
|
|
93
|
+
path.node.left.object.object.name === 'state') ||
|
|
94
|
+
((0, types_1.isIdentifier)(path.node.left.object) && path.node.left.object.name === 'state'))) {
|
|
95
|
+
/**
|
|
96
|
+
* Handle array element assignments like: state.arr[0] = '123'
|
|
97
|
+
* Example:
|
|
98
|
+
* Input: state.arr[0] = '123'
|
|
99
|
+
* Output: state.arr.update(arr => {
|
|
100
|
+
* arr[0] = '123';
|
|
101
|
+
* return arr;
|
|
102
|
+
* })
|
|
103
|
+
*/
|
|
104
|
+
let stateProp;
|
|
105
|
+
let baseObject;
|
|
106
|
+
if ((0, types_1.isIdentifier)(path.node.left.object) && path.node.left.object.name === 'state') {
|
|
107
|
+
stateProp = path.node.left.property;
|
|
108
|
+
baseObject = path.node.left.object;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
stateProp = getPropertyFromStateChain(path.node.left);
|
|
112
|
+
if (!stateProp)
|
|
113
|
+
return;
|
|
114
|
+
baseObject = (0, types_1.memberExpression)((0, types_1.identifier)('state'), (0, types_1.identifier)(stateProp));
|
|
115
|
+
}
|
|
116
|
+
const root = (0, types_1.memberExpression)(baseObject, (0, types_1.identifier)('update'));
|
|
117
|
+
root.extra = { ...root.extra, updateExpression: true };
|
|
118
|
+
const paramName = typeof stateProp === 'string' ? stateProp : (0, types_1.isIdentifier)(stateProp) ? stateProp.name : 'item';
|
|
119
|
+
const param = (0, types_1.identifier)(paramName);
|
|
120
|
+
let assignTarget;
|
|
121
|
+
if ((0, types_1.isIdentifier)(path.node.left.object) && path.node.left.object.name === 'state') {
|
|
122
|
+
// Direct state array: state[index] = value
|
|
123
|
+
assignTarget = (0, types_1.memberExpression)(param, path.node.left.property, true);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Property array: state.arr[index] = value
|
|
127
|
+
assignTarget = (0, types_1.memberExpression)(param, path.node.left.property, true);
|
|
128
|
+
}
|
|
129
|
+
const block = (0, types_1.blockStatement)([
|
|
130
|
+
(0, types_1.expressionStatement)((0, types_1.assignmentExpression)('=', assignTarget, path.node.right)),
|
|
131
|
+
(0, types_1.returnStatement)(param),
|
|
132
|
+
]);
|
|
133
|
+
const arrowFunction = (0, types_1.arrowFunctionExpression)([param], block);
|
|
134
|
+
const call = (0, types_1.callExpression)(root, [arrowFunction]);
|
|
135
|
+
path.replaceWith(call);
|
|
136
|
+
}
|
|
137
|
+
else if ((0, types_1.isMemberExpression)(path.node.left) &&
|
|
138
|
+
(0, types_1.isMemberExpression)(path.node.left.object) &&
|
|
139
|
+
(0, types_1.isIdentifier)(getBaseObject(path.node.left)) &&
|
|
140
|
+
getBaseObject(path.node.left).name === 'state') {
|
|
141
|
+
/**
|
|
142
|
+
* Handle any level of nested updates like state.store.something.nested = newVal
|
|
143
|
+
* Example:
|
|
144
|
+
* Input: state.store.something.nested = newVal
|
|
145
|
+
* Output: state.store.update(obj => ({
|
|
146
|
+
* ...obj,
|
|
147
|
+
* store: {
|
|
148
|
+
* ...obj.store,
|
|
149
|
+
* something: {
|
|
150
|
+
* ...obj.store.something,
|
|
151
|
+
* nested: newVal
|
|
152
|
+
* }
|
|
153
|
+
* }
|
|
154
|
+
* }))
|
|
155
|
+
*/
|
|
156
|
+
const stateProp = getPropertyFromStateChain(path.node.left);
|
|
157
|
+
if (!stateProp)
|
|
158
|
+
return;
|
|
159
|
+
const topLevelProp = (0, types_1.memberExpression)((0, types_1.identifier)('state'), (0, types_1.identifier)(stateProp));
|
|
160
|
+
const nestedPaths = getNestedPath(path.node.left, stateProp);
|
|
161
|
+
const root = (0, types_1.memberExpression)(topLevelProp, (0, types_1.identifier)('update'));
|
|
162
|
+
root.extra = { ...root.extra, updateExpression: true };
|
|
163
|
+
const paramName = stateProp;
|
|
164
|
+
const param = (0, types_1.identifier)(paramName);
|
|
165
|
+
let innerValue = path.node.right;
|
|
166
|
+
for (let i = nestedPaths.length - 1; i >= 0; i--) {
|
|
167
|
+
const spreadTarget = i === 0 ? param : buildPathAccess(param, nestedPaths.slice(0, i));
|
|
168
|
+
innerValue = (0, types_1.objectExpression)([
|
|
169
|
+
(0, types_1.spreadElement)(spreadTarget),
|
|
170
|
+
(0, types_1.objectProperty)((0, types_1.identifier)(nestedPaths[i]), innerValue, false, false),
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
173
|
+
const arrowFunction = (0, types_1.arrowFunctionExpression)([param], innerValue, false);
|
|
174
|
+
const call = (0, types_1.callExpression)(root, [arrowFunction]);
|
|
175
|
+
path.replaceWith(call);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const handleMemberExpression = (path, json) => {
|
|
179
|
+
var _a, _b, _c, _d;
|
|
180
|
+
if (((_a = path.node.extra) === null || _a === void 0 ? void 0 : _a.makeCallExpressionDone) || ((_c = (_b = path.parentPath) === null || _b === void 0 ? void 0 : _b.node.extra) === null || _c === void 0 ? void 0 : _c.updateExpression)) {
|
|
181
|
+
// Don't add a function if we've done it already
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if ((0, types_1.isCallExpression)(path.parent) &&
|
|
185
|
+
(0, types_1.isMemberExpression)(path.parent.callee) &&
|
|
186
|
+
(0, types_1.isIdentifier)(path.parent.callee.object) &&
|
|
187
|
+
(path.parent.callee.object.name === 'props' || path.parent.callee.object.name === 'state') &&
|
|
188
|
+
!((_d = path.parent.callee.extra) === null || _d === void 0 ? void 0 : _d.updateExpression)) {
|
|
189
|
+
// Don't add a function if it is already
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (isStateOrPropsExpression(path)) {
|
|
193
|
+
// Check if the state property is a method or function type, and if so, bind it to 'this'
|
|
194
|
+
if (isAFunctionOrMethod(json, path)) {
|
|
195
|
+
const bindExpr = `${path.toString()}.bind(this)`;
|
|
196
|
+
path.replaceWith((0, types_1.identifier)(bindExpr));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
path.node.extra = { ...path.node.extra, makeCallExpressionDone: true };
|
|
200
|
+
path.replaceWith((0, types_1.callExpression)(path.node, []));
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const handleHookAndStateOnEvents = (path, isHookDepArray) => {
|
|
204
|
+
if ((0, types_1.isIdentifier)(path.node.property) && (0, event_handlers_1.checkIsEvent)(path.node.property.name)) {
|
|
205
|
+
if ((0, types_1.isIfStatement)(path.parent)) {
|
|
206
|
+
// We don't do anything if the event is in an IfStatement
|
|
207
|
+
path.node.extra = { ...path.node.extra, updateExpression: true };
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
else if ((0, types_1.isCallExpression)(path.parent) &&
|
|
211
|
+
(0, types_1.isIdentifier)(path.node.object) &&
|
|
212
|
+
(0, types_1.isMemberExpression)(path.parent.callee)) {
|
|
213
|
+
// We add "emit" to events
|
|
214
|
+
const root = (0, types_1.memberExpression)(path.node, (0, types_1.identifier)('emit'));
|
|
215
|
+
root.extra = { ...root.extra, updateExpression: true };
|
|
216
|
+
path.replaceWith(root);
|
|
217
|
+
}
|
|
218
|
+
else if (isHookDepArray && (0, types_1.isIdentifier)(path.node.object)) {
|
|
219
|
+
const iden = (0, types_1.identifier)(`// "${path.node.object.name}.${path.node.property.name}" is an event skip it.`);
|
|
220
|
+
path.replaceWith(iden);
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
};
|
|
226
|
+
const handleTemplateLiteral = (path, json, context) => {
|
|
227
|
+
var _a;
|
|
228
|
+
const fnName = `templateStr_${(0, symbol_processor_1.hashCodeAsString)(path.toString())}`;
|
|
229
|
+
const extraParams = new Set();
|
|
230
|
+
// Collect loop variables from context
|
|
231
|
+
let currentContext = context;
|
|
232
|
+
while (currentContext === null || currentContext === void 0 ? void 0 : currentContext.parent) {
|
|
233
|
+
if (((_a = currentContext.parent.node) === null || _a === void 0 ? void 0 : _a.name) === mitosis_node_1.ForNodeName) {
|
|
234
|
+
const forNode = currentContext.parent.node;
|
|
235
|
+
if (forNode.scope.forName)
|
|
236
|
+
extraParams.add(forNode.scope.forName);
|
|
237
|
+
if (forNode.scope.indexName)
|
|
238
|
+
extraParams.add(forNode.scope.indexName);
|
|
239
|
+
}
|
|
240
|
+
currentContext = currentContext.parent;
|
|
241
|
+
}
|
|
242
|
+
const processedExpressions = path.node.expressions.map((expr) => {
|
|
243
|
+
let exprCode = '';
|
|
244
|
+
try {
|
|
245
|
+
const { code } = require('@babel/generator').default(expr);
|
|
246
|
+
exprCode = code;
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
exprCode = expr.toString();
|
|
250
|
+
}
|
|
251
|
+
// Replace state.x with this.x() for signals
|
|
252
|
+
return exprCode
|
|
253
|
+
.replace(/\bstate\.(\w+)(?!\()/g, 'this.$1()')
|
|
254
|
+
.replace(/\bprops\.(\w+)(?!\()/g, 'this.$1()');
|
|
255
|
+
});
|
|
256
|
+
// Convert Set to Array for final usage
|
|
257
|
+
const paramsList = Array.from(extraParams);
|
|
258
|
+
json.state[fnName] = {
|
|
259
|
+
code: `${fnName}(${paramsList.join(', ')}) {
|
|
260
|
+
return \`${path.node.quasis
|
|
261
|
+
.map((quasi, i) => {
|
|
262
|
+
const escapedRaw = quasi.value.raw.replace(/\\/g, '\\\\').replace(/\$/g, '\\$');
|
|
263
|
+
return (escapedRaw +
|
|
264
|
+
(i < processedExpressions.length ? '${' + processedExpressions[i] + '}' : ''));
|
|
265
|
+
})
|
|
266
|
+
.join('')}\`;
|
|
267
|
+
}`,
|
|
268
|
+
type: 'method',
|
|
269
|
+
};
|
|
270
|
+
// Return the function call with any needed parameters
|
|
271
|
+
return `${fnName}(${paramsList.join(', ')})`;
|
|
272
|
+
};
|
|
273
|
+
const handleCallExpressionArgument = (json, arg) => {
|
|
274
|
+
var _a;
|
|
275
|
+
if ((0, types_1.isMemberExpression)(arg) &&
|
|
276
|
+
(0, types_1.isIdentifier)(arg.object) &&
|
|
277
|
+
(0, types_1.isIdentifier)(arg.property) &&
|
|
278
|
+
(arg.object.name === 'state' || arg.object.name === 'props') &&
|
|
279
|
+
!((_a = arg.extra) === null || _a === void 0 ? void 0 : _a.makeCallExpressionDone)) {
|
|
280
|
+
if (arg.object.name === 'state' && json) {
|
|
281
|
+
const argPath = { node: arg };
|
|
282
|
+
if (isAFunctionOrMethod(json, argPath)) {
|
|
283
|
+
const argStr = arg.object.name + '.' + arg.property.name;
|
|
284
|
+
return (0, types_1.identifier)(`${argStr}.bind(this)`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const newArg = (0, types_1.callExpression)(arg, []);
|
|
288
|
+
newArg.extra = { makeCallExpressionDone: true };
|
|
289
|
+
return newArg;
|
|
290
|
+
}
|
|
291
|
+
return arg;
|
|
292
|
+
};
|
|
293
|
+
const transformHooksAndState = (code, isHookDepArray, json) => {
|
|
294
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
295
|
+
AssignmentExpression(path) {
|
|
296
|
+
handleAssignmentExpression(path);
|
|
297
|
+
},
|
|
298
|
+
UpdateExpression(path) {
|
|
299
|
+
/*
|
|
300
|
+
* If we have a function like this:
|
|
301
|
+
* `state._counter++;`
|
|
302
|
+
*
|
|
303
|
+
* We need to convert it and use the "update" example from https://angular.dev/guide/signals#writable-signals:
|
|
304
|
+
* `state._counter.update(_counter=>_counter++)`
|
|
305
|
+
*
|
|
306
|
+
*/
|
|
307
|
+
if ((0, types_1.isMemberExpression)(path.node.argument) &&
|
|
308
|
+
(0, types_1.isIdentifier)(path.node.argument.object) &&
|
|
309
|
+
path.node.argument.object.name === 'state' &&
|
|
310
|
+
(0, types_1.isIdentifier)(path.node.argument.property)) {
|
|
311
|
+
const root = (0, types_1.memberExpression)(path.node.argument, (0, types_1.identifier)('update'));
|
|
312
|
+
root.extra = { ...root.extra, updateExpression: true };
|
|
313
|
+
const argument = path.node.argument.property;
|
|
314
|
+
const block = (0, types_1.blockStatement)([
|
|
315
|
+
(0, types_1.expressionStatement)((0, types_1.updateExpression)(path.node.operator, argument)),
|
|
316
|
+
(0, types_1.returnStatement)(argument),
|
|
317
|
+
]);
|
|
318
|
+
const arrowFunction = (0, types_1.arrowFunctionExpression)([argument], block);
|
|
319
|
+
const call = (0, types_1.callExpression)(root, [arrowFunction]);
|
|
320
|
+
path.replaceWith(call);
|
|
321
|
+
}
|
|
322
|
+
else if ((0, types_1.isMemberExpression)(path.node.argument) &&
|
|
323
|
+
(0, types_1.isMemberExpression)(path.node.argument.object) &&
|
|
324
|
+
(0, types_1.isIdentifier)(getBaseObject(path.node.argument)) &&
|
|
325
|
+
getBaseObject(path.node.argument).name === 'state') {
|
|
326
|
+
// Handle nested update expressions like: state.obj.counter++
|
|
327
|
+
// Example:
|
|
328
|
+
// Input: state.obj.counter++
|
|
329
|
+
// Output: state.obj.update(obj => {
|
|
330
|
+
// Object.assign(obj, {
|
|
331
|
+
// counter: obj.counter + 1
|
|
332
|
+
// });
|
|
333
|
+
// return obj;
|
|
334
|
+
// });
|
|
335
|
+
//
|
|
336
|
+
const stateProp = getPropertyFromStateChain(path.node.argument);
|
|
337
|
+
if (!stateProp)
|
|
338
|
+
return;
|
|
339
|
+
const topLevelProp = (0, types_1.memberExpression)((0, types_1.identifier)('state'), (0, types_1.identifier)(stateProp));
|
|
340
|
+
const nestedPaths = getNestedPath(path.node.argument, stateProp);
|
|
341
|
+
const root = (0, types_1.memberExpression)(topLevelProp, (0, types_1.identifier)('update'));
|
|
342
|
+
root.extra = { ...root.extra, updateExpression: true };
|
|
343
|
+
const paramName = stateProp;
|
|
344
|
+
const param = (0, types_1.identifier)(paramName);
|
|
345
|
+
const lastPropName = nestedPaths[nestedPaths.length - 1];
|
|
346
|
+
const innerParamName = lastPropName + '_value';
|
|
347
|
+
const nestedPathAccess = buildPathAccess(param, nestedPaths.slice(0, -1));
|
|
348
|
+
let innerValue = (0, types_1.objectExpression)([
|
|
349
|
+
(0, types_1.spreadElement)(nestedPathAccess),
|
|
350
|
+
(0, types_1.objectProperty)((0, types_1.identifier)(lastPropName), (0, types_1.updateExpression)(path.node.operator, (0, types_1.identifier)(innerParamName), path.node.prefix), false, false),
|
|
351
|
+
]);
|
|
352
|
+
for (let i = nestedPaths.length - 2; i >= 0; i--) {
|
|
353
|
+
const spreadTarget = i === 0 ? param : buildPathAccess(param, nestedPaths.slice(0, i));
|
|
354
|
+
innerValue = (0, types_1.objectExpression)([
|
|
355
|
+
(0, types_1.spreadElement)(spreadTarget),
|
|
356
|
+
(0, types_1.objectProperty)((0, types_1.identifier)(nestedPaths[i]), innerValue, false, false),
|
|
357
|
+
]);
|
|
358
|
+
}
|
|
359
|
+
const block = (0, types_1.blockStatement)([
|
|
360
|
+
(0, types_1.expressionStatement)((0, types_1.callExpression)((0, types_1.memberExpression)((0, types_1.identifier)('Object'), (0, types_1.identifier)('assign')), [
|
|
361
|
+
param,
|
|
362
|
+
innerValue,
|
|
363
|
+
])),
|
|
364
|
+
(0, types_1.returnStatement)(param),
|
|
365
|
+
]);
|
|
366
|
+
const arrowFunction = (0, types_1.arrowFunctionExpression)([param], block);
|
|
367
|
+
const call = (0, types_1.callExpression)(root, [arrowFunction]);
|
|
368
|
+
path.replaceWith(call);
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
MemberExpression(path) {
|
|
372
|
+
const skip = handleHookAndStateOnEvents(path, isHookDepArray);
|
|
373
|
+
if (skip) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
handleMemberExpression(path, json);
|
|
377
|
+
},
|
|
378
|
+
CallExpression(path) {
|
|
379
|
+
// if args has a state.x or props.x, we need to add this.x() to the args
|
|
380
|
+
if (path.node.arguments.length > 0) {
|
|
381
|
+
const newArgs = path.node.arguments.map((arg) => handleCallExpressionArgument(json, arg));
|
|
382
|
+
// Only replace arguments if we made any changes
|
|
383
|
+
if (newArgs.some((arg, i) => arg !== path.node.arguments[i])) {
|
|
384
|
+
path.node.arguments = newArgs;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
const addToImportCall = (json, importName) => {
|
|
391
|
+
const importInstance = json.imports.find((imp) => imp.imports[importName]);
|
|
392
|
+
// Check if this is a type import - if it is, don't add it to importCalls
|
|
393
|
+
if ((importInstance === null || importInstance === void 0 ? void 0 : importInstance.importKind) === 'type') {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const isImportCall = !!importInstance;
|
|
397
|
+
const isExportCall = json.exports ? !!json.exports[importName] : false;
|
|
398
|
+
if (isImportCall || isExportCall) {
|
|
399
|
+
json.compileContext.angular.extra.importCalls.push(importName);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const transformBindings = (json, code, key, context) => {
|
|
403
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
404
|
+
BlockStatement() {
|
|
405
|
+
console.error(`
|
|
406
|
+
Component ${json.name} has a BlockStatement inside JSX'.
|
|
407
|
+
This will cause an error in Angular.
|
|
408
|
+
Please create and call a new function instead with this code:
|
|
409
|
+
${code}`);
|
|
410
|
+
},
|
|
411
|
+
CallExpression(path) {
|
|
412
|
+
// If we call a function from an import we need to add it to the Component as well
|
|
413
|
+
if ((0, types_1.isIdentifier)(path.node.callee)) {
|
|
414
|
+
addToImportCall(json, path.node.callee.name);
|
|
415
|
+
}
|
|
416
|
+
if (path.node.arguments.length > 0) {
|
|
417
|
+
const newArgs = path.node.arguments.map((arg) => handleCallExpressionArgument(json, arg));
|
|
418
|
+
// Only replace arguments if we made any changes
|
|
419
|
+
if (newArgs.some((arg, i) => arg !== path.node.arguments[i])) {
|
|
420
|
+
path.node.arguments = newArgs;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
Identifier(path) {
|
|
425
|
+
// If we use a constant from an import we need to add it to the Component as well
|
|
426
|
+
if ((0, types_1.isIdentifier)(path.node)) {
|
|
427
|
+
addToImportCall(json, path.node.name);
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
StringLiteral(path) {
|
|
431
|
+
var _a;
|
|
432
|
+
// We cannot use " for string literal in template
|
|
433
|
+
if ((_a = path.node.extra) === null || _a === void 0 ? void 0 : _a.raw) {
|
|
434
|
+
path.node.extra.raw = path.node.extra.raw.replaceAll('"', '"');
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
AssignmentExpression(path) {
|
|
438
|
+
handleAssignmentExpression(path);
|
|
439
|
+
},
|
|
440
|
+
MemberExpression(path) {
|
|
441
|
+
handleMemberExpression(path, json);
|
|
442
|
+
},
|
|
443
|
+
TemplateLiteral(path) {
|
|
444
|
+
var _a, _b, _c;
|
|
445
|
+
// they are already created as trackBy functions
|
|
446
|
+
if (key === 'key') {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
// skip template literals in spread bindings
|
|
450
|
+
if (key && ((_c = (_b = (_a = context === null || context === void 0 ? void 0 : context.node) === null || _a === void 0 ? void 0 : _a.bindings) === null || _b === void 0 ? void 0 : _b[key]) === null || _c === void 0 ? void 0 : _c.code.includes('...'))) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
// When we encounter a template literal, convert it to a function
|
|
454
|
+
const fnCall = handleTemplateLiteral(path, json, context);
|
|
455
|
+
path.replaceWith((0, types_1.identifier)(fnCall));
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
};
|
|
459
|
+
const getCodeProcessorPlugins = (json, options, processBindingOptions) => {
|
|
460
|
+
return [
|
|
461
|
+
...(options.plugins || []),
|
|
462
|
+
(0, process_code_1.CODE_PROCESSOR_PLUGIN)((codeType) => {
|
|
463
|
+
switch (codeType) {
|
|
464
|
+
case 'bindings':
|
|
465
|
+
return (code, key, context) => {
|
|
466
|
+
var _a, _b, _c, _d, _e, _f;
|
|
467
|
+
// Handle object spread expressions or TypeScript type assertions
|
|
468
|
+
if ((code.startsWith('{') && code.includes('...')) || code.includes(' as ')) {
|
|
469
|
+
if (((_a = context === null || context === void 0 ? void 0 : context.node) === null || _a === void 0 ? void 0 : _a.bindings) && key) {
|
|
470
|
+
const binding = context.node.bindings[key];
|
|
471
|
+
let isForContext = false;
|
|
472
|
+
let forName = '';
|
|
473
|
+
let indexName = '';
|
|
474
|
+
let currentContext = context;
|
|
475
|
+
while (currentContext === null || currentContext === void 0 ? void 0 : currentContext.parent) {
|
|
476
|
+
if (((_b = currentContext.parent.node) === null || _b === void 0 ? void 0 : _b.name) === mitosis_node_1.ForNodeName) {
|
|
477
|
+
isForContext = true;
|
|
478
|
+
const forNode = currentContext.parent.node;
|
|
479
|
+
forName = forNode.scope.forName || '_';
|
|
480
|
+
indexName = forNode.scope.indexName || '_';
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
currentContext = currentContext.parent;
|
|
484
|
+
}
|
|
485
|
+
const computedName = (0, get_computed_1.createObjectSpreadComputed)(json, binding, key, isForContext, forName, indexName);
|
|
486
|
+
if (isForContext) {
|
|
487
|
+
const params = [];
|
|
488
|
+
if (forName)
|
|
489
|
+
params.push(forName);
|
|
490
|
+
if (indexName)
|
|
491
|
+
params.push(indexName);
|
|
492
|
+
if (params.length > 0) {
|
|
493
|
+
return (0, class_components_1.processClassComponentBinding)(json, `${computedName}(${params.join(', ')})`, {
|
|
494
|
+
...processBindingOptions,
|
|
495
|
+
replaceWith: 'this.',
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return (0, class_components_1.processClassComponentBinding)(json, `${computedName}()`, {
|
|
500
|
+
...processBindingOptions,
|
|
501
|
+
replaceWith: 'this.',
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
const needsToReplaceWithThis = (code.startsWith('{') && code.includes('...')) ||
|
|
506
|
+
code.includes(' as ') ||
|
|
507
|
+
(context === null || context === void 0 ? void 0 : context.node.name.includes('.')) ||
|
|
508
|
+
((_c = context === null || context === void 0 ? void 0 : context.node.bindings[key]) === null || _c === void 0 ? void 0 : _c.type) === 'spread';
|
|
509
|
+
let replaceWith = '';
|
|
510
|
+
if (key === 'key') {
|
|
511
|
+
/**
|
|
512
|
+
* If we have a key attribute we need to check if it is inside a @for loop.
|
|
513
|
+
* We will create a new function for the key attribute.
|
|
514
|
+
* Therefore, we need to add "this" to state and props.
|
|
515
|
+
*/
|
|
516
|
+
const isForParent = ((_f = (_e = (_d = context === null || context === void 0 ? void 0 : context.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.node) === null || _f === void 0 ? void 0 : _f.name) === mitosis_node_1.ForNodeName;
|
|
517
|
+
if (isForParent) {
|
|
518
|
+
replaceWith = 'this.';
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
if (needsToReplaceWithThis) {
|
|
522
|
+
replaceWith = 'this.';
|
|
523
|
+
}
|
|
524
|
+
return (0, class_components_1.processClassComponentBinding)(json, transformBindings(json, code, key, context), {
|
|
525
|
+
...processBindingOptions,
|
|
526
|
+
replaceWith,
|
|
527
|
+
});
|
|
528
|
+
};
|
|
529
|
+
case 'hooks-deps-array':
|
|
530
|
+
case 'hooks':
|
|
531
|
+
case 'state':
|
|
532
|
+
return (code) => {
|
|
533
|
+
return (0, class_components_1.processClassComponentBinding)(json, transformHooksAndState(code, codeType === 'hooks-deps-array', json), processBindingOptions);
|
|
534
|
+
};
|
|
535
|
+
case 'properties':
|
|
536
|
+
case 'hooks-deps':
|
|
537
|
+
case 'context-set':
|
|
538
|
+
case 'dynamic-jsx-elements':
|
|
539
|
+
case 'types':
|
|
540
|
+
return (code) => {
|
|
541
|
+
return (0, class_components_1.processClassComponentBinding)(json, code, processBindingOptions);
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
}),
|
|
545
|
+
];
|
|
546
|
+
};
|
|
547
|
+
exports.getCodeProcessorPlugins = getCodeProcessorPlugins;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { BaseTranspilerOptions } from '../../types/transpiler';
|
|
2
|
+
export declare const BUILT_IN_COMPONENTS: Set<string>;
|
|
3
|
+
export type AngularApi = 'classic' | 'signals';
|
|
4
|
+
export interface ToAngularOptions extends BaseTranspilerOptions {
|
|
5
|
+
api?: AngularApi;
|
|
6
|
+
state?: 'class-properties' | 'inline-with-wrappers';
|
|
7
|
+
standalone?: boolean;
|
|
8
|
+
preserveImports?: boolean;
|
|
9
|
+
preserveFileExtensions?: boolean;
|
|
10
|
+
importMapper?: Function;
|
|
11
|
+
bootstrapMapper?: Function;
|
|
12
|
+
visuallyIgnoreHostElement?: boolean;
|
|
13
|
+
defaultExportComponents?: boolean;
|
|
14
|
+
experimental?: {
|
|
15
|
+
injectables?: (variableName: string, variableType: string) => string;
|
|
16
|
+
inject?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_ANGULAR_OPTIONS: ToAngularOptions;
|
|
20
|
+
export type AngularMetadata = {
|
|
21
|
+
/**
|
|
22
|
+
* Mitosis uses `attr.XXX` as default see https://angular.io/guide/attribute-binding.
|
|
23
|
+
* If you want to skip some you can use the 'nativeAttributes'.
|
|
24
|
+
*/
|
|
25
|
+
nativeAttributes?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* If you encounter some native events which aren't generated in lower-case.
|
|
28
|
+
* Create a new PR inside [event-handlers.ts](https://github.com/BuilderIO/mitosis/blob/main/packages/core/src/helpers/event-handlers.ts) to fix it for all.
|
|
29
|
+
*/
|
|
30
|
+
nativeEvents?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Overwrite default selector for component. Default will be kebab case (MyComponent -> my-component)
|
|
33
|
+
*/
|
|
34
|
+
selector?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Overwrite default change detection strategy.
|
|
37
|
+
* `OnPush` adds `changeDetection: ChangeDetectionStrategy.OnPush` to the component metadata.
|
|
38
|
+
*/
|
|
39
|
+
changeDetection?: 'Default' | 'OnPush';
|
|
40
|
+
/**
|
|
41
|
+
* Overwrite default sanitizeInnerHTML. Default is `false`
|
|
42
|
+
*/
|
|
43
|
+
sanitizeInnerHTML?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Only for api=classic
|
|
46
|
+
* Add additional @Output() properties to the component.
|
|
47
|
+
* Can be used with `useTarget({angular: ()=> ...})` if needed.
|
|
48
|
+
*/
|
|
49
|
+
outputs?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Skip hydration for the component.
|
|
52
|
+
* Adds `host: { ngSkipHydration: "true" }` to the component decorator.
|
|
53
|
+
*/
|
|
54
|
+
skipHydration?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Only for api=signals
|
|
57
|
+
*/
|
|
58
|
+
signals?: {
|
|
59
|
+
/**
|
|
60
|
+
* Turns every property in this array to [`model`](https://angular.dev/api/core/model).
|
|
61
|
+
* This is useful if you want to use ngModel(`[(prop)]`) syntax in Angular.
|
|
62
|
+
*/
|
|
63
|
+
writeable?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Adds [`.required`](https://angular.dev/api/core/input#required()) to the `input()` properties.
|
|
66
|
+
*/
|
|
67
|
+
required?: string[];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export type AngularBlockOptions = {
|
|
71
|
+
childComponents?: string[];
|
|
72
|
+
} & AngularMetadata;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_ANGULAR_OPTIONS = exports.BUILT_IN_COMPONENTS = void 0;
|
|
4
|
+
exports.BUILT_IN_COMPONENTS = new Set(['Show', 'For', 'Fragment', 'Slot']);
|
|
5
|
+
exports.DEFAULT_ANGULAR_OPTIONS = {
|
|
6
|
+
api: 'classic',
|
|
7
|
+
state: 'inline-with-wrappers',
|
|
8
|
+
preserveImports: false,
|
|
9
|
+
preserveFileExtensions: false,
|
|
10
|
+
visuallyIgnoreHostElement: true,
|
|
11
|
+
defaultExportComponents: false,
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ToBuilderOptions } from '../../generators/builder/types';
|
|
2
|
+
import { MitosisNode } from '../../types/mitosis-node';
|
|
3
|
+
import { TranspilerArgs } from '../../types/transpiler';
|
|
4
|
+
import { BuilderContent, BuilderElement } from '@builder.io/sdk';
|
|
5
|
+
export declare const builderBlockPrefixes: string[];
|
|
6
|
+
type InternalOptions = {
|
|
7
|
+
skipMapper?: boolean;
|
|
8
|
+
includeStateMap?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const blockToBuilder: (json: MitosisNode, options?: ToBuilderOptions, _internalOptions?: InternalOptions) => BuilderElement;
|
|
11
|
+
export declare const componentToBuilder: (options?: ToBuilderOptions) => ({ component }: TranspilerArgs) => BuilderContent;
|
|
12
|
+
export {};
|