@fias/create-fias-plugin 1.3.0 → 1.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fias/create-fias-plugin",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -63,6 +63,55 @@ function MyComponent() {
63
63
  - `fonts`: `{ body, heading, mono }` (font-family strings)
64
64
  - `components`: `{ borderRadius, buttonRadius, cardRadius, inputRadius, shadowSm, shadowMd, shadowLg, borderWidth }`
65
65
 
66
+ ### `useFiasFonts()` — Platform font catalog
67
+
68
+ **Permission:** none
69
+ **Returns:** `{ fonts, ensureFontLoaded }`
70
+
71
+ The platform vendors a catalog of fonts and injects every family's
72
+ `@font-face` into your plugin iframe automatically (the `.woff2` bytes
73
+ load lazily, only when a glyph is actually painted). So you can use any
74
+ catalog `family` name directly in CSS — no `<link>`, no `@import`, no
75
+ bundled font files, and **no Google Fonts** (those are blocked by the
76
+ plugin CSP). Build a font picker from `fonts`:
77
+
78
+ ```tsx
79
+ import { useFiasFonts } from '@fias/arche-sdk';
80
+
81
+ function FontPicker({ value, onChange }: { value: string; onChange: (f: string) => void }) {
82
+ const { fonts } = useFiasFonts();
83
+ return (
84
+ <select value={value} onChange={(e) => onChange(e.target.value)} style={{ fontFamily: value }}>
85
+ {fonts.map((f) => (
86
+ <option key={f.family} value={f.family} style={{ fontFamily: f.family }}>
87
+ {f.displayName}
88
+ </option>
89
+ ))}
90
+ </select>
91
+ );
92
+ }
93
+ ```
94
+
95
+ - `fonts`: `FontCatalogEntry[]` — `{ family, displayName, category, system }`.
96
+ `category` is one of `sans | serif | display | mono | handwriting | system`;
97
+ `system: true` marks OS fonts (always available, no web font needed).
98
+ - `ensureFontLoaded(family, sizePx?)`: `Promise<void>` — **canvas / PDF only.**
99
+ Normal DOM text needs nothing (the browser fetches the face when it
100
+ paints). But `<canvas>` (incl. Konva / Fabric) and PDF exporters measure
101
+ glyph metrics synchronously, so they rasterize the fallback face if the
102
+ bytes aren't in yet. Call and `await` this before drawing. It never
103
+ rejects, resolves instantly for already-loaded / system fonts, and
104
+ resolves after a 3s timeout if the CDN is unreachable.
105
+
106
+ ```tsx
107
+ const { ensureFontLoaded } = useFiasFonts();
108
+ await ensureFontLoaded(selectedFamily); // then draw to the canvas
109
+ ```
110
+
111
+ `FONT_CATALOG` and `ensureFontLoaded` are also exported standalone for use
112
+ outside React (e.g. an export routine). For curated heading/body theme
113
+ pairings instead of the flat catalog, see `FONT_PAIRINGS`.
114
+
66
115
  ### `useFiasUser()` — Current user profile
67
116
 
68
117
  **Permission:** `user:profile:read`
@@ -783,8 +832,8 @@ You can choose between **Staging** and **Production** environments using the dro
783
832
  You can also authenticate via the command line:
784
833
 
785
834
  ```bash
786
- npx fias-dev login # Authenticate with staging (default)
787
- npx fias-dev login --env production # Authenticate with production
835
+ npx fias-dev login # Authenticate with prod (default)
836
+ npx fias-dev login --env staging # Authenticate with staging (internal)
788
837
  ```
789
838
 
790
839
  ### Browsing Available Entities
@@ -820,7 +869,7 @@ happened either way).
820
869
 
821
870
  ### Managing the asset library (for `useArcheAssets`)
822
871
 
823
- `useArcheAssets()` reads a contributor-curated set of images pinned to the arche's published version. Populate that library with the `assets` subcommands. Each command accepts `--env <staging|prod|local>` (default `staging`) and `--arche-id <id>` (auto-resolved from the manifest when omitted).
872
+ `useArcheAssets()` reads a contributor-curated set of images pinned to the arche's published version. Populate that library with the `assets` subcommands. Each command accepts `--env <prod|staging|local>` (default `prod`) and `--arche-id <id>` (auto-resolved from the manifest when omitted).
824
873
 
825
874
  ```bash
826
875
  npx fias-dev assets enable # Turn on the asset library for this arche
@@ -848,7 +897,7 @@ npx fias-dev collaborators set <identifier> \ # Change role and/or
848
897
  npx fias-dev collaborators remove <identifier> # Revoke a collaborator
849
898
  ```
850
899
 
851
- All commands accept `--env <staging|production|local>` (default `staging`).
900
+ All commands accept `--env <prod|staging|local>` (default `prod`).
852
901
 
