@coldtea/pr-lens-renderer 0.4.0 → 0.5.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 (93) hide show
  1. package/README.md +15 -0
  2. package/dist/atlas.d.ts +6 -0
  3. package/dist/atlas.d.ts.map +1 -1
  4. package/dist/atlas.js +1 -1
  5. package/dist/atlas.js.map +1 -1
  6. package/dist/glob.d.ts.map +1 -1
  7. package/dist/glob.js +72 -9
  8. package/dist/glob.js.map +1 -1
  9. package/dist/index.d.ts +7 -3
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +7 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/manifest.d.ts +11 -3
  14. package/dist/manifest.d.ts.map +1 -1
  15. package/dist/manifest.js +10 -1
  16. package/dist/manifest.js.map +1 -1
  17. package/dist/render-all.d.ts +35 -0
  18. package/dist/render-all.d.ts.map +1 -0
  19. package/dist/render-all.js +110 -0
  20. package/dist/render-all.js.map +1 -0
  21. package/dist/render.d.ts +4 -31
  22. package/dist/render.d.ts.map +1 -1
  23. package/dist/render.js +5 -75
  24. package/dist/render.js.map +1 -1
  25. package/dist/svg/datamodel.d.ts.map +1 -1
  26. package/dist/svg/datamodel.js +8 -1
  27. package/dist/svg/datamodel.js.map +1 -1
  28. package/dist/svg/document.d.ts +8 -0
  29. package/dist/svg/document.d.ts.map +1 -1
  30. package/dist/svg/document.js +3 -2
  31. package/dist/svg/document.js.map +1 -1
  32. package/dist/theme.d.ts +2 -0
  33. package/dist/theme.d.ts.map +1 -1
  34. package/dist/theme.js +1 -0
  35. package/dist/theme.js.map +1 -1
  36. package/dist/version.d.ts +1 -1
  37. package/dist/version.js +1 -1
  38. package/dist/walkthrough/camera.d.ts +43 -0
  39. package/dist/walkthrough/camera.d.ts.map +1 -0
  40. package/dist/walkthrough/camera.js +101 -0
  41. package/dist/walkthrough/camera.js.map +1 -0
  42. package/dist/walkthrough/caption.d.ts +5 -0
  43. package/dist/walkthrough/caption.d.ts.map +1 -0
  44. package/dist/walkthrough/caption.js +36 -0
  45. package/dist/walkthrough/caption.js.map +1 -0
  46. package/dist/walkthrough/embed.d.ts +31 -0
  47. package/dist/walkthrough/embed.d.ts.map +1 -0
  48. package/dist/walkthrough/embed.js +297 -0
  49. package/dist/walkthrough/embed.js.map +1 -0
  50. package/dist/walkthrough/index.d.ts +8 -0
  51. package/dist/walkthrough/index.d.ts.map +1 -0
  52. package/dist/walkthrough/index.js +6 -0
  53. package/dist/walkthrough/index.js.map +1 -0
  54. package/dist/walkthrough/layout.d.ts +28 -0
  55. package/dist/walkthrough/layout.d.ts.map +1 -0
  56. package/dist/walkthrough/layout.js +31 -0
  57. package/dist/walkthrough/layout.js.map +1 -0
  58. package/dist/walkthrough/nest.d.ts +4 -0
  59. package/dist/walkthrough/nest.d.ts.map +1 -0
  60. package/dist/walkthrough/nest.js +4 -0
  61. package/dist/walkthrough/nest.js.map +1 -0
  62. package/dist/walkthrough/resolve.d.ts +45 -0
  63. package/dist/walkthrough/resolve.d.ts.map +1 -0
  64. package/dist/walkthrough/resolve.js +189 -0
  65. package/dist/walkthrough/resolve.js.map +1 -0
  66. package/dist/walkthrough/tile-ids.d.ts +8 -0
  67. package/dist/walkthrough/tile-ids.d.ts.map +1 -0
  68. package/dist/walkthrough/tile-ids.js +16 -0
  69. package/dist/walkthrough/tile-ids.js.map +1 -0
  70. package/dist/walkthrough/tiles.d.ts +15 -0
  71. package/dist/walkthrough/tiles.d.ts.map +1 -0
  72. package/dist/walkthrough/tiles.js +80 -0
  73. package/dist/walkthrough/tiles.js.map +1 -0
  74. package/package.json +7 -3
  75. package/src/atlas.ts +7 -1
  76. package/src/glob.ts +76 -11
  77. package/src/index.ts +23 -6
  78. package/src/manifest.ts +20 -3
  79. package/src/render-all.ts +195 -0
  80. package/src/render.ts +8 -116
  81. package/src/svg/datamodel.ts +13 -0
  82. package/src/svg/document.ts +3 -2
  83. package/src/theme.ts +4 -0
  84. package/src/version.ts +1 -1
  85. package/src/walkthrough/camera.ts +142 -0
  86. package/src/walkthrough/caption.ts +35 -0
  87. package/src/walkthrough/embed.ts +436 -0
  88. package/src/walkthrough/index.ts +42 -0
  89. package/src/walkthrough/layout.ts +46 -0
  90. package/src/walkthrough/nest.ts +6 -0
  91. package/src/walkthrough/resolve.ts +268 -0
  92. package/src/walkthrough/tile-ids.ts +17 -0
  93. package/src/walkthrough/tiles.ts +106 -0
