@floegence/floe-webapp-core 0.4.0 → 0.6.0

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 (87) hide show
  1. package/dist/components/ui/Dialog.d.ts +3 -0
  2. package/dist/components/ui/DirectoryPicker.d.ts +31 -0
  3. package/dist/components/ui/index.d.ts +1 -0
  4. package/dist/index.js +193 -191
  5. package/dist/index10.js +2 -2
  6. package/dist/index11.js +4 -4
  7. package/dist/index12.js +5 -5
  8. package/dist/index13.js +3 -3
  9. package/dist/index14.js +4 -4
  10. package/dist/index15.js +5 -5
  11. package/dist/index16.js +5 -5
  12. package/dist/index17.js +4 -4
  13. package/dist/index18.js +6 -6
  14. package/dist/index19.js +2 -2
  15. package/dist/index2.js +6 -6
  16. package/dist/index20.js +2 -2
  17. package/dist/index21.js +1 -1
  18. package/dist/index22.js +8 -5
  19. package/dist/index23.js +3 -3
  20. package/dist/index24.js +3 -3
  21. package/dist/index25.js +1 -1
  22. package/dist/index26.js +5 -5
  23. package/dist/index27.js +1 -1
  24. package/dist/index28.js +3 -3
  25. package/dist/index29.js +362 -81
  26. package/dist/index3.js +2 -2
  27. package/dist/index30.js +87 -37
  28. package/dist/index31.js +37 -66
  29. package/dist/index32.js +69 -278
  30. package/dist/index33.js +278 -152
  31. package/dist/index34.js +147 -24
  32. package/dist/index35.js +26 -45
  33. package/dist/index36.js +45 -10
  34. package/dist/index37.js +10 -27
  35. package/dist/index38.js +27 -159
  36. package/dist/index39.js +156 -228
  37. package/dist/index4.js +1 -1
  38. package/dist/index40.js +228 -125
  39. package/dist/index41.js +110 -176
  40. package/dist/index42.js +149 -122
  41. package/dist/index43.js +161 -183
  42. package/dist/index44.js +185 -145
  43. package/dist/index45.js +143 -114
  44. package/dist/index46.js +119 -47
  45. package/dist/index47.js +50 -48
  46. package/dist/index48.js +40 -30
  47. package/dist/index49.js +33 -44
  48. package/dist/index5.js +4 -4
  49. package/dist/index50.js +49 -25
  50. package/dist/index51.js +21 -169
  51. package/dist/index52.js +169 -36
  52. package/dist/index53.js +38 -64
  53. package/dist/index54.js +63 -93
  54. package/dist/index55.js +86 -111
  55. package/dist/index56.js +114 -131
  56. package/dist/index57.js +131 -32
  57. package/dist/index58.js +29 -425
  58. package/dist/index59.js +433 -36
  59. package/dist/index6.js +2 -2
  60. package/dist/index60.js +31 -12
  61. package/dist/index61.js +19 -13
  62. package/dist/index62.js +13 -10
  63. package/dist/index63.js +10 -16
  64. package/dist/index64.js +16 -10
  65. package/dist/index65.js +10 -8
  66. package/dist/index66.js +8 -61
  67. package/dist/index67.js +61 -5
  68. package/dist/index68.js +5 -11
  69. package/dist/index69.js +10 -25
  70. package/dist/index7.js +2 -2
  71. package/dist/index70.js +24 -30
  72. package/dist/index71.js +31 -90
  73. package/dist/index72.js +90 -26
  74. package/dist/index73.js +24 -43
  75. package/dist/index74.js +45 -13
  76. package/dist/index75.js +14 -35
  77. package/dist/index76.js +33 -62
  78. package/dist/index77.js +61 -81
  79. package/dist/index78.js +84 -14
  80. package/dist/index79.js +12 -2261
  81. package/dist/index8.js +2 -2
  82. package/dist/index80.js +2262 -6
  83. package/dist/index81.js +7 -39
  84. package/dist/index82.js +42 -0
  85. package/dist/index9.js +1 -1
  86. package/dist/styles.css +1 -1
  87. package/package.json +1 -1
