@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
|
@@ -19,9 +19,9 @@ var nodeHasStyles = function (node) {
|
|
|
19
19
|
exports.nodeHasStyles = nodeHasStyles;
|
|
20
20
|
var hasStyles = function (component) {
|
|
21
21
|
var hasStyles = false;
|
|
22
|
-
traverse_1.default(component).forEach(function (item) {
|
|
23
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
24
|
-
if (exports.nodeHasStyles(item)) {
|
|
22
|
+
(0, traverse_1.default)(component).forEach(function (item) {
|
|
23
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
24
|
+
if ((0, exports.nodeHasStyles)(item)) {
|
|
25
25
|
hasStyles = true;
|
|
26
26
|
this.stop();
|
|
27
27
|
}
|
|
@@ -34,42 +34,42 @@ var collectStyledComponents = function (json) {
|
|
|
34
34
|
var styledComponentsCode = '';
|
|
35
35
|
var componentIndexes = {};
|
|
36
36
|
var componentHashes = {};
|
|
37
|
-
traverse_1.default(json).forEach(function (item) {
|
|
38
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
39
|
-
if (exports.nodeHasStyles(item)) {
|
|
40
|
-
var value = exports.parseCssObject(item.bindings.css);
|
|
37
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
38
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
39
|
+
if ((0, exports.nodeHasStyles)(item)) {
|
|
40
|
+
var value = (0, exports.parseCssObject)(item.bindings.css);
|
|
41
41
|
delete item.bindings.css;
|
|
42
42
|
var normalizedNameProperty = item.properties.$name
|
|
43
|
-
? capitalize_1.capitalize(lodash_1.camelCase(item.properties.$name.replace(/[^a-z]/gi, '')))
|
|
43
|
+
? (0, capitalize_1.capitalize)((0, lodash_1.camelCase)(item.properties.$name.replace(/[^a-z]/gi, '')))
|
|
44
44
|
: null;
|
|
45
45
|
var componentName = normalizedNameProperty
|
|
46
46
|
? normalizedNameProperty
|
|
47
47
|
: /^h\d$/.test(item.name || '')
|
|
48
48
|
? item.name
|
|
49
|
-
: capitalize_1.capitalize(lodash_1.camelCase(item.name || 'div'));
|
|
49
|
+
: (0, capitalize_1.capitalize)((0, lodash_1.camelCase)(item.name || 'div'));
|
|
50
50
|
var index = (componentIndexes[componentName] =
|
|
51
51
|
(componentIndexes[componentName] || 0) + 1);
|
|
52
|
-
var className = ""
|
|
52
|
+
var className = "".concat(componentName).concat(componentName !== item.name && index === 1 ? '' : index);
|
|
53
53
|
var str = '';
|
|
54
54
|
var styles = getStylesOnly(value);
|
|
55
|
-
var stylesHash = object_hash_1.default(styles);
|
|
55
|
+
var stylesHash = (0, object_hash_1.default)(styles);
|
|
56
56
|
if (stylesHash === componentHashes[componentName]) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
if (!componentHashes[componentName]) {
|
|
60
60
|
componentHashes[componentName] = stylesHash;
|
|
61
61
|
}
|
|
62
|
-
str += exports.styleMapToCss(styles)
|
|
62
|
+
str += "".concat((0, exports.styleMapToCss)(styles), "\n");
|
|
63
63
|
var nestedSelectors = getNestedSelectors(value);
|
|
64
64
|
for (var nestedSelector in nestedSelectors) {
|
|
65
65
|
var value_1 = nestedSelectors[nestedSelector];
|
|
66
|
-
str += nestedSelector
|
|
66
|
+
str += "".concat(nestedSelector, " { ").concat((0, exports.styleMapToCss)(value_1), " }");
|
|
67
67
|
}
|
|
68
|
-
var prefix = is_upper_case_1.isUpperCase(item.name[0])
|
|
69
|
-
? "styled("
|
|
70
|
-
: "styled."
|
|
68
|
+
var prefix = (0, is_upper_case_1.isUpperCase)(item.name[0])
|
|
69
|
+
? "styled(".concat(item.name, ")`")
|
|
70
|
+
: "styled.".concat(item.name, "`");
|
|
71
71
|
item.name = className;
|
|
72
|
-
styledComponentsCode += "\n const "
|
|
72
|
+
styledComponentsCode += "\n const ".concat(className, " = ").concat(prefix).concat(str, "`\n ");
|
|
73
73
|
}
|
|
74
74
|
delete item.bindings.css;
|
|
75
75
|
}
|
|
@@ -93,21 +93,21 @@ var collectStyles = function (json, options) {
|
|
|
93
93
|
var classProperty = options.classProperty || 'class';
|
|
94
94
|
var componentIndexes = {};
|
|
95
95
|
var componentHashes = {};
|
|
96
|
-
traverse_1.default(json).forEach(function (item) {
|
|
97
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
98
|
-
if (exports.nodeHasStyles(item)) {
|
|
99
|
-
var value = exports.parseCssObject(item.bindings.css);
|
|
96
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
97
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
98
|
+
if ((0, exports.nodeHasStyles)(item)) {
|
|
99
|
+
var value = (0, exports.parseCssObject)(item.bindings.css);
|
|
100
100
|
delete item.bindings.css;
|
|
101
101
|
var componentName = item.properties.$name
|
|
102
|
-
? dash_case_1.dashCase(item.properties.$name)
|
|
102
|
+
? (0, dash_case_1.dashCase)(item.properties.$name)
|
|
103
103
|
: /^h\d$/.test(item.name || '') // don't dashcase h1 into h-1
|
|
104
104
|
? item.name
|
|
105
|
-
: dash_case_1.dashCase(item.name || 'div');
|
|
106
|
-
var stylesHash = object_hash_1.default(value);
|
|
105
|
+
: (0, dash_case_1.dashCase)(item.name || 'div');
|
|
106
|
+
var stylesHash = (0, object_hash_1.default)(value);
|
|
107
107
|
if (componentHashes[componentName] === stylesHash) {
|
|
108
|
-
var className_1 = ""
|
|
109
|
-
item.properties[classProperty] = (
|
|
110
|
-
''
|
|
108
|
+
var className_1 = "".concat(componentName).concat(options.prefix ? "-".concat(options.prefix) : '');
|
|
109
|
+
item.properties[classProperty] = "".concat(item.properties[classProperty] ||
|
|
110
|
+
'', " ").concat(className_1)
|
|
111
111
|
.trim()
|
|
112
112
|
.replace(/\s{2,}/g, ' ');
|
|
113
113
|
return;
|
|
@@ -117,9 +117,9 @@ var collectStyles = function (json, options) {
|
|
|
117
117
|
}
|
|
118
118
|
var index = (componentIndexes[componentName] =
|
|
119
119
|
(componentIndexes[componentName] || 0) + 1);
|
|
120
|
-
var className = ""
|
|
121
|
-
item.properties[classProperty] = (
|
|
122
|
-
''
|
|
120
|
+
var className = "".concat(componentName).concat(options.prefix ? "-".concat(options.prefix) : '').concat(index === 1 ? '' : "-".concat(index));
|
|
121
|
+
item.properties[classProperty] = "".concat(item.properties[classProperty] ||
|
|
122
|
+
'', " ").concat(className)
|
|
123
123
|
.trim()
|
|
124
124
|
.replace(/\s{2,}/g, ' ');
|
|
125
125
|
styleMap[className] = value;
|
|
@@ -132,33 +132,33 @@ var collectStyles = function (json, options) {
|
|
|
132
132
|
exports.collectStyles = collectStyles;
|
|
133
133
|
var collectCss = function (json, options) {
|
|
134
134
|
if (options === void 0) { options = {}; }
|
|
135
|
-
var styles = exports.collectStyles(json, options);
|
|
135
|
+
var styles = (0, exports.collectStyles)(json, options);
|
|
136
136
|
// TODO create and use a root selector
|
|
137
137
|
return classStyleMapToCss(styles);
|
|
138
138
|
};
|
|
139
139
|
exports.collectCss = collectCss;
|
|
140
140
|
var getNestedSelectors = function (map) {
|
|
141
|
-
return lodash_1.pickBy(map, function (value) { return typeof value === 'object'; });
|
|
141
|
+
return (0, lodash_1.pickBy)(map, function (value) { return typeof value === 'object'; });
|
|
142
142
|
};
|
|
143
143
|
var getStylesOnly = function (map) {
|
|
144
|
-
return lodash_1.pickBy(map, function (value) { return typeof value === 'string'; });
|
|
144
|
+
return (0, lodash_1.pickBy)(map, function (value) { return typeof value === 'string'; });
|
|
145
145
|
};
|
|
146
146
|
var classStyleMapToCss = function (map) {
|
|
147
147
|
var str = '';
|
|
148
148
|
for (var key in map) {
|
|
149
149
|
var styles = getStylesOnly(map[key]);
|
|
150
|
-
str += "."
|
|
150
|
+
str += ".".concat(key, " { ").concat((0, exports.styleMapToCss)(styles), " }");
|
|
151
151
|
var nestedSelectors = getNestedSelectors(map[key]);
|
|
152
152
|
for (var nestedSelector in nestedSelectors) {
|
|
153
153
|
var value = nestedSelectors[nestedSelector];
|
|
154
154
|
if (nestedSelector.startsWith('@')) {
|
|
155
|
-
str += nestedSelector
|
|
155
|
+
str += "".concat(nestedSelector, " { .").concat(key, " { ").concat((0, exports.styleMapToCss)(value), " } }");
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
158
158
|
var useSelector = nestedSelector.includes('&')
|
|
159
|
-
? nestedSelector.replace(/&/g, "."
|
|
160
|
-
: "."
|
|
161
|
-
str += useSelector
|
|
159
|
+
? nestedSelector.replace(/&/g, ".".concat(key))
|
|
160
|
+
: ".".concat(key, " ").concat(nestedSelector);
|
|
161
|
+
str += "".concat(useSelector, " { ").concat((0, exports.styleMapToCss)(value), " }");
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -169,7 +169,7 @@ var styleMapToCss = function (map) {
|
|
|
169
169
|
for (var key in map) {
|
|
170
170
|
var value = map[key];
|
|
171
171
|
if (typeof value === 'string') {
|
|
172
|
-
str += "\n"
|
|
172
|
+
str += "\n".concat((0, dash_case_1.dashCase)(key), ": ").concat(value, ";");
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
175
|
// TODO: do nothing
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dashCase = void 0;
|
|
4
4
|
var lodash_1 = require("lodash");
|
|
5
|
-
var dashCase = function (string) { return lodash_1.kebabCase(string); };
|
|
5
|
+
var dashCase = function (string) { return (0, lodash_1.kebabCase)(string); };
|
|
6
6
|
exports.dashCase = dashCase;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var globals_1 = require("@jest/globals");
|
|
4
4
|
var generic_format_1 = require("./generic-format");
|
|
5
|
-
globals_1.test('Can generic format sloppy Swift code', function () {
|
|
5
|
+
(0, globals_1.test)('Can generic format sloppy Swift code', function () {
|
|
6
6
|
var code = "\n import SwiftUI\n import JavaScriptCore\n \n struct MyComponent: View {\n \n @State private var updateIndex = 0\n private var context = JSContext()\n \n func eval(expression: String) -> JSValue! {\n return context?.evaluateScript(expression)\n }\n \n init() {\n let jsSource = \"\"\"\n const state = { name: \"Steve\" };\n \n \"\"\"\n context?.evaluateScript(jsSource)\n }\n \n \n var body: some View {\n VStack {\n Text(String(updateIndex)).hidden()\n VStack(){\n Foo(\n bar: baz\n )\n TextField(){}\n Text(\"Hello\")\n Text(eval(expression: \"\"\"state.name\"\"\"))\n Text(\"! I can run in React, Vue, Solid, or Liquid!\")}\n }\n }\n }\n ";
|
|
7
|
-
globals_1.expect(generic_format_1.format(code)).toMatchSnapshot();
|
|
7
|
+
(0, globals_1.expect)((0, generic_format_1.format)(code)).toMatchSnapshot();
|
|
8
8
|
});
|
|
@@ -8,8 +8,8 @@ var traverse_1 = __importDefault(require("traverse"));
|
|
|
8
8
|
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
9
|
function getComponentsUsed(json) {
|
|
10
10
|
var components = new Set();
|
|
11
|
-
traverse_1.default(json).forEach(function (item) {
|
|
12
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
11
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
12
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
13
13
|
components.add(item.name);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -9,9 +9,9 @@ var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
|
9
9
|
var is_upper_case_1 = require("./is-upper-case");
|
|
10
10
|
function getComponents(json) {
|
|
11
11
|
var components = new Set();
|
|
12
|
-
traverse_1.default(json).forEach(function (item) {
|
|
13
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
14
|
-
if (is_upper_case_1.isUpperCase(item.name[0])) {
|
|
12
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
13
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
14
|
+
if ((0, is_upper_case_1.isUpperCase)(item.name[0])) {
|
|
15
15
|
components.add(item.name);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -12,7 +12,7 @@ var allPropsMatchesRegex = new RegExp(propsRegex, 'g');
|
|
|
12
12
|
*/
|
|
13
13
|
var getProps = function (json) {
|
|
14
14
|
var props = new Set();
|
|
15
|
-
traverse_1.default(json).forEach(function (item) {
|
|
15
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
16
16
|
if (typeof item === 'string') {
|
|
17
17
|
// TODO: proper babel ref matching
|
|
18
18
|
var matches = item.match(allPropsMatchesRegex);
|
|
@@ -8,8 +8,8 @@ var traverse_1 = __importDefault(require("traverse"));
|
|
|
8
8
|
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
9
|
var getRefs = function (json) {
|
|
10
10
|
var refs = new Set();
|
|
11
|
-
traverse_1.default(json).forEach(function (item) {
|
|
12
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
11
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
12
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
13
13
|
if (typeof item.bindings.ref === 'string') {
|
|
14
14
|
refs.add(item.bindings.ref);
|
|
15
15
|
}
|
|
@@ -23,7 +23,7 @@ var getMemberObjectString = function (object, options) {
|
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
25
|
var functionValue = value.replace(function_literal_prefix_1.functionLiteralPrefix, '');
|
|
26
|
-
str += " "
|
|
26
|
+
str += " ".concat(keyPrefix, " ").concat(key, " ").concat(keyValueDelimiter, " ").concat(valueMapper(functionValue, 'function')).concat(lineItemDelimiter, " ");
|
|
27
27
|
}
|
|
28
28
|
else if (value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
|
|
29
29
|
var methodValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
|
|
@@ -34,20 +34,20 @@ var getMemberObjectString = function (object, options) {
|
|
|
34
34
|
if (!isGet && options.functions === false) {
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
|
-
str += keyPrefix
|
|
37
|
+
str += "".concat(keyPrefix, " ").concat(valueMapper(methodValue, isGet ? 'getter' : 'function'), " ").concat(lineItemDelimiter);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
if (options.data === false) {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
|
-
str += " "
|
|
43
|
+
str += " ".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(value), 'data')).concat(lineItemDelimiter, " ");
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
if (options.data === false) {
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
|
-
str += " "
|
|
50
|
+
str += " ".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(value), 'data')).concat(lineItemDelimiter, " ");
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
str += format === 'object' ? '}' : '';
|
|
@@ -56,6 +56,6 @@ var getMemberObjectString = function (object, options) {
|
|
|
56
56
|
exports.getMemberObjectString = getMemberObjectString;
|
|
57
57
|
var getStateObjectStringFromComponent = function (component, options) {
|
|
58
58
|
if (options === void 0) { options = {}; }
|
|
59
|
-
return exports.getMemberObjectString(component.state, options);
|
|
59
|
+
return (0, exports.getMemberObjectString)(component.state, options);
|
|
60
60
|
};
|
|
61
61
|
exports.getStateObjectStringFromComponent = getStateObjectStringFromComponent;
|
|
@@ -12,7 +12,7 @@ var allStateMatchesRegex = new RegExp(stateAccessRegex, 'g');
|
|
|
12
12
|
*/
|
|
13
13
|
var getStateUsed = function (json) {
|
|
14
14
|
var stateProperties = new Set();
|
|
15
|
-
traverse_1.default(json).forEach(function (item) {
|
|
15
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
16
16
|
if (typeof item === 'string') {
|
|
17
17
|
// TODO: proper babel ref matching
|
|
18
18
|
var matches = item.match(allStateMatchesRegex);
|
|
@@ -19,17 +19,17 @@ var gettersToFunctions = function (json) {
|
|
|
19
19
|
}
|
|
20
20
|
return false;
|
|
21
21
|
});
|
|
22
|
-
traverse_1.default(json).forEach(function (item) {
|
|
22
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
23
23
|
// TODO: not all strings are expressions!
|
|
24
24
|
if (typeof item === 'string') {
|
|
25
25
|
var value = item;
|
|
26
26
|
var _loop_1 = function (key) {
|
|
27
27
|
try {
|
|
28
|
-
value = value.replace(new RegExp("state\\s*\\.\\s*"
|
|
28
|
+
value = value.replace(new RegExp("state\\s*\\.\\s*".concat(key, "([^a-z0-9]|$)"), 'gi'), function (match, group1) {
|
|
29
29
|
if (match.endsWith('?')) {
|
|
30
|
-
return key
|
|
30
|
+
return "".concat(key, "?.()").concat(group1);
|
|
31
31
|
}
|
|
32
|
-
return key
|
|
32
|
+
return "".concat(key, "()").concat(group1);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
catch (err) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleMissingState = void 0;
|
|
4
4
|
var get_state_used_1 = require("./get-state-used");
|
|
5
5
|
function handleMissingState(json) {
|
|
6
|
-
var stateUsed = get_state_used_1.getStateUsed(json);
|
|
6
|
+
var stateUsed = (0, get_state_used_1.getStateUsed)(json);
|
|
7
7
|
Array.from(stateUsed).forEach(function (property) {
|
|
8
8
|
if (!(property in json.state)) {
|
|
9
9
|
json.state[property] = null;
|
|
@@ -8,8 +8,8 @@ var traverse_1 = __importDefault(require("traverse"));
|
|
|
8
8
|
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
9
|
var hasComponent = function (name, json) {
|
|
10
10
|
var has = false;
|
|
11
|
-
traverse_1.default(json).forEach(function (item) {
|
|
12
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
11
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
12
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
13
13
|
if (item.name === name) {
|
|
14
14
|
has = true;
|
|
15
15
|
this.stop();
|
|
@@ -7,7 +7,7 @@ exports.hasProps = void 0;
|
|
|
7
7
|
var traverse_1 = __importDefault(require("traverse"));
|
|
8
8
|
var hasProps = function (json) {
|
|
9
9
|
var has = false;
|
|
10
|
-
traverse_1.default(json).forEach(function (item) {
|
|
10
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
11
11
|
// TODO: use proper reference tracking
|
|
12
12
|
if (typeof item === 'string' && item.match(/(^|\W)props\s*\./)) {
|
|
13
13
|
has = true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function isChildren(node) {
|
|
4
|
-
return (
|
|
4
|
+
return ("".concat(node.bindings._text || '').replace(/\s+/g, '') === 'props.children');
|
|
5
5
|
}
|
|
6
6
|
exports.default = isChildren;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tryParseJson: (jsonStr: string) => any;
|
|
@@ -0,0 +1,17 @@
|
|
|
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.tryParseJson = void 0;
|
|
7
|
+
var json5_1 = __importDefault(require("json5"));
|
|
8
|
+
var tryParseJson = function (jsonStr) {
|
|
9
|
+
try {
|
|
10
|
+
return json5_1.default.parse(jsonStr);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
console.error('Could not JSON5 parse object:\n', jsonStr);
|
|
14
|
+
throw err;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.tryParseJson = tryParseJson;
|
|
@@ -32,7 +32,7 @@ var function_literal_prefix_1 = require("../constants/function-literal-prefix");
|
|
|
32
32
|
var babel_transform_1 = require("./babel-transform");
|
|
33
33
|
var tsPreset = require('@babel/preset-typescript');
|
|
34
34
|
var replaceRefsInString = function (code, refs, mapper) {
|
|
35
|
-
return babel_transform_1.babelTransformExpression(code, {
|
|
35
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
36
36
|
Identifier: function (path) {
|
|
37
37
|
var name = path.node.name;
|
|
38
38
|
var isRef = refs.includes(name);
|
|
@@ -43,7 +43,7 @@ var replaceRefsInString = function (code, refs, mapper) {
|
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
45
|
var mapRefs = function (component, mapper) {
|
|
46
|
-
var refs = Array.from(get_refs_1.getRefs(component));
|
|
46
|
+
var refs = Array.from((0, get_refs_1.getRefs)(component));
|
|
47
47
|
for (var _i = 0, _a = Object.keys(component.state); _i < _a.length; _i++) {
|
|
48
48
|
var key = _a[_i];
|
|
49
49
|
var value = component.state[key];
|
|
@@ -63,8 +63,8 @@ var mapRefs = function (component, mapper) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
traverse_1.default(component).forEach(function (item) {
|
|
67
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
66
|
+
(0, traverse_1.default)(component).forEach(function (item) {
|
|
67
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
68
68
|
for (var _i = 0, _a = Object.keys(item.bindings); _i < _a.length; _i++) {
|
|
69
69
|
var key = _a[_i];
|
|
70
70
|
var value = item.bindings[key];
|
|
@@ -5,13 +5,13 @@ var lodash_1 = require("lodash");
|
|
|
5
5
|
// This list is not exhaustive of all HTML boolean attributes, but we can add more in the future if needed.
|
|
6
6
|
var booleanHTMLAttributes = new Set(['checked', 'disabled', 'selected']);
|
|
7
7
|
function mapToAttributes(map) {
|
|
8
|
-
if (!lodash_1.size(map)) {
|
|
8
|
+
if (!(0, lodash_1.size)(map)) {
|
|
9
9
|
return '';
|
|
10
10
|
}
|
|
11
|
-
return lodash_1.reduce(map, function (memo, value, key) {
|
|
12
|
-
var attributeValue = " "
|
|
11
|
+
return (0, lodash_1.reduce)(map, function (memo, value, key) {
|
|
12
|
+
var attributeValue = " ".concat(key, "=\"").concat(value, "\"");
|
|
13
13
|
if (booleanHTMLAttributes.has(key) && value) {
|
|
14
|
-
attributeValue = " "
|
|
14
|
+
attributeValue = " ".concat(value);
|
|
15
15
|
}
|
|
16
16
|
return memo + attributeValue;
|
|
17
17
|
}, '');
|
|
@@ -6,10 +6,10 @@ function mapToCss(map, spaces, important, uewNewLine) {
|
|
|
6
6
|
if (spaces === void 0) { spaces = 2; }
|
|
7
7
|
if (important === void 0) { important = false; }
|
|
8
8
|
if (uewNewLine === void 0) { uewNewLine = spaces > 1; }
|
|
9
|
-
return lodash_1.reduce(map, function (memo, value, key) {
|
|
9
|
+
return (0, lodash_1.reduce)(map, function (memo, value, key) {
|
|
10
10
|
return (memo +
|
|
11
11
|
(value && value.trim()
|
|
12
|
-
? ""
|
|
12
|
+
? "".concat(uewNewLine ? '\n' : '').concat(' '.repeat(spaces)).concat((0, lodash_1.kebabCase)(key), ": ").concat(value + (important ? ' !important' : ''), ";")
|
|
13
13
|
: ''));
|
|
14
14
|
}, '');
|
|
15
15
|
}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseNodes = exports.parseNode = void 0;
|
|
4
4
|
var jsx_1 = require("../parsers/jsx");
|
|
5
5
|
var parseNode = function (str) {
|
|
6
|
-
return jsx_1.parseJsx("\n export default function MyComponent() {\n return ("
|
|
6
|
+
return (0, jsx_1.parseJsx)("\n export default function MyComponent() {\n return (".concat(str, ")\n }\n ")).children[0];
|
|
7
7
|
};
|
|
8
8
|
exports.parseNode = parseNode;
|
|
9
9
|
var parseNodes = function (str) {
|
|
10
|
-
return jsx_1.parseJsx("\n export default function MyComponent() {\n return (<>"
|
|
10
|
+
return (0, jsx_1.parseJsx)("\n export default function MyComponent() {\n return (<>".concat(str, "</>)\n }\n ")).children[0].children;
|
|
11
11
|
};
|
|
12
12
|
exports.parseNodes = parseNodes;
|
|
@@ -26,7 +26,7 @@ function parseReactiveScript(code, options) {
|
|
|
26
26
|
var state = {};
|
|
27
27
|
var format = options.format || 'html';
|
|
28
28
|
var useCode = format === 'html' ? ((_a = code.match(exports.reactiveScriptRe)) === null || _a === void 0 ? void 0 : _a[1]) || '' : code;
|
|
29
|
-
var output = core_1.transform(useCode, {
|
|
29
|
+
var output = (0, core_1.transform)(useCode, {
|
|
30
30
|
plugins: [
|
|
31
31
|
function () { return ({
|
|
32
32
|
visitor: {
|
|
@@ -45,11 +45,11 @@ function parseReactiveScript(code, options) {
|
|
|
45
45
|
if (core_1.types.isObjectProperty(item)) {
|
|
46
46
|
if (core_1.types.isFunctionExpression(item.value) ||
|
|
47
47
|
core_1.types.isArrowFunctionExpression(item.value)) {
|
|
48
|
-
return jsx_1.createFunctionStringLiteralObjectProperty(item.key, item.value);
|
|
48
|
+
return (0, jsx_1.createFunctionStringLiteralObjectProperty)(item.key, item.value);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
if (core_1.types.isObjectMethod(item)) {
|
|
52
|
-
return core_1.types.objectProperty(item.key, core_1.types.stringLiteral(""
|
|
52
|
+
return core_1.types.objectProperty(item.key, core_1.types.stringLiteral("".concat(method_literal_prefix_1.methodLiteralPrefix).concat((0, generator_1.default)(__assign(__assign({}, item), { returnType: null })).code)));
|
|
53
53
|
}
|
|
54
54
|
// Remove typescript types, e.g. from
|
|
55
55
|
// { foo: ('string' as SomeType) }
|
|
@@ -66,7 +66,7 @@ function parseReactiveScript(code, options) {
|
|
|
66
66
|
var code_1;
|
|
67
67
|
var obj = void 0;
|
|
68
68
|
try {
|
|
69
|
-
code_1 = generator_1.default(newObject).code;
|
|
69
|
+
code_1 = (0, generator_1.default)(newObject).code;
|
|
70
70
|
obj = json5_1.default.parse(code_1);
|
|
71
71
|
}
|
|
72
72
|
catch (err) {
|
|
@@ -14,7 +14,7 @@ function processHttpRequests(json) {
|
|
|
14
14
|
var value = httpRequests[key];
|
|
15
15
|
// TODO: unravel our proxy. aka parse out methods, header, etc
|
|
16
16
|
// and remove our proxy from being used anymore
|
|
17
|
-
onMount += "\n fetch(\""
|
|
17
|
+
onMount += "\n fetch(\"".concat(value, "\").then(res => res.json()).then(result => {\n state.").concat(key, " = result;\n })\n ");
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
json.hooks.onMount = onMount;
|
|
@@ -8,19 +8,19 @@ var lodash_1 = require("lodash");
|
|
|
8
8
|
var traverse_1 = __importDefault(require("traverse"));
|
|
9
9
|
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
10
10
|
function getRefName(path) {
|
|
11
|
-
return lodash_1.upperFirst(lodash_1.camelCase(lodash_1.last(path.split('.')))) + 'Ref';
|
|
11
|
+
return (0, lodash_1.upperFirst)((0, lodash_1.camelCase)((0, lodash_1.last)(path.split('.')))) + 'Ref';
|
|
12
12
|
}
|
|
13
13
|
function processTagReferences(json) {
|
|
14
14
|
var namesFound = new Set();
|
|
15
|
-
traverse_1.default(json).forEach(function (el) {
|
|
16
|
-
if (is_mitosis_node_1.isMitosisNode(el)) {
|
|
15
|
+
(0, traverse_1.default)(json).forEach(function (el) {
|
|
16
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(el)) {
|
|
17
17
|
if (el.name.includes('.')) {
|
|
18
18
|
if (!namesFound.has(el.name)) {
|
|
19
19
|
namesFound.add(el.name);
|
|
20
20
|
if (typeof json.hooks.init !== 'string') {
|
|
21
21
|
json.hooks.init = '';
|
|
22
22
|
}
|
|
23
|
-
json.hooks.init += "\n const "
|
|
23
|
+
json.hooks.init += "\n const ".concat(getRefName(el.name), " = ").concat(el.name, ";\n ");
|
|
24
24
|
}
|
|
25
25
|
el.name = getRefName(el.name);
|
|
26
26
|
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var remove_surrounding_block_1 = require("./remove-surrounding-block");
|
|
4
4
|
describe('removeSurroundingBlock', function () {
|
|
5
5
|
test('It removes the surrounding wrapper block', function () {
|
|
6
|
-
var output = remove_surrounding_block_1.removeSurroundingBlock('{ const foo = "bar" }');
|
|
6
|
+
var output = (0, remove_surrounding_block_1.removeSurroundingBlock)('{ const foo = "bar" }');
|
|
7
7
|
expect(output).toBe(' const foo = "bar" ');
|
|
8
8
|
});
|
|
9
9
|
});
|
|
@@ -23,12 +23,12 @@ var renderImport = function (theImport) {
|
|
|
23
23
|
var importString = 'import ';
|
|
24
24
|
var starImport = getStarImport(theImport);
|
|
25
25
|
if (starImport) {
|
|
26
|
-
importString += " * as "
|
|
26
|
+
importString += " * as ".concat(starImport, " ");
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
var defaultImport = getDefaultImport(theImport);
|
|
30
30
|
if (defaultImport) {
|
|
31
|
-
importString += " "
|
|
31
|
+
importString += " ".concat(defaultImport, ", ");
|
|
32
32
|
}
|
|
33
33
|
importString += ' { ';
|
|
34
34
|
var firstAdded = false;
|
|
@@ -43,14 +43,14 @@ var renderImport = function (theImport) {
|
|
|
43
43
|
else {
|
|
44
44
|
firstAdded = true;
|
|
45
45
|
}
|
|
46
|
-
importString += " "
|
|
46
|
+
importString += " ".concat(value, " ");
|
|
47
47
|
if (key !== value) {
|
|
48
|
-
importString += " as "
|
|
48
|
+
importString += " as ".concat(key, " ");
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
importString += ' } ';
|
|
52
52
|
}
|
|
53
|
-
importString += " from '"
|
|
53
|
+
importString += " from '".concat(theImport.path, "';");
|
|
54
54
|
return importString;
|
|
55
55
|
};
|
|
56
56
|
exports.renderImport = renderImport;
|
|
@@ -66,12 +66,12 @@ var renderImports = function (imports) {
|
|
|
66
66
|
if (theImport.path.startsWith('@builder.io/mitosis')) {
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
|
-
importString += exports.renderImport(theImport) + '\n';
|
|
69
|
+
importString += (0, exports.renderImport)(theImport) + '\n';
|
|
70
70
|
}
|
|
71
71
|
return importString;
|
|
72
72
|
};
|
|
73
73
|
exports.renderImports = renderImports;
|
|
74
74
|
var renderPreComponent = function (component) {
|
|
75
|
-
return "\n "
|
|
75
|
+
return "\n ".concat((0, exports.renderImports)(component.imports), "\n ").concat(component.hooks.preComponent || '', "\n ");
|
|
76
76
|
};
|
|
77
77
|
exports.renderPreComponent = renderPreComponent;
|
|
@@ -4,7 +4,7 @@ exports.replaceIdentifiers = void 0;
|
|
|
4
4
|
var core_1 = require("@babel/core");
|
|
5
5
|
var babel_transform_1 = require("./babel-transform");
|
|
6
6
|
var replaceIdentifiers = function (code, from, to) {
|
|
7
|
-
return babel_transform_1.babelTransformExpression(code, {
|
|
7
|
+
return (0, babel_transform_1.babelTransformExpression)(code, {
|
|
8
8
|
Identifier: function (path) {
|
|
9
9
|
if (
|
|
10
10
|
// This is not a property access - like `foo` in `this.foo`
|
|
@@ -7,8 +7,8 @@ exports.stripMetaProperties = void 0;
|
|
|
7
7
|
var traverse_1 = __importDefault(require("traverse"));
|
|
8
8
|
var is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
9
|
var stripMetaProperties = function (json) {
|
|
10
|
-
traverse_1.default(json).forEach(function (item) {
|
|
11
|
-
if (is_mitosis_node_1.isMitosisNode(item)) {
|
|
10
|
+
(0, traverse_1.default)(json).forEach(function (item) {
|
|
11
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
12
12
|
for (var property in item.properties) {
|
|
13
13
|
if (property.startsWith('$')) {
|
|
14
14
|
delete item.properties[property];
|
|
@@ -6,7 +6,7 @@ function traceReferenceToModulePath(imports, name) {
|
|
|
6
6
|
for (var _i = 0, imports_1 = imports; _i < imports_1.length; _i++) {
|
|
7
7
|
var importInfo = imports_1[_i];
|
|
8
8
|
if (name in importInfo.imports) {
|
|
9
|
-
return importInfo.path
|
|
9
|
+
return "".concat(importInfo.path, ":").concat(importInfo.imports[name]);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
return response;
|