@mayson-org/inject-script 1.0.9 → 1.0.10

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 — inline styles, host-shell ?pwa_install=1 contract. */
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,0FAA0F;AAC1F,wBAAgB,8BAA8B,IAAI,MAAM,CAwLvD"}
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,CA6KvD"}
@@ -1,8 +1,8 @@
1
- /** Source for MaysonInstallPrompt — inline styles, host-shell ?pwa_install=1 contract. */
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, type CSSProperties } from 'react';
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,92 @@ export function MaysonInstallPrompt() {
78
82
  }
79
83
  };
80
84
 
81
- const showDismiss = !showIOSHint && !showBrowserHint;
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
- bottom: 16,
89
87
  left: '50%',
90
- zIndex: 50,
91
- width: 'calc(100% - 2rem)',
92
- maxWidth: 384,
88
+ bottom: 16,
89
+ zIndex: 2147483646,
93
90
  transform: 'translateX(-50%)',
94
- };
95
-
96
- const cardStyle: CSSProperties = {
97
- borderRadius: 24,
91
+ display: 'inline-flex',
92
+ alignItems: 'flex-end',
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
- fontSize: 14,
105
- lineHeight: 1.4,
106
- ...(cornerMask
107
- ? { maskImage: cornerMask, WebkitMaskImage: cornerMask }
108
- : {}),
101
+ textTransform: 'none',
102
+ };
103
+
104
+ const labelStyle: React.CSSProperties = {
105
+ color: '#9D9DA2',
106
+ fontSize: 12,
107
+ fontWeight: 500,
108
+ lineHeight: '14px',
109
+ margin: 0,
109
110
  };
110
111
 
111
- const installBtnStyle: CSSProperties = {
112
+ const actionStyle: React.CSSProperties = {
113
+ display: 'inline-flex',
114
+ alignItems: 'center',
115
+ gap: 4,
116
+ color: '#9D9DA2',
117
+ textDecoration: 'none',
112
118
  cursor: 'pointer',
113
- borderRadius: 8,
114
- background: '#fafafa',
115
- color: '#171718',
119
+ outline: 'none',
116
120
  border: 'none',
117
- padding: '6px 12px',
118
- fontSize: 14,
119
- fontWeight: 500,
121
+ background: 'transparent',
122
+ padding: 0,
123
+ margin: 0,
120
124
  fontFamily: 'inherit',
121
- flexShrink: 0,
125
+ fontSize: 12,
126
+ fontWeight: 500,
127
+ lineHeight: '14px',
128
+ whiteSpace: 'nowrap',
122
129
  };
123
130
 
124
- const dismissBtnStyle: CSSProperties = {
125
- position: 'absolute',
126
- top: -6,
127
- right: -6,
128
- zIndex: 10,
129
- display: 'flex',
131
+ const dismissStyle: React.CSSProperties = {
132
+ display: 'inline-flex',
130
133
  alignItems: 'center',
131
134
  justifyContent: 'center',
132
- width: 20,
133
- height: 20,
134
- cursor: 'pointer',
135
- fontSize: 12,
136
- color: '#737373',
137
- background: '#171718',
138
- border: '0.6px solid #46454866',
139
- borderRadius: '9999px',
135
+ width: 18,
136
+ height: 18,
140
137
  padding: 0,
138
+ border: 'none',
139
+ background: 'transparent',
140
+ color: '#9D9DA2',
141
+ fontSize: 16,
142
+ lineHeight: 1,
143
+ cursor: 'pointer',
144
+ flexShrink: 0,
145
+ fontFamily: 'inherit',
141
146
  };
142
147
 
143
148
  return (
144
- <div style={shellStyle}>
145
- <div style={cardStyle}>
146
- {showIOSHint ? (
147
- <p style={{ margin: 0 }}>
148
- To install: tap the &quot;Share&quot; button in Safari, then choose &quot;Add to
149
- Home Screen&quot;.
150
- </p>
151
- ) : showBrowserHint ? (
152
- <p style={{ margin: 0 }}>
153
- To install: open your browser menu (⋮) and choose &quot;Install app&quot; or
154
- &quot;Add to Home Screen&quot;
155
- </p>
156
- ) : (
157
- <div
158
- style={{
159
- display: 'flex',
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
-
149
+ <div role="group" aria-label="Install app" style={shellStyle}>
150
+ {showIOSHint ? (
151
+ <p style={{ ...labelStyle, lineHeight: '16px', whiteSpace: 'normal' }}>
152
+ To install: tap Share in Safari, then &quot;Add to Home Screen&quot;.
153
+ </p>
154
+ ) : showBrowserHint ? (
155
+ <p style={{ ...labelStyle, lineHeight: '16px', whiteSpace: 'normal' }}>
156
+ To install: open your browser menu (⋮) and choose &quot;Install app&quot;.
157
+ </p>
158
+ ) : (
159
+ <button type="button" onClick={install} style={actionStyle}>
160
+ Install app
180
161
  </button>
181
162
  )}
163
+ <button
164
+ type="button"
165
+ aria-label="Dismiss install prompt"
166
+ onClick={dismiss}
167
+ style={dismissStyle}
168
+ >
169
+ &times;
170
+ </button>
182
171
  </div>
183
172
  );
184
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mayson-org/inject-script",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "CLI and library to inject Mayson watermark, ascii, and PWA into Next.js App Router layouts.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",