vizmatic 0.4.0 → 0.6.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 (149) hide show
  1. package/PROMPT.md +75 -531
  2. package/README.md +85 -1052
  3. package/ROADMAP.md +49 -67
  4. package/SCIENCE.md +250 -0
  5. package/assets/THIRD_PARTY_LICENSES.md +44 -1
  6. package/assets/fonts/InstrumentSerif-Italic.ttf +0 -0
  7. package/assets/fonts/InstrumentSerif-Regular.ttf +0 -0
  8. package/assets/fonts/SourceSerif4-24pt-Italic.ttf +0 -0
  9. package/assets/fonts/SourceSerif4-24pt-Regular.ttf +0 -0
  10. package/assets/licenses/raster-codecs-MIT.txt +74 -0
  11. package/dist/chunk-3F2VQ7NW.js +1 -0
  12. package/dist/{chunk-FEIPTPBZ.js → chunk-4XE64I2U.js} +53 -463
  13. package/dist/chunk-5ZAFH2JC.js +4231 -0
  14. package/dist/chunk-JHHPLALU.js +79 -0
  15. package/dist/chunk-LTX44BAE.js +112 -0
  16. package/dist/chunk-MLKGABMK.js +9 -0
  17. package/dist/chunk-PSBF4TEK.js +1 -0
  18. package/dist/chunk-RPAHMKAR.js +605 -0
  19. package/dist/chunk-RWF4VBUL.js +3617 -0
  20. package/dist/cli.js +369 -12
  21. package/dist/index.cjs +7413 -1810
  22. package/dist/index.d.cts +900 -599
  23. package/dist/index.d.ts +900 -599
  24. package/dist/index.js +5019 -3278
  25. package/dist/math-LXB4FH4E.js +7 -0
  26. package/dist/math-QVCETQDQ.js +1 -0
  27. package/dist/scene-browser-assets.d.ts +38 -0
  28. package/dist/scene-browser-assets.js +53 -0
  29. package/dist/scene-browser-chunks/chunk-5MVLYGXM.js +70 -0
  30. package/dist/scene-browser-chunks/chunk-ASXKN3NU.js +1 -0
  31. package/dist/scene-browser-chunks/chunk-CM5Y5LZP.js +1 -0
  32. package/dist/scene-browser-chunks/chunk-DP7NB4EW.js +6 -0
  33. package/dist/scene-browser-chunks/emscripten-module.browser-M5AEKJGE.js +1 -0
  34. package/dist/scene-browser-chunks/ffi-FL6ORJU3.js +1 -0
  35. package/dist/scene-browser-chunks/module-ES6BEMUI-JD5S5VKR.js +1 -0
  36. package/dist/scene-browser-chunks/module-asyncify-2EFITU5U-HWPFJFJC.js +1 -0
  37. package/dist/scene-browser-chunks/scene-browser-layout-M3XSXMV4.js +27 -0
  38. package/dist/scene-browser.d.ts +117 -0
  39. package/dist/scene-browser.js +220 -0
  40. package/dist/scene-cli.js +1 -1
  41. package/dist/scene-runtime.cjs +168 -103
  42. package/dist/scene-runtime.d.cts +3 -2
  43. package/dist/scene-runtime.d.ts +3 -2
  44. package/dist/scene-runtime.js +3 -1
  45. package/dist/server-2FYHZ4UO.js +331 -0
  46. package/dist/stage-browser/browser.d.ts +2483 -0
  47. package/dist/stage-browser/chunk-SQE76S5B.js +1 -0
  48. package/dist/stage-browser/chunk-VZNL6JY2.js +59 -0
  49. package/dist/stage-browser/dagre.esm-N2NIVIAZ.js +6 -0
  50. package/dist/stage-browser/math-4WFNHVV2.js +18 -0
  51. package/dist/stage-browser/stage.js +19 -0
  52. package/dist/stage-export.cjs +4980 -0
  53. package/dist/stage-export.d.cts +112 -0
  54. package/dist/stage-export.d.ts +112 -0
  55. package/dist/stage-export.js +544 -0
  56. package/dist/stage.cjs +9789 -0
  57. package/dist/stage.d.cts +1679 -0
  58. package/dist/stage.d.ts +1679 -0
  59. package/dist/stage.js +5418 -0
  60. package/dist/svg-import-Djj2q7Pc.d.cts +742 -0
  61. package/dist/svg-import-Djj2q7Pc.d.ts +742 -0
  62. package/dist/video-CcHW1qhV.d.cts +532 -0
  63. package/dist/video-CcHW1qhV.d.ts +532 -0
  64. package/examples/README.md +18 -0
  65. package/examples/agent-pipeline.tsx +4 -4
  66. package/examples/animated-pipeline.tsx +1 -5
  67. package/examples/attention-head.tsx +12 -12
  68. package/examples/aurora-incident.tsx +4 -3
  69. package/examples/building-blocks.tsx +8 -9
  70. package/examples/catalog-charts.tsx +4 -4
  71. package/examples/catalog-content.tsx +7 -9
  72. package/examples/catalog-convolution-kernel.tsx +116 -0
  73. package/examples/catalog-data.tsx +2 -8
  74. package/examples/catalog-dataflow.tsx +5 -9
  75. package/examples/catalog-dense.tsx +80 -0
  76. package/examples/catalog-deployment.tsx +5 -11
  77. package/examples/catalog-diagrams.tsx +13 -16
  78. package/examples/catalog-drawing.tsx +7 -7
  79. package/examples/catalog-flows.tsx +4 -4
  80. package/examples/catalog-foundations.tsx +11 -11
  81. package/examples/catalog-gaussian-blur.tsx +146 -0
  82. package/examples/catalog-image-tensors.tsx +115 -0
  83. package/examples/catalog-ml.tsx +36 -31
  84. package/examples/catalog-numeric-matrices.tsx +93 -0
  85. package/examples/catalog-photo-blur.tsx +209 -0
  86. package/examples/catalog-science-ai.tsx +130 -0
  87. package/examples/catalog-science-chemistry.tsx +103 -0
  88. package/examples/catalog-science-math.tsx +93 -0
  89. package/examples/catalog-science-physics.tsx +84 -0
  90. package/examples/catalog-sequence.tsx +59 -38
  91. package/examples/data-pipeline-lineage-presentation.tsx +5 -0
  92. package/examples/data-pipeline-lineage.tsx +85 -0
  93. package/examples/daybreak-launch.tsx +1 -0
  94. package/examples/desired-quadrant.tsx +7 -8
  95. package/examples/engineering-dashboard-presentation.tsx +13 -0
  96. package/examples/engineering-dashboard.tsx +160 -0
  97. package/examples/engineering-flow.tsx +2 -4
  98. package/examples/eval-dashboard.tsx +6 -6
  99. package/examples/films/attention.ts +278 -0
  100. package/examples/films/cache-miss.ts +431 -0
  101. package/examples/films/catalog.json +132 -0
  102. package/examples/films/central-limit.ts +269 -0
  103. package/examples/films/complex-maps.ts +273 -0
  104. package/examples/films/deck-example.ts +224 -0
  105. package/examples/films/euler-circle.ts +179 -0
  106. package/examples/films/fourier-epicycles.ts +265 -0
  107. package/examples/films/gradient-descent.ts +345 -0
  108. package/examples/films/linear-maps.ts +175 -0
  109. package/examples/films/lorenz.ts +207 -0
  110. package/examples/films/pythagoras.ts +185 -0
  111. package/examples/films/taylor-series.ts +159 -0
  112. package/examples/films/vizmatic-title.ts +117 -0
  113. package/examples/llm-serving-stack-presentation.tsx +5 -0
  114. package/examples/llm-serving-stack.tsx +94 -0
  115. package/examples/model-garden.tsx +1 -0
  116. package/examples/model-router.tsx +6 -6
  117. package/examples/nccl-all-gather.tsx +3 -3
  118. package/examples/nccl-all-reduce.tsx +3 -3
  119. package/examples/nccl-all-to-all.tsx +1 -1
  120. package/examples/nccl-broadcast.tsx +1 -1
  121. package/examples/nccl-reduce-scatter.tsx +5 -5
  122. package/examples/orthogonal-routing.tsx +4 -4
  123. package/examples/pareto-frontier.tsx +9 -10
  124. package/examples/presentation-frame.tsx +6 -6
  125. package/examples/production-system-map-presentation.tsx +5 -0
  126. package/examples/production-system-map.tsx +130 -0
  127. package/examples/rag-graph.tsx +7 -7
  128. package/examples/release-card.tsx +5 -5
  129. package/examples/spec-anatomy.tsx +5 -5
  130. package/examples/system-architecture.tsx +19 -32
  131. package/examples/theme-system.tsx +1 -1
  132. package/examples/token-matrix.tsx +4 -2
  133. package/examples/transparent-badge.tsx +1 -2
  134. package/examples/videos/README.md +36 -2
  135. package/examples/videos/calculus-tangent.tsx +101 -0
  136. package/examples/videos/catalyst-pathway.tsx +56 -0
  137. package/examples/videos/causal-attention.tsx +91 -0
  138. package/examples/videos/convolution-kernel.tsx +34 -0
  139. package/examples/videos/gaussian-blur.tsx +32 -0
  140. package/examples/videos/image-to-matrix.tsx +22 -0
  141. package/examples/videos/matrix-multiplication.tsx +128 -0
  142. package/examples/videos/photo-gaussian-blur.tsx +39 -0
  143. package/examples/videos/wave-interference.tsx +80 -0
  144. package/examples/vizmatic-bare.d.ts +1 -0
  145. package/examples/vizmatic-hero.tsx +9 -18
  146. package/examples/website-workflow.tsx +7 -7
  147. package/examples/weekend-field-notes.tsx +3 -2
  148. package/package.json +65 -11
  149. package/dist/chunk-TH3F4SDB.js +0 -79
