@wvdsh/sdk-js 0.0.32

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 ADDED
@@ -0,0 +1,52 @@
1
+ # WavedashSDK-JS
2
+ The JS Wavedash SDK allows games developers to interact with the Wavedash Online Services
3
+
4
+ # Local Installation
5
+ This package is hosted on GitHub Packages. Follow these steps to install from GitHub Packages
6
+ 1. Go to https://github.com/settings/tokens and create a Personal Access Token with read:packages permission
7
+ 2. Copy it and add to your bash profile
8
+ ```
9
+ export NODE_AUTH_TOKEN=yourtoken >> ~/.bashrc
10
+ ```
11
+ 3. Add the following to your `.npmrc` file in your project
12
+ ```
13
+ @wvdsh:registry=https://npm.pkg.github.com
14
+ //npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
15
+ ```
16
+
17
+ Now install the package:
18
+ ```
19
+ npm install @wvdsh/js
20
+ ```
21
+
22
+ # Usage
23
+ On the page that hosts the WASM game
24
+ ```javascript
25
+ import { setupWavedashSDK } from '@wvdsh/js';
26
+ import { useConvexClient } from 'convex-svelte';
27
+
28
+ const convexClient = useConvexClient();
29
+ const wavedashUser = {
30
+ id: ..., // fetched from backend
31
+ username: ... // fetched from backend
32
+ };
33
+ // Game session from the Wavedash backend that authorizes this user to play this game
34
+ const gameSessionToken = ...; // fetched from backend
35
+
36
+ setupWavedashSDK(convexClient, gameSessionToken, wavedashUser);
37
+ ```
38
+
39
+ WavedashJS is now set up, authenticated, and attached to the window.
40
+
41
+ If running a Unity game, we also need to give WavedashJS a reference to the Unity instance:
42
+ ```javascript
43
+ createUnityInstance(canvas, config, (progress: number) => {
44
+ loadingProgress = progress;
45
+ })
46
+ .then((instance: UnityInstance) => {
47
+ if ((window as any).WavedashJS) {
48
+ (window as any).WavedashJS.setEngineInstance(instance);
49
+ }
50
+ })
51
+ ```
52
+