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