nixamp 0.5.6 → 0.5.7
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/admin.d.ts +20 -0
- package/dist/admin.js +29 -3
- package/package.json +1 -1
- package/src/admin.ts +43 -2
- package/web/dist/sw.js +1 -1
package/dist/admin.d.ts
CHANGED
|
@@ -28,6 +28,19 @@ interface Snapshot {
|
|
|
28
28
|
export interface AdminOptions {
|
|
29
29
|
url: string;
|
|
30
30
|
key: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Every address the server found, labelled, share key not yet applied.
|
|
33
|
+
*
|
|
34
|
+
* `url` is the one this process talks to, which for a local daemon is
|
|
35
|
+
* loopback -- correct for asking it questions and useless for handing to
|
|
36
|
+
* anybody. These are the ones worth reading off the screen.
|
|
37
|
+
*/
|
|
38
|
+
links: {
|
|
39
|
+
label: string;
|
|
40
|
+
url: string;
|
|
41
|
+
}[];
|
|
42
|
+
/** What it is serving, so the admin view says so without being asked. */
|
|
43
|
+
source: string;
|
|
31
44
|
}
|
|
32
45
|
/** Where to point, from the flags or from the daemon that is running. */
|
|
33
46
|
export declare function resolveTarget(argv: string[]): AdminOptions;
|
|
@@ -42,6 +55,13 @@ export interface View {
|
|
|
42
55
|
error: string;
|
|
43
56
|
typing: boolean;
|
|
44
57
|
restreaming: string;
|
|
58
|
+
/** Labelled addresses, and the key that makes them work. */
|
|
59
|
+
links: {
|
|
60
|
+
label: string;
|
|
61
|
+
url: string;
|
|
62
|
+
}[];
|
|
63
|
+
key: string | null;
|
|
64
|
+
source: string;
|
|
45
65
|
}
|
|
46
66
|
export declare function draw(ui: Container, theme: Theme, view: View): void;
|
|
47
67
|
export {};
|
package/dist/admin.js
CHANGED
|
@@ -14,13 +14,22 @@ export function resolveTarget(argv) {
|
|
|
14
14
|
const keyAt = argv.findIndex((a) => a === "--key");
|
|
15
15
|
const url = at === -1 ? null : argv[at + 1];
|
|
16
16
|
const key = keyAt === -1 ? null : (argv[keyAt + 1] ?? null);
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Pointed somewhere by hand, that address is the only one known.
|
|
18
|
+
if (url) {
|
|
19
|
+
const bare = url.replace(/\/+$/, "");
|
|
20
|
+
return { url: bare, key, links: [{ label: "there", url: bare }], source: "" };
|
|
21
|
+
}
|
|
19
22
|
const state = readState();
|
|
20
23
|
if (state === null) {
|
|
21
24
|
throw new Error("nixamp: no daemon is running. Start one with `nixamp daemon start`, or pass --url.");
|
|
22
25
|
}
|
|
23
|
-
return {
|
|
26
|
+
return {
|
|
27
|
+
url: daemonUrl(state),
|
|
28
|
+
key: key ?? state.key,
|
|
29
|
+
// A state file written before 0.5.3 has no list; loopback stands in.
|
|
30
|
+
links: state.urls ?? [{ label: "here", url: daemonUrl(state) }],
|
|
31
|
+
source: state.source,
|
|
32
|
+
};
|
|
24
33
|
}
|
|
25
34
|
/** Seconds as something a person reads at a glance. */
|
|
26
35
|
export function since(ms) {
|
|
@@ -118,6 +127,7 @@ export async function admin(argv) {
|
|
|
118
127
|
app.on("exit", () => clearInterval(timer));
|
|
119
128
|
app.render(({ ui, theme }) => draw(ui, theme, {
|
|
120
129
|
url: target.url, report, snapshot, error, typing, restreaming,
|
|
130
|
+
links: target.links, key: target.key, source: target.source,
|
|
121
131
|
}));
|
|
122
132
|
await app.start();
|
|
123
133
|
clearInterval(timer);
|
|
@@ -159,6 +169,22 @@ export function draw(ui, theme, view) {
|
|
|
159
169
|
]);
|
|
160
170
|
});
|
|
161
171
|
});
|
|
172
|
+
// The links, because the point of a daemon is the phone in the other room
|
|
173
|
+
// and the address this process happens to talk to is the one that will not
|
|
174
|
+
// reach it. The key is on them: without it every address is a 401.
|
|
175
|
+
if (view.links.length > 0) {
|
|
176
|
+
const width = Math.max(...view.links.map((link) => link.label.length));
|
|
177
|
+
ui.panel({ title: "Share links", size: view.links.length + (view.source ? 3 : 2) }, (p) => {
|
|
178
|
+
for (const link of view.links) {
|
|
179
|
+
const full = view.key === null ? link.url : `${link.url}/s/${view.key}`;
|
|
180
|
+
p.text(`${link.label.padEnd(width)} ${full}`, {
|
|
181
|
+
fg: link.label === "on the internet" ? theme.accent : theme.foreground,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (view.source)
|
|
185
|
+
p.label(view.source);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
162
188
|
ui.panel({ title: `Connections (${report?.active ?? 0} live)` }, (p) => {
|
|
163
189
|
if (view.error) {
|
|
164
190
|
p.text(view.error, { fg: theme.danger });
|
package/package.json
CHANGED
package/src/admin.ts
CHANGED
|
@@ -30,6 +30,16 @@ interface Snapshot {
|
|
|
30
30
|
export interface AdminOptions {
|
|
31
31
|
url: string;
|
|
32
32
|
key: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Every address the server found, labelled, share key not yet applied.
|
|
35
|
+
*
|
|
36
|
+
* `url` is the one this process talks to, which for a local daemon is
|
|
37
|
+
* loopback -- correct for asking it questions and useless for handing to
|
|
38
|
+
* anybody. These are the ones worth reading off the screen.
|
|
39
|
+
*/
|
|
40
|
+
links: { label: string; url: string }[];
|
|
41
|
+
/** What it is serving, so the admin view says so without being asked. */
|
|
42
|
+
source: string;
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
/** Where to point, from the flags or from the daemon that is running. */
|
|
@@ -39,13 +49,23 @@ export function resolveTarget(argv: string[]): AdminOptions {
|
|
|
39
49
|
const url = at === -1 ? null : argv[at + 1];
|
|
40
50
|
const key = keyAt === -1 ? null : (argv[keyAt + 1] ?? null);
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
// Pointed somewhere by hand, that address is the only one known.
|
|
53
|
+
if (url) {
|
|
54
|
+
const bare = url.replace(/\/+$/, "");
|
|
55
|
+
return { url: bare, key, links: [{ label: "there", url: bare }], source: "" };
|
|
56
|
+
}
|
|
43
57
|
|
|
44
58
|
const state = readState();
|
|
45
59
|
if (state === null) {
|
|
46
60
|
throw new Error("nixamp: no daemon is running. Start one with `nixamp daemon start`, or pass --url.");
|
|
47
61
|
}
|
|
48
|
-
return {
|
|
62
|
+
return {
|
|
63
|
+
url: daemonUrl(state),
|
|
64
|
+
key: key ?? state.key,
|
|
65
|
+
// A state file written before 0.5.3 has no list; loopback stands in.
|
|
66
|
+
links: state.urls ?? [{ label: "here", url: daemonUrl(state) }],
|
|
67
|
+
source: state.source,
|
|
68
|
+
};
|
|
49
69
|
}
|
|
50
70
|
|
|
51
71
|
/** Seconds as something a person reads at a glance. */
|
|
@@ -134,6 +154,7 @@ export async function admin(argv: string[]): Promise<void> {
|
|
|
134
154
|
app.on("exit", () => clearInterval(timer));
|
|
135
155
|
app.render(({ ui, theme }) => draw(ui, theme, {
|
|
136
156
|
url: target.url, report, snapshot, error, typing, restreaming,
|
|
157
|
+
links: target.links, key: target.key, source: target.source,
|
|
137
158
|
}));
|
|
138
159
|
|
|
139
160
|
await app.start();
|
|
@@ -161,6 +182,10 @@ export interface View {
|
|
|
161
182
|
error: string;
|
|
162
183
|
typing: boolean;
|
|
163
184
|
restreaming: string;
|
|
185
|
+
/** Labelled addresses, and the key that makes them work. */
|
|
186
|
+
links: { label: string; url: string }[];
|
|
187
|
+
key: string | null;
|
|
188
|
+
source: string;
|
|
164
189
|
}
|
|
165
190
|
|
|
166
191
|
export function draw(ui: Container, theme: Theme, view: View): void {
|
|
@@ -189,6 +214,22 @@ export function draw(ui: Container, theme: Theme, view: View): void {
|
|
|
189
214
|
});
|
|
190
215
|
});
|
|
191
216
|
|
|
217
|
+
// The links, because the point of a daemon is the phone in the other room
|
|
218
|
+
// and the address this process happens to talk to is the one that will not
|
|
219
|
+
// reach it. The key is on them: without it every address is a 401.
|
|
220
|
+
if (view.links.length > 0) {
|
|
221
|
+
const width = Math.max(...view.links.map((link) => link.label.length));
|
|
222
|
+
ui.panel({ title: "Share links", size: view.links.length + (view.source ? 3 : 2) }, (p) => {
|
|
223
|
+
for (const link of view.links) {
|
|
224
|
+
const full = view.key === null ? link.url : `${link.url}/s/${view.key}`;
|
|
225
|
+
p.text(`${link.label.padEnd(width)} ${full}`, {
|
|
226
|
+
fg: link.label === "on the internet" ? theme.accent : theme.foreground,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (view.source) p.label(view.source);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
192
233
|
ui.panel({ title: `Connections (${report?.active ?? 0} live)` }, (p) => {
|
|
193
234
|
if (view.error) {
|
|
194
235
|
p.text(view.error, { fg: theme.danger });
|
package/web/dist/sw.js
CHANGED