@beeblock/svelar 0.4.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 (207) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +110 -0
  3. package/dist/actions/index.d.ts +101 -0
  4. package/dist/actions/index.js +1 -0
  5. package/dist/api-keys/index.d.ts +58 -0
  6. package/dist/api-keys/index.js +1 -0
  7. package/dist/audit/index.d.ts +52 -0
  8. package/dist/audit/index.js +1 -0
  9. package/dist/auth/Auth.d.ts +283 -0
  10. package/dist/auth/Gate.d.ts +166 -0
  11. package/dist/auth/index.d.ts +2 -0
  12. package/dist/auth/index.js +80 -0
  13. package/dist/broadcasting/client.d.ts +195 -0
  14. package/dist/broadcasting/client.js +1 -0
  15. package/dist/broadcasting/index.d.ts +318 -0
  16. package/dist/broadcasting/index.js +20 -0
  17. package/dist/cache/index.d.ts +77 -0
  18. package/dist/cache/index.js +1 -0
  19. package/dist/cli/Cli.d.ts +23 -0
  20. package/dist/cli/Command.d.ts +36 -0
  21. package/dist/cli/bin.d.ts +8 -0
  22. package/dist/cli/bin.js +5856 -0
  23. package/dist/cli/commands/KeyGenerateCommand.d.ts +16 -0
  24. package/dist/cli/commands/MakeActionCommand.d.ts +15 -0
  25. package/dist/cli/commands/MakeBroadcastingCommand.d.ts +29 -0
  26. package/dist/cli/commands/MakeChannelCommand.d.ts +18 -0
  27. package/dist/cli/commands/MakeCommandCommand.d.ts +16 -0
  28. package/dist/cli/commands/MakeConfigCommand.d.ts +13 -0
  29. package/dist/cli/commands/MakeControllerCommand.d.ts +28 -0
  30. package/dist/cli/commands/MakeDashboardCommand.d.ts +34 -0
  31. package/dist/cli/commands/MakeDockerCommand.d.ts +32 -0
  32. package/dist/cli/commands/MakeEventCommand.d.ts +11 -0
  33. package/dist/cli/commands/MakeJobCommand.d.ts +11 -0
  34. package/dist/cli/commands/MakeListenerCommand.d.ts +16 -0
  35. package/dist/cli/commands/MakeMiddlewareCommand.d.ts +11 -0
  36. package/dist/cli/commands/MakeMigrationCommand.d.ts +17 -0
  37. package/dist/cli/commands/MakeModelCommand.d.ts +25 -0
  38. package/dist/cli/commands/MakeObserverCommand.d.ts +23 -0
  39. package/dist/cli/commands/MakePluginCommand.d.ts +11 -0
  40. package/dist/cli/commands/MakeProviderCommand.d.ts +11 -0
  41. package/dist/cli/commands/MakeRepositoryCommand.d.ts +22 -0
  42. package/dist/cli/commands/MakeRequestCommand.d.ts +15 -0
  43. package/dist/cli/commands/MakeResourceCommand.d.ts +30 -0
  44. package/dist/cli/commands/MakeRouteCommand.d.ts +42 -0
  45. package/dist/cli/commands/MakeSchemaCommand.d.ts +20 -0
  46. package/dist/cli/commands/MakeSeederCommand.d.ts +11 -0
  47. package/dist/cli/commands/MakeServiceCommand.d.ts +28 -0
  48. package/dist/cli/commands/MakeTaskCommand.d.ts +12 -0
  49. package/dist/cli/commands/MigrateCommand.d.ts +26 -0
  50. package/dist/cli/commands/NewCommand.d.ts +21 -0
  51. package/dist/cli/commands/NewCommandTemplates.d.ts +123 -0
  52. package/dist/cli/commands/PluginInstallCommand.d.ts +16 -0
  53. package/dist/cli/commands/PluginListCommand.d.ts +11 -0
  54. package/dist/cli/commands/PluginPublishCommand.d.ts +22 -0
  55. package/dist/cli/commands/QueueFailedCommand.d.ts +9 -0
  56. package/dist/cli/commands/QueueFlushCommand.d.ts +9 -0
  57. package/dist/cli/commands/QueueRetryCommand.d.ts +16 -0
  58. package/dist/cli/commands/QueueWorkCommand.d.ts +25 -0
  59. package/dist/cli/commands/RoutesListCommand.d.ts +30 -0
  60. package/dist/cli/commands/ScheduleRunCommand.d.ts +15 -0
  61. package/dist/cli/commands/SeedCommand.d.ts +14 -0
  62. package/dist/cli/commands/TinkerCommand.d.ts +10 -0
  63. package/dist/cli/index.d.ts +36 -0
  64. package/dist/cli/index.js +1973 -0
  65. package/dist/cli/ts-resolve-hook.mjs +74 -0
  66. package/dist/cli/ts-resolver.mjs +8 -0
  67. package/dist/config/Config.d.ts +65 -0
  68. package/dist/config/index.d.ts +1 -0
  69. package/dist/config/index.js +1 -0
  70. package/dist/container/Application.d.ts +33 -0
  71. package/dist/container/Container.d.ts +70 -0
  72. package/dist/container/ServiceProvider.d.ts +21 -0
  73. package/dist/container/index.d.ts +3 -0
  74. package/dist/container/index.js +1 -0
  75. package/dist/dashboard/index.d.ts +123 -0
  76. package/dist/dashboard/index.js +5 -0
  77. package/dist/database/Connection.d.ts +80 -0
  78. package/dist/database/Migration.d.ts +76 -0
  79. package/dist/database/SchemaBuilder.d.ts +91 -0
  80. package/dist/database/Seeder.d.ts +9 -0
  81. package/dist/database/index.d.ts +4 -0
  82. package/dist/database/index.js +4 -0
  83. package/dist/email-templates/index.d.ts +51 -0
  84. package/dist/email-templates/index.js +57 -0
  85. package/dist/errors/Handler.d.ts +100 -0
  86. package/dist/errors/index.d.ts +1 -0
  87. package/dist/errors/index.js +5 -0
  88. package/dist/events/EventServiceProvider.d.ts +82 -0
  89. package/dist/events/Listener.d.ts +28 -0
  90. package/dist/events/index.d.ts +80 -0
  91. package/dist/events/index.js +1 -0
  92. package/dist/excel/index.d.ts +154 -0
  93. package/dist/excel/index.js +1 -0
  94. package/dist/feature-flags/index.d.ts +158 -0
  95. package/dist/feature-flags/index.js +59 -0
  96. package/dist/forms/index.d.ts +81 -0
  97. package/dist/forms/index.js +1 -0
  98. package/dist/hashing/Hash.d.ts +51 -0
  99. package/dist/hashing/index.d.ts +1 -0
  100. package/dist/hashing/index.js +1 -0
  101. package/dist/hooks/index.d.ts +135 -0
  102. package/dist/hooks/index.js +5 -0
  103. package/dist/http/index.d.ts +201 -0
  104. package/dist/http/index.js +2 -0
  105. package/dist/i18n/index.d.ts +81 -0
  106. package/dist/i18n/index.js +1 -0
  107. package/dist/index.d.ts +54 -0
  108. package/dist/index.js +127 -0
  109. package/dist/logging/LogViewer.d.ts +95 -0
  110. package/dist/logging/LogViewer.js +1 -0
  111. package/dist/logging/index.d.ts +83 -0
  112. package/dist/logging/index.js +3 -0
  113. package/dist/mail/index.d.ts +149 -0
  114. package/dist/mail/index.js +1 -0
  115. package/dist/middleware/Middleware.d.ts +208 -0
  116. package/dist/middleware/index.d.ts +1 -0
  117. package/dist/middleware/index.js +1 -0
  118. package/dist/notifications/index.d.ts +85 -0
  119. package/dist/notifications/index.js +2 -0
  120. package/dist/orm/Model.d.ts +123 -0
  121. package/dist/orm/Observer.d.ts +34 -0
  122. package/dist/orm/QueryBuilder.d.ts +119 -0
  123. package/dist/orm/Relationship.d.ts +58 -0
  124. package/dist/orm/index.d.ts +4 -0
  125. package/dist/orm/index.js +1 -0
  126. package/dist/pagination/index.d.ts +8 -0
  127. package/dist/pagination/index.js +0 -0
  128. package/dist/pdf/GeneratePdfJob.d.ts +99 -0
  129. package/dist/pdf/GeneratePdfJob.js +41 -0
  130. package/dist/pdf/index.d.ts +328 -0
  131. package/dist/pdf/index.js +41 -0
  132. package/dist/permissions/index.d.ts +161 -0
  133. package/dist/permissions/index.js +60 -0
  134. package/dist/plugins/BootstrapPlugins.d.ts +11 -0
  135. package/dist/plugins/PluginInstaller.d.ts +30 -0
  136. package/dist/plugins/PluginInstaller.js +1 -0
  137. package/dist/plugins/PluginPublisher.d.ts +32 -0
  138. package/dist/plugins/PluginPublisher.js +1 -0
  139. package/dist/plugins/PluginRegistry.d.ts +55 -0
  140. package/dist/plugins/PluginRegistry.js +1 -0
  141. package/dist/plugins/index.d.ts +206 -0
  142. package/dist/plugins/index.js +1 -0
  143. package/dist/queue/JobMonitor.d.ts +109 -0
  144. package/dist/queue/JobMonitor.js +5 -0
  145. package/dist/queue/index.d.ts +279 -0
  146. package/dist/queue/index.js +5 -0
  147. package/dist/repositories/index.d.ts +147 -0
  148. package/dist/repositories/index.js +1 -0
  149. package/dist/routing/Controller.d.ts +115 -0
  150. package/dist/routing/FormRequest.d.ts +94 -0
  151. package/dist/routing/Resource.d.ts +213 -0
  152. package/dist/routing/Response.d.ts +138 -0
  153. package/dist/routing/index.d.ts +4 -0
  154. package/dist/routing/index.js +5 -0
  155. package/dist/scheduler/ScheduleMonitor.d.ts +141 -0
  156. package/dist/scheduler/ScheduleMonitor.js +1 -0
  157. package/dist/scheduler/SchedulerLock.d.ts +33 -0
  158. package/dist/scheduler/index.d.ts +208 -0
  159. package/dist/scheduler/index.js +34 -0
  160. package/dist/services/index.d.ts +79 -0
  161. package/dist/services/index.js +1 -0
  162. package/dist/session/Session.d.ts +166 -0
  163. package/dist/session/index.d.ts +1 -0
  164. package/dist/session/index.js +16 -0
  165. package/dist/storage/index.d.ts +154 -0
  166. package/dist/storage/index.js +1 -0
  167. package/dist/support/Pipeline.d.ts +65 -0
  168. package/dist/support/date.d.ts +136 -0
  169. package/dist/support/date.js +1 -0
  170. package/dist/support/index.d.ts +8 -0
  171. package/dist/support/index.js +1 -0
  172. package/dist/support/singleton.d.ts +10 -0
  173. package/dist/support/uuid.d.ts +40 -0
  174. package/dist/teams/index.d.ts +91 -0
  175. package/dist/teams/index.js +78 -0
  176. package/dist/uploads/index.d.ts +63 -0
  177. package/dist/uploads/index.js +2 -0
  178. package/dist/validation/index.d.ts +46 -0
  179. package/dist/validation/index.js +1 -0
  180. package/dist/webhooks/index.d.ts +66 -0
  181. package/dist/webhooks/index.js +1 -0
  182. package/package.json +338 -0
  183. package/src/i18n/LanguageSwitcher.svelte +47 -0
  184. package/src/i18n/index.ts +113 -0
  185. package/src/ui/Alert.svelte +22 -0
  186. package/src/ui/Avatar.svelte +18 -0
  187. package/src/ui/AvatarFallback.svelte +18 -0
  188. package/src/ui/AvatarImage.svelte +12 -0
  189. package/src/ui/Badge.svelte +27 -0
  190. package/src/ui/Button.svelte +51 -0
  191. package/src/ui/Card.svelte +15 -0
  192. package/src/ui/CardContent.svelte +15 -0
  193. package/src/ui/CardDescription.svelte +15 -0
  194. package/src/ui/CardFooter.svelte +15 -0
  195. package/src/ui/CardHeader.svelte +15 -0
  196. package/src/ui/CardTitle.svelte +15 -0
  197. package/src/ui/Icon.svelte +81 -0
  198. package/src/ui/Input.svelte +40 -0
  199. package/src/ui/Label.svelte +20 -0
  200. package/src/ui/Separator.svelte +10 -0
  201. package/src/ui/Tabs.svelte +23 -0
  202. package/src/ui/TabsContent.svelte +27 -0
  203. package/src/ui/TabsList.svelte +19 -0
  204. package/src/ui/TabsTrigger.svelte +28 -0
  205. package/src/ui/Toaster.svelte +279 -0
  206. package/src/ui/index.ts +31 -0
  207. package/src/ui/toast.ts +212 -0
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Svelar Toast Store & API
3
+ *
4
+ * Reactive toast notification system using a callback-based store
5
+ * that works across package boundaries (no Svelte compiler needed).
6
+ *
7
+ * Import { toast } anywhere to show notifications.
8
+ * Import { Toaster } in your layout to render them.
9
+ *
10
+ * @module svelar/ui
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { toast } from 'svelar/ui';
15
+ *
16
+ * toast('Hello');
17
+ * toast.success('Saved!');
18
+ * toast.error('Failed', { description: 'Network error' });
19
+ * toast.warning('Careful', { duration: 8000 });
20
+ * toast.info('Tip', { action: { label: 'Undo', onClick: () => undo() } });
21
+ * toast.dismiss(id);
22
+ * toast.dismissAll();
23
+ * ```
24
+ */
25
+
26
+ export type ToastVariant = 'default' | 'success' | 'error' | 'warning' | 'info';
27
+
28
+ export type ToastState = 'entering' | 'visible' | 'exiting';
29
+
30
+ export interface ToastItem {
31
+ id: string;
32
+ variant: ToastVariant;
33
+ title: string;
34
+ description?: string;
35
+ duration: number;
36
+ dismissible: boolean;
37
+ action?: { label: string; onClick: () => void };
38
+ createdAt: number;
39
+ state: ToastState;
40
+ pausedAt?: number;
41
+ remaining: number;
42
+ timeoutId?: ReturnType<typeof setTimeout>;
43
+ }
44
+
45
+ export interface ToastOptions {
46
+ description?: string;
47
+ /** Auto-dismiss in ms. 0 = persistent. Default: 5000 (8000 for errors) */
48
+ duration?: number;
49
+ /** Show close button. Default: true */
50
+ dismissible?: boolean;
51
+ /** Action button */
52
+ action?: { label: string; onClick: () => void };
53
+ }
54
+
55
+ // ── Callback-based Store ────────────────────────────────────
56
+
57
+ let _toasts: ToastItem[] = [];
58
+ let _counter = 0;
59
+ let _listeners: Set<() => void> = new Set();
60
+
61
+ const ENTER_DURATION = 300;
62
+ const EXIT_DURATION = 200;
63
+
64
+ function notify() {
65
+ for (const listener of _listeners) {
66
+ listener();
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Subscribe to toast state changes. Returns an unsubscribe function.
72
+ */
73
+ export function subscribe(listener: () => void): () => void {
74
+ _listeners.add(listener);
75
+ return () => _listeners.delete(listener);
76
+ }
77
+
78
+ export function getToasts(): ToastItem[] {
79
+ return _toasts;
80
+ }
81
+
82
+ function scheduleAutoDismiss(item: ToastItem) {
83
+ if (item.duration <= 0) return;
84
+
85
+ item.timeoutId = setTimeout(() => {
86
+ dismiss(item.id);
87
+ }, item.remaining);
88
+ }
89
+
90
+ function addToast(variant: ToastVariant, title: string, options: ToastOptions = {}): string {
91
+ const id = `toast-${++_counter}-${Date.now()}`;
92
+ const duration = options.duration ?? (variant === 'error' ? 8000 : 5000);
93
+
94
+ const item: ToastItem = {
95
+ id,
96
+ variant,
97
+ title,
98
+ description: options.description,
99
+ duration,
100
+ dismissible: options.dismissible ?? true,
101
+ action: options.action,
102
+ createdAt: Date.now(),
103
+ state: 'entering',
104
+ remaining: duration,
105
+ };
106
+
107
+ _toasts = [..._toasts, item];
108
+ notify();
109
+
110
+ // Transition to visible after enter animation
111
+ setTimeout(() => {
112
+ _toasts = _toasts.map((t) => (t.id === id ? { ...t, state: 'visible' as ToastState } : t));
113
+ notify();
114
+ }, ENTER_DURATION);
115
+
116
+ // Start auto-dismiss timer
117
+ scheduleAutoDismiss(item);
118
+
119
+ return id;
120
+ }
121
+
122
+ export function dismiss(id: string) {
123
+ const item = _toasts.find((t) => t.id === id);
124
+ if (!item || item.state === 'exiting') return;
125
+
126
+ if (item.timeoutId) clearTimeout(item.timeoutId);
127
+
128
+ _toasts = _toasts.map((t) => (t.id === id ? { ...t, state: 'exiting' as ToastState } : t));
129
+ notify();
130
+
131
+ setTimeout(() => {
132
+ _toasts = _toasts.filter((t) => t.id !== id);
133
+ notify();
134
+ }, EXIT_DURATION);
135
+ }
136
+
137
+ export function dismissAll() {
138
+ _toasts = _toasts.map((t) => {
139
+ if (t.timeoutId) clearTimeout(t.timeoutId);
140
+ return { ...t, state: 'exiting' as ToastState };
141
+ });
142
+ notify();
143
+
144
+ setTimeout(() => {
145
+ _toasts = [];
146
+ notify();
147
+ }, EXIT_DURATION);
148
+ }
149
+
150
+ export function pauseToast(id: string) {
151
+ _toasts = _toasts.map((t) => {
152
+ if (t.id !== id || t.duration <= 0) return t;
153
+ if (t.timeoutId) clearTimeout(t.timeoutId);
154
+ const elapsed = Date.now() - t.createdAt - (t.duration - t.remaining);
155
+ return { ...t, pausedAt: Date.now(), remaining: Math.max(t.remaining - elapsed, 1000), timeoutId: undefined };
156
+ });
157
+ notify();
158
+ }
159
+
160
+ export function resumeToast(id: string) {
161
+ const item = _toasts.find((t) => t.id === id);
162
+ if (!item || !item.pausedAt || item.duration <= 0) return;
163
+
164
+ _toasts = _toasts.map((t) => {
165
+ if (t.id !== id) return t;
166
+ return { ...t, pausedAt: undefined };
167
+ });
168
+ notify();
169
+
170
+ scheduleAutoDismiss(item);
171
+ }
172
+
173
+ // ── Public API ────────────────────────────────────────────
174
+
175
+ function toastFn(title: string, options?: ToastOptions): string {
176
+ return addToast('default', title, options);
177
+ }
178
+
179
+ toastFn.success = (title: string, options?: ToastOptions) => addToast('success', title, options);
180
+ toastFn.error = (title: string, options?: ToastOptions) => addToast('error', title, options);
181
+ toastFn.warning = (title: string, options?: ToastOptions) => addToast('warning', title, options);
182
+ toastFn.info = (title: string, options?: ToastOptions) => addToast('info', title, options);
183
+ toastFn.dismiss = dismiss;
184
+ toastFn.dismissAll = dismissAll;
185
+
186
+ toastFn.promise = <T>(
187
+ promise: Promise<T>,
188
+ messages: {
189
+ loading: string;
190
+ success: string | ((data: T) => string);
191
+ error: string | ((err: any) => string);
192
+ },
193
+ options?: ToastOptions,
194
+ ): Promise<T> => {
195
+ const id = addToast('info', messages.loading, { ...options, duration: 0 });
196
+
197
+ promise
198
+ .then((data) => {
199
+ dismiss(id);
200
+ const msg = typeof messages.success === 'function' ? messages.success(data) : messages.success;
201
+ addToast('success', msg, options);
202
+ })
203
+ .catch((err) => {
204
+ dismiss(id);
205
+ const msg = typeof messages.error === 'function' ? messages.error(err) : messages.error;
206
+ addToast('error', msg, options);
207
+ });
208
+
209
+ return promise;
210
+ };
211
+
212
+ export const toast = toastFn;