@lark-apaas/client-toolkit 1.0.21 → 1.1.1

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.
@@ -3,8 +3,14 @@ import { useEffect, useRef, useState } from "react";
3
3
  import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
4
4
  import { getCsrfToken } from "../../utils/getCsrfToken.js";
5
5
  import { getAppId } from "../../utils/getAppId.js";
6
+ import { useIsMobile } from "../../hooks/index.js";
7
+ import { X } from "lucide-react";
8
+ import { Button } from "../ui/button.js";
6
9
  const Component = ()=>{
10
+ const HasClosedKey = `miaoda-creatByMiaoda-has-closed-${getAppId(window.location.pathname)}`;
11
+ const [visible, setVisible] = useState(!window.localStorage?.getItem(HasClosedKey));
7
12
  const [open, setOpen] = useState(false);
13
+ const isMobile = useIsMobile();
8
14
  const [userinfo, setUserinfo] = useState(null);
9
15
  const [isInternetVisible, setIsInternetVisible] = useState(false);
10
16
  const timeoutRef = useRef(null);
@@ -19,7 +25,7 @@ const Component = ()=>{
19
25
  });
20
26
  }, []);
21
27
  if ('production' !== process.env.NODE_ENV) return null;
22
- if (!userinfo) return null;
28
+ if (isMobile || !visible || !userinfo) return null;
23
29
  return /*#__PURE__*/ jsxs(Popover, {
24
30
  open: open,
25
31
  onOpenChange: setOpen,
@@ -43,12 +49,27 @@ const Component = ()=>{
43
49
  /*#__PURE__*/ jsx("p", {
44
50
  className: "shrink-0 min-w-[92px]",
45
51
  children: "由妙搭 AI 搭建"
52
+ }),
53
+ /*#__PURE__*/ jsx(Button, {
54
+ size: "icon",
55
+ variant: "ghost",
56
+ className: "cursor-pointer rounded-full w-4 h-4",
57
+ onClick: (e)=>{
58
+ e.stopPropagation();
59
+ e.preventDefault();
60
+ setVisible(false);
61
+ window.localStorage?.setItem(HasClosedKey, 'true');
62
+ },
63
+ children: /*#__PURE__*/ jsx(X, {
64
+ size: 10,
65
+ className: "text-[#646A73]"
66
+ })
46
67
  })
47
68
  ]
48
69
  })
49
70
  }),
