Skip to content

Commit 37b08c9

Browse files
authoredJun 27, 2024··
feat: add compatibility with txiki.js (#1895)
* feat: add compatibility with txiki.js txiki.js is compatible with most of the browser api, but it does not have the document variable. * style: run lint-fix * fix: navigator undefined
1 parent 0485ac7 commit 37b08c9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/lib/is-browser.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const isStandardBrowserEnv = () => {
2525
return false
2626
}
2727

28+
const isTxikijsEnv = () =>
29+
typeof navigator !== 'undefined' && navigator.userAgent === 'txiki.js'
30+
2831
const isWebWorkerEnv = () =>
2932
Boolean(
3033
// eslint-disable-next-line no-restricted-globals
@@ -37,7 +40,10 @@ const isReactNativeEnv = () =>
3740
typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
3841

3942
const isBrowser =
40-
isStandardBrowserEnv() || isWebWorkerEnv() || isReactNativeEnv()
43+
isStandardBrowserEnv() ||
44+
isWebWorkerEnv() ||
45+
isReactNativeEnv() ||
46+
isTxikijsEnv()
4147

4248
export const isWebWorker = isWebWorkerEnv()
4349

0 commit comments

Comments
 (0)
Please sign in to comment.