ember-storybook 0.0.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.
Files changed (46) hide show
  1. package/README.md +31 -0
  2. package/declarations/client/config.d.ts +5 -0
  3. package/declarations/client/config.d.ts.map +1 -0
  4. package/declarations/client/docs/config.d.ts +5 -0
  5. package/declarations/client/docs/config.d.ts.map +1 -0
  6. package/declarations/client/docs/sourceDecorator.d.ts +7 -0
  7. package/declarations/client/docs/sourceDecorator.d.ts.map +1 -0
  8. package/declarations/client/globals.d.ts +1 -0
  9. package/declarations/client/globals.d.ts.map +1 -0
  10. package/declarations/client/index.d.ts +6 -0
  11. package/declarations/client/index.d.ts.map +1 -0
  12. package/declarations/client/portable-stories.d.ts +23 -0
  13. package/declarations/client/portable-stories.d.ts.map +1 -0
  14. package/declarations/client/public-types.d.ts +27 -0
  15. package/declarations/client/public-types.d.ts.map +1 -0
  16. package/declarations/client/render-story.d.ts +19 -0
  17. package/declarations/client/render-story.d.ts.map +1 -0
  18. package/declarations/client/render.d.ts +7 -0
  19. package/declarations/client/render.d.ts.map +1 -0
  20. package/declarations/client/types.d.ts +25 -0
  21. package/declarations/client/types.d.ts.map +1 -0
  22. package/declarations/index.d.ts +3 -0
  23. package/declarations/index.d.ts.map +1 -0
  24. package/declarations/node/index.d.ts +4 -0
  25. package/declarations/node/index.d.ts.map +1 -0
  26. package/declarations/node/indexer.d.ts +5 -0
  27. package/declarations/node/indexer.d.ts.map +1 -0
  28. package/declarations/preset.d.ts +8 -0
  29. package/declarations/preset.d.ts.map +1 -0
  30. package/declarations/types.d.ts +23 -0
  31. package/declarations/types.d.ts.map +1 -0
  32. package/dist/client/config.mjs +12 -0
  33. package/dist/client/config.mjs.map +1 -0
  34. package/dist/client/docs/config.mjs +46 -0
  35. package/dist/client/docs/config.mjs.map +1 -0
  36. package/dist/client/index.mjs +3 -0
  37. package/dist/client-CKraj5BI.mjs +62 -0
  38. package/dist/client-CKraj5BI.mjs.map +1 -0
  39. package/dist/index.mjs +3 -0
  40. package/dist/node/index.mjs +8 -0
  41. package/dist/node/index.mjs.map +1 -0
  42. package/dist/preset.mjs +58 -0
  43. package/dist/preset.mjs.map +1 -0
  44. package/dist/render-BUq_AxtY.mjs +87 -0
  45. package/dist/render-BUq_AxtY.mjs.map +1 -0
  46. package/package.json +101 -0
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Storybook for Ember
2
+
3
+ Storybook for Ember is a UI development environment for your Ember components.
4
+ With it, you can visualize different states of your UI components and develop them interactively.
5
+
6
+ ![Storybook Screenshot](https://github.com/storybookjs/storybook/blob/main/media/storybook-intro.gif)
7
+
8
+ Storybook runs outside of your app.
9
+ So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
10
+
11
+ ## Getting Started
12
+
13
+ ```sh
14
+ cd my-ember-app
15
+ npx storybook@latest init
16
+ ```
17
+
18
+ For more information visit: [storybook.js.org](https://storybook.js.org?ref=readme)
19
+
20
+ ---
21
+
22
+ Storybook also comes with a lot of [addons](https://storybook.js.org/addons?ref=readme) and a great API to customize as you wish.
23
+ You can also build a [static version](https://storybook.js.org/docs/sharing/publish-storybook?renderer=ember&ref=readme) of your Storybook and deploy it anywhere you want.
24
+
25
+ ## Docs
26
+
27
+ - [Basics](https://storybook.js.org/docs/get-started/install?renderer=ember&ref=readme)
28
+ - [Configurations](https://storybook.js.org/docs/configure?renderer=ember&ref=readme)
29
+ - [Addons](https://storybook.js.org/docs/configure/user-interface/storybook-addons?renderer=ember&ref=readme)
30
+
31
+ Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
@@ -0,0 +1,5 @@
1
+ import type { ArgTypesEnhancer, Parameters } from 'storybook/internal/types';
2
+ export { render, renderToCanvas } from './render';
3
+ export declare const parameters: Parameters;
4
+ export declare const argTypesEnhancers: ArgTypesEnhancer[];
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/client/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,UAAU,EAAE,UAKxB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,EAAsB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { EmberRenderer } from '../types';
2
+ import type { DecoratorFunction, Parameters } from 'storybook/internal/types';
3
+ export declare const parameters: Parameters;
4
+ export declare const decorators: DecoratorFunction<EmberRenderer>[];
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/client/docs/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE9E,eAAO,MAAM,UAAU,EAAE,UAOxB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,aAAa,CAAC,EAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { EmberRenderer } from '../types';
2
+ import type { Args, ArgTypes, DecoratorFunction } from 'storybook/internal/types';
3
+ export declare function generateGlimmerSource(component: object & {
4
+ name?: string;
5
+ }, args: Args, argTypes: ArgTypes): string | undefined;
6
+ export declare const sourceDecorator: DecoratorFunction<EmberRenderer>;
7
+ //# sourceMappingURL=sourceDecorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceDecorator.d.ts","sourceRoot":"","sources":["../../../src/client/docs/sourceDecorator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA2ClF,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACrC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,GACjB,MAAM,GAAG,SAAS,CAoBpB;AAED,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,aAAa,CAoB5D,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/client/globals.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import './globals';
2
+ export * from './portable-stories';
3
+ export * from './public-types';
4
+ export { renderToCanvas } from './render';
5
+ export { RenderStory } from './render-story';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AAEnB,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { EmberRenderer } from './types';
2
+ import type { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations } from 'storybook/internal/types';
3
+ /**
4
+ * Function that sets the globalConfig of your storybook. The global config is the preview module of
5
+ * your .storybook folder.
6
+ *
7
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your
8
+ * stories when using `composeStories` or `composeStory`.
9
+ *
10
+ * Example:
11
+ *
12
+ * ```jsx
13
+ * // setup-file.js
14
+ * import { setProjectAnnotations } from '@storybook/preact';
15
+ * import projectAnnotations from './.storybook/preview';
16
+ *
17
+ * setProjectAnnotations(projectAnnotations);
18
+ * ```
19
+ *
20
+ * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')
21
+ */
22
+ export declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<EmberRenderer> | NamedOrDefaultProjectAnnotations<EmberRenderer>[]): NormalizedProjectAnnotations<EmberRenderer>;
23
+ //# sourceMappingURL=portable-stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portable-stories.d.ts","sourceRoot":"","sources":["../../src/client/portable-stories.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EACV,gCAAgC,EAChC,4BAA4B,EAC7B,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,kBAAkB,EACd,gCAAgC,CAAC,aAAa,CAAC,GAC/C,gCAAgC,CAAC,aAAa,CAAC,EAAE,GACpD,4BAA4B,CAAC,aAAa,CAAC,CAI7C"}
@@ -0,0 +1,27 @@
1
+ import type { EmberRenderer } from './types';
2
+ import type { AnnotatedStoryFn, Args, ComponentAnnotations, DecoratorFunction, LoaderFunction, ProjectAnnotations, StoryAnnotations, StoryContext as GenericStoryContext, StrictArgs } from 'storybook/internal/types';
3
+ export type { Args, ArgTypes, Parameters, StrictArgs } from 'storybook/internal/types';
4
+ /**
5
+ * Metadata to configure the stories for a component.
6
+ *
7
+ * @see [Default export](https://storybook.js.org/docs/api/csf#default-export)
8
+ */
9
+ export type Meta<TArgs = Args> = ComponentAnnotations<EmberRenderer, TArgs>;
10
+ /**
11
+ * Story function that represents a CSFv2 component example.
12
+ *
13
+ * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
14
+ */
15
+ export type StoryFn<TArgs = Args> = AnnotatedStoryFn<EmberRenderer, TArgs>;
16
+ /**
17
+ * Story object that represents a CSFv3 component example.
18
+ *
19
+ * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
20
+ */
21
+ export type StoryObj<TArgs = Args> = StoryAnnotations<EmberRenderer, TArgs>;
22
+ export type Decorator<TArgs = StrictArgs> = DecoratorFunction<EmberRenderer, TArgs>;
23
+ export type Loader<TArgs = StrictArgs> = LoaderFunction<EmberRenderer, TArgs>;
24
+ export type StoryContext<TArgs = StrictArgs> = GenericStoryContext<EmberRenderer, TArgs>;
25
+ export type Preview = ProjectAnnotations<EmberRenderer>;
26
+ export { type EmberRenderer } from './types';
27
+ //# sourceMappingURL=public-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-types.d.ts","sourceRoot":"","sources":["../../src/client/public-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,IAAI,mBAAmB,EACnC,UAAU,EACX,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEvF;;;;GAIG;AACH,MAAM,MAAM,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,oBAAoB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,OAAO,CAAC,KAAK,GAAG,IAAI,IAAI,gBAAgB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,KAAK,GAAG,IAAI,IAAI,gBAAgB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAE5E,MAAM,MAAM,SAAS,CAAC,KAAK,GAAG,UAAU,IAAI,iBAAiB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AACpF,MAAM,MAAM,MAAM,CAAC,KAAK,GAAG,UAAU,IAAI,cAAc,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAC9E,MAAM,MAAM,YAAY,CAAC,KAAK,GAAG,UAAU,IAAI,mBAAmB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AACzF,MAAM,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAExD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,19 @@
1
+ import Component from '@glimmer/component';
2
+ interface RenderStorySignature {
3
+ Args: {
4
+ story: () => object;
5
+ args: Record<string, unknown>;
6
+ };
7
+ Element: HTMLDivElement;
8
+ }
9
+ export declare class RenderStory extends Component<RenderStorySignature> {
10
+ render: import("ember-modifier").FunctionBasedModifier<{
11
+ Args: {
12
+ Positional: unknown[];
13
+ Named: import("ember-modifier/-private/signature").EmptyObject;
14
+ };
15
+ Element: HTMLDivElement;
16
+ }>;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=render-story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-story.d.ts","sourceRoot":"","sources":["../../src/client/render-story.gts"],"names":[],"mappings":"AAiCA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAM3C,UAAU,oBAAoB;IAC5B,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/B,CAAC;IACF,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,qBAAa,WAAY,SAAQ,SAAS,CAAC,oBAAoB,CAAC;IAC9D,MAAM;;;;;;OAYH;CASJ"}
@@ -0,0 +1,7 @@
1
+ import type { EmberRenderer, StoryContext } from './types';
2
+ import type { ArgsStoryFn, RenderContext } from 'storybook/internal/types';
3
+ export declare const render: ArgsStoryFn<EmberRenderer>;
4
+ export declare function renderToCanvas({ storyFn, showMain, storyContext, forceRemount }: RenderContext<EmberRenderer> & {
5
+ storyContext: StoryContext;
6
+ }, canvasElement: EmberRenderer['canvasElement']): Promise<() => void>;
7
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/client/render.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI3E,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,aAAa,CAc7C,CAAC;AAgDF,wBAAsB,cAAc,CAClC,EACE,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,EACb,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG;IAAE,YAAY,EAAE,YAAY,CAAA;CAAE,EAChE,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,uBA8E9C"}
@@ -0,0 +1,25 @@
1
+ import type Application from '@ember/application';
2
+ import type ApplicationInstance from '@ember/application/instance';
3
+ import type { StoryContext as DefaultStoryContext, WebRenderer } from 'storybook/internal/types';
4
+ export type { RenderContext } from 'storybook/internal/types';
5
+ export interface ShowErrorArgs {
6
+ title: string;
7
+ description: string;
8
+ }
9
+ export type AppParamater = typeof Application | ApplicationInstance | ((options?: Record<string, unknown>) => typeof Application | ApplicationInstance);
10
+ export interface EmberParameters {
11
+ ember?: {
12
+ app?: AppParamater;
13
+ owner?: Record<`${string}:${string}`, object>;
14
+ };
15
+ }
16
+ export interface EmberRenderer extends WebRenderer {
17
+ component: object;
18
+ storyResult: object;
19
+ csf4: true;
20
+ parameters: EmberParameters;
21
+ }
22
+ export type StoryContext = DefaultStoryContext<EmberRenderer> & {
23
+ parameters: DefaultStoryContext<EmberRenderer>['parameters'] & EmberParameters;
24
+ };
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEjG,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,YAAY,GACpB,OAAO,WAAW,GAClB,mBAAmB,GACnB,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,WAAW,GAAG,mBAAmB,CAAC,CAAC;AAEtF,MAAM,WAAW,eAAe;IAE9B,KAAK,CAAC,EAAE;QACN,GAAG,CAAC,EAAE,YAAY,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;KAC/C,CAAC;CACH;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAGhD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,MAAM,YAAY,GAAG,mBAAmB,CAAC,aAAa,CAAC,GAAG;IAC9D,UAAU,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC;CAChF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './client/index';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { StorybookConfig } from '../types';
2
+ export declare function defineMain(config: StorybookConfig): StorybookConfig;
3
+ export { type StorybookConfig } from '../types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,mBAEjD;AAED,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type CsfOptions } from 'storybook/internal/csf-tools';
2
+ import type { Indexer } from 'storybook/internal/types';
3
+ export declare const readCsf: (fileName: string, options: CsfOptions) => Promise<import("storybook/internal/csf-tools").CsfFile>;
4
+ export declare const emberIndexer: Indexer;
5
+ //# sourceMappingURL=indexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../src/node/indexer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAAW,MAAM,8BAA8B,CAAC;AAExE,OAAO,KAAK,EAAE,OAAO,EAA8B,MAAM,0BAA0B,CAAC;AAQpF,eAAO,MAAM,OAAO,GAAU,UAAU,MAAM,EAAE,SAAS,UAAU,4DAKlE,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OAO1B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type StorybookConfigVite } from '@storybook/builder-vite';
2
+ import type { StorybookConfig } from './types';
3
+ import type { PresetProperty } from 'storybook/internal/types';
4
+ export declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
5
+ export declare const viteFinal: StorybookConfigVite['viteFinal'];
6
+ export declare const experimental_indexers: StorybookConfig['experimental_indexers'];
7
+ export declare const core: PresetProperty<'core'>;
8
+ //# sourceMappingURL=preset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAAsB,MAAM,yBAAyB,CAAC;AAIvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,oBAAoB,CAkBnE,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,mBAAmB,CAAC,WAAW,CAkBtD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,eAAe,CAAC,uBAAuB,CAE1E,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,cAAc,CAAC,MAAM,CAcvC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { BuilderOptions, StorybookConfigVite } from '@storybook/builder-vite';
2
+ import type { CompatibleString, StorybookConfig as StorybookConfigBase } from 'storybook/internal/types';
3
+ type FrameworkName = CompatibleString<'ember-storybook'>;
4
+ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
5
+ export type FrameworkOptions = {
6
+ builder?: BuilderOptions;
7
+ };
8
+ type StorybookConfigFramework = {
9
+ framework: FrameworkName | {
10
+ name: FrameworkName;
11
+ options: FrameworkOptions;
12
+ };
13
+ core?: StorybookConfigBase['core'] & {
14
+ builder?: BuilderName | {
15
+ name: BuilderName;
16
+ options: BuilderOptions;
17
+ };
18
+ };
19
+ };
20
+ /** The interface for Storybook configuration in `main.ts` files. */
21
+ export type StorybookConfig = Omit<StorybookConfigBase, keyof StorybookConfigVite | keyof StorybookConfigFramework> & StorybookConfigVite & StorybookConfigFramework;
22
+ export {};
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,IAAI,mBAAmB,EACvC,MAAM,0BAA0B,CAAC;AAElC,KAAK,aAAa,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AACzD,KAAK,WAAW,GAAG,gBAAgB,CAAC,yBAAyB,CAAC,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,SAAS,EACL,aAAa,GACb;QACE,IAAI,EAAE,aAAa,CAAC;QACpB,OAAO,EAAE,gBAAgB,CAAC;KAC3B,CAAC;IACN,IAAI,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG;QACnC,OAAO,CAAC,EACJ,WAAW,GACX;YACE,IAAI,EAAE,WAAW,CAAC;YAClB,OAAO,EAAE,cAAc,CAAC;SACzB,CAAC;KACP,CAAC;CACH,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,mBAAmB,EACnB,MAAM,mBAAmB,GAAG,MAAM,wBAAwB,CAC3D,GACC,mBAAmB,GACnB,wBAAwB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { n as renderToCanvas, t as render } from "../render-BUq_AxtY.mjs";
2
+ import { enhanceArgTypes } from "storybook/internal/docs-tools";
3
+ //#region src/client/config.ts
4
+ const parameters = {
5
+ renderer: "ember",
6
+ docs: { story: { inline: true } }
7
+ };
8
+ const argTypesEnhancers = [enhanceArgTypes];
9
+ //#endregion
10
+ export { argTypesEnhancers, parameters, render, renderToCanvas };
11
+
12
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":["enhanceArgTypes","render","renderToCanvas","parameters","renderer","docs","story","inline","argTypesEnhancers"],"sources":["../../src/client/config.ts"],"sourcesContent":["import { enhanceArgTypes } from 'storybook/internal/docs-tools';\n\nimport type { ArgTypesEnhancer, Parameters } from 'storybook/internal/types';\n\nexport { render, renderToCanvas } from './render';\n\nexport const parameters: Parameters = {\n renderer: 'ember',\n docs: {\n story: { inline: true }\n }\n};\n\nexport const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];\n"],"mappings":";;;AAMA,MAAaG,aAAyB;CACpCC,UAAU;CACVC,MAAM,EACJC,OAAO,EAAEC,QAAQ,KAAK,EACxB;AACF;AAEA,MAAaC,oBAAwC,CAACR,eAAe"}
@@ -0,0 +1,46 @@
1
+ import { emitTransformCode, useEffect, useRef } from "storybook/preview-api";
2
+ import { SourceType } from "storybook/internal/docs-tools";
3
+ //#region src/client/docs/sourceDecorator.ts
4
+ function skipSourceRender(context) {
5
+ const sourceParams = context.parameters.docs?.source;
6
+ if (sourceParams?.type === SourceType.DYNAMIC) return false;
7
+ return (!context.parameters.__isArgsStory || sourceParams?.code) ?? sourceParams?.type === SourceType.CODE;
8
+ }
9
+ function toArgument(key, value, argTypes) {
10
+ if (value === void 0 || value === null) return;
11
+ if (argTypes[key].action) return;
12
+ if (typeof value === "string") return `@${key}=${JSON.stringify(value)}`;
13
+ if (typeof value === "number" || typeof value === "boolean") return `@${key}={{${JSON.stringify(value)}}}`;
14
+ }
15
+ function generateGlimmerSource(component, args, argTypes) {
16
+ const name = component.name;
17
+ if (!name) return;
18
+ const propsArray = Object.entries(args).map(([k, v]) => toArgument(k, v, argTypes)).filter(Boolean);
19
+ if (propsArray.length === 0) return `<${name} />`;
20
+ if (propsArray.length > 3) return `<${name}\n ${propsArray.join("\n ")}\n/>`;
21
+ return `<${name} ${propsArray.join(" ")} />`;
22
+ }
23
+ const sourceDecorator = (storyFn, context) => {
24
+ const source = useRef(void 0);
25
+ const story = storyFn();
26
+ useEffect(() => {
27
+ const renderedForSource = context.parameters.docs?.source?.excludeDecorators ? context.originalStoryFn(context.args, context) : story;
28
+ if (!skipSourceRender(context)) {
29
+ const code = generateGlimmerSource(renderedForSource, context.args, context.argTypes) ?? void 0;
30
+ emitTransformCode(code, context);
31
+ source.current = code;
32
+ }
33
+ });
34
+ return story;
35
+ };
36
+ //#endregion
37
+ //#region src/client/docs/config.ts
38
+ const parameters = { docs: { source: {
39
+ type: SourceType.DYNAMIC,
40
+ language: "html"
41
+ } } };
42
+ const decorators = [sourceDecorator];
43
+ //#endregion
44
+ export { decorators, parameters };
45
+
46
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":["SourceType","emitTransformCode","useEffect","useRef","skipSourceRender","context","sourceParams","parameters","docs","source","type","DYNAMIC","isArgsStory","__isArgsStory","code","CODE","toArgument","key","value","argTypes","undefined","argType","action","JSON","stringify","generateGlimmerSource","component","args","name","propsArray","Object","entries","map","k","v","filter","Boolean","length","join","sourceDecorator","storyFn","story","renderedForSource","excludeDecorators","originalStoryFn","current","SourceType","sourceDecorator","parameters","docs","source","type","DYNAMIC","language","decorators"],"sources":["../../../src/client/docs/sourceDecorator.ts","../../../src/client/docs/config.ts"],"sourcesContent":["import { SourceType } from 'storybook/internal/docs-tools';\nimport { emitTransformCode, useEffect, useRef } from 'storybook/preview-api';\n\nimport type { StoryFn } from '../public-types';\nimport type { EmberRenderer } from '../types';\nimport type { Args, ArgTypes, DecoratorFunction } from 'storybook/internal/types';\n\nfunction skipSourceRender(context: Parameters<DecoratorFunction<EmberRenderer>>[1]) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const sourceParams = context.parameters.docs?.source;\n\n // always render if the user forces it\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (sourceParams?.type === SourceType.DYNAMIC) {\n return false;\n }\n\n const isArgsStory = context.parameters.__isArgsStory as boolean;\n\n // never render if the user is forcing the block to render code, or\n // if the user provides code, or if it's not an args story.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (!isArgsStory || sourceParams?.code) ?? sourceParams?.type === SourceType.CODE;\n}\n\nfunction toArgument(key: string, value: unknown, argTypes: ArgTypes): string | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n\n const argType = argTypes[key];\n\n // event should be skipped\n if (argType.action) {\n return undefined;\n }\n\n if (typeof value === 'string') {\n return `@${key}=${JSON.stringify(value)}`;\n }\n\n if (typeof value === 'number' || typeof value === 'boolean') {\n return `@${key}={{${JSON.stringify(value)}}}`;\n }\n\n return undefined;\n}\n\nexport function generateGlimmerSource(\n component: object & { name?: string },\n args: Args,\n argTypes: ArgTypes\n): string | undefined {\n const name = component.name;\n\n if (!name) {\n return undefined;\n }\n\n const propsArray = Object.entries(args)\n .map(([k, v]) => toArgument(k, v, argTypes))\n .filter(Boolean);\n\n if (propsArray.length === 0) {\n return `<${name} />`;\n }\n\n if (propsArray.length > 3) {\n return `<${name}\\n ${propsArray.join('\\n ')}\\n/>`;\n }\n\n return `<${name} ${propsArray.join(' ')} />`;\n}\n\nexport const sourceDecorator: DecoratorFunction<EmberRenderer> = (storyFn, context) => {\n const source = useRef<string | undefined>(undefined);\n const story = storyFn();\n\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const renderedForSource = context.parameters.docs?.source?.excludeDecorators\n ? (context.originalStoryFn as StoryFn)(context.args, context)\n : story;\n\n if (!skipSourceRender(context)) {\n const code =\n generateGlimmerSource(renderedForSource, context.args, context.argTypes) ?? undefined;\n\n void emitTransformCode(code, context);\n source.current = code;\n }\n });\n\n return story;\n};\n","import { SourceType } from 'storybook/internal/docs-tools';\n\nimport { sourceDecorator } from './sourceDecorator';\n\nimport type { EmberRenderer } from '../types';\nimport type { DecoratorFunction, Parameters } from 'storybook/internal/types';\n\nexport const parameters: Parameters = {\n docs: {\n source: {\n type: SourceType.DYNAMIC,\n language: 'html'\n }\n }\n};\n\nexport const decorators: DecoratorFunction<EmberRenderer>[] = [sourceDecorator];\n"],"mappings":";;;AAOA,SAASI,iBAAiBC,SAA0D;CAElF,MAA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BiB,mBAAmBrC,QAAQsB,MAAMtB,QAAQc,QAAQ,KAAKC,KAAAA;GAE9E,kBAAuBN,MAAMT,OAAO;GACpCI,OAAOoC,UAAU/B;EACnB;CACF,CAAC;CAED,OAAO2B;AACT;;;ACvFA,MAAaO,aAAyB,EACpCC,MAAM,EACJC,QAAQ;CACNC,MAAML,WAAWM;CACjBC,UAAU;AACZ,EACF,EACF;AAEA,MAAaC,aAAiD,CAACP,eAAe"}
@@ -0,0 +1,3 @@
1
+ import { n as renderToCanvas } from "../render-BUq_AxtY.mjs";
2
+ import { n as setProjectAnnotations, t as RenderStory } from "../client-CKraj5BI.mjs";
3
+ export { RenderStory, renderToCanvas, setProjectAnnotations };
@@ -0,0 +1,62 @@
1
+ import { r as render_exports } from "./render-BUq_AxtY.mjs";
2
+ import { setDefaultProjectAnnotations, setProjectAnnotations } from "storybook/preview-api";
3
+ import { template } from "@ember/template-compiler";
4
+ import Component from "@glimmer/component";
5
+ import { getOwner } from "@ember/owner";
6
+ import { renderComponent } from "@ember/renderer";
7
+ import { modifier } from "ember-modifier";
8
+ //#region src/client/globals.ts
9
+ globalThis.STORYBOOK_ENV = "ember";
10
+ //#endregion
11
+ //#region src/client/portable-stories.ts
12
+ /**
13
+ * Function that sets the globalConfig of your storybook. The global config is the preview module of
14
+ * your .storybook folder.
15
+ *
16
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your
17
+ * stories when using `composeStories` or `composeStory`.
18
+ *
19
+ * Example:
20
+ *
21
+ * ```jsx
22
+ * // setup-file.js
23
+ * import { setProjectAnnotations } from '@storybook/preact';
24
+ * import projectAnnotations from './.storybook/preview';
25
+ *
26
+ * setProjectAnnotations(projectAnnotations);
27
+ * ```
28
+ *
29
+ * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')
30
+ */
31
+ function setProjectAnnotations$1(projectAnnotations) {
32
+ setDefaultProjectAnnotations(render_exports);
33
+ return setProjectAnnotations(projectAnnotations);
34
+ }
35
+ //#endregion
36
+ //#region src/client/render-story.gts
37
+ var RenderStory = class extends Component {
38
+ render = modifier((element) => {
39
+ const component = this.args.story();
40
+ const owner = getOwner(this);
41
+ const result = renderComponent(component, {
42
+ args: this.args.args,
43
+ into: element,
44
+ owner
45
+ });
46
+ return () => {
47
+ result.destroy();
48
+ };
49
+ });
50
+ static {
51
+ template(`<div {{this.render}}></div>`, {
52
+ component: this,
53
+ eval() {
54
+ return eval(arguments[0]);
55
+ }
56
+ });
57
+ }
58
+ };
59
+ //#endregion
60
+ export { setProjectAnnotations$1 as n, RenderStory as t };
61
+
62
+ //# sourceMappingURL=client-CKraj5BI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-CKraj5BI.mjs","names":["globalThis","STORYBOOK_ENV","setDefaultProjectAnnotations","setProjectAnnotations","originalSetProjectAnnotations","INTERNAL_DEFAULT_PROJECT_ANNOTATIONS","projectAnnotations"],"sources":["../src/client/globals.ts","../src/client/portable-stories.ts","../src/client/render-story.gts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\n// eslint-disable-next-line unicorn/no-global-object-property-assignment\nglobalThis.STORYBOOK_ENV = 'ember';\n","import {\n setDefaultProjectAnnotations,\n setProjectAnnotations as originalSetProjectAnnotations\n} from 'storybook/preview-api';\n\nimport * as INTERNAL_DEFAULT_PROJECT_ANNOTATIONS from './render';\n\nimport type { EmberRenderer } from './types';\nimport type {\n NamedOrDefaultProjectAnnotations,\n NormalizedProjectAnnotations\n} from 'storybook/internal/types';\n\n/**\n * Function that sets the globalConfig of your storybook. The global config is the preview module of\n * your .storybook folder.\n *\n * It should be run a single time, so that your global config (e.g. decorators) is applied to your\n * stories when using `composeStories` or `composeStory`.\n *\n * Example:\n *\n * ```jsx\n * // setup-file.js\n * import { setProjectAnnotations } from '@storybook/preact';\n * import projectAnnotations from './.storybook/preview';\n *\n * setProjectAnnotations(projectAnnotations);\n * ```\n *\n * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')\n */\nexport function setProjectAnnotations(\n projectAnnotations:\n | NamedOrDefaultProjectAnnotations<EmberRenderer>\n | NamedOrDefaultProjectAnnotations<EmberRenderer>[]\n): NormalizedProjectAnnotations<EmberRenderer> {\n setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS);\n\n return originalSetProjectAnnotations(projectAnnotations);\n}\n","import Component from '@glimmer/component';\nimport { getOwner } from '@ember/owner';\nimport { renderComponent } from '@ember/renderer';\n\nimport { modifier } from 'ember-modifier';\n\ninterface RenderStorySignature {\n Args: {\n story: () => object;\n args: Record<string, unknown>;\n };\n Element: HTMLDivElement;\n}\n\nexport class RenderStory extends Component<RenderStorySignature> {\n render = modifier((element: HTMLDivElement) => {\n const component = this.args.story();\n const owner = getOwner(this);\n const result = renderComponent(component, {\n args: this.args.args,\n into: element,\n owner\n });\n\n return () => {\n result.destroy();\n };\n });\n\n <template>\n <div {{this.render}}></div>\n </template>\n}\n"],"mappings":";;;;;;;;AAGAA,WAAWC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;AC6B3B,SAAgBE,wBACdG,oBAG6C;CAC7CJ,6BAA6BG,cAAoC;CAEjE,OAAOD,sBAA8BE,kBAAkB;AACzD;;;AC1BA,IAAa,cAAb,cAAiC,UAAU;CACzC,SAAS,UAAU,YAAS;EAC1B,MAAM,YAAY,KAAK,KAAK,MAAK;EACjC,MAAM,QAAQ,SAAS,IAAI;EAC3B,MAAM,SAAS,gBAAgB,WAAW;GACxC,MAAM,KAAK,KAAK;GAChB,MAAM;GACN;EACF,CAAA;EAEA,aAAO;GACL,OAAO,QAAO;EAChB;CACF,CAAA;CAEA;EAAA,SAAU,+BAEV;GAAA,WAAA;GAAA,OAAA;IAAA,OAAA,KAAA,UAAA,EAAW;GAAD;EAAA,CAAA;CAAA;AACZ"}
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { n as renderToCanvas } from "./render-BUq_AxtY.mjs";
2
+ import { n as setProjectAnnotations, t as RenderStory } from "./client-CKraj5BI.mjs";
3
+ export { RenderStory, renderToCanvas, setProjectAnnotations };
@@ -0,0 +1,8 @@
1
+ //#region src/node/index.ts
2
+ function defineMain(config) {
3
+ return config;
4
+ }
5
+ //#endregion
6
+ export { defineMain };
7
+
8
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["defineMain","config"],"sources":["../../src/node/index.ts"],"sourcesContent":["import type { StorybookConfig } from '../types';\n\nexport function defineMain(config: StorybookConfig) {\n return config;\n}\n\nexport { type StorybookConfig } from '../types';\n"],"mappings":";AAEA,SAAgBA,WAAWC,QAAyB;CAClD,OAAOA;AACT"}
@@ -0,0 +1,58 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { withoutVitePlugins } from "@storybook/builder-vite";
3
+ import { readFile } from "node:fs/promises";
4
+ import { Preprocessor } from "content-tag";
5
+ import { loadCsf } from "storybook/internal/csf-tools";
6
+ //#region src/node/indexer.ts
7
+ function parse(fileName, code) {
8
+ return new Preprocessor().process(code, { filename: fileName });
9
+ }
10
+ const readCsf = async (fileName, options) => {
11
+ return loadCsf(parse(fileName, await readFile(fileName, "utf8")).code, {
12
+ ...options,
13
+ fileName
14
+ });
15
+ };
16
+ const emberIndexer = {
17
+ test: /\.stories\.g[tj]s$/,
18
+ createIndex: async (fileName, options) => {
19
+ return (await readCsf(fileName, options)).parse().indexInputs;
20
+ }
21
+ };
22
+ //#endregion
23
+ //#region src/preset.ts
24
+ const previewAnnotations = async (entries = [], options) => {
25
+ const config = fileURLToPath(import.meta.resolve("ember-storybook/client/config"));
26
+ const annotations = [...entries, config];
27
+ const docsConfig = await options.presets.apply("docs", {}, options);
28
+ if (Object.keys(docsConfig).length > 0) {
29
+ const docsConfigPath = fileURLToPath(import.meta.resolve("ember-storybook/client/docs/config"));
30
+ annotations.push(docsConfigPath);
31
+ }
32
+ return annotations;
33
+ };
34
+ const viteFinal = async (config) => {
35
+ const { mergeConfig } = await import("vite");
36
+ config.plugins = await withoutVitePlugins(config.plugins, ["embroider-content-for"]);
37
+ return mergeConfig(config, {
38
+ optimizeDeps: { exclude: ["object-inspect"] },
39
+ resolve: { dedupe: ["ember-source"] }
40
+ });
41
+ };
42
+ const experimental_indexers = (indexers) => {
43
+ return [emberIndexer, ...indexers ?? []];
44
+ };
45
+ const core = async (config, options) => {
46
+ const framework = await options.presets.apply("framework");
47
+ return {
48
+ ...config,
49
+ builder: {
50
+ name: import.meta.resolve("@storybook/builder-vite"),
51
+ options: typeof framework === "string" ? {} : framework.options?.builder ?? {}
52
+ }
53
+ };
54
+ };
55
+ //#endregion
56
+ export { core, experimental_indexers, previewAnnotations, viteFinal };
57
+
58
+ //# sourceMappingURL=preset.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.mjs","names":["readFile","Preprocessor","loadCsf","parse","fileName","code","preprocessor","process","filename","readCsf","options","result","emberIndexer","test","createIndex","csf","indexInputs","fileURLToPath","withoutVitePlugins","emberIndexer","previewAnnotations","entries","options","config","import","meta","resolve","annotations","docsConfig","presets","apply","docsEnabled","Object","keys","length","docsConfigPath","push","viteFinal","mergeConfig","plugins","optimizeDeps","exclude","dedupe","experimental_indexers","indexers","core","framework","builder","name"],"sources":["../src/node/indexer.ts","../src/preset.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\n\nimport { Preprocessor } from 'content-tag';\nimport { type CsfOptions, loadCsf } from 'storybook/internal/csf-tools';\n\nimport type { Indexer, IndexerOptions, IndexInput } from 'storybook/internal/types';\n\nfunction parse(fileName: string, code: string) {\n const preprocessor = new Preprocessor();\n\n return preprocessor.process(code, { filename: fileName });\n}\n\nexport const readCsf = async (fileName: string, options: CsfOptions) => {\n const code = await readFile(fileName, 'utf8');\n const result = parse(fileName, code);\n\n return loadCsf(result.code, { ...options, fileName });\n};\n\nexport const emberIndexer: Indexer = {\n test: /\\.stories\\.g[tj]s$/,\n createIndex: async (fileName: string, options: IndexerOptions): Promise<IndexInput[]> => {\n const csf = await readCsf(fileName, options);\n\n return csf.parse().indexInputs;\n }\n};\n","import { fileURLToPath } from 'node:url';\n\nimport { type StorybookConfigVite, withoutVitePlugins } from '@storybook/builder-vite';\n\nimport { emberIndexer } from './node/indexer';\n\nimport type { StorybookConfig } from './types';\nimport type { PresetProperty } from 'storybook/internal/types';\nimport type { UserConfig } from 'vite';\n\nexport const previewAnnotations: PresetProperty<'previewAnnotations'> = async (\n // eslint-disable-next-line @typescript-eslint/default-param-last\n entries = [],\n options\n) => {\n const config = fileURLToPath(import.meta.resolve('ember-storybook/client/config'));\n const annotations = [...entries, config];\n\n const docsConfig = await options.presets.apply('docs', {}, options);\n const docsEnabled = Object.keys(docsConfig).length > 0;\n\n if (docsEnabled) {\n const docsConfigPath = fileURLToPath(import.meta.resolve('ember-storybook/client/docs/config'));\n\n annotations.push(docsConfigPath);\n }\n\n return annotations;\n};\n\nexport const viteFinal: StorybookConfigVite['viteFinal'] = async (config: UserConfig) => {\n const { mergeConfig } = await import('vite');\n\n config.plugins = await withoutVitePlugins(config.plugins, ['embroider-content-for']);\n\n return mergeConfig(config, {\n optimizeDeps: {\n // esbuild doesn't handle disabling modules when using plugins.\n // `object-inspect` gets pulled in by `qs` which is automatically\n // optimized by Storybook, and qs is a default dependency by ember-cli.\n // `object-inspect` isn't going to work in Ember with Vite, so it's\n // safe to exclude it.\n exclude: ['object-inspect']\n },\n resolve: {\n dedupe: ['ember-source']\n }\n });\n};\n\nexport const experimental_indexers: StorybookConfig['experimental_indexers'] = (indexers) => {\n return [emberIndexer, ...(indexers ?? [])];\n};\n\nexport const core: PresetProperty<'core'> = async (config, options) => {\n const framework = await options.presets.apply('framework');\n\n return {\n ...config,\n builder: {\n name: import.meta.resolve('@storybook/builder-vite'),\n options:\n typeof framework === 'string'\n ? {}\n : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ((framework.options?.builder ?? {}) as object)\n }\n };\n};\n"],"mappings":";;;;;;AAOA,SAASG,MAAMC,UA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A+B,OAAOtB,QAAQD,YAAY;CACrE,MAAMwB,YAAY,MAAMxB,QAAQO,QAAQC,MAAM,WAAW;CAEzD,OAAO;EACL,GAAGP;EACHwB,SAAS;GACPC,MAAMxB,OAAOC,KAAKC,QAAQ,yBAAyB;GACnDJ,SACE,OAAOwB,cAAc,WACjB,CAAC,IAECA,UAAUxB,SAASyB,WAAW,CAAC;EACzC;CACF;AACF"}
@@ -0,0 +1,87 @@
1
+ import Application from "@ember/application";
2
+ import ApplicationInstance from "@ember/application/instance";
3
+ //#region \0rolldown/runtime.js
4
+ var __defProp = Object.defineProperty;
5
+ var __exportAll = (all, no_symbols) => {
6
+ let target = {};
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
11
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
12
+ return target;
13
+ };
14
+ //#endregion
15
+ //#region src/client/render.ts
16
+ var render_exports = /* @__PURE__ */ __exportAll({
17
+ render: () => render,
18
+ renderToCanvas: () => renderToCanvas
19
+ });
20
+ const render = (args, context) => {
21
+ const { id, component } = context;
22
+ if (typeof component === "function") return component;
23
+ if (typeof component === "object") return component;
24
+ throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);
25
+ };
26
+ const contexts = /* @__PURE__ */ new Map();
27
+ function getAppOptions(opts) {
28
+ return {
29
+ ...opts,
30
+ autoboot: false
31
+ };
32
+ }
33
+ function buildAppInstance(application, opts) {
34
+ return application.create(getAppOptions(opts)).buildInstance();
35
+ }
36
+ function isApplication(maybeApp) {
37
+ return maybeApp.create !== void 0 && maybeApp.superclass && maybeApp.supeclass.name === "EmberApp";
38
+ }
39
+ function initApp(appOption, opts) {
40
+ if (appOption instanceof ApplicationInstance) return appOption;
41
+ if (isApplication(appOption)) return buildAppInstance(appOption, opts);
42
+ return initApp(appOption(getAppOptions(opts)), opts);
43
+ }
44
+ async function renderToCanvas({ storyFn, showMain, storyContext, forceRemount }, canvasElement) {
45
+ const { trackedObject } = await import("@ember/reactive/collections");
46
+ const { renderComponent } = await import("@ember/renderer");
47
+ const { destroy } = await import("@ember/destroyable");
48
+ const args = storyContext.args;
49
+ const Component = storyFn();
50
+ function unmount(element) {
51
+ const context = contexts.get(element);
52
+ if (!context) return;
53
+ contexts.delete(element);
54
+ context.renderer.destroy();
55
+ if (context.application) destroy(context.application);
56
+ }
57
+ if (forceRemount) unmount(canvasElement);
58
+ let application;
59
+ if (storyContext.parameters.ember?.app) {
60
+ const appOption = storyContext.parameters.ember.app;
61
+ application = initApp(appOption, { rootElement: canvasElement });
62
+ }
63
+ if (storyContext.parameters.ember?.owner) {
64
+ application ??= buildAppInstance(Application, { rootElement: canvasElement });
65
+ for (const [key, obj] of Object.entries(storyContext.parameters.ember.owner)) {
66
+ application.unregister(key);
67
+ application.register(key, obj);
68
+ }
69
+ }
70
+ const trackedArgs = trackedObject({ ...args });
71
+ const result = renderComponent(Component, {
72
+ args: trackedArgs,
73
+ into: canvasElement,
74
+ owner: application
75
+ });
76
+ contexts.set(canvasElement, {
77
+ application,
78
+ renderer: result,
79
+ args: trackedArgs
80
+ });
81
+ showMain();
82
+ return () => {};
83
+ }
84
+ //#endregion
85
+ export { renderToCanvas as n, render_exports as r, render as t };
86
+
87
+ //# sourceMappingURL=render-BUq_AxtY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-BUq_AxtY.mjs","names":["Application","ApplicationInstance","render","args","context","id","component","Error","contexts","Map","getAppOptions","opts","autoboot","buildAppInstance","application","create","buildInstance","isApplication","maybeApp","undefined","superclass","supeclass","name","initApp","appOption","renderToCanvas","storyFn","showMain","storyContext","forceRemount","canvasElement","trackedObject","renderComponent","destroy","Component","unmount","element","get","delete","renderer","parameters","ember","app","rootElement","owner","key","obj","Object","entries","unregister","register","trackedArgs","result","into","set"],"sources":["../src/client/render.ts"],"sourcesContent":["import Application from '@ember/application';\nimport ApplicationInstance from '@ember/application/instance';\n\nimport type { AppParamater, EmberRenderer, StoryContext } from './types';\nimport type { RenderResult } from '@ember/-internals/glimmer/lib/renderer';\nimport type { ArgsStoryFn, RenderContext } from 'storybook/internal/types';\n\ntype Args = Record<string, unknown>;\n\nexport const render: ArgsStoryFn<EmberRenderer> = (args, context) => {\n const { id, component } = context;\n\n if (typeof component === 'function') {\n return component;\n }\n\n if (typeof component === 'object') {\n return component;\n }\n\n throw new Error(\n `Unable to render story ${id} as the component annotation is missing from the default export`\n );\n};\n\nconst contexts = new Map<\n EmberRenderer['canvasElement'],\n {\n application: ApplicationInstance | undefined;\n renderer: RenderResult;\n args: Args;\n }\n>();\n\nfunction getAppOptions(opts: { rootElement: HTMLElement }) {\n return {\n ...opts,\n autoboot: false\n };\n}\n\nfunction buildAppInstance(application: typeof Application, opts: { rootElement: HTMLElement }) {\n return application.create(getAppOptions(opts)).buildInstance();\n}\n\nfunction isApplication(maybeApp: object): maybeApp is typeof Application {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (\n // @ts-expect-error well, ember types\n maybeApp.create !== undefined &&\n // @ts-expect-error well, ember types\n maybeApp.superclass &&\n // @ts-expect-error well, ember types\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n maybeApp.supeclass.name === 'EmberApp'\n );\n}\n\nfunction initApp(appOption: AppParamater, opts: { rootElement: HTMLElement }): ApplicationInstance {\n if (appOption instanceof ApplicationInstance) {\n return appOption;\n }\n\n if (isApplication(appOption)) {\n return buildAppInstance(appOption, opts);\n }\n\n // eslint-disable-next-line unicorn/no-useless-recursion\n return initApp(appOption(getAppOptions(opts)), opts);\n}\n\nexport async function renderToCanvas(\n {\n storyFn,\n showMain,\n storyContext,\n forceRemount\n }: RenderContext<EmberRenderer> & { storyContext: StoryContext },\n canvasElement: EmberRenderer['canvasElement']\n) {\n const { trackedObject } = await import('@ember/reactive/collections');\n const { renderComponent } = await import('@ember/renderer');\n const { destroy } = await import('@ember/destroyable');\n\n const args = storyContext.args;\n const Component = storyFn();\n\n function unmount(element: EmberRenderer['canvasElement']) {\n const context = contexts.get(element);\n\n if (!context) {\n return;\n }\n\n contexts.delete(element);\n context.renderer.destroy();\n\n if (context.application) {\n destroy(context.application);\n }\n }\n\n if (forceRemount) {\n unmount(canvasElement);\n }\n\n // this check does not work:\n // when globals are updated, that are interesting for a decorato\n // this check would prevent that update\n\n // const context = contexts.get(canvasElement);\n // if (context && !forceRemount && args) {\n // updateArgs(context.args, args);\n // return () => {\n // unmount(canvasElement);\n // };\n // }\n\n // find the ember app for the story\n let application: ApplicationInstance | undefined;\n\n if (storyContext.parameters.ember?.app) {\n const appOption = storyContext.parameters.ember.app;\n\n application = initApp(appOption, { rootElement: canvasElement });\n }\n\n // modify the owner for the story\n if (storyContext.parameters.ember?.owner) {\n application ??= buildAppInstance(Application, { rootElement: canvasElement });\n\n for (const [key, obj] of Object.entries(storyContext.parameters.ember.owner) as [\n `${string}:${string}`,\n object\n ][]) {\n application.unregister(key);\n application.register(key, obj);\n }\n }\n\n const trackedArgs = trackedObject({ ...args });\n const result = renderComponent(Component, {\n args: trackedArgs,\n into: canvasElement,\n owner: application\n });\n\n contexts.set(canvasElement, { application, renderer: result, args: trackedArgs });\n\n showMain();\n\n // eslint-disable-next-line unicorn/consistent-function-scoping\n return () => {\n // needs fix:\n // unmount(canvasElement);\n };\n}\n\n// function updateArgs(currentArgs: Args, nextArgs: Args) {\n// for (const key of Object.keys(currentArgs)) {\n// if (!(key in nextArgs)) {\n// delete currentArgs[key];\n// }\n// }\n\n// Object.assign(currentArgs, nextArgs);\n// }\n"],"mappings":";;;;;;;;;;;;;;;;;;;AASA,MAAaE,UAAsCC,MAAMC,YAAY;CACnE,MAAM,EAAEC,IAAIC,cAAcF;CAE1B,IAAI,OAAOE,cAAc,YACvB,OAAOA;CAGT,IAAI,OAAOA,cAAc,UACvB,OAAOA;CAGT,MAAM,IAAIC,MACR,0BAA0BF,GAAE,gEAC9B;AACF;AAEA,MAAMG,2BAAW,IAAIC,IAOnB;AAEF,SAASC,cAAcC,MAAoC;CACzD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,CAACe,KAAKC,QAAQC,OAAOC,QAAQpB,aAAaY,WAAWC,MAAMG,KAAK,GAGtE;GACH9B,YAAYmC,WAAWJ,GAAG;GAC1B/B,YAAYoC,SAASL,KAAKC,GAAG;EAC/B;CACF;CAEA,MAAMK,cAAcpB,cAAc,EAAE,GAAG5B,KAAK,CAAC;CAC7C,MAAMiD,SAASpB,gBAAgBE,WAAW;EACxC/B,MAAMgD;EACNE,MAAMvB;EACNc,OAAO9B;CACT,CAAC;CAEDN,SAAS8C,IAAIxB,eAAe;EAAEhB;EAAayB,UAAUa;EAAQjD,MAAMgD;CAAY,CAAC;CAEhFxB,SAAS;CAGT,aAAa,CAEX;AAEJ"}
package/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "ember-storybook",
3
+ "version": "0.0.0",
4
+ "license": "MIT",
5
+ "description": "Storybook for Ember: Develop, document, and test UI components in isolation",
6
+ "keywords": [
7
+ "storybook",
8
+ "storybook-framework",
9
+ "ember",
10
+ "component",
11
+ "components"
12
+ ],
13
+ "bugs": {
14
+ "url": "https://github.com/ember-integrations/ember-storybook/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/ember-integrations/ember-storybook"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./declarations/index.d.ts",
27
+ "default": "./dist/index.mjs"
28
+ },
29
+ "./client": {
30
+ "types": "./declarations/client/index.d.ts",
31
+ "default": "./dist/client/index.mjs"
32
+ },
33
+ "./client/config": {
34
+ "types": "./declarations/client/config.d.ts",
35
+ "default": "./dist/client/config.mjs"
36
+ },
37
+ "./client/docs/config": {
38
+ "types": "./declarations/client/docs/config.d.ts",
39
+ "default": "./dist/client/docs/config.mjs"
40
+ },
41
+ "./node": {
42
+ "types": "./declarations/node/index.d.ts",
43
+ "default": "./dist/node/index.mjs"
44
+ },
45
+ "./package.json": "./package.json",
46
+ "./preset": {
47
+ "types": "./declarations/preset.d.ts",
48
+ "default": "./dist/preset.mjs"
49
+ }
50
+ },
51
+ "files": [
52
+ "dist",
53
+ "declarations",
54
+ "README.md"
55
+ ],
56
+ "dependencies": {
57
+ "@storybook/builder-vite": "^10.5.0",
58
+ "@storybook/global": "^5.0.0",
59
+ "content-tag": "^4.0.0",
60
+ "ember-modifier": "4.3.0",
61
+ "ts-dedent": "^2.0.0"
62
+ },
63
+ "devDependencies": {
64
+ "@babel/core": "^7.29.0",
65
+ "@babel/plugin-transform-typescript": "^7.28.6",
66
+ "@embroider/addon-dev": "^8.3.1",
67
+ "@embroider/vite": "^1.7.8",
68
+ "@glimmer/component": "^2.1.1",
69
+ "@glint/ember-tsc": "1.8.11",
70
+ "@glint/template": "1.7.8",
71
+ "@gossi/config-eslint": "^1.3.4",
72
+ "@gossi/config-prettier": "^1.2.2",
73
+ "@rollup/plugin-babel": "^7.1.0",
74
+ "@types/node": "^26.1.0",
75
+ "ember-source": "^6.8.0",
76
+ "eslint": "^10.6.0",
77
+ "prettier": "^3.9.5",
78
+ "storybook": "^10.5.0",
79
+ "tsdown": "^0.22.4",
80
+ "typescript": "^6.0.3",
81
+ "vite": "^8.1.3"
82
+ },
83
+ "peerDependencies": {
84
+ "@glimmer/component": "^2.1.1",
85
+ "ember-source": ">=6.8.0",
86
+ "storybook": "^10.5.0",
87
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
88
+ },
89
+ "engines": {
90
+ "node": ">=24.0.0"
91
+ },
92
+ "scripts": {
93
+ "build": "tsdown",
94
+ "start": "tsdown --watch",
95
+ "lint": "pnpm run '/^lint:(?!.*(fix)).*$/'",
96
+ "lint:fix": "pnpm run '/^lint:[^:]*:fix/'",
97
+ "lint:js": "eslint . --cache",
98
+ "lint:js:fix": "eslint . --fix",
99
+ "lint:types": "ember-tsc --noEmit"
100
+ }
101
+ }