@king-one/monitor 1.0.5 → 1.0.7

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.
@@ -1,10 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { EventEmitter } from "./EventEmitter.mjs";
5
- import { SourceError } from "./SourceError.mjs";
6
- import { stringify } from "./utils.mjs";
7
- const _ErrorMonitor = class _ErrorMonitor {
1
+ var p = Object.defineProperty;
2
+ var h = (o, t, e) => t in o ? p(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var n = (o, t, e) => h(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { EventEmitter as c } from "./EventEmitter.mjs";
5
+ import { SourceError as f } from "./SourceError.mjs";
6
+ import { stringify as l } from "./utils.mjs";
7
+ const r = class r {
8
8
  /**
9
9
  * 取消订阅错误上报事件
10
10
  * @param callback - 错误上报回调函数
@@ -15,33 +15,28 @@ const _ErrorMonitor = class _ErrorMonitor {
15
15
  /**
16
16
  * 私有构造函数,防止外部直接实例化
17
17
  */
18
- constructor(options) {
19
- __publicField(this, "options");
20
- __publicField(this, "event");
21
- __publicField(this, "source");
18
+ constructor(t) {
19
+ n(this, "options");
20
+ n(this, "event");
21
+ n(this, "source");
22
22
  // 错误事件类型常量
23
- __publicField(this, "ERROR_REPORTED", "error-reported");
24
- this.options = this.validateOptions(options);
25
- this.event = new EventEmitter();
26
- this.source = new SourceError();
27
- this.init();
28
- if (options.integrations)
29
- this.initIntegrations();
23
+ n(this, "ERROR_REPORTED", "error-reported");
24
+ this.options = this.validateOptions(t), this.event = new c(), this.source = new f(), this.init(), t.integrations && this.initIntegrations();
30
25
  }
31
26
  /**
32
27
  * 订阅错误上报事件
33
28
  * @param callback - 错误上报回调函数
34
29
  */
35
- onErrorReported(callback) {
36
- this.event.on(this.ERROR_REPORTED, callback);
30
+ onErrorReported(t) {
31
+ this.event.on(this.ERROR_REPORTED, t);
37
32
  }
38
33
  initIntegrations() {
39
- var _a;
40
- (_a = this.options.integrations) == null ? void 0 : _a.forEach((integration) => {
34
+ var t;
35
+ (t = this.options.integrations) == null || t.forEach((e) => {
41
36
  try {
42
- integration.install(this);
43
- } catch (error) {
44
- console.error(`Failed to initialize integration ${integration.name}:`, error);
37
+ e.install(this);
38
+ } catch (i) {
39
+ console.error(`Failed to initialize integration ${e.name}:`, i);
45
40
  }
46
41
  });
47
42
  }
@@ -50,10 +45,9 @@ const _ErrorMonitor = class _ErrorMonitor {
50
45
  * @throws {Error} 当实例未初始化时抛出错误
51
46
  */
52
47
  static getInstance() {
53
- if (!_ErrorMonitor.instance) {
48
+ if (!r.instance)
54
49
  throw new Error("ErrorMonitor未初始化,请先调用initialize方法");
55
- }
56
- return _ErrorMonitor.instance;
50
+ return r.instance;
57
51
  }
58
52
  /**
59
53
  * 静态方法:手动上报错误信息
@@ -80,17 +74,15 @@ const _ErrorMonitor = class _ErrorMonitor {
80
74
  * @returns 处理后的完整配置项
81
75
  * @throws {Error} 当必要配置项缺失时抛出错误
82
76
  */
83
- validateOptions(options) {
84
- if (!options.url) {
77
+ validateOptions(t) {
78
+ if (!t.url)
85
79
  throw new Error("上报地址url不能为空");
86
- }
87
- if (!options.appId) {
88
- throw new Error("应用标识appId不能为空");
89
- }
80
+ if (!t.appId)
81
+ throw new Error("平台标识appId不能为空");
90
82
  return {
91
83
  env: "development",
92
84
  sampleRate: 1,
93
- ...options
85
+ ...t
94
86
  };
95
87
  }
96
88
  /**
@@ -98,8 +90,8 @@ const _ErrorMonitor = class _ErrorMonitor {
98
90
  * 包括:JS运行时错误、Promise异常、资源加载错误
99
91
  */
100
92
  init() {
101
- this.onErrorReported((error) => {
102
- this.reportError(error);
93
+ this.onErrorReported((t) => {
94
+ this.reportError(t);
103
95
  });
104
96
  }
105
97
  /**
@@ -118,66 +110,53 @@ const _ErrorMonitor = class _ErrorMonitor {
118
110
  * 上报错误信息到服务器
119
111
  * @param errorInfo - 错误信息对象
120
112
  */
121
- report(errorInfo) {
122
- if (Math.random() > (this.options.sampleRate || 1)) {
113
+ report(t) {
114
+ if (Math.random() > (this.options.sampleRate || 1))
123
115
  return;
124
- }
125
- let reportData = {
126
- ...errorInfo,
116
+ let e = {
117
+ ...t,
127
118
  appId: this.options.appId,
128
119
  env: this.options.env
129
- };
130
- let url = this.options.url;
120
+ }, i = this.options.url;
131
121
  if (this.options.paramsSerializer) {
132
- const params = this.options.paramsSerializer();
133
- url = `${url}?${stringify(params)}`;
122
+ const s = this.options.paramsSerializer();
123
+ i = `${i}?${l(s)}`;
134
124
  }
135
125
  if (this.options.beforeSend) {
136
- const result = this.options.beforeSend(reportData);
137
- if (!result) {
126
+ const s = this.options.beforeSend(e);
127
+ if (!s)
138
128
  return;
139
- }
140
- reportData = result;
141
- }
142
- if (navigator.sendBeacon) {
143
- navigator.sendBeacon(url, JSON.stringify(reportData));
144
- } else {
145
- fetch(url, {
146
- method: "POST",
147
- body: JSON.stringify(reportData),
148
- headers: {
149
- "Content-Type": "application/json"
150
- },
151
- keepalive: true
152
- }).catch(() => {
153
- });
129
+ e = s;
154
130
  }
131
+ navigator.sendBeacon ? navigator.sendBeacon(i, JSON.stringify(e)) : fetch(i, {
132
+ method: "POST",
133
+ body: JSON.stringify(e),
134
+ headers: {
135
+ "Content-Type": "text/plain"
136
+ },
137
+ keepalive: !0
138
+ }).catch(() => {
139
+ });
155
140
  }
156
141
  /**
157
142
  * 标准化错误信息
158
143
  * @param error - 原始错误信息
159
144
  * @returns 标准化后的错误信息对象
160
145
  */
161
- normalizeError(error) {
162
- if (this.isErrorInfo(error)) {
163
- return {
164
- ...error,
165
- extraInfo: this.options.extraInfo,
166
- ...this.getClientInfo()
167
- };
168
- }
169
- if (error instanceof Error) {
170
- return {
171
- type: error.name,
172
- message: error.message,
173
- stack: error.stack,
174
- extraInfo: this.options.extraInfo,
175
- ...this.getClientInfo()
176
- };
177
- }
178
- return {
146
+ normalizeError(t) {
147
+ return this.isErrorInfo(t) ? {
148
+ ...t,
149
+ extraInfo: { ...this.options.extraInfo, ...t.extraInfo },
150
+ ...this.getClientInfo()
151
+ } : t instanceof Error ? {
152
+ type: t.name,
153
+ message: t.message,
154
+ stack: t.stack,
155
+ extraInfo: this.options.extraInfo,
156
+ ...this.getClientInfo()
157
+ } : {
179
158
  type: "Error",
180
- message: error,
159
+ message: t,
181
160
  extraInfo: this.options.extraInfo,
182
161
  ...this.getClientInfo()
183
162
  };
@@ -187,16 +166,14 @@ const _ErrorMonitor = class _ErrorMonitor {
187
166
  * @param error - 待检查的错误信息
188
167
  * @returns 是否为 ErrorInfo 类型
189
168
  */
190
- isErrorInfo(error) {
191
- return typeof error === "object" && error !== null && "type" in error && "message" in error;
169
+ isErrorInfo(t) {
170
+ return typeof t == "object" && t !== null && "type" in t && "message" in t;
192
171
  }
193
- reportError(error) {
194
- if (!_ErrorMonitor.instance) {
172
+ reportError(t) {
173
+ if (!r.instance)
195
174
  throw new Error("ErrorMonitor未初始化,请先调用initialize方法");
196
- }
197
- const errorInfo = this.normalizeError(error);
198
- console.log("errorInfo", errorInfo);
199
- this.report(errorInfo);
175
+ const e = this.normalizeError(t);
176
+ this.report(e);
200
177
  }
201
178
  /**
202
179
  * 初始化错误监控实例
@@ -204,36 +181,32 @@ const _ErrorMonitor = class _ErrorMonitor {
204
181
  * @returns ErrorMonitor实例
205
182
  * @throws {Error} 当重复初始化或配置项缺失时抛出错误
206
183
  */
207
- static initialize(options) {
208
- if (_ErrorMonitor.instance) {
184
+ static initialize(t) {
185
+ if (r.instance)
209
186
  throw new Error("ErrorMonitor已经初始化,请勿重复初始化");
210
- }
211
- _ErrorMonitor.instance = new _ErrorMonitor(options);
212
- return _ErrorMonitor.instance;
187
+ return r.instance = new r(t), r.instance;
213
188
  }
214
189
  /**
215
190
  * 销毁实例,清理资源
216
191
  */
217
192
  static destroy() {
218
- if (_ErrorMonitor.instance) {
219
- _ErrorMonitor.instance = null;
220
- }
193
+ r.instance && (r.instance = null);
221
194
  }
222
- static captureError(error) {
223
- _ErrorMonitor.getInstance().reportError(error);
195
+ static captureError(t) {
196
+ r.getInstance().reportError(t);
224
197
  }
225
- emitError(error) {
226
- this.event.emit(this.ERROR_REPORTED, error);
198
+ emitError(t) {
199
+ this.event.emit(this.ERROR_REPORTED, t);
227
200
  }
228
- async getErrorSource(error) {
229
- return this.source.getErrorSource(error);
201
+ async getErrorSource(t) {
202
+ return this.source.getErrorSource(t);
230
203
  }
231
204
  get env() {
232
205
  return this.options.env;
233
206
  }
234
207
  };
235
- __publicField(_ErrorMonitor, "instance", null);
236
- let ErrorMonitor = _ErrorMonitor;
208
+ n(r, "instance", null);
209
+ let a = r;
237
210
  export {
238
- ErrorMonitor
211
+ a as ErrorMonitor
239
212
  };
@@ -1,10 +1,12 @@
1
- import { ErrorMonitor } from "./core.mjs";
2
- import { SourceError } from "./SourceError.mjs";
3
- import { VueError } from "./integrations/VueError.mjs";
4
- import { BrowserError } from "./integrations/BrowserError.mjs";
1
+ import { ErrorMonitor as e } from "./core.mjs";
2
+ import { SourceError as m } from "./SourceError.mjs";
3
+ import { VueError as f } from "./integrations/VueError.mjs";
4
+ import { BrowserError as E } from "./integrations/BrowserError.mjs";
5
+ import { timestampToBase66 as a } from "./utils.mjs";
5
6
  export {
6
- BrowserError,
7
- ErrorMonitor,
8
- SourceError,
9
- VueError
7
+ E as BrowserError,
8
+ e as ErrorMonitor,
9
+ m as SourceError,
10
+ f as VueError,
11
+ a as timestampToBase66
10
12
  };
@@ -1,76 +1,67 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { getClientInfo } from "../utils.mjs";
5
- class BrowserError {
1
+ var a = Object.defineProperty;
2
+ var m = (t, r, o) => r in t ? a(t, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[r] = o;
3
+ var i = (t, r, o) => m(t, typeof r != "symbol" ? r + "" : r, o);
4
+ import { getClientInfo as n } from "../utils.mjs";
5
+ class c {
6
6
  constructor() {
7
- __publicField(this, "name", "BrowserError");
8
- __publicField(this, "monitor", null);
7
+ i(this, "name", "BrowserError");
8
+ i(this, "monitor", null);
9
9
  }
10
- install(monitor) {
11
- this.monitor = monitor;
12
- window.addEventListener("error", (event) => {
13
- this.handleJsError(event);
14
- }, true);
15
- window.addEventListener("unhandledrejection", (event) => {
16
- this.handlePromiseError(event);
17
- });
18
- window.addEventListener("error", (event) => {
19
- if (event.target && event.target.tagName) {
20
- this.handleResourceError(event);
21
- }
22
- }, true);
10
+ install(r) {
11
+ this.monitor = r, window.addEventListener("error", (o) => {
12
+ this.handleJsError(o);
13
+ }, !0), window.addEventListener("unhandledrejection", (o) => {
14
+ this.handlePromiseError(o);
15
+ }), window.addEventListener("error", (o) => {
16
+ o.target && o.target.tagName && this.handleResourceError(o);
17
+ }, !0);
23
18
  }
24
19
  /**
25
20
  * 处理 JS 运行时错误
26
21
  * @param event - 错误事件对象
27
22
  */
28
- handleJsError(event) {
29
- var _a, _b;
30
- const errorInfo = {
31
- type: (_a = event.error) == null ? void 0 : _a.name,
32
- message: event.message,
23
+ handleJsError(r) {
24
+ var e, s;
25
+ const o = {
26
+ type: (e = r.error) == null ? void 0 : e.name,
27
+ message: r.message,
33
28
  source: {
34
- fileName: event.filename,
35
- lineNumber: event.lineno,
36
- columnNumber: event.colno
29
+ fileName: r.filename,
30
+ lineNumber: r.lineno,
31
+ columnNumber: r.colno
37
32
  },
38
- stack: (_b = event.error) == null ? void 0 : _b.stack,
39
- ...getClientInfo()
33
+ stack: (s = r.error) == null ? void 0 : s.stack,
34
+ ...n()
40
35
  };
41
- if (this.monitor)
42
- this.monitor.emitError(errorInfo);
36
+ this.monitor && this.monitor.emitError(o);
43
37
  }
44
38
  /**
45
39
  * 处理 Promise 异常
46
40
  * @param event - Promise 异常事件对象
47
41
  */
48
- handlePromiseError(event) {
49
- var _a, _b;
50
- const errorInfo = {
42
+ handlePromiseError(r) {
43
+ var e, s;
44
+ const o = {
51
45
  type: "NetworkError",
52
- message: ((_a = event.reason) == null ? void 0 : _a.message) || "Promise Error",
53
- stack: (_b = event.reason) == null ? void 0 : _b.stack,
54
- ...getClientInfo()
46
+ message: ((e = r.reason) == null ? void 0 : e.message) || "Promise Error",
47
+ stack: (s = r.reason) == null ? void 0 : s.stack,
48
+ ...n()
55
49
  };
56
- if (this.monitor)
57
- this.monitor.emitError(errorInfo);
50
+ this.monitor && this.monitor.emitError(o);
58
51
  }
59
52
  /**
60
53
  * 处理资源加载错误
61
54
  * @param event - 资源错误事件对象
62
55
  */
63
- handleResourceError(event) {
64
- const target = event.target;
65
- const errorInfo = {
56
+ handleResourceError(r) {
57
+ const o = r.target, e = {
66
58
  type: "ResourceError",
67
- message: `资源加载失败: ${target.tagName} ${target.src || target.href}`,
68
- ...getClientInfo()
59
+ message: `资源加载失败: ${o.tagName} ${o.src || o.href}`,
60
+ ...n()
69
61
  };
70
- if (this.monitor)
71
- this.monitor.emitError(errorInfo);
62
+ this.monitor && this.monitor.emitError(e);
72
63
  }
73
64
  }
74
65
  export {
75
- BrowserError
66
+ c as BrowserError
76
67
  };
@@ -1,27 +1,25 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- class VueError {
5
- constructor(app) {
6
- __publicField(this, "name", "VueError");
7
- __publicField(this, "app");
8
- this.app = app;
1
+ var c = Object.defineProperty;
2
+ var p = (s, e, a) => e in s ? c(s, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[e] = a;
3
+ var r = (s, e, a) => p(s, typeof e != "symbol" ? e + "" : e, a);
4
+ class o {
5
+ constructor(e) {
6
+ r(this, "name", "VueError");
7
+ r(this, "app");
8
+ this.app = e;
9
9
  }
10
- install(monitor) {
11
- if (monitor.env === "production") {
12
- this.app.config.errorHandler = async (error) => {
13
- const source = await monitor.getErrorSource(error);
14
- console.log(source);
15
- monitor.emitError({
16
- type: error.name,
17
- message: error.message,
18
- stack: error.stack,
19
- source
20
- });
21
- };
22
- }
10
+ install(e) {
11
+ e.env === "production" && (this.app.config.errorHandler = async (a) => {
12
+ const t = await e.getErrorSource(a);
13
+ e.emitError({
14
+ type: a.name,
15
+ message: a.message,
16
+ stack: a.stack,
17
+ source: t,
18
+ level: "error"
19
+ });
20
+ });
23
21
  }
24
22
  }
25
23
  export {
26
- VueError
24
+ o as VueError
27
25
  };
@@ -1,4 +1,4 @@
1
- function getClientInfo() {
1
+ function x() {
2
2
  return {
3
3
  url: window.location.href,
4
4
  userAgent: navigator.userAgent,
@@ -6,112 +6,101 @@ function getClientInfo() {
6
6
  timestamp: Date.now()
7
7
  };
8
8
  }
9
- function stringify(obj, options = {}) {
9
+ function V(i, c = {}) {
10
10
  const {
11
- encode = true,
12
- encodeValuesOnly = false,
13
- arrayFormat = "indices",
14
- skipNulls = false,
15
- delimiter = "&",
16
- strictNullHandling = false,
17
- sort,
18
- filter,
19
- allowDots = false,
20
- serializeDate = (date) => date.toISOString(),
21
- format = "RFC3986",
22
- addQueryPrefix = false,
23
- charset = "utf-8"
24
- } = options;
25
- const parts = [];
26
- const encoder = charset === "iso-8859-1" ? encodeURIComponentISO88591 : encodeURIComponent;
27
- const encodeValue = (value) => encode ? encoder(value) : value;
28
- const processKeyValue = (key, value, prefix = null) => {
29
- const fullKey = prefix ? `${prefix}[${key}]` : key;
30
- if (filter) {
31
- const filtered = filter(fullKey, value);
32
- if (filtered === void 0)
11
+ encode: t = !0,
12
+ encodeValuesOnly: f = !1,
13
+ arrayFormat: p = "indices",
14
+ skipNulls: g = !1,
15
+ delimiter: k = "&",
16
+ strictNullHandling: I = !1,
17
+ sort: w,
18
+ filter: $,
19
+ allowDots: y = !1,
20
+ serializeDate: S = (r) => r.toISOString(),
21
+ format: j = "RFC3986",
22
+ addQueryPrefix: C = !1,
23
+ charset: D = "utf-8"
24
+ } = c, l = [], E = D === "iso-8859-1" ? O : encodeURIComponent, a = (r) => t ? E(r) : r, d = (r, e, b = null) => {
25
+ const o = b ? `${b}[${r}]` : r;
26
+ if ($) {
27
+ const n = $(o, e);
28
+ if (n === void 0)
33
29
  return;
34
- value = filtered;
30
+ e = n;
35
31
  }
36
- if (value === null) {
37
- if (strictNullHandling) {
38
- parts.push(encodeValue(fullKey) + (encodeValuesOnly ? "" : "="));
39
- } else if (!skipNulls) {
40
- parts.push(`${encodeValue(fullKey)}=`);
41
- }
32
+ if (e === null) {
33
+ I ? l.push(a(o) + (f ? "" : "=")) : g || l.push(`${a(o)}=`);
42
34
  return;
43
35
  }
44
- if (typeof value === "boolean" || typeof value === "number") {
45
- value = String(value);
46
- }
47
- if (value instanceof Date) {
48
- value = serializeDate(value);
49
- }
50
- if (Array.isArray(value)) {
51
- if (value.length === 0 && skipNulls)
36
+ if ((typeof e == "boolean" || typeof e == "number") && (e = String(e)), e instanceof Date && (e = S(e)), Array.isArray(e)) {
37
+ if (e.length === 0 && g)
52
38
  return;
53
- switch (arrayFormat) {
39
+ switch (p) {
54
40
  case "indices":
55
- value.forEach((item, i) => {
56
- processKeyValue(String(i), item, fullKey);
41
+ e.forEach((s, u) => {
42
+ d(String(u), s, o);
57
43
  });
58
44
  break;
59
45
  case "brackets":
60
- value.forEach((item) => {
61
- processKeyValue("", item, fullKey);
46
+ e.forEach((s) => {
47
+ d("", s, o);
62
48
  });
63
49
  break;
64
50
  case "repeat":
65
- value.forEach((item) => {
66
- processKeyValue(fullKey, item);
51
+ e.forEach((s) => {
52
+ d(o, s);
67
53
  });
68
54
  break;
69
55
  case "comma":
70
- const commaSeparated = value.join(",");
71
- if (commaSeparated.length > 0) {
72
- parts.push(
73
- `${encodeValue(fullKey)}=${encodeValue(commaSeparated)}`
74
- );
75
- }
56
+ const n = e.join(",");
57
+ n.length > 0 && l.push(
58
+ `${a(o)}=${a(n)}`
59
+ );
76
60
  break;
77
61
  }
78
- } else if (typeof value === "object") {
79
- Object.keys(value).forEach((subKey) => {
80
- const separator = allowDots ? "." : "[";
81
- const suffix = allowDots ? "" : "]";
82
- processKeyValue(
83
- subKey,
84
- value[subKey],
85
- `${fullKey}${separator}${subKey}${suffix}`
62
+ } else if (typeof e == "object")
63
+ Object.keys(e).forEach((n) => {
64
+ const s = y ? "." : "[", u = y ? "" : "]";
65
+ d(
66
+ n,
67
+ e[n],
68
+ `${o}${s}${n}${u}`
86
69
  );
87
70
  });
88
- } else {
89
- const encodedKey = encode && !encodeValuesOnly ? encodeValue(fullKey) : fullKey;
90
- const encodedValue = encodeValue(String(value));
91
- parts.push(`${encodedKey}=${encodedValue}`);
71
+ else {
72
+ const n = t && !f ? a(o) : o, s = a(String(e));
73
+ l.push(`${n}=${s}`);
92
74
  }
93
75
  };
94
- let keys = Object.keys(obj);
95
- if (sort) {
96
- keys = keys.sort(sort);
97
- }
98
- keys.forEach((key) => {
99
- const value = obj[key];
100
- processKeyValue(key, value);
76
+ let m = Object.keys(i);
77
+ w && (m = m.sort(w)), m.forEach((r) => {
78
+ const e = i[r];
79
+ d(r, e);
101
80
  });
102
- let result = parts.join(delimiter);
103
- if (addQueryPrefix && result.length > 0) {
104
- result = `?${result}`;
105
- }
106
- return result;
81
+ let h = l.join(k);
82
+ return C && h.length > 0 && (h = `?${h}`), h;
107
83
  }
108
- function encodeURIComponentISO88591(str) {
109
- return encodeURIComponent(str).replace(/%[0-9A-F]{2}/g, (match) => {
110
- const code = Number.parseInt(match.substring(1), 16);
111
- return code >= 128 && code <= 255 ? String.fromCharCode(code) : match;
84
+ function O(i) {
85
+ return encodeURIComponent(i).replace(/%[0-9A-F]{2}/g, (c) => {
86
+ const t = Number.parseInt(c.substring(1), 16);
87
+ return t >= 128 && t <= 255 ? String.fromCharCode(t) : c;
112
88
  });
113
89
  }
90
+ function A(i, c = Date.now()) {
91
+ if (i.length !== 66)
92
+ throw new Error("BASE66_CHARS must contain exactly 66 characters");
93
+ let t = c, f = "";
94
+ if (t === 0)
95
+ return i[0];
96
+ for (; t > 0; ) {
97
+ const p = t % 66;
98
+ f = i[p] + f, t = Math.floor(t / 66);
99
+ }
100
+ return f;
101
+ }
114
102
  export {
115
- getClientInfo,
116
- stringify
103
+ x as getClientInfo,
104
+ V as stringify,
105
+ A as timestampToBase66
117
106
  };