@idosgames/core 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/CHANGELOG.md ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@idosgames/core` are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ > While the version stays in the **`0.x`** range the public API is still stabilizing:
9
+ > breaking changes may land in a **minor** bump. Once the surface is stable we cut
10
+ > `1.0.0`, and from then on breaking changes require a **major** bump.
11
+ >
12
+ > Anything marked `@experimental` in the code is exempt from these guarantees until it
13
+ > is promoted. See [RELEASING.md](../../RELEASING.md) for the full process.
14
+
15
+ ## [Unreleased]
16
+
17
+ ## [0.1.0] - 2026-06-29
18
+
19
+ ### Added
20
+
21
+ - Engine-agnostic core client (`createIDosGamesClient` / `IDosGamesClient`) that owns the
22
+ whole SDK graph: HTTP transport (retry, in-flight dedup, throttle, transparent 401
23
+ re-login), auth, local cache, and a typed event bus.
24
+ - 24 feature domains exposed as services on the client: `auth`, `user`, `currency`,
25
+ `item`, `store`, `lootbox`, `reward`, `quest`, `timedEvent`, `leaderboard`, `season`,
26
+ `premium`, `character`, `match`, `craft`, `collection`, `coopEvent`, `dealOffer`,
27
+ `referral`, `social`, `timedBoost`, `userCustomData`, `title`, `gameLoop`.
28
+ - `OperationResult<T>` discriminated result type — services never throw on expected
29
+ failures; callers branch on `result.ok`.
30
+ - zod-validated response models (the schema is the source of truth via `z.infer`).
31
+ - Platform adapters (`BrowserPlatformAdapter`, `NoopPlatformAdapter`) plus the
32
+ `@idosgames/core/platform` subpath export.
33
+
34
+ ---
35
+
36
+ The game templates `@idosgames/board-game` and `@idosgames/idle-rpg` live in this repo
37
+ as **starter projects** and are intentionally **not** published to npm; they are not
38
+ tracked in this changelog.
39
+
40
+ <!-- When the GitHub remote is known, add compare links here, e.g.:
41
+ [Unreleased]: https://github.com/<org>/<repo>/compare/v0.1.0...HEAD
42
+ -->
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 iDos Games
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # @idosgames/core
2
+
3
+ Engine-agnostic core of the **IDosGames SDK** — HTTP transport, authentication,
4
+ local cache, 24 feature services, and a typed event bus. It knows nothing about
5
+ any rendering engine (Three.js, Phaser, React…), so it works in any browser or
6
+ JS runtime.
7
+
8
+ - **Typed end to end.** Every backend response is validated at runtime with
9
+ [zod](https://zod.dev) before it reaches your code; the published type
10
+ declarations are flat and lightweight.
11
+ - **No exceptions on expected failures.** Service calls return a discriminated
12
+ `OperationResult<T>` (`{ ok: true, data }` or `{ ok: false, reason, error }`).
13
+ - **One client owns the whole graph.** Create it once; reach every service and
14
+ the local cache from it.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @idosgames/core
20
+ ```
21
+
22
+ Peer runtime deps (`zod`, `decimal.js`) are installed automatically.
23
+
24
+ ## Quick start
25
+
26
+ ```ts
27
+ import { createIDosGamesClient, isOk } from "@idosgames/core";
28
+ import { BrowserPlatformAdapter } from "@idosgames/core/platform";
29
+
30
+ const client = createIDosGamesClient({
31
+ titleID: "YOUR_TITLE_ID",
32
+ platform: new BrowserPlatformAdapter(), // storage + platform integration
33
+ });
34
+
35
+ // Authenticate (device id, Telegram, email, Google, or a platform token).
36
+ const login = await client.auth.loginWithDeviceID();
37
+ if (!isOk(login)) {
38
+ console.error("login failed:", login.reason, login.error);
39
+ }
40
+
41
+ // Call any service — results are discriminated, never thrown.
42
+ const res = await client.currency.convert(
43
+ "Virtual",
44
+ "GOLD",
45
+ "Virtual",
46
+ "GEM",
47
+ 100,
48
+ );
49
+ if (isOk(res)) {
50
+ console.log("credited:", res.data.TargetCredited);
51
+ }
52
+
53
+ // Read the local cache and react to changes via the typed event bus.
54
+ const off = client.on("currency:converted", (payload) => {
55
+ console.log("balances updated", payload);
56
+ });
57
+ // later: off();
58
+ ```
59
+
60
+ ## What's on the client
61
+
62
+ `client.auth`, `user`, `currency`, `item`, `store`, `lootbox`, `reward`, `quest`,
63
+ `timedEvent`, `leaderboard`, `season`, `premium`, `character`, `match`, `craft`,
64
+ `collection`, `coopEvent`, `dealOffer`, `referral`, `social`, `timedBoost`,
65
+ `userCustomData`, `title`, `gameLoop` — plus `client.data` (local cache) and
66
+ `client.on/once/off` (events).
67
+
68
+ ## Entry points
69
+
70
+ | Import | What |
71
+ | -------------------------- | ---------------------------------------------------------------------------------------------------------------- |
72
+ | `@idosgames/core` | client, services, models, result & event types |
73
+ | `@idosgames/core/platform` | platform adapters & storage (`BrowserPlatformAdapter`, `NoopPlatformAdapter`, `BrowserStorage`, `MemoryStorage`) |
74
+
75
+ ## Versioning
76
+
77
+ Semantic versioning. While on `0.x` the public API is still stabilizing, so
78
+ breaking changes may land in a **minor** bump — see
79
+ [CHANGELOG.md](./CHANGELOG.md). The backend HTTP API version (`/api/v2/…`) is
80
+ independent of this package's version.
81
+
82
+ ## License
83
+
84
+ [MIT](./LICENSE) © iDos Games
@@ -0,0 +1 @@
1
+ var n=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},o=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,t){this.map.set(e,t);}remove(e){this.map.delete(e);}};function r(){return globalThis.Telegram?.WebApp??null}function l(){return crypto.randomUUID()}var s="idos_device_id",i=class{storage;constructor(e=new n){this.storage=e;}getPlatform(){return r()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=r()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getTelegramInitDataRaw(){let e=r()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(s);return e||(e=l(),this.storage.setString(s,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let t=r();if(t?.openTelegramLink){t.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let t=r();if(t?.openInvoice){t.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let t=globalThis;typeof t.showAd=="function"&&await t.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var p="idos_device_id",g=class{storage;constructor(e=new o){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(p);return e||(e="noop-device",this.storage.setString(p,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};export{n as a,o as b,r as c,l as d,i as e,g as f};