qdadm 0.29.0 → 0.31.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 (49) hide show
  1. package/package.json +11 -2
  2. package/src/components/forms/FormPage.vue +1 -1
  3. package/src/components/index.js +5 -3
  4. package/src/components/layout/AppLayout.vue +13 -1
  5. package/src/components/layout/Zone.vue +40 -23
  6. package/src/composables/index.js +2 -1
  7. package/src/composables/useAuth.js +43 -4
  8. package/src/composables/useCurrentEntity.js +44 -0
  9. package/src/composables/useFormPageBuilder.js +3 -3
  10. package/src/composables/useNavContext.js +24 -8
  11. package/src/composables/useSSEBridge.js +118 -0
  12. package/src/debug/AuthCollector.js +254 -0
  13. package/src/debug/Collector.js +235 -0
  14. package/src/debug/DebugBridge.js +163 -0
  15. package/src/debug/DebugModule.js +215 -0
  16. package/src/debug/EntitiesCollector.js +376 -0
  17. package/src/debug/ErrorCollector.js +66 -0
  18. package/src/debug/LocalStorageAdapter.js +150 -0
  19. package/src/debug/SignalCollector.js +87 -0
  20. package/src/debug/ToastCollector.js +82 -0
  21. package/src/debug/ZonesCollector.js +300 -0
  22. package/src/debug/components/DebugBar.vue +1232 -0
  23. package/src/debug/components/ObjectTree.vue +194 -0
  24. package/src/debug/components/index.js +8 -0
  25. package/src/debug/components/panels/AuthPanel.vue +103 -0
  26. package/src/debug/components/panels/EntitiesPanel.vue +616 -0
  27. package/src/debug/components/panels/EntriesPanel.vue +188 -0
  28. package/src/debug/components/panels/ToastsPanel.vue +112 -0
  29. package/src/debug/components/panels/ZonesPanel.vue +232 -0
  30. package/src/debug/components/panels/index.js +8 -0
  31. package/src/debug/index.js +31 -0
  32. package/src/editors/index.js +12 -0
  33. package/src/entity/EntityManager.js +142 -20
  34. package/src/entity/storage/MockApiStorage.js +17 -1
  35. package/src/entity/storage/index.js +9 -2
  36. package/src/gen/index.js +3 -0
  37. package/src/index.js +7 -0
  38. package/src/kernel/Kernel.js +661 -48
  39. package/src/kernel/KernelContext.js +385 -0
  40. package/src/kernel/Module.js +111 -0
  41. package/src/kernel/ModuleLoader.js +573 -0
  42. package/src/kernel/SSEBridge.js +354 -0
  43. package/src/kernel/SignalBus.js +10 -7
  44. package/src/kernel/index.js +19 -0
  45. package/src/toast/ToastBridgeModule.js +70 -0
  46. package/src/toast/ToastListener.vue +47 -0
  47. package/src/toast/index.js +15 -0
  48. package/src/toast/useSignalToast.js +113 -0
  49. package/src/composables/useSSE.js +0 -212
