@weasel-js/forge 1.5.0 → 1.5.2

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 (37) hide show
  1. package/dist/{FrameController-Ba3LaWfq.d.ts → FrameController-eZM3hlcE.d.ts} +74 -1
  2. package/dist/{chunk-O5OQZQRZ.js → chunk-2JDYOBWM.js} +5 -5
  3. package/dist/chunk-2JDYOBWM.js.map +1 -0
  4. package/dist/{chunk-KKF7ZX5E.js → chunk-5YHEO26U.js} +133 -23
  5. package/dist/chunk-5YHEO26U.js.map +1 -0
  6. package/dist/{chunk-UZCXH724.js → chunk-6SRQIHJQ.js} +3 -8
  7. package/dist/chunk-6SRQIHJQ.js.map +1 -0
  8. package/dist/{chunk-IOBG7GZQ.js → chunk-FTFR2YPM.js} +2 -2
  9. package/dist/chunk-FTFR2YPM.js.map +1 -0
  10. package/dist/chunk-TLO6UHF2.js +103 -0
  11. package/dist/chunk-TLO6UHF2.js.map +1 -0
  12. package/dist/{config-DdumOfyd.d.ts → config-CSVP6duU.d.ts} +6 -2
  13. package/dist/csf/preview-api.js +2 -2
  14. package/dist/frame/index.d.ts +5 -4
  15. package/dist/frame/index.js +5 -5
  16. package/dist/index.d.ts +97 -5
  17. package/dist/index.js.map +1 -1
  18. package/dist/shell/index.css +209 -12
  19. package/dist/shell/index.css.map +1 -1
  20. package/dist/shell/index.d.ts +62 -4
  21. package/dist/shell/index.js +712 -182
  22. package/dist/shell/index.js.map +1 -1
  23. package/dist/test/index.d.ts +2 -2
  24. package/dist/test/index.js +7 -7
  25. package/dist/test/index.js.map +1 -1
  26. package/dist/test/play.d.ts +25 -0
  27. package/dist/test/play.js +14 -0
  28. package/dist/test/play.js.map +1 -0
  29. package/dist/vite/index.js +72 -20
  30. package/dist/vite/index.js.map +1 -1
  31. package/package.json +14 -5
  32. package/dist/chunk-IOBG7GZQ.js.map +0 -1
  33. package/dist/chunk-KKF7ZX5E.js.map +0 -1
  34. package/dist/chunk-KKVTFMWV.js +0 -59
  35. package/dist/chunk-KKVTFMWV.js.map +0 -1
  36. package/dist/chunk-O5OQZQRZ.js.map +0 -1
  37. package/dist/chunk-UZCXH724.js.map +0 -1
@@ -1,10 +1,15 @@
1
- import { I as IndexEntry, c as FromFrame } from '../FrameController-Ba3LaWfq.js';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { StorageAdapter, InstrumentList } from '@weasel-js/labkit';
4
- import { S as ShellConfig, a as GlobalDeclarations } from '../config-DdumOfyd.js';
2
+ import { LabContribution, StorageAdapter, InstrumentList } from '@weasel-js/labkit';
3
+ import { I as IndexEntry, e as FromFrame, b as A11yReport, T as ToFrame, C as CssVarReport, f as CapturedPicture, V as Viewport } from '../FrameController-eZM3hlcE.js';
4
+ import { S as ShellConfig, a as GlobalDeclarations } from '../config-CSVP6duU.js';
5
5
  import * as react from 'react';
6
+ import { RefObject } from 'react';
6
7
  import '@weasel-js/labkit/config';
7
8
 
