@builder.io/mitosis 0.4.0 → 0.4.2
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/constants/media-sizes.js +4 -5
- package/dist/src/generators/alpine/generate.js +114 -132
- package/dist/src/generators/alpine/render-mount-hook.js +8 -5
- package/dist/src/generators/alpine/render-update-hooks.js +13 -13
- package/dist/src/generators/angular/helpers.js +19 -9
- package/dist/src/generators/angular/index.js +599 -584
- package/dist/src/generators/builder.js +200 -165
- package/dist/src/generators/context/angular.js +32 -26
- package/dist/src/generators/context/helpers/context-with-symbol-key.js +25 -21
- package/dist/src/generators/context/qwik.js +21 -21
- package/dist/src/generators/context/react.js +22 -22
- package/dist/src/generators/context/rsc.js +20 -22
- package/dist/src/generators/context/solid.js +22 -22
- package/dist/src/generators/context/svelte.js +33 -28
- package/dist/src/generators/context/vue.js +1 -1
- package/dist/src/generators/helpers/context.js +6 -13
- package/dist/src/generators/helpers/functions.js +8 -8
- package/dist/src/generators/helpers/on-mount.js +9 -5
- package/dist/src/generators/helpers/rsc.js +7 -9
- package/dist/src/generators/html.js +995 -534
- package/dist/src/generators/liquid.js +81 -79
- package/dist/src/generators/lit/collect-class-string.js +10 -12
- package/dist/src/generators/lit/generate.js +204 -159
- package/dist/src/generators/marko/generate.js +193 -183
- package/dist/src/generators/minify.js +5 -9
- package/dist/src/generators/mitosis.js +135 -134
- package/dist/src/generators/qwik/component-generator.js +159 -154
- package/dist/src/generators/qwik/component.js +51 -81
- package/dist/src/generators/qwik/directives.js +68 -84
- package/dist/src/generators/qwik/helpers/add-prevent-default.js +6 -7
- package/dist/src/generators/qwik/helpers/convert-method-to-function.js +38 -38
- package/dist/src/generators/qwik/helpers/handlers.js +16 -25
- package/dist/src/generators/qwik/helpers/stable-inject.js +7 -8
- package/dist/src/generators/qwik/helpers/stable-serialize.js +7 -8
- package/dist/src/generators/qwik/helpers/state.js +36 -43
- package/dist/src/generators/qwik/helpers/styles.js +19 -40
- package/dist/src/generators/qwik/jsx.js +63 -75
- package/dist/src/generators/qwik/src-generator.js +134 -167
- package/dist/src/generators/react/blocks.js +122 -127
- package/dist/src/generators/react/generator.js +314 -259
- package/dist/src/generators/react/helpers.js +23 -28
- package/dist/src/generators/react/state.js +34 -51
- package/dist/src/generators/react-native/index.js +72 -84
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +14 -26
- package/dist/src/generators/rsc.js +30 -36
- package/dist/src/generators/solid/blocks.js +46 -43
- package/dist/src/generators/solid/helpers/styles.js +11 -11
- package/dist/src/generators/solid/index.js +199 -190
- package/dist/src/generators/solid/state/helpers.js +76 -90
- package/dist/src/generators/solid/state/signals.js +30 -37
- package/dist/src/generators/solid/state/state.js +35 -48
- package/dist/src/generators/solid/state/store.js +40 -46
- package/dist/src/generators/stencil/collect-class-string.js +10 -12
- package/dist/src/generators/stencil/generate.js +158 -145
- package/dist/src/generators/svelte/blocks.js +146 -144
- package/dist/src/generators/svelte/helpers.js +10 -17
- package/dist/src/generators/svelte/svelte.js +321 -287
- package/dist/src/generators/swift-ui.js +162 -101
- package/dist/src/generators/taro.js +32 -36
- package/dist/src/generators/template.js +71 -74
- package/dist/src/generators/vue/blocks.js +116 -107
- package/dist/src/generators/vue/compositionApi.js +67 -50
- package/dist/src/generators/vue/helpers.js +71 -96
- package/dist/src/generators/vue/optionsApi.js +134 -105
- package/dist/src/generators/vue/vue.js +210 -207
- package/dist/src/helpers/babel-transform.js +40 -63
- package/dist/src/helpers/bindings.js +4 -12
- package/dist/src/helpers/camel-case.js +4 -5
- package/dist/src/helpers/capitalize.js +1 -1
- package/dist/src/helpers/component-file-extensions.js +23 -35
- package/dist/src/helpers/create-mitosis-component.js +22 -26
- package/dist/src/helpers/create-mitosis-context.js +5 -12
- package/dist/src/helpers/create-mitosis-node.js +10 -12
- package/dist/src/helpers/dash-case.js +2 -2
- package/dist/src/helpers/dedent.js +18 -22
- package/dist/src/helpers/event-handlers.js +1 -1
- package/dist/src/helpers/fast-clone.js +1 -1
- package/dist/src/helpers/filter-empty-text-nodes.js +2 -2
- package/dist/src/helpers/generic-format.js +7 -8
- package/dist/src/helpers/get-bindings.js +4 -4
- package/dist/src/helpers/get-components-used.js +3 -3
- package/dist/src/helpers/get-components.js +4 -4
- package/dist/src/helpers/get-custom-imports.js +10 -12
- package/dist/src/helpers/get-prop-functions.js +7 -8
- package/dist/src/helpers/get-props-ref.js +8 -8
- package/dist/src/helpers/get-props.js +12 -13
- package/dist/src/helpers/get-refs.js +4 -4
- package/dist/src/helpers/get-state-object-string.js +42 -61
- package/dist/src/helpers/get-state-used.js +7 -8
- package/dist/src/helpers/get-styles.js +6 -6
- package/dist/src/helpers/getters-to-functions.js +8 -12
- package/dist/src/helpers/handle-missing-state.js +3 -3
- package/dist/src/helpers/has-bindings-text.js +6 -6
- package/dist/src/helpers/has-component.js +4 -4
- package/dist/src/helpers/has-props.js +3 -3
- package/dist/src/helpers/has-stateful-dom.js +4 -4
- package/dist/src/helpers/has.js +3 -3
- package/dist/src/helpers/indent.js +2 -3
- package/dist/src/helpers/is-children.js +4 -5
- package/dist/src/helpers/is-component.js +1 -1
- package/dist/src/helpers/is-html-attribute.js +2 -11
- package/dist/src/helpers/is-mitosis-node.js +1 -1
- package/dist/src/helpers/is-root-text-node.js +1 -1
- package/dist/src/helpers/is-upper-case.js +1 -1
- package/dist/src/helpers/is-valid-attribute-name.js +1 -1
- package/dist/src/helpers/json.js +2 -2
- package/dist/src/helpers/map-refs.js +29 -40
- package/dist/src/helpers/merge-options.js +20 -31
- package/dist/src/helpers/mitosis-imports.js +5 -6
- package/dist/src/helpers/nodes/for.js +2 -3
- package/dist/src/helpers/nullable.js +1 -3
- package/dist/src/helpers/on-event.js +32 -36
- package/dist/src/helpers/output.js +4 -5
- package/dist/src/helpers/parse-node.js +13 -5
- package/dist/src/helpers/parsers.js +10 -14
- package/dist/src/helpers/patterns.js +6 -8
- package/dist/src/helpers/plugins/process-code/index.js +114 -120
- package/dist/src/helpers/plugins/process-signals.js +114 -125
- package/dist/src/helpers/plugins/process-target-blocks.js +18 -20
- package/dist/src/helpers/process-http-requests.js +8 -4
- package/dist/src/helpers/remove-surrounding-block.js +2 -2
- package/dist/src/helpers/render-imports.js +99 -111
- package/dist/src/helpers/replace-identifiers.js +40 -49
- package/dist/src/helpers/replace-new-lines-in-strings.js +3 -3
- package/dist/src/helpers/signals/signals.js +27 -35
- package/dist/src/helpers/slots.js +11 -20
- package/dist/src/helpers/state.js +1 -3
- package/dist/src/helpers/strip-meta-properties.js +6 -6
- package/dist/src/helpers/strip-state-and-props-refs.js +21 -32
- package/dist/src/helpers/styles/collect-css.js +39 -44
- package/dist/src/helpers/styles/collect-styled-components.js +30 -28
- package/dist/src/helpers/styles/helpers.js +23 -29
- package/dist/src/helpers/trace-reference-to-module-path.js +3 -4
- package/dist/src/helpers/transform-state-setters.js +16 -19
- package/dist/src/helpers/traverse-nodes.js +2 -2
- package/dist/src/helpers/try-prettier-format.js +3 -3
- package/dist/src/helpers/typescript-project.js +25 -25
- package/dist/src/helpers/typescript.js +1 -3
- package/dist/src/modules/plugins.js +20 -28
- package/dist/src/parsers/angular.js +49 -57
- package/dist/src/parsers/builder/builder.js +448 -343
- package/dist/src/parsers/builder/helpers.js +10 -10
- package/dist/src/parsers/context.js +15 -17
- package/dist/src/parsers/jsx/ast.js +11 -11
- package/dist/src/parsers/jsx/component-types.js +22 -32
- package/dist/src/parsers/jsx/context.js +12 -12
- package/dist/src/parsers/jsx/element-parser.js +43 -54
- package/dist/src/parsers/jsx/exports.js +12 -14
- package/dist/src/parsers/jsx/function-parser.js +108 -119
- package/dist/src/parsers/jsx/helpers.js +11 -13
- package/dist/src/parsers/jsx/hooks/helpers.js +14 -16
- package/dist/src/parsers/jsx/hooks/index.js +34 -44
- package/dist/src/parsers/jsx/hooks/use-target.js +27 -27
- package/dist/src/parsers/jsx/imports.js +7 -17
- package/dist/src/parsers/jsx/jsx.js +92 -91
- package/dist/src/parsers/jsx/props-types.js +8 -10
- package/dist/src/parsers/jsx/props.js +15 -23
- package/dist/src/parsers/jsx/signals.js +28 -29
- package/dist/src/parsers/jsx/state.d.ts +2 -4
- package/dist/src/parsers/jsx/state.js +59 -93
- package/dist/src/parsers/svelte/css/index.js +1 -1
- package/dist/src/parsers/svelte/helpers/bindings.js +18 -19
- package/dist/src/parsers/svelte/helpers/children.js +5 -6
- package/dist/src/parsers/svelte/helpers/expressions.js +7 -9
- package/dist/src/parsers/svelte/helpers/hooks.js +2 -2
- package/dist/src/parsers/svelte/helpers/post-process.js +49 -70
- package/dist/src/parsers/svelte/helpers/string.js +5 -5
- package/dist/src/parsers/svelte/html/actions.js +17 -10
- package/dist/src/parsers/svelte/html/each.js +11 -16
- package/dist/src/parsers/svelte/html/element.js +68 -78
- package/dist/src/parsers/svelte/html/fragment.js +3 -3
- package/dist/src/parsers/svelte/html/if-else.js +11 -18
- package/dist/src/parsers/svelte/html/index.js +14 -14
- package/dist/src/parsers/svelte/html/mustache-tag.js +5 -5
- package/dist/src/parsers/svelte/html/slot.js +5 -5
- package/dist/src/parsers/svelte/html/text.js +7 -14
- package/dist/src/parsers/svelte/index.js +23 -72
- package/dist/src/parsers/svelte/instance/context.js +17 -17
- package/dist/src/parsers/svelte/instance/expressions.js +2 -2
- package/dist/src/parsers/svelte/instance/functions.js +35 -30
- package/dist/src/parsers/svelte/instance/hooks.js +4 -5
- package/dist/src/parsers/svelte/instance/imports.js +11 -21
- package/dist/src/parsers/svelte/instance/index.js +22 -22
- package/dist/src/parsers/svelte/instance/properties.js +11 -23
- package/dist/src/parsers/svelte/instance/reactive.js +11 -11
- package/dist/src/parsers/svelte/instance/references.js +13 -13
- package/dist/src/parsers/svelte/instance/statements.js +3 -3
- package/dist/src/parsers/svelte/module/index.js +14 -26
- package/dist/src/parsers/svelte/typescript/index.js +27 -36
- package/dist/src/plugins/compile-away-builder-components.js +223 -156
- package/dist/src/plugins/compile-away-components.js +13 -21
- package/dist/src/plugins/map-styles.js +7 -7
- package/dist/src/symbols/symbol-processor.js +44 -62
- package/dist/src/targets.js +19 -19
- package/dist/src/types/mitosis-node.js +1 -1
- package/package.json +1 -1
|
@@ -1,46 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
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));
|
|
21
|
-
};
|
|
22
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
3
|
exports.addCommonStyles = exports.renderUseLexicalScope = exports.addComponent = exports.createFileSet = void 0;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function createFileSet(options) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
4
|
+
const compile_away_builder_components_1 = require("../../plugins/compile-away-builder-components");
|
|
5
|
+
const on_mount_1 = require("../helpers/on-mount");
|
|
6
|
+
const directives_1 = require("./directives");
|
|
7
|
+
const handlers_1 = require("./helpers/handlers");
|
|
8
|
+
const stable_serialize_1 = require("./helpers/stable-serialize");
|
|
9
|
+
const styles_1 = require("./helpers/styles");
|
|
10
|
+
const jsx_1 = require("./jsx");
|
|
11
|
+
const src_generator_1 = require("./src-generator");
|
|
12
|
+
function createFileSet(options = {}) {
|
|
13
|
+
const opts = {
|
|
14
|
+
qwikLib: '@builder.io/qwik',
|
|
15
|
+
qrlPrefix: './',
|
|
16
|
+
output: 'ts',
|
|
17
|
+
minify: false,
|
|
18
|
+
jsx: true,
|
|
19
|
+
...options,
|
|
20
|
+
};
|
|
21
|
+
const extension = (opts.output == 'mjs' ? 'js' : opts.output) + (opts.jsx ? 'x' : '');
|
|
22
|
+
const srcOptions = {
|
|
37
23
|
isPretty: !opts.minify,
|
|
38
24
|
isModule: opts.output != 'cjs',
|
|
39
25
|
isTypeScript: opts.output == 'ts',
|
|
40
26
|
isJSX: opts.jsx,
|
|
41
27
|
isBuilder: true,
|
|
42
28
|
};
|
|
43
|
-
|
|
29
|
+
const fileSet = {
|
|
44
30
|
high: new src_generator_1.File('high.' + extension, srcOptions, opts.qwikLib, opts.qrlPrefix),
|
|
45
31
|
med: new src_generator_1.File('med.' + extension, srcOptions, opts.qwikLib, opts.qrlPrefix),
|
|
46
32
|
low: new src_generator_1.File('low.' + extension, srcOptions, opts.qwikLib, opts.qrlPrefix),
|
|
@@ -55,55 +41,54 @@ exports.createFileSet = createFileSet;
|
|
|
55
41
|
function getCommonStyles(fileSet) {
|
|
56
42
|
return fileSet['CommonStyles'];
|
|
57
43
|
}
|
|
58
|
-
function addComponent(fileSet, component, opts) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
function addComponent(fileSet, component, opts = {}) {
|
|
45
|
+
const _opts = { isRoot: false, shareStyles: false, ...opts };
|
|
46
|
+
(0, compile_away_builder_components_1.compileAwayBuilderComponentsFromTree)(component, {
|
|
47
|
+
...compile_away_builder_components_1.components,
|
|
62
48
|
// A set of components that should not be compiled away because they are implemented as runtime components.
|
|
63
|
-
Image: undefined,
|
|
49
|
+
Image: undefined,
|
|
50
|
+
CoreButton: undefined,
|
|
51
|
+
});
|
|
64
52
|
addBuilderBlockClass(component.children);
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
const componentName = component.name;
|
|
54
|
+
const handlers = (0, handlers_1.renderHandlers)(fileSet.high, componentName, component.children);
|
|
67
55
|
// If the component has no handlers, than it is probably static
|
|
68
56
|
// and so it is unlikely to be re-rendered on the client, therefore
|
|
69
57
|
// put it in a low priority bucket.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
const isStatic = Array.from(handlers.keys()).reduce((p, v) => p && v.indexOf('state') == -1, true);
|
|
59
|
+
const onRenderFile = isStatic ? fileSet.low : fileSet.med;
|
|
60
|
+
const componentFile = fileSet.med;
|
|
61
|
+
const styles = _opts.shareStyles ? getCommonStyles(fileSet).styles : new Map();
|
|
74
62
|
(0, styles_1.collectStyles)(component.children, styles);
|
|
75
|
-
|
|
63
|
+
let useStyles = () => null;
|
|
76
64
|
if (styles.size) {
|
|
77
65
|
if (_opts.shareStyles) {
|
|
78
66
|
if (_opts.isRoot) {
|
|
79
|
-
|
|
67
|
+
const symbolName = componentName + 'Styles';
|
|
80
68
|
getCommonStyles(fileSet).symbolName = symbolName;
|
|
81
69
|
useStyles = generateStyles(onRenderFile, fileSet.low, symbolName, false);
|
|
82
70
|
}
|
|
83
71
|
}
|
|
84
72
|
else {
|
|
85
|
-
|
|
73
|
+
const symbolName = componentName + 'Styles';
|
|
86
74
|
onRenderFile.exportConst(symbolName, (0, styles_1.renderStyles)(styles));
|
|
87
75
|
useStyles = generateStyles(onRenderFile, onRenderFile, symbolName, true);
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
78
|
if (component.meta.cssCode) {
|
|
91
|
-
|
|
79
|
+
const symbolName = componentName + 'UsrStyles';
|
|
92
80
|
onRenderFile.exportConst(symbolName, (0, stable_serialize_1.stableJSONserialize)(component.meta.cssCode));
|
|
93
|
-
useStyles = (function (
|
|
94
|
-
|
|
95
|
-
var _this = this;
|
|
96
|
-
fns.forEach(function (fn) { return fn.apply(_this); });
|
|
97
|
-
};
|
|
81
|
+
useStyles = ((fns) => function () {
|
|
82
|
+
fns.forEach((fn) => fn.apply(this));
|
|
98
83
|
})([useStyles, generateStyles(onRenderFile, onRenderFile, symbolName, false)]);
|
|
99
84
|
}
|
|
100
|
-
|
|
101
|
-
|
|
85
|
+
const directives = new Map();
|
|
86
|
+
let rootChildren = component.children;
|
|
102
87
|
addComponentOnMount(onRenderFile, function () {
|
|
103
88
|
return this.emit('return ', (0, jsx_1.renderJSXNodes)(onRenderFile, directives, handlers, rootChildren, styles, null, {}), ';');
|
|
104
89
|
}, componentName, component, useStyles);
|
|
105
90
|
componentFile.exportConst(componentName, (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'componentQrl'), [generateQrl(componentFile, onRenderFile, componentName + 'OnMount')], ['any', 'any']));
|
|
106
|
-
directives.forEach(
|
|
91
|
+
directives.forEach((code, name) => {
|
|
107
92
|
fileSet.med.import(fileSet.med.qwikModule, 'h');
|
|
108
93
|
fileSet.med.exportConst(name, code, true);
|
|
109
94
|
});
|
|
@@ -126,8 +111,8 @@ function generateStyles(fromFile, dstFile, symbol, scoped) {
|
|
|
126
111
|
};
|
|
127
112
|
}
|
|
128
113
|
function addBuilderBlockClass(children) {
|
|
129
|
-
children.forEach(
|
|
130
|
-
|
|
114
|
+
children.forEach((child) => {
|
|
115
|
+
const props = child.properties;
|
|
131
116
|
if (props['builder-id']) {
|
|
132
117
|
props.class = (props.class ? props.class + ' ' : '') + 'builder-block';
|
|
133
118
|
}
|
|
@@ -145,37 +130,23 @@ function renderUseLexicalScope(file) {
|
|
|
145
130
|
}
|
|
146
131
|
exports.renderUseLexicalScope = renderUseLexicalScope;
|
|
147
132
|
function addCommonStyles(fileSet) {
|
|
148
|
-
|
|
149
|
-
|
|
133
|
+
const { styles, symbolName } = getCommonStyles(fileSet);
|
|
134
|
+
const onRenderFile = fileSet.low;
|
|
150
135
|
if (symbolName) {
|
|
151
136
|
onRenderFile.exportConst(symbolName, (0, styles_1.renderStyles)(styles));
|
|
152
137
|
}
|
|
153
138
|
}
|
|
154
139
|
exports.addCommonStyles = addCommonStyles;
|
|
155
140
|
function addComponentOnMount(componentFile, onRenderEmit, componentName, component, useStyles) {
|
|
156
|
-
|
|
141
|
+
const inputInitializer = [];
|
|
157
142
|
if (component.inputs) {
|
|
158
|
-
component.inputs.forEach(
|
|
143
|
+
component.inputs.forEach((input) => {
|
|
159
144
|
input.defaultValue !== undefined &&
|
|
160
145
|
inputInitializer.push('if(!state.hasOwnProperty("', input.name, '"))state.', input.name, '=', (0, stable_serialize_1.stableJSONserialize)(input.defaultValue), ';');
|
|
161
146
|
});
|
|
162
147
|
}
|
|
163
148
|
componentFile.exportConst(componentName + 'OnMount', function () {
|
|
164
|
-
|
|
165
|
-
this.emit((0, src_generator_1.arrowFnValue)(['p'], function () {
|
|
166
|
-
return _this.emit.apply(_this, __spreadArray(__spreadArray(['{',
|
|
167
|
-
'const s=',
|
|
168
|
-
componentFile.import(componentFile.qwikModule, 'useStore').localName,
|
|
169
|
-
'(()=>{',
|
|
170
|
-
'const state=Object.assign({},structuredClone(typeof __STATE__==="object"&&__STATE__[p.serverStateId]),p);'], inputInitializer, false), [inlineCode((0, on_mount_1.stringifySingleScopeOnMount)(component)),
|
|
171
|
-
'return state;',
|
|
172
|
-
'},{deep:true});',
|
|
173
|
-
'const l={};',
|
|
174
|
-
'const state=__proxyMerge__(s,l);',
|
|
175
|
-
useStyles,
|
|
176
|
-
onRenderEmit,
|
|
177
|
-
';}'], false));
|
|
178
|
-
}));
|
|
149
|
+
this.emit((0, src_generator_1.arrowFnValue)(['p'], () => this.emit('{', 'const s=', componentFile.import(componentFile.qwikModule, 'useStore').localName, '(()=>{', 'const state=Object.assign({},structuredClone(typeof __STATE__==="object"&&__STATE__[p.serverStateId]),p);', ...inputInitializer, inlineCode((0, on_mount_1.stringifySingleScopeOnMount)(component)), 'return state;', '},{deep:true});', 'const l={};', 'const state=__proxyMerge__(s,l);', useStyles, onRenderEmit, ';}')));
|
|
179
150
|
});
|
|
180
151
|
}
|
|
181
152
|
function inlineCode(code) {
|
|
@@ -190,11 +161,10 @@ function inlineCode(code) {
|
|
|
190
161
|
}
|
|
191
162
|
};
|
|
192
163
|
}
|
|
193
|
-
function generateQrl(fromFile, dstFile, componentName, capture) {
|
|
194
|
-
if (capture === void 0) { capture = []; }
|
|
164
|
+
function generateQrl(fromFile, dstFile, componentName, capture = []) {
|
|
195
165
|
return (0, src_generator_1.invoke)(fromFile.import(fromFile.qwikModule, 'qrl'), [
|
|
196
166
|
dstFile.toQrlChunk(),
|
|
197
167
|
(0, src_generator_1.quote)(componentName),
|
|
198
|
-
|
|
168
|
+
`[${capture.join(',')}]`,
|
|
199
169
|
]);
|
|
200
170
|
}
|
|
@@ -1,92 +1,78 @@
|
|
|
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
|
-
};
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.Image = exports.DIRECTIVES = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const for_1 = require("../../helpers/nodes/for");
|
|
5
|
+
const minify_1 = require("../minify");
|
|
6
|
+
const src_generator_1 = require("./src-generator");
|
|
11
7
|
exports.DIRECTIVES = {
|
|
12
|
-
Show:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
8
|
+
Show: (node, blockFn) => function () {
|
|
9
|
+
var _a;
|
|
10
|
+
const expr = (_a = node.bindings.when) === null || _a === void 0 ? void 0 : _a.code;
|
|
11
|
+
const elseBlockFn = blockFn.else;
|
|
12
|
+
this.jsxExpression(() => {
|
|
13
|
+
this.emit(expr, '?');
|
|
14
|
+
blockFn();
|
|
15
|
+
this.emit(':');
|
|
16
|
+
if (elseBlockFn) {
|
|
17
|
+
elseBlockFn();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.emit('null');
|
|
21
|
+
}
|
|
22
|
+
});
|
|
30
23
|
},
|
|
31
|
-
For:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_this.emit(');}');
|
|
54
|
-
_this.isBuilder && _this.emit(').bind(l))');
|
|
55
|
-
_this.emit(')');
|
|
56
|
-
});
|
|
57
|
-
};
|
|
24
|
+
For: (_node, blockFn) => function () {
|
|
25
|
+
var _a;
|
|
26
|
+
const node = _node;
|
|
27
|
+
const expr = (_a = node.bindings.each) === null || _a === void 0 ? void 0 : _a.code;
|
|
28
|
+
this.jsxExpression(() => {
|
|
29
|
+
const forArgs = (0, for_1.getForArguments)(node);
|
|
30
|
+
const forName = forArgs[0];
|
|
31
|
+
this.emit('(', expr, '||[]).map(');
|
|
32
|
+
this.isBuilder && this.emit('((');
|
|
33
|
+
this.emit('(', forArgs, ') => {');
|
|
34
|
+
if (this.isBuilder) {
|
|
35
|
+
this.emit('const l={...this,', (0, src_generator_1.iteratorProperty)(expr), ':', forName, '==null?{}:', forName, ',', () => forArgs.forEach((arg) => {
|
|
36
|
+
this.emit(arg, ':', arg, ',');
|
|
37
|
+
}), '};');
|
|
38
|
+
this.emit('const state = __proxyMerge__(s,l);');
|
|
39
|
+
}
|
|
40
|
+
this.emit('return(');
|
|
41
|
+
blockFn();
|
|
42
|
+
this.emit(');}');
|
|
43
|
+
this.isBuilder && this.emit(').bind(l))');
|
|
44
|
+
this.emit(')');
|
|
45
|
+
});
|
|
58
46
|
},
|
|
59
|
-
Image: (0, minify_1.minify)
|
|
60
|
-
CoreButton: (0, minify_1.minify)
|
|
61
|
-
__passThroughProps__: (0, minify_1.minify)
|
|
62
|
-
__proxyMerge__: (0, minify_1.minify)
|
|
47
|
+
Image: (0, minify_1.minify) `${Image}`,
|
|
48
|
+
CoreButton: (0, minify_1.minify) `${CoreButton}`,
|
|
49
|
+
__passThroughProps__: (0, minify_1.minify) `${__passThroughProps__}`,
|
|
50
|
+
__proxyMerge__: (0, minify_1.minify) `${__proxyMerge__}`,
|
|
63
51
|
};
|
|
64
52
|
function Image(props) {
|
|
65
53
|
var _a;
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
let jsx = props.children || [];
|
|
55
|
+
let image = props.image;
|
|
68
56
|
if (image) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
const isBuilderIoImage = !!(image || '').match(/\.builder\.io/) && !props.noWebp;
|
|
58
|
+
const isPixel = (_a = props.builderBlock) === null || _a === void 0 ? void 0 : _a.id.startsWith('builder-pixel-');
|
|
59
|
+
const imgProps = {
|
|
72
60
|
src: props.image,
|
|
73
|
-
style:
|
|
61
|
+
style: `object-fit:${props.backgroundSize || 'cover'};object-position:${props.backgroundPosition || 'center'};` + (props.aspectRatio ? 'position:absolute;height:100%;width:100%;top:0;left:0' : ''),
|
|
74
62
|
sizes: props.sizes,
|
|
75
63
|
alt: props.altText,
|
|
76
64
|
role: !props.altText ? 'presentation' : undefined,
|
|
77
65
|
loading: isPixel ? 'eager' : 'lazy',
|
|
78
66
|
srcset: undefined,
|
|
79
67
|
};
|
|
80
|
-
|
|
81
|
-
return Object.keys(imgProps).forEach(function (k) { return imgProps[k] === undefined && delete imgProps[k]; });
|
|
82
|
-
};
|
|
68
|
+
const qwikBugWorkaround = (imgProps) => Object.keys(imgProps).forEach((k) => imgProps[k] === undefined && delete imgProps[k]);
|
|
83
69
|
qwikBugWorkaround(imgProps);
|
|
84
70
|
if (isBuilderIoImage) {
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
const webpImage = updateQueryParam(image, 'format', 'webp');
|
|
72
|
+
const srcset = ['100', '200', '400', '800', '1200', '1600', '2000']
|
|
87
73
|
.concat(props.srcsetSizes ? String(props.srcsetSizes).split(' ') : [])
|
|
88
|
-
.map(
|
|
89
|
-
return updateQueryParam(
|
|
74
|
+
.map((size) => {
|
|
75
|
+
return updateQueryParam(webpImage, 'width', size) + ' ' + size + 'w';
|
|
90
76
|
})
|
|
91
77
|
.concat(tryAppendWidth(image))
|
|
92
78
|
.join(', ');
|
|
@@ -102,27 +88,26 @@ function Image(props) {
|
|
|
102
88
|
jsx = [h('img', imgProps, jsx)];
|
|
103
89
|
}
|
|
104
90
|
if (props.aspectRatio && !(props.fitContent && props.children && props.children.length)) {
|
|
105
|
-
|
|
91
|
+
const sizingDiv = h('div', {
|
|
106
92
|
class: 'builder-image-sizer',
|
|
107
|
-
style:
|
|
93
|
+
style: `width:100%;padding-top:${(props.aspectRatio || 1) * 100}%;pointer-events:none;font-size:0`,
|
|
108
94
|
});
|
|
109
95
|
jsx.push(sizingDiv);
|
|
110
96
|
}
|
|
111
97
|
}
|
|
112
|
-
|
|
98
|
+
const children = props.children ? [jsx].concat(props.children) : [jsx];
|
|
113
99
|
return h(props.href ? 'a' : 'div', __passThroughProps__({ href: props.href, class: props.class }, props), children);
|
|
114
|
-
function updateQueryParam(uri, key, value) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
|
100
|
+
function updateQueryParam(uri = '', key, value) {
|
|
101
|
+
const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
|
|
102
|
+
const separator = uri.indexOf('?') !== -1 ? '&' : '?';
|
|
118
103
|
if (uri.match(re)) {
|
|
119
104
|
return uri.replace(re, '$1' + key + '=' + encodeURIComponent(value) + '$2');
|
|
120
105
|
}
|
|
121
106
|
return uri + separator + key + '=' + encodeURIComponent(value);
|
|
122
107
|
}
|
|
123
108
|
function tryAppendWidth(url) {
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
const match = url.match(/[?&]width=(\d+)/);
|
|
110
|
+
const width = match && match[1];
|
|
126
111
|
if (width) {
|
|
127
112
|
return [url + ' ' + width + 'w'];
|
|
128
113
|
}
|
|
@@ -131,7 +116,7 @@ function Image(props) {
|
|
|
131
116
|
}
|
|
132
117
|
exports.Image = Image;
|
|
133
118
|
function __passThroughProps__(dstProps, srcProps) {
|
|
134
|
-
for (
|
|
119
|
+
for (const key in srcProps) {
|
|
135
120
|
if (Object.prototype.hasOwnProperty.call(srcProps, key) &&
|
|
136
121
|
((key.startsWith('on') && key.endsWith('$')) || key == 'style')) {
|
|
137
122
|
dstProps[key] = srcProps[key];
|
|
@@ -140,8 +125,8 @@ function __passThroughProps__(dstProps, srcProps) {
|
|
|
140
125
|
return dstProps;
|
|
141
126
|
}
|
|
142
127
|
function CoreButton(props) {
|
|
143
|
-
|
|
144
|
-
|
|
128
|
+
const hasLink = !!props.link;
|
|
129
|
+
const hProps = {
|
|
145
130
|
dangerouslySetInnerHTML: props.text || '',
|
|
146
131
|
href: props.link,
|
|
147
132
|
target: props.openInNewTab ? '_blank' : '_self',
|
|
@@ -151,7 +136,7 @@ function CoreButton(props) {
|
|
|
151
136
|
}
|
|
152
137
|
function __proxyMerge__(state, local) {
|
|
153
138
|
return new Proxy(state, {
|
|
154
|
-
get:
|
|
139
|
+
get: (obj, prop) => {
|
|
155
140
|
if (local && prop in local) {
|
|
156
141
|
return local[prop];
|
|
157
142
|
}
|
|
@@ -159,10 +144,9 @@ function __proxyMerge__(state, local) {
|
|
|
159
144
|
return state[prop];
|
|
160
145
|
}
|
|
161
146
|
},
|
|
162
|
-
set:
|
|
147
|
+
set: (obj, prop, value) => {
|
|
163
148
|
obj[prop] = value;
|
|
164
149
|
return true;
|
|
165
150
|
},
|
|
166
151
|
});
|
|
167
152
|
}
|
|
168
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -4,24 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.addPreventDefault = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("../../../helpers/is-mitosis-node");
|
|
9
9
|
/**
|
|
10
10
|
* Find event handlers that explicitly call .preventDefault() and
|
|
11
11
|
* add preventdefault:event
|
|
12
12
|
* https://qwik.builder.io/tutorial/events/preventdefault
|
|
13
13
|
*/
|
|
14
14
|
function addPreventDefault(json) {
|
|
15
|
-
(0, legacy_1.default)(json).forEach(
|
|
15
|
+
(0, legacy_1.default)(json).forEach((node) => {
|
|
16
16
|
var _a;
|
|
17
17
|
if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
18
18
|
if (node.bindings) {
|
|
19
|
-
for (
|
|
20
|
-
var key = _b[_i];
|
|
19
|
+
for (const key of Object.keys(node.bindings)) {
|
|
21
20
|
if (key.startsWith('on')) {
|
|
22
21
|
if ((_a = node.bindings[key]) === null || _a === void 0 ? void 0 : _a.code.includes('.preventDefault()')) {
|
|
23
|
-
|
|
24
|
-
node.properties['preventdefault:' +
|
|
22
|
+
const event = key.slice(2).toLowerCase();
|
|
23
|
+
node.properties['preventdefault:' + event] = '';
|
|
25
24
|
node.bindings[key].code = node.bindings[key].code.replace(/.*?\.preventDefault\(\);?/, '').trim();
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertMethodToFunction = void 0;
|
|
4
4
|
function convertMethodToFunction(code, properties, lexicalArgs) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const out = [];
|
|
6
|
+
let idx = 0;
|
|
7
|
+
let lastIdx = idx;
|
|
8
|
+
let end = code.length;
|
|
9
|
+
let mode = "code" /* Mode.code */;
|
|
10
|
+
let braceDepth = 0;
|
|
11
|
+
let stringEndBraceDepth = -1;
|
|
12
|
+
let stringEndBraceDepthQueue = [];
|
|
13
|
+
let lastCh = null;
|
|
14
14
|
while (idx < end) {
|
|
15
|
-
|
|
15
|
+
const ch = code.charCodeAt(idx++);
|
|
16
16
|
switch (mode) {
|
|
17
17
|
case "code" /* Mode.code */:
|
|
18
18
|
if (ch === QUOTE_DOUBLE) {
|
|
@@ -46,22 +46,22 @@ function convertMethodToFunction(code, properties, lexicalArgs) {
|
|
|
46
46
|
consumeIdent();
|
|
47
47
|
if (code.charCodeAt(idx) == DOT) {
|
|
48
48
|
idx++;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const propEndIdx = findIdentEnd();
|
|
50
|
+
const identifier = code.substring(idx, propEndIdx);
|
|
51
|
+
const propType = properties[identifier];
|
|
52
52
|
if (propType) {
|
|
53
|
-
|
|
53
|
+
const isGetter = code.charCodeAt(propEndIdx) !== OPEN_PAREN;
|
|
54
54
|
lastIdx = idx = propEndIdx + (isGetter ? 0 : 1);
|
|
55
55
|
if (isGetter) {
|
|
56
56
|
if (propType === 'method') {
|
|
57
|
-
out.push(identifier,
|
|
57
|
+
out.push(identifier, `.bind(null,${lexicalArgs.join(',')})`);
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
|
-
out.push(identifier,
|
|
60
|
+
out.push(identifier, `(${lexicalArgs.join(',')})`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
-
out.push(identifier,
|
|
64
|
+
out.push(identifier, `(${lexicalArgs.join(',')},`);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
@@ -107,7 +107,7 @@ function convertMethodToFunction(code, properties, lexicalArgs) {
|
|
|
107
107
|
lastIdx = idx;
|
|
108
108
|
}
|
|
109
109
|
function findIdentEnd() {
|
|
110
|
-
|
|
110
|
+
let scanIdx = idx;
|
|
111
111
|
while (isIdentCh(code.charCodeAt(scanIdx)) && scanIdx < end) {
|
|
112
112
|
scanIdx++;
|
|
113
113
|
}
|
|
@@ -130,7 +130,7 @@ function isIdentCh(ch) {
|
|
|
130
130
|
function isWord(ch, code, idx, word) {
|
|
131
131
|
if (ch !== word.charCodeAt(0))
|
|
132
132
|
return false;
|
|
133
|
-
for (
|
|
133
|
+
for (let i = 1; i < word.length; i++) {
|
|
134
134
|
if (code.charCodeAt(idx + i - 1) !== word.charCodeAt(i)) {
|
|
135
135
|
return false;
|
|
136
136
|
}
|
|
@@ -140,22 +140,22 @@ function isWord(ch, code, idx, word) {
|
|
|
140
140
|
}
|
|
141
141
|
return true;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
143
|
+
const QUOTE_DOUBLE = '"'.charCodeAt(0);
|
|
144
|
+
const QUOTE_SINGLE = "'".charCodeAt(0);
|
|
145
|
+
const QUOTE_BACK_TICK = '`'.charCodeAt(0);
|
|
146
|
+
const BACKSLASH = `\\`.charCodeAt(0);
|
|
147
|
+
const FORWARD_SLASH = `/`.charCodeAt(0);
|
|
148
|
+
const EOL = `\n`.charCodeAt(0);
|
|
149
|
+
const STAR = `*`.charCodeAt(0);
|
|
150
|
+
const CHAR_0 = `0`.charCodeAt(0);
|
|
151
|
+
const CHAR_9 = `9`.charCodeAt(0);
|
|
152
|
+
const CHAR_a = `a`.charCodeAt(0);
|
|
153
|
+
const CHAR_z = `z`.charCodeAt(0);
|
|
154
|
+
const CHAR_A = `A`.charCodeAt(0);
|
|
155
|
+
const CHAR_Z = `Z`.charCodeAt(0);
|
|
156
|
+
const UNDERSCORE = `_`.charCodeAt(0);
|
|
157
|
+
const DOLLAR = `$`.charCodeAt(0);
|
|
158
|
+
const DOT = `.`.charCodeAt(0);
|
|
159
|
+
const OPEN_PAREN = '('.charCodeAt(0);
|
|
160
|
+
const OPEN_BRACE = '{'.charCodeAt(0);
|
|
161
|
+
const CLOSE_BRACE = '}'.charCodeAt(0);
|