@servrox/console-fx 0.1.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/browser/compiler.d.ts +14 -0
- package/dist/browser/compiler.d.ts.map +1 -0
- package/dist/browser/compiler.js +218 -0
- package/dist/browser/compiler.js.map +1 -0
- package/dist/browser/index.d.ts +16 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +55 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/measure.d.ts +5 -0
- package/dist/browser/measure.d.ts.map +1 -0
- package/dist/browser/measure.js +79 -0
- package/dist/browser/measure.js.map +1 -0
- package/dist/browser/preflight.d.ts +5 -0
- package/dist/browser/preflight.d.ts.map +1 -0
- package/dist/browser/preflight.js +70 -0
- package/dist/browser/preflight.js.map +1 -0
- package/dist/codegen/index.d.ts +5 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/index.js +56 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/effects/catalog.d.ts +5 -0
- package/dist/effects/catalog.d.ts.map +1 -0
- package/dist/effects/catalog.js +121 -0
- package/dist/effects/catalog.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/bounds.d.ts +16 -0
- package/dist/layout/bounds.d.ts.map +1 -0
- package/dist/layout/bounds.js +84 -0
- package/dist/layout/bounds.js.map +1 -0
- package/dist/layout/metrics.d.ts +20 -0
- package/dist/layout/metrics.d.ts.map +1 -0
- package/dist/layout/metrics.js +92 -0
- package/dist/layout/metrics.js.map +1 -0
- package/dist/layout/planner.d.ts +32 -0
- package/dist/layout/planner.d.ts.map +1 -0
- package/dist/layout/planner.js +439 -0
- package/dist/layout/planner.js.map +1 -0
- package/dist/layout/render.d.ts +4 -0
- package/dist/layout/render.d.ts.map +1 -0
- package/dist/layout/render.js +98 -0
- package/dist/layout/render.js.map +1 -0
- package/dist/layout/wrap.d.ts +16 -0
- package/dist/layout/wrap.d.ts.map +1 -0
- package/dist/layout/wrap.js +67 -0
- package/dist/layout/wrap.js.map +1 -0
- package/dist/model/layout.d.ts +112 -0
- package/dist/model/layout.d.ts.map +1 -0
- package/dist/model/layout.js +2 -0
- package/dist/model/layout.js.map +1 -0
- package/dist/model/limits.d.ts +19 -0
- package/dist/model/limits.d.ts.map +1 -0
- package/dist/model/limits.js +28 -0
- package/dist/model/limits.js.map +1 -0
- package/dist/model/types.d.ts +267 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +2 -0
- package/dist/model/types.js.map +1 -0
- package/dist/presentations/catalog.d.ts +5 -0
- package/dist/presentations/catalog.d.ts.map +1 -0
- package/dist/presentations/catalog.js +1522 -0
- package/dist/presentations/catalog.js.map +1 -0
- package/dist/presentations/compact.d.ts +16 -0
- package/dist/presentations/compact.d.ts.map +1 -0
- package/dist/presentations/compact.js +178 -0
- package/dist/presentations/compact.js.map +1 -0
- package/dist/presentations/fonts.d.ts +7 -0
- package/dist/presentations/fonts.d.ts.map +1 -0
- package/dist/presentations/fonts.js +7 -0
- package/dist/presentations/fonts.js.map +1 -0
- package/dist/presets/cards.d.ts +67 -0
- package/dist/presets/cards.d.ts.map +1 -0
- package/dist/presets/cards.js +305 -0
- package/dist/presets/cards.js.map +1 -0
- package/dist/presets/index.d.ts +125 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +270 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/renderers/cinematic/glyphs.d.ts +2 -0
- package/dist/renderers/cinematic/glyphs.d.ts.map +1 -0
- package/dist/renderers/cinematic/glyphs.js +86 -0
- package/dist/renderers/cinematic/glyphs.js.map +1 -0
- package/dist/renderers/cinematic/layout.d.ts +23 -0
- package/dist/renderers/cinematic/layout.d.ts.map +1 -0
- package/dist/renderers/cinematic/layout.js +86 -0
- package/dist/renderers/cinematic/layout.js.map +1 -0
- package/dist/renderers/cinematic/profiles.d.ts +51 -0
- package/dist/renderers/cinematic/profiles.d.ts.map +1 -0
- package/dist/renderers/cinematic/profiles.js +78 -0
- package/dist/renderers/cinematic/profiles.js.map +1 -0
- package/dist/renderers/cinematic/render.d.ts +8 -0
- package/dist/renderers/cinematic/render.d.ts.map +1 -0
- package/dist/renderers/cinematic/render.js +51 -0
- package/dist/renderers/cinematic/render.js.map +1 -0
- package/dist/renderers/css.d.ts +12 -0
- package/dist/renderers/css.d.ts.map +1 -0
- package/dist/renderers/css.js +72 -0
- package/dist/renderers/css.js.map +1 -0
- package/dist/renderers/presentations/compact-art.d.ts +3 -0
- package/dist/renderers/presentations/compact-art.d.ts.map +1 -0
- package/dist/renderers/presentations/compact-art.js +80 -0
- package/dist/renderers/presentations/compact-art.js.map +1 -0
- package/dist/renderers/presentations/layout.d.ts +5 -0
- package/dist/renderers/presentations/layout.d.ts.map +1 -0
- package/dist/renderers/presentations/layout.js +88 -0
- package/dist/renderers/presentations/layout.js.map +1 -0
- package/dist/renderers/presentations/render.d.ts +4 -0
- package/dist/renderers/presentations/render.d.ts.map +1 -0
- package/dist/renderers/presentations/render.js +199 -0
- package/dist/renderers/presentations/render.js.map +1 -0
- package/dist/renderers/presentations/shapes.d.ts +5 -0
- package/dist/renderers/presentations/shapes.d.ts.map +1 -0
- package/dist/renderers/presentations/shapes.js +6 -0
- package/dist/renderers/presentations/shapes.js.map +1 -0
- package/dist/renderers/svg-values.d.ts +3 -0
- package/dist/renderers/svg-values.d.ts.map +1 -0
- package/dist/renderers/svg-values.js +13 -0
- package/dist/renderers/svg-values.js.map +1 -0
- package/dist/renderers/svg.d.ts +16 -0
- package/dist/renderers/svg.d.ts.map +1 -0
- package/dist/renderers/svg.js +260 -0
- package/dist/renderers/svg.js.map +1 -0
- package/dist/validation/index.d.ts +14 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +291 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/layout.d.ts +10 -0
- package/dist/validation/layout.d.ts.map +1 -0
- package/dist/validation/layout.js +183 -0
- package/dist/validation/layout.js.map +1 -0
- package/dist/validation/options.d.ts +6 -0
- package/dist/validation/options.d.ts.map +1 -0
- package/dist/validation/options.js +29 -0
- package/dist/validation/options.js.map +1 -0
- package/dist/validation/recipe.d.ts +5 -0
- package/dist/validation/recipe.d.ts.map +1 -0
- package/dist/validation/recipe.js +30 -0
- package/dist/validation/recipe.js.map +1 -0
- package/dist/validation/render-options.d.ts +21 -0
- package/dist/validation/render-options.d.ts.map +1 -0
- package/dist/validation/render-options.js +36 -0
- package/dist/validation/render-options.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { LIMITS } from "../model/limits.js";
|
|
2
|
+
import { fail } from "../validation/index.js";
|
|
3
|
+
import { renderSvg } from "../renderers/svg.js";
|
|
4
|
+
import { planSvgLayout } from "./planner.js";
|
|
5
|
+
import { svgNumber } from "../renderers/svg-values.js";
|
|
6
|
+
import { presentationDescriptor } from "../presentations/catalog.js";
|
|
7
|
+
export function renderWithLayout(scene, motion, options) {
|
|
8
|
+
if (!options.layout && !options.sizing)
|
|
9
|
+
return renderSvg(scene, motion);
|
|
10
|
+
const plan = options.layout
|
|
11
|
+
? planSvgLayout(scene, options.layout, options)
|
|
12
|
+
: undefined;
|
|
13
|
+
const output = renderSvg(scene, motion, plan);
|
|
14
|
+
const width = plan?.report.artboard.width ?? scene.surface.width;
|
|
15
|
+
const height = plan?.report.artboard.height ?? scene.surface.height;
|
|
16
|
+
const sizing = options.sizing;
|
|
17
|
+
const diagnostics = [
|
|
18
|
+
...output.diagnostics,
|
|
19
|
+
...(plan?.report.diagnostics ?? []),
|
|
20
|
+
];
|
|
21
|
+
if (sizing?.mode === "container-experimental") {
|
|
22
|
+
if (sizing.maxWidth > width)
|
|
23
|
+
fail("unsupported-layout", "Container maximum width cannot exceed the image artboard.", ["sizing"]);
|
|
24
|
+
const ratio = height / width, fraction = sizing.fillFraction ?? 0.96;
|
|
25
|
+
if (sizing.maxWidth * ratio > LIMITS.svgHeight)
|
|
26
|
+
fail("invalid-options", "Proportional display height exceeds 400 pixels.", ["sizing"]);
|
|
27
|
+
diagnostics.push({
|
|
28
|
+
code: "experimental-container-sizing",
|
|
29
|
+
severity: "warning",
|
|
30
|
+
path: ["sizing"],
|
|
31
|
+
message: "Container sizing is experimental and requires qualification in the receiving DevTools.",
|
|
32
|
+
}, {
|
|
33
|
+
code: "display-readability-unknown",
|
|
34
|
+
severity: "warning",
|
|
35
|
+
path: ["sizing"],
|
|
36
|
+
message: "Actual display width and image-text readability are unknown. The complete native caption remains available.",
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
...output,
|
|
40
|
+
diagnostics,
|
|
41
|
+
width: sizing.maxWidth,
|
|
42
|
+
height: sizing.maxWidth * ratio,
|
|
43
|
+
carrierPadding: `min(${svgNumber((sizing.maxWidth * ratio) / 2)}px, ${svgNumber(50 * fraction * ratio)}%) min(${svgNumber(sizing.maxWidth / 2)}px, ${svgNumber(50 * fraction)}%)`,
|
|
44
|
+
sizing: {
|
|
45
|
+
mode: sizing.mode,
|
|
46
|
+
artboard: { width, height },
|
|
47
|
+
resolvedDisplayWidth: null,
|
|
48
|
+
resolvedDisplayHeight: null,
|
|
49
|
+
displayScale: null,
|
|
50
|
+
displayReadability: "unknown",
|
|
51
|
+
},
|
|
52
|
+
...(plan ? { layout: plan.report } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const displayWidth = sizing?.width ?? width, displayHeight = (displayWidth * height) / width;
|
|
56
|
+
if (sizing && !plan) {
|
|
57
|
+
const descriptor = scene.presentation
|
|
58
|
+
? presentationDescriptor(scene.presentation.profile)
|
|
59
|
+
: undefined;
|
|
60
|
+
const scale = (displayWidth / width) *
|
|
61
|
+
(descriptor
|
|
62
|
+
? Math.min((width - 2 * scene.surface.padding) / 720, (height - 2 * scene.surface.padding) / 240)
|
|
63
|
+
: 1);
|
|
64
|
+
const runs = descriptor
|
|
65
|
+
? descriptor.slots.map((s) => scene.lines[s.line].runs[s.run])
|
|
66
|
+
: scene.lines.flatMap((l) => l.runs);
|
|
67
|
+
if (runs.some((r) => r.text &&
|
|
68
|
+
r.style.fontSize * scale <
|
|
69
|
+
(descriptor?.group === "Useful" && r.style.fontSize >= 14 ? 12 : 8)))
|
|
70
|
+
fail("below-readable-size", "Fixed display sizing would violate the default readable font floor. Choose a larger width, explicit fitting or plain text.", ["sizing"]);
|
|
71
|
+
}
|
|
72
|
+
if (displayHeight > LIMITS.svgHeight)
|
|
73
|
+
fail("invalid-options", "Proportional display height exceeds 400 pixels.", [
|
|
74
|
+
"sizing",
|
|
75
|
+
]);
|
|
76
|
+
return {
|
|
77
|
+
...output,
|
|
78
|
+
width: displayWidth,
|
|
79
|
+
height: displayHeight,
|
|
80
|
+
diagnostics,
|
|
81
|
+
...(plan ? { layout: plan.report } : {}),
|
|
82
|
+
...(sizing || plan
|
|
83
|
+
? {
|
|
84
|
+
sizing: {
|
|
85
|
+
mode: "fixed",
|
|
86
|
+
artboard: { width, height },
|
|
87
|
+
resolvedDisplayWidth: displayWidth,
|
|
88
|
+
resolvedDisplayHeight: displayHeight,
|
|
89
|
+
displayScale: displayWidth / width,
|
|
90
|
+
displayReadability: plan
|
|
91
|
+
? "meets-requested-floor"
|
|
92
|
+
: "meets-default-floor",
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
: {}),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/layout/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAA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EACrB,4HAA4H,EAC5H,CAAC,QAAQ,CAAC,CACX,CAAC;IACN,CAAC;IACD,IAAI,aAAa,GAAG,MAAM,CAAC,SAAS;QAClC,IAAI,CAAC,iBAAiB,EAAE,iDAAiD,EAAE;YACzE,QAAQ;SACT,CAAC,CAAC;IACL,OAAO;QACL,GAAG,MAAM;QACT,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,aAAa;QACrB,WAAW;QACX,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxC,GAAG,CAAC,MAAM,IAAI,IAAI;YAChB,CAAC,CAAC;gBACE,MAAM,EAAE;oBACN,IAAI,EAAE,OAAgB;oBACtB,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;oBAC3B,oBAAoB,EAAE,YAAY;oBAClC,qBAAqB,EAAE,aAAa;oBACpC,YAAY,EAAE,YAAY,GAAG,KAAK;oBAClC,kBAAkB,EAAE,IAAI;wBACtB,CAAC,CAAE,uBAAiC;wBACpC,CAAC,CAAE,qBAA+B;iBACrC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TextRun } from "../model/types.js";
|
|
2
|
+
export type FlowRun = TextRun & {
|
|
3
|
+
readonly sourceRun: number;
|
|
4
|
+
};
|
|
5
|
+
type Token = readonly FlowRun[];
|
|
6
|
+
/** fit/v1 breaks only at complete graphemes, ASCII spaces and CJK letter boundaries.
|
|
7
|
+
* Tokens may cross style/run boundaries: styling cannot make an ID breakable.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wrapTokens(runs: readonly FlowRun[]): readonly Token[];
|
|
10
|
+
export declare function wrapTokensToRows(tokens: readonly Token[], width: number, occupiedWidth: (runs: readonly FlowRun[]) => number): FlowRun[][];
|
|
11
|
+
/** Optional preflight lookahead. The caller stops this iterator at its byte/work budget.
|
|
12
|
+
* Actual line fragments are shaped whole, never inferred from summed glyph advances.
|
|
13
|
+
*/
|
|
14
|
+
export declare function wrappingAlternatives(tokens: readonly Token[]): Generator<FlowRun, void, unknown>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=wrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/layout/wrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,KAAK,KAAK,GAAG,SAAS,OAAO,EAAE,CAAC;AAkBhC;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,KAAK,EAAE,CAyBrE;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,MAAM,GAClD,OAAO,EAAE,EAAE,CAYb;AAED;;GAEG;AACH,wBAAiB,oBAAoB,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,qCAQ7D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { cinematicEffect } from "../renderers/cinematic/layout.js";
|
|
2
|
+
const cjk = (text) => /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]+$/u.test(text);
|
|
3
|
+
function append(left, right) {
|
|
4
|
+
const result = [...left];
|
|
5
|
+
for (const run of right) {
|
|
6
|
+
const last = result.at(-1);
|
|
7
|
+
if (last?.sourceRun === run.sourceRun)
|
|
8
|
+
result[result.length - 1] = { ...last, text: last.text + run.text };
|
|
9
|
+
else
|
|
10
|
+
result.push(run);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
/** fit/v1 breaks only at complete graphemes, ASCII spaces and CJK letter boundaries.
|
|
15
|
+
* Tokens may cross style/run boundaries: styling cannot make an ID breakable.
|
|
16
|
+
*/
|
|
17
|
+
export function wrapTokens(runs) {
|
|
18
|
+
// Without grapheme boundaries, retain the complete styled paragraph.
|
|
19
|
+
if (typeof Intl.Segmenter !== "function")
|
|
20
|
+
return [runs];
|
|
21
|
+
const segmenter = new Intl.Segmenter("und", { granularity: "grapheme" });
|
|
22
|
+
const pieces = runs.flatMap((run) => (cinematicEffect(run)
|
|
23
|
+
? [run.text]
|
|
24
|
+
: [...segmenter.segment(run.text)].map((part) => part.segment)).map((text) => ({ ...run, text })));
|
|
25
|
+
const tokens = [];
|
|
26
|
+
let token = [];
|
|
27
|
+
for (const [i, piece] of pieces.entries()) {
|
|
28
|
+
token = append(token, [piece]);
|
|
29
|
+
const next = pieces[i + 1]?.text ?? "";
|
|
30
|
+
if (!/^[\u2060\ufeff]/u.test(next) &&
|
|
31
|
+
(piece.text.endsWith(" ") || (cjk(piece.text) && cjk(next)))) {
|
|
32
|
+
tokens.push(token);
|
|
33
|
+
token = [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (token.length || !tokens.length)
|
|
37
|
+
tokens.push(token);
|
|
38
|
+
return tokens;
|
|
39
|
+
}
|
|
40
|
+
export function wrapTokensToRows(tokens, width, occupiedWidth) {
|
|
41
|
+
const rows = [];
|
|
42
|
+
let row = [];
|
|
43
|
+
for (const token of tokens) {
|
|
44
|
+
const candidate = append(row, token);
|
|
45
|
+
if (occupiedWidth(candidate) > width && row.length) {
|
|
46
|
+
rows.push(row);
|
|
47
|
+
row = [...token];
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
row = candidate;
|
|
51
|
+
}
|
|
52
|
+
rows.push(row);
|
|
53
|
+
return rows;
|
|
54
|
+
}
|
|
55
|
+
/** Optional preflight lookahead. The caller stops this iterator at its byte/work budget.
|
|
56
|
+
* Actual line fragments are shaped whole, never inferred from summed glyph advances.
|
|
57
|
+
*/
|
|
58
|
+
export function* wrappingAlternatives(tokens) {
|
|
59
|
+
for (let start = 0; start < tokens.length; start++) {
|
|
60
|
+
let row = [];
|
|
61
|
+
for (let end = start; end < tokens.length; end++) {
|
|
62
|
+
row = append(row, tokens[end]);
|
|
63
|
+
yield* row.filter((run) => !cinematicEffect(run));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=wrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../src/layout/wrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,4DAA4D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE1E,SAAS,MAAM,CACb,IAAwB,EACxB,KAAyB;IAEzB,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,IAAI,EAAE,SAAS,KAAK,GAAG,CAAC,SAAS;YACnC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;;YACjE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAwB;IACjD,qEAAqE;IACrE,IAAI,OAAO,IAAI,CAAC,SAAS,K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AC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ExportOptions, SceneV1, TextStyle, Diagnostic } from "./types.js";
|
|
2
|
+
export interface LayoutRequest {
|
|
3
|
+
readonly algorithm: "fit/v1";
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly maxHeight: number;
|
|
6
|
+
readonly variant: "standard" | "compact" | "auto";
|
|
7
|
+
readonly overflow: "error" | "wrap" | "shrink" | "wrap-then-shrink";
|
|
8
|
+
readonly minFontSize: number;
|
|
9
|
+
}
|
|
10
|
+
export type OutputSizing = {
|
|
11
|
+
readonly mode: "fixed";
|
|
12
|
+
readonly width: number;
|
|
13
|
+
} | {
|
|
14
|
+
readonly mode: "container-experimental";
|
|
15
|
+
readonly maxWidth: number;
|
|
16
|
+
readonly fillFraction?: number;
|
|
17
|
+
};
|
|
18
|
+
export type MeasurementQuality = "authored-geometry" | "measured-local-font" | "estimated";
|
|
19
|
+
export interface PaintBounds {
|
|
20
|
+
readonly x: number;
|
|
21
|
+
readonly y: number;
|
|
22
|
+
readonly width: number;
|
|
23
|
+
readonly height: number;
|
|
24
|
+
}
|
|
25
|
+
/** Text is shaped as a complete fragment. The key is validated against every field. */
|
|
26
|
+
export interface TextMeasurementRequest {
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly algorithm: "fit/v1";
|
|
29
|
+
readonly profile: string;
|
|
30
|
+
readonly text: string;
|
|
31
|
+
readonly style: TextStyle;
|
|
32
|
+
readonly italic: boolean;
|
|
33
|
+
readonly direction: "ltr" | "rtl";
|
|
34
|
+
readonly environment: string;
|
|
35
|
+
}
|
|
36
|
+
export interface TextMeasurement {
|
|
37
|
+
readonly request: TextMeasurementRequest;
|
|
38
|
+
readonly advance: number;
|
|
39
|
+
readonly inkLeft: number;
|
|
40
|
+
readonly inkRight: number;
|
|
41
|
+
readonly ascent: number;
|
|
42
|
+
readonly descent: number;
|
|
43
|
+
}
|
|
44
|
+
export interface MeasurementSnapshot {
|
|
45
|
+
readonly kind: "consoleFxMeasurements";
|
|
46
|
+
readonly measurementVersion: 1;
|
|
47
|
+
readonly environment: string;
|
|
48
|
+
readonly records: readonly TextMeasurement[];
|
|
49
|
+
}
|
|
50
|
+
export interface LayoutFragment {
|
|
51
|
+
readonly sourceLine: number;
|
|
52
|
+
readonly sourceRun: number;
|
|
53
|
+
readonly slot?: string;
|
|
54
|
+
readonly text: string;
|
|
55
|
+
readonly x: number;
|
|
56
|
+
readonly baseline: number;
|
|
57
|
+
readonly fontSize: number;
|
|
58
|
+
readonly advance: number;
|
|
59
|
+
readonly ink: PaintBounds;
|
|
60
|
+
readonly paint: PaintBounds;
|
|
61
|
+
readonly quality: MeasurementQuality;
|
|
62
|
+
}
|
|
63
|
+
export interface LayoutReport {
|
|
64
|
+
readonly algorithm: "fit/v1";
|
|
65
|
+
readonly profile: string;
|
|
66
|
+
readonly variant: "standard" | "compact";
|
|
67
|
+
readonly artboard: {
|
|
68
|
+
readonly width: number;
|
|
69
|
+
readonly height: number;
|
|
70
|
+
};
|
|
71
|
+
readonly paint: PaintBounds;
|
|
72
|
+
readonly fragments: readonly LayoutFragment[];
|
|
73
|
+
readonly glyphBounds: readonly {
|
|
74
|
+
readonly sourceLine: number;
|
|
75
|
+
readonly sourceRun: number;
|
|
76
|
+
readonly index: number;
|
|
77
|
+
readonly ink: PaintBounds;
|
|
78
|
+
}[];
|
|
79
|
+
readonly visualRows: number;
|
|
80
|
+
readonly contentScale: number;
|
|
81
|
+
readonly displayScale: number | null;
|
|
82
|
+
readonly resolvedDisplayWidth: number | null;
|
|
83
|
+
readonly resolvedDisplayHeight: number | null;
|
|
84
|
+
readonly displayReadability: "meets-requested-floor" | "unknown";
|
|
85
|
+
readonly measurementQuality: MeasurementQuality;
|
|
86
|
+
readonly measurementEnvironment: string | null;
|
|
87
|
+
readonly verdict: "fits-under-recorded-conditions" | "estimated-fit";
|
|
88
|
+
readonly measurementRequests: readonly TextMeasurementRequest[];
|
|
89
|
+
readonly shapingRequests: number;
|
|
90
|
+
readonly shrinkCandidates: number;
|
|
91
|
+
readonly segmentation: "fit/v1-grapheme-space-cjk";
|
|
92
|
+
readonly blurTolerance: "3-sigma";
|
|
93
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
94
|
+
}
|
|
95
|
+
export interface RenderRecipeV1 {
|
|
96
|
+
readonly kind: "consoleFxRenderRecipe";
|
|
97
|
+
readonly recipeVersion: 1;
|
|
98
|
+
readonly scene: SceneV1;
|
|
99
|
+
readonly options: Omit<ExportOptions, "measurements" | "measurementEnvironment">;
|
|
100
|
+
}
|
|
101
|
+
export interface OutputSizingReport {
|
|
102
|
+
readonly mode: "fixed" | "container-experimental";
|
|
103
|
+
readonly artboard: {
|
|
104
|
+
readonly width: number;
|
|
105
|
+
readonly height: number;
|
|
106
|
+
};
|
|
107
|
+
readonly resolvedDisplayWidth: number | null;
|
|
108
|
+
readonly resolvedDisplayHeight: number | null;
|
|
109
|
+
readonly displayScale: number | null;
|
|
110
|
+
readonly displayReadability: "meets-requested-floor" | "meets-default-floor" | "unknown";
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/model/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEhF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,kBAAkB,CAAC;IACpE,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,GAAG,wBAAwB,CAC1C,CAAC;CACH;AACD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,wBAAwB,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACvE,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,kBAAkB,EACzB,uBAAuB,GAAG,qBAAqB,GAAG,SAAS,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/model/layout.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const LIMITS: Readonly<{
|
|
2
|
+
inputBytes: number;
|
|
3
|
+
textCodePoints: 2000;
|
|
4
|
+
lines: 8;
|
|
5
|
+
runs: 32;
|
|
6
|
+
effectsPerRun: 4;
|
|
7
|
+
animatedGraphemes: 80;
|
|
8
|
+
svgWidth: 1200;
|
|
9
|
+
svgHeight: 400;
|
|
10
|
+
svgElements: 1000;
|
|
11
|
+
motionMs: 5000;
|
|
12
|
+
snippetWarningBytes: number;
|
|
13
|
+
snippetBytes: number;
|
|
14
|
+
shareBytes: number;
|
|
15
|
+
history: 100;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function utf8ByteLength(value: string): number;
|
|
18
|
+
export declare function deepFreeze<T>(value: T): T;
|
|
19
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/model/limits.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;EAejB,CAAC;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAMzC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const LIMITS = Object.freeze({
|
|
2
|
+
inputBytes: 64 * 1024,
|
|
3
|
+
textCodePoints: 2000,
|
|
4
|
+
lines: 8,
|
|
5
|
+
runs: 32,
|
|
6
|
+
effectsPerRun: 4,
|
|
7
|
+
animatedGraphemes: 80,
|
|
8
|
+
svgWidth: 1200,
|
|
9
|
+
svgHeight: 400,
|
|
10
|
+
svgElements: 1000,
|
|
11
|
+
motionMs: 5000,
|
|
12
|
+
snippetWarningBytes: 32 * 1024,
|
|
13
|
+
snippetBytes: 128 * 1024,
|
|
14
|
+
shareBytes: 8 * 1024,
|
|
15
|
+
history: 100,
|
|
16
|
+
});
|
|
17
|
+
export function utf8ByteLength(value) {
|
|
18
|
+
return new TextEncoder().encode(value).byteLength;
|
|
19
|
+
}
|
|
20
|
+
export function deepFreeze(value) {
|
|
21
|
+
if (value !== null && typeof value === "object") {
|
|
22
|
+
for (const child of Object.values(value))
|
|
23
|
+
deepFreeze(child);
|
|
24
|
+
Object.freeze(value);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/model/limits.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAClC,UAAU,EAAE,EAAE,GAAG,IAAI;IACrB,cAAc,EAAE,IAAI;IACpB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,EAAE;IACR,aAAa,EAAE,CAAC;IAChB,iBAAiB,EAAE,EAAE;IACrB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,GAAG;IACd,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,IAAI;IACd,mBAAmB,EAAE,EAAE,GAAG,IAAI;IAC9B,YAAY,EAAE,GAAG,GAAG,IAAI;IACxB,UAAU,EAAE,CAAC,GAAG,IAAI;IACpB,OAAO,EAAE,GAAG;CACb,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,KAAQ;IACpC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import type { LayoutRequest, OutputSizing, MeasurementSnapshot, LayoutReport, OutputSizingReport } from "./layout.js";
|
|
2
|
+
export type * from "./layout.js";
|
|
3
|
+
export type Renderer = "css" | "svg" | "text";
|
|
4
|
+
export type Target = "chromium" | "firefox" | "safari" | "node" | "bun" | "unknown";
|
|
5
|
+
export type FontFamily = "sans" | "mono" | "serif";
|
|
6
|
+
export type CardPresetId = "buildReceipt" | "requestTrace" | "serviceReady" | "commandCard" | "releaseBulletin" | "blueprint" | "contourMap" | "letterpress" | "signalHalftone" | "orbital";
|
|
7
|
+
export type PresentationProfile = `${CardPresetId}/v1`;
|
|
8
|
+
export type StatusTone = "success" | "warning" | "error" | "neutral";
|
|
9
|
+
export type PresetPresentationInput = {
|
|
10
|
+
readonly kind: "presetCard";
|
|
11
|
+
readonly accent?: string;
|
|
12
|
+
readonly detail?: "minimal" | "standard";
|
|
13
|
+
} & ({
|
|
14
|
+
readonly profile: "requestTrace/v1";
|
|
15
|
+
readonly tone?: StatusTone;
|
|
16
|
+
} | {
|
|
17
|
+
readonly profile: Exclude<PresentationProfile, "requestTrace/v1">;
|
|
18
|
+
readonly tone?: never;
|
|
19
|
+
});
|
|
20
|
+
export type PresetPresentation = {
|
|
21
|
+
readonly kind: "presetCard";
|
|
22
|
+
readonly accent: string;
|
|
23
|
+
readonly detail: "minimal" | "standard";
|
|
24
|
+
} & ({
|
|
25
|
+
readonly profile: "requestTrace/v1";
|
|
26
|
+
readonly tone: StatusTone;
|
|
27
|
+
} | {
|
|
28
|
+
readonly profile: Exclude<PresentationProfile, "requestTrace/v1">;
|
|
29
|
+
readonly tone?: never;
|
|
30
|
+
});
|
|
31
|
+
export type CinematicProfile = "lightning-metal-v1" | "ice-cathedral-v1" | "liquid-chrome-v1" | "molten-gold-v1";
|
|
32
|
+
export interface CinematicMetalEffectInput {
|
|
33
|
+
readonly kind: "cinematicMetal";
|
|
34
|
+
readonly profile?: CinematicProfile;
|
|
35
|
+
readonly color?: string;
|
|
36
|
+
readonly depth?: number;
|
|
37
|
+
readonly glow?: number;
|
|
38
|
+
readonly ornaments?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export type EffectInput = CinematicMetalEffectInput | {
|
|
41
|
+
readonly kind: "badge";
|
|
42
|
+
readonly color?: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "neon";
|
|
45
|
+
readonly color?: string;
|
|
46
|
+
readonly intensity?: number;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "rgbSplit";
|
|
49
|
+
readonly offset?: number;
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "extruded";
|
|
52
|
+
readonly depth?: number;
|
|
53
|
+
readonly color?: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "holographic";
|
|
56
|
+
readonly intensity?: number;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "metallic";
|
|
59
|
+
readonly variant?: "gold" | "chrome";
|
|
60
|
+
} | {
|
|
61
|
+
readonly kind: "crt";
|
|
62
|
+
readonly intensity?: number;
|
|
63
|
+
} | {
|
|
64
|
+
readonly kind: "rainbow";
|
|
65
|
+
readonly saturation?: number;
|
|
66
|
+
} | {
|
|
67
|
+
readonly kind: "glowPulse";
|
|
68
|
+
readonly periodMs?: number;
|
|
69
|
+
readonly intensity?: number;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: "gradientDrift";
|
|
72
|
+
readonly periodMs?: number;
|
|
73
|
+
readonly distance?: number;
|
|
74
|
+
} | {
|
|
75
|
+
readonly kind: "wave";
|
|
76
|
+
readonly amplitude?: number;
|
|
77
|
+
readonly periodMs?: number;
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: "indicator";
|
|
80
|
+
readonly color?: string;
|
|
81
|
+
readonly periodMs?: number;
|
|
82
|
+
};
|
|
83
|
+
type WithDefaults<T> = T extends EffectInput ? Readonly<Required<T>> : never;
|
|
84
|
+
export type Effect = WithDefaults<EffectInput>;
|
|
85
|
+
export type EffectKind = Effect["kind"];
|
|
86
|
+
export interface TextStyle {
|
|
87
|
+
readonly color: string;
|
|
88
|
+
readonly fontSize: number;
|
|
89
|
+
readonly fontWeight: number;
|
|
90
|
+
readonly fontFamily: FontFamily;
|
|
91
|
+
readonly letterSpacing: number;
|
|
92
|
+
}
|
|
93
|
+
export interface Surface {
|
|
94
|
+
readonly width: number;
|
|
95
|
+
readonly height: number;
|
|
96
|
+
readonly background: string;
|
|
97
|
+
readonly padding: number;
|
|
98
|
+
readonly borderRadius: number;
|
|
99
|
+
}
|
|
100
|
+
export interface RunInput {
|
|
101
|
+
readonly text: string;
|
|
102
|
+
readonly style?: Partial<TextStyle>;
|
|
103
|
+
readonly effects?: readonly EffectInput[];
|
|
104
|
+
}
|
|
105
|
+
export interface LineInput {
|
|
106
|
+
readonly align?: "left" | "center" | "right";
|
|
107
|
+
readonly runs: readonly RunInput[];
|
|
108
|
+
}
|
|
109
|
+
export interface SceneInputV1 {
|
|
110
|
+
readonly schemaVersion: 1;
|
|
111
|
+
readonly label: string;
|
|
112
|
+
readonly presentation?: PresetPresentationInput;
|
|
113
|
+
readonly surface?: Partial<Surface>;
|
|
114
|
+
readonly lines: readonly LineInput[];
|
|
115
|
+
readonly motion?: {
|
|
116
|
+
readonly durationMs?: number;
|
|
117
|
+
readonly finish?: "freeze";
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export interface TextRun {
|
|
121
|
+
readonly text: string;
|
|
122
|
+
readonly style: TextStyle;
|
|
123
|
+
readonly effects: readonly Effect[];
|
|
124
|
+
}
|
|
125
|
+
export interface SceneLine {
|
|
126
|
+
readonly align: "left" | "center" | "right";
|
|
127
|
+
readonly runs: readonly TextRun[];
|
|
128
|
+
}
|
|
129
|
+
export interface SceneV1 {
|
|
130
|
+
readonly schemaVersion: 1;
|
|
131
|
+
readonly label: string;
|
|
132
|
+
readonly presentation?: PresetPresentation;
|
|
133
|
+
readonly surface: Surface;
|
|
134
|
+
readonly lines: readonly SceneLine[];
|
|
135
|
+
readonly motion: {
|
|
136
|
+
readonly durationMs: number;
|
|
137
|
+
readonly finish: "freeze";
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export interface Diagnostic {
|
|
141
|
+
readonly code: string;
|
|
142
|
+
readonly severity: "info" | "warning" | "error";
|
|
143
|
+
readonly path: readonly (string | number)[];
|
|
144
|
+
readonly message: string;
|
|
145
|
+
}
|
|
146
|
+
export type ValidationResult<T> = {
|
|
147
|
+
readonly ok: true;
|
|
148
|
+
readonly value: T;
|
|
149
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
150
|
+
} | {
|
|
151
|
+
readonly ok: false;
|
|
152
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
153
|
+
};
|
|
154
|
+
export type ParameterDescriptor = {
|
|
155
|
+
readonly type: "number";
|
|
156
|
+
readonly default: number;
|
|
157
|
+
readonly min: number;
|
|
158
|
+
readonly max: number;
|
|
159
|
+
readonly step: number;
|
|
160
|
+
} | {
|
|
161
|
+
readonly type: "color";
|
|
162
|
+
readonly default: string;
|
|
163
|
+
} | {
|
|
164
|
+
readonly type: "boolean";
|
|
165
|
+
readonly default: boolean;
|
|
166
|
+
} | {
|
|
167
|
+
readonly type: "enum";
|
|
168
|
+
readonly default: string;
|
|
169
|
+
readonly values: readonly string[];
|
|
170
|
+
};
|
|
171
|
+
export interface EffectDescriptor {
|
|
172
|
+
readonly kind: EffectKind;
|
|
173
|
+
readonly displayName: string;
|
|
174
|
+
readonly family: string;
|
|
175
|
+
readonly scopes: readonly ("run" | "surface")[];
|
|
176
|
+
readonly parameters: Readonly<Record<string, ParameterDescriptor>>;
|
|
177
|
+
readonly renderers: readonly Renderer[];
|
|
178
|
+
readonly motion: "static" | "decorative";
|
|
179
|
+
}
|
|
180
|
+
export interface PresentationSlot {
|
|
181
|
+
readonly id: string;
|
|
182
|
+
readonly label: string;
|
|
183
|
+
readonly line: number;
|
|
184
|
+
readonly run: number;
|
|
185
|
+
readonly style: TextStyle;
|
|
186
|
+
readonly x: number;
|
|
187
|
+
readonly y: number;
|
|
188
|
+
readonly anchor: "start" | "end";
|
|
189
|
+
readonly safeWidth: number;
|
|
190
|
+
readonly maxCodePoints: number;
|
|
191
|
+
readonly values?: readonly string[];
|
|
192
|
+
readonly editableStyleKeys?: readonly (keyof TextStyle)[];
|
|
193
|
+
}
|
|
194
|
+
export interface PresentationStatus {
|
|
195
|
+
readonly slot: string;
|
|
196
|
+
readonly source: "text" | "tone";
|
|
197
|
+
readonly palettes: Readonly<Record<string, {
|
|
198
|
+
readonly background: string;
|
|
199
|
+
readonly ink: string;
|
|
200
|
+
readonly marker: string;
|
|
201
|
+
readonly stroke: string;
|
|
202
|
+
}>>;
|
|
203
|
+
}
|
|
204
|
+
export interface PresentationDescriptor {
|
|
205
|
+
readonly id: CardPresetId;
|
|
206
|
+
readonly profile: PresentationProfile;
|
|
207
|
+
readonly name: string;
|
|
208
|
+
readonly group: "Useful" | "Artful";
|
|
209
|
+
readonly accent: string;
|
|
210
|
+
readonly background: string;
|
|
211
|
+
readonly rows: readonly number[];
|
|
212
|
+
readonly slots: readonly PresentationSlot[];
|
|
213
|
+
readonly renderers: readonly Renderer[];
|
|
214
|
+
readonly editableStyleKeys: readonly (keyof TextStyle)[];
|
|
215
|
+
readonly parameters: Readonly<Record<string, ParameterDescriptor>>;
|
|
216
|
+
readonly accentGeometry: readonly string[];
|
|
217
|
+
readonly status?: PresentationStatus;
|
|
218
|
+
}
|
|
219
|
+
export type ConsoleArgs = readonly [format: string, ...values: string[]];
|
|
220
|
+
export type CompiledPreview = {
|
|
221
|
+
readonly kind: "css";
|
|
222
|
+
readonly lines: readonly {
|
|
223
|
+
readonly runs: readonly {
|
|
224
|
+
readonly text: string;
|
|
225
|
+
readonly style: Readonly<Record<string, string>>;
|
|
226
|
+
}[];
|
|
227
|
+
}[];
|
|
228
|
+
} | {
|
|
229
|
+
readonly kind: "svg";
|
|
230
|
+
readonly imageUri: string;
|
|
231
|
+
readonly width: number;
|
|
232
|
+
readonly height: number;
|
|
233
|
+
readonly alt: string;
|
|
234
|
+
} | {
|
|
235
|
+
readonly kind: "text";
|
|
236
|
+
readonly text: string;
|
|
237
|
+
};
|
|
238
|
+
export interface CompileOptions {
|
|
239
|
+
readonly target?: Target;
|
|
240
|
+
readonly renderer?: Renderer;
|
|
241
|
+
readonly motion?: "allow" | "reduce";
|
|
242
|
+
readonly unsupported?: "error" | "fallback";
|
|
243
|
+
readonly layout?: LayoutRequest;
|
|
244
|
+
readonly sizing?: OutputSizing;
|
|
245
|
+
readonly measurements?: MeasurementSnapshot;
|
|
246
|
+
readonly measurementEnvironment?: string;
|
|
247
|
+
}
|
|
248
|
+
export interface CompiledConsole {
|
|
249
|
+
readonly args: ConsoleArgs;
|
|
250
|
+
readonly renderer: Renderer;
|
|
251
|
+
readonly text: string;
|
|
252
|
+
readonly animated: boolean;
|
|
253
|
+
readonly byteLength: number;
|
|
254
|
+
readonly preview: CompiledPreview;
|
|
255
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
256
|
+
readonly layout?: LayoutReport;
|
|
257
|
+
readonly outputSizing?: OutputSizingReport;
|
|
258
|
+
}
|
|
259
|
+
export interface ExportOptions extends Omit<CompileOptions, "motion"> {
|
|
260
|
+
readonly motion?: "system" | "reduce";
|
|
261
|
+
}
|
|
262
|
+
export interface ExportedConsole {
|
|
263
|
+
readonly code: string;
|
|
264
|
+
readonly byteLength: number;
|
|
265
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=types.d.ts.map
|