@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 +21 -10
- package/dist/lifecycle/client.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
<h1 align="center">Arcadible SDK</h1>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
33
|
+
## Initialization
|
|
33
34
|
|
|
34
35
|
```js
|
|
35
36
|
import { arcadible } from "@arcadible/sdk";
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
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. `
|
|
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
|
|
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
|
-
- [
|
|
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
|
package/dist/lifecycle/client.js
CHANGED
|
@@ -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()
|
|
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.
|
|
1
|
+
export declare const VERSION = "1.3.1";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED