@substrate-system/debug 0.9.15 → 0.9.18
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 +17 -1
- package/dist/browser/index.cjs.map +2 -2
- package/dist/browser/index.d.ts +1 -4
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/browser/index.min.cjs.map +2 -2
- package/dist/browser/index.min.js.map +2 -2
- package/dist/cloudflare/index.cjs +136 -149
- package/dist/cloudflare/index.cjs.map +4 -4
- package/dist/cloudflare/index.d.ts +3 -5
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +134 -160
- package/dist/cloudflare/index.js.map +4 -4
- package/dist/cloudflare/index.min.cjs +1 -1
- package/dist/cloudflare/index.min.cjs.map +4 -4
- package/dist/cloudflare/index.min.js +1 -1
- package/dist/cloudflare/index.min.js.map +4 -4
- package/dist/common.d.ts +4 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/meta.json +2 -2
- package/dist/node.cjs.map +2 -2
- package/dist/node.js.map +2 -2
- package/dist/node.min.cjs +3 -3
- package/dist/node.min.cjs.map +2 -2
- package/dist/node.min.js.map +2 -2
- package/dist/noop.d.ts +1 -1
- package/dist/noop.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cloudflare/index.js
CHANGED
|
@@ -1,153 +1,122 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
3
|
|
|
28
|
-
//
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return parse(val);
|
|
43
|
-
} else if (type === "number" && isFinite(val)) {
|
|
44
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
45
|
-
}
|
|
46
|
-
throw new Error(
|
|
47
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
function parse(str) {
|
|
51
|
-
str = String(str);
|
|
52
|
-
if (str.length > 100) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
56
|
-
str
|
|
57
|
-
);
|
|
58
|
-
if (!match) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
var n = parseFloat(match[1]);
|
|
62
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
63
|
-
switch (type) {
|
|
64
|
-
case "years":
|
|
65
|
-
case "year":
|
|
66
|
-
case "yrs":
|
|
67
|
-
case "yr":
|
|
68
|
-
case "y":
|
|
69
|
-
return n * y;
|
|
70
|
-
case "weeks":
|
|
71
|
-
case "week":
|
|
72
|
-
case "w":
|
|
73
|
-
return n * w;
|
|
74
|
-
case "days":
|
|
75
|
-
case "day":
|
|
76
|
-
case "d":
|
|
77
|
-
return n * d;
|
|
78
|
-
case "hours":
|
|
79
|
-
case "hour":
|
|
80
|
-
case "hrs":
|
|
81
|
-
case "hr":
|
|
82
|
-
case "h":
|
|
83
|
-
return n * h;
|
|
84
|
-
case "minutes":
|
|
85
|
-
case "minute":
|
|
86
|
-
case "mins":
|
|
87
|
-
case "min":
|
|
88
|
-
case "m":
|
|
89
|
-
return n * m;
|
|
90
|
-
case "seconds":
|
|
91
|
-
case "second":
|
|
92
|
-
case "secs":
|
|
93
|
-
case "sec":
|
|
94
|
-
case "s":
|
|
95
|
-
return n * s;
|
|
96
|
-
case "milliseconds":
|
|
97
|
-
case "millisecond":
|
|
98
|
-
case "msecs":
|
|
99
|
-
case "msec":
|
|
100
|
-
case "ms":
|
|
101
|
-
return n;
|
|
102
|
-
default:
|
|
103
|
-
return void 0;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
__name(parse, "parse");
|
|
107
|
-
function fmtShort(ms) {
|
|
108
|
-
var msAbs = Math.abs(ms);
|
|
109
|
-
if (msAbs >= d) {
|
|
110
|
-
return Math.round(ms / d) + "d";
|
|
111
|
-
}
|
|
112
|
-
if (msAbs >= h) {
|
|
113
|
-
return Math.round(ms / h) + "h";
|
|
114
|
-
}
|
|
115
|
-
if (msAbs >= m) {
|
|
116
|
-
return Math.round(ms / m) + "m";
|
|
117
|
-
}
|
|
118
|
-
if (msAbs >= s) {
|
|
119
|
-
return Math.round(ms / s) + "s";
|
|
120
|
-
}
|
|
121
|
-
return ms + "ms";
|
|
122
|
-
}
|
|
123
|
-
__name(fmtShort, "fmtShort");
|
|
124
|
-
function fmtLong(ms) {
|
|
125
|
-
var msAbs = Math.abs(ms);
|
|
126
|
-
if (msAbs >= d) {
|
|
127
|
-
return plural(ms, msAbs, d, "day");
|
|
128
|
-
}
|
|
129
|
-
if (msAbs >= h) {
|
|
130
|
-
return plural(ms, msAbs, h, "hour");
|
|
131
|
-
}
|
|
132
|
-
if (msAbs >= m) {
|
|
133
|
-
return plural(ms, msAbs, m, "minute");
|
|
134
|
-
}
|
|
135
|
-
if (msAbs >= s) {
|
|
136
|
-
return plural(ms, msAbs, s, "second");
|
|
137
|
-
}
|
|
138
|
-
return ms + " ms";
|
|
139
|
-
}
|
|
140
|
-
__name(fmtLong, "fmtLong");
|
|
141
|
-
function plural(ms, msAbs, n, name) {
|
|
142
|
-
var isPlural = msAbs >= n * 1.5;
|
|
143
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
144
|
-
}
|
|
145
|
-
__name(plural, "plural");
|
|
4
|
+
// src/ms.ts
|
|
5
|
+
var s = 1e3;
|
|
6
|
+
var m = s * 60;
|
|
7
|
+
var h = m * 60;
|
|
8
|
+
var d = h * 24;
|
|
9
|
+
var w = d * 7;
|
|
10
|
+
var y = d * 365.25;
|
|
11
|
+
function ms_default(val, options = {}) {
|
|
12
|
+
options = options || {};
|
|
13
|
+
const type = typeof val;
|
|
14
|
+
if (type === "string" && val.length > 0) {
|
|
15
|
+
return parse(val);
|
|
16
|
+
} else if (type === "number" && isFinite(val)) {
|
|
17
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
146
18
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
19
|
+
throw new Error(
|
|
20
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
__name(ms_default, "default");
|
|
24
|
+
function parse(str) {
|
|
25
|
+
str = String(str);
|
|
26
|
+
if (str.length > 100) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
30
|
+
str
|
|
31
|
+
);
|
|
32
|
+
if (!match) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const n = parseFloat(match[1]);
|
|
36
|
+
const type = (match[2] || "ms").toLowerCase();
|
|
37
|
+
switch (type) {
|
|
38
|
+
case "years":
|
|
39
|
+
case "year":
|
|
40
|
+
case "yrs":
|
|
41
|
+
case "yr":
|
|
42
|
+
case "y":
|
|
43
|
+
return n * y;
|
|
44
|
+
case "weeks":
|
|
45
|
+
case "week":
|
|
46
|
+
case "w":
|
|
47
|
+
return n * w;
|
|
48
|
+
case "days":
|
|
49
|
+
case "day":
|
|
50
|
+
case "d":
|
|
51
|
+
return n * d;
|
|
52
|
+
case "hours":
|
|
53
|
+
case "hour":
|
|
54
|
+
case "hrs":
|
|
55
|
+
case "hr":
|
|
56
|
+
case "h":
|
|
57
|
+
return n * h;
|
|
58
|
+
case "minutes":
|
|
59
|
+
case "minute":
|
|
60
|
+
case "mins":
|
|
61
|
+
case "min":
|
|
62
|
+
case "m":
|
|
63
|
+
return n * m;
|
|
64
|
+
case "seconds":
|
|
65
|
+
case "second":
|
|
66
|
+
case "secs":
|
|
67
|
+
case "sec":
|
|
68
|
+
case "s":
|
|
69
|
+
return n * s;
|
|
70
|
+
case "milliseconds":
|
|
71
|
+
case "millisecond":
|
|
72
|
+
case "msecs":
|
|
73
|
+
case "msec":
|
|
74
|
+
case "ms":
|
|
75
|
+
return n;
|
|
76
|
+
default:
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
__name(parse, "parse");
|
|
81
|
+
function fmtShort(ms) {
|
|
82
|
+
const msAbs = Math.abs(ms);
|
|
83
|
+
if (msAbs >= d) {
|
|
84
|
+
return Math.round(ms / d) + "d";
|
|
85
|
+
}
|
|
86
|
+
if (msAbs >= h) {
|
|
87
|
+
return Math.round(ms / h) + "h";
|
|
88
|
+
}
|
|
89
|
+
if (msAbs >= m) {
|
|
90
|
+
return Math.round(ms / m) + "m";
|
|
91
|
+
}
|
|
92
|
+
if (msAbs >= s) {
|
|
93
|
+
return Math.round(ms / s) + "s";
|
|
94
|
+
}
|
|
95
|
+
return ms + "ms";
|
|
96
|
+
}
|
|
97
|
+
__name(fmtShort, "fmtShort");
|
|
98
|
+
function fmtLong(ms) {
|
|
99
|
+
const msAbs = Math.abs(ms);
|
|
100
|
+
if (msAbs >= d) {
|
|
101
|
+
return plural(ms, msAbs, d, "day");
|
|
102
|
+
}
|
|
103
|
+
if (msAbs >= h) {
|
|
104
|
+
return plural(ms, msAbs, h, "hour");
|
|
105
|
+
}
|
|
106
|
+
if (msAbs >= m) {
|
|
107
|
+
return plural(ms, msAbs, m, "minute");
|
|
108
|
+
}
|
|
109
|
+
if (msAbs >= s) {
|
|
110
|
+
return plural(ms, msAbs, s, "second");
|
|
111
|
+
}
|
|
112
|
+
return ms + " ms";
|
|
113
|
+
}
|
|
114
|
+
__name(fmtLong, "fmtLong");
|
|
115
|
+
function plural(ms, msAbs, n, name) {
|
|
116
|
+
const isPlural = msAbs >= n * 1.5;
|
|
117
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
118
|
+
}
|
|
119
|
+
__name(plural, "plural");
|
|
151
120
|
|
|
152
121
|
// src/common.ts
|
|
153
122
|
function coerce(val) {
|
|
@@ -202,10 +171,8 @@ var colors = [
|
|
|
202
171
|
"#666666"
|
|
203
172
|
];
|
|
204
173
|
var index_default = createDebug;
|
|
205
|
-
function isEnabled(namespace,
|
|
206
|
-
|
|
207
|
-
const DEBUG = typeof globalThis !== "undefined" && globalThis.DEBUG || typeof process !== "undefined" && process.env?.DEBUG;
|
|
208
|
-
if (DEBUG === "*") return true;
|
|
174
|
+
function isEnabled(namespace, env) {
|
|
175
|
+
const DEBUG = env?.DEBUG || typeof globalThis !== "undefined" && globalThis.DEBUG || typeof process !== "undefined" && process.env?.DEBUG;
|
|
209
176
|
if (namespace === "DEV") {
|
|
210
177
|
if (!DEBUG) {
|
|
211
178
|
return true;
|
|
@@ -213,6 +180,7 @@ function isEnabled(namespace, forcedEnabled) {
|
|
|
213
180
|
return false;
|
|
214
181
|
}
|
|
215
182
|
if (!DEBUG) return false;
|
|
183
|
+
if (DEBUG === "*") return true;
|
|
216
184
|
const envVars = createRegexFromEnvVar(DEBUG);
|
|
217
185
|
return envVars.some((regex) => regex.test(namespace));
|
|
218
186
|
}
|
|
@@ -229,9 +197,9 @@ function createFormatters() {
|
|
|
229
197
|
};
|
|
230
198
|
}
|
|
231
199
|
__name(createFormatters, "createFormatters");
|
|
232
|
-
function logger(namespace, args, { prevTime, color },
|
|
200
|
+
function logger(namespace, args, { prevTime, color }, env) {
|
|
233
201
|
args = args || [];
|
|
234
|
-
if (!isEnabled(namespace,
|
|
202
|
+
if (!isEnabled(namespace, env)) return;
|
|
235
203
|
const curr = Number(/* @__PURE__ */ new Date());
|
|
236
204
|
const diff = curr - (prevTime || curr);
|
|
237
205
|
prevTime = curr;
|
|
@@ -267,30 +235,36 @@ function shouldUseColors() {
|
|
|
267
235
|
}
|
|
268
236
|
__name(shouldUseColors, "shouldUseColors");
|
|
269
237
|
function formatArgs({ diff, namespace }, args) {
|
|
270
|
-
args[0] = namespace + " " + args[0] + " +" + (
|
|
238
|
+
args[0] = namespace + " " + args[0] + " +" + ms_default(diff, {});
|
|
271
239
|
return args;
|
|
272
240
|
}
|
|
273
241
|
__name(formatArgs, "formatArgs");
|
|
274
|
-
function createDebug(
|
|
275
|
-
if (
|
|
242
|
+
function createDebug(namespaceOrEnabled, env) {
|
|
243
|
+
if (typeof namespaceOrEnabled === "boolean") {
|
|
244
|
+
if (namespaceOrEnabled === false) return noop;
|
|
245
|
+
return createDebug("DEV", { DEBUG: "*" });
|
|
246
|
+
}
|
|
276
247
|
const prevTime = Number(/* @__PURE__ */ new Date());
|
|
277
248
|
const color = selectColor(
|
|
278
|
-
typeof
|
|
249
|
+
typeof namespaceOrEnabled === "string" ? namespaceOrEnabled : generateRandomString(10),
|
|
279
250
|
colors
|
|
280
251
|
);
|
|
281
|
-
const
|
|
282
|
-
|
|
252
|
+
const actualNamespace = typeof namespaceOrEnabled === "string" ? namespaceOrEnabled : "DEV";
|
|
253
|
+
let envObj;
|
|
254
|
+
if (typeof env === "object") {
|
|
255
|
+
envObj = env;
|
|
256
|
+
}
|
|
283
257
|
const debug = /* @__PURE__ */ __name(function(...args) {
|
|
284
258
|
return logger(
|
|
285
259
|
actualNamespace,
|
|
286
260
|
args,
|
|
287
261
|
{ prevTime, color },
|
|
288
|
-
|
|
262
|
+
envObj
|
|
289
263
|
);
|
|
290
264
|
}, "debug");
|
|
291
265
|
debug.extend = function(extension) {
|
|
292
266
|
const extendedNamespace = actualNamespace + ":" + extension;
|
|
293
|
-
return createDebug(extendedNamespace);
|
|
267
|
+
return createDebug(extendedNamespace, envObj);
|
|
294
268
|
};
|
|
295
269
|
return debug;
|
|
296
270
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../
|
|
4
|
-
"sourcesContent": ["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n", "import humanize from 'ms'\nimport {\n generateRandomString,\n coerce,\n selectColor,\n createRegexFromEnvVar\n} from '../common.js'\nimport { noop } from '../noop.js'\n\n// Cloudflare Workers have a limited set of Web APIs\n// No localStorage, document, or navigator\nconst log = console.log || (() => {})\n\n// Simple color palette for Cloudflare Workers (no DOM-based colors)\nconst colors = [\n '#0066CC', '#CC0066', '#66CC00', '#CC6600', '#6600CC', '#00CC66',\n '#CC0000', '#0000CC', '#00CCCC', '#CCCC00', '#CC00CC', '#666666'\n]\n\nexport { createDebug }\nexport default createDebug\n\n/**\n * Check if the given namespace is enabled in Cloudflare Workers.\n * Since there's no localStorage, we check environment variables or global DEBUG.\n * `namespace` is the name that is passed into debug.\n * `forcedEnabled` is a boolean that forces logging when true.\n */\nfunction isEnabled (namespace: string, forcedEnabled?: boolean): boolean {\n // If explicitly forced to be enabled via boolean true\n if (forcedEnabled === true) return true\n\n // In Cloudflare Workers, check global DEBUG variable or environment\n const DEBUG = (typeof globalThis !== 'undefined' && (globalThis as any).DEBUG) ||\n (typeof process !== 'undefined' && process.env?.DEBUG)\n\n // Check for wildcard\n if (DEBUG === '*') return true\n\n // if we were not called with a namespace\n if (namespace === 'DEV') {\n // We want to log iff there is no DEBUG variable.\n if (!DEBUG) {\n return true\n }\n return false\n }\n\n // No DEBUG variable set\n if (!DEBUG) return false\n\n const envVars = createRegexFromEnvVar(DEBUG)\n return envVars.some(regex => regex.test(namespace))\n}\n\n/**\n * Map %j to `JSON.stringify()`, since Cloudflare Workers don't have Web Inspectors.\n */\nfunction createFormatters () {\n return {\n j: function (v: any) {\n try {\n return JSON.stringify(v)\n } catch (error) {\n return '[UnexpectedJSONParseError]: ' + String(error)\n }\n }\n }\n}\n\nfunction logger (\n namespace: string,\n args: any[],\n { prevTime, color },\n forcedEnabled?: boolean\n) {\n args = args || []\n if (!isEnabled(namespace, forcedEnabled)) return\n\n // Set `diff` timestamp\n const curr = Number(new Date())\n const diff = curr - (prevTime || curr)\n prevTime = curr\n\n args[0] = coerce(args[0])\n const formatters = createFormatters()\n\n if (typeof args[0] !== 'string') {\n // Anything else let's inspect with %O\n args.unshift('%O')\n }\n\n // Apply any `formatters` transformations\n let index = 0\n args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n // If we encounter an escaped %, then don't increase the\n // array index\n if (match === '%%') return '%'\n\n index++\n\n const formatter = formatters[format]\n if (typeof formatter === 'function') {\n const val = args[index]\n match = formatter.call(globalThis, val)\n\n // Now we need to remove `args[index]` since it's inlined\n // in the `format`\n args.splice(index, 1)\n index--\n }\n return match\n })\n\n // Apply Cloudflare-specific formatting (no colors in Workers typically)\n const _args = formatArgs({\n diff,\n color,\n useColors: shouldUseColors(),\n namespace\n }, args)\n\n log(..._args)\n}\n\nfunction shouldUseColors (): boolean {\n // Cloudflare Workers typically don't support colors in console output\n // But we can detect if we're in a development environment\n return false\n}\n\n/**\n * Format log arguments for Cloudflare Workers (no color support typically).\n */\nfunction formatArgs ({ diff, namespace }: {\n diff: number,\n color: number,\n namespace: string,\n useColors: boolean\n}, args) {\n args[0] = namespace + ' ' + args[0] + ' +' + humanize(diff, {})\n return args\n}\n\nexport type CloudflareDebugger = {\n (...args: any[]): void;\n extend: (namespace: string) => CloudflareDebugger;\n}\n\nfunction createDebug (namespace?: string | boolean): CloudflareDebugger {\n if (namespace === false) return noop\n const prevTime = Number(new Date())\n const color = selectColor(\n typeof namespace === 'string' ? namespace : generateRandomString(10),\n colors\n )\n\n // Determine if this is a boolean true passed as the namespace\n const forcedEnabled = namespace === true\n const actualNamespace = typeof namespace === 'string' ? namespace : 'DEV'\n\n const debug = function (...args: any[]) {\n return logger(\n actualNamespace,\n args,\n { prevTime, color },\n forcedEnabled\n )\n }\n\n debug.extend = function (extension: string): CloudflareDebugger {\n const extendedNamespace = actualNamespace + ':' + extension\n return createDebug(extendedNamespace)\n }\n\n return debug as CloudflareDebugger\n}\n", "/**\n* Coerce `val`.\n*\n* @param {unknown} val\n* @return {string}\n*/\nexport function coerce (val:unknown):string {\n if (val instanceof Error) {\n return val.stack || val.message\n }\n\n return String(val)\n}\n\n/**\n * Selects a color for a debug namespace\n * @param {string} namespace The namespace string for the debug instance to be colored\n * @return {number|string} An ANSI color code for the given namespace\n */\nexport function selectColor (\n namespace:string,\n colors:string[]|number[]\n):number|string {\n let hash = 0\n\n for (let i = 0; i < namespace.length; i++) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i)\n hash |= 0 // Convert to 32bit integer\n }\n\n return colors[Math.abs(hash) % colors.length]\n}\n\nexport function createRegexFromEnvVar (names:string):RegExp[] {\n const split = names.split(/[\\s,]+/).filter(Boolean)\n const regexs = split\n .map(word => word.replace(/\\*/g, '.*?'))\n .map(r => new RegExp('^' + r + '$'))\n\n return regexs\n}\n\n/**\n * Use this to create a random namespace in the case that `debug`\n * is called without any arguments.\n * @param {number} length Lenght of the random string\n * @returns {string}\n */\nexport function generateRandomString (length = 6):string {\n return Math.random().toString(20).substring(2, length)\n}\n", "import { type Debugger } from './browser/index.js'\n\nexport const noop:Debugger = function (_args:any[]) {}\nnoop.extend = function (_namespace:string) { return noop }\n\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["colors"
|
|
3
|
+
"sources": ["../../src/ms.ts", "../../src/common.ts", "../../src/noop.ts", "../../src/cloudflare/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Helpers.\n */\n\nconst s = 1000\nconst m = s * 60\nconst h = m * 60\nconst d = h * 24\nconst w = d * 7\nconst y = d * 365.25\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nexport default function (val, options:{ long?:boolean } = {}) {\n options = options || {}\n const type = typeof val\n if (type === 'string' && val.length > 0) {\n return parse(val)\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val)\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n )\n}\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse (str) {\n str = String(str)\n if (str.length > 100) {\n return\n }\n const match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n )\n if (!match) {\n return\n }\n const n = parseFloat(match[1])\n const type = (match[2] || 'ms').toLowerCase()\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y\n case 'weeks':\n case 'week':\n case 'w':\n return n * w\n case 'days':\n case 'day':\n case 'd':\n return n * d\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n\n default:\n return undefined\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort (ms) {\n const msAbs = Math.abs(ms)\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd'\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h'\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm'\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's'\n }\n return ms + 'ms'\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong (ms) {\n const msAbs = Math.abs(ms)\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day')\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour')\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute')\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second')\n }\n return ms + ' ms'\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural (ms, msAbs, n, name) {\n const isPlural = msAbs >= n * 1.5\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '')\n}\n", "/**\n* Coerce `val`.\n*\n* @param {unknown} val\n* @return {string}\n*/\nexport function coerce (val:unknown):string {\n if (val instanceof Error) {\n return val.stack || val.message\n }\n\n return String(val)\n}\n\n/**\n * Selects a color for a debug namespace\n * @param {string} namespace The namespace string for the debug instance to be colored\n * @return {number|string} An ANSI color code for the given namespace\n */\nexport function selectColor (\n namespace:string,\n colors:string[]|number[]\n):number|string {\n let hash = 0\n\n for (let i = 0; i < namespace.length; i++) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i)\n hash |= 0 // Convert to 32bit integer\n }\n\n return colors[Math.abs(hash) % colors.length]\n}\n\nexport function createRegexFromEnvVar (names:string):RegExp[] {\n const split = names.split(/[\\s,]+/).filter(Boolean)\n const regexs = split\n .map(word => word.replace(/\\*/g, '.*?'))\n .map(r => new RegExp('^' + r + '$'))\n\n return regexs\n}\n\nexport type Debugger = {\n (...args: any[]): void;\n extend: (namespace: string) => Debugger;\n}\n\n/**\n * Use this to create a random namespace in the case that `debug`\n * is called without any arguments.\n * @param {number} length Lenght of the random string\n * @returns {string}\n */\nexport function generateRandomString (length = 6):string {\n return Math.random().toString(20).substring(2, length)\n}\n", "import { type Debugger } from './common.js'\n\nexport const noop:Debugger = function (_args:any[]) {}\nnoop.extend = function (_namespace:string) { return noop }\n\n", "import humanize from '../ms.js'\nimport {\n generateRandomString,\n coerce,\n selectColor,\n createRegexFromEnvVar,\n type Debugger\n} from '../common.js'\nimport { noop } from '../noop.js'\n\n// Cloudflare Workers have a limited set of Web APIs\n// No localStorage, document, or navigator\nconst log = console.log || (() => {})\n\n// Simple color palette for Cloudflare Workers (no DOM-based colors)\nconst colors = [\n '#0066CC', '#CC0066', '#66CC00', '#CC6600', '#6600CC', '#00CC66',\n '#CC0000', '#0000CC', '#00CCCC', '#CCCC00', '#CC00CC', '#666666'\n]\n\nexport { createDebug }\nexport default createDebug\n\n/**\n * Check if the given namespace is enabled in Cloudflare Workers.\n * Since there's no localStorage, we check environment variables or global DEBUG.\n * `namespace` is the name that is passed into debug.\n * `env` is an optional environment object that can contain DEBUG setting.\n */\nfunction isEnabled (namespace:string, env?:Record<string, string>):boolean {\n // Determine the DEBUG value from env parameter, global, or process.env\n const DEBUG = env?.DEBUG ||\n (typeof globalThis !== 'undefined' && (globalThis as any).DEBUG) ||\n (typeof process !== 'undefined' && process.env?.DEBUG)\n\n // If no namespace (DEV mode), check if there's no DEBUG variable\n if (namespace === 'DEV') {\n // We want to log iff there is no DEBUG variable.\n if (!DEBUG) {\n return true\n }\n return false\n }\n\n // No DEBUG variable set\n if (!DEBUG) return false\n\n // Check for wildcard\n if (DEBUG === '*') return true\n\n // Check namespace vs DEBUG env var\n const envVars = createRegexFromEnvVar(DEBUG)\n return envVars.some(regex => regex.test(namespace))\n}\n\n/**\n * Map %j to `JSON.stringify()`, since Cloudflare Workers don't\n * have Web Inspectors.\n */\nfunction createFormatters () {\n return {\n j: function (v:any) {\n try {\n return JSON.stringify(v)\n } catch (error) {\n return '[UnexpectedJSONParseError]: ' + String(error)\n }\n }\n }\n}\n\nfunction logger (\n namespace:string,\n args:any[],\n { prevTime, color },\n env?:Record<string, string>\n) {\n args = args || []\n if (!isEnabled(namespace, env)) return\n\n // Set `diff` timestamp\n const curr = Number(new Date())\n const diff = curr - (prevTime || curr)\n prevTime = curr\n\n args[0] = coerce(args[0])\n const formatters = createFormatters()\n\n if (typeof args[0] !== 'string') {\n // Anything else let's inspect with %O\n args.unshift('%O')\n }\n\n // Apply any `formatters` transformations\n let index = 0\n args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n // If we encounter an escaped %, then don't increase the\n // array index\n if (match === '%%') return '%'\n\n index++\n\n const formatter = formatters[format]\n if (typeof formatter === 'function') {\n const val = args[index]\n match = formatter.call(globalThis, val)\n\n // Now we need to remove `args[index]` since it's inlined\n // in the `format`\n args.splice(index, 1)\n index--\n }\n return match\n })\n\n // Apply Cloudflare-specific formatting (no colors in Workers typically)\n const _args = formatArgs({\n diff,\n color,\n useColors: shouldUseColors(),\n namespace\n }, args)\n\n log(..._args)\n}\n\nfunction shouldUseColors ():boolean {\n // Cloudflare Workers typically don't support colors in console output\n // But we can detect if we're in a development environment\n return false\n}\n\n/**\n * Format log arguments for Cloudflare Workers (no color support typically).\n * Mutates the given args.\n */\nfunction formatArgs ({ diff, namespace }:{\n diff:number,\n color:number,\n namespace:string,\n useColors:boolean\n}, args:string[]) {\n args[0] = namespace + ' ' + args[0] + ' +' + humanize(diff, {})\n return args\n}\n\nfunction createDebug (namespace?:string, env?:Record<string, string>):Debugger;\nfunction createDebug (enabled:boolean):Debugger;\nfunction createDebug (\n namespaceOrEnabled?:string|boolean,\n env?:Record<string, string>\n):Debugger {\n // Handle the case where first parameter is a boolean\n if (typeof namespaceOrEnabled === 'boolean') {\n if (namespaceOrEnabled === false) return noop\n // If namespaceOrEnabled is true, use DEV mode with forced logging\n return createDebug('DEV', { DEBUG: '*' })\n }\n\n const prevTime = Number(new Date())\n const color = selectColor(\n typeof namespaceOrEnabled === 'string' ?\n namespaceOrEnabled :\n generateRandomString(10),\n colors\n )\n\n const actualNamespace = typeof namespaceOrEnabled === 'string' ?\n namespaceOrEnabled :\n 'DEV'\n\n // Handle environment parameter\n let envObj:Record<string, string>|undefined\n if (typeof env === 'object') {\n envObj = env\n }\n\n const debug = function (...args:any[]) {\n return logger(\n actualNamespace,\n args,\n { prevTime, color },\n envObj\n )\n }\n\n debug.extend = function (extension:string):Debugger {\n const extendedNamespace = actualNamespace + ':' + extension\n return createDebug(extendedNamespace, envObj)\n }\n\n return debug\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAIA,IAAM,IAAI;AACV,IAAM,IAAI,IAAI;AACd,IAAM,IAAI,IAAI;AACd,IAAM,IAAI,IAAI;AACd,IAAM,IAAI,IAAI;AACd,IAAM,IAAI,IAAI;AAgBC,SAAR,WAAkB,KAAK,UAA4B,CAAC,GAAG;AAC1D,YAAU,WAAW,CAAC;AACtB,QAAM,OAAO,OAAO;AACpB,MAAI,SAAS,YAAY,IAAI,SAAS,GAAG;AACrC,WAAO,MAAM,GAAG;AAAA,EACpB,WAAW,SAAS,YAAY,SAAS,GAAG,GAAG;AAC3C,WAAO,QAAQ,OAAO,QAAQ,GAAG,IAAI,SAAS,GAAG;AAAA,EACrD;AACA,QAAM,IAAI;AAAA,IACN,0DACF,KAAK,UAAU,GAAG;AAAA,EACpB;AACJ;AAZO;AAsBP,SAAS,MAAO,KAAK;AACjB,QAAM,OAAO,GAAG;AAChB,MAAI,IAAI,SAAS,KAAK;AAClB;AAAA,EACJ;AACA,QAAM,QAAQ,mIAAmI;AAAA,IAC7I;AAAA,EACJ;AACA,MAAI,CAAC,OAAO;AACR;AAAA,EACJ;AACA,QAAM,IAAI,WAAW,MAAM,CAAC,CAAC;AAC7B,QAAM,QAAQ,MAAM,CAAC,KAAK,MAAM,YAAY;AAC5C,UAAQ,MAAM;AAAA,IACV,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KA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EA,SAAO;AACX;AA5CS;",
|
|
6
|
+
"names": ["colors"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var t=(e,n)=>f(e,"name",{value:n,configurable:!0});var N=(e,n)=>{for(var r in n)f(e,r,{get:n[r],enumerable:!0})},U=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of S(n))!M.call(e,o)&&o!==r&&f(e,o,{get:()=>n[o],enumerable:!(s=R(n,o))||s.enumerable});return e};var V=e=>U(f({},"__esModule",{value:!0}),e);var L={};N(L,{createDebug:()=>l,default:()=>j});module.exports=V(L);function p(e,n={}){n=n||{};let r=typeof e;if(r==="string"&&e.length>0)return B(e);if(r==="number"&&isFinite(e))return n.long?A(e):k(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}t(p,"default");function B(e){if(e=String(e),e.length>100)return;let n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!n)return;let r=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}t(B,"parse");function k(e){let n=Math.abs(e);return n>=864e5?Math.round(e/864e5)+"d":n>=36e5?Math.round(e/36e5)+"h":n>=6e4?Math.round(e/6e4)+"m":n>=1e3?Math.round(e/1e3)+"s":e+"ms"}t(k,"fmtShort");function A(e){let n=Math.abs(e);return n>=864e5?g(e,n,864e5,"day"):n>=36e5?g(e,n,36e5,"hour"):n>=6e4?g(e,n,6e4,"minute"):n>=1e3?g(e,n,1e3,"second"):e+" ms"}t(A,"fmtLong");function g(e,n,r,s){let o=n>=r*1.5;return Math.round(e/r)+" "+s+(o?"s":"")}t(g,"plural");function y(e){return e instanceof Error?e.stack||e.message:String(e)}t(y,"coerce");function b(e,n){let r=0;for(let s=0;s<e.length;s++)r=(r<<5)-r+e.charCodeAt(s),r|=0;return n[Math.abs(r)%n.length]}t(b,"selectColor");function C(e){return e.split(/[\s,]+/).filter(Boolean).map(s=>s.replace(/\*/g,".*?")).map(s=>new RegExp("^"+s+"$"))}t(C,"createRegexFromEnvVar");function x(e=6){return Math.random().toString(20).substring(2,e)}t(x,"generateRandomString");var d=t(function(e){},"noop");d.extend=function(e){return d};var F=console.log||(()=>{}),G=["#0066CC","#CC0066","#66CC00","#CC6600","#6600CC","#00CC66","#CC0000","#0000CC","#00CCCC","#CCCC00","#CC00CC","#666666"];var j=l;function J(e,n){let r=n?.DEBUG||typeof globalThis<"u"&&globalThis.DEBUG||typeof process<"u"&&process.env?.DEBUG;return e==="DEV"?!r:r?r==="*"?!0:C(r).some(o=>o.test(e)):!1}t(J,"isEnabled");function T(){return{j:t(function(e){try{return JSON.stringify(e)}catch(n){return"[UnexpectedJSONParseError]: "+String(n)}},"j")}}t(T,"createFormatters");function _(e,n,{prevTime:r,color:s},o){if(n=n||[],!J(e,o))return;let c=Number(new Date),a=c-(r||c);r=c,n[0]=y(n[0]);let u=T();typeof n[0]!="string"&&n.unshift("%O");let i=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,(m,w)=>{if(m==="%%")return"%";i++;let h=u[w];if(typeof h=="function"){let E=n[i];m=h.call(globalThis,E),n.splice(i,1),i--}return m});let D=z({diff:a,color:s,useColors:v(),namespace:e},n);F(...D)}t(_,"logger");function v(){return!1}t(v,"shouldUseColors");function z({diff:e,namespace:n},r){return r[0]=n+" "+r[0]+" +"+p(e,{}),r}t(z,"formatArgs");function l(e,n){if(typeof e=="boolean")return e===!1?d:l("DEV",{DEBUG:"*"});let r=Number(new Date),s=b(typeof e=="string"?e:x(10),G),o=typeof e=="string"?e:"DEV",c;typeof n=="object"&&(c=n);let a=t(function(...u){return _(o,u,{prevTime:r,color:s},c)},"debug");return a.extend=function(u){let i=o+":"+u;return l(i,c)},a}t(l,"createDebug");
|
|
2
2
|
//# sourceMappingURL=index.min.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../
|
|
4
|
-
"sourcesContent": ["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n", "import humanize from 'ms'\nimport {\n generateRandomString,\n coerce,\n selectColor,\n createRegexFromEnvVar\n} from '../common.js'\nimport { noop } from '../noop.js'\n\n// Cloudflare Workers have a limited set of Web APIs\n// No localStorage, document, or navigator\nconst log = console.log || (() => {})\n\n// Simple color palette for Cloudflare Workers (no DOM-based colors)\nconst colors = [\n '#0066CC', '#CC0066', '#66CC00', '#CC6600', '#6600CC', '#00CC66',\n '#CC0000', '#0000CC', '#00CCCC', '#CCCC00', '#CC00CC', '#666666'\n]\n\nexport { createDebug }\nexport default createDebug\n\n/**\n * Check if the given namespace is enabled in Cloudflare Workers.\n * Since there's no localStorage, we check environment variables or global DEBUG.\n * `namespace` is the name that is passed into debug.\n * `forcedEnabled` is a boolean that forces logging when true.\n */\nfunction isEnabled (namespace: string, forcedEnabled?: boolean): boolean {\n // If explicitly forced to be enabled via boolean true\n if (forcedEnabled === true) return true\n\n // In Cloudflare Workers, check global DEBUG variable or environment\n const DEBUG = (typeof globalThis !== 'undefined' && (globalThis as any).DEBUG) ||\n (typeof process !== 'undefined' && process.env?.DEBUG)\n\n // Check for wildcard\n if (DEBUG === '*') return true\n\n // if we were not called with a namespace\n if (namespace === 'DEV') {\n // We want to log iff there is no DEBUG variable.\n if (!DEBUG) {\n return true\n }\n return false\n }\n\n // No DEBUG variable set\n if (!DEBUG) return false\n\n const envVars = createRegexFromEnvVar(DEBUG)\n return envVars.some(regex => regex.test(namespace))\n}\n\n/**\n * Map %j to `JSON.stringify()`, since Cloudflare Workers don't have Web Inspectors.\n */\nfunction createFormatters () {\n return {\n j: function (v: any) {\n try {\n return JSON.stringify(v)\n } catch (error) {\n return '[UnexpectedJSONParseError]: ' + String(error)\n }\n }\n }\n}\n\nfunction logger (\n namespace: string,\n args: any[],\n { prevTime, color },\n forcedEnabled?: boolean\n) {\n args = args || []\n if (!isEnabled(namespace, forcedEnabled)) return\n\n // Set `diff` timestamp\n const curr = Number(new Date())\n const diff = curr - (prevTime || curr)\n prevTime = curr\n\n args[0] = coerce(args[0])\n const formatters = createFormatters()\n\n if (typeof args[0] !== 'string') {\n // Anything else let's inspect with %O\n args.unshift('%O')\n }\n\n // Apply any `formatters` transformations\n let index = 0\n args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n // If we encounter an escaped %, then don't increase the\n // array index\n if (match === '%%') return '%'\n\n index++\n\n const formatter = formatters[format]\n if (typeof formatter === 'function') {\n const val = args[index]\n match = formatter.call(globalThis, val)\n\n // Now we need to remove `args[index]` since it's inlined\n // in the `format`\n args.splice(index, 1)\n index--\n }\n return match\n })\n\n // Apply Cloudflare-specific formatting (no colors in Workers typically)\n const _args = formatArgs({\n diff,\n color,\n useColors: shouldUseColors(),\n namespace\n }, args)\n\n log(..._args)\n}\n\nfunction shouldUseColors (): boolean {\n // Cloudflare Workers typically don't support colors in console output\n // But we can detect if we're in a development environment\n return false\n}\n\n/**\n * Format log arguments for Cloudflare Workers (no color support typically).\n */\nfunction formatArgs ({ diff, namespace }: {\n diff: number,\n color: number,\n namespace: string,\n useColors: boolean\n}, args) {\n args[0] = namespace + ' ' + args[0] + ' +' + humanize(diff, {})\n return args\n}\n\nexport type CloudflareDebugger = {\n (...args: any[]): void;\n extend: (namespace: string) => CloudflareDebugger;\n}\n\nfunction createDebug (namespace?: string | boolean): CloudflareDebugger {\n if (namespace === false) return noop\n const prevTime = Number(new Date())\n const color = selectColor(\n typeof namespace === 'string' ? namespace : generateRandomString(10),\n colors\n )\n\n // Determine if this is a boolean true passed as the namespace\n const forcedEnabled = namespace === true\n const actualNamespace = typeof namespace === 'string' ? namespace : 'DEV'\n\n const debug = function (...args: any[]) {\n return logger(\n actualNamespace,\n args,\n { prevTime, color },\n forcedEnabled\n )\n }\n\n debug.extend = function (extension: string): CloudflareDebugger {\n const extendedNamespace = actualNamespace + ':' + extension\n return createDebug(extendedNamespace)\n }\n\n return debug as CloudflareDebugger\n}\n", "/**\n* Coerce `val`.\n*\n* @param {unknown} val\n* @return {string}\n*/\nexport function coerce (val:unknown):string {\n if (val instanceof Error) {\n return val.stack || val.message\n }\n\n return String(val)\n}\n\n/**\n * Selects a color for a debug namespace\n * @param {string} namespace The namespace string for the debug instance to be colored\n * @return {number|string} An ANSI color code for the given namespace\n */\nexport function selectColor (\n namespace:string,\n colors:string[]|number[]\n):number|string {\n let hash = 0\n\n for (let i = 0; i < namespace.length; i++) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i)\n hash |= 0 // Convert to 32bit integer\n }\n\n return colors[Math.abs(hash) % colors.length]\n}\n\nexport function createRegexFromEnvVar (names:string):RegExp[] {\n const split = names.split(/[\\s,]+/).filter(Boolean)\n const regexs = split\n .map(word => word.replace(/\\*/g, '.*?'))\n .map(r => new RegExp('^' + r + '$'))\n\n return regexs\n}\n\n/**\n * Use this to create a random namespace in the case that `debug`\n * is called without any arguments.\n * @param {number} length Lenght of the random string\n * @returns {string}\n */\nexport function generateRandomString (length = 6):string {\n return Math.random().toString(20).substring(2, length)\n}\n", "import { type Debugger } from './browser/index.js'\n\nexport const noop:Debugger = function (_args:any[]) {}\nnoop.extend = function (_namespace:string) { return noop }\n\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../src/cloudflare/index.ts", "../../src/ms.ts", "../../src/common.ts", "../../src/noop.ts"],
|
|
4
|
+
"sourcesContent": ["import humanize from '../ms.js'\nimport {\n generateRandomString,\n coerce,\n selectColor,\n createRegexFromEnvVar,\n type Debugger\n} from '../common.js'\nimport { noop } from '../noop.js'\n\n// Cloudflare Workers have a limited set of Web APIs\n// No localStorage, document, or navigator\nconst log = console.log || (() => {})\n\n// Simple color palette for Cloudflare Workers (no DOM-based colors)\nconst colors = [\n '#0066CC', '#CC0066', '#66CC00', '#CC6600', '#6600CC', '#00CC66',\n '#CC0000', '#0000CC', '#00CCCC', '#CCCC00', '#CC00CC', '#666666'\n]\n\nexport { createDebug }\nexport default createDebug\n\n/**\n * Check if the given namespace is enabled in Cloudflare Workers.\n * Since there's no localStorage, we check environment variables or global DEBUG.\n * `namespace` is the name that is passed into debug.\n * `env` is an optional environment object that can contain DEBUG setting.\n */\nfunction isEnabled (namespace:string, env?:Record<string, string>):boolean {\n // Determine the DEBUG value from env parameter, global, or process.env\n const DEBUG = env?.DEBUG ||\n (typeof globalThis !== 'undefined' && (globalThis as any).DEBUG) ||\n (typeof process !== 'undefined' && process.env?.DEBUG)\n\n // If no namespace (DEV mode), check if there's no DEBUG variable\n if (namespace === 'DEV') {\n // We want to log iff there is no DEBUG variable.\n if (!DEBUG) {\n return true\n }\n return false\n }\n\n // No DEBUG variable set\n if (!DEBUG) return false\n\n // Check for wildcard\n if (DEBUG === '*') return true\n\n // Check namespace vs DEBUG env var\n const envVars = createRegexFromEnvVar(DEBUG)\n return envVars.some(regex => regex.test(namespace))\n}\n\n/**\n * Map %j to `JSON.stringify()`, since Cloudflare Workers don't\n * have Web Inspectors.\n */\nfunction createFormatters () {\n return {\n j: function (v:any) {\n try {\n return JSON.stringify(v)\n } catch (error) {\n return '[UnexpectedJSONParseError]: ' + String(error)\n }\n }\n }\n}\n\nfunction logger (\n namespace:string,\n args:any[],\n { prevTime, color },\n env?:Record<string, string>\n) {\n args = args || []\n if (!isEnabled(namespace, env)) return\n\n // Set `diff` timestamp\n const curr = Number(new Date())\n const diff = curr - (prevTime || curr)\n prevTime = curr\n\n args[0] = coerce(args[0])\n const formatters = createFormatters()\n\n if (typeof args[0] !== 'string') {\n // Anything else let's inspect with %O\n args.unshift('%O')\n }\n\n // Apply any `formatters` transformations\n let index = 0\n args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n // If we encounter an escaped %, then don't increase the\n // array index\n if (match === '%%') return '%'\n\n index++\n\n const formatter = formatters[format]\n if (typeof formatter === 'function') {\n const val = args[index]\n match = formatter.call(globalThis, val)\n\n // Now we need to remove `args[index]` since it's inlined\n // in the `format`\n args.splice(index, 1)\n index--\n }\n return match\n })\n\n // Apply Cloudflare-specific formatting (no colors in Workers typically)\n const _args = formatArgs({\n diff,\n color,\n useColors: shouldUseColors(),\n namespace\n }, args)\n\n log(..._args)\n}\n\nfunction shouldUseColors ():boolean {\n // Cloudflare Workers typically don't support colors in console output\n // But we can detect if we're in a development environment\n return false\n}\n\n/**\n * Format log arguments for Cloudflare Workers (no color support typically).\n * Mutates the given args.\n */\nfunction formatArgs ({ diff, namespace }:{\n diff:number,\n color:number,\n namespace:string,\n useColors:boolean\n}, args:string[]) {\n args[0] = namespace + ' ' + args[0] + ' +' + humanize(diff, {})\n return args\n}\n\nfunction createDebug (namespace?:string, env?:Record<string, string>):Debugger;\nfunction createDebug (enabled:boolean):Debugger;\nfunction createDebug (\n namespaceOrEnabled?:string|boolean,\n env?:Record<string, string>\n):Debugger {\n // Handle the case where first parameter is a boolean\n if (typeof namespaceOrEnabled === 'boolean') {\n if (namespaceOrEnabled === false) return noop\n // If namespaceOrEnabled is true, use DEV mode with forced logging\n return createDebug('DEV', { DEBUG: '*' })\n }\n\n const prevTime = Number(new Date())\n const color = selectColor(\n typeof namespaceOrEnabled === 'string' ?\n namespaceOrEnabled :\n generateRandomString(10),\n colors\n )\n\n const actualNamespace = typeof namespaceOrEnabled === 'string' ?\n namespaceOrEnabled :\n 'DEV'\n\n // Handle environment parameter\n let envObj:Record<string, string>|undefined\n if (typeof env === 'object') {\n envObj = env\n }\n\n const debug = function (...args:any[]) {\n return logger(\n actualNamespace,\n args,\n { prevTime, color },\n envObj\n )\n }\n\n debug.extend = function (extension:string):Debugger {\n const extendedNamespace = actualNamespace + ':' + extension\n return createDebug(extendedNamespace, envObj)\n }\n\n return debug\n}\n", "/**\n * Helpers.\n */\n\nconst s = 1000\nconst m = s * 60\nconst h = m * 60\nconst d = h * 24\nconst w = d * 7\nconst y = d * 365.25\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nexport default function (val, options:{ long?:boolean } = {}) {\n options = options || {}\n const type = typeof val\n if (type === 'string' && val.length > 0) {\n return parse(val)\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val)\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n )\n}\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse (str) {\n str = String(str)\n if (str.length > 100) {\n return\n }\n const match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n )\n if (!match) {\n return\n }\n const n = parseFloat(match[1])\n const type = (match[2] || 'ms').toLowerCase()\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y\n case 'weeks':\n case 'week':\n case 'w':\n return n * w\n case 'days':\n case 'day':\n case 'd':\n return n * d\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n\n default:\n return undefined\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort (ms) {\n const msAbs = Math.abs(ms)\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd'\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h'\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm'\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's'\n }\n return ms + 'ms'\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong (ms) {\n const msAbs = Math.abs(ms)\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day')\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour')\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute')\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second')\n }\n return ms + ' ms'\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural (ms, msAbs, n, name) {\n const isPlural = msAbs >= n * 1.5\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '')\n}\n", "/**\n* Coerce `val`.\n*\n* @param {unknown} val\n* @return {string}\n*/\nexport function coerce (val:unknown):string {\n if (val instanceof Error) {\n return val.stack || val.message\n }\n\n return String(val)\n}\n\n/**\n * Selects a color for a debug namespace\n * @param {string} namespace The namespace string for the debug instance to be colored\n * @return {number|string} An ANSI color code for the given namespace\n */\nexport function selectColor (\n namespace:string,\n colors:string[]|number[]\n):number|string {\n let hash = 0\n\n for (let i = 0; i < namespace.length; i++) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i)\n hash |= 0 // Convert to 32bit integer\n }\n\n return colors[Math.abs(hash) % colors.length]\n}\n\nexport function createRegexFromEnvVar (names:string):RegExp[] {\n const split = names.split(/[\\s,]+/).filter(Boolean)\n const regexs = split\n .map(word => word.replace(/\\*/g, '.*?'))\n .map(r => new RegExp('^' + r + '$'))\n\n return regexs\n}\n\nexport type Debugger = {\n (...args: any[]): void;\n extend: (namespace: string) => Debugger;\n}\n\n/**\n * Use this to create a random namespace in the case that `debug`\n * is called without any arguments.\n * @param {number} length Lenght of the random string\n * @returns {string}\n */\nexport function generateRandomString (length = 6):string {\n return Math.random().toString(20).substring(2, length)\n}\n", "import { type Debugger } from './common.js'\n\nexport const noop:Debugger = function (_args:any[]) {}\nnoop.extend = function (_namespace:string) { return noop }\n\n"],
|
|
5
|
+
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GCyBe,SAARK,EAAkBC,EAAKC,EAA4B,CAAC,EAAG,CAC1DA,EAAUA,GAAW,CAAC,EACtB,IAAMC,EAAO,OAAOF,EACpB,GAAIE,IAAS,UAAYF,EAAI,OAAS,EAClC,OAAOG,EAAMH,CAAG,EACb,GAAI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AChD,EAEOC,CACX,CA5CS7B,EAAAP,EAAA",
|
|
6
|
+
"names": ["index_exports", "__export", "createDebug", "index_default", "__toCommonJS", "ms_default", "val", "options", "type", "parse", "fmtLong", "fmtShort", "__name", "str", "match", "n", "ms", "msAbs", "plural", "name", "isPlural", "coerce", "val", "__name", "selectColor", "namespace", "colors", "hash", "i", "createRegexFromEnvVar", "names", "word", "r", "generateRandomString", "length", "noop", "__name", "_args", "_namespace", "log", "colors", "index_default", "createDebug", "isEnabled", "namespace", "env", "DEBUG", "createRegexFromEnvVar", "regex", "__name", "createFormatters", "v", "error", "logger", "args", "prevTime", "color", "curr", "diff", "coerce", "formatters", "index", "match", "format", "formatter", "val", "_args", "formatArgs", "shouldUseColors", "log", "ms_default", "namespaceOrEnabled", "noop", "selectColor", "generateRandomString", "colors", "actualNamespace", "envObj", "debug", "extension", "extendedNamespace"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E=Object.defineProperty;var t=(e,n)=>E(e,"name",{value:n,configurable:!0});function l(e,n={}){n=n||{};let r=typeof e;if(r==="string"&&e.length>0)return R(e);if(r==="number"&&isFinite(e))return n.long?M(e):S(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}t(l,"default");function R(e){if(e=String(e),e.length>100)return;let n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!n)return;let r=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}t(R,"parse");function S(e){let n=Math.abs(e);return n>=864e5?Math.round(e/864e5)+"d":n>=36e5?Math.round(e/36e5)+"h":n>=6e4?Math.round(e/6e4)+"m":n>=1e3?Math.round(e/1e3)+"s":e+"ms"}t(S,"fmtShort");function M(e){let n=Math.abs(e);return n>=864e5?f(e,n,864e5,"day"):n>=36e5?f(e,n,36e5,"hour"):n>=6e4?f(e,n,6e4,"minute"):n>=1e3?f(e,n,1e3,"second"):e+" ms"}t(M,"fmtLong");function f(e,n,r,s){let o=n>=r*1.5;return Math.round(e/r)+" "+s+(o?"s":"")}t(f,"plural");function h(e){return e instanceof Error?e.stack||e.message:String(e)}t(h,"coerce");function y(e,n){let r=0;for(let s=0;s<e.length;s++)r=(r<<5)-r+e.charCodeAt(s),r|=0;return n[Math.abs(r)%n.length]}t(y,"selectColor");function b(e){return e.split(/[\s,]+/).filter(Boolean).map(s=>s.replace(/\*/g,".*?")).map(s=>new RegExp("^"+s+"$"))}t(b,"createRegexFromEnvVar");function C(e=6){return Math.random().toString(20).substring(2,e)}t(C,"generateRandomString");var g=t(function(e){},"noop");g.extend=function(e){return g};var N=console.log||(()=>{}),U=["#0066CC","#CC0066","#66CC00","#CC6600","#6600CC","#00CC66","#CC0000","#0000CC","#00CCCC","#CCCC00","#CC00CC","#666666"];var Z=m;function V(e,n){let r=n?.DEBUG||typeof globalThis<"u"&&globalThis.DEBUG||typeof process<"u"&&process.env?.DEBUG;return e==="DEV"?!r:r?r==="*"?!0:b(r).some(o=>o.test(e)):!1}t(V,"isEnabled");function B(){return{j:t(function(e){try{return JSON.stringify(e)}catch(n){return"[UnexpectedJSONParseError]: "+String(n)}},"j")}}t(B,"createFormatters");function k(e,n,{prevTime:r,color:s},o){if(n=n||[],!V(e,o))return;let c=Number(new Date),a=c-(r||c);r=c,n[0]=h(n[0]);let u=B();typeof n[0]!="string"&&n.unshift("%O");let i=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,(d,D)=>{if(d==="%%")return"%";i++;let p=u[D];if(typeof p=="function"){let w=n[i];d=p.call(globalThis,w),n.splice(i,1),i--}return d});let x=F({diff:a,color:s,useColors:A(),namespace:e},n);N(...x)}t(k,"logger");function A(){return!1}t(A,"shouldUseColors");function F({diff:e,namespace:n},r){return r[0]=n+" "+r[0]+" +"+l(e,{}),r}t(F,"formatArgs");function m(e,n){if(typeof e=="boolean")return e===!1?g:m("DEV",{DEBUG:"*"});let r=Number(new Date),s=y(typeof e=="string"?e:C(10),U),o=typeof e=="string"?e:"DEV",c;typeof n=="object"&&(c=n);let a=t(function(...u){return k(o,u,{prevTime:r,color:s},c)},"debug");return a.extend=function(u){let i=o+":"+u;return m(i,c)},a}t(m,"createDebug");export{m as createDebug,Z as default};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|