@bridge-ds/core 0.18.0 → 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.
- package/bridge.config.schema.json +16 -0
- package/dist/audit/index.js +3 -3
- package/dist/audit/report.d.ts +17 -2
- package/dist/branch-actions.d.ts +7 -1
- package/dist/build-requests-github.d.ts +25 -0
- package/dist/build-requests.d.ts +403 -0
- package/dist/changelog-model.d.ts +102 -0
- package/dist/component-spec.d.ts +3 -1
- package/dist/config.d.ts +21 -0
- package/dist/css-color.d.ts +25 -0
- package/dist/docs-proposal.d.ts +1 -0
- package/dist/explorations.d.ts +1 -0
- package/dist/fidelity-references.d.ts +12 -0
- package/dist/figma-fix-loop.d.ts +153 -0
- package/dist/figma-fixes.d.ts +169 -0
- package/dist/figma-push-github.d.ts +7 -2
- package/dist/figma-push.d.ts +15 -2
- package/dist/gap-case.d.ts +144 -0
- package/dist/github-client.d.ts +31 -0
- package/dist/id-map.d.ts +10 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +3412 -658
- package/dist/index.js.map +1 -1
- package/dist/layered-review.d.ts +2 -0
- package/dist/measure-status.d.ts +127 -0
- package/dist/measured-only.d.ts +28 -0
- package/dist/measured-spec.d.ts +349 -0
- package/dist/measured-tokens.d.ts +25 -0
- package/dist/motion-docs.d.ts +51 -0
- package/dist/node/audit.d.ts +11 -3
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1637 -24
- package/dist/node/index.js.map +1 -1
- package/dist/node/measure-script.d.ts +1 -0
- package/dist/node/measure.d.ts +212 -0
- package/dist/node/spec-css.d.ts +9 -1
- package/dist/node/tokens-script.d.ts +3 -0
- package/dist/pr-composer.d.ts +5 -0
- package/dist/previews.d.ts +4 -1
- package/dist/{prod-branch-DenQkr_e.js → prod-branch-Bdx_2bRQ.js} +197 -159
- package/dist/prod-branch-Bdx_2bRQ.js.map +1 -0
- package/dist/prod-branch.d.ts +1 -1
- package/dist/repo-model.d.ts +5 -1
- package/dist/repo-source-github.d.ts +8 -0
- package/dist/{repo-source-CRfhLO87.js → repo-source-m0Tc603o.js} +1406 -629
- package/dist/repo-source-m0Tc603o.js.map +1 -0
- package/dist/repo-source.d.ts +6 -0
- package/dist/{report-DVEmUr0p.js → report-DFPKygfk.js} +17 -6
- package/dist/{report-DVEmUr0p.js.map → report-DFPKygfk.js.map} +1 -1
- package/dist/requester.d.ts +14 -0
- package/dist/requests.d.ts +2 -0
- package/dist/review-gate.d.ts +183 -2
- package/dist/risk.d.ts +12 -0
- package/dist/share-branch.d.ts +1 -1
- package/dist/snapshot.d.ts +34 -0
- package/dist/suggestion-review.d.ts +2 -0
- package/dist/suggestions-github.d.ts +21 -0
- package/dist/suggestions.d.ts +6 -0
- package/dist/token-proposal.d.ts +7 -0
- package/dist/try-in-product.d.ts +9 -0
- package/package.json +1 -1
- package/dist/prod-branch-DenQkr_e.js.map +0 -1
- package/dist/repo-source-CRfhLO87.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MEASURE_SCRIPT: string;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import type { SpecLayout } from '../component-spec';
|
|
2
|
+
import { type MeasuredBox, type MeasuredNode, type MeasuredProps, type MeasuredSpec, type MeasuredState, type MeasuredTokens } from '../measured-spec';
|
|
3
|
+
import { type StorybookIframeOptions, type StorybookIndex } from '../storybook';
|
|
4
|
+
import { MEASURE_SCRIPT } from './measure-script';
|
|
5
|
+
import { GLOBALS_SCRIPT, TOKENS_SCRIPT } from './tokens-script';
|
|
6
|
+
export { MEASURE_SCRIPT, TOKENS_SCRIPT, GLOBALS_SCRIPT };
|
|
7
|
+
export * from '../measured-spec';
|
|
8
|
+
/** The script's answer for one page. */
|
|
9
|
+
export interface MeasureResult {
|
|
10
|
+
root: MeasuredNode | null;
|
|
11
|
+
/** Visible elements outside the story root (popups portaled to the body), up to 3. */
|
|
12
|
+
portals: MeasuredNode[];
|
|
13
|
+
/** Plain wrapper elements skipped above the root (decorators). */
|
|
14
|
+
wrappers: number;
|
|
15
|
+
nodes: number;
|
|
16
|
+
/** Style rules read, and stylesheets that could not be read (cross-origin). */
|
|
17
|
+
rules: number;
|
|
18
|
+
sheets: {
|
|
19
|
+
read: number;
|
|
20
|
+
blocked: number;
|
|
21
|
+
};
|
|
22
|
+
/** Custom properties in scope at the component (root and provider elements), the pool `matched` tokens come from. */
|
|
23
|
+
rootVariables: number;
|
|
24
|
+
/** Of those, the ones a provider element around the story defines, not the page root (Fluent's FluentProvider). */
|
|
25
|
+
scopedVariables?: number | undefined;
|
|
26
|
+
viewport: {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
/** The root is block-level and spans its container (or is width: 100%): it fills in Figma, it does not hug. */
|
|
31
|
+
rootFill?: boolean | undefined;
|
|
32
|
+
/** A filling root was laid out at this width (px) for the measure and its screenshot, not the canvas width. */
|
|
33
|
+
fillWidth?: number | undefined;
|
|
34
|
+
/** With `open`: how the popup came to show (`already`: the story renders it open), or `none`. */
|
|
35
|
+
opened?: 'already' | 'click' | 'hover' | 'focus' | 'none' | undefined;
|
|
36
|
+
error?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
export interface MeasuredStory extends MeasureResult {
|
|
39
|
+
/** With `shot`: the PNG written and the root's size in CSS pixels. */
|
|
40
|
+
shot?: {
|
|
41
|
+
file: string;
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
} | undefined;
|
|
45
|
+
/** The props the story rendered with, read from Storybook's story context (args over component defaults). */
|
|
46
|
+
props?: MeasuredProps | undefined;
|
|
47
|
+
/** The pseudo state forced on the component, when asked and the browser could force it. */
|
|
48
|
+
state?: MeasuredState | undefined;
|
|
49
|
+
id: string;
|
|
50
|
+
url: string;
|
|
51
|
+
/** Milliseconds from navigation to measured. */
|
|
52
|
+
ms: number;
|
|
53
|
+
}
|
|
54
|
+
/** The browser a measure runs in: a page that can open a URL and evaluate an expression (playwright's Page fits). */
|
|
55
|
+
export interface MeasurePage {
|
|
56
|
+
goto(url: string, options?: {
|
|
57
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
58
|
+
timeout?: number;
|
|
59
|
+
}): Promise<unknown>;
|
|
60
|
+
evaluate<T>(expression: string): Promise<T>;
|
|
61
|
+
/**
|
|
62
|
+
* Forces pseudo classes on every element matching `selector` (Chrome DevTools CSS.forcePseudoState), or clears
|
|
63
|
+
* them with []. Optional: without it, `state` is not measured.
|
|
64
|
+
*/
|
|
65
|
+
forcePseudo?(selector: string, states: string[]): Promise<boolean>;
|
|
66
|
+
/** PNG of the first element matching `selector`, written to `file`; its size in CSS pixels. Optional (shots). */
|
|
67
|
+
screenshot?(selector: string, file: string): Promise<{
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
} | null>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Tags the element a measure with these options reads (`data-bridge-measure-root`): the component after wrappers, the
|
|
74
|
+
* popup, or the `within` part. For a screenshot of exactly what was measured.
|
|
75
|
+
*/
|
|
76
|
+
export declare function markMeasuredRoot(page: MeasurePage, o?: Pick<MeasureOptions, 'root' | 'unwrap' | 'within' | 'target' | 'open'>): Promise<boolean>;
|
|
77
|
+
export interface MeasureOptions {
|
|
78
|
+
iframe?: StorybookIframeOptions | undefined;
|
|
79
|
+
/** Root selector inside the iframe (`#storybook-root, #root`: Storybook 7+ then 6). */
|
|
80
|
+
root?: string | undefined;
|
|
81
|
+
maxNodes?: number | undefined;
|
|
82
|
+
maxDepth?: number | undefined;
|
|
83
|
+
/** Longest wait for the story to render, ms (default 15000). */
|
|
84
|
+
timeout?: number | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Measure the open popup (a menu, a dialog, a select's list, a tooltip) instead of its trigger: when none shows yet,
|
|
87
|
+
* the first closed trigger in the story is clicked, then hovered and focused, and the popup portaled to the body is
|
|
88
|
+
* the measured root. Stories that render open (`defaultOpen` / `open` args) are measured as they are.
|
|
89
|
+
*/
|
|
90
|
+
open?: boolean | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* A part measured alone inside what rendered (the component, then its popups): `[role=menuitem]`, `[role=tab]`, a
|
|
93
|
+
* class. For parts that only render inside a parent or a portal (a menu item, an accordion item, a toast).
|
|
94
|
+
*/
|
|
95
|
+
within?: string | undefined;
|
|
96
|
+
/** Story args to render with (`{ size: 'lg', disabled: true }`), passed in the iframe URL. */
|
|
97
|
+
args?: Record<string, string | number | boolean> | undefined;
|
|
98
|
+
/** A pseudo state forced on the component before it is measured (needs `MeasurePage.forcePseudo`). */
|
|
99
|
+
state?: MeasuredState | undefined;
|
|
100
|
+
/** Read the story's props from Storybook (default true in measureStory). */
|
|
101
|
+
props?: boolean | undefined;
|
|
102
|
+
/** Width a filling root is laid out at when it spans the canvas (default 400 px; 0 keeps the canvas width). */
|
|
103
|
+
fillWidth?: number | undefined;
|
|
104
|
+
/** Write a PNG of the measured root to this file (needs `MeasurePage.screenshot`), forced state included. */
|
|
105
|
+
shot?: string | undefined;
|
|
106
|
+
/** `portal`: the newest popup outside the story root is the component (set by `open`). */
|
|
107
|
+
target?: 'root' | 'portal' | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Go down from the root through plain wrappers and viewport-size decorator canvases to the component (default true).
|
|
110
|
+
* false: the root element is the component.
|
|
111
|
+
*/
|
|
112
|
+
unwrap?: boolean | undefined;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Waits until the story has rendered: Storybook's root has content (or its error screen shows), fonts are loaded and
|
|
116
|
+
* the markup stops changing for a few frames. Resolves with `rendered`, `error` or `timeout`.
|
|
117
|
+
*/
|
|
118
|
+
export declare const WAIT_SCRIPT: (rootSel: string, timeout: number, self?: boolean) => string;
|
|
119
|
+
/**
|
|
120
|
+
* Opens the story's popup when none shows: clicks the first closed trigger (pointer and mouse events in order), then
|
|
121
|
+
* hovers and focuses it (tooltips), and waits for the portal to settle. Resolves with how it opened, or `none`.
|
|
122
|
+
*/
|
|
123
|
+
export declare const OPEN_SCRIPT: (rootSel: string) => string;
|
|
124
|
+
/**
|
|
125
|
+
* Reads the rendered story's props from Storybook's preview (7, 8, 9): its args (with URL overrides) over the component
|
|
126
|
+
* defaults docgen found, and the argTypes (enum options, booleans, texts). Plain values only; null when the preview
|
|
127
|
+
* exposes nothing.
|
|
128
|
+
*/
|
|
129
|
+
export declare const PROPS_SCRIPT: (id?: string) => string;
|
|
130
|
+
/**
|
|
131
|
+
* Token values as the open story resolves them (on the component, so provider-scoped variables count): token path ->
|
|
132
|
+
* computed value, colors as `rgb()` and lengths in px, for value-level comparison (compareSpecToMeasured's `resolve`).
|
|
133
|
+
*/
|
|
134
|
+
export declare function resolveTokenValues(page: MeasurePage, vars: Record<string, string>): Promise<Record<string, string>>;
|
|
135
|
+
export interface HarvestOptions {
|
|
136
|
+
iframe?: StorybookIframeOptions | undefined;
|
|
137
|
+
/** Read every mode the Storybook's globals expose (default true). */
|
|
138
|
+
modes?: boolean | undefined;
|
|
139
|
+
timeout?: number | undefined;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Every CSS custom property a Storybook's stylesheets define, read in one story: its declared value where the story
|
|
143
|
+
* sits (providers included), resolved there, in two tiers (a literal is a primitive, `var(--x)` is semantic), and again
|
|
144
|
+
* under each theme, brand or density global the Storybook exposes (one Figma mode per value).
|
|
145
|
+
*/
|
|
146
|
+
export declare function harvestTokens(page: MeasurePage, storybook: string, story: string, o?: HarvestOptions): Promise<MeasuredTokens>;
|
|
147
|
+
/**
|
|
148
|
+
* Makes sure the story renders with these args. Storybook drops URL args it cannot validate against a story's initial
|
|
149
|
+
* args (Carbon's Button story declares none), so when the store does not hold them after the first render they are
|
|
150
|
+
* sent the way the Controls panel sends them (`updateStoryArgs`), and the re-render is awaited. Resolves `url` (the URL
|
|
151
|
+
* args held), `channel`, or `failed`.
|
|
152
|
+
*/
|
|
153
|
+
export declare const APPLY_ARGS_SCRIPT: (id: string, args: Record<string, string | number | boolean>, timeout: number) => string;
|
|
154
|
+
/** Opens one story in its iframe and measures what it rendered. */
|
|
155
|
+
export declare function measureStory(page: MeasurePage, storybook: string, id: string, o?: MeasureOptions): Promise<MeasuredStory>;
|
|
156
|
+
/** Measures what the page shows now (a story already open, or re-rendered with new args): waits for it, then reads it. */
|
|
157
|
+
export declare function measureRendered(page: MeasurePage, o?: MeasureOptions): Promise<MeasureResult & {
|
|
158
|
+
ms: number;
|
|
159
|
+
state?: MeasuredState | undefined;
|
|
160
|
+
shot?: {
|
|
161
|
+
file: string;
|
|
162
|
+
width: number;
|
|
163
|
+
height: number;
|
|
164
|
+
} | undefined;
|
|
165
|
+
}>;
|
|
166
|
+
export interface StoryPick {
|
|
167
|
+
id: string;
|
|
168
|
+
title: string;
|
|
169
|
+
name: string;
|
|
170
|
+
}
|
|
171
|
+
export interface PickStoriesOptions {
|
|
172
|
+
/** Components by name or title, case-insensitive ("Button", "Forms/Input"). */
|
|
173
|
+
only?: string[] | undefined;
|
|
174
|
+
/** Exact story ids; replaces `only` and `perComponent`. */
|
|
175
|
+
ids?: string[] | undefined;
|
|
176
|
+
/** Stories per component, in index order (default 3). */
|
|
177
|
+
perComponent?: number | undefined;
|
|
178
|
+
}
|
|
179
|
+
/** The stories a measure opens: given ids, else the first stories of each (selected) component. */
|
|
180
|
+
export declare function pickStoriesToMeasure(index: StorybookIndex, o?: PickStoriesOptions): StoryPick[];
|
|
181
|
+
/**
|
|
182
|
+
* The instances of a story that renders a component several times (a "Sizes" story, a row of tags, a matrix table of
|
|
183
|
+
* colors by sizes): under layout-only frames, captions aside, the components found, when most are the same component.
|
|
184
|
+
* Returns [] for a story that renders one component: a radio group's radios are its own parts (the group has a role,
|
|
185
|
+
* so it is the component, not a layout).
|
|
186
|
+
*/
|
|
187
|
+
export declare function splitInstances(root: MeasuredNode | null): MeasuredNode[];
|
|
188
|
+
export interface MeasuredToSpecOptions {
|
|
189
|
+
/** CSS custom property -> token path. Default: the name without `--`, dashes as dots (`--space-2` -> `space.2`); private names (`--_bg`) are not tokens. */
|
|
190
|
+
tokenOf?: ((cssVar: string) => string | undefined) | undefined;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* CSS module local name from a built class: Vite (`_label_aukrr_131`, `_label_1x2y3`), webpack and Next
|
|
194
|
+
* (`Button_label__a1b2c`, `Button-module__label__a1b2c`), a prefixed scheme (`prc-Button-Label-pTQ3x`). Other classes come
|
|
195
|
+
* back as they are.
|
|
196
|
+
*/
|
|
197
|
+
export declare function localClassName(cls: string): string;
|
|
198
|
+
/**
|
|
199
|
+
* A class that says how an element looks, not what it is: a utility (`flex`, `px-4`, `hover:bg-blue`, `w-[12px]`,
|
|
200
|
+
* `-mt-1`) or a class a CSS-in-JS library generated from the styles (`css-1g7m1fs`, `sc-bdVaJa`). It changes with the
|
|
201
|
+
* look from one variant to the next, so it never names or pairs a part: tag and position do. A BEM or semantic
|
|
202
|
+
* class (`cds--btn__label`, `chakra-alert__title`, a CSS module's `label`) still does.
|
|
203
|
+
*/
|
|
204
|
+
export declare function isUtilityClass(cls: string): boolean;
|
|
205
|
+
export declare function measuredLayout(style: Record<string, string>, children?: MeasuredBox[]): SpecLayout | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* Turns a measured story into the spec shape: one part per drawn element (wrappers that draw nothing are kept as
|
|
208
|
+
* frames, text runs become text parts), values bound to the declared token when there is one.
|
|
209
|
+
*/
|
|
210
|
+
export declare function measuredToSpec(m: Pick<MeasuredStory, 'id' | 'root'> & {
|
|
211
|
+
rootFill?: boolean | undefined;
|
|
212
|
+
}, o?: MeasuredToSpecOptions): MeasuredSpec;
|
package/dist/node/spec-css.d.ts
CHANGED
|
@@ -74,7 +74,15 @@ export declare const DEFAULT_STATE: CssState;
|
|
|
74
74
|
export declare function splitTop(text: string, sep: string | RegExp): string[];
|
|
75
75
|
/** Parses one complex selector ("a > .b:hover .c"). Throws on syntax it does not know. */
|
|
76
76
|
export declare function parseSelector(text: string): Complex;
|
|
77
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* The viewport width a component in Figma is drawn for: the one Storybook renders the code images at
|
|
79
|
+
* (@bridge-ds/visual references, 1200 x 800). Width media queries are read against it.
|
|
80
|
+
*/
|
|
81
|
+
export declare const SPEC_VIEWPORT_WIDTH = 1200;
|
|
82
|
+
/**
|
|
83
|
+
* Media queries a component in Figma is drawn under: a mouse (hover: hover), a screen, and a viewport
|
|
84
|
+
* SPEC_VIEWPORT_WIDTH wide (`min-width` and `max-width` in px, alone or joined with `and`). Nothing else.
|
|
85
|
+
*/
|
|
78
86
|
export declare function mediaApplies(query: string): boolean;
|
|
79
87
|
/** Rules of one CSS module, in source order. `@media` blocks are kept only when they apply in Figma. */
|
|
80
88
|
export declare function parseCssModule(module: string, text: string, startOrder?: number): {
|
package/dist/pr-composer.d.ts
CHANGED
|
@@ -38,6 +38,11 @@ export interface PrInput {
|
|
|
38
38
|
path: string;
|
|
39
39
|
choice: 'figma' | 'edit' | 'main';
|
|
40
40
|
}[];
|
|
41
|
+
/**
|
|
42
|
+
* Pushed from the Figma plugin: design-approved (docs/BUILD-REQUESTS.md), so the tier line says what happens next
|
|
43
|
+
* instead of the approvals. Off unless set (the plugin passes it for a push).
|
|
44
|
+
*/
|
|
45
|
+
fromFigma?: boolean | undefined;
|
|
41
46
|
}
|
|
42
47
|
/** Where a token change comes from. The plugin, the CLI and the MCP server each pass their own. */
|
|
43
48
|
export interface PrOrigin {
|
package/dist/previews.d.ts
CHANGED
|
@@ -177,5 +177,8 @@ export declare const previewLinksOf: (previews: BranchPreview[]) => {
|
|
|
177
177
|
label: string;
|
|
178
178
|
url: string;
|
|
179
179
|
}[];
|
|
180
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* True when every configured app has a finished build: ready with its URL, or failed (a build Vercel refused, such as
|
|
182
|
+
* a rate limit, never gets a URL). Polling can stop.
|
|
183
|
+
*/
|
|
181
184
|
export declare const previewsSettled: (previews: BranchPreview[]) => boolean;
|