@gtkx/storybook 0.0.1 → 2.0.0-beta.12

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/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
2
  import type { ComponentType, ReactNode } from "react";
3
- import type { ComponentAnnotations, GlobalTypes, Renderer, ArgTypes as StorybookArgTypes, StoryContext as StorybookContext } from "storybook/internal/types";
3
+ import type { ArgsFromMeta, ComponentAnnotations, GlobalTypes, Renderer, StoryAnnotations as StorybookAnnotations, ArgTypes as StorybookArgTypes, StoryContext as StorybookContext } from "storybook/internal/types";
4
4
  /** Named values supplied to a story, including component props and custom render args. */
5
5
  type Args = Record<string, unknown>;
6
6
  /** Storybook renderer types for React content rendered as native GTK widgets. */
@@ -60,22 +60,12 @@ type ComponentOrProps<T> = T extends ComponentType<infer Props extends object> ?
60
60
  type Simplify<T> = {
61
61
  [Key in keyof T]: T[Key];
62
62
  };
63
- /** Combines the argument requirements of every member of a union. */
64
- type UnionToIntersection<T> = (T extends unknown ? (value: T) => void : never) extends (value: infer Intersection) => void ? Intersection : never;
65
- /** Retains explicitly named args while removing broad index signatures. */
66
- type DeclaredArgs<T> = {
67
- [Key in keyof T as string extends Key ? never : number extends Key ? never : symbol extends Key ? never : Key]: T[Key];
68
- };
69
- /** Extracts the args accepted by a custom render function. */
70
- type RenderArgs<T> = T extends (args: infer Props extends object, context: never) => ReactNode ? Props : object;
71
- /** Combines the args required by a metadata object's decorators. */
72
- type DecoratorArgs<T> = T extends readonly (infer Item)[] ? UnionToIntersection<Item extends Decorator<infer Props extends object> ? Props : object> : object;
73
63
  /** Infers story args from component props, render functions, decorators, or declared defaults. */
74
64
  type ArgsFrom<T> = T extends {
75
65
  component?: infer Component;
76
- render?: infer Render;
77
- decorators?: infer Decorators;
78
- } ? Simplify<(NonNullable<Component> extends ComponentType<infer Props extends object> ? Props : object) & DeclaredArgs<RenderArgs<NonNullable<Render>> & DecoratorArgs<NonNullable<Decorators>>>> : T extends {
66
+ render?: unknown;
67
+ decorators?: unknown;
68
+ } ? Simplify<(NonNullable<Component> extends ComponentType<infer Props extends object> ? Props : object) & ArgsFromMeta<NativeRenderer, T>> : T extends {
79
69
  args: infer Defaults extends object;
80
70
  } ? Defaults : Args;
81
71
  /** CSF3 default export metadata typed from a React component or an explicit args type. */
@@ -99,11 +89,7 @@ type StoryObj<T = Args> = T extends {
99
89
  render?: unknown;
100
90
  decorators?: unknown;
101
91
  args?: unknown;
102
- } ? StoryAnnotations<ArgsFrom<T>> & (Record<never, never> extends RequiredStoryArgs<T, ArgsFrom<T>> ? {
103
- args?: RequiredStoryArgs<T, ArgsFrom<T>>;
104
- } : {
105
- args: RequiredStoryArgs<T, ArgsFrom<T>>;
106
- }) : StoryAnnotations<ComponentOrProps<T>>;
92
+ } ? StoryAnnotations<ArgsFrom<T>> & Pick<StorybookAnnotations<NativeRenderer<ArgsFrom<T>>, ArgsFrom<T>, RequiredStoryArgs<T, ArgsFrom<T>>>, "args"> : StoryAnnotations<ComponentOrProps<T>>;
107
93
  /** Project annotations shared by all composed stories. */
