@histoire/vue 0.0.0-stage → 1.0.0-beta.3

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 (204) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/controls/GenericControls.d.ts +30 -0
  3. package/dist/components/controls/GenericControls.d.ts.map +1 -0
  4. package/dist/components/controls/GenericControls.js +34 -0
  5. package/dist/components/controls/HistoireControls.d.ts +30 -0
  6. package/dist/components/controls/HistoireControls.d.ts.map +1 -0
  7. package/dist/components/controls/HistoireControls.js +176 -0
  8. package/dist/components/controls/PresetMenu.d.ts +63 -0
  9. package/dist/components/controls/PresetMenu.d.ts.map +1 -0
  10. package/dist/components/controls/PresetMenu.js +180 -0
  11. package/dist/components/controls/PropControl.d.ts +40 -0
  12. package/dist/components/controls/PropControl.d.ts.map +1 -0
  13. package/dist/components/controls/PropControl.js +66 -0
  14. package/dist/components/controls/StateControl.d.ts +15 -0
  15. package/dist/components/controls/StateControl.d.ts.map +1 -0
  16. package/dist/components/controls/StateControl.js +30 -0
  17. package/dist/components/controls/StatePresets.d.ts +37 -0
  18. package/dist/components/controls/StatePresets.d.ts.map +1 -0
  19. package/dist/components/controls/StatePresets.js +105 -0
  20. package/dist/components/controls/edit.d.ts +10 -0
  21. package/dist/components/controls/edit.d.ts.map +1 -0
  22. package/dist/components/controls/edit.js +82 -0
  23. package/dist/components/controls/editor.d.ts +9 -0
  24. package/dist/components/controls/editor.d.ts.map +1 -0
  25. package/dist/components/controls/editor.js +28 -0
  26. package/dist/components/docs/HistoireDocs.d.ts +44 -0
  27. package/dist/components/docs/HistoireDocs.d.ts.map +1 -0
  28. package/dist/components/docs/HistoireDocs.js +124 -0
  29. package/dist/components/docs/anchors.d.ts +3 -0
  30. package/dist/components/docs/anchors.d.ts.map +1 -0
  31. package/dist/components/docs/anchors.js +26 -0
  32. package/dist/components/docs/content.d.ts +11 -0
  33. package/dist/components/docs/content.d.ts.map +1 -0
  34. package/dist/components/docs/content.js +7 -0
  35. package/dist/components/docs/links.d.ts +20 -0
  36. package/dist/components/docs/links.d.ts.map +1 -0
  37. package/dist/components/docs/links.js +85 -0
  38. package/dist/components/docs/sanitize.d.ts +3 -0
  39. package/dist/components/docs/sanitize.d.ts.map +1 -0
  40. package/dist/components/docs/sanitize.js +16 -0
  41. package/dist/components/embed/EmbedPanels.d.ts +21 -0
  42. package/dist/components/embed/EmbedPanels.d.ts.map +1 -0
  43. package/dist/components/embed/EmbedPanels.js +49 -0
  44. package/dist/components/embed/HistoireEmbed.d.ts +47 -0
  45. package/dist/components/embed/HistoireEmbed.d.ts.map +1 -0
  46. package/dist/components/embed/HistoireEmbed.js +83 -0
  47. package/dist/components/embed/geometry.d.ts +5 -0
  48. package/dist/components/embed/geometry.d.ts.map +1 -0
  49. package/dist/components/embed/geometry.js +38 -0
  50. package/dist/components/events/HistoireEvents.d.ts +30 -0
  51. package/dist/components/events/HistoireEvents.d.ts.map +1 -0
  52. package/dist/components/events/HistoireEvents.js +88 -0
  53. package/dist/components/explorer/ExplorerNavigation.d.ts +20 -0
  54. package/dist/components/explorer/ExplorerNavigation.d.ts.map +1 -0
  55. package/dist/components/explorer/ExplorerNavigation.js +15 -0
  56. package/dist/components/explorer/ExplorerPanels.d.ts +42 -0
  57. package/dist/components/explorer/ExplorerPanels.d.ts.map +1 -0
  58. package/dist/components/explorer/ExplorerPanels.js +87 -0
  59. package/dist/components/explorer/ExplorerPreview.d.ts +29 -0
  60. package/dist/components/explorer/ExplorerPreview.d.ts.map +1 -0
  61. package/dist/components/explorer/ExplorerPreview.js +93 -0
  62. package/dist/components/explorer/HistoireExplorer.d.ts +47 -0
  63. package/dist/components/explorer/HistoireExplorer.d.ts.map +1 -0
  64. package/dist/components/explorer/HistoireExplorer.js +41 -0
  65. package/dist/components/explorer/panel-tabs.d.ts +48 -0
  66. package/dist/components/explorer/panel-tabs.d.ts.map +1 -0
  67. package/dist/components/explorer/panel-tabs.js +58 -0
  68. package/dist/components/extensions/HistoireExtensionOutlet.d.ts +47 -0
  69. package/dist/components/extensions/HistoireExtensionOutlet.d.ts.map +1 -0
  70. package/dist/components/extensions/HistoireExtensionOutlet.js +35 -0
  71. package/dist/components/extensions/HistoireExtensionView.d.ts +59 -0
  72. package/dist/components/extensions/HistoireExtensionView.d.ts.map +1 -0
  73. package/dist/components/extensions/HistoireExtensionView.js +58 -0
  74. package/dist/components/extensions/panel-action.d.ts +38 -0
  75. package/dist/components/extensions/panel-action.d.ts.map +1 -0
  76. package/dist/components/extensions/panel-action.js +19 -0
  77. package/dist/components/extensions/state-renderer.d.ts +17 -0
  78. package/dist/components/extensions/state-renderer.d.ts.map +1 -0
  79. package/dist/components/extensions/state-renderer.js +72 -0
  80. package/dist/components/extensions/view-lifecycle.d.ts +47 -0
  81. package/dist/components/extensions/view-lifecycle.d.ts.map +1 -0
  82. package/dist/components/extensions/view-lifecycle.js +108 -0
  83. package/dist/components/extensions/workbench-components.d.ts +9 -0
  84. package/dist/components/extensions/workbench-components.d.ts.map +1 -0
  85. package/dist/components/extensions/workbench-components.js +82 -0
  86. package/dist/components/preview/HistoirePreview.d.ts +23 -0
  87. package/dist/components/preview/HistoirePreview.d.ts.map +1 -0
  88. package/dist/components/preview/HistoirePreview.js +3 -0
  89. package/dist/components/preview/surface.d.ts +27 -0
  90. package/dist/components/preview/surface.d.ts.map +1 -0
  91. package/dist/components/preview/surface.js +133 -0
  92. package/dist/components/search/HistoireSearch.d.ts +9 -0
  93. package/dist/components/search/HistoireSearch.d.ts.map +1 -0
  94. package/dist/components/search/HistoireSearch.js +66 -0
  95. package/dist/components/source/HistoireSource.d.ts +58 -0
  96. package/dist/components/source/HistoireSource.d.ts.map +1 -0
  97. package/dist/components/source/HistoireSource.js +85 -0
  98. package/dist/components/source/content.d.ts +11 -0
  99. package/dist/components/source/content.d.ts.map +1 -0
  100. package/dist/components/source/content.js +7 -0
  101. package/dist/components/source/highlight.d.ts +3 -0
  102. package/dist/components/source/highlight.d.ts.map +1 -0
  103. package/dist/components/source/highlight.js +15 -0
  104. package/dist/components/source/render.d.ts +6 -0
  105. package/dist/components/source/render.d.ts.map +1 -0
  106. package/dist/components/source/render.js +11 -0
  107. package/dist/components/tests/HistoireTests.d.ts +66 -0
  108. package/dist/components/tests/HistoireTests.d.ts.map +1 -0
  109. package/dist/components/tests/HistoireTests.js +109 -0
  110. package/dist/components/tests/TestsRunActions.d.ts +54 -0
  111. package/dist/components/tests/TestsRunActions.d.ts.map +1 -0
  112. package/dist/components/tests/TestsRunActions.js +138 -0
  113. package/dist/components/tests/render.d.ts +33 -0
  114. package/dist/components/tests/render.d.ts.map +1 -0
  115. package/dist/components/tests/render.js +103 -0
  116. package/dist/components/toolbar/HistoireToolbar.d.ts +7 -0
  117. package/dist/components/toolbar/HistoireToolbar.d.ts.map +1 -0
  118. package/dist/components/toolbar/HistoireToolbar.js +66 -0
  119. package/dist/components/toolbar/ToolbarExtensions.d.ts +27 -0
  120. package/dist/components/toolbar/ToolbarExtensions.d.ts.map +1 -0
  121. package/dist/components/toolbar/ToolbarExtensions.js +79 -0
  122. package/dist/components/toolbar/groups.d.ts +19 -0
  123. package/dist/components/toolbar/groups.d.ts.map +1 -0
  124. package/dist/components/toolbar/groups.js +18 -0
  125. package/dist/components/tree/HistoireStoryTree.d.ts +40 -0
  126. package/dist/components/tree/HistoireStoryTree.d.ts.map +1 -0
  127. package/dist/components/tree/HistoireStoryTree.js +57 -0
  128. package/dist/composables/session.d.ts +4 -0
  129. package/dist/composables/session.d.ts.map +1 -0
  130. package/dist/composables/session.js +5 -0
  131. package/dist/composables/snapshot.d.ts +5 -0
  132. package/dist/composables/snapshot.d.ts.map +1 -0
  133. package/dist/composables/snapshot.js +9 -0
  134. package/dist/content/controller.d.ts +20 -0
  135. package/dist/content/controller.d.ts.map +1 -0
  136. package/dist/content/controller.js +54 -0
  137. package/dist/content.css +22 -0
  138. package/dist/controls.css +26 -0
  139. package/dist/embed.css +15 -0
  140. package/dist/explorer.css +67 -0
  141. package/dist/extensions.css +20 -0
  142. package/dist/foundation/VirtualList.d.ts +114 -0
  143. package/dist/foundation/VirtualList.d.ts.map +1 -0
  144. package/dist/foundation/VirtualList.js +126 -0
  145. package/dist/foundation/floating.d.ts +9 -0
  146. package/dist/foundation/floating.d.ts.map +1 -0
  147. package/dist/foundation/floating.js +90 -0
  148. package/dist/foundation/parts.d.ts +13 -0
  149. package/dist/foundation/parts.d.ts.map +1 -0
  150. package/dist/foundation/parts.js +13 -0
  151. package/dist/index.d.ts +18 -0
  152. package/dist/index.d.ts.map +1 -0
  153. package/dist/index.js +15 -0
  154. package/dist/internal.d.ts +31 -0
  155. package/dist/internal.d.ts.map +1 -0
  156. package/dist/internal.js +26 -0
  157. package/dist/navigation.css +51 -0
  158. package/dist/overlays/OverlayHost.d.ts +21 -0
  159. package/dist/overlays/OverlayHost.d.ts.map +1 -0
  160. package/dist/overlays/OverlayHost.js +118 -0
  161. package/dist/overlays/geometry.d.ts +4 -0
  162. package/dist/overlays/geometry.d.ts.map +1 -0
  163. package/dist/overlays/geometry.js +7 -0
  164. package/dist/overlays/menu-bounds.d.ts +10 -0
  165. package/dist/overlays/menu-bounds.d.ts.map +1 -0
  166. package/dist/overlays/menu-bounds.js +52 -0
  167. package/dist/provider/HistoireProvider.d.ts +43 -0
  168. package/dist/provider/HistoireProvider.d.ts.map +1 -0
  169. package/dist/provider/HistoireProvider.js +183 -0
  170. package/dist/provider/context.d.ts +37 -0
  171. package/dist/provider/context.d.ts.map +1 -0
  172. package/dist/provider/context.js +16 -0
  173. package/dist/provider/extensions.d.ts +61 -0
  174. package/dist/provider/extensions.d.ts.map +1 -0
  175. package/dist/provider/extensions.js +139 -0
  176. package/dist/provider/panels.d.ts +33 -0
  177. package/dist/provider/panels.d.ts.map +1 -0
  178. package/dist/provider/panels.js +53 -0
  179. package/dist/provider/plugin-shortcuts.d.ts +22 -0
  180. package/dist/provider/plugin-shortcuts.d.ts.map +1 -0
  181. package/dist/provider/plugin-shortcuts.js +73 -0
  182. package/dist/provider/shortcuts.d.ts +16 -0
  183. package/dist/provider/shortcuts.d.ts.map +1 -0
  184. package/dist/provider/shortcuts.js +62 -0
  185. package/dist/provider/theme.d.ts +4 -0
  186. package/dist/provider/theme.d.ts.map +1 -0
  187. package/dist/provider/theme.js +25 -0
  188. package/dist/search/navigation.d.ts +27 -0
  189. package/dist/search/navigation.d.ts.map +1 -0
  190. package/dist/search/navigation.js +61 -0
  191. package/dist/style.css +88 -0
  192. package/dist/tests/collector.d.ts +16 -0
  193. package/dist/tests/collector.d.ts.map +1 -0
  194. package/dist/tests/collector.js +51 -0
  195. package/dist/tests/controller.d.ts +28 -0
  196. package/dist/tests/controller.d.ts.map +1 -0
  197. package/dist/tests/controller.js +79 -0
  198. package/dist/tests/model.d.ts +20 -0
  199. package/dist/tests/model.d.ts.map +1 -0
  200. package/dist/tests/model.js +18 -0
  201. package/dist/tests.css +59 -0
  202. package/dist/virtual-list.css +6 -0
  203. package/package.json +58 -3
  204. package/README.md +0 -3
