@leftium/gg 0.0.33 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/gg.d.ts CHANGED
@@ -94,6 +94,13 @@ export declare namespace gg {
94
94
  col?: number;
95
95
  src?: string;
96
96
  }, ...args: unknown[]) => unknown;
97
+ let _o: (ns: string, file?: string, line?: number, col?: number, src?: string) => {
98
+ ns: string;
99
+ file?: string;
100
+ line?: number;
101
+ col?: number;
102
+ src?: string;
103
+ };
97
104
  }
98
105
  /**
99
106
  * Run gg diagnostics and log configuration status
package/dist/gg.js CHANGED
@@ -1,4 +1,4 @@
1
- import debugFactory from './debug.js';
1
+ import debugFactory, {} from './debug/index.js';
2
2
  import { BROWSER, DEV } from 'esm-env';
3
3
  import { toWordTuple } from './words.js';
4
4
  const _ggCallSitesPlugin = typeof __GG_TAG_PLUGIN__ !== 'undefined' ? __GG_TAG_PLUGIN__ : false;
@@ -8,23 +8,21 @@ const _ggCallSitesPlugin = typeof __GG_TAG_PLUGIN__ !== 'undefined' ? __GG_TAG_P
8
8
  */
9
9
  function createGgDebugger(namespace) {
10
10
  const dbg = debugFactory(namespace);
11
- // Store the original formatArgs (if it exists)
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ // Store the original formatArgs
13
12
  const originalFormatArgs = dbg.formatArgs;
14
13
  // Override formatArgs to add padding to the namespace display
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
14
  dbg.formatArgs = function (args) {
17
15
  // Call original formatArgs first
18
16
  if (originalFormatArgs) {
19
- originalFormatArgs.call(this, args);
17
+ originalFormatArgs.call(dbg, args);
20
18
  }
21
19
  // Extract the callpoint from namespace (strip 'gg:' prefix and any URL suffix)
22
- const nsMatch = this.namespace.match(/^gg:([^h]+?)(?:http|$)/);
23
- const callpoint = nsMatch ? nsMatch[1] : this.namespace.replace(/^gg:/, '');
20
+ const nsMatch = dbg.namespace.match(/^gg:([^h]+?)(?:http|$)/);
21
+ const callpoint = nsMatch ? nsMatch[1] : dbg.namespace.replace(/^gg:/, '');
24
22
  const paddedCallpoint = callpoint.padEnd(maxCallpointLength, ' ');
25
23
  // Replace the namespace in the formatted string with padded version
26
24
  if (typeof args[0] === 'string') {
27
- args[0] = args[0].replace(this.namespace, `gg:${paddedCallpoint}`);
25
+ args[0] = args[0].replace(dbg.namespace, `gg:${paddedCallpoint}`);
28
26
  }
29
27
  };
30
28
  return dbg;
@@ -167,6 +165,23 @@ const namespaceToLogFunction = new Map();
167
165
  let maxCallpointLength = 0;
168
166
  // Cache: raw stack line → word tuple (avoids re-hashing the same call site)
169
167
  const stackLineCache = new Map();
168
+ /**
169
+ * Resolve the callpoint for the caller at the given stack depth.
170
+ * depth=2 → caller of gg(), depth=3 → caller of gg.ns() (extra frame).
171
+ */
172
+ function resolveCallpoint(depth) {
173
+ const rawStack = new Error().stack || '';
174
+ const callerLine = rawStack.split('\n')[depth] || rawStack;
175
+ const callerKey = callerLine.replace(/:\d+:\d+\)?$/, '').trim();
176
+ const callpoint = stackLineCache.get(callerKey) ?? toWordTuple(callerKey);
177
+ if (!stackLineCache.has(callerKey)) {
178
+ stackLineCache.set(callerKey, callpoint);
179
+ }
180
+ if (callpoint.length < 80 && callpoint.length > maxCallpointLength) {
181
+ maxCallpointLength = callpoint.length;
182
+ }
183
+ return callpoint;
184
+ }
170
185
  /**
171
186
  * Reset the namespace width tracking.
172
187
  * Useful after configuration checks that may have long callpoint paths.
@@ -190,22 +205,8 @@ export function gg(...args) {
190
205
  // When the plugin IS installed, all gg() calls are rewritten to gg._ns() at build time,
191
206
  // so this code path only runs for un-transformed calls (i.e. plugin not installed).
192
207
  // Same call site always produces the same word pair (e.g. "calm-fox").
193
- const rawStack = new Error().stack || '';
194
- // Stack line [2]: skip "Error" header [0] and gg() frame [1]
195
- const callerLine = rawStack.split('\n')[2] || rawStack;
196
- // Strip line:col numbers so all gg() calls within the same function
197
- // hash to the same word tuple. In minified builds, multiple gg() calls
198
- // in one function differ only by column offset — we want them grouped.
199
- // Chrome: "at handleClick (chunk-abc.js:1:45892)" → "at handleClick (chunk-abc.js)"
200
- // Firefox: "handleClick@https://...:1:45892" → "handleClick@https://..."
201
- const callerKey = callerLine.replace(/:\d+:\d+\)?$/, '').trim();
202
- const callpoint = stackLineCache.get(callerKey) ?? toWordTuple(callerKey);
203
- if (!stackLineCache.has(callerKey)) {
204
- stackLineCache.set(callerKey, callpoint);
205
- }
206
- if (callpoint.length < 80 && callpoint.length > maxCallpointLength) {
207
- maxCallpointLength = callpoint.length;
208
- }
208
+ // depth=2: skip "Error" header [0] and gg() frame [1]
209
+ const callpoint = resolveCallpoint(2);
209
210
  const namespace = `gg:${callpoint}`;
210
211
  const ggLogFunction = namespaceToLogFunction.get(namespace) ||
211
212
  namespaceToLogFunction.set(namespace, createGgDebugger(namespace)).get(namespace);
@@ -261,15 +262,32 @@ export function gg(...args) {
261
262
  * across builds. For the internal plugin-generated version with file
262
263
  * metadata, see gg._ns().
263
264
  *
265
+ * The label supports template variables (substituted by the vite plugin
266
+ * at build time, or at runtime for $NS):
267
+ * $NS - auto-generated callpoint (file@fn with plugin, word-tuple without)
268
+ * $FN - enclosing function name (plugin only, empty without)
269
+ * $FILE - short file path (plugin only, empty without)
270
+ * $LINE - line number (plugin only, empty without)
271
+ * $COL - column number (plugin only, empty without)
272
+ *
264
273
  * @param nsLabel - The namespace label (appears as gg:<nsLabel> in output)
265
274
  * @param args - Same arguments as gg()
266
275
  * @returns Same as gg() - the first arg, or call-site info if no args
267
276
  *
268
277
  * @example
269
- * gg.ns("auth", "login failed") // logs under namespace "gg:auth"
270
- * gg.ns("cart", item, quantity) // logs under namespace "gg:cart"
278
+ * gg.ns("auth", "login failed") // gg:auth
279
+ * gg.ns("ERROR:$NS", msg) // gg:ERROR:routes/+page.svelte@handleClick (with plugin)
280
+ * // → gg:ERROR:calm-fox (without plugin)
281
+ * gg.ns("$NS:validation", fieldName) // → gg:routes/+page.svelte@handleClick:validation
271
282
  */
