@phreshos/client 0.1.48 → 0.1.50
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 +45 -37
- 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,8 +321,6 @@ 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 frame() { return (await this.state()).frame; }
|
|
325
|
-
async transaction() { return (await this.state()).transaction; }
|
|
326
324
|
async position() { return (await this.state()).position; }
|
|
327
325
|
async size() { return (await this.state()).size; }
|
|
328
326
|
async minimized() { return (await this.state()).minimized; }
|
|
@@ -336,24 +334,12 @@ class WindowHandle extends Events {
|
|
|
336
334
|
async maximize(maximized = true) { await wire.request(["maximize", await this.target(), maximized]); }
|
|
337
335
|
async setTitle(title) { await wire.request(["setTitle", await this.target(), title]); }
|
|
338
336
|
async setHeader(header) { await wire.request(["setHeader", await this.target(), header]); }
|
|
339
|
-
async setFrame(frame) { await wire.request(["setFrame", await this.target(), frame]); }
|
|
340
|
-
async setTransaction(transaction) { await wire.request(["setTransaction", await this.target(), transaction]); }
|
|
341
337
|
async raise() { await wire.request(["raise", await this.target()]); }
|
|
342
338
|
}
|
|
343
|
-
class WindowPresentationHandle
|
|
339
|
+
class WindowPresentationHandle {
|
|
344
340
|
target;
|
|
345
341
|
selected;
|
|
346
342
|
constructor(target, selected) {
|
|
347
|
-
super((event, listener, impossible) => {
|
|
348
|
-
if (!windowEvent(event)) {
|
|
349
|
-
impossible?.(new Error(`A Window presentation has no "${event}" event`));
|
|
350
|
-
return () => undefined;
|
|
351
|
-
}
|
|
352
|
-
return wire.on("presentation", event, listener, null, impossible);
|
|
353
|
-
}, (listener, impossible) => wire.onAll("presentation", (event, ...values) => {
|
|
354
|
-
if (typeof event === "string")
|
|
355
|
-
listener(event, values[0]);
|
|
356
|
-
}, null, impossible));
|
|
357
343
|
this.target = target;
|
|
358
344
|
this.selected = selected;
|
|
359
345
|
}
|
|
@@ -363,32 +349,49 @@ class WindowPresentationHandle extends Events {
|
|
|
363
349
|
transactionAndWait(transaction) {
|
|
364
350
|
return new WindowPresentationHandle(this.target, { transaction, wait: true });
|
|
365
351
|
}
|
|
366
|
-
async
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
async front() { return await this.read("front"); }
|
|
374
|
-
async layer() { return await this.read("layer"); }
|
|
352
|
+
async layer() {
|
|
353
|
+
const answer = await wire.request(["windowPresentationLayer", await this.target()]);
|
|
354
|
+
return answer[0];
|
|
355
|
+
}
|
|
356
|
+
beginMoveGesture(start) {
|
|
357
|
+
return new WindowMoveGestureHandle(this.target(), start);
|
|
358
|
+
}
|
|
375
359
|
async move(position) { await this.change("windowPresentationMove", position); }
|
|
376
360
|
async resize(size) { await this.change("windowPresentationResize", size); }
|
|
377
361
|
async setGeometry(geometry) { await this.change("windowPresentationGeometry", geometry); }
|
|
378
|
-
async
|
|
379
|
-
async maximize(maximized = true) { await this.change("windowPresentationMaximize", maximized); }
|
|
380
|
-
async setTitle(title) { await this.change("windowPresentationTitle", title); }
|
|
381
|
-
async setHeader(header) { await this.change("windowPresentationHeader", header); }
|
|
382
|
-
async setFrame(frame) { await this.change("windowPresentationFrame", frame); }
|
|
383
|
-
async follow() { await this.change("windowPresentationFollow"); }
|
|
384
|
-
async unfollow() { await this.change("windowPresentationUnfollow"); }
|
|
362
|
+
async setSurface(surface) { await this.change("windowPresentationSurface", surface); }
|
|
385
363
|
async raise() { await this.change("windowPresentationRaise"); }
|
|
386
364
|
async change(operation, value) {
|
|
387
|
-
await wire.request([operation, await this.target(), value, this.selected
|
|
365
|
+
await wire.request([operation, await this.target(), value, this.selected ?? null]);
|
|
388
366
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
367
|
+
}
|
|
368
|
+
class WindowMoveGestureHandle {
|
|
369
|
+
gesture = crypto.randomUUID();
|
|
370
|
+
address;
|
|
371
|
+
ready;
|
|
372
|
+
finished;
|
|
373
|
+
ended = false;
|
|
374
|
+
constructor(target, start) {
|
|
375
|
+
this.address = target;
|
|
376
|
+
this.ready = target.then(async (address) => {
|
|
377
|
+
await wire.request(["windowPresentationMoveGestureBegin", address, this.gesture, start]);
|
|
378
|
+
});
|
|
379
|
+
this.finished = this.ready.then(async () => {
|
|
380
|
+
await wire.request(["windowPresentationMoveGestureWait", await this.address, this.gesture]);
|
|
381
|
+
});
|
|
382
|
+
// A gesture may be abandoned by document teardown before its owner can end
|
|
383
|
+
// it. The boundary still owns cleanup; this only prevents an unhandled rejection.
|
|
384
|
+
void this.finished.catch(() => undefined);
|
|
385
|
+
void this.finished.then(() => { this.ended = true; }, () => { this.ended = true; });
|
|
386
|
+
}
|
|
387
|
+
cancel() {
|
|
388
|
+
if (this.ended)
|
|
389
|
+
return;
|
|
390
|
+
this.ended = true;
|
|
391
|
+
void this.ready.then(async () => {
|
|
392
|
+
const address = await this.address;
|
|
393
|
+
wire.send("end-host", "windowPresentationMoveGestureCancel", address, this.gesture);
|
|
394
|
+
}, () => undefined);
|
|
392
395
|
}
|
|
393
396
|
}
|
|
394
397
|
function deferredScoped(route, target, convert) {
|
|
@@ -414,7 +417,7 @@ function deferredScoped(route, target, convert) {
|
|
|
414
417
|
];
|
|
415
418
|
}
|
|
416
419
|
function windowEvent(event) {
|
|
417
|
-
return event === "move" || event === "resize" || event === "minimize" || event === "maximize" || event === "changeTitle" || event === "changeHeader" || event === "
|
|
420
|
+
return event === "move" || event === "resize" || event === "minimize" || event === "maximize" || event === "changeTitle" || event === "changeHeader" || event === "front";
|
|
418
421
|
}
|
|
419
422
|
function deferred(target, register, impossible) {
|
|
420
423
|
let active = true;
|
|
@@ -493,6 +496,11 @@ function programEvent(event, values) {
|
|
|
493
496
|
return { purge: values[0] === true };
|
|
494
497
|
if (event === "pinned")
|
|
495
498
|
return values[0] === true;
|
|
499
|
+
if (event === "permissions") {
|
|
500
|
+
const record = values[0];
|
|
501
|
+
program(record);
|
|
502
|
+
return parsePermissions(record.permissions);
|
|
503
|
+
}
|
|
496
504
|
return undefined;
|
|
497
505
|
}
|
|
498
506
|
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
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
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.59"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@the-link/messagepack": "^0.1.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
|
|
55
|
+
"@phreshos/core": "^0.1.59",
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
57
|
"vitest": "^4.1.10"
|
|
58
58
|
}
|