@pixerate/editor 0.175.0 → 0.177.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.
Files changed (39) hide show
  1. package/dist/{chunk-FKUKJ3XA.cjs → chunk-4XSBOGMK.cjs} +5 -4
  2. package/dist/{chunk-CJE5MOIS.js → chunk-N4ZXW3WB.js} +2 -1
  3. package/dist/{chunk-OVYQAYGH.cjs → chunk-UHMSMUHK.cjs} +75 -66
  4. package/dist/{chunk-BDIM6NVW.js → chunk-Y46OMERN.js} +10 -1
  5. package/dist/effects/fake.d.cts +1 -1
  6. package/dist/effects/fake.d.ts +1 -1
  7. package/dist/effects/index.cjs +38 -24
  8. package/dist/effects/index.js +20 -6
  9. package/dist/effects/types.d.cts +6 -0
  10. package/dist/effects/types.d.ts +6 -0
  11. package/dist/effects/ui.d.cts +0 -6
  12. package/dist/effects/ui.d.ts +0 -6
  13. package/dist/image-editor/controller.d.cts +28 -5
  14. package/dist/image-editor/controller.d.ts +28 -5
  15. package/dist/image-editor/effect-layers.d.cts +40 -0
  16. package/dist/image-editor/effect-layers.d.ts +40 -0
  17. package/dist/image-editor/index.cjs +931 -812
  18. package/dist/image-editor/index.d.cts +1 -0
  19. package/dist/image-editor/index.d.ts +1 -0
  20. package/dist/image-editor/index.js +152 -33
  21. package/dist/image-editor/layers/model.d.cts +15 -1
  22. package/dist/image-editor/layers/model.d.ts +15 -1
  23. package/dist/image-editor/layers/panel.d.cts +6 -2
  24. package/dist/image-editor/layers/panel.d.ts +6 -2
  25. package/dist/image-editor/provider-effect-tools.d.cts +2 -1
  26. package/dist/image-editor/provider-effect-tools.d.ts +2 -1
  27. package/dist/paint-editor/index.cjs +6 -6
  28. package/dist/paint-editor/index.js +1 -1
  29. package/dist/typography/index.cjs +185 -40
  30. package/dist/typography/index.d.cts +1 -0
  31. package/dist/typography/index.d.ts +1 -0
  32. package/dist/typography/index.js +149 -4
  33. package/dist/typography/registry.d.cts +4 -0
  34. package/dist/typography/registry.d.ts +4 -0
  35. package/dist/typography/stylesheet.d.cts +86 -0
  36. package/dist/typography/stylesheet.d.ts +86 -0
  37. package/package.json +1 -1
  38. package/skills/pixerate-image-editor/SKILL.md +2 -1
  39. package/skills/pixerate-typography/SKILL.md +7 -3
@@ -14,6 +14,8 @@ export interface FontSummary {
14
14
  source: FontSource;
15
15
  /** Platforms that ship it, for system fonts. */
16
16
  platforms?: FontPlatform[];
17
+ /** Lowercase, hyphenated classes from the provider, e.g. `display`, `slab-serif`, `variable-wdth`. */
18
+ tags?: string[];
17
19
  }
