diff --git a/frontend/src/lib/components/DisplayResult.svelte b/frontend/src/lib/components/DisplayResult.svelte index 80f7ce999f..b365bbdd96 100644 --- a/frontend/src/lib/components/DisplayResult.svelte +++ b/frontend/src/lib/components/DisplayResult.svelte @@ -76,6 +76,7 @@ | 'pdf' | undefined + let hasBigInt = false $: resultKind = inferResultKind(result) export let forceJson = false @@ -168,6 +169,13 @@ largeObject = size > DISPLAY_MAX_SIZE } + if (!largeObject) { + hasBigInt = checkIfHasBigInt(result) + if (hasBigInt) { + return 'json' + } + } + if (Array.isArray(result)) { if (result.length === 0) { return 'json' @@ -263,6 +271,21 @@ } } + function checkIfHasBigInt(result: any) { + if (typeof result === 'number' && Number.isInteger(result) && !Number.isSafeInteger(result)) { + return true + } + + if (Array.isArray(result)) { + return result.some(checkIfHasBigInt) + } + + if (result && typeof result === 'object') { + return Object.values(result).some(checkIfHasBigInt) + } + return false + } + function contentOrRootString(obj: string | { filename: string; content: string } | undefined) { if (obj == undefined || obj == null) { return '' @@ -401,14 +424,17 @@ /> {/each} -{:else if resultKind === 'nondisplayable'}