@codegrowers/storybook-jaspr-vite 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +51 -2
- package/STORYBOOK.md +188 -0
- package/dist/dart-highlighting.d.ts +1 -0
- package/dist/dart-highlighting.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/preset.d.ts +5 -0
- package/dist/preset.js +33 -0
- package/dist/preview.d.ts +18 -0
- package/dist/preview.js +125 -0
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.js +47 -0
- package/dist/renderer-preset.d.ts +2 -0
- package/dist/renderer-preset.js +2 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +28 -0
- package/dist/sources.d.ts +3 -0
- package/dist/sources.js +54 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.js +1 -0
- package/dist/vite-plugin.d.ts +4 -0
- package/dist/vite-plugin.js +150 -0
- package/package.json +76 -4
- package/preset.js +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
- Initial MIT-licensed release of the Jaspr Storybook integration.
|
|
6
|
+
- Render Jaspr components with controls, globals, actions and argument updates.
|
|
7
|
+
- Preserve component state on argument updates and isolate concurrent Docs previews.
|
|
8
|
+
- Dispose component trees on teardown and surface render errors in Storybook.
|
|
9
|
+
- Compile Dart through Vite for development and static Storybook builds.
|
|
10
|
+
- Display actual Dart source regions in Docs with Dart syntax highlighting.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Electree contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @codegrowers/storybook-jaspr-vite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A native Storybook renderer and Vite framework for Jaspr components written in
|
|
4
|
+
Dart. Mount real Jaspr components in Canvas and Docs, edit arguments with
|
|
5
|
+
Controls, record Actions and run TypeScript play functions against the DOM.
|
|
6
|
+
|
|
7
|
+
MIT licensed. Requires the companion
|
|
8
|
+
[`jaspr_storybook`](https://pub.dev/packages/jaspr_storybook) Dart runtime.
|
|
9
|
+
Both packages are released at `1.0.0`.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
bun add --dev @codegrowers/storybook-jaspr-vite@^1.0.0 storybook@10.6.5 vite@8.3.5 @storybook/addon-docs@10.6.5
|
|
13
|
+
dart pub add --dev jaspr_storybook:^1.0.0
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Register builders with `registerStorybook` in a Dart client entrypoint, configure
|
|
17
|
+
the framework in `.storybook/main.ts`, and write normal CSF stories with the
|
|
18
|
+
registered component key. The framework compiles Dart through Vite for both the
|
|
19
|
+
development server and static Storybook output.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import type { StorybookConfig } from '@codegrowers/storybook-jaspr-vite';
|
|
23
|
+
import { createRequire } from 'node:module';
|
|
24
|
+
import { dirname } from 'node:path';
|
|
25
|
+
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
framework: {
|
|
30
|
+
name: dirname(require.resolve('@codegrowers/storybook-jaspr-vite/package.json')),
|
|
31
|
+
options: { entrypoint: '../lib/storybook.client.dart' },
|
|
32
|
+
},
|
|
33
|
+
stories: ['../stories/**/*.stories.ts'],
|
|
34
|
+
} satisfies StorybookConfig;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Docs can show actual Dart builders selected with `#docregion` markers, with Dart
|
|
38
|
+
syntax highlighting. See [STORYBOOK.md](STORYBOOK.md) for Dart registration, CSF, controls, actions,
|
|
39
|
+
watch options, styling, examples and release instructions.
|
|
40
|
+
|
|
41
|
+
Tested with Jaspr 0.23.3 and 0.23.5, Storybook 10.6.5, Vite 8.3.5,
|
|
42
|
+
Bun 1.4.2 and Dart 3.13.5. The Dart SDK must be on `PATH`, or set
|
|
43
|
+
`framework.options.dartExecutable`. Node execution has not been verified.
|
|
44
|
+
|
|
45
|
+
Styles and assets belong to the consumer. Argument values must be compatible
|
|
46
|
+
with JSON. This version previews client-side Jaspr components; it does not
|
|
47
|
+
provide SSR/hydration testing, Wasm output, Dart constructor introspection or
|
|
48
|
+
automatic Dart story discovery.
|
|
49
|
+
|
|
50
|
+
To develop: run `bun install`, `bun run build`, `bun run format:check`,
|
|
51
|
+
`bun run lint`, `bun run typecheck` and `bun test`. Run `dart pub get` in
|
|
52
|
+
`example/`, then `bun run build:example` and `bun run preview` from the root.
|
package/STORYBOOK.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Storybook for Jaspr
|
|
2
|
+
|
|
3
|
+
Two MIT-licensed packages provide the integration, both at version `1.0.0`:
|
|
4
|
+
|
|
5
|
+
| Registry | Package | Source |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| pub.dev | [`jaspr_storybook`](https://pub.dev/packages/jaspr_storybook) | [Dart runtime](https://github.com/Code-Growers/jaspr_storybook) |
|
|
8
|
+
| npm | [`@codegrowers/storybook-jaspr-vite`](https://www.npmjs.com/package/@codegrowers/storybook-jaspr-vite) | [Storybook framework](https://github.com/Code-Growers/storybook-jaspr-vite) |
|
|
9
|
+
|
|
10
|
+
## Consumer setup
|
|
11
|
+
|
|
12
|
+
Add `jaspr_storybook` to your Dart application's development
|
|
13
|
+
dependencies and the matching npm framework plus Storybook/Vite to its JavaScript
|
|
14
|
+
development dependencies. For example, using Bun:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
dart pub add --dev jaspr_storybook:^1.0.0
|
|
18
|
+
bun add --dev @codegrowers/storybook-jaspr-vite@^1.0.0 storybook@10.6.5 vite@8.3.5 @storybook/addon-docs@10.6.5
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The current tested targets are Jaspr 0.23.3 and 0.23.5, Storybook 10.6.5, Vite
|
|
22
|
+
8.3.5, Bun 1.4.2 and Dart 3.13.5. The Jaspr constraint allows 0.23.x, but other patch versions
|
|
23
|
+
still need compatibility verification before extending the advertised matrix.
|
|
24
|
+
Node support has not been verified; the development and release scripts use Bun.
|
|
25
|
+
|
|
26
|
+
Register components in a Dart client entrypoint as shown in README.md. Configure
|
|
27
|
+
`.storybook/main.ts`:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import type { StorybookConfig } from '@codegrowers/storybook-jaspr-vite';
|
|
31
|
+
import { createRequire } from 'node:module';
|
|
32
|
+
import { dirname } from 'node:path';
|
|
33
|
+
|
|
34
|
+
const require = createRequire(import.meta.url);
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
framework: {
|
|
38
|
+
name: dirname(require.resolve('@codegrowers/storybook-jaspr-vite/package.json')),
|
|
39
|
+
options: {
|
|
40
|
+
entrypoint: '../lib/storybook.client.dart',
|
|
41
|
+
// Optional directories outside the entrypoint directory:
|
|
42
|
+
// watchPaths: ['../../shared_widgets/lib'],
|
|
43
|
+
// dartExecutable: '/path/to/dart',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
stories: ['../stories/**/*.stories.ts'],
|
|
47
|
+
addons: [dirname(require.resolve('@storybook/addon-docs/package.json'))],
|
|
48
|
+
} satisfies StorybookConfig;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Write normal CSF stories, using the Dart registry key as `component`:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import type { Meta, StoryObj } from '@codegrowers/storybook-jaspr-vite';
|
|
55
|
+
|
|
56
|
+
type Args = { label: string; disabled: boolean };
|
|
57
|
+
export default {
|
|
58
|
+
title: 'Components/Button',
|
|
59
|
+
component: 'button',
|
|
60
|
+
tags: ['autodocs'],
|
|
61
|
+
args: { label: 'Save', disabled: false },
|
|
62
|
+
argTypes: {
|
|
63
|
+
label: { control: 'text' },
|
|
64
|
+
disabled: { control: 'boolean' },
|
|
65
|
+
},
|
|
66
|
+
} satisfies Meta<Args>;
|
|
67
|
+
|
|
68
|
+
export const Default: StoryObj<Args> = {};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Run `dart pub get`, then `bun --bun storybook dev` or `bun --bun storybook build`.
|
|
72
|
+
The preset invokes the configured Dart SDK to compile the entrypoint. It serves
|
|
73
|
+
the result during development and emits it as a local asset in static builds.
|
|
74
|
+
No remote Dart or Jaspr server is required to view a built Storybook.
|
|
75
|
+
|
|
76
|
+
## Features and boundaries
|
|
77
|
+
|
|
78
|
+
- The renderer mounts actual Jaspr component trees directly into the Canvas.
|
|
79
|
+
It does not depend on the HTML renderer or embed a second iframe.
|
|
80
|
+
- Controls and globals update the root while retaining descendant state. Dart
|
|
81
|
+
can update controlled arguments through `story.updateArgs`.
|
|
82
|
+
- Actions cross the Dart/JavaScript boundary through a named event channel.
|
|
83
|
+
- Optional `undefined` object properties are omitted; array entries become
|
|
84
|
+
`null`, following JSON conventions. Functions and opaque objects are rejected.
|
|
85
|
+
- Inline Docs can mount multiple independent previews. Use `story.instanceId`
|
|
86
|
+
when assigning DOM ids.
|
|
87
|
+
- Story teardown disposes the Jaspr tree and removes the renderer-owned DOM.
|
|
88
|
+
Builder errors reject rendering so Storybook can show its error UI.
|
|
89
|
+
- Play functions run after the Dart mount/update promise completes. They are
|
|
90
|
+
authored in TypeScript against the preview's regular DOM.
|
|
91
|
+
- Changes to Dart files under the entrypoint directory or `watchPaths` trigger
|
|
92
|
+
recompilation and a full preview reload. Dart state resets on source changes;
|
|
93
|
+
this is not Jaspr hot reload. Compilation failures show the Vite error overlay.
|
|
94
|
+
- Styling remains in the application. Import CSS in `.storybook/preview.ts`
|
|
95
|
+
and serve fonts/images with Storybook `staticDirs`. Jaspr-generated CSS or
|
|
96
|
+
code generation must be prepared with the application's normal tooling.
|
|
97
|
+
- Dart constructor introspection, automatic Dart story discovery, server-only
|
|
98
|
+
components, SSR/hydration verification and Wasm output are outside this version.
|
|
99
|
+
Controls metadata is explicit. JSON-compatible arguments are required. To show
|
|
100
|
+
Dart source in Docs, supply `parameters.docs.source.code` and `language: 'dart'`.
|
|
101
|
+
|
|
102
|
+
## Dart source in Docs
|
|
103
|
+
|
|
104
|
+
The renderer shows real Dart source regions in Docs and the optional Code panel,
|
|
105
|
+
with Dart syntax highlighting. In the Dart entrypoint or files listed in
|
|
106
|
+
`framework.options.sourceFiles`, surround a builder or component expression with
|
|
107
|
+
markers matching its registered component key:
|
|
108
|
+
|
|
109
|
+
```dart
|
|
110
|
+
// #docregion button
|
|
111
|
+
Component buttonStory(StorybookContext story) => button(
|
|
112
|
+
disabled: story.arg<bool>('disabled'),
|
|
113
|
+
onClick: () => story.action('onClick'),
|
|
114
|
+
[.text(story.arg<String>('label'))],
|
|
115
|
+
);
|
|
116
|
+
// #enddocregion button
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
options: {
|
|
121
|
+
entrypoint: '../lib/storybook.client.dart',
|
|
122
|
+
sourceFiles: ['../lib/component_stories.dart'],
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Paths are relative to the Storybook configuration directory. The entrypoint is
|
|
127
|
+
always scanned. Source files are watched automatically. Each region has one
|
|
128
|
+
unique name; nested, duplicate, empty or unclosed regions fail the build.
|
|
129
|
+
Only marked code is embedded in the static build. Snippets show the Dart builder
|
|
130
|
+
as written, including `story.arg` calls; changing controls does not rewrite Dart
|
|
131
|
+
source. The TypeScript `play` function continues to run independently.
|
|
132
|
+
|
|
133
|
+
For a hand-written example or a story-specific variant, use standard Storybook
|
|
134
|
+
`parameters.docs.source.code` with `language: 'dart'`. `docs.source.transform`
|
|
135
|
+
is also supported by the Docs source block. Without a matching region or an
|
|
136
|
+
explicit source override, the code panel indicates that Dart source is unconfigured.
|
|
137
|
+
|
|
138
|
+
## Examples and development
|
|
139
|
+
|
|
140
|
+
Each repository includes a small `example/` with a button, a controlled switch
|
|
141
|
+
and stateful counters. No backend or application-specific assets are needed.
|
|
142
|
+
The example configuration lives in `example/storybook/` so pub.dev includes it;
|
|
143
|
+
consumer applications can use the conventional `.storybook/` directory.
|
|
144
|
+
|
|
145
|
+
In the Dart runtime repository:
|
|
146
|
+
|
|
147
|
+
```sh
|
|
148
|
+
dart pub get
|
|
149
|
+
dart format .
|
|
150
|
+
dart analyze
|
|
151
|
+
dart test
|
|
152
|
+
cd example
|
|
153
|
+
dart pub get
|
|
154
|
+
bun install
|
|
155
|
+
bun run dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
In the npm framework repository:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
bun install
|
|
162
|
+
bun run build
|
|
163
|
+
bun run format:check
|
|
164
|
+
bun run lint
|
|
165
|
+
bun run typecheck
|
|
166
|
+
bun test
|
|
167
|
+
cd example
|
|
168
|
+
dart pub get
|
|
169
|
+
cd ..
|
|
170
|
+
bun run build:example
|
|
171
|
+
bun run preview
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The Dart example uses the local runtime and the published npm framework. The
|
|
175
|
+
npm example uses the local framework and the published Dart runtime. Changes
|
|
176
|
+
to the shared browser protocol must be verified across both repositories.
|
|
177
|
+
|
|
178
|
+
## Release
|
|
179
|
+
|
|
180
|
+
Keep the paired package versions compatible. Run the checks above, review
|
|
181
|
+
`dart pub publish --dry-run` in the Dart repository and `bun pm pack --dry-run`
|
|
182
|
+
in the npm repository, and verify the examples in a browser.
|
|
183
|
+
|
|
184
|
+
Publish the Dart runtime with `dart pub publish`, and the public scoped npm
|
|
185
|
+
framework with `bun publish --access public`. The npm publish lifecycle builds
|
|
186
|
+
the distribution and runs its checks. Registry credentials belong in the local
|
|
187
|
+
authentication environment and must never be committed. Tag releases in both
|
|
188
|
+
source repositories after successful publication.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { FrameworkOptions, JasprRenderer, JasprStory, Meta, StorybookConfig, StoryObj, } from "./types.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/preset.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PresetProperty } from "storybook/internal/types";
|
|
2
|
+
import type { ViteFinal } from "@storybook/builder-vite";
|
|
3
|
+
export declare const core: PresetProperty<"core">;
|
|
4
|
+
export declare const managerEntries: (entries?: string[]) => string[];
|
|
5
|
+
export declare const viteFinal: ViteFinal;
|
package/dist/preset.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { mergeConfig, searchForWorkspaceRoot } from "vite";
|
|
4
|
+
import { dartPreviewPlugin } from "./vite-plugin.js";
|
|
5
|
+
export const core = {
|
|
6
|
+
builder: import.meta.resolve("@storybook/builder-vite"),
|
|
7
|
+
renderer: import.meta.resolve("./renderer-preset.js"),
|
|
8
|
+
};
|
|
9
|
+
export const managerEntries = (entries = []) => [
|
|
10
|
+
...entries,
|
|
11
|
+
fileURLToPath(import.meta.resolve("./dart-highlighting.js")),
|
|
12
|
+
];
|
|
13
|
+
export const viteFinal = async (config, options) => {
|
|
14
|
+
const framework = await options.presets.apply("framework");
|
|
15
|
+
if (!framework.options?.entrypoint) {
|
|
16
|
+
throw new Error("Jaspr Storybook requires framework.options.entrypoint relative to the config directory.");
|
|
17
|
+
}
|
|
18
|
+
return mergeConfig(config, {
|
|
19
|
+
plugins: [dartPreviewPlugin(framework.options, options.configDir)],
|
|
20
|
+
server: {
|
|
21
|
+
fs: {
|
|
22
|
+
// Bun may install Storybook outside a nested consumer workspace. Its
|
|
23
|
+
// injected mock bootstrap still needs to pass Vite's strict file checks.
|
|
24
|
+
allow: [
|
|
25
|
+
...(config.server?.fs?.allow ?? [
|
|
26
|
+
searchForWorkspaceRoot(config.root ?? process.cwd()),
|
|
27
|
+
]),
|
|
28
|
+
dirname(fileURLToPath(import.meta.resolve("storybook/package.json"))),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ArgsStoryFn, RenderContext } from "storybook/internal/types";
|
|
2
|
+
import "./dart-highlighting.js";
|
|
3
|
+
import type { JasprRenderer } from "./types.js";
|
|
4
|
+
export declare const parameters: {
|
|
5
|
+
renderer: string;
|
|
6
|
+
docs: {
|
|
7
|
+
story: {
|
|
8
|
+
inline: boolean;
|
|
9
|
+
};
|
|
10
|
+
source: {
|
|
11
|
+
language: string;
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare const argTypesEnhancers: (<TRenderer extends import("storybook/internal/types").Renderer>(context: import("storybook/internal/types").StoryContextForEnhancers<TRenderer>) => import("storybook/internal/types").Parameters)[];
|
|
17
|
+
export declare const render: ArgsStoryFn<JasprRenderer>;
|
|
18
|
+
export declare function renderToCanvas(context: RenderContext<JasprRenderer>, canvas: HTMLElement): Promise<() => void>;
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { action } from "storybook/actions";
|
|
2
|
+
import { UPDATE_STORY_ARGS } from "storybook/internal/core-events";
|
|
3
|
+
import { enhanceArgTypes, SNIPPET_RENDERED, } from "storybook/internal/docs-tools";
|
|
4
|
+
import { addons } from "storybook/preview-api";
|
|
5
|
+
import { bundleUrl, dartSources } from "virtual:jaspr-storybook-runtime";
|
|
6
|
+
import "./dart-highlighting.js";
|
|
7
|
+
import { checkRecord } from "./protocol.js";
|
|
8
|
+
import { loadRuntime } from "./runtime.js";
|
|
9
|
+
export const parameters = {
|
|
10
|
+
renderer: "jaspr",
|
|
11
|
+
docs: {
|
|
12
|
+
story: { inline: true },
|
|
13
|
+
source: { language: "dart", type: "dynamic" },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export const argTypesEnhancers = [enhanceArgTypes];
|
|
17
|
+
export const render = (args, context) => ({
|
|
18
|
+
component: context.component ?? "",
|
|
19
|
+
args,
|
|
20
|
+
});
|
|
21
|
+
const sessions = new WeakMap();
|
|
22
|
+
let nextInstance = 0;
|
|
23
|
+
export async function renderToCanvas(context, canvas) {
|
|
24
|
+
const story = context.storyFn();
|
|
25
|
+
if (!story ||
|
|
26
|
+
typeof story.component !== "string" ||
|
|
27
|
+
!story.component.trim()) {
|
|
28
|
+
throw new Error("Set component to a registered Jaspr builder key in your story metadata.");
|
|
29
|
+
}
|
|
30
|
+
const args = checkRecord(story.args, "args");
|
|
31
|
+
const globals = checkRecord(context.storyContext.globals, "globals");
|
|
32
|
+
const runtime = await loadRuntime(bundleUrl);
|
|
33
|
+
const emitSource = () => {
|
|
34
|
+
addons.getChannel().emit(SNIPPET_RENDERED, {
|
|
35
|
+
id: context.storyContext.id,
|
|
36
|
+
args: context.storyContext.unmappedArgs ?? context.storyContext.args,
|
|
37
|
+
source: dartSources[story.component] ??
|
|
38
|
+
"// No Dart source region is configured for this component.",
|
|
39
|
+
format: false,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const previous = sessions.get(canvas);
|
|
43
|
+
if (previous &&
|
|
44
|
+
!previous.disposed &&
|
|
45
|
+
previous.component === story.component &&
|
|
46
|
+
!context.forceRemount) {
|
|
47
|
+
previous.ready = previous.ready
|
|
48
|
+
.catch(() => { })
|
|
49
|
+
.then(() => {
|
|
50
|
+
if (!previous.disposed)
|
|
51
|
+
return runtime.update(previous.host.id, args, globals);
|
|
52
|
+
});
|
|
53
|
+
await previous.ready;
|
|
54
|
+
if (!previous.disposed)
|
|
55
|
+
emitSource();
|
|
56
|
+
context.showMain();
|
|
57
|
+
return previous.dispose;
|
|
58
|
+
}
|
|
59
|
+
previous?.dispose();
|
|
60
|
+
canvas.replaceChildren();
|
|
61
|
+
const host = document.createElement("div");
|
|
62
|
+
host.id = `jaspr-storybook-${++nextInstance}`;
|
|
63
|
+
canvas.appendChild(host);
|
|
64
|
+
const session = {
|
|
65
|
+
component: story.component,
|
|
66
|
+
runtime,
|
|
67
|
+
host,
|
|
68
|
+
disposed: false,
|
|
69
|
+
ready: Promise.resolve(),
|
|
70
|
+
dispose() {
|
|
71
|
+
if (session.disposed)
|
|
72
|
+
return;
|
|
73
|
+
session.disposed = true;
|
|
74
|
+
try {
|
|
75
|
+
runtime.unmount(host.id);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
// Jaspr disposal releases component state. The renderer owns DOM removal.
|
|
79
|
+
host.replaceChildren();
|
|
80
|
+
host.remove();
|
|
81
|
+
if (sessions.get(canvas) === session)
|
|
82
|
+
sessions.delete(canvas);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
sessions.set(canvas, session);
|
|
87
|
+
session.ready = runtime.mount(host.id, story.component, host.id, args, globals, (type, payload) => {
|
|
88
|
+
if (session.disposed)
|
|
89
|
+
return;
|
|
90
|
+
if (type === "error") {
|
|
91
|
+
const failure = checkRecord(payload, "error");
|
|
92
|
+
const error = new Error(String(failure.message));
|
|
93
|
+
if (typeof failure.stack === "string")
|
|
94
|
+
error.stack = failure.stack;
|
|
95
|
+
context.showException(error);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (type === "action") {
|
|
99
|
+
const event = checkRecord(payload, "action");
|
|
100
|
+
if (typeof event.name !== "string")
|
|
101
|
+
throw new Error("A Jaspr action must have a name.");
|
|
102
|
+
action(event.name)(event.value);
|
|
103
|
+
}
|
|
104
|
+
else if (type === "args") {
|
|
105
|
+
addons.getChannel().emit(UPDATE_STORY_ARGS, {
|
|
106
|
+
storyId: context.storyContext.id,
|
|
107
|
+
updatedArgs: checkRecord(payload, "updatedArgs"),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
await session.ready;
|
|
113
|
+
if (!session.disposed) {
|
|
114
|
+
emitSource();
|
|
115
|
+
context.showMain();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
session.dispose();
|
|
120
|
+
if (sessions.get(canvas) && sessions.get(canvas) !== session)
|
|
121
|
+
return () => { };
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
return session.dispose;
|
|
125
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface JasprRuntime {
|
|
2
|
+
protocolVersion: 1;
|
|
3
|
+
mount(instanceId: string, component: string, hostId: string, args: Record<string, unknown>, globals: Record<string, unknown>, emit: (type: string, payload: unknown) => void): Promise<unknown>;
|
|
4
|
+
update(instanceId: string, args: Record<string, unknown>, globals: Record<string, unknown>): Promise<unknown>;
|
|
5
|
+
unmount(instanceId: string): void;
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
__jasprStorybook?: JasprRuntime;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare function checkRuntime(value: unknown): JasprRuntime;
|
|
13
|
+
/** Normalize optional values and reject callbacks, cycles and opaque objects. */
|
|
14
|
+
export declare function checkRecord(value: unknown, label: string): Record<string, unknown>;
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function checkRuntime(value) {
|
|
2
|
+
if (typeof value !== "object" ||
|
|
3
|
+
value === null ||
|
|
4
|
+
!("protocolVersion" in value) ||
|
|
5
|
+
value.protocolVersion !== 1 ||
|
|
6
|
+
!("mount" in value) ||
|
|
7
|
+
typeof value.mount !== "function" ||
|
|
8
|
+
!("update" in value) ||
|
|
9
|
+
typeof value.update !== "function" ||
|
|
10
|
+
!("unmount" in value) ||
|
|
11
|
+
typeof value.unmount !== "function") {
|
|
12
|
+
throw new Error("Incompatible Jaspr Storybook runtime. Use matching Dart and npm package versions.");
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
/** Normalize optional values and reject callbacks, cycles and opaque objects. */
|
|
17
|
+
export function checkRecord(value, label) {
|
|
18
|
+
const ancestors = new Set();
|
|
19
|
+
const visit = (item, path) => {
|
|
20
|
+
if (item === null || typeof item === "string" || typeof item === "boolean")
|
|
21
|
+
return item;
|
|
22
|
+
if (typeof item === "number" && Number.isFinite(item))
|
|
23
|
+
return item;
|
|
24
|
+
if (typeof item !== "object" || item === null) {
|
|
25
|
+
throw new Error(`${path} must contain JSON-compatible values. Send callbacks through story.action().`);
|
|
26
|
+
}
|
|
27
|
+
if (ancestors.has(item))
|
|
28
|
+
throw new Error(`${path} contains a circular reference.`);
|
|
29
|
+
if (!Array.isArray(item) &&
|
|
30
|
+
Object.getPrototypeOf(item) !== Object.prototype &&
|
|
31
|
+
Object.getPrototypeOf(item) !== null) {
|
|
32
|
+
throw new Error(`${path} must contain plain objects and arrays.`);
|
|
33
|
+
}
|
|
34
|
+
ancestors.add(item);
|
|
35
|
+
const result = Array.isArray(item)
|
|
36
|
+
? Array.from(item, (child, index) => child === undefined ? null : visit(child, `${path}.${index}`))
|
|
37
|
+
: Object.fromEntries(Object.entries(item)
|
|
38
|
+
.filter(([, child]) => child !== undefined)
|
|
39
|
+
.map(([key, child]) => [key, visit(child, `${path}.${key}`)]));
|
|
40
|
+
ancestors.delete(item);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
44
|
+
throw new Error(`${label} must be an object.`);
|
|
45
|
+
}
|
|
46
|
+
return visit(value, label);
|
|
47
|
+
}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { checkRuntime } from "./protocol.js";
|
|
2
|
+
let loading;
|
|
3
|
+
export function loadRuntime(url) {
|
|
4
|
+
if (loading)
|
|
5
|
+
return loading;
|
|
6
|
+
loading = new Promise((resolve, reject) => {
|
|
7
|
+
const script = document.createElement("script");
|
|
8
|
+
script.src = url;
|
|
9
|
+
script.onload = () => {
|
|
10
|
+
try {
|
|
11
|
+
resolve(checkRuntime(window.__jasprStorybook));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
script.remove();
|
|
15
|
+
reject(error);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
script.onerror = () => {
|
|
19
|
+
script.remove();
|
|
20
|
+
reject(new Error(`Could not load the compiled Jaspr preview: ${url}`));
|
|
21
|
+
};
|
|
22
|
+
document.head.appendChild(script);
|
|
23
|
+
}).catch((error) => {
|
|
24
|
+
loading = undefined;
|
|
25
|
+
throw error;
|
|
26
|
+
});
|
|
27
|
+
return loading;
|
|
28
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Extract explicitly selected Dart code without trying to parse Dart as JavaScript. */
|
|
2
|
+
export declare function extractSourceRegions(source: string, filename?: string): Record<string, string>;
|
|
3
|
+
export declare function readSourceRegions(files: string[]): Promise<Record<string, string>>;
|
package/dist/sources.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
/** Extract explicitly selected Dart code without trying to parse Dart as JavaScript. */
|
|
3
|
+
export function extractSourceRegions(source, filename = "Dart source") {
|
|
4
|
+
const regions = Object.create(null);
|
|
5
|
+
let current;
|
|
6
|
+
for (const [index, line] of source.split(/\r?\n/).entries()) {
|
|
7
|
+
const marker = /^\s*\/\/\s*#(end)?docregion\s+([^\s,]+)\s*$/.exec(line);
|
|
8
|
+
if (!marker) {
|
|
9
|
+
current?.lines.push(line);
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const name = marker[2] ?? "";
|
|
13
|
+
const fail = (message) => {
|
|
14
|
+
throw new Error(`${filename}:${index + 1}: ${message}`);
|
|
15
|
+
};
|
|
16
|
+
if (!marker[1]) {
|
|
17
|
+
if (current)
|
|
18
|
+
fail("Dart source regions must not be nested.");
|
|
19
|
+
if (Object.hasOwn(regions, name))
|
|
20
|
+
fail(`Duplicate Dart source region: ${name}`);
|
|
21
|
+
current = { name, lines: [] };
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (!current || current.name !== name)
|
|
25
|
+
return fail(`Unmatched #enddocregion ${name}`);
|
|
26
|
+
const lines = current.lines;
|
|
27
|
+
const indentation = Math.min(...lines
|
|
28
|
+
.filter((value) => value.trim())
|
|
29
|
+
.map((value) => /^\s*/.exec(value)?.[0].length ?? 0));
|
|
30
|
+
const code = lines
|
|
31
|
+
.map((value) => value.slice(indentation))
|
|
32
|
+
.join("\n")
|
|
33
|
+
.trim();
|
|
34
|
+
if (!code)
|
|
35
|
+
fail(`Empty Dart source region: ${name}`);
|
|
36
|
+
regions[name] = code;
|
|
37
|
+
current = undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (current)
|
|
41
|
+
throw new Error(`${filename}: Unclosed #docregion ${current.name}`);
|
|
42
|
+
return regions;
|
|
43
|
+
}
|
|
44
|
+
export async function readSourceRegions(files) {
|
|
45
|
+
const sources = Object.create(null);
|
|
46
|
+
for (const file of new Set(files)) {
|
|
47
|
+
for (const [name, code] of Object.entries(extractSourceRegions(await readFile(file, "utf8"), file))) {
|
|
48
|
+
if (Object.hasOwn(sources, name))
|
|
49
|
+
throw new Error(`${file}: Duplicate Dart source region across files: ${name}`);
|
|
50
|
+
sources[name] = code;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return sources;
|
|
54
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Args, ComponentAnnotations, StoryAnnotations, WebRenderer, StorybookConfigRaw } from "storybook/internal/types";
|
|
2
|
+
import type { StorybookConfigVite } from "@storybook/builder-vite";
|
|
3
|
+
export interface JasprStory {
|
|
4
|
+
component: string;
|
|
5
|
+
args: Args;
|
|
6
|
+
}
|
|
7
|
+
export interface JasprRenderer extends WebRenderer {
|
|
8
|
+
component: string;
|
|
9
|
+
storyResult: JasprStory;
|
|
10
|
+
}
|
|
11
|
+
export type Meta<TArgs extends Args = Args> = ComponentAnnotations<JasprRenderer, TArgs>;
|
|
12
|
+
export type StoryObj<TArgs extends Args = Args> = StoryAnnotations<JasprRenderer, TArgs>;
|
|
13
|
+
export interface FrameworkOptions {
|
|
14
|
+
/** Dart client entrypoint, relative to the Storybook config directory. */
|
|
15
|
+
entrypoint: string;
|
|
16
|
+
/** SDK executable. Defaults to dart on PATH. */
|
|
17
|
+
dartExecutable?: string;
|
|
18
|
+
/** Additional Dart directories to watch, relative to the config directory. */
|
|
19
|
+
watchPaths?: string[];
|
|
20
|
+
/** Dart files with #docregion markers keyed by registered component name. */
|
|
21
|
+
sourceFiles?: string[];
|
|
22
|
+
}
|
|
23
|
+
export type StorybookConfig = Omit<StorybookConfigRaw, "framework"> & StorybookConfigVite & {
|
|
24
|
+
framework: {
|
|
25
|
+
name: string;
|
|
26
|
+
options: FrameworkOptions;
|
|
27
|
+
};
|
|
28
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { FrameworkOptions } from "./types.js";
|
|
3
|
+
export declare function compilePreview(entrypoint: string, dartExecutable: string, production: boolean): Promise<Buffer>;
|
|
4
|
+
export declare function dartPreviewPlugin(options: FrameworkOptions, configDir: string): Plugin;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { access, mkdtemp, readFile, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { readSourceRegions } from "./sources.js";
|
|
7
|
+
const exec = promisify(execFile);
|
|
8
|
+
const virtualId = "virtual:jaspr-storybook-runtime";
|
|
9
|
+
const resolvedId = `\0${virtualId}`;
|
|
10
|
+
const devUrl = "/@jaspr-storybook/preview.js";
|
|
11
|
+
async function packageConfig(entrypoint) {
|
|
12
|
+
let directory = dirname(entrypoint);
|
|
13
|
+
while (true) {
|
|
14
|
+
const candidate = join(directory, ".dart_tool", "package_config.json");
|
|
15
|
+
try {
|
|
16
|
+
await access(candidate);
|
|
17
|
+
return candidate;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
const parent = dirname(directory);
|
|
21
|
+
if (directory === parent)
|
|
22
|
+
throw new Error("Run dart pub get before starting Jaspr Storybook.");
|
|
23
|
+
directory = parent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function compilePreview(entrypoint, dartExecutable, production) {
|
|
28
|
+
const packages = await packageConfig(entrypoint);
|
|
29
|
+
const scratch = await mkdtemp(join(tmpdir(), "jaspr-storybook-"));
|
|
30
|
+
try {
|
|
31
|
+
const output = join(scratch, "preview.js");
|
|
32
|
+
await exec(dartExecutable, [
|
|
33
|
+
"compile",
|
|
34
|
+
"js",
|
|
35
|
+
"--no-source-maps",
|
|
36
|
+
`--packages=${packages}`,
|
|
37
|
+
production ? "-O2" : "-O1",
|
|
38
|
+
"-o",
|
|
39
|
+
output,
|
|
40
|
+
entrypoint,
|
|
41
|
+
], { cwd: dirname(entrypoint), maxBuffer: 8 * 1024 * 1024 });
|
|
42
|
+
return await readFile(output);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const output = error;
|
|
46
|
+
throw new Error(`Jaspr Storybook could not compile ${entrypoint}.\n${output.stdout ?? ""}${output.stderr ?? ""}${output.message ?? ""}`, { cause: error });
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
await rm(scratch, { recursive: true, force: true });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function dartPreviewPlugin(options, configDir) {
|
|
53
|
+
const entrypoint = resolve(configDir, options.entrypoint);
|
|
54
|
+
const sourceFiles = [
|
|
55
|
+
entrypoint,
|
|
56
|
+
...(options.sourceFiles ?? []).map((path) => resolve(configDir, path)),
|
|
57
|
+
];
|
|
58
|
+
const watchPaths = [
|
|
59
|
+
dirname(entrypoint),
|
|
60
|
+
...sourceFiles.map(dirname),
|
|
61
|
+
...(options.watchPaths ?? []).map((path) => resolve(configDir, path)),
|
|
62
|
+
];
|
|
63
|
+
let production = false;
|
|
64
|
+
let bundle;
|
|
65
|
+
let sources = {};
|
|
66
|
+
let queued = Promise.resolve();
|
|
67
|
+
let timer;
|
|
68
|
+
let server;
|
|
69
|
+
const recompile = () => {
|
|
70
|
+
queued = queued.then(async () => {
|
|
71
|
+
try {
|
|
72
|
+
const next = await compilePreview(entrypoint, options.dartExecutable ?? "dart", production);
|
|
73
|
+
const nextSources = await readSourceRegions(sourceFiles);
|
|
74
|
+
bundle = next;
|
|
75
|
+
sources = nextSources;
|
|
76
|
+
const module = server?.moduleGraph.getModuleById(resolvedId);
|
|
77
|
+
if (module)
|
|
78
|
+
server?.moduleGraph.invalidateModule(module);
|
|
79
|
+
server?.ws.send({ type: "full-reload" });
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
83
|
+
server?.config.logger.error(message);
|
|
84
|
+
server?.ws.send({ type: "error", err: { message, stack: "" } });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
name: "jaspr-storybook",
|
|
90
|
+
configResolved(config) {
|
|
91
|
+
production = config.command === "build";
|
|
92
|
+
},
|
|
93
|
+
async buildStart() {
|
|
94
|
+
sources = await readSourceRegions(sourceFiles);
|
|
95
|
+
bundle = await compilePreview(entrypoint, options.dartExecutable ?? "dart", production);
|
|
96
|
+
},
|
|
97
|
+
resolveId(id) {
|
|
98
|
+
if (id === virtualId)
|
|
99
|
+
return resolvedId;
|
|
100
|
+
},
|
|
101
|
+
load(id) {
|
|
102
|
+
if (id !== resolvedId)
|
|
103
|
+
return;
|
|
104
|
+
const sourceExport = `export const dartSources = ${JSON.stringify(sources)};`;
|
|
105
|
+
if (!production)
|
|
106
|
+
return `${sourceExport} export const bundleUrl = ${JSON.stringify(devUrl)};`;
|
|
107
|
+
const reference = this.emitFile({
|
|
108
|
+
type: "asset",
|
|
109
|
+
name: "jaspr-preview.js",
|
|
110
|
+
source: bundle,
|
|
111
|
+
});
|
|
112
|
+
return `${sourceExport} export const bundleUrl = import.meta.ROLLUP_FILE_URL_${reference};`;
|
|
113
|
+
},
|
|
114
|
+
configureServer(devServer) {
|
|
115
|
+
server = devServer;
|
|
116
|
+
server.middlewares.use(devUrl, (_request, response) => {
|
|
117
|
+
response.setHeader("Content-Type", "application/javascript; charset=utf-8");
|
|
118
|
+
response.setHeader("Cache-Control", "no-store");
|
|
119
|
+
response.end(bundle);
|
|
120
|
+
});
|
|
121
|
+
server.watcher.add(watchPaths);
|
|
122
|
+
const onChange = (path) => {
|
|
123
|
+
const absolute = resolve(path);
|
|
124
|
+
if (!absolute.endsWith(".dart") ||
|
|
125
|
+
!watchPaths.some((directory) => {
|
|
126
|
+
const pathFromDirectory = relative(directory, absolute);
|
|
127
|
+
return (pathFromDirectory !== ".." &&
|
|
128
|
+
!pathFromDirectory.startsWith(`..${sep}`) &&
|
|
129
|
+
!isAbsolute(pathFromDirectory));
|
|
130
|
+
}))
|
|
131
|
+
return;
|
|
132
|
+
if (timer)
|
|
133
|
+
clearTimeout(timer);
|
|
134
|
+
timer = setTimeout(recompile, 150);
|
|
135
|
+
};
|
|
136
|
+
server.watcher
|
|
137
|
+
.on("add", onChange)
|
|
138
|
+
.on("change", onChange)
|
|
139
|
+
.on("unlink", onChange);
|
|
140
|
+
server.httpServer?.once("close", () => {
|
|
141
|
+
if (timer)
|
|
142
|
+
clearTimeout(timer);
|
|
143
|
+
server?.watcher
|
|
144
|
+
.off("add", onChange)
|
|
145
|
+
.off("change", onChange)
|
|
146
|
+
.off("unlink", onChange);
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codegrowers/storybook-jaspr-vite",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A native Storybook renderer and Vite framework for Jaspr components written in Dart.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"storybook",
|
|
9
|
+
"jaspr",
|
|
10
|
+
"dart",
|
|
11
|
+
"vite",
|
|
12
|
+
"renderer"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./preset": "./dist/preset.js",
|
|
20
|
+
"./renderer-preset": "./dist/renderer-preset.js",
|
|
21
|
+
"./preview": "./dist/preview.js",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"preset.js",
|
|
27
|
+
"README.md",
|
|
28
|
+
"STORYBOOK.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "bun run build && bun run --bun storybook dev --config-dir example/storybook --port 6006 --no-open --disable-telemetry",
|
|
34
|
+
"build": "bun run --bun tsc -p tsconfig.build.json",
|
|
35
|
+
"build:example": "bun run build && bun run --bun storybook build --config-dir example/storybook --output-dir storybook-static --disable-telemetry",
|
|
36
|
+
"preview": "bun ./tool/serve-example.ts",
|
|
37
|
+
"format": "biome format --write src test tool example/storybook example/stories package.json tsconfig.json tsconfig.build.json biome.json preset.js",
|
|
38
|
+
"format:check": "biome format src test tool example/storybook example/stories package.json tsconfig.json tsconfig.build.json biome.json preset.js",
|
|
39
|
+
"lint": "biome lint src test tool example/storybook example/stories",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"test": "bun test",
|
|
42
|
+
"prepublishOnly": "bun run build && bun run format:check && bun run lint && bun run typecheck && bun test",
|
|
43
|
+
"prepack": "bun run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@storybook/builder-vite": "10.6.5",
|
|
47
|
+
"refractor": "^5.0.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"storybook": "^10.6.5",
|
|
51
|
+
"vite": "^8.3.5"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@biomejs/biome": "2.6.4",
|
|
55
|
+
"@storybook/addon-docs": "10.6.5",
|
|
56
|
+
"@types/bun": "1.3.11",
|
|
57
|
+
"@types/node": "24.10.1",
|
|
58
|
+
"storybook": "10.6.5",
|
|
59
|
+
"typescript": "6.0.3",
|
|
60
|
+
"vite": "8.3.5"
|
|
61
|
+
},
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "git+https://github.com/Code-Growers/storybook-jaspr-vite.git"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://github.com/Code-Growers/storybook-jaspr-vite#readme",
|
|
67
|
+
"bugs": {
|
|
68
|
+
"url": "https://github.com/Code-Growers/storybook-jaspr-vite/issues"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public",
|
|
72
|
+
"registry": "https://registry.npmjs.org/"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"bun": ">=1.4.2"
|
|
76
|
+
},
|
|
77
|
+
"packageManager": "bun@1.4.2"
|
|
78
|
+
}
|
package/preset.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist/preset.js";
|