@agimon-ai/doompi-web-contracts 0.0.1-alpha.2 → 0.0.1-alpha.26
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/README.md +36 -17
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.mts +7 -3
- package/dist/index.mjs +1 -1
- package/dist/services/define.d.cts +3 -4
- package/dist/services/define.d.cts.map +1 -1
- package/dist/services/define.d.mts +3 -4
- package/dist/services/define.d.mts.map +1 -1
- package/dist/services/globalStore.cjs +2 -0
- package/dist/services/globalStore.cjs.map +1 -0
- package/dist/services/globalStore.d.cts +6 -0
- package/dist/services/globalStore.d.cts.map +1 -0
- package/dist/services/globalStore.d.mts +6 -0
- package/dist/services/globalStore.d.mts.map +1 -0
- package/dist/services/globalStore.mjs +2 -0
- package/dist/services/globalStore.mjs.map +1 -0
- package/dist/services/sessionRegistry.cjs +2 -0
- package/dist/services/sessionRegistry.cjs.map +1 -0
- package/dist/services/sessionRegistry.d.cts +42 -0
- package/dist/services/sessionRegistry.d.cts.map +1 -0
- package/dist/services/sessionRegistry.d.mts +42 -0
- package/dist/services/sessionRegistry.d.mts.map +1 -0
- package/dist/services/sessionRegistry.mjs +2 -0
- package/dist/services/sessionRegistry.mjs.map +1 -0
- package/dist/services/sessionStore.d.cts +1 -2
- package/dist/services/sessionStore.d.cts.map +1 -1
- package/dist/services/sessionStore.d.mts +1 -2
- package/dist/services/sessionStore.d.mts.map +1 -1
- package/dist/services/testing/channels.cjs +1 -1
- package/dist/services/testing/channels.cjs.map +1 -1
- package/dist/services/testing/channels.d.cts +5 -6
- package/dist/services/testing/channels.d.cts.map +1 -1
- package/dist/services/testing/channels.d.mts +5 -6
- package/dist/services/testing/channels.d.mts.map +1 -1
- package/dist/services/testing/channels.mjs +1 -1
- package/dist/services/testing/channels.mjs.map +1 -1
- package/dist/services/testing/render.d.cts +2 -3
- package/dist/services/testing/render.d.cts.map +1 -1
- package/dist/services/testing/render.d.mts +2 -3
- package/dist/services/testing/render.d.mts.map +1 -1
- package/dist/services/testing/slotProps.cjs +1 -1
- package/dist/services/testing/slotProps.cjs.map +1 -1
- package/dist/services/testing/slotProps.d.cts +22 -12
- package/dist/services/testing/slotProps.d.cts.map +1 -1
- package/dist/services/testing/slotProps.d.mts +22 -12
- package/dist/services/testing/slotProps.d.mts.map +1 -1
- package/dist/services/testing/slotProps.mjs +1 -1
- package/dist/services/testing/slotProps.mjs.map +1 -1
- package/dist/services/toolResult.d.cts +2 -3
- package/dist/services/toolResult.d.cts.map +1 -1
- package/dist/services/toolResult.d.mts +2 -3
- package/dist/services/toolResult.d.mts.map +1 -1
- package/dist/types/modelContext.d.cts +43 -0
- package/dist/types/modelContext.d.cts.map +1 -0
- package/dist/types/modelContext.d.mts +43 -0
- package/dist/types/modelContext.d.mts.map +1 -0
- package/dist/types/sessionRegistry.d.cts +59 -0
- package/dist/types/sessionRegistry.d.cts.map +1 -0
- package/dist/types/sessionRegistry.d.mts +59 -0
- package/dist/types/sessionRegistry.d.mts.map +1 -0
- package/dist/types/webHub.d.cts +46 -6
- package/dist/types/webHub.d.cts.map +1 -1
- package/dist/types/webHub.d.mts +46 -6
- package/dist/types/webHub.d.mts.map +1 -1
- package/dist/types/webPlugin.d.cts +473 -41
- package/dist/types/webPlugin.d.cts.map +1 -1
- package/dist/types/webPlugin.d.mts +473 -41
- package/dist/types/webPlugin.d.mts.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,27 +1,46 @@
|
|
|
1
1
|
# @agimon-ai/doompi-web-contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Typed plugin, slot, session-channel, and hub-channel contracts for the DoomPi web cockpit.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This is a library, not a Pi extension. It starts no process and does not belong in `.doom/modes.yaml`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> **Alpha:** web plugin contracts may change between releases.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
the host package's build. It can contribute tabs with panels and badges, session data channels,
|
|
11
|
-
overlays, Leader Space key bindings, command palette commands, rail, selection bar, and
|
|
12
|
-
activity dock sections, and tool renderers: one `message` component per claimed tool (by name,
|
|
13
|
-
or by a `matches` predicate for tools named at runtime) that owns the tool call's whole timeline
|
|
14
|
-
item, composed from the shared components package's `MessageItem` so it looks like every other
|
|
15
|
-
item; `toolResultText` and `toolResultTextLines` read a result's text blocks the same way.
|
|
16
|
-
- An optional hub entry exporting `webHubChannels: readonly WebHubChannel[]`, loaded by the cockpit
|
|
17
|
-
server at startup. A channel watches some data source and answers per-session payloads that reach
|
|
18
|
-
the page as `ChannelFrame` messages whose frame type is the channel name.
|
|
9
|
+
## Install
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npm install @agimon-ai/doompi-web-contracts
|
|
13
|
+
```
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
Web plugin clients also require the package's React, React DOM, and TanStack Store peers when they use
|
|
16
|
+
those surfaces.
|
|
17
|
+
|
|
18
|
+
## Plugin shape
|
|
19
|
+
|
|
20
|
+
A web plugin can have two entries:
|
|
21
|
+
|
|
22
|
+
- A client entry exports `webPlugin: WebPluginDefinition`. It can contribute tabs, slots, Leader
|
|
23
|
+
bindings, commands, session channels, activity surfaces, and tool renderers.
|
|
24
|
+
- An optional hub entry exports `webHubChannels: readonly WebHubChannel[]`. Each channel watches a
|
|
25
|
+
data source and emits per-session `ChannelFrame` payloads to the page.
|
|
26
|
+
|
|
27
|
+
Declare both entries in the plugin package's `doompiWeb` manifest block. The DoomPi cockpit bundler
|
|
28
|
+
reads those declarations and generates the registration modules.
|
|
29
|
+
|
|
30
|
+
Use the definition helpers for checked literals:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import {
|
|
34
|
+
defineSessionChannel,
|
|
35
|
+
defineSessionStore,
|
|
36
|
+
defineSlot,
|
|
37
|
+
defineWebPlugin,
|
|
38
|
+
toolResultText,
|
|
39
|
+
} from '@agimon-ai/doompi-web-contracts';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Import contracts type-only from server code. The `/testing` subpath provides channel, render, slot,
|
|
43
|
+
and tool-message fixtures for plugin tests.
|
|
25
44
|
|
|
26
45
|
## License
|
|
27
46
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./services/define.cjs"),t=require("./services/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./services/define.cjs"),t=require("./services/globalStore.cjs"),n=require("./services/sessionStore.cjs"),r=require("./services/sessionRegistry.cjs"),i=require("./services/toolResult.cjs");exports.HUB_ADVERTISEMENT_VERSION=r.HUB_ADVERTISEMENT_VERSION,exports.REGISTRY_DIR_ENV=r.REGISTRY_DIR_ENV,exports.SESSION_LINEAGE_RECORD_VERSION=r.SESSION_LINEAGE_RECORD_VERSION,exports.defineGlobalStore=t.defineGlobalStore,exports.defineSessionChannel=e.defineSessionChannel,exports.defineSessionStore=n.defineSessionStore,exports.defineSlot=e.defineSlot,exports.defineWebPlugin=e.defineWebPlugin,exports.hubAdvertisementPath=r.hubAdvertisementPath,exports.parseHubAdvertisement=r.parseHubAdvertisement,exports.parseSessionLineage=r.parseSessionLineage,exports.resolveRegistryDir=r.resolveRegistryDir,exports.sessionLineagePath=r.sessionLineagePath,exports.toolResultText=i.toolResultText,exports.toolResultTextLines=i.toolResultTextLines;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModelContext, ModelContextAbortSignal, ModelContextBinding, ModelContextExecutionOptions, ModelContextRegistrationOptions, ModelContextTool, ModelContextToolChangeEvent, ModelContextToolChangeListener, ModelContextToolDescriptor } from "./types/modelContext.cjs";
|
|
2
|
+
import { ActivityGroupContribution, CaptureStatusEvent, ComposerCapture, ComposerSubmission, ContextAction, ContextActionContribution, ContextActionRunContext, DockFaceContribution, FileLinkSource, GlobalStore, LeaderBindingContribution, LeaderKeyContribution, MinorModeContribution, PaletteCommandContext, PaletteCommandContribution, RepositorySettingsPanelContribution, RepositorySettingsPanelProps, RepositorySettingsRepository, SelectionAxisContribution, SessionChannelContribution, SessionFrameSender, SessionRecords, SessionStore, SessionStoreChannel, SettingsFieldContribution, SettingsFieldOption, SettingsPanelContribution, SettingsPanelProps, SettingsSectionContribution, SlotDataFill, SlotDeclaration, SlotFillContribution, SurfaceContribution, TabContribution, ThreadViewOptions, ToolMessageRenderProps, ToolPromptContribution, ToolPromptDialog, ToolPromptRenderProps, ToolRendererContribution, ToolResultView, TransientTab, UserMessageActionContribution, UserMessageActionRunContext, WebPluginContextInventoryItem, WebPluginContextItem, WebPluginDefinition, WebPluginRuntime, WebPluginSlotProps } from "./types/webPlugin.cjs";
|
|
2
3
|
import { defineSessionChannel, defineSlot, defineWebPlugin } from "./services/define.cjs";
|
|
4
|
+
import { defineGlobalStore } from "./services/globalStore.cjs";
|
|
3
5
|
import { defineSessionStore } from "./services/sessionStore.cjs";
|
|
6
|
+
import { HubAdvertisement, RegistryDirInput, SessionLineageRecord } from "./types/sessionRegistry.cjs";
|
|
7
|
+
import { HUB_ADVERTISEMENT_VERSION, REGISTRY_DIR_ENV, SESSION_LINEAGE_RECORD_VERSION, hubAdvertisementPath, parseHubAdvertisement, parseSessionLineage, resolveRegistryDir, sessionLineagePath } from "./services/sessionRegistry.cjs";
|
|
4
8
|
import { toolResultText, toolResultTextLines } from "./services/toolResult.cjs";
|
|
5
|
-
import { ChannelFrame, HubChannelHost, HubChannelSource, HubSessionScope, WebHubChannel } from "./types/webHub.cjs";
|
|
6
|
-
export { type ActivityGroupContribution, type ChannelFrame, type HubChannelHost, type HubChannelSource, type HubSessionScope, type LeaderBindingContribution, type LeaderKeyContribution, type MinorModeContribution, type PaletteCommandContext, type PaletteCommandContribution, type SelectionAxisContribution, type SessionChannelContribution, type SessionFrameSender, type SessionRecords, type SessionStore, type SessionStoreChannel, type SlotDataFill, type SlotDeclaration, type SlotFillContribution, type SurfaceContribution, type TabContribution, type ToolMessageRenderProps, type ToolRendererContribution, type ToolResultView, type TransientTab, type WebHubChannel, type WebPluginDefinition, type WebPluginRuntime, type WebPluginSlotProps, defineSessionChannel, defineSessionStore, defineSlot, defineWebPlugin, toolResultText, toolResultTextLines };
|
|
9
|
+
import { ChannelFrame, ComputerUseHostBinding, ComputerUseHostOperation, ComputerUseHostRequest, HubChannelConnection, HubChannelHost, HubChannelLifecycle, HubChannelSource, HubSessionApiRequest, HubSessionScope, WebHubChannel } from "./types/webHub.cjs";
|
|
10
|
+
export { type ActivityGroupContribution, type CaptureStatusEvent, type ChannelFrame, type ComposerCapture, type ComposerSubmission, type ComputerUseHostBinding, type ComputerUseHostOperation, type ComputerUseHostRequest, type ContextAction, type ContextActionContribution, type ContextActionRunContext, type DockFaceContribution, type FileLinkSource, type GlobalStore, HUB_ADVERTISEMENT_VERSION, type HubAdvertisement, type HubChannelConnection, type HubChannelHost, type HubChannelLifecycle, type HubChannelSource, type HubSessionApiRequest, type HubSessionScope, type LeaderBindingContribution, type LeaderKeyContribution, type MinorModeContribution, type ModelContext, type ModelContextAbortSignal, type ModelContextBinding, type ModelContextExecutionOptions, type ModelContextRegistrationOptions, type ModelContextTool, type ModelContextToolChangeEvent, type ModelContextToolChangeListener, type ModelContextToolDescriptor, type PaletteCommandContext, type PaletteCommandContribution, REGISTRY_DIR_ENV, type RegistryDirInput, type RepositorySettingsPanelContribution, type RepositorySettingsPanelProps, type RepositorySettingsRepository, SESSION_LINEAGE_RECORD_VERSION, type SelectionAxisContribution, type SessionChannelContribution, type SessionFrameSender, type SessionLineageRecord, type SessionRecords, type SessionStore, type SessionStoreChannel, type SettingsFieldContribution, type SettingsFieldOption, type SettingsPanelContribution, type SettingsPanelProps, type SettingsSectionContribution, type SlotDataFill, type SlotDeclaration, type SlotFillContribution, type SurfaceContribution, type TabContribution, type ThreadViewOptions, type ToolMessageRenderProps, type ToolPromptContribution, type ToolPromptDialog, type ToolPromptRenderProps, type ToolRendererContribution, type ToolResultView, type TransientTab, type UserMessageActionContribution, type UserMessageActionRunContext, type WebHubChannel, type WebPluginContextInventoryItem, type WebPluginContextItem, type WebPluginDefinition, type WebPluginRuntime, type WebPluginSlotProps, defineGlobalStore, defineSessionChannel, defineSessionStore, defineSlot, defineWebPlugin, hubAdvertisementPath, parseHubAdvertisement, parseSessionLineage, resolveRegistryDir, sessionLineagePath, toolResultText, toolResultTextLines };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModelContext, ModelContextAbortSignal, ModelContextBinding, ModelContextExecutionOptions, ModelContextRegistrationOptions, ModelContextTool, ModelContextToolChangeEvent, ModelContextToolChangeListener, ModelContextToolDescriptor } from "./types/modelContext.mjs";
|
|
2
|
+
import { ActivityGroupContribution, CaptureStatusEvent, ComposerCapture, ComposerSubmission, ContextAction, ContextActionContribution, ContextActionRunContext, DockFaceContribution, FileLinkSource, GlobalStore, LeaderBindingContribution, LeaderKeyContribution, MinorModeContribution, PaletteCommandContext, PaletteCommandContribution, RepositorySettingsPanelContribution, RepositorySettingsPanelProps, RepositorySettingsRepository, SelectionAxisContribution, SessionChannelContribution, SessionFrameSender, SessionRecords, SessionStore, SessionStoreChannel, SettingsFieldContribution, SettingsFieldOption, SettingsPanelContribution, SettingsPanelProps, SettingsSectionContribution, SlotDataFill, SlotDeclaration, SlotFillContribution, SurfaceContribution, TabContribution, ThreadViewOptions, ToolMessageRenderProps, ToolPromptContribution, ToolPromptDialog, ToolPromptRenderProps, ToolRendererContribution, ToolResultView, TransientTab, UserMessageActionContribution, UserMessageActionRunContext, WebPluginContextInventoryItem, WebPluginContextItem, WebPluginDefinition, WebPluginRuntime, WebPluginSlotProps } from "./types/webPlugin.mjs";
|
|
2
3
|
import { defineSessionChannel, defineSlot, defineWebPlugin } from "./services/define.mjs";
|
|
4
|
+
import { defineGlobalStore } from "./services/globalStore.mjs";
|
|
3
5
|
import { defineSessionStore } from "./services/sessionStore.mjs";
|
|
6
|
+
import { HubAdvertisement, RegistryDirInput, SessionLineageRecord } from "./types/sessionRegistry.mjs";
|
|
7
|
+
import { HUB_ADVERTISEMENT_VERSION, REGISTRY_DIR_ENV, SESSION_LINEAGE_RECORD_VERSION, hubAdvertisementPath, parseHubAdvertisement, parseSessionLineage, resolveRegistryDir, sessionLineagePath } from "./services/sessionRegistry.mjs";
|
|
4
8
|
import { toolResultText, toolResultTextLines } from "./services/toolResult.mjs";
|
|
5
|
-
import { ChannelFrame, HubChannelHost, HubChannelSource, HubSessionScope, WebHubChannel } from "./types/webHub.mjs";
|
|
6
|
-
export { type ActivityGroupContribution, type ChannelFrame, type HubChannelHost, type HubChannelSource, type HubSessionScope, type LeaderBindingContribution, type LeaderKeyContribution, type MinorModeContribution, type PaletteCommandContext, type PaletteCommandContribution, type SelectionAxisContribution, type SessionChannelContribution, type SessionFrameSender, type SessionRecords, type SessionStore, type SessionStoreChannel, type SlotDataFill, type SlotDeclaration, type SlotFillContribution, type SurfaceContribution, type TabContribution, type ToolMessageRenderProps, type ToolRendererContribution, type ToolResultView, type TransientTab, type WebHubChannel, type WebPluginDefinition, type WebPluginRuntime, type WebPluginSlotProps, defineSessionChannel, defineSessionStore, defineSlot, defineWebPlugin, toolResultText, toolResultTextLines };
|
|
9
|
+
import { ChannelFrame, ComputerUseHostBinding, ComputerUseHostOperation, ComputerUseHostRequest, HubChannelConnection, HubChannelHost, HubChannelLifecycle, HubChannelSource, HubSessionApiRequest, HubSessionScope, WebHubChannel } from "./types/webHub.mjs";
|
|
10
|
+
export { type ActivityGroupContribution, type CaptureStatusEvent, type ChannelFrame, type ComposerCapture, type ComposerSubmission, type ComputerUseHostBinding, type ComputerUseHostOperation, type ComputerUseHostRequest, type ContextAction, type ContextActionContribution, type ContextActionRunContext, type DockFaceContribution, type FileLinkSource, type GlobalStore, HUB_ADVERTISEMENT_VERSION, type HubAdvertisement, type HubChannelConnection, type HubChannelHost, type HubChannelLifecycle, type HubChannelSource, type HubSessionApiRequest, type HubSessionScope, type LeaderBindingContribution, type LeaderKeyContribution, type MinorModeContribution, type ModelContext, type ModelContextAbortSignal, type ModelContextBinding, type ModelContextExecutionOptions, type ModelContextRegistrationOptions, type ModelContextTool, type ModelContextToolChangeEvent, type ModelContextToolChangeListener, type ModelContextToolDescriptor, type PaletteCommandContext, type PaletteCommandContribution, REGISTRY_DIR_ENV, type RegistryDirInput, type RepositorySettingsPanelContribution, type RepositorySettingsPanelProps, type RepositorySettingsRepository, SESSION_LINEAGE_RECORD_VERSION, type SelectionAxisContribution, type SessionChannelContribution, type SessionFrameSender, type SessionLineageRecord, type SessionRecords, type SessionStore, type SessionStoreChannel, type SettingsFieldContribution, type SettingsFieldOption, type SettingsPanelContribution, type SettingsPanelProps, type SettingsSectionContribution, type SlotDataFill, type SlotDeclaration, type SlotFillContribution, type SurfaceContribution, type TabContribution, type ThreadViewOptions, type ToolMessageRenderProps, type ToolPromptContribution, type ToolPromptDialog, type ToolPromptRenderProps, type ToolRendererContribution, type ToolResultView, type TransientTab, type UserMessageActionContribution, type UserMessageActionRunContext, type WebHubChannel, type WebPluginContextInventoryItem, type WebPluginContextItem, type WebPluginDefinition, type WebPluginRuntime, type WebPluginSlotProps, defineGlobalStore, defineSessionChannel, defineSessionStore, defineSlot, defineWebPlugin, hubAdvertisementPath, parseHubAdvertisement, parseSessionLineage, resolveRegistryDir, sessionLineagePath, toolResultText, toolResultTextLines };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineSessionChannel as e,defineSlot as t,defineWebPlugin as n}from"./services/define.mjs";import{
|
|
1
|
+
import{defineSessionChannel as e,defineSlot as t,defineWebPlugin as n}from"./services/define.mjs";import{defineGlobalStore as r}from"./services/globalStore.mjs";import{defineSessionStore as i}from"./services/sessionStore.mjs";import{HUB_ADVERTISEMENT_VERSION as a,REGISTRY_DIR_ENV as o,SESSION_LINEAGE_RECORD_VERSION as s,hubAdvertisementPath as c,parseHubAdvertisement as l,parseSessionLineage as u,resolveRegistryDir as d,sessionLineagePath as f}from"./services/sessionRegistry.mjs";import{toolResultText as p,toolResultTextLines as m}from"./services/toolResult.mjs";export{a as HUB_ADVERTISEMENT_VERSION,o as REGISTRY_DIR_ENV,s as SESSION_LINEAGE_RECORD_VERSION,r as defineGlobalStore,e as defineSessionChannel,i as defineSessionStore,t as defineSlot,n as defineWebPlugin,c as hubAdvertisementPath,l as parseHubAdvertisement,u as parseSessionLineage,d as resolveRegistryDir,f as sessionLineagePath,p as toolResultText,m as toolResultTextLines};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { SessionChannelContribution, SlotDeclaration, WebPluginDefinition } from "../types/webPlugin.cjs";
|
|
2
2
|
//#region src/services/define.d.ts
|
|
3
3
|
/** Identity helper so plugin modules get checked literals without a type annotation. */
|
|
4
|
-
declare function defineWebPlugin(plugin: WebPluginDefinition): WebPluginDefinition;
|
|
4
|
+
export declare function defineWebPlugin(plugin: WebPluginDefinition): WebPluginDefinition;
|
|
5
5
|
/**
|
|
6
6
|
* The one audited erasure from Payload to unknown. Channels are stored
|
|
7
7
|
* untyped in the host registry; the payload type lives entirely inside the
|
|
8
8
|
* plugin, behind its own parse gate.
|
|
9
9
|
*/
|
|
10
|
-
declare function defineSessionChannel<Payload>(channel: SessionChannelContribution<Payload>): SessionChannelContribution;
|
|
10
|
+
export declare function defineSessionChannel<Payload>(channel: SessionChannelContribution<Payload>): SessionChannelContribution;
|
|
11
11
|
/**
|
|
12
12
|
* Identity helper for a typed slot handle: the owner keeps the
|
|
13
13
|
* SlotDeclaration<Data> to read its fills back through slotData, and the
|
|
14
14
|
* plugin's `slots` array holds it erased. No cast is needed because Data only
|
|
15
15
|
* appears in the parse gate's return position.
|
|
16
16
|
*/
|
|
17
|
-
declare function defineSlot<Data>(slot: SlotDeclaration<Data>): SlotDeclaration<Data>;
|
|
17
|
+
export declare function defineSlot<Data>(slot: SlotDeclaration<Data>): SlotDeclaration<Data>;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { defineSessionChannel, defineSlot, defineWebPlugin };
|
|
20
19
|
//# sourceMappingURL=define.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.cts","names":[],"sources":["../../src/services/define.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"define.d.cts","names":[],"sources":["../../src/services/define.ts"],"mappings":";;;wBAGgB,gBAAgB,QAAQ,sBAAsB;;;;;;wBAS9C,qBAAqB,SACnC,SAAS,2BAA2B,WACnC;;;;;;;wBAUa,WAAW,MAAM,MAAM,gBAAgB,QAAQ,gBAAgB"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { SessionChannelContribution, SlotDeclaration, WebPluginDefinition } from "../types/webPlugin.mjs";
|
|
2
2
|
//#region src/services/define.d.ts
|
|
3
3
|
/** Identity helper so plugin modules get checked literals without a type annotation. */
|
|
4
|
-
declare function defineWebPlugin(plugin: WebPluginDefinition): WebPluginDefinition;
|
|
4
|
+
export declare function defineWebPlugin(plugin: WebPluginDefinition): WebPluginDefinition;
|
|
5
5
|
/**
|
|
6
6
|
* The one audited erasure from Payload to unknown. Channels are stored
|
|
7
7
|
* untyped in the host registry; the payload type lives entirely inside the
|
|
8
8
|
* plugin, behind its own parse gate.
|
|
9
9
|
*/
|
|
10
|
-
declare function defineSessionChannel<Payload>(channel: SessionChannelContribution<Payload>): SessionChannelContribution;
|
|
10
|
+
export declare function defineSessionChannel<Payload>(channel: SessionChannelContribution<Payload>): SessionChannelContribution;
|
|
11
11
|
/**
|
|
12
12
|
* Identity helper for a typed slot handle: the owner keeps the
|
|
13
13
|
* SlotDeclaration<Data> to read its fills back through slotData, and the
|
|
14
14
|
* plugin's `slots` array holds it erased. No cast is needed because Data only
|
|
15
15
|
* appears in the parse gate's return position.
|
|
16
16
|
*/
|
|
17
|
-
declare function defineSlot<Data>(slot: SlotDeclaration<Data>): SlotDeclaration<Data>;
|
|
17
|
+
export declare function defineSlot<Data>(slot: SlotDeclaration<Data>): SlotDeclaration<Data>;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { defineSessionChannel, defineSlot, defineWebPlugin };
|
|
20
19
|
//# sourceMappingURL=define.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.mts","names":[],"sources":["../../src/services/define.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"define.d.mts","names":[],"sources":["../../src/services/define.ts"],"mappings":";;;wBAGgB,gBAAgB,QAAQ,sBAAsB;;;;;;wBAS9C,qBAAqB,SACnC,SAAS,2BAA2B,WACnC;;;;;;;wBAUa,WAAW,MAAM,MAAM,gBAAgB,QAAQ,gBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalStore.cjs","names":["Store"],"sources":["../../src/services/globalStore.ts"],"sourcesContent":["import { Store } from '@tanstack/store';\nimport type { GlobalStore } from '../types/webPlugin.ts';\n\n/** Page-wide plugin state shared by every contribution from the plugin. */\nexport function defineGlobalStore<T>(initial: T): GlobalStore<T> {\n const store = new Store<T>(initial);\n\n const update = (updater: (current: T) => T): void => {\n const current = store.state;\n const next = updater(current);\n if (next !== current) store.setState(() => next);\n };\n\n const reset = (): void => {\n store.setState((current) => (current === initial ? current : initial));\n };\n\n return { store, update, reset };\n}\n"],"mappings":"iCAIA,SAAgB,EAAqB,EAA4B,CAC/D,IAAM,EAAQ,IAAIA,EAAAA,MAAS,CAAO,EAYlC,MAAO,CAAE,QAAO,OAVA,GAAqC,CACnD,IAAM,EAAU,EAAM,MAChB,EAAO,EAAQ,CAAO,EACxB,IAAS,GAAS,EAAM,aAAe,CAAI,CACjD,EAMwB,UAJE,CACxB,EAAM,SAAU,GAAa,IAAY,EAAU,EAAU,CAAQ,CACvE,CAE8B,CAChC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GlobalStore } from "../types/webPlugin.cjs";
|
|
2
|
+
//#region src/services/globalStore.d.ts
|
|
3
|
+
/** Page-wide plugin state shared by every contribution from the plugin. */
|
|
4
|
+
export declare function defineGlobalStore<T>(initial: T): GlobalStore<T>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//# sourceMappingURL=globalStore.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalStore.d.cts","names":[],"sources":["../../src/services/globalStore.ts"],"mappings":";;;wBAIgB,kBAAkB,GAAG,SAAS,IAAI,YAAY"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GlobalStore } from "../types/webPlugin.mjs";
|
|
2
|
+
//#region src/services/globalStore.d.ts
|
|
3
|
+
/** Page-wide plugin state shared by every contribution from the plugin. */
|
|
4
|
+
export declare function defineGlobalStore<T>(initial: T): GlobalStore<T>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//# sourceMappingURL=globalStore.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalStore.d.mts","names":[],"sources":["../../src/services/globalStore.ts"],"mappings":";;;wBAIgB,kBAAkB,GAAG,SAAS,IAAI,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalStore.mjs","names":[],"sources":["../../src/services/globalStore.ts"],"sourcesContent":["import { Store } from '@tanstack/store';\nimport type { GlobalStore } from '../types/webPlugin.ts';\n\n/** Page-wide plugin state shared by every contribution from the plugin. */\nexport function defineGlobalStore<T>(initial: T): GlobalStore<T> {\n const store = new Store<T>(initial);\n\n const update = (updater: (current: T) => T): void => {\n const current = store.state;\n const next = updater(current);\n if (next !== current) store.setState(() => next);\n };\n\n const reset = (): void => {\n store.setState((current) => (current === initial ? current : initial));\n };\n\n return { store, update, reset };\n}\n"],"mappings":"wCAIA,SAAgB,EAAqB,EAA4B,CAC/D,IAAM,EAAQ,IAAI,EAAS,CAAO,EAYlC,MAAO,CAAE,QAAO,OAVA,GAAqC,CACnD,IAAM,EAAU,EAAM,MAChB,EAAO,EAAQ,CAAO,EACxB,IAAS,GAAS,EAAM,aAAe,CAAI,CACjD,EAMwB,UAJE,CACxB,EAAM,SAAU,GAAa,IAAY,EAAU,EAAU,CAAQ,CACvE,CAE8B,CAChC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){return e.flagValue?e.flagValue:e.envValue?e.envValue:`${e.homeDir}/.doompi/run`}function t(e,t){return`${e}/sessions/${t}.lineage.json`}function n(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t)return;let n=t;if(n.version!==1||typeof n.parentSessionId!=`string`||n.parentSessionId===``)return;let r=typeof n.provenance==`string`?n.provenance:``;return{version:1,parentSessionId:n.parentSessionId,provenance:r}}function r(e){return`${e}/hub.json`}function i(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t)return;let n=t;if(n.version===1&&typeof n.url==`string`&&a(n.url)&&!(typeof n.pid!=`number`||!Number.isInteger(n.pid)||n.pid<=0))return{version:1,url:n.url,pid:n.pid}}function a(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`?t.hostname===`127.0.0.1`||t.hostname===`localhost`||t.hostname===`[::1]`||t.hostname===`::1`:!1}exports.HUB_ADVERTISEMENT_VERSION=1,exports.REGISTRY_DIR_ENV=`DOOMPI_RUNTIME_DIR`,exports.SESSION_LINEAGE_RECORD_VERSION=1,exports.hubAdvertisementPath=r,exports.parseHubAdvertisement=i,exports.parseSessionLineage=n,exports.resolveRegistryDir=e,exports.sessionLineagePath=t;
|
|
2
|
+
//# sourceMappingURL=sessionRegistry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionRegistry.cjs","names":[],"sources":["../../src/services/sessionRegistry.ts"],"sourcesContent":["import type { HubAdvertisement, RegistryDirInput, SessionLineageRecord } from '../types/sessionRegistry.ts';\n\n/** Overrides the runtime directory the hub and its session servers share. */\nexport const REGISTRY_DIR_ENV = 'DOOMPI_RUNTIME_DIR';\n\n/** The version a lineage sidecar must carry to be read at all. */\nexport const SESSION_LINEAGE_RECORD_VERSION = 1;\n\n/** The version a hub advertisement must carry to be read at all. */\nexport const HUB_ADVERTISEMENT_VERSION = 1;\n\nconst DEFAULT_RUN_DIR_SEGMENT = '.doompi/run';\nconst SESSIONS_SEGMENT = 'sessions';\nconst LINEAGE_EXTENSION = '.lineage.json';\nconst HUB_ADVERTISEMENT_FILE = 'hub.json';\n\n/**\n * The single definition of where the session registry lives.\n *\n * The hub, the session server, and any package that spawns a session must land\n * on the same directory or a spawned session never appears in the rail. This\n * used to be copied into each of them; it lives here so there is one answer.\n */\nexport function resolveRegistryDir(input: RegistryDirInput): string {\n if (input.flagValue) return input.flagValue;\n if (input.envValue) return input.envValue;\n return `${input.homeDir}/${DEFAULT_RUN_DIR_SEGMENT}`;\n}\n\n/** The lineage sidecar's path, beside the session's own record file. */\nexport function sessionLineagePath(registryDir: string, sessionId: string): string {\n return `${registryDir}/${SESSIONS_SEGMENT}/${sessionId}${LINEAGE_EXTENSION}`;\n}\n\n/**\n * Reads a lineage sidecar's contents.\n *\n * Every failure means the same thing to a caller: this session has no known\n * parent. A torn write, a version this build predates, or a file that is not\n * JSON at all are all normal, because the sidecar is written by a separate\n * process that may be mid-write or newer than the reader.\n */\nexport function parseSessionLineage(raw: string): SessionLineageRecord | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return undefined;\n }\n if (typeof parsed !== 'object' || parsed === null) return undefined;\n const record = parsed as Partial<SessionLineageRecord>;\n if (record.version !== SESSION_LINEAGE_RECORD_VERSION) return undefined;\n if (typeof record.parentSessionId !== 'string' || record.parentSessionId === '') return undefined;\n const provenance = typeof record.provenance === 'string' ? record.provenance : '';\n return { version: SESSION_LINEAGE_RECORD_VERSION, parentSessionId: record.parentSessionId, provenance };\n}\n\n/** Where the hub publishes its local address, at the registry root. */\nexport function hubAdvertisementPath(registryDir: string): string {\n return `${registryDir}/${HUB_ADVERTISEMENT_FILE}`;\n}\n\n/**\n * Reads a hub advertisement's contents.\n *\n * Like the lineage sidecar, every failure collapses to \"no hub advertised\",\n * because a caller can do nothing different with a torn write than with a\n * missing file. The url is required to be a loopback http origin: this file is\n * a discovery hint for local processes, and honouring an arbitrary address out\n * of it would let anything that can write the registry directory redirect a\n * session-create call to a host of its choosing.\n */\nexport function parseHubAdvertisement(raw: string): HubAdvertisement | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return undefined;\n }\n if (typeof parsed !== 'object' || parsed === null) return undefined;\n const record = parsed as Partial<HubAdvertisement>;\n if (record.version !== HUB_ADVERTISEMENT_VERSION) return undefined;\n if (typeof record.url !== 'string' || !isLoopbackHttpUrl(record.url)) return undefined;\n if (typeof record.pid !== 'number' || !Number.isInteger(record.pid) || record.pid <= 0) return undefined;\n return { version: HUB_ADVERTISEMENT_VERSION, url: record.url, pid: record.pid };\n}\n\n/** Whether a url is plain http to this machine, which is all this file may name. */\nfunction isLoopbackHttpUrl(value: string): boolean {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n if (url.protocol !== 'http:') return false;\n return (\n url.hostname === '127.0.0.1' || url.hostname === 'localhost' || url.hostname === '[::1]' || url.hostname === '::1'\n );\n}\n"],"mappings":"AAuBA,SAAgB,EAAmB,EAAiC,CAGlE,OAFI,EAAM,UAAkB,EAAM,UAC9B,EAAM,SAAiB,EAAM,SAC1B,GAAG,EAAM,QAAQ,aAC1B,CAGA,SAAgB,EAAmB,EAAqB,EAA2B,CACjF,MAAO,GAAG,EAAY,YAAuB,gBAC/C,CAUA,SAAgB,EAAoB,EAA+C,CACjF,IAAI,EACJ,GAAI,CACF,EAAS,KAAK,MAAM,CAAG,CACzB,MAAQ,CACN,MACF,CACA,GAAI,OAAO,GAAW,WAAY,EAAiB,OACnD,IAAM,EAAS,EAEf,GADI,EAAO,UAAA,GACP,OAAO,EAAO,iBAAoB,UAAY,EAAO,kBAAoB,GAAI,OACjF,IAAM,EAAa,OAAO,EAAO,YAAe,SAAW,EAAO,WAAa,GAC/E,MAAO,CAAE,QAAA,EAAyC,gBAAiB,EAAO,gBAAiB,YAAW,CACxG,CAGA,SAAgB,EAAqB,EAA6B,CAChE,MAAO,GAAG,EAAY,UACxB,CAYA,SAAgB,EAAsB,EAA2C,CAC/E,IAAI,EACJ,GAAI,CACF,EAAS,KAAK,MAAM,CAAG,CACzB,MAAQ,CACN,MACF,CACA,GAAI,OAAO,GAAW,WAAY,EAAiB,OACnD,IAAM,EAAS,EACX,KAAO,UAAA,GACP,OAAO,EAAO,KAAQ,UAAa,EAAkB,EAAO,GAAG,GAC/D,SAAO,EAAO,KAAQ,UAAY,CAAC,OAAO,UAAU,EAAO,GAAG,GAAK,EAAO,KAAO,GACrF,MAAO,CAAE,QAAA,EAAoC,IAAK,EAAO,IAAK,IAAK,EAAO,GAAI,CAChF,CAGA,SAAS,EAAkB,EAAwB,CACjD,IAAI,EACJ,GAAI,CACF,EAAM,IAAI,IAAI,CAAK,CACrB,MAAQ,CACN,MAAO,EACT,CAEA,OADI,EAAI,WAAa,QAEnB,EAAI,WAAa,aAAe,EAAI,WAAa,aAAe,EAAI,WAAa,SAAW,EAAI,WAAa,MAF1E,EAIvC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HubAdvertisement, RegistryDirInput, SessionLineageRecord } from "../types/sessionRegistry.cjs";
|
|
2
|
+
//#region src/services/sessionRegistry.d.ts
|
|
3
|
+
/** Overrides the runtime directory the hub and its session servers share. */
|
|
4
|
+
export declare const REGISTRY_DIR_ENV = "DOOMPI_RUNTIME_DIR";
|
|
5
|
+
/** The version a lineage sidecar must carry to be read at all. */
|
|
6
|
+
export declare const SESSION_LINEAGE_RECORD_VERSION = 1;
|
|
7
|
+
/** The version a hub advertisement must carry to be read at all. */
|
|
8
|
+
export declare const HUB_ADVERTISEMENT_VERSION = 1;
|
|
9
|
+
/**
|
|
10
|
+
* The single definition of where the session registry lives.
|
|
11
|
+
*
|
|
12
|
+
* The hub, the session server, and any package that spawns a session must land
|
|
13
|
+
* on the same directory or a spawned session never appears in the rail. This
|
|
14
|
+
* used to be copied into each of them; it lives here so there is one answer.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveRegistryDir(input: RegistryDirInput): string;
|
|
17
|
+
/** The lineage sidecar's path, beside the session's own record file. */
|
|
18
|
+
export declare function sessionLineagePath(registryDir: string, sessionId: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Reads a lineage sidecar's contents.
|
|
21
|
+
*
|
|
22
|
+
* Every failure means the same thing to a caller: this session has no known
|
|
23
|
+
* parent. A torn write, a version this build predates, or a file that is not
|
|
24
|
+
* JSON at all are all normal, because the sidecar is written by a separate
|
|
25
|
+
* process that may be mid-write or newer than the reader.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseSessionLineage(raw: string): SessionLineageRecord | undefined;
|
|
28
|
+
/** Where the hub publishes its local address, at the registry root. */
|
|
29
|
+
export declare function hubAdvertisementPath(registryDir: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Reads a hub advertisement's contents.
|
|
32
|
+
*
|
|
33
|
+
* Like the lineage sidecar, every failure collapses to "no hub advertised",
|
|
34
|
+
* because a caller can do nothing different with a torn write than with a
|
|
35
|
+
* missing file. The url is required to be a loopback http origin: this file is
|
|
36
|
+
* a discovery hint for local processes, and honouring an arbitrary address out
|
|
37
|
+
* of it would let anything that can write the registry directory redirect a
|
|
38
|
+
* session-create call to a host of its choosing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseHubAdvertisement(raw: string): HubAdvertisement | undefined;
|
|
41
|
+
//#endregion
|
|
42
|
+
//# sourceMappingURL=sessionRegistry.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionRegistry.d.cts","names":[],"sources":["../../src/services/sessionRegistry.ts"],"mappings":";;;qBAGa;;qBAGA;;qBAGA;;;;;;;;wBAcG,mBAAmB,OAAO;;wBAO1B,mBAAmB,qBAAqB;;;;;;;;;wBAYxC,oBAAoB,cAAc;;wBAgBlC,qBAAqB;;;;;;;;;;;wBAcrB,sBAAsB,cAAc"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HubAdvertisement, RegistryDirInput, SessionLineageRecord } from "../types/sessionRegistry.mjs";
|
|
2
|
+
//#region src/services/sessionRegistry.d.ts
|
|
3
|
+
/** Overrides the runtime directory the hub and its session servers share. */
|
|
4
|
+
export declare const REGISTRY_DIR_ENV = "DOOMPI_RUNTIME_DIR";
|
|
5
|
+
/** The version a lineage sidecar must carry to be read at all. */
|
|
6
|
+
export declare const SESSION_LINEAGE_RECORD_VERSION = 1;
|
|
7
|
+
/** The version a hub advertisement must carry to be read at all. */
|
|
8
|
+
export declare const HUB_ADVERTISEMENT_VERSION = 1;
|
|
9
|
+
/**
|
|
10
|
+
* The single definition of where the session registry lives.
|
|
11
|
+
*
|
|
12
|
+
* The hub, the session server, and any package that spawns a session must land
|
|
13
|
+
* on the same directory or a spawned session never appears in the rail. This
|
|
14
|
+
* used to be copied into each of them; it lives here so there is one answer.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveRegistryDir(input: RegistryDirInput): string;
|
|
17
|
+
/** The lineage sidecar's path, beside the session's own record file. */
|
|
18
|
+
export declare function sessionLineagePath(registryDir: string, sessionId: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Reads a lineage sidecar's contents.
|
|
21
|
+
*
|
|
22
|
+
* Every failure means the same thing to a caller: this session has no known
|
|
23
|
+
* parent. A torn write, a version this build predates, or a file that is not
|
|
24
|
+
* JSON at all are all normal, because the sidecar is written by a separate
|
|
25
|
+
* process that may be mid-write or newer than the reader.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseSessionLineage(raw: string): SessionLineageRecord | undefined;
|
|
28
|
+
/** Where the hub publishes its local address, at the registry root. */
|
|
29
|
+
export declare function hubAdvertisementPath(registryDir: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Reads a hub advertisement's contents.
|
|
32
|
+
*
|
|
33
|
+
* Like the lineage sidecar, every failure collapses to "no hub advertised",
|
|
34
|
+
* because a caller can do nothing different with a torn write than with a
|
|
35
|
+
* missing file. The url is required to be a loopback http origin: this file is
|
|
36
|
+
* a discovery hint for local processes, and honouring an arbitrary address out
|
|
37
|
+
* of it would let anything that can write the registry directory redirect a
|
|
38
|
+
* session-create call to a host of its choosing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseHubAdvertisement(raw: string): HubAdvertisement | undefined;
|
|
41
|
+
//#endregion
|
|
42
|
+
//# sourceMappingURL=sessionRegistry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionRegistry.d.mts","names":[],"sources":["../../src/services/sessionRegistry.ts"],"mappings":";;;qBAGa;;qBAGA;;qBAGA;;;;;;;;wBAcG,mBAAmB,OAAO;;wBAO1B,mBAAmB,qBAAqB;;;;;;;;;wBAYxC,oBAAoB,cAAc;;wBAgBlC,qBAAqB;;;;;;;;;;;wBAcrB,sBAAsB,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`DOOMPI_RUNTIME_DIR`,t=1,n=1;function r(e){return e.flagValue?e.flagValue:e.envValue?e.envValue:`${e.homeDir}/.doompi/run`}function i(e,t){return`${e}/sessions/${t}.lineage.json`}function a(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t)return;let n=t;if(n.version!==1||typeof n.parentSessionId!=`string`||n.parentSessionId===``)return;let r=typeof n.provenance==`string`?n.provenance:``;return{version:1,parentSessionId:n.parentSessionId,provenance:r}}function o(e){return`${e}/hub.json`}function s(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t)return;let n=t;if(n.version===1&&typeof n.url==`string`&&c(n.url)&&!(typeof n.pid!=`number`||!Number.isInteger(n.pid)||n.pid<=0))return{version:1,url:n.url,pid:n.pid}}function c(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`?t.hostname===`127.0.0.1`||t.hostname===`localhost`||t.hostname===`[::1]`||t.hostname===`::1`:!1}export{n as HUB_ADVERTISEMENT_VERSION,e as REGISTRY_DIR_ENV,t as SESSION_LINEAGE_RECORD_VERSION,o as hubAdvertisementPath,s as parseHubAdvertisement,a as parseSessionLineage,r as resolveRegistryDir,i as sessionLineagePath};
|
|
2
|
+
//# sourceMappingURL=sessionRegistry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionRegistry.mjs","names":[],"sources":["../../src/services/sessionRegistry.ts"],"sourcesContent":["import type { HubAdvertisement, RegistryDirInput, SessionLineageRecord } from '../types/sessionRegistry.ts';\n\n/** Overrides the runtime directory the hub and its session servers share. */\nexport const REGISTRY_DIR_ENV = 'DOOMPI_RUNTIME_DIR';\n\n/** The version a lineage sidecar must carry to be read at all. */\nexport const SESSION_LINEAGE_RECORD_VERSION = 1;\n\n/** The version a hub advertisement must carry to be read at all. */\nexport const HUB_ADVERTISEMENT_VERSION = 1;\n\nconst DEFAULT_RUN_DIR_SEGMENT = '.doompi/run';\nconst SESSIONS_SEGMENT = 'sessions';\nconst LINEAGE_EXTENSION = '.lineage.json';\nconst HUB_ADVERTISEMENT_FILE = 'hub.json';\n\n/**\n * The single definition of where the session registry lives.\n *\n * The hub, the session server, and any package that spawns a session must land\n * on the same directory or a spawned session never appears in the rail. This\n * used to be copied into each of them; it lives here so there is one answer.\n */\nexport function resolveRegistryDir(input: RegistryDirInput): string {\n if (input.flagValue) return input.flagValue;\n if (input.envValue) return input.envValue;\n return `${input.homeDir}/${DEFAULT_RUN_DIR_SEGMENT}`;\n}\n\n/** The lineage sidecar's path, beside the session's own record file. */\nexport function sessionLineagePath(registryDir: string, sessionId: string): string {\n return `${registryDir}/${SESSIONS_SEGMENT}/${sessionId}${LINEAGE_EXTENSION}`;\n}\n\n/**\n * Reads a lineage sidecar's contents.\n *\n * Every failure means the same thing to a caller: this session has no known\n * parent. A torn write, a version this build predates, or a file that is not\n * JSON at all are all normal, because the sidecar is written by a separate\n * process that may be mid-write or newer than the reader.\n */\nexport function parseSessionLineage(raw: string): SessionLineageRecord | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return undefined;\n }\n if (typeof parsed !== 'object' || parsed === null) return undefined;\n const record = parsed as Partial<SessionLineageRecord>;\n if (record.version !== SESSION_LINEAGE_RECORD_VERSION) return undefined;\n if (typeof record.parentSessionId !== 'string' || record.parentSessionId === '') return undefined;\n const provenance = typeof record.provenance === 'string' ? record.provenance : '';\n return { version: SESSION_LINEAGE_RECORD_VERSION, parentSessionId: record.parentSessionId, provenance };\n}\n\n/** Where the hub publishes its local address, at the registry root. */\nexport function hubAdvertisementPath(registryDir: string): string {\n return `${registryDir}/${HUB_ADVERTISEMENT_FILE}`;\n}\n\n/**\n * Reads a hub advertisement's contents.\n *\n * Like the lineage sidecar, every failure collapses to \"no hub advertised\",\n * because a caller can do nothing different with a torn write than with a\n * missing file. The url is required to be a loopback http origin: this file is\n * a discovery hint for local processes, and honouring an arbitrary address out\n * of it would let anything that can write the registry directory redirect a\n * session-create call to a host of its choosing.\n */\nexport function parseHubAdvertisement(raw: string): HubAdvertisement | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return undefined;\n }\n if (typeof parsed !== 'object' || parsed === null) return undefined;\n const record = parsed as Partial<HubAdvertisement>;\n if (record.version !== HUB_ADVERTISEMENT_VERSION) return undefined;\n if (typeof record.url !== 'string' || !isLoopbackHttpUrl(record.url)) return undefined;\n if (typeof record.pid !== 'number' || !Number.isInteger(record.pid) || record.pid <= 0) return undefined;\n return { version: HUB_ADVERTISEMENT_VERSION, url: record.url, pid: record.pid };\n}\n\n/** Whether a url is plain http to this machine, which is all this file may name. */\nfunction isLoopbackHttpUrl(value: string): boolean {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n if (url.protocol !== 'http:') return false;\n return (\n url.hostname === '127.0.0.1' || url.hostname === 'localhost' || url.hostname === '[::1]' || url.hostname === '::1'\n );\n}\n"],"mappings":"AAGA,MAAa,EAAmB,qBAGnB,EAAiC,EAGjC,EAA4B,EAczC,SAAgB,EAAmB,EAAiC,CAGlE,OAFI,EAAM,UAAkB,EAAM,UAC9B,EAAM,SAAiB,EAAM,SAC1B,GAAG,EAAM,QAAQ,aAC1B,CAGA,SAAgB,EAAmB,EAAqB,EAA2B,CACjF,MAAO,GAAG,EAAY,YAAuB,gBAC/C,CAUA,SAAgB,EAAoB,EAA+C,CACjF,IAAI,EACJ,GAAI,CACF,EAAS,KAAK,MAAM,CAAG,CACzB,MAAQ,CACN,MACF,CACA,GAAI,OAAO,GAAW,WAAY,EAAiB,OACnD,IAAM,EAAS,EAEf,GADI,EAAO,UAAA,GACP,OAAO,EAAO,iBAAoB,UAAY,EAAO,kBAAoB,GAAI,OACjF,IAAM,EAAa,OAAO,EAAO,YAAe,SAAW,EAAO,WAAa,GAC/E,MAAO,CAAE,QAAA,EAAyC,gBAAiB,EAAO,gBAAiB,YAAW,CACxG,CAGA,SAAgB,EAAqB,EAA6B,CAChE,MAAO,GAAG,EAAY,UACxB,CAYA,SAAgB,EAAsB,EAA2C,CAC/E,IAAI,EACJ,GAAI,CACF,EAAS,KAAK,MAAM,CAAG,CACzB,MAAQ,CACN,MACF,CACA,GAAI,OAAO,GAAW,WAAY,EAAiB,OACnD,IAAM,EAAS,EACX,KAAO,UAAA,GACP,OAAO,EAAO,KAAQ,UAAa,EAAkB,EAAO,GAAG,GAC/D,SAAO,EAAO,KAAQ,UAAY,CAAC,OAAO,UAAU,EAAO,GAAG,GAAK,EAAO,KAAO,GACrF,MAAO,CAAE,QAAA,EAAoC,IAAK,EAAO,IAAK,IAAK,EAAO,GAAI,CAChF,CAGA,SAAS,EAAkB,EAAwB,CACjD,IAAI,EACJ,GAAI,CACF,EAAM,IAAI,IAAI,CAAK,CACrB,MAAQ,CACN,MAAO,EACT,CAEA,OADI,EAAI,WAAa,QAEnB,EAAI,WAAa,aAAe,EAAI,WAAa,aAAe,EAAI,WAAa,SAAW,EAAI,WAAa,MAF1E,EAIvC"}
|
|
@@ -9,7 +9,6 @@ import { SessionStore } from "../types/webPlugin.cjs";
|
|
|
9
9
|
* per read would re-render forever. Records are therefore immutable values,
|
|
10
10
|
* and updaters and reducers return new ones.
|
|
11
11
|
*/
|
|
12
|
-
declare function defineSessionStore<T>(empty: T): SessionStore<T>;
|
|
12
|
+
export declare function defineSessionStore<T>(empty: T): SessionStore<T>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { defineSessionStore };
|
|
15
14
|
//# sourceMappingURL=sessionStore.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionStore.d.cts","names":[],"sources":["../../src/services/sessionStore.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sessionStore.d.cts","names":[],"sources":["../../src/services/sessionStore.ts"],"mappings":";;;;;;;;;;;wBAkBgB,mBAAmB,GAAG,OAAO,IAAI,aAAa"}
|
|
@@ -9,7 +9,6 @@ import { SessionStore } from "../types/webPlugin.mjs";
|
|
|
9
9
|
* per read would re-render forever. Records are therefore immutable values,
|
|
10
10
|
* and updaters and reducers return new ones.
|
|
11
11
|
*/
|
|
12
|
-
declare function defineSessionStore<T>(empty: T): SessionStore<T>;
|
|
12
|
+
export declare function defineSessionStore<T>(empty: T): SessionStore<T>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { defineSessionStore };
|
|
15
14
|
//# sourceMappingURL=sessionStore.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionStore.d.mts","names":[],"sources":["../../src/services/sessionStore.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sessionStore.d.mts","names":[],"sources":["../../src/services/sessionStore.ts"],"mappings":";;;;;;;;;;;wBAkBgB,mBAAmB,GAAG,OAAO,IAAI,aAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,n){let r=e.parse(n);return r===null?{accepted:!1}:(e.apply(t,r),{accepted:!0})}const t={sessionId:`s1`,cwd:`/repo`};function n(e,n={}){let r=[...n.sessions??[t]],i=[],a=[],o=e.start({sessions:()=>r,publish:(t,n)=>{i.push({type:e.frameType,sessionId:t,payload:n})},onNotice:e=>a.push(e)});return{source:o,published:i,notices:a,snapshot(e){let n=r.find(t=>t.sessionId===e)??r[0]??t;return o.payloadFor(n)},addSession(e){r.push(e),o.sessionAdded?.(e)},removeSession(e){let t=r.findIndex(t=>t.sessionId===e);t>=0&&r.splice(t,1),o.sessionRemoved?.(e)},close:()=>o.close()}}exports.driveChannel=e,exports.hubChannelHarness=n;
|
|
1
|
+
function e(e,t,n){let r=e.parse(n);return r===null?{accepted:!1}:(e.apply(t,r),{accepted:!0})}const t={sessionId:`s1`,cwd:`/repo`};function n(e,n={}){let r=[...n.sessions??[t]],i=[],a=[],o=e.start({sessions:()=>r,publish:(t,n)=>{i.push({type:e.frameType,sessionId:t,payload:n})},requestSessionApi:()=>Promise.resolve(Response.json({error:`No session API in the channel harness.`},{status:501})),onNotice:e=>a.push(e)});return{source:o,published:i,notices:a,snapshot(e){let n=r.find(t=>t.sessionId===e)??r[0]??t;return o.payloadFor(n)},addSession(e){r.push(e),o.sessionAdded?.(e)},removeSession(e){let t=r.findIndex(t=>t.sessionId===e);t>=0&&r.splice(t,1),o.sessionRemoved?.(e)},close:()=>o.close()}}exports.driveChannel=e,exports.hubChannelHarness=n;
|
|
2
2
|
//# sourceMappingURL=channels.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.cjs","names":[],"sources":["../../../src/services/testing/channels.ts"],"sourcesContent":["import type {\n ChannelFrame,\n HubChannelHost,\n HubChannelSource,\n HubSessionScope,\n WebHubChannel,\n} from '../../types/webHub.ts';\nimport type { SessionChannelContribution } from '../../types/webPlugin.ts';\n\n/**\n * The two halves of a plugin's data channel, driven the way the hub drives them.\n *\n * A channel is the one place a plugin parses input it did not produce, so its\n * parse gate is the boundary that matters, and a test that calls `apply`\n * directly steps straight over it. `driveChannel` sends a wire payload the way\n * the page does: through `parse` first, and nothing applied when it is\n * rejected.\n */\n\nexport interface ChannelDelivery {\n /** Whether the parse gate accepted the payload. */\n accepted: boolean;\n}\n\n/**\n * Sends one wire payload to a session channel.\n *\n * Returns whether the gate accepted it, so a test can assert a rejection\n * without knowing what the plugin's parsed shape looks like.\n */\nexport function driveChannel(\n channel: SessionChannelContribution,\n sessionId: string,\n payload: unknown,\n): ChannelDelivery {\n const parsed: unknown = channel.parse(payload);\n if (parsed === null) return { accepted: false };\n channel.apply(sessionId, parsed);\n return { accepted: true };\n}\n\nexport interface HubChannelHarness {\n /** The running source, as the hub holds it. */\n source: HubChannelSource;\n /** Everything the source pushed, in order. */\n readonly published: readonly ChannelFrame[];\n /** What the source told the hub. */\n readonly notices: readonly string[];\n /** The subscribe-time snapshot one session would receive; undefined means no frame. */\n snapshot(sessionId?: string): unknown;\n /** Registers a session with the source, as the hub does when one appears. */\n addSession(scope: HubSessionScope): void;\n removeSession(sessionId: string): void;\n close(): void;\n}\n\nexport interface HubChannelHarnessOptions {\n /** Sessions the hub already manages when the channel starts. */\n sessions?: readonly HubSessionScope[];\n}\n\nconst DEFAULT_SESSION: HubSessionScope = { sessionId: 's1', cwd: '/repo' };\n\n/**\n * A plugin's hub channel, started against a real host.\n *\n * The hub calls `payloadFor` once per subscriber and pushes through `publish`\n * afterwards, and a channel that only answers one of those looks correct in a\n * test that exercises the other.\n */\nexport function hubChannelHarness(channel: WebHubChannel, options: HubChannelHarnessOptions = {}): HubChannelHarness {\n const sessions = [...(options.sessions ?? [DEFAULT_SESSION])];\n const published: ChannelFrame[] = [];\n const notices: string[] = [];\n const host: HubChannelHost = {\n sessions: () => sessions,\n publish: (sessionId, payload) => {\n published.push({ type: channel.frameType, sessionId, payload });\n },\n onNotice: (message) => notices.push(message),\n };\n const source = channel.start(host);\n\n return {\n source,\n published,\n notices,\n snapshot(sessionId) {\n const scope = sessions.find((candidate) => candidate.sessionId === sessionId) ?? sessions[0] ?? DEFAULT_SESSION;\n return source.payloadFor(scope);\n },\n addSession(scope) {\n sessions.push(scope);\n source.sessionAdded?.(scope);\n },\n removeSession(sessionId) {\n const index = sessions.findIndex((candidate) => candidate.sessionId === sessionId);\n if (index >= 0) sessions.splice(index, 1);\n source.sessionRemoved?.(sessionId);\n },\n close: () => source.close(),\n };\n}\n"],"mappings":"AA8BA,SAAgB,EACd,EACA,EACA,EACiB,CACjB,IAAM,EAAkB,EAAQ,MAAM,CAAO,EAG7C,OAFI,IAAW,KAAa,CAAE,SAAU,EAAM,GAC9C,EAAQ,MAAM,EAAW,CAAM,EACxB,CAAE,SAAU,EAAK,EAC1B,CAsBA,MAAM,EAAmC,CAAE,UAAW,KAAM,IAAK,OAAQ,EASzE,SAAgB,EAAkB,EAAwB,EAAoC,CAAC,EAAsB,CACnH,IAAM,EAAW,CAAC,GAAI,EAAQ,UAAY,CAAC,CAAe,CAAE,EACtD,EAA4B,CAAC,EAC7B,EAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"channels.cjs","names":[],"sources":["../../../src/services/testing/channels.ts"],"sourcesContent":["import type {\n ChannelFrame,\n HubChannelHost,\n HubChannelSource,\n HubSessionScope,\n WebHubChannel,\n} from '../../types/webHub.ts';\nimport type { SessionChannelContribution } from '../../types/webPlugin.ts';\n\n/**\n * The two halves of a plugin's data channel, driven the way the hub drives them.\n *\n * A channel is the one place a plugin parses input it did not produce, so its\n * parse gate is the boundary that matters, and a test that calls `apply`\n * directly steps straight over it. `driveChannel` sends a wire payload the way\n * the page does: through `parse` first, and nothing applied when it is\n * rejected.\n */\n\nexport interface ChannelDelivery {\n /** Whether the parse gate accepted the payload. */\n accepted: boolean;\n}\n\n/**\n * Sends one wire payload to a session channel.\n *\n * Returns whether the gate accepted it, so a test can assert a rejection\n * without knowing what the plugin's parsed shape looks like.\n */\nexport function driveChannel(\n channel: SessionChannelContribution,\n sessionId: string,\n payload: unknown,\n): ChannelDelivery {\n const parsed: unknown = channel.parse(payload);\n if (parsed === null) return { accepted: false };\n channel.apply(sessionId, parsed);\n return { accepted: true };\n}\n\nexport interface HubChannelHarness {\n /** The running source, as the hub holds it. */\n source: HubChannelSource;\n /** Everything the source pushed, in order. */\n readonly published: readonly ChannelFrame[];\n /** What the source told the hub. */\n readonly notices: readonly string[];\n /** The subscribe-time snapshot one session would receive; undefined means no frame. */\n snapshot(sessionId?: string): unknown;\n /** Registers a session with the source, as the hub does when one appears. */\n addSession(scope: HubSessionScope): void;\n removeSession(sessionId: string): void;\n close(): void;\n}\n\nexport interface HubChannelHarnessOptions {\n /** Sessions the hub already manages when the channel starts. */\n sessions?: readonly HubSessionScope[];\n}\n\nconst DEFAULT_SESSION: HubSessionScope = { sessionId: 's1', cwd: '/repo' };\n\n/**\n * A plugin's hub channel, started against a real host.\n *\n * The hub calls `payloadFor` once per subscriber and pushes through `publish`\n * afterwards, and a channel that only answers one of those looks correct in a\n * test that exercises the other.\n */\nexport function hubChannelHarness(channel: WebHubChannel, options: HubChannelHarnessOptions = {}): HubChannelHarness {\n const sessions = [...(options.sessions ?? [DEFAULT_SESSION])];\n const published: ChannelFrame[] = [];\n const notices: string[] = [];\n const host: HubChannelHost = {\n sessions: () => sessions,\n publish: (sessionId, payload) => {\n published.push({ type: channel.frameType, sessionId, payload });\n },\n requestSessionApi: () =>\n Promise.resolve(Response.json({ error: 'No session API in the channel harness.' }, { status: 501 })),\n onNotice: (message) => notices.push(message),\n };\n const source = channel.start(host);\n\n return {\n source,\n published,\n notices,\n snapshot(sessionId) {\n const scope = sessions.find((candidate) => candidate.sessionId === sessionId) ?? sessions[0] ?? DEFAULT_SESSION;\n return source.payloadFor(scope);\n },\n addSession(scope) {\n sessions.push(scope);\n source.sessionAdded?.(scope);\n },\n removeSession(sessionId) {\n const index = sessions.findIndex((candidate) => candidate.sessionId === sessionId);\n if (index >= 0) sessions.splice(index, 1);\n source.sessionRemoved?.(sessionId);\n },\n close: () => source.close(),\n };\n}\n"],"mappings":"AA8BA,SAAgB,EACd,EACA,EACA,EACiB,CACjB,IAAM,EAAkB,EAAQ,MAAM,CAAO,EAG7C,OAFI,IAAW,KAAa,CAAE,SAAU,EAAM,GAC9C,EAAQ,MAAM,EAAW,CAAM,EACxB,CAAE,SAAU,EAAK,EAC1B,CAsBA,MAAM,EAAmC,CAAE,UAAW,KAAM,IAAK,OAAQ,EASzE,SAAgB,EAAkB,EAAwB,EAAoC,CAAC,EAAsB,CACnH,IAAM,EAAW,CAAC,GAAI,EAAQ,UAAY,CAAC,CAAe,CAAE,EACtD,EAA4B,CAAC,EAC7B,EAAoB,CAAC,EAUrB,EAAS,EAAQ,MAAM,CAR3B,aAAgB,EAChB,SAAU,EAAW,IAAY,CAC/B,EAAU,KAAK,CAAE,KAAM,EAAQ,UAAW,YAAW,SAAQ,CAAC,CAChE,EACA,sBACE,QAAQ,QAAQ,SAAS,KAAK,CAAE,MAAO,wCAAyC,EAAG,CAAE,OAAQ,GAAI,CAAC,CAAC,EACrG,SAAW,GAAY,EAAQ,KAAK,CAAO,CAEb,CAAC,EAEjC,MAAO,CACL,SACA,YACA,UACA,SAAS,EAAW,CAClB,IAAM,EAAQ,EAAS,KAAM,GAAc,EAAU,YAAc,CAAS,GAAK,EAAS,IAAM,EAChG,OAAO,EAAO,WAAW,CAAK,CAChC,EACA,WAAW,EAAO,CAChB,EAAS,KAAK,CAAK,EACnB,EAAO,eAAe,CAAK,CAC7B,EACA,cAAc,EAAW,CACvB,IAAM,EAAQ,EAAS,UAAW,GAAc,EAAU,YAAc,CAAS,EAC7E,GAAS,GAAG,EAAS,OAAO,EAAO,CAAC,EACxC,EAAO,iBAAiB,CAAS,CACnC,EACA,UAAa,EAAO,MAAM,CAC5B,CACF"}
|
|
@@ -10,7 +10,7 @@ import { ChannelFrame, HubChannelSource, HubSessionScope, WebHubChannel } from "
|
|
|
10
10
|
* the page does: through `parse` first, and nothing applied when it is
|
|
11
11
|
* rejected.
|
|
12
12
|
*/
|
|
13
|
-
interface ChannelDelivery {
|
|
13
|
+
export interface ChannelDelivery {
|
|
14
14
|
/** Whether the parse gate accepted the payload. */
|
|
15
15
|
accepted: boolean;
|
|
16
16
|
}
|
|
@@ -20,8 +20,8 @@ interface ChannelDelivery {
|
|
|
20
20
|
* Returns whether the gate accepted it, so a test can assert a rejection
|
|
21
21
|
* without knowing what the plugin's parsed shape looks like.
|
|
22
22
|
*/
|
|
23
|
-
declare function driveChannel(channel: SessionChannelContribution, sessionId: string, payload: unknown): ChannelDelivery;
|
|
24
|
-
interface HubChannelHarness {
|
|
23
|
+
export declare function driveChannel(channel: SessionChannelContribution, sessionId: string, payload: unknown): ChannelDelivery;
|
|
24
|
+
export interface HubChannelHarness {
|
|
25
25
|
/** The running source, as the hub holds it. */
|
|
26
26
|
source: HubChannelSource;
|
|
27
27
|
/** Everything the source pushed, in order. */
|
|
@@ -35,7 +35,7 @@ interface HubChannelHarness {
|
|
|
35
35
|
removeSession(sessionId: string): void;
|
|
36
36
|
close(): void;
|
|
37
37
|
}
|
|
38
|
-
interface HubChannelHarnessOptions {
|
|
38
|
+
export interface HubChannelHarnessOptions {
|
|
39
39
|
/** Sessions the hub already manages when the channel starts. */
|
|
40
40
|
sessions?: readonly HubSessionScope[];
|
|
41
41
|
}
|
|
@@ -46,7 +46,6 @@ interface HubChannelHarnessOptions {
|
|
|
46
46
|
* afterwards, and a channel that only answers one of those looks correct in a
|
|
47
47
|
* test that exercises the other.
|
|
48
48
|
*/
|
|
49
|
-
declare function hubChannelHarness(channel: WebHubChannel, options?: HubChannelHarnessOptions): HubChannelHarness;
|
|
49
|
+
export declare function hubChannelHarness(channel: WebHubChannel, options?: HubChannelHarnessOptions): HubChannelHarness;
|
|
50
50
|
//#endregion
|
|
51
|
-
export { ChannelDelivery, HubChannelHarness, HubChannelHarnessOptions, driveChannel, hubChannelHarness };
|
|
52
51
|
//# sourceMappingURL=channels.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.d.cts","names":[],"sources":["../../../src/services/testing/channels.ts"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"channels.d.cts","names":[],"sources":["../../../src/services/testing/channels.ts"],"mappings":";;;;;;;;;;;;iBAmBiB;;EAEf;;;;;;;;wBASc,aACd,SAAS,4BACT,mBACA,mBACC;iBAOc;;EAEf,QAAQ;;WAEC,oBAAoB;;WAEpB;;EAET,SAAS;;EAET,WAAW,OAAO;EAClB,cAAc;EACd;;iBAGe;;EAEf,oBAAoB;;;;;;;;;wBAYN,kBAAkB,SAAS,eAAe,UAAS,2BAAgC"}
|
|
@@ -10,7 +10,7 @@ import { ChannelFrame, HubChannelSource, HubSessionScope, WebHubChannel } from "
|
|
|
10
10
|
* the page does: through `parse` first, and nothing applied when it is
|
|
11
11
|
* rejected.
|
|
12
12
|
*/
|
|
13
|
-
interface ChannelDelivery {
|
|
13
|
+
export interface ChannelDelivery {
|
|
14
14
|
/** Whether the parse gate accepted the payload. */
|
|
15
15
|
accepted: boolean;
|
|
16
16
|
}
|
|
@@ -20,8 +20,8 @@ interface ChannelDelivery {
|
|
|
20
20
|
* Returns whether the gate accepted it, so a test can assert a rejection
|
|
21
21
|
* without knowing what the plugin's parsed shape looks like.
|
|
22
22
|
*/
|
|
23
|
-
declare function driveChannel(channel: SessionChannelContribution, sessionId: string, payload: unknown): ChannelDelivery;
|
|
24
|
-
interface HubChannelHarness {
|
|
23
|
+
export declare function driveChannel(channel: SessionChannelContribution, sessionId: string, payload: unknown): ChannelDelivery;
|
|
24
|
+
export interface HubChannelHarness {
|
|
25
25
|
/** The running source, as the hub holds it. */
|
|
26
26
|
source: HubChannelSource;
|
|
27
27
|
/** Everything the source pushed, in order. */
|
|
@@ -35,7 +35,7 @@ interface HubChannelHarness {
|
|
|
35
35
|
removeSession(sessionId: string): void;
|
|
36
36
|
close(): void;
|
|
37
37
|
}
|
|
38
|
-
interface HubChannelHarnessOptions {
|
|
38
|
+
export interface HubChannelHarnessOptions {
|
|
39
39
|
/** Sessions the hub already manages when the channel starts. */
|
|
40
40
|
sessions?: readonly HubSessionScope[];
|
|
41
41
|
}
|
|
@@ -46,7 +46,6 @@ interface HubChannelHarnessOptions {
|
|
|
46
46
|
* afterwards, and a channel that only answers one of those looks correct in a
|
|
47
47
|
* test that exercises the other.
|
|
48
48
|
*/
|
|
49
|
-
declare function hubChannelHarness(channel: WebHubChannel, options?: HubChannelHarnessOptions): HubChannelHarness;
|
|
49
|
+
export declare function hubChannelHarness(channel: WebHubChannel, options?: HubChannelHarnessOptions): HubChannelHarness;
|
|
50
50
|
//#endregion
|
|
51
|
-
export { ChannelDelivery, HubChannelHarness, HubChannelHarnessOptions, driveChannel, hubChannelHarness };
|
|
52
51
|
//# sourceMappingURL=channels.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.d.mts","names":[],"sources":["../../../src/services/testing/channels.ts"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"channels.d.mts","names":[],"sources":["../../../src/services/testing/channels.ts"],"mappings":";;;;;;;;;;;;iBAmBiB;;EAEf;;;;;;;;wBASc,aACd,SAAS,4BACT,mBACA,mBACC;iBAOc;;EAEf,QAAQ;;WAEC,oBAAoB;;WAEpB;;EAET,SAAS;;EAET,WAAW,OAAO;EAClB,cAAc;EACd;;iBAGe;;EAEf,oBAAoB;;;;;;;;;wBAYN,kBAAkB,SAAS,eAAe,UAAS,2BAAgC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,n){let r=e.parse(n);return r===null?{accepted:!1}:(e.apply(t,r),{accepted:!0})}const t={sessionId:`s1`,cwd:`/repo`};function n(e,n={}){let r=[...n.sessions??[t]],i=[],a=[],o=e.start({sessions:()=>r,publish:(t,n)=>{i.push({type:e.frameType,sessionId:t,payload:n})},onNotice:e=>a.push(e)});return{source:o,published:i,notices:a,snapshot(e){let n=r.find(t=>t.sessionId===e)??r[0]??t;return o.payloadFor(n)},addSession(e){r.push(e),o.sessionAdded?.(e)},removeSession(e){let t=r.findIndex(t=>t.sessionId===e);t>=0&&r.splice(t,1),o.sessionRemoved?.(e)},close:()=>o.close()}}export{e as driveChannel,n as hubChannelHarness};
|
|
1
|
+
function e(e,t,n){let r=e.parse(n);return r===null?{accepted:!1}:(e.apply(t,r),{accepted:!0})}const t={sessionId:`s1`,cwd:`/repo`};function n(e,n={}){let r=[...n.sessions??[t]],i=[],a=[],o=e.start({sessions:()=>r,publish:(t,n)=>{i.push({type:e.frameType,sessionId:t,payload:n})},requestSessionApi:()=>Promise.resolve(Response.json({error:`No session API in the channel harness.`},{status:501})),onNotice:e=>a.push(e)});return{source:o,published:i,notices:a,snapshot(e){let n=r.find(t=>t.sessionId===e)??r[0]??t;return o.payloadFor(n)},addSession(e){r.push(e),o.sessionAdded?.(e)},removeSession(e){let t=r.findIndex(t=>t.sessionId===e);t>=0&&r.splice(t,1),o.sessionRemoved?.(e)},close:()=>o.close()}}export{e as driveChannel,n as hubChannelHarness};
|
|
2
2
|
//# sourceMappingURL=channels.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.mjs","names":[],"sources":["../../../src/services/testing/channels.ts"],"sourcesContent":["import type {\n ChannelFrame,\n HubChannelHost,\n HubChannelSource,\n HubSessionScope,\n WebHubChannel,\n} from '../../types/webHub.ts';\nimport type { SessionChannelContribution } from '../../types/webPlugin.ts';\n\n/**\n * The two halves of a plugin's data channel, driven the way the hub drives them.\n *\n * A channel is the one place a plugin parses input it did not produce, so its\n * parse gate is the boundary that matters, and a test that calls `apply`\n * directly steps straight over it. `driveChannel` sends a wire payload the way\n * the page does: through `parse` first, and nothing applied when it is\n * rejected.\n */\n\nexport interface ChannelDelivery {\n /** Whether the parse gate accepted the payload. */\n accepted: boolean;\n}\n\n/**\n * Sends one wire payload to a session channel.\n *\n * Returns whether the gate accepted it, so a test can assert a rejection\n * without knowing what the plugin's parsed shape looks like.\n */\nexport function driveChannel(\n channel: SessionChannelContribution,\n sessionId: string,\n payload: unknown,\n): ChannelDelivery {\n const parsed: unknown = channel.parse(payload);\n if (parsed === null) return { accepted: false };\n channel.apply(sessionId, parsed);\n return { accepted: true };\n}\n\nexport interface HubChannelHarness {\n /** The running source, as the hub holds it. */\n source: HubChannelSource;\n /** Everything the source pushed, in order. */\n readonly published: readonly ChannelFrame[];\n /** What the source told the hub. */\n readonly notices: readonly string[];\n /** The subscribe-time snapshot one session would receive; undefined means no frame. */\n snapshot(sessionId?: string): unknown;\n /** Registers a session with the source, as the hub does when one appears. */\n addSession(scope: HubSessionScope): void;\n removeSession(sessionId: string): void;\n close(): void;\n}\n\nexport interface HubChannelHarnessOptions {\n /** Sessions the hub already manages when the channel starts. */\n sessions?: readonly HubSessionScope[];\n}\n\nconst DEFAULT_SESSION: HubSessionScope = { sessionId: 's1', cwd: '/repo' };\n\n/**\n * A plugin's hub channel, started against a real host.\n *\n * The hub calls `payloadFor` once per subscriber and pushes through `publish`\n * afterwards, and a channel that only answers one of those looks correct in a\n * test that exercises the other.\n */\nexport function hubChannelHarness(channel: WebHubChannel, options: HubChannelHarnessOptions = {}): HubChannelHarness {\n const sessions = [...(options.sessions ?? [DEFAULT_SESSION])];\n const published: ChannelFrame[] = [];\n const notices: string[] = [];\n const host: HubChannelHost = {\n sessions: () => sessions,\n publish: (sessionId, payload) => {\n published.push({ type: channel.frameType, sessionId, payload });\n },\n onNotice: (message) => notices.push(message),\n };\n const source = channel.start(host);\n\n return {\n source,\n published,\n notices,\n snapshot(sessionId) {\n const scope = sessions.find((candidate) => candidate.sessionId === sessionId) ?? sessions[0] ?? DEFAULT_SESSION;\n return source.payloadFor(scope);\n },\n addSession(scope) {\n sessions.push(scope);\n source.sessionAdded?.(scope);\n },\n removeSession(sessionId) {\n const index = sessions.findIndex((candidate) => candidate.sessionId === sessionId);\n if (index >= 0) sessions.splice(index, 1);\n source.sessionRemoved?.(sessionId);\n },\n close: () => source.close(),\n };\n}\n"],"mappings":"AA8BA,SAAgB,EACd,EACA,EACA,EACiB,CACjB,IAAM,EAAkB,EAAQ,MAAM,CAAO,EAG7C,OAFI,IAAW,KAAa,CAAE,SAAU,EAAM,GAC9C,EAAQ,MAAM,EAAW,CAAM,EACxB,CAAE,SAAU,EAAK,EAC1B,CAsBA,MAAM,EAAmC,CAAE,UAAW,KAAM,IAAK,OAAQ,EASzE,SAAgB,EAAkB,EAAwB,EAAoC,CAAC,EAAsB,CACnH,IAAM,EAAW,CAAC,GAAI,EAAQ,UAAY,CAAC,CAAe,CAAE,EACtD,EAA4B,CAAC,EAC7B,EAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"channels.mjs","names":[],"sources":["../../../src/services/testing/channels.ts"],"sourcesContent":["import type {\n ChannelFrame,\n HubChannelHost,\n HubChannelSource,\n HubSessionScope,\n WebHubChannel,\n} from '../../types/webHub.ts';\nimport type { SessionChannelContribution } from '../../types/webPlugin.ts';\n\n/**\n * The two halves of a plugin's data channel, driven the way the hub drives them.\n *\n * A channel is the one place a plugin parses input it did not produce, so its\n * parse gate is the boundary that matters, and a test that calls `apply`\n * directly steps straight over it. `driveChannel` sends a wire payload the way\n * the page does: through `parse` first, and nothing applied when it is\n * rejected.\n */\n\nexport interface ChannelDelivery {\n /** Whether the parse gate accepted the payload. */\n accepted: boolean;\n}\n\n/**\n * Sends one wire payload to a session channel.\n *\n * Returns whether the gate accepted it, so a test can assert a rejection\n * without knowing what the plugin's parsed shape looks like.\n */\nexport function driveChannel(\n channel: SessionChannelContribution,\n sessionId: string,\n payload: unknown,\n): ChannelDelivery {\n const parsed: unknown = channel.parse(payload);\n if (parsed === null) return { accepted: false };\n channel.apply(sessionId, parsed);\n return { accepted: true };\n}\n\nexport interface HubChannelHarness {\n /** The running source, as the hub holds it. */\n source: HubChannelSource;\n /** Everything the source pushed, in order. */\n readonly published: readonly ChannelFrame[];\n /** What the source told the hub. */\n readonly notices: readonly string[];\n /** The subscribe-time snapshot one session would receive; undefined means no frame. */\n snapshot(sessionId?: string): unknown;\n /** Registers a session with the source, as the hub does when one appears. */\n addSession(scope: HubSessionScope): void;\n removeSession(sessionId: string): void;\n close(): void;\n}\n\nexport interface HubChannelHarnessOptions {\n /** Sessions the hub already manages when the channel starts. */\n sessions?: readonly HubSessionScope[];\n}\n\nconst DEFAULT_SESSION: HubSessionScope = { sessionId: 's1', cwd: '/repo' };\n\n/**\n * A plugin's hub channel, started against a real host.\n *\n * The hub calls `payloadFor` once per subscriber and pushes through `publish`\n * afterwards, and a channel that only answers one of those looks correct in a\n * test that exercises the other.\n */\nexport function hubChannelHarness(channel: WebHubChannel, options: HubChannelHarnessOptions = {}): HubChannelHarness {\n const sessions = [...(options.sessions ?? [DEFAULT_SESSION])];\n const published: ChannelFrame[] = [];\n const notices: string[] = [];\n const host: HubChannelHost = {\n sessions: () => sessions,\n publish: (sessionId, payload) => {\n published.push({ type: channel.frameType, sessionId, payload });\n },\n requestSessionApi: () =>\n Promise.resolve(Response.json({ error: 'No session API in the channel harness.' }, { status: 501 })),\n onNotice: (message) => notices.push(message),\n };\n const source = channel.start(host);\n\n return {\n source,\n published,\n notices,\n snapshot(sessionId) {\n const scope = sessions.find((candidate) => candidate.sessionId === sessionId) ?? sessions[0] ?? DEFAULT_SESSION;\n return source.payloadFor(scope);\n },\n addSession(scope) {\n sessions.push(scope);\n source.sessionAdded?.(scope);\n },\n removeSession(sessionId) {\n const index = sessions.findIndex((candidate) => candidate.sessionId === sessionId);\n if (index >= 0) sessions.splice(index, 1);\n source.sessionRemoved?.(sessionId);\n },\n close: () => source.close(),\n };\n}\n"],"mappings":"AA8BA,SAAgB,EACd,EACA,EACA,EACiB,CACjB,IAAM,EAAkB,EAAQ,MAAM,CAAO,EAG7C,OAFI,IAAW,KAAa,CAAE,SAAU,EAAM,GAC9C,EAAQ,MAAM,EAAW,CAAM,EACxB,CAAE,SAAU,EAAK,EAC1B,CAsBA,MAAM,EAAmC,CAAE,UAAW,KAAM,IAAK,OAAQ,EASzE,SAAgB,EAAkB,EAAwB,EAAoC,CAAC,EAAsB,CACnH,IAAM,EAAW,CAAC,GAAI,EAAQ,UAAY,CAAC,CAAe,CAAE,EACtD,EAA4B,CAAC,EAC7B,EAAoB,CAAC,EAUrB,EAAS,EAAQ,MAAM,CAR3B,aAAgB,EAChB,SAAU,EAAW,IAAY,CAC/B,EAAU,KAAK,CAAE,KAAM,EAAQ,UAAW,YAAW,SAAQ,CAAC,CAChE,EACA,sBACE,QAAQ,QAAQ,SAAS,KAAK,CAAE,MAAO,wCAAyC,EAAG,CAAE,OAAQ,GAAI,CAAC,CAAC,EACrG,SAAW,GAAY,EAAQ,KAAK,CAAO,CAEb,CAAC,EAEjC,MAAO,CACL,SACA,YACA,UACA,SAAS,EAAW,CAClB,IAAM,EAAQ,EAAS,KAAM,GAAc,EAAU,YAAc,CAAS,GAAK,EAAS,IAAM,EAChG,OAAO,EAAO,WAAW,CAAK,CAChC,EACA,WAAW,EAAO,CAChB,EAAS,KAAK,CAAK,EACnB,EAAO,eAAe,CAAK,CAC7B,EACA,cAAc,EAAW,CACvB,IAAM,EAAQ,EAAS,UAAW,GAAc,EAAU,YAAc,CAAS,EAC7E,GAAS,GAAG,EAAS,OAAO,EAAO,CAAC,EACxC,EAAO,iBAAiB,CAAS,CACnC,EACA,UAAa,EAAO,MAAM,CAC5B,CACF"}
|
|
@@ -18,7 +18,7 @@ import { ComponentType } from "react";
|
|
|
18
18
|
* Callers pass components as values, never as JSX, so a plugin package needs no
|
|
19
19
|
* JSX configuration in the project that holds its tests.
|
|
20
20
|
*/
|
|
21
|
-
interface RenderedPlugin {
|
|
21
|
+
export interface RenderedPlugin {
|
|
22
22
|
/** The markup, or an empty string when the component threw. */
|
|
23
23
|
html: string;
|
|
24
24
|
/** What the component threw, which the host would have swallowed. */
|
|
@@ -26,7 +26,6 @@ interface RenderedPlugin {
|
|
|
26
26
|
/** Whether the rendered markup contains this text, ignoring the tags around it. */
|
|
27
27
|
includes(text: string): boolean;
|
|
28
28
|
}
|
|
29
|
-
declare function renderPlugin<Props extends object>(component: ComponentType<Props>, props: Props): RenderedPlugin;
|
|
29
|
+
export declare function renderPlugin<Props extends object>(component: ComponentType<Props>, props: Props): RenderedPlugin;
|
|
30
30
|
//#endregion
|
|
31
|
-
export { RenderedPlugin, renderPlugin };
|
|
32
31
|
//# sourceMappingURL=render.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.cts","names":[],"sources":["../../../src/services/testing/render.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"render.d.cts","names":[],"sources":["../../../src/services/testing/render.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAuBiB;;EAEf;;EAEA,OAAO;;EAEP,SAAS;;wBAWK,aAAa,sBAAsB,WAAW,cAAc,QAAQ,OAAO,QAAQ"}
|
|
@@ -18,7 +18,7 @@ import { ComponentType } from "react";
|
|
|
18
18
|
* Callers pass components as values, never as JSX, so a plugin package needs no
|
|
19
19
|
* JSX configuration in the project that holds its tests.
|
|
20
20
|
*/
|
|
21
|
-
interface RenderedPlugin {
|
|
21
|
+
export interface RenderedPlugin {
|
|
22
22
|
/** The markup, or an empty string when the component threw. */
|
|
23
23
|
html: string;
|
|
24
24
|
/** What the component threw, which the host would have swallowed. */
|
|
@@ -26,7 +26,6 @@ interface RenderedPlugin {
|
|
|
26
26
|
/** Whether the rendered markup contains this text, ignoring the tags around it. */
|
|
27
27
|
includes(text: string): boolean;
|
|
28
28
|
}
|
|
29
|
-
declare function renderPlugin<Props extends object>(component: ComponentType<Props>, props: Props): RenderedPlugin;
|
|
29
|
+
export declare function renderPlugin<Props extends object>(component: ComponentType<Props>, props: Props): RenderedPlugin;
|
|
30
30
|
//#endregion
|
|
31
|
-
export { RenderedPlugin, renderPlugin };
|
|
32
31
|
//# sourceMappingURL=render.d.mts.map
|