bunite-core 0.9.0 → 0.10.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/src/rpc/error.ts CHANGED
@@ -1,24 +1,35 @@
1
1
  export type IpcCode =
2
- | "ok"
3
- | "cancelled"
4
- | "unknown"
5
- | "invalid_argument"
6
- | "deadline_exceeded"
7
2
  | "not_found"
8
- | "not_supported"
3
+ | "failed_precondition"
9
4
  | "already_exists"
10
- | "permission_denied"
11
- | "unauthenticated"
5
+ | "invalid_argument"
6
+ | "cancelled"
7
+ | "deadline_exceeded"
12
8
  | "resource_exhausted"
13
- | "failed_precondition"
14
9
  | "unavailable"
15
- | "protocol_error";
10
+ | "internal";
16
11
 
17
12
  export type FailedPreconditionReason =
18
- | "cap_disposed"
19
- | "cap_revoked"
20
- | "owner_disconnect"
21
- | "protocol_violation";
13
+ | "version_mismatch"
14
+ | "unauthorized"
15
+ | "unregistered_cap_return"
16
+ | "revoked";
17
+
18
+ export type ResourceExhaustedReason =
19
+ | "max_frame_bytes"
20
+ | "max_concurrent_calls"
21
+ | "max_caps_per_connection"
22
+ | "stream_credit_window"
23
+ | "rate_limited";
24
+
25
+ export type UnavailableReason =
26
+ | "peer_closing"
27
+ | "goaway"
28
+ | "plugin_unloading";
29
+
30
+ export type AlreadyExistsReason =
31
+ | "name_collision"
32
+ | "reserved_namespace";
22
33
 
23
34
  export type RetrySpec =
24
35
  | { kind: "never" }
@@ -55,4 +66,3 @@ export class IpcError extends Error {
55
66
  };
56
67
  }
57
68
  }
58
-
@@ -1,6 +1,7 @@
1
1
  import { call, defineCap, stream, cap } from "./schema";
2
+ import type { CapDef } from "./schema";
2
3
 