50
71
  /*#__PURE__*/ jsxs(PopoverContent, {
51
- className: "w-80 pt-2 bg-white rounded-xl shadow-[0px_10px_36px_10px_rgba(31,35,41,0.04)] shadow-[0px_8px_24px_0px_rgba(31,35,41,0.04)] shadow-[0px_6px_12px_-10px_rgba(31,35,41,0.06)] outline outline-[0.50px] outline-offset-[-0.50px] outline-[#DEE0E3] inline-flex flex-col justify-center items-start overflow-hidden p-0",
72
+ className: "w-80 border-0 pt-2 bg-white rounded-xl shadow-[0px_10px_36px_10px_rgba(31,35,41,0.04)] shadow-[0px_8px_24px_0px_rgba(31,35,41,0.04)] shadow-[0px_6px_12px_-10px_rgba(31,35,41,0.06)] outline outline-[0.50px] outline-offset-[-0.50px] outline-[#DEE0E3] inline-flex flex-col justify-center items-start overflow-hidden p-0",
52
73
  side: "top",
53
74
  align: "end",
54
75
  sideOffset: 8,
@@ -3,15 +3,15 @@ import "react";
3
3
  import { Slot } from "@radix-ui/react-slot";
4
4
  import { cva } from "class-variance-authority";
5
5
  import { clsxWithTw } from "../../utils/utils.js";
6
- const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
6
+ const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-normal transition-all disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/20 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
7
7
  variants: {
8
8
  variant: {
9
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
10
- destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
11
- outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
12
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
13
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
14
- link: "text-primary underline-offset-4 hover:underline"
9
+ default: "bg-primary text-primary-foreground not-disabled:hover:bg-primary/90",
10
+ destructive: "bg-destructive text-white not-disabled:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
11
+ outline: "border bg-background not-disabled:hover:bg-accent not-disabled:hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:not-disabled:hover:bg-input/50",
12
+ secondary: "bg-secondary text-secondary-foreground not-disabled:hover:bg-secondary/80",
13
+ ghost: "not-disabled:hover:bg-accent not-disabled:hover:text-accent-foreground dark:not-disabled:hover:bg-accent/50",
14
+ link: "text-primary underline-offset-4 not-disabled:hover:underline"
15
15
  },
16
16
  size: {
17
17
  default: "h-9 px-4 py-2 has-[>svg]:px-3",
@@ -1,6 +1 @@
1
- export declare const logger: {
2
- debug(message: any, ...args: any[]): void;
3
- info(message: any, ...args: any[]): void;
4
- warn(message: any, ...args: any[]): void;
5
- error(message: any, ...args: any[]): void;
6
- };
1
+ export { logger } from './logger';
@@ -1,54 +1,2 @@
1
- const LOG_LEVELS = [
2
- 'debug',
3
- 'info',
4
- 'warn',
5
- 'error'
6
- ];
7
- const defaultConfig = {
8
- showLevel: false,
9
- showTimestamp: false,
10
- level: 'info',
11
- prefix: ''
12
- };
13
- let config = {
14
- ...defaultConfig
15
- };
16
- function configureLogger(options) {
17
- config = {
18
- ...defaultConfig,
19
- ...options
20
- };
21
- }
22
- function getLogLevel() {
23
- return config.level;
24
- }
25
- function shouldLog(level) {
26
- return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(getLogLevel());
27
- }
28
- function getFormattedPrefix(level) {
29
- const parts = [];
30
- if (config.prefix) parts.push(`[${config.prefix}]`);
31
- if (config.showLevel) parts.push(`[${level.toUpperCase()}]`);
32
- return parts;
33
- }
34
- configureLogger({
35
- showLevel: true,
36
- showTimestamp: false,
37
- level: 'development' === process.env.NODE_ENV ? 'debug' : 'error',
38
- prefix: 'MiaoDa'
39
- });
40
- const logger = {
41
- debug (message, ...args) {
42
- if (shouldLog('debug')) console.log(...getFormattedPrefix('debug'), message, ...args);
43
- },
44
- info (message, ...args) {
45
- if (shouldLog('info')) console.log(...getFormattedPrefix('info'), message, ...args);
46
- },
47
- warn (message, ...args) {
48
- if (shouldLog('warn')) console.log(...getFormattedPrefix('warn'), message, ...args);
49
- },
50
- error (message, ...args) {
51
- if (shouldLog('error')) console.error(...getFormattedPrefix('error'), message, ...args);
52
- }
53
- };
1
+ import { logger } from "./logger.js";
54
2
  export { logger };
@@ -0,0 +1 @@
1
+ export declare function interceptGlobalError(): void;
@@ -0,0 +1,10 @@
1
+ import { logger } from "./logger.js";
2
+ function interceptGlobalError() {
3
+ window.addEventListener('error', (event)=>{
4
+ logger.error('global error', event);
5
+ });
6
+ window.addEventListener('unhandledrejection', (event)=>{
7
+ logger.error('global unhandledrejection', event);
8
+ });
9
+ }
10
+ export { interceptGlobalError };
@@ -0,0 +1,113 @@
1
+ import z from 'zod';
2
+ export declare const networkRequestLogSchema: z.ZodObject<{
3
+ method: z.ZodString;
4
+ status: z.ZodInt;
5
+ statusText: z.ZodString;
6
+ path: z.ZodString;
7
+ requestData: z.ZodOptional<z.ZodUnknown>;
8
+ requestParams: z.ZodOptional<z.ZodUnknown>;
9
+ responseData: z.ZodOptional<z.ZodUnknown>;
10
+ traceID: z.ZodString;
11
+ }, z.core.$strip>;
12
+ export declare const genericErrorSchema: z.ZodObject<{
13
+ message: z.ZodString;
14
+ stack: z.ZodString;
15
+ }, z.core.$strip>;
16
+ export declare const routerErrorSchema: z.ZodObject<{
17
+ path: z.ZodString;
18
+ }, z.core.$strip>;
19
+ export declare const noCategoryLogSchema: z.ZodObject<{
20
+ message: z.ZodUnknown;
21
+ args: z.ZodArray<z.ZodUnknown>;
22
+ }, z.core.$strip>;
23
+ export declare const levelSchema: z.ZodEnum<{
24
+ info: "info";
25
+ warn: "warn";
26
+ error: "error";
27
+ debug: "debug";
28
+ }>;
29
+ export declare const selectedLogSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
30
+ type: z.ZodLiteral<"networkRequest">;
31
+ level: z.ZodEnum<{
32
+ info: "info";
33
+ warn: "warn";
34
+ error: "error";
35
+ debug: "debug";
36
+ }>;
37
+ id: z.ZodString;
38
+ data: z.ZodObject<{
39
+ method: z.ZodString;
40
+ status: z.ZodInt;
41
+ statusText: z.ZodString;
42
+ path: z.ZodString;
43
+ requestData: z.ZodOptional<z.ZodUnknown>;
44
+ requestParams: z.ZodOptional<z.ZodUnknown>;
45
+ responseData: z.ZodOptional<z.ZodUnknown>;
46
+ traceID: z.ZodString;
47
+ }, z.core.$strip>;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ type: z.ZodLiteral<"routerError">;
50
+ level: z.ZodEnum<{
51
+ info: "info";
52
+ warn: "warn";
53
+ error: "error";
54
+ debug: "debug";
55
+ }>;
56
+ id: z.ZodString;
57
+ data: z.ZodObject<{
58
+ path: z.ZodString;
59
+ }, z.core.$strip>;
60
+ }, z.core.$strip>, z.ZodObject<{
61
+ type: z.ZodLiteral<"renderError">;
62
+ level: z.ZodEnum<{
63
+ info: "info";
64
+ warn: "warn";
65
+ error: "error";
66
+ debug: "debug";
67
+ }>;
68
+ id: z.ZodString;
69
+ data: z.ZodObject<{
70
+ message: z.ZodString;
71
+ stack: z.ZodString;
72
+ }, z.core.$strip>;
73
+ }, z.core.$strip>, z.ZodObject<{
74
+ type: z.ZodLiteral<"globalError">;
75
+ level: z.ZodEnum<{
76
+ info: "info";
77
+ warn: "warn";
78
+ error: "error";
79
+ debug: "debug";
80
+ }>;
81
+ id: z.ZodString;
82
+ data: z.ZodObject<{
83
+ message: z.ZodString;
84
+ stack: z.ZodString;
85
+ }, z.core.$strip>;
86
+ }, z.core.$strip>, z.ZodObject<{
87
+ type: z.ZodLiteral<"unhandledRejectionError">;
88
+ level: z.ZodEnum<{
89
+ info: "info";
90
+ warn: "warn";
91
+ error: "error";
92
+ debug: "debug";
93
+ }>;
94
+ id: z.ZodString;
95
+ data: z.ZodObject<{
96
+ message: z.ZodString;
97
+ stack: z.ZodString;
98
+ }, z.core.$strip>;
99
+ }, z.core.$strip>, z.ZodObject<{
100
+ type: z.ZodLiteral<"noCategory">;
101
+ level: z.ZodEnum<{
102
+ info: "info";
103
+ warn: "warn";
104
+ error: "error";
105
+ debug: "debug";
106
+ }>;
107
+ id: z.ZodString;
108
+ data: z.ZodObject<{
109
+ message: z.ZodUnknown;
110
+ args: z.ZodArray<z.ZodUnknown>;
111
+ }, z.core.$strip>;
112
+ }, z.core.$strip>], "type">;
113
+ export type SelectedLog = z.infer<typeof selectedLogSchema>;
@@ -0,0 +1,67 @@
1
+ import zod from "zod";
2
+ const networkRequestLogSchema = zod.object({
3
+ method: zod.string(),
4
+ status: zod.int(),
5
+ statusText: zod.string(),
6
+ path: zod.string(),
7
+ requestData: zod.optional(zod.unknown()),
8
+ requestParams: zod.optional(zod.unknown()),
9
+ responseData: zod.optional(zod.unknown()),
10
+ traceID: zod.string()
11
+ });
12
+ const genericErrorSchema = zod.object({
13
+ message: zod.string(),
14
+ stack: zod.string()
15
+ });
16
+ const routerErrorSchema = zod.object({
17
+ path: zod.string()
18
+ });
19
+ const noCategoryLogSchema = zod.object({
20
+ message: zod.unknown(),
21
+ args: zod.array(zod.unknown())
22
+ });
23
+ const levelSchema = zod["enum"]([
24
+ 'info',
25
+ 'warn',
26
+ 'error',
27
+ 'debug'
28
+ ]);
29
+ const selectedLogSchema = zod.discriminatedUnion('type', [
30
+ zod.object({
31
+ type: zod.literal('networkRequest'),
32
+ level: levelSchema,
33
+ id: zod.string(),
34
+ data: networkRequestLogSchema
35
+ }),
36
+ zod.object({
37
+ type: zod.literal('routerError'),
38
+ level: levelSchema,
39
+ id: zod.string(),
40
+ data: routerErrorSchema
41
+ }),
42
+ zod.object({
43
+ type: zod.literal('renderError'),
44
+ level: levelSchema,
45
+ id: zod.string(),
46
+ data: genericErrorSchema
47
+ }),
48
+ zod.object({
49
+ type: zod.literal('globalError'),
50
+ level: levelSchema,
51
+ id: zod.string(),
52
+ data: genericErrorSchema
53
+ }),
54
+ zod.object({
55
+ type: zod.literal('unhandledRejectionError'),
56
+ level: levelSchema,
57
+ id: zod.string(),
58
+ data: genericErrorSchema
59
+ }),
60
+ zod.object({
61
+ type: zod.literal('noCategory'),
62
+ level: levelSchema,
63
+ id: zod.string(),
64
+ data: noCategoryLogSchema
65
+ })
66
+ ]);
67
+ export { genericErrorSchema, levelSchema, networkRequestLogSchema, noCategoryLogSchema, routerErrorSchema, selectedLogSchema };
@@ -0,0 +1,7 @@
1
+ export type LogInterceptor = (originLogger: typeof logger) => typeof logger;
2
+ export declare let logger: {
3
+ debug(message: any, ...args: any[]): void;
4
+ info(message: any, ...args: any[]): void;
5
+ warn(message: any, ...args: any[]): void;
6
+ error(message: any, ...args: any[]): void;
7
+ };
@@ -0,0 +1,58 @@
1
+ import { interceptors } from "./selected-logs.js";
2
+ import { interceptGlobalError } from "./intercept-global-error.js";
3
+ const LOG_LEVELS = [
4
+ 'debug',
5
+ 'info',
6
+ 'warn',
7
+ 'error'
8
+ ];
9
+ const defaultConfig = {
10
+ showLevel: false,
11
+ showTimestamp: false,
12
+ level: 'info',
13
+ prefix: ''
14
+ };
15
+ let config = {
16
+ ...defaultConfig
17
+ };
18
+ function configureLogger(options) {
19
+ config = {
20
+ ...defaultConfig,
21
+ ...options
22
+ };
23
+ }
24
+ function getLogLevel() {
25
+ return config.level;
26
+ }
27
+ function shouldLog(level) {
28
+ return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(getLogLevel());
29
+ }
30
+ function getFormattedPrefix(level) {
31
+ const parts = [];
32
+ if (config.prefix) parts.push(`[${config.prefix}]`);
33
+ if (config.showLevel) parts.push(`[${level.toUpperCase()}]`);
34
+ return parts;
35
+ }
36
+ configureLogger({
37
+ showLevel: true,
38
+ showTimestamp: false,
39
+ level: 'development' === process.env.NODE_ENV ? 'debug' : 'error',
40
+ prefix: 'MiaoDa'
41
+ });
42
+ let logger = {
43
+ debug (message, ...args) {
44
+ if (shouldLog('debug')) console.log(...getFormattedPrefix('debug'), message, ...args);
45
+ },
46
+ info (message, ...args) {
47
+ if (shouldLog('info')) console.log(...getFormattedPrefix('info'), message, ...args);
48
+ },
49
+ warn (message, ...args) {
50
+ if (shouldLog('warn')) console.log(...getFormattedPrefix('warn'), message, ...args);
51
+ },
52
+ error (message, ...args) {
53
+ if (shouldLog('error')) console.error(...getFormattedPrefix('error'), message, ...args);
54
+ }
55
+ };
56
+ for (const interceptor of interceptors)logger = interceptor(logger);
57
+ interceptGlobalError();
58
+ export { logger };
@@ -0,0 +1,2 @@
1
+ import { type LogInterceptor } from './logger';
2
+ export declare const interceptors: LogInterceptor[];
@@ -0,0 +1,260 @@
1
+ import { logger as external_logger_js_logger } from "./logger.js";
2
+ import { SourceMapConsumer } from "source-map";
3
+ import { normalizeBasePath } from "../utils/utils.js";
4
+ import { mappingText } from "./source-map-mappings-wasm.js";
5
+ import { genericErrorSchema, networkRequestLogSchema, noCategoryLogSchema, routerErrorSchema } from "./log-types.js";
6
+ function hexToBuffer(hexString) {
7
+ const hex = hexString.replace(/\s/g, '').toUpperCase();
8
+ if (!/^[0-9A-F]+$/.test(hex)) throw new Error('Invalid hex string');
9
+ if (hex.length % 2 !== 0) throw new Error('Hex string length must be even');
10
+ const buffer = new ArrayBuffer(hex.length / 2);
11
+ const uint8Array = new Uint8Array(buffer);
12
+ for(let i = 0; i < hex.length; i += 2){
13
+ const byteValue = parseInt(hex.substr(i, 2), 16);
14
+ uint8Array[i / 2] = byteValue;
15
+ }
16
+ return buffer;
17
+ }
18
+ SourceMapConsumer.initialize({
19
+ 'lib/mappings.wasm': hexToBuffer(mappingText)
20
+ });
21
+ async function getSourceMap() {
22
+ let sourceMapContent = '';
23
+ try {
24
+ const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
25
+ const res = await fetch(`${basePath}/main.js.map`);
26
+ sourceMapContent = await res.text();
27
+ } catch (e) {
28
+ external_logger_js_logger.warn('get main.js.map error', e);
29
+ }
30
+ return sourceMapContent;
31
+ }
32
+ async function parseSourceMap(stack) {
33
+ try {
34
+ const sourceMapContent = await getSourceMap();
35
+ if (!sourceMapContent) return stack;
36
+ const consumer = await new SourceMapConsumer(JSON.parse(sourceMapContent));
37
+ const lines = stack.split('\n');
38
+ for(let i = 0; i < lines.length; i++){
39
+ const line = lines[i];
40
+ const match = line.match(/\((.*main\.js):(\d+):(\d+)\)/);
41
+ if (match) {
42
+ const [fullMatch, , lineNum, colNum] = match;
43
+ const originalPosition = consumer.originalPositionFor({
44
+ line: Number(lineNum),
45
+ column: Number(colNum)
46
+ });
47
+ if (originalPosition.source) {
48
+ let originalPositionStr = `(${originalPosition.source}:${originalPosition.line}:${originalPosition.column})`;
49
+ originalPositionStr = originalPositionStr.replace('webpack://fullstack-nestjs-template/', '');
50
+ lines[i] = line.replace(fullMatch, originalPositionStr);
51
+ }
52
+ }
53
+ }
54
+ return lines.join('\n');
55
+ } catch (e) {
56
+ external_logger_js_logger.warn('recover code position error', e);
57
+ return stack;
58
+ }
59
+ }
60
+ function sendSelectedLog(log) {
61
+ const logWithID = {
62
+ ...log,
63
+ id: crypto.randomUUID()
64
+ };
65
+ try {
66
+ const logJSON = JSON.stringify(logWithID);
67
+ console.log(logJSON);
68
+ if (window.parent !== window) try {
69
+ window.parent.postMessage({
70
+ type: 'SELECTED_LOG',
71
+ payload: logJSON
72
+ }, '*');
73
+ } catch (e) {
74
+ external_logger_js_logger.warn('post selected log to parent iframe error', e);
75
+ }
76
+ } catch (e) {
77
+ external_logger_js_logger.warn('send selected log error', e);
78
+ }
79
+ }
80
+ const comprehensiveInterceptor = (logger)=>({
81
+ info: (message, ...args)=>{
82
+ try {
83
+ logger.info(message, ...args);
84
+ } catch (e) {
85
+ logger.warn('info log error', e);
86
+ }
87
+ if (message && 'object' == typeof message && 'HTTP Request' === message.type) return;
88
+ if (message && 'object' == typeof message && 'HTTP Response' === message.type) {
89
+ let requestData = message.data;
90
+ if ('string' == typeof requestData) try {
91
+ requestData = JSON.parse(requestData);
92
+ } catch (e) {
93
+ logger.warn('parse request data error', e);
94
+ }
95
+ const info = networkRequestLogSchema.safeParse({
96
+ method: message.method || '',
97
+ status: message.status || 0,
98
+ statusText: message.statusText || '',
99
+ path: message.url || '',
100
+ requestData,
101
+ requestParams: message.params,
102
+ responseData: message.responseData,
103
+ traceID: message.headers?.['X-Trace-ID'] || ''
104
+ });
105
+ if (info.success) sendSelectedLog({
106
+ type: 'networkRequest',
107
+ level: 'info',
108
+ data: info.data
109
+ });
110
+ return;
111
+ }
112
+ sendSelectedLog({
113
+ type: 'noCategory',
114
+ level: 'info',
115
+ data: {
116
+ message,
117
+ args
118
+ }
119
+ });
120
+ },
121
+ error: (message, ...args)=>{
122
+ try {
123
+ logger.error(message, ...args);
124
+ } catch (e) {
125
+ logger.warn('error log error', e);
126
+ }
127
+ if (message && 'object' == typeof message && 'HTTP Request' === message.type) return;
128
+ if (message && 'object' == typeof message && 'HTTP Response' === message.type) {
129
+ let requestData = message.data;
130
+ if ('string' == typeof requestData) try {
131
+ requestData = JSON.parse(requestData);
132
+ } catch (e) {
133
+ logger.warn('parse request data error', e);
134
+ }
135
+ const info = networkRequestLogSchema.safeParse({
136
+ method: message.method || '',
137
+ status: message.status || 0,
138
+ statusText: message.statusText || '',
139
+ path: message.url || '',
140
+ requestData,
141
+ requestParams: message.params,
142
+ responseData: message.responseData,
143
+ traceID: message.headers?.['X-Trace-ID'] || ''
144
+ });
145
+ if (info.success) sendSelectedLog({
146
+ type: 'networkRequest',
147
+ level: 'error',
148
+ data: info.data
149
+ });
150
+ return;
151
+ }
152
+ if ('RenderError' === message) return void (async ()=>{
153
+ const error = args[0];
154
+ if (error && error instanceof Error) {
155
+ const stack = await parseSourceMap(error.stack || '');
156
+ sendSelectedLog({
157
+ type: 'renderError',
158
+ level: 'error',
159
+ data: {
160
+ message: error.message,
161
+ stack
162
+ }
163
+ });
164
+ }
165
+ })();
166
+ if ('404 Error: User attempted to access non-existent route:' === message) {
167
+ const path = args[0] || '';
168
+ const data = routerErrorSchema.safeParse({
169
+ path
170
+ });
171
+ if (data.success) return void sendSelectedLog({
172
+ level: 'error',
173
+ type: 'routerError',
174
+ data: data.data
175
+ });
176
+ }
177
+ if ('global error' === message) {
178
+ const error = args[0];
179
+ if (error && error instanceof ErrorEvent) {
180
+ const data = genericErrorSchema.safeParse({
181
+ message: error?.error?.message || '',
182
+ stack: error?.error?.stack || ''
183
+ });
184
+ if (data.success) return void (async ()=>{
185
+ const stack = await parseSourceMap(data.data.stack || '');
186
+ sendSelectedLog({
187
+ type: 'globalError',
188
+ level: 'error',
189
+ data: {
190
+ ...data.data,
191
+ stack
192
+ }
193
+ });
194
+ })();
195
+ }
196
+ }
197
+ if ('global unhandledrejection' === message) {
198
+ const error = args[0];
199
+ if (error && error instanceof PromiseRejectionEvent) {
200
+ const data = genericErrorSchema.safeParse({
201
+ message: error?.reason?.message || '',
202
+ stack: error?.reason?.stack || ''
203
+ });
204
+ if (data.success) return void (async ()=>{
205
+ const stack = await parseSourceMap(data.data.stack || '');
206
+ sendSelectedLog({
207
+ type: 'unhandledRejectionError',
208
+ level: 'error',
209
+ data: {
210
+ ...data.data,
211
+ stack
212
+ }
213
+ });
214
+ })();
215
+ }
216
+ }
217
+ sendSelectedLog({
218
+ type: 'noCategory',
219
+ level: 'error',
220
+ data: noCategoryLogSchema.parse({
221
+ message,
222
+ args
223
+ })
224
+ });
225
+ },
226
+ warn: (message, ...args)=>{
227
+ try {
228
+ logger.warn(message, ...args);
229
+ } catch (e) {
230
+ logger.warn('warn log error', e);
231
+ }
232
+ sendSelectedLog({
233
+ type: 'noCategory',
234
+ level: 'warn',
235
+ data: {
236
+ message,
237
+ args
238
+ }
239
+ });
240
+ },
241
+ debug: (message, ...args)=>{
242
+ try {
243
+ logger.debug(message, ...args);
244
+ } catch (e) {
245
+ logger.warn('debug log error', e);
246
+ }
247
+ sendSelectedLog({
248
+ type: 'noCategory',
249
+ level: 'debug',
250
+ data: {
251
+ message,
252
+ args
253
+ }
254
+ });
255
+ }
256
+ });
257
+ const interceptors = [
258
+ comprehensiveInterceptor
259
+ ];
260
+ export { interceptors };