mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 15:10:48 +02:00
f3f6a8a8e0
* [web] add clsi-cache prompts * [web] add new editor variant to segmentation * [web] add tests for useNewEditorVariant * [web] adjust start of using clsi-cache in split-test GitOrigin-RevId: c9c5b1eff2ceefb65ef82516d9074cb971cb4c48
39 lines
1.4 KiB
TypeScript
39 lines
1.4 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 projectOwnerHasPremiumOnPageLoad = getMeta(
|
|
'ol-projectOwnerHasPremiumOnPageLoad'
|
|
)
|
|
export const fallBackToClsiCache =
|
|
projectOwnerHasPremiumOnPageLoad &&
|
|
(isFlagEnabled('populate-clsi-cache') ||
|
|
isFlagEnabled('populate-clsi-cache-for-prompt'))
|