types, errors and size
Exported types
Section titled “Exported types”Every type is exported from the package root. The IIFE has the same shapes at runtime without the names.
| Type | Page |
|---|---|
FiludiSdk | The shape of sdk and of window.FiludiSDK |
InitOptions, InitResult, MockConfig, HostName, Features, Policy, AgeBand | init |
AdResult, AdsAvailability | ads |
SaveRead<T>, SaveWrite | save |
Period, LeaderboardEntry, SubmitResult, TopResult, MeResult | leaderboard |
Player | player |
TrackProps | track |
HostEvents, Consent, Device, Off | host events, fullscreen and device |
HostExtras, CrazygamesExtras, PokiExtras, PlaygamaExtras | host extras |
FiludiInit, Adapter, AdapterContext, AdapterEvent, AdapterInit, AdKind, ParentMessage, RemoteSaveWrite, ScoreSubmission, Session, SignedScore, TrackEvent | The handshake and the adapter contract, for a hub or a host implementation, not for a game |
import { sdk, version } from '@filudi/game-sdk';
console.log(`Filudi SDK ${version}`);// Without a bundler: window.FiludiSDK.versionimport { sdk, version, type FiludiSdk, type SaveRead } from '@filudi/game-sdk';
interface MySave { level: number }
class Platform { constructor(private readonly api: FiludiSdk = sdk) {} load(): Promise<SaveRead<MySave>> { return this.api.save.get<MySave>(); }}console.log(`Filudi SDK ${version}`);Errors and logging
Section titled “Errors and logging”Nothing throws after init(). Failures are statuses on the result: unavailable, rejected, conflict,
too-large, error. The programming errors that throw: a method called before init() was called at all,
and player.get(), ads.available(), i18n.locale() or device() called before init() resolved.
init({ debug: true }) or ?filudi_debug=1 on the page URL logs every call and every host message to the
console with the prefix [filudi-sdk]. Leave it off in a release.
await sdk.init({ gameId: 'gloop', debug: location.hostname === 'localhost' });await sdk.init({ gameId: 'gloop', debug: import.meta.env.DEV });Browsers and size
Section titled “Browsers and size”Last two versions of Chrome, Firefox, Safari and Edge; iOS 16 and later. Signed scores need
crypto.subtle; without it submit returns rejected with reason signature and everything else works.
No eval, no document.write, no inline script: the SDK runs under the script-src 'self' policy of the
bundle route.
Two builds, 12 kB gzipped each on every host path:
- ESM,
dist/index.js: the core, the filudi adapter and the standalone adapter in the entry; the portal adapters and the rich mock as chunks loaded withimport()when that host is detected. - IIFE,
dist/filudi-sdk.iife.js: one file with the core, filudi, standalone and the three portal adapters, aswindow.FiludiSDKplusFiludiSDK.version. No rich mock: hostmockbehaves as standalone.
Each release lists its changes in the package’s changelog on npmjs.com. Pin the exact version and read the changelog before moving.