@aippy/runtime 0.4.0 → 0.4.1-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.
package/dist/ai/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as i, d as A, e as r, c as n, U as C, a as I, b as f, h as g, g as _, l as p, n as E, p as T, r as U, f as t, s as l, v as D } from "../helper-KmxP93y0.js";
1
+ import { D as i, d as A, e as r, c as n, U as C, a as I, b as f, h as g, g as _, l as p, n as E, p as T, r as U, f as t, s as l, v as D } from "../helper-CZqFi-QF.js";
2
2
  import "react";
3
3
  import "../bridge-CtB9L5kL.js";
4
4
  export {
@@ -8,18 +8,17 @@ import { AippyUseChatOptions } from './types';
8
8
  *
9
9
  * @example
10
10
  * ```tsx
11
+ * import { useState } from 'react';
11
12
  * import { useChat } from '@ai-sdk/react';
12
13
  * import { aippyChatConfig } from '@aippy/runtime/ai';
13
14
  *
14
- * const chatConfig = await aippyChatConfig();
15
- * const { messages, input, handleSubmit } = useChat(chatConfig);
15
+ * const [input, setInput] = useState('');
16
+ * const { messages, sendMessage, status } = useChat(aippyChatConfig());
16
17
  *
17
18
  * // With custom model and system prompt
18
- * const config = await aippyChatConfig({
19
- * model: 'claude-3',
20
- * system: 'You are a helpful assistant.',
21
- * });
22
- * const { messages } = useChat(config);
19
+ * const { messages, sendMessage } = useChat(
20
+ * aippyChatConfig({ model: 'gpt-5-nano', system: 'You are a helpful assistant.' })
21
+ * );
23
22
  * ```
24
23
  */
25
24
  export declare function aippyChatConfig(config?: AippyChatConfig): AippyUseChatOptions;
@@ -1,4 +1,4 @@
1
- import { c as i, b as s, i as t, p as d, u as o, a as u } from "../useSound-jHl7rkaq.js";
1
+ import { c as i, b as s, i as t, p as d, u as o, a as u } from "../useSound-z_eIn0KH.js";
2
2
  export {
3
3
  i as createHiddenMediaElement,
4
4
  s as isIOSDevice,
@@ -14,6 +14,7 @@ export interface UseSoundOptions extends UseAudioContextOptions {
14
14
  export interface PlayOptions {
15
15
  loop?: boolean;
16
16
  volume?: number;
17
+ pitch?: number;
17
18
  }
18
19
  export interface UseSoundReturn {
19
20
  /**
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { g as a } from "./bridge-CtB9L5kL.js";
3
- const r = "0.4.0", i = {
3
+ const r = "0.4.1-dev.1", i = {
4
4
  version: r
5
5
  }, o = i.version, c = "@aippy/runtime";
6
6
  function w() {
@@ -1,7 +1,7 @@
1
1
  import { D as r, g as s, m as o } from "../config-B0A7gHQM.js";
2
2
  import { _ as t, r as i } from "../bridge-CtB9L5kL.js";
3
3
  import { A as R, a as E, E as c, b as m, c as A } from "../errors-B3bDbQbD.js";
4
- import { S as f, V as g, c as l, a as y, g as _, s as d } from "../container-message-Cv27sbjB.js";
4
+ import { S as f, V as g, c as l, a as y, g as _, s as d } from "../container-message-KgL1paGV.js";
5
5
  import { A as D, C as O, R as F, a as I, p as S } from "../runtime-CmoG3v2m.js";
6
6
  export {
7
7
  D as AippyRuntime,
@@ -1,6 +1,6 @@
1
1
  import { createOpenAICompatible as d } from "@ai-sdk/openai-compatible";
2
2
  import { r as f } from "./bridge-CtB9L5kL.js";
3
- import { s as m, a as b } from "./container-message-Cv27sbjB.js";
3
+ import { s as m, a as b } from "./container-message-KgL1paGV.js";
4
4
  import { AISDKError as c, DefaultChatTransport as h } from "ai";
5
5
  import { E as g, b as p, a as u } from "./errors-B3bDbQbD.js";
6
6
  import { j as A } from "./url-c26cuIpu.js";
@@ -1,16 +1,16 @@
1
1
  import { D as r, g as s, m as o } from "../config-B0A7gHQM.js";
2
2
  import { _ as i, g as n, r as p } from "../bridge-CtB9L5kL.js";
3
3
  import { A as m, a as f, E as c, b as u, c as C } from "../errors-B3bDbQbD.js";
4
- import { S as g, V as I, c as d, a as E, g as S, s as x } from "../container-message-Cv27sbjB.js";
4
+ import { S as g, V as I, c as d, a as E, g as S, s as x } from "../container-message-KgL1paGV.js";
5
5
  import { A as U, C as _, R as T, a as D, p as v } from "../runtime-CmoG3v2m.js";
6
6
  import { CameraAPI as F, FileSystemAPI as P, GeolocationAPI as h, SensorsAPI as M, camera as O, fileSystem as b, geolocation as L, isMotionSupported as w, isOrientationSupported as H, requestMotionPermission as N, sensors as V, vibrate as B, watchMotion as k, watchOrientation as q } from "../device/index.js";
7
7
  import { P as G, a as z, c as K, b as W, g as X, i as Y, p as J, r as Q, s as Z } from "../app-version-checker-Bz7FrEZz.js";
8
8
  import { a as ee, P as ae, p as re, b as se } from "../pwa-C5nXU0DN.js";
9
9
  import { j as te } from "../url-c26cuIpu.js";
10
- import { a as ne, b as pe } from "../useTweaks-B7Muzo78.js";
11
- import { c as me, b as fe, i as ce, p as ue, u as Ce, a as le } from "../useSound-jHl7rkaq.js";
10
+ import { a as ne, b as pe } from "../useTweaks-v5wEZGGm.js";
11
+ import { c as me, b as fe, i as ce, p as ue, u as Ce, a as le } from "../useSound-z_eIn0KH.js";
12
12
  import { reportScore as Ie, sendEvent as de, updateScore as Ee } from "../leaderboard/index.js";
13
- import { D as xe, d as Re, e as Ue, c as _e, U as Te, a as De, b as ve, h as ye, g as Fe, l as Pe, n as he, p as Me, r as Oe, f as be, s as Le, v as we } from "../helper-KmxP93y0.js";
13
+ import { D as xe, d as Re, e as Ue, c as _e, U as Te, a as De, b as ve, h as ye, g as Fe, l as Pe, n as he, p as Me, r as Oe, f as be, s as Le, v as we } from "../helper-CZqFi-QF.js";
14
14
  import { c as Ne, u as Ve } from "../hooks-D5lkty5r.js";
15
15
  import { hasNativeBridge as ke } from "../native-bridge-BnvipFJc.js";
16
16
  export {
@@ -1,4 +1,4 @@
1
- import { a as e, b as s } from "../useTweaks-B7Muzo78.js";
1
+ import { a as e, b as s } from "../useTweaks-v5wEZGGm.js";
2
2
  export {
3
3
  e as aippyTweaks,
4
4
  s as aippyTweaksRuntime
@@ -15,38 +15,17 @@ declare global {
15
15
  }
16
16
  }
17
17
  export interface TweakItem {
18
- id: string;
18
+ id?: string;
19
19
  index: number;
20
20
  name: string;
21
21
  description: string;
22
22
  group?: string;
23
- type: 'number' | 'color' | 'boolean' | 'text' | 'image';
23
+ type: string;
24
24
  value: number | string | boolean;
25
- }
26
- export interface NumberTweakItem extends TweakItem {
27
- type: 'number';
28
25
  min?: number;
29
26
  max?: number;
30
27
  step?: number;
31
- value: number;
32
- }
33
- export interface BooleanTweakItem extends TweakItem {
34
- type: 'boolean';
35
- value: boolean;
36
- }
37
- export interface TextTweakItem extends TweakItem {
38
- type: 'text';
39
- value: string;
40
- }
41
- export interface ColorTweakItem extends TweakItem {
42
- type: 'color';
43
- value: string;
44
- }
45
- export interface ImageTweakItem extends TweakItem {
46
- type: 'image';
47
- value: string;
48
28
  }
49
- export type TweakConfig = NumberTweakItem | BooleanTweakItem | TextTweakItem | ColorTweakItem | ImageTweakItem;
50
29
  export interface TweaksConfig {
51
- [key: string]: TweakConfig;
30
+ [key: string]: TweakItem;
52
31
  }
@@ -1,7 +1,7 @@
1
1
  var U = Object.defineProperty;
2
2
  var j = (e, t, s) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
3
  var h = (e, t, s) => j(e, typeof t != "symbol" ? t + "" : t, s);
4
- import { useState as C, useRef as L, useEffect as P, useCallback as T } from "react";
4
+ import { useState as O, useRef as L, useEffect as P, useCallback as T } from "react";
5
5
  function _() {
6
6
  const e = navigator.userAgent;
7
7
  return !!(/iPad|iPhone|iPod/.test(e) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
@@ -20,7 +20,7 @@ function F(e = "video", t = !1) {
20
20
  const s = document.createElement(e);
21
21
  return s.muted = !1, s.autoplay = !0, e === "video" && (s.playsInline = !0), t ? s.style.cssText = "position:fixed;bottom:10px;right:10px;width:200px;background:#ff0000;z-index:9999;" : s.style.cssText = "position:fixed;width:1px;height:1px;opacity:0;pointer-events:none;", s;
22
22
  }
23
- class N {
23
+ class R {
24
24
  constructor(t, s, a, m = !1) {
25
25
  h(this, "analyser");
26
26
  h(this, "dataArray");
@@ -98,7 +98,7 @@ class N {
98
98
  }
99
99
  }
100
100
  const E = /* @__PURE__ */ new WeakSet();
101
- function R(e, t = {}) {
101
+ function N(e, t = {}) {
102
102
  if (E.has(e))
103
103
  return e;
104
104
  const {
@@ -125,12 +125,12 @@ function R(e, t = {}) {
125
125
  let y = [];
126
126
  function S() {
127
127
  const n = () => {
128
- const O = e.state;
129
- (O === "interrupted" || O === "suspended") && (l = !1);
128
+ const x = e.state;
129
+ (x === "interrupted" || x === "suspended") && (l = !1);
130
130
  };
131
131
  e.addEventListener("statechange", n);
132
- const d = (O) => {
133
- O.persisted && (l = !1);
132
+ const d = (x) => {
133
+ x.persisted && (l = !1);
134
134
  };
135
135
  window.addEventListener("pageshow", d);
136
136
  const M = () => {
@@ -141,7 +141,7 @@ function R(e, t = {}) {
141
141
  l = !1;
142
142
  };
143
143
  window.addEventListener("pagehide", M);
144
- const x = () => {
144
+ const C = () => {
145
145
  if (document.visibilityState === "hidden") {
146
146
  try {
147
147
  e.suspend();
@@ -150,11 +150,11 @@ function R(e, t = {}) {
150
150
  l = !1;
151
151
  }
152
152
  };
153
- document.addEventListener("visibilitychange", x), y = [
153
+ document.addEventListener("visibilitychange", C), y = [
154
154
  () => e.removeEventListener("statechange", n),
155
155
  () => window.removeEventListener("pageshow", d),
156
156
  () => window.removeEventListener("pagehide", M),
157
- () => document.removeEventListener("visibilitychange", x)
157
+ () => document.removeEventListener("visibilitychange", C)
158
158
  ];
159
159
  }
160
160
  function D() {
@@ -202,7 +202,7 @@ function R(e, t = {}) {
202
202
  const r = F(g, m);
203
203
  r.srcObject = I.stream, document.body.appendChild(r);
204
204
  let i = null;
205
- u.enabled && (i = new N(
205
+ u.enabled && (i = new R(
206
206
  e,
207
207
  r,
208
208
  u,
@@ -242,9 +242,9 @@ function R(e, t = {}) {
242
242
  return o(k), S(), E.add(e), k;
243
243
  }
244
244
  function q(e = {}) {
245
- const { autoUnlock: t = !0, ...s } = e, [a, m] = C(null), [g, f] = C(!1), u = L(null);
245
+ const { autoUnlock: t = !0, ...s } = e, [a, m] = O(null), [g, f] = O(!1), u = L(null);
246
246
  P(() => {
247
- const o = new AudioContext(), c = R(o, s);
247
+ const o = new AudioContext(), c = N(o, s);
248
248
  return u.current = c, m(c), () => {
249
249
  u.current = null, c.cleanup(), c.close();
250
250
  };
@@ -339,7 +339,7 @@ function H(e, t = {}) {
339
339
  }
340
340
  A(r);
341
341
  const n = p.createBufferSource();
342
- n.buffer = k, n.loop = i?.loop ?? !1;
342
+ n.buffer = k, n.loop = i?.loop ?? !1, n.playbackRate.value = i?.pitch ?? 1;
343
343
  const d = p.createGain();
344
344
  return d.gain.value = (i?.volume ?? 1) * S.current, n.connect(d), d.connect(p.destination), n.start(), c.current.set(r, { source: n, gain: d }), n.onended = () => {
345
345
  c.current.get(r)?.source === n && c.current.delete(r);
@@ -375,6 +375,6 @@ export {
375
375
  _ as b,
376
376
  F as c,
377
377
  B as i,
378
- R as p,
378
+ N as p,
379
379
  q as u
380
380
  };
@@ -1,9 +1,33 @@
1
- var b = Object.defineProperty;
2
- var g = (n, e, t) => e in n ? b(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var r = (n, e, t) => g(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { useReducer as v, useEffect as m } from "react";
1
+ var g = Object.defineProperty;
2
+ var m = (i, e, t) => e in i ? g(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var r = (i, e, t) => m(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { useReducer as h, useEffect as v } from "react";
5
5
  import { b as T, a as C } from "./errors-B3bDbQbD.js";
6
- class I {
6
+ const I = /* @__PURE__ */ new Set(["number", "color", "boolean", "text", "image"]), O = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, R = /\.(?:png|jpe?g|gif|webp|svg|avif|ico|bmp)(?:[?#]|$)/i;
7
+ function A(i) {
8
+ const e = i.value;
9
+ if (typeof e == "boolean") return "boolean";
10
+ if (typeof e == "number") return "number";
11
+ if (typeof e == "string") {
12
+ if (O.test(e)) return "color";
13
+ if (R.test(e)) return "image";
14
+ }
15
+ return "text";
16
+ }
17
+ function E(i) {
18
+ const e = {};
19
+ for (const [t, n] of Object.entries(i))
20
+ if (I.has(n.type))
21
+ e[t] = n;
22
+ else {
23
+ const a = A(n);
24
+ console.warn(
25
+ `⚠️ [Aippy Tweaks] Invalid type "${n.type}" for key "${t}", auto-corrected to "${a}"`
26
+ ), e[t] = { ...n, type: a };
27
+ }
28
+ return e;
29
+ }
30
+ class j {
7
31
  constructor(e) {
8
32
  r(this, "cancelled", !1);
9
33
  this.cancelFn = e;
@@ -23,23 +47,23 @@ class k {
23
47
  this.listeners.forEach((t) => t(e));
24
48
  }
25
49
  subscribe(e) {
26
- return this.listeners.push(e), new I(() => {
50
+ return this.listeners.push(e), new j(() => {
27
51
  const t = this.listeners.indexOf(e);
28
52
  t > -1 && this.listeners.splice(t, 1);
29
53
  });
30
54
  }
31
55
  }
32
- class O {
56
+ class S {
33
57
  constructor(e, t) {
34
58
  r(this, "values", {});
35
59
  r(this, "subject", new k());
36
60
  r(this, "observable");
37
61
  this.observable = e;
38
- for (const [i, a] of Object.entries(t))
39
- this.values[i] = a.value;
40
- this.observable.subscribe((i) => {
41
- if (i && i.values)
42
- for (const [a, s] of Object.entries(i.values)) {
62
+ for (const [n, a] of Object.entries(t))
63
+ this.values[n] = a.value;
64
+ this.observable.subscribe((n) => {
65
+ if (n && n.values)
66
+ for (const [a, s] of Object.entries(n.values)) {
43
67
  let o = s;
44
68
  if (this.values[a] !== void 0) {
45
69
  const c = typeof this.values[a];
@@ -57,10 +81,10 @@ class O {
57
81
  }
58
82
  // React Hook integration
59
83
  useState(e) {
60
- const [t, i] = v(() => this.getValue(e), this.getValue(e));
61
- return m(() => {
84
+ const [t, n] = h(() => this.getValue(e), this.getValue(e));
85
+ return v(() => {
62
86
  const a = this.subject.subscribe((s) => {
63
- s === e && i();
87
+ s === e && n();
64
88
  });
65
89
  return () => {
66
90
  a.cancel();
@@ -68,7 +92,7 @@ class O {
68
92
  }, [e]), t;
69
93
  }
70
94
  }
71
- class R {
95
+ class N {
72
96
  constructor() {
73
97
  r(this, "tweaksInstance", null);
74
98
  r(this, "tweaksDidWarn", !1);
@@ -80,11 +104,11 @@ class R {
80
104
  tweaks(e) {
81
105
  if (this.tweaksInstance)
82
106
  return this.tweaksDidWarn || (this.tweaksDidWarn = !0, console.warn("⚠️ [Aippy Tweaks] tweaks() is expected to only be called once, returning previous value")), this.tweaksInstance;
83
- this.originalConfig = { ...e };
84
- const t = new k(), i = new O(t, e), a = {};
107
+ e = E(e), this.originalConfig = { ...e };
108
+ const t = new k(), n = new S(t, e), a = {};
85
109
  for (const s of Object.keys(e))
86
110
  a[s] = {
87
- useState: () => i.useState(s)
111
+ useState: () => n.useState(s)
88
112
  };
89
113
  return this.tweaksInstance = a, typeof window < "u" && window.aippyTweaksRuntime && (window.aippyTweaksRuntime.tweaksInstance = a), this.initializeExternalCommunication(e, (s) => {
90
114
  t.send(s);
@@ -92,14 +116,14 @@ class R {
92
116
  }
93
117
  initializeExternalCommunication(e, t) {
94
118
  this.updateCallback = t;
95
- const i = window.webkit?.messageHandlers?.aippyListener;
96
- if (i)
119
+ const n = window.webkit?.messageHandlers?.aippyListener;
120
+ if (n)
97
121
  try {
98
122
  const s = {
99
123
  command: "tweaks.initialize",
100
124
  parameters: JSON.stringify(e)
101
125
  };
102
- i.postMessage(s);
126
+ n.postMessage(s);
103
127
  } catch (s) {
104
128
  console.warn("❌ [Aippy Tweaks] Failed to send tweaks config to iOS app:", s);
105
129
  }
@@ -145,19 +169,19 @@ class R {
145
169
  console.warn("⚠️ [Aippy Tweaks] No original config available for merging");
146
170
  return;
147
171
  }
148
- const t = {}, i = {};
172
+ const t = {}, n = {};
149
173
  let a = 0;
150
174
  for (const [o, c] of Object.entries(e))
151
175
  if (c && typeof c == "object" && "value" in c) {
152
- const p = c, u = this.originalConfig[o];
153
- if (!u) {
176
+ const u = c, w = this.originalConfig[o];
177
+ if (!w) {
154
178
  console.warn(`⚠️ [Aippy Tweaks] Key "${o}" not found in original config, skipping`);
155
179
  continue;
156
180
  }
157
- const h = /* @__PURE__ */ new Set(["tweakKey", "valueBefore", "tweaksType", "editType"]), d = { ...u };
158
- for (const [f, l] of Object.entries(p))
159
- h.has(f) || l != null && (d[f] = l);
160
- i[o] = d, t[o] = p.value, a++;
181
+ const b = /* @__PURE__ */ new Set(["tweakKey", "valueBefore", "tweaksType", "editType"]), f = { ...w };
182
+ for (const [d, l] of Object.entries(u))
183
+ b.has(d) || l != null && (f[d] = l);
184
+ n[o] = f, t[o] = u.value, a++;
161
185
  }
162
186
  if (a === 0) {
163
187
  console.warn("⚠️ [Aippy Tweaks] No valid values found in iOS data:", e);
@@ -173,11 +197,11 @@ class R {
173
197
  }
174
198
  }
175
199
  }
176
- const w = new R(), y = {
177
- tweaks: (n) => w.tweaks(n)
178
- }, S = y.tweaks;
179
- typeof window < "u" && (window.aippyTweaksRuntime = y, window.processNativeData = w.processNativeData.bind(w));
200
+ const p = new N(), y = {
201
+ tweaks: (i) => p.tweaks(i)
202
+ }, F = y.tweaks;
203
+ typeof window < "u" && (window.aippyTweaksRuntime = y, window.processNativeData = p.processNativeData.bind(p));
180
204
  export {
181
- S as a,
205
+ F as a,
182
206
  y as b
183
207
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aippy/runtime",
3
- "version": "0.4.0",
3
+ "version": "0.4.1-dev.1",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",