dewdrop-sdk 0.5.4 → 0.5.5
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/package.json +1 -1
- package/src/index.js +3 -2
- package/src/session.js +18 -3
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
// runs, `clients`, in that backend, over its port back, and `saves` into
|
|
6
6
|
// the browser's own storage, which the plugin's script empties as each
|
|
7
7
|
// page loads; `session` says when a session ends ahead of time, which here
|
|
8
|
-
// none does,
|
|
9
|
-
// nothing
|
|
8
|
+
// none does, lets a game end its player's session, which here ends
|
|
9
|
+
// nothing, and lets a game allow portrait views, which here the browser's
|
|
10
|
+
// window already gives; and `voice` reads the microphone through the browser's own
|
|
10
11
|
// audio worklet, into the chunks a game gets on Dewdrop.
|
|
11
12
|
export { llm } from './llm.js';
|
|
12
13
|
export { backend } from './backend.js';
|
package/src/session.js
CHANGED
|
@@ -12,12 +12,21 @@
|
|
|
12
12
|
// `session.exit()`, which on Dewdrop takes the player back to Dewdrop's
|
|
13
13
|
// home page while the room's other players play on, the game hearing
|
|
14
14
|
// `'exit'` as it goes; a backend has no player to send anywhere, so there it
|
|
15
|
-
// throws NotSupportedError.
|
|
16
|
-
//
|
|
17
|
-
//
|
|
15
|
+
// throws NotSupportedError. A game that lays itself out for either shape
|
|
16
|
+
// calls `session.allowPortrait()`, after which Dewdrop turns its view
|
|
17
|
+
// portrait whenever its player's page asks — a phone held upright — and the
|
|
18
|
+
// game hears each turn as a `resize`, its window taking the view's new
|
|
19
|
+
// shape; until then a session stays landscape, and a backend, which has no
|
|
20
|
+
// view, throws NotSupportedError. `npm run dev` ends no session, so here
|
|
21
|
+
// `ending` stays null and the event never fires, a game trying its handler
|
|
22
|
+
// by calling it, and `exit()` ends nothing: the console says so, once. The
|
|
23
|
+
// game here is the browser's own window, which already takes any shape and
|
|
24
|
+
// fires its own `resize`, so `allowPortrait()` changes nothing and says
|
|
25
|
+
// what it does on Dewdrop, once.
|
|
18
26
|
import { defineHandlers, side } from './net.js';
|
|
19
27
|
|
|
20
28
|
let told = false;
|
|
29
|
+
let toldPortrait = false;
|
|
21
30
|
class Session extends EventTarget {
|
|
22
31
|
get ending() { return null; }
|
|
23
32
|
exit() {
|
|
@@ -26,6 +35,12 @@ class Session extends EventTarget {
|
|
|
26
35
|
told = true;
|
|
27
36
|
console.info('[dewdrop] session.exit(): on Dewdrop this ends the session and takes the player back to Dewdrop’s home page; npm run dev keeps the game running');
|
|
28
37
|
}
|
|
38
|
+
allowPortrait() {
|
|
39
|
+
if (side.backend) throw new DOMException('session.allowPortrait is unavailable in a backend', 'NotSupportedError');
|
|
40
|
+
if (toldPortrait) return;
|
|
41
|
+
toldPortrait = true;
|
|
42
|
+
console.info('[dewdrop] session.allowPortrait(): on Dewdrop the view turns portrait whenever the player’s page is taller than wide, each turn a resize; npm run dev’s window already takes any shape');
|
|
43
|
+
}
|
|
29
44
|
}
|
|
30
45
|
defineHandlers(Session.prototype, ['ending']);
|
|
31
46
|
|