@cocreate/lazy-loader 1.3.6 → 1.3.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/CHANGELOG.md +14 -0
- package/CoCreate.config.js +3 -2
- package/package.json +4 -4
- package/src/index.js +5 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.3.8](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.3.7...v1.3.8) (2023-05-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump [@cocreate](https://github.com/cocreate) dependencies ([00f5981](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/00f5981f49294d8ef38aa9076560659c6c4643da))
|
|
7
|
+
|
|
8
|
+
## [1.3.7](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.3.6...v1.3.7) (2023-05-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* removed unused functions ([f440ea8](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/f440ea8f713ca918ac08a7d4ae0a92255880cd21))
|
|
14
|
+
|
|
1
15
|
## [1.3.6](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.3.5...v1.3.6) (2023-05-01)
|
|
2
16
|
|
|
3
17
|
|
package/CoCreate.config.js
CHANGED
|
@@ -17,9 +17,10 @@ module.exports = {
|
|
|
17
17
|
"general.cocreate.app"
|
|
18
18
|
],
|
|
19
19
|
"directory": "/docs/lazy-loader",
|
|
20
|
-
"
|
|
20
|
+
"parentDirectory": "{{parentDirectory}}",
|
|
21
|
+
"content-type": "{{content-type}}",
|
|
21
22
|
"public": "true",
|
|
22
|
-
"website_id": "
|
|
23
|
+
"website_id": "644d4bff8036fb9d1d1fd69c"
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/lazy-loader",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "A simple lazy-loader component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lazy-loader",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"webpack-log": "^3.0.1"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@cocreate/docs": "^1.7.
|
|
63
|
-
"@cocreate/hosting": "^1.
|
|
64
|
-
"@cocreate/observer": "^1.7.
|
|
62
|
+
"@cocreate/docs": "^1.7.8",
|
|
63
|
+
"@cocreate/hosting": "^1.10.0",
|
|
64
|
+
"@cocreate/observer": "^1.7.6"
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import observer from '@cocreate/observer';
|
|
2
2
|
|
|
3
|
-
export function addComponent(key, component) {
|
|
4
|
-
this[key] = component;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function removeComponent(key) {
|
|
8
|
-
if (this[key]) {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
3
|
function listen(callback, selector) {
|
|
12
4
|
|
|
13
5
|
function observerCallback({ target }) {
|
|
@@ -54,24 +46,16 @@ function listen(callback, selector) {
|
|
|
54
46
|
|
|
55
47
|
}
|
|
56
48
|
|
|
57
|
-
export async function lazyLoad(name, selector,
|
|
58
|
-
async function cc() {
|
|
59
|
-
let component = (await cb()).default;
|
|
60
|
-
Object.assign(window.CoCreate, {
|
|
61
|
-
[name]: component
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
49
|
+
export async function lazyLoad(name, selector, callback) {
|
|
65
50
|
if (document.querySelector(selector))
|
|
66
|
-
await
|
|
51
|
+
await dependency(name, await callback())
|
|
67
52
|
else
|
|
68
|
-
listen(
|
|
69
|
-
|
|
53
|
+
listen(callback, selector)
|
|
70
54
|
}
|
|
71
55
|
|
|
72
56
|
export async function dependency(name, promise) {
|
|
73
|
-
let
|
|
57
|
+
let component = await promise;
|
|
74
58
|
Object.assign(window.CoCreate, {
|
|
75
|
-
[name]:
|
|
59
|
+
[name]: component.default
|
|
76
60
|
});
|
|
77
61
|
}
|