@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,16 +1,8 @@
|
|
|
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.createSingleBinding = void 0;
|
|
15
|
-
|
|
4
|
+
const createSingleBinding = (args) => ({
|
|
5
|
+
...args,
|
|
6
|
+
type: 'single',
|
|
7
|
+
});
|
|
16
8
|
exports.createSingleBinding = createSingleBinding;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.camelCase = void 0;
|
|
4
|
-
|
|
4
|
+
const capitalize_1 = require("./capitalize");
|
|
5
5
|
/**
|
|
6
6
|
* This is a function similar to loadash `camelCase`, but it does not mess with capitalization.
|
|
7
7
|
*
|
|
@@ -9,10 +9,9 @@ var capitalize_1 = require("./capitalize");
|
|
|
9
9
|
* this fn: `camelCase('A-BC')` => "ABC"
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
function camelCase(text) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var first = parts.shift();
|
|
12
|
+
function camelCase(text = '') {
|
|
13
|
+
const parts = text.split('-');
|
|
14
|
+
const first = parts.shift();
|
|
16
15
|
return first + parts.map(capitalize_1.capitalize).join('');
|
|
17
16
|
}
|
|
18
17
|
exports.camelCase = camelCase;
|
|
@@ -1,58 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFileExtensionForTarget = exports.getComponentFileExtensionForTarget = exports.renameImport = exports.renameComponentImport = exports.renameComponentFile = exports.INPUT_EXTENSION_REGEX = exports.checkIsMitosisComponentFilePath = exports.checkIsLiteComponentFilePath = exports.checkIsSvelteComponentFilePath = exports.COMPONENT_IMPORT_EXTENSIONS = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const output_1 = require("./output");
|
|
5
|
+
const COMPONENT_EXTENSIONS = {
|
|
6
6
|
jsx: ['.lite.tsx', '.lite.jsx'],
|
|
7
7
|
svelte: ['.svelte'],
|
|
8
8
|
};
|
|
9
9
|
exports.COMPONENT_IMPORT_EXTENSIONS = [COMPONENT_EXTENSIONS.svelte, COMPONENT_EXTENSIONS.jsx]
|
|
10
10
|
.flat()
|
|
11
11
|
.concat(['.lite']);
|
|
12
|
-
|
|
13
|
-
return COMPONENT_EXTENSIONS.svelte.some(function (x) { return filePath.endsWith(x); });
|
|
14
|
-
};
|
|
12
|
+
const checkIsSvelteComponentFilePath = (filePath) => COMPONENT_EXTENSIONS.svelte.some((x) => filePath.endsWith(x));
|
|
15
13
|
exports.checkIsSvelteComponentFilePath = checkIsSvelteComponentFilePath;
|
|
16
|
-
|
|
17
|
-
return COMPONENT_EXTENSIONS.jsx.some(function (x) { return filePath.endsWith(x); });
|
|
18
|
-
};
|
|
14
|
+
const checkIsLiteComponentFilePath = (filePath) => COMPONENT_EXTENSIONS.jsx.some((x) => filePath.endsWith(x));
|
|
19
15
|
exports.checkIsLiteComponentFilePath = checkIsLiteComponentFilePath;
|
|
20
|
-
|
|
21
|
-
return (0, exports.checkIsLiteComponentFilePath)(filePath) || (0, exports.checkIsSvelteComponentFilePath)(filePath);
|
|
22
|
-
};
|
|
16
|
+
const checkIsMitosisComponentFilePath = (filePath) => (0, exports.checkIsLiteComponentFilePath)(filePath) || (0, exports.checkIsSvelteComponentFilePath)(filePath);
|
|
23
17
|
exports.checkIsMitosisComponentFilePath = checkIsMitosisComponentFilePath;
|
|
24
18
|
/**
|
|
25
19
|
* Matches `.svelte`, `.lite.tsx`, `.lite.jsx` files (with optional `.jsx`/`.tsx` extension)
|
|
26
20
|
*/
|
|
27
21
|
exports.INPUT_EXTENSION_REGEX = /\.(svelte|(lite(\.tsx|\.jsx)?))/g;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
isTypescript: (0, output_1.checkShouldOutputTypeScript)({ options: options, target: target }),
|
|
34
|
-
}));
|
|
35
|
-
};
|
|
22
|
+
const renameComponentFile = ({ path, target, options, }) => path.replace(exports.INPUT_EXTENSION_REGEX, (0, exports.getComponentFileExtensionForTarget)({
|
|
23
|
+
type: 'filename',
|
|
24
|
+
target,
|
|
25
|
+
isTypescript: (0, output_1.checkShouldOutputTypeScript)({ options, target }),
|
|
26
|
+
}));
|
|
36
27
|
exports.renameComponentFile = renameComponentFile;
|
|
37
28
|
/**
|
|
38
29
|
* just like `INPUT_EXTENSION_REGEX`, but adds trailing quotes to the end of import paths.
|
|
39
30
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return importPath.replace(INPUT_EXTENSION_IMPORT_REGEX, "".concat((0, exports.getComponentFileExtensionForTarget)({
|
|
31
|
+
const INPUT_EXTENSION_IMPORT_REGEX = /\.(svelte|(lite(\.tsx|\.jsx)?))(?<quote>['"])/g;
|
|
32
|
+
const renameComponentImport = ({ importPath, target, explicitImportFileExtension, }) => {
|
|
33
|
+
return importPath.replace(INPUT_EXTENSION_IMPORT_REGEX, `${(0, exports.getComponentFileExtensionForTarget)({
|
|
44
34
|
type: 'import',
|
|
45
|
-
target
|
|
46
|
-
explicitImportFileExtension
|
|
47
|
-
})
|
|
35
|
+
target,
|
|
36
|
+
explicitImportFileExtension,
|
|
37
|
+
})}$4`);
|
|
48
38
|
};
|
|
49
39
|
exports.renameComponentImport = renameComponentImport;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}), "$1"));
|
|
40
|
+
const renameImport = ({ importPath, target, explicitImportFileExtension, }) => {
|
|
41
|
+
return importPath.replace(/\.js(['"])/g, `${(0, exports.getFileExtensionForTarget)({
|
|
42
|
+
target,
|
|
43
|
+
explicitImportFileExtension,
|
|
44
|
+
})}$1`);
|
|
56
45
|
};
|
|
57
46
|
exports.renameImport = renameImport;
|
|
58
47
|
/**
|
|
@@ -60,7 +49,7 @@ exports.renameImport = renameImport;
|
|
|
60
49
|
* - in `core` to render import statements within other components.
|
|
61
50
|
* - in `cli` to render filenames for generated components, and import statements within plain `.js`/`.ts` files.
|
|
62
51
|
*/
|
|
63
|
-
|
|
52
|
+
const getComponentFileExtensionForTarget = (args) => {
|
|
64
53
|
switch (args.target) {
|
|
65
54
|
case 'angular': {
|
|
66
55
|
switch (args.type) {
|
|
@@ -111,8 +100,7 @@ var getComponentFileExtensionForTarget = function (args) {
|
|
|
111
100
|
}
|
|
112
101
|
};
|
|
113
102
|
exports.getComponentFileExtensionForTarget = getComponentFileExtensionForTarget;
|
|
114
|
-
|
|
115
|
-
var target = _a.target, explicitImportFileExtension = _a.explicitImportFileExtension;
|
|
103
|
+
const getFileExtensionForTarget = ({ target, explicitImportFileExtension, }) => {
|
|
116
104
|
switch (target) {
|
|
117
105
|
case 'angular':
|
|
118
106
|
case 'alpine':
|
|
@@ -1,31 +1,27 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
3
|
exports.createMitosisComponent = void 0;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
4
|
+
const createMitosisComponent = (options) => {
|
|
5
|
+
const { name, hooks, ...remainingOpts } = options || {};
|
|
6
|
+
const { onEvent = [], onMount = [], ...remainingHooks } = hooks || {};
|
|
7
|
+
return {
|
|
8
|
+
'@type': '@builder.io/mitosis/component',
|
|
9
|
+
imports: [],
|
|
10
|
+
exports: {},
|
|
11
|
+
inputs: [],
|
|
12
|
+
meta: {},
|
|
13
|
+
refs: {},
|
|
14
|
+
state: {},
|
|
15
|
+
children: [],
|
|
16
|
+
context: { get: {}, set: {} },
|
|
17
|
+
subComponents: [],
|
|
18
|
+
name: name || 'MyComponent',
|
|
19
|
+
hooks: {
|
|
20
|
+
onMount,
|
|
21
|
+
onEvent,
|
|
22
|
+
...remainingHooks,
|
|
23
|
+
},
|
|
24
|
+
...remainingOpts,
|
|
25
|
+
};
|
|
30
26
|
};
|
|
31
27
|
exports.createMitosisComponent = createMitosisComponent;
|
|
@@ -1,18 +1,11 @@
|
|
|
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.createMitosisContext = void 0;
|
|
15
4
|
function createMitosisContext(options) {
|
|
16
|
-
return
|
|
5
|
+
return {
|
|
6
|
+
'@type': '@builder.io/mitosis/context',
|
|
7
|
+
value: {},
|
|
8
|
+
...options,
|
|
9
|
+
};
|
|
17
10
|
}
|
|
18
11
|
exports.createMitosisContext = createMitosisContext;
|
|
@@ -1,16 +1,14 @@
|
|
|
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.createMitosisNode = void 0;
|
|
15
|
-
|
|
4
|
+
const createMitosisNode = (options) => ({
|
|
5
|
+
'@type': '@builder.io/mitosis/node',
|
|
6
|
+
name: 'div',
|
|
7
|
+
meta: {},
|
|
8
|
+
scope: {},
|
|
9
|
+
properties: {},
|
|
10
|
+
bindings: {},
|
|
11
|
+
children: [],
|
|
12
|
+
...options,
|
|
13
|
+
});
|
|
16
14
|
exports.createMitosisNode = createMitosisNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dashCase = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const dashCase = (string) => (0, lodash_1.kebabCase)(string);
|
|
6
6
|
exports.dashCase = dashCase;
|
|
@@ -8,15 +8,11 @@
|
|
|
8
8
|
// 2. Preserve whitespace inside backtick string literals
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.dedent = void 0;
|
|
11
|
-
function dedent(strings) {
|
|
12
|
-
|
|
13
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
14
|
-
values[_i - 1] = arguments[_i];
|
|
15
|
-
}
|
|
16
|
-
var raw = typeof strings === 'string' ? [strings] : strings.raw;
|
|
11
|
+
function dedent(strings, ...values) {
|
|
12
|
+
const raw = typeof strings === 'string' ? [strings] : strings.raw;
|
|
17
13
|
// first, perform interpolation
|
|
18
|
-
|
|
19
|
-
for (
|
|
14
|
+
let result = '';
|
|
15
|
+
for (let i = 0; i < raw.length; i++) {
|
|
20
16
|
result += raw[i]
|
|
21
17
|
// join lines when there is a suppressed newline
|
|
22
18
|
.replace(/\\\n[ \t]*/g, '')
|
|
@@ -27,12 +23,12 @@ function dedent(strings) {
|
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
// now strip indentation
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
lines.forEach(
|
|
33
|
-
|
|
26
|
+
const lines = split(result);
|
|
27
|
+
let mindent = null;
|
|
28
|
+
lines.forEach((l) => {
|
|
29
|
+
let m = l.match(/^(\s+)\S+/);
|
|
34
30
|
if (m) {
|
|
35
|
-
|
|
31
|
+
let indent = m[1].length;
|
|
36
32
|
if (!mindent) {
|
|
37
33
|
// this is the first indented line
|
|
38
34
|
mindent = indent;
|
|
@@ -43,13 +39,13 @@ function dedent(strings) {
|
|
|
43
39
|
}
|
|
44
40
|
});
|
|
45
41
|
if (mindent !== null) {
|
|
46
|
-
|
|
47
|
-
result = lines.map(
|
|
42
|
+
const m = mindent;
|
|
43
|
+
result = lines.map((l) => (l[0] === ' ' ? l.slice(m) : l)).join('\n');
|
|
48
44
|
}
|
|
49
45
|
// trim trailing whitespace on all lines
|
|
50
46
|
result = result
|
|
51
47
|
.split('\n')
|
|
52
|
-
.map(
|
|
48
|
+
.map((l) => l.trimEnd())
|
|
53
49
|
.join('\n');
|
|
54
50
|
return (result
|
|
55
51
|
// dedent eats leading and trailing whitespace too
|
|
@@ -65,12 +61,12 @@ exports.dedent = dedent;
|
|
|
65
61
|
* @returns The split string.
|
|
66
62
|
*/
|
|
67
63
|
function split(input) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
for (
|
|
73
|
-
|
|
64
|
+
const result = [];
|
|
65
|
+
let prev = '';
|
|
66
|
+
let current = '';
|
|
67
|
+
let inBackticks = false;
|
|
68
|
+
for (let i = 0; i < input.length; i++) {
|
|
69
|
+
const char = input[i];
|
|
74
70
|
if (prev !== '\\' && char === '`') {
|
|
75
71
|
inBackticks = !inBackticks;
|
|
76
72
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkIsBindingEventHandler = void 0;
|
|
4
|
-
|
|
4
|
+
const checkIsBindingEventHandler = (code) => code.startsWith('on');
|
|
5
5
|
exports.checkIsBindingEventHandler = checkIsBindingEventHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fastClone = void 0;
|
|
4
|
-
|
|
4
|
+
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
5
5
|
exports.fastClone = fastClone;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.filterEmptyTextNodes = exports.isEmptyTextNode = void 0;
|
|
4
|
-
|
|
4
|
+
const isEmptyTextNode = (node) => {
|
|
5
5
|
return typeof node.properties._text === 'string' && node.properties._text.trim().length === 0;
|
|
6
6
|
};
|
|
7
7
|
exports.isEmptyTextNode = isEmptyTextNode;
|
|
8
|
-
|
|
8
|
+
const filterEmptyTextNodes = (node) => !(0, exports.isEmptyTextNode)(node);
|
|
9
9
|
exports.filterEmptyTextNodes = filterEmptyTextNodes;
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.format = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const preSpaceRegex = /^\s*/g;
|
|
5
|
+
const DEFAULT_INDENT_SPACES = 2;
|
|
6
6
|
/**
|
|
7
7
|
* Generic formatter for languages prettier doesn't support, like Swift
|
|
8
8
|
*
|
|
9
9
|
* Not super sophisticated, but much better than nothing
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
lines.forEach(function (item, index) {
|
|
11
|
+
const format = (str, indentSpaces = DEFAULT_INDENT_SPACES) => {
|
|
12
|
+
let currentIndent = 0;
|
|
13
|
+
const lines = str.split('\n');
|
|
14
|
+
lines.forEach((item, index) => {
|
|
16
15
|
item = item.trimEnd();
|
|
17
16
|
if (!item) {
|
|
18
17
|
lines[index] = '';
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
lines[index] = item.replace(preSpaceRegex, ' '.repeat(currentIndent * indentSpaces));
|
|
22
|
-
|
|
21
|
+
const nextLine = lines[index + 1];
|
|
23
22
|
if (!nextLine) {
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBindingsCode = void 0;
|
|
4
4
|
function getBindingsCode(children) {
|
|
5
|
-
|
|
6
|
-
children.forEach(
|
|
7
|
-
Object.values(child.bindings || []).forEach(
|
|
5
|
+
const bindings = [];
|
|
6
|
+
children.forEach((child) => {
|
|
7
|
+
Object.values(child.bindings || []).forEach((binding) => {
|
|
8
8
|
bindings.push(binding.code);
|
|
9
9
|
});
|
|
10
10
|
if (child.children) {
|
|
11
|
-
bindings.push
|
|
11
|
+
bindings.push(...getBindingsCode(child.children));
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
return bindings;
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getComponentsUsed = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
9
|
function getComponentsUsed(json) {
|
|
10
|
-
|
|
10
|
+
const components = new Set();
|
|
11
11
|
(0, legacy_1.default)(json).forEach(function (item) {
|
|
12
12
|
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
13
13
|
components.add(item.name);
|
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getComponents = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
|
+
const is_upper_case_1 = require("./is-upper-case");
|
|
10
10
|
function getComponents(json) {
|
|
11
|
-
|
|
11
|
+
const components = new Set();
|
|
12
12
|
(0, legacy_1.default)(json).forEach(function (item) {
|
|
13
13
|
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
14
14
|
if ((0, is_upper_case_1.isUpperCase)(item.name[0])) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCustomImports = void 0;
|
|
4
|
-
|
|
4
|
+
const is_upper_case_1 = require("./is-upper-case");
|
|
5
5
|
/**
|
|
6
6
|
* Return custom imports of basic values (aka things
|
|
7
7
|
* that are not ClassCase like components and types)
|
|
@@ -16,16 +16,14 @@ var is_upper_case_1 = require("./is-upper-case");
|
|
|
16
16
|
* by the template
|
|
17
17
|
*/
|
|
18
18
|
function getCustomImports(json) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.map(
|
|
22
|
-
return Object.keys(item.imports).filter(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
item.toUpperCase() === item);
|
|
28
|
-
});
|
|
19
|
+
const blocksString = JSON.stringify(json.children);
|
|
20
|
+
const customImports = json.imports
|
|
21
|
+
.map((item) => {
|
|
22
|
+
return Object.keys(item.imports).filter((item) => item &&
|
|
23
|
+
// this ignores component imports, which are CamelCased.
|
|
24
|
+
(!(0, is_upper_case_1.isUpperCase)(item[0]) ||
|
|
25
|
+
// this includes constants which are typically CAPITALIZED.
|
|
26
|
+
item.toUpperCase() === item));
|
|
29
27
|
})
|
|
30
28
|
.flat()
|
|
31
29
|
// This is imperfect. Basically, if the string of this import name
|
|
@@ -34,7 +32,7 @@ function getCustomImports(json) {
|
|
|
34
32
|
// to templates. Arguably "good enough" for now, as there is generally no
|
|
35
33
|
// consequence to over adding here, and it would be a lot more performance expensive
|
|
36
34
|
// during compilation to do a complete AST parse and look for real references
|
|
37
|
-
.filter(
|
|
35
|
+
.filter((item) => blocksString.includes(item));
|
|
38
36
|
return customImports;
|
|
39
37
|
}
|
|
40
38
|
exports.getCustomImports = getCustomImports;
|
|
@@ -4,21 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getPropFunctions = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const propsRegex = /props\s*\.\s*([a-zA-Z0-9_\x04]+)\(/;
|
|
9
|
+
const allPropsMatchesRegex = new RegExp(propsRegex, 'g');
|
|
10
10
|
/**
|
|
11
11
|
* Get props used in the components by reference
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const getPropFunctions = (json) => {
|
|
14
|
+
const props = [];
|
|
15
15
|
(0, legacy_1.default)(json).forEach(function (item) {
|
|
16
16
|
if (typeof item === 'string') {
|
|
17
17
|
// TODO: proper babel ref matching
|
|
18
|
-
|
|
18
|
+
const matches = item.match(allPropsMatchesRegex);
|
|
19
19
|
if (matches) {
|
|
20
|
-
for (
|
|
21
|
-
var match = matches_1[_i];
|
|
20
|
+
for (const match of matches) {
|
|
22
21
|
props.push(match.match(propsRegex)[1]);
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -4,18 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getPropsRef = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
9
|
function getPropsRef(json, shouldRemove) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
let has = false;
|
|
11
|
+
let prop = '';
|
|
12
12
|
(0, legacy_1.default)(json).forEach(function (item) {
|
|
13
13
|
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const binding = item.bindings.ref;
|
|
15
|
+
const regexp = /(.+)?props\.(.+)( |\)|;|\()?$/;
|
|
16
16
|
if (binding && regexp.test(binding.code)) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const match = regexp.exec(binding.code);
|
|
18
|
+
const _prop = match === null || match === void 0 ? void 0 : match[2];
|
|
19
19
|
if (_prop) {
|
|
20
20
|
prop = _prop;
|
|
21
21
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getProps = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const process_code_1 = require("./plugins/process-code");
|
|
5
|
+
const propsRegex = /props\s*\.\s*([a-zA-Z0-9_\$]+)/;
|
|
6
|
+
const allPropsMatchesRegex = new RegExp(propsRegex, 'g');
|
|
7
7
|
// copied from https://github.com/vuejs/core/blob/fa6556a0d56eeff1fec4f948460351ccf8f99f35/packages/compiler-core/src/validateExpression.ts
|
|
8
8
|
// typeof, instanceof and in are allowed
|
|
9
|
-
|
|
9
|
+
const prohibitedKeywordRE = new RegExp('\\b' +
|
|
10
10
|
('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
|
|
11
11
|
'super,throw,while,yield,delete,export,import,return,switch,default,' +
|
|
12
12
|
'extends,finally,continue,debugger,function,arguments,typeof,void,' +
|
|
@@ -21,22 +21,21 @@ var prohibitedKeywordRE = new RegExp('\\b' +
|
|
|
21
21
|
/**
|
|
22
22
|
* Get props used in the components by reference
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(0, process_code_1.createCodeProcessorPlugin)(
|
|
27
|
-
|
|
24
|
+
const getProps = (json) => {
|
|
25
|
+
const props = new Set();
|
|
26
|
+
(0, process_code_1.createCodeProcessorPlugin)(() => (code) => {
|
|
27
|
+
const matches = code.match(allPropsMatchesRegex);
|
|
28
28
|
if (matches) {
|
|
29
|
-
for (
|
|
30
|
-
|
|
31
|
-
var prop = match.match(propsRegex)[1];
|
|
29
|
+
for (const match of matches) {
|
|
30
|
+
const prop = match.match(propsRegex)[1];
|
|
32
31
|
if (prop.match(prohibitedKeywordRE)) {
|
|
33
|
-
throw new Error(
|
|
32
|
+
throw new Error(`avoid using JavaScript keyword as property name: "${prop}"`);
|
|
34
33
|
}
|
|
35
34
|
props.add(prop);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
return code;
|
|
39
|
-
}
|
|
38
|
+
})(json);
|
|
40
39
|
return props;
|
|
41
40
|
};
|
|
42
41
|
exports.getProps = getProps;
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getRefs = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
|
+
const getRefs = (json) => {
|
|
10
|
+
const refs = new Set();
|
|
11
11
|
(0, legacy_1.default)(json).forEach(function (item) {
|
|
12
12
|
var _a;
|
|
13
13
|
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|