@@ -1,8 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
1
+ import {
2
+ getThemeColors
3
+ } from "./chunk-RPAHMKAR.js";
6
4
 
7
5
  // src/scene-runtime.ts
8
6
  import { getQuickJS } from "quickjs-emscripten";
@@ -151,447 +149,11 @@ function findBareRootJsxStart(source, allowNativeTags = false) {
151
149
  return -1;
152
150
  }
153
151
 
154
- // src/theme.ts
155
- import parseCssColor from "parse-css-color";
156
- var darkColors = {
157
- // Canvas backgrounds
158
- bg: "#151620",
159
- bgCard: "#1a1b26",
160
- bgCardAlt: "#1e2030",
161
- bgHover: "#24253a",
162
- bgSubtle: "#151620",
163
- // Brand / semantic colors (matches Mermaid palette)
164
- primary: "#7c3aed",
165
- // Purple — key/highlighted components
166
- primaryLight: "#a78bfa",
167
- primaryDark: "#6d28d9",
168
- secondary: "#2563eb",
169
- // Blue — supporting elements
170
- secondaryLight: "#60a5fa",
171
- secondaryDark: "#1d4ed8",
172
- positive: "#059669",
173
- // Green — output/success
174
- positiveLight: "#34d399",
175
- positiveDark: "#047857",
176
- warning: "#d97706",
177
- // Amber — warnings
178
- warningLight: "#fbbf24",
179
- warningDark: "#b45309",
180
- critical: "#dc2626",
181
- // Red — errors/bottlenecks
182
- criticalLight: "#f87171",
183
- criticalDark: "#b91c1c",
184
- info: "#06b6d4",
185
- // Cyan — informational
186
- infoLight: "#22d3ee",
187
- infoDark: "#0891b2",
188
- accent: "#f472b6",
189
- // Pink — accents
190
- accentLight: "#f9a8d4",
191
- neutral: "#334155",
192
- // Slate — infrastructure/background
193
- neutralLight: "#475569",
194
- neutralDark: "#1e293b",
195
- // Text
196
- textPrimary: "#f1f5f9",
197
- textSecondary: "#94a3b8",
198
- textMuted: "#8493a8",
199
- textOnColor: "#ffffff",
200
- // Borders
201
- border: "#334155",
202
- borderSubtle: "#1e293b",
203
- borderLight: "#475569",
204
- shadow: "rgba(0, 0, 0, 0.24)"
205
- };
206
- var lightColors = {
207
- // Canvas backgrounds
208
- bg: "#f5f7fa",
209
- bgCard: "#f8fafc",
210
- bgCardAlt: "#f1f5f9",
211
- bgHover: "#e2e8f0",
212
- bgSubtle: "#f5f7fa",
213
- // Brand / semantic colors (same hues, adjusted for light bg)
214
- primary: "#7c3aed",
215
- primaryLight: "#8b5cf6",
216
- primaryDark: "#6d28d9",
217
- secondary: "#2563eb",
218
- secondaryLight: "#3b82f6",
219
- secondaryDark: "#1d4ed8",
220
- positive: "#059669",
221
- positiveLight: "#10b981",
222
- positiveDark: "#047857",
223
- warning: "#d97706",
224
- warningLight: "#f59e0b",
225
- warningDark: "#b45309",
226
- critical: "#dc2626",
227
- criticalLight: "#ef4444",
228
- criticalDark: "#b91c1c",
229
- info: "#0891b2",
230
- infoLight: "#06b6d4",
231
- infoDark: "#0e7490",
232
- accent: "#ec4899",
233
- accentLight: "#f472b6",
234
- neutral: "#cbd5e1",
235
- neutralLight: "#94a3b8",
236
- neutralDark: "#e2e8f0",
237
- // Text
238
- textPrimary: "#0f172a",
239
- textSecondary: "#475569",
240
- textMuted: "#5b677a",
241
- textOnColor: "#ffffff",
242
- // Borders
243
- border: "#e2e8f0",
244
- borderSubtle: "#e2e8f0",
245
- borderLight: "#cbd5e1",
246
- shadow: "rgba(15, 23, 42, 0.12)"
247
- };
248
- var defaultStyleTokens = {
249
- preset: "default",
250
- fontSans: "Inter",
251
- fontMono: "JetBrains Mono"
252
- };
253
- var engineeringColors = {
254
- ...lightColors,
255
- bg: "#f4f4f5",
256
- bgCard: "#ffffff",
257
- bgCardAlt: "#ececee",
258
- bgHover: "#e4e4e7",
259
- bgSubtle: "#eeeeef",
260
- primary: "#632ca6",
261
- primaryLight: "#6d28d9",
262
- primaryDark: "#4c1d95",
263
- secondary: "#124fc7",
264
- secondaryLight: "#1556d1",
265
- secondaryDark: "#123d96",
266
- positive: "#087a55",
267
- positiveLight: "#0a8060",
268
- positiveDark: "#05543c",
269
- warning: "#c96c00",
270
- warningLight: "#d97800",
271
- warningDark: "#9a4f00",
272
- critical: "#b83232",
273
- criticalLight: "#c43d3d",
274
- criticalDark: "#8f2626",
275
- info: "#0b7185",
276
- infoLight: "#0d7d92",
277
- infoDark: "#075565",
278
- accent: "#a83c76",
279
- accentLight: "#b74583",
280
- neutral: "#52525b",
281
- neutralLight: "#71717a",
282
- neutralDark: "#3f3f46",
283
- textPrimary: "#101012",
284
- textSecondary: "#3f3f46",
285
- textMuted: "#68686f",
286
- textOnColor: "#ffffff",
287
- border: "#3f3f46",
288
- borderSubtle: "#d4d4d8",
289
- borderLight: "#a1a1aa",
290
- shadow: "rgba(0, 0, 0, 0)"
291
- };
292
- function getThemeColors(mode, preset = "default") {
293
- if (preset === "engineering") {
294
- return {
295
- ...engineeringColors,
296
- preset,
297
- fontSans: "Inter",
298
- fontMono: "JetBrains Mono"
299
- };
300
- }
301
- return {
302
- ...mode === "light" ? lightColors : darkColors,
303
- ...defaultStyleTokens
304
- };
305
- }
306
- var colors = {
307
- ...darkColors,
308
- ...defaultStyleTokens
309
- };
310
- var gradients = {
311
- purple: "linear-gradient(135deg, #7c3aed, #a855f7)",
312
- blue: "linear-gradient(135deg, #2563eb, #60a5fa)",
313
- green: "linear-gradient(135deg, #059669, #34d399)",
314
- warm: "linear-gradient(135deg, #f59e0b, #ef4444)",
315
- cyan: "linear-gradient(135deg, #06b6d4, #22d3ee)",
316
- pink: "linear-gradient(135deg, #ec4899, #f472b6)",
317
- sunset: "linear-gradient(135deg, #f97316, #db2777)",
318
- ocean: "linear-gradient(135deg, #0284c7, #7c3aed)",
319
- dark: "linear-gradient(180deg, #0f1117, #1a1b26)"
320
- };
321
- var toneGradients = {
322
- blue: gradients.blue,
323
- purple: gradients.purple,
324
- green: gradients.green,
325
- warm: gradients.warm,
326
- cyan: gradients.cyan,
327
- pink: gradients.pink,
328
- red: gradients.warm,
329
- critical: gradients.warm,
330
- neutral: gradients.dark,
331
- sunset: gradients.sunset,
332
- ocean: gradients.ocean,
333
- dark: gradients.dark
334
- };
335
- function getToneGradient(tone) {
336
- return toneGradients[tone];
337
- }
338
- function getToneColor(tone, c) {
339
- return {
340
- blue: c.secondaryLight,
341
- purple: c.primaryLight,
342
- green: c.positiveLight,
343
- warm: c.warningLight,
344
- cyan: c.infoLight,
345
- pink: c.accentLight,
346
- red: c.criticalLight,
347
- critical: c.criticalLight,
348
- neutral: c.textSecondary,
349
- sunset: c.warningLight,
350
- ocean: c.infoLight,
351
- dark: c.textSecondary
352
- }[tone];
353
- }
354
- function getReadableToneColor(tone, c, background = c.bgCard, backdrop = c.bgCard) {
355
- const semanticColor = {
356
- blue: "secondary",
357
- purple: "primary",
358
- green: "positive",
359
- warm: "warning",
360
- cyan: "info",
361
- pink: "accent",
362
- red: "critical",
363
- critical: "critical",
364
- neutral: "neutral",
365
- sunset: "warning",
366
- ocean: "info",
367
- dark: "neutral"
368
- };
369
- const color = getReadableColor(semanticColor[tone], c);
370
- return colorContrast(color, background, backdrop) >= 4.5 ? color : getReadableTextColor(background, c, backdrop);
371
- }
372
- function getToneFill(tone, c) {
373
- if (c.preset !== "engineering") return withColorAlpha(getToneColor(tone, c), 22 / 255);
374
- return {
375
- blue: "#cddcfa",
376
- purple: "#dfcff8",
377
- green: "#d5ede4",
378
- warm: "#fde7ce",
379
- cyan: "#d7edf1",
380
- pink: "#f3d9e7",
381
- red: "#f4d7d7",
382
- critical: "#f4d7d7",
383
- neutral: "#e4e4e7",
384
- sunset: "#fde1d6",
385
- ocean: "#d8e2f6",
386
- dark: "#dedee2"
387
- }[tone];
388
- }
389
- var typography = {
390
- title: { fontSize: 28, fontWeight: 700, fontFamily: "Inter" },
391
- subtitle: { fontSize: 20, fontWeight: 600, fontFamily: "Inter" },
392
- label: { fontSize: 16, fontWeight: 600, fontFamily: "Inter" },
393
- body: { fontSize: 14, fontWeight: 400, fontFamily: "Inter" },
394
- small: { fontSize: 12, fontWeight: 500, fontFamily: "Inter" },
395
- tiny: { fontSize: 11, fontWeight: 500, fontFamily: "Inter" },
396
- code: { fontSize: 13, fontWeight: 400, fontFamily: "JetBrains Mono" },
397
- annotation: { fontSize: 12, fontWeight: 500, fontFamily: "Inter", fontStyle: "italic" }
398
- };
399
- var canvas = {
400
- standard: { width: 800, height: 500 },
401
- wide: { width: 1e3, height: 400 },
402
- square: { width: 600, height: 600 },
403
- tall: { width: 600, height: 800 }
404
- };
405
- function getStyles(c) {
406
- return {
407
- canvas: {
408
- width: "100%",
409
- height: "100%",
410
- display: "flex",
411
- flexDirection: "column",
412
- backgroundColor: c.bg,
413
- fontFamily: c.fontSans,
414
- padding: 40
415
- },
416
- card: {
417
- display: "flex",
418
- flexDirection: "column",
419
- backgroundColor: c.bgCard,
420
- borderRadius: 8,
421
- border: `1px solid ${c.borderSubtle}`,
422
- padding: 20
423
- },
424
- pill: {
425
- display: "flex",
426
- alignItems: "center",
427
- justifyContent: "center",
428
- borderRadius: 999,
429
- padding: "6px 16px",
430
- fontSize: 13,
431
- fontWeight: 600,
432
- fontFamily: "Inter"
433
- }
434
- };
435
- }
436
- var styles = {
437
- canvas: {
438
- width: "100%",
439
- height: "100%",
440
- display: "flex",
441
- flexDirection: "column",
442
- backgroundColor: colors.bg,
443
- fontFamily: "Inter",
444
- padding: 40
445
- },
446
- card: {
447
- display: "flex",
448
- flexDirection: "column",
449
- backgroundColor: colors.bgCard,
450
- borderRadius: 8,
451
- border: `1px solid ${colors.borderSubtle}`,
452
- padding: 20
453
- },
454
- pill: {
455
- display: "flex",
456
- alignItems: "center",
457
- justifyContent: "center",
458
- borderRadius: 999,
459
- padding: "6px 16px",
460
- fontSize: 13,
461
- fontWeight: 600,
462
- fontFamily: "Inter"
463
- }
464
- };
465
- function getColor(name, c) {
466
- if (c) return c[name];
467
- return colors[name];
468
- }
469
- function getReadableColor(name, c) {
470
- const variants = {
471
- primary: [c.primaryLight, c.primary, c.primaryDark],
472
- secondary: [c.secondaryLight, c.secondary, c.secondaryDark],
473
- positive: [c.positiveLight, c.positive, c.positiveDark],
474
- warning: [c.warningLight, c.warning, c.warningDark],
475
- critical: [c.criticalLight, c.critical, c.criticalDark],
476
- info: [c.infoLight, c.info, c.infoDark],
477
- accent: [c.accentLight, c.accent, "#be185d"],
478
- neutral: [c.textSecondary, c.neutralLight, c.neutral, c.neutralDark]
479
- };
480
- return variants[name].reduce((best, candidate) => colorContrast(candidate, c.bgCard) > colorContrast(best, c.bgCard) ? candidate : best);
481
- }
482
- function parseColor(color) {
483
- const parsed = parseCssColor(color);
484
- if (!parsed || parsed.values.length < 3) return void 0;
485
- if (parsed.type !== "hsl") {
486
- return {
487
- channels: [parsed.values[0] ?? 0, parsed.values[1] ?? 0, parsed.values[2] ?? 0],
488
- alpha: parsed.alpha
489
- };
490
- }
491
- const hue = ((parsed.values[0] ?? 0) % 360 + 360) % 360;
492
- const saturation = (parsed.values[1] ?? 0) / 100;
493
- const lightness = (parsed.values[2] ?? 0) / 100;
494
- const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
495
- const segment = hue / 60;
496
- const intermediate = chroma * (1 - Math.abs(segment % 2 - 1));
497
- let channels;
498
- if (segment < 1) channels = [chroma, intermediate, 0];
499
- else if (segment < 2) channels = [intermediate, chroma, 0];
500
- else if (segment < 3) channels = [0, chroma, intermediate];
501
- else if (segment < 4) channels = [0, intermediate, chroma];
502
- else if (segment < 5) channels = [intermediate, 0, chroma];
503
- else channels = [chroma, 0, intermediate];
504
- const offset = lightness - chroma / 2;
505
- return {
506
- channels: channels.map((channel) => Math.round((channel + offset) * 255)),
507
- alpha: parsed.alpha
508
- };
509
- }
510
- function withColorAlpha(color, opacity) {
511
- if (typeof color !== "string" || !Number.isFinite(opacity)) return "transparent";
512
- const parsed = parseColor(color);
513
- if (!parsed) return "transparent";
514
- const alpha = Math.min(1, Math.max(0, parsed.alpha * Math.min(1, Math.max(0, opacity))));
515
- const hex = color.trim();
516
- if (/^#[\da-f]{6}$/i.test(hex)) {
517
- return `${hex}${Math.round(alpha * 255).toString(16).padStart(2, "0")}`;
518
- }
519
- return `rgba(${parsed.channels.join(", ")}, ${Number(alpha.toFixed(6))})`;
520
- }
521
- function colorLuminance(color, backdrop) {
522
- const parsed = parseColor(color);
523
- if (!parsed) return void 0;
524
- let channels = parsed.channels;
525
- if (parsed.alpha < 1) {
526
- const backdropColor = backdrop ? parseColor(backdrop) : void 0;
527
- if (!backdropColor) return void 0;
528
- channels = channels.map((channel, index) => Math.round(
529
- channel * parsed.alpha + backdropColor.channels[index] * (1 - parsed.alpha)
530
- ));
531
- }
532
- const [r, g, b] = channels.map((channel) => {
533
- const normalized = channel / 255;
534
- return normalized <= 0.04045 ? normalized / 12.92 : ((normalized + 0.055) / 1.055) ** 2.4;
535
- });
536
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
537
- }
538
- function colorContrast(left, right, rightBackdrop) {
539
- const leftLuminance = colorLuminance(left);
540
- const rightLuminance = colorLuminance(right, rightBackdrop);
541
- if (leftLuminance == null || rightLuminance == null) return 0;
542
- return (Math.max(leftLuminance, rightLuminance) + 0.05) / (Math.min(leftLuminance, rightLuminance) + 0.05);
543
- }
544
- function getReadableTextColor(background, c, backdrop = c.bgCard) {
545
- if (colorLuminance(background, backdrop) == null) return c.textPrimary;
546
- const candidates = [c.textPrimary, c.textOnColor, c.bg, "#000000"];
547
- const readable = candidates.find((candidate) => colorContrast(candidate, background, backdrop) >= 4.5);
548
- if (readable) return readable;
549
- return candidates.reduce((best, candidate) => colorContrast(candidate, background, backdrop) > colorContrast(best, background, backdrop) ? candidate : best);
550
- }
551
- function getGradient(name) {
552
- const map = {
553
- primary: gradients.purple,
554
- secondary: gradients.blue,
555
- positive: gradients.green,
556
- warning: gradients.warm,
557
- critical: gradients.warm,
558
- info: gradients.cyan,
559
- accent: gradients.pink,
560
- neutral: gradients.dark
561
- };
562
- return map[name];
563
- }
564
- function heatColor(value) {
565
- const v = Math.max(0, Math.min(1, value));
566
- if (v < 0.25) {
567
- const t = v / 0.25;
568
- return lerpColor("#1e293b", "#0891b2", t);
569
- } else if (v < 0.5) {
570
- const t = (v - 0.25) / 0.25;
571
- return lerpColor("#0891b2", "#059669", t);
572
- } else if (v < 0.75) {
573
- const t = (v - 0.5) / 0.25;
574
- return lerpColor("#059669", "#d97706", t);
575
- } else {
576
- const t = (v - 0.75) / 0.25;
577
- return lerpColor("#d97706", "#dc2626", t);
578
- }
579
- }
580
- function lerpColor(a, b, t) {
581
- const ah = parseInt(a.slice(1), 16);
582
- const bh = parseInt(b.slice(1), 16);
583
- const ar = ah >> 16 & 255, ag = ah >> 8 & 255, ab = ah & 255;
584
- const br = bh >> 16 & 255, bg = bh >> 8 & 255, bb = bh & 255;
585
- const rr = Math.round(ar + (br - ar) * t);
586
- const rg = Math.round(ag + (bg - ag) * t);
587
- const rb = Math.round(ab + (bb - ab) * t);
588
- return `#${(rr << 16 | rg << 8 | rb).toString(16).padStart(6, "0")}`;
589
- }
590
-
591
152
  // src/scene-components.ts
