@substrate-system/debug 0.9.13 → 0.9.15
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 +28 -6
- package/dist/cloudflare/index.cjs +310 -0
- package/dist/cloudflare/index.cjs.map +7 -0
- package/dist/cloudflare/index.d.ts +8 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +302 -0
- package/dist/cloudflare/index.js.map +7 -0
- package/dist/cloudflare/index.min.cjs +2 -0
- package/dist/cloudflare/index.min.cjs.map +7 -0
- package/dist/cloudflare/index.min.js +2 -0
- package/dist/cloudflare/index.min.js.map +7 -0
- package/package.json +17 -6
package/README.md
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
[](https://bundlephobia.com/package/@substrate-system/web-component)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
10
|
+
* [x] Cloudflare
|
|
11
|
+
* [x] Node
|
|
12
|
+
* [x] browsers
|
|
10
13
|
|
|
11
14
|
A tiny JavaScript debugging utility that works in Node.js and browsers.
|
|
12
15
|
Use environment variables to control logging in Node.js, and `localStorage`
|
|
@@ -20,7 +23,7 @@ In Node.js, it uses the environment variable `DEBUG`.
|
|
|
20
23
|
|
|
21
24
|
**Featuring:**
|
|
22
25
|
* Use [exports](https://github.com/substrate-system/debug/blob/main/package.json#L31)
|
|
23
|
-
field in `package.json` to choose node JS or
|
|
26
|
+
field in `package.json` to choose node JS, browser, or cloudflare version
|
|
24
27
|
* ESM only
|
|
25
28
|
|
|
26
29
|
Plus, [see the docs](https://substrate-system.github.io/debug/)
|
|
@@ -43,7 +46,10 @@ generated by typescript.
|
|
|
43
46
|
* [browser](#browser)
|
|
44
47
|
* [Run the Node example](#run-the-node-example)
|
|
45
48
|
- [Test](#test)
|
|
49
|
+
* [All tests](#all-tests)
|
|
46
50
|
* [Node](#node)
|
|
51
|
+
* [Cloudlfare](#cloudlfare)
|
|
52
|
+
* [Browsers](#browsers)
|
|
47
53
|
|
|
48
54
|
<!-- tocstop -->
|
|
49
55
|
|
|
@@ -146,9 +152,9 @@ const log = Debug('auth')
|
|
|
146
152
|
const logSign = log.extend('sign')
|
|
147
153
|
const logLogin = log.extend('login')
|
|
148
154
|
|
|
149
|
-
log('hello')
|
|
150
|
-
logSign('hello')
|
|
151
|
-
logLogin('hello')
|
|
155
|
+
log('hello') // auth hello
|
|
156
|
+
logSign('hello') // auth:sign hello
|
|
157
|
+
logLogin('hello') // auth:login hello
|
|
152
158
|
```
|
|
153
159
|
|
|
154
160
|
Chained extending is also supported:
|
|
@@ -193,10 +199,26 @@ npm run example:node
|
|
|
193
199
|
|
|
194
200
|
## Test
|
|
195
201
|
|
|
202
|
+
### All tests
|
|
203
|
+
|
|
204
|
+
```sh
|
|
205
|
+
npm test
|
|
206
|
+
```
|
|
207
|
+
|
|
196
208
|
### Node
|
|
197
209
|
|
|
198
|
-
|
|
210
|
+
```sh
|
|
211
|
+
npm run test:node
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Cloudlfare
|
|
199
215
|
|
|
200
216
|
```sh
|
|
201
|
-
npm test
|
|
217
|
+
npm run test:cloudflare
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Browsers
|
|
221
|
+
|
|
222
|
+
```sh
|
|
223
|
+
npm run test:browser
|
|
202
224
|
```
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
|
|
34
|
+
// node_modules/ms/index.js
|
|
35
|
+
var require_ms = __commonJS({
|
|
36
|
+
"node_modules/ms/index.js"(exports, module2) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var s = 1e3;
|
|
39
|
+
var m = s * 60;
|
|
40
|
+
var h = m * 60;
|
|
41
|
+
var d = h * 24;
|
|
42
|
+
var w = d * 7;
|
|
43
|
+
var y = d * 365.25;
|
|
44
|
+
module2.exports = function(val, options) {
|
|
45
|
+
options = options || {};
|
|
46
|
+
var type = typeof val;
|
|
47
|
+
if (type === "string" && val.length > 0) {
|
|
48
|
+
return parse(val);
|
|
49
|
+
} else if (type === "number" && isFinite(val)) {
|
|
50
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
51
|
+
}
|
|
52
|
+
throw new Error(
|
|
53
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
function parse(str) {
|
|
57
|
+
str = String(str);
|
|
58
|
+
if (str.length > 100) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
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(
|
|
62
|
+
str
|
|
63
|
+
);
|
|
64
|
+
if (!match) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var n = parseFloat(match[1]);
|
|
68
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
69
|
+
switch (type) {
|
|
70
|
+
case "years":
|
|
71
|
+
case "year":
|
|
72
|
+
case "yrs":
|
|
73
|
+
case "yr":
|
|
74
|
+
case "y":
|
|
75
|
+
return n * y;
|
|
76
|
+
case "weeks":
|
|
77
|
+
case "week":
|
|
78
|
+
case "w":
|
|
79
|
+
return n * w;
|
|
80
|
+
case "days":
|
|
81
|
+
case "day":
|
|
82
|
+
case "d":
|
|
83
|
+
return n * d;
|
|
84
|
+
case "hours":
|
|
85
|
+
case "hour":
|
|
86
|
+
case "hrs":
|
|
87
|
+
case "hr":
|
|
88
|
+
case "h":
|
|
89
|
+
return n * h;
|
|
90
|
+
case "minutes":
|
|
91
|
+
case "minute":
|
|
92
|
+
case "mins":
|
|
93
|
+
case "min":
|
|
94
|
+
case "m":
|
|
95
|
+
return n * m;
|
|
96
|
+
case "seconds":
|
|
97
|
+
case "second":
|
|
98
|
+
case "secs":
|
|
99
|
+
case "sec":
|
|
100
|
+
case "s":
|
|
101
|
+
return n * s;
|
|
102
|
+
case "milliseconds":
|
|
103
|
+
case "millisecond":
|
|
104
|
+
case "msecs":
|
|
105
|
+
case "msec":
|
|
106
|
+
case "ms":
|
|
107
|
+
return n;
|
|
108
|
+
default:
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
__name(parse, "parse");
|
|
113
|
+
function fmtShort(ms) {
|
|
114
|
+
var msAbs = Math.abs(ms);
|
|
115
|
+
if (msAbs >= d) {
|
|
116
|
+
return Math.round(ms / d) + "d";
|
|
117
|
+
}
|
|
118
|
+
if (msAbs >= h) {
|
|
119
|
+
return Math.round(ms / h) + "h";
|
|
120
|
+
}
|
|
121
|
+
if (msAbs >= m) {
|
|
122
|
+
return Math.round(ms / m) + "m";
|
|
123
|
+
}
|
|
124
|
+
if (msAbs >= s) {
|
|
125
|
+
return Math.round(ms / s) + "s";
|
|
126
|
+
}
|
|
127
|
+
return ms + "ms";
|
|
128
|
+
}
|
|
129
|
+
__name(fmtShort, "fmtShort");
|
|
130
|
+
function fmtLong(ms) {
|
|
131
|
+
var msAbs = Math.abs(ms);
|
|
132
|
+
if (msAbs >= d) {
|
|
133
|
+
return plural(ms, msAbs, d, "day");
|
|
134
|
+
}
|
|
135
|
+
if (msAbs >= h) {
|
|
136
|
+
return plural(ms, msAbs, h, "hour");
|
|
137
|
+
}
|
|
138
|
+
if (msAbs >= m) {
|
|
139
|
+
return plural(ms, msAbs, m, "minute");
|
|
140
|
+
}
|
|
141
|
+
if (msAbs >= s) {
|
|
142
|
+
return plural(ms, msAbs, s, "second");
|
|
143
|
+
}
|
|
144
|
+
return ms + " ms";
|
|
145
|
+
}
|
|
146
|
+
__name(fmtLong, "fmtLong");
|
|
147
|
+
function plural(ms, msAbs, n, name) {
|
|
148
|
+
var isPlural = msAbs >= n * 1.5;
|
|
149
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
150
|
+
}
|
|
151
|
+
__name(plural, "plural");
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// src/cloudflare/index.ts
|
|
156
|
+
var index_exports = {};
|
|
157
|
+
__export(index_exports, {
|
|
158
|
+
createDebug: () => createDebug,
|
|
159
|
+
default: () => index_default
|
|
160
|
+
});
|
|
161
|
+
module.exports = __toCommonJS(index_exports);
|
|
162
|
+
var import_ms = __toESM(require_ms(), 1);
|
|
163
|
+
|
|
164
|
+
// src/common.ts
|
|
165
|
+
function coerce(val) {
|
|
166
|
+
if (val instanceof Error) {
|
|
167
|
+
return val.stack || val.message;
|
|
168
|
+
}
|
|
169
|
+
return String(val);
|
|
170
|
+
}
|
|
171
|
+
__name(coerce, "coerce");
|
|
172
|
+
function selectColor(namespace, colors2) {
|
|
173
|
+
let hash = 0;
|
|
174
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
175
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
176
|
+
hash |= 0;
|
|
177
|
+
}
|
|
178
|
+
return colors2[Math.abs(hash) % colors2.length];
|
|
179
|
+
}
|
|
180
|
+
__name(selectColor, "selectColor");
|
|
181
|
+
function createRegexFromEnvVar(names) {
|
|
182
|
+
const split = names.split(/[\s,]+/).filter(Boolean);
|
|
183
|
+
const regexs = split.map((word) => word.replace(/\*/g, ".*?")).map((r) => new RegExp("^" + r + "$"));
|
|
184
|
+
return regexs;
|
|
185
|
+
}
|
|
186
|
+
__name(createRegexFromEnvVar, "createRegexFromEnvVar");
|
|
187
|
+
function generateRandomString(length = 6) {
|
|
188
|
+
return Math.random().toString(20).substring(2, length);
|
|
189
|
+
}
|
|
190
|
+
__name(generateRandomString, "generateRandomString");
|
|
191
|
+
|
|
192
|
+
// src/noop.ts
|
|
193
|
+
var noop = /* @__PURE__ */ __name(function(_args) {
|
|
194
|
+
}, "noop");
|
|
195
|
+
noop.extend = function(_namespace) {
|
|
196
|
+
return noop;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/cloudflare/index.ts
|
|
200
|
+
var log = console.log || (() => {
|
|
201
|
+
});
|
|
202
|
+
var colors = [
|
|
203
|
+
"#0066CC",
|
|
204
|
+
"#CC0066",
|
|
205
|
+
"#66CC00",
|
|
206
|
+
"#CC6600",
|
|
207
|
+
"#6600CC",
|
|
208
|
+
"#00CC66",
|
|
209
|
+
"#CC0000",
|
|
210
|
+
"#0000CC",
|
|
211
|
+
"#00CCCC",
|
|
212
|
+
"#CCCC00",
|
|
213
|
+
"#CC00CC",
|
|
214
|
+
"#666666"
|
|
215
|
+
];
|
|
216
|
+
var index_default = createDebug;
|
|
217
|
+
function isEnabled(namespace, forcedEnabled) {
|
|
218
|
+
if (forcedEnabled === true) return true;
|
|
219
|
+
const DEBUG = typeof globalThis !== "undefined" && globalThis.DEBUG || typeof process !== "undefined" && process.env?.DEBUG;
|
|
220
|
+
if (DEBUG === "*") return true;
|
|
221
|
+
if (namespace === "DEV") {
|
|
222
|
+
if (!DEBUG) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
if (!DEBUG) return false;
|
|
228
|
+
const envVars = createRegexFromEnvVar(DEBUG);
|
|
229
|
+
return envVars.some((regex) => regex.test(namespace));
|
|
230
|
+
}
|
|
231
|
+
__name(isEnabled, "isEnabled");
|
|
232
|
+
function createFormatters() {
|
|
233
|
+
return {
|
|
234
|
+
j: /* @__PURE__ */ __name(function(v) {
|
|
235
|
+
try {
|
|
236
|
+
return JSON.stringify(v);
|
|
237
|
+
} catch (error) {
|
|
238
|
+
return "[UnexpectedJSONParseError]: " + String(error);
|
|
239
|
+
}
|
|
240
|
+
}, "j")
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
__name(createFormatters, "createFormatters");
|
|
244
|
+
function logger(namespace, args, { prevTime, color }, forcedEnabled) {
|
|
245
|
+
args = args || [];
|
|
246
|
+
if (!isEnabled(namespace, forcedEnabled)) return;
|
|
247
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
248
|
+
const diff = curr - (prevTime || curr);
|
|
249
|
+
prevTime = curr;
|
|
250
|
+
args[0] = coerce(args[0]);
|
|
251
|
+
const formatters = createFormatters();
|
|
252
|
+
if (typeof args[0] !== "string") {
|
|
253
|
+
args.unshift("%O");
|
|
254
|
+
}
|
|
255
|
+
let index = 0;
|
|
256
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
257
|
+
if (match === "%%") return "%";
|
|
258
|
+
index++;
|
|
259
|
+
const formatter = formatters[format];
|
|
260
|
+
if (typeof formatter === "function") {
|
|
261
|
+
const val = args[index];
|
|
262
|
+
match = formatter.call(globalThis, val);
|
|
263
|
+
args.splice(index, 1);
|
|
264
|
+
index--;
|
|
265
|
+
}
|
|
266
|
+
return match;
|
|
267
|
+
});
|
|
268
|
+
const _args = formatArgs({
|
|
269
|
+
diff,
|
|
270
|
+
color,
|
|
271
|
+
useColors: shouldUseColors(),
|
|
272
|
+
namespace
|
|
273
|
+
}, args);
|
|
274
|
+
log(..._args);
|
|
275
|
+
}
|
|
276
|
+
__name(logger, "logger");
|
|
277
|
+
function shouldUseColors() {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
__name(shouldUseColors, "shouldUseColors");
|
|
281
|
+
function formatArgs({ diff, namespace }, args) {
|
|
282
|
+
args[0] = namespace + " " + args[0] + " +" + (0, import_ms.default)(diff, {});
|
|
283
|
+
return args;
|
|
284
|
+
}
|
|
285
|
+
__name(formatArgs, "formatArgs");
|
|
286
|
+
function createDebug(namespace) {
|
|
287
|
+
if (namespace === false) return noop;
|
|
288
|
+
const prevTime = Number(/* @__PURE__ */ new Date());
|
|
289
|
+
const color = selectColor(
|
|
290
|
+
typeof namespace === "string" ? namespace : generateRandomString(10),
|
|
291
|
+
colors
|
|
292
|
+
);
|
|
293
|
+
const forcedEnabled = namespace === true;
|
|
294
|
+
const actualNamespace = typeof namespace === "string" ? namespace : "DEV";
|
|
295
|
+
const debug = /* @__PURE__ */ __name(function(...args) {
|
|
296
|
+
return logger(
|
|
297
|
+
actualNamespace,
|
|
298
|
+
args,
|
|
299
|
+
{ prevTime, color },
|
|
300
|
+
forcedEnabled
|
|
301
|
+
);
|
|
302
|
+
}, "debug");
|
|
303
|
+
debug.extend = function(extension) {
|
|
304
|
+
const extendedNamespace = actualNamespace + ":" + extension;
|
|
305
|
+
return createDebug(extendedNamespace);
|
|
306
|
+
};
|
|
307
|
+
return debug;
|
|
308
|
+
}
|
|
309
|
+
__name(createDebug, "createDebug");
|
|
310
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../node_modules/ms/index.js", "../../src/cloudflare/index.ts", "../../src/common.ts", "../../src/noop.ts"],
|
|
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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,sCAAAA,SAAA;AAAA;AAIA,QAAI,IAAI;AACR,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AAgBZ,IAAAA,QAAO,UAAU,SAAU,KAAK,SAAS;AACvC,gBAAU,WAAW,CAAC;AACtB,UAAI,OAAO,OAAO;AAClB,UAAI,SAAS,YAAY,IAAI,SAAS,GAAG;AACvC,eAAO,MAAM,GAAG;AAAA,MAClB,WAAW,SAAS,YAAY,SAAS,GAAG,GAAG;AAC7C,eAAO,QAAQ,OAAO,QAAQ,GAAG,IAAI,SAAS,GAAG;AAAA,MACnD;AACA,YAAM,IAAI;AAAA,QACR,0DACE,KAAK,UAAU,GAAG;AAAA,MACtB;AAAA,IACF;AAUA,aAAS,MAAM,KAAK;AAClB,YAAM,OAAO,GAAG;AAChB,UAAI,IAAI,SAAS,KAAK;AACpB;AAAA,MACF;AACA,UAAI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QAAM,QAAQ,mCAAa,MAAa;AACpC,WAAO;AAAA,MACH;AAAA,MACA;AAAA,MACA,EAAE,UAAU,MAAM;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ,GAPc;AASd,QAAM,SAAS,SAAU,WAAuC;AAC5D,UAAM,oBAAoB,kBAAkB,MAAM;AAClD,WAAO,YAAY,iBAAiB;AAAA,EACxC;AAEA,SAAO;AACX;AA3BS;",
|
|
6
|
+
"names": ["module", "colors", "humanize"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createDebug };
|
|
2
|
+
export default createDebug;
|
|
3
|
+
export type CloudflareDebugger = {
|
|
4
|
+
(...args: any[]): void;
|
|
5
|
+
extend: (namespace: string) => CloudflareDebugger;
|
|
6
|
+
};
|
|
7
|
+
declare function createDebug(namespace?: string | boolean): CloudflareDebugger;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,CAAA;AACtB,eAAe,WAAW,CAAA;AA4H1B,MAAM,MAAM,kBAAkB,GAAG;IAC7B,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,kBAAkB,CAAC;CACrD,CAAA;AAED,iBAAS,WAAW,CAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,kBAAkB,CA2BtE"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
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
|
+
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
|
+
|
|
28
|
+
// node_modules/ms/index.js
|
|
29
|
+
var require_ms = __commonJS({
|
|
30
|
+
"node_modules/ms/index.js"(exports, module) {
|
|
31
|
+
"use strict";
|
|
32
|
+
var s = 1e3;
|
|
33
|
+
var m = s * 60;
|
|
34
|
+
var h = m * 60;
|
|
35
|
+
var d = h * 24;
|
|
36
|
+
var w = d * 7;
|
|
37
|
+
var y = d * 365.25;
|
|
38
|
+
module.exports = function(val, options) {
|
|
39
|
+
options = options || {};
|
|
40
|
+
var type = typeof val;
|
|
41
|
+
if (type === "string" && val.length > 0) {
|
|
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");
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// src/cloudflare/index.ts
|
|
150
|
+
var import_ms = __toESM(require_ms(), 1);
|
|
151
|
+
|
|
152
|
+
// src/common.ts
|
|
153
|
+
function coerce(val) {
|
|
154
|
+
if (val instanceof Error) {
|
|
155
|
+
return val.stack || val.message;
|
|
156
|
+
}
|
|
157
|
+
return String(val);
|
|
158
|
+
}
|
|
159
|
+
__name(coerce, "coerce");
|
|
160
|
+
function selectColor(namespace, colors2) {
|
|
161
|
+
let hash = 0;
|
|
162
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
163
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
164
|
+
hash |= 0;
|
|
165
|
+
}
|
|
166
|
+
return colors2[Math.abs(hash) % colors2.length];
|
|
167
|
+
}
|
|
168
|
+
__name(selectColor, "selectColor");
|
|
169
|
+
function createRegexFromEnvVar(names) {
|
|
170
|
+
const split = names.split(/[\s,]+/).filter(Boolean);
|
|
171
|
+
const regexs = split.map((word) => word.replace(/\*/g, ".*?")).map((r) => new RegExp("^" + r + "$"));
|
|
172
|
+
return regexs;
|
|
173
|
+
}
|
|
174
|
+
__name(createRegexFromEnvVar, "createRegexFromEnvVar");
|
|
175
|
+
function generateRandomString(length = 6) {
|
|
176
|
+
return Math.random().toString(20).substring(2, length);
|
|
177
|
+
}
|
|
178
|
+
__name(generateRandomString, "generateRandomString");
|
|
179
|
+
|
|
180
|
+
// src/noop.ts
|
|
181
|
+
var noop = /* @__PURE__ */ __name(function(_args) {
|
|
182
|
+
}, "noop");
|
|
183
|
+
noop.extend = function(_namespace) {
|
|
184
|
+
return noop;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// src/cloudflare/index.ts
|
|
188
|
+
var log = console.log || (() => {
|
|
189
|
+
});
|
|
190
|
+
var colors = [
|
|
191
|
+
"#0066CC",
|
|
192
|
+
"#CC0066",
|
|
193
|
+
"#66CC00",
|
|
194
|
+
"#CC6600",
|
|
195
|
+
"#6600CC",
|
|
196
|
+
"#00CC66",
|
|
197
|
+
"#CC0000",
|
|
198
|
+
"#0000CC",
|
|
199
|
+
"#00CCCC",
|
|
200
|
+
"#CCCC00",
|
|
201
|
+
"#CC00CC",
|
|
202
|
+
"#666666"
|
|
203
|
+
];
|
|
204
|
+
var index_default = createDebug;
|
|
205
|
+
function isEnabled(namespace, forcedEnabled) {
|
|
206
|
+
if (forcedEnabled === true) return true;
|
|
207
|
+
const DEBUG = typeof globalThis !== "undefined" && globalThis.DEBUG || typeof process !== "undefined" && process.env?.DEBUG;
|
|
208
|
+
if (DEBUG === "*") return true;
|
|
209
|
+
if (namespace === "DEV") {
|
|
210
|
+
if (!DEBUG) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
if (!DEBUG) return false;
|
|
216
|
+
const envVars = createRegexFromEnvVar(DEBUG);
|
|
217
|
+
return envVars.some((regex) => regex.test(namespace));
|
|
218
|
+
}
|
|
219
|
+
__name(isEnabled, "isEnabled");
|
|
220
|
+
function createFormatters() {
|
|
221
|
+
return {
|
|
222
|
+
j: /* @__PURE__ */ __name(function(v) {
|
|
223
|
+
try {
|
|
224
|
+
return JSON.stringify(v);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
return "[UnexpectedJSONParseError]: " + String(error);
|
|
227
|
+
}
|
|
228
|
+
}, "j")
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
__name(createFormatters, "createFormatters");
|
|
232
|
+
function logger(namespace, args, { prevTime, color }, forcedEnabled) {
|
|
233
|
+
args = args || [];
|
|
234
|
+
if (!isEnabled(namespace, forcedEnabled)) return;
|
|
235
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
236
|
+
const diff = curr - (prevTime || curr);
|
|
237
|
+
prevTime = curr;
|
|
238
|
+
args[0] = coerce(args[0]);
|
|
239
|
+
const formatters = createFormatters();
|
|
240
|
+
if (typeof args[0] !== "string") {
|
|
241
|
+
args.unshift("%O");
|
|
242
|
+
}
|
|
243
|
+
let index = 0;
|
|
244
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
245
|
+
if (match === "%%") return "%";
|
|
246
|
+
index++;
|
|
247
|
+
const formatter = formatters[format];
|
|
248
|
+
if (typeof formatter === "function") {
|
|
249
|
+
const val = args[index];
|
|
250
|
+
match = formatter.call(globalThis, val);
|
|
251
|
+
args.splice(index, 1);
|
|
252
|
+
index--;
|
|
253
|
+
}
|
|
254
|
+
return match;
|
|
255
|
+
});
|
|
256
|
+
const _args = formatArgs({
|
|
257
|
+
diff,
|
|
258
|
+
color,
|
|
259
|
+
useColors: shouldUseColors(),
|
|
260
|
+
namespace
|
|
261
|
+
}, args);
|
|
262
|
+
log(..._args);
|
|
263
|
+
}
|
|
264
|
+
__name(logger, "logger");
|
|
265
|
+
function shouldUseColors() {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
__name(shouldUseColors, "shouldUseColors");
|
|
269
|
+
function formatArgs({ diff, namespace }, args) {
|
|
270
|
+
args[0] = namespace + " " + args[0] + " +" + (0, import_ms.default)(diff, {});
|
|
271
|
+
return args;
|
|
272
|
+
}
|
|
273
|
+
__name(formatArgs, "formatArgs");
|
|
274
|
+
function createDebug(namespace) {
|
|
275
|
+
if (namespace === false) return noop;
|
|
276
|
+
const prevTime = Number(/* @__PURE__ */ new Date());
|
|
277
|
+
const color = selectColor(
|
|
278
|
+
typeof namespace === "string" ? namespace : generateRandomString(10),
|
|
279
|
+
colors
|
|
280
|
+
);
|
|
281
|
+
const forcedEnabled = namespace === true;
|
|
282
|
+
const actualNamespace = typeof namespace === "string" ? namespace : "DEV";
|
|
283
|
+
const debug = /* @__PURE__ */ __name(function(...args) {
|
|
284
|
+
return logger(
|
|
285
|
+
actualNamespace,
|
|
286
|
+
args,
|
|
287
|
+
{ prevTime, color },
|
|
288
|
+
forcedEnabled
|
|
289
|
+
);
|
|
290
|
+
}, "debug");
|
|
291
|
+
debug.extend = function(extension) {
|
|
292
|
+
const extendedNamespace = actualNamespace + ":" + extension;
|
|
293
|
+
return createDebug(extendedNamespace);
|
|
294
|
+
};
|
|
295
|
+
return debug;
|
|
296
|
+
}
|
|
297
|
+
__name(createDebug, "createDebug");
|
|
298
|
+
export {
|
|
299
|
+
createDebug,
|
|
300
|
+
index_default as default
|
|
301
|
+
};
|
|
302
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../node_modules/ms/index.js", "../../src/cloudflare/index.ts", "../../src/common.ts", "../../src/noop.ts"],
|
|
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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAIA,QAAI,IAAI;AACR,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AACZ,QAAI,IAAI,IAAI;AAgBZ,WAAO,UAAU,SAAU,KAAK,SAAS;AACvC,gBAAU,WAAW,CAAC;AACtB,UAAI,OAAO,OAAO;AAClB,UAAI,SAAS,YAAY,IAAI,SAAS,GAAG;AACvC,eAAO,MAAM,GAAG;AAAA,MAClB,WAAW,SAAS,YAAY,SAAS,GAAG,GAAG;AAC7C,eAAO,QAAQ,OAAO,QAAQ,GAAG,IAAI,SAAS,GAAG;AAAA,MACnD;AACA,YAAM,IAAI;AAAA,QACR,0DACE,KAAK,UAAU,GAAG;AAAA,MACtB;AAAA,IACF;AAUA,aAAS,MAAM,KAAK;AAClB,YAAM,OAAO,GAAG;AAChB,UAAI,IAAI,SAAS,KAAK;AACpB;AAAA,MACF;AACA,UAAI,QAAQ,mIAAmI;AAAA,QAC7I;AAAA,MACF;AACA,UAAI,CAAC,OAAO;AACV;AAAA,MACF;AACA,UAAI,IAAI,WAAW,MAAM,CAAC,CAAC;AAC3B,UAAI,QAAQ,MAA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B,kBAAkB,MAAM;AAClD,WAAO,YAAY,iBAAiB;AAAA,EACxC;AAEA,SAAO;AACX;AA3BS;",
|
|
6
|
+
"names": ["colors", "humanize"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var A=Object.create;var g=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var t=(e,r)=>g(e,"name",{value:r,configurable:!0});var G=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),J=(e,r)=>{for(var n in r)g(e,n,{get:r[n],enumerable:!0})},x=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of U(r))!O.call(e,s)&&s!==n&&g(e,s,{get:()=>r[s],enumerable:!(o=F(r,s))||o.enumerable});return e};var T=(e,r,n)=>(n=e!=null?A(B(e)):{},x(r||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),_=e=>x(g({},"__esModule",{value:!0}),e);var v=G((re,D)=>{"use strict";var i=1e3,c=i*60,f=c*60,u=f*24,z=u*7,L=u*365.25;D.exports=function(e,r){r=r||{};var n=typeof e;if(n==="string"&&e.length>0)return P(e);if(n==="number"&&isFinite(e))return r.long?j(e):$(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function P(e){if(e=String(e),!(e.length>100)){var r=/^(-?(?:\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(r){var n=parseFloat(r[1]),o=(r[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return n*L;case"weeks":case"week":case"w":return n*z;case"days":case"day":case"d":return n*u;case"hours":case"hour":case"hrs":case"hr":case"h":return n*f;case"minutes":case"minute":case"mins":case"min":case"m":return n*c;case"seconds":case"second":case"secs":case"sec":case"s":return n*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}t(P,"parse");function $(e){var r=Math.abs(e);return r>=u?Math.round(e/u)+"d":r>=f?Math.round(e/f)+"h":r>=c?Math.round(e/c)+"m":r>=i?Math.round(e/i)+"s":e+"ms"}t($,"fmtShort");function j(e){var r=Math.abs(e);return r>=u?m(e,r,u,"day"):r>=f?m(e,r,f,"hour"):r>=c?m(e,r,c,"minute"):r>=i?m(e,r,i,"second"):e+" ms"}t(j,"fmtLong");function m(e,r,n,o){var s=r>=n*1.5;return Math.round(e/n)+" "+o+(s?"s":"")}t(m,"plural")});var Y={};J(Y,{createDebug:()=>b,default:()=>H});module.exports=_(Y);var N=T(v(),1);function w(e){return e instanceof Error?e.stack||e.message:String(e)}t(w,"coerce");function E(e,r){let n=0;for(let o=0;o<e.length;o++)n=(n<<5)-n+e.charCodeAt(o),n|=0;return r[Math.abs(n)%r.length]}t(E,"selectColor");function S(e){return e.split(/[\s,]+/).filter(Boolean).map(o=>o.replace(/\*/g,".*?")).map(o=>new RegExp("^"+o+"$"))}t(S,"createRegexFromEnvVar");function M(e=6){return Math.random().toString(20).substring(2,e)}t(M,"generateRandomString");var C=t(function(e){},"noop");C.extend=function(e){return C};var Z=console.log||(()=>{}),q=["#0066CC","#CC0066","#66CC00","#CC6600","#6600CC","#00CC66","#CC0000","#0000CC","#00CCCC","#CCCC00","#CC00CC","#666666"];var H=b;function I(e,r){if(r===!0)return!0;let n=typeof globalThis<"u"&&globalThis.DEBUG||typeof process<"u"&&process.env?.DEBUG;return n==="*"?!0:e==="DEV"?!n:n?S(n).some(s=>s.test(e)):!1}t(I,"isEnabled");function K(){return{j:t(function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+String(r)}},"j")}}t(K,"createFormatters");function Q(e,r,{prevTime:n,color:o},s){if(r=r||[],!I(e,s))return;let a=Number(new Date),l=a-(n||a);n=a,r[0]=w(r[0]);let p=K();typeof r[0]!="string"&&r.unshift("%O");let d=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,(h,V)=>{if(h==="%%")return"%";d++;let y=p[V];if(typeof y=="function"){let k=r[d];h=y.call(globalThis,k),r.splice(d,1),d--}return h});let R=X({diff:l,color:o,useColors:W(),namespace:e},r);Z(...R)}t(Q,"logger");function W(){return!1}t(W,"shouldUseColors");function X({diff:e,namespace:r},n){return n[0]=r+" "+n[0]+" +"+(0,N.default)(e,{}),n}t(X,"formatArgs");function b(e){if(e===!1)return C;let r=Number(new Date),n=E(typeof e=="string"?e:M(10),q),o=e===!0,s=typeof e=="string"?e:"DEV",a=t(function(...l){return Q(s,l,{prevTime:r,color:n},o)},"debug");return a.extend=function(l){let p=s+":"+l;return b(p)},a}t(b,"createDebug");
|
|
2
|
+
//# sourceMappingURL=index.min.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../node_modules/ms/index.js", "../../src/cloudflare/index.ts", "../../src/common.ts", "../../src/noop.ts"],
|
|
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": "uqBAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cAIA,IAAIC,EAAI,IACJC,EAAID,EAAI,GACRE,EAAID,EAAI,GACRE,EAAID,EAAI,GACRE,EAAID,EAAI,EACRE,EAAIF,EAAI,OAgBZJ,EAAO,QAAU,SAAUO,EAAKC,EAAS,CACvCA,EAAUA,GAAW,CAAC,EACtB,IAAIC,EAAO,OAAOF,EAClB,GAAIE,IAAS,UAAYF,EAAI,OAAS,EACpC,OAAOG,EAAMH,CAAG,EACX,GAAIE,IAAS,UAAY,SAASF,CAAG,EAC1C,OAAOC,EAAQ,KAAOG,EAAQJ,CAAG,EAAIK,EAASL,CAAG,EAEnD,MAAM,IAAI,MACR,wDACE,KAAK,UAAUA,CAAG,CACtB,CACF,EAUA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MG,EAAYJ,EAAWG,CAAM,EACnC,GAAI,OAAOC,GAAc,WAAY,CACjC,IAAMC,EAAMX,EAAKO,CAAK,EACtBC,EAAQE,EAAU,KAAK,WAAYC,CAAG,EAItCX,EAAK,OAAOO,EAAO,CAAC,EACpBA,GACJ,CACA,OAAOC,CACX,CAAC,EAGD,IAAMI,EAAQC,EAAW,CACrB,KAAAT,EACA,MAAAF,EACA,UAAWY,EAAgB,EAC3B,UAAAxB,CACJ,EAAGU,CAAI,EAEPe,EAAI,GAAGH,CAAK,CAChB,CArDSjB,EAAAI,EAAA,UAuDT,SAASe,GAA4B,CAGjC,MAAO,EACX,CAJSnB,EAAAmB,EAAA,mBAST,SAASD,EAAY,CAAE,KAAAT,EAAM,UAAAd,CAAU,EAKpCU,EAAM,CACL,OAAAA,EAAK,CAAC,EAAIV,EAAY,IAAMU,EAAK,CAAC,EAAI,QAAO,EAAAgB,SAASZ,EAAM,CAAC,CAAC,EACvDJ,CACX,CARSL,EAAAkB,EAAA,cAeT,SAASzB,EAAaE,EAAkD,CACpE,GAAIA,IAAc,GAAO,OAAO2B,EAChC,IAAMhB,EAAW,OAAO,IAAI,IAAM,EAC5BC,EAAQgB,EACV,OAAO5B,GAAc,SAAWA,EAAY6B,EAAqB,EAAE,EACnEC,CACJ,EAGM7B,EAAgBD,IAAc,GAC9B+B,EAAkB,OAAO/B,GAAc,SAAWA,EAAY,MAE9DgC,EAAQ3B,EAAA,YAAaK,EAAa,CACpC,OAAOD,EACHsB,EACArB,EACA,CAAE,SAAAC,EAAU,MAAAC,CAAM,EAClBX,CACJ,CACJ,EAPc,SASd,OAAA+B,EAAM,OAAS,SAAUC,EAAuC,CAC5D,IAAMC,EAAoBH,EAAkB,IAAME,EAClD,OAAOnC,EAAYoC,CAAiB,CACxC,EAEOF,CACX,CA3BS3B,EAAAP,EAAA",
|
|
6
|
+
"names": ["require_ms", "__commonJSMin", "exports", "module", "s", "m", "h", "d", "w", "y", "val", "options", "type", "parse", "fmtLong", "fmtShort", "str", "match", "__name", "ms", "msAbs", "plural", "name", "isPlural", "index_exports", "__export", "createDebug", "index_default", "__toCommonJS", "import_ms", "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", "forcedEnabled", "DEBUG", "createRegexFromEnvVar", "regex", "__name", "createFormatters", "v", "error", "logger", "args", "prevTime", "color", "curr", "diff", "coerce", "formatters", "index", "match", "format", "formatter", "val", "_args", "formatArgs", "shouldUseColors", "log", "humanize", "noop", "selectColor", "generateRandomString", "colors", "actualNamespace", "debug", "extension", "extendedNamespace"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var k=Object.create;var h=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var t=(e,r)=>h(e,"name",{value:r,configurable:!0});var O=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var G=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of F(r))!B.call(e,s)&&s!==n&&h(e,s,{get:()=>r[s],enumerable:!(o=A(r,s))||o.enumerable});return e};var J=(e,r,n)=>(n=e!=null?k(U(e)):{},G(r||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e));var x=O((W,y)=>{"use strict";var i=1e3,c=i*60,f=c*60,u=f*24,T=u*7,_=u*365.25;y.exports=function(e,r){r=r||{};var n=typeof e;if(n==="string"&&e.length>0)return z(e);if(n==="number"&&isFinite(e))return r.long?P(e):L(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function z(e){if(e=String(e),!(e.length>100)){var r=/^(-?(?:\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(r){var n=parseFloat(r[1]),o=(r[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return n*_;case"weeks":case"week":case"w":return n*T;case"days":case"day":case"d":return n*u;case"hours":case"hour":case"hrs":case"hr":case"h":return n*f;case"minutes":case"minute":case"mins":case"min":case"m":return n*c;case"seconds":case"second":case"secs":case"sec":case"s":return n*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}t(z,"parse");function L(e){var r=Math.abs(e);return r>=u?Math.round(e/u)+"d":r>=f?Math.round(e/f)+"h":r>=c?Math.round(e/c)+"m":r>=i?Math.round(e/i)+"s":e+"ms"}t(L,"fmtShort");function P(e){var r=Math.abs(e);return r>=u?d(e,r,u,"day"):r>=f?d(e,r,f,"hour"):r>=c?d(e,r,c,"minute"):r>=i?d(e,r,i,"second"):e+" ms"}t(P,"fmtLong");function d(e,r,n,o){var s=r>=n*1.5;return Math.round(e/n)+" "+o+(s?"s":"")}t(d,"plural")});var S=J(x(),1);function D(e){return e instanceof Error?e.stack||e.message:String(e)}t(D,"coerce");function v(e,r){let n=0;for(let o=0;o<e.length;o++)n=(n<<5)-n+e.charCodeAt(o),n|=0;return r[Math.abs(n)%r.length]}t(v,"selectColor");function w(e){return e.split(/[\s,]+/).filter(Boolean).map(o=>o.replace(/\*/g,".*?")).map(o=>new RegExp("^"+o+"$"))}t(w,"createRegexFromEnvVar");function E(e=6){return Math.random().toString(20).substring(2,e)}t(E,"generateRandomString");var m=t(function(e){},"noop");m.extend=function(e){return m};var $=console.log||(()=>{}),j=["#0066CC","#CC0066","#66CC00","#CC6600","#6600CC","#00CC66","#CC0000","#0000CC","#00CCCC","#CCCC00","#CC00CC","#666666"];var se=M;function Z(e,r){if(r===!0)return!0;let n=typeof globalThis<"u"&&globalThis.DEBUG||typeof process<"u"&&process.env?.DEBUG;return n==="*"?!0:e==="DEV"?!n:n?w(n).some(s=>s.test(e)):!1}t(Z,"isEnabled");function q(){return{j:t(function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+String(r)}},"j")}}t(q,"createFormatters");function H(e,r,{prevTime:n,color:o},s){if(r=r||[],!Z(e,s))return;let a=Number(new Date),l=a-(n||a);n=a,r[0]=D(r[0]);let C=q();typeof r[0]!="string"&&r.unshift("%O");let g=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,(p,R)=>{if(p==="%%")return"%";g++;let b=C[R];if(typeof b=="function"){let V=r[g];p=b.call(globalThis,V),r.splice(g,1),g--}return p});let N=K({diff:l,color:o,useColors:I(),namespace:e},r);$(...N)}t(H,"logger");function I(){return!1}t(I,"shouldUseColors");function K({diff:e,namespace:r},n){return n[0]=r+" "+n[0]+" +"+(0,S.default)(e,{}),n}t(K,"formatArgs");function M(e){if(e===!1)return m;let r=Number(new Date),n=v(typeof e=="string"?e:E(10),j),o=e===!0,s=typeof e=="string"?e:"DEV",a=t(function(...l){return H(s,l,{prevTime:r,color:n},o)},"debug");return a.extend=function(l){let C=s+":"+l;return M(C)},a}t(M,"createDebug");export{M as createDebug,se as default};
|
|
2
|
+
//# sourceMappingURL=index.min.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../node_modules/ms/index.js", "../../src/cloudflare/index.ts", "../../src/common.ts", "../../src/noop.ts"],
|
|
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": "4jBAAA,IAAAA,EAAAC,EAAA,CAAAC,EAAAC,IAAA,cAIA,IAAIC,EAAI,IACJC,EAAID,EAAI,GACRE,EAAID,EAAI,GACRE,EAAID,EAAI,GACRE,EAAID,EAAI,EACRE,EAAIF,EAAI,OAgBZJ,EAAO,QAAU,SAAUO,EAAKC,EAAS,CACvCA,EAAUA,GAAW,CAAC,EACtB,IAAIC,EAAO,OAAOF,EAClB,GAAIE,I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ACxC,EAEOF,CACX,CA3BS3B,EAAAP,EAAA",
|
|
6
|
+
"names": ["require_ms", "__commonJSMin", "exports", "module", "s", "m", "h", "d", "w", "y", "val", "options", "type", "parse", "fmtLong", "fmtShort", "str", "match", "__name", "ms", "msAbs", "plural", "name", "isPlural", "import_ms", "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", "forcedEnabled", "DEBUG", "createRegexFromEnvVar", "regex", "__name", "createFormatters", "v", "error", "logger", "args", "prevTime", "color", "curr", "diff", "coerce", "formatters", "index", "match", "format", "formatter", "val", "_args", "formatArgs", "shouldUseColors", "log", "humanize", "noop", "selectColor", "generateRandomString", "colors", "actualNamespace", "debug", "extension", "extendedNamespace"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@substrate-system/debug",
|
|
3
3
|
"description": "Debug utility",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.9.
|
|
5
|
+
"version": "0.9.15",
|
|
6
6
|
"main": "./dist/node.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"./dist/*"
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"import": "./dist/node.js",
|
|
14
14
|
"require": "./dist/node.cjs"
|
|
15
15
|
},
|
|
16
|
+
"worker": {
|
|
17
|
+
"import": "./dist/cloudflare/index.js",
|
|
18
|
+
"require": "./dist/cloudflare/index.cjs"
|
|
19
|
+
},
|
|
16
20
|
"browser": {
|
|
17
21
|
"import": "./dist/browser/index.js",
|
|
18
22
|
"require": "./dist/browser/index.cjs"
|
|
@@ -30,6 +34,10 @@
|
|
|
30
34
|
"import": "./dist/browser/index.js",
|
|
31
35
|
"require": "./dist/browser/index.cjs"
|
|
32
36
|
},
|
|
37
|
+
"./cloudflare": {
|
|
38
|
+
"import": "./dist/cloudflare/index.js",
|
|
39
|
+
"require": "./dist/cloudflare/index.cjs"
|
|
40
|
+
},
|
|
33
41
|
"./*": {
|
|
34
42
|
"import": "./dist/*.js",
|
|
35
43
|
"require": "./dist/*.cjs"
|
|
@@ -39,11 +47,13 @@
|
|
|
39
47
|
"lint": "eslint \"./**/*.{ts,js}\"",
|
|
40
48
|
"test:node": "esbuild ./test/index.ts --format=esm --bundle --platform=node | node --input-type=module",
|
|
41
49
|
"test:browser": "esbuild ./test/test-browser.ts --bundle | npx tapout",
|
|
42
|
-
"test": "npm run
|
|
43
|
-
"build-
|
|
44
|
-
"
|
|
45
|
-
"build-
|
|
46
|
-
"build-
|
|
50
|
+
"test:cloudflare": "npm run build-cloudflare-worker && node --test test/test-miniflare.mjs",
|
|
51
|
+
"build-cloudflare-worker": "esbuild test/cloudflare-worker.js --format=esm --bundle --platform=neutral --outfile=test/cloudflare-worker-bundled.js",
|
|
52
|
+
"test": "npm run test:browser && npm run test:node && npm run test:cloudflare",
|
|
53
|
+
"build-cjs": "esbuild src/node.ts --format=cjs --bundle --platform=node --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --out-extension:.js=.cjs --sourcemap --external:supports-color --external:@substrate-system/util && esbuild src/browser/index.ts --format=cjs --bundle --keep-names --tsconfig=tsconfig.build.json --outfile=./dist/browser/index.cjs --sourcemap && esbuild src/cloudflare/index.ts --format=cjs --bundle --platform=neutral --keep-names --tsconfig=tsconfig.build.json --outfile=./dist/cloudflare/index.cjs --sourcemap",
|
|
54
|
+
"build-cjs:min": "esbuild src/node.ts --format=cjs --bundle --platform=node --minify --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --out-extension:.js=.min.cjs --sourcemap --external:supports-color --external:@substrate-system/util && esbuild src/browser/index.ts --format=cjs --bundle --minify --keep-names --tsconfig=tsconfig.build.json --outfile=./dist/browser/index.min.cjs --sourcemap && esbuild src/cloudflare/index.ts --format=cjs --bundle --platform=neutral --minify --keep-names --tsconfig=tsconfig.build.json --outfile=./dist/cloudflare/index.min.cjs --sourcemap",
|
|
55
|
+
"build-esm": "esbuild src/node.ts --format=esm --bundle --platform=node --metafile=dist/meta.json --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --sourcemap --external:supports-color --external:@substrate-system/util && esbuild src/browser/index.ts --format=esm --bundle --keep-names --tsconfig=tsconfig.build.json --outfile=./dist/browser/index.js --sourcemap && esbuild src/cloudflare/index.ts --format=esm --bundle --platform=neutral --keep-names --tsconfig=tsconfig.build.json --outfile=./dist/cloudflare/index.js --sourcemap && tsc --emitDeclarationOnly --project tsconfig.build.json --outDir dist",
|
|
56
|
+
"build-esm:min": "esbuild src/node.ts --format=esm --bundle --platform=node --keep-names --minify --tsconfig=tsconfig.build.json --out-extension:.js=.min.js --outdir=./dist --sourcemap --external:supports-color --external:@substrate-system/util && esbuild src/browser/index.ts --format=esm --bundle --keep-names --minify --tsconfig=tsconfig.build.json --outfile=./dist/browser/index.min.js --sourcemap && esbuild src/cloudflare/index.ts --format=esm --bundle --platform=neutral --keep-names --minify --tsconfig=tsconfig.build.json --outfile=./dist/cloudflare/index.min.js --sourcemap",
|
|
47
57
|
"build": "mkdir -p ./dist && rm -rf ./dist/* && npm run build-cjs && npm run build-esm && npm run build-esm:min && npm run build-cjs:min",
|
|
48
58
|
"exmaple:node": "npx esbuild --platform=node --bundle ./example/node.ts | DEBUG=\"hello:*\" node",
|
|
49
59
|
"build-example": "vite build",
|
|
@@ -72,6 +82,7 @@
|
|
|
72
82
|
"eslint-config-standard": "^17.1.0",
|
|
73
83
|
"http-server": "^14.1.1",
|
|
74
84
|
"markdown-toc": "^1.2.0",
|
|
85
|
+
"miniflare": "^4.20250829.0",
|
|
75
86
|
"tap-spec": "^5.0.0",
|
|
76
87
|
"typedoc": "^0.28.1",
|
|
77
88
|
"typescript": "^5.4.5",
|