@histoire/plugin-kit 0.0.0-stage → 1.0.0-beta.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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -2
  3. package/dist/builtins.d.ts +13 -0
  4. package/dist/builtins.d.ts.map +1 -0
  5. package/dist/builtins.js +7 -0
  6. package/dist/define.d.ts +19 -0
  7. package/dist/define.d.ts.map +1 -0
  8. package/dist/define.js +43 -0
  9. package/dist/errors.d.ts +11 -0
  10. package/dist/errors.d.ts.map +1 -0
  11. package/dist/errors.js +14 -0
  12. package/dist/frame.d.ts +6 -0
  13. package/dist/frame.d.ts.map +1 -0
  14. package/dist/frame.js +3 -0
  15. package/dist/host/actions.d.ts +37 -0
  16. package/dist/host/actions.d.ts.map +1 -0
  17. package/dist/host/actions.js +47 -0
  18. package/dist/host/create-host.d.ts +9 -0
  19. package/dist/host/create-host.d.ts.map +1 -0
  20. package/dist/host/create-host.js +194 -0
  21. package/dist/host/diagnostics.d.ts +14 -0
  22. package/dist/host/diagnostics.d.ts.map +1 -0
  23. package/dist/host/diagnostics.js +26 -0
  24. package/dist/host/frames.d.ts +43 -0
  25. package/dist/host/frames.d.ts.map +1 -0
  26. package/dist/host/frames.js +63 -0
  27. package/dist/host/generation.d.ts +24 -0
  28. package/dist/host/generation.d.ts.map +1 -0
  29. package/dist/host/generation.js +38 -0
  30. package/dist/host/install.d.ts +43 -0
  31. package/dist/host/install.d.ts.map +1 -0
  32. package/dist/host/install.js +168 -0
  33. package/dist/host/manifest.d.ts +23 -0
  34. package/dist/host/manifest.d.ts.map +1 -0
  35. package/dist/host/manifest.js +37 -0
  36. package/dist/host/mount.d.ts +15 -0
  37. package/dist/host/mount.d.ts.map +1 -0
  38. package/dist/host/mount.js +57 -0
  39. package/dist/host/ordering.d.ts +20 -0
  40. package/dist/host/ordering.d.ts.map +1 -0
  41. package/dist/host/ordering.js +12 -0
  42. package/dist/host/plugin-api.d.ts +33 -0
  43. package/dist/host/plugin-api.d.ts.map +1 -0
  44. package/dist/host/plugin-api.js +113 -0
  45. package/dist/host/preferences.d.ts +57 -0
  46. package/dist/host/preferences.d.ts.map +1 -0
  47. package/dist/host/preferences.js +137 -0
  48. package/dist/host/registry.d.ts +43 -0
  49. package/dist/host/registry.d.ts.map +1 -0
  50. package/dist/host/registry.js +123 -0
  51. package/dist/host/resources.d.ts +20 -0
  52. package/dist/host/resources.d.ts.map +1 -0
  53. package/dist/host/resources.js +45 -0
  54. package/dist/ids.d.ts +32 -0
  55. package/dist/ids.d.ts.map +1 -0
  56. package/dist/ids.js +51 -0
  57. package/dist/index.d.ts +27 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +16 -0
  60. package/dist/react/index.d.ts +19 -0
  61. package/dist/react/index.d.ts.map +1 -0
  62. package/dist/react/index.js +25 -0
  63. package/dist/render/keys.d.ts +7 -0
  64. package/dist/render/keys.d.ts.map +1 -0
  65. package/dist/render/keys.js +15 -0
  66. package/dist/render/mount-manager.d.ts +36 -0
  67. package/dist/render/mount-manager.d.ts.map +1 -0
  68. package/dist/render/mount-manager.js +128 -0
  69. package/dist/render/view-binding.d.ts +19 -0
  70. package/dist/render/view-binding.d.ts.map +1 -0
  71. package/dist/render/view-binding.js +7 -0
  72. package/dist/render/workbench-components.d.ts +39 -0
  73. package/dist/render/workbench-components.d.ts.map +1 -0
  74. package/dist/render/workbench-components.js +76 -0
  75. package/dist/session/context.d.ts +66 -0
  76. package/dist/session/context.d.ts.map +1 -0
  77. package/dist/session/context.js +173 -0
  78. package/dist/session/frames.d.ts +46 -0
  79. package/dist/session/frames.d.ts.map +1 -0
  80. package/dist/session/frames.js +68 -0
  81. package/dist/shortcuts.d.ts +94 -0
  82. package/dist/shortcuts.d.ts.map +1 -0
  83. package/dist/shortcuts.js +157 -0
  84. package/dist/styles.d.ts +3 -0
  85. package/dist/styles.d.ts.map +1 -0
  86. package/dist/styles.js +25 -0
  87. package/dist/svelte4/index.d.ts +27 -0
  88. package/dist/svelte4/index.d.ts.map +1 -0
  89. package/dist/svelte4/index.js +16 -0
  90. package/dist/svelte5/index.d.ts +21 -0
  91. package/dist/svelte5/index.d.ts.map +1 -0
  92. package/dist/svelte5/index.js +40 -0
  93. package/dist/types/actions.d.ts +12 -0
  94. package/dist/types/actions.d.ts.map +1 -0
  95. package/dist/types/actions.js +1 -0
  96. package/dist/types/base.d.ts +12 -0
  97. package/dist/types/base.d.ts.map +1 -0
  98. package/dist/types/base.js +1 -0
  99. package/dist/types/canvas.d.ts +150 -0
  100. package/dist/types/canvas.d.ts.map +1 -0
  101. package/dist/types/canvas.js +1 -0
  102. package/dist/types/channel.d.ts +28 -0
  103. package/dist/types/channel.d.ts.map +1 -0
  104. package/dist/types/channel.js +1 -0
  105. package/dist/types/commands.d.ts +35 -0
  106. package/dist/types/commands.d.ts.map +1 -0
  107. package/dist/types/commands.js +1 -0
  108. package/dist/types/common.d.ts +7 -0
  109. package/dist/types/common.d.ts.map +1 -0
  110. package/dist/types/common.js +1 -0
  111. package/dist/types/context.d.ts +72 -0
  112. package/dist/types/context.d.ts.map +1 -0
  113. package/dist/types/context.js +1 -0
  114. package/dist/types/contribution.d.ts +56 -0
  115. package/dist/types/contribution.d.ts.map +1 -0
  116. package/dist/types/contribution.js +1 -0
  117. package/dist/types/frame.d.ts +41 -0
  118. package/dist/types/frame.d.ts.map +1 -0
  119. package/dist/types/frame.js +1 -0
  120. package/dist/types/host.d.ts +123 -0
  121. package/dist/types/host.d.ts.map +1 -0
  122. package/dist/types/host.js +1 -0
  123. package/dist/types/index.d.ts +19 -0
  124. package/dist/types/index.d.ts.map +1 -0
  125. package/dist/types/index.js +1 -0
  126. package/dist/types/inspector.d.ts +38 -0
  127. package/dist/types/inspector.d.ts.map +1 -0
  128. package/dist/types/inspector.js +1 -0
  129. package/dist/types/menus.d.ts +71 -0
  130. package/dist/types/menus.d.ts.map +1 -0
  131. package/dist/types/menus.js +1 -0
  132. package/dist/types/plugin.d.ts +133 -0
  133. package/dist/types/plugin.d.ts.map +1 -0
  134. package/dist/types/plugin.js +1 -0
  135. package/dist/types/preferences.d.ts +31 -0
  136. package/dist/types/preferences.d.ts.map +1 -0
  137. package/dist/types/preferences.js +1 -0
  138. package/dist/types/services.d.ts +175 -0
  139. package/dist/types/services.d.ts.map +1 -0
  140. package/dist/types/services.js +1 -0
  141. package/dist/types/shell.d.ts +47 -0
  142. package/dist/types/shell.d.ts.map +1 -0
  143. package/dist/types/shell.js +1 -0
  144. package/dist/types/toolbar.d.ts +59 -0
  145. package/dist/types/toolbar.d.ts.map +1 -0
  146. package/dist/types/toolbar.js +1 -0
  147. package/dist/types/view.d.ts +82 -0
  148. package/dist/types/view.d.ts.map +1 -0
  149. package/dist/types/view.js +1 -0
  150. package/dist/vue/components.d.ts +122 -0
  151. package/dist/vue/components.d.ts.map +1 -0
  152. package/dist/vue/components.js +112 -0
  153. package/dist/vue/index.d.ts +21 -0
  154. package/dist/vue/index.d.ts.map +1 -0
  155. package/dist/vue/index.js +47 -0
  156. package/dist/vue/mount.d.ts +9 -0
  157. package/dist/vue/mount.d.ts.map +1 -0
  158. package/dist/vue/mount.js +32 -0
  159. package/dist/vue/panel-action.d.ts +60 -0
  160. package/dist/vue/panel-action.d.ts.map +1 -0
  161. package/dist/vue/panel-action.js +28 -0
  162. package/package.json +92 -3
