@arcadible/sdk 1.4.0 → 1.4.2

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 CHANGED
@@ -35,18 +35,18 @@ The package is for a game with a build step, such as a Vite project. A game with
35
35
  ```js
36
36
  import { arcadible } from "@arcadible/sdk";
37
37
 
38
- await arcadible.initStart(); // first thing in your game's code
38
+ await arcadible.initStart(); // as your code starts, before anything it awaits
39
39
  arcadible.initProgress(0.5);
40
40
  // … load, build the scene, and draw the first frame …
41
41
  await arcadible.initComplete();
42
42
  ```
43
43
 
44
- Call `initStart()` first thing in your game's code, report how far along you are with `initProgress()`, from 0 to 1, if you can measure it, and call `initComplete()` once your first frame is drawn. Arcadible shows your splash and the progress until then, and `initComplete()` resolves once the loading screen has faded into your game.
44
+ Call `initStart()` as your code starts, before anything it awaits, report how far along you are with `initProgress()`, from 0 to 1, if you can measure it, and call `initComplete()` once your first frame is drawn. Arcadible shows your splash and the progress until then, and `initComplete()` resolves once the loading screen has faded into your game.
45
45
 
46
46
  ## Save and load
47
47
 
48
48
  ```js
49
- // once the saves have loaded
49
+ // as your game starts, after initStart()
50
50
  const saved = await arcadible.saves.read("progress");
51
51
  const progress = saved ? JSON.parse(saved) : { level: 1 };
52
52
 
@@ -54,7 +54,7 @@ const progress = saved ? JSON.parse(saved) : { level: 1 };
54
54
  await arcadible.saves.write("progress", JSON.stringify(progress));
55
55
  ```
56
56
 
57
- A save is a name holding one string. Once `initStart()` has resolved, `readSync`, `listSync`, and `infoSync` answer at once from memory, for reads during play. Every call that fails rejects (or, for the sync calls, throws) with an `ArcadibleError`, whose `code` says what to do. `arcadible.saves.where` says who can read the saves back: every version of the game, only this build, or only until the page closes.
57
+ Saves are for what your game remembers between sessions, such as progress, settings, and preferences, not a general key/value store: up to 32 saves, 1 MB together, each named as you choose. A save is a name holding one string. Read your saves once as your game starts, keep the state in your game, and write at checkpoints. Every call returns a promise, and one that fails rejects with an `ArcadibleError`, whose `code` says what to do. `arcadible.saves.where` says who can read the saves back: every version of the game, only this build, or only until the page closes.
58
58
 
59
59
  Off Arcadible, such as on your dev server, the package still works, with the same rules and limits: there's no loading screen, so `initComplete()` resolves at once, saves are kept in the game's own browser storage, `arcadible.saves.where` is `"build"`, and `arcadible.build` is `null`.
60
60
 
@@ -40,6 +40,7 @@ export const Codes = {
40
40
  Busy: "busy",
41
41
  Full: "full",
42
42
  Invalid: "invalid",
43
+ // only `readSync`, `listSync`, and `infoSync` throw it, before `ready`.
43
44
  NotReady: "not_ready",
44
45
  Timeout: "timeout",
45
46
  TooLarge: "too_large",
package/dist/client.d.ts CHANGED
@@ -24,8 +24,8 @@ export interface Arcadible {
24
24
  /** Saves that carry over between the game's versions. */
25
25
  readonly saves: Saves;
26
26
  /**
27
- * Starts the game's initialization: call it first, before anything you
28
- * await, and Arcadible shows the game's loading screen until
27
+ * Starts the game's initialization: call it as your code starts, before
28
+ * anything it awaits, and Arcadible shows the game's loading screen until
29
29
  * `initComplete()`.
30
30
  * It resolves as `ready` does, once the SDK and the saves are ready.
31
31
  */
@@ -14,8 +14,7 @@ export const Names = {
14
14
  Complete: "lifecycle.initComplete",
15
15
  };
16
16
  // The first SDK that sends them. An older one doesn't, so the page takes its
17
- // loading screen down at `load`, without waiting to hear. 1.3's SDKs sent
18
- // these under other names, so the page treats them as older too.
17
+ // loading screen down at `load`, without waiting to hear.
19
18
  export const INIT_SINCE = "1.4.0";
20
19
  // How long `initComplete()` waits for the page to say the game is visible:
21
20
  // past the loading screen's minimum and fade, and a device held the wrong
@@ -12,17 +12,28 @@ export interface Saves {
12
12
  info(name: string): Promise<SaveInfo | null>;
13
13
  /** Removes the save, if there is one. */
14
14
  remove(name: string): Promise<void>;
15
- /** After `ready`, the save's string from memory; before it, throws `not_ready`. */
15
+ /**
16
+ * The save's string from memory, once `ready` has settled; before it,
17
+ * throws `not_ready`. Prefer `await read(name)`: read once as the game
18
+ * starts, and keep the state in the game.
19
+ */
16
20
  readSync(name: string): string | null;
17
- /** After `ready`, the names of the game's saves from memory, sorted. */
21
+ /**
22
+ * The names of the game's saves from memory, sorted, once `ready` has
23
+ * settled. Prefer `await list()`.
24
+ */
18
25
  listSync(): string[];
19
- /** After `ready`, the save's version and time from memory, or `null`. */
26
+ /**
27
+ * Which version wrote the save, and when, from memory, once `ready` has
28
+ * settled. Prefer `await info(name)`.
29
+ */
20
30
  infoSync(name: string): SaveInfo | null;
21
31
  /**
22
- * Who can read the saves back, once `ready` has settled: `"game"` (every
23
- * version of the game), `"build"` (only this build), or `"memory"` (only
24
- * until the page closes). `undefined` until it's known. Other values may
25
- * be added: treat one you don't know as `"game"`.
32
+ * Who can read the saves back, once `initStart()` or `ready` has
33
+ * settled: `"game"` (every version of the game), `"build"` (only this
34
+ * build), or `"memory"` (only until the page closes). `undefined` until
35
+ * it's known. Other values may be added: treat one you don't know as
36
+ * `"game"`.
26
37
  */
27
38
  readonly where: Where | undefined;
28
39
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.4.0";
1
+ export declare const VERSION = "1.4.2";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // The client's version, sent in its hello and shown as `arcadible.version`,
2
2
  // for bug reports. It matches package.json (test/unit/protocol.test.ts).
3
- export const VERSION = "1.4.0";
3
+ export const VERSION = "1.4.2";
package/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  ],
44
44
  "type": "module",
45
45
  "types": "./dist/index.d.ts",
46
- "version": "1.4.0"
46
+ "version": "1.4.2"
47
47
  }