@kosmas10/portal 0.0.2 → 0.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Portal
2
2
 
3
- **Version:** 0.0.1
3
+ **Version:** 0.0.4
4
4
  **Package:** `@kosmas10/portal`
5
5
 
6
6
  A launcher portal for AI Chat Extensions applications. Provides a unified entry point to access Chat & Verify, Folder LLM Analyzer, and other AI-powered tools.
@@ -132,7 +132,22 @@ portal-bootstrap.html?loaderVersion=1.0.0&appVersion=0.0.1
132
132
 
133
133
  ## 📝 Version History
134
134
 
135
- ### 0.0.1 (Current)
135
+ ### 0.0.4 (Current)
136
+ - Removed all non-error console output to prevent console popups during normal operation
137
+ - Cleaner console output - only shows errors when something goes wrong
138
+ - Bootstrap file updated with cleaner code structure and version resolution
139
+
140
+ ### 0.0.3
141
+ - **Improved @latest handling**: Resolves `@latest` to specific version numbers by fetching package.json first
142
+ - Avoids CDN cache issues by using specific version numbers instead of `@latest` tag
143
+ - Fetches version from `package.json` with cache buster to ensure fresh data
144
+ - Version caching to avoid multiple fetches for the same package
145
+ - Falls back to `@latest` if version fetch fails for backward compatibility
146
+
147
+ ### 0.0.2
148
+ - Bug fixes and improvements
149
+
150
+ ### 0.0.1
136
151
  - Initial release
137
152
  - Launcher interface for AI Chat Extensions apps
138
153
  - 3-stage loading architecture
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosmas10/portal",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "A launcher portal for AI Chat Extensions applications. Provides a unified entry point to access Chat & Verify, Folder LLM Analyzer, and other AI-powered tools. Part of a 3-stage loading architecture for maximum reliability.",
5
5
  "main": "portal.html",
6
6
  "files": [
@@ -10,8 +10,7 @@
10
10
  "LICENSE"
11
11
  ],
12
12
  "scripts": {
13
- "test": "echo \"No tests specified\" && exit 0",
14
- "purge-cdn": "bash purge-cdn.sh"
13
+ "test": "echo \"No tests specified\" && exit 0"
15
14
  },
