@cero-base/cero 2.2.1 → 2.3.1

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 (42) hide show
  1. package/README.md +24 -16
  2. package/package.json +7 -6
  3. package/src/build/index.js +38 -34
  4. package/src/build/internal.js +96 -11
  5. package/src/build/schemas.js +119 -19
  6. package/src/extensions/handle-sync.js +8 -12
  7. package/src/extensions/index.js +17 -63
  8. package/src/extensions/mirror.js +44 -0
  9. package/src/extensions/profile-sync.js +10 -12
  10. package/src/handle/index.js +499 -374
  11. package/src/handle/join.js +144 -0
  12. package/src/index.js +91 -119
  13. package/src/lib/bluetooth.js +83 -19
  14. package/src/lib/constants.js +1 -0
  15. package/src/lib/operators.js +296 -128
  16. package/src/lib/peek.js +1 -1
  17. package/src/lib/refs.js +7 -7
  18. package/src/lib/spec.js +32 -0
  19. package/src/local/index.js +27 -3
  20. package/src/rpc/client.js +247 -205
  21. package/src/rpc/server.js +186 -133
  22. package/types/build/index.d.ts +3 -8
  23. package/types/build/internal.d.ts +86 -27
  24. package/types/build/schemas.d.ts +91 -12
  25. package/types/extensions/handle-sync.d.ts +4 -12
  26. package/types/extensions/index.d.ts +59 -59
  27. package/types/extensions/mirror.d.ts +13 -0
  28. package/types/extensions/profile-sync.d.ts +4 -13
  29. package/types/handle/index.d.ts +229 -198
  30. package/types/handle/join.d.ts +63 -0
  31. package/types/index.d.ts +36 -53
  32. package/types/lib/bluetooth.d.ts +57 -19
  33. package/types/lib/constants.d.ts +1 -0
  34. package/types/lib/operators.d.ts +166 -81
  35. package/types/lib/peek.d.ts +2 -2
  36. package/types/lib/refs.d.ts +14 -15
  37. package/types/lib/spec.d.ts +87 -0
  38. package/types/local/index.d.ts +19 -9
  39. package/types/rpc/client.d.ts +110 -93
  40. package/types/rpc/server.d.ts +91 -50
  41. package/src/rpc/index.js +0 -8
  42. package/types/rpc/index.d.ts +0 -7
@@ -3,3 +3,90 @@
3
3
  * so cero apps can describe their tables without pulling in the core package directly.
4
4
  */
5
5
  export { t, schema } from '@cero-base/core/schema';
