@cube-drone/marquee-markup 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,249 @@
1
+ // buildSite(): render a folder of .mq files into a static website. This is
2
+ // the batteries-included *embedder*, so it implements the embedder half of
3
+ // the spec:
4
+ // - :::include doc=X::: resolves X.mq beside the including page. Included
5
+ // documents may not include (the v0 depth cap), which also makes cycles
6
+ // unrepresentable. Files named _*.mq are includable partials, not pages.
7
+ // - Relative doc-id links ([Menu](menu)) resolve to the built pages
8
+ // (menu.html) - the base-URI duty, done at build time.
9
+ // - Relative media is copied into <out>/media/ and re-pointed.
10
+ // - Turbolinks get the plugin chain (fetchless defaults unless overridden).
11
+ // - <title> comes from :::meta title, dogfooding document metadata.
12
+ // - Fonts ship as files, and only the faces the site's pages actually use.
13
+ // Stylesheets and fonts are real cacheable files - this is a website, not a
14
+ // single-file page (that's what marquee() is for).
15
+
16
+ import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
17
+ import { basename, join, resolve } from "node:path";
18
+ import { parse } from "@cube-drone/marquee-parser";
19
+ import {
20
+ bareWebProfile,
21
+ escapeText,
22
+ render,
23
+ usedFontTokens,
24
+ type EmojiResolution,
25
+ type Profile,
26
+ } from "@cube-drone/marquee-html-renderer";
27
+ import { marqueeCss } from "@cube-drone/marquee-css";
28
+ import { standardEmoji } from "@cube-drone/marquee-emoji";
29
+ import { externalFontFaces, fontFilePath } from "@cube-drone/marquee-fonts";
30
+ import {
31
+ composeTurbolinks,
32
+ defaultPlugins,
33
+ opengraphPlugin,
34
+ resolveTargets,
35
+ turbolinkStyles,
36
+ turbolinkTargets,
37
+ type TurbolinkPlugin,
38
+ } from "@cube-drone/marquee-turbolink";
39
+ import { docIsPage, envelopeCss, metaTitle, readabilityCss } from "./index.ts";
40
+
41
+ export interface SiteOptions {
42
+ /** Force the site's theme; default follows the reader's OS. */
43
+ colorScheme?: "light" | "dark";
44
+ /** Wrap pages in a 650px centered readability envelope (default false;
45
+ * opt-in so it can't interfere with a host stack's layout). Documents
46
+ * that ARE a `:::page` are left alone. */
47
+ envelope?: boolean;
48
+ /** Best-effort color-readability rescue: clamp author colors' lightness
49
+ * toward the canvas's opposite (see MarqueeOptions.readable). Defaults
50
+ * ON - the site's shell declares the color-scheme, so the clamp
51
+ * direction is trustworthy; pass false to opt out. */
52
+ readable?: boolean;
53
+ /** Turbolink expanders; defaults to the fetchless default set. */
54
+ plugins?: TurbolinkPlugin[];
55
+ /** Your emoji: slug -> replacement text or `{ image, alt? }`, layered
56
+ * over the default table (profile.emoji wins over everything). */
57
+ emoji?: Record<string, EmojiResolution>;
58
+ /** The implicit emoji table (default true): gemoji's standard shortcodes.
59
+ * Set false and unlisted slugs stay literal. */
60
+ emojiDefaults?: boolean;
61
+ /** Overrides layered on the assembled per-site profile. */
62
+ profile?: Partial<Profile>;
63
+ }
64
+
65
+ export interface SiteReport {
66
+ pages: string[];
67
+ mediaFiles: number;
68
+ fontFaces: string[];
69
+ outDir: string;
70
+ }
71
+
72
+ /** Synchronous, fetchless site build - turbolinks with nothing gathered
73
+ * degrade to plain links. */
74
+ export function buildSite(siteDirArg: string, outDirArg: string, opts: SiteOptions = {}): SiteReport {
75
+ return buildSiteCore(siteDirArg, outDirArg, opts, opts.plugins ?? defaultPlugins, undefined);
76
+ }
77
+
78
+ /** buildSite(), plus the network: gathers every page's turbolink targets,
79
+ * runs the composed plugins' async resolve() phase once (OpenGraph joins
80
+ * the chain automatically - and this executes plugin fetch code, so trust
81
+ * your chain), then builds with the gathered data. */
82
+ export async function buildSiteFetch(
83
+ siteDirArg: string,
84
+ outDirArg: string,
85
+ opts: SiteOptions = {},
86
+ ): Promise<SiteReport> {
87
+ const base = opts.plugins ?? defaultPlugins;
88
+ const plugins = base.some((p) => p.name === opengraphPlugin.name)
89
+ ? base
90
+ : [...base, opengraphPlugin];
91
+ const siteDir = resolve(siteDirArg);
92
+ const targets: string[] = [];
93
+ for (const file of readdirSync(siteDir).filter((f) => f.endsWith(".mq"))) {
94
+ targets.push(...turbolinkTargets(parse(readFileSync(join(siteDir, file), "utf8"))));
95
+ }
96
+ const resolved = await resolveTargets(targets, plugins);
97
+ return buildSiteCore(siteDirArg, outDirArg, opts, plugins, resolved);
98
+ }
99
+
100
+ function buildSiteCore(
101
+ siteDirArg: string,
102
+ outDirArg: string,
103
+ opts: SiteOptions,
104
+ plugins: TurbolinkPlugin[],
105
+ resolved: Map<string, unknown> | undefined,
106
+ ): SiteReport {
107
+ const siteDir = resolve(siteDirArg);
108
+ const outDir = resolve(outDirArg);
109
+ const emojiTable: Record<string, EmojiResolution> = {
110
+ ...(opts.emojiDefaults === false ? {} : standardEmoji),
111
+ ...opts.emoji,
112
+ };
113
+
114
+ const mqFiles = readdirSync(siteDir).filter((f) => f.endsWith(".mq"));
115
+ const pageIds = mqFiles.filter((f) => !f.startsWith("_")).map((f) => basename(f, ".mq"));
116
+
117
+ // -- media: relative embeds copied in once, re-pointed at media/<name>
118
+
119
+ const copiedMedia = new Map<string, string>();
120
+
121
+ function siteMediaUrl(path: string): string {
122
+ let name = copiedMedia.get(path);
123
+ if (name === undefined) {
124
+ name = basename(path);
125
+ for (let n = 2; [...copiedMedia.values()].includes(name); n += 1) {
126
+ const dot = basename(path).lastIndexOf(".");
127
+ name = dot <= 0 ? `${basename(path)}-${n}` : `${basename(path).slice(0, dot)}-${n}${basename(path).slice(dot)}`;
128
+ }
129
+ mkdirSync(join(outDir, "media"), { recursive: true });
130
+ copyFileSync(path, join(outDir, "media", name));
131
+ copiedMedia.set(path, name);
132
+ }
133
+ return `media/${encodeURIComponent(name)}`;
134
+ }
135
+
136
+ // -- the embedder profile; `depth` enforces "includes may not include"
137
+
138
+ function siteProfile(depth: number): Profile {
139
+ return {
140
+ ...bareWebProfile,
141
+ media(target) {
142
+ if (!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(target)) {
143
+ const path = resolve(siteDir, target.split(/[?#]/, 1)[0]!);
144
+ if (existsSync(path)) {
145
+ // Kind-by-extension via the default profile (dummy https host -
146
+ // only the extension matters to it).
147
+ const base = bareWebProfile.media(`https://local/${basename(path)}`);
148
+ if (base !== null) {
149
+ return { kind: base.kind, url: siteMediaUrl(path) };
150
+ }
151
+ }
152
+ return null;
153
+ }
154
+ return bareWebProfile.media(target);
155
+ },
156
+ turbolink: composeTurbolinks(plugins, resolved),
157
+ emoji: (slug: string) => emojiTable[slug] ?? null,
158
+ directive(name, attrs, _children) {
159
+ if (name !== "include" || depth > 0) {
160
+ return null; // deep include -> unknown vocabulary -> inert placeholder
161
+ }
162
+ const doc = attrs["doc"];
163
+ if (doc === undefined || !/^[A-Za-z0-9_.-]+$/.test(doc)) {
164
+ return null;
165
+ }
166
+ const path = join(siteDir, `${doc}.mq`);
167
+ if (!existsSync(path)) {
168
+ return null; // missing include: the placeholder says so, words survive
169
+ }
170
+ const included = parse(readFileSync(path, "utf8"));
171
+ if (included.type !== "document") {
172
+ return null;
173
+ }
174
+ const inner = siteProfile(depth + 1);
175
+ return included.children.map((child) => render(child, inner)).join("");
176
+ },
177
+ ...opts.profile,
178
+ };
179
+ }
180
+
181
+ function shell(title: string, body: string): string {
182
+ return `<!doctype html>
183
+ <html lang="en">
184
+ <head>
185
+ <meta charset="utf-8">
186
+ <meta name="viewport" content="width=device-width, initial-scale=1">
187
+ <title>${escapeText(title)}</title>
188
+ <link rel="stylesheet" href="css/marquee.css">
189
+ <link rel="stylesheet" href="css/fonts.css">
190
+ <link rel="stylesheet" href="css/turbolink.css">
191
+ <style>/* the embedder's page, the embedder's reset: full-bleed backgrounds
192
+ (marquee.css never touches body - it must embed politely in host pages),
193
+ and the reader's OS theme decides light or dark unless the build forced one */
194
+ :root { color-scheme: ${opts.colorScheme ?? "light dark"}; }
195
+ body { margin: 0; }${opts.envelope === true ? `\n${envelopeCss}` : ""}${opts.readable === false ? "" : `\n${readabilityCss(opts.colorScheme)}`}</style>
196
+ </head>
197
+ <body>
198
+ ${body}
199
+ </body>
200
+ </html>
201
+ `;
202
+ }
203
+
204
+ // -- build
205
+
206
+ mkdirSync(join(outDir, "css"), { recursive: true });
207
+ writeFileSync(join(outDir, "css/marquee.css"), marqueeCss);
208
+ writeFileSync(join(outDir, "css/turbolink.css"), turbolinkStyles(plugins));
209
+
210
+ const profile = siteProfile(0);
211
+ const usedFonts = new Set<string>();
212
+ for (const id of pageIds) {
213
+ const source = readFileSync(join(siteDir, `${id}.mq`), "utf8");
214
+ const doc = parse(source);
215
+ let body = render(doc, profile);
216
+ // Doc-id links become page links: the base-URI duty, resolved at build.
217
+ for (const target of pageIds) {
218
+ body = body.replaceAll(`href="${target}"`, `href="${target}.html"`);
219
+ }
220
+ for (const token of usedFontTokens(body)) {
221
+ usedFonts.add(token);
222
+ }
223
+ // The envelope defers to a document that IS a page.
224
+ if (opts.envelope === true && !docIsPage(doc)) {
225
+ body = `<div class="mq-envelope">${body}</div>`;
226
+ }
227
+ writeFileSync(join(outDir, `${id}.html`), shell(metaTitle(doc) ?? id, body));
228
+ }
229
+
230
+ // Fonts: only the faces this site actually uses. Readers never fetch
231
+ // unused @font-face rules anyway (font loading is lazy), but a deploy
232
+ // artifact shouldn't haul the whole library to serve four faces.
233
+ mkdirSync(join(outDir, "fonts"), { recursive: true });
234
+ const shipped: string[] = [];
235
+ for (const token of [...usedFonts].sort()) {
236
+ const path = fontFilePath(token);
237
+ if (path === null) {
238
+ continue; // standard stacks and unfetched faces: fallbacks handle it
239
+ }
240
+ copyFileSync(path, join(outDir, "fonts", `${token}.woff2`));
241
+ shipped.push(token);
242
+ }
243
+ writeFileSync(
244
+ join(outDir, "css/fonts.css"),
245
+ `/* fonts.css - generated per site: only the faces these pages use. */\n\n${externalFontFaces(shipped, "../fonts/")}\n`,
246
+ );
247
+
248
+ return { pages: pageIds, mediaFiles: copiedMedia.size, fontFaces: shipped, outDir };
249
+ }
package/src/index.ts ADDED
@@ -0,0 +1,298 @@
1
+ // @cube-drone/marquee-markup: Marquee, batteries included.
2
+ //
3
+ // import { marquee } from "@cube-drone/marquee-markup";
4
+ // writeFileSync("hello.html", marquee("# hello *world*"));
5
+ //
6
+ // One motion: parse, render, style, inline the fonts the page actually
7
+ // wears, wrap in a page shell. `marqueeFragment()` gives embedders the
8
+ // pieces instead; `buildSite()` renders a folder of .mq files into a
9
+ // website (shared nav/footer includes, per-site font subsetting).
10
+ //
11
+ // Everything underneath is re-exported, so outgrowing the convenience never
12
+ // means switching packages: the same parse/render/Profile/plugin machinery
13
+ // from @cube-drone/marquee-parser, -html-renderer, -css, -fonts, and
14
+ // @cube-drone/marquee-turbolink is all reachable from here.
15
+
16
+ import { parse, type Node } from "@cube-drone/marquee-parser";
17
+ import {
18
+ bareWebProfile,
19
+ escapeText,
20
+ render,
21
+ usedFontTokens,
22
+ type EmojiResolution,
23
+ type Profile,
24
+ } from "@cube-drone/marquee-html-renderer";
25
+ import { marqueeCss } from "@cube-drone/marquee-css";
26
+ import { standardEmoji } from "@cube-drone/marquee-emoji";
27
+ import { externalFontFaces, inlineFontFaces } from "@cube-drone/marquee-fonts";
28
+ import {
29
+ composeTurbolinks,
30
+ defaultPlugins,
31
+ opengraphPlugin,
32
+ resolveTargets,
33
+ turbolinkStyles,
34
+ turbolinkTargets,
35
+ type TurbolinkPlugin,
36
+ } from "@cube-drone/marquee-turbolink";
37
+
38
+ export interface MarqueeOptions {
39
+ /** Page title; defaults to the document's `:::meta title`, then "Marquee". */
40
+ title?: string;
41
+ /** Font delivery: "inline" (default) carries the used faces as base64;
42
+ * "external" emits @font-face urls under `fontBase` (copy the files
43
+ * yourself - `fontTokens` in the fragment return + `fontFilePath()` tell
44
+ * you which); "none" lets names degrade to their fallback stacks. */
45
+ fonts?: "inline" | "external" | "none";
46
+ /** Base path for fonts: "external" urls (default "fonts/"). */
47
+ fontBase?: string;
48
+ /** Your emoji: slug -> replacement text, or `{ image, alt? }` for a
49
+ * custom-emoji image (rendered as an inline `<img class="mq-emoji">`,
50
+ * character-sized). Entries layer over the default table and win on
51
+ * collision. (For dynamic resolution, use `profile.emoji` instead - a
52
+ * profile override wins over everything.) */
53
+ emoji?: Record<string, EmojiResolution>;
54
+ /** The implicit emoji table (default true): gemoji's standard shortcodes,
55
+ * from @cube-drone/marquee-emoji. Set false and unlisted slugs stay
56
+ * literal `:slug:`. */
57
+ emojiDefaults?: boolean;
58
+ /** Force the page's theme. Default: follow the reader's OS
59
+ * (`color-scheme: light dark`). Applies to the page shell, so it only
60
+ * affects `marquee()`/`marqueeFetch()` - fragments follow their host. */
61
+ colorScheme?: "light" | "dark";
62
+ /** Wrap the rendered document in a 650px centered envelope, purely for
63
+ * readability (default false - it could interfere with a host stack's
64
+ * own layout, so it's opt-in). A document that IS a `:::page` (its
65
+ * top-level content is page directives) is left alone even when this is
66
+ * on: the author took layout control, the envelope defers. */
67
+ envelope?: boolean;
68
+ /** Best-effort color-readability rescue: author colors keep their hue
69
+ * but their lightness is clamped toward the canvas's opposite -
70
+ * lightened on dark canvases, darkened on light. Containers that paint
71
+ * their own background (schemes, `background=` knobs) own their contrast
72
+ * and are left alone. Defaults ON for whole pages (marquee/marqueeFetch/
73
+ * buildSite - our shell declared the color-scheme, so the clamp direction
74
+ * is trustworthy) and OFF for bare fragments (a host theming by class
75
+ * rather than OS preference would get the clamp backwards - opt in when
76
+ * your canvas follows prefers-color-scheme). */
77
+ readable?: boolean;
78
+ /** Turbolink expanders; defaults to the fetchless default set. */
79
+ plugins?: TurbolinkPlugin[];
80
+ /** Overrides layered on the assembled profile (schemes, media policy...). */
81
+ profile?: Partial<Profile>;
82
+ }
83
+
84
+ function assembleProfile(
85
+ opts: MarqueeOptions,
86
+ plugins: TurbolinkPlugin[],
87
+ resolved?: Map<string, unknown>,
88
+ ): Profile {
89
+ const emoji: Record<string, EmojiResolution> = {
90
+ ...(opts.emojiDefaults === false ? {} : standardEmoji),
91
+ ...opts.emoji,
92
+ };
93
+ return {
94
+ ...bareWebProfile,
95
+ turbolink: composeTurbolinks(plugins, resolved),
96
+ emoji: (slug: string) => emoji[slug] ?? null,
97
+ ...opts.profile,
98
+ };
99
+ }
100
+
101
+ /** The fetch-mode plugin chain: yours (or the defaults) with the OpenGraph
102
+ * expander appended, unless you already composed one in. */
103
+ function fetchChain(opts: MarqueeOptions): TurbolinkPlugin[] {
104
+ const base = opts.plugins ?? defaultPlugins;
105
+ return base.some((p) => p.name === opengraphPlugin.name) ? base : [...base, opengraphPlugin];
106
+ }
107
+
108
+ /** The document's own `:::meta title`, if it declares one. */
109
+ export function metaTitle(doc: Node): string | undefined {
110
+ if (doc.type !== "document") {
111
+ return undefined;
112
+ }
113
+ for (const child of doc.children) {
114
+ if (child.type === "directive" && child.name === "meta" && child.attrs["title"] !== undefined) {
115
+ return child.attrs["title"];
116
+ }
117
+ }
118
+ return undefined;
119
+ }
120
+
121
+ interface Fragment {
122
+ body: string;
123
+ css: string;
124
+ title: string;
125
+ fontTokens: string[];
126
+ }
127
+
128
+ /** Parse and render to embeddable pieces: what goes in the body, the CSS
129
+ * that belongs in the head (stylesheet + composed plugin skins + fonts per
130
+ * options), the title, and which font faces the page wears. */
131
+ export function marqueeFragment(source: string, opts: MarqueeOptions = {}): Fragment {
132
+ return fragmentCore(parse(source), opts, opts.plugins ?? defaultPlugins);
133
+ }
134
+
135
+ /** The readability envelope: omnibus convenience, not renderer contract
136
+ * (mq-* classes in marquee.css are the renderers'; this one is ours). */
137
+ export const envelopeCss = `.mq-envelope { max-width: 650px; margin-inline: auto; padding-inline: 1rem; }`;
138
+
139
+ /** The `readable` option's stylesheet: CSS relative color syntax clamps the
140
+ * *lightness* of author colors (hue and chroma survive) toward whatever the
141
+ * canvas isn't - floor 0.72 on dark canvases, ceiling 0.55 on light. The
142
+ * clamp bounds ride inherited custom properties, so containers that paint
143
+ * their own background (schemes, `background=` knobs) reset them to no-ops
144
+ * for their whole subtree: they own their contrast. A painted background
145
+ * with NO chosen text color additionally gets black-or-white text computed
146
+ * from the background's own lightness. Browsers without relative-color
147
+ * support ignore all of it and fall back to the raw colors. */
148
+ export function readabilityCss(colorScheme?: "light" | "dark"): string {
149
+ const dark = `.mq-doc { --mq-rl-min: 0.72; --mq-rl-max: 1; }`;
150
+ const light = `.mq-doc { --mq-rl-min: 0; --mq-rl-max: 0.55; }`;
151
+ const mode =
152
+ colorScheme === "dark"
153
+ ? dark
154
+ : colorScheme === "light"
155
+ ? light
156
+ : `@media (prefers-color-scheme: dark) { ${dark} }\n@media (prefers-color-scheme: light) { ${light} }`;
157
+ return `${mode}
158
+ .mq-doc [style*="--mq-color"] { color: oklch(from var(--mq-color) clamp(var(--mq-rl-min, 0), l, var(--mq-rl-max, 1)) c h); }
159
+ .mq-doc [style*="--mq-bg"]:not([style*="--mq-color"]) { color: oklch(from var(--mq-bg) calc(1 - clamp(0, (l - 0.5) * 999, 1)) 0 h); }
160
+ .mq-doc [class*="mq-scheme-"], .mq-doc [style*="--mq-bg"] { --mq-rl-min: 0; --mq-rl-max: 1; }`;
161
+ }
162
+
163
+ /** Does the document take layout into its own hands? Only when it IS a
164
+ * page: every top-level block (ignoring `:::meta` and comments) is a
165
+ * `:::page` directive. A document that merely *contains* a page demo among
166
+ * prose is still an unstructured document, and the envelope applies. */
167
+ export function docIsPage(doc: Node): boolean {
168
+ if (doc.type !== "document") {
169
+ return false;
170
+ }
171
+ const blocks = doc.children.filter(
172
+ (c) => c.type !== "comment" && !(c.type === "directive" && c.name === "meta"),
173
+ );
174
+ return blocks.length > 0 && blocks.every((c) => c.type === "directive" && c.name === "page");
175
+ }
176
+
177
+ function fragmentCore(
178
+ doc: Node,
179
+ opts: MarqueeOptions,
180
+ plugins: TurbolinkPlugin[],
181
+ resolved?: Map<string, unknown>,
182
+ ): Fragment {
183
+ const profile = assembleProfile(opts, plugins, resolved);
184
+ let body = render(doc, profile);
185
+ const enveloped = opts.envelope === true && !docIsPage(doc);
186
+ if (enveloped) {
187
+ body = `<div class="mq-envelope">${body}</div>`;
188
+ }
189
+ const fontTokens = usedFontTokens(body);
190
+ let css = `${marqueeCss}\n${turbolinkStyles(plugins)}`;
191
+ if (enveloped) {
192
+ css += `\n${envelopeCss}`;
193
+ }
194
+ if (opts.readable === true) {
195
+ css += `\n${readabilityCss(opts.colorScheme)}`;
196
+ }
197
+ const fonts = opts.fonts ?? "inline";
198
+ const faces =
199
+ fonts === "inline"
200
+ ? inlineFontFaces(fontTokens)
201
+ : fonts === "external"
202
+ ? externalFontFaces(fontTokens, opts.fontBase ?? "fonts/")
203
+ : "";
204
+ if (faces !== "") {
205
+ css += `\n${faces}`;
206
+ }
207
+ return { body, css, title: opts.title ?? metaTitle(doc) ?? "Marquee", fontTokens };
208
+ }
209
+
210
+ /** Just the stuff that goes inside <body>: the rendered document fragment. */
211
+ export function marqueeBody(source: string, opts: MarqueeOptions = {}): string {
212
+ return marqueeFragment(source, opts).body;
213
+ }
214
+
215
+ /** Just the stuff that goes inside <head>: title + one <style> block. */
216
+ export function marqueeHead(source: string, opts: MarqueeOptions = {}): string {
217
+ const { css, title } = marqueeFragment(source, opts);
218
+ return `<title>${escapeText(title)}</title>\n<style>\n${css}\n</style>`;
219
+ }
220
+
221
+ function pageShell({ body, css, title }: Fragment, colorScheme?: "light" | "dark"): string {
222
+ return `<!doctype html>
223
+ <html lang="en">
224
+ <head>
225
+ <meta charset="utf-8">
226
+ <meta name="viewport" content="width=device-width, initial-scale=1">
227
+ <title>${escapeText(title)}</title>
228
+ <style>
229
+ /* The page is ours, so it follows the reader's OS theme unless the caller
230
+ forced one. marquee.css never declares color-scheme itself - embedded
231
+ fragments defer to their host - and its own neutrals are translucent, so
232
+ they ride either canvas. */
233
+ :root { color-scheme: ${colorScheme ?? "light dark"}; }
234
+ body { margin: 0; }
235
+ ${css}
236
+ </style>
237
+ </head>
238
+ <body>
239
+ ${body}
240
+ </body>
241
+ </html>
242
+ `;
243
+ }
244
+
245
+ /** The one smooth motion: Marquee source in, a complete self-contained
246
+ * HTML page out. Synchronous and fetchless - turbolinks with nothing
247
+ * gathered degrade to plain links. */
248
+ export function marquee(source: string, opts: MarqueeOptions = {}): string {
249
+ return pageShell(marqueeFragment(source, { readable: true, ...opts }), opts.colorScheme);
250
+ }
251
+
252
+ /** marquee(), plus the network: runs the composed plugins' async resolve()
253
+ * phase ahead of the render - OpenGraph summaries for bare web links
254
+ * (opengraphPlugin joins the chain automatically), plus whatever gathering
255
+ * your own plugins declare. That means this function EXECUTES plugin fetch
256
+ * code: compose the chain from plugins you trust, because a malicious one
257
+ * runs here too. Rendering itself stays sync and fetchless; a failed fetch
258
+ * degrades to the plain link. */
259
+ export async function marqueeFetch(source: string, opts: MarqueeOptions = {}): Promise<string> {
260
+ const plugins = fetchChain(opts);
261
+ const doc = parse(source);
262
+ const resolved = await resolveTargets(turbolinkTargets(doc), plugins);
263
+ return pageShell(fragmentCore(doc, { readable: true, ...opts }, plugins, resolved), opts.colorScheme);
264
+ }
265
+
266
+ export { buildSite, buildSiteFetch, type SiteReport } from "./build-site.ts";
267
+
268
+ // The full toolbox, re-exported: growth never requires switching packages.
269
+ export { parse, UnsupportedVersionError } from "@cube-drone/marquee-parser";
270
+ export type { Attrs, Node, Reason } from "@cube-drone/marquee-parser";
271
+ export {
272
+ FONTS,
273
+ bareWebProfile,
274
+ escapeAttr,
275
+ escapeText,
276
+ render,
277
+ renderMarquee,
278
+ usedFontTokens,
279
+ } from "@cube-drone/marquee-html-renderer";
280
+ export type { EmojiResolution, MediaResolution, Profile, TurbolinkLevel } from "@cube-drone/marquee-html-renderer";
281
+ export { marqueeCss } from "@cube-drone/marquee-css";
282
+ export { standardEmoji } from "@cube-drone/marquee-emoji";
283
+ export {
284
+ FONT_MANIFEST,
285
+ externalFontFaces,
286
+ fontFilePath,
287
+ inlineFontFaces,
288
+ } from "@cube-drone/marquee-fonts";
289
+ export {
290
+ composeTurbolinks,
291
+ defaultPlugins,
292
+ opengraphPlugin,
293
+ renderCard,
294
+ resolveTargets,
295
+ turbolinkStyles,
296
+ turbolinkTargets,
297
+ } from "@cube-drone/marquee-turbolink";
298
+ export type { TurbolinkContext, TurbolinkPlugin, TurbolinkSummary } from "@cube-drone/marquee-turbolink";