storybook-astro 0.1.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/LICENSE +21 -0
- package/README.md +330 -0
- package/dist/index.cjs +397 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +390 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/index.cjs +50 -0
- package/dist/integration/index.cjs.map +1 -0
- package/dist/integration/index.d.cts +26 -0
- package/dist/integration/index.d.ts +26 -0
- package/dist/integration/index.js +44 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/toolbar-app.cjs +91 -0
- package/dist/integration/toolbar-app.cjs.map +1 -0
- package/dist/integration/toolbar-app.d.cts +10 -0
- package/dist/integration/toolbar-app.d.ts +10 -0
- package/dist/integration/toolbar-app.js +89 -0
- package/dist/integration/toolbar-app.js.map +1 -0
- package/dist/preset.cjs +294 -0
- package/dist/preset.cjs.map +1 -0
- package/dist/preset.d.cts +49 -0
- package/dist/preset.d.ts +49 -0
- package/dist/preset.js +285 -0
- package/dist/preset.js.map +1 -0
- package/dist/render-BR-BGSWL.d.cts +36 -0
- package/dist/render-BR-BGSWL.d.ts +36 -0
- package/dist/renderer/entry-preview.cjs +315 -0
- package/dist/renderer/entry-preview.cjs.map +1 -0
- package/dist/renderer/entry-preview.d.cts +26 -0
- package/dist/renderer/entry-preview.d.ts +26 -0
- package/dist/renderer/entry-preview.js +311 -0
- package/dist/renderer/entry-preview.js.map +1 -0
- package/dist/renderer/index.cjs +216 -0
- package/dist/renderer/index.cjs.map +1 -0
- package/dist/renderer/index.d.cts +21 -0
- package/dist/renderer/index.d.ts +21 -0
- package/dist/renderer/index.js +211 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/sourceTransformer-CsgaPbY9.d.cts +38 -0
- package/dist/sourceTransformer-CsgaPbY9.d.ts +38 -0
- package/package.json +100 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/framework/vite-plugins.ts
|
|
16
|
+
var vite_plugins_exports = {};
|
|
17
|
+
__export(vite_plugins_exports, {
|
|
18
|
+
createAstroVitePlugins: () => createAstroVitePlugins
|
|
19
|
+
});
|
|
20
|
+
async function createAstroVitePlugins(options) {
|
|
21
|
+
process.env.VITEST = "true";
|
|
22
|
+
const astroViteConfig = await getAstroViteConfig();
|
|
23
|
+
const astroPlugins = extractAstroPlugins(astroViteConfig);
|
|
24
|
+
return [
|
|
25
|
+
...astroPlugins,
|
|
26
|
+
astroContainerPlugin(),
|
|
27
|
+
astroStylesPlugin(options.stylesheets || []),
|
|
28
|
+
astroScriptsPlugin(options.scripts || []),
|
|
29
|
+
astroComponentMarkerPlugin()
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
async function getAstroViteConfig() {
|
|
33
|
+
if (cachedAstroViteConfig) {
|
|
34
|
+
return cachedAstroViteConfig;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const { getViteConfig } = await import('astro/config');
|
|
38
|
+
const configFn = getViteConfig({}, {
|
|
39
|
+
// Minimal inline Astro config - will use astro.config.mjs from project
|
|
40
|
+
});
|
|
41
|
+
cachedAstroViteConfig = await configFn({
|
|
42
|
+
mode: "development",
|
|
43
|
+
command: "serve"
|
|
44
|
+
});
|
|
45
|
+
return cachedAstroViteConfig;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.warn("[storybook-astro] Could not load Astro Vite config:", error);
|
|
48
|
+
return { plugins: [] };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function extractAstroPlugins(config) {
|
|
52
|
+
if (!config.plugins) return [];
|
|
53
|
+
const flatPlugins = [];
|
|
54
|
+
const flatten = (arr) => {
|
|
55
|
+
for (const item of arr) {
|
|
56
|
+
if (Array.isArray(item)) {
|
|
57
|
+
flatten(item);
|
|
58
|
+
} else if (item) {
|
|
59
|
+
flatPlugins.push(item);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
flatten(config.plugins);
|
|
64
|
+
const essentialPlugins = [
|
|
65
|
+
"astro:build",
|
|
66
|
+
"astro:build:normal",
|
|
67
|
+
"astro:config-alias",
|
|
68
|
+
"astro:load-fallback",
|
|
69
|
+
"astro:postprocess",
|
|
70
|
+
"astro:markdown",
|
|
71
|
+
"astro:html",
|
|
72
|
+
"astro:scripts",
|
|
73
|
+
"astro:assets",
|
|
74
|
+
"astro:head",
|
|
75
|
+
"astro:container"
|
|
76
|
+
];
|
|
77
|
+
return flatPlugins.filter((p) => {
|
|
78
|
+
if (!p || typeof p !== "object") return false;
|
|
79
|
+
const name = "name" in p ? String(p.name) : "";
|
|
80
|
+
return essentialPlugins.some((essential) => name.startsWith(essential) || name === essential);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function astroContainerPlugin() {
|
|
84
|
+
let viteServer;
|
|
85
|
+
return {
|
|
86
|
+
name: "storybook-astro:container",
|
|
87
|
+
configureServer(server) {
|
|
88
|
+
viteServer = server;
|
|
89
|
+
server.ws.on("astro:render:request", async (data, client) => {
|
|
90
|
+
try {
|
|
91
|
+
const html = await renderAstroComponent(data, viteServer);
|
|
92
|
+
const response = {
|
|
93
|
+
id: data.id,
|
|
94
|
+
html
|
|
95
|
+
};
|
|
96
|
+
client.send("astro:render:response", response);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
99
|
+
console.error("[storybook-astro] Render error:", errorMessage);
|
|
100
|
+
const response = {
|
|
101
|
+
id: data.id,
|
|
102
|
+
html: `<div style="color: #dc2626; background: #fef2f2; padding: 16px; border-radius: 8px; font-family: system-ui;">
|
|
103
|
+
<strong>Render Error</strong>
|
|
104
|
+
<pre style="margin: 8px 0 0; white-space: pre-wrap;">${escapeHtml(errorMessage)}</pre>
|
|
105
|
+
</div>`,
|
|
106
|
+
error: errorMessage
|
|
107
|
+
};
|
|
108
|
+
client.send("astro:render:response", response);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function renderAstroComponent(data, server) {
|
|
115
|
+
const { experimental_AstroContainer: AstroContainer } = await import('astro/container');
|
|
116
|
+
const container = await AstroContainer.create({
|
|
117
|
+
// Resolve module paths for client-side scripts
|
|
118
|
+
resolve: async (specifier) => {
|
|
119
|
+
if (specifier.startsWith("astro:scripts")) {
|
|
120
|
+
return `/@id/${specifier}`;
|
|
121
|
+
}
|
|
122
|
+
return specifier;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const componentModule = await server.ssrLoadModule(data.component);
|
|
126
|
+
const Component = componentModule.default;
|
|
127
|
+
if (!Component) {
|
|
128
|
+
throw new Error(`Component not found: ${data.component}`);
|
|
129
|
+
}
|
|
130
|
+
const html = await container.renderToString(Component, {
|
|
131
|
+
props: data.args || {},
|
|
132
|
+
slots: data.slots || {}
|
|
133
|
+
});
|
|
134
|
+
return html;
|
|
135
|
+
}
|
|
136
|
+
function astroStylesPlugin(stylesheets) {
|
|
137
|
+
const virtualModuleId = "virtual:astro-storybook/styles";
|
|
138
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
139
|
+
return {
|
|
140
|
+
name: "storybook-astro:styles",
|
|
141
|
+
resolveId(id) {
|
|
142
|
+
if (id === virtualModuleId) {
|
|
143
|
+
return resolvedVirtualModuleId;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
load(id) {
|
|
147
|
+
if (id === resolvedVirtualModuleId) {
|
|
148
|
+
const normalized = stylesheets.map((s) => normalizeAssetPath(s));
|
|
149
|
+
return `export const stylesheets = ${JSON.stringify(normalized)};`;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function astroScriptsPlugin(scripts) {
|
|
155
|
+
const virtualModuleId = "virtual:astro-storybook/scripts";
|
|
156
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
157
|
+
return {
|
|
158
|
+
name: "storybook-astro:scripts",
|
|
159
|
+
resolveId(id) {
|
|
160
|
+
if (id === virtualModuleId) {
|
|
161
|
+
return resolvedVirtualModuleId;
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
load(id) {
|
|
165
|
+
if (id === resolvedVirtualModuleId) {
|
|
166
|
+
const normalized = scripts.map((s) => normalizeAssetPath(s));
|
|
167
|
+
return `export const scripts = ${JSON.stringify(normalized)};`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function astroComponentMarkerPlugin() {
|
|
173
|
+
return {
|
|
174
|
+
name: "storybook-astro:component-marker",
|
|
175
|
+
enforce: "post",
|
|
176
|
+
transform(code, id) {
|
|
177
|
+
if (!id.endsWith(".astro") && !id.includes(".astro?")) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
if (code.includes("export default") || code.includes("export { $$Component as default }")) {
|
|
181
|
+
const moduleIdLine = `
|
|
182
|
+
;(function() {
|
|
183
|
+
if (typeof $$Component !== 'undefined') {
|
|
184
|
+
$$Component.isAstroComponentFactory = true;
|
|
185
|
+
$$Component.moduleId = ${JSON.stringify(id.split("?")[0])};
|
|
186
|
+
}
|
|
187
|
+
})();
|
|
188
|
+
`;
|
|
189
|
+
return {
|
|
190
|
+
code: code + moduleIdLine,
|
|
191
|
+
map: null
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
},
|
|
196
|
+
// Handle HMR for Astro components
|
|
197
|
+
handleHotUpdate({ file, server }) {
|
|
198
|
+
if (file.endsWith(".astro")) {
|
|
199
|
+
server.ws.send({
|
|
200
|
+
type: "custom",
|
|
201
|
+
event: "astro:component:update",
|
|
202
|
+
data: { file }
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function normalizeAssetPath(path) {
|
|
209
|
+
if (/^https?:\/\//.test(path)) {
|
|
210
|
+
return path;
|
|
211
|
+
}
|
|
212
|
+
path = path.replace(/^\.\//, "");
|
|
213
|
+
if (!path.startsWith("/")) {
|
|
214
|
+
path = "/" + path;
|
|
215
|
+
}
|
|
216
|
+
return path;
|
|
217
|
+
}
|
|
218
|
+
function escapeHtml(text) {
|
|
219
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
220
|
+
}
|
|
221
|
+
var cachedAstroViteConfig;
|
|
222
|
+
var init_vite_plugins = __esm({
|
|
223
|
+
"src/framework/vite-plugins.ts"() {
|
|
224
|
+
cachedAstroViteConfig = null;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// src/docs/sourceTransformer.ts
|
|
229
|
+
function getComponentName(context) {
|
|
230
|
+
const { component, title } = context;
|
|
231
|
+
if (component) {
|
|
232
|
+
if (component.displayName) return component.displayName;
|
|
233
|
+
if (component.name && component.name !== "default") return component.name;
|
|
234
|
+
if (component.__docgenInfo?.displayName) return component.__docgenInfo.displayName;
|
|
235
|
+
}
|
|
236
|
+
const parts = title.split("/");
|
|
237
|
+
return parts[parts.length - 1];
|
|
238
|
+
}
|
|
239
|
+
function formatPropValue(value) {
|
|
240
|
+
if (typeof value === "string") {
|
|
241
|
+
const escaped = value.replace(/"/g, '\\"');
|
|
242
|
+
return `"${escaped}"`;
|
|
243
|
+
}
|
|
244
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
245
|
+
return `{${value}}`;
|
|
246
|
+
}
|
|
247
|
+
if (value === null || value === void 0) {
|
|
248
|
+
return `{${value}}`;
|
|
249
|
+
}
|
|
250
|
+
if (Array.isArray(value) || typeof value === "object") {
|
|
251
|
+
return `{${JSON.stringify(value, null, 2)}}`;
|
|
252
|
+
}
|
|
253
|
+
return `{${String(value)}}`;
|
|
254
|
+
}
|
|
255
|
+
function formatProps(args, indent = " ") {
|
|
256
|
+
const entries = Object.entries(args).filter(([_, value]) => value !== void 0);
|
|
257
|
+
if (entries.length === 0) {
|
|
258
|
+
return "";
|
|
259
|
+
}
|
|
260
|
+
if (entries.length === 1) {
|
|
261
|
+
const [key, value] = entries[0];
|
|
262
|
+
const formatted = formatPropValue(value);
|
|
263
|
+
if (formatted.length < 40) {
|
|
264
|
+
return ` ${key}=${formatted}`;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return "\n" + entries.map(([key, value]) => `${indent}${key}=${formatPropValue(value)}`).join("\n") + "\n";
|
|
268
|
+
}
|
|
269
|
+
function transformSource(code, context) {
|
|
270
|
+
if (context.parameters?.docs?.source?.code) {
|
|
271
|
+
return context.parameters.docs.source.code;
|
|
272
|
+
}
|
|
273
|
+
const componentName = getComponentName(context);
|
|
274
|
+
const { args } = context;
|
|
275
|
+
if (!args || Object.keys(args).length === 0) {
|
|
276
|
+
return `---
|
|
277
|
+
import ${componentName} from '../components/${componentName}.astro';
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
<${componentName} />`;
|
|
281
|
+
}
|
|
282
|
+
const propsString = formatProps(args);
|
|
283
|
+
const selfClosing = !propsString.includes("\n");
|
|
284
|
+
if (selfClosing) {
|
|
285
|
+
return `---
|
|
286
|
+
import ${componentName} from '../components/${componentName}.astro';
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
<${componentName}${propsString} />`;
|
|
290
|
+
}
|
|
291
|
+
return `---
|
|
292
|
+
import ${componentName} from '../components/${componentName}.astro';
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
<${componentName}${propsString}/>`;
|
|
296
|
+
}
|
|
297
|
+
var require2 = createRequire(import.meta.url);
|
|
298
|
+
function getToolbarEntrypoint() {
|
|
299
|
+
const packageJsonPath = require2.resolve("storybook-astro/package.json");
|
|
300
|
+
const packageRoot = dirname(packageJsonPath);
|
|
301
|
+
return join(packageRoot, "dist", "integration", "toolbar-app.js");
|
|
302
|
+
}
|
|
303
|
+
function storybookDevToolbar(options = {}) {
|
|
304
|
+
const { port = 6006, host = "localhost" } = options;
|
|
305
|
+
return {
|
|
306
|
+
name: "storybook-astro/toolbar",
|
|
307
|
+
hooks: {
|
|
308
|
+
"astro:config:setup": ({ addDevToolbarApp, command }) => {
|
|
309
|
+
if (command !== "dev") return;
|
|
310
|
+
const entrypointPath = getToolbarEntrypoint();
|
|
311
|
+
addDevToolbarApp({
|
|
312
|
+
id: "storybook-toolbar-app",
|
|
313
|
+
name: "Storybook",
|
|
314
|
+
// Official Storybook icon from https://github.com/storybookjs/brand
|
|
315
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 64" fill="none"><path fill="#FF4785" d="M50.273 2.923a3.12 3.12 0 0 1 .006.194v55.766a3.117 3.117 0 0 1-3.15 3.117l-42.14-1.869a3.108 3.108 0 0 1-3.006-2.997L.002 5.955A3.108 3.108 0 0 1 2.953 2.727L37.427.594l-.3 7.027a.466.466 0 0 0 .753.396l2.758-2.07 2.329 1.816a.467.467 0 0 0 .76-.381l-.26-7.155 3.466-.221a3.108 3.108 0 0 1 3.34 2.917Z"/><path fill="#fff" d="M29.403 23.369c0 1.213 8.254.636 9.362-.215 0-8.259-4.477-12.599-12.676-12.599-8.199 0-12.793 4.408-12.793 11.019 0 11.514 15.7 11.734 15.7 18.015 0 1.763-.872 2.81-2.791 2.81-2.5 0-3.489-1.264-3.373-5.561 0-.932-9.536-1.223-9.827 0-.74 10.414 5.815 13.417 13.316 13.417 7.269 0 12.967-3.834 12.967-10.776 0-12.34-15.933-12.01-15.933-18.125 0-2.48 1.861-2.81 2.966-2.81 1.163 0 3.256.203 3.082 4.825Z"/></svg>`,
|
|
316
|
+
entrypoint: entrypointPath
|
|
317
|
+
});
|
|
318
|
+
},
|
|
319
|
+
"astro:server:setup": ({ server }) => {
|
|
320
|
+
server.middlewares.use((req, res, next) => {
|
|
321
|
+
if (req.url === "/__storybook-config") {
|
|
322
|
+
res.setHeader("Content-Type", "application/json");
|
|
323
|
+
res.end(JSON.stringify({ port, host }));
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
next();
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
var __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
333
|
+
var require3 = createRequire(import.meta.url);
|
|
334
|
+
function getAbsolutePath(input) {
|
|
335
|
+
return dirname(require3.resolve(join(input, "package.json")));
|
|
336
|
+
}
|
|
337
|
+
var core = {
|
|
338
|
+
builder: getAbsolutePath("@storybook/builder-vite"),
|
|
339
|
+
renderer: join(__dirname$1, "renderer")
|
|
340
|
+
};
|
|
341
|
+
var frameworkName = "storybook-astro";
|
|
342
|
+
var previewAnnotations = async (input = []) => {
|
|
343
|
+
return [
|
|
344
|
+
...input,
|
|
345
|
+
join(__dirname$1, "renderer", "entry-preview.js")
|
|
346
|
+
];
|
|
347
|
+
};
|
|
348
|
+
async function viteFinal(config, { presets }) {
|
|
349
|
+
const frameworkOptions = await presets.apply("frameworkOptions");
|
|
350
|
+
const { createAstroVitePlugins: createAstroVitePlugins2 } = await Promise.resolve().then(() => (init_vite_plugins(), vite_plugins_exports));
|
|
351
|
+
const astroPlugins = await createAstroVitePlugins2(frameworkOptions || {});
|
|
352
|
+
const existingPlugins = config.plugins || [];
|
|
353
|
+
const existingOptimizeDeps = config.optimizeDeps || {};
|
|
354
|
+
const existingSsr = config.ssr || {};
|
|
355
|
+
return {
|
|
356
|
+
...config,
|
|
357
|
+
plugins: [...existingPlugins, ...astroPlugins],
|
|
358
|
+
optimizeDeps: {
|
|
359
|
+
...existingOptimizeDeps,
|
|
360
|
+
include: [
|
|
361
|
+
...existingOptimizeDeps.include || [],
|
|
362
|
+
// Pre-bundle CJS modules that Astro depends on
|
|
363
|
+
"cssesc",
|
|
364
|
+
"string-width"
|
|
365
|
+
],
|
|
366
|
+
exclude: [
|
|
367
|
+
...existingOptimizeDeps.exclude || [],
|
|
368
|
+
"astro",
|
|
369
|
+
"astro/container"
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
ssr: {
|
|
373
|
+
...existingSsr,
|
|
374
|
+
noExternal: [
|
|
375
|
+
...Array.isArray(existingSsr.noExternal) ? existingSsr.noExternal : [],
|
|
376
|
+
"storybook-astro"
|
|
377
|
+
]
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
var preset_default = {
|
|
382
|
+
core,
|
|
383
|
+
viteFinal,
|
|
384
|
+
frameworkName,
|
|
385
|
+
previewAnnotations
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
export { preset_default as default, storybookDevToolbar, transformSource };
|
|
389
|
+
//# sourceMappingURL=index.js.map
|
|
390
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/framework/vite-plugins.ts","../src/docs/sourceTransformer.ts","../src/integration/index.ts","../src/preset.ts"],"names":["require","__dirname","dirname","createRequire","join","createAstroVitePlugins"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAA,oBAAA,GAAA,EAAA;AAAA,QAAA,CAAA,oBAAA,EAAA;AAAA,EAAA,sBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkBA,eAAsB,uBAAuB,OAAA,EAA8C;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AW,EAAC;AAC3C,EAAA,MAAM,oBAAA,GAAuB,MAAA,CAAO,YAAA,IAAgB,EAAC;AACrD,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,GAAA,IAAO,EAAC;AAEnC,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,OAAA,EAAS,CAAC,GAAG,eAAA,EAAiB,GAAG,YAAY,CAAA;AAAA,IAC7C,YAAA,EAAc;AAAA,MACZ,GAAG,oBAAA;AAAA,MACH,OAAA,EAAS;AAAA,QACP,GAAI,oBAAA,CAAqB,OAAA,IAAW,EAAC;AAAA;AAAA,QAErC,QAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,OAAA,EAAS;AAAA,QACP,GAAI,oBAAA,CAAqB,OAAA,IAAW,EAAC;AAAA,QACrC,OAAA;AAAA,QACA;AAAA;AACF,KACF;AAAA,IACA,GAAA,EAAK;AAAA,MACH,GAAG,WAAA;AAAA,MACH,UAAA,EAAY;AAAA,QACV,GAAI,MAAM,OAAA,CAAQ,WAAA,CAAY,UAAU,CAAA,GAAI,WAAA,CAAY,aAAa,EAAC;AAAA,QACtE;AAAA;AACF;AACF,GACF;AACF;AAKA,IAAO,cAAA,GAAQ;AAAA,EACb,IAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["/**\n * Vite plugins for Astro Storybook integration\n * \n * Creates the necessary Vite plugins to:\n * 1. Handle Astro component imports via Astro's Vite plugin\n * 2. Set up WebSocket communication for rendering\n * 3. Inject global styles and scripts\n */\n\nimport type { Plugin, ViteDevServer, InlineConfig } from 'vite';\nimport type { FrameworkOptions, RenderRequestMessage, RenderResponseMessage } from '../types/index.js';\n\n// Cache the Astro Vite config to avoid recreating it\nlet cachedAstroViteConfig: InlineConfig | null = null;\n\n/**\n * Create all Vite plugins needed for Astro support in Storybook\n */\nexport async function createAstroVitePlugins(options: FrameworkOptions): Promise<Plugin[]> {\n // Set VITEST env to trick Astro into compiling components for client-side rendering\n // This works around the SSR check in astro:build plugin that would otherwise\n // stub out components with an error\n process.env.VITEST = 'true';\n \n // Get Astro's full Vite configuration including all plugins\n const astroViteConfig = await getAstroViteConfig();\n \n // Extract plugins from Astro's config\n const astroPlugins = extractAstroPlugins(astroViteConfig);\n \n return [\n ...astroPlugins,\n astroContainerPlugin(),\n astroStylesPlugin(options.stylesheets || []),\n astroScriptsPlugin(options.scripts || []),\n astroComponentMarkerPlugin(),\n ];\n}\n\n/**\n * Get the full Astro Vite configuration using getViteConfig\n */\nasync function getAstroViteConfig(): Promise<InlineConfig> {\n if (cachedAstroViteConfig) {\n return cachedAstroViteConfig;\n }\n \n try {\n const { getViteConfig } = await import('astro/config');\n \n // getViteConfig returns a function that takes { mode, command }\n const configFn = getViteConfig({}, {\n // Minimal inline Astro config - will use astro.config.mjs from project\n });\n \n cachedAstroViteConfig = await configFn({ \n mode: 'development', \n command: 'serve' \n });\n \n return cachedAstroViteConfig;\n } catch (error) {\n console.warn('[storybook-astro] Could not load Astro Vite config:', error);\n return { plugins: [] };\n }\n}\n\n/**\n * Extract relevant plugins from Astro's Vite configuration\n */\nfunction extractAstroPlugins(config: InlineConfig): Plugin[] {\n if (!config.plugins) return [];\n \n // Flatten nested plugin arrays - use explicit typing to avoid deep recursion\n const flatPlugins: unknown[] = [];\n const flatten = (arr: unknown[]): void => {\n for (const item of arr) {\n if (Array.isArray(item)) {\n flatten(item);\n } else if (item) {\n flatPlugins.push(item);\n }\n }\n };\n flatten(config.plugins as unknown[]);\n \n // Include plugins essential for .astro file compilation\n const essentialPlugins = [\n 'astro:build',\n 'astro:build:normal', \n 'astro:config-alias',\n 'astro:load-fallback',\n 'astro:postprocess',\n 'astro:markdown',\n 'astro:html',\n 'astro:scripts',\n 'astro:assets',\n 'astro:head',\n 'astro:container',\n ];\n \n return flatPlugins.filter((p): p is Plugin => {\n if (!p || typeof p !== 'object') return false;\n const name = 'name' in p ? String((p as { name: unknown }).name) : '';\n return essentialPlugins.some(essential => name.startsWith(essential) || name === essential);\n });\n}\n\n/**\n * Plugin that sets up the Astro Container API for server-side rendering\n * Handles WebSocket messages from the client to render components\n */\nfunction astroContainerPlugin(): Plugin {\n let viteServer: ViteDevServer;\n \n return {\n name: 'storybook-astro:container',\n \n configureServer(server) {\n viteServer = server;\n \n // Handle render requests from the client\n server.ws.on('astro:render:request', async (data: RenderRequestMessage['data'], client) => {\n try {\n const html = await renderAstroComponent(data, viteServer);\n \n const response: RenderResponseMessage['data'] = {\n id: data.id,\n html,\n };\n \n client.send('astro:render:response', response);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error';\n console.error('[storybook-astro] Render error:', errorMessage);\n \n const response: RenderResponseMessage['data'] = {\n id: data.id,\n html: `<div style=\"color: #dc2626; background: #fef2f2; padding: 16px; border-radius: 8px; font-family: system-ui;\">\n <strong>Render Error</strong>\n <pre style=\"margin: 8px 0 0; white-space: pre-wrap;\">${escapeHtml(errorMessage)}</pre>\n </div>`,\n error: errorMessage,\n };\n \n client.send('astro:render:response', response);\n }\n });\n },\n };\n}\n\n/**\n * Render an Astro component using the Container API\n */\nasync function renderAstroComponent(\n data: RenderRequestMessage['data'],\n server: ViteDevServer\n): Promise<string> {\n // Dynamic import to get fresh module on HMR\n const { experimental_AstroContainer: AstroContainer } = await import('astro/container');\n \n // Create container for rendering\n const container = await AstroContainer.create({\n // Resolve module paths for client-side scripts\n resolve: async (specifier: string) => {\n if (specifier.startsWith('astro:scripts')) {\n return `/@id/${specifier}`;\n }\n return specifier;\n },\n });\n \n // Import the component module\n const componentModule = await server.ssrLoadModule(data.component);\n const Component = componentModule.default;\n \n if (!Component) {\n throw new Error(`Component not found: ${data.component}`);\n }\n \n // Render to string\n const html = await container.renderToString(Component, {\n props: data.args || {},\n slots: data.slots || {},\n });\n \n return html;\n}\n\n/**\n * Virtual module plugin for injecting global stylesheets\n */\nfunction astroStylesPlugin(stylesheets: string[]): Plugin {\n const virtualModuleId = 'virtual:astro-storybook/styles';\n const resolvedVirtualModuleId = '\\0' + virtualModuleId;\n \n return {\n name: 'storybook-astro:styles',\n \n resolveId(id) {\n if (id === virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n \n load(id) {\n if (id === resolvedVirtualModuleId) {\n const normalized = stylesheets.map(s => normalizeAssetPath(s));\n return `export const stylesheets = ${JSON.stringify(normalized)};`;\n }\n },\n };\n}\n\n/**\n * Virtual module plugin for injecting global scripts\n */\nfunction astroScriptsPlugin(scripts: string[]): Plugin {\n const virtualModuleId = 'virtual:astro-storybook/scripts';\n const resolvedVirtualModuleId = '\\0' + virtualModuleId;\n \n return {\n name: 'storybook-astro:scripts',\n \n resolveId(id) {\n if (id === virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n \n load(id) {\n if (id === resolvedVirtualModuleId) {\n const normalized = scripts.map(s => normalizeAssetPath(s));\n return `export const scripts = ${JSON.stringify(normalized)};`;\n }\n },\n };\n}\n\n/**\n * Plugin to mark Astro components with their module ID for rendering\n */\nfunction astroComponentMarkerPlugin(): Plugin {\n return {\n name: 'storybook-astro:component-marker',\n enforce: 'post',\n \n transform(code, id) {\n // Only process compiled .astro files\n if (!id.endsWith('.astro') && !id.includes('.astro?')) {\n return null;\n }\n \n // Look for the default export and add moduleId\n // Astro compiles components to have a default export\n if (code.includes('export default') || code.includes('export { $$Component as default }')) {\n const moduleIdLine = `\\n;(function() { \n if (typeof $$Component !== 'undefined') { \n $$Component.isAstroComponentFactory = true;\n $$Component.moduleId = ${JSON.stringify(id.split('?')[0])}; \n }\n })();\\n`;\n \n return {\n code: code + moduleIdLine,\n map: null,\n };\n }\n \n return null;\n },\n \n // Handle HMR for Astro components\n handleHotUpdate({ file, server }) {\n if (file.endsWith('.astro')) {\n server.ws.send({\n type: 'custom',\n event: 'astro:component:update',\n data: { file },\n });\n }\n },\n };\n}\n\n/**\n * Normalize asset paths for injection\n */\nfunction normalizeAssetPath(path: string): string {\n // Keep absolute URLs as-is\n if (/^https?:\\/\\//.test(path)) {\n return path;\n }\n \n // Remove leading ./ and ensure leading /\n path = path.replace(/^\\.\\//, '');\n if (!path.startsWith('/')) {\n path = '/' + path;\n }\n \n return path;\n}\n\n/**\n * Escape HTML special characters\n */\nfunction escapeHtml(text: string): string {\n return text\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n","/**\n * Source code transformer for Astro components in Storybook docs\n * \n * Transforms story args into proper Astro component syntax for display\n * in the \"Show code\" panel.\n */\n\nexport interface StoryContext {\n id: string;\n name: string;\n title: string;\n component?: {\n displayName?: string;\n name?: string;\n __docgenInfo?: {\n displayName?: string;\n };\n } & ((...args: unknown[]) => unknown);\n args: Record<string, unknown>;\n parameters?: {\n docs?: {\n source?: {\n code?: string;\n language?: string;\n excludeDecorators?: boolean;\n };\n };\n };\n}\n\n/**\n * Get the component name from the story context\n */\nfunction getComponentName(context: StoryContext): string {\n const { component, title } = context;\n \n // Try to get name from component\n if (component) {\n if (component.displayName) return component.displayName;\n if (component.name && component.name !== 'default') return component.name;\n if (component.__docgenInfo?.displayName) return component.__docgenInfo.displayName;\n }\n \n // Fall back to extracting from title (e.g., \"Components/HeroSection\" -> \"HeroSection\")\n const parts = title.split('/');\n return parts[parts.length - 1];\n}\n\n/**\n * Format a prop value for Astro template syntax\n */\nfunction formatPropValue(value: unknown): string {\n if (typeof value === 'string') {\n // Escape quotes in strings\n const escaped = value.replace(/\"/g, '\\\\\"');\n return `\"${escaped}\"`;\n }\n \n if (typeof value === 'number' || typeof value === 'boolean') {\n return `{${value}}`;\n }\n \n if (value === null || value === undefined) {\n return `{${value}}`;\n }\n \n if (Array.isArray(value) || typeof value === 'object') {\n // For complex values, use JSX expression syntax\n return `{${JSON.stringify(value, null, 2)}}`;\n }\n \n return `{${String(value)}}`;\n}\n\n/**\n * Format props as Astro component attributes\n */\nfunction formatProps(args: Record<string, unknown>, indent: string = ' '): string {\n const entries = Object.entries(args).filter(([_, value]) => value !== undefined);\n \n if (entries.length === 0) {\n return '';\n }\n \n // For single short prop, keep it inline\n if (entries.length === 1) {\n const [key, value] = entries[0];\n const formatted = formatPropValue(value);\n if (formatted.length < 40) {\n return ` ${key}=${formatted}`;\n }\n }\n \n // For multiple props or long values, format multiline\n return '\\n' + entries\n .map(([key, value]) => `${indent}${key}=${formatPropValue(value)}`)\n .join('\\n') + '\\n';\n}\n\n/**\n * Transform story source code to Astro syntax\n * \n * @param code - The original source code (usually just args object)\n * @param context - The story context with component and args info\n * @returns Formatted Astro component code\n */\nexport function transformSource(code: string, context: StoryContext): string {\n // If custom source is provided, use it\n if (context.parameters?.docs?.source?.code) {\n return context.parameters.docs.source.code;\n }\n \n const componentName = getComponentName(context);\n const { args } = context;\n \n // Handle empty args\n if (!args || Object.keys(args).length === 0) {\n return `---\nimport ${componentName} from '../components/${componentName}.astro';\n---\n\n<${componentName} />`;\n }\n \n const propsString = formatProps(args);\n const selfClosing = !propsString.includes('\\n');\n \n if (selfClosing) {\n return `---\nimport ${componentName} from '../components/${componentName}.astro';\n---\n\n<${componentName}${propsString} />`;\n }\n \n return `---\nimport ${componentName} from '../components/${componentName}.astro';\n---\n\n<${componentName}${propsString}/>`;\n}\n\n/**\n * Default export for easy importing\n */\nexport default transformSource;\n","/**\n * Astro Integration for Storybook Dev Toolbar App\n * \n * Adds a Storybook icon to the Astro dev toolbar that links to the running Storybook instance.\n */\n\nimport type { AstroIntegration } from 'astro';\nimport { createRequire } from 'module';\nimport { dirname, join } from 'path';\n\nconst require = createRequire(import.meta.url);\n\n// Get the toolbar-app.js path relative to the package root\n// This avoids issues with import.meta.url when bundled\nfunction getToolbarEntrypoint(): string {\n // Resolve the package.json to find the package root\n const packageJsonPath = require.resolve('storybook-astro/package.json');\n const packageRoot = dirname(packageJsonPath);\n return join(packageRoot, 'dist', 'integration', 'toolbar-app.js');\n}\n\nexport interface StorybookToolbarOptions {\n /**\n * The port Storybook is running on\n * @default 6006\n */\n port?: number;\n \n /**\n * The host Storybook is running on\n * @default 'localhost'\n */\n host?: string;\n}\n\n/**\n * Astro integration that adds a Storybook link to the dev toolbar\n */\nexport function storybookDevToolbar(options: StorybookToolbarOptions = {}): AstroIntegration {\n const { port = 6006, host = 'localhost' } = options;\n \n return {\n name: 'storybook-astro/toolbar',\n hooks: {\n 'astro:config:setup': ({ addDevToolbarApp, command }) => {\n // Only add in dev mode\n if (command !== 'dev') return;\n \n const entrypointPath = getToolbarEntrypoint();\n \n addDevToolbarApp({\n id: 'storybook-toolbar-app',\n name: 'Storybook',\n // Official Storybook icon from https://github.com/storybookjs/brand\n icon: `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 52 64\" fill=\"none\"><path fill=\"#FF4785\" d=\"M50.273 2.923a3.12 3.12 0 0 1 .006.194v55.766a3.117 3.117 0 0 1-3.15 3.117l-42.14-1.869a3.108 3.108 0 0 1-3.006-2.997L.002 5.955A3.108 3.108 0 0 1 2.953 2.727L37.427.594l-.3 7.027a.466.466 0 0 0 .753.396l2.758-2.07 2.329 1.816a.467.467 0 0 0 .76-.381l-.26-7.155 3.466-.221a3.108 3.108 0 0 1 3.34 2.917Z\"/><path fill=\"#fff\" d=\"M29.403 23.369c0 1.213 8.254.636 9.362-.215 0-8.259-4.477-12.599-12.676-12.599-8.199 0-12.793 4.408-12.793 11.019 0 11.514 15.7 11.734 15.7 18.015 0 1.763-.872 2.81-2.791 2.81-2.5 0-3.489-1.264-3.373-5.561 0-.932-9.536-1.223-9.827 0-.74 10.414 5.815 13.417 13.316 13.417 7.269 0 12.967-3.834 12.967-10.776 0-12.34-15.933-12.01-15.933-18.125 0-2.48 1.861-2.81 2.966-2.81 1.163 0 3.256.203 3.082 4.825Z\"/></svg>`,\n entrypoint: entrypointPath,\n });\n },\n 'astro:server:setup': ({ server }) => {\n // Inject the Storybook URL into the client via a virtual module\n server.middlewares.use((req, res, next) => {\n if (req.url === '/__storybook-config') {\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({ port, host }));\n return;\n }\n next();\n });\n },\n },\n };\n}\n\nexport default storybookDevToolbar;\n","/**\n * Storybook Preset for Astro Framework\n * \n * This preset configures Storybook to work with Astro components by:\n * 1. Setting up the Vite builder with Astro-specific plugins\n * 2. Configuring the custom Astro renderer\n * 3. Adding middleware for server-side rendering via Container API\n */\n\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createRequire } from 'node:module';\nimport type { FrameworkOptions } from './types/index.js';\nimport type { InlineConfig } from 'vite';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst require = createRequire(import.meta.url);\n\n/**\n * Get absolute path to a package\n */\nfunction getAbsolutePath<T extends string>(input: T): T {\n return dirname(require.resolve(join(input, 'package.json'))) as T;\n}\n\n/**\n * Core Storybook configuration\n */\nexport const core = {\n builder: getAbsolutePath('@storybook/builder-vite'),\n renderer: join(__dirname, 'renderer'),\n};\n\n/**\n * Framework name for Storybook\n */\nexport const frameworkName = 'storybook-astro' as const;\n\n/**\n * Preview annotations - tells Storybook where to find the render functions\n */\nexport const previewAnnotations = async (input: string[] = []) => {\n return [\n ...input,\n join(__dirname, 'renderer', 'entry-preview.js'),\n ];\n};\n\ninterface ViteFinalContext {\n presets: {\n apply<T>(preset: string): Promise<T>;\n };\n}\n\n/**\n * Vite configuration for Astro support\n */\nexport async function viteFinal(\n config: InlineConfig,\n { presets }: ViteFinalContext\n): Promise<InlineConfig> {\n const frameworkOptions = await presets.apply<FrameworkOptions>('frameworkOptions');\n \n // Dynamic import to avoid bundling issues\n const { createAstroVitePlugins } = await import('./framework/vite-plugins.js');\n \n const astroPlugins = await createAstroVitePlugins(frameworkOptions || {});\n \n const existingPlugins = config.plugins || [];\n const existingOptimizeDeps = config.optimizeDeps || {};\n const existingSsr = config.ssr || {};\n \n return {\n ...config,\n plugins: [...existingPlugins, ...astroPlugins],\n optimizeDeps: {\n ...existingOptimizeDeps,\n include: [\n ...(existingOptimizeDeps.include || []),\n // Pre-bundle CJS modules that Astro depends on\n 'cssesc',\n 'string-width',\n ],\n exclude: [\n ...(existingOptimizeDeps.exclude || []),\n 'astro',\n 'astro/container',\n ],\n },\n ssr: {\n ...existingSsr,\n noExternal: [\n ...(Array.isArray(existingSsr.noExternal) ? existingSsr.noExternal : []),\n 'storybook-astro',\n ],\n },\n };\n}\n\n/**\n * Default export for preset auto-detection\n */\nexport default {\n core,\n viteFinal,\n frameworkName,\n previewAnnotations,\n};\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var module$1 = require('module');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
|
|
8
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
9
|
+
// src/integration/index.ts
|
|
10
|
+
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
11
|
+
function getToolbarEntrypoint() {
|
|
12
|
+
const packageJsonPath = require2.resolve("storybook-astro/package.json");
|
|
13
|
+
const packageRoot = path.dirname(packageJsonPath);
|
|
14
|
+
return path.join(packageRoot, "dist", "integration", "toolbar-app.js");
|
|
15
|
+
}
|
|
16
|
+
function storybookDevToolbar(options = {}) {
|
|
17
|
+
const { port = 6006, host = "localhost" } = options;
|
|
18
|
+
return {
|
|
19
|
+
name: "storybook-astro/toolbar",
|
|
20
|
+
hooks: {
|
|
21
|
+
"astro:config:setup": ({ addDevToolbarApp, command }) => {
|
|
22
|
+
if (command !== "dev") return;
|
|
23
|
+
const entrypointPath = getToolbarEntrypoint();
|
|
24
|
+
addDevToolbarApp({
|
|
25
|
+
id: "storybook-toolbar-app",
|
|
26
|
+
name: "Storybook",
|
|
27
|
+
// Official Storybook icon from https://github.com/storybookjs/brand
|
|
28
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 64" fill="none"><path fill="#FF4785" d="M50.273 2.923a3.12 3.12 0 0 1 .006.194v55.766a3.117 3.117 0 0 1-3.15 3.117l-42.14-1.869a3.108 3.108 0 0 1-3.006-2.997L.002 5.955A3.108 3.108 0 0 1 2.953 2.727L37.427.594l-.3 7.027a.466.466 0 0 0 .753.396l2.758-2.07 2.329 1.816a.467.467 0 0 0 .76-.381l-.26-7.155 3.466-.221a3.108 3.108 0 0 1 3.34 2.917Z"/><path fill="#fff" d="M29.403 23.369c0 1.213 8.254.636 9.362-.215 0-8.259-4.477-12.599-12.676-12.599-8.199 0-12.793 4.408-12.793 11.019 0 11.514 15.7 11.734 15.7 18.015 0 1.763-.872 2.81-2.791 2.81-2.5 0-3.489-1.264-3.373-5.561 0-.932-9.536-1.223-9.827 0-.74 10.414 5.815 13.417 13.316 13.417 7.269 0 12.967-3.834 12.967-10.776 0-12.34-15.933-12.01-15.933-18.125 0-2.48 1.861-2.81 2.966-2.81 1.163 0 3.256.203 3.082 4.825Z"/></svg>`,
|
|
29
|
+
entrypoint: entrypointPath
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
"astro:server:setup": ({ server }) => {
|
|
33
|
+
server.middlewares.use((req, res, next) => {
|
|
34
|
+
if (req.url === "/__storybook-config") {
|
|
35
|
+
res.setHeader("Content-Type", "application/json");
|
|
36
|
+
res.end(JSON.stringify({ port, host }));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
next();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var integration_default = storybookDevToolbar;
|
|
46
|
+
|
|
47
|
+
exports.default = integration_default;
|
|
48
|
+
exports.storybookDevToolbar = storybookDevToolbar;
|
|
49
|
+
//# sourceMappingURL=index.cjs.map
|
|
50
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@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SAAA,CAAU,EAAE,IAAA,EAAM,IAAA,EAAM,CAAC,CAAA;AACtC,YAAA;AAAA,UACF;AACA,UAAA,IAAA,EAAK;AAAA,QACP,CAAC,CAAA;AAAA,MACH;AAAA;AACF,GACF;AACF;AAEA,IAAO,mBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Astro Integration for Storybook Dev Toolbar App\n * \n * Adds a Storybook icon to the Astro dev toolbar that links to the running Storybook instance.\n */\n\nimport type { AstroIntegration } from 'astro';\nimport { createRequire } from 'module';\nimport { dirname, join } from 'path';\n\nconst require = createRequire(import.meta.url);\n\n// Get the toolbar-app.js path relative to the package root\n// This avoids issues with import.meta.url when bundled\nfunction getToolbarEntrypoint(): string {\n // Resolve the package.json to find the package root\n const packageJsonPath = require.resolve('storybook-astro/package.json');\n const packageRoot = dirname(packageJsonPath);\n return join(packageRoot, 'dist', 'integration', 'toolbar-app.js');\n}\n\nexport interface StorybookToolbarOptions {\n /**\n * The port Storybook is running on\n * @default 6006\n */\n port?: number;\n \n /**\n * The host Storybook is running on\n * @default 'localhost'\n */\n host?: string;\n}\n\n/**\n * Astro integration that adds a Storybook link to the dev toolbar\n */\nexport function storybookDevToolbar(options: StorybookToolbarOptions = {}): AstroIntegration {\n const { port = 6006, host = 'localhost' } = options;\n \n return {\n name: 'storybook-astro/toolbar',\n hooks: {\n 'astro:config:setup': ({ addDevToolbarApp, command }) => {\n // Only add in dev mode\n if (command !== 'dev') return;\n \n const entrypointPath = getToolbarEntrypoint();\n \n addDevToolbarApp({\n id: 'storybook-toolbar-app',\n name: 'Storybook',\n // Official Storybook icon from https://github.com/storybookjs/brand\n icon: `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 52 64\" fill=\"none\"><path fill=\"#FF4785\" d=\"M50.273 2.923a3.12 3.12 0 0 1 .006.194v55.766a3.117 3.117 0 0 1-3.15 3.117l-42.14-1.869a3.108 3.108 0 0 1-3.006-2.997L.002 5.955A3.108 3.108 0 0 1 2.953 2.727L37.427.594l-.3 7.027a.466.466 0 0 0 .753.396l2.758-2.07 2.329 1.816a.467.467 0 0 0 .76-.381l-.26-7.155 3.466-.221a3.108 3.108 0 0 1 3.34 2.917Z\"/><path fill=\"#fff\" d=\"M29.403 23.369c0 1.213 8.254.636 9.362-.215 0-8.259-4.477-12.599-12.676-12.599-8.199 0-12.793 4.408-12.793 11.019 0 11.514 15.7 11.734 15.7 18.015 0 1.763-.872 2.81-2.791 2.81-2.5 0-3.489-1.264-3.373-5.561 0-.932-9.536-1.223-9.827 0-.74 10.414 5.815 13.417 13.316 13.417 7.269 0 12.967-3.834 12.967-10.776 0-12.34-15.933-12.01-15.933-18.125 0-2.48 1.861-2.81 2.966-2.81 1.163 0 3.256.203 3.082 4.825Z\"/></svg>`,\n entrypoint: entrypointPath,\n });\n },\n 'astro:server:setup': ({ server }) => {\n // Inject the Storybook URL into the client via a virtual module\n server.middlewares.use((req, res, next) => {\n if (req.url === '/__storybook-config') {\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({ port, host }));\n return;\n }\n next();\n });\n },\n },\n };\n}\n\nexport default storybookDevToolbar;\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AstroIntegration } from 'astro';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Astro Integration for Storybook Dev Toolbar App
|
|
5
|
+
*
|
|
6
|
+
* Adds a Storybook icon to the Astro dev toolbar that links to the running Storybook instance.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface StorybookToolbarOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The port Storybook is running on
|
|
12
|
+
* @default 6006
|
|
13
|
+
*/
|
|
14
|
+
port?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The host Storybook is running on
|
|
17
|
+
* @default 'localhost'
|
|
18
|
+
*/
|
|
19
|
+
host?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Astro integration that adds a Storybook link to the dev toolbar
|
|
23
|
+
*/
|
|
24
|
+
declare function storybookDevToolbar(options?: StorybookToolbarOptions): AstroIntegration;
|
|
25
|
+
|
|
26
|
+
export { type StorybookToolbarOptions, storybookDevToolbar as default, storybookDevToolbar };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AstroIntegration } from 'astro';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Astro Integration for Storybook Dev Toolbar App
|
|
5
|
+
*
|
|
6
|
+
* Adds a Storybook icon to the Astro dev toolbar that links to the running Storybook instance.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface StorybookToolbarOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The port Storybook is running on
|
|
12
|
+
* @default 6006
|
|
13
|
+
*/
|
|
14
|
+
port?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The host Storybook is running on
|
|
17
|
+
* @default 'localhost'
|
|
18
|
+
*/
|
|
19
|
+
host?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Astro integration that adds a Storybook link to the dev toolbar
|
|
23
|
+
*/
|
|
24
|
+
declare function storybookDevToolbar(options?: StorybookToolbarOptions): AstroIntegration;
|
|
25
|
+
|
|
26
|
+
export { type StorybookToolbarOptions, storybookDevToolbar as default, storybookDevToolbar };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
|
|
4
|
+
// src/integration/index.ts
|
|
5
|
+
var require2 = createRequire(import.meta.url);
|
|
6
|
+
function getToolbarEntrypoint() {
|
|
7
|
+
const packageJsonPath = require2.resolve("storybook-astro/package.json");
|
|
8
|
+
const packageRoot = dirname(packageJsonPath);
|
|
9
|
+
return join(packageRoot, "dist", "integration", "toolbar-app.js");
|
|
10
|
+
}
|
|
11
|
+
function storybookDevToolbar(options = {}) {
|
|
12
|
+
const { port = 6006, host = "localhost" } = options;
|
|
13
|
+
return {
|
|
14
|
+
name: "storybook-astro/toolbar",
|
|
15
|
+
hooks: {
|
|
16
|
+
"astro:config:setup": ({ addDevToolbarApp, command }) => {
|
|
17
|
+
if (command !== "dev") return;
|
|
18
|
+
const entrypointPath = getToolbarEntrypoint();
|
|
19
|
+
addDevToolbarApp({
|
|
20
|
+
id: "storybook-toolbar-app",
|
|
21
|
+
name: "Storybook",
|
|
22
|
+
// Official Storybook icon from https://github.com/storybookjs/brand
|
|
23
|
+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 64" fill="none"><path fill="#FF4785" d="M50.273 2.923a3.12 3.12 0 0 1 .006.194v55.766a3.117 3.117 0 0 1-3.15 3.117l-42.14-1.869a3.108 3.108 0 0 1-3.006-2.997L.002 5.955A3.108 3.108 0 0 1 2.953 2.727L37.427.594l-.3 7.027a.466.466 0 0 0 .753.396l2.758-2.07 2.329 1.816a.467.467 0 0 0 .76-.381l-.26-7.155 3.466-.221a3.108 3.108 0 0 1 3.34 2.917Z"/><path fill="#fff" d="M29.403 23.369c0 1.213 8.254.636 9.362-.215 0-8.259-4.477-12.599-12.676-12.599-8.199 0-12.793 4.408-12.793 11.019 0 11.514 15.7 11.734 15.7 18.015 0 1.763-.872 2.81-2.791 2.81-2.5 0-3.489-1.264-3.373-5.561 0-.932-9.536-1.223-9.827 0-.74 10.414 5.815 13.417 13.316 13.417 7.269 0 12.967-3.834 12.967-10.776 0-12.34-15.933-12.01-15.933-18.125 0-2.48 1.861-2.81 2.966-2.81 1.163 0 3.256.203 3.082 4.825Z"/></svg>`,
|
|
24
|
+
entrypoint: entrypointPath
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
"astro:server:setup": ({ server }) => {
|
|
28
|
+
server.middlewares.use((req, res, next) => {
|
|
29
|
+
if (req.url === "/__storybook-config") {
|
|
30
|
+
res.setHeader("Content-Type", "application/json");
|
|
31
|
+
res.end(JSON.stringify({ port, host }));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
next();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var integration_default = storybookDevToolbar;
|
|
41
|
+
|
|
42
|
+
export { integration_default as default, storybookDevToolbar };
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integration/index.ts"],"names":["require"],"mappings":";;;;AAUA,IAAMA,QAAAA,GAAU,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAI7C,SAAS,oBAAA,GAA+B;AAEtC,EAAA,MAAM,eAAA,GAAkBA,QAAAA,CAAQ,OAAA,CAAQ,8BAA8B,CAAA;AACtE,EAAA,MAAM,WAAA,GAAc,QAAQ,eAAe,CAAA;AAC3C,EAAA,OAAO,IAAA,CAAK,WAAA,EAAa,MAAA,EAAQ,aAAA,EAAe,gBAAgB,CAAA;AAClE;AAmBO,SAAS,mBAAA,CAAoB,OAAA,GAAmC,EAAC,EAAqB;AAC3F,EAAA,MAAM,EAAE,IAAA,GAAO,IAAA,EAAM,IAAA,GAAO,aAAY,GAAI,OAAA;AAE5C,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,yBAAA;AAAA,IACN,KAAA,EAAO;AAAA,MACL,oBAAA,EAAsB,CAAC,EAAE,gBAAA,EAAkB,SAAQ,KAAM;AAEvD,QAAA,IAAI,YAAY,KAAA,EAAO;AAEvB,QAAA,MAAM,iBAAiB,oBAAA,EAAqB;AAE5C,QAAA,gBAAA,CAAiB;AAAA,UACf,EAAA,EAAI,uBAAA;AAAA,UACJ,IAAA,EAAM,WAAA;AAAA;AAAA,UAEN,IAAA,EAAM,CAAA,+zBAAA,CAAA;AAAA,UACN,UAAA,EAAY;AAAA,SACb,CAAA;AAAA,MACH,CAAA;AAAA,MACA,oBAAA,EAAsB,CAAC,EAAE,MAAA,EAAO,KAAM;AAEpC,QAAA,MAAA,CAAO,WAAA,CAAY,GAAA,CAAI,CAAC,GAAA,EAAK,KAAK,IAAA,KAAS;AACzC,UAAA,IAAI,GAAA,CAAI,QAAQ,qBAAA,EAAuB;AACrC,YAAA,GAAA,CAAI,SAAA,CAAU,gBAAgB,kBAAkB,CAAA;AAChD,YAAA,GAAA,CAAI,IAAI,IAAA,CAAK,SAAA,CAAU,EAAE,IAAA,EAAM,IAAA,EAAM,CAAC,CAAA;AACtC,YAAA;AAAA,UACF;AACA,UAAA,IAAA,EAAK;AAAA,QACP,CAAC,CAAA;AAAA,MACH;AAAA;AACF,GACF;AACF;AAEA,IAAO,mBAAA,GAAQ","file":"index.js","sourcesContent":["/**\n * Astro Integration for Storybook Dev Toolbar App\n * \n * Adds a Storybook icon to the Astro dev toolbar that links to the running Storybook instance.\n */\n\nimport type { AstroIntegration } from 'astro';\nimport { createRequire } from 'module';\nimport { dirname, join } from 'path';\n\nconst require = createRequire(import.meta.url);\n\n// Get the toolbar-app.js path relative to the package root\n// This avoids issues with import.meta.url when bundled\nfunction getToolbarEntrypoint(): string {\n // Resolve the package.json to find the package root\n const packageJsonPath = require.resolve('storybook-astro/package.json');\n const packageRoot = dirname(packageJsonPath);\n return join(packageRoot, 'dist', 'integration', 'toolbar-app.js');\n}\n\nexport interface StorybookToolbarOptions {\n /**\n * The port Storybook is running on\n * @default 6006\n */\n port?: number;\n \n /**\n * The host Storybook is running on\n * @default 'localhost'\n */\n host?: string;\n}\n\n/**\n * Astro integration that adds a Storybook link to the dev toolbar\n */\nexport function storybookDevToolbar(options: StorybookToolbarOptions = {}): AstroIntegration {\n const { port = 6006, host = 'localhost' } = options;\n \n return {\n name: 'storybook-astro/toolbar',\n hooks: {\n 'astro:config:setup': ({ addDevToolbarApp, command }) => {\n // Only add in dev mode\n if (command !== 'dev') return;\n \n const entrypointPath = getToolbarEntrypoint();\n \n addDevToolbarApp({\n id: 'storybook-toolbar-app',\n name: 'Storybook',\n // Official Storybook icon from https://github.com/storybookjs/brand\n icon: `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 52 64\" fill=\"none\"><path fill=\"#FF4785\" d=\"M50.273 2.923a3.12 3.12 0 0 1 .006.194v55.766a3.117 3.117 0 0 1-3.15 3.117l-42.14-1.869a3.108 3.108 0 0 1-3.006-2.997L.002 5.955A3.108 3.108 0 0 1 2.953 2.727L37.427.594l-.3 7.027a.466.466 0 0 0 .753.396l2.758-2.07 2.329 1.816a.467.467 0 0 0 .76-.381l-.26-7.155 3.466-.221a3.108 3.108 0 0 1 3.34 2.917Z\"/><path fill=\"#fff\" d=\"M29.403 23.369c0 1.213 8.254.636 9.362-.215 0-8.259-4.477-12.599-12.676-12.599-8.199 0-12.793 4.408-12.793 11.019 0 11.514 15.7 11.734 15.7 18.015 0 1.763-.872 2.81-2.791 2.81-2.5 0-3.489-1.264-3.373-5.561 0-.932-9.536-1.223-9.827 0-.74 10.414 5.815 13.417 13.316 13.417 7.269 0 12.967-3.834 12.967-10.776 0-12.34-15.933-12.01-15.933-18.125 0-2.48 1.861-2.81 2.966-2.81 1.163 0 3.256.203 3.082 4.825Z\"/></svg>`,\n entrypoint: entrypointPath,\n });\n },\n 'astro:server:setup': ({ server }) => {\n // Inject the Storybook URL into the client via a virtual module\n server.middlewares.use((req, res, next) => {\n if (req.url === '/__storybook-config') {\n res.setHeader('Content-Type', 'application/json');\n res.end(JSON.stringify({ port, host }));\n return;\n }\n next();\n });\n },\n },\n };\n}\n\nexport default storybookDevToolbar;\n"]}
|