@playus.club/games-sdk 0.1.0
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/LICENSE.md +35 -0
- package/README.md +129 -0
- package/dist/sdk/babylon/canvas.d.ts +30 -0
- package/dist/sdk/babylon/canvas.d.ts.map +1 -0
- package/dist/sdk/babylon/index.d.ts +3 -0
- package/dist/sdk/babylon/index.d.ts.map +1 -0
- package/dist/sdk/babylon.js +52 -0
- package/dist/sdk/bridge.d.ts +2 -0
- package/dist/sdk/bridge.d.ts.map +1 -0
- package/dist/sdk/chunks/background-DLy8kjVf.js +47 -0
- package/dist/sdk/chunks/debug-BKXPXMKn.js +92 -0
- package/dist/sdk/chunks/touch-hint-BZBB3COY.js +148 -0
- package/dist/sdk/helpers/timeFormat.d.ts +3 -0
- package/dist/sdk/helpers/timeFormat.d.ts.map +1 -0
- package/dist/sdk/i18n.d.ts +55 -0
- package/dist/sdk/i18n.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +366 -0
- package/dist/sdk/mobile-interaction.d.ts +4 -0
- package/dist/sdk/mobile-interaction.d.ts.map +1 -0
- package/dist/sdk/native-bridge.d.ts +45 -0
- package/dist/sdk/native-bridge.d.ts.map +1 -0
- package/dist/sdk/overlay/debug.d.ts +31 -0
- package/dist/sdk/overlay/debug.d.ts.map +1 -0
- package/dist/sdk/overlay/index.d.ts +5 -0
- package/dist/sdk/overlay/index.d.ts.map +1 -0
- package/dist/sdk/overlay/touch-hint.d.ts +12 -0
- package/dist/sdk/overlay/touch-hint.d.ts.map +1 -0
- package/dist/sdk/overlay.js +3 -0
- package/dist/sdk/phaser/container.d.ts +25 -0
- package/dist/sdk/phaser/container.d.ts.map +1 -0
- package/dist/sdk/phaser/index.d.ts +3 -0
- package/dist/sdk/phaser/index.d.ts.map +1 -0
- package/dist/sdk/phaser.js +72 -0
- package/dist/sdk/random.d.ts +5 -0
- package/dist/sdk/random.d.ts.map +1 -0
- package/dist/sdk/sound.d.ts +36 -0
- package/dist/sdk/sound.d.ts.map +1 -0
- package/dist/sdk/tap-to-start.d.ts +19 -0
- package/dist/sdk/tap-to-start.d.ts.map +1 -0
- package/dist/sdk/three/canvas.d.ts +13 -0
- package/dist/sdk/three/canvas.d.ts.map +1 -0
- package/dist/sdk/three/index.d.ts +3 -0
- package/dist/sdk/three/index.d.ts.map +1 -0
- package/dist/sdk/three.js +36 -0
- package/dist/sdk/timing.d.ts +4 -0
- package/dist/sdk/timing.d.ts.map +1 -0
- package/dist/sdk/types/background.d.ts +33 -0
- package/dist/sdk/types/background.d.ts.map +1 -0
- package/dist/sdk/url-params.d.ts +5 -0
- package/dist/sdk/url-params.d.ts.map +1 -0
- package/package.json +77 -0
- package/src/playus/fonts.css +29 -0
- package/src/playus/global.css +14 -0
- package/src/playus/styles.css +61 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Language } from './i18n';
|
|
2
|
+
import { type TouchHintType } from './overlay/touch-hint';
|
|
3
|
+
export type TapToStartMode = 'dismiss-only' | 'pass-first-input';
|
|
4
|
+
export type LocalizedText = string | Partial<Record<Language, string>>;
|
|
5
|
+
export type TapToStartOverlay = {
|
|
6
|
+
show: () => void;
|
|
7
|
+
hide: () => void;
|
|
8
|
+
destroy: () => void;
|
|
9
|
+
};
|
|
10
|
+
type TapToStartOptions = {
|
|
11
|
+
parent?: HTMLElement;
|
|
12
|
+
text?: LocalizedText;
|
|
13
|
+
touchHint?: TouchHintType | false;
|
|
14
|
+
mode?: TapToStartMode;
|
|
15
|
+
onStart: (event: PointerEvent) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function createTapToStartOverlay(options: TapToStartOptions): TapToStartOverlay;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=tap-to-start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap-to-start.d.ts","sourceRoot":"","sources":["../../src/playus/tap-to-start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE3F,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,kBAAkB,CAAC;AACjE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,aAAa,GAAG,KAAK,CAAC;IAClC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CA2DrF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BackgroundConfig } from '../types/background';
|
|
2
|
+
export type ThreeCanvasOptions = {
|
|
3
|
+
aspectRatio?: number;
|
|
4
|
+
background?: BackgroundConfig;
|
|
5
|
+
};
|
|
6
|
+
export declare function createThreeCanvas(options?: ThreeCanvasOptions): HTMLCanvasElement;
|
|
7
|
+
export declare function getThreeRendererOptions(background?: BackgroundConfig): {
|
|
8
|
+
alpha: boolean;
|
|
9
|
+
antialias: boolean;
|
|
10
|
+
powerPreference: "high-performance";
|
|
11
|
+
preserveDrawingBuffer: boolean;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=canvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../../../src/playus/three/canvas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAqC,MAAM,qBAAqB,CAAC;AAE/F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CAwCrF;AAED,wBAAgB,uBAAuB,CAAC,UAAU,CAAC,EAAE,gBAAgB;;;;;EAOpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/playus/three/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { i as e, n as t, o as n, r } from "./chunks/background-DLy8kjVf.js";
|
|
2
|
+
//#region src/playus/three/canvas.ts
|
|
3
|
+
function i(r = {}) {
|
|
4
|
+
let i = r.aspectRatio ?? 1.6, a = t(r.background), o = document.createElement("div");
|
|
5
|
+
o.id = "game-root", Object.assign(o.style, {
|
|
6
|
+
position: "fixed",
|
|
7
|
+
inset: "0",
|
|
8
|
+
display: "grid",
|
|
9
|
+
placeItems: "center",
|
|
10
|
+
background: a ?? "transparent"
|
|
11
|
+
}), e(o), document.body.appendChild(o);
|
|
12
|
+
let s = document.createElement("div");
|
|
13
|
+
s.id = "game-viewport", Object.assign(s.style, {
|
|
14
|
+
width: `min(100vw, calc(100vh / ${i}))`,
|
|
15
|
+
aspectRatio: `${1 / i}`,
|
|
16
|
+
position: "relative",
|
|
17
|
+
overflow: "hidden",
|
|
18
|
+
background: a ?? "transparent"
|
|
19
|
+
}), e(s), o.appendChild(s);
|
|
20
|
+
let c = document.createElement("canvas");
|
|
21
|
+
return c.id = "gameCanvas", Object.assign(c.style, {
|
|
22
|
+
width: "100%",
|
|
23
|
+
height: "100%",
|
|
24
|
+
display: "block"
|
|
25
|
+
}), e(c), n(c), s.appendChild(c), c;
|
|
26
|
+
}
|
|
27
|
+
function a(e) {
|
|
28
|
+
return {
|
|
29
|
+
alpha: r(e),
|
|
30
|
+
antialias: !0,
|
|
31
|
+
powerPreference: "high-performance",
|
|
32
|
+
preserveDrawingBuffer: !1
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { i as createThreeCanvas, a as getThreeRendererOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../src/playus/timing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGtE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background configuration for games
|
|
3
|
+
*
|
|
4
|
+
* Games run in iOS WKWebView where transparent backgrounds let the native
|
|
5
|
+
* iOS UI show through. When a game doesn't need transparency, using a solid
|
|
6
|
+
* color can provide minor performance improvements by skipping alpha blending.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Transparent (default) - iOS native background shows through
|
|
10
|
+
* { transparent: true }
|
|
11
|
+
*
|
|
12
|
+
* // Solid color - minor performance optimization
|
|
13
|
+
* { transparent: false, color: '#1a1a2e' }
|
|
14
|
+
*/
|
|
15
|
+
export type BackgroundConfig = {
|
|
16
|
+
transparent: true;
|
|
17
|
+
} | {
|
|
18
|
+
transparent: false;
|
|
19
|
+
color: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Default: transparent background for iOS native show-through
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_BACKGROUND: BackgroundConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a background config is transparent
|
|
27
|
+
*/
|
|
28
|
+
export declare function isTransparent(config?: BackgroundConfig): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get background color (returns undefined for transparent)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getBackgroundColor(config?: BackgroundConfig): string | undefined;
|
|
33
|
+
//# sourceMappingURL=background.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.d.ts","sourceRoot":"","sources":["../../../src/playus/types/background.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GACrB;IAAE,WAAW,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAwC,CAAC;AAE1E;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAGhF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-params.d.ts","sourceRoot":"","sources":["../../src/playus/url-params.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASvD;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAU1F"}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@playus.club/games-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/dappsltd/playus-games-sdk.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/dappsltd/playus-games-sdk#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/dappsltd/playus-games-sdk/issues"
|
|
15
|
+
},
|
|
16
|
+
"description": "Playus games SDK: native bridge, host handshake, sounds, haptics, overlays, seeded random, and engine helpers for Playus-compatible web game bundles.",
|
|
17
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
18
|
+
"author": "Dapps Pte Ltd (https://dapps.ltd)",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/sdk",
|
|
21
|
+
"src/playus/*.css",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/sdk/index.d.ts",
|
|
27
|
+
"import": "./dist/sdk/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./phaser": {
|
|
30
|
+
"types": "./dist/sdk/phaser/index.d.ts",
|
|
31
|
+
"import": "./dist/sdk/phaser.js"
|
|
32
|
+
},
|
|
33
|
+
"./babylon": {
|
|
34
|
+
"types": "./dist/sdk/babylon/index.d.ts",
|
|
35
|
+
"import": "./dist/sdk/babylon.js"
|
|
36
|
+
},
|
|
37
|
+
"./three": {
|
|
38
|
+
"types": "./dist/sdk/three/index.d.ts",
|
|
39
|
+
"import": "./dist/sdk/three.js"
|
|
40
|
+
},
|
|
41
|
+
"./overlay": {
|
|
42
|
+
"types": "./dist/sdk/overlay/index.d.ts",
|
|
43
|
+
"import": "./dist/sdk/overlay.js"
|
|
44
|
+
},
|
|
45
|
+
"./styles.css": "./src/playus/styles.css",
|
|
46
|
+
"./fonts.css": "./src/playus/fonts.css",
|
|
47
|
+
"./global.css": "./src/playus/global.css"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"prepublishOnly": "npm run build:sdk",
|
|
51
|
+
"dev": "vite --host --port 8091",
|
|
52
|
+
"dev:starter": "vite games/starter-game --config vite.config.ts --host --port 8090 --strictPort",
|
|
53
|
+
"dev:phaser": "vite games/phaser-example --config vite.config.ts --host --port 8090 --strictPort",
|
|
54
|
+
"dev:babylon": "vite games/babylon-example --config vite.config.ts --host --port 8090 --strictPort",
|
|
55
|
+
"build:sdk": "vite build --config vite.sdk.config.ts && tsc -p tsconfig.sdk.json",
|
|
56
|
+
"build": "tsc --noEmit && npm run build:sdk && vite build --outDir dist/tester && vite build games/starter-game --config vite.config.ts --outDir ../../dist/games/starter-game --emptyOutDir false && vite build games/phaser-example --config vite.config.ts --outDir ../../dist/games/phaser-example --emptyOutDir false && vite build games/babylon-example --config vite.config.ts --outDir ../../dist/games/babylon-example --emptyOutDir false",
|
|
57
|
+
"preview": "vite preview --host --port 4173"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@babylonjs/core": "^8.31.2",
|
|
61
|
+
"phaser": "^3.80.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@babylonjs/core": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"phaser": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@babylonjs/core": "^8.31.2",
|
|
73
|
+
"phaser": "^3.80.0",
|
|
74
|
+
"typescript": "^5.9.2",
|
|
75
|
+
"vite": "^8.1.0"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: "Unbounded";
|
|
3
|
+
src: url("native://fonts/Unbounded.woff2") format("woff2"),
|
|
4
|
+
url("native://fonts/Unbounded.ttf") format("truetype"),
|
|
5
|
+
url("https://pub-f2838cca4376431f9c696446d4a3e503.r2.dev/fonts/Unbounded.woff2") format("woff2");
|
|
6
|
+
font-style: normal;
|
|
7
|
+
font-weight: 400 900;
|
|
8
|
+
font-display: swap;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@font-face {
|
|
12
|
+
font-family: "Space Grotesk";
|
|
13
|
+
src: url("native://fonts/SpaceGrotesk.woff2") format("woff2"),
|
|
14
|
+
url("native://fonts/SpaceGrotesk.ttf") format("truetype"),
|
|
15
|
+
url("https://pub-f2838cca4376431f9c696446d4a3e503.r2.dev/fonts/SpaceGrotesk.woff2") format("woff2");
|
|
16
|
+
font-style: normal;
|
|
17
|
+
font-weight: 300 800;
|
|
18
|
+
font-display: block;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@font-face {
|
|
22
|
+
font-family: "Quicksand";
|
|
23
|
+
src: url("native://fonts/Quicksand.woff2") format("woff2"),
|
|
24
|
+
url("native://fonts/Quicksand.ttf") format("truetype"),
|
|
25
|
+
url("https://pub-f2838cca4376431f9c696446d4a3e503.r2.dev/fonts/Quicksand.woff2") format("woff2");
|
|
26
|
+
font-style: normal;
|
|
27
|
+
font-weight: 300 700;
|
|
28
|
+
font-display: swap;
|
|
29
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@import "./fonts.css";
|
|
2
|
+
@import "./global.css";
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
color-scheme: dark;
|
|
6
|
+
font-family: "Space Grotesk", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
7
|
+
background: #121214;
|
|
8
|
+
color: #ffffff;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
* {
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
-webkit-tap-highlight-color: transparent;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
html,
|
|
17
|
+
body {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
margin: 0;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
user-select: none;
|
|
23
|
+
touch-action: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
button,
|
|
27
|
+
input,
|
|
28
|
+
select {
|
|
29
|
+
font: inherit;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.playus-game-root {
|
|
33
|
+
position: fixed;
|
|
34
|
+
inset: 0;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
background: #17171d;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.playus-tap-start {
|
|
40
|
+
position: fixed;
|
|
41
|
+
inset: 0;
|
|
42
|
+
z-index: 50;
|
|
43
|
+
display: grid;
|
|
44
|
+
place-items: center;
|
|
45
|
+
padding: 28px;
|
|
46
|
+
background: rgba(0, 0, 0, 0.7);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.playus-tap-start[hidden] {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.playus-tap-start__label {
|
|
54
|
+
max-width: 80%;
|
|
55
|
+
text-align: center;
|
|
56
|
+
color: #ffffff;
|
|
57
|
+
font-family: "Unbounded", "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
58
|
+
font-size: min(5vh, 6vw);
|
|
59
|
+
font-weight: 700;
|
|
60
|
+
line-height: 1.12;
|
|
61
|
+
}
|