From b6fbd0fd543c935cd58afe5bd2d1493a075d7e80 Mon Sep 17 00:00:00 2001 From: takejohn Date: Sun, 30 Nov 2025 23:46:10 +0900 Subject: [PATCH] =?UTF-8?q?falsy=E3=81=AA=E5=80=A4=E3=82=92=E3=82=82?= =?UTF-8?q?=E3=81=A4=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC=E3=82=BF=E3=81=8C?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vitepress/pages/Playground.vue | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.vitepress/pages/Playground.vue b/.vitepress/pages/Playground.vue index 6402fd5..0c28387 100644 --- a/.vitepress/pages/Playground.vue +++ b/.vitepress/pages/Playground.vue @@ -87,7 +87,7 @@

Syntax Error

See Output tab for details

-
+
No metadata
@@ -221,7 +221,14 @@ const errorLine = ref(null); const ast = ref(null); const astHtml = ref(''); -const metadata = ref(null); +type OptionalMetadata = { + exists: false; +} | { + exists: true; + value: unknown; +}; + +const metadata = ref({ exists: false }); const metadataHtml = ref(''); function parse() { @@ -235,7 +242,11 @@ function parse() { const [ast_, metadata_] = runner.value.parse(code.value); logs.value = []; ast.value = ast_; - metadata.value = metadata_?.get(null) ?? null; + if (metadata_?.has(null)) { + metadata.value = { exists: true, value: metadata_.get(null) }; + } else { + metadata.value = { exists: false }; + } } catch (err) { if (runner.value.isAiScriptError(err)) { logs.value = [{ @@ -252,7 +263,7 @@ function parse() { } } ast.value = null; - metadata.value = null; + metadata.value = { exists: false }; } } } @@ -423,12 +434,12 @@ onMounted(async () => { watch(metadata, async (newMetadata) => { if (highlighter) { - if (newMetadata == null) { + if (!newMetadata.exists) { metadataHtml.value = ''; return; } - metadataHtml.value = highlighter.codeToHtml(JSON.stringify(newMetadata, null, 2), { + metadataHtml.value = highlighter.codeToHtml(JSON.stringify(newMetadata.value, null, 2), { lang: 'json', themes: { light: 'github-light',