@keenmate/svelte-spa-router 5.0.0 → 5.1.0
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/CHANGELOG.md +18 -1
- package/package.json +1 -1
- package/src/lib/index.js +70 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [5.
|
|
10
|
+
## [5.1.0] - TBD
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Global Window API:** Added runtime debugging and introspection via `window.components['svelte-spa-router']`
|
|
14
|
+
- `version()` - Get library version at runtime
|
|
15
|
+
- `config` - Access package metadata (name, version, author, license, repository, homepage)
|
|
16
|
+
- `logging.enableLogging()` - Enable all debug logging from browser console
|
|
17
|
+
- `logging.disableLogging()` - Disable all logging from browser console
|
|
18
|
+
- `logging.setLogLevel(level)` - Set global log level from browser console
|
|
19
|
+
- `logging.setCategoryLevel(category, level)` - Control specific logging categories from browser console
|
|
20
|
+
- `logging.getCategories()` - List all available logging categories
|
|
21
|
+
- TypeScript support with full autocompletion for global API
|
|
22
|
+
- SSR-safe implementation (only initializes in browser)
|
|
23
|
+
- Namespace-safe pattern using `window.components` (shared across all component libraries)
|
|
24
|
+
- Enables debugging production issues without code changes or rebuilding
|
|
25
|
+
- Example: `window.components['svelte-spa-router'].logging.setCategoryLevel('ROUTER:NAVIGATION', 'debug')`
|
|
26
|
+
|
|
27
|
+
## [5.0.0] - 2025-01-17 ✅ Published
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
13
30
|
- **Code Quality:** Major ESLint cleanup - reduced linting issues from 161 to 11 (93% reduction)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keenmate/svelte-spa-router",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Router for SPAs using Svelte 5 with runes, dual-mode routing, permissions, and error handling",
|
|
5
5
|
"main": "./src/lib/index.js",
|
|
6
6
|
"svelte": "./src/lib/Router.svelte",
|
package/src/lib/index.js
CHANGED
|
@@ -24,3 +24,73 @@ export * from './helpers/filters.svelte.js';
|
|
|
24
24
|
|
|
25
25
|
// Navigation guard system
|
|
26
26
|
export * from './helpers/navigation-guard.svelte.js';
|
|
27
|
+
|
|
28
|
+
// Import logging utilities for global API
|
|
29
|
+
import {
|
|
30
|
+
enableLogging,
|
|
31
|
+
disableLogging,
|
|
32
|
+
setLogLevel,
|
|
33
|
+
setCategoryLevel
|
|
34
|
+
} from './logger';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {Object} GlobalRouterAPI
|
|
38
|
+
* @property {() => string} version - Get library version
|
|
39
|
+
* @property {Object} config - Package metadata
|
|
40
|
+
* @property {string} config.name - Package name
|
|
41
|
+
* @property {string} config.version - Package version
|
|
42
|
+
* @property {string} config.author - Package author
|
|
43
|
+
* @property {string} config.license - Package license
|
|
44
|
+
* @property {string} config.repository - Repository URL
|
|
45
|
+
* @property {string} config.homepage - Homepage URL
|
|
46
|
+
* @property {Object} logging - Logging controls
|
|
47
|
+
* @property {() => void} logging.enableLogging - Enable all debug logging
|
|
48
|
+
* @property {() => void} logging.disableLogging - Disable all logging
|
|
49
|
+
* @property {(level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent') => void} logging.setLogLevel - Set global log level
|
|
50
|
+
* @property {(category: string, level?: string) => void} logging.setCategoryLevel - Set category-specific log level
|
|
51
|
+
* @property {() => string[]} logging.getCategories - List all logging categories
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
// List of all logging categories
|
|
55
|
+
const LOGGING_CATEGORIES = [
|
|
56
|
+
'ROUTER',
|
|
57
|
+
'ROUTER:NAVIGATION',
|
|
58
|
+
'ROUTER:SCROLL',
|
|
59
|
+
'ROUTER:GUARDS',
|
|
60
|
+
'ROUTER:CONDITIONS',
|
|
61
|
+
'ROUTER:HIERARCHY',
|
|
62
|
+
'ROUTER:PERMISSIONS',
|
|
63
|
+
'ROUTER:ROUTES',
|
|
64
|
+
'ROUTER:ZONES',
|
|
65
|
+
'ROUTER:METADATA',
|
|
66
|
+
'ROUTER:ERROR_HANDLER',
|
|
67
|
+
'ROUTER:FILTERS'
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
// Initialize global API (SSR-safe)
|
|
71
|
+
if (typeof window !== 'undefined') {
|
|
72
|
+
// Create components namespace if it doesn't exist
|
|
73
|
+
window.components = window.components || {};
|
|
74
|
+
|
|
75
|
+
// Initialize svelte-spa-router API
|
|
76
|
+
// Note: __VERSION__, __PACKAGE_NAME__, etc. are injected by build tools (Vite, Rollup)
|
|
77
|
+
// via the `define` option. Fallback values are provided for source distribution.
|
|
78
|
+
window.components['svelte-spa-router'] = {
|
|
79
|
+
version: () => typeof __VERSION__ !== 'undefined' ? __VERSION__ : '5.1.0',
|
|
80
|
+
config: {
|
|
81
|
+
name: typeof __PACKAGE_NAME__ !== 'undefined' ? __PACKAGE_NAME__ : '@keenmate/svelte-spa-router',
|
|
82
|
+
version: typeof __VERSION__ !== 'undefined' ? __VERSION__ : '5.1.0',
|
|
83
|
+
author: typeof __AUTHOR__ !== 'undefined' ? __AUTHOR__ : 'KeenMate (https://keenmate.com)',
|
|
84
|
+
license: typeof __LICENSE__ !== 'undefined' ? __LICENSE__ : 'MIT',
|
|
85
|
+
repository: typeof __REPOSITORY__ !== 'undefined' ? __REPOSITORY__ : 'https://github.com/keenmate/svelte-spa-router',
|
|
86
|
+
homepage: typeof __HOMEPAGE__ !== 'undefined' ? __HOMEPAGE__ : 'https://github.com/keenmate/svelte-spa-router#readme'
|
|
87
|
+
},
|
|
88
|
+
logging: {
|
|
89
|
+
enableLogging,
|
|
90
|
+
disableLogging,
|
|
91
|
+
setLogLevel,
|
|
92
|
+
setCategoryLevel,
|
|
93
|
+
getCategories: () => [...LOGGING_CATEGORIES]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|