3
- export const BrowserWindowCap = defineCap({
4
+ export const BrowserWindowCap = defineCap("bunite.BrowserWindow", {
4
5
  focus: call<void, void>(),
5
6
  close: call<void, void>(),
6
7
  setBounds: call<{ x: number; y: number; w: number; h: number }, void>(),
@@ -9,7 +10,7 @@ export const BrowserWindowCap = defineCap({
9
10
  label: call<void, string>({ idempotent: true }),
10
11
  });
11
12
 
12
- export const WindowCap = defineCap({
13
+ export const WindowCap = defineCap("bunite.Window", {
13
14
  create: call<WindowCreateOpts, typeof BrowserWindowCap>({ returns: cap(BrowserWindowCap) }),
14
15
  list: call<void, typeof BrowserWindowCap>({ returns: cap.array(BrowserWindowCap), idempotent: true }),
15
16
  focus: call<{ id?: number; label?: string }, void>(),
@@ -23,14 +24,14 @@ export interface WindowCreateOpts {
23
24
  label?: string;
24
25
  }
25
26
 
26
- export const FileRefCap = defineCap({
27
+ export const FileRefCap = defineCap("bunite.FileRef", {
27
28
  text: call<void, string>({ idempotent: true }),
28
29
  bytes: call<void, Uint8Array>({ idempotent: true }),
29
30
  path: call<void, string>({ idempotent: true }),
30
31
  revoke: call<void, void>(),
31
- }, { disposal: { method: "revoke", async: true } });
32
+ }, { disposal: { method: "revoke" } });
32
33
 
33
- export const DialogsCap = defineCap({
34
+ export const DialogsCap = defineCap("bunite.Dialogs", {
34
35
  openFile: call<DialogOpenFileOpts, typeof FileRefCap>({ returns: cap.array(FileRefCap) }),
35
36
  saveFile: call<DialogSaveFileOpts, typeof FileRefCap>({ returns: cap(FileRefCap) }),
36
37
  showMessage: call<DialogMessageOpts, "primary" | "secondary" | "tertiary">(),
@@ -57,21 +58,21 @@ export interface DialogMessageOpts {
57
58
  tertiary?: string;
58
59
  }
59
60
 
60
- export const ClipboardCap = defineCap({
61
+ export const ClipboardCap = defineCap("bunite.Clipboard", {
61
62
  readText: call<void, string>({ idempotent: true }),
62
63
  writeText: call<{ text: string }, void>(),
63
64
  readBytes: call<{ mime: string }, Uint8Array>({ idempotent: true }),
64
65
  writeBytes: call<{ mime: string; data: Uint8Array }, void>(),
65
66
  });
66
67
 
67
- export const ShellCap = defineCap({
68
+ export const ShellCap = defineCap("bunite.Shell", {
68
69
  openExternal: call<{ url: string }, boolean>(),
69
70
  showItemInFolder: call<{ path: string }, void>(),
70
71
  });
71
72
 
72
73
  export type SurfaceMask = { x: number; y: number; w: number; h: number };
73
74
 
74
- export const SurfaceCap = defineCap({
75
+ export const SurfaceCap = defineCap("bunite.Surface", {
75
76
  init: call<{
76
77
  src: string;
77
78
  x: number;
@@ -92,7 +93,7 @@ export const SurfaceCap = defineCap({
92
93
  didNavigate: stream<void, { surfaceId: number; url: string }>(),
93
94
  });
94
95
 
95
- export const RuntimeCap = defineCap({
96
+ export const RuntimeCap = defineCap("bunite.Runtime", {
96
97
  window: call<void, typeof WindowCap>({ returns: cap(WindowCap), idempotent: true }),
97
98
  dialogs: call<void, typeof DialogsCap>({ returns: cap(DialogsCap), idempotent: true }),
98
99
  clipboard: call<void, typeof ClipboardCap>({ returns: cap(ClipboardCap), idempotent: true }),
@@ -112,10 +113,9 @@ export const FRAMEWORK_TYPE_IDS = {
112
113
  Clipboard: 5,
113
114
  Shell: 6,
114
115
  BrowserWindow: 7,
116
+ Surface: 8,
115
117
  } as const;
116
118
 
117
- import type { CapDef } from "./schema";
118
-
119
119
  const FRAMEWORK_CAP_TYPE_IDS = new Map<CapDef<any, any>, number>([
120
120
  [RuntimeCap, FRAMEWORK_TYPE_IDS.Runtime],
121
121
  [WindowCap, FRAMEWORK_TYPE_IDS.Window],
@@ -124,7 +124,7 @@ const FRAMEWORK_CAP_TYPE_IDS = new Map<CapDef<any, any>, number>([
124
124
  [ClipboardCap, FRAMEWORK_TYPE_IDS.Clipboard],
125
125
  [ShellCap, FRAMEWORK_TYPE_IDS.Shell],
126
126
  [BrowserWindowCap, FRAMEWORK_TYPE_IDS.BrowserWindow],
127
- [SurfaceCap, 8],
127
+ [SurfaceCap, FRAMEWORK_TYPE_IDS.Surface],
128
128
  ]);
129
129
 
130
130
  export function frameworkTypeIdOf(cap: CapDef<any, any>): number | undefined {
package/src/rpc/index.ts CHANGED
@@ -25,10 +25,10 @@ export type {
25
25
  MethodDef,
26
26
  MethodsRecord,
27
27
  DisposalSpec,
28
+ DefineCapOpts,
28
29
  Schema,
29
- SchemaShape,
30
+ SchemaRoots,
30
31
  ImplsOf,
31
- ServerDescriptor,
32
32
  ReturnsKind,
33
33
  CallCtx,
34
34
  Attestation,
@@ -38,8 +38,6 @@ export type {
38
38
  ClientReturn,
39
39
  } from "./schema";
40
40
 
41
- export { topologyHash, canonicalize } from "./hash";
42
-
43
41
  export {
44
42
  CapRef,
45
43
  CAP_REF_EXT,
@@ -47,6 +45,8 @@ export {
47
45
  isFrame,
48
46
  DEFAULT_MAX_BYTES,
49
47
  PROTOCOL_VERSION,
48
+ FRAMEWORK_NAME_PREFIX,
49
+ BOOTSTRAP_METHOD,
50
50
  } from "./wire";
51
51
 
52
52
  export type {
@@ -58,6 +58,7 @@ export type {
58
58
  DropFrame,
59
59
  HelloFrame,
60
60
  GoAwayFrame,
61
+ CapRevokedFrame,
61
62
  StreamEvent,
62
63
  Target,
63
64
  CallMeta,
@@ -73,6 +74,9 @@ export type {
73
74
  IpcStatus,
74
75
  RetrySpec,
75
76
  FailedPreconditionReason,
77
+ ResourceExhaustedReason,
78
+ UnavailableReason,
79
+ AlreadyExistsReason,
76
80
  } from "./error";
77
81
 
78
82
  export {
@@ -84,6 +88,7 @@ export {
84
88
  FIRST_USER_CAP_ID,
85
89
  FIRST_USER_TYPE_ID,
86
90
  MAX_CAPS_PER_CONNECTION,
91
+ MAX_IN_FLIGHT_CALLS_PER_CONNECTION,
87
92
  createConnection,
88
93
  } from "./peer";
89
94
 
@@ -110,8 +115,12 @@ export type {
110
115
  Transport,
111
116
  Connection,
112
117
  ConnectionOptions,
118
+ ConnectionEvents,
113
119
  CapTableEntry,
114
120
  PendingCall,
121
+ Policy,
122
+ IfExists,
123
+ ServeHandle,
115
124
  } from "./peer";
116
125
 
117
126
  export {