9
+ /** What axe found in the story of the trial this is rendered inside, re-run on demand. */
10
+ declare function A11yPanel(): react_jsx_runtime.JSX.Element;
11
+ declare const A11Y_SECTION: LabContribution;
12
+
8
13
  interface WorkshopProps {
9
14
  index: readonly IndexEntry[];
10
15
  frameUrl: string;
@@ -34,8 +39,60 @@ type Ready = Extract<FromFrame, {
34
39
  type: 'ready';
35
40
  }>;
36
41
 
42
+ type Send = (msg: ToFrame) => void;
43
+ /** What an axe run in the frame came back with. */
44
+ type A11yOutcome = {
45
+ ok: true;
46
+ report: A11yReport;
47
+ } | {
48
+ ok: false;
49
+ message: string;
50
+ };
51
+ /** The half of a trial's frame that answers a request: each call is one round trip over the frame's channel. */
52
+ interface TrialFrameCalls {
53
+ send: Send;
54
+ audit: () => Promise<A11yOutcome>;
55
+ /** Rejects when the frame could not draw itself, or went away before it did. */
56
+ capture: () => Promise<CapturedPicture>;
57
+ }
58
+ /** What trial chrome can reach of the frame its trial shows. */
59
+ interface TrialFrame {
60
+ /** Null while no frame is connected. */
61
+ send: Send | null;
62
+ /** The frame's latest `vars` report. */
63
+ vars: readonly CssVarReport[];
64
+ /** Runs axe over the story and records the answer as `a11y`. Null while no frame is connected. */
65
+ audit: (() => Promise<A11yOutcome>) | null;
66
+ /** What the last audit found; null until one has run against the connected frame. */
67
+ a11y: A11yOutcome | null;
68
+ /** The story's own picture, for an export to draw over. Null while no frame is connected. */
69
+ capture: (() => Promise<CapturedPicture>) | null;
70
+ /** The story's content box, as the frame last measured it; null until it has. */
71
+ size: Viewport | null;
72
+ }
73
+ /** Each trial's frame, keyed by trial id: `FrameView` connects and reports, trial chrome reads. */
74
+ interface TrialFrames {
75
+ /** Returns a disconnect that does nothing once a newer connection replaced this one. */
76
+ connect(trialId: string, calls: TrialFrameCalls): () => void;
77
+ report(trialId: string, vars: readonly CssVarReport[]): void;
78
+ reportA11y(trialId: string, outcome: A11yOutcome): void;
79
+ reportSize(trialId: string, size: Viewport): void;
80
+ /** The element a trial's frame is mounted in — stable across the frame reloads that replace the link,
81
+ * because an annotation target's ref has to outlive them. */
82
+ hostRef(trialId: string): RefObject<HTMLElement | null>;
83
+ get(trialId: string): TrialFrame;
84
+ subscribe(listener: () => void): () => void;
85
+ }
86
+ declare const TrialFramesContext: react.Context<TrialFrames | null>;
87
+ /** The frame of the trial `trialId` names, re-read when it connects or reports. */
88
+ declare function useTrialFrame(trialId: string): TrialFrame;
89
+
37
90
  interface StoryRegistry {
38
91
  instruments: InstrumentList;
92
+ /** Whether a story's frame has reported its schema. An instrument is built
93
+ * either way, and before the report its schema is empty — which reads as
94
+ * "no args" to anything that cannot tell the two apart. */
95
+ isReady: (id: string) => boolean;
39
96
  /** Called by FrameView. Replaces the story's instrument only when `ready.schema`, layout or viewport differ from what it holds. */
40
97
  onReady: (entry: IndexEntry, ready: Ready) => void;
41
98
  }
@@ -46,6 +103,7 @@ interface StoryRegistry {
46
103
  declare function useStoryRegistry(index: readonly IndexEntry[], options: {
47
104
  frameUrl: string;
48
105
  globals?: GlobalDeclarations;
106
+ frames?: TrialFrames;
49
107
  }): StoryRegistry;
50
108
 
51
- export { type MountWorkshopOptions, type MountedWorkshop, StoryGlobalsContext, type StoryRegistry, Workshop, type WorkshopProps, mountWorkshop, useStoryRegistry };
109
+ export { A11Y_SECTION, type A11yOutcome, A11yPanel, type MountWorkshopOptions, type MountedWorkshop, StoryGlobalsContext, type StoryRegistry, type TrialFrame, type TrialFrames, TrialFramesContext, Workshop, type WorkshopProps, mountWorkshop, useStoryRegistry, useTrialFrame };