@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.
- package/LICENSE +21 -0
- package/dist/components/controls/GenericControls.d.ts +30 -0
- package/dist/components/controls/GenericControls.d.ts.map +1 -0
- package/dist/components/controls/GenericControls.js +34 -0
- package/dist/components/controls/HistoireControls.d.ts +30 -0
- package/dist/components/controls/HistoireControls.d.ts.map +1 -0
- package/dist/components/controls/HistoireControls.js +176 -0
- package/dist/components/controls/PresetMenu.d.ts +63 -0
- package/dist/components/controls/PresetMenu.d.ts.map +1 -0
- package/dist/components/controls/PresetMenu.js +180 -0
- package/dist/components/controls/PropControl.d.ts +40 -0
- package/dist/components/controls/PropControl.d.ts.map +1 -0
- package/dist/components/controls/PropControl.js +66 -0
- package/dist/components/controls/StateControl.d.ts +15 -0
- package/dist/components/controls/StateControl.d.ts.map +1 -0
- package/dist/components/controls/StateControl.js +30 -0
- package/dist/components/controls/StatePresets.d.ts +37 -0
- package/dist/components/controls/StatePresets.d.ts.map +1 -0
- package/dist/components/controls/StatePresets.js +105 -0
- package/dist/components/controls/edit.d.ts +10 -0
- package/dist/components/controls/edit.d.ts.map +1 -0
- package/dist/components/controls/edit.js +82 -0
- package/dist/components/controls/editor.d.ts +9 -0
- package/dist/components/controls/editor.d.ts.map +1 -0
- package/dist/components/controls/editor.js +28 -0
- package/dist/components/docs/HistoireDocs.d.ts +44 -0
- package/dist/components/docs/HistoireDocs.d.ts.map +1 -0
- package/dist/components/docs/HistoireDocs.js +124 -0
- package/dist/components/docs/anchors.d.ts +3 -0
- package/dist/components/docs/anchors.d.ts.map +1 -0
- package/dist/components/docs/anchors.js +26 -0
- package/dist/components/docs/content.d.ts +11 -0
- package/dist/components/docs/content.d.ts.map +1 -0
- package/dist/components/docs/content.js +7 -0
- package/dist/components/docs/links.d.ts +20 -0
- package/dist/components/docs/links.d.ts.map +1 -0
- package/dist/components/docs/links.js +85 -0
- package/dist/components/docs/sanitize.d.ts +3 -0
- package/dist/components/docs/sanitize.d.ts.map +1 -0
- package/dist/components/docs/sanitize.js +16 -0
- package/dist/components/embed/EmbedPanels.d.ts +21 -0
- package/dist/components/embed/EmbedPanels.d.ts.map +1 -0
- package/dist/components/embed/EmbedPanels.js +49 -0
- package/dist/components/embed/HistoireEmbed.d.ts +36 -0
- package/dist/components/embed/HistoireEmbed.d.ts.map +1 -0
- package/dist/components/embed/HistoireEmbed.js +81 -0
- package/dist/components/embed/geometry.d.ts +5 -0
- package/dist/components/embed/geometry.d.ts.map +1 -0
- package/dist/components/embed/geometry.js +38 -0
- package/dist/components/events/HistoireEvents.d.ts +30 -0
- package/dist/components/events/HistoireEvents.d.ts.map +1 -0
- package/dist/components/events/HistoireEvents.js +88 -0
- package/dist/components/explorer/ExplorerNavigation.d.ts +20 -0
- package/dist/components/explorer/ExplorerNavigation.d.ts.map +1 -0
- package/dist/components/explorer/ExplorerNavigation.js +15 -0
- package/dist/components/explorer/ExplorerPanels.d.ts +42 -0
- package/dist/components/explorer/ExplorerPanels.d.ts.map +1 -0
- package/dist/components/explorer/ExplorerPanels.js +87 -0
- package/dist/components/explorer/ExplorerPreview.d.ts +29 -0
- package/dist/components/explorer/ExplorerPreview.d.ts.map +1 -0
- package/dist/components/explorer/ExplorerPreview.js +93 -0
- package/dist/components/explorer/HistoireExplorer.d.ts +47 -0
- package/dist/components/explorer/HistoireExplorer.d.ts.map +1 -0
- package/dist/components/explorer/HistoireExplorer.js +41 -0
- package/dist/components/explorer/panel-tabs.d.ts +48 -0
- package/dist/components/explorer/panel-tabs.d.ts.map +1 -0
- package/dist/components/explorer/panel-tabs.js +58 -0
- package/dist/components/extensions/HistoireExtensionOutlet.d.ts +47 -0
- package/dist/components/extensions/HistoireExtensionOutlet.d.ts.map +1 -0
- package/dist/components/extensions/HistoireExtensionOutlet.js +35 -0
- package/dist/components/extensions/HistoireExtensionView.d.ts +59 -0
- package/dist/components/extensions/HistoireExtensionView.d.ts.map +1 -0
- package/dist/components/extensions/HistoireExtensionView.js +58 -0
- package/dist/components/extensions/panel-action.d.ts +38 -0
- package/dist/components/extensions/panel-action.d.ts.map +1 -0
- package/dist/components/extensions/panel-action.js +19 -0
- package/dist/components/extensions/state-renderer.d.ts +17 -0
- package/dist/components/extensions/state-renderer.d.ts.map +1 -0
- package/dist/components/extensions/state-renderer.js +72 -0
- package/dist/components/extensions/view-lifecycle.d.ts +47 -0
- package/dist/components/extensions/view-lifecycle.d.ts.map +1 -0
- package/dist/components/extensions/view-lifecycle.js +108 -0
- package/dist/components/extensions/workbench-components.d.ts +9 -0
- package/dist/components/extensions/workbench-components.d.ts.map +1 -0
- package/dist/components/extensions/workbench-components.js +82 -0
- package/dist/components/preview/HistoirePreview.d.ts +11 -0
- package/dist/components/preview/HistoirePreview.d.ts.map +1 -0
- package/dist/components/preview/HistoirePreview.js +3 -0
- package/dist/components/preview/surface.d.ts +13 -0
- package/dist/components/preview/surface.d.ts.map +1 -0
- package/dist/components/preview/surface.js +129 -0
- package/dist/components/search/HistoireSearch.d.ts +9 -0
- package/dist/components/search/HistoireSearch.d.ts.map +1 -0
- package/dist/components/search/HistoireSearch.js +66 -0
- package/dist/components/source/HistoireSource.d.ts +58 -0
- package/dist/components/source/HistoireSource.d.ts.map +1 -0
- package/dist/components/source/HistoireSource.js +85 -0
- package/dist/components/source/content.d.ts +11 -0
- package/dist/components/source/content.d.ts.map +1 -0
- package/dist/components/source/content.js +7 -0
- package/dist/components/source/highlight.d.ts +3 -0
- package/dist/components/source/highlight.d.ts.map +1 -0
- package/dist/components/source/highlight.js +15 -0
- package/dist/components/source/render.d.ts +6 -0
- package/dist/components/source/render.d.ts.map +1 -0
- package/dist/components/source/render.js +11 -0
- package/dist/components/tests/HistoireTests.d.ts +66 -0
- package/dist/components/tests/HistoireTests.d.ts.map +1 -0
- package/dist/components/tests/HistoireTests.js +109 -0
- package/dist/components/tests/TestsRunActions.d.ts +54 -0
- package/dist/components/tests/TestsRunActions.d.ts.map +1 -0
- package/dist/components/tests/TestsRunActions.js +138 -0
- package/dist/components/tests/render.d.ts +33 -0
- package/dist/components/tests/render.d.ts.map +1 -0
- package/dist/components/tests/render.js +103 -0
- package/dist/components/toolbar/HistoireToolbar.d.ts +7 -0
- package/dist/components/toolbar/HistoireToolbar.d.ts.map +1 -0
- package/dist/components/toolbar/HistoireToolbar.js +66 -0
- package/dist/components/toolbar/ToolbarExtensions.d.ts +27 -0
- package/dist/components/toolbar/ToolbarExtensions.d.ts.map +1 -0
- package/dist/components/toolbar/ToolbarExtensions.js +79 -0
- package/dist/components/toolbar/groups.d.ts +19 -0
- package/dist/components/toolbar/groups.d.ts.map +1 -0
- package/dist/components/toolbar/groups.js +18 -0
- package/dist/components/tree/HistoireStoryTree.d.ts +40 -0
- package/dist/components/tree/HistoireStoryTree.d.ts.map +1 -0
- package/dist/components/tree/HistoireStoryTree.js +57 -0
- package/dist/composables/session.d.ts +4 -0
- package/dist/composables/session.d.ts.map +1 -0
- package/dist/composables/session.js +5 -0
- package/dist/composables/snapshot.d.ts +5 -0
- package/dist/composables/snapshot.d.ts.map +1 -0
- package/dist/composables/snapshot.js +9 -0
- package/dist/content/controller.d.ts +20 -0
- package/dist/content/controller.d.ts.map +1 -0
- package/dist/content/controller.js +54 -0
- package/dist/content.css +22 -0
- package/dist/controls.css +26 -0
- package/dist/embed.css +15 -0
- package/dist/explorer.css +67 -0
- package/dist/extensions.css +20 -0
- package/dist/foundation/VirtualList.d.ts +114 -0
- package/dist/foundation/VirtualList.d.ts.map +1 -0
- package/dist/foundation/VirtualList.js +126 -0
- package/dist/foundation/floating.d.ts +9 -0
- package/dist/foundation/floating.d.ts.map +1 -0
- package/dist/foundation/floating.js +90 -0
- package/dist/foundation/parts.d.ts +13 -0
- package/dist/foundation/parts.d.ts.map +1 -0
- package/dist/foundation/parts.js +13 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/internal.d.ts +31 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +26 -0
- package/dist/navigation.css +51 -0
- package/dist/overlays/OverlayHost.d.ts +21 -0
- package/dist/overlays/OverlayHost.d.ts.map +1 -0
- package/dist/overlays/OverlayHost.js +118 -0
- package/dist/overlays/geometry.d.ts +4 -0
- package/dist/overlays/geometry.d.ts.map +1 -0
- package/dist/overlays/geometry.js +7 -0
- package/dist/overlays/menu-bounds.d.ts +10 -0
- package/dist/overlays/menu-bounds.d.ts.map +1 -0
- package/dist/overlays/menu-bounds.js +52 -0
- package/dist/provider/HistoireProvider.d.ts +43 -0
- package/dist/provider/HistoireProvider.d.ts.map +1 -0
- package/dist/provider/HistoireProvider.js +183 -0
- package/dist/provider/context.d.ts +37 -0
- package/dist/provider/context.d.ts.map +1 -0
- package/dist/provider/context.js +16 -0
- package/dist/provider/extensions.d.ts +61 -0
- package/dist/provider/extensions.d.ts.map +1 -0
- package/dist/provider/extensions.js +139 -0
- package/dist/provider/panels.d.ts +33 -0
- package/dist/provider/panels.d.ts.map +1 -0
- package/dist/provider/panels.js +53 -0
- package/dist/provider/plugin-shortcuts.d.ts +22 -0
- package/dist/provider/plugin-shortcuts.d.ts.map +1 -0
- package/dist/provider/plugin-shortcuts.js +73 -0
- package/dist/provider/shortcuts.d.ts +16 -0
- package/dist/provider/shortcuts.d.ts.map +1 -0
- package/dist/provider/shortcuts.js +62 -0
- package/dist/provider/theme.d.ts +4 -0
- package/dist/provider/theme.d.ts.map +1 -0
- package/dist/provider/theme.js +25 -0
- package/dist/search/navigation.d.ts +27 -0
- package/dist/search/navigation.d.ts.map +1 -0
- package/dist/search/navigation.js +61 -0
- package/dist/style.css +88 -0
- package/dist/tests/collector.d.ts +16 -0
- package/dist/tests/collector.d.ts.map +1 -0
- package/dist/tests/collector.js +51 -0
- package/dist/tests/controller.d.ts +28 -0
- package/dist/tests/controller.d.ts.map +1 -0
- package/dist/tests/controller.js +79 -0
- package/dist/tests/model.d.ts +20 -0
- package/dist/tests/model.d.ts.map +1 -0
- package/dist/tests/model.js +18 -0
- package/dist/tests.css +59 -0
- package/dist/virtual-list.css +6 -0
- package/package.json +58 -3
- package/README.md +0 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { HstButton, HstPulsatingDisc } from '@histoire/controls/vue';
|
|
2
|
+
import { createContributionKeys } from '@histoire/plugin-kit';
|
|
3
|
+
import { defineComponent, h, shallowRef, watch } from 'vue';
|
|
4
|
+
import { useHistoireSnapshot } from '../../composables/snapshot.js';
|
|
5
|
+
import { useHistoireContext } from '../../provider/context.js';
|
|
6
|
+
import { useProvidedHistoireTestsModel } from '../../tests/model.js';
|
|
7
|
+
import { HistoireExtensionOutlet } from '../extensions/HistoireExtensionOutlet.js';
|
|
8
|
+
import { HistoireExtensionView } from '../extensions/HistoireExtensionView.js';
|
|
9
|
+
import { HistoireSource } from '../source/HistoireSource.js';
|
|
10
|
+
import { getNativePanelKey, NATIVE_BUILTIN_PANELS, readPluginBadge, resolvePanel } from './panel-tabs.js';
|
|
11
|
+
/**
|
|
12
|
+
* Shared independent panels; standalone controls active tab through routing adapter.
|
|
13
|
+
* Built-in tabs come from the descriptors the standalone inspector uses; plugin tabs and
|
|
14
|
+
* sections from the provider's extension host follow them.
|
|
15
|
+
*/
|
|
16
|
+
export const ExplorerPanels = defineComponent({
|
|
17
|
+
name: 'HistoireExplorerPanels',
|
|
18
|
+
props: {
|
|
19
|
+
activePanel: { type: String, default: undefined },
|
|
20
|
+
docsAnchor: { type: String, default: '' },
|
|
21
|
+
sourceMode: { type: String, default: 'raw' },
|
|
22
|
+
},
|
|
23
|
+
emits: ['panel', 'error'],
|
|
24
|
+
setup(props, { emit }) {
|
|
25
|
+
const snapshot = useHistoireSnapshot();
|
|
26
|
+
const context = useHistoireContext();
|
|
27
|
+
const { extensions } = context;
|
|
28
|
+
const tests = useProvidedHistoireTestsModel(context.session);
|
|
29
|
+
const selected = shallowRef('controls');
|
|
30
|
+
const failedBadges = new WeakSet();
|
|
31
|
+
const keyOf = createContributionKeys();
|
|
32
|
+
// Successful docs search activates this provider's shared panel only.
|
|
33
|
+
// Caller slots/visibility and explicitly controlled standalone routing remain authoritative.
|
|
34
|
+
watch(() => context.panels.docs.value, (intent) => {
|
|
35
|
+
if (intent)
|
|
36
|
+
selected.value = 'docs';
|
|
37
|
+
}, { immediate: true, flush: 'sync' });
|
|
38
|
+
// Plugin navigation (`openInspectorTab`) selects through the same path as a click.
|
|
39
|
+
watch(() => context.panels.tab.value, (intent) => {
|
|
40
|
+
if (intent)
|
|
41
|
+
select(getNativePanelKey(intent.id));
|
|
42
|
+
}, { flush: 'sync' });
|
|
43
|
+
/** External route owns requested tab; embedded explorer keeps local memory only. */
|
|
44
|
+
function select(value) {
|
|
45
|
+
selected.value = value;
|
|
46
|
+
context.panels.clear();
|
|
47
|
+
emit('panel', value);
|
|
48
|
+
}
|
|
49
|
+
/** Inspector sections of one tab and position, or the footer. */
|
|
50
|
+
function sections(tab, position) {
|
|
51
|
+
return h(HistoireExtensionOutlet, { kind: 'inspector.section', filter: (section) => {
|
|
52
|
+
const value = section;
|
|
53
|
+
return value.tab === tab && (position === undefined || value.position === position);
|
|
54
|
+
} });
|
|
55
|
+
}
|
|
56
|
+
/** One tab button. */
|
|
57
|
+
function tabButton(key, active, label) {
|
|
58
|
+
return h(HstButton, { 'color': 'flat', 'type': 'button', 'role': 'tab', 'aria-selected': active, 'onClick': () => select(key) }, { default: () => label });
|
|
59
|
+
}
|
|
60
|
+
return () => {
|
|
61
|
+
const frame = extensions.frame;
|
|
62
|
+
const pluginTabs = extensions.available('inspector.tab', frame);
|
|
63
|
+
const requested = props.activePanel ?? selected.value;
|
|
64
|
+
const active = resolvePanel(requested, pluginTabs, extensions);
|
|
65
|
+
const activeKey = active.type === 'builtin' ? active.panel.key : active.type === 'plugin' ? active.tab.id : requested;
|
|
66
|
+
const activeId = active.type === 'builtin' ? active.panel.descriptor.id : activeKey;
|
|
67
|
+
const story = snapshot.value.catalog.stories.find(story => story.id === snapshot.value.selection?.storyId);
|
|
68
|
+
const body = active.type === 'builtin'
|
|
69
|
+
? h(active.panel.component, { anchor: props.docsAnchor, onError: (error) => emit('error', error) })
|
|
70
|
+
: active.type === 'plugin' && frame
|
|
71
|
+
? h(HistoireExtensionView, { key: keyOf(active.tab), contribution: active.tab, context: frame })
|
|
72
|
+
: h('div', { 'aria-busy': 'true', 'aria-label': 'Loading panel' }, h(HstPulsatingDisc, { size: 16 }));
|
|
73
|
+
return h('aside', { 'class': 'histoire-explorer-panels', 'aria-label': 'Histoire panels' }, [
|
|
74
|
+
h('div', { class: 'histoire-explorer-tabs', role: 'tablist' }, [
|
|
75
|
+
...NATIVE_BUILTIN_PANELS.map(panel => tabButton(panel.key, activeKey === panel.key, [panel.label, panel.key === 'tests' && tests?.state.value.collection ? h('span', { 'aria-label': 'Collected tests' }, ` ${tests.state.value.collection.definitions.length}`) : null])),
|
|
76
|
+
...pluginTabs.map((tab) => {
|
|
77
|
+
const badge = frame && readPluginBadge(tab, frame, extensions, failedBadges);
|
|
78
|
+
return tabButton(tab.id, activeKey === tab.id, [tab.label, badge != null && badge !== '' ? h('span', null, ` ${badge}`) : null]);
|
|
79
|
+
}),
|
|
80
|
+
]),
|
|
81
|
+
h('div', { class: 'histoire-explorer-panel' }, [sections(activeId, 'before'), body, sections(activeId, 'after')]),
|
|
82
|
+
sections('footer'),
|
|
83
|
+
story?.content.rawSource ? h(HistoireSource, { mode: props.sourceMode === 'dynamic' ? 'dynamic' : 'raw', onError: (error) => emit('error', error) }) : null,
|
|
84
|
+
]);
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Explorer primary runtime returns only after owned runtime teardown finishes. */
|
|
2
|
+
export declare const ExplorerPreview: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
active: {
|
|
4
|
+
type: BooleanConstructor;
|
|
5
|
+
default: boolean;
|
|
6
|
+
};
|
|
7
|
+
docsAnchor: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("error" | "ready")[], "error" | "ready", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
+
active: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
docsAnchor: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
}>> & Readonly<{
|
|
23
|
+
onError?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
onReady?: ((...args: any[]) => any) | undefined;
|
|
25
|
+
}>, {
|
|
26
|
+
active: boolean;
|
|
27
|
+
docsAnchor: string;
|
|
28
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
29
|
+
//# sourceMappingURL=ExplorerPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExplorerPreview.d.ts","sourceRoot":"","sources":["../../../src/components/explorer/ExplorerPreview.ts"],"names":[],"mappings":"AASA,mFAAmF;AACnF,eAAO,MAAM,eAAe;;QAEP,IAAI;QAAW,OAAO;;;QAAwB,IAAI;QAAU,OAAO;;;;;;;;;;;;;;;;;;;4EAyEtF,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { HstButton, HstSelect } from '@histoire/controls/vue';
|
|
2
|
+
import { waitForHistoireSelection } from '@histoire/sdk/internal';
|
|
3
|
+
import { defineComponent, h, nextTick, shallowRef, watch } from 'vue';
|
|
4
|
+
import { useHistoireSnapshot } from '../../composables/snapshot.js';
|
|
5
|
+
import { useHistoireContext, useHistoireResource } from '../../provider/context.js';
|
|
6
|
+
import { HISTOIRE_SHORTCUT_SCOPE_ATTRIBUTE } from '../../provider/plugin-shortcuts.js';
|
|
7
|
+
import { HistoireDocs } from '../docs/HistoireDocs.js';
|
|
8
|
+
import { HistoirePreview } from '../preview/HistoirePreview.js';
|
|
9
|
+
/** Explorer primary runtime returns only after owned runtime teardown finishes. */
|
|
10
|
+
export const ExplorerPreview = defineComponent({
|
|
11
|
+
name: 'HistoireExplorerPreview',
|
|
12
|
+
props: { active: { type: Boolean, default: true }, docsAnchor: { type: String, default: '' } },
|
|
13
|
+
emits: ['ready', 'error'],
|
|
14
|
+
setup(props, { emit, slots }) {
|
|
15
|
+
const { session } = useHistoireContext();
|
|
16
|
+
const snapshot = useHistoireSnapshot();
|
|
17
|
+
const mode = shallowRef('empty');
|
|
18
|
+
const switching = shallowRef(false);
|
|
19
|
+
const primary = shallowRef(null);
|
|
20
|
+
let generation = 0;
|
|
21
|
+
let active = true;
|
|
22
|
+
let closing = Promise.resolve();
|
|
23
|
+
/** Preserve primary slot ownership until old transport actually closes. */
|
|
24
|
+
async function select(value, automatic = false) {
|
|
25
|
+
const token = ++generation;
|
|
26
|
+
if (!switching.value && mode.value === value)
|
|
27
|
+
return;
|
|
28
|
+
// Retain a settled transport for null targets. During teardown the latest
|
|
29
|
+
// transition must join closing and clear switching after its predecessor retires.
|
|
30
|
+
if (!switching.value && props.active) {
|
|
31
|
+
mode.value = value;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (automatic && props.active && primary.value) {
|
|
35
|
+
await waitForHistoireSelection(session);
|
|
36
|
+
if (!active || token !== generation)
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const owned = primary.value;
|
|
40
|
+
switching.value = true;
|
|
41
|
+
try {
|
|
42
|
+
if (owned)
|
|
43
|
+
closing = owned.unmount();
|
|
44
|
+
await closing;
|
|
45
|
+
if (!active || token !== generation)
|
|
46
|
+
return;
|
|
47
|
+
await nextTick();
|
|
48
|
+
if (!active || token !== generation)
|
|
49
|
+
return;
|
|
50
|
+
mode.value = value;
|
|
51
|
+
switching.value = false;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (active && token === generation)
|
|
55
|
+
emit('error', error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
watch([() => snapshot.value.selection?.storyId, () => props.active, () => snapshot.value.catalog.stories.find(story => story.id === snapshot.value.selection?.storyId)?.docsOnly], () => {
|
|
59
|
+
const story = snapshot.value.catalog.stories.find(story => story.id === snapshot.value.selection?.storyId);
|
|
60
|
+
void select(!props.active || !story ? 'empty' : story.docsOnly ? 'docs' : 'preview', true);
|
|
61
|
+
}, { immediate: true });
|
|
62
|
+
/** Catalog variant choice changes canonical target, retaining owned primary transport. */
|
|
63
|
+
function selectVariant(variantId) {
|
|
64
|
+
const storyId = snapshot.value.selection?.storyId;
|
|
65
|
+
if (!active || !storyId)
|
|
66
|
+
return;
|
|
67
|
+
void session.selection.select({ storyId, variantId }).catch((error) => {
|
|
68
|
+
if (active)
|
|
69
|
+
emit('error', error);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
useHistoireResource(() => {
|
|
73
|
+
active = false;
|
|
74
|
+
generation++;
|
|
75
|
+
return primary.value?.unmount() ?? closing;
|
|
76
|
+
});
|
|
77
|
+
return () => {
|
|
78
|
+
const story = snapshot.value.catalog.stories.find(story => story.id === snapshot.value.selection?.storyId);
|
|
79
|
+
const showingRuntime = mode.value === 'preview';
|
|
80
|
+
// Plugin shortcut focus areas: the whole canvas, and the single-variant frame inside it.
|
|
81
|
+
return h('main', { 'class': 'histoire-explorer-preview', 'aria-label': 'Histoire canvas', [HISTOIRE_SHORTCUT_SCOPE_ATTRIBUTE]: 'canvas' }, [
|
|
82
|
+
mode.value === 'docs' ? h(HistoireDocs, { key: 'docs', anchor: props.docsAnchor, onError: error => emit('error', error) }) : mode.value === 'empty' ? slots.empty?.() : null,
|
|
83
|
+
showingRuntime && snapshot.value.selection?.variantId && story
|
|
84
|
+
? h('div', { class: 'histoire-explorer-layout' }, [
|
|
85
|
+
h(HstSelect, { 'layout': 'inline', 'aria-label': 'Variant', 'modelValue': snapshot.value.selection.variantId, 'onUpdate:modelValue': selectVariant, 'options': story.variants.map(variant => ({ value: variant.id, label: variant.title })) }),
|
|
86
|
+
])
|
|
87
|
+
: null,
|
|
88
|
+
showingRuntime && !snapshot.value.selection?.variantId && story ? h('div', { 'role': 'group', 'aria-label': 'Choose variant' }, story.variants.map(variant => h(HstButton, { 'color': 'flat', 'type': 'button', 'data-test-id': 'story-variant-list-item', 'onClick': () => void session.selection.select({ storyId: story.id, variantId: variant.id }).catch(error => emit('error', error)) }, { default: () => variant.title }))) : null,
|
|
89
|
+
props.active && !switching.value ? h(HistoirePreview, { 'key': 'runtime', 'ref': primary, [HISTOIRE_SHORTCUT_SCOPE_ATTRIBUTE]: showingRuntime && snapshot.value.selection?.variantId ? 'frame' : undefined, 'style': showingRuntime ? undefined : { position: 'absolute', inset: '0', visibility: 'hidden', pointerEvents: 'none' }, 'aria-hidden': !showingRuntime, 'onReady': () => emit('ready'), 'onError': error => emit('error', error) }) : null,
|
|
90
|
+
]);
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Reusable composition consumes explicit provider; host owns URL/title and session. */
|
|
2
|
+
export declare const HistoireExplorer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
showNavigation: {
|
|
4
|
+
type: BooleanConstructor;
|
|
5
|
+
default: boolean;
|
|
6
|
+
};
|
|
7
|
+
showSearch: {
|
|
8
|
+
type: BooleanConstructor;
|
|
9
|
+
default: boolean;
|
|
10
|
+
};
|
|
11
|
+
showToolbar: {
|
|
12
|
+
type: BooleanConstructor;
|
|
13
|
+
default: boolean;
|
|
14
|
+
};
|
|
15
|
+
showPanels: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
default: boolean;
|
|
18
|
+
};
|
|
19
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("error" | "ready")[], "error" | "ready", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
|
+
showNavigation: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
showSearch: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
showToolbar: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
showPanels: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
38
|
+
}>> & Readonly<{
|
|
39
|
+
onError?: ((...args: any[]) => any) | undefined;
|
|
40
|
+
onReady?: ((...args: any[]) => any) | undefined;
|
|
41
|
+
}>, {
|
|
42
|
+
showNavigation: boolean;
|
|
43
|
+
showSearch: boolean;
|
|
44
|
+
showToolbar: boolean;
|
|
45
|
+
showPanels: boolean;
|
|
46
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
47
|
+
//# sourceMappingURL=HistoireExplorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HistoireExplorer.d.ts","sourceRoot":"","sources":["../../../src/components/explorer/HistoireExplorer.ts"],"names":[],"mappings":"AASA,wFAAwF;AACxF,eAAO,MAAM,gBAAgB;;QAGP,IAAI;QAAW,OAAO;;;QAC1B,IAAI;QAAW,OAAO;;;QACrB,IAAI;QAAW,OAAO;;;QACvB,IAAI;QAAW,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAyBtC,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { useHistoireSnapshot } from '../../composables/snapshot.js';
|
|
3
|
+
import { useHistoireContext } from '../../provider/context.js';
|
|
4
|
+
import { HistoireSearch } from '../search/HistoireSearch.js';
|
|
5
|
+
import { HistoireToolbar } from '../toolbar/HistoireToolbar.js';
|
|
6
|
+
import { ExplorerNavigation } from './ExplorerNavigation.js';
|
|
7
|
+
import { ExplorerPanels } from './ExplorerPanels.js';
|
|
8
|
+
import { ExplorerPreview } from './ExplorerPreview.js';
|
|
9
|
+
/** Reusable composition consumes explicit provider; host owns URL/title and session. */
|
|
10
|
+
export const HistoireExplorer = defineComponent({
|
|
11
|
+
name: 'HistoireExplorer',
|
|
12
|
+
props: {
|
|
13
|
+
showNavigation: { type: Boolean, default: true },
|
|
14
|
+
showSearch: { type: Boolean, default: true },
|
|
15
|
+
showToolbar: { type: Boolean, default: true },
|
|
16
|
+
showPanels: { type: Boolean, default: true },
|
|
17
|
+
},
|
|
18
|
+
emits: ['ready', 'error'],
|
|
19
|
+
setup(props, { slots, emit }) {
|
|
20
|
+
const { session } = useHistoireContext();
|
|
21
|
+
const snapshot = useHistoireSnapshot();
|
|
22
|
+
/** Parts retain own scoped errors; explorer adds one composition observation. */
|
|
23
|
+
function error(value) {
|
|
24
|
+
emit('error', value);
|
|
25
|
+
}
|
|
26
|
+
return () => {
|
|
27
|
+
const context = { session, snapshot: snapshot.value };
|
|
28
|
+
return h('div', { class: 'histoire-explorer' }, [
|
|
29
|
+
props.showNavigation ? (slots.navigation?.(context) ?? h(ExplorerNavigation, { showSearch: props.showSearch, onError: error })) : null,
|
|
30
|
+
h('div', { class: 'histoire-explorer-main' }, [
|
|
31
|
+
!props.showNavigation && props.showSearch ? h(HistoireSearch, { onError: error }) : null,
|
|
32
|
+
props.showToolbar ? (slots.toolbar?.(context) ?? h(HistoireToolbar, { onError: error })) : null,
|
|
33
|
+
h('div', { class: 'histoire-explorer-workspace' }, [
|
|
34
|
+
slots.preview?.(context) ?? h(ExplorerPreview, { onReady: () => emit('ready'), onError: error }),
|
|
35
|
+
props.showPanels ? (slots.panels?.(context) ?? h(ExplorerPanels, { onError: error })) : null,
|
|
36
|
+
]),
|
|
37
|
+
]),
|
|
38
|
+
]);
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { BuiltinInspectorTabDescriptor, FrameScopedContext, QualifiedContribution } from '@histoire/plugin-kit';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
import type { HistoireProviderExtensions } from '../../provider/extensions.js';
|
|
4
|
+
/** One built-in explorer panel: shared descriptor plus its native key, label and body. */
|
|
5
|
+
export interface NativeBuiltinPanel {
|
|
6
|
+
/** Shared built-in descriptor (`builtin:props`, ...). */
|
|
7
|
+
descriptor: BuiltinInspectorTabDescriptor;
|
|
8
|
+
/** Native `activePanel` value (`controls`, `docs`, ...). */
|
|
9
|
+
key: string;
|
|
10
|
+
/** Visible label; native explorers keep "Controls" for Props. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Panel body. */
|
|
13
|
+
component: Component;
|
|
14
|
+
}
|
|
15
|
+
/** Built-in explorer panels in shared descriptor order; plugin tabs follow them. */
|
|
16
|
+
export declare const NATIVE_BUILTIN_PANELS: readonly NativeBuiltinPanel[];
|
|
17
|
+
/**
|
|
18
|
+
* Native panel key of a navigation id: `builtin:` ids map to built-in keys, plugin ids stay.
|
|
19
|
+
* @param id Qualified tab id.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getNativePanelKey(id: string): string;
|
|
22
|
+
/** Active panel resolved against built-ins and the plugin tabs available now. */
|
|
23
|
+
export type ResolvedPanel = {
|
|
24
|
+
type: 'builtin';
|
|
25
|
+
panel: NativeBuiltinPanel;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'plugin';
|
|
28
|
+
tab: QualifiedContribution<'inspector.tab'>;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'pending';
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the requested panel. A plugin id waits while plugins set up, so deep links survive
|
|
34
|
+
* startup; afterwards a missing tab falls back to Controls.
|
|
35
|
+
* @param requested Requested native key or plugin id.
|
|
36
|
+
* @param tabs Plugin tabs available now.
|
|
37
|
+
* @param extensions Provider plugin state.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolvePanel(requested: string, tabs: ReadonlyArray<QualifiedContribution<'inspector.tab'>>, extensions: HistoireProviderExtensions): ResolvedPanel;
|
|
40
|
+
/**
|
|
41
|
+
* Plugin badge text; a throwing badge is hidden for good and reported once.
|
|
42
|
+
* @param tab Plugin tab.
|
|
43
|
+
* @param context Inspector context.
|
|
44
|
+
* @param extensions Provider plugin state.
|
|
45
|
+
* @param failed Tabs whose badge already failed.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readPluginBadge(tab: QualifiedContribution<'inspector.tab'>, context: FrameScopedContext, extensions: HistoireProviderExtensions, failed: WeakSet<object>): string | number | null | undefined;
|
|
48
|
+
//# sourceMappingURL=panel-tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-tabs.d.ts","sourceRoot":"","sources":["../../../src/components/explorer/panel-tabs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACpH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAO9E,0FAA0F;AAC1F,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,UAAU,EAAE,6BAA6B,CAAA;IACzC,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAA;IACX,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAA;IACb,kBAAkB;IAClB,SAAS,EAAE,SAAS,CAAA;CACrB;AAKD,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAK5D,CAAA;AAEH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,iFAAiF;AACjF,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAEvB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC,EAAE,UAAU,EAAE,0BAA0B,GAAG,aAAa,CAOlK;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,qBAAqB,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAU7M"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BUILTIN_INSPECTOR_TABS } from '@histoire/plugin-kit';
|
|
2
|
+
import { HistoireControls } from '../controls/HistoireControls.js';
|
|
3
|
+
import { HistoireDocs } from '../docs/HistoireDocs.js';
|
|
4
|
+
import { HistoireEvents } from '../events/HistoireEvents.js';
|
|
5
|
+
import { HistoireTests } from '../tests/HistoireTests.js';
|
|
6
|
+
/** Native bodies by shared legacy value. */
|
|
7
|
+
const BODIES = { '': HistoireControls, 'docs': HistoireDocs, 'events': HistoireEvents, 'tests': HistoireTests };
|
|
8
|
+
/** Built-in explorer panels in shared descriptor order; plugin tabs follow them. */
|
|
9
|
+
export const NATIVE_BUILTIN_PANELS = BUILTIN_INSPECTOR_TABS.map(descriptor => ({
|
|
10
|
+
descriptor,
|
|
11
|
+
key: descriptor.value || 'controls',
|
|
12
|
+
label: descriptor.value ? descriptor.label : 'Controls',
|
|
13
|
+
component: BODIES[descriptor.value],
|
|
14
|
+
}));
|
|
15
|
+
/**
|
|
16
|
+
* Native panel key of a navigation id: `builtin:` ids map to built-in keys, plugin ids stay.
|
|
17
|
+
* @param id Qualified tab id.
|
|
18
|
+
*/
|
|
19
|
+
export function getNativePanelKey(id) {
|
|
20
|
+
return NATIVE_BUILTIN_PANELS.find(panel => panel.descriptor.id === id)?.key ?? id;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the requested panel. A plugin id waits while plugins set up, so deep links survive
|
|
24
|
+
* startup; afterwards a missing tab falls back to Controls.
|
|
25
|
+
* @param requested Requested native key or plugin id.
|
|
26
|
+
* @param tabs Plugin tabs available now.
|
|
27
|
+
* @param extensions Provider plugin state.
|
|
28
|
+
*/
|
|
29
|
+
export function resolvePanel(requested, tabs, extensions) {
|
|
30
|
+
const builtin = NATIVE_BUILTIN_PANELS.find(panel => panel.key === requested);
|
|
31
|
+
if (builtin)
|
|
32
|
+
return { type: 'builtin', panel: builtin };
|
|
33
|
+
const tab = tabs.find(entry => entry.id === requested);
|
|
34
|
+
if (tab)
|
|
35
|
+
return { type: 'plugin', tab };
|
|
36
|
+
if (extensions.host && !extensions.ready && requested.includes(':'))
|
|
37
|
+
return { type: 'pending' };
|
|
38
|
+
return { type: 'builtin', panel: NATIVE_BUILTIN_PANELS[0] };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Plugin badge text; a throwing badge is hidden for good and reported once.
|
|
42
|
+
* @param tab Plugin tab.
|
|
43
|
+
* @param context Inspector context.
|
|
44
|
+
* @param extensions Provider plugin state.
|
|
45
|
+
* @param failed Tabs whose badge already failed.
|
|
46
|
+
*/
|
|
47
|
+
export function readPluginBadge(tab, context, extensions, failed) {
|
|
48
|
+
if (!tab.badge || failed.has(tab))
|
|
49
|
+
return undefined;
|
|
50
|
+
try {
|
|
51
|
+
return tab.badge(context);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
failed.add(tab);
|
|
55
|
+
extensions.host?.reportViewError(tab.id, error, 'report');
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ContributionKind, QualifiedContribution } from '@histoire/plugin-kit';
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Renders the available contributions of one surface kind from the provider's extension host,
|
|
5
|
+
* in registry order. Without `context`, inspector kinds use the selected variant's context and
|
|
6
|
+
* every other kind the provider's root context. Renders nothing without a host, without a
|
|
7
|
+
* context (no selected variant for inspector kinds) or for contributions unavailable there.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HistoireExtensionOutlet: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
/** Contribution kind placed here. */
|
|
11
|
+
kind: {
|
|
12
|
+
type: PropType<ContributionKind>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
/** Surface context; decides availability and is pushed to every view. */
|
|
16
|
+
context: {
|
|
17
|
+
type: ObjectConstructor;
|
|
18
|
+
default: undefined;
|
|
19
|
+
};
|
|
20
|
+
/** Narrows the placement, e.g. inspector sections of one tab and position. */
|
|
21
|
+
filter: {
|
|
22
|
+
type: PropType<(contribution: QualifiedContribution) => boolean>;
|
|
23
|
+
default: undefined;
|
|
24
|
+
};
|
|
25
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}>[] | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
28
|
+
/** Contribution kind placed here. */
|
|
29
|
+
kind: {
|
|
30
|
+
type: PropType<ContributionKind>;
|
|
31
|
+
required: true;
|
|
32
|
+
};
|
|
33
|
+
/** Surface context; decides availability and is pushed to every view. */
|
|
34
|
+
context: {
|
|
35
|
+
type: ObjectConstructor;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
/** Narrows the placement, e.g. inspector sections of one tab and position. */
|
|
39
|
+
filter: {
|
|
40
|
+
type: PropType<(contribution: QualifiedContribution) => boolean>;
|
|
41
|
+
default: undefined;
|
|
42
|
+
};
|
|
43
|
+
}>> & Readonly<{}>, {
|
|
44
|
+
context: Record<string, any>;
|
|
45
|
+
filter: (contribution: QualifiedContribution) => boolean;
|
|
46
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
47
|
+
//# sourceMappingURL=HistoireExtensionOutlet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HistoireExtensionOutlet.d.ts","sourceRoot":"","sources":["../../../src/components/extensions/HistoireExtensionOutlet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AASnC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAGhC,qCAAqC;;cACb,QAAQ,CAAC,gBAAgB,CAAC;;;IAClD,yEAAyE;;QAC9D,IAAI;QAAU,OAAO;;IAChC,8EAA8E;;QACpE,IAAI,EAAc,QAAQ,CAAC,CAAC,YAAY,EAAE,qBAAqB,KAAK,OAAO,CAAC;QAAE,OAAO;;;;;IAL/F,qCAAqC;;;;;IAErC,yEAAyE;;;;;IAEzE,8EAA8E;;;;;;;2BAC1B,qBAAqB,KAAK,OAAO;4EAavF,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createContributionKeys } from '@histoire/plugin-kit';
|
|
2
|
+
import { defineComponent, h } from 'vue';
|
|
3
|
+
import { useHistoireContext } from '../../provider/context.js';
|
|
4
|
+
import { HistoireExtensionView } from './HistoireExtensionView.js';
|
|
5
|
+
/** Kinds whose views receive the selected variant's inspector context by default. */
|
|
6
|
+
const FRAME_SCOPED = ['inspector.tab', 'inspector.section'];
|
|
7
|
+
/**
|
|
8
|
+
* Renders the available contributions of one surface kind from the provider's extension host,
|
|
9
|
+
* in registry order. Without `context`, inspector kinds use the selected variant's context and
|
|
10
|
+
* every other kind the provider's root context. Renders nothing without a host, without a
|
|
11
|
+
* context (no selected variant for inspector kinds) or for contributions unavailable there.
|
|
12
|
+
*/
|
|
13
|
+
export const HistoireExtensionOutlet = defineComponent({
|
|
14
|
+
name: 'HistoireExtensionOutlet',
|
|
15
|
+
props: {
|
|
16
|
+
/** Contribution kind placed here. */
|
|
17
|
+
kind: { type: String, required: true },
|
|
18
|
+
/** Surface context; decides availability and is pushed to every view. */
|
|
19
|
+
context: { type: Object, default: undefined },
|
|
20
|
+
/** Narrows the placement, e.g. inspector sections of one tab and position. */
|
|
21
|
+
filter: { type: Function, default: undefined },
|
|
22
|
+
},
|
|
23
|
+
setup(props) {
|
|
24
|
+
const { extensions } = useHistoireContext();
|
|
25
|
+
const keyOf = createContributionKeys();
|
|
26
|
+
return () => {
|
|
27
|
+
const context = props.context ?? (FRAME_SCOPED.includes(props.kind) ? extensions.frame : extensions.context);
|
|
28
|
+
if (!context)
|
|
29
|
+
return null;
|
|
30
|
+
const available = extensions.available(props.kind, context);
|
|
31
|
+
const placed = props.filter ? available.filter(props.filter) : available;
|
|
32
|
+
return placed.map(contribution => h(HistoireExtensionView, { key: keyOf(contribution), contribution, context }));
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { QualifiedContribution } from '@histoire/plugin-kit';
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Renders one contribution's view in a native provider: Vue `component` views through the
|
|
5
|
+
* caller's Vue app (same instance as the plugin when the host imported it), DOM `mount` views
|
|
6
|
+
* through the caller-owned extension host. Context snapshots update the view without remounting.
|
|
7
|
+
* Failures stay local to this view and are recorded as diagnostics of the contribution's plugin.
|
|
8
|
+
* Pending and failed views render the workbench state components plugin views also receive
|
|
9
|
+
* (an enclosing workbench's, else the native ones).
|
|
10
|
+
*/
|
|
11
|
+
export declare const HistoireExtensionView: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
12
|
+
/** Host utilities for documented component parts; package markers remain intact. */
|
|
13
|
+
classes: {
|
|
14
|
+
type: PropType<Partial<Record<"mount" | "root", string>>>;
|
|
15
|
+
default: undefined;
|
|
16
|
+
};
|
|
17
|
+
/** Explicit false makes the view inert; omission preserves host pointer behavior. */
|
|
18
|
+
interactive: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
/** Fixed for the component lifetime; key the component by contribution object. */
|
|
23
|
+
contribution: {
|
|
24
|
+
type: PropType<QualifiedContribution>;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
/** Surface context snapshot. */
|
|
28
|
+
context: {
|
|
29
|
+
type: ObjectConstructor;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
35
|
+
/** Host utilities for documented component parts; package markers remain intact. */
|
|
36
|
+
classes: {
|
|
37
|
+
type: PropType<Partial<Record<"mount" | "root", string>>>;
|
|
38
|
+
default: undefined;
|
|
39
|
+
};
|
|
40
|
+
/** Explicit false makes the view inert; omission preserves host pointer behavior. */
|
|
41
|
+
interactive: {
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
default: undefined;
|
|
44
|
+
};
|
|
45
|
+
/** Fixed for the component lifetime; key the component by contribution object. */
|
|
46
|
+
contribution: {
|
|
47
|
+
type: PropType<QualifiedContribution>;
|
|
48
|
+
required: true;
|
|
49
|
+
};
|
|
50
|
+
/** Surface context snapshot. */
|
|
51
|
+
context: {
|
|
52
|
+
type: ObjectConstructor;
|
|
53
|
+
required: true;
|
|
54
|
+
};
|
|
55
|
+
}>> & Readonly<{}>, {
|
|
56
|
+
classes: Partial<Record<"mount" | "root", string>>;
|
|
57
|
+
interactive: boolean;
|
|
58
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
59
|
+
//# sourceMappingURL=HistoireExtensionView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HistoireExtensionView.d.ts","sourceRoot":"","sources":["../../../src/components/extensions/HistoireExtensionView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAuB,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,KAAK,CAAA;AAS9C;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;IAG9B,oFAAoF;;;;;IAEpF,qFAAqF;;QACtE,IAAI;QAAW,OAAO;;IACrC,kFAAkF;;cAClD,QAAQ,CAAC,qBAAqB,CAAC;;;IAC/D,gCAAgC;;;;;;;;IANhC,oFAAoF;;;;;IAEpF,qFAAqF;;;;;IAErF,kFAAkF;;;;;IAElF,gCAAgC;;;;;;;;4EAkClC,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { LoadingDelayBoundary, useLoadingDelay } from '@histoire/controls/vue';
|
|
2
|
+
import { WORKBENCH_COMPONENTS_KEY } from '@histoire/plugin-kit';
|
|
3
|
+
import { defineComponent, h, inject } from 'vue';
|
|
4
|
+
import { mergePartClass, partClassesProp } from '../../foundation/parts.js';
|
|
5
|
+
import { useHistoireContext } from '../../provider/context.js';
|
|
6
|
+
import { useExtensionView } from './view-lifecycle.js';
|
|
7
|
+
import { histoireWorkbenchComponents } from './workbench-components.js';
|
|
8
|
+
/**
|
|
9
|
+
* Renders one contribution's view in a native provider: Vue `component` views through the
|
|
10
|
+
* caller's Vue app (same instance as the plugin when the host imported it), DOM `mount` views
|
|
11
|
+
* through the caller-owned extension host. Context snapshots update the view without remounting.
|
|
12
|
+
* Failures stay local to this view and are recorded as diagnostics of the contribution's plugin.
|
|
13
|
+
* Pending and failed views render the workbench state components plugin views also receive
|
|
14
|
+
* (an enclosing workbench's, else the native ones).
|
|
15
|
+
*/
|
|
16
|
+
export const HistoireExtensionView = defineComponent({
|
|
17
|
+
name: 'HistoireExtensionView',
|
|
18
|
+
props: {
|
|
19
|
+
/** Host utilities for documented component parts; package markers remain intact. */
|
|
20
|
+
classes: partClassesProp(),
|
|
21
|
+
/** Explicit false makes the view inert; omission preserves host pointer behavior. */
|
|
22
|
+
interactive: { type: Boolean, default: undefined },
|
|
23
|
+
/** Fixed for the component lifetime; key the component by contribution object. */
|
|
24
|
+
contribution: { type: Object, required: true },
|
|
25
|
+
/** Surface context snapshot. */
|
|
26
|
+
context: { type: Object, required: true },
|
|
27
|
+
},
|
|
28
|
+
setup(props) {
|
|
29
|
+
const provider = useHistoireContext();
|
|
30
|
+
const { id } = props.contribution;
|
|
31
|
+
const framed = 'degradedVisualIntegration' in props.contribution && props.contribution.degradedVisualIntegration === true;
|
|
32
|
+
const view = useExtensionView({
|
|
33
|
+
// Captured once: the outlet remounts views when the host or contribution changes.
|
|
34
|
+
host: provider.extensions.host,
|
|
35
|
+
contribution: props.contribution,
|
|
36
|
+
context: () => props.context,
|
|
37
|
+
overlayParent: () => provider.overlay.value ?? provider.root.value ?? document.body,
|
|
38
|
+
});
|
|
39
|
+
const { name } = view;
|
|
40
|
+
const loadingVisible = useLoadingDelay(() => view.pending.value && !view.failure.value && !view.component);
|
|
41
|
+
const components = inject(WORKBENCH_COMPONENTS_KEY, null);
|
|
42
|
+
const ErrorState = (components?.WorkbenchErrorState ?? histoireWorkbenchComponents.WorkbenchErrorState);
|
|
43
|
+
const LoadingState = (components?.WorkbenchLoadingState ?? histoireWorkbenchComponents.WorkbenchLoadingState);
|
|
44
|
+
return () => {
|
|
45
|
+
const error = view.failure.value?.error;
|
|
46
|
+
return h('div', { 'class': mergePartClass('histoire-extension-view', props.classes?.root), 'inert': props.interactive === false ? true : undefined, 'style': props.interactive === false ? { pointerEvents: 'none' } : undefined, 'data-histoire-interactive': props.interactive, 'data-histoire-contribution': id }, [
|
|
47
|
+
view.failure.value
|
|
48
|
+
? h(ErrorState, { title: name ? `${name} failed` : 'Extension failed' }, () => error instanceof Error ? error.message : String(error ?? ''))
|
|
49
|
+
: view.component
|
|
50
|
+
? framed
|
|
51
|
+
? h('div', { class: 'histoire-extension-degraded' }, [h(view.component, { context: view.current.value, onVnodeMounted: view.onComponentMounted })])
|
|
52
|
+
: h(view.component, { context: view.current.value, onVnodeMounted: view.onComponentMounted })
|
|
53
|
+
: loadingVisible.value ? h(LoadingDelayBoundary, null, () => h(LoadingState, { title: name ? `Loading ${name}` : 'Loading extension' })) : null,
|
|
54
|
+
view.component ? null : h('div', { ref: view.container, class: [mergePartClass('histoire-extension-mount', props.classes?.mount), framed && 'histoire-extension-degraded'], hidden: !!view.failure.value }),
|
|
55
|
+
]);
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|