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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapters/types.d.ts +152 -0
  3. package/dist/adapters/types.d.ts.map +1 -0
  4. package/dist/adapters/types.js +1 -0
  5. package/dist/index.d.ts +6 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +19 -0
  8. package/dist/internal.d.ts +16 -0
  9. package/dist/internal.d.ts.map +1 -0
  10. package/dist/internal.js +8 -0
  11. package/dist/mounts/channel.d.ts +20 -0
  12. package/dist/mounts/channel.d.ts.map +1 -0
  13. package/dist/mounts/channel.js +76 -0
  14. package/dist/mounts/events.d.ts +9 -0
  15. package/dist/mounts/events.d.ts.map +1 -0
  16. package/dist/mounts/events.js +45 -0
  17. package/dist/mounts/geometry.d.ts +9 -0
  18. package/dist/mounts/geometry.d.ts.map +1 -0
  19. package/dist/mounts/geometry.js +69 -0
  20. package/dist/mounts/handle.d.ts +5 -0
  21. package/dist/mounts/handle.d.ts.map +1 -0
  22. package/dist/mounts/handle.js +44 -0
  23. package/dist/mounts/iframe.d.ts +4 -0
  24. package/dist/mounts/iframe.d.ts.map +1 -0
  25. package/dist/mounts/iframe.js +143 -0
  26. package/dist/mounts/overlay.d.ts +11 -0
  27. package/dist/mounts/overlay.d.ts.map +1 -0
  28. package/dist/mounts/overlay.js +53 -0
  29. package/dist/mounts/view-snapshot.d.ts +4 -0
  30. package/dist/mounts/view-snapshot.d.ts.map +1 -0
  31. package/dist/mounts/view-snapshot.js +24 -0
  32. package/dist/persistence/key.d.ts +3 -0
  33. package/dist/persistence/key.d.ts.map +1 -0
  34. package/dist/persistence/key.js +4 -0
  35. package/dist/persistence/storage.d.ts +13 -0
  36. package/dist/persistence/storage.d.ts.map +1 -0
  37. package/dist/persistence/storage.js +37 -0
  38. package/dist/session/channels.d.ts +8 -0
  39. package/dist/session/channels.d.ts.map +1 -0
  40. package/dist/session/channels.js +117 -0
  41. package/dist/session/context.d.ts +97 -0
  42. package/dist/session/context.d.ts.map +1 -0
  43. package/dist/session/context.js +136 -0
  44. package/dist/session/controller.d.ts +5 -0
  45. package/dist/session/controller.d.ts.map +1 -0
  46. package/dist/session/controller.js +217 -0
  47. package/dist/session/debug-lease.d.ts +5 -0
  48. package/dist/session/debug-lease.d.ts.map +1 -0
  49. package/dist/session/debug-lease.js +64 -0
  50. package/dist/session/debug.d.ts +14 -0
  51. package/dist/session/debug.d.ts.map +1 -0
  52. package/dist/session/debug.js +242 -0
  53. package/dist/session/events.d.ts +7 -0
  54. package/dist/session/events.d.ts.map +1 -0
  55. package/dist/session/events.js +23 -0
  56. package/dist/session/inspection.d.ts +5 -0
  57. package/dist/session/inspection.d.ts.map +1 -0
  58. package/dist/session/inspection.js +88 -0
  59. package/dist/session/internal.d.ts +87 -0
  60. package/dist/session/internal.d.ts.map +1 -0
  61. package/dist/session/internal.js +144 -0
  62. package/dist/session/mounts.d.ts +6 -0
  63. package/dist/session/mounts.d.ts.map +1 -0
  64. package/dist/session/mounts.js +153 -0
  65. package/dist/session/notifications.d.ts +5 -0
  66. package/dist/session/notifications.d.ts.map +1 -0
  67. package/dist/session/notifications.js +143 -0
  68. package/dist/session/ownership.d.ts +20 -0
  69. package/dist/session/ownership.d.ts.map +1 -0
  70. package/dist/session/ownership.js +69 -0
  71. package/dist/session/plugin-hub.d.ts +59 -0
  72. package/dist/session/plugin-hub.d.ts.map +1 -0
  73. package/dist/session/plugin-hub.js +215 -0
  74. package/dist/session/plugins.d.ts +8 -0
  75. package/dist/session/plugins.d.ts.map +1 -0
  76. package/dist/session/plugins.js +78 -0
  77. package/dist/session/request.d.ts +8 -0
  78. package/dist/session/request.d.ts.map +1 -0
  79. package/dist/session/request.js +99 -0
  80. package/dist/session/runtime.d.ts +5 -0
  81. package/dist/session/runtime.d.ts.map +1 -0
  82. package/dist/session/runtime.js +25 -0
  83. package/dist/session/selection.d.ts +9 -0
  84. package/dist/session/selection.d.ts.map +1 -0
  85. package/dist/session/selection.js +111 -0
  86. package/dist/session/services.d.ts +18 -0
  87. package/dist/session/services.d.ts.map +1 -0
  88. package/dist/session/services.js +51 -0
  89. package/dist/session/settings.d.ts +7 -0
  90. package/dist/session/settings.d.ts.map +1 -0
  91. package/dist/session/settings.js +31 -0
  92. package/dist/session/snapshot.d.ts +12 -0
  93. package/dist/session/snapshot.d.ts.map +1 -0
  94. package/dist/session/snapshot.js +72 -0
  95. package/dist/session/state.d.ts +11 -0
  96. package/dist/session/state.d.ts.map +1 -0
  97. package/dist/session/state.js +73 -0
  98. package/dist/session/variant.d.ts +4 -0
  99. package/dist/session/variant.d.ts.map +1 -0
  100. package/dist/session/variant.js +11 -0
  101. package/dist/transport/authority.d.ts +35 -0
  102. package/dist/transport/authority.d.ts.map +1 -0
  103. package/dist/transport/authority.js +110 -0
  104. package/dist/transport/connection.d.ts +4 -0
  105. package/dist/transport/connection.d.ts.map +1 -0
  106. package/dist/transport/connection.js +37 -0
  107. package/dist/transport/handshake.d.ts +36 -0
  108. package/dist/transport/handshake.d.ts.map +1 -0
  109. package/dist/transport/handshake.js +112 -0
  110. package/dist/transport/inbound.d.ts +15 -0
  111. package/dist/transport/inbound.d.ts.map +1 -0
  112. package/dist/transport/inbound.js +51 -0
  113. package/dist/transport/port.d.ts +51 -0
  114. package/dist/transport/port.d.ts.map +1 -0
  115. package/dist/transport/port.js +288 -0
  116. package/dist/transport/reply.d.ts +6 -0
  117. package/dist/transport/reply.d.ts.map +1 -0
  118. package/dist/transport/reply.js +44 -0
  119. package/dist/transport/requests.d.ts +33 -0
  120. package/dist/transport/requests.d.ts.map +1 -0
  121. package/dist/transport/requests.js +62 -0
  122. package/dist/transport/session-commands.d.ts +5 -0
  123. package/dist/transport/session-commands.d.ts.map +1 -0
  124. package/dist/transport/session-commands.js +70 -0
  125. package/dist/transport/validated.d.ts +13 -0
  126. package/dist/transport/validated.d.ts.map +1 -0
  127. package/dist/transport/validated.js +22 -0
  128. package/dist/transport/validation.d.ts +8 -0
  129. package/dist/transport/validation.d.ts.map +1 -0
  130. package/dist/transport/validation.js +20 -0
  131. package/dist/types.d.ts +143 -0
  132. package/dist/types.d.ts.map +1 -0
  133. package/dist/types.js +1 -0
  134. package/package.json +38 -3
  135. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Guillaume Chau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,152 @@