@@ -1,212 +0,0 @@
1
- /**
2
- * useSSE - Server-Sent Events composable
3
- *
4
- * Manages EventSource connection with automatic reconnection and cleanup.
5
- * Uses authAdapter.getToken() for authentication if available.
6
- *
7
- * Usage:
8
- * const { connected, error, reconnect, close } = useSSE('/api/events', {
9
- * eventHandlers: {
10
- * 'bot:status': (data) => console.log('Bot status:', data),
11
- * 'task:complete': (data) => handleTaskComplete(data)
12
- * }
13
- * })
14
- *
15
- * Options:
16
- * - eventHandlers: Object mapping event names to handler functions
17
- * - reconnectDelay: Delay in ms before reconnecting (default: 5000)
18
- * - autoConnect: Start connection immediately (default: true)
19
- * - withCredentials: Include credentials in request (default: false)
20
- * - tokenParam: Query param name for token (default: 'token')
21
- * - getToken: Custom token getter function (default: uses authAdapter)
22
- */
23
-
24
- import { ref, inject, onUnmounted, onMounted } from 'vue'
25
-
26
- export function useSSE(url, options = {}) {
27
- const {
28
- eventHandlers = {},
29
- reconnectDelay = 5000,
30
- autoConnect = true,
31
- withCredentials = false,
32
- tokenParam = 'token',
33
- getToken: customGetToken = null
34
- } = options
35
-
36
- const authAdapter = inject('authAdapter', null)
37
-
38
- const connected = ref(false)
39
- const error = ref(null)
40
- const reconnecting = ref(false)
41
-
42
- let eventSource = null
43
- let reconnectTimer = null
44
-
45
- /**
46
- * Get authentication token
47
- */
48
- const getToken = () => {
49
- // Custom getter takes precedence
50
- if (customGetToken) {
51
- return customGetToken()
52
- }
53
- // Try authAdapter
54
- if (authAdapter?.getToken) {
55
- return authAdapter.getToken()
56
- }
57
- // Fallback to localStorage
58
- return localStorage.getItem('auth_token')
59
- }
60
-
61
- /**
62
- * Build SSE URL with token
63
- */
64
- const buildUrl = () => {
65
- const token = getToken()
66
- const sseUrl = new URL(url, window.location.origin)
67
-
68
- if (token && tokenParam) {
69
- sseUrl.searchParams.set(tokenParam, token)
70
- }
71
-
72
- return sseUrl.toString()
73
- }
74
-
75
- /**
76
- * Connect to SSE endpoint
77
- */
78
- const connect = () => {
79
- // Clean up existing connection
80
- if (eventSource) {
81
- eventSource.close()
82
- eventSource = null
83
- }
84
-
85
- // Clear any pending reconnect
86
- if (reconnectTimer) {
87
- clearTimeout(reconnectTimer)
88
- reconnectTimer = null
89
- }
90
-
91
- try {
92
- const sseUrl = buildUrl()
93
-
94
- eventSource = new EventSource(sseUrl, {
95
- withCredentials
96
- })
97
-
98
- eventSource.onopen = () => {
99
- connected.value = true
100
- error.value = null
101
- reconnecting.value = false
102
- }
103
-
104
- eventSource.onerror = (err) => {
105
- connected.value = false
106
- error.value = 'Connection error'
107
-
108
- // Close broken connection
109
- if (eventSource) {
110
- eventSource.close()
111
- eventSource = null
112
- }
113
-
114
- // Schedule reconnect
115
- if (reconnectDelay > 0) {
116
- reconnecting.value = true
117
- reconnectTimer = setTimeout(() => {
118
- if (!connected.value) {
119
- connect()
120
- }
121
- }, reconnectDelay)
122
- }
123
- }
124
-
125
- // Register custom event handlers
126
- for (const [eventName, handler] of Object.entries(eventHandlers)) {
127
- if (eventName === 'message') continue // Handle below
128
-
129
- eventSource.addEventListener(eventName, (event) => {
130
- try {
131
- const data = JSON.parse(event.data)
132
- handler(data, event)
133
- } catch (err) {
134
- console.error(`[useSSE] Error parsing event "${eventName}":`, err)
135
- // Call handler with raw data on parse error
136
- handler(event.data, event)
137
- }
138
- })
139
- }
140
-
141
- // Handle generic message events
142
- eventSource.onmessage = (event) => {
143
- if (!eventHandlers.message) return
144
-
145
- try {
146
- const data = JSON.parse(event.data)
147
- eventHandlers.message(data, event)
148
- } catch (err) {
149
- console.error('[useSSE] Error parsing message:', err)
150
- eventHandlers.message(event.data, event)
151
- }
152
- }
153
-
154
- } catch (err) {
155
- error.value = err.message
156
- connected.value = false
157
- }
158
- }
159
-
160
- /**
161
- * Close connection
162
- */
163
- const close = () => {
164
- if (reconnectTimer) {
165
- clearTimeout(reconnectTimer)
166
- reconnectTimer = null
167
- }
168
-
169
- if (eventSource) {
170
- eventSource.close()
171
- eventSource = null
172
- }
173
-
174
- connected.value = false
175
- reconnecting.value = false
176
- }
177
-
178
- /**
179
- * Reconnect (close and connect)
180
- */
181
- const reconnect = () => {
182
- close()
183
- connect()
184
- }
185
-
186
- // Auto-connect on mount if enabled
187
- onMounted(() => {
188
- if (autoConnect) {
189
- connect()
190
- }
191
- })
192
-
193
- // Cleanup on unmount
194
- onUnmounted(() => {
195
- close()
196
- })
197
-
198
- return {
199
- /** Reactive connection state */
200
- connected,
201
- /** Reactive error message */
202
- error,
203
- /** Reactive reconnecting state */
204
- reconnecting,
205
- /** Manually connect */
206
- connect,
207
- /** Close connection */
208
- close,
209
- /** Reconnect (close + connect) */
210
- reconnect
211
- }
212
- }