@smartnet360/svelte-components 0.0.123 → 0.0.125

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.
Files changed (36) hide show
  1. package/dist/apps/antenna-tools/components/AntennaControls.svelte +71 -9
  2. package/dist/apps/antenna-tools/components/AntennaControls.svelte.d.ts +2 -0
  3. package/dist/apps/antenna-tools/components/AntennaSettingsModal.svelte +4 -174
  4. package/dist/apps/antenna-tools/components/AntennaTools.svelte +48 -82
  5. package/dist/apps/antenna-tools/components/DatabaseViewer.svelte +5 -8
  6. package/dist/apps/antenna-tools/components/MSIConverter.svelte +377 -52
  7. package/dist/apps/antenna-tools/db.js +4 -0
  8. package/dist/apps/antenna-tools/utils/db-utils.d.ts +19 -0
  9. package/dist/apps/antenna-tools/utils/db-utils.js +108 -0
  10. package/dist/apps/antenna-tools/utils/msi-parser.d.ts +35 -1
  11. package/dist/apps/antenna-tools/utils/msi-parser.js +105 -35
  12. package/dist/core/Auth/LoginForm.svelte +397 -0
  13. package/dist/core/Auth/LoginForm.svelte.d.ts +16 -0
  14. package/dist/core/Auth/auth.svelte.d.ts +22 -0
  15. package/dist/core/Auth/auth.svelte.js +184 -0
  16. package/dist/core/Auth/config.d.ts +25 -0
  17. package/dist/core/Auth/config.js +256 -0
  18. package/dist/core/Auth/index.d.ts +4 -0
  19. package/dist/core/Auth/index.js +5 -0
  20. package/dist/core/Auth/types.d.ts +140 -0
  21. package/dist/core/Auth/types.js +2 -0
  22. package/dist/core/Benchmark/Benchmark.svelte +662 -0
  23. package/dist/core/Benchmark/Benchmark.svelte.d.ts +3 -0
  24. package/dist/core/Benchmark/benchmark-utils.d.ts +48 -0
  25. package/dist/core/Benchmark/benchmark-utils.js +80 -0
  26. package/dist/core/Benchmark/index.d.ts +2 -0
  27. package/dist/core/Benchmark/index.js +3 -0
  28. package/dist/core/LandingPage/App.svelte +102 -0
  29. package/dist/core/LandingPage/App.svelte.d.ts +20 -0
  30. package/dist/core/LandingPage/LandingPage.svelte +480 -0
  31. package/dist/core/LandingPage/LandingPage.svelte.d.ts +21 -0
  32. package/dist/core/LandingPage/index.d.ts +2 -0
  33. package/dist/core/LandingPage/index.js +3 -0
  34. package/dist/core/index.d.ts +3 -0
  35. package/dist/core/index.js +6 -0
  36. package/package.json +1 -1
