@arcadible/sdk 1.3.0 → 1.3.1

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
@@ -7,11 +7,12 @@
7
7
  <h1 align="center">Arcadible SDK</h1>
8
8
 
9
9
  <p align="center">
10
- Saves that carry over from one version of your game to the next.
10
+ Arcadible's loading screen for your game, and saves that carry over from one version to the next.
11
11
  </p>
12
12
 
13
13
  <p align="center">
14
14
  <a href="https://developer.arcadible.com/references/arcadible-sdk">Docs</a> ·
15
+ <a href="https://developer.arcadible.com/build/initialization">Initialization</a> ·
15
16
  <a href="https://developer.arcadible.com/build/saves">Saves</a> ·
16
17
  <a href="https://arcadible.com">Arcadible</a> ·
17
18
  <a href="https://studio.arcadible.com">Studio</a>
@@ -19,7 +20,7 @@
19
20
 
20
21
  <br>
21
22
 
22
- Each build of a game on [Arcadible](https://arcadible.com) has its own origin, so its browser storage starts empty with every update. Saves made through the Arcadible SDK are kept by the play page instead, on the player's device, so they carry over. The SDK is optional, and saves are all it does.
23
+ The Arcadible SDK is optional: a game runs on [Arcadible](https://arcadible.com) without it. With it, a game gets two things from the play page around it: its [initialization](https://developer.arcadible.com/build/initialization), bracketed, so Arcadible's loading screen shows the game's splash and progress until its first frame is drawn, and [saves](https://developer.arcadible.com/build/saves), kept by the play page, so the player's progress carries over from one version to the next.
23
24
 
24
25
  ## Install
25
26
 
@@ -29,29 +30,39 @@ npm install @arcadible/sdk
29
30
 
30
31
  The package is for a game with a build step, such as a Vite project. A game without one uses the [hosted script](https://developer.arcadible.com/references/arcadible-sdk#install) instead.
31
32
 
32
- ## Save and load
33
+ ## Initialization
33
34
 
34
35
  ```js
35
36
  import { arcadible } from "@arcadible/sdk";
36
37
 
37
- // at startup: once the saves have loaded, the player's progress, or a new game.
38
- await arcadible.ready;
38
+ await arcadible.initBegin(); // first thing in your game's code
39
+ arcadible.initProgress(0.5);
40
+ // … load, build the scene, and draw the first frame …
41
+ await arcadible.initEnd();
42
+ ```
43
+
44
+ Call `initBegin()` 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 `initEnd()` once your first frame is drawn. Arcadible shows your splash and the progress until then, and `initEnd()` resolves once the loading screen has faded into your game.
45
+
46
+ ## Save and load
47
+
48
+ ```js
49
+ // once the saves have loaded
39
50
  const saved = await arcadible.saves.read("progress");
40
51
  const progress = saved ? JSON.parse(saved) : { level: 1 };
41
52
 
42
- // at a checkpoint:
53
+ // at a checkpoint
43
54
  await arcadible.saves.write("progress", JSON.stringify(progress));
44
55
  ```
45
56
 
46
- A save is a name holding one string. `arcadible.ready` settles once the game's saves have loaded, and never fails; calls made before it wait for it, and from then on `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
+ A save is a name holding one string. Once `initBegin()` 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.
47
58
 
48
- Off Arcadible, such as on your dev server, the package works on its own, with the same rules and limits: saves are kept on the page's own origin, `arcadible.saves.where` is `"build"`, and `arcadible.build` is `null`.
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 `initEnd()` resolves at once, saves are kept in the game's own browser storage, `arcadible.saves.where` is `"build"`, and `arcadible.build` is `null`.
49
60
 
50
61
  ## Learn more
51
62
 
52
- - [Arcadible SDK](https://developer.arcadible.com/references/arcadible-sdk): installing it, the hosted script, `ready` and `build`, and every code.
53
- - [`arcadible.saves`](https://developer.arcadible.com/references/arcadible-sdk/saves): every call, what it returns, and when it fails.
63
+ - [Initialization](https://developer.arcadible.com/build/initialization): where each call goes, progress, and what comes after.
54
64
  - [Saves](https://developer.arcadible.com/build/saves): using saves well, across versions, channels, and tabs, and where they're kept.
65
+ - [Arcadible SDK](https://developer.arcadible.com/references/arcadible-sdk): including it, every call, the saves' included, and every code.
55
66
  - [Limits](https://developer.arcadible.com/references/limits#saves): how many saves, and how large.
56
67
 
57
68
  ## License
@@ -20,7 +20,7 @@ export function createLifecycle(bus, win) {
20
20
  if (warnedLate || !framed)
21
21
  return;
22
22
  warnedLate = true;
23
- log("warn", `${call} came after the page loaded, so Arcadible's loading screen was already down. Call initBegin() first, before anything you await.`);
23
+ log("warn", `${call} came after the page loaded, so Arcadible's loading screen was already down. Call initBegin() as your code starts, before anything you await or schedule for later.`);
24
24
  };
25
25
  const onLoad = function () {
26
26
  if (loaded)
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.3.0";
1
+ export declare const VERSION = "1.3.1";
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.3.0";
3
+ export const VERSION = "1.3.1";
package/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  ],
44
44
  "type": "module",
45
45
  "types": "./dist/index.d.ts",
46
- "version": "1.3.0"
46
+ "version": "1.3.1"
47
47
  }