Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
feat: Add syntax highlighting to Code Text (#6007)
Oleg Isonen6385e290c67f
diff --git a/apps/builder/app/builder/features/settings-panel/controls/code.test.ts b/apps/builder/app/builder/features/settings-panel/controls/code.test.tsnew file mode 100644index 0000000000..1342a8aa0b--- /dev/null+++ b/apps/builder/app/builder/features/settings-panel/controls/code.test.ts@@ -0,0 +1,11 @@+import { expect, test } from "vitest";+import { matchCodeTextEditorLanguage } from "./code";++test("matches the selected Code Text language with CodeMirror", () => {+ expect(matchCodeTextEditorLanguage("python")?.name).toBe("Python");+ expect(matchCodeTextEditorLanguage("bash")?.name).toBe("Shell");+});++test("falls back to plain text for unsupported Code Text languages", () => {+ expect(matchCodeTextEditorLanguage("astro")).toBeUndefined();+});diff --git a/apps/builder/app/builder/features/settings-panel/controls/code.tsx b/apps/builder/app/builder/features/settings-panel/controls/code.tsxindex 6d6298697a..336ba3b27e 100644--- a/apps/builder/app/builder/features/settings-panel/controls/code.tsx+++ b/apps/builder/app/builder/features/settings-panel/controls/code.tsx@@ -1,4 +1,9 @@-import { useState } from "react";+import { useEffect, useState } from "react";+import {+ LanguageDescription,+ type LanguageSupport,+} from "@codemirror/language";+import { languages } from "@codemirror/language-data";import {Button,DialogClose,@@ -50,6 +55,48 @@ export type CodeControlBehavior = {) => { success: true; value: string } | { success: false; message: string };};+export const matchCodeTextEditorLanguage = (selectedLanguage: unknown) => {+ if (typeof selectedLanguage !== "string") {+ return;+ }++ return (+ LanguageDescription.matchLanguageName(languages, selectedLanguage, false) ??+ undefined+ );+};++const useCodeTextLanguageSupport = (selectedLanguage: unknown) => {+ const [languageSupport, setLanguageSupport] = useState<LanguageSupport>();++ useEffect(() => {+ let canceled = false;+ setLanguageSupport(undefined);++ const description = matchCodeTextEditorLanguage(selectedLanguage);+ if (description === undefined) {+ return;+ }++ void description.load().then(+ (support) => {+ if (canceled === false) {+ setLanguageSupport(support);+ }+ },+ () => {+ // Keep the editor in plain-text mode when a language fails to load.+ }+ );++ return () => {+ canceled = true;+ };+ }, [selectedLanguage]);++ return languageSupport;+};+const ErrorInfo = ({error,onAutoFix,@@ -100,6 +147,7 @@ export const CodeControl = ({prop,propName,computedValue,+ computedProps,onChange,behavior,}: (ControlProps<"code"> | ControlProps<"codetext">) & {@@ -111,6 +159,9 @@ export const CodeControl = ({control: "text" as const,};const lang = meta.control === "code" ? meta.language : undefined;+ const codeTextLanguageSupport = useCodeTextLanguageSupport(+ meta.control === "codetext" ? computedProps?.get("language") : undefined+ );const label = humanizeAttribute(metaOverride.label || propName);const editorValue = behavior? behavior.formatValue(computedValue)@@ -129,7 +180,11 @@ export const CodeControl = ({storedValue = result.value;}- if (behavior === undefined && lang === "html") {+ if (+ behavior === undefined &&+ meta.control === "code" &&+ lang === "html"+ ) {const error = validateHtmlEmbedCode(value);setError(error);@@ -204,6 +259,7 @@ export const CodeControl = ({renderControl={({ readOnly }) => (<CodeEditorlang={lang}+ languageSupport={codeTextLanguageSupport}title={<DialogTitlemaximizablediff --git a/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsx b/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsxindex 1cfd21c7d9..f70c76c452 100644--- a/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsx+++ b/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsx@@ -146,6 +146,7 @@ const renderProperty = (instanceId: targetInstanceId,meta,prop,+ computedProps: targetPropValues,computedValue:targetPropValues.get(propName) ??// support legacy html props with react namesdiff --git a/apps/builder/app/builder/features/settings-panel/shared.tsx b/apps/builder/app/builder/features/settings-panel/shared.tsxindex 94c601a0b6..43beac8ca1 100644--- a/apps/builder/app/builder/features/settings-panel/shared.tsx+++ b/apps/builder/app/builder/features/settings-panel/shared.tsx@@ -76,6 +76,7 @@ export type ControlProps<Control> = {prop: Prop | undefined;propName: string;computedValue: unknown;+ computedProps?: ReadonlyMap<string, unknown>;onChange: (value: PropValue) => void;};diff --git a/apps/builder/app/builder/shared/expression-editor.tsx b/apps/builder/app/builder/shared/expression-editor.tsxindex 024f4bc5ac..03d539dc37 100644--- a/apps/builder/app/builder/shared/expression-editor.tsx+++ b/apps/builder/app/builder/shared/expression-editor.tsx@@ -9,6 +9,7 @@ import {WidgetType,ViewPlugin,keymap,+ lineNumbers,EditorView,tooltips,} from "@codemirror/view";@@ -40,6 +41,7 @@ import {EditorDialogButton,EditorDialogControl,type EditorApi,+ foldGutterExtension,getCodeEditorCssVars,normalizeEditorValue,} from "~/shared/code-editor-base";@@ -670,6 +672,10 @@ export const ExpressionEditor = ({],[scopeWithUnsetVariables, aliasesWithUnsetVariables, size]);+ const dialogExtensions = useMemo(+ () => [...extensions, lineNumbers(), foldGutterExtension],+ [extensions]+ );// prevent clicking on autocomplete options propagating to body// and closing dialogs and popovers@@ -689,6 +695,20 @@ export const ExpressionEditor = ({};}, []);+ const handleChange = (newValue: string) => {+ const expressionWithRestoredVariables = restoreExpressionVariables({+ expression: newValue,+ maskedIdByName: idByName,+ });+ onChange(expressionWithRestoredVariables);+ };+ const handleChangeComplete = (newValue: string) => {+ const expressionWithRestoredVariables = restoreExpressionVariables({+ expression: newValue,+ maskedIdByName: idByName,+ });+ onChangeComplete(expressionWithRestoredVariables);+ };const content = (<EditorContentaria-label={ariaLabel}@@ -699,20 +719,8 @@ export const ExpressionEditor = ({readOnly={readOnly}autoFocus={autoFocus}value={expressionWithUnsetVariables}- onChange={(newValue: string) => {- const expressionWithRestoredVariables = restoreExpressionVariables({- expression: newValue,- maskedIdByName: idByName,- });- onChange(expressionWithRestoredVariables);- }}- onChangeComplete={(newValue: string) => {- const expressionWithRestoredVariables = restoreExpressionVariables({- expression: newValue,- maskedIdByName: idByName,- });- onChangeComplete(expressionWithRestoredVariables);- }}+ onChange={handleChange}+ onChangeComplete={handleChangeComplete}/>);@@ -724,7 +732,24 @@ export const ExpressionEditor = ({<div className={wrapperStyle({ size })}><EditorDialogControl>{content}- <EditorDialog title="Expression Editor" content={content}>+ <EditorDialog+ title="Expression editor"+ contentPadding={false}+ content={+ <EditorContent+ aria-label={ariaLabel}+ editorApiRef={editorApiRef}+ extensions={dialogExtensions}+ invalid={color === "error"}+ chromeless+ readOnly={readOnly}+ autoFocus={autoFocus}+ value={expressionWithUnsetVariables}+ onChange={handleChange}+ onChangeComplete={handleChangeComplete}+ />+ }+ ><EditorDialogButton /></EditorDialog></EditorDialogControl>diff --git a/apps/builder/app/shared/code-editor.tsx b/apps/builder/app/shared/code-editor.tsxindex 38055848af..2f7aa06382 100644--- a/apps/builder/app/shared/code-editor.tsx+++ b/apps/builder/app/shared/code-editor.tsx@@ -9,6 +9,7 @@ import type { Extension } from "@codemirror/state";import { styleTags, tags } from "@lezer/highlight";import {keymap,+ lineNumbers,tooltips,highlightSpecialChars,highlightActiveLine,@@ -28,6 +29,7 @@ import {import { html } from "@codemirror/lang-html";import { javascript } from "@codemirror/lang-javascript";import { markdown } from "@codemirror/lang-markdown";+import { cssCompletionSource, cssLanguage } from "@codemirror/lang-css";import { css } from "@webstudio-is/design-system";import {EditorContent,@@ -37,7 +39,6 @@ import {foldGutterExtension,getCodeEditorCssVars,} from "~/shared/code-editor-base";-import { cssCompletionSource, cssLanguage } from "@codemirror/lang-css";const wrapperStyle = css({position: "relative",@@ -62,6 +63,12 @@ const wrapperStyle = css({const noLanguageExtensions: Extension[] = [];+export type CodeEditorLanguage =+ | "html"+ | "json"+ | "markdown"+ | "css-properties";+const getHtmlExtensions = () => [highlightActiveLine(),highlightSpecialChars(),@@ -136,10 +143,25 @@ const getCssPropertiesExtensions = () => [autocompletion({ icons: false }),];+const getDynamicLanguageExtensions = (languageSupport: Extension) => [+ highlightActiveLine(),+ highlightSpecialChars(),+ indentOnInput(),+ languageSupport,+ bracketMatching(),+ closeBrackets(),+ // render autocomplete in body+ // to prevent popover scroll overflow+ tooltips({ parent: document.body }),+ autocompletion({ icons: false }),+ keymap.of([...closeBracketsKeymap, ...completionKeymap]),+];+export const CodeEditor = forwardRef<HTMLDivElement,Omit<ComponentProps<typeof EditorContent>, "extensions"> & {- lang?: "html" | "json" | "markdown" | "css-properties";+ lang?: CodeEditorLanguage;+ languageSupport?: Extension;languageExtensions?: Extension[];title?: ReactNode;size?: "default" | "small" | "full";@@ -148,6 +170,7 @@ export const CodeEditor = forwardRef<>((props, ref) => {const {lang,+ languageSupport,languageExtensions = noLanguageExtensions,title,size,@@ -180,13 +203,25 @@ export const CodeEditor = forwardRef<return [];}, [lang]);+ const dynamicLanguageExtensions = useMemo(+ () =>+ languageSupport === undefined+ ? noLanguageExtensions+ : getDynamicLanguageExtensions(languageSupport),+ [languageSupport]+ );+const extensions = useMemo(- () => [...builtInExtensions, ...languageExtensions],- [builtInExtensions, languageExtensions]+ () => [+ ...builtInExtensions,+ ...dynamicLanguageExtensions,+ ...languageExtensions,+ ],+ [builtInExtensions, dynamicLanguageExtensions, languageExtensions]);const dialogExtensions = useMemo(- () => [...extensions, foldGutterExtension],+ () => [...extensions, lineNumbers(), foldGutterExtension],[extensions]);@@ -216,9 +251,11 @@ export const CodeEditor = forwardRef<<EditorContent {...editorContentProps} extensions={extensions} /><EditorDialogtitle={title}+ contentPadding={false}content={<EditorContent{...editorContentProps}+ chromelessextensions={dialogExtensions}/>}diff --git a/apps/builder/package.json b/apps/builder/package.jsonindex 13a3788ad6..6a61fe02f4 100644--- a/apps/builder/package.json+++ b/apps/builder/package.json@@ -32,6 +32,7 @@"@codemirror/lang-javascript": "^6.2.3","@codemirror/lang-markdown": "^6.3.2","@codemirror/language": "^6.11.0",+ "@codemirror/language-data": "^6.5.2","@codemirror/lint": "^6.8.5","@codemirror/state": "^6.5.2","@codemirror/view": "^6.36.4",diff --git a/docs/university/core-components/code-text.md b/docs/university/core-components/code-text.mdindex fe0e8c414f..bf0c9f9cb6 100644--- a/docs/university/core-components/code-text.md+++ b/docs/university/core-components/code-text.md@@ -1,31 +1,45 @@----description: Display inline code snippets with the Code Text component in Webstudio.+description: Display source code with language-aware syntax highlighting.----# 📄 Code Text Component+# Code Text-> See [MDN: \<code\>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code)+Use Code Text to display source code with syntax highlighting. It renders a+semantic `<code>` element and preserves the source text for copying and screen+readers.-The Code Text component displays inline code snippets with monospace formatting. It renders as a `<code>` HTML element, making it semantically correct for representing code, filenames, or technical terms.+## When to use-## When to Use+Use Code Text for code examples, commands, configuration, or other source text.+Use [Text](text.md) for prose that does not need syntax highlighting.-Use Code Text for:+## How to use-- Inline code references (variable names, function calls)-- Filenames and paths-- Keyboard shortcuts-- Technical terms-- Command examples+1. Open the **Components** panel.+2. Expand **Typography**.+3. Drag **Code Text** onto the canvas.+4. Enter the source in **Code** in the Settings panel, or edit it on the canvas.+5. Select the matching **Language**.+6. Select a **Theme**.-## How to Use+You can bind **Code**, **Language**, and **Theme** to variables or resource+values. A fixed Language or Theme includes only that selected asset in the+published build. A bound Language or Theme makes the available catalog part of+the server build so any runtime value can be rendered. The browser loads only+the language and theme selected at runtime.-1. Drag a **Code Text** component from Components > Text onto your canvas-2. Enter your code or technical text-3. Style to differentiate from regular text+The highlighted markup is rendered with SSR and SSG output, so it appears+consistently when the page first loads and after it becomes interactive.++## Styling++Apply typography, spacing, border, and background styles in the Style panel.+The selected theme supplies the syntax token colors and initial text and+background colors. A background set in the Style panel overrides the theme+background; select another theme to change the syntax colors.## Related-- [Text](text.md) – Inline text content-- [HTML Embed](html-embed.md) – Embed custom HTML/code-- [Paragraph](paragraph.md) – Block-level text+- [Text](text.md)+- [HTML Embed](html-embed.md)+- [Paragraph](paragraph.md)diff --git a/fixtures/react-router-cloudflare/package.json b/fixtures/react-router-cloudflare/package.jsonindex 81f3714831..738bd07415 100644--- a/fixtures/react-router-cloudflare/package.json+++ b/fixtures/react-router-cloudflare/package.json@@ -34,7 +34,10 @@"wrangler": "^4.14.1","@webstudio-is/wsauth": "workspace:*","@react-router/node": "^7.5.3",- "@react-router/serve": "^7.5.3"+ "@react-router/serve": "^7.5.3",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"},"type": "module","private": true,diff --git a/fixtures/react-router-docker/package.json b/fixtures/react-router-docker/package.jsonindex 2ebb1dc003..1f87653b9c 100644--- a/fixtures/react-router-docker/package.json+++ b/fixtures/react-router-docker/package.json@@ -30,7 +30,10 @@"react-router": "^7.5.3","vite": "^6.3.4","webstudio": "workspace:*",- "@webstudio-is/wsauth": "workspace:*"+ "@webstudio-is/wsauth": "workspace:*",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"},"private": true,"sideEffects": false,diff --git a/fixtures/react-router-netlify/package.json b/fixtures/react-router-netlify/package.jsonindex ec470c398f..f66d2bac1b 100644--- a/fixtures/react-router-netlify/package.json+++ b/fixtures/react-router-netlify/package.json@@ -31,7 +31,10 @@"vite": "^6.3.4","webstudio": "workspace:*","@webstudio-is/wsauth": "workspace:*",- "@react-router/serve": "^7.5.3"+ "@react-router/serve": "^7.5.3",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"},"type": "module","private": true,diff --git a/fixtures/react-router-vercel/package.json b/fixtures/react-router-vercel/package.jsonindex 3a3b6cade0..0424576fba 100644--- a/fixtures/react-router-vercel/package.json+++ b/fixtures/react-router-vercel/package.json@@ -31,7 +31,10 @@"vite": "^6.3.4","webstudio": "workspace:*","@webstudio-is/wsauth": "workspace:*",- "@react-router/serve": "^7.5.3"+ "@react-router/serve": "^7.5.3",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"},"private": true,"type": "module",diff --git a/fixtures/ssg-cloudflare-pages/package.json b/fixtures/ssg-cloudflare-pages/package.jsonindex b87cb403bf..64b95c76ed 100644--- a/fixtures/ssg-cloudflare-pages/package.json+++ b/fixtures/ssg-cloudflare-pages/package.json@@ -42,6 +42,9 @@"react": "18.3.0-canary-14898b6a9-20240318","react-dom": "18.3.0-canary-14898b6a9-20240318","vike": "^0.4.229",- "@webstudio-is/wsauth": "workspace:*"+ "@webstudio-is/wsauth": "workspace:*",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"}}diff --git a/fixtures/ssg-cloudflare-pages/react-dom-server-browser.d.ts b/fixtures/ssg-cloudflare-pages/react-dom-server-browser.d.tsnew file mode 100644index 0000000000..cfbd5c9302--- /dev/null+++ b/fixtures/ssg-cloudflare-pages/react-dom-server-browser.d.ts@@ -0,0 +1,3 @@+declare module "react-dom/server.browser" {+ export { renderToReadableStream } from "react-dom/server";+}diff --git a/fixtures/ssg-cloudflare-pages/renderer/+onRenderHtml.tsx b/fixtures/ssg-cloudflare-pages/renderer/+onRenderHtml.tsxindex f7a96c9728..e311fea71c 100644--- a/fixtures/ssg-cloudflare-pages/renderer/+onRenderHtml.tsx+++ b/fixtures/ssg-cloudflare-pages/renderer/+onRenderHtml.tsx@@ -1,6 +1,6 @@-import { renderToString } from "react-dom/server";+import { renderToReadableStream } from "react-dom/server.browser";import { dangerouslySkipEscape, escapeInject } from "vike/server";-import type { OnRenderHtmlSync } from "vike/types";+import type { OnRenderHtmlAsync } from "vike/types";import {CustomCode,projectId,@@ -11,29 +11,27 @@ import {// @ts-ignore} from "../app/__generated__/_index";-export const onRenderHtml: OnRenderHtmlSync = (pageContext) => {+export const onRenderHtml: OnRenderHtmlAsync = async (pageContext) => {const lang = pageContext.data.pageMeta.language || "en";const Head = pageContext.config.Head ?? (() => <></>);const Page = pageContext.Page ?? (() => <></>);- const html = dangerouslySkipEscape(- renderToString(- <html- lang={lang}- data-ws-project={projectId}- data-ws-version={projectVersion}- data-ws-last-published={lastPublished}- >- <head>- <meta charSet="UTF-8" />- <meta name="viewport" content="width=device-width,initial-scale=1" />- <Head data={pageContext.data} />- <CustomCode />- </head>- <Page data={pageContext.data} />- </html>- )+ const stream = await renderToReadableStream(+ <html+ lang={lang}+ data-ws-project={projectId}+ data-ws-version={projectVersion}+ data-ws-last-published={lastPublished}+ >+ <head>+ <meta charSet="UTF-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <Head data={pageContext.data} />+ <CustomCode />+ </head>+ <Page data={pageContext.data} />+ </html>);- return escapeInject`<!DOCTYPE html>-${html}-`;+ await stream.allReady;+ const html = dangerouslySkipEscape(await new Response(stream).text());+ return escapeInject`${html}`;};diff --git a/fixtures/ssg-netlify-by-project-id/package.json b/fixtures/ssg-netlify-by-project-id/package.jsonindex ea76cd0ba8..f97cc78406 100644--- a/fixtures/ssg-netlify-by-project-id/package.json+++ b/fixtures/ssg-netlify-by-project-id/package.json@@ -42,6 +42,9 @@"react": "18.3.0-canary-14898b6a9-20240318","react-dom": "18.3.0-canary-14898b6a9-20240318","vike": "^0.4.229",- "@webstudio-is/wsauth": "workspace:*"+ "@webstudio-is/wsauth": "workspace:*",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"}}diff --git a/fixtures/ssg-netlify-by-project-id/react-dom-server-browser.d.ts b/fixtures/ssg-netlify-by-project-id/react-dom-server-browser.d.tsnew file mode 100644index 0000000000..cfbd5c9302--- /dev/null+++ b/fixtures/ssg-netlify-by-project-id/react-dom-server-browser.d.ts@@ -0,0 +1,3 @@+declare module "react-dom/server.browser" {+ export { renderToReadableStream } from "react-dom/server";+}diff --git a/fixtures/ssg-netlify-by-project-id/renderer/+onRenderHtml.tsx b/fixtures/ssg-netlify-by-project-id/renderer/+onRenderHtml.tsxindex f7a96c9728..e311fea71c 100644--- a/fixtures/ssg-netlify-by-project-id/renderer/+onRenderHtml.tsx+++ b/fixtures/ssg-netlify-by-project-id/renderer/+onRenderHtml.tsx@@ -1,6 +1,6 @@-import { renderToString } from "react-dom/server";+import { renderToReadableStream } from "react-dom/server.browser";import { dangerouslySkipEscape, escapeInject } from "vike/server";-import type { OnRenderHtmlSync } from "vike/types";+import type { OnRenderHtmlAsync } from "vike/types";import {CustomCode,projectId,@@ -11,29 +11,27 @@ import {// @ts-ignore} from "../app/__generated__/_index";-export const onRenderHtml: OnRenderHtmlSync = (pageContext) => {+export const onRenderHtml: OnRenderHtmlAsync = async (pageContext) => {const lang = pageContext.data.pageMeta.language || "en";const Head = pageContext.config.Head ?? (() => <></>);const Page = pageContext.Page ?? (() => <></>);- const html = dangerouslySkipEscape(- renderToString(- <html- lang={lang}- data-ws-project={projectId}- data-ws-version={projectVersion}- data-ws-last-published={lastPublished}- >- <head>- <meta charSet="UTF-8" />- <meta name="viewport" content="width=device-width,initial-scale=1" />- <Head data={pageContext.data} />- <CustomCode />- </head>- <Page data={pageContext.data} />- </html>- )+ const stream = await renderToReadableStream(+ <html+ lang={lang}+ data-ws-project={projectId}+ data-ws-version={projectVersion}+ data-ws-last-published={lastPublished}+ >+ <head>+ <meta charSet="UTF-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <Head data={pageContext.data} />+ <CustomCode />+ </head>+ <Page data={pageContext.data} />+ </html>);- return escapeInject`<!DOCTYPE html>-${html}-`;+ await stream.allReady;+ const html = dangerouslySkipEscape(await new Response(stream).text());+ return escapeInject`${html}`;};diff --git a/fixtures/webstudio-cloudflare-template/package.json b/fixtures/webstudio-cloudflare-template/package.jsonindex f8a39ec1ca..8ed3b805aa 100644--- a/fixtures/webstudio-cloudflare-template/package.json+++ b/fixtures/webstudio-cloudflare-template/package.json@@ -46,7 +46,10 @@"react-dom": "18.3.0-canary-14898b6a9-20240318","webstudio": "workspace:*","worktop": "0.8.0-next.18",- "zod": "^4.4.3"+ "zod": "^4.4.3",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"},"devDependencies": {"@cloudflare/workers-types": "^4.20240620.0",diff --git a/fixtures/webstudio-features/package.json b/fixtures/webstudio-features/package.jsonindex e9a01b8d78..d3efaf383a 100644--- a/fixtures/webstudio-features/package.json+++ b/fixtures/webstudio-features/package.json@@ -32,7 +32,10 @@"vite": "^6.3.4","webstudio": "workspace:*","@webstudio-is/wsauth": "workspace:*",- "@react-router/serve": "^7.5.3"+ "@react-router/serve": "^7.5.3",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ "shiki": "4.4.1"},"devDependencies": {"@types/react": "^18.2.70",diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex f77dc3ac63..28f8ff364b 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -74,6 +74,8 @@"@remix-run/node": "^2.16.5","@remix-run/react": "^2.16.5","@remix-run/server-runtime": "^2.16.5",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1","@types/mdast": "^4.0.4","@types/react": "^18.2.70","@types/react-dom": "^18.2.25",@@ -108,6 +110,7 @@"react": "18.3.0-canary-14898b6a9-20240318","react-dom": "18.3.0-canary-14898b6a9-20240318","react-router": "^7.5.3",+ "shiki": "4.4.1","ts-expect": "^1.3.0","typescript": "7.0.2","vike": "^0.4.229",diff --git a/packages/cli/src/framework-react-router.ts b/packages/cli/src/framework-react-router.tsindex e00a04486f..69014dbb96 100644--- a/packages/cli/src/framework-react-router.ts+++ b/packages/cli/src/framework-react-router.ts@@ -36,7 +36,7 @@ export const createFramework = async (await cleanupFrameworkTemplates(options);const reactRouter = "@webstudio-is/sdk-components-react-router";- const { components, metas } = createFrameworkComponentRegistry({+ const { components, metas, buildHooks } = createFrameworkComponentRegistry({routerComponents: reactRouterComponents,routerComponentPackage: reactRouter,});@@ -44,6 +44,7 @@ export const createFramework = async (return {metas,components,+ componentBuildHooks: buildHooks,tags: {textarea: `${baseComponentImportSource}:Textarea`,input: `${baseComponentImportSource}:Input`,diff --git a/packages/cli/src/framework-remix.ts b/packages/cli/src/framework-remix.tsindex 5eaca7b20d..8edb28229c 100644--- a/packages/cli/src/framework-remix.ts+++ b/packages/cli/src/framework-remix.ts@@ -36,7 +36,7 @@ export const createFramework = async (await cleanupFrameworkTemplates(options);const remix = "@webstudio-is/sdk-components-react-remix";- const { components, metas } = createFrameworkComponentRegistry({+ const { components, metas, buildHooks } = createFrameworkComponentRegistry({routerComponents: remixComponents,routerComponentPackage: remix,});@@ -44,6 +44,7 @@ export const createFramework = async (return {metas,components,+ componentBuildHooks: buildHooks,tags: {textarea: `${baseComponentImportSource}:Textarea`,input: `${baseComponentImportSource}:Input`,diff --git a/packages/cli/src/framework-vike-ssg.ts b/packages/cli/src/framework-vike-ssg.tsindex 87afcc8c85..7c5af19db7 100644--- a/packages/cli/src/framework-vike-ssg.ts+++ b/packages/cli/src/framework-vike-ssg.ts@@ -47,11 +47,12 @@ export const createFramework = async (// cleanup route templates after reading to not bloat generated codeawait cleanupFrameworkTemplates(options);- const { components, metas } = createFrameworkComponentRegistry();+ const { components, metas, buildHooks } = createFrameworkComponentRegistry();return {metas,components,+ componentBuildHooks: buildHooks,tags: {textarea: `${baseComponentImportSource}:Textarea`,input: `${baseComponentImportSource}:Input`,diff --git a/packages/cli/src/framework.ts b/packages/cli/src/framework.tsindex 281439dabb..c7c8be2e48 100644--- a/packages/cli/src/framework.ts+++ b/packages/cli/src/framework.ts@@ -1,6 +1,6 @@import { rm } from "node:fs/promises";import { join } from "node:path";-import type { WsComponentMeta } from "@webstudio-is/sdk";+import type { ComponentBuildHook, WsComponentMeta } from "@webstudio-is/sdk";export type FrameworkOptions = { preserveTemplates?: boolean };export const routeTemplatesDirectory = join("app", "route-templates");@@ -23,6 +23,7 @@ export type Framework = {metas: Record<string, WsComponentMeta>;// instance.component: "importSource:importSpecifier"components: Record<string, string>;+ componentBuildHooks: ComponentBuildHook[];// instance.tag: "importSource:importSpecifier"tags: Record<string, string>;html: (params: {diff --git a/packages/cli/src/prebuild.test.ts b/packages/cli/src/prebuild.test.tsindex b39c6c732a..e3f2250791 100644--- a/packages/cli/src/prebuild.test.ts+++ b/packages/cli/src/prebuild.test.ts@@ -15,8 +15,14 @@ import { pathToFileURL } from "node:url";import { tmpdir } from "node:os";import { execFile } from "node:child_process";import { promisify } from "node:util";+import {+ defaultTreeAdapter,+ parse as parseHtml,+ type DefaultTreeAdapterMap,+} from "parse5";+import { build } from "esbuild";import { bundleVersion } from "@webstudio-is/protocol";-import type { Asset } from "@webstudio-is/sdk";+import type { Asset, Instance, Prop } from "@webstudio-is/sdk";import {createDocumentGraph,type AssetFileDocument,@@ -124,6 +130,45 @@ const getFilePaths = async (dir: string): Promise<string[]> => {return paths.flat();};+const getImportSources = async (source: string) => {+ const result = await build({+ stdin: { contents: source, loader: "tsx" },+ bundle: false,+ format: "esm",+ metafile: true,+ write: false,+ });+ return Object.values(result.metafile.outputs).flatMap((output) =>+ output.imports.map(({ path }) => path)+ );+};++const findElementsByTagName = (+ node: DefaultTreeAdapterMap["node"],+ tagName: string+): DefaultTreeAdapterMap["element"][] => {+ const elements: DefaultTreeAdapterMap["element"][] = [];+ if (defaultTreeAdapter.isElementNode(node) && node.tagName === tagName) {+ elements.push(node);+ }+ if ("childNodes" in node) {+ for (const child of node.childNodes) {+ elements.push(...findElementsByTagName(child, tagName));+ }+ }+ return elements;+};++const getTextContent = (node: DefaultTreeAdapterMap["node"]): string => {+ if (defaultTreeAdapter.isTextNode(node)) {+ return node.value;+ }+ if ("childNodes" in node) {+ return node.childNodes.map(getTextContent).join("");+ }+ return "";+};+const createSiteData = (overrides: {assets?: Asset[];@@ -136,18 +181,8 @@ const createSiteData = (meta: Record<string, unknown>;isDraft?: boolean;}>;- instances?: Array<- [- string,- {- type?: "instance";- id: string;- component: string;- tag?: string;- children: Array<{ type: "id"; value: string }>;- },- ]- >;+ instances?: Array<[string, Omit<Instance, "type">]>;+ props?: Array<[string, Prop]>;pageMeta?: Record<string, unknown>;redirects?: Redirects;} = {}@@ -227,7 +262,7 @@ const createSiteData = (},],},- props: [],+ props: overrides.props ?? [],instances: (overrides.instances ?? [[@@ -250,6 +285,62 @@ const createSiteData = (};};+const createCodeTextSiteData = (+ selections: Array<{+ id: string;+ code?: string;+ language?: string | { type: "expression"; value: string };+ theme?: string | { type: "expression"; value: string };+ lang?: string;+ children?: Instance["children"];+ }>+) => {+ const instances: Array<[string, Omit<Instance, "type">]> = [+ [+ "root",+ {+ id: "root",+ component: "Box",+ children: selections.map(({ id }) => ({ type: "id", value: id })),+ },+ ],+ ];+ const props: Array<[string, Prop]> = [];+ for (const selection of selections) {+ instances.push([+ selection.id,+ {+ id: selection.id,+ component: "CodeText",+ children: selection.children ?? [],+ },+ ]);+ for (const [name, value] of [+ ["code", selection.code],+ ["language", selection.language],+ ["theme", selection.theme],+ ["lang", selection.lang],+ ] as const) {+ if (value === undefined) {+ continue;+ }+ const id = `${selection.id}-${name}`;+ props.push([+ id,+ {+ id,+ instanceId: selection.id,+ name,+ ...(typeof value === "string"+ ? { type: "string" as const, value }+ : value),+ },+ ]);+ }+ }+ return createSiteData({ instances, props });+};+const writeSiteData = async (siteData: ReturnType<typeof createSiteData> = createSiteData()) => {@@ -636,6 +727,216 @@ test("hydrates encoded filenames from an embedded SSG database", async () => {});describe("prebuild", () => {+ test("imports only configured Code Text language and theme assets", async () => {+ await writeSiteData(+ createCodeTextSiteData([+ {+ id: "code-1",+ code: "const answer = 42;",+ language: "javascript",+ theme: "github-light",+ },+ {+ id: "code-2",+ code: "const answer = 42;",+ language: "javascript",+ theme: "nord",+ },+ ])+ );++ await prebuild({ assets: false, template: ["react-router"] });++ const generatedPage = await readFile(+ "app/__generated__/_index.tsx",+ "utf8"+ );+ const importSources = await getImportSources(generatedPage);+ expect(+ importSources.filter((source) => source === "@shikijs/langs/javascript")+ ).toHaveLength(1);+ expect(importSources).toEqual(+ expect.arrayContaining([+ "@shikijs/themes/github-light",+ "@shikijs/themes/nord",+ "@webstudio-is/sdk-components-react/code-text",+ ])+ );+ expect(importSources).not.toContain("@shikijs/langs/css");+ expect(importSources).not.toContain("@shikijs/themes/dracula");+ });++ test("generates lazy loaders for bound selections", async () => {+ await writeSiteData(+ createCodeTextSiteData([+ {+ id: "code-1",+ code: "const answer = 42;",+ language: { type: "expression", value: '"javascript"' },+ theme: { type: "expression", value: '"github-light"' },+ },+ ])+ );++ await prebuild({ assets: false, template: ["react-router"] });++ const generatedPage = await readFile(+ "app/__generated__/_index.tsx",+ "utf8"+ );+ const importSources = await getImportSources(generatedPage);+ expect(importSources).toEqual(+ expect.arrayContaining(["shiki/langs", "shiki/themes"])+ );+ expect(importSources).not.toContain("@shikijs/langs/javascript");+ expect(importSources).not.toContain("@shikijs/themes/github-light");+ expect(generatedPage).not.toContain("import.meta.env.SSR");+ expect(generatedPage).not.toContain("await Promise.all");+ expect(generatedPage).toContain("suspense: true");+ expect(generatedPage).toContain("loader?.().then");+ });++ test("prerenders configured and legacy Code Text in SSG output", async () => {+ await writeSiteData(+ createCodeTextSiteData([+ {+ id: "code-highlighted",+ code: "const answer = 42;",+ language: "javascript",+ theme: "github-light",+ },+ {+ id: "code-plaintext",+ code: "plain <value>",+ language: "plaintext",+ theme: "nord",+ },+ {+ id: "code-legacy",+ lang: "en",+ children: [{ type: "text", value: "legacy <code>" }],+ },+ ])+ );++ await prebuild({ assets: false, template: ["ssg"] });++ const generatedPage = await readFile(+ "app/__generated__/_index.tsx",+ "utf8"+ );+ const importSources = await getImportSources(generatedPage);+ expect(importSources).toEqual(+ expect.arrayContaining([+ "@shikijs/langs/javascript",+ "@shikijs/themes/github-light",+ "@shikijs/themes/nord",+ ])+ );+ expect(importSources).not.toContain("@shikijs/langs/plaintext");+ expect(importSources).not.toContain("@shikijs/langs/css");+ expect(importSources).not.toContain("@shikijs/themes/dracula");+ expect(+ JSON.parse(await readFile("package.json", "utf8")).dependencies+ ).toMatchObject({+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1",+ shiki: "4.4.1",+ });++ await symlink(join(originalCwd, "node_modules"), "node_modules", "dir");+ await runGeneratedCommand("vite", ["build"]);+ await runGeneratedCommand("vike", ["prerender"]);++ const html = parseHtml(await readFile("dist/client/index.html", "utf8"));+ const codeElements = findElementsByTagName(html, "code");+ const [highlightedCode, plaintextCode, legacyCode] = codeElements;+ if (+ highlightedCode === undefined ||+ plaintextCode === undefined ||+ legacyCode === undefined+ ) {+ throw new Error("Expected three prerendered Code Text elements");+ }+ expect(+ Object.fromEntries(+ highlightedCode.attrs.map(({ name, value }) => [name, value])+ )+ ).toMatchObject({+ class: "w-code-text",+ });+ expect(+ Object.fromEntries(+ highlightedCode.attrs.map(({ name, value }) => [name, value])+ )+ ).not.toHaveProperty("tabindex");+ expect(+ findElementsByTagName(highlightedCode, "span").length+ ).toBeGreaterThan(0);+ expect(getTextContent(highlightedCode)).toBe("const answer = 42;");++ expect(+ Object.fromEntries(+ plaintextCode.attrs.map(({ name, value }) => [name, value])+ )+ ).toMatchObject({+ class: "w-code-text",+ style: expect.stringContaining(+ "--w-code-text-theme-background:#2e3440ff"+ ),+ });+ expect(getTextContent(plaintextCode)).toBe("plain <value>");++ expect(+ Object.fromEntries(+ legacyCode.attrs.map(({ name, value }) => [name, value])+ )+ ).toMatchObject({ class: "w-code-text", lang: "en" });+ expect(findElementsByTagName(legacyCode, "span")).toHaveLength(0);+ expect(getTextContent(legacyCode)).toBe("legacy <code>");+ }, 30_000);++ test("prerenders bound Code Text while keeping catalog chunks lazy", async () => {+ await writeSiteData(+ createCodeTextSiteData([+ {+ id: "code-bound",+ code: "const answer = 42;",+ language: { type: "expression", value: '"javascript"' },+ theme: { type: "expression", value: '"github-light"' },+ },+ ])+ );++ await prebuild({ assets: false, template: ["ssg"] });+ await symlink(join(originalCwd, "node_modules"), "node_modules", "dir");+ await runGeneratedCommand("vite", ["build"]);+ await runGeneratedCommand("vike", ["prerender"]);++ const htmlSource = await readFile("dist/client/index.html", "utf8");+ expect(htmlSource).toMatch(/^<!DOCTYPE html><html/);+ const html = parseHtml(htmlSource);+ const [codeElement] = findElementsByTagName(html, "code");+ if (codeElement === undefined) {+ throw new Error("Expected a prerendered Code Text element");+ }+ expect(findElementsByTagName(codeElement, "span").length).toBeGreaterThan(+ 0+ );+ expect(getTextContent(codeElement)).toBe("const answer = 42;");++ const clientPaths = await getFilePaths("dist/client");+ const catalogChunks = clientPaths.filter(+ (path) => path.includes("/chunks/") && path.endsWith(".js")+ );+ expect(catalogChunks.length).toBeGreaterThan(100);+ const referencedChunks = catalogChunks.filter((chunk) => {+ const filename = chunk.split("/").at(-1);+ return filename !== undefined && htmlSource.includes(filename);+ });+ expect(referencedChunks).toHaveLength(1);+ }, 60_000);+test("emits the identity marker only for local previews", async () => {await prebuild({assets: false,diff --git a/packages/cli/src/prebuild.ts b/packages/cli/src/prebuild.tsindex ee93d814c0..ad2b3f9521 100644--- a/packages/cli/src/prebuild.ts+++ b/packages/cli/src/prebuild.ts@@ -54,6 +54,7 @@ import {type Resource,type WsComponentMeta,type Pages,+ type ComponentBuildContribution,} from "@webstudio-is/sdk";import { migratePages } from "@webstudio-is/project-migrations/pages";import { collectFontFamiliesFromStyleDecls } from "@webstudio-is/project-build/runtime";@@ -1126,10 +1127,30 @@ export const prebuild = async (options: {}}+ const props = new Map(pageData.build.props);+ const componentBuildContributions = new Map<+ string,+ ComponentBuildContribution+ >();+ for (const hook of framework.componentBuildHooks) {+ const contribution = await hook.build({+ instances,+ props,+ meta: framework.metas[hook.component],+ scope,+ });+ if (contribution !== undefined) {+ componentBuildContributions.set(hook.component, contribution);+ }+ }+// generate component imports// Map<importSource, Map<id, importSpecifier>>const imports = new Map<string, Map<string, string>>();for (const instance of instances.values()) {+ if (componentBuildContributions.has(instance.component)) {+ continue;+ }let descriptor = framework.components[instance.component];let id = instance.component;if (instance.component === elementComponent && instance.tag) {@@ -1158,10 +1179,22 @@ export const prebuild = async (options: {importsString += `import { ${specifiersString} } from "${importSource}";\n`;}+ const componentBuildDeclarations: string[] = [];+ for (const contribution of componentBuildContributions.values()) {+ for (const buildImport of contribution.imports) {+ if (buildImport.imported === undefined) {+ importsString += `import ${buildImport.local} from ${JSON.stringify(buildImport.source)};\n`;+ } else {+ importsString += `import { ${buildImport.imported} as ${buildImport.local} } from ${JSON.stringify(buildImport.source)};\n`;+ }+ }+ componentBuildDeclarations.push(...contribution.declarations);+ }+ const componentBuildSetupString = componentBuildDeclarations.join("\n");+const pageFontAssets = fontAssetsByPage[page.id];const pageBackgroundImageAssets = backgroundImageAssetsByPage[page.id];- const props = new Map(pageData.build.props);const dataSources = new Map(pageData.build.dataSources);const resources = new Map(pageData.build.resources);replaceFormActionsWithResources({@@ -1219,7 +1252,7 @@ export const prebuild = async (options: {import { Fragment, useState } from "react";import { renderText, useResource, useVariableState } from "@webstudio-is/react-sdk/runtime";- ${importsString}+ ${importsString}${componentBuildSetupString}export const projectId = "${siteData.build.projectId}";diff --git a/packages/cli/templates/defaults/package.json b/packages/cli/templates/defaults/package.jsonindex aebac80a8c..439f5553de 100644--- a/packages/cli/templates/defaults/package.json+++ b/packages/cli/templates/defaults/package.json@@ -8,6 +8,8 @@"typecheck": "tsc --noEmit"},"dependencies": {+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1","@remix-run/node": "2.16.5","@remix-run/react": "2.16.5","@remix-run/server-runtime": "2.16.5",@@ -21,7 +23,8 @@"@webstudio-is/wsauth": "0.0.0-webstudio-version","isbot": "^5.1.25","react": "18.3.0-canary-14898b6a9-20240318",- "react-dom": "18.3.0-canary-14898b6a9-20240318"+ "react-dom": "18.3.0-canary-14898b6a9-20240318",+ "shiki": "4.4.1"},"devDependencies": {"@remix-run/dev": "2.16.5",diff --git a/packages/cli/templates/internal/package.json b/packages/cli/templates/internal/package.jsonindex 0647aeb838..46ee1a9907 100644--- a/packages/cli/templates/internal/package.json+++ b/packages/cli/templates/internal/package.json@@ -1,5 +1,7 @@{"dependencies": {+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1","@webstudio-is/image": "workspace:*","@webstudio-is/react-sdk": "workspace:*","@webstudio-is/sdk": "workspace:*",@@ -7,6 +9,7 @@"@webstudio-is/sdk-components-react": "workspace:*","@webstudio-is/sdk-components-react-radix": "workspace:*","@webstudio-is/sdk-components-react-remix": "workspace:*",- "@webstudio-is/wsauth": "workspace:*"+ "@webstudio-is/wsauth": "workspace:*",+ "shiki": "4.4.1"}}diff --git a/packages/cli/templates/react-router/package.json b/packages/cli/templates/react-router/package.jsonindex 7a5a97d0ce..38ba1538c9 100644--- a/packages/cli/templates/react-router/package.json+++ b/packages/cli/templates/react-router/package.json@@ -9,6 +9,8 @@"typecheck": "tsc --noEmit"},"dependencies": {+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1","@react-router/dev": "^7.5.3","@react-router/fs-routes": "^7.5.3","@react-router/node": "^7.5.3",@@ -25,6 +27,7 @@"react": "18.3.0-canary-14898b6a9-20240318","react-dom": "18.3.0-canary-14898b6a9-20240318","react-router": "^7.5.3",+ "shiki": "4.4.1","vite": "^6.3.4"},"devDependencies": {diff --git a/packages/cli/templates/ssg/package.json b/packages/cli/templates/ssg/package.jsonindex 87a4f46d5b..88f2717987 100644--- a/packages/cli/templates/ssg/package.json+++ b/packages/cli/templates/ssg/package.json@@ -9,6 +9,8 @@"typecheck": "tsc --noEmit"},"dependencies": {+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1","@webstudio-is/image": "0.0.0-webstudio-version","@webstudio-is/react-sdk": "0.0.0-webstudio-version","@webstudio-is/sdk": "0.0.0-webstudio-version",@@ -17,6 +19,7 @@"@webstudio-is/sdk-components-react-radix": "0.0.0-webstudio-version","react": "18.3.0-canary-14898b6a9-20240318","react-dom": "18.3.0-canary-14898b6a9-20240318",+ "shiki": "4.4.1","vike": "^0.4.229"},"devDependencies": {diff --git a/packages/cli/templates/ssg/react-dom-server-browser.d.ts b/packages/cli/templates/ssg/react-dom-server-browser.d.tsnew file mode 100644index 0000000000..cfbd5c9302--- /dev/null+++ b/packages/cli/templates/ssg/react-dom-server-browser.d.ts@@ -0,0 +1,3 @@+declare module "react-dom/server.browser" {+ export { renderToReadableStream } from "react-dom/server";+}diff --git a/packages/cli/templates/ssg/renderer/+onRenderHtml.tsx b/packages/cli/templates/ssg/renderer/+onRenderHtml.tsxindex f7a96c9728..e311fea71c 100644--- a/packages/cli/templates/ssg/renderer/+onRenderHtml.tsx+++ b/packages/cli/templates/ssg/renderer/+onRenderHtml.tsx@@ -1,6 +1,6 @@-import { renderToString } from "react-dom/server";+import { renderToReadableStream } from "react-dom/server.browser";import { dangerouslySkipEscape, escapeInject } from "vike/server";-import type { OnRenderHtmlSync } from "vike/types";+import type { OnRenderHtmlAsync } from "vike/types";import {CustomCode,projectId,@@ -11,29 +11,27 @@ import {// @ts-ignore} from "../app/__generated__/_index";-export const onRenderHtml: OnRenderHtmlSync = (pageContext) => {+export const onRenderHtml: OnRenderHtmlAsync = async (pageContext) => {const lang = pageContext.data.pageMeta.language || "en";const Head = pageContext.config.Head ?? (() => <></>);const Page = pageContext.Page ?? (() => <></>);- const html = dangerouslySkipEscape(- renderToString(- <html- lang={lang}- data-ws-project={projectId}- data-ws-version={projectVersion}- data-ws-last-published={lastPublished}- >- <head>- <meta charSet="UTF-8" />- <meta name="viewport" content="width=device-width,initial-scale=1" />- <Head data={pageContext.data} />- <CustomCode />- </head>- <Page data={pageContext.data} />- </html>- )+ const stream = await renderToReadableStream(+ <html+ lang={lang}+ data-ws-project={projectId}+ data-ws-version={projectVersion}+ data-ws-last-published={lastPublished}+ >+ <head>+ <meta charSet="UTF-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <Head data={pageContext.data} />+ <CustomCode />+ </head>+ <Page data={pageContext.data} />+ </html>);- return escapeInject`<!DOCTYPE html>-${html}-`;+ await stream.allReady;+ const html = dangerouslySkipEscape(await new Response(stream).text());+ return escapeInject`${html}`;};diff --git a/packages/sdk-components-react/package.json b/packages/sdk-components-react/package.jsonindex aec2175169..e79a4574e5 100644--- a/packages/sdk-components-react/package.json+++ b/packages/sdk-components-react/package.json@@ -23,6 +23,26 @@"types": "./lib/types/components.d.ts","import": "./lib/components.js"},+ "./code-text": {+ "webstudio": "./src/code-text/index.tsx",+ "types": "./lib/types/code-text/index.d.ts",+ "import": "./lib/code-text/index.js"+ },+ "./code-text/build": {+ "webstudio": "./src/code-text/build.ts",+ "types": "./lib/types/code-text/build.d.ts",+ "import": "./lib/code-text/build.js"+ },+ "./build-hooks": {+ "webstudio": "./src/build-hooks.ts",+ "types": "./lib/types/build-hooks.d.ts",+ "import": "./lib/build-hooks.js"+ },+ "./canvas-components": {+ "webstudio": "./src/canvas-components.ts",+ "types": "./lib/types/canvas-components.d.ts",+ "import": "./lib/canvas-components.js"+ },"./metas": {"webstudio": "./src/metas.ts","types": "./lib/types/metas.d.ts",@@ -46,7 +66,7 @@},"scripts": {"build": "vite build --config ../../vite.sdk-components.config.ts",- "build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.test.{ts,tsx} !./src/*.ws.ts !./src/*.ws.ts !./src/*.template.tsx' && oxfmt \"**/*.props.ts\"",+ "build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.test.{ts,tsx} !./src/*.ws.ts !./src/*.template.tsx' && oxfmt \"**/*.props.ts\"","build:stories": "tsx --conditions=webstudio src/generate-stories.ts && oxfmt \"src/__generated__/*.stories.tsx\"","dts": "tsc --project tsconfig.dts.json","test": "vitest run",@@ -58,6 +78,8 @@},"dependencies": {"@react-aria/utils": "^3.27.0",+ "@shikijs/langs": "4.4.1",+ "@shikijs/themes": "4.4.1","@webstudio-is/icons": "workspace:*","@webstudio-is/image": "workspace:*","@webstudio-is/react-sdk": "workspace:*",@@ -65,13 +87,15 @@"await-interaction-response": "^0.0.2","colord": "^2.9.3","github-slugger": "2.0.0",+ "hast-util-to-jsx-runtime": "^2.3.6","mdast-util-from-markdown": "2.0.3","mdast-util-frontmatter": "2.0.1","mdast-util-to-string": "4.0.0","micromark": "^4.0.2","micromark-extension-frontmatter": "2.0.0","micromark-extension-gfm": "^3.0.0",- "sanitize-html": "2.17.6"+ "sanitize-html": "2.17.6",+ "shiki": "4.4.1"},"devDependencies": {"@testing-library/dom": "^10.4.0",diff --git a/packages/sdk-components-react/src/__generated__/code-text.props.ts b/packages/sdk-components-react/src/__generated__/code-text.props.tsdeleted file mode 100644index 366bf096e7..0000000000--- a/packages/sdk-components-react/src/__generated__/code-text.props.ts+++ /dev/null@@ -1,5 +0,0 @@-import type { PropMeta } from "@webstudio-is/sdk";--export const props: Record<string, PropMeta> = {- code: { required: false, control: "text", type: "string" },-};diff --git a/packages/sdk-components-react/src/__generated__/code-text.stories.tsx b/packages/sdk-components-react/src/__generated__/code-text.stories.tsxindex 6e41fdd10f..89fc790cc1 100644--- a/packages/sdk-components-react/src/__generated__/code-text.stories.tsx+++ b/packages/sdk-components-react/src/__generated__/code-text.stories.tsx@@ -3,7 +3,12 @@ import { Box as Box, CodeText as CodeText } from "../components";const Component = () => {return (<Box className={`w-box`}>- <CodeText className={`w-code-text`}>{'status: "ready"'}</CodeText>+ <CodeText+ code={'const status = "ready";'}+ language={"javascript"}+ theme={"github-light"}+ className={`w-code-text`}+ /></Box>);};@@ -29,7 +34,8 @@ const Story = {display: block;padding-left: 0.2em;padding-right: 0.2em;- background-color: rgb(238 238 238 / 1);+ color: var(--w-code-text-theme-color);+ background-color: var(--w-code-text-theme-background, rgb(238 238 238 / 1));white-space: pre-wrap;white-space-collapse: preserve}diff --git a/packages/sdk-components-react/src/basic.template.tsx b/packages/sdk-components-react/src/basic.template.tsxindex e7dbc209b4..650b54fae2 100644--- a/packages/sdk-components-react/src/basic.template.tsx+++ b/packages/sdk-components-react/src/basic.template.tsx@@ -55,11 +55,6 @@ export const Checkbox: TemplateMeta = {template: <$.Checkbox aria-label="Enable weekly summary" />,};-export const CodeText: TemplateMeta = {- category: "typography",- template: <$.CodeText>{new PlaceholderValue('status: "ready"')}</$.CodeText>,-};-export const Fragment: TemplateMeta = {category: "general",template: (diff --git a/packages/sdk-components-react/src/build-hooks.ts b/packages/sdk-components-react/src/build-hooks.tsnew file mode 100644index 0000000000..6369a975dc--- /dev/null+++ b/packages/sdk-components-react/src/build-hooks.ts@@ -0,0 +1,3 @@+import { codeTextBuildHook } from "./code-text/build";++export const buildHooks = [codeTextBuildHook];diff --git a/packages/sdk-components-react/src/canvas-components.ts b/packages/sdk-components-react/src/canvas-components.tsnew file mode 100644index 0000000000..d89654b68d--- /dev/null+++ b/packages/sdk-components-react/src/canvas-components.ts@@ -0,0 +1,5 @@+import { CanvasCodeText } from "./code-text/canvas";++export const canvasComponents = {+ CodeText: CanvasCodeText,+};diff --git a/packages/sdk-components-react/src/code-text.tsx b/packages/sdk-components-react/src/code-text.tsxdeleted file mode 100644index b617859553..0000000000--- a/packages/sdk-components-react/src/code-text.tsx+++ /dev/null@@ -1,47 +0,0 @@-/**- * @deprecated This component will be replaced by the Element component in the future.- * Use Element with tag="code" instead.- */-import {- type ElementRef,- type ComponentProps,- forwardRef,- type ForwardedRef,-} from "react";--export const defaultTag = "code";--const Placeholder = ({- innerRef,- ...rest-}: {- innerRef: ForwardedRef<HTMLElement>;-}) => {- return (- <code {...rest} style={{ padding: 20 }} ref={innerRef}>- {`Open the "Settings" panel to edit the code.`}- </code>- );-};--export const CodeText = forwardRef<- ElementRef<typeof defaultTag>,- ComponentProps<typeof defaultTag> & { code?: string }->(({ code, children, ...props }, ref) => {- // We are supporting children here for historical reasons, because- // the first version of this component allowed using any components inside the CodeText- // and we didn't want to migrate them to use code, also it's not entirely possible.- if (- (children === undefined && code === undefined) ||- String(code).trim().length === 0- ) {- return <Placeholder innerRef={ref} {...props} />;- }- return (- <code {...props} ref={ref}>- {code ?? children}- </code>- );-});--CodeText.displayName = "CodeText";diff --git a/packages/sdk-components-react/src/code-text/base.tsx b/packages/sdk-components-react/src/code-text/base.tsxnew file mode 100644index 0000000000..780515eeec--- /dev/null+++ b/packages/sdk-components-react/src/code-text/base.tsx@@ -0,0 +1,45 @@+import { type ElementRef, type ComponentProps, forwardRef } from "react";++export const defaultTag = "code";++type CodeTextProps = ComponentProps<typeof defaultTag> & {+ code?: string;+ language?: string;+ theme?: string;+};++export const CodeText = forwardRef<+ ElementRef<typeof defaultTag>,+ CodeTextProps+>(+ (+ {+ code,+ children,+ language: _language,+ theme: _theme,+ ...props+ }: CodeTextProps,+ ref+ ) => {+ // Children are supported for Code Text instances created before the+ // editable code property was introduced.+ if (+ (children === undefined && code === undefined) ||+ String(code).trim().length === 0+ ) {+ return (+ <code {...props} style={{ padding: 20 }} ref={ref}>+ {`Open the "Settings" panel to edit the code.`}+ </code>+ );+ }+ return (+ <code {...props} ref={ref}>+ {code ?? children}+ </code>+ );+ }+);++CodeText.displayName = "CodeText";diff --git a/packages/sdk-components-react/src/code-text/build.test.ts b/packages/sdk-components-react/src/code-text/build.test.tsnew file mode 100644index 0000000000..3af52795db--- /dev/null+++ b/packages/sdk-components-react/src/code-text/build.test.ts@@ -0,0 +1,197 @@+import { expect, test } from "vitest";+import type { Instances, Props, WsComponentMeta } from "@webstudio-is/sdk";+import { collectCodeTextAssets } from "./build";++const meta = {+ props: {+ language: {+ required: true,+ control: "select",+ type: "string",+ options: ["plaintext", "javascript"],+ },+ theme: {+ required: true,+ control: "select",+ type: "string",+ options: ["github-light", "nord"],+ },+ },+} satisfies WsComponentMeta;++const instances = new Map([+ [+ "code-1",+ {+ type: "instance" as const,+ id: "code-1",+ component: "CodeText",+ children: [],+ },+ ],+ [+ "code-2",+ {+ type: "instance" as const,+ id: "code-2",+ component: "CodeText",+ children: [],+ },+ ],+]) satisfies Instances;++const collect = (props: Props) =>+ collectCodeTextAssets({ instances, props, meta });++test("collects the deduplicated union of configured Code Text assets", () => {+ const props = new Map([+ [+ "code-1-language",+ {+ id: "code-1-language",+ instanceId: "code-1",+ name: "language",+ type: "string" as const,+ value: "javascript",+ },+ ],+ [+ "code-1-theme",+ {+ id: "code-1-theme",+ instanceId: "code-1",+ name: "theme",+ type: "string" as const,+ value: "github-light",+ },+ ],+ [+ "code-2-language",+ {+ id: "code-2-language",+ instanceId: "code-2",+ name: "language",+ type: "string" as const,+ value: "javascript",+ },+ ],+ [+ "code-2-theme",+ {+ id: "code-2-theme",+ instanceId: "code-2",+ name: "theme",+ type: "string" as const,+ value: "nord",+ },+ ],+ ]) satisfies Props;++ expect(collect(props)).toEqual({+ staticLanguages: ["javascript"],+ staticThemes: ["github-light", "nord"],+ dynamicLanguages: false,+ dynamicThemes: false,+ });+});++test("keeps legacy Code Text instances on the plain renderer", () => {+ expect(collect(new Map())).toBeUndefined();+});++test("keeps legacy HTML language instances on the plain renderer", () => {+ const props = new Map([+ [+ "code-1-lang",+ {+ id: "code-1-lang",+ instanceId: "code-1",+ name: "lang",+ type: "string" as const,+ value: "javascript",+ },+ ],+ ]) satisfies Props;++ expect(collect(props)).toBeUndefined();+});++test("rejects incomplete highlighting selections", () => {+ const props = new Map([+ [+ "code-1-theme",+ {+ id: "code-1-theme",+ instanceId: "code-1",+ name: "theme",+ type: "string" as const,+ value: "github-light",+ },+ ],+ ]) satisfies Props;++ expect(() => collect(props)).toThrow(+ 'Code Text "code-1" requires both Language and Theme selections.'+ );+});++test("marks expression-bound selections as dynamic", () => {+ const props = new Map([+ [+ "code-1-language",+ {+ id: "code-1-language",+ instanceId: "code-1",+ name: "language",+ type: "expression" as const,+ value: '"javascript"',+ },+ ],+ [+ "code-1-theme",+ {+ id: "code-1-theme",+ instanceId: "code-1",+ name: "theme",+ type: "string" as const,+ value: "github-light",+ },+ ],+ ]) satisfies Props;++ expect(collect(props)).toEqual({+ staticLanguages: [],+ staticThemes: ["github-light"],+ dynamicLanguages: true,+ dynamicThemes: false,+ });+});++test("rejects selections outside the component metadata", () => {+ const props = new Map([+ [+ "code-1-language",+ {+ id: "code-1-language",+ instanceId: "code-1",+ name: "language",+ type: "string" as const,+ value: "ruby",+ },+ ],+ [+ "code-1-theme",+ {+ id: "code-1-theme",+ instanceId: "code-1",+ name: "theme",+ type: "string" as const,+ value: "github-light",+ },+ ],+ ]) satisfies Props;++ expect(() => collect(props)).toThrow(+ 'Code Text "code-1" has an unsupported language selection "ruby".'+ );+});diff --git a/packages/sdk-components-react/src/code-text/build.ts b/packages/sdk-components-react/src/code-text/build.tsnew file mode 100644index 0000000000..e71cb8d8ab--- /dev/null+++ b/packages/sdk-components-react/src/code-text/build.ts@@ -0,0 +1,216 @@+import type {+ ComponentBuildHook,+ Instances,+ Prop,+ Props,+ WsComponentMeta,+} from "@webstudio-is/sdk";++export const codeTextComponent = "CodeText";++type Selection = {+ language?: Prop;+ theme?: Prop;+};++const readOptions = (+ meta: WsComponentMeta | undefined,+ name: "language" | "theme"+) => {+ const propMeta = meta?.props?.[name];+ if (propMeta?.control !== "select") {+ throw new Error(`Code Text ${name} metadata must use a select control.`);+ }+ return new Set(propMeta.options);+};++const readSelection = ({+ instanceId,+ label,+ prop,+ supportedValues,+}: {+ instanceId: string;+ label: "Language" | "Theme";+ prop: Prop;+ supportedValues: ReadonlySet<string>;+}) => {+ if (prop.type === "expression") {+ return;+ }+ if (prop.type !== "string") {+ throw new Error(+ `Code Text "${instanceId}" ${label} must be a fixed selection or expression binding.`+ );+ }+ if (supportedValues.has(prop.value) === false) {+ throw new Error(+ `Code Text "${instanceId}" has an unsupported ${label.toLowerCase()} selection "${prop.value}".`+ );+ }+ return prop.value;+};++export const collectCodeTextAssets = ({+ instances,+ props,+ meta,+}: {+ instances: Instances;+ props: Props;+ meta: WsComponentMeta | undefined;+}) => {+ const selections = new Map<string, Selection>();+ for (const prop of props.values()) {+ if (prop.name !== "language" && prop.name !== "theme") {+ continue;+ }+ const instance = instances.get(prop.instanceId);+ if (instance?.component !== codeTextComponent) {+ continue;+ }+ const selection = selections.get(instance.id) ?? {};+ selection[prop.name] = prop;+ selections.set(instance.id, selection);+ }++ if (selections.size === 0) {+ return;+ }++ const supportedLanguages = readOptions(meta, "language");+ const supportedThemes = readOptions(meta, "theme");+ const staticLanguages = new Set<string>();+ const staticThemes = new Set<string>();+ let dynamicLanguages = false;+ let dynamicThemes = false;+ for (const [instanceId, selection] of selections) {+ if (selection.language === undefined || selection.theme === undefined) {+ throw new Error(+ `Code Text "${instanceId}" requires both Language and Theme selections.`+ );+ }+ const language = readSelection({+ instanceId,+ label: "Language",+ prop: selection.language,+ supportedValues: supportedLanguages,+ });+ const theme = readSelection({+ instanceId,+ label: "Theme",+ prop: selection.theme,+ supportedValues: supportedThemes,+ });+ if (language === undefined) {+ dynamicLanguages = true;+ } else if (language !== "plaintext") {+ staticLanguages.add(language);+ }+ if (theme === undefined) {+ dynamicThemes = true;+ } else {+ staticThemes.add(theme);+ }+ }++ return {+ staticLanguages: [...staticLanguages].sort(),+ staticThemes: [...staticThemes].sort(),+ dynamicLanguages,+ dynamicThemes,+ };+};++export const codeTextBuildHook: ComponentBuildHook = {+ component: codeTextComponent,+ build: ({ instances, props, meta, scope }) => {+ const assets = collectCodeTextAssets({ instances, props, meta });+ if (assets === undefined) {+ return;+ }++ const imports = [];+ const createCodeTextName = scope.getName(+ "code-text-factory",+ "createCodeText"+ );+ const codeTextName = scope.getName(codeTextComponent, "CodeText");+ imports.push({+ source: "@webstudio-is/sdk-components-react/code-text",+ imported: "createCodeText",+ local: createCodeTextName,+ });++ const staticLanguageNames: string[] = [];+ for (const language of assets.staticLanguages) {+ const name = scope.getName(+ `code-text-language-${language}`,+ `${language}Language`+ );+ imports.push({+ source: `@shikijs/langs/${language}`,+ local: name,+ });+ staticLanguageNames.push(name);+ }++ const staticThemeNames: string[] = [];+ for (const theme of assets.staticThemes) {+ const name = scope.getName(`code-text-theme-${theme}`, `${theme}Theme`);+ imports.push({+ source: `@shikijs/themes/${theme}`,+ local: name,+ });+ staticThemeNames.push(name);+ }++ const loaderEntries: string[] = [];+ if (assets.dynamicLanguages) {+ const loadersName = scope.getName(+ "code-text-language-loaders",+ "codeTextLanguageLoaders"+ );+ imports.push({+ source: "shiki/langs",+ imported: "bundledLanguages",+ local: loadersName,+ });+ loaderEntries.push(+ `language: (language) => { const loader = ${loadersName}[language as keyof typeof ${loadersName}]; return loader?.().then((module) => module.default); }`+ );+ }+ if (assets.dynamicThemes) {+ const loadersName = scope.getName(+ "code-text-theme-loaders",+ "codeTextThemeLoaders"+ );+ imports.push({+ source: "shiki/themes",+ imported: "bundledThemes",+ local: loadersName,+ });+ loaderEntries.push(+ `theme: (theme) => { const loader = ${loadersName}[theme as keyof typeof ${loadersName}]; return loader?.().then((module) => module.default); }`+ );+ }++ const factoryOptions = [+ `languages: [${staticLanguageNames.join(", ")}]`,+ `themes: [${staticThemeNames.join(", ")}]`,+ ];+ if (loaderEntries.length > 0) {+ factoryOptions.push(+ `loaders: { ${loaderEntries.join(", ")} }`,+ "suspense: true"+ );+ }++ return {+ imports,+ declarations: [+ `const ${codeTextName} = ${createCodeTextName}({ ${factoryOptions.join(", ")} });`,+ ],+ };+ },+};diff --git a/packages/sdk-components-react/src/code-text/bundle.test.ts b/packages/sdk-components-react/src/code-text/bundle.test.tsnew file mode 100644index 0000000000..14ff6190f6--- /dev/null+++ b/packages/sdk-components-react/src/code-text/bundle.test.ts@@ -0,0 +1,80 @@+import { build } from "esbuild";+import { fileURLToPath } from "node:url";+import { expect, test } from "vitest";++const getBundleInputs = async (contents: string) => {+ const result = await build({+ stdin: {+ contents,+ loader: "tsx",+ resolveDir: fileURLToPath(new URL(".", import.meta.url)),+ },+ bundle: true,+ write: false,+ metafile: true,+ format: "esm",+ platform: "browser",+ conditions: ["webstudio"],+ external: ["react", "react/jsx-runtime"],+ });+ return Object.keys(result.metafile?.inputs ?? {});+};++test("bundles only directly selected Shiki assets", async () => {+ const inputs = await getBundleInputs(`+ import javascript from "@shikijs/langs/javascript";+ import nord from "@shikijs/themes/nord";+ import { createCodeText } from "@webstudio-is/sdk-components-react/code-text";+ export const CodeText = createCodeText({+ languages: [javascript],+ themes: [nord],+ });+ `);++ expect(+ inputs.some((path) => path.endsWith("@shikijs/langs/dist/javascript.mjs"))+ ).toBe(true);+ expect(+ inputs.some((path) => path.endsWith("@shikijs/themes/dist/nord.mjs"))+ ).toBe(true);+ expect(+ inputs.some((path) => path.endsWith("@shikijs/langs/dist/css.mjs"))+ ).toBe(false);+ expect(+ inputs.some((path) => path.endsWith("@shikijs/langs/dist/index.mjs"))+ ).toBe(false);+ expect(+ inputs.some((path) => path.endsWith("@shikijs/themes/dist/dracula.mjs"))+ ).toBe(false);+ expect(inputs.some((path) => path.endsWith("shiki/dist/index.mjs"))).toBe(+ false+ );+});++test("keeps Shiki out of plain Code Text bundles", async () => {+ const inputs = await getBundleInputs(`+ import { CodeText } from "@webstudio-is/sdk-components-react/components";+ export const code = <CodeText code="plain" />;+ `);++ expect(inputs.filter((path) => path.includes("shiki"))).toEqual([]);+});++test("reads Code Text metadata without bundling Shiki loaders", async () => {+ const inputs = await getBundleInputs(`+ import { CodeText } from "@webstudio-is/sdk-components-react/metas";+ export const options = CodeText.props;+ `);++ expect(+ inputs.some((path) => path.includes("shiki/dist/langs-bundle-full"))+ ).toBe(false);+ expect(inputs.some((path) => path.includes("@shikijs/core"))).toBe(false);+ expect(+ inputs.filter(+ (path) =>+ path.includes("@shikijs/langs/dist/") &&+ path.endsWith("@shikijs/langs/dist/index.mjs") === false+ )+ ).toEqual([]);+});diff --git a/packages/sdk-components-react/src/code-text/canvas.test.tsx b/packages/sdk-components-react/src/code-text/canvas.test.tsxnew file mode 100644index 0000000000..e0128c46e1--- /dev/null+++ b/packages/sdk-components-react/src/code-text/canvas.test.tsx@@ -0,0 +1,47 @@+// @vitest-environment jsdom++import { render, waitFor } from "@testing-library/react";+import { expect, test } from "vitest";+import { canvasComponents } from "../canvas-components";++const CanvasCodeText = canvasComponents.CodeText;++test("loads highlighting without replacing the code element", async () => {+ const { container, rerender } = render(+ <CanvasCodeText+ code="const answer = 42;"+ language="javascript"+ theme="github-light"+ tabIndex={0}+ />+ );++ const codeElement = container.querySelector("code");+ expect(codeElement?.textContent).toBe("const answer = 42;");+ codeElement?.focus();+ await waitFor(() =>+ expect(container.querySelector("code span")).not.toBeNull()+ );+ expect(container.querySelector("code")).toBe(codeElement);+ expect(document.activeElement).toBe(codeElement);++ rerender(+ <CanvasCodeText+ code="const answer = 42;"+ language="javascript"+ theme="nord"+ tabIndex={0}+ />+ );+ await waitFor(() => {+ const updatedCodeElement = container.querySelector("code");+ expect(+ updatedCodeElement?.style.getPropertyValue(+ "--w-code-text-theme-background"+ )+ ).toBe("#2e3440ff");+ expect(updatedCodeElement?.className).toBe("");+ });+ expect(container.querySelector("code")).toBe(codeElement);+ expect(document.activeElement).toBe(codeElement);+});diff --git a/packages/sdk-components-react/src/code-text/canvas.tsx b/packages/sdk-components-react/src/code-text/canvas.tsxnew file mode 100644index 0000000000..24944782a5--- /dev/null+++ b/packages/sdk-components-react/src/code-text/canvas.tsx@@ -0,0 +1,15 @@+import { bundledLanguages } from "shiki/langs";+import { bundledThemes } from "shiki/themes";+import { createCodeText } from "./index";++const load = async <Registration,>(+ loader: (() => Promise<{ default: Registration }>) | undefined+) => (await loader?.())?.default;++export const CanvasCodeText = createCodeText({+ loaders: {+ language: (language) =>+ load(bundledLanguages[language as keyof typeof bundledLanguages]),+ theme: (theme) => load(bundledThemes[theme as keyof typeof bundledThemes]),+ },+});diff --git a/packages/sdk-components-react/src/code-text/index.test.tsx b/packages/sdk-components-react/src/code-text/index.test.tsxnew file mode 100644index 0000000000..fc8865da5c--- /dev/null+++ b/packages/sdk-components-react/src/code-text/index.test.tsx@@ -0,0 +1,292 @@+// @vitest-environment jsdom++import { createRef } from "react";+import { renderToStaticMarkup, renderToString } from "react-dom/server";+import { hydrateRoot } from "react-dom/client";+import { act, render, waitFor } from "@testing-library/react";+import { expect, test, vi } from "vitest";+import css from "@shikijs/langs/css";+import javascript from "@shikijs/langs/javascript";+import githubLight from "@shikijs/themes/github-light";+import nord from "@shikijs/themes/nord";+import { createCodeText } from ".";+import { CodeText } from "./base";++const HighlightedCodeText = createCodeText({+ languages: [javascript],+ themes: [githubLight, nord],+});++test("renders highlighted HAST inside the semantic code root", () => {+ const markup = renderToStaticMarkup(+ <HighlightedCodeText+ className="custom-code"+ code="const answer = 42;"+ language="javascript"+ theme="github-light"+ />+ );++ expect(markup).toMatch(/^<code/);+ expect(markup).not.toContain("<pre");+ expect(markup).toContain("<span");+ expect(markup).not.toContain('language="javascript"');+ const container = document.createElement("div");+ container.innerHTML = markup;+ const codeElement = container.querySelector("code");+ expect(codeElement?.className).toBe("custom-code");+ expect(codeElement?.getAttribute("tabindex")).toBeNull();+});++test("keeps theme colors without changing typography", () => {+ const markup = renderToStaticMarkup(+ <HighlightedCodeText code="// answer" language="javascript" theme="nord" />+ );+ const container = document.createElement("div");+ container.innerHTML = markup;+ const codeElement = container.querySelector("code");++ expect(+ codeElement?.style.getPropertyValue("--w-code-text-theme-background")+ ).toBe("#2e3440ff");+ expect(codeElement?.style.getPropertyValue("--w-code-text-theme-color")).toBe(+ "#d8dee9ff"+ );+ expect(markup).not.toContain("font-style");+ expect(markup).not.toContain("font-weight");+});++test("preserves an author-provided tab index", () => {+ const markup = renderToStaticMarkup(+ <HighlightedCodeText+ code="const answer = 42;"+ language="javascript"+ theme="github-light"+ tabIndex={0}+ />+ );++ expect(markup).toContain('tabindex="0"');+});++test("allows a failed asset load to retry after remount", async () => {+ let languageAttempts = 0;+ const AsyncCodeText = createCodeText({+ loaders: {+ language: async () => {+ languageAttempts += 1;+ return languageAttempts === 1 ? undefined : javascript;+ },+ theme: async () => githubLight,+ },+ });+ const props = {+ code: "const answer = 42;",+ language: "javascript",+ theme: "github-light",+ } as const;++ const firstRender = render(<AsyncCodeText {...props} />);+ await waitFor(() => expect(languageAttempts).toBe(1));+ firstRender.unmount();++ const secondRender = render(<AsyncCodeText {...props} />);+ await waitFor(() => expect(languageAttempts).toBe(2));+ await waitFor(() =>+ expect(secondRender.container.querySelector("code span")).not.toBeNull()+ );+});++test("keeps source code escaped", () => {+ const source = '<img src=x onerror="unsafe()">';+ const markup = renderToStaticMarkup(+ <HighlightedCodeText+ code={source}+ language="javascript"+ theme="github-light"+ />+ );++ expect(markup).toContain("<");+ expect(markup).toContain("img");+ expect(markup).not.toContain("<img");+ expect(markup).not.toContain("onerror=");+ const container = document.createElement("div");+ container.innerHTML = markup;+ expect(container.textContent).toBe(source);+ expect(container.querySelector("img")).toBeNull();+});++test("renders legacy content without highlighting configuration", () => {+ expect(+ renderToStaticMarkup(<HighlightedCodeText>legacy code</HighlightedCodeText>)+ ).toBe("<code>legacy code</code>");+});++test("falls back to plain code for an unavailable selection", () => {+ expect(+ renderToStaticMarkup(+ <HighlightedCodeText code="puts :hello" language="ruby" theme="nord" />+ )+ ).toBe("<code>puts :hello</code>");+});++test("preserves the empty-code placeholder", () => {+ expect(+ renderToStaticMarkup(+ <HighlightedCodeText+ code=" "+ language="javascript"+ theme="github-light"+ />+ )+ ).toContain("Open the "Settings" panel to edit the code.");+});++test("hydrates the server markup without changing the DOM", async () => {+ const element = (+ <HighlightedCodeText+ code="const answer = 42;"+ language="javascript"+ theme="github-light"+ />+ );+ const container = document.createElement("div");+ container.innerHTML = renderToString(element);+ const serverMarkup = container.innerHTML;++ let root: ReturnType<typeof hydrateRoot>;+ await act(async () => {+ root = hydrateRoot(container, element);+ });+ expect(container.innerHTML).toBe(serverMarkup);+ await act(async () => root.unmount());+});++test("preserves server highlighting while client assets load", async () => {+ let resolveLanguage: (language: typeof javascript) => void = () => {};+ const language = new Promise<typeof javascript>((resolve) => {+ resolveLanguage = resolve;+ });+ const ServerCodeText = createCodeText({+ languages: [javascript],+ themes: [githubLight],+ suspense: true,+ });+ const ClientCodeText = createCodeText({+ loaders: {+ language: () => language,+ theme: async () => githubLight,+ },+ suspense: true,+ });+ const props = {+ code: "const answer = 42;",+ language: "javascript",+ theme: "github-light",+ } as const;+ const container = document.createElement("div");+ container.innerHTML = renderToString(<ServerCodeText {...props} />);+ const serverMarkup = container.innerHTML;+ const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});++ let root: ReturnType<typeof hydrateRoot>;+ await act(async () => {+ root = hydrateRoot(container, <ClientCodeText {...props} />);+ });+ expect(container.innerHTML).toBe(serverMarkup);+ expect(consoleError).not.toHaveBeenCalled();++ await act(async () => resolveLanguage(javascript));+ await waitFor(() =>+ expect(container.querySelector("code span")).not.toBeNull()+ );+ expect(container.innerHTML).toBe(serverMarkup);+ expect(consoleError).not.toHaveBeenCalled();++ await act(async () => root.unmount());+ consoleError.mockRestore();+});++test("keeps the code element mounted when a bound selection changes", async () => {+ let resolveLanguage: (language: typeof css) => void = () => {};+ const language = new Promise<typeof css>((resolve) => {+ resolveLanguage = resolve;+ });+ let resolveTheme: (theme: typeof nord) => void = () => {};+ const theme = new Promise<typeof nord>((resolve) => {+ resolveTheme = resolve;+ });+ const DynamicCodeText = createCodeText({+ languages: [javascript],+ themes: [githubLight],+ loaders: {+ language: () => language,+ theme: () => theme,+ },+ suspense: true,+ });+ const view = render(+ <DynamicCodeText+ code="const answer = 42;"+ language="javascript"+ theme="github-light"+ tabIndex={0}+ />+ );+ const codeElement = view.container.querySelector("code");+ codeElement?.focus();++ view.rerender(+ <DynamicCodeText+ code=".answer { color: red; }"+ language="css"+ theme="nord"+ tabIndex={0}+ />+ );+ expect(view.container.querySelector("code")).toBe(codeElement);+ expect(document.activeElement).toBe(codeElement);++ await act(async () => {+ resolveLanguage(css);+ resolveTheme(nord);+ });+ await waitFor(() =>+ expect(view.container.querySelector("code span")).not.toBeNull()+ );+ expect(view.container.querySelector("code")).toBe(codeElement);+ expect(document.activeElement).toBe(codeElement);+ expect(+ codeElement?.style.getPropertyValue("--w-code-text-theme-background")+ ).toBe("#2e3440ff");+});++test("forwards the code element ref", async () => {+ const ref = createRef<HTMLElement>();+ const container = document.createElement("div");+ document.body.append(container);++ let root: ReturnType<typeof hydrateRoot>;+ const element = (+ <HighlightedCodeText+ ref={ref}+ code="const answer = 42;"+ language="javascript"+ theme="github-light"+ />+ );+ container.innerHTML = renderToString(element);+ await act(async () => {+ root = hydrateRoot(container, element);+ });+ expect(ref.current?.tagName).toBe("CODE");+ await act(async () => root.unmount());+ container.remove();+});++test("preserves the HTML language of legacy plain Code Text", () => {+ expect(renderToStaticMarkup(<CodeText lang="en">legacy code</CodeText>)).toBe(+ '<code lang="en">legacy code</code>'+ );+});diff --git a/packages/sdk-components-react/src/code-text/index.tsx b/packages/sdk-components-react/src/code-text/index.tsxnew file mode 100644index 0000000000..203860d24b--- /dev/null+++ b/packages/sdk-components-react/src/code-text/index.tsx@@ -0,0 +1,327 @@+import {+ Fragment,+ Suspense,+ forwardRef,+ useEffect,+ useMemo,+ useRef,+ useState,+ type ComponentProps,+ type CSSProperties,+ type ElementRef,+ type ReactElement,+} from "react";+import { jsx, jsxs } from "react/jsx-runtime";+import { toJsxRuntime } from "hast-util-to-jsx-runtime";+import {+ createHighlighterCoreSync,+ type LanguageRegistration,+ type MaybeArray,+ type ShikiTransformer,+ type ThemeRegistrationAny,+} from "shiki/core";+import { createJavaScriptRegexEngine } from "shiki/engine/javascript";+import { CodeText, defaultTag } from "./base";+import {+ codeTextThemeBackgroundVariable,+ codeTextThemeColorVariable,+} from "./theme";++type CodeTextProps = ComponentProps<typeof CodeText>;+type Highlighter = ReturnType<typeof createHighlighterCoreSync>;+type LanguageLoader = (+ language: string+) => Promise<MaybeArray<LanguageRegistration> | undefined> | undefined;+type ThemeLoader = (+ theme: string+) => Promise<ThemeRegistrationAny | undefined> | undefined;+type AssetLoaders = {+ language?: LanguageLoader;+ theme?: ThemeLoader;+};++// Canvas assets load after the first paint, so theme typography must not+// change text metrics when highlighting appears.+const colorOnlyThemeTransformer: ShikiTransformer = {+ tokens: (lines) =>+ lines.map((line) =>+ line.map((token) => ({ ...token, fontStyle: undefined }))+ ),+};++const highlightCode = ({+ highlighter,+ code,+ language,+ theme,+}: {+ highlighter: Highlighter;+ code: string;+ language: string;+ theme: string;+}) => {+ let root;+ try {+ root = highlighter.codeToHast(code, {+ lang: language,+ theme,+ tabindex: false,+ transformers: [colorOnlyThemeTransformer],+ });+ } catch {+ return;+ }++ const pre = root.children[0];+ if (pre?.type !== "element" || pre.tagName !== "pre") {+ return;+ }+ const nestedCode = pre.children[0];+ if (nestedCode?.type !== "element" || nestedCode.tagName !== "code") {+ return;+ }++ return toJsxRuntime(+ { ...pre, tagName: "code", children: nestedCode.children },+ { Fragment, jsx, jsxs }+ ) as ReactElement<ComponentProps<"code">>;+};++export const createCodeText = ({+ languages = [],+ themes = [],+ loaders,+ suspense = false,+}: {+ languages?: MaybeArray<LanguageRegistration>[];+ themes?: ThemeRegistrationAny[];+ loaders?: AssetLoaders;+ suspense?: boolean;+}) => {+ const highlighter = createHighlighterCoreSync({+ langs: languages,+ themes,+ engine: createJavaScriptRegexEngine({ target: "ES2018" }),+ warnings: false,+ });+ const languageLoads = new Map<string, Promise<boolean>>();+ const themeLoads = new Map<string, Promise<boolean>>();+ const suspenseLoads = new Map<string, Promise<void>>();++ const isLanguageLoaded = (language: string) =>+ language === "plaintext" ||+ highlighter.getLoadedLanguages().includes(language);+ const isThemeLoaded = (theme: string) =>+ highlighter.getLoadedThemes().includes(theme);+ const isSelectionLoaded = (language: string, theme: string) =>+ isLanguageLoaded(language) && isThemeLoaded(theme);++ const loadAsset = <Registration,>({+ name,+ isLoaded,+ loads,+ loader,+ register,+ }: {+ name: string;+ isLoaded: (name: string) => boolean;+ loads: Map<string, Promise<boolean>>;+ loader:+ | ((name: string) => Promise<Registration | undefined> | undefined)+ | undefined;+ register: (registration: Registration) => void;+ }) => {+ if (isLoaded(name)) {+ return;+ }+ let promise = loads.get(name);+ if (promise !== undefined) {+ return promise;+ }+ const registration = loader?.(name);+ if (registration === undefined) {+ return;+ }+ promise = registration+ .then((loaded) => {+ if (loaded === undefined) {+ return false;+ }+ register(loaded);+ return true;+ })+ .catch(() => false);+ loads.set(name, promise);+ void promise.then((loaded) => {+ if (loaded === false && loads.get(name) === promise) {+ loads.delete(name);+ }+ });+ return promise;+ };++ const loadLanguage = (language: string) =>+ loadAsset({+ name: language,+ isLoaded: isLanguageLoaded,+ loads: languageLoads,+ loader: loaders?.language,+ register: (registration) => highlighter.loadLanguageSync(registration),+ });++ const loadTheme = (theme: string) =>+ loadAsset({+ name: theme,+ isLoaded: isThemeLoaded,+ loads: themeLoads,+ loader: loaders?.theme,+ register: (registration) => highlighter.loadThemeSync(registration),+ });++ const loadAssets = (language: string, theme: string) => {+ if (isSelectionLoaded(language, theme)) {+ return;+ }+ const promises: Promise<boolean>[] = [];+ if (isLanguageLoaded(language) === false) {+ const promise = loadLanguage(language);+ if (promise === undefined) {+ return;+ }+ promises.push(promise);+ }+ if (isThemeLoaded(theme) === false) {+ const promise = loadTheme(theme);+ if (promise === undefined) {+ return;+ }+ promises.push(promise);+ }+ if (promises.length === 0) {+ return;+ }+ return Promise.all(promises).then(() => isSelectionLoaded(language, theme));+ };++ const CodeTextContent = forwardRef<+ ElementRef<typeof defaultTag>,+ CodeTextProps+ >(({ code, children, language, theme, className, style, ...props }, ref) => {+ const [, rerender] = useState(0);+ const didCommit = useRef(false);++ useEffect(() => {+ didCommit.current = true;+ }, []);++ const hasSelection =+ typeof language === "string" && typeof theme === "string";+ const assetsReady = hasSelection && isSelectionLoaded(language, theme);+ if (suspense && didCommit.current === false && assetsReady === false) {+ if (hasSelection) {+ const key = JSON.stringify([language, theme]);+ let promise = suspenseLoads.get(key);+ if (promise === undefined) {+ const assets = loadAssets(language, theme);+ if (assets !== undefined) {+ promise = assets.then((loaded) => {+ if (loaded === false) {+ return new Promise<void>(() => {});+ }+ });+ suspenseLoads.set(key, promise);+ }+ }+ if (promise !== undefined) {+ throw promise;+ }+ }+ }++ useEffect(() => {+ if (hasSelection === false || assetsReady) {+ return;+ }+ const promise = loadAssets(language, theme);+ if (promise === undefined) {+ return;+ }++ let active = true;+ void promise.then((loaded) => {+ if (active && loaded) {+ rerender((value) => value + 1);+ }+ });+ return () => {+ active = false;+ };+ }, [assetsReady, hasSelection, language, theme]);++ const highlighted = useMemo(() => {+ if (+ assetsReady === false ||+ typeof code !== "string" ||+ code.trim().length === 0 ||+ typeof language !== "string" ||+ typeof theme !== "string"+ ) {+ return;+ }+ return highlightCode({ highlighter, code, language, theme });+ }, [assetsReady, code, language, theme]);++ if (highlighted === undefined) {+ return (+ <CodeText+ {...props}+ ref={ref}+ className={className}+ style={style}+ code={code}+ >+ {children}+ </CodeText>+ );+ }++ const {+ style: highlightedStyle,+ children: highlightedChildren,+ ...highlightedProps+ } = highlighted.props;+ const themedStyle = {+ [`--${codeTextThemeBackgroundVariable}`]:+ highlightedStyle?.backgroundColor,+ [`--${codeTextThemeColorVariable}`]: highlightedStyle?.color,+ ...style,+ } as CSSProperties;+ return (+ <CodeText+ {...highlightedProps}+ {...props}+ ref={ref}+ className={className}+ style={themedStyle}+ >+ {highlightedChildren}+ </CodeText>+ );+ });++ CodeTextContent.displayName = "CodeTextContent";+ if (suspense === false) {+ return CodeTextContent;+ }++ const SuspenseCodeText = forwardRef<+ ElementRef<typeof defaultTag>,+ CodeTextProps+ >((props, ref) => (+ <Suspense fallback={<CodeText {...props} ref={ref} />}>+ <CodeTextContent {...props} ref={ref} />+ </Suspense>+ ));+ SuspenseCodeText.displayName = "SuspenseCodeText";+ return SuspenseCodeText;+};diff --git a/packages/sdk-components-react/src/code-text/meta.test.ts b/packages/sdk-components-react/src/code-text/meta.test.tsnew file mode 100644index 0000000000..4aeadf7212--- /dev/null+++ b/packages/sdk-components-react/src/code-text/meta.test.ts@@ -0,0 +1,45 @@+import { expect, test } from "vitest";+import { themeNames } from "@shikijs/themes";+import { bundledLanguagesInfo } from "shiki/langs";+import { meta } from "./meta";++test("exposes static language and theme selections", () => {+ expect(meta.deprecated).toBeUndefined();+ expect(meta.initialProps).toEqual([+ "id",+ "class",+ "code",+ "language",+ "theme",+ ]);+ expect(meta.props?.language).toEqual({+ label: "Language",+ required: true,+ control: "select",+ type: "string",+ options: ["plaintext", ...bundledLanguagesInfo.map(({ id }) => id)],+ });+ expect(meta.props?.theme).toEqual({+ label: "Theme",+ required: true,+ control: "select",+ type: "string",+ options: [...themeNames],+ });+ expect(meta.presetStyle?.code).toEqual(+ expect.arrayContaining([+ {+ property: "color",+ value: { type: "var", value: "w-code-text-theme-color" },+ },+ {+ property: "background-color",+ value: {+ type: "var",+ value: "w-code-text-theme-background",+ fallback: { type: "rgb", r: 238, g: 238, b: 238, alpha: 1 },+ },+ },+ ])+ );+});diff --git a/packages/sdk-components-react/src/code-text.ws.ts b/packages/sdk-components-react/src/code-text/meta.tssimilarity index 51%rename from packages/sdk-components-react/src/code-text.ws.tsrename to packages/sdk-components-react/src/code-text/meta.tsindex c765b7f7dd..d2a64f4d7f 100644--- a/packages/sdk-components-react/src/code-text.ws.ts+++ b/packages/sdk-components-react/src/code-text/meta.ts@@ -1,8 +1,12 @@import { BracesIcon } from "@webstudio-is/icons/svg";import type { PresetStyle, WsComponentMeta } from "@webstudio-is/sdk";import { code } from "@webstudio-is/sdk/normalize.css";-import type { defaultTag } from "./code-text";-import { props } from "./__generated__/code-text.props";+import type { defaultTag } from "./base";+import { codeTextLanguageNames, codeTextThemeNames } from "./options";+import {+ codeTextThemeBackgroundVariable,+ codeTextThemeColorVariable,+} from "./theme";const presetStyle = {code: [@@ -27,24 +31,46 @@ const presetStyle = {property: "padding-right",value: { type: "unit", value: 0.2, unit: "em" },},+ {+ property: "color",+ value: { type: "var", value: codeTextThemeColorVariable },+ },{property: "background-color",- value: { type: "rgb", r: 238, g: 238, b: 238, alpha: 1 },+ value: {+ type: "var",+ value: codeTextThemeBackgroundVariable,+ fallback: { type: "rgb", r: 238, g: 238, b: 238, alpha: 1 },+ },},],} satisfies PresetStyle<typeof defaultTag>;export const meta: WsComponentMeta = {- deprecated: true,icon: BracesIcon,+ description:+ "Display source code with syntax highlighting for a selected language and theme.",presetStyle,- initialProps: ["id", "class", "lang", "code"],+ initialProps: ["id", "class", "code", "language", "theme"],props: {- ...props,code: {required: true,control: "codetext",type: "string",},+ language: {+ label: "Language",+ required: true,+ control: "select",+ type: "string",+ options: codeTextLanguageNames,+ },+ theme: {+ label: "Theme",+ required: true,+ control: "select",+ type: "string",+ options: codeTextThemeNames,+ },},};diff --git a/packages/sdk-components-react/src/code-text/options.test.ts b/packages/sdk-components-react/src/code-text/options.test.tsnew file mode 100644index 0000000000..5d29f55028--- /dev/null+++ b/packages/sdk-components-react/src/code-text/options.test.ts@@ -0,0 +1,12 @@+import { expect, test } from "vitest";+import { bundledLanguagesInfo } from "shiki/langs";+import { themeNames } from "@shikijs/themes";+import { codeTextLanguageNames, codeTextThemeNames } from "./options";++test("matches Shiki's bundled language and theme IDs", () => {+ expect(codeTextLanguageNames).toEqual([+ "plaintext",+ ...bundledLanguagesInfo.map(({ id }) => id),+ ]);+ expect(codeTextThemeNames).toEqual(themeNames);+});diff --git a/packages/sdk-components-react/src/code-text/options.ts b/packages/sdk-components-react/src/code-text/options.tsnew file mode 100644index 0000000000..b4d2750cfc--- /dev/null+++ b/packages/sdk-components-react/src/code-text/options.ts@@ -0,0 +1,30 @@+import { languageNames } from "@shikijs/langs";+import { themeNames } from "@shikijs/themes";++// These embedded grammars do not have loaders in Shiki's bundled registry.+const unbundledLanguageNames = new Set([+ "angular-expression",+ "angular-inline-style",+ "angular-inline-template",+ "angular-let-declaration",+ "angular-template",+ "angular-template-blocks",+ "cpp-macro",+ "es-tag-css",+ "es-tag-glsl",+ "es-tag-html",+ "es-tag-sql",+ "es-tag-xml",+ "jinja-html",+ "markdown-nix",+ "markdown-vue",+ "vue-directives",+ "vue-interpolations",+ "vue-sfc-style-variable-injection",+]);++export const codeTextLanguageNames = [+ "plaintext",+ ...languageNames.filter((name) => unbundledLanguageNames.has(name) === false),+];+export const codeTextThemeNames = [...themeNames];diff --git a/packages/sdk-components-react/src/code-text/template.tsx b/packages/sdk-components-react/src/code-text/template.tsxnew file mode 100644index 0000000000..76e5138b08--- /dev/null+++ b/packages/sdk-components-react/src/code-text/template.tsx@@ -0,0 +1,12 @@+import { $, type TemplateMeta } from "@webstudio-is/template";++export const CodeText: TemplateMeta = {+ category: "typography",+ template: (+ <$.CodeText+ code={'const status = "ready";'}+ language="javascript"+ theme="github-light"+ />+ ),+};diff --git a/packages/sdk-components-react/src/code-text/theme.ts b/packages/sdk-components-react/src/code-text/theme.tsnew file mode 100644index 0000000000..2441c07d4d--- /dev/null+++ b/packages/sdk-components-react/src/code-text/theme.ts@@ -0,0 +1,2 @@+export const codeTextThemeBackgroundVariable = "w-code-text-theme-background";+export const codeTextThemeColorVariable = "w-code-text-theme-color";diff --git a/packages/sdk-components-react/src/components.ts b/packages/sdk-components-react/src/components.tsindex 8cad234121..2e63cb6ac5 100644--- a/packages/sdk-components-react/src/components.ts+++ b/packages/sdk-components-react/src/components.ts@@ -23,7 +23,7 @@ export { Blockquote } from "./blockquote";export { List } from "./list";export { ListItem } from "./list-item";export { Separator } from "./separator";-export { CodeText } from "./code-text";+export { CodeText } from "./code-text/base";export { Label } from "./label";export { Textarea } from "./textarea";export { RadioButton } from "./radio-button";diff --git a/packages/sdk-components-react/src/metas.ts b/packages/sdk-components-react/src/metas.tsindex be668a1781..c4f961300c 100644--- a/packages/sdk-components-react/src/metas.ts+++ b/packages/sdk-components-react/src/metas.ts@@ -23,7 +23,7 @@ export { meta as Blockquote } from "./blockquote.ws";export { meta as List } from "./list.ws";export { meta as ListItem } from "./list-item.ws";export { meta as Separator } from "./separator.ws";-export { meta as CodeText } from "./code-text.ws";+export { meta as CodeText } from "./code-text/meta";export { meta as Label } from "./label.ws";export { meta as Textarea } from "./textarea.ws";export { meta as RadioButton } from "./radio-button.ws";diff --git a/packages/sdk-components-react/src/story-templates.ts b/packages/sdk-components-react/src/story-templates.tsindex 32ec6d7c8e..157f13cebe 100644--- a/packages/sdk-components-react/src/story-templates.ts+++ b/packages/sdk-components-react/src/story-templates.ts@@ -6,3 +6,4 @@ export { meta as YouTube } from "./youtube.template";export { meta as HeadSlot } from "./head-slot.template";export { meta as Select } from "./select.template";export * from "./basic.template";+export * from "./code-text/template";diff --git a/packages/sdk-components-react/tsconfig.dts.json b/packages/sdk-components-react/tsconfig.dts.jsonindex aea2722fd4..2855237720 100644--- a/packages/sdk-components-react/tsconfig.dts.json+++ b/packages/sdk-components-react/tsconfig.dts.json@@ -3,6 +3,10 @@"include": ["src/index.ts","src/components.ts",+ "src/code-text/index.tsx",+ "src/code-text/build.ts",+ "src/build-hooks.ts",+ "src/canvas-components.ts","src/metas.ts","src/hooks.ts","src/create-link.tsx"diff --git a/packages/sdk-components-registry/package.json b/packages/sdk-components-registry/package.jsonindex a6ad4e1f3a..703a1ffb67 100644--- a/packages/sdk-components-registry/package.json+++ b/packages/sdk-components-registry/package.json@@ -46,6 +46,7 @@"@webstudio-is/sdk-components-react-radix": "workspace:*"},"devDependencies": {+ "@testing-library/react": "^16.2.0","@types/react": "^18.2.70","@types/react-dom": "^18.2.25","@webstudio-is/tsconfig": "workspace:*",diff --git a/packages/sdk-components-registry/src/canvas.ts b/packages/sdk-components-registry/src/canvas.tsindex 8d15afbe42..535cc83402 100644--- a/packages/sdk-components-registry/src/canvas.ts+++ b/packages/sdk-components-registry/src/canvas.ts@@ -1,6 +1,7 @@import { coreMetas } from "@webstudio-is/sdk";import { coreTemplates } from "@webstudio-is/sdk/core-templates";import * as baseComponents from "@webstudio-is/sdk-components-react/components";+import { canvasComponents as baseCanvasComponents } from "@webstudio-is/sdk-components-react/canvas-components";import { hooks as baseHooks } from "@webstudio-is/sdk-components-react/hooks";import * as baseTemplates from "@webstudio-is/sdk-components-react/templates";import * as animationComponents from "@webstudio-is/sdk-components-animation";@@ -34,7 +35,7 @@ export const canvasComponentLibraries = [templates: coreTemplates,},{- components: baseComponents,+ components: { ...baseComponents, ...baseCanvasComponents },metas: getLibraryMetas(),hooks: baseHooks,templates: baseTemplates,diff --git a/packages/sdk-components-registry/src/framework.test.ts b/packages/sdk-components-registry/src/framework.test.tsindex 1aa14a435d..d9713adde8 100644--- a/packages/sdk-components-registry/src/framework.test.ts+++ b/packages/sdk-components-registry/src/framework.test.ts@@ -3,6 +3,7 @@ import {baseComponentImportSource,createFrameworkComponentRegistry,} from "./framework";+import { buildHooks as baseBuildHooks } from "@webstudio-is/sdk-components-react/build-hooks";import { componentMetaLibraries, getComponentName } from "./shared";test("creates framework component imports from component package metas", () => {@@ -17,6 +18,8 @@ test("creates framework component imports from component package metas", () => {expect(registry.metas[component]).toBe(meta);}}++ expect(registry.buildHooks).toEqual(baseBuildHooks);});test("overrides router components only when a framework provides them", () => {diff --git a/packages/sdk-components-registry/src/framework.ts b/packages/sdk-components-registry/src/framework.tsindex f49ddaba67..249b019797 100644--- a/packages/sdk-components-registry/src/framework.ts+++ b/packages/sdk-components-registry/src/framework.ts@@ -1,4 +1,5 @@-import type { WsComponentMeta } from "@webstudio-is/sdk";+import type { ComponentBuildHook, WsComponentMeta } from "@webstudio-is/sdk";+import { buildHooks as baseBuildHooks } from "@webstudio-is/sdk-components-react/build-hooks";import {baseComponentImportSource,componentMetaLibraries,@@ -8,6 +9,7 @@ import {export type FrameworkComponentRegistry = {metas: Record<string, WsComponentMeta>;components: Record<string, string>;+ buildHooks: ComponentBuildHook[];};export const createFrameworkComponentRegistry = ({@@ -19,6 +21,7 @@ export const createFrameworkComponentRegistry = ({} = {}): FrameworkComponentRegistry => {const components: Record<string, string> = {};const metas: Record<string, WsComponentMeta> = {};+ const buildHooks: ComponentBuildHook[] = [...baseBuildHooks];for (const library of componentMetaLibraries) {for (const [exportName, meta] of Object.entries(library.metas)) {@@ -37,7 +40,7 @@ export const createFrameworkComponentRegistry = ({}}- return { components, metas };+ return { components, metas, buildHooks };};export { baseComponentImportSource };diff --git a/packages/sdk/src/component-build.ts b/packages/sdk/src/component-build.tsnew file mode 100644index 0000000000..7a20a65b37--- /dev/null+++ b/packages/sdk/src/component-build.ts@@ -0,0 +1,28 @@+import type { Instances } from "./schema/instances";+import type { Props } from "./schema/props";+import type { WsComponentMeta } from "./schema/component-meta";+import type { Scope } from "./scope";++export type ComponentBuildImport = {+ source: string;+ imported?: string;+ local: string;+};++export type ComponentBuildContribution = {+ imports: ComponentBuildImport[];+ declarations: string[];+};++export type ComponentBuildHook = {+ component: string;+ build: (context: {+ instances: Instances;+ props: Props;+ meta: WsComponentMeta | undefined;+ scope: Scope;+ }) =>+ | ComponentBuildContribution+ | undefined+ | Promise<ComponentBuildContribution | undefined>;+};diff --git a/packages/sdk/src/core-templates.tsx b/packages/sdk/src/core-templates.tsxindex 12d3178c51..4915325b74 100644--- a/packages/sdk/src/core-templates.tsx+++ b/packages/sdk/src/core-templates.tsx@@ -100,7 +100,11 @@ const blockMeta: TemplateMeta = {<ws.element ws:label="Separator" ws:tag="hr" /><ws.element ws:label="Blockquote" ws:tag="blockquote"></ws.element><$.HtmlEmbed />- <ws.element ws:label="Code Text" ws:tag="code" />+ <$.CodeText+ code={'const status = "ready";'}+ language="javascript"+ theme="github-light"+ /></BlockTemplate><ws.element ws:label="Paragraph" ws:tag="p">The Content Block component designates regions on the page where@@ -186,17 +190,11 @@ const typography: Record<string, TemplateMeta> = {code_text: {category: "typography",template: (- <ws.element- ws:tag="code"- ws:style={css`- display: block;- white-space-collapse: preserve;- text-wrap-mode: wrap;- padding-left: 0.2em;- padding-right: 0.2em;- background-color: rgb(238 238 238);- `}- ></ws.element>+ <$.CodeText+ code={'const status = "ready";'}+ language="javascript"+ theme="github-light"+ />),},diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.tsindex bb6026f48a..5c40e2e7d7 100644--- a/packages/sdk/src/index.ts+++ b/packages/sdk/src/index.ts@@ -23,6 +23,11 @@ export * from "./core-metas";export * from "./instances-utils";export * from "./page-utils";export * from "./scope";+export type {+ ComponentBuildContribution,+ ComponentBuildHook,+ ComponentBuildImport,+} from "./component-build";export * from "./expression";export * from "./resources-generator";export * from "./page-meta-generator";diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 6dd40b9ba2..985ae4a719 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -128,6 +128,9 @@ importers:'@codemirror/language':specifier: ^6.11.0version: 6.11.0+ '@codemirror/language-data':+ specifier: ^6.5.2+ version: 6.5.2'@codemirror/lint':specifier: ^6.8.5version: 6.8.5@@ -540,6 +543,12 @@ importers:'@react-router/serve':specifier: ^7.5.3version: 7.5.3([email protected]([email protected]([email protected]))([email protected]))([email protected])+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/image':specifier: workspace:*version: link:../../packages/image@@ -576,6 +585,9 @@ importers:react-router:specifier: ^7.5.3+ shiki:+ specifier: 4.4.1+ version: 4.4.1vite:specifier: 6.3.4version: 6.3.4(@types/[email protected])([email protected])([email protected])([email protected])([email protected])@@ -610,6 +622,12 @@ importers:'@react-router/serve':specifier: ^7.5.3version: 7.5.3([email protected]([email protected]([email protected]))([email protected]))([email protected])+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/image':specifier: workspace:*version: link:../../packages/image@@ -652,6 +670,9 @@ importers:react-router:specifier: ^7.5.3+ shiki:+ specifier: 4.4.1+ version: 4.4.1vite:specifier: 6.3.4version: 6.3.4(@types/[email protected])([email protected])([email protected])([email protected])([email protected])@@ -686,6 +707,12 @@ importers:'@react-router/serve':specifier: ^7.5.3version: 7.5.3([email protected]([email protected]([email protected]))([email protected]))([email protected])+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/image':specifier: workspace:*version: link:../../packages/image@@ -722,6 +749,9 @@ importers:react-router:specifier: ^7.5.3+ shiki:+ specifier: 4.4.1+ version: 4.4.1vite:specifier: 6.3.4version: 6.3.4(@types/[email protected])([email protected])([email protected])([email protected])([email protected])@@ -753,6 +783,12 @@ importers:'@react-router/serve':specifier: ^7.5.3version: 7.5.3([email protected]([email protected]([email protected]))([email protected]))([email protected])+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@vercel/react-router':specifier: ^1.1.0version: 1.1.0(@react-router/[email protected](@react-router/[email protected]([email protected]([email protected]([email protected]))([email protected]))([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])([email protected]))(@react-router/[email protected]([email protected]([email protected]([email protected]))([email protected]))([email protected]))([email protected])([email protected]([email protected]))([email protected])@@ -792,6 +828,9 @@ importers:react-router:specifier: ^7.5.3+ shiki:+ specifier: 4.4.1+ version: 4.4.1vite:specifier: 6.3.4version: 6.3.4(@types/[email protected])([email protected])([email protected])([email protected])([email protected])@@ -811,6 +850,12 @@ importers:fixtures/ssg-cloudflare-pages:dependencies:+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/image':specifier: workspace:*version: link:../../packages/image@@ -841,6 +886,9 @@ importers:react-dom:specifier: 18.3.0-canary-14898b6a9-20240318version: 18.3.0-canary-14898b6a9-20240318([email protected])+ shiki:+ specifier: 4.4.1+ version: 4.4.1vike:specifier: ^0.4.229version: 0.4.229([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))@@ -866,6 +914,12 @@ importers:fixtures/ssg-netlify-by-project-id:dependencies:+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/image':specifier: workspace:*version: link:../../packages/image@@ -896,6 +950,9 @@ importers:react-dom:specifier: 18.3.0-canary-14898b6a9-20240318version: 18.3.0-canary-14898b6a9-20240318([email protected])+ shiki:+ specifier: 4.4.1+ version: 4.4.1vike:specifier: ^0.4.229version: 0.4.229([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))@@ -936,6 +993,12 @@ importers:'@remix-run/server-runtime':specifier: 2.16.5version: 2.16.5([email protected])+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/image':specifier: workspace:*version: link:../../packages/image@@ -969,6 +1032,9 @@ importers:react-dom:specifier: 18.3.0-canary-14898b6a9-20240318version: 18.3.0-canary-14898b6a9-20240318([email protected])+ shiki:+ specifier: 4.4.1+ version: 4.4.1webstudio:specifier: workspace:*version: link:../../packages/cli@@ -1021,6 +1087,12 @@ importers:'@react-router/serve':specifier: ^7.5.3version: 7.5.3([email protected]([email protected]([email protected]))([email protected]))([email protected])+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/image':specifier: workspace:*version: link:../../packages/image@@ -1057,6 +1129,9 @@ importers:react-router:specifier: ^7.5.3+ shiki:+ specifier: 4.4.1+ version: 4.4.1vite:specifier: 6.3.4version: 6.3.4(@types/[email protected])([email protected])([email protected])([email protected])([email protected])@@ -1283,6 +1358,12 @@ importers:'@remix-run/server-runtime':specifier: ^2.16.5version: 2.16.5([email protected])+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@types/mdast':specifier: ^4.0.4version: 4.0.4@@ -1385,6 +1466,9 @@ importers:react-router:specifier: ^7.5.3+ shiki:+ specifier: 4.4.1+ version: 4.4.1ts-expect:specifier: ^1.3.0version: 1.3.0@@ -2540,6 +2624,12 @@ importers:'@react-aria/utils':specifier: ^3.27.0+ '@shikijs/langs':+ specifier: 4.4.1+ version: 4.4.1+ '@shikijs/themes':+ specifier: 4.4.1+ version: 4.4.1'@webstudio-is/icons':specifier: workspace:*version: link:../icons@@ -2561,6 +2651,9 @@ importers:github-slugger:specifier: 2.0.0version: 2.0.0+ hast-util-to-jsx-runtime:+ specifier: ^2.3.6+ version: 2.3.6mdast-util-from-markdown:specifier: 2.0.3version: 2.0.3@@ -2582,6 +2675,9 @@ importers:sanitize-html:specifier: 2.17.6version: 2.17.6+ shiki:+ specifier: 4.4.1+ version: 4.4.1devDependencies:'@testing-library/dom':specifier: ^10.4.0@@ -2797,6 +2893,9 @@ importers:specifier: workspace:*version: link:../sdk-components-react-radixdevDependencies:+ '@testing-library/react':+ specifier: ^16.2.0+ version: 16.2.0(@testing-library/[email protected])(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])'@types/react':specifier: ^18.2.70version: 18.2.79@@ -3507,21 +3606,78 @@ packages:'@codemirror/[email protected]':resolution: {integrity: sha512-q8VPEFaEP4ikSlt6ZxjB3zW72+7osfAYW9i8Zu943uqbKuz6utc1+F170hyLUCUltXORjQXRyYQNfkckzA/bPQ==}+ '@codemirror/[email protected]':+ resolution: {integrity: sha512-oap+gsltb/fzdlTQWD6BFF4bSLKcDnlxDsLdePiJpCVNKWXSTAbiiQeYI3UmES+BLAdkmIC1WjyztC1pi/bX4g==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-URM26M3vunFFn9/sm6rzqrBzDgfWuDixp85uTY49wKudToc2jTHUrKIGGKs+QWND+YLofNNZpxcNGRynFJfvgA==}+'@codemirror/[email protected]':resolution: {integrity: sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==}+ '@codemirror/[email protected]':+ resolution: {integrity: sha512-7fNvbyNylvqCphW9HD6WFnRpcDjr+KXX/FgqXy5H5ZS0eC5edDljukm/yNgYkwTsgp2busdod50AOTIy6Jikfg==}+'@codemirror/[email protected]':resolution: {integrity: sha512-aQv37pIMSlueybId/2PVSP6NPnmurFDVmZwzc7jszd2KAF8qd4VBbvNYPXWQq90WIARjsdVkPbw29pszmHws3Q==}+ '@codemirror/[email protected]':+ resolution: {integrity: sha512-m5Nt1mQ/cznJY7tMfQTJchmrjdjQ71IDs+55d1GAa8DGaB8JXWsVCkVT284C3RTASaY43YknrK2X3hPO/J3MOQ==}+'@codemirror/[email protected]':resolution: {integrity: sha512-8PR3vIWg7pSu7ur8A07pGiYHgy3hHj+mRYRCSG8q+mPIrl0F02rgpGv+DsQTHRTc30rydOsf5PZ7yjKFg2Ackw==}+ '@codemirror/[email protected]':+ resolution: {integrity: sha512-P5kyHLObzjtbGj16h+hyvZTxJhSjBEeSx4wMjbnAf3b0uwTy2+F0zGjMZL4PQOm/mh2eGZ5xUDVZXgwP783Nsw==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-EYdQTG22V+KUUk8Qq582g7FMnCZeEHsyuOJisHRft/mQ+ZSZ2w51NupvDUHiqtsOy7It5cHLPGfHQLpMh9bqpQ==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-6PDVU3ZnfeYyz1at1E/ttorErZvZFXXt1OPhtfe1EZJ2V2iDFa0CwPqPgG5F7NXN0yONGoBogKmFAafKTqlwIw==}+'@codemirror/[email protected]':resolution: {integrity: sha512-c/5MYinGbFxYl4itE9q/rgN/sMTjOr8XL5OWnC+EaRMLfCbVUmmubTJfdgpfcSS2SCaT7b+Q+xi3l6CgoE+BsA==}+ '@codemirror/[email protected]':+ resolution: {integrity: sha512-ZKy2v1n8Fc8oEXj0Th0PUMXzQJ0AIR6TaZU+PbDHExFwdu+guzOA4jmCHS1Nz4vbFezwD7LyBdDnddSJeScMCA==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-IRjC8RUBhn9mGR9ywecNhB51yePWCGgvHfY1lWN/Mrp3cKuHr0isDKia+9HnvhiWNnMpbGhWrkhuWOc09exRyw==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-EZaGjCUegtiU7kSMvOfEZpaCReowEf3yNidYu7+vfuGTm9ow4mthAparY5hisJqOHmJowVH3Upu+eJlUji6qqA==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-l/bdzIABvnTo1nzdY6U+kPAC51czYQcOErfzQ9zSm9D8GmNPD0WTW8st/CJwBTPLO8jlrbyvlSEcN20dc4iL0Q==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-6ayPkEd/yRw0XKBx5uAiToSgGECo/GY2NoJIHXIIQh1EVwLuKoU8BP/qK0qH5NLXAbtJRLuT73hx7P9X34iO4w==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-QSKdtYTDRhEHCfo5zOShzxCmqKJvgGrZwDQSdbvCRJ5pRLWBS7pD/8e/tH44aVQT6FKm0t6RVNoSUWHOI5vNug==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-Imi2KTpVGm7TKuUkqyJ5NRmeFWF7aMpNiwHnLQe0x9kmrxElndyH0K6H/gXtWwY6UshMRAhpENsgfpSwsgmC6Q==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-AZ8DJBuXGVHybpBQhmZtgew5//4hv3tdkXnr3vDmOUMJRuB6vn/uuwtmTOTlqEaQFg3hQSVeA90NmvIQyUV6FQ==}++ '@codemirror/[email protected]':+ resolution: {integrity: sha512-CPkWBKrNS8stYbEU5kwBwTf3JB1kghlbh4FSAwzGW2TEscdeHHH4FGysREW86Mqnj3Qn09s0/6Ea/TutmoTobg==}+'@codemirror/[email protected]':resolution: {integrity: sha512-A7+f++LodNNc1wGgoRDTt78cOwWm9KVezApgjOMp1W4hM0898nsqBXwF+sbePE7ZRcjN7Sa1Z5m2oN27XkmEjQ==}+ '@codemirror/[email protected]':+ resolution: {integrity: sha512-xCsmIzH78MyWkib9jlPaaun57XNkfbMIhagfaZVd0iLTqlpw3jXaIcbZm72MTmmn64eTZpBVNjbyYh+QXnxRsg==}+'@codemirror/[email protected]':resolution: {integrity: sha512-s3n3KisH7dx3vsoeGMxsbRAgKe4O1vbrnKBClm99PU0fWxmxsx5rR2PfqQgIt+2MMJBHbiJ5rfIdLYfB9NNvsA==}@@ -4591,24 +4747,54 @@ packages:'@lezer/[email protected]':resolution: {integrity: sha512-w7ojc8ejBqr2REPsWxJjrMFsA/ysDCFICn8zEOR9mrqzOu2amhITYuLD8ag6XZf0CFXDrhKqw7+tW8cX66NaDA==}+ '@lezer/[email protected]':+ resolution: {integrity: sha512-vh9gWWJOXFVY8HBHK3Twzq8MgwG2iN4GSyzBP9sCGTe37P15x2R14VaBQk0VA0ezTRN1KHYBBsHhvpGZ2Xy/pA==}+'@lezer/[email protected]':resolution: {integrity: sha512-FuAnusbLBl1SEAtfN8NdShxYJiESKw9LAFysfea1T96jD3ydBn12oYjaSG1a04BQRIUd93/0D8e5CV1cUMkmQg==}+ '@lezer/[email protected]':+ resolution: {integrity: sha512-xToRsYxwsgJNHTgNdStpcvmbVuKxTapV0dM0wey1geMMRc9aggoVyKgzYp41D2/vVOx+Ii4hmE206kvxIXBVXQ==}+'@lezer/[email protected]':resolution: {integrity: sha512-Z5duk4RN/3zuVO7Jq0pGLJ3qynpxUVsh7IbUbGj88+uV2ApSAn6kWg2au3iJb+0Zi7kKtqffIESgNcRXWZWmSA==}'@lezer/[email protected]':resolution: {integrity: sha512-dqpT8nISx/p9Do3AchvYGV3qYc4/rKr3IBZxlHmpIKam56P47RSHkSF5f13Vu9hebS1jM0HmtJIwLbWz1VIY6w==}+ '@lezer/[email protected]':+ resolution: {integrity: sha512-yHquUfujwg6Yu4Fd1GNHCvidIvJwi/1Xu2DaKl/pfWIA2c1oXkVvawH3NyXhCaFx4OdlYBVX5wvz2f7Aoa/4Xw==}+'@lezer/[email protected]':resolution: {integrity: sha512-j44kbR1QL26l6dMunZ1uhKBFteVGLVCBGNUD2sUaMnic+rbTviVuoK0CD1l9FTW31EueWvFFswCKMH7Z+M3JRA==}+ '@lezer/[email protected]':+ resolution: {integrity: sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==}+'@lezer/[email protected]':resolution: {integrity: sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA==}'@lezer/[email protected]':resolution: {integrity: sha512-DGlzU/i8DC8k0uz1F+jeePrkATl0jWakauTzftMQOcbaMkHbNSRki/4E2tOzJWsVpoKYhe7iTJ03aepdwVUXUA==}+ '@lezer/[email protected]':+ resolution: {integrity: sha512-W7asp9DhM6q0W6DYNwIkLSKOvxlXRrif+UXBMxzsJUuqmhE7oVU+gS3THO4S/Puh7Xzgm858UNaFi6dxTP8dJA==}++ '@lezer/[email protected]':+ resolution: {integrity: sha512-MhQIURHRytsNzP/YXnqpYKW6la6voAH3kyplTOOiCdjyFY6cWWGFVmYVdHIPrElqSDf4iCDktQCockB9FxuhzQ==}++ '@lezer/[email protected]':+ resolution: {integrity: sha512-Lz5sIPBdF2FUXcWeCu1//ojFAZqzTQNRga0aYv6dYXqJqPfMdCAI0NzajWUd4Xijj1IKJLtjoXRPMvTKWBcqKg==}++ '@lezer/[email protected]':+ resolution: {integrity: sha512-3mMGdCTUZ/84ArHOuXWQr37pnf7f+Nw9ycPUeKX+wu19b7pSMcZGLbaXwvD2APMBDOGxPmpK/O6S1v1EvLoqgQ==}++ '@lezer/[email protected]':+ resolution: {integrity: sha512-CdDwirL0OEaStFue/66ZmFSeppuL6Dwjlk8qk153mSQwiSH/Dlri4GNymrNWnUmPl2Um7QfV1FO9KFUyX3Twww==}++ '@lezer/[email protected]':+ resolution: {integrity: sha512-2lrrHqxalACEbxIbsjhqGpSW8kWpUKuY6RHgnSAFZa6qK62wvnPxA8hGOwOoDbwHcOFs5M4o27mjGu+P7TvBmw==}+'@marijn/[email protected]':resolution: {integrity: sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==}@@ -6135,6 +6321,37 @@ packages:'@sec-ant/[email protected]':resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==}+ '@shikijs/[email protected]':+ resolution: {integrity: sha512-VeR2CY6Nn9/WbisoYLOQZ7HZOnwTrpBuOw4wExjqLnBCi62BNWynBUO6K2uPIASPFJwAv7cX1fUu+LrPlSstcw==}+ engines: {node: '>=20'}++ '@shikijs/[email protected]':+ resolution: {integrity: sha512-6U4lJBh8LTvIkEVqRHv/rr3ruwtO6IweFQt1ME1ntHJMGHS+6N86vfYGO1o8c/DtOCTia2lfhdQBtBrps1sDfQ==}+ engines: {node: '>=20'}++ '@shikijs/[email protected]':+ resolution: {integrity: sha512-p23RugMKss0r5DAtRJW1yAXUDl60JvhQYV20yuxei//26JyDSJefV3umyWzzwep2weblMnJGDYahuti6XkcMgA==}+ engines: {node: '>=20'}++ '@shikijs/[email protected]':+ resolution: {integrity: sha512-xb2kCMloBCIraIy2fS5MW0t/BxVY3q2nDyQKBoeSeq6KNrQbShHetCFlw2n35fGIJ6t3+hXDLQogP5ir9O9bvA==}+ engines: {node: '>=20'}++ '@shikijs/[email protected]':+ resolution: {integrity: sha512-ko2OfDoG89YuQ7xL5LtcQiWKb7NIv1Ephb7g48TVU198OzAMLC8lXVEwaJGHK4sUMYrfAGJDqYmNLOLiW/Kz8w==}+ engines: {node: '>=20'}++ '@shikijs/[email protected]':+ resolution: {integrity: sha512-wudOaoFro+/Zl9gQv2W1Ur5XlVduqvTuYLI483Xi0wgc1A+cy1hfB2r6ac6ufBgF+ID7KJEW7L41MHrzQ4wH+w==}+ engines: {node: '>=20'}++ '@shikijs/[email protected]':+ resolution: {integrity: sha512-GOwCLQDHM5EjGUWNPrhzJbr6JP8V/Dx/CDVkWvbZ1Avw5JFnNUckrgbLmE07qtg4WlW7Q7QFndhjIkeU9XMPvw==}+ engines: {node: '>=20'}++ '@shikijs/[email protected]':+ resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}+'@shopify/[email protected]':resolution: {integrity: sha512-LxonkiWEu12FbZhuOMhsdocpxCqm7By8C/2U9QgNuEoXUx2iMrlXjJv3p93RwfNC6TrdlNRo17gRer1z1309VQ==}engines: {node: '>=18.12.0'}@@ -6442,9 +6659,6 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-3qvGd0z8F2ENTGr/GG1yViqfiKmRfrXVx5sJyHGFu3z7m5g5utCQtGp/g29JnjflhtQJBv1WDQukHiT58xPcYQ==}- '@types/[email protected]':- resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}-'@types/[email protected]':resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==}@@ -6460,6 +6674,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==}+ '@types/[email protected]':+ resolution: {integrity: sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==}+'@types/[email protected]':resolution: {integrity: sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==}@@ -6661,6 +6878,9 @@ packages:cpu: [x64]os: [win32]+ '@ungap/[email protected]':+ resolution: {integrity: sha512-60YRaenCQcVjYEKOcG824+DRGGIQ3VKErcBoAEDJZz5bKIs2ZG+X/H9Nk+Q6EVkwJk5QNApxbrc5QtBSwtrXAg==}+'@unocss/[email protected]':resolution: {integrity: sha512-P9IlQfgms+8/nka7fBhiiWU4SPwrTNKbTdK0z1SLnttXMHHjsB2zpG+Vi1JQDpICfY9Y1/2pWtguPE+zeOVu9Q==}@@ -7856,6 +8076,9 @@ packages:resolution: {integrity: sha512-bEN9VHRyXAUOjkKVQVvArFym08BTWB0aJPppZZr0UNyAqWsLaVfAqP7hbaTJjzHifmB5ebnR8Wm7r7yGN/HonQ==}+ resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==}+resolution: {integrity: sha512-IzU74r1PK5IMMGZXUVZbmiu4A1uhiPgW5hm1GjcOfr4ZzHaMPpLNJjR7HjXiIOzi25nZDrgFTobHTkV5Q6ITjA==}@@ -8285,9 +8508,18 @@ packages:resolution: {integrity: sha512-kiGD9WIW3gRKK8Gao3n1f+ahUeTMeJUJILnIT2QNrPigDNdH7rJxzhEbh81UajGeAdAHFecT1a+fLVOCTq9B4Q==}+ resolution: {integrity: sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==}++ resolution: {integrity: sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg==}+resolution: {integrity: sha512-nAxA0v8+vXSBDt3AnRUNjyRIQ0rD+ntpbAp4LnPkumc5M9yUbSMa4XDU9Q6etY4f1Wp4bNgvc1yjiZtsTTrSng==}+ resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==}+resolution: {integrity: sha512-Wv7UgbOswBXYMWQCrzuf5j6Yxs3Dz4Gm3hdrrMV88mD1bbL4khX5aojJvMRLOe30bj6eRo5TYRdcDwTEWl4Wbg==}@@ -8316,6 +8548,9 @@ packages:resolution: {integrity: sha512-KM1SNmemQtsD+OTInZTYKZNbyPzzVrjMR2Iz1Np+Y+bcxUh0dgKF4NtylJVkGZRLe3NklHizJ5k1Vd3ug1uTPA==}engines: {node: '>=18.20'}+ resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==}+resolution: {integrity: sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==}@@ -8415,6 +8650,9 @@ packages:resolution: {integrity: sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==}+ resolution: {integrity: sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==}+resolution: {integrity: sha512-SZWYkWNfjIXIBYSDpXDYIgshqtbOPsi4lviawAEceR1Kqk+sHDlcQjWrzNQsii80AyBY0q5c8HCTNjqo74ul+Q==}@@ -8972,15 +9210,24 @@ packages:resolution: {integrity: sha512-xIPmR5ReJDu/DHH1OoIT1HkuybIfRGYRywC+gJtI7qHjCJp/M9jrmBEJW22O8lskDWm562BX2W8TiAwRTb0rKA==}+ resolution: {integrity: sha512-J6f+9hUp+ldTZqKRSg7Vw5V6MqjATc+3E4gf3CFNcuZNWD8XdyI6zQ8GqH7f8169MM6P7hMBRDVGnn7oHB9kXQ==}+resolution: {integrity: sha512-DtMn9CmVhVzZx3f+optVDF8yFgQVt7FghCRNdlIaS3X5Bnym3hZwPbg/XW86vdpKjlc1PVj26SpnLGeJBXD3JA==}+ resolution: {integrity: sha512-lj/z8v0r6ZtsN/cGNNtemmmfoLAFZnjMbNyLzBafjzikOM+glrjNHPlf6lQDOTccj9n5b0PPihEBbhneMyGs1Q==}+resolution: {integrity: sha512-38w5y+r8nyKlGvNjSEqWrhG0w5PmnRA+wnBvm+ulYCct7nsGYhFVb0lljS9bQav4psDAS1eGkP2LMVcZBi/aqw==}resolution: {integrity: sha512-SXqglS0HrEvSdUEfoXFtcg7DRl7S2cwOXc7jkuusG472Mmjag34DUDeOJUZtl+BVnyeO1frIgVpHlNRWc2gk/w==}+ resolution: {integrity: sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==}+resolution: {integrity: sha512-WmI1gTXUBJo4/ZmSk79Wcb2HcjPJBzM1nlI/OUWA8yk2X9ik3ffNbBGsU+09BFmXaL1IBb9fiuvq6/KMiNycSg==}@@ -8990,6 +9237,9 @@ packages:resolution: {integrity: sha512-pits93r8PhnIoU4Vy9bjW39M2jJ6/tdHyja9rrot9uujkN7UTU9SDnE6WNJz/IGyQk3XHX6yNNtrBH6cQzm8Hw==}+ resolution: {integrity: sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==}+resolution: {integrity: sha512-bbv7TPv/WC49thZPg3jXuqzuvI45IL2EVAr/KxF0BSdHsU0ceFHOmwQn6evxAh1GaoK/6GQ1wp4R4oW2+LFL/A==}@@ -9559,6 +9809,12 @@ packages:resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==}engines: {node: '>=18'}+ resolution: {integrity: sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==}++ resolution: {integrity: sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==}+resolution: {integrity: sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw==}engines: {node: '>=20'}@@ -9956,6 +10212,9 @@ packages:resolution: {integrity: sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg==}+ resolution: {integrity: sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==}+resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}engines: {node: '>= 0.10'}@@ -10174,6 +10433,15 @@ packages:resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==}+ resolution: {integrity: sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==}++ resolution: {integrity: sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==}++ resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==}+resolution: {integrity: sha512-RSYAtP31mvYLkAHrOlh25pCNQ5hWnT106VukGaaFfuJrZFkGRX5GhUAdPqpSDXxOhA2c4akmRuplv1mRqnBn6Q==}engines: {node: '>=8'}@@ -10424,6 +10692,10 @@ packages:resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}engines: {node: '>=8'}+ resolution: {integrity: sha512-rFP+iYKzjLEIqiMiKANhARqiAbk4deDhWnBtnUO/K0D0dPxMGDH4N0FVfBY/VeI+lPrV4wNGCHQZp7EOr7NNBw==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==}engines: {node: '>= 0.4'}@@ -10631,9 +10903,15 @@ packages:resolution: {integrity: sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==}+ resolution: {integrity: sha512-RjQetxJrrUJLQPHbLku6U/ocGtzyjbJMP9lCNK7Ag0CNh690nSH8woqWH9u16nMjYBAok+i7JO1NP2pOy8IsPQ==}+resolution: {integrity: sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==}+ resolution: {integrity: sha512-LIN7rULI0jBscWQYaSswptyderlarFkjQ+t79nzty8tcIAceVomEVlLzH5VP4Cmsv6MtKhs7qaAiwlcp+Mgaxw==}+resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}engines: {node: '>=8'}@@ -10923,6 +11201,9 @@ packages:resolution: {integrity: sha512-kUBE91efOWfIVBo8xzh/uZQ7p9ffYRtUbMRZBNFYwf0RK8koUMx6dGUfwylLOKmaT2cs4wSW96QoYUSXAyEtpg==}+ resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==}+resolution: {integrity: sha512-TkBb0HABNmxzAcfLf4qsIbFbaPDvMO6wa3b3j4VcEzFVaw1LBKwnW4/sRJ/atSLSzoIg41JWEdnE7N6DIhGDGQ==}@@ -11141,9 +11422,15 @@ packages:resolution: {integrity: sha512-0yaU+rj2gKAyEk12ffdSbBfjnnj+b1zqTBv3OQCTn8yEB02bsPizwdBPrLJjHnK+cU9EMMcUnNv938XcZIkmdA==}+ resolution: {integrity: sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==}+resolution: {integrity: sha512-ADBsmerdGBs2WYckrLBEmuETSPyTD4TuLxTrw0DvjirxW1ra4ZwkbzG8ndsv3Q57smvHxo677MHaQrY9yxH8cA==}+ resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}+resolution: {integrity: sha512-FLiNUDwj42yRpb/iNKwjoScskyEozCjtz9kne5qvgp9fkxYSEXU/sKb+t5+XUljb4orjFgBBVCNyISqdRnAKkA==}engines: {node: '>=18.0.0'}@@ -12380,6 +12667,20 @@ snapshots:'@codemirror/view': 6.36.4'@lezer/common': 1.2.3+ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/lang-html': 6.4.9+ '@codemirror/lang-javascript': 6.2.3+ '@codemirror/language': 6.11.0+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/language': 6.11.0+ '@lezer/cpp': 1.1.6+'@codemirror/[email protected]':dependencies:'@codemirror/autocomplete': 6.18.6@@ -12388,6 +12689,14 @@ snapshots:'@lezer/common': 1.2.3'@lezer/css': 1.1.11+ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@lezer/common': 1.2.3+ '@lezer/go': 1.0.1+'@codemirror/[email protected]':dependencies:'@codemirror/autocomplete': 6.18.6@@ -12400,6 +12709,11 @@ snapshots:'@lezer/css': 1.1.11'@lezer/html': 1.3.10+ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/language': 6.11.0+ '@lezer/java': 1.1.3+'@codemirror/[email protected]':dependencies:'@codemirror/autocomplete': 6.18.6@@ -12410,6 +12724,41 @@ snapshots:'@lezer/common': 1.2.3'@lezer/javascript': 1.4.19+ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/lang-html': 6.4.9+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@codemirror/view': 6.36.4+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/language': 6.11.0+ '@lezer/json': 1.0.3++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/lang-css': 6.3.1+ '@codemirror/language': 6.11.0+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/lang-html': 6.4.9+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@codemirror/view': 6.36.4+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2+'@codemirror/[email protected]':dependencies:'@codemirror/autocomplete': 6.18.6@@ -12420,6 +12769,105 @@ snapshots:'@lezer/common': 1.2.3'@lezer/markdown': 1.3.1+ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/lang-html': 6.4.9+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@lezer/common': 1.2.3+ '@lezer/php': 1.0.5++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@lezer/common': 1.2.3+ '@lezer/python': 1.1.19++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/language': 6.11.0+ '@lezer/rust': 1.0.2++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/lang-css': 6.3.1+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@lezer/common': 1.2.3+ '@lezer/sass': 1.1.0++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/lang-html': 6.4.9+ '@codemirror/lang-javascript': 6.2.3+ '@codemirror/language': 6.11.0+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/language': 6.11.0+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@codemirror/view': 6.36.4+ '@lezer/common': 1.2.3+ '@lezer/xml': 1.0.6++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/language': 6.11.0+ '@codemirror/state': 6.5.2+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2+ '@lezer/yaml': 1.0.4++ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/lang-angular': 0.1.4+ '@codemirror/lang-cpp': 6.0.3+ '@codemirror/lang-css': 6.3.1+ '@codemirror/lang-go': 6.0.1+ '@codemirror/lang-html': 6.4.9+ '@codemirror/lang-java': 6.0.2+ '@codemirror/lang-javascript': 6.2.3+ '@codemirror/lang-jinja': 6.0.1+ '@codemirror/lang-json': 6.0.2+ '@codemirror/lang-less': 6.0.2+ '@codemirror/lang-liquid': 6.3.2+ '@codemirror/lang-markdown': 6.3.2+ '@codemirror/lang-php': 6.0.2+ '@codemirror/lang-python': 6.2.1+ '@codemirror/lang-rust': 6.0.2+ '@codemirror/lang-sass': 6.0.2+ '@codemirror/lang-sql': 6.10.0+ '@codemirror/lang-vue': 0.1.3+ '@codemirror/lang-wast': 6.0.2+ '@codemirror/lang-xml': 6.1.0+ '@codemirror/lang-yaml': 6.1.3+ '@codemirror/language': 6.11.0+ '@codemirror/legacy-modes': 6.5.3+'@codemirror/[email protected]':dependencies:'@codemirror/state': 6.5.2@@ -12429,6 +12877,10 @@ snapshots:'@lezer/lr': 1.4.2style-mod: 4.1.2+ '@codemirror/[email protected]':+ dependencies:+ '@codemirror/language': 6.11.0+'@codemirror/[email protected]':dependencies:'@codemirror/state': 6.5.2@@ -13217,12 +13669,24 @@ snapshots:'@lezer/[email protected]': {}+ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2+'@lezer/[email protected]':dependencies:'@lezer/common': 1.2.3'@lezer/highlight': 1.2.1'@lezer/lr': 1.4.2+ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2+'@lezer/[email protected]':dependencies:'@lezer/common': 1.2.3@@ -13233,12 +13697,24 @@ snapshots:'@lezer/highlight': 1.2.1'@lezer/lr': 1.4.2+ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2+'@lezer/[email protected]':dependencies:'@lezer/common': 1.2.3'@lezer/highlight': 1.2.1'@lezer/lr': 1.4.2+ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2+'@lezer/[email protected]':dependencies:'@lezer/common': 1.2.3@@ -13248,6 +13724,42 @@ snapshots:'@lezer/common': 1.2.3'@lezer/highlight': 1.2.1+ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2++ '@lezer/[email protected]':+ dependencies:+ '@lezer/common': 1.2.3+ '@lezer/highlight': 1.2.1+ '@lezer/lr': 1.4.2+'@marijn/[email protected]': {}'@mdx-js/[email protected]':@@ -14895,7 +15407,7 @@ snapshots:'@rollup/[email protected]([email protected])':dependencies:- '@types/estree': 1.0.6+ '@types/estree': 1.0.7estree-walker: 2.0.2picomatch: 4.0.2optionalDependencies:@@ -14970,6 +15482,46 @@ snapshots:'@sec-ant/[email protected]': {}+ '@shikijs/[email protected]':+ dependencies:+ '@shikijs/primitive': 4.4.1+ '@shikijs/types': 4.4.1+ '@shikijs/vscode-textmate': 10.0.2+ '@types/hast': 3.0.5+ hast-util-to-html: 9.0.5++ '@shikijs/[email protected]':+ dependencies:+ '@shikijs/types': 4.4.1+ '@shikijs/vscode-textmate': 10.0.2+ oniguruma-to-es: 4.3.6++ '@shikijs/[email protected]':+ dependencies:+ '@shikijs/types': 4.4.1+ '@shikijs/vscode-textmate': 10.0.2++ '@shikijs/[email protected]':+ dependencies:+ '@shikijs/types': 4.4.1++ '@shikijs/[email protected]':+ dependencies:+ '@shikijs/types': 4.4.1+ '@shikijs/vscode-textmate': 10.0.2+ '@types/hast': 3.0.5++ '@shikijs/[email protected]':+ dependencies:+ '@shikijs/types': 4.4.1++ '@shikijs/[email protected]':+ dependencies:+ '@shikijs/vscode-textmate': 10.0.2+ '@types/hast': 3.0.5++ '@shikijs/[email protected]': {}+'@shopify/[email protected]': {}'@sindresorhus/[email protected]': {}@@ -15354,8 +15906,6 @@ snapshots:dependencies:'@types/estree': 1.0.7- '@types/[email protected]': {}-'@types/[email protected]': {}'@types/[email protected]':@@ -15380,6 +15930,10 @@ snapshots:dependencies:'@types/unist': 3.0.3+ '@types/[email protected]':+ dependencies:+ '@types/unist': 3.0.3+'@types/[email protected]': {}'@types/[email protected]': {}@@ -15520,6 +16074,8 @@ snapshots:'@typescript/[email protected]':optional: true+ '@ungap/[email protected]': {}+'@unocss/[email protected]': {}'@unocss/[email protected]':@@ -16850,6 +17406,8 @@ snapshots:+ [email protected]: {}+dependencies:'@types/estree-jsx': 1.0.0@@ -17414,8 +17972,46 @@ snapshots:transitivePeerDependencies:- supports-color+ dependencies:+ '@types/hast': 3.0.5+ '@types/unist': 3.0.3+ ccount: 2.0.1+ comma-separated-tokens: 2.0.3+ hast-util-whitespace: 3.0.0+ html-void-elements: 3.0.0+ mdast-util-to-hast: 13.2.1+ property-information: 7.2.0+ space-separated-tokens: 2.0.2+ stringify-entities: 4.0.3+ zwitch: 2.0.4++ dependencies:+ '@types/estree': 1.0.7+ '@types/hast': 3.0.5+ '@types/unist': 3.0.3+ comma-separated-tokens: 2.0.3+ devlop: 1.1.0+ estree-util-is-identifier-name: 3.0.0+ hast-util-whitespace: 3.0.0+ mdast-util-mdx-expression: 2.0.1+ mdast-util-mdx-jsx: 3.2.0+ mdast-util-mdxjs-esm: 2.0.1+ property-information: 7.2.0+ space-separated-tokens: 2.0.2+ style-to-js: 1.1.21+ unist-util-position: 5.0.0+ vfile-message: 4.0.3+ transitivePeerDependencies:+ - supports-color++ dependencies:+ '@types/hast': 3.0.5+dependencies:'@preact/signals-core': 1.14.0@@ -17440,6 +18036,8 @@ snapshots:+ [email protected]: {}+dependencies:domelementtype: 2.3.0@@ -17545,6 +18143,8 @@ snapshots:+ [email protected]: {}+@@ -18143,6 +18743,17 @@ snapshots:transitivePeerDependencies:- supports-color+ dependencies:+ '@types/estree-jsx': 1.0.0+ '@types/hast': 3.0.5+ '@types/mdast': 4.0.4+ devlop: 1.1.0+ mdast-util-from-markdown: 2.0.3+ mdast-util-to-markdown: 2.1.2+ transitivePeerDependencies:+ - supports-color+dependencies:'@types/estree-jsx': 1.0.0@@ -18160,6 +18771,23 @@ snapshots:transitivePeerDependencies:- supports-color+ dependencies:+ '@types/estree-jsx': 1.0.0+ '@types/hast': 3.0.5+ '@types/mdast': 4.0.4+ '@types/unist': 3.0.3+ ccount: 2.0.1+ devlop: 1.1.0+ mdast-util-from-markdown: 2.0.3+ mdast-util-to-markdown: 2.1.2+ parse-entities: 4.0.0+ stringify-entities: 4.0.3+ unist-util-stringify-position: 4.0.0+ vfile-message: 4.0.3+ transitivePeerDependencies:+ - supports-color+dependencies:mdast-util-from-markdown: 1.3.1@@ -18180,6 +18808,17 @@ snapshots:transitivePeerDependencies:- supports-color+ dependencies:+ '@types/estree-jsx': 1.0.0+ '@types/hast': 3.0.5+ '@types/mdast': 4.0.4+ devlop: 1.1.0+ mdast-util-from-markdown: 2.0.3+ mdast-util-to-markdown: 2.1.2+ transitivePeerDependencies:+ - supports-color+dependencies:'@types/mdast': 3.0.15@@ -18201,6 +18840,18 @@ snapshots:unist-util-position: 4.0.4unist-util-visit: 4.1.2+ dependencies:+ '@types/hast': 3.0.5+ '@types/mdast': 4.0.4+ '@ungap/structured-clone': 1.3.3+ devlop: 1.1.0+ micromark-util-sanitize-uri: 2.0.1+ trim-lines: 3.0.1+ unist-util-position: 5.0.0+ unist-util-visit: 5.1.0+ vfile: 6.0.3+dependencies:'@types/mdast': 3.0.15@@ -19005,6 +19656,14 @@ snapshots:dependencies:mimic-function: 5.0.1+ [email protected]: {}++ dependencies:+ oniguruma-parser: 0.12.2+ regex: 6.1.0+ regex-recursion: 6.0.2+dependencies:default-browser: 5.5.0@@ -19404,6 +20063,8 @@ snapshots:+ [email protected]: {}+dependencies:forwarded: 0.2.0@@ -19646,6 +20307,16 @@ snapshots:+ dependencies:+ regex-utilities: 2.3.0++ [email protected]: {}++ dependencies:+ regex-utilities: 2.3.0+@@ -20017,6 +20688,17 @@ snapshots:+ dependencies:+ '@shikijs/core': 4.4.1+ '@shikijs/engine-javascript': 4.4.1+ '@shikijs/engine-oniguruma': 4.4.1+ '@shikijs/langs': 4.4.1+ '@shikijs/themes': 4.4.1+ '@shikijs/types': 4.4.1+ '@shikijs/vscode-textmate': 10.0.2+ '@types/hast': 3.0.5+dependencies:es-errors: 1.3.0@@ -20212,10 +20894,18 @@ snapshots:+ dependencies:+ style-to-object: 1.0.14+dependencies:inline-style-parser: 0.1.1+ dependencies:+ inline-style-parser: 0.2.7+dependencies:has-flag: 4.0.0@@ -20539,6 +21229,10 @@ snapshots:dependencies:'@types/unist': 2.0.6+ dependencies:+ '@types/unist': 3.0.3+dependencies:'@types/unist': 2.0.6@@ -20710,6 +21404,11 @@ snapshots:'@types/unist': 2.0.6unist-util-stringify-position: 3.0.3+ dependencies:+ '@types/unist': 3.0.3+ unist-util-stringify-position: 4.0.0+dependencies:'@types/unist': 2.0.6@@ -20717,6 +21416,11 @@ snapshots:unist-util-stringify-position: 3.0.3vfile-message: 3.1.3+ dependencies:+ '@types/unist': 3.0.3+ vfile-message: 4.0.3+[email protected]([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])):dependencies:'@brillout/import': 0.2.6