storybook 10.1.0-beta.3 → 10.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/_node-chunks/{builder-manager-OAF6SRKJ.js → builder-manager-T3A7QLUO.js} +24 -26
  2. package/dist/_node-chunks/{camelcase-UG5ZJHCD.js → camelcase-WMMYRUH4.js} +7 -7
  3. package/dist/_node-chunks/{chunk-WBULWRM7.js → chunk-3MVB5IZX.js} +28 -24
  4. package/dist/_node-chunks/{chunk-N5IE6WWR.js → chunk-5DEFF2GB.js} +7 -7
  5. package/dist/_node-chunks/{chunk-JOOO54RB.js → chunk-67VVNDJJ.js} +6 -6
  6. package/dist/_node-chunks/{chunk-SUILKNPA.js → chunk-C6RLDV2P.js} +8 -8
  7. package/dist/_node-chunks/{chunk-473LXK7O.js → chunk-CM44JL5Z.js} +6 -6
  8. package/dist/_node-chunks/{chunk-XS5QCZP7.js → chunk-CSFSQ2I4.js} +7 -7
  9. package/dist/_node-chunks/{chunk-H6HVK5J2.js → chunk-EFN4RLWH.js} +7 -7
  10. package/dist/_node-chunks/{chunk-WYLXFNIP.js → chunk-EFTR6VSG.js} +9 -9
  11. package/dist/_node-chunks/{chunk-SKFAHEPX.js → chunk-EJPOXNSG.js} +15 -15
  12. package/dist/_node-chunks/{chunk-7WOMK33B.js → chunk-HDMHX5QM.js} +7 -7
  13. package/dist/_node-chunks/{chunk-U24W5IIW.js → chunk-HT32VUX7.js} +7 -7
  14. package/dist/_node-chunks/chunk-IQFN7VY4.js +23 -0
  15. package/dist/_node-chunks/{chunk-RABBUYPA.js → chunk-JYAXWHGH.js} +9 -9
  16. package/dist/_node-chunks/chunk-K7U3BSTR.js +61 -0
  17. package/dist/_node-chunks/{chunk-CRJ7M6EO.js → chunk-KAVR7KJP.js} +285 -280
  18. package/dist/_node-chunks/{chunk-6YYH64IJ.js → chunk-KI6KY2ZN.js} +13 -13
  19. package/dist/_node-chunks/{chunk-Y7VDA7NY.js → chunk-NORFPLB6.js} +7 -7
  20. package/dist/_node-chunks/{chunk-LZ2HPFRB.js → chunk-PMZEJJNX.js} +7 -7
  21. package/dist/_node-chunks/{chunk-NOTIBODG.js → chunk-RSJK2D7X.js} +6 -6
  22. package/dist/_node-chunks/{chunk-UWK6Z4VL.js → chunk-TBYOSPAV.js} +6 -6
  23. package/dist/_node-chunks/{chunk-STYUJSG3.js → chunk-TC7X5DN2.js} +10 -10
  24. package/dist/_node-chunks/{chunk-TUQOGYET.js → chunk-TCLOOFNE.js} +7 -7
  25. package/dist/_node-chunks/{chunk-WSIZMTN2.js → chunk-VN7SAKM4.js} +6 -6
  26. package/dist/_node-chunks/{chunk-745GFLCZ.js → chunk-VW25O2YM.js} +6 -6
  27. package/dist/_node-chunks/{chunk-A5VW7257.js → chunk-WGBDDI6W.js} +642 -639
  28. package/dist/_node-chunks/chunk-YN3C74EA.js +18 -0
  29. package/dist/_node-chunks/{chunk-NKT3R6IH.js → chunk-YTTOTUWC.js} +6 -6
  30. package/dist/_node-chunks/{chunk-Q65ED3UK.js → chunk-YZ3XRP4N.js} +6 -6
  31. package/dist/_node-chunks/{dist-N33YQ3NH.js → dist-L6XLFQOU.js} +9 -9
  32. package/dist/_node-chunks/{globby-5IBS67N3.js → globby-7IXLXFEA.js} +9 -9
  33. package/dist/_node-chunks/{lib-2XH6KQ2B.js → lib-T5L2ZSAG.js} +7 -7
  34. package/dist/_node-chunks/{mdx-N42X6CFJ-3GGSRLVV.js → mdx-N42X6CFJ-GOOKUTSA.js} +8 -8
  35. package/dist/_node-chunks/{p-limit-Z3A7N5MY.js → p-limit-7GKATDEW.js} +7 -7
  36. package/dist/babel/index.js +10 -10
  37. package/dist/bin/core.js +12 -12
  38. package/dist/bin/dispatcher.js +11 -11
  39. package/dist/bin/loader.js +9 -9
  40. package/dist/cli/index.d.ts +1 -2
  41. package/dist/cli/index.js +18 -18
  42. package/dist/common/index.d.ts +553 -560
  43. package/dist/common/index.js +19 -21
  44. package/dist/core-server/index.js +33 -33
  45. package/dist/core-server/presets/common-override-preset.js +9 -9
  46. package/dist/core-server/presets/common-preset.js +25 -25
  47. package/dist/csf-tools/index.js +9 -9
  48. package/dist/manager/globals-runtime.js +1 -1
  49. package/dist/manager/runtime.js +70 -96
  50. package/dist/manager-api/index.d.ts +178 -178
  51. package/dist/manager-api/index.js +1 -1
  52. package/dist/mocking-utils/index.js +8 -8
  53. package/dist/node-logger/index.d.ts +3 -1
  54. package/dist/node-logger/index.js +9 -9
  55. package/dist/server-errors.js +11 -11
  56. package/dist/telemetry/index.js +23 -23
  57. package/dist/types/index.d.ts +1 -1
  58. package/package.json +2 -2
  59. package/dist/_node-chunks/chunk-5N3H43LE.js +0 -23
  60. package/dist/_node-chunks/chunk-DRN5YXX5.js +0 -18
  61. package/dist/_node-chunks/chunk-LJRIVT23.js +0 -61
@@ -1,5 +1,5 @@
1
1
  import * as storybook_internal_types from 'storybook/internal/types';
2
- import { CLIOptions, LoadOptions, BuilderOptions, StorybookConfigRaw, PresetConfig, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, LoadedPreset, Presets, PackageJson, CoreCommon_AddonInfo, SupportedFramework, SupportedRenderer, SupportedBuilder, Options as Options$2, CoreWebpackCompiler, CoreCommon_StorybookInfo, Ref, StorybookConfig, StoriesEntry, NormalizedStoriesSpecifier } from 'storybook/internal/types';
2
+ import { CLIOptions, LoadOptions, BuilderOptions, StorybookConfigRaw, PresetConfig, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, LoadedPreset, Presets, CoreCommon_AddonInfo, SupportedFramework, SupportedRenderer, SupportedBuilder, Options as Options$2, CoreWebpackCompiler, CoreCommon_StorybookInfo, Ref, StorybookConfig, StoriesEntry, NormalizedStoriesSpecifier, PackageJson } from 'storybook/internal/types';
3
3
  export { PackageJson } from 'storybook/internal/types';
4
4
  import { WriteStream } from 'node:fs';
5
5
  import { Buffer } from 'node:buffer';
@@ -172,188 +172,598 @@ type MergeExclusive<FirstType, SecondType> =
172
172
  (Without<FirstType, SecondType> & SecondType) | (Without<SecondType, FirstType> & FirstType) :
173
173
  FirstType | SecondType;
174
174
 