package/README.md CHANGED
@@ -77,6 +77,21 @@ The atlas is as deterministic as the SVG. Same document, same boxes, in the same
77
77
 
78
78
  Each lens fills in what it draws. The architecture lens places lanes, cards and edges and no flow step; the data-flow lens places the cards heading its columns and the steps of each flow, and no lane or edge. A node the same render draws twice, heading a column in two stacked flows, gets the box covering both of them: a reader sent to that node is being sent to all of it. A card's box is the card, not the badge strip above it, which is context a veil may dim.
79
79
 
80
+ ## The walkthrough embed
81
+
82
+ ```ts
83
+ import { renderWalkthroughEmbed } from "@coldtea/pr-lens-renderer";
84
+
85
+ const result = renderWalkthroughEmbed(doc, { theme: "dark" });
86
+ if (result.type === "rendered") write(result.embed.svg);
87
+ ```
88
+
89
+ A document's walkthrough as one animated SVG, 870 wide, for a surface that shows images and runs no script: a pull request comment, a README. The caption above the stage is styled as a GitHub alert, the camera flies between the diagrams on the canvas's own path and at its pace, and the context outside each step's focus is dimmed through a mask rather than a veil, because the picture cannot know the colour of the page it lands on. The tour plays twice and rests on its last step, caption and all; under `prefers-reduced-motion` it is that still. Only the diagrams the tour visits travel with it.
90
+
91
+ The result is `absent` for a document with no walkthrough and `unresolvable`, with the steps at fault, for one whose tour points at something its diagrams do not draw. `renderAll` draws the embed for each half of the pair it was asked for and lists it under `walkthrough` in the manifest; a `neutral` render gets none, since the embed is transparent and tuned per half.
92
+
93
+ The canvas and the embed share the strip layout, the camera and the walkthrough resolution (`stripLayout`, `frame`, `interpolateFlight`, `resolveWalkthrough`), so a step framed on one lands the same way on the other. A browser bundle imports them from `@coldtea/pr-lens-renderer/walkthrough`, which reaches nothing of node; `planTiles` and the embed itself stay on the root entry, since they draw.
94
+
80
95
  ## Corrections
81
96
 
82
97
  A repository's `.github/pr-lens.yml` is an overlay, applied here before layout and never written back into inference, so a correction keeps holding as the code moves:
package/dist/atlas.d.ts CHANGED
@@ -18,6 +18,12 @@ export type RenderAtlas = {
18
18
  messages: Record<string, Record<string, Box>>;
19
19
  /** The data-model lens's cards; its stores land in `lanes` and its relations in `edges`. */
20
20
  tables: Record<string, Box>;
21
+ /**
22
+ * The rows a table card draws, keyed by table then column name. A folded
23
+ * card lists only the columns it shows, so a column with no box here is one
24
+ * the picture left out, not one the surface may place by counting rows.
25
+ */
26
+ columns: Record<string, Record<string, Box>>;
21
27
  };
22
28
  /** An atlas for a drawing that has placed nothing. */
23
29
  export declare const emptyAtlas: () => RenderAtlas;
