@aurelia/storybook 2.1.0 → 2.3.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 (116) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +195 -12
  3. package/dist/index.d.ts +25 -0
  4. package/dist/index.js +101 -27
  5. package/dist/index.js.map +1 -1
  6. package/dist/preset.d.ts +21 -0
  7. package/dist/preset.js +74 -20
  8. package/dist/preset.js.map +1 -1
  9. package/dist/preview/helpers.d.ts +2 -0
  10. package/dist/preview/helpers.js +6 -0
  11. package/dist/preview/helpers.js.map +1 -0
  12. package/dist/preview/render.d.ts +7 -0
  13. package/dist/preview/render.js +99 -28
  14. package/dist/preview/render.js.map +1 -1
  15. package/dist/preview/storybook-types-runtime.d.ts +1 -0
  16. package/dist/preview/storybook-types-runtime.js +5 -0
  17. package/dist/preview/storybook-types-runtime.js.map +1 -0
  18. package/dist/preview/storybook-types.d.ts +27 -0
  19. package/dist/preview/types-runtime.d.ts +1 -0
  20. package/dist/preview/types-runtime.js +5 -0
  21. package/dist/preview/types-runtime.js.map +1 -0
  22. package/dist/preview/types.d.ts +44 -0
  23. package/dist/preview.d.ts +3 -0
  24. package/dist/preview.js +104 -29
  25. package/dist/preview.js.map +1 -1
  26. package/dist/webpack.d.ts +10 -0
  27. package/dist/webpack.js +19 -1
  28. package/dist/webpack.js.map +1 -1
  29. package/package.json +75 -15
  30. package/preset.js +2 -1
  31. package/CONTINUITY.md +0 -22
  32. package/__tests__/preset.test.ts +0 -49
  33. package/__tests__/preview.test.ts +0 -139
  34. package/__tests__/render.test.ts +0 -187
  35. package/__tests__/webpack.test.ts +0 -21
  36. package/apps/hello-world/.storybook/main.ts +0 -49
  37. package/apps/hello-world/.storybook/preview.ts +0 -1
  38. package/apps/hello-world/.stylelintrc.json +0 -5
  39. package/apps/hello-world/README.md +0 -28
  40. package/apps/hello-world/eslint.config.mjs +0 -25
  41. package/apps/hello-world/favicon.ico +0 -0
  42. package/apps/hello-world/index.html +0 -17
  43. package/apps/hello-world/package-lock.json +0 -9307
  44. package/apps/hello-world/package.json +0 -55
  45. package/apps/hello-world/src/components/feedback-form.html +0 -111
  46. package/apps/hello-world/src/components/feedback-form.ts +0 -45
  47. package/apps/hello-world/src/components/notification-center.html +0 -119
  48. package/apps/hello-world/src/components/notification-center.ts +0 -27
  49. package/apps/hello-world/src/components/stat-card.html +0 -107
  50. package/apps/hello-world/src/components/stat-card.ts +0 -33
  51. package/apps/hello-world/src/components/weather-widget.html +0 -89
  52. package/apps/hello-world/src/components/weather-widget.ts +0 -30
  53. package/apps/hello-world/src/hello-world.html +0 -48
  54. package/apps/hello-world/src/hello-world.ts +0 -17
  55. package/apps/hello-world/src/main.ts +0 -6
  56. package/apps/hello-world/src/my-app.html +0 -1
  57. package/apps/hello-world/src/my-app.ts +0 -3
  58. package/apps/hello-world/src/resource.d.ts +0 -15
  59. package/apps/hello-world/src/services/weather-service.ts +0 -15
  60. package/apps/hello-world/src/stories/feedback-form.stories.ts +0 -52
  61. package/apps/hello-world/src/stories/hello-world.stories.ts +0 -53
  62. package/apps/hello-world/src/stories/notification-center.stories.ts +0 -81
  63. package/apps/hello-world/src/stories/stat-card.stories.ts +0 -65
  64. package/apps/hello-world/src/stories/weather-widget.stories.ts +0 -57
  65. package/apps/hello-world/test/my-app.spec.ts +0 -15
  66. package/apps/hello-world/test/setup.ts +0 -29
  67. package/apps/hello-world/tsconfig.json +0 -19
  68. package/apps/hello-world/tsconfig.vitest.json +0 -11
  69. package/apps/hello-world/vite.config.ts +0 -17
  70. package/apps/hello-world/vitest.config.ts +0 -15
  71. package/apps/hello-world-webpack/.env.development +0 -0
  72. package/apps/hello-world-webpack/.storybook/main.ts +0 -14
  73. package/apps/hello-world-webpack/.storybook/preview.ts +0 -3
  74. package/apps/hello-world-webpack/.stylelintrc.json +0 -5
  75. package/apps/hello-world-webpack/README.md +0 -29
  76. package/apps/hello-world-webpack/eslint.config.mjs +0 -25
  77. package/apps/hello-world-webpack/favicon.ico +0 -0
  78. package/apps/hello-world-webpack/index.html +0 -15
  79. package/apps/hello-world-webpack/package-lock.json +0 -9853
  80. package/apps/hello-world-webpack/package.json +0 -51
  81. package/apps/hello-world-webpack/src/components/feedback-form.html +0 -111
  82. package/apps/hello-world-webpack/src/components/feedback-form.ts +0 -45
  83. package/apps/hello-world-webpack/src/components/notification-center.html +0 -119
  84. package/apps/hello-world-webpack/src/components/notification-center.ts +0 -27
  85. package/apps/hello-world-webpack/src/components/stat-card.html +0 -107
  86. package/apps/hello-world-webpack/src/components/stat-card.ts +0 -33
  87. package/apps/hello-world-webpack/src/components/weather-widget.html +0 -89
  88. package/apps/hello-world-webpack/src/components/weather-widget.ts +0 -30
  89. package/apps/hello-world-webpack/src/hello-world.html +0 -48
  90. package/apps/hello-world-webpack/src/hello-world.ts +0 -17
  91. package/apps/hello-world-webpack/src/main.ts +0 -6
  92. package/apps/hello-world-webpack/src/my-app.css +0 -3
  93. package/apps/hello-world-webpack/src/my-app.html +0 -1
  94. package/apps/hello-world-webpack/src/my-app.stories.ts +0 -15
  95. package/apps/hello-world-webpack/src/my-app.ts +0 -3
  96. package/apps/hello-world-webpack/src/resource.d.ts +0 -13
  97. package/apps/hello-world-webpack/src/services/weather-service.ts +0 -15
  98. package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +0 -52
  99. package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +0 -53
  100. package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +0 -81
  101. package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +0 -65
  102. package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +0 -57
  103. package/apps/hello-world-webpack/tsconfig.json +0 -18
  104. package/apps/hello-world-webpack/webpack.config.js +0 -111
  105. package/dist/preview/types.js +0 -2
  106. package/dist/preview/types.js.map +0 -1
  107. package/jest.config.js +0 -9
  108. package/rollup.config.mjs +0 -50
  109. package/src/index.ts +0 -32
  110. package/src/preset.ts +0 -49
  111. package/src/preview/render.ts +0 -175
  112. package/src/preview/types.ts +0 -7
  113. package/src/preview.ts +0 -1
  114. package/src/webpack.ts +0 -21
  115. package/tsconfig.build.json +0 -5
  116. package/tsconfig.json +0 -15
package/dist/preset.js CHANGED
@@ -16,29 +16,84 @@ function getRules() {
16
16
  },
17
17
  ];
18
18
  }
19
+ /**
20
+ * Rsbuild/Rspack rules (avoid ts-loader; Rsbuild handles TS transpilation).
21
+ */
22
+ function getRsbuildRules() {
23
+ return [
24
+ {
25
+ test: /\.ts$/i,
26
+ enforce: 'pre',
27
+ use: ['@aurelia/webpack-loader'],
28
+ exclude: /node_modules/,
29
+ },
30
+ {
31
+ test: /\.html$/i,
32
+ use: '@aurelia/webpack-loader',
33
+ exclude: /node_modules/,
34
+ },
35
+ ];
36
+ }
19
37
 
20
38
  // src/preset.ts
21
39
  // Minimal preset for Storybook-Aurelia2
40
+ function addUnique(existing, entries) {
41
+ return Array.from(new Set([...(existing ?? []), ...entries]));
42
+ }
43
+ function ruleKey(rule) {
44
+ const use = Array.isArray(rule.use) ? rule.use.join('|') : String(rule.use ?? '');
45
+ return `${String(rule.test)}::${use}::${String(rule.enforce ?? '')}`;
46
+ }
47
+ function appendUniqueRules(existing, rules) {
48
+ const seen = new Set(existing.map(ruleKey));
49
+ for (const rule of rules) {
50
+ const key = ruleKey(rule);
51
+ if (!seen.has(key)) {
52
+ existing.push(rule);
53
+ seen.add(key);
54
+ }
55
+ }
56
+ return existing;
57
+ }
22
58
  /**
23
59
  * Optionally adjust the Vite configuration.
24
60
  */
25
61
  async function viteFinal(config) {
26
- // Configure Vite to properly handle dependencies
27
- config.define = config.define || {};
28
- config.define['process.env.NODE_ENV'] = JSON.stringify(process.env.NODE_ENV || 'development');
29
- // Configure optimization deps
30
- config.optimizeDeps = config.optimizeDeps || {};
31
- config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
32
- // Only exclude Aurelia-specific dependencies that cause issues
33
- const excludeList = [
34
- '@aurelia/runtime-html'
35
- ];
36
- excludeList.forEach(dep => {
37
- if (!config.optimizeDeps.exclude.includes(dep)) {
38
- config.optimizeDeps.exclude.push(dep);
62
+ config.define = {
63
+ ...(config.define ?? {}),
64
+ 'process.env.NODE_ENV': config.define?.['process.env.NODE_ENV'] ?? JSON.stringify(process.env.NODE_ENV || 'development'),
65
+ };
66
+ config.optimizeDeps = {
67
+ ...(config.optimizeDeps ?? {}),
68
+ exclude: addUnique(config.optimizeDeps?.exclude, ['@aurelia/runtime-html']),
69
+ };
70
+ return config;
71
+ }
72
+ async function loadMergeRsbuildConfig() {
73
+ try {
74
+ const { mergeRsbuildConfig } = await import('@rsbuild/core');
75
+ return mergeRsbuildConfig;
76
+ }
77
+ catch (error) {
78
+ const message = error instanceof Error ? error.message : String(error);
79
+ throw new Error(`@aurelia/storybook: rsbuild support requires @rsbuild/core to be installed. Original error: ${message}`);
80
+ }
81
+ }
82
+ /**
83
+ * Optionally adjust the Rsbuild configuration (Rspack-based).
84
+ */
85
+ async function rsbuildFinal(config) {
86
+ const mergeRsbuildConfig = await loadMergeRsbuildConfig();
87
+ return mergeRsbuildConfig(config, {
88
+ tools: {
89
+ rspack: (rspackConfig) => {
90
+ const moduleConfig = rspackConfig.module ?? (rspackConfig.module = {});
91
+ const rules = moduleConfig.rules ?? (moduleConfig.rules = []);
92
+ appendUniqueRules(rules, getRsbuildRules());
93
+ return rspackConfig;
94
+ }
39
95
  }
40
96
  });
41
- return config;
42
97
  }
43
98
  /**
44
99
  * A function to configure webpack.
@@ -46,15 +101,14 @@ async function viteFinal(config) {
46
101
  * @returns
47
102
  */
48
103
  async function webpackFinal(config) {
49
- const rules = config.module?.rules;
50
- if (rules) {
51
- rules.push(...getRules());
52
- }
104
+ const moduleConfig = config.module ?? (config.module = {});
105
+ const rules = moduleConfig.rules ?? (moduleConfig.rules = []);
106
+ appendUniqueRules(rules, getRules());
53
107
  return config;
54
108
  }
55
109
  // Export a default for compatibility.
56
- var preset = { viteFinal, webpackFinal };
110
+ var preset = { viteFinal, rsbuildFinal, webpackFinal };
57
111
  const previewAnnotations = ['./preview.js'];
58
112
 
59
- export { preset as default, previewAnnotations, viteFinal, webpackFinal };
113
+ export { preset as default, previewAnnotations, rsbuildFinal, viteFinal, webpackFinal };
60
114
  //# sourceMappingURL=preset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","sources":["../src/webpack.ts","../src/preset.ts"],"sourcesContent":["// src/webpack.ts\nimport type { RuleSetRule } from 'webpack';\n\n/**\n * A set of rules to be added to the webpack configuration.\n * @returns\n */\nexport function getRules(): RuleSetRule[] {\n return [\n {\n test: /\\.ts$/i,\n use: ['ts-loader', '@aurelia/webpack-loader'],\n exclude: /node_modules/,\n },\n {\n test: /\\.html$/i,\n use: '@aurelia/webpack-loader',\n exclude: /node_modules/,\n },\n ];\n}\n","// src/preset.ts\n// Minimal preset for Storybook-Aurelia2\n\nimport { getRules } from './webpack';\n\n/**\n * Optionally adjust the Vite configuration.\n */\nexport async function viteFinal(config: any): Promise<any> {\n // Configure Vite to properly handle dependencies\n config.define = config.define || {};\n config.define['process.env.NODE_ENV'] = JSON.stringify(process.env.NODE_ENV || 'development');\n \n // Configure optimization deps\n config.optimizeDeps = config.optimizeDeps || {};\n config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];\n \n // Only exclude Aurelia-specific dependencies that cause issues\n const excludeList = [\n '@aurelia/runtime-html'\n ];\n \n excludeList.forEach(dep => {\n if (!config.optimizeDeps.exclude.includes(dep)) {\n config.optimizeDeps.exclude.push(dep);\n }\n });\n \n return config;\n}\n\n/**\n * A function to configure webpack.\n * @param config\n * @returns\n */\nexport async function webpackFinal(config: any): Promise<any> {\n const rules = config.module?.rules;\n if (rules) {\n rules.push(...getRules());\n }\n\n return config;\n}\n\n// Export a default for compatibility.\nexport default { viteFinal, webpackFinal };\n\nexport const previewAnnotations = ['./preview.js'];\n"],"names":[],"mappings":"AAGA;;;AAGG;SACa,QAAQ,GAAA;IACtB,OAAO;AAC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AE,SAAS,EAAE,YAAY,EAAE;AAEnC,MAAM,kBAAkB,GAAG,CAAC,cAAc;;;;"}
1
+ {"version":3,"file":"preset.js","sources":["../src/webpack.ts","../src/preset.ts"],"sourcesContent":["// src/webpack.ts\nimport type { RuleSetRule } from 'webpack';\n\n/**\n * A set of rules to be added to the webpack configuration.\n * @returns\n */\nexport function getRules(): RuleSetRule[] {\n return [\n {\n test: /\\.ts$/i,\n use: ['ts-loader', '@aurelia/webpack-loader'],\n exclude: /node_modules/,\n },\n {\n test: /\\.html$/i,\n use: '@aurelia/webpack-loader',\n exclude: /node_modules/,\n },\n ];\n}\n\n/**\n * Rsbuild/Rspack rules (avoid ts-loader; Rsbuild handles TS transpilation).\n */\nexport function getRsbuildRules(): RuleSetRule[] {\n return [\n {\n test: /\\.ts$/i,\n enforce: 'pre',\n use: ['@aurelia/webpack-loader'],\n exclude: /node_modules/,\n },\n {\n test: /\\.html$/i,\n use: '@aurelia/webpack-loader',\n exclude: /node_modules/,\n },\n ];\n}\n","// src/preset.ts\n// Minimal preset for Storybook-Aurelia2\n\nimport { getRules, getRsbuildRules } from './webpack';\n\nfunction addUnique<T>(existing: T[] | undefined, entries: T[]): T[] {\n return Array.from(new Set([...(existing ?? []), ...entries]));\n}\n\nfunction ruleKey(rule: any): string {\n const use = Array.isArray(rule.use) ? rule.use.join('|') : String(rule.use ?? '');\n return `${String(rule.test)}::${use}::${String(rule.enforce ?? '')}`;\n}\n\nfunction appendUniqueRules(existing: any[], rules: any[]): any[] {\n const seen = new Set(existing.map(ruleKey));\n for (const rule of rules) {\n const key = ruleKey(rule);\n if (!seen.has(key)) {\n existing.push(rule);\n seen.add(key);\n }\n }\n return existing;\n}\n\n/**\n * Optionally adjust the Vite configuration.\n */\nexport async function viteFinal(config: any): Promise<any> {\n config.define = {\n ...(config.define ?? {}),\n 'process.env.NODE_ENV': config.define?.['process.env.NODE_ENV'] ?? JSON.stringify(process.env.NODE_ENV || 'development'),\n };\n\n config.optimizeDeps = {\n ...(config.optimizeDeps ?? {}),\n exclude: addUnique(config.optimizeDeps?.exclude, ['@aurelia/runtime-html']),\n };\n\n return config;\n}\n\nasync function loadMergeRsbuildConfig() {\n try {\n const { mergeRsbuildConfig } = await import('@rsbuild/core');\n return mergeRsbuildConfig;\n } catch (error: any) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(\n `@aurelia/storybook: rsbuild support requires @rsbuild/core to be installed. Original error: ${message}`\n );\n }\n}\n\n/**\n * Optionally adjust the Rsbuild configuration (Rspack-based).\n */\nexport async function rsbuildFinal(config: any): Promise<any> {\n const mergeRsbuildConfig = await loadMergeRsbuildConfig();\n\n return mergeRsbuildConfig(config, {\n tools: {\n rspack: (rspackConfig: any) => {\n const moduleConfig = rspackConfig.module ?? (rspackConfig.module = {});\n const rules = moduleConfig.rules ?? (moduleConfig.rules = []);\n appendUniqueRules(rules, getRsbuildRules());\n return rspackConfig;\n }\n }\n });\n}\n\n/**\n * A function to configure webpack.\n * @param config\n * @returns\n */\nexport async function webpackFinal(config: any): Promise<any> {\n const moduleConfig = config.module ?? (config.module = {});\n const rules = moduleConfig.rules ?? (moduleConfig.rules = []);\n appendUniqueRules(rules, getRules());\n\n return config;\n}\n\n// Export a default for compatibility.\nexport default { viteFinal, rsbuildFinal, webpackFinal };\n\nexport const previewAnnotations = ['./preview.js'];\n"],"names":[],"mappings":"AAGA;;;AAGG;SACa,QAAQ,GAAA;IACtB,OAAO;AACL,QAAA;AACE,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,GAAG,EAAE,CAAC,WAAW,EAAE,yBAAyB,CAAC;AAC7C,YAAA,OAAO,EAAE,cAAc;AACxB,SAAA;AACD,QAAA;AACE,YAAA,IAAI,EAAE,UAAU;AAChB,YAAA,GAAG,EAAE,yBAAyB;AAC9B,YAAA,OAAO,EAAE,cAAc;AACxB,SAAA;KACF;AACH;AAEA;;AAEG;SACa,eAAe,GAAA;IAC7B,OAAO;AACL,QAAA;AACE,YAAA,IAAI,EAAE,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AC,KAAK,GAAG,EAAE,CAAC;AAC7D,gBAAA,iBAAiB,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC;AAC3C,gBAAA,OAAO,YAAY;YACvB;AACH;AACJ,KAAA,CAAC;AACN;AAEA;;;;AAIG;AACI,eAAe,YAAY,CAAC,MAAW,EAAA;AAC1C,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;AAC1D,IAAA,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,GAAG,EAAE,CAAC;AAC7D,IAAA,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;AAEpC,IAAA,OAAO,MAAM;AACjB;AAEA;AACA,aAAe,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE;AAEjD,MAAM,kBAAkB,GAAG,CAAC,cAAc;;;;"}
@@ -0,0 +1,2 @@
1
+ import type { AureliaStoryResult } from './types';
2
+ export declare function defineAureliaStory<TArgs = Record<string, unknown>>(story: AureliaStoryResult<TArgs>): AureliaStoryResult<TArgs>;
@@ -0,0 +1,6 @@
1
+ function defineAureliaStory(story) {
2
+ return story;
3
+ }
4
+
5
+ export { defineAureliaStory };
6
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../src/preview/helpers.ts"],"sourcesContent":["import type { AureliaStoryResult } from './types';\n\nexport function defineAureliaStory<TArgs = Record<string, unknown>>(\n story: AureliaStoryResult<TArgs>\n): AureliaStoryResult<TArgs> {\n return story;\n}\n"],"names":[],"mappings":"AAEM,SAAU,kBAAkB,CAChC,KAAgC,EAAA;AAEhC,IAAA,OAAO,KAAK;AACd;;;;"}
@@ -0,0 +1,7 @@
1
+ import type { RenderContext, ArgsStoryFn } from './storybook-types';
2
+ import type { AureliaRenderer, AureliaStoryResult, AureliaStoryContext } from './types';
3
+ import Aurelia, { Constructable } from 'aurelia';
4
+ export declare const render: ArgsStoryFn<AureliaRenderer>;
5
+ export declare function renderToCanvas({ storyFn, title, name, showMain, showError, storyContext, forceRemount, }: RenderContext<AureliaRenderer>, canvasElement: HTMLElement, bootstrapAppFn?: typeof createAureliaApp): Promise<() => void>;
6
+ export declare function createAureliaApp(story: AureliaStoryResult, args: Record<string, any>, domElement: HTMLElement, component?: Constructable, storyContext?: AureliaStoryContext): Omit<Aurelia, "app" | "enhance" | "register">;
7
+ export declare function createComponentTemplate(component: Constructable, innerHtml?: string): string;
@@ -1,22 +1,45 @@
1
1
  import Aurelia, { CustomElement } from 'aurelia';
2
2
 
3
- // Track Aurelia apps for cleanup
4
3
  const appMap = new Map();
5
- async function teardown(element) {
6
- if (appMap.has(element)) {
7
- const app = appMap.get(element);
8
- if (app) {
9
- await app.stop();
10
- appMap.delete(element);
11
- }
4
+ function mergeStoryProps(parameters, storyArgs, storyProps) {
5
+ return { ...parameters?.args, ...storyArgs, ...storyProps };
6
+ }
7
+ function getAureliaParameters(storyContext) {
8
+ const parameters = storyContext?.parameters?.aurelia;
9
+ if (!parameters || typeof parameters !== 'object') {
10
+ return undefined;
11
+ }
12
+ return parameters;
13
+ }
14
+ function normalizeRegistrations(parameters) {
15
+ if (!parameters) {
16
+ return [];
17
+ }
18
+ const register = Array.isArray(parameters.register) ? parameters.register : [];
19
+ const components = Array.isArray(parameters.components) ? parameters.components : [];
20
+ const items = Array.isArray(parameters.items) ? parameters.items : [];
21
+ return [...register, ...components, ...items].filter(Boolean);
22
+ }
23
+ async function teardown(element, expectedApp) {
24
+ const mounted = appMap.get(element);
25
+ if (!mounted) {
26
+ return;
27
+ }
28
+ if (expectedApp && mounted.app !== expectedApp) {
29
+ return;
30
+ }
31
+ appMap.delete(element);
32
+ if (typeof mounted.app?.stop === 'function') {
33
+ await mounted.app.stop();
12
34
  }
13
35
  }
14
36
  const render = (args, context) => {
15
37
  const { id, component: Component } = context;
16
38
  if (!Component) {
17
- throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);
39
+ const label = context.title && context.name ? `${context.title} / ${context.name}` : id;
40
+ throw new Error(`Unable to render story ${label} as the component annotation is missing from the default export`);
18
41
  }
19
- return { Component, props: args, template: '' };
42
+ return { Component, props: args };
20
43
  };
21
44
  async function renderToCanvas({ storyFn, title, name, showMain, showError, storyContext, forceRemount, }, canvasElement, bootstrapAppFn) {
22
45
  // Store reference to the original storybook root element
@@ -38,10 +61,10 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
38
61
  // All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe
39
62
  const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;
40
63
  const { parameters, component, args } = storyContext;
41
- let app = appMap.get(rootElement);
64
+ const storyId = storyContext.id ?? `${title}--${name}`;
65
+ const mounted = appMap.get(rootElement);
66
+ let app = mounted?.app;
42
67
  const story = storyFn();
43
- // Temporary debug logging
44
- console.log(`[DEBUG] Story: ${name}, forceRemount: ${forceRemount}, hasExistingApp: ${!!app}, canvasId: ${canvasElement.className}`);
45
68
  if (!story) {
46
69
  showError({
47
70
  title: `Expecting an Aurelia component from the story: "${name}" of "${title}".`,
@@ -52,44 +75,87 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
52
75
  });
53
76
  return () => { };
54
77
  }
78
+ if (!component && !story.template) {
79
+ showError({
80
+ title: `Expecting a template or component from the story: "${name}" of "${title}".`,
81
+ description: `
82
+ Provide a component on the default export or return "{ template: '<custom-component></custom-component>' }" from the story.
83
+ `,
84
+ });
85
+ return () => { };
86
+ }
55
87
  showMain();
56
- if (!app || forceRemount) {
88
+ const shouldRemount = !app || forceRemount || mounted?.id !== storyId;
89
+ if (shouldRemount) {
57
90
  if (forceRemount && app) {
58
- await teardown(rootElement);
91
+ await teardown(rootElement, app);
92
+ app = undefined;
93
+ }
94
+ if (mounted?.id !== storyId && app) {
95
+ await teardown(rootElement, app);
59
96
  app = undefined;
60
97
  }
61
98
  // Clear container before mounting new app
62
99
  hostElement.innerHTML = '';
63
- const mergedProps = { ...parameters?.args, ...args, ...story.props };
64
- const aureliaApp = appBootstrapFn(story, mergedProps, hostElement, component);
100
+ const mergedProps = mergeStoryProps(parameters, args, story.props);
101
+ const aureliaApp = appBootstrapFn(story, mergedProps, hostElement, component, storyContext);
65
102
  await aureliaApp.start();
66
- appMap.set(rootElement, aureliaApp);
103
+ appMap.set(rootElement, { id: storyId, app: aureliaApp });
67
104
  app = aureliaApp;
68
105
  }
69
106
  else {
70
107
  // update existing app props
71
- const mergedProps = { ...parameters?.args, ...args, ...story.props };
108
+ const mergedProps = mergeStoryProps(parameters, args, story.props);
72
109
  if (app?.root?.controller?.viewModel) {
73
110
  Object.assign(app.root.controller.viewModel, mergedProps);
74
111
  }
75
112
  }
76
113
  // Return cleanup fn
114
+ const appForCleanup = app;
77
115
  return async () => {
78
- await teardown(rootElement);
116
+ await teardown(rootElement, appForCleanup);
79
117
  };
80
118
  }
81
- function createAureliaApp(story, args, domElement, component) {
119
+ function createAureliaApp(story, args, domElement, component, storyContext) {
82
120
  const aurelia = new Aurelia(story.container);
83
- if (story.items?.length) {
84
- aurelia.register(...story.items);
121
+ const { container } = aurelia;
122
+ const aureliaParameters = getAureliaParameters(storyContext);
123
+ const registerIfNeeded = (resource) => {
124
+ if (!resource) {
125
+ return;
126
+ }
127
+ if (CustomElement.isType(resource)) {
128
+ const definition = CustomElement.getDefinition(resource);
129
+ if (container.has(definition.key, false)) {
130
+ return;
131
+ }
132
+ }
133
+ aurelia.register(resource);
134
+ };
135
+ const registerAll = (resources) => {
136
+ if (!resources?.length) {
137
+ return;
138
+ }
139
+ for (const resource of resources) {
140
+ registerIfNeeded(resource);
141
+ }
142
+ };
143
+ if (aureliaParameters?.configureContainer && storyContext) {
144
+ aureliaParameters.configureContainer(container, storyContext);
85
145
  }
86
- if (story.components?.length) {
87
- aurelia.register(...story.components);
146
+ registerAll(normalizeRegistrations(aureliaParameters));
147
+ registerAll(story.items);
148
+ const storyComponents = (story.components ?? []).filter(Boolean);
149
+ const dedupedComponents = component
150
+ ? storyComponents.filter((entry) => entry !== component)
151
+ : storyComponents;
152
+ for (const entry of dedupedComponents) {
153
+ registerIfNeeded(entry);
88
154
  }
89
155
  let { template } = story;
90
156
  if (component) {
91
157
  template = template ?? createComponentTemplate(component, story.innerHtml);
92
- aurelia.register(component);
158
+ registerIfNeeded(component);
93
159
  }
94
160
  const App = CustomElement.define({
95
161
  name: 'sb-app',
@@ -98,6 +164,9 @@ function createAureliaApp(story, args, domElement, component) {
98
164
  }, class {
99
165
  });
100
166
  const app = Object.assign(new App(), args);
167
+ if (aureliaParameters?.configure && storyContext) {
168
+ aureliaParameters.configure(aurelia, storyContext);
169
+ }
101
170
  return aurelia.app({
102
171
  host: domElement,
103
172
  component: app,
@@ -105,9 +174,11 @@ function createAureliaApp(story, args, domElement, component) {
105
174
  }
106
175
  function createComponentTemplate(component, innerHtml) {
107
176
  const def = CustomElement.getDefinition(component);
108
- return `<${def.name} ${Object.values(def.bindables)
177
+ const bindings = Object.values(def.bindables ?? {})
109
178
  .map((bindable) => `${bindable.attribute}.bind="${bindable.name}"`)
110
- .join(' ')}>${innerHtml ?? ''}</${def.name}>`;
179
+ .join(' ');
180
+ const bindingAttributes = bindings ? ` ${bindings}` : '';
181
+ return `<${def.name}${bindingAttributes}>${innerHtml ?? ''}</${def.name}>`;
111
182
  }
112
183
 
113
184
  export { createAureliaApp, createComponentTemplate, render, renderToCanvas };
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sources":["../../src/preview/render.ts"],"sourcesContent":["import { STORY_CHANGED } from 'storybook/internal/core-events';\nimport type { RenderContext, ArgsStoryFn } from 'storybook/internal/types';\nimport type { AureliaRenderer } from './types';\nimport Aurelia, { Constructable, CustomElement } from 'aurelia';\n\ninterface AureliaStoryResult {\n template: string;\n components?: unknown[];\n Component?: unknown;\n container?: any;\n items?: unknown[];\n innerHtml?: string;\n props?: Record<string, any>;\n}\n\n// Track Aurelia apps for cleanup\nconst appMap = new Map<HTMLElement, any>();\n\nasync function teardown(element: HTMLElement) {\n if (appMap.has(element)) {\n const app = appMap.get(element);\n if (app) {\n await app.stop();\n appMap.delete(element);\n }\n }\n}\n\nexport const render: ArgsStoryFn<AureliaRenderer> = (args, context) => {\n const { id, component: Component } = context;\n \n if (!Component) {\n throw new Error(\n `Unable to render story ${id} as the component annotation is missing from the default export`\n );\n }\n return { Component, props: args, template: '' };\n};\n\nexport async function renderToCanvas(\n {\n storyFn,\n title,\n name,\n showMain,\n showError,\n storyContext,\n forceRemount,\n }: RenderContext<AureliaRenderer>,\n canvasElement: HTMLElement,\n bootstrapAppFn?: typeof createAureliaApp\n) {\n // Store reference to the original storybook root element\n const rootElement = canvasElement;\n\n // Ensure we have (or create) a single container inside the root where the Aurelia app actually renders\n let hostElement: HTMLElement;\n if (rootElement.id === 'storybook-root') {\n hostElement = rootElement.querySelector('.aurelia-story-container') as HTMLElement;\n if (!hostElement) {\n hostElement = document.createElement('div');\n hostElement.className = 'aurelia-story-container';\n hostElement.style.height = '100%';\n rootElement.appendChild(hostElement);\n }\n } else {\n hostElement = rootElement;\n }\n\n // All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe\n const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;\n const { parameters, component, args } = storyContext;\n \n let app = appMap.get(rootElement);\n const story = storyFn() as AureliaStoryResult;\n \n // Temporary debug logging\n console.log(`[DEBUG] Story: ${name}, forceRemount: ${forceRemount}, hasExistingApp: ${!!app}, canvasId: ${canvasElement.className}`);\n\n if (!story) {\n showError({\n title: `Expecting an Aurelia component from the story: \"${name}\" of \"${title}\".`,\n description: `\n Did you forget to return the Aurelia component from the story?\n Use \"() => ({ template: '<custom-component></custom-component>' })\" when defining the story.\n `,\n });\n return () => {};\n }\n\n showMain();\n\n if (!app || forceRemount) {\n if (forceRemount && app) {\n await teardown(rootElement);\n app = undefined;\n }\n // Clear container before mounting new app\n hostElement.innerHTML = '';\n\n const mergedProps = { ...parameters?.args, ...args, ...story.props };\n\n const aureliaApp = appBootstrapFn(\n story,\n mergedProps,\n hostElement,\n component as Constructable\n );\n await aureliaApp.start();\n appMap.set(rootElement, aureliaApp);\n app = aureliaApp;\n } else {\n // update existing app props\n const mergedProps = { ...parameters?.args, ...args, ...story.props };\n if (app?.root?.controller?.viewModel) {\n Object.assign(app.root.controller.viewModel, mergedProps);\n }\n }\n\n // Return cleanup fn\n return async () => {\n await teardown(rootElement);\n };\n}\n\nexport function createAureliaApp(\n story: AureliaStoryResult,\n args: Record<string, any>,\n domElement: HTMLElement,\n component?: Constructable\n) {\n const aurelia = new Aurelia(story.container);\n\n if (story.items?.length) {\n aurelia.register(...story.items);\n }\n\n if (story.components?.length) {\n aurelia.register(...story.components);\n }\n\n let { template } = story;\n\n if (component) {\n template = template ?? createComponentTemplate(component, story.innerHtml);\n aurelia.register(component);\n }\n\n const App = CustomElement.define(\n {\n name: 'sb-app',\n template,\n containerless: true,\n },\n class {}\n );\n\n const app = Object.assign(new App(), args);\n\n return aurelia.app({\n host: domElement,\n component: app,\n });\n}\n\nexport function createComponentTemplate(\n component: Constructable,\n innerHtml?: string\n): string {\n const def = CustomElement.getDefinition(component);\n\n return `<${def.name} ${Object.values(def.bindables)\n .map((bindable) => `${bindable.attribute}.bind=\"${bindable.name}\"`)\n .join(' ')}>${innerHtml ?? ''}</${def.name}>`;\n}"],"names":[],"mappings":";;AAeA;AACA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB;AAE1C,eAAe,QAAQ,CAAC,OAAoB,EAAA;AAC1C,IAAA,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QACvB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,GAAG,EAAE;AACP,YAAA,MAAM,GAAG,CAAC,IAAI,EAAE;AAChB,YAAA,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QACxB;IACF;AACF;MAEa,MAAM,GAAiC,CAAC,IAAI,EAAE,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AG,CAAC,CAAC,QAAQ,KAAK,CAAA,EAAG,QAAQ,CAAC,SAAS,CAAA,OAAA,EAAU,QAAQ,CAAC,IAAI,GAAG;AACjE,SAAA,IAAI,CAAC,GAAG,CAAC,CAAA,CAAA,EAAI,SAAS,IAAI,EAAE,CAAA,EAAA,EAAK,GAAG,CAAC,IAAI,CAAA,CAAA,CAAG;AACjD;;;;"}
1
+ {"version":3,"file":"render.js","sources":["../../src/preview/render.ts"],"sourcesContent":["import type { RenderContext, ArgsStoryFn } from './storybook-types';\nimport type {\n AureliaRenderer,\n AureliaStoryResult,\n AureliaParameters,\n AureliaStoryContext,\n} from './types';\nimport Aurelia, { Constructable, CustomElement } from 'aurelia';\n\ninterface MountedAureliaApp {\n id?: string;\n app: any;\n}\n\nconst appMap = new Map<HTMLElement, MountedAureliaApp>();\n\nfunction mergeStoryProps(\n parameters: { args?: Record<string, any> } | undefined,\n storyArgs: Record<string, any> | undefined,\n storyProps: Record<string, any> | undefined\n) {\n return { ...parameters?.args, ...storyArgs, ...storyProps };\n}\n\nfunction getAureliaParameters(\n storyContext?: AureliaStoryContext\n): AureliaParameters | undefined {\n const parameters = storyContext?.parameters?.aurelia;\n if (!parameters || typeof parameters !== 'object') {\n return undefined;\n }\n return parameters as AureliaParameters;\n}\n\nfunction normalizeRegistrations(\n parameters: AureliaParameters | undefined\n): unknown[] {\n if (!parameters) {\n return [];\n }\n\n const register = Array.isArray(parameters.register) ? parameters.register : [];\n const components = Array.isArray(parameters.components) ? parameters.components : [];\n const items = Array.isArray(parameters.items) ? parameters.items : [];\n\n return [...register, ...components, ...items].filter(Boolean);\n}\n\nasync function teardown(element: HTMLElement, expectedApp?: any) {\n const mounted = appMap.get(element);\n if (!mounted) {\n return;\n }\n\n if (expectedApp && mounted.app !== expectedApp) {\n return;\n }\n\n appMap.delete(element);\n\n if (typeof mounted.app?.stop === 'function') {\n await mounted.app.stop();\n }\n}\n\nexport const render: ArgsStoryFn<AureliaRenderer> = (args, context) => {\n const { id, component: Component } = context;\n \n if (!Component) {\n const label = context.title && context.name ? `${context.title} / ${context.name}` : id;\n throw new Error(\n `Unable to render story ${label} as the component annotation is missing from the default export`\n );\n }\n return { Component, props: args };\n};\n\nexport async function renderToCanvas(\n {\n storyFn,\n title,\n name,\n showMain,\n showError,\n storyContext,\n forceRemount,\n }: RenderContext<AureliaRenderer>,\n canvasElement: HTMLElement,\n bootstrapAppFn?: typeof createAureliaApp\n) {\n // Store reference to the original storybook root element\n const rootElement = canvasElement;\n\n // Ensure we have (or create) a single container inside the root where the Aurelia app actually renders\n let hostElement: HTMLElement;\n if (rootElement.id === 'storybook-root') {\n hostElement = rootElement.querySelector('.aurelia-story-container') as HTMLElement;\n if (!hostElement) {\n hostElement = document.createElement('div');\n hostElement.className = 'aurelia-story-container';\n hostElement.style.height = '100%';\n rootElement.appendChild(hostElement);\n }\n } else {\n hostElement = rootElement;\n }\n\n // All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe\n const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;\n const { parameters, component, args } = storyContext;\n const storyId = storyContext.id ?? `${title}--${name}`;\n \n const mounted = appMap.get(rootElement);\n let app = mounted?.app;\n const story = storyFn() as AureliaStoryResult;\n \n if (!story) {\n showError({\n title: `Expecting an Aurelia component from the story: \"${name}\" of \"${title}\".`,\n description: `\n Did you forget to return the Aurelia component from the story?\n Use \"() => ({ template: '<custom-component></custom-component>' })\" when defining the story.\n `,\n });\n return () => {};\n }\n\n if (!component && !story.template) {\n showError({\n title: `Expecting a template or component from the story: \"${name}\" of \"${title}\".`,\n description: `\n Provide a component on the default export or return \"{ template: '<custom-component></custom-component>' }\" from the story.\n `,\n });\n return () => {};\n }\n\n showMain();\n\n const shouldRemount = !app || forceRemount || mounted?.id !== storyId;\n\n if (shouldRemount) {\n if (forceRemount && app) {\n await teardown(rootElement, app);\n app = undefined;\n }\n if (mounted?.id !== storyId && app) {\n await teardown(rootElement, app);\n app = undefined;\n }\n\n // Clear container before mounting new app\n hostElement.innerHTML = '';\n\n const mergedProps = mergeStoryProps(parameters, args, story.props);\n\n const aureliaApp = appBootstrapFn(\n story,\n mergedProps,\n hostElement,\n component as Constructable,\n storyContext\n );\n await aureliaApp.start();\n appMap.set(rootElement, { id: storyId, app: aureliaApp });\n app = aureliaApp;\n } else {\n // update existing app props\n const mergedProps = mergeStoryProps(parameters, args, story.props);\n if (app?.root?.controller?.viewModel) {\n Object.assign(app.root.controller.viewModel, mergedProps);\n }\n }\n\n // Return cleanup fn\n const appForCleanup = app;\n return async () => {\n await teardown(rootElement, appForCleanup);\n };\n}\n\nexport function createAureliaApp(\n story: AureliaStoryResult,\n args: Record<string, any>,\n domElement: HTMLElement,\n component?: Constructable,\n storyContext?: AureliaStoryContext\n) {\n const aurelia = new Aurelia(story.container);\n const { container } = aurelia;\n const aureliaParameters = getAureliaParameters(storyContext);\n\n const registerIfNeeded = (resource: unknown) => {\n if (!resource) {\n return;\n }\n\n if (CustomElement.isType(resource)) {\n const definition = CustomElement.getDefinition(resource);\n if (container.has(definition.key, false)) {\n return;\n }\n }\n\n aurelia.register(resource);\n };\n\n const registerAll = (resources?: unknown[]) => {\n if (!resources?.length) {\n return;\n }\n\n for (const resource of resources) {\n registerIfNeeded(resource);\n }\n };\n\n if (aureliaParameters?.configureContainer && storyContext) {\n aureliaParameters.configureContainer(container, storyContext);\n }\n\n registerAll(normalizeRegistrations(aureliaParameters));\n registerAll(story.items);\n\n const storyComponents = (story.components ?? []).filter(Boolean);\n const dedupedComponents = component\n ? storyComponents.filter((entry) => entry !== component)\n : storyComponents;\n\n for (const entry of dedupedComponents) {\n registerIfNeeded(entry);\n }\n\n let { template } = story;\n\n if (component) {\n template = template ?? createComponentTemplate(component, story.innerHtml);\n registerIfNeeded(component);\n }\n\n const App = CustomElement.define(\n {\n name: 'sb-app',\n template,\n containerless: true,\n },\n class {}\n );\n\n const app = Object.assign(new App(), args);\n\n if (aureliaParameters?.configure && storyContext) {\n aureliaParameters.configure(aurelia, storyContext);\n }\n\n return aurelia.app({\n host: domElement,\n component: app,\n });\n}\n\nexport function createComponentTemplate(\n component: Constructable,\n innerHtml?: string\n): string {\n const def = CustomElement.getDefinition(component);\n\n const bindings = Object.values(def.bindables ?? {})\n .map((bindable) => `${bindable.attribute}.bind=\"${bindable.name}\"`)\n .join(' ');\n const bindingAttributes = bindings ? ` ${bindings}` : '';\n\n return `<${def.name}${bindingAttributes}>${innerHtml ?? ''}</${def.name}>`;\n}\n"],"names":[],"mappings":";;AAcA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkC;AAExD,SAAS,eAAe,CACtB,UAAsD,EACtD,SAA0C,EAC1C,UAA2C,EAAA;AAE3C,IAAA,OAAO,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,GAAG,UAAU,EAAE;AAC7D;AAEA,SAAS,oBAAoB,CAC3B,YAAkC,EAAA;AAElC,IAAA,MAAM,UAAU,GAAG,YAAY,EAAE,UAAU,EAAE,OAAO;IACpD,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;AACjD,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,OAAO,UAA+B;AACxC;AAEA,SAAS,sBAAsB,CAC7B,UAAyC,EAAA;IAEzC,IAAI,CAAC,UAAU,EAAE;AACf,QAAA,OAAO,EAAE;IACX;IAEA,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,GAAG,EAAE;IAC9E,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,UAAU,GAAG,EAAE;IACpF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,GAAG,EAAE;AAErE,IAAA,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,UAAU,EAAE,GAA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GAAG,EAAE;AAExD,IAAA,OAAO,CAAA,CAAA,EAAI,GAAG,CAAC,IAAI,GAAG,iBAAiB,CAAA,CAAA,EAAI,SAAS,IAAI,EAAE,CAAA,EAAA,EAAK,GAAG,CAAC,IAAI,GAAG;AAC5E;;;;"}
@@ -0,0 +1 @@
1
+ export declare const __AURELIA_STORYBOOK_STORYBOOK_TYPES__ = true;
@@ -0,0 +1,5 @@
1
+ // Runtime stub so the export map has a JS target for type-only entries.
2
+ const __AURELIA_STORYBOOK_STORYBOOK_TYPES__ = true;
3
+
4
+ export { __AURELIA_STORYBOOK_STORYBOOK_TYPES__ };
5
+ //# sourceMappingURL=storybook-types-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook-types-runtime.js","sources":["../../src/preview/storybook-types-runtime.ts"],"sourcesContent":["// Runtime stub so the export map has a JS target for type-only entries.\nexport const __AURELIA_STORYBOOK_STORYBOOK_TYPES__ = true;\n"],"names":[],"mappings":"AAAA;AACO,MAAM,qCAAqC,GAAG;;;;"}
@@ -0,0 +1,27 @@
1
+ export interface Renderer {
2
+ component?: unknown;
3
+ storyResult?: unknown;
4
+ canvasElement?: HTMLElement;
5
+ }
6
+ export interface StoryContext<TRenderer = Renderer, TArgs = Record<string, unknown>> {
7
+ id?: string;
8
+ component?: unknown;
9
+ args: TArgs;
10
+ parameters?: {
11
+ args?: Record<string, unknown>;
12
+ } & Record<string, unknown>;
13
+ [key: string]: unknown;
14
+ }
15
+ export type ArgsStoryFn<TRenderer = Renderer, TArgs = Record<string, unknown>> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => unknown;
16
+ export interface RenderContext<TRenderer = Renderer, TArgs = Record<string, unknown>> {
17
+ storyFn: () => unknown;
18
+ title: string;
19
+ name: string;
20
+ showMain: () => void;
21
+ showError: (error: {
22
+ title: string;
23
+ description?: string;
24
+ }) => void;
25
+ storyContext: StoryContext<TRenderer, TArgs>;
26
+ forceRemount?: boolean;
27
+ }
@@ -0,0 +1 @@
1
+ export declare const __AURELIA_STORYBOOK_TYPES__ = true;
@@ -0,0 +1,5 @@
1
+ // Runtime stub so the export map has a JS target for type-only entries.
2
+ const __AURELIA_STORYBOOK_TYPES__ = true;
3
+
4
+ export { __AURELIA_STORYBOOK_TYPES__ };
5
+ //# sourceMappingURL=types-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-runtime.js","sources":["../../src/preview/types-runtime.ts"],"sourcesContent":["// Runtime stub so the export map has a JS target for type-only entries.\nexport const __AURELIA_STORYBOOK_TYPES__ = true;\n"],"names":[],"mappings":"AAAA;AACO,MAAM,2BAA2B,GAAG;;;;"}
@@ -0,0 +1,44 @@
1
+ import type { IContainer } from 'aurelia';
2
+ import type Aurelia from 'aurelia';
3
+ import type { Renderer, StoryContext, RenderContext, ArgsStoryFn } from './storybook-types';
4
+ export interface AureliaRenderer extends Renderer {
5
+ /** The DOM element in which the story is rendered */
6
+ canvasElement: HTMLElement;
7
+ }
8
+ export interface AureliaStoryResult<TArgs = Record<string, unknown>> {
9
+ template?: string;
10
+ components?: unknown[];
11
+ Component?: unknown;
12
+ container?: IContainer;
13
+ items?: unknown[];
14
+ innerHtml?: string;
15
+ props?: Partial<TArgs>;
16
+ }
17
+ export type AureliaStoryContext<TArgs = Record<string, unknown>> = StoryContext<AureliaRenderer, TArgs>;
18
+ export type AureliaRenderContext<TArgs = Record<string, unknown>> = RenderContext<AureliaRenderer, TArgs>;
19
+ export type AureliaArgsStoryFn<TArgs = Record<string, unknown>> = ArgsStoryFn<AureliaRenderer, TArgs>;
20
+ export interface AureliaParameters<TArgs = Record<string, unknown>> {
21
+ /**
22
+ * Global resources/plugins to register with Aurelia (merged across preview + story parameters).
23
+ */
24
+ register?: unknown[];
25
+ /**
26
+ * Alias for register: match the story result `components` contract.
27
+ */
28
+ components?: unknown[];
29
+ /**
30
+ * Alias for register: match the story result `items` contract.
31
+ */
32
+ items?: unknown[];
33
+ /**
34
+ * Configure the container before the Aurelia app starts.
35
+ */
36
+ configureContainer?: (container: IContainer, context: AureliaStoryContext<TArgs>) => void;
37
+ /**
38
+ * Configure the Aurelia instance before the app starts.
39
+ */
40
+ configure?: (aurelia: Aurelia, context: AureliaStoryContext<TArgs>) => void;
41
+ }
42
+ export interface AureliaStoryParameters<TArgs = Record<string, unknown>> {
43
+ aurelia?: AureliaParameters<TArgs>;
44
+ }
@@ -0,0 +1,3 @@
1
+ export { renderToCanvas, render } from './preview/render';
2
+ export { defineAureliaStory } from './preview/helpers';
3
+ export type { AureliaArgsStoryFn, AureliaParameters, AureliaRenderContext, AureliaRenderer, AureliaStoryParameters, AureliaStoryContext, AureliaStoryResult } from './preview/types';