@leftium/gg 0.0.2 → 0.0.3
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.js +10 -6
- package/package.json +5 -3
package/dist/gg.js
CHANGED
|
@@ -38,6 +38,7 @@ const port = await getServerPort();
|
|
|
38
38
|
const ggConfig = {
|
|
39
39
|
enabled: true,
|
|
40
40
|
showHints: true,
|
|
41
|
+
editorLink: false,
|
|
41
42
|
openInEditorUrlTemplate: `http://localhost:${port}/__open-in-editor?file=$FILENAME`,
|
|
42
43
|
// The srcRoot contains all source files.
|
|
43
44
|
// filename A : http://localhost:5173/src/routes/+layout.svelte
|
|
@@ -50,7 +51,8 @@ const srcRootRegex = new RegExp(ggConfig.srcRootPattern, 'i');
|
|
|
50
51
|
// To maintain unique millisecond diffs for each callpoint:
|
|
51
52
|
// - Create a unique log function for each callpoint.
|
|
52
53
|
// - Cache and reuse the same log function for a given callpoint.
|
|
53
|
-
const
|
|
54
|
+
const namespaceToLogFunction = new Map();
|
|
55
|
+
let maxCallpointLength = 0;
|
|
54
56
|
function openInEditorUrl(fileName) {
|
|
55
57
|
return ggConfig.openInEditorUrlTemplate.replace('$FILENAME', encodeURIComponent(fileName).replaceAll('%2F', '/'));
|
|
56
58
|
}
|
|
@@ -100,17 +102,19 @@ export function gg(...args) {
|
|
|
100
102
|
const filename = stack[0].fileName?.replace(timestampRegex, '') || '';
|
|
101
103
|
// Example: src/routes/+page.svelte
|
|
102
104
|
const filenameToOpen = filename.replace(srcRootRegex, '$<folderName>/');
|
|
105
|
+
const url = openInEditorUrl(filenameToOpen);
|
|
103
106
|
// Example: routes/+page.svelte
|
|
104
107
|
const filenameToDisplay = filename.replace(srcRootRegex, '');
|
|
105
108
|
const { functionName } = stack[0];
|
|
106
109
|
//console.log({ filename, fileNameToOpen: filenameToOpen, fileNameToDisplay: filenameToDisplay });
|
|
107
110
|
// A callpoint is uniquely identified by the filename plus function name
|
|
108
111
|
const callpoint = `${filenameToDisplay}${functionName ? `@${functionName}` : ''}`;
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
maxCallpointLength = Math.max(maxCallpointLength, callpoint.length);
|
|
113
|
+
const namespace = `${callpoint.padEnd(maxCallpointLength, ' ')}\t${ggConfig.editorLink ? url : ''}\n`;
|
|
114
|
+
const ggLogFunction = namespaceToLogFunction.get(namespace) ||
|
|
115
|
+
namespaceToLogFunction.set(namespace, ggLog.extend(namespace)).get(namespace);
|
|
111
116
|
if (!args.length) {
|
|
112
|
-
|
|
113
|
-
ggLogFunction(` 📝📝📝 ${url} 👀👀👀`);
|
|
117
|
+
ggLogFunction(` 📝📝 ${url} 👀👀`);
|
|
114
118
|
return {
|
|
115
119
|
fileName: filenameToDisplay,
|
|
116
120
|
functionName,
|
|
@@ -118,7 +122,7 @@ export function gg(...args) {
|
|
|
118
122
|
stack
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
|
-
ggLogFunction(...args);
|
|
125
|
+
ggLogFunction(...['', '\t', ...args]);
|
|
122
126
|
return args[0];
|
|
123
127
|
}
|
|
124
128
|
gg.disable = debugFactory.disable;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leftium/gg",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Leftium/gg.git"
|
|
@@ -48,8 +48,6 @@
|
|
|
48
48
|
"@types/node": "^22.13.17",
|
|
49
49
|
"add": "^2.0.6",
|
|
50
50
|
"debug": "^4.4.0",
|
|
51
|
-
"dotenv": "^16.4.7",
|
|
52
|
-
"error-stack-parser": "^2.1.4",
|
|
53
51
|
"eslint": "^9.18.0",
|
|
54
52
|
"eslint-config-prettier": "^10.0.1",
|
|
55
53
|
"eslint-plugin-svelte": "^3.0.0",
|
|
@@ -73,5 +71,9 @@
|
|
|
73
71
|
"onlyBuiltDependencies": [
|
|
74
72
|
"esbuild"
|
|
75
73
|
]
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"dotenv": "^17.2.0",
|
|
77
|
+
"error-stack-parser": "^2.1.4"
|
|
76
78
|
}
|
|
77
79
|
}
|