electron-cast 0.1.1 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ - **Changed default: pages now run Google's own Cast SDK.** `installCastBridge` installs a stand-in Presentation API
6
+ (`mode: "presentation"`, the new default) instead of electron-cast's `chrome.cast`, so Google's `cast_sender.js` and
7
+ `cast.framework` load and run unmodified. The main process answers it with a translator for the message format
8
+ Chrome's Media Router uses with that SDK. `createCastManager` serves it by default (`presentation: false` turns it
9
+ off) and now needs `ipcMain.on` and `ipcMain.removeListener`, which Electron's `ipcMain` has.
10
+ - A cast must now start from a user gesture, as in Chrome.
11
+ - The previous behaviour is still available with `mode: "chromecast"` in `installCastBridge`.
12
+
13
+ ## 0.2.0
14
+
15
+ - `chrome.cast.media` in the polyfill: `loadMedia`, `queueLoad`, playback commands (play, pause, seek, stop, volume,
16
+ tracks), queue operations, media status updates, and media listeners, over the existing bridge.
17
+ - Google Cast Application Framework compatibility in the polyfill: `Media.getEstimatedBreakTime`,
18
+ `getEstimatedBreakClipTime` and `getEstimatedLiveSeekableRange`; `ReceiverAction.STOP` reaching receiver action
19
+ listeners before the session ends when the user stops casting from the picker; a session is announced to a
20
+ `sessionListener` function only once, across repeated `initialize` calls and `requestSessionById`; ended sessions
21
+ leave the session map (later events for them are ignored); a LOAD waits through interim LOADING statuses; and
22
+ `MEDIA_STATUS` entries no longer reset `volume` when absent, and clear `breakStatus` and `liveSeekableRange` when
23
+ dropped.
24
+ - The polyfill blocks Google's `cast_sender.js` loader scripts (gstatic clank and the Cast extensions) before they
25
+ can overwrite it with a Presentation-API implementation that finds no devices in Electron.
26
+
3
27
  ## 0.1.1
4
28
 
5
29
  - `electron-cast/main` re-exports `CastRequestInfo`, `DeviceChoice` and `CastDevice`, so a `selectDevice` picker can be
package/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # electron-cast
2
2
 
3
- Chromecast for Electron. Web pages that use the Google Cast sender API (`chrome.cast`) get a working
4
- implementation, and your main process handles device discovery and the Cast v2 protocol. No native modules, no
3
+ Chromecast for Electron. Web pages that use Google's Cast SDK (`chrome.cast`, `cast.framework`) can cast, running
4
+ Google's own SDK, while your main process handles device discovery and the Cast v2 protocol. No native modules, no
5
5
  runtime dependencies, and it works with `sandbox: true` and `contextIsolation: true`.
6
6
 
7
- Electron has no Presentation API or Media Router, and electron/electron#869 was closed in 2025 with no plans to add
8
- one. This library fills that gap: a page's own cast button (YouTube Music's, for example) works unchanged.
7
+ Electron has the Presentation API but no Media Router behind it, and electron/electron#869 was closed in 2025 with no
8
+ plans to add one. This library fills that gap: a page's own cast button (YouTube Music's, for example) works
9
+ unchanged.
9
10
 
10
11
  ## Install
11
12
 
@@ -54,22 +55,56 @@ Import from `electron-cast/preload`, not the package root: the root also exports
54
55
  Node's `tls` and `dgram` and cannot load in a sandboxed preload. The preload entry has no imports of its own, so a
55
56
  bundler can inline it.
56
57
 
