@coldtea/pr-lens-renderer 0.4.1 → 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.
- package/README.md +15 -0
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +72 -9
- package/dist/glob.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +11 -3
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +10 -1
- package/dist/manifest.js.map +1 -1
- package/dist/render-all.d.ts +35 -0
- package/dist/render-all.d.ts.map +1 -0
- package/dist/render-all.js +110 -0
- package/dist/render-all.js.map +1 -0
- package/dist/render.d.ts +4 -31
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +5 -75
- package/dist/render.js.map +1 -1
- package/dist/svg/document.d.ts +8 -0
- package/dist/svg/document.d.ts.map +1 -1
- package/dist/svg/document.js +3 -2
- package/dist/svg/document.js.map +1 -1
- package/dist/theme.d.ts +2 -0
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +1 -0
- package/dist/theme.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walkthrough/camera.d.ts +43 -0
- package/dist/walkthrough/camera.d.ts.map +1 -0
- package/dist/walkthrough/camera.js +101 -0
- package/dist/walkthrough/camera.js.map +1 -0
- package/dist/walkthrough/caption.d.ts +5 -0
- package/dist/walkthrough/caption.d.ts.map +1 -0
- package/dist/walkthrough/caption.js +36 -0
- package/dist/walkthrough/caption.js.map +1 -0
- package/dist/walkthrough/embed.d.ts +31 -0
- package/dist/walkthrough/embed.d.ts.map +1 -0
- package/dist/walkthrough/embed.js +297 -0
- package/dist/walkthrough/embed.js.map +1 -0
- package/dist/walkthrough/index.d.ts +8 -0
- package/dist/walkthrough/index.d.ts.map +1 -0
- package/dist/walkthrough/index.js +6 -0
- package/dist/walkthrough/index.js.map +1 -0
- package/dist/walkthrough/layout.d.ts +28 -0
- package/dist/walkthrough/layout.d.ts.map +1 -0
- package/dist/walkthrough/layout.js +31 -0
- package/dist/walkthrough/layout.js.map +1 -0
- package/dist/walkthrough/nest.d.ts +4 -0
- package/dist/walkthrough/nest.d.ts.map +1 -0
- package/dist/walkthrough/nest.js +4 -0
- package/dist/walkthrough/nest.js.map +1 -0
- package/dist/walkthrough/resolve.d.ts +45 -0
- package/dist/walkthrough/resolve.d.ts.map +1 -0
- package/dist/walkthrough/resolve.js +189 -0
- package/dist/walkthrough/resolve.js.map +1 -0
- package/dist/walkthrough/tile-ids.d.ts +8 -0
- package/dist/walkthrough/tile-ids.d.ts.map +1 -0
- package/dist/walkthrough/tile-ids.js +16 -0
- package/dist/walkthrough/tile-ids.js.map +1 -0
- package/dist/walkthrough/tiles.d.ts +15 -0
- package/dist/walkthrough/tiles.d.ts.map +1 -0
- package/dist/walkthrough/tiles.js +80 -0
- package/dist/walkthrough/tiles.js.map +1 -0
- package/package.json +7 -3
- package/src/glob.ts +76 -11
- package/src/index.ts +23 -6
- package/src/manifest.ts +20 -3
- package/src/render-all.ts +195 -0
- package/src/render.ts +8 -116
- package/src/svg/document.ts +3 -2
- package/src/theme.ts +4 -0
- package/src/version.ts +1 -1
- package/src/walkthrough/camera.ts +142 -0
- package/src/walkthrough/caption.ts +35 -0
- package/src/walkthrough/embed.ts +436 -0
- package/src/walkthrough/index.ts +42 -0
- package/src/walkthrough/layout.ts +46 -0
- package/src/walkthrough/nest.ts +6 -0
- package/src/walkthrough/resolve.ts +268 -0
- package/src/walkthrough/tile-ids.ts +17 -0
- 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/glob.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","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AAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;wBAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAChE,CAAC;gBACD,MAAM;YACR,KAAK,KAAK;gBACR,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,GAAG,IAAI,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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,
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,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@@ -1,9 +1,13 @@
|
|
|
1
1
|
export { RENDERER_NAME, RENDERER_VERSION } from "./version.js";
|
|
2
|
-
export { render
|
|
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,
|
|
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,EAAE,MAAM,EAAwC,MAAM,aAAa,CAAC;AAE3E,OAAO,EACL,SAAS,GAOV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,gBAAgB,GAIjB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAiB,MAAM,wBAAwB,CAAC;AAE9E,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAoB,MAAM,YAAY,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAwB,MAAM,aAAa,CAAC;AAItE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAA4C,MAAM,YAAY,CAAC;AAEnH,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB,kBAAkB,GAEnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC"}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,5 +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
|
-
|
|
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
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -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;
|
|
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,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE7G,OAAO,EAAU,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAGhE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAC4C,CAAC;AAEzF,0DAA0D;AAC1D,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAG9E,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,aAAa,UAAW,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
|
-
|
|
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
|
package/dist/manifest.js.map
CHANGED
|
@@ -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,
|
|
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,EA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EACb,MAA8B,EAC9B,WAAwC,EACxB,EAAE,CAAC,CAAC;IACpB,aAAa,EAAE,cAAc;IAC7B,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG;QAChC,WAAW,EAAE,gBAAgB,CAAC,GAAG,CAAC;KACnC;IACD,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE;IAC5D,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC;IACnB,WAAW,EAAE,CAAC,GAAG,WAAW,CAAC;CAC9B,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Config, GraphDoc, RenderAsset, 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 };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,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
|
|
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
35
|
//# sourceMappingURL=render.d.ts.map
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAmB,MAAM,yBAAyB,CAAC;AAEvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAMpD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AAIF,eAAO,MAAM,OAAO,QAAS,QAAQ,UAAU,MAAM,GAAG,SAAS,KAAG,QACJ,CAAC;AAoCjE;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,QAAS,QAAQ,WAAW,aAAa,KAAG,WAyC9D,CAAC"}
|
package/dist/render.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { assertNever
|
|
1
|
+
import { assertNever } from "@coldtea/pr-lens-schema";
|
|
2
2
|
import { applyCorrections } from "./corrections.js";
|
|
3
3
|
import { PrLensRenderError } from "./errors.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { paletteFor, THEME_PAIR } from "./theme.js";
|
|
4
|
+
import { findView, resolveScope } from "./scope.js";
|
|
5
|
+
import { paletteFor } from "./theme.js";
|
|
7
6
|
import { paintArchitecture } from "./svg/architecture.js";
|
|
8
7
|
import { paintDataFlow } from "./svg/dataflow.js";
|
|
9
8
|
import { paintDataModel } from "./svg/datamodel.js";
|
|
10
9
|
import { svgDocument } from "./svg/document.js";
|
|
11
10
|
const WHOLE_DOCUMENT = { kind: "all" };
|
|
12
|
-
const prepare = (doc, config) => config === undefined ? doc : applyCorrections(doc, config.map);
|
|
11
|
+
export const prepare = (doc, config) => config === undefined ? doc : applyCorrections(doc, config.map);
|
|
13
12
|
const paint = (lens, graph, doc, theme) => {
|
|
14
13
|
const palette = paletteFor(theme);
|
|
15
14
|
switch (lens) {
|
|
@@ -63,6 +62,7 @@ export const render = (doc, options) => {
|
|
|
63
62
|
});
|
|
64
63
|
return {
|
|
65
64
|
svg,
|
|
65
|
+
body,
|
|
66
66
|
width,
|
|
67
67
|
height,
|
|
68
68
|
lens: options.lens,
|
|
@@ -78,74 +78,4 @@ const requireView = (views, id) => {
|
|
|
78
78
|
throw new PrLensRenderError("UNKNOWN_VIEW", `this document has no view '${id}'`);
|
|
79
79
|
return view;
|
|
80
80
|
};
|
|
81
|
-
/**
|
|
82
|
-
* Every drill-down section a comment will show, in both themes.
|
|
83
|
-
*
|
|
84
|
-
* A document with no sections still renders: it gets one diagram per lens it
|
|
85
|
-
* declares, which is what a comment falls back to when extraction found
|
|
86
|
-
* nothing worth splitting into a tree.
|
|
87
|
-
*/
|
|
88
|
-
export const renderAll = (doc, options = {}) => {
|
|
89
|
-
const prepared = prepare(doc, options.config);
|
|
90
|
-
const themes = options.themes ?? THEME_PAIR;
|
|
91
|
-
const targets = prepared.views.length > 0
|
|
92
|
-
? flattenViews(prepared.views)
|
|
93
|
-
.filter((view) => prepared.lenses.includes(view.lens))
|
|
94
|
-
.map((view) => ({ lens: view.lens, view }))
|
|
95
|
-
: prepared.lenses
|
|
96
|
-
.filter((lens) => {
|
|
97
|
-
switch (lens) {
|
|
98
|
-
case "architecture":
|
|
99
|
-
return true;
|
|
100
|
-
case "data-flow":
|
|
101
|
-
return prepared.flows.length > 0;
|
|
102
|
-
case "data-model":
|
|
103
|
-
return prepared.dataModel !== undefined;
|
|
104
|
-
default:
|
|
105
|
-
return assertNever(lens, "Unhandled lens");
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
.map((lens) => ({ lens, view: undefined }));
|
|
109
|
-
/**
|
|
110
|
-
* The contract caps a view tree at the number of views a two-theme render
|
|
111
|
-
* fits inside a manifest, so a parsed document cannot reach this. A
|
|
112
|
-
* hand-built one can: the cap lives in a refinement, and a refinement does
|
|
113
|
-
* not survive into the inferred type. This is a postcondition on what is
|
|
114
|
-
* about to be produced rather than a re-reading of what came in — the count
|
|
115
|
-
* depends on how many themes the caller asked for, which no document knows.
|
|
116
|
-
*/
|
|
117
|
-
if (targets.length * themes.length > MAX_RENDER_ASSETS)
|
|
118
|
-
throw new PrLensRenderError("TOO_MANY_ASSETS", `this document asks for ${targets.length * themes.length} pictures across ${targets.length} views ` +
|
|
119
|
-
`and ${themes.length} themes, and a render manifest carries at most ${MAX_RENDER_ASSETS}`);
|
|
120
|
-
const assets = [];
|
|
121
|
-
for (const target of targets)
|
|
122
|
-
for (const theme of themes) {
|
|
123
|
-
const rendered = render(prepared, {
|
|
124
|
-
lens: target.lens,
|
|
125
|
-
theme,
|
|
126
|
-
view: target.view?.id,
|
|
127
|
-
});
|
|
128
|
-
const address = { lens: target.lens, theme, view: target.view?.id };
|
|
129
|
-
const hash = contentHash(rendered.svg);
|
|
130
|
-
assets.push({
|
|
131
|
-
...rendered,
|
|
132
|
-
asset: {
|
|
133
|
-
id: renderAssetId(address),
|
|
134
|
-
lens: target.lens,
|
|
135
|
-
theme,
|
|
136
|
-
view: target.view?.id,
|
|
137
|
-
mediaType: "image/svg+xml",
|
|
138
|
-
contentHash: hash,
|
|
139
|
-
bytes: Buffer.byteLength(rendered.svg, "utf8"),
|
|
140
|
-
width: rendered.width,
|
|
141
|
-
height: rendered.height,
|
|
142
|
-
animated: rendered.animated,
|
|
143
|
-
path: renderAssetFileName(address, hash),
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (assets.length === 0)
|
|
148
|
-
throw new PrLensRenderError("NOTHING_TO_RENDER", "this document declares no renderable view");
|
|
149
|
-
return { assets, manifest: buildManifest(prepared, assets.map(({ asset }) => asset)) };
|
|
150
|
-
};
|
|
151
81
|
//# sourceMappingURL=render.js.map
|
package/dist/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAyBhD,MAAM,cAAc,GAAc,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAElD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAa,EAAE,MAA0B,EAAY,EAAE,CAC7E,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;AAEjE,MAAM,KAAK,GAAG,CACZ,IAAU,EACV,KAAkB,EAClB,GAAa,EACb,KAAY,EAC4E,EAAE;IAC1F,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAElC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,cAAc,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,KAAK,CAA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