@mayson-org/inject-script 1.0.9 → 1.0.11
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.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** Source for MaysonInstallPrompt —
|
|
1
|
+
/** Source for MaysonInstallPrompt — same visual language as MaysonWatermark. */
|
|
2
2
|
export declare function buildMaysonInstallPromptSource(): string;
|
|
3
3
|
//# sourceMappingURL=install-prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install-prompt.d.ts","sourceRoot":"","sources":["../../../../src/plugins/pwa/templates/install-prompt.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"install-prompt.d.ts","sourceRoot":"","sources":["../../../../src/plugins/pwa/templates/install-prompt.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,8BAA8B,IAAI,MAAM,CAkLvD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** Source for MaysonInstallPrompt —
|
|
1
|
+
/** Source for MaysonInstallPrompt — same visual language as MaysonWatermark. */
|
|
2
2
|
export function buildMaysonInstallPromptSource() {
|
|
3
3
|
return `'use client';
|
|
4
4
|
|
|
5
|
-
import { useEffect, useState
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
const DISMISS_KEY = 'mayson-pwa-install-dismissed';
|
|
8
8
|
|
|
@@ -60,12 +60,16 @@ export function MaysonInstallPrompt() {
|
|
|
60
60
|
|
|
61
61
|
if (!visible) return null;
|
|
62
62
|
|
|
63
|
-
const dismiss = () => {
|
|
63
|
+
const dismiss = (event: React.MouseEvent) => {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
event.stopPropagation();
|
|
64
66
|
localStorage.setItem(DISMISS_KEY, '1');
|
|
65
67
|
setVisible(false);
|
|
66
68
|
};
|
|
67
69
|
|
|
68
|
-
const install = async () => {
|
|
70
|
+
const install = async (event: React.MouseEvent) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
event.stopPropagation();
|
|
69
73
|
if (deferred) {
|
|
70
74
|
await deferred.prompt();
|
|
71
75
|
const { outcome } = await deferred.userChoice;
|
|
@@ -78,107 +82,97 @@ export function MaysonInstallPrompt() {
|
|
|
78
82
|
}
|
|
79
83
|
};
|
|
80
84
|
|
|
81
|
-
const
|
|
82
|
-
const cornerMask = showDismiss
|
|
83
|
-
? 'radial-gradient(circle 20px at 100% 0, transparent 16px, #000 17px)'
|
|
84
|
-
: undefined;
|
|
85
|
-
|
|
86
|
-
const shellStyle: CSSProperties = {
|
|
85
|
+
const shellStyle: React.CSSProperties = {
|
|
87
86
|
position: 'fixed',
|
|
88
|
-
|
|
87
|
+
top: 16,
|
|
89
88
|
left: '50%',
|
|
90
|
-
zIndex:
|
|
91
|
-
width: 'calc(100% - 2rem)',
|
|
92
|
-
maxWidth: 384,
|
|
89
|
+
zIndex: 2147483646,
|
|
93
90
|
transform: 'translateX(-50%)',
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
display: 'inline-flex',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
gap: 8,
|
|
94
|
+
maxWidth: 'calc(100% - 2rem)',
|
|
95
|
+
padding: '4px 8px',
|
|
96
|
+
borderRadius: 6,
|
|
98
97
|
background: '#171718',
|
|
99
98
|
border: '0.6px solid #46454866',
|
|
100
99
|
boxShadow: '0px 8px 12px 6px #00000026',
|
|
101
|
-
padding: '12px 20px',
|
|
102
|
-
color: '#9D9DA2',
|
|
103
100
|
fontFamily: '"Google Sans", system-ui, -apple-system, sans-serif',
|
|
104
|
-
|
|
105
|
-
lineHeight: 1.4,
|
|
106
|
-
...(cornerMask
|
|
107
|
-
? { maskImage: cornerMask, WebkitMaskImage: cornerMask }
|
|
108
|
-
: {}),
|
|
101
|
+
textTransform: 'none',
|
|
109
102
|
};
|
|
110
103
|
|
|
111
|
-
const
|
|
104
|
+
const labelStyle: React.CSSProperties = {
|
|
105
|
+
color: '#9D9DA2',
|
|
106
|
+
fontSize: 12,
|
|
107
|
+
fontWeight: 500,
|
|
108
|
+
lineHeight: '14px',
|
|
109
|
+
margin: 0,
|
|
110
|
+
whiteSpace: 'nowrap',
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const installBtnStyle: React.CSSProperties = {
|
|
114
|
+
display: 'inline-flex',
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
justifyContent: 'center',
|
|
112
117
|
cursor: 'pointer',
|
|
113
|
-
|
|
118
|
+
outline: 'none',
|
|
119
|
+
border: 'none',
|
|
120
|
+
borderRadius: 4,
|
|
114
121
|
background: '#fafafa',
|
|
115
122
|
color: '#171718',
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
fontSize: 14,
|
|
119
|
-
fontWeight: 500,
|
|
123
|
+
padding: '2px 8px',
|
|
124
|
+
margin: 0,
|
|
120
125
|
fontFamily: 'inherit',
|
|
126
|
+
fontSize: 12,
|
|
127
|
+
fontWeight: 500,
|
|
128
|
+
lineHeight: '14px',
|
|
129
|
+
whiteSpace: 'nowrap',
|
|
121
130
|
flexShrink: 0,
|
|
122
131
|
};
|
|
123
132
|
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
top: -6,
|
|
127
|
-
right: -6,
|
|
128
|
-
zIndex: 10,
|
|
129
|
-
display: 'flex',
|
|
133
|
+
const dismissStyle: React.CSSProperties = {
|
|
134
|
+
display: 'inline-flex',
|
|
130
135
|
alignItems: 'center',
|
|
131
136
|
justifyContent: 'center',
|
|
132
|
-
width:
|
|
133
|
-
height:
|
|
134
|
-
cursor: 'pointer',
|
|
135
|
-
fontSize: 12,
|
|
136
|
-
color: '#737373',
|
|
137
|
-
background: '#171718',
|
|
138
|
-
border: '0.6px solid #46454866',
|
|
139
|
-
borderRadius: '9999px',
|
|
137
|
+
width: 18,
|
|
138
|
+
height: 18,
|
|
140
139
|
padding: 0,
|
|
140
|
+
border: 'none',
|
|
141
|
+
background: 'transparent',
|
|
142
|
+
color: '#9D9DA2',
|
|
143
|
+
fontSize: 16,
|
|
144
|
+
lineHeight: 1,
|
|
145
|
+
cursor: 'pointer',
|
|
146
|
+
flexShrink: 0,
|
|
147
|
+
fontFamily: 'inherit',
|
|
141
148
|
};
|
|
142
149
|
|
|
143
150
|
return (
|
|
144
|
-
<div style={shellStyle}>
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
alignItems: 'center',
|
|
161
|
-
justifyContent: 'space-between',
|
|
162
|
-
gap: 12,
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
<p style={{ margin: 0 }}>Install this app on your device</p>
|
|
166
|
-
<button type="button" onClick={install} style={installBtnStyle}>
|
|
167
|
-
Install
|
|
168
|
-
</button>
|
|
169
|
-
</div>
|
|
170
|
-
)}
|
|
171
|
-
</div>
|
|
172
|
-
{showDismiss && (
|
|
173
|
-
<button
|
|
174
|
-
type="button"
|
|
175
|
-
onClick={dismiss}
|
|
176
|
-
aria-label="Dismiss install prompt"
|
|
177
|
-
style={dismissBtnStyle}
|
|
178
|
-
>
|
|
179
|
-
✕
|
|
180
|
-
</button>
|
|
151
|
+
<div role="group" aria-label="Install app" style={shellStyle}>
|
|
152
|
+
{showIOSHint ? (
|
|
153
|
+
<p style={{ ...labelStyle, whiteSpace: 'normal', lineHeight: '16px' }}>
|
|
154
|
+
To install: tap Share in Safari, then "Add to Home Screen".
|
|
155
|
+
</p>
|
|
156
|
+
) : showBrowserHint ? (
|
|
157
|
+
<p style={{ ...labelStyle, whiteSpace: 'normal', lineHeight: '16px' }}>
|
|
158
|
+
To install: open your browser menu (⋮) and choose "Install app".
|
|
159
|
+
</p>
|
|
160
|
+
) : (
|
|
161
|
+
<>
|
|
162
|
+
<span style={labelStyle}>Install this app on your device</span>
|
|
163
|
+
<button type="button" onClick={install} style={installBtnStyle}>
|
|
164
|
+
Install
|
|
165
|
+
</button>
|
|
166
|
+
</>
|
|
181
167
|
)}
|
|
168
|
+
<button
|
|
169
|
+
type="button"
|
|
170
|
+
aria-label="Dismiss install prompt"
|
|
171
|
+
onClick={dismiss}
|
|
172
|
+
style={dismissStyle}
|
|
173
|
+
>
|
|
174
|
+
×
|
|
175
|
+
</button>
|
|
182
176
|
</div>
|
|
183
177
|
);
|
|
184
178
|
}
|
package/package.json
CHANGED