@plasmicapp/loader-react 1.0.32 → 1.0.36

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.
@@ -1034,7 +1034,7 @@ function toFullLookup(lookup) {
1034
1034
  };
1035
1035
  } else {
1036
1036
  return {
1037
- name: normalizeName(namePart),
1037
+ name: codeComponent ? namePart : normalizeName(namePart),
1038
1038
  projectId: projectId,
1039
1039
  isCode: codeComponent
1040
1040
  };
@@ -1407,53 +1407,100 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1407
1407
  };
1408
1408
 
1409
1409
  _proto.maybeFetchComponentData = /*#__PURE__*/function () {
1410
- var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1411
- var _this$maybeGetCompMet,
1410
+ var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1411
+ var _this = this;
1412
+
1413
+ var _len2,
1414
+ specs,
1415
+ _key2,
1416
+ returnWithSpecsToFetch,
1417
+ _this$maybeGetCompMet2,
1412
1418
  existingMetas,
1413
1419
  missingSpecs,
1414
- _this$maybeGetCompMet2,
1415
- existingMetas2,
1416
- missingSpecs2,
1417
- _args = arguments;
1420
+ _args2 = arguments;
1418
1421
 
1419
- return runtime_1.wrap(function _callee$(_context) {
1422
+ return runtime_1.wrap(function _callee2$(_context2) {
1420
1423
  while (1) {
1421
- switch (_context.prev = _context.next) {
1424
+ switch (_context2.prev = _context2.next) {
1422
1425
  case 0:
1423
- _this$maybeGetCompMet = this.maybeGetCompMetas.apply(this, _args), existingMetas = _this$maybeGetCompMet.found, missingSpecs = _this$maybeGetCompMet.missing;
1426
+ for (_len2 = _args2.length, specs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1427
+ specs[_key2] = _args2[_key2];
1428
+ }
1424
1429
 
1425
- if (!(missingSpecs.length === 0)) {
1426
- _context.next = 3;
1430
+ returnWithSpecsToFetch = /*#__PURE__*/function () {
1431
+ var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
1432
+ var _this$maybeGetCompMet, existingMetas2, missingSpecs2;
1433
+
1434
+ return runtime_1.wrap(function _callee$(_context) {
1435
+ while (1) {
1436
+ switch (_context.prev = _context.next) {
1437
+ case 0:
1438
+ _context.next = 2;
1439
+ return _this.fetchMissingData({
1440
+ missingSpecs: specsToFetch
1441
+ });
1442
+
1443
+ case 2:
1444
+ _this$maybeGetCompMet = _this.maybeGetCompMetas.apply(_this, specs), existingMetas2 = _this$maybeGetCompMet.found, missingSpecs2 = _this$maybeGetCompMet.missing;
1445
+
1446
+ if (!(missingSpecs2.length > 0)) {
1447
+ _context.next = 5;
1448
+ break;
1449
+ }
1450
+
1451
+ return _context.abrupt("return", null);
1452
+
1453
+ case 5:
1454
+ return _context.abrupt("return", prepComponentData.apply(void 0, [_this.bundle].concat(existingMetas2)));
1455
+
1456
+ case 6:
1457
+ case "end":
1458
+ return _context.stop();
1459
+ }
1460
+ }
1461
+ }, _callee);
1462
+ }));
1463
+
1464
+ return function returnWithSpecsToFetch(_x) {
1465
+ return _ref.apply(this, arguments);
1466
+ };
1467
+ }();
1468
+
1469
+ if (!this.opts.alwaysFresh) {
1470
+ _context2.next = 6;
1427
1471
  break;
1428
1472
  }
1429
1473
 
1430
- return _context.abrupt("return", prepComponentData.apply(void 0, [this.bundle].concat(existingMetas)));
1431
-
1432
- case 3:
1433
- _context.next = 5;
1434
- return this.fetchMissingData({
1435
- missingSpecs: missingSpecs
1436
- });
1474
+ _context2.next = 5;
1475
+ return returnWithSpecsToFetch(specs);
1437
1476
 
1438
1477
  case 5:
1439
- _this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, _args), existingMetas2 = _this$maybeGetCompMet2.found, missingSpecs2 = _this$maybeGetCompMet2.missing;
1478
+ return _context2.abrupt("return", _context2.sent);
1440
1479
 
1441
- if (!(missingSpecs2.length > 0)) {
1442
- _context.next = 8;
1480
+ case 6:
1481
+ // Else we only fetch actually missing specs
1482
+ _this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, specs), existingMetas = _this$maybeGetCompMet2.found, missingSpecs = _this$maybeGetCompMet2.missing;
1483
+
1484
+ if (!(missingSpecs.length === 0)) {
1485
+ _context2.next = 9;
1443
1486
  break;
1444
1487
  }
1445
1488
 
1446
- return _context.abrupt("return", null);
1447
-
1448
- case 8:
1449
- return _context.abrupt("return", prepComponentData.apply(void 0, [this.bundle].concat(existingMetas2)));
1489
+ return _context2.abrupt("return", prepComponentData.apply(void 0, [this.bundle].concat(existingMetas)));
1450
1490
 
1451
1491
  case 9:
1492
+ _context2.next = 11;
1493
+ return returnWithSpecsToFetch(missingSpecs);
1494
+
1495
+ case 11:
1496
+ return _context2.abrupt("return", _context2.sent);
1497
+
1498
+ case 12:
1452
1499
  case "end":
1453
- return _context.stop();
1500
+ return _context2.stop();
1454
1501
  }
1455
1502
  }
1456
- }, _callee, this);
1503
+ }, _callee2, this);
1457
1504
  }));
