@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.esm.js CHANGED
@@ -32353,6 +32353,12 @@ function _arrayLikeToArray$q(r, a) { (null == a || a > r.length) && (a = r.lengt
32353
32353
  * Matches the provider resolution pattern used by useMcpProvider:
32354
32354
  * 1. Widget-level: widgetData.selectedProviders[providerType] (set by handleSelectProvider on the layout item)
32355
32355
  * 2. Workspace-level fallback: workspace.workspaceData.selectedProviders[widgetId][providerType]
32356
+ * 3. App-default fallback: any provider of matching type flagged `isDefaultForType` in AppContext.providers
32357
+ * (managed via Settings → Providers "Use as default…" toggle)
32358
+ * 4. null — widget surfaces its own "no provider" empty state
32359
+ *
32360
+ * Existing widgets/workspaces retain their explicit bindings; the default layer only
32361
+ * activates for widgets with no explicit binding (mirrors useMcpProvider exactly).
32356
32362
  *
32357
32363
  * Reads provider data from AppContext.providers (not DashboardContext.providers, which has a
32358
32364
  * structural issue where providers don't flow through from AppWrapper).
@@ -32394,9 +32400,10 @@ var useWidgetProviders = function useWidgetProviders() {
32394
32400
  // Get all provider type declarations from the widget config
32395
32401
  var providerDeclarations = (widgetData === null || widgetData === void 0 ? void 0 : widgetData.providers) || [];
32396
32402
 
32397
- // Resolve each declared provider using the same two-layer lookup as useMcpProvider:
32403
+ // Resolve each declared provider using the same three-layer lookup as useMcpProvider:
32398
32404
  // 1. Widget-level: stored directly on the layout item by handleSelectProvider
32399
32405
  // 2. Workspace-level: stored as workspace.selectedProviders[widgetId][providerType]
32406
+ // 3. App-default: any provider in AppContext.providers flagged isDefaultForType
32400
32407
  var providers = {};
32401
32408
  var _iterator = _createForOfIteratorHelper$q(providerDeclarations),
32402
32409
  _step;
@@ -32415,6 +32422,23 @@ var useWidgetProviders = function useWidgetProviders() {
32415
32422
  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;
32416
32423
  }
32417
32424
 
32425
+ // 3. App-default fallback — only kicks in for widgets with no explicit
32426
+ // per-widget or per-workspace binding. Walking the map is O(N)
32427
+ // in the provider count, which is small (typically <20 even for
32428
+ // heavy users); the cost is bounded and the lookup runs once per
32429
+ // declared provider type per render.
32430
+ if (!providerName && app !== null && app !== void 0 && app.providers && _typeof(app.providers) === "object") {
32431
+ for (var _i = 0, _Object$entries = Object.entries(app.providers); _i < _Object$entries.length; _i++) {
32432
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
32433
+ name = _Object$entries$_i[0],
32434
+ data = _Object$entries$_i[1];
32435
+ if ((data === null || data === void 0 ? void 0 : data.type) === providerType && (data === null || data === void 0 ? void 0 : data.isDefaultForType) === true) {
32436
+ providerName = name;
32437
+ break;
32438
+ }
32439
+ }
32440
+ }
32441
+
32418
32442
  // Look up from AppContext.providers (not DashboardContext)
32419
32443
  if (providerName) {
32420
32444
  var _app$providers;