@builder.io/mitosis 0.7.3 → 0.7.5
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/generators/angular/blocks.js +2 -1
- package/dist/src/generators/mitosis/generator.js +15 -0
- package/dist/src/generators/stencil/helpers/index.js +1 -1
- package/dist/src/generators/vue/vue.js +3 -0
- package/dist/src/helpers/apply-meta-tagname.d.ts +2 -0
- package/dist/src/helpers/apply-meta-tagname.js +20 -0
- package/dist/src/helpers/get-tag-name.d.ts +2 -0
- package/dist/src/helpers/get-tag-name.js +7 -0
- package/dist/src/plugins/compile-away-builder-components.js +2 -1
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ const hooks_1 = require("../../generators/angular/helpers/hooks");
|
|
|
10
10
|
const parse_selector_1 = require("../../generators/angular/parse-selector");
|
|
11
11
|
const bindings_1 = require("../../helpers/bindings");
|
|
12
12
|
const event_handlers_1 = require("../../helpers/event-handlers");
|
|
13
|
+
const get_tag_name_1 = require("../../helpers/get-tag-name");
|
|
13
14
|
const is_children_1 = __importDefault(require("../../helpers/is-children"));
|
|
14
15
|
const is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
|
|
15
16
|
const remove_surrounding_block_1 = require("../../helpers/remove-surrounding-block");
|
|
@@ -299,7 +300,7 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
299
300
|
else {
|
|
300
301
|
let element = null, classNames = [], attributes;
|
|
301
302
|
const isComponent = childComponents.find((impName) => impName === json.name);
|
|
302
|
-
const tagName = json
|
|
303
|
+
const tagName = (0, get_tag_name_1.getBuilderTagName)(json);
|
|
303
304
|
const selector = json.meta.selector || (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.selector);
|
|
304
305
|
if (selector) {
|
|
305
306
|
try {
|
|
@@ -52,6 +52,13 @@ exports.DEFAULT_FORMAT = 'legacy';
|
|
|
52
52
|
const isValidAttributeName = (str) => {
|
|
53
53
|
return Boolean(str && /^[$a-z0-9\-_:]+$/i.test(str));
|
|
54
54
|
};
|
|
55
|
+
const isInvalidJsxAttributeName = (str) => {
|
|
56
|
+
let attr = str.trim();
|
|
57
|
+
if (attr.startsWith(':') || str.startsWith('@')) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
55
62
|
const blockToMitosis = (json, toMitosisOptions = {}, component, insideJsx) => {
|
|
56
63
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
57
64
|
const options = {
|
|
@@ -154,6 +161,10 @@ const blockToMitosis = (json, toMitosisOptions = {}, component, insideJsx) => {
|
|
|
154
161
|
let str = '';
|
|
155
162
|
str += `<${json.name} `;
|
|
156
163
|
for (const key in json.properties) {
|
|
164
|
+
if (isInvalidJsxAttributeName(key)) {
|
|
165
|
+
console.warn('Skipping invalid attribute name:', key);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
157
168
|
const value = (json.properties[key] || '').replace(/"/g, '"').replace(/\n/g, '\\n');
|
|
158
169
|
if (!isValidAttributeName(key)) {
|
|
159
170
|
console.warn('Skipping invalid attribute name:', key);
|
|
@@ -163,6 +174,10 @@ const blockToMitosis = (json, toMitosisOptions = {}, component, insideJsx) => {
|
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
176
|
for (const key in json.bindings) {
|
|
177
|
+
if (isInvalidJsxAttributeName(key)) {
|
|
178
|
+
console.warn('Skipping invalid attribute name:', key);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
166
181
|
const value = (_e = json.bindings[key]) === null || _e === void 0 ? void 0 : _e.code;
|
|
167
182
|
if (!value || ((_f = json.slots) === null || _f === void 0 ? void 0 : _f[key])) {
|
|
168
183
|
continue;
|
|
@@ -65,7 +65,7 @@ const getPropsAsCode = ({ props, propOptions, defaultProps, json, }) => {
|
|
|
65
65
|
// Stencil adds "on" to every `@Event` so we need to remove "on" from event props
|
|
66
66
|
// https://stenciljs.com/docs/events#using-events-in-jsx
|
|
67
67
|
const eventType = hasTyping
|
|
68
|
-
? `EventEmitter<
|
|
68
|
+
? `EventEmitter<Parameters<Required<${propsTypeRef}>["${item}"]>[number]> | void`
|
|
69
69
|
: 'any';
|
|
70
70
|
return `@Event() ${(0, event_handlers_1.getEventNameWithoutOn)(item)}: ${eventType}${defaultPropString}`;
|
|
71
71
|
}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.componentToVue = void 0;
|
|
7
|
+
const apply_meta_tagname_1 = require("../../helpers/apply-meta-tagname");
|
|
7
8
|
const babel_transform_1 = require("../../helpers/babel-transform");
|
|
8
9
|
const bindings_1 = require("../../helpers/bindings");
|
|
9
10
|
const dedent_1 = require("../../helpers/dedent");
|
|
@@ -165,6 +166,8 @@ const componentToVue = (userOptions) => ({ component: _component, path }) => {
|
|
|
165
166
|
const css = (0, collect_css_1.collectCss)(component, {
|
|
166
167
|
prefix: (_b = (_a = options.cssNamespace) === null || _a === void 0 ? void 0 : _a.call(options)) !== null && _b !== void 0 ? _b : undefined,
|
|
167
168
|
});
|
|
169
|
+
// Apply the meta tagName to the component BEFORE we strip the meta properties
|
|
170
|
+
(0, apply_meta_tagname_1.applyMetaTagName)(component);
|
|
168
171
|
(0, strip_meta_properties_1.stripMetaProperties)(component);
|
|
169
172
|
const templateStrBody = component.children
|
|
170
173
|
.map((item) => (0, blocks_1.blockToVue)(item, options, { isRootNode: true }))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.applyMetaTagName = void 0;
|
|
7
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
8
|
+
const is_mitosis_node_1 = require("./is-mitosis-node");
|
|
9
|
+
const applyMetaTagName = (json) => {
|
|
10
|
+
(0, legacy_1.default)(json).forEach((item) => {
|
|
11
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
12
|
+
if (item.properties.$tagName) {
|
|
13
|
+
item.name = item.properties.$tagName;
|
|
14
|
+
delete item.properties.$tagName;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return json;
|
|
19
|
+
};
|
|
20
|
+
exports.applyMetaTagName = applyMetaTagName;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.compileAwayBuilderComponents = exports.compileAwayBuilderComponentsFromTree = exports.components = void 0;
|
|
7
|
+
const get_tag_name_1 = require("../helpers/get-tag-name");
|
|
7
8
|
const sdk_1 = require("@builder.io/sdk");
|
|
8
9
|
const json5_1 = __importDefault(require("json5"));
|
|
9
10
|
const lodash_1 = require("lodash");
|
|
@@ -38,7 +39,7 @@ const wrapOutput = (node, child, components) => {
|
|
|
38
39
|
...(0, lodash_1.omit)(node.bindings, ...inputNames),
|
|
39
40
|
},
|
|
40
41
|
// TODO: forward tagName as a $tagName="..."
|
|
41
|
-
name: node.properties._tagName || node
|
|
42
|
+
name: node.properties._tagName || (0, get_tag_name_1.getBuilderTagName)(node) || 'div',
|
|
42
43
|
children: Array.isArray(child) ? child : [child],
|
|
43
44
|
});
|
|
44
45
|
};
|