108
94
  type Preview = Annotations<Args> & {
109
95
  /** Initial global values available in story rendering and decorators. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EACR,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,IAAI,iBAAiB,EAC7B,YAAY,IAAI,gBAAgB,EACnC,MAAM,0BAA0B,CAAC;AAElC,0FAA0F;AAC1F,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,iFAAiF;AACjF,KAAK,cAAc,CAAC,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,CAAC,GAAG,CAAC,SAAS,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GACjE,GAAG,GACH,KAAK;CAChB,CAAC,MAAM,OAAO,CAAC,GACZ,MAAM,CAAC;AAEX,8DAA8D;AAC9D,KAAK,eAAe,CAAC,OAAO,SAAS,WAAW,IAAI,MAAM,CACtD,SAAS,CAAC,OAAO,CAAC,EAClB,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAC9C,CAAC;AAEF,YAAY,EACR,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,WAAW,GACd,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport type {\n ComponentAnnotations,\n GlobalTypes,\n Renderer,\n ArgTypes as StorybookArgTypes,\n StoryContext as StorybookContext,\n} from \"storybook/internal/types\";\n\n/** Named values supplied to a story, including component props and custom render args. */\ntype Args = Record<string, unknown>;\n\n/** Storybook renderer types for React content rendered as native GTK widgets. */\ntype NativeRenderer<TArgs extends object = Args> = Renderer & {\n /** React component receiving the story's args. */\n component: ComponentType<TArgs>;\n /** React content returned by story rendering. */\n storyResult: ReactNode;\n /** Native widget type representing the preview canvas. */\n canvasElement: Gtk.Widget;\n};\n\n/** Explicit argument metadata used to configure native controls and named actions. */\ntype ArgTypes<TArgs extends object = Args> = Partial<StorybookArgTypes<TArgs>>;\n\n/** Composed story identity, args, and annotations available to render functions and decorators. */\ntype StoryContext<TArgs extends object = Args> = Pick<\n StorybookContext<NativeRenderer<TArgs>, TArgs>,\n \"id\" | \"name\" | \"title\" | \"args\" | \"initialArgs\" | \"argTypes\" | \"viewMode\"\n> & {\n /** Parameters merged from preview, component metadata, and the story. */\n parameters: Args;\n /** Global values after applying preview defaults and metadata or story overrides. */\n globals: Args;\n};\n\n/** Renders native React content from the current story args and composition context. */\ntype StoryRender<TArgs extends object = Args> = (args: TArgs, context: StoryContext<TArgs>) => ReactNode;\n\n/** Values a decorator can override when invoking the decorated story. */\ntype StoryContextUpdate<TArgs extends object = Args> = {\n /** Partial args merged into the current invocation without changing composed defaults. */\n args?: Partial<TArgs>;\n /** Global values overridden for the decorated invocation. */\n globals?: Args;\n};\n\n/** Wraps story content and can override args or globals when invoking the supplied Story function. */\ntype Decorator<TArgs extends object = Args> = (\n Story: (update?: StoryContextUpdate<TArgs>) => ReactNode,\n context: StoryContext<TArgs>,\n) => ReactNode;\n\n/** Shared CSF annotations accepted at preview, component, and story scope. */\ntype Annotations<TArgs extends object> = {\n /** Default args, with more specific annotation scopes taking precedence. */\n args?: Partial<TArgs>;\n /** Explicit argument descriptions, controls, and action registrations. */\n argTypes?: ArgTypes<TArgs>;\n /** Parameters merged across scopes, including native preview and layout settings. */\n parameters?: Args;\n /** Wrappers composed around the story's render function. */\n decorators?: Decorator<TArgs>[];\n /** Custom renderer used in place of the component or a less specific render annotation. */\n render?: StoryRender<TArgs>;\n /** Storybook tags composed with tags from other annotation scopes. */\n tags?: string[];\n};\n\n/** Default export metadata describing a component's stories and their shared annotations. */\ntype ComponentMeta<TArgs extends object> = Annotations<TArgs> & Pick<\n ComponentAnnotations<NativeRenderer<TArgs>, TArgs>,\n \"title\" | \"id\" | \"includeStories\" | \"excludeStories\"\n> & {\n /** Component rendered with story args when no custom render annotation applies. */\n component?: ComponentType<TArgs>;\n /** Global overrides shared by this component's stories. */\n globals?: Args;\n};\n\n/** Resolves a component's props or accepts an explicitly supplied args object type. */\ntype ComponentOrProps<T> = T extends ComponentType<infer Props extends object>\n ? Props\n : T extends object ? T : Args;\n\n/** Presents combined inferred args as a single object type. */\ntype Simplify<T> = { [Key in keyof T]: T[Key] };\n\n/** Combines the argument requirements of every member of a union. */\ntype UnionToIntersection<T> = (\n T extends unknown ? (value: T) => void : never\n) extends (value: infer Intersection) => void ? Intersection : never;\n\n/** Retains explicitly named args while removing broad index signatures. */\ntype DeclaredArgs<T> = {\n [Key in keyof T as string extends Key\n ? never\n : number extends Key ? never : symbol extends Key ? never : Key]: T[Key];\n};\n\n/** Extracts the args accepted by a custom render function. */\ntype RenderArgs<T> = T extends (args: infer Props extends object, context: never) => ReactNode ? Props : object;\n\n/** Combines the args required by a metadata object's decorators. */\ntype DecoratorArgs<T> = T extends readonly (infer Item)[]\n ? UnionToIntersection<Item extends Decorator<infer Props extends object> ? Props : object>\n : object;\n\n/** Infers story args from component props, render functions, decorators, or declared defaults. */\ntype ArgsFrom<T> = T extends { component?: infer Component; render?: infer Render; decorators?: infer Decorators }\n ? Simplify<\n (NonNullable<Component> extends ComponentType<infer Props extends object> ? Props : object) &\n DeclaredArgs<RenderArgs<NonNullable<Render>> & DecoratorArgs<NonNullable<Decorators>>>\n >\n : T extends { args: infer Defaults extends object } ? Defaults : Args;\n\n/** CSF3 default export metadata typed from a React component or an explicit args type. */\ntype Meta<T = Args> = ComponentMeta<ComponentOrProps<T>>;\n\n/** Annotations for one CSF3 story object, including its display name and global overrides. */\ntype StoryAnnotations<TArgs extends object> = Annotations<TArgs> & {\n /** Display name overriding the name derived from the story's named export. */\n name?: string;\n /** Global overrides applied specifically to this story. */\n globals?: Args;\n};\n\n/** Extracts args already defaulted by component metadata. */\ntype DefaultArgs<T> = T extends { args: infer Defaults } ? Defaults : Record<never, never>;\n\n/** Makes args with metadata defaults optional while preserving other required args. */\ntype RequiredStoryArgs<T, TArgs extends object> =\n Omit<TArgs, keyof DefaultArgs<T>> & Partial<Pick<TArgs, keyof TArgs & keyof DefaultArgs<T>>>;\n\n/** CSF3 story object inferred from metadata, a React component, or an explicit args type. */\ntype StoryObj<T = Args> = T extends { component?: unknown; render?: unknown; decorators?: unknown; args?: unknown }\n ? StoryAnnotations<ArgsFrom<T>> & (Record<never, never> extends RequiredStoryArgs<T, ArgsFrom<T>>\n ? { args?: RequiredStoryArgs<T, ArgsFrom<T>> }\n : { args: RequiredStoryArgs<T, ArgsFrom<T>> })\n : StoryAnnotations<ComponentOrProps<T>>;\n\n/** Project annotations shared by all composed stories. */\ntype Preview = Annotations<Args> & {\n /** Initial global values available in story rendering and decorators. */\n initialGlobals?: Args;\n /** Storybook metadata describing global values; native toolbar controls are not provided. */\n globalTypes?: GlobalTypes;\n};\n\n/** Renderable story with merged annotations; props override its composed default args. */\ntype ComposedStory<TArgs extends object = Args> = ((args: Partial<TArgs>) => ReactNode) & {\n /** Default args merged across preview, component metadata, and story annotations. */\n args: Partial<TArgs>;\n /** Composed argument metadata available to native controls and actions. */\n argTypes: ArgTypes<TArgs>;\n /** Composed parameters available to the renderer and explorer. */\n parameters: Args;\n /** Composed global values available in story context. */\n globals: Args;\n /** Storybook identifier derived from component identity and the story export. */\n id: string;\n /** Story name attached by Storybook's portable composition API. */\n storyName: string;\n /** Tags resulting from composition across annotation scopes. */\n tags: string[];\n};\n\n/** Imported CSF module containing default metadata and named story exports. */\ntype StoryModule = {\n /** Component metadata validated when the module is composed. */\n default: unknown;\n};\n\n/** Named module exports whose types match CSF3 stories, excluding module bookkeeping. */\ntype StoryKeys<TModule extends StoryModule> = {\n [Key in keyof TModule]: Key extends \"default\" | \"__esModule\" | \"__namedExportsOrder\"\n ? never\n : TModule[Key] extends StoryAnnotations<ArgsFrom<TModule[\"default\"]>>\n ? Key\n : never;\n}[keyof TModule] & string;\n\n/** Composed stories keyed by their original named exports. */\ntype ComposedStories<TModule extends StoryModule> = Record<\n StoryKeys<TModule>,\n ComposedStory<ArgsFrom<TModule[\"default\"]>>\n>;\n\nexport type {\n Args,\n ArgTypes,\n ComponentMeta,\n ComposedStories,\n ComposedStory,\n Decorator,\n Meta,\n Preview,\n StoryAnnotations,\n StoryContext,\n StoryContextUpdate,\n StoryModule,\n StoryObj,\n StoryRender,\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport type {\n ArgsFromMeta,\n ComponentAnnotations,\n GlobalTypes,\n Renderer,\n StoryAnnotations as StorybookAnnotations,\n ArgTypes as StorybookArgTypes,\n StoryContext as StorybookContext,\n} from \"storybook/internal/types\";\n\n/** Named values supplied to a story, including component props and custom render args. */\ntype Args = Record<string, unknown>;\n\n/** Storybook renderer types for React content rendered as native GTK widgets. */\ntype NativeRenderer<TArgs extends object = Args> = Renderer & {\n /** React component receiving the story's args. */\n component: ComponentType<TArgs>;\n /** React content returned by story rendering. */\n storyResult: ReactNode;\n /** Native widget type representing the preview canvas. */\n canvasElement: Gtk.Widget;\n};\n\n/** Explicit argument metadata used to configure native controls and named actions. */\ntype ArgTypes<TArgs extends object = Args> = Partial<StorybookArgTypes<TArgs>>;\n\n/** Composed story identity, args, and annotations available to render functions and decorators. */\ntype StoryContext<TArgs extends object = Args> = Pick<\n StorybookContext<NativeRenderer<TArgs>, TArgs>,\n \"id\" | \"name\" | \"title\" | \"args\" | \"initialArgs\" | \"argTypes\" | \"viewMode\"\n> & {\n /** Parameters merged from preview, component metadata, and the story. */\n parameters: Args;\n /** Global values after applying preview defaults and metadata or story overrides. */\n globals: Args;\n};\n\n/** Renders native React content from the current story args and composition context. */\ntype StoryRender<TArgs extends object = Args> = (args: TArgs, context: StoryContext<TArgs>) => ReactNode;\n\n/** Values a decorator can override when invoking the decorated story. */\ntype StoryContextUpdate<TArgs extends object = Args> = {\n /** Partial args merged into the current invocation without changing composed defaults. */\n args?: Partial<TArgs>;\n /** Global values overridden for the decorated invocation. */\n globals?: Args;\n};\n\n/** Wraps story content and can override args or globals when invoking the supplied Story function. */\ntype Decorator<TArgs extends object = Args> = (\n Story: (update?: StoryContextUpdate<TArgs>) => ReactNode,\n context: StoryContext<TArgs>,\n) => ReactNode;\n\n/** Shared CSF annotations accepted at preview, component, and story scope. */\ntype Annotations<TArgs extends object> = {\n /** Default args, with more specific annotation scopes taking precedence. */\n args?: Partial<TArgs>;\n /** Explicit argument descriptions, controls, and action registrations. */\n argTypes?: ArgTypes<TArgs>;\n /** Parameters merged across scopes, including native preview and layout settings. */\n parameters?: Args;\n /** Wrappers composed around the story's render function. */\n decorators?: Decorator<TArgs>[];\n /** Custom renderer used in place of the component or a less specific render annotation. */\n render?: StoryRender<TArgs>;\n /** Storybook tags composed with tags from other annotation scopes. */\n tags?: string[];\n};\n\n/** Default export metadata describing a component's stories and their shared annotations. */\ntype ComponentMeta<TArgs extends object> = Annotations<TArgs> &\n Pick<ComponentAnnotations<NativeRenderer<TArgs>, TArgs>, \"title\" | \"id\" | \"includeStories\" | \"excludeStories\"> & {\n /** Component rendered with story args when no custom render annotation applies. */\n component?: ComponentType<TArgs>;\n /** Global overrides shared by this component's stories. */\n globals?: Args;\n };\n\n/** Resolves a component's props or accepts an explicitly supplied args object type. */\ntype ComponentOrProps<T> = T extends ComponentType<infer Props extends object> ? Props : T extends object ? T : Args;\n\n/** Presents combined inferred args as a single object type. */\ntype Simplify<T> = { [Key in keyof T]: T[Key] };\n\n/** Infers story args from component props, render functions, decorators, or declared defaults. */\ntype ArgsFrom<T> = T extends { component?: infer Component; render?: unknown; decorators?: unknown }\n ? Simplify<\n (NonNullable<Component> extends ComponentType<infer Props extends object> ? Props : object) &\n ArgsFromMeta<NativeRenderer, T>\n >\n : T extends { args: infer Defaults extends object }\n ? Defaults\n : Args;\n\n/** CSF3 default export metadata typed from a React component or an explicit args type. */\ntype Meta<T = Args> = ComponentMeta<ComponentOrProps<T>>;\n\n/** Annotations for one CSF3 story object, including its display name and global overrides. */\ntype StoryAnnotations<TArgs extends object> = Annotations<TArgs> & {\n /** Display name overriding the name derived from the story's named export. */\n name?: string;\n /** Global overrides applied specifically to this story. */\n globals?: Args;\n};\n\n/** Extracts args already defaulted by component metadata. */\ntype DefaultArgs<T> = T extends { args: infer Defaults } ? Defaults : Record<never, never>;\n\n/** Makes args with metadata defaults optional while preserving other required args. */\ntype RequiredStoryArgs<T, TArgs extends object> = Omit<TArgs, keyof DefaultArgs<T>> &\n Partial<Pick<TArgs, keyof TArgs & keyof DefaultArgs<T>>>;\n\n/** CSF3 story object inferred from metadata, a React component, or an explicit args type. */\ntype StoryObj<T = Args> = T extends { component?: unknown; render?: unknown; decorators?: unknown; args?: unknown }\n ? StoryAnnotations<ArgsFrom<T>> &\n Pick<\n StorybookAnnotations<NativeRenderer<ArgsFrom<T>>, ArgsFrom<T>, RequiredStoryArgs<T, ArgsFrom<T>>>,\n \"args\"\n >\n : StoryAnnotations<ComponentOrProps<T>>;\n\n/** Project annotations shared by all composed stories. */\ntype Preview = Annotations<Args> & {\n /** Initial global values available in story rendering and decorators. */\n initialGlobals?: Args;\n /** Storybook metadata describing global values; native toolbar controls are not provided. */\n globalTypes?: GlobalTypes;\n};\n\n/** Renderable story with merged annotations; props override its composed default args. */\ntype ComposedStory<TArgs extends object = Args> = ((args: Partial<TArgs>) => ReactNode) & {\n /** Default args merged across preview, component metadata, and story annotations. */\n args: Partial<TArgs>;\n /** Composed argument metadata available to native controls and actions. */\n argTypes: ArgTypes<TArgs>;\n /** Composed parameters available to the renderer and explorer. */\n parameters: Args;\n /** Composed global values available in story context. */\n globals: Args;\n /** Storybook identifier derived from component identity and the story export. */\n id: string;\n /** Story name attached by Storybook's portable composition API. */\n storyName: string;\n /** Tags resulting from composition across annotation scopes. */\n tags: string[];\n};\n\n/** Imported CSF module containing default metadata and named story exports. */\ntype StoryModule = {\n /** Component metadata validated when the module is composed. */\n default: unknown;\n};\n\n/** Named module exports whose types match CSF3 stories, excluding module bookkeeping. */\ntype StoryKeys<TModule extends StoryModule> = {\n [Key in keyof TModule]: Key extends \"default\" | \"__esModule\" | \"__namedExportsOrder\"\n ? never\n : TModule[Key] extends StoryAnnotations<ArgsFrom<TModule[\"default\"]>>\n ? Key\n : never;\n}[keyof TModule] &\n string;\n\n/** Composed stories keyed by their original named exports. */\ntype ComposedStories<TModule extends StoryModule> = Record<\n StoryKeys<TModule>,\n ComposedStory<ArgsFrom<TModule[\"default\"]>>\n>;\n\nexport type {\n Args,\n ArgTypes,\n ComponentMeta,\n ComposedStories,\n ComposedStory,\n Decorator,\n Meta,\n Preview,\n StoryAnnotations,\n StoryContext,\n StoryContextUpdate,\n StoryModule,\n StoryObj,\n StoryRender,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,WAAW,EACd,MAAM,YAAY,CAAC;AAEpB,KAAK,YAAY,GAAG,CAAC,KAAK,SAAS,MAAM,EACrC,GAAG,WAAW,EAAE;IACZ,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAC9B,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC;IAC1B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;KAAE;IACxC,UAAU,CAAC,EAAE,MAAM;CACtB,KACA,aAAa,CAAC,KAAK,CAAC,CAAC;AAE1B,QAAA,MAAM,uBAAuB,EAAmB,YAAY,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEvG,KAAK,YAAY,GAAG,CAAC,KAAK,SAAS,MAAM,EACrC,GAAG,WAAW,EAAE;IACZ,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAC9B,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC;IAC1B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;KAAE;IACxC,UAAU,CAAC,EAAE,MAAM;CACtB,KACA,aAAa,CAAC,KAAK,CAAC,CAAC;AAE1B,QAAA,MAAM,uBAAuB,EAAmB,YAAY,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"upstream.js","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAmBrD,MAAM,uBAAuB,GAAG,YAA4B,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import { composeStory } from \"storybook/preview-api\";\nimport type {\n ComponentMeta,\n ComposedStory,\n Preview,\n StoryAnnotations,\n StoryRender,\n} from \"./types.js\";\n\ntype ComposeStory = <TArgs extends object>(\n ...annotations: [\n story: StoryAnnotations<TArgs>,\n meta: ComponentMeta<TArgs>,\n preview: Preview,\n renderer: { render: StoryRender<TArgs> },\n exportName?: string,\n ]\n) => ComposedStory<TArgs>;\n\nconst composeStoryAnnotations = composeStory as ComposeStory;\n\nexport { composeStoryAnnotations };\n\nexport { isExportStory, storyNameFromExport } from \"storybook/internal/csf\";\n"]}
