@cocreate/lazy-loader 1.20.4 → 1.21.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 +14 -0
- package/package.json +1 -1
- package/src/client.js +9 -5
- package/src/server.js +16 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.21.0](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.20.5...v1.21.0) (2024-08-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* handle nested initailization function ([c46b449](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/c46b4497936e61d4c932de664be70bbbf6e72f05))
|
|
7
|
+
|
|
8
|
+
## [1.20.5](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.20.4...v1.20.5) (2024-08-24)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* try catch dependency ([70b10f5](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/70b10f546bba430aea32c206bcb033945d986842))
|
|
14
|
+
|
|
1
15
|
## [1.20.4](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.20.3...v1.20.4) (2024-06-30)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -61,12 +61,16 @@ export async function lazyLoad(name, selector, callback) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export async function dependency(name, promise) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
window.CoCreate
|
|
64
|
+
try {
|
|
65
|
+
let component = await promise;
|
|
66
|
+
if (!window.CoCreate)
|
|
67
|
+
window.CoCreate = {}
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
window.CoCreate[name] = component.default || component
|
|
70
|
+
dispatchComponentLoaded(name)
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('error loading chunck: ', error)
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
function dispatchComponentLoaded(name) {
|
package/src/server.js
CHANGED
|
@@ -193,12 +193,22 @@ class CoCreateLazyLoader {
|
|
|
193
193
|
throw new Error(`Missing ${name} key in organization apis object`);
|
|
194
194
|
|
|
195
195
|
// ToDo: if data.endpoint service not required as endpoint will be used
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (config.initialize)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
let instance = require(config.path);
|
|
197
|
+
|
|
198
|
+
if (config.initialize) {
|
|
199
|
+
const initialize = config.initialize.split('.');
|
|
200
|
+
|
|
201
|
+
// Traverse the nested structure to reach the correct constructor
|
|
202
|
+
for (let i = 0; i < initialize.length; i++) {
|
|
203
|
+
if (instance[initialize[i]]) {
|
|
204
|
+
instance = instance[initialize[i]];
|
|
205
|
+
} else {
|
|
206
|
+
throw new Error(`Service path ${config.initialize} is incorrect at ${initialize[i]}`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
instance = new instance(key);
|
|
202
212
|
|
|
203
213
|
let params = [], mainParam = false
|
|
204
214
|
for (let i = 0; true; i++) {
|