@builder.io/mitosis 0.0.56-77 → 0.0.56-78
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/react.d.ts +1 -1
- package/dist/src/generators/react.js +14 -3
- package/dist/src/parsers/jsx/component-types.d.ts +0 -1
- package/dist/src/parsers/jsx/component-types.js +1 -5
- package/dist/src/parsers/jsx/jsx.js +0 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseTranspilerOptions, Transpiler } from '../types/transpiler';
|
|
2
2
|
import { MitosisNode } from '../types/mitosis-node';
|
|
3
3
|
export interface ToReactOptions extends BaseTranspilerOptions {
|
|
4
|
-
stylesType?: 'emotion' | 'styled-components' | 'styled-jsx' | 'react-native';
|
|
4
|
+
stylesType?: 'emotion' | 'styled-components' | 'styled-jsx' | 'react-native' | 'style-tag';
|
|
5
5
|
stateType?: 'useState' | 'mobx' | 'valtio' | 'solid' | 'builder';
|
|
6
6
|
format?: 'lite' | 'safe';
|
|
7
7
|
type?: 'dom' | 'native';
|
|
@@ -55,6 +55,7 @@ var collect_styled_components_1 = require("../helpers/styles/collect-styled-comp
|
|
|
55
55
|
var helpers_1 = require("../helpers/styles/helpers");
|
|
56
56
|
var slots_1 = require("../helpers/slots");
|
|
57
57
|
var state_1 = require("../helpers/state");
|
|
58
|
+
var hash_sum_1 = __importDefault(require("hash-sum"));
|
|
58
59
|
var openFrag = function (options) { return getFragment('open', options); };
|
|
59
60
|
var closeFrag = function (options) { return getFragment('close', options); };
|
|
60
61
|
function getFragment(type, options) {
|
|
@@ -463,7 +464,13 @@ var _componentToReact = function (json, options, isSubComponent) {
|
|
|
463
464
|
if (options.plugins) {
|
|
464
465
|
json = (0, plugins_1.runPostJsonPlugins)(json, options.plugins);
|
|
465
466
|
}
|
|
466
|
-
var css = stylesType === 'styled-jsx'
|
|
467
|
+
var css = stylesType === 'styled-jsx'
|
|
468
|
+
? (0, collect_css_1.collectCss)(json)
|
|
469
|
+
: stylesType === 'style-tag'
|
|
470
|
+
? (0, collect_css_1.collectCss)(json, {
|
|
471
|
+
prefix: (0, hash_sum_1.default)(json),
|
|
472
|
+
})
|
|
473
|
+
: null;
|
|
467
474
|
var styledComponentsCode = stylesType === 'styled-components' && componentHasStyles && (0, collect_styled_components_1.collectStyledComponents)(json);
|
|
468
475
|
if (options.format !== 'lite') {
|
|
469
476
|
(0, strip_meta_properties_1.stripMetaProperties)(json);
|
|
@@ -488,7 +495,7 @@ var _componentToReact = function (json, options, isSubComponent) {
|
|
|
488
495
|
reactLibImports.add('useEffect');
|
|
489
496
|
}
|
|
490
497
|
var wrap = wrapInFragment(json) ||
|
|
491
|
-
(componentHasStyles && stylesType === 'styled-jsx') ||
|
|
498
|
+
(componentHasStyles && (stylesType === 'styled-jsx' || stylesType === 'style-tag')) ||
|
|
492
499
|
isRootSpecialNode(json);
|
|
493
500
|
var _p = getRefsString(json, allRefs, options), hasStateArgument = _p[0], refsString = _p[1];
|
|
494
501
|
var nativeStyles = stylesType === 'react-native' && componentHasStyles && (0, react_native_1.collectReactNativeStyles)(json);
|
|
@@ -522,7 +529,11 @@ var _componentToReact = function (json, options, isSubComponent) {
|
|
|
522
529
|
? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onMount.code, options), options), "\n }, [])")
|
|
523
530
|
: '', (_l = (_k = json.hooks.onUpdate) === null || _k === void 0 ? void 0 : _k.map(function (hook) { return "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(hook.code, options), options), "\n }, \n ").concat(hook.deps ? processBinding(updateStateSettersInCode(hook.deps, options), options) : '', ")"); }).join(';')) !== null && _l !== void 0 ? _l : '', ((_m = json.hooks.onUnMount) === null || _m === void 0 ? void 0 : _m.code)
|
|
524
531
|
? "useEffect(() => {\n return () => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onUnMount.code, options), options), "\n }\n }, [])")
|
|
525
|
-
: '', wrap ? openFrag(options) : '', json.children.map(function (item) { return (0, exports.blockToReact)(item, options); }).join('\n'), componentHasStyles && stylesType === 'styled-jsx'
|
|
532
|
+
: '', wrap ? openFrag(options) : '', json.children.map(function (item) { return (0, exports.blockToReact)(item, options); }).join('\n'), componentHasStyles && stylesType === 'styled-jsx'
|
|
533
|
+
? "<style jsx>{`".concat(css, "`}</style>")
|
|
534
|
+
: componentHasStyles && stylesType === 'style-tag'
|
|
535
|
+
? "<style>{`".concat(css, "`}</style>")
|
|
536
|
+
: '', wrap ? closeFrag(options) : '', isForwardRef ? ')' : '', !nativeStyles
|
|
526
537
|
? ''
|
|
527
538
|
: "\n const styles = StyleSheet.create(".concat(json5_1.default.stringify(nativeStyles), ");\n "), styledComponentsCode ? styledComponentsCode : '');
|
|
528
539
|
str = (0, replace_new_lines_in_strings_1.stripNewlinesInStrings)(str);
|
|
@@ -2,7 +2,6 @@ import * as babel from '@babel/core';
|
|
|
2
2
|
import { Context } from './types';
|
|
3
3
|
export declare const getPropsTypeRef: (node: babel.types.FunctionDeclaration, context: Context) => string | undefined;
|
|
4
4
|
export declare const isTypeImport: (node: babel.Node) => boolean;
|
|
5
|
-
export declare const isTypeExport: (node: babel.Node) => boolean;
|
|
6
5
|
export declare const isTypeOrInterface: (node: babel.Node) => boolean;
|
|
7
6
|
export declare const collectTypes: (node: babel.Node, context: Context) => void;
|
|
8
7
|
export declare const collectInterfaces: (node: babel.Node, context: Context) => void;
|
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.collectInterfaces = exports.collectTypes = exports.isTypeOrInterface = exports.
|
|
38
|
+
exports.collectInterfaces = exports.collectTypes = exports.isTypeOrInterface = exports.isTypeImport = exports.getPropsTypeRef = void 0;
|
|
39
39
|
var babel = __importStar(require("@babel/core"));
|
|
40
40
|
var generator_1 = __importDefault(require("@babel/generator"));
|
|
41
41
|
var types = babel.types;
|
|
@@ -72,10 +72,6 @@ var isTypeImport = function (node) {
|
|
|
72
72
|
((_a = node.specifiers[0]) === null || _a === void 0 ? void 0 : _a.local.name) !== 'JSX';
|
|
73
73
|
};
|
|
74
74
|
exports.isTypeImport = isTypeImport;
|
|
75
|
-
var isTypeExport = function (node) {
|
|
76
|
-
return types.isExportDeclaration(node) && node.exportKind === 'type';
|
|
77
|
-
};
|
|
78
|
-
exports.isTypeExport = isTypeExport;
|
|
79
75
|
var isTypeOrInterface = function (node) {
|
|
80
76
|
return types.isTSTypeAliasDeclaration(node) ||
|
|
81
77
|
types.isTSInterfaceDeclaration(node) ||
|
|
@@ -517,9 +517,6 @@ function parseJsx(jsx, options) {
|
|
|
517
517
|
}
|
|
518
518
|
(0, component_types_1.collectTypes)(statement, context);
|
|
519
519
|
}
|
|
520
|
-
if ((0, component_types_1.isTypeExport)(statement)) {
|
|
521
|
-
(0, component_types_1.collectTypes)(statement, context);
|
|
522
|
-
}
|
|
523
520
|
}
|
|
524
521
|
var exportsOrLocalVariables = path.node.body.filter(function (statement) {
|
|
525
522
|
return !isImportOrDefaultExport(statement) &&
|