@trops/dash-core 0.1.105 → 0.1.106

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
@@ -36384,6 +36384,23 @@ var RegistryPackageDetail = function RegistryPackageDetail(_ref) {
36384
36384
  }, idx);
36385
36385
  })
36386
36386
  })]
36387
+ }), widget.appOrigin && /*#__PURE__*/jsxs("div", {
36388
+ className: "flex items-center gap-1.5 text-xs opacity-50",
36389
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
36390
+ icon: "laptop",
36391
+ className: "h-3 w-3"
36392
+ }), /*#__PURE__*/jsxs("span", {
36393
+ children: ["Built for ", widget.appOrigin]
36394
+ })]
36395
+ }), widget.missingApis && widget.missingApis.length > 0 && /*#__PURE__*/jsx("div", {
36396
+ className: "p-2 rounded bg-yellow-900/30 border border-yellow-700",
36397
+ children: /*#__PURE__*/jsxs("p", {
36398
+ className: "text-xs text-yellow-400",
36399
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
36400
+ icon: "triangle-exclamation",
36401
+ className: "mr-1"
36402
+ }), "Incompatible \u2014 requires", " ", widget.missingApis.join(", "), " API", widget.missingApis.length !== 1 ? "s" : ""]
36403
+ })
36387
36404
  }), widget.repository && /*#__PURE__*/jsxs("div", {
36388
36405
  children: [/*#__PURE__*/jsx("span", {
36389
36406
  className: "text-xs font-semibold opacity-50 mb-1 block",
@@ -36429,6 +36446,10 @@ function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.lengt
36429
36446
  * Extracted from EnhancedWidgetDropdown so the same logic can power the
36430
36447
  * Discover tab inside AppSettingsModal (and anywhere else).
36431
36448
  *
36449
+ * Options:
36450
+ * filterByCapabilities – if true (default), only show packages compatible
36451
+ * with the app's API capabilities
36452
+ *
36432
36453
  * Returns:
36433
36454
  * packages – raw package objects from the registry
36434
36455
  * flatWidgets – flattened widget entries with `isRegistry: true`
@@ -36439,8 +36460,13 @@ function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.lengt
36439
36460
  * installError – install error string (or null)
36440
36461
  * search() – manually trigger a search
36441
36462
  * installPackage(widget) – install a specific registry widget
36463
+ * showAllPackages / setShowAllPackages – toggle to show incompatible packages
36464
+ * appCapabilities – the app's API namespaces
36442
36465
  */
36443
36466
  var useRegistrySearch = function useRegistrySearch() {
36467
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
36468
+ _ref$filterByCapabili = _ref.filterByCapabilities,
36469
+ filterByCapabilities = _ref$filterByCapabili === void 0 ? true : _ref$filterByCapabili;
36444
36470
  var _useState = useState(false),
36445
36471
  _useState2 = _slicedToArray(_useState, 2),
36446
36472
  isLoading = _useState2[0],
@@ -36469,10 +36495,22 @@ var useRegistrySearch = function useRegistrySearch() {
36469
36495
  _useState12 = _slicedToArray(_useState11, 2),
36470
36496
  installError = _useState12[0],
36471
36497
  setInstallError = _useState12[1];
36498
+ var _useState13 = useState(false),
36499
+ _useState14 = _slicedToArray(_useState13, 2),
36500
+ showAllPackages = _useState14[0],
36501
+ setShowAllPackages = _useState14[1];
36502
+
36503
+ // Discover app capabilities from window.mainApi
36504
+ var appCapabilities = useMemo(function () {
36505
+ if (typeof window !== "undefined" && window.mainApi) {
36506
+ return Object.keys(window.mainApi);
36507
+ }
36508
+ return [];
36509
+ }, []);
36472
36510
  var search = useCallback(/*#__PURE__*/function () {
36473
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(query) {
36511
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(query) {
36474
36512
  var _window$mainApi;
36475
- var result, pkgs, widgets, _iterator, _step, pkg, _iterator2, _step2, widget, _t;
36513
+ var filters, result, pkgs, capSet, widgets, _iterator, _step, pkg, allApiProviders, _iterator2, _step2, p, _iterator3, _step3, w, _iterator5, _step5, _p, missingApis, _iterator4, _step4, widget, _t;
36476
36514
  return _regeneratorRuntime.wrap(function (_context) {
36477
36515
  while (1) switch (_context.prev = _context.next) {
36478
36516
  case 0:
@@ -36487,23 +36525,71 @@ var useRegistrySearch = function useRegistrySearch() {
36487
36525
  setIsLoading(true);
36488
36526
  setError(null);
36489
36527
  _context.prev = 2;
36528
+ filters = {};
36529
+ if (filterByCapabilities && !showAllPackages && appCapabilities.length) {
36530
+ filters.appCapabilities = appCapabilities;
36531
+ }
36490
36532
  _context.next = 3;
36491
- return window.mainApi.registry.search(query !== null && query !== void 0 ? query : searchQuery, {});
36533
+ return window.mainApi.registry.search(query !== null && query !== void 0 ? query : searchQuery, filters);
36492
36534
  case 3:
36493
36535
  result = _context.sent;
36494
36536
  pkgs = result.packages || [];
36495
36537
  setPackages(pkgs);
36496
36538
 
36497
36539
  // Flatten packages into widget entries
36540
+ capSet = new Set(appCapabilities.map(function (c) {
36541
+ return c.toLowerCase();
36542
+ }));
36498
36543
  widgets = [];
36499
36544
  _iterator = _createForOfIteratorHelper$2(pkgs);
36500
36545
  try {
36501
36546
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
36502
36547
  pkg = _step.value;
36503
- _iterator2 = _createForOfIteratorHelper$2(pkg.widgets || []);
36548
+ // Compute missing APIs for the entire package
36549
+ allApiProviders = [];
36550
+ _iterator2 = _createForOfIteratorHelper$2(pkg.providers || []);
36504
36551
  try {
36505
36552
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
36506
- widget = _step2.value;
36553
+ p = _step2.value;
36554
+ if (p.providerClass === "api" && p.required !== false) {
36555
+ allApiProviders.push(p.type);
36556
+ }
36557
+ }
36558
+ } catch (err) {
36559
+ _iterator2.e(err);
36560
+ } finally {
36561
+ _iterator2.f();
36562
+ }
36563
+ _iterator3 = _createForOfIteratorHelper$2(pkg.widgets || []);
36564
+ try {
36565
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
36566
+ w = _step3.value;
36567
+ _iterator5 = _createForOfIteratorHelper$2(w.providers || []);
36568
+ try {
36569
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
36570
+ _p = _step5.value;
36571
+ if (_p.providerClass === "api" && _p.required !== false) {
36572
+ allApiProviders.push(_p.type);
36573
+ }
36574
+ }
36575
+ } catch (err) {
36576
+ _iterator5.e(err);
36577
+ } finally {
36578
+ _iterator5.f();
36579
+ }
36580
+ }
36581
+ } catch (err) {
36582
+ _iterator3.e(err);
36583
+ } finally {
36584
+ _iterator3.f();
36585
+ }
36586
+ missingApis = _toConsumableArray(new Set(allApiProviders)).filter(function (api) {
36587
+ return !capSet.has(api.toLowerCase());
36588
+ });
36589
+ _iterator4 = _createForOfIteratorHelper$2(pkg.widgets || []);
36590
+ try {
36591
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
36592
+ widget = _step4.value;
36507
36593
  widgets.push({
36508
36594
  key: "".concat(pkg.name, "/").concat(widget.name),
36509
36595
  name: widget.displayName || widget.name,
@@ -36521,13 +36607,16 @@ var useRegistrySearch = function useRegistrySearch() {
36521
36607
  downloadUrl: pkg.downloadUrl || "",
36522
36608
  repository: pkg.repository || "",
36523
36609
  publishedAt: pkg.publishedAt || "",
36524
- packageWidgets: pkg.widgets || []
36610
+ packageWidgets: pkg.widgets || [],
36611
+ appOrigin: pkg.appOrigin || null,
36612
+ packageProviders: pkg.providers || [],
36613
+ missingApis: missingApis
36525
36614
  });
36526
36615
  }
36527
36616
  } catch (err) {
36528
- _iterator2.e(err);
36617
+ _iterator4.e(err);
36529
36618
  } finally {
36530
- _iterator2.f();
36619
+ _iterator4.f();
36531
36620
  }
36532
36621
  }
36533
36622
  } catch (err) {
@@ -36555,9 +36644,9 @@ var useRegistrySearch = function useRegistrySearch() {
36555
36644
  }, _callee, null, [[2, 4, 5, 6]]);
36556
36645
  }));
36557
36646
  return function (_x) {
36558
- return _ref.apply(this, arguments);
36647
+ return _ref2.apply(this, arguments);
36559
36648
  };
36560
- }(), [searchQuery]);
36649
+ }(), [searchQuery, filterByCapabilities, showAllPackages, appCapabilities]);
36561
36650
 
36562
36651
  // Debounce search on query changes (300ms)
36563
36652
  useEffect(function () {
@@ -36568,9 +36657,9 @@ var useRegistrySearch = function useRegistrySearch() {
36568
36657
  return clearTimeout(timer);
36569
36658
  };
36570
36659
  // eslint-disable-next-line react-hooks/exhaustive-deps
36571
- }, [searchQuery]);
36660
+ }, [searchQuery, showAllPackages]);
36572
36661
  var installPackage = useCallback(/*#__PURE__*/function () {
36573
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(widget) {
36662
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(widget) {
36574
36663
  var packageName, downloadUrl, packageVersion, resolvedUrl, _t2;
36575
36664
  return _regeneratorRuntime.wrap(function (_context2) {
36576
36665
  while (1) switch (_context2.prev = _context2.next) {
@@ -36606,7 +36695,7 @@ var useRegistrySearch = function useRegistrySearch() {
36606
36695
  }, _callee2, null, [[2, 4, 5, 6]]);
36607
36696
  }));
36608
36697
  return function (_x2) {
36609
- return _ref2.apply(this, arguments);
36698
+ return _ref3.apply(this, arguments);
36610
36699
  };
36611
36700
  }(), []);
36612
36701
  var retry = useCallback(function () {
@@ -36623,7 +36712,10 @@ var useRegistrySearch = function useRegistrySearch() {
36623
36712
  installError: installError,
36624
36713
  search: search,
36625
36714
  installPackage: installPackage,
36626
- retry: retry
36715
+ retry: retry,
36716
+ showAllPackages: showAllPackages,
36717
+ setShowAllPackages: setShowAllPackages,
36718
+ appCapabilities: appCapabilities
36627
36719
  };
36628
36720
  };
36629
36721
 
@@ -36649,7 +36741,9 @@ var DiscoverWidgetsDetail = function DiscoverWidgetsDetail(_ref) {
36649
36741
  isInstalling = _useRegistrySearch.isInstalling,
36650
36742
  installError = _useRegistrySearch.installError,
36651
36743
  installPackage = _useRegistrySearch.installPackage,
36652
- retry = _useRegistrySearch.retry;
36744
+ retry = _useRegistrySearch.retry,
36745
+ showAllPackages = _useRegistrySearch.showAllPackages,
36746
+ setShowAllPackages = _useRegistrySearch.setShowAllPackages;
36653
36747
  var _useState = useState(null),
36654
36748
  _useState2 = _slicedToArray(_useState, 2),
36655
36749
  selectedPackageName = _useState2[0],
@@ -36814,10 +36908,15 @@ var DiscoverWidgetsDetail = function DiscoverWidgetsDetail(_ref) {
36814
36908
  className: "space-y-1",
36815
36909
  children: packages.map(function (pkg) {
36816
36910
  var widgetCount = (pkg.widgets || []).length;
36911
+ // Check if this package has incompatible API dependencies
36912
+ var pkgWidget = flatWidgets.find(function (w) {
36913
+ return w.packageName === pkg.name;
36914
+ });
36915
+ var hasIncompatible = (pkgWidget === null || pkgWidget === void 0 ? void 0 : pkgWidget.missingApis) && pkgWidget.missingApis.length > 0;
36817
36916
  return /*#__PURE__*/jsx(Sidebar.Item, {
36818
36917
  icon: /*#__PURE__*/jsx(FontAwesomeIcon, {
36819
- icon: "cube",
36820
- className: "h-3.5 w-3.5"
36918
+ icon: hasIncompatible ? "triangle-exclamation" : "cube",
36919
+ className: "h-3.5 w-3.5 ".concat(hasIncompatible ? "text-yellow-500" : "")
36821
36920
  }),
36822
36921
  onClick: function onClick() {
36823
36922
  return setSelectedPackageName(pkg.name);
@@ -36843,14 +36942,24 @@ var DiscoverWidgetsDetail = function DiscoverWidgetsDetail(_ref) {
36843
36942
  children: "Back"
36844
36943
  })]
36845
36944
  })
36846
- }), /*#__PURE__*/jsx("div", {
36945
+ }), /*#__PURE__*/jsxs("div", {
36847
36946
  className: "flex-shrink-0 px-4 py-3",
36848
- children: /*#__PURE__*/jsx(SearchInput, {
36947
+ children: [/*#__PURE__*/jsx(SearchInput, {
36849
36948
  value: searchQuery,
36850
36949
  onChange: setSearchQuery,
36851
36950
  placeholder: "Search packages...",
36852
36951
  inputClassName: "py-1.5 text-xs"
36853
- })
36952
+ }), /*#__PURE__*/jsxs("label", {
36953
+ className: "flex items-center gap-1.5 mt-2 text-xs opacity-50 cursor-pointer select-none",
36954
+ children: [/*#__PURE__*/jsx("input", {
36955
+ type: "checkbox",
36956
+ checked: showAllPackages,
36957
+ onChange: function onChange(e) {
36958
+ return setShowAllPackages(e.target.checked);
36959
+ },
36960
+ className: "rounded"
36961
+ }), "Show all packages"]
36962
+ })]
36854
36963
  }), /*#__PURE__*/jsx("div", {
36855
36964
  className: "flex-1 min-h-0 overflow-y-auto px-2",
36856
36965
  children: listBody