@builder.io/mitosis 0.1.1 → 0.1.3
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/helpers/component-file-extensions.d.ts +1 -1
- package/dist/src/helpers/component-file-extensions.js +2 -2
- package/dist/src/parsers/builder/builder.d.ts +1 -1
- package/dist/src/parsers/builder/builder.js +4 -3
- package/dist/src/parsers/jsx/hooks/use-target.js +24 -2
- package/dist/src/parsers/jsx/state.js +7 -7
- package/dist/src/plugins/compile-away-builder-components.js +4 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MitosisConfig, Target } from '
|
|
1
|
+
import { MitosisConfig, Target } from '../types/config';
|
|
2
2
|
export declare const COMPONENT_IMPORT_EXTENSIONS: string[];
|
|
3
3
|
export declare const checkIsSvelteComponentFilePath: (filePath: string) => boolean;
|
|
4
4
|
export declare const checkIsLiteComponentFilePath: (filePath: string) => boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getComponentFileExtensionForTarget = exports.renameImport = exports.renameComponentFile = exports.INPUT_EXTENSION_REGEX = exports.checkIsMitosisComponentFilePath = exports.checkIsLiteComponentFilePath = exports.checkIsSvelteComponentFilePath = exports.COMPONENT_IMPORT_EXTENSIONS = void 0;
|
|
4
|
-
var
|
|
4
|
+
var output_1 = require("./output");
|
|
5
5
|
var COMPONENT_EXTENSIONS = {
|
|
6
6
|
jsx: ['.lite.tsx', '.lite.jsx'],
|
|
7
7
|
svelte: ['.svelte'],
|
|
@@ -30,7 +30,7 @@ var renameComponentFile = function (_a) {
|
|
|
30
30
|
return path.replace(exports.INPUT_EXTENSION_REGEX, (0, exports.getComponentFileExtensionForTarget)({
|
|
31
31
|
type: 'filename',
|
|
32
32
|
target: target,
|
|
33
|
-
isTypescript: (0,
|
|
33
|
+
isTypescript: (0, output_1.checkShouldOutputTypeScript)({ options: options, target: target }),
|
|
34
34
|
}));
|
|
35
35
|
};
|
|
36
36
|
exports.renameComponentFile = renameComponentFile;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { MitosisComponent, MitosisState } from '../../types/mitosis-component';
|
|
1
2
|
import { BuilderContent, BuilderElement } from '@builder.io/sdk';
|
|
2
|
-
import { MitosisComponent, MitosisState } from '../..';
|
|
3
3
|
import { MitosisNode } from '../../types/mitosis-node';
|
|
4
4
|
type InternalOptions = {
|
|
5
5
|
skipMapper?: boolean;
|
|
@@ -47,12 +47,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
47
|
};
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.builderContentToMitosisComponent = exports.isBuilderElement = exports.createBuilderElement = exports.convertExportDefaultToReturn = exports.extractStateHook = exports.builderElementToMitosisNode = exports.symbolBlocksAsChildren = void 0;
|
|
50
|
+
var mitosis_1 = require("../../generators/mitosis");
|
|
51
|
+
var symbol_processor_1 = require("../../symbols/symbol-processor");
|
|
50
52
|
var babel = __importStar(require("@babel/core"));
|
|
51
53
|
var generator_1 = __importDefault(require("@babel/generator"));
|
|
52
54
|
var json5_1 = __importDefault(require("json5"));
|
|
53
55
|
var lodash_1 = require("lodash");
|
|
54
56
|
var traverse_1 = __importDefault(require("traverse"));
|
|
55
|
-
var __1 = require("../..");
|
|
56
57
|
var media_sizes_1 = require("../../constants/media-sizes");
|
|
57
58
|
var bindings_1 = require("../../helpers/bindings");
|
|
58
59
|
var capitalize_1 = require("../../helpers/capitalize");
|
|
@@ -532,7 +533,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
|
|
|
532
533
|
// For now, stringify to Mitosis nodes even though that only really works in React, due to syntax overlap.
|
|
533
534
|
// the correct long term solution is to hold on to the Mitosis Node, and have a plugin for each framework
|
|
534
535
|
// which processes any Mitosis nodes set into the attribute and moves them as slots when relevant (Svelte/Vue)
|
|
535
|
-
return (0,
|
|
536
|
+
return (0, mitosis_1.blockToMitosis)(node, {}, null);
|
|
536
537
|
};
|
|
537
538
|
if ((0, exports.isBuilderElement)(value)) {
|
|
538
539
|
bindings[key] = (0, bindings_1.createSingleBinding)({ code: transformBldrElementToBinding(value) });
|
|
@@ -751,7 +752,7 @@ function extractSymbols(json) {
|
|
|
751
752
|
subComponents: subComponents,
|
|
752
753
|
};
|
|
753
754
|
}
|
|
754
|
-
var createBuilderElement = function (options) { return (__assign({ '@type': '@builder.io/sdk:Element', id: 'builder-' + (0,
|
|
755
|
+
var createBuilderElement = function (options) { return (__assign({ '@type': '@builder.io/sdk:Element', id: 'builder-' + (0, symbol_processor_1.hashCodeAsString)(options) }, options)); };
|
|
755
756
|
exports.createBuilderElement = createBuilderElement;
|
|
756
757
|
var isBuilderElement = function (el) {
|
|
757
758
|
return (el === null || el === void 0 ? void 0 : el['@type']) === '@builder.io/sdk:Element';
|
|
@@ -29,7 +29,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.getUseTargetStatements = exports.getIdFromMatch = exports.USE_TARGET_MAGIC_REGEX = exports.USE_TARGET_MAGIC_STRING = exports.getMagicString = exports.getTargetId = void 0;
|
|
30
30
|
var babel = __importStar(require("@babel/core"));
|
|
31
31
|
var generator_1 = __importDefault(require("@babel/generator"));
|
|
32
|
-
var
|
|
32
|
+
var TARGETS = {
|
|
33
|
+
alpine: null,
|
|
34
|
+
angular: null,
|
|
35
|
+
customElement: null,
|
|
36
|
+
html: null,
|
|
37
|
+
mitosis: null,
|
|
38
|
+
liquid: null,
|
|
39
|
+
react: null,
|
|
40
|
+
reactNative: null,
|
|
41
|
+
solid: null,
|
|
42
|
+
svelte: null,
|
|
43
|
+
swift: null,
|
|
44
|
+
template: null,
|
|
45
|
+
webcomponent: null,
|
|
46
|
+
vue: null,
|
|
47
|
+
stencil: null,
|
|
48
|
+
qwik: null,
|
|
49
|
+
marko: null,
|
|
50
|
+
preact: null,
|
|
51
|
+
lit: null,
|
|
52
|
+
rsc: null,
|
|
53
|
+
taro: null,
|
|
54
|
+
};
|
|
33
55
|
var types = babel.types;
|
|
34
56
|
var getTargetId = function (component) {
|
|
35
57
|
var latestId = Object.keys(component.targetBlocks || {}).length;
|
|
@@ -76,7 +98,7 @@ var getUseTargetStatements = function (path) {
|
|
|
76
98
|
if (!types.isIdentifier(prop.key)) {
|
|
77
99
|
throw new Error('ERROR Parsing `useTarget()`: Expected an identifier, instead got: ' + prop.key);
|
|
78
100
|
}
|
|
79
|
-
if (!Object.keys(
|
|
101
|
+
if (!Object.keys(TARGETS).concat('default').includes(prop.key.name)) {
|
|
80
102
|
throw new Error('ERROR Parsing `useTarget()`: Invalid target: ' + prop.key.name);
|
|
81
103
|
}
|
|
82
104
|
var keyName = prop.key.name;
|
|
@@ -39,7 +39,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.parseStateObjectToMitosisState = exports.mapStateIdentifiers = void 0;
|
|
41
41
|
var babel = __importStar(require("@babel/core"));
|
|
42
|
-
var generator_1 = __importDefault(require("@babel/generator"));
|
|
43
42
|
var function_1 = require("fp-ts/lib/function");
|
|
44
43
|
var traverse_1 = __importDefault(require("traverse"));
|
|
45
44
|
var babel_transform_1 = require("../../helpers/babel-transform");
|
|
@@ -79,12 +78,13 @@ function mapStateIdentifiersInExpression(expression, stateProperties) {
|
|
|
79
78
|
path.replaceWith(newExpression);
|
|
80
79
|
}
|
|
81
80
|
catch (err) {
|
|
82
|
-
console.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
console.error(err);
|
|
82
|
+
// console.log('err: ', {
|
|
83
|
+
// from: generate(path.parent).code,
|
|
84
|
+
// fromChild: generate(path.node).code,
|
|
85
|
+
// to: newExpression,
|
|
86
|
+
// // err,
|
|
87
|
+
// });
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -256,8 +256,8 @@ exports.components = {
|
|
|
256
256
|
}), components);
|
|
257
257
|
},
|
|
258
258
|
Image: function (node, context, components) {
|
|
259
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
260
|
-
var
|
|
259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
260
|
+
var _k = node.properties, backgroundSize = _k.backgroundSize, backgroundPosition = _k.backgroundPosition;
|
|
261
261
|
var srcset = node.properties.srcset;
|
|
262
262
|
var aspectRatio = ((_a = node.bindings.aspectRatio) === null || _a === void 0 ? void 0 : _a.code)
|
|
263
263
|
? parseFloat(node.bindings.aspectRatio.code)
|
|
@@ -281,12 +281,13 @@ exports.components = {
|
|
|
281
281
|
bindings: noUndefined({
|
|
282
282
|
src: ((_c = node.bindings.image) === null || _c === void 0 ? void 0 : _c.code) && { code: (_d = node.bindings.image) === null || _d === void 0 ? void 0 : _d.code },
|
|
283
283
|
sizes: ((_e = node.bindings.sizes) === null || _e === void 0 ? void 0 : _e.code) && { code: (_f = node.bindings.sizes) === null || _f === void 0 ? void 0 : _f.code },
|
|
284
|
+
style: ((_g = node.bindings.style) === null || _g === void 0 ? void 0 : _g.code) && { code: (_h = node.bindings.style) === null || _h === void 0 ? void 0 : _h.code },
|
|
284
285
|
css: (0, bindings_1.createSingleBinding)({
|
|
285
286
|
code: JSON.stringify(__assign(__assign({ aspectRatio: aspectRatio ? String((0, lodash_1.round)(1 / aspectRatio, 2)) : undefined, objectFit: backgroundSize || 'cover', objectPosition: backgroundPosition || 'center', width: '100%' }, css), { display: undefined, flexDirection: undefined, position: css.position === 'relative' ? undefined : css.position })),
|
|
286
287
|
}),
|
|
287
288
|
}),
|
|
288
289
|
});
|
|
289
|
-
if (!((
|
|
290
|
+
if (!((_j = node.children) === null || _j === void 0 ? void 0 : _j.length)) {
|
|
290
291
|
return img;
|
|
291
292
|
}
|
|
292
293
|
// TODO: deal with links: anchor tag and href
|