@builder.io/mitosis 0.0.45-4 → 0.0.47
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__/builder.test.js +73 -65
- package/dist/src/__tests__/context.test.js +13 -10
- package/dist/src/__tests__/data/basic.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/button-with-metadata.raw.jsx +1 -1
- package/dist/src/__tests__/data/blocks/columns.raw.jsx +2 -2
- package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -3
- package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -3
- package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
- package/dist/src/__tests__/data/blocks/image.raw.jsx +4 -4
- package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +4 -4
- package/dist/src/__tests__/data/context/component-with-context.lite.jsx +2 -2
- package/dist/src/__tests__/data/context/simple.context.lite.js +1 -1
- package/dist/src/__tests__/html.test.js +2 -2
- package/dist/src/__tests__/liquid.test.js +34 -34
- package/dist/src/__tests__/parse-jsx.test.js +1 -1
- package/dist/src/__tests__/qwik.test.js +197 -50
- package/dist/src/__tests__/react-native.test.js +35 -35
- package/dist/src/__tests__/react.test.js +35 -35
- package/dist/src/__tests__/solid.test.js +32 -32
- package/dist/src/__tests__/vue.test.js +35 -34
- package/dist/src/generators/angular.d.ts +4 -7
- package/dist/src/generators/angular.js +77 -81
- package/dist/src/generators/builder.d.ts +4 -4
- package/dist/src/generators/builder.js +57 -57
- package/dist/src/generators/context/react.d.ts +3 -1
- package/dist/src/generators/context/react.js +20 -17
- package/dist/src/generators/html.d.ts +5 -9
- package/dist/src/generators/html.js +205 -199
- package/dist/src/generators/liquid.d.ts +5 -9
- package/dist/src/generators/liquid.js +62 -59
- package/dist/src/generators/mitosis.d.ts +6 -7
- package/dist/src/generators/mitosis.js +61 -63
- package/dist/src/generators/qwik/component.d.ts +20 -0
- package/dist/src/generators/qwik/component.js +117 -0
- package/dist/src/generators/qwik/directives.d.ts +2 -0
- package/dist/src/generators/qwik/directives.js +27 -0
- package/dist/src/generators/qwik/handlers.d.ts +4 -0
- package/dist/src/generators/qwik/handlers.js +80 -0
- package/dist/src/generators/qwik/index.d.ts +2 -0
- package/dist/src/generators/qwik/index.js +9 -0
- package/dist/src/generators/qwik/jsx.d.ts +4 -0
- package/dist/src/generators/qwik/jsx.js +124 -0
- package/dist/src/generators/qwik/src-generator.d.ts +79 -0
- package/dist/src/generators/qwik/src-generator.js +427 -0
- package/dist/src/generators/qwik/styles.d.ts +7 -0
- package/dist/src/generators/qwik/styles.js +94 -0
- package/dist/src/generators/react-native.d.ts +4 -7
- package/dist/src/generators/react-native.js +25 -22
- package/dist/src/generators/react.d.ts +4 -8
- package/dist/src/generators/react.js +118 -114
- package/dist/src/generators/solid.d.ts +4 -8
- package/dist/src/generators/solid.js +55 -54
- package/dist/src/generators/svelte.d.ts +4 -7
- package/dist/src/generators/svelte.js +120 -123
- package/dist/src/generators/swift-ui.d.ts +2 -2
- package/dist/src/generators/swift-ui.js +62 -62
- package/dist/src/generators/template.d.ts +4 -8
- package/dist/src/generators/template.js +48 -45
- package/dist/src/generators/vue.d.ts +9 -9
- package/dist/src/generators/vue.js +170 -169
- package/dist/src/helpers/babel-transform.js +9 -9
- package/dist/src/helpers/camel-case.d.ts +8 -0
- package/dist/src/helpers/camel-case.js +18 -0
- package/dist/src/helpers/collect-styles.js +39 -37
- package/dist/src/helpers/dash-case.js +1 -1
- package/dist/src/helpers/generic-format.test.js +2 -2
- package/dist/src/helpers/get-components-used.js +2 -2
- package/dist/src/helpers/get-components.js +3 -3
- package/dist/src/helpers/get-props.js +1 -1
- package/dist/src/helpers/get-refs.js +2 -2
- package/dist/src/helpers/get-state-object-string.js +52 -39
- package/dist/src/helpers/get-state-used.js +1 -1
- package/dist/src/helpers/get-styles.js +1 -1
- package/dist/src/helpers/getters-to-functions.js +4 -4
- package/dist/src/helpers/handle-missing-state.js +1 -1
- package/dist/src/helpers/has-component.js +2 -2
- package/dist/src/helpers/has-props.js +1 -1
- package/dist/src/helpers/is-children.js +1 -1
- package/dist/src/helpers/json.d.ts +1 -0
- package/dist/src/helpers/json.js +17 -0
- package/dist/src/helpers/map-refs.js +7 -6
- package/dist/src/helpers/map-to-attributes.js +4 -4
- package/dist/src/helpers/map-to-css.js +2 -2
- package/dist/src/helpers/parse-node.js +2 -2
- package/dist/src/helpers/parse-reactive-script.js +4 -4
- package/dist/src/helpers/patterns.d.ts +2 -0
- package/dist/src/helpers/patterns.js +5 -0
- package/dist/src/helpers/process-http-requests.js +1 -1
- package/dist/src/helpers/process-tag-references.js +4 -4
- package/dist/src/helpers/remove-surrounding-block.test.js +1 -1
- package/dist/src/helpers/render-imports.js +7 -7
- package/dist/src/helpers/replace-idenifiers.js +1 -1
- package/dist/src/helpers/strip-meta-properties.js +2 -2
- package/dist/src/helpers/trace-reference-to-module-path.js +1 -1
- package/dist/src/helpers/traverse-nodes.js +2 -2
- package/dist/src/helpers/try-prettier-format.js +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +3 -1
- package/dist/src/modules/plugins.d.ts +2 -10
- package/dist/src/parsers/angular.js +13 -13
- package/dist/src/parsers/builder.d.ts +1 -1
- package/dist/src/parsers/builder.js +56 -59
- package/dist/src/parsers/context.js +2 -2
- package/dist/src/parsers/jsx.js +59 -87
- package/dist/src/parsers/liquid.js +193 -195
- package/dist/src/plugins/compile-away-builder-components.d.ts +1 -1
- package/dist/src/plugins/compile-away-builder-components.js +337 -92
- package/dist/src/plugins/compile-away-components.js +3 -3
- package/dist/src/plugins/map-styles.js +3 -3
- package/dist/src/targets.d.ts +24 -0
- package/dist/src/targets.js +30 -0
- package/dist/src/types/config.d.ts +31 -0
- package/dist/src/types/{jsx-lite-component.js → config.js} +0 -0
- package/dist/src/types/generators.d.ts +0 -0
- package/dist/src/types/generators.js +1 -0
- package/dist/src/types/plugins.d.ts +11 -0
- package/dist/src/types/{jsx-lite-context.js → plugins.js} +0 -0
- package/dist/test/qwik/Accordion/high.jsx +1 -0
- package/dist/test/qwik/Accordion/low.jsx +92 -0
- package/dist/test/qwik/Accordion/med.jsx +9 -0
- package/dist/test/qwik/For/high.jsx +1 -0
- package/dist/test/qwik/For/low.jsx +55 -0
- package/dist/test/qwik/For/med.jsx +9 -0
- package/dist/test/qwik/Image/high.js +1 -0
- package/dist/test/qwik/Image/low.js +68 -0
- package/dist/test/qwik/Image/med.js +9 -0
- package/dist/test/qwik/Image.slow/high.js +1 -0
- package/dist/test/qwik/Image.slow/low.js +68 -0
- package/dist/test/qwik/Image.slow/med.js +9 -0
- package/dist/test/qwik/button/high.js +8 -0
- package/dist/test/qwik/button/low.js +34 -0
- package/dist/test/qwik/button/med.js +9 -0
- package/dist/test/qwik/hello_world/stylesheet/high.jsx +1 -0
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +24 -0
- package/dist/test/qwik/hello_world/stylesheet/med.jsx +9 -0
- package/dist/test/qwik/page-with-symbol/high.js +1 -0
- package/dist/test/qwik/page-with-symbol/low.js +49 -0
- package/dist/test/qwik/page-with-symbol/med.js +9 -0
- package/dist/test/qwik/svg/high.js +1 -0
- package/dist/test/qwik/svg/low.js +30 -0
- package/dist/test/qwik/svg/med.js +9 -0
- package/dist/test/qwik/todo/Todo.cjs/high.cjs +31 -0
- package/dist/test/qwik/todo/Todo.cjs/low.cjs +1 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +59 -0
- package/dist/test/qwik/todo/Todo.js/high.js +5 -0
- package/dist/test/qwik/todo/Todo.js/low.js +0 -0
- package/dist/test/qwik/todo/Todo.js/med.js +1 -0
- package/dist/test/qwik/todo/Todo.tsx/high.tsx +30 -0
- package/dist/test/qwik/todo/Todo.tsx/low.tsx +1 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +34 -0
- package/dist/test/qwik/todos/Todo.tsx/high.tsx +12 -0
- package/dist/test/qwik/todos/Todo.tsx/low.tsx +25 -0
- package/dist/test/qwik/todos/Todo.tsx/med.tsx +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/CHANGELOG.md +0 -4
- package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +0 -11
- package/dist/src/__tests__/data/blocks/tabs.raw.jsx +0 -24
- package/dist/src/__tests__/qoot.test.d.ts +0 -1
- package/dist/src/__tests__/qoot.test.js +0 -115
- package/dist/src/generators/jsx-lite.d.ts +0 -10
- package/dist/src/generators/jsx-lite.js +0 -176
- package/dist/src/generators/qoot.d.ts +0 -21
- package/dist/src/generators/qoot.js +0 -442
- package/dist/src/generators/qwik.d.ts +0 -21
- package/dist/src/generators/qwik.js +0 -458
- package/dist/src/helpers/create-jsx-lite-component.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-component.js +0 -16
- package/dist/src/helpers/create-jsx-lite-context.d.ts +0 -4
- package/dist/src/helpers/create-jsx-lite-context.js +0 -18
- package/dist/src/helpers/create-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-node.js +0 -16
- package/dist/src/helpers/is-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/is-jsx-lite-node.js +0 -7
- package/dist/src/types/jsx-lite-component.d.ts +0 -63
- package/dist/src/types/jsx-lite-context.d.ts +0 -6
- package/dist/src/types/jsx-lite-node.d.ts +0 -13
- package/dist/src/types/jsx-lite-node.js +0 -2
- package/dist/src/types/jsx-lite-styles.d.ts +0 -1
- package/dist/src/types/jsx-lite-styles.js +0 -2
- package/dist/test/qoot/Todo/bundle.js +0 -88
- package/dist/test/qoot/Todo/component.ts +0 -17
- package/dist/test/qoot/Todo/onButtonClick.ts +0 -13
- package/dist/test/qoot/Todo/onInput2Blur.ts +0 -11
- package/dist/test/qoot/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qoot/Todo/onInputClick.ts +0 -10
- package/dist/test/qoot/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qoot/Todo/public.ts +0 -4
- package/dist/test/qoot/Todo/template.tsx +0 -46
- package/dist/test/qoot/Todos/component.ts +0 -9
- package/dist/test/qoot/Todos/onInputClick.ts +0 -14
- package/dist/test/qoot/Todos/public.ts +0 -3
- package/dist/test/qoot/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todo/bundle.js +0 -46
- package/dist/test/qwik/Todo/component.ts +0 -17
- package/dist/test/qwik/Todo/onButtonClick.ts +0 -10
- package/dist/test/qwik/Todo/onInput2Blur.ts +0 -14
- package/dist/test/qwik/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo/onInputClick.ts +0 -13
- package/dist/test/qwik/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qwik/Todo/public.ts +0 -3
- package/dist/test/qwik/Todo/template.tsx +0 -46
- package/dist/test/qwik/Todo.ts +0 -4
- package/dist/test/qwik/Todo_component.ts +0 -14
- package/dist/test/qwik/Todo_onButtonClick.ts +0 -10
- package/dist/test/qwik/Todo_onInput2Blur.ts +0 -11
- package/dist/test/qwik/Todo_onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo_onInputClick.ts +0 -10
- package/dist/test/qwik/Todo_onLabelDblClick.ts +0 -11
- package/dist/test/qwik/Todo_template.tsx +0 -46
- package/dist/test/qwik/Todos/component.ts +0 -9
- package/dist/test/qwik/Todos/onInputClick.ts +0 -14
- package/dist/test/qwik/Todos/public.ts +0 -3
- package/dist/test/qwik/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todos.ts +0 -3
- package/dist/test/qwik/Todos_component.ts +0 -9
- package/dist/test/qwik/Todos_onInputClick.ts +0 -14
- package/dist/test/qwik/Todos_template.tsx +0 -30
|
@@ -20,83 +20,83 @@ var image = require('./data/blocks/image.raw');
|
|
|
20
20
|
var columns = require('./data/blocks/columns.raw');
|
|
21
21
|
describe('Solid', function () {
|
|
22
22
|
test('Basic', function () {
|
|
23
|
-
var
|
|
24
|
-
var output = solid_1.componentToSolid(
|
|
23
|
+
var component = (0, jsx_1.parseJsx)(basic);
|
|
24
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
25
25
|
expect(output).toMatchSnapshot();
|
|
26
26
|
});
|
|
27
27
|
test('Input block', function () {
|
|
28
|
-
var
|
|
29
|
-
var output = solid_1.componentToSolid(
|
|
28
|
+
var component = (0, jsx_1.parseJsx)(inputBlock);
|
|
29
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
30
30
|
expect(output).toMatchSnapshot();
|
|
31
31
|
});
|
|
32
32
|
test('Submit button block', function () {
|
|
33
|
-
var
|
|
34
|
-
var output = solid_1.componentToSolid(
|
|
33
|
+
var component = (0, jsx_1.parseJsx)(submitButtonBlock);
|
|
34
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
35
35
|
expect(output).toMatchSnapshot();
|
|
36
36
|
});
|
|
37
37
|
test('Select block', function () {
|
|
38
|
-
var
|
|
39
|
-
var output = solid_1.componentToSolid(
|
|
38
|
+
var component = (0, jsx_1.parseJsx)(selectBlock);
|
|
39
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
40
40
|
expect(output).toMatchSnapshot();
|
|
41
41
|
});
|
|
42
42
|
test('Form block', function () {
|
|
43
|
-
var
|
|
44
|
-
var output = solid_1.componentToSolid(
|
|
43
|
+
var component = (0, jsx_1.parseJsx)(formBlock);
|
|
44
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
45
45
|
expect(output).toMatchSnapshot();
|
|
46
46
|
});
|
|
47
47
|
test('Button', function () {
|
|
48
|
-
var
|
|
49
|
-
var output = solid_1.componentToSolid(
|
|
48
|
+
var component = (0, jsx_1.parseJsx)(button);
|
|
49
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
50
50
|
expect(output).toMatchSnapshot();
|
|
51
51
|
});
|
|
52
52
|
test('Textarea', function () {
|
|
53
|
-
var
|
|
54
|
-
var output = solid_1.componentToSolid(
|
|
53
|
+
var component = (0, jsx_1.parseJsx)(textarea);
|
|
54
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
55
55
|
expect(output).toMatchSnapshot();
|
|
56
56
|
});
|
|
57
57
|
test('Img', function () {
|
|
58
|
-
var
|
|
59
|
-
var output = solid_1.componentToSolid(
|
|
58
|
+
var component = (0, jsx_1.parseJsx)(img);
|
|
59
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
60
60
|
expect(output).toMatchSnapshot();
|
|
61
61
|
});
|
|
62
62
|
test('Video', function () {
|
|
63
|
-
var
|
|
64
|
-
var output = solid_1.componentToSolid(
|
|
63
|
+
var component = (0, jsx_1.parseJsx)(video);
|
|
64
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
65
65
|
expect(output).toMatchSnapshot();
|
|
66
66
|
});
|
|
67
67
|
test('Section', function () {
|
|
68
|
-
var
|
|
69
|
-
var output = solid_1.componentToSolid(
|
|
68
|
+
var component = (0, jsx_1.parseJsx)(section);
|
|
69
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
70
70
|
expect(output).toMatchSnapshot();
|
|
71
71
|
});
|
|
72
72
|
test('Text', function () {
|
|
73
|
-
var
|
|
74
|
-
var output = solid_1.componentToSolid(
|
|
73
|
+
var component = (0, jsx_1.parseJsx)(text);
|
|
74
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
75
75
|
expect(output).toMatchSnapshot();
|
|
76
76
|
});
|
|
77
77
|
test('RawText', function () {
|
|
78
|
-
var
|
|
79
|
-
var output = solid_1.componentToSolid(
|
|
78
|
+
var component = (0, jsx_1.parseJsx)(rawText);
|
|
79
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
80
80
|
expect(output).toMatchSnapshot();
|
|
81
81
|
});
|
|
82
82
|
test('CustomCode', function () {
|
|
83
|
-
var
|
|
84
|
-
var output = solid_1.componentToSolid(
|
|
83
|
+
var component = (0, jsx_1.parseJsx)(customCode);
|
|
84
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
85
85
|
expect(output).toMatchSnapshot();
|
|
86
86
|
});
|
|
87
87
|
test('Embed', function () {
|
|
88
|
-
var
|
|
89
|
-
var output = solid_1.componentToSolid(
|
|
88
|
+
var component = (0, jsx_1.parseJsx)(customCode);
|
|
89
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
90
90
|
expect(output).toMatchSnapshot();
|
|
91
91
|
});
|
|
92
92
|
test('Image', function () {
|
|
93
|
-
var
|
|
94
|
-
var output = solid_1.componentToSolid(
|
|
93
|
+
var component = (0, jsx_1.parseJsx)(image);
|
|
94
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
95
95
|
expect(output).toMatchSnapshot();
|
|
96
96
|
});
|
|
97
97
|
test('Columns', function () {
|
|
98
|
-
var
|
|
99
|
-
var output = solid_1.componentToSolid(
|
|
98
|
+
var component = (0, jsx_1.parseJsx)(columns);
|
|
99
|
+
var output = (0, solid_1.componentToSolid)()({ component: component });
|
|
100
100
|
expect(output).toMatchSnapshot();
|
|
101
101
|
});
|
|
102
102
|
});
|
|
@@ -19,90 +19,91 @@ var customCode = require('./data/blocks/custom-code.raw');
|
|
|
19
19
|
var embed = require('./data/blocks/embed.raw');
|
|
20
20
|
var image = require('./data/blocks/image.raw');
|
|
21
21
|
var columns = require('./data/blocks/columns.raw');
|
|
22
|
+
var path = 'test-path';
|
|
22
23
|
describe('Vue', function () {
|
|
23
24
|
test('Basic', function () {
|
|
24
|
-
var
|
|
25
|
-
var output = vue_1.componentToVue(
|
|
25
|
+
var component = (0, jsx_1.parseJsx)(basic);
|
|
26
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
26
27
|
expect(output).toMatchSnapshot();
|
|
27
28
|
});
|
|
28
29
|
test('Input block', function () {
|
|
29
|
-
var
|
|
30
|
-
var output = vue_1.componentToVue(
|
|
30
|
+
var component = (0, jsx_1.parseJsx)(inputBlock);
|
|
31
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
31
32
|
expect(output).toMatchSnapshot();
|
|
32
33
|
});
|
|
33
34
|
test('Submit button block', function () {
|
|
34
|
-
var
|
|
35
|
-
var output = vue_1.componentToVue(
|
|
35
|
+
var component = (0, jsx_1.parseJsx)(submitButtonBlock);
|
|
36
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
36
37
|
expect(output).toMatchSnapshot();
|
|
37
38
|
});
|
|
38
39
|
test('Select block', function () {
|
|
39
|
-
var
|
|
40
|
-
var output = vue_1.componentToVue(
|
|
40
|
+
var component = (0, jsx_1.parseJsx)(selectBlock);
|
|
41
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
41
42
|
expect(output).toMatchSnapshot();
|
|
42
43
|
});
|
|
43
44
|
test('Form block', function () {
|
|
44
|
-
var
|
|
45
|
-
var output = vue_1.componentToVue(
|
|
45
|
+
var component = (0, jsx_1.parseJsx)(formBlock);
|
|
46
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
46
47
|
expect(output).toMatchSnapshot();
|
|
47
48
|
});
|
|
48
49
|
test('Button', function () {
|
|
49
|
-
var
|
|
50
|
-
var output = vue_1.componentToVue(
|
|
50
|
+
var component = (0, jsx_1.parseJsx)(button);
|
|
51
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
51
52
|
expect(output).toMatchSnapshot();
|
|
52
53
|
});
|
|
53
54
|
test('Textarea', function () {
|
|
54
|
-
var
|
|
55
|
-
var output = vue_1.componentToVue(
|
|
55
|
+
var component = (0, jsx_1.parseJsx)(textarea);
|
|
56
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
56
57
|
expect(output).toMatchSnapshot();
|
|
57
58
|
});
|
|
58
59
|
test('Img', function () {
|
|
59
|
-
var
|
|
60
|
-
var output = vue_1.componentToVue(
|
|
60
|
+
var component = (0, jsx_1.parseJsx)(img);
|
|
61
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
61
62
|
expect(output).toMatchSnapshot();
|
|
62
63
|
});
|
|
63
64
|
test('Video', function () {
|
|
64
|
-
var
|
|
65
|
-
var output = vue_1.componentToVue(
|
|
65
|
+
var component = (0, jsx_1.parseJsx)(video);
|
|
66
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
66
67
|
expect(output).toMatchSnapshot();
|
|
67
68
|
});
|
|
68
69
|
test('Section', function () {
|
|
69
|
-
var
|
|
70
|
-
var output = vue_1.componentToVue(
|
|
70
|
+
var component = (0, jsx_1.parseJsx)(section);
|
|
71
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
71
72
|
expect(output).toMatchSnapshot();
|
|
72
73
|
});
|
|
73
74
|
test('Text', function () {
|
|
74
|
-
var
|
|
75
|
-
var output = vue_1.componentToVue(
|
|
75
|
+
var component = (0, jsx_1.parseJsx)(text);
|
|
76
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
76
77
|
expect(output).toMatchSnapshot();
|
|
77
78
|
});
|
|
78
79
|
test('RawText', function () {
|
|
79
|
-
var
|
|
80
|
-
var output = vue_1.componentToVue(
|
|
80
|
+
var component = (0, jsx_1.parseJsx)(rawText);
|
|
81
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
81
82
|
expect(output).toMatchSnapshot();
|
|
82
83
|
});
|
|
83
84
|
test('Stamped.io', function () {
|
|
84
|
-
var
|
|
85
|
-
var output = vue_1.componentToVue(
|
|
85
|
+
var component = (0, jsx_1.parseJsx)(stamped);
|
|
86
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
86
87
|
expect(output).toMatchSnapshot();
|
|
87
88
|
});
|
|
88
89
|
test('CustomCode', function () {
|
|
89
|
-
var
|
|
90
|
-
var output = vue_1.componentToVue(
|
|
90
|
+
var component = (0, jsx_1.parseJsx)(customCode);
|
|
91
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
91
92
|
expect(output).toMatchSnapshot();
|
|
92
93
|
});
|
|
93
94
|
test('Embed', function () {
|
|
94
|
-
var
|
|
95
|
-
var output = vue_1.componentToVue(
|
|
95
|
+
var component = (0, jsx_1.parseJsx)(customCode);
|
|
96
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
96
97
|
expect(output).toMatchSnapshot();
|
|
97
98
|
});
|
|
98
99
|
test('Image', function () {
|
|
99
|
-
var
|
|
100
|
-
var output = vue_1.componentToVue(
|
|
100
|
+
var component = (0, jsx_1.parseJsx)(image);
|
|
101
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
101
102
|
expect(output).toMatchSnapshot();
|
|
102
103
|
});
|
|
103
104
|
test('Columns', function () {
|
|
104
|
-
var
|
|
105
|
-
var output = vue_1.componentToVue(
|
|
105
|
+
var component = (0, jsx_1.parseJsx)(columns);
|
|
106
|
+
var output = (0, vue_1.componentToVue)()({ component: component, path: path });
|
|
106
107
|
expect(output).toMatchSnapshot();
|
|
107
108
|
});
|
|
108
109
|
});
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { MitosisComponent } from '../types/mitosis-component';
|
|
2
1
|
import { MitosisNode } from '../types/mitosis-node';
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
plugins?: Plugin[];
|
|
7
|
-
};
|
|
2
|
+
import { BaseTranspilerOptions, Transpiler } from '../types/config';
|
|
3
|
+
export interface ToAngularOptions extends BaseTranspilerOptions {
|
|
4
|
+
}
|
|
8
5
|
export declare const blockToAngular: (json: MitosisNode, options?: ToAngularOptions) => string;
|
|
9
|
-
export declare const componentToAngular: (
|
|
6
|
+
export declare const componentToAngular: (options?: ToAngularOptions) => Transpiler;
|
|
@@ -26,9 +26,9 @@ var strip_meta_properties_1 = require("../helpers/strip-meta-properties");
|
|
|
26
26
|
var remove_surrounding_block_1 = require("../helpers/remove-surrounding-block");
|
|
27
27
|
var mappers = {
|
|
28
28
|
Fragment: function (json, options) {
|
|
29
|
-
return "<div>"
|
|
30
|
-
.map(function (item) { return exports.blockToAngular(item, options); })
|
|
31
|
-
.join('\n')
|
|
29
|
+
return "<div>".concat(json.children
|
|
30
|
+
.map(function (item) { return (0, exports.blockToAngular)(item, options); })
|
|
31
|
+
.join('\n'), "</div>");
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
var blockToAngular = function (json, options) {
|
|
@@ -36,32 +36,32 @@ var blockToAngular = function (json, options) {
|
|
|
36
36
|
if (mappers[json.name]) {
|
|
37
37
|
return mappers[json.name](json, options);
|
|
38
38
|
}
|
|
39
|
-
if (is_children_1.default(json)) {
|
|
39
|
+
if ((0, is_children_1.default)(json)) {
|
|
40
40
|
return "<ng-slot></ng-slot>";
|
|
41
41
|
}
|
|
42
42
|
if (json.properties._text) {
|
|
43
43
|
return json.properties._text;
|
|
44
44
|
}
|
|
45
45
|
if (json.bindings._text) {
|
|
46
|
-
return "{{"
|
|
46
|
+
return "{{".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings._text), "}}");
|
|
47
47
|
}
|
|
48
48
|
var str = '';
|
|
49
49
|
if (json.name === 'For') {
|
|
50
|
-
str += "<ng-container *ngFor=\"let "
|
|
50
|
+
str += "<ng-container *ngFor=\"let ".concat(json.properties._forName, " of ").concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings.each), "\">");
|
|
51
51
|
str += json.children
|
|
52
|
-
.map(function (item) { return exports.blockToAngular(item, options); })
|
|
52
|
+
.map(function (item) { return (0, exports.blockToAngular)(item, options); })
|
|
53
53
|
.join('\n');
|
|
54
54
|
str += "</ng-container>";
|
|
55
55
|
}
|
|
56
56
|
else if (json.name === 'Show') {
|
|
57
|
-
str += "<ng-container *ngIf=\""
|
|
57
|
+
str += "<ng-container *ngIf=\"".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings.when), "\">");
|
|
58
58
|
str += json.children
|
|
59
|
-
.map(function (item) { return exports.blockToAngular(item, options); })
|
|
59
|
+
.map(function (item) { return (0, exports.blockToAngular)(item, options); })
|
|
60
60
|
.join('\n');
|
|
61
61
|
str += "</ng-container>";
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
-
str += "<"
|
|
64
|
+
str += "<".concat(json.name, " ");
|
|
65
65
|
// TODO: spread support for angular
|
|
66
66
|
// if (json.bindings._spread) {
|
|
67
67
|
// str += `v-bind="${stripStateAndPropsRefs(
|
|
@@ -73,7 +73,7 @@ var blockToAngular = function (json, options) {
|
|
|
73
73
|
continue;
|
|
74
74
|
}
|
|
75
75
|
var value = json.properties[key];
|
|
76
|
-
str += " "
|
|
76
|
+
str += " ".concat(key, "=\"").concat(value, "\" ");
|
|
77
77
|
}
|
|
78
78
|
for (var key in json.bindings) {
|
|
79
79
|
if (key === '_spread') {
|
|
@@ -84,7 +84,7 @@ var blockToAngular = function (json, options) {
|
|
|
84
84
|
}
|
|
85
85
|
var value = json.bindings[key];
|
|
86
86
|
// TODO: proper babel transform to replace. Util for this
|
|
87
|
-
var useValue = strip_state_and_props_refs_1.stripStateAndPropsRefs(value);
|
|
87
|
+
var useValue = (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(value);
|
|
88
88
|
if (key.startsWith('on')) {
|
|
89
89
|
var event_1 = key.replace('on', '').toLowerCase();
|
|
90
90
|
if (event_1 === 'change' &&
|
|
@@ -92,14 +92,14 @@ var blockToAngular = function (json, options) {
|
|
|
92
92
|
event_1 = 'input';
|
|
93
93
|
}
|
|
94
94
|
// TODO: proper babel transform to replace. Util for this
|
|
95
|
-
var finalValue = remove_surrounding_block_1.removeSurroundingBlock(useValue.replace(/event\./g, '$event.'));
|
|
96
|
-
str += " ("
|
|
95
|
+
var finalValue = (0, remove_surrounding_block_1.removeSurroundingBlock)(useValue.replace(/event\./g, '$event.'));
|
|
96
|
+
str += " (".concat(event_1, ")=\"").concat(finalValue, "\" ");
|
|
97
97
|
}
|
|
98
98
|
else if (key === 'ref') {
|
|
99
|
-
str += " #"
|
|
99
|
+
str += " #".concat(useValue, " ");
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
|
-
str += " ["
|
|
102
|
+
str += " [".concat(key, "]=\"").concat(useValue, "\" ");
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
if (jsx_1.selfClosingTags.has(json.name)) {
|
|
@@ -108,85 +108,81 @@ var blockToAngular = function (json, options) {
|
|
|
108
108
|
str += '>';
|
|
109
109
|
if (json.children) {
|
|
110
110
|
str += json.children
|
|
111
|
-
.map(function (item) { return exports.blockToAngular(item, options); })
|
|
111
|
+
.map(function (item) { return (0, exports.blockToAngular)(item, options); })
|
|
112
112
|
.join('\n');
|
|
113
113
|
}
|
|
114
|
-
str += "</"
|
|
114
|
+
str += "</".concat(json.name, ">");
|
|
115
115
|
}
|
|
116
116
|
return str;
|
|
117
117
|
};
|
|
118
118
|
exports.blockToAngular = blockToAngular;
|
|
119
119
|
var indent = function (str, spaces) {
|
|
120
120
|
if (spaces === void 0) { spaces = 4; }
|
|
121
|
-
return str.replace(/\n([^\n])/g, "\n"
|
|
121
|
+
return str.replace(/\n([^\n])/g, "\n".concat(' '.repeat(spaces), "$1"));
|
|
122
122
|
};
|
|
123
|
-
var componentToAngular = function (
|
|
123
|
+
var componentToAngular = function (options) {
|
|
124
124
|
if (options === void 0) { options = {}; }
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
json =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
json
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
css =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
template =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"\n \\`,\n ",
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
if (options.plugins) {
|
|
182
|
-
str = plugins_1.runPostCodePlugins(str, options.plugins);
|
|
183
|
-
}
|
|
184
|
-
return str;
|
|
125
|
+
return function (_a) {
|
|
126
|
+
var component = _a.component;
|
|
127
|
+
// Make a copy we can safely mutate, similar to babel's toolchain
|
|
128
|
+
var json = (0, fast_clone_1.fastClone)(component);
|
|
129
|
+
if (options.plugins) {
|
|
130
|
+
json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
|
|
131
|
+
}
|
|
132
|
+
var props = (0, get_props_1.getProps)(component);
|
|
133
|
+
var refs = Array.from((0, get_refs_1.getRefs)(json));
|
|
134
|
+
(0, map_refs_1.mapRefs)(json, function (refName) { return "this.".concat(refName, ".nativeElement"); });
|
|
135
|
+
if (options.plugins) {
|
|
136
|
+
json = (0, plugins_1.runPostJsonPlugins)(json, options.plugins);
|
|
137
|
+
}
|
|
138
|
+
var css = (0, collect_styles_1.collectCss)(json);
|
|
139
|
+
if (options.prettier !== false) {
|
|
140
|
+
css = tryFormat(css, 'css');
|
|
141
|
+
}
|
|
142
|
+
var template = json.children.map(function (item) { return (0, exports.blockToAngular)(item); }).join('\n');
|
|
143
|
+
if (options.prettier !== false) {
|
|
144
|
+
template = tryFormat(template, 'html');
|
|
145
|
+
}
|
|
146
|
+
(0, strip_meta_properties_1.stripMetaProperties)(json);
|
|
147
|
+
var dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
|
|
148
|
+
format: 'class',
|
|
149
|
+
valueMapper: function (code) {
|
|
150
|
+
return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(code, { replaceWith: 'this.' });
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: `\n ", "\n `,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n }\n "], ["\n import { Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: \\`\n ", "\n \\`,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n }\n "])), refs.length ? ', ViewChild, ElementRef' : '', props.size ? ', Input' : '', (0, render_imports_1.renderPreComponent)(json), (0, lodash_1.kebabCase)(json.name || 'my-component'), indent(template, 8)
|
|
154
|
+
.replace(/`/g, '\\`')
|
|
155
|
+
.replace(/\$\{/g, '\\${'), css.length
|
|
156
|
+
? "styles: [\n `".concat(indent(css, 8), "`\n ],")
|
|
157
|
+
: '', component.name, Array.from(props)
|
|
158
|
+
.map(function (item) { return "@Input() ".concat(item, ": any"); })
|
|
159
|
+
.join('\n'), refs
|
|
160
|
+
.map(function (refName) { return "@ViewChild('".concat(refName, "') ").concat(refName, ": ElementRef"); })
|
|
161
|
+
.join('\n'), !component.hooks.onMount
|
|
162
|
+
? ''
|
|
163
|
+
: "ngOnInit() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(component.hooks.onMount, {
|
|
164
|
+
replaceWith: 'this.',
|
|
165
|
+
}), "\n }"), !component.hooks.onUnMount
|
|
166
|
+
? ''
|
|
167
|
+
: "ngOnDestroy() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(component.hooks.onUnMount, {
|
|
168
|
+
replaceWith: 'this.',
|
|
169
|
+
}), "\n }"), dataString);
|
|
170
|
+
if (options.plugins) {
|
|
171
|
+
str = (0, plugins_1.runPreCodePlugins)(str, options.plugins);
|
|
172
|
+
}
|
|
173
|
+
if (options.prettier !== false) {
|
|
174
|
+
str = tryFormat(str, 'typescript');
|
|
175
|
+
}
|
|
176
|
+
if (options.plugins) {
|
|
177
|
+
str = (0, plugins_1.runPostCodePlugins)(str, options.plugins);
|
|
178
|
+
}
|
|
179
|
+
return str;
|
|
180
|
+
};
|
|
185
181
|
};
|
|
186
182
|
exports.componentToAngular = componentToAngular;
|
|
187
183
|
var tryFormat = function (str, parser) {
|
|
188
184
|
try {
|
|
189
|
-
return standalone_1.format(str, {
|
|
185
|
+
return (0, standalone_1.format)(str, {
|
|
190
186
|
parser: parser,
|
|
191
187
|
plugins: [
|
|
192
188
|
// To support running in browsers
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { MitosisComponent } from '../types/mitosis-component';
|
|
2
1
|
import { MitosisNode } from '../types/mitosis-node';
|
|
3
2
|
import { BuilderElement } from '@builder.io/sdk';
|
|
4
|
-
|
|
3
|
+
import { TranspilerArgs } from '../types/config';
|
|
4
|
+
export interface ToBuilderOptions {
|
|
5
5
|
includeIds?: boolean;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
declare type InternalOptions = {
|
|
8
8
|
skipMapper?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare const blockToBuilder: (json: MitosisNode, options?: ToBuilderOptions, _internalOptions?: InternalOptions) => BuilderElement;
|
|
11
|
-
export declare const componentToBuilder: (
|
|
11
|
+
export declare const componentToBuilder: (options?: ToBuilderOptions) => ({ component, }: TranspilerArgs) => {
|
|
12
12
|
data: {
|
|
13
13
|
httpRequests: any;
|
|
14
14
|
jsCode: string;
|