272
283
  gg.ns = function (nsLabel, ...args) {
284
+ // Resolve $NS at runtime (word-tuple fallback when plugin isn't installed).
285
+ // With the plugin, $NS is already substituted at build time before this runs.
286
+ // depth=3: skip "Error" [0], resolveCallpoint [1], gg.ns [2] → caller [3]
287
+ if (nsLabel.includes('$NS')) {
288
+ const callpoint = resolveCallpoint(3);
289
+ nsLabel = nsLabel.replace(/\$NS/g, callpoint);
290
+ }
273
291
  return gg._ns({ ns: nsLabel }, ...args);
274
292
  };
275
293
  /**
@@ -343,6 +361,18 @@ gg._ns = function (options, ...args) {
343
361
  }
344
362
  return returnValue;
345
363
  };
364
+ /**
365
+ * gg._o() - Internal: build options object for gg._ns() without object literal syntax.
366
+ *
367
+ * Used by the vite plugin to transform gg() calls in Svelte template markup,
368
+ * where object literals ({...}) would break Svelte's template parser.
369
+ *
370
+ * In <script> blocks: gg._ns({ns:'...', file:'...', line:1, col:1}, args)
371
+ * In template markup: gg._ns(gg._o('...','...',1,1), args)
372
+ */
373
+ gg._o = function (ns, file, line, col, src) {
374
+ return { ns, file, line, col, src };
375
+ };
346
376
  gg.disable = isCloudflareWorker() ? () => { } : debugFactory.disable;