@@ -0,0 +1,37 @@
1
+ import type { HistoireSession } from '@histoire/sdk';
2
+ import type { InjectionKey, Ref, ShallowRef } from 'vue';
3
+ import type { HistoireProviderExtensions } from './extensions.js';
4
+ import type { createHistoirePanelNavigation } from './panels.js';
5
+ /** Provider container dimensions; responsive panels use these instead of window size. */
6
+ export interface HistoireContainerSize {
7
+ /** Available content width in CSS pixels. */
8
+ width: number;
9
+ /** Available content height in CSS pixels. */
10
+ height: number;
11
+ }
12
+ /** Shared local ownership for native parts; internal entry is first-party only. */
13
+ export interface HistoireVueContext {
14
+ /** Explicit caller-owned controller; provider never disposes it. */
15
+ session: HistoireSession;
16
+ /** Native root, absent until client mount. */
17
+ root: ShallowRef<HTMLElement | null>;
18
+ /** Local teleport target shared by controls and panels. */
19
+ overlay: ShallowRef<HTMLElement | null>;
20
+ /** Observed provider content box. */
21
+ size: Readonly<Ref<Readonly<HistoireContainerSize>>>;
22
+ /** Source/selection-owned local panel activation; independent parts require no router. */
23
+ panels: ReturnType<typeof createHistoirePanelNavigation>;
24
+ /** Own idempotent teardown; returned disposer observes asynchronous rejection. */
25
+ own: (cleanup: () => void | Promise<void>) => () => void;
26
+ /** Report typed child failures through provider's error event. */
27
+ reportError: (error: unknown) => void;
28
+ /** Plugin surfaces: caller-owned host (own or inherited), surface contexts, registry reads. */
29
+ extensions: HistoireProviderExtensions;
30
+ }
31
+ /** Each Vue tree owns its context; no active provider or controller globals. */
32
+ export declare const histoireContextKey: InjectionKey<HistoireVueContext>;
33
+ /** Resolve current provider with clear setup failure for independent parts. */
34
+ export declare function useHistoireContext(): HistoireVueContext;
35
+ /** Bind resource to both child scope and provider teardown, cleaning exactly once. */
36
+ export declare function useHistoireResource(cleanup: () => void | Promise<void>): () => void;
37
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/provider/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAGhE,yFAAyF;AACzF,MAAM,WAAW,qBAAqB;IACpC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;CACf;AAED,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,OAAO,EAAE,eAAe,CAAA;IACxB,8CAA8C;IAC9C,IAAI,EAAE,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACpC,2DAA2D;IAC3D,OAAO,EAAE,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACvC,qCAAqC;IACrC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;IACpD,0FAA0F;IAC1F,MAAM,EAAE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAA;IACxD,kFAAkF;IAClF,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,MAAM,IAAI,CAAA;IACxD,kEAAkE;IAClE,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,+FAA+F;IAC/F,UAAU,EAAE,0BAA0B,CAAA;CACvC;AAED,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,kBAAkB,CAA8B,CAAA;AAE9F,+EAA+E;AAC/E,wBAAgB,kBAAkB,IAAI,kBAAkB,CAIvD;AAED,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,CAInF"}
@@ -0,0 +1,16 @@
1
+ import { inject, onScopeDispose } from 'vue';
2
+ /** Each Vue tree owns its context; no active provider or controller globals. */
3
+ export const histoireContextKey = Symbol('HistoireProvider');
4
+ /** Resolve current provider with clear setup failure for independent parts. */
5
+ export function useHistoireContext() {
6
+ const context = inject(histoireContextKey);
7
+ if (!context)
8
+ throw new Error('HistoireProvider is required');
9
+ return context;
10
+ }
11
+ /** Bind resource to both child scope and provider teardown, cleaning exactly once. */
12
+ export function useHistoireResource(cleanup) {
13
+ const dispose = useHistoireContext().own(cleanup);
14
+ onScopeDispose(dispose);
15
+ return dispose;
16
+ }
@@ -0,0 +1,61 @@
1
+ import type { ContributionContext, ContributionKind, ExtensionHost, FrameScopedContext, QualifiedContribution, WorkbenchContext } from '@histoire/plugin-kit';
2
+ import type { HistoireSession } from '@histoire/sdk';
3
+ import type { InjectionKey } from 'vue';
4
+ import type { createHistoirePanelNavigation } from './panels.js';
5
+ /** Extension host binding nested providers inherit when they get no `extensions` prop. */
6
+ export interface HistoireExtensionsBinding {
7
+ /** Nearest caller-owned extension host, if any. */
8
+ readonly host: ExtensionHost | undefined;
9
+ }
10
+ /** Injection key of the inherited extension host (nested selected-frame providers reuse it). */
11
+ export declare const histoireExtensionsKey: InjectionKey<HistoireExtensionsBinding>;
12
+ /**
13
+ * Hands a caller-owned host to descendant providers without an `extensions` prop. First-party
14
+ * workbenches that create their host below their root provider call this.
15
+ * @param host Host, or a getter of the current host.
16
+ */
17
+ export declare function provideHistoireExtensions(host: ExtensionHost | undefined | (() => ExtensionHost | undefined)): void;
18
+ /** Plugin surfaces of one provider: host, surface contexts and reactive registry reads. */
19
+ export interface HistoireProviderExtensions {
20
+ /** Caller-owned host (own prop or inherited); never disposed by the provider. */
21
+ readonly host: ExtensionHost | undefined;
22
+ /** Whether the host received the provider's `extensions` prop (binds keyboard shortcuts). */
23
+ readonly owned: boolean;
24
+ /** Whether every plugin setup settled. */
25
+ readonly ready: boolean;
26
+ /** Root surface context (toolbar, commands, shortcuts) of the current session. */
27
+ readonly context: WorkbenchContext | undefined;
28
+ /** Inspector context of the selected variant, `undefined` without one. */
29
+ readonly frame: FrameScopedContext | undefined;
30
+ /** Ordered available contributions; Vue-tracked (registry, context and readiness changes). */
31
+ available: <K extends ContributionKind>(kind: K, context: ContributionContext<K> | undefined) => ReadonlyArray<QualifiedContribution<K>>;
32
+ /** Runs an action against `context` with the current selection scope captured. */
33
+ run: (contributionId: string, context: unknown) => Promise<void>;
34
+ }
35
+ /** Inputs of {@link createProviderExtensions}. */
36
+ export interface ProviderExtensionsOptions {
37
+ /** Explicit `extensions` prop. */
38
+ own: () => ExtensionHost | undefined;
39
+ /** Inherited host binding. */
40
+ inherited: HistoireExtensionsBinding | undefined;
41
+ /** Current caller session. */
42
+ session: () => HistoireSession;
43
+ /** Provider-local panel navigation receiving inspector tab requests. */
44
+ panels: ReturnType<typeof createHistoirePanelNavigation>;
45
+ }
46
+ /**
47
+ * Plugin wiring of one provider. Surface contexts are rebuilt per session generation (session
48
+ * replacement closes the old one; its views unmount with the provider content); the host is
49
+ * caller-owned and only observed, never disposed.
50
+ * @param options Host sources, session and panel navigation.
51
+ */
52
+ export declare function createProviderExtensions(options: ProviderExtensionsOptions): {
53
+ state: HistoireProviderExtensions;
54
+ /** Publishes the provider's latest snapshot selection. */
55
+ synchronize(value: ReturnType<HistoireSession['getSnapshot']>): void;
56
+ /** Session replacement: retire the old surface context; the host stays. */
57
+ replace(): void;
58
+ /** Provider teardown: stop observing; never dispose the caller's host. */
59
+ close(): void;
60
+ };
61
+ //# sourceMappingURL=extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/provider/extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,aAAa,EAAE,kBAAkB,EAAqB,qBAAqB,EAAkB,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAChM,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAKhE,0FAA0F;AAC1F,MAAM,WAAW,yBAAyB;IACxC,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAAA;CACzC;AAED,gGAAgG;AAChG,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAAC,yBAAyB,CAAgC,CAAA;AAE1G;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,IAAI,CAKnH;AAED,2FAA2F;AAC3F,MAAM,WAAW,0BAA0B;IACzC,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAAA;IACxC,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAA;IAC9C,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAA;IAC9C,8FAA8F;IAC9F,SAAS,EAAE,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAA;IACxI,kFAAkF;IAClF,GAAG,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACjE;AAED,kDAAkD;AAClD,MAAM,WAAW,yBAAyB;IACxC,kCAAkC;IAClC,GAAG,EAAE,MAAM,aAAa,GAAG,SAAS,CAAA;IACpC,8BAA8B;IAC9B,SAAS,EAAE,yBAAyB,GAAG,SAAS,CAAA;IAChD,8BAA8B;IAC9B,OAAO,EAAE,MAAM,eAAe,CAAA;IAC9B,wEAAwE;IACxE,MAAM,EAAE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAA;CACzD;AAWD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB;;IA0FvE,0DAA0D;uBACvC,UAAU,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI;IAGpE,2EAA2E;eAChE,IAAI;IAOf,0EAA0E;aACjE,IAAI;EAMhB"}
@@ -0,0 +1,139 @@
1
+ import { createSessionContext, createSessionFrameService, createSessionNavigation } from '@histoire/plugin-kit';
2
+ import { getHistoireTargetKey } from '@histoire/protocol';
3
+ import { computed, provide, shallowRef, watch } from 'vue';
4
+ /** Injection key of the inherited extension host (nested selected-frame providers reuse it). */
5
+ export const histoireExtensionsKey = Symbol('HistoireExtensions');
6
+ /**
7
+ * Hands a caller-owned host to descendant providers without an `extensions` prop. First-party
8
+ * workbenches that create their host below their root provider call this.
9
+ * @param host Host, or a getter of the current host.
10
+ */
11
+ export function provideHistoireExtensions(host) {
12
+ const read = typeof host === 'function' ? host : () => host;
13
+ provide(histoireExtensionsKey, { get host() {
14
+ return read();
15
+ } });
16
+ }
17
+ /**
18
+ * Builds a native navigation: stories through the session, inspector tabs through this
19
+ * provider's explorer panels; panes, settings and canvas views do not exist in native hosts
20
+ * and are ignored, so plugins never change host-owned URLs.
21
+ */
22
+ function createNativeNavigation(session, panels) {
23
+ return Object.freeze({ ...createSessionNavigation(session), openInspectorTab: (id) => panels.requestTab(id) });
24
+ }
25
+ /**
26
+ * Plugin wiring of one provider. Surface contexts are rebuilt per session generation (session
27
+ * replacement closes the old one; its views unmount with the provider content); the host is
28
+ * caller-owned and only observed, never disposed.
29
+ * @param options Host sources, session and panel navigation.
30
+ */
31
+ export function createProviderExtensions(options) {
32
+ const host = computed(() => options.own() ?? options.inherited?.host);
33
+ // Registry snapshots are not reactive: host and context notifications bump this revision.
34
+ const revision = shallowRef(0);
35
+ const ready = shallowRef(false);
36
+ // Bumped when the host or the session context changes: surface contexts are rebuilt.
37
+ const generation = shallowRef(0);
38
+ const selection = shallowRef(options.session().getSnapshot().selection);
39
+ let session;
40
+ /** Creates the surface context of the current session, with frames when the session has them. */
41
+ function open() {
42
+ const current = options.session();
43
+ const plugins = current.plugins;
44
+ const created = createSessionContext({ session: current, navigation: createNativeNavigation(current, options.panels), frames: plugins ? createSessionFrameService(plugins) : undefined });
45
+ created.context.subscribe(() => revision.value++);
46
+ return created;
47
+ }
48
+ const stopHost = watch(host, (value, _previous, onCleanup) => {
49
+ ready.value = false;
50
+ revision.value++;
51
+ generation.value++;
52
+ if (!value)
53
+ return;
54
+ let active = true;
55
+ const stop = value.subscribe(() => revision.value++);
56
+ void value.ready.then(() => {
57
+ if (active)
58
+ ready.value = true;
59
+ });
60
+ onCleanup(() => {
61
+ active = false;
62
+ stop();
63
+ });
64
+ }, { immediate: true, flush: 'sync' });
65
+ /** Surface context, created on first use so providers without plugins subscribe nothing. */
66
+ function root() {
67
+ if (!host.value)
68
+ return undefined;
69
+ return session ??= open();
70
+ }
71
+ // Equal keys stop propagation: the frame context changes object only when the target does,
72
+ // so views receive updates, never remounts, for unrelated snapshot publications.
73
+ const targetKey = computed(() => selection.value?.variantId ? getHistoireTargetKey(selection.value) : '');
74
+ const frame = computed(() => {
75
+ void generation.value;
76
+ const context = root()?.context;
77
+ const target = selection.value;
78
+ if (!context || !targetKey.value || !target?.variantId)
79
+ return undefined;
80
+ const current = options.session();
81
+ const frameTarget = Object.freeze({ storyId: target.storyId, variantId: target.variantId });
82
+ return Object.freeze({
83
+ ...context,
84
+ selection: context.selection,
85
+ frame: Object.freeze({ key: targetKey.value, target: frameTarget }),
86
+ runtime: Object.freeze({ getSnapshot: () => current.getSnapshot(), subscribe: (listener) => current.subscribe(listener) }),
87
+ });
88
+ });
89
+ const state = {
90
+ get host() {
91
+ return host.value;
92
+ },
93
+ get owned() {
94
+ return !!options.own();
95
+ },
96
+ get ready() {
97
+ return ready.value;
98
+ },
99
+ get context() {
100
+ void generation.value;
101
+ return root()?.context;
102
+ },
103
+ get frame() {
104
+ return frame.value;
105
+ },
106
+ available(kind, context) {
107
+ void revision.value;
108
+ const value = host.value;
109
+ return value && context ? value.available(kind, context) : [];
110
+ },
111
+ run(contributionId, context) {
112
+ const value = host.value;
113
+ if (!value)
114
+ return Promise.reject(new Error('[histoire] no extension host'));
115
+ return value.run(contributionId, context, { signal: root()?.selectionSignal() });
116
+ },
117
+ };
118
+ return {
119
+ state,
120
+ /** Publishes the provider's latest snapshot selection. */
121
+ synchronize(value) {
122
+ selection.value = value.selection;
123
+ },
124
+ /** Session replacement: retire the old surface context; the host stays. */
125
+ replace() {
126
+ session?.close();
127
+ session = undefined;
128
+ selection.value = options.session().getSnapshot().selection;
129
+ revision.value++;
130
+ generation.value++;
131
+ },
132
+ /** Provider teardown: stop observing; never dispose the caller's host. */
133
+ close() {
134
+ stopHost();
135
+ session?.close();
136
+ session = undefined;
137
+ },
138
+ };
139
+ }
@@ -0,0 +1,33 @@
1
+ import type { HistoireSearchResult, HistoireSourceIdentity, HistoireTarget } from '@histoire/protocol';
2
+ import type { HistoireSession } from '@histoire/sdk';
3
+ /** A successful search owns a local panel intent, never the host's URL or global active panel. */
4
+ export interface HistoireDocsIntent {
5
+ /** Exact canonical selection whose documentation should be visible. */
6
+ target: HistoireTarget;
7
+ /** Captured completed source publication; replacement content retires this intent. */
8
+ source: HistoireSourceIdentity;
9
+ /** Panel-local documentation anchor, empty when search supplies no anchor. */
10
+ anchor: string;
11
+ }
12
+ /** Provider reuses its snapshot observer to retire local intent without another SDK subscription. */
13
+ export declare function createHistoirePanelNavigation(snapshot: HistoireSession['getSnapshot']): {
14
+ /** Readonly reactive intent consumed only by this provider's native panels. */
15
+ docs: Readonly<import("vue").ShallowRef<HistoireDocsIntent | null, HistoireDocsIntent | null>>;
16
+ /** Readonly reactive inspector tab request (qualified `builtin:` or plugin id). */
17
+ tab: Readonly<import("vue").ShallowRef<{
18
+ id: string;
19
+ } | null, {
20
+ id: string;
21
+ } | null>>;
22
+ /** Plugin navigation asks this provider's explorer panels to show one tab. */
23
+ requestTab(id: string): void;
24
+ /** Admit activation against its original source/target; only docs publish local panel intent. */
25
+ showDocs(result: HistoireSearchResult, source: HistoireSourceIdentity | null): boolean;
26
+ /** Source, navigation and disconnect publications retire old panel anchors immediately. */
27
+ synchronize(value: ReturnType<HistoireSession['getSnapshot']>): void;
28
+ /** Explicit tab choice or provider session replacement owns local intent retirement. */
29
+ clear(): void;
30
+ /** Provider teardown cannot publish another panel activation. */
31
+ close(): void;
32
+ };
33
+ //# sourceMappingURL=panels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/provider/panels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACtG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,kGAAkG;AAClG,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,MAAM,EAAE,cAAc,CAAA;IACtB,sFAAsF;IACtF,MAAM,EAAE,sBAAsB,CAAA;IAC9B,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qGAAqG;AACrG,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,eAAe,CAAC,aAAa,CAAC;IAYlF,+EAA+E;IAC/E,IAAI;IACJ,mFAAmF;IACnF,GAAG;YAXwB,MAAM;;;;IAYjC,8EAA8E;IAC9E,UAAU,KAAK,MAAM,GAAG,IAAI;IAG5B,iGAAiG;IACjG,QAAQ,SAAS,oBAAoB,UAAU,sBAAsB,GAAG,IAAI,GAAG,OAAO;IAOtF,2FAA2F;IAC3F,WAAW,QAAQ,UAAU,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI;IAGpE,wFAAwF;IACxF,KAAK,IAAI,IAAI;IAIb,iEAAiE;IACjE,KAAK,IAAI,IAAI;EAMhB"}
@@ -0,0 +1,53 @@
1
+ import { getHistoireTargetKey } from '@histoire/protocol';
2
+ import { shallowReadonly, shallowRef } from 'vue';
3
+ /** Provider reuses its snapshot observer to retire local intent without another SDK subscription. */
4
+ export function createHistoirePanelNavigation(snapshot) {
5
+ const docs = shallowRef(null);
6
+ // Plugin navigation (`openInspectorTab`) publishes a fresh object per request so repeated
7
+ // requests for one tab still notify watchers.
8
+ const tab = shallowRef(null);
9
+ let active = true;
10
+ /** Exact source and selection prevent delayed activation from claiming another provider target. */
11
+ function current(intent, value) {
12
+ return value.status === 'ready' && !value.stale && !!value.selection && getHistoireTargetKey(value.selection) === getHistoireTargetKey(intent.target)
13
+ && value.source?.sourceId === intent.source.sourceId && value.source.epoch === intent.source.epoch && value.source.revision === intent.source.revision;
14
+ }
15
+ return {
16
+ /** Readonly reactive intent consumed only by this provider's native panels. */
17
+ docs: shallowReadonly(docs),
18
+ /** Readonly reactive inspector tab request (qualified `builtin:` or plugin id). */
19
+ tab: shallowReadonly(tab),
20
+ /** Plugin navigation asks this provider's explorer panels to show one tab. */
21
+ requestTab(id) {
22
+ if (active)
23
+ tab.value = { id };
24
+ },
25
+ /** Admit activation against its original source/target; only docs publish local panel intent. */
26
+ showDocs(result, source) {
27
+ if (!active || !source)
28
+ return false;
29
+ const intent = { target: result.target, source, anchor: result.anchor ?? '' };
30
+ if (!current(intent, snapshot()))
31
+ return false;
32
+ if (result.kind === 'docs')
33
+ docs.value = intent;
34
+ return true;
35
+ },
36
+ /** Source, navigation and disconnect publications retire old panel anchors immediately. */
37
+ synchronize(value) {
38
+ if (docs.value && !current(docs.value, value))
39
+ docs.value = null;
40
+ },
41
+ /** Explicit tab choice or provider session replacement owns local intent retirement. */
42
+ clear() {
43
+ docs.value = null;
44
+ tab.value = null;
45
+ },
46
+ /** Provider teardown cannot publish another panel activation. */
47
+ close() {
48
+ active = false;
49
+ docs.value = null;
50
+ tab.value = null;
51
+ },
52
+ };
53
+ }
@@ -0,0 +1,22 @@
1
+ import type { ShortcutScope } from '@histoire/plugin-kit';
2
+ import type { HistoireProviderExtensions } from './extensions.js';
3
+ /** Attribute naming the native focus area (`canvas`, `frame`) an element belongs to. */
4
+ export declare const HISTOIRE_SHORTCUT_SCOPE_ATTRIBUTE = "data-histoire-shortcut-scope";
5
+ /**
6
+ * Shortcut scopes native hosts route keys to: `canvas` is the explorer canvas
7
+ * (`ExplorerPreview`), `frame` its single-variant frame. `comment` has no native surface:
8
+ * shortcuts in it are disabled with a diagnostic at registration.
9
+ */
10
+ export declare const NATIVE_SHORTCUT_SCOPES: readonly ShortcutScope[];
11
+ /**
12
+ * Binds plugin `shortcut` contributions to one provider root. Bindings are checked when they are
13
+ * committed (shared plugin-kit rules: built-ins win, earlier bindings win, scopes without a native
14
+ * surface are rejected), each rejection recorded once as a diagnostic; commands stay available.
15
+ * Events from nested providers, text inputs or already handled keys are ignored.
16
+ * @param root Provider root element.
17
+ * @param extensions Provider plugin state; only a provider owning its host binds keys.
18
+ * @param reportError Receives command failures.
19
+ * @returns Removes the listener and stops observing the host.
20
+ */
21
+ export declare function bindPluginShortcuts(root: HTMLElement, extensions: HistoireProviderExtensions, reportError: (error: unknown) => void): () => void;
22
+ //# sourceMappingURL=plugin-shortcuts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-shortcuts.d.ts","sourceRoot":"","sources":["../../src/provider/plugin-shortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAIjE,wFAAwF;AACxF,eAAO,MAAM,iCAAiC,iCAAiC,CAAA;AAE/E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,aAAa,EAAiD,CAAA;AAkB5G;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,0BAA0B,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAiChJ"}
@@ -0,0 +1,73 @@
1
+ import { createPluginShortcutBindings, isEditableTarget } from '@histoire/plugin-kit';
2
+ import { watch } from 'vue';
3
+ /** Attribute naming the native focus area (`canvas`, `frame`) an element belongs to. */
4
+ export const HISTOIRE_SHORTCUT_SCOPE_ATTRIBUTE = 'data-histoire-shortcut-scope';
5
+ /**
6
+ * Shortcut scopes native hosts route keys to: `canvas` is the explorer canvas
7
+ * (`ExplorerPreview`), `frame` its single-variant frame. `comment` has no native surface:
8
+ * shortcuts in it are disabled with a diagnostic at registration.
9
+ */
10
+ export const NATIVE_SHORTCUT_SCOPES = Object.freeze(['global', 'canvas', 'frame']);
11
+ /**
12
+ * Scopes containing `target`, innermost first (frame, canvas, then global), like the standalone
13
+ * workbench. Focus areas outside `root` (a host page wrapping the provider) do not count.
14
+ * @param target Key event target.
15
+ * @param root Provider root.
16
+ */
17
+ function eventScopes(target, root) {
18
+ const scopes = [];
19
+ for (const scope of ['frame', 'canvas']) {
20
+ const area = target.closest(`[${HISTOIRE_SHORTCUT_SCOPE_ATTRIBUTE}="${scope}"]`);
21
+ if (area && root.contains(area))
22
+ scopes.push(scope);
23
+ }
24
+ scopes.push('global');
25
+ return scopes;
26
+ }
27
+ /**
28
+ * Binds plugin `shortcut` contributions to one provider root. Bindings are checked when they are
29
+ * committed (shared plugin-kit rules: built-ins win, earlier bindings win, scopes without a native
30
+ * surface are rejected), each rejection recorded once as a diagnostic; commands stay available.
31
+ * Events from nested providers, text inputs or already handled keys are ignored.
32
+ * @param root Provider root element.
33
+ * @param extensions Provider plugin state; only a provider owning its host binds keys.
34
+ * @param reportError Receives command failures.
35
+ * @returns Removes the listener and stops observing the host.
36
+ */
37
+ export function bindPluginShortcuts(root, extensions, reportError) {
38
+ let bindings;
39
+ // The host can change with the `extensions` prop; registrations are tracked per host.
40
+ const stopHost = watch(() => extensions.owned ? extensions.host : undefined, (host, _previous, onCleanup) => {
41
+ if (!host)
42
+ return;
43
+ bindings = createPluginShortcutBindings(host, NATIVE_SHORTCUT_SCOPES);
44
+ const current = bindings;
45
+ onCleanup(() => {
46
+ current.dispose();
47
+ if (bindings === current)
48
+ bindings = undefined;
49
+ });
50
+ }, { immediate: true, flush: 'sync' });
51
+ /** Runs the command of the first matching available shortcut, innermost scope first. */
52
+ function keydown(event) {
53
+ const context = extensions.context;
54
+ const target = event.target;
55
+ if (!bindings || !context || !target?.closest || event.defaultPrevented || event.repeat || isEditableTarget(target))
56
+ return;
57
+ if (target.closest('.histoire-provider') !== root)
58
+ return;
59
+ const shortcuts = extensions.available('shortcut', context);
60
+ const commands = extensions.available('command', context);
61
+ const shortcut = bindings.match(event, eventScopes(target, root), candidate => shortcuts.includes(candidate) && commands.some(command => command.id === candidate.command));
62
+ if (!shortcut)
63
+ return;
64
+ event.preventDefault();
65
+ event.stopPropagation();
66
+ void extensions.run(shortcut.command, context).catch(reportError);
67
+ }
68
+ root.addEventListener('keydown', keydown);
69
+ return () => {
70
+ root.removeEventListener('keydown', keydown);
71
+ stopHost();
72
+ };
73
+ }
@@ -0,0 +1,16 @@
1
+ import type { ShallowRef } from 'vue';
2
+ /** First-party standalone dialog can reveal owned search before native focus occurs. */
3
+ export declare const HISTOIRE_SEARCH_FOCUS = "histoire:search-focus";
4
+ /** Owned source-frame intent toggles chrome in its exact standalone provider. */
5
+ export declare const HISTOIRE_TOGGLE_UI = "histoire:toggle-ui";
6
+ /** Owned source-frame Escape restores chrome without toggling visible UI off. */
7
+ export declare const HISTOIRE_SHOW_UI = "histoire:show-ui";
8
+ /** Dispatch the finite restore intent on its owning provider root. */
9
+ export declare function requestHistoireUiShow(root: HTMLElement | null): void;
10
+ /** Dispatch the finite UI-toggle intent on its owning provider root. */
11
+ export declare function requestHistoireUiToggle(root: HTMLElement | null): void;
12
+ /** Owned source-frame intent focuses only this provider's first independent search part. */
13
+ export declare function focusHistoireSearch(root: HTMLElement | null): void;
14
+ /** Provider-root listener never claims host or nested-provider keyboard input. */
15
+ export declare function useHistoireSearchShortcut(input: ShallowRef<HTMLInputElement | null>): void;
16
+ //# sourceMappingURL=shortcuts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcuts.d.ts","sourceRoot":"","sources":["../../src/provider/shortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAIrC,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,0BAA0B,CAAA;AAC5D,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,uBAAuB,CAAA;AACtD,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,qBAAqB,CAAA;AASlD,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAEpE;AAED,wEAAwE;AACxE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAEtE;AAED,4FAA4F;AAC5F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAYlE;AAED,kFAAkF;AAClF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,IAAI,CAmB1F"}
@@ -0,0 +1,62 @@
1
+ import { onMounted } from 'vue';
2
+ import { useHistoireContext, useHistoireResource } from './context.js';
3
+ /** First-party standalone dialog can reveal owned search before native focus occurs. */
4
+ export const HISTOIRE_SEARCH_FOCUS = 'histoire:search-focus';
5
+ /** Owned source-frame intent toggles chrome in its exact standalone provider. */
6
+ export const HISTOIRE_TOGGLE_UI = 'histoire:toggle-ui';
7
+ /** Owned source-frame Escape restores chrome without toggling visible UI off. */
8
+ export const HISTOIRE_SHOW_UI = 'histoire:show-ui';
9
+ /** Dispatch a finite visibility intent without bubbling into neighboring providers. */
10
+ function requestUiVisibility(root, type) {
11
+ if (!root)
12
+ return;
13
+ const Event = root.ownerDocument.defaultView?.Event;
14
+ if (Event)
15
+ root.dispatchEvent(new Event(type, { cancelable: true }));
16
+ }
17
+ /** Dispatch the finite restore intent on its owning provider root. */
18
+ export function requestHistoireUiShow(root) {
19
+ requestUiVisibility(root, HISTOIRE_SHOW_UI);
20
+ }
21
+ /** Dispatch the finite UI-toggle intent on its owning provider root. */
22
+ export function requestHistoireUiToggle(root) {
23
+ requestUiVisibility(root, HISTOIRE_TOGGLE_UI);
24
+ }
25
+ /** Owned source-frame intent focuses only this provider's first independent search part. */
26
+ export function focusHistoireSearch(root) {
27
+ if (!root)
28
+ return;
29
+ // The owning shell can reveal an unmounted search pane before native focus.
30
+ // Dispatch directly on this provider so nested or neighboring owners cannot
31
+ // claim the source document's finite search intent.
32
+ const Event = root.ownerDocument.defaultView?.Event;
33
+ if (Event && !root.dispatchEvent(new Event(HISTOIRE_SEARCH_FOCUS, { cancelable: true })))
34
+ return;
35
+ const input = Array.from(root.querySelectorAll('.histoire-search input[type="search"]')).find(candidate => candidate.closest('.histoire-provider') === root);
36
+ if (input) {
37
+ input.focus();
38
+ input.select();
39
+ }
40
+ }
41
+ /** Provider-root listener never claims host or nested-provider keyboard input. */
42
+ export function useHistoireSearchShortcut(input) {
43
+ const context = useHistoireContext();
44
+ let root = null;
45
+ /** Native bubbling scope handles only explicit search shortcut; no document listener. */
46
+ function keydown(event) {
47
+ const target = event.target;
48
+ if (event.defaultPrevented || event.altKey || !(event.ctrlKey || event.metaKey) || event.key.toLowerCase() !== 'k' || target?.closest('.histoire-provider') !== root || !input.value)
49
+ return;
50
+ event.preventDefault();
51
+ event.stopPropagation();
52
+ focusHistoireSearch(root);
53
+ }
54
+ onMounted(() => {
55
+ root = context.root.value;
56
+ root?.addEventListener('keydown', keydown);
57
+ });
58
+ useHistoireResource(() => {
59
+ root?.removeEventListener('keydown', keydown);
60
+ root = null;
61
+ });
62
+ }
@@ -0,0 +1,4 @@
1
+ import type { HistoireSourceConfig } from '@histoire/protocol';
2
+ /** Project palette stays on owning provider; channels/alpha also feed peer controls and replicas. */
3
+ export declare function getHistoireThemeVariables(config: HistoireSourceConfig | undefined, dark: boolean): Record<string, string>;
4
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/provider/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAG9D,qGAAqG;AACrG,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,oBAAoB,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBzH"}
@@ -0,0 +1,25 @@
1
+ import { getHistoireColorChannels, getHistoireSemanticThemeOverrides, parseColor } from '@histoire/protocol';
2
+ /** Project palette stays on owning provider; channels/alpha also feed peer controls and replicas. */
3
+ export function getHistoireThemeVariables(config, dark) {
4
+ const variables = {};
5
+ for (const [color, shades] of Object.entries(config?.theme.colors ?? {})) {
6
+ for (const [shade, input] of Object.entries(shades)) {
7
+ const parsed = parseColor(input);
8
+ if (!parsed)
9
+ continue;
10
+ const value = getHistoireColorChannels(parsed);
11
+ const name = `--_histoire-color-${color}-${shade}`;
12
+ variables[name] = value.channels;
13
+ variables[`${name}-alpha`] = value.alpha;
14
+ }
15
+ }
16
+ const overrides = getHistoireSemanticThemeOverrides(config?.theme.colors, dark);
17
+ Object.assign(variables, overrides);
18
+ for (const name of Object.keys(overrides)) {
19
+ if (!name.endsWith('-rgb'))
20
+ continue;
21
+ const role = name.slice(0, -4);
22
+ variables[role] = `rgb(var(${name}) / var(${role}-alpha, ${role === '--histoire-accent-soft' && dark ? '.12' : '1'}))`;
23
+ }
24
+ return variables;
25
+ }
@@ -0,0 +1,27 @@
1
+ /** Extension identity survives visibility changes; callbacks belong to one publication. */
2
+ export interface HistoireSearchExtension {
3
+ /** Stable command identity, independent of its current list position. */
4
+ id: string;
5
+ /** Activate only the action paired with this visible command. */
6
+ activate: () => void;
7
+ }
8
+ /** First-party search extensions share one keyboard index with story results. */
9
+ export interface HistoireSearchNavigation {
10
+ /** Replace current story actions; loading and query changes retire old targets. */
11
+ setResults: (actions: readonly (() => void)[]) => void;
12
+ /** Replace visible commands, retaining highlight by ID or retiring removed action. */
13
+ setExtensions: (actions: readonly HistoireSearchExtension[]) => void;
14
+ /** Move highlight to explicitly focused story/extension result. */
15
+ focus: (index: number, extension?: boolean) => void;
16
+ /** Whether this result owns the combined highlight. */
17
+ isActive: (index: number, extension?: boolean) => boolean;
18
+ /** Handle each bubbled key once, including native button Enter activation. */
19
+ keydown: (event: KeyboardEvent) => void;
20
+ }
21
+ /** Story results precede extension actions; one owner activates exactly one item. */
22
+ export declare function createHistoireSearchNavigation(): HistoireSearchNavigation;
23
+ /** Only first-party command palette provides an extended navigation owner. */
24
+ export declare function provideHistoireSearchNavigation(navigation: HistoireSearchNavigation): void;
25
+ /** Independent panels create local navigation, with no global active search. */
26
+ export declare function useHistoireSearchNavigation(): HistoireSearchNavigation;
27
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/search/navigation.ts"],"names":[],"mappings":"AAGA,2FAA2F;AAC3F,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,EAAE,EAAE,MAAM,CAAA;IACV,iEAAiE;IACjE,QAAQ,EAAE,MAAM,IAAI,CAAA;CACrB;AAED,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,mFAAmF;IACnF,UAAU,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAA;IACtD,sFAAsF;IACtF,aAAa,EAAE,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,KAAK,IAAI,CAAA;IACpE,mEAAmE;IACnE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACnD,uDAAuD;IACvD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;IACzD,8EAA8E;IAC9E,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;CACxC;AAKD,qFAAqF;AACrF,wBAAgB,8BAA8B,IAAI,wBAAwB,CA2CzE;AAED,8EAA8E;AAC9E,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAE1F;AAED,gFAAgF;AAChF,wBAAgB,2BAA2B,IAAI,wBAAwB,CAEtE"}