@cocreate/lazy-loader 1.3.5 → 1.3.7
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/demo/index.html +1 -1
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/src/index.js +5 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.3.7](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.3.6...v1.3.7) (2023-05-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed unused functions ([f440ea8](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/f440ea8f713ca918ac08a7d4ae0a92255880cd21))
|
|
7
|
+
|
|
8
|
+
## [1.3.6](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.3.5...v1.3.6) (2023-05-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update manifest.json to manifest.webmanifest ([b605f27](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/b605f27956d535d00f849ec0c8482c827eb07fe0))
|
|
14
|
+
|
|
1
15
|
## [1.3.5](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.3.4...v1.3.5) (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/demo/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
<link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
|
|
9
9
|
<title>lazy-loader | CoCreateJS</title>
|
|
10
|
-
<link rel="manifest" href="/manifest.
|
|
10
|
+
<link rel="manifest" href="/manifest.webmanifest">
|
|
11
11
|
</head>
|
|
12
12
|
|
|
13
13
|
<body>
|
package/docs/index.html
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<!-- CoCreate CSS CDN -->
|
|
14
14
|
<link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
|
|
15
15
|
|
|
16
|
-
<link rel="manifest" href="/manifest.
|
|
16
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
17
17
|
</head>
|
|
18
18
|
|
|
19
19
|
<body>
|
package/package.json
CHANGED
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
|
}
|