175
- type StdioOption =
176
- | 'pipe'
177
- | 'overlapped'
178
- | 'ipc'
179
- | 'ignore'
180
- | 'inherit'
181
- | Stream
182
- | number
183
- | undefined;
175
+ declare function temporaryDirectory({ prefix }?: {
176
+ prefix?: string | undefined;
177
+ }): Promise<string>;
178
+ type FileOptions = MergeExclusive<{
179
+ /**
180
+ * File extension.
181
+ *
182
+ * Mutually exclusive with the `name` option.
183
+ *
184
+ * _You usually won't need this option. Specify it only when actually needed._
185
+ */
186
+ readonly extension?: string;
187
+ }, {
188
+ /**
189
+ * Filename.
190
+ *
191
+ * Mutually exclusive with the `extension` option.
192
+ *
193
+ * _You usually won't need this option. Specify it only when actually needed._
194
+ */
195
+ readonly name?: string;
196
+ }>;
197
+ declare function temporaryFile({ name, extension }?: FileOptions): Promise<string>;
198
+ declare function parseList(str: string): string[];
199
+ declare function getEnvConfig(program: Record<string, any>, configEnv: Record<string, any>): void;
200
+ /**
201
+ * Given a file name, creates an object with utilities to manage a log file. It creates a temporary
202
+ * log file which you can manage with the returned functions. You can then decide whether to move
203
+ * the log file to the users project, or remove it.
204
+ *
205
+ * @example
206
+ *
207
+ * ```ts
208
+ * const { logStream, moveLogFile, removeLogFile, clearLogFile, readLogFile } =
209
+ * await createLogStream('my-log-file.log');
210
+ *
211
+ * // SCENARIO 1:
212
+ * // you can write custom messages to generate a log file
213
+ * logStream.write('my log message');
214
+ * await moveLogFile();
215
+ *
216
+ * // SCENARIO 2:
217
+ * // or you can pass it to stdio and capture the output of that command
218
+ * try {
219
+ * await executeCommand({
220
+ * command: 'pnpm',
221
+ * args: ['info', packageName, ...args],
222
+ * // do not output to the user, and send stdio and stderr to log file
223
+ * stdio: ['ignore', logStream, logStream],
224
+ * });
225
+ * } catch (err) {
226
+ * // do something with the log file content
227
+ * const output = await readLogFile();
228
+ * // move the log file to the users project
229
+ * await moveLogFile();
230
+ * }
231
+ * // success, no need to keep the log file
232
+ * await removeLogFile();
233
+ * ```
234
+ */
235
+ declare const createLogStream: (logFileName?: string) => Promise<{
236
+ moveLogFile: () => Promise<void>;
237
+ removeLogFile: () => Promise<void>;
238
+ clearLogFile: () => Promise<void>;
239
+ readLogFile: () => Promise<string>;
240
+ logStream: WriteStream;
241
+ }>;
242
+ declare const isCorePackage: (pkg: string) => boolean;
243
+ declare const isSatelliteAddon: (pkg: string) => boolean;
184
244
 
185
- type EncodingOption =
186
- | 'utf8'
187
- // eslint-disable-next-line unicorn/text-encoding-identifier-case
188
- | 'utf-8'
189
- | 'utf16le'
190
- | 'utf-16le'
191
- | 'ucs2'
192
- | 'ucs-2'
193
- | 'latin1'
194
- | 'binary'
195
- | 'ascii'
196
- | 'hex'
197
- | 'base64'
198
- | 'base64url'
199
- | 'buffer'
200
- | null
201
- | undefined;
202
- type DefaultEncodingOption = 'utf8';
245
+ interface Options$1 {
246
+ before: CoreCommon_AddonInfo;
247
+ after: CoreCommon_AddonInfo;
248
+ configFile: string;
249
+ getConfig: (path: string) => any;
250
+ }
251
+ declare const checkAddonOrder: ({ before, after, configFile, getConfig }: Options$1) => Promise<void>;
203
252
 
