@assistant-ui/appos 0.0.1 → 0.0.2
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/chunks/src.js +365 -71
- package/dist/index.js +58 -14
- package/dist/next-page.js +1 -1
- package/dist/pack.js +8 -3
- package/dist/types/packages/appos-client/src/index.d.ts +270 -76
- package/dist/types/src/lib/pack.d.ts +1 -1
- package/dist/types/src/lib/swbn/manifest.d.ts +53 -15
- package/package.json +1 -1
|
@@ -5,21 +5,38 @@ export declare class CloudError extends Error {
|
|
|
5
5
|
readonly details: Record<string, unknown>;
|
|
6
6
|
constructor(code: string, message: string, status?: number, details?: Record<string, unknown>);
|
|
7
7
|
}
|
|
8
|
+
/** What is selected in an app (appos.setSelection): the words, and where they are. */
|
|
9
|
+
export interface Selection {
|
|
10
|
+
/** Where the text is: the file's address, or the app's own link to the document in it. No spaces. */
|
|
11
|
+
address: string;
|
|
12
|
+
/** The first and last line of it there, counting from 1. */
|
|
13
|
+
lines?: [number, number];
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
/** What is selected in the app that shows this page, with that app as the shell names it (appos.onSelection). */
|
|
17
|
+
export interface EmbeddedSelection extends Selection {
|
|
18
|
+
app: {
|
|
19
|
+
did: string;
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
8
23
|
/**
|
|
9
|
-
* The file this frame runs: one instance of the app. Local
|
|
24
|
+
* The file this frame runs: one instance of the app. Local live files of one
|
|
10
25
|
* app share its origin's storage, so keep each one's data under its id.
|
|
11
|
-
* The primary
|
|
12
|
-
*
|
|
13
|
-
* appos.
|
|
26
|
+
* The primary live file (the app's first) owns what the origin held before
|
|
27
|
+
* live files existed. A cloud live file is a LiveWorker someone shared: open it with
|
|
28
|
+
* appos.liveWorkers.open(liveFile.actor).
|
|
14
29
|
*/
|
|
15
30
|
/** One file in appos.files.all(): where it is and what it is, never its data. */
|
|
16
31
|
export interface IndexedFile {
|
|
17
32
|
key: string;
|
|
18
33
|
title: string;
|
|
34
|
+
/** `ext`: the app's appos.extension, shown after the name; never part of it. */
|
|
19
35
|
app: {
|
|
20
36
|
did: string;
|
|
21
37
|
name: string;
|
|
22
38
|
icon?: string;
|
|
39
|
+
ext?: string;
|
|
23
40
|
};
|
|
24
41
|
/** "device", "cloud" or a host's name. */
|
|
25
42
|
host: string;
|
|
@@ -34,24 +51,119 @@ export interface IndexedFile {
|
|
|
34
51
|
workspace?: number;
|
|
35
52
|
/** Its app isn't on this device yet: opening the file gets it. */
|
|
36
53
|
install?: true;
|
|
54
|
+
/** Open to the web (appos.requestOpenWeb()); the Files app closes it with appos.files.closeOpenWeb(key). */
|
|
55
|
+
openWeb?: true;
|
|
56
|
+
/** The user's role in it, when its host says. The owner renames, moves, shares and deletes it. */
|
|
57
|
+
role?: "owner" | "editor" | "viewer";
|
|
58
|
+
/** The folder it is in on its host, by id; at the top when absent. */
|
|
59
|
+
folder?: string;
|
|
60
|
+
/** Its address, for whoever may open it: <host>/<owner's handle>/<folders>/<name>.<ext>. */
|
|
61
|
+
url?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* One of this app's own files (appos.files.list(), appos.files.recent()): what it is and where, never its data. Open
|
|
65
|
+
* it with appos.files.open(file.address).
|
|
66
|
+
*/
|
|
67
|
+
export interface AppFile {
|
|
68
|
+
name: string;
|
|
69
|
+
/** Its folder's path on its host ("Work/Plans"); "" at the top, and for a file someone shared with the person. */
|
|
70
|
+
folder: string;
|
|
71
|
+
/** Where it is, as people read it: "appOS cloud", "This device" or a host's name. */
|
|
72
|
+
host: string;
|
|
73
|
+
/** When it last changed (ms), to the minute, when its host keeps that (the appOS cloud does). */
|
|
74
|
+
updatedAt?: number;
|
|
75
|
+
/** When the person last opened it on this device (ms). */
|
|
76
|
+
openedAt?: number;
|
|
77
|
+
/** Someone besides its owner is in it, it is someone else's, or it is shared by link. */
|
|
78
|
+
shared: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Its address (https://<host>/<owner's handle>/<folders>/<name>.<ext>), which changes when it is renamed or moved;
|
|
81
|
+
* or, for a file without one yet (on another host, or on this device), a stand-in only appos.files.open() takes.
|
|
82
|
+
*/
|
|
83
|
+
address: string;
|
|
37
84
|
}
|
|
38
|
-
/** appos.files.all()
|
|
85
|
+
/** A folder on a host (appos.files.all()). `parent` is "" at the top. */
|
|
86
|
+
export interface IndexedFolder {
|
|
87
|
+
id: string;
|
|
88
|
+
host: string;
|
|
89
|
+
name: string;
|
|
90
|
+
parent: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* appos.files.all(): every host (this device first), every file and the hosts' folders. A host with `folders`
|
|
94
|
+
* keeps folders and names; one with `trash` moves a deleted file to Trash.
|
|
95
|
+
*/
|
|
39
96
|
export interface FileIndex {
|
|
40
97
|
hosts: {
|
|
41
98
|
id: string;
|
|
42
99
|
label: string;
|
|
100
|
+
folders?: true;
|
|
101
|
+
trash?: true;
|
|
43
102
|
}[];
|
|
44
103
|
files: IndexedFile[];
|
|
104
|
+
folders: IndexedFolder[];
|
|
105
|
+
}
|
|
106
|
+
/** A file in Trash (appos.files.trash()): deleted for good at `purgeAt`. */
|
|
107
|
+
export interface TrashedFile {
|
|
108
|
+
key: string;
|
|
109
|
+
title: string;
|
|
110
|
+
app: {
|
|
111
|
+
did: string;
|
|
112
|
+
name: string;
|
|
113
|
+
icon?: string;
|
|
114
|
+
};
|
|
115
|
+
host: string;
|
|
116
|
+
deleted: number;
|
|
117
|
+
purgeAt: number;
|
|
45
118
|
}
|
|
46
|
-
export interface
|
|
119
|
+
export interface LiveFile {
|
|
47
120
|
id: string;
|
|
48
121
|
kind: "local" | "cloud";
|
|
49
122
|
primary: boolean;
|
|
123
|
+
/** A cloud live file: its LiveWorker's id (the wire name is still `actor`). */
|
|
50
124
|
actor?: string;
|
|
51
|
-
/** A workspace (appos.multiple): the
|
|
125
|
+
/** A workspace (appos.multiple): the LiveWorkers it names, on any hosts. Open each and merge them. */
|
|
52
126
|
actors?: string[];
|
|
53
127
|
title?: string;
|
|
54
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* appos.files.open(): the shell's file picker. This app's files on every host the user is signed in to, and New (on
|
|
131
|
+
* the host the user picks). Resolves to what the user picked or made, or null when they cancelled. Apps with
|
|
132
|
+
* appos.multiple may ask for several; the shell saves them as a workspace. `kind`: one of the app's LiveWorker
|
|
133
|
+
* classes; the sheet lists and makes only files of it. Each file shows the name its LiveWorker's title() method
|
|
134
|
+
* gives, when it has one.
|
|
135
|
+
*
|
|
136
|
+
* appos.files.open(address): opens one of this app's own files (an `address` from appos.files.list() or recent())
|
|
137
|
+
* in its own tab, as Recent files does, once the shell finds it among this app's files the person can reach. Rejects
|
|
138
|
+
* with CloudError "no-file" for any other address: another app's file, one they can't reach, or nothing.
|
|
139
|
+
*/
|
|
140
|
+
declare function openFiles(address: string): Promise<void>;
|
|
141
|
+
declare function openFiles(options?: {
|
|
142
|
+
multiple?: boolean;
|
|
143
|
+
kind?: string;
|
|
144
|
+
}): Promise<{
|
|
145
|
+
ids: string[];
|
|
146
|
+
workspace?: string;
|
|
147
|
+
} | null>;
|
|
148
|
+
/**
|
|
149
|
+
* Shows the page at `path` of the app with DID `app` in `slot`, a box of this page's that is the page's place: as wide
|
|
150
|
+
* as the slot, and as tall as the page's content (the slot's height is set to it). The shell runs the page as a frame of
|
|
151
|
+
* its own app, laid over the slot, so it keeps its own storage, files and grants, and this page never reaches into it.
|
|
152
|
+
* The app has to list `path` in its manifest's appos.embeddable. `remove()` takes it away. Outside a shell, nothing.
|
|
153
|
+
*/
|
|
154
|
+
declare function embed(slot: HTMLElement, app: string, path: string): {
|
|
155
|
+
remove(): void;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Tells the pages this one shows (appos.embed) what is selected here, as it changes: the words, the address of what
|
|
159
|
+
* they are in, and their lines there. null: nothing is selected. Nothing comes back.
|
|
160
|
+
*/
|
|
161
|
+
declare function setSelection(selection: Selection | null): void;
|
|
162
|
+
/**
|
|
163
|
+
* For a page another app shows (appos.embed): `fn` hears what is selected in that app, now and each time it changes
|
|
164
|
+
* (null for nothing), with the app. Never called in a page no app shows. Returns the unsubscribe.
|
|
165
|
+
*/
|
|
166
|
+
declare function onSelection(fn: (selection: EmbeddedSelection | null) => void): () => void;
|
|
55
167
|
declare function ready(): Promise<{
|
|
56
168
|
version: string;
|
|
57
169
|
build?: number;
|
|
@@ -72,16 +184,16 @@ export declare function showSheet(opts: {
|
|
|
72
184
|
}[];
|
|
73
185
|
dismissable?: boolean;
|
|
74
186
|
}): void;
|
|
75
|
-
/** Shows the built-in sheet for a cloud problem the user can act on (`
|
|
76
|
-
export declare function explain(error: CloudError,
|
|
187
|
+
/** Shows the built-in sheet for a cloud problem the user can act on (`liveWorkerPath`: the LiveWorker the call went to). */
|
|
188
|
+
export declare function explain(error: CloudError, liveWorkerPath?: string): void;
|
|
77
189
|
/**
|
|
78
190
|
* The app's backend. It has no URL: `fetch()` can't reach it, so a URL that
|
|
79
191
|
* came from anywhere (a link, a message, another site) never becomes a call
|
|
80
|
-
* to it. Paths name
|
|
192
|
+
* to it. Paths name a LiveWorker and what to send it:
|
|
81
193
|
*
|
|
82
194
|
* /whoami
|
|
83
|
-
* /actors GET: the user's
|
|
84
|
-
* /actor/<id>/<path> one
|
|
195
|
+
* /actors GET: the user's LiveWorkers; POST /actors/<Class>: a new one
|
|
196
|
+
* /actor/<id>/<path> one LiveWorker
|
|
85
197
|
*/
|
|
86
198
|
export declare const backend: {
|
|
87
199
|
/** Sends a request to the backend; resolves to its streamed response. */
|
|
@@ -115,23 +227,23 @@ export declare class BackendSocket extends EventTarget {
|
|
|
115
227
|
/** @internal */
|
|
116
228
|
_closed(code: number, reason: string, clean: boolean): void;
|
|
117
229
|
}
|
|
118
|
-
export type
|
|
119
|
-
export interface
|
|
230
|
+
export type LiveWorkerRole = "owner" | "editor" | "viewer";
|
|
231
|
+
export interface LiveWorkerEntry {
|
|
120
232
|
id: string;
|
|
121
|
-
/** The
|
|
233
|
+
/** The LiveWorker's class, as appos.actors names it. */
|
|
122
234
|
name: string;
|
|
123
235
|
/** The signed-in user's role in it. */
|
|
124
|
-
role:
|
|
125
|
-
/** Opens the app on this
|
|
236
|
+
role: LiveWorkerRole;
|
|
237
|
+
/** Opens the app on this LiveWorker, for people who hold a role in it. */
|
|
126
238
|
url?: string;
|
|
127
239
|
}
|
|
128
|
-
export interface
|
|
240
|
+
export interface LiveWorkerInfo {
|
|
129
241
|
id: string;
|
|
130
242
|
className: string;
|
|
131
243
|
owner: string;
|
|
132
244
|
isOwner: boolean;
|
|
133
245
|
/** The signed-in user's roles here. */
|
|
134
|
-
roles:
|
|
246
|
+
roles: LiveWorkerRole[];
|
|
135
247
|
/** The owner sees every grant: user → role. */
|
|
136
248
|
grants?: Record<string, "editor" | "viewer">;
|
|
137
249
|
running?: {
|
|
@@ -147,60 +259,68 @@ export interface ActorInfo {
|
|
|
147
259
|
by: string;
|
|
148
260
|
denied: boolean;
|
|
149
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* Open to the web (appos.requestOpenWeb()): since when, and `url`, the file's address plus ".git", where git's smart
|
|
264
|
+
* HTTP reaches it from anywhere (no url while the file has no address yet); else null.
|
|
265
|
+
*/
|
|
266
|
+
openWeb?: {
|
|
267
|
+
url?: string;
|
|
268
|
+
since: number;
|
|
269
|
+
} | null;
|
|
150
270
|
}
|
|
151
|
-
/** A person in
|
|
152
|
-
export interface
|
|
271
|
+
/** A person in a LiveWorker, to show: never an email. */
|
|
272
|
+
export interface LiveWorkerProfile {
|
|
153
273
|
id: string;
|
|
154
|
-
role:
|
|
274
|
+
role: LiveWorkerRole;
|
|
155
275
|
name?: string;
|
|
156
276
|
image?: string;
|
|
157
277
|
}
|
|
158
|
-
/** A connection to one
|
|
159
|
-
export declare class
|
|
278
|
+
/** A connection to one LiveWorker: RPC, fetch and a live socket, each with the user's claims. */
|
|
279
|
+
export declare class LiveWorker {
|
|
160
280
|
readonly id: string;
|
|
161
281
|
readonly path: string;
|
|
162
282
|
/** The signed-in user's roles, as of open(). */
|
|
163
|
-
roles:
|
|
283
|
+
roles: LiveWorkerRole[];
|
|
164
284
|
constructor(id: string);
|
|
165
|
-
/** backend.fetch() to the
|
|
285
|
+
/** backend.fetch() to the LiveWorker's own fetch handler, at `sub` under it. Problems the user can act on get the SDK's sheets. */
|
|
166
286
|
fetch(sub?: string, init?: RequestInit): Promise<Response>;
|
|
167
|
-
/** Calls a method of the
|
|
287
|
+
/** Calls a method of the LiveWorker's class. Throws CloudError on failure. */
|
|
168
288
|
call<T = unknown>(method: string, ...args: unknown[]): Promise<T>;
|
|
169
|
-
/** A WebSocket to the
|
|
289
|
+
/** A WebSocket to the LiveWorker's fetch handler. */
|
|
170
290
|
websocket(sub?: string, protocols?: string | string[]): Promise<BackendSocket>;
|
|
171
291
|
/**
|
|
172
292
|
* The owner and members to show: [{ id, role, name?, image? }]. `name` and
|
|
173
293
|
* `image` (an https avatar URL) come from each person's assistant-ui
|
|
174
294
|
* account; someone who never signed in to appOS has only id and role.
|
|
175
|
-
* The backend reads the same list with env.appos.profiles(). Cloud
|
|
295
|
+
* The backend reads the same list with env.appos.profiles(). Cloud LiveWorkers only.
|
|
176
296
|
*/
|
|
177
|
-
profiles(): Promise<
|
|
297
|
+
profiles(): Promise<LiveWorkerProfile[]>;
|
|
178
298
|
/** Owner, roles, the build it runs. Shows the owner a newer build a member asked for (Approve / Deny). */
|
|
179
|
-
info(): Promise<
|
|
299
|
+
info(): Promise<LiveWorkerInfo>;
|
|
180
300
|
}
|
|
181
301
|
/**
|
|
182
|
-
* A link that opens this app on
|
|
302
|
+
* A link that opens this app on LiveWorker `id` and gives whoever opens it `role`
|
|
183
303
|
* (editor by default; viewers can share only as viewers). The app shows it
|
|
184
304
|
* in its own share sheet.
|
|
185
305
|
*/
|
|
186
306
|
declare function share(id: string, role?: "editor" | "viewer"): Promise<string>;
|
|
187
307
|
/**
|
|
188
|
-
* Opens appOS's Share sheet for
|
|
308
|
+
* Opens appOS's Share sheet for LiveWorker `id`: the people on it with their role
|
|
189
309
|
* and the link each joined by, and, for its owner, the share links (new,
|
|
190
310
|
* copy, revoke). The same sheet for every app; resolves once it is shown.
|
|
191
311
|
*/
|
|
192
312
|
declare function openShare(id: string): Promise<void>;
|
|
193
|
-
/** What appOS tells the page when the person's role in
|
|
313
|
+
/** What appOS tells the page when the person's role in a LiveWorker changed: role null once they lost access. */
|
|
194
314
|
export interface AccessChange {
|
|
195
315
|
actor: string;
|
|
196
|
-
role:
|
|
316
|
+
role: LiveWorkerRole | null;
|
|
197
317
|
}
|
|
198
318
|
/**
|
|
199
|
-
* Calls `fn` when appOS finds the signed-in person's access to
|
|
319
|
+
* Calls `fn` when appOS finds the signed-in person's access to a LiveWorker
|
|
200
320
|
* changed (revoked, or they left on another device). Returns an unsubscribe.
|
|
201
321
|
*/
|
|
202
322
|
declare function onAccess(fn: (change: AccessChange) => void): () => void;
|
|
203
|
-
export type
|
|
323
|
+
export type LiveTextStatus = {
|
|
204
324
|
state: "connecting";
|
|
205
325
|
} | {
|
|
206
326
|
state: "live";
|
|
@@ -213,8 +333,8 @@ export type LiveFileStatus = {
|
|
|
213
333
|
code: string;
|
|
214
334
|
message: string;
|
|
215
335
|
};
|
|
216
|
-
/** The live file this frame runs (appos.
|
|
217
|
-
export declare class
|
|
336
|
+
/** The text of the live file this frame runs, when it is shared by link (appos.liveText()). */
|
|
337
|
+
export declare class LiveText {
|
|
218
338
|
#private;
|
|
219
339
|
/** The link that opens this file, to copy and send. */
|
|
220
340
|
readonly url: string;
|
|
@@ -223,25 +343,25 @@ export declare class LiveFile {
|
|
|
223
343
|
/** The file's text as this frame last saw it; undefined until loaded(). */
|
|
224
344
|
get data(): string | undefined;
|
|
225
345
|
get rev(): number;
|
|
226
|
-
get status():
|
|
346
|
+
get status(): LiveTextStatus;
|
|
227
347
|
/** Resolves with the file's text once the cloud has sent it. */
|
|
228
348
|
loaded(): Promise<string>;
|
|
229
349
|
/** Runs `fn` with the text whenever someone else changed the file. */
|
|
230
350
|
onChange(fn: (data: string) => void): () => void;
|
|
231
351
|
/** Runs `fn` when the connection changes (connecting, live with N people, offline). */
|
|
232
|
-
onStatus(fn: (s:
|
|
352
|
+
onStatus(fn: (s: LiveTextStatus) => void): () => void;
|
|
233
353
|
/** Replaces the file's text for everyone. Resent after a reconnect until the cloud confirms it. */
|
|
234
354
|
save(data: string): void;
|
|
235
355
|
/** True while a local write is not yet in the cloud. */
|
|
236
356
|
get saving(): boolean;
|
|
237
357
|
close(): void;
|
|
238
358
|
}
|
|
239
|
-
declare function
|
|
359
|
+
declare function liveText(): Promise<LiveText | undefined>;
|
|
240
360
|
/**
|
|
241
361
|
* Moves the file this frame runs to the appOS cloud as a live file holding
|
|
242
362
|
* `data` (text, at most 512 KB), and returns its link. Anyone with the link
|
|
243
363
|
* opens the file and edits it live; no sign-in. Already live: its link.
|
|
244
|
-
* Afterwards appos.
|
|
364
|
+
* Afterwards appos.liveText() connects to it.
|
|
245
365
|
*/
|
|
246
366
|
declare function shareFile(data: string): Promise<{
|
|
247
367
|
url: string;
|
|
@@ -313,36 +433,36 @@ export declare const appos: {
|
|
|
313
433
|
/** A WebSocket to the backend, relayed by the shell. */
|
|
314
434
|
connect(path: string, protocols?: string | string[]): Promise<BackendSocket>;
|
|
315
435
|
};
|
|
316
|
-
/** The app's
|
|
317
|
-
|
|
436
|
+
/** The app's LiveWorkers: create, open, list, grant, revoke, launched (appos.actors in the manifest). */
|
|
437
|
+
liveWorkers: {
|
|
318
438
|
/**
|
|
319
|
-
* A new
|
|
439
|
+
* A new LiveWorker of class `name`, owned by the user, on their default host.
|
|
320
440
|
* `host` says where it went: "cloud" or the host's name.
|
|
321
441
|
*/
|
|
322
|
-
create(name: string): Promise<
|
|
442
|
+
create(name: string): Promise<LiveWorkerEntry & {
|
|
323
443
|
url: string;
|
|
324
444
|
host: string;
|
|
325
445
|
}>;
|
|
326
|
-
/** A connection to
|
|
327
|
-
open(id: string): Promise<
|
|
328
|
-
/** The
|
|
329
|
-
list(): Promise<
|
|
330
|
-
/** Owner only: gives `user` a role in
|
|
331
|
-
/** Owner only: gives `user` (their appOS ID) a role in
|
|
446
|
+
/** A connection to a LiveWorker the user holds a role in. Rejects with "not-member" otherwise. */
|
|
447
|
+
open(id: string): Promise<LiveWorker>;
|
|
448
|
+
/** The LiveWorkers the user owns or holds a role in, on every host. */
|
|
449
|
+
list(): Promise<LiveWorkerEntry[]>;
|
|
450
|
+
/** Owner only: gives `user` a role in LiveWorker `id`. */
|
|
451
|
+
/** Owner only: gives `user` (their appOS ID) a role in LiveWorker `id`. */
|
|
332
452
|
grant(id: string, user: string, role: "editor" | "viewer"): Promise<void>;
|
|
333
|
-
/** Owner only: takes `user`'s role in
|
|
453
|
+
/** Owner only: takes `user`'s role in LiveWorker `id` away. */
|
|
334
454
|
revoke(id: string, user: string): Promise<void>;
|
|
335
455
|
/**
|
|
336
|
-
* The
|
|
456
|
+
* The LiveWorker a share link opened this app on, joined with the link's key
|
|
337
457
|
* (once per launch). Undefined when the app was not opened from one.
|
|
338
458
|
*/
|
|
339
|
-
launched(): Promise<
|
|
459
|
+
launched(): Promise<LiveWorker | undefined>;
|
|
340
460
|
};
|
|
341
|
-
/** A share link to
|
|
461
|
+
/** A share link to a LiveWorker for a role: share(id, "viewer"). */
|
|
342
462
|
share: typeof share;
|
|
343
|
-
/** appOS's Share sheet for
|
|
463
|
+
/** appOS's Share sheet for a LiveWorker: openShare(id). */
|
|
344
464
|
openShare: typeof openShare;
|
|
345
|
-
/** Hears when the person's access to
|
|
465
|
+
/** Hears when the person's access to a LiveWorker changed: onAccess(({ LiveWorker, role }) => …). */
|
|
346
466
|
onAccess: typeof onAccess;
|
|
347
467
|
/** { version, previousVersion }: previousVersion only on the first launch after an update. */
|
|
348
468
|
ready: typeof ready;
|
|
@@ -381,23 +501,36 @@ export declare const appos: {
|
|
|
381
501
|
* save(), hear others with onChange(). Undefined when the file is not live
|
|
382
502
|
* (see shareFile()).
|
|
383
503
|
*/
|
|
384
|
-
|
|
504
|
+
liveText: typeof liveText;
|
|
385
505
|
/** Moves this frame's file to the cloud as a live file; resolves to its link. */
|
|
386
506
|
shareFile: typeof shareFile;
|
|
387
|
-
/** The file
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* The shell's file picker: this app's files on every host the user is
|
|
391
|
-
* signed in to, and New (on the host the user picks). Resolves to what the
|
|
392
|
-
* user picked or made, or null when they cancelled. Apps with
|
|
393
|
-
* appos.multiple may ask for several; the shell saves them as a workspace.
|
|
394
|
-
*/
|
|
507
|
+
/** The live file this frame runs; undefined in appOS from before live files. */
|
|
508
|
+
liveFile(): Promise<LiveFile | undefined>;
|
|
509
|
+
/** The person's files of this app: the shell's Open and New dialogs, and this app's own list of them. */
|
|
395
510
|
files: {
|
|
396
|
-
|
|
397
|
-
|
|
511
|
+
/** The shell's Open dialog, or with an address, one of this app's own files in its tab (see openFiles). */
|
|
512
|
+
open: typeof openFiles;
|
|
513
|
+
/**
|
|
514
|
+
* This app's files the person owns or that are shared with them, on every host the shell is signed in to and this
|
|
515
|
+
* device, by name: what each is and where, never its data. Only this app's own type: other apps' files come only
|
|
516
|
+
* through the shell's Open dialog. `folder`: only those in that folder ("" the top, "Work/Plans" deeper).
|
|
517
|
+
*/
|
|
518
|
+
list({ folder }?: {
|
|
519
|
+
folder?: string;
|
|
520
|
+
}): Promise<AppFile[]>;
|
|
521
|
+
/** This app's files the person opened on this device lately, newest first: `limit` of them (10; at most 50). */
|
|
522
|
+
recent({ limit }?: {
|
|
523
|
+
limit?: number;
|
|
524
|
+
}): Promise<AppFile[]>;
|
|
525
|
+
/**
|
|
526
|
+
* The shell's New dialog: the user picks a host, a folder and a name, and the shell makes a file of this app
|
|
527
|
+
* there (of `kind`, one of the app's LiveWorker classes, when given). Resolves to its LiveWorker id (open it with
|
|
528
|
+
* appos.liveWorkers.open(id)), or null when the user cancelled. The app never sees the user's other files.
|
|
529
|
+
*/
|
|
530
|
+
create({ kind }?: {
|
|
531
|
+
kind?: string;
|
|
398
532
|
}): Promise<{
|
|
399
|
-
|
|
400
|
-
workspace?: string;
|
|
533
|
+
id: string;
|
|
401
534
|
} | null>;
|
|
402
535
|
/**
|
|
403
536
|
* The Files app only (did:web:appos.assistant-ui.workers.dev:apps:files):
|
|
@@ -407,17 +540,72 @@ export declare const appos: {
|
|
|
407
540
|
all(): Promise<FileIndex>;
|
|
408
541
|
/** The Files app only: opens a file all() listed in its own app, in a tab. */
|
|
409
542
|
openInApp(key: string): Promise<void>;
|
|
543
|
+
/** The Files app only: closes a file all() listed as openWeb to the web. */
|
|
544
|
+
closeOpenWeb(key: string): Promise<void>;
|
|
545
|
+
/**
|
|
546
|
+
* The Files app only: renames a file. Names are unique in a folder by name alone; a taken one rejects with
|
|
547
|
+
* CloudError "name-taken". Resolves to the name it has now.
|
|
548
|
+
*/
|
|
549
|
+
rename(key: string, name: string): Promise<string>;
|
|
550
|
+
/** The Files app only: moves a file into a folder on its host ("" for the top). */
|
|
551
|
+
move(key: string, folder: string): Promise<void>;
|
|
552
|
+
/**
|
|
553
|
+
* The Files app only: deletes a file. Its owner's goes to Trash where its host has one ("trash") and for good
|
|
554
|
+
* elsewhere ("delete"); anyone else's leaves their view on this device ("remove") and stays for its owner.
|
|
555
|
+
*/
|
|
556
|
+
delete(key: string): Promise<"trash" | "delete" | "remove">;
|
|
557
|
+
/** The Files app only: opens the shell's Share sheet on a file (its people, roles and links). */
|
|
558
|
+
share(key: string): Promise<void>;
|
|
559
|
+
/** The Files app only: the files in Trash, newest first. */
|
|
560
|
+
trash(): Promise<TrashedFile[]>;
|
|
561
|
+
/** The Files app only: back from Trash, in its folder (or at the top), its name suffixed if it was taken. */
|
|
562
|
+
restore(key: string): Promise<void>;
|
|
563
|
+
/** The Files app only: deletes a file in Trash for good, for everyone. */
|
|
564
|
+
purge(key: string): Promise<void>;
|
|
565
|
+
/** The Files app only: the shell's New dialog at a host and folder; the user picks the app. The file opens in it. */
|
|
566
|
+
newFile(host: string, folder?: string): Promise<boolean>;
|
|
567
|
+
/** The Files app only: deletes every file in Trash for good. */
|
|
568
|
+
emptyTrash(): Promise<void>;
|
|
569
|
+
/** The Files app only: a host's folders. Folders only organize; sharing is per file. */
|
|
570
|
+
folders: {
|
|
571
|
+
create(host: string, name: string, parent?: string): Promise<IndexedFolder>;
|
|
572
|
+
rename(host: string, id: string, name: string): Promise<IndexedFolder>;
|
|
573
|
+
move(host: string, id: string, parent: string): Promise<IndexedFolder>;
|
|
574
|
+
/** An empty folder only (CloudError "not-empty" otherwise). */
|
|
575
|
+
delete(host: string, id: string): Promise<void>;
|
|
576
|
+
};
|
|
410
577
|
};
|
|
411
|
-
/**
|
|
412
|
-
|
|
578
|
+
/**
|
|
579
|
+
* Makes a new file of this app and opens it in its own tab: through the shell's New dialog (host, folder, name)
|
|
580
|
+
* when the app has LiveWorkers, else on this device. Null when the user cancelled the dialog.
|
|
581
|
+
*/
|
|
582
|
+
newLiveFile(): Promise<{
|
|
413
583
|
id: string;
|
|
414
584
|
kind: "local" | "cloud";
|
|
585
|
+
} | null>;
|
|
586
|
+
/**
|
|
587
|
+
* Opens another of this app's files (its id from liveFile()) in its own tab, as App info does: an app that
|
|
588
|
+
* lists its own files opens one this way. Rejects with CloudError "no-file" for an id that isn't this app's.
|
|
589
|
+
*/
|
|
590
|
+
openLiveFile(id: string): Promise<void>;
|
|
591
|
+
/**
|
|
592
|
+
* Asks appOS to open the file this frame runs (a LiveWorker in the appOS cloud) to the open web, for an app whose
|
|
593
|
+
* manifest declares appos.openWeb. appOS shows its own prompt to the file's owner; the app never sets it. Answers
|
|
594
|
+
* { open: true, url } (already open: no prompt), or { open: false } when the owner said no. `url` is the file's
|
|
595
|
+
* address plus ".git" (none while the file has no address yet): git's smart HTTP there (`<url>/info/refs`,
|
|
596
|
+
* `/git-upload-pack`, `/git-receive-pack`) reaches the LiveWorker's fetch() at that route, with no user the platform
|
|
597
|
+
* vouches for (caller() is { roles: [], web: true }) and Authorization untouched: the app checks who they are. Every
|
|
598
|
+
* refusal there answers as an address that names nothing. The owner closes it in App info or the Files app.
|
|
599
|
+
*/
|
|
600
|
+
requestOpenWeb(): Promise<{
|
|
601
|
+
open: boolean;
|
|
602
|
+
url?: string;
|
|
415
603
|
}>;
|
|
416
604
|
/**
|
|
417
|
-
* Local
|
|
605
|
+
* Local live files the user deleted since the app last ran: delete their data
|
|
418
606
|
* (it shares this origin). Called once per launch with the ids.
|
|
419
607
|
*/
|
|
420
|
-
|
|
608
|
+
onLiveFileRemoved(fn: (ids: string[]) => void | Promise<void>): void;
|
|
421
609
|
/** Names the app in the SDK's sheets. */
|
|
422
610
|
setName(name: string): void;
|
|
423
611
|
/** Names the file this frame runs, as Home and the tab show it. */
|
|
@@ -428,6 +616,12 @@ export declare const appos: {
|
|
|
428
616
|
* Outside a shell it does nothing.
|
|
429
617
|
*/
|
|
430
618
|
setBadge(count: number): void;
|
|
619
|
+
/** Another app's page in this one: embed(slot, did, path); see appos.embeddable in that app's manifest. */
|
|
620
|
+
embed: typeof embed;
|
|
621
|
+
/** What is selected here, for the pages this one shows: setSelection({ address, lines?, text }) or null. */
|
|
622
|
+
setSelection: typeof setSelection;
|
|
623
|
+
/** In a page another app shows: what is selected in that app, now and as it changes. */
|
|
624
|
+
onSelection: typeof onSelection;
|
|
431
625
|
/**
|
|
432
626
|
* How many CSS px of the shell's own chrome (a host page's mark, say) cover the start of the app's header, from
|
|
433
627
|
* the shell's hello: pad the header's start by it. 0 when the shell says nothing (appOS itself) or outside a shell.
|
|
@@ -12,6 +12,6 @@ export interface PackFile {
|
|
|
12
12
|
export declare function normalizePath(input: string): string;
|
|
13
13
|
/**
|
|
14
14
|
* Builds a .wbn. `/index.html` is also served at `/`, the primary URL, and
|
|
15
|
-
* `/a/index.html` at `/a`.
|
|
15
|
+
* `/a/index.html` at `/a`. Declaration files (.d.ts, .d.ts.map) stay out.
|
|
16
16
|
*/
|
|
17
17
|
export declare function packFiles(files: PackFile[]): Uint8Array;
|