@leftium/gg 0.0.19 → 0.0.21
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/debug/src/browser.d.ts +1 -4
- package/dist/debug/src/index.d.ts +1 -4
- package/dist/gg.js +31 -36
- package/package.json +18 -18
|
@@ -46,10 +46,7 @@ declare const _exports: {
|
|
|
46
46
|
useColors: typeof import("./browser.js").useColors;
|
|
47
47
|
storage: LocalStorage;
|
|
48
48
|
colors: string[];
|
|
49
|
-
log:
|
|
50
|
-
(...data: any[]): void;
|
|
51
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
52
|
-
};
|
|
49
|
+
log: (...data: any[]) => void;
|
|
53
50
|
} | {
|
|
54
51
|
(namespace: string): Function;
|
|
55
52
|
debug: {
|
package/dist/gg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debugFactory from './debug.js';
|
|
2
2
|
import ErrorStackParser from 'error-stack-parser';
|
|
3
|
-
import { BROWSER } from 'esm-env';
|
|
3
|
+
import { BROWSER, DEV } from 'esm-env';
|
|
4
4
|
// Helper to detect if we're running in CloudFlare Workers
|
|
5
5
|
const isCloudflareWorker = () => {
|
|
6
6
|
// Check for CloudFlare Workers-specific global
|
|
@@ -96,45 +96,38 @@ export function gg(...args) {
|
|
|
96
96
|
if (!ggConfig.enabled || isCloudflareWorker()) {
|
|
97
97
|
return args.length ? args[0] : { url: '', stack: [] };
|
|
98
98
|
}
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const { functionName } = stack[0];
|
|
125
|
-
//console.log({ filename, fileNameToOpen: filenameToOpen, fileNameToDisplay: filenameToDisplay });
|
|
126
|
-
// A callpoint is uniquely identified by the filename plus function name
|
|
127
|
-
const callpoint = `${filenameToDisplay}${functionName ? `@${functionName}` : ''}`;
|
|
128
|
-
if (callpoint.length < 80 && callpoint.length > maxCallpointLength) {
|
|
129
|
-
maxCallpointLength = callpoint.length;
|
|
99
|
+
// Initialize return values
|
|
100
|
+
let fileName = '';
|
|
101
|
+
let functionName = '';
|
|
102
|
+
let url = '';
|
|
103
|
+
let stack = [];
|
|
104
|
+
let namespace = 'gg:';
|
|
105
|
+
// In development: calculate detailed callpoint information
|
|
106
|
+
// In production: skip expensive stack parsing and use simple namespace
|
|
107
|
+
if (DEV) {
|
|
108
|
+
// Ignore first stack frame, which is always the call to gg() itself.
|
|
109
|
+
stack = ErrorStackParser.parse(new Error()).splice(1);
|
|
110
|
+
// Example: http://localhost:5173/src/routes/+page.svelte
|
|
111
|
+
const filename = stack[0].fileName?.replace(timestampRegex, '') || '';
|
|
112
|
+
// Example: src/routes/+page.svelte
|
|
113
|
+
const filenameToOpen = filename.replace(srcRootRegex, '$<folderName>/');
|
|
114
|
+
url = openInEditorUrl(filenameToOpen);
|
|
115
|
+
// Example: routes/+page.svelte
|
|
116
|
+
fileName = filename.replace(srcRootRegex, '');
|
|
117
|
+
functionName = stack[0].functionName || '';
|
|
118
|
+
// A callpoint is uniquely identified by the filename plus function name
|
|
119
|
+
const callpoint = `${fileName}${functionName ? `@${functionName}` : ''}`;
|
|
120
|
+
if (callpoint.length < 80 && callpoint.length > maxCallpointLength) {
|
|
121
|
+
maxCallpointLength = callpoint.length;
|
|
122
|
+
}
|
|
123
|
+
namespace = `gg:${callpoint.padEnd(maxCallpointLength, ' ')}${ggConfig.editorLink ? url : ''}`;
|
|
130
124
|
}
|
|
131
|
-
const namespace = `gg:${callpoint.padEnd(maxCallpointLength, ' ')}${ggConfig.editorLink ? url : ''}`;
|
|
132
125
|
const ggLogFunction = namespaceToLogFunction.get(namespace) ||
|
|
133
126
|
namespaceToLogFunction.set(namespace, debugFactory(namespace)).get(namespace);
|
|
134
127
|
if (!args.length) {
|
|
135
128
|
ggLogFunction(` 📝📝 ${url} 👀👀`);
|
|
136
129
|
return {
|
|
137
|
-
fileName
|
|
130
|
+
fileName,
|
|
138
131
|
functionName,
|
|
139
132
|
url,
|
|
140
133
|
stack
|
|
@@ -175,8 +168,10 @@ if (ggConfig.showHints && !isCloudflareWorker()) {
|
|
|
175
168
|
if (BROWSER) {
|
|
176
169
|
const hint = makeHint(!ggLogTest.enabled, " (Try `localStorage.debug = 'gg:*'`)");
|
|
177
170
|
message(`${checkbox(ggLogTest.enabled)} localStorage.debug: ${localStorage?.debug}${hint}`);
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
if (DEV) {
|
|
172
|
+
const { status } = await fetch('/__open-in-editor?file=+');
|
|
173
|
+
message(makeHint(status === 222, `✅ (optional) open-in-editor vite plugin detected! (status code: ${status})`, `⚠️ (optional) open-in-editor vite plugin not detected. (status code: ${status}.) Add plugin in vite.config.ts`));
|
|
174
|
+
}
|
|
180
175
|
}
|
|
181
176
|
else {
|
|
182
177
|
const hint = makeHint(!ggLogTest.enabled, ' (Try `DEBUG=gg:* npm dev`)');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leftium/gg",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Leftium/gg.git"
|
|
@@ -27,33 +27,33 @@
|
|
|
27
27
|
"svelte": "^5.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@eslint/compat": "^
|
|
31
|
-
"@eslint/js": "^9.39.
|
|
30
|
+
"@eslint/compat": "^2.0.1",
|
|
31
|
+
"@eslint/js": "^9.39.2",
|
|
32
32
|
"@picocss/pico": "^2.1.1",
|
|
33
33
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
34
34
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
35
35
|
"@rollup/plugin-terser": "^0.4.4",
|
|
36
|
-
"@sveltejs/adapter-vercel": "^6.
|
|
37
|
-
"@sveltejs/kit": "^2.
|
|
38
|
-
"@sveltejs/package": "^2.5.
|
|
39
|
-
"@sveltejs/vite-plugin-svelte": "^6.2.
|
|
36
|
+
"@sveltejs/adapter-vercel": "^6.3.0",
|
|
37
|
+
"@sveltejs/kit": "^2.49.4",
|
|
38
|
+
"@sveltejs/package": "^2.5.7",
|
|
39
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
40
40
|
"@types/debug": "^4.1.12",
|
|
41
|
-
"@types/node": "^
|
|
41
|
+
"@types/node": "^25.0.8",
|
|
42
42
|
"add": "^2.0.6",
|
|
43
43
|
"debug": "^4.4.3",
|
|
44
|
-
"eslint": "^9.39.
|
|
44
|
+
"eslint": "^9.39.2",
|
|
45
45
|
"eslint-config-prettier": "^10.1.8",
|
|
46
|
-
"eslint-plugin-svelte": "^3.
|
|
47
|
-
"globals": "^
|
|
48
|
-
"prettier": "^3.
|
|
49
|
-
"prettier-plugin-svelte": "^3.4.
|
|
50
|
-
"publint": "^0.3.
|
|
46
|
+
"eslint-plugin-svelte": "^3.14.0",
|
|
47
|
+
"globals": "^17.0.0",
|
|
48
|
+
"prettier": "^3.7.4",
|
|
49
|
+
"prettier-plugin-svelte": "^3.4.1",
|
|
50
|
+
"publint": "^0.3.16",
|
|
51
51
|
"supports-color": "^10.2.2",
|
|
52
|
-
"svelte": "^5.
|
|
53
|
-
"svelte-check": "^4.3.
|
|
52
|
+
"svelte": "^5.46.3",
|
|
53
|
+
"svelte-check": "^4.3.5",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
|
-
"typescript-eslint": "^8.
|
|
56
|
-
"vite": "^7.
|
|
55
|
+
"typescript-eslint": "^8.53.0",
|
|
56
|
+
"vite": "^7.3.1",
|
|
57
57
|
"vite-plugin-devtools-json": "^1.0.0"
|
|
58
58
|
},
|
|
59
59
|
"keywords": [
|