@storybook/addon-docs 10.5.0-alpha.0 → 10.5.0-alpha.10

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/dist/preset.js CHANGED
@@ -1,15 +1,15 @@
1
- import CJS_COMPAT_NODE_URL_v7k80q8btl from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_v7k80q8btl from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_v7k80q8btl from "node:module";
1
+ import CJS_COMPAT_NODE_URL_73jg7cechs from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_73jg7cechs from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_73jg7cechs from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_v7k80q8btl.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_v7k80q8btl.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_v7k80q8btl.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_73jg7cechs.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_73jg7cechs.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_73jg7cechs.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
- import "./_node-chunks/chunk-KOSZ4OFX.js";
12
+ import "./_node-chunks/chunk-KLL5RTY5.js";
13
13
 
14
14
  // src/preset.ts
15
15
  import { isAbsolute as isAbsolute2 } from "node:path";
@@ -218,23 +218,46 @@ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" &&
218
218
  }
219
219
  };
220
220
 
221
+ // src/mdx-service/server.ts
222
+ import { getComponentIdFromEntry as getComponentIdFromEntry2, groupBy as groupBy2, registerService } from "storybook/internal/common";
223
+ import { Tag as Tag2 } from "storybook/internal/core-server";
224
+
221
225
  // src/manifest.ts
222
226
  import * as fs from "node:fs/promises";
223
227
  import * as path2 from "node:path";
224
- import { groupBy } from "storybook/internal/common";
225
- import { Tag, analyzeMdx } from "storybook/internal/core-server";
228
+ import { getComponentIdFromEntry, groupBy } from "storybook/internal/common";
229
+ import {
230
+ Tag,
231
+ analyzeMdx,
232
+ mdxManifestRef
233
+ } from "storybook/internal/core-server";
226
234
  import { logger } from "storybook/internal/node-logger";
