@fabi-play/sdk 0.5.0 → 0.7.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/README.md +27 -1
- package/dist/avatars.js +1 -1
- package/dist/chunks/{chunk-H3BKYVPL.js → chunk-WS2JRQ53.js} +72 -0
- package/dist/fabi-play.d.ts +64 -2
- package/dist/fabi-play.js +1 -1
- package/dist/fabi-play.umd.js +98 -6
- package/dist/fabi-play.umd.min.js +1 -1
- package/dist/index.d.ts +64 -2
- package/dist/index.js +34 -6
- package/dist/integrity.json +5 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AimHold,
|
|
2
3
|
BodyInterpolator,
|
|
3
4
|
MAX_PICTURE_SIDE,
|
|
5
|
+
NO_SAFE_AREA,
|
|
4
6
|
NS,
|
|
5
7
|
PICTURE_JPEG_QUALITY,
|
|
6
8
|
PROTOCOL_VERSION,
|
|
7
9
|
__publicField,
|
|
10
|
+
aimPoint,
|
|
8
11
|
checkPicture,
|
|
9
12
|
defaultAvatarFor,
|
|
10
13
|
drawAvatar,
|
|
@@ -14,13 +17,14 @@ import {
|
|
|
14
17
|
parseGameStats,
|
|
15
18
|
parsePictureResult,
|
|
16
19
|
parsePictureTitle,
|
|
20
|
+
parseSafeArea,
|
|
17
21
|
parseTurnOrder,
|
|
18
22
|
parseTurnPlayers,
|
|
19
23
|
parseView,
|
|
20
24
|
smoothBody,
|
|
21
25
|
toScreen,
|
|
22
26
|
wire
|
|
23
|
-
} from "./chunks/chunk-
|
|
27
|
+
} from "./chunks/chunk-WS2JRQ53.js";
|
|
24
28
|
|
|
25
29
|
// src/adapters.ts
|
|
26
30
|
function muteDuringBreaks(play, win = window) {
|
|
@@ -405,7 +409,7 @@ function easy(connecting) {
|
|
|
405
409
|
p.on("frame", (f) => {
|
|
406
410
|
emit("players", { players: f.players });
|
|
407
411
|
for (const pl of f.players) {
|
|
408
|
-
emit("hands", { player: pl.id, left: pl.leftHand, right: pl.rightHand });
|
|
412
|
+
emit("hands", { player: pl.id, left: pl.leftHand, right: pl.rightHand, aim: { left: p.aim(pl, "left"), right: p.aim(pl, "right") } });
|
|
409
413
|
if (shapes.get(pl.id) !== pl.shape) {
|
|
410
414
|
shapes.set(pl.id, pl.shape);
|
|
411
415
|
emit("shape", { player: pl.id, shape: pl.shape });
|
|
@@ -455,6 +459,12 @@ function easy(connecting) {
|
|
|
455
459
|
get muted() {
|
|
456
460
|
return play?.muted ?? false;
|
|
457
461
|
},
|
|
462
|
+
get orientation() {
|
|
463
|
+
return play?.orientation ?? "landscape";
|
|
464
|
+
},
|
|
465
|
+
get safeArea() {
|
|
466
|
+
return play?.safeArea ?? NO_SAFE_AREA;
|
|
467
|
+
},
|
|
458
468
|
get view() {
|
|
459
469
|
return play?.view ?? null;
|
|
460
470
|
},
|
|
@@ -463,13 +473,14 @@ function easy(connecting) {
|
|
|
463
473
|
},
|
|
464
474
|
reportStats: (s) => play?.reportStats(s),
|
|
465
475
|
toScreen: (p) => play ? play.toScreen(p) : toScreen(null, p),
|
|
476
|
+
aim: (player, side) => play ? play.aim(player, side) : null,
|
|
466
477
|
avatarOf: (player) => play ? play.avatarOf(player) : early.of(player),
|
|
467
478
|
drawAvatar: (...args) => play ? play.drawAvatar(...args) : drawEarly(...args),
|
|
468
479
|
smoothedBody: (...args) => play ? play.smoothedBody(...args) : early.smoothedBody(...args)
|
|
469
480
|
};
|
|
470
481
|
}
|
|
471
482
|
var none = Object.freeze([]);
|
|
472
|
-
var startInfo = (p) => ({ ageRange: p.ageRange, players: p.players, locale: p.locale, mode: p.mode, orientation: p.orientation, backdrop: p.backdrop, view: p.view, device: p.device, turns: p.turns, input: p.input, pointer: p.pointer, canSavePicture: p.canSavePicture, muted: p.muted });
|
|
483
|
+
var startInfo = (p) => ({ ageRange: p.ageRange, players: p.players, locale: p.locale, mode: p.mode, orientation: p.orientation, safeArea: p.safeArea, backdrop: p.backdrop, view: p.view, device: p.device, turns: p.turns, input: p.input, pointer: p.pointer, canSavePicture: p.canSavePicture, muted: p.muted });
|
|
473
484
|
var playingNow = (p) => p.input === "remote" ? p.players[0] ?? 1 : 1;
|
|
474
485
|
function endOf(p, score, last) {
|
|
475
486
|
const now = playingNow(p);
|
|
@@ -536,6 +547,9 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
536
547
|
let started = false;
|
|
537
548
|
let backdrop = "none";
|
|
538
549
|
let view = null;
|
|
550
|
+
let orientation = "landscape";
|
|
551
|
+
let latest = [];
|
|
552
|
+
const hold = new AimHold();
|
|
539
553
|
let input = "body";
|
|
540
554
|
let players = Object.freeze([]);
|
|
541
555
|
let turns = players;
|
|
@@ -568,6 +582,9 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
568
582
|
backdrop = m.backdrop === "video" ? "video" : "none";
|
|
569
583
|
view = parseView(m.view) ?? null;
|
|
570
584
|
const device = parseDeviceHint(m.device) ?? null;
|
|
585
|
+
orientation = m.orientation === "portrait" ? "portrait" : "landscape";
|
|
586
|
+
const safe = parseSafeArea(m.safeArea);
|
|
587
|
+
const safeArea = safe ? Object.freeze(safe) : NO_SAFE_AREA;
|
|
571
588
|
input = m.input === "remote" ? "remote" : "body";
|
|
572
589
|
const pointer2 = input === "remote" && m.pointer === true;
|
|
573
590
|
pictures = m.pictures === true;
|
|
@@ -594,8 +611,8 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
594
611
|
input,
|
|
595
612
|
pointer: pointer2,
|
|
596
613
|
muted: m.muted,
|
|
597
|
-
|
|
598
|
-
|
|
614
|
+
orientation,
|
|
615
|
+
safeArea,
|
|
599
616
|
ageRange: m.ageRange ?? "6-8",
|
|
600
617
|
get backdrop() {
|
|
601
618
|
return backdrop;
|
|
@@ -608,6 +625,14 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
608
625
|
reported = parseGameStats(s);
|
|
609
626
|
},
|
|
610
627
|
toScreen: (p) => toScreen(view, p),
|
|
628
|
+
aim(player, side) {
|
|
629
|
+
const id = typeof player === "number" ? player : player?.id;
|
|
630
|
+
const frame = typeof player === "number" ? latest.find((f) => f.id === player) : player;
|
|
631
|
+
const portrait = orientation === "portrait";
|
|
632
|
+
const body = frame ? (backdrop !== "video" || portrait ? smoothedBody(frame) : null) ?? frame.body : null;
|
|
633
|
+
const p = body ? aimPoint(body, side, { orientation, view }) : null;
|
|
634
|
+
return portrait && typeof id === "number" ? hold.at(AimHold.key(id, side), p, performance.now()) : p;
|
|
635
|
+
},
|
|
611
636
|
avatarOf: (player) => avatars.of(player),
|
|
612
637
|
drawAvatar: drawAvatar2,
|
|
613
638
|
smoothedBody,
|
|
@@ -653,7 +678,10 @@ function connect(channel = windowChannel(), options = {}) {
|
|
|
653
678
|
} else if (!started) return;
|
|
654
679
|
else {
|
|
655
680
|
let message = m;
|
|
656
|
-
if (m.type === "frame" && Array.isArray(m.players))
|
|
681
|
+
if (m.type === "frame" && Array.isArray(m.players)) {
|
|
682
|
+
avatars.note(m.players, m.t);
|
|
683
|
+
latest = m.players;
|
|
684
|
+
}
|
|
657
685
|
if (m.type === "backdrop") {
|
|
658
686
|
if (m.backdrop !== "video" && m.backdrop !== "none") return;
|
|
659
687
|
const next = parseView(m.view) ?? null;
|
package/dist/integrity.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "@fabi-play/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"algorithm": "sha384",
|
|
5
5
|
"files": {
|
|
6
|
-
"fabi-play.js": "sha384-
|
|
7
|
-
"fabi-play.umd.js": "sha384-
|
|
8
|
-
"fabi-play.umd.min.js": "sha384-
|
|
9
|
-
"fabi-play.d.ts": "sha384-
|
|
6
|
+
"fabi-play.js": "sha384-oFpkf9B1CsUDL+XlGXShlfHQ3DTLlgS44lky9VxfWnBeqvmNphqu65gEPayVBIfG",
|
|
7
|
+
"fabi-play.umd.js": "sha384-tK0C5xmAYcSgn3f6b5GwRW4FSvlYaL/mU66pq59HL7PxleXQ8pq5dlscRP2eBBnS",
|
|
8
|
+
"fabi-play.umd.min.js": "sha384-jm4xGGWJgLcbQz0V1il8tK2X6XAIn8DWbSJwMk9qW5ow7f1wnJlMuthrBJ4wPmOl",
|
|
9
|
+
"fabi-play.d.ts": "sha384-ck4BadH6pHuM4CSneqAG70DIGprN0PUMf+DPfGM9D1XUKcnMuQrgqm5d1K3Lmvo4",
|
|
10
10
|
"fabi-play.schema.json": "sha384-MzT9DYjL6d80Ff+4iZQFbrQVpg7q02ok5Bzkb2UKshUStaFZocty+JxuzLHXXheR"
|
|
11
11
|
}
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabi-play/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "What a game imports: players, movements and the end of the game, from inside its sandboxed frame.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fabi-play",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@fabi-play/avatars": "^0.
|
|
40
|
-
"@fabi-play/protocol": "^0.
|
|
39
|
+
"@fabi-play/avatars": "^0.7.0",
|
|
40
|
+
"@fabi-play/protocol": "^0.7.0",
|
|
41
41
|
"dts-bundle-generator": "9.5.1",
|
|
42
42
|
"esbuild": "0.28.2",
|
|
43
43
|
"tsx": "4.23.15",
|