1
+ {"version":3,"file":"upstream.js","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAarD,MAAM,uBAAuB,GAAG,YAA4B,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import { composeStory } from \"storybook/preview-api\";\nimport type { ComponentMeta, ComposedStory, Preview, StoryAnnotations, StoryRender } from \"./types.js\";\n\ntype ComposeStory = <TArgs extends object>(\n ...annotations: [\n story: StoryAnnotations<TArgs>,\n meta: ComponentMeta<TArgs>,\n preview: Preview,\n renderer: { render: StoryRender<TArgs> },\n exportName?: string,\n ]\n) => ComposedStory<TArgs>;\n\nconst composeStoryAnnotations = composeStory as ComposeStory;\n\nexport { composeStoryAnnotations };\n\nexport { isExportStory, storyNameFromExport } from \"storybook/internal/csf\";\n"]}
package/package.json CHANGED
@@ -1,86 +1,78 @@
1
1
  {
2
- "name": "@gtkx/storybook",
3
- "version": "0.0.1",
4
- "description": "Native story explorer and portable Component Story Format fixtures for GTKX applications.",
5
- "keywords": [
6
- "gtkx",
7
- "gtk",
8
- "gtk4",
9
- "adwaita",
10
- "react",
11
- "storybook",
12
- "csf",
13
- "linux"
14
- ],
15
- "homepage": "https://gtkx.dev",
16
- "bugs": {
17
- "url": "https://github.com/gtkx-org/gtkx/issues"
2
+ "name": "@gtkx/storybook",
3
+ "version": "2.0.0-beta.12",
4
+ "description": "Native component stories for GTKX.",
5
+ "keywords": [
6
+ "gtkx",
7
+ "gtk",
8
+ "gtk4",
9
+ "adwaita",
10
+ "react",
11
+ "storybook",
12
+ "csf",
13
+ "linux",
14
+ "gnome",
15
+ "desktop"
16
+ ],
17
+ "homepage": "https://gtkx.dev",
18
+ "bugs": {
19
+ "url": "https://github.com/gtkx-org/gtkx/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/gtkx-org/gtkx.git",
24
+ "directory": "packages/storybook"
25
+ },
26
+ "license": "MPL-2.0",
27
+ "author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
28
+ "type": "module",
29
+ "exports": {
30
+ "./package.json": "./package.json",
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": null,
35
+ "default": "./dist/index.js"
18
36
  },
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/gtkx-org/gtkx.git",
22
- "directory": "packages/storybook"
37
+ "./config": {
38
+ "types": "./dist/config.d.ts",
39
+ "import": "./dist/config.js",
40
+ "require": null,
41
+ "default": "./dist/config.js"
23
42
  },
24
- "license": "MPL-2.0",
25
- "author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
26
- "type": "module",
27
- "exports": {
28
- "./package.json": "./package.json",
29
- ".": {
30
- "source": "./src/index.ts",
31
- "types": "./dist/index.d.ts",
32
- "import": "./dist/index.js",
33
- "require": null,
34
- "default": "./dist/index.js"
35
- },
36
- "./config": {
37
- "source": "./src/config.ts",
38
- "types": "./dist/config.d.ts",
39
- "import": "./dist/config.js",
40
- "require": null,
41
- "default": "./dist/config.js"
42
- },
43
- "./explorer": {
44
- "source": "./src/explorer.ts",
45
- "types": "./dist/explorer.d.ts",
46
- "import": "./dist/explorer.js",
47
- "require": null,
48
- "default": "./dist/explorer.js"
49
- }
50
- },
51
- "sideEffects": false,
52
- "files": [
53
- "dist",
54
- "src"
55
- ],
56
- "scripts": {
57
- "release": "tsx ../../scripts/release-package.ts"
58
- },
59
- "nx": {
60
- "targets": {
61
- "lint": {
62
- "options": {
63
- "cwd": ".",
64
- "command": "eslint {projectRoot}"
65
- }
66
- }
67
- }
68
- },
69
- "engines": {
70
- "node": ">=26.7.0"
71
- },
72
- "dependencies": {
73
- "@gtkx/components": "workspace:*",
74
- "@gtkx/react": "workspace:*",
75
- "storybook": "10.6.0"
76
- },
77
- "peerDependencies": {
78
- "react": "^19.2"
79
- },
80
- "devDependencies": {
81
- "@gtkx/config": "workspace:*",
82
- "@gtkx/testing": "workspace:*",
83
- "@gtkx/vitest": "workspace:*",
84
- "vitest": "catalog:"
43
+ "./explorer": {
44
+ "types": "./dist/explorer.d.ts",
45
+ "import": "./dist/explorer.js",
46
+ "require": null,
47
+ "default": "./dist/explorer.js"
85
48
  }
86
- }
49
+ },
50
+ "sideEffects": false,
51
+ "files": [
52
+ "dist",
53
+ "src"
54
+ ],
55
+ "engines": {
56
+ "node": ">=26.7.0"
57
+ },
58
+ "dependencies": {
59
+ "@gtkx/components": "2.0.0-beta.12",
60
+ "@gtkx/react": "2.0.0-beta.12",
61
+ "@gtkx/utils": "2.0.0-beta.12",
62
+ "storybook": "10.6.2"
63
+ },
64
+ "peerDependencies": {
65
+ "@types/react": "^19.3",
66
+ "react": "^19.3"
67
+ },
68
+ "devDependencies": {
69
+ "@gtkx/config": "2.0.0-beta.12",
70
+ "@gtkx/testing": "2.0.0-beta.12",
71
+ "@gtkx/vitest": "2.0.0-beta.12",
72
+ "@types/react": "^19.3.0",
73
+ "vitest": "5.0.5"
74
+ },
75
+ "scripts": {
76
+ "release": "node ../../scripts/release/publish-package.ts"
77
+ }
78
+ }
package/src/actions.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { normalizeError } from "@gtkx/utils";
1
2
  import { AsyncLocalStorage } from "node:async_hooks";
