@builder.io/mitosis 0.0.93 → 0.0.95
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/builder.js +0 -1
- package/dist/src/generators/context/qwik.js +1 -1
- package/dist/src/generators/mitosis.js +2 -1
- package/dist/src/generators/qwik/component-generator.js +80 -163
- package/dist/src/generators/qwik/component.js +3 -3
- package/dist/src/generators/qwik/{add-prevent-default.d.ts → helpers/add-prevent-default.d.ts} +1 -1
- package/dist/src/generators/qwik/{add-prevent-default.js → helpers/add-prevent-default.js} +1 -1
- package/dist/src/generators/qwik/helpers/convert-method-to-function.d.ts +2 -0
- package/dist/src/generators/qwik/{convert-method-to-function.js → helpers/convert-method-to-function.js} +0 -1
- package/dist/src/generators/qwik/helpers/handlers.d.ts +3 -0
- package/dist/src/generators/qwik/{handlers.js → helpers/handlers.js} +3 -4
- package/dist/src/generators/qwik/helpers/state.d.ts +27 -0
- package/dist/src/generators/qwik/helpers/state.js +116 -0
- package/dist/src/generators/qwik/{styles.d.ts → helpers/styles.d.ts} +2 -2
- package/dist/src/generators/qwik/{styles.js → helpers/styles.js} +1 -1
- package/dist/src/generators/qwik/jsx.d.ts +1 -1
- package/dist/src/generators/qwik/jsx.js +3 -1
- package/dist/src/generators/qwik/src-generator.d.ts +0 -4
- package/dist/src/generators/qwik/src-generator.js +8 -13
- package/dist/src/generators/react/generator.js +2 -1
- package/dist/src/generators/{react-native.d.ts → react-native/index.d.ts} +3 -3
- package/dist/src/generators/{react-native.js → react-native/index.js} +46 -35
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.d.ts +3 -0
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +63 -0
- package/dist/src/generators/solid/index.js +4 -1
- package/dist/src/generators/svelte/svelte.js +13 -1
- package/dist/src/generators/vue/helpers.js +1 -1
- package/dist/src/helpers/babel-transform.d.ts +3 -3
- package/dist/src/helpers/babel-transform.js +42 -26
- package/dist/src/helpers/is-root-text-node.d.ts +4 -0
- package/dist/src/helpers/is-root-text-node.js +12 -0
- package/dist/src/helpers/map-refs.js +2 -26
- package/dist/src/helpers/parsers.js +11 -5
- package/dist/src/helpers/patterns.d.ts +1 -0
- package/dist/src/helpers/patterns.js +3 -1
- package/dist/src/helpers/plugins/process-code.d.ts +1 -1
- package/dist/src/helpers/plugins/process-code.js +9 -9
- package/dist/src/helpers/render-imports.js +1 -0
- package/dist/src/parsers/jsx/component-types.d.ts +2 -2
- package/dist/src/parsers/jsx/component-types.js +7 -16
- package/dist/src/parsers/jsx/index.d.ts +1 -1
- package/dist/src/parsers/jsx/index.js +3 -16
- package/dist/src/parsers/jsx/jsx.js +17 -22
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/src/generators/qwik/convert-method-to-function.d.ts +0 -1
- package/dist/src/generators/qwik/handlers.d.ts +0 -4
- /package/dist/src/generators/qwik/{stable-inject.d.ts → helpers/stable-inject.d.ts} +0 -0
- /package/dist/src/generators/qwik/{stable-inject.js → helpers/stable-inject.js} +0 -0
- /package/dist/src/generators/qwik/{stable-serialize.d.ts → helpers/stable-serialize.d.ts} +0 -0
- /package/dist/src/generators/qwik/{stable-serialize.js → helpers/stable-serialize.js} +0 -0
|
@@ -4,9 +4,9 @@ exports.CODE_PROCESSOR_PLUGIN = void 0;
|
|
|
4
4
|
var nullable_1 = require("../nullable");
|
|
5
5
|
var traverse_nodes_1 = require("../traverse-nodes");
|
|
6
6
|
/**
|
|
7
|
-
* Process code in
|
|
7
|
+
* Process code in each node.
|
|
8
8
|
*/
|
|
9
|
-
var
|
|
9
|
+
var preProcessNodeCode = function (_a) {
|
|
10
10
|
// const propertiesProcessor = codeProcessor('properties');
|
|
11
11
|
// for (const key in json.properties) {
|
|
12
12
|
// const value = json.properties[key];
|
|
@@ -14,12 +14,12 @@ var preProcessBlockCode = function (_a) {
|
|
|
14
14
|
// json.properties[key] = propertiesProcessor(value);
|
|
15
15
|
// }
|
|
16
16
|
// }
|
|
17
|
-
var json = _a.json, codeProcessor = _a.codeProcessor;
|
|
18
|
-
var bindingsProcessor = codeProcessor('bindings');
|
|
17
|
+
var json = _a.json, codeProcessor = _a.codeProcessor, parentComponent = _a.parentComponent;
|
|
18
|
+
var bindingsProcessor = codeProcessor('bindings', parentComponent);
|
|
19
19
|
for (var key in json.bindings) {
|
|
20
20
|
var value = json.bindings[key];
|
|
21
21
|
if (value === null || value === void 0 ? void 0 : value.code) {
|
|
22
|
-
value.code = bindingsProcessor(value.code);
|
|
22
|
+
value.code = bindingsProcessor(value.code, key);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
};
|
|
@@ -31,9 +31,9 @@ var CODE_PROCESSOR_PLUGIN = function (codeProcessor) {
|
|
|
31
31
|
json: {
|
|
32
32
|
post: function (json) {
|
|
33
33
|
function processHook(key, hook) {
|
|
34
|
-
hook.code = codeProcessor('hooks')(hook.code, key);
|
|
34
|
+
hook.code = codeProcessor('hooks', json)(hook.code, key);
|
|
35
35
|
if (hook.deps) {
|
|
36
|
-
hook.deps = codeProcessor('hooks-deps')(hook.deps);
|
|
36
|
+
hook.deps = codeProcessor('hooks-deps', json)(hook.deps, key);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
@@ -57,11 +57,11 @@ var CODE_PROCESSOR_PLUGIN = function (codeProcessor) {
|
|
|
57
57
|
for (var key in json.state) {
|
|
58
58
|
var state = json.state[key];
|
|
59
59
|
if (state) {
|
|
60
|
-
state.code = codeProcessor('state')(state.code);
|
|
60
|
+
state.code = codeProcessor('state', json)(state.code, key);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
(0, traverse_nodes_1.traverseNodes)(json, function (node) {
|
|
64
|
-
|
|
64
|
+
preProcessNodeCode({ json: node, codeProcessor: codeProcessor, parentComponent: json });
|
|
65
65
|
});
|
|
66
66
|
},
|
|
67
67
|
},
|
|
@@ -42,6 +42,7 @@ var getFileExtensionForTarget = function (target) {
|
|
|
42
42
|
// these `.lite` extensions are handled in the `transpile` step of the CLI.
|
|
43
43
|
// TO-DO: consolidate file-extension renaming to this file, and remove `.lite` replaces from the CLI `transpile`. (outdated) ?
|
|
44
44
|
// Bit team wanted to make sure React and Angular behaved the same in regards to imports - ALU 10/05/22
|
|
45
|
+
case 'qwik':
|
|
45
46
|
default:
|
|
46
47
|
return '.lite';
|
|
47
48
|
}
|
|
@@ -3,6 +3,6 @@ import { Context } from './types';
|
|
|
3
3
|
declare const types: typeof babel.types;
|
|
4
4
|
export declare const getPropsTypeRef: (node: babel.types.FunctionDeclaration, context: Context) => string | undefined;
|
|
5
5
|
export declare const isTypeOrInterface: (node: babel.Node) => boolean;
|
|
6
|
-
|
|
7
|
-
export declare
|
|
6
|
+
import { NodePath as BabelTraverseNodePath } from '@babel/traverse';
|
|
7
|
+
export declare const collectTypes: (path: BabelTraverseNodePath<babel.types.TSTypeAliasDeclaration> | BabelTraverseNodePath<babel.types.ExportNamedDeclaration> | BabelTraverseNodePath<babel.types.TSInterfaceDeclaration> | BabelTraverseNodePath<babel.types.TSTypeAliasDeclaration>, context: Context) => void;
|
|
8
8
|
export {};
|
|
@@ -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.
|
|
38
|
+
exports.collectTypes = exports.isTypeOrInterface = 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;
|
|
@@ -78,24 +78,15 @@ var isTypeOrInterface = function (node) {
|
|
|
78
78
|
(types.isExportNamedDeclaration(node) && types.isTSInterfaceDeclaration(node.declaration));
|
|
79
79
|
};
|
|
80
80
|
exports.isTypeOrInterface = isTypeOrInterface;
|
|
81
|
-
var
|
|
81
|
+
var getTypesFromNode = function (node, context) {
|
|
82
82
|
var typeStr = (0, generator_1.default)(node).code;
|
|
83
83
|
var _a = context.builder.component.types, types = _a === void 0 ? [] : _a;
|
|
84
84
|
types.push(typeStr);
|
|
85
85
|
context.builder.component.types = types.filter(Boolean);
|
|
86
86
|
};
|
|
87
|
+
var collectTypes = function (path, context) {
|
|
88
|
+
var node = path.node;
|
|
89
|
+
getTypesFromNode(node, context);
|
|
90
|
+
path.remove();
|
|
91
|
+
};
|
|
87
92
|
exports.collectTypes = collectTypes;
|
|
88
|
-
function handleTypeImports(path, context) {
|
|
89
|
-
for (var _i = 0, _a = path.node.body; _i < _a.length; _i++) {
|
|
90
|
-
var statement = _a[_i];
|
|
91
|
-
if (isTypeImport(statement)) {
|
|
92
|
-
var importDeclaration = statement;
|
|
93
|
-
// Remove .lite from path if exists, as that will be stripped
|
|
94
|
-
if (importDeclaration.source.value.endsWith('.lite')) {
|
|
95
|
-
importDeclaration.source.value = importDeclaration.source.value.replace(/\.lite$/, '');
|
|
96
|
-
}
|
|
97
|
-
(0, exports.collectTypes)(statement, context);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.handleTypeImports = handleTypeImports;
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.METADATA_HOOK_NAME = exports.selfClosingTags = void 0;
|
|
18
|
-
|
|
3
|
+
exports.METADATA_HOOK_NAME = exports.selfClosingTags = exports.parseJsx = void 0;
|
|
4
|
+
var jsx_1 = require("./jsx");
|
|
5
|
+
Object.defineProperty(exports, "parseJsx", { enumerable: true, get: function () { return jsx_1.parseJsx; } });
|
|
19
6
|
var helpers_1 = require("./helpers");
|
|
20
7
|
Object.defineProperty(exports, "selfClosingTags", { enumerable: true, get: function () { return helpers_1.selfClosingTags; } });
|
|
21
8
|
var hooks_1 = require("./hooks");
|
|
@@ -55,9 +55,10 @@ var function_1 = require("fp-ts/lib/function");
|
|
|
55
55
|
var imports_1 = require("./imports");
|
|
56
56
|
var element_parser_1 = require("./element-parser");
|
|
57
57
|
var function_parser_1 = require("./function-parser");
|
|
58
|
-
var
|
|
59
|
-
var
|
|
58
|
+
var preset_typescript_1 = __importDefault(require("@babel/preset-typescript"));
|
|
59
|
+
var plugin_syntax_typescript_1 = __importDefault(require("@babel/plugin-syntax-typescript"));
|
|
60
60
|
var types = babel.types;
|
|
61
|
+
var typescriptBabelPreset = [preset_typescript_1.default, { isTSX: true, allExtensions: true }];
|
|
61
62
|
var beforeParse = function (path) {
|
|
62
63
|
path.traverse({
|
|
63
64
|
FunctionDeclaration: function (path) {
|
|
@@ -73,29 +74,24 @@ var beforeParse = function (path) {
|
|
|
73
74
|
* @returns A JSON representation of the Mitosis component
|
|
74
75
|
*/
|
|
75
76
|
function parseJsx(jsx, _options) {
|
|
77
|
+
var _a;
|
|
76
78
|
if (_options === void 0) { _options = {}; }
|
|
77
79
|
var subComponentFunctions = [];
|
|
78
80
|
var options = __assign({ typescript: false }, _options);
|
|
79
|
-
var
|
|
81
|
+
var jsxToUse = options.typescript
|
|
82
|
+
? jsx
|
|
83
|
+
: // strip typescript types by running through babel's TS preset.
|
|
84
|
+
(_a = babel.transform(jsx, {
|
|
85
|
+
configFile: false,
|
|
86
|
+
babelrc: false,
|
|
87
|
+
presets: [typescriptBabelPreset],
|
|
88
|
+
})) === null || _a === void 0 ? void 0 : _a.code;
|
|
89
|
+
var output = babel.transform(jsxToUse, {
|
|
80
90
|
configFile: false,
|
|
81
91
|
babelrc: false,
|
|
82
92
|
comments: false,
|
|
83
|
-
presets: [
|
|
84
|
-
[
|
|
85
|
-
tsPreset,
|
|
86
|
-
{
|
|
87
|
-
isTSX: true,
|
|
88
|
-
allExtensions: true,
|
|
89
|
-
// If left to its default `false`, then this will strip away:
|
|
90
|
-
// - unused JS imports
|
|
91
|
-
// - types imports within regular JS import syntax
|
|
92
|
-
// When outputting to TS, we must set it to `true` to preserve these imports.
|
|
93
|
-
onlyRemoveTypeImports: options.typescript,
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
],
|
|
97
93
|
plugins: [
|
|
98
|
-
|
|
94
|
+
[plugin_syntax_typescript_1.default, { isTSX: true }],
|
|
99
95
|
function () { return ({
|
|
100
96
|
visitor: {
|
|
101
97
|
JSXExpressionContainer: function (path, context) {
|
|
@@ -112,7 +108,6 @@ function parseJsx(jsx, _options) {
|
|
|
112
108
|
component: (0, create_mitosis_component_1.createMitosisComponent)(),
|
|
113
109
|
};
|
|
114
110
|
var keepStatements = path.node.body.filter(function (statement) { return (0, helpers_1.isImportOrDefaultExport)(statement) || (0, component_types_1.isTypeOrInterface)(statement); });
|
|
115
|
-
(0, component_types_1.handleTypeImports)(path, context);
|
|
116
111
|
context.builder.component.exports = (0, exports_1.generateExports)(path);
|
|
117
112
|
subComponentFunctions = path.node.body
|
|
118
113
|
.filter(function (node) {
|
|
@@ -149,14 +144,14 @@ function parseJsx(jsx, _options) {
|
|
|
149
144
|
var node = path.node;
|
|
150
145
|
if (babel.types.isTSInterfaceDeclaration(node.declaration) ||
|
|
151
146
|
babel.types.isTSTypeAliasDeclaration(node.declaration)) {
|
|
152
|
-
(0, component_types_1.collectTypes)(path
|
|
147
|
+
(0, component_types_1.collectTypes)(path, context);
|
|
153
148
|
}
|
|
154
149
|
},
|
|
155
150
|
TSTypeAliasDeclaration: function (path, context) {
|
|
156
|
-
(0, component_types_1.collectTypes)(path
|
|
151
|
+
(0, component_types_1.collectTypes)(path, context);
|
|
157
152
|
},
|
|
158
153
|
TSInterfaceDeclaration: function (path, context) {
|
|
159
|
-
(0, component_types_1.collectTypes)(path
|
|
154
|
+
(0, component_types_1.collectTypes)(path, context);
|
|
160
155
|
},
|
|
161
156
|
},
|
|
162
157
|
}); },
|