@poveste/shared 0.20.0 → 0.21.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/story.js +2 -0
- package/dist/types/docgen.d.ts +49 -1
- package/dist/types/story.d.ts +10 -0
- package/dist/virtual.d.ts +37 -0
- package/dist/virtual.js +41 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/story.js
CHANGED
package/dist/types/docgen.d.ts
CHANGED
|
@@ -23,6 +23,15 @@ export interface DocSlot {
|
|
|
23
23
|
name: string;
|
|
24
24
|
description?: string;
|
|
25
25
|
type?: string;
|
|
26
|
+
/**
|
|
27
|
+
* What it passes its content, `open` in `<template #default="{ open }">`, one row each,
|
|
28
|
+
* so the JSDoc on each shows (#1436).
|
|
29
|
+
*/
|
|
30
|
+
props?: {
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
}[];
|
|
26
35
|
tags: DocTag[];
|
|
27
36
|
}
|
|
28
37
|
export interface DocEvent {
|
|
@@ -32,6 +41,10 @@ export interface DocEvent {
|
|
|
32
41
|
tags: DocTag[];
|
|
33
42
|
}
|
|
34
43
|
export interface ComponentDoc {
|
|
44
|
+
/** The component's own name, when the file it was read from is not named after it. */
|
|
45
|
+
name?: string;
|
|
46
|
+
/** Its type parameters as the source declares them, `T extends string = string`, when it has any. */
|
|
47
|
+
generic?: string;
|
|
35
48
|
props: DocProp[];
|
|
36
49
|
slots: DocSlot[];
|
|
37
50
|
events: DocEvent[];
|
|
@@ -42,6 +55,10 @@ export interface ComponentDoc {
|
|
|
42
55
|
* memory this whole design is about: `dispose` must let it go.
|
|
43
56
|
*/
|
|
44
57
|
export interface DocgenExtractor {
|
|
58
|
+
/**
|
|
59
|
+
* A failure is thrown. When the file is not named after the component, as with a
|
|
60
|
+
* JSX story, an error carrying a `component` string names it for the reader.
|
|
61
|
+
*/
|
|
45
62
|
extract: (file: string) => ComponentDoc | undefined | Promise<ComponentDoc | undefined>;
|
|
46
63
|
/** A file changed on disk. Called for any file, not only components. */
|
|
47
64
|
update?: (file: string) => void | Promise<void>;
|
|
@@ -64,7 +81,16 @@ export interface DocgenExtractorModule {
|
|
|
64
81
|
createExtractor: (context: DocgenExtractorContext) => DocgenExtractor | Promise<DocgenExtractor>;
|
|
65
82
|
}
|
|
66
83
|
export interface PluginDocgen {
|
|
67
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* What a request hands the extractor. `imports`: each file the story's module
|
|
86
|
+
* imports that `match` accepts, as a Vue story imports its `.vue` files.
|
|
87
|
+
* `story`: the story file itself, for a story collection gave to this plugin's
|
|
88
|
+
* `supportPlugin` and that `match` accepts, in a format whose story names its
|
|
89
|
+
* component in a `component` field the extractor resolves. `autoDocs.exclude`
|
|
90
|
+
* reaches the extractor in its options, since only it knows the component's file.
|
|
91
|
+
*/
|
|
92
|
+
scope?: 'imports' | 'story';
|
|
93
|
+
/** Whether a resolved file is one this plugin documents. */
|
|
68
94
|
match: (file: string) => boolean;
|
|
69
95
|
/**
|
|
70
96
|
* An absolute path or `file:` URL to a module exporting `createExtractor`. It is
|
|
@@ -73,6 +99,20 @@ export interface PluginDocgen {
|
|
|
73
99
|
module: string;
|
|
74
100
|
/** Passed to `createExtractor`; it has to survive a structured clone. */
|
|
75
101
|
options?: unknown;
|
|
102
|
+
/**
|
|
103
|
+
* Where the extractor loads `typescript` from, when it reads types with it: a file
|
|
104
|
+
* whose `require` it uses, or `'book'` for the book's own root. In a book where that
|
|
105
|
+
* finds no TypeScript, or one newer than 6, auto-docs is off for this plugin with one
|
|
106
|
+
* log line (#1382, #1401). A value rather than a function, so a plugin whose entry
|
|
107
|
+
* also runs in the browser can declare it.
|
|
108
|
+
*/
|
|
109
|
+
typescript?: 'book' | (string & {});
|
|
110
|
+
/**
|
|
111
|
+
* Type packages the book must have for the extractor to read its framework's types,
|
|
112
|
+
* such as `@types/react`. Missing one, auto-docs is off for this plugin with one log
|
|
113
|
+
* line naming it, rather than an error under every component it would read as `any`.
|
|
114
|
+
*/
|
|
115
|
+
types?: string[];
|
|
76
116
|
/**
|
|
77
117
|
* Why this plugin cannot document the book at `root`, or nothing when it can.
|
|
78
118
|
* With a reason, auto-docs is off for this plugin and the reason is logged once,
|
|
@@ -90,3 +130,11 @@ export interface AutoDocsOptions {
|
|
|
90
130
|
/** Component files to leave out, matched as substrings of the path. */
|
|
91
131
|
exclude?: string[];
|
|
92
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* The field a story format uses to name the component it documents, shared by
|
|
135
|
+
* the JSX formats so Solid and React spell it the same way (#1110, #1161).
|
|
136
|
+
*/
|
|
137
|
+
export interface StoryComponentOptions<C> {
|
|
138
|
+
/** The component this story documents. Auto-docs reads its props from its type. */
|
|
139
|
+
component?: C;
|
|
140
|
+
}
|
package/dist/types/story.d.ts
CHANGED
|
@@ -41,10 +41,18 @@ export interface InheritedProps {
|
|
|
41
41
|
}
|
|
42
42
|
export interface VariantProps extends CommonProps, InheritedProps {
|
|
43
43
|
}
|
|
44
|
+
/** A section of the auto-docs table on a story's Docs tab. */
|
|
45
|
+
export type AutoDocsSection = 'props' | 'slots' | 'events';
|
|
44
46
|
export interface StoryProps extends CommonProps, InheritedProps {
|
|
45
47
|
group?: string;
|
|
46
48
|
layout?: StoryLayout;
|
|
47
49
|
docsOnly?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The auto-docs table on this story's Docs tab: `false` for none, never extracting
|
|
52
|
+
* the story's components; an array for only those sections. Left out, the story
|
|
53
|
+
* follows the book's `autoDocs`, which a story cannot turn on (#1398).
|
|
54
|
+
*/
|
|
55
|
+
autoDocs?: boolean | AutoDocsSection[];
|
|
48
56
|
}
|
|
49
57
|
export interface CommonMeta {
|
|
50
58
|
}
|
|
@@ -65,6 +73,7 @@ export interface Story {
|
|
|
65
73
|
icon?: string;
|
|
66
74
|
iconColor?: string;
|
|
67
75
|
docsOnly?: boolean;
|
|
76
|
+
autoDocs?: boolean | AutoDocsSection[] | undefined;
|
|
68
77
|
file?: StoryFile;
|
|
69
78
|
lastSelectedVariant?: Variant;
|
|
70
79
|
/** The story's own slots. Any of the three can be absent: a story may define none. */
|
|
@@ -174,6 +183,7 @@ export interface ServerStory {
|
|
|
174
183
|
icon?: string | undefined;
|
|
175
184
|
iconColor?: string | undefined;
|
|
176
185
|
docsOnly?: boolean | undefined;
|
|
186
|
+
autoDocs?: boolean | AutoDocsSection[] | undefined;
|
|
177
187
|
docsText?: string | undefined;
|
|
178
188
|
meta?: StoryMeta | undefined;
|
|
179
189
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PovesteConfig } from './types/config.js';
|
|
2
|
+
/**
|
|
3
|
+
* The virtual modules Poveste's client imports, by the ids core serves them
|
|
4
|
+
* under. A story test's Vite plugin serves the same ones, from this list.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VIRTUAL_IDS: {
|
|
7
|
+
readonly setup: "virtual:$poveste-setup";
|
|
8
|
+
readonly generatedGlobalSetup: "virtual:$poveste-generated-global-setup";
|
|
9
|
+
readonly config: "virtual:$poveste-config";
|
|
10
|
+
readonly markdownFiles: "virtual:$poveste-markdown-files";
|
|
11
|
+
readonly componentDocs: "virtual:$poveste-component-docs";
|
|
12
|
+
readonly supportPluginsClient: "virtual:$poveste-support-plugins-client";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The config as the browser gets it: the fields `@poveste/app` reads, and no
|
|
16
|
+
* others. The rest is build-side, and holds paths on the machine that built the
|
|
17
|
+
* book (`outDir`, each plugin's modules, the logo files), which a built book
|
|
18
|
+
* published in full (#1383). The logos reach the browser as `logos`, below.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clientConfig(config: Partial<PovesteConfig>): {
|
|
21
|
+
theme: {
|
|
22
|
+
title: string | undefined;
|
|
23
|
+
logoHref: string | undefined;
|
|
24
|
+
defaultColorScheme: "light" | "dark" | "auto" | undefined;
|
|
25
|
+
hideColorSchemeSwitch: boolean | undefined;
|
|
26
|
+
storeColorScheme: boolean | undefined;
|
|
27
|
+
darkClass: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
routerMode: "history" | "hash" | undefined;
|
|
30
|
+
autoApplyContrastColor: boolean | undefined;
|
|
31
|
+
responsivePresets: import("./index.js").ResponsivePreset[] | undefined;
|
|
32
|
+
backgroundPresets: import("./index.js").BackgroundPreset[] | undefined;
|
|
33
|
+
defaultBackgroundColor: string | undefined;
|
|
34
|
+
preview: import("./index.js").PreviewConfig | undefined;
|
|
35
|
+
isolateStyles: boolean | undefined;
|
|
36
|
+
sandboxDarkClass: string | undefined;
|
|
37
|
+
};
|
package/dist/virtual.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The virtual modules Poveste's client imports, by the ids core serves them
|
|
3
|
+
* under. A story test's Vite plugin serves the same ones, from this list.
|
|
4
|
+
*/
|
|
5
|
+
export const VIRTUAL_IDS = {
|
|
6
|
+
setup: 'virtual:$poveste-setup',
|
|
7
|
+
generatedGlobalSetup: 'virtual:$poveste-generated-global-setup',
|
|
8
|
+
config: 'virtual:$poveste-config',
|
|
9
|
+
markdownFiles: 'virtual:$poveste-markdown-files',
|
|
10
|
+
componentDocs: 'virtual:$poveste-component-docs',
|
|
11
|
+
supportPluginsClient: 'virtual:$poveste-support-plugins-client',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The config as the browser gets it: the fields `@poveste/app` reads, and no
|
|
15
|
+
* others. The rest is build-side, and holds paths on the machine that built the
|
|
16
|
+
* book (`outDir`, each plugin's modules, the logo files), which a built book
|
|
17
|
+
* published in full (#1383). The logos reach the browser as `logos`, below.
|
|
18
|
+
*/
|
|
19
|
+
export function clientConfig(config) {
|
|
20
|
+
const theme = config.theme ?? {};
|
|
21
|
+
return {
|
|
22
|
+
theme: {
|
|
23
|
+
title: theme.title,
|
|
24
|
+
logoHref: theme.logoHref,
|
|
25
|
+
defaultColorScheme: theme.defaultColorScheme,
|
|
26
|
+
hideColorSchemeSwitch: theme.hideColorSchemeSwitch,
|
|
27
|
+
storeColorScheme: theme.storeColorScheme,
|
|
28
|
+
darkClass: theme.darkClass,
|
|
29
|
+
},
|
|
30
|
+
routerMode: config.routerMode,
|
|
31
|
+
autoApplyContrastColor: config.autoApplyContrastColor,
|
|
32
|
+
responsivePresets: config.responsivePresets,
|
|
33
|
+
backgroundPresets: config.backgroundPresets,
|
|
34
|
+
// eslint-disable-next-line ts/no-deprecated -- the app still reads it as a fallback
|
|
35
|
+
defaultBackgroundColor: config.defaultBackgroundColor,
|
|
36
|
+
preview: config.preview,
|
|
37
|
+
isolateStyles: config.isolateStyles,
|
|
38
|
+
// eslint-disable-next-line ts/no-deprecated -- the app still reads it as a fallback
|
|
39
|
+
sandboxDarkClass: config.sandboxDarkClass,
|
|
40
|
+
};
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poveste/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.1",
|
|
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.
|
|
42
|
+
"@poveste/vendors": "^0.21.1",
|
|
43
43
|
"@types/fs-extra": "^11.0.4",
|
|
44
44
|
"chokidar": "^5.0.0",
|
|
45
45
|
"markdown-it": "^15.0.3",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/node": "^26.6.5",
|
|
52
52
|
"typescript": "6.0.3",
|
|
53
53
|
"vite": "^8.3.4",
|
|
54
|
-
"vitest": "^5.0.
|
|
54
|
+
"vitest": "^5.0.5",
|
|
55
55
|
"vue-router": "^5.4.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|