@weasel-js/forge 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +33 -0
  2. package/dist/{FrameController-BspC9Zr5.d.ts → FrameController-HEcTM04H.d.ts} +24 -1
  3. package/dist/{chunk-A4JOEGYQ.js → chunk-7GQI2PDH.js} +7 -46
  4. package/dist/chunk-7GQI2PDH.js.map +1 -0
  5. package/dist/{chunk-PO5JLVYT.js → chunk-DDDCZ6XW.js} +98 -11
  6. package/dist/chunk-DDDCZ6XW.js.map +1 -0
  7. package/dist/{chunk-FWPBKKYB.js → chunk-ERRLEH6S.js} +10 -11
  8. package/dist/chunk-ERRLEH6S.js.map +1 -0
  9. package/dist/chunk-LLGBNJAZ.js +77 -0
  10. package/dist/chunk-LLGBNJAZ.js.map +1 -0
  11. package/dist/chunk-WEQSLPKT.js +9 -0
  12. package/dist/chunk-WEQSLPKT.js.map +1 -0
  13. package/dist/{chunk-VEKEBILL.js → chunk-YKN3IAEX.js} +12 -10
  14. package/dist/chunk-YKN3IAEX.js.map +1 -0
  15. package/dist/{config-DU_WuORS.d.ts → config-pDbcbGco.d.ts} +20 -3
  16. package/dist/csf/preview-api.js +1 -1
  17. package/dist/frame/index.css +63 -7
  18. package/dist/frame/index.css.map +1 -1
  19. package/dist/frame/index.d.ts +4 -2
  20. package/dist/frame/index.js +10 -3
  21. package/dist/frame/index.js.map +1 -1
  22. package/dist/index.d.ts +12 -4
  23. package/dist/index.js +2 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/shell/index.css +162 -3
  26. package/dist/shell/index.css.map +1 -1
  27. package/dist/shell/index.d.ts +39 -37
  28. package/dist/shell/index.js +166 -188
  29. package/dist/shell/index.js.map +1 -1
  30. package/dist/test/index.d.ts +1 -1
  31. package/dist/test/index.js +4 -3
  32. package/dist/test/index.js.map +1 -1
  33. package/dist/vite/index.js +344 -18
  34. package/dist/vite/index.js.map +1 -1
  35. package/package.json +10 -10
  36. package/dist/chunk-A4JOEGYQ.js.map +0 -1
  37. package/dist/chunk-FWPBKKYB.js.map +0 -1
  38. package/dist/chunk-PO5JLVYT.js.map +0 -1
  39. package/dist/chunk-VEKEBILL.js.map +0 -1
@@ -1,15 +1,14 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { LabContribution, StorageAdapter, RenderContext, InstrumentList } from '@weasel-js/labkit';
3
- import { FrameImporters } from '../frame/index.js';
4
- import { g as IndexEntry, F as FrameSetup, L as LoadedStory, h as Layout, G as Globals, i as FromFrame, b as A11yReport, T as ToFrame, C as CssVarReport, j as CapturedPicture, V as Viewport } from '../FrameController-BspC9Zr5.js';
5
- import { S as ShellConfig, a as GlobalDeclarations } from '../config-DU_WuORS.js';
6
1
  import * as react from 'react';
7
2
  import { RefObject, ReactNode } from 'react';
3
+ import { LabContribution, StorageAdapter, RenderContext, InstrumentList } from '@weasel-js/labkit';
4
+ import { FrameImporters } from '../frame/index.js';
5
+ import { h as IndexEntry, F as FrameSetup, c as DepGraph, L as LoadedStory, i as Layout, G as Globals, j as FromFrame, b as A11yReport, T as ToFrame, k as CssVarReport, l as CapturedPicture, V as Viewport } from '../FrameController-HEcTM04H.js';
6
+ import { S as ShellConfig, a as GlobalDeclarations } from '../config-pDbcbGco.js';
8
7
  import '@weasel-js/labkit/config';
9
8
  import '@weasel-js/theme';
10
9
 
11
10
  /** What axe found in the story of the trial this is rendered inside, re-run on demand. */
12
- declare function A11yPanel(): react_jsx_runtime.JSX.Element;
11
+ declare function A11yPanel(): react.JSX.Element;
13
12
  declare const A11Y_SECTION: LabContribution;
14
13
 
15
14
  /** Story files edited while the workshop runs, for the registry to load again. */
@@ -33,8 +32,10 @@ interface WorkshopProps {
33
32
  stories?: readonly string[];
34
33
  storageKey?: string;
35
34
  storage?: StorageAdapter;
35
+ /** The component graph index pages list dependencies from. */
36
+ dependencies?: DepGraph;
36
37
  }
37
- declare function Workshop({ index, frameUrl, importers, setup, changes, config, stories, storageKey, storage }: WorkshopProps): react_jsx_runtime.JSX.Element;
38
+ declare function Workshop({ index, frameUrl, importers, setup, changes, config, stories, storageKey, storage, dependencies }: WorkshopProps): react.JSX.Element;
38
39
 
