@builder.io/mitosis 0.0.46 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/__tests__/angular.test.d.ts +1 -0
- package/dist/src/__tests__/angular.test.js +12 -0
- package/dist/src/__tests__/data/blocks/columns.raw.jsx +6 -0
- package/dist/src/__tests__/data/blocks/onUpdate.raw.d.ts +1 -0
- package/dist/src/__tests__/data/blocks/onUpdate.raw.jsx +10 -0
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +1 -0
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +11 -0
- package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +11 -0
- package/dist/src/__tests__/data/blocks/tabs.raw.jsx +24 -0
- package/dist/src/__tests__/qoot.test.d.ts +1 -0
- package/dist/src/__tests__/qoot.test.js +115 -0
- package/dist/src/__tests__/qwik.test.js +68 -9
- package/dist/src/__tests__/react.test.js +12 -0
- package/dist/src/__tests__/svelte.test.d.ts +1 -0
- package/dist/src/__tests__/svelte.test.js +12 -0
- package/dist/src/__tests__/vue.test.js +6 -0
- package/dist/src/generators/angular.js +7 -3
- package/dist/src/generators/builder.js +7 -7
- package/dist/src/generators/html.js +16 -7
- package/dist/src/generators/jsx-lite.d.ts +10 -0
- package/dist/src/generators/jsx-lite.js +176 -0
- package/dist/src/generators/minify.d.ts +1 -0
- package/dist/src/generators/minify.js +24 -0
- package/dist/src/generators/mitosis.js +5 -2
- package/dist/src/generators/qoot.d.ts +21 -0
- package/dist/src/generators/qoot.js +442 -0
- package/dist/src/generators/qwik/component.js +48 -6
- package/dist/src/generators/qwik/directives.d.ts +21 -1
- package/dist/src/generators/qwik/directives.js +93 -13
- package/dist/src/generators/qwik/jsx.d.ts +1 -1
- package/dist/src/generators/qwik/jsx.js +30 -7
- package/dist/src/generators/qwik/src-generator.d.ts +15 -2
- package/dist/src/generators/qwik/src-generator.js +82 -16
- package/dist/src/generators/qwik.d.ts +21 -0
- package/dist/src/generators/qwik.js +458 -0
- package/dist/src/generators/react-native.js +34 -27
- package/dist/src/generators/react.js +36 -14
- package/dist/src/generators/solid.js +5 -2
- package/dist/src/generators/svelte.js +10 -5
- package/dist/src/generators/vue.js +9 -6
- package/dist/src/helpers/create-jsx-lite-component.d.ts +2 -0
- package/dist/src/helpers/create-jsx-lite-component.js +16 -0
- package/dist/src/helpers/create-jsx-lite-context.d.ts +4 -0
- package/dist/src/helpers/create-jsx-lite-context.js +18 -0
- package/dist/src/helpers/create-jsx-lite-node.d.ts +2 -0
- package/dist/src/helpers/create-jsx-lite-node.js +16 -0
- package/dist/src/helpers/get-state-object-string.js +51 -38
- package/dist/src/helpers/is-jsx-lite-node.d.ts +2 -0
- package/dist/src/helpers/is-jsx-lite-node.js +7 -0
- package/dist/src/helpers/map-refs.js +10 -8
- 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 +3 -3
- package/dist/src/helpers/process-tag-references.js +4 -3
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +4 -3
- package/dist/src/jsx-types.d.ts +1 -1
- package/dist/src/parsers/builder.d.ts +50 -10
- package/dist/src/parsers/builder.js +37 -7
- package/dist/src/parsers/jsx.js +43 -3
- package/dist/src/parsers/liquid.js +4 -4
- package/dist/src/plugins/compile-away-builder-components.js +40 -20
- package/dist/src/symbols/symbol-processor.d.ts +18 -0
- package/dist/src/symbols/symbol-processor.js +177 -0
- package/dist/src/types/jsx-lite-component.d.ts +63 -0
- package/dist/src/types/jsx-lite-component.js +2 -0
- package/dist/src/types/jsx-lite-context.d.ts +6 -0
- package/dist/src/types/jsx-lite-context.js +2 -0
- package/dist/src/types/jsx-lite-node.d.ts +13 -0
- package/dist/src/types/jsx-lite-node.js +2 -0
- package/dist/src/types/jsx-lite-styles.d.ts +1 -0
- package/dist/src/types/jsx-lite-styles.js +2 -0
- package/dist/src/types/mitosis-component.d.ts +10 -5
- package/dist/test/qoot/Todo/bundle.js +88 -0
- package/dist/test/qoot/Todo/component.ts +17 -0
- package/dist/test/qoot/Todo/onButtonClick.ts +13 -0
- package/dist/test/qoot/Todo/onInput2Blur.ts +11 -0
- package/dist/test/qoot/Todo/onInput2KeyUp.ts +10 -0
- package/dist/test/qoot/Todo/onInputClick.ts +10 -0
- package/dist/test/qoot/Todo/onLabelDblClick.ts +11 -0
- package/dist/test/qoot/Todo/public.ts +4 -0
- package/dist/test/qoot/Todo/template.tsx +46 -0
- package/dist/test/qoot/Todos/component.ts +9 -0
- package/dist/test/qoot/Todos/onInputClick.ts +14 -0
- package/dist/test/qoot/Todos/public.ts +3 -0
- package/dist/test/qoot/Todos/template.tsx +30 -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/{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/Todo/bundle.js +46 -0
- package/dist/test/qwik/Todo/component.ts +17 -0
- package/dist/test/qwik/Todo/onButtonClick.ts +10 -0
- package/dist/test/qwik/Todo/onInput2Blur.ts +14 -0
- package/dist/test/qwik/Todo/onInput2KeyUp.ts +10 -0
- package/dist/test/qwik/Todo/onInputClick.ts +13 -0
- package/dist/test/qwik/Todo/onLabelDblClick.ts +11 -0
- package/dist/test/qwik/Todo/public.ts +3 -0
- package/dist/test/qwik/Todo/template.tsx +46 -0
- package/dist/test/qwik/Todo.ts +4 -0
- package/dist/test/qwik/Todo_component.ts +17 -0
- package/dist/test/qwik/Todo_onButtonClick.ts +13 -0
- package/dist/test/qwik/Todo_onInput2Blur.ts +14 -0
- package/dist/test/qwik/Todo_onInput2KeyUp.ts +10 -0
- package/dist/test/qwik/Todo_onInputClick.ts +13 -0
- package/dist/test/qwik/Todo_onLabelDblClick.ts +14 -0
- package/dist/test/qwik/Todo_template.tsx +46 -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/test/qwik/Todos/component.ts +9 -0
- package/dist/test/qwik/Todos/onInputClick.ts +14 -0
- package/dist/test/qwik/Todos/public.ts +3 -0
- package/dist/test/qwik/Todos/template.tsx +30 -0
- package/dist/test/qwik/Todos.ts +3 -0
- package/dist/test/qwik/Todos_component.ts +9 -0
- package/dist/test/qwik/Todos_onInputClick.ts +14 -0
- package/dist/test/qwik/Todos_template.tsx +30 -0
- package/dist/test/qwik/qwik/Image/high.js +1 -0
- package/dist/test/qwik/qwik/Image/low.js +75 -0
- package/dist/test/qwik/qwik/Image/med.js +9 -0
- package/dist/test/qwik/qwik/Image.slow/high.js +1 -0
- package/dist/test/qwik/qwik/Image.slow/low.js +75 -0
- package/dist/test/qwik/qwik/Image.slow/med.js +9 -0
- package/dist/test/qwik/qwik/button/high.js +8 -0
- package/dist/test/qwik/qwik/button/low.js +34 -0
- package/dist/test/qwik/qwik/button/med.js +9 -0
- package/dist/test/qwik/qwik/hello_world/stylesheet/high.jsx +1 -0
- package/dist/test/qwik/qwik/hello_world/stylesheet/low.jsx +24 -0
- package/dist/test/qwik/qwik/hello_world/stylesheet/med.jsx +9 -0
- package/dist/test/qwik/qwik/page-with-symbol/high.js +1 -0
- package/dist/test/qwik/qwik/page-with-symbol/low.js +49 -0
- package/dist/test/qwik/qwik/page-with-symbol/med.js +9 -0
- package/dist/test/qwik/qwik/svg/high.js +1 -0
- package/dist/test/qwik/qwik/svg/low.js +30 -0
- package/dist/test/qwik/qwik/svg/med.js +9 -0
- package/dist/test/qwik/qwik/todo/Todo.cjs/high.cjs +31 -0
- package/dist/test/qwik/qwik/todo/Todo.cjs/low.cjs +1 -0
- package/dist/test/qwik/qwik/todo/Todo.cjs/med.cjs +59 -0
- package/dist/test/qwik/qwik/todo/Todo.js/high.js +5 -0
- package/dist/{src/types/generators.d.ts → test/qwik/qwik/todo/Todo.js/low.js} +0 -0
- package/dist/test/qwik/qwik/todo/Todo.js/med.js +1 -0
- package/dist/test/qwik/qwik/todo/Todo.tsx/high.tsx +30 -0
- package/dist/test/qwik/qwik/todo/Todo.tsx/low.tsx +1 -0
- package/dist/test/qwik/qwik/todo/Todo.tsx/med.tsx +34 -0
- package/dist/test/qwik/qwik/todos/Todo.tsx/high.tsx +12 -0
- package/dist/test/qwik/qwik/todos/Todo.tsx/low.tsx +24 -0
- package/dist/test/qwik/qwik/todos/Todo.tsx/med.tsx +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/types/generators.js +0 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __assign = (this && this.__assign) || function () {
|
|
7
|
+
__assign = Object.assign || function(t) {
|
|
8
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
+
s = arguments[i];
|
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
+
t[p] = s[p];
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
14
|
+
};
|
|
15
|
+
return __assign.apply(this, arguments);
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.componentToJsxLite = exports.blockToJsxLite = exports.DEFAULT_FORMAT = void 0;
|
|
22
|
+
var dedent_1 = __importDefault(require("dedent"));
|
|
23
|
+
var json5_1 = __importDefault(require("json5"));
|
|
24
|
+
var standalone_1 = require("prettier/standalone");
|
|
25
|
+
var fast_clone_1 = require("../helpers/fast-clone");
|
|
26
|
+
var get_components_1 = require("../helpers/get-components");
|
|
27
|
+
var get_refs_1 = require("../helpers/get-refs");
|
|
28
|
+
var get_state_object_string_1 = require("../helpers/get-state-object-string");
|
|
29
|
+
var map_refs_1 = require("../helpers/map-refs");
|
|
30
|
+
var render_imports_1 = require("../helpers/render-imports");
|
|
31
|
+
var jsx_1 = require("../parsers/jsx");
|
|
32
|
+
var react_1 = require("./react");
|
|
33
|
+
exports.DEFAULT_FORMAT = 'legacy';
|
|
34
|
+
// Special isValidAttributeName for JSX Lite so we can allow for $ in names
|
|
35
|
+
var isValidAttributeName = function (str) {
|
|
36
|
+
return Boolean(str && /^[$a-z0-9\-_:]+$/i.test(str));
|
|
37
|
+
};
|
|
38
|
+
var blockToJsxLite = function (json, toJsxLiteOptions) {
|
|
39
|
+
if (toJsxLiteOptions === void 0) { toJsxLiteOptions = {}; }
|
|
40
|
+
var options = __assign({ format: exports.DEFAULT_FORMAT }, toJsxLiteOptions);
|
|
41
|
+
if (options.format === 'react') {
|
|
42
|
+
return react_1.blockToReact(json, {
|
|
43
|
+
format: 'lite',
|
|
44
|
+
stateType: 'useState',
|
|
45
|
+
stylesType: 'emotion',
|
|
46
|
+
prettier: options.prettier,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (json.name === 'For') {
|
|
50
|
+
var needsWrapper = json.children.length !== 1;
|
|
51
|
+
return "<For each={" + json.bindings.each + "}>\n {(" + json.properties._forName + ", index) =>\n " + (needsWrapper ? '<>' : '') + "\n " + json.children.map(function (child) { return exports.blockToJsxLite(child, options); }) + "}\n " + (needsWrapper ? '</>' : '') + "\n </For>";
|
|
52
|
+
}
|
|
53
|
+
if (json.properties._text) {
|
|
54
|
+
return json.properties._text;
|
|
55
|
+
}
|
|
56
|
+
if (json.bindings._text) {
|
|
57
|
+
return "{" + json.bindings._text + "}";
|
|
58
|
+
}
|
|
59
|
+
var str = '';
|
|
60
|
+
str += "<" + json.name + " ";
|
|
61
|
+
if (json.bindings._spread) {
|
|
62
|
+
str += " {...(" + json.bindings._spread + ")} ";
|
|
63
|
+
}
|
|
64
|
+
for (var key in json.properties) {
|
|
65
|
+
var value = (json.properties[key] || '')
|
|
66
|
+
.replace(/"/g, '"')
|
|
67
|
+
.replace(/\n/g, '\\n');
|
|
68
|
+
if (!isValidAttributeName(key)) {
|
|
69
|
+
console.warn('Skipping invalid attribute name:', key);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
str += " " + key + "=\"" + value + "\" ";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (var key in json.bindings) {
|
|
76
|
+
var value = json.bindings[key];
|
|
77
|
+
if (key === '_spread') {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (key.startsWith('on')) {
|
|
81
|
+
str += " " + key + "={event => " + value.replace(/\s*;$/, '') + "} ";
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (!isValidAttributeName(key)) {
|
|
85
|
+
console.warn('Skipping invalid attribute name:', key);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
str += " " + key + "={" + value + "} ";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (jsx_1.selfClosingTags.has(json.name)) {
|
|
93
|
+
return str + ' />';
|
|
94
|
+
}
|
|
95
|
+
// Self close by default if no children
|
|
96
|
+
if (!json.children.length) {
|
|
97
|
+
str += ' />';
|
|
98
|
+
return str;
|
|
99
|
+
}
|
|
100
|
+
str += '>';
|
|
101
|
+
if (json.children) {
|
|
102
|
+
str += json.children
|
|
103
|
+
.map(function (item) { return exports.blockToJsxLite(item, options); })
|
|
104
|
+
.join('\n');
|
|
105
|
+
}
|
|
106
|
+
str += "</" + json.name + ">";
|
|
107
|
+
return str;
|
|
108
|
+
};
|
|
109
|
+
exports.blockToJsxLite = blockToJsxLite;
|
|
110
|
+
var getRefsString = function (json, refs) {
|
|
111
|
+
if (refs === void 0) { refs = get_refs_1.getRefs(json); }
|
|
112
|
+
var str = '';
|
|
113
|
+
for (var _i = 0, _a = Array.from(refs); _i < _a.length; _i++) {
|
|
114
|
+
var ref = _a[_i];
|
|
115
|
+
str += "\nconst " + ref + " = useRef();";
|
|
116
|
+
}
|
|
117
|
+
return str;
|
|
118
|
+
};
|
|
119
|
+
var jsxLiteCoreComponents = ['Show', 'For'];
|
|
120
|
+
var componentToJsxLite = function (componentJson, toJsxLiteOptions) {
|
|
121
|
+
if (toJsxLiteOptions === void 0) { toJsxLiteOptions = {}; }
|
|
122
|
+
var options = __assign({ format: exports.DEFAULT_FORMAT }, toJsxLiteOptions);
|
|
123
|
+
if (options.format === 'react') {
|
|
124
|
+
return react_1.componentToReact(componentJson, {
|
|
125
|
+
format: 'lite',
|
|
126
|
+
stateType: 'useState',
|
|
127
|
+
stylesType: 'emotion',
|
|
128
|
+
prettier: options.prettier,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
var json = fast_clone_1.fastClone(componentJson);
|
|
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 jsxLiteComponents = components.filter(function (item) {
|
|
137
|
+
return jsxLiteCoreComponents.includes(item);
|
|
138
|
+
});
|
|
139
|
+
var otherComponents = components.filter(function (item) { return !jsxLiteCoreComponents.includes(item); });
|
|
140
|
+
var hasState = Boolean(Object.keys(componentJson.state).length);
|
|
141
|
+
var needsJsxLiteCoreImport = Boolean(hasState || refs.size || jsxLiteComponents.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 "])), !needsJsxLiteCoreImport
|
|
149
|
+
? ''
|
|
150
|
+
: "import { " + (!hasState ? '' : 'useState, ') + " " + (!refs.size ? '' : 'useRef, ') + " " + jsxLiteComponents.join(', ') + " } from '@jsx-lite/core';", !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.blockToJsxLite(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
|
+
});
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
console.error('Format error for file:', str, JSON.stringify(json, null, 2));
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return str;
|
|
174
|
+
};
|
|
175
|
+
exports.componentToJsxLite = componentToJsxLite;
|
|
176
|
+
var templateObject_1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function minify(messageParts: TemplateStringsArray, ...expressions: readonly any[]): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minify = void 0;
|
|
4
|
+
function minify(messageParts) {
|
|
5
|
+
var expressions = [];
|
|
6
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7
|
+
expressions[_i - 1] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
var text = '';
|
|
10
|
+
for (var i = 0; i < messageParts.length; i++) {
|
|
11
|
+
var part = messageParts[i];
|
|
12
|
+
text += part;
|
|
13
|
+
if (i < expressions.length) {
|
|
14
|
+
text += expressions[i];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return text
|
|
18
|
+
.replace('\n', ' ')
|
|
19
|
+
.replace(/^\s+/, '')
|
|
20
|
+
.replace(/\s+$/, '')
|
|
21
|
+
.replace(/\s+/g, ' ')
|
|
22
|
+
.replace(/\s?([,;\:\-\{\}\(\)\<\>])\s?/g, function (_, match) { return match; });
|
|
23
|
+
}
|
|
24
|
+
exports.minify = minify;
|
|
@@ -120,6 +120,7 @@ var mitosisCoreComponents = ['Show', 'For'];
|
|
|
120
120
|
var componentToMitosis = function (toMitosisOptions) {
|
|
121
121
|
if (toMitosisOptions === void 0) { toMitosisOptions = {}; }
|
|
122
122
|
return function (_a) {
|
|
123
|
+
var _b, _c;
|
|
123
124
|
var component = _a.component;
|
|
124
125
|
var options = __assign({ format: exports.DEFAULT_FORMAT }, toMitosisOptions);
|
|
125
126
|
if (options.format === 'react') {
|
|
@@ -150,9 +151,11 @@ var componentToMitosis = function (toMitosisOptions) {
|
|
|
150
151
|
? ''
|
|
151
152
|
: "".concat(jsx_1.METADATA_HOOK_NAME, "(").concat(json5_1.default.stringify(component.meta.metadataHook), ")"), component.name, !hasState
|
|
152
153
|
? ''
|
|
153
|
-
: "const state = useState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");"), getRefsString(json), !json.hooks.onMount
|
|
154
|
+
: "const state = useState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");"), getRefsString(json), !((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code)
|
|
154
155
|
? ''
|
|
155
|
-
: "
|
|
156
|
+
: "onMount(() => { ".concat(json.hooks.onMount.code, " })"), !((_c = json.hooks.onUnMount) === null || _c === void 0 ? void 0 : _c.code)
|
|
157
|
+
? ''
|
|
158
|
+
: "onUnMount(() => { ".concat(json.hooks.onUnMount.code, " })"), addWrapper ? '<>' : '', json.children.map(function (item) { return (0, exports.blockToMitosis)(item, options); }).join('\n'), addWrapper ? '</>' : '');
|
|
156
159
|
if (options.prettier !== false) {
|
|
157
160
|
try {
|
|
158
161
|
str = (0, standalone_1.format)(str, {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Plugin } from '../modules/plugins';
|
|
2
|
+
import { JSXLiteComponent } from '../types/jsx-lite-component';
|
|
3
|
+
declare type ToQootOptions = {
|
|
4
|
+
prettier?: boolean;
|
|
5
|
+
plugins?: Plugin[];
|
|
6
|
+
qootLib?: string;
|
|
7
|
+
qrlPrefix?: string;
|
|
8
|
+
cssNamespace?: string;
|
|
9
|
+
minifyStyles?: boolean;
|
|
10
|
+
qrlSuffix?: string;
|
|
11
|
+
bundle?: boolean;
|
|
12
|
+
format?: 'builder' | 'default';
|
|
13
|
+
};
|
|
14
|
+
export declare type File = {
|
|
15
|
+
path: string;
|
|
16
|
+
contents: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const componentToQoot: (componentJson: JSXLiteComponent, toQootOptions?: ToQootOptions) => Promise<{
|
|
19
|
+
files: File[];
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|