@trops/dash-core 0.1.561 → 0.1.562

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.js CHANGED
@@ -32371,6 +32371,12 @@ function _arrayLikeToArray$q(r, a) { (null == a || a > r.length) && (a = r.lengt
32371
32371
  * Matches the provider resolution pattern used by useMcpProvider:
32372
32372
  * 1. Widget-level: widgetData.selectedProviders[providerType] (set by handleSelectProvider on the layout item)
32373
32373
  * 2. Workspace-level fallback: workspace.workspaceData.selectedProviders[widgetId][providerType]
32374
+ * 3. App-default fallback: any provider of matching type flagged `isDefaultForType` in AppContext.providers
32375
+ * (managed via Settings → Providers "Use as default…" toggle)
32376
+ * 4. null — widget surfaces its own "no provider" empty state
32377
+ *
32378
+ * Existing widgets/workspaces retain their explicit bindings; the default layer only
32379
+ * activates for widgets with no explicit binding (mirrors useMcpProvider exactly).
32374
32380
  *
32375
32381
  * Reads provider data from AppContext.providers (not DashboardContext.providers, which has a
32376
32382
  * structural issue where providers don't flow through from AppWrapper).
@@ -32412,9 +32418,10 @@ var useWidgetProviders = function useWidgetProviders() {
32412
32418
  // Get all provider type declarations from the widget config
32413
32419
  var providerDeclarations = (widgetData === null || widgetData === void 0 ? void 0 : widgetData.providers) || [];
32414
32420
 
32415
- // Resolve each declared provider using the same two-layer lookup as useMcpProvider:
32421
+ // Resolve each declared provider using the same three-layer lookup as useMcpProvider:
32416
32422
  // 1. Widget-level: stored directly on the layout item by handleSelectProvider
32417
32423
  // 2. Workspace-level: stored as workspace.selectedProviders[widgetId][providerType]
32424
+ // 3. App-default: any provider in AppContext.providers flagged isDefaultForType
32418
32425
  var providers = {};
32419
32426
  var _iterator = _createForOfIteratorHelper$q(providerDeclarations),
32420
32427
  _step;
@@ -32433,6 +32440,23 @@ var useWidgetProviders = function useWidgetProviders() {
32433
32440
  providerName = (workspace === null || workspace === void 0 || (_workspace$workspaceD = workspace.workspaceData) === null || _workspace$workspaceD === void 0 || (_workspace$workspaceD = _workspace$workspaceD.selectedProviders) === null || _workspace$workspaceD === void 0 || (_workspace$workspaceD = _workspace$workspaceD[widgetId]) === null || _workspace$workspaceD === void 0 ? void 0 : _workspace$workspaceD[providerType]) || null;
32434
32441
  }
32435
32442
 
32443
+ // 3. App-default fallback — only kicks in for widgets with no explicit
32444
+ // per-widget or per-workspace binding. Walking the map is O(N)
32445
+ // in the provider count, which is small (typically <20 even for
32446
+ // heavy users); the cost is bounded and the lookup runs once per
32447
+ // declared provider type per render.
32448
+ if (!providerName && app !== null && app !== void 0 && app.providers && _typeof(app.providers) === "object") {
32449
+ for (var _i = 0, _Object$entries = Object.entries(app.providers); _i < _Object$entries.length; _i++) {
32450
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
32451
+ name = _Object$entries$_i[0],
32452
+ data = _Object$entries$_i[1];
32453
+ if ((data === null || data === void 0 ? void 0 : data.type) === providerType && (data === null || data === void 0 ? void 0 : data.isDefaultForType) === true) {
32454
+ providerName = name;
32455
+ break;
32456
+ }
32457
+ }
32458
+ }
32459
+
32436
32460
  // Look up from AppContext.providers (not DashboardContext)
32437
32461
  if (providerName) {
32438
32462
  var _app$providers;