2
3
  import { inspect } from "node:util";
3
4
  import type { Args, ArgTypes } from "./types.js";
@@ -6,7 +7,6 @@ type ActionEntry = {
6
7
  id: number;
7
8
  name: string;
8
9
  args: string[];
9
- timestamp: number;
10
10
  error?: string;
11
11
  };
12
12
 
@@ -81,7 +81,6 @@ class ActionStore {
81
81
  private entries: ActionEntry[] = [];
82
82
  private readonly listeners: Set<() => void> = new Set();
83
83
  private nextId = 0;
84
- private readonly limit: number;
85
84
 
86
85
  getSnapshot = (): ActionEntry[] => this.entries;
87
86
 
@@ -97,14 +96,6 @@ class ActionStore {
97
96
  this.publish([]);
98
97
  };
99
98
 
100
- constructor(limit: number = DEFAULT_HISTORY_LIMIT) {
101
- if (!Number.isSafeInteger(limit) || limit < 1) {
102
- throw new RangeError("Action history needs a positive integer limit");
103
- }
104
-
105
- this.limit = limit;
106
- }
107
-
108
99
  private publish(entries: ActionEntry[]): void {
109
100
  this.entries = entries;
110
101
 
@@ -118,10 +109,9 @@ class ActionStore {
118
109
  id: this.nextId++,
119
110
  name,
120
111
  args: args.slice(0, 8).map((value) => formatArgument(value)),
121
- timestamp: Date.now(),
122
112
  ...(error !== undefined && { error: error.message.slice(0, MAX_ARGUMENT_LENGTH) }),
123
113
  };
124
- this.publish([...this.entries, entry].slice(-this.limit));
114
+ this.publish([...this.entries, entry].slice(-DEFAULT_HISTORY_LIMIT));
125
115
  }
126
116
  }
