mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 13:49:00 +02:00
3586b37491
* [web] Remove clsi-cache-prompt/survey and split-tests * [web] Remove initial 50/50 clsi-cache split-test * [web] Remove synctex-downloaded-from-cache event * [web] Remove fallback-to-clsi-cache event * [saas-e2e] fix tests with clsi-cache enabled GitOrigin-RevId: b5cf2ab073dc866fe398b81fd5afe46422134c80
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import getMeta from '../../../utils/meta'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
|
const hasTextEncoder = typeof TextEncoder !== 'undefined'
|
|
if (!hasTextEncoder) {
|
|
debugConsole.warn('TextEncoder is not available. Disabling pdf-caching.')
|
|
}
|
|
|
|
const isOpera =
|
|
// userAgentData is experimental and not currently in the Navigator type
|
|
Array.isArray((navigator as any).userAgentData?.brands) &&
|
|
(navigator as any).userAgentData.brands.some(
|
|
(b: { brand: string }) => b.brand === 'Opera'
|
|
)
|
|
if (isOpera) {
|
|
debugConsole.warn('Browser cache is limited in Opera. Disabling pdf-caching.')
|
|
}
|
|
|
|
function isFlagEnabled(flag: string): boolean {
|
|
if (!hasTextEncoder) return false
|
|
if (isOpera) return false
|
|
return getMeta('ol-splitTestVariants')?.[flag] === 'enabled'
|
|
}
|
|
|
|
export const cachedUrlLookupEnabled = isFlagEnabled(
|
|
'pdf-caching-cached-url-lookup'
|
|
)
|
|
export const prefetchingEnabled = isFlagEnabled('pdf-caching-prefetching')
|
|
export const prefetchLargeEnabled = isFlagEnabled('pdf-caching-prefetch-large')
|
|
export const enablePdfCaching = isFlagEnabled('pdf-caching-mode')
|
|
export const trackPdfDownloadEnabled = isFlagEnabled('track-pdf-download')
|
|
export const canUseClsiCache = getMeta('ol-canUseClsiCache')
|