@builder.io/mitosis 0.0.45 → 0.0.46
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 +2 -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 +36 -36
- 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.js +13 -13
- package/dist/src/generators/qwik/handlers.js +12 -8
- package/dist/src/generators/qwik/jsx.js +13 -9
- package/dist/src/generators/qwik/styles.js +11 -7
- package/dist/src/generators/react-native.d.ts +4 -7
- package/dist/src/generators/react-native.js +25 -22
- package/dist/src/generators/react.d.ts +4 -8
- package/dist/src/generators/react.js +103 -112
- 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 +169 -169
- package/dist/src/helpers/babel-transform.js +9 -9
- package/dist/src/helpers/collect-styles.js +39 -39
- 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 +5 -5
- 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 +4 -4
- 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/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 +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/modules/plugins.d.ts +2 -10
- package/dist/src/parsers/angular.js +13 -13
- package/dist/src/parsers/builder.js +54 -58
- package/dist/src/parsers/context.js +2 -2
- package/dist/src/parsers/jsx.js +59 -87
- package/dist/src/parsers/liquid.js +191 -194
- package/dist/src/plugins/compile-away-builder-components.js +49 -45
- 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/{test/qwik/Todo/Todo.js/low.js → 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/{Todo → todo}/Todo.cjs/high.cjs +0 -0
- package/dist/test/qwik/{Todo → todo}/Todo.cjs/low.cjs +0 -0
- package/dist/test/qwik/{Todo → todo}/Todo.cjs/med.cjs +0 -0
- package/dist/test/qwik/{Todo → todo}/Todo.js/high.js +0 -0
- package/dist/test/qwik/{qwik/todo → todo}/Todo.js/low.js +0 -0
- package/dist/test/qwik/{Todo → todo}/Todo.js/med.js +0 -0
- package/dist/test/qwik/{Todo → todo}/Todo.tsx/high.tsx +0 -0
- package/dist/test/qwik/{Todo → todo}/Todo.tsx/low.tsx +0 -0
- package/dist/test/qwik/{Todo → todo}/Todo.tsx/med.tsx +0 -0
- package/dist/test/qwik/{Todos → todos}/Todo.tsx/high.tsx +0 -0
- package/dist/test/qwik/{Todos → todos}/Todo.tsx/low.tsx +0 -0
- package/dist/test/qwik/{Todos → todos}/Todo.tsx/med.tsx +0 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- 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
- package/dist/test/qwik/qwik/Image/high.js +0 -1
- package/dist/test/qwik/qwik/Image/low.js +0 -75
- package/dist/test/qwik/qwik/Image/med.js +0 -9
- package/dist/test/qwik/qwik/Image.slow/high.js +0 -1
- package/dist/test/qwik/qwik/Image.slow/low.js +0 -75
- package/dist/test/qwik/qwik/Image.slow/med.js +0 -9
- package/dist/test/qwik/qwik/button/high.js +0 -8
- package/dist/test/qwik/qwik/button/low.js +0 -34
- package/dist/test/qwik/qwik/button/med.js +0 -9
- package/dist/test/qwik/qwik/hello_world/stylesheet/high.jsx +0 -1
- package/dist/test/qwik/qwik/hello_world/stylesheet/low.jsx +0 -24
- package/dist/test/qwik/qwik/hello_world/stylesheet/med.jsx +0 -9
- package/dist/test/qwik/qwik/page-with-symbol/high.js +0 -1
- package/dist/test/qwik/qwik/page-with-symbol/low.js +0 -49
- package/dist/test/qwik/qwik/page-with-symbol/med.js +0 -9
- package/dist/test/qwik/qwik/svg/high.js +0 -1
- package/dist/test/qwik/qwik/svg/low.js +0 -30
- package/dist/test/qwik/qwik/svg/med.js +0 -9
- package/dist/test/qwik/qwik/todo/Todo.cjs/high.cjs +0 -31
- package/dist/test/qwik/qwik/todo/Todo.cjs/low.cjs +0 -1
- package/dist/test/qwik/qwik/todo/Todo.cjs/med.cjs +0 -59
- package/dist/test/qwik/qwik/todo/Todo.js/high.js +0 -5
- package/dist/test/qwik/qwik/todo/Todo.js/med.js +0 -1
- package/dist/test/qwik/qwik/todo/Todo.tsx/high.tsx +0 -30
- package/dist/test/qwik/qwik/todo/Todo.tsx/low.tsx +0 -1
- package/dist/test/qwik/qwik/todo/Todo.tsx/med.tsx +0 -34
- package/dist/test/qwik/qwik/todos/Todo.tsx/high.tsx +0 -12
- package/dist/test/qwik/qwik/todos/Todo.tsx/low.tsx +0 -24
- package/dist/test/qwik/qwik/todos/Todo.tsx/med.tsx +0 -8
|
@@ -28,9 +28,9 @@ var isValidLiquidBinding = function (str) {
|
|
|
28
28
|
exports.isValidLiquidBinding = isValidLiquidBinding;
|
|
29
29
|
var mappers = {
|
|
30
30
|
Fragment: function (json, options) {
|
|
31
|
-
return "<div>"
|
|
31
|
+
return "<div>".concat(json.children
|
|
32
32
|
.map(function (item) { return blockToLiquid(item, options); })
|
|
33
|
-
.join('\n')
|
|
33
|
+
.join('\n'), "</div>");
|
|
34
34
|
},
|
|
35
35
|
};
|
|
36
36
|
// TODO: spread support
|
|
@@ -44,18 +44,18 @@ var blockToLiquid = function (json, options) {
|
|
|
44
44
|
return json.properties._text;
|
|
45
45
|
}
|
|
46
46
|
if (json.bindings._text) {
|
|
47
|
-
if (!exports.isValidLiquidBinding(json.bindings._text)) {
|
|
47
|
+
if (!(0, exports.isValidLiquidBinding)(json.bindings._text)) {
|
|
48
48
|
return '';
|
|
49
49
|
}
|
|
50
|
-
return "{{"
|
|
50
|
+
return "{{".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings._text), "}}");
|
|
51
51
|
}
|
|
52
52
|
var str = '';
|
|
53
53
|
if (json.name === 'For') {
|
|
54
|
-
if (!(exports.isValidLiquidBinding(json.bindings.each) &&
|
|
55
|
-
exports.isValidLiquidBinding(json.properties._forName))) {
|
|
54
|
+
if (!((0, exports.isValidLiquidBinding)(json.bindings.each) &&
|
|
55
|
+
(0, exports.isValidLiquidBinding)(json.properties._forName))) {
|
|
56
56
|
return str;
|
|
57
57
|
}
|
|
58
|
-
str += "{% for "
|
|
58
|
+
str += "{% for ".concat(json.properties._forName, " in ").concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings.each), " %}");
|
|
59
59
|
if (json.children) {
|
|
60
60
|
str += json.children
|
|
61
61
|
.map(function (item) { return blockToLiquid(item, options); })
|
|
@@ -64,10 +64,10 @@ var blockToLiquid = function (json, options) {
|
|
|
64
64
|
str += '{% endfor %}';
|
|
65
65
|
}
|
|
66
66
|
else if (json.name === 'Show') {
|
|
67
|
-
if (!exports.isValidLiquidBinding(json.bindings.when)) {
|
|
67
|
+
if (!(0, exports.isValidLiquidBinding)(json.bindings.when)) {
|
|
68
68
|
return str;
|
|
69
69
|
}
|
|
70
|
-
str += "{% if "
|
|
70
|
+
str += "{% if ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings.when), " %}");
|
|
71
71
|
if (json.children) {
|
|
72
72
|
str += json.children
|
|
73
73
|
.map(function (item) { return blockToLiquid(item, options); })
|
|
@@ -76,14 +76,14 @@ var blockToLiquid = function (json, options) {
|
|
|
76
76
|
str += '{% endif %}';
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
|
-
str += "<"
|
|
79
|
+
str += "<".concat(json.name, " ");
|
|
80
80
|
if (json.bindings._spread === '_spread' &&
|
|
81
|
-
exports.isValidLiquidBinding(json.bindings._spread)) {
|
|
82
|
-
str += "\n {% for _attr in "
|
|
81
|
+
(0, exports.isValidLiquidBinding)(json.bindings._spread)) {
|
|
82
|
+
str += "\n {% for _attr in ".concat(json.bindings._spread, " %}\n {{ _attr[0] }}=\"{{ _attr[1] }}\"\n {% endfor %}\n ");
|
|
83
83
|
}
|
|
84
84
|
for (var key in json.properties) {
|
|
85
85
|
var value = json.properties[key];
|
|
86
|
-
str += " "
|
|
86
|
+
str += " ".concat(key, "=\"").concat(value, "\" ");
|
|
87
87
|
}
|
|
88
88
|
for (var key in json.bindings) {
|
|
89
89
|
if (key === '_spread' || key === 'ref' || key === 'css') {
|
|
@@ -91,12 +91,12 @@ var blockToLiquid = function (json, options) {
|
|
|
91
91
|
}
|
|
92
92
|
var value = json.bindings[key];
|
|
93
93
|
// TODO: proper babel transform to replace. Util for this
|
|
94
|
-
var useValue = strip_state_and_props_refs_1.stripStateAndPropsRefs(value);
|
|
94
|
+
var useValue = (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(value);
|
|
95
95
|
if (key.startsWith('on')) {
|
|
96
96
|
// Do nothing
|
|
97
97
|
}
|
|
98
|
-
else if (exports.isValidLiquidBinding(useValue)) {
|
|
99
|
-
str += " "
|
|
98
|
+
else if ((0, exports.isValidLiquidBinding)(useValue)) {
|
|
99
|
+
str += " ".concat(key, "=\"{{").concat(useValue, "}}\" ");
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
if (jsx_1.selfClosingTags.has(json.name)) {
|
|
@@ -108,55 +108,58 @@ var blockToLiquid = function (json, options) {
|
|
|
108
108
|
.map(function (item) { return blockToLiquid(item, options); })
|
|
109
109
|
.join('\n');
|
|
110
110
|
}
|
|
111
|
-
str += "</"
|
|
111
|
+
str += "</".concat(json.name, ">");
|
|
112
112
|
}
|
|
113
113
|
return str;
|
|
114
114
|
};
|
|
115
115
|
// TODO: add JS support similar to componentToHtml()
|
|
116
|
-
var componentToLiquid = function (
|
|
116
|
+
var componentToLiquid = function (options) {
|
|
117
117
|
if (options === void 0) { options = {}; }
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
json =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
strip_meta_properties_1.stripMetaProperties(json);
|
|
124
|
-
if (options.plugins) {
|
|
125
|
-
json = plugins_1.runPostJsonPlugins(json, options.plugins);
|
|
126
|
-
}
|
|
127
|
-
var str = json.children.map(function (item) { return blockToLiquid(item); }).join('\n');
|
|
128
|
-
if (css.trim().length) {
|
|
129
|
-
str += "<style>" + css + "</style>";
|
|
130
|
-
}
|
|
131
|
-
if (options.reactive) {
|
|
132
|
-
var stateObjectString = get_state_object_string_1.getStateObjectStringFromComponent(json);
|
|
133
|
-
if (stateObjectString.trim().length > 4) {
|
|
134
|
-
str += "<script reactive>\n export default {\n state: " + stateObjectString + "\n }\n </script>";
|
|
118
|
+
return function (_a) {
|
|
119
|
+
var component = _a.component;
|
|
120
|
+
var json = (0, fast_clone_1.fastClone)(component);
|
|
121
|
+
if (options.plugins) {
|
|
122
|
+
json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
|
|
135
123
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (options.prettier !== false) {
|
|
141
|
-
try {
|
|
142
|
-
str = standalone_1.format(str, {
|
|
143
|
-
parser: 'html',
|
|
144
|
-
htmlWhitespaceSensitivity: 'ignore',
|
|
145
|
-
plugins: [
|
|
146
|
-
// To support running in browsers
|
|
147
|
-
require('prettier/parser-html'),
|
|
148
|
-
require('prettier/parser-postcss'),
|
|
149
|
-
require('prettier/parser-babel'),
|
|
150
|
-
],
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
console.warn('Could not prettify', { string: str }, err);
|
|
124
|
+
var css = (0, collect_styles_1.collectCss)(json);
|
|
125
|
+
(0, strip_meta_properties_1.stripMetaProperties)(json);
|
|
126
|
+
if (options.plugins) {
|
|
127
|
+
json = (0, plugins_1.runPostJsonPlugins)(json, options.plugins);
|
|
155
128
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
129
|
+
var str = json.children.map(function (item) { return blockToLiquid(item); }).join('\n');
|
|
130
|
+
if (css.trim().length) {
|
|
131
|
+
str += "<style>".concat(css, "</style>");
|
|
132
|
+
}
|
|
133
|
+
if (options.reactive) {
|
|
134
|
+
var stateObjectString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(json);
|
|
135
|
+
if (stateObjectString.trim().length > 4) {
|
|
136
|
+
str += "<script reactive>\n export default {\n state: ".concat(stateObjectString, "\n }\n </script>");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (options.plugins) {
|
|
140
|
+
str = (0, plugins_1.runPreCodePlugins)(str, options.plugins);
|
|
141
|
+
}
|
|
142
|
+
if (options.prettier !== false) {
|
|
143
|
+
try {
|
|
144
|
+
str = (0, standalone_1.format)(str, {
|
|
145
|
+
parser: 'html',
|
|
146
|
+
htmlWhitespaceSensitivity: 'ignore',
|
|
147
|
+
plugins: [
|
|
148
|
+
// To support running in browsers
|
|
149
|
+
require('prettier/parser-html'),
|
|
150
|
+
require('prettier/parser-postcss'),
|
|
151
|
+
require('prettier/parser-babel'),
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
console.warn('Could not prettify', { string: str }, err);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (options.plugins) {
|
|
160
|
+
str = (0, plugins_1.runPostCodePlugins)(str, options.plugins);
|
|
161
|
+
}
|
|
162
|
+
return str;
|
|
163
|
+
};
|
|
161
164
|
};
|
|
162
165
|
exports.componentToLiquid = componentToLiquid;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transpiler } from '..';
|
|
2
2
|
import { MitosisNode } from '../types/mitosis-node';
|
|
3
|
-
export
|
|
4
|
-
export declare type MitosisFormat = 'react' | 'legacy';
|
|
5
|
-
export declare type ToMitosisOptions = {
|
|
3
|
+
export interface ToMitosisOptions {
|
|
6
4
|
prettier?: boolean;
|
|
7
|
-
format:
|
|
8
|
-
}
|
|
5
|
+
format: 'react' | 'legacy';
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_FORMAT: ToMitosisOptions['format'];
|
|
9
8
|
export declare const blockToMitosis: (json: MitosisNode, toMitosisOptions?: Partial<ToMitosisOptions>) => string;
|
|
10
|
-
export declare const componentToMitosis: (
|
|
9
|
+
export declare const componentToMitosis: (toMitosisOptions?: Partial<ToMitosisOptions>) => Transpiler;
|
|
@@ -39,7 +39,7 @@ var blockToMitosis = function (json, toMitosisOptions) {
|
|
|
39
39
|
if (toMitosisOptions === void 0) { toMitosisOptions = {}; }
|
|
40
40
|
var options = __assign({ format: exports.DEFAULT_FORMAT }, toMitosisOptions);
|
|
41
41
|
if (options.format === 'react') {
|
|
42
|
-
return react_1.blockToReact(json, {
|
|
42
|
+
return (0, react_1.blockToReact)(json, {
|
|
43
43
|
format: 'lite',
|
|
44
44
|
stateType: 'useState',
|
|
45
45
|
stylesType: 'emotion',
|
|
@@ -48,18 +48,18 @@ var blockToMitosis = function (json, toMitosisOptions) {
|
|
|
48
48
|
}
|
|
49
49
|
if (json.name === 'For') {
|
|
50
50
|
var needsWrapper = json.children.length !== 1;
|
|
51
|
-
return "<For each={"
|
|
51
|
+
return "<For each={".concat(json.bindings.each, "}>\n {(").concat(json.properties._forName, ", index) =>\n ").concat(needsWrapper ? '<>' : '', "\n ").concat(json.children.map(function (child) { return (0, exports.blockToMitosis)(child, options); }), "}\n ").concat(needsWrapper ? '</>' : '', "\n </For>");
|
|
52
52
|
}
|
|
53
53
|
if (json.properties._text) {
|
|
54
54
|
return json.properties._text;
|
|
55
55
|
}
|
|
56
56
|
if (json.bindings._text) {
|
|
57
|
-
return "{"
|
|
57
|
+
return "{".concat(json.bindings._text, "}");
|
|
58
58
|
}
|
|
59
59
|
var str = '';
|
|
60
|
-
str += "<"
|
|
60
|
+
str += "<".concat(json.name, " ");
|
|
61
61
|
if (json.bindings._spread) {
|
|
62
|
-
str += " {...("
|
|
62
|
+
str += " {...(".concat(json.bindings._spread, ")} ");
|
|
63
63
|
}
|
|
64
64
|
for (var key in json.properties) {
|
|
65
65
|
var value = (json.properties[key] || '')
|
|
@@ -69,7 +69,7 @@ var blockToMitosis = function (json, toMitosisOptions) {
|
|
|
69
69
|
console.warn('Skipping invalid attribute name:', key);
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
str += " "
|
|
72
|
+
str += " ".concat(key, "=\"").concat(value, "\" ");
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
for (var key in json.bindings) {
|
|
@@ -78,14 +78,14 @@ var blockToMitosis = function (json, toMitosisOptions) {
|
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
80
|
if (key.startsWith('on')) {
|
|
81
|
-
str += " "
|
|
81
|
+
str += " ".concat(key, "={event => ").concat(value.replace(/\s*;$/, ''), "} ");
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
84
|
if (!isValidAttributeName(key)) {
|
|
85
85
|
console.warn('Skipping invalid attribute name:', key);
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
-
str += " "
|
|
88
|
+
str += " ".concat(key, "={").concat(value, "} ");
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -100,77 +100,75 @@ var blockToMitosis = function (json, toMitosisOptions) {
|
|
|
100
100
|
str += '>';
|
|
101
101
|
if (json.children) {
|
|
102
102
|
str += json.children
|
|
103
|
-
.map(function (item) { return exports.blockToMitosis(item, options); })
|
|
103
|
+
.map(function (item) { return (0, exports.blockToMitosis)(item, options); })
|
|
104
104
|
.join('\n');
|
|
105
105
|
}
|
|
106
|
-
str += "</"
|
|
106
|
+
str += "</".concat(json.name, ">");
|
|
107
107
|
return str;
|
|
108
108
|
};
|
|
109
109
|
exports.blockToMitosis = blockToMitosis;
|
|
110
110
|
var getRefsString = function (json, refs) {
|
|
111
|
-
if (refs === void 0) { refs = get_refs_1.getRefs(json); }
|
|
111
|
+
if (refs === void 0) { refs = (0, get_refs_1.getRefs)(json); }
|
|
112
112
|
var str = '';
|
|
113
113
|
for (var _i = 0, _a = Array.from(refs); _i < _a.length; _i++) {
|
|
114
114
|
var ref = _a[_i];
|
|
115
|
-
str += "\nconst "
|
|
115
|
+
str += "\nconst ".concat(ref, " = useRef();");
|
|
116
116
|
}
|
|
117
117
|
return str;
|
|
118
118
|
};
|
|
119
119
|
var mitosisCoreComponents = ['Show', 'For'];
|
|
120
|
-
var componentToMitosis = function (
|
|
120
|
+
var componentToMitosis = function (toMitosisOptions) {
|
|
121
121
|
if (toMitosisOptions === void 0) { toMitosisOptions = {}; }
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
var refs = get_refs_1.getRefs(json);
|
|
133
|
-
map_refs_1.mapRefs(json, function (refName) { return refName + ".current"; });
|
|
134
|
-
var addWrapper = json.children.length !== 1;
|
|
135
|
-
var components = Array.from(get_components_1.getComponents(json));
|
|
136
|
-
var mitosisComponents = components.filter(function (item) {
|
|
137
|
-
return mitosisCoreComponents.includes(item);
|
|
138
|
-
});
|
|
139
|
-
var otherComponents = components.filter(function (item) { return !mitosisCoreComponents.includes(item); });
|
|
140
|
-
var hasState = Boolean(Object.keys(componentJson.state).length);
|
|
141
|
-
var needsMitosisCoreImport = Boolean(hasState || refs.size || mitosisComponents.length);
|
|
142
|
-
// TODO: smart only pull in imports as needed
|
|
143
|
-
var str = dedent_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n\n ", "\n\n export default function ", "(props) {\n ", "\n ", "\n\n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n "], ["\n ",
|
|
144
|
-
"\n ",
|
|
145
|
-
"\n ", "\n\n ",
|
|
146
|
-
"\n\n export default function ", "(props) {\n ",
|
|
147
|
-
"\n ", "\n\n ", "\n\n ",
|
|
148
|
-
"\n\n return (", "\n ", "\n ", ")\n }\n\n "])), !needsMitosisCoreImport
|
|
149
|
-
? ''
|
|
150
|
-
: "import { " + (!hasState ? '' : 'useState, ') + " " + (!refs.size ? '' : 'useRef, ') + " " + mitosisComponents.join(', ') + " } from '@builder.io/mitosis';", !otherComponents.length
|
|
151
|
-
? ''
|
|
152
|
-
: "import { " + otherComponents.join(',') + " } from '@components';", render_imports_1.renderPreComponent(json), !componentJson.meta.metadataHook
|
|
153
|
-
? ''
|
|
154
|
-
: jsx_1.METADATA_HOOK_NAME + "(" + json5_1.default.stringify(componentJson.meta.metadataHook) + ")", componentJson.name, !hasState
|
|
155
|
-
? ''
|
|
156
|
-
: "const state = useState(" + get_state_object_string_1.getStateObjectStringFromComponent(json) + ");", getRefsString(json), !json.hooks.onMount ? '' : "onMount(() => { " + json.hooks.onMount + " })", !json.hooks.onUnMount
|
|
157
|
-
? ''
|
|
158
|
-
: "onUnMount(() => { " + json.hooks.onUnMount + " })", addWrapper ? '<>' : '', json.children.map(function (item) { return exports.blockToMitosis(item, options); }).join('\n'), addWrapper ? '</>' : '');
|
|
159
|
-
if (options.prettier !== false) {
|
|
160
|
-
try {
|
|
161
|
-
str = standalone_1.format(str, {
|
|
162
|
-
parser: 'typescript',
|
|
163
|
-
plugins: [
|
|
164
|
-
require('prettier/parser-typescript'), // To support running in browsers
|
|
165
|
-
],
|
|
166
|
-
});
|
|
122
|
+
return function (_a) {
|
|
123
|
+
var component = _a.component;
|
|
124
|
+
var options = __assign({ format: exports.DEFAULT_FORMAT }, toMitosisOptions);
|
|
125
|
+
if (options.format === 'react') {
|
|
126
|
+
return (0, react_1.componentToReact)({
|
|
127
|
+
format: 'lite',
|
|
128
|
+
stateType: 'useState',
|
|
129
|
+
stylesType: 'emotion',
|
|
130
|
+
prettier: options.prettier,
|
|
131
|
+
})({ component: component });
|
|
167
132
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
133
|
+
var json = (0, fast_clone_1.fastClone)(component);
|
|
134
|
+
var refs = (0, get_refs_1.getRefs)(json);
|
|
135
|
+
(0, map_refs_1.mapRefs)(json, function (refName) { return "".concat(refName, ".current"); });
|
|
136
|
+
var addWrapper = json.children.length !== 1;
|
|
137
|
+
var components = Array.from((0, get_components_1.getComponents)(json));
|
|
138
|
+
var mitosisComponents = components.filter(function (item) {
|
|
139
|
+
return mitosisCoreComponents.includes(item);
|
|
140
|
+
});
|
|
141
|
+
var otherComponents = components.filter(function (item) { return !mitosisCoreComponents.includes(item); });
|
|
142
|
+
var hasState = Boolean(Object.keys(component.state).length);
|
|
143
|
+
var needsMitosisCoreImport = Boolean(hasState || refs.size || mitosisComponents.length);
|
|
144
|
+
// TODO: smart only pull in imports as needed
|
|
145
|
+
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n\n ", "\n\n export default function ", "(props) {\n ", "\n ", "\n\n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n "], ["\n ", "\n ", "\n ", "\n\n ", "\n\n export default function ", "(props) {\n ", "\n ", "\n\n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n "])), !needsMitosisCoreImport
|
|
146
|
+
? ''
|
|
147
|
+
: "import { ".concat(!hasState ? '' : 'useState, ', " ").concat(!refs.size ? '' : 'useRef, ', " ").concat(mitosisComponents.join(', '), " } from '@builder.io/mitosis';"), !otherComponents.length
|
|
148
|
+
? ''
|
|
149
|
+
: "import { ".concat(otherComponents.join(','), " } from '@components';"), (0, render_imports_1.renderPreComponent)(json), !component.meta.metadataHook
|
|
150
|
+
? ''
|
|
151
|
+
: "".concat(jsx_1.METADATA_HOOK_NAME, "(").concat(json5_1.default.stringify(component.meta.metadataHook), ")"), component.name, !hasState
|
|
152
|
+
? ''
|
|
153
|
+
: "const state = useState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");"), getRefsString(json), !json.hooks.onMount ? '' : "onMount(() => { ".concat(json.hooks.onMount, " })"), !json.hooks.onUnMount
|
|
154
|
+
? ''
|
|
155
|
+
: "onUnMount(() => { ".concat(json.hooks.onUnMount, " })"), addWrapper ? '<>' : '', json.children.map(function (item) { return (0, exports.blockToMitosis)(item, options); }).join('\n'), addWrapper ? '</>' : '');
|
|
156
|
+
if (options.prettier !== false) {
|
|
157
|
+
try {
|
|
158
|
+
str = (0, standalone_1.format)(str, {
|
|
159
|
+
parser: 'typescript',
|
|
160
|
+
plugins: [
|
|
161
|
+
require('prettier/parser-typescript'), // To support running in browsers
|
|
162
|
+
],
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
console.error('Format error for file:', str, JSON.stringify(json, null, 2));
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
171
169
|
}
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
return str;
|
|
171
|
+
};
|
|
174
172
|
};
|
|
175
173
|
exports.componentToMitosis = componentToMitosis;
|
|
176
174
|
var templateObject_1;
|
|
@@ -45,9 +45,9 @@ function getCommonStyles(fileSet) {
|
|
|
45
45
|
function addComponent(fileSet, component, opts) {
|
|
46
46
|
if (opts === void 0) { opts = {}; }
|
|
47
47
|
var _opts = __assign({ isRoot: false, shareStyles: false }, opts);
|
|
48
|
-
compile_away_builder_components_1.compileAwayBuilderComponentsFromTree(component, compile_away_builder_components_1.components);
|
|
48
|
+
(0, compile_away_builder_components_1.compileAwayBuilderComponentsFromTree)(component, compile_away_builder_components_1.components);
|
|
49
49
|
var componentName = component.name;
|
|
50
|
-
var handlers = handlers_1.renderHandlers(fileSet.high, componentName, component.children);
|
|
50
|
+
var handlers = (0, handlers_1.renderHandlers)(fileSet.high, componentName, component.children);
|
|
51
51
|
// If the component has no handlers, than it is probably static
|
|
52
52
|
// and so it is unlikely to be re-rendered on the client, therefore
|
|
53
53
|
// put it in a low priority bucket.
|
|
@@ -56,7 +56,7 @@ function addComponent(fileSet, component, opts) {
|
|
|
56
56
|
var componentFile = fileSet.med;
|
|
57
57
|
if (!componentFile.exports.get('onMountCreateEmptyState')) {
|
|
58
58
|
componentFile.exportConst('onMountCreateEmptyState', function () {
|
|
59
|
-
this.emit(src_generator_1.invoke(componentFile.import(componentFile.qwikModule, 'qHook'), [src_generator_1.arrowFnValue([], ['({})'])], ['any', 'any']));
|
|
59
|
+
this.emit((0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qHook'), [(0, src_generator_1.arrowFnValue)([], ['({})'])], ['any', 'any']));
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
if (component.hooks.onMount) {
|
|
@@ -65,15 +65,15 @@ function addComponent(fileSet, component, opts) {
|
|
|
65
65
|
var styles = _opts.shareStyles
|
|
66
66
|
? getCommonStyles(fileSet).styles
|
|
67
67
|
: new Map();
|
|
68
|
-
styles_1.collectStyles(component.children, styles);
|
|
68
|
+
(0, styles_1.collectStyles)(component.children, styles);
|
|
69
69
|
var qComponentOptions = {
|
|
70
70
|
// tagName: string(componentName.toLowerCase()),
|
|
71
|
-
onMount: src_generator_1.invoke(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
71
|
+
onMount: (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
72
72
|
componentFile.toQrl(component.hooks.onMount
|
|
73
73
|
? componentName + '_onMount'
|
|
74
74
|
: 'onMountCreateEmptyState'),
|
|
75
75
|
]),
|
|
76
|
-
onRender: src_generator_1.invoke(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
76
|
+
onRender: (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
77
77
|
onRenderFile.toQrl(componentName + '_onRender'),
|
|
78
78
|
]),
|
|
79
79
|
};
|
|
@@ -87,13 +87,13 @@ function addComponent(fileSet, component, opts) {
|
|
|
87
87
|
else {
|
|
88
88
|
if (styles.size) {
|
|
89
89
|
qComponentOptions.styles = onRenderFile.toQrl(componentName + '_styles');
|
|
90
|
-
onRenderFile.exportConst(componentName + '_styles', styles_1.renderStyles(styles));
|
|
90
|
+
onRenderFile.exportConst(componentName + '_styles', (0, styles_1.renderStyles)(styles));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
componentFile.exportConst(componentName, src_generator_1.invoke(componentFile.import(componentFile.qwikModule, 'qComponent'), [qComponentOptions], ['any', 'any']));
|
|
93
|
+
componentFile.exportConst(componentName, (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qComponent'), [qComponentOptions], ['any', 'any']));
|
|
94
94
|
onRenderFile.src.emit(src_generator_1.NL);
|
|
95
|
-
onRenderFile.exportConst(componentName + '_onRender', src_generator_1.invoke(onRenderFile.import(onRenderFile.qwikModule, 'qHook'), [
|
|
96
|
-
src_generator_1.arrowFnValue(['props', 'state'], jsx_1.renderJSXNodes(onRenderFile, handlers, component.children, styles)),
|
|
95
|
+
onRenderFile.exportConst(componentName + '_onRender', (0, src_generator_1.invoke)(onRenderFile.import(onRenderFile.qwikModule, 'qHook'), [
|
|
96
|
+
(0, src_generator_1.arrowFnValue)(['props', 'state'], (0, jsx_1.renderJSXNodes)(onRenderFile, handlers, component.children, styles)),
|
|
97
97
|
]));
|
|
98
98
|
}
|
|
99
99
|
exports.addComponent = addComponent;
|
|
@@ -101,15 +101,15 @@ function addCommonStyles(fileSet) {
|
|
|
101
101
|
var _a = getCommonStyles(fileSet), styles = _a.styles, symbolName = _a.symbolName;
|
|
102
102
|
var onRenderFile = fileSet.low;
|
|
103
103
|
if (symbolName) {
|
|
104
|
-
onRenderFile.exportConst(symbolName, styles_1.renderStyles(styles));
|
|
104
|
+
onRenderFile.exportConst(symbolName, (0, styles_1.renderStyles)(styles));
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
exports.addCommonStyles = addCommonStyles;
|
|
108
108
|
function addComponentOnMount(componentFile, componentName, component) {
|
|
109
109
|
componentFile.exportConst(componentName + '_onMount', function () {
|
|
110
110
|
var _this = this;
|
|
111
|
-
this.emit(src_generator_1.invoke(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
112
|
-
src_generator_1.arrowFnValue([], function () {
|
|
111
|
+
this.emit((0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
112
|
+
(0, src_generator_1.arrowFnValue)([], function () {
|
|
113
113
|
return _this.emit('{', src_generator_1.NL, src_generator_1.INDENT, 'const state = {};', src_generator_1.NL, component.hooks.onMount, src_generator_1.NL, 'return state;', src_generator_1.UNINDENT, src_generator_1.NL, '}');
|
|
114
114
|
}),
|
|
115
115
|
], ['any', 'any']));
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
3
|
-
for (var i = 0,
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
6
10
|
};
|
|
7
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
12
|
exports.renderHandlers = exports.extractJSBlock = void 0;
|
|
@@ -27,7 +31,7 @@ exports.extractJSBlock = extractJSBlock;
|
|
|
27
31
|
function renderHandlers(file, componentName, children) {
|
|
28
32
|
var id = 0;
|
|
29
33
|
var map = new Map();
|
|
30
|
-
var nodes = __spreadArray([], children);
|
|
34
|
+
var nodes = __spreadArray([], children, true);
|
|
31
35
|
while (nodes.length) {
|
|
32
36
|
var node = nodes.shift();
|
|
33
37
|
var bindings = node.bindings;
|
|
@@ -37,7 +41,7 @@ function renderHandlers(file, componentName, children) {
|
|
|
37
41
|
if (binding != null) {
|
|
38
42
|
if (key.startsWith('on')) {
|
|
39
43
|
var block = extractJSBlock(binding) || binding;
|
|
40
|
-
var symbol = componentName
|
|
44
|
+
var symbol = "".concat(componentName, "_").concat(key, "_").concat(id++);
|
|
41
45
|
map.set(binding, symbol);
|
|
42
46
|
renderHandler(file, symbol, block);
|
|
43
47
|
}
|
|
@@ -51,7 +55,7 @@ function renderHandlers(file, componentName, children) {
|
|
|
51
55
|
exports.renderHandlers = renderHandlers;
|
|
52
56
|
function renderHandler(file, symbol, code) {
|
|
53
57
|
file.exportConst(symbol, function () {
|
|
54
|
-
this.emit(src_generator_1.invoke(file.import(file.qwikModule, 'qHook'), [src_generator_1.arrowFnBlock(['props', 'state'], [wrapWithUse(file, code)])], ['any', 'any']));
|
|
58
|
+
this.emit((0, src_generator_1.invoke)(file.import(file.qwikModule, 'qHook'), [(0, src_generator_1.arrowFnBlock)(['props', 'state'], [wrapWithUse(file, code)])], ['any', 'any']));
|
|
55
59
|
});
|
|
56
60
|
file.src.emit(src_generator_1.NL);
|
|
57
61
|
}
|
|
@@ -61,7 +65,7 @@ function wrapWithUse(file, code) {
|
|
|
61
65
|
return function () {
|
|
62
66
|
this.emit('{', src_generator_1.NL, src_generator_1.INDENT);
|
|
63
67
|
needsEvent &&
|
|
64
|
-
this.emit('const event', src_generator_1.WS, '=', src_generator_1.WS, src_generator_1.invoke(file.import(file.qwikModule, 'useEvent'), []), ';', src_generator_1.NL);
|
|
68
|
+
this.emit('const event', src_generator_1.WS, '=', src_generator_1.WS, (0, src_generator_1.invoke)(file.import(file.qwikModule, 'useEvent'), []), ';', src_generator_1.NL);
|
|
65
69
|
var blockContent = stripBlock(code);
|
|
66
70
|
this.emit(blockContent);
|
|
67
71
|
this.emit(src_generator_1.UNINDENT, src_generator_1.NL, '}');
|
|
@@ -10,10 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
14
|
-
for (var i = 0,
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
17
21
|
};
|
|
18
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
23
|
exports.renderJSXNodes = void 0;
|
|
@@ -43,7 +47,7 @@ function renderJSXNodes(file, handlers, children, styles, root) {
|
|
|
43
47
|
else {
|
|
44
48
|
_this.isJSX
|
|
45
49
|
? _this.emit(child.properties._text)
|
|
46
|
-
: _this.jsxTextBinding(src_generator_1.string(child.properties._text));
|
|
50
|
+
: _this.jsxTextBinding((0, src_generator_1.string)(child.properties._text));
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
else {
|
|
@@ -87,7 +91,7 @@ function isSymbol(name) {
|
|
|
87
91
|
return name.charAt(0) == name.charAt(0).toUpperCase();
|
|
88
92
|
}
|
|
89
93
|
function addClass(className, existingClass) {
|
|
90
|
-
return __spreadArray([className], (existingClass ? existingClass.split(' ') : [])).join(' ');
|
|
94
|
+
return __spreadArray([className], (existingClass ? existingClass.split(' ') : []), true).join(' ');
|
|
91
95
|
}
|
|
92
96
|
function isEmptyTextNode(child) {
|
|
93
97
|
var _a;
|
|
@@ -107,9 +111,9 @@ function rewriteHandlers(file, handlers, bindings) {
|
|
|
107
111
|
continue;
|
|
108
112
|
}
|
|
109
113
|
else if ((handlerBlock = handlers.get(binding))) {
|
|
110
|
-
key = "on:"
|
|
111
|
-
binding = src_generator_1.invoke(file.import(file.qwikModule, 'qHook'), [
|
|
112
|
-
src_generator_1.string(file.qrlPrefix + 'high#' + handlerBlock),
|
|
114
|
+
key = "on:".concat(key.substr(2).toLowerCase());
|
|
115
|
+
binding = (0, src_generator_1.invoke)(file.import(file.qwikModule, 'qHook'), [
|
|
116
|
+
(0, src_generator_1.string)(file.qrlPrefix + 'high#' + handlerBlock),
|
|
113
117
|
]);
|
|
114
118
|
}
|
|
115
119
|
outBindings[key] = binding;
|
|
@@ -10,10 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
14
|
-
for (var i = 0,
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
17
21
|
};
|
|
18
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -24,7 +28,7 @@ var json5_1 = __importDefault(require("json5"));
|
|
|
24
28
|
var dash_case_1 = require("../../helpers/dash-case");
|
|
25
29
|
var src_generator_1 = require("./src-generator");
|
|
26
30
|
function collectStyles(children, styleMap) {
|
|
27
|
-
var nodes = __spreadArray([], children);
|
|
31
|
+
var nodes = __spreadArray([], children, true);
|
|
28
32
|
while (nodes.length) {
|
|
29
33
|
var child = nodes.shift();
|
|
30
34
|
nodes.push.apply(nodes, child.children);
|
|
@@ -63,7 +67,7 @@ function renderStyles(styles) {
|
|
|
63
67
|
mediaStyles.push(styles.CLASS_NAME, key, value);
|
|
64
68
|
}
|
|
65
69
|
else {
|
|
66
|
-
_this.emit(dash_case_1.dashCase(key), ':', src_generator_1.WS, value, ';', src_generator_1.NL);
|
|
70
|
+
_this.emit((0, dash_case_1.dashCase)(key), ':', src_generator_1.WS, value, ';', src_generator_1.NL);
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
}
|
|
@@ -78,7 +82,7 @@ function renderStyles(styles) {
|
|
|
78
82
|
for (var key in mediaObj) {
|
|
79
83
|
if (Object.prototype.hasOwnProperty.call(mediaObj, key)) {
|
|
80
84
|
var value = mediaObj[key];
|
|
81
|
-
this.emit(dash_case_1.dashCase(key), ':', src_generator_1.WS, value, ';', src_generator_1.NL);
|
|
85
|
+
this.emit((0, dash_case_1.dashCase)(key), ':', src_generator_1.WS, value, ';', src_generator_1.NL);
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
this.emit(src_generator_1.UNINDENT, '}', src_generator_1.NL);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { ClassStyleMap } from '../helpers/collect-styles';
|
|
2
|
-
import { Plugin } from '../modules/plugins';
|
|
3
2
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { BaseTranspilerOptions, Transpiler } from '../types/config';
|
|
4
|
+
export interface ToReactNativeOptions extends BaseTranspilerOptions {
|
|
6
5
|
stylesType?: 'emotion' | 'react-native';
|
|
7
6
|
stateType?: 'useState' | 'mobx' | 'valtio' | 'solid' | 'builder';
|
|
8
|
-
|
|
9
|
-
};
|
|
7
|
+
}
|
|
10
8
|
export declare const collectReactNativeStyles: (json: MitosisComponent) => ClassStyleMap;
|
|
11
|
-
export declare const componentToReactNative: (
|
|
12
|
-
export {};
|
|
9
|
+
export declare const componentToReactNative: (options?: ToReactNativeOptions) => Transpiler;
|