@builder.io/mitosis 0.0.48 → 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/CHANGELOG.md +4 -0
- 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/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 +38 -10
- 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 +80 -3
- package/dist/src/generators/qwik/jsx.d.ts +1 -1
- package/dist/src/generators/qwik/jsx.js +28 -5
- package/dist/src/generators/qwik/src-generator.d.ts +3 -1
- package/dist/src/generators/qwik/src-generator.js +34 -10
- package/dist/src/generators/qwik.d.ts +21 -0
- package/dist/src/generators/qwik.js +458 -0
- package/dist/src/generators/react.js +13 -7
- package/dist/src/generators/solid.js +5 -2
- package/dist/src/generators/svelte.js +10 -5
- package/dist/src/generators/vue.js +7 -5
- 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/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 +7 -6
- 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/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 +3 -4
- 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/{For/high.jsx → qwik/Image.slow/high.js} +0 -0
- package/dist/test/qwik/qwik/Image.slow/low.js +75 -0
- package/dist/test/qwik/{For/med.jsx → qwik/Image.slow/med.js} +0 -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
- package/dist/test/qwik/For/low.jsx +0 -55
|
@@ -1,6 +1,11 @@
|
|
|
1
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
|
+
};
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DIRECTIVES = void 0;
|
|
7
|
+
exports.CoreButton = exports.Image = exports.DIRECTIVES = void 0;
|
|
8
|
+
var minify_1 = require("../minify");
|
|
4
9
|
var src_generator_1 = require("./src-generator");
|
|
5
10
|
exports.DIRECTIVES = {
|
|
6
11
|
Show: function (node, blockFn) {
|
|
@@ -18,10 +23,82 @@ exports.DIRECTIVES = {
|
|
|
18
23
|
var expr = node.bindings.each;
|
|
19
24
|
this.isJSX && this.emit('{', src_generator_1.WS);
|
|
20
25
|
this.emit('(', expr, src_generator_1.WS, '||', src_generator_1.WS, '[])');
|
|
21
|
-
this.emit('.map(', '()', src_generator_1.WS, '
|
|
26
|
+
this.emit('.map(', '(function(__value__)', src_generator_1.WS, '{', src_generator_1.INDENT, src_generator_1.NL);
|
|
27
|
+
this.emit('var state', src_generator_1.WS, '=', src_generator_1.WS, 'Object.assign({},', src_generator_1.WS, 'this,', src_generator_1.WS, '{', (0, src_generator_1.iteratorProperty)(expr), ':', src_generator_1.WS, '__value__', src_generator_1.WS, '==', src_generator_1.WS, 'null', src_generator_1.WS, '?', src_generator_1.WS, '{}', src_generator_1.WS, ':', src_generator_1.WS, '__value__', '});', src_generator_1.NL);
|
|
28
|
+
this.emit('return', src_generator_1.WS, '(');
|
|
22
29
|
blockFn();
|
|
23
|
-
this.emit(
|
|
30
|
+
this.emit(')', ';', src_generator_1.UNINDENT, src_generator_1.NL);
|
|
31
|
+
this.emit('}', ').bind(state))', src_generator_1.NL);
|
|
24
32
|
this.isJSX && this.emit('}', src_generator_1.NL);
|
|
25
33
|
};
|
|
26
34
|
},
|
|
35
|
+
Image: (0, minify_1.minify)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), Image),
|
|
36
|
+
CoreButton: (0, minify_1.minify)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["", ""], ["", ""])), CoreButton),
|
|
27
37
|
};
|
|
38
|
+
function Image(props) {
|
|
39
|
+
var jsx = props.children || [];
|
|
40
|
+
var image = props.image;
|
|
41
|
+
if (image) {
|
|
42
|
+
var isBuilderIoImage = !!(image || '').match(/builder\.io/);
|
|
43
|
+
var imgProps = {
|
|
44
|
+
src: props.image,
|
|
45
|
+
style: "object-fit:".concat(props.backgroundSize ||
|
|
46
|
+
'cover', ";object-position:").concat(props.backgroundPosition || 'center', ";") +
|
|
47
|
+
(props.aspectRatio
|
|
48
|
+
? 'position:absolute;height:100%;width:100%;top:0;left:0'
|
|
49
|
+
: ''),
|
|
50
|
+
sizes: props.sizes,
|
|
51
|
+
alt: props.altText,
|
|
52
|
+
loading: props.lazy ? 'lazy' : undefined,
|
|
53
|
+
srcset: undefined,
|
|
54
|
+
};
|
|
55
|
+
var sizingDiv = h('div', {
|
|
56
|
+
class: 'builder-image-sizer',
|
|
57
|
+
style: "width:100%;padding-top:".concat((props.aspectRatio || 1) *
|
|
58
|
+
100, "%;pointer-events:none;font-size:0"),
|
|
59
|
+
});
|
|
60
|
+
if (isBuilderIoImage) {
|
|
61
|
+
var srcset = ['100', '200', '400', '800', '1200', '1600', '2000']
|
|
62
|
+
.map(function (size) {
|
|
63
|
+
return updateQueryParam(image, 'width', size) + ' ' + size + 'w';
|
|
64
|
+
})
|
|
65
|
+
.concat([image])
|
|
66
|
+
.join(', ');
|
|
67
|
+
imgProps.srcset = srcset;
|
|
68
|
+
jsx = jsx = [
|
|
69
|
+
h('picture', {}, [
|
|
70
|
+
h('source', { type: 'image/webp', srcset: srcset }),
|
|
71
|
+
h('img', imgProps, jsx),
|
|
72
|
+
]),
|
|
73
|
+
sizingDiv,
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
jsx = [h('img', imgProps, jsx), sizingDiv];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
var children = props.children ? [jsx].concat(props.children) : [jsx];
|
|
81
|
+
return h(props.href ? 'a' : 'div', { href: props.href, class: props.class }, children);
|
|
82
|
+
function updateQueryParam(uri, key, value) {
|
|
83
|
+
if (uri === void 0) { uri = ''; }
|
|
84
|
+
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
|
|
85
|
+
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
|
86
|
+
if (uri.match(re)) {
|
|
87
|
+
return uri.replace(re, '$1' + key + '=' + encodeURIComponent(value) + '$2');
|
|
88
|
+
}
|
|
89
|
+
return uri + separator + key + '=' + encodeURIComponent(value);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.Image = Image;
|
|
93
|
+
function CoreButton(props) {
|
|
94
|
+
var hasLink = !!props.link;
|
|
95
|
+
var hProps = {
|
|
96
|
+
innerHTML: props.text || '',
|
|
97
|
+
href: props.link,
|
|
98
|
+
target: props.openInNewTab ? '_blank' : '_self',
|
|
99
|
+
class: props.class,
|
|
100
|
+
};
|
|
101
|
+
return h(hasLink ? 'a' : props.tagName$ || 'span', hProps);
|
|
102
|
+
}
|
|
103
|
+
exports.CoreButton = CoreButton;
|
|
104
|
+
var templateObject_1, templateObject_2;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { MitosisNode } from '../../types/mitosis-node';
|
|
2
2
|
import { File } from './src-generator';
|
|
3
3
|
import { CssStyles } from './styles';
|
|
4
|
-
export declare function renderJSXNodes(file: File, handlers: Map<string, string>, children: MitosisNode[], styles: Map<string, CssStyles>, root?: boolean): any;
|
|
4
|
+
export declare function renderJSXNodes(file: File, directives: Map<string, string>, handlers: Map<string, string>, children: MitosisNode[], styles: Map<string, CssStyles>, parentSymbolBindings: Record<string, string>, root?: boolean): any;
|
|
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.renderJSXNodes = void 0;
|
|
24
24
|
var directives_1 = require("./directives");
|
|
25
25
|
var src_generator_1 = require("./src-generator");
|
|
26
|
-
function renderJSXNodes(file, handlers, children, styles, root) {
|
|
26
|
+
function renderJSXNodes(file, directives, handlers, children, styles, parentSymbolBindings, root) {
|
|
27
27
|
if (root === void 0) { root = true; }
|
|
28
28
|
return function () {
|
|
29
29
|
var _this = this;
|
|
@@ -55,10 +55,16 @@ function renderJSXNodes(file, handlers, children, styles, root) {
|
|
|
55
55
|
var directive = directives_1.DIRECTIVES[childName];
|
|
56
56
|
if (typeof directive == 'function') {
|
|
57
57
|
_this.emit(directive(child, function () {
|
|
58
|
-
return renderJSXNodes(file, handlers, child.children, styles, false).call(_this);
|
|
58
|
+
return renderJSXNodes(file, directives, handlers, child.children, styles, {}, false).call(_this);
|
|
59
59
|
}));
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
+
if (typeof directive == 'string') {
|
|
63
|
+
directives.set(childName, directive);
|
|
64
|
+
if (file.module !== 'med') {
|
|
65
|
+
file.import('./med.js', childName);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
62
68
|
if (isSymbol(childName)) {
|
|
63
69
|
// TODO(misko): We are hard coding './med.js' which is not right.
|
|
64
70
|
file.import('./med.js', childName);
|
|
@@ -73,8 +79,10 @@ function renderJSXNodes(file, handlers, children, styles, root) {
|
|
|
73
79
|
props = __assign({}, props);
|
|
74
80
|
props.class = addClass(styles.get(css).CLASS_NAME, props.class);
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
var symbolBindings = {};
|
|
83
|
+
var bindings = rewriteHandlers(file, handlers, child.bindings, symbolBindings);
|
|
84
|
+
_this.jsxBegin(childName, props, __assign(__assign({}, bindings), parentSymbolBindings));
|
|
85
|
+
renderJSXNodes(file, directives, handlers, child.children, styles, symbolBindings, false).call(_this);
|
|
78
86
|
_this.jsxEnd(childName);
|
|
79
87
|
}
|
|
80
88
|
}
|
|
@@ -100,7 +108,19 @@ function isEmptyTextNode(child) {
|
|
|
100
108
|
function isTextNode(child) {
|
|
101
109
|
return (child.properties._text !== undefined || child.bindings._text !== undefined);
|
|
102
110
|
}
|
|
103
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Rewrites bindings:
|
|
113
|
+
* - Remove `css`
|
|
114
|
+
* - Rewrites event handles
|
|
115
|
+
* - Extracts symbol bindings.
|
|
116
|
+
*
|
|
117
|
+
* @param file
|
|
118
|
+
* @param handlers
|
|
119
|
+
* @param bindings
|
|
120
|
+
* @param symbolBindings Options record which will receive the symbol bindings
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
function rewriteHandlers(file, handlers, bindings, symbolBindings) {
|
|
104
124
|
var outBindings = {};
|
|
105
125
|
for (var key in bindings) {
|
|
106
126
|
if (Object.prototype.hasOwnProperty.call(bindings, key)) {
|
|
@@ -116,6 +136,9 @@ function rewriteHandlers(file, handlers, bindings) {
|
|
|
116
136
|
(0, src_generator_1.quote)(file.qrlPrefix + 'high#' + handlerBlock),
|
|
117
137
|
]);
|
|
118
138
|
}
|
|
139
|
+
else if (symbolBindings && key.startsWith('symbol.data.')) {
|
|
140
|
+
symbolBindings[(0, src_generator_1.lastProperty)(key)] = binding;
|
|
141
|
+
}
|
|
119
142
|
outBindings[key] = binding;
|
|
120
143
|
}
|
|
121
144
|
}
|
|
@@ -40,7 +40,7 @@ export declare class SrcBuilder {
|
|
|
40
40
|
emit(...values: any[]): this;
|
|
41
41
|
private push;
|
|
42
42
|
emitList(values: any[], sep?: string): this;
|
|
43
|
-
const(name: string, value?: any, exprt?: boolean): this;
|
|
43
|
+
const(name: string, value?: any, exprt?: boolean, locallyVisible?: boolean): this;
|
|
44
44
|
type(def: string): this;
|
|
45
45
|
typeParameters(typeParameters: string[] | undefined): void;
|
|
46
46
|
jsxBegin(symbol: Symbol | string, props: Record<string, any>, bindings: Record<string, any>): void;
|
|
@@ -77,3 +77,5 @@ export declare function iif(code: any): (this: SrcBuilder) => void;
|
|
|
77
77
|
* it is not 100% but a good enough approximation
|
|
78
78
|
*/
|
|
79
79
|
export declare function isStatement(code: string): boolean;
|
|
80
|
+
export declare function lastProperty(expr: string): string;
|
|
81
|
+
export declare function iteratorProperty(expr: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isStatement = exports.iif = exports.arrowFnValue = exports.arrowFnBlock = exports.invoke = exports.quote = exports.Block = exports.Imports = exports.Symbol = exports.SrcBuilder = exports.File = exports.UNINDENT = exports.INDENT = exports.NL = exports.RS = exports.WS = void 0;
|
|
3
|
+
exports.iteratorProperty = exports.lastProperty = exports.isStatement = exports.iif = exports.arrowFnValue = exports.arrowFnBlock = exports.invoke = exports.quote = exports.Block = exports.Imports = exports.Symbol = exports.SrcBuilder = exports.File = exports.UNINDENT = exports.INDENT = exports.NL = exports.RS = exports.WS = void 0;
|
|
4
4
|
exports.WS = String.fromCharCode(29);
|
|
5
5
|
exports.RS = ' ';
|
|
6
6
|
exports.NL = '\n';
|
|
@@ -44,6 +44,8 @@ var File = /** @class */ (function () {
|
|
|
44
44
|
return quote(this.qrlPrefix + this.module + '#' + symbol);
|
|
45
45
|
};
|
|
46
46
|
File.prototype.exportConst = function (name, value) {
|
|
47
|
+
if (this.exports.has(name))
|
|
48
|
+
return;
|
|
47
49
|
this.exports.set(name, this.src.isModule ? name : 'exports.' + name);
|
|
48
50
|
this.src.const(name, value, true);
|
|
49
51
|
};
|
|
@@ -188,10 +190,13 @@ var SrcBuilder = /** @class */ (function () {
|
|
|
188
190
|
}
|
|
189
191
|
return this;
|
|
190
192
|
};
|
|
191
|
-
SrcBuilder.prototype.const = function (name, value, exprt) {
|
|
193
|
+
SrcBuilder.prototype.const = function (name, value, exprt, locallyVisible) {
|
|
192
194
|
if (exprt === void 0) { exprt = false; }
|
|
195
|
+
if (locallyVisible === void 0) { locallyVisible = false; }
|
|
193
196
|
if (exprt) {
|
|
194
|
-
this.emit(this.isModule
|
|
197
|
+
this.emit(this.isModule
|
|
198
|
+
? 'export const '
|
|
199
|
+
: (locallyVisible ? 'const ' + name + '=' : '') + 'exports.');
|
|
195
200
|
}
|
|
196
201
|
else {
|
|
197
202
|
this.emit('const ');
|
|
@@ -215,6 +220,10 @@ var SrcBuilder = /** @class */ (function () {
|
|
|
215
220
|
}
|
|
216
221
|
};
|
|
217
222
|
SrcBuilder.prototype.jsxBegin = function (symbol, props, bindings) {
|
|
223
|
+
if (symbol == 'div' && ('href' in props || 'href' in bindings)) {
|
|
224
|
+
// HACK: if we contain href then we are `a` not `div`
|
|
225
|
+
symbol = 'a';
|
|
226
|
+
}
|
|
218
227
|
if (this.isJSX) {
|
|
219
228
|
this.emit('<' + symbol);
|
|
220
229
|
}
|
|
@@ -238,9 +247,11 @@ var SrcBuilder = /** @class */ (function () {
|
|
|
238
247
|
this.emit(quote(props[key]));
|
|
239
248
|
}
|
|
240
249
|
}
|
|
241
|
-
for (var
|
|
242
|
-
if (Object.prototype.hasOwnProperty.call(bindings,
|
|
243
|
-
!ignoreKey(
|
|
250
|
+
for (var rawKey in bindings) {
|
|
251
|
+
if (Object.prototype.hasOwnProperty.call(bindings, rawKey) &&
|
|
252
|
+
!ignoreKey(rawKey)) {
|
|
253
|
+
var binding = bindings[rawKey];
|
|
254
|
+
var key = lastProperty(rawKey);
|
|
244
255
|
if (first) {
|
|
245
256
|
first = false;
|
|
246
257
|
this.isJSX && this.emit(exports.RS, exports.INDENT, exports.INDENT);
|
|
@@ -250,8 +261,12 @@ var SrcBuilder = /** @class */ (function () {
|
|
|
250
261
|
}
|
|
251
262
|
this.isJSX ? this.emit(key) : this.emit(possiblyQuotePropertyName(key));
|
|
252
263
|
this.isJSX ? this.emit('={') : this.emit(':', exports.WS);
|
|
253
|
-
|
|
254
|
-
|
|
264
|
+
if (binding === props[key]) {
|
|
265
|
+
// HACK: workaround for the fact that sometimes the `bindings` have string literals
|
|
266
|
+
// We assume that when the binding content equals prop content.
|
|
267
|
+
binding = JSON.stringify(binding);
|
|
268
|
+
}
|
|
269
|
+
else if (typeof binding == 'string' && isStatement(binding)) {
|
|
255
270
|
binding = iif(binding);
|
|
256
271
|
}
|
|
257
272
|
this.emit(binding);
|
|
@@ -336,10 +351,10 @@ exports.Imports = Imports;
|
|
|
336
351
|
function ignoreKey(key) {
|
|
337
352
|
return (key.startsWith('$') ||
|
|
338
353
|
key.startsWith('_') ||
|
|
339
|
-
key.startsWith('symbol.data') ||
|
|
340
354
|
key == 'code' ||
|
|
341
355
|
key == '' ||
|
|
342
|
-
key == 'builder-id'
|
|
356
|
+
key == 'builder-id' ||
|
|
357
|
+
key.indexOf('.') !== -1);
|
|
343
358
|
}
|
|
344
359
|
var Block = /** @class */ (function () {
|
|
345
360
|
function Block(imports) {
|
|
@@ -425,3 +440,12 @@ var STRING_LITERAL = /(["'`])((\\{2})*|((\n|.)*?[^\\](\\{2})*))\1/g;
|
|
|
425
440
|
var EXPRESSION_SEPARATORS = /[()\[\]{}.\?:\-+/*,]+/;
|
|
426
441
|
// https://regexr.com/6cpka
|
|
427
442
|
var EXPRESSION_IDENTIFIER = /^\s*[a-zA-Z0-9_$]+\s*$/;
|
|
443
|
+
function lastProperty(expr) {
|
|
444
|
+
var parts = expr.split('.');
|
|
445
|
+
return parts[parts.length - 1];
|
|
446
|
+
}
|
|
447
|
+
exports.lastProperty = lastProperty;
|
|
448
|
+
function iteratorProperty(expr) {
|
|
449
|
+
return lastProperty(expr) + 'Item';
|
|
450
|
+
}
|
|
451
|
+
exports.iteratorProperty = iteratorProperty;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Plugin } from '../modules/plugins';
|
|
2
|
+
import { MitosisComponent } from '../types/mitosis-component';
|
|
3
|
+
declare type ToQwikOptions = {
|
|
4
|
+
prettier?: boolean;
|
|
5
|
+
plugins?: Plugin[];
|
|
6
|
+
qwikLib?: 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 componentToQwik: (componentJson: MitosisComponent, toQwikOptions?: ToQwikOptions) => Promise<{
|
|
19
|
+
files: File[];
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|