@builder.io/mitosis 0.3.22 → 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.
@@ -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 ? '' : "useState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(component), ");"), !component.hooks.onMount.length
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 useState hook
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)), mapBuilderBindingsToMitosisBindingWithCode(block.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 = (_a = {},
373
- _a[options.preserveTextBlocks ? 'innerHTML' : '_text'] = text,
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 useState to be a variable assignment,
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("useState(", "var state = useState("), "\n }"));
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 useState hook
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 useState
672
+ // Check for useStore
671
673
  if (types.isCallExpression(expression)) {
672
- if (types.isIdentifier(expression.callee) && expression.callee.name === 'useState') {
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);
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "name": "Builder.io",
23
23
  "url": "https://www.builder.io"
24
24
  },
25
- "version": "0.3.22",
25
+ "version": "0.4.0",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {