@burdenoff/microfe-bigconsole 2026.1012.3 → 2026.1012.4

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.
Files changed (34) hide show
  1. package/dist/bigconsole/assistant/assistantApi.js +5 -5
  2. package/dist/bigconsole/components/builder/inspector/AppearanceSection.js +33 -18
  3. package/dist/bigconsole/components/dashboard/WidgetPalette.js +154 -150
  4. package/dist/bigconsole/components/embed/renderer-manifest.js +12 -0
  5. package/dist/bigconsole/components/widgets/WidgetRegistry.js +122 -1
  6. package/dist/bigconsole/components/widgets/WidgetWrapper.js +227 -224
  7. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgetConfig.d.ts +10 -0
  8. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgetConfig.js +113 -0
  9. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgets.d.ts +10 -0
  10. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgets.js +186 -0
  11. package/dist/bigconsole/components/widgets/advanced/data.d.ts +36 -0
  12. package/dist/bigconsole/components/widgets/advanced/data.js +113 -0
  13. package/dist/bigconsole/components/widgets/advanced/mapData.d.ts +10 -0
  14. package/dist/bigconsole/components/widgets/advanced/mapData.js +22 -0
  15. package/dist/bigconsole/components/widgets/advanced/waterfallData.d.ts +15 -0
  16. package/dist/bigconsole/components/widgets/advanced/waterfallData.js +28 -0
  17. package/dist/bigconsole/components/widgets/chart/charts/WaterfallChart.js +34 -37
  18. package/dist/bigconsole/components/widgets/index.js +1 -1
  19. package/dist/bigconsole/components/widgets/map-widget/MapWidget.d.ts +2 -0
  20. package/dist/bigconsole/components/widgets/map-widget/MapWidget.js +64 -63
  21. package/dist/bigconsole/graphql/widgetCapabilities.d.ts +7 -0
  22. package/dist/bigconsole/graphql/widgetCapabilities.js +37 -0
  23. package/dist/bigconsole/hooks/useWidgetCatalog.js +46 -41
  24. package/dist/bigconsole/hooks/useWidgetOperations.js +113 -88
  25. package/dist/bigconsole/renderers/adapters/BigConsoleRenderer.js +8 -5
  26. package/dist/bigconsole/types/index.d.ts +1 -1
  27. package/dist/bigconsole/utils/advancedWidgetCapabilities.d.ts +14 -0
  28. package/dist/bigconsole/utils/advancedWidgetCapabilities.js +36 -0
  29. package/dist/bigconsole/utils/widgetTypeMapping.d.ts +1 -1
  30. package/dist/bigconsole/utils/widgetTypeMapping.js +13 -2
  31. package/dist/generated/wspace-operations.d.ts +61 -2
  32. package/dist/generated/wspace-operations.js +44 -18
  33. package/dist/generated/wspace-types.d.ts +34 -3
  34. package/package.json +1 -1
@@ -15,9 +15,9 @@ import "./retention/RetentionWidget.js";
15
15
  import "./timeline/TimelineWidget.js";
16
16
  import "./adaptive-card/AdaptiveCardWidget.js";
17
17
  import "./adaptive-card/index.js";
18
+ import "./chart/ChartWidget.js";
18
19
  import "./calendar/CalendarWidget.js";
19
20
  import "./calendar/index.js";
20
- import "./chart/ChartWidget.js";
21
21
  import "./chart/index.js";
22
22
  import "./custom/CustomWidget.js";
23
23
  import "./custom/index.js";
@@ -42,6 +42,8 @@ export interface MapData {
42
42
  };
43
43
  zoom?: number;
44
44
  markers?: MapMarker[];
45
+ /** Governed tabular source envelope; field mappings select marker attributes. */
46
+ rows?: Record<string, unknown>[];
45
47
  /** GeoJSON regions for choropleth mode. */
46
48
  geoJson?: GeoJsonFeatureCollection;
47
49
  /** Per-region values joined to GeoJSON features for choropleth shading. */
