@poveste/shared 0.13.1 → 0.15.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/codegen/serialize-js.js +9 -5
- package/dist/codegen/util.js +4 -2
- package/dist/setup.d.ts +6 -1
- package/dist/setup.js +27 -2
- package/dist/state.d.ts +1 -1
- package/dist/state.js +2 -0
- package/dist/story-error.d.ts +3 -3
- package/dist/types/command.d.ts +10 -2
- package/dist/types/config.d.ts +3 -3
- package/dist/types/plugin.d.ts +108 -8
- package/dist/types/story.d.ts +32 -32
- package/package.json +7 -7
|
@@ -42,7 +42,7 @@ function objectToSourceLines(object, seen, indentCount = 0) {
|
|
|
42
42
|
lines.push('{');
|
|
43
43
|
lines.push(...createLines(1, (lines) => {
|
|
44
44
|
for (const key in object) {
|
|
45
|
-
const value = object
|
|
45
|
+
const value = Reflect.get(object, key);
|
|
46
46
|
let printedKey = key;
|
|
47
47
|
if (KEY_ESCAPE_REG.test(key)) {
|
|
48
48
|
printedKey = `'${printedKey}'`;
|
|
@@ -66,11 +66,11 @@ function arrayToSourceLines(array, seen, indentCount = 0) {
|
|
|
66
66
|
addLinesFromValue(lines, value, '', ',', seen);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
const [first] = contentLines;
|
|
70
|
+
if (!first) {
|
|
70
71
|
lines.push('[]');
|
|
71
72
|
}
|
|
72
73
|
else if (contentLines.length <= MAX_SINGLE_LINE_ARRAY_LENGTH && !contentLines.some(line => line.spaces > 1)) {
|
|
73
|
-
const [first] = contentLines;
|
|
74
74
|
first.line = contentLines.map(({ line }) => line.substring(0, line.length - 1)).join(', ');
|
|
75
75
|
first.line = `[${first.line}]`;
|
|
76
76
|
first.spaces--;
|
|
@@ -120,7 +120,11 @@ function addLinesFromValue(lines, value, before, after, seen) {
|
|
|
120
120
|
lines.push(before + result + after);
|
|
121
121
|
}
|
|
122
122
|
function wrap(lines, before, after) {
|
|
123
|
-
|
|
124
|
-
lines
|
|
123
|
+
const first = lines[0];
|
|
124
|
+
const last = lines.at(-1);
|
|
125
|
+
if (first)
|
|
126
|
+
first.line = before + first.line;
|
|
127
|
+
if (last)
|
|
128
|
+
last.line += after;
|
|
125
129
|
return lines;
|
|
126
130
|
}
|
package/dist/codegen/util.js
CHANGED
|
@@ -4,7 +4,9 @@ export function indent(lines, count = 1) {
|
|
|
4
4
|
export function unindent(code) {
|
|
5
5
|
const lines = code.split('\n');
|
|
6
6
|
let indentLevel = -1;
|
|
7
|
-
|
|
7
|
+
// Empty until a non-blank line is seen: `replace(undefined, '')` would look for
|
|
8
|
+
// the literal text "undefined" (TS6 reports it as used before assignment).
|
|
9
|
+
let indentText = '';
|
|
8
10
|
const linesToAnalyze = lines.filter(line => line.trim().length > 0);
|
|
9
11
|
for (const line of linesToAnalyze) {
|
|
10
12
|
const match = /^\s*/.exec(line);
|
|
@@ -51,7 +53,7 @@ export function createAutoBuildingObject(format, specialKeysHandler, key = '', d
|
|
|
51
53
|
if (!cache[p]) {
|
|
52
54
|
const childKey = key ? `${key}.${p.toString()}` : p.toString();
|
|
53
55
|
const child = createAutoBuildingObject(format, specialKeysHandler, childKey, depth + 1);
|
|
54
|
-
cache[p] =
|
|
56
|
+
cache[p] = child;
|
|
55
57
|
}
|
|
56
58
|
return cache[p].proxy;
|
|
57
59
|
},
|
package/dist/setup.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ export type SetupModule = Record<string, unknown> | undefined;
|
|
|
2
2
|
/**
|
|
3
3
|
* Reads a setup hook (`setupVanilla`, `setupVue3`, ...) out of a setup module.
|
|
4
4
|
*
|
|
5
|
+
* `retired` names hooks a plugin has stopped accepting. Nothing passes a
|
|
6
|
+
* non-empty list today; it exists so that removing a name at 1.0 is a string
|
|
7
|
+
* moving between two arrays rather than a failure mode designed under release
|
|
8
|
+
* pressure.
|
|
9
|
+
*
|
|
5
10
|
* Takes the module as an argument instead of letting callers access it inline:
|
|
6
11
|
* the setup modules are namespace imports of virtual or user-provided files that
|
|
7
12
|
* aren't guaranteed to declare every hook, and a static `namespace.setupVue3`
|
|
@@ -9,4 +14,4 @@ export type SetupModule = Record<string, unknown> | undefined;
|
|
|
9
14
|
* consumer build. Passing the namespace through a call forces it to be
|
|
10
15
|
* materialized, so the lookup happens at runtime where it belongs.
|
|
11
16
|
*/
|
|
12
|
-
export declare function getSetupHook<T>(mod: SetupModule, name: string | string[]): T | undefined;
|
|
17
|
+
export declare function getSetupHook<T>(mod: SetupModule, name: string | string[], retired?: string[]): T | undefined;
|
package/dist/setup.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reads a setup hook (`setupVanilla`, `setupVue3`, ...) out of a setup module.
|
|
3
3
|
*
|
|
4
|
+
* `retired` names hooks a plugin has stopped accepting. Nothing passes a
|
|
5
|
+
* non-empty list today; it exists so that removing a name at 1.0 is a string
|
|
6
|
+
* moving between two arrays rather than a failure mode designed under release
|
|
7
|
+
* pressure.
|
|
8
|
+
*
|
|
4
9
|
* Takes the module as an argument instead of letting callers access it inline:
|
|
5
10
|
* the setup modules are namespace imports of virtual or user-provided files that
|
|
6
11
|
* aren't guaranteed to declare every hook, and a static `namespace.setupVue3`
|
|
@@ -8,9 +13,28 @@
|
|
|
8
13
|
* consumer build. Passing the namespace through a call forces it to be
|
|
9
14
|
* materialized, so the lookup happens at runtime where it belongs.
|
|
10
15
|
*/
|
|
11
|
-
export function getSetupHook(mod, name) {
|
|
16
|
+
export function getSetupHook(mod, name, retired = []) {
|
|
12
17
|
const names = typeof name === 'string' ? [name] : name;
|
|
13
18
|
const present = names.filter(candidate => typeof mod?.[candidate] === 'function');
|
|
19
|
+
// Dropping a name is otherwise silent: the export stops being looked up, and a
|
|
20
|
+
// file that has it does nothing at all — no error, no warning, no hook. The
|
|
21
|
+
// people most likely to hold one are working from an older recipe, which is
|
|
22
|
+
// the worst audience for a silent failure.
|
|
23
|
+
//
|
|
24
|
+
// `retired` is a parameter rather than a constant so the mechanism can be
|
|
25
|
+
// exercised with a fixture list while every production list is still empty.
|
|
26
|
+
// An empty detector that has only ever been seen to pass cannot be told apart
|
|
27
|
+
// from one that does not work (#157).
|
|
28
|
+
const dropped = retired.filter(candidate => typeof mod?.[candidate] === 'function');
|
|
29
|
+
if (dropped.length > 0) {
|
|
30
|
+
// Two different situations, and the message has to say which: with no live
|
|
31
|
+
// name exported the setup does not run at all, and with one it does — so
|
|
32
|
+
// "nothing runs" would send someone to debug a setup that is working.
|
|
33
|
+
const consequence = present.length > 0
|
|
34
|
+
? `${present[0]} runs; the old export is ignored.`
|
|
35
|
+
: `Rename to ${names[names.length - 1]} — nothing runs until you do.`;
|
|
36
|
+
console.warn(`[poveste] Setup file exports ${dropped.join(', ')}, which ${dropped.length === 1 ? 'is' : 'are'} no longer read. ${consequence}`);
|
|
37
|
+
}
|
|
14
38
|
// Earlier names win, so a plugin lists its established hook first and a newer
|
|
15
39
|
// alias after it: an existing setup file keeps the exact behaviour it had.
|
|
16
40
|
// Running both instead would apply the same setup twice, which for Vue means
|
|
@@ -19,5 +43,6 @@ export function getSetupHook(mod, name) {
|
|
|
19
43
|
console.warn(`[poveste] Setup file exports ${present.length} interchangeable setup hooks (${present.join(', ')}). `
|
|
20
44
|
+ `Only ${present[0]} runs. Keep one — they are aliases, not separate hooks.`);
|
|
21
45
|
}
|
|
22
|
-
|
|
46
|
+
const [first] = present;
|
|
47
|
+
return first ? mod[first] : undefined;
|
|
23
48
|
}
|
package/dist/state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function clone(data: any): any;
|
|
2
|
-
export declare function omit(data: any, keys: string[]):
|
|
2
|
+
export declare function omit(data: any, keys: string[]): Record<string, any>;
|
|
3
3
|
/**
|
|
4
4
|
* Structural comparison, deliberately narrow: it recurses into plain objects and
|
|
5
5
|
* arrays and compares everything else by `Object.is`.
|
package/dist/state.js
CHANGED
package/dist/story-error.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare const SANDBOX_ERROR = "__poveste:sandbox-error";
|
|
2
2
|
export interface StoryError {
|
|
3
3
|
message: string;
|
|
4
|
-
stack?: string;
|
|
4
|
+
stack?: string | undefined;
|
|
5
5
|
/**
|
|
6
6
|
* Which occupant threw. A warm realm is retargeted rather than reloaded
|
|
7
7
|
* (#240), so the host has to reject a report from the previous one.
|
|
8
8
|
*/
|
|
9
|
-
storyId?: string;
|
|
10
|
-
variantId?: string;
|
|
9
|
+
storyId?: string | undefined;
|
|
10
|
+
variantId?: string | undefined;
|
|
11
11
|
}
|
|
12
12
|
export declare function toStoryError(error: unknown): Pick<StoryError, 'message' | 'stack'>;
|
|
13
13
|
export declare function reportStoryError(error: unknown, occupant?: Pick<StoryError, 'storyId' | 'variantId'>): void;
|
package/dist/types/command.d.ts
CHANGED
|
@@ -23,8 +23,16 @@ export interface ClientCommandOptions extends CommonCommandOptions {
|
|
|
23
23
|
export type ClientCommand = Command & ClientCommandOptions;
|
|
24
24
|
export interface ClientCommandContext {
|
|
25
25
|
route: RouteLocationNormalizedLoaded;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The story the route names, or undefined on any route that names none — the
|
|
28
|
+
* home page, or a story id that is not loaded. Declared non-optional here
|
|
29
|
+
* until #667: the app has always filled it from a `.find()`, so a plugin
|
|
30
|
+
* writing `ctx.currentStory.id` in `showIf` was reading a value the type
|
|
31
|
+
* promised and the app did not always supply.
|
|
32
|
+
*/
|
|
33
|
+
currentStory: Story | undefined;
|
|
34
|
+
/** The selected variant, or undefined. Null in the tick between a story being routed to and its variant being chosen. */
|
|
35
|
+
currentVariant: Variant | undefined;
|
|
28
36
|
}
|
|
29
37
|
export interface PluginCommand<TParams = Record<string, any>> extends Command {
|
|
30
38
|
serverAction?: (params: TParams) => unknown;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type MarkdownIt from 'markdown-it';
|
|
1
|
+
import type { MarkdownIt } from 'markdown-it';
|
|
2
2
|
import type { UseHeadInput } from 'unhead/types';
|
|
3
3
|
import type { UserConfig as ViteConfig, ConfigEnv as ViteConfigEnv } from 'vite';
|
|
4
4
|
import type { Plugin } from './plugin.js';
|
|
@@ -14,7 +14,7 @@ export type GrayColorKeys = ColorKeys | '750' | '850' | '950';
|
|
|
14
14
|
export interface ResponsivePreset {
|
|
15
15
|
label: string;
|
|
16
16
|
width: number;
|
|
17
|
-
height?: number;
|
|
17
|
+
height?: number | null;
|
|
18
18
|
}
|
|
19
19
|
export interface BackgroundPreset {
|
|
20
20
|
label: string;
|
|
@@ -76,7 +76,7 @@ export interface PovesteConfig {
|
|
|
76
76
|
groups?: TreeGroupConfig[];
|
|
77
77
|
};
|
|
78
78
|
/**
|
|
79
|
-
* Customize the look of the
|
|
79
|
+
* Customize the look of the book.
|
|
80
80
|
*/
|
|
81
81
|
theme: {
|
|
82
82
|
/**
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ import type { Awaitable } from '../type-utils.js';
|
|
|
7
7
|
import type { PluginCommand } from './command.js';
|
|
8
8
|
import type { ConfigMode, PovesteConfig } from './config.js';
|
|
9
9
|
import type { ServerStory, ServerStoryFile, ServerVariant } from './story.js';
|
|
10
|
+
/**
|
|
11
|
+
* A framework's collection strategy: how a story file written for that framework
|
|
12
|
+
* is imported and mounted. `@poveste/plugin-vue` and `@poveste/plugin-svelte`
|
|
13
|
+
* each expose one, and `supportMatch` in the config decides which files it claims.
|
|
14
|
+
*/
|
|
10
15
|
export interface SupportPlugin {
|
|
11
16
|
id: string;
|
|
12
17
|
moduleName: string;
|
|
@@ -14,37 +19,121 @@ export interface SupportPlugin {
|
|
|
14
19
|
importStoriesPrepend?: string;
|
|
15
20
|
importStoryComponent: (file: ServerStoryFile, index: number) => string;
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* A {@link SupportPlugin} after Poveste has resolved it. Identical to the
|
|
24
|
+
* declared shape today; it exists so resolution can add fields without changing
|
|
25
|
+
* what a plugin author writes.
|
|
26
|
+
*/
|
|
17
27
|
export interface FinalSupportPlugin extends SupportPlugin {
|
|
18
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Loads a module through Vite, so a plugin can read a user's `.ts` or `.vue`
|
|
31
|
+
* file the way the collector does rather than reaching for `import`.
|
|
32
|
+
*
|
|
33
|
+
* `loadModule` resolves to `undefined` on an error it has already logged, so a
|
|
34
|
+
* caller that needs to fail has to check the result. `clearCache` invalidates
|
|
35
|
+
* Vite's module graph as well as the runner's, which is what makes a re-read
|
|
36
|
+
* after a file change return the new contents.
|
|
37
|
+
*/
|
|
19
38
|
export interface ModuleLoader {
|
|
20
39
|
clearCache: () => void;
|
|
21
40
|
loadModule: (file: string) => Promise<any>;
|
|
22
41
|
destroy: () => void;
|
|
23
42
|
}
|
|
43
|
+
/** What changed under a path passed to `api.watch`. */
|
|
44
|
+
export type WatchEvent = 'add' | 'change' | 'unlink';
|
|
45
|
+
/** Called by `api.watch` with what happened and the absolute path it happened to. */
|
|
46
|
+
export type WatchCallback = (event: WatchEvent, path: string) => Awaitable<unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* What every plugin hook receives.
|
|
49
|
+
*
|
|
50
|
+
* Prefer `log`/`warn`/`error` over `console`: they prefix the plugin's name, so
|
|
51
|
+
* a line in a busy build says what printed it.
|
|
52
|
+
*/
|
|
24
53
|
export interface PluginApiBase {
|
|
54
|
+
/**
|
|
55
|
+
* Poveste's own picocolors.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated Import `picocolors` directly. Works for the rest of 0.x and is removable at 1.0 (#356).
|
|
58
|
+
*/
|
|
25
59
|
colors: typeof pc;
|
|
60
|
+
/**
|
|
61
|
+
* Poveste's own pathe.
|
|
62
|
+
*
|
|
63
|
+
* @deprecated Import `node:path`, or `pathe` for forward slashes on Windows. Works for the rest of
|
|
64
|
+
* 0.x and is removable at 1.0 (#356).
|
|
65
|
+
*/
|
|
26
66
|
path: typeof path;
|
|
67
|
+
/**
|
|
68
|
+
* Poveste's own fs-extra.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated Import `node:fs` or `node:fs/promises` directly. Works for the rest of 0.x and is
|
|
71
|
+
* removable at 1.0 (#356).
|
|
72
|
+
*/
|
|
27
73
|
fs: typeof fs;
|
|
28
74
|
moduleLoader: ModuleLoader;
|
|
29
75
|
readonly pluginTempDir: string;
|
|
30
|
-
log: (...msg:
|
|
31
|
-
warn: (...msg:
|
|
32
|
-
error: (...msg:
|
|
76
|
+
log: (...msg: unknown[]) => void;
|
|
77
|
+
warn: (...msg: unknown[]) => void;
|
|
78
|
+
error: (...msg: unknown[]) => void;
|
|
33
79
|
getStories: () => ServerStory[];
|
|
34
80
|
addStoryFile: (file: string) => void;
|
|
35
81
|
getConfig: () => PovesteConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Calls `callback` when a file under `paths` is added, changed or removed after
|
|
84
|
+
* the call. What already exists raises nothing.
|
|
85
|
+
*
|
|
86
|
+
* Poveste owns the watcher and closes it with the dev server, however the server
|
|
87
|
+
* ends, so a plugin has nothing to release. The returned function stops watching
|
|
88
|
+
* sooner. A callback that throws or rejects is logged with the plugin's name.
|
|
89
|
+
*
|
|
90
|
+
* Only `poveste dev` watches. In a build this does nothing, because a watcher
|
|
91
|
+
* opened while a failed build closes its server is what kept that build's
|
|
92
|
+
* process alive (#434).
|
|
93
|
+
*/
|
|
94
|
+
watch: (paths: string | string[], callback: WatchCallback) => () => Promise<void>;
|
|
36
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* {@link PluginApiBase} as passed to `onDev`.
|
|
98
|
+
*/
|
|
37
99
|
export interface PluginApiDev extends PluginApiBase {
|
|
100
|
+
/**
|
|
101
|
+
* Poveste's own chokidar module. A watcher opened from it is the plugin's to close.
|
|
102
|
+
*
|
|
103
|
+
* @deprecated Use {@link PluginApiBase.watch}, which Poveste closes with the dev server. Works for
|
|
104
|
+
* the rest of 0.x and is removable at 1.0 (#356).
|
|
105
|
+
*/
|
|
38
106
|
watcher: typeof chokidar;
|
|
39
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Mutates the Vite config Poveste is about to build with. Registered through
|
|
110
|
+
* `changeViteConfig`, and run once, before the build starts.
|
|
111
|
+
*/
|
|
40
112
|
export type ChangeViteConfigCallback = (config: ViteInlineConfig) => Awaitable<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Runs after a build **succeeds**. A build that fails never reaches it, which is
|
|
115
|
+
* why anything that must be released belongs in `onCleanup` instead (#434).
|
|
116
|
+
*/
|
|
41
117
|
export type BuildEndCallback = () => Awaitable<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Runs once per variant **after** the build has finished, against a preview
|
|
120
|
+
* server started for the purpose, with the URL that variant is served from.
|
|
121
|
+
* This is the hook a screenshot or visual-diff plugin uses.
|
|
122
|
+
*
|
|
123
|
+
* Registering one is what makes the build start that server at all, so a plugin
|
|
124
|
+
* that registers unconditionally adds a preview boot to every build.
|
|
125
|
+
*/
|
|
42
126
|
export type PreviewStoryCallback = (payload: {
|
|
43
127
|
file: string;
|
|
44
128
|
story: ServerStory;
|
|
45
129
|
variant: ServerVariant;
|
|
46
130
|
url: string;
|
|
47
131
|
}) => Awaitable<void>;
|
|
132
|
+
/**
|
|
133
|
+
* {@link PluginApiBase} plus the build hooks, passed to `onBuild`. The three
|
|
134
|
+
* arrays are the registered callbacks; the three functions are how a plugin adds
|
|
135
|
+
* to them.
|
|
136
|
+
*/
|
|
48
137
|
export interface PluginApiBuild extends PluginApiBase {
|
|
49
138
|
changeViteConfigCallbacks: ChangeViteConfigCallback[];
|
|
50
139
|
buildEndCallbacks: BuildEndCallback[];
|
|
@@ -53,17 +142,29 @@ export interface PluginApiBuild extends PluginApiBase {
|
|
|
53
142
|
onBuildEnd: (cb: BuildEndCallback) => void;
|
|
54
143
|
onPreviewStory: (cb: PreviewStoryCallback) => void;
|
|
55
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* {@link PluginApiBase} plus the event that triggered the hook, passed to
|
|
147
|
+
* `onDevEvent`. `payload` is whatever the client sent to `sendEvent`, unvalidated.
|
|
148
|
+
*/
|
|
56
149
|
export interface PluginApiDevEvent extends PluginApiBase {
|
|
57
150
|
event: string;
|
|
58
151
|
payload: any;
|
|
59
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* A Poveste plugin: a name and whichever hooks it needs. Listed in `plugins` in
|
|
155
|
+
* `poveste.config.ts`, and every hook is optional.
|
|
156
|
+
*
|
|
157
|
+
* The hooks below run in the order they are declared — `defaultConfig`, `config`
|
|
158
|
+
* and `configResolved` while the config settles, then `onDev`, `onBuild` or
|
|
159
|
+
* `onPreview` depending on the command.
|
|
160
|
+
*/
|
|
60
161
|
export interface Plugin {
|
|
61
162
|
/**
|
|
62
163
|
* Name of the plugin
|
|
63
164
|
*/
|
|
64
165
|
name: string;
|
|
65
166
|
/**
|
|
66
|
-
* Modify
|
|
167
|
+
* Modify Poveste's default config. The hook can either mutate the passed config or
|
|
67
168
|
* return a partial config object that will be deeply merged into the existing
|
|
68
169
|
* config. User config will have higher priority than default config.
|
|
69
170
|
*
|
|
@@ -72,7 +173,7 @@ export interface Plugin {
|
|
|
72
173
|
*/
|
|
73
174
|
defaultConfig?: (defaultConfig: PovesteConfig, mode: ConfigMode) => Partial<PovesteConfig> | null | void | Promise<Partial<PovesteConfig> | null | void>;
|
|
74
175
|
/**
|
|
75
|
-
* Modify
|
|
176
|
+
* Modify the Poveste config. The hook can either mutate the passed config or
|
|
76
177
|
* return a partial config object that will be deeply merged into the existing
|
|
77
178
|
* config.
|
|
78
179
|
*
|
|
@@ -81,7 +182,7 @@ export interface Plugin {
|
|
|
81
182
|
*/
|
|
82
183
|
config?: (config: PovesteConfig, mode: ConfigMode) => Partial<PovesteConfig> | null | void | Promise<Partial<PovesteConfig> | null | void>;
|
|
83
184
|
/**
|
|
84
|
-
* Use this hook to read and store the final resolved
|
|
185
|
+
* Use this hook to read and store the final resolved Poveste config.
|
|
85
186
|
*/
|
|
86
187
|
configResolved?: (config: PovesteConfig) => Awaitable<void>;
|
|
87
188
|
/**
|
|
@@ -91,8 +192,7 @@ export interface Plugin {
|
|
|
91
192
|
onDev?: (api: PluginApiDev, onCleanup: (cb: () => Awaitable<void>) => void) => Awaitable<void>;
|
|
92
193
|
/**
|
|
93
194
|
* Use this hook to do processing during production build.
|
|
94
|
-
|
|
95
|
-
/**
|
|
195
|
+
*
|
|
96
196
|
* `onCleanup` runs however the build ends, including when it fails. Anything a
|
|
97
197
|
* plugin opened belongs there rather than in `onBuildEnd`, which only runs when
|
|
98
198
|
* the build succeeded — a plugin holding a framework instance or a watcher kept
|
package/dist/types/story.d.ts
CHANGED
|
@@ -75,26 +75,26 @@ export interface VariantMeta extends CommonMeta {
|
|
|
75
75
|
export interface Variant {
|
|
76
76
|
id: string;
|
|
77
77
|
title: string;
|
|
78
|
-
icon?: string;
|
|
79
|
-
iconColor?: string;
|
|
80
|
-
setupApp?: (payload: any) => unknown;
|
|
81
|
-
slots?: () => {
|
|
78
|
+
icon?: string | undefined;
|
|
79
|
+
iconColor?: string | undefined;
|
|
80
|
+
setupApp?: ((payload: any) => unknown) | undefined;
|
|
81
|
+
slots?: (() => {
|
|
82
82
|
default: any;
|
|
83
83
|
controls: any;
|
|
84
84
|
source: any;
|
|
85
|
-
};
|
|
85
|
+
}) | undefined;
|
|
86
86
|
state: any;
|
|
87
|
-
source?: string;
|
|
88
|
-
responsiveDisabled?: boolean;
|
|
89
|
-
autoPropsDisabled?: boolean;
|
|
90
|
-
configReady?: boolean;
|
|
91
|
-
previewReady?: boolean;
|
|
92
|
-
meta?: VariantMeta;
|
|
87
|
+
source?: string | undefined;
|
|
88
|
+
responsiveDisabled?: boolean | undefined;
|
|
89
|
+
autoPropsDisabled?: boolean | undefined;
|
|
90
|
+
configReady?: boolean | undefined;
|
|
91
|
+
previewReady?: boolean | undefined;
|
|
92
|
+
meta?: VariantMeta | undefined;
|
|
93
93
|
}
|
|
94
94
|
export interface PropDefinition {
|
|
95
95
|
name: string;
|
|
96
|
-
types?: string[];
|
|
97
|
-
required?: boolean;
|
|
96
|
+
types?: string[] | undefined;
|
|
97
|
+
required?: boolean | undefined;
|
|
98
98
|
default?: any;
|
|
99
99
|
}
|
|
100
100
|
export interface AutoPropComponentDefinition {
|
|
@@ -123,7 +123,7 @@ export interface ServerStoryFile {
|
|
|
123
123
|
/**
|
|
124
124
|
* Generated path for tree UI
|
|
125
125
|
*/
|
|
126
|
-
treePath?: string[];
|
|
126
|
+
treePath?: string[] | undefined;
|
|
127
127
|
/**
|
|
128
128
|
* Use the module id in imports to allow HMR
|
|
129
129
|
*/
|
|
@@ -131,23 +131,23 @@ export interface ServerStoryFile {
|
|
|
131
131
|
/**
|
|
132
132
|
* Resolved story data from story file execution
|
|
133
133
|
*/
|
|
134
|
-
story?: ServerStory;
|
|
134
|
+
story?: ServerStory | undefined;
|
|
135
135
|
/**
|
|
136
136
|
* Data sent to user tree config functions
|
|
137
137
|
*/
|
|
138
|
-
treeFile?: ServerTreeFile;
|
|
138
|
+
treeFile?: ServerTreeFile | undefined;
|
|
139
139
|
/**
|
|
140
140
|
* Is virtual module
|
|
141
141
|
*/
|
|
142
|
-
virtual?: boolean;
|
|
142
|
+
virtual?: boolean | undefined;
|
|
143
143
|
/**
|
|
144
144
|
* Virtual module code
|
|
145
145
|
*/
|
|
146
|
-
moduleCode?: string;
|
|
146
|
+
moduleCode?: string | undefined;
|
|
147
147
|
/**
|
|
148
148
|
* Related markdown docs
|
|
149
149
|
*/
|
|
150
|
-
markdownFile?: ServerMarkdownFile;
|
|
150
|
+
markdownFile?: ServerMarkdownFile | undefined;
|
|
151
151
|
}
|
|
152
152
|
export interface ServerMarkdownFile {
|
|
153
153
|
id: string;
|
|
@@ -155,28 +155,28 @@ export interface ServerMarkdownFile {
|
|
|
155
155
|
absolutePath: string;
|
|
156
156
|
isRelatedToStory: boolean;
|
|
157
157
|
frontmatter?: any;
|
|
158
|
-
html?: string;
|
|
159
|
-
content?: string;
|
|
160
|
-
storyFile?: ServerStoryFile;
|
|
158
|
+
html?: string | undefined;
|
|
159
|
+
content?: string | undefined;
|
|
160
|
+
storyFile?: ServerStoryFile | undefined;
|
|
161
161
|
}
|
|
162
162
|
export interface ServerStory {
|
|
163
163
|
id: string;
|
|
164
164
|
title: string;
|
|
165
|
-
group?: string;
|
|
165
|
+
group?: string | undefined;
|
|
166
166
|
variants: ServerVariant[];
|
|
167
|
-
layout?: StoryLayout;
|
|
168
|
-
icon?: string;
|
|
169
|
-
iconColor?: string;
|
|
170
|
-
docsOnly?: boolean;
|
|
171
|
-
docsText?: string;
|
|
172
|
-
meta?: StoryMeta;
|
|
167
|
+
layout?: StoryLayout | undefined;
|
|
168
|
+
icon?: string | undefined;
|
|
169
|
+
iconColor?: string | undefined;
|
|
170
|
+
docsOnly?: boolean | undefined;
|
|
171
|
+
docsText?: string | undefined;
|
|
172
|
+
meta?: StoryMeta | undefined;
|
|
173
173
|
}
|
|
174
174
|
export interface ServerVariant {
|
|
175
175
|
id: string;
|
|
176
176
|
title: string;
|
|
177
|
-
icon?: string;
|
|
178
|
-
iconColor?: string;
|
|
179
|
-
meta?: VariantMeta;
|
|
177
|
+
icon?: string | undefined;
|
|
178
|
+
iconColor?: string | undefined;
|
|
179
|
+
meta?: VariantMeta | undefined;
|
|
180
180
|
}
|
|
181
181
|
export interface ServerTreeFile {
|
|
182
182
|
title: string;
|
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.15.0",
|
|
5
5
|
"description": "Shared utilities for Poveste",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan",
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"vite": "^8.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@poveste/vendors": "^0.
|
|
42
|
+
"@poveste/vendors": "^0.15.0",
|
|
43
43
|
"@types/fs-extra": "^11.0.4",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"pathe": "^
|
|
44
|
+
"chokidar": "^5.0.0",
|
|
45
|
+
"markdown-it": "^15.0.2",
|
|
46
|
+
"pathe": "^2.0.3",
|
|
47
47
|
"picocolors": "^1.1.1",
|
|
48
48
|
"unhead": "^3.1.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"typescript": "
|
|
51
|
+
"typescript": "6.0.3",
|
|
52
52
|
"vite": "^8.2.0",
|
|
53
|
-
"vitest": "^
|
|
53
|
+
"vitest": "^5.0.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "rimraf dist && tsc",
|