@djangocfg/ui-core 2.1.167 → 2.1.169

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/README.md CHANGED
@@ -193,9 +193,24 @@ import '@djangocfg/ui-core/styles/globals';
193
193
  | `@djangocfg/ui-core/hooks` | Hooks only |
194
194
  | `@djangocfg/ui-core/lib` | Utilities (cn, etc.) |
195
195
  | `@djangocfg/ui-core/lib/dialog-service` | Dialog service |
196
+ | `@djangocfg/ui-core/utils` | Runtime utilities (emitRuntimeError) |
196
197
  | `@djangocfg/ui-core/styles` | CSS |
197
198
  | `@djangocfg/ui-core/styles/palette` | Theme palette hooks & utilities |
198
199
 
200
+ ## Runtime Error Emitter
201
+
202
+ Emit runtime errors as events (caught by ErrorTrackingProvider in layouts):
203
+
204
+ ```tsx
205
+ import { emitRuntimeError } from '@djangocfg/ui-core/utils';
206
+
207
+ try {
208
+ doSomething();
209
+ } catch (error) {
210
+ emitRuntimeError('MyComponent', 'Operation failed', error, { extra: 'context' });
211
+ }
212
+ ```
213
+
199
214
  ## What's NOT included (use ui-nextjs)
200
215
 
201
216
  These features require Next.js or browser storage APIs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ui-core",
3
- "version": "2.1.167",
3
+ "version": "2.1.169",
4
4
  "description": "Pure React UI component library without Next.js dependencies - for Electron, Vite, CRA apps",
5
5
  "keywords": [
6
6
  "ui-components",
@@ -53,6 +53,11 @@
53
53
  "import": "./src/lib/dialog-service/index.ts",
54
54
  "require": "./src/lib/dialog-service/index.ts"
55
55
  },
56
+ "./utils": {
57
+ "types": "./src/utils/index.ts",
58
+ "import": "./src/utils/index.ts",
59
+ "require": "./src/utils/index.ts"
60
+ },
56
61
  "./styles": "./src/styles/index.css",
57
62
  "./styles/globals": "./src/styles/globals.css",
58
63
  "./styles/theme": "./src/styles/theme.css",
@@ -76,7 +81,7 @@
76
81
  "playground": "playground dev"
77
82
  },
78
83
  "peerDependencies": {
79
- "@djangocfg/i18n": "^2.1.167",
84
+ "@djangocfg/i18n": "^2.1.169",
80
85
  "react-device-detect": "^2.2.3",
81
86
  "consola": "^3.4.2",
82
87
  "lucide-react": "^0.545.0",
@@ -138,9 +143,9 @@
138
143
  "vaul": "1.1.2"
139
144
  },
140
145
  "devDependencies": {
141
- "@djangocfg/i18n": "^2.1.167",
146
+ "@djangocfg/i18n": "^2.1.169",
142
147
  "@djangocfg/playground": "workspace:*",
143
- "@djangocfg/typescript-config": "^2.1.167",
148
+ "@djangocfg/typescript-config": "^2.1.169",
144
149
  "@types/node": "^24.7.2",
145
150
  "@types/react": "^19.1.0",
146
151
  "@types/react-dom": "^19.1.0",
@@ -0,0 +1,10 @@
1
+ export {
2
+ LazyWrapper,
3
+ DefaultLoader,
4
+ InlineLoader,
5
+ FullScreenLoader,
6
+ createLazyComponent,
7
+ createLazyNamedComponent,
8
+ } from './LazyComponent';
9
+ export type { LazyWrapperProps } from './LazyComponent';
10
+ ../utils/runtime-errors
@@ -1,9 +1 @@
1
- export {
2
- LazyWrapper,
3
- DefaultLoader,
4
- InlineLoader,
5
- FullScreenLoader,
6
- createLazyComponent,
7
- createLazyNamedComponent,
8
- } from './LazyComponent';
9
- export type { LazyWrapperProps } from './LazyComponent';
1
+ export { emitRuntimeError, RUNTIME_ERROR_EVENT } from './runtime-errors';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Runtime Error Emitter
3
+ *
4
+ * Emits runtime errors as CustomEvents that can be caught by ErrorTrackingProvider.
5
+ * This is a lightweight utility with no dependencies, suitable for use in any package.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { emitRuntimeError } from '@djangocfg/ui-core/utils';
10
+ *
11
+ * try {
12
+ * doSomething();
13
+ * } catch (error) {
14
+ * emitRuntimeError('MyComponent', 'Failed to do something', error, { extra: 'context' });
15
+ * }
16
+ * ```
17
+ */
18
+
19
+ /** Event name for runtime errors - must match ERROR_EVENTS.RUNTIME in layouts */
20
+ export const RUNTIME_ERROR_EVENT = 'runtime-error';
21
+
22
+ /**
23
+ * Emit a runtime error event
24
+ *
25
+ * @param source - Error source identifier (e.g., 'Tour', 'Form', 'API')
26
+ * @param message - Human-readable error message
27
+ * @param error - Original Error object (optional)
28
+ * @param context - Additional context data (optional)
29
+ */
30
+ export function emitRuntimeError(
31
+ source: string,
32
+ message: string,
33
+ error?: Error,
34
+ context?: Record<string, unknown>
35
+ ): void {
36
+ if (typeof window === 'undefined') return;
37
+
38
+ const event = new CustomEvent(RUNTIME_ERROR_EVENT, {
39
+ detail: {
40
+ source,
41
+ message,
42
+ error,
43
+ context,
44
+ timestamp: new Date(),
45
+ },
46
+ });
47
+
48
+ window.dispatchEvent(event);
49
+ }
File without changes