From c11f8c718d0bced2effcd73e9c32caa27409469c Mon Sep 17 00:00:00 2001 From: _Kerman Date: Thu, 23 Nov 2023 16:36:12 +0800 Subject: [PATCH] upd: add `window.__QUASI_PREVIEW__` in preview iframe --- packages/northstar/src/views/preview.r.ts | 2 +- packages/runtime/src/types/env.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 packages/runtime/src/types/env.ts diff --git a/packages/northstar/src/views/preview.r.ts b/packages/northstar/src/views/preview.r.ts index d7789b4..ea484cb 100644 --- a/packages/northstar/src/views/preview.r.ts +++ b/packages/northstar/src/views/preview.r.ts @@ -25,7 +25,7 @@ let errorMsg = ""; export async function startPreview() { const compiler = new Compiler(currentProject.toOutput()); compiler.runtimeModuleURL = runtimeURL; - code.js = transformer.transform("$", await compiler.compile()); + code.js = "window.__QUASI_PREVIEW__ = true; \n\n" + transformer.transform("$", await compiler.compile()); code.css = ( await compileTailwindCSS( `@tailwind base; diff --git a/packages/runtime/src/types/env.ts b/packages/runtime/src/types/env.ts new file mode 100644 index 0000000..5385489 --- /dev/null +++ b/packages/runtime/src/types/env.ts @@ -0,0 +1,6 @@ +declare global { + interface Window { + __QUASI_PREVIEW__: boolean; + } +} +export {};