@kensio/colophon 2.11.0 → 2.12.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 +1 -1
- package/dist/astro/index.d.ts.map +1 -1
- package/dist/astro/index.js +0 -1
- package/dist/astro/index.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +5 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/image/media.d.ts.map +1 -1
- package/dist/image/media.js.map +1 -1
- package/dist/image/svg.js +1 -1
- package/dist/measure/faces.d.ts.map +1 -1
- package/dist/measure/faces.js.map +1 -1
- package/dist/platform/base64.d.ts.map +1 -1
- package/dist/platform/base64.js +0 -2
- package/dist/platform/base64.js.map +1 -1
- package/dist/pool.js +1 -1
- package/dist/templates/banner/index.js +2 -2
- package/dist/templates/banner/index.js.map +1 -1
- package/dist/templates/card/index.js +2 -2
- package/dist/templates/card/index.js.map +1 -1
- package/dist/templates/code/bar.d.ts +24 -0
- package/dist/templates/code/bar.d.ts.map +1 -0
- package/dist/templates/code/bar.js +31 -0
- package/dist/templates/code/bar.js.map +1 -0
- package/dist/templates/code/gutter.d.ts +30 -0
- package/dist/templates/code/gutter.d.ts.map +1 -0
- package/dist/templates/code/gutter.js +64 -0
- package/dist/templates/code/gutter.js.map +1 -0
- package/dist/templates/code/index.d.ts.map +1 -1
- package/dist/templates/code/index.js +34 -15
- package/dist/templates/code/index.js.map +1 -1
- package/dist/templates/code/layout.d.ts +6 -1
- package/dist/templates/code/layout.d.ts.map +1 -1
- package/dist/templates/code/layout.js +8 -3
- package/dist/templates/code/layout.js.map +1 -1
- package/dist/templates/code/mark/draw.d.ts +26 -0
- package/dist/templates/code/mark/draw.d.ts.map +1 -0
- package/dist/templates/code/mark/draw.js +41 -0
- package/dist/templates/code/mark/draw.js.map +1 -0
- package/dist/templates/code/mark/index.d.ts +16 -0
- package/dist/templates/code/mark/index.d.ts.map +1 -0
- package/dist/templates/code/mark/index.js +34 -0
- package/dist/templates/code/mark/index.js.map +1 -0
- package/dist/templates/code/mark/locate.d.ts +20 -0
- package/dist/templates/code/mark/locate.d.ts.map +1 -0
- package/dist/templates/code/mark/locate.js +56 -0
- package/dist/templates/code/mark/locate.js.map +1 -0
- package/dist/templates/code/mark/read.d.ts +30 -0
- package/dist/templates/code/mark/read.d.ts.map +1 -0
- package/dist/templates/code/mark/read.js +61 -0
- package/dist/templates/code/mark/read.js.map +1 -0
- package/dist/templates/code/plate.d.ts +7 -1
- package/dist/templates/code/plate.d.ts.map +1 -1
- package/dist/templates/code/plate.js +14 -4
- package/dist/templates/code/plate.js.map +1 -1
- package/dist/templates/footer.d.ts +9 -1
- package/dist/templates/footer.d.ts.map +1 -1
- package/dist/templates/footer.js +24 -0
- package/dist/templates/footer.js.map +1 -1
- package/dist/templates/frame.d.ts.map +1 -1
- package/dist/templates/frame.js +5 -7
- package/dist/templates/frame.js.map +1 -1
- package/dist/templates/terminal/index.js +4 -4
- package/dist/templates/terminal/index.js.map +1 -1
- package/dist/templates/window/dots.d.ts +11 -0
- package/dist/templates/window/dots.d.ts.map +1 -0
- package/dist/templates/window/dots.js +32 -0
- package/dist/templates/window/dots.js.map +1 -0
- package/dist/templates/{terminal/window.d.ts → window/index.d.ts} +4 -2
- package/dist/templates/window/index.d.ts.map +1 -0
- package/dist/templates/window/index.js +48 -0
- package/dist/templates/window/index.js.map +1 -0
- package/dist/templates/window/title.d.ts +9 -0
- package/dist/templates/window/title.d.ts.map +1 -0
- package/dist/templates/window/title.js +24 -0
- package/dist/templates/window/title.js.map +1 -0
- package/dist/texture/chevrons.d.ts +13 -0
- package/dist/texture/chevrons.d.ts.map +1 -0
- package/dist/texture/chevrons.js +22 -0
- package/dist/texture/chevrons.js.map +1 -0
- package/dist/texture/color.d.ts +10 -0
- package/dist/texture/color.d.ts.map +1 -0
- package/dist/texture/color.js +10 -0
- package/dist/texture/color.js.map +1 -0
- package/dist/texture/grid.d.ts +14 -0
- package/dist/texture/grid.d.ts.map +1 -0
- package/dist/texture/grid.js +38 -0
- package/dist/texture/grid.js.map +1 -0
- package/dist/texture/halftone.d.ts +14 -0
- package/dist/texture/halftone.d.ts.map +1 -0
- package/dist/texture/halftone.js +55 -0
- package/dist/texture/halftone.js.map +1 -0
- package/dist/texture/honeycomb.d.ts +14 -0
- package/dist/texture/honeycomb.d.ts.map +1 -0
- package/dist/texture/honeycomb.js +43 -0
- package/dist/texture/honeycomb.js.map +1 -0
- package/dist/texture/index.d.ts.map +1 -1
- package/dist/texture/index.js +44 -8
- package/dist/texture/index.js.map +1 -1
- package/dist/texture/moire.d.ts +18 -0
- package/dist/texture/moire.d.ts.map +1 -0
- package/dist/texture/moire.js +44 -0
- package/dist/texture/moire.js.map +1 -0
- package/dist/texture/pattern.d.ts +10 -0
- package/dist/texture/pattern.d.ts.map +1 -1
- package/dist/texture/pattern.js +37 -15
- package/dist/texture/pattern.js.map +1 -1
- package/dist/texture/rays.d.ts +13 -0
- package/dist/texture/rays.d.ts.map +1 -0
- package/dist/texture/rays.js +36 -0
- package/dist/texture/rays.js.map +1 -0
- package/dist/texture/resolve.d.ts +5 -4
- package/dist/texture/resolve.d.ts.map +1 -1
- package/dist/texture/resolve.js +5 -4
- package/dist/texture/resolve.js.map +1 -1
- package/dist/texture/scallops.d.ts +14 -0
- package/dist/texture/scallops.d.ts.map +1 -0
- package/dist/texture/scallops.js +29 -0
- package/dist/texture/scallops.js.map +1 -0
- package/dist/texture/tile.d.ts +14 -0
- package/dist/texture/tile.d.ts.map +1 -0
- package/dist/texture/tile.js +23 -0
- package/dist/texture/tile.js.map +1 -0
- package/dist/texture/topographic/contours.d.ts +13 -0
- package/dist/texture/topographic/contours.d.ts.map +1 -0
- package/dist/texture/topographic/contours.js +72 -0
- package/dist/texture/topographic/contours.js.map +1 -0
- package/dist/texture/topographic/field.d.ts +8 -0
- package/dist/texture/topographic/field.d.ts.map +1 -0
- package/dist/texture/topographic/field.js +29 -0
- package/dist/texture/topographic/field.js.map +1 -0
- package/dist/texture/topographic/index.d.ts +17 -0
- package/dist/texture/topographic/index.d.ts.map +1 -0
- package/dist/texture/topographic/index.js +48 -0
- package/dist/texture/topographic/index.js.map +1 -0
- package/dist/texture/waves.d.ts +18 -0
- package/dist/texture/waves.d.ts.map +1 -0
- package/dist/texture/waves.js +55 -0
- package/dist/texture/waves.js.map +1 -0
- package/dist/theme/presets.d.ts +13 -5
- package/dist/theme/presets.d.ts.map +1 -1
- package/dist/theme/presets.js +16 -5
- package/dist/theme/presets.js.map +1 -1
- package/dist/types.d.ts +256 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/collect.d.ts.map +1 -1
- package/dist/validate/collect.js +2 -1
- package/dist/validate/collect.js.map +1 -1
- package/dist/validate/keys.d.ts +41 -2
- package/dist/validate/keys.d.ts.map +1 -1
- package/dist/validate/keys.js +141 -4
- package/dist/validate/keys.js.map +1 -1
- package/dist/validate/texture.d.ts +4 -5
- package/dist/validate/texture.d.ts.map +1 -1
- package/dist/validate/texture.js +11 -16
- package/dist/validate/texture.js.map +1 -1
- package/dist/validate/values.d.ts +6 -0
- package/dist/validate/values.d.ts.map +1 -1
- package/dist/validate/values.js +16 -1
- package/dist/validate/values.js.map +1 -1
- package/package.json +23 -31
- package/dist/highlight/probe.d.ts +0 -4
- package/dist/highlight/probe.d.ts.map +0 -1
- package/dist/highlight/probe.js +0 -4
- package/dist/highlight/probe.js.map +0 -1
- package/dist/jpeg/index.d.ts +0 -10
- package/dist/jpeg/index.d.ts.map +0 -1
- package/dist/jpeg/index.js +0 -2
- package/dist/jpeg/index.js.map +0 -1
- package/dist/render/png.d.ts +0 -20
- package/dist/render/png.d.ts.map +0 -1
- package/dist/render/png.js +0 -29
- package/dist/render/png.js.map +0 -1
- package/dist/stamp/chunk.d.ts +0 -14
- package/dist/stamp/chunk.d.ts.map +0 -1
- package/dist/stamp/chunk.js +0 -38
- package/dist/stamp/chunk.js.map +0 -1
- package/dist/templates/code/ellipsis.d.ts +0 -3
- package/dist/templates/code/ellipsis.d.ts.map +0 -1
- package/dist/templates/code/ellipsis.js +0 -3
- package/dist/templates/code/ellipsis.js.map +0 -1
- package/dist/templates/terminal/window.d.ts.map +0 -1
- package/dist/templates/terminal/window.js +0 -84
- package/dist/templates/terminal/window.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { box } from "../../../layout/index.js";
|
|
2
|
+
/** Clear space around the marked characters, as a fraction of the size. */
|
|
3
|
+
const padScale = 0.16;
|
|
4
|
+
/** The band a line's glyphs are drawn in, which is what a mark encloses. */
|
|
5
|
+
function lineRect(span, metrics) {
|
|
6
|
+
const { originY, step, fontSize } = metrics;
|
|
7
|
+
const pad = fontSize * padScale;
|
|
8
|
+
return {
|
|
9
|
+
y: Math.round(originY + span.line * step + (step - fontSize) / 2 - pad),
|
|
10
|
+
height: Math.round(fontSize + pad * 2),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A mark over one span of code: a box around the characters, or a band across
|
|
15
|
+
* the line where the post named no columns.
|
|
16
|
+
*
|
|
17
|
+
* The box is stroked and the band is filled, which is the difference between
|
|
18
|
+
* pointing at something and highlighting it. Both take the palette's warm
|
|
19
|
+
* accent by default, so a mark is the one thing on the image that is neither
|
|
20
|
+
* the code theme's colours nor the site's brand.
|
|
21
|
+
*/
|
|
22
|
+
export function markSvg(span, metrics, color) {
|
|
23
|
+
const { originX, charWidth, fontSize } = metrics;
|
|
24
|
+
const { y, height } = lineRect(span, metrics);
|
|
25
|
+
const fill = span.color ?? color;
|
|
26
|
+
if (span.length === undefined) {
|
|
27
|
+
return box({ x: metrics.band.x, y, width: metrics.band.width, height }, { radius: Math.round(fontSize * 0.2), fill, fillOpacity: 0.16 });
|
|
28
|
+
}
|
|
29
|
+
const pad = charWidth * padScale;
|
|
30
|
+
return box({
|
|
31
|
+
x: Math.round(originX + span.column * charWidth - pad),
|
|
32
|
+
y,
|
|
33
|
+
width: Math.round(span.length * charWidth + pad * 2),
|
|
34
|
+
height,
|
|
35
|
+
}, {
|
|
36
|
+
radius: Math.round(fontSize * 0.2),
|
|
37
|
+
stroke: fill,
|
|
38
|
+
strokeWidth: Math.max(1, Math.round(fontSize * 0.08)),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=draw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw.js","sourceRoot":"","sources":["../../../../src/templates/code/mark/draw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAe/C,2EAA2E;AAC3E,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,4EAA4E;AAC5E,SAAS,QAAQ,CACf,IAAc,EACd,OAAoB;IAEpB,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAEhC,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QACvE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC;KACvC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CACrB,IAAc,EACd,OAAoB,EACpB,KAAa;IAEb,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC;IAEjC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,GAAG,CACR,EAAE,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAC3D,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAChE,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,SAAS,GAAG,QAAQ,CAAC;IAEjC,OAAO,GAAG,CACR;QACE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,SAAS,GAAG,GAAG,CAAC;QACtD,CAAC;QACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC;QACpD,MAAM;KACP,EACD;QACE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC;QAClC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;KACtD,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CodeToken } from "../../../highlight/index.js";
|
|
2
|
+
import type { MetaImageProps, ResolvedConfig } from "../../../types.js";
|
|
3
|
+
import type { MarkMetrics } from "./draw.js";
|
|
4
|
+
export type { MarkMetrics } from "./draw.js";
|
|
5
|
+
/**
|
|
6
|
+
* What a post asked to have marked on its snippet, drawn over the code.
|
|
7
|
+
*
|
|
8
|
+
* A mark that cannot be placed is reported rather than dropped quietly. There
|
|
9
|
+
* are three ways to get one, and an author cannot tell them apart from the
|
|
10
|
+
* image: the text is not in the snippet at all, or it is on a line the fitting
|
|
11
|
+
* dropped, or it was past the width and got clipped. The message says the
|
|
12
|
+
* marks were not found, and the truncation warning beside it says whether
|
|
13
|
+
* there was room for them.
|
|
14
|
+
*/
|
|
15
|
+
export declare function codeMarks(props: MetaImageProps, lines: readonly (readonly CodeToken[])[], metrics: MarkMetrics, config: ResolvedConfig): string;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/templates/code/mark/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,EACxC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,cAAc,GACrB,MAAM,CA0BR"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { markSvg } from "./draw.js";
|
|
2
|
+
import { locateMark } from "./locate.js";
|
|
3
|
+
import { readMarks } from "./read.js";
|
|
4
|
+
/**
|
|
5
|
+
* What a post asked to have marked on its snippet, drawn over the code.
|
|
6
|
+
*
|
|
7
|
+
* A mark that cannot be placed is reported rather than dropped quietly. There
|
|
8
|
+
* are three ways to get one, and an author cannot tell them apart from the
|
|
9
|
+
* image: the text is not in the snippet at all, or it is on a line the fitting
|
|
10
|
+
* dropped, or it was past the width and got clipped. The message says the
|
|
11
|
+
* marks were not found, and the truncation warning beside it says whether
|
|
12
|
+
* there was room for them.
|
|
13
|
+
*/
|
|
14
|
+
export function codeMarks(props, lines, metrics, config) {
|
|
15
|
+
// Widened because this arrives from a post's frontmatter: the declared type
|
|
16
|
+
// is what a project means to write, not what the file holds.
|
|
17
|
+
const declared = props["mark"];
|
|
18
|
+
const missing = [];
|
|
19
|
+
let drawn = "";
|
|
20
|
+
for (const mark of readMarks(declared, config)) {
|
|
21
|
+
const span = locateMark(mark, lines);
|
|
22
|
+
if (span === undefined) {
|
|
23
|
+
missing.push(mark.text ?? `line ${String(mark.line ?? 0)}`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
drawn += markSvg(span, metrics, config.colors.brandWarm);
|
|
27
|
+
}
|
|
28
|
+
if (missing.length > 0) {
|
|
29
|
+
config.onWarning(`code mark ${missing.map((name) => JSON.stringify(name)).join(", ")}` +
|
|
30
|
+
` not found in the snippet as drawn.`);
|
|
31
|
+
}
|
|
32
|
+
return drawn;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/templates/code/mark/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CACvB,KAAqB,EACrB,KAAwC,EACxC,OAAoB,EACpB,MAAsB;IAEtB,4EAA4E;IAC5E,6DAA6D;IAC7D,MAAM,QAAQ,GAAY,KAAK,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,KAAK,GAAG,EAAE,CAAC;IAEf,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAErC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,QAAQ,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;YAC5D,SAAS;QACX,CAAC;QAED,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,SAAS,CACd,aAAa,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACnE,qCAAqC,CACxC,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CodeToken } from "../../../highlight/index.js";
|
|
2
|
+
import type { CodeMark } from "./read.js";
|
|
3
|
+
/** Where a mark landed on the character grid, once it was found. */
|
|
4
|
+
export interface MarkSpan {
|
|
5
|
+
/** Zero-based, into the lines being drawn. */
|
|
6
|
+
readonly line: number;
|
|
7
|
+
readonly column: number;
|
|
8
|
+
/** Characters, or `undefined` for the whole line. */
|
|
9
|
+
readonly length: number | undefined;
|
|
10
|
+
readonly color: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Turn a declared mark into grid coordinates, or nothing where it names
|
|
14
|
+
* something the image does not show.
|
|
15
|
+
*
|
|
16
|
+
* A mark naming a line and no column is the whole line, which is the band an
|
|
17
|
+
* editor draws rather than a box around a word.
|
|
18
|
+
*/
|
|
19
|
+
export declare function locateMark(mark: CodeMark, lines: readonly (readonly CodeToken[])[]): MarkSpan | undefined;
|
|
20
|
+
//# sourceMappingURL=locate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locate.d.ts","sourceRoot":"","sources":["../../../../src/templates/code/mark/locate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,oEAAoE;AACpE,MAAM,WAAW,QAAQ;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAsCD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,GACvC,QAAQ,GAAG,SAAS,CAyBtB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One line as plain text, rebuilt from the tokens by putting each back at its
|
|
3
|
+
* own column.
|
|
4
|
+
*
|
|
5
|
+
* The tokens are what survived highlighting, fitting and clipping, so this is
|
|
6
|
+
* the line as it will be drawn rather than as it was written. Searching what
|
|
7
|
+
* is drawn is the point: a mark on a line that was dropped has nowhere to go,
|
|
8
|
+
* and finding it in the original snippet would only mean drawing a box in the
|
|
9
|
+
* wrong place.
|
|
10
|
+
*/
|
|
11
|
+
function lineText(tokens) {
|
|
12
|
+
let text = "";
|
|
13
|
+
for (const token of tokens) {
|
|
14
|
+
text = text.padEnd(token.column, " ") + token.text;
|
|
15
|
+
}
|
|
16
|
+
return text;
|
|
17
|
+
}
|
|
18
|
+
/** The first line holding the text, and where on it. */
|
|
19
|
+
function findText(text, lines) {
|
|
20
|
+
for (const [line, tokens] of lines.entries()) {
|
|
21
|
+
const column = lineText(tokens).indexOf(text);
|
|
22
|
+
if (column !== -1) {
|
|
23
|
+
return { line, column };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Turn a declared mark into grid coordinates, or nothing where it names
|
|
30
|
+
* something the image does not show.
|
|
31
|
+
*
|
|
32
|
+
* A mark naming a line and no column is the whole line, which is the band an
|
|
33
|
+
* editor draws rather than a box around a word.
|
|
34
|
+
*/
|
|
35
|
+
export function locateMark(mark, lines) {
|
|
36
|
+
const color = mark.color;
|
|
37
|
+
if (mark.text !== undefined) {
|
|
38
|
+
const found = findText(mark.text, lines);
|
|
39
|
+
return found === undefined
|
|
40
|
+
? undefined
|
|
41
|
+
: { ...found, length: mark.length ?? mark.text.length, color };
|
|
42
|
+
}
|
|
43
|
+
const line = (mark.line ?? 0) - 1;
|
|
44
|
+
if (line < 0 || line >= lines.length) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return mark.column === undefined
|
|
48
|
+
? { line, column: 0, length: undefined, color }
|
|
49
|
+
: {
|
|
50
|
+
line,
|
|
51
|
+
column: mark.column - 1,
|
|
52
|
+
length: mark.length ?? 1,
|
|
53
|
+
color,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=locate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locate.js","sourceRoot":"","sources":["../../../../src/templates/code/mark/locate.ts"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AACH,SAAS,QAAQ,CAAC,MAA4B;IAC5C,IAAI,IAAI,GAAG,EAAE,CAAC;IAEd,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,C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AC,CAAC;YACE,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC;YACxB,KAAK;SACN,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "../../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* One thing a post asked to have marked on its snippet.
|
|
4
|
+
*
|
|
5
|
+
* `text` names it by what it says, which is what frontmatter usually wants: it
|
|
6
|
+
* survives the snippet being edited above the line, and it is what somebody
|
|
7
|
+
* would type. `line` and `column` name it by where it is, for the times the
|
|
8
|
+
* same text appears twice or the thing worth marking is a whole line.
|
|
9
|
+
*/
|
|
10
|
+
export interface CodeMark {
|
|
11
|
+
readonly text?: string;
|
|
12
|
+
/** One-based, as an editor counts. */
|
|
13
|
+
readonly line?: number;
|
|
14
|
+
/** One-based. Omit it, with no `text`, to mark the whole line. */
|
|
15
|
+
readonly column?: number;
|
|
16
|
+
/** Characters from `column`. Defaults to what `text` is, or the line. */
|
|
17
|
+
readonly length?: number;
|
|
18
|
+
/** Defaults to the palette's warm accent. */
|
|
19
|
+
readonly color?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The marks a post declared: one, or a list of them.
|
|
23
|
+
*
|
|
24
|
+
* Anything that is neither a string nor an object saying where to look is a
|
|
25
|
+
* mistake in the frontmatter, and it is reported rather than dropped. A mark
|
|
26
|
+
* that goes missing is invisible in the finished image, so nothing else would
|
|
27
|
+
* ever say the post asked for one.
|
|
28
|
+
*/
|
|
29
|
+
export declare function readMarks(declared: unknown, config: ResolvedConfig): readonly CodeMark[];
|
|
30
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../../src/templates/code/mark/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AA8CD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,cAAc,GACrB,SAAS,QAAQ,EAAE,CAuBrB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { optionalString } from "../../../props.js";
|
|
2
|
+
function number(value) {
|
|
3
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
4
|
+
? value
|
|
5
|
+
: undefined;
|
|
6
|
+
}
|
|
7
|
+
/** One declared mark, read field by field the way a badge is. */
|
|
8
|
+
function markFromProps(declared) {
|
|
9
|
+
const read = (key) => key in declared ? declared[key] : undefined;
|
|
10
|
+
const text = optionalString(read("text"));
|
|
11
|
+
const line = number(read("line"));
|
|
12
|
+
if ((text === undefined || text === "") && line === undefined) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const column = number(read("column"));
|
|
16
|
+
const length = number(read("length"));
|
|
17
|
+
const color = optionalString(read("color"));
|
|
18
|
+
return {
|
|
19
|
+
...(text !== undefined && text !== "" && { text }),
|
|
20
|
+
...(line !== undefined && { line }),
|
|
21
|
+
...(column !== undefined && { column }),
|
|
22
|
+
...(length !== undefined && { length }),
|
|
23
|
+
...(color !== undefined && { color }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** A string is the text to find, and an object is read for its fields. */
|
|
27
|
+
function markFromValue(declared) {
|
|
28
|
+
const text = optionalString(declared);
|
|
29
|
+
if (text !== undefined) {
|
|
30
|
+
return text === "" ? undefined : { text };
|
|
31
|
+
}
|
|
32
|
+
return typeof declared === "object" && declared !== null
|
|
33
|
+
? markFromProps(declared)
|
|
34
|
+
: undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The marks a post declared: one, or a list of them.
|
|
38
|
+
*
|
|
39
|
+
* Anything that is neither a string nor an object saying where to look is a
|
|
40
|
+
* mistake in the frontmatter, and it is reported rather than dropped. A mark
|
|
41
|
+
* that goes missing is invisible in the finished image, so nothing else would
|
|
42
|
+
* ever say the post asked for one.
|
|
43
|
+
*/
|
|
44
|
+
export function readMarks(declared, config) {
|
|
45
|
+
if (declared === undefined) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const values = Array.isArray(declared) ? declared : [declared];
|
|
49
|
+
const marks = [];
|
|
50
|
+
for (const value of values) {
|
|
51
|
+
const mark = markFromValue(value);
|
|
52
|
+
if (mark === undefined) {
|
|
53
|
+
config.onWarning(`code mark ${JSON.stringify(value)} says nothing to mark:` +
|
|
54
|
+
` give it text to find, or a line to draw across.`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
marks.push(mark);
|
|
58
|
+
}
|
|
59
|
+
return marks;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../src/templates/code/mark/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAuBnD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,iEAAiE;AACjE,SAAS,aAAa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AAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI;QACtD,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC;QACzB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,QAAiB,EACjB,MAAsB;IAEtB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAe,EAAE,CAAC;IAE7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QAElC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,CAAC,SAAS,CACd,aAAa,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,wBAAwB;gBACxD,kDAAkD,CACrD,CAAC;YACF,SAAS;QACX,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "../../types.js";
|
|
1
2
|
import type { Panel } from "./panel.js";
|
|
2
3
|
/**
|
|
3
4
|
* Shrink a panel onto its content, keeping it centred in the space it was
|
|
@@ -12,6 +13,11 @@ export declare function hugPanel(available: Panel, wanted: {
|
|
|
12
13
|
* The panel itself: a drop shadow, then the theme-coloured surface it sits on.
|
|
13
14
|
* The surface is stroked rather than left flat, so a dark theme still has an
|
|
14
15
|
* edge against a dark background.
|
|
16
|
+
*
|
|
17
|
+
* A panel the background shows through casts no shadow. The shadow is the same
|
|
18
|
+
* rectangle offset a few pixels, so a translucent surface shows most of it as
|
|
19
|
+
* a dark wash across the panel, which reads as a smudge rather than as depth.
|
|
20
|
+
* A pane of glass is not a raised card, and this is the difference.
|
|
15
21
|
*/
|
|
16
|
-
export declare function panelSvg(available: Panel, background: string, shadowOffset: number): string;
|
|
22
|
+
export declare function panelSvg(available: Panel, background: string, shadowOffset: number, config: ResolvedConfig): string;
|
|
17
23
|
//# sourceMappingURL=plate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate.d.ts","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,KAAK,EAChB,MAAM,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1D,KAAK,CAmBP;AAED
|
|
1
|
+
{"version":3,"file":"plate.d.ts","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,KAAK,EAChB,MAAM,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1D,KAAK,CAmBP;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,cAAc,GACrB,MAAM,CAcR"}
|
|
@@ -21,14 +21,24 @@ export function hugPanel(available, wanted) {
|
|
|
21
21
|
* The panel itself: a drop shadow, then the theme-coloured surface it sits on.
|
|
22
22
|
* The surface is stroked rather than left flat, so a dark theme still has an
|
|
23
23
|
* edge against a dark background.
|
|
24
|
+
*
|
|
25
|
+
* A panel the background shows through casts no shadow. The shadow is the same
|
|
26
|
+
* rectangle offset a few pixels, so a translucent surface shows most of it as
|
|
27
|
+
* a dark wash across the panel, which reads as a smudge rather than as depth.
|
|
28
|
+
* A pane of glass is not a raised card, and this is the difference.
|
|
24
29
|
*/
|
|
25
|
-
export function panelSvg(available, background, shadowOffset) {
|
|
30
|
+
export function panelSvg(available, background, shadowOffset, config) {
|
|
31
|
+
const { panelOpacity, borderColor, borderOpacity } = config.code;
|
|
32
|
+
// A full-opacity surface says nothing about its opacity, which keeps the
|
|
33
|
+
// common case's output to what the template actually decided.
|
|
26
34
|
return panel(available, {
|
|
27
35
|
radius: available.radius,
|
|
28
36
|
fill: background,
|
|
29
|
-
stroke:
|
|
30
|
-
strokeOpacity:
|
|
31
|
-
|
|
37
|
+
stroke: borderColor,
|
|
38
|
+
strokeOpacity: borderOpacity,
|
|
39
|
+
...(panelOpacity < 1
|
|
40
|
+
? { fillOpacity: panelOpacity }
|
|
41
|
+
: { shadow: shadowOffset }),
|
|
32
42
|
});
|
|
33
43
|
}
|
|
34
44
|
//# sourceMappingURL=plate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plate.js","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"plate.js","sourceRoot":"","sources":["../../../src/templates/code/plate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI9C;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,SAAgB,EAChB,M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W,EAAE,YAAY,EAAE;YAC/B,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type { ResolvedConfig } from "../types.js";
|
|
1
|
+
import type { Dimensions, ResolvedConfig } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The size the line along the bottom is drawn at.
|
|
4
|
+
*
|
|
5
|
+
* Every template asks for it here rather than working it out, which is what
|
|
6
|
+
* stops the twelve of them drifting apart. It is one number for the footer,
|
|
7
|
+
* the byline and the attribution alike, since they are all the same line.
|
|
8
|
+
*/
|
|
9
|
+
export declare function footerFontSize(dimensions: Dimensions): number;
|
|
2
10
|
/**
|
|
3
11
|
* Where and how a template wants its footer drawn. Every template places the
|
|
4
12
|
* footer differently; what they share is that a config with no footer, or an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkB9D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAO7D;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,MAAM,CAER;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,eAAe,GACzB,MAAM,CAeR"}
|
package/dist/templates/footer.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { baselineFor, textElement } from "../layout/index.js";
|
|
2
|
+
/** The footer's size, as a fraction of the image's height. */
|
|
3
|
+
const footerScale = 0.036;
|
|
4
|
+
/**
|
|
5
|
+
* The least it may be, as a fraction of the image's width.
|
|
6
|
+
*
|
|
7
|
+
* Height alone is what the footer used to be measured against, and it left the
|
|
8
|
+
* landscape sizes with the smallest text on the least of it: at 1200x630 the
|
|
9
|
+
* line came out at 20px against the square's 38px, on an image a feed scales
|
|
10
|
+
* to the same width. Width is what legibility tracks, for the reason the code
|
|
11
|
+
* template's font-size bounds are fractions of it, so this is the floor that
|
|
12
|
+
* stops a wide image having a footer nobody can read. The square is above it
|
|
13
|
+
* and keeps the proportions it had.
|
|
14
|
+
*/
|
|
15
|
+
const footerWidthFloor = 0.026;
|
|
16
|
+
/**
|
|
17
|
+
* The size the line along the bottom is drawn at.
|
|
18
|
+
*
|
|
19
|
+
* Every template asks for it here rather than working it out, which is what
|
|
20
|
+
* stops the twelve of them drifting apart. It is one number for the footer,
|
|
21
|
+
* the byline and the attribution alike, since they are all the same line.
|
|
22
|
+
*/
|
|
23
|
+
export function footerFontSize(dimensions) {
|
|
24
|
+
return Math.round(Math.max(dimensions.height * footerScale, dimensions.width * footerWidthFloor));
|
|
25
|
+
}
|
|
2
26
|
/**
|
|
3
27
|
* The baseline of a footer sitting on the bottom margin.
|
|
4
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG9D,8DAA8D;AAC9D,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,UAAsB;IACnD,OAAO,IAAI,CAAC,KAAK,CACf,IAAI,CAAC,GAAG,CACN,UAAU,CAAC,MAAM,GAAG,WAAW,EAC/B,UAAU,CAAC,KAAK,GAAG,gBAAgB,CACpC,CACF,CAAC;AACJ,CAAC;AAeD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,GAAW,EACX,QAAgB;IAEhB,OAAO,WAAW,CAAC,MAAM,GAAG,GAAG,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAsB,EACtB,SAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE;QACtC,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;QAC9B,WAAW,EAAE,SAAS,CAAC,OAAO;QAC9B,GAAG,CAAC,SAAS,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;KACpE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQ1E;;;;;;;;GAQG;AACH,MAAM,WAAW,KAAK;IACpB,yCAAyC;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,OAAO,GAAE,YAAiB,GACzB,KAAK,CAcP;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,SAAI,GAAG,IAAI,CAOvD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
package/dist/templates/frame.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { footerBaseline, hasFooter } from "./footer.js";
|
|
1
|
+
import { footerBaseline, footerFontSize, hasFooter } from "./footer.js";
|
|
2
2
|
import { inset } from "../layout/index.js";
|
|
3
3
|
/** Margin from the image edge, as a fraction of its width. */
|
|
4
4
|
const defaultPadScale = 0.075;
|
|
5
|
-
/** The footer's size, as a fraction of the image's height. */
|
|
6
|
-
const footerScale = 0.032;
|
|
7
5
|
/** Clear space between the content and the footer line, as a fraction of it. */
|
|
8
6
|
const footerGap = 0.02;
|
|
9
7
|
/**
|
|
@@ -14,14 +12,14 @@ const footerGap = 0.02;
|
|
|
14
12
|
export function imageFrame(dimensions, config, avatar, options = {}) {
|
|
15
13
|
const { width, height } = dimensions;
|
|
16
14
|
const pad = Math.round(width * (options.padScale ?? defaultPadScale));
|
|
17
|
-
const
|
|
15
|
+
const fontSize = footerFontSize(dimensions);
|
|
18
16
|
const isDrawn = options.footer === true || hasFooter(config) || avatar !== undefined;
|
|
19
17
|
return {
|
|
20
18
|
pad,
|
|
21
|
-
footerFontSize,
|
|
19
|
+
footerFontSize: fontSize,
|
|
22
20
|
full: { x: 0, y: 0, width, height },
|
|
23
|
-
footerRoom: isDrawn ?
|
|
24
|
-
footerY: footerBaseline(height, pad,
|
|
21
|
+
footerRoom: isDrawn ? fontSize + Math.round(height * footerGap) : 0,
|
|
22
|
+
footerY: footerBaseline(height, pad, fontSize),
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,8DAA8D;AAC9D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,gFAAgF;AAChF,MAAM,SAAS,GAAG,IAAI,CAAC;AAsCvB;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,UAAsB,EACtB,MAAsB,EACtB,MAA8B,EAC9B,OAAO,GAAiB,EAAE;IAE1B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,CAAC,CAAC;IACtE,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,OAAO,GACX,OAAO,CAAC,MAAM,KAAK,IAAI,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,SAAS,CAAC;IAEvE,OAAO;QACL,GAAG;QACH,cAAc,EAAE,QAAQ;QACxB,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;QACnC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC;KAC/C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,MAA0B,EAAE,GAAW;IAC9D,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AACjE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,GAAG,GAAG,CAAC;IAC/C,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;QACvB,GAAG,EAAE,KAAK,CAAC,GAAG,GAAG,GAAG;QACpB,KAAK,EAAE,KAAK,CAAC,GAAG;QAChB,IAAI,EAAE,KAAK,CAAC,GAAG;QACf,MAAM,EAAE,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,UAAU;KACrC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,GAAW;IAChD,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9B,CAAC"}
|
|
@@ -7,9 +7,9 @@ import { hugPanel, panelSvg } from "../code/plate.js";
|
|
|
7
7
|
import { codeBody } from "../code/spans.js";
|
|
8
8
|
import { warnIfTruncated } from "../code/warn.js";
|
|
9
9
|
import { charWidthRatio } from "../code/width.js";
|
|
10
|
-
import { hasFooter } from "../footer.js";
|
|
10
|
+
import { footerFontSize, hasFooter } from "../footer.js";
|
|
11
|
+
import { barHeight, titleBar } from "../window/index.js";
|
|
11
12
|
import { terminalSession } from "./session.js";
|
|
12
|
-
import { barHeight, titleBar } from "./window.js";
|
|
13
13
|
/**
|
|
14
14
|
* A command and what it printed, in a terminal window.
|
|
15
15
|
*
|
|
@@ -27,7 +27,7 @@ export const terminalTemplate = {
|
|
|
27
27
|
name: "terminal",
|
|
28
28
|
async render({ props, config, dimensions, measure }) {
|
|
29
29
|
const { width, height } = dimensions;
|
|
30
|
-
const footerFs =
|
|
30
|
+
const footerFs = footerFontSize(dimensions);
|
|
31
31
|
const session = await terminalSession(props, config);
|
|
32
32
|
const available = layoutPanel(dimensions, config, 0, footerFs, false, hasFooter(config));
|
|
33
33
|
// The bar is measured against the space the window was allotted rather
|
|
@@ -45,7 +45,7 @@ export const terminalTemplate = {
|
|
|
45
45
|
height: bar + body + fitted.padding * 2,
|
|
46
46
|
});
|
|
47
47
|
const shadow = Math.max(1, Math.round(Math.min(width, height) * 0.01));
|
|
48
|
-
return (panelSvg(window, session.background, shadow) +
|
|
48
|
+
return (panelSvg(window, session.background, shadow, config) +
|
|
49
49
|
titleBar(window, bar, optionalString(props.title) ?? "", config, measure) +
|
|
50
50
|
codeBody(fitted.lines, {
|
|
51
51
|
originX: window.x + fitted.padding,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/terminal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kB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AAI,CAAC,CAAC,CAAC;QAEvE,OAAO,CACL,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC;YACpD,QAAQ,CACN,MAAM,EACN,GAAG,EACH,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EACjC,MAAM,EACN,OAAO,CACR;YACD,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE;gBACrB,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO;gBAClC,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;gBAC1D,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU;gBAClC,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC;YACF,UAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CACzC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Which buttons a window's bar carries. */
|
|
2
|
+
export type WindowDots = "mono" | "macos";
|
|
3
|
+
/** Where the buttons sit in the bar, and how big they are. */
|
|
4
|
+
export interface DotsLayout {
|
|
5
|
+
readonly left: number;
|
|
6
|
+
readonly middle: number;
|
|
7
|
+
readonly diameter: number;
|
|
8
|
+
}
|
|
9
|
+
/** The row of buttons at the left of the bar. */
|
|
10
|
+
export declare function windowDots(dots: WindowDots, layout: DotsLayout): string;
|
|
11
|
+
//# sourceMappingURL=dots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dots.d.ts","sourceRoot":"","sources":["../../../src/templates/window/dots.ts"],"names":[],"mappings":"AAGA,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAuB1C,8DAA8D;AAC9D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAevE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { box } from "../../layout/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The three buttons, in the colours every reader has seen on a window.
|
|
4
|
+
*
|
|
5
|
+
* They are not the site's colours and are not meant to be. The point of the
|
|
6
|
+
* chrome is that the image is recognised as a window before a word of it is
|
|
7
|
+
* read, and these are what does the recognising.
|
|
8
|
+
*
|
|
9
|
+
* The neutral set says the same thing without borrowing an operating system's
|
|
10
|
+
* colours, which is what a snippet on a site with a palette of its own usually
|
|
11
|
+
* wants. The terminal draws the coloured ones, since a terminal is a window
|
|
12
|
+
* somebody has seen rather than a decorated panel.
|
|
13
|
+
*/
|
|
14
|
+
const macosButtons = ["#ff5f57", "#febc2e", "#28c840"];
|
|
15
|
+
/** One button's fill, which for the neutral set is the bar's own tone. */
|
|
16
|
+
function buttonStyle(dots, index) {
|
|
17
|
+
return dots === "macos"
|
|
18
|
+
? { fill: macosButtons[index] ?? "#ffffff" }
|
|
19
|
+
: { fill: "#ffffff", fillOpacity: 0.28 };
|
|
20
|
+
}
|
|
21
|
+
/** The row of buttons at the left of the bar. */
|
|
22
|
+
export function windowDots(dots, layout) {
|
|
23
|
+
const { left, middle, diameter } = layout;
|
|
24
|
+
const gap = Math.round(diameter * 1.7);
|
|
25
|
+
return Array.from({ length: macosButtons.length }, (_unused, index) => box({
|
|
26
|
+
x: left + index * gap,
|
|
27
|
+
y: middle - Math.round(diameter / 2),
|
|
28
|
+
width: diameter,
|
|
29
|
+
height: diameter,
|
|
30
|
+
}, { radius: Math.round(diameter / 2), ...buttonStyle(dots, index) })).join("");
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=dots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dots.js","sourceRoot":"","sources":["../../../src/templates/window/dots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAM5C;;;;;;;;;;;GAWG;AACH,MAAM,YAAY,GAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAE1E,0EAA0E;AAC1E,SAAS,WAAW,CAAC,IAAgB,EAAE,KAAa;IAClD,OAAO,IAAI,KAAK,OAAO;QACrB,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,IAAI,SAAS,EAAE;QAC5C,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC7C,CAAC;AASD,iDAAiD;AACjD,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,MAAkB;IAC7D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;IAEvC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CACpE,GAAG,CACD;QACE,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,GAAG;QACrB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC;QACpC,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,QAAQ;KACjB,EACD,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAClE,CACF,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { MeasureText, ResolvedConfig } from "../../types.js";
|
|
2
2
|
import type { Panel } from "../code/panel.js";
|
|
3
|
+
import type { WindowDots } from "./dots.js";
|
|
4
|
+
export type { WindowDots } from "./dots.js";
|
|
3
5
|
/** How tall the title bar is on a window of this width. */
|
|
4
6
|
export declare function barHeight(windowWidth: number): number;
|
|
5
7
|
/**
|
|
@@ -10,5 +12,5 @@ export declare function barHeight(windowWidth: number): number;
|
|
|
10
12
|
* lifts whatever the code theme's background happens to be instead of having
|
|
11
13
|
* to be chosen against it.
|
|
12
14
|
*/
|
|
13
|
-
export declare function titleBar(window: Panel, height: number, title: string, config: ResolvedConfig, measure: MeasureText): string;
|
|
14
|
-
//# sourceMappingURL=
|
|
15
|
+
export declare function titleBar(window: Panel, height: number, title: string, config: ResolvedConfig, measure: MeasureText, dots?: WindowDots): string;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/window/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAQ5C,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErD;AAwBD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,WAAW,EACpB,IAAI,GAAE,UAAoB,GACzB,MAAM,CAeR"}
|