onelaraveljs 1.2.7 → 1.2.8
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/index.js +18 -3
- package/package.json +1 -1
- package/src/core/ViewController.js +33 -11
package/index.js
CHANGED
|
@@ -4,14 +4,29 @@ import { viewLoader } from './src/core/ViewLoader.js';
|
|
|
4
4
|
import { EventService } from './src/core/services/EventService.js';
|
|
5
5
|
import initApp from './src/init.js';
|
|
6
6
|
import { View } from './src/core/View.js';
|
|
7
|
+
import logger from './src/core/logger.js';
|
|
8
|
+
import { StoreService } from './src/core/services/StoreService.js';
|
|
9
|
+
import { HttpService } from './src/core/services/HttpService.js';
|
|
10
|
+
import { StorageService } from './src/core/services/StorageService.js';
|
|
11
|
+
export { OneMarkup } from './src/core/OneMarkup.js';
|
|
7
12
|
|
|
13
|
+
export const Store = StoreService.getInstance();
|
|
14
|
+
export const Storage = StorageService.getInstance('storage');
|
|
15
|
+
export const EventBus = EventService.getInstance();
|
|
16
|
+
// HttpService Class
|
|
8
17
|
// Export Core Components
|
|
9
|
-
export
|
|
10
|
-
|
|
18
|
+
export const Http = new HttpService();
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
App,
|
|
11
22
|
viewLoader,
|
|
12
23
|
EventService,
|
|
13
24
|
initApp,
|
|
14
|
-
View
|
|
25
|
+
View,
|
|
26
|
+
StoreService,
|
|
27
|
+
HttpService,
|
|
28
|
+
StorageService,
|
|
29
|
+
logger
|
|
15
30
|
};
|
|
16
31
|
|
|
17
32
|
// Default export
|
package/package.json
CHANGED
|
@@ -981,23 +981,45 @@ export class ViewController {
|
|
|
981
981
|
}
|
|
982
982
|
|
|
983
983
|
__include(path, data = {}) {
|
|
984
|
-
logger.log(`Including view: ${path} into ${this.path}`);
|
|
985
984
|
if (this.isVirtualRendering) {
|
|
986
985
|
const childParams = this._templateManager.childrenConfig[this._templateManager.childrenIndex];
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
986
|
+
|
|
987
|
+
// RELAXED CHECK: If strict SSR check fails, verify if the view exists and create it anyway.
|
|
988
|
+
// This handles cases where static includes were not registered in SSR data.
|
|
989
|
+
let child = null;
|
|
990
|
+
let childData = { ...data };
|
|
991
|
+
let isHydrated = false;
|
|
992
|
+
|
|
993
|
+
if (childParams && childParams.name === path) {
|
|
994
|
+
// Happy path: Hydration match found
|
|
995
|
+
this._templateManager.childrenIndex++;
|
|
996
|
+
const childConfig = this.App.View.ssrViewManager.getInstance(childParams.name, childParams.id);
|
|
997
|
+
if (childConfig) {
|
|
998
|
+
childData = { ...data, ...childConfig.data, __SSR_VIEW_ID__: childParams.id };
|
|
999
|
+
isHydrated = true;
|
|
1000
|
+
// Pre-create child instance
|
|
1001
|
+
child = this.$include(childParams.name, childData);
|
|
1002
|
+
if (child) {
|
|
1003
|
+
child.__.__scan(childConfig);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
if (!child) {
|
|
1009
|
+
// Fallback: Create a fresh instance even if SSR data is missing
|
|
1010
|
+
// This allows the includes to exist in the Virtual DOM tree, resolving "view is null" errors.
|
|
1011
|
+
// However, we mark it so it doesn't try to bind to non-existent SSR DOM nodes strictly.
|
|
1012
|
+
console.warn(`__include: Soft hydration for ${path} (Missing SSR Data)`);
|
|
1013
|
+
child = this.$include(path, data);
|
|
994
1014
|
}
|
|
995
|
-
|
|
996
|
-
const child = this.$include(childParams.name, childData);
|
|
1015
|
+
|
|
997
1016
|
if (!child) {
|
|
998
1017
|
return null;
|
|
999
1018
|
}
|
|
1000
|
-
|
|
1019
|
+
|
|
1020
|
+
// Important: We must ensure renderView returns the view object during scan,
|
|
1021
|
+
// but the original code calls renderView(child, null, true).
|
|
1022
|
+
// renderView(..., true) usually returns the view instance itself in scan mode.
|
|
1001
1023
|
return this.App.View.renderView(child, null, true);
|
|
1002
1024
|
}
|
|
1003
1025
|
|