@kensio/colophon 2.3.0 → 2.4.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 +62 -801
- package/dist/background.d.ts +7 -2
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +44 -1
- package/dist/background.js.map +1 -1
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/config.js +1 -1
- package/dist/config/defaults.d.ts +8 -7
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +8 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +5 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/resolve.d.ts +7 -0
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +16 -0
- package/dist/config/resolve.js.map +1 -1
- package/dist/config/size.d.ts +1 -1
- package/dist/config/size.d.ts.map +1 -1
- package/dist/config/size.js +3 -2
- package/dist/config/size.js.map +1 -1
- package/dist/content/props.d.ts +2 -2
- package/dist/content/props.js +2 -2
- package/dist/content/slug.d.ts +5 -5
- package/dist/content/slug.js +6 -6
- package/dist/content/slug.js.map +1 -1
- package/dist/content/walk.d.ts +1 -1
- package/dist/content/walk.js +1 -1
- package/dist/fonts/index.d.ts +3 -2
- package/dist/fonts/index.d.ts.map +1 -1
- package/dist/fonts/index.js +3 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/fonts/resolve.js +1 -1
- package/dist/generate/extra.js +4 -4
- package/dist/generate/extra.js.map +1 -1
- package/dist/generate/options.d.ts +1 -1
- package/dist/generate/outputs.d.ts +4 -4
- package/dist/generate/outputs.js +4 -4
- package/dist/highlight/language.d.ts +2 -3
- package/dist/highlight/language.d.ts.map +1 -1
- package/dist/highlight/language.js +3 -4
- package/dist/highlight/language.js.map +1 -1
- package/dist/highlight/normalise.d.ts +2 -2
- package/dist/highlight/normalise.js +2 -2
- package/dist/image/index.d.ts +18 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/index.js +42 -0
- package/dist/image/index.js.map +1 -0
- package/dist/image/jpeg.d.ts +10 -0
- package/dist/image/jpeg.d.ts.map +1 -0
- package/dist/image/jpeg.js +57 -0
- package/dist/image/jpeg.js.map +1 -0
- package/dist/image/load.d.ts +4 -0
- package/dist/image/load.d.ts.map +1 -0
- package/dist/image/load.js +60 -0
- package/dist/image/load.js.map +1 -0
- package/dist/image/media.d.ts +10 -0
- package/dist/image/media.d.ts.map +1 -0
- package/dist/image/media.js +37 -0
- package/dist/image/media.js.map +1 -0
- package/dist/image/resolve.d.ts +13 -0
- package/dist/image/resolve.d.ts.map +1 -0
- package/dist/image/resolve.js +38 -0
- package/dist/image/resolve.js.map +1 -0
- package/dist/image/size.d.ts +22 -0
- package/dist/image/size.d.ts.map +1 -0
- package/dist/image/size.js +60 -0
- package/dist/image/size.js.map +1 -0
- package/dist/image/svg.d.ts +12 -0
- package/dist/image/svg.d.ts.map +1 -0
- package/dist/image/svg.js +61 -0
- package/dist/image/svg.js.map +1 -0
- package/dist/image/uri.d.ts +9 -0
- package/dist/image/uri.d.ts.map +1 -0
- package/dist/image/uri.js +22 -0
- package/dist/image/uri.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/block.d.ts +37 -0
- package/dist/layout/block.d.ts.map +1 -0
- package/dist/layout/block.js +26 -0
- package/dist/layout/block.js.map +1 -0
- package/dist/layout/box.d.ts +20 -0
- package/dist/layout/box.d.ts.map +1 -0
- package/dist/layout/box.js +61 -0
- package/dist/layout/box.js.map +1 -0
- package/dist/layout/distribute.d.ts +15 -0
- package/dist/layout/distribute.d.ts.map +1 -0
- package/dist/layout/distribute.js +30 -0
- package/dist/layout/distribute.js.map +1 -0
- package/dist/layout/image.d.ts +42 -0
- package/dist/layout/image.d.ts.map +1 -0
- package/dist/layout/image.js +34 -0
- package/dist/layout/image.js.map +1 -0
- package/dist/layout/index.d.ts +40 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +30 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/lines.d.ts +45 -0
- package/dist/layout/lines.d.ts.map +1 -0
- package/dist/layout/lines.js +71 -0
- package/dist/layout/lines.js.map +1 -0
- package/dist/layout/measure.d.ts +11 -0
- package/dist/layout/measure.d.ts.map +1 -0
- package/dist/layout/measure.js +11 -0
- package/dist/layout/measure.js.map +1 -0
- package/dist/layout/panel.d.ts +20 -0
- package/dist/layout/panel.d.ts.map +1 -0
- package/dist/layout/panel.js +22 -0
- package/dist/layout/panel.js.map +1 -0
- package/dist/layout/row.d.ts +15 -0
- package/dist/layout/row.d.ts.map +1 -0
- package/dist/layout/row.js +20 -0
- package/dist/layout/row.js.map +1 -0
- package/dist/layout/scrim.d.ts +23 -0
- package/dist/layout/scrim.d.ts.map +1 -0
- package/dist/layout/scrim.js +38 -0
- package/dist/layout/scrim.js.map +1 -0
- package/dist/layout/stack.d.ts +14 -0
- package/dist/layout/stack.d.ts.map +1 -0
- package/dist/layout/stack.js +19 -0
- package/dist/layout/stack.js.map +1 -0
- package/dist/layout/types.d.ts +49 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/types.js +2 -0
- package/dist/layout/types.js.map +1 -0
- package/dist/manifest/build.d.ts +1 -1
- package/dist/manifest/build.js +1 -1
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.js +1 -1
- package/dist/manifest/order.d.ts +1 -1
- package/dist/manifest/order.js +1 -1
- package/dist/manifest/page.d.ts +2 -2
- package/dist/manifest/page.js +3 -3
- package/dist/measure/estimate.d.ts +10 -0
- package/dist/measure/estimate.d.ts.map +1 -0
- package/dist/measure/estimate.js +58 -0
- package/dist/measure/estimate.js.map +1 -0
- package/dist/measure/faces.d.ts +15 -0
- package/dist/measure/faces.d.ts.map +1 -0
- package/dist/measure/faces.js +70 -0
- package/dist/measure/faces.js.map +1 -0
- package/dist/measure/index.d.ts +16 -0
- package/dist/measure/index.d.ts.map +1 -0
- package/dist/measure/index.js +0 -0
- package/dist/measure/index.js.map +1 -0
- package/dist/measure/runs.d.ts +17 -0
- package/dist/measure/runs.d.ts.map +1 -0
- package/dist/measure/runs.js +39 -0
- package/dist/measure/runs.js.map +1 -0
- package/dist/measure/select.d.ts +13 -0
- package/dist/measure/select.d.ts.map +1 -0
- package/dist/measure/select.js +47 -0
- package/dist/measure/select.js.map +1 -0
- package/dist/meta/tags.d.ts +6 -6
- package/dist/meta/tags.js +6 -6
- package/dist/meta/url.d.ts +4 -4
- package/dist/meta/url.js +4 -4
- package/dist/placement/check.d.ts +1 -1
- package/dist/placement/check.js +1 -1
- package/dist/placement/index.js +1 -1
- package/dist/placement/relative.d.ts +3 -3
- package/dist/placement/relative.js +3 -3
- package/dist/pool.d.ts +2 -2
- package/dist/pool.js +3 -3
- package/dist/pool.js.map +1 -1
- package/dist/props.d.ts +7 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +17 -0
- package/dist/props.js.map +1 -0
- package/dist/render/svg.d.ts +4 -2
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render/svg.js +19 -4
- package/dist/render/svg.js.map +1 -1
- package/dist/stamp/config-digest.d.ts.map +1 -1
- package/dist/stamp/config-digest.js +20 -1
- package/dist/stamp/config-digest.js.map +1 -1
- package/dist/stamp/index.js +2 -2
- package/dist/stamp/index.js.map +1 -1
- package/dist/stamp/read.d.ts +1 -1
- package/dist/stamp/read.js +4 -4
- package/dist/templates/attribution.d.ts +17 -0
- package/dist/templates/attribution.d.ts.map +1 -0
- package/dist/templates/attribution.js +39 -0
- package/dist/templates/attribution.js.map +1 -0
- package/dist/templates/banner/badge.d.ts.map +1 -1
- package/dist/templates/banner/badge.js +3 -6
- package/dist/templates/banner/badge.js.map +1 -1
- package/dist/templates/banner/index.d.ts +3 -0
- package/dist/templates/banner/index.d.ts.map +1 -1
- package/dist/templates/banner/index.js +37 -35
- package/dist/templates/banner/index.js.map +1 -1
- package/dist/templates/banner/lines.d.ts +7 -12
- package/dist/templates/banner/lines.d.ts.map +1 -1
- package/dist/templates/banner/lines.js +23 -34
- package/dist/templates/banner/lines.js.map +1 -1
- package/dist/templates/banner/version.d.ts +9 -0
- package/dist/templates/banner/version.d.ts.map +1 -0
- package/dist/templates/banner/version.js +21 -0
- package/dist/templates/banner/version.js.map +1 -0
- package/dist/templates/card/index.d.ts +4 -1
- package/dist/templates/card/index.d.ts.map +1 -1
- package/dist/templates/card/index.js +37 -25
- package/dist/templates/card/index.js.map +1 -1
- package/dist/templates/card/lines.d.ts +17 -13
- package/dist/templates/card/lines.d.ts.map +1 -1
- package/dist/templates/card/lines.js +24 -20
- package/dist/templates/card/lines.js.map +1 -1
- package/dist/templates/code/chrome.d.ts +7 -3
- package/dist/templates/code/chrome.d.ts.map +1 -1
- package/dist/templates/code/chrome.js +12 -11
- package/dist/templates/code/chrome.js.map +1 -1
- package/dist/templates/code/clip.d.ts +1 -1
- package/dist/templates/code/clip.js +1 -1
- package/dist/templates/code/fit.d.ts +2 -2
- package/dist/templates/code/fit.d.ts.map +1 -1
- package/dist/templates/code/fit.js +4 -4
- package/dist/templates/code/fit.js.map +1 -1
- package/dist/templates/code/index.d.ts.map +1 -1
- package/dist/templates/code/index.js +7 -6
- package/dist/templates/code/index.js.map +1 -1
- package/dist/templates/code/layout.d.ts +1 -1
- package/dist/templates/code/layout.d.ts.map +1 -1
- package/dist/templates/code/layout.js +6 -6
- package/dist/templates/code/layout.js.map +1 -1
- package/dist/templates/code/panel.d.ts +13 -0
- package/dist/templates/code/panel.d.ts.map +1 -1
- package/dist/templates/code/panel.js +34 -2
- package/dist/templates/code/panel.js.map +1 -1
- package/dist/templates/code/plate.d.ts +3 -1
- package/dist/templates/code/plate.d.ts.map +1 -1
- package/dist/templates/code/plate.js +11 -9
- package/dist/templates/code/plate.js.map +1 -1
- package/dist/templates/code/spans.js +1 -1
- package/dist/templates/code/spans.js.map +1 -1
- package/dist/templates/code/width.d.ts +10 -0
- package/dist/templates/code/width.d.ts.map +1 -0
- package/dist/templates/code/width.js +26 -0
- package/dist/templates/code/width.js.map +1 -0
- package/dist/templates/footer.d.ts +8 -0
- package/dist/templates/footer.d.ts.map +1 -1
- package/dist/templates/footer.js +11 -1
- package/dist/templates/footer.js.map +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +1 -1
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/logo.d.ts +15 -0
- package/dist/templates/logo.d.ts.map +1 -0
- package/dist/templates/logo.js +30 -0
- package/dist/templates/logo.js.map +1 -0
- package/dist/templates/measure.d.ts +11 -0
- package/dist/templates/measure.d.ts.map +1 -0
- package/dist/templates/measure.js +11 -0
- package/dist/templates/measure.js.map +1 -0
- package/dist/templates/props.d.ts +2 -2
- package/dist/templates/props.js +2 -2
- package/dist/templates/text.d.ts +37 -0
- package/dist/templates/text.d.ts.map +1 -0
- package/dist/templates/text.js +26 -0
- package/dist/templates/text.js.map +1 -0
- package/dist/text/break.d.ts +11 -0
- package/dist/text/break.d.ts.map +1 -0
- package/dist/text/break.js +30 -0
- package/dist/text/break.js.map +1 -0
- package/dist/text/fit.d.ts +30 -0
- package/dist/text/fit.d.ts.map +1 -0
- package/dist/text/fit.js +29 -0
- package/dist/text/fit.js.map +1 -0
- package/dist/text/index.d.ts +5 -3
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +3 -2
- package/dist/text/index.js.map +1 -1
- package/dist/text/wrap.d.ts +17 -7
- package/dist/text/wrap.d.ts.map +1 -1
- package/dist/text/wrap.js +25 -17
- package/dist/text/wrap.js.map +1 -1
- package/dist/types.d.ts +161 -45
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +3 -2
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/keys.d.ts +19 -2
- package/dist/validate/keys.d.ts.map +1 -1
- package/dist/validate/keys.js +40 -3
- package/dist/validate/keys.js.map +1 -1
- package/dist/validate/suggest.d.ts.map +1 -1
- package/dist/validate/suggest.js +21 -3
- package/dist/validate/suggest.js.map +1 -1
- package/dist/validate/values.d.ts +2 -2
- package/dist/validate/values.d.ts.map +1 -1
- package/dist/validate/values.js +17 -3
- package/dist/validate/values.js.map +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { create, open } from "fontkit";
|
|
2
|
+
/**
|
|
3
|
+
* Parsed faces, keyed by the font file's path. A build renders many images
|
|
4
|
+
* from one config, so without this every image would parse every font again.
|
|
5
|
+
*/
|
|
6
|
+
const byPath = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* The same for fonts supplied as bytes, keyed by the array itself. A config
|
|
9
|
+
* holds one of these and hands it to every render, so identity is enough here
|
|
10
|
+
* and hashing the bytes would cost more than the parse it saves.
|
|
11
|
+
*/
|
|
12
|
+
const byData = new WeakMap();
|
|
13
|
+
/**
|
|
14
|
+
* What a face declares about itself. The types say both of these are always
|
|
15
|
+
* there, and a font file is data: one missing its name or its `OS/2` table
|
|
16
|
+
* would otherwise take the build down inside `selectFace`, rather than being
|
|
17
|
+
* measured as well as it can be. A face with no family name matches no stack,
|
|
18
|
+
* so it is only ever reached as the fallback that the first configured font is.
|
|
19
|
+
*/
|
|
20
|
+
function toFace(font) {
|
|
21
|
+
const declared = font;
|
|
22
|
+
return {
|
|
23
|
+
family: declared.familyName ?? "",
|
|
24
|
+
weight: declared["OS/2"]?.usWeightClass ?? 400,
|
|
25
|
+
font,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** A collection file holds several faces; a plain font file holds one. */
|
|
29
|
+
function facesOf(loaded) {
|
|
30
|
+
return "fonts" in loaded
|
|
31
|
+
? loaded.fonts.map((font) => toFace(font))
|
|
32
|
+
: [toFace(loaded)];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse one configured font for measurement, or report that it could not be.
|
|
36
|
+
*
|
|
37
|
+
* A file the rasteriser accepts and this cannot is rare, but it is not fatal:
|
|
38
|
+
* the image still renders, and its text is laid out from estimates instead. It
|
|
39
|
+
* is worth saying so, because wrapping that is quietly approximate is exactly
|
|
40
|
+
* what supplying a font file was meant to stop. The warning goes through the
|
|
41
|
+
* cache below, so a build says it once per file rather than once per image.
|
|
42
|
+
*/
|
|
43
|
+
async function load(font, onWarning) {
|
|
44
|
+
try {
|
|
45
|
+
return facesOf("data" in font ? create(Buffer.from(font.data)) : await open(font.path));
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const name = "data" in font ? (font.family ?? "font data") : font.path;
|
|
49
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
50
|
+
onWarning(`could not read ${name} for text measurement, so text drawn in it is` +
|
|
51
|
+
` wrapped from estimates instead: ${reason}`);
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function cached(font, onWarning) {
|
|
56
|
+
if ("data" in font) {
|
|
57
|
+
const pending = byData.get(font.data) ?? load(font, onWarning);
|
|
58
|
+
byData.set(font.data, pending);
|
|
59
|
+
return pending;
|
|
60
|
+
}
|
|
61
|
+
const pending = byPath.get(font.path) ?? load(font, onWarning);
|
|
62
|
+
byPath.set(font.path, pending);
|
|
63
|
+
return pending;
|
|
64
|
+
}
|
|
65
|
+
/** Every face the configured fonts hold, in the order they were configured. */
|
|
66
|
+
export async function loadFaces(fonts, onWarning) {
|
|
67
|
+
const loaded = await Promise.all(fonts.map(async (font) => cached(font, onWarning)));
|
|
68
|
+
return loaded.flat();
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=faces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faces.js","sourceRoot":"","sources":["../../src/measure/faces.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAevC;;;GAGG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoC,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,GAAG,IAAI,OAAO,EAAwC,CAAC;AAEnE;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,IAAU;IACxB,MAAM,QAAQ,GAAG,IAKhB,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,UAAU,IAAI,EAAE;QACjC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,IAAI,GAAG;QAC9C,IAAI;KACL,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,SAAS,OAAO,CAAC,MAAyC;IACxD,OAAO,OAAO,IAAI,MAAM;QACtB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,IAAI,CACjB,IAAgB,EAChB,SAAyB;IAEzB,IAAI,CAAC;QACH,OAAO,OAAO,CACZ,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CACxE,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACvE,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,SAAS,CACP,kBAAkB,IAAI,+CAA+C;YACnE,oCAAoC,MAAM,EAAE,CAC/C,CAAC;QACF,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CACb,IAAgB,EAChB,SAAyB;IAEzB,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/D,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAA4B,EAC5B,SAAyB;IAEzB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CACnD,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MeasureText, ResolvedConfig } from "../types.js";
|
|
2
|
+
export type { Face } from "./faces.js";
|
|
3
|
+
/**
|
|
4
|
+
* A {@link MeasureText} for the fonts a build is rendering with.
|
|
5
|
+
*
|
|
6
|
+
* Widths are held per em and multiplied by the font size on the way out, which
|
|
7
|
+
* is what makes fitting text affordable: choosing a size means wrapping the
|
|
8
|
+
* same words several times over, and only the last multiplication differs.
|
|
9
|
+
* Text is unhinted at these sizes, so the scaling is exact rather than close.
|
|
10
|
+
*
|
|
11
|
+
* The cache lives for as long as the measurer, which is one image. Titles
|
|
12
|
+
* repeat across the sizes of an image and rarely between images, so a longer
|
|
13
|
+
* life would hold a build's worth of strings to save very little.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createMeasurer(config: ResolvedConfig): Promise<MeasureText>;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/measure/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,aAAa,CAAC;AAO1E,YAAY,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AA8CvC;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,WAAW,CAAC,CAgBtB"}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/measure/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC;;;;;;;;GAQG;AACH,SAAS,OAAO,CACd,KAAsB,EACtB,KAAgB,EAChB,cAAuB;IAEvB,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,IAAI,GAAG,CAAC;IAEvC,OAAO,CACL,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC;QAC3C,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACxC,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,SAAS,SAAS,CAChB,IAAY,EACZ,KAAgB,EAChB,KAAsB,EACtB,cAAuB;IAEvB,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,IAAI,GAAG,CAAC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAEtD,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,KAAK,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QACrD,GAAG;YACD,GAAG,CAAC,IAAI,KAAK,SAAS;gBACpB,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC;gBACzD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAsB;IAEtB,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAExC,OAAO,CAAC,IAAY,EAAE,KAAgB,EAAU,EAAE;QAChD,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,UAAU,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAClH,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE7B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,CAAC;QAED,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC9D,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACpB,OAAO,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Face } from "./faces.js";
|
|
2
|
+
/**
|
|
3
|
+
* A stretch of text and the face that will draw it, or no face where nothing
|
|
4
|
+
* loaded covers it and the width has to be estimated.
|
|
5
|
+
*/
|
|
6
|
+
export interface TextRun {
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly face: Face | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** Advance width of `text` in `face`, as a multiple of the font size. */
|
|
11
|
+
export declare function emWidth(text: string, face: Face): number;
|
|
12
|
+
/**
|
|
13
|
+
* Split `text` into the longest runs that one face can draw. Text a build has
|
|
14
|
+
* supplied fonts for comes back as a single run, which is the common case.
|
|
15
|
+
*/
|
|
16
|
+
export declare function coverageRuns(text: string, primary: Face | undefined, faces: readonly Face[]): readonly TextRun[];
|
|
17
|
+
//# sourceMappingURL=runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/measure/runs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACjC;AAED,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAExD;AA0BD;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,GAAG,SAAS,EACzB,KAAK,EAAE,SAAS,IAAI,EAAE,GACrB,SAAS,OAAO,EAAE,CAepB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Advance width of `text` in `face`, as a multiple of the font size. */
|
|
2
|
+
export function emWidth(text, face) {
|
|
3
|
+
return face.font.layout(text).advanceWidth / face.font.unitsPerEm;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The face that will draw one character: the one the style resolved to, or the
|
|
7
|
+
* first other loaded face holding a glyph for it. This is what the rasteriser
|
|
8
|
+
* does with a missing glyph, and measuring a Japanese title against a Latin
|
|
9
|
+
* face that has none of it would be worse than not measuring at all.
|
|
10
|
+
*/
|
|
11
|
+
function coveringFace(character, primary, faces) {
|
|
12
|
+
const point = character.codePointAt(0);
|
|
13
|
+
if (point === undefined) {
|
|
14
|
+
return primary;
|
|
15
|
+
}
|
|
16
|
+
if (primary?.font.hasGlyphForCodePoint(point) === true) {
|
|
17
|
+
return primary;
|
|
18
|
+
}
|
|
19
|
+
return faces.find((face) => face.font.hasGlyphForCodePoint(point));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Split `text` into the longest runs that one face can draw. Text a build has
|
|
23
|
+
* supplied fonts for comes back as a single run, which is the common case.
|
|
24
|
+
*/
|
|
25
|
+
export function coverageRuns(text, primary, faces) {
|
|
26
|
+
const runs = [];
|
|
27
|
+
for (const character of text) {
|
|
28
|
+
const face = coveringFace(character, primary, faces);
|
|
29
|
+
const last = runs.at(-1);
|
|
30
|
+
if (last === undefined || last.face !== face) {
|
|
31
|
+
runs.push({ text: character, face });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
runs[runs.length - 1] = { text: last.text + character, face };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return runs;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/measure/runs.ts"],"names":[],"mappings":"AAWA,yEAAyE;AACzE,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,IAAU;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CACnB,SAAiB,EACjB,OAAyB,EACzB,KAAsB;IAEtB,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAEvC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACvD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,OAAyB,EACzB,KAAsB;IAEtB,MAAM,IAAI,GAAc,EAAE,CAAC;IAE3B,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC;QAChE,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Face } from "./faces.js";
|
|
2
|
+
/**
|
|
3
|
+
* The families named by a CSS-style stack, in order and unquoted, so that
|
|
4
|
+
* `'"JetBrains Mono", Menlo, monospace'` becomes three names to try.
|
|
5
|
+
*/
|
|
6
|
+
export declare function familyNames(stack: string): readonly string[];
|
|
7
|
+
/**
|
|
8
|
+
* The face a style resolves to, or `undefined` when the stack names nothing
|
|
9
|
+
* that was loaded. Families are tried in the order the stack lists them, which
|
|
10
|
+
* is what a stack means.
|
|
11
|
+
*/
|
|
12
|
+
export declare function selectFace(faces: readonly Face[], stack: string, weight: number): Face | undefined;
|
|
13
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/measure/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAU5D;AA4BD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,IAAI,GAAG,SAAS,CAUlB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The families named by a CSS-style stack, in order and unquoted, so that
|
|
3
|
+
* `'"JetBrains Mono", Menlo, monospace'` becomes three names to try.
|
|
4
|
+
*/
|
|
5
|
+
export function familyNames(stack) {
|
|
6
|
+
return stack
|
|
7
|
+
.split(",")
|
|
8
|
+
.map((name) => name
|
|
9
|
+
.trim()
|
|
10
|
+
.replaceAll(/^["']|["']$/g, "")
|
|
11
|
+
.trim())
|
|
12
|
+
.filter((name) => name !== "");
|
|
13
|
+
}
|
|
14
|
+
/** Faces belonging to one family, matched as the rasteriser matches them. */
|
|
15
|
+
function inFamily(faces, family) {
|
|
16
|
+
const wanted = family.toLowerCase();
|
|
17
|
+
return faces.filter((face) => face.family.toLowerCase() === wanted);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The face nearest the requested weight. A family supplying only a regular cut
|
|
21
|
+
* is drawn in that cut by the rasteriser rather than being emboldened, so
|
|
22
|
+
* measuring the nearest weight is measuring what will actually appear.
|
|
23
|
+
*/
|
|
24
|
+
function nearestWeight(faces, weight) {
|
|
25
|
+
let best = faces[0];
|
|
26
|
+
for (const face of faces) {
|
|
27
|
+
if (Math.abs(face.weight - weight) < Math.abs(best.weight - weight)) {
|
|
28
|
+
best = face;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return best;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The face a style resolves to, or `undefined` when the stack names nothing
|
|
35
|
+
* that was loaded. Families are tried in the order the stack lists them, which
|
|
36
|
+
* is what a stack means.
|
|
37
|
+
*/
|
|
38
|
+
export function selectFace(faces, stack, weight) {
|
|
39
|
+
for (const family of familyNames(stack)) {
|
|
40
|
+
const [first, ...rest] = inFamily(faces, family);
|
|
41
|
+
if (first !== undefined) {
|
|
42
|
+
return nearestWeight([first, ...rest], weight);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/measure/select.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,IAAI;SACD,IAAI,EAAE;SACN,UAAU,CAAC,cAAc,EAAE,EAAE,CAAC;SAC9B,IAAI,EAAE,CACV;SACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,6EAA6E;AAC7E,SAAS,QAAQ,CAAC,KAAsB,EAAE,MAAc;IACtD,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACpC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CACpB,KAAiC,EACjC,MAAc;IAEd,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;YACpE,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB,EACtB,KAAa,EACb,MAAc;IAEd,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAEjD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,aAAa,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/meta/tags.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { Manifest, MetaTag, MetaTagOptions } from "../types.js";
|
|
|
3
3
|
* The social meta tags for one page of a {@link Manifest}.
|
|
4
4
|
*
|
|
5
5
|
* Generating the image is half the job: a site still has to write the tags,
|
|
6
|
-
* and every site ends up with slightly different results
|
|
7
|
-
* relative URL a crawler cannot resolve, a large card promising an image
|
|
8
|
-
* is square.
|
|
6
|
+
* and every site ends up with slightly different results: a missing width, a
|
|
7
|
+
* relative URL a crawler cannot resolve, or a large card promising an image
|
|
8
|
+
* that is square.
|
|
9
9
|
*
|
|
10
10
|
* A page the manifest does not have gets no tags rather than an error. Not
|
|
11
|
-
* every page has a share image
|
|
12
|
-
* site says so
|
|
13
|
-
* advance.
|
|
11
|
+
* every page has a share image, and a props mapper returning `undefined` is
|
|
12
|
+
* how a site says so, so a template asking about one should not have to know
|
|
13
|
+
* in advance.
|
|
14
14
|
*
|
|
15
15
|
* Alt text is emitted for both platforms when the page has any. Twitter reads
|
|
16
16
|
* its own `twitter:image:alt` rather than falling back to the Open Graph one,
|
package/dist/meta/tags.js
CHANGED
|
@@ -30,14 +30,14 @@ function imageUrl(slug, image, options) {
|
|
|
30
30
|
* The social meta tags for one page of a {@link Manifest}.
|
|
31
31
|
*
|
|
32
32
|
* Generating the image is half the job: a site still has to write the tags,
|
|
33
|
-
* and every site ends up with slightly different results
|
|
34
|
-
* relative URL a crawler cannot resolve, a large card promising an image
|
|
35
|
-
* is square.
|
|
33
|
+
* and every site ends up with slightly different results: a missing width, a
|
|
34
|
+
* relative URL a crawler cannot resolve, or a large card promising an image
|
|
35
|
+
* that is square.
|
|
36
36
|
*
|
|
37
37
|
* A page the manifest does not have gets no tags rather than an error. Not
|
|
38
|
-
* every page has a share image
|
|
39
|
-
* site says so
|
|
40
|
-
* advance.
|
|
38
|
+
* every page has a share image, and a props mapper returning `undefined` is
|
|
39
|
+
* how a site says so, so a template asking about one should not have to know
|
|
40
|
+
* in advance.
|
|
41
41
|
*
|
|
42
42
|
* Alt text is emitted for both platforms when the page has any. Twitter reads
|
|
43
43
|
* its own `twitter:image:alt` rather than falling back to the Open Graph one,
|
package/dist/meta/url.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* the placement's `urlBase` said, which is usually site-relative, so this is
|
|
7
7
|
* where the two halves meet.
|
|
8
8
|
*
|
|
9
|
-
* A URL that names its own scheme is returned untouched
|
|
10
|
-
* at a CDN has said everything there is to say. A scheme-relative one
|
|
11
|
-
* has not: it is relative to the page's scheme, which is exactly what
|
|
12
|
-
* reading the tag elsewhere does not have, so it borrows the base's.
|
|
9
|
+
* A URL that names its own scheme is returned untouched, since a placement
|
|
10
|
+
* pointing at a CDN has said everything there is to say. A scheme-relative one
|
|
11
|
+
* (`//cdn`) has not: it is relative to the page's scheme, which is exactly what
|
|
12
|
+
* a crawler reading the tag elsewhere does not have, so it borrows the base's.
|
|
13
13
|
*/
|
|
14
14
|
export declare function absoluteUrl(url: string, baseUrl: string | undefined): string;
|
|
15
15
|
//# sourceMappingURL=url.d.ts.map
|
package/dist/meta/url.js
CHANGED
|
@@ -15,10 +15,10 @@ function schemeOf(url) {
|
|
|
15
15
|
* the placement's `urlBase` said, which is usually site-relative, so this is
|
|
16
16
|
* where the two halves meet.
|
|
17
17
|
*
|
|
18
|
-
* A URL that names its own scheme is returned untouched
|
|
19
|
-
* at a CDN has said everything there is to say. A scheme-relative one
|
|
20
|
-
* has not: it is relative to the page's scheme, which is exactly what
|
|
21
|
-
* reading the tag elsewhere does not have, so it borrows the base's.
|
|
18
|
+
* A URL that names its own scheme is returned untouched, since a placement
|
|
19
|
+
* pointing at a CDN has said everything there is to say. A scheme-relative one
|
|
20
|
+
* (`//cdn`) has not: it is relative to the page's scheme, which is exactly what
|
|
21
|
+
* a crawler reading the tag elsewhere does not have, so it borrows the base's.
|
|
22
22
|
*/
|
|
23
23
|
export function absoluteUrl(url, baseUrl) {
|
|
24
24
|
if (baseUrl === undefined || schemed.test(url)) {
|
|
@@ -6,7 +6,7 @@ import type { Placement } from "../types.js";
|
|
|
6
6
|
* JavaScript with nothing checking it, and none of these omissions fails
|
|
7
7
|
* anywhere near the config: a missing `dir` surfaces as a complaint about an
|
|
8
8
|
* argument to `path`, and the rest as something not being a function. Key
|
|
9
|
-
* validation is no help either
|
|
9
|
+
* validation is no help either, since it is the option that is not there.
|
|
10
10
|
*
|
|
11
11
|
* This sits here rather than in `validate/`, which checks keys and the names
|
|
12
12
|
* of closed sets, for the reason `fonts/resolve.ts` does: what a value has to
|
package/dist/placement/check.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* JavaScript with nothing checking it, and none of these omissions fails
|
|
6
6
|
* anywhere near the config: a missing `dir` surfaces as a complaint about an
|
|
7
7
|
* argument to `path`, and the rest as something not being a function. Key
|
|
8
|
-
* validation is no help either
|
|
8
|
+
* validation is no help either, since it is the option that is not there.
|
|
9
9
|
*
|
|
10
10
|
* This sits here rather than in `validate/`, which checks keys and the names
|
|
11
11
|
* of closed sets, for the reason `fonts/resolve.ts` does: what a value has to
|
package/dist/placement/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { besideContent, imageName } from "./relative.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Prefix a `urlBase` onto an image's path under the root that placed it.
|
|
7
7
|
*
|
|
8
|
-
* No base, no URL: a directory on disk does not say how
|
|
8
|
+
* No base, no URL: a directory on disk does not say how, or whether, it is
|
|
9
9
|
* served, and a URL Colophon invented would be worse than the gap it fills,
|
|
10
10
|
* since the whole point of writing one down is that a site can trust it.
|
|
11
11
|
*/
|
|
@@ -5,9 +5,9 @@ import type { ContentFile, OutputSize } from "../types.js";
|
|
|
5
5
|
* carries the post's keywords, and the size name keeps every image of a post
|
|
6
6
|
* distinct (`my-post-og.png`, `my-post-square.png`).
|
|
7
7
|
*
|
|
8
|
-
* A slug carrying directories of its own
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* A slug carrying directories of its own puts them in the name, so the image's
|
|
9
|
+
* path mirrors the route wherever it is placed. That is what the `route`
|
|
10
|
+
* strategy produces, and what a frontmatter `slug` of `docs/intro` means.
|
|
11
11
|
*
|
|
12
12
|
* The digest is the image's rebuild stamp: the props, the config and the size
|
|
13
13
|
* it is drawn from. Hashing the rendered bytes would be a truer name, but they
|
|
@@ -13,9 +13,9 @@ const hashLength = 8;
|
|
|
13
13
|
* carries the post's keywords, and the size name keeps every image of a post
|
|
14
14
|
* distinct (`my-post-og.png`, `my-post-square.png`).
|
|
15
15
|
*
|
|
16
|
-
* A slug carrying directories of its own
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* A slug carrying directories of its own puts them in the name, so the image's
|
|
17
|
+
* path mirrors the route wherever it is placed. That is what the `route`
|
|
18
|
+
* strategy produces, and what a frontmatter `slug` of `docs/intro` means.
|
|
19
19
|
*
|
|
20
20
|
* The digest is the image's rebuild stamp: the props, the config and the size
|
|
21
21
|
* it is drawn from. Hashing the rendered bytes would be a truer name, but they
|
package/dist/pool.d.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* flight stays bounded however large the input is.
|
|
10
10
|
*
|
|
11
11
|
* The first rejection propagates, as it would from `Promise.all`. Items
|
|
12
|
-
* already in flight run to completion
|
|
13
|
-
* no further ones are started.
|
|
12
|
+
* already in flight run to completion, since there is no cancelling a render,
|
|
13
|
+
* but no further ones are started.
|
|
14
14
|
*
|
|
15
15
|
* Throws if `limit` is not a positive integer.
|
|
16
16
|
*/
|
package/dist/pool.js
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
* flight stays bounded however large the input is.
|
|
10
10
|
*
|
|
11
11
|
* The first rejection propagates, as it would from `Promise.all`. Items
|
|
12
|
-
* already in flight run to completion
|
|
13
|
-
* no further ones are started.
|
|
12
|
+
* already in flight run to completion, since there is no cancelling a render,
|
|
13
|
+
* but no further ones are started.
|
|
14
14
|
*
|
|
15
15
|
* Throws if `limit` is not a positive integer.
|
|
16
16
|
*/
|
|
17
17
|
export async function mapConcurrent(items, limit, worker) {
|
|
18
18
|
// A limit below one starts no workers at all, and an empty `Promise.all`
|
|
19
|
-
// resolves happily
|
|
19
|
+
// resolves happily, so the caller would get an empty result back as though
|
|
20
20
|
// there had been nothing to do. A build reporting success having rendered
|
|
21
21
|
// nothing is the failure worth being loud about.
|
|
22
22
|
if (!Number.isSafeInteger(limit) || limit < 1) {
|
package/dist/pool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAsB,EACtB,KAAa,EACb,MAAsD;IAEtD,yEAAyE;IACzE,
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAsB,EACtB,KAAa,EACb,MAAsD;IAEtD,yEAAyE;IACzE,2EAA2E;IAC3E,0EAA0E;IAC1E,iDAAiD;IACjD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,6BAA6B,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAC3E,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,kCAAkC;IAClC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,6EAA6E;IAC7E,4EAA4E;IAC5E,YAAY;IACZ,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,KAAK,UAAU,GAAG;QAChB,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;YAClC,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,wEAAwE;YACxE,oEAAoE;YACpE,4CAA4C;YAC5C,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CACzE,GAAG,EAAE,CACN,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,yEAAyE;QACzE,qEAAqE;QACrE,SAAS,GAAG,IAAI,CAAC;QACjB,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/props.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a prop as a string, coercing the scalar types YAML frontmatter yields
|
|
3
|
+
* (numbers, booleans) and returning `undefined` for anything else, since
|
|
4
|
+
* templates treat "not a usable string" and "absent" the same way.
|
|
5
|
+
*/
|
|
6
|
+
export declare function optionalString(value: unknown): string | undefined;
|
|
7
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAcjE"}
|
package/dist/props.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a prop as a string, coercing the scalar types YAML frontmatter yields
|
|
3
|
+
* (numbers, booleans) and returning `undefined` for anything else, since
|
|
4
|
+
* templates treat "not a usable string" and "absent" the same way.
|
|
5
|
+
*/
|
|
6
|
+
export function optionalString(value) {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === "number" ||
|
|
11
|
+
typeof value === "boolean" ||
|
|
12
|
+
typeof value === "bigint") {
|
|
13
|
+
return String(value);
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/render/svg.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import type { Dimensions, MetaImageProps, ResolvedConfig } from "../types.js";
|
|
|
3
3
|
* Build the complete SVG document for one image: the enclosing `<svg>` root,
|
|
4
4
|
* the config-driven background, and the template's foreground content.
|
|
5
5
|
*
|
|
6
|
-
* Asynchronous because a template may need to load resources
|
|
7
|
-
* template fetches syntax grammars and themes on demand
|
|
6
|
+
* Asynchronous because a template may need to load resources. The `code`
|
|
7
|
+
* template fetches syntax grammars and themes on demand, the fonts the text is
|
|
8
|
+
* measured against have to be read before a template can lay it out, and so do
|
|
9
|
+
* the logo, the avatar and any background photo.
|
|
8
10
|
*/
|
|
9
11
|
export declare function buildSvg(props: MetaImageProps, config: ResolvedConfig, dimensions: Dimensions): Promise<string>;
|
|
10
12
|
//# sourceMappingURL=svg.d.ts.map
|
package/dist/render/svg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAK9E;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,MAAM,CAAC,CA4BjB"}
|
package/dist/render/svg.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { backgroundSvg } from "../background.js";
|
|
2
|
+
import { loadImages } from "../image/index.js";
|
|
3
|
+
import { createMeasurer } from "../measure/index.js";
|
|
2
4
|
import { selectTemplate } from "./template.js";
|
|
3
5
|
const backgroundId = "colophon-bg";
|
|
4
6
|
/**
|
|
5
7
|
* Build the complete SVG document for one image: the enclosing `<svg>` root,
|
|
6
8
|
* the config-driven background, and the template's foreground content.
|
|
7
9
|
*
|
|
8
|
-
* Asynchronous because a template may need to load resources
|
|
9
|
-
* template fetches syntax grammars and themes on demand
|
|
10
|
+
* Asynchronous because a template may need to load resources. The `code`
|
|
11
|
+
* template fetches syntax grammars and themes on demand, the fonts the text is
|
|
12
|
+
* measured against have to be read before a template can lay it out, and so do
|
|
13
|
+
* the logo, the avatar and any background photo.
|
|
10
14
|
*/
|
|
11
15
|
export async function buildSvg(props, config, dimensions) {
|
|
12
16
|
const template = selectTemplate(config, props.template);
|
|
13
|
-
const
|
|
14
|
-
|
|
17
|
+
const [measure, images] = await Promise.all([
|
|
18
|
+
createMeasurer(config),
|
|
19
|
+
loadImages(config, props),
|
|
20
|
+
]);
|
|
21
|
+
const background = backgroundSvg(config.background, dimensions, backgroundId, images.background);
|
|
22
|
+
const body = await template.render({
|
|
23
|
+
props,
|
|
24
|
+
config,
|
|
25
|
+
dimensions,
|
|
26
|
+
measure,
|
|
27
|
+
logo: images.logo,
|
|
28
|
+
avatar: images.avatar,
|
|
29
|
+
});
|
|
15
30
|
const { width, height } = dimensions;
|
|
16
31
|
return (`<svg width="${String(width)}" height="${String(height)}"` +
|
|
17
32
|
` viewBox="0 0 ${String(width)} ${String(height)}"` +
|
package/dist/render/svg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAqB,EACrB,MAAsB,EACtB,UAAsB;IAEtB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,cAAc,CAAC,MAAM,CAAC;QACtB,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC;KAC1B,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,aAAa,CAC9B,MAAM,CAAC,UAAU,EACjB,UAAU,EACV,YAAY,EACZ,MAAM,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACjC,KAAK;QACL,MAAM;QACN,UAAU;QACV,OAAO;QACP,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAErC,OAAO,CACL,eAAe,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,GAAG;QAC1D,iBAAiB,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG;QACnD,uCAAuC,UAAU,GAAG,IAAI,QAAQ,CACjE,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-digest.d.ts","sourceRoot":"","sources":["../../src/stamp/config-digest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"config-digest.d.ts","sourceRoot":"","sources":["../../src/stamp/config-digest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,aAAa,CAAC;AA6CrB;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAqB1E"}
|
|
@@ -18,6 +18,23 @@ async function fontDigest(font) {
|
|
|
18
18
|
const bytes = "data" in font ? font.data : await readFile(font.path);
|
|
19
19
|
return sha256(stableStringify({ family: font.family, bytes: sha256(bytes) }));
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Digest an image by its contents, for the reason a font is digested that way:
|
|
23
|
+
* a logo replaced at the same path is a different logo, and every image drawn
|
|
24
|
+
* with it wants rendering again.
|
|
25
|
+
*/
|
|
26
|
+
async function imageDigest(source) {
|
|
27
|
+
return sha256("data" in source ? source.data : await readFile(source.path));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A background, with any image it draws replaced by a digest of that image's
|
|
31
|
+
* bytes. Everything else about a background is already a value.
|
|
32
|
+
*/
|
|
33
|
+
async function backgroundDigest(background) {
|
|
34
|
+
return background.type === "image"
|
|
35
|
+
? { ...background, source: await imageDigest(background.source) }
|
|
36
|
+
: background;
|
|
37
|
+
}
|
|
21
38
|
/**
|
|
22
39
|
* Digest the config fields that affect what an image looks like.
|
|
23
40
|
*
|
|
@@ -28,11 +45,13 @@ async function fontDigest(font) {
|
|
|
28
45
|
*/
|
|
29
46
|
export async function configDigest(config) {
|
|
30
47
|
const fonts = await Promise.all(config.fonts.map(async (font) => fontDigest(font)));
|
|
48
|
+
const logo = config.logo === undefined ? undefined : await imageDigest(config.logo);
|
|
31
49
|
return sha256(stableStringify({
|
|
32
50
|
version: await packageVersion(),
|
|
33
51
|
colors: config.colors,
|
|
34
|
-
background: config.background,
|
|
52
|
+
background: await backgroundDigest(config.background),
|
|
35
53
|
fonts,
|
|
54
|
+
logo,
|
|
36
55
|
systemFonts: config.systemFonts,
|
|
37
56
|
fontFamily: config.fontFamily,
|
|
38
57
|
footer: config.footer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-digest.js","sourceRoot":"","sources":["../../src/stamp/config-digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"config-digest.js","sourceRoot":"","sources":["../../src/stamp/config-digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQ5C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;GAKG;AACH,KAAK,UAAU,cAAc;IAC3B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAC7B,IAAI,GAAG,CAAC,oBAAoB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAC9C,MAAM,CACP,CAAC;IACF,OAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAyB,CAAC,OAAO,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,UAAU,CAAC,IAAgB;IACxC,MAAM,KAAK,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrE,OAAO,MAAM,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,WAAW,CAAC,MAAmB;IAC5C,OAAO,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,gBAAgB,CAAC,UAAsB;IACpD,OAAO,UAAU,CAAC,IAAI,KAAK,OAAO;QAChC,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QACjE,CAAC,CAAC,UAAU,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAsB;IACvD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CACnD,CAAC;IACF,MAAM,IAAI,GACR,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzE,OAAO,MAAM,CACX,eAAe,CAAC;QACd,OAAO,EAAE,MAAM,cAAc,EAAE;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,MAAM,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC;QACrD,KAAK;QACL,IAAI;QACJ,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/stamp/index.js
CHANGED
|
@@ -12,8 +12,8 @@ export async function createStamper(config) {
|
|
|
12
12
|
// A custom template is config the project controls, so its source counts as
|
|
13
13
|
// part of the input. Built-in templates are covered by the package version.
|
|
14
14
|
// Source text is all there is to go on: a template that reads something its
|
|
15
|
-
// own code does not name
|
|
16
|
-
// the stamp noticing, and needs `overwrite` to pick it up.
|
|
15
|
+
// own code does not name, such as a closed-over value or a file it loads,
|
|
16
|
+
// can change without the stamp noticing, and needs `overwrite` to pick it up.
|
|
17
17
|
const templateDigest = (name) => {
|
|
18
18
|
const cached = templateDigests.get(name);
|
|
19
19
|
if (cached !== undefined) {
|
package/dist/stamp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stamp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAczC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAsB;IACxD,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAElD,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAC5E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stamp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAczC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAsB;IACxD,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAElD,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE;QAC9C,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,MAAM,GACV,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnE,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,CAAC,KAAK,EAAE,IAAI;YACf,OAAO,MAAM,CACX,eAAe,CAAC;gBACd,IAAI;gBACJ,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAC9B,kEAAkE;gBAClE,kEAAkE;gBAClE,IAAI;gBACJ,KAAK;aACN,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/stamp/read.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Read the stamp out of a PNG file. Returns `undefined` when the file is
|
|
3
|
-
* missing, unreadable, not a PNG, or carries no stamp
|
|
3
|
+
* missing, unreadable, not a PNG, or carries no stamp, all of which mean the
|
|
4
4
|
* image cannot be shown to be up to date, so it should be rendered again.
|
|
5
5
|
*/
|
|
6
6
|
export declare function readPngStamp(file: string): Promise<string | undefined>;
|