nixamp 0.3.0 → 0.4.0
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/directory.d.ts +126 -3
- package/dist/directory.js +171 -7
- package/dist/durable.d.ts +70 -0
- package/dist/durable.js +156 -0
- package/dist/follows.d.ts +92 -0
- package/dist/follows.js +248 -0
- package/dist/notify.d.ts +83 -0
- package/dist/notify.js +126 -0
- package/dist/optin.d.ts +37 -0
- package/dist/optin.js +122 -0
- package/dist/partyline.d.ts +259 -0
- package/dist/partyline.js +616 -0
- package/dist/paywall.js +1 -1
- package/dist/playlist.js +5 -0
- package/dist/publish.d.ts +21 -0
- package/dist/publish.js +18 -2
- package/dist/server.d.ts +15 -0
- package/dist/server.js +558 -11
- package/dist/share.d.ts +10 -0
- package/dist/share.js +12 -0
- package/package.json +5 -2
- package/src/directory.ts +232 -5
- package/src/durable.ts +215 -0
- package/src/follows.ts +307 -0
- package/src/notify.ts +217 -0
- package/src/optin.ts +128 -0
- package/src/partyline.ts +742 -0
- package/src/paywall.ts +1 -1
- package/src/playlist.ts +5 -0
- package/src/publish.ts +38 -2
- package/src/server.ts +610 -10
- package/src/share.ts +13 -0
- package/web/dist/assets/{index-0wAv50Ay.css → index-DSIDSSPF.css} +1 -1
- package/web/dist/assets/index-qRguFskX.js +1 -0
- package/web/dist/index.html +27 -2
- package/web/dist/install.sh +82 -0
- package/web/dist/sw.js +45 -3
- package/web/dist/assets/index-WYJ6R4uF.js +0 -1
package/dist/publish.js
CHANGED
|
@@ -33,6 +33,8 @@ export class Publisher {
|
|
|
33
33
|
fetcher;
|
|
34
34
|
id = null;
|
|
35
35
|
timer = null;
|
|
36
|
+
/** Whether we have already said that the directory wants an account. */
|
|
37
|
+
refused = false;
|
|
36
38
|
constructor(target, fetcher = fetch) {
|
|
37
39
|
this.target = target;
|
|
38
40
|
this.fetcher = fetcher;
|
|
@@ -47,17 +49,30 @@ export class Publisher {
|
|
|
47
49
|
try {
|
|
48
50
|
const response = await this.fetcher(`${this.target.directory}/api/directory`, {
|
|
49
51
|
method: "POST",
|
|
50
|
-
headers: {
|
|
52
|
+
headers: {
|
|
53
|
+
"content-type": "application/json",
|
|
54
|
+
...(this.target.token ? { authorization: `Bearer ${this.target.token}` } : {}),
|
|
55
|
+
},
|
|
51
56
|
body: JSON.stringify({
|
|
52
57
|
...(this.id ? { id: this.id } : {}),
|
|
53
58
|
name: this.target.name,
|
|
54
59
|
url: this.target.url,
|
|
60
|
+
...(this.target.audio ? { audio: this.target.audio } : {}),
|
|
55
61
|
tracks: this.target.tracks,
|
|
56
62
|
nowPlaying: this.target.nowPlaying(),
|
|
57
63
|
}),
|
|
58
64
|
});
|
|
59
|
-
if (!response.ok)
|
|
65
|
+
if (!response.ok) {
|
|
66
|
+
// Worth telling the operator about exactly once. A heartbeat that is
|
|
67
|
+
// refused every 90 seconds should not print every 90 seconds, and
|
|
68
|
+
// "could not reach the directory" would be the wrong thing to say
|
|
69
|
+
// about a directory that answered perfectly clearly.
|
|
70
|
+
if (response.status === 401 && !this.refused) {
|
|
71
|
+
this.refused = true;
|
|
72
|
+
this.target.onRefused?.();
|
|
73
|
+
}
|
|
60
74
|
return null;
|
|
75
|
+
}
|
|
61
76
|
const listing = (await response.json());
|
|
62
77
|
this.id = listing.id;
|
|
63
78
|
if (listing.config !== undefined)
|
|
@@ -79,6 +94,7 @@ export class Publisher {
|
|
|
79
94
|
try {
|
|
80
95
|
await this.fetcher(`${this.target.directory}/api/directory?id=${encodeURIComponent(this.id)}`, {
|
|
81
96
|
method: "DELETE",
|
|
97
|
+
...(this.target.token ? { headers: { authorization: `Bearer ${this.target.token}` } } : {}),
|
|
82
98
|
});
|
|
83
99
|
}
|
|
84
100
|
catch {
|
package/dist/server.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { Channels } from "./channels.ts";
|
|
|
6
6
|
import { Accounts } from "./accounts.ts";
|
|
7
7
|
import { Owner } from "./owner.ts";
|
|
8
8
|
import { Directory } from "./directory.ts";
|
|
9
|
+
import { PartyLine } from "./partyline.ts";
|
|
10
|
+
import { Follows } from "./follows.ts";
|
|
9
11
|
import { type Tools, type Track } from "./audio.ts";
|
|
10
12
|
import { type Command, type RemoteTrack, type Snapshot } from "./protocol.ts";
|
|
11
13
|
export declare const SERVE_BAND_COUNT = 24;
|
|
@@ -200,6 +202,19 @@ export interface HandlerOptions {
|
|
|
200
202
|
secureCookies?: boolean;
|
|
201
203
|
/** Who may administer this server. */
|
|
202
204
|
owner?: Owner;
|
|
205
|
+
/**
|
|
206
|
+
* The dial-in party line, on the instance that answers the phone number.
|
|
207
|
+
* Only nixamp.com passes this; a nixamp on a laptop has no number.
|
|
208
|
+
*/
|
|
209
|
+
partyLine?: PartyLine;
|
|
210
|
+
/**
|
|
211
|
+
* Following broadcasters, and where to reach the people who do. Durable,
|
|
212
|
+
* unlike everything else here, because the point of a follow is to outlive
|
|
213
|
+
* the stream.
|
|
214
|
+
*/
|
|
215
|
+
follows?: Follows;
|
|
216
|
+
/** The VAPID public key a browser needs before it can subscribe. */
|
|
217
|
+
vapidPublicKey?: string;
|
|
203
218
|
}
|
|
204
219
|
/**
|
|
205
220
|
* The whole HTTP surface, as a plain function of a request — so a test can
|