decklight 0.8.1 → 0.10.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.
Files changed (138) hide show
  1. package/PLATFORM.md +707 -0
  2. package/README.md +226 -150
  3. package/SPEC.md +803 -888
  4. package/cli/agent-review.mjs +246 -0
  5. package/cli/agents.mjs +35 -9
  6. package/cli/associate.mjs +12 -12
  7. package/cli/audit.mjs +42 -10
  8. package/cli/banner.mjs +41 -17
  9. package/cli/bundle-audio.mjs +190 -0
  10. package/cli/bundle-module.mjs +95 -0
  11. package/cli/bundle.mjs +439 -35
  12. package/cli/cast.mjs +48 -12
  13. package/cli/check-fixes.mjs +186 -0
  14. package/cli/check.mjs +988 -0
  15. package/cli/clone-deck.mjs +179 -0
  16. package/cli/commands.mjs +345 -0
  17. package/cli/comments.mjs +64 -18
  18. package/cli/commit-flow.mjs +51 -22
  19. package/cli/commit-message.mjs +51 -74
  20. package/cli/commit-split.mjs +601 -0
  21. package/cli/deck-refs.mjs +64 -0
  22. package/cli/deck-routes.mjs +67 -0
  23. package/cli/deckfile.mjs +3 -5
  24. package/cli/decklight.mjs +68 -289
  25. package/cli/design-system-deps.mjs +209 -0
  26. package/cli/design-system-edit.mjs +194 -0
  27. package/cli/design-system-refs.mjs +666 -0
  28. package/cli/design-system.mjs +497 -0
  29. package/cli/doctor.mjs +115 -0
  30. package/cli/edit-git.mjs +353 -0
  31. package/cli/edit-handover.mjs +551 -0
  32. package/cli/edit-look.mjs +631 -0
  33. package/cli/edit-slides.mjs +683 -0
  34. package/cli/edit.mjs +2585 -855
  35. package/cli/enhance.mjs +485 -0
  36. package/cli/extension.mjs +10 -10
  37. package/cli/font-refs.mjs +273 -0
  38. package/cli/font.mjs +246 -0
  39. package/cli/git-tree.mjs +1 -1
  40. package/cli/git.mjs +78 -11
  41. package/cli/import.mjs +56 -10
  42. package/cli/init.mjs +407 -236
  43. package/cli/library.mjs +127 -0
  44. package/cli/loader.mjs +3 -1
  45. package/cli/marketplace-autocheck.mjs +200 -0
  46. package/cli/marketplace.mjs +460 -29
  47. package/cli/narrate.mjs +251 -0
  48. package/cli/open-browser.mjs +63 -0
  49. package/cli/open.mjs +961 -0
  50. package/cli/pdf.mjs +64 -17
  51. package/cli/pkg.mjs +44 -2
  52. package/cli/plugin.mjs +43 -41
  53. package/cli/port-conflict.mjs +53 -23
  54. package/cli/pptx-export.mjs +63 -27
  55. package/cli/publish.mjs +8 -4
  56. package/cli/qr.mjs +1 -1
  57. package/cli/record.mjs +85 -23
  58. package/cli/remote.mjs +43 -17
  59. package/cli/restore.mjs +11 -4
  60. package/cli/review-ref.mjs +125 -0
  61. package/cli/review-remote.mjs +92 -48
  62. package/cli/review-routes.mjs +254 -0
  63. package/cli/review-store.mjs +47 -7
  64. package/cli/review-submit.mjs +47 -57
  65. package/cli/runtime-link.mjs +560 -0
  66. package/cli/serve.mjs +236 -45
  67. package/cli/setup.mjs +112 -0
  68. package/cli/sign.mjs +1 -1
  69. package/cli/skill-content.mjs +229 -35
  70. package/cli/skills.mjs +353 -26
  71. package/cli/start.mjs +110 -0
  72. package/cli/supervise.mjs +6 -6
  73. package/cli/theme-refs.mjs +527 -0
  74. package/cli/theme.mjs +181 -137
  75. package/cli/trust.mjs +83 -0
  76. package/cli/units.mjs +112 -47
  77. package/cli/update-check.mjs +1 -5
  78. package/cli/upgrade.mjs +194 -28
  79. package/cli/upstream.mjs +4 -3
  80. package/cli/util.mjs +4 -4
  81. package/cli/wizard.mjs +6 -6
  82. package/dist/build-info.json +1 -1
  83. package/dist/decklight.css +1533 -59
  84. package/dist/decklight.js +258 -115
  85. package/dist/decklight.js.map +4 -4
  86. package/docs/GLOSSARY.md +141 -0
  87. package/docs/architecture.svg +17 -17
  88. package/package.json +4 -2
  89. package/themes/README.md +9 -8
  90. package/themes/reveal-solarized.css +10 -0
  91. package/tools/args.mjs +20 -0
  92. package/tools/atomic-write.mjs +48 -0
  93. package/tools/brand-palette.mjs +717 -0
  94. package/tools/bridge.mjs +1 -1
  95. package/tools/build-groups.mjs +42 -0
  96. package/tools/color.mjs +48 -0
  97. package/tools/deck-html.mjs +396 -11
  98. package/tools/design-system-format.mjs +778 -0
  99. package/tools/design-system-migrations.mjs +207 -0
  100. package/tools/elevenlabs-tts.mjs +110 -17
  101. package/tools/exec.mjs +11 -3
  102. package/tools/extension-check.mjs +31 -7
  103. package/tools/font-format.mjs +190 -0
  104. package/tools/font-stacks.mjs +24 -0
  105. package/tools/gemini-tts.mjs +3 -0
  106. package/tools/lipsync-config.mjs +103 -0
  107. package/tools/lipsync-engines.mjs +205 -2
  108. package/tools/lipsync-server.mjs +264 -41
  109. package/tools/lipsync.mjs +37 -18
  110. package/tools/local-voice.mjs +32 -42
  111. package/tools/narration-manifest.mjs +270 -0
  112. package/tools/narration-synth.mjs +416 -0
  113. package/tools/pptx.mjs +776 -19
  114. package/tools/publish-targets.mjs +1 -1
  115. package/tools/publish-voices.mjs +3 -3
  116. package/tools/recording-impact.mjs +7 -3
  117. package/tools/render-theme.mjs +33 -0
  118. package/tools/review-anchor.mjs +28 -12
  119. package/tools/semver.mjs +40 -0
  120. package/tools/sentences.mjs +180 -0
  121. package/tools/shot.mjs +14 -7
  122. package/tools/site-clip.mjs +114 -0
  123. package/tools/site-voices.mjs +232 -0
  124. package/tools/template-theme.mjs +1 -1
  125. package/tools/test-impact.mjs +17 -10
  126. package/tools/theme-check.mjs +30 -3
  127. package/tools/tts-cache.mjs +4 -3
  128. package/tools/tts-engines.mjs +38 -20
  129. package/tools/tts-setup.mjs +7 -7
  130. package/tools/video-options.mjs +34 -0
  131. package/tools/video.mjs +530 -54
  132. package/tools/voiceover-server.mjs +185 -104
  133. package/tools/voiceover.mjs +119 -261
  134. package/tools/zip.mjs +1 -1
  135. package/cli/dev.mjs +0 -623
  136. package/cli/present.mjs +0 -853
  137. package/cli/review.mjs +0 -361
  138. package/tools/publish-site-voices.mjs +0 -75