592
153
  var SCENE_COMPONENT_NAMES = Object.freeze([
593
154
  "Arrow",
594
155
  "ArrowMarkerDef",
156
+ "AttentionMatrix",
595
157
  "AxisPlot",
596
158
  "Badge",
597
159
  "BadgePill",
@@ -612,16 +174,21 @@ var SCENE_COMPONENT_NAMES = Object.freeze([
612
174
  "DataflowDiagram",
613
175
  "DeploymentDiagram",
614
176
  "DetailList",
177
+ "DiagramLegend",
615
178
  "DonutChart",
616
179
  "DotPoint",
617
180
  "EquationCard",
181
+ "FactRows",
618
182
  "Flow",
619
183
  "FlowArrow",
184
+ "FreeBodyDiagram",
185
+ "GeometryDiagram",
620
186
  "GradientChip",
621
187
  "GraphDiagram",
622
188
  "Grid",
623
189
  "Heatmap",
624
190
  "Icon",
191
+ "InlineBar",
625
192
  "IntervalPlot",
626
193
  "KeyValueList",
627
194
  "LayeredNetwork",
@@ -630,27 +197,37 @@ var SCENE_COMPONENT_NAMES = Object.freeze([
630
197
  "MathText",
631
198
  "Matrix",
632
199
  "MetricCard",
200
+ "MetricStrip",
633
201
  "MiniBarChart",
202
+ "MoleculeDiagram",
203
+ "NumberLine",
634
204
  "Panel",
635
205
  "ParetoBarChart",
636
206
  "ParetoChart",
637
207
  "PieChart",
638
208
  "Pipeline",
209
+ "PixelGrid",
639
210
  "ProgressList",
640
211
  "ProgressRow",
641
212
  "QuadrantChart",
213
+ "ReactionEnergyDiagram",
214
+ "ReactionEquation",
642
215
  "Row",
643
216
  "ScatterPlot",
644
217
  "Scene",
645
218
  "SequenceDiagram",
219
+ "SmallMultiples",
220
+ "Sparkline",
646
221
  "Stack",
647
222
  "StackedBar",
223
+ "StatusDot",
648
224
  "StatusList",
649
225
  "StatusRow",
650
226
  "StepCard",
651
227
  "SvgFrame",
652
228
  "SvgMathText",
653
229
  "SvgPoint",
230
+ "TagList",
654
231
  "TextLabel",
655
232
  "Tile",
656
233
  "TileGrid",
@@ -663,6 +240,7 @@ var SCENE_COMPONENT_NAMES = Object.freeze([
663
240
  "ValuePill",
664
241
  "VectorArrow",
665
242
  "VectorSegment",
243
+ "WaveDiagram",
666
244
  "WindowFrame"
667
245
  ]);
668
246
  var SCENE_DOM_TAGS = Object.freeze([
@@ -857,6 +435,37 @@ function validateSceneComponentProps(name, props) {
857
435
  tree(props.root);
858
436
  }
859
437
  if (name === "ParetoChart") entries(props.points, "ParetoChart.points", 512);
438
+ if (name === "NumberLine") {
439
+ entries(props.ticks, "NumberLine.ticks", 128);
440
+ entries(props.markers, "NumberLine.markers", 64);
441
+ }
442
+ if (name === "GeometryDiagram") {
443
+ entries(props.points, "GeometryDiagram.points", 128);
444
+ entries(props.segments, "GeometryDiagram.segments", 256);
445
+ entries(props.angles, "GeometryDiagram.angles", 64);
446
+ }
447
+ if (name === "FreeBodyDiagram") entries(props.forces, "FreeBodyDiagram.forces", 32);
448
+ if (name === "WaveDiagram") {
449
+ entries(props.waves, "WaveDiagram.waves", 8);
450
+ if (props.sampleCount !== void 0) integer(props.sampleCount, "WaveDiagram.sampleCount", 2, 512);
451
+ }
452
+ if (name === "MoleculeDiagram") {
453
+ entries(props.atoms, "MoleculeDiagram.atoms", 64);
454
+ entries(props.bonds, "MoleculeDiagram.bonds", 96);
455
+ }
456
+ if (name === "ReactionEquation") {
457
+ entries(props.reactants, "ReactionEquation.reactants", 16);
458
+ entries(props.products, "ReactionEquation.products", 16);
459
+ }
460
+ if (name === "AttentionMatrix") {
461
+ for (const row of entries(props.weights, "AttentionMatrix.weights", 32)) entries(row, "AttentionMatrix row", 32);
462
+ for (const row of entries(props.mask, "AttentionMatrix.mask", 32)) entries(row, "AttentionMatrix mask row", 32);
463
+ }
464
+ if (name === "PixelGrid") {
465
+ const rows = entries(props.pixels, "PixelGrid.pixels", 128);
466
+ const cells = rows.reduce((sum, row) => sum + entries(row, "PixelGrid row", 128).length, 0);
467
+ if (cells > 1024) throw new Error("Editable scene PixelGrid supports at most 1024 pixels.");
468
+ }
860
469
  }
861
470
 
862
471
  // src/scene-graph.ts
@@ -1050,7 +659,7 @@ async function prepareScene(request) {
1050
659
  const sourceSha256 = await sceneSha256(normalized.source);
1051
660
  const inputSha256 = await sceneSha256(JSON.stringify({ runtimeVersion: SCENE_RUNTIME_VERSION, ...normalized }));
1052
661
  const QuickJS = await getQuickJS();
1053
- const colors2 = getThemeColors(normalized.theme);
662
+ const colors = getThemeColors(normalized.theme);
1054
663
  const components = `const { ${SCENE_COMPONENT_NAMES.join(", ")} } = Object.fromEntries(${JSON.stringify(SCENE_COMPONENT_NAMES)}.map(name => [name, __primitive(name)]));`;
1055
664
  const evaluate = async (requestedTime) => {
1056
665
  const time = normalizeSceneTime(requestedTime, normalized.duration);
@@ -1073,7 +682,7 @@ async function prepareScene(request) {
1073
682
  theme: normalized.theme,
1074
683
  cues: normalized.cues,
1075
684
  seed: normalized.seed,
1076
- c: colors2
685
+ c: colors
1077
686
  };
1078
687
  const declaration = `const { ${Object.keys(context).join(", ")} } = ${JSON.stringify(context)};`;
1079
688
  try {
@@ -1132,25 +741,6 @@ async function evaluateSceneSource(request) {
1132
741
  }
1133
742
 
1134
743
  export {
1135
- __export,
1136
- getThemeColors,
1137
- colors,
1138
- gradients,
1139
- toneGradients,
1140
- getToneGradient,
1141
- getToneColor,
1142
- getReadableToneColor,
1143
- getToneFill,
1144
- typography,
1145
- canvas,
1146
- getStyles,
1147
- styles,
1148
- getColor,
1149
- getReadableColor,
1150
- withColorAlpha,
1151
- getReadableTextColor,
1152
- getGradient,
1153
- heatColor,
1154
744
  SCENE_COMPONENT_NAMES,
1155
745
  SCENE_DOM_TAGS,
1156
746
  SCENE_RUNTIME_VERSION,