@histoire/plugin-kit 0.0.0-stage → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +182 -2
- package/dist/builtins.d.ts +13 -0
- package/dist/builtins.d.ts.map +1 -0
- package/dist/builtins.js +7 -0
- package/dist/define.d.ts +19 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +43 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +14 -0
- package/dist/frame.d.ts +6 -0
- package/dist/frame.d.ts.map +1 -0
- package/dist/frame.js +3 -0
- package/dist/host/actions.d.ts +37 -0
- package/dist/host/actions.d.ts.map +1 -0
- package/dist/host/actions.js +47 -0
- package/dist/host/create-host.d.ts +9 -0
- package/dist/host/create-host.d.ts.map +1 -0
- package/dist/host/create-host.js +194 -0
- package/dist/host/diagnostics.d.ts +14 -0
- package/dist/host/diagnostics.d.ts.map +1 -0
- package/dist/host/diagnostics.js +26 -0
- package/dist/host/frames.d.ts +43 -0
- package/dist/host/frames.d.ts.map +1 -0
- package/dist/host/frames.js +63 -0
- package/dist/host/generation.d.ts +24 -0
- package/dist/host/generation.d.ts.map +1 -0
- package/dist/host/generation.js +38 -0
- package/dist/host/install.d.ts +43 -0
- package/dist/host/install.d.ts.map +1 -0
- package/dist/host/install.js +168 -0
- package/dist/host/manifest.d.ts +23 -0
- package/dist/host/manifest.d.ts.map +1 -0
- package/dist/host/manifest.js +37 -0
- package/dist/host/mount.d.ts +15 -0
- package/dist/host/mount.d.ts.map +1 -0
- package/dist/host/mount.js +57 -0
- package/dist/host/ordering.d.ts +20 -0
- package/dist/host/ordering.d.ts.map +1 -0
- package/dist/host/ordering.js +12 -0
- package/dist/host/plugin-api.d.ts +33 -0
- package/dist/host/plugin-api.d.ts.map +1 -0
- package/dist/host/plugin-api.js +113 -0
- package/dist/host/preferences.d.ts +57 -0
- package/dist/host/preferences.d.ts.map +1 -0
- package/dist/host/preferences.js +137 -0
- package/dist/host/registry.d.ts +43 -0
- package/dist/host/registry.d.ts.map +1 -0
- package/dist/host/registry.js +123 -0
- package/dist/host/resources.d.ts +20 -0
- package/dist/host/resources.d.ts.map +1 -0
- package/dist/host/resources.js +45 -0
- package/dist/ids.d.ts +32 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +51 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +25 -0
- package/dist/render/keys.d.ts +7 -0
- package/dist/render/keys.d.ts.map +1 -0
- package/dist/render/keys.js +15 -0
- package/dist/render/mount-manager.d.ts +36 -0
- package/dist/render/mount-manager.d.ts.map +1 -0
- package/dist/render/mount-manager.js +128 -0
- package/dist/render/view-binding.d.ts +19 -0
- package/dist/render/view-binding.d.ts.map +1 -0
- package/dist/render/view-binding.js +7 -0
- package/dist/render/workbench-components.d.ts +39 -0
- package/dist/render/workbench-components.d.ts.map +1 -0
- package/dist/render/workbench-components.js +76 -0
- package/dist/session/context.d.ts +66 -0
- package/dist/session/context.d.ts.map +1 -0
- package/dist/session/context.js +173 -0
- package/dist/session/frames.d.ts +46 -0
- package/dist/session/frames.d.ts.map +1 -0
- package/dist/session/frames.js +68 -0
- package/dist/shortcuts.d.ts +94 -0
- package/dist/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts.js +157 -0
- package/dist/styles.d.ts +3 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +25 -0
- package/dist/svelte4/index.d.ts +27 -0
- package/dist/svelte4/index.d.ts.map +1 -0
- package/dist/svelte4/index.js +16 -0
- package/dist/svelte5/index.d.ts +21 -0
- package/dist/svelte5/index.d.ts.map +1 -0
- package/dist/svelte5/index.js +40 -0
- package/dist/types/actions.d.ts +12 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/actions.js +1 -0
- package/dist/types/base.d.ts +12 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/base.js +1 -0
- package/dist/types/canvas.d.ts +150 -0
- package/dist/types/canvas.d.ts.map +1 -0
- package/dist/types/canvas.js +1 -0
- package/dist/types/channel.d.ts +28 -0
- package/dist/types/channel.d.ts.map +1 -0
- package/dist/types/channel.js +1 -0
- package/dist/types/commands.d.ts +35 -0
- package/dist/types/commands.d.ts.map +1 -0
- package/dist/types/commands.js +1 -0
- package/dist/types/common.d.ts +7 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +1 -0
- package/dist/types/context.d.ts +72 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +1 -0
- package/dist/types/contribution.d.ts +56 -0
- package/dist/types/contribution.d.ts.map +1 -0
- package/dist/types/contribution.js +1 -0
- package/dist/types/frame.d.ts +41 -0
- package/dist/types/frame.d.ts.map +1 -0
- package/dist/types/frame.js +1 -0
- package/dist/types/host.d.ts +123 -0
- package/dist/types/host.d.ts.map +1 -0
- package/dist/types/host.js +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/inspector.d.ts +38 -0
- package/dist/types/inspector.d.ts.map +1 -0
- package/dist/types/inspector.js +1 -0
- package/dist/types/menus.d.ts +71 -0
- package/dist/types/menus.d.ts.map +1 -0
- package/dist/types/menus.js +1 -0
- package/dist/types/plugin.d.ts +133 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +1 -0
- package/dist/types/preferences.d.ts +31 -0
- package/dist/types/preferences.d.ts.map +1 -0
- package/dist/types/preferences.js +1 -0
- package/dist/types/services.d.ts +175 -0
- package/dist/types/services.d.ts.map +1 -0
- package/dist/types/services.js +1 -0
- package/dist/types/shell.d.ts +47 -0
- package/dist/types/shell.d.ts.map +1 -0
- package/dist/types/shell.js +1 -0
- package/dist/types/toolbar.d.ts +59 -0
- package/dist/types/toolbar.d.ts.map +1 -0
- package/dist/types/toolbar.js +1 -0
- package/dist/types/view.d.ts +82 -0
- package/dist/types/view.d.ts.map +1 -0
- package/dist/types/view.js +1 -0
- package/dist/vue/components.d.ts +122 -0
- package/dist/vue/components.d.ts.map +1 -0
- package/dist/vue/components.js +112 -0
- package/dist/vue/index.d.ts +21 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +47 -0
- package/dist/vue/mount.d.ts +9 -0
- package/dist/vue/mount.d.ts.map +1 -0
- package/dist/vue/mount.js +32 -0
- package/dist/vue/panel-action.d.ts +60 -0
- package/dist/vue/panel-action.d.ts.map +1 -0
- package/dist/vue/panel-action.js +28 -0
- package/package.json +92 -3
package/dist/ids.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isHistoirePluginId } from '@histoire/protocol';
|
|
2
|
+
import { PluginDefinitionError } from './errors.js';
|
|
3
|
+
/** Namespace reserved for built-in workbench contributions (`builtin:props`). */
|
|
4
|
+
export const BUILTIN_NAMESPACE = 'builtin';
|
|
5
|
+
/** Local contribution ids: non-empty, no whitespace, no `:` (it separates the namespace). */
|
|
6
|
+
const LOCAL_ID_PATTERN = /^[^\s:]+$/;
|
|
7
|
+
/**
|
|
8
|
+
* Whether `id` is usable as a plugin id (`[a-z][a-z0-9-]*`, at most 64 characters, not
|
|
9
|
+
* `builtin`). Same grammar as the Node descriptor and channel validation (`@histoire/protocol`).
|
|
10
|
+
* @param id Candidate value of any type.
|
|
11
|
+
*/
|
|
12
|
+
export function isValidPluginId(id) {
|
|
13
|
+
return isHistoirePluginId(id);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Throws an attributed error unless `id` is a valid plugin id.
|
|
17
|
+
* @param id Candidate value of any type.
|
|
18
|
+
*/
|
|
19
|
+
export function assertPluginId(id) {
|
|
20
|
+
if (id === BUILTIN_NAMESPACE) {
|
|
21
|
+
throw new PluginDefinitionError(`plugin id "${BUILTIN_NAMESPACE}" is reserved for built-in contributions`);
|
|
22
|
+
}
|
|
23
|
+
if (!isValidPluginId(id)) {
|
|
24
|
+
throw new PluginDefinitionError(`invalid plugin id ${JSON.stringify(id)}; expected at most 64 lowercase letters, digits and dashes, starting with a letter`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Qualifies a local contribution id as `${pluginId}:${localId}`.
|
|
29
|
+
* @param pluginId Owning plugin; `builtin` is rejected.
|
|
30
|
+
* @param localId Id as written by the plugin.
|
|
31
|
+
*/
|
|
32
|
+
export function qualifyId(pluginId, localId) {
|
|
33
|
+
assertPluginId(pluginId);
|
|
34
|
+
if (typeof localId !== 'string' || !LOCAL_ID_PATTERN.test(localId)) {
|
|
35
|
+
throw new PluginDefinitionError(`invalid contribution id ${JSON.stringify(localId)}; expected a non-empty id without whitespace or ":"`, pluginId);
|
|
36
|
+
}
|
|
37
|
+
return `${pluginId}:${localId}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Splits a qualified id. Returns `null` for unqualified or malformed ids.
|
|
41
|
+
* @param id Qualified id such as `acme:panel` or `builtin:props`.
|
|
42
|
+
*/
|
|
43
|
+
export function parseQualifiedId(id) {
|
|
44
|
+
const separator = id.indexOf(':');
|
|
45
|
+
if (separator < 0)
|
|
46
|
+
return null;
|
|
47
|
+
const namespace = id.slice(0, separator);
|
|
48
|
+
const localId = id.slice(separator + 1);
|
|
49
|
+
const validNamespace = namespace === BUILTIN_NAMESPACE || isValidPluginId(namespace);
|
|
50
|
+
return validNamespace && LOCAL_ID_PATTERN.test(localId) ? { namespace, localId } : null;
|
|
51
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { BUILTIN_INSPECTOR_TABS } from './builtins.js';
|
|
2
|
+
export type { BuiltinInspectorTabDescriptor } from './builtins.js';
|
|
3
|
+
export { defineFramePlugin, defineWorkbenchPlugin, PLUGIN_API_VERSION } from './define.js';
|
|
4
|
+
export { PluginDefinitionError } from './errors.js';
|
|
5
|
+
export { createExtensionHost } from './host/create-host.js';
|
|
6
|
+
export { PLUGIN_FRAMES_SERVICE } from './host/frames.js';
|
|
7
|
+
export type { PluginFrameService } from './host/frames.js';
|
|
8
|
+
export { createScope } from './host/generation.js';
|
|
9
|
+
export type { Scope } from './host/generation.js';
|
|
10
|
+
export { lazyWorkbenchPlugins } from './host/manifest.js';
|
|
11
|
+
export type { WorkbenchPluginManifestEntry } from './host/manifest.js';
|
|
12
|
+
export { assertPluginId, BUILTIN_NAMESPACE, isValidPluginId, parseQualifiedId, qualifyId } from './ids.js';
|
|
13
|
+
export type { ParsedQualifiedId } from './ids.js';
|
|
14
|
+
export { createContributionKeys } from './render/keys.js';
|
|
15
|
+
export { WORKBENCH_VIEW_KEY } from './render/view-binding.js';
|
|
16
|
+
export type { WorkbenchViewBinding } from './render/view-binding.js';
|
|
17
|
+
export { cancelPlainLoadingState, renderPlainWorkbenchState, WORKBENCH_COMPONENTS_KEY } from './render/workbench-components.js';
|
|
18
|
+
export type { WorkbenchComponents } from './render/workbench-components.js';
|
|
19
|
+
export { createSessionContext, createSessionNavigation } from './session/context.js';
|
|
20
|
+
export type { SessionContext, SessionContextOptions, SessionContextSource } from './session/context.js';
|
|
21
|
+
export { createSessionFrameService } from './session/frames.js';
|
|
22
|
+
export type { SessionFrameActor, SessionFramePlugins, SessionFrameServiceOptions } from './session/frames.js';
|
|
23
|
+
export { BUILTIN_SHORTCUTS, createPluginShortcutBindings, findBuiltinShortcutConflict, findPluginShortcutConflict, isEditableTarget, matchesShortcut, shortcutBindingsOverlap } from './shortcuts.js';
|
|
24
|
+
export type { BuiltinShortcut, IdentifiedShortcutBinding, PluginShortcutBindings, PluginShortcutConflictOptions, ShortcutBinding, ShortcutKeyEvent } from './shortcuts.js';
|
|
25
|
+
export { installPluginStyles } from './styles.js';
|
|
26
|
+
export type * from './types/index.js';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,YAAY,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,YAAY,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAC1G,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAC/H,YAAY,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACpF,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACvG,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAC7G,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AACrM,YAAY,EAAE,eAAe,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC1K,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,mBAAmB,kBAAkB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Root entry: framework-neutral contracts only. Must not import vue/react/svelte/vite or touch the DOM at import.
|
|
2
|
+
export { BUILTIN_INSPECTOR_TABS } from './builtins.js';
|
|
3
|
+
export { defineFramePlugin, defineWorkbenchPlugin, PLUGIN_API_VERSION } from './define.js';
|
|
4
|
+
export { PluginDefinitionError } from './errors.js';
|
|
5
|
+
export { createExtensionHost } from './host/create-host.js';
|
|
6
|
+
export { PLUGIN_FRAMES_SERVICE } from './host/frames.js';
|
|
7
|
+
export { createScope } from './host/generation.js';
|
|
8
|
+
export { lazyWorkbenchPlugins } from './host/manifest.js';
|
|
9
|
+
export { assertPluginId, BUILTIN_NAMESPACE, isValidPluginId, parseQualifiedId, qualifyId } from './ids.js';
|
|
10
|
+
export { createContributionKeys } from './render/keys.js';
|
|
11
|
+
export { WORKBENCH_VIEW_KEY } from './render/view-binding.js';
|
|
12
|
+
export { cancelPlainLoadingState, renderPlainWorkbenchState, WORKBENCH_COMPONENTS_KEY } from './render/workbench-components.js';
|
|
13
|
+
export { createSessionContext, createSessionNavigation } from './session/context.js';
|
|
14
|
+
export { createSessionFrameService } from './session/frames.js';
|
|
15
|
+
export { BUILTIN_SHORTCUTS, createPluginShortcutBindings, findBuiltinShortcutConflict, findPluginShortcutConflict, isEditableTarget, matchesShortcut, shortcutBindingsOverlap } from './shortcuts.js';
|
|
16
|
+
export { installPluginStyles } from './styles.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { MountView, ViewHost } from '../types/view.js';
|
|
3
|
+
/** Props a React view component receives. */
|
|
4
|
+
export interface ReactViewProps<C> {
|
|
5
|
+
/** Current context snapshot. */
|
|
6
|
+
context: C;
|
|
7
|
+
/** Host services; render popovers with `createPortal(..., host.overlayRoot)`. */
|
|
8
|
+
host: ViewHost;
|
|
9
|
+
}
|
|
10
|
+
/** React component rendered as a workbench view. */
|
|
11
|
+
export type ReactViewComponent<C> = ComponentType<ReactViewProps<C>>;
|
|
12
|
+
/**
|
|
13
|
+
* Wraps a React component as a DOM `mount` view: one React root per container. Context
|
|
14
|
+
* updates re-render the same root; disposal unmounts it, portals and effects included.
|
|
15
|
+
* Renders synchronously so the view is in the DOM once the mount settles.
|
|
16
|
+
* @param component Component rendered with the surface context.
|
|
17
|
+
*/
|
|
18
|
+
export declare function reactView<C>(component: ReactViewComponent<C>): MountView<C>;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAK3D,6CAA6C;AAC7C,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,gCAAgC;IAChC,OAAO,EAAE,CAAC,CAAA;IACV,iFAAiF;IACjF,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AAEpE;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAe3E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { flushSync } from 'react-dom';
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a React component as a DOM `mount` view: one React root per container. Context
|
|
6
|
+
* updates re-render the same root; disposal unmounts it, portals and effects included.
|
|
7
|
+
* Renders synchronously so the view is in the DOM once the mount settles.
|
|
8
|
+
* @param component Component rendered with the surface context.
|
|
9
|
+
*/
|
|
10
|
+
export function reactView(component) {
|
|
11
|
+
return {
|
|
12
|
+
mount(container, context, host) {
|
|
13
|
+
const root = createRoot(container);
|
|
14
|
+
/** Renders one snapshot synchronously. */
|
|
15
|
+
const render = (next) => flushSync(() => root.render(createElement(component, { context: next, host })));
|
|
16
|
+
render(context);
|
|
17
|
+
return {
|
|
18
|
+
update: render,
|
|
19
|
+
dispose() {
|
|
20
|
+
root.unmount();
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render keys for hosts that list contributions (outlets, toolbars). Keys follow contribution
|
|
3
|
+
* objects: a contribution re-registered under the same id
|
|
4
|
+
* is a new object and remounts its view; context changes never do.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createContributionKeys(): (contribution: object) => string;
|
|
7
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/render/keys.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAQzE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render keys for hosts that list contributions (outlets, toolbars). Keys follow contribution
|
|
3
|
+
* objects: a contribution re-registered under the same id
|
|
4
|
+
* is a new object and remounts its view; context changes never do.
|
|
5
|
+
*/
|
|
6
|
+
export function createContributionKeys() {
|
|
7
|
+
const keys = new WeakMap();
|
|
8
|
+
let next = 0;
|
|
9
|
+
return (contribution) => {
|
|
10
|
+
let key = keys.get(contribution);
|
|
11
|
+
if (key === undefined)
|
|
12
|
+
keys.set(contribution, key = `contribution-${next++}`);
|
|
13
|
+
return key;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MountedView } from '../types/host.js';
|
|
2
|
+
import type { ViewHost, ViewMount } from '../types/view.js';
|
|
3
|
+
/** Failure kinds a mount manager reports; `report` comes from the view's own `reportError`. */
|
|
4
|
+
export type MountFailurePhase = 'mount' | 'update' | 'dispose' | 'report';
|
|
5
|
+
/** Inputs of one DOM view lifecycle. */
|
|
6
|
+
export interface MountManagerOptions<C> {
|
|
7
|
+
/** View mount function. */
|
|
8
|
+
mount: ViewMount<C>;
|
|
9
|
+
/** Host-owned container; the view owns its children. */
|
|
10
|
+
container: HTMLElement;
|
|
11
|
+
/** Initial context snapshot. */
|
|
12
|
+
context: C;
|
|
13
|
+
/** Element for the view's popovers and menus. */
|
|
14
|
+
overlayRoot: HTMLElement;
|
|
15
|
+
/** Owner generation (plugin, host); its retirement disposes the view. */
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
/** Receives every failure; never throws back into the manager. */
|
|
18
|
+
report: (error: unknown, phase: MountFailurePhase) => void;
|
|
19
|
+
/** Runs once after the view (if attached) is disposed. */
|
|
20
|
+
onDispose?: () => void;
|
|
21
|
+
/** Host renderer of workbench states; plain markup when absent. */
|
|
22
|
+
renderState?: ViewHost['renderState'];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Runs one DOM `mount` view: mount, serialized updates, error capture and disposal.
|
|
26
|
+
*
|
|
27
|
+
* Each manager owns a generation scope linked to its owner. The view's `host.signal` aborts
|
|
28
|
+
* when the manager is disposed or the owner retires. A mount that completes after that is
|
|
29
|
+
* never attached: its handle is disposed immediately and receives no update. Snapshots pushed
|
|
30
|
+
* while the mount is pending are coalesced and only the latest is applied once it completes.
|
|
31
|
+
* A failed mount or update marks the view failed; a failed update also disposes it, since
|
|
32
|
+
* its state is unknown.
|
|
33
|
+
* @param options View, container, context and reporting.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createMountManager<C>(options: MountManagerOptions<C>): MountedView;
|
|
36
|
+
//# sourceMappingURL=mount-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-manager.d.ts","sourceRoot":"","sources":["../../src/render/mount-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAc,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAIvE,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEzE,wCAAwC;AACxC,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,2BAA2B;IAC3B,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IACnB,wDAAwD;IACxD,SAAS,EAAE,WAAW,CAAA;IACtB,gCAAgC;IAChC,OAAO,EAAE,CAAC,CAAA;IACV,iDAAiD;IACjD,WAAW,EAAE,WAAW,CAAA;IACxB,yEAAyE;IACzE,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,kEAAkE;IAClE,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAC1D,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,mEAAmE;IACnE,WAAW,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAA;CACtC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,WAAW,CAmHlF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createScope } from '../host/generation.js';
|
|
2
|
+
import { cancelPlainLoadingState, renderPlainWorkbenchState } from './workbench-components.js';
|
|
3
|
+
/**
|
|
4
|
+
* Runs one DOM `mount` view: mount, serialized updates, error capture and disposal.
|
|
5
|
+
*
|
|
6
|
+
* Each manager owns a generation scope linked to its owner. The view's `host.signal` aborts
|
|
7
|
+
* when the manager is disposed or the owner retires. A mount that completes after that is
|
|
8
|
+
* never attached: its handle is disposed immediately and receives no update. Snapshots pushed
|
|
9
|
+
* while the mount is pending are coalesced and only the latest is applied once it completes.
|
|
10
|
+
* A failed mount or update marks the view failed; a failed update also disposes it, since
|
|
11
|
+
* its state is unknown.
|
|
12
|
+
* @param options View, container, context and reporting.
|
|
13
|
+
*/
|
|
14
|
+
export function createMountManager(options) {
|
|
15
|
+
const { report } = options;
|
|
16
|
+
const scope = createScope(options.signal);
|
|
17
|
+
let handle;
|
|
18
|
+
let failed = false;
|
|
19
|
+
let queued;
|
|
20
|
+
let disposal;
|
|
21
|
+
const stateContainers = new Set();
|
|
22
|
+
const viewHost = {
|
|
23
|
+
signal: scope.signal,
|
|
24
|
+
overlayRoot: options.overlayRoot,
|
|
25
|
+
reportError: (error) => {
|
|
26
|
+
if (scope.active)
|
|
27
|
+
report(error, 'report');
|
|
28
|
+
},
|
|
29
|
+
renderState(container, state) {
|
|
30
|
+
if (!scope.active)
|
|
31
|
+
return;
|
|
32
|
+
if (options.renderState) {
|
|
33
|
+
options.renderState(container, state);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
stateContainers.add(container);
|
|
37
|
+
renderPlainWorkbenchState(container, state);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Disposes one handle, capturing its failure.
|
|
43
|
+
* @param target Handle returned by the mount.
|
|
44
|
+
*/
|
|
45
|
+
async function disposeHandle(target) {
|
|
46
|
+
try {
|
|
47
|
+
await target.dispose?.();
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
report(error, 'dispose');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Pushes a snapshot to the attached view; a throwing update fails and disposes the view.
|
|
55
|
+
* @param context Snapshot.
|
|
56
|
+
*/
|
|
57
|
+
function apply(context) {
|
|
58
|
+
if (!handle || failed || !scope.active)
|
|
59
|
+
return;
|
|
60
|
+
try {
|
|
61
|
+
handle.update?.(context);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
failed = true;
|
|
65
|
+
report(error, 'update');
|
|
66
|
+
void dispose();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Retires the scope, then disposes the attached view, if any. Idempotent and reentrant. */
|
|
70
|
+
function dispose() {
|
|
71
|
+
if (disposal)
|
|
72
|
+
return disposal;
|
|
73
|
+
// Placeholder first: retiring fires the owner-abort listener, which calls back here.
|
|
74
|
+
disposal = Promise.resolve();
|
|
75
|
+
scope.retire();
|
|
76
|
+
for (const container of stateContainers)
|
|
77
|
+
cancelPlainLoadingState(container);
|
|
78
|
+
stateContainers.clear();
|
|
79
|
+
const attached = handle;
|
|
80
|
+
handle = undefined;
|
|
81
|
+
queued = undefined;
|
|
82
|
+
disposal = (attached ? disposeHandle(attached) : Promise.resolve()).then(() => options.onDispose?.());
|
|
83
|
+
return disposal;
|
|
84
|
+
}
|
|
85
|
+
let result;
|
|
86
|
+
try {
|
|
87
|
+
result = options.mount(options.container, options.context, viewHost);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
result = Promise.reject(error);
|
|
91
|
+
}
|
|
92
|
+
const ready = Promise.resolve(result).then((value) => {
|
|
93
|
+
const attached = value ?? {};
|
|
94
|
+
if (!scope.active) {
|
|
95
|
+
// Late completion of a retired generation: release it, never attach it.
|
|
96
|
+
void disposeHandle(attached);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
handle = attached;
|
|
100
|
+
if (queued) {
|
|
101
|
+
const { context } = queued;
|
|
102
|
+
queued = undefined;
|
|
103
|
+
apply(context);
|
|
104
|
+
}
|
|
105
|
+
}, (error) => {
|
|
106
|
+
// A failure after retirement belongs to a generation nobody observes anymore.
|
|
107
|
+
if (!scope.active)
|
|
108
|
+
return;
|
|
109
|
+
failed = true;
|
|
110
|
+
report(error, 'mount');
|
|
111
|
+
throw error;
|
|
112
|
+
});
|
|
113
|
+
// Callers may never await `ready`; a mount failure is already reported.
|
|
114
|
+
ready.catch(() => { });
|
|
115
|
+
scope.signal.addEventListener('abort', () => void dispose(), { once: true });
|
|
116
|
+
return {
|
|
117
|
+
ready,
|
|
118
|
+
update(context) {
|
|
119
|
+
if (failed || !scope.active)
|
|
120
|
+
return;
|
|
121
|
+
if (handle)
|
|
122
|
+
apply(context);
|
|
123
|
+
else
|
|
124
|
+
queued = { context: context };
|
|
125
|
+
},
|
|
126
|
+
dispose,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ViewHost } from '../types/view.js';
|
|
2
|
+
/**
|
|
3
|
+
* Provide/inject key of the {@link WorkbenchViewBinding} around each Vue view.
|
|
4
|
+
*
|
|
5
|
+
* Registered with `Symbol.for` so separate copies of plugin-kit (the workbench's and a
|
|
6
|
+
* plugin's own install) agree on it; the key itself carries no framework dependency.
|
|
7
|
+
*/
|
|
8
|
+
export declare const WORKBENCH_VIEW_KEY: symbol;
|
|
9
|
+
/**
|
|
10
|
+
* What a Vue view host provides under {@link WORKBENCH_VIEW_KEY}. Providers back `context`
|
|
11
|
+
* with reactive state, so reads made during render track context changes.
|
|
12
|
+
*/
|
|
13
|
+
export interface WorkbenchViewBinding<C = unknown> {
|
|
14
|
+
/** Current context snapshot of the view's surface. */
|
|
15
|
+
readonly context: C;
|
|
16
|
+
/** Host services of the view. */
|
|
17
|
+
readonly host: ViewHost;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=view-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-binding.d.ts","sourceRoot":"","sources":["../../src/render/view-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAyD,CAAA;AAE1F;;;GAGG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC/C,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CACxB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provide/inject key of the {@link WorkbenchViewBinding} around each Vue view.
|
|
3
|
+
*
|
|
4
|
+
* Registered with `Symbol.for` so separate copies of plugin-kit (the workbench's and a
|
|
5
|
+
* plugin's own install) agree on it; the key itself carries no framework dependency.
|
|
6
|
+
*/
|
|
7
|
+
export const WORKBENCH_VIEW_KEY = Symbol.for('histoire.plugin-kit.workbench-view');
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { WorkbenchComponent, WorkbenchState } from '../types/view.js';
|
|
2
|
+
/** Cancels a plain loading state without changing content. */
|
|
3
|
+
export declare function cancelPlainLoadingState(container: HTMLElement): void;
|
|
4
|
+
/**
|
|
5
|
+
* Provide/inject key under which a Vue host provides its {@link WorkbenchComponents}.
|
|
6
|
+
*
|
|
7
|
+
* Registered with `Symbol.for` so the workbench, native hosts and a plugin's own copy of
|
|
8
|
+
* plugin-kit agree on it without importing each other.
|
|
9
|
+
*/
|
|
10
|
+
export declare const WORKBENCH_COMPONENTS_KEY: symbol;
|
|
11
|
+
/**
|
|
12
|
+
* Host implementations of the shared workbench state and pane layout components, keyed by the
|
|
13
|
+
* names `@histoire/plugin-kit/vue` exports. Missing entries render plugin-kit's plain fallback.
|
|
14
|
+
*/
|
|
15
|
+
export interface WorkbenchComponents {
|
|
16
|
+
/** Primary panel action: props icon, label, disabled; emits click. */
|
|
17
|
+
WorkbenchPanelAction?: WorkbenchComponent;
|
|
18
|
+
/** Empty area: props `icon`, `title`; slots `default` (detail), `actions`. */
|
|
19
|
+
WorkbenchEmptyState?: WorkbenchComponent;
|
|
20
|
+
/** Loading placeholder: prop `title`; slot `default` (detail). */
|
|
21
|
+
WorkbenchLoadingState?: WorkbenchComponent;
|
|
22
|
+
/** Failure: props `title`, optional `icon`; slots `default` (detail), `actions`. */
|
|
23
|
+
WorkbenchErrorState?: WorkbenchComponent;
|
|
24
|
+
/** Fixed-height pane header: prop `title`; slot `default` (trailing actions). */
|
|
25
|
+
WorkbenchPaneHeader?: WorkbenchComponent;
|
|
26
|
+
/** Filter or section switch row: slot `default`. */
|
|
27
|
+
WorkbenchPaneToolbar?: WorkbenchComponent;
|
|
28
|
+
/** Scrolling list body inset by the pane gutter: slot `default`. */
|
|
29
|
+
WorkbenchPaneList?: WorkbenchComponent;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Renders `state` into `container` as plain, unstyled markup (title and detail inside a
|
|
33
|
+
* `status` or `alert` region), replacing its children; `null` empties it. Used for DOM views
|
|
34
|
+
* whose host has no styled renderer.
|
|
35
|
+
* @param container Element owned by the view.
|
|
36
|
+
* @param state State to show, or `null` to clear.
|
|
37
|
+
*/
|
|
38
|
+
export declare function renderPlainWorkbenchState(container: HTMLElement, state: WorkbenchState | null): void;
|
|
39
|
+
//# sourceMappingURL=workbench-components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workbench-components.d.ts","sourceRoot":"","sources":["../../src/render/workbench-components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAM1E,8DAA8D;AAC9D,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAGpE;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAA+D,CAAA;AAEtG;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,kBAAkB,CAAA;IACzC,8EAA8E;IAC9E,mBAAmB,CAAC,EAAE,kBAAkB,CAAA;IACxC,kEAAkE;IAClE,qBAAqB,CAAC,EAAE,kBAAkB,CAAA;IAC1C,oFAAoF;IACpF,mBAAmB,CAAC,EAAE,kBAAkB,CAAA;IACxC,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,kBAAkB,CAAA;IACxC,oDAAoD;IACpD,oBAAoB,CAAC,EAAE,kBAAkB,CAAA;IACzC,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAiCpG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createLoadingDelay } from '@histoire/shared/loading-delay';
|
|
2
|
+
/** Pending plain loading presentations, keyed by their owned container. */
|
|
3
|
+
const pendingStates = new WeakMap();
|
|
4
|
+
/** Cancels a plain loading state without changing content. */
|
|
5
|
+
export function cancelPlainLoadingState(container) {
|
|
6
|
+
pendingStates.get(container)?.cancel();
|
|
7
|
+
pendingStates.delete(container);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provide/inject key under which a Vue host provides its {@link WorkbenchComponents}.
|
|
11
|
+
*
|
|
12
|
+
* Registered with `Symbol.for` so the workbench, native hosts and a plugin's own copy of
|
|
13
|
+
* plugin-kit agree on it without importing each other.
|
|
14
|
+
*/
|
|
15
|
+
export const WORKBENCH_COMPONENTS_KEY = Symbol.for('histoire.plugin-kit.workbench-components');
|
|
16
|
+
/**
|
|
17
|
+
* Renders `state` into `container` as plain, unstyled markup (title and detail inside a
|
|
18
|
+
* `status` or `alert` region), replacing its children; `null` empties it. Used for DOM views
|
|
19
|
+
* whose host has no styled renderer.
|
|
20
|
+
* @param container Element owned by the view.
|
|
21
|
+
* @param state State to show, or `null` to clear.
|
|
22
|
+
*/
|
|
23
|
+
export function renderPlainWorkbenchState(container, state) {
|
|
24
|
+
const pending = pendingStates.get(container);
|
|
25
|
+
if (state?.kind === 'loading' && pending) {
|
|
26
|
+
pending.update(state);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
cancelPlainLoadingState(container);
|
|
30
|
+
if (!state) {
|
|
31
|
+
container.replaceChildren();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const document = container.ownerDocument;
|
|
35
|
+
if (state.kind === 'loading') {
|
|
36
|
+
const marker = document.createComment('loading');
|
|
37
|
+
container.replaceChildren(marker);
|
|
38
|
+
let latest = state;
|
|
39
|
+
let region;
|
|
40
|
+
const delay = createLoadingDelay(() => {
|
|
41
|
+
// A plugin may have replaced our marker with its own content.
|
|
42
|
+
if (marker.parentNode === container && container.childNodes.length === 1)
|
|
43
|
+
region = renderPlainState(container, latest);
|
|
44
|
+
else
|
|
45
|
+
pendingStates.delete(container);
|
|
46
|
+
});
|
|
47
|
+
pendingStates.set(container, {
|
|
48
|
+
cancel: delay.dispose,
|
|
49
|
+
update(value) {
|
|
50
|
+
latest = value;
|
|
51
|
+
if (region?.parentNode === container && container.childNodes.length === 1)
|
|
52
|
+
region = renderPlainState(container, latest);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
delay.setPending(true);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
renderPlainState(container, state);
|
|
59
|
+
}
|
|
60
|
+
/** Renders one settled state without scheduling. */
|
|
61
|
+
function renderPlainState(container, state) {
|
|
62
|
+
const document = container.ownerDocument;
|
|
63
|
+
const region = document.createElement('div');
|
|
64
|
+
region.setAttribute('role', state.kind === 'error' ? 'alert' : 'status');
|
|
65
|
+
region.setAttribute('data-histoire-state', state.kind);
|
|
66
|
+
const title = document.createElement('strong');
|
|
67
|
+
title.textContent = state.title;
|
|
68
|
+
region.append(title);
|
|
69
|
+
if (state.detail) {
|
|
70
|
+
const detail = document.createElement('p');
|
|
71
|
+
detail.textContent = state.detail;
|
|
72
|
+
region.append(detail);
|
|
73
|
+
}
|
|
74
|
+
container.replaceChildren(region);
|
|
75
|
+
return region;
|
|
76
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { HistoireReadonly, HistoireSelectionInput, HistoireSnapshot } from '@histoire/protocol';
|
|
2
|
+
import type { PluginFrameService } from '../host/frames.js';
|
|
3
|
+
import type { Disposer } from '../types/common.js';
|
|
4
|
+
import type { WorkbenchContext, WorkbenchSource } from '../types/context.js';
|
|
5
|
+
import type { CatalogService, DevEventService, NavigationService, TestsService } from '../types/services.js';
|
|
6
|
+
/**
|
|
7
|
+
* Public session methods a session context reads. `HistoireSession` from `@histoire/sdk`
|
|
8
|
+
* satisfies it structurally; plugin-kit never imports the SDK.
|
|
9
|
+
*/
|
|
10
|
+
export interface SessionContextSource {
|
|
11
|
+
/**
|
|
12
|
+
* Latest coherent snapshot; `source`, `selection` and, when present, `catalog` (its identity
|
|
13
|
+
* changes on each publication) are read.
|
|
14
|
+
*/
|
|
15
|
+
getSnapshot: () => HistoireReadonly<Pick<HistoireSnapshot, 'source' | 'selection'> & Partial<Pick<HistoireSnapshot, 'catalog'>>>;
|
|
16
|
+
/** Observes snapshot publications. */
|
|
17
|
+
subscribe: (listener: () => void) => Disposer;
|
|
18
|
+
/** Metadata-only catalog. */
|
|
19
|
+
catalog: Omit<CatalogService, 'subscribe'>;
|
|
20
|
+
/** Canonical selection; the default navigation selects stories through it. */
|
|
21
|
+
selection?: {
|
|
22
|
+
select: (input: HistoireSelectionInput) => Promise<unknown>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Inputs of {@link createSessionContext}. */
|
|
26
|
+
export interface SessionContextOptions {
|
|
27
|
+
/** Session the context reads. */
|
|
28
|
+
session: SessionContextSource;
|
|
29
|
+
/** Story source mode; `remote` (no dev-only contributions) by default. */
|
|
30
|
+
mode?: WorkbenchSource['mode'];
|
|
31
|
+
/** Navigation; defaults to {@link createSessionNavigation}. */
|
|
32
|
+
navigation?: NavigationService;
|
|
33
|
+
/** Dev event service; absent without a compatible dev transport. */
|
|
34
|
+
devEvents?: DevEventService;
|
|
35
|
+
/** Project test runs; adds the `tests` capability. */
|
|
36
|
+
tests?: TestsService;
|
|
37
|
+
/** Frame messaging; adds the `frames` capability (see `createSessionFrameService`). */
|
|
38
|
+
frames?: PluginFrameService;
|
|
39
|
+
}
|
|
40
|
+
/** Root context plus the generation scopes actions capture. */
|
|
41
|
+
export interface SessionContext {
|
|
42
|
+
/** Root-scoped context, e.g. `services.context` of `createExtensionHost`. */
|
|
43
|
+
readonly context: WorkbenchContext;
|
|
44
|
+
/** Aborted at the next selection or source change. */
|
|
45
|
+
selectionSignal: () => AbortSignal;
|
|
46
|
+
/** Aborted at the next source change (new source id, URL or epoch). */
|
|
47
|
+
sourceSignal: () => AbortSignal;
|
|
48
|
+
/** Releases the session subscription and retires every scope. */
|
|
49
|
+
close: () => void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Navigation for hosts without workbench routes: stories are selected through the session;
|
|
53
|
+
* tabs, panes, settings and canvas views do not exist and are ignored with a warning, so a
|
|
54
|
+
* plugin never changes a host-owned URL.
|
|
55
|
+
* @param session Session selecting stories.
|
|
56
|
+
* @param warn Receives ignored destinations; `console.warn` by default.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createSessionNavigation(session: Pick<SessionContextSource, 'selection'>, warn?: (message: string) => void): NavigationService;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a root-scoped context from public session methods (standalone workbench, native Vue,
|
|
61
|
+
* React and plain DOM hosts share it). Selection and source changes rotate generation scopes;
|
|
62
|
+
* actions capture the current scope when they start, so a later change aborts them.
|
|
63
|
+
* @param options Session, mode and services.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createSessionContext(options: SessionContextOptions): SessionContext;
|
|
66
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/session/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAuB,gBAAgB,EAAsB,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAI5G;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,EAAE,MAAM,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IAChI,sCAAsC;IACtC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,QAAQ,CAAA;IAC7C,6BAA6B;IAC7B,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;IAC1C,8EAA8E;IAC9E,SAAS,CAAC,EAAE;QAAE,MAAM,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,CAAA;CAC5E;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,iCAAiC;IACjC,OAAO,EAAE,oBAAoB,CAAA;IAC7B,0EAA0E;IAC1E,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IAC9B,+DAA+D;IAC/D,UAAU,CAAC,EAAE,iBAAiB,CAAA;IAC9B,oEAAoE;IACpE,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,sDAAsD;IACtD,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB,uFAAuF;IACvF,MAAM,CAAC,EAAE,kBAAkB,CAAA;CAC5B;AAED,+DAA+D;AAC/D,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,sDAAsD;IACtD,eAAe,EAAE,MAAM,WAAW,CAAA;IAClC,uEAAuE;IACvE,YAAY,EAAE,MAAM,WAAW,CAAA;IAC/B,iEAAiE;IACjE,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,EAAE,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAuC,GAAG,iBAAiB,CAY/K;AA+CD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CA+FnF"}
|