1458
1505
 
1459
1506
  function maybeFetchComponentData() {
@@ -1464,39 +1511,39 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1464
1511
  }();
1465
1512
 
1466
1513
  _proto.fetchComponentData = /*#__PURE__*/function () {
1467
- var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1514
+ var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
1468
1515
  var data,
1469
1516
  _this$maybeGetCompMet3,
1470
1517
  missingSpecs,
1471
- _args2 = arguments;
1518
+ _args3 = arguments;
1472
1519
 
1473
- return runtime_1.wrap(function _callee2$(_context2) {
1520
+ return runtime_1.wrap(function _callee3$(_context3) {
1474
1521
  while (1) {
1475
- switch (_context2.prev = _context2.next) {
1522
+ switch (_context3.prev = _context3.next) {
1476
1523
  case 0:
1477
- _context2.next = 2;
1478
- return this.maybeFetchComponentData.apply(this, _args2);
1524
+ _context3.next = 2;
1525
+ return this.maybeFetchComponentData.apply(this, _args3);
1479
1526
 
1480
1527
  case 2:
1481
- data = _context2.sent;
1528
+ data = _context3.sent;
1482
1529
 
1483
1530
  if (data) {
1484
- _context2.next = 6;
1531
+ _context3.next = 6;
1485
1532
  break;
1486
1533
  }
1487
1534
 
1488
- _this$maybeGetCompMet3 = this.maybeGetCompMetas.apply(this, _args2), missingSpecs = _this$maybeGetCompMet3.missing;
1535
+ _this$maybeGetCompMet3 = this.maybeGetCompMetas.apply(this, _args3), missingSpecs = _this$maybeGetCompMet3.missing;
1489
1536
  throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
1490
1537
 
1491
1538
  case 6:
1492
- return _context2.abrupt("return", data);
1539
+ return _context3.abrupt("return", data);
1493
1540
 
1494
1541
  case 7:
1495
1542
  case "end":
1496
- return _context2.stop();
1543
+ return _context3.stop();
1497
1544
  }
1498
1545
  }
1499
- }, _callee2, this);
1546
+ }, _callee3, this);
1500
1547
  }));
1501
1548
 
1502
1549
  function fetchComponentData() {
@@ -1507,30 +1554,30 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1507
1554
  }();
1508
1555
 
