@dormer/renderer 0.0.0-stage → 0.1.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 (3) hide show
  1. package/package.json +16 -4
  2. package/src/index.ts +45 -0
  3. package/README.md +0 -3
package/package.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "@dormer/renderer",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "Typed renderer-side access to the Dormer bridge (invoke, send, on, stream)",
5
+ "type": "module",
6
+ "license": "Apache-2.0 OR MIT",
7
+ "exports": {
8
+ ".": "./src/index.ts"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/veerareddyvishal144/dormer.git",
16
+ "directory": "packages/renderer"
17
+ }
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,45 @@
1
+ // Thin typed wrapper over the host-injected `window.dormer` bridge.
2
+ export interface DormerErrorLike extends Error { code: string; data?: unknown; retry: boolean }
3
+ export interface InvokeOptions { signal?: AbortSignal }
4
+ export type BinaryInput = Uint8Array | ArrayBuffer | ArrayBufferView;
5
+ /** Trailing argument a handler receives for each part of a chunked upload (bodies > ~16 MiB). */
6
+ export interface BulkChunkMeta { __dormerChunk: { upload: string; chunk: number; of: number; total: number } }
7
+ export interface DormerBridge {
8
+ invoke<T = unknown>(channel: string, ...args: unknown[]): Promise<T>;
9
+ invokeWith<T = unknown>(opts: InvokeOptions, channel: string, ...args: unknown[]): Promise<T>;
10
+ /**
11
+ * Bulk/binary upload over the custom scheme (ADR-0005 §3). The handler registered with
12
+ * `ipcMain.handle(channel, (event, bytes: Buffer, ...args) => ...)` receives the bytes as its
13
+ * first argument. Returns a `Uint8Array` when the handler returns binary, else the JSON value.
14
+ * Uploads above ~16 MiB are sent as sequential 8 MiB chunk calls, each with a trailing
15
+ * `BulkChunkMeta` argument; the result of the last chunk call is returned.
16
+ */
17
+ invokeBinary<T = unknown>(channel: string, data: BinaryInput, ...args: unknown[]): Promise<T>;
18
+ invokeBinaryWith<T = unknown>(opts: InvokeOptions, channel: string, data: BinaryInput, ...args: unknown[]): Promise<T>;
19
+ send(channel: string, ...args: unknown[]): void;
20
+ on(channel: string, listener: (...args: any[]) => void): () => void;
21
+ once(channel: string, listener: (...args: any[]) => void): () => void;
22
+ off(channel: string, listener: (...args: any[]) => void): void;
23
+ stream(channel: string, ...args: unknown[]): ReadableStream<Uint8Array>;
24
+ readonly windowId: number;
25
+ readonly platform: "darwin" | "win32" | "linux";
26
+ readonly version: number;
27
+ }
28
+ declare global { interface Window { dormer?: DormerBridge } }
29
+
30
+ function bridge(): DormerBridge {
31
+ const b = (globalThis as unknown as Window).dormer;
32
+ if (!b) throw new Error("Dormer bridge not available: this page is not running inside a Dormer window");
33
+ return b;
34
+ }
35
+ export const isDormer = (): boolean => Boolean((globalThis as unknown as Window).dormer);
36
+ export const invoke = <T = unknown>(channel: string, ...args: unknown[]): Promise<T> => bridge().invoke<T>(channel, ...args);
37
+ export const invokeWith = <T = unknown>(opts: InvokeOptions, channel: string, ...args: unknown[]): Promise<T> => bridge().invokeWith<T>(opts, channel, ...args);
38
+ export const invokeBinary = <T = unknown>(channel: string, data: BinaryInput, ...args: unknown[]): Promise<T> => bridge().invokeBinary<T>(channel, data, ...args);
39
+ export const invokeBinaryWith = <T = unknown>(opts: InvokeOptions, channel: string, data: BinaryInput, ...args: unknown[]): Promise<T> => bridge().invokeBinaryWith<T>(opts, channel, data, ...args);
40
+ export const send = (channel: string, ...args: unknown[]): void => bridge().send(channel, ...args);
41
+ export const on = (channel: string, listener: (...args: any[]) => void): (() => void) => bridge().on(channel, listener);
42
+ export const once = (channel: string, listener: (...args: any[]) => void): (() => void) => bridge().once(channel, listener);
43
+ export const stream = (channel: string, ...args: unknown[]): ReadableStream<Uint8Array> => bridge().stream(channel, ...args);
44
+ export const platform = (): DormerBridge["platform"] => bridge().platform;
45
+ export const windowId = (): number => bridge().windowId;
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.