347
377
  gg.enable = isCloudflareWorker() ? () => { } : debugFactory.enable;
348
378
  /**
@@ -499,26 +529,28 @@ Object.defineProperty(gg, '_onLog', {
499
529
  // eslint-disable-next-line @typescript-eslint/no-namespace
500
530
  (function (gg) {
501
531
  })(gg || (gg = {}));
532
+ // Track if diagnostics have already run to prevent double execution
533
+ let diagnosticsRan = false;
502
534
  /**
503
535
  * Run gg diagnostics and log configuration status
504
536
  * Can be called immediately or delayed (e.g., after Eruda loads)
505
537
  */
506
538
  export async function runGgDiagnostics() {
507
- if (!ggConfig.showHints || isCloudflareWorker())
539
+ if (!ggConfig.showHints || isCloudflareWorker() || diagnosticsRan)
508
540
  return;
541
+ diagnosticsRan = true;
542
+ // Create test debugger for server-side enabled check
509
543
  const ggLogTest = debugFactory('gg:TEST');
510
544
  let ggMessage = '\n';
511
- // Utilities for forming ggMessage:
512
545
  const message = (s) => (ggMessage += `${s}\n`);
513
546
  const checkbox = (test) => (test ? '✅' : '❌');
514
547
  const makeHint = (test, ifTrue, ifFalse = '') => (test ? ifTrue : ifFalse);
515
- // Use plain console.log for diagnostics - appears in Eruda's Console tab
516
548
  console.log(`Loaded gg module. Checking configuration...`);
517
- if (ggConfig.enabled && ggLogTest.enabled) {
518
- gg('If you can see this logg, gg configured correctly!');
549
+ const configOk = BROWSER ? ggConfig.enabled : ggConfig.enabled && ggLogTest.enabled;
550
+ if (configOk) {
519
551
  message(`No problems detected:`);
520
552
  if (BROWSER) {
521
- message(`ℹ️ If gg output not visible: enable "Verbose" log level in DevTools, or check Eruda's GG tab.`);
553
+ message(`ℹ️ gg messages appear in the Eruda GG panel. Use Settings > Native Console to also show in browser console.`);
522
554
  }
523
555
  }
524
556
  else {
@@ -534,35 +566,27 @@ export async function runGgDiagnostics() {
534
566
  }
535
567
  }
536
568
  message(`${checkbox(ggConfig.enabled)} gg enabled: ${ggConfig.enabled}${enableHint}`);
537
- if (BROWSER) {
538
- const hint = makeHint(!ggLogTest.enabled, " (Try `localStorage.debug = 'gg:*'`)");
539
- message(`${checkbox(ggLogTest.enabled)} localStorage.debug: ${localStorage?.debug}${hint}`);
540
- }
541
- else {
542
- const hint = makeHint(!ggLogTest.enabled, ' (Try `DEBUG=gg:* npm dev`)');
569
+ if (!BROWSER) {
570
+ // Server-side: check DEBUG env var (the only output path on the server)
571
+ const hint = makeHint(!ggLogTest.enabled, ' (Try `DEBUG=gg:* npm run dev`)');
543
572
  if (dotenvModule) {
544
- dotenvModule.config(); // Load the environment variables
573
+ dotenvModule.config();
545
574
  }
546
575
  message(`${checkbox(ggLogTest.enabled)} DEBUG env variable: ${process?.env?.DEBUG}${hint}`);
547
576
  }
548
- // Optional plugin diagnostics listed last
577
+ // Optional plugin diagnostics
549
578
  message(makeHint(_ggCallSitesPlugin, `✅ gg-call-sites vite plugin detected! Call-site namespaces and open-in-editor links baked in at build time.`, `⚠️ gg-call-sites vite plugin not detected. Add ggCallSitesPlugin() to vite.config.ts for file:line call-site namespaces and open-in-editor links. Without plugin, using word-tuple names (e.g. calm-fox) as call-site identifiers.`));
550
579
  if (BROWSER && DEV) {
551
580
  const { status } = await fetch('/__open-in-editor?file=+');
552
581
  message(makeHint(status === 222, `✅ (optional) open-in-editor vite plugin detected! (status code: ${status}) Clickable links open source files in editor.`, `⚠️ (optional) open-in-editor vite plugin not detected. (status code: ${status}) Add openInEditorPlugin() to vite.config.ts for clickable links that open source files in editor`));
553
582
  }
554
- // Use plain console.log for diagnostics - appears in Eruda's Console tab
555
583
  console.log(ggMessage);
556
- // Reset namespace width after configuration check
557
- // This prevents the long callpoint from the config check from affecting subsequent logs
558
584
  resetNamespaceWidth();
559
585
  }
560
- // Run diagnostics immediately on module load if Eruda is not being used
561
- // (If Eruda will load, the loader will call runGgDiagnostics after Eruda is ready)
562
- if (ggConfig.showHints && !isCloudflareWorker()) {
563
- // Only run immediately if we're not in a context where Eruda might load
564
- // In browser dev mode, assume Eruda might load and skip immediate diagnostics
565
- if (!BROWSER || !DEV) {
566
- runGgDiagnostics();
567
- }
586
+ // Run diagnostics immediately on module load ONLY in Node.js environments
587
+ // In browser, the Eruda loader (if configured) will call runGgDiagnostics()
588
+ // after Eruda is ready. If Eruda is not configured, diagnostics won't run
589
+ // in browser (user must manually check console or call runGgDiagnostics()).
590
+ if (ggConfig.showHints && !isCloudflareWorker() && !BROWSER) {
591
+ runGgDiagnostics();
568
592
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { gg, fg, bg } from './gg.js';
2
2
  import openInEditorPlugin from './open-in-editor.js';
3
3
  import ggCallSitesPlugin from './gg-call-sites-plugin.js';
4
+ export { default as GgConsole } from './GgConsole.svelte';
4
5
  export { gg, fg, bg, openInEditorPlugin, ggCallSitesPlugin };
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@
2
2
  import { gg, fg, bg } from './gg.js';
3
3
  import openInEditorPlugin from './open-in-editor.js';
4
4
  import ggCallSitesPlugin from './gg-call-sites-plugin.js';
5
+ export { default as GgConsole } from './GgConsole.svelte';
5
6
  export { gg, fg, bg, openInEditorPlugin, ggCallSitesPlugin };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { Plugin } from 'vite';
2
+ import ggCallSitesPlugin from './gg-call-sites-plugin.js';
3
+ import type { GgCallSitesPluginOptions } from './gg-call-sites-plugin.js';
4
+ import openInEditorPlugin from './open-in-editor.js';
5
+ export interface GgPluginsOptions {
6
+ /**
7
+ * Options for the call-sites Vite plugin (source metadata rewriting).
8
+ * @default {}
9
+ */
10
+ callSites?: GgCallSitesPluginOptions;
11
+ /**
12
+ * Enable the open-in-editor Vite plugin (dev server middleware).
13
+ * Set to `false` to disable.
14
+ * @default true
15
+ */
16
+ openInEditor?: boolean;
17
+ }
18
+ /**
19
+ * All gg Vite plugins bundled together.
20
+ *
21
+ * Includes:
22
+ * - `ggCallSitesPlugin` — rewrites `gg()` calls with source file/line/col metadata
23
+ * - `openInEditorPlugin` — adds `/__open-in-editor` dev server middleware
24
+ * - Automatic `es2022` build target (required for top-level await)
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import ggPlugins from '@leftium/gg/vite';
29
+ *
30
+ * export default defineConfig({
31
+ * plugins: [sveltekit(), ...ggPlugins()]
32
+ * });
33
+ * ```
34
+ */
35
+ export default function ggPlugins(options?: GgPluginsOptions): Plugin[];
36
+ export { ggCallSitesPlugin, openInEditorPlugin };
37
+ export type { GgCallSitesPluginOptions };
package/dist/vite.js ADDED
@@ -0,0 +1,46 @@
1
+ import ggCallSitesPlugin from './gg-call-sites-plugin.js';
2
+ import openInEditorPlugin from './open-in-editor.js';
3
+ /**
4
+ * All gg Vite plugins bundled together.
5
+ *
6
+ * Includes:
7
+ * - `ggCallSitesPlugin` — rewrites `gg()` calls with source file/line/col metadata
8
+ * - `openInEditorPlugin` — adds `/__open-in-editor` dev server middleware
9
+ * - Automatic `es2022` build target (required for top-level await)
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import ggPlugins from '@leftium/gg/vite';
14
+ *
15
+ * export default defineConfig({
16
+ * plugins: [sveltekit(), ...ggPlugins()]
17
+ * });
18
+ * ```
19
+ */
20
+ export default function ggPlugins(options = {}) {
21
+ const plugins = [];
22
+ // Ensure es2022 target for top-level await support
23
+ plugins.push({
24
+ name: 'gg-config',
25
+ config() {
26
+ return {
27
+ build: {
28
+ target: 'es2022'
29
+ },
30
+ optimizeDeps: {
31
+ esbuildOptions: {
32
+ target: 'es2022',
33
+ supported: { 'top-level-await': true }
34
+ }
35
+ }
36
+ };
37
+ }
38
+ });
39
+ plugins.push(ggCallSitesPlugin(options.callSites));
40
+ if (options.openInEditor !== false) {
41
+ plugins.push(openInEditorPlugin());
42
+ }
43
+ return plugins;
44
+ }
45
+ // Allow granular imports for advanced users
46
+ export { ggCallSitesPlugin, openInEditorPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leftium/gg",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Leftium/gg.git"
@@ -9,9 +9,7 @@
9
9
  "files": [
10
10
  "dist",
11
11
  "!dist/**/*.test.*",
12
- "!dist/**/*.spec.*",
13
- "!dist/debug/",
14
- "patches/"
12
+ "!dist/**/*.spec.*"
15
13
  ],
16
14
  "sideEffects": [
17
15
  "**/*.css"
@@ -21,8 +19,13 @@
21
19
  "exports": {
22
20
  ".": {
23
21
  "types": "./dist/index.d.ts",
22
+ "svelte": "./dist/index.js",
24
23
  "default": "./dist/index.js"
25
24
  },
25
+ "./vite": {
26
+ "types": "./dist/vite.d.ts",
27
+ "default": "./dist/vite.js"
28
+ },
26
29
  "./eruda": {
27
30
  "types": "./dist/eruda/index.d.ts",
28
31
  "default": "./dist/eruda/index.js"
@@ -31,21 +34,21 @@
31
34
  "peerDependencies": {
32
35
  "svelte": "^5.0.0"
33
36
  },
37
+ "peerDependenciesMeta": {
38
+ "svelte": {
39
+ "optional": true
40
+ }
41
+ },
34
42
  "devDependencies": {
35
43
  "@eslint/compat": "^2.0.2",
36
44
  "@eslint/js": "^10.0.1",
37
45
  "@picocss/pico": "^2.1.1",
38
- "@rollup/plugin-commonjs": "^29.0.0",
39
- "@rollup/plugin-node-resolve": "^16.0.3",
40
- "@rollup/plugin-terser": "^0.4.4",
41
46
  "@sveltejs/adapter-vercel": "^6.3.1",
42
47
  "@sveltejs/kit": "^2.50.2",
43
48
  "@sveltejs/package": "^2.5.7",
44
49
  "@sveltejs/vite-plugin-svelte": "^6.2.4",
45
- "@types/debug": "^4.1.12",
46
50
  "@types/node": "^25.2.2",
47
51
  "add": "^2.0.6",
48
- "debug": "^4.4.3",
49
52
  "eruda": "^3.4.3",
50
53
  "eslint": "^10.0.0",
51
54
  "eslint-config-prettier": "^10.1.8",
@@ -54,19 +57,22 @@
54
57
  "prettier": "^3.8.1",
55
58
  "prettier-plugin-svelte": "^3.4.1",
56
59
  "publint": "^0.3.17",
57
- "rollup": "^4.57.1",
58
60
  "supports-color": "^10.2.2",
59
61
  "svelte": "^5.50.1",
60
62
  "svelte-check": "^4.3.6",
61
63
  "typescript": "^5.9.3",
62
64
  "typescript-eslint": "^8.55.0",
63
65
  "vite": "^7.3.1",
64
- "vite-plugin-devtools-json": "^1.0.0"
66
+ "vite-plugin-devtools-json": "^1.0.0",
67
+ "vitest": "^4.0.18"
65
68
  },
66
69
  "keywords": [
67
70
  "svelte"
68
71
  ],
69
72
  "dependencies": {
73
+ "@sveltejs/acorn-typescript": "^1.0.9",
74
+ "@types/estree": "^1.0.8",
75
+ "acorn": "^8.15.0",
70
76
  "dotenv": "^17.2.4",
71
77
  "esm-env": "^1.2.2",
72
78
  "launch-editor": "^2.12.0"
@@ -78,6 +84,8 @@
78
84
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
79
85
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
80
86
  "format": "prettier --write .",
81
- "lint": "prettier --check . && eslint ."
87
+ "lint": "prettier --check . && eslint .",
88
+ "test": "vitest run",
89
+ "test:watch": "vitest"
82
90
  }
83
91
  }
@@ -1,2 +0,0 @@
1
- export { w as default };
2
- declare var w: any;
@@ -1,3 +0,0 @@
1
- // @ts-nocheck
2
- // Auto-generated bundled debug library - type checking disabled
3
- import e from"tty";import t from"util";function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var r=function e(){var r=!1;try{r=this instanceof e}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var s,o,i,c,a,u={exports:{}},l={exports:{}};function f(){if(o)return s;o=1;var e=1e3,t=60*e,r=60*t,n=24*r,i=7*n,c=365.25*n;function a(e,t,r,n){var s=t>=1.5*r;return Math.round(e/r)+" "+n+(s?"s":"")}return s=function(s,o){o=o||{};var u=typeof s;if("string"===u&&s.length>0)return function(s){if((s=String(s)).length>100)return;var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!o)return;var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*c;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(s);if("number"===u&&isFinite(s))return o.long?function(s){var o=Math.abs(s);if(o>=n)return a(s,o,n,"day");if(o>=r)return a(s,o,r,"hour");if(o>=t)return a(s,o,t,"minute");if(o>=e)return a(s,o,e,"second");return s+" ms"}(s):function(s){var o=Math.abs(s);if(o>=n)return Math.round(s/n)+"d";if(o>=r)return Math.round(s/r)+"h";if(o>=t)return Math.round(s/t)+"m";if(o>=e)return Math.round(s/e)+"s";return s+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}function p(){if(c)return i;return c=1,i=function(e){function t(e){let n,s,o,i=null;function c(...e){if(!c.enabled)return;const r=c,s=Number(new Date),o=s-(n||s);r.diff=o,r.prev=n,r.curr=s,n=s,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,s)=>{if("%%"===n)return"%";i++;const o=t.formatters[s];if("function"==typeof o){const t=e[i];n=o.call(r,t),e.splice(i,1),i--}return n}),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return c.namespace=e,c.useColors=t.useColors(),c.color=t.selectColor(e),c.extend=r,c.destroy=t.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(s!==t.namespaces&&(s=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(c),c}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e,t){let r=0,n=0,s=-1,o=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(s=n,o=r,n++):(r++,n++);else{if(-1===s)return!1;n=s+1,o++,r=o}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=f(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(r=>{t[r]=e[r]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t},i}var d={exports:{}};const C=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e?.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),m=0!==C&&{level:C,hasBasic:!0,has256:C>=2,has16m:C>=3},g={stdout:m,stderr:m};var h,F,y=n(Object.freeze({__proto__:null,default:g}));function b(){return h||(h=1,function(r,n){const s=e,o=t;n.init=function(e){e.inspectOpts={};const t=Object.keys(n.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=n.inspectOpts[t[r]]},n.log=function(...e){return process.stderr.write(o.formatWithOptions(n.inspectOpts,...e)+"\n")},n.formatArgs=function(e){const{namespace:t,useColors:s}=this;if(s){const n=this.color,s="[3"+(n<8?n:"8;5;"+n),o=`${s};1m${("+"+r.exports.humanize(this.diff)).padStart(6)} ${t} `;e[0]=o+e[0].split("\n").join("\n"+o),e.push(s+"")}else e[0]=function(){if(n.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+t+" "+e[0]},n.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},n.load=function(){return process.env.DEBUG},n.useColors=function(){return"colors"in n.inspectOpts?Boolean(n.inspectOpts.colors):s.isatty(process.stderr.fd)},n.destroy=o.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),n.colors=[6,2,3,4,5,1];try{const e=y;e&&(e.stderr||e).level>=2&&(n.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}n.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{const r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase());let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[r]=n,e},{}),r.exports=p()(n);const{formatters:i}=r.exports;i.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},i.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}}(d,d.exports)),d.exports}var v=(F||(F=1,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?u.exports=(a||(a=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+`${("+"+e.exports.humanize(this.diff)).padStart(6)} ${this.namespace}`+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" "),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,s=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(s=n))}),t.splice(s,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=p()(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(l,l.exports)),l.exports):u.exports=b()),u.exports),w=r(v);export{w as default};
package/dist/debug.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export default debug;
2
- import debug from 'debug';
package/dist/debug.js DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * Re-export patched debug library
3
- * This file bundles the patched version of debug into the library distribution.
4
- *
5
- * The patch moves time diff display before namespace:
6
- * Standard: gg:file +123ms
7
- * Patched: +123ms gg:file
8
- */
9
-
10
- // In dev mode: use debug from node_modules (with patch applied via pnpm)
11
- // After build: this file is replaced by a direct import of the bundled version
12
- // See: scripts/bundle-debug.js which creates dist/debug-bundled.js
13
- import debug from './debug-bundled.js';
14
-
15
- export default debug;
@@ -1,35 +0,0 @@
1
- diff --git a/src/browser.js b/src/browser.js
2
- index 5993451b82e6b27d981e202b349641816d867ccf..a2eb7c60fb7f5a8b93b2310acb15d6f89c3a1195 100644
3
- --- a/src/browser.js
4
- +++ b/src/browser.js
5
- @@ -148,11 +148,11 @@ function useColors() {
6
-
7
- function formatArgs(args) {
8
- args[0] = (this.useColors ? '%c' : '') +
9
- - this.namespace +
10
- + `${('+' + module.exports.humanize(this.diff)).padStart(6)} ${this.namespace}` +
11
- (this.useColors ? ' %c' : ' ') +
12
- args[0] +
13
- (this.useColors ? '%c ' : ' ') +
14
- - '+' + module.exports.humanize(this.diff);
15
- + '';
16
-
17
- if (!this.useColors) {
18
- return;
19
- diff --git a/src/node.js b/src/node.js
20
- index 715560a4ca8fb4c8dd6353eafdde6e83af28f05e..3829ba356e038a60408f9f7f0ed742baab527c6b 100644
21
- --- a/src/node.js
22
- +++ b/src/node.js
23
- @@ -170,10 +170,10 @@ function formatArgs(args) {
24
- if (useColors) {
25
- const c = this.color;
26
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
27
- - const prefix = ` ${colorCode};1m${name} \u001B[0m`;
28
- + const prefix = `${colorCode};1m${('+' + module.exports.humanize(this.diff)).padStart(6)} ${name} \u001B[0m`;
29
-
30
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
31
- - args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
32
- + args.push(colorCode + '' + '\u001B[0m');
33
- } else {
34
- args[0] = getDate() + name + ' ' + args[0];
35
- }