@trops/dash-core 0.1.264 → 0.1.266

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
@@ -45051,7 +45051,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
45051
45051
  error = _useState6[0],
45052
45052
  setError = _useState6[1];
45053
45053
  var refresh = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
45054
- var _window$mainApi, cMap, builtinWidgets, installedWidgets, list, installedNames, deduped, _t;
45054
+ var _window$mainApi, cMap, builtinWidgets, registryByName, list, installedFromCM, cmSourcePackages, fallbackInstalled, _t;
45055
45055
  return _regeneratorRuntime.wrap(function (_context) {
45056
45056
  while (1) switch (_context.prev = _context.next) {
45057
45057
  case 0:
@@ -45062,6 +45062,8 @@ var useInstalledWidgets = function useInstalledWidgets() {
45062
45062
  cMap = ComponentManager.componentMap() || {};
45063
45063
  builtinWidgets = Object.keys(cMap).filter(function (key) {
45064
45064
  return cMap[key].type === "widget";
45065
+ }).filter(function (key) {
45066
+ return !cMap[key]._sourcePackage;
45065
45067
  }).map(function (key) {
45066
45068
  var config = cMap[key];
45067
45069
  return {
@@ -45078,11 +45080,11 @@ var useInstalledWidgets = function useInstalledWidgets() {
45078
45080
  workspace: config.workspace || null,
45079
45081
  componentNames: [key]
45080
45082
  };
45081
- }); // ── Installed widgets from WidgetRegistry ───────────────
45082
- // Registry entries now include .dash.js fields (icon, providers,
45083
- // workspace, etc.) persisted at install time. Also try enriching
45084
- // from ComponentManager as a fallback.
45085
- installedWidgets = [];
45083
+ }); // ── Installed widgets from ComponentManager + Registry ───
45084
+ // CM entries with _sourcePackage are registry-installed widgets.
45085
+ // Show each as an individual "installed" entry, enriched with
45086
+ // registry-level metadata (version, path, packageId).
45087
+ registryByName = {};
45086
45088
  if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && _window$mainApi.widgets)) {
45087
45089
  _context.next = 3;
45088
45090
  break;
@@ -45091,50 +45093,57 @@ var useInstalledWidgets = function useInstalledWidgets() {
45091
45093
  return window.mainApi.widgets.list();
45092
45094
  case 2:
45093
45095
  list = _context.sent;
45094
- installedWidgets = (list || []).map(function (w) {
45095
- var _w$providers;
45096
- // Try to find a matching ComponentManager entry:
45097
- // 1) by componentNames stored in the registry entry
45098
- // 2) by _sourcePackage on the CM entry
45099
- var cmKey = (w.componentNames || []).find(function (cn) {
45100
- return cn in cMap;
45101
- }) || Object.keys(cMap).find(function (key) {
45102
- return cMap[key]._sourcePackage === w.name;
45103
- });
45104
- var cm = cmKey ? cMap[cmKey] : null;
45096
+ (list || []).forEach(function (w) {
45097
+ registryByName[w.name] = w;
45098
+ });
45099
+ case 3:
45100
+ installedFromCM = Object.keys(cMap).filter(function (key) {
45101
+ return cMap[key].type === "widget" && !!cMap[key]._sourcePackage;
45102
+ }).map(function (key) {
45103
+ var config = cMap[key];
45104
+ var reg = registryByName[config._sourcePackage] || {};
45105
+ return {
45106
+ name: key,
45107
+ displayName: config.name || key,
45108
+ author: config.author || reg.author || null,
45109
+ "package": config["package"] || null,
45110
+ description: config.description || null,
45111
+ icon: config.icon || null,
45112
+ version: reg.version || null,
45113
+ path: reg.path || null,
45114
+ source: "installed",
45115
+ providers: config.providers || [],
45116
+ workspace: config.workspace || null,
45117
+ componentNames: [key],
45118
+ packageId: reg.packageId || config._sourcePackage
45119
+ };
45120
+ }); // Fallback: registry packages whose components never loaded
45121
+ // into CM (e.g. compile failure). Show the package-level entry.
45122
+ cmSourcePackages = new Set(Object.values(cMap).filter(function (c) {
45123
+ return c._sourcePackage;
45124
+ }).map(function (c) {
45125
+ return c._sourcePackage;
45126
+ }));
45127
+ fallbackInstalled = Object.values(registryByName).filter(function (w) {
45128
+ return !cmSourcePackages.has(w.name);
45129
+ }).map(function (w) {
45105
45130
  return {
45106
45131
  name: w.name,
45107
- displayName: w.displayName || (cm === null || cm === void 0 ? void 0 : cm.name) || cmKey || w.name,
45108
- author: w.author || (cm === null || cm === void 0 ? void 0 : cm.author) || null,
45109
- "package": w["package"] || (cm === null || cm === void 0 ? void 0 : cm["package"]) || null,
45110
- description: w.description || (cm === null || cm === void 0 ? void 0 : cm.description) || null,
45111
- icon: w.icon || (cm === null || cm === void 0 ? void 0 : cm.icon) || null,
45132
+ displayName: w.displayName || w.name,
45133
+ author: w.author || null,
45134
+ "package": w["package"] || null,
45135
+ description: w.description || null,
45136
+ icon: w.icon || null,
45112
45137
  version: w.version || null,
45113
45138
  path: w.path || null,
45114
45139
  source: "installed",
45115
- providers: (_w$providers = w.providers) !== null && _w$providers !== void 0 && _w$providers.length ? w.providers : (cm === null || cm === void 0 ? void 0 : cm.providers) || [],
45116
- workspace: w.workspace || (cm === null || cm === void 0 ? void 0 : cm.workspace) || null,
45117
- componentNames: w.componentNames || (cmKey ? [cmKey] : []),
45140
+ providers: w.providers || [],
45141
+ workspace: w.workspace || null,
45142
+ componentNames: w.componentNames || [],
45118
45143
  packageId: w.packageId || w.name
45119
45144
  };
45120
45145
  });
45121
- case 3:
45122
- // ── Merge: installed wins on name collision ──────────────
45123
- // Also remove builtin entries whose _sourcePackage matches an
45124
- // installed widget name (e.g. builtin "WeatherWidget" with
45125
- // _sourcePackage "weather-widget" is the same as installed
45126
- // "weather-widget").
45127
- installedNames = new Set(installedWidgets.map(function (w) {
45128
- return w.name;
45129
- }));
45130
- deduped = builtinWidgets.filter(function (w) {
45131
- var _cMap$w$name;
45132
- if (installedNames.has(w.name)) return false;
45133
- var sp = (_cMap$w$name = cMap[w.name]) === null || _cMap$w$name === void 0 ? void 0 : _cMap$w$name._sourcePackage;
45134
- if (sp && installedNames.has(sp)) return false;
45135
- return true;
45136
- });
45137
- setWidgets([].concat(_toConsumableArray(deduped), _toConsumableArray(installedWidgets)));
45146
+ setWidgets([].concat(_toConsumableArray(builtinWidgets), _toConsumableArray(installedFromCM), _toConsumableArray(fallbackInstalled)));
45138
45147
  _context.next = 5;
45139
45148
  break;
45140
45149
  case 4: