@aurelia/storybook 2.2.1 → 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.
- package/CHANGELOG.md +7 -1
- package/README.md +18 -14
- package/dist/index.js +34 -14
- package/dist/index.js.map +1 -1
- package/dist/preset.js +30 -20
- package/dist/preset.js.map +1 -1
- package/dist/preview/render.d.ts +1 -1
- package/dist/preview/render.js +34 -14
- package/dist/preview/render.js.map +1 -1
- package/dist/preview.js +34 -14
- package/dist/preview.js.map +1 -1
- package/package.json +30 -15
- package/preset.js +2 -1
- package/.github/workflows/ci.yml +0 -61
- package/.github/workflows/publish.yml +0 -82
- package/.github/workflows/storybook-preview.yml +0 -62
- package/__tests__/create-aurelia-app.test.ts +0 -94
- package/__tests__/preset.test.ts +0 -78
- package/__tests__/preview.test.ts +0 -17
- package/__tests__/render.test.ts +0 -176
- package/__tests__/webpack.test.ts +0 -21
- package/apps/hello-world/.storybook/main.ts +0 -49
- package/apps/hello-world/.storybook/preview.ts +0 -1
- package/apps/hello-world/.stylelintrc.json +0 -5
- package/apps/hello-world/README.md +0 -28
- package/apps/hello-world/eslint.config.mjs +0 -25
- package/apps/hello-world/favicon.ico +0 -0
- package/apps/hello-world/index.html +0 -17
- package/apps/hello-world/package-lock.json +0 -9424
- package/apps/hello-world/package.json +0 -55
- package/apps/hello-world/src/components/feedback-form.html +0 -111
- package/apps/hello-world/src/components/feedback-form.ts +0 -45
- package/apps/hello-world/src/components/notification-center.html +0 -119
- package/apps/hello-world/src/components/notification-center.ts +0 -27
- package/apps/hello-world/src/components/stat-card.html +0 -107
- package/apps/hello-world/src/components/stat-card.ts +0 -41
- package/apps/hello-world/src/components/weather-widget.html +0 -89
- package/apps/hello-world/src/components/weather-widget.ts +0 -31
- package/apps/hello-world/src/hello-world.html +0 -48
- package/apps/hello-world/src/hello-world.ts +0 -17
- package/apps/hello-world/src/main.ts +0 -6
- package/apps/hello-world/src/my-app.html +0 -1
- package/apps/hello-world/src/my-app.ts +0 -3
- package/apps/hello-world/src/resource.d.ts +0 -15
- package/apps/hello-world/src/services/weather-service.ts +0 -15
- package/apps/hello-world/src/stories/feedback-form.stories.ts +0 -58
- package/apps/hello-world/src/stories/hello-world.stories.ts +0 -64
- package/apps/hello-world/src/stories/notification-center.stories.ts +0 -88
- package/apps/hello-world/src/stories/stat-card.stories.ts +0 -75
- package/apps/hello-world/src/stories/weather-widget.stories.ts +0 -62
- package/apps/hello-world/test/my-app.spec.ts +0 -15
- package/apps/hello-world/test/setup.ts +0 -29
- package/apps/hello-world/tsconfig.json +0 -19
- package/apps/hello-world/tsconfig.vitest.json +0 -11
- package/apps/hello-world/vite.config.ts +0 -17
- package/apps/hello-world/vitest.config.ts +0 -15
- package/apps/hello-world-rsbuild/.storybook/main.ts +0 -16
- package/apps/hello-world-rsbuild/.storybook/preview.ts +0 -1
- package/apps/hello-world-rsbuild/.stylelintrc.json +0 -5
- package/apps/hello-world-rsbuild/README.md +0 -28
- package/apps/hello-world-rsbuild/eslint.config.mjs +0 -25
- package/apps/hello-world-rsbuild/favicon.ico +0 -0
- package/apps/hello-world-rsbuild/index.html +0 -17
- package/apps/hello-world-rsbuild/package-lock.json +0 -11131
- package/apps/hello-world-rsbuild/package.json +0 -56
- package/apps/hello-world-rsbuild/src/components/feedback-form.html +0 -111
- package/apps/hello-world-rsbuild/src/components/feedback-form.ts +0 -45
- package/apps/hello-world-rsbuild/src/components/notification-center.html +0 -119
- package/apps/hello-world-rsbuild/src/components/notification-center.ts +0 -27
- package/apps/hello-world-rsbuild/src/components/stat-card.html +0 -107
- package/apps/hello-world-rsbuild/src/components/stat-card.ts +0 -41
- package/apps/hello-world-rsbuild/src/components/weather-widget.html +0 -89
- package/apps/hello-world-rsbuild/src/components/weather-widget.ts +0 -31
- package/apps/hello-world-rsbuild/src/hello-world.html +0 -48
- package/apps/hello-world-rsbuild/src/hello-world.ts +0 -17
- package/apps/hello-world-rsbuild/src/main.ts +0 -6
- package/apps/hello-world-rsbuild/src/my-app.html +0 -1
- package/apps/hello-world-rsbuild/src/my-app.ts +0 -3
- package/apps/hello-world-rsbuild/src/resource.d.ts +0 -15
- package/apps/hello-world-rsbuild/src/services/weather-service.ts +0 -15
- package/apps/hello-world-rsbuild/src/stories/feedback-form.stories.ts +0 -58
- package/apps/hello-world-rsbuild/src/stories/hello-world.stories.ts +0 -64
- package/apps/hello-world-rsbuild/src/stories/notification-center.stories.ts +0 -88
- package/apps/hello-world-rsbuild/src/stories/stat-card.stories.ts +0 -75
- package/apps/hello-world-rsbuild/src/stories/weather-widget.stories.ts +0 -62
- package/apps/hello-world-rsbuild/test/my-app.spec.ts +0 -15
- package/apps/hello-world-rsbuild/test/setup.ts +0 -29
- package/apps/hello-world-rsbuild/tsconfig.json +0 -19
- package/apps/hello-world-rsbuild/tsconfig.vitest.json +0 -11
- package/apps/hello-world-rsbuild/vite.config.ts +0 -17
- package/apps/hello-world-rsbuild/vitest.config.ts +0 -15
- package/apps/hello-world-webpack/.env.development +0 -0
- package/apps/hello-world-webpack/.storybook/main.ts +0 -14
- package/apps/hello-world-webpack/.storybook/preview.ts +0 -3
- package/apps/hello-world-webpack/.stylelintrc.json +0 -5
- package/apps/hello-world-webpack/README.md +0 -29
- package/apps/hello-world-webpack/eslint.config.mjs +0 -25
- package/apps/hello-world-webpack/favicon.ico +0 -0
- package/apps/hello-world-webpack/index.html +0 -15
- package/apps/hello-world-webpack/package-lock.json +0 -9828
- package/apps/hello-world-webpack/package.json +0 -52
- package/apps/hello-world-webpack/src/components/feedback-form.html +0 -111
- package/apps/hello-world-webpack/src/components/feedback-form.ts +0 -45
- package/apps/hello-world-webpack/src/components/notification-center.html +0 -119
- package/apps/hello-world-webpack/src/components/notification-center.ts +0 -27
- package/apps/hello-world-webpack/src/components/stat-card.html +0 -107
- package/apps/hello-world-webpack/src/components/stat-card.ts +0 -41
- package/apps/hello-world-webpack/src/components/weather-widget.html +0 -89
- package/apps/hello-world-webpack/src/components/weather-widget.ts +0 -31
- package/apps/hello-world-webpack/src/hello-world.html +0 -48
- package/apps/hello-world-webpack/src/hello-world.ts +0 -17
- package/apps/hello-world-webpack/src/main.ts +0 -6
- package/apps/hello-world-webpack/src/my-app.css +0 -3
- package/apps/hello-world-webpack/src/my-app.html +0 -1
- package/apps/hello-world-webpack/src/my-app.stories.ts +0 -17
- package/apps/hello-world-webpack/src/my-app.ts +0 -3
- package/apps/hello-world-webpack/src/resource.d.ts +0 -13
- package/apps/hello-world-webpack/src/services/weather-service.ts +0 -15
- package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +0 -58
- package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +0 -64
- package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +0 -88
- package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +0 -75
- package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +0 -62
- package/apps/hello-world-webpack/tsconfig.json +0 -18
- package/apps/hello-world-webpack/webpack.config.js +0 -111
- package/jest.config.cjs +0 -9
- package/rollup.config.mjs +0 -52
- package/scripts/sync-versions.cjs +0 -55
- package/src/index.ts +0 -42
- package/src/preset.ts +0 -79
- package/src/preview/helpers.ts +0 -7
- package/src/preview/render.ts +0 -243
- package/src/preview/storybook-types-runtime.ts +0 -2
- package/src/preview/storybook-types.ts +0 -34
- package/src/preview/types-runtime.ts +0 -2
- package/src/preview/types.ts +0 -62
- package/src/preview.ts +0 -11
- package/src/webpack.ts +0 -40
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
## [2.3.0](https://github.com/aurelia/storybook/compare/v2.2.1...v2.3.0) (2026-06-02)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **package:** update storybook and deps ([a79e567](https://github.com/aurelia/storybook/commit/a79e5674fe13b8ebe0eb6542d03f4b6742196ff9))
|
|
6
|
+
|
|
1
7
|
## [2.2.1](https://github.com/aurelia/storybook/compare/2.1.0...2.2.1) (2026-01-23)
|
|
2
8
|
|
|
3
9
|
### Features
|
|
4
10
|
|
|
5
|
-
* **storybook:** update packages, tooling, rsbuild support ([3a97a99](https://github.com/aurelia/storybook/commit/3a97a9950693183b5880756a943e620895f9457b))
|
|
11
|
+
* **storybook:** update packages, tooling, rsbuild support ([3a97a99](https://github.com/aurelia/storybook/commit/3a97a9950693183b5880756a943e620895f9457b))
|
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# @aurelia/storybook
|
|
2
2
|
|
|
3
|
-
> **Note:** Storybook support is still
|
|
3
|
+
> **Note:** Storybook support is still release-candidate stage. Please report anything that feels off while Aurelia 2 and Storybook 10 continue to settle.
|
|
4
4
|
|
|
5
|
-
`@aurelia/storybook` is the glue between Aurelia 2 components and Storybook 10. It wires Aurelia
|
|
5
|
+
`@aurelia/storybook` is the glue between Aurelia 2 components and Storybook 10. It wires an Aurelia app into Storybook's rendering pipeline so you can preview, test, and document your components with Vite, Webpack, or Rsbuild/Rspack.
|
|
6
6
|
|
|
7
7
|
## Compatibility at a Glance
|
|
8
8
|
|
|
9
9
|
| Item | Supported versions | Notes |
|
|
10
10
|
| --- | --- | --- |
|
|
11
|
-
| Storybook | 10.x (ESM) | Tested with 10.
|
|
12
|
-
| Aurelia | 2.0.0-
|
|
13
|
-
| Bundlers | `@storybook/builder-vite` (Vite 5) · `@storybook/builder-webpack5` · `storybook-builder-rsbuild` (Rsbuild/Rspack) | Pick whichever matches your app; they share the same Aurelia preview runtime. |
|
|
11
|
+
| Storybook | 10.x (ESM) | Tested with 10.4.x; works with `storybook dev`/`storybook build` commands. |
|
|
12
|
+
| Aurelia | 2.0.0-rc.1+ | Uses Aurelia's app APIs under the hood. |
|
|
13
|
+
| Bundlers | `@storybook/builder-vite` (Vite 5-8) · `@storybook/builder-webpack5` · `storybook-builder-rsbuild` (Rsbuild/Rspack) | Pick whichever matches your app; they share the same Aurelia preview runtime. |
|
|
14
14
|
| Node.js | ≥ 20.19.0 or ≥ 22.12.0 | Matches the engines field in `package.json` and Storybook 10's baseline.
|
|
15
15
|
|
|
16
16
|
## Requirements
|
|
17
17
|
|
|
18
|
-
- An Aurelia 2 application (TypeScript or JavaScript) already set up with
|
|
18
|
+
- An Aurelia 2 application (TypeScript or JavaScript) already set up with Vite, Webpack, or Rsbuild/Rspack.
|
|
19
19
|
- Storybook 10.x installed in the project. (Run `npx storybook@latest init` if you are starting fresh.)
|
|
20
|
-
- The peer dependencies listed in [`package.json`](package.json) that align with the Aurelia 2
|
|
20
|
+
- The peer dependencies listed in [`package.json`](package.json) that align with the Aurelia 2 release-candidate train you are targeting.
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
@@ -45,7 +45,7 @@ Add whichever addons you need (`@storybook/addon-links`, `@storybook/addon-actio
|
|
|
45
45
|
|
|
46
46
|
const config: StorybookConfig & { viteFinal?: (config: InlineConfig) => InlineConfig | Promise<InlineConfig> } = {
|
|
47
47
|
stories: ['../src/stories/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
48
|
-
addons: [
|
|
48
|
+
addons: [],
|
|
49
49
|
framework: {
|
|
50
50
|
name: '@aurelia/storybook',
|
|
51
51
|
options: {},
|
|
@@ -54,7 +54,7 @@ Add whichever addons you need (`@storybook/addon-links`, `@storybook/addon-actio
|
|
|
54
54
|
builder: '@storybook/builder-vite',
|
|
55
55
|
},
|
|
56
56
|
viteFinal: async (viteConfig) => {
|
|
57
|
-
//
|
|
57
|
+
// Optional: extend this when your app needs extra Vite config.
|
|
58
58
|
viteConfig.optimizeDeps = viteConfig.optimizeDeps ?? {};
|
|
59
59
|
viteConfig.optimizeDeps.exclude = Array.from(new Set([...(viteConfig.optimizeDeps.exclude ?? []), '@aurelia/runtime-html']));
|
|
60
60
|
|
|
@@ -69,8 +69,7 @@ Add whichever addons you need (`@storybook/addon-links`, `@storybook/addon-actio
|
|
|
69
69
|
export default config;
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
- The `define` shim avoids `process is not defined` errors when Storybook code (or Aurelia plugins) look for `process.env.NODE_ENV` in the preview iframe.
|
|
72
|
+
The Aurelia preset already excludes `@aurelia/runtime-html` from pre-bundling and defines `process.env.NODE_ENV`; keep a `viteFinal` hook only when your app needs to merge additional Vite settings.
|
|
74
73
|
|
|
75
74
|
3. **Create `.storybook/preview.ts`:**
|
|
76
75
|
|
|
@@ -102,7 +101,7 @@ Add whichever addons you need (`@storybook/addon-links`, `@storybook/addon-actio
|
|
|
102
101
|
|
|
103
102
|
const config: StorybookConfig = {
|
|
104
103
|
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
105
|
-
addons: [
|
|
104
|
+
addons: [],
|
|
106
105
|
framework: {
|
|
107
106
|
name: '@aurelia/storybook',
|
|
108
107
|
options: {},
|
|
@@ -131,7 +130,7 @@ Add whichever addons you need (`@storybook/addon-links`, `@storybook/addon-actio
|
|
|
131
130
|
|
|
132
131
|
const config: StorybookConfig = {
|
|
133
132
|
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
134
|
-
addons: [
|
|
133
|
+
addons: [],
|
|
135
134
|
framework: {
|
|
136
135
|
name: '@aurelia/storybook',
|
|
137
136
|
options: {},
|
|
@@ -144,7 +143,7 @@ Add whichever addons you need (`@storybook/addon-links`, `@storybook/addon-actio
|
|
|
144
143
|
export default config;
|
|
145
144
|
```
|
|
146
145
|
|
|
147
|
-
The Aurelia preset injects
|
|
146
|
+
The Aurelia preset injects `@aurelia/webpack-loader` via `rsbuildFinal`,
|
|
148
147
|
so most projects do not need extra Rsbuild configuration. If you do, add your own `rsbuildFinal`
|
|
149
148
|
and merge with `@rsbuild/core`'s `mergeRsbuildConfig`.
|
|
150
149
|
|
|
@@ -384,6 +383,7 @@ export const CleanState = {
|
|
|
384
383
|
|
|
385
384
|
- `apps/hello-world` – Vite-based Aurelia starter that consumes `@aurelia/storybook`.
|
|
386
385
|
- `apps/hello-world-webpack` – Equivalent Webpack example.
|
|
386
|
+
- `apps/hello-world-rsbuild` – Rsbuild/Rspack example for projects using `storybook-builder-rsbuild`.
|
|
387
387
|
|
|
388
388
|
To try them out:
|
|
389
389
|
|
|
@@ -395,6 +395,10 @@ npm run storybook
|
|
|
395
395
|
cd ../hello-world-webpack
|
|
396
396
|
npm install
|
|
397
397
|
npm run storybook
|
|
398
|
+
|
|
399
|
+
cd ../hello-world-rsbuild
|
|
400
|
+
npm install
|
|
401
|
+
npm run storybook
|
|
398
402
|
```
|
|
399
403
|
|
|
400
404
|
Each sample project now includes a small library of showcase stories you can open in Storybook to see different aspects of the integration:
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Aurelia, { CustomElement } from 'aurelia';
|
|
2
2
|
|
|
3
|
-
// Track Aurelia apps for cleanup
|
|
4
3
|
const appMap = new Map();
|
|
5
4
|
function mergeStoryProps(parameters, storyArgs, storyProps) {
|
|
6
5
|
return { ...parameters?.args, ...storyArgs, ...storyProps };
|
|
@@ -21,13 +20,17 @@ function normalizeRegistrations(parameters) {
|
|
|
21
20
|
const items = Array.isArray(parameters.items) ? parameters.items : [];
|
|
22
21
|
return [...register, ...components, ...items].filter(Boolean);
|
|
23
22
|
}
|
|
24
|
-
async function teardown(element) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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();
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
async function renderToCanvas({ storyFn, title, name, showMain, showError, storyContext, forceRemount, }, canvasElement, bootstrapAppFn) {
|
|
@@ -50,7 +53,9 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
50
53
|
// All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe
|
|
51
54
|
const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;
|
|
52
55
|
const { parameters, component, args } = storyContext;
|
|
53
|
-
|
|
56
|
+
const storyId = storyContext.id ?? `${title}--${name}`;
|
|
57
|
+
const mounted = appMap.get(rootElement);
|
|
58
|
+
let app = mounted?.app;
|
|
54
59
|
const story = storyFn();
|
|
55
60
|
if (!story) {
|
|
56
61
|
showError({
|
|
@@ -62,10 +67,24 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
62
67
|
});
|
|
63
68
|
return () => { };
|
|
64
69
|
}
|
|
70
|
+
if (!component && !story.template) {
|
|
71
|
+
showError({
|
|
72
|
+
title: `Expecting a template or component from the story: "${name}" of "${title}".`,
|
|
73
|
+
description: `
|
|
74
|
+
Provide a component on the default export or return "{ template: '<custom-component></custom-component>' }" from the story.
|
|
75
|
+
`,
|
|
76
|
+
});
|
|
77
|
+
return () => { };
|
|
78
|
+
}
|
|
65
79
|
showMain();
|
|
66
|
-
|
|
80
|
+
const shouldRemount = !app || forceRemount || mounted?.id !== storyId;
|
|
81
|
+
if (shouldRemount) {
|
|
67
82
|
if (forceRemount && app) {
|
|
68
|
-
await teardown(rootElement);
|
|
83
|
+
await teardown(rootElement, app);
|
|
84
|
+
app = undefined;
|
|
85
|
+
}
|
|
86
|
+
if (mounted?.id !== storyId && app) {
|
|
87
|
+
await teardown(rootElement, app);
|
|
69
88
|
app = undefined;
|
|
70
89
|
}
|
|
71
90
|
// Clear container before mounting new app
|
|
@@ -73,7 +92,7 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
73
92
|
const mergedProps = mergeStoryProps(parameters, args, story.props);
|
|
74
93
|
const aureliaApp = appBootstrapFn(story, mergedProps, hostElement, component, storyContext);
|
|
75
94
|
await aureliaApp.start();
|
|
76
|
-
appMap.set(rootElement, aureliaApp);
|
|
95
|
+
appMap.set(rootElement, { id: storyId, app: aureliaApp });
|
|
77
96
|
app = aureliaApp;
|
|
78
97
|
}
|
|
79
98
|
else {
|
|
@@ -84,8 +103,9 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
// Return cleanup fn
|
|
106
|
+
const appForCleanup = app;
|
|
87
107
|
return async () => {
|
|
88
|
-
await teardown(rootElement);
|
|
108
|
+
await teardown(rootElement, appForCleanup);
|
|
89
109
|
};
|
|
90
110
|
}
|
|
91
111
|
function createAureliaApp(story, args, domElement, component, storyContext) {
|
|
@@ -146,7 +166,7 @@ function createAureliaApp(story, args, domElement, component, storyContext) {
|
|
|
146
166
|
}
|
|
147
167
|
function createComponentTemplate(component, innerHtml) {
|
|
148
168
|
const def = CustomElement.getDefinition(component);
|
|
149
|
-
const bindings = Object.values(def.bindables)
|
|
169
|
+
const bindings = Object.values(def.bindables ?? {})
|
|
150
170
|
.map((bindable) => `${bindable.attribute}.bind="${bindable.name}"`)
|
|
151
171
|
.join(' ');
|
|
152
172
|
const bindingAttributes = bindings ? ` ${bindings}` : '';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/preview/render.ts","../src/preview/helpers.ts","../src/index.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\n// Track Aurelia apps for cleanup\nconst appMap = new Map<HTMLElement, any>();\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) {\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 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 \n let app = appMap.get(rootElement);\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 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 = 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, 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 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 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","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","import { renderToCanvas } from './preview/render';\nimport { defineAureliaStory } from './preview/helpers';\n\nexport { renderToCanvas };\nexport const render = renderToCanvas;\nexport { defineAureliaStory };\nexport type {\n AureliaRenderer,\n AureliaStoryResult,\n AureliaArgsStoryFn,\n AureliaRenderContext,\n AureliaStoryContext,\n AureliaParameters,\n AureliaStoryParameters\n} from './preview/types';\n\n// Define the framework\nexport const framework = {\n name: '@aurelia/storybook',\n options: {}\n};\n\n// Framework configuration for Storybook\nexport const frameworkOptions = {\n builder: {\n name: '@storybook/builder-vite',\n options: {}\n }\n};\n\n// Export a complete framework configuration\nexport const aureliaFramework = {\n name: '@aurelia/storybook',\n options: {},\n builder: '@storybook/builder-vite'\n};\n\n// Provide external dependencies configuration\nexport const externals = {\n 'react': 'React',\n 'react-dom': 'ReactDOM'\n};\n"],"names":[],"mappings":";;AASA;AACA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB;AAE1C,SAAS,eAAe,CACtB,UAAsD,EACtD,SAA0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AAM,gBAAgB,GAAG;AAC9B,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,OAAO,EAAE,EAAE;AACX,IAAA,OAAO,EAAE;;AAGX;AACO,MAAM,SAAS,GAAG;AACvB,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,WAAW,EAAE;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/preview/render.ts","../src/preview/helpers.ts","../src/index.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","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","import { renderToCanvas } from './preview/render';\nimport { defineAureliaStory } from './preview/helpers';\n\nexport { renderToCanvas };\nexport const render = renderToCanvas;\nexport { defineAureliaStory };\nexport type {\n AureliaRenderer,\n AureliaStoryResult,\n AureliaArgsStoryFn,\n AureliaRenderContext,\n AureliaStoryContext,\n AureliaParameters,\n AureliaStoryParameters\n} from './preview/types';\n\n// Define the framework\nexport const framework = {\n name: '@aurelia/storybook',\n options: {}\n};\n\n// Framework configuration for Storybook\nexport const frameworkOptions = {\n builder: {\n name: '@storybook/builder-vite',\n options: {}\n }\n};\n\n// Export a complete framework configuration\nexport const aureliaFramework = {\n name: '@aurelia/storybook',\n options: {},\n builder: '@storybook/builder-vite'\n};\n\n// Provide external dependencies configuration\nexport const externals = {\n 'react': 'React',\n 'react-dom': 'ReactDOM'\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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,SAAS,CAAA,OAAA,EAAU,QAAQ,CAAC,IAAI,GAAG;SACjE,IAAI,CAAC,GAAG,CAAC;AACZ,IAAA,MAAM,iBAAiB,GAAG,QAAQ,GAAG,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAE,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;;AC/QM,SAAU,kBAAkB,CAChC,KAAgC,EAAA;AAEhC,IAAA,OAAO,KAAK;AACd;;ACFO,MAAM,MAAM,GAAG;AAYtB;AACO,MAAM,SAAS,GAAG;AACvB,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,OAAO,EAAE;;AAGX;AACO,MAAM,gBAAgB,GAAG;AAC9B,IAAA,OAAO,EAAE;AACP,QAAA,IAAI,EAAE,yBAAyB;AAC/B,QAAA,OAAO,EAAE;AACV;;AAGH;AACO,MAAM,gBAAgB,GAAG;AAC9B,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,OAAO,EAAE,EAAE;AACX,IAAA,OAAO,EAAE;;AAGX;AACO,MAAM,SAAS,GAAG;AACvB,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,WAAW,EAAE;;;;;"}
|
package/dist/preset.js
CHANGED
|
@@ -37,25 +37,36 @@ function getRsbuildRules() {
|
|
|
37
37
|
|
|
38
38
|
// src/preset.ts
|
|
39
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
|
+
}
|
|
40
58
|
/**
|
|
41
59
|
* Optionally adjust the Vite configuration.
|
|
42
60
|
*/
|
|
43
61
|
async function viteFinal(config) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
config.optimizeDeps =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
'@aurelia/runtime-html'
|
|
53
|
-
];
|
|
54
|
-
excludeList.forEach(dep => {
|
|
55
|
-
if (!config.optimizeDeps.exclude.includes(dep)) {
|
|
56
|
-
config.optimizeDeps.exclude.push(dep);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
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
|
+
};
|
|
59
70
|
return config;
|
|
60
71
|
}
|
|
61
72
|
async function loadMergeRsbuildConfig() {
|
|
@@ -78,7 +89,7 @@ async function rsbuildFinal(config) {
|
|
|
78
89
|
rspack: (rspackConfig) => {
|
|
79
90
|
const moduleConfig = rspackConfig.module ?? (rspackConfig.module = {});
|
|
80
91
|
const rules = moduleConfig.rules ?? (moduleConfig.rules = []);
|
|
81
|
-
rules
|
|
92
|
+
appendUniqueRules(rules, getRsbuildRules());
|
|
82
93
|
return rspackConfig;
|
|
83
94
|
}
|
|
84
95
|
}
|
|
@@ -90,10 +101,9 @@ async function rsbuildFinal(config) {
|
|
|
90
101
|
* @returns
|
|
91
102
|
*/
|
|
92
103
|
async function webpackFinal(config) {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
104
|
+
const moduleConfig = config.module ?? (config.module = {});
|
|
105
|
+
const rules = moduleConfig.rules ?? (moduleConfig.rules = []);
|
|
106
|
+
appendUniqueRules(rules, getRules());
|
|
97
107
|
return config;
|
|
98
108
|
}
|
|
99
109
|
// Export a default for compatibility.
|
package/dist/preset.js.map
CHANGED
|
@@ -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\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\n/**\n * Optionally adjust the Vite configuration.\n */\nexport async function viteFinal(config: any): Promise<any> {\n
|
|
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,QAAQ;AACd,YAAA,OAAO,EAAE,KAAK;YACd,GAAG,EAAE,CAAC,yBAAyB,CAAC;AAChC,YAAA,OAAO,EAAE,cAAc;AACxB,SAAA;AACD,QAAA;AACE,YAAA,IAAI,EAAE,UAAU;AAChB,YAAA,GAAG,EAAE,yBAAyB;AAC9B,YAAA,OAAO,EAAE,c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M,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;;;;"}
|
package/dist/preview/render.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import type { AureliaRenderer, AureliaStoryResult, AureliaStoryContext } from '.
|
|
|
3
3
|
import Aurelia, { Constructable } from 'aurelia';
|
|
4
4
|
export declare const render: ArgsStoryFn<AureliaRenderer>;
|
|
5
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, "
|
|
6
|
+
export declare function createAureliaApp(story: AureliaStoryResult, args: Record<string, any>, domElement: HTMLElement, component?: Constructable, storyContext?: AureliaStoryContext): Omit<Aurelia, "app" | "enhance" | "register">;
|
|
7
7
|
export declare function createComponentTemplate(component: Constructable, innerHtml?: string): string;
|
package/dist/preview/render.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Aurelia, { CustomElement } from 'aurelia';
|
|
2
2
|
|
|
3
|
-
// Track Aurelia apps for cleanup
|
|
4
3
|
const appMap = new Map();
|
|
5
4
|
function mergeStoryProps(parameters, storyArgs, storyProps) {
|
|
6
5
|
return { ...parameters?.args, ...storyArgs, ...storyProps };
|
|
@@ -21,13 +20,17 @@ function normalizeRegistrations(parameters) {
|
|
|
21
20
|
const items = Array.isArray(parameters.items) ? parameters.items : [];
|
|
22
21
|
return [...register, ...components, ...items].filter(Boolean);
|
|
23
22
|
}
|
|
24
|
-
async function teardown(element) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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();
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
const render = (args, context) => {
|
|
@@ -58,7 +61,9 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
58
61
|
// All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe
|
|
59
62
|
const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;
|
|
60
63
|
const { parameters, component, args } = storyContext;
|
|
61
|
-
|
|
64
|
+
const storyId = storyContext.id ?? `${title}--${name}`;
|
|
65
|
+
const mounted = appMap.get(rootElement);
|
|
66
|
+
let app = mounted?.app;
|
|
62
67
|
const story = storyFn();
|
|
63
68
|
if (!story) {
|
|
64
69
|
showError({
|
|
@@ -70,10 +75,24 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
70
75
|
});
|
|
71
76
|
return () => { };
|
|
72
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
|
+
}
|
|
73
87
|
showMain();
|
|
74
|
-
|
|
88
|
+
const shouldRemount = !app || forceRemount || mounted?.id !== storyId;
|
|
89
|
+
if (shouldRemount) {
|
|
75
90
|
if (forceRemount && app) {
|
|
76
|
-
await teardown(rootElement);
|
|
91
|
+
await teardown(rootElement, app);
|
|
92
|
+
app = undefined;
|
|
93
|
+
}
|
|
94
|
+
if (mounted?.id !== storyId && app) {
|
|
95
|
+
await teardown(rootElement, app);
|
|
77
96
|
app = undefined;
|
|
78
97
|
}
|
|
79
98
|
// Clear container before mounting new app
|
|
@@ -81,7 +100,7 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
81
100
|
const mergedProps = mergeStoryProps(parameters, args, story.props);
|
|
82
101
|
const aureliaApp = appBootstrapFn(story, mergedProps, hostElement, component, storyContext);
|
|
83
102
|
await aureliaApp.start();
|
|
84
|
-
appMap.set(rootElement, aureliaApp);
|
|
103
|
+
appMap.set(rootElement, { id: storyId, app: aureliaApp });
|
|
85
104
|
app = aureliaApp;
|
|
86
105
|
}
|
|
87
106
|
else {
|
|
@@ -92,8 +111,9 @@ async function renderToCanvas({ storyFn, title, name, showMain, showError, story
|
|
|
92
111
|
}
|
|
93
112
|
}
|
|
94
113
|
// Return cleanup fn
|
|
114
|
+
const appForCleanup = app;
|
|
95
115
|
return async () => {
|
|
96
|
-
await teardown(rootElement);
|
|
116
|
+
await teardown(rootElement, appForCleanup);
|
|
97
117
|
};
|
|
98
118
|
}
|
|
99
119
|
function createAureliaApp(story, args, domElement, component, storyContext) {
|
|
@@ -154,7 +174,7 @@ function createAureliaApp(story, args, domElement, component, storyContext) {
|
|
|
154
174
|
}
|
|
155
175
|
function createComponentTemplate(component, innerHtml) {
|
|
156
176
|
const def = CustomElement.getDefinition(component);
|
|
157
|
-
const bindings = Object.values(def.bindables)
|
|
177
|
+
const bindings = Object.values(def.bindables ?? {})
|
|
158
178
|
.map((bindable) => `${bindable.attribute}.bind="${bindable.name}"`)
|
|
159
179
|
.join(' ');
|
|
160
180
|
const bindingAttributes = bindings ? ` ${bindings}` : '';
|
|
@@ -1 +1 @@
|
|
|
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\n// Track Aurelia apps for cleanup\nconst appMap = new Map<HTMLElement, any>();\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) {\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 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 \n let app = appMap.get(rootElement);\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 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 = 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, 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 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 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":";;AASA;AACA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB;AAE1C,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,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],"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}>`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