@snap-rail/protocol 0.1.1 → 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.
- package/lib/index.js +45 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/surfaces.d.ts +43 -0
- package/lib/types/surfaces.js +43 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
import { defineContract, method } from "./contract.js";
|
|
2
2
|
import { RpcBusinessError, RpcId, err, isRpcError, ok } from "./rpc.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
//#region lib/types/surfaces.js
|
|
5
|
+
/**
|
|
6
|
+
* The surface vocabulary: one renderer window role. `main` is the operator
|
|
7
|
+
* window (the app's only always-present surface); `ball` is the auxiliary
|
|
8
|
+
* always-on-top surface a plugin drives through the Shell seam — the floating
|
|
9
|
+
* ball.
|
|
10
|
+
*
|
|
11
|
+
* A surface is an identity, not a layout. Every surface boots the same
|
|
12
|
+
* renderer with its own client entry (`snapRail.client.surfaces`) and its own
|
|
13
|
+
* seed set; a plugin face binds to exactly one surface and reads
|
|
14
|
+
* `ctx.client.surface` to know which. Auxiliary surfaces never subscribe to
|
|
15
|
+
* equipment points directly — they consume host-aggregated frames, because a
|
|
16
|
+
* hidden surface must not keep a data path alive and a shown one must not
|
|
17
|
+
* need a second subscription graph.
|
|
18
|
+
*
|
|
19
|
+
* The whitelist is closed on purpose: a plugin may not name an arbitrary URL
|
|
20
|
+
* or spawn an arbitrary window — the Shell owns every window and only these
|
|
21
|
+
* two roles exist.
|
|
22
|
+
*
|
|
23
|
+
* @module @snap-rail/protocol/surfaces
|
|
24
|
+
*/
|
|
25
|
+
/** Every surface id, in boot order (`main` first). */
|
|
26
|
+
const SURFACE_IDS = ["main", "ball"];
|
|
27
|
+
/** The always-on-top auxiliary surfaces: windows the Shell creates lazily. */
|
|
28
|
+
const AUX_SURFACE_IDS = ["ball"];
|
|
29
|
+
/**
|
|
30
|
+
* Whether a wire value names a surface.
|
|
31
|
+
*
|
|
32
|
+
* @param value - the candidate (any wire value).
|
|
33
|
+
* @returns true when the value is a {@link SurfaceId}.
|
|
34
|
+
*/
|
|
35
|
+
function isSurfaceId(value) {
|
|
36
|
+
return typeof value === "string" && SURFACE_IDS.includes(value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether a wire value names an auxiliary surface.
|
|
40
|
+
*
|
|
41
|
+
* @param value - the candidate (any wire value).
|
|
42
|
+
* @returns true when the value is an {@link AuxSurfaceId}.
|
|
43
|
+
*/
|
|
44
|
+
function isAuxSurfaceId(value) {
|
|
45
|
+
return typeof value === "string" && AUX_SURFACE_IDS.includes(value);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
4
48
|
//#region lib/types/schemas.js
|
|
5
49
|
/**
|
|
6
50
|
* Envelope validation at the trust boundary: the type/rpcId/method
|
|
@@ -135,4 +179,4 @@ var InProcessApiClient = class extends AbstractApiClient {
|
|
|
135
179
|
}
|
|
136
180
|
};
|
|
137
181
|
//#endregion
|
|
138
|
-
export { AbstractApiClient, InProcessApiClient, RpcBusinessError, RpcId, RpcTransportError, defineContract, err, isRpcError, method, ok, parseClientRequest, parseServerRequest };
|
|
182
|
+
export { AUX_SURFACE_IDS, AbstractApiClient, InProcessApiClient, RpcBusinessError, RpcId, RpcTransportError, SURFACE_IDS, defineContract, err, isAuxSurfaceId, isRpcError, isSurfaceId, method, ok, parseClientRequest, parseServerRequest };
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The surface vocabulary: one renderer window role. `main` is the operator
|
|
3
|
+
* window (the app's only always-present surface); `ball` is the auxiliary
|
|
4
|
+
* always-on-top surface a plugin drives through the Shell seam — the floating
|
|
5
|
+
* ball.
|
|
6
|
+
*
|
|
7
|
+
* A surface is an identity, not a layout. Every surface boots the same
|
|
8
|
+
* renderer with its own client entry (`snapRail.client.surfaces`) and its own
|
|
9
|
+
* seed set; a plugin face binds to exactly one surface and reads
|
|
10
|
+
* `ctx.client.surface` to know which. Auxiliary surfaces never subscribe to
|
|
11
|
+
* equipment points directly — they consume host-aggregated frames, because a
|
|
12
|
+
* hidden surface must not keep a data path alive and a shown one must not
|
|
13
|
+
* need a second subscription graph.
|
|
14
|
+
*
|
|
15
|
+
* The whitelist is closed on purpose: a plugin may not name an arbitrary URL
|
|
16
|
+
* or spawn an arbitrary window — the Shell owns every window and only these
|
|
17
|
+
* two roles exist.
|
|
18
|
+
*
|
|
19
|
+
* @module @snap-rail/protocol/surfaces
|
|
20
|
+
*/
|
|
21
|
+
/** Every surface id, in boot order (`main` first). */
|
|
22
|
+
export declare const SURFACE_IDS: readonly ["main", "ball"];
|
|
23
|
+
/** The always-on-top auxiliary surfaces: windows the Shell creates lazily. */
|
|
24
|
+
export declare const AUX_SURFACE_IDS: readonly ["ball"];
|
|
25
|
+
/** One renderer window role. */
|
|
26
|
+
export type SurfaceId = (typeof SURFACE_IDS)[number];
|
|
27
|
+
/** One auxiliary surface role. */
|
|
28
|
+
export type AuxSurfaceId = (typeof AUX_SURFACE_IDS)[number];
|
|
29
|
+
/**
|
|
30
|
+
* Whether a wire value names a surface.
|
|
31
|
+
*
|
|
32
|
+
* @param value - the candidate (any wire value).
|
|
33
|
+
* @returns true when the value is a {@link SurfaceId}.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isSurfaceId(value: unknown): value is SurfaceId;
|
|
36
|
+
/**
|
|
37
|
+
* Whether a wire value names an auxiliary surface.
|
|
38
|
+
*
|
|
39
|
+
* @param value - the candidate (any wire value).
|
|
40
|
+
* @returns true when the value is an {@link AuxSurfaceId}.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isAuxSurfaceId(value: unknown): value is AuxSurfaceId;
|
|
43
|
+
//# sourceMappingURL=surfaces.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The surface vocabulary: one renderer window role. `main` is the operator
|
|
3
|
+
* window (the app's only always-present surface); `ball` is the auxiliary
|
|
4
|
+
* always-on-top surface a plugin drives through the Shell seam — the floating
|
|
5
|
+
* ball.
|
|
6
|
+
*
|
|
7
|
+
* A surface is an identity, not a layout. Every surface boots the same
|
|
8
|
+
* renderer with its own client entry (`snapRail.client.surfaces`) and its own
|
|
9
|
+
* seed set; a plugin face binds to exactly one surface and reads
|
|
10
|
+
* `ctx.client.surface` to know which. Auxiliary surfaces never subscribe to
|
|
11
|
+
* equipment points directly — they consume host-aggregated frames, because a
|
|
12
|
+
* hidden surface must not keep a data path alive and a shown one must not
|
|
13
|
+
* need a second subscription graph.
|
|
14
|
+
*
|
|
15
|
+
* The whitelist is closed on purpose: a plugin may not name an arbitrary URL
|
|
16
|
+
* or spawn an arbitrary window — the Shell owns every window and only these
|
|
17
|
+
* two roles exist.
|
|
18
|
+
*
|
|
19
|
+
* @module @snap-rail/protocol/surfaces
|
|
20
|
+
*/
|
|
21
|
+
/** Every surface id, in boot order (`main` first). */
|
|
22
|
+
export const SURFACE_IDS = ['main', 'ball'];
|
|
23
|
+
/** The always-on-top auxiliary surfaces: windows the Shell creates lazily. */
|
|
24
|
+
export const AUX_SURFACE_IDS = ['ball'];
|
|
25
|
+
/**
|
|
26
|
+
* Whether a wire value names a surface.
|
|
27
|
+
*
|
|
28
|
+
* @param value - the candidate (any wire value).
|
|
29
|
+
* @returns true when the value is a {@link SurfaceId}.
|
|
30
|
+
*/
|
|
31
|
+
export function isSurfaceId(value) {
|
|
32
|
+
return typeof value === 'string' && SURFACE_IDS.includes(value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether a wire value names an auxiliary surface.
|
|
36
|
+
*
|
|
37
|
+
* @param value - the candidate (any wire value).
|
|
38
|
+
* @returns true when the value is an {@link AuxSurfaceId}.
|
|
39
|
+
*/
|
|
40
|
+
export function isAuxSurfaceId(value) {
|
|
41
|
+
return typeof value === 'string' && AUX_SURFACE_IDS.includes(value);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=surfaces.js.map
|
package/package.json
CHANGED