storybook 9.1.0-alpha.3 → 9.1.0-alpha.5

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 (70) hide show
  1. package/dist/actions/index.cjs +16 -16
  2. package/dist/actions/index.d.ts +1 -38
  3. package/dist/actions/index.js +12 -12
  4. package/dist/actions/preview.cjs +25 -25
  5. package/dist/actions/preview.d.ts +37 -547
  6. package/dist/actions/preview.js +18 -18
  7. package/dist/backgrounds/index.cjs +12 -144
  8. package/dist/backgrounds/index.d.ts +1 -591
  9. package/dist/backgrounds/index.js +0 -130
  10. package/dist/backgrounds/preview.cjs +63 -63
  11. package/dist/backgrounds/preview.d.ts +40 -542
  12. package/dist/backgrounds/preview.js +47 -47
  13. package/dist/bin/index.cjs +50 -50
  14. package/dist/bin/index.js +50 -50
  15. package/dist/cli/bin/index.cjs +1 -1
  16. package/dist/cli/bin/index.js +1 -1
  17. package/dist/common/index.cjs +755 -756
  18. package/dist/common/index.d.ts +9 -5
  19. package/dist/common/index.js +700 -700
  20. package/dist/component-testing/preview.cjs +12 -12
  21. package/dist/component-testing/preview.d.ts +2 -2
  22. package/dist/component-testing/preview.js +7 -7
  23. package/dist/controls/index.cjs +16 -16
  24. package/dist/controls/index.d.ts +1 -36
  25. package/dist/controls/preview.cjs +17 -17
  26. package/dist/controls/preview.d.ts +34 -546
  27. package/dist/controls/preview.js +3 -3
  28. package/dist/csf/index.cjs +1210 -95
  29. package/dist/csf/index.d.ts +59 -18
  30. package/dist/csf/index.js +1214 -90
  31. package/dist/csf-tools/index.cjs +2 -1
  32. package/dist/csf-tools/index.js +2 -2
  33. package/dist/highlight/index.cjs +15 -15
  34. package/dist/highlight/index.d.ts +1 -12
  35. package/dist/highlight/index.js +4 -4
  36. package/dist/highlight/preview.cjs +63 -63
  37. package/dist/highlight/preview.d.ts +11 -546
  38. package/dist/highlight/preview.js +11 -10
  39. package/dist/manager/globals-runtime.js +29776 -29777
  40. package/dist/manager-api/index.cjs +1 -1
  41. package/dist/manager-api/index.js +1 -1
  42. package/dist/measure/index.cjs +12 -472
  43. package/dist/measure/index.d.ts +1 -566
  44. package/dist/measure/index.js +0 -464
  45. package/dist/measure/preview.cjs +104 -104
  46. package/dist/measure/preview.d.ts +11 -546
  47. package/dist/measure/preview.js +105 -105
  48. package/dist/outline/index.cjs +12 -524
  49. package/dist/outline/index.d.ts +1 -566
  50. package/dist/outline/index.js +0 -500
  51. package/dist/outline/preview.cjs +32 -32
  52. package/dist/outline/preview.d.ts +11 -546
  53. package/dist/outline/preview.js +27 -27
  54. package/dist/preview/runtime.js +8259 -8266
  55. package/dist/preview-api/index.cjs +1228 -1261
  56. package/dist/preview-api/index.d.ts +6 -8
  57. package/dist/preview-api/index.js +927 -963
  58. package/dist/telemetry/index.cjs +1 -1
  59. package/dist/telemetry/index.js +1 -1
  60. package/dist/test/preview.cjs +42 -42
  61. package/dist/test/preview.d.ts +12 -550
  62. package/dist/test/preview.js +36 -36
  63. package/dist/types/index.d.ts +5 -3
  64. package/dist/viewport/index.cjs +17 -24
  65. package/dist/viewport/index.d.ts +9 -532
  66. package/dist/viewport/index.js +9 -16
  67. package/dist/viewport/preview.cjs +22 -22
  68. package/dist/viewport/preview.d.ts +45 -552
  69. package/dist/viewport/preview.js +8 -8
  70. package/package.json +1 -1
@@ -3340,7 +3340,7 @@ type OrString<T extends string> = T | (string & {});
3340
3340
  type ViewMode = OrString<ViewMode$1 | 'settings'> | undefined;
3341
3341
  type Layout = 'centered' | 'fullscreen' | 'padded' | 'none';
3342
3342
  interface StorybookParameters {
3343
- options?: Addon_OptionsParameter;
3343
+ options?: Addon_OptionsParameterV7;
3344
3344
  /**
3345
3345
  * The layout property defines basic styles added to the preview body where the story is rendered.
3346
3346
  *
@@ -3348,6 +3348,9 @@ interface StorybookParameters {
3348
3348
  */
3349
3349
  layout?: Layout;
3350
3350
  }
