playertwo-sdk 0.2.13 → 0.2.14

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.
Files changed (2) hide show
  1. package/index.d.ts +45 -1
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -115,6 +115,9 @@ export interface Unlocked {
115
115
  /** The completion trophy, earned with this one. */
116
116
  complete?: Trophy;
117
117
  test?: boolean;
118
+ /** A guest's (p2.guest): kept for them until they sign in, when their account earns it (numbered, with its XP); n is
119
+ null and there is no XP until then. */
120
+ guest?: true;
118
121
  }
119
122
 
120
123
  export interface Addon {
@@ -148,6 +151,9 @@ export interface Submitted {
148
151
  previous: number | null;
149
152
  rank: number | null;
150
153
  total: number | null;
154
+ /** A guest's (p2.guest): their best kept for them until they sign in, when it goes to their account's place on the
155
+ board; no rank or total until then. */
156
+ guest?: true;
151
157
  }
152
158
 
153
159
  export interface BoardRow {
@@ -340,6 +346,39 @@ export interface Donate {
340
346
  button(options?: { corner?: "top-right" | "top-left" | "bottom-right" | "bottom-left"; parent?: HTMLElement }): Promise<HTMLButtonElement | null>;
341
347
  }
342
348
 
349
+ /** Notifications from the game's server (p2.notify; docs: /docs/sdk#notify), to a player who let the game send them: in
350
+ their PlayerTwo notifications, and on their devices where push is on. The server sends with its key (POST
351
+ /api/v1/sdk/server/notify): one an hour and three a day to a player at most. */
352
+ export interface Notify {
353
+ /** Asks the player, on PlayerTwo's own card over the game, whether the game may notify them, with its reason (`why`,
354
+ up to 120 characters). `asked` is false, and nothing shows, when they said yes already, a card was shown this
355
+ session, or they said not now in the last week. Rejects with code "guest", "busy", "no-notify" (outside
356
+ PlayerTwo's player on the web) or "offline". */
357
+ ask(options?: { why?: string }): Promise<{ allowed: boolean; asked: boolean }>;
358
+ /** Whether the player let the game notify them (false wherever it can't be known). */
359
+ allowed(): Promise<boolean>;
360
+ }
361
+
362
+ /** The device the game runs on (p2.device.get(); docs: /docs/sdk#device), worked out in the game's page once. */
363
+ export interface DeviceInfo {
364
+ /** A starting point for the game's settings. */
365
+ tier: "low" | "mid" | "high";
366
+ phone: boolean;
367
+ touch: boolean;
368
+ /** GB, or null where the browser won't say. */
369
+ memory: number | null;
370
+ cores: number | null;
371
+ /** The GPU's name, or "". */
372
+ gpu: string;
373
+ /** A GPU drawn by the processor (SwiftShader, llvmpipe). */
374
+ software: boolean;
375
+ screen: { w: number; h: number; dpr: number };
376
+ saveData: boolean;
377
+ reducedMotion: boolean;
378
+ /** Frames a second over half a second as it was asked, or null while the page was hidden. */
379
+ fps: number | null;
380
+ }
381
+
343
382
  export interface Stats {
344
383
  /** Every stat. */
345
384
  get(): Promise<{ stats: Record<string, number> }>;
@@ -867,7 +906,8 @@ export interface P2 {
867
906
  /** True in a demo: demos earn no trophies. */
868
907
  demo: boolean;
869
908
  /** True for a guest: playing without a PlayerTwo account (in Instagram's browser, or a card on X). Nothing is sold to
870
- a guest (the store's calls reject "guest"): ask them to sign up with signUp(). */
909
+ a guest (the store's calls reject "guest"): ask them to sign up with signUp(). Their trophies and bests are kept for
910
+ them until they sign in (answered with guest: true). */
871
911
  guest: boolean;
872
912
  /** Asks a guest to sign up to PlayerTwo, on PlayerTwo's own card, with your reason (`why`, up to 80 characters: "To
873
913
  buy the Gold Pack"). In PlayerTwo's player: { ok: true } as they press Sign up (your last saves are asked for,
@@ -892,6 +932,10 @@ export interface P2 {
892
932
  /** Donations to the game's developer, when its studio put them inside the game. */
893
933
  donate: Donate;
894
934
  moments: Moments;
935
+ /** Notifications from the game's server, to players who said yes. */
936
+ notify: Notify;
937
+ /** The device: a quality tier and what it was worked out from. */
938
+ device: { get(): Promise<DeviceInfo> };
895
939
  stats: Stats;
896
940
  scores: Scores;
897
941
  saves: Saves;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playertwo-sdk",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "SDK for HTML5 and browser games on PlayerTwo (playertwo.plus): trophies, leaderboards, stats, cloud saves, in-game purchases, donations to the developer, your own events and errors in your analytics, feeds of outside data, voice chat and multiplayer rooms with server-side room code.",
5
5
  "keywords": [
6
6
  "playertwo",