@builder.io/mitosis 0.3.21 → 0.4.0
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.
|
@@ -799,7 +799,7 @@ var componentToAngular = function (userOptions) {
|
|
|
799
799
|
};
|
|
800
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
801
|
'Component'
|
|
802
|
-
], false), (domRefs.size || dynamicComponents.size ? ['ViewChild', 'ElementRef'] : []), true), (props.size ? ['Input'] : []), true), (dynamicComponents.size ? ['
|
|
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
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
804
|
explicitImportFileExtension: options.explicitImportFileExtension,
|
|
805
805
|
component: json,
|
|
@@ -243,7 +243,7 @@ var componentToBuilder = function (options) {
|
|
|
243
243
|
data: {
|
|
244
244
|
httpRequests: (_c = (_b = component === null || component === void 0 ? void 0 : component.meta) === null || _b === void 0 ? void 0 : _b.useMetadata) === null || _c === void 0 ? void 0 : _c.httpRequests,
|
|
245
245
|
jsCode: tryFormat((0, dedent_1.dedent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n\n ", "\n \n ", "\n "], ["\n ", "\n\n ", "\n \n ", "\n "])), !(0, has_props_1.hasProps)(component) ? '' : "var props = state;", !hasState ? '' : "Object.assign(state, ".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(component), ");"), (0, on_mount_1.stringifySingleScopeOnMount)(component))),
|
|
246
|
-
tsCode: tryFormat((0, dedent_1.dedent)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n\n ", "\n\n ", "\n "], ["\n ", "\n\n ", "\n\n ", "\n "])), !(0, has_props_1.hasProps)(component) ? '' : "var props = state;", !hasState ? '' : "
|
|
246
|
+
tsCode: tryFormat((0, dedent_1.dedent)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n\n ", "\n\n ", "\n "], ["\n ", "\n\n ", "\n\n ", "\n "])), !(0, has_props_1.hasProps)(component) ? '' : "var props = state;", !hasState ? '' : "useStore(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(component), ");"), !component.hooks.onMount.length
|
|
247
247
|
? ''
|
|
248
248
|
: "onMount(() => {\n ".concat((0, on_mount_1.stringifySingleScopeOnMount)(component), "\n })"))),
|
|
249
249
|
blocks: component.children
|
|
@@ -17,7 +17,7 @@ type BuilderToMitosisOptions = {
|
|
|
17
17
|
export declare const builderElementToMitosisNode: (block: BuilderElement, options: BuilderToMitosisOptions, _internalOptions?: InternalOptions) => MitosisNode;
|
|
18
18
|
export declare const getMetaFromBlock: (block: BuilderElement, options: BuilderToMitosisOptions) => {};
|
|
19
19
|
/**
|
|
20
|
-
* Take Builder custom jsCode and extract the contents of the
|
|
20
|
+
* Take Builder custom jsCode and extract the contents of the useStore hook
|
|
21
21
|
* and return it as a JS object along with the inputted code with the hook
|
|
22
22
|
* code extracted
|
|
23
23
|
*/
|
|
@@ -339,7 +339,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
|
|
|
339
339
|
var css = getCssFromBlock(block);
|
|
340
340
|
var styleString = getStyleStringFromBlock(block, options);
|
|
341
341
|
var actionBindings = getActionBindingsFromBlock(block, options);
|
|
342
|
-
var blockBindings = __assign(__assign({}, mapBuilderBindingsToMitosisBindingWithCode((_b = block.code) === null || _b === void 0 ? void 0 : _b.bindings))
|
|
342
|
+
var blockBindings = __assign(__assign({}, mapBuilderBindingsToMitosisBindingWithCode(block.bindings)), mapBuilderBindingsToMitosisBindingWithCode((_b = block.code) === null || _b === void 0 ? void 0 : _b.bindings));
|
|
343
343
|
var bindings = __assign(__assign(__assign(__assign({}, (0, lodash_1.omitBy)(blockBindings, function (value, key) {
|
|
344
344
|
if (key === 'component.options.text') {
|
|
345
345
|
return true;
|
|
@@ -369,9 +369,11 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
|
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
371
|
var text = block.component.options.text;
|
|
372
|
-
var innerProperties =
|
|
373
|
-
|
|
374
|
-
_a
|
|
372
|
+
var innerProperties = innerBindings._text
|
|
373
|
+
? {}
|
|
374
|
+
: (_a = {},
|
|
375
|
+
_a[options.preserveTextBlocks ? 'innerHTML' : '_text'] = text,
|
|
376
|
+
_a);
|
|
375
377
|
if (options.preserveTextBlocks) {
|
|
376
378
|
return (0, create_mitosis_node_1.createMitosisNode)({
|
|
377
379
|
name: block.tagName || 'div',
|
|
@@ -643,10 +645,10 @@ var getHooks = function (content) {
|
|
|
643
645
|
var code = convertExportDefaultToReturn(((_a = content.data) === null || _a === void 0 ? void 0 : _a.tsCode) || ((_b = content.data) === null || _b === void 0 ? void 0 : _b.jsCode) || '');
|
|
644
646
|
try {
|
|
645
647
|
return (0, jsx_1.parseJsx)("\n export default function TemporaryComponent() {\n ".concat(
|
|
646
|
-
// Mitosis parser looks for
|
|
648
|
+
// Mitosis parser looks for useStore to be a variable assignment,
|
|
647
649
|
// but in Builder that's not how it works. For now do a replace to
|
|
648
650
|
// easily resuse the same parsing code as this is the only difference
|
|
649
|
-
code.replace("
|
|
651
|
+
code.replace("useStore(", "var state = useStore("), "\n }"));
|
|
650
652
|
}
|
|
651
653
|
catch (err) {
|
|
652
654
|
console.warn('Could not parse js code as a Mitosis component body', err, code);
|
|
@@ -654,7 +656,7 @@ var getHooks = function (content) {
|
|
|
654
656
|
}
|
|
655
657
|
};
|
|
656
658
|
/**
|
|
657
|
-
* Take Builder custom jsCode and extract the contents of the
|
|
659
|
+
* Take Builder custom jsCode and extract the contents of the useStore hook
|
|
658
660
|
* and return it as a JS object along with the inputted code with the hook
|
|
659
661
|
* code extracted
|
|
660
662
|
*/
|
|
@@ -667,9 +669,9 @@ function extractStateHook(code) {
|
|
|
667
669
|
var statement = body[i];
|
|
668
670
|
if (types.isExpressionStatement(statement)) {
|
|
669
671
|
var expression = statement.expression;
|
|
670
|
-
// Check for
|
|
672
|
+
// Check for useStore
|
|
671
673
|
if (types.isCallExpression(expression)) {
|
|
672
|
-
if (types.isIdentifier(expression.callee) && expression.callee.name === '
|
|
674
|
+
if (types.isIdentifier(expression.callee) && expression.callee.name === 'useStore') {
|
|
673
675
|
var arg = expression.arguments[0];
|
|
674
676
|
if (types.isObjectExpression(arg)) {
|
|
675
677
|
state = (0, state_1.parseStateObjectToMitosisState)(arg);
|