6
+ export type RefInfo = {
7
+ kind?: 'single' | 'collection' | 'action' | 'handle';
8
+ schema?: string;
9
+ /**
10
+ * The handle type a `handle` ref opens.
11
+ */
12
+ type?: string;
13
+ /**
14
+ * A builtin: members, devices, files and the like.
15
+ */
16
+ internal?: boolean;
17
+ /**
18
+ * Computed on the device, never stored: status, joins, nearby.
19
+ */
20
+ live?: boolean;
21
+ /**
22
+ * The declared fields, in schema order.
23
+ */
24
+ fields?: string[];
25
+ /**
26
+ * The required fields and their types.
27
+ */
28
+ required?: Record<string, string>;
29
+ /**
30
+ * The fields holding file ids.
31
+ */
32
+ files?: string[];
33
+ verb?: string;
34
+ };
35
+ export type SpecMeta = {
36
+ ns?: string;
37
+ /**
38
+ * The handle type, on a handle's spec.
39
+ */
40
+ type?: string;
41
+ version?: number;
42
+ refs: Record<string, RefInfo>;
43
+ local?: {
44
+ refs: Record<string, RefInfo>;
45
+ };
46
+ handles?: Record<string, SpecMeta>;
47
+ };
48
+ export type Spec = import('@cero-base/core/rpc').Spec & {
49
+ meta: SpecMeta;
50
+ database?: object;
51
+ dispatch?: object;
52
+ local?: {
53
+ database: object;
54
+ schema: object;
55
+ meta: SpecMeta;
56
+ codec?: import('@cero-base/core/rpc').Codec;
57
+ };
58
+ extensions?: import('../extensions/index.js').Extension[] | null;
59
+ handles?: Record<string, Spec>;
60
+ };
61
+ export type Row = import('@cero-base/core/database').Row;
62
+ /**
63
+ * @typedef {object} RefInfo One entry of a spec's `meta.refs`.
64
+ * @property {'single' | 'collection' | 'action' | 'handle'} [kind]
65
+ * @property {string} [schema]
66
+ * @property {string} [type] The handle type a `handle` ref opens.
67
+ * @property {boolean} [internal] A builtin: members, devices, files and the like.
68
+ * @property {boolean} [live] Computed on the device, never stored: status, joins, nearby.
69
+ * @property {string[]} [fields] The declared fields, in schema order.
70
+ * @property {Record<string, string>} [required] The required fields and their types.
71
+ * @property {string[]} [files] The fields holding file ids.
72
+ * @property {string} [verb]
73
+ *
74
+ * @typedef {object} SpecMeta
75
+ * @property {string} [ns]
76
+ * @property {string} [type] The handle type, on a handle's spec.
77
+ * @property {number} [version]
78
+ * @property {Record<string, RefInfo>} refs
79
+ * @property {{ refs: Record<string, RefInfo> }} [local]
80
+ * @property {Record<string, SpecMeta>} [handles]
81
+ *
82
+ * @typedef {import('@cero-base/core/rpc').Spec & {
83
+ * meta: SpecMeta,
84
+ * database?: object,
85
+ * dispatch?: object,
86
+ * local?: { database: object, schema: object, meta: SpecMeta, codec?: import('@cero-base/core/rpc').Codec },
87
+ * extensions?: import('../extensions/index.js').Extension[] | null,
88
+ * handles?: Record<string, Spec>
89
+ * }} Spec What `build` writes and `cero()` opens.
90
+ *
91
+ * @typedef {import('@cero-base/core/database').Row} Row
92
+ */
@@ -4,11 +4,11 @@ export type LocalOpts = {
4
4
  /**
5
5
  * Pre-existing HypercoreStorage to reuse.
6
6
  */
7
- root?: any;
7
+ root?: import('hypercore-storage');
8
8
  /**
9
9
  * Pre-existing Corestore to reuse.
10
10
  */
11
- store?: any;
11
+ store?: import('corestore');
12
12
  /**
13
13
  * 32-byte key encrypting the local store at rest.
14
14
  */
@@ -16,8 +16,8 @@ export type LocalOpts = {
16
16
  };
17
17
  /**
18
18
  * @typedef {object} LocalOpts
19
- * @property {any} [root] Pre-existing HypercoreStorage to reuse.
20
- * @property {any} [store] Pre-existing Corestore to reuse.
19
+ * @property {import('hypercore-storage')} [root] Pre-existing HypercoreStorage to reuse.
20
+ * @property {import('corestore')} [store] Pre-existing Corestore to reuse.
21
21
  * @property {Uint8Array} [storageKey] 32-byte key encrypting the local store at rest.
22
22
  */
23
23
  /**
@@ -26,14 +26,24 @@ export type LocalOpts = {
26
26
  */
27
27
  export declare class Local extends ReadyResource {
28
28
  dir: string;
29
- spec: any;
29
+ spec: import("../lib/spec.js").Spec;
30
30
  store: Storage;
31
31
  /**
32
32
  * @param {string | null} dir Directory for the local store, or `null` when reusing an external `store`.
33
- * @param {any} spec Built cero spec — must include `spec.local.database` and `spec.meta.local`.
33
+ * @param {import('../lib/spec.js').Spec} spec Built cero spec, with `spec.local.database` and `spec.meta.local`.
34
34
  * @param {LocalOpts} [opts]
35
35
  */
36
- constructor(dir: string | null, spec: any, { root, store, storageKey }?: LocalOpts);
37
- _open(): Promise<void>;
38
- _close(): Promise<void>;
36
+ constructor(dir: string | null, spec: import('../lib/spec.js').Spec, { root, store, storageKey }?: LocalOpts);
37
+ /** @private */
38
+ private _open;
39
+ /** @private */
40
+ private _close;
39
41
  }
42
+ /**
43
+ * One of the mailbox's boxes, kept in the local store so mail survives a restart.
44
+ *
45
+ * @param {import('@cero-base/core/storage').Storage} store
46
+ * @param {'inbox' | 'outbox'} name
47
+ * @returns {import('@cero-base/core/mailbox').Box}
48
+ */
49
+ export declare function box(store: import('@cero-base/core/storage').Storage, name: 'inbox' | 'outbox'): import('@cero-base/core/mailbox').Box;
@@ -1,45 +1,63 @@
1
+ import { Readable } from 'streamx';
1
2
  import { RPCClient } from '@cero-base/core/rpc';
2
- import { put, set, get, del, watch, changes, call, open, rotate } from '../lib/operators.js';
3
+ import { Ref } from '../lib/refs.js';
4
+ import * as verbs from '../lib/operators.js';
3
5
  import { t, schema } from '../lib/spec.js';
4
- export { put, set, get, del, watch, changes, call, open, rotate, t, schema };
5
- export type BaseRPCClient = import('@cero-base/core/rpc').RPCClient;
6
- export type RefInfo = {
7
- kind?: 'single' | 'collection' | 'action' | 'handle';
8
- schema?: string;
9
- type?: string;
10
- internal?: boolean;
11
- };
12
- export type Spec = import('@cero-base/core/rpc').Spec & {
13
- meta: {
14
- ns?: string;
15
- refs: Record<string, RefInfo>;
16
- local?: {
17
- refs: Record<string, RefInfo>;
18
- };
19
- handles?: Record<string, Spec>;
20
- };
21
- handles: Record<string, Spec>;
22
- };
23
- export type SingleResult = {
24
- data: any;
25
- };
26
- export type ListResult = {
27
- data: any[];
28
- total: number;
29
- size: number;
30
- };
31
- export type GetByIdResult = {
32
- data: any | null;
33
- };
34
- export type ClientIdentity = {
35
- id: string;
36
- toPhrase: () => string | null;
6
+ declare const remote: {
7
+ put(ref: verbs.Ref, row: verbs.Row): Promise<verbs.SingleResult>;
8
+ set(ref: verbs.Ref, row: verbs.Row, opts?: {
9
+ upsert?: boolean;
10
+ }): Promise<verbs.SingleResult | null>;
11
+ del(ref: verbs.Ref, id?: string): Promise<void>;
12
+ call(ref: verbs.Ref, d?: verbs.Row): Promise<void>;
13
+ get(ref: verbs.Ref, q?: string | Record<string, unknown>): Promise<verbs.SingleResult | verbs.ListResult>;
14
+ watch(ref: verbs.Ref, query?: string | (Record<string, unknown> & {
15
+ changes?: boolean;
16
+ }), opts?: {
17
+ signal?: AbortSignal;
18
+ }): import('streamx').Readable;
19
+ open(ref: verbs.Ref, arg?: string | {
20
+ invite?: string;
21
+ id?: string;
22
+ name?: string;
23
+ } | undefined): Promise<verbs.Context>;
24
+ invite(ctx: verbs.Context, opts?: import("@cero-base/core").InviteOpts): Promise<string>;
25
+ revoke(ctx: verbs.Context, code: string): Promise<boolean>;
26
+ rotate(ctx: verbs.Context): Promise<{
27
+ epoch: number;
28
+ }>;
29
+ accept(ctx: verbs.Context, request: {
30
+ id: string;
31
+ }, { role }?: {
32
+ role?: string;
33
+ }): Promise<void>;
34
+ deny(ctx: verbs.Context, request: {
35
+ id: string;
36
+ }, reason?: string): Promise<void>;
37
+ leave(ctx: verbs.Context): Promise<void>;
38
+ close(ctx: verbs.Context): Promise<void>;
39
+ cancel(me: verbs.Context, code: string): Promise<boolean>;
40
+ suspend(me: verbs.Context): Promise<void>;
41
+ resume(me: verbs.Context): Promise<void>;
42
+ activate(room: verbs.Context): Promise<void>;
43
+ deactivate(room: verbs.Context): Promise<void>;
44
+ phrase(me: verbs.Context): Promise<string>;
45
+ nearby(ctx: verbs.Context, mode: boolean | string): Promise<void>;
37
46
  };
47
+ export declare const put: typeof verbs.put, set: typeof verbs.set, get: typeof verbs.get, del: typeof verbs.del, watch: typeof verbs.watch, call: typeof verbs.call, open: typeof verbs.open, invite: typeof verbs.invite, revoke: typeof verbs.revoke, rotate: typeof verbs.rotate, accept: typeof verbs.accept, deny: typeof verbs.deny, leave: typeof verbs.leave, close: typeof verbs.close, cancel: typeof verbs.cancel, suspend: typeof verbs.suspend, resume: typeof verbs.resume, activate: typeof verbs.activate, deactivate: typeof verbs.deactivate, phrase: typeof verbs.phrase, nearby: typeof verbs.nearby;
48
+ export { t, schema };
49
+ export type BaseRPCClient = import('@cero-base/core/rpc').RPCClient;
50
+ export type RefInfo = import('../lib/spec.js').RefInfo;
51
+ export type Spec = import('../lib/spec.js').Spec;
52
+ export type Row = import('../lib/spec.js').Row;
53
+ export type SingleResult = import('../lib/operators.js').SingleResult;
54
+ export type ListResult = import('../lib/operators.js').ListResult;
38
55
  export type HandleStub = {
39
56
  id: string;
40
57
  type: string;
41
58
  name: string | null;
42
59
  };
60
+ export type Context = (Client | Handle) & Record<string, Ref>;
43
61
  /**
44
62
  * Re-initialize a `Client` from a recovery phrase. Closes the existing
45
63
  * local state and reseeds identity from the phrase.
@@ -56,13 +74,18 @@ declare class LocalRefs {
56
74
  parent: Client;
57
75
  spec: import("@cero-base/core").Spec;
58
76
  store: this;
59
- _local: boolean;
77
+ /** @private */
78
+ _local;
60
79
  /** @param {Client} client */
61
80
  constructor(client: Client);
62
81
  /** Underlying RPC channel borrowed from the parent. */
63
- get rpc(): any;
64
- /** Root handle id (local ops are resolved against the root's local store). */
65
- get id(): any;
82
+ get rpc(): object;
83
+ /**
84
+ * The root's id: local ops resolve against the root's local store.
85
+ *
86
+ * @returns {string | null}
87
+ */
88
+ get id(): string | null;
66
89
  }
67
90
  /**
68
91
  * IPC-side RPC client for cero. Wraps an `hrpc` channel and exposes the same
@@ -70,55 +93,60 @@ declare class LocalRefs {
70
93
  * across the wire.
71
94
  */
72
95
  export declare class Client extends RPCClient {
73
- operators: Record<string, any>;
74
- id: any;
75
- deviceId: any;
96
+ /** @private */
97
+ _onerror;
98
+ /** @type {string | null} */
99
+ id: string | null;
100
+ /** @type {{ id: string, name: string | null } | null} */
101
+ device: {
102
+ id: string;
103
+ name: string | null;
104
+ } | null;
76
105
  store: this;
77
106
  local: LocalRefs;
78
- _fileBase: any;
79
- _fileToken: any;
80
- identity: {
81
- id: any;
82
- toPhrase: () => Promise<any>;
83
- };
107
+ /** @private */
108
+ _fileBase;
109
+ /** @private */
110
+ _fileToken;
84
111
  /**
85
- * @param {any} ipc Framed IPC stream (must be writable).
112
+ * @param {import('streamx').Duplex} ipc Framed IPC stream (must be writable).
86
113
  * @param {Spec} spec Compiled cero spec (schema + rpc + handles).
87
- * @param {{ operators?: Record<string, any> }} [opts] The operators to bind, instead of the ones the spec carries.
114
+ * @param {{ onerror?: (err: Error) => void }} [opts] Where the worker's background errors go; the console without one.
88
115
  */
89
- constructor(ipc: any, spec: Spec, opts?: {
90
- operators?: Record<string, any>;
116
+ constructor(ipc: import('streamx').Duplex, spec: Spec, { onerror }?: {
117
+ onerror?: (err: Error) => void;
91
118
  });
92
- _pumpErrors(): void;
93
- _open(): Promise<void>;
94
- /** Pause networking and storage on the server. Idempotent. */
95
- suspend(): Promise<void>;
96
- /** Resume a suspended server. Idempotent. */
97
- resume(): Promise<void>;
119
+ /** @private */
120
+ private _pumpErrors;
121
+ /** @private */
122
+ private _open;
98
123
  /**
99
124
  * Create a new child handle of the given type.
100
125
  *
101
126
  * @param {string} type
102
- * @param {Record<string, any>} [opts]
127
+ * @param {{ name?: string | null }} [opts]
103
128
  * @returns {Promise<Handle>}
129
+ * @private
104
130
  */
105
- _create(type: string, opts?: Record<string, any>): Promise<Handle>;
131
+ private _create;
106
132
  /**
107
133
  * Load an existing child handle by id.
108
134
  *
109
135
  * @param {string} type
110
136
  * @param {string} id
111
137
  * @returns {Promise<Handle>}
138
+ * @private
112
139
  */
113
- _load(type: string, id: string): Promise<Handle>;
140
+ private _load;
114
141
  /**
115
142
  * Join a child handle via invite.
116
143
  *
117
144
  * @param {string} invite
118
145
  * @param {string} type
119
146
  * @returns {Promise<Handle>}
147
+ * @private
120
148
  */
121
- _join(invite: string, type: string): Promise<Handle>;
149
+ private _join;
122
150
  }
123
151
  /**
124
152
  * Client-side proxy for a remote handle. Exposes the same row-ops surface as `Client` but
@@ -130,7 +158,7 @@ declare class Handle {
130
158
  id: string;
131
159
  type: string;
132
160
  name: string;
133
- spec: Spec;
161
+ spec: import("../lib/spec.js").Spec;
134
162
  store: this;
135
163
  /**
136
164
  * @param {Client} parent
@@ -140,47 +168,36 @@ declare class Handle {
140
168
  */
141
169
  constructor(parent: Client, id: string, type: string, name: string | null);
142
170
  /** Underlying RPC channel borrowed from the parent. */
143
- get rpc(): any;
144
- /** Tear down the remote handle without leaving the room. */
171
+ get rpc(): object;
145
172
  close(): any;
146
- /** Tear down the remote handle and drop membership. */
147
- leave(): any;
148
173
  }
149
174
  /**
150
175
  * Construct a `Client`, wait for `init` to complete, and return it.
151
176
  *
152
- * @param {any} ipc
153
- * @param {object} spec
154
- * @param {{ operators?: Record<string, any> }} [opts]
177
+ * @param {import('streamx').Duplex} ipc
178
+ * @param {Spec} spec
179
+ * @param {{ onerror?: (err: Error) => void }} [opts]
155
180
  * @returns {Promise<Client>}
156
181
  */
157
- export declare function connect(ipc: any, spec: object, opts?: {
158
- operators?: Record<string, any>;
182
+ export declare function connect(ipc: import('streamx').Duplex, spec: Spec, opts?: {
183
+ onerror?: (err: Error) => void;
159
184
  }): Promise<Client>;
160
185
  /**
161
186
  * Symmetric client entry. Mirrors the main `cero`, but `cero(ipc, spec)` connects to a
162
187
  * server (via `connect`) instead of opening a local store.
163
188
  *
164
- * @param {any} ipc Framed IPC duplex stream.
165
- * @param {any} spec Built cero spec.
166
- * @param {{ operators?: Record<string, any> }} [opts]
167
- * @returns {Promise<Client>}
189
+ * @param {import('streamx').Duplex} ipc Framed IPC duplex stream.
190
+ * @param {Spec} spec Built cero spec.
191
+ * @param {{ onerror?: (err: Error) => void }} [opts]
192
+ * @returns {Promise<Context>}
168
193
  */
169
- export declare function cero(ipc: any, spec: any, opts?: {
170
- operators?: Record<string, any>;
171
- }): Promise<Client>;
172
- export declare namespace cero {
173
- export { connect };
174
- export { restore };
175
- export { t };
176
- export { put };
177
- export { set };
178
- export { get };
179
- export { del };
180
- export { watch };
181
- export { changes };
182
- export { call };
183
- export { open };
184
- export { rotate };
185
- export { schema };
186
- }
194
+ declare function start(ipc: import('streamx').Duplex, spec: Spec, opts?: {
195
+ onerror?: (err: Error) => void;
196
+ }): Promise<Context>;
197
+ /** @type {typeof start & typeof remote & { connect: typeof connect, restore: typeof restore, t: typeof t, schema: typeof schema }} */
198
+ export declare const cero: typeof start & typeof remote & {
199
+ connect: typeof connect;
200
+ restore: typeof restore;
201
+ t: typeof t;
202
+ schema: typeof schema;
203
+ };
@@ -28,13 +28,20 @@ export type Identity = {
28
28
  * Per-device id (empty when no `local` spec).
29
29
  */
30
30
  deviceId: string;
31
+ /**
32
+ * This device's name, empty when it has none.
33
+ */
34
+ deviceName: string;
31
35
  };
32
36
  export type RefAndCodec = {
33
- ref: any;
34
- codec: any;
37
+ ref: import('../lib/refs.js').Ref;
38
+ codec: import('@cero-base/core/rpc').Codec;
39
+ info?: import('../lib/spec.js').RefInfo;
35
40
  };
41
+ export type Spec = import('../lib/spec.js').Spec;
42
+ export type Context = import('../handle/index.js').Context;
36
43
  export type GetResult = {
37
- data: any;
44
+ data: import('../lib/spec.js').Row | import('../lib/spec.js').Row[] | null;
38
45
  total?: number;
39
46
  size?: number;
40
47
  };
@@ -51,74 +58,103 @@ export type GetResult = {
51
58
  * @typedef {object} Identity
52
59
  * @property {string} id Long-lived cero identity id.
53
60
  * @property {string} deviceId Per-device id (empty when no `local` spec).
61
+ * @property {string} deviceName This device's name, empty when it has none.
62
+ *
63
+ * @typedef {{ ref: import('../lib/refs.js').Ref, codec: import('@cero-base/core/rpc').Codec, info?: import('../lib/spec.js').RefInfo }} RefAndCodec
54
64
  *
55
- * @typedef {{ ref: any, codec: any }} RefAndCodec
65
+ * @typedef {import('../lib/spec.js').Spec} Spec
66
+ * @typedef {import('../handle/index.js').Context} Context
56
67
  *
57
- * @typedef {{ data: any, total?: number, size?: number }} GetResult Single-ref get omits `total`/`size`; list/handle refs include them.
68
+ * @typedef {{ data: import('../lib/spec.js').Row | import('../lib/spec.js').Row[] | null, total?: number, size?: number }} GetResult Single-ref get omits `total`/`size`; list/handle refs include them.
58
69
  */
59
70
  /**
60
- * IPC-side RPC server for cero. Bridges an `hrpc` channel to a live `Handle` tree:
61
- * lazy-initializes the root via `cero()` on the first `init` call, then exposes data ops,
62
- * pairing, and handle lifecycle.
71
+ * IPC-side RPC server for cero. Bridges an `hrpc` channel to a live `Handle` tree: boots the
72
+ * root via `cero()` as soon as it opens, so the network is up while the UI still loads, then
73
+ * exposes data ops, pairing, and handle lifecycle.
63
74
  */
64
75
  export declare class Server extends RPCServer {
65
76
  storage: string;
66
- _report: (err: Error) => void;
67
- opts: {
68
- name?: string;
69
- bootstrap?: Array<{
70
- host: string;
71
- port: number;
72
- }>;
73
- isMobile?: boolean;
74
- onerror: (err: any) => void;
77
+ /** @private */
78
+ _report;
79
+ /** @type {Omit<Partial<ServerOpts>, 'storage'> & { onerror: (err: Error) => void }} */
80
+ opts: Omit<Partial<ServerOpts>, 'storage'> & {
81
+ onerror: (err: Error) => void;
75
82
  };
76
83
  /** @type {Set<object>} open error streams, one per connected client */
77
84
  _errors: Set<object>;
78
- me: import("../handle/index.js").CeroHandle;
79
- handles: Map<any, any>;
85
+ /** @type {Context | null} */
86
+ me: Context | null;
87
+ /** @type {Map<string, Context>} */
88
+ handles: Map<string, Context>;
80
89
  /** @type {Map<string, Set<object>>} handle id → its open watch streams */
81
90
  _watchStreams: Map<string, Set<object>>;
91
+ /** @private */
92
+ _booting;
82
93
  /**
83
- * @param {any} ipc Framed IPC stream (must be writable).
84
- * @param {object} spec
94
+ * @param {import('streamx').Duplex} ipc Framed IPC stream (must be writable).
95
+ * @param {Spec} spec
85
96
  * @param {Partial<ServerOpts>} [opts]
86
97
  */
87
- constructor(ipc: any, spec: object, { storage, ...opts }?: Partial<ServerOpts>);
98
+ constructor(ipc: import('streamx').Duplex, spec: Spec, { storage, ...opts }?: Partial<ServerOpts>);
88
99
  /**
89
- * Root cero id (null until `init` has run).
100
+ * Root cero id (undefined until booted).
90
101
  *
91
102
  * @returns {string|undefined}
92
103
  */
93
104
  get id(): string | undefined;
94
105
  /**
95
- * Root identity object (null until `init` has run).
106
+ * Root identity object (undefined until booted).
96
107
  *
97
- * @returns {any}
98
- */
99
- get identity(): any;
100
- _close(): Promise<void>;
101
- /** End every watch stream bound to a handle (e.g. when it closes or leaves). */
102
- _endWatches(handle: any): void;
103
- /** Wire the `init` handler that lazily constructs the root cero handle. */
104
- _onerror(err: any): void;
105
- _wireInit(): void;
106
- /** Wire the `restore` handler that rebuilds the local store from a phrase. */
107
- _wireRestore(): void;
108
- /** Register the row-level RPC handlers (put/set/get/del/watch/call). */
109
- _wireData(): void;
110
- /** Register invite/revoke/join RPC handlers. */
111
- _wirePairing(): void;
112
- /** Register add/open/close/leave RPC handlers for child handles. */
113
- _wireHandles(): void;
108
+ * @returns {import('@cero-base/core/identity').Identity | undefined}
109
+ */
110
+ get identity(): import('@cero-base/core/identity').Identity | undefined;
111
+ /** @private */
112
+ private _open;
113
+ /** @private */
114
+ private _boot;
115
+ /** @private */
116
+ private _close;
117
+ /**
118
+ * End every watch stream bound to a handle (e.g. when it closes or leaves).
119
+ * @private
120
+ */
121
+ private _endWatches;
122
+ /** @private */
123
+ private _onerror;
124
+ /**
125
+ * Wire the `errors` and `init` handlers: init waits for the boot and attaches the client.
126
+ * @private
127
+ */
128
+ private _wireInit;
129
+ /**
130
+ * Wire the `restore` handler. The phrase becomes a seed here: the UI cannot load the crypto it takes.
131
+ * @private
132
+ */
133
+ private _wireRestore;
134
+ /**
135
+ * Register the row-level RPC handlers (put/set/get/del/watch/call).
136
+ * @private
137
+ */
138
+ private _wireData;
139
+ /**
140
+ * Register invite/revoke/join RPC handlers.
141
+ * @private
142
+ */
143
+ private _wirePairing;
144
+ /**
145
+ * Register add/open/close/leave RPC handlers for child handles.
146
+ * @private
147
+ */
148
+ private _wireHandles;
114
149
  /**
115
150
  * Look up a live handle by id, throwing if unknown. Binds the handle's
116
151
  * codec on first use.
117
152
  *
118
153
  * @param {string} id
119
- * @returns {any}
154
+ * @returns {Context}
155
+ * @private
120
156
  */
121
- _resolve(id: string): any;
157
+ private _resolve;
122
158
  /**
123
159
  * Resolve a `{ handle, ref }` pair to its `Ref` and codec.
124
160
  *
@@ -126,23 +162,28 @@ export declare class Server extends RPCServer {
126
162
  * @param {string} name
127
163
  * @param {boolean} [local]
128
164
  * @returns {RefAndCodec}
165
+ * @private
129
166
  */
130
- _refOf(id: string, name: string, local?: boolean): RefAndCodec;
167
+ private _refOf;
131
168
  /**
132
169
  * Snapshot the current identity for return to the client.
133
170
  *
134
171
  * @returns {Identity}
172
+ * @private
173
+ */
174
+ private _identity;
175
+ /**
176
+ * Wire the on-demand `seed` handler — surfaces the recovery phrase only when asked.
177
+ * @private
135
178
  */
136
- _identity(): Identity;
137
- /** Wire the on-demand `seed` handler — surfaces the recovery phrase only when asked. */
138
- _wireSeed(): void;
179
+ private _wireSeed;
139
180
  }
140
181
  /**
141
182
  * Construct a `Server`, wait for it to be ready, and return it.
142
183
  *
143
- * @param {any} ipc
144
- * @param {object} spec
184
+ * @param {import('streamx').Duplex} ipc
185
+ * @param {Spec} spec
145
186
  * @param {ServerOpts} opts
146
187
  * @returns {Promise<Server>}
147
188
  */
148
- export declare function serve(ipc: any, spec: object, opts: ServerOpts): Promise<Server>;
189
+ export declare function serve(ipc: import('streamx').Duplex, spec: Spec, opts: ServerOpts): Promise<Server>;
package/src/rpc/index.js DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * RPC barrel — re-exports the `Server`/`Client` classes and their `serve()`/`connect()`
3
- * helpers so consumers can spin up either side of the cero IPC bridge from a single
4
- * import.
5
- */
6
-
7
- export { Server, serve } from './server.js'
8
- export { Client, connect } from './client.js'
@@ -1,7 +0,0 @@
1
- /**
2
- * RPC barrel — re-exports the `Server`/`Client` classes and their `serve()`/`connect()`
3
- * helpers so consumers can spin up either side of the cero IPC bridge from a single
4
- * import.
5
- */
6
- export { Server, serve } from './server.js';
7
- export { Client, connect } from './client.js';