@poveste/shared 0.18.3 → 0.19.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.
@@ -1,4 +1,3 @@
1
- import type { RouteLocationNormalizedLoaded } from 'vue-router';
2
1
  import type { Prompt } from './prompt.js';
3
2
  import type { Story, Variant } from './story.js';
4
3
  export interface CommonCommandOptions {
@@ -21,8 +20,24 @@ export interface ClientCommandOptions extends CommonCommandOptions {
21
20
  * A command that can be executed from the search bar.
22
21
  */
23
22
  export type ClientCommand = Command & ClientCommandOptions;
23
+ /**
24
+ * The route the book is on, as a command sees it. The app passes its
25
+ * `vue-router` route, and this names the fields a command reads rather than
26
+ * importing the router's type: this package depends on no router, so that import
27
+ * failed a consumer's type check under `skipLibCheck: false`, in a Solid or
28
+ * Svelte project most of all (#1199).
29
+ */
30
+ export interface ClientCommandRoute {
31
+ path: string;
32
+ fullPath: string;
33
+ hash: string;
34
+ name: string | symbol | null | undefined;
35
+ params: Record<string, string | string[]>;
36
+ query: Record<string, string | null | (string | null)[]>;
37
+ meta: Record<PropertyKey, unknown>;
38
+ }
24
39
  export interface ClientCommandContext {
25
- route: RouteLocationNormalizedLoaded;
40
+ route: ClientCommandRoute;
26
41
  /**
27
42
  * The story the route names, or undefined on any route that names none — the
28
43
  * home page, or a story id that is not loaded. Declared non-optional here
@@ -16,6 +16,39 @@ export interface ResponsivePreset {
16
16
  width: number;
17
17
  height?: number | null;
18
18
  }
19
+ /**
20
+ * What the story preview opens at. Each value is applied on every load, for a
21
+ * reader with stored settings too, until that reader changes the setting in the
22
+ * toolbar; from then on theirs wins.
23
+ */
24
+ export interface PreviewConfig {
25
+ /**
26
+ * A CSS color. Match a `color` from `backgroundPresets` to also highlight that
27
+ * entry in the dropdown.
28
+ *
29
+ * @default 'transparent'
30
+ */
31
+ backgroundColor?: string;
32
+ /**
33
+ * In pixels. `null` sizes the preview to the available space. Set it with
34
+ * `responsiveHeight` to open at one of `responsivePresets`.
35
+ *
36
+ * @default 720
37
+ */
38
+ responsiveWidth?: number | null;
39
+ /**
40
+ * In pixels. `null` sizes the preview to the available space.
41
+ *
42
+ * @default null
43
+ */
44
+ responsiveHeight?: number | null;
45
+ /** Swap the width and height. @default false */
46
+ rotate?: boolean;
47
+ /** Show a checkerboard behind the story. @default false */
48
+ checkerboard?: boolean;
49
+ /** @default 'ltr' */
50
+ textDirection?: 'ltr' | 'rtl';
51
+ }
19
52
  export interface BackgroundPreset {
20
53
  label: string;
21
54
  color: string;
@@ -156,11 +189,11 @@ export interface PovesteConfig {
156
189
  lang?: string;
157
190
  };
158
191
  /**
159
- * Setup file exporting a default function executed when setting up each story preview.
192
+ * Setup file loaded with every story. Import custom CSS files from it, and export
193
+ * the setup function your framework's plugin reads, such as `setupVue`. A default
194
+ * export is not called.
160
195
  *
161
- * Import custom CSS files from this file.
162
- *
163
- * Example: `'/src/poveste-setup.ts'`
196
+ * Example: `'/src/poveste.setup.ts'`
164
197
  */
165
198
  setupFile?: string | {
166
199
  /**
@@ -194,13 +227,18 @@ export interface PovesteConfig {
194
227
  * Background color of the story preview.
195
228
  */
196
229
  backgroundPresets?: BackgroundPreset[];
230
+ /**
231
+ * What the story preview opens at, before the reader changes it in the toolbar.
232
+ * Each field mirrors the toolbar setting of the same name.
233
+ */
234
+ preview?: PreviewConfig;
197
235
  /**
198
236
  * Initial background color used for story previews before the user picks one.
199
237
  *
200
- * Should match a `color` from `backgroundPresets` to also highlight the corresponding
201
- * entry in the dropdown; any other value is still applied as a CSS color.
238
+ * Still honoured where it is set. When `preview.backgroundColor` is set too,
239
+ * that one wins.
202
240
  *
203
- * @default 'transparent'
241
+ * @deprecated use `preview.backgroundColor` instead
204
242
  */
205
243
  defaultBackgroundColor?: string;
206
244
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@poveste/shared",
3
3
  "type": "module",
4
- "version": "0.18.3",
4
+ "version": "0.19.0",
5
5
  "description": "Shared utilities for Poveste",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan",
@@ -39,7 +39,7 @@
39
39
  "vite": "^8.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@poveste/vendors": "^0.18.3",
42
+ "@poveste/vendors": "^0.19.0",
43
43
  "@types/fs-extra": "^11.0.4",
44
44
  "chokidar": "^5.0.0",
45
45
  "markdown-it": "^15.0.2",