@unboxy/phaser-sdk 0.2.2 → 0.2.3
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/SDK-GUIDE.md +1 -0
- package/dist/core/Unboxy.js +9 -2
- package/package.json +1 -1
package/SDK-GUIDE.md
CHANGED
|
@@ -134,6 +134,7 @@ this.highScore = typeof saved === 'number' ? saved : 0;
|
|
|
134
134
|
|
|
135
135
|
## Changelog
|
|
136
136
|
|
|
137
|
+
- **0.2.3** — anonymous users now use localStorage even inside a host (was throwing UNAUTHENTICATED when calling `saves` in home-ui without login)
|
|
137
138
|
- **0.2.2** — added `SDK-GUIDE.md`
|
|
138
139
|
- **0.2.1** — added `Unboxy.init`, `unboxy.user`, `unboxy.saves`, Transport abstraction (PostMessage + LocalStorage backends)
|
|
139
140
|
- **0.2.0** — added `UnboxyScene`, recording support. Migrated to public npm.
|
package/dist/core/Unboxy.js
CHANGED
|
@@ -2,7 +2,7 @@ import { PostMessageTransport } from './transports/PostMessageTransport.js';
|
|
|
2
2
|
import { LocalStorageTransport } from './transports/LocalStorageTransport.js';
|
|
3
3
|
import { SavesModule } from '../saves/SavesModule.js';
|
|
4
4
|
// Kept in sync with package.json on each publish.
|
|
5
|
-
const SDK_VERSION = '0.2.
|
|
5
|
+
const SDK_VERSION = '0.2.3';
|
|
6
6
|
/**
|
|
7
7
|
* Unboxy platform services bound to the current (game, user).
|
|
8
8
|
*
|
|
@@ -13,7 +13,14 @@ const SDK_VERSION = '0.2.2';
|
|
|
13
13
|
export class Unboxy {
|
|
14
14
|
constructor(transport) {
|
|
15
15
|
this.transport = transport;
|
|
16
|
-
|
|
16
|
+
// Saves are per-user. When the viewer is anonymous (no logged-in user),
|
|
17
|
+
// route save calls to localStorage even if a host is attached — the host
|
|
18
|
+
// backend requires auth, so forwarding would 401. Other module surfaces
|
|
19
|
+
// (future leaderboards, etc.) can still use the primary transport.
|
|
20
|
+
const savesTransport = transport.user === null
|
|
21
|
+
? new LocalStorageTransport(transport.gameId || 'anonymous')
|
|
22
|
+
: transport;
|
|
23
|
+
this.saves = new SavesModule(savesTransport);
|
|
17
24
|
}
|
|
18
25
|
/** The current authenticated user, or `null` if anonymous / standalone. */
|
|
19
26
|
get user() { return this.transport.user; }
|