18
20
  export interface FontProvider {
19
21
  readonly id: string;
@@ -33,6 +35,8 @@ export interface FontFilter {
33
35
  /** Case-insensitive substring of the family name. */
34
36
  query?: string;
35
37
  isVariable?: boolean;
38
+ /** Keep fonts carrying every one of these tags (any case, spaces as hyphens). */
39
+ tags?: readonly string[];
36
40
  }
37
41
  /** Whether a font offers a weight (variable fonts offer every weight in their range). */
38
42
  export declare function fontHasWeight(font: FontSummary, weight: FontWeight): boolean;
@@ -14,6 +14,8 @@ export interface FontSummary {
14
14
  source: FontSource;
15
15
  /** Platforms that ship it, for system fonts. */
16
16
  platforms?: FontPlatform[];
17
+ /** Lowercase, hyphenated classes from the provider, e.g. `display`, `slab-serif`, `variable-wdth`. */
18
+ tags?: string[];
17
19
  }
18
20
  export interface FontProvider {
19
21
  readonly id: string;
@@ -33,6 +35,8 @@ export interface FontFilter {
33
35
  /** Case-insensitive substring of the family name. */
34
36
  query?: string;
35
37
  isVariable?: boolean;
38
+ /** Keep fonts carrying every one of these tags (any case, spaces as hyphens). */
39
+ tags?: readonly string[];
36
40
  }
37
41
  /** Whether a font offers a weight (variable fonts offer every weight in their range). */
38
42
  export declare function fontHasWeight(font: FontSummary, weight: FontWeight): boolean;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Font services that serve CSS (Google Fonts, Bunny Fonts, a self-hosted css2-compatible proxy):
3
+ * a provider that loads a family by adding the service's stylesheet and waiting for the face,
4
+ * and an adapter for the Google Fonts catalog and stylesheet URLs.
5
+ */
6
+ import { type FontProvider, type FontSummary } from './registry.cjs';
7
+ import { type FontStyle, type FontWeight } from './types.cjs';
8
+ /** The parts of `document.fonts` the stylesheet provider uses. */
9
+ export interface StylesheetFontSetLike {
10
+ load(font: string, text?: string): Promise<readonly unknown[]>;
11
+ }
12
+ export interface StylesheetFontProviderOptions {
13
+ id?: string;
14
+ /** The service's families; called once, on first use. */
15
+ listFonts: () => FontSummary[] | Promise<FontSummary[]>;
16
+ /** The stylesheet URL that declares one face. */
17
+ stylesheetUrl: (family: string, weight: FontWeight, style: FontStyle) => string;
18
+ /**
19
+ * Adds a stylesheet and resolves when it has loaded (default: a `<link rel="stylesheet">` in
20
+ * `document.head`). Inject a fake in tests: nothing then hits the network.
21
+ */
22
+ addStylesheet?: (url: string) => Promise<void>;
23
+ /** Where faces are waited for (default `document.fonts`). */
24
+ fontFaceSet?: StylesheetFontSetLike;
25
+ /**
26
+ * Characters the face must cover once loaded (default Latin letters and digits). Services split
27
+ * a family into `unicode-range` subsets, and `document.fonts.load` without text fetches none of
28
+ * the files a page needs for words.
29
+ */
30
+ sampleText?: string;
31
+ }
32
+ /**
33
+ * Fonts from a service that serves CSS. `loadFont` asks for the nearest weight and style the
34
+ * family offers, adds that face's stylesheet once, then resolves `true` when the browser has the face (`document.fonts.load` matched it), `false` when the family
35
+ * is not listed, the stylesheet fails or no face matches. Loads are cached per face; failures can
36
+ * be retried.
37
+ */
38
+ export declare function createStylesheetFontProvider(options: StylesheetFontProviderOptions): FontProvider & {
39
+ loaded(family: string, weight?: FontWeight, style?: FontStyle): boolean;
40
+ };
41
+ /** One family in the Google Fonts metadata (`https://fonts.google.com/metadata/fonts`), as far as this module reads it. */
42
+ export interface GoogleFontsFamilyMetadata {
43
+ family: string;
44
+ /** `Sans Serif`, `Serif`, `Display`, `Handwriting` or `Monospace`. */
45
+ category?: string;
46
+ /** Further classes, e.g. `Display`, `Handwriting`, `Monospace`, `Symbols`. */
47
+ classifications?: readonly string[];
48
+ /** Stroke class, e.g. `Sans Serif`, `Serif`, `Slab Serif`. */
49
+ stroke?: string | null;
50
+ /** Faces by weight, `i` for italic: `{ "400": …, "700i": … }`. */
51
+ fonts?: Record<string, unknown>;
52
+ axes?: ReadonlyArray<{
53
+ tag: string;
54
+ min: number;
55
+ max: number;
56
+ }>;
57
+ /** Rank, 1 = most popular. */
58
+ popularity?: number;
59
+ subsets?: readonly string[];
60
+ }
61
+ /**
62
+ * The families in a Google Fonts metadata response (the object, its `familyMetadataList`, or the
63
+ * raw text with its `)]}'` prefix), most popular first. A family classified as display,
64
+ * handwriting or monospace takes that category even when Google files it under sans serif or
65
+ * serif (Anton is a sans serif classified as display); its classes, stroke and axes become
66
+ * `tags` (`display`, `slab-serif`, `variable-wdth`…).
67
+ */
68
+ export declare function googleFontsCatalog(metadata: unknown): FontSummary[];
69
+ /** The Google Fonts css2 URL for one face, e.g. `…/css2?family=Space+Grotesk:ital,wght@0,700&display=swap`. */
70
+ export declare function googleFontsStylesheetUrl(family: string, weight?: FontWeight, style?: FontStyle, options?: {
71
+ baseUrl?: string;
72
+ display?: string;
73
+ }): string;
74
+ export interface GoogleFontsProviderOptions extends Omit<StylesheetFontProviderOptions, 'listFonts' | 'stylesheetUrl'> {
75
+ /**
76
+ * The Google Fonts metadata, or the catalog already built from it. fonts.google.com does not
77
+ * allow cross-origin reads, so a browser host fetches it through its own server.
78
+ */
79
+ catalog: () => Promise<unknown>;
80
+ /** css2-compatible stylesheet endpoint (default `https://fonts.googleapis.com/css2`). */
81
+ baseUrl?: string;
82
+ }
83
+ /** Google Fonts (or a css2-compatible mirror): its catalog, loaded face by face through its stylesheets. */
84
+ export declare function createGoogleFontsProvider(options: GoogleFontsProviderOptions): FontProvider & {
85
+ loaded(family: string, weight?: FontWeight, style?: FontStyle): boolean;
86
+ };
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Font services that serve CSS (Google Fonts, Bunny Fonts, a self-hosted css2-compatible proxy):
3
+ * a provider that loads a family by adding the service's stylesheet and waiting for the face,
4
+ * and an adapter for the Google Fonts catalog and stylesheet URLs.
5
+ */
6
+ import { type FontProvider, type FontSummary } from './registry.js';
7
+ import { type FontStyle, type FontWeight } from './types.js';
8
+ /** The parts of `document.fonts` the stylesheet provider uses. */
9
+ export interface StylesheetFontSetLike {
10
+ load(font: string, text?: string): Promise<readonly unknown[]>;
11
+ }
12
+ export interface StylesheetFontProviderOptions {
13
+ id?: string;
14
+ /** The service's families; called once, on first use. */
15
+ listFonts: () => FontSummary[] | Promise<FontSummary[]>;
16
+ /** The stylesheet URL that declares one face. */
17
+ stylesheetUrl: (family: string, weight: FontWeight, style: FontStyle) => string;
18
+ /**
19
+ * Adds a stylesheet and resolves when it has loaded (default: a `<link rel="stylesheet">` in
20
+ * `document.head`). Inject a fake in tests: nothing then hits the network.
21
+ */
22
+ addStylesheet?: (url: string) => Promise<void>;
23
+ /** Where faces are waited for (default `document.fonts`). */
24
+ fontFaceSet?: StylesheetFontSetLike;
25
+ /**
26
+ * Characters the face must cover once loaded (default Latin letters and digits). Services split
27
+ * a family into `unicode-range` subsets, and `document.fonts.load` without text fetches none of
28
+ * the files a page needs for words.
29
+ */
30
+ sampleText?: string;
31
+ }
32
+ /**
33
+ * Fonts from a service that serves CSS. `loadFont` asks for the nearest weight and style the
34
+ * family offers, adds that face's stylesheet once, then resolves `true` when the browser has the face (`document.fonts.load` matched it), `false` when the family
35
+ * is not listed, the stylesheet fails or no face matches. Loads are cached per face; failures can
36
+ * be retried.
37
+ */
38
+ export declare function createStylesheetFontProvider(options: StylesheetFontProviderOptions): FontProvider & {
39
+ loaded(family: string, weight?: FontWeight, style?: FontStyle): boolean;
40
+ };
41
+ /** One family in the Google Fonts metadata (`https://fonts.google.com/metadata/fonts`), as far as this module reads it. */
42
+ export interface GoogleFontsFamilyMetadata {
43
+ family: string;
44
+ /** `Sans Serif`, `Serif`, `Display`, `Handwriting` or `Monospace`. */
45
+ category?: string;
46
+ /** Further classes, e.g. `Display`, `Handwriting`, `Monospace`, `Symbols`. */
47
+ classifications?: readonly string[];
48
+ /** Stroke class, e.g. `Sans Serif`, `Serif`, `Slab Serif`. */
49
+ stroke?: string | null;
50
+ /** Faces by weight, `i` for italic: `{ "400": …, "700i": … }`. */
51
+ fonts?: Record<string, unknown>;
52
+ axes?: ReadonlyArray<{
53
+ tag: string;
54
+ min: number;
55
+ max: number;
56
+ }>;
57
+ /** Rank, 1 = most popular. */
58
+ popularity?: number;
59
+ subsets?: readonly string[];
60
+ }
61
+ /**
62
+ * The families in a Google Fonts metadata response (the object, its `familyMetadataList`, or the
63
+ * raw text with its `)]}'` prefix), most popular first. A family classified as display,
64
+ * handwriting or monospace takes that category even when Google files it under sans serif or
65
+ * serif (Anton is a sans serif classified as display); its classes, stroke and axes become
66
+ * `tags` (`display`, `slab-serif`, `variable-wdth`…).
67
+ */
68
+ export declare function googleFontsCatalog(metadata: unknown): FontSummary[];
69
+ /** The Google Fonts css2 URL for one face, e.g. `…/css2?family=Space+Grotesk:ital,wght@0,700&display=swap`. */
70
+ export declare function googleFontsStylesheetUrl(family: string, weight?: FontWeight, style?: FontStyle, options?: {
71
+ baseUrl?: string;
72
+ display?: string;
73
+ }): string;
74
+ export interface GoogleFontsProviderOptions extends Omit<StylesheetFontProviderOptions, 'listFonts' | 'stylesheetUrl'> {
75
+ /**
76
+ * The Google Fonts metadata, or the catalog already built from it. fonts.google.com does not
77
+ * allow cross-origin reads, so a browser host fetches it through its own server.
78
+ */
79
+ catalog: () => Promise<unknown>;
80
+ /** css2-compatible stylesheet endpoint (default `https://fonts.googleapis.com/css2`). */
81
+ baseUrl?: string;
82
+ }
83
+ /** Google Fonts (or a css2-compatible mirror): its catalog, loaded face by face through its stylesheets. */
84
+ export declare function createGoogleFontsProvider(options: GoogleFontsProviderOptions): FontProvider & {
85
+ loaded(family: string, weight?: FontWeight, style?: FontStyle): boolean;
86
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.175.0",
3
+ "version": "0.177.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -390,7 +390,8 @@ in the source frame at the document's bit depth, colour mode and profile. Read
390
390
  | `apply_effect` | Run a provider filter effect on a layer as a smart filter (`target`, `effect`, `values`, `index`, `enabled`, `opacity`); a pixel, shape or type layer becomes a smart object in the same undo step (`converted`). Returns the filter id. |
391
391
  | `update_effect` | Change an effect smart filter (`values` merged, `null` resets; `enabled`, `opacity`, `index`) or redraw an effect layer (`effect: "generator"`, values only). |
392
392
  | `remove_effect` | Remove an effect smart filter, or (`generator`) keep an effect layer's pixels as a plain layer. |
393
- | `add_effect_layer` | Add a layer drawn by a generator, overlay or title effect at the document's size and bit depth (`values`, `time`, `name`, `aboveId` / `belowId`, `opacity`, `blend`). Returns the layer id. |
393
+ | `add_effect_layer` | Add a layer drawn by a generator, overlay or title effect at the document's size and bit depth (`values`, `time`, `animate`, `name`, `aboveId` / `belowId`, `opacity`, `blend`). An effect with its own background (`backgroundOpacity` in `describe_effect`) starts with it transparent when there are layers below. Returns the layer id. |
394
+ | `set_effect_layer` | Change an effect layer: swap its `effect` (its defaults plus `values`), pick the still frame (`time`, ms), or make it play in an animation (`animate: { duration }`; `null` for a still frame). The longest animating layer sets the animation's length. |
394
395
  | `apply_selection_as_mask` | Mask a layer with the current selection: pass `layerId` to mask an existing layer, or `kind` (plus optional `params`) to create a new masked layer in one step. `density` 0..1 and `feather` px soften the mask non-destructively. Returns `layerId`, kind, mask info and the selection summary. |
395
396
 
396
397
  ### Save and open
@@ -23,8 +23,12 @@ what this machine has.
23
23
 
24
24
  ## Working method
25
25
 
26
- 1. **Find fonts.** `list_fonts` with `category`, `weight`, `style` or `query`. Only use families it
27
- returns (or that the user names), and always ship them inside a stack from `resolve_font_stack`.
26
+ 1. **Find fonts.** `list_fonts` with `category`, `weight`, `style`, `tags` or `query`. Only use
27
+ families it returns (or that the user names), and always ship them inside a stack from
28
+ `resolve_font_stack`. When the host offers a web font service (`source: 'web'`, e.g. Google
29
+ Fonts), its catalog is far larger than the installed fonts and listed most popular first:
30
+ narrow it by `category` and by the `tags` the result counts (`display`, `slab-serif`,
31
+ `variable-wdth`…) to find faces with the character you want, rather than taking the top few.
28
32
  2. **Load before rendering.** `load_font` before drawing or capturing text in a web font, so the
29
33
  first frame does not use the fallback. `loaded: false` means the fallback will show.
30
34
  3. **Set up the scale.** `generate_type_hierarchy` for named tokens and ready CSS custom
@@ -62,7 +66,7 @@ what this machine has.
62
66
 
63
67
  | Tool | When to use | Returns |
64
68
  | --- | --- | --- |
65
- | `list_fonts` | Discover families the host offers; filter by `category`, `source`, `weight`, `style`, `query`; `limit` default 50 | `{ fonts: [{ family, category, weights, styles, isVariable?, source }], total, truncated }` |
69
+ | `list_fonts` | Discover families the host offers; filter by `category`, `source`, `weight`, `style`, `tags`, `query`; `limit` default 50 | `{ fonts: [{ family, category, weights, styles, isVariable?, source, tags? }], total, truncated, tags: [{ tag, count }] }` |
66
70
  | `resolve_font_stack` | Turn a family (or stack) into a resilient `font-family` value for its category; also says if the provider lists it | `{ stack, families, category, available }` |
67
71
  | `suggest_type_scale` | Sizes for arbitrary integer `steps` (-12…12) from `baseSize` (px, default 16) and `ratio` (name or number, default major-third) | `{ ratio, baseSize, steps: [{ name, step, size, lineHeight, letterSpacing }] }` |
68
72
  | `generate_type_hierarchy` | Named tokens caption…display on one scale, with CSS custom properties (`prefix`, `selector`) | `{ ratio, ratioName?, baseSize, steps: { body, h1, … }, css }` |