@agentshouse/app-bridge 0.1.0-alpha.7 → 0.1.0-alpha.8
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/README.md +8 -2
- package/client/src/bridge.d.ts +1 -0
- package/client/src/bridge.js +20 -0
- package/client/src/test-host.d.ts +1 -0
- package/client/src/test-host.js +5 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The renderer-side client of the agents.house App bridge. An App served by House
|
|
4
4
|
receives one message port before its own scripts run; this package is that
|
|
5
|
-
port's one listener. It carries
|
|
5
|
+
port's one listener. It carries six families:
|
|
6
6
|
|
|
7
7
|
- **Navigation** - the part of the shell's URL below the App's path, with its
|
|
8
8
|
query and fragment. The shell delivers it when the App starts and whenever the
|
|
@@ -39,6 +39,11 @@ port's one listener. It carries five families:
|
|
|
39
39
|
refusal is House's `{ error: { code } }`, `app_release_not_found` for an
|
|
40
40
|
App with no release; a read House does not answer, or one that outlived
|
|
41
41
|
the browser's signed-in User, is `null`.
|
|
42
|
+
- **App screenshot read** - given an App reference, `readScreenshot(app)`
|
|
43
|
+
answers the image this browser captured of that App's screen the first time
|
|
44
|
+
it ran its current release, as a PNG `Blob` at most 1200 pixels wide, or
|
|
45
|
+
`null` when this browser holds none. The image stays in the browser; a Site
|
|
46
|
+
holds none.
|
|
42
47
|
|
|
43
48
|
The package carries no credential handling and no Runtime family. It surfaces
|
|
44
49
|
the dedicated Runtime port the worker transfers over the bridge as a plain
|
|
@@ -99,4 +104,5 @@ records in `consents` each
|
|
|
99
104
|
`gaConsent` it takes while that status measures and publishes the status the
|
|
100
105
|
choice leaves, records in `tabs` each `setTab` the shell would take and ignores
|
|
101
106
|
any other, answers a release code read from the `sources` it was given, or
|
|
102
|
-
`null`,
|
|
107
|
+
`null`, answers `readScreenshot` from the `screenshots` it was given by App
|
|
108
|
+
reference, and attaches a Runtime port.
|
package/client/src/bridge.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface HouseBridge {
|
|
|
24
24
|
readAttachment(room: string, attachment: string): Promise<HouseImageCopy | null>;
|
|
25
25
|
sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseSourceRefusal | null>;
|
|
26
26
|
sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseSourceRefusal | null>;
|
|
27
|
+
readScreenshot(app: string): Promise<Blob | null>;
|
|
27
28
|
status(): HouseStatus | null;
|
|
28
29
|
onStatus(listener: (status: HouseStatus) => void): () => void;
|
|
29
30
|
gaConsent(choice: HouseGaChoice): void;
|
package/client/src/bridge.js
CHANGED
|
@@ -35,6 +35,8 @@ export function connectHouseBridge(source = heldBridge()) {
|
|
|
35
35
|
let nextAttachment = 0;
|
|
36
36
|
const sources = new Map();
|
|
37
37
|
let nextSource = 0;
|
|
38
|
+
const screenshots = new Map();
|
|
39
|
+
let nextScreenshot = 0;
|
|
38
40
|
const addressListeners = new Set();
|
|
39
41
|
const statusListeners = new Set();
|
|
40
42
|
let outbox = [];
|
|
@@ -101,6 +103,17 @@ export function connectHouseBridge(source = heldBridge()) {
|
|
|
101
103
|
pending.resolve(answer.answer ?? null);
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
106
|
+
if (data.house === 'screenshot') {
|
|
107
|
+
const answer = data;
|
|
108
|
+
if (typeof answer.id !== 'number')
|
|
109
|
+
return;
|
|
110
|
+
const pending = screenshots.get(answer.id);
|
|
111
|
+
if (pending === undefined)
|
|
112
|
+
return;
|
|
113
|
+
screenshots.delete(answer.id);
|
|
114
|
+
pending.resolve(answer.image ?? null);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
104
117
|
if (data.house === 'ceremony-refused') {
|
|
105
118
|
const refused = data.path;
|
|
106
119
|
const named = typeof refused === 'string' ? refused : null;
|
|
@@ -170,6 +183,13 @@ export function connectHouseBridge(source = heldBridge()) {
|
|
|
170
183
|
sourceDownload(app, release) {
|
|
171
184
|
return readSource('source-download', app, release);
|
|
172
185
|
},
|
|
186
|
+
readScreenshot(app) {
|
|
187
|
+
const pending = settled();
|
|
188
|
+
const id = ++nextScreenshot;
|
|
189
|
+
screenshots.set(id, pending.settle);
|
|
190
|
+
send({ house: 'screenshot-read', id, app });
|
|
191
|
+
return pending.promise;
|
|
192
|
+
},
|
|
173
193
|
status() {
|
|
174
194
|
return status;
|
|
175
195
|
},
|
|
@@ -25,5 +25,6 @@ export interface HouseBridgeTestHostOptions {
|
|
|
25
25
|
readonly top: HouseSourceTop;
|
|
26
26
|
readonly download: HouseSourceDownload;
|
|
27
27
|
}[];
|
|
28
|
+
readonly screenshots?: Readonly<Record<string, Blob>>;
|
|
28
29
|
}
|
|
29
30
|
export declare function createHouseBridgeTestHost(options?: HouseBridgeTestHostOptions): HouseBridgeTestHost;
|
package/client/src/test-host.js
CHANGED
|
@@ -109,6 +109,11 @@ export function createHouseBridgeTestHost(options = {}) {
|
|
|
109
109
|
},
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
+
else if (data.house === 'screenshot-read') {
|
|
113
|
+
const asked = data;
|
|
114
|
+
const held = typeof asked.app === 'string' ? options.screenshots?.[asked.app] : undefined;
|
|
115
|
+
deliver({ house: 'screenshot', id: asked.id, image: held ?? null });
|
|
116
|
+
}
|
|
112
117
|
}
|
|
113
118
|
const port = {
|
|
114
119
|
postMessage(message) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/app-bridge",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
4
|
-
"description": "Renderer-side client of the agents.house App bridge: navigation, the tab title and icon, ceremonies, status, Site image reads and App
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
|
+
"description": "Renderer-side client of the agents.house App bridge: navigation, the tab title and icon, ceremonies, status, Site image reads, App release code and App screenshot reads, with an in-page test host.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|