16
15
  "keywords": [
17
16
  "portal",
@@ -20,16 +20,17 @@
20
20
  // STAGE 1 BOOTSTRAP - IMMUTABLE
21
21
  // ============================================================================
22
22
  // This file should NEVER be modified after deployment.
23
- // Always uses @latest to automatically get loader updates.
23
+ // Fetches loader version from package.json to avoid @latest cache issues.
24
24
  // Only change: the app package name (@kosmas10/portal)
25
25
  // ============================================================================
26
26
  (function() {
27
- var script = document.createElement('script');
28
- // Add timestamp to force cache refresh (helps with CDN caching issues)
29
- script.src = 'https://cdn.jsdelivr.net/npm/@kosmas10/html-app-loader@latest/loader.js?app=@kosmas10/portal&_=' + Date.now();
30
- script.onerror = function() {
31
- document.body.innerHTML =
32
- '<!DOCTYPE html>' +
27
+ // Configuration: Only change this for different apps
28
+ var APP_PACKAGE = '@kosmas10/portal';
29
+ var APP_NAME = 'Portal';
30
+
31
+ // Shared error HTML generator
32
+ function createErrorHtml(url) {
33
+ return '<!DOCTYPE html>' +
33
34
  '<html><head><meta charset="UTF-8"><style>' +
34
35
  'body{margin:0;padding:40px;font-family:system-ui,sans-serif;line-height:1.6}' +
35
36
  '.error{max-width:600px;margin:0 auto;padding:30px;background:#fee;border:2px solid #c33;border-radius:8px}' +
@@ -40,7 +41,7 @@
40
41
  '<div class="error">' +
41
42
  '<h1>Failed to Load Application</h1>' +
42
43
  '<p>The application loader could not be loaded from:</p>' +
43
- '<p><code>' + script.src + '</code></p>' +
44
+ '<p><code>' + url + '</code></p>' +
44
45
  '<p><strong>Possible causes:</strong></p>' +
45
46
  '<ul>' +
46
47
  '<li>No internet connection</li>' +
@@ -59,8 +60,47 @@
59
60
  '<li>Contact your IT department if on a corporate network</li>' +
60
61
  '</ul>' +
61
62
  '</div></body></html>';
62
- };
63
- document.head.appendChild(script);
63
+ }
64
+
65
+ // Load script with error handling
66
+ function loadScript(url) {
67
+ var script = document.createElement('script');
68
+ script.src = url + '&_=' + Date.now();
69
+ script.onerror = function() {
70
+ document.body.innerHTML = createErrorHtml(url);
71
+ };
72
+ document.head.appendChild(script);
73
+ }
74
+
75
+ // Fetch loader version from package.json
76
+ async function getLoaderVersion() {
77
+ var cacheBuster = Date.now();
78
+ var packageJsonUrl = 'https://cdn.jsdelivr.net/npm/@kosmas10/html-app-loader@latest/package.json?t=' + cacheBuster;
79
+ var response = await fetch(packageJsonUrl);
80
+ if (!response.ok) {
81
+ throw new Error('Failed to fetch loader package.json: HTTP ' + response.status);
82
+ }
83
+ var packageData = await response.json();
84
+ if (!packageData.version) {
85
+ throw new Error('package.json does not contain version field');
86
+ }
87
+ return packageData.version;
88
+ }
89
+
90
+ // Main loader function
91
+ async function loadLoader() {
92
+ try {
93
+ var loaderVersion = await getLoaderVersion();
94
+ var loaderUrl = 'https://cdn.jsdelivr.net/npm/@kosmas10/html-app-loader@' + loaderVersion + '/loader.js?app=' + APP_PACKAGE;
95
+ loadScript(loaderUrl);
96
+ } catch (error) {
97
+ console.error(APP_NAME + ' Bootstrap: Error fetching loader version:', error);
98
+ var fallbackUrl = 'https://cdn.jsdelivr.net/npm/@kosmas10/html-app-loader@latest/loader.js?app=' + APP_PACKAGE;
99
+ loadScript(fallbackUrl);
100
+ }
101
+ }
102
+
103
+ loadLoader();
64
104
  })();
65
105
  </script>
66
106
  </body>
package/portal.html CHANGED
@@ -357,16 +357,65 @@
357
357
 
358
358
  <script>
359
359
  // App version - keep in sync with package.json
360
- const APP_VERSION = '0.0.2';
361
- console.log('Portal v' + APP_VERSION + ' loaded');
360
+ const APP_VERSION = '0.0.4';
362
361
 
363
362
  // CDN base URL for loading apps
364
363
  const CDN_BASE = 'https://cdn.jsdelivr.net/npm/@kosmas10/';
365
364
 
366
- function openApp(packageName) {
367
- // Open the application bootstrap from CDN in a new tab/window
368
- const url = CDN_BASE + packageName + '@latest/' + packageName + '-bootstrap.html';
369
- window.open(url, '_blank');
365
+ // Cache for resolved versions to avoid multiple fetches
366
+ const versionCache = {};
367
+
368
+ /**
369
+ * Fetch the latest version from package.json
370
+ * This avoids @latest cache issues by fetching package.json (which updates faster)
371
+ * and then using the specific version number
372
+ */
373
+ async function getLatestVersion(packageName) {
374
+ // Check cache first
375
+ if (versionCache[packageName]) {
376
+ return versionCache[packageName];
377
+ }
378
+
379
+ try {
380
+ const cacheBuster = Date.now();
381
+ const packageJsonUrl = CDN_BASE + packageName + '@latest/package.json?t=' + cacheBuster;
382
+
383
+ const response = await fetch(packageJsonUrl);
384
+ if (!response.ok) {
385
+ throw new Error('Failed to fetch package.json: HTTP ' + response.status);
386
+ }
387
+
388
+ const packageData = await response.json();
389
+ if (!packageData.version) {
390
+ throw new Error('package.json does not contain version field');
391
+ }
392
+
393
+ // Cache the version
394
+ versionCache[packageName] = packageData.version;
395
+ return packageData.version;
396
+ } catch (error) {
397
+ console.error('Portal: Error fetching latest version for', packageName, ':', error);
398
+ // Fallback to 'latest' if we can't fetch the version
399
+ return 'latest';
400
+ }
401
+ }
402
+
403
+ async function openApp(packageName) {
404
+ try {
405
+ // Resolve 'latest' to actual version number
406
+ const resolvedVersion = await getLatestVersion(packageName);
407
+
408
+ // Build URL with specific version (not @latest)
409
+ const url = CDN_BASE + packageName + '@' + resolvedVersion + '/' + packageName + '-bootstrap.html';
410
+
411
+ // Open the application bootstrap from CDN in a new tab/window
412
+ window.open(url, '_blank');
413
+ } catch (error) {
414
+ console.error('Portal: Error opening app', packageName, ':', error);
415
+ // Fallback: try with @latest if version resolution fails
416
+ const fallbackUrl = CDN_BASE + packageName + '@latest/' + packageName + '-bootstrap.html';
417
+ window.open(fallbackUrl, '_blank');
418
+ }
370
419
  }
371
420
 
372
421
  // Add some interactive effects