@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 +4 -4
- package/dist/bus/protocol.js +1 -0
- package/dist/client.d.ts +2 -2
- package/dist/lifecycle/rules.js +1 -2
- package/dist/saves/client.d.ts +18 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
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(); //
|
|
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()`
|
|
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
|
-
//
|
|
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.
|
|
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
|
|
package/dist/bus/protocol.js
CHANGED
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
|
|
28
|
-
*
|
|
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
|
*/
|
package/dist/lifecycle/rules.js
CHANGED
|
@@ -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.
|
|
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
|
package/dist/saves/client.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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 `
|
|
23
|
-
* version of the game), `"build"` (only this
|
|
24
|
-
* until the page closes). `undefined` until
|
|
25
|
-
* be added: treat one you don't know as
|
|
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.
|
|
1
|
+
export declare const VERSION = "1.4.2";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED