silverwolf-x's picture
download
raw
1.2 kB
import type { DevToolsConfig } from '../shared'
import { devToolsConfigSchema } from '../../shared/devtools-config-schema'
import { deepMerge } from '../../shared/deepmerge'
let queuedConfigPatch: DevToolsConfig = {}
let timer: ReturnType<typeof setTimeout> | null = null
function flushPatch() {
if (Object.keys(queuedConfigPatch).length === 0) {
return
}
const body = JSON.stringify(queuedConfigPatch)
queuedConfigPatch = {}
fetch('/__nextjs_devtools_config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
// keepalive in case of fetch interrupted, e.g. navigation or reload
keepalive: true,
}).catch((error) => {
console.warn('[Next.js DevTools] Failed to save config:', {
data: body,
error,
})
})
}
export function saveDevToolsConfig(patch: DevToolsConfig) {
const validation = devToolsConfigSchema.safeParse(patch)
if (!validation.success) {
console.warn(
'[Next.js DevTools] Invalid config patch:',
validation.error.message
)
return
}
queuedConfigPatch = deepMerge(queuedConfigPatch, patch)
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(flushPatch, 120)
}

Xet Storage Details

Size:
1.2 kB
·
Xet hash:
22d0a2241c0240762f5f3b0c3731577015f26e5dc9122c5fc172d6d90059e803

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.