@pixerate/editor 0.161.0 → 0.162.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/dist/agent/index.cjs +36 -35
- package/dist/agent/index.js +7 -6
- package/dist/animation/index.cjs +5 -4
- package/dist/animation/index.js +4 -3
- package/dist/animation-editor/index.cjs +62 -61
- package/dist/animation-editor/index.js +6 -5
- package/dist/canvas/index.cjs +33 -32
- package/dist/canvas/index.js +6 -5
- package/dist/chart/index.cjs +88 -87
- package/dist/chart/index.js +7 -6
- package/dist/{chunk-QMI5HZWA.cjs → chunk-236TKNUR.cjs} +3 -3
- package/dist/{chunk-6UPGM3JB.js → chunk-2TKHLX6H.js} +1 -1
- package/dist/{chunk-3YDQLQH2.cjs → chunk-32MMQYCQ.cjs} +81 -81
- package/dist/{chunk-MHEXLG3M.cjs → chunk-3GJH2MGH.cjs} +37 -37
- package/dist/{chunk-AKDWAWSY.cjs → chunk-3IHNXRUV.cjs} +45 -45
- package/dist/{chunk-TVO6W2Q6.cjs → chunk-4NGVHHJB.cjs} +17 -17
- package/dist/chunk-4VU4CP7R.js +769 -0
- package/dist/{chunk-DBIVICAO.js → chunk-7CKPUUN4.js} +1 -1
- package/dist/{chunk-57JLBGJ5.cjs → chunk-7YBDRJXT.cjs} +8 -8
- package/dist/{chunk-KY3FYKP3.js → chunk-BQWGN5WH.js} +1 -1
- package/dist/{chunk-LEUZ4FRC.cjs → chunk-CIPIESX4.cjs} +3 -3
- package/dist/chunk-CJE5MOIS.js +347 -0
- package/dist/{chunk-5QBRAIVK.js → chunk-CX6JLDFC.js} +3 -3
- package/dist/{chunk-R3QY7PPL.js → chunk-DTSTNRPH.js} +1 -1
- package/dist/{chunk-6LUYFHHN.cjs → chunk-EQ46F75O.cjs} +51 -51
- package/dist/{chunk-UKCJ43YL.cjs → chunk-ES3UEVUT.cjs} +130 -898
- package/dist/{chunk-UM3RPYC5.js → chunk-EVPZ5IKN.js} +1 -1
- package/dist/{chunk-XNQ5EFB4.cjs → chunk-EY22AY6R.cjs} +16 -16
- package/dist/chunk-FKUKJ3XA.cjs +347 -0
- package/dist/{chunk-YABNLNY7.js → chunk-GLMP22FT.js} +3 -3
- package/dist/{chunk-SUF6WRXR.cjs → chunk-GTELFJRE.cjs} +2 -2
- package/dist/{chunk-72BGL3I2.js → chunk-GWV4T5NZ.js} +1 -1
- package/dist/{chunk-AY65VQSU.js → chunk-H3OEM3Q2.js} +1 -1
- package/dist/{chunk-4YWAEV4W.cjs → chunk-HDGBM7EA.cjs} +26 -26
- package/dist/{chunk-H5XX4KHB.js → chunk-HLOKB7WW.js} +5 -3
- package/dist/{chunk-WNAAWLZ5.js → chunk-KGTF55R3.js} +2 -2
- package/dist/{chunk-WPPJH6X4.cjs → chunk-LL3H5XUH.cjs} +6 -4
- package/dist/{chunk-4T44CJ5K.cjs → chunk-NA4UVVJ4.cjs} +15 -15
- package/dist/{chunk-Q6PA362P.js → chunk-NO5QQDHZ.js} +2 -2
- package/dist/{chunk-AA34BA7G.js → chunk-QYZGBVNC.js} +30 -798
- package/dist/chunk-S6X2QRVU.cjs +769 -0
- package/dist/{chunk-SSCL7QQ4.js → chunk-XDCFJEU7.js} +2 -2
- package/dist/color/index.cjs +6 -2
- package/dist/color/index.d.cts +1 -0
- package/dist/color/index.d.ts +1 -0
- package/dist/color/index.js +28 -24
- package/dist/color/suggest.d.cts +12 -0
- package/dist/color/suggest.d.ts +12 -0
- package/dist/effects/index.cjs +37 -13
- package/dist/effects/index.js +29 -5
- package/dist/effects/ui.d.cts +20 -3
- package/dist/effects/ui.d.ts +20 -3
- package/dist/export/index.cjs +6 -5
- package/dist/export/index.js +5 -4
- package/dist/extensions/index.cjs +9 -8
- package/dist/extensions/index.js +8 -7
- package/dist/gradient/index.cjs +28 -26
- package/dist/gradient/index.js +7 -5
- package/dist/image-editor/index.cjs +638 -637
- package/dist/image-editor/index.js +5 -4
- package/dist/index.cjs +15 -14
- package/dist/index.js +9 -8
- package/dist/paint-editor/index.cjs +15 -14
- package/dist/paint-editor/index.js +5 -4
- package/dist/typography/accessibility.d.cts +44 -0
- package/dist/typography/accessibility.d.ts +44 -0
- package/dist/typography/catalog.d.cts +98 -0
- package/dist/typography/catalog.d.ts +98 -0
- package/dist/typography/index.cjs +1099 -0
- package/dist/typography/index.d.cts +16 -0
- package/dist/typography/index.d.ts +16 -0
- package/dist/typography/index.js +1099 -0
- package/dist/typography/metrics.d.cts +31 -0
- package/dist/typography/metrics.d.ts +31 -0
- package/dist/typography/picker.d.cts +132 -0
- package/dist/typography/picker.d.ts +132 -0
- package/dist/typography/registry.d.cts +66 -0
- package/dist/typography/registry.d.ts +66 -0
- package/dist/typography/scale.d.cts +62 -0
- package/dist/typography/scale.d.ts +62 -0
- package/dist/typography/segment.d.cts +26 -0
- package/dist/typography/segment.d.ts +26 -0
- package/dist/typography/stack.d.cts +26 -0
- package/dist/typography/stack.d.ts +26 -0
- package/dist/typography/tools.d.cts +34 -0
- package/dist/typography/tools.d.ts +34 -0
- package/dist/typography/types.d.cts +96 -0
- package/dist/typography/types.d.ts +96 -0
- package/dist/typography/weight.d.cts +13 -0
- package/dist/typography/weight.d.ts +13 -0
- package/dist/vector/index.cjs +950 -949
- package/dist/vector/index.js +5 -4
- package/dist/video-editor/index.cjs +5 -4
- package/dist/video-editor/index.js +4 -3
- package/package.json +11 -1
- package/skills/README.md +1 -0
- package/skills/pixerate-typography/SKILL.md +91 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS `font-family` stacks: parsing, formatting and cross-platform fallbacks.
|
|
3
|
+
*/
|
|
4
|
+
import type { FontCategory } from './types.cjs';
|
|
5
|
+
/** Generic family keywords; these must stay unquoted in `font-family`. */
|
|
6
|
+
export declare const GENERIC_FONT_FAMILIES: readonly string[];
|
|
7
|
+
export type FontStackName = 'system-ui' | 'humanist-sans' | 'geometric-sans' | 'editorial-serif' | 'transitional-serif' | 'code-mono' | 'handwriting' | 'display';
|
|
8
|
+
/** Tested cross-platform stacks, each ending in a generic family. */
|
|
9
|
+
export declare const FONT_STACKS: Readonly<Record<FontStackName, string>>;
|
|
10
|
+
export declare const FONT_STACK_NAMES: FontStackName[];
|
|
11
|
+
/** The stack used as a fallback for each category. */
|
|
12
|
+
export declare const CATEGORY_FALLBACK_STACK: Readonly<Record<FontCategory, FontStackName>>;
|
|
13
|
+
/**
|
|
14
|
+
* Splits a CSS `font-family` value into unquoted family names. Handles single and double quotes,
|
|
15
|
+
* backslash escapes and commas inside quotes; collapses white space in unquoted names.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseFontFamily(stack: string): string[];
|
|
18
|
+
/** Quotes a family name for CSS when it needs it (generic keywords are never quoted). */
|
|
19
|
+
export declare function quoteFontFamily(name: string): string;
|
|
20
|
+
/** Joins family names into a CSS `font-family` value, dropping duplicates (case-insensitive). */
|
|
21
|
+
export declare function formatFontFamily(families: readonly string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* A resilient `font-family` value for a family: the family (or every family of a stack passed
|
|
24
|
+
* in), then the stack for its category, ending in a generic family.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveFontFallback(family: string, category?: FontCategory): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS `font-family` stacks: parsing, formatting and cross-platform fallbacks.
|
|
3
|
+
*/
|
|
4
|
+
import type { FontCategory } from './types.js';
|
|
5
|
+
/** Generic family keywords; these must stay unquoted in `font-family`. */
|
|
6
|
+
export declare const GENERIC_FONT_FAMILIES: readonly string[];
|
|
7
|
+
export type FontStackName = 'system-ui' | 'humanist-sans' | 'geometric-sans' | 'editorial-serif' | 'transitional-serif' | 'code-mono' | 'handwriting' | 'display';
|
|
8
|
+
/** Tested cross-platform stacks, each ending in a generic family. */
|
|
9
|
+
export declare const FONT_STACKS: Readonly<Record<FontStackName, string>>;
|
|
10
|
+
export declare const FONT_STACK_NAMES: FontStackName[];
|
|
11
|
+
/** The stack used as a fallback for each category. */
|
|
12
|
+
export declare const CATEGORY_FALLBACK_STACK: Readonly<Record<FontCategory, FontStackName>>;
|
|
13
|
+
/**
|
|
14
|
+
* Splits a CSS `font-family` value into unquoted family names. Handles single and double quotes,
|
|
15
|
+
* backslash escapes and commas inside quotes; collapses white space in unquoted names.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseFontFamily(stack: string): string[];
|
|
18
|
+
/** Quotes a family name for CSS when it needs it (generic keywords are never quoted). */
|
|
19
|
+
export declare function quoteFontFamily(name: string): string;
|
|
20
|
+
/** Joins family names into a CSS `font-family` value, dropping duplicates (case-insensitive). */
|
|
21
|
+
export declare function formatFontFamily(families: readonly string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* A resilient `font-family` value for a family: the family (or every family of a stack passed
|
|
24
|
+
* in), then the stack for its category, ending in a generic family.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveFontFallback(family: string, category?: FontCategory): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent tools for typography: font discovery and fallback stacks, modular scales and hierarchies,
|
|
3
|
+
* fluid sizes, readability and accessibility audits, text segmentation, and a font picker.
|
|
4
|
+
*/
|
|
5
|
+
import type { AgentToolProvider } from '../tools/registry.cjs';
|
|
6
|
+
import type { FontPickerModel } from './picker.cjs';
|
|
7
|
+
import { type FontProvider } from './registry.cjs';
|
|
8
|
+
export interface TypographyToolProviderOptions {
|
|
9
|
+
/** Provider id (unique per registry). Default 'typography'. */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Tool-name prefix; defaults to 'typography', '' for bare names. */
|
|
12
|
+
namespace?: string;
|
|
13
|
+
/** Where `list_fonts`, `resolve_font_stack` and `load_font` look. Default: the system font catalog. */
|
|
14
|
+
provider?: FontProvider;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An AgentToolProvider with font discovery, fallback stacks, type scales and hierarchies, fluid
|
|
18
|
+
* sizes, readability and type-aware contrast audits, and text segmentation. `load_font` is only
|
|
19
|
+
* listed when the font provider can load fonts.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createTypographyToolProvider(options?: TypographyToolProviderOptions): AgentToolProvider;
|
|
22
|
+
export interface FontPickerToolProviderOptions {
|
|
23
|
+
/** Provider id (unique per registry). Default 'font-picker'. */
|
|
24
|
+
id?: string;
|
|
25
|
+
/** Tool-name prefix; defaults to 'fontpicker', '' for bare names. */
|
|
26
|
+
namespace?: string;
|
|
27
|
+
/** Refuse `set_font_selection` (with this reason) while true; read tools still work. */
|
|
28
|
+
readOnly?: () => string | false;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Tools that read and change a mounted {@link FontPickerModel}, so an agent can choose a font in
|
|
32
|
+
* the same control a person uses.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createFontPickerToolProvider(model: FontPickerModel, options?: FontPickerToolProviderOptions): AgentToolProvider;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent tools for typography: font discovery and fallback stacks, modular scales and hierarchies,
|
|
3
|
+
* fluid sizes, readability and accessibility audits, text segmentation, and a font picker.
|
|
4
|
+
*/
|
|
5
|
+
import type { AgentToolProvider } from '../tools/registry.js';
|
|
6
|
+
import type { FontPickerModel } from './picker.js';
|
|
7
|
+
import { type FontProvider } from './registry.js';
|
|
8
|
+
export interface TypographyToolProviderOptions {
|
|
9
|
+
/** Provider id (unique per registry). Default 'typography'. */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Tool-name prefix; defaults to 'typography', '' for bare names. */
|
|
12
|
+
namespace?: string;
|
|
13
|
+
/** Where `list_fonts`, `resolve_font_stack` and `load_font` look. Default: the system font catalog. */
|
|
14
|
+
provider?: FontProvider;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An AgentToolProvider with font discovery, fallback stacks, type scales and hierarchies, fluid
|
|
18
|
+
* sizes, readability and type-aware contrast audits, and text segmentation. `load_font` is only
|
|
19
|
+
* listed when the font provider can load fonts.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createTypographyToolProvider(options?: TypographyToolProviderOptions): AgentToolProvider;
|
|
22
|
+
export interface FontPickerToolProviderOptions {
|
|
23
|
+
/** Provider id (unique per registry). Default 'font-picker'. */
|
|
24
|
+
id?: string;
|
|
25
|
+
/** Tool-name prefix; defaults to 'fontpicker', '' for bare names. */
|
|
26
|
+
namespace?: string;
|
|
27
|
+
/** Refuse `set_font_selection` (with this reason) while true; read tools still work. */
|
|
28
|
+
readOnly?: () => string | false;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Tools that read and change a mounted {@link FontPickerModel}, so an agent can choose a font in
|
|
32
|
+
* the same control a person uses.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createFontPickerToolProvider(model: FontPickerModel, options?: FontPickerToolProviderOptions): AgentToolProvider;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core typography types: font specs, weights, categories, scales and readability results.
|
|
3
|
+
*/
|
|
4
|
+
/** Numeric CSS font weights, 100–900 in steps of 100. */
|
|
5
|
+
export type NumericFontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
6
|
+
/** A CSS font weight: numeric, or the `normal` (400) and `bold` (700) keywords. */
|
|
7
|
+
export type FontWeight = NumericFontWeight | 'normal' | 'bold';
|
|
8
|
+
export type FontStyle = 'normal' | 'italic' | 'oblique';
|
|
9
|
+
/** Broad classification used for filtering and for choosing a fallback stack. */
|
|
10
|
+
export type FontCategory = 'sans-serif' | 'serif' | 'monospace' | 'display' | 'handwriting';
|
|
11
|
+
/** Where a font comes from: installed on the system, loaded over the web, or supplied by the host. */
|
|
12
|
+
export type FontSource = 'system' | 'web' | 'custom';
|
|
13
|
+
export declare const FONT_CATEGORIES: readonly FontCategory[];
|
|
14
|
+
/** Display names for categories (and `all`), for filters and badges. */
|
|
15
|
+
export declare const FONT_CATEGORY_LABELS: Readonly<Record<FontCategory | 'all', string>>;
|
|
16
|
+
export declare const FONT_WEIGHTS: readonly NumericFontWeight[];
|
|
17
|
+
export declare const FONT_STYLES: readonly FontStyle[];
|
|
18
|
+
/** Normalized specification for a typographic style. */
|
|
19
|
+
export interface FontSpec {
|
|
20
|
+
/** Primary family name, unquoted (e.g. `Inter`). Use `resolveFontFallback` for a CSS stack. */
|
|
21
|
+
family: string;
|
|
22
|
+
/** Default 400. */
|
|
23
|
+
weight?: FontWeight;
|
|
24
|
+
/** Default `normal`. */
|
|
25
|
+
style?: FontStyle;
|
|
26
|
+
/** Font size in CSS px. */
|
|
27
|
+
size: number;
|
|
28
|
+
/** Unitless line-height multiplier (1.5 = 150 % of `size`). */
|
|
29
|
+
lineHeight?: number;
|
|
30
|
+
/** Tracking in em (0.05 = 5 % of `size`). */
|
|
31
|
+
letterSpacing?: number;
|
|
32
|
+
category?: FontCategory;
|
|
33
|
+
}
|
|
34
|
+
/** Named modular scale ratios. */
|
|
35
|
+
export type ModularScaleRatio = 'minor-second' | 'major-second' | 'minor-third' | 'major-third' | 'perfect-fourth' | 'augmented-fourth' | 'perfect-fifth' | 'golden-ratio';
|
|
36
|
+
export interface TypeScaleStep {
|
|
37
|
+
/** Token name, e.g. `body`, `h1`, or `step-3` for an unnamed step. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Integer exponent; 0 is the base size. */
|
|
40
|
+
step: number;
|
|
41
|
+
/** Computed size in px (rounded to 0.01). */
|
|
42
|
+
size: number;
|
|
43
|
+
/** Recommended unitless line-height. */
|
|
44
|
+
lineHeight: number;
|
|
45
|
+
/** Recommended tracking in em. */
|
|
46
|
+
letterSpacing: number;
|
|
47
|
+
}
|
|
48
|
+
export interface TypeHierarchy {
|
|
49
|
+
ratio: number;
|
|
50
|
+
/** The named ratio, when one was used. */
|
|
51
|
+
ratioName?: ModularScaleRatio;
|
|
52
|
+
baseSize: number;
|
|
53
|
+
steps: Record<string, TypeScaleStep>;
|
|
54
|
+
}
|
|
55
|
+
export interface ReadabilityAuditResult {
|
|
56
|
+
lineLength: {
|
|
57
|
+
/** Average characters (grapheme clusters) per line. */
|
|
58
|
+
characters: number;
|
|
59
|
+
/** Average words per line. */
|
|
60
|
+
words: number;
|
|
61
|
+
/** `lines` when measured from the text's own line breaks, `width` when estimated from a container width. */
|
|
62
|
+
source: 'lines' | 'width';
|
|
63
|
+
/** Optimal is 45–75 characters. */
|
|
64
|
+
status: 'optimal' | 'too-short' | 'too-long';
|
|
65
|
+
recommendation?: string;
|
|
66
|
+
};
|
|
67
|
+
lineSpacing: {
|
|
68
|
+
/** Line-height multiplier used (1.2 when none was given: the browser `normal` approximation). */
|
|
69
|
+
ratio: number;
|
|
70
|
+
/** True when `ratio` was not given. */
|
|
71
|
+
assumed: boolean;
|
|
72
|
+
/** Line spacing is at least 1.5 (WCAG 1.4.8 / 1.4.12 body-text value). */
|
|
73
|
+
meetsRecommended: boolean;
|
|
74
|
+
recommendation?: string;
|
|
75
|
+
};
|
|
76
|
+
/** The text is set in capitals (two or more letters, none lower case). */
|
|
77
|
+
allCaps: boolean;
|
|
78
|
+
wordCount: number;
|
|
79
|
+
/** Silent reading at 238 words per minute. */
|
|
80
|
+
estimatedReadingTimeSeconds: number;
|
|
81
|
+
/** Human-readable findings, empty when nothing needs attention. */
|
|
82
|
+
issues: string[];
|
|
83
|
+
}
|
|
84
|
+
/** One piece of text from `segmentText`, with UTF-16 offsets into the original string. */
|
|
85
|
+
export interface TextSegment {
|
|
86
|
+
text: string;
|
|
87
|
+
/** UTF-16 offset of the first code unit. */
|
|
88
|
+
start: number;
|
|
89
|
+
/** UTF-16 offset just past the last code unit. */
|
|
90
|
+
end: number;
|
|
91
|
+
/** Position in the returned list. */
|
|
92
|
+
index: number;
|
|
93
|
+
/** For `word` granularity: whether the segment is a word (not white space or punctuation). */
|
|
94
|
+
isWordLike?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export type SegmentGranularity = 'grapheme' | 'word' | 'sentence' | 'line';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core typography types: font specs, weights, categories, scales and readability results.
|
|
3
|
+
*/
|
|
4
|
+
/** Numeric CSS font weights, 100–900 in steps of 100. */
|
|
5
|
+
export type NumericFontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
6
|
+
/** A CSS font weight: numeric, or the `normal` (400) and `bold` (700) keywords. */
|
|
7
|
+
export type FontWeight = NumericFontWeight | 'normal' | 'bold';
|
|
8
|
+
export type FontStyle = 'normal' | 'italic' | 'oblique';
|
|
9
|
+
/** Broad classification used for filtering and for choosing a fallback stack. */
|
|
10
|
+
export type FontCategory = 'sans-serif' | 'serif' | 'monospace' | 'display' | 'handwriting';
|
|
11
|
+
/** Where a font comes from: installed on the system, loaded over the web, or supplied by the host. */
|
|
12
|
+
export type FontSource = 'system' | 'web' | 'custom';
|
|
13
|
+
export declare const FONT_CATEGORIES: readonly FontCategory[];
|
|
14
|
+
/** Display names for categories (and `all`), for filters and badges. */
|
|
15
|
+
export declare const FONT_CATEGORY_LABELS: Readonly<Record<FontCategory | 'all', string>>;
|
|
16
|
+
export declare const FONT_WEIGHTS: readonly NumericFontWeight[];
|
|
17
|
+
export declare const FONT_STYLES: readonly FontStyle[];
|
|
18
|
+
/** Normalized specification for a typographic style. */
|
|
19
|
+
export interface FontSpec {
|
|
20
|
+
/** Primary family name, unquoted (e.g. `Inter`). Use `resolveFontFallback` for a CSS stack. */
|
|
21
|
+
family: string;
|
|
22
|
+
/** Default 400. */
|
|
23
|
+
weight?: FontWeight;
|
|
24
|
+
/** Default `normal`. */
|
|
25
|
+
style?: FontStyle;
|
|
26
|
+
/** Font size in CSS px. */
|
|
27
|
+
size: number;
|
|
28
|
+
/** Unitless line-height multiplier (1.5 = 150 % of `size`). */
|
|
29
|
+
lineHeight?: number;
|
|
30
|
+
/** Tracking in em (0.05 = 5 % of `size`). */
|
|
31
|
+
letterSpacing?: number;
|
|
32
|
+
category?: FontCategory;
|
|
33
|
+
}
|
|
34
|
+
/** Named modular scale ratios. */
|
|
35
|
+
export type ModularScaleRatio = 'minor-second' | 'major-second' | 'minor-third' | 'major-third' | 'perfect-fourth' | 'augmented-fourth' | 'perfect-fifth' | 'golden-ratio';
|
|
36
|
+
export interface TypeScaleStep {
|
|
37
|
+
/** Token name, e.g. `body`, `h1`, or `step-3` for an unnamed step. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Integer exponent; 0 is the base size. */
|
|
40
|
+
step: number;
|
|
41
|
+
/** Computed size in px (rounded to 0.01). */
|
|
42
|
+
size: number;
|
|
43
|
+
/** Recommended unitless line-height. */
|
|
44
|
+
lineHeight: number;
|
|
45
|
+
/** Recommended tracking in em. */
|
|
46
|
+
letterSpacing: number;
|
|
47
|
+
}
|
|
48
|
+
export interface TypeHierarchy {
|
|
49
|
+
ratio: number;
|
|
50
|
+
/** The named ratio, when one was used. */
|
|
51
|
+
ratioName?: ModularScaleRatio;
|
|
52
|
+
baseSize: number;
|
|
53
|
+
steps: Record<string, TypeScaleStep>;
|
|
54
|
+
}
|
|
55
|
+
export interface ReadabilityAuditResult {
|
|
56
|
+
lineLength: {
|
|
57
|
+
/** Average characters (grapheme clusters) per line. */
|
|
58
|
+
characters: number;
|
|
59
|
+
/** Average words per line. */
|
|
60
|
+
words: number;
|
|
61
|
+
/** `lines` when measured from the text's own line breaks, `width` when estimated from a container width. */
|
|
62
|
+
source: 'lines' | 'width';
|
|
63
|
+
/** Optimal is 45–75 characters. */
|
|
64
|
+
status: 'optimal' | 'too-short' | 'too-long';
|
|
65
|
+
recommendation?: string;
|
|
66
|
+
};
|
|
67
|
+
lineSpacing: {
|
|
68
|
+
/** Line-height multiplier used (1.2 when none was given: the browser `normal` approximation). */
|
|
69
|
+
ratio: number;
|
|
70
|
+
/** True when `ratio` was not given. */
|
|
71
|
+
assumed: boolean;
|
|
72
|
+
/** Line spacing is at least 1.5 (WCAG 1.4.8 / 1.4.12 body-text value). */
|
|
73
|
+
meetsRecommended: boolean;
|
|
74
|
+
recommendation?: string;
|
|
75
|
+
};
|
|
76
|
+
/** The text is set in capitals (two or more letters, none lower case). */
|
|
77
|
+
allCaps: boolean;
|
|
78
|
+
wordCount: number;
|
|
79
|
+
/** Silent reading at 238 words per minute. */
|
|
80
|
+
estimatedReadingTimeSeconds: number;
|
|
81
|
+
/** Human-readable findings, empty when nothing needs attention. */
|
|
82
|
+
issues: string[];
|
|
83
|
+
}
|
|
84
|
+
/** One piece of text from `segmentText`, with UTF-16 offsets into the original string. */
|
|
85
|
+
export interface TextSegment {
|
|
86
|
+
text: string;
|
|
87
|
+
/** UTF-16 offset of the first code unit. */
|
|
88
|
+
start: number;
|
|
89
|
+
/** UTF-16 offset just past the last code unit. */
|
|
90
|
+
end: number;
|
|
91
|
+
/** Position in the returned list. */
|
|
92
|
+
index: number;
|
|
93
|
+
/** For `word` granularity: whether the segment is a word (not white space or punctuation). */
|
|
94
|
+
isWordLike?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export type SegmentGranularity = 'grapheme' | 'word' | 'sentence' | 'line';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font weight normalisation and matching.
|
|
3
|
+
*/
|
|
4
|
+
import type { FontWeight, NumericFontWeight } from './types.cjs';
|
|
5
|
+
/** `normal` → 400, `bold` → 700, numbers rounded to the nearest 100 within 100–900. */
|
|
6
|
+
export declare function normalizeFontWeight(weight: FontWeight | number | undefined): NumericFontWeight;
|
|
7
|
+
/** Whether a value is a CSS font weight this module accepts. */
|
|
8
|
+
export declare function isFontWeight(value: unknown): value is FontWeight;
|
|
9
|
+
/**
|
|
10
|
+
* The available weight CSS font matching would pick for `wanted`: for 400 try 500 first, then
|
|
11
|
+
* lighter, then heavier; below 400 lighter first; above 500 heavier first.
|
|
12
|
+
*/
|
|
13
|
+
export declare function nearestFontWeight(wanted: FontWeight | number, available: readonly FontWeight[]): NumericFontWeight;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font weight normalisation and matching.
|
|
3
|
+
*/
|
|
4
|
+
import type { FontWeight, NumericFontWeight } from './types.js';
|
|
5
|
+
/** `normal` → 400, `bold` → 700, numbers rounded to the nearest 100 within 100–900. */
|
|
6
|
+
export declare function normalizeFontWeight(weight: FontWeight | number | undefined): NumericFontWeight;
|
|
7
|
+
/** Whether a value is a CSS font weight this module accepts. */
|
|
8
|
+
export declare function isFontWeight(value: unknown): value is FontWeight;
|
|
9
|
+
/**
|
|
10
|
+
* The available weight CSS font matching would pick for `wanted`: for 400 try 500 first, then
|
|
11
|
+
* lighter, then heavier; below 400 lighter first; above 500 heavier first.
|
|
12
|
+
*/
|
|
13
|
+
export declare function nearestFontWeight(wanted: FontWeight | number, available: readonly FontWeight[]): NumericFontWeight;
|