127
117
 
@@ -144,40 +134,39 @@ const settleCallback = async (
144
134
  }
145
135
  };
146
136
 
147
- const bindCallback = (
148
- store: ActionStore,
149
- options: CallbackOptions,
150
- ): EventCallback => (...values) => {
151
- const succeed = (): void => {
152
- store.record(options.name, values);
153
- };
154
- const fail = (cause: unknown): void => {
155
- const error = cause instanceof Error ? cause : new Error(String(cause));
156
- store.record(options.name, values, error);
137
+ const bindCallback =
138
+ (store: ActionStore, options: CallbackOptions): EventCallback =>
139
+ (...values) => {
140
+ const succeed = (): void => {
141
+ store.record(options.name, values);
142
+ };
143
+ const fail = (cause: unknown): void => {
144
+ const error = normalizeError(cause);
145
+ store.record(options.name, values, error);
157
146
 
158
- if (options.onError === undefined) {
159
- throw error;
160
- }
147
+ if (options.onError === undefined) {
148
+ throw error;
149
+ }
161
150
 
162
- options.onError(error);
163
- };
151
+ options.onError(error);
152
+ };
164
153
 
165
- try {
166
- const result = actionScope.run(store, () => options.callback?.(...values));
154
+ try {
155
+ const result = actionScope.run(store, () => options.callback?.(...values));
167
156
 
168
- if (result instanceof Promise) {
169
- return settleCallback(result, succeed, fail);
170
- }
157
+ if (result instanceof Promise) {
158
+ return settleCallback(result, succeed, fail);
159
+ }
171
160
 
172
- succeed();
161
+ succeed();
173
162
 
174
- return result;
175
- } catch (error) {
176
- fail(error);
163
+ return result;
164
+ } catch (error) {
165
+ fail(error);
177
166
 
178
- return;
179
- }
180
- };
167
+ return;
168
+ }
169
+ };
181
170
 