204
- type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {
205
- /**
206
- Kill the spawned process when the parent process exits unless either:
207
- - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
208
- - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
253
+ declare function loadEnvs(options?: {
254
+ production?: boolean;
255
+ }): Promise<{
256
+ stringified: Record<string, string>;
257
+ raw: Record<string, string>;
258
+ }>;
259
+ declare const stringifyEnvs: (raw: Record<string, string>) => Record<string, string>;
260
+ declare const stringifyProcessEnvs: (raw: Record<string, string>) => Record<string, string>;
261
+ declare const optionalEnvToBoolean: (input: string | undefined) => boolean | undefined;
262
+ /**
263
+ * Consistently determine if we are in a CI environment
264
+ *
265
+ * Doing Boolean(process.env.CI) or !process.env.CI is not enough, because users might set CI=false
266
+ * or CI=0, which would be truthy, and thus return true in those cases.
267
+ */
268
+ declare function isCI(): boolean | undefined;
209
269
 
210
- @default true
211
- */
212
- readonly cleanup?: boolean;
270
+ declare const commonGlobOptions: (glob: string) => {
271
+ ignore?: undefined;
272
+ } | {
273
+ ignore: string[];
274
+ };
213
275
 
214
- /**
215
- Prefer locally installed binaries when looking for a binary to execute.
276
+ declare const frameworkToRenderer: Record<SupportedFramework | SupportedRenderer, SupportedRenderer>;
277
+ declare const frameworkToBuilder: Record<SupportedFramework, SupportedBuilder>;
216
278
 
217
- If you `$ npm install foo`, you can then `execa('foo')`.
279
+ /**
280
+ * Builder options can be specified in `core.builder.options` or `framework.options.builder`.
281
+ * Preference is given here to `framework.options.builder` if both are specified.
282
+ */
283
+ declare function getBuilderOptions<T extends Record<string, any>>(options: Options$2): Promise<T | Record<string, never>>;
218
284
 
219
- @default `true` with `$`, `false` otherwise
220
- */
221
- readonly preferLocal?: boolean;
285
+ /** Framework can be a string or an object. This utility always returns the string name. */
286
+ declare function getFrameworkName(options: Options$2): Promise<string>;
287
+ /**
288
+ * Extracts the proper framework name from the given framework field. The framework field can be the
289
+ * framework package name or a path to the framework package.
290
+ *
291
+ * @example
292
+ *
293
+ * ```ts
294
+ * extractFrameworkPackageName('/path/to/@storybook/angular'); // => '@storybook/angular'
295
+ * extractFrameworkPackageName('@third-party/framework'); // => '@third-party/framework'
296
+ * ```
297
+ */
298
+ declare const extractFrameworkPackageName: (framework: string) => string;
222
299
 
223
- /**
224
- Preferred path to find locally installed binaries in (use with `preferLocal`).
300
+ /**
301
+ * Render is set as a string on core. It must be set by the framework It falls back to the framework
302
+ * name if not set
303
+ */
304
+ declare function getRendererName(options: Options$2): Promise<string>;
305
+ /**
306
+ * Extracts the proper renderer name from the given framework name.
307
+ *
308
+ * @example
309
+ *
310
+ * ```ts
311
+ * extractRenderer('@storybook/react'); // => 'react'
312
+ * extractRenderer('@storybook/angular'); // => 'angular'
313
+ * extractRenderer('@third-party/framework'); // => null
314
+ * ```
315
+ *
316
+ * @param frameworkName The name of the framework.
317
+ * @returns The name of the renderer.
318
+ */
319
+ declare function extractRenderer(frameworkName: string): Promise<storybook_internal_types.SupportedRenderer | null>;
225
320
 
226
- @default process.cwd()
227
- */
228
- readonly localDir?: string | URL;
321
+ declare function getStorybookConfiguration(storybookScript: string, shortName: string, longName: string): string | null;
229
322
 
230
- /**
231
- Path to the Node.js executable to use in child processes.
323
+ declare const rendererPackages: Record<string, SupportedRenderer>;
324
+ declare const frameworkPackages: Record<string, SupportedFramework>;
325
+ declare const builderPackages: Record<string, SupportedBuilder>;
326
+ declare const compilerPackages: Record<string, CoreWebpackCompiler>;
327
+ declare const findConfigFile: (prefix: string, configDir: string) => string | null;
328
+ declare const getConfigInfo: (configDir?: string) => {
329
+ configDir: string;
330
+ mainConfigPath: string | null;
331
+ previewConfigPath: string | null;
332
+ managerConfigPath: string | null;
333
+ };
334
+ declare const getStorybookInfo: (configDir?: string, cwd?: string) => Promise<CoreCommon_StorybookInfo>;
232
335
 
233
- This can be either an absolute path or a path relative to the `cwd` option.
336
+ declare const getAutoRefs: (options: Options$2) => Promise<Record<string, Ref>>;
337
+ declare function getRefs(options: Options$2): Promise<Record<string, Ref>>;
234
338
 
235
- Requires `preferLocal` to be `true`.
339
+ declare function globToRegexp(glob: string): RegExp;
236
340
 
237
- For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.
341
+ declare class HandledError extends Error {
342
+ handled: boolean;
343
+ constructor(error: unknown);
344
+ }
238
345
 
239
- @default process.execPath
240
- */
241
- readonly execPath?: string;
346
+ /**
347
+ * Return a string corresponding to template filled with bindings using following pattern: For each
348
+ * (key, value) of `bindings` replace, in template, `{{key}}` by escaped version of `value`
349
+ *
350
+ * @param template {String} Template with `{{binding}}`
351
+ * @param bindings {Object} key-value object use to fill the template, `{{key}}` will be replaced by
352
+ * `escaped(value)`
353
+ * @returns {String} Filled template
354
+ */
355
+ declare const interpolate: (template: string, bindings: Record<string, string>) => string;
242
356
 
243
- /**
244
- Buffer the output from the spawned process. When set to `false`, you must read the output of `stdout` and `stderr` (or `all` if the `all` option is `true`). Otherwise the returned promise will not be resolved/rejected.
357
+ interface PackageMeta {
358
+ name: string;
359
+ version: string;
360
+ [key: string]: any;
361
+ }
245
362
 
246
- If the spawned process fails, `error.stdout`, `error.stderr`, and `error.all` will contain the buffered data.
363
+ interface ToString {
364
+ toString(): string;
365
+ }
247
366
 
248
- @default true
249
- */
250
- readonly buffer?: boolean;
367
+ type StringOrToString = string | ToString;
251
368
 
252
- /**
253
- Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
369
+ /**
370
+ * Callback invoked when resolving asynchronously
371
+ *
372
+ * @param error
373
+ * @param resolved Absolute path to resolved identifier
374
+ */
375
+ type resolveCallback = (err: Error | null, resolved?: string, pkg?: PackageMeta) => void;
254
376
 
255
- @default `inherit` with `$`, `pipe` otherwise
256
- */
257
- readonly stdin?: StdioOption;
377
+ /**
378
+ * Callback invoked when checking if a file or directory exists
379
+ *
380
+ * @param error
381
+ * @param exists If the given file or directory exists
382
+ */
383
+ type existsCallback = (err: Error | null, isFile?: boolean) => void;
258
384
 
259
- /**
260
- Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
261
-
262
- @default 'pipe'
263
- */
264
- readonly stdout?: StdioOption;
385
+ /**
386
+ * Callback invoked when reading a file
387
+ *
388
+ * @param error
389
+ * @param isFile If the given file exists
390
+ */
391
+ type readFileCallback = (err: Error | null, file?: StringOrToString) => void;
265
392
 
266
- /**
267
- Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
393
+ /**
394
+ * Callback invoked when resolving a potential symlink
395
+ *
396
+ * @param error
397
+ * @param resolved Absolute path to the resolved file
398
+ */
399
+ type realpathCallback = (err: Error | null, resolved?: string) => void;
268
400
 
269
- @default 'pipe'
270
- */
271
- readonly stderr?: StdioOption;
401
+ /**
402
+ * Callback invoked when reading and parsing a package.json file
403
+ *
404
+ * @param error
405
+ * @param resolved Absolute path to the resolved file
406
+ */
407
+ type readPackageCallback = (err: Error | null, package?: Record<string, unknown>) => void;
272
408
 
273
- /**
274
- Setting this to `false` resolves the promise with the error instead of rejecting it.
409
+ /**
410
+ * Synchronously resolve the module path string id, returning the result and throwing an error when id can't be resolved.
411
+ *
412
+ * @param id Identifier to resolve
413
+ * @param options Options to use for resolving, optional.
414
+ */
415
+ declare function resolveSync(id: string, opts?: resolve.SyncOpts): string;
275
416
 
276
- @default true
277
- */
278
- readonly reject?: boolean;
417
+ /**
418
+ * Return whether a package is in core
419
+ */
420
+ declare function resolveIsCore(id: string): boolean | undefined;
279
421
 
280
- /**
281
- Add an `.all` property on the promise and the resolved value. The property contains the output of the process with `stdout` and `stderr` interleaved.
422
+ // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
423
+ type JSONValue = string | number | boolean | JSONObject | JSONArray;
424
+ interface JSONObject {
425
+ [x: string]: JSONValue;
426
+ }
427
+ interface JSONArray extends Array<JSONValue> {}
282
428
 
283
- @default false
284
- */
285
- readonly all?: boolean;
429
+ /**
430
+ * Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
431
+ *
432
+ * @param id Identifier to resolve
433
+ * @param callback
434
+ */
435
+ declare function resolve(id: string, cb: resolveCallback): void;
286
436
 
287
- /**
288
- Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
437
+ /**
438
+ * Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
439
+ *
440
+ * @param id Identifier to resolve
441
+ * @param options Options to use for resolving, optional.
442
+ * @param callback
443
+ */
444
+ declare function resolve(id: string, opts: resolve.AsyncOpts, cb: resolveCallback): void;
289
445
 
290
- @default true
291
- */
292
- readonly stripFinalNewline?: boolean;
446
+ declare namespace resolve {
447
+ export type PackageJSON = JSONObject;
293
448
 
294
- /**
295
- Set to `false` if you don't want to extend the environment variables when providing the `env` property.
449
+ interface Opts {
450
+ /** directory to begin resolving from (defaults to __dirname) */
451
+ basedir?: string | undefined;
452
+ /** package.json data applicable to the module being loaded */
453
+ package?: any;
454
+ /** set to false to exclude node core modules (e.g. fs) from the search */
455
+ includeCoreModules?: boolean | undefined;
456
+ /** array of file extensions to search in order (defaults to ['.js']) */
457
+ extensions?: string | readonly string[] | undefined;
458
+ /** transform the parsed package.json contents before looking at the "main" field */
459
+ packageFilter?: ((pkg: PackageJSON, pkgFile: string, dir: string) => PackageJSON) | undefined;
460
+ /** transform a path within a package */
461
+ pathFilter?: ((pkg: PackageJSON, path: string, relativePath: string) => string) | undefined;
462
+ /** require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this) */
463
+ paths?: string | readonly string[] | undefined;
464
+ /** return the list of candidate paths where the packages sources may be found (probably don't use this) */
465
+ packageIterator?:
466
+ | ((request: string, start: string, getPackageCandidates: () => string[], opts: Opts) => string[])
467
+ | undefined;
468
+ /** directory (or directories) in which to recursively look for modules. (default to 'node_modules') */
469
+ moduleDirectory?: string | readonly string[] | undefined;
470
+ /**
471
+ * if true, doesn't resolve `basedir` to real path before resolving.
472
+ * This is the way Node resolves dependencies when executed with the --preserve-symlinks flag.
473
+ *
474
+ * Note: this property is currently true by default but it will be changed to false in the next major version because Node's resolution
475
+ * algorithm does not preserve symlinks by default.
476
+ */
477
+ preserveSymlinks?: boolean | undefined;
478
+ }
296
479
 
297
- @default true
298
- */
299
- readonly extendEnv?: boolean;
480
+ interface BaseAsyncOpts extends Opts {
481
+ /** function to asynchronously test whether a file exists */
482
+ isFile?: ((file: string, cb: existsCallback) => void) | undefined;
483
+ /** function to asynchronously test whether a directory exists */
484
+ isDirectory?: ((directory: string, cb: existsCallback) => void) | undefined;
485
+ /** function to asynchronously resolve a potential symlink to its real path */
486
+ realpath?: ((file: string, cb: realpathCallback) => void) | undefined;
487
+ }
300
488
 
301
- /**
302
- Current working directory of the child process.
489
+ export type AsyncOpts =
490
+ & BaseAsyncOpts
491
+ & ({
492
+ /** how to read files asynchronously (defaults to fs.readFile) */
493
+ readFile?: ((file: string, cb: readFileCallback) => void) | undefined;
494
+ /** function to asynchronously read and parse a package.json file */
495
+ readPackage?: never | undefined;
496
+ } | {
497
+ /** how to read files asynchronously (defaults to fs.readFile) */
498
+ readFile?: never | undefined;
499
+ /** function to asynchronously read and parse a package.json file */
500
+ readPackage?:
501
+ | ((
502
+ readFile: (file: string, cb: readFileCallback) => void,
503
+ pkgfile: string,
504
+ cb: readPackageCallback,
505
+ ) => void)
506
+ | undefined;
507
+ });
303
508
 
