@trops/dash-core 0.1.605 → 0.1.606
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 +139 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +139 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2807,13 +2807,42 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
2807
2807
|
error = _useState6[0],
|
|
2808
2808
|
setError = _useState6[1];
|
|
2809
2809
|
var refresh = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
2810
|
-
var _window$mainApi, cMap, builtinWidgets, registryByName, list, installedFromCM, cmSourcePackages, fallbackInstalled, _t;
|
|
2810
|
+
var _window$mainApi, _window$mainApi2, classifyWidget, cMap, builtinWidgets, draftsByPackageDir, draftShortIdToId, allDrafts, _iterator4, _step4, d, shortId, registryByName, list, installedFromCM, cmSourcePackages, fallbackInstalled, _t, _t3;
|
|
2811
2811
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
2812
2812
|
while (1) switch (_context.prev = _context.next) {
|
|
2813
2813
|
case 0:
|
|
2814
2814
|
setIsLoading(true);
|
|
2815
2815
|
setError(null);
|
|
2816
2816
|
_context.prev = 1;
|
|
2817
|
+
classifyWidget = function classifyWidget(reg, fallbackName) {
|
|
2818
|
+
var name = (reg === null || reg === void 0 ? void 0 : reg.name) || fallbackName || "";
|
|
2819
|
+
var path = (reg === null || reg === void 0 ? void 0 : reg.path) || "";
|
|
2820
|
+
// 1. Match against drafts metadata by packageDir (canonical).
|
|
2821
|
+
if (path && draftsByPackageDir.has(path)) {
|
|
2822
|
+
return {
|
|
2823
|
+
kind: "draft",
|
|
2824
|
+
draftId: draftsByPackageDir.get(path).id
|
|
2825
|
+
};
|
|
2826
|
+
}
|
|
2827
|
+
// 2. Fallback: the dir name follows `<base>-draft-<shortId>`;
|
|
2828
|
+
// pluck the shortId and look it up in the drafts list.
|
|
2829
|
+
var m = String(name).match(/-draft-([A-Za-z0-9]+)$/);
|
|
2830
|
+
if (m) {
|
|
2831
|
+
var _shortId = m[1].slice(0, 8);
|
|
2832
|
+
var draftId = draftShortIdToId.get(_shortId) || null;
|
|
2833
|
+
return {
|
|
2834
|
+
kind: "draft",
|
|
2835
|
+
draftId: draftId
|
|
2836
|
+
};
|
|
2837
|
+
}
|
|
2838
|
+
return {
|
|
2839
|
+
kind: "installed",
|
|
2840
|
+
draftId: null
|
|
2841
|
+
};
|
|
2842
|
+
}; // ── Installed widgets from ComponentManager + Registry ───
|
|
2843
|
+
// CM entries with _sourcePackage are registry-installed widgets.
|
|
2844
|
+
// Show each as an individual "installed" entry, enriched with
|
|
2845
|
+
// registry-level metadata (version, path, packageId).
|
|
2817
2846
|
// ── Built-in widgets from ComponentManager ──────────────
|
|
2818
2847
|
cMap = ComponentManager.componentMap() || {};
|
|
2819
2848
|
builtinWidgets = Object.keys(cMap).filter(function (key) {
|
|
@@ -2832,33 +2861,80 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
2832
2861
|
version: null,
|
|
2833
2862
|
path: null,
|
|
2834
2863
|
source: "builtin",
|
|
2864
|
+
kind: "installed",
|
|
2865
|
+
draftId: null,
|
|
2835
2866
|
providers: config.providers || [],
|
|
2836
2867
|
workspace: config.workspace || null,
|
|
2837
2868
|
componentNames: [key],
|
|
2838
2869
|
scopedId: key
|
|
2839
2870
|
};
|
|
2840
|
-
}); // ──
|
|
2841
|
-
//
|
|
2842
|
-
//
|
|
2843
|
-
//
|
|
2871
|
+
}); // ── Drafts (in-progress widgets from the AI Builder) ─────
|
|
2872
|
+
// Drafts on disk look like installed packages — their dirs
|
|
2873
|
+
// sit under @ai-built/<name>-draft-<shortId>/ alongside real
|
|
2874
|
+
// installs. We surface them as `kind: "draft"` so consumers
|
|
2875
|
+
// (dashboard picker, Settings → Widgets) can render them
|
|
2876
|
+
// distinctly (Resume/Delete affordances) or filter them out.
|
|
2877
|
+
// The match is `packageDir`-based when available (canonical)
|
|
2878
|
+
// and falls back to a `-draft-` name-pattern check so legacy
|
|
2879
|
+
// drafts without the on-disk metadata still get classified.
|
|
2880
|
+
draftsByPackageDir = new Map();
|
|
2881
|
+
draftShortIdToId = new Map();
|
|
2882
|
+
if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.drafts) !== null && _window$mainApi !== void 0 && _window$mainApi.list)) {
|
|
2883
|
+
_context.next = 6;
|
|
2884
|
+
break;
|
|
2885
|
+
}
|
|
2886
|
+
_context.prev = 2;
|
|
2887
|
+
_context.next = 3;
|
|
2888
|
+
return window.mainApi.drafts.list();
|
|
2889
|
+
case 3:
|
|
2890
|
+
_t = _context.sent;
|
|
2891
|
+
if (_t) {
|
|
2892
|
+
_context.next = 4;
|
|
2893
|
+
break;
|
|
2894
|
+
}
|
|
2895
|
+
_t = [];
|
|
2896
|
+
case 4:
|
|
2897
|
+
allDrafts = _t;
|
|
2898
|
+
_iterator4 = _createForOfIteratorHelper$M(allDrafts);
|
|
2899
|
+
try {
|
|
2900
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2901
|
+
d = _step4.value;
|
|
2902
|
+
if (d !== null && d !== void 0 && d.packageDir) draftsByPackageDir.set(d.packageDir, d);
|
|
2903
|
+
if (d !== null && d !== void 0 && d.id) {
|
|
2904
|
+
shortId = String(d.id).replace(/^draft-/, "").slice(0, 8);
|
|
2905
|
+
if (shortId) draftShortIdToId.set(shortId, d.id);
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
} catch (err) {
|
|
2909
|
+
_iterator4.e(err);
|
|
2910
|
+
} finally {
|
|
2911
|
+
_iterator4.f();
|
|
2912
|
+
}
|
|
2913
|
+
_context.next = 6;
|
|
2914
|
+
break;
|
|
2915
|
+
case 5:
|
|
2916
|
+
_context.prev = 5;
|
|
2917
|
+
_context["catch"](2);
|
|
2918
|
+
case 6:
|
|
2844
2919
|
registryByName = {};
|
|
2845
|
-
if (!((_window$
|
|
2846
|
-
_context.next =
|
|
2920
|
+
if (!((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.widgets)) {
|
|
2921
|
+
_context.next = 8;
|
|
2847
2922
|
break;
|
|
2848
2923
|
}
|
|
2849
|
-
_context.next =
|
|
2924
|
+
_context.next = 7;
|
|
2850
2925
|
return window.mainApi.widgets.list();
|
|
2851
|
-
case
|
|
2926
|
+
case 7:
|
|
2852
2927
|
list = _context.sent;
|
|
2853
2928
|
(list || []).forEach(function (w) {
|
|
2854
2929
|
registryByName[w.packageId || w.name] = w;
|
|
2855
2930
|
});
|
|
2856
|
-
case
|
|
2931
|
+
case 8:
|
|
2857
2932
|
installedFromCM = Object.keys(cMap).filter(function (key) {
|
|
2858
2933
|
return cMap[key].type === "widget" && !!cMap[key]._sourcePackage;
|
|
2859
2934
|
}).map(function (key) {
|
|
2860
2935
|
var config = cMap[key];
|
|
2861
2936
|
var reg = registryByName[config._sourcePackage] || {};
|
|
2937
|
+
var classification = classifyWidget(reg, config._sourcePackage);
|
|
2862
2938
|
return {
|
|
2863
2939
|
name: key,
|
|
2864
2940
|
displayName: config.name || key,
|
|
@@ -2869,6 +2945,8 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
2869
2945
|
version: reg.version || null,
|
|
2870
2946
|
path: reg.path || null,
|
|
2871
2947
|
source: "installed",
|
|
2948
|
+
kind: classification.kind,
|
|
2949
|
+
draftId: classification.draftId,
|
|
2872
2950
|
providers: config.providers || [],
|
|
2873
2951
|
workspace: config.workspace || null,
|
|
2874
2952
|
componentNames: [key],
|
|
@@ -2885,6 +2963,7 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
2885
2963
|
fallbackInstalled = Object.values(registryByName).filter(function (w) {
|
|
2886
2964
|
return !cmSourcePackages.has(w.name);
|
|
2887
2965
|
}).map(function (w) {
|
|
2966
|
+
var classification = classifyWidget(w, w.name);
|
|
2888
2967
|
return {
|
|
2889
2968
|
name: w.name,
|
|
2890
2969
|
displayName: w.displayName || w.name,
|
|
@@ -2895,6 +2974,8 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
2895
2974
|
version: w.version || null,
|
|
2896
2975
|
path: w.path || null,
|
|
2897
2976
|
source: "installed",
|
|
2977
|
+
kind: classification.kind,
|
|
2978
|
+
draftId: classification.draftId,
|
|
2898
2979
|
providers: w.providers || [],
|
|
2899
2980
|
workspace: w.workspace || null,
|
|
2900
2981
|
componentNames: w.componentNames || [],
|
|
@@ -2903,31 +2984,31 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
2903
2984
|
};
|
|
2904
2985
|
});
|
|
2905
2986
|
setWidgets([].concat(_toConsumableArray(builtinWidgets), _toConsumableArray(installedFromCM), _toConsumableArray(fallbackInstalled)));
|
|
2906
|
-
_context.next =
|
|
2987
|
+
_context.next = 10;
|
|
2907
2988
|
break;
|
|
2908
|
-
case
|
|
2909
|
-
_context.prev =
|
|
2910
|
-
|
|
2911
|
-
setError(
|
|
2989
|
+
case 9:
|
|
2990
|
+
_context.prev = 9;
|
|
2991
|
+
_t3 = _context["catch"](1);
|
|
2992
|
+
setError(_t3.message || "Failed to load widgets");
|
|
2912
2993
|
setWidgets([]);
|
|
2913
|
-
case
|
|
2914
|
-
_context.prev =
|
|
2994
|
+
case 10:
|
|
2995
|
+
_context.prev = 10;
|
|
2915
2996
|
setIsLoading(false);
|
|
2916
|
-
return _context.finish(
|
|
2917
|
-
case
|
|
2997
|
+
return _context.finish(10);
|
|
2998
|
+
case 11:
|
|
2918
2999
|
case "end":
|
|
2919
3000
|
return _context.stop();
|
|
2920
3001
|
}
|
|
2921
|
-
}, _callee, null, [[1,
|
|
3002
|
+
}, _callee, null, [[1, 9, 10, 11], [2, 5]]);
|
|
2922
3003
|
})), []);
|
|
2923
3004
|
var uninstallWidget = useCallback(/*#__PURE__*/function () {
|
|
2924
3005
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(widgetName) {
|
|
2925
|
-
var _window$
|
|
2926
|
-
var widget, packageId, cMap, keysToRemove,
|
|
3006
|
+
var _window$mainApi3;
|
|
3007
|
+
var widget, packageId, cMap, keysToRemove, _t4;
|
|
2927
3008
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
2928
3009
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2929
3010
|
case 0:
|
|
2930
|
-
if ((_window$
|
|
3011
|
+
if ((_window$mainApi3 = window.mainApi) !== null && _window$mainApi3 !== void 0 && _window$mainApi3.widgets) {
|
|
2931
3012
|
_context2.next = 1;
|
|
2932
3013
|
break;
|
|
2933
3014
|
}
|
|
@@ -2958,8 +3039,8 @@ var useInstalledWidgets = function useInstalledWidgets() {
|
|
|
2958
3039
|
break;
|
|
2959
3040
|
case 4:
|
|
2960
3041
|
_context2.prev = 4;
|
|
2961
|
-
|
|
2962
|
-
throw
|
|
3042
|
+
_t4 = _context2["catch"](1);
|
|
3043
|
+
throw _t4;
|
|
2963
3044
|
case 5:
|
|
2964
3045
|
case "end":
|
|
2965
3046
|
return _context2.stop();
|
|
@@ -17667,6 +17748,12 @@ var EnhancedWidgetDropdown = function EnhancedWidgetDropdown(_ref) {
|
|
|
17667
17748
|
// Filter widgets based on search, author, and provider
|
|
17668
17749
|
var getFilteredWidgets = function getFilteredWidgets() {
|
|
17669
17750
|
var filtered = widgets.filter(function (widget) {
|
|
17751
|
+
// Drafts are in-progress widgets — they appear in
|
|
17752
|
+
// Settings → Widgets (as a Draft chip with Resume/Delete
|
|
17753
|
+
// affordances) but never in the dashboard placement picker
|
|
17754
|
+
// since they're not finished products.
|
|
17755
|
+
if (widget.kind === "draft") return false;
|
|
17756
|
+
|
|
17670
17757
|
// Search filter
|
|
17671
17758
|
var searchLower = searchQuery.toLowerCase();
|
|
17672
17759
|
var matchesSearch = !searchQuery || (widget.name || "").toLowerCase().includes(searchLower) || (widget.description || "").toLowerCase().includes(searchLower) || (widget.key || "").toLowerCase().includes(searchLower) || (widget.packageName || "").toLowerCase().includes(searchLower) || (widget.packageTags || []).some(function (t) {
|
|
@@ -48660,7 +48747,27 @@ var InstalledWidgetDetail = function InstalledWidgetDetail(_ref) {
|
|
|
48660
48747
|
className: "p-2 rounded bg-red-900/30 border border-red-700 text-xs text-red-400",
|
|
48661
48748
|
children: updateError
|
|
48662
48749
|
})
|
|
48663
|
-
}), widget.source !== "builtin" && /*#__PURE__*/jsxs("div", {
|
|
48750
|
+
}), widget.source !== "builtin" && widget.kind === "draft" && /*#__PURE__*/jsxs("div", {
|
|
48751
|
+
className: "flex-shrink-0 flex flex-row justify-end gap-2 px-6 py-4 border-t ".concat(currentTheme["border-primary-medium"] || "border-white/10"),
|
|
48752
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
48753
|
+
title: "Resume",
|
|
48754
|
+
onClick: function onClick() {
|
|
48755
|
+
window.dispatchEvent(new CustomEvent("dash:open-widget-builder", {
|
|
48756
|
+
detail: {
|
|
48757
|
+
resumeDraftId: widget.draftId || null
|
|
48758
|
+
}
|
|
48759
|
+
}));
|
|
48760
|
+
},
|
|
48761
|
+
disabled: !widget.draftId,
|
|
48762
|
+
size: "sm"
|
|
48763
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
48764
|
+
title: "Delete",
|
|
48765
|
+
onClick: function onClick() {
|
|
48766
|
+
return onDelete(widget);
|
|
48767
|
+
},
|
|
48768
|
+
size: "sm"
|
|
48769
|
+
})]
|
|
48770
|
+
}), widget.source !== "builtin" && widget.kind !== "draft" && /*#__PURE__*/jsxs("div", {
|
|
48664
48771
|
className: "flex-shrink-0 flex flex-row justify-end gap-2 px-6 py-4 border-t ".concat(currentTheme["border-primary-medium"] || "border-white/10"),
|
|
48665
48772
|
children: [updateInfo && /*#__PURE__*/jsx(Button, {
|
|
48666
48773
|
title: isUpdating ? "Updating..." : "Update Package to v".concat(updateInfo.latestVersion),
|
|
@@ -50127,7 +50234,12 @@ var WidgetsSection = function WidgetsSection(_ref) {
|
|
|
50127
50234
|
className: "flex items-center gap-2",
|
|
50128
50235
|
children: [widget.displayName || widget.name, widget.source === "builtin" && /*#__PURE__*/jsx(Tag3, {
|
|
50129
50236
|
text: "Built-in"
|
|
50130
|
-
}),
|
|
50237
|
+
}), widget.kind === "draft" && /*#__PURE__*/jsx("span", {
|
|
50238
|
+
className: "px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-amber-900/40 text-amber-200 border border-amber-700/30",
|
|
50239
|
+
"data-testid": "widget-draft-chip-".concat(widget.name),
|
|
50240
|
+
title: "In-progress widget \u2014 open to Resume or Delete from the action menu",
|
|
50241
|
+
children: "Draft"
|
|
50242
|
+
}), widget.kind !== "draft" && updates.has(widget.name) && /*#__PURE__*/jsx("span", {
|
|
50131
50243
|
className: "text-[10px] text-blue-400 font-medium",
|
|
50132
50244
|
"data-testid": "widget-update-badge-".concat(widget.name),
|
|
50133
50245
|
children: "Update"
|