@trops/dash-core 0.1.273 → 0.1.274

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.
package/dist/index.esm.js CHANGED
@@ -45188,7 +45188,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
45188
45188
  case 2:
45189
45189
  list = _context.sent;
45190
45190
  (list || []).forEach(function (w) {
45191
- registryByName[w.name] = w;
45191
+ registryByName[w.packageId || w.name] = w;
45192
45192
  });
45193
45193
  case 3:
45194
45194
  installedFromCM = Object.keys(cMap).filter(function (key) {
@@ -45356,17 +45356,32 @@ function useWidgetUpdates() {
45356
45356
  if (installed.length === 0) return;
45357
45357
  checkedRef.current = true;
45358
45358
  setIsChecking(true);
45359
- var payload = installed.map(function (w) {
45360
- return {
45361
- name: w.name,
45362
- version: w.version
45363
- };
45359
+
45360
+ // Deduplicate by package — multiple widgets in the same package share one version
45361
+ var pkgMap = new Map();
45362
+ installed.forEach(function (w) {
45363
+ var pkgId = w.packageId || w.name;
45364
+ if (!pkgMap.has(pkgId)) {
45365
+ pkgMap.set(pkgId, {
45366
+ name: pkgId,
45367
+ version: w.version
45368
+ });
45369
+ }
45364
45370
  });
45371
+ var payload = Array.from(pkgMap.values());
45365
45372
  (_window$mainApi = window.mainApi) === null || _window$mainApi === void 0 || (_window$mainApi = _window$mainApi.registry) === null || _window$mainApi === void 0 || _window$mainApi.checkUpdates(payload).then(function (results) {
45366
45373
  if (Array.isArray(results) && results.length > 0) {
45367
45374
  var map = new Map();
45368
45375
  results.forEach(function (r) {
45369
- return map.set(r.name, r);
45376
+ // Key by package ID (from result)
45377
+ map.set(r.name, r);
45378
+ // Also key by each widget's CM key so UI can look up by widget name
45379
+ installed.forEach(function (w) {
45380
+ var pkgId = w.packageId || w.name;
45381
+ if (pkgId === r.name) {
45382
+ map.set(w.name, r);
45383
+ }
45384
+ });
45370
45385
  });
45371
45386
  setUpdates(map);
45372
45387
  }
@@ -45379,7 +45394,7 @@ function useWidgetUpdates() {
45379
45394
  // Update a single widget by downloading the latest version
45380
45395
  var updateWidget = useCallback(/*#__PURE__*/function () {
45381
45396
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(name) {
45382
- var info, resolvedUrl;
45397
+ var info, widget, packageId, resolvedUrl;
45383
45398
  return _regeneratorRuntime.wrap(function (_context) {
45384
45399
  while (1) switch (_context.prev = _context.next) {
45385
45400
  case 0:
@@ -45390,11 +45405,16 @@ function useWidgetUpdates() {
45390
45405
  }
45391
45406
  return _context.abrupt("return");
45392
45407
  case 1:
45408
+ // Use packageId for install — name may be a CM key (widget-level)
45409
+ widget = installedWidgets.find(function (w) {
45410
+ return w.name === name;
45411
+ });
45412
+ packageId = (widget === null || widget === void 0 ? void 0 : widget.packageId) || info.name || name;
45393
45413
  setIsUpdating(name);
45394
45414
  _context.prev = 2;
45395
- resolvedUrl = info.downloadUrl.replace(/\{version\}/g, info.latestVersion).replace(/\{name\}/g, name);
45415
+ resolvedUrl = info.downloadUrl.replace(/\{version\}/g, info.latestVersion).replace(/\{name\}/g, packageId);
45396
45416
  _context.next = 3;
45397
- return window.mainApi.widgets.install(name, resolvedUrl);
45417
+ return window.mainApi.widgets.install(packageId, resolvedUrl);
45398
45418
  case 3:
45399
45419
  // Remove from updates map on success
45400
45420
  setUpdates(function (prev) {
@@ -45421,7 +45441,7 @@ function useWidgetUpdates() {
45421
45441
  return function (_x) {
45422
45442
  return _ref.apply(this, arguments);
45423
45443
  };
45424
- }(), [updates, onUpdated]);
45444
+ }(), [updates, onUpdated, installedWidgets]);
45425
45445
  return {
45426
45446
  updates: updates,
45427
45447
  isChecking: isChecking,