1509
1556
  _proto.fetchPages = /*#__PURE__*/function () {
1510
- var _fetchPages = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
1557
+ var _fetchPages = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
1511
1558
  var data;
1512
- return runtime_1.wrap(function _callee3$(_context3) {
1559
+ return runtime_1.wrap(function _callee4$(_context4) {
1513
1560
  while (1) {
1514
- switch (_context3.prev = _context3.next) {
1561
+ switch (_context4.prev = _context4.next) {
1515
1562
  case 0:
1516
1563
  this.maybeReportClientSideFetch(function () {
1517
1564
  return "Plasmic: fetching all page metadata in the browser";
1518
1565
  });
1519
- _context3.next = 3;
1566
+ _context4.next = 3;
1520
1567
  return this.fetchAllData();
1521
1568
 
1522
1569
  case 3:
1523
- data = _context3.sent;
1524
- return _context3.abrupt("return", data.components.filter(function (comp) {
1570
+ data = _context4.sent;
1571
+ return _context4.abrupt("return", data.components.filter(function (comp) {
1525
1572
  return comp.isPage && comp.path;
1526
1573
  }));
1527
1574
 
1528
1575
  case 5:
1529
1576
  case "end":
1530
- return _context3.stop();
1577
+ return _context4.stop();
1531
1578
  }
1532
1579
  }
1533
- }, _callee3, this);
1580
+ }, _callee4, this);
1534
1581
  }));
1535
1582
 
1536
1583
  function fetchPages() {
@@ -1541,28 +1588,28 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1541
1588
  }();
1542
1589
 
1543
1590
  _proto.fetchComponents = /*#__PURE__*/function () {
1544
- var _fetchComponents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
1591
+ var _fetchComponents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
1545
1592
  var data;
1546
- return runtime_1.wrap(function _callee4$(_context4) {
1593
+ return runtime_1.wrap(function _callee5$(_context5) {
1547
1594
  while (1) {
1548
- switch (_context4.prev = _context4.next) {
1595
+ switch (_context5.prev = _context5.next) {
1549
1596
  case 0:
1550
1597
  this.maybeReportClientSideFetch(function () {
1551
1598
  return "Plasmic: fetching all component metadata in the browser";
1552
1599
  });
1553
- _context4.next = 3;
1600
+ _context5.next = 3;
1554
1601
  return this.fetchAllData();
1555
1602
 
1556
1603
  case 3:
1557
- data = _context4.sent;
1558
- return _context4.abrupt("return", data.components);
1604
+ data = _context5.sent;
1605
+ return _context5.abrupt("return", data.components);
1559
1606
 
1560
1607
  case 5:
1561
1608
  case "end":
1562
- return _context4.stop();
1609
+ return _context5.stop();
1563
1610
  }
1564
1611
  }
1565
- }, _callee4, this);
1612
+ }, _callee5, this);
1566
1613
  }));
1567
1614
 
1568
1615
  function fetchComponents() {
@@ -1580,10 +1627,10 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1580
1627
  _proto.fetchMissingData =
1581
1628
  /*#__PURE__*/
1582
1629
  function () {
1583
- var _fetchMissingData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(opts) {
1584
- return runtime_1.wrap(function _callee5$(_context5) {
1630
+ var _fetchMissingData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(opts) {
1631
+ return runtime_1.wrap(function _callee6$(_context6) {
1585
1632
  while (1) {
1586
- switch (_context5.prev = _context5.next) {
1633
+ switch (_context6.prev = _context6.next) {
1587
1634
  case 0:
1588
1635
  // TODO: do better than just fetching everything
1589
1636
  this.maybeReportClientSideFetch(function () {
@@ -1591,17 +1638,17 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1591
1638
  return getLookupSpecName(spec);
1592
1639
  }).join(', ');
1593
1640
  });
1594
- return _context5.abrupt("return", this.fetchAllData());
1641
+ return _context6.abrupt("return", this.fetchAllData());
1595
1642
 
1596
1643
  case 2:
1597
1644
  case "end":
1598
- return _context5.stop();
1645
+ return _context6.stop();
1599
1646
  }
1600
1647
  }
1601
- }, _callee5, this);
1648
+ }, _callee6, this);
1602
1649
  }));
1603
1650
 
1604
- function fetchMissingData(_x) {
1651
+ function fetchMissingData(_x2) {
1605
1652
  return _fetchMissingData.apply(this, arguments);
1606
1653
  }
1607
1654
 
@@ -1621,29 +1668,29 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1621
1668
  };
1622
1669
 
1623
1670
  _proto.fetchAllData = /*#__PURE__*/function () {
1624
- var _fetchAllData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
1671
+ var _fetchAllData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
1625
1672
  var bundle;
1626
- return runtime_1.wrap(function _callee6$(_context6) {
1673
+ return runtime_1.wrap(function _callee7$(_context7) {
1627
1674
  while (1) {
1628
- switch (_context6.prev = _context6.next) {
1675
+ switch (_context7.prev = _context7.next) {
1629
1676
  case 0:
1630
- _context6.next = 2;
1677
+ _context7.next = 2;
1631
1678
  return this.ensureFetcher().fetchAllData();
1632
1679
 
1633
1680
  case 2:
1634
- bundle = _context6.sent;
1681
+ bundle = _context7.sent;
1635
1682
  this.mergeBundle(bundle);
1636
1683
  this.roots.forEach(function (watcher) {
1637
1684
  return watcher.onDataFetched == null ? void 0 : watcher.onDataFetched();
1638
1685
  });
1639
- return _context6.abrupt("return", bundle);
1686
+ return _context7.abrupt("return", bundle);
1640
1687
 
1641
1688
  case 6:
1642
1689
  case "end":
1643
- return _context6.stop();
1690
+ return _context7.stop();
1644
1691
  }
1645
1692
  }
1646
- }, _callee6, this);
1693
+ }, _callee7, this);
1647
1694
  }));
1648
1695
 
