@builder.io/mitosis 0.0.50-8 → 0.0.54
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/__tests__/angular.test.d.ts +1 -0
- package/dist/src/__tests__/angular.test.js +18 -0
- package/dist/src/__tests__/builder.test.d.ts +1 -0
- package/dist/src/__tests__/builder.test.js +235 -0
- package/dist/src/__tests__/context.test.d.ts +1 -0
- package/dist/src/__tests__/context.test.js +35 -0
- package/dist/src/__tests__/data/blocks/onUpdate.raw copy.d.ts +1 -0
- package/dist/src/__tests__/data/blocks/onUpdate.raw copy.jsx +10 -0
- package/dist/src/__tests__/data/blocks/self-referencing-component-with-children.raw.d.ts +1 -0
- package/dist/src/__tests__/data/blocks/self-referencing-component-with-children.raw.jsx +15 -0
- package/dist/src/__tests__/data/blocks/self-referencing-component.raw.d.ts +1 -0
- package/dist/src/__tests__/data/blocks/self-referencing-component.raw.jsx +12 -0
- package/dist/src/__tests__/data/blocks/slot.raw.d.ts +5 -0
- package/dist/src/__tests__/data/blocks/slot.raw.jsx +6 -0
- package/dist/src/__tests__/data/blocks/styles.raw.d.ts +1 -0
- package/dist/src/__tests__/data/blocks/styles.raw.jsx +10 -0
- package/dist/src/__tests__/html.test.d.ts +1 -0
- package/dist/src/__tests__/html.test.js +18 -0
- package/dist/src/__tests__/liquid.test.d.ts +1 -0
- package/dist/src/__tests__/liquid.test.js +108 -0
- package/dist/src/__tests__/parse-jsx.test.d.ts +1 -0
- package/dist/src/__tests__/parse-jsx.test.js +15 -0
- package/dist/src/__tests__/qwik.directive.test.d.ts +1 -0
- package/dist/src/__tests__/qwik.directive.test.js +107 -0
- package/dist/src/__tests__/qwik.test.d.ts +1 -0
- package/dist/src/__tests__/qwik.test.js +434 -0
- package/dist/src/__tests__/react-native.test.d.ts +1 -0
- package/dist/src/__tests__/react-native.test.js +140 -0
- package/dist/src/__tests__/react.test.d.ts +1 -0
- package/dist/src/__tests__/react.test.js +141 -0
- package/dist/src/__tests__/solid.test.d.ts +1 -0
- package/dist/src/__tests__/solid.test.js +102 -0
- package/dist/src/__tests__/stencil.test.d.ts +1 -0
- package/dist/src/__tests__/stencil.test.js +102 -0
- package/dist/src/__tests__/svelte.test.d.ts +1 -0
- package/dist/src/__tests__/svelte.test.js +36 -0
- package/dist/src/__tests__/vue.test.d.ts +1 -0
- package/dist/src/__tests__/vue.test.js +139 -0
- package/dist/src/__tests__/webcomponent.test.d.ts +1 -0
- package/dist/src/__tests__/webcomponent.test.js +12 -0
- package/dist/src/constants/html_tags.d.ts +1 -0
- package/dist/src/constants/html_tags.js +119 -0
- package/dist/src/generators/angular.js +1 -1
- package/dist/src/generators/context/react copy.d.ts +8 -0
- package/dist/src/generators/context/react copy.js +28 -0
- package/dist/src/generators/context/solid.d.ts +8 -0
- package/dist/src/generators/context/solid.js +28 -0
- package/dist/src/generators/context/svelte.d.ts +8 -0
- package/dist/src/generators/context/svelte.js +28 -0
- package/dist/src/generators/helpers/context.d.ts +2 -0
- package/dist/src/generators/helpers/context.js +8 -0
- package/dist/src/generators/mitosis.js +4 -3
- package/dist/src/generators/qwik/component.js +3 -1
- package/dist/src/generators/qwik/directives.d.ts +14 -5
- package/dist/src/generators/qwik/directives.js +22 -14
- package/dist/src/generators/qwik/jsx.js +14 -2
- package/dist/src/generators/qwik/src-generator.js +47 -24
- package/dist/src/generators/react.js +2 -5
- package/dist/src/generators/solid.js +82 -8
- package/dist/src/generators/stencil/generate.js +1 -1
- package/dist/src/generators/svelte.d.ts +9 -1
- package/dist/src/generators/svelte.js +170 -77
- package/dist/src/generators/vue.js +4 -1
- package/dist/src/helpers/babel-transform copy.d.ts +8 -0
- package/dist/src/helpers/babel-transform copy.js +138 -0
- package/dist/src/helpers/babel-transform.d.ts +4 -7
- package/dist/src/helpers/babel-transform.js +13 -1
- package/dist/src/helpers/babel-transform.test.d.ts +1 -0
- package/dist/src/helpers/babel-transform.test.js +7 -0
- package/dist/src/helpers/generic-format.test.d.ts +1 -0
- package/dist/src/helpers/generic-format.test.js +8 -0
- package/dist/src/helpers/get-state-object-string.js +2 -1
- package/dist/src/helpers/parsers.d.ts +8 -0
- package/dist/src/helpers/parsers.js +66 -0
- package/dist/src/helpers/remove-surrounding-block.test.d.ts +1 -0
- package/dist/src/helpers/remove-surrounding-block.test.js +9 -0
- package/dist/src/helpers/render-imports.d.ts +2 -4
- package/dist/src/helpers/render-imports.js +32 -14
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/parsers/builder.d.ts +0 -2
- package/dist/src/parsers/builder.js +5 -33
- package/dist/src/parsers/jsx.d.ts +7 -0
- package/dist/src/parsers/jsx.js +7 -0
- package/dist/src/symbols/symbol-processor.js +3 -3
- package/dist/src/types/mitosis-component.d.ts +0 -1
- package/dist/test/qwik/Accordion/high.jsx +0 -0
- package/dist/test/qwik/Accordion/low.jsx +207 -0
- package/dist/test/qwik/Accordion/med.jsx +10 -0
- package/dist/test/qwik/For/high.jsx +0 -0
- package/dist/test/qwik/For/low.jsx +33 -0
- package/dist/test/qwik/For/med.jsx +10 -0
- package/dist/test/qwik/Image/high.js +9 -0
- package/dist/test/qwik/Image/low.js +0 -0
- package/dist/test/qwik/Image/med.js +149 -0
- package/dist/test/qwik/Image.slow/high.js +9 -0
- package/dist/test/qwik/Image.slow/low.js +0 -0
- package/dist/test/qwik/Image.slow/med.js +149 -0
- package/dist/test/qwik/bindings/high.cjs +0 -0
- package/dist/test/qwik/bindings/low.cjs +33 -0
- package/dist/test/qwik/bindings/med.cjs +12 -0
- package/dist/test/qwik/button/high.js +3 -0
- package/dist/test/qwik/button/low.js +11 -0
- package/dist/test/qwik/button/med.js +37 -0
- package/dist/test/qwik/component/bindings/high.jsx +0 -0
- package/dist/test/qwik/component/bindings/low.jsx +43 -0
- package/dist/test/qwik/component/bindings/med.jsx +53 -0
- package/dist/test/qwik/component/component/inputs/high.cjsx +9 -0
- package/dist/test/qwik/component/component/inputs/low.cjsx +0 -0
- package/dist/test/qwik/component/component/inputs/med.cjsx +65 -0
- package/dist/test/qwik/hello_world/stylesheet/high.jsx +0 -0
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +12 -0
- package/dist/test/qwik/hello_world/stylesheet/med.jsx +10 -0
- package/dist/test/qwik/page-with-symbol/high.js +0 -0
- package/dist/test/qwik/page-with-symbol/low.js +19 -0
- package/dist/test/qwik/page-with-symbol/med.js +10 -0
- package/dist/test/qwik/show-hide/high.jsx +9 -0
- package/dist/test/qwik/show-hide/low.jsx +0 -0
- package/dist/test/qwik/show-hide/med.jsx +174 -0
- package/dist/test/qwik/svg/high.js +0 -0
- package/dist/test/qwik/svg/low.js +13 -0
- package/dist/test/qwik/svg/med.js +10 -0
- package/dist/test/qwik/todo/Todo.cjs/high.cjs +23 -0
- package/dist/test/qwik/todo/Todo.cjs/low.cjs +0 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +48 -0
- package/dist/test/qwik/todo/Todo.js/high.js +22 -0
- package/dist/test/qwik/todo/Todo.js/low.js +0 -0
- package/dist/test/qwik/todo/Todo.js/med.js +45 -0
- package/dist/test/qwik/todo/Todo.tsx/high.tsx +22 -0
- package/dist/test/qwik/todo/Todo.tsx/low.tsx +0 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +41 -0
- package/dist/test/qwik/todos/Todo.tsx/high.tsx +7 -0
- package/dist/test/qwik/todos/Todo.tsx/low.tsx +27 -0
- package/dist/test/qwik/todos/Todo.tsx/med.tsx +9 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1,66 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isCodeBodyIdentifier = exports.isExpression = exports.isCodeBodyExpression = exports.parseCode = void 0;
|
|
27
|
+
var babel = __importStar(require("@babel/core"));
|
|
28
|
+
var jsxPlugin = require('@babel/plugin-syntax-jsx');
|
|
29
|
+
var tsPreset = require('@babel/preset-typescript');
|
|
30
|
+
var decorators = require('@babel/plugin-syntax-decorators');
|
|
31
|
+
function parseCode(code) {
|
|
32
|
+
var ast = babel.parse(code, {
|
|
33
|
+
presets: [[tsPreset, { isTSX: true, allExtensions: true }]],
|
|
34
|
+
plugins: [[decorators, { legacy: true }], jsxPlugin],
|
|
35
|
+
});
|
|
36
|
+
var body = babel.types.isFile(ast)
|
|
37
|
+
? ast.program.body
|
|
38
|
+
: babel.types.isProgram(ast)
|
|
39
|
+
? ast.body
|
|
40
|
+
: [];
|
|
41
|
+
return body;
|
|
42
|
+
}
|
|
43
|
+
exports.parseCode = parseCode;
|
|
44
|
+
var isCodeBodyExpression = function (body) {
|
|
45
|
+
return body.length == 1 &&
|
|
46
|
+
(babel.types.isExpression(body[0]) ||
|
|
47
|
+
babel.types.isExpressionStatement(body[0]));
|
|
48
|
+
};
|
|
49
|
+
exports.isCodeBodyExpression = isCodeBodyExpression;
|
|
50
|
+
/**
|
|
51
|
+
* Returns `true` if the `code` is a valid expression. (vs a statement)
|
|
52
|
+
*/
|
|
53
|
+
function isExpression(code) {
|
|
54
|
+
try {
|
|
55
|
+
var body = parseCode(code);
|
|
56
|
+
return (0, exports.isCodeBodyExpression)(body);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.isExpression = isExpression;
|
|
63
|
+
var isCodeBodyIdentifier = function (body) {
|
|
64
|
+
return body.length == 1 && babel.types.isIdentifier(body[0]);
|
|
65
|
+
};
|
|
66
|
+
exports.isCodeBodyIdentifier = isCodeBodyIdentifier;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var remove_surrounding_block_1 = require("./remove-surrounding-block");
|
|
4
|
+
describe('removeSurroundingBlock', function () {
|
|
5
|
+
test('It removes the surrounding wrapper block', function () {
|
|
6
|
+
var output = (0, remove_surrounding_block_1.removeSurroundingBlock)('{ const foo = "bar" }');
|
|
7
|
+
expect(output).toBe(' const foo = "bar" ');
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { MitosisComponent
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const renderImports: (imports: MitosisImport[]) => string;
|
|
4
|
-
export declare const renderPreComponent: (component: MitosisComponent) => string;
|
|
1
|
+
import { MitosisComponent } from '../types/mitosis-component';
|
|
2
|
+
export declare const renderPreComponent: (component: MitosisComponent, target?: "angular" | "builder" | "customElement" | "html" | "mitosis" | "liquid" | "react" | "reactNative" | "solid" | "svelte" | "swift" | "template" | "webcomponent" | "vue" | undefined) => string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderPreComponent =
|
|
4
|
-
var getStarImport = function (
|
|
3
|
+
exports.renderPreComponent = void 0;
|
|
4
|
+
var getStarImport = function (_a) {
|
|
5
|
+
var theImport = _a.theImport;
|
|
5
6
|
for (var key in theImport.imports) {
|
|
6
7
|
var value = theImport.imports[key];
|
|
7
8
|
if (value === '*') {
|
|
@@ -10,7 +11,8 @@ var getStarImport = function (theImport) {
|
|
|
10
11
|
}
|
|
11
12
|
return null;
|
|
12
13
|
};
|
|
13
|
-
var getDefaultImport = function (
|
|
14
|
+
var getDefaultImport = function (_a) {
|
|
15
|
+
var theImport = _a.theImport;
|
|
14
16
|
for (var key in theImport.imports) {
|
|
15
17
|
var value = theImport.imports[key];
|
|
16
18
|
if (value === 'default') {
|
|
@@ -19,14 +21,32 @@ var getDefaultImport = function (theImport) {
|
|
|
19
21
|
}
|
|
20
22
|
return null;
|
|
21
23
|
};
|
|
22
|
-
var
|
|
24
|
+
var transformImportPath = function (theImport, target) {
|
|
25
|
+
// We need to drop the `.lite` from context files, because the context generator does so as well.
|
|
26
|
+
if (theImport.path.endsWith('.context.lite')) {
|
|
27
|
+
return theImport.path.replace('.lite', '');
|
|
28
|
+
}
|
|
29
|
+
switch (target) {
|
|
30
|
+
case 'svelte':
|
|
31
|
+
if (theImport.path.endsWith('.lite'))
|
|
32
|
+
// all svelte components have `.svelte` extension
|
|
33
|
+
return theImport.path.replace('.lite', '.svelte');
|
|
34
|
+
else {
|
|
35
|
+
return theImport.path;
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
return theImport.path;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var renderImport = function (_a) {
|
|
42
|
+
var theImport = _a.theImport, target = _a.target;
|
|
23
43
|
var importString = 'import ';
|
|
24
|
-
var starImport = getStarImport(theImport);
|
|
44
|
+
var starImport = getStarImport({ theImport: theImport });
|
|
25
45
|
if (starImport) {
|
|
26
46
|
importString += " * as ".concat(starImport, " ");
|
|
27
47
|
}
|
|
28
48
|
else {
|
|
29
|
-
var defaultImport = getDefaultImport(theImport);
|
|
49
|
+
var defaultImport = getDefaultImport({ theImport: theImport });
|
|
30
50
|
if (defaultImport) {
|
|
31
51
|
importString += " ".concat(defaultImport, ", ");
|
|
32
52
|
}
|
|
@@ -50,11 +70,12 @@ var renderImport = function (theImport) {
|
|
|
50
70
|
}
|
|
51
71
|
importString += ' } ';
|
|
52
72
|
}
|
|
53
|
-
|
|
73
|
+
var path = transformImportPath(theImport, target);
|
|
74
|
+
importString += " from '".concat(path, "';");
|
|
54
75
|
return importString;
|
|
55
76
|
};
|
|
56
|
-
|
|
57
|
-
var
|
|
77
|
+
var renderImports = function (_a) {
|
|
78
|
+
var imports = _a.imports, target = _a.target;
|
|
58
79
|
var importString = '';
|
|
59
80
|
for (var _i = 0, imports_1 = imports; _i < imports_1.length; _i++) {
|
|
60
81
|
var theImport = imports_1[_i];
|
|
@@ -66,12 +87,9 @@ var renderImports = function (imports) {
|
|
|
66
87
|
if (theImport.path.startsWith('@builder.io/mitosis')) {
|
|
67
88
|
continue;
|
|
68
89
|
}
|
|
69
|
-
importString += (
|
|
90
|
+
importString += renderImport({ theImport: theImport, target: target }) + '\n';
|
|
70
91
|
}
|
|
71
92
|
return importString;
|
|
72
93
|
};
|
|
73
|
-
|
|
74
|
-
var renderPreComponent = function (component) {
|
|
75
|
-
return "\n ".concat((0, exports.renderImports)(component.imports), "\n ").concat(component.hooks.preComponent || '', "\n ");
|
|
76
|
-
};
|
|
94
|
+
var renderPreComponent = function (component, target) { return "\n ".concat(renderImports({ imports: component.imports, target: target }), "\n ").concat(component.hooks.preComponent || '', "\n "); };
|
|
77
95
|
exports.renderPreComponent = renderPreComponent;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -27,7 +27,9 @@ export * from './parsers/context';
|
|
|
27
27
|
export * from './generators/vue';
|
|
28
28
|
export * from './generators/angular';
|
|
29
29
|
export * from './generators/context/react';
|
|
30
|
+
export * from './generators/context/solid';
|
|
30
31
|
export * from './generators/context/vue';
|
|
32
|
+
export * from './generators/context/svelte';
|
|
31
33
|
export * from './generators/react';
|
|
32
34
|
export * from './generators/solid';
|
|
33
35
|
export * from './generators/liquid';
|
package/dist/src/index.js
CHANGED
|
@@ -53,7 +53,9 @@ __exportStar(require("./parsers/context"), exports);
|
|
|
53
53
|
__exportStar(require("./generators/vue"), exports);
|
|
54
54
|
__exportStar(require("./generators/angular"), exports);
|
|
55
55
|
__exportStar(require("./generators/context/react"), exports);
|
|
56
|
+
__exportStar(require("./generators/context/solid"), exports);
|
|
56
57
|
__exportStar(require("./generators/context/vue"), exports);
|
|
58
|
+
__exportStar(require("./generators/context/svelte"), exports);
|
|
57
59
|
__exportStar(require("./generators/react"), exports);
|
|
58
60
|
__exportStar(require("./generators/solid"), exports);
|
|
59
61
|
__exportStar(require("./generators/liquid"), exports);
|
|
@@ -36,7 +36,6 @@ export declare const builderContentToMitosisComponent: (builderContent: BuilderC
|
|
|
36
36
|
imports: import("..").MitosisImport[];
|
|
37
37
|
meta: import("../types/json").JSONObject & {
|
|
38
38
|
useMetadata?: import("../types/json").JSONObject | undefined;
|
|
39
|
-
metadataHook?: import("../types/json").JSONObject | undefined;
|
|
40
39
|
};
|
|
41
40
|
inputs: import("..").MitosisComponentInput[];
|
|
42
41
|
state: import("../types/json").JSONObject;
|
|
@@ -70,7 +69,6 @@ export declare const builderContentToMitosisComponent: (builderContent: BuilderC
|
|
|
70
69
|
imports: import("..").MitosisImport[];
|
|
71
70
|
meta: import("../types/json").JSONObject & {
|
|
72
71
|
useMetadata?: import("../types/json").JSONObject | undefined;
|
|
73
|
-
metadataHook?: import("../types/json").JSONObject | undefined;
|
|
74
72
|
};
|
|
75
73
|
inputs: import("..").MitosisComponentInput[];
|
|
76
74
|
state: import("../types/json").JSONObject;
|
|
@@ -49,9 +49,7 @@ var capitalize_1 = require("../helpers/capitalize");
|
|
|
49
49
|
var create_mitosis_component_1 = require("../helpers/create-mitosis-component");
|
|
50
50
|
var create_mitosis_node_1 = require("../helpers/create-mitosis-node");
|
|
51
51
|
var jsx_1 = require("./jsx");
|
|
52
|
-
var
|
|
53
|
-
var tsPreset = require('@babel/preset-typescript');
|
|
54
|
-
var decorators = require('@babel/plugin-syntax-decorators');
|
|
52
|
+
var parsers_1 = require("../helpers/parsers");
|
|
55
53
|
// Omit some superflous styles that can come from Builder's web importer
|
|
56
54
|
var styleOmitList = [
|
|
57
55
|
'backgroundRepeatX',
|
|
@@ -182,7 +180,7 @@ var getBlockNonActionBindings = function (block, options) {
|
|
|
182
180
|
if (options.includeBuilderExtras) {
|
|
183
181
|
for (var key in obj) {
|
|
184
182
|
if (!isValidBindingKey(key)) {
|
|
185
|
-
console.warn('Skipping invalid
|
|
183
|
+
console.warn('Skipping invalid binding key:', key);
|
|
186
184
|
continue;
|
|
187
185
|
}
|
|
188
186
|
var value = obj[key];
|
|
@@ -209,7 +207,7 @@ var wrapBinding = function (value) {
|
|
|
209
207
|
if (!(value.includes(';') || value.match(/(^|\s|;)return[^a-z0-9A-Z]/))) {
|
|
210
208
|
return value;
|
|
211
209
|
}
|
|
212
|
-
return "(() => {\n try { ".concat(isExpression(value) ? 'return ' : '').concat(value, " }\n catch (err) {\n console.warn('Builder code error', err);\n }\n })()");
|
|
210
|
+
return "(() => {\n try { ".concat((0, parsers_1.isExpression)(value) ? 'return ' : '').concat(value, " }\n catch (err) {\n console.warn('Builder code error', err);\n }\n })()");
|
|
213
211
|
};
|
|
214
212
|
var getBlockBindings = function (block, options) {
|
|
215
213
|
var obj = __assign(__assign({}, getBlockNonActionBindings(block, options)), getBlockActionsAsBindings(block, options));
|
|
@@ -556,7 +554,7 @@ var getHooks = function (content) {
|
|
|
556
554
|
function extractStateHook(code) {
|
|
557
555
|
var types = babel.types;
|
|
558
556
|
var state = {};
|
|
559
|
-
var body = parseCode(code);
|
|
557
|
+
var body = (0, parsers_1.parseCode)(code);
|
|
560
558
|
var newBody = body.slice();
|
|
561
559
|
for (var i = 0; i < body.length; i++) {
|
|
562
560
|
var statement = body[i];
|
|
@@ -594,7 +592,7 @@ function extractStateHook(code) {
|
|
|
594
592
|
exports.extractStateHook = extractStateHook;
|
|
595
593
|
function convertExportDefaultToReturn(code) {
|
|
596
594
|
var types = babel.types;
|
|
597
|
-
var body = parseCode(code);
|
|
595
|
+
var body = (0, parsers_1.parseCode)(code);
|
|
598
596
|
var newBody = body.slice();
|
|
599
597
|
for (var i = 0; i < body.length; i++) {
|
|
600
598
|
var statement = body[i];
|
|
@@ -608,32 +606,6 @@ function convertExportDefaultToReturn(code) {
|
|
|
608
606
|
return (0, generator_1.default)(types.program(newBody)).code || '';
|
|
609
607
|
}
|
|
610
608
|
exports.convertExportDefaultToReturn = convertExportDefaultToReturn;
|
|
611
|
-
function parseCode(code) {
|
|
612
|
-
var ast = babel.parse(code, {
|
|
613
|
-
presets: [[tsPreset, { isTSX: true, allExtensions: true }]],
|
|
614
|
-
plugins: [[decorators, { legacy: true }], jsxPlugin],
|
|
615
|
-
});
|
|
616
|
-
var body = babel.types.isFile(ast)
|
|
617
|
-
? ast.program.body
|
|
618
|
-
: babel.types.isProgram(ast)
|
|
619
|
-
? ast.body
|
|
620
|
-
: [];
|
|
621
|
-
return body;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Returns `true` if the `code` is a valid expression. (vs a statement)
|
|
625
|
-
*/
|
|
626
|
-
function isExpression(code) {
|
|
627
|
-
try {
|
|
628
|
-
var body = parseCode(code);
|
|
629
|
-
return (body.length == 1 &&
|
|
630
|
-
(babel.types.isExpression(body[0]) ||
|
|
631
|
-
babel.types.isExpressionStatement(body[0])));
|
|
632
|
-
}
|
|
633
|
-
catch (e) {
|
|
634
|
-
return false;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
609
|
// TODO: maybe this should be part of the builder -> Mitosis part
|
|
638
610
|
function extractSymbols(json) {
|
|
639
611
|
var _a, _b, _c, _d;
|
|
@@ -9,5 +9,12 @@ declare type ParseMitosisOptions = {
|
|
|
9
9
|
format: 'react' | 'simple';
|
|
10
10
|
jsonHookNames?: string[];
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* This function takes the raw string from a Mitosis component, and converts it into a JSON that can be processed by
|
|
14
|
+
* each generator function.
|
|
15
|
+
*
|
|
16
|
+
* @param jsx string representation of the Mitosis component
|
|
17
|
+
* @returns A JSON representation of the Mitosis component
|
|
18
|
+
*/
|
|
12
19
|
export declare function parseJsx(jsx: string, options?: Partial<ParseMitosisOptions>): MitosisComponent;
|
|
13
20
|
export {};
|
package/dist/src/parsers/jsx.js
CHANGED
|
@@ -622,6 +622,13 @@ function extractContextComponents(json) {
|
|
|
622
622
|
var isImportOrDefaultExport = function (node) {
|
|
623
623
|
return types.isExportDefaultDeclaration(node) || types.isImportDeclaration(node);
|
|
624
624
|
};
|
|
625
|
+
/**
|
|
626
|
+
* This function takes the raw string from a Mitosis component, and converts it into a JSON that can be processed by
|
|
627
|
+
* each generator function.
|
|
628
|
+
*
|
|
629
|
+
* @param jsx string representation of the Mitosis component
|
|
630
|
+
* @returns A JSON representation of the Mitosis component
|
|
631
|
+
*/
|
|
625
632
|
function parseJsx(jsx, options) {
|
|
626
633
|
if (options === void 0) { options = {}; }
|
|
627
634
|
var useOptions = __assign({ format: 'react' }, options);
|
|
@@ -76,7 +76,7 @@ function convertBuilderContentToSymbolHierarchy(content, _a) {
|
|
|
76
76
|
if (cssCode) {
|
|
77
77
|
collectComponentStyles && collectComponentStyles.push((0, minify_1.minify)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), cssCode));
|
|
78
78
|
}
|
|
79
|
-
while (path[0 /*
|
|
79
|
+
while (path[0 /* DEPTH */] >= this.path.length) {
|
|
80
80
|
path.shift();
|
|
81
81
|
path.shift();
|
|
82
82
|
}
|
|
@@ -92,10 +92,10 @@ function convertBuilderContentToSymbolHierarchy(content, _a) {
|
|
|
92
92
|
collectComponentState[id] = state;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
if (path[0 /*
|
|
95
|
+
if (path[0 /* DEPTH */] < this.path.length) {
|
|
96
96
|
var id = getIdFromSymbol(el);
|
|
97
97
|
hierarchy[id] = [];
|
|
98
|
-
addIfMissing(hierarchy[path[1 /*
|
|
98
|
+
addIfMissing(hierarchy[path[1 /* ID */]], id);
|
|
99
99
|
path.unshift(this.path.length, id);
|
|
100
100
|
}
|
|
101
101
|
// TODO(misko): This should be `el.content` not `el`
|
|
File without changes
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { h, qrl, useLexicalScope } from "@builder.io/qwik";
|
|
2
|
+
export const MyComponent_styles = `.csw5022{display:flex;flex-direction:column;position:relative;flex-shrink:0;box-sizing:border-box;margin-top:20px;align-items:stretch}.csanagh{margin-top:10px;position:relative;display:flex;align-items:stretch;flex-direction:column;padding-bottom:10px}.c4qyc1p{position:relative;display:flex;align-items:stretch;flex-direction:column;margin-top:10px;padding-bottom:10px}.crwdrpw{text-align:left;display:flex;flex-direction:column}.ctcw2m4{padding-top:50px;text-align:left;display:flex;flex-direction:column;padding-bottom:50px}`;
|
|
3
|
+
export const MyComponent_onRender = () => {
|
|
4
|
+
const state = useLexicalScope()[0];
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
gridRowWidth="25%"
|
|
8
|
+
class="csw5022"
|
|
9
|
+
items={[
|
|
10
|
+
{
|
|
11
|
+
title: [
|
|
12
|
+
{
|
|
13
|
+
"@type": "@builder.io/sdk:Element",
|
|
14
|
+
"@version": 2,
|
|
15
|
+
layerName: "Accordion item title",
|
|
16
|
+
id: "builder-5fed2723c1cc4fb39e9d22b9c54ef179",
|
|
17
|
+
children: [
|
|
18
|
+
{
|
|
19
|
+
"@type": "@builder.io/sdk:Element",
|
|
20
|
+
"@version": 2,
|
|
21
|
+
id: "builder-2cad86b387ec405d82917895d7af0a12",
|
|
22
|
+
component: {
|
|
23
|
+
name: "Text",
|
|
24
|
+
options: { text: "<p>Item 1</p>" },
|
|
25
|
+
},
|
|
26
|
+
responsiveStyles: {
|
|
27
|
+
large: {
|
|
28
|
+
textAlign: "left",
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexDirection: "column",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
responsiveStyles: {
|
|
36
|
+
large: {
|
|
37
|
+
marginTop: "10px",
|
|
38
|
+
position: "relative",
|
|
39
|
+
display: "flex",
|
|
40
|
+
alignItems: "stretch",
|
|
41
|
+
flexDirection: "column",
|
|
42
|
+
paddingBottom: "10px",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
detail: [
|
|
48
|
+
{
|
|
49
|
+
"@type": "@builder.io/sdk:Element",
|
|
50
|
+
"@version": 2,
|
|
51
|
+
layerName: "Accordion item detail",
|
|
52
|
+
id: "builder-18279a99b32240f19aa21d3f4b015cc9",
|
|
53
|
+
children: [
|
|
54
|
+
{
|
|
55
|
+
"@type": "@builder.io/sdk:Element",
|
|
56
|
+
"@version": 2,
|
|
57
|
+
id: "builder-2dbfa56b8988461c8566bbe759580e9b",
|
|
58
|
+
component: {
|
|
59
|
+
name: "Text",
|
|
60
|
+
options: { text: "<p>Item 1 content</p>" },
|
|
61
|
+
},
|
|
62
|
+
responsiveStyles: {
|
|
63
|
+
large: {
|
|
64
|
+
paddingTop: "50px",
|
|
65
|
+
textAlign: "left",
|
|
66
|
+
display: "flex",
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
paddingBottom: "50px",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
responsiveStyles: {
|
|
74
|
+
large: {
|
|
75
|
+
position: "relative",
|
|
76
|
+
display: "flex",
|
|
77
|
+
alignItems: "stretch",
|
|
78
|
+
flexDirection: "column",
|
|
79
|
+
marginTop: "10px",
|
|
80
|
+
paddingBottom: "10px",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
title: [
|
|
88
|
+
{
|
|
89
|
+
"@type": "@builder.io/sdk:Element",
|
|
90
|
+
"@version": 2,
|
|
91
|
+
layerName: "Accordion item title",
|
|
92
|
+
id: "builder-2a93def22a354cf7aa193c20d1ad6def",
|
|
93
|
+
children: [
|
|
94
|
+
{
|
|
95
|
+
"@type": "@builder.io/sdk:Element",
|
|
96
|
+
"@version": 2,
|
|
97
|
+
id: "builder-1365fc457ece45db82ad90dbe9819e7c",
|
|
98
|
+
component: {
|
|
99
|
+
name: "Text",
|
|
100
|
+
options: { text: "<p>Item 2</p>" },
|
|
101
|
+
},
|
|
102
|
+
responsiveStyles: {
|
|
103
|
+
large: {
|
|
104
|
+
textAlign: "left",
|
|
105
|
+
display: "flex",
|
|
106
|
+
flexDirection: "column",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
responsiveStyles: {
|
|
112
|
+
large: {
|
|
113
|
+
marginTop: "10px",
|
|
114
|
+
position: "relative",
|
|
115
|
+
display: "flex",
|
|
116
|
+
alignItems: "stretch",
|
|
117
|
+
flexDirection: "column",
|
|
118
|
+
paddingBottom: "10px",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
detail: [
|
|
124
|
+
{
|
|
125
|
+
"@type": "@builder.io/sdk:Element",
|
|
126
|
+
"@version": 2,
|
|
127
|
+
layerName: "Accordion item detail",
|
|
128
|
+
id: "builder-fd6ef41da6d040328fbd8b0801611fe5",
|
|
129
|
+
children: [
|
|
130
|
+
{
|
|
131
|
+
"@type": "@builder.io/sdk:Element",
|
|
132
|
+
"@version": 2,
|
|
133
|
+
id: "builder-7362f9fd64c647c5a400d9e75c74473f",
|
|
134
|
+
component: {
|
|
135
|
+
name: "Text",
|
|
136
|
+
options: { text: "<p>Item 2 content</p>" },
|
|
137
|
+
},
|
|
138
|
+
responsiveStyles: {
|
|
139
|
+
large: {
|
|
140
|
+
paddingTop: "50px",
|
|
141
|
+
textAlign: "left",
|
|
142
|
+
display: "flex",
|
|
143
|
+
flexDirection: "column",
|
|
144
|
+
paddingBottom: "50px",
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
responsiveStyles: {
|
|
150
|
+
large: {
|
|
151
|
+
position: "relative",
|
|
152
|
+
display: "flex",
|
|
153
|
+
alignItems: "stretch",
|
|
154
|
+
flexDirection: "column",
|
|
155
|
+
marginTop: "10px",
|
|
156
|
+
paddingBottom: "10px",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
]}
|
|
163
|
+
animate={true}
|
|
164
|
+
>
|
|
165
|
+
<div>
|
|
166
|
+
<div builder="accordion">
|
|
167
|
+
<div builder="accordion-title">
|
|
168
|
+
<div class="csanagh">
|
|
169
|
+
<div class="crwdrpw">
|
|
170
|
+
<div innerHTML="<p>Item 1</p>" class="builder-text"></div>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
<div builder="accordion-detail">
|
|
175
|
+
<div class="c4qyc1p">
|
|
176
|
+
<div class="ctcw2m4">
|
|
177
|
+
<div
|
|
178
|
+
innerHTML="<p>Item 1 content</p>"
|
|
179
|
+
class="builder-text"
|
|
180
|
+
></div>
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
<div builder="accordion">
|
|
186
|
+
<div builder="accordion-title">
|
|
187
|
+
<div class="csanagh">
|
|
188
|
+
<div class="crwdrpw">
|
|
189
|
+
<div innerHTML="<p>Item 2</p>" class="builder-text"></div>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
<div builder="accordion-detail">
|
|
194
|
+
<div class="c4qyc1p">
|
|
195
|
+
<div class="ctcw2m4">
|
|
196
|
+
<div
|
|
197
|
+
innerHTML="<p>Item 2 content</p>"
|
|
198
|
+
class="builder-text"
|
|
199
|
+
></div>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
);
|
|
207
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { componentQrl, qrl, withScopedStylesQrl } from "@builder.io/qwik";
|
|
2
|
+
export const MyComponent_onMount = (state) => {
|
|
3
|
+
typeof __STATE__ === "object" &&
|
|
4
|
+
Object.assign(state, __STATE__[state.serverStateId]);
|
|
5
|
+
withScopedStylesQrl(qrl("./low.js", "MyComponent_styles", []));
|
|
6
|
+
return qrl("./low.js", "MyComponent_onRender", [state]);
|
|
7
|
+
};
|
|
8
|
+
export const MyComponent = componentQrl(
|
|
9
|
+
qrl("./med.js", "MyComponent_onMount", [])
|
|
10
|
+
);
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { h, qrl, useLexicalScope } from "@builder.io/qwik";
|
|
2
|
+
export const MyComponent_styles = `.cvdfnp5{display:flex;flex-direction:column;position:relative;flex-shrink:0;box-sizing:border-box;margin-top:0px;padding-left:20px;padding-right:20px;padding-top:50px;padding-bottom:50px;width:100vw;margin-left:calc(50% - 50vw)}.cz5wnof{width:100%;align-self:stretch;flex-grow:1;box-sizing:border-box;max-width:1200px;display:flex;flex-direction:column;align-items:stretch;margin-left:auto;margin-right:auto}.cdrk993{text-align:center}`;
|
|
3
|
+
export const MyComponent_onRender = () => {
|
|
4
|
+
const state = useLexicalScope()[0];
|
|
5
|
+
return (
|
|
6
|
+
<div class="cvdfnp5" maxWidth={1200}>
|
|
7
|
+
<section class="cz5wnof">
|
|
8
|
+
{(state.simpleList.results || []).map(
|
|
9
|
+
function (__value__) {
|
|
10
|
+
var state = Object.assign({}, this, {
|
|
11
|
+
resultsItem: __value__ == null ? {} : __value__,
|
|
12
|
+
});
|
|
13
|
+
return (
|
|
14
|
+
<div class="cdrk993">
|
|
15
|
+
<div
|
|
16
|
+
class="builder-text"
|
|
17
|
+
innerHTML={(() => {
|
|
18
|
+
try {
|
|
19
|
+
var _virtual_index = state.resultsItem.data.title;
|
|
20
|
+
return _virtual_index;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.warn("Builder code error", err);
|
|
23
|
+
}
|
|
24
|
+
})()}
|
|
25
|
+
></div>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}.bind(state)
|
|
29
|
+
)}
|
|
30
|
+
</section>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { componentQrl, qrl, withScopedStylesQrl } from "@builder.io/qwik";
|
|
2
|
+
export const MyComponent_onMount = (state) => {
|
|
3
|
+
typeof __STATE__ === "object" &&
|
|
4
|
+
Object.assign(state, __STATE__[state.serverStateId]);
|
|
5
|
+
withScopedStylesQrl(qrl("./low.js", "MyComponent_styles", []));
|
|
6
|
+
return qrl("./low.js", "MyComponent_onRender", [state]);
|
|
7
|
+
};
|
|
8
|
+
export const MyComponent = componentQrl(
|
|
9
|
+
qrl("./med.js", "MyComponent_onMount", [])
|
|
10
|
+
);
|
|
File without changes
|