slicejs-web-framework 2.4.1 → 2.4.3
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.
|
@@ -83,9 +83,9 @@ export default class Controller {
|
|
|
83
83
|
const bundleModule = await import(bundlePath);
|
|
84
84
|
|
|
85
85
|
// Manually register components from the imported bundle
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (bundleModule.SLICE_BUNDLE) {
|
|
87
|
+
await this.registerBundle(bundleModule.SLICE_BUNDLE);
|
|
88
|
+
}
|
|
89
89
|
|
|
90
90
|
this.loadedBundles.add(bundleName);
|
|
91
91
|
} catch (error) {
|
|
@@ -288,11 +288,11 @@ export default class Controller {
|
|
|
288
288
|
/**
|
|
289
289
|
* 📦 New bundle registration method (simplified and robust)
|
|
290
290
|
*/
|
|
291
|
-
|
|
291
|
+
registerBundle(bundle) {
|
|
292
292
|
const validation = this.validateBundle(bundle);
|
|
293
293
|
if (!validation.isValid) {
|
|
294
294
|
console.warn(`❌ Bundle validation failed: ${validation.error}`);
|
|
295
|
-
return;
|
|
295
|
+
return Promise.resolve(false);
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
const { components, metadata } = bundle;
|
|
@@ -303,8 +303,9 @@ export default class Controller {
|
|
|
303
303
|
const chunkSize = 50;
|
|
304
304
|
let index = 0;
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
const
|
|
306
|
+
return new Promise((resolve) => {
|
|
307
|
+
const processChunk = () => {
|
|
308
|
+
const sliceEntries = entries.slice(index, index + chunkSize);
|
|
308
309
|
|
|
309
310
|
for (const [componentName, componentData] of sliceEntries) {
|
|
310
311
|
try {
|
|
@@ -321,31 +322,48 @@ export default class Controller {
|
|
|
321
322
|
}
|
|
322
323
|
}
|
|
323
324
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
325
|
+
if (componentData.class && !this.classes.has(componentName)) {
|
|
326
|
+
const registeredName = componentData.isFramework
|
|
327
|
+
? `Framework/Structural/${componentName}`
|
|
328
|
+
: componentName;
|
|
329
|
+
this.classes.set(registeredName, componentData.class);
|
|
330
|
+
if (componentName === 'Loading') {
|
|
331
|
+
console.log('🔎 Bundle class registered: Loading', {
|
|
332
|
+
registeredName,
|
|
333
|
+
type: typeof componentData.class,
|
|
334
|
+
isFunction: typeof componentData.class === 'function'
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
if (componentName === 'InputSearchDocs' || componentName === 'MainMenu') {
|
|
338
|
+
console.log(`🔎 Bundle class registered: ${componentName}`, {
|
|
339
|
+
registeredName,
|
|
340
|
+
type: typeof componentData.class,
|
|
341
|
+
isFunction: typeof componentData.class === 'function'
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
330
345
|
} catch (error) {
|
|
331
346
|
console.warn(`❌ Failed to register component ${componentName}:`, error);
|
|
332
347
|
}
|
|
333
348
|
}
|
|
334
349
|
|
|
335
350
|
index += chunkSize;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
351
|
+
if (index < entries.length) {
|
|
352
|
+
if (typeof requestIdleCallback === 'function') {
|
|
353
|
+
requestIdleCallback(processChunk);
|
|
354
|
+
} else {
|
|
355
|
+
setTimeout(processChunk, 0);
|
|
356
|
+
}
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
344
359
|
|
|
345
|
-
|
|
360
|
+
console.log(`✅ Bundle registration completed: ${metadata.componentCount} components processed`);
|
|
361
|
+
resolve(true);
|
|
362
|
+
};
|
|
346
363
|
|
|
347
|
-
|
|
348
|
-
|
|
364
|
+
processChunk();
|
|
365
|
+
});
|
|
366
|
+
}
|
|
349
367
|
|
|
350
368
|
/**
|
|
351
369
|
* Validates bundle structure before registering.
|
package/Slice/Slice.js
CHANGED
|
@@ -156,8 +156,22 @@ export default class Slice {
|
|
|
156
156
|
delete props.id;
|
|
157
157
|
delete props.sliceId;
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
const ComponentClass = this.controller.classes.get(componentName);
|
|
160
|
+
if (componentName === 'Loading') {
|
|
161
|
+
console.log('🔎 Build component: Loading', {
|
|
162
|
+
classType: typeof ComponentClass,
|
|
163
|
+
isFunction: typeof ComponentClass === 'function',
|
|
164
|
+
classValue: ComponentClass
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (componentName === 'InputSearchDocs' || componentName === 'MainMenu') {
|
|
168
|
+
console.log(`🔎 Build component: ${componentName}`, {
|
|
169
|
+
classType: typeof ComponentClass,
|
|
170
|
+
isFunction: typeof ComponentClass === 'function',
|
|
171
|
+
classValue: ComponentClass
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const componentInstance = new ComponentClass(props);
|
|
161
175
|
|
|
162
176
|
if (componentIds.id && isVisual) componentInstance.id = componentIds.id;
|
|
163
177
|
if (componentIds.sliceId) componentInstance.sliceId = componentIds.sliceId;
|
|
@@ -252,9 +266,9 @@ async function init() {
|
|
|
252
266
|
await import('/bundles/slice-bundle.framework.js');
|
|
253
267
|
frameworkClasses = window.SLICE_FRAMEWORK_CLASSES || null;
|
|
254
268
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
269
|
+
} catch (error) {
|
|
270
|
+
console.warn('Framework bundle not available, falling back to dynamic imports', error);
|
|
271
|
+
}
|
|
258
272
|
|
|
259
273
|
if (!frameworkClasses) {
|
|
260
274
|
const imports = await Promise.all([
|
|
@@ -283,11 +297,11 @@ async function init() {
|
|
|
283
297
|
const criticalFile = config?.bundles?.critical?.file;
|
|
284
298
|
if (criticalFile) {
|
|
285
299
|
const criticalModule = await import(`/bundles/${criticalFile}`);
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
300
|
+
if (criticalModule.SLICE_BUNDLE) {
|
|
301
|
+
await window.slice.controller.registerBundle(criticalModule.SLICE_BUNDLE);
|
|
302
|
+
window.slice.controller.loadedBundles.add('critical');
|
|
303
|
+
window.slice.controller.criticalBundleLoaded = true;
|
|
304
|
+
}
|
|
291
305
|
}
|
|
292
306
|
|
|
293
307
|
const routeBundles = config?.routeBundles || {};
|
|
@@ -300,12 +314,12 @@ async function init() {
|
|
|
300
314
|
const bundleInfo = config?.bundles?.routes?.[bundleName];
|
|
301
315
|
if (!bundleInfo?.file) continue;
|
|
302
316
|
const routeModule = await import(`/bundles/${bundleInfo.file}`);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
317
|
+
if (routeModule.SLICE_BUNDLE) {
|
|
318
|
+
await window.slice.controller.registerBundle(routeModule.SLICE_BUNDLE);
|
|
319
|
+
window.slice.controller.loadedBundles.add(bundleName);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
};
|
|
309
323
|
|
|
310
324
|
if (typeof requestIdleCallback === 'function') {
|
|
311
325
|
requestIdleCallback(() => loadRouteBundles());
|