Compare commits

..
5 Commits
Author SHA1 Message Date
oaklake89 b7b70a2dad Merge branch 'fix/npm-audit'
Publish Extension / publish (push) Successful in 35s
2026-10-11 10:03:53 +00:00
oaklake89 651b0e900b Fix: Update vulnerable development dependencies 2026-10-11 10:02:55 +00:00
oaklake89 65cf5d164b Release 1.0.4
Publish Extension / publish (push) Failing after 24s
2026-10-11 09:41:53 +00:00
oaklake89 aff808fb53 Merge branch 'fix/status-bar' 2026-10-11 09:40:15 +00:00
oaklake89 ac98e481f1 Fix: Improve status bar alignment and HTTP requests 2026-10-11 09:39:37 +00:00
5 changed files with 794 additions and 2400 deletions

No files matched your search

+7
View File
@@ -1,5 +1,12 @@
# Changelog # Changelog
## [1.0.4] - 2026-10-11
### Changed
- Improved status bar alignment by using figure spaces to maintain a consistent width for single- and double-digit visitor counts.
- Replaced https.get() with the native fetch() API for simpler and more reliable HTTP requests.
## [1.0.3] - 2026-06-07 ## [1.0.3] - 2026-06-07
### Fixed ### Fixed
+753 -2358
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -2,7 +2,7 @@
"name": "vsc-adda", "name": "vsc-adda",
"displayName": "Adda", "displayName": "Adda",
"description": "Track the number of checked-in visitors at Adda Hälsoperspektiv AB.", "description": "Track the number of checked-in visitors at Adda Hälsoperspektiv AB.",
"version": "1.0.3", "version": "1.0.4",
"publisher": "oaklake89", "publisher": "oaklake89",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -49,7 +49,7 @@
"lint": "eslint src", "lint": "eslint src",
"test": "vscode-test", "test": "vscode-test",
"package": "vsce package --baseContentUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main --baseImagesUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main", "package": "vsce package --baseContentUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main --baseImagesUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main",
"publish": "vsce publish --baseContentUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main --baseImagesUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main" "publish": "vsce publish --baseContentUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main --baseImagesUrl https://git.kvarnarp.se/vscode/vsc-adda/raw/branch/main"
}, },
"overrides": { "overrides": {
"diff": "^8.0.4", "diff": "^8.0.4",
@@ -59,9 +59,9 @@
"@types/mocha": "^10.0.10", "@types/mocha": "^10.0.10",
"@types/node": "22.x", "@types/node": "22.x",
"@types/vscode": "^1.109.0", "@types/vscode": "^1.109.0",
"@vscode/test-cli": "^0.0.11", "@vscode/test-cli": "^0.0.15",
"@vscode/test-electron": "^2.5.2", "@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "^3.7.1", "@vscode/vsce": "^4.0.0",
"eslint": "^9.39.3", "eslint": "^9.39.3",
"typescript": "^5.9.3", "typescript": "^5.9.3",
"typescript-eslint": "^8.56.1" "typescript-eslint": "^8.56.1"
+18 -34
View File
@@ -1,37 +1,21 @@
import * as https from 'https'; const URL = 'https://www.gymcontrol.se/global/checkedin/checkedin.php?uid=9094';
export function getVisitorCount(): Promise<number> { export async function getVisitorCount(): Promise<number> {
return new Promise((resolve, reject) => { const response = await fetch(URL, {
const req = https.get('https://www.gymcontrol.se/global/checkedin/checkedin.php?uid=9094', (res) => { signal: AbortSignal.timeout(5000)
if (!res.statusCode || res.statusCode < 200 || res.statusCode >= 300) {
res.resume();
reject(new Error(`HTTP ${res.statusCode ?? '?'}`));
return;
}
res.setEncoding('utf8');
let raw = '';
res.on('data', (chunk) => {
raw += chunk;
});
res.on('end', () => {
const text = raw.trim();
const n = Number.parseInt(text, 10);
if (Number.isFinite(n)) {
resolve(n);
} else {
reject(new Error(`Invalid response: "${text}"`));
}
});
});
req.on('error', reject);
req.setTimeout(5000, () => {
req.destroy(new Error('Timeout after 5000 ms'));
});
}); });
const raw = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const text = raw.trim();
if (!/^\d+$/.test(text)) {
throw new Error(`Invalid response: ${JSON.stringify(text)}`);
}
return Number(text);
} }
+12 -4
View File
@@ -1,6 +1,8 @@
import * as vscode from 'vscode'; import * as vscode from 'vscode';
const TOOLTIP_TEXT = 'Current Gym Visitors'; const TOOLTIP_TEXT = 'Current Gym Visitors';
const FIGURE_SPACE = '\u2007';
const VISITOR_COUNT_WIDTH = 2;
let item: vscode.StatusBarItem; let item: vscode.StatusBarItem;
let getCount: (() => Promise<number>) | undefined; let getCount: (() => Promise<number>) | undefined;
@@ -10,7 +12,7 @@ export function initStatusBar(getVisitorCount: () => Promise<number>, commandId:
item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 1000); item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 1000);
item.command = commandId; item.command = commandId;
item.text = '$(adda-fitness) 0'; item.text = `$(adda-fitness) ${formatCount(0)}`;
item.tooltip = TOOLTIP_TEXT; item.tooltip = TOOLTIP_TEXT;
item.show(); item.show();
@@ -23,20 +25,26 @@ export async function refresh(): Promise<void> {
} }
item.text = '$(adda-fitness) $(sync~spin)'; item.text = '$(adda-fitness) $(sync~spin)';
item.tooltip = 'Updating visitor count...';
item.show();
try { try {
const [count] = await Promise.all([getCount(), sleep(1500)]); const [count] = await Promise.all([getCount(), sleep(1500)]);
item.text = `$(adda-fitness) ${count}`; item.text = `$(adda-fitness) ${formatCount(count)}`;
item.tooltip = TOOLTIP_TEXT; item.tooltip = TOOLTIP_TEXT;
} catch (e: any) { } catch (e: unknown) {
item.text = '$(warning) Adda'; item.text = '$(warning) Adda';
item.tooltip = e?.message ?? 'Unknown error'; item.tooltip = e instanceof Error ? e.message : 'Unknown error';
} finally { } finally {
item.show(); item.show();
} }
} }
function formatCount(count: number): string {
return count.toString().padStart(VISITOR_COUNT_WIDTH, FIGURE_SPACE);
}
function sleep(ms: number): Promise<void> { function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms)); return new Promise((resolve) => setTimeout(resolve, ms));
} }