@aippy/runtime 0.4.0 → 0.4.1-dev.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/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-Cw67btub.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,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.0", 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-DZYnuAQg.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-DZYnuAQg.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-DZYnuAQg.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";
10
+ import { a as ne, b as pe } from "../useTweaks-v5wEZGGm.js";
11
11
  import { c as me, b as fe, i as ce, p as ue, u as Ce, a as le } from "../useSound-jHl7rkaq.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-Cw67btub.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,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.0",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",