304
- @default process.cwd()
305
- */
306
- readonly cwd?: string | URL;
509
+ interface BaseSyncOpts extends Opts {
510
+ /** function to synchronously test whether a file exists */
511
+ isFile?: ((file: string) => boolean) | undefined;
512
+ /** function to synchronously test whether a directory exists */
513
+ isDirectory?: ((directory: string) => boolean) | undefined;
514
+ /** function to synchronously resolve a potential symlink to its real path */
515
+ realpathSync?: ((file: string) => string) | undefined;
516
+ }
307
517
 
308
- /**
309
- Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.
518
+ export type SyncOpts =
519
+ & BaseSyncOpts
520
+ & ({
521
+ /** how to read files synchronously (defaults to fs.readFileSync) */
522
+ readFileSync?: ((file: string) => StringOrToString) | undefined;
523
+ /** function to synchronously read and parse a package.json file */
524
+ readPackageSync?: never | undefined;
525
+ } | {
526
+ /** how to read files synchronously (defaults to fs.readFileSync) */
527
+ readFileSync?: never | undefined;
528
+ /** function to synchronously read and parse a package.json file */
529
+ readPackageSync?:
530
+ | ((
531
+ readFileSync: (file: string) => StringOrToString,
532
+ pkgfile: string,
533
+ ) => Record<string, unknown> | undefined)
534
+ | undefined;
535
+ });
310
536
 
311
- @default process.env
312
- */
313
- readonly env?: NodeJS.ProcessEnv;
537
+ export var sync: typeof resolveSync;
538
+ export var isCore: typeof resolveIsCore;
539
+ }
314
540
 
315
- /**
316
- Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.
317
- */
318
- readonly argv0?: string;
541
+ declare const supportedExtensions: readonly [".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts", ".mtsx", ".cjs", ".cts", ".ctsx"];
542
+ declare function getInterpretedFile(pathToFile: string): string | undefined;
543
+ declare function resolveImport(id: string, options: resolve.SyncOpts): string;
319
544
 
320
- /**
321
- Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
545
+ declare function serverRequire(filePath: string | string[]): Promise<any> | null;
322
546
 
323
- @default 'pipe'
324
- */
325
- readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];
547
+ declare function loadMainConfig({ configDir, cwd, skipCache, }: {
548
+ configDir: string;
549
+ cwd?: string;
550
+ skipCache?: boolean;
551
+ }): Promise<StorybookConfig>;
326
552
 
327
- /**
328
- Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:
329
- - `json`: Uses `JSON.stringify()` and `JSON.parse()`.
330
- - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
553
+ declare function loadManagerOrAddonsFile({ configDir }: {
554
+ configDir: string;
555
+ }): string | undefined;
331
556
 
332
- [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
557
+ declare function loadPreviewOrConfigFile({ configDir }: {
558
+ configDir: string;
559
+ }): string | undefined;
333
560
 
334
- @default 'json'
335
- */
336
- readonly serialization?: 'json' | 'advanced';
561
+ declare function logConfig(caption: unknown, config: unknown): void;
337
562
 
338
- /**
339
- Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
563
+ declare const DEFAULT_FILES_PATTERN = "**/*.@(mdx|stories.@(js|jsx|mjs|ts|tsx))";
564
+ declare const getDirectoryFromWorkingDir: ({ configDir, workingDir, directory, }: NormalizeOptions & {
565
+ directory: string;
566
+ }) => string;
567
+ declare const normalizeStoriesEntry: (entry: StoriesEntry, { configDir, workingDir, defaultFilesPattern }: NormalizeOptions) => NormalizedStoriesSpecifier;
568
+ interface NormalizeOptions {
569
+ configDir: string;
570
+ workingDir: string;
571
+ defaultFilesPattern?: string;
572
+ }
573
+ declare const normalizeStories: (entries: StoriesEntry[], options: NormalizeOptions) => NormalizedStoriesSpecifier[];
340
574
 
341
- @default false
342
- */
343
- readonly detached?: boolean;
575
+ declare const getProjectRoot: () => string;
576
+ declare const invalidateProjectRootCache: () => void;
577
+ /** Finds files in the directory tree up to the project root */
578
+ declare const findFilesUp: (matchers: string[], baseDir?: string) => string[];
579
+ declare const nodePathsToArray: (nodePath: string) => string[];
580
+ /** Ensures that a path starts with `./` or `../`, or is entirely `.` or `..` */
581
+ declare function normalizeStoryPath(filename: string): string;
344
582
 
345
- /**
346
- Sets the user identity of the process.
347
- */
348
- readonly uid?: number;
583
+ declare function readTemplate(filename: string): Promise<string>;
349
584
 
350
- /**
351
- Sets the group identity of the process.
352
- */
353
- readonly gid?: number;
585
+ type StdioOption =
586
+ | 'pipe'
587
+ | 'overlapped'
588
+ | 'ipc'
589
+ | 'ignore'
590
+ | 'inherit'
591
+ | Stream
592
+ | number
593
+ | undefined;
354
594
 
