@builder.io/mitosis 0.0.134 → 0.0.136

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.
Files changed (78) hide show
  1. package/dist/src/constants/media-sizes.d.ts +1 -1
  2. package/dist/src/generators/angular.js +1 -0
  3. package/dist/src/generators/builder.d.ts +1 -1
  4. package/dist/src/generators/context/qwik.d.ts +1 -1
  5. package/dist/src/generators/context/react.d.ts +1 -1
  6. package/dist/src/generators/context/rsc.d.ts +1 -1
  7. package/dist/src/generators/context/solid.d.ts +1 -1
  8. package/dist/src/generators/html.js +5 -1
  9. package/dist/src/generators/lit/generate.js +5 -1
  10. package/dist/src/generators/marko/generate.js +5 -1
  11. package/dist/src/generators/mitosis.js +18 -1
  12. package/dist/src/generators/qwik/component-generator.js +1 -0
  13. package/dist/src/generators/qwik/component.d.ts +1 -1
  14. package/dist/src/generators/qwik/helpers/state.d.ts +5 -5
  15. package/dist/src/generators/qwik/helpers/styles.d.ts +1 -1
  16. package/dist/src/generators/qwik/src-generator.d.ts +1 -1
  17. package/dist/src/generators/react/generator.js +2 -1
  18. package/dist/src/generators/react-native/sanitize-react-native-block-styles.d.ts +1 -1
  19. package/dist/src/generators/rsc.d.ts +1 -1
  20. package/dist/src/generators/solid/index.js +5 -1
  21. package/dist/src/generators/solid/state/state.d.ts +1 -1
  22. package/dist/src/generators/solid/types.d.ts +1 -1
  23. package/dist/src/generators/stencil/generate.js +5 -1
  24. package/dist/src/generators/svelte/blocks.d.ts +1 -1
  25. package/dist/src/generators/svelte/svelte.js +5 -1
  26. package/dist/src/generators/svelte/types.d.ts +1 -1
  27. package/dist/src/generators/swift-ui.d.ts +1 -1
  28. package/dist/src/generators/taro.d.ts +1 -1
  29. package/dist/src/generators/vue/blocks.d.ts +1 -1
  30. package/dist/src/generators/vue/helpers.d.ts +1 -1
  31. package/dist/src/generators/vue/types.d.ts +3 -3
  32. package/dist/src/generators/vue/vue.js +1 -0
  33. package/dist/src/helpers/babel-transform.d.ts +1 -1
  34. package/dist/src/helpers/component-file-extensions.d.ts +4 -2
  35. package/dist/src/helpers/component-file-extensions.js +3 -2
  36. package/dist/src/helpers/create-mitosis-component.d.ts +1 -1
  37. package/dist/src/helpers/get-state-object-string.d.ts +1 -1
  38. package/dist/src/helpers/json.d.ts +1 -1
  39. package/dist/src/helpers/map-refs.d.ts +1 -1
  40. package/dist/src/helpers/nullable.d.ts +1 -1
  41. package/dist/src/helpers/plugins/process-code/index.d.ts +1 -1
  42. package/dist/src/helpers/plugins/process-code/types.d.ts +2 -2
  43. package/dist/src/helpers/plugins/process-signals.js +2 -0
  44. package/dist/src/helpers/render-imports.d.ts +20 -21
  45. package/dist/src/helpers/render-imports.js +16 -11
  46. package/dist/src/helpers/replace-identifiers.d.ts +2 -2
  47. package/dist/src/helpers/slots.d.ts +1 -1
  48. package/dist/src/helpers/strip-state-and-props-refs.d.ts +2 -2
  49. package/dist/src/helpers/styles/collect-css.d.ts +1 -1
  50. package/dist/src/helpers/styles/helpers.d.ts +2 -2
  51. package/dist/src/helpers/styles/helpers.js +11 -5
  52. package/dist/src/helpers/transform-state-setters.d.ts +1 -1
  53. package/dist/src/helpers/typescript.d.ts +4 -4
  54. package/dist/src/index.d.ts +2 -2
  55. package/dist/src/parsers/builder/builder.d.ts +2 -2
  56. package/dist/src/parsers/context.d.ts +1 -1
  57. package/dist/src/parsers/jsx/index.d.ts +1 -0
  58. package/dist/src/parsers/jsx/types.d.ts +2 -2
  59. package/dist/src/parsers/svelte/helpers/post-process.d.ts +1 -1
  60. package/dist/src/parsers/svelte/index.js +1 -1
  61. package/dist/src/parsers/svelte/types/index.d.ts +1 -1
  62. package/dist/src/plugins/compile-away-builder-components.d.ts +2 -2
  63. package/dist/src/plugins/compile-away-builder-components.js +1 -2
  64. package/dist/src/plugins/compile-away-components.d.ts +1 -1
  65. package/dist/src/plugins/map-styles.d.ts +1 -1
  66. package/dist/src/symbols/symbol-processor.d.ts +1 -1
  67. package/dist/src/targets.d.ts +21 -21
  68. package/dist/src/types/config.d.ts +8 -9
  69. package/dist/src/types/json.d.ts +6 -6
  70. package/dist/src/types/metadata.d.ts +3 -3
  71. package/dist/src/types/mitosis-component.d.ts +14 -14
  72. package/dist/src/types/mitosis-context.d.ts +1 -1
  73. package/dist/src/types/mitosis-node.d.ts +7 -7
  74. package/dist/src/types/mitosis-styles.d.ts +1 -1
  75. package/dist/src/types/plugins.d.ts +1 -1
  76. package/dist/src/types/transpiler.d.ts +15 -2
  77. package/dist/tsconfig.build.tsbuildinfo +1 -1
  78. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- export declare type Size = 'large' | 'medium' | 'small';