235
+
236
+ // src/extract-docs-summary.ts
237
+ function extractDocsSummary(content) {
238
+ let result = content;
239
+ result = result.replace(/^\s*import\s+(?:[\s\S]*?from\s+)?['"][^'"]+['"];?\s*$/gm, "");
240
+ let prevResult = "";
241
+ for (; prevResult !== result; )
242
+ prevResult = result, result = result.replace(/\{[^{}]*\}/g, "");
243
+ for (result = result.replace(/<[^>]+\/>/g, ""), prevResult = ""; prevResult !== result; )
244
+ prevResult = result, result = result.replace(/<(\w+)[^>]*>([\s\S]*?)<\/\1>/g, "$2");
245
+ if (result = result.replace(/<[^>]+>/g, ""), result = result.replace(/\s+/g, " ").trim(), !!result)
246
+ return result.length > 90 ? `${result.slice(0, 90)}...` : result;
247
+ }
248
+
249
+ // src/manifest.ts
227
250
  async function createDocsManifestEntry(entry) {
228
251
  let absolutePath = path2.join(process.cwd(), entry.importPath);
229
252
  try {
230
- let content = await fs.readFile(absolutePath, "utf-8"), { summary } = await analyzeMdx(content);
253
+ let content = await fs.readFile(absolutePath, "utf-8"), { summary } = await analyzeMdx(content), derivedSummary = summary ?? extractDocsSummary(content);
231
254
  return {
232
255
  id: entry.id,
233
256
  name: entry.name,
234
257
  path: entry.importPath,
235
258
  title: entry.title,
236
259
  content,
237
- ...summary && { summary }
260
+ ...derivedSummary !== void 0 && { summary: derivedSummary }
238
261
  };
239
262
  } catch (err) {
240
263
  return {
@@ -249,24 +272,39 @@ async function createDocsManifestEntry(entry) {
249
272
  };
250
273
  }
251
274
  }
252
- async function extractUnattachedDocsEntries(entries) {
253
- if (entries.length === 0)
254
- return {};
255
- let entriesWithContent = await Promise.all(entries.map(createDocsManifestEntry));
256
- return Object.fromEntries(entriesWithContent.map((entry) => [entry.id, entry]));
275
+ function createDocsManifestRefEntry(entry, componentId) {
276
+ return {
277
+ id: entry.id,
278
+ name: entry.name,
279
+ mdx: { $ref: mdxManifestRef(componentId, entry.id) }
280
+ };
281
+ }
282
+ async function buildUnattachedDocs(entries, build) {
283
+ let docs2 = await Promise.all(
284
+ entries.map(async (entry) => [entry.id, await build(entry, entry.id)])
285
+ );
286
+ return Object.fromEntries(docs2);
257
287
  }
258
- async function extractAttachedDocsEntries(entries, existingComponents) {
288
+ async function applyAttachedDocs(entries, existingComponents, build) {
259
289
  if (!existingComponents || entries.length === 0)
260
290
  return existingComponents;
261
- let entriesWithContent = await Promise.all(entries.map(createDocsManifestEntry));
262
- for (let docsEntry of entriesWithContent) {
263
- let componentId = docsEntry.id.split("--")[0], component = existingComponents.components[componentId];
264
- component && (component.docs || (component.docs = {}), component.docs[docsEntry.id] = docsEntry);
291
+ let docs2 = await Promise.all(
292
+ entries.map(async (entry) => {
293
+ let componentId = getComponentIdFromEntry(entry);
294
+ return { componentId, doc: await build(entry, componentId) };
295
+ })
296
+ ), components = { ...existingComponents.components };
297
+ for (let { componentId, doc } of docs2) {
298
+ let component = components[componentId] ?? { id: componentId, name: componentId };
299
+ components[componentId] = {
300
+ ...component,
301
+ docs: { ...component.docs, [doc.id]: doc }
302
+ };
265
303
  }
266
- return existingComponents;
304
+ return { ...existingComponents, components };
267
305
  }
268
- var manifests = async (existingManifests = {}, { manifestEntries }) => {
269
- let startPerformance = performance.now(), docsEntries = manifestEntries.filter(
306
+ var manifests = async (existingManifests = {}, { manifestEntries, presets }) => {
307
+ let startPerformance = performance.now(), features = await presets?.apply?.("features"), useMdxService = features?.experimentalDocgenServer === !0 && features?.componentsManifest === !0, docsEntries = manifestEntries.filter(
270
308
  (entry) => entry.type === "docs"
271
309
  );
272
310
  if (docsEntries.length === 0)
@@ -283,20 +321,398 @@ var manifests = async (existingManifests = {}, { manifestEntries }) => {
283
321
  });
284
322
  if (unattachedEntries.length === 0 && attachedEntries.length === 0)
285
323
  return existingManifests;
286
- let existingManifestsWithDocs = existingManifests, [unattachedDocs, updatedComponents] = await Promise.all([
287
- extractUnattachedDocsEntries(unattachedEntries),
288
- extractAttachedDocsEntries(attachedEntries, existingManifestsWithDocs.components)
324
+ let existingManifestsWithDocs = existingManifests, build = useMdxService ? createDocsManifestRefEntry : createDocsManifestEntry, [unattachedDocs, updatedComponents] = await Promise.all([
325
+ buildUnattachedDocs(unattachedEntries, build),
326
+ applyAttachedDocs(attachedEntries, existingManifestsWithDocs.components, build)
289
327
  ]), processedCount = unattachedEntries.length + attachedEntries.length;
290
328
  logger.verbose(
291
329
  `Docs manifest generation took ${performance.now() - startPerformance}ms for ${processedCount} entries (${unattachedEntries.length} unattached, ${attachedEntries.length} attached)`
292
330
  );
293
331
  let result = { ...existingManifestsWithDocs };
294
332
  return Object.keys(unattachedDocs).length > 0 && (result.docs = {
295
- v: 0,
333
+ v: useMdxService ? 1 : 0,
296
334
  docs: unattachedDocs
297
335
  }), updatedComponents && (result.components = updatedComponents), result;
298
336
  };
299
337
 
338
+ // src/mdx-service/definition.ts
339
+ import {
340
+ MDX_SERVICE_ID,
341
+ mdxQueryStaticPath
342
+ } from "storybook/internal/core-server";
343
+
344
+ // ../../../node_modules/valibot/dist/index.mjs
345
+ var store$4, DEFAULT_CONFIG = {
346
+ lang: void 0,
347
+ message: void 0,
348
+ abortEarly: void 0,
349
+ abortPipeEarly: void 0
350
+ };
351
+ function getGlobalConfig(config$1) {
352
+ return !config$1 && !store$4 ? DEFAULT_CONFIG : {
353
+ lang: config$1?.lang ?? store$4?.lang,
354
+ message: config$1?.message,
355
+ abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
356
+ abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
357
+ };
358
+ }
359
+ var store$3;
360
+ function getGlobalMessage(lang) {
361
+ return store$3?.get(lang);
362
+ }
363
+ var store$2;
364
+ function getSchemaMessage(lang) {
365
+ return store$2?.get(lang);
366
+ }
367
+ var store$1;
368
+ function getSpecificMessage(reference, lang) {
369
+ return store$1?.get(reference)?.get(lang);
370
+ }
371
+ function _stringify(input) {
372
+ let type = typeof input;
373
+ return type === "string" ? `"${input}"` : type === "number" || type === "bigint" || type === "boolean" ? `${input}` : type === "object" || type === "function" ? (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null" : type;
374
+ }
375
+ function _addIssue(context, label, dataset, config$1, other) {
376
+ let input = other && "input" in other ? other.input : dataset.value, expected = other?.expected ?? context.expects ?? null, received = other?.received ?? _stringify(input), issue = {
377
+ kind: context.kind,
378
+ type: context.type,
379
+ input,
380
+ expected,
381
+ received,
382
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
383
+ requirement: context.requirement,
384
+ path: other?.path,
385
+ issues: other?.issues,
386
+ lang: config$1.lang,
387
+ abortEarly: config$1.abortEarly,
388
+ abortPipeEarly: config$1.abortPipeEarly
389
+ }, isSchema = context.kind === "schema", message$1 = other?.message ?? context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config$1.message ?? getGlobalMessage(issue.lang);
390
+ message$1 !== void 0 && (issue.message = typeof message$1 == "function" ? message$1(issue) : message$1), isSchema && (dataset.typed = !1), dataset.issues ? dataset.issues.push(issue) : dataset.issues = [issue];
391
+ }
392
+ var _standardCache = /* @__PURE__ */ new WeakMap();
393
+ function _getStandardProps(context) {
394
+ let cached = _standardCache.get(context);
395
+ return cached || (cached = {
396
+ version: 1,
397
+ vendor: "valibot",
398
+ validate(value$1) {
399
+ return context["~run"]({ value: value$1 }, getGlobalConfig());
400
+ }
401
+ }, _standardCache.set(context, cached)), cached;
402
+ }
403
+ function _isValidObjectKey(object$1, key) {
404
+ return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
405
+ }
406
+ var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
407
+ function getFallback(schema, dataset, config$1) {
408
+ return typeof schema.fallback == "function" ? schema.fallback(dataset, config$1) : schema.fallback;
409
+ }
410
+ function getDefault(schema, dataset, config$1) {
411
+ return typeof schema.default == "function" ? schema.default(dataset, config$1) : schema.default;
412
+ }
413
+ function object(entries$1, message$1) {
414
+ return {
415
+ kind: "schema",
416
+ type: "object",
417
+ reference: object,
418
+ expects: "Object",
419
+ async: !1,
420
+ entries: entries$1,
421
+ message: message$1,
422
+ get "~standard"() {
423
+ return _getStandardProps(this);
424
+ },
425
+ "~run"(dataset, config$1) {
426
+ let input = dataset.value;
427
+ if (input && typeof input == "object") {
428
+ dataset.typed = !0, dataset.value = {};
429
+ for (let key in this.entries) {
430
+ let valueSchema = this.entries[key];
431
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
432
+ let value$1 = key in input ? input[key] : getDefault(valueSchema), valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
433
+ if (valueDataset.issues) {
434
+ let pathItem = {
435
+ type: "object",
436
+ origin: "value",
437
+ input,
438
+ key,
439
+ value: value$1
440
+ };
441
+ for (let issue of valueDataset.issues)
442
+ issue.path ? issue.path.unshift(pathItem) : issue.path = [pathItem], dataset.issues?.push(issue);
443
+ if (dataset.issues || (dataset.issues = valueDataset.issues), config$1.abortEarly) {
444
+ dataset.typed = !1;
445
+ break;
446
+ }
447
+ }
448
+ valueDataset.typed || (dataset.typed = !1), dataset.value[key] = valueDataset.value;
449
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = getFallback(valueSchema);
450
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish" && (_addIssue(this, "key", dataset, config$1, {
451
+ input: void 0,
452
+ expected: `"${key}"`,
453
+ path: [{
454
+ type: "object",
455
+ origin: "key",
456
+ input,
457
+ key,
458
+ value: input[key]
459
+ }]
460
+ }), config$1.abortEarly))
461
+ break;
462
+ }
463
+ } else _addIssue(this, "type", dataset, config$1);
464
+ return dataset;
465
+ }
466
+ };
467
+ }
468
+ function optional(wrapped, default_) {
469
+ return {
470
+ kind: "schema",
471
+ type: "optional",
472
+ reference: optional,
473
+ expects: `(${wrapped.expects} | undefined)`,
474
+ async: !1,
475
+ wrapped,
476
+ default: default_,
477
+ get "~standard"() {
478
+ return _getStandardProps(this);
479
+ },
480
+ "~run"(dataset, config$1) {
481
+ return dataset.value === void 0 && (this.default !== void 0 && (dataset.value = getDefault(this, dataset, config$1)), dataset.value === void 0) ? (dataset.typed = !0, dataset) : this.wrapped["~run"](dataset, config$1);
482
+ }
483
+ };
484
+ }
485
+ function record(key, value$1, message$1) {
486
+ return {
487
+ kind: "schema",
488
+ type: "record",
489
+ reference: record,
490
+ expects: "Object",
491
+ async: !1,
492
+ key,
493
+ value: value$1,
494
+ message: message$1,
495
+ get "~standard"() {
496
+ return _getStandardProps(this);
497
+ },
498
+ "~run"(dataset, config$1) {
499
+ let input = dataset.value;
500
+ if (input && typeof input == "object") {
501
+ dataset.typed = !0, dataset.value = {};
502
+ for (let entryKey in input) if (_isValidObjectKey(input, entryKey)) {
503
+ let entryValue = input[entryKey], keyDataset = this.key["~run"]({ value: entryKey }, config$1);
504
+ if (keyDataset.issues) {
505
+ let pathItem = {
506
+ type: "object",
507
+ origin: "key",
508
+ input,
509
+ key: entryKey,
510
+ value: entryValue
511
+ };
512
+ for (let issue of keyDataset.issues)
513
+ issue.path = [pathItem], dataset.issues?.push(issue);
514
+ if (dataset.issues || (dataset.issues = keyDataset.issues), config$1.abortEarly) {
515
+ dataset.typed = !1;
516
+ break;
517
+ }
518
+ }
519
+ let valueDataset = this.value["~run"]({ value: entryValue }, config$1);
520
+ if (valueDataset.issues) {
521
+ let pathItem = {
522
+ type: "object",
523
+ origin: "value",
524
+ input,
525
+ key: entryKey,
526
+ value: entryValue
527
+ };
528
+ for (let issue of valueDataset.issues)
529
+ issue.path ? issue.path.unshift(pathItem) : issue.path = [pathItem], dataset.issues?.push(issue);
530
+ if (dataset.issues || (dataset.issues = valueDataset.issues), config$1.abortEarly) {
531
+ dataset.typed = !1;
532
+ break;
533
+ }
534
+ }
535
+ (!keyDataset.typed || !valueDataset.typed) && (dataset.typed = !1), keyDataset.typed && (dataset.value[keyDataset.value] = valueDataset.value);
536
+ }
537
+ } else _addIssue(this, "type", dataset, config$1);
538
+ return dataset;
539
+ }
540
+ };
541
+ }
542
+ function string(message$1) {
543
+ return {
544
+ kind: "schema",
545
+ type: "string",
546
+ reference: string,
547
+ expects: "string",
548
+ async: !1,
549
+ message: message$1,
550
+ get "~standard"() {
551
+ return _getStandardProps(this);
552
+ },
553
+ "~run"(dataset, config$1) {
554
+ return typeof dataset.value == "string" ? dataset.typed = !0 : _addIssue(this, "type", dataset, config$1), dataset;
555
+ }
556
+ };
557
+ }
558
+ function undefined_(message$1) {
559
+ return {
560
+ kind: "schema",
561
+ type: "undefined",
562
+ reference: undefined_,
563
+ expects: "undefined",
564
+ async: !1,
565
+ message: message$1,
566
+ get "~standard"() {
567
+ return _getStandardProps(this);
568
+ },
569
+ "~run"(dataset, config$1) {
570
+ return dataset.value === void 0 ? dataset.typed = !0 : _addIssue(this, "type", dataset, config$1), dataset;
571
+ }
572
+ };
573
+ }
574
+ function void_(message$1) {
575
+ return {
576
+ kind: "schema",
577
+ type: "void",
578
+ reference: void_,
579
+ expects: "void",
580
+ async: !1,
581
+ message: message$1,
582
+ get "~standard"() {
583
+ return _getStandardProps(this);
584
+ },
585
+ "~run"(dataset, config$1) {
586
+ return dataset.value === void 0 ? dataset.typed = !0 : _addIssue(this, "type", dataset, config$1), dataset;
587
+ }
588
+ };
589
+ }
590
+
591
+ // src/mdx-service/definition.ts
592
+ import { defineService } from "storybook/open-service";
593
+ var mdxInputSchema = object({ id: string() }), mdxErrorSchema = object({
594
+ name: string(),
595
+ message: string()
596
+ }), mdxDocPayloadSchema = object({
597
+ id: string(),
598
+ name: string(),
599
+ path: string(),
600
+ title: string(),
601
+ content: optional(string()),
602
+ summary: optional(string()),
603
+ error: optional(mdxErrorSchema)
604
+ }), mdxPayloadSchema = object({
605
+ id: string(),
606
+ name: string(),
607
+ docs: record(string(), mdxDocPayloadSchema)
608
+ }), mdxOutputSchema = optional(mdxPayloadSchema), mdxServiceDef = defineService({
609
+ id: MDX_SERVICE_ID,
610
+ internal: !0,
611
+ // this service really only ensures that the MDX docs are available in manifests, so there is no need to expose it to the public API
612
+ initialState: { components: {} },
613
+ queries: {
614
+ mdxForComponent: {
615
+ input: mdxInputSchema,
616
+ output: mdxOutputSchema,
617
+ handler: (input, ctx) => ctx.self.state.components[input.id],
618
+ load: async (input, ctx) => {
619
+ await ctx.self.commands._extractMdxForComponent(input);
620
+ },
621
+ staticPath: (input) => mdxQueryStaticPath(input.id)
622
+ },
623
+ mdxForAllComponents: {
624
+ input: void_(),
625
+ output: record(string(), mdxPayloadSchema),
626
+ handler: (_input, ctx) => ctx.self.state.components,
627
+ load: async (_input, ctx) => {
628
+ await ctx.self.commands._extractAllMdx(void 0);
629
+ }
630
+ }
631
+ },
632
+ commands: {
633
+ _extractMdxForComponent: {
634
+ internal: !0,
635
+ input: mdxInputSchema,
636
+ output: mdxOutputSchema
637
+ },
638
+ _extractAllMdx: {
639
+ internal: !0,
640
+ input: undefined_(),
641
+ output: void_()
642
+ }
643
+ }
644
+ });
645
+
646
+ // src/mdx-service/server.ts
647
+ function groupMdxEntriesByComponent(index) {
648
+ return groupBy2(
649
+ Object.values(index.entries).filter(
650
+ (entry) => entry.type === "docs" && ((entry.tags?.includes(Tag2.ATTACHED_MDX) ?? !1) || (entry.tags?.includes(Tag2.UNATTACHED_MDX) ?? !1))
651
+ ),
652
+ (entry) => entry.tags?.includes(Tag2.ATTACHED_MDX) ? getComponentIdFromEntry2(entry) : entry.id
653
+ );
654
+ }
655
+ var defaultMdxProvider = async ({ componentId, entries }) => {
656
+ if (entries.length === 0)
657
+ return;
658
+ let docs2 = await Promise.all(entries.map(createDocsManifestEntry));
659
+ return {
660
+ id: componentId,
661
+ name: componentId,
662
+ docs: Object.fromEntries(docs2.map((doc) => [doc.id, doc]))
663
+ };
664
+ };
665
+ function registerMdxService({
666
+ getIndex,
667
+ provider = defaultMdxProvider
668
+ }) {
669
+ return registerService(mdxServiceDef, {
670
+ queries: {
671
+ mdxForComponent: {
672
+ staticInputs: async () => {
673
+ let index = await getIndex(), grouped = groupMdxEntriesByComponent(index);
674
+ return Object.keys(grouped).map((id) => ({ id }));
675
+ }
676
+ }
677
+ },
678
+ commands: {
679
+ _extractMdxForComponent: {
680
+ handler: async (input, ctx) => {
681
+ let index = await getIndex(), entries = groupMdxEntriesByComponent(index)[input.id] ?? [];
682
+ if (entries.length === 0)
683
+ return;
684
+ let payload = await provider({
685
+ componentId: input.id,
686
+ entries
687
+ });
688
+ if (payload)
689
+ return ctx.self.setState((state) => {
690
+ state.components[input.id] = payload;
691
+ }), payload;
692
+ }
693
+ },
694
+ _extractAllMdx: {
695
+ handler: async (_input, ctx) => {
696
+ let index = await getIndex(), grouped = groupMdxEntriesByComponent(index), extracted = await Promise.all(
697
+ Object.entries(grouped).map(async ([id, entries]) => {
698
+ let payload = await provider({ componentId: id, entries });
699
+ return payload ? [id, payload] : void 0;
700
+ })
701
+ );
702
+ ctx.self.setState((state) => {
703
+ for (let result of extracted) {
704
+ if (!result)
705
+ continue;
706
+ let [id, payload] = result;
707
+ state.components[id] = payload;
708
+ }
709
+ });
710
+ }
711
+ }
712
+ }
713
+ });
714
+ }
715
+
300
716
  // src/preset.ts
301
717
  var getResolvedReact = async (options) => {
302
718
  let resolvedReact2 = await options.presets.apply("resolvedReact", {});
@@ -312,10 +728,12 @@ var getResolvedReact = async (options) => {
312
728
  };
313
729
  };
314
730
  async function webpack(webpackConfig = {}, options) {
315
- let { module = {} } = webpackConfig, { csfPluginOptions = {}, mdxPluginOptions = {} } = options, enrichCsf = await options.presets.apply("experimental_enrichCsf"), rehypeSlug = (await import("./_node-chunks/rehype-slug-JUQPLQ3T.js")).default, rehypeExternalLinks = (await import("./_node-chunks/rehype-external-links-LI2JTKJL.js")).default, mdxLoaderOptions = await options.presets.apply("mdxLoaderOptions", {
731
+ let { module = {} } = webpackConfig, { csfPluginOptions = {}, mdxPluginOptions = {} } = options, enrichCsf = await options.presets.apply("experimental_enrichCsf"), rehypeSlug = (await import("./_node-chunks/rehype-slug-5IVSCV7M.js")).default, rehypeExternalLinks = (await import("./_node-chunks/rehype-external-links-VWGGYBH3.js")).default, mdxLoaderOptions = await options.presets.apply("mdxLoaderOptions", {
316
732
  ...mdxPluginOptions,
317
733
  mdxCompileOptions: {
318
- providerImportSource: import.meta.resolve("@storybook/addon-docs/mdx-react-shim"),
734
+ providerImportSource: fileURLToPath2(
735
+ import.meta.resolve("@storybook/addon-docs/mdx-react-shim")
736
+ ),
319
737
  ...mdxPluginOptions.mdxCompileOptions,
320
738
  rehypePlugins: [
321
739
  ...mdxPluginOptions?.mdxCompileOptions?.rehypePlugins ?? [],
@@ -388,7 +806,7 @@ var docs = (input = {}, options) => {
388
806
  }, addons = [
389
807
  import.meta.resolve("@storybook/react-dom-shim/preset")
390
808
  ], viteFinal = async (config, options) => {
391
- let { plugins = [] } = config, { mdxPlugin } = await import("./_node-chunks/mdx-plugin-AGMUJNOQ.js"), { react, reactDom, mdx } = await getResolvedReact(options), packageDeduplicationPlugin = {
809
+ let { plugins = [] } = config, { mdxPlugin } = await import("./_node-chunks/mdx-plugin-PNWQJL3O.js"), { react, reactDom, mdx } = await getResolvedReact(options), packageDeduplicationPlugin = {
392
810
  name: "storybook:package-deduplication",
393
811
  enforce: "pre",
394
812
  config: () => ({
@@ -411,7 +829,15 @@ var docs = (input = {}, options) => {
411
829
  react: existing?.react ?? resolvePackageDir("react"),
412
830
  reactDom: existing?.reactDom ?? resolvePackageDir("react-dom"),
413
831
  mdx: existing?.mdx ?? fileURLToPath2(import.meta.resolve("@mdx-js/react"))
414
- }), optimizeViteDeps = [
832
+ }), services = async (_value, options) => {
833
+ let features = await options.presets.apply("features");
834
+ if (features?.experimentalDocgenServer && features?.componentsManifest && !options.ignorePreview) {
835
+ let generator = await options.presets.apply("storyIndexGenerator");
836
+ registerMdxService({
837
+ getIndex: () => generator.getIndex()
838
+ });
839
+ }
840
+ }, optimizeViteDeps = [
415
841
  "@storybook/addon-docs",
416
842
  "@storybook/addon-docs/blocks",
417
843
  "@storybook/addon-docs > @mdx-js/react",
@@ -426,6 +852,7 @@ export {
426
852
  manifests as experimental_manifests,
427
853
  optimizeViteDeps,
428
854
  resolvedReact,
855
+ services,
429
856
  viteFinal,
430
857
  webpackX as webpack
431
858
  };
package/dist/preview.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  parameters
3
- } from "./_browser-chunks/chunk-S4QKU6I5.js";
4
- import "./_browser-chunks/chunk-SL3VIQZ3.js";
3
+ } from "./_browser-chunks/chunk-6Z2O5XYJ.js";
4
+ import "./_browser-chunks/chunk-UAWMPV5J.js";
5
5
  export {
6
6
  parameters
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "10.5.0-alpha.0",
3
+ "version": "10.5.0-alpha.10",
4
4
  "description": "Storybook Docs: Document UI components automatically with stories and MDX",
5
5
  "keywords": [
6
6
  "docs",
@@ -87,9 +87,9 @@
87
87
  ],
88
88
  "dependencies": {
89
89
  "@mdx-js/react": "^3.0.0",
90
- "@storybook/csf-plugin": "10.5.0-alpha.0",
90
+ "@storybook/csf-plugin": "10.5.0-alpha.10",
91
91
  "@storybook/icons": "^2.0.2",
92
- "@storybook/react-dom-shim": "10.5.0-alpha.0",
92
+ "@storybook/react-dom-shim": "10.5.0-alpha.10",
93
93
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
94
94
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
95
95
  "ts-dedent": "^2.0.0"
@@ -117,7 +117,7 @@
117
117
  },
118
118
  "peerDependencies": {
119
119
  "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
120
- "storybook": "^10.5.0-alpha.0"
120
+ "storybook": "^10.5.0-alpha.10"
121
121
  },
122
122
  "peerDependenciesMeta": {
123
123
  "@types/react": {
@@ -1,13 +0,0 @@
1
- // src/blocks/controls/helpers.ts
2
- var getControlId = (value, storyId) => {
3
- let base = value.replace(/\s+/g, "-");
4
- return storyId ? `control-${storyId}-${base}` : `control-${base}`;
5
- }, getControlSetterButtonId = (value, storyId) => {
6
- let base = value.replace(/\s+/g, "-");
7
- return storyId ? `set-${storyId}-${base}` : `set-${base}`;
8
- };
9
-
10
- export {
11
- getControlId,
12
- getControlSetterButtonId
13
- };