1649
1696
  function fetchAllData() {
@@ -1799,22 +1846,22 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
1799
1846
  _proto2.fetchComponentData =
1800
1847
  /*#__PURE__*/
1801
1848
  function () {
1802
- var _fetchComponentData2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
1849
+ var _fetchComponentData2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
1803
1850
  var _this$__internal;
1804
1851
 
1805
- var _args7 = arguments;
1806
- return runtime_1.wrap(function _callee7$(_context7) {
1852
+ var _args8 = arguments;
1853
+ return runtime_1.wrap(function _callee8$(_context8) {
1807
1854
  while (1) {
1808
- switch (_context7.prev = _context7.next) {
1855
+ switch (_context8.prev = _context8.next) {
1809
1856
  case 0:
1810
- return _context7.abrupt("return", (_this$__internal = this.__internal).fetchComponentData.apply(_this$__internal, _args7));
1857
+ return _context8.abrupt("return", (_this$__internal = this.__internal).fetchComponentData.apply(_this$__internal, _args8));
1811
1858
 
1812
1859
  case 1:
1813
1860
  case "end":
1814
- return _context7.stop();
1861
+ return _context8.stop();
1815
1862
  }
1816
1863
  }
1817
- }, _callee7, this);
1864
+ }, _callee8, this);
1818
1865
  }));
1819
1866
 
1820
1867
  function fetchComponentData() {
@@ -1833,22 +1880,22 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
1833
1880
  _proto2.maybeFetchComponentData =
1834
1881
  /*#__PURE__*/
1835
1882
  function () {
1836
- var _maybeFetchComponentData2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
1883
+ var _maybeFetchComponentData2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() {
1837
1884
  var _this$__internal2;
1838
1885
 
1839
- var _args8 = arguments;
1840
- return runtime_1.wrap(function _callee8$(_context8) {
1886
+ var _args9 = arguments;
1887
+ return runtime_1.wrap(function _callee9$(_context9) {
1841
1888
  while (1) {
1842
- switch (_context8.prev = _context8.next) {
1889
+ switch (_context9.prev = _context9.next) {
1843
1890
  case 0:
1844
- return _context8.abrupt("return", (_this$__internal2 = this.__internal).maybeFetchComponentData.apply(_this$__internal2, _args8));
1891
+ return _context9.abrupt("return", (_this$__internal2 = this.__internal).maybeFetchComponentData.apply(_this$__internal2, _args9));
1845
1892
 
1846
1893
  case 1:
1847
1894
  case "end":
1848
- return _context8.stop();
1895
+ return _context9.stop();
1849
1896
  }
1850
1897
  }
1851
- }, _callee8, this);
1898
+ }, _callee9, this);
1852
1899
  }));
1853
1900
 
1854
1901
  function maybeFetchComponentData() {
@@ -1865,19 +1912,19 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
1865
1912
  _proto2.fetchPages =
1866
1913
  /*#__PURE__*/
1867
1914
  function () {
1868
- var _fetchPages2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() {
1869
- return runtime_1.wrap(function _callee9$(_context9) {
1915
+ var _fetchPages2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10() {
1916
+ return runtime_1.wrap(function _callee10$(_context10) {
1870
1917
  while (1) {
1871
- switch (_context9.prev = _context9.next) {
1918
+ switch (_context10.prev = _context10.next) {
1872
1919
  case 0:
1873
- return _context9.abrupt("return", this.__internal.fetchPages());
1920
+ return _context10.abrupt("return", this.__internal.fetchPages());
1874
1921
 
1875
1922
  case 1:
1876
1923
  case "end":
1877
- return _context9.stop();
1924
+ return _context10.stop();
1878
1925
  }
1879
1926
  }
1880
- }, _callee9, this);
1927
+ }, _callee10, this);
1881
1928
  }));
1882
1929
 
1883
1930
  function fetchPages() {
@@ -1894,19 +1941,19 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
1894
1941
  _proto2.fetchComponents =
1895
1942
  /*#__PURE__*/
1896
1943
  function () {
1897
- var _fetchComponents2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10() {
1898
- return runtime_1.wrap(function _callee10$(_context10) {
1944
+ var _fetchComponents2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11() {
1945
+ return runtime_1.wrap(function _callee11$(_context11) {
1899
1946
  while (1) {
1900
- switch (_context10.prev = _context10.next) {
1947
+ switch (_context11.prev = _context11.next) {
1901
1948
  case 0:
1902
- return _context10.abrupt("return", this.__internal.fetchComponents());
1949
+ return _context11.abrupt("return", this.__internal.fetchComponents());
1903
1950
 
1904
1951
  case 1:
1905
1952
  case "end":
1906
- return _context10.stop();
1953
+ return _context11.stop();
1907
1954
  }
1908
1955
  }
1909
- }, _callee10, this);
1956
+ }, _callee11, this);
1910
1957
  }));
1911
1958
 
1912
1959
  function fetchComponents() {