@phreshos/client 0.1.48 → 0.1.49
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/dist/appearance.d.ts +1 -0
- package/dist/domain.js +11 -6
- package/dist/system.js +67 -28
- package/package.json +3 -3
package/dist/appearance.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export default class ClientAppearance extends Events<AppearanceEvents, never> im
|
|
|
10
10
|
shadow: import("@phreshos/core").ThemedValue<import("@phreshos/core").AppearanceShadow>;
|
|
11
11
|
material: import("@phreshos/core").ThemedValue<import("@phreshos/core").AppearanceMaterial>;
|
|
12
12
|
transaction: import("@phreshos/core").AppearanceTransaction;
|
|
13
|
+
taskbar: import("@phreshos/core").AppearanceTaskbar;
|
|
13
14
|
signInWallpaper: import("@phreshos/core").ThemedValue<string | null>;
|
|
14
15
|
desktopWallpaper: import("@phreshos/core").ThemedValue<string | null>;
|
|
15
16
|
}>>;
|
package/dist/domain.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientEndpoint as CoreClientEndpoint, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, ServerEndpoint as CoreServerEndpoint, parseEndpointReference, parseProcessSnapshot, parseProgramDefinition, parseProgramSnapshot, } from "@phreshos/core";
|
|
1
|
+
import { ClientEndpoint as CoreClientEndpoint, Endpoint as CoreEndpoint, Process as CoreProcess, Program as CoreProgram, ServerEndpoint as CoreServerEndpoint, parseEndpointReference, parseProcessSnapshot, parseProgramDefinition, parsePermissions, parseProgramSnapshot, } from "@phreshos/core";
|
|
2
2
|
import Events, { stream } from "./events.js";
|
|
3
3
|
import Deadline from "./deadline.js";
|
|
4
4
|
import HandleRegistry from "./handle-registry.js";
|
|
@@ -321,7 +321,7 @@ class WindowHandle extends Events {
|
|
|
321
321
|
}
|
|
322
322
|
async title() { return (await this.state()).title; }
|
|
323
323
|
async header() { return (await this.state()).header; }
|
|
324
|
-
async
|
|
324
|
+
async surface() { return (await this.state()).surface; }
|
|
325
325
|
async transaction() { return (await this.state()).transaction; }
|
|
326
326
|
async position() { return (await this.state()).position; }
|
|
327
327
|
async size() { return (await this.state()).size; }
|
|
@@ -336,7 +336,7 @@ class WindowHandle extends Events {
|
|
|
336
336
|
async maximize(maximized = true) { await wire.request(["maximize", await this.target(), maximized]); }
|
|
337
337
|
async setTitle(title) { await wire.request(["setTitle", await this.target(), title]); }
|
|
338
338
|
async setHeader(header) { await wire.request(["setHeader", await this.target(), header]); }
|
|
339
|
-
async
|
|
339
|
+
async setSurface(surface) { await wire.request(["setSurface", await this.target(), surface]); }
|
|
340
340
|
async setTransaction(transaction) { await wire.request(["setTransaction", await this.target(), transaction]); }
|
|
341
341
|
async raise() { await wire.request(["raise", await this.target()]); }
|
|
342
342
|
}
|
|
@@ -365,7 +365,7 @@ class WindowPresentationHandle extends Events {
|
|
|
365
365
|
}
|
|
366
366
|
async title() { return await this.read("title"); }
|
|
367
367
|
async header() { return await this.read("header"); }
|
|
368
|
-
async
|
|
368
|
+
async surface() { return await this.read("surface"); }
|
|
369
369
|
async position() { return await this.read("position"); }
|
|
370
370
|
async size() { return await this.read("size"); }
|
|
371
371
|
async minimized() { return await this.read("minimized"); }
|
|
@@ -379,7 +379,7 @@ class WindowPresentationHandle extends Events {
|
|
|
379
379
|
async maximize(maximized = true) { await this.change("windowPresentationMaximize", maximized); }
|
|
380
380
|
async setTitle(title) { await this.change("windowPresentationTitle", title); }
|
|
381
381
|
async setHeader(header) { await this.change("windowPresentationHeader", header); }
|
|
382
|
-
async
|
|
382
|
+
async setSurface(surface) { await this.change("windowPresentationSurface", surface); }
|
|
383
383
|
async follow() { await this.change("windowPresentationFollow"); }
|
|
384
384
|
async unfollow() { await this.change("windowPresentationUnfollow"); }
|
|
385
385
|
async raise() { await this.change("windowPresentationRaise"); }
|
|
@@ -414,7 +414,7 @@ function deferredScoped(route, target, convert) {
|
|
|
414
414
|
];
|
|
415
415
|
}
|
|
416
416
|
function windowEvent(event) {
|
|
417
|
-
return event === "move" || event === "resize" || event === "minimize" || event === "maximize" || event === "changeTitle" || event === "changeHeader" || event === "
|
|
417
|
+
return event === "move" || event === "resize" || event === "minimize" || event === "maximize" || event === "changeTitle" || event === "changeHeader" || event === "changeSurface" || event === "changeTransaction" || event === "front";
|
|
418
418
|
}
|
|
419
419
|
function deferred(target, register, impossible) {
|
|
420
420
|
let active = true;
|
|
@@ -493,6 +493,11 @@ function programEvent(event, values) {
|
|
|
493
493
|
return { purge: values[0] === true };
|
|
494
494
|
if (event === "pinned")
|
|
495
495
|
return values[0] === true;
|
|
496
|
+
if (event === "permissions") {
|
|
497
|
+
const record = values[0];
|
|
498
|
+
program(record);
|
|
499
|
+
return parsePermissions(record.permissions);
|
|
500
|
+
}
|
|
496
501
|
return undefined;
|
|
497
502
|
}
|
|
498
503
|
function processEvent(event, values) {
|
package/dist/system.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseShellEvent, parseSessionEndSnapshot, execute as executeRequest } from "@phreshos/core";
|
|
1
|
+
import { parseShellEvent, parseAuthenticationRequirements, parseAuthenticationState, parsePermissions, parseSessionEndSnapshot, execute as executeRequest } from "@phreshos/core";
|
|
2
2
|
import ClientAppearance from "./appearance.js";
|
|
3
3
|
import wire from "./wire.js";
|
|
4
4
|
import { prepareService } from "./service.js";
|
|
@@ -13,8 +13,7 @@ class ClientSystem {
|
|
|
13
13
|
appearance = new ClientAppearance();
|
|
14
14
|
program = new SystemProgramHandle();
|
|
15
15
|
process = new SystemProcessHandle();
|
|
16
|
-
|
|
17
|
-
session = new SystemSessionHandle();
|
|
16
|
+
authentication = new SystemAuthenticationHandle();
|
|
18
17
|
service = new SystemServiceHandle();
|
|
19
18
|
uploads = uploads;
|
|
20
19
|
network = network;
|
|
@@ -84,37 +83,52 @@ class SystemProcessHandle extends Events {
|
|
|
84
83
|
return answer[0] ? process(answer[0]) : null;
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
class
|
|
86
|
+
class SystemAuthenticationHandle extends Events {
|
|
88
87
|
constructor() {
|
|
89
|
-
super((event, listener, impossible) =>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
super((event, listener, impossible) => {
|
|
89
|
+
const [route, sourceEvent] = authenticationEventRoute(event);
|
|
90
|
+
return wire.on(route, sourceEvent, (...values) => listener(systemAuthenticationEvent(route, sourceEvent, values)), null, impossible);
|
|
91
|
+
}, (observer, impossible) => {
|
|
92
|
+
const stops = ["host-connection", "host-session"].map(route => wire.onAll(route, (event, ...values) => {
|
|
93
|
+
if (typeof event !== "string")
|
|
94
|
+
return;
|
|
95
|
+
const name = authenticationEventName(route, event);
|
|
96
|
+
if (name)
|
|
97
|
+
observer(name, systemAuthenticationEvent(route, event, values));
|
|
98
|
+
}, null, impossible));
|
|
99
|
+
return () => stops.forEach(stop => stop());
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async state() {
|
|
103
|
+
const [value] = await wire.request(["host-authentication-state"]);
|
|
104
|
+
return parseAuthenticationState(value);
|
|
105
|
+
}
|
|
106
|
+
async requirements() {
|
|
107
|
+
const [value] = await wire.request(["host-authentication-requirements"]);
|
|
108
|
+
return parseAuthenticationRequirements(value);
|
|
109
|
+
}
|
|
110
|
+
async connections() {
|
|
111
|
+
const [snapshots] = await wire.request(["host-authentication-connections"]);
|
|
96
112
|
return snapshots.map(connection);
|
|
97
113
|
}
|
|
98
|
-
async
|
|
99
|
-
const [snapshot] = await wire.request(["host-connection
|
|
114
|
+
async connection(identity) {
|
|
115
|
+
const [snapshot] = await wire.request(["host-authentication-connection", identity]);
|
|
100
116
|
return snapshot === null ? null : connection(snapshot);
|
|
101
117
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
constructor() {
|
|
105
|
-
super((event, listener, impossible) => wire.on("host-session", event, (...values) => listener(systemSessionEvent(event, values)), null, impossible), observer => wire.onAll("host-session", (event, ...values) => {
|
|
106
|
-
if (typeof event === "string")
|
|
107
|
-
observer(event, systemSessionEvent(event, values));
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
async list() {
|
|
111
|
-
const [snapshots] = await wire.request(["host-session-list"]);
|
|
118
|
+
async sessions() {
|
|
119
|
+
const [snapshots] = await wire.request(["host-authentication-sessions"]);
|
|
112
120
|
return snapshots.map(session);
|
|
113
121
|
}
|
|
114
|
-
async
|
|
115
|
-
const [snapshot] = await wire.request(["host-session
|
|
122
|
+
async session(identity) {
|
|
123
|
+
const [snapshot] = await wire.request(["host-authentication-session", identity]);
|
|
116
124
|
return snapshot === null ? null : session(snapshot);
|
|
117
125
|
}
|
|
126
|
+
async setCredentials(credentials) {
|
|
127
|
+
await wire.request(["host-authentication-set-credentials", credentials]);
|
|
128
|
+
}
|
|
129
|
+
async signOutAllSessions() {
|
|
130
|
+
await wire.request(["host-authentication-sign-out-all-sessions"]);
|
|
131
|
+
}
|
|
118
132
|
}
|
|
119
133
|
function systemProcessEvent(event, values) {
|
|
120
134
|
if (event === "create")
|
|
@@ -130,12 +144,37 @@ function systemProgramEvent(event, values) {
|
|
|
130
144
|
return { program: program(values[1]), purge: values[2] === true };
|
|
131
145
|
if (event === "pinned")
|
|
132
146
|
return { program: program(values[1]), pinned: values[2] === true };
|
|
147
|
+
if (event === "permissions") {
|
|
148
|
+
const handle = program(values[1]);
|
|
149
|
+
return { program: handle, permissions: parsePermissions(values[1].permissions) };
|
|
150
|
+
}
|
|
133
151
|
return values[0];
|
|
134
152
|
}
|
|
135
|
-
function
|
|
136
|
-
|
|
153
|
+
function authenticationEventRoute(event) {
|
|
154
|
+
if (event === "connectionCreate")
|
|
155
|
+
return ["host-connection", "create"];
|
|
156
|
+
if (event === "connectionDisconnect")
|
|
157
|
+
return ["host-connection", "disconnect"];
|
|
158
|
+
if (event === "sessionCreate")
|
|
159
|
+
return ["host-session", "create"];
|
|
160
|
+
if (event === "sessionEnd")
|
|
161
|
+
return ["host-session", "end"];
|
|
162
|
+
throw new Error(`The Authentication domain does not expose a ${event} event`);
|
|
163
|
+
}
|
|
164
|
+
function authenticationEventName(route, event) {
|
|
165
|
+
if (route === "host-connection" && event === "create")
|
|
166
|
+
return "connectionCreate";
|
|
167
|
+
if (route === "host-connection" && event === "disconnect")
|
|
168
|
+
return "connectionDisconnect";
|
|
169
|
+
if (route === "host-session" && event === "create")
|
|
170
|
+
return "sessionCreate";
|
|
171
|
+
if (route === "host-session" && event === "end")
|
|
172
|
+
return "sessionEnd";
|
|
173
|
+
return null;
|
|
137
174
|
}
|
|
138
|
-
function
|
|
175
|
+
function systemAuthenticationEvent(route, event, values) {
|
|
176
|
+
if (route === "host-connection")
|
|
177
|
+
return connection(values[1]);
|
|
139
178
|
const handle = session(values[1]);
|
|
140
179
|
return event === "end" ? { session: handle, reason: parseSessionEndSnapshot({ ...values[1], reason: values[2] }).reason } : handle;
|
|
141
180
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/client",
|
|
3
|
-
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"description": "The SDK used by a Program's client endpoint.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"test": "vitest run --project default"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
|
|
49
|
+
"@phreshos/core": "^0.1.58"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@the-link/messagepack": "^0.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
|
|
55
|
+
"@phreshos/core": "^0.1.58",
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
57
|
"vitest": "^4.1.10"
|
|
58
58
|
}
|