355
- /**
356
- If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
595
+ type EncodingOption =
596
+ | 'utf8'
597
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case
598
+ | 'utf-8'
599
+ | 'utf16le'
600
+ | 'utf-16le'
601
+ | 'ucs2'
602
+ | 'ucs-2'
603
+ | 'latin1'
604
+ | 'binary'
605
+ | 'ascii'
606
+ | 'hex'
607
+ | 'base64'
608
+ | 'base64url'
609
+ | 'buffer'
610
+ | null
611
+ | undefined;
612
+ type DefaultEncodingOption = 'utf8';
613
+
614
+ type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {
615
+ /**
616
+ Kill the spawned process when the parent process exits unless either:
617
+ - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
618
+ - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
619
+
620
+ @default true
621
+ */
622
+ readonly cleanup?: boolean;
623
+
624
+ /**
625
+ Prefer locally installed binaries when looking for a binary to execute.
626
+
627
+ If you `$ npm install foo`, you can then `execa('foo')`.
628
+
629
+ @default `true` with `$`, `false` otherwise
630
+ */
631
+ readonly preferLocal?: boolean;
632
+
633
+ /**
634
+ Preferred path to find locally installed binaries in (use with `preferLocal`).
635
+
636
+ @default process.cwd()
637
+ */
638
+ readonly localDir?: string | URL;
639
+
640
+ /**
641
+ Path to the Node.js executable to use in child processes.
642
+
643
+ This can be either an absolute path or a path relative to the `cwd` option.
644
+
645
+ Requires `preferLocal` to be `true`.
646
+
647
+ For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.
648
+
649
+ @default process.execPath
650
+ */
651
+ readonly execPath?: string;
652
+
653
+ /**
654
+ Buffer the output from the spawned process. When set to `false`, you must read the output of `stdout` and `stderr` (or `all` if the `all` option is `true`). Otherwise the returned promise will not be resolved/rejected.
655
+
656
+ If the spawned process fails, `error.stdout`, `error.stderr`, and `error.all` will contain the buffered data.
657
+
658
+ @default true
659
+ */
660
+ readonly buffer?: boolean;
661
+
662
+ /**
663
+ Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
664
+
665
+ @default `inherit` with `$`, `pipe` otherwise
666
+ */
667
+ readonly stdin?: StdioOption;
668
+
669
+ /**
670
+ Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
671
+
672
+ @default 'pipe'
673
+ */
674
+ readonly stdout?: StdioOption;
675
+
676
+ /**
677
+ Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
678
+
679
+ @default 'pipe'
680
+ */
681
+ readonly stderr?: StdioOption;
682
+
683
+ /**
684
+ Setting this to `false` resolves the promise with the error instead of rejecting it.
685
+
686
+ @default true
687
+ */
688
+ readonly reject?: boolean;
689
+
690
+ /**
691
+ Add an `.all` property on the promise and the resolved value. The property contains the output of the process with `stdout` and `stderr` interleaved.
692
+
693
+ @default false
694
+ */
695
+ readonly all?: boolean;
696
+
697
+ /**
698
+ Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
699
+
700
+ @default true
701
+ */
702
+ readonly stripFinalNewline?: boolean;
703
+
704
+ /**
705
+ Set to `false` if you don't want to extend the environment variables when providing the `env` property.
706
+
707
+ @default true
708
+ */
709
+ readonly extendEnv?: boolean;
710
+
711
+ /**
712
+ Current working directory of the child process.
713
+
714
+ @default process.cwd()
715
+ */
716
+ readonly cwd?: string | URL;
717
+
718
+ /**
719
+ Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.
720
+
721
+ @default process.env
722
+ */
723
+ readonly env?: NodeJS.ProcessEnv;
724
+
725
+ /**
726
+ Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.
727
+ */
728
+ readonly argv0?: string;
729
+
730
+ /**
731
+ Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
732
+
733
+ @default 'pipe'
734
+ */
735
+ readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];
736
+
737
+ /**
738
+ Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:
739
+ - `json`: Uses `JSON.stringify()` and `JSON.parse()`.
740
+ - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
741
+
742
+ [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
743
+
744
+ @default 'json'
745
+ */
746
+ readonly serialization?: 'json' | 'advanced';
747
+
748
+ /**
749
+ Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
750
+
751
+ @default false
752
+ */
753
+ readonly detached?: boolean;
754
+
755
+ /**
756
+ Sets the user identity of the process.
757
+ */
758
+ readonly uid?: number;
759
+
760
+ /**
761
+ Sets the group identity of the process.
762
+ */
763
+ readonly gid?: number;
764
+
765
+ /**
766
+ If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
357
767
 
358
768
  We recommend against using this option since it is:
359
769
  - not cross-platform, encouraging shell-specific syntax.
@@ -442,7 +852,7 @@ type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption>
442
852
  readonly verbose?: boolean;
443
853
  };
444
854
 
445
- type Options$1<EncodingType extends EncodingOption = DefaultEncodingOption> = {
855
+ type Options<EncodingType extends EncodingOption = DefaultEncodingOption> = {
446
856
  /**
447
857
  Write some input to the `stdin` of your binary.
448
858
 
@@ -472,7 +882,7 @@ type NodeOptions<EncodingType extends EncodingOption = DefaultEncodingOption> =
472
882
  @default process.execArgv
473
883
  */
474
884
  readonly nodeOptions?: string[];
475
- } & Options$1<EncodingType>;
885
+ } & Options<EncodingType>;
476
886
 
477
887
  type StdoutStderrAll = string | Buffer | undefined;
478
888
 
