@pisell/pisellos 2.2.91 → 2.2.92

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.
@@ -1526,7 +1526,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1526
1526
  key: "processProductSyncMessages",
1527
1527
  value: (function () {
1528
1528
  var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1529
- var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator7, _step7, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges;
1529
+ var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator7, _step7, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges;
1530
1530
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1531
1531
  while (1) switch (_context17.prev = _context17.next) {
1532
1532
  case 0:
@@ -1551,13 +1551,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1551
1551
  _iterator7.s();
1552
1552
  case 13:
1553
1553
  if ((_step7 = _iterator7.n()).done) {
1554
- _context17.next = 35;
1554
+ _context17.next = 36;
1555
1555
  break;
1556
1556
  }
1557
1557
  msg = _step7.value;
1558
1558
  channelKey = msg._channelKey || msg.module || 'product';
1559
1559
  if (!(channelKey === 'product')) {
1560
- _context17.next = 32;
1560
+ _context17.next = 33;
1561
1561
  break;
1562
1562
  }
1563
1563
  if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
@@ -1569,33 +1569,37 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1569
1569
  break;
1570
1570
  }
1571
1571
  if ((_msg$ids = msg.ids) !== null && _msg$ids !== void 0 && _msg$ids.length) deleteIds.push.apply(deleteIds, _toConsumableArray(msg.ids));else if (msg.id) deleteIds.push(msg.id);
1572
- return _context17.abrupt("continue", 33);
1572
+ return _context17.abrupt("continue", 34);
1573
1573
  case 21:
1574
1574
  if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
1575
- _context17.next = 25;
1575
+ _context17.next = 26;
1576
1576
  break;
1577
1577
  }
1578
1578
  ids = msg.ids || (msg.id ? [msg.id] : []);
1579
1579
  priceRefreshIds.push.apply(priceRefreshIds, _toConsumableArray(ids));
1580
- return _context17.abrupt("continue", 33);
1581
- case 25:
1580
+ if (msg.body) {
1581
+ bodyId = msg.body.id;
1582
+ if (bodyId) bodyUpdates.set(bodyId, msg.body);
1583
+ }
1584
+ return _context17.abrupt("continue", 34);
1585
+ case 26:
1582
1586
  if (!msg.body) {
1583
- _context17.next = 29;
1587
+ _context17.next = 30;
1584
1588
  break;
1585
1589
  }
1586
- bodyId = msg.body.id || msg.id;
1587
- if (bodyId) bodyUpdates.set(bodyId, msg.body);
1588
- return _context17.abrupt("continue", 33);
1589
- case 29:
1590
+ _bodyId = msg.body.id || msg.id;
1591
+ if (_bodyId) bodyUpdates.set(_bodyId, msg.body);
1592
+ return _context17.abrupt("continue", 34);
1593
+ case 30:
1590
1594
  // 4. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
1591
1595
  if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
1592
1596
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.ids));
1593
1597
  } else if (msg.id) {
1594
1598
  sseRefreshIds.push(msg.id);
1595
1599
  }
1596
- _context17.next = 33;
1600
+ _context17.next = 34;
1597
1601
  break;
1598
- case 32:
1602
+ case 33:
1599
1603
  if (channelKey === 'product_quotation') {
1600
1604
  // 报价单变更影响范围大,标记清除全量价格缓存
1601
1605
  shouldClearPriceCache = true;
@@ -1607,61 +1611,61 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1607
1611
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1608
1612
  }
1609
1613
  }
1610
- case 33:
1614
+ case 34:
1611
1615
  _context17.next = 13;
1612
1616
  break;
1613
- case 35:
1614
- _context17.next = 40;
1617
+ case 36:
1618
+ _context17.next = 41;
1615
1619
  break;
1616
- case 37:
1617
- _context17.prev = 37;
1620
+ case 38:
1621
+ _context17.prev = 38;
1618
1622
  _context17.t0 = _context17["catch"](11);
1619
1623
  _iterator7.e(_context17.t0);
1620
- case 40:
1621
- _context17.prev = 40;
1624
+ case 41:
1625
+ _context17.prev = 41;
1622
1626
  _iterator7.f();
1623
- return _context17.finish(40);
1624
- case 43:
1627
+ return _context17.finish(41);
1628
+ case 44:
1625
1629
  uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
1626
1630
  uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds));
1627
1631
  uniquePriceIds = _toConsumableArray(new Set(priceRefreshIds)); // 1. 处理删除
1628
1632
  if (!(uniqueDeleteIds.length > 0)) {
1629
- _context17.next = 49;
1633
+ _context17.next = 50;
1630
1634
  break;
1631
1635
  }
1632
- _context17.next = 49;
1636
+ _context17.next = 50;
1633
1637
  return this.removeProductsByIds(uniqueDeleteIds);
1634
- case 49:
1638
+ case 50:
1635
1639
  if (!(bodyUpdates.size > 0)) {
1636
- _context17.next = 52;
1640
+ _context17.next = 53;
1637
1641
  break;
1638
1642
  }
