@aippy/runtime 0.2.2 → 0.2.3-dev.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.
@@ -1,4 +1,4 @@
1
- import { A as d, E as v, c as _ } from "../errors-CDEBaBxB.js";
1
+ import { A as f, E as v, c as _ } from "../errors-CDEBaBxB.js";
2
2
  const o = {
3
3
  mode: "development",
4
4
  debug: !1,
@@ -22,7 +22,7 @@ function a(e) {
22
22
  }
23
23
  };
24
24
  }
25
- const s = "0.2.2", t = {
25
+ const s = "0.2.3-dev.1", t = {
26
26
  version: s
27
27
  }, i = t.version, c = "@aippy/runtime";
28
28
  function p() {
@@ -33,7 +33,7 @@ function p() {
33
33
  };
34
34
  }
35
35
  export {
36
- d as AippyRuntimeError,
36
+ f as AippyRuntimeError,
37
37
  o as DEFAULT_CONFIG,
38
38
  v as ERROR_CODES,
39
39
  c as SDK_NAME,
@@ -1,23 +1,24 @@
1
- import { DEFAULT_CONFIG as o, SDK_NAME as r, VERSION as t, getConfigFromEnv as s, getVersionInfo as i, mergeConfig as m } from "../core/index.js";
2
- import { A as p, E as c, c as f } from "../errors-CDEBaBxB.js";
3
- import { CameraAPI as A, FileSystemAPI as E, GeolocationAPI as l, SensorsAPI as S, camera as u, fileSystem as x, geolocation as I, sensors as P, vibrate as C } from "../device/index.js";
1
+ import { DEFAULT_CONFIG as r, SDK_NAME as a, VERSION as t, getConfigFromEnv as s, getVersionInfo as i, mergeConfig as n } from "../core/index.js";
2
+ import { A as m, E as c, c as f } from "../errors-CDEBaBxB.js";
3
+ import { CameraAPI as A, FileSystemAPI as E, GeolocationAPI as S, SensorsAPI as l, camera as u, fileSystem as x, geolocation as I, sensors as P, vibrate as C } from "../device/index.js";
4
4
  import { c as R, a as y, P as D, b as M, p as O, d as b } from "../pwa-8DGmPqLV.js";
5
- import { a as v, b as w } from "../useTweaks-QxMRmg7i.js";
5
+ import { a as F, b as w } from "../useTweaks-QxMRmg7i.js";
6
6
  import { c as T, a as V, i as _, b as k, p as G, u as H } from "../useAudioContext-BKgy28A1.js";
7
+ import { reportScore as h, sendEvent as K, updateScore as L } from "../leaderboard/index.js";
7
8
  export {
8
- p as AippyRuntimeError,
9
+ m as AippyRuntimeError,
9
10
  A as CameraAPI,
10
- o as DEFAULT_CONFIG,
11
+ r as DEFAULT_CONFIG,
11
12
  c as ERROR_CODES,
12
13
  E as FileSystemAPI,
13
- l as GeolocationAPI,
14
+ S as GeolocationAPI,
14
15
  R as PWAUtils,
15
16
  y as PerformanceMonitor,
16
17
  D as PlatformDetector,
17
- r as SDK_NAME,
18
- S as SensorsAPI,
18
+ a as SDK_NAME,
19
+ l as SensorsAPI,
19
20
  t as VERSION,
20
- v as aippyTweaks,
21
+ F as aippyTweaks,
21
22
  w as aippyTweaksRuntime,
22
23
  u as camera,
23
24
  f as createError,
@@ -29,12 +30,15 @@ export {
29
30
  i as getVersionInfo,
30
31
  _ as isIOSDevice,
31
32
  k as isMediaStreamAudioSupported,
32
- m as mergeConfig,
33
+ n as mergeConfig,
33
34
  G as patchAudioContext,
34
35
  M as performanceMonitor,
35
36
  O as platform,
36
37
  b as pwa,
38
+ h as reportScore,
39
+ K as sendEvent,
37
40
  P as sensors,
41
+ L as updateScore,
38
42
  H as useAudioContext,
39
43
  C as vibrate
40
44
  };
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './device';
3
3
  export * from './utils';
4
4
  export * from './tweaks';
5
5
  export * from './audio';
6
+ export * from './leaderboard';
@@ -0,0 +1,2 @@
1
+ export * from './report';
2
+ export * from './types';
@@ -0,0 +1,42 @@
1
+ function r(e, o) {
2
+ try {
3
+ if (window.parent && window.parent !== window) {
4
+ const n = {
5
+ __aippyGame: !0,
6
+ payload: e
7
+ };
8
+ window.parent.postMessage(n, "*");
9
+ }
10
+ const a = window.webkit?.messageHandlers?.aippyListener;
11
+ a && a.postMessage({
12
+ command: o,
13
+ parameters: JSON.stringify(e)
14
+ });
15
+ } catch (a) {
16
+ console.warn("[Aippy Leaderboard] Failed to send game event:", a);
17
+ }
18
+ }
19
+ function t(e) {
20
+ r({
21
+ type: "score",
22
+ score: e
23
+ }, "leaderboard.reportScore"), console.log(`[Aippy Leaderboard] Score reported: ${e}`);
24
+ }
25
+ function p(e) {
26
+ r({
27
+ type: "score",
28
+ score: e
29
+ }, "leaderboard.updateScore"), console.log(`[Aippy Leaderboard] Score updated: ${e}`);
30
+ }
31
+ function d(e, o) {
32
+ const a = {
33
+ type: e,
34
+ ...o
35
+ };
36
+ r(a, "leaderboard.event"), console.log(`[Aippy Leaderboard] Event sent: ${e}`, o);
37
+ }
38
+ export {
39
+ t as reportScore,
40
+ d as sendEvent,
41
+ p as updateScore
42
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Leaderboard reporting functionality for score submission and game events
3
+ */
4
+ /**
5
+ * Report final game score to parent window or iOS app (used when game ends)
6
+ * @param score - The score value to report
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * reportScore(100);
11
+ * reportScore(1500);
12
+ * ```
13
+ */
14
+ export declare function reportScore(score: number): void;
15
+ /**
16
+ * Update current game score to parent window or iOS app (used during gameplay)
17
+ * @param score - The current score value to update
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * updateScore(50);
22
+ * updateScore(currentScore);
23
+ * ```
24
+ */
25
+ export declare function updateScore(score: number): void;
26
+ /**
27
+ * Send a custom game event
28
+ * @param eventType - The event type
29
+ * @param data - Additional event data
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * sendEvent('level-complete', { level: 5, time: 120 });
34
+ * ```
35
+ */
36
+ export declare function sendEvent(eventType: string, data?: Record<string, unknown>): void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Leaderboard SDK type definitions
3
+ */
4
+ /**
5
+ * Score report payload
6
+ */
7
+ export interface ScorePayload {
8
+ /** Message type, fixed as 'score' */
9
+ type: 'score';
10
+ /** The score value */
11
+ score: number;
12
+ /** Score unit (e.g., 'points', 'coins') */
13
+ unit?: string;
14
+ /** Whether bigger score is better for leaderboard ranking */
15
+ 'bigger-is-better'?: boolean;
16
+ }
17
+ /**
18
+ * Generic game event payload
19
+ */
20
+ export interface GameEventPayload {
21
+ /** Event type */
22
+ type: string;
23
+ /** Additional event data */
24
+ [key: string]: unknown;
25
+ }
26
+ /**
27
+ * Message format for postMessage communication
28
+ */
29
+ export interface AippyGameMessage {
30
+ /** Message identifier */
31
+ __aippyGame: true;
32
+ /** Event payload */
33
+ payload: ScorePayload | GameEventPayload;
34
+ }
@@ -0,0 +1,2 @@
1
+ export * from './leaderboard/index'
2
+ export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aippy/runtime",
3
- "version": "0.2.2",
3
+ "version": "0.2.3-dev.1",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",
@@ -31,6 +31,10 @@
31
31
  "./audio": {
32
32
  "import": "./dist/audio/index.js",
33
33
  "types": "./dist/audio/index.d.ts"
34
+ },
35
+ "./leaderboard": {
36
+ "import": "./dist/leaderboard/index.js",
37
+ "types": "./dist/leaderboard/index.d.ts"
34
38
  }
35
39
  },
36
40
  "files": [
@@ -88,13 +92,13 @@
88
92
  "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
89
93
  "format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
90
94
  "clean": "rm -rf dist",
91
- "publish:patch": "pnpm version patch && pnpm publish --no-git-checks",
92
- "publish:minor": "pnpm version minor && pnpm publish --no-git-checks",
93
- "publish:major": "pnpm version major && pnpm publish --no-git-checks",
94
- "publish:alpha": "pnpm version prerelease --preid=alpha && pnpm publish --tag alpha --no-git-checks",
95
- "publish:beta": "pnpm version prerelease --preid=beta && pnpm publish --tag beta --no-git-checks",
96
- "publish:rc": "pnpm version prerelease --preid=rc && pnpm publish --tag rc --no-git-checks",
97
- "publish:dev": "pnpm version prerelease --preid=dev && pnpm publish --tag dev --no-git-checks",
95
+ "publish:patch": "pnpm prepublishOnly && pnpm version patch && pnpm publish --no-git-checks",
96
+ "publish:minor": "pnpm prepublishOnly && pnpm version minor && pnpm publish --no-git-checks",
97
+ "publish:major": "pnpm prepublishOnly && pnpm version major && pnpm publish --no-git-checks",
98
+ "publish:alpha": "pnpm prepublishOnly && pnpm version prerelease --preid=alpha && pnpm publish --tag alpha --no-git-checks",
99
+ "publish:beta": "pnpm prepublishOnly && pnpm version prerelease --preid=beta && pnpm publish --tag beta --no-git-checks",
100
+ "publish:rc": "pnpm prepublishOnly && pnpm version prerelease --preid=rc && pnpm publish --tag rc --no-git-checks",
101
+ "publish:dev": "pnpm prepublishOnly && pnpm version prerelease --preid=dev && pnpm publish --tag dev --no-git-checks",
98
102
  "audit": "pnpm audit --audit-level moderate",
99
103
  "audit:fix": "pnpm audit --fix",
100
104
  "security:check": "pnpm audit && pnpm outdated",