57
- That's all. The page sees `chrome.cast.isAvailable === true` before its scripts run, and its cast button drives
58
- sessions through IPC to the main process.
58
+ That's all. The page loads Google's Cast SDK as usual, and its cast button drives sessions through IPC to the main
59
+ process.
60
+
61
+ ### How the page gets its Cast SDK
62
+
63
+ Electron has the Presentation API (`navigator.presentation`, `PresentationRequest`) but nothing behind it, so in
64
+ Electron Google's Cast SDK finds no devices. By default electron-cast fills in that missing piece: the page gets a
65
+ stand-in Presentation API backed by the main process, and **Google's own `cast_sender.js` and `cast.framework` load
66
+ and run unmodified**, as they do in Chrome. electron-cast never replaces Google's SDK.
67
+
68
+ A cast has to start from a user gesture (a click on the page's cast button), as in Chrome. Current limits:
69
+
70
+ - A session doesn't survive a page reload, so auto-join after a reload starts a new session.
71
+ - Google's SDK running inside an iframe gets no events, because messages go to the main frame.
72
+
73
+ **Fallback: `mode: "chromecast"`.** This installs electron-cast's own implementation of `chrome.cast` and
74
+ `chrome.cast.media` and blocks Google's loader scripts. Use it for pages that call `chrome.cast` without loading
75
+ Google's script, or if Google's script ever stops working on the stand-in:
76
+
77
+ ```ts
78
+ installCastBridge({ contextBridge, ipcRenderer, mode: "chromecast" });
79
+ ```
80
+
81
+ The main process serves both modes. `createCastManager({ ..., presentation: false })` serves only `"chromecast"`.
59
82
 
60
83
  ## What works
61
84
 
62
85
  - Device discovery over mDNS on every network interface, with devices coming and going live.
63
- - `chrome.cast.initialize`, `requestSession`, `session.stop`, `session.leave`, receiver availability, volume and
64
- mute, and messages on custom namespaces (`sendMessage` and `addMessageListener`). That is all YouTube
65
- Music's cast button needs, and it works end to end.
66
- - Several pages or windows at once; a page that reloads or closes leaves its sessions without stopping playback.
86
+ - Several pages or windows at once. A page that reloads or closes leaves its sessions without stopping playback.
67
87
 
68
- Not yet: `chrome.cast.media` (`loadMedia` fails with `session_error`), and the newer `cast.framework` API. Pages
69
- that load media through the Default Media Receiver need those.
88
+ **Default mode (Google's SDK):**
70
89
 
71
- Casting is tested end to end with a Chromecast (YouTube Music). Discovery and connections are tested with Chromecast
72
- Ultra, Google Home Mini, Nest Hub, Nest Hub Max and speaker groups.
90
+ - Google's SDK gets what Chrome would give it: receiver availability, the device picker, sessions and joining them,
91
+ messages on any namespace, volume, and media commands with their status replies.
92
+ - Tested end to end with YouTube Music (YouTube Music Desktop, Electron 45) casting to speaker groups, a Nest Hub
93
+ and several Chromecasts, and with `cast.framework` on a Nest Hub: session start, volume, HLS load, play, pause,
94
+ seek, resume and stop.
95
+
96
+ **`mode: "chromecast"`:**
97
+
98
+ - `chrome.cast.initialize`, `requestSession`, `session.stop`, `session.leave`, receiver availability, volume and
99
+ mute, and messages on custom namespaces (`sendMessage` and `addMessageListener`).
100
+ - `chrome.cast.media`: load and queue media (`loadMedia`, `queueLoad`), control playback (play, pause, seek, stop,
101
+ volume, tracks, queue operations), receive media status updates, and watch for media with media listeners.
102
+ - `cast.framework` (`CastContext`, `RemotePlayer`, `RemotePlayerController`) on top of the polyfill. Google's
103
+ loader scripts are blocked so they can't overwrite it.
104
+ - Tested end to end with a Chromecast (YouTube Music), and with `cast.framework` media on a Nest Hub (load, play,
105
+ pause, seek, volume, and stopping from the picker).
106
+
107
+ Discovery and connections are tested with Chromecast Ultra, Google Home Mini, Nest Hub, Nest Hub Max and speaker groups.
73
108
 
74
109
  ## Lower layers
75
110
 
@@ -20,10 +20,16 @@ export interface IpcMainInvokeEventLike {
20
20
  sender: WebContentsLike;
21
21
  senderFrame: FrameLike | null;
22
22
  }
23
- /** The subset of an Electron `IpcMain` the manager needs. */
23
+ /** The subset of an Electron `IpcMainEvent` the manager needs. */
24
+ export interface IpcMainEventLike {
25
+ sender: WebContentsLike;
26
+ }
27
+ /** The subset of an Electron `IpcMain` the manager needs (`on`/`removeListener` unless `presentation: false`). */
24
28
  export interface IpcMainLike {
25
29
  handle(channel: string, listener: (event: IpcMainInvokeEventLike, ...args: any[]) => unknown): void;
26
30
  removeHandler(channel: string): void;
31
+ on?(channel: string, listener: (event: IpcMainEventLike, ...args: any[]) => void): unknown;
32
+ removeListener?(channel: string, listener: (event: IpcMainEventLike, ...args: any[]) => void): unknown;
27
33
  }
28
34
  /** Dependencies of {@link createCastManager}; the Electron objects are passed in, never imported. */
29
35
  export interface CastManagerOptions {
@@ -36,6 +42,12 @@ export interface CastManagerOptions {
36
42
  };
37
43
  createClient?(device: CastDevice): CastClientLike;
38
44
  channel?: string;
45
+ /**
46
+ * Answer the preload's presentation mode (the page's own Google Cast SDK running on a stand-in Presentation API),
47
+ * which is the preload's default. Needs `ipcMain.on` and `ipcMain.removeListener`. Default true; false serves only
48
+ * the preload's `mode: "chromecast"`.
49
+ */
50
+ presentation?: boolean;
39
51
  }
40
52
  /** The main-process cast manager. */
41
53
  export interface CastManager {
@@ -46,6 +58,7 @@ export interface CastManager {
46
58
  /**
47
59
  * Wires the session service to Electron IPC: one invoke handler per app on
48
60
  * `<channel>:call`, events sent back on `<channel>:event`. Each webContents is
49
- * a sender that leaves its sessions when it is destroyed or navigates.
61
+ * a sender that leaves its sessions when it is destroyed or navigates. Unless
62
+ * `presentation: false` it also serves `<channel>:presentation` (see {@link CastManagerOptions.presentation}).
50
63
  */
51
64
  export declare function createCastManager(options: CastManagerOptions): CastManager;
@@ -1,22 +1,51 @@
1
1
  import { CastSessionService } from "./session-service.js";
2
2
  import { CastDiscovery } from "../discovery/index.js";
3
3
  import { CastClient } from "../client/index.js";
4
+ import { CastPresentationHandler } from "./presentation-handler.js";
5
+ /** Availability watches kept per webContents; the page never releases one, so the oldest are dropped. */
6
+ const MAX_WATCHES_PER_PAGE = 32;
7
+ /** Largest page-to-receiver message accepted (Cast messages are capped at 64 KiB on the wire). */
8
+ const MAX_MESSAGE_CHARS = 1 << 20;
9
+ /** The sending frame's origin; null when there is no frame. An unparseable URL gives "" so allowOrigin decides. */
10
+ function originOf(frame) {
11
+ if (frame === null)
12
+ return null;
13
+ if (typeof frame.origin === "string" && frame.origin !== "")
14
+ return frame.origin;
15
+ try {
16
+ return new URL(frame.url).origin;
17
+ }
18
+ catch {
19
+ return "";
20
+ }
21
+ }
4
22
  /**
5
23
  * Wires the session service to Electron IPC: one invoke handler per app on
6
24
  * `<channel>:call`, events sent back on `<channel>:event`. Each webContents is
7
- * a sender that leaves its sessions when it is destroyed or navigates.
25
+ * a sender that leaves its sessions when it is destroyed or navigates. Unless
26
+ * `presentation: false` it also serves `<channel>:presentation` (see {@link CastManagerOptions.presentation}).
8
27
  */
9
28
  export function createCastManager(options) {
10
29
  const channel = options.channel ?? "electron-cast";
30
+ if (options.presentation !== false && (typeof options.ipcMain.on !== "function" || typeof options.ipcMain.removeListener !== "function")) {
31
+ throw new TypeError("presentation mode needs ipcMain.on and ipcMain.removeListener");
32
+ }
11
33
  const discovery = options.discovery ?? new CastDiscovery();
12
34
  const createClient = options.createClient ?? ((d) => new CastClient({ host: d.host, port: d.port }));
13
35
  const contents = new Map();
36
+ let handler;
14
37
  const service = new CastSessionService({
15
38
  devices: discovery,
16
39
  createClient,
17
40
  selectDevice: options.selectDevice,
18
41
  allowOrigin: options.allowOrigin,
19
42
  emit(senderId, event) {
43
+ try {
44
+ handler?.onServiceEvent(senderId, event);
45
+ }
46
+ catch (err) {
47
+ console.error("electron-cast: presentation handler failed on a service event", err);
48
+ }
20
49
  const wc = contents.get(senderId);
21
50
  if (wc === undefined || wc.isDestroyed())
22
51
  return;
@@ -34,33 +63,189 @@ export function createCastManager(options) {
34
63
  return;
35
64
  contents.set(wc.id, wc);
36
65
  wc.once("destroyed", () => {
66
+ presentation?.senderGone(wc.id);
37
67
  contents.delete(wc.id);
38
68
  service.senderGone(wc.id);
39
69
  });
40
70
  wc.on("did-navigate", () => {
71
+ presentation?.senderGone(wc.id);
41
72
  service.senderGone(wc.id);
42
73
  });
43
74
  };
44
75
  options.ipcMain.handle(`${channel}:call`, (event, method, params) => {
45
- const frame = event.senderFrame;
46
- if (frame === null) {
76
+ const origin = originOf(event.senderFrame);
77
+ if (origin === null) {
47
78
  return Promise.resolve({ ok: false, code: "extension_missing", description: "No sender frame" });
48
79
  }
49
- let origin = "";
50
- if (typeof frame.origin === "string" && frame.origin !== "") {
51
- origin = frame.origin;
52
- }
53
- else {
80
+ watch(event.sender);
81
+ return service.handle({ id: event.sender.id, origin }, method, params);
82
+ });
83
+ /** Presentation mode: IPC for the page's stand-in Presentation API, answered by a CastPresentationHandler. */
84
+ const setUpPresentation = () => {
85
+ const ipc = options.ipcMain;
86
+ const on = ipc.on.bind(ipc);
87
+ const off = ipc.removeListener.bind(ipc);
88
+ const h = new CastPresentationHandler({ service });
89
+ handler = h;
90
+ const connections = new Map();
91
+ const watches = new Map();
92
+ const sendTo = (wcId, payload) => {
93
+ const wc = contents.get(wcId);
94
+ if (wc === undefined || wc.isDestroyed())
95
+ return;
54
96
  try {
55
- origin = new URL(frame.url).origin;
97
+ wc.send(`${channel}:presentation:event`, payload);
56
98
  }
57
99
  catch {
58
- // invalid URL: keep "" so allowOrigin decides
100
+ // destroyed between the check and the send
59
101
  }
60
- }
61
- watch(event.sender);
62
- return service.handle({ id: event.sender.id, origin }, method, params);
63
- });
102
+ };
103
+ const invalid = (description) => ({ ok: false, code: "InvalidAccessError", description });
104
+ const isId = (v) => typeof v === "string" && v !== "" && v.length <= 256;
105
+ const isUrls = (v) => Array.isArray(v) && v.length > 0 && v.length <= 16 && v.every((u) => typeof u === "string");
106
+ /** Finish a start/reconnect: register the connection and route its traffic to the page. */
107
+ const open = async (wcId, connectionId, opening) => {
108
+ if (connections.has(connectionId))
109
+ return invalid("connectionId in use");
110
+ const slot = { conn: null, wcId };
111
+ connections.set(connectionId, slot); // reserved while the picker or join is pending
112
+ let conn;
113
+ try {
114
+ conn = await opening();
115
+ }
116
+ catch (err) {
117
+ if (connections.get(connectionId) === slot)
118
+ connections.delete(connectionId);
119
+ const e = err;
120
+ const name = typeof e?.name === "string" && e.name !== "" && e.name !== "Error" ? e.name : "OperationError";
121
+ return { ok: false, code: name, description: typeof e?.message === "string" ? e.message : String(err) };
122
+ }
123
+ if (!contents.has(wcId) || connections.get(connectionId) !== slot) {
124
+ conn.close();
125
+ return { ok: false, code: "AbortError", description: "The page went away" };
126
+ }
127
+ slot.conn = conn;
128
+ conn.onclose = (state) => {
129
+ if (connections.get(connectionId) === slot)
130
+ connections.delete(connectionId);
131
+ sendTo(wcId, { type: "statechange", connectionId, state });
132
+ };
133
+ // The stand-in registered this connectionId before calling, so it buffers anything sent before the reply.
134
+ conn.onmessage = (data) => sendTo(wcId, { type: "message", connectionId, data });
135
+ return { ok: true, value: { id: conn.id, url: conn.url } };
136
+ };
137
+ ipc.handle(`${channel}:presentation`, async (event, method, params) => {
138
+ const origin = originOf(event.senderFrame);
139
+ if (origin === null)
140
+ return { ok: false, code: "NotAllowedError", description: "No sender frame" };
141
+ watch(event.sender);
142
+ const wcId = event.sender.id;
143
+ const p = (typeof params === "object" && params !== null ? params : {});
144
+ try {
145
+ switch (method) {
146
+ case "getAvailability": {
147
+ if (!isId(p.watchId) || !isUrls(p.urls))
148
+ return invalid("getAvailability expects { watchId, urls }");
149
+ const watchId = p.watchId;
150
+ const old = watches.get(watchId);
151
+ if (old !== undefined && old.wcId !== wcId)
152
+ return invalid("watchId in use");
153
+ old?.ac.abort();
154
+ watches.delete(watchId);
155
+ const mine = [...watches].filter(([, w]) => w.wcId === wcId);
156
+ for (const [id, w] of mine.slice(0, Math.max(0, mine.length - (MAX_WATCHES_PER_PAGE - 1)))) {
157
+ w.ac.abort();
158
+ watches.delete(id);
159
+ }
160
+ const ac = new AbortController();
161
+ watches.set(watchId, { ac, wcId });
162
+ const available = await h.getAvailability({
163
+ urls: p.urls,
164
+ origin,
165
+ senderId: wcId,
166
+ signal: ac.signal,
167
+ onchange: (value) => sendTo(wcId, { type: "availability", watchId, value }),
168
+ });
169
+ return { ok: true, value: { available } };
170
+ }
171
+ case "stopWatching": {
172
+ const w = isId(p.watchId) ? watches.get(p.watchId) : undefined;
173
+ if (w !== undefined && w.wcId === wcId) {
174
+ w.ac.abort();
175
+ watches.delete(p.watchId);
176
+ }
177
+ return { ok: true, value: undefined };
178
+ }
179
+ case "start":
180
+ if (!isId(p.connectionId) || !isUrls(p.urls))
181
+ return invalid("start expects { connectionId, urls }");
182
+ {
183
+ const urls = p.urls;
184
+ return await open(wcId, p.connectionId, () => h.startPresentation({ urls, origin, senderId: wcId }));
185
+ }
186
+ case "reconnect":
187
+ if (!isId(p.connectionId) || !isUrls(p.urls) || !isId(p.presentationId)) {
188
+ return invalid("reconnect expects { connectionId, urls, presentationId }");
189
+ }
190
+ {
191
+ const { urls, presentationId } = p;
192
+ return await open(wcId, p.connectionId, () => h.reconnectPresentation({ urls, origin, senderId: wcId, presentationId }));
193
+ }
194
+ case "close":
195
+ case "terminate": {
196
+ const c = isId(p.connectionId) ? connections.get(p.connectionId) : undefined;
197
+ if (c !== undefined && c.wcId === wcId && c.conn !== null) {
198
+ if (method === "close")
199
+ c.conn.close();
200
+ else
201
+ c.conn.terminate();
202
+ }
203
+ return { ok: true, value: undefined };
204
+ }
205
+ default:
206
+ return invalid(`unknown method: ${String(method)}`);
207
+ }
208
+ }
209
+ catch (err) {
210
+ return { ok: false, code: "OperationError", description: err instanceof Error ? err.message : String(err) };
211
+ }
212
+ });
213
+ const onSend = (event, connectionId, data) => {
214
+ if (typeof connectionId !== "string" || typeof data !== "string")
215
+ return;
216
+ const c = connections.get(connectionId);
217
+ if (c === undefined || c.wcId !== event.sender.id || c.conn === null)
218
+ return;
219
+ if (data.length > MAX_MESSAGE_CHARS)
220
+ return;
221
+ c.conn.send(data);
222
+ };
223
+ on(`${channel}:presentation:send`, onSend);
224
+ return {
225
+ /** Close the page's connections and watches before the service drops it. */
226
+ senderGone(wcId) {
227
+ h.senderGone(wcId);
228
+ for (const [id, c] of connections)
229
+ if (c.wcId === wcId)
230
+ connections.delete(id);
231
+ for (const [id, w] of watches) {
232
+ if (w.wcId !== wcId)
233
+ continue;
234
+ w.ac.abort();
235
+ watches.delete(id);
236
+ }
237
+ },
238
+ dispose() {
239
+ ipc.removeHandler(`${channel}:presentation`);
240
+ off(`${channel}:presentation:send`, onSend);
241
+ for (const w of watches.values())
242
+ w.ac.abort();
243
+ watches.clear();
244
+ connections.clear();
245
+ },
246
+ };
247
+ };
248
+ const presentation = options.presentation !== false ? setUpPresentation() : undefined;
64
249
  let disposed = false;
65
250
  return {
66
251
  start: () => discovery.start(),
@@ -70,6 +255,7 @@ export function createCastManager(options) {
70
255
  return;
71
256
  disposed = true;
72
257
  options.ipcMain.removeHandler(`${channel}:call`);
258
+ presentation?.dispose();
73
259
  discovery.stop();
74
260
  await service.dispose();
75
261
  contents.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/electron/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAmF,MAAM,sBAAsB,CAAC;AAE3I,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAA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O;YACX,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,OAAO,CAAC,CAAC;YACjD,YAAY,EAAE,OAAO,EAAE,CAAC;YACxB,SAAS,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -10,6 +10,8 @@ export interface ContextBridgeLike {
10
10
  export interface IpcRendererLike {
11
11
  invoke(channel: string, ...args: unknown[]): Promise<unknown>;
12
12
  on(channel: string, listener: (event: unknown, ...args: any[]) => void): unknown;
13
+ /** Needed in presentation mode (the default). */
14
+ send?(channel: string, ...args: unknown[]): void;
13
15
  }
14
16
  /** Dependencies of {@link installCastBridge}; the Electron objects are passed in, never imported. */
15
17
  export interface CastBridgeOptions {
@@ -17,6 +19,16 @@ export interface CastBridgeOptions {
17
19
  ipcRenderer: IpcRendererLike;
18
20
  channel?: string;
19
21
  bridgeKey?: string;
22
+ /**
23
+ * "presentation" (default) installs a stand-in Presentation API, so the page's own copy of Google's Cast SDK
24
+ * loads and runs unmodified. "chromecast" installs electron-cast's own chrome.cast instead and blocks Google's
25
+ * loader scripts.
26
+ */
27
+ mode?: "chromecast" | "presentation";
28
+ presentationBridgeKey?: string;
20
29
  }
21
- /** Call from a preload script: exposes the bridge and installs chrome.cast in the page before its scripts run. */
30
+ /**
31
+ * Call from a preload script. Exposes the bridge and, before the page's scripts run, installs the Presentation API
32
+ * stand-in (default) or, with `mode: "chromecast"`, electron-cast's own chrome.cast.
33
+ */
22
34
  export declare function installCastBridge(options: CastBridgeOptions): void;
@@ -1,10 +1,21 @@
1
1
  import { installChromeCast } from "../polyfill/install.js";
2
+ import { installPresentationStandIn } from "../polyfill/presentation-standin.js";
2
3
  function describe(err) {
3
4
  return err instanceof Error ? err.message : String(err);
4
5
  }
5
- /** Call from a preload script: exposes the bridge and installs chrome.cast in the page before its scripts run. */
6
+ /**
7
+ * Call from a preload script. Exposes the bridge and, before the page's scripts run, installs the Presentation API
8
+ * stand-in (default) or, with `mode: "chromecast"`, electron-cast's own chrome.cast.
9
+ */
6
10
  export function installCastBridge(options) {
7
11
  const channel = options.channel ?? "electron-cast";
12
+ const mode = options.mode ?? "presentation";
13
+ if (mode !== "presentation" && mode !== "chromecast")
14
+ throw new TypeError(`unknown mode: ${String(mode)}`);
15
+ if (mode === "presentation") {
16
+ installPresentationBridge(options, channel);
17
+ return;
18
+ }
8
19
  const bridgeKey = options.bridgeKey ?? "__electronCastBridge";
9
20
  const bridge = {
10
21
  /** Forward one bridge call to the main process; never rejects. */
@@ -33,4 +44,42 @@ export function installCastBridge(options) {
33
44
  options.contextBridge.exposeInMainWorld(bridgeKey, bridge);
34
45
  options.contextBridge.executeInMainWorld({ func: installChromeCast, args: [bridgeKey] });
35
46
  }
47
+ /** Presentation mode: expose the stand-in's bridge and install the stand-in; chrome.cast is left to Google's SDK. */
48
+ function installPresentationBridge(options, channel) {
49
+ const key = options.presentationBridgeKey ?? "__electronCastPresentationBridge";
50
+ const ipc = options.ipcRenderer;
51
+ if (typeof ipc.send !== "function")
52
+ throw new TypeError("presentation mode needs ipcRenderer.send");
53
+ const send = ipc.send.bind(ipc);
54
+ const bridge = {
55
+ /** Forward one call to the main process; never rejects. */
56
+ call(method, params) {
57
+ let invoked;
58
+ try {
59
+ invoked = ipc.invoke(`${channel}:presentation`, method, params);
60
+ }
61
+ catch (err) {
62
+ invoked = Promise.reject(err);
63
+ }
64
+ return invoked.then((result) => result, (err) => ({ ok: false, code: "OperationError", description: describe(err) }));
65
+ },
66
+ /** Page -> main: one message on an open connection; the reply comes back in-band. */
67
+ send(connectionId, data) {
68
+ send(`${channel}:presentation:send`, connectionId, data);
69
+ },
70
+ /** Relay `<channel>:presentation:event` payloads to the page, dropping the IPC event object. */
71
+ onEvent(listener) {
72
+ ipc.on(`${channel}:presentation:event`, (_event, payload) => {
73
+ try {
74
+ listener(payload);
75
+ }
76
+ catch (err) {
77
+ console.error(err);
78
+ }
79
+ });
80
+ },
81
+ };
82
+ options.contextBridge.exposeInMainWorld(key, bridge);
83
+ options.contextBridge.executeInMainWorld({ func: installPresentationStandIn, args: [key] });
84
+ }
36
85
  //# sourceMappingURL=preload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preload.js","sourceRoot":"","sources":["../../src/electron/preload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAqB3D,SAAS,QAAQ,CAAC,GAAY;IAC5B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,kHAAkH;AAClH,MAAM,UAAU,iBAAiB,CAAC,OAA0B;IAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC;IACnD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,sBAAsB,CAAC;IAC9D,MAAM,MAAM,GAAG;QACb,kEAAkE;QAClE,IAAI,CAAC,MAAoB,EAAE,MAAe;YACxC,IAAI,OAAyB,CAAC;YAC9B,IAAI,CAAC;gBACH,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YAC1E,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,OAAO,CAAC,IAAI,CACjB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAsB,EAClC,CAAC,GAAY,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,W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,OAAO,CAAC,QAAkC;YACxC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,qBAAqB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;gBAC1D,IAAI,CAAC;oBACH,QAAQ,CAAC,OAAO,CAAC,CAAC;gBACpB,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IACF,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { ReceiverSnapshot, SessionSnapshot } from "../polyfill/bridge-types.ts";
2
+ /** The Cast media namespace; the only reserved namespace kept by {@link filterNamespaces}. */
3
+ export declare const MEDIA_NAMESPACE = "urn:x-cast:com.google.cast.media";
4
+ /** The fields parsed out of a presentation request URL. */
5
+ export interface PresentationUrl {
6
+ appId: string;
7
+ capabilities: string[];
8
+ clientId: string | null;
9
+ autoJoinPolicy: string;
10
+ defaultActionPolicy: string;
11
+ launchTimeout: number | null;
12
+ }
13
+ /** A validated inbound router message, with `timeoutMillis` dropped and object messages null-stripped. */
14
+ export interface ParsedEnvelope {
15
+ type: string;
16
+ message: unknown;
17
+ sequenceNumber?: number;
18
+ clientId: string;
19
+ }
20
+ /**
21
+ * Parses a presentation request URL (the legacy `https://google.com/cast#__castAppId__=...` form or
22
+ * `cast:<appId>?...`) into its launch fields, or null for anything that is not one of those forms.
23
+ */
24
+ export declare function parsePresentationUrl(url: string): PresentationUrl | null;
25
+ /** Deep-copies a value, dropping every object property whose value is null (null array elements are kept). */
26
+ export declare function stripNulls(v: unknown): unknown;
27
+ /** Escapes the five HTML metacharacters, as Chromium's `base::EscapeForHTML` does for receiver names. */
28
+ export declare function escapeHtml(s: string): string;
29
+ /** Chromium's receiver label: unpadded base64url of sha256(deviceId + per-process token). */
30
+ export declare function receiverLabel(deviceId: string, token: string): string;
31
+ /** Shapes a ReceiverSnapshot into the receiver object clank reads, with an escaped name and hashed label. */
32
+ export declare function toReceiver(r: ReceiverSnapshot, label: string): {
33
+ label: string;
34
+ friendlyName: string;
35
+ capabilities: string[];
36
+ volume: import("../polyfill/bridge-types.ts").VolumeSnapshot;
37
+ isActiveInput: boolean | null;
38
+ displayStatus: null;
39
+ receiverType: string;
40
+ };
41
+ /** Drops the reserved namespaces from a session's namespace list, keeping everything else in order. */
42
+ export declare function filterNamespaces(ns: {
43
+ name: string;
44
+ }[]): {
45
+ name: string;
46
+ }[];
47
+ /** Shapes a SessionSnapshot into the new_session/update_session message clank's converter copies onto the session. */
48
+ export declare function toSession(s: SessionSnapshot, label: string, media?: object[]): Record<string, unknown>;
49
+ /** Converts a supportedMediaCommands bitmask (or passes through an array of strings) into command names. */
50
+ export declare function mediaCommands(v: unknown): string[];
51
+ /** Shallow-copies a media-status entry, stamping its sessionId and converting its media commands to strings. */
52
+ export declare function toMediaEntry(entry: Record<string, unknown>, sessionId: string): Record<string, unknown>;
53
+ /** Serialises an outbound Chromium router message; undefined/null/empty-object messages become null. */
54
+ export declare function envelope(type: string, message: unknown, clientId: string, sequenceNumber?: number): string;
55
+ /** Validates an inbound router message the way Chromium's CIM parser does, stripping nulls from object messages. */
56
+ export declare function parseEnvelope(raw: string): ParsedEnvelope | null;
57
+ /** True when a v2_message type is one of the media requests forwarded to the receiver. */
58
+ export declare function isMediaRequest(type: string): boolean;
59
+ /** Maps the media request types to the receiver's protocol names, leaving all other types unchanged. */
60
+ export declare function receiverMediaType(type: string): string;