@@ -757,7 +1167,7 @@ declare abstract class JsPackageManager {
757
1167
  /** Runs arbitrary package scripts. */
758
1168
  abstract getRunCommand(command: string): string;
759
1169
  /** Get the package.json file for a given module. */
760
- abstract getModulePackageJSON(packageName: string): Promise<PackageJson | null>;
1170
+ abstract getModulePackageJSON(packageName: string, cwd?: string): Promise<PackageJson | null>;
761
1171
  isStorybookInMonorepo(): boolean;
762
1172
  installDependencies(options?: {
763
1173
  force?: boolean;
@@ -941,423 +1351,6 @@ declare class JsPackageManagerFactory {
941
1351
  private static inferPackageManagerFromUserAgent;
942
1352
  }
943
1353
 
944
- declare function temporaryDirectory({ prefix }?: {
945
- prefix?: string | undefined;
946
- }): Promise<string>;
947
- type FileOptions = MergeExclusive<{
948
- /**
949
- * File extension.
950
- *
951
- * Mutually exclusive with the `name` option.
952
- *
953
- * _You usually won't need this option. Specify it only when actually needed._
954
- */
955
- readonly extension?: string;
956
- }, {
957
- /**
958
- * Filename.
959
- *
960
- * Mutually exclusive with the `extension` option.
961
- *
962
- * _You usually won't need this option. Specify it only when actually needed._
963
- */
964
- readonly name?: string;
965
- }>;
966
- declare function temporaryFile({ name, extension }?: FileOptions): Promise<string>;
967
- declare function parseList(str: string): string[];
968
- /**
969
- * Given a package manager, returns the coerced version of Storybook. It tries to find renderer
970
- * packages in the project and returns the coerced version of the first one found. Example: If
971
- *
972
- * @storybook/react version 8.0.0-alpha.14 is installed, it returns the coerced version 8.0.0
973
- */
974
- declare function getCoercedStorybookVersion(packageManager: JsPackageManager): Promise<string>;
975
- declare function getEnvConfig(program: Record<string, any>, configEnv: Record<string, any>): void;
976
- /**
977
- * Given a file name, creates an object with utilities to manage a log file. It creates a temporary
978
- * log file which you can manage with the returned functions. You can then decide whether to move
979
- * the log file to the users project, or remove it.
980
- *
981
- * @example
982
- *
983
- * ```ts
984
- * const { logStream, moveLogFile, removeLogFile, clearLogFile, readLogFile } =
985
- * await createLogStream('my-log-file.log');
986
- *
987
- * // SCENARIO 1:
988
- * // you can write custom messages to generate a log file
989
- * logStream.write('my log message');
990
- * await moveLogFile();
991
- *
992
- * // SCENARIO 2:
993
- * // or you can pass it to stdio and capture the output of that command
994
- * try {
995
- * await executeCommand({
996
- * command: 'pnpm',
997
- * args: ['info', packageName, ...args],
998
- * // do not output to the user, and send stdio and stderr to log file
999
- * stdio: ['ignore', logStream, logStream],
1000
- * });
1001
- * } catch (err) {
1002
- * // do something with the log file content
1003
- * const output = await readLogFile();
1004
- * // move the log file to the users project
1005
- * await moveLogFile();
1006
- * }
1007
- * // success, no need to keep the log file
1008
- * await removeLogFile();
1009
- * ```
1010
- */
1011
- declare const createLogStream: (logFileName?: string) => Promise<{
1012
- moveLogFile: () => Promise<void>;
1013
- removeLogFile: () => Promise<void>;
1014
- clearLogFile: () => Promise<void>;
1015
- readLogFile: () => Promise<string>;
1016
- logStream: WriteStream;
1017
- }>;
1018
- declare const isCorePackage: (pkg: string) => boolean;
1019
- declare const isSatelliteAddon: (pkg: string) => boolean;
1020
-
1021
- interface Options {
1022
- before: CoreCommon_AddonInfo;
1023
- after: CoreCommon_AddonInfo;
1024
- configFile: string;
1025
- getConfig: (path: string) => any;
1026
- }
1027
- declare const checkAddonOrder: ({ before, after, configFile, getConfig }: Options) => Promise<void>;
1028
-
1029
- declare function loadEnvs(options?: {
1030
- production?: boolean;
1031
- }): Promise<{
1032
- stringified: Record<string, string>;
1033
- raw: Record<string, string>;
1034
- }>;
1035
- declare const stringifyEnvs: (raw: Record<string, string>) => Record<string, string>;
1036
- declare const stringifyProcessEnvs: (raw: Record<string, string>) => Record<string, string>;
1037
- declare const optionalEnvToBoolean: (input: string | undefined) => boolean | undefined;
1038
- /**
1039
- * Consistently determine if we are in a CI environment
1040
- *
1041
- * Doing Boolean(process.env.CI) or !process.env.CI is not enough, because users might set CI=false
1042
- * or CI=0, which would be truthy, and thus return true in those cases.
1043
- */
1044
- declare function isCI(): boolean | undefined;
1045
-
1046
- declare const commonGlobOptions: (glob: string) => {
1047
- ignore?: undefined;
1048
- } | {
1049
- ignore: string[];
1050
- };
1051
-
1052
- declare const frameworkToRenderer: Record<SupportedFramework | SupportedRenderer, SupportedRenderer>;
1053
- declare const frameworkToBuilder: Record<SupportedFramework, SupportedBuilder>;
1054
-
1055
- /**
1056
- * Builder options can be specified in `core.builder.options` or `framework.options.builder`.
1057
- * Preference is given here to `framework.options.builder` if both are specified.
1058
- */
1059
- declare function getBuilderOptions<T extends Record<string, any>>(options: Options$2): Promise<T | Record<string, never>>;
1060
-
1061
- /** Framework can be a string or an object. This utility always returns the string name. */
1062
- declare function getFrameworkName(options: Options$2): Promise<string>;
1063
- /**
1064
- * Extracts the proper framework name from the given framework field. The framework field can be the
1065
- * framework package name or a path to the framework package.
1066
- *
1067
- * @example
1068
- *
1069
- * ```ts
1070
- * extractFrameworkPackageName('/path/to/@storybook/angular'); // => '@storybook/angular'
1071
- * extractFrameworkPackageName('@third-party/framework'); // => '@third-party/framework'
1072
- * ```
1073
- */
1074
- declare const extractFrameworkPackageName: (framework: string) => string;
1075
-
1076
- /**
1077
- * Render is set as a string on core. It must be set by the framework It falls back to the framework
1078
- * name if not set
1079
- */
1080
- declare function getRendererName(options: Options$2): Promise<string>;
1081
- /**
1082
- * Extracts the proper renderer name from the given framework name.
1083
- *
1084
- * @example
1085
- *
1086
- * ```ts
1087
- * extractRenderer('@storybook/react'); // => 'react'
1088
- * extractRenderer('@storybook/angular'); // => 'angular'
1089
- * extractRenderer('@third-party/framework'); // => null
1090
- * ```
1091
- *
1092
- * @param frameworkName The name of the framework.
1093
- * @returns The name of the renderer.
1094
- */
1095
- declare function extractRenderer(frameworkName: string): Promise<storybook_internal_types.SupportedRenderer | null>;
1096
-
1097
- declare function getStorybookConfiguration(storybookScript: string, shortName: string, longName: string): string | null;
1098
-
1099
- declare const rendererPackages: Record<string, SupportedRenderer>;
1100
- declare const frameworkPackages: Record<string, SupportedFramework>;
1101
- declare const builderPackages: Record<string, SupportedBuilder>;
1102
- declare const compilerPackages: Record<string, CoreWebpackCompiler>;
1103
- declare const findConfigFile: (prefix: string, configDir: string) => string | null;
1104
- declare const getConfigInfo: (configDir?: string) => {
1105
- configDir: string;
1106
- mainConfigPath: string | null;
1107
- previewConfigPath: string | null;
1108
- managerConfigPath: string | null;
1109
- };
1110
- declare const getStorybookInfo: (configDir?: string, cwd?: string) => Promise<CoreCommon_StorybookInfo>;
1111
-
1112
- declare const getAutoRefs: (options: Options$2) => Promise<Record<string, Ref>>;
1113
- declare function getRefs(options: Options$2): Promise<Record<string, Ref>>;
1114
-
1115
- declare function globToRegexp(glob: string): RegExp;
1116
-
1117
- declare class HandledError extends Error {
1118
- handled: boolean;
1119
- constructor(error: unknown);
1120
- }
1121
-
1122
- /**
1123
- * Return a string corresponding to template filled with bindings using following pattern: For each
1124
- * (key, value) of `bindings` replace, in template, `{{key}}` by escaped version of `value`
1125
- *
1126
- * @param template {String} Template with `{{binding}}`
1127
- * @param bindings {Object} key-value object use to fill the template, `{{key}}` will be replaced by
1128
- * `escaped(value)`
1129
- * @returns {String} Filled template
1130
- */
1131
- declare const interpolate: (template: string, bindings: Record<string, string>) => string;
1132
-
1133
- interface PackageMeta {
1134
- name: string;
1135
- version: string;
1136
- [key: string]: any;
1137
- }
1138
-
1139
- interface ToString {
1140
- toString(): string;
1141
- }
1142
-
1143
- type StringOrToString = string | ToString;
1144
-
1145
- /**
1146
- * Callback invoked when resolving asynchronously
1147
- *
1148
- * @param error
1149
- * @param resolved Absolute path to resolved identifier
1150
- */
1151
- type resolveCallback = (err: Error | null, resolved?: string, pkg?: PackageMeta) => void;
1152
-
1153
- /**
1154
- * Callback invoked when checking if a file or directory exists
1155
- *
1156
- * @param error
1157
- * @param exists If the given file or directory exists
1158
- */
1159
- type existsCallback = (err: Error | null, isFile?: boolean) => void;
1160
-
1161
- /**
1162
- * Callback invoked when reading a file
1163
- *
1164
- * @param error
1165
- * @param isFile If the given file exists
1166
- */
1167
- type readFileCallback = (err: Error | null, file?: StringOrToString) => void;
1168
-
1169
- /**
1170
- * Callback invoked when resolving a potential symlink
1171
- *
1172
- * @param error
1173
- * @param resolved Absolute path to the resolved file
1174
- */
1175
- type realpathCallback = (err: Error | null, resolved?: string) => void;
1176
-
1177
- /**
1178
- * Callback invoked when reading and parsing a package.json file
1179
- *
1180
- * @param error
1181
- * @param resolved Absolute path to the resolved file
1182
- */
1183
- type readPackageCallback = (err: Error | null, package?: Record<string, unknown>) => void;
1184
-
1185
- /**
1186
- * Synchronously resolve the module path string id, returning the result and throwing an error when id can't be resolved.
1187
- *
1188
- * @param id Identifier to resolve
1189
- * @param options Options to use for resolving, optional.
1190
- */
1191
- declare function resolveSync(id: string, opts?: resolve.SyncOpts): string;
1192
-
1193
- /**
1194
- * Return whether a package is in core
1195
- */
1196
- declare function resolveIsCore(id: string): boolean | undefined;
1197
-
1198
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
1199
- type JSONValue = string | number | boolean | JSONObject | JSONArray;
1200
- interface JSONObject {
1201
- [x: string]: JSONValue;
1202
- }
1203
- interface JSONArray extends Array<JSONValue> {}
1204
-
1205
- /**
1206
- * Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
1207
- *
1208
- * @param id Identifier to resolve
1209
- * @param callback
1210
- */
1211
- declare function resolve(id: string, cb: resolveCallback): void;
1212
-
1213
- /**
1214
- * Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
1215
- *
1216
- * @param id Identifier to resolve
1217
- * @param options Options to use for resolving, optional.
1218
- * @param callback
1219
- */
1220
- declare function resolve(id: string, opts: resolve.AsyncOpts, cb: resolveCallback): void;
1221
-
1222
- declare namespace resolve {
1223
- export type PackageJSON = JSONObject;
1224
-
1225
- interface Opts {
1226
- /** directory to begin resolving from (defaults to __dirname) */
1227
- basedir?: string | undefined;
1228
- /** package.json data applicable to the module being loaded */
1229
- package?: any;
1230
- /** set to false to exclude node core modules (e.g. fs) from the search */
1231
- includeCoreModules?: boolean | undefined;
1232
- /** array of file extensions to search in order (defaults to ['.js']) */
1233
- extensions?: string | readonly string[] | undefined;
1234
- /** transform the parsed package.json contents before looking at the "main" field */
1235
- packageFilter?: ((pkg: PackageJSON, pkgFile: string, dir: string) => PackageJSON) | undefined;
1236
- /** transform a path within a package */
1237
- pathFilter?: ((pkg: PackageJSON, path: string, relativePath: string) => string) | undefined;
1238
- /** require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this) */
1239
- paths?: string | readonly string[] | undefined;
1240
- /** return the list of candidate paths where the packages sources may be found (probably don't use this) */
1241
- packageIterator?:
1242
- | ((request: string, start: string, getPackageCandidates: () => string[], opts: Opts) => string[])
1243
- | undefined;
1244
- /** directory (or directories) in which to recursively look for modules. (default to 'node_modules') */
1245
- moduleDirectory?: string | readonly string[] | undefined;
1246
- /**
1247
- * if true, doesn't resolve `basedir` to real path before resolving.
1248
- * This is the way Node resolves dependencies when executed with the --preserve-symlinks flag.
1249
- *
1250
- * Note: this property is currently true by default but it will be changed to false in the next major version because Node's resolution
1251
- * algorithm does not preserve symlinks by default.
1252
- */
1253
- preserveSymlinks?: boolean | undefined;
1254
- }
1255
-
1256
- interface BaseAsyncOpts extends Opts {
1257
- /** function to asynchronously test whether a file exists */
1258
- isFile?: ((file: string, cb: existsCallback) => void) | undefined;
1259
- /** function to asynchronously test whether a directory exists */
1260
- isDirectory?: ((directory: string, cb: existsCallback) => void) | undefined;
1261
- /** function to asynchronously resolve a potential symlink to its real path */
1262
- realpath?: ((file: string, cb: realpathCallback) => void) | undefined;
1263
- }
1264
-
1265
- export type AsyncOpts =
1266
- & BaseAsyncOpts
1267
- & ({
1268
- /** how to read files asynchronously (defaults to fs.readFile) */
1269
- readFile?: ((file: string, cb: readFileCallback) => void) | undefined;
1270
- /** function to asynchronously read and parse a package.json file */
1271
- readPackage?: never | undefined;
1272
- } | {
1273
- /** how to read files asynchronously (defaults to fs.readFile) */
1274
- readFile?: never | undefined;
1275
- /** function to asynchronously read and parse a package.json file */
1276
- readPackage?:
1277
- | ((
1278
- readFile: (file: string, cb: readFileCallback) => void,
1279
- pkgfile: string,
1280
- cb: readPackageCallback,
1281
- ) => void)
1282
- | undefined;
1283
- });
1284
-
1285
- interface BaseSyncOpts extends Opts {
1286
- /** function to synchronously test whether a file exists */
1287
- isFile?: ((file: string) => boolean) | undefined;
1288
- /** function to synchronously test whether a directory exists */
1289
- isDirectory?: ((directory: string) => boolean) | undefined;
1290
- /** function to synchronously resolve a potential symlink to its real path */
1291
- realpathSync?: ((file: string) => string) | undefined;
1292
- }
1293
-
1294
- export type SyncOpts =
1295
- & BaseSyncOpts
1296
- & ({
1297
- /** how to read files synchronously (defaults to fs.readFileSync) */
1298
- readFileSync?: ((file: string) => StringOrToString) | undefined;
1299
- /** function to synchronously read and parse a package.json file */
1300
- readPackageSync?: never | undefined;
1301
- } | {
1302
- /** how to read files synchronously (defaults to fs.readFileSync) */
1303
- readFileSync?: never | undefined;
1304
- /** function to synchronously read and parse a package.json file */
1305
- readPackageSync?:
1306
- | ((
1307
- readFileSync: (file: string) => StringOrToString,
1308
- pkgfile: string,
1309
- ) => Record<string, unknown> | undefined)
1310
- | undefined;
1311
- });
1312
-
1313
- export var sync: typeof resolveSync;
1314
- export var isCore: typeof resolveIsCore;
1315
- }
1316
-
1317
- declare const supportedExtensions: readonly [".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts", ".mtsx", ".cjs", ".cts", ".ctsx"];
1318
- declare function getInterpretedFile(pathToFile: string): string | undefined;
1319
- declare function resolveImport(id: string, options: resolve.SyncOpts): string;
1320
-
1321
- declare function serverRequire(filePath: string | string[]): Promise<any> | null;
1322
-
1323
- declare function loadMainConfig({ configDir, cwd, skipCache, }: {
1324
- configDir: string;
1325
- cwd?: string;
1326
- skipCache?: boolean;
1327
- }): Promise<StorybookConfig>;
1328
-
1329
- declare function loadManagerOrAddonsFile({ configDir }: {
1330
- configDir: string;
1331
- }): string | undefined;
1332
-
1333
- declare function loadPreviewOrConfigFile({ configDir }: {
1334
- configDir: string;
1335
- }): string | undefined;
1336
-
1337
- declare function logConfig(caption: unknown, config: unknown): void;
1338
-
1339
- declare const DEFAULT_FILES_PATTERN = "**/*.@(mdx|stories.@(js|jsx|mjs|ts|tsx))";
1340
- declare const getDirectoryFromWorkingDir: ({ configDir, workingDir, directory, }: NormalizeOptions & {
1341
- directory: string;
1342
- }) => string;
1343
- declare const normalizeStoriesEntry: (entry: StoriesEntry, { configDir, workingDir, defaultFilesPattern }: NormalizeOptions) => NormalizedStoriesSpecifier;
1344
- interface NormalizeOptions {
1345
- configDir: string;
1346
- workingDir: string;
1347
- defaultFilesPattern?: string;
1348
- }
1349
- declare const normalizeStories: (entries: StoriesEntry[], options: NormalizeOptions) => NormalizedStoriesSpecifier[];
1350
-
1351
- declare const getProjectRoot: () => string;
1352
- declare const invalidateProjectRootCache: () => void;
1353
- /** Finds files in the directory tree up to the project root */
1354
- declare const findFilesUp: (matchers: string[], baseDir?: string) => string[];
1355
- declare const nodePathsToArray: (nodePath: string) => string[];
1356
- /** Ensures that a path starts with `./` or `../`, or is entirely `.` or `..` */
1357
- declare function normalizeStoryPath(filename: string): string;
1358
-
1359
- declare function readTemplate(filename: string): Promise<string>;
1360
-
1361
1354
  type RemoveAddonOptions = {
1362
1355
  packageManager: JsPackageManager;
1363
1356
  configDir?: string;
@@ -1589,4 +1582,4 @@ declare const getAddonNames: (mainConfig: StorybookConfig) => string[];
1589
1582
  declare const groupBy: <K extends PropertyKey, T>(items: T[], keySelector: (item: T, index: number) => K) => Record<K, T[]>;
1590
1583
  declare function invariant(condition: unknown, message?: string | (() => string)): asserts condition;
1591
1584
 
1592
- export { DEFAULT_FILES_PATTERN, type ExecuteCommandOptions, type FileOptions, FileSystemCache, HandledError, type InstallationMetadata, type InterPresetOptions, JsPackageManager, JsPackageManagerFactory, type PackageJsonInfo, type PackageJsonWithDepsAndDevDeps, type PackageJsonWithMaybeDeps, PackageManagerName, type PackageMetadata, type RemoveAddonOptions, type SetupAddonInConfigOptions, builderPackages, cache, checkAddonOrder, commonGlobOptions, compilerPackages, createFileSystemCache, createLogStream, doesVariableOrFunctionDeclarationExist, executeCommand, executeCommandSync, executeNodeCommand, extractFrameworkPackageName, extractRenderer, filterPresetsConfig, findConfigFile, findFilesUp, formatFileContent, frameworkPackages, frameworkToBuilder, frameworkToRenderer, getAbsolutePathWrapperAsCallExpression, getAbsolutePathWrapperName, getAddonNames, getAutoRefs, getBuilderOptions, getCoercedStorybookVersion, getConfigInfo, getDirectoryFromWorkingDir, getEnvConfig, getFieldsForGetAbsolutePathWrapper, getFrameworkName, getInterpretedFile, getPackageDetails, getPresets, getPrettier, getPreviewBodyTemplate, getPreviewHeadTemplate, getProjectRoot, getRefs, getRendererName, getStoryId, getStoryTitle, getStorybookConfiguration, getStorybookInfo, globToRegexp, groupBy, importMetaResolve, importModule, interpolate, invalidateProjectRootCache, invariant, isCI, isCorePackage, isGetAbsolutePathWrapperNecessary, isPreservingSymlinks, isSatelliteAddon, loadAllPresets, loadEnvs, loadMainConfig, loadManagerOrAddonsFile, loadPreset, loadPreviewOrConfigFile, logConfig, nodePathsToArray, normalizeStories, normalizeStoriesEntry, normalizeStoryPath, optionalEnvToBoolean, parseList, posix, readTemplate, removeAddon, rendererPackages, resolveAddonName, resolveImport, resolvePackageDir, resolvePathInStorybookCache, safeResolveModule, satisfies, scanAndTransformFiles, serverRequire, setupAddonInConfig, stringifyEnvs, stringifyProcessEnvs, supportedExtensions, syncPreviewAddonsWithMainConfig, syncStorybookAddons, temporaryDirectory, temporaryFile, transformImportFiles, validateConfigurationFiles, validateFrameworkName, _default as versions, wrapValueWithGetAbsolutePathWrapper };
1585
+ export { DEFAULT_FILES_PATTERN, type ExecuteCommandOptions, type FileOptions, FileSystemCache, HandledError, type InstallationMetadata, type InterPresetOptions, JsPackageManager, JsPackageManagerFactory, type PackageJsonInfo, type PackageJsonWithDepsAndDevDeps, type PackageJsonWithMaybeDeps, PackageManagerName, type PackageMetadata, type RemoveAddonOptions, type SetupAddonInConfigOptions, builderPackages, cache, checkAddonOrder, commonGlobOptions, compilerPackages, createFileSystemCache, createLogStream, doesVariableOrFunctionDeclarationExist, executeCommand, executeCommandSync, executeNodeCommand, extractFrameworkPackageName, extractRenderer, filterPresetsConfig, findConfigFile, findFilesUp, formatFileContent, frameworkPackages, frameworkToBuilder, frameworkToRenderer, getAbsolutePathWrapperAsCallExpression, getAbsolutePathWrapperName, getAddonNames, getAutoRefs, getBuilderOptions, getConfigInfo, getDirectoryFromWorkingDir, getEnvConfig, getFieldsForGetAbsolutePathWrapper, getFrameworkName, getInterpretedFile, getPackageDetails, getPresets, getPrettier, getPreviewBodyTemplate, getPreviewHeadTemplate, getProjectRoot, getRefs, getRendererName, getStoryId, getStoryTitle, getStorybookConfiguration, getStorybookInfo, globToRegexp, groupBy, importMetaResolve, importModule, interpolate, invalidateProjectRootCache, invariant, isCI, isCorePackage, isGetAbsolutePathWrapperNecessary, isPreservingSymlinks, isSatelliteAddon, loadAllPresets, loadEnvs, loadMainConfig, loadManagerOrAddonsFile, loadPreset, loadPreviewOrConfigFile, logConfig, nodePathsToArray, normalizeStories, normalizeStoriesEntry, normalizeStoryPath, optionalEnvToBoolean, parseList, posix, readTemplate, removeAddon, rendererPackages, resolveAddonName, resolveImport, resolvePackageDir, resolvePathInStorybookCache, safeResolveModule, satisfies, scanAndTransformFiles, serverRequire, setupAddonInConfig, stringifyEnvs, stringifyProcessEnvs, supportedExtensions, syncPreviewAddonsWithMainConfig, syncStorybookAddons, temporaryDirectory, temporaryFile, transformImportFiles, validateConfigurationFiles, validateFrameworkName, _default as versions, wrapValueWithGetAbsolutePathWrapper };