@pixerate/editor 0.160.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-VKF3PWKR.cjs → chunk-3OSXHLIT.cjs} +259 -28
- package/dist/{chunk-TVO6W2Q6.cjs → chunk-4NGVHHJB.cjs} +17 -17
- package/dist/chunk-4VU4CP7R.js +769 -0
- package/dist/chunk-6DM3PUQD.cjs +767 -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/{chunk-IQ6KKXOU.js → chunk-YN4AYYBJ.js} +243 -12
- package/dist/chunk-ZGOHKS3X.js +767 -0
- 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 +44 -771
- package/dist/effects/index.js +34 -761
- 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 +17 -16
- package/dist/paint-editor/index.js +6 -5
- 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/audio.d.cts +9 -0
- package/dist/video-editor/audio.d.ts +9 -0
- package/dist/video-editor/check.d.cts +1 -1
- package/dist/video-editor/check.d.ts +1 -1
- package/dist/video-editor/controller.d.cts +47 -0
- package/dist/video-editor/controller.d.ts +47 -0
- package/dist/video-editor/dialogue-tools.d.cts +19 -0
- package/dist/video-editor/dialogue-tools.d.ts +19 -0
- package/dist/video-editor/effect-authoring.d.cts +54 -0
- package/dist/video-editor/effect-authoring.d.ts +54 -0
- package/dist/video-editor/evaluate.d.cts +11 -0
- package/dist/video-editor/evaluate.d.ts +11 -0
- package/dist/video-editor/export.d.cts +7 -1
- package/dist/video-editor/export.d.ts +7 -1
- package/dist/video-editor/index.cjs +1857 -531
- package/dist/video-editor/index.d.cts +7 -0
- package/dist/video-editor/index.d.ts +7 -0
- package/dist/video-editor/index.js +1516 -190
- package/dist/video-editor/lut.d.cts +12 -2
- package/dist/video-editor/lut.d.ts +12 -2
- package/dist/video-editor/mask.d.cts +48 -0
- package/dist/video-editor/mask.d.ts +48 -0
- package/dist/video-editor/mix.d.cts +107 -0
- package/dist/video-editor/mix.d.ts +107 -0
- package/dist/video-editor/music-tools.d.cts +19 -0
- package/dist/video-editor/music-tools.d.ts +19 -0
- package/dist/video-editor/parse.d.cts +3 -1
- package/dist/video-editor/parse.d.ts +3 -1
- package/dist/video-editor/plan.d.cts +75 -0
- package/dist/video-editor/plan.d.ts +75 -0
- package/dist/video-editor/render.d.cts +1 -1
- package/dist/video-editor/render.d.ts +1 -1
- package/dist/video-editor/timeline.d.cts +2 -0
- package/dist/video-editor/timeline.d.ts +2 -0
- package/dist/video-editor/tools.d.cts +90 -0
- package/dist/video-editor/tools.d.ts +90 -0
- package/dist/video-editor/transcript-controller.d.cts +106 -0
- package/dist/video-editor/transcript-controller.d.ts +106 -0
- package/dist/video-editor/transcript.d.cts +40 -0
- package/dist/video-editor/transcript.d.ts +40 -0
- package/dist/video-editor/types.d.cts +62 -2
- package/dist/video-editor/types.d.ts +62 -2
- package/dist/video-editor/ui.d.cts +21 -1
- package/dist/video-editor/ui.d.ts +21 -1
- package/package.json +11 -1
- package/skills/README.md +3 -0
- package/skills/pixerate-bgm-alignment/SKILL.md +82 -0
- package/skills/pixerate-talking-head-edit/SKILL.md +80 -0
- package/skills/pixerate-typography/SKILL.md +91 -0
- package/skills/pixerate-video-editor/SKILL.md +40 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measure (line length), line spacing and other readability checks for body text.
|
|
3
|
+
*/
|
|
4
|
+
import type { FontCategory, FontSpec, ReadabilityAuditResult } from './types.cjs';
|
|
5
|
+
/** Comfortable measure for body text, in characters per line. */
|
|
6
|
+
export declare const OPTIMAL_MEASURE: {
|
|
7
|
+
readonly min: 45;
|
|
8
|
+
readonly max: 75;
|
|
9
|
+
};
|
|
10
|
+
/** WCAG 1.4.8 (AAA) line spacing and the WCAG 1.4.12 test value: 1.5× the font size. */
|
|
11
|
+
export declare const RECOMMENDED_LINE_HEIGHT = 1.5;
|
|
12
|
+
/** Silent reading speed used for reading time (words per minute). */
|
|
13
|
+
export declare const READING_WORDS_PER_MINUTE = 238;
|
|
14
|
+
/** Line-height browsers use for `normal` with most fonts, assumed when none is given. */
|
|
15
|
+
export declare const ASSUMED_NORMAL_LINE_HEIGHT = 1.2;
|
|
16
|
+
/** Estimated characters per line for a container width (px) at a font size, from average glyph widths. */
|
|
17
|
+
export declare function estimateCharactersPerLine(width: number, font: {
|
|
18
|
+
size: number;
|
|
19
|
+
category?: FontCategory;
|
|
20
|
+
letterSpacing?: number;
|
|
21
|
+
}): number;
|
|
22
|
+
export interface ReadabilityOptions extends Partial<FontSpec> {
|
|
23
|
+
/** Container width in px; when given with `size`, line length is estimated from it instead of the text's own line breaks. */
|
|
24
|
+
width?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Audits body text: line length against 45–75 characters, line spacing against 1.5, text set in
|
|
28
|
+
* capitals, and reading time. Line length comes from the text's own lines, or from `width` and
|
|
29
|
+
* `size` when both are given.
|
|
30
|
+
*/
|
|
31
|
+
export declare function auditTextReadability(text: string, font?: ReadabilityOptions): ReadabilityAuditResult;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measure (line length), line spacing and other readability checks for body text.
|
|
3
|
+
*/
|
|
4
|
+
import type { FontCategory, FontSpec, ReadabilityAuditResult } from './types.js';
|
|
5
|
+
/** Comfortable measure for body text, in characters per line. */
|
|
6
|
+
export declare const OPTIMAL_MEASURE: {
|
|
7
|
+
readonly min: 45;
|
|
8
|
+
readonly max: 75;
|
|
9
|
+
};
|
|
10
|
+
/** WCAG 1.4.8 (AAA) line spacing and the WCAG 1.4.12 test value: 1.5× the font size. */
|
|
11
|
+
export declare const RECOMMENDED_LINE_HEIGHT = 1.5;
|
|
12
|
+
/** Silent reading speed used for reading time (words per minute). */
|
|
13
|
+
export declare const READING_WORDS_PER_MINUTE = 238;
|
|
14
|
+
/** Line-height browsers use for `normal` with most fonts, assumed when none is given. */
|
|
15
|
+
export declare const ASSUMED_NORMAL_LINE_HEIGHT = 1.2;
|
|
16
|
+
/** Estimated characters per line for a container width (px) at a font size, from average glyph widths. */
|
|
17
|
+
export declare function estimateCharactersPerLine(width: number, font: {
|
|
18
|
+
size: number;
|
|
19
|
+
category?: FontCategory;
|
|
20
|
+
letterSpacing?: number;
|
|
21
|
+
}): number;
|
|
22
|
+
export interface ReadabilityOptions extends Partial<FontSpec> {
|
|
23
|
+
/** Container width in px; when given with `size`, line length is estimated from it instead of the text's own line breaks. */
|
|
24
|
+
width?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Audits body text: line length against 45–75 characters, line spacing against 1.5, text set in
|
|
28
|
+
* capitals, and reading time. Line length comes from the text's own lines, or from `width` and
|
|
29
|
+
* `size` when both are given.
|
|
30
|
+
*/
|
|
31
|
+
export declare function auditTextReadability(text: string, font?: ReadabilityOptions): ReadabilityAuditResult;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless font picker model shared by the React and Svelte bindings: the selected family, weight,
|
|
3
|
+
* style and metrics, category filter and search, recent families, highlight navigation for a
|
|
4
|
+
* combobox, and per-family load status. DOM-free.
|
|
5
|
+
*/
|
|
6
|
+
import { type FontProvider, type FontSummary } from './registry.cjs';
|
|
7
|
+
import type { FontCategory, FontSpec, FontStyle, FontWeight, NumericFontWeight } from './types.cjs';
|
|
8
|
+
export type FontLoadStatus = 'idle' | 'loading' | 'loaded' | 'failed';
|
|
9
|
+
export interface FontPickerState {
|
|
10
|
+
/** The selected value. */
|
|
11
|
+
value: Required<Pick<FontSpec, 'family' | 'size' | 'style' | 'lineHeight' | 'letterSpacing'>> & {
|
|
12
|
+
weight: NumericFontWeight;
|
|
13
|
+
category?: FontCategory;
|
|
14
|
+
};
|
|
15
|
+
/** Category filter (`all` for none). */
|
|
16
|
+
category: FontCategory | 'all';
|
|
17
|
+
query: string;
|
|
18
|
+
/** Every font the picker knows. */
|
|
19
|
+
fonts: readonly FontSummary[];
|
|
20
|
+
/** `fonts` after the category filter and search. */
|
|
21
|
+
results: readonly FontSummary[];
|
|
22
|
+
/** Recently chosen families that are still in `fonts`, newest first. */
|
|
23
|
+
recent: readonly FontSummary[];
|
|
24
|
+
/** Index into `results` of the highlighted option (-1 for none). */
|
|
25
|
+
highlighted: number;
|
|
26
|
+
previewText: string;
|
|
27
|
+
/** Whether `fonts` is being fetched from the provider. */
|
|
28
|
+
loading: boolean;
|
|
29
|
+
/** Provider error message from the last refresh. */
|
|
30
|
+
error?: string;
|
|
31
|
+
/** Load status of each family's preview face, by lower-cased family. */
|
|
32
|
+
loadStatus: Readonly<Record<string, FontLoadStatus>>;
|
|
33
|
+
}
|
|
34
|
+
export interface FontPickerOptions {
|
|
35
|
+
/** Where fonts come from. Without one, pass `fonts`. */
|
|
36
|
+
provider?: FontProvider;
|
|
37
|
+
/** A fixed list (used until `refresh()` replaces it from the provider). */
|
|
38
|
+
fonts?: readonly FontSummary[];
|
|
39
|
+
/** Initial value. Default: the first font at 16px. */
|
|
40
|
+
value?: Partial<FontSpec>;
|
|
41
|
+
/** Initial recent families, newest first. */
|
|
42
|
+
recent?: readonly string[];
|
|
43
|
+
/** Most recent families kept (default 8). */
|
|
44
|
+
maxRecent?: number;
|
|
45
|
+
previewText?: string;
|
|
46
|
+
/** Load a family's face through the provider when it is selected (default true). */
|
|
47
|
+
loadOnSelect?: boolean;
|
|
48
|
+
/** Called whenever the value changes (not on filter or search changes). */
|
|
49
|
+
onChange?: (value: FontSpec) => void;
|
|
50
|
+
}
|
|
51
|
+
/** Weights a font offers (every weight in range for a variable font; all nine when unknown). */
|
|
52
|
+
export declare function offeredWeights(font: FontSummary | undefined): NumericFontWeight[];
|
|
53
|
+
export declare const DEFAULT_PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog";
|
|
54
|
+
export declare class FontPickerModel {
|
|
55
|
+
private state;
|
|
56
|
+
private readonly listeners;
|
|
57
|
+
private readonly valueListeners;
|
|
58
|
+
private recentFamilies;
|
|
59
|
+
private destroyed;
|
|
60
|
+
readonly provider?: FontProvider;
|
|
61
|
+
private readonly maxRecent;
|
|
62
|
+
private readonly loadOnSelect;
|
|
63
|
+
private readonly onChange?;
|
|
64
|
+
constructor(options?: FontPickerOptions);
|
|
65
|
+
/** The current state. The same object is returned until something changes. */
|
|
66
|
+
getState: () => FontPickerState;
|
|
67
|
+
/** Calls `listener` after every change; returns an unsubscribe function. */
|
|
68
|
+
subscribe: (listener: (state: FontPickerState) => void) => (() => void);
|
|
69
|
+
/**
|
|
70
|
+
* Calls `listener` when the value changes through the picker or its agent tools (not through
|
|
71
|
+
* `setValue`, so a controlled component does not echo its own updates). Returns an unsubscribe.
|
|
72
|
+
*/
|
|
73
|
+
onValueChange: (listener: (value: FontSpec) => void) => (() => void);
|
|
74
|
+
/** The selected value as a {@link FontSpec}. */
|
|
75
|
+
get value(): FontSpec;
|
|
76
|
+
/** The selected family's summary, if it is in `fonts`. */
|
|
77
|
+
get selectedFont(): FontSummary | undefined;
|
|
78
|
+
/** Weights the selected family offers (all nine when unknown or variable). */
|
|
79
|
+
get availableWeights(): NumericFontWeight[];
|
|
80
|
+
/** Styles the selected family offers (`normal` when unknown). */
|
|
81
|
+
get availableStyles(): FontStyle[];
|
|
82
|
+
/** CSS for the selection: a fallback-resolved `font-family` plus the other properties. */
|
|
83
|
+
get css(): {
|
|
84
|
+
fontFamily: string;
|
|
85
|
+
fontWeight: string;
|
|
86
|
+
fontStyle: string;
|
|
87
|
+
fontSize: string;
|
|
88
|
+
lineHeight: string;
|
|
89
|
+
letterSpacing: string;
|
|
90
|
+
};
|
|
91
|
+
/** A `font-family` value for previewing any family in a list. */
|
|
92
|
+
familyCss(font: FontSummary | string): string;
|
|
93
|
+
/** Fetches fonts from the provider. Keeps the current list when it fails. */
|
|
94
|
+
refresh(): Promise<readonly FontSummary[]>;
|
|
95
|
+
setQuery(query: string): void;
|
|
96
|
+
setCategory(category: FontCategory | 'all'): void;
|
|
97
|
+
setPreviewText(previewText: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Selects a family. Throws when `fonts` is non-empty and does not list it. Keeps the weight if
|
|
100
|
+
* the family has it, else picks the nearest one; keeps the style if offered, else `normal`.
|
|
101
|
+
*/
|
|
102
|
+
selectFamily(family: string): void;
|
|
103
|
+
/** Sets the weight; snaps to the nearest weight the family offers. */
|
|
104
|
+
setWeight(weight: FontWeight | number): void;
|
|
105
|
+
setStyle(style: FontStyle): void;
|
|
106
|
+
/** Font size in px, clamped to 1–1000. */
|
|
107
|
+
setSize(size: number): void;
|
|
108
|
+
/** Unitless line-height, clamped to 0.5–4. */
|
|
109
|
+
setLineHeight(lineHeight: number): void;
|
|
110
|
+
/** Tracking in em, clamped to -0.5–1. */
|
|
111
|
+
setLetterSpacing(letterSpacing: number): void;
|
|
112
|
+
/** Replaces the value (for controlled components). Does not call `onChange` or touch recents. */
|
|
113
|
+
setValue(value: Partial<FontSpec>): void;
|
|
114
|
+
/** Moves the highlight through `results` (wraps around). */
|
|
115
|
+
moveHighlight(delta: number): void;
|
|
116
|
+
setHighlight(index: number): void;
|
|
117
|
+
/** Selects the highlighted result. Returns whether there was one. */
|
|
118
|
+
commitHighlight(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Handles combobox keys (ArrowDown/ArrowUp/Home/End/Enter/Escape). Returns whether the key was
|
|
121
|
+
* handled, so the caller can `preventDefault`.
|
|
122
|
+
*/
|
|
123
|
+
handleKey(key: string): boolean;
|
|
124
|
+
/** Loads a family's face through the provider (for previews) and tracks its status. */
|
|
125
|
+
loadFamily(family: string, weight?: FontWeight, style?: FontStyle): Promise<boolean>;
|
|
126
|
+
destroy(): void;
|
|
127
|
+
private commit;
|
|
128
|
+
private derive;
|
|
129
|
+
private set;
|
|
130
|
+
}
|
|
131
|
+
/** Creates a {@link FontPickerModel}. */
|
|
132
|
+
export declare function createFontPicker(options?: FontPickerOptions): FontPickerModel;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless font picker model shared by the React and Svelte bindings: the selected family, weight,
|
|
3
|
+
* style and metrics, category filter and search, recent families, highlight navigation for a
|
|
4
|
+
* combobox, and per-family load status. DOM-free.
|
|
5
|
+
*/
|
|
6
|
+
import { type FontProvider, type FontSummary } from './registry.js';
|
|
7
|
+
import type { FontCategory, FontSpec, FontStyle, FontWeight, NumericFontWeight } from './types.js';
|
|
8
|
+
export type FontLoadStatus = 'idle' | 'loading' | 'loaded' | 'failed';
|
|
9
|
+
export interface FontPickerState {
|
|
10
|
+
/** The selected value. */
|
|
11
|
+
value: Required<Pick<FontSpec, 'family' | 'size' | 'style' | 'lineHeight' | 'letterSpacing'>> & {
|
|
12
|
+
weight: NumericFontWeight;
|
|
13
|
+
category?: FontCategory;
|
|
14
|
+
};
|
|
15
|
+
/** Category filter (`all` for none). */
|
|
16
|
+
category: FontCategory | 'all';
|
|
17
|
+
query: string;
|
|
18
|
+
/** Every font the picker knows. */
|
|
19
|
+
fonts: readonly FontSummary[];
|
|
20
|
+
/** `fonts` after the category filter and search. */
|
|
21
|
+
results: readonly FontSummary[];
|
|
22
|
+
/** Recently chosen families that are still in `fonts`, newest first. */
|
|
23
|
+
recent: readonly FontSummary[];
|
|
24
|
+
/** Index into `results` of the highlighted option (-1 for none). */
|
|
25
|
+
highlighted: number;
|
|
26
|
+
previewText: string;
|
|
27
|
+
/** Whether `fonts` is being fetched from the provider. */
|
|
28
|
+
loading: boolean;
|
|
29
|
+
/** Provider error message from the last refresh. */
|
|
30
|
+
error?: string;
|
|
31
|
+
/** Load status of each family's preview face, by lower-cased family. */
|
|
32
|
+
loadStatus: Readonly<Record<string, FontLoadStatus>>;
|
|
33
|
+
}
|
|
34
|
+
export interface FontPickerOptions {
|
|
35
|
+
/** Where fonts come from. Without one, pass `fonts`. */
|
|
36
|
+
provider?: FontProvider;
|
|
37
|
+
/** A fixed list (used until `refresh()` replaces it from the provider). */
|
|
38
|
+
fonts?: readonly FontSummary[];
|
|
39
|
+
/** Initial value. Default: the first font at 16px. */
|
|
40
|
+
value?: Partial<FontSpec>;
|
|
41
|
+
/** Initial recent families, newest first. */
|
|
42
|
+
recent?: readonly string[];
|
|
43
|
+
/** Most recent families kept (default 8). */
|
|
44
|
+
maxRecent?: number;
|
|
45
|
+
previewText?: string;
|
|
46
|
+
/** Load a family's face through the provider when it is selected (default true). */
|
|
47
|
+
loadOnSelect?: boolean;
|
|
48
|
+
/** Called whenever the value changes (not on filter or search changes). */
|
|
49
|
+
onChange?: (value: FontSpec) => void;
|
|
50
|
+
}
|
|
51
|
+
/** Weights a font offers (every weight in range for a variable font; all nine when unknown). */
|
|
52
|
+
export declare function offeredWeights(font: FontSummary | undefined): NumericFontWeight[];
|
|
53
|
+
export declare const DEFAULT_PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog";
|
|
54
|
+
export declare class FontPickerModel {
|
|
55
|
+
private state;
|
|
56
|
+
private readonly listeners;
|
|
57
|
+
private readonly valueListeners;
|
|
58
|
+
private recentFamilies;
|
|
59
|
+
private destroyed;
|
|
60
|
+
readonly provider?: FontProvider;
|
|
61
|
+
private readonly maxRecent;
|
|
62
|
+
private readonly loadOnSelect;
|
|
63
|
+
private readonly onChange?;
|
|
64
|
+
constructor(options?: FontPickerOptions);
|
|
65
|
+
/** The current state. The same object is returned until something changes. */
|
|
66
|
+
getState: () => FontPickerState;
|
|
67
|
+
/** Calls `listener` after every change; returns an unsubscribe function. */
|
|
68
|
+
subscribe: (listener: (state: FontPickerState) => void) => (() => void);
|
|
69
|
+
/**
|
|
70
|
+
* Calls `listener` when the value changes through the picker or its agent tools (not through
|
|
71
|
+
* `setValue`, so a controlled component does not echo its own updates). Returns an unsubscribe.
|
|
72
|
+
*/
|
|
73
|
+
onValueChange: (listener: (value: FontSpec) => void) => (() => void);
|
|
74
|
+
/** The selected value as a {@link FontSpec}. */
|
|
75
|
+
get value(): FontSpec;
|
|
76
|
+
/** The selected family's summary, if it is in `fonts`. */
|
|
77
|
+
get selectedFont(): FontSummary | undefined;
|
|
78
|
+
/** Weights the selected family offers (all nine when unknown or variable). */
|
|
79
|
+
get availableWeights(): NumericFontWeight[];
|
|
80
|
+
/** Styles the selected family offers (`normal` when unknown). */
|
|
81
|
+
get availableStyles(): FontStyle[];
|
|
82
|
+
/** CSS for the selection: a fallback-resolved `font-family` plus the other properties. */
|
|
83
|
+
get css(): {
|
|
84
|
+
fontFamily: string;
|
|
85
|
+
fontWeight: string;
|
|
86
|
+
fontStyle: string;
|
|
87
|
+
fontSize: string;
|
|
88
|
+
lineHeight: string;
|
|
89
|
+
letterSpacing: string;
|
|
90
|
+
};
|
|
91
|
+
/** A `font-family` value for previewing any family in a list. */
|
|
92
|
+
familyCss(font: FontSummary | string): string;
|
|
93
|
+
/** Fetches fonts from the provider. Keeps the current list when it fails. */
|
|
94
|
+
refresh(): Promise<readonly FontSummary[]>;
|
|
95
|
+
setQuery(query: string): void;
|
|
96
|
+
setCategory(category: FontCategory | 'all'): void;
|
|
97
|
+
setPreviewText(previewText: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Selects a family. Throws when `fonts` is non-empty and does not list it. Keeps the weight if
|
|
100
|
+
* the family has it, else picks the nearest one; keeps the style if offered, else `normal`.
|
|
101
|
+
*/
|
|
102
|
+
selectFamily(family: string): void;
|
|
103
|
+
/** Sets the weight; snaps to the nearest weight the family offers. */
|
|
104
|
+
setWeight(weight: FontWeight | number): void;
|
|
105
|
+
setStyle(style: FontStyle): void;
|
|
106
|
+
/** Font size in px, clamped to 1–1000. */
|
|
107
|
+
setSize(size: number): void;
|
|
108
|
+
/** Unitless line-height, clamped to 0.5–4. */
|
|
109
|
+
setLineHeight(lineHeight: number): void;
|
|
110
|
+
/** Tracking in em, clamped to -0.5–1. */
|
|
111
|
+
setLetterSpacing(letterSpacing: number): void;
|
|
112
|
+
/** Replaces the value (for controlled components). Does not call `onChange` or touch recents. */
|
|
113
|
+
setValue(value: Partial<FontSpec>): void;
|
|
114
|
+
/** Moves the highlight through `results` (wraps around). */
|
|
115
|
+
moveHighlight(delta: number): void;
|
|
116
|
+
setHighlight(index: number): void;
|
|
117
|
+
/** Selects the highlighted result. Returns whether there was one. */
|
|
118
|
+
commitHighlight(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Handles combobox keys (ArrowDown/ArrowUp/Home/End/Enter/Escape). Returns whether the key was
|
|
121
|
+
* handled, so the caller can `preventDefault`.
|
|
122
|
+
*/
|
|
123
|
+
handleKey(key: string): boolean;
|
|
124
|
+
/** Loads a family's face through the provider (for previews) and tracks its status. */
|
|
125
|
+
loadFamily(family: string, weight?: FontWeight, style?: FontStyle): Promise<boolean>;
|
|
126
|
+
destroy(): void;
|
|
127
|
+
private commit;
|
|
128
|
+
private derive;
|
|
129
|
+
private set;
|
|
130
|
+
}
|
|
131
|
+
/** Creates a {@link FontPickerModel}. */
|
|
132
|
+
export declare function createFontPicker(options?: FontPickerOptions): FontPickerModel;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable font providers: the interface hosts implement (system fonts, a web font service, a
|
|
3
|
+
* design system's own families), filtering, and a combinator that merges several providers.
|
|
4
|
+
*/
|
|
5
|
+
import type { FontCategory, FontSource, FontStyle, FontWeight } from './types.cjs';
|
|
6
|
+
export type FontPlatform = 'macos' | 'windows' | 'ios' | 'android' | 'linux';
|
|
7
|
+
export interface FontSummary {
|
|
8
|
+
family: string;
|
|
9
|
+
category: FontCategory;
|
|
10
|
+
weights: FontWeight[];
|
|
11
|
+
styles: FontStyle[];
|
|
12
|
+
/** A variable font: any weight between the lowest and highest in `weights` works. */
|
|
13
|
+
isVariable?: boolean;
|
|
14
|
+
source: FontSource;
|
|
15
|
+
/** Platforms that ship it, for system fonts. */
|
|
16
|
+
platforms?: FontPlatform[];
|
|
17
|
+
}
|
|
18
|
+
export interface FontProvider {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
/** Every font the provider offers. */
|
|
21
|
+
listFonts(): Promise<FontSummary[]>;
|
|
22
|
+
/** Whether the provider offers (system) or has loaded (web) the family. */
|
|
23
|
+
hasFont(family: string): boolean | Promise<boolean>;
|
|
24
|
+
/** Makes a face usable for rendering; resolves `true` when it is ready, `false` when it cannot be loaded. */
|
|
25
|
+
loadFont?(family: string, weight?: FontWeight, style?: FontStyle): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export interface FontFilter {
|
|
28
|
+
category?: FontCategory;
|
|
29
|
+
source?: FontSource;
|
|
30
|
+
/** Keep fonts that offer this weight (variable fonts: within their range). */
|
|
31
|
+
weight?: FontWeight;
|
|
32
|
+
style?: FontStyle;
|
|
33
|
+
/** Case-insensitive substring of the family name. */
|
|
34
|
+
query?: string;
|
|
35
|
+
isVariable?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Whether a font offers a weight (variable fonts offer every weight in their range). */
|
|
38
|
+
export declare function fontHasWeight(font: FontSummary, weight: FontWeight): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Filters fonts. With a `query`, families that start with it come first, then the rest that
|
|
41
|
+
* contain it; otherwise the order is kept.
|
|
42
|
+
*/
|
|
43
|
+
export declare function filterFonts(fonts: readonly FontSummary[], filter?: FontFilter): FontSummary[];
|
|
44
|
+
/** Finds a family by name, case-insensitively. */
|
|
45
|
+
export declare function findFont(fonts: readonly FontSummary[], family: string): FontSummary | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* One provider over several: fonts are merged by family (case-insensitive; the first provider
|
|
48
|
+
* that lists a family wins), `hasFont` asks each in turn, and `loadFont` uses the first
|
|
49
|
+
* provider that lists the family and can load.
|
|
50
|
+
*/
|
|
51
|
+
export declare function combineFontProviders(providers: readonly FontProvider[], options?: {
|
|
52
|
+
id?: string;
|
|
53
|
+
}): FontProvider;
|
|
54
|
+
export interface EnsureFontsResult {
|
|
55
|
+
loaded: string[];
|
|
56
|
+
failed: string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Loads every face a set of specs needs before rendering (for example before rasterising a title
|
|
60
|
+
* preview, so the first frame does not use a fallback font). Duplicates are loaded once.
|
|
61
|
+
*/
|
|
62
|
+
export declare function ensureFontsLoaded(provider: FontProvider, specs: ReadonlyArray<{
|
|
63
|
+
family: string;
|
|
64
|
+
weight?: FontWeight;
|
|
65
|
+
style?: FontStyle;
|
|
66
|
+
}>): Promise<EnsureFontsResult>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable font providers: the interface hosts implement (system fonts, a web font service, a
|
|
3
|
+
* design system's own families), filtering, and a combinator that merges several providers.
|
|
4
|
+
*/
|
|
5
|
+
import type { FontCategory, FontSource, FontStyle, FontWeight } from './types.js';
|
|
6
|
+
export type FontPlatform = 'macos' | 'windows' | 'ios' | 'android' | 'linux';
|
|
7
|
+
export interface FontSummary {
|
|
8
|
+
family: string;
|
|
9
|
+
category: FontCategory;
|
|
10
|
+
weights: FontWeight[];
|
|
11
|
+
styles: FontStyle[];
|
|
12
|
+
/** A variable font: any weight between the lowest and highest in `weights` works. */
|
|
13
|
+
isVariable?: boolean;
|
|
14
|
+
source: FontSource;
|
|
15
|
+
/** Platforms that ship it, for system fonts. */
|
|
16
|
+
platforms?: FontPlatform[];
|
|
17
|
+
}
|
|
18
|
+
export interface FontProvider {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
/** Every font the provider offers. */
|
|
21
|
+
listFonts(): Promise<FontSummary[]>;
|
|
22
|
+
/** Whether the provider offers (system) or has loaded (web) the family. */
|
|
23
|
+
hasFont(family: string): boolean | Promise<boolean>;
|
|
24
|
+
/** Makes a face usable for rendering; resolves `true` when it is ready, `false` when it cannot be loaded. */
|
|
25
|
+
loadFont?(family: string, weight?: FontWeight, style?: FontStyle): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export interface FontFilter {
|
|
28
|
+
category?: FontCategory;
|
|
29
|
+
source?: FontSource;
|
|
30
|
+
/** Keep fonts that offer this weight (variable fonts: within their range). */
|
|
31
|
+
weight?: FontWeight;
|
|
32
|
+
style?: FontStyle;
|
|
33
|
+
/** Case-insensitive substring of the family name. */
|
|
34
|
+
query?: string;
|
|
35
|
+
isVariable?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Whether a font offers a weight (variable fonts offer every weight in their range). */
|
|
38
|
+
export declare function fontHasWeight(font: FontSummary, weight: FontWeight): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Filters fonts. With a `query`, families that start with it come first, then the rest that
|
|
41
|
+
* contain it; otherwise the order is kept.
|
|
42
|
+
*/
|
|
43
|
+
export declare function filterFonts(fonts: readonly FontSummary[], filter?: FontFilter): FontSummary[];
|
|
44
|
+
/** Finds a family by name, case-insensitively. */
|
|
45
|
+
export declare function findFont(fonts: readonly FontSummary[], family: string): FontSummary | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* One provider over several: fonts are merged by family (case-insensitive; the first provider
|
|
48
|
+
* that lists a family wins), `hasFont` asks each in turn, and `loadFont` uses the first
|
|
49
|
+
* provider that lists the family and can load.
|
|
50
|
+
*/
|
|
51
|
+
export declare function combineFontProviders(providers: readonly FontProvider[], options?: {
|
|
52
|
+
id?: string;
|
|
53
|
+
}): FontProvider;
|
|
54
|
+
export interface EnsureFontsResult {
|
|
55
|
+
loaded: string[];
|
|
56
|
+
failed: string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Loads every face a set of specs needs before rendering (for example before rasterising a title
|
|
60
|
+
* preview, so the first frame does not use a fallback font). Duplicates are loaded once.
|
|
61
|
+
*/
|
|
62
|
+
export declare function ensureFontsLoaded(provider: FontProvider, specs: ReadonlyArray<{
|
|
63
|
+
family: string;
|
|
64
|
+
weight?: FontWeight;
|
|
65
|
+
style?: FontStyle;
|
|
66
|
+
}>): Promise<EnsureFontsResult>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modular type scales, a standard heading-to-caption hierarchy, and fluid (viewport-scaled) sizes.
|
|
3
|
+
*/
|
|
4
|
+
import type { ModularScaleRatio, TypeHierarchy, TypeScaleStep } from './types.cjs';
|
|
5
|
+
/** The named ratios and their values. */
|
|
6
|
+
export declare const MODULAR_SCALE_RATIOS: Readonly<Record<ModularScaleRatio, number>>;
|
|
7
|
+
export declare const MODULAR_SCALE_RATIO_NAMES: ModularScaleRatio[];
|
|
8
|
+
/** Token names of the standard hierarchy, by step (caption −2 … display 5). */
|
|
9
|
+
export declare const TYPE_HIERARCHY_STEPS: Readonly<Record<string, number>>;
|
|
10
|
+
/** The value of a named ratio. Throws for an unknown name. */
|
|
11
|
+
export declare function getScaleRatio(name: ModularScaleRatio): number;
|
|
12
|
+
/** A ratio as a number: named ratios are looked up, numbers must be above 1 and at most 4. */
|
|
13
|
+
export declare function resolveScaleRatio(ratio: number | ModularScaleRatio): number;
|
|
14
|
+
/**
|
|
15
|
+
* Recommended unitless line-height for a size: 1.5 up to 16px (body text, WCAG 1.4.8), easing
|
|
16
|
+
* to 1.1 at 64px and above (display type), in steps of 0.05.
|
|
17
|
+
*/
|
|
18
|
+
export declare function recommendedLineHeight(size: number): number;
|
|
19
|
+
/** Recommended tracking in em: looser for small text, tighter for large headings. */
|
|
20
|
+
export declare function recommendedLetterSpacing(size: number): number;
|
|
21
|
+
/** One step of a scale: `baseSize × ratio^step`, with recommended line-height and tracking. */
|
|
22
|
+
export declare function typeScaleStep(baseSize: number, ratio: number, step: number, name?: string): TypeScaleStep;
|
|
23
|
+
/** A modular scale: one {@link TypeScaleStep} per requested step, in the order given. */
|
|
24
|
+
export declare function computeTypeScale(baseSize: number, ratio: number | ModularScaleRatio, steps?: readonly number[]): TypeScaleStep[];
|
|
25
|
+
/** Tokens `caption`, `body-sm`, `body`, `h4`, `h3`, `h2`, `h1` and `display` on one modular scale. */
|
|
26
|
+
export declare function generateTypeHierarchy(options?: {
|
|
27
|
+
baseSize?: number;
|
|
28
|
+
ratio?: ModularScaleRatio | number;
|
|
29
|
+
}): TypeHierarchy;
|
|
30
|
+
/**
|
|
31
|
+
* CSS custom properties for a hierarchy: `--<prefix>-<name>-size` (rem), `-line-height` and
|
|
32
|
+
* `-letter-spacing` (em) per token, inside `selector` (default `:root`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function typeHierarchyToCss(hierarchy: TypeHierarchy, options?: {
|
|
35
|
+
prefix?: string;
|
|
36
|
+
selector?: string;
|
|
37
|
+
rootFontSize?: number;
|
|
38
|
+
}): string;
|
|
39
|
+
export interface FluidSizeOptions {
|
|
40
|
+
/** Size in px at `minViewport` and below. */
|
|
41
|
+
minSize: number;
|
|
42
|
+
/** Size in px at `maxViewport` and above. */
|
|
43
|
+
maxSize: number;
|
|
44
|
+
/** Viewport width in px where scaling starts. */
|
|
45
|
+
minViewport: number;
|
|
46
|
+
/** Viewport width in px where scaling stops. */
|
|
47
|
+
maxViewport: number;
|
|
48
|
+
/** Root font size in px used to express rem values (default 16). */
|
|
49
|
+
rootFontSize?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface FluidSize {
|
|
52
|
+
/** `clamp(min, intercept + slope·vw, max)` with rem bounds, so user zoom and font settings still apply. */
|
|
53
|
+
clampCss: string;
|
|
54
|
+
/** Growth per viewport px (px of font per px of viewport). */
|
|
55
|
+
slope: number;
|
|
56
|
+
/** Intercept in px (the size the linear part gives at a zero-width viewport). */
|
|
57
|
+
intercept: number;
|
|
58
|
+
/** The size in px at a viewport width. */
|
|
59
|
+
evaluateAt: (viewport: number) => number;
|
|
60
|
+
}
|
|
61
|
+
/** A size that scales linearly with the viewport between two widths, as a CSS `clamp()`. */
|
|
62
|
+
export declare function computeFluidSize(options: FluidSizeOptions): FluidSize;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modular type scales, a standard heading-to-caption hierarchy, and fluid (viewport-scaled) sizes.
|
|
3
|
+
*/
|
|
4
|
+
import type { ModularScaleRatio, TypeHierarchy, TypeScaleStep } from './types.js';
|
|
5
|
+
/** The named ratios and their values. */
|
|
6
|
+
export declare const MODULAR_SCALE_RATIOS: Readonly<Record<ModularScaleRatio, number>>;
|
|
7
|
+
export declare const MODULAR_SCALE_RATIO_NAMES: ModularScaleRatio[];
|
|
8
|
+
/** Token names of the standard hierarchy, by step (caption −2 … display 5). */
|
|
9
|
+
export declare const TYPE_HIERARCHY_STEPS: Readonly<Record<string, number>>;
|
|
10
|
+
/** The value of a named ratio. Throws for an unknown name. */
|
|
11
|
+
export declare function getScaleRatio(name: ModularScaleRatio): number;
|
|
12
|
+
/** A ratio as a number: named ratios are looked up, numbers must be above 1 and at most 4. */
|
|
13
|
+
export declare function resolveScaleRatio(ratio: number | ModularScaleRatio): number;
|
|
14
|
+
/**
|
|
15
|
+
* Recommended unitless line-height for a size: 1.5 up to 16px (body text, WCAG 1.4.8), easing
|
|
16
|
+
* to 1.1 at 64px and above (display type), in steps of 0.05.
|
|
17
|
+
*/
|
|
18
|
+
export declare function recommendedLineHeight(size: number): number;
|
|
19
|
+
/** Recommended tracking in em: looser for small text, tighter for large headings. */
|
|
20
|
+
export declare function recommendedLetterSpacing(size: number): number;
|
|
21
|
+
/** One step of a scale: `baseSize × ratio^step`, with recommended line-height and tracking. */
|
|
22
|
+
export declare function typeScaleStep(baseSize: number, ratio: number, step: number, name?: string): TypeScaleStep;
|
|
23
|
+
/** A modular scale: one {@link TypeScaleStep} per requested step, in the order given. */
|
|
24
|
+
export declare function computeTypeScale(baseSize: number, ratio: number | ModularScaleRatio, steps?: readonly number[]): TypeScaleStep[];
|
|
25
|
+
/** Tokens `caption`, `body-sm`, `body`, `h4`, `h3`, `h2`, `h1` and `display` on one modular scale. */
|
|
26
|
+
export declare function generateTypeHierarchy(options?: {
|
|
27
|
+
baseSize?: number;
|
|
28
|
+
ratio?: ModularScaleRatio | number;
|
|
29
|
+
}): TypeHierarchy;
|
|
30
|
+
/**
|
|
31
|
+
* CSS custom properties for a hierarchy: `--<prefix>-<name>-size` (rem), `-line-height` and
|
|
32
|
+
* `-letter-spacing` (em) per token, inside `selector` (default `:root`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function typeHierarchyToCss(hierarchy: TypeHierarchy, options?: {
|
|
35
|
+
prefix?: string;
|
|
36
|
+
selector?: string;
|
|
37
|
+
rootFontSize?: number;
|
|
38
|
+
}): string;
|
|
39
|
+
export interface FluidSizeOptions {
|
|
40
|
+
/** Size in px at `minViewport` and below. */
|
|
41
|
+
minSize: number;
|
|
42
|
+
/** Size in px at `maxViewport` and above. */
|
|
43
|
+
maxSize: number;
|
|
44
|
+
/** Viewport width in px where scaling starts. */
|
|
45
|
+
minViewport: number;
|
|
46
|
+
/** Viewport width in px where scaling stops. */
|
|
47
|
+
maxViewport: number;
|
|
48
|
+
/** Root font size in px used to express rem values (default 16). */
|
|
49
|
+
rootFontSize?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface FluidSize {
|
|
52
|
+
/** `clamp(min, intercept + slope·vw, max)` with rem bounds, so user zoom and font settings still apply. */
|
|
53
|
+
clampCss: string;
|
|
54
|
+
/** Growth per viewport px (px of font per px of viewport). */
|
|
55
|
+
slope: number;
|
|
56
|
+
/** Intercept in px (the size the linear part gives at a zero-width viewport). */
|
|
57
|
+
intercept: number;
|
|
58
|
+
/** The size in px at a viewport width. */
|
|
59
|
+
evaluateAt: (viewport: number) => number;
|
|
60
|
+
}
|
|
61
|
+
/** A size that scales linearly with the viewport between two widths, as a CSS `clamp()`. */
|
|
62
|
+
export declare function computeFluidSize(options: FluidSizeOptions): FluidSize;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-agnostic text segmentation (graphemes, words, sentences, lines) with UTF-16 offsets, so
|
|
3
|
+
* live text can be split for staggered animation without converting it to outlines.
|
|
4
|
+
*/
|
|
5
|
+
import type { SegmentGranularity, TextSegment } from './types.cjs';
|
|
6
|
+
export interface SegmentTextOptions {
|
|
7
|
+
/** BCP 47 locale for `Intl.Segmenter` (default: the runtime's). */
|
|
8
|
+
locale?: string;
|
|
9
|
+
/** For `word`: return only word-like segments, dropping white space and punctuation (default false). */
|
|
10
|
+
wordsOnly?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* For `line`: wrap each hard line greedily at word boundaries so no line exceeds this many
|
|
13
|
+
* characters (a word longer than that gets a line of its own). Omit to split on line breaks only.
|
|
14
|
+
*/
|
|
15
|
+
maxCharacters?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Grapheme clusters as strings (falls back to code points without `Intl.Segmenter`). */
|
|
18
|
+
export declare function graphemes(text: string, locale?: string): string[];
|
|
19
|
+
/** Number of user-perceived characters (grapheme clusters). */
|
|
20
|
+
export declare function countGraphemes(text: string, locale?: string): number;
|
|
21
|
+
/**
|
|
22
|
+
* Splits text into graphemes, words, sentences or lines. Offsets are UTF-16 indexes into `text`,
|
|
23
|
+
* so `text.slice(start, end) === segment.text`. `line` splits on line breaks (and wraps when
|
|
24
|
+
* `maxCharacters` is set); it cannot know how a renderer will wrap without a measure.
|
|
25
|
+
*/
|
|
26
|
+
export declare function segmentText(text: string, granularity: SegmentGranularity, options?: SegmentTextOptions): TextSegment[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-agnostic text segmentation (graphemes, words, sentences, lines) with UTF-16 offsets, so
|
|
3
|
+
* live text can be split for staggered animation without converting it to outlines.
|
|
4
|
+
*/
|
|
5
|
+
import type { SegmentGranularity, TextSegment } from './types.js';
|
|
6
|
+
export interface SegmentTextOptions {
|
|
7
|
+
/** BCP 47 locale for `Intl.Segmenter` (default: the runtime's). */
|
|
8
|
+
locale?: string;
|
|
9
|
+
/** For `word`: return only word-like segments, dropping white space and punctuation (default false). */
|
|
10
|
+
wordsOnly?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* For `line`: wrap each hard line greedily at word boundaries so no line exceeds this many
|
|
13
|
+
* characters (a word longer than that gets a line of its own). Omit to split on line breaks only.
|
|
14
|
+
*/
|
|
15
|
+
maxCharacters?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Grapheme clusters as strings (falls back to code points without `Intl.Segmenter`). */
|
|
18
|
+
export declare function graphemes(text: string, locale?: string): string[];
|
|
19
|
+
/** Number of user-perceived characters (grapheme clusters). */
|
|
20
|
+
export declare function countGraphemes(text: string, locale?: string): number;
|
|
21
|
+
/**
|
|
22
|
+
* Splits text into graphemes, words, sentences or lines. Offsets are UTF-16 indexes into `text`,
|
|
23
|
+
* so `text.slice(start, end) === segment.text`. `line` splits on line breaks (and wraps when
|
|
24
|
+
* `maxCharacters` is set); it cannot know how a renderer will wrap without a measure.
|
|
25
|
+
*/
|
|
26
|
+
export declare function segmentText(text: string, granularity: SegmentGranularity, options?: SegmentTextOptions): TextSegment[];
|