package/cli/bundle.mjs CHANGED
@@ -16,10 +16,24 @@
16
16
  * - themes : the theme <link> is replaced by <style data-theme="name">
17
17
  * blocks (inactive ones carry media="not all"; the engine's
18
18
  * inline-theme mode toggles them — picker/?theme= work).
19
+ * Every theme the deck MARKS from a marketplace
20
+ * ("markedThemes") is inlined too, from this machine's
21
+ * copy of that marketplace (SPEC THEME_DISTRIBUTION).
19
22
  * - terminals : data-cast="url" casts are embedded and switched to
20
23
  * data-cast-inline (fetch is blocked on file://).
21
24
  * - images : <img src>, data-background-image and data-background-poster
22
25
  * → data: URIs (background VIDEOS stay external, with a notice).
26
+ * - design systems: every one the deck references ("designSystems") — its
27
+ * stylesheet with each relative url() as a data: URI, its
28
+ * meta and its layouts, the blocks every server injects
29
+ * (SPEC DESIGN_SYSTEMS), so layouts expand from file://.
30
+ * - audio : with --audio, every recorded narration file (a track's
31
+ * folder, a local manifest's files) as a data: URI the
32
+ * runtime plays in place of the path; `--audio aac|opus`
33
+ * re-encodes each small first. Off by default.
34
+ * - fonts : every font package the deck references ("fonts") — its
35
+ * faces as data: URIs in @font-face rules, and its meta
36
+ * (SPEC FONTS), so the type is the same from file://.
23
37
  *
24
38
  * MERGE mode (--all or several inputs): every module's <section>s are
25
39
  * concatenated into one deck, in order. Each module's first section gets
@@ -31,10 +45,17 @@
31
45
  import fs from 'node:fs';
32
46
  import path from 'node:path';
33
47
  import { makeFail, scriptSafe, runMain } from './util.mjs';
34
- import { inlineRuntime } from './pkg.mjs';
48
+ import { inlineRuntime, packageAsset, PKG, THEMES_DIR } from './pkg.mjs';
49
+ import { configBlock, configTheme, firstExecutableScript, hasEmbeddedRuntime, hasRuntime, linkRuntime } from './runtime-link.mjs';
50
+ import { addedThemeStyle, markedRefs, markedShipped, markedSources, resolveThemeRef, stillValid } from './theme-refs.mjs';
51
+ import { bundleDesignSystem, designSystemRefs, packageVerdict, resolveDesignSystemRef } from './design-system-refs.mjs';
52
+ import { bundleFont, fontRefs, fontVerdict, resolveFontRef } from './font-refs.mjs';
53
+ import { MarketplaceError } from './marketplace.mjs';
35
54
  import { escapeHtml } from '../tools/escape.mjs';
36
55
  import { isMain } from '../tools/args.mjs';
56
+ import { AUDIO_CHOICES, CODECS, estimateAudio, inlineAudio, narrationAudio, sizeLabel } from './bundle-audio.mjs';
37
57
  import { injectBeforeBodyEnd } from '../tools/deck-html.mjs';
58
+ import { deckModules, pickModule, renumber, sliceManifest, sliceModule, slug } from './bundle-module.mjs';
38
59
 
39
60
  const fail = makeFail('bundle');
40
61
 
@@ -67,7 +88,7 @@ function containerBounds(html) {
67
88
  }
68
89
 
69
90
  /** Cut `const PLAYLIST = {…};` (brace-matched) and the `playlist: X` init
70
- * property out of a merged deck — cross-file navigation has no meaning
91
+ * property out of the deck being bundled — cross-file navigation has no meaning
71
92
  * inside one file; in-file data-module markers replace it. */
72
93
  function stripPlaylist(html) {
73
94
  const declM = html.match(/const\s+PLAYLIST\s*=\s*/);
@@ -184,14 +205,20 @@ function mergeDecks(jobs, baseDir, notices) {
184
205
 
185
206
  // ---------------------------------------------------------------- arguments
186
207
 
187
- /** `client` is the sigstore seam — see publishMain; omitted, the real one is used. */
188
- export async function bundleMain(argv = process.argv.slice(2), { client } = {}) {
208
+ /**
209
+ * `client` is the sigstore seam — see publishMain; omitted, the real one is used.
210
+ * `report`, when given, is filled with `{ out, notices }` once the file is
211
+ * written: where it went and the notes printed after it, for a caller (the edit
212
+ * server's bundle card) that says them somewhere other than this terminal.
213
+ */
214
+ export async function bundleMain(argv = process.argv.slice(2), { client, estimate = false, report = null } = {}) {
189
215
 
190
216
  if (!argv.length || argv.includes('--help') || argv.includes('-h')) {
191
217
  process.stdout.write(`decklight bundle — flatten deck(s) into one self-contained HTML file
192
218
 
193
219
  Usage:
194
- decklight bundle <deck.html> [-o out.html] [--sign] [--deck] [--themes current|all|…]
220
+ decklight bundle <deck.html> [-o out.html] [--audio [original|aac|opus]] [--sign] [--deck] [--themes current|all|…]
221
+ decklight bundle <deck.html> --module <title | n> [-o out.html] [--audio …] [--themes …]
195
222
  decklight bundle <deck.html> --all [-o out.html] [--title "…"] [--themes …]
196
223
  decklight bundle <a.html> <b.html> … [-o out.html] [--title "…"] [--themes …]
197
224
 
@@ -212,26 +239,58 @@ Options:
212
239
  --sign, because the container is the signed artifact. A
213
240
  .decklight renamed to .html still plays in a browser: the
214
241
  deck comes first in the file and the metadata is appended.
215
- --title <t> <title> for a merged presentation
216
- --transform <name> run an installed build-time transform (decklight transform
217
- add <name>) on the deck's own source before anything else
242
+ --module <t|n> bundle one chapter of the deck: the slides from its
243
+ <section data-module="…"> up to the next one, named by
244
+ title or by number. The chapter's narration comes with it,
245
+ renumbered to its slides (--audio carries it inside)
246
+ --title <t> <title> for the multi-module deck
247
+ --transform <name> run an installed build-time transform (decklight library
248
+ add transform <name>) on the deck's own source before anything else
218
249
  is inlined — repeatable, applied in the order given
219
- --themes <sel> which themes to embed:
250
+ --themes <sel> which shipped themes to embed:
220
251
  current just the deck's linked theme (default)
221
252
  all every theme in the deck's themes/ directory
222
253
  name,name,… an explicit list (the deck's linked theme
223
254
  stays active when included, else the first)
255
+ every theme the deck MARKS ("markedThemes") is embedded as
256
+ well, whichever you choose
257
+ --theme <name> the theme the bundle opens on — a shipped theme (embedded
258
+ alongside the others) or one the deck marks
259
+ --audio [how] carry the narration's recorded audio inside the file, so
260
+ it plays from disk with nothing beside it:
261
+ original the files as recorded (the default)
262
+ aac mono AAC at 32 kbps, ~4 KB a second of
263
+ voice, plays in every browser
264
+ opus mono Opus at 24 kbps, ~3 KB a second,
265
+ the smallest (Safari from 17)
266
+ aac and opus need ffmpeg and cost some quality. Off by
267
+ default: a talk's audio is tens of MB, so it stays beside
268
+ the deck and the bundle names the folder to send with it
269
+ (--no-audio says so explicitly)
270
+ --allow-missing-design-systems
271
+ bundle even when a design system the deck uses cannot be
272
+ read on this machine: it is left out, and the slides that
273
+ name its layouts render plainly wherever the file opens
274
+ --allow-missing-fonts
275
+ bundle even when a font the deck references cannot be read
276
+ on this machine: it is left out, and the theme's own font
277
+ stack shows wherever the file opens
224
278
  `);
225
279
  return 0;
226
280
  }
227
281
 
228
282
  const inputs = [];
229
- let outPath = null, themesSel = 'current', all = false, mergedTitle = null, sign = false, deckFile = false;
283
+ let outPath = null, themesSel = 'current', all = false, mergedTitle = null, sign = false, deckFile = false, openOn = null;
284
+ let allowMissingSystems = false;
285
+ let allowMissingFonts = false;
286
+ let audioChoice = null;
287
+ let moduleWant = null;
230
288
  const transformNames = [];
231
289
  for (let i = 0; i < argv.length; i++) {
232
290
  const a = argv[i];
233
291
  if (a === '-o') outPath = argv[++i];
234
292
  else if (a === '--themes') themesSel = argv[++i];
293
+ else if (a === '--theme') openOn = argv[++i];
235
294
  else if (a === '--all') all = true;
236
295
  else if (a === '--transform') transformNames.push(argv[++i]);
237
296
  else if (a === '--sign') sign = true;
@@ -240,11 +299,21 @@ for (let i = 0; i < argv.length; i++) {
240
299
  // an attestation. Naming the implication beats refusing the obvious command.
241
300
  else if (a === '--deck') { deckFile = true; sign = true; }
242
301
  else if (a === '--title') mergedTitle = argv[++i];
302
+ else if (a === '--module') {
303
+ moduleWant = argv[++i];
304
+ if (moduleWant == null || moduleWant.startsWith('-')) fail('--module takes a chapter: its title, or its number');
305
+ }
306
+ else if (a === '--allow-missing-design-systems') allowMissingSystems = true;
307
+ else if (a === '--allow-missing-fonts') allowMissingFonts = true;
308
+ // `--audio` alone is the files as recorded; a codec after it re-encodes them
309
+ else if (a === '--audio') audioChoice = AUDIO_CHOICES.includes(argv[i + 1]) ? argv[++i] : 'original';
310
+ else if (a === '--no-audio') audioChoice = null;
243
311
  else if (!a.startsWith('-')) inputs.push(a);
244
312
  else fail(`unknown argument: ${a}`);
245
313
  }
246
314
  if (!inputs.length) fail('no deck given');
247
315
  if (all && inputs.length > 1) fail('--all takes a single deck (it follows that deck’s playlist)');
316
+ if (moduleWant != null && inputs.length > 1) fail('--module takes a single deck (it bundles one chapter of it)');
248
317
 
249
318
  const firstPath = path.resolve(inputs[0]);
250
319
  if (!fs.existsSync(firstPath)) fail(`deck not found: ${firstPath}`);
@@ -257,6 +326,14 @@ if (all) {
257
326
  const src = fs.readFileSync(firstPath, 'utf8');
258
327
  const modules = parsePlaylist(src);
259
328
  if (!modules.length) fail('--all: the deck has no parseable playlist ({ title, href } modules)');
329
+ if (moduleWant != null) {
330
+ // A playlist's module is a file of its own: bundling it is bundling that file.
331
+ const k = /^\d+$/.test(moduleWant.trim()) ? Number(moduleWant) - 1
332
+ : modules.findIndex((m) => m.title.toLowerCase() === moduleWant.trim().toLowerCase());
333
+ fail(modules[k]
334
+ ? `--module with --all: a playlist module is a file of its own — bundle it as one:\n decklight bundle ${path.join(path.relative(process.cwd(), deckDir) || '.', modules[k].href)}`
335
+ : '--module bundles one chapter of a single deck; --all merges a playlist — use one or the other');
336
+ }
260
337
  jobs = modules.map((m) => {
261
338
  const p = path.resolve(deckDir, m.href);
262
339
  if (!fs.existsSync(p)) fail(`playlist module not found: ${m.href} (${p})`);
@@ -271,6 +348,8 @@ if (all) {
271
348
  }
272
349
 
273
350
  let html;
351
+ // `--module`: the chapter being bundled; its narration is renumbered to it
352
+ let chapter = null;
274
353
  if (jobs) {
275
354
  html = mergeDecks(jobs, deckDir, notices);
276
355
  const t = mergedTitle ||
@@ -280,14 +359,34 @@ if (jobs) {
280
359
  path.join(deckDir, path.basename(firstPath, '.html') + '-course.html'));
281
360
  } else {
282
361
  html = fs.readFileSync(firstPath, 'utf8');
362
+ let suffix = '-standalone';
363
+ if (moduleWant != null) {
364
+ const bounds = containerBounds(html);
365
+ if (!bounds) fail(`no .decklight container in ${firstPath}`);
366
+ const { modules, spans } = deckModules(html, bounds);
367
+ try { chapter = pickModule(modules, moduleWant); } catch (e) { fail(e.message); }
368
+ html = sliceModule(html, bounds, spans, chapter);
369
+ html = html.replace(/<title>([^<]*)<\/title>/i, (t, was) =>
370
+ `<title>${was.trim() ? `${was.trim()} · ` : ''}${escapeHtml(chapter.title)}</title>`);
371
+ suffix = `-${slug(chapter.title)}`;
372
+ notices.push(`module ${chapter.n} of ${modules.length}: ${chapter.title} — slides ${chapter.offset + 1}–${chapter.offset + chapter.count} of the deck, 1–${chapter.count} in the bundle`);
373
+ }
283
374
  outPath = path.resolve(outPath ||
284
- path.join(deckDir, path.basename(firstPath, '.html') + '-standalone.html'));
375
+ path.join(deckDir, path.basename(firstPath, '.html') + suffix + '.html'));
285
376
  }
286
377
 
378
+ // What went into the file and where each piece came from, said once at the end
379
+ // as two lines — the runtime and the themes — rather than a note per file.
380
+ const fromInstall = new Set(); // decklight.js / decklight.css read from the installed package
287
381
  const read = (rel) => {
288
382
  const p = path.resolve(deckDir, rel);
289
- if (!fs.existsSync(p)) fail(`referenced file not found: ${rel} (${p})`);
290
- return fs.readFileSync(p, 'utf8');
383
+ if (fs.existsSync(p)) return fs.readFileSync(p, 'utf8');
384
+ // A deck that LINKS the runtime ships no decklight.js beside itself: the
385
+ // servers answer it from the installed package, and so does this (#517) —
386
+ // what a bundle carries is what the deck was playing with.
387
+ const asset = packageAsset(rel);
388
+ if (asset) { fromInstall.add(path.basename(rel)); return fs.readFileSync(asset.file, 'utf8'); }
389
+ fail(`referenced file not found: ${rel} (${p})`);
291
390
  };
292
391
 
293
392
  // --------------------------------------------------------------- transforms
@@ -315,47 +414,223 @@ if (transformNames.length) {
315
414
 
316
415
  // ---------------------------------------------------------- theme selection
317
416
 
417
+ // The deck as the author wrote it, before anything is spliced in. The playlist
418
+ // check below reads THIS: the runtime's own source says `playlist:` too, and
419
+ // matching the inlined page flagged every deck that links the runtime.
420
+ const sourceHtml = html;
421
+
422
+ // A deck as data (#520) carries no runtime at all: the servers reference it
423
+ // on the way out, and so does this — the same references, added by the same
424
+ // function — after which it is the linked deck the sections below already
425
+ // know how to flatten. What a bundle embeds is what the deck was playing with.
426
+ const linked = !hasRuntime(html);
427
+ if (linked) {
428
+ html = linkRuntime(html);
429
+ // said in the summary: the source deck carries no runtime of its own
430
+ }
431
+
318
432
  const themeLinkRe = /<link\b[^>]*rel=["']stylesheet["'][^>]*href=["']([^"']*themes\/([\w-]+)\.css)["'][^>]*>/i;
319
433
  const themeLinkM = html.match(themeLinkRe);
320
- if (!themeLinkM) {
434
+ // An imported deck whose theme was derived from the file's own palette embeds
435
+ // that one theme and nothing else (DECK_IMPORT): it has no link to flatten and
436
+ // no runtime yet, and the theme it has is the theme it keeps. An ADDED theme
437
+ // (`data-theme-added`, what `theme add` pasted in before 0.9.0) is not the
438
+ // deck's own: it is an extra over the base theme, and taking it for the base
439
+ // bundled a deck whose only theme was somebody else's.
440
+ const OWN_THEME_STYLE = /<style\b(?![^>]*\bdata-theme-added\b)[^>]*\bdata-theme\b/i;
441
+ const ownTheme = !themeLinkM && linked && OWN_THEME_STYLE.test(html);
442
+ if (!themeLinkM && !ownTheme) {
321
443
  // A deck with its themes already INLINE is the common way to arrive here —
322
444
  // `decklight init` scaffolds one, and the README's own quick start goes
323
445
  // straight from init to bundle. Blaming a missing <link> sends that reader
324
446
  // looking for markup they were never supposed to have, when the honest
325
447
  // answer is that there is nothing left to flatten.
326
- const inlined = /<style\b[^>]*\bdata-theme\b/i.test(html);
448
+ const inlined = OWN_THEME_STYLE.test(html);
327
449
  fail(inlined
328
450
  ? 'this deck is already self-contained — its themes are inline <style data-theme> blocks.\n'
329
451
  + ' bundle is for a deck that REFERENCES dist/ and themes/ by URL; there is nothing here to flatten.\n'
330
452
  + ' to refresh its inlined runtime and themes instead: decklight upgrade <deck.html>'
331
453
  : 'no theme <link> (href matching themes/<name>.css) found in the deck');
332
454
  }
333
- const [themeLinkTag, themeHref, linkedTheme] = themeLinkM;
455
+ const [themeLinkTag, themeHref, linkedTheme] = themeLinkM ?? [null, 'themes/', null];
334
456
  const themesDir = path.resolve(deckDir, path.dirname(themeHref));
457
+ // A linked deck ships no themes/ beside itself: what it links is answered by
458
+ // the installed package when served, and inlined from there here (#517). A
459
+ // folder on disk wins, per theme and for the `all` listing alike.
460
+ const themeFile = (name) => {
461
+ const own = path.join(themesDir, `${name}.css`);
462
+ if (fs.existsSync(own)) return own;
463
+ const shipped = path.join(THEMES_DIR, `${name}.css`);
464
+ return fs.existsSync(shipped) ? shipped : null;
465
+ };
335
466
 
336
467
  let themeNames;
337
- if (themesSel === 'current') {
468
+ if (ownTheme) {
469
+ themeNames = [html.match(/<style\b(?![^>]*\bdata-theme-added\b)[^>]*\bdata-theme\s*=\s*["']([\w-]+)["']/i)?.[1] ?? 'own'];
470
+ if (themesSel !== 'all' && themesSel !== 'current') notices.push('--themes ignored: the deck embeds a theme of its own, and that is the one it keeps');
471
+ } else if (themesSel === 'current') {
338
472
  themeNames = [linkedTheme];
339
473
  } else if (themesSel === 'all') {
340
- themeNames = fs.readdirSync(themesDir).filter((f) => f.endsWith('.css'))
474
+ themeNames = fs.readdirSync(fs.existsSync(themesDir) ? themesDir : THEMES_DIR).filter((f) => f.endsWith('.css'))
341
475
  .map((f) => f.replace(/\.css$/, '')).sort();
342
476
  } else {
343
477
  themeNames = themesSel.split(',').map((s) => s.trim()).filter(Boolean);
344
478
  }
479
+ // The themes the deck MARKS travel with it: resolved from this machine's
480
+ // marketplaces now, inlined below, and never linked — a reference to a
481
+ // marketplace means nothing to whoever opens the file (SPEC THEME_DISTRIBUTION).
482
+ // A marked name is not a file in themes/, so it leaves the shipped list here.
483
+ const markedFrom = markedSources(sourceHtml);
484
+ const marked = markedRefs(sourceHtml).map((r) => {
485
+ const hit = resolveThemeRef(r, undefined, { source: markedFrom[r.marketplace] ?? null });
486
+ if (!hit.file) fail(`the deck marks ${r.ref}, and this machine cannot read it — ${hit.missing}`);
487
+ const valid = stillValid(hit.file);
488
+ if (!valid.ok) fail(`the deck marks ${r.ref}, and ${valid.why}`);
489
+ return hit;
490
+ });
491
+ const markedNames = marked.map((r) => r.name);
492
+ // Design systems (SPEC DESIGN_SYSTEMS) travel like marked themes: resolved
493
+ // from this machine's checkouts now, carried as bytes, never linked. Merged,
494
+ // every module's count — once per name and version; one name at two
495
+ // versions has no single right answer, so it is refused.
496
+ const systems = []; // { ref, name, version, marketplace, block }
497
+ const systemsLeftOut = []; // { ref, why }
498
+ {
499
+ const decks = jobs
500
+ ? jobs.map((j) => ({ label: j.title, html: fs.readFileSync(j.path, 'utf8') }))
501
+ : [{ label: path.basename(firstPath), html: sourceHtml }];
502
+ const byName = new Map();
503
+ for (const d of decks) {
504
+ const from = markedSources(d.html);
505
+ for (const ref of designSystemRefs(d.html)) {
506
+ const r = resolveDesignSystemRef(ref, undefined, { source: from[ref.marketplace] ?? null });
507
+ const verdict = r.dir ? packageVerdict(r.dir) : null;
508
+ // a package that is HERE but broken is its author's bug, never papered over
509
+ if (verdict && !verdict.ok) fail(`the deck uses the design system ${ref.ref}, and ${verdict.why}`);
510
+ const why = r.missing;
511
+ if (why) {
512
+ if (!allowMissingSystems) {
513
+ fail(`the deck uses the design system ${ref.ref}, and this machine cannot read it — ${why}
514
+ `
515
+ + ' (--allow-missing-design-systems bundles without it: its slides render plainly)');
516
+ }
517
+ if (!systemsLeftOut.some((x) => x.ref === ref.ref)) systemsLeftOut.push({ ref: ref.ref, why });
518
+ continue;
519
+ }
520
+ const version = String(verdict.manifest.version ?? '');
521
+ const seen = byName.get(ref.name);
522
+ if (seen) {
523
+ if (seen.version !== version) {
524
+ fail(`two modules use the design system "${ref.name}" at different versions — ${seen.label} has ${seen.version}, ${d.label} has ${version}; one file can carry one`);
525
+ }
526
+ continue;
527
+ }
528
+ let block;
529
+ try { block = bundleDesignSystem(r, verdict); } catch (e) {
530
+ if (e instanceof MarketplaceError) fail(`the design system ${ref.ref}: ${e.message}`);
531
+ throw e;
532
+ }
533
+ byName.set(ref.name, { version, label: d.label });
534
+ systems.push({ ref: ref.ref, name: ref.name, version, marketplace: ref.marketplace, block });
535
+ for (const url of block.external) notices.push(`design system ${ref.ref}: url(${url}) stays external — it will not show offline`);
536
+ }
537
+ }
538
+ for (const x of systemsLeftOut) notices.push(`design system ${x.ref} not carried — ${x.why}; the slides that use it render plainly`);
539
+ }
540
+
541
+ // Fonts (SPEC FONTS) the same way: resolved from the checkouts, carried as
542
+ // bytes, once per name; a font here but broken is refused whatever the flag.
543
+ const fonts = []; // { ref, name, version, marketplace, block }
544
+ const fontsLeftOut = []; // { ref, why }
545
+ {
546
+ const decks = jobs
547
+ ? jobs.map((j) => ({ label: j.title, html: fs.readFileSync(j.path, 'utf8') }))
548
+ : [{ label: path.basename(firstPath), html: sourceHtml }];
549
+ const byName = new Map();
550
+ for (const d of decks) {
551
+ const from = markedSources(d.html);
552
+ for (const ref of fontRefs(d.html)) {
553
+ const r = resolveFontRef(ref, undefined, { source: from[ref.marketplace] ?? null });
554
+ const verdict = r.dir ? fontVerdict(r.dir) : null;
555
+ if (verdict && !verdict.ok) fail(`the deck uses the font ${ref.ref}, and ${verdict.why}`);
556
+ if (r.missing) {
557
+ if (!allowMissingFonts) {
558
+ fail(`the deck uses the font ${ref.ref}, and this machine cannot read it — ${r.missing}\n`
559
+ + ' (--allow-missing-fonts bundles without it: the theme\'s own font stack shows instead)');
560
+ }
561
+ if (!fontsLeftOut.some((x) => x.ref === ref.ref)) fontsLeftOut.push({ ref: ref.ref, why: r.missing });
562
+ continue;
563
+ }
564
+ const version = String(verdict.manifest.version ?? '');
565
+ const seen = byName.get(ref.name);
566
+ if (seen) {
567
+ if (seen.version !== version) fail(`two modules use the font "${ref.name}" at different versions — ${seen.label} has ${seen.version}, ${d.label} has ${version}; one file can carry one`);
568
+ continue;
569
+ }
570
+ byName.set(ref.name, { version, label: d.label });
571
+ fonts.push({ ref: ref.ref, name: ref.name, version, marketplace: ref.marketplace, family: verdict.manifest.family, block: bundleFont(r, verdict) });
572
+ }
573
+ }
574
+ for (const x of fontsLeftOut) notices.push(`font ${x.ref} not carried — ${x.why}; the theme's own font stack shows instead`);
575
+ }
576
+ if (openOn !== null && !/^[\w-]+$/.test(openOn)) fail(`--theme ${JSON.stringify(openOn)} is not a theme name`);
577
+ // a design system's own themes (SPEC BRAND_PALETTE) come in its blocks, like a marked theme's
578
+ const brandNames = systems.flatMap((s) => s.block.brandThemes ?? []);
579
+ const carried = (n) => markedNames.includes(n) || brandNames.includes(n);
580
+ if (openOn && !ownTheme && !carried(openOn) && !themeNames.includes(openOn)) themeNames.push(openOn);
581
+ themeNames = themeNames.filter((n) => !carried(n));
582
+ // A marked SHIPPED theme travels too: embedded beside the one the file opens
583
+ // on, whatever --themes chose, because marking it is how the author said so.
584
+ const markedShippedNames = markedShipped(sourceHtml).filter((n) => !themeNames.includes(n));
585
+ if (!ownTheme) themeNames.push(...markedShippedNames);
345
586
  if (!themeNames.length) fail('no themes selected');
346
- const activeTheme = themeNames.includes(linkedTheme) ? linkedTheme : themeNames[0];
347
- if (activeTheme !== linkedTheme) {
587
+ const activeTheme = openOn && themeNames.includes(openOn) ? openOn
588
+ : themeNames.includes(linkedTheme) ? linkedTheme : themeNames[0];
589
+ if (!ownTheme && activeTheme !== linkedTheme && !openOn) {
348
590
  notices.push(`linked theme "${linkedTheme}" not in --themes list; "${activeTheme}" is active`);
349
591
  }
350
592
 
351
- const themeBlocks = themeNames.map((name) => {
352
- const cssPath = path.join(themesDir, name + '.css');
353
- if (!fs.existsSync(cssPath)) fail(`theme not found: ${name} (${cssPath})`);
593
+ const ownThemeFiles = new Set(); // themes read from a themes/ folder beside the deck
594
+ const themeBlocks = ownTheme ? null : themeNames.map((name) => {
595
+ const cssPath = themeFile(name);
596
+ if (!cssPath) fail(`theme not found: ${name} (${path.join(themesDir, `${name}.css`)}, and not shipped)`);
597
+ if (cssPath.startsWith(themesDir)) ownThemeFiles.add(name);
354
598
  const css = fs.readFileSync(cssPath, 'utf8');
355
599
  const media = name === activeTheme ? '' : ' media="not all"';
356
600
  return `<style data-theme="${name}"${media}>\n${css}\n</style>`;
357
601
  }).join('\n');
358
- html = html.replace(themeLinkTag, themeBlocks);
602
+ if (themeBlocks !== null) html = html.replace(themeLinkTag, themeBlocks);
603
+ // A deck that keeps a theme of its own (DECK_IMPORT) carries marked shipped
604
+ // themes as further inline blocks, off until picked.
605
+ if (ownTheme && markedShippedNames.length) {
606
+ const extra = markedShippedNames.map((name) => {
607
+ const cssPath = themeFile(name);
608
+ if (!cssPath) fail(`theme not found: ${name}`);
609
+ return `<style data-theme="${name}" media="not all">\n${fs.readFileSync(cssPath, 'utf8')}\n</style>`;
610
+ }).join('\n');
611
+ const headEnd = html.search(/<\/head>/i);
612
+ html = headEnd === -1 ? `${extra}\n${html}` : `${html.slice(0, headEnd)}${extra}\n${html.slice(headEnd)}`;
613
+ }
614
+ if (marked.length) {
615
+ const blocks = marked.map((r) => addedThemeStyle(r, fs.readFileSync(r.file, 'utf8'))).join('\n');
616
+ const headEnd = html.search(/<\/head>/i);
617
+ html = headEnd === -1 ? `${blocks}\n${html}` : `${html.slice(0, headEnd)}${blocks}\n${html.slice(headEnd)}`;
618
+ }
619
+ // The theme the bundle opens on is the configured one, and the runtime reads
620
+ // it from the configuration block — so `--theme` is written THERE, which is
621
+ // what makes a marked theme (an added block, not an inline one) the one a
622
+ // double-clicked file opens on.
623
+ if (openOn) {
624
+ const block = configBlock(html);
625
+ if (block?.config) {
626
+ const inner = /"theme"\s*:\s*"[^"]*"/.test(block.inner)
627
+ ? block.inner.replace(/"theme"\s*:\s*"[^"]*"/, `"theme": ${JSON.stringify(openOn)}`)
628
+ : block.inner.replace('{', `{ "theme": ${JSON.stringify(openOn)},`);
629
+ html = html.slice(0, block.innerStart) + inner + html.slice(block.innerEnd);
630
+ } else if (carried(openOn)) {
631
+ fail(`--theme ${openOn}: the deck has no configuration block to open it from`);
632
+ }
633
+ }
359
634
 
360
635
  // ------------------------------------------------- structure stylesheet(s)
361
636
 
@@ -409,10 +684,14 @@ html = html.replace(
409
684
  // ------------------------------------------------------------ runtime script
410
685
 
411
686
  html = html.replace(
412
- /<script\b[^>]*src=["']([^"']+)["'][^>]*>\s*<\/script>/gi,
413
- (tag, src) => {
687
+ /<script\b([^>]*)src=["']([^"']+)["']([^>]*)>\s*<\/script>/gi,
688
+ (tag, pre, src, post) => {
414
689
  if (/^(https?:)?\/\//.test(src)) { notices.push(`external script kept as src: ${src}`); return tag; }
415
- return `<script>\n${inlineRuntime(read(src))}\n</script>`;
690
+ // the runtime's marker rides along (#520): a bundle that boots from its
691
+ // configuration block has no init call for the audit and upgrade to
692
+ // locate the engine by, so the mark is how they find it
693
+ const marked = /\bdata-decklight-runtime\s*=\s*["']js["']/i.test(pre + post) ? ' data-decklight-runtime="js"' : '';
694
+ return `<script${marked}>\n${inlineRuntime(read(src))}\n</script>`;
416
695
  });
417
696
 
418
697
  // ------------------------------------------------------------------- casts
@@ -439,8 +718,9 @@ html = html.replace(
439
718
  // 50–150 MB), same posture as playlist links.
440
719
  {
441
720
  const seen = new Set();
721
+ // `dir: 'voices'` in a boot call, `"dir": "voices"` in a configuration block
442
722
  const narrDirs = [...new Set(
443
- [...html.matchAll(/\b(?:dir|files)\s*:\s*['"]([^'"]+)['"]/g)].map((m) => m[1]))];
723
+ [...html.matchAll(/\b(?:dir|files)["']?\s*:\s*['"]([^'"]+)['"]/g)].map((m) => m[1]))];
444
724
  for (const d of narrDirs) {
445
725
  const abs = path.resolve(deckDir, d);
446
726
  if (!fs.existsSync(abs) || !fs.statSync(abs).isDirectory()) continue;
@@ -454,6 +734,11 @@ html = html.replace(
454
734
  if (vm) {
455
735
  // vm[1] is the whole STEM (`slide-07`, `slide-07-02`) — the same name
456
736
  // the runtime looks the block up by, so the two cannot drift apart.
737
+ if (chapter) {
738
+ // the chapter's own timelines, under the slide number the bundle asks for
739
+ vm[1] = renumber(vm[1], chapter);
740
+ if (!vm[1]) continue;
741
+ }
457
742
  if (seen.has(vm[1])) {
458
743
  notices.push(`character visemes: ${d}/${f} skipped — ${vm[1]} already inlined from another track`);
459
744
  continue;
@@ -463,14 +748,16 @@ html = html.replace(
463
748
  + `${scriptSafe(fs.readFileSync(path.join(abs, f), 'utf8'))}\n</script>`);
464
749
  } else if (/^slide-\d+\.mp4$/.test(f)) mp4s++;
465
750
  }
466
- if (mp4s) {
751
+ if (mp4s && chapter) {
752
+ notices.push(`character video: ${mp4s} slide-NN.mp4 in ${d}/ are numbered for the whole deck and stay external — the chapter's character plays from its visemes`);
753
+ } else if (mp4s) {
467
754
  notices.push(`character video: ${mp4s} slide-NN.mp4 in ${d}/ stay external — ship the folder next to the bundle`);
468
755
  }
469
756
  }
470
757
  if (seen.size) {
471
758
  const beats = [...seen].filter((k) => /^slide-\d+-\d+$/.test(k)).length;
472
759
  notices.push(`character visemes: inlined ${seen.size} timeline(s)`
473
- + (beats ? ` (${seen.size - beats} slides + ${beats} ⟨CLICK⟩ beats)` : ''));
760
+ + (beats ? ` (${seen.size - beats} slides + ${beats} [click] beats)` : ''));
474
761
  }
475
762
  }
476
763
 
@@ -484,21 +771,81 @@ html = html.replace(
484
771
  // the manifest, and inlining it would undo the feature.
485
772
  {
486
773
  let n = 0;
774
+ // `manifest: '…'` in a boot call, `"manifest": "…"` in a configuration block
487
775
  const manifests = [...new Set(
488
- [...html.matchAll(/\bmanifest\s*:\s*['"]([^'"]+)['"]/g)].map((m) => m[1]))];
776
+ [...html.matchAll(/\bmanifest["']?\s*:\s*['"]([^'"]+)['"]/g)].map((m) => m[1]))];
489
777
  for (const rel of manifests) {
490
778
  const abs = path.resolve(deckDir, rel);
491
779
  if (!fs.existsSync(abs) || !fs.statSync(abs).isFile()) {
492
780
  notices.push(`narration manifest: ${rel} not found — the bundle will fetch it at runtime`);
493
781
  continue;
494
782
  }
783
+ let text = fs.readFileSync(abs, 'utf8');
784
+ if (chapter) {
785
+ // the manifest is indexed by slide: cut it to the chapter's
786
+ try { text = JSON.stringify(sliceManifest(JSON.parse(text), chapter), null, 1); } catch { /* not JSON: inlined as it is */ }
787
+ }
495
788
  embeds.push(`<script type="application/json" data-decklight-voices="${rel.replace(/"/g, '&quot;')}">\n`
496
- + `${scriptSafe(fs.readFileSync(abs, 'utf8'))}\n</script>`);
789
+ + `${scriptSafe(text)}\n</script>`);
497
790
  n++;
498
791
  }
499
792
  if (n) notices.push(`narration: inlined ${n} voice manifest(s) — the audio stays in its bucket`);
500
793
  }
501
794
 
795
+ // ------------------------------------------------------ narration audio
796
+
797
+ // A recorded track's audio is the one part of a deck too big to carry by
798
+ // default: a slide's clip is half a megabyte to a few, a talk's worth tens,
799
+ // and base64 adds a third. So it stays beside the deck unless asked for:
800
+ // `--audio` carries it inside as recorded, `--audio aac` / `--audio opus`
801
+ // re-encoded small (cli/bundle-audio.mjs). Either way the bundle says which
802
+ // files it left out or took in.
803
+ let audioEstimate = null;
804
+ {
805
+ const { found, remote, folders } = narrationAudio(html, deckDir, chapter);
806
+ if (estimate) {
807
+ if (found.size) audioEstimate = { ...(await estimateAudio(found)), folders };
808
+ } else if (found.size && audioChoice) {
809
+ let carried;
810
+ try { carried = await inlineAudio(found, audioChoice); } catch (e) { fail(e.message); }
811
+ embeds.push(...carried.blocks);
812
+ notices.push(`narration audio: inlined ${found.size} file(s), ${sizeLabel(carried.bytes)}`
813
+ + `${CODECS[audioChoice] ? ` (re-encoded from ${sizeLabel(carried.before)}, ${CODECS[audioChoice].label})` : ''}, from ${folders}`);
814
+ } else if (found.size) {
815
+ notices.push(`narration audio: ${found.size} file(s) stay beside the deck, in ${folders} — ship them next to the bundle, or bundle with --audio [original|aac|opus] to carry them inside`);
816
+ }
817
+ if (remote && audioChoice) notices.push(`narration audio: ${remote} manifest file(s) live at a URL and stay there`);
818
+ }
819
+
820
+ // -------------------------------------------------------- design systems
821
+
822
+ // The stylesheets where every server links them — the end of <head>, after
823
+ // the themes, so the cascade is the one the author saw — and the meta and
824
+ // layouts before the runtime too: classic scripts execute mid-parse, so they
825
+ // must be in the document when the engine looks for them.
826
+ if (systems.length) {
827
+ const at = (withScript) => {
828
+ const masked = html.replace(/<!--[\s\S]*?-->/g, (m) => ' '.repeat(m.length));
829
+ const marks = [masked.search(/<\/head>/i), withScript ? firstExecutableScript(html) ?? -1 : -1].filter((i) => i !== -1);
830
+ return marks.length ? Math.min(...marks) : 0;
831
+ };
832
+ const insert = (i, tags) => { html = `${html.slice(0, i)}${tags.join('\n')}\n${html.slice(i)}`; };
833
+ insert(at(true), systems.flatMap((x) => x.block.tags.slice(1)));
834
+ insert(at(false), systems.map((x) => x.block.tags[0]));
835
+ }
836
+ // The fonts the same way: their @font-face at the end of <head>, where the
837
+ // servers link them, their meta before the runtime reads it.
838
+ if (fonts.length) {
839
+ const at = (withScript) => {
840
+ const masked = html.replace(/<!--[\s\S]*?-->/g, (m) => ' '.repeat(m.length));
841
+ const marks = [masked.search(/<\/head>/i), withScript ? firstExecutableScript(html) ?? -1 : -1].filter((i) => i !== -1);
842
+ return marks.length ? Math.min(...marks) : 0;
843
+ };
844
+ const insert = (i, tags) => { html = `${html.slice(0, i)}${tags.join('\n')}\n${html.slice(i)}`; };
845
+ insert(at(true), fonts.map((x) => x.block.tags[1]));
846
+ insert(at(false), fonts.map((x) => x.block.tags[0]));
847
+ }
848
+
502
849
  // -------------------------------------------------------------- assemble
503
850
 
504
851
  if (embeds.length) {
@@ -508,9 +855,9 @@ if (embeds.length) {
508
855
  }
509
856
 
510
857
  if (!jobs) {
511
- const playlistM = html.match(/playlist\s*:/);
858
+ const playlistM = sourceHtml.match(/playlist\s*:/);
512
859
  if (playlistM) {
513
- const hrefs = [...html.matchAll(/href:\s*['"]([^'"]+\.html)['"]/g)].map((m) => m[1]);
860
+ const hrefs = [...sourceHtml.matchAll(/href:\s*['"]([^'"]+\.html)['"]/g)].map((m) => m[1]);
514
861
  notices.push('deck has a playlist — cross-file module links cannot resolve inside a single file:' +
515
862
  (hrefs.length ? '\n ' + [...new Set(hrefs)].join('\n ') : ''));
516
863
  }
@@ -520,6 +867,10 @@ if (!jobs) {
520
867
  // (INTEGRITY#SIGNING): a failed signature must leave no artifact behind, or
521
868
  // the unsigned file sitting there afterwards gets picked up later and sent as
522
869
  // though it were finished. Bytes, not a path, for exactly this reason.
870
+ // An estimate (the edit server's bundle card) stops here: the file as it
871
+ // would be without its audio, and what each way of carrying the audio adds.
872
+ if (estimate) return { base: Buffer.byteLength(html, 'utf8'), audio: audioEstimate };
873
+
523
874
  let bundleSig = null;
524
875
  if (sign) {
525
876
  const { signBytes } = await import('./sign.mjs');
@@ -531,7 +882,59 @@ if (sign) {
531
882
  fs.writeFileSync(outPath, html);
532
883
  const kb = (fs.statSync(outPath).size / 1024).toFixed(1);
533
884
  const what = jobs ? `${jobs.length} modules` : path.basename(firstPath);
534
- process.stdout.write(`bundled ${what} → ${outPath} (${kb} KB, themes: ${themeNames.join(', ')}; active: ${activeTheme})\n`);
885
+ process.stdout.write(`bundled ${what} → ${outPath} (${kb} KB)\n`);
886
+ // The runtime: where the copy in the file came from. A deck that is data (#520)
887
+ // carries none — which reads like a warning unless it says it is the SOURCE deck
888
+ // that carried none, and the file that has one.
889
+ const runtimeFrom = linked ? 'embedded from this install (the source deck carries no runtime)'
890
+ : fromInstall.has('decklight.js') ? 'embedded from this install (the source deck links it)'
891
+ : "embedded from the source deck's own copy";
892
+ process.stdout.write(` runtime decklight ${PKG.version} — ${runtimeFrom}\n`);
893
+ // The themes: the one it opens on, the others it can switch to, and why each
894
+ // is there — marked, or asked for with --themes — and where one came from when
895
+ // it was not this install (a themes/ folder beside the deck, a marketplace).
896
+ {
897
+ // a brand theme opens on top of the base, which is then the one embedded as active
898
+ const opening = (openOn && !brandNames.includes(openOn) ? openOn : null) ?? (ownTheme ? themeNames[0] : activeTheme);
899
+ const tagged = (n, ...why) => {
900
+ const bits = [...why, ownThemeFiles.has(n) ? 'own file' : null].filter(Boolean);
901
+ return bits.length ? `${n} (${bits.join(', ')})` : n;
902
+ };
903
+ const parts = [tagged(opening, 'opens on', ownTheme ? 'its own' : null)];
904
+ const chosen = themeNames.filter((n) => n !== opening && !markedShippedNames.includes(n));
905
+ if (chosen.length) parts.push(chosen.map((n) => tagged(n)).join(', '));
906
+ const shippedMarked = markedShippedNames.filter((n) => n !== opening);
907
+ if (shippedMarked.length) parts.push(`${shippedMarked.join(', ')} (marked)`);
908
+ const byMarket = new Map();
909
+ for (const r of marked) {
910
+ const m = r.ref.split('@')[1];
911
+ byMarket.set(m, [...(byMarket.get(m) ?? []), r.name]);
912
+ }
913
+ for (const [m, names] of byMarket) parts.push(`${names.join(', ')} (marked, from ${m})`);
914
+ // the design systems' own themes, and the one it opens on when that is one of them
915
+ const opensBrand = [openOn, configTheme(html)].find((n) => n && brandNames.includes(n));
916
+ if (opensBrand) parts[0] = tagged(opening, 'under it');
917
+ for (const s of systems) {
918
+ const names = s.block.brandThemes ?? [];
919
+ if (names.length) parts.push(`${names.map((n) => (n === opensBrand ? `${n} (opens on)` : n)).join(', ')} (${s.name}'s own)`);
920
+ }
921
+ process.stdout.write(` themes ${parts.join(' · ')}\n`);
922
+ }
923
+ // The design systems: name, version, the catalog it came from, what went in.
924
+ if (systems.length || systemsLeftOut.length) {
925
+ const parts = systems.map(({ name, version, marketplace, block }) => {
926
+ const assets = block.assets ? `, ${block.assets} asset${block.assets === 1 ? '' : 's'} (${(block.bytes / 1024).toFixed(1)} KB)` : '';
927
+ return `${name} ${version} (from ${marketplace}) — stylesheet${assets}, ${block.templates} template${block.templates === 1 ? '' : 's'}`;
928
+ });
929
+ for (const x of systemsLeftOut) parts.push(`${x.ref} — not carried`);
930
+ process.stdout.write(` designs ${parts.join(' · ')}\n`);
931
+ }
932
+ if (fonts.length || fontsLeftOut.length) {
933
+ const parts = fonts.map(({ name, version, marketplace, family, block }) =>
934
+ `${name} ${version} (from ${marketplace}) — '${family}', ${block.faces} face${block.faces === 1 ? '' : 's'} (${(block.bytes / 1024).toFixed(1)} KB)`);
935
+ for (const x of fontsLeftOut) parts.push(`${x.ref} — not carried`);
936
+ process.stdout.write(` fonts ${parts.join(' · ')}\n`);
937
+ }
535
938
  if (bundleSig) {
536
939
  const { writeSidecar, verifyBytes, formatSignature } = await import('./sign.mjs');
537
940
  const sidecar = writeSidecar(outPath, bundleSig);
@@ -558,6 +961,7 @@ if (bundleSig) {
558
961
  }
559
962
  }
560
963
  for (const n of notices) process.stdout.write(`note: ${n}\n`);
964
+ if (report) Object.assign(report, { out: outPath, notices });
561
965
  }
562
966
 
563
967
  if (isMain(import.meta.url)) process.exitCode = await runMain('bundle', bundleMain);