@@ -1,82 +1,83 @@
1
- import { memo as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
3
- import s from "leaflet";
1
+ import { normalizeMapMarkers as e } from "../advanced/mapData.js";
2
+ import { memo as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
3
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
4
+ import c from "leaflet";
4
5
  //#region src/bigconsole/components/widgets/map-widget/MapWidget.tsx
5
- var c = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css", l = "sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=", u = !1;
6
- function d() {
7
- if (u || document.getElementById("leaflet-css")) return;
8
- u = !0;
6
+ var l = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css", u = "sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=", d = !1;
7
+ function f() {
8
+ if (d || document.getElementById("leaflet-css")) return;
9
+ d = !0;
9
10
  let e = document.createElement("link");
10
- e.id = "leaflet-css", e.rel = "stylesheet", e.href = c, e.integrity = l, e.crossOrigin = "anonymous", e.referrerPolicy = "no-referrer", e.onerror = () => {
11
- console.warn("[bigconsole] Leaflet CSS failed to load; map styling may be broken."), u = !1, e.remove();
11
+ e.id = "leaflet-css", e.rel = "stylesheet", e.href = l, e.integrity = u, e.crossOrigin = "anonymous", e.referrerPolicy = "no-referrer", e.onerror = () => {
12
+ console.warn("[bigconsole] Leaflet CSS failed to load; map styling may be broken."), d = !1, e.remove();
12
13
  }, document.head.appendChild(e);
13
14
  }
14
- var f = "var(--color-chart-1, #3b82f6)";
15
- function p(e) {
16
- if (typeof e != "string") return f;
15
+ var p = "var(--color-chart-1, #3b82f6)";
16
+ function m(e) {
17
+ if (typeof e != "string") return p;
17
18
  let t = e.trim();
18
- return t.length > 64 || /[;{}<>"'\\]/.test(t) || /\burl\s*\(/i.test(t) || !/^[#a-zA-Z0-9(),.%/_\s-]+$/.test(t) ? f : t;
19
+ return t.length > 64 || /[;{}<>"'\\]/.test(t) || /\burl\s*\(/i.test(t) || !/^[#a-zA-Z0-9(),.%/_\s-]+$/.test(t) ? p : t;
19
20
  }
20
- function m(e) {
21
+ function h(e) {
21
22
  return typeof e == "number" && Number.isFinite(e);
22
23
  }
23
- function h(e) {
24
+ function g(e) {
24
25
  return e >= .66 ? "var(--color-status-error)" : e >= .33 ? "var(--color-status-warning)" : "var(--color-status-info)";
25
26
  }
26
- function g(e) {
27
+ function _(e) {
27
28
  let t = document.createElement("div"), n = document.createElement("div");
28
- if (n.style.fontWeight = "600", n.textContent = e.popup || e.name || "Location", t.appendChild(n), m(e.value)) {
29
+ if (n.style.fontWeight = "600", n.textContent = e.popup || e.name || "Location", t.appendChild(n), h(e.value)) {
29
30
  let n = document.createElement("div");
30
31
  n.textContent = e.value.toLocaleString(), t.appendChild(n);
31
32
  }
32
33
  return t;
33
34
  }
34
- function _(e) {
35
+ function v(e) {
35
36
  let t = e;
36
- return t && m(t.lat) && m(t.lng) ? {
37
+ return t && h(t.lat) && h(t.lng) ? {
37
38
  lat: t.lat,
38
39
  lng: t.lng
39
40
  } : void 0;
40
41
  }
41
- function v(e, t) {
42
- let n = Array.isArray(e) ? void 0 : e, r = Array.isArray(e) ? e : e?.markers, i = Array.isArray(r) ? r.filter((e) => e && m(e.lat) && m(e.lng)) : [], a = (n?.geoJson ?? t.geoJson) || void 0, o = t.regionIdField || "id", s = /* @__PURE__ */ new Map(), c = n?.regions ?? t.regions;
42
+ function y(t, n) {
43
+ let r = Array.isArray(t) ? void 0 : t, i = e(Array.isArray(t) ? t : t?.markers ?? t?.rows, n), a = (r?.geoJson ?? n.geoJson) || void 0, o = n.regionIdField || "id", s = /* @__PURE__ */ new Map(), c = r?.regions ?? n.regions;
43
44
  if (Array.isArray(c)) for (let e of c) {
44
45
  if (!e) continue;
45
46
  let t = e[o] ?? e.id ?? e.region ?? e.code, n = e.value ?? e.count ?? e.total;
46
- t != null && m(n) && s.set(String(t), {
47
+ t != null && h(n) && s.set(String(t), {
47
48
  value: n,
48
49
  name: typeof e.name == "string" ? e.name : void 0
49
50
  });
50
51
  }
51
52
  return {
52
53
  markers: i,
53
- center: _(n?.center),
54
- zoom: m(n?.zoom) ? n?.zoom : void 0,
55
- fallbackCenter: _(t.center),
56
- fallbackZoom: m(t.zoom) ? t.zoom : void 0,
54
+ center: v(r?.center),
55
+ zoom: h(r?.zoom) ? r?.zoom : void 0,
56
+ fallbackCenter: v(n.center),
57
+ fallbackZoom: h(n.zoom) ? n.zoom : void 0,
57
58
  geoJson: a && Array.isArray(a.features) ? a : void 0,
58
59
  regionValues: s
59
60
  };
60
61
  }
61
- var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
62
- let f = r(null), _ = r(null), y = r(null), [b, x] = i("loading"), S = n(() => e?.config ?? {}, [e?.config]), C = S.showMarkers !== !1, w = S.mapMode === "heat", T = S.regionIdField || "id", { markers: E, center: D, zoom: O, fallbackCenter: k, fallbackZoom: A, geoJson: j, regionValues: M } = n(() => v(c, S), [c, S]), N = !!(j && M.size > 0), P = r(() => void 0);
63
- return t(() => {
62
+ var b = t(function({ widget: e, data: t, onClick: l, onDrilldown: u }) {
63
+ let d = i(null), p = i(null), v = i(null), [b, x] = a("loading"), S = r(() => e?.config ?? {}, [e?.config]), C = S.showMarkers !== !1, w = S.mapMode === "heat", T = S.regionIdField || "id", { markers: E, center: D, zoom: O, fallbackCenter: k, fallbackZoom: A, geoJson: j, regionValues: M } = r(() => y(t, S), [t, S]), N = !!(j && M.size > 0), P = i(() => void 0);
64
+ return n(() => {
64
65
  P.current = (e) => {
65
66
  u ? u(e) : l && l(e);
66
67
  };
67
- }, [l, u]), t(() => {
68
- let e = f.current;
68
+ }, [l, u]), n(() => {
69
+ let e = d.current;
69
70
  if (!e) return;
70
- d();
71
+ f();
71
72
  let t;
72
73
  try {
73
- t = s.map(e, {
74
+ t = c.map(e, {
74
75
  center: [20, 0],
75
76
  zoom: 2,
76
77
  scrollWheelZoom: !0,
77
78
  attributionControl: !0
78
79
  });
79
- let n = s.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
80
+ let n = c.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
80
81
  attribution: "© OpenStreetMap contributors",
81
82
  maxZoom: 18
82
83
  }), r = !1;
@@ -84,27 +85,27 @@ var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
84
85
  r = !0, x((e) => e === "error" ? "ready" : e);
85
86
  }), n.on("tileerror", () => {
86
87
  r || x("error");
87
- }), n.addTo(t), _.current = t, y.current = null, x("ready");
88
+ }), n.addTo(t), p.current = t, v.current = null, x("ready");
88
89
  } catch {
89
90
  x("error");
90
91
  return;
91
92
  }
92
- let n = typeof ResizeObserver < "u" ? new ResizeObserver(() => _.current?.invalidateSize()) : void 0;
93
+ let n = typeof ResizeObserver < "u" ? new ResizeObserver(() => p.current?.invalidateSize()) : void 0;
93
94
  n?.observe(e);
94
95
  let r = window.setTimeout(() => t.invalidateSize(), 80);
95
96
  return () => {
96
- window.clearTimeout(r), n?.disconnect(), t.remove(), _.current = null;
97
+ window.clearTimeout(r), n?.disconnect(), t.remove(), p.current = null;
97
98
  };
98
- }, []), t(() => {
99
- let e = _.current;
99
+ }, []), n(() => {
100
+ let e = p.current;
100
101
  if (!e) return;
101
- let t = s.layerGroup(), n = null;
102
+ let t = c.layerGroup(), n = null;
102
103
  if (j && M.size > 0) {
103
104
  let e = Array.from(M.values()).map((e) => e.value), r = Math.min(...e), i = Math.max(...e) - r || 1, a = (e) => {
104
105
  let t = e.properties ?? {}, n = e.id ?? t[T] ?? t.id ?? t.code;
105
106
  return n == null ? void 0 : M.get(String(n));
106
107
  };
107
- n = s.geoJSON(j, {
108
+ n = c.geoJSON(j, {
108
109
  style: (e) => {
109
110
  let t = e ? a(e) : void 0, n = t ? (t.value - r) / i : 0;
110
111
  return {
@@ -130,15 +131,15 @@ var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
130
131
  }), n.addTo(t);
131
132
  }
132
133
  if (C && w) {
133
- let e = E.map((e) => m(e.value) ? e.value : 1), n = e.reduce((e, t) => Math.min(e, t), Infinity), r = e.reduce((e, t) => Math.max(e, t), -Infinity) - n || 1;
134
+ let e = E.map((e) => h(e.value) ? e.value : 1), n = e.reduce((e, t) => Math.min(e, t), Infinity), r = e.reduce((e, t) => Math.max(e, t), -Infinity) - n || 1;
134
135
  E.forEach((i, a) => {
135
- let o = (e[a] - n) / r, c = s.circleMarker([i.lat, i.lng], {
136
+ let o = (e[a] - n) / r, s = c.circleMarker([i.lat, i.lng], {
136
137
  radius: 10 + o * 22,
137
- fillColor: h(o),
138
+ fillColor: g(o),
138
139
  fillOpacity: .25 + o * .35,
139
140
  stroke: !1
140
141
  }).addTo(t);
141
- c.bindPopup(g(i)), c.on("click", () => P.current(i));
142
+ s.bindPopup(_(i)), s.on("click", () => P.current(i));
142
143
  });
143
144
  } else if (C) for (let e of E) {
144
145
  let n = document.createElement("div");
@@ -147,17 +148,17 @@ var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
147
148
  height: "14px",
148
149
  borderRadius: "50% 50% 50% 0",
149
150
  transform: "rotate(-45deg)",
150
- background: p(e.color),
151
+ background: m(e.color),
151
152
  border: "2px solid #fff",
152
153
  boxShadow: "0 1px 4px rgba(0,0,0,.4)"
153
154
  });
154
- let r = s.divIcon({
155
+ let r = c.divIcon({
155
156
  className: "bc-map-marker",
156
157
  html: n,
157
158
  iconSize: [14, 14],
158
159
  iconAnchor: [7, 14]
159
- }), i = s.marker([e.lat, e.lng], { icon: r }).addTo(t);
160
- i.bindPopup(g(e)), i.on("click", () => P.current(e));
160
+ }), i = c.marker([e.lat, e.lng], { icon: r }).addTo(t);
161
+ i.bindPopup(_(e)), i.on("click", () => P.current(e));
161
162
  }
162
163
  t.addTo(e);
163
164
  let r = JSON.stringify({
@@ -168,7 +169,7 @@ var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
168
169
  fz: A ?? null,
169
170
  g: j ? M.size : 0
170
171
  });
171
- if (r !== y.current) if (y.current = r, D) e.setView([D.lat, D.lng], O ?? e.getZoom());
172
+ if (r !== v.current) if (v.current = r, D) e.setView([D.lat, D.lng], O ?? e.getZoom());
172
173
  else if (!E.length && n) {
173
174
  let t = n.getBounds();
174
175
  t.isValid() && e.fitBounds(t, {
@@ -177,12 +178,12 @@ var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
177
178
  });
178
179
  } else if (E.length === 1) e.setView([E[0].lat, E[0].lng], O ?? 8);
179
180
  else if (E.length > 1) {
180
- let t = s.latLngBounds(E.map((e) => [e.lat, e.lng]));
181
+ let t = c.latLngBounds(E.map((e) => [e.lat, e.lng]));
181
182
  e.fitBounds(t, {
182
183
  padding: [32, 32],
183
184
  maxZoom: 12
184
185
  });
185
- } else k ? e.setView([k.lat, k.lng], O ?? A ?? e.getZoom()) : m(O ?? A) && e.setZoom(O ?? A);
186
+ } else k ? e.setView([k.lat, k.lng], O ?? A ?? e.getZoom()) : h(O ?? A) && e.setZoom(O ?? A);
186
187
  let i = window.setTimeout(() => e.invalidateSize(), 0);
187
188
  return () => {
188
189
  window.clearTimeout(i), t.remove();
@@ -198,37 +199,37 @@ var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
198
199
  j,
199
200
  M,
200
201
  T
201
- ]), /* @__PURE__ */ o("div", {
202
+ ]), /* @__PURE__ */ s("div", {
202
203
  className: "relative h-full w-full overflow-hidden rounded-lg bg-bg-sunken",
203
204
  children: [
204
- /* @__PURE__ */ a("div", {
205
- ref: f,
205
+ /* @__PURE__ */ o("div", {
206
+ ref: d,
206
207
  className: "h-full w-full"
207
208
  }),
208
- b !== "error" && E.length === 0 && !N && /* @__PURE__ */ a("div", {
209
+ b !== "error" && E.length === 0 && !N && /* @__PURE__ */ o("div", {
209
210
  className: "pointer-events-none absolute inset-0 z-[500] flex items-center justify-center bg-bg-sunken/70 text-sm text-text-secondary",
210
- children: /* @__PURE__ */ o("div", {
211
+ children: /* @__PURE__ */ s("div", {
211
212
  className: "text-center",
212
- children: [/* @__PURE__ */ o("svg", {
213
+ children: [/* @__PURE__ */ s("svg", {
213
214
  className: "mx-auto mb-2 h-12 w-12 text-text-muted",
214
215
  fill: "none",
215
216
  stroke: "currentColor",
216
217
  viewBox: "0 0 24 24",
217
- children: [/* @__PURE__ */ a("path", {
218
+ children: [/* @__PURE__ */ o("path", {
218
219
  strokeLinecap: "round",
219
220
  strokeLinejoin: "round",
220
221
  strokeWidth: 1.5,
221
222
  d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"
222
- }), /* @__PURE__ */ a("path", {
223
+ }), /* @__PURE__ */ o("path", {
223
224
  strokeLinecap: "round",
224
225
  strokeLinejoin: "round",
225
226
  strokeWidth: 1.5,
226
227
  d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z"
227
228
  })]
228
- }), /* @__PURE__ */ a("p", { children: "No map data" })]
229
+ }), /* @__PURE__ */ o("p", { children: "No map data" })]
229
230
  })
230
231
  }),
231
- b === "error" && /* @__PURE__ */ a("div", {
232
+ b === "error" && /* @__PURE__ */ o("div", {
232
233
  className: "absolute inset-0 z-[500] flex items-center justify-center bg-bg-sunken px-4 text-center text-sm text-text-secondary",
233
234
  children: "The map needs an internet connection and couldn’t load."
234
235
  })
@@ -236,4 +237,4 @@ var y = e(function({ widget: e, data: c, onClick: l, onDrilldown: u }) {
236
237
  });
237
238
  });
238
239
  //#endregion
239
- export { y as default };
240
+ export { b as default };
@@ -0,0 +1,7 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+ import { GetWidgetTypesQuery } from '../../generated/wspace-operations';
3
+
4
+ /** Only an older catalog schema triggers fallback; auth/network errors remain errors. */
5
+ export declare function isLegacyWidgetCatalogSchema(error: unknown): boolean;
6
+ /** Uses the ordinary scoped catalog: production intentionally disables introspection. */
7
+ export declare function loadNativeWidgetCatalog(client: ApolloClient, workspaceId: string): Promise<GetWidgetTypesQuery>;
@@ -0,0 +1,37 @@
1
+ import { GetLegacyWidgetTypesDocument as e, GetWidgetTypesDocument as t } from "../../generated/wspace-operations.js";
2
+ //#region src/bigconsole/graphql/widgetCapabilities.ts
3
+ function n(e) {
4
+ return e instanceof Error && e.message.includes("Cannot query field \"federationType\" on type \"WidgetTypeInfo\"");
5
+ }
6
+ async function r(r, i) {
7
+ let a = {
8
+ fetchPolicy: "no-cache",
9
+ errorPolicy: "none",
10
+ context: {
11
+ requiredWorkspaceAuth: !0,
12
+ requiredWorkspaceId: i,
13
+ queryDeduplication: !1
14
+ }
15
+ };
16
+ try {
17
+ let e = await r.query({
18
+ query: t,
19
+ ...a
20
+ });
21
+ if (!e.data) throw Error("Widget catalog response is missing.");
22
+ return e.data;
23
+ } catch (t) {
24
+ if (!n(t)) throw t;
25
+ let i = await r.query({
26
+ query: e,
27
+ ...a
28
+ });
29
+ if (!i.data) throw Error("Widget catalog response is missing.", { cause: t });
30
+ return { getWidgetTypes: i.data.getWidgetTypes.map((e) => ({
31
+ ...e,
32
+ federationType: null
33
+ })) };
34
+ }
35
+ }
36
+ //#endregion
37
+ export { r as loadNativeWidgetCatalog };
@@ -1,26 +1,27 @@
1
- import { GetWidgetTypesDocument as e } from "../../generated/wspace-operations.js";
1
+ import { loadNativeWidgetCatalog as e } from "../graphql/widgetCapabilities.js";
2
2
  import t, { WIDGET_CATEGORY_LABELS as n, getAllWidgetDefinitions as r, getWidgetDefinition as i } from "../components/widgets/WidgetRegistry.js";
3
3
  import { isFederationAccessible as a, mapFromFederationWidgetType as o } from "../utils/widgetTypeMapping.js";
4
- import { useEffect as s, useMemo as c } from "react";
5
- import { useQuery as l } from "@tanstack/react-query";
6
- import { print as u } from "graphql";
4
+ import { filterAdvancedWidgetDefinitions as s, nativeFederationTypes as c } from "../utils/advancedWidgetCapabilities.js";
5
+ import { useEffect as l, useLayoutEffect as u, useMemo as d, useRef as f } from "react";
6
+ import { useApolloClient as p } from "@apollo/client/react";
7
+ import { useQuery as m } from "@tanstack/react-query";
7
8
  //#region src/bigconsole/hooks/useWidgetCatalog.ts
8
- var d = new Set(Object.keys(n)), f = "Puzzle", p = "Installed";
9
- function m(e) {
9
+ var h = new Set(Object.keys(n)), g = "Puzzle", _ = "Installed";
10
+ function v(e) {
10
11
  let n = String(e).toLowerCase();
11
12
  return Object.prototype.hasOwnProperty.call(t, n) || a(e);
12
13
  }
13
- function h(e) {
14
+ function y(e) {
14
15
  let n = String(e).toLowerCase();
15
16
  return Object.prototype.hasOwnProperty.call(t, n) ? n : o(e);
16
17
  }
17
- function g(e) {
18
+ function b(e) {
18
19
  return {
19
20
  type: "custom",
20
21
  name: e.label,
21
22
  description: e.description,
22
- icon: e.icon || f,
23
- category: p,
23
+ icon: e.icon || g,
24
+ category: _,
24
25
  component: null,
25
26
  defaultConfig: {
26
27
  ...e.defaultConfig ?? {},
@@ -51,9 +52,9 @@ function g(e) {
51
52
  tags: ["store", "installed"]
52
53
  };
53
54
  }
54
- function _(e) {
55
- if (!m(e.type)) return g(e);
56
- let t = h(e.type), n = i(t), r = d.has(e.category) ? e.category : n.category;
55
+ function x(e) {
56
+ if (!v(e.type)) return b(e);
57
+ let t = y(e.type), n = i(t), r = h.has(e.category) ? e.category : n.category;
57
58
  return {
58
59
  type: t,
59
60
  name: e.label,
@@ -81,42 +82,46 @@ function _(e) {
81
82
  tags: n.tags
82
83
  };
83
84
  }
84
- function v(t = {}) {
85
- let { workspaceId: n, apiGatewayUrl: i, authToken: a, enabled: o = !0 } = t, { data: d, isLoading: f, error: p } = l({
86
- queryKey: ["widgetCatalog", n],
85
+ function S(t = {}) {
86
+ let { workspaceId: n, apiGatewayUrl: i, enabled: a = !0 } = t, o = p(), h = f(n);
87
+ u(() => (h.current = a ? n : void 0, () => {
88
+ h.current = void 0;
89
+ }), [n, a]);
90
+ let { data: g, isLoading: _, error: v } = m({
91
+ queryKey: [
92
+ "widgetCatalog",
93
+ n,
94
+ i
95
+ ],
87
96
  queryFn: async () => {
88
- let t = { "Content-Type": "application/json" };
89
- n && (t["x-workspace-id"] = n), a && (t.Authorization = `Bearer ${a}`);
90
- let r = i ? `${i}/workspaces/graphql` : "/workspaces/graphql", o = await fetch(r, {
91
- method: "POST",
92
- headers: t,
93
- body: JSON.stringify({ query: u(e) })
94
- });
95
- if (!o.ok) throw Error(`Failed to fetch widget catalog: ${o.status}`);
96
- let s = await o.json();
97
- if (s.errors?.length) throw Error(s.errors[0].message);
98
- return s.data?.getWidgetTypes ?? [];
97
+ if (!n || h.current !== n) throw Error("Widget catalog workspace changed.");
98
+ let t = await e(o, n);
99
+ if (h.current !== n) throw Error("Widget catalog workspace changed.");
100
+ return t;
99
101
  },
100
- enabled: o && !!n,
102
+ enabled: a && !!n,
101
103
  staleTime: 600 * 1e3
102
104
  });
103
- return s(() => {
104
- p && console.warn("Falling back to bundled widget registry:", p.message);
105
- }, [p]), c(() => d && d.length > 0 ? {
106
- definitions: d.map(_),
105
+ l(() => {
106
+ v && console.warn("Falling back to bundled widget registry:", v.message);
107
+ }, [v]);
108
+ let y = g?.getWidgetTypes, b = d(() => c(g?.getWidgetTypes ?? []), [g]);
109
+ return d(() => y && y.length > 0 ? {
110
+ definitions: s(y.map(x), b),
107
111
  source: "backend",
108
- loading: f,
109
- error: p ?? void 0
112
+ loading: _,
113
+ error: v ?? void 0
110
114
  } : {
111
- definitions: r(),
115
+ definitions: s(r(), b),
112
116
  source: "static",
113
- loading: f,
114
- error: p ?? void 0
117
+ loading: _,
118
+ error: v ?? void 0
115
119
  }, [
116
- d,
117
- f,
118
- p
120
+ y,
121
+ b,
122
+ _,
123
+ v
119
124
  ]);
120
125
  }
121
126
  //#endregion
122
- export { v as default };
127
+ export { S as default };