@@ -0,0 +1,123 @@
1
+ import type { HistoireJsonValue } from '@histoire/protocol';
2
+ import type { Disposer } from './common.js';
3
+ import type { WorkbenchContext } from './context.js';
4
+ import type { ContributionKind, ContributionOfKind, QualifiedContribution, WorkbenchContribution } from './contribution.js';
5
+ import type { WorkbenchPluginDefinition } from './plugin.js';
6
+ import type { StorageLike } from './preferences.js';
7
+ import type { ViewHost } from './view.js';
8
+ /** Plugin entry passed to a host, optionally with browser-visible options. */
9
+ export type ExtensionHostPlugin = WorkbenchPluginDefinition | {
10
+ definition: WorkbenchPluginDefinition;
11
+ options?: HistoireJsonValue;
12
+ };
13
+ /** Services a host builds plugin APIs from. Absent optional services become capabilities reported unavailable. */
14
+ export interface ExtensionHostServices {
15
+ /** Root-scoped context handed to plugins as `api.context`. */
16
+ context: WorkbenchContext;
17
+ /** Preference storage; memory fallback when absent. */
18
+ storage?: StorageLike;
19
+ /** Namespace separating preferences of different projects sharing one storage. */
20
+ storageNamespace?: string;
21
+ }
22
+ /** Options for `createExtensionHost`. */
23
+ export interface ExtensionHostOptions {
24
+ /** Plugins in config order. */
25
+ plugins: ReadonlyArray<ExtensionHostPlugin>;
26
+ /** Host services. */
27
+ services: ExtensionHostServices;
28
+ }
29
+ /**
30
+ * Phase in which a plugin failure happened. `callback` covers plugin callbacks the host
31
+ * invokes outside a view or action (availability predicates, preference listeners);
32
+ * `report` covers errors the plugin passed to `reportError`.
33
+ */
34
+ export type PluginDiagnosticPhase = 'load' | 'setup' | 'register' | 'mount' | 'update' | 'run' | 'dispose' | 'callback' | 'report';
35
+ /** Surface context a contribution kind's `available` predicate receives. */
36
+ export type ContributionContext<K extends ContributionKind> = ContributionOfKind<K> extends {
37
+ available?: (context: infer C) => boolean;
38
+ } ? C : never;
39
+ /** Per-invocation options of `ExtensionHost.run`. */
40
+ export interface ExtensionRunOptions {
41
+ /** Captured target scope; aborting it aborts the action and discards its result. */
42
+ signal?: AbortSignal;
43
+ }
44
+ /** Attributed plugin failure; never retried. */
45
+ export interface PluginDiagnostic {
46
+ /** Failing plugin. */
47
+ readonly pluginId: string;
48
+ /** Qualified contribution id, when the failure belongs to one. */
49
+ readonly contributionId?: string;
50
+ /** Lifecycle phase. */
51
+ readonly phase: PluginDiagnosticPhase;
52
+ /** Original error. */
53
+ readonly error: unknown;
54
+ }
55
+ /** View mounted by the host into a caller container. */
56
+ export interface MountedView {
57
+ /** Resolves once the view mounted, or rejects with its mount error. */
58
+ readonly ready: Promise<void>;
59
+ /** Pushes a new context snapshot; snapshots pushed while mounting are applied after it. */
60
+ update: (context: unknown) => void;
61
+ /** Disposes the view; safe to call repeatedly. */
62
+ dispose: () => Promise<void>;
63
+ }
64
+ /** View lifecycle phase a view failure belongs to. */
65
+ export type ViewFailurePhase = 'mount' | 'update';
66
+ /** Per-mount options of `ExtensionHost.mount`. */
67
+ export interface ViewMountOptions {
68
+ /**
69
+ * Element for the view's popovers and menus, inside the caller's theme scope.
70
+ * Defaults to an element appended to the container's document body for the view's lifetime.
71
+ */
72
+ overlayRoot?: HTMLElement;
73
+ /**
74
+ * Notified of each failure after it is recorded as a diagnostic, so the caller can show
75
+ * the error state for this view only. A failed update disposes the view.
76
+ */
77
+ onError?: (error: unknown, phase: ViewFailurePhase) => void;
78
+ /** Styled renderer behind the view's `ViewHost.renderState`; defaults to plain markup. */
79
+ renderState?: ViewHost['renderState'];
80
+ }
81
+ /** Per-workbench owner of plugin setup, registry, preferences, diagnostics and teardown. */
82
+ export interface ExtensionHost {
83
+ /** Resolves when all plugin setups settled (success or attributed failure). */
84
+ readonly ready: Promise<void>;
85
+ /** Ordered committed contributions of one kind; the same frozen array until a commit changes the kind. */
86
+ contributions: <K extends ContributionKind>(kind: K) => ReadonlyArray<QualifiedContribution<K>>;
87
+ /**
88
+ * Ordered committed contributions of one kind available in `context`: `available` passes and
89
+ * `devOnly` entries only for dev sources. A throwing predicate hides its contribution for good.
90
+ */
91
+ available: <K extends ContributionKind>(kind: K, context: ContributionContext<K>) => ReadonlyArray<QualifiedContribution<K>>;
92
+ /** Registers a `builtin:`-qualified contribution owned by the embedding app; plugins cannot use the namespace. */
93
+ registerBuiltin: (contribution: WorkbenchContribution) => Disposer;
94
+ /**
95
+ * Notified after registry commits (never per provisional registration), after root context
96
+ * changes (availability may change) and after new diagnostics.
97
+ */
98
+ subscribe: (listener: () => void) => Disposer;
99
+ /**
100
+ * Mounts the DOM `mount` view of a contribution into `container`. The view is disposed when
101
+ * the returned handle, its plugin or the host retires. Workbench Vue `component` views render
102
+ * through the embedding Vue app instead; mounting one rejects `ready`.
103
+ */
104
+ mount: (contributionId: string, container: HTMLElement, context: unknown, options?: ViewMountOptions) => MountedView;
105
+ /**
106
+ * Records a failure of a view the embedding app rendered itself (workbench Vue `component`
107
+ * views), attributed to the contribution's plugin. `report` is for errors the view passed to
108
+ * its `ViewHost.reportError`. Ignored for unknown contributions and after disposal.
109
+ */
110
+ reportViewError: (contributionId: string, error: unknown, phase: ViewFailurePhase | 'report') => void;
111
+ /**
112
+ * Runs an action contribution against a captured context. Frame-menu children are addressed
113
+ * as `${itemId}:${childId}` (`acme:export:json`). Rejects with the action error
114
+ * (also recorded as a diagnostic); resolves without a result when the plugin, the host or
115
+ * `options.signal` retired before the action settled.
116
+ */
117
+ run: (contributionId: string, context: unknown, options?: ExtensionRunOptions) => Promise<void>;
118
+ /** Attributed failures recorded so far. */
119
+ diagnostics: () => ReadonlyArray<PluginDiagnostic>;
120
+ /** Disposes every plugin and registration exactly once. */
121
+ dispose: () => Promise<void>;
122
+ }
123
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/types/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC3H,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAC3B,yBAAyB,GACzB;IAAE,UAAU,EAAE,yBAAyB,CAAC;IAAC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W,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,WAAW,CAAA;IACpH;;;;OAIG;IACH,eAAe,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,GAAG,QAAQ,KAAK,IAAI,CAAA;IACrG;;;;;OAKG;IACH,GAAG,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/F,2CAA2C;IAC3C,WAAW,EAAE,MAAM,aAAa,CAAC,gBAAgB,CAAC,CAAA;IAClD,2DAA2D;IAC3D,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ export type * from './actions.js';
2
+ export type * from './base.js';
3
+ export type * from './canvas.js';
4
+ export type * from './channel.js';
5
+ export type * from './commands.js';
6
+ export type * from './common.js';
7
+ export type * from './context.js';
8
+ export type * from './contribution.js';
9
+ export type * from './frame.js';
10
+ export type * from './host.js';
11
+ export type * from './inspector.js';
12
+ export type * from './menus.js';
13
+ export type * from './plugin.js';
14
+ export type * from './preferences.js';
15
+ export type * from './services.js';
16
+ export type * from './shell.js';
17
+ export type * from './toolbar.js';
18
+ export type * from './view.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,cAAc,CAAA;AACjC,mBAAmB,WAAW,CAAA;AAC9B,mBAAmB,aAAa,CAAA;AAChC,mBAAmB,cAAc,CAAA;AACjC,mBAAmB,eAAe,CAAA;AAClC,mBAAmB,aAAa,CAAA;AAChC,mBAAmB,cAAc,CAAA;AACjC,mBAAmB,mBAAmB,CAAA;AACtC,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,WAAW,CAAA;AAC9B,mBAAmB,gBAAgB,CAAA;AACnC,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,aAAa,CAAA;AAChC,mBAAmB,kBAAkB,CAAA;AACrC,mBAAmB,eAAe,CAAA;AAClC,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,cAAc,CAAA;AACjC,mBAAmB,WAAW,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { ContributionBase } from './base.js';
2
+ import type { WorkbenchIcon } from './common.js';
3
+ import type { FrameScopedContext } from './context.js';
4
+ import type { ContributionView } from './view.js';
5
+ /** Built-in inspector tabs that accept sections. */
6
+ export type BuiltinInspectorTab = 'builtin:props' | 'builtin:docs' | 'builtin:events' | 'builtin:tests';
7
+ /**
8
+ * Tab a section attaches to: a built-in tab, a qualified plugin tab (`acme:panel`),
9
+ * or `footer` (below every tab, before the Source drawer).
10
+ */
11
+ export type InspectorSectionTab = BuiltinInspectorTab | 'footer' | `${string}:${string}`;
12
+ /** Inspector tab appended after built-in tabs; bound to the selected frame. */
13
+ export type InspectorTabInput = ContributionBase<FrameScopedContext> & {
14
+ /** Visible tab label. */
15
+ label: string;
16
+ /** Tab icon. */
17
+ icon: WorkbenchIcon;
18
+ /** Local or same-plugin qualified command id; the host publishes its qualified identity. */
19
+ primaryCommand?: string;
20
+ /** Optional count or short text shown on the tab. */
21
+ badge?: (context: FrameScopedContext) => string | number | null | undefined;
22
+ } & ContributionView<FrameScopedContext>;
23
+ /** Section rendered before or after one inspector tab body. */
24
+ export type InspectorSectionInput = ContributionBase<FrameScopedContext> & {
25
+ /** Tab receiving the section; unqualified names are rejected. */
26
+ tab: InspectorSectionTab;
27
+ /** Placement around the tab body. */
28
+ position: 'before' | 'after';
29
+ } & ContributionView<FrameScopedContext>;
30
+ /** Registered inspector tab. */
31
+ export type InspectorTabContribution = InspectorTabInput & {
32
+ kind: 'inspector.tab';
33
+ };
34
+ /** Registered inspector section. */
35
+ export type InspectorSectionContribution = InspectorSectionInput & {
36
+ kind: 'inspector.section';
37
+ };
38
+ //# sourceMappingURL=inspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../src/types/inspector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD,oDAAoD;AACpD,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG,cAAc,GAAG,gBAAgB,GAAG,eAAe,CAAA;AAEvG;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,QAAQ,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAA;AAExF,+EAA+E;AAC/E,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,GAAG;IACrE,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,gBAAgB;IAChB,IAAI,EAAE,aAAa,CAAA;IACnB,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,qDAAqD;IACrD,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAC5E,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;AAExC,+DAA+D;AAC/D,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,GAAG;IACzE,iEAAiE;IACjE,GAAG,EAAE,mBAAmB,CAAA;IACxB,qCAAqC;IACrC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAA;CAC7B,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;AAExC,gCAAgC;AAChC,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAA;AAEpF,oCAAoC;AACpC,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,GAAG;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ import type { HistoireTarget } from '@histoire/protocol';
2
+ import type { ActionRun } from './actions.js';
3
+ import type { ContributionBase } from './base.js';
4
+ import type { WorkbenchIcon } from './common.js';
5
+ import type { FrameRef, FrameScopedContext, WorkbenchContext } from './context.js';
6
+ /** Nested frame menu entry. */
7
+ export interface FrameMenuChild {
8
+ /** Local id, unique among siblings, without whitespace or `:`; runnable as `${itemId}:${id}`. */
9
+ id: string;
10
+ /** Visible label. */
11
+ label: string;
12
+ /** Entry icon. */
13
+ icon: WorkbenchIcon;
14
+ /** Adjacent groups receive a separator. */
15
+ group?: string;
16
+ /** Action run on the right-clicked frame. */
17
+ run: ActionRun<FrameScopedContext>;
18
+ }
19
+ /** Entry in the frame context menu; runs against the right-clicked frame. */
20
+ export type FrameMenuItemInput = ContributionBase<FrameScopedContext> & {
21
+ /** Visible label. */
22
+ label: string;
23
+ /** Entry icon. */
24
+ icon: WorkbenchIcon;
25
+ /** Adjacent groups receive a separator. */
26
+ group?: string;
27
+ /** Optional submenu entries. */
28
+ children?: readonly FrameMenuChild[];
29
+ /** Action run on the right-clicked frame. */
30
+ run: ActionRun<FrameScopedContext>;
31
+ };
32
+ /** Existing workbench context-menu target kinds. */
33
+ export type ContextMenuTargetKind = 'frame' | 'story' | 'search-result' | 'test' | 'inspector' | 'toolbar' | 'folder' | 'test-group' | 'comment' | 'control';
34
+ /** Serializable description of the right-clicked target. */
35
+ export interface ContextMenuTarget {
36
+ /** Target kind. */
37
+ readonly kind: ContextMenuTargetKind;
38
+ /** Target label as shown in the workbench. */
39
+ readonly label: string;
40
+ /** Stable target key when the target has one. */
41
+ readonly key?: string;
42
+ /** Story/variant identity when the target carries one. */
43
+ readonly selection?: HistoireTarget;
44
+ /** Frame identity for frame-bound targets. */
45
+ readonly frame?: FrameRef;
46
+ }
47
+ /** Context passed to context-menu entries. */
48
+ export interface ContextMenuContext extends WorkbenchContext {
49
+ /** Right-clicked target, captured when the menu opened. */
50
+ readonly target: ContextMenuTarget;
51
+ }
52
+ /** Entry in the existing workbench context menu. */
53
+ export type ContextMenuItemInput = ContributionBase<ContextMenuContext> & {
54
+ /** Target kinds showing the entry. */
55
+ targets: readonly ContextMenuTargetKind[];
56
+ /** Visible label. */
57
+ label: string;
58
+ /** Optional entry icon. */
59
+ icon?: WorkbenchIcon;
60
+ /** Action run on the captured target. */
61
+ run: ActionRun<ContextMenuContext>;
62
+ };
63
+ /** Registered frame menu entry. */
64
+ export type FrameMenuItemContribution = FrameMenuItemInput & {
65
+ kind: 'frame-menu.item';
66
+ };
67
+ /** Registered context menu entry. */
68
+ export type ContextMenuItemContribution = ContextMenuItemInput & {
69
+ kind: 'context-menu.item';
70
+ };
71
+ //# sourceMappingURL=menus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menus.d.ts","sourceRoot":"","sources":["../../src/types/menus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAElF,+BAA+B;AAC/B,MAAM,WAAW,cAAc;IAC7B,iGAAiG;IACjG,EAAE,EAAE,MAAM,CAAA;IACV,qBAAqB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MAAM,oBAAoB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,GAAG;IACxE,sCAAsC;IACtC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAA;IACzC,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,2BAA2B;IAC3B,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,yCAAyC;IACzC,GAAG,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAA;CACnC,CAAA;AAED,mCAAmC;AACnC,MAAM,MAAM,yBAAyB,GAAG,kBAAkB,GAAG;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAExF,qCAAqC;AACrC,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,133 @@
1
+ import type { HistoireJsonValue } from '@histoire/protocol';
2
+ import type { CanvasFrameBadgeInput, CanvasFrameOverlayInput, CanvasOverlayInput, CanvasToolInput, CanvasViewInput } from './canvas.js';
3
+ import type { PluginChannel } from './channel.js';
4
+ import type { CommandInput, ShortcutInput } from './commands.js';
5
+ import type { Awaitable, Disposer } from './common.js';
6
+ import type { FrameRef, WorkbenchContext } from './context.js';
7
+ import type { WorkbenchContribution } from './contribution.js';
8
+ import type { InspectorSectionInput, InspectorTabInput } from './inspector.js';
9
+ import type { ContextMenuItemInput, FrameMenuItemInput } from './menus.js';
10
+ import type { PluginPreferences } from './preferences.js';
11
+ import type { HomeSectionInput, SettingsSectionInput, ShellPaneInput } from './shell.js';
12
+ import type { ToolbarItemInput } from './toolbar.js';
13
+ /** Frame with this plugin's frame module attached. */
14
+ export interface PluginFrameRef extends FrameRef {
15
+ /** Attached actor; a channel opened on this ref reaches exactly this actor. */
16
+ readonly actorId: string;
17
+ }
18
+ /** Same-origin browser window belonging to one currently attached frame actor. */
19
+ export interface PluginFrameWindow {
20
+ /** Frame's current window proxy. */
21
+ readonly window: Window;
22
+ /** Exact permitted origin of that window. */
23
+ readonly origin: string;
24
+ /** Current frame document identity. */
25
+ readonly documentId: string;
26
+ }
27
+ /**
28
+ * API passed to `setup`. Every helper returns a {@link Disposer}; registrations made after
29
+ * setup follow the same ownership and are disposed with the plugin.
30
+ */
31
+ export interface WorkbenchPluginApi {
32
+ /** Plugin id. */
33
+ readonly id: string;
34
+ /** Browser-visible options from the plugin descriptor. */
35
+ readonly options: HistoireJsonValue | undefined;
36
+ /** Root-scoped context; surfaces receive narrower scopes. */
37
+ readonly context: WorkbenchContext;
38
+ /** Plugin-scoped JSON preferences. */
39
+ readonly preferences: PluginPreferences;
40
+ /** Aborted when the plugin is disposed or its host retires. */
41
+ readonly signal: AbortSignal;
42
+ /** Generic registration; the helpers below are typed sugar over it. */
43
+ contribute: (contribution: WorkbenchContribution) => Disposer;
44
+ /** Inspector tabs and sections. */
45
+ inspector: {
46
+ /** Adds a tab after built-in tabs. */
47
+ addTab: (tab: InspectorTabInput) => Disposer;
48
+ /** Adds a section around a tab body. */
49
+ addSection: (section: InspectorSectionInput) => Disposer;
50
+ };
51
+ /** Canvas toolbar. */
52
+ toolbar: {
53
+ /** Adds an item to an overflow group. */
54
+ addItem: (item: ToolbarItemInput) => Disposer;
55
+ };
56
+ /** Command search. */
57
+ commands: {
58
+ /** Adds a command. */
59
+ add: (command: CommandInput) => Disposer;
60
+ };
61
+ /** Keyboard shortcuts. */
62
+ shortcuts: {
63
+ /** Binds keys to a qualified command id. */
64
+ add: (shortcut: ShortcutInput) => Disposer;
65
+ };
66
+ /** Context menus. */
67
+ menus: {
68
+ /** Adds a frame context menu entry. */
69
+ addFrameAction: (item: FrameMenuItemInput) => Disposer;
70
+ /** Adds a workbench context menu entry. */
71
+ addContextAction: (item: ContextMenuItemInput) => Disposer;
72
+ };
73
+ /** Canvas layers, tools and arrangements. */
74
+ canvas: {
75
+ /** Adds a viewport or canvas overlay. */
76
+ addOverlay: (overlay: CanvasOverlayInput) => Disposer;
77
+ /** Adds an overlay instantiated per frame. */
78
+ addFrameOverlay: (overlay: CanvasFrameOverlayInput) => Disposer;
79
+ /** Adds a badge to every frame header (counts, statuses). */
80
+ addFrameBadge: (badge: CanvasFrameBadgeInput) => Disposer;
81
+ /** Adds a tool to the tool switch. */
82
+ addTool: (tool: CanvasToolInput) => Disposer;
83
+ /** Adds an arrangement beside Grid, List and Matrix. */
84
+ addView: (view: CanvasViewInput) => Disposer;
85
+ };
86
+ /** Workbench shell rail. */
87
+ shell: {
88
+ /** Adds a rail pane. */
89
+ addPane: (pane: ShellPaneInput) => Disposer;
90
+ };
91
+ /** Settings page. */
92
+ settings: {
93
+ /** Adds a settings section. */
94
+ addSection: (section: SettingsSectionInput) => Disposer;
95
+ };
96
+ /** Home page. */
97
+ home: {
98
+ /** Adds a home section. */
99
+ addSection: (section: HomeSectionInput) => Disposer;
100
+ };
101
+ /** Frames running this plugin's frame module. */
102
+ frames: {
103
+ /** Frames with this plugin attached. */
104
+ list: () => ReadonlyArray<PluginFrameRef>;
105
+ /** Opens a channel bound to the exact actor of `frame`. */
106
+ open: (frame: FrameRef) => PluginChannel;
107
+ /** Resolves an attached actor's same-origin window, if the host supports it. */
108
+ window: (frame: PluginFrameRef) => PluginFrameWindow | undefined;
109
+ /**
110
+ * Observes attach and detach of this plugin's frames (`list()` changed). Released with the
111
+ * plugin; never fires in hosts without frame messaging.
112
+ */
113
+ subscribe: (listener: () => void) => Disposer;
114
+ };
115
+ /** Records a diagnostic attributed to this plugin. */
116
+ reportError: (error: unknown) => void;
117
+ /**
118
+ * Signals that plugin-internal state read by `badge`, `pressed` or `available` callbacks
119
+ * changed: every surface re-reads them (host subscribers are notified). Registry, context and
120
+ * preference changes already do this. No-op once the plugin retired.
121
+ */
122
+ invalidate: () => void;
123
+ }
124
+ /** Shape accepted by `defineWorkbenchPlugin`. */
125
+ export interface WorkbenchPluginDefinition {
126
+ /** Plugin id; must match the descriptor id. */
127
+ readonly id: string;
128
+ /** Extension contract version; only `1` exists. */
129
+ readonly apiVersion: 1;
130
+ /** Runs once per extension host. Registrations made before it settles commit atomically. */
131
+ readonly setup: (api: WorkbenchPluginApi) => Awaitable<void | Disposer>;
132
+ }
133
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEpD,sDAAsD;AACtD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,kFAAkF;AAClF,MAAM,WAAW,iB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GG;QACH,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,QAAQ,CAAA;KAC9C,CAAA;IACD,sDAAsD;IACtD,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC;;;;OAIG;IACH,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,iDAAiD;AACjD,MAAM,WAAW,yBAAyB;IACxC,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,mDAAmD;IACnD,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IACtB,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAA;CACxE"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { HistoireJsonValue } from '@histoire/protocol';
2
+ import type { Disposer } from './common.js';
3
+ /**
4
+ * Plugin-scoped JSON preferences. Standalone persists under a plugin and project namespace;
5
+ * embedded hosts persist only when they inject storage. Never saved to project config.
6
+ */
7
+ export interface PluginPreferences {
8
+ /** Reads a stored value, or `fallback` when absent or unreadable. */
9
+ get: <T extends HistoireJsonValue>(key: string, fallback: T) => T;
10
+ /** Stores a JSON value and notifies subscribers of `key`. */
11
+ set: (key: string, value: HistoireJsonValue) => void;
12
+ /** Observes changes to one key. */
13
+ subscribe: (key: string, listener: (value: HistoireJsonValue) => void) => Disposer;
14
+ }
15
+ /** Minimal synchronous storage injected by hosts (compatible with `window.localStorage`). */
16
+ export interface StorageLike {
17
+ /** Reads a raw string value or `null`. */
18
+ getItem: (key: string) => string | null;
19
+ /** Writes a raw string value. */
20
+ setItem: (key: string, value: string) => void;
21
+ /** Removes a value. */
22
+ removeItem: (key: string) => void;
23
+ /**
24
+ * Optional: observes changes made outside this host (another tab or window), like the
25
+ * `storage` event. `key` is the changed key, or `null` when the storage was cleared. Without
26
+ * it, preference subscribers only see writes of their own host.
27
+ * @returns Stops observing; called when the host is disposed.
28
+ */
29
+ subscribe?: (listener: (key: string | null) => void) => Disposer;
30
+ }
31
+ //# sourceMappingURL=preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../../src/types/preferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,GAAG,EAAE,CAAC,CAAC,SAAS,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAA;IACjE,6DAA6D;IAC7D,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACpD,mCAAmC;IACnC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,KAAK,QAAQ,CAAA;CACnF;AAED,6FAA6F;AAC7F,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;IACvC,iCAAiC;IACjC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7C,uBAAuB;IACvB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,KAAK,QAAQ,CAAA;CACjE"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,175 @@
1
+ import type { HistoireCatalogStory, HistoireJsonValue, HistoireReadonly, HistoireRect, HistoireSearchResult, HistoireSelectionInput, HistoireTarget, HistoireTestRunSummary } from '@histoire/protocol';
2
+ import type { Disposer } from './common.js';
3
+ import type { FrameRef } from './context.js';
4
+ /** Metadata-only catalog access, mirroring `HistoireSession.catalog`. */
5
+ export interface CatalogService {
6
+ /** Reads the completed source catalog. */
7
+ list: () => Promise<readonly HistoireCatalogStory[]>;
8
+ /** Resolves one exact story. */
9
+ getStory: (storyId: string) => Promise<HistoireCatalogStory>;
10
+ /** Searches titles and docs without mounting stories. */
11
+ search: (query: string) => Promise<readonly HistoireSearchResult[]>;
12
+ /**
13
+ * Notified after each catalog publication (story edits in dev); re-read stories from the
14
+ * catalog. Absent on hosts that cannot observe publications.
15
+ */
16
+ subscribe?: (listener: () => void) => Disposer;
17
+ }
18
+ /**
19
+ * Workbench navigation. Ids are qualified plugin ids (`acme:panel`) or `builtin:` ids.
20
+ * Unknown ids are ignored with a diagnostic once the host is ready.
21
+ */
22
+ export interface NavigationService {
23
+ /** Selects a story or variant. */
24
+ selectStory: (input: HistoireSelectionInput) => Promise<void>;
25
+ /** Opens an inspector tab. */
26
+ openInspectorTab: (tabId: string) => void;
27
+ /** Opens a rail pane. */
28
+ openPane: (paneId: string) => void;
29
+ /** Opens settings, optionally at one section. */
30
+ openSettings: (sectionId?: string) => void;
31
+ /** Switches the canvas arrangement to a built-in or plugin view. */
32
+ openCanvasView: (viewId: string) => void;
33
+ }
34
+ /** Plugin events forwarded to the Node `onDevEvent` hook over the dev transport. */
35
+ export interface DevEventService {
36
+ /** Sends one event and resolves with the Node hook's result. */
37
+ send: (event: string, payload?: HistoireJsonValue) => Promise<unknown>;
38
+ }
39
+ /** Latest test facts of one variant. */
40
+ export interface TestsEntry {
41
+ /** Variant the facts belong to. */
42
+ readonly target: HistoireTarget;
43
+ /** Latest completed run of the variant, `null` before its first run. */
44
+ readonly summary: HistoireReadonly<HistoireTestRunSummary> | null;
45
+ /** A run including this variant is in progress. */
46
+ readonly running: boolean;
47
+ /** Sources changed since the summary was produced. */
48
+ readonly stale: boolean;
49
+ /** Message of a failure that kept the variant from reporting, `null` otherwise. */
50
+ readonly error: string | null;
51
+ }
52
+ /**
53
+ * Project test runs shared with the workbench Tests pane (same results, same execution lane).
54
+ * Present only where the host can run tests (dev server).
55
+ */
56
+ export interface TestsService {
57
+ /** Variants that reported or are running, in no particular order. */
58
+ entries: () => ReadonlyArray<TestsEntry>;
59
+ /** A run is in progress. */
60
+ readonly running: boolean;
61
+ /** Runs can start now (server tests available, source ready). */
62
+ readonly canRun: boolean;
63
+ /**
64
+ * Progress of the current run; `null` when idle or unknown. Server runs wait to start (`queued`,
65
+ * for example behind other test work), collect stories (`collect`, counted in stories), then run
66
+ * assertions (`run`, counted in variants).
67
+ */
68
+ readonly progress: {
69
+ readonly phase: 'queued' | 'collect' | 'run';
70
+ readonly completed: number;
71
+ readonly total: number;
72
+ } | null;
73
+ /** Failure of the latest run as a whole (not of single tests), `null` otherwise. */
74
+ readonly error: string | null;
75
+ /** Runs every selectable variant, like the Tests pane "Run all". */
76
+ runAll: () => Promise<void>;
77
+ /** Runs one variant. */
78
+ run: (target: HistoireTarget) => Promise<void>;
79
+ /** Notified after entries or run state change; read fresh values from the service. */
80
+ subscribe: (listener: () => void) => Disposer;
81
+ }
82
+ /** Point in CSS pixels. */
83
+ export interface CanvasPoint {
84
+ /** Horizontal position. */
85
+ x: number;
86
+ /** Vertical position. */
87
+ y: number;
88
+ }
89
+ /** Geometry of one frame laid out on the canvas. */
90
+ export interface CanvasFrameGeometry {
91
+ /** Frame identity. */
92
+ readonly frame: FrameRef;
93
+ /** Frame document box: position in canvas space, size in the document's CSS pixels. */
94
+ readonly rect: HistoireRect;
95
+ }
96
+ /** Why a frame lease was refused or ended before readiness. */
97
+ export type FrameLeaseFailureReason =
98
+ /** Every live frame slot of the viewport is taken; the selected frame keeps the last one. */
99
+ 'budget'
100
+ /** Released (or its signal aborted) before it was granted or became ready. */
101
+ | 'released'
102
+ /** The canvas viewport went away. */
103
+ | 'unavailable';
104
+ /** Rejection value of `acquireFrame` and of `FrameLease.ready` after release. */
105
+ export interface FrameLeaseError extends Error {
106
+ /** Always `FrameLeaseError`. */
107
+ readonly name: 'FrameLeaseError';
108
+ /** Failure category. */
109
+ readonly reason: FrameLeaseFailureReason;
110
+ }
111
+ /** Managed story frame acquired through the canvas frame budget. */
112
+ export interface FrameLease {
113
+ /** Frame identity, registered in the workbench frame registry; distinct per lease. */
114
+ readonly frame: FrameRef;
115
+ /**
116
+ * Resolves once the frame rendered its variant. Rejects with the startup error, or with a
117
+ * `FrameLeaseError` (`released`) when released first.
118
+ */
119
+ readonly ready: Promise<void>;
120
+ /** Releases the frame and disposes its session exactly once; cancels pending startup. Idempotent. */
121
+ release: () => void;
122
+ }
123
+ /** Options for acquiring a managed frame. */
124
+ export interface FrameLeaseOptions {
125
+ /** Element receiving the frame document; the plugin owns its placement and size. */
126
+ container: HTMLElement;
127
+ /**
128
+ * Logical box registered for coordinate conversion, frame overlays and `frames()`: position
129
+ * in canvas space, size in the frame document's CSS pixels. Defaults to the container's
130
+ * size at the canvas origin.
131
+ */
132
+ rect?: HistoireRect;
133
+ /** Wait for a free slot instead of rejecting with `budget` when the viewport budget is full. */
134
+ queue?: boolean;
135
+ /** Aborting releases the lease, or withdraws a queued request. */
136
+ signal?: AbortSignal;
137
+ }
138
+ /**
139
+ * Readonly geometry, coordinate transforms and frame leases of one canvas viewport.
140
+ * Getters read live values; subscribe to re-read after changes.
141
+ */
142
+ export interface CanvasService {
143
+ /** Effective zoom factor. */
144
+ readonly zoom: number;
145
+ /** Canvas translation in viewport pixels. */
146
+ readonly pan: Readonly<CanvasPoint>;
147
+ /** Viewport box in client coordinates. */
148
+ readonly viewport: Readonly<HistoireRect>;
149
+ /** Converts a viewport-local point to canvas space. */
150
+ toCanvas: (point: CanvasPoint) => CanvasPoint;
151
+ /** Converts a canvas-space point to viewport-local coordinates. */
152
+ toViewport: (point: CanvasPoint) => CanvasPoint;
153
+ /**
154
+ * Converts a point in one frame document's CSS pixels to viewport-local coordinates using
155
+ * the frame's rendered box, so it follows pan, zoom, scroll and rotation. `null` while the
156
+ * frame has no rendered document.
157
+ */
158
+ frameToViewport: (frameKey: string, point: CanvasPoint) => CanvasPoint | null;
159
+ /**
160
+ * Converts a viewport-local point to the exact frame document's CSS pixels. Returns `null`
161
+ * while the frame has no rendered document. Coordinates follow the rendered frame box.
162
+ * Older or external hosts may omit this capability.
163
+ */
164
+ viewportToFrame?: (frameKey: string, point: CanvasPoint) => CanvasPoint | null;
165
+ /** Frames currently registered on this canvas, including leased ones. */
166
+ frames: () => ReadonlyArray<CanvasFrameGeometry>;
167
+ /**
168
+ * Acquires a managed frame through the viewport budget and startup queue. Rejects with a
169
+ * `FrameLeaseError` (`budget`) when denied and `queue` is not set.
170
+ */
171
+ acquireFrame: (target: HistoireTarget, options: FrameLeaseOptions) => Promise<FrameLease>;
172
+ /** Notified after geometry or frame list changes. */
173
+ subscribe: (listener: () => void) => Disposer;
174
+ }
175
+ //# sourceMappingURL=services.d.ts.map