package/dist/index55.js CHANGED
@@ -1,124 +1,99 @@
1
- import { delegateEvents as g, template as m, insert as l, createComponent as f, effect as h, className as p } from "solid-js/web";
2
- import { onCleanup as b, For as v, Show as u } from "solid-js";
3
- import { createStore as x, produce as d } from "solid-js/store";
4
- import { createSimpleContext as $ } from "./index50.js";
5
- import { cn as w } from "./index67.js";
6
- var _ = /* @__PURE__ */ m('<div class="fixed bottom-4 right-4 z-[100] flex flex-col gap-2 max-w-sm">'), y = /* @__PURE__ */ m('<p class="mt-1 text-sm text-muted-foreground">'), k = /* @__PURE__ */ m('<button type=button class="mt-2 text-sm font-medium text-primary hover:underline">'), C = /* @__PURE__ */ m('<div role=alert><div class="flex items-start gap-3"><div class="flex-1 min-w-0"><p class="font-medium text-sm"></p></div><button type=button class="text-muted-foreground hover:text-foreground transition-colors"aria-label=Dismiss><svg class="w-4 h-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M6 18L18 6M6 6l12 12">');
7
- const N = 5e3;
1
+ import { createSignal as p, onCleanup as K } from "solid-js";
2
+ import { createSimpleContext as D } from "./index51.js";
3
+ import { useResolvedFloeConfig as W } from "./index52.js";
4
+ import { formatKeybind as P, parseKeybind as k, matchKeybind as y } from "./index70.js";
5
+ import { deferNonBlocking as v } from "./index69.js";
8
6
  function S() {
9
- const [o, c] = x({
10
- notifications: []
11
- }), i = /* @__PURE__ */ new Map();
12
- b(() => {
13
- i.forEach((t) => clearTimeout(t)), i.clear();
14
- });
15
- const a = (t) => {
16
- const e = i.get(t);
17
- e && (clearTimeout(e), i.delete(t)), c(d((n) => {
18
- n.notifications = n.notifications.filter((s) => s.id !== t);
19
- }));
20
- }, r = (t) => {
21
- const e = `notification-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, n = t.duration ?? N;
22
- if (c(d((s) => {
23
- s.notifications.push({
24
- ...t,
25
- id: e
26
- });
27
- })), n > 0) {
28
- const s = setTimeout(() => a(e), n);
29
- i.set(e, s);
30
- }
31
- return e;
7
+ const x = W(), u = () => x.config.commands, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), [g, l] = p(!1), [b, m] = p(""), [C, E] = p([]), d = () => {
8
+ E(Array.from(i.values()));
32
9
  };
10
+ if (typeof window < "u" && u().enableGlobalKeybinds) {
11
+ const e = (n) => {
12
+ if (!n || !(n instanceof HTMLElement)) return !1;
13
+ const r = n.tagName.toLowerCase();
14
+ return !!(r === "input" || r === "textarea" || r === "select" || n.isContentEditable || n.getAttribute("role") === "textbox");
15
+ }, t = (n) => {
16
+ const r = u();
17
+ if (!r.ignoreWhenTyping) return !1;
18
+ const o = n.target ?? (typeof document < "u" ? document.activeElement : null);
19
+ return !(!e(o) || r.allowWhenTypingWithin && o instanceof Element && o.closest(r.allowWhenTypingWithin));
20
+ }, s = (n) => {
21
+ const r = u();
22
+ if (r.save.enabled && y(n, r.save.keybind)) {
23
+ const o = i.get(r.save.commandId);
24
+ o ? (n.preventDefault(), v(() => {
25
+ Promise.resolve(o.execute()).catch((c) => console.error(c));
26
+ })) : r.save.preventDefaultWhenNoHandler && n.preventDefault();
27
+ return;
28
+ }
29
+ if (!t(n)) {
30
+ if (r.palette.enabled && y(n, r.palette.keybind)) {
31
+ n.preventDefault(), l((o) => !o);
32
+ return;
33
+ }
34
+ if (!g())
35
+ for (const o of i.values()) {
36
+ if (!o.keybind) continue;
37
+ const c = a.get(o.id);
38
+ if (c && y(n, c)) {
39
+ n.preventDefault(), v(() => {
40
+ Promise.resolve(o.execute()).catch((L) => console.error(L));
41
+ });
42
+ return;
43
+ }
44
+ }
45
+ }
46
+ };
47
+ window.addEventListener("keydown", s), K(() => window.removeEventListener("keydown", s));
48
+ }
49
+ let w = "", h = null, f = [];
33
50
  return {
34
- notifications: () => o.notifications,
35
- show: r,
36
- dismiss: a,
37
- dismissAll: () => {
38
- i.forEach((t) => clearTimeout(t)), i.clear(), c("notifications", []);
51
+ // State
52
+ isOpen: g,
53
+ search: b,
54
+ commands: C,
55
+ filteredCommands: () => {
56
+ const e = C(), t = b().toLowerCase().trim();
57
+ return e === h && t === w ? f : (h = e, w = t, t ? (f = e.filter((s) => {
58
+ var n, r;
59
+ return s.title.toLowerCase().includes(t) || ((n = s.description) == null ? void 0 : n.toLowerCase().includes(t)) || ((r = s.category) == null ? void 0 : r.toLowerCase().includes(t));
60
+ }), f) : (f = e, e));
39
61
  },
40
- info: (t, e) => r({
41
- type: "info",
42
- title: t,
43
- message: e
44
- }),
45
- success: (t, e) => r({
46
- type: "success",
47
- title: t,
48
- message: e
62
+ // Actions
63
+ open: () => l(!0),
64
+ close: () => {
65
+ l(!1), m("");
66
+ },
67
+ toggle: () => l((e) => !e),
68
+ setSearch: (e) => m(e),
69
+ register: (e) => (i.set(e.id, e), e.keybind && a.set(e.id, k(e.keybind)), d(), () => {
70
+ i.delete(e.id), a.delete(e.id), d();
49
71
  }),
50
- warning: (t, e) => r({
51
- type: "warning",
52
- title: t,
53
- message: e
72
+ registerAll: (e) => (e.forEach((t) => {
73
+ i.set(t.id, t), t.keybind && a.set(t.id, k(t.keybind));
74
+ }), d(), () => {
75
+ e.forEach((t) => {
76
+ i.delete(t.id), a.delete(t.id);
77
+ }), d();
54
78
  }),
55
- error: (t, e) => r({
56
- type: "error",
57
- title: t,
58
- message: e
59
- })
79
+ execute: (e) => {
80
+ const t = i.get(e);
81
+ t && (l(!1), m(""), v(() => {
82
+ Promise.resolve(t.execute()).catch((s) => console.error(s));
83
+ }));
84
+ },
85
+ getKeybindDisplay: P
60
86
  };
61
87
  }
62
88
  const {
63
- Provider: P,
64
- use: T
65
- } = $({
66
- name: "Notification",
89
+ Provider: N,
90
+ use: O
91
+ } = D({
92
+ name: "Command",
67
93
  init: S
68
94
  });
69
- function U() {
70
- const {
71
- notifications: o,
72
- dismiss: c
73
- } = T();
74
- return (() => {
75
- var i = _();
76
- return l(i, f(v, {
77
- get each() {
78
- return o();
79
- },
80
- children: (a) => f(D, {
81
- notification: a,
82
- onDismiss: () => c(a.id)
83
- })
84
- })), i;
85
- })();
86
- }
87
- function D(o) {
88
- const c = {
89
- info: "border-info/50 bg-info/10",
90
- success: "border-success/50 bg-success/10",
91
- warning: "border-warning/50 bg-warning/10",
92
- error: "border-error/50 bg-error/10"
93
- };
94
- return (() => {
95
- var i = C(), a = i.firstChild, r = a.firstChild, t = r.firstChild, e = r.nextSibling;
96
- return l(t, () => o.notification.title), l(r, f(u, {
97
- get when() {
98
- return o.notification.message;
99
- },
100
- get children() {
101
- var n = y();
102
- return l(n, () => o.notification.message), n;
103
- }
104
- }), null), l(r, f(u, {
105
- get when() {
106
- return o.notification.action;
107
- },
108
- get children() {
109
- var n = k();
110
- return n.$$click = () => {
111
- var s;
112
- return (s = o.notification.action) == null ? void 0 : s.onClick();
113
- }, l(n, () => o.notification.action.label), n;
114
- }
115
- }), null), e.$$click = () => o.onDismiss(), h(() => p(i, w("animate-in slide-in-from-right fade-in", "rounded-lg border p-4 shadow-lg backdrop-blur-sm", "bg-card text-card-foreground", c[o.notification.type]))), i;
116
- })();
117
- }
118
- g(["click"]);
119
95
  export {
120
- U as NotificationContainer,
121
- P as NotificationProvider,
122
- S as createNotificationService,
123
- T as useNotification
96
+ N as CommandProvider,
97
+ S as createCommandService,
98
+ O as useCommand
124
99
  };
package/dist/index56.js CHANGED
@@ -1,141 +1,124 @@
1
- import { createSignal as C } from "solid-js";
2
- import { createSimpleContext as w } from "./index50.js";
3
- import { useResolvedFloeConfig as b } from "./index51.js";
4
- import { useTheme as v } from "./index52.js";
5
- import { useLayout as M } from "./index53.js";
6
- import { useCommand as S } from "./index54.js";
7
- import { useNotification as x } from "./index55.js";
8
- import { deferNonBlocking as A } from "./index68.js";
9
- function R(s) {
10
- const r = `[${s}]`;
11
- return {
12
- debug: (...o) => console.debug(r, ...o),
13
- info: (...o) => console.info(r, ...o),
14
- warn: (...o) => console.warn(r, ...o),
15
- error: (...o) => console.error(r, ...o)
16
- };
17
- }
18
- function B(s, r) {
19
- const o = `component:${r}:`;
20
- return {
21
- get: (a, u) => s.load(o + a, u),
22
- set: (a, u) => s.debouncedSave(o + a, u),
23
- remove: (a) => A(() => s.remove(o + a))
24
- };
25
- }
26
- function J() {
27
- const s = v(), r = M(), o = S(), a = x(), u = b();
28
- return (g, f) => ({
29
- protocol: f == null ? void 0 : f.protocol,
30
- theme: s,
31
- layout: r,
32
- commands: o,
33
- notifications: a,
34
- storage: B(u.persist, g),
35
- logger: R(g)
1
+ import { delegateEvents as g, template as m, insert as l, createComponent as f, effect as h, className as p } from "solid-js/web";
2
+ import { onCleanup as b, For as v, Show as u } from "solid-js";
3
+ import { createStore as x, produce as d } from "solid-js/store";
4
+ import { createSimpleContext as $ } from "./index51.js";
5
+ import { cn as w } from "./index68.js";
6
+ var _ = /* @__PURE__ */ m('<div class="fixed bottom-4 right-4 z-[100] flex flex-col gap-2 max-w-sm">'), y = /* @__PURE__ */ m('<p class="mt-1 text-sm text-muted-foreground">'), k = /* @__PURE__ */ m('<button type=button class="mt-2 text-sm font-medium text-primary hover:underline">'), C = /* @__PURE__ */ m('<div role=alert><div class="flex items-start gap-3"><div class="flex-1 min-w-0"><p class="font-medium text-sm"></p></div><button type=button class="text-muted-foreground hover:text-foreground transition-colors"aria-label=Dismiss><svg class="w-4 h-4"fill=none viewBox="0 0 24 24"stroke=currentColor><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M6 18L18 6M6 6l12 12">');
7
+ const N = 5e3;
8
+ function S() {
9
+ const [o, c] = x({
10
+ notifications: []
11
+ }), i = /* @__PURE__ */ new Map();
12
+ b(() => {
13
+ i.forEach((t) => clearTimeout(t)), i.clear();
36
14
  });
37
- }
38
- const h = w({
39
- name: "ComponentRegistry",
40
- init: k
41
- }), K = h.Provider;
42
- function O() {
43
- return h.use();
44
- }
45
- function k() {
46
- const [s, r] = C(/* @__PURE__ */ new Map()), [o, a] = C(/* @__PURE__ */ new Set()), u = /* @__PURE__ */ new Map(), g = (t) => {
47
- r((e) => new Map(e).set(t.id, t));
48
- }, f = (t) => {
49
- r((e) => {
50
- const n = new Map(e);
51
- return t.forEach((c) => n.set(c.id, c)), n;
52
- });
53
- }, y = async (t, e) => {
54
- var p, l;
55
- const n = s().get(t);
56
- if (!n || o().has(t)) return;
57
- const c = [];
58
- try {
59
- if ((p = n.commands) != null && p.length) {
60
- const m = n.commands.map((i) => ({
61
- id: i.id,
62
- title: i.title,
63
- description: i.description,
64
- icon: i.icon,
65
- keybind: i.keybind,
66
- category: i.category,
67
- execute: () => i.execute(e)
68
- }));
69
- c.push(e.commands.registerAll(m));
70
- }
71
- await ((l = n.onMount) == null ? void 0 : l.call(n, e)), c.length && u.set(t, () => c.forEach((m) => m())), a((m) => {
72
- const i = new Set(m);
73
- return i.add(t), i;
15
+ const a = (t) => {
16
+ const e = i.get(t);
17
+ e && (clearTimeout(e), i.delete(t)), c(d((n) => {
18
+ n.notifications = n.notifications.filter((s) => s.id !== t);
19
+ }));
20
+ }, r = (t) => {
21
+ const e = `notification-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, n = t.duration ?? N;
22
+ if (c(d((s) => {
23
+ s.notifications.push({
24
+ ...t,
25
+ id: e
74
26
  });
75
- } catch (m) {
76
- throw c.forEach((i) => i()), m;
27
+ })), n > 0) {
28
+ const s = setTimeout(() => a(e), n);
29
+ i.set(e, s);
77
30
  }
78
- }, d = async (t) => {
79
- var n, c;
80
- const e = s().get(t);
81
- if (e && o().has(t))
82
- try {
83
- await ((n = e.onUnmount) == null ? void 0 : n.call(e));
84
- } finally {
85
- (c = u.get(t)) == null || c(), u.delete(t), a((p) => {
86
- const l = new Set(p);
87
- return l.delete(t), l;
88
- });
89
- }
31
+ return e;
90
32
  };
91
33
  return {
92
- register: g,
93
- registerAll: f,
94
- unregister: async (t) => {
95
- await d(t), r((e) => {
96
- const n = new Map(e);
97
- return n.delete(t), n;
98
- });
34
+ notifications: () => o.notifications,
35
+ show: r,
36
+ dismiss: a,
37
+ dismissAll: () => {
38
+ i.forEach((t) => clearTimeout(t)), i.clear(), c("notifications", []);
99
39
  },
100
- mount: y,
101
- unmount: d,
102
- mountAll: async (t) => {
103
- for (const e of s().keys())
104
- await y(e, t(e));
105
- },
106
- unmountAll: async () => {
107
- for (const t of o())
108
- await d(t);
109
- },
110
- components: s,
111
- mountedComponents: o,
112
- sidebarItems: () => {
113
- const t = [];
114
- for (const e of s().values())
115
- e.sidebar && t.push({
116
- ...e,
117
- order: e.sidebar.order ?? 100
118
- });
119
- return t.sort((e, n) => e.order - n.order);
120
- },
121
- allCommands: () => {
122
- const t = [];
123
- for (const e of s().values())
124
- e.commands && t.push(...e.commands);
125
- return t;
126
- },
127
- statusBarItems: () => {
128
- const t = [];
129
- for (const e of s().values())
130
- e.statusBar && t.push(...e.statusBar);
131
- return t;
132
- },
133
- getComponent: (t) => s().get(t)
40
+ info: (t, e) => r({
41
+ type: "info",
42
+ title: t,
43
+ message: e
44
+ }),
45
+ success: (t, e) => r({
46
+ type: "success",
47
+ title: t,
48
+ message: e
49
+ }),
50
+ warning: (t, e) => r({
51
+ type: "warning",
52
+ title: t,
53
+ message: e
54
+ }),
55
+ error: (t, e) => r({
56
+ type: "error",
57
+ title: t,
58
+ message: e
59
+ })
134
60
  };
135
61
  }
62
+ const {
63
+ Provider: P,
64
+ use: T
65
+ } = $({
66
+ name: "Notification",
67
+ init: S
68
+ });
69
+ function U() {
70
+ const {
71
+ notifications: o,
72
+ dismiss: c
73
+ } = T();
74
+ return (() => {
75
+ var i = _();
76
+ return l(i, f(v, {
77
+ get each() {
78
+ return o();
79
+ },
80
+ children: (a) => f(D, {
81
+ notification: a,
82
+ onDismiss: () => c(a.id)
83
+ })
84
+ })), i;
85
+ })();
86
+ }
87
+ function D(o) {
88
+ const c = {
89
+ info: "border-info/50 bg-info/10",
90
+ success: "border-success/50 bg-success/10",
91
+ warning: "border-warning/50 bg-warning/10",
92
+ error: "border-error/50 bg-error/10"
93
+ };
94
+ return (() => {
95
+ var i = C(), a = i.firstChild, r = a.firstChild, t = r.firstChild, e = r.nextSibling;
96
+ return l(t, () => o.notification.title), l(r, f(u, {
97
+ get when() {
98
+ return o.notification.message;
99
+ },
100
+ get children() {
101
+ var n = y();
102
+ return l(n, () => o.notification.message), n;
103
+ }
104
+ }), null), l(r, f(u, {
105
+ get when() {
106
+ return o.notification.action;
107
+ },
108
+ get children() {
109
+ var n = k();
110
+ return n.$$click = () => {
111
+ var s;
112
+ return (s = o.notification.action) == null ? void 0 : s.onClick();
113
+ }, l(n, () => o.notification.action.label), n;
114
+ }
115
+ }), null), e.$$click = () => o.onDismiss(), h(() => p(i, w("animate-in slide-in-from-right fade-in", "rounded-lg border p-4 shadow-lg backdrop-blur-sm", "bg-card text-card-foreground", c[o.notification.type]))), i;
116
+ })();
117
+ }
118
+ g(["click"]);
136
119
  export {
137
- K as ComponentRegistryProvider,
138
- k as createComponentRegistry,
139
- J as useComponentContextFactory,
140
- O as useComponentRegistry
120
+ U as NotificationContainer,
121
+ P as NotificationProvider,
122
+ S as createNotificationService,
123
+ T as useNotification
141
124
  };
package/dist/index57.js CHANGED
@@ -1,42 +1,141 @@
1
- import { createSignal as n } from "solid-js";
2
- import { createSimpleContext as o } from "./index50.js";
3
- const {
4
- Provider: f,
5
- use: m
6
- } = o({
7
- name: "WidgetRegistry",
8
- init: c
9
- });
10
- function c() {
11
- const [s, i] = n(/* @__PURE__ */ new Map());
1
+ import { createSignal as C } from "solid-js";
2
+ import { createSimpleContext as w } from "./index51.js";
3
+ import { useResolvedFloeConfig as b } from "./index52.js";
4
+ import { useTheme as v } from "./index53.js";
5
+ import { useLayout as M } from "./index54.js";
6
+ import { useCommand as S } from "./index55.js";
7
+ import { useNotification as x } from "./index56.js";
8
+ import { deferNonBlocking as A } from "./index69.js";
9
+ function R(s) {
10
+ const r = `[${s}]`;
12
11
  return {
13
- register: (e) => {
14
- i((t) => new Map(t).set(e.type, e));
15
- },
16
- registerAll: (e) => {
17
- i((t) => {
18
- const r = new Map(t);
19
- return e.forEach((g) => r.set(g.type, g)), r;
12
+ debug: (...o) => console.debug(r, ...o),
13
+ info: (...o) => console.info(r, ...o),
14
+ warn: (...o) => console.warn(r, ...o),
15
+ error: (...o) => console.error(r, ...o)
16
+ };
17
+ }
18
+ function B(s, r) {
19
+ const o = `component:${r}:`;
20
+ return {
21
+ get: (a, u) => s.load(o + a, u),
22
+ set: (a, u) => s.debouncedSave(o + a, u),
23
+ remove: (a) => A(() => s.remove(o + a))
24
+ };
25
+ }
26
+ function J() {
27
+ const s = v(), r = M(), o = S(), a = x(), u = b();
28
+ return (g, f) => ({
29
+ protocol: f == null ? void 0 : f.protocol,
30
+ theme: s,
31
+ layout: r,
32
+ commands: o,
33
+ notifications: a,
34
+ storage: B(u.persist, g),
35
+ logger: R(g)
36
+ });
37
+ }
38
+ const h = w({
39
+ name: "ComponentRegistry",
40
+ init: k
41
+ }), K = h.Provider;
42
+ function O() {
43
+ return h.use();
44
+ }
45
+ function k() {
46
+ const [s, r] = C(/* @__PURE__ */ new Map()), [o, a] = C(/* @__PURE__ */ new Set()), u = /* @__PURE__ */ new Map(), g = (t) => {
47
+ r((e) => new Map(e).set(t.id, t));
48
+ }, f = (t) => {
49
+ r((e) => {
50
+ const n = new Map(e);
51
+ return t.forEach((c) => n.set(c.id, c)), n;
52
+ });
53
+ }, y = async (t, e) => {
54
+ var p, l;
55
+ const n = s().get(t);
56
+ if (!n || o().has(t)) return;
57
+ const c = [];
58
+ try {
59
+ if ((p = n.commands) != null && p.length) {
60
+ const m = n.commands.map((i) => ({
61
+ id: i.id,
62
+ title: i.title,
63
+ description: i.description,
64
+ icon: i.icon,
65
+ keybind: i.keybind,
66
+ category: i.category,
67
+ execute: () => i.execute(e)
68
+ }));
69
+ c.push(e.commands.registerAll(m));
70
+ }
71
+ await ((l = n.onMount) == null ? void 0 : l.call(n, e)), c.length && u.set(t, () => c.forEach((m) => m())), a((m) => {
72
+ const i = new Set(m);
73
+ return i.add(t), i;
20
74
  });
21
- },
22
- unregister: (e) => {
23
- i((t) => {
24
- const r = new Map(t);
25
- return r.delete(e), r;
75
+ } catch (m) {
76
+ throw c.forEach((i) => i()), m;
77
+ }
78
+ }, d = async (t) => {
79
+ var n, c;
80
+ const e = s().get(t);
81
+ if (e && o().has(t))
82
+ try {
83
+ await ((n = e.onUnmount) == null ? void 0 : n.call(e));
84
+ } finally {
85
+ (c = u.get(t)) == null || c(), u.delete(t), a((p) => {
86
+ const l = new Set(p);
87
+ return l.delete(t), l;
88
+ });
89
+ }
90
+ };
91
+ return {
92
+ register: g,
93
+ registerAll: f,
94
+ unregister: async (t) => {
95
+ await d(t), r((e) => {
96
+ const n = new Map(e);
97
+ return n.delete(t), n;
26
98
  });
27
99
  },
28
- widgets: s,
29
- getWidget: (e) => s().get(e),
30
- getWidgetsByCategory: (e) => {
100
+ mount: y,
101
+ unmount: d,
102
+ mountAll: async (t) => {
103
+ for (const e of s().keys())
104
+ await y(e, t(e));
105
+ },
106
+ unmountAll: async () => {
107
+ for (const t of o())
108
+ await d(t);
109
+ },
110
+ components: s,
111
+ mountedComponents: o,
112
+ sidebarItems: () => {
113
+ const t = [];
114
+ for (const e of s().values())
115
+ e.sidebar && t.push({
116
+ ...e,
117
+ order: e.sidebar.order ?? 100
118
+ });
119
+ return t.sort((e, n) => e.order - n.order);
120
+ },
121
+ allCommands: () => {
31
122
  const t = [];
32
- for (const r of s().values())
33
- r.category === e && t.push(r);
123
+ for (const e of s().values())
124
+ e.commands && t.push(...e.commands);
34
125
  return t;
35
- }
126
+ },
127
+ statusBarItems: () => {
128
+ const t = [];
129
+ for (const e of s().values())
130
+ e.statusBar && t.push(...e.statusBar);
131
+ return t;
132
+ },
133
+ getComponent: (t) => s().get(t)
36
134
  };
37
135
  }
38
136
  export {
39
- f as WidgetRegistryProvider,
40
- c as createWidgetRegistry,
41
- m as useWidgetRegistry
137
+ K as ComponentRegistryProvider,
138
+ k as createComponentRegistry,
139
+ J as useComponentContextFactory,
140
+ O as useComponentRegistry
42
141
  };