progressive-share-button 1.0.0-alpha.6 → 1.0.0-alpha.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 +22 -0
- package/README.md +1 -2
- package/dist/progressive-share-button.es.js +132 -59
- package/dist/progressive-share-button.umd.js +163 -3
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0-alpha.8] - 2023-02-27
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Turned off minification for production builds because module will be ultimately be bundled with the application using the module and minification will be handled by the application's build process.
|
|
13
|
+
|
|
14
|
+
## [1.0.0-alpha.7] - 2023-02-27
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Added `CHANGELOG.md` file. Sorry for the delay on this one, if you've been watching this as it has gone through development. I'll try to keep this up to date from now on. We're still in an alpha state, so breaking changes will still happen, but I will document them here.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Changed: (breaking change) the import statement now initialized the web component without needing to call the imported function.
|
package/README.md
CHANGED
|
@@ -39,11 +39,10 @@ npm install progressive-share-button
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
main.js, if installed with npm
|
|
42
|
+
|
|
42
43
|
```javascript
|
|
43
44
|
// Import the component, which is the default export, so no curly braces are needed.
|
|
44
45
|
import ProgressiveShareButton from 'progressive-share-button';
|
|
45
|
-
// Initialie the component
|
|
46
|
-
ProgressiveShareButton();
|
|
47
46
|
```
|
|
48
47
|
|
|
49
48
|
### Customizing the component name
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
class
|
|
1
|
+
class ProgressiveShareButtonElement extends HTMLElement {
|
|
2
2
|
constructor() {
|
|
3
|
-
super()
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
super();
|
|
4
|
+
this.attachShadow({ mode: "open" });
|
|
5
|
+
this.iconSize = () => {
|
|
6
|
+
const size = this.getAttribute("icon-size") ?? "";
|
|
7
|
+
if (_isNumeric(size)) {
|
|
8
|
+
return size + "px";
|
|
9
|
+
} else if (size) {
|
|
10
|
+
return size;
|
|
11
|
+
} else {
|
|
12
|
+
return 24 + "px";
|
|
13
|
+
}
|
|
6
14
|
};
|
|
7
|
-
function
|
|
8
|
-
return /^-?\d+$/.test(
|
|
15
|
+
function _isNumeric(value) {
|
|
16
|
+
return /^-?\d+$/.test(value);
|
|
9
17
|
}
|
|
10
|
-
typeof navigator.share
|
|
18
|
+
if (typeof navigator.share === "function" || _getBoolean(this.getAttribute("debug"))) {
|
|
19
|
+
if (this.shadowRoot) {
|
|
20
|
+
this.shadowRoot.innerHTML = `
|
|
11
21
|
<style>
|
|
12
22
|
:host {
|
|
13
23
|
display: inline-block;
|
|
@@ -30,80 +40,143 @@ class u extends HTMLElement {
|
|
|
30
40
|
</style>
|
|
31
41
|
<button part="shareButton">
|
|
32
42
|
<slot>
|
|
33
|
-
${
|
|
43
|
+
${_whichIcon()}
|
|
34
44
|
</slot>
|
|
35
|
-
</button
|
|
45
|
+
</button>`;
|
|
46
|
+
this.addEventListener("click", this.share);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
console.warn("ProgressiveShareButton disabled due to lack of Web Share API support on this browser.");
|
|
50
|
+
}
|
|
36
51
|
}
|
|
37
52
|
share() {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
const debug = _getBoolean(this.getAttribute("debug"));
|
|
54
|
+
const smartShare = _getBoolean(this.getAttribute("smart-share"));
|
|
55
|
+
const url = this.getAttribute("url");
|
|
56
|
+
let text = this.getAttribute("text");
|
|
57
|
+
let title = this.getAttribute("title");
|
|
58
|
+
let data = {};
|
|
59
|
+
if (url) {
|
|
60
|
+
data.url = url;
|
|
61
|
+
}
|
|
62
|
+
if (text) {
|
|
63
|
+
data.text = text;
|
|
64
|
+
}
|
|
65
|
+
if (title) {
|
|
66
|
+
data.title = title;
|
|
67
|
+
}
|
|
68
|
+
if (smartShare) {
|
|
69
|
+
if (title && title.slice(-1) !== ".") {
|
|
70
|
+
title = title + ".";
|
|
71
|
+
}
|
|
72
|
+
if (text && text.slice(-1) !== ".") {
|
|
73
|
+
text = text + ".";
|
|
74
|
+
}
|
|
75
|
+
data = {
|
|
76
|
+
text: `${title ? title + " " : ""}${text ? text + " " : ""}${url ? url : ""}`
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (!data.url && !data.text && !data.title) {
|
|
80
|
+
data.url = window.location.href;
|
|
81
|
+
}
|
|
82
|
+
let shareEvent = new CustomEvent("progressive-share-success", {
|
|
83
|
+
bubbles: true,
|
|
84
|
+
cancelable: false,
|
|
85
|
+
composed: true,
|
|
86
|
+
detail: data
|
|
48
87
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
88
|
+
if (navigator.share) {
|
|
89
|
+
if (debug == 1) {
|
|
90
|
+
console.debug("data to be shared", data);
|
|
91
|
+
} else {
|
|
92
|
+
navigator.share(data).then(() => {
|
|
93
|
+
this.dispatchEvent(shareEvent);
|
|
94
|
+
}).catch((e) => {
|
|
95
|
+
let shareEventFail = new CustomEvent(
|
|
96
|
+
"progressive-share-fail",
|
|
97
|
+
{
|
|
98
|
+
bubbles: true,
|
|
99
|
+
cancelable: false,
|
|
100
|
+
composed: true,
|
|
101
|
+
detail: e
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
this.dispatchEvent(shareEventFail);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
console.debug("data to be shared", data);
|
|
109
|
+
}
|
|
63
110
|
}
|
|
64
111
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
112
|
+
function ProgressiveShareButton() {
|
|
113
|
+
if (typeof navigator.share === "function") {
|
|
114
|
+
console.log(
|
|
115
|
+
"ProgressiveShareButton support initialized. <progressive-share-success /> element now available"
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
console.log(
|
|
119
|
+
"ProgressiveShareButton support initialized. This browser does not have Web Share API support support."
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
customElements.define(
|
|
71
123
|
"progressive-share-button",
|
|
72
|
-
|
|
73
|
-
)
|
|
124
|
+
ProgressiveShareButtonElement
|
|
125
|
+
);
|
|
126
|
+
return true;
|
|
74
127
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
128
|
+
const iosShareIcon = '<svg xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 84.53 108.43" class="icon"><title>Share icon</title><desc>Square with upward arrow</desc><path d="m76.21,33.15h-23.38v5.28h23.38c1.72,0,3.04,1.32,3.04,2.91v58.77c0,1.58-1.32,2.91-3.04,2.91H8.32c-1.72,0-3.04-1.32-3.04-2.9v-58.64c0-1.58,1.32-2.91,3.04-2.91h20.74v-5.28H8.32c-4.62,0-8.32,3.7-8.32,8.19v58.77c0,4.49,3.7,8.19,8.32,8.19h67.88c4.62,0,8.32-3.7,8.32-8.19v-58.77c0-4.62-3.7-8.32-8.32-8.32h0Z"/><path d="m39.62,8.58v69.21h5.28V8.58l13.6,10.04,3.17-4.23L42.26,0l-19.41,14.4,3.17,4.23,13.6-10.04Z"/></svg>';
|
|
129
|
+
const androidShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 18.19 21.46" class="icon"><title>Share icon</title><desc>Circle with smaller circles radiating out</desc><g id="c"><path d="m15.1,15.29c-.89,0-1.7.38-2.28.98l-6.98-3.84c.24-.43.38-.94.38-1.49s-.14-1.03-.38-1.49l7.22-4.03c.55.48,1.25.77,2.04.77,1.7,0,3.1-1.39,3.1-3.1s-1.39-3.1-3.1-3.1-3.1,1.39-3.1,3.1c0,.67.22,1.27.58,1.78l-7.18,4.01c-.58-.62-1.39-1.03-2.3-1.03-1.7,0-3.1,1.39-3.1,3.1s1.39,3.1,3.1,3.1c.91,0,1.73-.41,2.3-1.03l6.98,3.84c-.26.46-.41.96-.41,1.51,0,1.7,1.39,3.1,3.1,3.1s3.1-1.39,3.1-3.1-1.37-3.07-3.07-3.07h0Zm0-14.54c1.32,0,2.38,1.08,2.38,2.38s-1.08,2.38-2.38,2.38-2.38-1.08-2.38-2.38,1.06-2.38,2.38-2.38ZM3.1,13.32c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.06,2.38-2.38,2.38Zm12,7.44c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.08,2.38-2.38,2.38Z"/></g></svg>';
|
|
130
|
+
const winShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 112.98 100.64" class="icon" ><title>Share icon</title><desc>Square with arrow coming out to the right</desc><g id="c"><path d="m80.68,16.3l22.7,22.65-22.7,22.64v-11.44h-6.78c-18.27,0-33.35,6.91-43.25,13.14,2.34-12.07,7.94-21.2,16.75-27.16,10.12-6.84,22.02-7.83,26.67-7.94l6.6-.15v-11.73M73.93,0v21.43c-12.15.29-51.56,5.17-51.27,56.46,0,0,21.02-20.94,51.27-20.98v20.98l39.05-38.98L73.93,0ZM0,28.24v72.39h86.95v-20.98l-6.6,6.61v7.26H8.12V28.24H0Z"/></g></svg>';
|
|
131
|
+
const _guessOs = () => {
|
|
132
|
+
const userAgent = navigator.userAgent;
|
|
133
|
+
if (/iPhone|iPad|iPod/.test(userAgent)) {
|
|
134
|
+
return "iOS";
|
|
135
|
+
} else if (/Android/.test(userAgent)) {
|
|
136
|
+
return "Android";
|
|
137
|
+
} else if (/Windows/.test(userAgent)) {
|
|
138
|
+
return "Windows";
|
|
139
|
+
} else if (/Mac/.test(userAgent)) {
|
|
140
|
+
return "Mac";
|
|
141
|
+
} else {
|
|
142
|
+
return "Unknown";
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const _whichIcon = () => {
|
|
146
|
+
const os = _guessOs();
|
|
147
|
+
switch (os) {
|
|
80
148
|
case "iOS":
|
|
81
149
|
case "Mac":
|
|
82
|
-
return
|
|
150
|
+
return iosShareIcon;
|
|
83
151
|
case "Android":
|
|
84
|
-
return
|
|
152
|
+
return androidShareIcon;
|
|
85
153
|
case "Windows":
|
|
86
154
|
case "Unknown":
|
|
87
155
|
default:
|
|
88
|
-
return
|
|
156
|
+
return winShareIcon;
|
|
89
157
|
}
|
|
90
158
|
};
|
|
91
|
-
function
|
|
92
|
-
var
|
|
93
|
-
|
|
159
|
+
function _getBoolean(stringValue) {
|
|
160
|
+
var _a;
|
|
161
|
+
if (!stringValue) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
switch ((_a = stringValue == null ? void 0 : stringValue.toLowerCase()) == null ? void 0 : _a.trim()) {
|
|
94
165
|
case "true":
|
|
95
166
|
case "1":
|
|
96
|
-
return
|
|
167
|
+
return true;
|
|
97
168
|
case "false":
|
|
98
169
|
case "0":
|
|
99
|
-
|
|
100
|
-
case void 0:
|
|
101
|
-
return !1;
|
|
170
|
+
return false;
|
|
102
171
|
default:
|
|
103
|
-
return JSON.parse(
|
|
172
|
+
return JSON.parse(stringValue);
|
|
104
173
|
}
|
|
105
174
|
}
|
|
175
|
+
const main = (() => {
|
|
176
|
+
ProgressiveShareButton();
|
|
177
|
+
})();
|
|
106
178
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
179
|
+
ProgressiveShareButton,
|
|
180
|
+
ProgressiveShareButtonElement,
|
|
181
|
+
main as default
|
|
109
182
|
};
|
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["progressive-share-button"] = {}));
|
|
3
|
+
})(this, function(exports2) {
|
|
4
|
+
"use strict";
|
|
5
|
+
class ProgressiveShareButtonElement extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.attachShadow({ mode: "open" });
|
|
9
|
+
this.iconSize = () => {
|
|
10
|
+
const size = this.getAttribute("icon-size") ?? "";
|
|
11
|
+
if (_isNumeric(size)) {
|
|
12
|
+
return size + "px";
|
|
13
|
+
} else if (size) {
|
|
14
|
+
return size;
|
|
15
|
+
} else {
|
|
16
|
+
return 24 + "px";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function _isNumeric(value) {
|
|
20
|
+
return /^-?\d+$/.test(value);
|
|
21
|
+
}
|
|
22
|
+
if (typeof navigator.share === "function" || _getBoolean(this.getAttribute("debug"))) {
|
|
23
|
+
if (this.shadowRoot) {
|
|
24
|
+
this.shadowRoot.innerHTML = `
|
|
2
25
|
<style>
|
|
3
26
|
:host {
|
|
4
27
|
display: inline-block;
|
|
@@ -21,6 +44,143 @@
|
|
|
21
44
|
</style>
|
|
22
45
|
<button part="shareButton">
|
|
23
46
|
<slot>
|
|
24
|
-
${
|
|
47
|
+
${_whichIcon()}
|
|
25
48
|
</slot>
|
|
26
|
-
</button
|
|
49
|
+
</button>`;
|
|
50
|
+
this.addEventListener("click", this.share);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
console.warn("ProgressiveShareButton disabled due to lack of Web Share API support on this browser.");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
share() {
|
|
57
|
+
const debug = _getBoolean(this.getAttribute("debug"));
|
|
58
|
+
const smartShare = _getBoolean(this.getAttribute("smart-share"));
|
|
59
|
+
const url = this.getAttribute("url");
|
|
60
|
+
let text = this.getAttribute("text");
|
|
61
|
+
let title = this.getAttribute("title");
|
|
62
|
+
let data = {};
|
|
63
|
+
if (url) {
|
|
64
|
+
data.url = url;
|
|
65
|
+
}
|
|
66
|
+
if (text) {
|
|
67
|
+
data.text = text;
|
|
68
|
+
}
|
|
69
|
+
if (title) {
|
|
70
|
+
data.title = title;
|
|
71
|
+
}
|
|
72
|
+
if (smartShare) {
|
|
73
|
+
if (title && title.slice(-1) !== ".") {
|
|
74
|
+
title = title + ".";
|
|
75
|
+
}
|
|
76
|
+
if (text && text.slice(-1) !== ".") {
|
|
77
|
+
text = text + ".";
|
|
78
|
+
}
|
|
79
|
+
data = {
|
|
80
|
+
text: `${title ? title + " " : ""}${text ? text + " " : ""}${url ? url : ""}`
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (!data.url && !data.text && !data.title) {
|
|
84
|
+
data.url = window.location.href;
|
|
85
|
+
}
|
|
86
|
+
let shareEvent = new CustomEvent("progressive-share-success", {
|
|
87
|
+
bubbles: true,
|
|
88
|
+
cancelable: false,
|
|
89
|
+
composed: true,
|
|
90
|
+
detail: data
|
|
91
|
+
});
|
|
92
|
+
if (navigator.share) {
|
|
93
|
+
if (debug == 1) {
|
|
94
|
+
console.debug("data to be shared", data);
|
|
95
|
+
} else {
|
|
96
|
+
navigator.share(data).then(() => {
|
|
97
|
+
this.dispatchEvent(shareEvent);
|
|
98
|
+
}).catch((e) => {
|
|
99
|
+
let shareEventFail = new CustomEvent(
|
|
100
|
+
"progressive-share-fail",
|
|
101
|
+
{
|
|
102
|
+
bubbles: true,
|
|
103
|
+
cancelable: false,
|
|
104
|
+
composed: true,
|
|
105
|
+
detail: e
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
this.dispatchEvent(shareEventFail);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
console.debug("data to be shared", data);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function ProgressiveShareButton() {
|
|
117
|
+
if (typeof navigator.share === "function") {
|
|
118
|
+
console.log(
|
|
119
|
+
"ProgressiveShareButton support initialized. <progressive-share-success /> element now available"
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
console.log(
|
|
123
|
+
"ProgressiveShareButton support initialized. This browser does not have Web Share API support support."
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
customElements.define(
|
|
127
|
+
"progressive-share-button",
|
|
128
|
+
ProgressiveShareButtonElement
|
|
129
|
+
);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
const iosShareIcon = '<svg xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 84.53 108.43" class="icon"><title>Share icon</title><desc>Square with upward arrow</desc><path d="m76.21,33.15h-23.38v5.28h23.38c1.72,0,3.04,1.32,3.04,2.91v58.77c0,1.58-1.32,2.91-3.04,2.91H8.32c-1.72,0-3.04-1.32-3.04-2.9v-58.64c0-1.58,1.32-2.91,3.04-2.91h20.74v-5.28H8.32c-4.62,0-8.32,3.7-8.32,8.19v58.77c0,4.49,3.7,8.19,8.32,8.19h67.88c4.62,0,8.32-3.7,8.32-8.19v-58.77c0-4.62-3.7-8.32-8.32-8.32h0Z"/><path d="m39.62,8.58v69.21h5.28V8.58l13.6,10.04,3.17-4.23L42.26,0l-19.41,14.4,3.17,4.23,13.6-10.04Z"/></svg>';
|
|
133
|
+
const androidShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 18.19 21.46" class="icon"><title>Share icon</title><desc>Circle with smaller circles radiating out</desc><g id="c"><path d="m15.1,15.29c-.89,0-1.7.38-2.28.98l-6.98-3.84c.24-.43.38-.94.38-1.49s-.14-1.03-.38-1.49l7.22-4.03c.55.48,1.25.77,2.04.77,1.7,0,3.1-1.39,3.1-3.1s-1.39-3.1-3.1-3.1-3.1,1.39-3.1,3.1c0,.67.22,1.27.58,1.78l-7.18,4.01c-.58-.62-1.39-1.03-2.3-1.03-1.7,0-3.1,1.39-3.1,3.1s1.39,3.1,3.1,3.1c.91,0,1.73-.41,2.3-1.03l6.98,3.84c-.26.46-.41.96-.41,1.51,0,1.7,1.39,3.1,3.1,3.1s3.1-1.39,3.1-3.1-1.37-3.07-3.07-3.07h0Zm0-14.54c1.32,0,2.38,1.08,2.38,2.38s-1.08,2.38-2.38,2.38-2.38-1.08-2.38-2.38,1.06-2.38,2.38-2.38ZM3.1,13.32c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.06,2.38-2.38,2.38Zm12,7.44c-1.32,0-2.38-1.08-2.38-2.38s1.08-2.38,2.38-2.38,2.38,1.08,2.38,2.38-1.08,2.38-2.38,2.38Z"/></g></svg>';
|
|
134
|
+
const winShareIcon = '<svg id="b" xmlns="http://www.w3.org/2000/svg" part="shareIcon" viewBox="0 0 112.98 100.64" class="icon" ><title>Share icon</title><desc>Square with arrow coming out to the right</desc><g id="c"><path d="m80.68,16.3l22.7,22.65-22.7,22.64v-11.44h-6.78c-18.27,0-33.35,6.91-43.25,13.14,2.34-12.07,7.94-21.2,16.75-27.16,10.12-6.84,22.02-7.83,26.67-7.94l6.6-.15v-11.73M73.93,0v21.43c-12.15.29-51.56,5.17-51.27,56.46,0,0,21.02-20.94,51.27-20.98v20.98l39.05-38.98L73.93,0ZM0,28.24v72.39h86.95v-20.98l-6.6,6.61v7.26H8.12V28.24H0Z"/></g></svg>';
|
|
135
|
+
const _guessOs = () => {
|
|
136
|
+
const userAgent = navigator.userAgent;
|
|
137
|
+
if (/iPhone|iPad|iPod/.test(userAgent)) {
|
|
138
|
+
return "iOS";
|
|
139
|
+
} else if (/Android/.test(userAgent)) {
|
|
140
|
+
return "Android";
|
|
141
|
+
} else if (/Windows/.test(userAgent)) {
|
|
142
|
+
return "Windows";
|
|
143
|
+
} else if (/Mac/.test(userAgent)) {
|
|
144
|
+
return "Mac";
|
|
145
|
+
} else {
|
|
146
|
+
return "Unknown";
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const _whichIcon = () => {
|
|
150
|
+
const os = _guessOs();
|
|
151
|
+
switch (os) {
|
|
152
|
+
case "iOS":
|
|
153
|
+
case "Mac":
|
|
154
|
+
return iosShareIcon;
|
|
155
|
+
case "Android":
|
|
156
|
+
return androidShareIcon;
|
|
157
|
+
case "Windows":
|
|
158
|
+
case "Unknown":
|
|
159
|
+
default:
|
|
160
|
+
return winShareIcon;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
function _getBoolean(stringValue) {
|
|
164
|
+
var _a;
|
|
165
|
+
if (!stringValue) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
switch ((_a = stringValue == null ? void 0 : stringValue.toLowerCase()) == null ? void 0 : _a.trim()) {
|
|
169
|
+
case "true":
|
|
170
|
+
case "1":
|
|
171
|
+
return true;
|
|
172
|
+
case "false":
|
|
173
|
+
case "0":
|
|
174
|
+
return false;
|
|
175
|
+
default:
|
|
176
|
+
return JSON.parse(stringValue);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const main = (() => {
|
|
180
|
+
ProgressiveShareButton();
|
|
181
|
+
})();
|
|
182
|
+
exports2.ProgressiveShareButton = ProgressiveShareButton;
|
|
183
|
+
exports2.ProgressiveShareButtonElement = ProgressiveShareButtonElement;
|
|
184
|
+
exports2.default = main;
|
|
185
|
+
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
186
|
+
});
|