slicejs-web-framework 2.3.1 → 2.3.2

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/Slice/Slice.js CHANGED
@@ -1,297 +1,383 @@
1
- import Controller from './Components/Structural/Controller/Controller.js';
2
- import StylesManager from './Components/Structural/StylesManager/StylesManager.js';
3
-
4
- export default class Slice {
5
- constructor(sliceConfig) {
6
- this.controller = new Controller();
7
- this.stylesManager = new StylesManager();
8
- this.paths = sliceConfig.paths;
9
- this.themeConfig = sliceConfig.themeManager;
10
- this.stylesConfig = sliceConfig.stylesManager;
11
- this.loggerConfig = sliceConfig.logger;
12
- this.debuggerConfig = sliceConfig.debugger;
13
- this.loadingConfig = sliceConfig.loading;
14
- this.eventsConfig = sliceConfig.events;
15
-
16
- // šŸ“¦ Bundle system is initialized automatically via import in index.js
17
- }
18
-
19
- async getClass(module) {
20
- try {
21
- const { default: myClass } = await import(module);
22
- return await myClass;
23
- } catch (error) {
24
- this.logger.logError('Slice', `Error loading class ${module}`, error);
25
- }
26
- }
27
-
28
- isProduction() {
29
- return true;
30
- }
31
-
32
- getComponent(componentSliceId) {
33
- return this.controller.activeComponents.get(componentSliceId);
34
- }
35
-
36
- async build(componentName, props = {}) {
37
- if (!componentName) {
38
- this.logger.logError('Slice', null, `Component name is required to build a component`);
39
- return null;
40
- }
41
-
42
- if (typeof componentName !== 'string') {
43
- this.logger.logError('Slice', null, `Component name must be a string`);
44
- return null;
45
- }
46
-
47
- if (!this.controller.componentCategories.has(componentName)) {
48
- this.logger.logError('Slice', null, `Component ${componentName} not found in components.js file`);
49
- return null;
50
- }
51
-
52
- // šŸ“¦ Try to load from bundles first
53
- const bundleName = this.controller.getBundleForComponent(componentName);
54
- if (bundleName && !this.controller.loadedBundles.has(bundleName)) {
55
- await this.controller.loadBundle(bundleName);
56
- }
57
-
58
- let componentCategory = this.controller.componentCategories.get(componentName);
59
-
60
- // šŸ“¦ Check if component is already available from loaded bundles
61
- const isFromBundle = this.controller.isComponentFromBundle(componentName);
62
-
63
- if (componentCategory === 'Structural') {
64
- this.logger.logError(
65
- 'Slice',
66
- null,
67
- `Component ${componentName} is a Structural component and cannot be built`
68
- );
69
- return null;
70
- }
71
-
72
- let isVisual = slice.paths.components[componentCategory].type === 'Visual';
73
- let modulePath = `${slice.paths.components[componentCategory].path}/${componentName}/${componentName}.js`;
74
-
75
- // Load template, class, and CSS concurrently if needed
76
- try {
77
- // šŸ“¦ Skip individual loading if component is available from bundles
78
- const loadTemplate =
79
- isFromBundle || !isVisual || this.controller.templates.has(componentName)
80
- ? Promise.resolve(null)
81
- : this.controller.fetchText(componentName, 'html', componentCategory);
82
-
83
- const loadClass =
84
- isFromBundle || this.controller.classes.has(componentName)
85
- ? Promise.resolve(null)
86
- : this.getClass(modulePath);
87
-
88
- const loadCSS =
89
- isFromBundle || !isVisual || this.controller.requestedStyles.has(componentName)
90
- ? Promise.resolve(null)
91
- : this.controller.fetchText(componentName, 'css', componentCategory);
92
-
93
- const [html, ComponentClass, css] = await Promise.all([loadTemplate, loadClass, loadCSS]);
94
-
95
- // šŸ“¦ If component is from bundle but not in cache, it should have been registered by registerBundle
96
- if (isFromBundle) {
97
- console.log(`šŸ“¦ Using bundled component: ${componentName}`);
98
- }
99
-
100
- if (html || html === '') {
101
- const template = document.createElement('template');
102
- template.innerHTML = html;
103
- this.controller.templates.set(componentName, template);
104
- this.logger.logInfo('Slice', `Template ${componentName} loaded`);
105
- }
106
-
107
- if (ComponentClass) {
108
- this.controller.classes.set(componentName, ComponentClass);
109
- this.logger.logInfo('Slice', `Class ${componentName} loaded`);
110
- }
111
-
112
- if (css) {
113
- this.stylesManager.registerComponentStyles(componentName, css);
114
- this.logger.logInfo('Slice', `CSS ${componentName} loaded`);
115
- }
116
- } catch (error) {
117
- console.log(error);
118
- this.logger.logError('Slice', `Error loading resources for ${componentName}`, error);
119
- return null;
120
- }
121
-
122
- // Create instance
123
- try {
124
- let componentIds = {};
125
- if (props.id) componentIds.id = props.id;
126
- if (props.sliceId) componentIds.sliceId = props.sliceId;
127
-
128
- delete props.id;
129
- delete props.sliceId;
130
-
131
- const ComponentClass = this.controller.classes.get(componentName);
132
- const componentInstance = new ComponentClass(props);
133
-
134
- if (componentIds.id && isVisual) componentInstance.id = componentIds.id;
135
- if (componentIds.sliceId) componentInstance.sliceId = componentIds.sliceId;
136
-
137
- if (!this.controller.verifyComponentIds(componentInstance)) {
138
- this.logger.logError('Slice', `Error registering instance ${componentName} ${componentInstance.sliceId}`);
139
- return null;
140
- }
141
-
142
- if (componentInstance.init) await componentInstance.init();
143
-
144
- if (slice.debuggerConfig.enabled && isVisual) {
145
- this.debugger.attachDebugMode(componentInstance);
146
- }
147
-
148
- this.controller.registerComponent(componentInstance);
149
- if (isVisual) {
150
- this.controller.registerComponentsRecursively(componentInstance);
151
- }
152
-
153
- this.logger.logInfo('Slice', `Instance ${componentInstance.sliceId} created`);
154
- return componentInstance;
155
- } catch (error) {
156
- console.log(error);
157
- this.logger.logError('Slice', `Error creating instance ${componentName}`, error);
158
- return null;
159
- }
160
- }
161
-
162
- async setTheme(themeName) {
163
- await this.stylesManager.themeManager.applyTheme(themeName);
164
- }
165
-
166
- get theme() {
167
- return this.stylesManager.themeManager.currentTheme;
168
- }
169
-
170
- attachTemplate(componentInstance) {
171
- this.controller.loadTemplateToComponent(componentInstance);
172
- }
173
- }
174
-
175
- async function loadConfig() {
176
- try {
177
- const response = await fetch('/sliceConfig.json'); // šŸ”¹ Express lo sirve desde `src/`
178
- if (!response.ok) throw new Error('Error loading sliceConfig.json');
179
- const json = await response.json();
180
- console.log(json);
181
- return json;
182
- } catch (error) {
183
- console.error(`Error loading config file: ${error.message}`);
184
- return null;
185
- }
186
- }
187
-
188
- async function init() {
189
- const sliceConfig = await loadConfig();
190
- if (!sliceConfig) {
191
- //Display error message in console with colors and alert in english
192
- console.error('%cā›”ļø Error loading Slice configuration ā›”ļø', 'color: red; font-size: 20px;');
193
- alert('Error loading Slice configuration');
194
- return;
195
- }
196
-
197
- window.slice = new Slice(sliceConfig);
198
-
199
- slice.paths.structuralComponentFolderPath = '/Slice/Components/Structural';
200
-
201
- if (sliceConfig.logger.enabled) {
202
- const LoggerModule = await window.slice.getClass(`${slice.paths.structuralComponentFolderPath}/Logger/Logger.js`);
203
- window.slice.logger = new LoggerModule();
204
- } else {
205
- window.slice.logger = {
206
- logError: () => {},
207
- logWarning: () => {},
208
- logInfo: () => {},
209
- };
210
- }
211
-
212
- if (sliceConfig.debugger.enabled) {
213
- const DebuggerModule = await window.slice.getClass(
214
- `${slice.paths.structuralComponentFolderPath}/Debugger/Debugger.js`
215
- );
216
- window.slice.debugger = new DebuggerModule();
217
- await window.slice.debugger.enableDebugMode();
218
- document.body.appendChild(window.slice.debugger);
219
- }
220
-
221
- if (sliceConfig.events?.enabled) {
222
- const EventManagerModule = await window.slice.getClass(
223
- `${slice.paths.structuralComponentFolderPath}/EventManager/EventManager.js`
224
- );
225
- window.slice.events = new EventManagerModule();
226
- if (typeof window.slice.events.init === 'function') {
227
- await window.slice.events.init();
228
- }
229
- window.slice.logger.logError('Slice', 'EventManager enabled');
230
- } else {
231
- window.slice.events = {
232
- subscribe: () => null,
233
- subscribeOnce: () => null,
234
- unsubscribe: () => false,
235
- emit: () => {},
236
- bind: () => ({
237
- subscribe: () => null,
238
- subscribeOnce: () => null,
239
- emit: () => {},
240
- }),
241
- cleanupComponent: () => 0,
242
- hasSubscribers: () => false,
243
- subscriberCount: () => 0,
244
- clear: () => {},
245
- };
246
- window.slice.logger.logError('Slice', 'EventManager disabled');
247
- }
248
-
249
- if (sliceConfig.context?.enabled) {
250
- const ContextManagerModule = await window.slice.getClass(
251
- `${slice.paths.structuralComponentFolderPath}/ContextManager/ContextManager.js`
252
- );
253
- window.slice.context = new ContextManagerModule();
254
- if (typeof window.slice.context.init === 'function') {
255
- await window.slice.context.init();
256
- }
257
- window.slice.logger.logError('Slice', 'ContextManager enabled');
258
- } else {
259
- window.slice.context = {
260
- create: () => false,
261
- getState: () => null,
262
- setState: () => {},
263
- watch: () => null,
264
- has: () => false,
265
- destroy: () => false,
266
- list: () => [],
267
- };
268
- window.slice.logger.logError('Slice', 'ContextManager disabled');
269
- }
270
-
271
- if (sliceConfig.loading.enabled) {
272
- const loading = await window.slice.build('Loading', {});
273
- window.slice.loading = loading;
274
- }
275
-
276
- await window.slice.stylesManager.init();
277
-
278
- const routesModule = await import(slice.paths.routesFile);
279
- const routes = routesModule.default;
280
- const RouterModule = await window.slice.getClass(`${slice.paths.structuralComponentFolderPath}/Router/Router.js`);
281
- window.slice.router = new RouterModule(routes);
282
- await window.slice.router.init();
283
- }
284
-
285
- await init();
286
-
287
- // Initialize bundles if available
288
- try {
289
- const { initializeBundles } = await import('/bundles/bundle.config.js');
290
- if (initializeBundles) {
291
- await initializeBundles(window.slice);
292
- console.log('šŸ“¦ Bundles initialized automatically');
293
- }
294
- } catch (error) {
295
- // Bundles not available, continue with individual component loading
296
- console.log('šŸ“„ Using individual component loading (no bundles found)');
297
- }
1
+ import Controller from './Components/Structural/Controller/Controller.js';
2
+ import StylesManager from './Components/Structural/StylesManager/StylesManager.js';
3
+
4
+ /**
5
+ * Main Slice.js runtime.
6
+ */
7
+ export default class Slice {
8
+ /**
9
+ * @param {Object} sliceConfig
10
+ */
11
+ constructor(sliceConfig) {
12
+ this.controller = new Controller();
13
+ this.stylesManager = new StylesManager();
14
+ this.paths = sliceConfig.paths;
15
+ this.themeConfig = sliceConfig.themeManager;
16
+ this.stylesConfig = sliceConfig.stylesManager;
17
+ this.loggerConfig = sliceConfig.logger;
18
+ this.debuggerConfig = sliceConfig.debugger;
19
+ this.loadingConfig = sliceConfig.loading;
20
+ this.eventsConfig = sliceConfig.events;
21
+
22
+ // šŸ“¦ Bundle system is initialized automatically via import in index.js
23
+ }
24
+
25
+ /**
26
+ * Dynamically import a module and return its default export.
27
+ * @param {string} module
28
+ * @returns {Promise<any>}
29
+ */
30
+ async getClass(module) {
31
+ try {
32
+ const { default: myClass } = await import(module);
33
+ return await myClass;
34
+ } catch (error) {
35
+ this.logger.logError('Slice', `Error loading class ${module}`, error);
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Flag for production behavior (override in builds).
41
+ * @returns {boolean}
42
+ */
43
+ isProduction() {
44
+ return true;
45
+ }
46
+
47
+ /**
48
+ * Get a component instance by sliceId.
49
+ * @param {string} componentSliceId
50
+ * @returns {HTMLElement|undefined}
51
+ */
52
+ getComponent(componentSliceId) {
53
+ return this.controller.activeComponents.get(componentSliceId);
54
+ }
55
+
56
+ /**
57
+ * Build a component instance and run init.
58
+ * @param {string} componentName
59
+ * @param {Object} [props]
60
+ * @returns {Promise<HTMLElement|Object|null>}
61
+ */
62
+ async build(componentName, props = {}) {
63
+ if (!componentName) {
64
+ this.logger.logError('Slice', null, `Component name is required to build a component`);
65
+ return null;
66
+ }
67
+
68
+ if (typeof componentName !== 'string') {
69
+ this.logger.logError('Slice', null, `Component name must be a string`);
70
+ return null;
71
+ }
72
+
73
+ if (!this.controller.componentCategories.has(componentName)) {
74
+ this.logger.logError('Slice', null, `Component ${componentName} not found in components.js file`);
75
+ return null;
76
+ }
77
+
78
+ // šŸ“¦ Try to load from bundles first
79
+ const bundleName = this.controller.getBundleForComponent(componentName);
80
+ if (bundleName && !this.controller.loadedBundles.has(bundleName)) {
81
+ await this.controller.loadBundle(bundleName);
82
+ }
83
+
84
+ let componentCategory = this.controller.componentCategories.get(componentName);
85
+
86
+ // šŸ“¦ Check if component is already available from loaded bundles
87
+ const isFromBundle = this.controller.isComponentFromBundle(componentName);
88
+
89
+ if (componentCategory === 'Structural') {
90
+ this.logger.logError(
91
+ 'Slice',
92
+ null,
93
+ `Component ${componentName} is a Structural component and cannot be built`
94
+ );
95
+ return null;
96
+ }
97
+
98
+ let isVisual = slice.paths.components[componentCategory].type === 'Visual';
99
+ let modulePath = `${slice.paths.components[componentCategory].path}/${componentName}/${componentName}.js`;
100
+
101
+ // Load template, class, and CSS concurrently if needed
102
+ try {
103
+ // šŸ“¦ Skip individual loading if component is available from bundles
104
+ const loadTemplate =
105
+ isFromBundle || !isVisual || this.controller.templates.has(componentName)
106
+ ? Promise.resolve(null)
107
+ : this.controller.fetchText(componentName, 'html', componentCategory);
108
+
109
+ const loadClass =
110
+ isFromBundle || this.controller.classes.has(componentName)
111
+ ? Promise.resolve(null)
112
+ : this.getClass(modulePath);
113
+
114
+ const loadCSS =
115
+ isFromBundle || !isVisual || this.controller.requestedStyles.has(componentName)
116
+ ? Promise.resolve(null)
117
+ : this.controller.fetchText(componentName, 'css', componentCategory);
118
+
119
+ const [html, ComponentClass, css] = await Promise.all([loadTemplate, loadClass, loadCSS]);
120
+
121
+ // šŸ“¦ If component is from bundle but not in cache, it should have been registered by registerBundle
122
+ if (isFromBundle) {
123
+ console.log(`šŸ“¦ Using bundled component: ${componentName}`);
124
+ }
125
+
126
+ if (html || html === '') {
127
+ const template = document.createElement('template');
128
+ template.innerHTML = html;
129
+ this.controller.templates.set(componentName, template);
130
+ this.logger.logInfo('Slice', `Template ${componentName} loaded`);
131
+ }
132
+
133
+ if (ComponentClass) {
134
+ this.controller.classes.set(componentName, ComponentClass);
135
+ this.logger.logInfo('Slice', `Class ${componentName} loaded`);
136
+ }
137
+
138
+ if (css) {
139
+ this.stylesManager.registerComponentStyles(componentName, css);
140
+ this.logger.logInfo('Slice', `CSS ${componentName} loaded`);
141
+ }
142
+ } catch (error) {
143
+ console.log(error);
144
+ this.logger.logError('Slice', `Error loading resources for ${componentName}`, error);
145
+ return null;
146
+ }
147
+
148
+ // Create instance
149
+ try {
150
+ let componentIds = {};
151
+ if (props.id) componentIds.id = props.id;
152
+ if (props.sliceId) componentIds.sliceId = props.sliceId;
153
+
154
+ delete props.id;
155
+ delete props.sliceId;
156
+
157
+ const ComponentClass = this.controller.classes.get(componentName);
158
+ const componentInstance = new ComponentClass(props);
159
+
160
+ if (componentIds.id && isVisual) componentInstance.id = componentIds.id;
161
+ if (componentIds.sliceId) componentInstance.sliceId = componentIds.sliceId;
162
+
163
+ if (!this.controller.verifyComponentIds(componentInstance)) {
164
+ this.logger.logError('Slice', `Error registering instance ${componentName} ${componentInstance.sliceId}`);
165
+ return null;
166
+ }
167
+
168
+ if (componentInstance.init) await componentInstance.init();
169
+
170
+ if (slice.debuggerConfig.enabled && isVisual) {
171
+ this.debugger.attachDebugMode(componentInstance);
172
+ }
173
+
174
+ this.controller.registerComponent(componentInstance);
175
+ if (isVisual) {
176
+ this.controller.registerComponentsRecursively(componentInstance);
177
+ }
178
+
179
+ this.logger.logInfo('Slice', `Instance ${componentInstance.sliceId} created`);
180
+ return componentInstance;
181
+ } catch (error) {
182
+ console.log(error);
183
+ this.logger.logError('Slice', `Error creating instance ${componentName}`, error);
184
+ return null;
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Apply a theme by name.
190
+ * @param {string} themeName
191
+ * @returns {Promise<void>}
192
+ */
193
+ async setTheme(themeName) {
194
+ await this.stylesManager.themeManager.applyTheme(themeName);
195
+ }
196
+
197
+ /**
198
+ * Current theme name.
199
+ * @returns {string|null}
200
+ */
201
+ get theme() {
202
+ return this.stylesManager.themeManager.currentTheme;
203
+ }
204
+
205
+ /**
206
+ * Attach HTML template to a component instance.
207
+ * @param {HTMLElement} componentInstance
208
+ * @returns {void}
209
+ */
210
+ attachTemplate(componentInstance) {
211
+ this.controller.loadTemplateToComponent(componentInstance);
212
+ }
213
+ }
214
+
215
+ async function loadConfig() {
216
+ try {
217
+ const response = await fetch('/sliceConfig.json'); // šŸ”¹ Express lo sirve desde `src/`
218
+ if (!response.ok) throw new Error('Error loading sliceConfig.json');
219
+ const json = await response.json();
220
+ console.log(json);
221
+ return json;
222
+ } catch (error) {
223
+ console.error(`Error loading config file: ${error.message}`);
224
+ return null;
225
+ }
226
+ }
227
+
228
+ async function init() {
229
+ const sliceConfig = await loadConfig();
230
+ if (!sliceConfig) {
231
+ //Display error message in console with colors and alert in english
232
+ console.error('%cā›”ļø Error loading Slice configuration ā›”ļø', 'color: red; font-size: 20px;');
233
+ alert('Error loading Slice configuration');
234
+ return;
235
+ }
236
+
237
+ window.slice = new Slice(sliceConfig);
238
+
239
+ slice.paths.structuralComponentFolderPath = '/Slice/Components/Structural';
240
+
241
+ if (sliceConfig.logger.enabled) {
242
+ const LoggerModule = await window.slice.getClass(`${slice.paths.structuralComponentFolderPath}/Logger/Logger.js`);
243
+ window.slice.logger = new LoggerModule();
244
+ } else {
245
+ window.slice.logger = {
246
+ logError: () => {},
247
+ logWarning: () => {},
248
+ logInfo: () => {},
249
+ };
250
+ }
251
+
252
+ if (sliceConfig.debugger.enabled) {
253
+ const DebuggerModule = await window.slice.getClass(
254
+ `${slice.paths.structuralComponentFolderPath}/Debugger/Debugger.js`
255
+ );
256
+ window.slice.debugger = new DebuggerModule();
257
+ await window.slice.debugger.enableDebugMode();
258
+ document.body.appendChild(window.slice.debugger);
259
+ }
260
+
261
+ if (sliceConfig.events?.ui?.enabled) {
262
+ const EventsDebuggerModule = await window.slice.getClass(
263
+ `${slice.paths.structuralComponentFolderPath}/EventManager/EventManagerDebugger.js`
264
+ );
265
+ window.slice.eventsDebugger = new EventsDebuggerModule();
266
+ await window.slice.eventsDebugger.init();
267
+ document.body.appendChild(window.slice.eventsDebugger);
268
+ }
269
+
270
+ if (sliceConfig.context?.ui?.enabled) {
271
+ const ContextDebuggerModule = await window.slice.getClass(
272
+ `${slice.paths.structuralComponentFolderPath}/ContextManager/ContextManagerDebugger.js`
273
+ );
274
+ window.slice.contextDebugger = new ContextDebuggerModule();
275
+ await window.slice.contextDebugger.init();
276
+ document.body.appendChild(window.slice.contextDebugger);
277
+ }
278
+
279
+ if (sliceConfig.events?.enabled) {
280
+ const EventManagerModule = await window.slice.getClass(
281
+ `${slice.paths.structuralComponentFolderPath}/EventManager/EventManager.js`
282
+ );
283
+ window.slice.events = new EventManagerModule();
284
+ if (typeof window.slice.events.init === 'function') {
285
+ await window.slice.events.init();
286
+ }
287
+ window.slice.logger.logError('Slice', 'EventManager enabled');
288
+ } else {
289
+ window.slice.events = {
290
+ subscribe: () => null,
291
+ subscribeOnce: () => null,
292
+ unsubscribe: () => false,
293
+ emit: () => {},
294
+ bind: () => ({
295
+ subscribe: () => null,
296
+ subscribeOnce: () => null,
297
+ emit: () => {},
298
+ }),
299
+ cleanupComponent: () => 0,
300
+ hasSubscribers: () => false,
301
+ subscriberCount: () => 0,
302
+ clear: () => {},
303
+ };
304
+ window.slice.logger.logError('Slice', 'EventManager disabled');
305
+ }
306
+
307
+ if (sliceConfig.context?.enabled) {
308
+ const ContextManagerModule = await window.slice.getClass(
309
+ `${slice.paths.structuralComponentFolderPath}/ContextManager/ContextManager.js`
310
+ );
311
+ window.slice.context = new ContextManagerModule();
312
+ if (typeof window.slice.context.init === 'function') {
313
+ await window.slice.context.init();
314
+ }
315
+ window.slice.logger.logError('Slice', 'ContextManager enabled');
316
+ } else {
317
+ window.slice.context = {
318
+ create: () => false,
319
+ getState: () => null,
320
+ setState: () => {},
321
+ watch: () => null,
322
+ has: () => false,
323
+ destroy: () => false,
324
+ list: () => [],
325
+ };
326
+ window.slice.logger.logError('Slice', 'ContextManager disabled');
327
+ }
328
+
329
+ if (sliceConfig.loading.enabled) {
330
+ const loading = await window.slice.build('Loading', {});
331
+ window.slice.loading = loading;
332
+ }
333
+
334
+ await window.slice.stylesManager.init();
335
+
336
+ if (sliceConfig.events?.ui?.shortcut || sliceConfig.context?.ui?.shortcut) {
337
+ const normalize = (value) => (typeof value === 'string' ? value.toLowerCase() : '');
338
+ const toKey = (event) => {
339
+ const parts = [];
340
+ if (event.ctrlKey) parts.push('ctrl');
341
+ if (event.shiftKey) parts.push('shift');
342
+ if (event.altKey) parts.push('alt');
343
+ if (event.metaKey) parts.push('meta');
344
+ const key = event.key?.toLowerCase();
345
+ if (key && !['control', 'shift', 'alt', 'meta'].includes(key)) {
346
+ parts.push(key);
347
+ }
348
+ return parts.join('+');
349
+ };
350
+
351
+ const handlers = {
352
+ [normalize(sliceConfig.events?.ui?.shortcut)]: () => window.slice.eventsDebugger?.toggle?.(),
353
+ [normalize(sliceConfig.context?.ui?.shortcut)]: () => window.slice.contextDebugger?.toggle?.(),
354
+ };
355
+
356
+ document.addEventListener('keydown', (event) => {
357
+ const key = toKey(event);
358
+ if (!key || !handlers[key]) return;
359
+ event.preventDefault();
360
+ handlers[key]();
361
+ });
362
+ }
363
+
364
+ const routesModule = await import(slice.paths.routesFile);
365
+ const routes = routesModule.default;
366
+ const RouterModule = await window.slice.getClass(`${slice.paths.structuralComponentFolderPath}/Router/Router.js`);
367
+ window.slice.router = new RouterModule(routes);
368
+ await window.slice.router.init();
369
+ }
370
+
371
+ await init();
372
+
373
+ // Initialize bundles if available
374
+ try {
375
+ const { initializeBundles } = await import('/bundles/bundle.config.js');
376
+ if (initializeBundles) {
377
+ await initializeBundles(window.slice);
378
+ console.log('šŸ“¦ Bundles initialized automatically');
379
+ }
380
+ } catch (error) {
381
+ // Bundles not available, continue with individual component loading
382
+ console.log('šŸ“„ Using individual component loading (no bundles found)');
383
+ }