1
+ export type Size = 'large' | 'medium' | 'small';
2
2
  export declare const sizeNames: Size[];
3
3
  export declare const sizes: {
4
4
  small: {
@@ -395,6 +395,7 @@ var componentToAngular = function (userOptions) {
395
395
  return "const defaultProps = {".concat(defalutPropsString, "};\n");
396
396
  };
397
397
  var str = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n ", "\n ", "\n ", "\n\n @Component({\n ", "\n })\n export class ", " {\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n }\n "], ["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n ", "\n ", "\n ", "\n\n @Component({\n ", "\n })\n export class ", " {\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n }\n "])), outputs.length ? 'Output, EventEmitter, \n' : '', ((_f = options === null || options === void 0 ? void 0 : options.experimental) === null || _f === void 0 ? void 0 : _f.inject) ? 'Inject, forwardRef,' : '', domRefs.size ? ', ViewChild, ElementRef' : '', props.size ? ', Input' : '', options.standalone ? "import { CommonModule } from '@angular/common';" : '', json.types ? json.types.join('\n') : '', getPropsDefinition({ json: json }), (0, render_imports_1.renderPreComponent)({
398
+ explicitImportFileExtension: options.explicitImportFileExtension,
398
399
  component: json,
399
400
  target: 'angular',
400
401
  excludeMitosisComponents: !options.standalone && !options.preserveImports,
@@ -4,7 +4,7 @@ import { BaseTranspilerOptions, TranspilerArgs } from '../types/transpiler';
4
4
  export interface ToBuilderOptions extends BaseTranspilerOptions {
5
5
  includeIds?: boolean;
6
6
  }
7
- declare type InternalOptions = {
7
+ type InternalOptions = {
8
8
  skipMapper?: boolean;
9
9
  };
10
10
  export declare const blockToBuilder: (json: MitosisNode, options?: ToBuilderOptions, _internalOptions?: InternalOptions) => BuilderElement;
@@ -1,5 +1,5 @@
1
1
  import { MitosisContext } from '../../types/mitosis-context';
2
- declare type ContextToQwikOptions = {
2
+ type ContextToQwikOptions = {
3
3
  format?: boolean;
4
4
  };
5
5
  export declare const contextToQwik: (options?: ContextToQwikOptions) => ({ context }: {
@@ -1,5 +1,5 @@
1
1
  import { MitosisContext } from '../../types/mitosis-context';
2
- declare type ContextToReactOptions = {
2
+ type ContextToReactOptions = {
3
3
  format?: boolean;
4
4
  preact?: boolean;
5
5
  typescript?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { MitosisContext } from '../../types/mitosis-context';
2
- declare type ContextToRscOptions = {
2
+ type ContextToRscOptions = {
3
3
  format?: boolean;
4
4
  };
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { MitosisContext } from '../../types/mitosis-context';
2
- declare type ContextToSolidOptions = {
2
+ type ContextToSolidOptions = {
3
3
  format?: boolean;
4
4
  };
5
5
  export declare const contextToSolid: (options?: ContextToSolidOptions) => ({ context }: {
@@ -611,7 +611,11 @@ var componentToCustomElement = function (_options) {
611
611
  console.warn('Could not prettify', { string: html }, err);
612
612
  }
613
613
  }
614
- var str = "\n ".concat(json.types ? json.types.join('\n') : '', "\n ").concat((0, render_imports_1.renderPreComponent)({ component: json, target: 'customElement' }), "\n /**\n * Usage:\n * \n * <").concat(kebabName, "></").concat(kebabName, ">\n * \n */\n class ").concat(ComponentName, " extends ").concat(((_j = options === null || options === void 0 ? void 0 : options.experimental) === null || _j === void 0 ? void 0 : _j.classExtends)
614
+ var str = "\n ".concat(json.types ? json.types.join('\n') : '', "\n ").concat((0, render_imports_1.renderPreComponent)({
615
+ explicitImportFileExtension: options.explicitImportFileExtension,
616
+ component: json,
617
+ target: 'customElement',
618
+ }), "\n /**\n * Usage:\n * \n * <").concat(kebabName, "></").concat(kebabName, ">\n * \n */\n class ").concat(ComponentName, " extends ").concat(((_j = options === null || options === void 0 ? void 0 : options.experimental) === null || _j === void 0 ? void 0 : _j.classExtends)
615
619
  ? (_k = options === null || options === void 0 ? void 0 : options.experimental) === null || _k === void 0 ? void 0 : _k.classExtends(json, options)
616
620
  : 'HTMLElement', " {\n ").concat(Array.from(domRefs)
617
621
  .map(function (ref) {
@@ -180,7 +180,11 @@ var componentToLit = function (_options) {
180
180
  html = html.replace(/\n{3,}/g, '\n\n');
181
181
  }
182
182
  }
183
- var str = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n import { LitElement, html, css } from 'lit';\n import { customElement, property, state, query } from 'lit/decorators.js';\n\n ", "\n ", "\n\n @customElement('", "')\n export default class ", " extends LitElement {\n ", "\n\n ", "\n\n ", "\n \n \n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n ", "\n \n render() {\n return html`\n ", "\n ", "\n `\n }\n }\n "], ["\n ", "\n import { LitElement, html, css } from 'lit';\n import { customElement, property, state, query } from 'lit/decorators.js';\n\n ", "\n ", "\n\n @customElement('", "')\n export default class ", " extends LitElement {\n ", "\n\n ", "\n\n ", "\n \n \n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n ", "\n \n render() {\n return html\\`\n ", "\n ", "\n \\`\n }\n }\n "])), (0, render_imports_1.renderPreComponent)({ component: json, target: 'lit' }), json.types ? json.types.join('\n') : '', hasSpread
183
+ var str = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n import { LitElement, html, css } from 'lit';\n import { customElement, property, state, query } from 'lit/decorators.js';\n\n ", "\n ", "\n\n @customElement('", "')\n export default class ", " extends LitElement {\n ", "\n\n ", "\n\n ", "\n \n \n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n ", "\n \n render() {\n return html`\n ", "\n ", "\n `\n }\n }\n "], ["\n ", "\n import { LitElement, html, css } from 'lit';\n import { customElement, property, state, query } from 'lit/decorators.js';\n\n ", "\n ", "\n\n @customElement('", "')\n export default class ", " extends LitElement {\n ", "\n\n ", "\n\n ", "\n \n \n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n ", "\n \n render() {\n return html\\`\n ", "\n ", "\n \\`\n }\n }\n "])), (0, render_imports_1.renderPreComponent)({
184
+ explicitImportFileExtension: options.explicitImportFileExtension,
185
+ component: json,
186
+ target: 'lit',
187
+ }), json.types ? json.types.join('\n') : '', hasSpread
184
188
  ? "\n const spread = (properties) =>\n directive((part) => {\n for (const property in properties) {\n const value = properties[attr];\n part.element[property] = value;\n }\n });\n "
185
189
  : '', ((_b = json.meta.useMetadata) === null || _b === void 0 ? void 0 : _b.tagName) || getCustomTagName(json.name, options), json.name, options.useShadowDom
186
190
  ? ''
@@ -182,7 +182,11 @@ var componentToMarko = function (userOptions) {
182
182
  console.warn('Could not format css', err);
183
183
  }
184
184
  }
185
- var jsString = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n\n class {\n ", "\n\n ", "\n\n ", "\n \n ", "\n ", "\n ", "\n }\n "], ["\n ", "\n\n class {\n ", "\n\n ", "\n\n ", "\n \n ", "\n ", "\n ", "\n }\n "])), (0, render_imports_1.renderPreComponent)({ component: json, target: 'marko' }), methodsString, !hasState
185
+ var jsString = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n\n class {\n ", "\n\n ", "\n\n ", "\n \n ", "\n ", "\n ", "\n }\n "], ["\n ", "\n\n class {\n ", "\n\n ", "\n\n ", "\n \n ", "\n ", "\n ", "\n }\n "])), (0, render_imports_1.renderPreComponent)({
186
+ explicitImportFileExtension: options.explicitImportFileExtension,
187
+ component: json,
188
+ target: 'marko',
189
+ }), methodsString, !hasState
186
190
  ? ''
187
191
  : "onCreate(".concat(thisHasProps ? 'input' : '', ") {\n this.state = ").concat(dataString, "\n }"), Array.from(domRefs)
188
192
  .map(function (refName) { return "get ".concat((0, lodash_1.camelCase)(refName), "() { \n return this.getEl('").concat((0, lodash_1.camelCase)(refName), "')\n }"); })
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.componentToMitosis = exports.blockToMitosis = exports.DEFAULT_FORMAT = void 0;
31
+ var plugins_1 = require("../modules/plugins");
31
32
  var json5_1 = __importDefault(require("json5"));
32
33
  var standalone_1 = require("prettier/standalone");
33
34
  var hooks_1 = require("../constants/hooks");
@@ -143,6 +144,9 @@ var componentToMitosis = function (toMitosisOptions) {
143
144
  })({ component: component });
144
145
  }
145
146
  var json = (0, fast_clone_1.fastClone)(component);
147
+ if (options.plugins) {
148
+ json = (0, plugins_1.runPreJsonPlugins)({ json: json, plugins: options.plugins });
149
+ }
146
150
  var domRefs = (0, get_refs_1.getRefs)(component);
147
151
  // grab refs not used for bindings
148
152
  var jsRefs = Object.keys(component.refs).filter(function (ref) { return domRefs.has(ref); });
@@ -154,15 +158,25 @@ var componentToMitosis = function (toMitosisOptions) {
154
158
  var components = Array.from((0, get_components_1.getComponents)(json));
155
159
  var mitosisComponents = components.filter(function (item) { return mitosisCoreComponents.includes(item); });
156
160
  var otherComponents = components.filter(function (item) { return !mitosisCoreComponents.includes(item); });
161
+ if (options.plugins) {
162
+ json = (0, plugins_1.runPostJsonPlugins)({ json: json, plugins: options.plugins });
163
+ }
157
164
  var hasState = (0, state_1.checkHasState)(component);
158
165
  var needsMitosisCoreImport = Boolean(hasState || refs.length || mitosisComponents.length);
159
166
  var stringifiedUseMetadata = json5_1.default.stringify(component.meta.useMetadata);
160
167
  // TODO: smart only pull in imports as needed
161
168
  var str = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n export default function ", "(props) {\n ", "\n ", "\n\n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n "], ["\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n export default function ", "(props) {\n ", "\n ", "\n\n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n "])), !needsMitosisCoreImport
162
169
  ? ''
163
- : "import { ".concat(!hasState ? '' : 'useStore, ', " ").concat(!refs.length ? '' : 'useRef, ', " ").concat(mitosisComponents.join(', '), " } from '..';"), !otherComponents.length ? '' : "import { ".concat(otherComponents.join(','), " } from '@components';"), json.types ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({ component: json, target: 'mitosis' }), stringifiedUseMetadata && stringifiedUseMetadata !== '{}'
170
+ : "import { ".concat(!hasState ? '' : 'useStore, ', " ").concat(!refs.length ? '' : 'useRef, ', " ").concat(mitosisComponents.join(', '), " } from '..';"), !otherComponents.length ? '' : "import { ".concat(otherComponents.join(','), " } from '@components';"), json.types ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({
171
+ explicitImportFileExtension: options.explicitImportFileExtension,
172
+ component: json,
173
+ target: 'mitosis',
174
+ }), stringifiedUseMetadata && stringifiedUseMetadata !== '{}'
164
175
  ? "".concat(hooks_1.HOOKS.METADATA, "(").concat(stringifiedUseMetadata, ")")
165
176
  : '', component.name, !hasState ? '' : "const state = useStore(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");"), getRefsString(json, refs), json.hooks.onMount.map(function (hook) { return "onMount(() => { ".concat(hook.code, " })"); }), !((_b = json.hooks.onUnMount) === null || _b === void 0 ? void 0 : _b.code) ? '' : "onUnMount(() => { ".concat(json.hooks.onUnMount.code, " })"), addWrapper ? '<>' : '', json.children.map(function (item) { return (0, exports.blockToMitosis)(item, options, component); }).join('\n'), addWrapper ? '</>' : '');
177
+ if (options.plugins) {
178
+ str = (0, plugins_1.runPreCodePlugins)({ json: json, code: str, plugins: options.plugins });
179
+ }
166
180
  if (options.prettier !== false) {
167
181
  try {
168
182
  str = (0, standalone_1.format)(str, {
@@ -177,6 +191,9 @@ var componentToMitosis = function (toMitosisOptions) {
177
191
  throw err;
178
192
  }
179
193
  }
194
+ if (options.plugins) {
195
+ str = (0, plugins_1.runPostCodePlugins)({ json: json, code: str, plugins: options.plugins });
196
+ }
180
197
  return str;
181
198
  };
182
199
  };
@@ -306,6 +306,7 @@ function emitImports(file, component) {
306
306
  target: 'qwik',
307
307
  theImport: i,
308
308
  preserveFileExtensions: false,
309
+ explicitImportFileExtension: false,
309
310
  });
310
311
  Object.keys(i.imports).forEach(function (key) {
311
312
  var keyValue = i.imports[key];
@@ -1,6 +1,6 @@
1
1
  import { MitosisComponent } from '../../types/mitosis-component';
2
2
  import { File, SrcBuilder } from './src-generator';
3
- export declare type QwikOptions = {
3
+ export type QwikOptions = {
4
4
  qwikLib?: string;
5
5
  qrlPrefix?: string;
6
6
  output?: 'ts' | 'cjs' | 'mjs';
@@ -4,19 +4,19 @@ import { File } from '../src-generator';
4
4
  /**
5
5
  * Stores getters and initialization map.
6
6
  */
7
- export declare type StateInit = [
7
+ export type StateInit = [
8
8
  StateValues,
9
9
  /**
10
10
  * Set of state initializers.
11
11
  */
12
12
  ...string[]
13
13
  ];
14
- export declare type PropertyName = string;
15
- export declare type StateValue = string;
14
+ export type PropertyName = string;
15
+ export type StateValue = string;
16
16
  /**
17
17
  * Map of getters that need to be rewritten to function invocations.
18
18
  */
19
- export declare type StateValues = Record<PropertyName, StateValue>;
19
+ export type StateValues = Record<PropertyName, StateValue>;
20
20
  /**
21
21
  * @param file
22
22
  * @param stateInit
@@ -28,5 +28,5 @@ export declare function emitUseStore({ file, stateInit, isDeep, }: {
28
28
  }): void;
29
29
  export declare function emitStateMethodsAndRewriteBindings(file: File, component: MitosisComponent, metadata?: ComponentMetadata): StateInit;
30
30
  export declare function getLexicalScopeVars(component: MitosisComponent): string[];
31
- export declare type MethodMap = Record<string, 'method' | 'getter'>;
31
+ export type MethodMap = Record<string, 'method' | 'getter'>;
32
32
  export declare function getStateMethodsAndGetters(state: MitosisComponent['state']): MethodMap;
@@ -1,6 +1,6 @@
1
1
  import { MitosisNode } from '../../..';
2
2
  import { SrcBuilder } from '../src-generator';
3
- export declare type CssStyles = {
3
+ export type CssStyles = {
4
4
  CLASS_NAME: string;
5
5
  } & Record<string, string>;
6
6
  export declare function collectStyles(children: MitosisNode[], styleMap: Map<string, CssStyles>): Map<string, CssStyles>;
@@ -5,7 +5,7 @@ export interface SrcBuilderOptions {
5
5
  isJSX: boolean;
6
6
  isBuilder: boolean;
7
7
  }
8
- export declare type EmitFn = (this: SrcBuilder) => void;
8
+ export type EmitFn = (this: SrcBuilder) => void;
9
9
  export declare class File {
10
10
  filename: string;
11
11
  imports: Imports;
@@ -215,7 +215,7 @@ var componentToReact = function (reactOptions) {
215
215
  str = (0, standalone_1.format)(str, {
216
216
  parser: 'typescript',
217
217
  plugins: [
218
- require('prettier/parser-typescript'),
218
+ require('prettier/parser-typescript'), // To support running in browsers
219
219
  require('prettier/parser-postcss'),
220
220
  ],
221
221
  })
@@ -429,6 +429,7 @@ var _componentToReact = function (json, options, isSubComponent) {
429
429
  : options.stateType === 'mobx'
430
430
  ? "import { useLocalObservable, observer } from 'mobx-react-lite';"
431
431
  : '', json.types && options.typescript ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({
432
+ explicitImportFileExtension: options.explicitImportFileExtension,
432
433
  component: json,
433
434
  target: options.type === 'native' ? 'reactNative' : 'react',
434
435
  }), isForwardRef ? "const ".concat(json.name, " = forwardRef").concat(forwardRefType, "(") : '', json.name, componentArgs, componentBody, isForwardRef ? ')' : '', getPropsDefinition({ json: json }), reactNativeStyles
@@ -1,3 +1,3 @@
1
- declare type Styles = Record<string, string | number>;
1
+ type Styles = Record<string, string | number>;
2
2
  export declare const sanitizeReactNativeBlockStyles: (styles: Styles) => Styles;
3
3
  export {};
@@ -1,4 +1,4 @@
1
1
  import { TranspilerGenerator } from '../types/transpiler';
2
2
  import { ToReactOptions } from './react';
3
- export declare type ToRscOptions = ToReactOptions;
3
+ export type ToRscOptions = ToReactOptions;
4
4
  export declare const componentToRsc: TranspilerGenerator<Partial<ToRscOptions>>;
@@ -191,7 +191,11 @@ var componentToSolid = function (passedOptions) {
191
191
  var propsArgs = "props".concat(options.typescript ? ":".concat(propType) : '');
192
192
  var str = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n function ", "(", ") {\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n return (", "\n ", "\n ", "\n ", "\n ", ")\n }\n\n export default ", ";\n "], ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n function ", "(", ") {\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n return (", "\n ", "\n ", "\n ", "\n ", ")\n }\n\n export default ", ";\n "])), solidJSImports.length > 0 ? "import { ".concat(solidJSImports.join(', '), " } from 'solid-js';") : '', !foundDynamicComponents ? '' : "import { Dynamic } from 'solid-js/web';", storeImports.length > 0 ? "import { ".concat(storeImports.join(', '), " } from 'solid-js/store';") : '', !componentHasStyles && options.stylesType === 'styled-components'
193
193
  ? ''
194
- : "import { css } from \"solid-styled-components\";", json.types && options.typescript ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({ component: json, target: 'solid' }), json.name, propsArgs, (_f = state === null || state === void 0 ? void 0 : state.str) !== null && _f !== void 0 ? _f : '', getRefsString(json, options), getContextString(json, options), json.hooks.onMount.map(function (hook) { return "onMount(() => { ".concat(hook.code, " })"); }).join('\n'), json.hooks.onUpdate
194
+ : "import { css } from \"solid-styled-components\";", json.types && options.typescript ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({
195
+ explicitImportFileExtension: options.explicitImportFileExtension,
196
+ component: json,
197
+ target: 'solid',
198
+ }), json.name, propsArgs, (_f = state === null || state === void 0 ? void 0 : state.str) !== null && _f !== void 0 ? _f : '', getRefsString(json, options), getContextString(json, options), json.hooks.onMount.map(function (hook) { return "onMount(() => { ".concat(hook.code, " })"); }).join('\n'), json.hooks.onUpdate
195
199
  ? json.hooks.onUpdate
196
200
  .map(function (hook, index) {
197
201
  if (hook.deps) {
@@ -1,6 +1,6 @@
1
1
  import { MitosisComponent } from '../../../types/mitosis-component';
2
2
  import { ToSolidOptions } from '../types';
3
- declare type State = {
3
+ type State = {
4
4
  str: string;
5
5
  import: {
6
6
  store?: string[];
@@ -1,5 +1,5 @@
1
1
  import { BaseTranspilerOptions } from '../../types/transpiler';
2
- export declare type SolidState = 'mutable' | 'signals' | 'store';
2
+ export type SolidState = 'mutable' | 'signals' | 'store';
3
3
  export interface ToSolidOptions extends BaseTranspilerOptions {
4
4
  state: SolidState;
5
5
  stylesType?: 'styled-components' | 'style-tag';
@@ -142,7 +142,11 @@ var componentToStencil = function (_options) {
142
142
  *
143
143
  * export default function ...
144
144
  */
145
- , "',\n ", "\n })\n export default class ", " {\n \n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n ", "\n \n render() {\n return (", "\n \n ", "\n\n ", ")\n }\n }\n "])), (0, render_imports_1.renderPreComponent)({ component: json, target: 'stencil' }),
145
+ , "',\n ", "\n })\n export default class ", " {\n \n ", "\n\n ", "\n ", "\n \n ", "\n ", "\n ", "\n \n render() {\n return (", "\n \n ", "\n\n ", ")\n }\n }\n "])), (0, render_imports_1.renderPreComponent)({
146
+ explicitImportFileExtension: options.explicitImportFileExtension,
147
+ component: json,
148
+ target: 'stencil',
149
+ }),
146
150
  /**
147
151
  * You can set the tagName in your Mitosis component as
148
152
  *
@@ -1,7 +1,7 @@
1
1
  import { MitosisComponent } from '../../types/mitosis-component';
2
2
  import { BaseNode, MitosisNode } from '../../types/mitosis-node';
3
3
  import { ToSvelteOptions } from './types';
4
- declare type BlockToSvelte<T extends BaseNode = MitosisNode> = (props: {
4
+ type BlockToSvelte<T extends BaseNode = MitosisNode> = (props: {
5
5
  json: T;
6
6
  options: ToSvelteOptions;
7
7
  parentComponent: MitosisComponent;
@@ -275,7 +275,11 @@ var componentToSvelte = function (userProvidedOptions) {
275
275
  // make sure this is after all other state/code is initialized
276
276
  , "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), tsLangAttribute, !svelteImports.length ? '' : "import { ".concat(svelteImports.sort().join(', '), " } from 'svelte'"), !svelteStoreImports.length
277
277
  ? ''
278
- : "import { ".concat(svelteStoreImports.sort().join(', '), " } from 'svelte/store'"), (0, render_imports_1.renderPreComponent)({ component: json, target: 'svelte' }), !hasData || options.stateType === 'variables' ? '' : "import onChange from 'on-change'", props
278
+ : "import { ".concat(svelteStoreImports.sort().join(', '), " } from 'svelte/store'"), (0, render_imports_1.renderPreComponent)({
279
+ explicitImportFileExtension: options.explicitImportFileExtension,
280
+ component: json,
281
+ target: 'svelte',
282
+ }), !hasData || options.stateType === 'variables' ? '' : "import onChange from 'on-change'", props
279
283
  .map(function (name) {
280
284
  var _a, _b, _c;
281
285
  if (name === 'children') {
@@ -1,4 +1,4 @@
1
1
  import { BaseTranspilerOptions } from '../../types/transpiler';
2
- export declare type ToSvelteOptions = BaseTranspilerOptions & {
2
+ export type ToSvelteOptions = BaseTranspilerOptions & {
3
3
  stateType?: 'proxies' | 'variables';
4
4
  };
@@ -1,3 +1,3 @@
1
1
  import { BaseTranspilerOptions, TranspilerGenerator } from '../types/transpiler';
2
- export declare type ToSwiftOptions = BaseTranspilerOptions;
2
+ export type ToSwiftOptions = BaseTranspilerOptions;
3
3
  export declare const componentToSwift: TranspilerGenerator<ToSwiftOptions>;
@@ -3,7 +3,7 @@ import { MitosisComponent } from '../types/mitosis-component';
3
3
  import { TranspilerGenerator } from '../types/transpiler';
4
4
  import { ToReactOptions } from './react';
5
5
  export declare const DEFAULT_Component_SET: Set<string>;
6
- export declare type ToTaroOptions = ToReactOptions;
6
+ export type ToTaroOptions = ToReactOptions;
7
7
  export declare const collectTaroStyles: (json: MitosisComponent) => ClassStyleMap;
8
8
  export declare const TagMap: Record<string, string>;
9
9
  export declare const componentToTaro: TranspilerGenerator<Partial<ToTaroOptions>>;
@@ -1,6 +1,6 @@
1
1
  import { MitosisNode } from '../../types/mitosis-node';
2
2
  import { ToVueOptions } from './types';
3
- declare type BlockRenderer = (json: MitosisNode, options: ToVueOptions, scope?: Scope) => string;
3
+ type BlockRenderer = (json: MitosisNode, options: ToVueOptions, scope?: Scope) => string;
4
4
  interface Scope {
5
5
  isRootNode?: boolean;
6
6
  }
@@ -10,7 +10,7 @@ export declare function encodeQuotes(string: string): string;
10
10
  export declare const mapMitosisComponentToKebabCase: (componentName: string) => string;
11
11
  export declare const renameMitosisComponentsToKebabCase: (str: string) => string;
12
12
  export declare function getContextNames(json: MitosisComponent): string[];
13
- declare type ProcessBinding = {
13
+ type ProcessBinding = {
14
14
  code: string;
15
15
  options: ToVueOptions;
16
16
  json: MitosisComponent;
@@ -1,7 +1,7 @@
1
1
  import { OmitObj } from '../../helpers/typescript';
2
2
  import { BaseTranspilerOptions } from '../../types/transpiler';
3
- export declare type VueVersion = 2 | 3;
4
- export declare type Api = 'options' | 'composition';
3
+ export type VueVersion = 2 | 3;
4
+ export type Api = 'options' | 'composition';
5
5
  interface VueVersionOpt {
6
6
  vueVersion: VueVersion;
7
7
  }
@@ -12,5 +12,5 @@ export interface ToVueOptions extends BaseTranspilerOptions, VueVersionOpt {
12
12
  defineComponent?: boolean;
13
13
  api: Api;
14
14
  }
15
- export declare type VueOptsWithoutVersion = OmitObj<ToVueOptions, VueVersionOpt>;
15
+ export type VueOptsWithoutVersion = OmitObj<ToVueOptions, VueVersionOpt>;
16
16
  export {};
@@ -220,6 +220,7 @@ var componentToVue = function (userOptions) {
220
220
  var str = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n\n\n <script ", " ", ">\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n "], ["\n ", "\n\n\n <script ", " ", ">\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n "])), template.trim().length > 0
221
221
  ? "<template>\n ".concat(template, "\n </template>")
222
222
  : '', options.api === 'composition' ? 'setup' : '', tsLangAttribute, vueImports.length ? "import { ".concat((0, lodash_1.uniq)(vueImports).sort().join(', '), " } from \"vue\"") : '', (0, render_imports_1.renderPreComponent)({
223
+ explicitImportFileExtension: options.explicitImportFileExtension,
223
224
  component: component,
224
225
  target: 'vue',
225
226
  asyncComponentImports: options.asyncComponentImports,
@@ -1,7 +1,7 @@
1
1
  import * as babel from '@babel/core';
2
2
  import type { Visitor } from '@babel/traverse';
3
3
  export declare const babelTransformCode: <VisitorContextType = any>(code: string, visitor?: babel.Visitor<VisitorContextType> | undefined, stripTypes?: boolean) => string;
4
- declare type ExpressionType = 'expression' | 'unknown' | 'block' | 'functionBody';
4
+ type ExpressionType = 'expression' | 'unknown' | 'block' | 'functionBody';
5
5
  export declare const babelTransformExpression: <VisitorContextType = any>(code: string, visitor: babel.Visitor<VisitorContextType>, initialType?: ExpressionType, stripTypes?: boolean) => string;
6
6
  export declare const convertTypeScriptToJS: (code: string) => string;
7
7
  export {};
@@ -12,17 +12,19 @@ export declare const renameComponentFile: ({ path, target, options, }: {
12
12
  target: Target;
13
13
  options: MitosisConfig;
14
14
  }) => string;
15
- export declare const renameImport: ({ importPath, target }: {
15
+ export declare const renameImport: ({ importPath, target, explicitImportFileExtension, }: {
16
16
  importPath: string;
17
17
  target: Target;
18
+ explicitImportFileExtension: boolean;
18
19
  }) => string;
19
- declare type Args = {
20
+ type Args = {
20
21
  target: Target;
21
22
  } & ({
22
23
  /**
23
24
  * Whether we are rendering an import statement or a filename.
24
25
  */
25
26
  type: 'import';
27
+ explicitImportFileExtension: boolean;
26
28
  } | {
27
29
  /**
28
30
  * Whether we are rendering an import statement or a filename.
@@ -39,10 +39,11 @@ exports.renameComponentFile = renameComponentFile;
39
39
  */
40
40
  var INPUT_EXTENSION_IMPORT_REGEX = /\.(svelte|(lite(\.tsx|\.jsx)?))(?<quote>['"])/g;
41
41
  var renameImport = function (_a) {
42
- var importPath = _a.importPath, target = _a.target;
42
+ var importPath = _a.importPath, target = _a.target, explicitImportFileExtension = _a.explicitImportFileExtension;
43
43
  return importPath.replace(INPUT_EXTENSION_IMPORT_REGEX, "".concat((0, exports.getComponentFileExtensionForTarget)({
44
44
  type: 'import',
45
45
  target: target,
46
+ explicitImportFileExtension: explicitImportFileExtension,
46
47
  }), "$4"));
47
48
  };
48
49
  exports.renameImport = renameImport;
@@ -87,7 +88,7 @@ var getComponentFileExtensionForTarget = function (args) {
87
88
  switch (args.type) {
88
89
  case 'import':
89
90
  // we can't have `.jsx`/`.tsx` extensions in the import paths, so we stick with implicit file extensions.
90
- return '';
91
+ return args.explicitImportFileExtension ? '.js' : '';
91
92
  case 'filename':
92
93
  return args.isTypescript ? '.tsx' : '.jsx';
93
94
  }
@@ -1,6 +1,6 @@
1
1
  import { MitosisComponent } from '../types/mitosis-component';
2
2
  import { Overwrite, Prettify } from './typescript';
3
- declare type PartialMitosisComponent = Prettify<Overwrite<Partial<MitosisComponent>, {
3
+ type PartialMitosisComponent = Prettify<Overwrite<Partial<MitosisComponent>, {
4
4
  hooks: Partial<MitosisComponent['hooks']>;
5
5
  }>>;
6
6
  export declare const createMitosisComponent: (options?: PartialMitosisComponent) => MitosisComponent;
@@ -1,6 +1,6 @@
1
1
  import { MitosisComponent } from '../types/mitosis-component';
2
2
  import { MitosisContext } from '../types/mitosis-context';
3
- declare type ValueMapper = (code: string, type: 'data' | 'function' | 'getter', typeParameter: string | undefined, key: string | undefined) => string;
3
+ type ValueMapper = (code: string, type: 'data' | 'function' | 'getter', typeParameter: string | undefined, key: string | undefined) => string;
4
4
  interface GetStateObjectStringOptions {
5
5
  data?: boolean;
6
6
  functions?: boolean;
@@ -1,3 +1,3 @@
1
- declare type ParsedJson = any;
1
+ type ParsedJson = any;
2
2
  export declare const tryParseJson: (jsonStr: string) => ParsedJson;
3
3
  export {};
@@ -1,3 +1,3 @@
1
1
  import { MitosisComponent } from '../types/mitosis-component';
2
- export declare type RefMapper = (refName: string) => string;
2
+ export type RefMapper = (refName: string) => string;
3
3
  export declare const mapRefs: (component: MitosisComponent, mapper: RefMapper) => void;
@@ -1,2 +1,2 @@
1
- export declare type Nullable<X> = X | null | undefined;
1
+ export type Nullable<X> = X | null | undefined;
2
2
  export declare const checkIsDefined: <T>(value: Nullable<T>) => value is NonNullable<T>;
@@ -7,6 +7,6 @@ export declare const createCodeProcessorPlugin: (codeProcessor: CodeProcessor, {
7
7
  /**
8
8
  * Given a `codeProcessor` function, processes all code expressions within a Mitosis component.
9
9
  */
10
- export declare const CODE_PROCESSOR_PLUGIN: (a_0: (codeType: import("./types").CodeType, json: MitosisComponent, node?: import("../../..").MitosisNode | undefined) => (code: string, hookType: string) => string | (() => void), a_1?: {
10
+ export declare const CODE_PROCESSOR_PLUGIN: (codeProcessor: (codeType: import("./types").CodeType, json: MitosisComponent, node?: import("../../..").MitosisNode | undefined) => (code: string, hookType: string) => string | (() => void), a_1?: {
11
11
  processProperties?: boolean | undefined;
12
12
  } | undefined) => Plugin;
@@ -1,6 +1,6 @@
1
1
  import { MitosisComponent } from '../../../types/mitosis-component';
2
2
  import { MitosisNode } from '../../../types/mitosis-node';
3
- export declare type CodeType = 'hooks' | 'hooks-deps' | 'bindings' | 'properties' | 'state' | 'types' | 'context-set' | 'dynamic-jsx-elements';
3
+ export type CodeType = 'hooks' | 'hooks-deps' | 'bindings' | 'properties' | 'state' | 'types' | 'context-set' | 'dynamic-jsx-elements';
4
4
  declare function codeProcessor(codeType: CodeType, json: MitosisComponent, node?: MitosisNode): (code: string, hookType: string) => string | (() => void);
5
- export declare type CodeProcessor = typeof codeProcessor;
5
+ export type CodeProcessor = typeof codeProcessor;
6
6
  export {};
@@ -103,6 +103,8 @@ var getSignalMapperForTarget = function (target) {
103
103
  return {
104
104
  getter: function (name) { return core_1.types.identifier('$' + name); },
105
105
  };
106
+ case 'preact':
107
+ case 'reactNative':
106
108
  case 'react':
107
109
  case 'solid':
108
110
  return {
@@ -1,37 +1,36 @@
1
1
  import { Target } from '../types/config';
2
2
  import { MitosisComponent, MitosisImport } from '../types/mitosis-component';
3
3
  export declare const checkIsComponentImport: (theImport: MitosisImport) => boolean;
4
- export declare const transformImportPath: ({ theImport, target, preserveFileExtensions, }: {
4
+ export declare const transformImportPath: ({ theImport, target, preserveFileExtensions, explicitImportFileExtension, }: {
5
5
  theImport: MitosisImport;
6
6
  target: Target;
7
7
  preserveFileExtensions: boolean;
8
+ explicitImportFileExtension: boolean;
8
9
  }) => string;
9
- export declare const renderImport: ({ theImport, target, asyncComponentImports, preserveFileExtensions, component, componentsUsed, importMapper, }: {
10
- theImport: MitosisImport;
10
+ type ImportArgs = {
11
11
  target: Target;
12
12
  asyncComponentImports: boolean;
13
- preserveFileExtensions?: boolean | undefined;
13
+ preserveFileExtensions?: boolean;
14
14
  component?: MitosisComponent | null | undefined;
15
- componentsUsed?: string[] | undefined;
16
- importMapper?: Function | null | undefined;
17
- }) => string;
18
- export declare const renderImports: ({ imports, target, asyncComponentImports, excludeMitosisComponents, preserveFileExtensions, component, componentsUsed, importMapper, }: {
19
- imports: MitosisImport[];
20
- target: Target;
21
- asyncComponentImports: boolean;
22
- excludeMitosisComponents?: boolean | undefined;
23
- preserveFileExtensions?: boolean | undefined;
24
- component: MitosisComponent;
25
- componentsUsed?: string[] | undefined;
15
+ /**
16
+ * This is only used by Angular generator, and will be deprecated in the future.
17
+ */
26
18
  importMapper?: Function | null | undefined;
19
+ /**
20
+ * This is only used by Angular generator, and will be deprecated in the future.
21
+ */
22
+ explicitImportFileExtension?: boolean;
23
+ /**
24
+ * This is only used by Angular generator, and will be deprecated in the future.
25
+ */
26
+ componentsUsed?: string[];
27
+ };
28
+ export declare const renderImport: ({ theImport, target, asyncComponentImports, preserveFileExtensions, component, componentsUsed, importMapper, explicitImportFileExtension, }: ImportArgs & {
29
+ theImport: MitosisImport;
27
30
  }) => string;
28
- export declare const renderPreComponent: ({ component, target, excludeMitosisComponents, asyncComponentImports, preserveFileExtensions, componentsUsed, importMapper, }: {
31
+ export declare const renderPreComponent: ({ component, target, excludeMitosisComponents, asyncComponentImports, preserveFileExtensions, componentsUsed, importMapper, explicitImportFileExtension, }: Omit<ImportArgs, "asyncComponentImports" | "explicitImportFileExtension"> & Partial<Pick<ImportArgs, "asyncComponentImports" | "explicitImportFileExtension">> & {
29
32
  component: MitosisComponent;
30
33
  target: Target;
31
- asyncComponentImports?: boolean | undefined;
32
34
  excludeMitosisComponents?: boolean | undefined;
33
- preserveFileExtensions?: boolean | undefined;
34
- componentsUsed?: string[] | undefined;
35
- importMapper?: Function | null | undefined;
36
35
  }) => string;
37
- export declare const renderExportAndLocal: (component: MitosisComponent) => string;
36
+ export {};