1639
- _context17.next = 52;
1643
+ _context17.next = 53;
1640
1644
  return this.applyBodyUpdatesToStore(bodyUpdates);
1641
- case 52:
1645
+ case 53:
1642
1646
  if (!(uniqueSSEIds.length > 0)) {
1643
- _context17.next = 60;
1647
+ _context17.next = 61;
1644
1648
  break;
1645
1649
  }
1646
- _context17.next = 55;
1650
+ _context17.next = 56;
1647
1651
  return this.fetchProductsBySSE(uniqueSSEIds);
1648
- case 55:
1652
+ case 56:
1649
1653
  freshProducts = _context17.sent;
1650
1654
  if (!(freshProducts.length > 0)) {
1651
- _context17.next = 59;
1655
+ _context17.next = 60;
1652
1656
  break;
1653
1657
  }
1654
- _context17.next = 59;
1658
+ _context17.next = 60;
1655
1659
  return this.mergeProductsToStore(freshProducts);
1656
- case 59:
1657
- this.logInfo('processProductSyncMessages: SSE 增量更新完成', {
1660
+ case 60:
1661
+ this.logInfo('processProductSyncMessages: SSE 增量更新完成123', {
1658
1662
  requestedCount: uniqueSSEIds.length,
1659
1663
  receivedCount: freshProducts.length
1660
1664
  });
1661
- case 60:
1665
+ case 61:
1662
1666
  // 收集所有非 delete 的变更 IDs(body + SSE + price),用于增量更新价格缓存
1663
1667
  allChangedIds = _toConsumableArray(new Set([].concat(_toConsumableArray(Array.from(bodyUpdates.keys())), _toConsumableArray(uniqueSSEIds), _toConsumableArray(uniquePriceIds))));
1664
- this.logInfo('processProductSyncMessages: 处理完成', {
1668
+ this.logInfo('processProductSyncMessages: 处理完成123', {
1665
1669
  deleteCount: uniqueDeleteIds.length,
1666
1670
  bodyUpdateCount: bodyUpdates.size,
1667
1671
  sseRefreshCount: uniqueSSEIds.length,
@@ -1671,25 +1675,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1671
1675
  });
1672
1676
  hasChanges = uniqueDeleteIds.length > 0 || allChangedIds.length > 0 || shouldClearPriceCache;
1673
1677
  if (hasChanges) {
1674
- _context17.next = 66;
1678
+ _context17.next = 67;
1675
1679
  break;
1676
1680
  }
1677
1681
  this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
1678
1682
  return _context17.abrupt("return");
1679
- case 66:
1683
+ case 67:
1680
1684
  // 报价单变更 → 清除全量价格缓存,后续走全量重建
1681
1685
  if (shouldClearPriceCache) {
1682
1686
  this.clearPriceCache();
1683
1687
  }
1684
- _context17.next = 69;
1688
+ _context17.next = 70;
1685
1689
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, {
1686
1690
  changedIds: allChangedIds
1687
1691
  });
1688
- case 69:
1692
+ case 70:
1689
1693
  case "end":
1690
1694
  return _context17.stop();
1691
1695
  }
1692
- }, _callee17, this, [[11, 37, 40, 43]]);
1696
+ }, _callee17, this, [[11, 38, 41, 44]]);
1693
1697
  }));
1694
1698
  function processProductSyncMessages() {
1695
1699
  return _processProductSyncMessages.apply(this, arguments);
@@ -954,6 +954,11 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
954
954
  if ((_c = msg.change_types) == null ? void 0 : _c.includes("price")) {
955
955
  const ids = msg.ids || (msg.id ? [msg.id] : []);
956
956
  priceRefreshIds.push(...ids);
957
+ if (msg.body) {
958
+ const bodyId = msg.body.id;
959
+ if (bodyId)
960
+ bodyUpdates.set(bodyId, msg.body);
961
+ }
957
962
  continue;
958
963
  }
959
964
  if (msg.body) {
@@ -992,7 +997,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
992
997
  if (freshProducts.length > 0) {
993
998
  await this.mergeProductsToStore(freshProducts);
994
999
  }
995
- this.logInfo("processProductSyncMessages: SSE 增量更新完成", {
1000
+ this.logInfo("processProductSyncMessages: SSE 增量更新完成123", {
996
1001
  requestedCount: uniqueSSEIds.length,
997
1002
  receivedCount: freshProducts.length
998
1003
  });
@@ -1002,7 +1007,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1002
1007
  ...uniqueSSEIds,
1003
1008
  ...uniquePriceIds
1004
1009
  ])];
1005
- this.logInfo("processProductSyncMessages: 处理完成", {
1010
+ this.logInfo("processProductSyncMessages: 处理完成123", {
1006
1011
  deleteCount: uniqueDeleteIds.length,
1007
1012
  bodyUpdateCount: bodyUpdates.size,
1008
1013
  sseRefreshCount: uniqueSSEIds.length,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.91",
4
+ "version": "2.2.92",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",