39
40
  interface MountWorkshopOptions extends WorkshopProps {
40
41
  /** Default: the document's `#root`. */
@@ -47,6 +48,8 @@ interface MountedWorkshop {
47
48
  setImporters(importers: FrameImporters): void;
48
49
  /** Loads `file` again for every story that had it, through the current importers. */
49
50
  reloadStory(file: string): void;
51
+ /** Swaps in the component graph, as the vite plugin's `forge:deps` event carries. */
52
+ setDependencies(dependencies: DepGraph): void;
50
53
  unmount(): void;
51
54
  }
52
55
  declare function mountWorkshop({ container, ...props }: MountWorkshopOptions): MountedWorkshop;
@@ -65,7 +68,7 @@ interface StoryTrialProps {
65
68
  onError?: (error: unknown) => void;
66
69
  }
67
70
  /** A story rendered in the workshop document, inside a `TrialHost`, from the trial's own config and state. */
68
- declare function StoryTrial({ story, setup, ctx, hostRef, onRendered, onError }: StoryTrialProps): react_jsx_runtime.JSX.Element;
71
+ declare function StoryTrial({ story, setup, ctx, hostRef, onRendered, onError }: StoryTrialProps): react.JSX.Element;
69
72
 
70
73
  interface TrialHostProps {
71
74
  layout: Layout;
@@ -84,12 +87,39 @@ interface TrialHostProps {
84
87
  * itself, keeps its CSS variable overrides on itself, contains fixed-position descendants and portals, reports its
85
88
  * vars, size and audits to the trial's frame registry, and unmounts its content while out of view.
86
89
  */
87
- declare function TrialHost({ layout, setup, config, children, hostRef, onRendered }: TrialHostProps): react_jsx_runtime.JSX.Element;
90
+ declare function TrialHost({ layout, setup, config, children, hostRef, onRendered }: TrialHostProps): react.JSX.Element;
88
91
 
89
92
  type Ready = Extract<FromFrame, {
90
93
  type: 'ready';
91
94
  }>;
92
95
 
96
+ interface StoryRegistry {
97
+ instruments: InstrumentList;
98
+ /** Whether a story's schema is known: its module has loaded, or its frame has reported. An instrument is built
99
+ * either way, and before that its schema is empty — which reads as "no args" to anything that cannot tell the
100
+ * two apart. */
101
+ isReady: (id: string) => boolean;
102
+ /** Called by FrameView. Replaces the story's instrument only when `ready.schema`, layout or viewport differ from what it holds. */
103
+ onReady: (entry: IndexEntry, ready: Ready) => void;
104
+ /** Drops what was loaded from `file` and loads it again for every entry that had it, as after an edit. */
105
+ reload: (file: string) => void;
106
+ }
107
+ interface StoryRegistryOptions {
108
+ frameUrl: string;
109
+ globals?: GlobalDeclarations;
110
+ /** Story modules by file. Given, every entry without `isolate` renders in the workshop document; absent, every
111
+ * entry renders in a frame. */
112
+ importers?: FrameImporters;
113
+ /** The frame config, applied to each story host in the document. */
114
+ setup?: FrameSetup;
115
+ load?: (mod: Record<string, unknown>, autoTitle: string, parameters?: Record<string, unknown>) => LoadedStory[];
116
+ }
117
+ /**
118
+ * One instrument per story in `index`, each schema holding a `$globals` group for `globals`. The lab's global values
119
+ * reach the stories through `StoryGlobalsContext`, not through here.
120
+ */
121
+ declare function useStoryRegistry(index: readonly IndexEntry[], options: StoryRegistryOptions): StoryRegistry;
122
+
93
123
  type Send = (msg: ToFrame) => void;
94
124
  /** What an axe run in the frame came back with. */
95
125
  type A11yOutcome = {
@@ -138,32 +168,4 @@ declare const TrialFramesContext: react.Context<TrialFrames | null>;
138
168
  /** The frame of the trial `trialId` names, re-read when it connects or reports. */
139
169
  declare function useTrialFrame(trialId: string): TrialFrame;
140
170
 
141
- interface StoryRegistry {
142
- instruments: InstrumentList;
143
- /** Whether a story's schema is known: its module has loaded, or its frame has reported. An instrument is built
144
- * either way, and before that its schema is empty — which reads as "no args" to anything that cannot tell the
145
- * two apart. */
146
- isReady: (id: string) => boolean;
147
- /** Called by FrameView. Replaces the story's instrument only when `ready.schema`, layout or viewport differ from what it holds. */
148
- onReady: (entry: IndexEntry, ready: Ready) => void;
149
- /** Drops what was loaded from `file` and loads it again for every entry that had it, as after an edit. */
150
- reload: (file: string) => void;
151
- }
152
- interface StoryRegistryOptions {
153
- frameUrl: string;
154
- globals?: GlobalDeclarations;
155
- frames?: TrialFrames;
156
- /** Story modules by file. Given, every entry without `isolate` renders in the workshop document; absent, every
157
- * entry renders in a frame. */
158
- importers?: FrameImporters;
159
- /** The frame config, applied to each story host in the document. */
160
- setup?: FrameSetup;
161
- load?: (mod: Record<string, unknown>, autoTitle: string, parameters?: Record<string, unknown>) => LoadedStory[];
162
- }
163
- /**
164
- * One instrument per story in `index`, each schema holding a `$globals` group for `globals`. The lab's global values
165
- * reach the stories through `StoryGlobalsContext`, not through here.
166
- */
167
- declare function useStoryRegistry(index: readonly IndexEntry[], options: StoryRegistryOptions): StoryRegistry;
168
-
169
171
  export { A11Y_SECTION, type A11yOutcome, A11yPanel, type MountWorkshopOptions, type MountedWorkshop, StoryGlobalsContext, type StoryRegistry, StoryTrial, type StoryTrialProps, type TrialFrame, type TrialFrames, TrialFramesContext, TrialHost, type TrialHostProps, Workshop, type WorkshopProps, mountWorkshop, useStoryRegistry, useTrialFrame };