@builder.io/mitosis 0.3.2 → 0.3.3

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.
@@ -1,4 +1,4 @@
1
- import { JSX } from '@builder.io/mitosis/jsx-runtime';
1
+ import { JSX } from '../jsx-runtime';
2
2
  import { Dictionary } from './helpers/typescript';
3
3
  import { ComponentMetadata } from './types/metadata';
4
4
  import { ReactivityType, TargetBlock } from './types/mitosis-component';
@@ -15,6 +15,7 @@ type BuilderToMitosisOptions = {
15
15
  includeMeta?: boolean;
16
16
  };
17
17
  export declare const builderElementToMitosisNode: (block: BuilderElement, options: BuilderToMitosisOptions, _internalOptions?: InternalOptions) => MitosisNode;
18
+ export declare const getMetaFromBlock: (block: BuilderElement, options: BuilderToMitosisOptions) => {};
18
19
  /**
19
20
  * Take Builder custom jsCode and extract the contents of the useState hook
20
21
  * and return it as a JS object along with the inputted code with the hook
@@ -46,7 +46,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
47
  };
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.builderContentToMitosisComponent = exports.isBuilderElement = exports.createBuilderElement = exports.convertExportDefaultToReturn = exports.extractStateHook = exports.builderElementToMitosisNode = exports.symbolBlocksAsChildren = void 0;
49
+ exports.builderContentToMitosisComponent = exports.isBuilderElement = exports.createBuilderElement = exports.convertExportDefaultToReturn = exports.extractStateHook = exports.getMetaFromBlock = exports.builderElementToMitosisNode = exports.symbolBlocksAsChildren = void 0;
50
50
  var symbol_processor_1 = require("../../symbols/symbol-processor");
51
51
  var babel = __importStar(require("@babel/core"));
52
52
  var generator_1 = __importDefault(require("@babel/generator"));
@@ -258,6 +258,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
258
258
  return (0, create_mitosis_node_1.createMitosisNode)({
259
259
  name: 'Symbol',
260
260
  bindings: bindings,
261
+ meta: (0, exports.getMetaFromBlock)(block, options),
261
262
  });
262
263
  } }, (!exports.symbolBlocksAsChildren
263
264
  ? {}
@@ -286,6 +287,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
286
287
  })), (Object.keys(css).length && {
287
288
  css: (0, bindings_1.createSingleBinding)({ code: JSON.stringify(css) }),
288
289
  })),
290
+ meta: (0, exports.getMetaFromBlock)(block, options),
289
291
  children: !blocks
290
292
  ? []
291
293
  : [
@@ -313,7 +315,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
313
315
  properties: {
314
316
  link: col.link,
315
317
  },
316
- })), { children: col.blocks.map(function (col) { return (0, exports.builderElementToMitosisNode)(col, options); }) }));
318
+ })), { meta: (0, exports.getMetaFromBlock)(block, options), children: col.blocks.map(function (col) { return (0, exports.builderElementToMitosisNode)(col, options); }) }));
317
319
  })) || [];
318
320
  return node;
319
321
  }, 'Shopify:For': function (block, options) {
@@ -328,6 +330,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
328
330
  forName: block.component.options.repeat.itemName,
329
331
  indexName: '$index',
330
332
  },
333
+ meta: (0, exports.getMetaFromBlock)(block, options),
331
334
  children: (block.children || []).map(function (child) { return (0, exports.builderElementToMitosisNode)(child, options); }),
332
335
  });
333
336
  }, Text: function (block, options) {
@@ -374,6 +377,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
374
377
  name: block.tagName || 'div',
375
378
  bindings: bindings,
376
379
  properties: properties,
380
+ meta: (0, exports.getMetaFromBlock)(block, options),
377
381
  children: [
378
382
  (0, create_mitosis_node_1.createMitosisNode)({
379
383
  bindings: innerBindings,
@@ -399,6 +403,7 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
399
403
  name: finalTagname,
400
404
  bindings: bindings,
401
405
  properties: finalProperties,
406
+ meta: (0, exports.getMetaFromBlock)(block, options),
402
407
  children: [
403
408
  (0, create_mitosis_node_1.createMitosisNode)({
404
409
  bindings: innerBindings,
@@ -411,13 +416,14 @@ var componentMappers = __assign(__assign({ Symbol: function (block, options) {
411
416
  name: finalTagname,
412
417
  properties: __assign(__assign(__assign({}, finalProperties), properties), innerProperties),
413
418
  bindings: __assign(__assign({}, bindings), innerBindings),
419
+ meta: (0, exports.getMetaFromBlock)(block, options),
414
420
  });
415
421
  } });
416
422
  var builderElementToMitosisNode = function (block, options, _internalOptions) {
417
423
  var _a;
418
424
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
419
425
  if (_internalOptions === void 0) { _internalOptions = {}; }
420
- var _x = options.includeSpecialBindings, includeSpecialBindings = _x === void 0 ? true : _x, _y = options.includeMeta, includeMeta = _y === void 0 ? false : _y;
426
+ var _x = options.includeSpecialBindings, includeSpecialBindings = _x === void 0 ? true : _x;
421
427
  if (((_b = block.component) === null || _b === void 0 ? void 0 : _b.name) === 'Core:Fragment') {
422
428
  block.component.name = 'Fragment';
423
429
  }
@@ -437,6 +443,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
437
443
  forName: ((_f = block.repeat) === null || _f === void 0 ? void 0 : _f.itemName) || 'item',
438
444
  indexName: '$index',
439
445
  },
446
+ meta: (0, exports.getMetaFromBlock)(block, options),
440
447
  children: ((_g = block.children) === null || _g === void 0 ? void 0 : _g.map(function (child) { return (0, exports.builderElementToMitosisNode)(child, options); })) || [],
441
448
  });
442
449
  }
@@ -455,6 +462,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
455
462
  forName: ((_l = block.repeat) === null || _l === void 0 ? void 0 : _l.itemName) || 'item',
456
463
  indexName: '$index',
457
464
  },
465
+ meta: (0, exports.getMetaFromBlock)(block, options),
458
466
  children: [(0, exports.builderElementToMitosisNode)((0, lodash_1.omit)(useBlock, 'repeat'), options)],
459
467
  });
460
468
  }
@@ -476,6 +484,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
476
484
  return (0, create_mitosis_node_1.createMitosisNode)({
477
485
  name: 'Show',
478
486
  bindings: { when: (0, bindings_1.createSingleBinding)({ code: code }) },
487
+ meta: (0, exports.getMetaFromBlock)(block, options),
479
488
  children: ((_o = block.children) === null || _o === void 0 ? void 0 : _o.map(function (child) { return (0, exports.builderElementToMitosisNode)(child, options); })) || [],
480
489
  });
481
490
  }
@@ -483,6 +492,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
483
492
  return (0, create_mitosis_node_1.createMitosisNode)({
484
493
  name: 'Show',
485
494
  bindings: { when: (0, bindings_1.createSingleBinding)({ code: code }) },
495
+ meta: (0, exports.getMetaFromBlock)(block, options),
486
496
  children: [
487
497
  (0, exports.builderElementToMitosisNode)(__assign(__assign({}, block), { code: __assign(__assign({}, block.code), { bindings: (0, lodash_1.omit)(blockBindings, 'show', 'hide') }), bindings: (0, lodash_1.omit)(blockBindings, 'show', 'hide') }), options),
488
498
  ],
@@ -580,8 +590,7 @@ var builderElementToMitosisNode = function (block, options, _internalOptions) {
580
590
  css: (0, bindings_1.createSingleBinding)({ code: JSON.stringify(css) }),
581
591
  })),
582
592
  slots: __assign({}, slots),
583
- meta: includeMeta
584
- ? __assign({ 'builder-id': block.id }, block.meta) : {},
593
+ meta: (0, exports.getMetaFromBlock)(block, options),
585
594
  });
586
595
  // Has single text node child
587
596
  var firstChild = (_s = block.children) === null || _s === void 0 ? void 0 : _s[0];
@@ -623,6 +632,12 @@ var getBuilderPropsForSymbol = function (block) {
623
632
  }
624
633
  return undefined;
625
634
  };
635
+ var getMetaFromBlock = function (block, options) {
636
+ var _a = options.includeMeta, includeMeta = _a === void 0 ? false : _a;
637
+ return includeMeta
638
+ ? __assign({ 'builder-id': block.id }, block.meta) : {};
639
+ };
640
+ exports.getMetaFromBlock = getMetaFromBlock;
626
641
  var getHooks = function (content) {
627
642
  var _a, _b;
628
643
  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) || '');
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.2",
25
+ "version": "0.3.3",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {