@zhongxiaobing/monitor-react 0.1.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/dist/index.js ADDED
@@ -0,0 +1,764 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+
22
+ // src/index.ts
23
+ var index_exports = {};
24
+ __export(index_exports, {
25
+ MonitorErrorBoundary: () => MonitorErrorBoundary,
26
+ createReactMonitor: () => createReactMonitor,
27
+ useMonitor: () => useMonitor
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/createReactMonitor.tsx
32
+ var import_react2 = require("react");
33
+
34
+ // ../monitor-shared/src/utils/uuid.ts
35
+ function createEventId() {
36
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
37
+ return crypto.randomUUID();
38
+ }
39
+ return `evt_${Date.now()}_${Math.random().toString(16).slice(2)}`;
40
+ }
41
+
42
+ // ../monitor-shared/src/utils/error.ts
43
+ function normalizeError(error) {
44
+ if (error instanceof Error) {
45
+ return {
46
+ name: error.name,
47
+ message: error.message,
48
+ stack: error.stack
49
+ };
50
+ }
51
+ if (typeof error === "string") {
52
+ return {
53
+ message: error
54
+ };
55
+ }
56
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
57
+ const maybeError = error;
58
+ return {
59
+ name: typeof maybeError.name === "string" ? maybeError.name : void 0,
60
+ message: maybeError.message,
61
+ stack: typeof maybeError.stack === "string" ? maybeError.stack : void 0
62
+ };
63
+ }
64
+ return {
65
+ message: "Unknown error"
66
+ };
67
+ }
68
+
69
+ // ../monitor-shared/src/utils/browser.ts
70
+ function getLocationInfo() {
71
+ return {
72
+ url: window.location.href,
73
+ pathname: window.location.pathname,
74
+ title: document.title,
75
+ userAgent: navigator.userAgent
76
+ };
77
+ }
78
+
79
+ // ../monitor-transport/src/queue.ts
80
+ var EventQueue = class {
81
+ constructor() {
82
+ __publicField(this, "events", []);
83
+ }
84
+ add(event) {
85
+ this.events.push(event);
86
+ }
87
+ drain() {
88
+ const current = [...this.events];
89
+ this.events = [];
90
+ return current;
91
+ }
92
+ size() {
93
+ return this.events.length;
94
+ }
95
+ };
96
+
97
+ // ../monitor-transport/src/sender.ts
98
+ async function sendEvents(dsn, events) {
99
+ if (!events.length) return;
100
+ if (navigator.sendBeacon) {
101
+ const blob = new Blob([JSON.stringify({ events })], {
102
+ type: "application/json"
103
+ });
104
+ navigator.sendBeacon(dsn, blob);
105
+ return;
106
+ }
107
+ await fetch(dsn, {
108
+ method: "POST",
109
+ headers: {
110
+ "Content-Type": "application/json"
111
+ },
112
+ body: JSON.stringify({ events }),
113
+ keepalive: true
114
+ });
115
+ }
116
+
117
+ // ../monitor-core/src/context.ts
118
+ function createBaseContext(options) {
119
+ const locationInfo = getLocationInfo();
120
+ return {
121
+ appId: options.appId,
122
+ appName: options.appName,
123
+ env: options.env,
124
+ release: options.release,
125
+ ...locationInfo
126
+ };
127
+ }
128
+
129
+ // ../monitor-core/src/plugin-system.ts
130
+ function setupPlugins(plugins, api, options) {
131
+ const disposers = [];
132
+ for (const plugin of plugins) {
133
+ const disposer = plugin.setup({ api, options });
134
+ if (typeof disposer === "function") {
135
+ disposers.push(disposer);
136
+ }
137
+ }
138
+ return () => {
139
+ for (const dispose of disposers) {
140
+ dispose();
141
+ }
142
+ };
143
+ }
144
+
145
+ // ../monitor-core/src/monitor.ts
146
+ var Monitor = class {
147
+ constructor(options) {
148
+ __publicField(this, "queue", new EventQueue());
149
+ __publicField(this, "options");
150
+ __publicField(this, "context");
151
+ __publicField(this, "disposePlugins", null);
152
+ var _a;
153
+ this.options = options;
154
+ this.context = createBaseContext(options);
155
+ this.disposePlugins = setupPlugins((_a = options.plugins) != null ? _a : [], this, options);
156
+ }
157
+ emit(event) {
158
+ const mergedEvent = {
159
+ ...this.context,
160
+ ...event,
161
+ appId: event.appId || this.context.appId,
162
+ appName: event.appName || this.context.appName,
163
+ env: event.env || this.context.env,
164
+ release: event.release || this.context.release,
165
+ url: event.url || this.context.url,
166
+ pathname: event.pathname || this.context.pathname,
167
+ title: event.title || this.context.title,
168
+ userAgent: event.userAgent || this.context.userAgent,
169
+ eventId: event.eventId || createEventId(),
170
+ timestamp: event.timestamp || Date.now()
171
+ };
172
+ const finalEvent = this.options.beforeSend ? this.options.beforeSend(mergedEvent) : mergedEvent;
173
+ if (!finalEvent) return;
174
+ this.queue.add(finalEvent);
175
+ void this.flush();
176
+ }
177
+ captureException(error, extra) {
178
+ const normalized = normalizeError(error);
179
+ const event = {
180
+ eventId: "",
181
+ eventType: "exception",
182
+ appId: "",
183
+ env: "",
184
+ url: "",
185
+ pathname: "",
186
+ title: "",
187
+ timestamp: 0,
188
+ userAgent: "",
189
+ extra,
190
+ error: {
191
+ name: normalized.name,
192
+ message: normalized.message,
193
+ stack: normalized.stack,
194
+ source: "react"
195
+ }
196
+ };
197
+ this.emit(event);
198
+ }
199
+ async flush() {
200
+ const events = this.queue.drain();
201
+ await sendEvents(this.options.dsn, events);
202
+ }
203
+ destroy() {
204
+ var _a;
205
+ (_a = this.disposePlugins) == null ? void 0 : _a.call(this);
206
+ this.disposePlugins = null;
207
+ }
208
+ };
209
+ function initMonitor(options) {
210
+ return new Monitor(options);
211
+ }
212
+
213
+ // ../monitor-plugin-blank-screen/src/dedupe.ts
214
+ function normalizeScore(score) {
215
+ return score.toFixed(1);
216
+ }
217
+ function createDedupeKey(input) {
218
+ return [input.pathname, input.trigger, normalizeScore(input.score)].join("|");
219
+ }
220
+ function createBlankScreenDedupe(windowMs) {
221
+ const cache = /* @__PURE__ */ new Map();
222
+ function shouldReport(input) {
223
+ const now = Date.now();
224
+ const key = createDedupeKey(input);
225
+ const lastReportedAt = cache.get(key);
226
+ if (!lastReportedAt || now - lastReportedAt > windowMs) {
227
+ cache.set(key, now);
228
+ return true;
229
+ }
230
+ return false;
231
+ }
232
+ function cleanup() {
233
+ const now = Date.now();
234
+ for (const [key, timestamp] of cache.entries()) {
235
+ if (now - timestamp > windowMs) {
236
+ cache.delete(key);
237
+ }
238
+ }
239
+ }
240
+ return {
241
+ shouldReport,
242
+ cleanup
243
+ };
244
+ }
245
+
246
+ // ../monitor-plugin-blank-screen/src/root.ts
247
+ function getRootElement(rootSelector) {
248
+ if (rootSelector) {
249
+ const customRoot = document.querySelector(rootSelector);
250
+ if (customRoot) {
251
+ return customRoot;
252
+ }
253
+ }
254
+ const appRoot = document.querySelector("#app");
255
+ if (appRoot) {
256
+ return appRoot;
257
+ }
258
+ const reactRoot = document.querySelector("#root");
259
+ if (reactRoot) {
260
+ return reactRoot;
261
+ }
262
+ return document.body;
263
+ }
264
+
265
+ // ../monitor-plugin-blank-screen/src/sampler.ts
266
+ var DEFAULT_SAMPLE_POINTS = [
267
+ [0.5, 0.5],
268
+ [0.2, 0.2],
269
+ [0.5, 0.2],
270
+ [0.8, 0.2],
271
+ [0.2, 0.5],
272
+ [0.8, 0.5],
273
+ [0.2, 0.8],
274
+ [0.5, 0.8],
275
+ [0.8, 0.8]
276
+ ];
277
+ function getSamplePoints(samplePoints) {
278
+ return (samplePoints == null ? void 0 : samplePoints.length) ? samplePoints : DEFAULT_SAMPLE_POINTS;
279
+ }
280
+ function sampleElements(points) {
281
+ const width = window.innerWidth;
282
+ const height = window.innerHeight;
283
+ return points.map(([xRatio, yRatio]) => {
284
+ const x = Math.floor(width * xRatio);
285
+ const y = Math.floor(height * yRatio);
286
+ const element = document.elementFromPoint(x, y);
287
+ return {
288
+ x,
289
+ y,
290
+ element
291
+ };
292
+ });
293
+ }
294
+
295
+ // ../monitor-plugin-blank-screen/src/score.ts
296
+ function matchesIgnoreSelectors(element, ignoreSelectors) {
297
+ return ignoreSelectors.some((selector) => {
298
+ try {
299
+ return element.matches(selector) || !!element.closest(selector);
300
+ } catch {
301
+ return false;
302
+ }
303
+ });
304
+ }
305
+ function isContainerElement(element, rootElement) {
306
+ const tagName = element.tagName.toLowerCase();
307
+ if (tagName === "html" || tagName === "body") {
308
+ return true;
309
+ }
310
+ if (element === rootElement) {
311
+ return true;
312
+ }
313
+ return false;
314
+ }
315
+ function getElementSummary(element) {
316
+ if (!element) return "null";
317
+ const tagName = element.tagName.toLowerCase();
318
+ const id = element.id ? `#${element.id}` : "";
319
+ const className = typeof element.className === "string" && element.className.trim() ? `.${element.className.trim().split(/\s+/).join(".")}` : "";
320
+ return `${tagName}${id}${className}`;
321
+ }
322
+ function calculateBlankScore(sampledElements, rootElement, ignoreSelectors) {
323
+ let blankCount = 0;
324
+ const domSummary = sampledElements.map(({ element }) => {
325
+ if (!element) {
326
+ blankCount += 1;
327
+ return "null";
328
+ }
329
+ if (matchesIgnoreSelectors(element, ignoreSelectors)) {
330
+ blankCount += 1;
331
+ return `${getElementSummary(element)}(ignored)`;
332
+ }
333
+ if (isContainerElement(element, rootElement)) {
334
+ blankCount += 1;
335
+ return `${getElementSummary(element)}(container)`;
336
+ }
337
+ return getElementSummary(element);
338
+ });
339
+ return {
340
+ score: sampledElements.length ? blankCount / sampledElements.length : 0,
341
+ domSummary
342
+ };
343
+ }
344
+
345
+ // ../monitor-plugin-blank-screen/src/detect.ts
346
+ function runBlankScreenCheck(options) {
347
+ const {
348
+ rootSelector,
349
+ scoreThreshold = 0.8,
350
+ samplePoints,
351
+ ignoreSelectors = []
352
+ } = options;
353
+ const rootElement = getRootElement(rootSelector);
354
+ const points = getSamplePoints(samplePoints);
355
+ const sampledElements = sampleElements(points);
356
+ const { score, domSummary } = calculateBlankScore(
357
+ sampledElements,
358
+ rootElement,
359
+ ignoreSelectors
360
+ );
361
+ if (score < scoreThreshold) {
362
+ return null;
363
+ }
364
+ return {
365
+ score,
366
+ rootSelector,
367
+ domSummary
368
+ };
369
+ }
370
+
371
+ // ../monitor-plugin-blank-screen/src/normalize.ts
372
+ function createBlankScreenEvent({
373
+ score,
374
+ rootSelector,
375
+ domSummary,
376
+ trigger
377
+ }) {
378
+ return {
379
+ eventId: "",
380
+ eventType: "blank_screen",
381
+ appId: "",
382
+ env: "",
383
+ url: "",
384
+ pathname: "",
385
+ title: "",
386
+ timestamp: 0,
387
+ userAgent: "",
388
+ blankScreen: {
389
+ score,
390
+ rootSelector,
391
+ domSummary,
392
+ readyState: document.readyState,
393
+ trigger
394
+ }
395
+ };
396
+ }
397
+
398
+ // ../monitor-plugin-blank-screen/src/route-change.ts
399
+ function registerRouteChangeListener(onRouteChange) {
400
+ const originalPushState = history.pushState;
401
+ const originalReplaceState = history.replaceState;
402
+ const handleRouteChange = () => {
403
+ onRouteChange();
404
+ };
405
+ history.pushState = function(...args) {
406
+ const result = originalPushState.apply(this, args);
407
+ handleRouteChange();
408
+ return result;
409
+ };
410
+ history.replaceState = function(...args) {
411
+ const result = originalReplaceState.apply(this, args);
412
+ handleRouteChange();
413
+ return result;
414
+ };
415
+ window.addEventListener("popstate", handleRouteChange);
416
+ window.addEventListener("hashchange", handleRouteChange);
417
+ return () => {
418
+ history.pushState = originalPushState;
419
+ history.replaceState = originalReplaceState;
420
+ window.removeEventListener("popstate", handleRouteChange);
421
+ window.removeEventListener("hashchange", handleRouteChange);
422
+ };
423
+ }
424
+
425
+ // ../monitor-plugin-blank-screen/src/index.ts
426
+ function blankScreenPlugin(options = {}) {
427
+ const {
428
+ delayMs = 3e3,
429
+ detectOnRouteChange = true,
430
+ routeChangeDelayMs = 2e3,
431
+ dedupeWindowMs = 1e4
432
+ } = options;
433
+ return {
434
+ name: "blank-screen-plugin",
435
+ setup({ api }) {
436
+ if (typeof window === "undefined" || typeof document === "undefined") {
437
+ return;
438
+ }
439
+ const dedupe = createBlankScreenDedupe(dedupeWindowMs);
440
+ const emitIfNeeded = (trigger) => {
441
+ dedupe.cleanup();
442
+ const result = runBlankScreenCheck(options);
443
+ if (!result) {
444
+ return;
445
+ }
446
+ const pathname = window.location.pathname;
447
+ const shouldReport = dedupe.shouldReport({
448
+ pathname,
449
+ trigger,
450
+ score: result.score
451
+ });
452
+ if (!shouldReport) {
453
+ return;
454
+ }
455
+ api.emit(
456
+ createBlankScreenEvent({
457
+ score: result.score,
458
+ rootSelector: result.rootSelector,
459
+ domSummary: result.domSummary,
460
+ trigger
461
+ })
462
+ );
463
+ };
464
+ const initialTimer = window.setTimeout(() => {
465
+ emitIfNeeded("initial");
466
+ }, delayMs);
467
+ let routeTimer = null;
468
+ const disposeRouteChange = detectOnRouteChange ? registerRouteChangeListener(() => {
469
+ if (routeTimer !== null) {
470
+ window.clearTimeout(routeTimer);
471
+ }
472
+ routeTimer = window.setTimeout(() => {
473
+ emitIfNeeded("route_change");
474
+ }, routeChangeDelayMs);
475
+ }) : () => {
476
+ };
477
+ return () => {
478
+ window.clearTimeout(initialTimer);
479
+ if (routeTimer !== null) {
480
+ window.clearTimeout(routeTimer);
481
+ }
482
+ disposeRouteChange();
483
+ };
484
+ }
485
+ };
486
+ }
487
+
488
+ // ../monitor-plugin-error/src/normalize.ts
489
+ function createExceptionEvent({
490
+ error,
491
+ source
492
+ }) {
493
+ const normalized = normalizeError(error);
494
+ return {
495
+ eventId: "",
496
+ eventType: "exception",
497
+ appId: "",
498
+ env: "",
499
+ url: "",
500
+ pathname: "",
501
+ title: "",
502
+ timestamp: 0,
503
+ userAgent: "",
504
+ error: {
505
+ name: normalized.name,
506
+ message: normalized.message,
507
+ stack: normalized.stack,
508
+ source
509
+ }
510
+ };
511
+ }
512
+
513
+ // ../monitor-plugin-error/src/unhandledrejection.ts
514
+ function registerUnhandledRejection(api) {
515
+ const handler = (event) => {
516
+ const exceptionEvent = createExceptionEvent({
517
+ error: event.reason,
518
+ source: "unhandledrejection"
519
+ });
520
+ api.emit(exceptionEvent);
521
+ };
522
+ window.addEventListener("unhandledrejection", handler);
523
+ return () => {
524
+ window.removeEventListener("unhandledrejection", handler);
525
+ };
526
+ }
527
+
528
+ // ../monitor-plugin-error/src/onerror.ts
529
+ function registerWindowOnError(api) {
530
+ const handler = (message, _source, _lineno, _colno, error) => {
531
+ const targetError = error != null ? error : message;
532
+ const event = createExceptionEvent({
533
+ error: targetError,
534
+ source: "window.onerror"
535
+ });
536
+ api.emit(event);
537
+ return false;
538
+ };
539
+ window.onerror = handler;
540
+ return () => {
541
+ if (window.onerror === handler) {
542
+ window.onerror = null;
543
+ }
544
+ };
545
+ }
546
+
547
+ // ../monitor-plugin-error/src/index.ts
548
+ function errorPlugin(options = {}) {
549
+ const {
550
+ captureOnError = true,
551
+ captureUnhandledRejection = true
552
+ } = options;
553
+ return {
554
+ name: "error-plugin",
555
+ setup({ api }) {
556
+ const disposers = [];
557
+ if (captureOnError) {
558
+ disposers.push(registerWindowOnError(api));
559
+ }
560
+ if (captureUnhandledRejection) {
561
+ disposers.push(registerUnhandledRejection(api));
562
+ }
563
+ return () => {
564
+ for (const dispose of disposers) {
565
+ dispose();
566
+ }
567
+ };
568
+ }
569
+ };
570
+ }
571
+
572
+ // ../monitor-plugin-network/src/normalize.ts
573
+ function createHttpErrorEvent({
574
+ url,
575
+ method,
576
+ status,
577
+ duration,
578
+ responseMessage
579
+ }) {
580
+ return {
581
+ eventId: "",
582
+ eventType: "http_error",
583
+ appId: "",
584
+ env: "",
585
+ url: "",
586
+ pathname: "",
587
+ title: "",
588
+ timestamp: 0,
589
+ userAgent: "",
590
+ request: {
591
+ url,
592
+ method,
593
+ status,
594
+ duration,
595
+ success: false,
596
+ source: "fetch"
597
+ },
598
+ response: {
599
+ message: responseMessage
600
+ }
601
+ };
602
+ }
603
+
604
+ // ../monitor-plugin-network/src/url.ts
605
+ function resolveUrlObject(url) {
606
+ return new URL(url, window.location.origin);
607
+ }
608
+ function isMonitorRequest(requestUrl, dsn) {
609
+ try {
610
+ const request = resolveUrlObject(requestUrl);
611
+ const target = resolveUrlObject(dsn);
612
+ return request.origin === target.origin && request.pathname === target.pathname;
613
+ } catch {
614
+ return requestUrl === dsn;
615
+ }
616
+ }
617
+
618
+ // ../monitor-plugin-network/src/patch-fetch.ts
619
+ function patchFetch(api, sdkOptions, options) {
620
+ if (typeof window === "undefined" || typeof window.fetch !== "function") {
621
+ return () => {
622
+ };
623
+ }
624
+ const originalFetch = window.fetch.bind(window);
625
+ const {
626
+ capture5xx = true,
627
+ captureNetworkError = true
628
+ } = options;
629
+ window.fetch = async (input, init) => {
630
+ const method = ((init == null ? void 0 : init.method) || "GET").toUpperCase();
631
+ const requestUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
632
+ if (isMonitorRequest(requestUrl, sdkOptions.dsn)) {
633
+ return originalFetch(input, init);
634
+ }
635
+ const startedAt = Date.now();
636
+ try {
637
+ const response = await originalFetch(input, init);
638
+ const duration = Date.now() - startedAt;
639
+ if (capture5xx && response.status >= 500) {
640
+ api.emit(
641
+ createHttpErrorEvent({
642
+ url: requestUrl,
643
+ method,
644
+ status: response.status,
645
+ duration,
646
+ responseMessage: response.statusText
647
+ })
648
+ );
649
+ }
650
+ return response;
651
+ } catch (error) {
652
+ const duration = Date.now() - startedAt;
653
+ if (captureNetworkError) {
654
+ api.emit(
655
+ createHttpErrorEvent({
656
+ url: requestUrl,
657
+ method,
658
+ duration,
659
+ responseMessage: error instanceof Error ? error.message : "Fetch request failed"
660
+ })
661
+ );
662
+ }
663
+ throw error;
664
+ }
665
+ };
666
+ return () => {
667
+ window.fetch = originalFetch;
668
+ };
669
+ }
670
+
671
+ // ../monitor-plugin-network/src/index.ts
672
+ function networkPlugin(options = {}) {
673
+ return {
674
+ name: "network-plugin",
675
+ setup({ api, options: sdkOptions }) {
676
+ const disposeFetch = patchFetch(api, sdkOptions, options);
677
+ return () => {
678
+ disposeFetch();
679
+ };
680
+ }
681
+ };
682
+ }
683
+
684
+ // src/MonitorErrorBoundary.tsx
685
+ var import_react = require("react");
686
+ var MonitorErrorBoundary = class extends import_react.Component {
687
+ constructor() {
688
+ super(...arguments);
689
+ __publicField(this, "state", {
690
+ hasError: false
691
+ });
692
+ }
693
+ static getDerivedStateFromError() {
694
+ return { hasError: true };
695
+ }
696
+ componentDidCatch(error, info) {
697
+ this.props.monitor.captureException(error, {
698
+ componentStack: info.componentStack
699
+ });
700
+ }
701
+ render() {
702
+ var _a;
703
+ if (this.state.hasError) {
704
+ return (_a = this.props.fallback) != null ? _a : null;
705
+ }
706
+ return this.props.children;
707
+ }
708
+ };
709
+
710
+ // src/createReactMonitor.tsx
711
+ var import_jsx_runtime = require("react/jsx-runtime");
712
+ var MonitorContext = (0, import_react2.createContext)(null);
713
+ function createReactMonitor(options) {
714
+ var _a;
715
+ const monitor = initMonitor({
716
+ ...options,
717
+ plugins: [
718
+ ...getDefaultPlugins(options),
719
+ ...(_a = options.plugins) != null ? _a : []
720
+ ]
721
+ });
722
+ function MonitorRoot({ children, fallback }) {
723
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MonitorContext.Provider, { value: monitor, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MonitorErrorBoundary, { monitor, fallback: fallback != null ? fallback : options.fallback, children }) });
724
+ }
725
+ function withMonitor(Component2) {
726
+ return function WrappedComponent(props) {
727
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MonitorRoot, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component2, { ...props }) });
728
+ };
729
+ }
730
+ return {
731
+ monitor,
732
+ MonitorRoot,
733
+ withMonitor
734
+ };
735
+ }
736
+ function useMonitor() {
737
+ const monitor = (0, import_react2.useContext)(MonitorContext);
738
+ if (!monitor) {
739
+ throw new Error("useMonitor must be used within MonitorRoot");
740
+ }
741
+ return monitor;
742
+ }
743
+ function getDefaultPlugins(options) {
744
+ var _a;
745
+ const disabled = new Set((_a = options.disableDefaultPlugins) != null ? _a : []);
746
+ const plugins = [];
747
+ if (!disabled.has("error")) {
748
+ plugins.push(errorPlugin(options.error));
749
+ }
750
+ if (!disabled.has("network")) {
751
+ plugins.push(networkPlugin(options.network));
752
+ }
753
+ if (!disabled.has("blankScreen")) {
754
+ plugins.push(blankScreenPlugin(options.blankScreen));
755
+ }
756
+ return plugins;
757
+ }
758
+ // Annotate the CommonJS export names for ESM import in node:
759
+ 0 && (module.exports = {
760
+ MonitorErrorBoundary,
761
+ createReactMonitor,
762
+ useMonitor
763
+ });
764
+ //# sourceMappingURL=index.js.map