@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,187 @@
|
|
|
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.replaceNodes = exports.replacePropsIdentifier = exports.replaceStateIdentifier = exports.replaceIdentifiers = void 0;
|
|
7
|
+
const core_1 = require("@babel/core");
|
|
8
|
+
const generator_1 = __importDefault(require("@babel/generator"));
|
|
9
|
+
const function_1 = require("fp-ts/lib/function");
|
|
10
|
+
const babel_transform_1 = require("./babel-transform");
|
|
11
|
+
/**
|
|
12
|
+
* Given a `to` function given by the user, figure out the best argument to provide to the `to` function.
|
|
13
|
+
* This function makes a best guess based on the AST structure it's dealing with.
|
|
14
|
+
*/
|
|
15
|
+
const getToParam = (path) => {
|
|
16
|
+
if (core_1.types.isMemberExpression(path.node) || core_1.types.isOptionalMemberExpression(path.node)) {
|
|
17
|
+
if (core_1.types.isIdentifier(path.node.property)) {
|
|
18
|
+
// if simple member expression e.g. `props.foo`, returns `foo`
|
|
19
|
+
const propertyName = path.node.property.name;
|
|
20
|
+
return propertyName;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// if nested member expression e.g. `props.foo.bar.baz`, returns `foo.bar.baz`
|
|
24
|
+
const x = (0, generator_1.default)(path.node.property).code;
|
|
25
|
+
return x;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// if naked identifier e.g. `foo`, returns `foo`
|
|
30
|
+
const nodeName = path.node.name;
|
|
31
|
+
return nodeName;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const _replaceIdentifiers = (path, { from, to }) => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const memberExpressionObject = core_1.types.isIdentifier(path.node) ? path.node : path.node.object;
|
|
37
|
+
const normalizedFrom = Array.isArray(from) ? from : [from];
|
|
38
|
+
if (!core_1.types.isIdentifier(memberExpressionObject) ||
|
|
39
|
+
((_b = (_a = path.node) === null || _a === void 0 ? void 0 : _a._builder_meta) === null || _b === void 0 ? void 0 : _b.newlyGenerated)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const matchesFrom = normalizedFrom.includes(memberExpressionObject.name);
|
|
43
|
+
if (matchesFrom) {
|
|
44
|
+
if (to) {
|
|
45
|
+
// `props.foo` to `state`, e.g. `state.foo`
|
|
46
|
+
if (typeof to === 'string') {
|
|
47
|
+
const cleanedIdentifier = (0, function_1.pipe)(
|
|
48
|
+
// Remove trailing `.` if it exists in the user-provided string, as the dot is generated
|
|
49
|
+
// by babel from the AST
|
|
50
|
+
to.endsWith('.') ? to.substring(0, to.length - 1) : to, core_1.types.identifier);
|
|
51
|
+
if (core_1.types.isIdentifier(path.node)) {
|
|
52
|
+
path.replaceWith(cleanedIdentifier);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
path.replaceWith(core_1.types.memberExpression(cleanedIdentifier, path.node.property));
|
|
56
|
+
}
|
|
57
|
+
// `props.foo` to (name) => `state.${name}.bar`, e.g. `state.foo.bar`
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
try {
|
|
61
|
+
const newMemberExpression = (0, function_1.pipe)(getToParam(path), (x) => to(x, memberExpressionObject.name), (expression) => {
|
|
62
|
+
const [head, ...tail] = expression.split('.');
|
|
63
|
+
return [head, tail.join('.')];
|
|
64
|
+
}, ([obj, prop]) => {
|
|
65
|
+
const objIdentifier = core_1.types.identifier(obj);
|
|
66
|
+
if (prop === '') {
|
|
67
|
+
return objIdentifier;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return core_1.types.memberExpression(objIdentifier, core_1.types.identifier(prop));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* If both `path` and `newMemberExpression` are equal nodes, do nothing.
|
|
75
|
+
* This is to prevent infinite loops when the user-provided `to` function returns the same identifier.
|
|
76
|
+
*
|
|
77
|
+
* The infinite loop probably happens because we end up traversing the new `Identifier` node again?
|
|
78
|
+
*/
|
|
79
|
+
if ((0, generator_1.default)(path.node).code === (0, generator_1.default)(newMemberExpression).code) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
newMemberExpression._builder_meta = { newlyGenerated: true };
|
|
83
|
+
path.replaceWith(newMemberExpression);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.debug('Could not replace node.');
|
|
87
|
+
// throw err;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
if (!core_1.types.isIdentifier(path.node)) {
|
|
93
|
+
// if we're looking at a member expression, e.g. `props.foo` and no `to` was provided, then we want to strip out
|
|
94
|
+
// the identifier and end up with `foo`. So we replace the member expression with just its `property` value.
|
|
95
|
+
path.replaceWith(path.node.property);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated Use `replaceNodes` instead.
|
|
102
|
+
*/
|
|
103
|
+
const replaceIdentifiers = ({ code, from, to }) => {
|
|
104
|
+
try {
|
|
105
|
+
return (0, function_1.pipe)((0, babel_transform_1.babelTransformExpression)(code, {
|
|
106
|
+
MemberExpression(path) {
|
|
107
|
+
_replaceIdentifiers(path, { from, to });
|
|
108
|
+
},
|
|
109
|
+
OptionalMemberExpression(path) {
|
|
110
|
+
_replaceIdentifiers(path, { from, to });
|
|
111
|
+
},
|
|
112
|
+
Identifier(path) {
|
|
113
|
+
// we only want to ignore certain identifiers:
|
|
114
|
+
if (
|
|
115
|
+
// (optional) member expressions are already handled in other visitors
|
|
116
|
+
!core_1.types.isMemberExpression(path.parent) &&
|
|
117
|
+
!core_1.types.isOptionalMemberExpression(path.parent) &&
|
|
118
|
+
// function declaration identifiers shouldn't be transformed
|
|
119
|
+
!core_1.types.isFunctionDeclaration(path.parent) &&
|
|
120
|
+
// variable declaration identifiers shouldn't be transformed
|
|
121
|
+
// !(types.isVariableDeclarator(path.parent) && path.parent.id === path.node)
|
|
122
|
+
// object -> { detail: { state: 'something' } } shouldn't be transformed to { detail: { this: 'something' } }
|
|
123
|
+
!core_1.types.isObjectProperty(path.parent)) {
|
|
124
|
+
_replaceIdentifiers(path, { from, to });
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
// merely running `babel.transform` will add spaces around the code, even if we don't end up replacing anything.
|
|
129
|
+
// we have some other code downstream that cannot have untrimmed spaces, so we need to trim the output.
|
|
130
|
+
(code) => code.trim());
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
throw err;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
exports.replaceIdentifiers = replaceIdentifiers;
|
|
137
|
+
const replaceStateIdentifier = (to) => (code) => (0, exports.replaceIdentifiers)({ code, from: 'state', to });
|
|
138
|
+
exports.replaceStateIdentifier = replaceStateIdentifier;
|
|
139
|
+
const replacePropsIdentifier = (to) => (code) => (0, exports.replaceIdentifiers)({ code, from: 'props', to });
|
|
140
|
+
exports.replacePropsIdentifier = replacePropsIdentifier;
|
|
141
|
+
const isNewlyGenerated = (node) => { var _a; return (_a = node === null || node === void 0 ? void 0 : node._builder_meta) === null || _a === void 0 ? void 0 : _a.newlyGenerated; };
|
|
142
|
+
/**
|
|
143
|
+
* Replaces all instances of a Babel AST Node with a new Node within a code string.
|
|
144
|
+
* Uses `generate()` to convert the Node to a string and compare them.
|
|
145
|
+
*/
|
|
146
|
+
const replaceNodes = ({ code, nodeMaps }) => {
|
|
147
|
+
const searchAndReplace = (path) => {
|
|
148
|
+
if (isNewlyGenerated(path.node) || isNewlyGenerated(path.parent))
|
|
149
|
+
return;
|
|
150
|
+
for (const { from, to, condition } of nodeMaps) {
|
|
151
|
+
if (isNewlyGenerated(path.node) || isNewlyGenerated(path.parent))
|
|
152
|
+
return;
|
|
153
|
+
// if (path.node.type !== from.type) return;
|
|
154
|
+
const matchesCondition = condition ? condition(path) : true;
|
|
155
|
+
if ((0, generator_1.default)(path.node).code === (0, generator_1.default)(from).code && matchesCondition) {
|
|
156
|
+
const x = core_1.types.cloneNode(to);
|
|
157
|
+
x._builder_meta = { newlyGenerated: true };
|
|
158
|
+
try {
|
|
159
|
+
path.replaceWith(x);
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
console.log('error replacing', {
|
|
163
|
+
code,
|
|
164
|
+
orig: (0, generator_1.default)(path.node).code,
|
|
165
|
+
to: (0, generator_1.default)(x).code,
|
|
166
|
+
});
|
|
167
|
+
// throw err;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
173
|
+
ThisExpression(path) {
|
|
174
|
+
searchAndReplace(path);
|
|
175
|
+
},
|
|
176
|
+
MemberExpression(path) {
|
|
177
|
+
searchAndReplace(path);
|
|
178
|
+
},
|
|
179
|
+
Identifier(path) {
|
|
180
|
+
searchAndReplace(path);
|
|
181
|
+
},
|
|
182
|
+
OptionalMemberExpression(path) {
|
|
183
|
+
searchAndReplace(path);
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
exports.replaceNodes = replaceNodes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripNewlinesInStrings(string: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripNewlinesInStrings = void 0;
|
|
4
|
+
function stripNewlinesInStrings(string) {
|
|
5
|
+
let inString = null;
|
|
6
|
+
return string
|
|
7
|
+
.split('')
|
|
8
|
+
.map((char, index) => {
|
|
9
|
+
if (inString) {
|
|
10
|
+
if (char === '\n') {
|
|
11
|
+
return ' ';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// Prior char is escape char and the char before that is not escaping it
|
|
15
|
+
const isEscaped = string[index - 1] === '\\' && string[index - 2] !== '\\';
|
|
16
|
+
if (!inString && (char === '"' || char === "'") && !isEscaped) {
|
|
17
|
+
inString = char;
|
|
18
|
+
}
|
|
19
|
+
else if (inString && char === inString && !isEscaped) {
|
|
20
|
+
inString = null;
|
|
21
|
+
}
|
|
22
|
+
return char;
|
|
23
|
+
})
|
|
24
|
+
.join('');
|
|
25
|
+
}
|
|
26
|
+
exports.stripNewlinesInStrings = stripNewlinesInStrings;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.set = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Minimal implementation of lodash's _.set
|
|
6
|
+
* https://lodash.com/docs/4.17.15#set
|
|
7
|
+
*
|
|
8
|
+
* See ./set.test.ts for usage examples
|
|
9
|
+
*/
|
|
10
|
+
const set = (obj, _path, value) => {
|
|
11
|
+
if (Object(obj) !== obj) {
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
const path = Array.isArray(_path)
|
|
15
|
+
? _path
|
|
16
|
+
: _path.toString().match(/[^.[\]]+/g);
|
|
17
|
+
path
|
|
18
|
+
.slice(0, -1)
|
|
19
|
+
.reduce((a, c, i) => Object(a[c]) === a[c]
|
|
20
|
+
? a[c]
|
|
21
|
+
: (a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}), obj)[path[path.length - 1]] = value;
|
|
22
|
+
return obj;
|
|
23
|
+
};
|
|
24
|
+
exports.set = set;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './signals';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./signals"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Target } from '../../types/config';
|
|
2
|
+
export declare const getSignalMitosisImportForTarget: (target: Target) => import("../..").MitosisImport | undefined;
|
|
3
|
+
export declare const getSignalImportName: (code: string) => string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Finds all `Signal` types and replaces them with the correct type for the given target.
|
|
6
|
+
* e.g. `Signal<string>` becomes `Writable<string>` for Svelte.
|
|
7
|
+
*/
|
|
8
|
+
export declare const mapSignalType: ({ code, target, signalImportName, }: {
|
|
9
|
+
code: string;
|
|
10
|
+
target: Target;
|
|
11
|
+
signalImportName?: string | undefined;
|
|
12
|
+
}) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Processes the `Signal` type usage in a plain TS file:
|
|
15
|
+
* - Finds the `Signal` import name
|
|
16
|
+
* - Maps the `Signal` type to the target's equivalent
|
|
17
|
+
* - Adds the equivalent of the `Signal` import to the file
|
|
18
|
+
*/
|
|
19
|
+
export declare const mapSignalTypeInTSFile: ({ code, target }: {
|
|
20
|
+
code: string;
|
|
21
|
+
target: Target;
|
|
22
|
+
}) => string;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapSignalTypeInTSFile = exports.mapSignalType = exports.getSignalImportName = exports.getSignalMitosisImportForTarget = void 0;
|
|
4
|
+
const core_1 = require("@babel/core");
|
|
5
|
+
const function_1 = require("fp-ts/lib/function");
|
|
6
|
+
const babel_transform_1 = require("../../helpers/babel-transform");
|
|
7
|
+
const mitosis_imports_1 = require("../mitosis-imports");
|
|
8
|
+
const getSignalMappingForTarget = (target) => {
|
|
9
|
+
switch (target) {
|
|
10
|
+
case 'svelte':
|
|
11
|
+
const importDeclaration = core_1.types.importDeclaration([core_1.types.importSpecifier(core_1.types.identifier('Writable'), core_1.types.identifier('Writable'))], core_1.types.stringLiteral('svelte/store'));
|
|
12
|
+
importDeclaration.importKind = 'type';
|
|
13
|
+
return {
|
|
14
|
+
getTypeReference: (generics = []) => core_1.types.tsTypeReference(core_1.types.identifier('Writable'), core_1.types.tsTypeParameterInstantiation(generics)),
|
|
15
|
+
importDeclaration,
|
|
16
|
+
};
|
|
17
|
+
default:
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const getSignalMitosisImportForTarget = (target) => {
|
|
22
|
+
const signalType = getSignalMappingForTarget(target);
|
|
23
|
+
if (!signalType) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return (0, mitosis_imports_1.mapImportDeclarationToMitosisImport)(signalType.importDeclaration);
|
|
27
|
+
};
|
|
28
|
+
exports.getSignalMitosisImportForTarget = getSignalMitosisImportForTarget;
|
|
29
|
+
const getSignalImportName = (code) => {
|
|
30
|
+
let foundSignalUsage = false;
|
|
31
|
+
let signalImportName = undefined;
|
|
32
|
+
(0, babel_transform_1.babelTransformExpression)(code, {
|
|
33
|
+
ImportSpecifier(path) {
|
|
34
|
+
if (core_1.types.isIdentifier(path.node.imported) && path.node.imported.name === 'Signal') {
|
|
35
|
+
if (path.parentPath.isImportDeclaration() &&
|
|
36
|
+
path.parentPath.node.source.value === '@builder.io/mitosis') {
|
|
37
|
+
/**
|
|
38
|
+
* in case the import is aliased, we need to use the local name,
|
|
39
|
+
* e.g. `import { Signal as MySignal } from '../..'`
|
|
40
|
+
*/
|
|
41
|
+
signalImportName = path.node.local.name;
|
|
42
|
+
path.stop();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if (!signalImportName) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
(0, babel_transform_1.babelTransformExpression)(code, {
|
|
51
|
+
TSTypeReference(path) {
|
|
52
|
+
if (core_1.types.isIdentifier(path.node.typeName) && path.node.typeName.name === signalImportName) {
|
|
53
|
+
foundSignalUsage = true;
|
|
54
|
+
path.stop();
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
return foundSignalUsage ? signalImportName : undefined;
|
|
59
|
+
};
|
|
60
|
+
exports.getSignalImportName = getSignalImportName;
|
|
61
|
+
const addSignalImport = ({ code, target }) => {
|
|
62
|
+
const signalType = getSignalMappingForTarget(target);
|
|
63
|
+
if (!signalType) {
|
|
64
|
+
return code;
|
|
65
|
+
}
|
|
66
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
67
|
+
Program(path) {
|
|
68
|
+
path.node.body.unshift(signalType.importDeclaration);
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Finds all `Signal` types and replaces them with the correct type for the given target.
|
|
74
|
+
* e.g. `Signal<string>` becomes `Writable<string>` for Svelte.
|
|
75
|
+
*/
|
|
76
|
+
const mapSignalType = ({ code, target, signalImportName = (0, exports.getSignalImportName)(code), }) => {
|
|
77
|
+
const signalType = getSignalMappingForTarget(target);
|
|
78
|
+
const map = (path) => {
|
|
79
|
+
var _a;
|
|
80
|
+
if (core_1.types.isIdentifier(path.node.typeName) && path.node.typeName.name === signalImportName) {
|
|
81
|
+
const params = ((_a = path.node.typeParameters) === null || _a === void 0 ? void 0 : _a.params) || [];
|
|
82
|
+
const newType = (signalType === null || signalType === void 0 ? void 0 : signalType.getTypeReference)
|
|
83
|
+
? signalType.getTypeReference(params)
|
|
84
|
+
: // if no mapping exists, drop `Signal` and just use the generic type passed to `Signal` as-is.
|
|
85
|
+
params[0];
|
|
86
|
+
path.replaceWith(newType);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
90
|
+
TSTypeReference(path) {
|
|
91
|
+
map(path);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
exports.mapSignalType = mapSignalType;
|
|
96
|
+
/**
|
|
97
|
+
* Processes the `Signal` type usage in a plain TS file:
|
|
98
|
+
* - Finds the `Signal` import name
|
|
99
|
+
* - Maps the `Signal` type to the target's equivalent
|
|
100
|
+
* - Adds the equivalent of the `Signal` import to the file
|
|
101
|
+
*/
|
|
102
|
+
const mapSignalTypeInTSFile = ({ code, target }) => {
|
|
103
|
+
const signalImportName = (0, exports.getSignalImportName)(code);
|
|
104
|
+
if (!signalImportName) {
|
|
105
|
+
return code;
|
|
106
|
+
}
|
|
107
|
+
return (0, function_1.pipe)((0, exports.mapSignalType)({ target, code, signalImportName }), (code) => addSignalImport({ code, target }));
|
|
108
|
+
};
|
|
109
|
+
exports.mapSignalTypeInTSFile = mapSignalTypeInTSFile;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type SlotMapper = (slotName: string) => string;
|
|
2
|
+
export declare const isSlotProperty: (key: string, slotPrefix?: string) => boolean;
|
|
3
|
+
export declare const stripSlotPrefix: (key: string, slotPrefix?: string) => string;
|
|
4
|
+
export declare const toKebabSlot: (key: string, slotPrefix?: string) => string;
|
|
5
|
+
export declare function replaceSlotsInString(code: string, mapper: SlotMapper): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceSlotsInString = exports.toKebabSlot = exports.stripSlotPrefix = exports.isSlotProperty = void 0;
|
|
4
|
+
const core_1 = require("@babel/core");
|
|
5
|
+
const function_1 = require("fp-ts/function");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const babel_transform_1 = require("./babel-transform");
|
|
8
|
+
const SLOT_PREFIX = 'slot';
|
|
9
|
+
const isSlotProperty = (key, slotPrefix = SLOT_PREFIX) => key.startsWith(slotPrefix);
|
|
10
|
+
exports.isSlotProperty = isSlotProperty;
|
|
11
|
+
const stripSlotPrefix = (key, slotPrefix = SLOT_PREFIX) => (0, exports.isSlotProperty)(key, slotPrefix) ? key.substring(slotPrefix.length) : key;
|
|
12
|
+
exports.stripSlotPrefix = stripSlotPrefix;
|
|
13
|
+
const toKebabSlot = (key, slotPrefix = SLOT_PREFIX) => (0, function_1.pipe)((0, exports.stripSlotPrefix)(key, slotPrefix), lodash_1.kebabCase);
|
|
14
|
+
exports.toKebabSlot = toKebabSlot;
|
|
15
|
+
function replaceSlotsInString(code, mapper) {
|
|
16
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
17
|
+
Identifier(path) {
|
|
18
|
+
const name = path.node.name;
|
|
19
|
+
const isSlot = (0, exports.isSlotProperty)(name);
|
|
20
|
+
if (isSlot) {
|
|
21
|
+
path.replaceWith(core_1.types.identifier(mapper((0, exports.stripSlotPrefix)(name).toLowerCase())));
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.replaceSlotsInString = replaceSlotsInString;
|
|
@@ -0,0 +1,26 @@
|
|
|
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.stripMetaProperties = void 0;
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
|
+
const stripMetaProperties = (json) => {
|
|
10
|
+
(0, legacy_1.default)(json).forEach((item) => {
|
|
11
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
12
|
+
for (const property in item.properties) {
|
|
13
|
+
if (property.startsWith('$')) {
|
|
14
|
+
delete item.properties[property];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
for (const property in item.bindings) {
|
|
18
|
+
if (property.startsWith('$')) {
|
|
19
|
+
delete item.bindings[property];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return json;
|
|
25
|
+
};
|
|
26
|
+
exports.stripMetaProperties = stripMetaProperties;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type StripStateAndPropsRefsOptions = {
|
|
2
|
+
replaceWith?: string | ((name: string) => string);
|
|
3
|
+
includeProps?: boolean;
|
|
4
|
+
includeState?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Do not use this anywhere. We are migrating to AST transforms and should avoid Regex String.replace() as they are
|
|
8
|
+
* very brittle.
|
|
9
|
+
*
|
|
10
|
+
* If you need to re-use this, re-create it as an AST tranform first.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DO_NOT_USE_CONTEXT_VARS_TRANSFORMS: ({ code, contextVars, context, }: {
|
|
13
|
+
code: string;
|
|
14
|
+
contextVars?: string[] | undefined;
|
|
15
|
+
context: string;
|
|
16
|
+
}) => string;
|
|
17
|
+
export type DO_NOT_USE_ARGS = {
|
|
18
|
+
outputVars?: string[];
|
|
19
|
+
domRefs?: string[];
|
|
20
|
+
stateVars?: string[];
|
|
21
|
+
contextVars?: string[];
|
|
22
|
+
context?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Do not use these anywhere. We are migrating to AST transforms and should avoid Regex String.replace() as they are
|
|
26
|
+
* very brittle.
|
|
27
|
+
*
|
|
28
|
+
* If you need to re-use a part of this, re-create it as an AST tranform first.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DO_NOT_USE_VARS_TRANSFORMS: (newCode: string, { context, domRefs, outputVars, stateVars, contextVars }: DO_NOT_USE_ARGS) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Remove state. and props. from expressions, e.g.
|
|
33
|
+
* state.foo -> foo
|
|
34
|
+
*
|
|
35
|
+
* This is for support for frameworks like Vue, Svelte, liquid, etc
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export declare const stripStateAndPropsRefs: (code?: string, _options?: StripStateAndPropsRefsOptions) => string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripStateAndPropsRefs = exports.DO_NOT_USE_VARS_TRANSFORMS = exports.DO_NOT_USE_CONTEXT_VARS_TRANSFORMS = void 0;
|
|
4
|
+
const replace_identifiers_1 = require("./replace-identifiers");
|
|
5
|
+
const DEFAULT_OPTIONS = {
|
|
6
|
+
replaceWith: '',
|
|
7
|
+
includeProps: true,
|
|
8
|
+
includeState: true,
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Do not use this anywhere. We are migrating to AST transforms and should avoid Regex String.replace() as they are
|
|
12
|
+
* very brittle.
|
|
13
|
+
*
|
|
14
|
+
* If you need to re-use this, re-create it as an AST tranform first.
|
|
15
|
+
*/
|
|
16
|
+
const DO_NOT_USE_CONTEXT_VARS_TRANSFORMS = ({ code, contextVars, context, }) => {
|
|
17
|
+
contextVars === null || contextVars === void 0 ? void 0 : contextVars.forEach((_var) => {
|
|
18
|
+
code = code.replace(
|
|
19
|
+
// determine expression edge cases - https://regex101.com/r/iNcTSM/1
|
|
20
|
+
new RegExp('(^|\\n|\\r| |;|\\(|\\[|!)' + _var + '(\\?\\.|\\.|\\(| |;|\\)|$)', 'g'), '$1' + context + _var + '$2');
|
|
21
|
+
});
|
|
22
|
+
return code;
|
|
23
|
+
};
|
|
24
|
+
exports.DO_NOT_USE_CONTEXT_VARS_TRANSFORMS = DO_NOT_USE_CONTEXT_VARS_TRANSFORMS;
|
|
25
|
+
/**
|
|
26
|
+
* Do not use these anywhere. We are migrating to AST transforms and should avoid Regex String.replace() as they are
|
|
27
|
+
* very brittle.
|
|
28
|
+
*
|
|
29
|
+
* If you need to re-use a part of this, re-create it as an AST tranform first.
|
|
30
|
+
*/
|
|
31
|
+
const DO_NOT_USE_VARS_TRANSFORMS = (newCode, { context = 'this.', domRefs, outputVars, stateVars, contextVars }) => {
|
|
32
|
+
newCode = (0, exports.DO_NOT_USE_CONTEXT_VARS_TRANSFORMS)({ code: newCode, context, contextVars });
|
|
33
|
+
outputVars === null || outputVars === void 0 ? void 0 : outputVars.forEach((_var) => {
|
|
34
|
+
// determine expression edge cases onMessage( to this.onMessage.emit(
|
|
35
|
+
const regexp = '(^|\\s|;|\\()(props\\.?)' + _var + '\\(';
|
|
36
|
+
const replacer = '$1' + context + _var + '.emit(';
|
|
37
|
+
newCode = newCode.replace(new RegExp(regexp, 'g'), replacer);
|
|
38
|
+
});
|
|
39
|
+
const matchPropertyAccessorsArguments = '\\?\\.|,|\\.|\\(| |;|\\)|\\]|$'; // foo?.stuff | foo) | foo | foo] etc.
|
|
40
|
+
const matchVariableUseInClass = '^|\\n|\\r| |;|\\(|\\[|!|,'; // foo | (foo | !foo | foo, | [foo etc.
|
|
41
|
+
domRefs === null || domRefs === void 0 ? void 0 : domRefs.forEach((_var) => {
|
|
42
|
+
newCode = newCode.replace(new RegExp(`(${matchVariableUseInClass})${_var}(${matchPropertyAccessorsArguments})`, 'g'), '$1' + 'this.' + _var + '$2');
|
|
43
|
+
});
|
|
44
|
+
stateVars === null || stateVars === void 0 ? void 0 : stateVars.forEach((_var) => {
|
|
45
|
+
newCode = newCode.replace(
|
|
46
|
+
/*
|
|
47
|
+
1. Skip anything that is a class variable declaration
|
|
48
|
+
myClass() {
|
|
49
|
+
stuff = 'hi'
|
|
50
|
+
foo = 'bar' <-- in the event that formatting is off
|
|
51
|
+
}
|
|
52
|
+
2. Skip anything that is the name of a function declaration or a getter
|
|
53
|
+
stuff = function stuff() {} or get stuff
|
|
54
|
+
3. If the conditions are met then try to match all use cases of the class variables, see above.
|
|
55
|
+
*/
|
|
56
|
+
new RegExp(`(?!^${_var}|^ ${_var})(?<!function|get)(${matchVariableUseInClass})${_var}(${matchPropertyAccessorsArguments})`, 'g'), '$1' + 'this.' + _var + '$2');
|
|
57
|
+
});
|
|
58
|
+
return newCode;
|
|
59
|
+
};
|
|
60
|
+
exports.DO_NOT_USE_VARS_TRANSFORMS = DO_NOT_USE_VARS_TRANSFORMS;
|
|
61
|
+
/**
|
|
62
|
+
* Remove state. and props. from expressions, e.g.
|
|
63
|
+
* state.foo -> foo
|
|
64
|
+
*
|
|
65
|
+
* This is for support for frameworks like Vue, Svelte, liquid, etc
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
const stripStateAndPropsRefs = (code, _options = {}) => {
|
|
69
|
+
let newCode = code || '';
|
|
70
|
+
const { replaceWith, includeProps, includeState } = {
|
|
71
|
+
...DEFAULT_OPTIONS,
|
|
72
|
+
..._options,
|
|
73
|
+
};
|
|
74
|
+
if (includeProps) {
|
|
75
|
+
newCode = (0, replace_identifiers_1.replacePropsIdentifier)(replaceWith)(newCode);
|
|
76
|
+
// TODO: webcomponent edge-case
|
|
77
|
+
if (/el\.this\.props/.test(newCode)) {
|
|
78
|
+
newCode = newCode.replace(/el\.this\.props/g, 'el.props');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (includeState) {
|
|
82
|
+
newCode = (0, replace_identifiers_1.replaceStateIdentifier)(replaceWith)(newCode);
|
|
83
|
+
}
|
|
84
|
+
return newCode;
|
|
85
|
+
};
|
|
86
|
+
exports.stripStateAndPropsRefs = stripStateAndPropsRefs;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MitosisComponent } from '../../types/mitosis-component';
|
|
2
|
+
type CollectStyleOptions = {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function normalizeName(name: string | undefined): string;
|
|
6
|
+
export declare const collectCss: (json: MitosisComponent, options?: CollectStyleOptions) => string;
|
|
7
|
+
export {};
|