@djangocfg/ui-nextjs 2.1.45 → 2.1.46
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/package.json +4 -4
- package/src/hooks/useBrowserDetect.ts +206 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-nextjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.46",
|
|
4
4
|
"description": "Next.js UI component library with Radix UI primitives, Tailwind CSS styling, charts, and form components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-components",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"check": "tsc --noEmit"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@djangocfg/api": "^2.1.
|
|
62
|
-
"@djangocfg/ui-core": "^2.1.
|
|
61
|
+
"@djangocfg/api": "^2.1.46",
|
|
62
|
+
"@djangocfg/ui-core": "^2.1.46",
|
|
63
63
|
"@types/react": "^19.1.0",
|
|
64
64
|
"@types/react-dom": "^19.1.0",
|
|
65
65
|
"consola": "^3.4.2",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"vidstack": "next"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
109
|
+
"@djangocfg/typescript-config": "^2.1.46",
|
|
110
110
|
"@types/node": "^24.7.2",
|
|
111
111
|
"eslint": "^9.37.0",
|
|
112
112
|
"tailwindcss-animate": "1.0.7",
|
|
@@ -26,6 +26,23 @@ export interface BrowserInfo {
|
|
|
26
26
|
isSamsungBrowser: boolean;
|
|
27
27
|
isUCBrowser: boolean;
|
|
28
28
|
|
|
29
|
+
// Additional browsers
|
|
30
|
+
isComet: boolean; // Perplexity's Comet browser (Chromium-based, supports push)
|
|
31
|
+
isOperaMini: boolean; // Opera Mini (does NOT support push notifications)
|
|
32
|
+
isIE: boolean; // Internet Explorer (does NOT support push notifications)
|
|
33
|
+
|
|
34
|
+
// In-App Browsers (WebViews) - typically do NOT support push notifications
|
|
35
|
+
isFacebookInApp: boolean; // Facebook's in-app browser
|
|
36
|
+
isInstagramInApp: boolean; // Instagram's in-app browser
|
|
37
|
+
isTikTokInApp: boolean; // TikTok's in-app browser
|
|
38
|
+
isSnapchatInApp: boolean; // Snapchat's in-app browser
|
|
39
|
+
isWeChatInApp: boolean; // WeChat's in-app browser
|
|
40
|
+
isThreadsInApp: boolean; // Threads' in-app browser
|
|
41
|
+
isLinkedInInApp: boolean; // LinkedIn's in-app browser (uses Chrome WebView - supports push on Android)
|
|
42
|
+
isTwitterInApp: boolean; // Twitter/X's in-app browser (uses Chrome WebView - supports push on Android)
|
|
43
|
+
isInAppBrowser: boolean; // Any in-app browser detected
|
|
44
|
+
isWebView: boolean; // Generic WebView detection
|
|
45
|
+
|
|
29
46
|
// Browser name
|
|
30
47
|
browserName: string;
|
|
31
48
|
|
|
@@ -34,6 +51,25 @@ export interface BrowserInfo {
|
|
|
34
51
|
isBlink: boolean; // Chromium's engine
|
|
35
52
|
isGecko: boolean; // Firefox's engine
|
|
36
53
|
|
|
54
|
+
// Push notification support
|
|
55
|
+
/**
|
|
56
|
+
* Whether the browser supports Web Push Notifications.
|
|
57
|
+
* Returns false for browsers known to NOT support push:
|
|
58
|
+
* - Opera Mini (no service worker support)
|
|
59
|
+
* - Internet Explorer (deprecated, no Push API)
|
|
60
|
+
* - UC Browser (unreliable push support)
|
|
61
|
+
* - In-App browsers (Facebook, Instagram, TikTok, Snapchat, etc.)
|
|
62
|
+
* - Generic WebViews (except Twitter/LinkedIn on Android which use Chrome WebView)
|
|
63
|
+
*
|
|
64
|
+
* Note: Comet (Perplexity) is Chromium-based and DOES support push notifications.
|
|
65
|
+
* Note: This is a browser-level check. For full push support,
|
|
66
|
+
* also check 'serviceWorker' in navigator && 'PushManager' in window
|
|
67
|
+
*/
|
|
68
|
+
supportsPushNotifications: boolean;
|
|
69
|
+
|
|
70
|
+
// iOS specific
|
|
71
|
+
isIOSBrowser: boolean; // Any browser on iOS (all use WebKit, limited push support)
|
|
72
|
+
|
|
37
73
|
// For debugging
|
|
38
74
|
userAgent: string;
|
|
39
75
|
}
|
|
@@ -70,10 +106,25 @@ export function useBrowserDetect(): BrowserInfo {
|
|
|
70
106
|
isYandex: false,
|
|
71
107
|
isSamsungBrowser: false,
|
|
72
108
|
isUCBrowser: false,
|
|
109
|
+
isComet: false,
|
|
110
|
+
isOperaMini: false,
|
|
111
|
+
isIE: false,
|
|
112
|
+
isFacebookInApp: false,
|
|
113
|
+
isInstagramInApp: false,
|
|
114
|
+
isTikTokInApp: false,
|
|
115
|
+
isSnapchatInApp: false,
|
|
116
|
+
isWeChatInApp: false,
|
|
117
|
+
isThreadsInApp: false,
|
|
118
|
+
isLinkedInInApp: false,
|
|
119
|
+
isTwitterInApp: false,
|
|
120
|
+
isInAppBrowser: false,
|
|
121
|
+
isWebView: false,
|
|
73
122
|
browserName: 'unknown',
|
|
74
123
|
isWebKit: false,
|
|
75
124
|
isBlink: false,
|
|
76
125
|
isGecko: false,
|
|
126
|
+
supportsPushNotifications: false,
|
|
127
|
+
isIOSBrowser: false,
|
|
77
128
|
userAgent: '',
|
|
78
129
|
};
|
|
79
130
|
}
|
|
@@ -103,8 +154,93 @@ export function useBrowserDetect(): BrowserInfo {
|
|
|
103
154
|
// UC Browser
|
|
104
155
|
const isUCBrowser = ua.includes('ucbrowser') || ua.includes('uc browser');
|
|
105
156
|
|
|
157
|
+
// Comet Browser (Perplexity's AI browser, Chromium-based)
|
|
158
|
+
// May have 'comet' in UA or can be detected by specific markers
|
|
159
|
+
const isComet = ua.includes('comet') || ua.includes('perplexity');
|
|
160
|
+
|
|
161
|
+
// Opera Mini (does NOT support service workers or push)
|
|
162
|
+
const isOperaMini = ua.includes('opera mini') || ua.includes('opios');
|
|
163
|
+
|
|
164
|
+
// Internet Explorer (deprecated, no Push API support)
|
|
165
|
+
const isIE = ua.includes('msie') || ua.includes('trident/');
|
|
166
|
+
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// In-App Browsers Detection (WebViews)
|
|
169
|
+
// These browsers typically do NOT support web push notifications
|
|
170
|
+
// ============================================================================
|
|
171
|
+
|
|
172
|
+
// Facebook In-App Browser
|
|
173
|
+
// UA contains: FBAN (Facebook App Name) or FBAV (Facebook App Version)
|
|
174
|
+
const isFacebookInApp = ua.includes('fban') || ua.includes('fbav') || ua.includes('fb_iab');
|
|
175
|
+
|
|
176
|
+
// Instagram In-App Browser
|
|
177
|
+
// UA contains: Instagram
|
|
178
|
+
const isInstagramInApp = ua.includes('instagram');
|
|
179
|
+
|
|
180
|
+
// TikTok In-App Browser
|
|
181
|
+
// UA contains: TikTok or BytedanceWebview or ByteLocale
|
|
182
|
+
const isTikTokInApp = ua.includes('tiktok') || ua.includes('bytedancewebview') || ua.includes('bytelocale');
|
|
183
|
+
|
|
184
|
+
// Snapchat In-App Browser
|
|
185
|
+
// UA contains: Snapchat
|
|
186
|
+
const isSnapchatInApp = ua.includes('snapchat');
|
|
187
|
+
|
|
188
|
+
// WeChat In-App Browser
|
|
189
|
+
// UA contains: MicroMessenger
|
|
190
|
+
const isWeChatInApp = ua.includes('micromessenger');
|
|
191
|
+
|
|
192
|
+
// Threads In-App Browser (Meta's app)
|
|
193
|
+
// UA contains: Threads or uses same markers as Instagram
|
|
194
|
+
const isThreadsInApp = ua.includes('barcelona'); // Threads codename is Barcelona
|
|
195
|
+
|
|
196
|
+
// LinkedIn In-App Browser
|
|
197
|
+
// UA contains: LinkedIn - NOTE: Uses Chrome WebView on Android, may support push
|
|
198
|
+
const isLinkedInInApp = ua.includes('linkedinapp');
|
|
199
|
+
|
|
200
|
+
// Twitter/X In-App Browser
|
|
201
|
+
// UA contains: Twitter - NOTE: Uses Chrome WebView on Android, may support push
|
|
202
|
+
const isTwitterInApp = ua.includes('twitter');
|
|
203
|
+
|
|
204
|
+
// Pinterest In-App Browser
|
|
205
|
+
const isPinterestInApp = ua.includes('pinterest');
|
|
206
|
+
|
|
207
|
+
// Telegram In-App Browser
|
|
208
|
+
const isTelegramInApp = ua.includes('telegram');
|
|
209
|
+
|
|
210
|
+
// Line In-App Browser
|
|
211
|
+
const isLineInApp = ua.includes('line/');
|
|
212
|
+
|
|
213
|
+
// Kakao In-App Browser (Korea)
|
|
214
|
+
const isKakaoInApp = ua.includes('kakaotalk');
|
|
215
|
+
|
|
216
|
+
// Generic WebView detection
|
|
217
|
+
// Android WebView: contains 'wv' in UA or specific WebView markers
|
|
218
|
+
// iOS WebView: WKWebView doesn't have distinct UA, but some markers exist
|
|
219
|
+
const isWebView = ua.includes('wv)') || // Android WebView marker
|
|
220
|
+
ua.includes('webview') ||
|
|
221
|
+
ua.includes('; wv') ||
|
|
222
|
+
(ua.includes('iphone') && !ua.includes('safari')) || // iOS WebView (no Safari)
|
|
223
|
+
(ua.includes('ipad') && !ua.includes('safari'));
|
|
224
|
+
|
|
225
|
+
// Aggregate: Any in-app browser
|
|
226
|
+
const isInAppBrowser = isFacebookInApp ||
|
|
227
|
+
isInstagramInApp ||
|
|
228
|
+
isTikTokInApp ||
|
|
229
|
+
isSnapchatInApp ||
|
|
230
|
+
isWeChatInApp ||
|
|
231
|
+
isThreadsInApp ||
|
|
232
|
+
isLinkedInInApp ||
|
|
233
|
+
isTwitterInApp ||
|
|
234
|
+
isPinterestInApp ||
|
|
235
|
+
isTelegramInApp ||
|
|
236
|
+
isLineInApp ||
|
|
237
|
+
isKakaoInApp;
|
|
238
|
+
|
|
239
|
+
// iOS detection (all iOS browsers use WebKit, limited push support)
|
|
240
|
+
const isIOSBrowser = ua.includes('iphone') || ua.includes('ipad') || ua.includes('ipod');
|
|
241
|
+
|
|
106
242
|
// Opera (modern Chromium-based)
|
|
107
|
-
const isOpera = ua.includes('opr/') || ua.includes('opera');
|
|
243
|
+
const isOpera = (ua.includes('opr/') || ua.includes('opera')) && !isOperaMini;
|
|
108
244
|
|
|
109
245
|
// Chrome (not Edge, not other Chromium browsers)
|
|
110
246
|
const isChrome = ua.includes('chrome') &&
|
|
@@ -114,7 +250,8 @@ export function useBrowserDetect(): BrowserInfo {
|
|
|
114
250
|
!isSamsungBrowser &&
|
|
115
251
|
!isVivaldi &&
|
|
116
252
|
!isArc &&
|
|
117
|
-
!isBrave
|
|
253
|
+
!isBrave &&
|
|
254
|
+
!isComet;
|
|
118
255
|
|
|
119
256
|
// Firefox
|
|
120
257
|
const isFirefox = ua.includes('firefox') && !ua.includes('seamonkey');
|
|
@@ -138,7 +275,8 @@ export function useBrowserDetect(): BrowserInfo {
|
|
|
138
275
|
isVivaldi ||
|
|
139
276
|
isArc ||
|
|
140
277
|
isBrave ||
|
|
141
|
-
isUCBrowser
|
|
278
|
+
isUCBrowser ||
|
|
279
|
+
isComet;
|
|
142
280
|
|
|
143
281
|
// Engine detection
|
|
144
282
|
const isWebKit = !isChromium && isSafari;
|
|
@@ -146,8 +284,24 @@ export function useBrowserDetect(): BrowserInfo {
|
|
|
146
284
|
const isGecko = isFirefox;
|
|
147
285
|
|
|
148
286
|
// Determine browser name
|
|
287
|
+
// In-app browsers take priority in naming
|
|
149
288
|
let browserName = 'unknown';
|
|
150
|
-
if (
|
|
289
|
+
if (isFacebookInApp) browserName = 'Facebook In-App';
|
|
290
|
+
else if (isInstagramInApp) browserName = 'Instagram In-App';
|
|
291
|
+
else if (isTikTokInApp) browserName = 'TikTok In-App';
|
|
292
|
+
else if (isSnapchatInApp) browserName = 'Snapchat In-App';
|
|
293
|
+
else if (isWeChatInApp) browserName = 'WeChat In-App';
|
|
294
|
+
else if (isThreadsInApp) browserName = 'Threads In-App';
|
|
295
|
+
else if (isLinkedInInApp) browserName = 'LinkedIn In-App';
|
|
296
|
+
else if (isTwitterInApp) browserName = 'Twitter In-App';
|
|
297
|
+
else if (isPinterestInApp) browserName = 'Pinterest In-App';
|
|
298
|
+
else if (isTelegramInApp) browserName = 'Telegram In-App';
|
|
299
|
+
else if (isLineInApp) browserName = 'Line In-App';
|
|
300
|
+
else if (isKakaoInApp) browserName = 'KakaoTalk In-App';
|
|
301
|
+
else if (isComet) browserName = 'Comet';
|
|
302
|
+
else if (isOperaMini) browserName = 'Opera Mini';
|
|
303
|
+
else if (isIE) browserName = 'Internet Explorer';
|
|
304
|
+
else if (isBrave) browserName = 'Brave';
|
|
151
305
|
else if (isArc) browserName = 'Arc';
|
|
152
306
|
else if (isVivaldi) browserName = 'Vivaldi';
|
|
153
307
|
else if (isYandex) browserName = 'Yandex';
|
|
@@ -158,6 +312,39 @@ export function useBrowserDetect(): BrowserInfo {
|
|
|
158
312
|
else if (isChrome) browserName = 'Chrome';
|
|
159
313
|
else if (isSafari) browserName = 'Safari';
|
|
160
314
|
else if (isFirefox) browserName = 'Firefox';
|
|
315
|
+
else if (isWebView) browserName = 'WebView';
|
|
316
|
+
|
|
317
|
+
// Determine push notification support
|
|
318
|
+
// These browsers are known to NOT support Web Push:
|
|
319
|
+
// - Opera Mini: no service worker support
|
|
320
|
+
// - Internet Explorer: deprecated, no Push API
|
|
321
|
+
// - UC Browser: unreliable push support on many versions
|
|
322
|
+
// - Most In-App browsers (Facebook, Instagram, TikTok, etc.)
|
|
323
|
+
// - Generic WebViews (except Twitter/LinkedIn on Android)
|
|
324
|
+
//
|
|
325
|
+
// Note: Comet (Perplexity) is Chromium-based and DOES support push notifications.
|
|
326
|
+
// Note: Twitter and LinkedIn on Android use Chrome WebView and DO support push.
|
|
327
|
+
// However, we err on the side of caution and disable for all in-app browsers.
|
|
328
|
+
const browserBlocksPush = isOperaMini ||
|
|
329
|
+
isIE ||
|
|
330
|
+
isUCBrowser ||
|
|
331
|
+
isFacebookInApp ||
|
|
332
|
+
isInstagramInApp ||
|
|
333
|
+
isTikTokInApp ||
|
|
334
|
+
isSnapchatInApp ||
|
|
335
|
+
isWeChatInApp ||
|
|
336
|
+
isThreadsInApp ||
|
|
337
|
+
isPinterestInApp ||
|
|
338
|
+
isTelegramInApp ||
|
|
339
|
+
isLineInApp ||
|
|
340
|
+
isKakaoInApp ||
|
|
341
|
+
isWebView;
|
|
342
|
+
|
|
343
|
+
// Twitter and LinkedIn on Android use Chrome WebView - they actually support push
|
|
344
|
+
// But only on Android, not iOS
|
|
345
|
+
const twitterLinkedInAndroid = (isTwitterInApp || isLinkedInInApp) && !isIOSBrowser;
|
|
346
|
+
|
|
347
|
+
const supportsPushNotifications = !browserBlocksPush || twitterLinkedInAndroid;
|
|
161
348
|
|
|
162
349
|
return {
|
|
163
350
|
isChrome,
|
|
@@ -172,10 +359,25 @@ export function useBrowserDetect(): BrowserInfo {
|
|
|
172
359
|
isYandex,
|
|
173
360
|
isSamsungBrowser,
|
|
174
361
|
isUCBrowser,
|
|
362
|
+
isComet,
|
|
363
|
+
isOperaMini,
|
|
364
|
+
isIE,
|
|
365
|
+
isFacebookInApp,
|
|
366
|
+
isInstagramInApp,
|
|
367
|
+
isTikTokInApp,
|
|
368
|
+
isSnapchatInApp,
|
|
369
|
+
isWeChatInApp,
|
|
370
|
+
isThreadsInApp,
|
|
371
|
+
isLinkedInInApp,
|
|
372
|
+
isTwitterInApp,
|
|
373
|
+
isInAppBrowser,
|
|
374
|
+
isWebView,
|
|
175
375
|
browserName,
|
|
176
376
|
isWebKit,
|
|
177
377
|
isBlink,
|
|
178
378
|
isGecko,
|
|
379
|
+
supportsPushNotifications,
|
|
380
|
+
isIOSBrowser,
|
|
179
381
|
userAgent: window.navigator.userAgent,
|
|
180
382
|
};
|
|
181
383
|
}, []);
|