@usefragments/core 1.10.0 → 1.10.2
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/codes/index.d.ts +1 -1
- package/dist/compiled-types/index.d.ts +1 -1
- package/dist/generate/index.d.ts +1 -1
- package/dist/{governance-B5WWcmFY.d.ts → governance-CLk_wkP9.d.ts} +1 -1
- package/dist/index.d.ts +136 -357
- package/dist/index.js +7 -454
- package/dist/index.js.map +1 -1
- package/dist/preview-runtime.d.ts +48 -0
- package/dist/preview-runtime.js +91 -0
- package/dist/preview-runtime.js.map +1 -0
- package/dist/react-types.d.ts +3 -2
- package/dist/registry.d.ts +18 -18
- package/dist/schemas/index.d.ts +1 -1
- package/dist/storyAdapter.d.ts +187 -0
- package/dist/storyAdapter.js +371 -0
- package/dist/storyAdapter.js.map +1 -0
- package/dist/test-utils.d.ts +1 -1
- package/package.json +9 -1
- package/src/index.ts +0 -35
- package/src/react-create-element.test.ts +22 -0
- package/src/react-create-element.ts +12 -0
- package/src/react-types.ts +2 -1
- package/src/storyAdapter.ts +3 -2
- package/src/tokens/scss.test.ts +32 -1
- package/src/tokens/scss.ts +12 -7
- package/dist/{index-DtHxs0Pf.d.ts → index-_sxhUNqx.d.ts} +12 -12
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { V as VariantRenderOptions, a as VariantLoader } from './governance-CLk_wkP9.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import './topology/index.js';
|
|
6
|
+
import './types-xJ2xyp_G.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Minimal contract for rendering a preview variant.
|
|
10
|
+
* Compatible with fragment variants and Storybook-adapted variants.
|
|
11
|
+
*/
|
|
12
|
+
interface PreviewVariantLike {
|
|
13
|
+
render: (options?: VariantRenderOptions) => ReactNode;
|
|
14
|
+
loaders?: VariantLoader[];
|
|
15
|
+
}
|
|
16
|
+
interface PreviewRuntimeState {
|
|
17
|
+
content: ReactNode | null;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
error: Error | null;
|
|
20
|
+
loadedData?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
interface PreviewRuntimeOptions {
|
|
23
|
+
variant?: PreviewVariantLike | null;
|
|
24
|
+
loadedData?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execute all variant loaders and merge their payloads.
|
|
28
|
+
* `loadedData` is applied last so host-level overrides win.
|
|
29
|
+
*/
|
|
30
|
+
declare function executeVariantLoaders(loaders: VariantLoader[] | undefined, loadedData?: Record<string, unknown>): Promise<Record<string, unknown> | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a full runtime state (loader execution + render) in one async call.
|
|
33
|
+
* This is useful for testing and for hook/component orchestration.
|
|
34
|
+
*/
|
|
35
|
+
declare function resolvePreviewRuntimeState(options: PreviewRuntimeOptions): Promise<PreviewRuntimeState>;
|
|
36
|
+
/**
|
|
37
|
+
* Hook for rendering a preview variant with loader support.
|
|
38
|
+
*/
|
|
39
|
+
declare function usePreviewVariantRuntime(options: PreviewRuntimeOptions): PreviewRuntimeState;
|
|
40
|
+
interface PreviewVariantRuntimeProps extends PreviewRuntimeOptions {
|
|
41
|
+
children: (state: PreviewRuntimeState) => ReactNode;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Render-prop component wrapper around `usePreviewVariantRuntime`.
|
|
45
|
+
*/
|
|
46
|
+
declare function PreviewVariantRuntime({ variant, loadedData, children, }: PreviewVariantRuntimeProps): react_jsx_runtime.JSX.Element;
|
|
47
|
+
|
|
48
|
+
export { type PreviewRuntimeOptions, type PreviewRuntimeState, type PreviewVariantLike, PreviewVariantRuntime, executeVariantLoaders, resolvePreviewRuntimeState, usePreviewVariantRuntime };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// src/preview-runtime.tsx
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
+
var EMPTY_STATE = {
|
|
5
|
+
content: null,
|
|
6
|
+
isLoading: false,
|
|
7
|
+
error: null,
|
|
8
|
+
loadedData: void 0
|
|
9
|
+
};
|
|
10
|
+
function toError(error) {
|
|
11
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
12
|
+
}
|
|
13
|
+
async function executeVariantLoaders(loaders, loadedData) {
|
|
14
|
+
const hasLoaders = !!loaders && loaders.length > 0;
|
|
15
|
+
if (!hasLoaders) {
|
|
16
|
+
return loadedData;
|
|
17
|
+
}
|
|
18
|
+
const results = await Promise.all(loaders.map((loader) => loader()));
|
|
19
|
+
const mergedFromLoaders = results.reduce(
|
|
20
|
+
(acc, result) => ({ ...acc, ...result }),
|
|
21
|
+
{}
|
|
22
|
+
);
|
|
23
|
+
return loadedData ? { ...mergedFromLoaders, ...loadedData } : mergedFromLoaders;
|
|
24
|
+
}
|
|
25
|
+
async function resolvePreviewRuntimeState(options) {
|
|
26
|
+
const { variant, loadedData } = options;
|
|
27
|
+
if (!variant) {
|
|
28
|
+
return EMPTY_STATE;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const mergedLoadedData = await executeVariantLoaders(variant.loaders, loadedData);
|
|
32
|
+
const content = variant.render({ loadedData: mergedLoadedData });
|
|
33
|
+
return {
|
|
34
|
+
content,
|
|
35
|
+
isLoading: false,
|
|
36
|
+
error: null,
|
|
37
|
+
loadedData: mergedLoadedData
|
|
38
|
+
};
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return {
|
|
41
|
+
content: null,
|
|
42
|
+
isLoading: false,
|
|
43
|
+
error: toError(error),
|
|
44
|
+
loadedData: void 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function usePreviewVariantRuntime(options) {
|
|
49
|
+
const { variant, loadedData } = options;
|
|
50
|
+
const [state, setState] = useState(EMPTY_STATE);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
let cancelled = false;
|
|
53
|
+
if (!variant) {
|
|
54
|
+
setState(EMPTY_STATE);
|
|
55
|
+
return () => {
|
|
56
|
+
cancelled = true;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const hasLoaders = !!variant.loaders && variant.loaders.length > 0;
|
|
60
|
+
setState({
|
|
61
|
+
content: null,
|
|
62
|
+
isLoading: hasLoaders,
|
|
63
|
+
error: null,
|
|
64
|
+
loadedData: void 0
|
|
65
|
+
});
|
|
66
|
+
resolvePreviewRuntimeState({ variant, loadedData }).then((nextState) => {
|
|
67
|
+
if (!cancelled) {
|
|
68
|
+
setState(nextState);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return () => {
|
|
72
|
+
cancelled = true;
|
|
73
|
+
};
|
|
74
|
+
}, [variant, loadedData]);
|
|
75
|
+
return state;
|
|
76
|
+
}
|
|
77
|
+
function PreviewVariantRuntime({
|
|
78
|
+
variant,
|
|
79
|
+
loadedData,
|
|
80
|
+
children
|
|
81
|
+
}) {
|
|
82
|
+
const state = usePreviewVariantRuntime({ variant, loadedData });
|
|
83
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children(state) });
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
PreviewVariantRuntime,
|
|
87
|
+
executeVariantLoaders,
|
|
88
|
+
resolvePreviewRuntimeState,
|
|
89
|
+
usePreviewVariantRuntime
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=preview-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/preview-runtime.tsx"],"sourcesContent":["import { useEffect, useState, type ReactNode } from \"react\";\nimport type { VariantLoader, VariantRenderOptions } from \"./types.js\";\n\n/**\n * Minimal contract for rendering a preview variant.\n * Compatible with fragment variants and Storybook-adapted variants.\n */\nexport interface PreviewVariantLike {\n render: (options?: VariantRenderOptions) => ReactNode;\n loaders?: VariantLoader[];\n}\n\nexport interface PreviewRuntimeState {\n content: ReactNode | null;\n isLoading: boolean;\n error: Error | null;\n loadedData?: Record<string, unknown>;\n}\n\nexport interface PreviewRuntimeOptions {\n variant?: PreviewVariantLike | null;\n loadedData?: Record<string, unknown>;\n}\n\nconst EMPTY_STATE: PreviewRuntimeState = {\n content: null,\n isLoading: false,\n error: null,\n loadedData: undefined,\n};\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\n/**\n * Execute all variant loaders and merge their payloads.\n * `loadedData` is applied last so host-level overrides win.\n */\nexport async function executeVariantLoaders(\n loaders: VariantLoader[] | undefined,\n loadedData?: Record<string, unknown>,\n): Promise<Record<string, unknown> | undefined> {\n const hasLoaders = !!loaders && loaders.length > 0;\n if (!hasLoaders) {\n return loadedData;\n }\n\n const results = await Promise.all(loaders.map((loader) => loader()));\n const mergedFromLoaders = results.reduce<Record<string, unknown>>(\n (acc, result) => ({ ...acc, ...result }),\n {},\n );\n\n return loadedData ? { ...mergedFromLoaders, ...loadedData } : mergedFromLoaders;\n}\n\n/**\n * Resolve a full runtime state (loader execution + render) in one async call.\n * This is useful for testing and for hook/component orchestration.\n */\nexport async function resolvePreviewRuntimeState(\n options: PreviewRuntimeOptions,\n): Promise<PreviewRuntimeState> {\n const { variant, loadedData } = options;\n if (!variant) {\n return EMPTY_STATE;\n }\n\n try {\n const mergedLoadedData = await executeVariantLoaders(variant.loaders, loadedData);\n const content = variant.render({ loadedData: mergedLoadedData });\n return {\n content,\n isLoading: false,\n error: null,\n loadedData: mergedLoadedData,\n };\n } catch (error) {\n return {\n content: null,\n isLoading: false,\n error: toError(error),\n loadedData: undefined,\n };\n }\n}\n\n/**\n * Hook for rendering a preview variant with loader support.\n */\nexport function usePreviewVariantRuntime(\n options: PreviewRuntimeOptions,\n): PreviewRuntimeState {\n const { variant, loadedData } = options;\n const [state, setState] = useState<PreviewRuntimeState>(EMPTY_STATE);\n\n useEffect(() => {\n let cancelled = false;\n\n if (!variant) {\n setState(EMPTY_STATE);\n return () => {\n cancelled = true;\n };\n }\n\n const hasLoaders = !!variant.loaders && variant.loaders.length > 0;\n setState({\n content: null,\n isLoading: hasLoaders,\n error: null,\n loadedData: undefined,\n });\n\n resolvePreviewRuntimeState({ variant, loadedData }).then((nextState) => {\n if (!cancelled) {\n setState(nextState);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [variant, loadedData]);\n\n return state;\n}\n\ninterface PreviewVariantRuntimeProps extends PreviewRuntimeOptions {\n children: (state: PreviewRuntimeState) => ReactNode;\n}\n\n/**\n * Render-prop component wrapper around `usePreviewVariantRuntime`.\n */\nexport function PreviewVariantRuntime({\n variant,\n loadedData,\n children,\n}: PreviewVariantRuntimeProps) {\n const state = usePreviewVariantRuntime({ variant, loadedData });\n return <>{children(state)}</>;\n}\n"],"mappings":";AAAA,SAAS,WAAW,gBAAgC;AA8I3C;AAtHT,IAAM,cAAmC;AAAA,EACvC,SAAS;AAAA,EACT,WAAW;AAAA,EACX,OAAO;AAAA,EACP,YAAY;AACd;AAEA,SAAS,QAAQ,OAAuB;AACtC,SAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;AAMA,eAAsB,sBACpB,SACA,YAC8C;AAC9C,QAAM,aAAa,CAAC,CAAC,WAAW,QAAQ,SAAS;AACjD,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,MAAM,QAAQ,IAAI,QAAQ,IAAI,CAAC,WAAW,OAAO,CAAC,CAAC;AACnE,QAAM,oBAAoB,QAAQ;AAAA,IAChC,CAAC,KAAK,YAAY,EAAE,GAAG,KAAK,GAAG,OAAO;AAAA,IACtC,CAAC;AAAA,EACH;AAEA,SAAO,aAAa,EAAE,GAAG,mBAAmB,GAAG,WAAW,IAAI;AAChE;AAMA,eAAsB,2BACpB,SAC8B;AAC9B,QAAM,EAAE,SAAS,WAAW,IAAI;AAChC,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,mBAAmB,MAAM,sBAAsB,QAAQ,SAAS,UAAU;AAChF,UAAM,UAAU,QAAQ,OAAO,EAAE,YAAY,iBAAiB,CAAC;AAC/D,WAAO;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MACX,OAAO;AAAA,MACP,YAAY;AAAA,IACd;AAAA,EACF,SAAS,OAAO;AACd,WAAO;AAAA,MACL,SAAS;AAAA,MACT,WAAW;AAAA,MACX,OAAO,QAAQ,KAAK;AAAA,MACpB,YAAY;AAAA,IACd;AAAA,EACF;AACF;AAKO,SAAS,yBACd,SACqB;AACrB,QAAM,EAAE,SAAS,WAAW,IAAI;AAChC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA8B,WAAW;AAEnE,YAAU,MAAM;AACd,QAAI,YAAY;AAEhB,QAAI,CAAC,SAAS;AACZ,eAAS,WAAW;AACpB,aAAO,MAAM;AACX,oBAAY;AAAA,MACd;AAAA,IACF;AAEA,UAAM,aAAa,CAAC,CAAC,QAAQ,WAAW,QAAQ,QAAQ,SAAS;AACjE,aAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,OAAO;AAAA,MACP,YAAY;AAAA,IACd,CAAC;AAED,+BAA2B,EAAE,SAAS,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc;AACtE,UAAI,CAAC,WAAW;AACd,iBAAS,SAAS;AAAA,MACpB;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,SAAS,UAAU,CAAC;AAExB,SAAO;AACT;AASO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,GAA+B;AAC7B,QAAM,QAAQ,yBAAyB,EAAE,SAAS,WAAW,CAAC;AAC9D,SAAO,gCAAG,mBAAS,KAAK,GAAE;AAC5B;","names":[]}
|
package/dist/react-types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType, ReactNode, JSX } from 'react';
|
|
2
|
-
export { F as FragmentDefinition,
|
|
2
|
+
export { F as FragmentDefinition, b as FragmentDefinitionV2 } from './governance-CLk_wkP9.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import './topology/index.js';
|
|
5
5
|
import './types-xJ2xyp_G.js';
|
|
@@ -9,7 +9,8 @@ import './types-xJ2xyp_G.js';
|
|
|
9
9
|
*
|
|
10
10
|
* Import from '@usefragments/core/react' when you need React-typed
|
|
11
11
|
* component definitions. The main '@usefragments/core' entrypoint
|
|
12
|
-
* works without React installed
|
|
12
|
+
* works without React installed — story and preview-runtime APIs live on
|
|
13
|
+
* `@usefragments/core/story` and `@usefragments/core/preview-runtime`.
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
/**
|
package/dist/registry.d.ts
CHANGED
|
@@ -215,7 +215,7 @@ declare const registryComponentSchema: z.ZodObject<{
|
|
|
215
215
|
componentId: string;
|
|
216
216
|
name: string;
|
|
217
217
|
publicRef: string;
|
|
218
|
-
tier: "
|
|
218
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
219
219
|
provenance: Record<string, unknown>;
|
|
220
220
|
examples: unknown[];
|
|
221
221
|
files: {
|
|
@@ -263,7 +263,7 @@ declare const registryComponentSchema: z.ZodObject<{
|
|
|
263
263
|
status?: string | undefined;
|
|
264
264
|
category?: string | undefined;
|
|
265
265
|
contract?: unknown;
|
|
266
|
-
tier?: "
|
|
266
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
267
267
|
provenance?: Record<string, unknown> | undefined;
|
|
268
268
|
examples?: unknown[] | undefined;
|
|
269
269
|
styleFiles?: string[] | undefined;
|
|
@@ -497,7 +497,7 @@ declare const registryManifestDraftSchema: z.ZodObject<{
|
|
|
497
497
|
componentId: string;
|
|
498
498
|
name: string;
|
|
499
499
|
publicRef: string;
|
|
500
|
-
tier: "
|
|
500
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
501
501
|
provenance: Record<string, unknown>;
|
|
502
502
|
examples: unknown[];
|
|
503
503
|
files: {
|
|
@@ -545,7 +545,7 @@ declare const registryManifestDraftSchema: z.ZodObject<{
|
|
|
545
545
|
status?: string | undefined;
|
|
546
546
|
category?: string | undefined;
|
|
547
547
|
contract?: unknown;
|
|
548
|
-
tier?: "
|
|
548
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
549
549
|
provenance?: Record<string, unknown> | undefined;
|
|
550
550
|
examples?: unknown[] | undefined;
|
|
551
551
|
styleFiles?: string[] | undefined;
|
|
@@ -610,7 +610,7 @@ declare const registryManifestDraftSchema: z.ZodObject<{
|
|
|
610
610
|
componentId: string;
|
|
611
611
|
name: string;
|
|
612
612
|
publicRef: string;
|
|
613
|
-
tier: "
|
|
613
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
614
614
|
provenance: Record<string, unknown>;
|
|
615
615
|
examples: unknown[];
|
|
616
616
|
files: {
|
|
@@ -712,7 +712,7 @@ declare const registryManifestDraftSchema: z.ZodObject<{
|
|
|
712
712
|
status?: string | undefined;
|
|
713
713
|
category?: string | undefined;
|
|
714
714
|
contract?: unknown;
|
|
715
|
-
tier?: "
|
|
715
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
716
716
|
provenance?: Record<string, unknown> | undefined;
|
|
717
717
|
examples?: unknown[] | undefined;
|
|
718
718
|
styleFiles?: string[] | undefined;
|
|
@@ -970,7 +970,7 @@ declare const registryManifestSchema: z.ZodObject<{
|
|
|
970
970
|
componentId: string;
|
|
971
971
|
name: string;
|
|
972
972
|
publicRef: string;
|
|
973
|
-
tier: "
|
|
973
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
974
974
|
provenance: Record<string, unknown>;
|
|
975
975
|
examples: unknown[];
|
|
976
976
|
files: {
|
|
@@ -1018,7 +1018,7 @@ declare const registryManifestSchema: z.ZodObject<{
|
|
|
1018
1018
|
status?: string | undefined;
|
|
1019
1019
|
category?: string | undefined;
|
|
1020
1020
|
contract?: unknown;
|
|
1021
|
-
tier?: "
|
|
1021
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
1022
1022
|
provenance?: Record<string, unknown> | undefined;
|
|
1023
1023
|
examples?: unknown[] | undefined;
|
|
1024
1024
|
styleFiles?: string[] | undefined;
|
|
@@ -1085,7 +1085,7 @@ declare const registryManifestSchema: z.ZodObject<{
|
|
|
1085
1085
|
componentId: string;
|
|
1086
1086
|
name: string;
|
|
1087
1087
|
publicRef: string;
|
|
1088
|
-
tier: "
|
|
1088
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
1089
1089
|
provenance: Record<string, unknown>;
|
|
1090
1090
|
examples: unknown[];
|
|
1091
1091
|
files: {
|
|
@@ -1188,7 +1188,7 @@ declare const registryManifestSchema: z.ZodObject<{
|
|
|
1188
1188
|
status?: string | undefined;
|
|
1189
1189
|
category?: string | undefined;
|
|
1190
1190
|
contract?: unknown;
|
|
1191
|
-
tier?: "
|
|
1191
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
1192
1192
|
provenance?: Record<string, unknown> | undefined;
|
|
1193
1193
|
examples?: unknown[] | undefined;
|
|
1194
1194
|
styleFiles?: string[] | undefined;
|
|
@@ -1449,7 +1449,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1449
1449
|
componentId: string;
|
|
1450
1450
|
name: string;
|
|
1451
1451
|
publicRef: string;
|
|
1452
|
-
tier: "
|
|
1452
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
1453
1453
|
provenance: Record<string, unknown>;
|
|
1454
1454
|
examples: unknown[];
|
|
1455
1455
|
files: {
|
|
@@ -1497,7 +1497,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1497
1497
|
status?: string | undefined;
|
|
1498
1498
|
category?: string | undefined;
|
|
1499
1499
|
contract?: unknown;
|
|
1500
|
-
tier?: "
|
|
1500
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
1501
1501
|
provenance?: Record<string, unknown> | undefined;
|
|
1502
1502
|
examples?: unknown[] | undefined;
|
|
1503
1503
|
styleFiles?: string[] | undefined;
|
|
@@ -1564,7 +1564,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1564
1564
|
componentId: string;
|
|
1565
1565
|
name: string;
|
|
1566
1566
|
publicRef: string;
|
|
1567
|
-
tier: "
|
|
1567
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
1568
1568
|
provenance: Record<string, unknown>;
|
|
1569
1569
|
examples: unknown[];
|
|
1570
1570
|
files: {
|
|
@@ -1667,7 +1667,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1667
1667
|
status?: string | undefined;
|
|
1668
1668
|
category?: string | undefined;
|
|
1669
1669
|
contract?: unknown;
|
|
1670
|
-
tier?: "
|
|
1670
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
1671
1671
|
provenance?: Record<string, unknown> | undefined;
|
|
1672
1672
|
examples?: unknown[] | undefined;
|
|
1673
1673
|
styleFiles?: string[] | undefined;
|
|
@@ -1772,7 +1772,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1772
1772
|
componentId: string;
|
|
1773
1773
|
name: string;
|
|
1774
1774
|
publicRef: string;
|
|
1775
|
-
tier: "
|
|
1775
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
1776
1776
|
provenance: Record<string, unknown>;
|
|
1777
1777
|
examples: unknown[];
|
|
1778
1778
|
files: {
|
|
@@ -1885,7 +1885,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1885
1885
|
status?: string | undefined;
|
|
1886
1886
|
category?: string | undefined;
|
|
1887
1887
|
contract?: unknown;
|
|
1888
|
-
tier?: "
|
|
1888
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
1889
1889
|
provenance?: Record<string, unknown> | undefined;
|
|
1890
1890
|
examples?: unknown[] | undefined;
|
|
1891
1891
|
styleFiles?: string[] | undefined;
|
|
@@ -1978,7 +1978,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
1978
1978
|
componentId: string;
|
|
1979
1979
|
name: string;
|
|
1980
1980
|
publicRef: string;
|
|
1981
|
-
tier: "
|
|
1981
|
+
tier: "composition" | "core" | "custom" | "utility";
|
|
1982
1982
|
provenance: Record<string, unknown>;
|
|
1983
1983
|
examples: unknown[];
|
|
1984
1984
|
files: {
|
|
@@ -2091,7 +2091,7 @@ declare const registryArtifactSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2091
2091
|
status?: string | undefined;
|
|
2092
2092
|
category?: string | undefined;
|
|
2093
2093
|
contract?: unknown;
|
|
2094
|
-
tier?: "
|
|
2094
|
+
tier?: "composition" | "core" | "custom" | "utility" | undefined;
|
|
2095
2095
|
provenance?: Record<string, unknown> | undefined;
|
|
2096
2096
|
examples?: unknown[] | undefined;
|
|
2097
2097
|
styleFiles?: string[] | undefined;
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'zod';
|
|
2
2
|
export { LegacySeverityLevel, Severity, SeverityLevel, legacySeverityLevelSchema, severityLevelSchema, severitySchema } from '../severity.js';
|
|
3
|
-
export { b as AGENT_FORMAT_SCHEMA_VERSION, c as AgentErrorEnvelope, A as AgentFormat, d as AgentOutput, Q as FactEvidence, R as FactLocation, F as Finding, a as FindingFix, f as FindingReplaceClassTokenFix, g as FindingReplaceComponentFix, h as FindingReplaceImportFix, i as FindingReplacePropValueFix, j as FindingReplaceStyleValueFix, k as Fix, G as GovernanceVerdict, l as GovernanceVerdictMetadata, S as SuppressionDirective, V as ValidatorResult, n as Violation, o as agentErrorEnvelopeSchema, T as agentFindingSchema, p as agentFormatSchema, q as agentIntegritySchema, r as agentOutputSchema, U as agentPlanSchema, t as factEvidenceSchema, u as factLocationSchema, v as findingFixSchema, w as findingReplaceClassTokenFixSchema, x as findingReplaceComponentFixSchema, y as findingReplaceImportFixSchema, z as findingReplacePropValueFixSchema, B as findingReplaceStyleValueFixSchema, C as findingSchema, D as fixSchema, H as governanceVerdictMetadataSchema, J as governanceVerdictSchema, K as normalizeFinding, L as normalizeSeverity, M as normalizeViolation, N as suppressionDirectiveSchema, O as validatorResultSchema, P as violationSchema } from '../index-
|
|
3
|
+
export { b as AGENT_FORMAT_SCHEMA_VERSION, c as AgentErrorEnvelope, A as AgentFormat, d as AgentOutput, Q as FactEvidence, R as FactLocation, F as Finding, a as FindingFix, f as FindingReplaceClassTokenFix, g as FindingReplaceComponentFix, h as FindingReplaceImportFix, i as FindingReplacePropValueFix, j as FindingReplaceStyleValueFix, k as Fix, G as GovernanceVerdict, l as GovernanceVerdictMetadata, S as SuppressionDirective, V as ValidatorResult, n as Violation, o as agentErrorEnvelopeSchema, T as agentFindingSchema, p as agentFormatSchema, q as agentIntegritySchema, r as agentOutputSchema, U as agentPlanSchema, t as factEvidenceSchema, u as factLocationSchema, v as findingFixSchema, w as findingReplaceClassTokenFixSchema, x as findingReplaceComponentFixSchema, y as findingReplaceImportFixSchema, z as findingReplacePropValueFixSchema, B as findingReplaceStyleValueFixSchema, C as findingSchema, D as fixSchema, H as governanceVerdictMetadataSchema, J as governanceVerdictSchema, K as normalizeFinding, L as normalizeSeverity, M as normalizeViolation, N as suppressionDirectiveSchema, O as validatorResultSchema, P as violationSchema } from '../index-_sxhUNqx.js';
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { ReactNode, ComponentType } from 'react';
|
|
2
|
+
import { isExportStory as isExportStory$1, storyNameFromExport as storyNameFromExport$1, toId as toId$1 } from '@storybook/csf';
|
|
3
|
+
import { F as FragmentDefinition } from './governance-CLk_wkP9.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import './topology/index.js';
|
|
6
|
+
import './types-xJ2xyp_G.js';
|
|
7
|
+
|
|
8
|
+
declare const toId: typeof toId$1;
|
|
9
|
+
declare const storyNameFromExport: typeof storyNameFromExport$1;
|
|
10
|
+
declare const isExportStory: typeof isExportStory$1;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Runtime adapter for converting Storybook CSF modules to Fragment definitions.
|
|
14
|
+
*
|
|
15
|
+
* This operates on IMPORTED modules at runtime, not source code parsing.
|
|
16
|
+
* By leveraging Vite's module system, we get 100% accurate render functions
|
|
17
|
+
* without any regex or AST parsing complexity.
|
|
18
|
+
*
|
|
19
|
+
* Supports Storybook 8.x with both CSF2 (Template.bind) and CSF3 (object stories).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Storybook decorator function signature
|
|
24
|
+
*/
|
|
25
|
+
type Decorator = (Story: () => ReactNode, context: StoryContext) => ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Storybook loader function signature
|
|
28
|
+
*/
|
|
29
|
+
type Loader = (context: StoryContext) => Promise<Record<string, unknown>>;
|
|
30
|
+
/**
|
|
31
|
+
* Storybook play function signature (internal, extends StoryContext)
|
|
32
|
+
*/
|
|
33
|
+
type StorybookPlayFunction = (context: StorybookPlayFunctionContext) => Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Context passed to Storybook play functions (extends StoryContext for compatibility)
|
|
36
|
+
*/
|
|
37
|
+
interface StorybookPlayFunctionContext extends StoryContext {
|
|
38
|
+
canvasElement: HTMLElement;
|
|
39
|
+
step: (name: string, fn: () => Promise<void>) => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Context passed to decorators and render functions
|
|
43
|
+
*/
|
|
44
|
+
interface StoryContext {
|
|
45
|
+
args: Record<string, unknown>;
|
|
46
|
+
argTypes: Record<string, StoryArgType>;
|
|
47
|
+
globals: Record<string, unknown>;
|
|
48
|
+
parameters: Record<string, unknown>;
|
|
49
|
+
id: string;
|
|
50
|
+
kind: string;
|
|
51
|
+
name: string;
|
|
52
|
+
story: string;
|
|
53
|
+
viewMode: "story" | "docs";
|
|
54
|
+
loaded: Record<string, unknown>;
|
|
55
|
+
abortSignal: AbortSignal;
|
|
56
|
+
componentId: string;
|
|
57
|
+
title: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Storybook Meta (default export)
|
|
61
|
+
*/
|
|
62
|
+
interface StoryMeta {
|
|
63
|
+
title?: string;
|
|
64
|
+
component?: ComponentType<unknown>;
|
|
65
|
+
subcomponents?: Record<string, ComponentType<unknown>>;
|
|
66
|
+
tags?: string[];
|
|
67
|
+
parameters?: Record<string, unknown> & {
|
|
68
|
+
docs?: {
|
|
69
|
+
description?: {
|
|
70
|
+
component?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
argTypes?: Record<string, StoryArgType>;
|
|
75
|
+
args?: Record<string, unknown>;
|
|
76
|
+
decorators?: Decorator[];
|
|
77
|
+
loaders?: Loader[];
|
|
78
|
+
render?: (args: Record<string, unknown>, context?: StoryContext) => ReactNode;
|
|
79
|
+
includeStories?: string[] | RegExp;
|
|
80
|
+
excludeStories?: string[] | RegExp;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Storybook argType definition
|
|
84
|
+
*/
|
|
85
|
+
interface StoryArgType {
|
|
86
|
+
control?: string | false | {
|
|
87
|
+
type: string;
|
|
88
|
+
min?: number;
|
|
89
|
+
max?: number;
|
|
90
|
+
step?: number;
|
|
91
|
+
presetColors?: string[];
|
|
92
|
+
};
|
|
93
|
+
options?: string[];
|
|
94
|
+
description?: string;
|
|
95
|
+
table?: {
|
|
96
|
+
defaultValue?: {
|
|
97
|
+
summary: string;
|
|
98
|
+
};
|
|
99
|
+
type?: {
|
|
100
|
+
summary: string;
|
|
101
|
+
};
|
|
102
|
+
category?: string;
|
|
103
|
+
subcategory?: string;
|
|
104
|
+
disable?: boolean;
|
|
105
|
+
};
|
|
106
|
+
type?: {
|
|
107
|
+
name: string;
|
|
108
|
+
required?: boolean;
|
|
109
|
+
};
|
|
110
|
+
name?: string;
|
|
111
|
+
defaultValue?: unknown;
|
|
112
|
+
if?: {
|
|
113
|
+
arg?: string;
|
|
114
|
+
exists?: boolean;
|
|
115
|
+
};
|
|
116
|
+
mapping?: Record<string, unknown>;
|
|
117
|
+
action?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Storybook Story export (CSF3)
|
|
121
|
+
*/
|
|
122
|
+
interface Story {
|
|
123
|
+
args?: Record<string, unknown>;
|
|
124
|
+
argTypes?: Record<string, StoryArgType>;
|
|
125
|
+
render?: (args: Record<string, unknown>, context?: StoryContext) => ReactNode;
|
|
126
|
+
decorators?: Decorator[];
|
|
127
|
+
loaders?: Loader[];
|
|
128
|
+
play?: StorybookPlayFunction;
|
|
129
|
+
parameters?: Record<string, unknown> & {
|
|
130
|
+
docs?: {
|
|
131
|
+
description?: {
|
|
132
|
+
story?: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
name?: string;
|
|
137
|
+
storyName?: string;
|
|
138
|
+
tags?: string[];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* CSF2 story function (from Template.bind({})) with args attached
|
|
142
|
+
*/
|
|
143
|
+
type CSF2Story = ((args: Record<string, unknown>) => ReactNode) & {
|
|
144
|
+
args?: Record<string, unknown>;
|
|
145
|
+
argTypes?: Record<string, StoryArgType>;
|
|
146
|
+
decorators?: Decorator[];
|
|
147
|
+
loaders?: Loader[];
|
|
148
|
+
play?: StorybookPlayFunction;
|
|
149
|
+
parameters?: Record<string, unknown>;
|
|
150
|
+
storyName?: string;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* A complete Storybook module with default meta and named story exports
|
|
154
|
+
*/
|
|
155
|
+
interface StoryModule {
|
|
156
|
+
default: StoryMeta;
|
|
157
|
+
[exportName: string]: Story | CSF2Story | StoryMeta | unknown;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Global configuration from preview.tsx
|
|
161
|
+
*/
|
|
162
|
+
interface PreviewConfig {
|
|
163
|
+
decorators?: Decorator[];
|
|
164
|
+
parameters?: Record<string, unknown>;
|
|
165
|
+
globalTypes?: Record<string, unknown>;
|
|
166
|
+
args?: Record<string, unknown>;
|
|
167
|
+
argTypes?: Record<string, StoryArgType>;
|
|
168
|
+
loaders?: Loader[];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Set the global preview configuration loaded from .storybook/preview.tsx
|
|
172
|
+
*/
|
|
173
|
+
declare function setPreviewConfig(config: PreviewConfig): void;
|
|
174
|
+
/**
|
|
175
|
+
* Get the current global preview configuration
|
|
176
|
+
*/
|
|
177
|
+
declare function getPreviewConfig(): PreviewConfig;
|
|
178
|
+
/**
|
|
179
|
+
* Convert a Storybook module to a Fragment definition at runtime.
|
|
180
|
+
*
|
|
181
|
+
* @param storyModule - The imported Storybook module
|
|
182
|
+
* @param filePath - File path for metadata extraction
|
|
183
|
+
* @returns A complete FragmentDefinition ready for the viewer
|
|
184
|
+
*/
|
|
185
|
+
declare function storyModuleToFragment(storyModule: StoryModule, filePath: string): FragmentDefinition | null;
|
|
186
|
+
|
|
187
|
+
export { type CSF2Story, type Decorator, type Loader, type PreviewConfig, type Story, type StoryArgType, type StoryContext, type StoryMeta, type StoryModule, getPreviewConfig, isExportStory, setPreviewConfig, storyModuleToFragment, storyNameFromExport, toId };
|