853
902
  ### Other CLI diagnostics
854
903
 
@@ -63,6 +63,55 @@ function MyComponent() {
63
63
  - `fonts`: `{ body, heading, mono }` (font-family strings)
64
64
  - `components`: `{ borderRadius, buttonRadius, cardRadius, inputRadius, shadowSm, shadowMd, shadowLg, borderWidth }`
65
65
 
66
+ ### `useFiasFonts()` — Platform font catalog
67
+
68
+ **Permission:** none
69
+ **Returns:** `{ fonts, ensureFontLoaded }`
70
+
71
+ The platform vendors a catalog of fonts and injects every family's
72
+ `@font-face` into your plugin iframe automatically (the `.woff2` bytes
73
+ load lazily, only when a glyph is actually painted). So you can use any
74
+ catalog `family` name directly in CSS — no `<link>`, no `@import`, no
75
+ bundled font files, and **no Google Fonts** (those are blocked by the
76
+ plugin CSP). Build a font picker from `fonts`:
77
+
78
+ ```tsx
79
+ import { useFiasFonts } from '@fias/arche-sdk';
80
+
81
+ function FontPicker({ value, onChange }: { value: string; onChange: (f: string) => void }) {
82
+ const { fonts } = useFiasFonts();
83
+ return (
84
+ <select value={value} onChange={(e) => onChange(e.target.value)} style={{ fontFamily: value }}>
85
+ {fonts.map((f) => (
86
+ <option key={f.family} value={f.family} style={{ fontFamily: f.family }}>
87
+ {f.displayName}
88
+ </option>
89
+ ))}
90
+ </select>
91
+ );
92
+ }
93
+ ```
94
+
95
+ - `fonts`: `FontCatalogEntry[]` — `{ family, displayName, category, system }`.
96
+ `category` is one of `sans | serif | display | mono | handwriting | system`;
97
+ `system: true` marks OS fonts (always available, no web font needed).
98
+ - `ensureFontLoaded(family, sizePx?)`: `Promise<void>` — **canvas / PDF only.**
99
+ Normal DOM text needs nothing (the browser fetches the face when it
100
+ paints). But `<canvas>` (incl. Konva / Fabric) and PDF exporters measure
101
+ glyph metrics synchronously, so they rasterize the fallback face if the
102
+ bytes aren't in yet. Call and `await` this before drawing. It never
103
+ rejects, resolves instantly for already-loaded / system fonts, and
104
+ resolves after a 3s timeout if the CDN is unreachable.
105
+
106
+ ```tsx
107
+ const { ensureFontLoaded } = useFiasFonts();
108
+ await ensureFontLoaded(selectedFamily); // then draw to the canvas
109
+ ```
110
+
111
+ `FONT_CATALOG` and `ensureFontLoaded` are also exported standalone for use
112
+ outside React (e.g. an export routine). For curated heading/body theme
113
+ pairings instead of the flat catalog, see `FONT_PAIRINGS`.
114
+
66
115
  ### `useFiasUser()` — Current user profile
67
116
 
68
117
  **Permission:** `user:profile:read`
@@ -783,8 +832,8 @@ You can choose between **Staging** and **Production** environments using the dro
783
832
  You can also authenticate via the command line:
784
833
 
785
834
  ```bash
786
- npx fias-dev login # Authenticate with staging (default)
787
- npx fias-dev login --env production # Authenticate with production
835
+ npx fias-dev login # Authenticate with prod (default)
836
+ npx fias-dev login --env staging # Authenticate with staging (internal)
788
837
  ```
789
838
 
790
839
  ### Browsing Available Entities
@@ -820,7 +869,7 @@ happened either way).
820
869
 
821
870
  ### Managing the asset library (for `useArcheAssets`)
822
871
 
823
- `useArcheAssets()` reads a contributor-curated set of images pinned to the arche's published version. Populate that library with the `assets` subcommands. Each command accepts `--env <staging|prod|local>` (default `staging`) and `--arche-id <id>` (auto-resolved from the manifest when omitted).
872
+ `useArcheAssets()` reads a contributor-curated set of images pinned to the arche's published version. Populate that library with the `assets` subcommands. Each command accepts `--env <prod|staging|local>` (default `prod`) and `--arche-id <id>` (auto-resolved from the manifest when omitted).
824
873
 
825
874
  ```bash
826
875
  npx fias-dev assets enable # Turn on the asset library for this arche
@@ -848,7 +897,7 @@ npx fias-dev collaborators set <identifier> \ # Change role and/or
848
897
  npx fias-dev collaborators remove <identifier> # Revoke a collaborator
849
898
  ```
850
899
 
851
- All commands accept `--env <staging|production|local>` (default `staging`).
900
+ All commands accept `--env <prod|staging|local>` (default `prod`).
852
901
 
853
902
  ### Other CLI diagnostics
854
903