@bridge-ds/core 0.11.0 → 0.12.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/README.md +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +181 -30
- package/dist/index.js.map +1 -1
- package/dist/storybook.d.ts +94 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** One index entry, normalised across versions. */
|
|
2
|
+
export interface StorybookEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
/** Sidebar path, `/`-separated ("Forms/Button"). */
|
|
5
|
+
title: string;
|
|
6
|
+
/** Story or docs page name ("Primary", "Docs"). */
|
|
7
|
+
name: string;
|
|
8
|
+
type: 'story' | 'docs';
|
|
9
|
+
/** Storybook 9+ marks test entries `test`; stories are `story`. Absent before. */
|
|
10
|
+
subtype?: string;
|
|
11
|
+
importPath: string;
|
|
12
|
+
tags: string[];
|
|
13
|
+
exportName?: string;
|
|
14
|
+
componentPath?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Entries that share a title: one component (or one docs-only page such as "Intro"). */
|
|
17
|
+
export interface StorybookComponent {
|
|
18
|
+
title: string;
|
|
19
|
+
/** Last segment of the title ("Button" for "Forms/Button"). */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Segments before the name (["Forms"]); empty at the root. */
|
|
22
|
+
group: string[];
|
|
23
|
+
/** Story entries in index order (test entries excluded). */
|
|
24
|
+
stories: StorybookEntry[];
|
|
25
|
+
docs: StorybookEntry[];
|
|
26
|
+
/** Union of the entries' tags, sorted. */
|
|
27
|
+
tags: string[];
|
|
28
|
+
}
|
|
29
|
+
export type StorybookIndexSource = 'index.json' | 'stories.json';
|
|
30
|
+
export interface StorybookIndex {
|
|
31
|
+
/** The index's `v` field. */
|
|
32
|
+
version: number;
|
|
33
|
+
source: StorybookIndexSource;
|
|
34
|
+
entries: StorybookEntry[];
|
|
35
|
+
/** Grouped by title, sorted by title. */
|
|
36
|
+
components: StorybookComponent[];
|
|
37
|
+
}
|
|
38
|
+
export type StorybookErrorCode = 'invalid-url' | 'not-found' | 'not-json' | 'private' | 'empty' | 'http' | 'network';
|
|
39
|
+
export declare class StorybookIndexError extends Error {
|
|
40
|
+
readonly code: StorybookErrorCode;
|
|
41
|
+
readonly status?: number | undefined;
|
|
42
|
+
constructor(code: StorybookErrorCode, message: string, status?: number | undefined);
|
|
43
|
+
}
|
|
44
|
+
/** Groups entries by title. Test entries (subtype `test`) stay out of `stories`. */
|
|
45
|
+
export declare function groupStorybookComponents(entries: StorybookEntry[]): StorybookComponent[];
|
|
46
|
+
/**
|
|
47
|
+
* Parses an `index.json` (v4, v5) or `stories.json` (v3) body. Throws StorybookIndexError: `private` for a
|
|
48
|
+
* Chromatic login answer, `empty` when the body has no readable entries.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseStorybookIndex(json: unknown, source?: StorybookIndexSource): StorybookIndex;
|
|
51
|
+
/**
|
|
52
|
+
* The base address of a Storybook from what a person pastes: trims, drops the query and hash
|
|
53
|
+
* (`?path=/story/...`), a trailing `index.html` / `iframe.html` / `index.json` / `stories.json`, and trailing slashes.
|
|
54
|
+
* Throws `invalid-url` unless it is http(s); https is required except on localhost.
|
|
55
|
+
*/
|
|
56
|
+
export declare function normalizeStorybookUrl(input: string): string;
|
|
57
|
+
/** The index files to try, in order. */
|
|
58
|
+
export declare const storybookIndexUrls: (base: string) => {
|
|
59
|
+
url: string;
|
|
60
|
+
source: StorybookIndexSource;
|
|
61
|
+
}[];
|
|
62
|
+
export interface StorybookIframeOptions {
|
|
63
|
+
/** `story` (default) or `docs`. */
|
|
64
|
+
viewMode?: 'story' | 'docs';
|
|
65
|
+
/** Toolbar globals (`globals=brand:ocean;theme:dark`), in insertion order. */
|
|
66
|
+
globals?: Record<string, string>;
|
|
67
|
+
/** Story args (`args=label:Save`). */
|
|
68
|
+
args?: Record<string, string>;
|
|
69
|
+
}
|
|
70
|
+
/** URL of one story (or docs page) rendered alone: `<base>/iframe.html?id=<id>&viewMode=story[&globals=..][&args=..]`. */
|
|
71
|
+
export declare function storybookIframeUrl(base: string, id: string, o?: StorybookIframeOptions): string;
|
|
72
|
+
/** URL of a story or docs page in the full Storybook UI (sidebar and toolbar). */
|
|
73
|
+
export declare function storybookManagerUrl(base: string, id: string, viewMode?: 'story' | 'docs'): string;
|
|
74
|
+
export type StorybookFetch = (url: string, init?: {
|
|
75
|
+
headers?: Record<string, string>;
|
|
76
|
+
signal?: AbortSignal;
|
|
77
|
+
}) => Promise<{
|
|
78
|
+
ok: boolean;
|
|
79
|
+
status: number;
|
|
80
|
+
headers: {
|
|
81
|
+
get(name: string): string | null;
|
|
82
|
+
};
|
|
83
|
+
text(): Promise<string>;
|
|
84
|
+
}>;
|
|
85
|
+
export interface FetchStorybookIndexOptions {
|
|
86
|
+
fetch?: StorybookFetch;
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Reads a Storybook's index: `index.json`, then `stories.json`. A 404, an HTML answer (static hosts that fall back
|
|
91
|
+
* to index.html) or a body without entries moves on to the next file; the first readable index wins. Throws
|
|
92
|
+
* StorybookIndexError with the most telling failure (`private` before `not-json` before `not-found`).
|
|
93
|
+
*/
|
|
94
|
+
export declare function fetchStorybookIndex(base: string, o?: FetchStorybookIndexOptions): Promise<StorybookIndex>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridge-ds/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bridge core: bridge.config.json, DTCG token loading (tiers and layered modes), alias resolution, WCAG contrast, diffs, minimal-diff edits, PR body, the shared risk tier classifier, changesets and a fetch-based GitHub client. No Figma API, no DOM; Node-only helpers (git, reading a product folder) under @bridge-ds/core/node; the adoption audit under @bridge-ds/core/audit.",
|
|
6
6
|
"license": "MIT",
|