@lightworkai.official/debug-capture-angular 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.
package/src/index.ts ADDED
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Angular bindings for @lightworkai.official/debug-capture.
3
+ *
4
+ * Standalone providers + one standalone component, so this works in an
5
+ * `app.config.ts` and in an NgModule without shipping two of everything.
6
+ *
7
+ * Note what a consumer does NOT have to do: no `CUSTOM_ELEMENTS_SCHEMA`. The
8
+ * reporter is a custom element, but it is created imperatively by
9
+ * `installDebugCapture` and never appears in a template, so Angular's compiler
10
+ * never sees an unknown tag to complain about. That awkwardness is the
11
+ * wrapper's to absorb, which is most of the reason the wrapper exists.
12
+ */
13
+ import {
14
+ APP_INITIALIZER,
15
+ Component,
16
+ Input,
17
+ type EnvironmentProviders,
18
+ makeEnvironmentProviders,
19
+ } from "@angular/core";
20
+ import {
21
+ configureDebugCapture,
22
+ installDebugCapture,
23
+ launch,
24
+ setErroredQueriesSource,
25
+ type DebugCaptureConfig,
26
+ type ErroredQuery,
27
+ } from "@lightworkai.official/debug-capture";
28
+
29
+ export interface DebugCaptureProviderOptions extends DebugCaptureConfig {
30
+ /** Failed queries from the app's data layer, if it has one. */
31
+ errorQueries?: () => ErroredQuery[];
32
+ /** Mount the built-in reporter UI. Off if the host renders its own. */
33
+ ui?: boolean;
34
+ }
35
+
36
+ /**
37
+ * Configure and arm in one call, from `app.config.ts`:
38
+ *
39
+ * providers: [provideDebugCapture({ host, realmKey, app: {...} })]
40
+ *
41
+ * Runs as an APP_INITIALIZER so the buffers are recording before the first
42
+ * route renders. Capture that starts late is capture that misses the navigation
43
+ * the user is about to complain about.
44
+ */
45
+ export function provideDebugCapture(options: DebugCaptureProviderOptions): EnvironmentProviders {
46
+ const { errorQueries, ui, ...config } = options;
47
+ return makeEnvironmentProviders([
48
+ {
49
+ provide: APP_INITIALIZER,
50
+ multi: true,
51
+ useValue: () => {
52
+ configureDebugCapture(config);
53
+ if (errorQueries) setErroredQueriesSource(errorQueries);
54
+ installDebugCapture({ ui });
55
+ },
56
+ },
57
+ ]);
58
+ }
59
+
60
+ /**
61
+ * The button that opens the reporter.
62
+ *
63
+ * `launch` runs straight out of the click: screen capture is gated on a user
64
+ * gesture, and anything awaited in front of it loses the gesture. That rules
65
+ * out routing this through a service that returns a Promise.
66
+ */
67
+ @Component({
68
+ selector: "lw-report-problem-button",
69
+ standalone: true,
70
+ template: `
71
+ <button type="button" [attr.aria-label]="label" [attr.title]="label" (click)="report()">
72
+ <ng-content>
73
+ <svg
74
+ width="20"
75
+ height="20"
76
+ viewBox="0 0 24 24"
77
+ fill="none"
78
+ stroke="currentColor"
79
+ stroke-width="1.8"
80
+ stroke-linecap="round"
81
+ stroke-linejoin="round"
82
+ aria-hidden="true"
83
+ >
84
+ <path d="M8 2l1.9 1.9M16 2l-1.9 1.9" />
85
+ <rect x="8" y="6" width="8" height="14" rx="4" />
86
+ <path d="M3 13h5M16 13h5M4 8l3 2M20 8l-3 2M4 18l3-2M20 18l-3-2" />
87
+ </svg>
88
+ </ng-content>
89
+ </button>
90
+ `,
91
+ styles: [":host { display: inline-flex; }"],
92
+ })
93
+ export class ReportProblemButtonComponent {
94
+ @Input() label = "รายงานปัญหา";
95
+
96
+ report(): void {
97
+ launch({ type: "manual" });
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Real standalone components now, not a web element mounted from a wrapper.
103
+ * The core package holds the logic every framework shares — the ingest client,
104
+ * the sanitiser, the status maps, the comparators, the capture buffers — and
105
+ * each framework package renders it the way that framework renders things.
106
+ *
107
+ * Import the stylesheet once, in `angular.json` or a global stylesheet:
108
+ *
109
+ * @import "@lightworkai.official/debug-capture/style.css";
110
+ */
111
+ export { MyTicketsPanelComponent } from "./components/my-tickets-panel.component";
112
+ export { TicketTableComponent } from "./components/ticket-table.component";
113
+ export { TicketDetailComponent } from "./components/ticket-detail.component";
114
+ export { RichReplyEditorComponent } from "./components/rich-reply-editor.component";
115
+ export { TicketBodyComponent } from "./components/ticket-body.component";
116
+ export { ImageAnnotatorDialogComponent } from "./components/image-annotator-dialog.component";
117
+
118
+ export { configureDebugCapture, launch, onCrash } from "@lightworkai.official/debug-capture";
119
+ export type { DebugCaptureConfig, DebugReason, ErroredQuery, MyTicketListItem, MyTicketDetail } from "@lightworkai.official/debug-capture";