@@ -1 +1 @@
1
- {"version":3,"file":"atlas.d.ts","sourceRoot":"","sources":["../src/atlas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAc,KAAK,GAAG,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9C,4FAA4F;IAC5F,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,UAAU,QAAO,WAA8E,CAAC;AAE7G,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE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 @@
1
1
  import { covering } from "./bounds.js";
2
2
  import { roundCoord } from "./geometry.js";
3
3
  /** An atlas for a drawing that has placed nothing. */
4
- export const emptyAtlas = () => ({ lanes: {}, nodes: {}, edges: {}, messages: {}, tables: {} });
4
+ export const emptyAtlas = () => ({ lanes: {}, nodes: {}, edges: {}, messages: {}, tables: {}, columns: {} });
5
5
  /**
6
6
  * Boxes onto the canvas and into a record, in the order they were drawn.
7
7
  *
package/dist/atlas.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"atlas.js","sourceRoot":"","sources":["../src/atlas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,UAAU,EAAY,MAAM,eAAe,CAAC;AAsBrD,sDAAsD;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAI7G;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,OAA8B,EAC9B,MAAc,EACO,EAAE;IACvB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAe,CAAC;IACrC,KAAK,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,OAAO,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,KAAK;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,EAAE,CAAC;IACtC,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,KAAK;QAC3B,KAAK,CAAC,EAAE,CAAC,GAAG;YACV,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;YACpC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;YACpC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC;YAC5B,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC;SAC/B,CAAC;IACJ,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,QAAQ,MAAM,KAAG,OAY3D,CAAC"}
1
+ {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,QAAQ,MAAM,KAAG,OA4C3D,CAAC"}
package/dist/glob.js CHANGED
@@ -1,17 +1,80 @@
1
- const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1
+ import { assertNever } from "@coldtea/pr-lens-schema";
2
+ const tokenize = (pattern) => {
3
+ const tokens = [];
4
+ for (let i = 0; i < pattern.length; i += 1) {
5
+ const ch = pattern[i];
6
+ if (ch === "*" &&
7
+ pattern[i + 1] === "*" &&
8
+ pattern[i + 2] === "/" &&
9
+ (i === 0 || pattern[i - 1] === "/")) {
10
+ tokens.push({ kind: "crossDir" });
11
+ i += 2;
12
+ }
13
+ else if (ch === "*" && pattern[i + 1] === "*") {
14
+ tokens.push({ kind: "cross" });
15
+ i += 1;
16
+ }
17
+ else if (ch === "*") {
18
+ tokens.push({ kind: "star" });
19
+ }
20
+ else if (ch === "?") {
21
+ tokens.push({ kind: "any" });
22
+ }
23
+ else {
24
+ tokens.push({ kind: "char", value: ch });
25
+ }
26
+ }
27
+ return tokens;
28
+ };
2
29
  /**
3
30
  * Path matching for config selectors, with the subset of glob a person
4
31
  * actually writes in one: `**` crosses directory boundaries, `*` and `?` do
5
32
  * not. Every other character is literal.
6
33
  */
7
34
  export const matchesGlob = (pattern, path) => {
8
- const source = pattern
9
- .split("**")
10
- .map((crossing) => crossing
11
- .split("*")
12
- .map((segment) => segment.split("?").map(escapeRegExp).join("[^/]"))
13
- .join("[^/]*"))
14
- .join(".*");
15
- return new RegExp(`^${source}$`).test(path);
35
+ const n = path.length;
36
+ const reachable = new Uint8Array(n + 1);
37
+ reachable[0] = 1;
38
+ for (const token of tokenize(pattern)) {
39
+ switch (token.kind) {
40
+ case "crossDir": {
41
+ const first = reachable.indexOf(1);
42
+ if (first !== -1) {
43
+ for (let j = first + 1; j <= n; j += 1) {
44
+ if (path[j - 1] === "/")
45
+ reachable[j] = 1;
46
+ }
47
+ }
48
+ break;
49
+ }
50
+ case "cross":
51
+ for (let j = 1; j <= n; j += 1) {
52
+ if (reachable[j - 1])
53
+ reachable[j] = 1;
54
+ }
55
+ break;
56
+ case "star":
57
+ for (let j = 1; j <= n; j += 1) {
58
+ if (path[j - 1] !== "/" && reachable[j - 1])
59
+ reachable[j] = 1;
60
+ }
61
+ break;
62
+ case "any":
63
+ for (let j = n; j >= 1; j -= 1) {
64
+ reachable[j] = path[j - 1] !== "/" && reachable[j - 1] ? 1 : 0;
65
+ }
66
+ reachable[0] = 0;
67
+ break;
68
+ case "char":
69
+ for (let j = n; j >= 1; j -= 1) {
70
+ reachable[j] = path[j - 1] === token.value && reachable[j - 1] ? 1 : 0;
71
+ }
72
+ reachable[0] = 0;
73
+ break;
74
+ default:
75
+ return assertNever(token);
76
+ }
77
+ }
78
+ return reachable[n] === 1;
16
79
  };
17
80
  //# sourceMappingURL=glob.js.map
package/dist/glob.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAE7F;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,IAAY,EAAW,EAAE;IACpE,MAAM,MAAM,GAAG,OAAO;SACnB,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChB,QAAQ;SACL,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACnE,IAAI,CAAC,OAAO,CAAC,CACjB;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAC"}
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAStD,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAwB,EAAE;IACzD,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC;QACvB,IACE,EAAE,KAAK,GAAG;YACV,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG;YACtB,OAAO,CAAC,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C,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjE,CAAC;gBACD,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACjB,MAAM;YACR,KAAK,MAAM;gBACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC/B,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzE,CAAC;gBACD,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACjB,MAAM;YACR;gBACE,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  export { RENDERER_NAME, RENDERER_VERSION } from "./version.js";
2
- export { render, renderAll, type RenderAllOptions, type RenderThemes, type RenderAllResult, type RenderedAsset, type RenderedSvg, type RenderOptions, } from "./render.js";
2
+ export { render, type RenderedSvg, type RenderOptions } from "./render.js";
3
+ export { renderAll, type RenderAllOptions, type RenderAllResult, type RenderedAsset, type RenderedWalkthrough, type RenderedWalkthroughs, type RenderThemes, } from "./render-all.js";
4
+ export { EMBED_WIDTH, renderWalkthroughEmbed, walkthroughLabel, type WalkthroughEmbed, type WalkthroughEmbedOptions, type WalkthroughEmbedResult, } from "./walkthrough/embed.js";
5
+ export { planTiles, renderFlow, type TilePlan } from "./walkthrough/tiles.js";
6
+ export * from "./walkthrough/index.js";
3
7
  export { emptyAtlas, type RenderAtlas } from "./atlas.js";
4
8
  export { PrLensRenderError, type RenderErrorCode } from "./errors.js";
5
9
  export type { Box } from "./geometry.js";
6
- export { paletteFor, THEMES, THEME_PAIR, type Palette, type Theme } from "./theme.js";
7
- export { buildManifest, canonicalJson, contentHash, CONTENT_HASH_LENGTH, graphContentHash, renderAssetFileName, renderAssetId, type AssetAddress, } from "./manifest.js";
10
+ export { isPairTheme, paletteFor, THEMES, THEME_PAIR, type PairTheme, type Palette, type Theme } from "./theme.js";
11
+ export { assetIdentity, buildManifest, canonicalJson, contentHash, CONTENT_HASH_LENGTH, graphContentHash, renderAssetFileName, renderAssetId, walkthroughAssetFileName, walkthroughAssetId, type AssetAddress, } from "./manifest.js";
8
12
  export { applyCorrections } from "./corrections.js";
9
13
  export { findView, flattenViews, resolveScope, type ScopedGraph } from "./scope.js";
10
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,MAAM,EACN,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtE,YAAY,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtF,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,E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ClB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,13 @@
1
1
  export { RENDERER_NAME, RENDERER_VERSION } from "./version.js";
2
- export { render, renderAll, } from "./render.js";
2
+ export { render } from "./render.js";
3
+ export { renderAll, } from "./render-all.js";
4
+ export { EMBED_WIDTH, renderWalkthroughEmbed, walkthroughLabel, } from "./walkthrough/embed.js";
5
+ export { planTiles, renderFlow } from "./walkthrough/tiles.js";
6
+ export * from "./walkthrough/index.js";
3
7
  export { emptyAtlas } from "./atlas.js";
4
8
  export { PrLensRenderError } from "./errors.js";
5
- export { paletteFor, THEMES, THEME_PAIR } from "./theme.js";
6
- export { buildManifest, canonicalJson, contentHash, CONTENT_HASH_LENGTH, graphContentHash, renderAssetFileName, renderAssetId, } from "./manifest.js";
9
+ export { isPairTheme, paletteFor, THEMES, THEME_PAIR } from "./theme.js";
10
+ export { assetIdentity, buildManifest, canonicalJson, contentHash, CONTENT_HASH_LENGTH, graphContentHash, renderAssetFileName, renderAssetId, walkthroughAssetFileName, walkthroughAssetId, } from "./manifest.js";
7
11
  export { applyCorrections } from "./corrections.js";
8
12
  export { findView, flattenViews, resolveScope } from "./scope.js";
9
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,MAAM,EACN,SAAS,GAOV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAoB,MAAM,YAAY,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAwB,MAAM,a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+1,5 @@
1
- import type { GraphDoc, Lens, RenderAsset, RenderManifest } from "@coldtea/pr-lens-schema";
2
- import { type Theme } from "./theme.js";
1
+ import type { GraphDoc, Lens, RenderAsset, RenderManifest, WalkthroughAsset } from "@coldtea/pr-lens-schema";
2
+ import { type PairTheme, type Theme } from "./theme.js";
3
3
  /**
4
4
  * How many hex characters of the digest an address carries. Long enough that
5
5
  * two different renders will not collide inside one repository's history,
@@ -16,6 +16,11 @@ export declare const CONTENT_HASH_LENGTH = 32;
16
16
  * what the same render is called.
17
17
  */
18
18
  export declare const contentHash: (bytes: string) => string;
19
+ /** The one place an asset's bytes become its identity. */
20
+ export declare const assetIdentity: (svg: string) => {
21
+ contentHash: string;
22
+ bytes: number;
23
+ };
19
24
  /** JSON with object keys in sorted order, so equal documents hash equal. */
20
25
  export declare const canonicalJson: (value: unknown) => string;
21
26
  export declare const graphContentHash: (doc: GraphDoc) => string;
@@ -35,5 +40,8 @@ export type AssetAddress = {
35
40
  export declare const renderAssetId: ({ lens, theme, view }: AssetAddress) => string;
36
41
  /** The file name an asset is written or published under. */
37
42
  export declare const renderAssetFileName: (address: AssetAddress, hash: string) => string;
38
- export declare const buildManifest: (doc: GraphDoc, assets: readonly RenderAsset[]) => RenderManifest;
43
+ /** Listed apart from the view assets, so a view called "walkthrough" cannot collide with it. */
44
+ export declare const walkthroughAssetId: (theme: PairTheme) => string;
45
+ export declare const walkthroughAssetFileName: (theme: PairTheme, hash: string) => string;
46
+ export declare const buildManifest: (doc: GraphDoc, assets: readonly RenderAsset[], walkthrough: readonly WalkthroughAsset[]) => RenderManifest;
39
47
  //# sourceMappingURL=manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EAAU,KAAK,KAAK,EA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AW,OAAO,KAAG,MAS9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,QAAQ,KAAG,MAAyC,CAAC;AAE3F,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAsDlF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,0BAA2B,YAAY,KAAG,MAC1B,CAAC;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,YAAa,YAAY,QAAQ,MAAM,KAAG,MACjC,CAAC;AAE1C,gGAAgG;AAChG,eAAO,MAAM,kBAAkB,UAAW,SAAS,KAAG,MAAgC,CAAC;AAEvF,eAAO,MAAM,wBAAwB,UAAW,SAAS,QAAQ,MAAM,KAAG,MAC9B,CAAC;AAE7C,eAAO,MAAM,aAAa,QACnB,QAAQ,UACL,SAAS,WAAW,EAAE,eACjB,SAAS,gBAAgB,EAAE,KACvC,cAWD,CAAC"}
package/dist/manifest.js CHANGED
@@ -18,6 +18,11 @@ export const CONTENT_HASH_LENGTH = 32;
18
18
  * what the same render is called.
19
19
  */
20
20
  export const contentHash = (bytes) => createHash("sha256").update(bytes, "utf8").digest("hex").slice(0, CONTENT_HASH_LENGTH);
21
+ /** The one place an asset's bytes become its identity. */
22
+ export const assetIdentity = (svg) => ({
23
+ contentHash: contentHash(svg),
24
+ bytes: Buffer.byteLength(svg, "utf8"),
25
+ });
21
26
  /** JSON with object keys in sorted order, so equal documents hash equal. */
22
27
  export const canonicalJson = (value) => {
23
28
  if (value === null || typeof value !== "object")
@@ -87,7 +92,10 @@ const fileNameSafe = (id) => {
87
92
  export const renderAssetId = ({ lens, theme, view }) => `${fileNameSafe(view ?? lens)}-${theme}`;
88
93
  /** The file name an asset is written or published under. */
89
94
  export const renderAssetFileName = (address, hash) => `${renderAssetId(address)}-${hash}.svg`;
90
- export const buildManifest = (doc, assets) => ({
95
+ /** Listed apart from the view assets, so a view called "walkthrough" cannot collide with it. */
96
+ export const walkthroughAssetId = (theme) => `walkthrough-${theme}`;
97
+ export const walkthroughAssetFileName = (theme, hash) => `${walkthroughAssetId(theme)}-${hash}.svg`;
98
+ export const buildManifest = (doc, assets, walkthrough) => ({
91
99
  schemaVersion: SCHEMA_VERSION,
92
100
  kind: "render-manifest",
93
101
  graph: {
@@ -97,5 +105,6 @@ export const buildManifest = (doc, assets) => ({
97
105
  },
98
106
  renderer: { name: RENDERER_NAME, version: RENDERER_VERSION },
99
107
  assets: [...assets],
108
+ walkthrough: [...walkthrough],
100
109
  });
101
110
  //# sourceMappingURL=manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAc,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE,CACnD,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;AAEzF,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAU,EAAE;IACtD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC;IACxF,IAAI,KAAK,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sset, RenderManifest, WalkthroughAsset } from "@coldtea/pr-lens-schema";
2
+ import { type RenderedSvg } from "./render.js";
3
+ import { type WalkthroughEmbed } from "./walkthrough/embed.js";
4
+ import type { WalkthroughIssue } from "./walkthrough/resolve.js";
5
+ /** The pair, one half of it, or neutral. Never all three: the view cap assumes two assets per view. */
6
+ export type RenderThemes = readonly ["light", "dark"] | readonly ["light"] | readonly ["dark"] | readonly ["neutral"];
7
+ export type RenderAllOptions = {
8
+ config?: Config;
9
+ /** The pair by default. */
10
+ themes?: RenderThemes;
11
+ };
12
+ export type RenderedAsset = RenderedSvg & {
13
+ asset: RenderAsset;
14
+ };
15
+ export type RenderedWalkthrough = WalkthroughEmbed & {
16
+ asset: WalkthroughAsset;
17
+ };
18
+ /** `absent` for a neutral render too: the embed has no single-image form. */
19
+ export type RenderedWalkthroughs = {
20
+ type: "absent";
21
+ } | {
22
+ type: "unresolvable";
23
+ issues: WalkthroughIssue[];
24
+ } | {
25
+ type: "rendered";
26
+ assets: RenderedWalkthrough[];
27
+ };
28
+ export type RenderAllResult = {
29
+ assets: RenderedAsset[];
30
+ walkthrough: RenderedWalkthroughs;
31
+ manifest: RenderManifest;
32
+ };
33
+ /** Every drill-down section in every theme asked for, or one diagram per lens when there are none. */
34
+ export declare const renderAll: (doc: GraphDoc, options?: RenderAllOptions) => RenderAllResult;
35
+ //# sourceMappingURL=render-all.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-all.d.ts","sourceRoot":"","sources":["../src/render-all.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EAER,WAAW,EACX,cAAc,EAEd,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAWjC,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,uGAAuG;AACvG,MAAM,MAAM,YAAY,GACpB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,GAC1B,SAAS,CAAC,OAAO,CAAC,GAClB,SAAS,CAAC,MAAM,CAAC,GACjB,SAAS,CAAC,SAAS,CAAC,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,CAAC;AAEjE,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG;IACnD,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,mBAAmB,EAAE,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,WAAW,EAAE,oBAAoB,CAAC;IAClC,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,SAAS,QACf,QAAQ,YACJ,gBAAgB,KACxB,eAkFF,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { assertNever, MAX_RENDER_ASSETS } from "@coldtea/pr-lens-schema";
2
+ import { PrLensRenderError } from "./errors.js";
3
+ import { assetIdentity, buildManifest, renderAssetFileName, renderAssetId, walkthroughAssetFileName, walkthroughAssetId, } from "./manifest.js";
4
+ import { prepare, render } from "./render.js";
5
+ import { flattenViews } from "./scope.js";
6
+ import { isPairTheme, THEME_PAIR } from "./theme.js";
7
+ import { renderWalkthroughEmbed, } from "./walkthrough/embed.js";
8
+ import { tileIdForView } from "./walkthrough/tile-ids.js";
9
+ /** Every drill-down section in every theme asked for, or one diagram per lens when there are none. */
10
+ export const renderAll = (doc, options = {}) => {
11
+ const prepared = prepare(doc, options.config);
12
+ const themes = options.themes ?? THEME_PAIR;
13
+ const targets = prepared.views.length > 0
14
+ ? flattenViews(prepared.views)
15
+ .filter((view) => prepared.lenses.includes(view.lens))
16
+ .map((view) => ({ lens: view.lens, view }))
17
+ : prepared.lenses
18
+ .filter((lens) => {
19
+ switch (lens) {
20
+ case "architecture":
21
+ return true;
22
+ case "data-flow":
23
+ return prepared.flows.length > 0;
24
+ case "data-model":
25
+ return prepared.dataModel !== undefined;
26
+ default:
27
+ return assertNever(lens, "Unhandled lens");
28
+ }
29
+ })
30
+ .map((lens) => ({ lens, view: undefined }));
31
+ // Only a hand-built document can reach this: the contract's cap is a refinement, which the type does not carry.
32
+ if (targets.length * themes.length > MAX_RENDER_ASSETS)
33
+ throw new PrLensRenderError("TOO_MANY_ASSETS", `this document asks for ${targets.length * themes.length} pictures across ${targets.length} views ` +
34
+ `and ${themes.length} themes, and a render manifest carries at most ${MAX_RENDER_ASSETS}`);
35
+ const assets = [];
36
+ for (const target of targets)
37
+ for (const theme of themes) {
38
+ const rendered = render(prepared, {
39
+ lens: target.lens,
40
+ theme,
41
+ view: target.view?.id,
42
+ });
43
+ const address = { lens: target.lens, theme, view: target.view?.id };
44
+ const identity = assetIdentity(rendered.svg);
45
+ assets.push({
46
+ ...rendered,
47
+ asset: {
48
+ id: renderAssetId(address),
49
+ lens: target.lens,
50
+ theme,
51
+ view: target.view?.id,
52
+ mediaType: "image/svg+xml",
53
+ ...identity,
54
+ width: rendered.width,
55
+ height: rendered.height,
56
+ animated: rendered.animated,
57
+ path: renderAssetFileName(address, identity.contentHash),
58
+ },
59
+ });
60
+ }
61
+ if (assets.length === 0)
62
+ throw new PrLensRenderError("NOTHING_TO_RENDER", "this document declares no renderable view");
63
+ const walkthrough = renderWalkthroughs(prepared, themes, assets);
64
+ const walkthroughAssets = walkthrough.type === "rendered"
65
+ ? walkthrough.assets.map(({ asset }) => asset)
66
+ : [];
67
+ return {
68
+ assets,
69
+ walkthrough,
70
+ manifest: buildManifest(prepared, assets.map(({ asset }) => asset), walkthroughAssets),
71
+ };
72
+ };
73
+ /** Hands the views just drawn to the embed, which then draws only flow and whole-model tiles. */
74
+ const renderWalkthroughs = (doc, themes, drawn) => {
75
+ const assets = [];
76
+ for (const theme of themes.filter(isPairTheme)) {
77
+ const tiles = new Map(drawn.flatMap((asset) => asset.theme === theme && asset.view !== undefined
78
+ ? [[tileIdForView(asset.view), asset]]
79
+ : []));
80
+ const result = renderWalkthroughEmbed(doc, { theme, tiles });
81
+ switch (result.type) {
82
+ case "absent":
83
+ case "unresolvable":
84
+ return result;
85
+ case "rendered": {
86
+ const identity = assetIdentity(result.embed.svg);
87
+ assets.push({
88
+ ...result.embed,
89
+ asset: {
90
+ id: walkthroughAssetId(theme),
91
+ theme,
92
+ mediaType: "image/svg+xml",
93
+ ...identity,
94
+ width: result.embed.width,
95
+ height: result.embed.height,
96
+ steps: result.embed.steps,
97
+ path: walkthroughAssetFileName(theme, identity.contentHash),
98
+ },
99
+ });
100
+ break;
101
+ }
102
+ default:
103
+ return assertNever(result, "Unhandled walkthrough embed result");
104
+ }
105
+ }
106
+ return assets.length === 0
107
+ ? { type: "absent" }
108
+ : { type: "rendered", assets };
109
+ };
110
+ //# sourceMappingURL=render-all.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-all.js","sourceRoot":"","sources":["../src/render-all.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB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I,CAAC,EAAE,KAAK,CAAC,CAAC;YACtC,CAAC,CAAC,EAAE,CACP,CACF,CAAC;QACF,MAAM,MAAM,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7D,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,QAAQ,CAAC;YACd,KAAK,cAAc;gBACjB,OAAO,MAAM,CAAC;YAChB,KAAK,UAAU,EAAE,CAAC;gBAChB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACjD,MAAM,CAAC,IAAI,CAAC;oBACV,GAAG,MAAM,CAAC,KAAK;oBACf,KAAK,EAAE;wBACL,EAAE,EAAE,kBAAkB,CAAC,KAAK,CAAC;wBAC7B,KAAK;wBACL,SAAS,EAAE,eAAe;wBAC1B,GAAG,QAAQ;wBACX,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;wBACzB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;wBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;wBACzB,IAAI,EAAE,wBAAwB,CAAC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC;qBAC5D;iBACF,CAAC,CAAC;gBACH,MAAM;YACR,CAAC;YACD;gBACE,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC;QACxB,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE;QACpB,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC,CAAC"}
package/dist/render.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Config, GraphDoc, Lens, RenderAsset, RenderManifest } from "@coldtea/pr-lens-schema";
1
+ import type { Config, GraphDoc, Lens } from "@coldtea/pr-lens-schema";
2
2
  import type { RenderAtlas } from "./atlas.js";
3
3
  import { type Theme } from "./theme.js";
4
4
  export type RenderOptions = {
@@ -11,6 +11,8 @@ export type RenderOptions = {
11
11
  };
12
12
  export type RenderedSvg = {
13
13
  svg: string;
14
+ /** The painting alone, for a document that nests this picture under its own defs and ground. */
15
+ body: string;
14
16
  width: number;
15
17
  height: number;
16
18
  lens: Lens;
@@ -20,6 +22,7 @@ export type RenderedSvg = {
20
22
  /** Where every lane, node, edge and flow step of this picture landed. */
21
23
  atlas: RenderAtlas;
22
24
  };
25
+ export declare const prepare: (doc: GraphDoc, config: Config | undefined) => GraphDoc;
23
26
  /**
24
27
  * A schema-valid document in, one self-contained SVG out.
25
28
  *
@@ -29,34 +32,4 @@ export type RenderedSvg = {
29
32
  * from rearranging itself between two pushes that barely changed anything.
30
33
  */
31
34
  export declare const render: (doc: GraphDoc, options: RenderOptions) => RenderedSvg;
32
- /**
33
- * What a render may be asked for: the `<picture>` pair, one half of it, or
34
- * the single self-contained render.
35
- *
36
- * Not `readonly Theme[]`, which would admit all three at once — three assets
37
- * per view against a view cap derived from two, so a document that validates
38
- * could produce a manifest that does not. The contract's promise is that if
39
- * it parses, it renders; this is the boundary that keeps it true.
40
- */
41
- export type RenderThemes = readonly ["light", "dark"] | readonly ["light"] | readonly ["dark"] | readonly ["neutral"];
42
- export type RenderAllOptions = {
43
- config?: Config;
44
- /** The `<picture>` pair by default; `['neutral']` for a single-image surface. */
45
- themes?: RenderThemes;
46
- };
47
- export type RenderedAsset = RenderedSvg & {
48
- asset: RenderAsset;
49
- };
50
- export type RenderAllResult = {
51
- assets: RenderedAsset[];
52
- manifest: RenderManifest;
53
- };
54
- /**
55
- * Every drill-down section a comment will show, in both themes.
56
- *
57
- * A document with no sections still renders: it gets one diagram per lens it
58
- * declares, which is what a comment falls back to when extraction found
59
- * nothing worth splitting into a tree.
60
- */
61
- export declare const renderAll: (doc: GraphDoc, options?: RenderAllOptions) => RenderAllResult;
62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