3351
+ interface StorybookTypes {
3352
+ parameters: StorybookParameters;
3353
+ }
3351
3354
  interface StorybookInternalParameters extends StorybookParameters {
3352
3355
  fileName?: string;
3353
3356
  docsOnly?: true;
@@ -3364,7 +3367,6 @@ type MaybePromise<T> = Promise<T> | T;
3364
3367
  type TeardownRenderToCanvas = () => MaybePromise<void>;
3365
3368
  type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
3366
3369
  interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotations$1<TRenderer> {
3367
- addons?: ProjectAnnotations<TRenderer>[];
3368
3370
  testingLibraryRender?: (...args: never[]) => {
3369
3371
  unmount: () => void;
3370
3372
  };
@@ -3587,4 +3589,4 @@ type SupportedFrameworks = 'angular' | 'ember' | 'html-vite' | 'nextjs' | 'nextj
3587
3589
 
3588
3590
  type SupportedRenderers = 'react' | 'react-native' | 'vue3' | 'angular' | 'ember' | 'preact' | 'svelte' | 'qwik' | 'html' | 'web-components' | 'server' | 'solid' | 'nuxt';
3589
3591
 
3590
- export { type API_ActiveTabsType, type API_BaseEntry, type API_ComponentEntry, type API_ComposedRef, type API_ComposedRefUpdate, type API_DocsEntry, type API_FilterFunction, type API_GroupEntry, type API_HashEntry, type API_IframeRenderer, type API_IndexHash, type API_Layout, type API_LayoutCustomisations, type API_LeafEntry, type API_LoadedRefData, type API_MatchOptions, type API_Notification, type API_OptionsData, type API_PanelPositions, type API_PreparedIndexEntry, type API_PreparedStoryIndex, type API_Provider, type API_ProviderData, type API_RefId, type API_RefUrl, type API_Refs, type API_ReleaseNotes, type API_RenderOptions, type API_RootEntry, type API_RouteOptions, type API_SetRefData, type API_Settings, type API_SidebarOptions, type API_StateMerger, type API_StoryEntry, type API_StoryMapper, type API_UI, type API_UIOptions, type API_UnknownEntries, type API_Version, type API_Versions$1 as API_Versions, type API_ViewMode, type Actor, type Addon_AddStoryArgs, type Addon_Annotations, type Addon_ArgType, type Addon_ArgsStoryFn, type Addon_BaseAnnotations, type Addon_BaseDecorators, type Addon_BaseMeta, type Addon_BaseStoryFn, type Addon_BaseStoryObject, type Addon_BaseType, type Addon_ClientApiAddon, type Addon_ClientApiAddons, type Addon_ClientApiReturnFn, type Addon_ClientStoryApi, type Addon_Collection, type Addon_Comparator, type Addon_Config, type Addon_DecoratorFunction, type Addon_Elements, type Addon_LegacyStoryFn, type Addon_LoadFn, type Addon_Loadable, type Addon_Loader, type Addon_LoaderFunction, type Addon_Loaders, type Addon_MakeDecoratorResult, type Addon_OptionsParameter, type Addon_OptionsParameterV7, type Addon_PageType, type Addon_PartialStoryFn, type Addon_RenderOptions, type Addon_RequireContext, type Addon_StoryApi, type Addon_StoryContext, type Addon_StoryContextUpdate, type Addon_StoryFn, type Addon_StorySortComparator, type Addon_StorySortComparatorV7, type Addon_StorySortMethod, type Addon_StorySortObjectParameter, type Addon_StorySortParameter, type Addon_StorySortParameterV7, type Addon_StoryWrapper, type Addon_TestProviderType, type Addon_ToolbarConfig, type Addon_Type, type Addon_Types, Addon_TypesEnum, type Addon_TypesMapping, type Addon_WrapperSettings, type Addon_WrapperType, type Addons_ArgTypes, type BaseIndexEntry, type BaseIndexInput, type BaseStory, type BoundStory, type Builder, type BuilderName, type BuilderOptions, type BuilderResult, type BuilderStats, type Builder_EnvsRaw, type Builder_Unpromise, type Builder_WithRequiredProperty, type CLIBaseOptions, type CLIOptions, type CSFFile, type CompatibleString, type ComposeStoryFn, type ComposedStoryFn, type CoreCommon_AddonEntry, type CoreCommon_AddonInfo, type CoreCommon_OptionsEntry, type CoreCommon_ResolvedAddonPreset, type CoreCommon_ResolvedAddonVirtual, type CoreCommon_StorybookInfo, type CoreConfig, type DocsContextProps, type DocsIndexEntry, type DocsIndexInput, type DocsOptions, type DocsPreparedPayload, type DocsRenderFunction, type Entry, type Event, type EventInfo, type GlobalsUpdatedPayload, type IndexEntry, type IndexEntryLegacy, type IndexInput, type IndexInputStats, type IndexedCSFFile, type IndexedStory, type Indexer, type IndexerOptions, type LoadOptions, type LoadedPreset, type Middleware, MockUniversalStore, type ModuleExport, type ModuleExports, type ModuleImportFn, type NamedOrDefaultProjectAnnotations, type NormalizedComponentAnnotations, type NormalizedProjectAnnotations, type NormalizedStoriesSpecifier, type NormalizedStoryAnnotations, type Options, type PackageJson, type PartialArgsStoryFn, type Path, type PreparedMeta, type PreparedStory, type Preset, type PresetConfig, type PresetProperty, type PresetPropertyFn, type PresetValue, type Presets, type PreviewAnnotation, type ProjectAnnotations, type Ref, type RenderContext, type RenderContextCallbacks, type RenderToCanvas, type Renderer, type RendererName, type ResolvedModuleExport, type ResolvedModuleExportFromType, type ResolvedModuleExportType, type SetGlobalsPayload, type SetStoriesPayload, type SetStoriesStory, type SetStoriesStoryData, type Stats, type Status, type StatusByTypeId, type StatusStore, type StatusStoreByTypeId, type StatusTypeId, type StatusValue, type StatusesByStoryIdAndTypeId, type StoreOptions, type Store_CSFExports, type StoriesEntry, type StoriesSpecifier, type StoriesWithPartialProps, type StoryIndex, type StoryIndexEntry, type StoryIndexInput, type StoryIndexV2, type StoryIndexV3, type StoryPreparedPayload, type StoryRenderOptions, type StorybookConfig, type StorybookConfigOptions, type StorybookConfigRaw, type StorybookInternalParameters, type StorybookParameters, type SupportedFrameworks, type SupportedRenderers, type TagOptions, type TagsOptions, type TeardownRenderToCanvas, type TestBuildConfig, type TestBuildFlags, type TestProviderId, type TestProviderState, type TestProviderStateByProviderId, type TestProviderStoreById, type TypescriptOptions, UniversalStore, type UseStatusStore, type UseTestProviderStore, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };
3592
+ export { type API_ActiveTabsType, type API_BaseEntry, type API_ComponentEntry, type API_ComposedRef, type API_ComposedRefUpdate, type API_DocsEntry, type API_FilterFunction, type API_GroupEntry, type API_HashEntry, type API_IframeRenderer, type API_IndexHash, type API_Layout, type API_LayoutCustomisations, type API_LeafEntry, type API_LoadedRefData, type API_MatchOptions, type API_Notification, type API_OptionsData, type API_PanelPositions, type API_PreparedIndexEntry, type API_PreparedStoryIndex, type API_Provider, type API_ProviderData, type API_RefId, type API_RefUrl, type API_Refs, type API_ReleaseNotes, type API_RenderOptions, type API_RootEntry, type API_RouteOptions, type API_SetRefData, type API_Settings, type API_SidebarOptions, type API_StateMerger, type API_StoryEntry, type API_StoryMapper, type API_UI, type API_UIOptions, type API_UnknownEntries, type API_Version, type API_Versions$1 as API_Versions, type API_ViewMode, type Actor, type Addon_AddStoryArgs, type Addon_Annotations, type Addon_ArgType, type Addon_ArgsStoryFn, type Addon_BaseAnnotations, type Addon_BaseDecorators, type Addon_BaseMeta, type Addon_BaseStoryFn, type Addon_BaseStoryObject, type Addon_BaseType, type Addon_ClientApiAddon, type Addon_ClientApiAddons, type Addon_ClientApiReturnFn, type Addon_ClientStoryApi, type Addon_Collection, type Addon_Comparator, type Addon_Config, type Addon_DecoratorFunction, type Addon_Elements, type Addon_LegacyStoryFn, type Addon_LoadFn, type Addon_Loadable, type Addon_Loader, type Addon_LoaderFunction, type Addon_Loaders, type Addon_MakeDecoratorResult, type Addon_OptionsParameter, type Addon_OptionsParameterV7, type Addon_PageType, type Addon_PartialStoryFn, type Addon_RenderOptions, type Addon_RequireContext, type Addon_StoryApi, type Addon_StoryContext, type Addon_StoryContextUpdate, type Addon_StoryFn, type Addon_StorySortComparator, type Addon_StorySortComparatorV7, type Addon_StorySortMethod, type Addon_StorySortObjectParameter, type Addon_StorySortParameter, type Addon_StorySortParameterV7, type Addon_StoryWrapper, type Addon_TestProviderType, type Addon_ToolbarConfig, type Addon_Type, type Addon_Types, Addon_TypesEnum, type Addon_TypesMapping, type Addon_WrapperSettings, type Addon_WrapperType, type Addons_ArgTypes, type BaseIndexEntry, type BaseIndexInput, type BaseStory, type BoundStory, type Builder, type BuilderName, type BuilderOptions, type BuilderResult, type BuilderStats, type Builder_EnvsRaw, type Builder_Unpromise, type Builder_WithRequiredProperty, type CLIBaseOptions, type CLIOptions, type CSFFile, type CompatibleString, type ComposeStoryFn, type ComposedStoryFn, type CoreCommon_AddonEntry, type CoreCommon_AddonInfo, type CoreCommon_OptionsEntry, type CoreCommon_ResolvedAddonPreset, type CoreCommon_ResolvedAddonVirtual, type CoreCommon_StorybookInfo, type CoreConfig, type DocsContextProps, type DocsIndexEntry, type DocsIndexInput, type DocsOptions, type DocsPreparedPayload, type DocsRenderFunction, type Entry, type Event, type EventInfo, type GlobalsUpdatedPayload, type IndexEntry, type IndexEntryLegacy, type IndexInput, type IndexInputStats, type IndexedCSFFile, type IndexedStory, type Indexer, type IndexerOptions, type LoadOptions, type LoadedPreset, type Middleware, MockUniversalStore, type ModuleExport, type ModuleExports, type ModuleImportFn, type NamedOrDefaultProjectAnnotations, type NormalizedComponentAnnotations, type NormalizedProjectAnnotations, type NormalizedStoriesSpecifier, type NormalizedStoryAnnotations, type Options, type PackageJson, type PartialArgsStoryFn, type Path, type PreparedMeta, type PreparedStory, type Preset, type PresetConfig, type PresetProperty, type PresetPropertyFn, type PresetValue, type Presets, type PreviewAnnotation, type ProjectAnnotations, type Ref, type RenderContext, type RenderContextCallbacks, type RenderToCanvas, type Renderer, type RendererName, type ResolvedModuleExport, type ResolvedModuleExportFromType, type ResolvedModuleExportType, type SetGlobalsPayload, type SetStoriesPayload, type SetStoriesStory, type SetStoriesStoryData, type Stats, type Status, type StatusByTypeId, type StatusStore, type StatusStoreByTypeId, type StatusTypeId, type StatusValue, type StatusesByStoryIdAndTypeId, type StoreOptions, type Store_CSFExports, type StoriesEntry, type StoriesSpecifier, type StoriesWithPartialProps, type StoryIndex, type StoryIndexEntry, type StoryIndexInput, type StoryIndexV2, type StoryIndexV3, type StoryPreparedPayload, type StoryRenderOptions, type StorybookConfig, type StorybookConfigOptions, type StorybookConfigRaw, type StorybookInternalParameters, type StorybookParameters, type StorybookTypes, type SupportedFrameworks, type SupportedRenderers, type TagOptions, type TagsOptions, type TeardownRenderToCanvas, type TestBuildConfig, type TestBuildFlags, type TestProviderId, type TestProviderState, type TestProviderStateByProviderId, type TestProviderStoreById, type TypescriptOptions, UniversalStore, type UseStatusStore, type UseTestProviderStore, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };
@@ -1,36 +1,35 @@
1
1
  "use strict";
2
- var o = Object.defineProperty;
3
- var n = Object.getOwnPropertyDescriptor;
4
- var l = Object.getOwnPropertyNames;
5
- var m = Object.prototype.hasOwnProperty;
6
- var a = (t, e) => {
2
+ var h = Object.defineProperty;
3
+ var s = Object.getOwnPropertyDescriptor;
4
+ var n = Object.getOwnPropertyNames;
5
+ var l = Object.prototype.hasOwnProperty;
6
+ var y = (t, e) => {
7
7
  for (var i in e)
8
- o(t, i, { get: e[i], enumerable: !0 });
9
- }, y = (t, e, i, x) => {
8
+ h(t, i, { get: e[i], enumerable: !0 });
9
+ }, m = (t, e, i, x) => {
10
10
  if (e && typeof e == "object" || typeof e == "function")
11
- for (let p of l(e))
12
- !m.call(t, p) && p !== i && o(t, p, { get: () => e[p], enumerable: !(x = n(e, p)) || x.enumerable });
11
+ for (let p of n(e))
12
+ !l.call(t, p) && p !== i && h(t, p, { get: () => e[p], enumerable: !(x = s(e, p)) || x.enumerable });
13
13
  return t;
14
14
  };
15
- var r = (t) => y(o({}, "__esModule", { value: !0 }), t);
15
+ var a = (t) => m(h({}, "__esModule", { value: !0 }), t);
16
16
 
17
17
  // src/viewport/index.ts
18
18
  var T = {};
19
- a(T, {
20
- ADDON_ID: () => h,
19
+ y(T, {
20
+ ADDON_ID: () => o,
21
21
  DEFAULT_VIEWPORT: () => g,
22
22
  INITIAL_VIEWPORTS: () => b,
23
23
  MINIMAL_VIEWPORTS: () => I,
24
24
  PANEL_ID: () => d,
25
- PARAM_KEY: () => s,
25
+ PARAM_KEY: () => r,
26
26
  TOOL_ID: () => w,
27
- initialGlobals: () => A,
28
- responsiveViewport: () => S
27
+ responsiveViewport: () => A
29
28
  });
30
- module.exports = r(T);
29
+ module.exports = a(T);
31
30
 
32
31
  // src/viewport/constants.ts
33
- var h = "storybook/viewport", s = "viewport", d = `${h}/panel`, w = `${h}/tool`;
32
+ var o = "storybook/viewport", r = "viewport", d = `${o}/panel`, w = `${o}/tool`;
34
33
 
35
34
  // src/viewport/defaults.ts
36
35
  var P = {
@@ -293,14 +292,8 @@ var P = {
293
292
  }
294
293
  };
295
294
 
296
- // src/viewport/preview.ts
297
- var f = require("storybook/preview-api");
298
- var A = {
299
- [s]: { value: void 0, isRotated: !1 }
300
- };
301
-
302
295
  // src/viewport/responsiveViewport.tsx
303
- var S = {
296
+ var A = {
304
297
  name: "Reset viewport",
305
298
  styles: {
306
299
  height: "100%",
@@ -1,5 +1,3 @@
1
- import { NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
2
-
3
1
  declare const ADDON_ID = "storybook/viewport";
4
2
  declare const PARAM_KEY = "viewport";
5
3
  declare const PANEL_ID = "storybook/viewport/panel";
@@ -8,7 +6,7 @@ declare const TOOL_ID = "storybook/viewport/tool";
8
6
  interface Viewport {
9
7
  name: string;
10
8
  styles: ViewportStyles;
11
- type: 'desktop' | 'mobile' | 'tablet' | 'other';
9
+ type?: 'desktop' | 'mobile' | 'tablet' | 'other';
12
10
  }
13
11
  interface ViewportStyles {
14
12
  height: string;
@@ -25,7 +23,7 @@ type GlobalState = {
25
23
  * When true the viewport applied will be rotated 90°, e.g. it will rotate from portrait to
26
24
  * landscape orientation.
27
25
  */
28
- isRotated: boolean;
26
+ isRotated?: boolean;
29
27
  };
30
28
  type GlobalStateUpdate = Partial<GlobalState>;
31
29
  interface ViewportParameters {
@@ -34,7 +32,7 @@ interface ViewportParameters {
34
32
  *
35
33
  * @see https://storybook.js.org/docs/essentials/viewport#parameters
36
34
  */
37
- viewport: {
35
+ viewport?: {
38
36
  /**
39
37
  * Remove the addon panel and disable the addon's behavior . If you wish to turn off this addon
40
38
  * for the entire Storybook, you should do so when registering addon-essentials
@@ -55,7 +53,11 @@ interface ViewportGlobals {
55
53
  *
56
54
  * @see https://storybook.js.org/docs/essentials/viewport#globals
57
55
  */
58
- viewport: GlobalState | GlobalState['value'];
56
+ viewport?: GlobalState | GlobalState['value'];
57
+ }
58
+ interface ViewportTypes {
59
+ parameters: ViewportParameters;
60
+ globals: ViewportGlobals;
59
61
  }
60
62
 
61
63
  declare const INITIAL_VIEWPORTS_DATA: {
@@ -289,531 +291,6 @@ declare const INITIAL_VIEWPORTS: ViewportMap;
289
291
  declare const DEFAULT_VIEWPORT = "responsive";
290
292
  declare const MINIMAL_VIEWPORTS: ViewportMap;
291
293
 
292
- /**
293
- * Actions represent the type of change to a location value.
294
- */
295
- declare enum Action {
296
- /**
297
- * A POP indicates a change to an arbitrary index in the history stack, such
298
- * as a back or forward navigation. It does not describe the direction of the
299
- * navigation, only that the current index changed.
300
- *
301
- * Note: This is the default action for newly created history objects.
302
- */
303
- Pop = "POP",
304
- /**
305
- * A PUSH indicates a new entry being added to the history stack, such as when
306
- * a link is clicked and a new page loads. When this happens, all subsequent
307
- * entries in the stack are lost.
308
- */
309
- Push = "PUSH",
310
- /**
311
- * A REPLACE indicates the entry at the current index in the history stack
312
- * being replaced by a new one.
313
- */
314
- Replace = "REPLACE"
315
- }
316
- /**
317
- * The pathname, search, and hash values of a URL.
318
- */
319
- interface Path {
320
- /**
321
- * A URL pathname, beginning with a /.
322
- */
323
- pathname: string;
324
- /**
325
- * A URL search string, beginning with a ?.
326
- */
327
- search: string;
328
- /**
329
- * A URL fragment identifier, beginning with a #.
330
- */
331
- hash: string;
332
- }
333
- /**
334
- * An entry in a history stack. A location contains information about the
335
- * URL path, as well as possibly some arbitrary state and a key.
336
- */
337
- interface Location extends Path {
338
- /**
339
- * A value of arbitrary data associated with this location.
340
- */
341
- state: any;
342
- /**
343
- * A unique string associated with this location. May be used to safely store
344
- * and retrieve data in some other storage API, like `localStorage`.
345
- *
346
- * Note: This value is always "default" on the initial location.
347
- */
348
- key: string;
349
- }
350
-
351
- /**
352
- * Map of routeId -> data returned from a loader/action/error
353
- */
354
- interface RouteData {
355
- [routeId: string]: any;
356
- }
357
- declare enum ResultType {
358
- data = "data",
359
- deferred = "deferred",
360
- redirect = "redirect",
361
- error = "error"
362
- }
363
- /**
364
- * Successful result from a loader or action
365
- */
366
- interface SuccessResult {
367
- type: ResultType.data;
368
- data: any;
369
- statusCode?: number;
370
- headers?: Headers;
371
- }
372
- /**
373
- * Successful defer() result from a loader or action
374
- */
375
- interface DeferredResult {
376
- type: ResultType.deferred;
377
- deferredData: DeferredData;
378
- statusCode?: number;
379
- headers?: Headers;
380
- }
381
- /**
382
- * Redirect result from a loader or action
383
- */
384
- interface RedirectResult {
385
- type: ResultType.redirect;
386
- status: number;
387
- location: string;
388
- revalidate: boolean;
389
- reloadDocument?: boolean;
390
- }
391
- /**
392
- * Unsuccessful result from a loader or action
393
- */
394
- interface ErrorResult {
395
- type: ResultType.error;
396
- error: any;
397
- headers?: Headers;
398
- }
399
- /**
400
- * Result from a loader or action - potentially successful or unsuccessful
401
- */
402
- type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
403
- type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
404
- type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
405
- /**
406
- * Active navigation/fetcher form methods are exposed in lowercase on the
407
- * RouterState
408
- */
409
- type FormMethod = LowerCaseFormMethod;
410
- /**
411
- * In v7, active navigation/fetcher form methods are exposed in uppercase on the
412
- * RouterState. This is to align with the normalization done via fetch().
413
- */
414
- type V7_FormMethod = UpperCaseFormMethod;
415
- type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
416
- type JsonObject = {
417
- [Key in string]: JsonValue;
418
- } & {
419
- [Key in string]?: JsonValue | undefined;
420
- };
421
- type JsonArray = JsonValue[] | readonly JsonValue[];
422
- type JsonPrimitive = string | number | boolean | null;
423
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
424
- /**
425
- * @private
426
- * Internal interface to pass around for action submissions, not intended for
427
- * external consumption
428
- */
429
- type Submission = {
430
- formMethod: FormMethod | V7_FormMethod;
431
- formAction: string;
432
- formEncType: FormEncType;
433
- formData: FormData;
434
- json: undefined;
435
- text: undefined;
436
- } | {
437
- formMethod: FormMethod | V7_FormMethod;
438
- formAction: string;
439
- formEncType: FormEncType;
440
- formData: undefined;
441
- json: JsonValue;
442
- text: undefined;
443
- } | {
444
- formMethod: FormMethod | V7_FormMethod;
445
- formAction: string;
446
- formEncType: FormEncType;
447
- formData: undefined;
448
- json: undefined;
449
- text: string;
450
- };
451
- /**
452
- * @private
453
- * Arguments passed to route loader/action functions. Same for now but we keep
454
- * this as a private implementation detail in case they diverge in the future.
455
- */
456
- interface DataFunctionArgs {
457
- request: Request;
458
- params: Params;
459
- context?: any;
460
- }
461
- /**
462
- * Arguments passed to loader functions
463
- */
464
- interface LoaderFunctionArgs extends DataFunctionArgs {
465
- }
466
- /**
467
- * Arguments passed to action functions
468
- */
469
- interface ActionFunctionArgs extends DataFunctionArgs {
470
- }
471
- /**
472
- * Loaders and actions can return anything except `undefined` (`null` is a
473
- * valid return value if there is no data to return). Responses are preferred
474
- * and will ease any future migration to Remix
475
- */
476
- type DataFunctionValue = Response | NonNullable<unknown> | null;
477
- /**
478
- * Route loader function signature
479
- */
480
- interface LoaderFunction {
481
- (args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
482
- }
483
- /**
484
- * Route action function signature
485
- */
486
- interface ActionFunction {
487
- (args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
488
- }
489
- /**
490
- * Route shouldRevalidate function signature. This runs after any submission
491
- * (navigation or fetcher), so we flatten the navigation/fetcher submission
492
- * onto the arguments. It shouldn't matter whether it came from a navigation
493
- * or a fetcher, what really matters is the URLs and the formData since loaders
494
- * have to re-run based on the data models that were potentially mutated.
495
- */
496
- interface ShouldRevalidateFunction {
497
- (args: {
498
- currentUrl: URL;
499
- currentParams: AgnosticDataRouteMatch["params"];
500
- nextUrl: URL;
501
- nextParams: AgnosticDataRouteMatch["params"];
502
- formMethod?: Submission["formMethod"];
503
- formAction?: Submission["formAction"];
504
- formEncType?: Submission["formEncType"];
505
- text?: Submission["text"];
506
- formData?: Submission["formData"];
507
- json?: Submission["json"];
508
- actionResult?: DataResult;
509
- defaultShouldRevalidate: boolean;
510
- }): boolean;
511
- }
512
- /**
513
- * Keys we cannot change from within a lazy() function. We spread all other keys
514
- * onto the route. Either they're meaningful to the router, or they'll get
515
- * ignored.
516
- */
517
- type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
518
- type RequireOne<T, Key = keyof T> = Exclude<{
519
- [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
520
- }[keyof T], undefined>;
521
- /**
522
- * lazy() function to load a route definition, which can add non-matching
523
- * related properties to a route
524
- */
525
- interface LazyRouteFunction<R extends AgnosticRouteObject> {
526
- (): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
527
- }
528
- /**
529
- * Base RouteObject with common props shared by all types of routes
530
- */
531
- type AgnosticBaseRouteObject = {
532
- caseSensitive?: boolean;
533
- path?: string;
534
- id?: string;
535
- loader?: LoaderFunction;
536
- action?: ActionFunction;
537
- hasErrorBoundary?: boolean;
538
- shouldRevalidate?: ShouldRevalidateFunction;
539
- handle?: any;
540
- lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
541
- };
542
- /**
543
- * Index routes must not have children
544
- */
545
- type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
546
- children?: undefined;
547
- index: true;
548
- };
549
- /**
550
- * Non-index routes may have children, but cannot have index
551
- */
552
- type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
553
- children?: AgnosticRouteObject[];
554
- index?: false;
555
- };
556
- /**
557
- * A route object represents a logical route, with (optionally) its child
558
- * routes organized in a tree-like structure.
559
- */
560
- type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
561
- type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
562
- id: string;
563
- };
564
- type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
565
- children?: AgnosticDataRouteObject[];
566
- id: string;
567
- };
568
- /**
569
- * A data route object, which is just a RouteObject with a required unique ID
570
- */
571
- type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
572
- /**
573
- * The parameters that were parsed from the URL path.
574
- */
575
- type Params<Key extends string = string> = {
576
- readonly [key in Key]: string | undefined;
577
- };
578
- /**
579
- * A RouteMatch contains info about how a route matched a URL.
580
- */
581
- interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
582
- /**
583
- * The names and values of dynamic parameters in the URL.
584
- */
585
- params: Params<ParamKey>;
586
- /**
587
- * The portion of the URL pathname that was matched.
588
- */
589
- pathname: string;
590
- /**
591
- * The portion of the URL pathname that was matched before child routes.
592
- */
593
- pathnameBase: string;
594
- /**
595
- * The route object that was used to match.
596
- */
597
- route: RouteObjectType;
598
- }
599
- interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
600
- }
601
- declare class DeferredData {
602
- private pendingKeysSet;
603
- private controller;
604
- private abortPromise;
605
- private unlistenAbortSignal;
606
- private subscribers;
607
- data: Record<string, unknown>;
608
- init?: ResponseInit;
609
- deferredKeys: string[];
610
- constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
611
- private trackPromise;
612
- private onSettle;
613
- private emit;
614
- subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
615
- cancel(): void;
616
- resolveData(signal: AbortSignal): Promise<boolean>;
617
- get done(): boolean;
618
- get unwrappedData(): {};
619
- get pendingKeys(): string[];
620
- }
621
-
622
- /**
623
- * State maintained internally by the router. During a navigation, all states
624
- * reflect the the "old" location unless otherwise noted.
625
- */
626
- interface RouterState {
627
- /**
628
- * The action of the most recent navigation
629
- */
630
- historyAction: Action;
631
- /**
632
- * The current location reflected by the router
633
- */
634
- location: Location;
635
- /**
636
- * The current set of route matches
637
- */
638
- matches: AgnosticDataRouteMatch[];
639
- /**
640
- * Tracks whether we've completed our initial data load
641
- */
642
- initialized: boolean;
643
- /**
644
- * Current scroll position we should start at for a new view
645
- * - number -> scroll position to restore to
646
- * - false -> do not restore scroll at all (used during submissions)
647
- * - null -> don't have a saved position, scroll to hash or top of page
648
- */
649
- restoreScrollPosition: number | false | null;
650
- /**
651
- * Indicate whether this navigation should skip resetting the scroll position
652
- * if we are unable to restore the scroll position
653
- */
654
- preventScrollReset: boolean;
655
- /**
656
- * Tracks the state of the current navigation
657
- */
658
- navigation: Navigation;
659
- /**
660
- * Tracks any in-progress revalidations
661
- */
662
- revalidation: RevalidationState;
663
- /**
664
- * Data from the loaders for the current matches
665
- */
666
- loaderData: RouteData;
667
- /**
668
- * Data from the action for the current matches
669
- */
670
- actionData: RouteData | null;
671
- /**
672
- * Errors caught from loaders for the current matches
673
- */
674
- errors: RouteData | null;
675
- /**
676
- * Map of current fetchers
677
- */
678
- fetchers: Map<string, Fetcher>;
679
- /**
680
- * Map of current blockers
681
- */
682
- blockers: Map<string, Blocker>;
683
- }
684
- /**
685
- * Data that can be passed into hydrate a Router from SSR
686
- */
687
- type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
688
- /**
689
- * Potential states for state.navigation
690
- */
691
- type NavigationStates = {
692
- Idle: {
693
- state: "idle";
694
- location: undefined;
695
- formMethod: undefined;
696
- formAction: undefined;
697
- formEncType: undefined;
698
- formData: undefined;
699
- json: undefined;
700
- text: undefined;
701
- };
702
- Loading: {
703
- state: "loading";
704
- location: Location;
705
- formMethod: Submission["formMethod"] | undefined;
706
- formAction: Submission["formAction"] | undefined;
707
- formEncType: Submission["formEncType"] | undefined;
708
- formData: Submission["formData"] | undefined;
709
- json: Submission["json"] | undefined;
710
- text: Submission["text"] | undefined;
711
- };
712
- Submitting: {
713
- state: "submitting";
714
- location: Location;
715
- formMethod: Submission["formMethod"];
716
- formAction: Submission["formAction"];
717
- formEncType: Submission["formEncType"];
718
- formData: Submission["formData"];
719
- json: Submission["json"];
720
- text: Submission["text"];
721
- };
722
- };
723
- type Navigation = NavigationStates[keyof NavigationStates];
724
- type RevalidationState = "idle" | "loading";
725
- /**
726
- * Potential states for fetchers
727
- */
728
- type FetcherStates<TData = any> = {
729
- Idle: {
730
- state: "idle";
731
- formMethod: undefined;
732
- formAction: undefined;
733
- formEncType: undefined;
734
- text: undefined;
735
- formData: undefined;
736
- json: undefined;
737
- data: TData | undefined;
738
- " _hasFetcherDoneAnything "?: boolean;
739
- };
740
- Loading: {
741
- state: "loading";
742
- formMethod: Submission["formMethod"] | undefined;
743
- formAction: Submission["formAction"] | undefined;
744
- formEncType: Submission["formEncType"] | undefined;
745
- text: Submission["text"] | undefined;
746
- formData: Submission["formData"] | undefined;
747
- json: Submission["json"] | undefined;
748
- data: TData | undefined;
749
- " _hasFetcherDoneAnything "?: boolean;
750
- };
751
- Submitting: {
752
- state: "submitting";
753
- formMethod: Submission["formMethod"];
754
- formAction: Submission["formAction"];
755
- formEncType: Submission["formEncType"];
756
- text: Submission["text"];
757
- formData: Submission["formData"];
758
- json: Submission["json"];
759
- data: TData | undefined;
760
- " _hasFetcherDoneAnything "?: boolean;
761
- };
762
- };
763
- type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
764
- interface BlockerBlocked {
765
- state: "blocked";
766
- reset(): void;
767
- proceed(): void;
768
- location: Location;
769
- }
770
- interface BlockerUnblocked {
771
- state: "unblocked";
772
- reset: undefined;
773
- proceed: undefined;
774
- location: undefined;
775
- }
776
- interface BlockerProceeding {
777
- state: "proceeding";
778
- reset: undefined;
779
- proceed: undefined;
780
- location: Location;
781
- }
782
- type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
783
-
784
- /**
785
- * NOTE: If you refactor this to split up the modules into separate files,
786
- * you'll need to update the rollup config for react-router-dom-v5-compat.
787
- */
788
-
789
- declare global {
790
- var __staticRouterHydrationData: HydrationState | undefined;
791
- }
792
-
793
- declare global {
794
- interface SymbolConstructor {
795
- readonly observable: symbol;
796
- }
797
- }
798
-
799
- declare global {
800
- var globalProjectAnnotations: NormalizedProjectAnnotations<any>;
801
- var defaultProjectAnnotations: ProjectAnnotations<any>;
802
- }
803
- type WrappedStoryRef = {
804
- __pw_type: 'jsx' | 'importRef';
805
- };
806
- type UnwrappedJSXStoryRef = {
807
- __pw_type: 'jsx';
808
- type: UnwrappedImportStoryRef;
809
- };
810
- type UnwrappedImportStoryRef = ComposedStoryFn;
811
- declare global {
812
- function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
813
- }
814
-
815
- declare const initialGlobals: Record<string, GlobalState>;
816
-
817
294
  declare const responsiveViewport: Viewport;
818
295
 
819
- export { ADDON_ID, DEFAULT_VIEWPORT, type GlobalState, type GlobalStateUpdate, INITIAL_VIEWPORTS, type InitialViewportKeys, MINIMAL_VIEWPORTS, PANEL_ID, PARAM_KEY, TOOL_ID, type Viewport, type ViewportGlobals, type ViewportMap, type ViewportParameters, type ViewportStyles, initialGlobals, responsiveViewport };
296
+ export { ADDON_ID, DEFAULT_VIEWPORT, type GlobalState, type GlobalStateUpdate, INITIAL_VIEWPORTS, type InitialViewportKeys, MINIMAL_VIEWPORTS, PANEL_ID, PARAM_KEY, TOOL_ID, type Viewport, type ViewportGlobals, type ViewportMap, type ViewportParameters, type ViewportStyles, type ViewportTypes, responsiveViewport };