@@ -0,0 +1,184 @@
1
+ // Auth state management using Svelte 5 runes
2
+ import { browser } from '$app/environment';
3
+ // Default configuration
4
+ const defaultConfig = {
5
+ apiEndpoint: '/api/auth',
6
+ devMode: false,
7
+ storagePrefix: 'rf-tools-auth',
8
+ sessionTimeout: 8 * 60 * 60 * 1000 // 8 hours
9
+ };
10
+ /**
11
+ * Create auth state store with Svelte 5 runes
12
+ * This must be called within a component context or .svelte.ts file
13
+ */
14
+ export function createAuthState(config = {}) {
15
+ const cfg = { ...defaultConfig, ...config };
16
+ // Core state
17
+ let session = $state(null);
18
+ let isLoading = $state(false);
19
+ let error = $state(null);
20
+ let initialized = $state(false);
21
+ // Derived state
22
+ const isAuthenticated = $derived(session !== null && session.expiresAt > Date.now());
23
+ const user = $derived(session?.user ?? null);
24
+ const permissions = $derived(session?.permissions ?? []);
25
+ const token = $derived(session?.token ?? null);
26
+ // Storage keys
27
+ const sessionKey = `${cfg.storagePrefix}-session`;
28
+ /**
29
+ * Initialize auth state from storage
30
+ */
31
+ function initialize() {
32
+ if (!browser) {
33
+ initialized = true;
34
+ return;
35
+ }
36
+ try {
37
+ const stored = localStorage.getItem(sessionKey);
38
+ if (stored) {
39
+ const parsed = JSON.parse(stored);
40
+ if (parsed.expiresAt > Date.now()) {
41
+ session = parsed;
42
+ }
43
+ else {
44
+ localStorage.removeItem(sessionKey);
45
+ }
46
+ }
47
+ }
48
+ catch (e) {
49
+ console.error('Failed to restore auth session:', e);
50
+ localStorage.removeItem(sessionKey);
51
+ }
52
+ initialized = true;
53
+ }
54
+ /**
55
+ * Save session to storage
56
+ */
57
+ function saveSession(newSession) {
58
+ session = newSession;
59
+ if (browser) {
60
+ localStorage.setItem(sessionKey, JSON.stringify(newSession));
61
+ }
62
+ }
63
+ /**
64
+ * Clear session
65
+ */
66
+ function clearSession() {
67
+ session = null;
68
+ if (browser) {
69
+ localStorage.removeItem(sessionKey);
70
+ }
71
+ }
72
+ /**
73
+ * Login with credentials
74
+ */
75
+ async function login(username, password, agreedToMonitoring) {
76
+ if (!agreedToMonitoring) {
77
+ error = 'You must agree to activity monitoring to proceed.';
78
+ return false;
79
+ }
80
+ isLoading = true;
81
+ error = null;
82
+ try {
83
+ const response = await fetch(`${cfg.apiEndpoint}/login`, {
84
+ method: 'POST',
85
+ headers: { 'Content-Type': 'application/json' },
86
+ body: JSON.stringify({ username, password, agreedToMonitoring })
87
+ });
88
+ const data = await response.json();
89
+ if (data.success && data.session) {
90
+ saveSession(data.session);
91
+ return true;
92
+ }
93
+ else {
94
+ error = data.error || 'Authentication failed';
95
+ return false;
96
+ }
97
+ }
98
+ catch (e) {
99
+ error = e instanceof Error ? e.message : 'Network error';
100
+ return false;
101
+ }
102
+ finally {
103
+ isLoading = false;
104
+ }
105
+ }
106
+ /**
107
+ * Login with dev mode credentials (auto-login)
108
+ */
109
+ function loginDev(devUser, devPermissions) {
110
+ const devSession = {
111
+ user: devUser,
112
+ permissions: devPermissions,
113
+ token: 'dev-token-' + Date.now(),
114
+ expiresAt: Date.now() + cfg.sessionTimeout
115
+ };
116
+ saveSession(devSession);
117
+ }
118
+ /**
119
+ * Logout
120
+ */
121
+ async function logout() {
122
+ isLoading = true;
123
+ try {
124
+ // Call logout endpoint if we have a token
125
+ if (session?.token) {
126
+ await fetch(`${cfg.apiEndpoint}/logout`, {
127
+ method: 'POST',
128
+ headers: {
129
+ 'Content-Type': 'application/json',
130
+ 'Authorization': `Bearer ${session.token}`
131
+ }
132
+ }).catch(() => { }); // Ignore errors
133
+ }
134
+ }
135
+ finally {
136
+ clearSession();
137
+ isLoading = false;
138
+ }
139
+ }
140
+ /**
141
+ * Check if user has permission for a feature
142
+ */
143
+ function hasPermission(featureId, level = 'view') {
144
+ const permission = permissions.find(p => p.featureId === featureId);
145
+ if (!permission)
146
+ return false;
147
+ switch (level) {
148
+ case 'view': return permission.canView;
149
+ case 'edit': return permission.canEdit ?? false;
150
+ case 'admin': return permission.canAdmin ?? false;
151
+ default: return false;
152
+ }
153
+ }
154
+ /**
155
+ * Check if user can access a route
156
+ */
157
+ function canAccessRoute(route, requiredPermission) {
158
+ if (!isAuthenticated)
159
+ return false;
160
+ if (!requiredPermission)
161
+ return true;
162
+ return hasPermission(requiredPermission, 'view');
163
+ }
164
+ // Initialize on creation
165
+ initialize();
166
+ return {
167
+ // State (getters)
168
+ get session() { return session; },
169
+ get isLoading() { return isLoading; },
170
+ get error() { return error; },
171
+ get initialized() { return initialized; },
172
+ get isAuthenticated() { return isAuthenticated; },
173
+ get user() { return user; },
174
+ get permissions() { return permissions; },
175
+ get token() { return token; },
176
+ // Actions
177
+ login,
178
+ loginDev,
179
+ logout,
180
+ hasPermission,
181
+ canAccessRoute,
182
+ clearError: () => { error = null; }
183
+ };
184
+ }
@@ -0,0 +1,25 @@
1
+ import type { DevConfig, CategoryInfo, AppDefinition, User, FeatureAccess } from './types.js';
2
+ /**
3
+ * Default category definitions
4
+ */
5
+ export declare const DEFAULT_CATEGORIES: CategoryInfo[];
6
+ /**
7
+ * Default app definitions - all available apps/tools
8
+ */
9
+ export declare const DEFAULT_APPS: AppDefinition[];
10
+ /**
11
+ * Default dev user for development mode
12
+ */
13
+ export declare const DEFAULT_DEV_USER: User;
14
+ /**
15
+ * Default permissions for dev mode (full access)
16
+ */
17
+ export declare const DEFAULT_DEV_PERMISSIONS: FeatureAccess[];
18
+ /**
19
+ * Get full dev configuration
20
+ */
21
+ export declare function getDevConfig(): DevConfig;
22
+ /**
23
+ * Check if we're in development mode
24
+ */
25
+ export declare function isDevMode(): boolean;
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Default category definitions
3
+ */
4
+ export const DEFAULT_CATEGORIES = [
5
+ {
6
+ id: 'map-tools',
7
+ title: 'Map Tools',
8
+ description: 'Geographic visualization and network mapping tools',
9
+ icon: 'bi-map',
10
+ color: 'primary'
11
+ },
12
+ {
13
+ id: 'visualization',
14
+ title: 'Visualization',
15
+ description: 'Charts, graphs, and data visualization tools',
16
+ icon: 'bi-bar-chart-line',
17
+ color: 'success'
18
+ },
19
+ {
20
+ id: 'optimization',
21
+ title: 'Optimization',
22
+ description: 'Network optimization and planning tools',
23
+ icon: 'bi-sliders',
24
+ color: 'warning'
25
+ },
26
+ {
27
+ id: 'analysis',
28
+ title: 'Analysis',
29
+ description: 'Data analysis and reporting tools',
30
+ icon: 'bi-graph-up',
31
+ color: 'info'
32
+ },
33
+ {
34
+ id: 'configuration',
35
+ title: 'Configuration',
36
+ description: 'System configuration and settings',
37
+ icon: 'bi-gear',
38
+ color: 'secondary'
39
+ },
40
+ {
41
+ id: 'demo',
42
+ title: 'Demos & Examples',
43
+ description: 'Demo applications and component showcases',
44
+ icon: 'bi-play-circle',
45
+ color: 'dark'
46
+ }
47
+ ];
48
+ /**
49
+ * Default app definitions - all available apps/tools
50
+ */
51
+ export const DEFAULT_APPS = [
52
+ // Map Tools
53
+ {
54
+ id: 'map-v3-demo',
55
+ title: 'Network Map',
56
+ description: 'Interactive cellular network visualization with coverage layers',
57
+ route: '/apps/map-v3-demo',
58
+ icon: 'bi-map',
59
+ category: 'map-tools',
60
+ requiredPermission: 'map-view',
61
+ enabled: true,
62
+ badge: 'New',
63
+ badgeColor: 'success'
64
+ },
65
+ {
66
+ id: 'coverage-test',
67
+ title: 'Coverage Analysis',
68
+ description: 'Analyze network coverage and signal propagation',
69
+ route: '/apps/coverage-test',
70
+ icon: 'bi-broadcast',
71
+ category: 'map-tools',
72
+ requiredPermission: 'coverage-view',
73
+ enabled: true
74
+ },
75
+ {
76
+ id: 'map-demo',
77
+ title: 'Map Demo (Legacy)',
78
+ description: 'Legacy map component demonstration',
79
+ route: '/apps/map-demo',
80
+ icon: 'bi-map-fill',
81
+ category: 'map-tools',
82
+ requiredPermission: 'map-view',
83
+ enabled: true
84
+ },
85
+ // Visualization
86
+ {
87
+ id: 'charts-demo',
88
+ title: 'Charts',
89
+ description: 'Interactive Plotly-based chart visualization system',
90
+ route: '/apps/demo/charts',
91
+ icon: 'bi-bar-chart-line',
92
+ category: 'visualization',
93
+ requiredPermission: 'charts-view',
94
+ enabled: true
95
+ },
96
+ {
97
+ id: 'charts-editor',
98
+ title: 'Chart Editor',
99
+ description: 'Create and customize chart configurations',
100
+ route: '/apps/demo/charts/editor',
101
+ icon: 'bi-pencil-square',
102
+ category: 'visualization',
103
+ requiredPermission: 'charts-edit',
104
+ enabled: true
105
+ },
106
+ {
107
+ id: 'desktop-grid',
108
+ title: 'Desktop Grid',
109
+ description: 'Multi-panel layout orchestrator for complex dashboards',
110
+ route: '/apps/demo/desktop',
111
+ icon: 'bi-grid-3x3-gap',
112
+ category: 'visualization',
113
+ requiredPermission: 'desktop-view',
114
+ enabled: true
115
+ },
116
+ {
117
+ id: 'cell-table',
118
+ title: 'Cell Table',
119
+ description: 'Tabulator-based data table with grouping and filtering',
120
+ route: '/apps/demo/cell-table',
121
+ icon: 'bi-table',
122
+ category: 'visualization',
123
+ requiredPermission: 'table-view',
124
+ enabled: true
125
+ },
126
+ // Analysis
127
+ {
128
+ id: 'antenna-patterns',
129
+ title: 'Antenna Patterns',
130
+ description: 'Visualize and analyze antenna radiation patterns',
131
+ route: '/apps/antenna-patterns',
132
+ icon: 'bi-broadcast-pin',
133
+ category: 'analysis',
134
+ requiredPermission: 'antenna-view',
135
+ enabled: true
136
+ },
137
+ {
138
+ id: 'site-check',
139
+ title: 'Site Check',
140
+ description: 'Site validation and configuration checker',
141
+ route: '/apps/site-check',
142
+ icon: 'bi-building-check',
143
+ category: 'analysis',
144
+ requiredPermission: 'site-check',
145
+ enabled: true
146
+ },
147
+ // Configuration
148
+ {
149
+ id: 'settings-test',
150
+ title: 'Settings Panel',
151
+ description: 'Configuration management interface',
152
+ route: '/apps/settings-test',
153
+ icon: 'bi-gear-wide-connected',
154
+ category: 'configuration',
155
+ requiredPermission: 'settings-view',
156
+ enabled: true
157
+ },
158
+ {
159
+ id: 'settings-demo',
160
+ title: 'Settings Demo',
161
+ description: 'Settings component showcase',
162
+ route: '/apps/demo/settings-demo',
163
+ icon: 'bi-sliders2',
164
+ category: 'configuration',
165
+ enabled: true
166
+ },
167
+ // Demos
168
+ {
169
+ id: 'tree-test',
170
+ title: 'Tree View',
171
+ description: 'Hierarchical tree navigation component',
172
+ route: '/apps/demo/tree-test',
173
+ icon: 'bi-diagram-3',
174
+ category: 'demo',
175
+ enabled: true
176
+ },
177
+ {
178
+ id: 'dummy-components',
179
+ title: 'Component Showcase',
180
+ description: 'Demo of all available UI components',
181
+ route: '/apps/demo/dummy-components',
182
+ icon: 'bi-boxes',
183
+ category: 'demo',
184
+ enabled: true
185
+ },
186
+ {
187
+ id: 'charts-tabs',
188
+ title: 'Charts Tabs Mode',
189
+ description: 'Charts with tabbed navigation',
190
+ route: '/apps/demo/charts/tabs',
191
+ icon: 'bi-window-tab',
192
+ category: 'demo',
193
+ enabled: true
194
+ },
195
+ {
196
+ id: 'charts-scrollspy',
197
+ title: 'Charts Scrollspy',
198
+ description: 'Charts with scroll-based navigation',
199
+ route: '/apps/demo/charts/scrollspy',
200
+ icon: 'bi-arrows-vertical',
201
+ category: 'demo',
202
+ enabled: true
203
+ }
204
+ ];
205
+ /**
206
+ * Default dev user for development mode
207
+ */
208
+ export const DEFAULT_DEV_USER = {
209
+ id: 'dev-user',
210
+ username: 'developer',
211
+ displayName: 'Developer',
212
+ email: 'dev@localhost',
213
+ groups: ['developers', 'admins'],
214
+ loginTime: Date.now()
215
+ };
216
+ /**
217
+ * Default permissions for dev mode (full access)
218
+ */
219
+ export const DEFAULT_DEV_PERMISSIONS = [
220
+ { featureId: 'map-view', canView: true, canEdit: true, canAdmin: true },
221
+ { featureId: 'coverage-view', canView: true, canEdit: true, canAdmin: true },
222
+ { featureId: 'charts-view', canView: true, canEdit: true, canAdmin: true },
223
+ { featureId: 'charts-edit', canView: true, canEdit: true, canAdmin: true },
224
+ { featureId: 'desktop-view', canView: true, canEdit: true, canAdmin: true },
225
+ { featureId: 'table-view', canView: true, canEdit: true, canAdmin: true },
226
+ { featureId: 'antenna-view', canView: true, canEdit: true, canAdmin: true },
227
+ { featureId: 'site-check', canView: true, canEdit: true, canAdmin: true },
228
+ { featureId: 'settings-view', canView: true, canEdit: true, canAdmin: true },
229
+ { featureId: 'admin', canView: true, canEdit: true, canAdmin: true }
230
+ ];
231
+ /**
232
+ * Get full dev configuration
233
+ */
234
+ export function getDevConfig() {
235
+ return {
236
+ devMode: true,
237
+ devUser: DEFAULT_DEV_USER,
238
+ devPermissions: DEFAULT_DEV_PERMISSIONS,
239
+ landingPage: {
240
+ title: 'RF Tool Components',
241
+ subtitle: 'Network Planning and Visualization Suite',
242
+ categories: DEFAULT_CATEGORIES,
243
+ apps: DEFAULT_APPS
244
+ }
245
+ };
246
+ }
247
+ /**
248
+ * Check if we're in development mode
249
+ */
250
+ export function isDevMode() {
251
+ // Check environment - in dev server or explicit flag
252
+ if (typeof import.meta !== 'undefined' && import.meta.env?.DEV) {
253
+ return true;
254
+ }
255
+ return false;
256
+ }
@@ -0,0 +1,4 @@
1
+ export * from './types.js';
2
+ export * from './auth.svelte.js';
3
+ export * from './config.js';
4
+ export { default as LoginForm } from './LoginForm.svelte';
@@ -0,0 +1,5 @@
1
+ // Auth module barrel export
2
+ export * from './types.js';
3
+ export * from './auth.svelte.js';
4
+ export * from './config.js';
5
+ export { default as LoginForm } from './LoginForm.svelte';
@@ -0,0 +1,140 @@
1
+ /**
2
+ * User information returned after successful authentication
3
+ */
4
+ export interface User {
5
+ /** Unique user identifier */
6
+ id: string;
7
+ /** Username used for login */
8
+ username: string;
9
+ /** Display name */
10
+ displayName: string;
11
+ /** User email (from LDAP) */
12
+ email?: string;
13
+ /** Groups/roles from LDAP */
14
+ groups?: string[];
15
+ /** Timestamp of login */
16
+ loginTime: number;
17
+ }
18
+ /**
19
+ * Access permission for a specific feature/app
20
+ */
21
+ export interface FeatureAccess {
22
+ /** Feature/app identifier */
23
+ featureId: string;
24
+ /** Whether user can view this feature */
25
+ canView: boolean;
26
+ /** Whether user can edit/modify */
27
+ canEdit?: boolean;
28
+ /** Whether user can administrate */
29
+ canAdmin?: boolean;
30
+ }
31
+ /**
32
+ * User session with permissions
33
+ */
34
+ export interface UserSession {
35
+ /** Authenticated user info */
36
+ user: User;
37
+ /** Access permissions for features */
38
+ permissions: FeatureAccess[];
39
+ /** Session token (for API calls) */
40
+ token: string;
41
+ /** Token expiration timestamp */
42
+ expiresAt: number;
43
+ }
44
+ /**
45
+ * Login credentials
46
+ */
47
+ export interface LoginCredentials {
48
+ username: string;
49
+ password: string;
50
+ /** User agreed to activity monitoring */
51
+ agreedToMonitoring: boolean;
52
+ }
53
+ /**
54
+ * Login response from API
55
+ */
56
+ export interface LoginResponse {
57
+ success: boolean;
58
+ session?: UserSession;
59
+ error?: string;
60
+ }
61
+ /**
62
+ * Auth configuration
63
+ */
64
+ export interface AuthConfig {
65
+ /** API endpoint for authentication */
66
+ apiEndpoint: string;
67
+ /** Enable development mode (auto-login) */
68
+ devMode: boolean;
69
+ /** Session storage key prefix */
70
+ storagePrefix: string;
71
+ /** Session timeout in milliseconds */
72
+ sessionTimeout: number;
73
+ }
74
+ /**
75
+ * App/Feature definition for landing page
76
+ */
77
+ export interface AppDefinition {
78
+ /** Unique identifier */
79
+ id: string;
80
+ /** Display title */
81
+ title: string;
82
+ /** Short description */
83
+ description: string;
84
+ /** Route path */
85
+ route: string;
86
+ /** Bootstrap icon class (e.g., 'bi-map') */
87
+ icon: string;
88
+ /** Category for grouping */
89
+ category: AppCategory;
90
+ /** Required permission to access */
91
+ requiredPermission?: string;
92
+ /** Whether app is enabled */
93
+ enabled: boolean;
94
+ /** Badge text (e.g., 'New', 'Beta') */
95
+ badge?: string;
96
+ /** Badge color class */
97
+ badgeColor?: string;
98
+ }
99
+ /**
100
+ * App category for grouping in landing page
101
+ */
102
+ export type AppCategory = 'map-tools' | 'visualization' | 'optimization' | 'analysis' | 'configuration' | 'demo';
103
+ /**
104
+ * Category metadata for display
105
+ */
106
+ export interface CategoryInfo {
107
+ id: AppCategory;
108
+ title: string;
109
+ description: string;
110
+ icon: string;
111
+ color: string;
112
+ }
113
+ /**
114
+ * Landing page configuration
115
+ */
116
+ export interface LandingPageConfig {
117
+ /** Application title */
118
+ title: string;
119
+ /** Subtitle/description */
120
+ subtitle: string;
121
+ /** Logo URL (optional) */
122
+ logo?: string;
123
+ /** Categories to display */
124
+ categories: CategoryInfo[];
125
+ /** Apps to display */
126
+ apps: AppDefinition[];
127
+ }
128
+ /**
129
+ * Development mode configuration (from config.json)
130
+ */
131
+ export interface DevConfig {
132
+ /** Enable dev mode */
133
+ devMode: boolean;
134
+ /** Auto-login user for dev mode */
135
+ devUser: User;
136
+ /** Dev mode permissions */
137
+ devPermissions: FeatureAccess[];
138
+ /** Landing page config */
139
+ landingPage: LandingPageConfig;
140
+ }
@@ -0,0 +1,2 @@
1
+ // Auth module types
2
+ export {};