@builder.io/mitosis 0.0.45-5 → 0.0.48
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__/builder.test.js +71 -68
- package/dist/src/__tests__/context.test.js +13 -10
- package/dist/src/__tests__/data/basic.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/button-with-metadata.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/columns.raw.jsx +8 -2
- package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -3
- package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -3
- package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
- package/dist/src/__tests__/data/blocks/image.raw.jsx +4 -4
- package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +4 -4
- package/dist/src/__tests__/data/context/component-with-context.lite.jsx +2 -2
- package/dist/src/__tests__/data/context/simple.context.lite.js +1 -1
- package/dist/src/__tests__/html.test.js +2 -2
- package/dist/src/__tests__/liquid.test.js +34 -34
- package/dist/src/__tests__/parse-jsx.test.js +1 -1
- package/dist/src/__tests__/qwik.test.js +197 -50
- package/dist/src/__tests__/react-native.test.js +35 -35
- package/dist/src/__tests__/react.test.js +35 -35
- package/dist/src/__tests__/solid.test.js +32 -32
- package/dist/src/__tests__/vue.test.js +35 -34
- package/dist/src/generators/angular.d.ts +4 -7
- package/dist/src/generators/angular.js +77 -81
- package/dist/src/generators/builder.d.ts +4 -4
- package/dist/src/generators/builder.js +57 -57
- package/dist/src/generators/context/react.d.ts +3 -1
- package/dist/src/generators/context/react.js +20 -17
- package/dist/src/generators/html.d.ts +5 -9
- package/dist/src/generators/html.js +205 -199
- package/dist/src/generators/liquid.d.ts +5 -9
- package/dist/src/generators/liquid.js +62 -59
- package/dist/src/generators/mitosis.d.ts +6 -7
- package/dist/src/generators/mitosis.js +61 -63
- package/dist/src/generators/qwik/component.d.ts +20 -0
- package/dist/src/generators/qwik/component.js +117 -0
- package/dist/src/generators/qwik/directives.d.ts +2 -0
- package/dist/src/generators/qwik/directives.js +27 -0
- package/dist/src/generators/qwik/handlers.d.ts +4 -0
- package/dist/src/generators/qwik/handlers.js +80 -0
- package/dist/src/generators/qwik/index.d.ts +2 -0
- package/dist/src/generators/qwik/index.js +9 -0
- package/dist/src/generators/qwik/jsx.d.ts +4 -0
- package/dist/src/generators/qwik/jsx.js +124 -0
- package/dist/src/generators/qwik/src-generator.d.ts +79 -0
- package/dist/src/generators/qwik/src-generator.js +427 -0
- package/dist/src/generators/qwik/styles.d.ts +7 -0
- package/dist/src/generators/qwik/styles.js +94 -0
- package/dist/src/generators/react-native.d.ts +4 -7
- package/dist/src/generators/react-native.js +53 -43
- package/dist/src/generators/react.d.ts +4 -8
- package/dist/src/generators/react.js +122 -114
- package/dist/src/generators/solid.d.ts +4 -8
- package/dist/src/generators/solid.js +55 -54
- package/dist/src/generators/svelte.d.ts +4 -7
- package/dist/src/generators/svelte.js +120 -123
- package/dist/src/generators/swift-ui.d.ts +2 -2
- package/dist/src/generators/swift-ui.js +62 -62
- package/dist/src/generators/template.d.ts +4 -8
- package/dist/src/generators/template.js +48 -45
- package/dist/src/generators/vue.d.ts +9 -9
- package/dist/src/generators/vue.js +170 -169
- package/dist/src/helpers/babel-transform.js +9 -9
- package/dist/src/helpers/camel-case.d.ts +8 -0
- package/dist/src/helpers/camel-case.js +18 -0
- package/dist/src/helpers/collect-styles.js +39 -37
- package/dist/src/helpers/dash-case.js +1 -1
- package/dist/src/helpers/generic-format.test.js +2 -2
- package/dist/src/helpers/get-components-used.js +2 -2
- package/dist/src/helpers/get-components.js +3 -3
- package/dist/src/helpers/get-props.js +1 -1
- package/dist/src/helpers/get-refs.js +2 -2
- package/dist/src/helpers/get-state-object-string.js +52 -39
- package/dist/src/helpers/get-state-used.js +1 -1
- package/dist/src/helpers/get-styles.js +1 -1
- package/dist/src/helpers/getters-to-functions.js +4 -4
- package/dist/src/helpers/handle-missing-state.js +1 -1
- package/dist/src/helpers/has-component.js +2 -2
- package/dist/src/helpers/has-props.js +1 -1
- package/dist/src/helpers/is-children.js +1 -1
- package/dist/src/helpers/json.d.ts +1 -0
- package/dist/src/helpers/json.js +17 -0
- package/dist/src/helpers/map-refs.js +7 -6
- package/dist/src/helpers/map-to-attributes.js +4 -4
- package/dist/src/helpers/map-to-css.js +2 -2
- package/dist/src/helpers/parse-node.js +2 -2
- package/dist/src/helpers/parse-reactive-script.js +4 -4
- package/dist/src/helpers/patterns.d.ts +2 -0
- package/dist/src/helpers/patterns.js +5 -0
- package/dist/src/helpers/process-http-requests.js +1 -1
- package/dist/src/helpers/process-tag-references.js +4 -4
- package/dist/src/helpers/remove-surrounding-block.test.js +1 -1
- package/dist/src/helpers/render-imports.js +7 -7
- package/dist/src/helpers/replace-idenifiers.js +1 -1
- package/dist/src/helpers/strip-meta-properties.js +2 -2
- package/dist/src/helpers/trace-reference-to-module-path.js +1 -1
- package/dist/src/helpers/traverse-nodes.js +2 -2
- package/dist/src/helpers/try-prettier-format.js +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +3 -1
- package/dist/src/jsx-types.d.ts +1 -1
- package/dist/src/modules/plugins.d.ts +2 -10
- package/dist/src/parsers/angular.js +13 -13
- package/dist/src/parsers/builder.d.ts +1 -1
- package/dist/src/parsers/builder.js +56 -59
- package/dist/src/parsers/context.js +2 -2
- package/dist/src/parsers/jsx.js +59 -87
- package/dist/src/parsers/liquid.js +193 -195
- package/dist/src/plugins/compile-away-builder-components.d.ts +1 -1
- package/dist/src/plugins/compile-away-builder-components.js +330 -91
- package/dist/src/plugins/compile-away-components.js +3 -3
- package/dist/src/plugins/map-styles.js +3 -3
- package/dist/src/targets.d.ts +24 -0
- package/dist/src/targets.js +30 -0
- package/dist/src/types/config.d.ts +31 -0
- package/dist/src/types/{jsx-lite-component.js → config.js} +0 -0
- package/dist/src/types/generators.d.ts +0 -0
- package/dist/src/types/generators.js +1 -0
- package/dist/src/types/plugins.d.ts +11 -0
- package/dist/src/types/{jsx-lite-context.js → plugins.js} +0 -0
- package/dist/test/qwik/Accordion/high.jsx +1 -0
- package/dist/test/qwik/Accordion/low.jsx +92 -0
- package/dist/test/qwik/Accordion/med.jsx +9 -0
- package/dist/test/qwik/For/high.jsx +1 -0
- package/dist/test/qwik/For/low.jsx +55 -0
- package/dist/test/qwik/For/med.jsx +9 -0
- package/dist/test/qwik/Image/high.js +1 -0
- package/dist/test/qwik/Image/low.js +68 -0
- package/dist/test/qwik/Image/med.js +9 -0
- package/dist/test/qwik/Image.slow/high.js +1 -0
- package/dist/test/qwik/Image.slow/low.js +68 -0
- package/dist/test/qwik/Image.slow/med.js +9 -0
- package/dist/test/qwik/button/high.js +8 -0
- package/dist/test/qwik/button/low.js +34 -0
- package/dist/test/qwik/button/med.js +9 -0
- package/dist/test/qwik/hello_world/stylesheet/high.jsx +1 -0
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +24 -0
- package/dist/test/qwik/hello_world/stylesheet/med.jsx +9 -0
- package/dist/test/qwik/page-with-symbol/high.js +1 -0
- package/dist/test/qwik/page-with-symbol/low.js +49 -0
- package/dist/test/qwik/page-with-symbol/med.js +9 -0
- package/dist/test/qwik/svg/high.js +1 -0
- package/dist/test/qwik/svg/low.js +30 -0
- package/dist/test/qwik/svg/med.js +9 -0
- package/dist/test/qwik/todo/Todo.cjs/high.cjs +31 -0
- package/dist/test/qwik/todo/Todo.cjs/low.cjs +1 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +59 -0
- package/dist/test/qwik/todo/Todo.js/high.js +5 -0
- package/dist/test/qwik/todo/Todo.js/low.js +0 -0
- package/dist/test/qwik/todo/Todo.js/med.js +1 -0
- package/dist/test/qwik/todo/Todo.tsx/high.tsx +30 -0
- package/dist/test/qwik/todo/Todo.tsx/low.tsx +1 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +34 -0
- package/dist/test/qwik/todos/Todo.tsx/high.tsx +12 -0
- package/dist/test/qwik/todos/Todo.tsx/low.tsx +25 -0
- package/dist/test/qwik/todos/Todo.tsx/med.tsx +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -4
- package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +0 -11
- package/dist/src/__tests__/data/blocks/tabs.raw.jsx +0 -24
- package/dist/src/__tests__/qoot.test.d.ts +0 -1
- package/dist/src/__tests__/qoot.test.js +0 -115
- package/dist/src/generators/jsx-lite.d.ts +0 -10
- package/dist/src/generators/jsx-lite.js +0 -176
- package/dist/src/generators/qoot.d.ts +0 -21
- package/dist/src/generators/qoot.js +0 -442
- package/dist/src/generators/qwik.d.ts +0 -21
- package/dist/src/generators/qwik.js +0 -458
- package/dist/src/helpers/create-jsx-lite-component.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-component.js +0 -16
- package/dist/src/helpers/create-jsx-lite-context.d.ts +0 -4
- package/dist/src/helpers/create-jsx-lite-context.js +0 -18
- package/dist/src/helpers/create-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-node.js +0 -16
- package/dist/src/helpers/is-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/is-jsx-lite-node.js +0 -7
- package/dist/src/types/jsx-lite-component.d.ts +0 -63
- package/dist/src/types/jsx-lite-context.d.ts +0 -6
- package/dist/src/types/jsx-lite-node.d.ts +0 -13
- package/dist/src/types/jsx-lite-node.js +0 -2
- package/dist/src/types/jsx-lite-styles.d.ts +0 -1
- package/dist/src/types/jsx-lite-styles.js +0 -2
- package/dist/test/qoot/Todo/bundle.js +0 -88
- package/dist/test/qoot/Todo/component.ts +0 -17
- package/dist/test/qoot/Todo/onButtonClick.ts +0 -13
- package/dist/test/qoot/Todo/onInput2Blur.ts +0 -11
- package/dist/test/qoot/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qoot/Todo/onInputClick.ts +0 -10
- package/dist/test/qoot/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qoot/Todo/public.ts +0 -4
- package/dist/test/qoot/Todo/template.tsx +0 -46
- package/dist/test/qoot/Todos/component.ts +0 -9
- package/dist/test/qoot/Todos/onInputClick.ts +0 -14
- package/dist/test/qoot/Todos/public.ts +0 -3
- package/dist/test/qoot/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todo/bundle.js +0 -46
- package/dist/test/qwik/Todo/component.ts +0 -17
- package/dist/test/qwik/Todo/onButtonClick.ts +0 -10
- package/dist/test/qwik/Todo/onInput2Blur.ts +0 -14
- package/dist/test/qwik/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo/onInputClick.ts +0 -13
- package/dist/test/qwik/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qwik/Todo/public.ts +0 -3
- package/dist/test/qwik/Todo/template.tsx +0 -46
- package/dist/test/qwik/Todo.ts +0 -4
- package/dist/test/qwik/Todo_component.ts +0 -17
- package/dist/test/qwik/Todo_onButtonClick.ts +0 -13
- package/dist/test/qwik/Todo_onInput2Blur.ts +0 -14
- package/dist/test/qwik/Todo_onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo_onInputClick.ts +0 -13
- package/dist/test/qwik/Todo_onLabelDblClick.ts +0 -14
- package/dist/test/qwik/Todo_template.tsx +0 -46
- package/dist/test/qwik/Todos/component.ts +0 -9
- package/dist/test/qwik/Todos/onInputClick.ts +0 -14
- package/dist/test/qwik/Todos/public.ts +0 -3
- package/dist/test/qwik/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todos.ts +0 -3
- package/dist/test/qwik/Todos_component.ts +0 -9
- package/dist/test/qwik/Todos_onInputClick.ts +0 -14
- package/dist/test/qwik/Todos_template.tsx +0 -30
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { MitosisComponent } from '../types/mitosis-component';
|
|
2
1
|
import { MitosisNode } from '../types/mitosis-node';
|
|
3
2
|
import { BuilderElement } from '@builder.io/sdk';
|
|
4
|
-
|
|
3
|
+
import { TranspilerArgs } from '../types/config';
|
|
4
|
+
export interface ToBuilderOptions {
|
|
5
5
|
includeIds?: boolean;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
declare type InternalOptions = {
|
|
8
8
|
skipMapper?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare const blockToBuilder: (json: MitosisNode, options?: ToBuilderOptions, _internalOptions?: InternalOptions) => BuilderElement;
|
|
11
|
-
export declare const componentToBuilder: (
|
|
11
|
+
export declare const componentToBuilder: (options?: ToBuilderOptions) => ({ component, }: TranspilerArgs) => {
|
|
12
12
|
data: {
|
|
13
13
|
httpRequests: any;
|
|
14
14
|
jsCode: string;
|
|
@@ -34,7 +34,7 @@ var builder_1 = require("../parsers/builder");
|
|
|
34
34
|
var remove_surrounding_block_1 = require("../helpers/remove-surrounding-block");
|
|
35
35
|
var traverse_1 = __importDefault(require("traverse"));
|
|
36
36
|
var omitMetaProperties = function (obj) {
|
|
37
|
-
return lodash_1.omitBy(obj, function (_value, key) { return key.startsWith('$'); });
|
|
37
|
+
return (0, lodash_1.omitBy)(obj, function (_value, key) { return key.startsWith('$'); });
|
|
38
38
|
};
|
|
39
39
|
var builderBlockPrefixes = ['Amp', 'Core', 'Builder', 'Raw', 'Form'];
|
|
40
40
|
var mapComponentName = function (name) {
|
|
@@ -45,8 +45,8 @@ var mapComponentName = function (name) {
|
|
|
45
45
|
var prefix = builderBlockPrefixes_1[_i];
|
|
46
46
|
if (name.startsWith(prefix)) {
|
|
47
47
|
var suffix = name.replace(prefix, '');
|
|
48
|
-
if (is_upper_case_1.isUpperCase(suffix[0])) {
|
|
49
|
-
return prefix
|
|
48
|
+
if ((0, is_upper_case_1.isUpperCase)(suffix[0])) {
|
|
49
|
+
return "".concat(prefix, ":").concat(name.replace(prefix, ''));
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -61,7 +61,7 @@ var componentMappers = __assign(__assign({}, (!builder_1.symbolBlocksAsChildren
|
|
|
61
61
|
json5_1.default.parse(node.bindings.symbol)) ||
|
|
62
62
|
{};
|
|
63
63
|
if (child) {
|
|
64
|
-
lodash_1.set(symbolOptions, 'content.data.blocks', child.children.map(function (item) { return exports.blockToBuilder(item, options); }));
|
|
64
|
+
(0, lodash_1.set)(symbolOptions, 'content.data.blocks', child.children.map(function (item) { return (0, exports.blockToBuilder)(item, options); }));
|
|
65
65
|
}
|
|
66
66
|
return el({
|
|
67
67
|
component: {
|
|
@@ -74,15 +74,14 @@ var componentMappers = __assign(__assign({}, (!builder_1.symbolBlocksAsChildren
|
|
|
74
74
|
}, options);
|
|
75
75
|
},
|
|
76
76
|
})), { Columns: function (node, options) {
|
|
77
|
-
var block = exports.blockToBuilder(node, options, { skipMapper: true });
|
|
77
|
+
var block = (0, exports.blockToBuilder)(node, options, { skipMapper: true });
|
|
78
78
|
var columns = block.children.map(function (item) { return ({
|
|
79
79
|
blocks: item.children,
|
|
80
80
|
}); });
|
|
81
81
|
block.component.options.columns = columns;
|
|
82
82
|
block.children = [];
|
|
83
83
|
return block;
|
|
84
|
-
},
|
|
85
|
-
For: function (node, options) {
|
|
84
|
+
}, For: function (node, options) {
|
|
86
85
|
return el({
|
|
87
86
|
component: {
|
|
88
87
|
name: 'Core:Fragment',
|
|
@@ -93,10 +92,9 @@ var componentMappers = __assign(__assign({}, (!builder_1.symbolBlocksAsChildren
|
|
|
93
92
|
},
|
|
94
93
|
children: node.children
|
|
95
94
|
.filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
|
|
96
|
-
.map(function (node) { return exports.blockToBuilder(node, options); }),
|
|
95
|
+
.map(function (node) { return (0, exports.blockToBuilder)(node, options); }),
|
|
97
96
|
}, options);
|
|
98
|
-
},
|
|
99
|
-
Show: function (node, options) {
|
|
97
|
+
}, Show: function (node, options) {
|
|
100
98
|
return el({
|
|
101
99
|
// TODO: the reverse mapping for this
|
|
102
100
|
component: {
|
|
@@ -107,7 +105,7 @@ var componentMappers = __assign(__assign({}, (!builder_1.symbolBlocksAsChildren
|
|
|
107
105
|
},
|
|
108
106
|
children: node.children
|
|
109
107
|
.filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
|
|
110
|
-
.map(function (node) { return exports.blockToBuilder(node, options); }),
|
|
108
|
+
.map(function (node) { return (0, exports.blockToBuilder)(node, options); }),
|
|
111
109
|
}, options);
|
|
112
110
|
} });
|
|
113
111
|
var el = function (options, toBuilderOptions) { return (__assign(__assign({ '@type': '@builder.io/sdk:Element' }, (toBuilderOptions.includeIds && {
|
|
@@ -119,7 +117,7 @@ var el = function (options, toBuilderOptions) { return (__assign(__assign({ '@ty
|
|
|
119
117
|
function tryFormat(code) {
|
|
120
118
|
var str = code;
|
|
121
119
|
try {
|
|
122
|
-
str = standalone_1.format(str, {
|
|
120
|
+
str = (0, standalone_1.format)(str, {
|
|
123
121
|
parser: 'babel',
|
|
124
122
|
plugins: [
|
|
125
123
|
require('prettier/parser-babel'), // To support running in browsers
|
|
@@ -158,14 +156,14 @@ var blockToBuilder = function (json, options, _internalOptions) {
|
|
|
158
156
|
},
|
|
159
157
|
}, options);
|
|
160
158
|
}
|
|
161
|
-
var thisIsComponent = is_component_1.isComponent(json);
|
|
159
|
+
var thisIsComponent = (0, is_component_1.isComponent)(json);
|
|
162
160
|
var bindings = json.bindings;
|
|
163
161
|
var actions = {};
|
|
164
162
|
for (var key in bindings) {
|
|
165
163
|
var eventBindingKeyRegex = /^on([A-Z])/;
|
|
166
164
|
var firstCharMatchForEventBindingKey = (_b = key.match(eventBindingKeyRegex)) === null || _b === void 0 ? void 0 : _b[1];
|
|
167
165
|
if (firstCharMatchForEventBindingKey) {
|
|
168
|
-
actions[key.replace(eventBindingKeyRegex, firstCharMatchForEventBindingKey.toLowerCase())] = remove_surrounding_block_1.removeSurroundingBlock(bindings[key]);
|
|
166
|
+
actions[key.replace(eventBindingKeyRegex, firstCharMatchForEventBindingKey.toLowerCase())] = (0, remove_surrounding_block_1.removeSurroundingBlock)(bindings[key]);
|
|
169
167
|
delete bindings[key];
|
|
170
168
|
}
|
|
171
169
|
}
|
|
@@ -177,12 +175,12 @@ var blockToBuilder = function (json, options, _internalOptions) {
|
|
|
177
175
|
return "continue";
|
|
178
176
|
}
|
|
179
177
|
var value = bindings[key];
|
|
180
|
-
var parsed = lodash_1.attempt(function () { return json5_1.default.parse(value); });
|
|
178
|
+
var parsed = (0, lodash_1.attempt)(function () { return json5_1.default.parse(value); });
|
|
181
179
|
if (!(parsed instanceof Error)) {
|
|
182
180
|
componentOptions[key] = parsed;
|
|
183
181
|
}
|
|
184
182
|
else {
|
|
185
|
-
builderBindings["component.options."
|
|
183
|
+
builderBindings["component.options.".concat(key)] = bindings[key];
|
|
186
184
|
}
|
|
187
185
|
};
|
|
188
186
|
for (var key in bindings) {
|
|
@@ -213,7 +211,7 @@ var blockToBuilder = function (json, options, _internalOptions) {
|
|
|
213
211
|
}
|
|
214
212
|
if (thisIsComponent) {
|
|
215
213
|
for (var key in json.bindings) {
|
|
216
|
-
bindings["component.options."
|
|
214
|
+
bindings["component.options.".concat(key)] = json.bindings[key];
|
|
217
215
|
}
|
|
218
216
|
}
|
|
219
217
|
return el(__assign(__assign(__assign(__assign({ tagName: thisIsComponent ? undefined : json.name }, (hasCss && {
|
|
@@ -230,51 +228,53 @@ var blockToBuilder = function (json, options, _internalOptions) {
|
|
|
230
228
|
? undefined
|
|
231
229
|
: omitMetaProperties(json.properties), bindings: thisIsComponent
|
|
232
230
|
? builderBindings
|
|
233
|
-
: lodash_1.omit(bindings, 'css'), actions: actions, children: json.children
|
|
231
|
+
: (0, lodash_1.omit)(bindings, 'css'), actions: actions, children: json.children
|
|
234
232
|
.filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
|
|
235
|
-
.map(function (child) { return exports.blockToBuilder(child, options); }) }), options);
|
|
233
|
+
.map(function (child) { return (0, exports.blockToBuilder)(child, options); }) }), options);
|
|
236
234
|
};
|
|
237
235
|
exports.blockToBuilder = blockToBuilder;
|
|
238
|
-
var componentToBuilder = function (
|
|
239
|
-
var _a, _b;
|
|
236
|
+
var componentToBuilder = function (options) {
|
|
240
237
|
if (options === void 0) { options = {}; }
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
?
|
|
248
|
-
:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
"\n "])), !has_props_1.hasProps(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
var _a;
|
|
269
|
-
if (builder_1.isBuilderElement(el)) {
|
|
270
|
-
var value = subComponentMap[(_a = el.component) === null || _a === void 0 ? void 0 : _a.name];
|
|
271
|
-
if (value) {
|
|
272
|
-
console.log('applied?');
|
|
273
|
-
lodash_1.set(el, 'component.options.symbol.content', value);
|
|
274
|
-
}
|
|
238
|
+
return function (_a) {
|
|
239
|
+
var _b, _c;
|
|
240
|
+
var component = _a.component;
|
|
241
|
+
var hasState = Boolean(Object.keys(component.state).length);
|
|
242
|
+
var result = (0, fast_clone_1.fastClone)({
|
|
243
|
+
data: {
|
|
244
|
+
httpRequests: (_c = (_b = component === null || component === void 0 ? void 0 : component.meta) === null || _b === void 0 ? void 0 : _b.useMetadata) === null || _c === void 0 ? void 0 : _c.httpRequests,
|
|
245
|
+
jsCode: tryFormat((0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n\n ", "\n\n ", "\n "], ["\n ", "\n\n ", "\n\n ", "\n "])), !(0, has_props_1.hasProps)(component) ? '' : "var props = state;", !hasState
|
|
246
|
+
? ''
|
|
247
|
+
: "Object.assign(state, ".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(component), ");"), !component.hooks.onMount ? '' : component.hooks.onMount)),
|
|
248
|
+
tsCode: tryFormat((0, dedent_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n\n ", "\n\n ", "\n "], ["\n ", "\n\n ", "\n\n ", "\n "])), !(0, has_props_1.hasProps)(component) ? '' : "var props = state;", !hasState
|
|
249
|
+
? ''
|
|
250
|
+
: "useState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(component), ");"), !component.hooks.onMount
|
|
251
|
+
? ''
|
|
252
|
+
: "onMount(() => {\n ".concat(component.hooks.onMount, "\n })"))),
|
|
253
|
+
blocks: component.children
|
|
254
|
+
.filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
|
|
255
|
+
.map(function (child) { return (0, exports.blockToBuilder)(child, options); }),
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
var subComponentMap = {};
|
|
259
|
+
for (var _i = 0, _d = component.subComponents; _i < _d.length; _i++) {
|
|
260
|
+
var subComponent = _d[_i];
|
|
261
|
+
var name_1 = subComponent.name;
|
|
262
|
+
subComponentMap[name_1] = (0, exports.componentToBuilder)(options)({
|
|
263
|
+
component: subComponent,
|
|
264
|
+
});
|
|
275
265
|
}
|
|
276
|
-
|
|
277
|
-
|
|
266
|
+
(0, traverse_1.default)([result, subComponentMap]).forEach(function (el) {
|
|
267
|
+
var _a;
|
|
268
|
+
if ((0, builder_1.isBuilderElement)(el)) {
|
|
269
|
+
var value = subComponentMap[(_a = el.component) === null || _a === void 0 ? void 0 : _a.name];
|
|
270
|
+
if (value) {
|
|
271
|
+
console.log('applied?');
|
|
272
|
+
(0, lodash_1.set)(el, 'component.options.symbol.content', value);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
return result;
|
|
277
|
+
};
|
|
278
278
|
};
|
|
279
279
|
exports.componentToBuilder = componentToBuilder;
|
|
280
280
|
var templateObject_1, templateObject_2;
|
|
@@ -2,5 +2,7 @@ import { MitosisContext } from '../../types/mitosis-context';
|
|
|
2
2
|
declare type ContextToReactOptions = {
|
|
3
3
|
format?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare
|
|
5
|
+
export declare const contextToReact: (options?: ContextToReactOptions) => ({ context, }: {
|
|
6
|
+
context: MitosisContext;
|
|
7
|
+
}) => string;
|
|
6
8
|
export {};
|
|
@@ -3,23 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.contextToReact = void 0;
|
|
4
4
|
var standalone_1 = require("prettier/standalone");
|
|
5
5
|
var get_state_object_string_1 = require("../../helpers/get-state-object-string");
|
|
6
|
-
function
|
|
6
|
+
var contextToReact = function (options) {
|
|
7
7
|
if (options === void 0) { options = {}; }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
return function (_a) {
|
|
9
|
+
var context = _a.context;
|
|
10
|
+
var str = "\n import { createContext } from 'react';\n\n export default createContext(".concat((0, get_state_object_string_1.getMemberObjectString)(context.value), ")\n ");
|
|
11
|
+
if (options.format !== false) {
|
|
12
|
+
try {
|
|
13
|
+
str = (0, standalone_1.format)(str, {
|
|
14
|
+
parser: 'typescript',
|
|
15
|
+
plugins: [
|
|
16
|
+
require('prettier/parser-typescript'), // To support running in browsers
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
console.error('Format error for file:', str);
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
17
24
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return str;
|
|
24
|
-
}
|
|
25
|
+
return str;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
25
28
|
exports.contextToReact = contextToReact;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare type ToHtmlOptions = {
|
|
4
|
-
prettier?: boolean;
|
|
1
|
+
import { BaseTranspilerOptions, Transpiler } from '../types/config';
|
|
2
|
+
export interface ToHtmlOptions extends BaseTranspilerOptions {
|
|
5
3
|
format?: 'class' | 'script';
|
|
6
|
-
plugins?: Plugin[];
|
|
7
4
|
prefix?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const componentToHtml: (
|
|
10
|
-
export declare const componentToCustomElement: (
|
|
11
|
-
export {};
|
|
5
|
+
}
|
|
6
|
+
export declare const componentToHtml: (options?: ToHtmlOptions) => Transpiler;
|
|
7
|
+
export declare const componentToCustomElement: (options?: ToHtmlOptions) => Transpiler;
|