@builder.io/mitosis 0.0.56-81 → 0.0.56-84
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/generators/angular.js +9 -9
- package/dist/src/generators/html.d.ts +0 -7
- package/dist/src/generators/html.js +24 -24
- package/dist/src/generators/svelte.js +11 -9
- package/dist/src/parsers/builder.d.ts +0 -2
- package/dist/src/parsers/jsx/component-types.d.ts +0 -1
- package/dist/src/parsers/jsx/component-types.js +2 -9
- package/dist/src/parsers/jsx/jsx.js +3 -6
- package/dist/src/parsers/jsx/state.js +0 -2
- package/dist/src/types/mitosis-component.d.ts +0 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/__tests__/angular.test.d.ts +0 -1
- package/dist/src/__tests__/angular.test.js +0 -10
- package/dist/src/__tests__/builder.test.d.ts +0 -1
- package/dist/src/__tests__/builder.test.js +0 -235
- package/dist/src/__tests__/context.test.d.ts +0 -1
- package/dist/src/__tests__/context.test.js +0 -35
- package/dist/src/__tests__/data/context/component-with-context.lite.d.ts +0 -3
- package/dist/src/__tests__/data/context/component-with-context.lite.jsx +0 -21
- package/dist/src/__tests__/data/context/simple.context.lite.d.ts +0 -9
- package/dist/src/__tests__/data/context/simple.context.lite.js +0 -15
- package/dist/src/__tests__/data/nested-styles.lite.d.ts +0 -1
- package/dist/src/__tests__/data/nested-styles.lite.jsx +0 -20
- package/dist/src/__tests__/data/types/foo-type.d.ts +0 -1
- package/dist/src/__tests__/data/types/foo-type.js +0 -2
- package/dist/src/__tests__/data/types/type-export.lite.d.ts +0 -3
- package/dist/src/__tests__/data/types/type-export.lite.jsx +0 -6
- package/dist/src/__tests__/hash-code.test.d.ts +0 -1
- package/dist/src/__tests__/hash-code.test.js +0 -11
- package/dist/src/__tests__/html.test.d.ts +0 -1
- package/dist/src/__tests__/html.test.js +0 -7
- package/dist/src/__tests__/liquid.test.d.ts +0 -1
- package/dist/src/__tests__/liquid.test.js +0 -7
- package/dist/src/__tests__/lit.test.d.ts +0 -1
- package/dist/src/__tests__/lit.test.js +0 -7
- package/dist/src/__tests__/marko.test.d.ts +0 -1
- package/dist/src/__tests__/marko.test.js +0 -14
- package/dist/src/__tests__/parse-jsx.test.d.ts +0 -1
- package/dist/src/__tests__/parse-jsx.test.js +0 -37
- package/dist/src/__tests__/qwik/convert-method-to-function.test.d.ts +0 -1
- package/dist/src/__tests__/qwik/convert-method-to-function.test.js +0 -37
- package/dist/src/__tests__/qwik/src-generator.test.d.ts +0 -1
- package/dist/src/__tests__/qwik/src-generator.test.js +0 -65
- package/dist/src/__tests__/qwik.directive.test.d.ts +0 -1
- package/dist/src/__tests__/qwik.directive.test.js +0 -108
- package/dist/src/__tests__/qwik.test.d.ts +0 -1
- package/dist/src/__tests__/qwik.test.js +0 -465
- package/dist/src/__tests__/react-native.test.d.ts +0 -1
- package/dist/src/__tests__/react-native.test.js +0 -7
- package/dist/src/__tests__/react.test.d.ts +0 -1
- package/dist/src/__tests__/react.test.js +0 -20
- package/dist/src/__tests__/shared.d.ts +0 -3
- package/dist/src/__tests__/shared.js +0 -305
- package/dist/src/__tests__/solid.test.d.ts +0 -1
- package/dist/src/__tests__/solid.test.js +0 -10
- package/dist/src/__tests__/stencil.test.d.ts +0 -1
- package/dist/src/__tests__/stencil.test.js +0 -7
- package/dist/src/__tests__/styles.test.d.ts +0 -1
- package/dist/src/__tests__/styles.test.js +0 -23
- package/dist/src/__tests__/svelte.test.d.ts +0 -1
- package/dist/src/__tests__/svelte.test.js +0 -7
- package/dist/src/__tests__/vue.test.d.ts +0 -1
- package/dist/src/__tests__/vue.test.js +0 -7
- package/dist/src/__tests__/webcomponent.test.d.ts +0 -1
- package/dist/src/__tests__/webcomponent.test.js +0 -15
- package/dist/src/constants/html_tags.d.ts +0 -1
- package/dist/src/constants/html_tags.js +0 -119
- package/dist/src/generators/context/qwik.d.ts +0 -8
- package/dist/src/generators/context/qwik.js +0 -27
- package/dist/src/generators/context/react.d.ts +0 -8
- package/dist/src/generators/context/react.js +0 -28
- package/dist/src/generators/context/solid.d.ts +0 -8
- package/dist/src/generators/context/solid.js +0 -28
- package/dist/src/generators/context/svelte.d.ts +0 -8
- package/dist/src/generators/context/svelte.js +0 -28
- package/dist/src/generators/context/vue.d.ts +0 -6
- package/dist/src/generators/context/vue.js +0 -9
- package/dist/src/generators/helpers/context.d.ts +0 -2
- package/dist/src/generators/helpers/context.js +0 -7
- package/dist/src/generators/lit/collect-class-string.d.ts +0 -2
- package/dist/src/generators/lit/collect-class-string.js +0 -43
- package/dist/src/generators/lit/generate.d.ts +0 -4
- package/dist/src/generators/lit/generate.js +0 -204
- package/dist/src/generators/lit/index.d.ts +0 -1
- package/dist/src/generators/lit/index.js +0 -17
- package/dist/src/generators/marko/generate.d.ts +0 -21
- package/dist/src/generators/marko/generate.js +0 -298
- package/dist/src/generators/marko/index.d.ts +0 -1
- package/dist/src/generators/marko/index.js +0 -17
- package/dist/src/generators/mitosis.d.ts +0 -9
- package/dist/src/generators/mitosis.js +0 -183
- package/dist/src/generators/qwik/add-prevent-default.d.ts +0 -7
- package/dist/src/generators/qwik/add-prevent-default.js +0 -32
- package/dist/src/generators/qwik/component-generator.d.ts +0 -4
- package/dist/src/generators/qwik/component-generator.js +0 -305
- package/dist/src/generators/qwik/component.d.ts +0 -22
- package/dist/src/generators/qwik/component.js +0 -180
- package/dist/src/generators/qwik/convert-method-to-function.d.ts +0 -1
- package/dist/src/generators/qwik/convert-method-to-function.js +0 -162
- package/dist/src/generators/qwik/directives.d.ts +0 -31
- package/dist/src/generators/qwik/directives.js +0 -138
- package/dist/src/generators/qwik/handlers.d.ts +0 -4
- package/dist/src/generators/qwik/handlers.js +0 -69
- package/dist/src/generators/qwik/index.d.ts +0 -4
- package/dist/src/generators/qwik/index.js +0 -11
- package/dist/src/generators/qwik/jsx.d.ts +0 -16
- package/dist/src/generators/qwik/jsx.js +0 -218
- package/dist/src/generators/qwik/src-generator.d.ts +0 -86
- package/dist/src/generators/qwik/src-generator.js +0 -579
- package/dist/src/generators/qwik/styles.d.ts +0 -7
- package/dist/src/generators/qwik/styles.js +0 -91
- package/dist/src/generators/react-native.d.ts +0 -9
- package/dist/src/generators/react-native.js +0 -110
- package/dist/src/generators/react.d.ts +0 -14
- package/dist/src/generators/react.js +0 -531
- package/dist/src/generators/solid.d.ts +0 -5
- package/dist/src/generators/solid.js +0 -306
- package/dist/src/generators/stencil/collect-class-string.d.ts +0 -2
- package/dist/src/generators/stencil/collect-class-string.js +0 -43
- package/dist/src/generators/stencil/generate.d.ts +0 -4
- package/dist/src/generators/stencil/generate.js +0 -182
- package/dist/src/generators/stencil/index.d.ts +0 -1
- package/dist/src/generators/stencil/index.js +0 -17
- package/dist/src/generators/swift-ui.d.ts +0 -5
- package/dist/src/generators/swift-ui.js +0 -271
- package/dist/src/generators/template.d.ts +0 -4
- package/dist/src/generators/template.js +0 -135
- package/dist/src/generators/vue.d.ts +0 -21
- package/dist/src/generators/vue.js +0 -548
- package/dist/src/helpers/babel-transform.test.d.ts +0 -1
- package/dist/src/helpers/babel-transform.test.js +0 -7
- package/dist/src/helpers/camel-case.d.ts +0 -8
- package/dist/src/helpers/camel-case.js +0 -18
- package/dist/src/helpers/generic-format.d.ts +0 -6
- package/dist/src/helpers/generic-format.js +0 -36
- package/dist/src/helpers/generic-format.test.d.ts +0 -1
- package/dist/src/helpers/generic-format.test.js +0 -8
- package/dist/src/helpers/get-components.d.ts +0 -2
- package/dist/src/helpers/get-components.js +0 -21
- package/dist/src/helpers/get-state-used.d.ts +0 -5
- package/dist/src/helpers/get-state-used.js +0 -29
- package/dist/src/helpers/get-styles.d.ts +0 -4
- package/dist/src/helpers/get-styles.js +0 -33
- package/dist/src/helpers/getters-to-functions.d.ts +0 -5
- package/dist/src/helpers/getters-to-functions.js +0 -50
- package/dist/src/helpers/handle-missing-state.d.ts +0 -2
- package/dist/src/helpers/handle-missing-state.js +0 -13
- package/dist/src/helpers/has.d.ts +0 -9
- package/dist/src/helpers/has.js +0 -27
- package/dist/src/helpers/html-escape.d.ts +0 -1
- package/dist/src/helpers/html-escape.js +0 -7
- package/dist/src/helpers/is-valid-attribute-name.d.ts +0 -1
- package/dist/src/helpers/is-valid-attribute-name.js +0 -7
- package/dist/src/helpers/parse-node.d.ts +0 -2
- package/dist/src/helpers/parse-node.js +0 -12
- package/dist/src/helpers/parse-reactive-script.d.ts +0 -7
- package/dist/src/helpers/parse-reactive-script.js +0 -87
- package/dist/src/helpers/process-http-requests.d.ts +0 -2
- package/dist/src/helpers/process-http-requests.js +0 -21
- package/dist/src/helpers/process-tag-references.d.ts +0 -2
- package/dist/src/helpers/process-tag-references.js +0 -31
- package/dist/src/helpers/remove-surrounding-block.test.d.ts +0 -1
- package/dist/src/helpers/remove-surrounding-block.test.js +0 -9
- package/dist/src/helpers/render-imports.d.ts +0 -20
- package/dist/src/helpers/render-imports.js +0 -156
- package/dist/src/helpers/render-imports.test.d.ts +0 -1
- package/dist/src/helpers/render-imports.test.js +0 -33
- package/dist/src/helpers/styles/collect-css.test.d.ts +0 -1
- package/dist/src/helpers/styles/collect-css.test.js +0 -18
- package/dist/src/helpers/styles/collect-styled-components.d.ts +0 -2
- package/dist/src/helpers/styles/collect-styled-components.js +0 -61
- package/dist/src/helpers/traverse-nodes.d.ts +0 -4
- package/dist/src/helpers/traverse-nodes.js +0 -16
- package/dist/src/helpers/try-prettier-format.d.ts +0 -1
- package/dist/src/helpers/try-prettier-format.js +0 -24
- package/dist/src/index.d.ts +0 -59
- package/dist/src/index.js +0 -98
- package/dist/src/parsers/html.d.ts +0 -0
- package/dist/src/parsers/html.js +0 -2
- package/dist/src/plugins/compile-away-builder-components.d.ts +0 -18
- package/dist/src/plugins/compile-away-builder-components.js +0 -562
- package/dist/src/plugins/compile-away-components.d.ts +0 -33
- package/dist/src/plugins/compile-away-components.js +0 -58
- package/dist/src/plugins/map-styles.d.ts +0 -12
- package/dist/src/plugins/map-styles.js +0 -16
- package/dist/src/targets.d.ts +0 -30
- package/dist/src/targets.js +0 -43
- package/dist/src/types/config.d.ts +0 -54
- package/dist/src/types/config.js +0 -2
- package/dist/src/types/mitosis-styles.d.ts +0 -1
- package/dist/src/types/mitosis-styles.js +0 -2
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -193,14 +193,14 @@ exports.blockToAngular = blockToAngular;
|
|
|
193
193
|
var componentToAngular = function (options) {
|
|
194
194
|
if (options === void 0) { options = {}; }
|
|
195
195
|
return function (_a) {
|
|
196
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
196
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
197
197
|
var component = _a.component;
|
|
198
198
|
// Make a copy we can safely mutate, similar to babel's toolchain
|
|
199
199
|
var json = (0, fast_clone_1.fastClone)(component);
|
|
200
200
|
if (options.plugins) {
|
|
201
201
|
json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
|
|
202
202
|
}
|
|
203
|
-
var
|
|
203
|
+
var _o = (0, get_props_ref_1.getPropsRef)(json, true), forwardProp = _o[0], hasPropRef = _o[1];
|
|
204
204
|
var childComponents = [];
|
|
205
205
|
var propsTypeRef = json.propsTypeRef !== 'any' ? json.propsTypeRef : undefined;
|
|
206
206
|
json.imports.forEach(function (_a) {
|
|
@@ -212,7 +212,7 @@ var componentToAngular = function (options) {
|
|
|
212
212
|
});
|
|
213
213
|
});
|
|
214
214
|
var customImports = (0, get_custom_imports_1.getCustomImports)(json);
|
|
215
|
-
var
|
|
215
|
+
var _p = component.exports, localExports = _p === void 0 ? {} : _p;
|
|
216
216
|
var localExportVars = Object.keys(localExports)
|
|
217
217
|
.filter(function (key) { return localExports[key].usedInLocal; })
|
|
218
218
|
.map(function (key) { return "".concat(key, " = ").concat(key, ";"); });
|
|
@@ -289,7 +289,7 @@ var componentToAngular = function (options) {
|
|
|
289
289
|
});
|
|
290
290
|
},
|
|
291
291
|
});
|
|
292
|
-
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n ", "\n ", "\n
|
|
292
|
+
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { ", " ", " Component ", "", " } from '@angular/core';\n ", "\n\n ", "\n ", "\n\n @Component({\n ", "\n selector: '", "',\n template: `\n ", "\n `,\n ", "\n })\n export default 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 @Component({\n ", "\n selector: '", "',\n template: \\`\n ", "\n \\`,\n ", "\n })\n export default 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' : '', ((_g = options === null || options === void 0 ? void 0 : options.experimental) === null || _g === void 0 ? void 0 : _g.inject) ? 'Inject, forwardRef,' : '', domRefs.size ? ', ViewChild, ElementRef' : '', props.size ? ', Input' : '', options.standalone ? "import { CommonModule } from '@angular/common';" : '', json.types ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({
|
|
293
293
|
component: json,
|
|
294
294
|
target: 'angular',
|
|
295
295
|
excludeMitosisComponents: !options.standalone,
|
|
@@ -322,23 +322,23 @@ var componentToAngular = function (options) {
|
|
|
322
322
|
})
|
|
323
323
|
.join('\n'), !hasConstructor
|
|
324
324
|
? ''
|
|
325
|
-
: "constructor(\n".concat(injectables.join(',\n'), ") {\n ").concat(!((
|
|
325
|
+
: "constructor(\n".concat(injectables.join(',\n'), ") {\n ").concat(!((_h = component.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
|
|
326
326
|
? ''
|
|
327
|
-
: "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((
|
|
327
|
+
: "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_j = component.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code, {
|
|
328
328
|
replaceWith: 'this.',
|
|
329
329
|
contextVars: contextVars,
|
|
330
330
|
outputVars: outputVars,
|
|
331
331
|
}), "\n "), "\n }\n "), !hasOnMount
|
|
332
332
|
? ''
|
|
333
|
-
: "ngOnInit() {\n \n ".concat(!((
|
|
333
|
+
: "ngOnInit() {\n \n ".concat(!((_k = component.hooks) === null || _k === void 0 ? void 0 : _k.onMount)
|
|
334
334
|
? ''
|
|
335
|
-
: "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((
|
|
335
|
+
: "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_l = component.hooks.onMount) === null || _l === void 0 ? void 0 : _l.code, {
|
|
336
336
|
replaceWith: 'this.',
|
|
337
337
|
contextVars: contextVars,
|
|
338
338
|
outputVars: outputVars,
|
|
339
339
|
domRefs: Array.from(domRefs),
|
|
340
340
|
stateVars: stateVars,
|
|
341
|
-
}), "\n "), "\n }"), !((
|
|
341
|
+
}), "\n "), "\n }"), !((_m = component.hooks.onUpdate) === null || _m === void 0 ? void 0 : _m.length)
|
|
342
342
|
? ''
|
|
343
343
|
: "ngAfterContentChecked() {\n ".concat(component.hooks.onUpdate.reduce(function (code, hook) {
|
|
344
344
|
code += (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(hook.code, {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BaseTranspilerOptions, Transpiler } from '../types/transpiler';
|
|
2
|
-
export interface ToHtmlOptions extends BaseTranspilerOptions {
|
|
3
|
-
format?: 'class' | 'script';
|
|
4
|
-
prefix?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const componentToHtml: (options?: ToHtmlOptions) => Transpiler;
|
|
7
|
-
export declare const componentToCustomElement: (options?: ToHtmlOptions) => Transpiler;
|
|
@@ -485,7 +485,7 @@ exports.componentToHtml = componentToHtml;
|
|
|
485
485
|
var componentToCustomElement = function (options) {
|
|
486
486
|
if (options === void 0) { options = {}; }
|
|
487
487
|
return function (_a) {
|
|
488
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14
|
|
488
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
|
489
489
|
var component = _a.component;
|
|
490
490
|
var ComponentName = component.name;
|
|
491
491
|
var kebabName = (0, lodash_2.kebabCase)(ComponentName);
|
|
@@ -494,7 +494,7 @@ var componentToCustomElement = function (options) {
|
|
|
494
494
|
if (options.plugins) {
|
|
495
495
|
json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
|
|
496
496
|
}
|
|
497
|
-
var
|
|
497
|
+
var _15 = (0, get_props_ref_1.getPropsRef)(json, true), forwardProp = _15[0], hasPropRef = _15[1];
|
|
498
498
|
var contextVars = Object.keys(((_b = json === null || json === void 0 ? void 0 : json.context) === null || _b === void 0 ? void 0 : _b.get) || {});
|
|
499
499
|
var childComponents = getChildComponents(json, useOptions);
|
|
500
500
|
var componentHasProps = (0, has_props_1.hasProps)(json);
|
|
@@ -518,7 +518,7 @@ var componentToCustomElement = function (options) {
|
|
|
518
518
|
});
|
|
519
519
|
var setContext = [];
|
|
520
520
|
for (var key in json.context.set) {
|
|
521
|
-
var
|
|
521
|
+
var _16 = json.context.set[key], name_1 = _16.name, value = _16.value, ref = _16.ref;
|
|
522
522
|
setContext.push({ name: name_1, value: value, ref: ref });
|
|
523
523
|
}
|
|
524
524
|
addUpdateAfterSet(json, useOptions);
|
|
@@ -581,17 +581,17 @@ var componentToCustomElement = function (options) {
|
|
|
581
581
|
console.warn('Could not prettify', { string: html }, err);
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
|
-
var str = "\n ".concat(json.types ? json.types.join('\n') : '', "\n ").concat(
|
|
585
|
-
? (
|
|
584
|
+
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 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _j === void 0 ? void 0 : _j.classExtends)
|
|
585
|
+
? (_k = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _k === void 0 ? void 0 : _k.classExtends(json, useOptions)
|
|
586
586
|
: 'HTMLElement', " {\n ").concat(Array.from(domRefs)
|
|
587
587
|
.map(function (ref) {
|
|
588
588
|
return "\n get _".concat(ref, "() {\n return this._root.querySelector(\"[data-ref='").concat(ComponentName, "-").concat(ref, "']\")\n }\n ");
|
|
589
589
|
})
|
|
590
590
|
.join('\n'), "\n\n get _root() {\n return this.shadowRoot || this;\n }\n\n constructor() {\n super();\n const self = this;\n ").concat(
|
|
591
591
|
// TODO: more than one context not injector
|
|
592
|
-
setContext.length === 1 && ((
|
|
592
|
+
setContext.length === 1 && ((_l = setContext === null || setContext === void 0 ? void 0 : setContext[0]) === null || _l === void 0 ? void 0 : _l.ref)
|
|
593
593
|
? "this.context = ".concat(setContext[0].ref)
|
|
594
|
-
: '', "\n\n ").concat(!((
|
|
594
|
+
: '', "\n\n ").concat(!((_o = (_m = json.hooks) === null || _m === void 0 ? void 0 : _m.onInit) === null || _o === void 0 ? void 0 : _o.code) ? '' : 'this.onInitOnce = false;', "\n\n this.state = ").concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
|
|
595
595
|
valueMapper: function (value) {
|
|
596
596
|
return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(addUpdateAfterSetInCode(value, useOptions, 'self.update'), {
|
|
597
597
|
includeProps: false,
|
|
@@ -612,10 +612,10 @@ var componentToCustomElement = function (options) {
|
|
|
612
612
|
? ''
|
|
613
613
|
: "\n this.componentProps = [".concat(Array.from(props)
|
|
614
614
|
.map(function (prop) { return "\"".concat(prop, "\""); })
|
|
615
|
-
.join(','), "];\n "), "\n\n ").concat(!((
|
|
615
|
+
.join(','), "];\n "), "\n\n ").concat(!((_p = json.hooks.onUpdate) === null || _p === void 0 ? void 0 : _p.length)
|
|
616
616
|
? ''
|
|
617
|
-
: "\n this.updateDeps = [".concat((
|
|
618
|
-
? (
|
|
617
|
+
: "\n this.updateDeps = [".concat((_q = json.hooks.onUpdate) === null || _q === void 0 ? void 0 : _q.map(function (hook) { return updateReferencesInCode((hook === null || hook === void 0 ? void 0 : hook.deps) || '[]', useOptions); }).join(','), "];\n "), "\n\n // used to keep track of all nodes created by show/for\n this.nodesToDestroy = [];\n // batch updates\n this.pendingUpdate = false;\n ").concat(((_r = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _r === void 0 ? void 0 : _r.componentConstructor)
|
|
618
|
+
? (_s = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _s === void 0 ? void 0 : _s.componentConstructor(json, useOptions)
|
|
619
619
|
: '', "\n\n ").concat(useOptions.js, "\n\n ").concat(jsRefs
|
|
620
620
|
.map(function (ref) {
|
|
621
621
|
var _a;
|
|
@@ -623,32 +623,32 @@ var componentToCustomElement = function (options) {
|
|
|
623
623
|
var argument = ((_a = json['refs'][ref]) === null || _a === void 0 ? void 0 : _a.argument) || 'null';
|
|
624
624
|
return "this._".concat(ref, " = ").concat(argument);
|
|
625
625
|
})
|
|
626
|
-
.join('\n'), "\n\n if (").concat((
|
|
626
|
+
.join('\n'), "\n\n if (").concat((_t = json.meta.useMetadata) === null || _t === void 0 ? void 0 : _t.isAttachedToShadowDom, ") {\n this.attachShadow({ mode: 'open' })\n }\n }\n\n\n ").concat(!((_u = json.hooks.onUnMount) === null || _u === void 0 ? void 0 : _u.code)
|
|
627
627
|
? ''
|
|
628
|
-
: "\n disconnectedCallback() {\n ".concat(((
|
|
629
|
-
? (
|
|
628
|
+
: "\n disconnectedCallback() {\n ".concat(((_v = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _v === void 0 ? void 0 : _v.disconnectedCallback)
|
|
629
|
+
? (_w = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _w === void 0 ? void 0 : _w.disconnectedCallback(json, useOptions)
|
|
630
630
|
: "\n // onUnMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onUnMount.code, useOptions), useOptions, {
|
|
631
631
|
contextVars: contextVars,
|
|
632
|
-
}), "\n this.destroyAnyNodes(); // clean up nodes when component is destroyed\n ").concat(!((
|
|
632
|
+
}), "\n this.destroyAnyNodes(); // clean up nodes when component is destroyed\n ").concat(!((_y = (_x = json.hooks) === null || _x === void 0 ? void 0 : _x.onInit) === null || _y === void 0 ? void 0 : _y.code) ? '' : 'this.onInitOnce = false;', "\n "), "\n }\n "), "\n\n destroyAnyNodes() {\n // destroy current view template refs before rendering again\n this.nodesToDestroy.forEach(el => el.remove());\n this.nodesToDestroy = [];\n }\n\n connectedCallback() {\n ").concat(context.join('\n'), "\n ").concat(!componentHasProps
|
|
633
633
|
? ''
|
|
634
|
-
: "\n this.getAttributeNames().forEach((attr) => {\n const jsVar = attr.replace(/-/g, '');\n const regexp = new RegExp(jsVar, 'i');\n this.componentProps.forEach(prop => {\n if (regexp.test(prop)) {\n const attrValue = this.getAttribute(attr);\n if (this.props[prop] !== attrValue) {\n this.props[prop] = attrValue;\n }\n }\n });\n });\n ", "\n ").concat(((
|
|
635
|
-
? (
|
|
636
|
-
: "\n this._root.innerHTML = `\n ".concat(html, "`;\n this.pendingUpdate = true;\n ").concat(!((
|
|
634
|
+
: "\n this.getAttributeNames().forEach((attr) => {\n const jsVar = attr.replace(/-/g, '');\n const regexp = new RegExp(jsVar, 'i');\n this.componentProps.forEach(prop => {\n if (regexp.test(prop)) {\n const attrValue = this.getAttribute(attr);\n if (this.props[prop] !== attrValue) {\n this.props[prop] = attrValue;\n }\n }\n });\n });\n ", "\n ").concat(((_z = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _z === void 0 ? void 0 : _z.connectedCallbackUpdate)
|
|
635
|
+
? (_0 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _0 === void 0 ? void 0 : _0.connectedCallbackUpdate(json, html, useOptions)
|
|
636
|
+
: "\n this._root.innerHTML = `\n ".concat(html, "`;\n this.pendingUpdate = true;\n ").concat(!((_2 = (_1 = json.hooks) === null || _1 === void 0 ? void 0 : _1.onInit) === null || _2 === void 0 ? void 0 : _2.code) ? '' : 'this.onInit();', "\n this.render();\n this.onMount();\n this.pendingUpdate = false;\n this.update();\n "), "\n }\n ").concat(!((_4 = (_3 = json.hooks) === null || _3 === void 0 ? void 0 : _3.onInit) === null || _4 === void 0 ? void 0 : _4.code)
|
|
637
637
|
? ''
|
|
638
|
-
: "\n onInit() {\n ".concat(!((
|
|
638
|
+
: "\n onInit() {\n ".concat(!((_6 = (_5 = json.hooks) === null || _5 === void 0 ? void 0 : _5.onInit) === null || _6 === void 0 ? void 0 : _6.code)
|
|
639
639
|
? ''
|
|
640
|
-
: "\n if (!this.onInitOnce) {\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode((
|
|
640
|
+
: "\n if (!this.onInitOnce) {\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode((_8 = (_7 = json.hooks) === null || _7 === void 0 ? void 0 : _7.onInit) === null || _8 === void 0 ? void 0 : _8.code, useOptions), useOptions, {
|
|
641
641
|
contextVars: contextVars,
|
|
642
642
|
}), "\n this.onInitOnce = true;\n }"), "\n }\n "), "\n\n ").concat(!hasShow
|
|
643
643
|
? ''
|
|
644
|
-
: "\n showContent(el) {\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content\n // grabs the content of a node that is between <template> tags\n // iterates through child nodes to register all content including text elements\n // attaches the content after the template\n \n \n const elementFragment = el.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n children.forEach(child => {\n if (el?.scope) {\n child.scope = el.scope;\n }\n if (el?.context) {\n child.context = el.context;\n }\n this.nodesToDestroy.push(child);\n });\n el.after(elementFragment);\n }", "\n ").concat(!((
|
|
644
|
+
: "\n showContent(el) {\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content\n // grabs the content of a node that is between <template> tags\n // iterates through child nodes to register all content including text elements\n // attaches the content after the template\n \n \n const elementFragment = el.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n children.forEach(child => {\n if (el?.scope) {\n child.scope = el.scope;\n }\n if (el?.context) {\n child.context = el.context;\n }\n this.nodesToDestroy.push(child);\n });\n el.after(elementFragment);\n }", "\n ").concat(!((_9 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _9 === void 0 ? void 0 : _9.attributeChangedCallback)
|
|
645
645
|
? ''
|
|
646
|
-
: "\n attributeChangedCallback(name, oldValue, newValue) {\n ".concat((
|
|
646
|
+
: "\n attributeChangedCallback(name, oldValue, newValue) {\n ".concat((_10 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _10 === void 0 ? void 0 : _10.attributeChangedCallback(['name', 'oldValue', 'newValue'], json, useOptions), "\n }\n "), "\n\n onMount() {\n ").concat(!((_11 = json.hooks.onMount) === null || _11 === void 0 ? void 0 : _11.code)
|
|
647
647
|
? ''
|
|
648
648
|
: // TODO: make prettier by grabbing only the function body
|
|
649
649
|
"\n // onMount\n ".concat(updateReferencesInCode(addUpdateAfterSetInCode(json.hooks.onMount.code, useOptions), useOptions, {
|
|
650
650
|
contextVars: contextVars,
|
|
651
|
-
}), "\n "), "\n }\n\n onUpdate() {\n ").concat(!((
|
|
651
|
+
}), "\n "), "\n }\n\n onUpdate() {\n ").concat(!((_12 = json.hooks.onUpdate) === null || _12 === void 0 ? void 0 : _12.length)
|
|
652
652
|
? ''
|
|
653
653
|
: "\n const self = this;\n ".concat(json.hooks.onUpdate.reduce(function (code, hook, index) {
|
|
654
654
|
// create check update
|
|
@@ -701,8 +701,8 @@ var componentToCustomElement = function (options) {
|
|
|
701
701
|
? ''
|
|
702
702
|
: "\n // scope helper\n getScope(el, name) {\n do {\n let value = el?.scope?.[name]\n if (value !== undefined) {\n return value\n }\n } while ((el = el.parentNode));\n }\n ", "\n\n ").concat(!hasLoop
|
|
703
703
|
? ''
|
|
704
|
-
: "\n\n // Helper to render loops\n renderLoop(template, array, itemName, itemIndex, collectionName) {\n const collection = [];\n for (let [index, value] of array.entries()) {\n const elementFragment = template.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n const localScope = {};\n let scope = localScope;\n if (template?.scope) {\n const getParent = {\n get(target, prop, receiver) {\n if (prop in target) {\n return target[prop];\n }\n if (prop in template.scope) {\n return template.scope[prop];\n }\n return target[prop];\n }\n };\n scope = new Proxy(localScope, getParent);\n }\n children.forEach((child) => {\n if (itemName !== undefined) {\n scope[itemName] = value;\n }\n if (itemIndex !== undefined) {\n scope[itemIndex] = index;\n }\n if (collectionName !== undefined) {\n scope[collectionName] = array;\n }\n child.scope = scope;\n if (template.context) {\n child.context = context;\n }\n this.nodesToDestroy.push(child);\n collection.unshift(child)\n });\n }\n collection.forEach(child => template.after(child));\n }\n ", "\n }\n\n ").concat(((
|
|
705
|
-
? (
|
|
704
|
+
: "\n\n // Helper to render loops\n renderLoop(template, array, itemName, itemIndex, collectionName) {\n const collection = [];\n for (let [index, value] of array.entries()) {\n const elementFragment = template.content.cloneNode(true);\n const children = Array.from(elementFragment.childNodes)\n const localScope = {};\n let scope = localScope;\n if (template?.scope) {\n const getParent = {\n get(target, prop, receiver) {\n if (prop in target) {\n return target[prop];\n }\n if (prop in template.scope) {\n return template.scope[prop];\n }\n return target[prop];\n }\n };\n scope = new Proxy(localScope, getParent);\n }\n children.forEach((child) => {\n if (itemName !== undefined) {\n scope[itemName] = value;\n }\n if (itemIndex !== undefined) {\n scope[itemIndex] = index;\n }\n if (collectionName !== undefined) {\n scope[collectionName] = array;\n }\n child.scope = scope;\n if (template.context) {\n child.context = context;\n }\n this.nodesToDestroy.push(child);\n collection.unshift(child)\n });\n }\n collection.forEach(child => template.after(child));\n }\n ", "\n }\n\n ").concat(((_13 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _13 === void 0 ? void 0 : _13.customElementsDefine)
|
|
705
|
+
? (_14 = useOptions === null || useOptions === void 0 ? void 0 : useOptions.experimental) === null || _14 === void 0 ? void 0 : _14.customElementsDefine(kebabName, component, useOptions)
|
|
706
706
|
: "customElements.define('".concat(kebabName, "', ").concat(ComponentName, ");"), "\n ");
|
|
707
707
|
if (options.plugins) {
|
|
708
708
|
str = (0, plugins_1.runPreCodePlugins)(str, options.plugins);
|
|
@@ -65,6 +65,7 @@ var lodash_1 = require("lodash");
|
|
|
65
65
|
var function_literal_prefix_1 = require("../constants/function-literal-prefix");
|
|
66
66
|
var method_literal_prefix_1 = require("../constants/method-literal-prefix");
|
|
67
67
|
var patterns_1 = require("../helpers/patterns");
|
|
68
|
+
var is_upper_case_1 = require("../helpers/is-upper-case");
|
|
68
69
|
var mappers = {
|
|
69
70
|
Fragment: function (_a) {
|
|
70
71
|
var _b;
|
|
@@ -91,7 +92,7 @@ var mappers = {
|
|
|
91
92
|
delete firstChild.properties.key;
|
|
92
93
|
delete firstChild.bindings.key;
|
|
93
94
|
}
|
|
94
|
-
return "\n{#each ".concat(stripStateAndProps((_c = json.bindings.each) === null || _c === void 0 ? void 0 : _c.code, options), " as ").concat(json.scope.For[0]
|
|
95
|
+
return "\n{#each ".concat(stripStateAndProps((_c = json.bindings.each) === null || _c === void 0 ? void 0 : _c.code, options), " as ").concat(json.scope.For[0]).concat(json.scope.For[1] ? ", ".concat(json.scope.For[1]) : '', " ").concat(keyValue ? "(".concat(keyValue, ")") : '', "}\n").concat(json.children.map(function (item) { return (0, exports.blockToSvelte)({ json: item, options: options, parentComponent: parentComponent }); }).join('\n'), "\n{/each}\n");
|
|
95
96
|
},
|
|
96
97
|
Show: function (_a) {
|
|
97
98
|
var _b;
|
|
@@ -174,7 +175,8 @@ var blockToSvelte = function (_a) {
|
|
|
174
175
|
if ((_c = json.bindings._spread) === null || _c === void 0 ? void 0 : _c.code) {
|
|
175
176
|
str += "{...".concat(stripStateAndProps(json.bindings._spread.code, options), "}");
|
|
176
177
|
}
|
|
177
|
-
|
|
178
|
+
var isComponent = Boolean(tagName[0] && (0, is_upper_case_1.isUpperCase)(tagName[0]));
|
|
179
|
+
if ((((_d = json.bindings.style) === null || _d === void 0 ? void 0 : _d.code) || json.properties.style) && !isComponent) {
|
|
178
180
|
var useValue = stripStateAndProps(((_e = json.bindings.style) === null || _e === void 0 ? void 0 : _e.code) || json.properties.style, options);
|
|
179
181
|
str += "use:mitosis_styling={".concat(useValue, "}");
|
|
180
182
|
delete json.bindings.style;
|
|
@@ -288,7 +290,7 @@ var componentToSvelte = function (_a) {
|
|
|
288
290
|
if (_a === void 0) { _a = {}; }
|
|
289
291
|
var _b = _a.plugins, plugins = _b === void 0 ? [] : _b, userProvidedOptions = __rest(_a, ["plugins"]);
|
|
290
292
|
return function (_a) {
|
|
291
|
-
var _b, _c, _d, _e, _f, _g;
|
|
293
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
292
294
|
var component = _a.component;
|
|
293
295
|
var options = __assign({ stateType: 'variables', prettier: true, plugins: __spreadArray([FUNCTION_HACK_PLUGIN], plugins, true) }, userProvidedOptions);
|
|
294
296
|
// Make a copy we can safely mutate, similar to babel's toolchain
|
|
@@ -336,10 +338,10 @@ var componentToSvelte = function (_a) {
|
|
|
336
338
|
return (0, function_1.pipe)(stripStateAndProps(hookCode, options), babel_transform_1.babelTransformCode);
|
|
337
339
|
};
|
|
338
340
|
var str = '';
|
|
339
|
-
if (json.
|
|
340
|
-
str += (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <script context='module' lang='ts'>\n ", "\n
|
|
341
|
+
if ((_b = json.types) === null || _b === void 0 ? void 0 : _b.length) {
|
|
342
|
+
str += (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <script context='module' lang='ts'>\n ", "\n </script>\n \n\n \n\n "], ["\n <script context='module' lang='ts'>\n ", "\n </script>\n \\n\n \\n\n "])), json.types ? json.types.join('\n\n') + '\n' : '');
|
|
341
343
|
}
|
|
342
|
-
str += (0, dedent_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n <script lang='ts'>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "], ["\n <script lang='ts'>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), !((
|
|
344
|
+
str += (0, dedent_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n <script lang='ts'>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "], ["\n <script lang='ts'>\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), !((_c = json.hooks.onMount) === null || _c === void 0 ? void 0 : _c.code) ? '' : "import { onMount } from 'svelte'", !((_d = json.hooks.onUpdate) === null || _d === void 0 ? void 0 : _d.length) ? '' : "import { afterUpdate } from 'svelte'", !((_e = json.hooks.onUnMount) === null || _e === void 0 ? void 0 : _e.code) ? '' : "import { onDestroy } from 'svelte'", (0, render_imports_1.renderPreComponent)({ component: json, target: 'svelte' }), (0, context_1.hasContext)(component) ? 'import { getContext, setContext } from "svelte";' : '', !hasData || options.stateType === 'variables' ? '' : "import onChange from 'on-change'", (0, lodash_1.uniq)(refs.map(function (ref) { return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(ref); }).concat(props))
|
|
343
345
|
.map(function (name) {
|
|
344
346
|
if (name === 'children') {
|
|
345
347
|
return '';
|
|
@@ -357,9 +359,9 @@ var componentToSvelte = function (_a) {
|
|
|
357
359
|
? dataString.length < 4
|
|
358
360
|
? ''
|
|
359
361
|
: "let state = onChange(".concat(dataString, ", () => state = state)")
|
|
360
|
-
: dataString, !((
|
|
362
|
+
: dataString, !((_f = json.hooks.onMount) === null || _f === void 0 ? void 0 : _f.code)
|
|
361
363
|
? ''
|
|
362
|
-
: "onMount(() => { ".concat(transformHookCode(json.hooks.onMount.code), " });"), !((
|
|
364
|
+
: "onMount(() => { ".concat(transformHookCode(json.hooks.onMount.code), " });"), !((_g = json.hooks.onUpdate) === null || _g === void 0 ? void 0 : _g.length)
|
|
363
365
|
? ''
|
|
364
366
|
: json.hooks.onUpdate
|
|
365
367
|
.map(function (_a, index) {
|
|
@@ -373,7 +375,7 @@ var componentToSvelte = function (_a) {
|
|
|
373
375
|
return "afterUpdate(() => { ".concat(hookCode, " })");
|
|
374
376
|
}
|
|
375
377
|
})
|
|
376
|
-
.join(';'), !((
|
|
378
|
+
.join(';'), !((_h = json.hooks.onUnMount) === null || _h === void 0 ? void 0 : _h.code)
|
|
377
379
|
? ''
|
|
378
380
|
: "onDestroy(() => { ".concat(transformHookCode(json.hooks.onUnMount.code), " });"), json.children
|
|
379
381
|
.map(function (item) {
|
|
@@ -63,7 +63,6 @@ export declare const builderContentToMitosisComponent: (builderContent: BuilderC
|
|
|
63
63
|
children: MitosisNode[];
|
|
64
64
|
subComponents: import("..").MitosisComponent[];
|
|
65
65
|
types?: string[] | undefined;
|
|
66
|
-
interfaces?: string[] | undefined;
|
|
67
66
|
propsTypeRef?: string | undefined;
|
|
68
67
|
}[];
|
|
69
68
|
'@type': "@builder.io/mitosis/component";
|
|
@@ -96,7 +95,6 @@ export declare const builderContentToMitosisComponent: (builderContent: BuilderC
|
|
|
96
95
|
};
|
|
97
96
|
children: MitosisNode[];
|
|
98
97
|
types?: string[] | undefined;
|
|
99
|
-
interfaces?: string[] | undefined;
|
|
100
98
|
propsTypeRef?: string | undefined;
|
|
101
99
|
};
|
|
102
100
|
export {};
|
|
@@ -4,4 +4,3 @@ export declare const getPropsTypeRef: (node: babel.types.FunctionDeclaration, co
|
|
|
4
4
|
export declare const isTypeImport: (node: babel.Node) => boolean;
|
|
5
5
|
export declare const isTypeOrInterface: (node: babel.Node) => boolean;
|
|
6
6
|
export declare const collectTypes: (node: babel.Node, context: Context) => void;
|
|
7
|
-
export declare const collectInterfaces: (node: babel.Node, context: Context) => void;
|
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
38
|
+
exports.collectTypes = exports.isTypeOrInterface = exports.isTypeImport = exports.getPropsTypeRef = void 0;
|
|
39
39
|
var babel = __importStar(require("@babel/core"));
|
|
40
40
|
var generator_1 = __importDefault(require("@babel/generator"));
|
|
41
41
|
var types = babel.types;
|
|
@@ -54,7 +54,7 @@ var getPropsTypeRef = function (node, context) {
|
|
|
54
54
|
.replace(/;/g, '');
|
|
55
55
|
if (generatedTypes.startsWith('{')) {
|
|
56
56
|
var propsTypeRef = "".concat((_a = node.id) === null || _a === void 0 ? void 0 : _a.name, "Props");
|
|
57
|
-
context.builder.component.
|
|
57
|
+
context.builder.component.types = __spreadArray(__spreadArray([], (context.builder.component.types || []), true), [
|
|
58
58
|
"export interface ".concat(propsTypeRef, " ").concat(generatedTypes),
|
|
59
59
|
], false);
|
|
60
60
|
return propsTypeRef;
|
|
@@ -86,10 +86,3 @@ var collectTypes = function (node, context) {
|
|
|
86
86
|
context.builder.component.types = types.filter(Boolean);
|
|
87
87
|
};
|
|
88
88
|
exports.collectTypes = collectTypes;
|
|
89
|
-
var collectInterfaces = function (node, context) {
|
|
90
|
-
var interfaceStr = (0, generator_1.default)(node).code;
|
|
91
|
-
var _a = context.builder.component.interfaces, interfaces = _a === void 0 ? [] : _a;
|
|
92
|
-
interfaces.push(interfaceStr);
|
|
93
|
-
context.builder.component.interfaces = interfaces.filter(Boolean);
|
|
94
|
-
};
|
|
95
|
-
exports.collectInterfaces = collectInterfaces;
|
|
@@ -616,11 +616,8 @@ function parseJsx(jsx, options) {
|
|
|
616
616
|
},
|
|
617
617
|
ExportNamedDeclaration: function (path, context) {
|
|
618
618
|
var node = path.node;
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
(0, component_types_1.collectInterfaces)(path.node, context);
|
|
622
|
-
}
|
|
623
|
-
if (babel.types.isTSTypeAliasDeclaration(node.declaration)) {
|
|
619
|
+
if (babel.types.isTSInterfaceDeclaration(node.declaration) ||
|
|
620
|
+
babel.types.isTSTypeAliasDeclaration(node.declaration)) {
|
|
624
621
|
(0, component_types_1.collectTypes)(path.node, context);
|
|
625
622
|
}
|
|
626
623
|
},
|
|
@@ -628,7 +625,7 @@ function parseJsx(jsx, options) {
|
|
|
628
625
|
(0, component_types_1.collectTypes)(path.node, context);
|
|
629
626
|
},
|
|
630
627
|
TSInterfaceDeclaration: function (path, context) {
|
|
631
|
-
(0, component_types_1.
|
|
628
|
+
(0, component_types_1.collectTypes)(path.node, context);
|
|
632
629
|
},
|
|
633
630
|
},
|
|
634
631
|
}); },
|
|
@@ -105,7 +105,6 @@ function mapReactIdentifiers(json) {
|
|
|
105
105
|
if (item.bindings.class) {
|
|
106
106
|
// TO-DO: it's too much work to merge 2 bindings, so just remove the old one for now.
|
|
107
107
|
item.bindings.class = item.bindings.className;
|
|
108
|
-
console.warn("[".concat(json.name, "]: Found both 'class' and 'className' bindings: removing 'className'."));
|
|
109
108
|
}
|
|
110
109
|
else {
|
|
111
110
|
item.bindings.class = item.bindings.className;
|
|
@@ -115,7 +114,6 @@ function mapReactIdentifiers(json) {
|
|
|
115
114
|
if (item.properties.className) {
|
|
116
115
|
if (item.properties.class) {
|
|
117
116
|
item.properties.class = "".concat(item.properties.class, " ").concat(item.properties.className);
|
|
118
|
-
console.warn("[".concat(json.name, "]: Found both 'class' and 'className' properties: merging."));
|
|
119
117
|
}
|
|
120
118
|
else {
|
|
121
119
|
item.properties.class = item.properties.className;
|