182
171
  const actionName = (value: unknown, configuredName: unknown): string | undefined => {
183
172
  if (typeof configuredName === "string") {
@@ -206,12 +195,7 @@ const callbackOptions = (
206
195
  };
207
196
  };
208
197
 
209
- const bindActions = (
210
- args: Args,
211
- argTypes: ArgTypes,
212
- store: ActionStore,
213
- onError?: (error: Error) => void,
214
- ): Args => {
198
+ const bindActions = (args: Args, argTypes: ArgTypes, store: ActionStore, onError?: (error: Error) => void): Args => {
215
199
  const bound = { ...args };
216
200
  const names = new Set([...Object.keys(args), ...Object.keys(argTypes)]);
217
201
 
package/src/catalog.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { normalizeError } from "@gtkx/utils";
1
2
  import type { Args, ArgTypes, ComponentMeta, ComposedStory, Preview, StoryAnnotations } from "./types.js";
2
3
  import { composeStories } from "./compose.js";
3
4
  import { storyNameFromExport } from "./upstream.js";
@@ -59,8 +60,6 @@ type LoadedSource = StoryLoadError | { source: StorySource; cached: CachedStorie
59
60
 
60
61
  const EMPTY_PREVIEW: Preview = {};
61
62
 
62
- const normalizeError = (cause: unknown): Error => cause instanceof Error ? cause : new Error(String(cause));
63
-
64
63
  const isObject = (value: unknown): value is Record<string, unknown> =>
65
64
  value !== null && typeof value === "object" && !Array.isArray(value);
66
65
 
@@ -73,14 +72,16 @@ const explicitControls = (
73
72
  const controls: ArgTypes = {};
74
73
 
75
74
  for (const [argument, annotation] of Object.entries(resolved)) {
76
- const control = story?.argTypes?.[argument]?.control ??
77
- meta.argTypes?.[argument]?.control ?? preview.argTypes?.[argument]?.control;
75
+ const control =
76
+ story?.argTypes?.[argument]?.control ??
77
+ meta.argTypes?.[argument]?.control ??
78
+ preview.argTypes?.[argument]?.control;
78
79
 
79
80
  if (control === undefined) {
80
81
  continue;
81
82
  }
82
83
 
83
- controls[argument] = { ...annotation, control: control === false ? false : annotation?.control ?? control };
84
+ controls[argument] = { ...annotation, control: control !== false && (annotation?.control ?? control) };
84
85
  }
85
86
 
86
87
  return controls;
@@ -173,10 +174,13 @@ const loadSource = async (
173
174
  try {
174
175
  const module = await source.load();
175
176
  const previous = getCache().get(source.id);
176
- const cached = previous !== undefined && previous.module === module &&
177
- previous.title === source.title && previous.preview === preview
178
- ? previous
179
- : { module, title: source.title, preview, entries: composeSource(source, module, preview) };
177
+ const cached =
178
+ previous !== undefined &&
179
+ previous.module === module &&
180
+ previous.title === source.title &&
181
+ previous.preview === preview
182
+ ? previous
183
+ : { module, title: source.title, preview, entries: composeSource(source, module, preview) };
180
184
 
181
185
  return { source, cached };
182
186
  } catch (error) {
@@ -233,7 +237,10 @@ class StoryCatalog {
233
237
  this.publish({ stories, errors, isLoading: false });
234
238
 
235
239
  if (errors.length > 0) {
236
- const failure = new AggregateError(errors.map(({ error }) => error), "Some stories could not be loaded");
240
+ const failure = new AggregateError(
241
+ errors.map(({ error }) => error),
242
+ "Some stories could not be loaded",
243
+ );
237
244
  this.loadFailures.add(failure);
238
245
  throw failure;
239
246
  }
package/src/compose.ts CHANGED
@@ -34,23 +34,25 @@ const composeStory = <TArgs extends object>(
34
34
  preview: Preview = {},
35
35
  exportName?: string,
36
36
  ): ComposedStory<TArgs> => {
37
- requireObject(story);
38
- requireObject(meta);
39
- requireObject(preview);
40
-
41
37
  if (!story.render && !meta.render && !preview.render && !meta.component) {
42
38
  throw new TypeError("A story needs a component or render function");
43
39
  }
44
40
 
45
- return composeStoryAnnotations(story, { ...meta }, preview, {
46
- render: (args) => {
47
- if (!meta.component) {
48
- throw new TypeError("A story needs a component or render function");
49
- }
41
+ return composeStoryAnnotations(
42
+ story,
43
+ { ...meta },
44
+ preview,
45
+ {
46
+ render: (args) => {
47
+ if (!meta.component) {
48
+ throw new TypeError("A story needs a component or render function");
49
+ }
50
50
 
51
- return createElement(meta.component, args);
51
+ return createElement(meta.component, args);
52
+ },
52
53
  },
53
- }, exportName);
54
+ exportName,
55
+ );
54
56
  };
55
57
 
56
58
  /**
@@ -67,9 +69,7 @@ const composeStories = <TModule extends StoryModule>(
67
69
  stories: TModule,
68
70
  preview: Preview = {},
69
71
  ): ComposedStories<TModule> => {
70
- requireObject(stories);
71
72
  requireObject(stories.default);
72
- requireObject(preview);
73
73
 
74
74
  const meta = stories.default as ComponentMeta<Args>;
75
75
  const composed: Partial<ComposedStories<TModule>> = {};