@cocreate/pwa 1.22.0 → 1.22.1
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 +8 -0
- package/package.json +1 -1
- package/src/geolocation.js +1 -1
- package/src/index.js +1 -1
- package/src/web-share.js +48 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.22.1](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.22.0...v1.22.1) (2025-04-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* dispatch end event on action element rather than document ([c14b2f3](https://github.com/CoCreate-app/CoCreate-pwa/commit/c14b2f3e92e50f3487aefd66a479e4222c835ab6))
|
|
7
|
+
* update observer observe param to type and and attributeName to attributeFilter ([5545765](https://github.com/CoCreate-app/CoCreate-pwa/commit/554576546507eda1c7577ae593e5c660572ba774))
|
|
8
|
+
|
|
1
9
|
# [1.22.0](https://github.com/CoCreate-app/CoCreate-pwa/compare/v1.21.0...v1.22.0) (2025-01-18)
|
|
2
10
|
|
|
3
11
|
|
package/package.json
CHANGED
package/src/geolocation.js
CHANGED
package/src/index.js
CHANGED
package/src/web-share.js
CHANGED
|
@@ -23,60 +23,68 @@
|
|
|
23
23
|
* For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import Observer from
|
|
27
|
-
import Actions from
|
|
26
|
+
import Observer from "@cocreate/observer";
|
|
27
|
+
import Actions from "@cocreate/actions";
|
|
28
28
|
|
|
29
29
|
const selector = "[share]";
|
|
30
30
|
|
|
31
31
|
async function init(element) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
32
|
+
if (
|
|
33
|
+
element &&
|
|
34
|
+
!(element instanceof HTMLCollection) &&
|
|
35
|
+
!Array.isArray(element)
|
|
36
|
+
)
|
|
37
|
+
element = [element];
|
|
38
|
+
else if (!element) {
|
|
39
|
+
element = document.querySelectorAll(selector);
|
|
40
|
+
}
|
|
42
41
|
|
|
42
|
+
for (let i = 0; i < element.length; i++)
|
|
43
|
+
element[i].addEventListener("click", function (e) {
|
|
44
|
+
share(e.target);
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
function share(element) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
if (navigator.share && element) {
|
|
50
|
+
let title = element.getAttribute("share-title") || document.title;
|
|
51
|
+
let text =
|
|
52
|
+
element.getAttribute("share-text") ||
|
|
53
|
+
document.querySelector('meta[name="description"]')?.content ||
|
|
54
|
+
"";
|
|
55
|
+
let url = element.getAttribute("share-url") || window.location.href;
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
navigator
|
|
58
|
+
.share({
|
|
59
|
+
title: title,
|
|
60
|
+
text: text,
|
|
61
|
+
url: url
|
|
62
|
+
})
|
|
63
|
+
.then(() => console.log("Successful share"))
|
|
64
|
+
.catch((error) => console.log("Error sharing", error));
|
|
65
|
+
} else {
|
|
66
|
+
console.log(
|
|
67
|
+
"Web Share API is not supported or element is not provided."
|
|
68
|
+
);
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
Observer.init({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
name: "webshare",
|
|
74
|
+
types: ["addedNodes"],
|
|
75
|
+
selector: "[share]",
|
|
76
|
+
callback: (mutation) => {
|
|
77
|
+
init(mutation.target);
|
|
78
|
+
}
|
|
70
79
|
});
|
|
71
80
|
|
|
72
81
|
Actions.init({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
init()
|
|
82
|
+
name: "share",
|
|
83
|
+
callback: (action) => {
|
|
84
|
+
share(action.element);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
80
87
|
|
|
81
|
-
|
|
88
|
+
init();
|
|
82
89
|
|
|
90
|
+
export default { init };
|