@builder.io/mitosis 0.0.56-13 → 0.0.56-16
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/__tests__/angular.test.js +2 -104
- package/dist/src/__tests__/builder.test.js +3 -3
- package/dist/src/__tests__/data/basic-child-component.raw.jsx +1 -2
- package/dist/src/__tests__/data/basic-context.raw.d.ts +1 -0
- package/dist/src/__tests__/data/basic-context.raw.jsx +29 -0
- package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.d.ts +1 -0
- package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.jsx +10 -0
- package/dist/src/__tests__/data/basic-for-show.raw.jsx +2 -3
- package/dist/src/__tests__/data/basic-for.raw.jsx +2 -3
- package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.d.ts +5 -0
- package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.jsx +17 -0
- package/dist/src/__tests__/data/basic-forwardRef.raw.d.ts +5 -0
- package/dist/src/__tests__/data/basic-forwardRef.raw.jsx +14 -0
- package/dist/src/__tests__/data/basic-onChange.raw.d.ts +1 -0
- package/dist/src/__tests__/data/basic-onChange.raw.jsx +17 -0
- package/dist/src/__tests__/data/basic-onMount-update.raw.jsx +1 -1
- package/dist/src/__tests__/data/basic-onUpdate-return.raw.d.ts +1 -0
- package/dist/src/__tests__/data/basic-onUpdate-return.raw.jsx +24 -0
- package/dist/src/__tests__/data/basic-outputs-meta.raw.jsx +1 -1
- package/dist/src/__tests__/data/basic-outputs.raw.jsx +1 -1
- package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.d.ts +6 -0
- package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.jsx +14 -0
- package/dist/src/__tests__/data/basic-props-destructure.raw.d.ts +6 -0
- package/dist/src/__tests__/data/basic-props-destructure.raw.jsx +14 -0
- package/dist/src/__tests__/data/basic-props.raw.d.ts +6 -0
- package/dist/src/__tests__/data/basic-props.raw.jsx +13 -0
- package/dist/src/__tests__/data/basic-ref-assignment.raw.d.ts +4 -0
- package/dist/src/__tests__/data/basic-ref-assignment.raw.jsx +15 -0
- package/dist/src/__tests__/data/basic-ref-usePrevious.raw.d.ts +5 -0
- package/dist/src/__tests__/data/basic-ref-usePrevious.raw.jsx +35 -0
- package/dist/src/__tests__/data/basic-ref.raw.d.ts +4 -0
- package/dist/src/__tests__/data/basic-ref.raw.jsx +36 -0
- package/dist/src/__tests__/data/basic.raw.d.ts +6 -1
- package/dist/src/__tests__/data/basic.raw.jsx +10 -3
- package/dist/src/__tests__/data/blocks/classname-jsx.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/columns.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -7
- package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -7
- package/dist/src/__tests__/data/blocks/form.raw.jsx +3 -3
- package/dist/src/__tests__/data/blocks/image.raw.jsx +8 -9
- package/dist/src/__tests__/data/blocks/img-state.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/input.raw.jsx +1 -3
- package/dist/src/__tests__/data/blocks/multiple-onUpdateWithDeps.raw.jsx +7 -1
- package/dist/src/__tests__/data/blocks/onInit.raw.d.ts +8 -1
- package/dist/src/__tests__/data/blocks/onInit.raw.jsx +13 -3
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/section-state.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/select.raw.jsx +1 -3
- package/dist/src/__tests__/data/blocks/shadow-dom.raw.jsx +2 -4
- package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +2 -4
- package/dist/src/__tests__/data/blocks/text.raw.jsx +2 -5
- package/dist/src/__tests__/data/styles/class-and-className.raw.jsx +1 -3
- package/dist/src/__tests__/data/styles/className.raw.jsx +1 -3
- package/dist/src/__tests__/data/styles/classState.raw.d.ts +1 -0
- package/dist/src/__tests__/data/styles/classState.raw.jsx +12 -0
- package/dist/src/__tests__/data/types/component-props-interface.raw.d.ts +6 -0
- package/dist/src/__tests__/data/types/component-props-interface.raw.jsx +6 -0
- package/dist/src/__tests__/data/types/component-props-type.raw.d.ts +6 -0
- package/dist/src/__tests__/data/types/component-props-type.raw.jsx +6 -0
- package/dist/src/__tests__/data/types/preserve-typing.raw.d.ts +8 -0
- package/dist/src/__tests__/data/types/preserve-typing.raw.jsx +6 -0
- package/dist/src/__tests__/html.test.js +2 -145
- package/dist/src/__tests__/liquid.test.js +2 -109
- package/dist/src/__tests__/parse-jsx.test.js +22 -0
- package/dist/src/__tests__/qwik/convertMethodToFunction.test.d.ts +1 -0
- package/dist/src/__tests__/qwik/convertMethodToFunction.test.js +34 -0
- package/dist/src/__tests__/qwik/src-generator.test.d.ts +1 -0
- package/dist/src/__tests__/qwik/src-generator.test.js +65 -0
- package/dist/src/__tests__/qwik.test.js +44 -21
- package/dist/src/__tests__/react-native.test.js +2 -135
- package/dist/src/__tests__/react.test.js +5 -177
- package/dist/src/__tests__/shared.d.ts +3 -0
- package/dist/src/__tests__/shared.js +224 -0
- package/dist/src/__tests__/solid.test.js +2 -103
- package/dist/src/__tests__/stencil.test.js +3 -98
- package/dist/src/__tests__/styles.test.js +9 -1
- package/dist/src/__tests__/svelte.test.js +6 -0
- package/dist/src/__tests__/vue.test.js +2 -134
- package/dist/src/__tests__/webcomponent.test.js +6 -165
- package/dist/src/constants/hooks.d.ts +6 -0
- package/dist/src/constants/hooks.js +9 -0
- package/dist/src/generators/angular.d.ts +1 -1
- package/dist/src/generators/angular.js +66 -34
- package/dist/src/generators/builder.d.ts +1 -1
- package/dist/src/generators/builder.js +6 -12
- package/dist/src/generators/context/{react copy.d.ts → qwik.d.ts} +2 -2
- package/dist/src/generators/context/{react copy.js → qwik.js} +4 -5
- package/dist/src/generators/context/svelte.d.ts +1 -1
- package/dist/src/generators/helpers/context.js +1 -2
- package/dist/src/generators/html.d.ts +1 -1
- package/dist/src/generators/html.js +206 -120
- package/dist/src/generators/liquid.d.ts +1 -1
- package/dist/src/generators/liquid.js +6 -14
- package/dist/src/generators/mitosis.d.ts +1 -1
- package/dist/src/generators/mitosis.js +30 -29
- package/dist/src/generators/qwik/component-generator.d.ts +4 -0
- package/dist/src/generators/qwik/component-generator.js +271 -0
- package/dist/src/generators/qwik/component.js +4 -5
- package/dist/src/generators/qwik/convertMethodToFunction.d.ts +1 -0
- package/dist/src/generators/qwik/convertMethodToFunction.js +161 -0
- package/dist/src/generators/qwik/directives.js +20 -18
- package/dist/src/generators/qwik/index.d.ts +3 -1
- package/dist/src/generators/qwik/index.js +3 -1
- package/dist/src/generators/qwik/jsx.js +10 -6
- package/dist/src/generators/qwik/src-generator.d.ts +19 -7
- package/dist/src/generators/qwik/src-generator.js +149 -31
- package/dist/src/generators/qwik/styles.js +1 -2
- package/dist/src/generators/react-native.d.ts +2 -2
- package/dist/src/generators/react-native.js +3 -6
- package/dist/src/generators/react.d.ts +4 -2
- package/dist/src/generators/react.js +88 -68
- package/dist/src/generators/solid.d.ts +1 -1
- package/dist/src/generators/solid.js +9 -12
- package/dist/src/generators/stencil/generate.d.ts +1 -1
- package/dist/src/generators/stencil/generate.js +5 -11
- package/dist/src/generators/svelte.d.ts +1 -1
- package/dist/src/generators/svelte.js +19 -26
- package/dist/src/generators/swift-ui.d.ts +1 -1
- package/dist/src/generators/swift-ui.js +6 -12
- package/dist/src/generators/template.d.ts +1 -1
- package/dist/src/generators/template.js +6 -14
- package/dist/src/generators/vue.d.ts +12 -6
- package/dist/src/generators/vue.js +62 -31
- package/dist/src/helpers/babel-transform.js +3 -8
- package/dist/src/helpers/create-mitosis-component.d.ts +1 -1
- package/dist/src/helpers/create-mitosis-component.js +1 -1
- package/dist/src/helpers/fast-clone.js +1 -3
- package/dist/src/helpers/filter-empty-text-nodes.js +1 -2
- package/dist/src/helpers/get-bindings.d.ts +2 -0
- package/dist/src/helpers/get-bindings.js +18 -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/getters-to-functions.d.ts +1 -1
- package/dist/src/helpers/getters-to-functions.js +1 -1
- 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-stateful-dom.d.ts +2 -0
- package/dist/src/helpers/has-stateful-dom.js +21 -0
- package/dist/src/helpers/is-children.js +1 -2
- package/dist/src/helpers/is-component.js +1 -3
- package/dist/src/helpers/is-html-attribute.d.ts +1 -1
- package/dist/src/helpers/is-html-attribute.js +4 -19
- package/dist/src/helpers/map-refs.js +4 -1
- package/dist/src/helpers/parsers.js +1 -2
- package/dist/src/helpers/render-imports.d.ts +18 -2
- package/dist/src/helpers/render-imports.js +86 -45
- package/dist/src/helpers/render-imports.test.d.ts +1 -0
- package/dist/src/helpers/render-imports.test.js +19 -0
- package/dist/src/helpers/replace-idenifiers.js +2 -5
- package/dist/src/helpers/strip-state-and-props-refs.d.ts +2 -1
- package/dist/src/helpers/strip-state-and-props-refs.js +5 -8
- package/dist/src/helpers/styles/collect-css.d.ts +6 -0
- package/dist/src/helpers/styles/collect-css.js +87 -0
- package/dist/src/helpers/styles/collect-css.test.d.ts +1 -0
- package/dist/src/helpers/styles/collect-css.test.js +18 -0
- package/dist/src/helpers/styles/collect-styled-components.d.ts +2 -0
- package/dist/src/helpers/styles/collect-styled-components.js +61 -0
- package/dist/src/helpers/styles/helpers.d.ts +30 -0
- package/dist/src/helpers/styles/helpers.js +61 -0
- package/dist/src/helpers/typescript.d.ts +2 -0
- package/dist/src/helpers/typescript.js +2 -0
- package/dist/src/index.d.ts +7 -4
- package/dist/src/index.js +24 -8
- package/dist/src/jsx-types.d.ts +1 -0
- package/dist/src/modules/plugins.d.ts +1 -1
- package/dist/src/parsers/angular.js +10 -28
- package/dist/src/parsers/builder.d.ts +23 -23
- package/dist/src/parsers/builder.js +15 -33
- package/dist/src/parsers/jsx.d.ts +2 -1
- package/dist/src/parsers/jsx.js +214 -64
- package/dist/src/parsers/liquid.js +51 -149
- package/dist/src/plugins/compile-away-builder-components.js +4 -10
- package/dist/src/symbols/symbol-processor.js +4 -6
- package/dist/src/targets.d.ts +5 -3
- package/dist/src/targets.js +7 -1
- package/dist/src/types/config.d.ts +37 -17
- package/dist/src/types/mitosis-component.d.ts +30 -10
- package/dist/src/types/transpiler.d.ts +14 -0
- package/dist/src/types/transpiler.js +2 -0
- package/dist/test/qwik/Accordion/low.jsx +1 -0
- package/dist/test/qwik/For/low.jsx +1 -0
- package/dist/test/qwik/Image/med.js +2 -1
- package/dist/test/qwik/Image.slow/med.js +2 -1
- package/dist/test/qwik/bindings/low.cjs +3 -2
- package/dist/test/qwik/button/low.js +1 -0
- package/dist/test/qwik/component/bindings/low.jsx +2 -1
- package/dist/test/qwik/component/component/inputs/med.cjsx +2 -1
- package/dist/test/qwik/for-loop.bindings/high.cjs +0 -0
- package/dist/test/qwik/for-loop.bindings/low.cjs +47 -0
- package/dist/test/qwik/for-loop.bindings/med.cjs +5 -0
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +1 -0
- package/dist/test/qwik/mount/high.cjs +0 -0
- package/dist/test/qwik/mount/low.cjs +44 -0
- package/dist/test/qwik/mount/med.cjs +3 -0
- package/dist/test/qwik/page-with-symbol/low.js +1 -0
- package/dist/test/qwik/show-hide/med.jsx +2 -1
- package/dist/test/qwik/svg/low.js +1 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +1 -0
- package/dist/test/qwik/todo/Todo.js/med.js +1 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +1 -0
- package/dist/test/qwik/todos/Todo.tsx/low.tsx +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -3
- package/README.md +0 -239
- package/dist/src/__tests__/data/blocks/content-slot.raw.d.ts +0 -6
- package/dist/src/__tests__/data/blocks/content-slot.raw.jsx +0 -13
- package/dist/src/__tests__/data/blocks/onUpdate.raw copy.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/onUpdate.raw copy.jsx +0 -10
- package/dist/src/__tests__/data/blocks/slot.raw.d.ts +0 -5
- package/dist/src/__tests__/data/blocks/slot.raw.jsx +0 -6
- package/dist/src/__tests__/data/blocks/styles.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/styles.raw.jsx +0 -10
- package/dist/src/helpers/babel-transform copy.d.ts +0 -8
- package/dist/src/helpers/babel-transform copy.js +0 -138
- package/dist/src/helpers/collect-styles.d.ts +0 -29
- package/dist/src/helpers/collect-styles.js +0 -176
|
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.componentToTemplate = void 0;
|
|
11
11
|
var standalone_1 = require("prettier/standalone");
|
|
12
|
-
var
|
|
12
|
+
var collect_css_1 = require("../helpers/styles/collect-css");
|
|
13
13
|
var fast_clone_1 = require("../helpers/fast-clone");
|
|
14
14
|
var jsx_1 = require("../parsers/jsx");
|
|
15
15
|
var plugins_1 = require("../modules/plugins");
|
|
@@ -17,9 +17,7 @@ var dedent_1 = __importDefault(require("dedent"));
|
|
|
17
17
|
var get_state_object_string_1 = require("../helpers/get-state-object-string");
|
|
18
18
|
var mappers = {
|
|
19
19
|
Fragment: function (json, options) {
|
|
20
|
-
return "<div>".concat(json.children
|
|
21
|
-
.map(function (item) { return blockToTemplate(item, options); })
|
|
22
|
-
.join('\n'), "</div>");
|
|
20
|
+
return "<div>".concat(json.children.map(function (item) { return blockToTemplate(item, options); }).join('\n'), "</div>");
|
|
23
21
|
},
|
|
24
22
|
};
|
|
25
23
|
// TODO: spread support
|
|
@@ -39,18 +37,14 @@ var blockToTemplate = function (json, options) {
|
|
|
39
37
|
if (json.name === 'For') {
|
|
40
38
|
str += "${".concat((_b = json.bindings.each) === null || _b === void 0 ? void 0 : _b.code, "?.map(").concat(json.properties._forName, " => `");
|
|
41
39
|
if (json.children) {
|
|
42
|
-
str += json.children
|
|
43
|
-
.map(function (item) { return blockToTemplate(item, options); })
|
|
44
|
-
.join('\n');
|
|
40
|
+
str += json.children.map(function (item) { return blockToTemplate(item, options); }).join('\n');
|
|
45
41
|
}
|
|
46
42
|
str += '`).join("")}';
|
|
47
43
|
}
|
|
48
44
|
else if (json.name === 'Show') {
|
|
49
45
|
str += "${!(".concat((_c = json.bindings.when) === null || _c === void 0 ? void 0 : _c.code, ") ? '' : `");
|
|
50
46
|
if (json.children) {
|
|
51
|
-
str += json.children
|
|
52
|
-
.map(function (item) { return blockToTemplate(item, options); })
|
|
53
|
-
.join('\n');
|
|
47
|
+
str += json.children.map(function (item) { return blockToTemplate(item, options); }).join('\n');
|
|
54
48
|
}
|
|
55
49
|
str += '`}';
|
|
56
50
|
}
|
|
@@ -87,9 +81,7 @@ var blockToTemplate = function (json, options) {
|
|
|
87
81
|
}
|
|
88
82
|
str += '>';
|
|
89
83
|
if (json.children) {
|
|
90
|
-
str += json.children
|
|
91
|
-
.map(function (item) { return blockToTemplate(item, options); })
|
|
92
|
-
.join('\n');
|
|
84
|
+
str += json.children.map(function (item) { return blockToTemplate(item, options); }).join('\n');
|
|
93
85
|
}
|
|
94
86
|
str += "</".concat(json.name, ">");
|
|
95
87
|
}
|
|
@@ -104,7 +96,7 @@ var componentToTemplate = function (options) {
|
|
|
104
96
|
if (options.plugins) {
|
|
105
97
|
json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
|
|
106
98
|
}
|
|
107
|
-
var css = (0,
|
|
99
|
+
var css = (0, collect_css_1.collectCss)(json);
|
|
108
100
|
if (options.plugins) {
|
|
109
101
|
json = (0, plugins_1.runPostJsonPlugins)(json, options.plugins);
|
|
110
102
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { MitosisNode } from '../types/mitosis-node';
|
|
2
|
-
import { BaseTranspilerOptions,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { BaseTranspilerOptions, Transpiler } from '../types/transpiler';
|
|
3
|
+
import { OmitObj } from '../helpers/typescript';
|
|
4
|
+
export declare type VueVersion = 2 | 3;
|
|
5
|
+
interface VueVersionOpt {
|
|
6
|
+
vueVersion: VueVersion;
|
|
7
|
+
}
|
|
8
|
+
export interface ToVueOptions extends BaseTranspilerOptions, VueVersionOpt {
|
|
5
9
|
cssNamespace?: () => string;
|
|
6
10
|
namePrefix?: (path: string) => string;
|
|
11
|
+
asyncComponentImports?: boolean;
|
|
7
12
|
}
|
|
8
13
|
export declare const blockToVue: (node: MitosisNode, options: ToVueOptions) => string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
declare type VueOptsWithoutVersion = OmitObj<ToVueOptions, VueVersionOpt>;
|
|
15
|
+
export declare const componentToVue2: (vueOptions?: VueOptsWithoutVersion) => Transpiler;
|
|
16
|
+
export declare const componentToVue3: (vueOptions?: VueOptsWithoutVersion) => Transpiler;
|
|
17
|
+
export {};
|
|
@@ -38,10 +38,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
39
|
};
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.
|
|
41
|
+
exports.componentToVue3 = exports.componentToVue2 = exports.blockToVue = void 0;
|
|
42
42
|
var dedent_1 = __importDefault(require("dedent"));
|
|
43
43
|
var standalone_1 = require("prettier/standalone");
|
|
44
|
-
var
|
|
44
|
+
var collect_css_1 = require("../helpers/styles/collect-css");
|
|
45
45
|
var fast_clone_1 = require("../helpers/fast-clone");
|
|
46
46
|
var get_state_object_string_1 = require("../helpers/get-state-object-string");
|
|
47
47
|
var map_refs_1 = require("../helpers/map-refs");
|
|
@@ -265,9 +265,7 @@ function getContextProvideString(component, options) {
|
|
|
265
265
|
var _a = component.context.set[key], value = _a.value, name_1 = _a.name;
|
|
266
266
|
str += "\n ".concat(name_1, ": ").concat(value
|
|
267
267
|
? (0, get_state_object_string_1.getMemberObjectString)(value, {
|
|
268
|
-
valueMapper: function (code) {
|
|
269
|
-
return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(code, { replaceWith: '_this.' });
|
|
270
|
-
},
|
|
268
|
+
valueMapper: function (code) { return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(code, { replaceWith: '_this.' }); },
|
|
271
269
|
})
|
|
272
270
|
: null, ",\n ");
|
|
273
271
|
}
|
|
@@ -299,16 +297,33 @@ var onUpdatePlugin = function (options) { return ({
|
|
|
299
297
|
}); };
|
|
300
298
|
var BASE_OPTIONS = {
|
|
301
299
|
plugins: [onUpdatePlugin],
|
|
300
|
+
vueVersion: 2,
|
|
302
301
|
};
|
|
303
302
|
var mergeOptions = function (_a, _b) {
|
|
304
303
|
var _c = _a.plugins, pluginsA = _c === void 0 ? [] : _c, a = __rest(_a, ["plugins"]);
|
|
305
304
|
var _d = _b.plugins, pluginsB = _d === void 0 ? [] : _d, b = __rest(_b, ["plugins"]);
|
|
306
305
|
return (__assign(__assign(__assign({}, a), b), { plugins: __spreadArray(__spreadArray([], pluginsA, true), pluginsB, true) }));
|
|
307
306
|
};
|
|
307
|
+
var generateComponentImport = function (options) {
|
|
308
|
+
return function (componentName) {
|
|
309
|
+
var key = (0, lodash_1.kebabCase)(componentName);
|
|
310
|
+
if (options.vueVersion >= 3 && options.asyncComponentImports) {
|
|
311
|
+
return "'".concat(key, "': defineAsyncComponent(").concat(componentName, ")");
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
return "'".concat(key, "': ").concat(componentName);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
var generateComponents = function (componentsUsed, options) {
|
|
319
|
+
if (componentsUsed.length === 0) {
|
|
320
|
+
return '';
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
return "components: { ".concat(componentsUsed.map(generateComponentImport(options)).join(','), " },");
|
|
324
|
+
}
|
|
325
|
+
};
|
|
308
326
|
var componentToVue = function (userOptions) {
|
|
309
|
-
if (userOptions === void 0) { userOptions = {}; }
|
|
310
|
-
// hack while we migrate all other transpilers to receive/handle path
|
|
311
|
-
// TO-DO: use `Transpiler` once possible
|
|
312
327
|
return function (_a) {
|
|
313
328
|
var _b, _c, _d, _e, _f, _g, _h;
|
|
314
329
|
var component = _a.component, path = _a.path;
|
|
@@ -325,9 +340,24 @@ var componentToVue = function (userOptions) {
|
|
|
325
340
|
if (options.plugins) {
|
|
326
341
|
component = (0, plugins_1.runPostJsonPlugins)(component, options.plugins);
|
|
327
342
|
}
|
|
328
|
-
var css = (0,
|
|
343
|
+
var css = (0, collect_css_1.collectCss)(component, {
|
|
329
344
|
prefix: (_c = (_b = options.cssNamespace) === null || _b === void 0 ? void 0 : _b.call(options)) !== null && _c !== void 0 ? _c : undefined,
|
|
330
345
|
});
|
|
346
|
+
var localExports = component.exports;
|
|
347
|
+
var localVarAsData = [];
|
|
348
|
+
var localVarAsFunc = [];
|
|
349
|
+
if (localExports) {
|
|
350
|
+
Object.keys(localExports).forEach(function (key) {
|
|
351
|
+
if (localExports[key].usedInLocal) {
|
|
352
|
+
if (localExports[key].isFunction) {
|
|
353
|
+
localVarAsFunc.push(key);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
localVarAsData.push(key);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
331
361
|
var dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(component, {
|
|
332
362
|
data: true,
|
|
333
363
|
functions: false,
|
|
@@ -337,9 +367,7 @@ var componentToVue = function (userOptions) {
|
|
|
337
367
|
data: false,
|
|
338
368
|
getters: true,
|
|
339
369
|
functions: false,
|
|
340
|
-
valueMapper: function (code) {
|
|
341
|
-
return processBinding(code.replace(patterns_1.GETTER, ''), options, component);
|
|
342
|
-
},
|
|
370
|
+
valueMapper: function (code) { return processBinding(code.replace(patterns_1.GETTER, ''), options, component); },
|
|
343
371
|
});
|
|
344
372
|
var functionsString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(component, {
|
|
345
373
|
data: false,
|
|
@@ -350,11 +378,7 @@ var componentToVue = function (userOptions) {
|
|
|
350
378
|
var blocksString = JSON.stringify(component.children);
|
|
351
379
|
// Component references to include in `component: { YourComponent, ... }
|
|
352
380
|
var componentsUsed = Array.from((0, get_components_used_1.getComponentsUsed)(component))
|
|
353
|
-
.filter(function (name) {
|
|
354
|
-
return name.length &&
|
|
355
|
-
!name.includes('.') &&
|
|
356
|
-
name[0].toUpperCase() === name[0];
|
|
357
|
-
})
|
|
381
|
+
.filter(function (name) { return name.length && !name.includes('.') && name[0].toUpperCase() === name[0]; })
|
|
358
382
|
// Strip out components that compile away
|
|
359
383
|
.filter(function (name) { return !['For', 'Show', 'Fragment', component.name].includes(name); });
|
|
360
384
|
// Append refs to data as { foo, bar, etc }
|
|
@@ -365,28 +389,28 @@ var componentToVue = function (userOptions) {
|
|
|
365
389
|
// Don't include component imports
|
|
366
390
|
.filter(function (key) { return !componentsUsed.includes(key); })
|
|
367
391
|
.join(','), "}"));
|
|
392
|
+
if (localVarAsData.length) {
|
|
393
|
+
dataString = dataString.replace(/}$/, "".concat(localVarAsData.join(','), "}"));
|
|
394
|
+
}
|
|
368
395
|
var elementProps = (0, get_props_1.getProps)(component);
|
|
369
396
|
(0, strip_meta_properties_1.stripMetaProperties)(component);
|
|
370
|
-
var template = component.children
|
|
371
|
-
.map(function (item) { return (0, exports.blockToVue)(item, options); })
|
|
372
|
-
.join('\n');
|
|
397
|
+
var template = component.children.map(function (item) { return (0, exports.blockToVue)(item, options); }).join('\n');
|
|
373
398
|
var includeClassMapHelper = template.includes('_classStringToObject');
|
|
374
399
|
if (includeClassMapHelper) {
|
|
375
400
|
functionsString = functionsString.replace(/}\s*$/, "_classStringToObject(str) {\n const obj = {};\n if (typeof str !== 'string') { return obj }\n const classNames = str.trim().split(/\\s+/); \n for (const name of classNames) {\n obj[name] = true;\n } \n return obj;\n } }");
|
|
376
401
|
}
|
|
402
|
+
if (localVarAsFunc.length) {
|
|
403
|
+
functionsString = functionsString.replace(/}\s*$/, "".concat(localVarAsFunc.join(','), "}"));
|
|
404
|
+
}
|
|
377
405
|
var onUpdateWithDeps = ((_d = component.hooks.onUpdate) === null || _d === void 0 ? void 0 : _d.filter(function (hook) { var _a; return (_a = hook.deps) === null || _a === void 0 ? void 0 : _a.length; })) || [];
|
|
378
406
|
var onUpdateWithoutDeps = ((_e = component.hooks.onUpdate) === null || _e === void 0 ? void 0 : _e.filter(function (hook) { var _a; return !((_a = hook.deps) === null || _a === void 0 ? void 0 : _a.length); })) || [];
|
|
379
|
-
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <template>\n ", "\n </template>\n <script>\n ", "\n\n export default {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n }\n </script>\n ", "\n "], ["\n <template>\n ", "\n </template>\n <script>\n ", "\n\n export default {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n }\n </script>\n ", "\n "])), template, (0, render_imports_1.renderPreComponent)(
|
|
407
|
+
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <template>\n ", "\n </template>\n <script>\n ", "\n ", "\n\n export default {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n }\n </script>\n ", "\n "], ["\n <template>\n ", "\n </template>\n <script>\n ", "\n ", "\n\n export default {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n }\n </script>\n ", "\n "])), template, options.vueVersion >= 3 ? 'import { defineAsyncComponent } from "vue"' : '', (0, render_imports_1.renderPreComponent)({
|
|
408
|
+
component: component,
|
|
409
|
+
target: 'vue',
|
|
410
|
+
asyncComponentImports: options.asyncComponentImports,
|
|
411
|
+
}), !component.name
|
|
380
412
|
? ''
|
|
381
|
-
: "name: '".concat(((_f = options.namePrefix) === null || _f === void 0 ? void 0 : _f.call(options, path))
|
|
382
|
-
? ((_g = options.namePrefix) === null || _g === void 0 ? void 0 : _g.call(options, path)) + '-'
|
|
383
|
-
: '').concat((0, lodash_1.kebabCase)(component.name), "',"), !componentsUsed.length
|
|
384
|
-
? ''
|
|
385
|
-
: "components: { ".concat(componentsUsed
|
|
386
|
-
.map(function (componentName) {
|
|
387
|
-
return "'".concat((0, lodash_1.kebabCase)(componentName), "': async () => ").concat(componentName);
|
|
388
|
-
})
|
|
389
|
-
.join(','), " },"), elementProps.size
|
|
413
|
+
: "name: '".concat(path && ((_f = options.namePrefix) === null || _f === void 0 ? void 0 : _f.call(options, path)) ? ((_g = options.namePrefix) === null || _g === void 0 ? void 0 : _g.call(options, path)) + '-' : '').concat((0, lodash_1.kebabCase)(component.name), "',"), generateComponents(componentsUsed, options), elementProps.size
|
|
390
414
|
? "props: ".concat(JSON.stringify(Array.from(elementProps).filter(function (prop) { return prop !== 'children' && prop !== 'class'; })), ",")
|
|
391
415
|
: '', dataString.length < 4
|
|
392
416
|
? ''
|
|
@@ -447,7 +471,14 @@ var componentToVue = function (userOptions) {
|
|
|
447
471
|
});
|
|
448
472
|
};
|
|
449
473
|
};
|
|
450
|
-
|
|
474
|
+
var componentToVue2 = function (vueOptions) {
|
|
475
|
+
return componentToVue(__assign(__assign({}, vueOptions), { vueVersion: 2 }));
|
|
476
|
+
};
|
|
477
|
+
exports.componentToVue2 = componentToVue2;
|
|
478
|
+
var componentToVue3 = function (vueOptions) {
|
|
479
|
+
return componentToVue(__assign(__assign({}, vueOptions), { vueVersion: 3 }));
|
|
480
|
+
};
|
|
481
|
+
exports.componentToVue3 = componentToVue3;
|
|
451
482
|
// Remove unused artifacts like empty script or style tags
|
|
452
483
|
var removePatterns = [
|
|
453
484
|
"<script>\nexport default {};\n</script>",
|
|
@@ -44,10 +44,7 @@ var babelTransform = function (code, visitor) {
|
|
|
44
44
|
configFile: false,
|
|
45
45
|
babelrc: false,
|
|
46
46
|
presets: [[tsPreset, { isTSX: true, allExtensions: true }]],
|
|
47
|
-
plugins: __spreadArray([
|
|
48
|
-
[decorators, { legacy: true }],
|
|
49
|
-
jsxPlugin
|
|
50
|
-
], (visitor ? [function () { return ({ visitor: visitor }); }] : []), true),
|
|
47
|
+
plugins: __spreadArray([[decorators, { legacy: true }], jsxPlugin], (visitor ? [function () { return ({ visitor: visitor }); }] : []), true),
|
|
51
48
|
});
|
|
52
49
|
};
|
|
53
50
|
exports.babelTransform = babelTransform;
|
|
@@ -68,8 +65,7 @@ var babelTransformExpression = function (code, visitor, type) {
|
|
|
68
65
|
}
|
|
69
66
|
// For Builder content
|
|
70
67
|
if (type === 'unknown' &&
|
|
71
|
-
(code.includes('return _virtual_index') ||
|
|
72
|
-
code.trim().startsWith('return ')) &&
|
|
68
|
+
(code.includes('return _virtual_index') || code.trim().startsWith('return ')) &&
|
|
73
69
|
!code.trim().startsWith('function')) {
|
|
74
70
|
type = 'functionBody';
|
|
75
71
|
}
|
|
@@ -97,8 +93,7 @@ var babelTransformExpression = function (code, visitor, type) {
|
|
|
97
93
|
// If it can't, e.g. this is an expression or code fragment, modify the code below and try again
|
|
98
94
|
// Detect method fragments. These get passed sometimes and otherwise
|
|
99
95
|
// generate compile errors. They are of the form `foo() { ... }`
|
|
100
|
-
var isMethod = Boolean(!code.startsWith('function') &&
|
|
101
|
-
code.match(/^[a-z0-9]+\s*\([^\)]*\)\s*[\{:]/i));
|
|
96
|
+
var isMethod = Boolean(!code.startsWith('function') && code.match(/^[a-z0-9_]+\s*\([^\)]*\)\s*[\{:]/i));
|
|
102
97
|
if (isMethod) {
|
|
103
98
|
useCode = "function ".concat(useCode);
|
|
104
99
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
2
|
-
export declare const createMitosisComponent: (options?: Partial<MitosisComponent>
|
|
2
|
+
export declare const createMitosisComponent: (options?: Partial<MitosisComponent>) => MitosisComponent;
|
|
@@ -12,5 +12,5 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.createMitosisComponent = void 0;
|
|
15
|
-
var createMitosisComponent = function (options) { return (__assign({ '@type': '@builder.io/mitosis/component', imports: [], inputs: [], meta: {}, state: {}, children: [], hooks: {}, context: { get: {}, set: {} }, name: (options === null || options === void 0 ? void 0 : options.name) || 'MyComponent', subComponents: [] }, options)); };
|
|
15
|
+
var createMitosisComponent = function (options) { return (__assign({ '@type': '@builder.io/mitosis/component', imports: [], exports: {}, inputs: [], meta: {}, refs: {}, state: {}, children: [], hooks: {}, context: { get: {}, set: {} }, name: (options === null || options === void 0 ? void 0 : options.name) || 'MyComponent', subComponents: [] }, options)); };
|
|
16
16
|
exports.createMitosisComponent = createMitosisComponent;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fastClone = void 0;
|
|
4
|
-
var fastClone = function (obj) {
|
|
5
|
-
return JSON.parse(JSON.stringify(obj));
|
|
6
|
-
};
|
|
4
|
+
var fastClone = function (obj) { return JSON.parse(JSON.stringify(obj)); };
|
|
7
5
|
exports.fastClone = fastClone;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.filterEmptyTextNodes = void 0;
|
|
4
4
|
var filterEmptyTextNodes = function (node) {
|
|
5
|
-
return !(typeof node.properties._text === 'string' &&
|
|
6
|
-
!node.properties._text.trim().length);
|
|
5
|
+
return !(typeof node.properties._text === 'string' && !node.properties._text.trim().length);
|
|
7
6
|
};
|
|
8
7
|
exports.filterEmptyTextNodes = filterEmptyTextNodes;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBindingsCode = void 0;
|
|
4
|
+
function getBindingsCode(children) {
|
|
5
|
+
var bindings = [];
|
|
6
|
+
children.forEach(function (child) {
|
|
7
|
+
if (child.bindings) {
|
|
8
|
+
Object.keys(child.bindings).forEach(function (key) {
|
|
9
|
+
bindings.push(child.bindings[key].code);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (child.children) {
|
|
13
|
+
bindings.push.apply(bindings, getBindingsCode(child.children));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return bindings;
|
|
17
|
+
}
|
|
18
|
+
exports.getBindingsCode = getBindingsCode;
|
|
@@ -0,0 +1,32 @@
|
|
|
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.getPropsRef = void 0;
|
|
7
|
+
var traverse_1 = __importDefault(require("traverse"));
|
|
8
|
+
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
|
+
function getPropsRef(json, shouldRemove) {
|
|
10
|
+
var has = false;
|
|
11
|
+
var prop = '';
|
|
12
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
13
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
14
|
+
var binding = item.bindings.ref;
|
|
15
|
+
var regexp = /(.+)?props\.(.+)( |\)|;|\()?$/;
|
|
16
|
+
if (binding && regexp.test(binding.code)) {
|
|
17
|
+
var match = regexp.exec(binding.code);
|
|
18
|
+
var _prop = match === null || match === void 0 ? void 0 : match[2];
|
|
19
|
+
if (_prop) {
|
|
20
|
+
prop = _prop;
|
|
21
|
+
}
|
|
22
|
+
if (shouldRemove) {
|
|
23
|
+
delete item.bindings.ref;
|
|
24
|
+
}
|
|
25
|
+
has = true;
|
|
26
|
+
this.stop();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return [prop, has];
|
|
31
|
+
}
|
|
32
|
+
exports.getPropsRef = getPropsRef;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
2
2
|
/**
|
|
3
|
-
* Map getters like `
|
|
3
|
+
* Map getters like `useStore({ get foo() { ... }})` from `state.foo` to `foo()`
|
|
4
4
|
*/
|
|
5
5
|
export declare const gettersToFunctions: (json: MitosisComponent) => void;
|
|
@@ -7,7 +7,7 @@ exports.gettersToFunctions = void 0;
|
|
|
7
7
|
var method_literal_prefix_1 = require("../constants/method-literal-prefix");
|
|
8
8
|
var traverse_1 = __importDefault(require("traverse"));
|
|
9
9
|
/**
|
|
10
|
-
* Map getters like `
|
|
10
|
+
* Map getters like `useStore({ get foo() { ... }})` from `state.foo` to `foo()`
|
|
11
11
|
*/
|
|
12
12
|
var gettersToFunctions = function (json) {
|
|
13
13
|
var getterKeys = Object.keys(json.state).filter(function (item) {
|
|
@@ -0,0 +1,21 @@
|
|
|
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.hasBindingsText = void 0;
|
|
7
|
+
var traverse_1 = __importDefault(require("traverse"));
|
|
8
|
+
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
|
+
var is_children_1 = __importDefault(require("./is-children"));
|
|
10
|
+
var hasBindingsText = function (json) {
|
|
11
|
+
var has = false;
|
|
12
|
+
(0, traverse_1.default)(json).forEach(function (node) {
|
|
13
|
+
var _a;
|
|
14
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(node) && !(0, is_children_1.default)(node) && ((_a = node.bindings._text) === null || _a === void 0 ? void 0 : _a.code)) {
|
|
15
|
+
has = true;
|
|
16
|
+
this.stop();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return has;
|
|
20
|
+
};
|
|
21
|
+
exports.hasBindingsText = hasBindingsText;
|
|
@@ -0,0 +1,21 @@
|
|
|
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.hasStatefulDom = void 0;
|
|
7
|
+
var traverse_1 = __importDefault(require("traverse"));
|
|
8
|
+
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
|
+
var hasStatefulDom = function (json) {
|
|
10
|
+
var has = false;
|
|
11
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
12
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
13
|
+
if (/input|textarea|select/.test(item.name)) {
|
|
14
|
+
has = true;
|
|
15
|
+
this.stop();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return has;
|
|
20
|
+
};
|
|
21
|
+
exports.hasStatefulDom = hasStatefulDom;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function isChildren(node) {
|
|
4
4
|
var _a;
|
|
5
|
-
return
|
|
6
|
-
'props.children');
|
|
5
|
+
return "".concat(((_a = node.bindings._text) === null || _a === void 0 ? void 0 : _a.code) || '').replace(/\s+/g, '') === 'props.children';
|
|
7
6
|
}
|
|
8
7
|
exports.default = isChildren;
|
|
@@ -4,7 +4,5 @@ exports.isComponent = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* This node is a component, vs a plain html tag (<Foo> vs <div>)
|
|
6
6
|
*/
|
|
7
|
-
var isComponent = function (json) {
|
|
8
|
-
return json.name.toLowerCase() !== json.name;
|
|
9
|
-
};
|
|
7
|
+
var isComponent = function (json) { return json.name.toLowerCase() !== json.name; };
|
|
10
8
|
exports.isComponent = isComponent;
|
|
@@ -80,15 +80,7 @@ exports.htmlElementAttributes = {
|
|
|
80
80
|
'target',
|
|
81
81
|
'type',
|
|
82
82
|
],
|
|
83
|
-
audio: [
|
|
84
|
-
'autoplay',
|
|
85
|
-
'controls',
|
|
86
|
-
'crossorigin',
|
|
87
|
-
'loop',
|
|
88
|
-
'muted',
|
|
89
|
-
'preload',
|
|
90
|
-
'src',
|
|
91
|
-
],
|
|
83
|
+
audio: ['autoplay', 'controls', 'crossorigin', 'loop', 'muted', 'preload', 'src'],
|
|
92
84
|
base: ['href', 'target'],
|
|
93
85
|
basefont: ['color', 'face', 'size'],
|
|
94
86
|
blockquote: ['cite'],
|
|
@@ -295,15 +287,7 @@ exports.htmlElementAttributes = {
|
|
|
295
287
|
'src',
|
|
296
288
|
'type',
|
|
297
289
|
],
|
|
298
|
-
select: [
|
|
299
|
-
'autocomplete',
|
|
300
|
-
'disabled',
|
|
301
|
-
'form',
|
|
302
|
-
'multiple',
|
|
303
|
-
'name',
|
|
304
|
-
'required',
|
|
305
|
-
'size',
|
|
306
|
-
],
|
|
290
|
+
select: ['autocomplete', 'disabled', 'form', 'multiple', 'name', 'required', 'size'],
|
|
307
291
|
slot: ['name'],
|
|
308
292
|
source: ['height', 'media', 'sizes', 'src', 'srcset', 'type', 'width'],
|
|
309
293
|
style: ['media', 'type'],
|
|
@@ -390,6 +374,7 @@ var isHtmlAttribute = function (attr, tagName) {
|
|
|
390
374
|
if (/role|aria-/.test(attr)) {
|
|
391
375
|
return true;
|
|
392
376
|
}
|
|
393
|
-
|
|
377
|
+
var getAttr = __spreadArray(__spreadArray([], exports.htmlElementAttributes['*'], true), (exports.htmlElementAttributes[tagName] || []), true).find(function (attribute) { return attr === attribute; });
|
|
378
|
+
return Boolean(getAttr);
|
|
394
379
|
};
|
|
395
380
|
exports.isHtmlAttribute = isHtmlAttribute;
|
|
@@ -59,7 +59,10 @@ var replaceRefsInString = function (code, refs, mapper) {
|
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
var mapRefs = function (component, mapper) {
|
|
62
|
-
var
|
|
62
|
+
var refSet = (0, get_refs_1.getRefs)(component);
|
|
63
|
+
// grab refs not used for bindings
|
|
64
|
+
Object.keys(component.refs).forEach(function (ref) { return refSet.add(ref); });
|
|
65
|
+
var refs = Array.from(refSet);
|
|
63
66
|
for (var _i = 0, _a = Object.keys(component.state); _i < _a.length; _i++) {
|
|
64
67
|
var key = _a[_i];
|
|
65
68
|
var value = component.state[key];
|
|
@@ -43,8 +43,7 @@ function parseCode(code) {
|
|
|
43
43
|
exports.parseCode = parseCode;
|
|
44
44
|
var isCodeBodyExpression = function (body) {
|
|
45
45
|
return body.length == 1 &&
|
|
46
|
-
(babel.types.isExpression(body[0]) ||
|
|
47
|
-
babel.types.isExpressionStatement(body[0]));
|
|
46
|
+
(babel.types.isExpression(body[0]) || babel.types.isExpressionStatement(body[0]));
|
|
48
47
|
};
|
|
49
48
|
exports.isCodeBodyExpression = isCodeBodyExpression;
|
|
50
49
|
/**
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Target } from '../types/config';
|
|
2
|
+
import { MitosisComponent, MitosisImport } from '../types/mitosis-component';
|
|
3
|
+
export declare const renderImport: ({ theImport, target, asyncComponentImports, }: {
|
|
4
|
+
theImport: MitosisImport;
|
|
5
|
+
target: Target;
|
|
6
|
+
asyncComponentImports: boolean;
|
|
7
|
+
}) => string;
|
|
8
|
+
export declare const renderImports: ({ imports, target, asyncComponentImports, }: {
|
|
9
|
+
imports: MitosisImport[];
|
|
10
|
+
target: Target;
|
|
11
|
+
asyncComponentImports: boolean;
|
|
12
|
+
}) => string;
|
|
13
|
+
export declare const renderPreComponent: ({ component, target, asyncComponentImports, }: {
|
|
14
|
+
component: MitosisComponent;
|
|
15
|
+
target: Target;
|
|
16
|
+
asyncComponentImports?: boolean | undefined;
|
|
17
|
+
}) => string;
|
|
18
|
+
export declare const renderExportAndLocal: (component: MitosisComponent) => string;
|