@minca/core 0.1.14 → 0.1.15
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 +2 -2
- package/dist/files/space-files.d.ts +15 -3
- package/dist/files/space-files.d.ts.map +1 -1
- package/dist/files/space-files.js +225 -37
- package/dist/files/space-files.js.map +1 -1
- package/dist/network/relay-minca.d.ts +12 -1
- package/dist/network/relay-minca.d.ts.map +1 -1
- package/dist/network/relay-minca.js +14 -6
- package/dist/network/relay-minca.js.map +1 -1
- package/dist/network/relay-nostr.d.ts +14 -3
- package/dist/network/relay-nostr.d.ts.map +1 -1
- package/dist/network/relay-nostr.js +11 -9
- package/dist/network/relay-nostr.js.map +1 -1
- package/dist/network/relays.d.ts +26 -17
- package/dist/network/relays.d.ts.map +1 -1
- package/dist/network/relays.js +21 -28
- package/dist/network/relays.js.map +1 -1
- package/dist/network/rendezvous.d.ts +1 -1
- package/dist/network/rendezvous.d.ts.map +1 -1
- package/dist/network/rendezvous.js +2 -2
- package/dist/network/rendezvous.js.map +1 -1
- package/dist/node/actions.d.ts.map +1 -1
- package/dist/node/actions.js +6 -1
- package/dist/node/actions.js.map +1 -1
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +7 -7
- package/dist/node/node.js.map +1 -1
- package/dist/node/space-runtime.d.ts +1 -1
- package/dist/node/space-runtime.d.ts.map +1 -1
- package/dist/node/space-runtime.js +17 -5
- package/dist/node/space-runtime.js.map +1 -1
- package/dist/node/types.d.ts +4 -3
- package/dist/node/types.d.ts.map +1 -1
- package/dist/schema/collection-def.d.ts.map +1 -1
- package/dist/schema/collection-def.js +16 -5
- package/dist/schema/collection-def.js.map +1 -1
- package/dist/schemas/automations.d.ts +8 -0
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/connectors.d.ts +12 -0
- package/dist/schemas/connectors.d.ts.map +1 -1
- package/dist/schemas/fragments.d.ts +22 -2
- package/dist/schemas/fragments.d.ts.map +1 -1
- package/dist/schemas/fragments.js +20 -12
- package/dist/schemas/fragments.js.map +1 -1
- package/dist/schemas/library/annotations.d.ts +30 -0
- package/dist/schemas/library/annotations.d.ts.map +1 -1
- package/dist/schemas/library/annotations.js +1 -0
- package/dist/schemas/library/annotations.js.map +1 -1
- package/dist/schemas/library/community.d.ts +28 -0
- package/dist/schemas/library/community.d.ts.map +1 -1
- package/dist/schemas/library/life.d.ts +62 -2
- package/dist/schemas/library/life.d.ts.map +1 -1
- package/dist/schemas/library/media.d.ts +36 -0
- package/dist/schemas/library/media.d.ts.map +1 -1
- package/dist/schemas/library/money.d.ts +74 -2
- package/dist/schemas/library/money.d.ts.map +1 -1
- package/dist/schemas/library/planning.d.ts +56 -0
- package/dist/schemas/library/planning.d.ts.map +1 -1
- package/dist/schemas/library/publishing.d.ts +80 -4
- package/dist/schemas/library/publishing.d.ts.map +1 -1
- package/dist/schemas/library/social.d.ts +44 -0
- package/dist/schemas/library/social.d.ts.map +1 -1
- package/docs/README.md +2 -2
- package/docs/actions.md +47 -20
- package/docs/blueprints-and-guides.md +41 -13
- package/docs/building-an-app.md +4 -4
- package/docs/collections.md +31 -3
- package/docs/node.md +14 -12
- package/docs/standard-library.md +26 -25
- package/docs/storage.md +33 -10
- package/package.json +2 -21
- package/dist/calls/calls.d.ts +0 -140
- package/dist/calls/calls.d.ts.map +0 -1
- package/dist/calls/calls.js +0 -861
- package/dist/calls/calls.js.map +0 -1
- package/dist/calls/index.d.ts +0 -4
- package/dist/calls/index.d.ts.map +0 -1
- package/dist/calls/index.js +0 -3
- package/dist/calls/index.js.map +0 -1
- package/dist/react/context.d.ts +0 -81
- package/dist/react/context.d.ts.map +0 -1
- package/dist/react/context.js +0 -97
- package/dist/react/context.js.map +0 -1
- package/dist/react/follow.d.ts +0 -11
- package/dist/react/follow.d.ts.map +0 -1
- package/dist/react/follow.js +0 -7
- package/dist/react/follow.js.map +0 -1
- package/dist/react/index.d.ts +0 -44
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -40
- package/dist/react/index.js.map +0 -1
- package/dist/react/minca-auth.d.ts +0 -19
- package/dist/react/minca-auth.d.ts.map +0 -1
- package/dist/react/minca-auth.js +0 -36
- package/dist/react/minca-auth.js.map +0 -1
- package/dist/react/use-calls.d.ts +0 -21
- package/dist/react/use-calls.d.ts.map +0 -1
- package/dist/react/use-calls.js +0 -39
- package/dist/react/use-calls.js.map +0 -1
- package/dist/react/use-invite-link.d.ts +0 -24
- package/dist/react/use-invite-link.d.ts.map +0 -1
- package/dist/react/use-invite-link.js +0 -62
- package/dist/react/use-invite-link.js.map +0 -1
- package/dist/react/use-live.d.ts +0 -16
- package/dist/react/use-live.d.ts.map +0 -1
- package/dist/react/use-live.js +0 -56
- package/dist/react/use-live.js.map +0 -1
- package/dist/react/use-my-name.d.ts +0 -12
- package/dist/react/use-my-name.d.ts.map +0 -1
- package/dist/react/use-my-name.js +0 -38
- package/dist/react/use-my-name.js.map +0 -1
- package/dist/react/use-names.d.ts +0 -7
- package/dist/react/use-names.d.ts.map +0 -1
- package/dist/react/use-names.js +0 -13
- package/dist/react/use-names.js.map +0 -1
- package/dist/react/use-network.d.ts +0 -9
- package/dist/react/use-network.d.ts.map +0 -1
- package/dist/react/use-network.js +0 -33
- package/dist/react/use-network.js.map +0 -1
- package/dist/react/use-query.d.ts +0 -14
- package/dist/react/use-query.d.ts.map +0 -1
- package/dist/react/use-query.js +0 -26
- package/dist/react/use-query.js.map +0 -1
- package/dist/react/use-space.d.ts +0 -29
- package/dist/react/use-space.d.ts.map +0 -1
- package/dist/react/use-space.js +0 -57
- package/dist/react/use-space.js.map +0 -1
- package/dist/react/use-spaces.d.ts +0 -29
- package/dist/react/use-spaces.d.ts.map +0 -1
- package/dist/react/use-spaces.js +0 -78
- package/dist/react/use-spaces.js.map +0 -1
- package/docs/calls.md +0 -189
package/docs/standard-library.md
CHANGED
|
@@ -90,18 +90,19 @@ keep the library small enough to choose from, and each choice obvious:
|
|
|
90
90
|
out in each definition, built by the library's `fragments` so they are
|
|
91
91
|
identical everywhere:
|
|
92
92
|
|
|
93
|
-
| Fragment | Shape
|
|
94
|
-
| ---------- |
|
|
95
|
-
| `when` | string 10–64: RFC 3339 date-time (`2026-03-01T18:30:00+01:00`), or `YYYY-MM-DD` for a whole day |
|
|
96
|
-
| `day` | string of 10: `YYYY-MM-DD`
|
|
97
|
-
| `
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
93
|
+
| Fragment | Shape |
|
|
94
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| `when` | string 10–64, `x-kind: "when"`: RFC 3339 date-time (`2026-03-01T18:30:00+01:00`), or `YYYY-MM-DD` for a whole day |
|
|
96
|
+
| `day` | string of 10, `x-kind: "day"`: `YYYY-MM-DD` |
|
|
97
|
+
| `url` | string 1–2048, `x-kind: "url"`: a web address |
|
|
98
|
+
| `timeZone` | string 1–64: an IANA zone, `Europe/Oslo` |
|
|
99
|
+
| DID | string 1–256, `x-kind: "did"`: an account DID (built by `person`) |
|
|
100
|
+
| `money` | `{ amount, currency }`, `x-kind: "money"`, both required: `amount` a decimal string 1–32 (`"12.50"`), never a number; `currency` ISO 4217, 3 characters |
|
|
101
|
+
| `address` | `{ street, locality, region, postcode, country }`, each optional; `country` ISO 3166-1 alpha-2 |
|
|
102
|
+
| `place` | `{ name, address, lat, lon, cells }` (built by `placeRef`), each optional; `lat` −90–90, `lon` −180–180, WGS 84; `cells` string 1–12[] (≤ 8), the geohash cells of `lat` and `lon` (see Places and areas) |
|
|
103
|
+
| `blob` | `{ hash, size, mime, name?, key?, salt? }`, `x-kind: "file"`: what `records.addFile` gives: `hash` the file's id (64 hex characters), `size` bytes as stored, `mime` required; `key` and `salt` open it (22 base64url characters each) |
|
|
104
|
+
| `image` | `{ blob, alt? }`, `x-kind: "image"`: `alt` ≤ 2000, what it shows |
|
|
105
|
+
| `position` | string 1–200, `x-kind: "position"`, that sorts where a record goes (Positions, below) |
|
|
105
106
|
|
|
106
107
|
Until the dialect has `format` ([spec 02 §6.2](https://github.com/leifriksheim/minca/blob/main/spec/02-records.md)), `when` and `day` are checked only for
|
|
107
108
|
length. A `blob` is what `records.addFile` gives
|
|
@@ -125,17 +126,17 @@ anything, and only moderators and admins write in the collections in
|
|
|
125
126
|
|
|
126
127
|
**Annotations**
|
|
127
128
|
|
|
128
|
-
| Name | Body | Links
|
|
129
|
-
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
130
|
-
| `std.reaction` | **`emoji`** string 1–16; `respondingTo` DID; topic `respondingTo` | `about` → `*`, one
|
|
131
|
-
| `std.comment` | **`text`** string 1–10000; `mentions` DID[] (≤ 64); `replyingTo` DID; `respondingTo` DID; topics `mentions`, `replyingTo`, `respondingTo` | `about` → `*`, one; `replyTo` → `std.comment`, one | — |
|
|
132
|
-
| `std.tag` | **`label`** string 1–100 | `about` → `*`, one
|
|
133
|
-
| `std.rating` | **`score`** integer 1–5; `review` string ≤ 10000 | `about` → `*`, one
|
|
134
|
-
| `std.highlight` | **`quote`** string 1–10000; `prefix` string ≤ 500; `suffix` string ≤ 500; `note` string ≤ 10000 | `about` → `*`, one
|
|
135
|
-
| `std.pin` | `note` string ≤ 500 | `about` → `*`, one
|
|
136
|
-
| `std.report` | **`reason`** `spam`/`abuse`/`sexual`/`misleading`/`illegal`/`other`; `note` string ≤ 2000 | `about` → `*`, one
|
|
137
|
-
| `std.label` | **`value`** string 1–64 | `about` → `*`, one
|
|
138
|
-
| `std.claim` | `note` string ≤ 500; `respondingTo` DID; topic `respondingTo` | `about` → `*`, one
|
|
129
|
+
| Name | Body | Links | Rules |
|
|
130
|
+
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -------------------------------------- |
|
|
131
|
+
| `std.reaction` | **`emoji`** string 1–16; `respondingTo` DID; topic `respondingTo` | `about` → `*`, one | `onePer: [@author, link:about, emoji]` |
|
|
132
|
+
| `std.comment` | **`text`** string 1–10000; `mentions` DID[] (≤ 64); `replyingTo` DID; `respondingTo` DID; topics `mentions`, `replyingTo`, `respondingTo` | `about` → `*`, one; `replyTo` → `std.comment`, one; `shares` → `*`, one | — |
|
|
133
|
+
| `std.tag` | **`label`** string 1–100 | `about` → `*`, one | `onePer: [@author, link:about, label]` |
|
|
134
|
+
| `std.rating` | **`score`** integer 1–5; `review` string ≤ 10000 | `about` → `*`, one | `onePer: [@author, link:about]` |
|
|
135
|
+
| `std.highlight` | **`quote`** string 1–10000; `prefix` string ≤ 500; `suffix` string ≤ 500; `note` string ≤ 10000 | `about` → `*`, one | — |
|
|
136
|
+
| `std.pin` | `note` string ≤ 500 | `about` → `*`, one | `onePer: [link:about]` |
|
|
137
|
+
| `std.report` | **`reason`** `spam`/`abuse`/`sexual`/`misleading`/`illegal`/`other`; `note` string ≤ 2000 | `about` → `*`, one | `onePer: [@author, link:about]` |
|
|
138
|
+
| `std.label` | **`value`** string 1–64 | `about` → `*`, one | `onePer: [link:about, value]` |
|
|
139
|
+
| `std.claim` | `note` string ≤ 500; `respondingTo` DID; topic `respondingTo` | `about` → `*`, one | `onePer: [link:about]` |
|
|
139
140
|
|
|
140
141
|
**People**
|
|
141
142
|
|
|
@@ -519,7 +520,7 @@ _Source: `packages/core/src/schemas/geo.ts` (`geohash`, `cellsOf`, `cellsAround`
|
|
|
519
520
|
|
|
520
521
|
## `std.call`
|
|
521
522
|
|
|
522
|
-
Calls themselves are kept nowhere ([calls](calls.md)). Their history is a
|
|
523
|
+
Calls themselves are kept nowhere ([calls](../../calls/README.md)). Their history is a
|
|
523
524
|
`std.call` record in the space, written only if the space defines `std.call`:
|
|
524
525
|
|
|
525
526
|
| Field | Type | Meaning |
|
|
@@ -545,4 +546,4 @@ _Implementation detail:_ the call a device is in is kept in `sessionStorage`
|
|
|
545
546
|
under `minca-call` as `{ space, call }`, so after a reload the page can offer to
|
|
546
547
|
rejoin while the call is still going on.
|
|
547
548
|
|
|
548
|
-
_Source: `packages/
|
|
549
|
+
_Source: `packages/calls/src/calls.ts`, `packages/core/src/schemas/library/publishing.ts` (`call`). Tests: `packages/calls/tests/calls.test.ts`._
|
package/docs/storage.md
CHANGED
|
@@ -172,8 +172,12 @@ change and on close.
|
|
|
172
172
|
directory store (`localPath` in `packages/cli/src/home.ts`). A command and
|
|
173
173
|
the daemon share it, and the daemon finds the command's writes as it finds
|
|
174
174
|
any directory store's (`reconcileFolder`). Writer keys are beside it in
|
|
175
|
-
`
|
|
176
|
-
|
|
175
|
+
`writer-keys/`; a slot left in the home from before is not read, nor
|
|
176
|
+
`writers/`, where a minca from before the numbered lock keeps its keys, so
|
|
177
|
+
the two never sign with one key. `minca agent`
|
|
178
|
+
and `minca mcp` keep each session's key and stores together in a slot of
|
|
179
|
+
`<home>/agent`, beside the data folder the sessions share
|
|
180
|
+
([actions](actions.md#the-agent-on-a-computer)).
|
|
177
181
|
- **Elsewhere** it must be given: `folderStores` refuses to start without
|
|
178
182
|
one, since a lasting key's places kept in memory would be handed out again
|
|
179
183
|
after a restart.
|
|
@@ -326,16 +330,35 @@ How this library does the rest:
|
|
|
326
330
|
(`fileRefsIn`, at most 16), so the envelope and the body always agree.
|
|
327
331
|
- **Reading.** `records.readFile(space, ref)` gives the bytes: held here, or
|
|
328
332
|
fetched from connected peers, one after another, then from mirrors,
|
|
329
|
-
checking every chunk.
|
|
330
|
-
|
|
331
|
-
|
|
333
|
+
checking every chunk. When none has them it waits, asking everyone again
|
|
334
|
+
whenever records change or a peer connects, and every 15 s, and resolves
|
|
335
|
+
once one does. It rejects for a file no version this node keeps whole
|
|
336
|
+
names, one whose id is here whole yet won't open as named, and when the
|
|
337
|
+
space closes. For a picture, `URL.createObjectURL(new Blob([bytes], {
|
|
338
|
+
type: ref.mime }))` shows it.
|
|
332
339
|
- **Where chunks live.** Entries in the space's own store: `f/<id>/list`,
|
|
333
|
-
`f/<id>/<n>`,
|
|
334
|
-
|
|
340
|
+
`f/<id>/<n>`, `f/<id>/own` with the time a file was added here (0 once a
|
|
341
|
+
version names it), and `f/<id>/used` with when it was last fetched or
|
|
342
|
+
read. A data folder keeps these in this device's own stores, not the
|
|
335
343
|
folder.
|
|
336
|
-
- **What a node fetches.** A node
|
|
337
|
-
|
|
338
|
-
|
|
344
|
+
- **What a node fetches.** Files follow records. A node fetches every file
|
|
345
|
+
named by a version it keeps whole about 2 s after its records change,
|
|
346
|
+
while the writer is likely still connected. A file this sweep found
|
|
347
|
+
nobody had is not asked of everyone again for 10 minutes, but is asked at
|
|
348
|
+
once of each peer that connects meanwhile.
|
|
349
|
+
- **A device's limits.** A node limits the files it did not add, in every
|
|
350
|
+
space: it fetches unread only files of up to 5 MiB, so photos and
|
|
351
|
+
documents come ahead and video when played. Past 256 MiB of them in a
|
|
352
|
+
space, counting each at the size its list proves, or every chunk held of
|
|
353
|
+
one never whole, it drops those fetched or opened longest ago, down to
|
|
354
|
+
90%, at the start of each pass and as it fetches. One never whole goes
|
|
355
|
+
first. A file added here is never dropped, nor one being fetched or read;
|
|
356
|
+
one larger than the limit is dropped on the pass after it is read, and
|
|
357
|
+
fetched again at the next read. A dropped file that was whole keeps its
|
|
358
|
+
`used` entry, so it is not fetched unread again while a version names it;
|
|
359
|
+
reading it fetches it. The limit is per space, so a device in many spaces
|
|
360
|
+
holds more. A node with `fetchFiles: 'all'`, a carrier or host, fetches
|
|
361
|
+
and keeps every file.
|
|
339
362
|
- **Serving.** A `want-file` is answered with at most 4 chunks; the asker
|
|
340
363
|
asks again for the rest, so a large file never floods a connection.
|
|
341
364
|
- **Keeping.** About 2 s after records change, files no version kept whole
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minca/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Self-sovereign P2P protocol for the browser — identity, schemas, storage, networking, and gossip sync",
|
|
6
6
|
"repository": {
|
|
@@ -51,16 +51,6 @@
|
|
|
51
51
|
"types": "./dist/elements/index.d.ts",
|
|
52
52
|
"import": "./dist/elements/index.js"
|
|
53
53
|
},
|
|
54
|
-
"./react": {
|
|
55
|
-
"@minca/source": "./src/react/index.ts",
|
|
56
|
-
"types": "./dist/react/index.d.ts",
|
|
57
|
-
"import": "./dist/react/index.js"
|
|
58
|
-
},
|
|
59
|
-
"./calls": {
|
|
60
|
-
"@minca/source": "./src/calls/index.ts",
|
|
61
|
-
"types": "./dist/calls/index.d.ts",
|
|
62
|
-
"import": "./dist/calls/index.js"
|
|
63
|
-
},
|
|
64
54
|
"./inbox": {
|
|
65
55
|
"@minca/source": "./src/inbox/index.ts",
|
|
66
56
|
"types": "./dist/inbox/index.d.ts",
|
|
@@ -70,13 +60,12 @@
|
|
|
70
60
|
"scripts": {
|
|
71
61
|
"build": "rm -rf dist && tsc",
|
|
72
62
|
"typecheck": "tsc --noEmit && tsc -p tests",
|
|
73
|
-
"test": "node --experimental-vm-modules --import tsx --test --test-concurrency=
|
|
63
|
+
"test": "node --experimental-vm-modules --import tsx --test --test-concurrency=8 --test-timeout=60000 --test-force-exit tests/*.test.ts",
|
|
74
64
|
"prepack": "node ../../scripts/npm-readme.mjs",
|
|
75
65
|
"postpack": "rm -f README.md",
|
|
76
66
|
"prepublishOnly": "npm run build"
|
|
77
67
|
},
|
|
78
68
|
"devDependencies": {
|
|
79
|
-
"@types/react": "^19.3.0",
|
|
80
69
|
"@types/ws": "^8.18.2",
|
|
81
70
|
"esbuild": "^0.28.2",
|
|
82
71
|
"tsx": "^4.19.0",
|
|
@@ -95,14 +84,6 @@
|
|
|
95
84
|
"@scure/base": "^2.4.0",
|
|
96
85
|
"aws4fetch": "^1.0.20"
|
|
97
86
|
},
|
|
98
|
-
"peerDependencies": {
|
|
99
|
-
"react": "^19.3.1"
|
|
100
|
-
},
|
|
101
|
-
"peerDependenciesMeta": {
|
|
102
|
-
"react": {
|
|
103
|
-
"optional": true
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
87
|
"publishConfig": {
|
|
107
88
|
"access": "public"
|
|
108
89
|
}
|
package/dist/calls/calls.d.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Voice and video calls between the people in a space.
|
|
3
|
-
*
|
|
4
|
-
* Nothing here is new to the protocol. A call is live messages
|
|
5
|
-
* (`node.spaces.send`) in the space it belongs to, and a WebRTC connection of
|
|
6
|
-
* its own between each pair of people in it — the shape Matrix gives group
|
|
7
|
-
* calls (MSC3401, Element Call's full mesh):
|
|
8
|
-
*
|
|
9
|
-
* ```
|
|
10
|
-
* call.here { call, since, camera, muted } to the space, every few seconds while in it
|
|
11
|
-
* call.ring { call } to one account: ring its devices
|
|
12
|
-
* call.answered { call } / call.declined to the caller, and to your own other devices
|
|
13
|
-
* call.cancel { call } the caller gave up ringing
|
|
14
|
-
* call.signal { call, description | candidate } to one device: setting up the connection
|
|
15
|
-
* call.leave { call } to the space: gone now, not in 15 seconds
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* The setup travels over the space's own peer connection, whose handshake
|
|
19
|
-
* proved who is at the other end — so the offer, and the fingerprint of the
|
|
20
|
-
* key the browser will insist on, really come from that person. A relay only
|
|
21
|
-
* ever introduced the two devices; it never sees a call.
|
|
22
|
-
*
|
|
23
|
-
* Only members of the space (anyone holding a role) are rung by, heard in or
|
|
24
|
-
* connected to a call; a view-only reader of a public space is not.
|
|
25
|
-
*
|
|
26
|
-
* A call belongs to the space, not to a screen: it keeps the space open
|
|
27
|
-
* (`spaces.hold`) for as long as it runs, so moving between spaces
|
|
28
|
-
* never interrupts it. One call at a time.
|
|
29
|
-
*
|
|
30
|
-
* Each connection is made with an audio and a video transceiver from the
|
|
31
|
-
* start. Turning the camera on or off, or sharing the screen, swaps the track
|
|
32
|
-
* a sender carries and never renegotiates — so neither side can offer at the
|
|
33
|
-
* same moment as the other, and the side with the lower session DID always
|
|
34
|
-
* makes the offer.
|
|
35
|
-
*/
|
|
36
|
-
import type { P2PNode } from '../node/types.js';
|
|
37
|
-
export interface CallsOptions {
|
|
38
|
-
/** How a WebRTC connection is made. `new RTCPeerConnection` by default. */
|
|
39
|
-
readonly createConnection?: (config: RTCConfiguration) => RTCPeerConnection;
|
|
40
|
-
/** Camera and microphone. `navigator.mediaDevices.getUserMedia` by default. */
|
|
41
|
-
readonly getUserMedia?: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
|
|
42
|
-
/** The screen, for sharing it. `navigator.mediaDevices.getDisplayMedia` by default. */
|
|
43
|
-
readonly getDisplayMedia?: (constraints: DisplayMediaStreamOptions) => Promise<MediaStream>;
|
|
44
|
-
/** How a set of tracks becomes something a `<video>` can show. `new MediaStream` by default. */
|
|
45
|
-
readonly createStream?: (tracks: ReadonlyArray<MediaStreamTrack>) => MediaStream | null;
|
|
46
|
-
/** Where the call you're in is remembered, to offer rejoining after a reload. `sessionStorage` by default; null for nowhere. */
|
|
47
|
-
readonly storage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'> | null;
|
|
48
|
-
/** How often you say you're in a call. Default 5 s. */
|
|
49
|
-
readonly heartbeatMs?: number;
|
|
50
|
-
/** How long without hearing that someone is gone. Default 15 s. */
|
|
51
|
-
readonly goneMs?: number;
|
|
52
|
-
/** How long a ring rings before it's a missed call. Default 45 s. */
|
|
53
|
-
readonly ringMs?: number;
|
|
54
|
-
}
|
|
55
|
-
/** Someone else in the call you're in: one device of theirs */
|
|
56
|
-
export interface CallPeer {
|
|
57
|
-
/** Their device's session DID */
|
|
58
|
-
readonly peer: string;
|
|
59
|
-
/** Their account */
|
|
60
|
-
readonly account: string;
|
|
61
|
-
/** What they send: sound, and video when their camera is on. Null until it arrives. */
|
|
62
|
-
readonly stream: MediaStream | null;
|
|
63
|
-
readonly muted: boolean;
|
|
64
|
-
readonly camera: boolean;
|
|
65
|
-
readonly connection: 'connecting' | 'connected' | 'failed';
|
|
66
|
-
}
|
|
67
|
-
/** The call you're in */
|
|
68
|
-
export interface CurrentCall {
|
|
69
|
-
readonly id: string;
|
|
70
|
-
readonly space: string;
|
|
71
|
-
/** When you joined it, ms */
|
|
72
|
-
readonly joinedAt: number;
|
|
73
|
-
/** Your own camera and microphone, for showing yourself */
|
|
74
|
-
readonly local: MediaStream | null;
|
|
75
|
-
readonly muted: boolean;
|
|
76
|
-
readonly camera: boolean;
|
|
77
|
-
readonly sharing: boolean;
|
|
78
|
-
readonly people: ReadonlyArray<CallPeer>;
|
|
79
|
-
/** Who you're ringing, while it rings — and what came of it, for a moment after */
|
|
80
|
-
readonly outgoing: {
|
|
81
|
-
readonly to: string;
|
|
82
|
-
readonly since: number;
|
|
83
|
-
readonly state: 'ringing' | 'declined' | 'missed';
|
|
84
|
-
} | null;
|
|
85
|
-
/** Something went wrong that you should hear about: no microphone, say */
|
|
86
|
-
readonly problem: string | null;
|
|
87
|
-
}
|
|
88
|
-
/** Someone ringing you */
|
|
89
|
-
export interface IncomingCall {
|
|
90
|
-
readonly id: string;
|
|
91
|
-
readonly space: string;
|
|
92
|
-
/** The caller's account */
|
|
93
|
-
readonly from: string;
|
|
94
|
-
readonly since: number;
|
|
95
|
-
}
|
|
96
|
-
/** A call going on in a space you have open, that you're not in */
|
|
97
|
-
export interface CallAround {
|
|
98
|
-
readonly id: string;
|
|
99
|
-
readonly space: string;
|
|
100
|
-
/** Accounts in it, each once */
|
|
101
|
-
readonly people: ReadonlyArray<string>;
|
|
102
|
-
/** When the first of them joined, ms */
|
|
103
|
-
readonly since: number;
|
|
104
|
-
}
|
|
105
|
-
export interface CallsState {
|
|
106
|
-
readonly current: CurrentCall | null;
|
|
107
|
-
readonly ringing: ReadonlyArray<IncomingCall>;
|
|
108
|
-
readonly around: ReadonlyArray<CallAround>;
|
|
109
|
-
/** The call you were in before this page loaded, while it's still going on */
|
|
110
|
-
readonly rejoin: CallAround | null;
|
|
111
|
-
}
|
|
112
|
-
export interface CallOptions {
|
|
113
|
-
/** Start with the camera on. Default false: sound only. */
|
|
114
|
-
readonly video?: boolean;
|
|
115
|
-
}
|
|
116
|
-
export interface Calls {
|
|
117
|
-
/** What's going on now. The same object until something changes. */
|
|
118
|
-
getState(): CallsState;
|
|
119
|
-
subscribe(listener: () => void): () => void;
|
|
120
|
-
/** Joins the call going on in a space, or starts one. Leaves any other call first. */
|
|
121
|
-
start(space: string, options?: CallOptions & {
|
|
122
|
-
readonly call?: string;
|
|
123
|
-
}): Promise<void>;
|
|
124
|
-
/** Starts a call in a space, and rings one person there — all their devices, until one answers */
|
|
125
|
-
ring(space: string, account: string, options?: CallOptions): Promise<void>;
|
|
126
|
-
answer(id: string, options?: CallOptions): Promise<void>;
|
|
127
|
-
decline(id: string): Promise<void>;
|
|
128
|
-
leave(): Promise<void>;
|
|
129
|
-
setMuted(muted: boolean): void;
|
|
130
|
-
setCamera(on: boolean): Promise<void>;
|
|
131
|
-
/** Shows your screen in place of your camera, until you stop it (or the browser does) */
|
|
132
|
-
shareScreen(): Promise<void>;
|
|
133
|
-
stopSharing(): Promise<void>;
|
|
134
|
-
/** Stops offering `rejoin` */
|
|
135
|
-
forgetRejoin(): void;
|
|
136
|
-
/** Leaves any call and stops listening */
|
|
137
|
-
close(): Promise<void>;
|
|
138
|
-
}
|
|
139
|
-
export declare function createCalls(node: P2PNode, options?: CallsOptions): Calls;
|
|
140
|
-
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../src/calls/calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,kBAAkB,CAAC;AAK3D,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,M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