@histoire/vue 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 (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 +36 -0
  45. package/dist/components/embed/HistoireEmbed.d.ts.map +1 -0
  46. package/dist/components/embed/HistoireEmbed.js +81 -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 +11 -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 +13 -0
  90. package/dist/components/preview/surface.d.ts.map +1 -0
  91. package/dist/components/preview/surface.js +129 -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,38 @@
1
+ /** Native primary panel action matching host control height and theme. */
2
+ export declare const NativeWorkbenchPanelAction: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
+ /** Offline Carbon glyph name. */
4
+ icon: {
5
+ type: StringConstructor;
6
+ required: true;
7
+ };
8
+ /** Visible action label. */
9
+ label: {
10
+ type: StringConstructor;
11
+ required: true;
12
+ };
13
+ /** Whether activation is disabled. */
14
+ disabled: BooleanConstructor;
15
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
16
+ [key: string]: any;
17
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ /** Main action activated. */
19
+ click: (_event: MouseEvent) => true;
20
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
+ /** Offline Carbon glyph name. */
22
+ icon: {
23
+ type: StringConstructor;
24
+ required: true;
25
+ };
26
+ /** Visible action label. */
27
+ label: {
28
+ type: StringConstructor;
29
+ required: true;
30
+ };
31
+ /** Whether activation is disabled. */
32
+ disabled: BooleanConstructor;
33
+ }>> & Readonly<{
34
+ onClick?: ((_event: MouseEvent) => any) | undefined;
35
+ }>, {
36
+ disabled: boolean;
37
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
38
+ //# sourceMappingURL=panel-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-action.d.ts","sourceRoot":"","sources":["../../../src/components/extensions/panel-action.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B;IAGnC,iCAAiC;;;;;IAEjC,4BAA4B;;;;;IAE5B,sCAAsC;;;;;IAItC,6BAA6B;oBACb,UAAU;;IAT1B,iCAAiC;;;;;IAEjC,4BAA4B;;;;;IAE5B,sCAAsC;;;;;;4EAQxC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { BuiltinIcon, HstButton } from '@histoire/controls/vue';
2
+ import { defineComponent, h } from 'vue';
3
+ /** Native primary panel action matching host control height and theme. */
4
+ export const NativeWorkbenchPanelAction = defineComponent({
5
+ name: 'NativeWorkbenchPanelAction',
6
+ props: {
7
+ /** Offline Carbon glyph name. */
8
+ icon: { type: String, required: true },
9
+ /** Visible action label. */
10
+ label: { type: String, required: true },
11
+ /** Whether activation is disabled. */
12
+ disabled: Boolean,
13
+ },
14
+ emits: {
15
+ /** Main action activated. */
16
+ click: (_event) => true,
17
+ },
18
+ setup: (props, { emit }) => () => h(HstButton, { color: 'primary', disabled: props.disabled, onClick: (event) => emit('click', event) }, () => [h(BuiltinIcon, { icon: props.icon, size: 16 }), props.label]),
19
+ });
@@ -0,0 +1,17 @@
1
+ import type { ViewHost, WorkbenchComponents } from '@histoire/plugin-kit';
2
+ /** State renderer of one view and the cleanup releasing what it rendered. */
3
+ export interface ViewStateRenderer {
4
+ /** `ViewHost.renderState` of the view. */
5
+ renderState: ViewHost['renderState'];
6
+ /** Unmounts every state still rendered; later calls render nothing. */
7
+ release: () => void;
8
+ }
9
+ /**
10
+ * Creates the `renderState` of one view, called in the view component's setup. States render
11
+ * with the given workbench components, else the ones provided around the view (native), as
12
+ * separate Vue roots inside plugin-owned elements that share the view's app context; without
13
+ * components they render plain markup.
14
+ * @param given Components of the calling workbench.
15
+ */
16
+ export declare function createViewStateRenderer(given?: WorkbenchComponents): ViewStateRenderer;
17
+ //# sourceMappingURL=state-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/extensions/state-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAkB,MAAM,sBAAsB,CAAA;AAqBzF,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,WAAW,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;IACpC,uEAAuE;IACvE,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CA6CtF"}
@@ -0,0 +1,72 @@
1
+ import { LoadingDelayBoundary, useLoadingDelay } from '@histoire/controls/vue';
2
+ import { cancelPlainLoadingState, renderPlainWorkbenchState, WORKBENCH_COMPONENTS_KEY } from '@histoire/plugin-kit';
3
+ import { defineComponent, getCurrentInstance, h, inject, render } from 'vue';
4
+ /** Delays plugin-provided loading markup once, including host-supplied components. */
5
+ const DelayedState = defineComponent({
6
+ setup(_props, { slots }) {
7
+ const visible = useLoadingDelay(true);
8
+ return () => visible.value ? h(LoadingDelayBoundary, null, slots.default) : null;
9
+ },
10
+ });
11
+ /** Provided component rendering each state kind. */
12
+ const STATE_COMPONENTS = {
13
+ empty: 'WorkbenchEmptyState',
14
+ loading: 'WorkbenchLoadingState',
15
+ error: 'WorkbenchErrorState',
16
+ };
17
+ /**
18
+ * Creates the `renderState` of one view, called in the view component's setup. States render
19
+ * with the given workbench components, else the ones provided around the view (native), as
20
+ * separate Vue roots inside plugin-owned elements that share the view's app context; without
21
+ * components they render plain markup.
22
+ * @param given Components of the calling workbench.
23
+ */
24
+ export function createViewStateRenderer(given) {
25
+ const components = given ?? inject(WORKBENCH_COMPONENTS_KEY, null);
26
+ const appContext = getCurrentInstance()?.appContext ?? null;
27
+ // Containers currently holding a Vue root; others hold plain markup or plugin content.
28
+ const roots = new Set();
29
+ const plain = new Set();
30
+ let released = false;
31
+ /**
32
+ * Unmounts the Vue root in `container`, if any.
33
+ * @param container Plugin-owned element.
34
+ */
35
+ function unmountRoot(container) {
36
+ if (roots.delete(container))
37
+ render(null, container);
38
+ }
39
+ return {
40
+ renderState(container, state) {
41
+ if (released)
42
+ return;
43
+ const component = state && components?.[STATE_COMPONENTS[state.kind]];
44
+ if (!state || !component) {
45
+ unmountRoot(container);
46
+ plain.add(container);
47
+ renderPlainWorkbenchState(container, state);
48
+ return;
49
+ }
50
+ const { kind, detail, ...props } = state;
51
+ cancelPlainLoadingState(container);
52
+ plain.delete(container);
53
+ const stateNode = () => h(component, props, detail ? { default: () => detail } : undefined);
54
+ const vnode = kind === 'loading' ? h(DelayedState, null, stateNode) : stateNode();
55
+ // Same app context as the view: global components, directives and app-level provides.
56
+ vnode.appContext = appContext;
57
+ // A first Vue render appends; replace plugin content or plain markup instead.
58
+ if (!roots.has(container))
59
+ container.replaceChildren();
60
+ render(vnode, container);
61
+ roots.add(container);
62
+ },
63
+ release() {
64
+ released = true;
65
+ for (const container of [...roots])
66
+ unmountRoot(container);
67
+ for (const container of plain)
68
+ cancelPlainLoadingState(container);
69
+ plain.clear();
70
+ },
71
+ };
72
+ }
@@ -0,0 +1,47 @@
1
+ import type { ExtensionHost, QualifiedContribution, WorkbenchComponents } from '@histoire/plugin-kit';
2
+ import type { Component, ShallowRef } from 'vue';
3
+ /** Inputs of {@link useExtensionView}. */
4
+ export interface ExtensionViewOptions {
5
+ /** Host owning the contribution; records failures. */
6
+ host: ExtensionHost;
7
+ /** Fixed for the component lifetime; key the component by contribution object. */
8
+ contribution: QualifiedContribution;
9
+ /** Current surface context snapshot; watched, new snapshots update the view. */
10
+ context: () => unknown;
11
+ /**
12
+ * Element receiving this view's overlay root (themed layer of the surface). Returns
13
+ * `undefined` while unresolvable (before mount); the root is then attached on mount.
14
+ */
15
+ overlayParent: () => HTMLElement | null | undefined;
16
+ /** Components rendering `ViewHost.renderState`; defaults to the ones provided around the view. */
17
+ components?: WorkbenchComponents;
18
+ }
19
+ /** Reactive state of one rendered contribution view. */
20
+ export interface ExtensionViewState {
21
+ /** Contribution label or title, when it has one. */
22
+ name: string | undefined;
23
+ /** Vue component view; `undefined` for DOM mount views. */
24
+ component: Component | undefined;
25
+ /** Latest context snapshot; reactive so Vue views re-render on change. */
26
+ current: ShallowRef<unknown>;
27
+ /** Set once the view failed; the view stays failed until remounted. */
28
+ failure: ShallowRef<{
29
+ error: unknown;
30
+ } | undefined>;
31
+ /** Whether a DOM view is still mounting. */
32
+ pending: ShallowRef<boolean>;
33
+ /** Template ref of the element DOM views mount into. */
34
+ container: ShallowRef<HTMLElement | null | undefined>;
35
+ /** Called when the Vue view mounted; later Vue failures are update failures. */
36
+ onComponentMounted: () => void;
37
+ }
38
+ /**
39
+ * Lifecycle of one contribution view, shared by the standalone workbench and native providers:
40
+ * provides the `WorkbenchViewBinding` (live context + view host), keeps Vue view errors local and
41
+ * attributed, mounts DOM views through the host's mount manager (which owns update ordering and
42
+ * late disposal), pushes context snapshots without remounting, and releases everything on unmount.
43
+ * Callers render the states (failure, pending, component, container) with their own components.
44
+ * @param options Host, contribution, context source and overlay placement.
45
+ */
46
+ export declare function useExtensionView(options: ExtensionViewOptions): ExtensionViewState;
47
+ //# sourceMappingURL=view-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/components/extensions/view-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAe,qBAAqB,EAA8B,mBAAmB,EAAwB,MAAM,sBAAsB,CAAA;AACpK,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAiBhD,0CAA0C;AAC1C,MAAM,WAAW,oBAAoB;IACnC,sDAAsD;IACtD,IAAI,EAAE,aAAa,CAAA;IACnB,kFAAkF;IAClF,YAAY,EAAE,qBAAqB,CAAA;IACnC,gFAAgF;IAChF,OAAO,EAAE,MAAM,OAAO,CAAA;IACtB;;;OAGG;IACH,aAAa,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IACnD,kGAAkG;IAClG,UAAU,CAAC,EAAE,mBAAmB,CAAA;CACjC;AAED,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,2DAA2D;IAC3D,SAAS,EAAE,SAAS,GAAG,SAAS,CAAA;IAChC,0EAA0E;IAC1E,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC5B,uEAAuE;IACvE,OAAO,EAAE,UAAU,CAAC;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC,CAAA;IACnD,4CAA4C;IAC5C,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC5B,wDAAwD;IACxD,SAAS,EAAE,UAAU,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IACrD,gFAAgF;IAChF,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,kBAAkB,CAqGlF"}
@@ -0,0 +1,108 @@
1
+ import { WORKBENCH_VIEW_KEY } from '@histoire/plugin-kit';
2
+ import { onBeforeUnmount, onErrorCaptured, onMounted, provide, shallowRef, watch } from 'vue';
3
+ import { createViewStateRenderer } from './state-renderer.js';
4
+ /**
5
+ * Lifecycle of one contribution view, shared by the standalone workbench and native providers:
6
+ * provides the `WorkbenchViewBinding` (live context + view host), keeps Vue view errors local and
7
+ * attributed, mounts DOM views through the host's mount manager (which owns update ordering and
8
+ * late disposal), pushes context snapshots without remounting, and releases everything on unmount.
9
+ * Callers render the states (failure, pending, component, container) with their own components.
10
+ * @param options Host, contribution, context source and overlay placement.
11
+ */
12
+ export function useExtensionView(options) {
13
+ const { host, contribution } = options;
14
+ const { id } = contribution;
15
+ const view = contribution;
16
+ const current = shallowRef(options.context());
17
+ const failure = shallowRef();
18
+ const pending = shallowRef(!view.component);
19
+ const container = shallowRef();
20
+ const controller = new AbortController();
21
+ let overlayRoot;
22
+ let attached = false;
23
+ let mounted;
24
+ let componentMounted = false;
25
+ const states = createViewStateRenderer(options.components);
26
+ /** Appends the overlay root to its parent once that parent is known. */
27
+ function attachOverlayRoot() {
28
+ const parent = overlayRoot && !attached ? options.overlayParent() : undefined;
29
+ if (!parent || !overlayRoot)
30
+ return;
31
+ parent.append(overlayRoot);
32
+ attached = true;
33
+ }
34
+ /** Per-view overlay element, created on first use so views without popovers add nothing. */
35
+ function ensureOverlayRoot() {
36
+ if (!overlayRoot) {
37
+ overlayRoot = document.createElement('div');
38
+ overlayRoot.className = 'histoire-extension-overlay-root';
39
+ overlayRoot.setAttribute('data-histoire-contribution', id);
40
+ attachOverlayRoot();
41
+ }
42
+ return overlayRoot;
43
+ }
44
+ const viewHost = {
45
+ signal: controller.signal,
46
+ get overlayRoot() {
47
+ return ensureOverlayRoot();
48
+ },
49
+ reportError: (error) => {
50
+ if (!controller.signal.aborted)
51
+ host.reportViewError(id, error, 'report');
52
+ },
53
+ renderState: states.renderState,
54
+ };
55
+ provide(WORKBENCH_VIEW_KEY, {
56
+ get context() {
57
+ return current.value;
58
+ },
59
+ host: viewHost,
60
+ });
61
+ /**
62
+ * Shows the error state of this view only.
63
+ * @param error View failure.
64
+ */
65
+ function fail(error) {
66
+ failure.value = { error };
67
+ pending.value = false;
68
+ }
69
+ // Errors below a Vue view stay here, attributed to the plugin.
70
+ onErrorCaptured((error) => {
71
+ if (failure.value)
72
+ return false;
73
+ const phase = componentMounted ? 'update' : 'mount';
74
+ host.reportViewError(id, error, phase);
75
+ fail(error);
76
+ return false;
77
+ });
78
+ onMounted(() => {
79
+ attachOverlayRoot();
80
+ if (view.component || !container.value)
81
+ return;
82
+ mounted = host.mount(id, container.value, current.value, { overlayRoot: ensureOverlayRoot(), onError: fail, renderState: states.renderState });
83
+ mounted.ready.then(() => {
84
+ pending.value = false;
85
+ }, () => { });
86
+ });
87
+ watch(options.context, (context) => {
88
+ current.value = context;
89
+ mounted?.update(context);
90
+ });
91
+ onBeforeUnmount(() => {
92
+ controller.abort();
93
+ states.release();
94
+ void mounted?.dispose();
95
+ overlayRoot?.remove();
96
+ });
97
+ return {
98
+ name: view.label ?? view.title,
99
+ component: view.component,
100
+ current,
101
+ failure,
102
+ pending,
103
+ container,
104
+ onComponentMounted: () => {
105
+ componentMounted = true;
106
+ },
107
+ };
108
+ }
@@ -0,0 +1,9 @@
1
+ import type { WorkbenchComponents } from '@histoire/plugin-kit';
2
+ /** Components native providers hand to plugin views. */
3
+ export declare const histoireWorkbenchComponents: Readonly<WorkbenchComponents>;
4
+ /**
5
+ * Provides the native components unless an enclosing workbench (the standalone app, or an
6
+ * outer provider) already did, so nested selected-frame providers keep the outer look.
7
+ */
8
+ export declare function provideNativeWorkbenchComponents(): void;
9
+ //# sourceMappingURL=workbench-components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbench-components.d.ts","sourceRoot":"","sources":["../../../src/components/extensions/workbench-components.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAwF/D,wDAAwD;AACxD,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,mBAAmB,CAQpE,CAAA;AAEF;;;GAGG;AACH,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD"}
@@ -0,0 +1,82 @@
1
+ import { BuiltinIcon, HstPulsatingDisc, useLoadingDelay } from '@histoire/controls/vue';
2
+ import { WORKBENCH_COMPONENTS_KEY } from '@histoire/plugin-kit';
3
+ import { defineComponent, h, inject, provide } from 'vue';
4
+ import { NativeWorkbenchPanelAction } from './panel-action.js';
5
+ /**
6
+ * Shared state layout: visual, headline, optional detail and actions.
7
+ * @param attributes Root attributes (role, state kind).
8
+ * @param visual Icon badge or busy disc.
9
+ * @param title Headline.
10
+ * @param slots Detail and actions slots.
11
+ * @param slots.default Detail slot.
12
+ * @param slots.actions Actions slot.
13
+ */
14
+ function state(attributes, visual, title, slots) {
15
+ return h('div', { class: 'histoire-state', ...attributes }, [
16
+ h('span', { 'class': 'histoire-state-visual', 'aria-hidden': 'true' }, visual),
17
+ h('strong', title),
18
+ slots.default ? h('p', slots.default()) : null,
19
+ slots.actions ? h('div', { class: 'histoire-state-actions' }, slots.actions()) : null,
20
+ ]);
21
+ }
22
+ /** Native empty state. */
23
+ const EmptyState = defineComponent({
24
+ name: 'HistoireWorkbenchEmptyState',
25
+ props: { icon: { type: String, required: true }, title: { type: String, required: true } },
26
+ slots: Object,
27
+ setup: (props, { slots }) => () => state({ 'role': 'status', 'data-state': 'empty' }, h(BuiltinIcon, { icon: props.icon, size: 20 }), props.title, slots),
28
+ });
29
+ /** Native loading state. */
30
+ const LoadingState = defineComponent({
31
+ name: 'HistoireWorkbenchLoadingState',
32
+ props: { title: { type: String, required: true } },
33
+ slots: Object,
34
+ setup(props, { slots }) {
35
+ const visible = useLoadingDelay(true);
36
+ return () => visible.value ? state({ 'role': 'status', 'aria-atomic': 'true', 'data-state': 'loading' }, h(HstPulsatingDisc, { size: 24, immediate: true }), props.title, { default: slots.default }) : null;
37
+ },
38
+ });
39
+ /** Native error state, announced as an alert. */
40
+ const ErrorState = defineComponent({
41
+ name: 'HistoireWorkbenchErrorState',
42
+ props: { icon: { type: String, default: 'error-filled' }, title: { type: String, required: true } },
43
+ slots: Object,
44
+ setup: (props, { slots }) => () => state({ 'role': 'alert', 'aria-atomic': 'true', 'data-state': 'error' }, h(BuiltinIcon, { icon: props.icon, size: 20 }), props.title, slots),
45
+ });
46
+ /** Native pane header. */
47
+ const PaneHeader = defineComponent({
48
+ name: 'HistoireWorkbenchPaneHeader',
49
+ props: { title: { type: String, required: true } },
50
+ slots: Object,
51
+ setup: (props, { slots }) => () => h('header', { class: 'histoire-pane-header' }, [h('h2', props.title), slots.default?.()]),
52
+ });
53
+ /** Native pane toolbar row. */
54
+ const PaneToolbar = defineComponent({
55
+ name: 'HistoireWorkbenchPaneToolbar',
56
+ slots: Object,
57
+ setup: (_props, { slots }) => () => h('div', { class: 'histoire-pane-toolbar' }, slots.default?.()),
58
+ });
59
+ /** Native pane list body. */
60
+ const PaneList = defineComponent({
61
+ name: 'HistoireWorkbenchPaneList',
62
+ slots: Object,
63
+ setup: (_props, { slots }) => () => h('div', { class: 'histoire-pane-list' }, slots.default?.()),
64
+ });
65
+ /** Components native providers hand to plugin views. */
66
+ export const histoireWorkbenchComponents = Object.freeze({
67
+ WorkbenchEmptyState: EmptyState,
68
+ WorkbenchLoadingState: LoadingState,
69
+ WorkbenchErrorState: ErrorState,
70
+ WorkbenchPanelAction: NativeWorkbenchPanelAction,
71
+ WorkbenchPaneHeader: PaneHeader,
72
+ WorkbenchPaneToolbar: PaneToolbar,
73
+ WorkbenchPaneList: PaneList,
74
+ });
75
+ /**
76
+ * Provides the native components unless an enclosing workbench (the standalone app, or an
77
+ * outer provider) already did, so nested selected-frame providers keep the outer look.
78
+ */
79
+ export function provideNativeWorkbenchComponents() {
80
+ if (!inject(WORKBENCH_COMPONENTS_KEY, null))
81
+ provide(WORKBENCH_COMPONENTS_KEY, histoireWorkbenchComponents);
82
+ }
@@ -0,0 +1,11 @@
1
+ /** Isolated single preview using nearest provider's explicit session. */
2
+ export declare const HistoirePreview: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
+ [key: string]: any;
4
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ ready: () => true;
6
+ error: (_error: unknown) => true;
7
+ }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
8
+ onError?: ((_error: unknown) => any) | undefined;
9
+ onReady?: (() => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
+ //# sourceMappingURL=HistoirePreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistoirePreview.d.ts","sourceRoot":"","sources":["../../../src/components/preview/HistoirePreview.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,eAAO,MAAM,eAAe;;;;;;;;iFAAsD,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { createHistoirePrimary } from './surface.js';
2
+ /** Isolated single preview using nearest provider's explicit session. */
3
+ export const HistoirePreview = createHistoirePrimary('HistoirePreview', 'preview');
@@ -0,0 +1,13 @@
1
+ /** Build native primary wrapper around SDK-owned source runtime; no host story imports. */
2
+ export declare function createHistoirePrimary(name: string, surface: 'preview'): import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
+ [key: string]: any;
4
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ /** Fires after source runtime readiness, including explicit empty-book readiness. */
6
+ ready: () => true;
7
+ /** Typed source/runtime or primary ownership failure. */
8
+ error: (_error: unknown) => true;
9
+ }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
10
+ onError?: ((_error: unknown) => any) | undefined;
11
+ onReady?: (() => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
+ //# sourceMappingURL=surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../../src/components/preview/surface.ts"],"names":[],"mappings":"AAQA,2FAA2F;AAC3F,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS;;;IAKhE,qFAAqF;;IAErF,yDAAyD;oBACzC,OAAO;;;;kFAoG5B"}
@@ -0,0 +1,129 @@
1
+ import { LoadingDelayBoundary, useLoadingDelay } from '@histoire/controls/vue';
2
+ import { HistoireSdkError } from '@histoire/protocol';
3
+ import { isHistoirePrimaryMountActive, subscribeHistoireMountEvents } from '@histoire/sdk/internal';
4
+ import { defineComponent, h, onMounted, shallowRef } from 'vue';
5
+ import { useHistoireContext, useHistoireResource } from '../../provider/context.js';
6
+ import { focusHistoireSearch, requestHistoireUiShow, requestHistoireUiToggle } from '../../provider/shortcuts.js';
7
+ /** Build native primary wrapper around SDK-owned source runtime; no host story imports. */
8
+ export function createHistoirePrimary(name, surface) {
9
+ return defineComponent({
10
+ name,
11
+ inheritAttrs: false,
12
+ emits: {
13
+ /** Fires after source runtime readiness, including explicit empty-book readiness. */
14
+ ready: () => true,
15
+ /** Typed source/runtime or primary ownership failure. */
16
+ error: (_error) => true,
17
+ },
18
+ setup(_props, { attrs, slots, emit, expose }) {
19
+ const context = useHistoireContext();
20
+ const session = context.session;
21
+ const initial = session.getSnapshot();
22
+ const container = shallowRef(null);
23
+ const error = shallowRef();
24
+ const ready = shallowRef(false);
25
+ const loadingVisible = useLoadingDelay(() => !ready.value && !error.value);
26
+ let mount;
27
+ let removed = false;
28
+ let closing;
29
+ let stopFocus;
30
+ let stopReadiness;
31
+ let settled = false;
32
+ let acknowledged = false;
33
+ let selectionChanged = false;
34
+ let readyDocument;
35
+ /** Exposed teardown joins SDK ownership release before caller replaces a primary. */
36
+ function unmount() {
37
+ removed = true;
38
+ stopFocus?.();
39
+ stopReadiness?.();
40
+ closing ??= mount?.unmount() ?? Promise.resolve();
41
+ void closing.catch(() => { });
42
+ return closing;
43
+ }
44
+ useHistoireResource(unmount);
45
+ /** Show failures locally and through provider's resource/error boundary. */
46
+ function fail(value) {
47
+ if (removed)
48
+ return;
49
+ error.value = value;
50
+ emit('error', value);
51
+ context.reportError(value);
52
+ }
53
+ /** Read live ownership rather than adopting a delayed observer's snapshot. */
54
+ function currentSnapshot() {
55
+ const snapshot = session.getSnapshot();
56
+ if (removed || !mount || !isHistoirePrimaryMountActive(session, mount) || snapshot.source?.sourceId !== initial.source?.sourceId || snapshot.runtime.mountId !== mount.id)
57
+ return;
58
+ return snapshot;
59
+ }
60
+ /** Initial promise may retire; retained primary follows each owned document. */
61
+ function synchronizeReadiness() {
62
+ const snapshot = currentSnapshot();
63
+ selectionChanged ||= snapshot?.selection?.storyId !== initial.selection?.storyId || snapshot?.selection?.variantId !== initial.selection?.variantId;
64
+ const runtime = snapshot?.runtime;
65
+ const currentReady = Boolean(settled && snapshot?.status === 'ready' && !snapshot.stale && runtime && ((runtime.status === 'ready' && runtime.runtimeId)
66
+ || ((acknowledged || selectionChanged) && !snapshot.selection?.variantId && !runtime.runtimeId && ['absent', 'mounting'].includes(runtime.status))));
67
+ const notify = currentReady && (!ready.value || readyDocument !== runtime?.runtimeId);
68
+ ready.value = currentReady;
69
+ readyDocument = currentReady ? runtime?.runtimeId : undefined;
70
+ if (currentReady)
71
+ error.value = undefined;
72
+ if (notify)
73
+ emit('ready');
74
+ }
75
+ onMounted(() => {
76
+ if (removed || !container.value)
77
+ return;
78
+ try {
79
+ mount = session.mount(container.value, { surface });
80
+ stopReadiness = session.subscribe(synchronizeReadiness);
81
+ stopFocus = subscribeHistoireMountEvents(mount, (event) => {
82
+ if (event.event !== 'focus.changed')
83
+ return;
84
+ const action = event.payload.action;
85
+ if (action === 'search')
86
+ focusHistoireSearch(context.root.value);
87
+ else if (action === 'toggle-ui')
88
+ requestHistoireUiToggle(context.root.value);
89
+ else if (action === 'show-ui')
90
+ requestHistoireUiShow(context.root.value);
91
+ });
92
+ mount.ready.then(() => {
93
+ if (removed)
94
+ return;
95
+ settled = acknowledged = true;
96
+ synchronizeReadiness();
97
+ }, (value) => {
98
+ const snapshot = currentSnapshot();
99
+ if (!snapshot)
100
+ return;
101
+ settled = true;
102
+ // Selecting docs/null retires initial readiness, not this live mount.
103
+ if (value instanceof HistoireSdkError && value.code === 'RUNTIME_CHANGED' && selectionChanged && snapshot.status === 'ready' && !snapshot.stale && !['failed', 'stale'].includes(snapshot.runtime.status))
104
+ synchronizeReadiness();
105
+ else
106
+ fail(value);
107
+ });
108
+ }
109
+ catch (value) {
110
+ fail(value);
111
+ }
112
+ });
113
+ expose({
114
+ unmount,
115
+ get mount() {
116
+ return mount;
117
+ },
118
+ });
119
+ return () => h('div', { ...attrs, 'class': ['histoire-primary', attrs.class], 'data-histoire-surface': surface }, [
120
+ // Story DOM may paint before the framework has admitted its actor. Keep
121
+ // the viewport measurable while preventing input that cannot be owned yet.
122
+ h('div', { 'ref': container, 'class': 'histoire-primary-frame', 'aria-busy': !ready.value && !error.value, 'inert': ready.value ? undefined : true }),
123
+ error.value
124
+ ? (slots.error?.({ error: error.value }) ?? h('div', { role: 'alert', class: 'histoire-primary-status' }, error.value instanceof Error ? error.value.message : 'Variant failed to render.'))
125
+ : loadingVisible.value && slots.loading ? h(LoadingDelayBoundary, null, slots.loading) : null,
126
+ ]);
127
+ },
128
+ });
129
+ }
@@ -0,0 +1,9 @@
1
+ /** Independent search reuses source Fuse ranking; superseded queries never render or activate. */
2
+ export declare const HistoireSearch: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
+ [key: string]: any;
4
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("error" | "query" | "select")[], "error" | "query" | "select", import("vue").PublicProps, Readonly<{}> & Readonly<{
5
+ onError?: ((...args: any[]) => any) | undefined;
6
+ onQuery?: ((...args: any[]) => any) | undefined;
7
+ onSelect?: ((...args: any[]) => any) | undefined;
8
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
9
+ //# sourceMappingURL=HistoireSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistoireSearch.d.ts","sourceRoot":"","sources":["../../../src/components/search/HistoireSearch.ts"],"names":[],"mappings":"AASA,kGAAkG;AAClG,eAAO,MAAM,cAAc;;;;;;iFAwDzB,CAAA"}