@builder.io/mitosis 0.3.20 → 0.3.21
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.
|
@@ -264,10 +264,10 @@ var handleNgOutletBindings = function (node, options) {
|
|
|
264
264
|
return allProps;
|
|
265
265
|
};
|
|
266
266
|
var blockToAngular = function (_a) {
|
|
267
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
268
|
-
var root = _a.root, json = _a.json,
|
|
267
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
268
|
+
var root = _a.root, json = _a.json, _m = _a.options, options = _m === void 0 ? {} : _m, _o = _a.blockOptions, blockOptions = _o === void 0 ? {
|
|
269
269
|
nativeAttributes: [],
|
|
270
|
-
} :
|
|
270
|
+
} : _o;
|
|
271
271
|
var childComponents = (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.childComponents) || [];
|
|
272
272
|
if (mappers[json.name]) {
|
|
273
273
|
return mappers[json.name](root, json, options);
|
|
@@ -339,7 +339,7 @@ var blockToAngular = function (_a) {
|
|
|
339
339
|
if (options.state === 'class-properties') {
|
|
340
340
|
var inputsPropsStateName = "mergedInputs_".concat((0, symbol_processor_1.hashCodeAsString)(allProps));
|
|
341
341
|
root.state[inputsPropsStateName] = {
|
|
342
|
-
code: '
|
|
342
|
+
code: '{}' + (options.typescript ? ' as any' : ''),
|
|
343
343
|
type: 'property',
|
|
344
344
|
};
|
|
345
345
|
if (!((_k = root.hooks.onInit) === null || _k === void 0 ? void 0 : _k.code.includes(inputsPropsStateName))) {
|
|
@@ -348,12 +348,10 @@ var blockToAngular = function (_a) {
|
|
|
348
348
|
}
|
|
349
349
|
root.hooks.onInit.code += "\nthis.".concat(inputsPropsStateName, " = {").concat(allProps, "};\n");
|
|
350
350
|
}
|
|
351
|
-
if (root.hooks.onUpdate
|
|
352
|
-
root.hooks.onUpdate
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
.join('')
|
|
356
|
-
.includes(inputsPropsStateName)) {
|
|
351
|
+
if (!((_l = root.hooks.onUpdate) === null || _l === void 0 ? void 0 : _l.map(function (hook) { return hook.code; }).join('').includes(inputsPropsStateName))) {
|
|
352
|
+
if (!root.hooks.onUpdate) {
|
|
353
|
+
root.hooks.onUpdate = [];
|
|
354
|
+
}
|
|
357
355
|
root.hooks.onUpdate.push({
|
|
358
356
|
code: "this.".concat(inputsPropsStateName, " = {").concat(allProps, "}"),
|
|
359
357
|
});
|
|
@@ -596,7 +594,7 @@ var transformState = function (json) {
|
|
|
596
594
|
var componentToAngular = function (userOptions) {
|
|
597
595
|
if (userOptions === void 0) { userOptions = {}; }
|
|
598
596
|
return function (_a) {
|
|
599
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
597
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
600
598
|
var _component = _a.component;
|
|
601
599
|
// Make a copy we can safely mutate, similar to babel's toolchain
|
|
602
600
|
var json = (0, fast_clone_1.fastClone)(_component);
|
|
@@ -663,7 +661,7 @@ var componentToAngular = function (userOptions) {
|
|
|
663
661
|
if (options.plugins) {
|
|
664
662
|
json = (0, plugins_1.runPreJsonPlugins)({ json: json, plugins: options.plugins });
|
|
665
663
|
}
|
|
666
|
-
var
|
|
664
|
+
var _o = (0, get_props_ref_1.getPropsRef)(json, true), forwardProp = _o[0], hasPropRef = _o[1];
|
|
667
665
|
var childComponents = [];
|
|
668
666
|
var propsTypeRef = json.propsTypeRef !== 'any' ? json.propsTypeRef : undefined;
|
|
669
667
|
json.imports.forEach(function (_a) {
|
|
@@ -675,7 +673,7 @@ var componentToAngular = function (userOptions) {
|
|
|
675
673
|
});
|
|
676
674
|
});
|
|
677
675
|
var customImports = (0, get_custom_imports_1.getCustomImports)(json);
|
|
678
|
-
var
|
|
676
|
+
var _p = json.exports, localExports = _p === void 0 ? {} : _p;
|
|
679
677
|
var localExportVars = Object.keys(localExports)
|
|
680
678
|
.filter(function (key) { return localExports[key].usedInLocal; })
|
|
681
679
|
.map(function (key) { return "".concat(key, " = ").concat(key, ";"); });
|
|
@@ -750,10 +748,10 @@ var componentToAngular = function (userOptions) {
|
|
|
750
748
|
template = tryFormat(template, 'html');
|
|
751
749
|
}
|
|
752
750
|
(0, strip_meta_properties_1.stripMetaProperties)(json);
|
|
753
|
-
var
|
|
751
|
+
var _q = traverseToGetAllDynamicComponents(json, options, {
|
|
754
752
|
childComponents: childComponents,
|
|
755
753
|
nativeAttributes: (_e = (_d = useMetadata === null || useMetadata === void 0 ? void 0 : useMetadata.angular) === null || _d === void 0 ? void 0 : _d.nativeAttributes) !== null && _e !== void 0 ? _e : [],
|
|
756
|
-
}), dynamicComponents =
|
|
754
|
+
}), dynamicComponents = _q.components, dynamicTemplate = _q.dynamicTemplate;
|
|
757
755
|
transformState(json);
|
|
758
756
|
var dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
|
|
759
757
|
format: 'class',
|
|
@@ -799,7 +797,10 @@ var componentToAngular = function (userOptions) {
|
|
|
799
797
|
.join(',');
|
|
800
798
|
return "const defaultProps = {".concat(defalutPropsString, "};\n");
|
|
801
799
|
};
|
|
802
|
-
var
|
|
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 ? ['ViewChild', '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)({
|
|
803
804
|
explicitImportFileExtension: options.explicitImportFileExtension,
|
|
804
805
|
component: json,
|
|
805
806
|
target: 'angular',
|
|
@@ -852,11 +853,11 @@ var componentToAngular = function (userOptions) {
|
|
|
852
853
|
? ''
|
|
853
854
|
: "constructor(\n".concat(injectables.join(',\n')).concat(dynamicComponents.size
|
|
854
855
|
? "\nprivate vcRef".concat(options.typescript ? ': ViewContainerRef' : '', ",\n")
|
|
855
|
-
: '', ") {}\n "), !json.hooks.onMount.length && !dynamicComponents.size && !((
|
|
856
|
+
: '', ") {}\n "), !json.hooks.onMount.length && !dynamicComponents.size && !((_h = json.hooks.onInit) === null || _h === void 0 ? void 0 : _h.code)
|
|
856
857
|
? ''
|
|
857
|
-
: "ngOnInit() {\n ".concat(!((
|
|
858
|
+
: "ngOnInit() {\n ".concat(!((_j = json.hooks) === null || _j === void 0 ? void 0 : _j.onInit)
|
|
858
859
|
? ''
|
|
859
|
-
: "\n ".concat((
|
|
860
|
+
: "\n ".concat((_k = json.hooks.onInit) === null || _k === void 0 ? void 0 : _k.code, "\n "), "\n ").concat(json.hooks.onMount.length > 0
|
|
860
861
|
? "\n if (typeof window !== 'undefined') {\n ".concat((0, on_mount_1.stringifySingleScopeOnMount)(json), "\n }\n ")
|
|
861
862
|
: '', "\n ").concat(dynamicComponents.size
|
|
862
863
|
? "\n this.myContent = [".concat(Array.from(dynamicComponents)
|
|
@@ -866,9 +867,9 @@ var componentToAngular = function (userOptions) {
|
|
|
866
867
|
.toLowerCase(), "TemplateRef).rootNodes");
|
|
867
868
|
})
|
|
868
869
|
.join(', '), "];\n ")
|
|
869
|
-
: '', "\n }"), !((
|
|
870
|
+
: '', "\n }"), !((_l = json.hooks.onUpdate) === null || _l === void 0 ? void 0 : _l.length)
|
|
870
871
|
? ''
|
|
871
|
-
: "ngOnChanges() {\n if (typeof window !== 'undefined') {\n ".concat((
|
|
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) {
|
|
872
873
|
code += hook.code;
|
|
873
874
|
return code + '\n';
|
|
874
875
|
}, ''), "\n }\n }\n "), !json.hooks.onUnMount
|