1
+ import type { HistoireEmbedPresentation, HistoireEvent, HistoireHostChannelMessage, HistoirePluginChannelEvent, HistoireRuntimeSnapshot, HistoireSettings, HistoireSourceDescriptor, HistoireStateSnapshot, HistoireSurface, HistoireTarget, HistoireViewport } from '@histoire/protocol';
2
+ import type { HistoireMountChannel } from '../mounts/channel.js';
3
+ import type { HistoireSession } from '../types.js';
4
+ /** Captured ownership supplied to every first-party transport operation. */
5
+ export interface HistoireRequestCapture {
6
+ /** Allocated bridge request identity when crossing into a runtime. */
7
+ requestId?: string;
8
+ /** Owning browser session. */
9
+ sessionId: string;
10
+ /** Connected data bridge lifetime. */
11
+ connectionId: string;
12
+ /** Stable book identity. */
13
+ sourceId: string;
14
+ /** Source generation. */
15
+ epoch: string;
16
+ /** Completed catalog/content revision. */
17
+ revision: string;
18
+ /** Surface attachment, absent for data operations. */
19
+ mountId?: string;
20
+ /** Story runtime document, absent for data operations. */
21
+ runtimeId?: string;
22
+ /** Exact operation target when applicable. */
23
+ target?: HistoireTarget;
24
+ /** Parent-owned selection generation for first-party surface intents. */
25
+ selectionVersion?: number;
26
+ /** Controller-owned cancellation, including caller cancellation. */
27
+ signal: AbortSignal;
28
+ }
29
+ /** Finite requests supported by injected source/runtime adapters. */
30
+ export type HistoireSessionCommand = 'catalog.search' | 'selection.select' | 'state.get' | 'state.patch' | 'state.reset' | 'controls.preset' | 'settings.update' | 'events.clear' | 'docs.get' | 'source.get' | 'tests.collect' | 'tests.run' | 'openInEditor' | 'channel.post' | 'plugin.post' | 'inspection.variant' | 'inspection.dom' | 'inspection.highlight' | 'inspection.debug' | 'inspection.components' | 'inspection.component' | 'inspection.componentForElement' | 'inspection.accessibility' | 'inspection.pick' | 'inspection.highlightLease' | 'inspection.highlightClear';
31
+ /** Validated adapter notification ownership; SDK still checks current lifetime. */
32
+ export interface HistoireNotificationOwner {
33
+ /** Connected data bridge lifetime. */
34
+ connectionId: string;
35
+ /** Stable book identity. */
36
+ sourceId: string;
37
+ /** Source generation. */
38
+ epoch: string;
39
+ /** Completed source revision. */
40
+ revision: string;
41
+ /** Originating surface when present. */
42
+ mountId?: string;
43
+ /** Runtime document when present. */
44
+ runtimeId?: string;
45
+ }
46
+ /** Narrow notifications after transport schema/origin/port validation. */
47
+ export type HistoireSessionNotification = HistoireNotificationOwner & ({
48
+ type: 'catalog';
49
+ descriptor: HistoireSourceDescriptor;
50
+ } | {
51
+ type: 'disconnect';
52
+ } | {
53
+ type: 'runtime';
54
+ runtime: HistoireRuntimeSnapshot;
55
+ } | {
56
+ type: 'layout';
57
+ viewports: readonly HistoireViewport[];
58
+ } | {
59
+ type: 'state';
60
+ state: HistoireStateSnapshot;
61
+ } | {
62
+ type: 'event';
63
+ event: HistoireEvent;
64
+ } | {
65
+ type: 'channel';
66
+ message: HistoireHostChannelMessage;
67
+ } | {
68
+ type: 'plugin';
69
+ message: HistoirePluginChannelEvent;
70
+ } | {
71
+ type: 'dropped';
72
+ count: number;
73
+ stale?: boolean;
74
+ });
75
+ /** Shared request/subscription/cleanup lifecycle for first-party transports. */
76
+ export interface HistoireTransport {
77
+ /** Negotiated port lifetime, distinct for data bridge and every surface. */
78
+ id: string;
79
+ /** Perform one correlated request; never retry execution automatically. */
80
+ request: <T = unknown>(command: HistoireSessionCommand, payload: unknown, capture: HistoireRequestCapture) => Promise<T>;
81
+ /** Observe validated notifications, returning complete listener cleanup. */
82
+ subscribe: (listener: (notification: HistoireSessionNotification) => void) => () => void;
83
+ /** Complete owned transport teardown; observe abandoned request work. */
84
+ close: () => Promise<void> | void;
85
+ }
86
+ /** Data-only connection; source adapter never executes stories implicitly. */
87
+ export interface HistoireSourceConnection extends HistoireTransport {
88
+ /** Unique connected bridge lifetime. */
89
+ id: string;
90
+ /** Completed source metadata obtained during explicit handshake. */
91
+ descriptor: HistoireSourceDescriptor;
92
+ /** Optional portable source preference defaults. */
93
+ initialSettings?: Partial<HistoireSettings>;
94
+ }
95
+ /** Surface transport owns its elements/ports, never caller session. */
96
+ export interface HistoireSurfaceConnection extends HistoireTransport {
97
+ /** Finite first-party controls UI relay, absent on data/primary transports. */
98
+ channel?: HistoireMountChannel;
99
+ /** View readiness; primary surfaces return actual runtime identity. */
100
+ ready: Promise<HistoireRuntimeSnapshot | void>;
101
+ }
102
+ /** Explicit source connection input; safe to construct without browser globals. */
103
+ export interface HistoireConnectContext {
104
+ /** Normalized source base URL. */
105
+ url: string;
106
+ /** Owning session identity. */
107
+ sessionId: string;
108
+ /** Cancellation during connection or disposal. */
109
+ signal: AbortSignal;
110
+ }
111
+ /** Synchronously captured mount input before any element creation. */
112
+ export interface HistoireMountContext {
113
+ /** Local parent controller for validated view intents/subscriptions; never wire data. */
114
+ session: HistoireSession;
115
+ /** Owning session. */
116
+ sessionId: string;
117
+ /** Unique attachment. */
118
+ mountId: string;
119
+ /** Requested first-party view. */
120
+ surface: HistoireSurface;
121
+ /** Optional scoped explorer composition, never additional authority. */
122
+ presentation?: HistoireEmbedPresentation;
123
+ /** Validated variant gutter override in CSS pixels. */
124
+ padding?: number;
125
+ /** Explicit hidden primary request. */
126
+ hidden: boolean;
127
+ /** Caller-owned container; absent for adapter-owned hidden container. */
128
+ container?: HTMLElement;
129
+ /** Connected data source. */
130
+ source: HistoireSourceConnection;
131
+ /** Captured selected target. */
132
+ target: HistoireTarget | null;
133
+ /** Current host preferences. */
134
+ settings: HistoireSettings;
135
+ }
136
+ /** Optional storage injection avoids browser assumptions in controller tests. */
137
+ export interface HistoirePreferenceStorage {
138
+ /** Read saved JSON or null. */
139
+ getItem: (key: string) => string | null;
140
+ /** Persist validated settings only. */
141
+ setItem: (key: string, value: string) => void;
142
+ }
143
+ /** Unsupported public loader seam, reserved for first-party adapters. */
144
+ export interface HistoireSessionAdapters {
145
+ /** Connect metadata/content without importing story modules in host. */
146
+ connect: (context: HistoireConnectContext) => Promise<HistoireSourceConnection>;
147
+ /** Create one surface after controller synchronously reserves ownership. */
148
+ mount?: (context: HistoireMountContext) => HistoireSurfaceConnection;
149
+ /** Optional lazily evaluated preference storage provider. */
150
+ storage?: () => HistoirePreferenceStorage | undefined;
151
+ }
152
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EACb,0BAA0B,EAC1B,0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;IACvC,MAAM,EAAE,OAAO,CAAA;IACf,yEAAyE;IACzE,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,6BAA6B;IAC7B,MAAM,EAAE,wBAAwB,CAAA;IAChC,gCAAgC;IAChC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;IAC7B,gCAAgC;IAChC,QAAQ,EAAE,gBAAgB,CAAA;CAC3B;AAED,iFAAiF;AACjF,MAAM,WAAW,yBAAyB;IACxC,+BAA+B;IAC/B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;IACvC,uCAAuC;IACvC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9C;AAED,yEAAyE;AACzE,MAAM,WAAW,uBAAuB;IACtC,wEAAwE;IACxE,OAAO,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAA;IAC/E,4EAA4E;IAC5E,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,yBAAyB,CAAA;IACpE,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,yBAAyB,GAAG,SAAS,CAAA;CACtD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { HistoireSession, HistoireSessionOptions } from './types.js';
2
+ export type * from './types.js';
3
+ export { HistoireSdkError } from '@histoire/protocol';
4
+ /** Construct without browser effects; connection and mounting stay explicit. */
5
+ export declare function createHistoireSession(options: HistoireSessionOptions): HistoireSession;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAKzE,mBAAmB,YAAY,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CAatF"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import { mountRemoteSurface } from './mounts/iframe.js';
2
+ import { createHistoireSessionWithAdapters } from './session/controller.js';
3
+ import { connectRemoteSource } from './transport/connection.js';
4
+ export { HistoireSdkError } from '@histoire/protocol';
5
+ /** Construct without browser effects; connection and mounting stay explicit. */
6
+ export function createHistoireSession(options) {
7
+ return createHistoireSessionWithAdapters(options, {
8
+ connect: connectRemoteSource,
9
+ mount: mountRemoteSurface,
10
+ storage: () => {
11
+ try {
12
+ return window.localStorage;
13
+ }
14
+ catch {
15
+ return undefined;
16
+ }
17
+ },
18
+ });
19
+ }
@@ -0,0 +1,16 @@
1
+ export type * from './adapters/types.js';
2
+ export { bindHistoireMountChannel, configureHistoireMountControls, postHistoireMountEvent, subscribeHistoireMountEvents } from './mounts/channel.js';
3
+ export type { HistoireMountChannel } from './mounts/channel.js';
4
+ export { createHistoireSessionWithAdapters } from './session/controller.js';
5
+ export { canOpenHistoireTargetInEditor, delegateHistoireStoryLinks, getAcceptedHistoireSessionDescriptor, getHistoireDocsPolicy, getHistoireSessionDescriptor, isAcceptedHistoireSourceDescriptor, isHistoirePrimaryMountActive, registerHistoireSessionInternals, requestHistoireOpenInEditor, requestHistoireStatePreset, selectHistoireStoryLink, waitForHistoireSelection } from './session/internal.js';
6
+ export type { HistoirePresetAction, HistoirePresetList, HistoireStoryLink } from './session/internal.js';
7
+ export { OperationOwner } from './session/ownership.js';
8
+ export { createPluginChannelHub } from './session/plugin-hub.js';
9
+ export type { HistoirePluginHubActor, PluginChannelHub, PluginChannelHubOptions } from './session/plugin-hub.js';
10
+ export { createBridgePort } from './transport/port.js';
11
+ export type { BridgePortOptions, HistoireBridgePort } from './transport/port.js';
12
+ export { dispatchHistoireSessionCommand } from './transport/session-commands.js';
13
+ export { getBridgeSurfaceRole } from './transport/validation.js';
14
+ /** First-party-only adapter contracts; external story loaders are unsupported. */
15
+ export type * from './types.js';
16
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,mBAAmB,qBAAqB,CAAA;AACxC,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AACpJ,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAA;AAC3E,OAAO,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,oCAAoC,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAC5Y,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACxG,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,kFAAkF;AAClF,mBAAmB,YAAY,CAAA"}
@@ -0,0 +1,8 @@
1
+ export { bindHistoireMountChannel, configureHistoireMountControls, postHistoireMountEvent, subscribeHistoireMountEvents } from './mounts/channel.js';
2
+ export { createHistoireSessionWithAdapters } from './session/controller.js';
3
+ export { canOpenHistoireTargetInEditor, delegateHistoireStoryLinks, getAcceptedHistoireSessionDescriptor, getHistoireDocsPolicy, getHistoireSessionDescriptor, isAcceptedHistoireSourceDescriptor, isHistoirePrimaryMountActive, registerHistoireSessionInternals, requestHistoireOpenInEditor, requestHistoireStatePreset, selectHistoireStoryLink, waitForHistoireSelection } from './session/internal.js';
4
+ export { OperationOwner } from './session/ownership.js';
5
+ export { createPluginChannelHub } from './session/plugin-hub.js';
6
+ export { createBridgePort } from './transport/port.js';
7
+ export { dispatchHistoireSessionCommand } from './transport/session-commands.js';
8
+ export { getBridgeSurfaceRole } from './transport/validation.js';
@@ -0,0 +1,20 @@
1
+ import type { HistoireBridgePublication } from '@histoire/protocol';
2
+ import type { HistoireMount, HistoireSession } from '../types.js';
3
+ /** First-party controls publications; finite payload validators remain protocol-owned. */
4
+ export interface HistoireMountChannel {
5
+ /** Configure native custom-only presentation before first view synchronization. */
6
+ configure?: (customOnly: boolean) => void;
7
+ /** Observe validated port publications scoped to one mounted surface. */
8
+ subscribe: (listener: (event: HistoireBridgePublication) => void) => () => void;
9
+ /** Reply to current controls overlay; arbitrary commands/events are not exposed. */
10
+ post: (event: 'overlay.result', payload: unknown) => void;
11
+ }
12
+ /** Bind one mount channel; canonical runtime remains sole authority for replica traffic. */
13
+ export declare function bindHistoireMountChannel(mount: HistoireMount, session: HistoireSession, channel?: HistoireMountChannel): () => void;
14
+ /** Subscribe before mount.ready so initial replica availability cannot be lost. */
15
+ export declare function subscribeHistoireMountEvents(mount: HistoireMount, listener: (event: HistoireBridgePublication) => void): () => void;
16
+ /** Resolve opaque option identity only on its owning current surface port. */
17
+ export declare function postHistoireMountEvent(mount: HistoireMount, event: 'overlay.result', payload: unknown): void;
18
+ /** Native custom frame omits generic editors rendered locally by owning provider. */
19
+ export declare function configureHistoireMountControls(mount: HistoireMount, customOnly: boolean): void;
20
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/mounts/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,0FAA0F;AAC1F,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAA;IACzC,yEAAyE;IACzE,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;IAC/E,oFAAoF;IACpF,IAAI,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAC1D;AAcD,4FAA4F;AAC5F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,MAAM,IAAI,CAgDnI;AACD,mFAAmF;AACnF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,GAAG,MAAM,IAAI,CAMnI;AACD,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAI5G;AACD,qFAAqF;AACrF,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAE9F"}
@@ -0,0 +1,76 @@
1
+ const bindings = new WeakMap();
2
+ const bindingKey = Symbol.for('@histoire/sdk/mount-channel/protocol-1');
3
+ /** Split native/SDK bundles share only already validated finite mount channel binding. */
4
+ function binding(mount) {
5
+ return bindings.get(mount) ?? mount[bindingKey];
6
+ }
7
+ const events = new Set(['overlay.open', 'overlay.update', 'overlay.close', 'controls.height', 'focus.changed']);
8
+ /** Bind one mount channel; canonical runtime remains sole authority for replica traffic. */
9
+ export function bindHistoireMountChannel(mount, session, channel) {
10
+ if (!channel) {
11
+ return () => {
12
+ };
13
+ }
14
+ let active = true;
15
+ const listeners = new Set();
16
+ /** Scope check also rejects same-target reloads, publication changes and detached primary. */
17
+ function current(event) {
18
+ const snapshot = session.getSnapshot();
19
+ return active && snapshot.status === 'ready' && snapshot.runtime.status === 'ready' && !!snapshot.runtime.runtimeId
20
+ && (!event || (event.mountId === mount.id && event.sourceId === snapshot.source?.sourceId
21
+ && event.epoch === snapshot.source.epoch && event.revision === snapshot.source.revision
22
+ && event.runtimeId === snapshot.runtime.runtimeId && event.target?.storyId === snapshot.selection?.storyId
23
+ && event.target?.variantId === snapshot.selection?.variantId));
24
+ }
25
+ const off = channel.subscribe((event) => {
26
+ if (!events.has(event.event) || !current(event)) {
27
+ return;
28
+ }
29
+ for (const listener of [...listeners]) {
30
+ try {
31
+ listener(event);
32
+ }
33
+ catch {
34
+ // UI observer failure cannot interrupt owned port lifecycle.
35
+ }
36
+ }
37
+ });
38
+ bindings.set(mount, { listeners, post(event, payload) {
39
+ if (current()) {
40
+ channel.post(event, payload);
41
+ }
42
+ }, configure(customOnly) {
43
+ if (active) {
44
+ channel.configure?.(customOnly);
45
+ }
46
+ } });
47
+ if (!Object.hasOwn(mount, bindingKey))
48
+ Object.defineProperty(mount, bindingKey, { get: () => bindings.get(mount), enumerable: false });
49
+ return () => {
50
+ if (!active) {
51
+ return;
52
+ }
53
+ active = false;
54
+ bindings.delete(mount);
55
+ listeners.clear();
56
+ off();
57
+ };
58
+ }
59
+ /** Subscribe before mount.ready so initial replica availability cannot be lost. */
60
+ export function subscribeHistoireMountEvents(mount, listener) {
61
+ const entry = binding(mount);
62
+ entry?.listeners.add(listener);
63
+ return () => {
64
+ entry?.listeners.delete(listener);
65
+ };
66
+ }
67
+ /** Resolve opaque option identity only on its owning current surface port. */
68
+ export function postHistoireMountEvent(mount, event, payload) {
69
+ if (event === 'overlay.result') {
70
+ binding(mount)?.post(event, payload);
71
+ }
72
+ }
73
+ /** Native custom frame omits generic editors rendered locally by owning provider. */
74
+ export function configureHistoireMountControls(mount, customOnly) {
75
+ binding(mount)?.configure(customOnly);
76
+ }
@@ -0,0 +1,9 @@
1
+ import type { HistoireBridgeIdentity, HistoireEvent } from '@histoire/protocol';
2
+ import type { HistoireSession } from '../types.js';
3
+ /** Bounded retained/future replay, kept separate from 8 MiB view snapshot projection. */
4
+ export declare function createMountEventStream(session: HistoireSession, publish: (payload: {
5
+ items: readonly HistoireEvent[];
6
+ reset?: boolean;
7
+ droppedCount?: number;
8
+ }, owner: Partial<HistoireBridgeIdentity>) => void): () => void;
9
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/mounts/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAGlD,yFAAyF;AACzF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,KAAK,IAAI,cAoC/M"}
@@ -0,0 +1,45 @@
1
+ import { validateWireValue } from '@histoire/protocol';
2
+ /** Bounded retained/future replay, kept separate from 8 MiB view snapshot projection. */
3
+ export function createMountEventStream(session, publish) {
4
+ let previous;
5
+ let previousDropped = 0;
6
+ let identity = '';
7
+ /** Parent history is canonical; clear and document/selection replacement publish explicit reset. */
8
+ function synchronize() {
9
+ const snapshot = session.getSnapshot();
10
+ const current = JSON.stringify([snapshot.source?.epoch, snapshot.runtime.runtimeId, snapshot.selection]);
11
+ const owner = { ...(snapshot.runtime.runtimeId ? { runtimeId: snapshot.runtime.runtimeId } : {}), ...(snapshot.selection ? { target: snapshot.selection } : {}) };
12
+ const items = snapshot.events.items;
13
+ const reset = !previous || identity !== current || (previous.length > 0 && items.length === 0) || snapshot.events.droppedCount < previousDropped;
14
+ if (reset)
15
+ publish({ items: [], reset: true, ...(snapshot.events.droppedCount ? { droppedCount: snapshot.events.droppedCount } : {}) }, owner);
16
+ else if (snapshot.events.droppedCount > previousDropped)
17
+ publish({ items: [], droppedCount: snapshot.events.droppedCount - previousDropped }, owner);
18
+ const last = identity === current ? previous?.at(-1)?.sequence ?? -1 : -1;
19
+ const pending = items.filter(event => event.sequence > last);
20
+ let batch = [];
21
+ /** Flush respects publication byte budget as well as small batch count. */
22
+ const flush = () => {
23
+ if (batch.length)
24
+ publish({ items: batch }, owner);
25
+ batch = [];
26
+ };
27
+ for (const event of pending) {
28
+ try {
29
+ validateWireValue({ items: [...batch, event] }, { kind: 'event', name: 'events.appended' });
30
+ }
31
+ catch {
32
+ flush();
33
+ }
34
+ batch.push(event);
35
+ if (batch.length >= 32)
36
+ flush();
37
+ }
38
+ flush();
39
+ previous = items;
40
+ previousDropped = snapshot.events.droppedCount;
41
+ identity = current;
42
+ }
43
+ synchronize();
44
+ return session.subscribe(synchronize);
45
+ }
@@ -0,0 +1,9 @@
1
+ import type { HistoireSessionNotification } from '../adapters/types.js';
2
+ /** Map validated source-local layout into mount padding box and all host scroll clips. */
3
+ export declare function createMountGeometry(iframe: HTMLIFrameElement, container: HTMLElement, publish: (notification: HistoireSessionNotification) => void): {
4
+ /** Runtime change clears cache; late host scroll cannot publish predecessor positions. */
5
+ receive(notification: HistoireSessionNotification): HistoireSessionNotification;
6
+ /** Remove observers/listeners before mount ownership release. */
7
+ close(): void;
8
+ };
9
+ //# sourceMappingURL=geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/mounts/geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAGvE,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,2BAA2B,KAAK,IAAI;IAuC/I,0FAA0F;IAC1F,OAAO,eAAe,2BAA2B,GAAG,2BAA2B;IAY/E,iEAAiE;IACjE,KAAK;EASR"}
@@ -0,0 +1,69 @@
1
+ import { intersectRuntimeRects, mapRuntimeViewport } from '@histoire/protocol';
2
+ /** Map validated source-local layout into mount padding box and all host scroll clips. */
3
+ export function createMountGeometry(iframe, container, publish) {
4
+ let last;
5
+ let active = true;
6
+ let scheduled = 0;
7
+ const window = container.ownerDocument.defaultView;
8
+ /** Geometry never queries child DOM; cross-origin surface has same behavior. */
9
+ function project(value) {
10
+ const frame = iframe.getBoundingClientRect();
11
+ const mount = container.getBoundingClientRect();
12
+ const offset = { x: mount.x + container.clientLeft * (container.offsetWidth ? mount.width / container.offsetWidth : 1), y: mount.y + container.clientTop * (container.offsetHeight ? mount.height / container.offsetHeight : 1) };
13
+ let clip = intersectRuntimeRects(frame, { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight });
14
+ for (let parent = container; parent && clip; parent = parent.parentElement) {
15
+ const style = window.getComputedStyle(parent);
16
+ const x = /auto|scroll|hidden|clip/.test(style.overflowX);
17
+ const y = /auto|scroll|hidden|clip/.test(style.overflowY);
18
+ if (x || y) {
19
+ const rect = parent.getBoundingClientRect();
20
+ const scaleX = parent.offsetWidth ? rect.width / parent.offsetWidth : 1;
21
+ const scaleY = parent.offsetHeight ? rect.height / parent.offsetHeight : 1;
22
+ clip = intersectRuntimeRects(clip, { x: x ? rect.x + parent.clientLeft * scaleX : clip.x, y: y ? rect.y + parent.clientTop * scaleY : clip.y, width: x ? parent.clientWidth * scaleX : clip.width, height: y ? parent.clientHeight * scaleY : clip.height });
23
+ }
24
+ }
25
+ const viewports = clip && iframe.clientWidth && iframe.clientHeight ? value.viewports.map(viewport => mapRuntimeViewport(viewport, { x: frame.x - offset.x, y: frame.y - offset.y, width: frame.width, height: frame.height }, { width: iframe.clientWidth, height: iframe.clientHeight }, { ...clip, x: clip.x - offset.x, y: clip.y - offset.y })).filter((value) => value !== null) : [];
26
+ return { ...value, viewports };
27
+ }
28
+ /** Coalesced host scrolling/resize refresh retained source geometry under same captured owner. */
29
+ function refresh() {
30
+ if (!active || scheduled || !last)
31
+ return;
32
+ scheduled = window.requestAnimationFrame(() => {
33
+ scheduled = 0;
34
+ if (active && last)
35
+ publish(project(last));
36
+ });
37
+ }
38
+ const resize = new ResizeObserver(refresh);
39
+ resize.observe(container);
40
+ resize.observe(iframe);
41
+ window.addEventListener('resize', refresh);
42
+ container.ownerDocument.addEventListener('scroll', refresh, true);
43
+ return {
44
+ /** Runtime change clears cache; late host scroll cannot publish predecessor positions. */
45
+ receive(notification) {
46
+ if (notification.type === 'runtime') {
47
+ last = notification.runtime.status === 'ready' ? { ...notification, type: 'layout', viewports: notification.runtime.viewports } : undefined;
48
+ if (!last)
49
+ return notification;
50
+ const viewports = project(last).viewports;
51
+ const viewport = viewports.find(viewport => viewport.target.storyId === notification.runtime.viewport?.target.storyId && viewport.target.variantId === notification.runtime.viewport.target.variantId) ?? null;
52
+ return { ...notification, runtime: { ...notification.runtime, viewports, viewport } };
53
+ }
54
+ if (notification.type !== 'layout')
55
+ return notification;
56
+ last = notification;
57
+ return project(notification);
58
+ },
59
+ /** Remove observers/listeners before mount ownership release. */
60
+ close() {
61
+ active = false;
62
+ last = undefined;
63
+ window.cancelAnimationFrame(scheduled);
64
+ resize.disconnect();
65
+ window.removeEventListener('resize', refresh);
66
+ container.ownerDocument.removeEventListener('scroll', refresh, true);
67
+ },
68
+ };
69
+ }
@@ -0,0 +1,5 @@
1
+ import type { HistoireRuntimeSnapshot } from '@histoire/protocol';
2
+ import type { HistoireBridgePort } from '../transport/port.js';
3
+ /** Await actual document readiness with complete timer/observer/cancellation cleanup. */
4
+ export declare function waitBridgeRuntime(bridge: HistoireBridgePort, signal: AbortSignal, timeout: number): Promise<HistoireRuntimeSnapshot>;
5
+ //# sourceMappingURL=handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../src/mounts/handle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAyCpI"}
@@ -0,0 +1,44 @@
1
+ import { HistoireSdkError } from '@histoire/protocol';
2
+ /** Await actual document readiness with complete timer/observer/cancellation cleanup. */
3
+ export function waitBridgeRuntime(bridge, signal, timeout) {
4
+ const promise = new Promise((resolve, reject) => {
5
+ let timer;
6
+ let off = () => {
7
+ };
8
+ /** Release every waiter before settling or aborting. */
9
+ function cleanup() {
10
+ clearTimeout(timer);
11
+ off();
12
+ signal.removeEventListener('abort', abort);
13
+ }
14
+ /** Unmount and disposal cancel before any late runtime publication. */
15
+ function abort() {
16
+ cleanup();
17
+ reject(new HistoireSdkError('RUNTIME_CHANGED', 'Surface detached'));
18
+ }
19
+ off = bridge.subscribe((value) => {
20
+ if (value.type !== 'runtime') {
21
+ return;
22
+ }
23
+ if (value.runtime.status === 'ready') {
24
+ cleanup();
25
+ resolve(value.runtime);
26
+ }
27
+ else if (value.runtime.status === 'failed' || value.runtime.status === 'stale') {
28
+ cleanup();
29
+ reject(new HistoireSdkError('PREVIEW_NOT_READY', 'Runtime unavailable'));
30
+ }
31
+ });
32
+ timer = setTimeout(() => {
33
+ cleanup();
34
+ reject(new HistoireSdkError('TIMEOUT', 'Runtime readiness timed out'));
35
+ }, timeout);
36
+ signal.addEventListener('abort', abort, { once: true });
37
+ if (signal.aborted) {
38
+ abort();
39
+ }
40
+ });
41
+ void promise.catch(() => {
42
+ });
43
+ return promise;
44
+ }
@@ -0,0 +1,4 @@
1
+ import type { HistoireMountContext, HistoireSurfaceConnection } from '../adapters/types.js';
2
+ /** Own iframe and optional hidden container; caller session always stays local. */
3
+ export declare function mountRemoteSurface(context: HistoireMountContext): HistoireSurfaceConnection;
4
+ //# sourceMappingURL=iframe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../../src/mounts/iframe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAW3F,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,yBAAyB,CA6H3F"}