@builder.io/mitosis 0.4.0 → 0.4.2
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/constants/media-sizes.js +4 -5
- package/dist/src/generators/alpine/generate.js +114 -132
- package/dist/src/generators/alpine/render-mount-hook.js +8 -5
- package/dist/src/generators/alpine/render-update-hooks.js +13 -13
- package/dist/src/generators/angular/helpers.js +19 -9
- package/dist/src/generators/angular/index.js +599 -584
- package/dist/src/generators/builder.js +200 -165
- package/dist/src/generators/context/angular.js +32 -26
- package/dist/src/generators/context/helpers/context-with-symbol-key.js +25 -21
- package/dist/src/generators/context/qwik.js +21 -21
- package/dist/src/generators/context/react.js +22 -22
- package/dist/src/generators/context/rsc.js +20 -22
- package/dist/src/generators/context/solid.js +22 -22
- package/dist/src/generators/context/svelte.js +33 -28
- package/dist/src/generators/context/vue.js +1 -1
- package/dist/src/generators/helpers/context.js +6 -13
- package/dist/src/generators/helpers/functions.js +8 -8
- package/dist/src/generators/helpers/on-mount.js +9 -5
- package/dist/src/generators/helpers/rsc.js +7 -9
- package/dist/src/generators/html.js +995 -534
- package/dist/src/generators/liquid.js +81 -79
- package/dist/src/generators/lit/collect-class-string.js +10 -12
- package/dist/src/generators/lit/generate.js +204 -159
- package/dist/src/generators/marko/generate.js +193 -183
- package/dist/src/generators/minify.js +5 -9
- package/dist/src/generators/mitosis.js +135 -134
- package/dist/src/generators/qwik/component-generator.js +159 -154
- package/dist/src/generators/qwik/component.js +51 -81
- package/dist/src/generators/qwik/directives.js +68 -84
- package/dist/src/generators/qwik/helpers/add-prevent-default.js +6 -7
- package/dist/src/generators/qwik/helpers/convert-method-to-function.js +38 -38
- package/dist/src/generators/qwik/helpers/handlers.js +16 -25
- package/dist/src/generators/qwik/helpers/stable-inject.js +7 -8
- package/dist/src/generators/qwik/helpers/stable-serialize.js +7 -8
- package/dist/src/generators/qwik/helpers/state.js +36 -43
- package/dist/src/generators/qwik/helpers/styles.js +19 -40
- package/dist/src/generators/qwik/jsx.js +63 -75
- package/dist/src/generators/qwik/src-generator.js +134 -167
- package/dist/src/generators/react/blocks.js +122 -127
- package/dist/src/generators/react/generator.js +314 -259
- package/dist/src/generators/react/helpers.js +23 -28
- package/dist/src/generators/react/state.js +34 -51
- package/dist/src/generators/react-native/index.js +72 -84
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +14 -26
- package/dist/src/generators/rsc.js +30 -36
- package/dist/src/generators/solid/blocks.js +46 -43
- package/dist/src/generators/solid/helpers/styles.js +11 -11
- package/dist/src/generators/solid/index.js +199 -190
- package/dist/src/generators/solid/state/helpers.js +76 -90
- package/dist/src/generators/solid/state/signals.js +30 -37
- package/dist/src/generators/solid/state/state.js +35 -48
- package/dist/src/generators/solid/state/store.js +40 -46
- package/dist/src/generators/stencil/collect-class-string.js +10 -12
- package/dist/src/generators/stencil/generate.js +158 -145
- package/dist/src/generators/svelte/blocks.js +146 -144
- package/dist/src/generators/svelte/helpers.js +10 -17
- package/dist/src/generators/svelte/svelte.js +321 -287
- package/dist/src/generators/swift-ui.js +162 -101
- package/dist/src/generators/taro.js +32 -36
- package/dist/src/generators/template.js +71 -74
- package/dist/src/generators/vue/blocks.js +116 -107
- package/dist/src/generators/vue/compositionApi.js +67 -50
- package/dist/src/generators/vue/helpers.js +71 -96
- package/dist/src/generators/vue/optionsApi.js +134 -105
- package/dist/src/generators/vue/vue.js +210 -207
- package/dist/src/helpers/babel-transform.js +40 -63
- package/dist/src/helpers/bindings.js +4 -12
- package/dist/src/helpers/camel-case.js +4 -5
- package/dist/src/helpers/capitalize.js +1 -1
- package/dist/src/helpers/component-file-extensions.js +23 -35
- package/dist/src/helpers/create-mitosis-component.js +22 -26
- package/dist/src/helpers/create-mitosis-context.js +5 -12
- package/dist/src/helpers/create-mitosis-node.js +10 -12
- package/dist/src/helpers/dash-case.js +2 -2
- package/dist/src/helpers/dedent.js +18 -22
- package/dist/src/helpers/event-handlers.js +1 -1
- package/dist/src/helpers/fast-clone.js +1 -1
- package/dist/src/helpers/filter-empty-text-nodes.js +2 -2
- package/dist/src/helpers/generic-format.js +7 -8
- package/dist/src/helpers/get-bindings.js +4 -4
- package/dist/src/helpers/get-components-used.js +3 -3
- package/dist/src/helpers/get-components.js +4 -4
- package/dist/src/helpers/get-custom-imports.js +10 -12
- package/dist/src/helpers/get-prop-functions.js +7 -8
- package/dist/src/helpers/get-props-ref.js +8 -8
- package/dist/src/helpers/get-props.js +12 -13
- package/dist/src/helpers/get-refs.js +4 -4
- package/dist/src/helpers/get-state-object-string.js +42 -61
- package/dist/src/helpers/get-state-used.js +7 -8
- package/dist/src/helpers/get-styles.js +6 -6
- package/dist/src/helpers/getters-to-functions.js +8 -12
- package/dist/src/helpers/handle-missing-state.js +3 -3
- package/dist/src/helpers/has-bindings-text.js +6 -6
- package/dist/src/helpers/has-component.js +4 -4
- package/dist/src/helpers/has-props.js +3 -3
- package/dist/src/helpers/has-stateful-dom.js +4 -4
- package/dist/src/helpers/has.js +3 -3
- package/dist/src/helpers/indent.js +2 -3
- package/dist/src/helpers/is-children.js +4 -5
- package/dist/src/helpers/is-component.js +1 -1
- package/dist/src/helpers/is-html-attribute.js +2 -11
- package/dist/src/helpers/is-mitosis-node.js +1 -1
- package/dist/src/helpers/is-root-text-node.js +1 -1
- package/dist/src/helpers/is-upper-case.js +1 -1
- package/dist/src/helpers/is-valid-attribute-name.js +1 -1
- package/dist/src/helpers/json.js +2 -2
- package/dist/src/helpers/map-refs.js +29 -40
- package/dist/src/helpers/merge-options.js +20 -31
- package/dist/src/helpers/mitosis-imports.js +5 -6
- package/dist/src/helpers/nodes/for.js +2 -3
- package/dist/src/helpers/nullable.js +1 -3
- package/dist/src/helpers/on-event.js +32 -36
- package/dist/src/helpers/output.js +4 -5
- package/dist/src/helpers/parse-node.js +13 -5
- package/dist/src/helpers/parsers.js +10 -14
- package/dist/src/helpers/patterns.js +6 -8
- package/dist/src/helpers/plugins/process-code/index.js +114 -120
- package/dist/src/helpers/plugins/process-signals.js +114 -125
- package/dist/src/helpers/plugins/process-target-blocks.js +18 -20
- package/dist/src/helpers/process-http-requests.js +8 -4
- package/dist/src/helpers/remove-surrounding-block.js +2 -2
- package/dist/src/helpers/render-imports.js +99 -111
- package/dist/src/helpers/replace-identifiers.js +40 -49
- package/dist/src/helpers/replace-new-lines-in-strings.js +3 -3
- package/dist/src/helpers/signals/signals.js +27 -35
- package/dist/src/helpers/slots.js +11 -20
- package/dist/src/helpers/state.js +1 -3
- package/dist/src/helpers/strip-meta-properties.js +6 -6
- package/dist/src/helpers/strip-state-and-props-refs.js +21 -32
- package/dist/src/helpers/styles/collect-css.js +39 -44
- package/dist/src/helpers/styles/collect-styled-components.js +30 -28
- package/dist/src/helpers/styles/helpers.js +23 -29
- package/dist/src/helpers/trace-reference-to-module-path.js +3 -4
- package/dist/src/helpers/transform-state-setters.js +16 -19
- package/dist/src/helpers/traverse-nodes.js +2 -2
- package/dist/src/helpers/try-prettier-format.js +3 -3
- package/dist/src/helpers/typescript-project.js +25 -25
- package/dist/src/helpers/typescript.js +1 -3
- package/dist/src/modules/plugins.js +20 -28
- package/dist/src/parsers/angular.js +49 -57
- package/dist/src/parsers/builder/builder.js +448 -343
- package/dist/src/parsers/builder/helpers.js +10 -10
- package/dist/src/parsers/context.js +15 -17
- package/dist/src/parsers/jsx/ast.js +11 -11
- package/dist/src/parsers/jsx/component-types.js +22 -32
- package/dist/src/parsers/jsx/context.js +12 -12
- package/dist/src/parsers/jsx/element-parser.js +43 -54
- package/dist/src/parsers/jsx/exports.js +12 -14
- package/dist/src/parsers/jsx/function-parser.js +108 -119
- package/dist/src/parsers/jsx/helpers.js +11 -13
- package/dist/src/parsers/jsx/hooks/helpers.js +14 -16
- package/dist/src/parsers/jsx/hooks/index.js +34 -44
- package/dist/src/parsers/jsx/hooks/use-target.js +27 -27
- package/dist/src/parsers/jsx/imports.js +7 -17
- package/dist/src/parsers/jsx/jsx.js +92 -91
- package/dist/src/parsers/jsx/props-types.js +8 -10
- package/dist/src/parsers/jsx/props.js +15 -23
- package/dist/src/parsers/jsx/signals.js +28 -29
- package/dist/src/parsers/jsx/state.d.ts +2 -4
- package/dist/src/parsers/jsx/state.js +59 -93
- package/dist/src/parsers/svelte/css/index.js +1 -1
- package/dist/src/parsers/svelte/helpers/bindings.js +18 -19
- package/dist/src/parsers/svelte/helpers/children.js +5 -6
- package/dist/src/parsers/svelte/helpers/expressions.js +7 -9
- package/dist/src/parsers/svelte/helpers/hooks.js +2 -2
- package/dist/src/parsers/svelte/helpers/post-process.js +49 -70
- package/dist/src/parsers/svelte/helpers/string.js +5 -5
- package/dist/src/parsers/svelte/html/actions.js +17 -10
- package/dist/src/parsers/svelte/html/each.js +11 -16
- package/dist/src/parsers/svelte/html/element.js +68 -78
- package/dist/src/parsers/svelte/html/fragment.js +3 -3
- package/dist/src/parsers/svelte/html/if-else.js +11 -18
- package/dist/src/parsers/svelte/html/index.js +14 -14
- package/dist/src/parsers/svelte/html/mustache-tag.js +5 -5
- package/dist/src/parsers/svelte/html/slot.js +5 -5
- package/dist/src/parsers/svelte/html/text.js +7 -14
- package/dist/src/parsers/svelte/index.js +23 -72
- package/dist/src/parsers/svelte/instance/context.js +17 -17
- package/dist/src/parsers/svelte/instance/expressions.js +2 -2
- package/dist/src/parsers/svelte/instance/functions.js +35 -30
- package/dist/src/parsers/svelte/instance/hooks.js +4 -5
- package/dist/src/parsers/svelte/instance/imports.js +11 -21
- package/dist/src/parsers/svelte/instance/index.js +22 -22
- package/dist/src/parsers/svelte/instance/properties.js +11 -23
- package/dist/src/parsers/svelte/instance/reactive.js +11 -11
- package/dist/src/parsers/svelte/instance/references.js +13 -13
- package/dist/src/parsers/svelte/instance/statements.js +3 -3
- package/dist/src/parsers/svelte/module/index.js +14 -26
- package/dist/src/parsers/svelte/typescript/index.js +27 -36
- package/dist/src/plugins/compile-away-builder-components.js +223 -156
- package/dist/src/plugins/compile-away-components.js +13 -21
- package/dist/src/plugins/map-styles.js +7 -7
- package/dist/src/symbols/symbol-processor.js +44 -62
- package/dist/src/targets.js +19 -19
- package/dist/src/types/mitosis-node.js +1 -1
- package/package.json +1 -1
|
@@ -1,97 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
4
|
};
|
|
29
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
6
|
exports.componentToAngular = exports.blockToAngular = void 0;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Fragment:
|
|
69
|
-
return
|
|
70
|
-
.map(
|
|
71
|
-
.join('\n')
|
|
7
|
+
const html_tags_1 = require("../../constants/html_tags");
|
|
8
|
+
const dedent_1 = require("../../helpers/dedent");
|
|
9
|
+
const fast_clone_1 = require("../../helpers/fast-clone");
|
|
10
|
+
const get_components_used_1 = require("../../helpers/get-components-used");
|
|
11
|
+
const get_custom_imports_1 = require("../../helpers/get-custom-imports");
|
|
12
|
+
const get_prop_functions_1 = require("../../helpers/get-prop-functions");
|
|
13
|
+
const get_props_1 = require("../../helpers/get-props");
|
|
14
|
+
const get_props_ref_1 = require("../../helpers/get-props-ref");
|
|
15
|
+
const get_refs_1 = require("../../helpers/get-refs");
|
|
16
|
+
const get_state_object_string_1 = require("../../helpers/get-state-object-string");
|
|
17
|
+
const indent_1 = require("../../helpers/indent");
|
|
18
|
+
const is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
|
|
19
|
+
const is_upper_case_1 = require("../../helpers/is-upper-case");
|
|
20
|
+
const map_refs_1 = require("../../helpers/map-refs");
|
|
21
|
+
const merge_options_1 = require("../../helpers/merge-options");
|
|
22
|
+
const process_code_1 = require("../../helpers/plugins/process-code");
|
|
23
|
+
const remove_surrounding_block_1 = require("../../helpers/remove-surrounding-block");
|
|
24
|
+
const render_imports_1 = require("../../helpers/render-imports");
|
|
25
|
+
const replace_identifiers_1 = require("../../helpers/replace-identifiers");
|
|
26
|
+
const slots_1 = require("../../helpers/slots");
|
|
27
|
+
const strip_meta_properties_1 = require("../../helpers/strip-meta-properties");
|
|
28
|
+
const strip_state_and_props_refs_1 = require("../../helpers/strip-state-and-props-refs");
|
|
29
|
+
const collect_css_1 = require("../../helpers/styles/collect-css");
|
|
30
|
+
const helpers_1 = require("../../helpers/styles/helpers");
|
|
31
|
+
const traverse_nodes_1 = require("../../helpers/traverse-nodes");
|
|
32
|
+
const plugins_1 = require("../../modules/plugins");
|
|
33
|
+
const symbol_processor_1 = require("../../symbols/symbol-processor");
|
|
34
|
+
const mitosis_node_1 = require("../../types/mitosis-node");
|
|
35
|
+
const function_1 = require("fp-ts/lib/function");
|
|
36
|
+
const lodash_1 = require("lodash");
|
|
37
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
38
|
+
const standalone_1 = require("prettier/standalone");
|
|
39
|
+
const is_children_1 = __importDefault(require("../../helpers/is-children"));
|
|
40
|
+
const on_mount_1 = require("../helpers/on-mount");
|
|
41
|
+
const helpers_2 = require("./helpers");
|
|
42
|
+
const types_1 = require("./types");
|
|
43
|
+
const mappers = {
|
|
44
|
+
Fragment: (root, json, options) => {
|
|
45
|
+
return `<ng-container>${json.children
|
|
46
|
+
.map((item) => (0, exports.blockToAngular)({ root, json: item, options }))
|
|
47
|
+
.join('\n')}</ng-container>`;
|
|
72
48
|
},
|
|
73
|
-
Slot:
|
|
74
|
-
|
|
75
|
-
return
|
|
76
|
-
.map(
|
|
77
|
-
var binding = _a[0], value = _a[1];
|
|
49
|
+
Slot: (root, json, options) => {
|
|
50
|
+
const renderChildren = () => { var _a; return (_a = json.children) === null || _a === void 0 ? void 0 : _a.map((item) => (0, exports.blockToAngular)({ root, json: item, options })).join('\n'); };
|
|
51
|
+
return `<ng-content ${Object.entries({ ...json.bindings, ...json.properties })
|
|
52
|
+
.map(([binding, value]) => {
|
|
78
53
|
if (value && binding === 'name') {
|
|
79
|
-
|
|
80
|
-
return
|
|
54
|
+
const selector = (0, function_1.pipe)((0, lodash_1.isString)(value) ? value : value.code, slots_1.stripSlotPrefix, lodash_1.kebabCase);
|
|
55
|
+
return `select="[${selector}]"`;
|
|
81
56
|
}
|
|
82
57
|
})
|
|
83
|
-
.join('\n')
|
|
84
|
-
.map(
|
|
85
|
-
var binding = _a[0], value = _a[1];
|
|
58
|
+
.join('\n')}>${Object.entries(json.bindings)
|
|
59
|
+
.map(([binding, value]) => {
|
|
86
60
|
if (value && binding !== 'name') {
|
|
87
61
|
return value.code;
|
|
88
62
|
}
|
|
89
63
|
})
|
|
90
|
-
.join('\n')
|
|
64
|
+
.join('\n')}${renderChildren()}</ng-content>`;
|
|
91
65
|
},
|
|
92
66
|
};
|
|
93
|
-
|
|
94
|
-
(0, legacy_1.default)(json).forEach(
|
|
67
|
+
const preprocessCssAsJson = (json) => {
|
|
68
|
+
(0, legacy_1.default)(json).forEach((item) => {
|
|
95
69
|
var _a, _b;
|
|
96
70
|
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
97
71
|
if ((0, helpers_1.nodeHasCss)(item)) {
|
|
@@ -102,157 +76,155 @@ var preprocessCssAsJson = function (json) {
|
|
|
102
76
|
}
|
|
103
77
|
});
|
|
104
78
|
};
|
|
105
|
-
|
|
106
|
-
return
|
|
79
|
+
const generateNgModule = (content, name, componentsUsed, component, bootstrapMapper) => {
|
|
80
|
+
return `import { NgModule } from "@angular/core";
|
|
81
|
+
import { CommonModule } from "@angular/common";
|
|
82
|
+
|
|
83
|
+
${content}
|
|
84
|
+
|
|
85
|
+
@NgModule({
|
|
86
|
+
declarations: [${name}],
|
|
87
|
+
imports: [CommonModule${componentsUsed.length ? ', ' + componentsUsed.map((comp) => `${comp}Module`).join(', ') : ''}],
|
|
88
|
+
exports: [${name}],
|
|
89
|
+
${bootstrapMapper ? bootstrapMapper(name, componentsUsed, component) : ''}
|
|
90
|
+
})
|
|
91
|
+
export class ${name}Module {}`;
|
|
107
92
|
};
|
|
108
93
|
// TODO: Maybe in the future allow defining `string | function` as values
|
|
109
|
-
|
|
94
|
+
const BINDINGS_MAPPER = {
|
|
110
95
|
innerHTML: 'innerHTML',
|
|
111
96
|
style: 'ngStyle',
|
|
112
97
|
};
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
const handleObjectBindings = (code) => {
|
|
99
|
+
let objectCode = code.replace(/^{/, '').replace(/}$/, '');
|
|
115
100
|
objectCode = objectCode.replace(/\/\/.*\n/g, '');
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
var otherObjs = objectKeys.map(function (item) {
|
|
125
|
-
return "{ ".concat(item, " }");
|
|
126
|
-
});
|
|
127
|
-
var temp = "".concat(spreadOutObjects.join(', '), ", ").concat(otherObjs.join(', '));
|
|
128
|
-
if (temp.endsWith(', ')) {
|
|
129
|
-
temp = temp.slice(0, -2);
|
|
130
|
-
}
|
|
131
|
-
if (temp.startsWith(', ')) {
|
|
132
|
-
temp = temp.slice(2);
|
|
133
|
-
}
|
|
101
|
+
let temp = objectCode;
|
|
102
|
+
//STEP 1. remove spread operator for expressions like '{ ...objectName }' and replace them with object name, example {...obj} => obj
|
|
103
|
+
temp = temp.replace(/\{\s*\.\.\.(\w+)\s*}/g, '$1');
|
|
104
|
+
//STEP 2. remove all remaining spread operators that could be nested somewhere deeper, example { ...obj, field1: value1 } => { obj, field1: value1 }
|
|
105
|
+
temp = temp.replace(/\.\.\./g, '');
|
|
106
|
+
//STEP 3. deal with consequences of STEP 2 - for all left field assignments we create new objects provided to useObjectWrapper,
|
|
107
|
+
//and we get rid of surrounding brackets of the initial input value, example {...obj1,test:true,...obj2} => obj1, {test: true}, obj2
|
|
108
|
+
temp = temp.replace(/(\s*\w+\s*:\s*((["'].+["'])|(\[.+])|([\w.]+)))(,|[\n\s]*)/g, `{ $1 },`);
|
|
134
109
|
// handle template strings
|
|
135
110
|
if (temp.includes('`')) {
|
|
136
111
|
// template str
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
112
|
+
let str = temp.match(/`[^`]*`/g);
|
|
113
|
+
let values = str && str[0].match(/\${[^}]*}/g);
|
|
114
|
+
let forValues = values === null || values === void 0 ? void 0 : values.map((val) => val.slice(2, -1)).join(' + ');
|
|
140
115
|
if (str && forValues) {
|
|
141
116
|
temp = temp.replace(str[0], forValues);
|
|
142
117
|
}
|
|
143
118
|
}
|
|
144
119
|
return temp;
|
|
145
120
|
};
|
|
146
|
-
|
|
121
|
+
const processCodeBlockInTemplate = (code) => {
|
|
147
122
|
// contains helper calls as Angular doesn't support JS expressions in templates
|
|
148
|
-
if (code.startsWith('{')) {
|
|
123
|
+
if (code.startsWith('{') && code.includes('...')) {
|
|
149
124
|
// Objects cannot be spread out directly in Angular so we need to use `useObjectWrapper`
|
|
150
|
-
return
|
|
125
|
+
return `useObjectWrapper(${handleObjectBindings(code)})`;
|
|
151
126
|
}
|
|
152
127
|
else if (code.startsWith('Object.values')) {
|
|
153
|
-
|
|
154
|
-
return
|
|
128
|
+
let stripped = code.replace('Object.values', '');
|
|
129
|
+
return `useObjectDotValues${stripped}`;
|
|
155
130
|
}
|
|
156
131
|
else if (code.includes('JSON.stringify')) {
|
|
157
|
-
|
|
158
|
-
return
|
|
132
|
+
let obj = code.match(/JSON.stringify\((.*)\)/);
|
|
133
|
+
return `useJsonStringify(${obj})`;
|
|
159
134
|
}
|
|
160
135
|
else if (code.includes(' as ')) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return
|
|
136
|
+
const asIndex = code.indexOf('as');
|
|
137
|
+
const asCode = code.slice(0, asIndex - 1);
|
|
138
|
+
return `$any${asCode})`;
|
|
164
139
|
}
|
|
165
140
|
else {
|
|
166
|
-
return
|
|
141
|
+
return `${code}`;
|
|
167
142
|
}
|
|
168
143
|
};
|
|
169
|
-
|
|
170
|
-
|
|
144
|
+
const processEventBinding = (key, code, nodeName, customArg) => {
|
|
145
|
+
let event = key.replace('on', '');
|
|
171
146
|
event = event.charAt(0).toLowerCase() + event.slice(1);
|
|
172
147
|
if (event === 'change' && nodeName === 'input' /* todo: other tags */) {
|
|
173
148
|
event = 'input';
|
|
174
149
|
}
|
|
175
150
|
// TODO: proper babel transform to replace. Util for this
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
151
|
+
const eventName = customArg;
|
|
152
|
+
const regexp = new RegExp('(^|\\n|\\r| |;|\\(|\\[|!)' + eventName + '(\\?\\.|\\.|\\(| |;|\\)|$)', 'g');
|
|
153
|
+
const replacer = '$1$event$2';
|
|
154
|
+
const finalValue = (0, remove_surrounding_block_1.removeSurroundingBlock)(code.replace(regexp, replacer));
|
|
180
155
|
return {
|
|
181
|
-
event
|
|
156
|
+
event,
|
|
182
157
|
value: finalValue,
|
|
183
158
|
};
|
|
184
159
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return "[".concat(keyToUse, "]=\"").concat(codeToUse, "\"");
|
|
216
|
-
}
|
|
217
|
-
};
|
|
160
|
+
const stringifyBinding = (node, options, blockOptions) => ([key, binding]) => {
|
|
161
|
+
if (options.state === 'inline-with-wrappers' && (binding === null || binding === void 0 ? void 0 : binding.type) === 'spread') {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (key.startsWith('$') || key.startsWith('"') || key === 'key') {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const keyToUse = BINDINGS_MAPPER[key] || key;
|
|
168
|
+
const { code, arguments: cusArgs = ['event'] } = binding;
|
|
169
|
+
// TODO: proper babel transform to replace. Util for this
|
|
170
|
+
if (keyToUse.startsWith('on')) {
|
|
171
|
+
const { event, value } = processEventBinding(keyToUse, code, node.name, cusArgs[0]);
|
|
172
|
+
return ` (${event})="${value}"`;
|
|
173
|
+
}
|
|
174
|
+
else if (keyToUse === 'class') {
|
|
175
|
+
return ` [class]="${code}" `;
|
|
176
|
+
}
|
|
177
|
+
else if (keyToUse === 'ref') {
|
|
178
|
+
return ` #${code} `;
|
|
179
|
+
}
|
|
180
|
+
else if ((html_tags_1.VALID_HTML_TAGS.includes(node.name.trim()) || keyToUse.includes('-')) &&
|
|
181
|
+
!blockOptions.nativeAttributes.includes(keyToUse) &&
|
|
182
|
+
!Object.values(BINDINGS_MAPPER).includes(keyToUse)) {
|
|
183
|
+
// standard html elements need the attr to satisfy the compiler in many cases: eg: svg elements and [fill]
|
|
184
|
+
return ` [attr.${keyToUse}]="${code}" `;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
const codeToUse = options.state === 'inline-with-wrappers' ? processCodeBlockInTemplate(code) : code;
|
|
188
|
+
return `[${keyToUse}]="${codeToUse}"`;
|
|
189
|
+
}
|
|
218
190
|
};
|
|
219
|
-
|
|
191
|
+
const handleNgOutletBindings = (node, options) => {
|
|
220
192
|
var _a;
|
|
221
|
-
|
|
222
|
-
for (
|
|
193
|
+
let allProps = '';
|
|
194
|
+
for (const key in node.properties) {
|
|
223
195
|
if (key.startsWith('$')) {
|
|
224
196
|
continue;
|
|
225
197
|
}
|
|
226
198
|
if (key === 'key') {
|
|
227
199
|
continue;
|
|
228
200
|
}
|
|
229
|
-
|
|
230
|
-
allProps +=
|
|
201
|
+
const value = node.properties[key];
|
|
202
|
+
allProps += `${key}: '${value}', `;
|
|
231
203
|
}
|
|
232
|
-
for (
|
|
204
|
+
for (const key in node.bindings) {
|
|
233
205
|
if (key.startsWith('"')) {
|
|
234
206
|
continue;
|
|
235
207
|
}
|
|
236
208
|
if (key.startsWith('$')) {
|
|
237
209
|
continue;
|
|
238
210
|
}
|
|
239
|
-
|
|
211
|
+
let { code, arguments: cusArgs = ['event'] } = node.bindings[key];
|
|
240
212
|
if (options.state === 'class-properties') {
|
|
241
|
-
code =
|
|
213
|
+
code = `this.${code}`;
|
|
242
214
|
if (((_a = node.bindings[key]) === null || _a === void 0 ? void 0 : _a.type) === 'spread') {
|
|
243
|
-
allProps +=
|
|
215
|
+
allProps += `...${code}, `;
|
|
244
216
|
continue;
|
|
245
217
|
}
|
|
246
218
|
}
|
|
247
|
-
|
|
219
|
+
let keyToUse = key.includes('-') ? `'${key}'` : key;
|
|
248
220
|
keyToUse = keyToUse.replace('state.', '').replace('props.', '');
|
|
249
221
|
if (key.startsWith('on')) {
|
|
250
|
-
|
|
251
|
-
allProps +=
|
|
222
|
+
const { event, value } = processEventBinding(key, code, node.name, cusArgs[0]);
|
|
223
|
+
allProps += `on${event.charAt(0).toUpperCase() + event.slice(1)}: ${value.replace(/\(.*?\)/g, '')}.bind(this), `;
|
|
252
224
|
}
|
|
253
225
|
else {
|
|
254
|
-
|
|
255
|
-
allProps +=
|
|
226
|
+
const codeToUse = options.state === 'inline-with-wrappers' ? processCodeBlockInTemplate(code) : code;
|
|
227
|
+
allProps += `${keyToUse}: ${codeToUse}, `;
|
|
256
228
|
}
|
|
257
229
|
}
|
|
258
230
|
if (allProps.endsWith(', ')) {
|
|
@@ -263,126 +235,129 @@ var handleNgOutletBindings = function (node, options) {
|
|
|
263
235
|
}
|
|
264
236
|
return allProps;
|
|
265
237
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
var childComponents = (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.childComponents) || [];
|
|
238
|
+
const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
239
|
+
nativeAttributes: [],
|
|
240
|
+
}, }) => {
|
|
241
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
242
|
+
const childComponents = (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.childComponents) || [];
|
|
272
243
|
if (mappers[json.name]) {
|
|
273
244
|
return mappers[json.name](root, json, options);
|
|
274
245
|
}
|
|
275
246
|
if ((0, is_children_1.default)({ node: json })) {
|
|
276
|
-
return
|
|
247
|
+
return `<ng-content></ng-content>`;
|
|
277
248
|
}
|
|
278
249
|
if (json.properties._text) {
|
|
279
250
|
return json.properties._text;
|
|
280
251
|
}
|
|
281
|
-
|
|
252
|
+
const textCode = (_a = json.bindings._text) === null || _a === void 0 ? void 0 : _a.code;
|
|
282
253
|
if (textCode) {
|
|
283
254
|
if ((0, slots_1.isSlotProperty)(textCode)) {
|
|
284
|
-
return
|
|
255
|
+
return `<ng-content select="[${(0, slots_1.toKebabSlot)(textCode)}]"></ng-content>`;
|
|
285
256
|
}
|
|
286
257
|
if (textCode.includes('JSON.stringify')) {
|
|
287
|
-
|
|
288
|
-
return
|
|
258
|
+
const obj = textCode.replace(/JSON.stringify\(\s*(\w+)\s*,?.*\)/, '$1');
|
|
259
|
+
return `{{${obj} | json}}`;
|
|
289
260
|
}
|
|
290
|
-
return
|
|
261
|
+
return `{{${textCode}}}`;
|
|
291
262
|
}
|
|
292
|
-
|
|
263
|
+
let str = '';
|
|
293
264
|
if ((0, mitosis_node_1.checkIsForNode)(json)) {
|
|
294
|
-
|
|
295
|
-
|
|
265
|
+
const indexName = json.scope.indexName;
|
|
266
|
+
const forName = json.scope.forName;
|
|
296
267
|
// Check if "key" is present for the first child of the for loop
|
|
297
|
-
if (json.children[0].bindings && ((
|
|
298
|
-
|
|
299
|
-
|
|
268
|
+
if (json.children[0].bindings && ((_b = json.children[0].bindings.key) === null || _b === void 0 ? void 0 : _b.code)) {
|
|
269
|
+
const fnIndex = ((_c = root.meta) === null || _c === void 0 ? void 0 : _c._trackByForIndex) || 0;
|
|
270
|
+
const trackByFnName = `trackBy${forName ? forName.charAt(0).toUpperCase() + forName.slice(1) : ''}${fnIndex}`;
|
|
300
271
|
root.meta._trackByForIndex = fnIndex + 1;
|
|
301
|
-
|
|
272
|
+
let code = (_d = json.children[0].bindings.key) === null || _d === void 0 ? void 0 : _d.code;
|
|
302
273
|
root.state[trackByFnName] = {
|
|
303
|
-
code:
|
|
274
|
+
code: `${trackByFnName}(${indexName !== null && indexName !== void 0 ? indexName : '_'}, ${forName}) { return ${code}; }`,
|
|
304
275
|
type: 'method',
|
|
305
276
|
};
|
|
306
|
-
str +=
|
|
277
|
+
str += `<ng-container *ngFor="let ${forName} of ${(_e = json.bindings.each) === null || _e === void 0 ? void 0 : _e.code}${indexName ? `; let ${indexName} = index` : ''}; trackBy: ${trackByFnName}">`;
|
|
307
278
|
}
|
|
308
279
|
else {
|
|
309
|
-
str +=
|
|
280
|
+
str += `<ng-container *ngFor="let ${forName} of ${(_f = json.bindings.each) === null || _f === void 0 ? void 0 : _f.code}${indexName ? `; let ${indexName} = index` : ''}">`;
|
|
310
281
|
}
|
|
311
282
|
str += json.children
|
|
312
|
-
.map(
|
|
283
|
+
.map((item) => (0, exports.blockToAngular)({ root, json: item, options, blockOptions }))
|
|
313
284
|
.join('\n');
|
|
314
|
-
str +=
|
|
285
|
+
str += `</ng-container>`;
|
|
315
286
|
}
|
|
316
287
|
else if (json.name === 'Show') {
|
|
317
|
-
|
|
288
|
+
let condition = (_g = json.bindings.when) === null || _g === void 0 ? void 0 : _g.code;
|
|
318
289
|
if (options.state === 'inline-with-wrappers' && (condition === null || condition === void 0 ? void 0 : condition.includes('typeof'))) {
|
|
319
|
-
|
|
320
|
-
condition = condition.replace(
|
|
290
|
+
let wordAfterTypeof = condition.split('typeof')[1].trim().split(' ')[0];
|
|
291
|
+
condition = condition.replace(`typeof ${wordAfterTypeof}`, `useTypeOf(${wordAfterTypeof})`);
|
|
321
292
|
}
|
|
322
|
-
str +=
|
|
293
|
+
str += `<ng-container *ngIf="${condition}">`;
|
|
323
294
|
str += json.children
|
|
324
|
-
.map(
|
|
295
|
+
.map((item) => (0, exports.blockToAngular)({ root, json: item, options, blockOptions }))
|
|
325
296
|
.join('\n');
|
|
326
|
-
str +=
|
|
297
|
+
str += `</ng-container>`;
|
|
327
298
|
// else condition
|
|
328
|
-
if ((0, is_mitosis_node_1.isMitosisNode)((
|
|
329
|
-
str +=
|
|
330
|
-
str += (0, exports.blockToAngular)({ root
|
|
331
|
-
str +=
|
|
299
|
+
if ((0, is_mitosis_node_1.isMitosisNode)((_h = json.meta) === null || _h === void 0 ? void 0 : _h.else)) {
|
|
300
|
+
str += `<ng-container *ngIf="!(${condition})">`;
|
|
301
|
+
str += (0, exports.blockToAngular)({ root, json: json.meta.else, options, blockOptions });
|
|
302
|
+
str += `</ng-container>`;
|
|
332
303
|
}
|
|
333
304
|
}
|
|
334
305
|
else if (json.name.includes('.')) {
|
|
335
|
-
|
|
306
|
+
const elSelector = childComponents.find((impName) => impName === json.name)
|
|
336
307
|
? (0, lodash_1.kebabCase)(json.name)
|
|
337
308
|
: json.name;
|
|
338
|
-
|
|
309
|
+
let allProps = handleNgOutletBindings(json, options);
|
|
339
310
|
if (options.state === 'class-properties') {
|
|
340
|
-
|
|
311
|
+
const inputsPropsStateName = `mergedInputs_${(0, symbol_processor_1.hashCodeAsString)(allProps)}`;
|
|
341
312
|
root.state[inputsPropsStateName] = {
|
|
342
313
|
code: '{}' + (options.typescript ? ' as any' : ''),
|
|
343
314
|
type: 'property',
|
|
344
315
|
};
|
|
345
|
-
if (!((
|
|
316
|
+
if (!((_j = root.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code.includes(inputsPropsStateName))) {
|
|
346
317
|
if (!root.hooks.onInit) {
|
|
347
318
|
root.hooks.onInit = { code: '' };
|
|
348
319
|
}
|
|
349
|
-
root.hooks.onInit.code +=
|
|
320
|
+
root.hooks.onInit.code += `\nthis.${inputsPropsStateName} = {${allProps}};\n`;
|
|
350
321
|
}
|
|
351
|
-
if (!((
|
|
322
|
+
if (!((_k = root.hooks.onUpdate) === null || _k === void 0 ? void 0 : _k.map((hook) => hook.code).join('').includes(inputsPropsStateName))) {
|
|
352
323
|
if (!root.hooks.onUpdate) {
|
|
353
324
|
root.hooks.onUpdate = [];
|
|
354
325
|
}
|
|
355
326
|
root.hooks.onUpdate.push({
|
|
356
|
-
code:
|
|
327
|
+
code: `this.${inputsPropsStateName} = {${allProps}}`,
|
|
357
328
|
});
|
|
358
329
|
}
|
|
359
|
-
allProps =
|
|
330
|
+
allProps = `${inputsPropsStateName}`;
|
|
360
331
|
}
|
|
361
332
|
else {
|
|
362
|
-
allProps =
|
|
363
|
-
}
|
|
364
|
-
str +=
|
|
365
|
-
|
|
333
|
+
allProps = `{ ${allProps} }`;
|
|
334
|
+
}
|
|
335
|
+
str += `<ng-container *ngComponentOutlet="
|
|
336
|
+
${elSelector.replace('state.', '').replace('props.', '')};
|
|
337
|
+
inputs: ${allProps};
|
|
338
|
+
content: myContent;
|
|
339
|
+
"> `;
|
|
340
|
+
str += `</ng-container>`;
|
|
366
341
|
}
|
|
367
342
|
else {
|
|
368
|
-
|
|
343
|
+
const elSelector = childComponents.find((impName) => impName === json.name)
|
|
369
344
|
? (0, lodash_1.kebabCase)(json.name)
|
|
370
345
|
: json.name;
|
|
371
|
-
str +=
|
|
346
|
+
str += `<${elSelector} `;
|
|
372
347
|
// TODO: spread support for angular
|
|
373
348
|
// if (json.bindings._spread) {
|
|
374
349
|
// str += `v-bind="${stripStateAndPropsRefs(
|
|
375
350
|
// json.bindings._spread as string,
|
|
376
351
|
// )}"`;
|
|
377
352
|
// }
|
|
378
|
-
for (
|
|
353
|
+
for (const key in json.properties) {
|
|
379
354
|
if (key.startsWith('$')) {
|
|
380
355
|
continue;
|
|
381
356
|
}
|
|
382
|
-
|
|
383
|
-
str +=
|
|
357
|
+
const value = json.properties[key];
|
|
358
|
+
str += ` ${key}="${value}" `;
|
|
384
359
|
}
|
|
385
|
-
|
|
360
|
+
const stringifiedBindings = Object.entries(json.bindings)
|
|
386
361
|
.map(stringifyBinding(json, options, blockOptions))
|
|
387
362
|
.join('');
|
|
388
363
|
str += stringifiedBindings;
|
|
@@ -392,53 +367,46 @@ var blockToAngular = function (_a) {
|
|
|
392
367
|
str += '>';
|
|
393
368
|
if (json.children) {
|
|
394
369
|
str += json.children
|
|
395
|
-
.map(
|
|
370
|
+
.map((item) => (0, exports.blockToAngular)({ root, json: item, options, blockOptions }))
|
|
396
371
|
.join('\n');
|
|
397
372
|
}
|
|
398
|
-
str +=
|
|
373
|
+
str += `</${elSelector}>`;
|
|
399
374
|
}
|
|
400
375
|
return str;
|
|
401
376
|
};
|
|
402
377
|
exports.blockToAngular = blockToAngular;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
(0, legacy_1.default)(json).forEach(
|
|
378
|
+
const traverseToGetAllDynamicComponents = (json, options, blockOptions) => {
|
|
379
|
+
const components = new Set();
|
|
380
|
+
let dynamicTemplate = '';
|
|
381
|
+
(0, legacy_1.default)(json).forEach((item) => {
|
|
407
382
|
if ((0, is_mitosis_node_1.isMitosisNode)(item) && item.name.includes('.') && item.name.split('.').length === 2) {
|
|
408
|
-
|
|
409
|
-
.map(
|
|
383
|
+
const children = item.children
|
|
384
|
+
.map((child) => (0, exports.blockToAngular)({ root: json, json: child, options, blockOptions }))
|
|
410
385
|
.join('\n');
|
|
411
|
-
dynamicTemplate =
|
|
386
|
+
dynamicTemplate = `<ng-template #${item.name.split('.')[1].toLowerCase() + 'Template'}>${children}</ng-template>`;
|
|
412
387
|
components.add(item.name);
|
|
413
388
|
}
|
|
414
389
|
});
|
|
415
390
|
return {
|
|
416
|
-
components
|
|
417
|
-
dynamicTemplate
|
|
391
|
+
components,
|
|
392
|
+
dynamicTemplate,
|
|
418
393
|
};
|
|
419
394
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
395
|
+
const processAngularCode = ({ contextVars, outputVars, domRefs, stateVars, replaceWith, }) => (code) => (0, function_1.pipe)((0, strip_state_and_props_refs_1.DO_NOT_USE_VARS_TRANSFORMS)(code, {
|
|
396
|
+
contextVars,
|
|
397
|
+
domRefs,
|
|
398
|
+
outputVars,
|
|
399
|
+
stateVars,
|
|
400
|
+
}), (newCode) => (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(newCode, { replaceWith }));
|
|
401
|
+
const isASimpleProperty = (code) => {
|
|
402
|
+
const expressions = ['==', '===', '!=', '!==', '<', '>', '<=', '>='];
|
|
403
|
+
const invalidChars = ['{', '}', '(', ')', 'typeof'];
|
|
404
|
+
return !invalidChars.some((char) => code.includes(char)) && !expressions.includes(code);
|
|
430
405
|
};
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var invalidChars = ['{', '}', '(', ')', 'typeof'];
|
|
434
|
-
return !invalidChars.some(function (char) { return code.includes(char); }) && !expressions.includes(code);
|
|
435
|
-
};
|
|
436
|
-
var generateNewBindingName = function (index, name) {
|
|
437
|
-
return "node_".concat(index, "_").concat(name.replaceAll('.', '_').replaceAll('-', '_'));
|
|
438
|
-
};
|
|
439
|
-
var handleBindings = function (json, item, index, forName, indexName) {
|
|
406
|
+
const generateNewBindingName = (index, name) => `node_${index}_${name.replaceAll('.', '_').replaceAll('-', '_')}`;
|
|
407
|
+
const handleBindings = (json, item, index, forName, indexName) => {
|
|
440
408
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
441
|
-
for (
|
|
409
|
+
for (const key in item.bindings) {
|
|
442
410
|
if (key.startsWith('"') ||
|
|
443
411
|
key.startsWith('$') ||
|
|
444
412
|
key === 'css' ||
|
|
@@ -446,37 +414,37 @@ var handleBindings = function (json, item, index, forName, indexName) {
|
|
|
446
414
|
isASimpleProperty(item.bindings[key].code)) {
|
|
447
415
|
continue;
|
|
448
416
|
}
|
|
449
|
-
|
|
417
|
+
const newBindingName = generateNewBindingName(index, item.name);
|
|
450
418
|
if (forName) {
|
|
451
419
|
if (item.name === 'For')
|
|
452
420
|
continue;
|
|
453
421
|
if (key === 'key')
|
|
454
422
|
continue;
|
|
455
423
|
if (key.startsWith('on')) {
|
|
456
|
-
|
|
457
|
-
|
|
424
|
+
const { arguments: cusArgs = ['event'] } = item.bindings[key];
|
|
425
|
+
const eventBindingName = `${generateNewBindingName(index, item.name)}_event`;
|
|
458
426
|
if (((_a = item.bindings[key]) === null || _a === void 0 ? void 0 : _a.code.trim().startsWith('{')) &&
|
|
459
427
|
((_b = item.bindings[key]) === null || _b === void 0 ? void 0 : _b.code.trim().endsWith('}'))) {
|
|
460
|
-
|
|
461
|
-
|
|
428
|
+
const forAndIndex = `${forName ? `, ${forName}` : ''}${indexName ? `, ${indexName}` : ''}`;
|
|
429
|
+
const eventArgs = `${cusArgs.join(', ')}${forAndIndex}`;
|
|
462
430
|
json.state[eventBindingName] = {
|
|
463
|
-
code:
|
|
431
|
+
code: `(${eventArgs}) => ${item.bindings[key].code}`,
|
|
464
432
|
type: 'function',
|
|
465
433
|
};
|
|
466
|
-
item.bindings[key].code =
|
|
434
|
+
item.bindings[key].code = `state.${eventBindingName}(${eventArgs})`;
|
|
467
435
|
json.state[newBindingName] = {
|
|
468
|
-
code:
|
|
436
|
+
code: `(${eventArgs}) => (${item.bindings[key].code})`,
|
|
469
437
|
type: 'function',
|
|
470
438
|
};
|
|
471
|
-
item.bindings[key].code =
|
|
439
|
+
item.bindings[key].code = `state.${newBindingName}($${eventArgs})`;
|
|
472
440
|
}
|
|
473
441
|
}
|
|
474
442
|
else {
|
|
475
443
|
json.state[newBindingName] = {
|
|
476
|
-
code:
|
|
444
|
+
code: `(${forName}${indexName ? `, ${indexName}` : ''}) => (${item.bindings[key].code})`,
|
|
477
445
|
type: 'function',
|
|
478
446
|
};
|
|
479
|
-
item.bindings[key].code =
|
|
447
|
+
item.bindings[key].code = `state.${newBindingName}(${forName}${indexName ? `, ${indexName}` : ''})`;
|
|
480
448
|
}
|
|
481
449
|
}
|
|
482
450
|
else if ((_c = item.bindings[key]) === null || _c === void 0 ? void 0 : _c.code) {
|
|
@@ -485,36 +453,36 @@ var handleBindings = function (json, item, index, forName, indexName) {
|
|
|
485
453
|
if (!((_e = json.hooks['onInit']) === null || _e === void 0 ? void 0 : _e.code)) {
|
|
486
454
|
json.hooks['onInit'] = { code: '' };
|
|
487
455
|
}
|
|
488
|
-
json.hooks['onInit'].code +=
|
|
456
|
+
json.hooks['onInit'].code += `\nstate.${newBindingName} = ${item.bindings[key].code};\n`;
|
|
489
457
|
json.hooks['onUpdate'] = json.hooks['onUpdate'] || [];
|
|
490
458
|
json.hooks['onUpdate'].push({
|
|
491
|
-
code:
|
|
459
|
+
code: `state.${newBindingName} = ${item.bindings[key].code}`,
|
|
492
460
|
});
|
|
493
|
-
item.bindings[key].code =
|
|
461
|
+
item.bindings[key].code = `state.${newBindingName}`;
|
|
494
462
|
}
|
|
495
463
|
else if (key.startsWith('on')) {
|
|
496
|
-
|
|
464
|
+
const { arguments: cusArgs = ['event'] } = item.bindings[key];
|
|
497
465
|
if (((_f = item.bindings[key]) === null || _f === void 0 ? void 0 : _f.code.trim().startsWith('{')) &&
|
|
498
466
|
((_g = item.bindings[key]) === null || _g === void 0 ? void 0 : _g.code.trim().endsWith('}'))) {
|
|
499
467
|
json.state[newBindingName] = {
|
|
500
|
-
code:
|
|
468
|
+
code: `(${cusArgs.join(', ')}) => ${item.bindings[key].code}`,
|
|
501
469
|
type: 'function',
|
|
502
470
|
};
|
|
503
|
-
item.bindings[key].code =
|
|
471
|
+
item.bindings[key].code = `state.${newBindingName}(${cusArgs.join(', ')})`;
|
|
504
472
|
}
|
|
505
473
|
}
|
|
506
474
|
else {
|
|
507
|
-
json.state[newBindingName] = { code:
|
|
475
|
+
json.state[newBindingName] = { code: `null`, type: 'property' };
|
|
508
476
|
if (!((_h = json.hooks['onInit']) === null || _h === void 0 ? void 0 : _h.code)) {
|
|
509
477
|
json.hooks['onInit'] = { code: '' };
|
|
510
478
|
}
|
|
511
|
-
json.hooks['onInit'].code +=
|
|
479
|
+
json.hooks['onInit'].code += `\nstate.${newBindingName} = {...(${item.bindings[key].code})};\n`;
|
|
512
480
|
json.hooks['onUpdate'] = json.hooks['onUpdate'] || [];
|
|
513
481
|
json.hooks['onUpdate'].push({
|
|
514
|
-
code:
|
|
482
|
+
code: `state.${newBindingName} = {...(${item.bindings[key].code})}`,
|
|
515
483
|
});
|
|
516
484
|
item.bindings[newBindingName] = item.bindings[key];
|
|
517
|
-
item.bindings[key].code =
|
|
485
|
+
item.bindings[key].code = `state.${newBindingName}`;
|
|
518
486
|
delete item.bindings[key];
|
|
519
487
|
}
|
|
520
488
|
}
|
|
@@ -522,42 +490,41 @@ var handleBindings = function (json, item, index, forName, indexName) {
|
|
|
522
490
|
}
|
|
523
491
|
return index;
|
|
524
492
|
};
|
|
525
|
-
|
|
526
|
-
for (
|
|
493
|
+
const handleProperties = (json, item, index) => {
|
|
494
|
+
for (const key in item.properties) {
|
|
527
495
|
if (key.startsWith('$') || isASimpleProperty(item.properties[key])) {
|
|
528
496
|
continue;
|
|
529
497
|
}
|
|
530
|
-
|
|
531
|
-
json.state[newBindingName] = { code: '`' +
|
|
532
|
-
item.bindings[key] = { code:
|
|
498
|
+
const newBindingName = generateNewBindingName(index, item.name);
|
|
499
|
+
json.state[newBindingName] = { code: '`' + `${item.properties[key]}` + '`', type: 'property' };
|
|
500
|
+
item.bindings[key] = { code: `state.${newBindingName}`, type: 'single' };
|
|
533
501
|
delete item.properties[key];
|
|
534
502
|
index++;
|
|
535
503
|
}
|
|
536
504
|
return index;
|
|
537
505
|
};
|
|
538
|
-
|
|
539
|
-
var _b = _a === void 0 ? {} : _a, forName = _b.forName, indexName = _b.indexName;
|
|
506
|
+
const handleAngularBindings = (json, item, index, { forName, indexName } = {}) => {
|
|
540
507
|
if ((0, is_children_1.default)({ node: item }))
|
|
541
508
|
return index;
|
|
542
509
|
index = handleBindings(json, item, index, forName, indexName);
|
|
543
510
|
index = handleProperties(json, item, index);
|
|
544
511
|
return index;
|
|
545
512
|
};
|
|
546
|
-
|
|
513
|
+
const classPropertiesPlugin = () => ({
|
|
547
514
|
json: {
|
|
548
|
-
pre:
|
|
549
|
-
|
|
550
|
-
(0, traverse_nodes_1.traverseNodes)(json,
|
|
515
|
+
pre: (json) => {
|
|
516
|
+
let lastId = 0;
|
|
517
|
+
(0, traverse_nodes_1.traverseNodes)(json, (item) => {
|
|
551
518
|
if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
|
|
552
519
|
if (item.name === 'For') {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
(0, traverse_nodes_1.traverseNodes)(item,
|
|
520
|
+
const forName = item.scope.forName;
|
|
521
|
+
const indexName = item.scope.indexName;
|
|
522
|
+
(0, traverse_nodes_1.traverseNodes)(item, (child) => {
|
|
556
523
|
if ((0, is_mitosis_node_1.isMitosisNode)(child)) {
|
|
557
524
|
child._traversed = true;
|
|
558
525
|
lastId = handleAngularBindings(json, child, lastId, {
|
|
559
|
-
forName
|
|
560
|
-
indexName
|
|
526
|
+
forName,
|
|
527
|
+
indexName,
|
|
561
528
|
});
|
|
562
529
|
}
|
|
563
530
|
});
|
|
@@ -570,331 +537,380 @@ var classPropertiesPlugin = function () { return ({
|
|
|
570
537
|
return json;
|
|
571
538
|
},
|
|
572
539
|
},
|
|
573
|
-
});
|
|
540
|
+
});
|
|
574
541
|
// if any state "property" is trying to access state.* or props.*
|
|
575
542
|
// then we need to move them to onInit where they can be accessed
|
|
576
|
-
|
|
543
|
+
const transformState = (json) => {
|
|
577
544
|
Object.entries(json.state)
|
|
578
545
|
.reverse()
|
|
579
|
-
.forEach(
|
|
580
|
-
var
|
|
581
|
-
var key = _a[0], value = _a[1];
|
|
546
|
+
.forEach(([key, value]) => {
|
|
547
|
+
var _a;
|
|
582
548
|
if ((value === null || value === void 0 ? void 0 : value.type) === 'property') {
|
|
583
549
|
if (value.code && (value.code.includes('state.') || value.code.includes('props.'))) {
|
|
584
|
-
|
|
550
|
+
const code = (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(value.code, { replaceWith: 'this' });
|
|
585
551
|
json.state[key].code = 'null';
|
|
586
|
-
if (!((
|
|
552
|
+
if (!((_a = json.hooks.onInit) === null || _a === void 0 ? void 0 : _a.code)) {
|
|
587
553
|
json.hooks.onInit = { code: '' };
|
|
588
554
|
}
|
|
589
|
-
json.hooks.onInit.code =
|
|
555
|
+
json.hooks.onInit.code = `\nthis.${key} = ${code};\n${json.hooks.onInit.code}`;
|
|
590
556
|
}
|
|
591
557
|
}
|
|
592
558
|
});
|
|
593
559
|
};
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
.map(function (_a) {
|
|
630
|
-
var key = _a[0];
|
|
631
|
-
return key;
|
|
632
|
-
});
|
|
633
|
-
return (0, replace_identifiers_1.replaceIdentifiers)({
|
|
634
|
-
code: code,
|
|
635
|
-
from: allMethodNames,
|
|
636
|
-
to: function (name) { return "this.".concat(name); },
|
|
637
|
-
});
|
|
560
|
+
const componentToAngular = (userOptions = {}) => ({ component: _component }) => {
|
|
561
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
562
|
+
// Make a copy we can safely mutate, similar to babel's toolchain
|
|
563
|
+
let json = (0, fast_clone_1.fastClone)(_component);
|
|
564
|
+
const useMetadata = (_a = json.meta) === null || _a === void 0 ? void 0 : _a.useMetadata;
|
|
565
|
+
const contextVars = Object.keys(((_b = json === null || json === void 0 ? void 0 : json.context) === null || _b === void 0 ? void 0 : _b.get) || {});
|
|
566
|
+
// TODO: Why is 'outputs' used here and shouldn't it be typed in packages/core/src/types/metadata.ts
|
|
567
|
+
const metaOutputVars = (useMetadata === null || useMetadata === void 0 ? void 0 : useMetadata.outputs) || [];
|
|
568
|
+
const outputVars = (0, lodash_1.uniq)([...metaOutputVars, ...(0, get_prop_functions_1.getPropFunctions)(json)]);
|
|
569
|
+
const stateVars = Object.keys((json === null || json === void 0 ? void 0 : json.state) || {});
|
|
570
|
+
const options = (0, merge_options_1.initializeOptions)({
|
|
571
|
+
target: 'angular',
|
|
572
|
+
component: _component,
|
|
573
|
+
defaults: types_1.DEFAULT_ANGULAR_OPTIONS,
|
|
574
|
+
userOptions: userOptions,
|
|
575
|
+
});
|
|
576
|
+
options.plugins = [
|
|
577
|
+
...(options.plugins || []),
|
|
578
|
+
(0, process_code_1.CODE_PROCESSOR_PLUGIN)((codeType) => {
|
|
579
|
+
switch (codeType) {
|
|
580
|
+
case 'hooks':
|
|
581
|
+
return (0, function_1.flow)(processAngularCode({
|
|
582
|
+
replaceWith: 'this',
|
|
583
|
+
contextVars,
|
|
584
|
+
outputVars,
|
|
585
|
+
domRefs: Array.from((0, get_refs_1.getRefs)(json)),
|
|
586
|
+
stateVars,
|
|
587
|
+
}), (code) => {
|
|
588
|
+
const allMethodNames = Object.entries(json.state)
|
|
589
|
+
.filter(([_, value]) => (value === null || value === void 0 ? void 0 : value.type) === 'function' || (value === null || value === void 0 ? void 0 : value.type) === 'method')
|
|
590
|
+
.map(([key]) => key);
|
|
591
|
+
return (0, replace_identifiers_1.replaceIdentifiers)({
|
|
592
|
+
code,
|
|
593
|
+
from: allMethodNames,
|
|
594
|
+
to: (name) => `this.${name}`,
|
|
638
595
|
});
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}),
|
|
657
|
-
], false);
|
|
658
|
-
if (options.state === 'class-properties') {
|
|
659
|
-
options.plugins.push(classPropertiesPlugin);
|
|
660
|
-
}
|
|
661
|
-
if (options.plugins) {
|
|
662
|
-
json = (0, plugins_1.runPreJsonPlugins)({ json: json, plugins: options.plugins });
|
|
663
|
-
}
|
|
664
|
-
var _o = (0, get_props_ref_1.getPropsRef)(json, true), forwardProp = _o[0], hasPropRef = _o[1];
|
|
665
|
-
var childComponents = [];
|
|
666
|
-
var propsTypeRef = json.propsTypeRef !== 'any' ? json.propsTypeRef : undefined;
|
|
667
|
-
json.imports.forEach(function (_a) {
|
|
668
|
-
var imports = _a.imports;
|
|
669
|
-
Object.keys(imports).forEach(function (key) {
|
|
670
|
-
if (imports[key] === 'default') {
|
|
671
|
-
childComponents.push(key);
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
|
-
});
|
|
675
|
-
var customImports = (0, get_custom_imports_1.getCustomImports)(json);
|
|
676
|
-
var _p = json.exports, localExports = _p === void 0 ? {} : _p;
|
|
677
|
-
var localExportVars = Object.keys(localExports)
|
|
678
|
-
.filter(function (key) { return localExports[key].usedInLocal; })
|
|
679
|
-
.map(function (key) { return "".concat(key, " = ").concat(key, ";"); });
|
|
680
|
-
var injectables = contextVars.map(function (variableName) {
|
|
681
|
-
var _a, _b, _c, _d;
|
|
682
|
-
var variableType = (_a = json === null || json === void 0 ? void 0 : json.context) === null || _a === void 0 ? void 0 : _a.get[variableName].name;
|
|
683
|
-
if ((_b = options === null || options === void 0 ? void 0 : options.experimental) === null || _b === void 0 ? void 0 : _b.injectables) {
|
|
684
|
-
return (_c = options === null || options === void 0 ? void 0 : options.experimental) === null || _c === void 0 ? void 0 : _c.injectables(variableName, variableType);
|
|
685
|
-
}
|
|
686
|
-
if ((_d = options === null || options === void 0 ? void 0 : options.experimental) === null || _d === void 0 ? void 0 : _d.inject) {
|
|
687
|
-
return "@Inject(forwardRef(() => ".concat(variableType, ")) public ").concat(variableName, ": ").concat(variableType);
|
|
596
|
+
});
|
|
597
|
+
case 'bindings':
|
|
598
|
+
return (code) => {
|
|
599
|
+
const newLocal = processAngularCode({
|
|
600
|
+
contextVars: [],
|
|
601
|
+
outputVars,
|
|
602
|
+
domRefs: [], // the template doesn't need the this keyword.
|
|
603
|
+
})(code);
|
|
604
|
+
return newLocal.replace(/"/g, '"');
|
|
605
|
+
};
|
|
606
|
+
case 'hooks-deps':
|
|
607
|
+
case 'state':
|
|
608
|
+
case 'context-set':
|
|
609
|
+
case 'properties':
|
|
610
|
+
case 'dynamic-jsx-elements':
|
|
611
|
+
case 'types':
|
|
612
|
+
return (x) => x;
|
|
688
613
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
if ((_a = options === null || options === void 0 ? void 0 : options.experimental) === null || _a === void 0 ? void 0 : _a.outputs) {
|
|
705
|
-
return (_b = options === null || options === void 0 ? void 0 : options.experimental) === null || _b === void 0 ? void 0 : _b.outputs(json, variableName);
|
|
614
|
+
}),
|
|
615
|
+
];
|
|
616
|
+
if (options.state === 'class-properties') {
|
|
617
|
+
options.plugins.push(classPropertiesPlugin);
|
|
618
|
+
}
|
|
619
|
+
if (options.plugins) {
|
|
620
|
+
json = (0, plugins_1.runPreJsonPlugins)({ json, plugins: options.plugins });
|
|
621
|
+
}
|
|
622
|
+
const [forwardProp, hasPropRef] = (0, get_props_ref_1.getPropsRef)(json, true);
|
|
623
|
+
const childComponents = [];
|
|
624
|
+
const propsTypeRef = json.propsTypeRef !== 'any' ? json.propsTypeRef : undefined;
|
|
625
|
+
json.imports.forEach(({ imports }) => {
|
|
626
|
+
Object.keys(imports).forEach((key) => {
|
|
627
|
+
if (imports[key] === 'default') {
|
|
628
|
+
childComponents.push(key);
|
|
706
629
|
}
|
|
707
|
-
return "@Output() ".concat(variableName, " = new EventEmitter()");
|
|
708
630
|
});
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
if (options.
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
return helperFunctions.add((0, helpers_2.HELPER_FUNCTIONS)(options.typescript)[key]);
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
return tmpl;
|
|
745
|
-
})
|
|
746
|
-
.join('\n');
|
|
747
|
-
if (options.prettier !== false) {
|
|
748
|
-
template = tryFormat(template, 'html');
|
|
631
|
+
});
|
|
632
|
+
const customImports = (0, get_custom_imports_1.getCustomImports)(json);
|
|
633
|
+
const { exports: localExports = {} } = json;
|
|
634
|
+
const localExportVars = Object.keys(localExports)
|
|
635
|
+
.filter((key) => localExports[key].usedInLocal)
|
|
636
|
+
.map((key) => `${key} = ${key};`);
|
|
637
|
+
const injectables = contextVars.map((variableName) => {
|
|
638
|
+
var _a, _b, _c, _d;
|
|
639
|
+
const variableType = (_a = json === null || json === void 0 ? void 0 : json.context) === null || _a === void 0 ? void 0 : _a.get[variableName].name;
|
|
640
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.experimental) === null || _b === void 0 ? void 0 : _b.injectables) {
|
|
641
|
+
return (_c = options === null || options === void 0 ? void 0 : options.experimental) === null || _c === void 0 ? void 0 : _c.injectables(variableName, variableType);
|
|
642
|
+
}
|
|
643
|
+
if ((_d = options === null || options === void 0 ? void 0 : options.experimental) === null || _d === void 0 ? void 0 : _d.inject) {
|
|
644
|
+
return `@Inject(forwardRef(() => ${variableType})) public ${variableName}: ${variableType}`;
|
|
645
|
+
}
|
|
646
|
+
return `public ${variableName} : ${variableType}`;
|
|
647
|
+
});
|
|
648
|
+
const hasConstructor = Boolean(injectables.length);
|
|
649
|
+
const props = (0, get_props_1.getProps)(json);
|
|
650
|
+
// prevent jsx props from showing up as @Input
|
|
651
|
+
if (hasPropRef) {
|
|
652
|
+
props.delete(forwardProp);
|
|
653
|
+
}
|
|
654
|
+
props.delete('children');
|
|
655
|
+
// remove props for outputs
|
|
656
|
+
outputVars.forEach((variableName) => {
|
|
657
|
+
props.delete(variableName);
|
|
658
|
+
});
|
|
659
|
+
const outputs = outputVars.map((variableName) => {
|
|
660
|
+
var _a, _b;
|
|
661
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.experimental) === null || _a === void 0 ? void 0 : _a.outputs) {
|
|
662
|
+
return (_b = options === null || options === void 0 ? void 0 : options.experimental) === null || _b === void 0 ? void 0 : _b.outputs(json, variableName);
|
|
749
663
|
}
|
|
750
|
-
(
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
664
|
+
return `@Output() ${variableName} = new EventEmitter()`;
|
|
665
|
+
});
|
|
666
|
+
const domRefs = (0, get_refs_1.getRefs)(json);
|
|
667
|
+
const jsRefs = Object.keys(json.refs).filter((ref) => !domRefs.has(ref));
|
|
668
|
+
const componentsUsed = Array.from((0, get_components_used_1.getComponentsUsed)(json)).filter((item) => {
|
|
669
|
+
return item.length && (0, is_upper_case_1.isUpperCase)(item[0]) && !types_1.BUILT_IN_COMPONENTS.has(item);
|
|
670
|
+
});
|
|
671
|
+
(0, map_refs_1.mapRefs)(json, (refName) => {
|
|
672
|
+
const isDomRef = domRefs.has(refName);
|
|
673
|
+
return `this.${isDomRef ? '' : '_'}${refName}${isDomRef ? '.nativeElement' : ''}`;
|
|
674
|
+
});
|
|
675
|
+
if (options.plugins) {
|
|
676
|
+
json = (0, plugins_1.runPostJsonPlugins)({ json, plugins: options.plugins });
|
|
677
|
+
}
|
|
678
|
+
preprocessCssAsJson(json);
|
|
679
|
+
let css = (0, collect_css_1.collectCss)(json);
|
|
680
|
+
if (options.prettier !== false) {
|
|
681
|
+
css = tryFormat(css, 'css');
|
|
682
|
+
}
|
|
683
|
+
const helperFunctions = new Set();
|
|
684
|
+
let template = json.children
|
|
685
|
+
.map((item) => {
|
|
686
|
+
var _a, _b;
|
|
687
|
+
const tmpl = (0, exports.blockToAngular)({
|
|
688
|
+
root: json,
|
|
689
|
+
json: item,
|
|
690
|
+
options,
|
|
691
|
+
blockOptions: {
|
|
692
|
+
childComponents,
|
|
693
|
+
nativeAttributes: (_b = (_a = useMetadata === null || useMetadata === void 0 ? void 0 : useMetadata.angular) === null || _a === void 0 ? void 0 : _a.nativeAttributes) !== null && _b !== void 0 ? _b : [],
|
|
694
|
+
},
|
|
765
695
|
});
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
696
|
+
if (options.state === 'inline-with-wrappers') {
|
|
697
|
+
(0, helpers_2.getAppropriateTemplateFunctionKeys)(tmpl).forEach((key) => helperFunctions.add((0, helpers_2.HELPER_FUNCTIONS)(options.typescript)[key]));
|
|
698
|
+
}
|
|
699
|
+
return tmpl;
|
|
700
|
+
})
|
|
701
|
+
.join('\n');
|
|
702
|
+
if (options.prettier !== false) {
|
|
703
|
+
template = tryFormat(template, 'html');
|
|
704
|
+
}
|
|
705
|
+
(0, strip_meta_properties_1.stripMetaProperties)(json);
|
|
706
|
+
const { components: dynamicComponents, dynamicTemplate } = traverseToGetAllDynamicComponents(json, options, {
|
|
707
|
+
childComponents,
|
|
708
|
+
nativeAttributes: (_d = (_c = useMetadata === null || useMetadata === void 0 ? void 0 : useMetadata.angular) === null || _c === void 0 ? void 0 : _c.nativeAttributes) !== null && _d !== void 0 ? _d : [],
|
|
709
|
+
});
|
|
710
|
+
transformState(json);
|
|
711
|
+
const dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
|
|
712
|
+
format: 'class',
|
|
713
|
+
valueMapper: processAngularCode({
|
|
714
|
+
replaceWith: 'this',
|
|
715
|
+
contextVars,
|
|
716
|
+
outputVars,
|
|
717
|
+
domRefs: Array.from(domRefs),
|
|
718
|
+
stateVars,
|
|
719
|
+
}),
|
|
720
|
+
});
|
|
721
|
+
const hostDisplayCss = options.visuallyIgnoreHostElement ? ':host { display: contents; }' : '';
|
|
722
|
+
const styles = css.length ? [hostDisplayCss, css].join('\n') : hostDisplayCss;
|
|
723
|
+
// Preparing built in component metadata parameters
|
|
724
|
+
const componentMetadata = {
|
|
725
|
+
selector: `'${(0, lodash_1.kebabCase)(json.name || 'my-component')}, ${json.name}'`,
|
|
726
|
+
template: `\`
|
|
727
|
+
${(0, indent_1.indent)(dynamicTemplate, 8).replace(/`/g, '\\`').replace(/\$\{/g, '\\${')}
|
|
728
|
+
${(0, indent_1.indent)(template, 8).replace(/`/g, '\\`').replace(/\$\{/g, '\\${')}
|
|
729
|
+
\``,
|
|
730
|
+
...(styles
|
|
770
731
|
? {
|
|
771
|
-
styles:
|
|
732
|
+
styles: `[\`${(0, indent_1.indent)(styles, 8)}\`]`,
|
|
772
733
|
}
|
|
773
|
-
: {})
|
|
734
|
+
: {}),
|
|
735
|
+
...(options.standalone
|
|
774
736
|
? // TODO: also add child component imports here as well
|
|
775
737
|
{
|
|
776
738
|
standalone: 'true',
|
|
777
|
-
imports:
|
|
739
|
+
imports: `[${['CommonModule', ...componentsUsed].join(', ')}]`,
|
|
778
740
|
}
|
|
779
|
-
: {})
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return "".concat(prop, ": ").concat(value);
|
|
796
|
-
})
|
|
797
|
-
.join(',');
|
|
798
|
-
return "const defaultProps = {".concat(defalutPropsString, "};\n");
|
|
799
|
-
};
|
|
800
|
-
var angularCoreImports = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], (outputs.length ? ['Output', 'EventEmitter'] : []), true), (((_f = options === null || options === void 0 ? void 0 : options.experimental) === null || _f === void 0 ? void 0 : _f.inject) ? ['Inject', 'forwardRef'] : []), true), [
|
|
801
|
-
'Component'
|
|
802
|
-
], false), (domRefs.size || dynamicComponents.size ? ['ViewChild', 'ElementRef'] : []), true), (props.size ? ['Input'] : []), true), (dynamicComponents.size ? ['ViewContainerRef', 'TemplateRef'] : []), true), (((_g = json.hooks.onUpdate) === null || _g === void 0 ? void 0 : _g.length) && options.typescript ? ['SimpleChanges'] : []), true).join(', ');
|
|
803
|
-
var str = (0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { ", " } from '@angular/core';\n ", "\n\n ", "\n ", "\n ", "\n\n @Component({\n ", "\n })\n export default class ", " {\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n \n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n }\n "], ["\n import { ", " } from '@angular/core';\n ", "\n\n ", "\n ", "\n ", "\n\n @Component({\n ", "\n })\n export default class ", " {\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n \n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n }\n "])), angularCoreImports, options.standalone ? "import { CommonModule } from '@angular/common';" : '', json.types ? json.types.join('\n') : '', getPropsDefinition({ json: json }), (0, render_imports_1.renderPreComponent)({
|
|
804
|
-
explicitImportFileExtension: options.explicitImportFileExtension,
|
|
805
|
-
component: json,
|
|
806
|
-
target: 'angular',
|
|
807
|
-
excludeMitosisComponents: !options.standalone && !options.preserveImports,
|
|
808
|
-
preserveFileExtensions: options.preserveFileExtensions,
|
|
809
|
-
componentsUsed: componentsUsed,
|
|
810
|
-
importMapper: options === null || options === void 0 ? void 0 : options.importMapper,
|
|
811
|
-
}), Object.entries(componentMetadata)
|
|
812
|
-
.map(function (_a) {
|
|
813
|
-
var k = _a[0], v = _a[1];
|
|
814
|
-
return "".concat(k, ": ").concat(v);
|
|
815
|
-
})
|
|
816
|
-
.join(','), json.name, localExportVars.join('\n'), customImports.map(function (name) { return "".concat(name, " = ").concat(name); }).join('\n'), Array.from(props)
|
|
817
|
-
.filter(function (item) { return !(0, slots_1.isSlotProperty)(item) && item !== 'children'; })
|
|
818
|
-
.map(function (item) {
|
|
819
|
-
var propType = propsTypeRef ? "".concat(propsTypeRef, "[\"").concat(item, "\"]") : 'any';
|
|
820
|
-
var propDeclaration = "@Input() ".concat(item).concat(options.typescript ? "!: ".concat(propType) : '');
|
|
821
|
-
if (json.defaultProps && json.defaultProps.hasOwnProperty(item)) {
|
|
822
|
-
propDeclaration += " = defaultProps[\"".concat(item, "\"]");
|
|
823
|
-
}
|
|
824
|
-
return propDeclaration;
|
|
825
|
-
})
|
|
826
|
-
.join('\n'), outputs.join('\n'), Array.from(domRefs)
|
|
827
|
-
.map(function (refName) {
|
|
828
|
-
return "@ViewChild('".concat(refName, "') ").concat(refName).concat(options.typescript ? '!: ElementRef' : '');
|
|
829
|
-
})
|
|
830
|
-
.join('\n'), Array.from(dynamicComponents)
|
|
831
|
-
.map(function (component) {
|
|
832
|
-
return "@ViewChild('".concat(component
|
|
833
|
-
.split('.')[1]
|
|
834
|
-
.toLowerCase(), "Template', { static: true }) ").concat(component
|
|
835
|
-
.split('.')[1]
|
|
836
|
-
.toLowerCase(), "TemplateRef").concat(options.typescript ? '!: TemplateRef<any>' : '');
|
|
837
|
-
})
|
|
838
|
-
.join('\n'), dynamicComponents.size ? "myContent".concat(options.typescript ? '?: any[][];' : '') : '', dataString, helperFunctions.size ? Array.from(helperFunctions).join('\n') : '', jsRefs
|
|
839
|
-
.map(function (ref) {
|
|
840
|
-
var argument = json.refs[ref].argument;
|
|
841
|
-
var typeParameter = json.refs[ref].typeParameter;
|
|
842
|
-
return "private _".concat(ref).concat(typeParameter ? ": ".concat(typeParameter) : '').concat(argument
|
|
843
|
-
? " = ".concat(processAngularCode({
|
|
844
|
-
replaceWith: 'this.',
|
|
845
|
-
contextVars: contextVars,
|
|
846
|
-
outputVars: outputVars,
|
|
847
|
-
domRefs: Array.from(domRefs),
|
|
848
|
-
stateVars: stateVars,
|
|
849
|
-
})(argument))
|
|
850
|
-
: '', ";");
|
|
741
|
+
: {}),
|
|
742
|
+
};
|
|
743
|
+
// Taking into consideration what user has passed in options and allowing them to override the default generated metadata
|
|
744
|
+
Object.entries(json.meta.angularConfig || {}).forEach(([key, value]) => {
|
|
745
|
+
componentMetadata[key] = value;
|
|
746
|
+
});
|
|
747
|
+
const getPropsDefinition = ({ json }) => {
|
|
748
|
+
if (!json.defaultProps)
|
|
749
|
+
return '';
|
|
750
|
+
const defalutPropsString = Object.keys(json.defaultProps)
|
|
751
|
+
.map((prop) => {
|
|
752
|
+
var _a;
|
|
753
|
+
const value = json.defaultProps.hasOwnProperty(prop)
|
|
754
|
+
? (_a = json.defaultProps[prop]) === null || _a === void 0 ? void 0 : _a.code
|
|
755
|
+
: 'undefined';
|
|
756
|
+
return `${prop}: ${value}`;
|
|
851
757
|
})
|
|
852
|
-
.join('
|
|
853
|
-
|
|
854
|
-
: "constructor(\n".concat(injectables.join(',\n')).concat(dynamicComponents.size
|
|
855
|
-
? "\nprivate vcRef".concat(options.typescript ? ': ViewContainerRef' : '', ",\n")
|
|
856
|
-
: '', ") {}\n "), !json.hooks.onMount.length && !dynamicComponents.size && !((_h = json.hooks.onInit) === null || _h === void 0 ? void 0 : _h.code)
|
|
857
|
-
? ''
|
|
858
|
-
: "ngOnInit() {\n ".concat(!((_j = json.hooks) === null || _j === void 0 ? void 0 : _j.onInit)
|
|
859
|
-
? ''
|
|
860
|
-
: "\n ".concat((_k = json.hooks.onInit) === null || _k === void 0 ? void 0 : _k.code, "\n "), "\n ").concat(json.hooks.onMount.length > 0
|
|
861
|
-
? "\n if (typeof window !== 'undefined') {\n ".concat((0, on_mount_1.stringifySingleScopeOnMount)(json), "\n }\n ")
|
|
862
|
-
: '', "\n ").concat(dynamicComponents.size
|
|
863
|
-
? "\n this.myContent = [".concat(Array.from(dynamicComponents)
|
|
864
|
-
.map(function (component) {
|
|
865
|
-
return "this.vcRef.createEmbeddedView(this.".concat(component
|
|
866
|
-
.split('.')[1]
|
|
867
|
-
.toLowerCase(), "TemplateRef).rootNodes");
|
|
868
|
-
})
|
|
869
|
-
.join(', '), "];\n ")
|
|
870
|
-
: '', "\n }"), !((_l = json.hooks.onUpdate) === null || _l === void 0 ? void 0 : _l.length)
|
|
871
|
-
? ''
|
|
872
|
-
: "ngOnChanges(changes".concat(options.typescript ? ': SimpleChanges' : '', ") {\n if (typeof window !== 'undefined') {\n ").concat((_m = json.hooks.onUpdate) === null || _m === void 0 ? void 0 : _m.reduce(function (code, hook) {
|
|
873
|
-
code += hook.code;
|
|
874
|
-
return code + '\n';
|
|
875
|
-
}, ''), "\n }\n }\n "), !json.hooks.onUnMount
|
|
876
|
-
? ''
|
|
877
|
-
: "ngOnDestroy() {\n ".concat(json.hooks.onUnMount.code, "\n }"));
|
|
878
|
-
if (options.standalone !== true) {
|
|
879
|
-
str = generateNgModule(str, json.name, componentsUsed, json, options.bootstrapMapper);
|
|
880
|
-
}
|
|
881
|
-
if (options.plugins) {
|
|
882
|
-
str = (0, plugins_1.runPreCodePlugins)({ json: json, code: str, plugins: options.plugins });
|
|
883
|
-
}
|
|
884
|
-
if (options.prettier !== false) {
|
|
885
|
-
str = tryFormat(str, 'typescript');
|
|
886
|
-
}
|
|
887
|
-
if (options.plugins) {
|
|
888
|
-
str = (0, plugins_1.runPostCodePlugins)({ json: json, code: str, plugins: options.plugins });
|
|
889
|
-
}
|
|
890
|
-
return str;
|
|
758
|
+
.join(',');
|
|
759
|
+
return `const defaultProps = {${defalutPropsString}};\n`;
|
|
891
760
|
};
|
|
761
|
+
const angularCoreImports = [
|
|
762
|
+
...(outputs.length ? ['Output', 'EventEmitter'] : []),
|
|
763
|
+
...(((_e = options === null || options === void 0 ? void 0 : options.experimental) === null || _e === void 0 ? void 0 : _e.inject) ? ['Inject', 'forwardRef'] : []),
|
|
764
|
+
'Component',
|
|
765
|
+
...(domRefs.size || dynamicComponents.size ? ['ViewChild', 'ElementRef'] : []),
|
|
766
|
+
...(props.size ? ['Input'] : []),
|
|
767
|
+
...(dynamicComponents.size ? ['ViewContainerRef', 'TemplateRef'] : []),
|
|
768
|
+
...(((_f = json.hooks.onUpdate) === null || _f === void 0 ? void 0 : _f.length) && options.typescript ? ['SimpleChanges'] : []),
|
|
769
|
+
].join(', ');
|
|
770
|
+
let str = (0, dedent_1.dedent) `
|
|
771
|
+
import { ${angularCoreImports} } from '@angular/core';
|
|
772
|
+
${options.standalone ? `import { CommonModule } from '@angular/common';` : ''}
|
|
773
|
+
|
|
774
|
+
${json.types ? json.types.join('\n') : ''}
|
|
775
|
+
${getPropsDefinition({ json })}
|
|
776
|
+
${(0, render_imports_1.renderPreComponent)({
|
|
777
|
+
explicitImportFileExtension: options.explicitImportFileExtension,
|
|
778
|
+
component: json,
|
|
779
|
+
target: 'angular',
|
|
780
|
+
excludeMitosisComponents: !options.standalone && !options.preserveImports,
|
|
781
|
+
preserveFileExtensions: options.preserveFileExtensions,
|
|
782
|
+
componentsUsed,
|
|
783
|
+
importMapper: options === null || options === void 0 ? void 0 : options.importMapper,
|
|
784
|
+
})}
|
|
785
|
+
|
|
786
|
+
@Component({
|
|
787
|
+
${Object.entries(componentMetadata)
|
|
788
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
789
|
+
.join(',')}
|
|
790
|
+
})
|
|
791
|
+
export default class ${json.name} {
|
|
792
|
+
${localExportVars.join('\n')}
|
|
793
|
+
${customImports.map((name) => `${name} = ${name}`).join('\n')}
|
|
794
|
+
|
|
795
|
+
${Array.from(props)
|
|
796
|
+
.filter((item) => !(0, slots_1.isSlotProperty)(item) && item !== 'children')
|
|
797
|
+
.map((item) => {
|
|
798
|
+
const propType = propsTypeRef ? `${propsTypeRef}["${item}"]` : 'any';
|
|
799
|
+
let propDeclaration = `@Input() ${item}${options.typescript ? `!: ${propType}` : ''}`;
|
|
800
|
+
if (json.defaultProps && json.defaultProps.hasOwnProperty(item)) {
|
|
801
|
+
propDeclaration += ` = defaultProps["${item}"]`;
|
|
802
|
+
}
|
|
803
|
+
return propDeclaration;
|
|
804
|
+
})
|
|
805
|
+
.join('\n')}
|
|
806
|
+
|
|
807
|
+
${outputs.join('\n')}
|
|
808
|
+
|
|
809
|
+
${Array.from(domRefs)
|
|
810
|
+
.map((refName) => `@ViewChild('${refName}') ${refName}${options.typescript ? '!: ElementRef' : ''}`)
|
|
811
|
+
.join('\n')}
|
|
812
|
+
|
|
813
|
+
${Array.from(dynamicComponents)
|
|
814
|
+
.map((component) => `@ViewChild('${component
|
|
815
|
+
.split('.')[1]
|
|
816
|
+
.toLowerCase()}Template', { static: true }) ${component
|
|
817
|
+
.split('.')[1]
|
|
818
|
+
.toLowerCase()}TemplateRef${options.typescript ? '!: TemplateRef<any>' : ''}`)
|
|
819
|
+
.join('\n')}
|
|
820
|
+
|
|
821
|
+
${dynamicComponents.size ? `myContent${options.typescript ? '?: any[][];' : ''}` : ''}
|
|
822
|
+
|
|
823
|
+
${dataString}
|
|
824
|
+
|
|
825
|
+
${helperFunctions.size ? Array.from(helperFunctions).join('\n') : ''}
|
|
826
|
+
|
|
827
|
+
${jsRefs
|
|
828
|
+
.map((ref) => {
|
|
829
|
+
const argument = json.refs[ref].argument;
|
|
830
|
+
const typeParameter = json.refs[ref].typeParameter;
|
|
831
|
+
return `private _${ref}${typeParameter ? `: ${typeParameter}` : ''}${argument
|
|
832
|
+
? ` = ${processAngularCode({
|
|
833
|
+
replaceWith: 'this.',
|
|
834
|
+
contextVars,
|
|
835
|
+
outputVars,
|
|
836
|
+
domRefs: Array.from(domRefs),
|
|
837
|
+
stateVars,
|
|
838
|
+
})(argument)}`
|
|
839
|
+
: ''};`;
|
|
840
|
+
})
|
|
841
|
+
.join('\n')}
|
|
842
|
+
|
|
843
|
+
${!hasConstructor && !dynamicComponents.size
|
|
844
|
+
? ''
|
|
845
|
+
: `constructor(\n${injectables.join(',\n')}${dynamicComponents.size
|
|
846
|
+
? `\nprivate vcRef${options.typescript ? ': ViewContainerRef' : ''},\n`
|
|
847
|
+
: ''}) {}
|
|
848
|
+
`}
|
|
849
|
+
${!json.hooks.onMount.length && !dynamicComponents.size && !((_g = json.hooks.onInit) === null || _g === void 0 ? void 0 : _g.code)
|
|
850
|
+
? ''
|
|
851
|
+
: `ngOnInit() {
|
|
852
|
+
${!((_h = json.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
|
|
853
|
+
? ''
|
|
854
|
+
: `
|
|
855
|
+
${(_j = json.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code}
|
|
856
|
+
`}
|
|
857
|
+
${json.hooks.onMount.length > 0
|
|
858
|
+
? `
|
|
859
|
+
if (typeof window !== 'undefined') {
|
|
860
|
+
${(0, on_mount_1.stringifySingleScopeOnMount)(json)}
|
|
861
|
+
}
|
|
862
|
+
`
|
|
863
|
+
: ''}
|
|
864
|
+
${dynamicComponents.size
|
|
865
|
+
? `
|
|
866
|
+
this.myContent = [${Array.from(dynamicComponents)
|
|
867
|
+
.map((component) => `this.vcRef.createEmbeddedView(this.${component
|
|
868
|
+
.split('.')[1]
|
|
869
|
+
.toLowerCase()}TemplateRef).rootNodes`)
|
|
870
|
+
.join(', ')}];
|
|
871
|
+
`
|
|
872
|
+
: ''}
|
|
873
|
+
}`}
|
|
874
|
+
|
|
875
|
+
${!((_k = json.hooks.onUpdate) === null || _k === void 0 ? void 0 : _k.length)
|
|
876
|
+
? ''
|
|
877
|
+
: `ngOnChanges(changes${options.typescript ? ': SimpleChanges' : ''}) {
|
|
878
|
+
if (typeof window !== 'undefined') {
|
|
879
|
+
${(_l = json.hooks.onUpdate) === null || _l === void 0 ? void 0 : _l.reduce((code, hook) => {
|
|
880
|
+
code += hook.code;
|
|
881
|
+
return code + '\n';
|
|
882
|
+
}, '')}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
`}
|
|
886
|
+
|
|
887
|
+
${!json.hooks.onUnMount
|
|
888
|
+
? ''
|
|
889
|
+
: `ngOnDestroy() {
|
|
890
|
+
${json.hooks.onUnMount.code}
|
|
891
|
+
}`}
|
|
892
|
+
|
|
893
|
+
}
|
|
894
|
+
`;
|
|
895
|
+
if (options.standalone !== true) {
|
|
896
|
+
str = generateNgModule(str, json.name, componentsUsed, json, options.bootstrapMapper);
|
|
897
|
+
}
|
|
898
|
+
if (options.plugins) {
|
|
899
|
+
str = (0, plugins_1.runPreCodePlugins)({ json, code: str, plugins: options.plugins });
|
|
900
|
+
}
|
|
901
|
+
if (options.prettier !== false) {
|
|
902
|
+
str = tryFormat(str, 'typescript');
|
|
903
|
+
}
|
|
904
|
+
if (options.plugins) {
|
|
905
|
+
str = (0, plugins_1.runPostCodePlugins)({ json, code: str, plugins: options.plugins });
|
|
906
|
+
}
|
|
907
|
+
return str;
|
|
892
908
|
};
|
|
893
909
|
exports.componentToAngular = componentToAngular;
|
|
894
|
-
|
|
910
|
+
const tryFormat = (str, parser) => {
|
|
895
911
|
try {
|
|
896
912
|
return (0, standalone_1.format)(str, {
|
|
897
|
-
parser
|
|
913
|
+
parser,
|
|
898
914
|
plugins: [
|
|
899
915
|
// To support running in browsers
|
|
900
916
|
require('prettier/parser-typescript'),
|
|
@@ -910,4 +926,3 @@ var tryFormat = function (str, parser) {
|
|
|
910
926
|
}
|
|
911
927
|
return str;
|
|
912
928
|
};
|
|
913
|
-
var templateObject_1;
|