@aippy/runtime 0.2.4-dev.7 โ†’ 0.2.4-dev.8

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, A as f, C as u, E as A, R as _, b as m, c as R, p as g } from "../runtime-BdIpqmWa.js";
1
+ import { a as d, A as f, C as u, E as A, R as _, b as m, c as R, p as g } from "../runtime-DjBdOttl.js";
2
2
  const s = {
3
3
  mode: "development",
4
4
  debug: !1,
@@ -22,7 +22,7 @@ function c(e) {
22
22
  }
23
23
  };
24
24
  }
25
- const r = "0.2.4-dev.7", a = {
25
+ const r = "0.2.4-dev.8", a = {
26
26
  version: r
27
27
  }, i = a.version, t = "@aippy/runtime";
28
28
  function p() {
@@ -39,6 +39,7 @@ export declare class AippyRuntime {
39
39
  receiveChannel: ReceiveChannel;
40
40
  private seq;
41
41
  private motionListeners;
42
+ private noListenersWarned;
42
43
  /**
43
44
  * Unified native data receiver - Routes to specific handlers based on message type
44
45
  * Called by native code via: window.aippyRuntime.receiveMessage(message)
@@ -1,7 +1,7 @@
1
1
  var v = Object.defineProperty;
2
- var f = (a, t, e) => t in a ? v(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var w = (a, t, e) => f(a, typeof t != "symbol" ? t + "" : t, e);
4
- import { c as s, b as E } from "../runtime-BdIpqmWa.js";
2
+ var E = (a, t, e) => t in a ? v(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var w = (a, t, e) => E(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import { c as s, b as f } from "../runtime-DjBdOttl.js";
5
5
  class P {
6
6
  constructor() {
7
7
  w(this, "stream", null);
@@ -72,7 +72,7 @@ class P {
72
72
  this.stream && (this.stream.getTracks().forEach((t) => t.stop()), this.stream = null);
73
73
  }
74
74
  }
75
- const M = new P();
75
+ const D = new P();
76
76
  class O {
77
77
  /**
78
78
  * Check if geolocation is supported
@@ -198,8 +198,7 @@ async function y() {
198
198
  }
199
199
  function S(a) {
200
200
  console.log("๐Ÿ”ง [Aippy Sensors] watchMotionNative - Setting up native bridge listener");
201
- const t = E.addMotionListener((e) => {
202
- console.log("๐Ÿ“ฆ [Aippy Sensors] watchMotionNative - Received native data:", e);
201
+ const t = f.addMotionListener((e) => {
203
202
  const i = {
204
203
  gravity: {
205
204
  x: e.gravity?.x ?? 0,
@@ -223,7 +222,7 @@ function S(a) {
223
222
  },
224
223
  timestamp: Date.now()
225
224
  };
226
- console.log("โœจ [Aippy Sensors] watchMotionNative - Transformed data:", i), a(i);
225
+ a(i);
227
226
  });
228
227
  return console.log("โœ… [Aippy Sensors] watchMotionNative - Listener setup complete"), t;
229
228
  }
@@ -289,7 +288,7 @@ function N(a, t = !0) {
289
288
  e = !1, window.removeEventListener("devicemotion", o), i && (i(), i = null);
290
289
  };
291
290
  }
292
- function D(a, t = !0) {
291
+ function M(a, t = !0) {
293
292
  const e = h();
294
293
  return console.log(`๐ŸŽฏ [Aippy Sensors] watchMotion - Using ${e ? "NATIVE BRIDGE" : "WEB API"} mode`), e ? (console.log("๐Ÿ“ฑ [Aippy Sensors] Starting native bridge motion listener"), S(a)) : (console.log("๐ŸŒ [Aippy Sensors] Starting Web API motion listener (may require permission)"), N(a, t));
295
294
  }
@@ -508,8 +507,8 @@ class R {
508
507
  });
509
508
  }
510
509
  }
511
- const T = new R();
512
- function k(a) {
510
+ const k = new R();
511
+ function T(a) {
513
512
  return new Promise((t) => {
514
513
  if ("vibrate" in navigator)
515
514
  navigator.vibrate(a), t();
@@ -528,15 +527,15 @@ export {
528
527
  R as FileSystemAPI,
529
528
  O as GeolocationAPI,
530
529
  A as SensorsAPI,
531
- M as camera,
532
- T as fileSystem,
530
+ D as camera,
531
+ k as fileSystem,
533
532
  U as geolocation,
534
533
  h as hasNativeBridge,
535
534
  m as isMotionSupported,
536
535
  g as isOrientationSupported,
537
536
  y as requestMotionPermission,
538
537
  x as sensors,
539
- k as vibrate,
540
- D as watchMotion,
538
+ T as vibrate,
539
+ M as watchMotion,
541
540
  L as watchOrientation
542
541
  };
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_CONFIG as o, SDK_NAME as t, VERSION as r, getConfigFromEnv as i, getVersionInfo as s, mergeConfig as n } from "../core/index.js";
2
- import { a as m, A as c, C as d, E as f, R as u, b as l, c as A, p as S } from "../runtime-BdIpqmWa.js";
2
+ import { a as m, A as c, C as d, E as f, R as u, b as l, c as A, p as S } from "../runtime-DjBdOttl.js";
3
3
  import { CameraAPI as C, FileSystemAPI as R, GeolocationAPI as x, SensorsAPI as M, camera as P, fileSystem as I, geolocation as g, hasNativeBridge as y, isMotionSupported as O, isOrientationSupported as b, requestMotionPermission as v, sensors as D, vibrate as h, watchMotion as w, watchOrientation as F } from "../device/index.js";
4
4
  import { c as T, a as V, P as _, b as k, p as G, d as H } from "../pwa-8DGmPqLV.js";
5
5
  import { a as q, b as B } from "../useTweaks-QxMRmg7i.js";
@@ -1,12 +1,12 @@
1
1
  var u = Object.defineProperty;
2
- var m = (o, e, t) => e in o ? u(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var c = (o, e, t) => m(o, typeof e != "symbol" ? e + "" : e, t);
2
+ var m = (o, e, n) => e in o ? u(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
+ var r = (o, e, n) => m(o, typeof e != "symbol" ? e + "" : e, n);
4
4
  class d extends Error {
5
- constructor(t, i = "AIPPY_ERROR", n) {
6
- super(t);
7
- c(this, "code");
8
- c(this, "context");
9
- this.name = "AippyRuntimeError", this.code = i, this.context = n;
5
+ constructor(n, i = "AIPPY_ERROR", t) {
6
+ super(n);
7
+ r(this, "code");
8
+ r(this, "context");
9
+ this.name = "AippyRuntimeError", this.code = i, this.context = t;
10
10
  }
11
11
  }
12
12
  const R = {
@@ -16,12 +16,12 @@ const R = {
16
16
  NETWORK_ERROR: "NETWORK_ERROR",
17
17
  UNKNOWN_ERROR: "UNKNOWN_ERROR"
18
18
  };
19
- function w(o, e = "UNKNOWN_ERROR", t) {
20
- return new d(o, R[e], t);
19
+ function g(o, e = "UNKNOWN_ERROR", n) {
20
+ return new d(o, R[e], n);
21
21
  }
22
22
  class a {
23
23
  constructor(e) {
24
- c(this, "cancelled", !1);
24
+ r(this, "cancelled", !1);
25
25
  this.cancelFn = e;
26
26
  }
27
27
  cancel() {
@@ -31,28 +31,28 @@ class a {
31
31
  return this.cancelled;
32
32
  }
33
33
  }
34
- class y {
34
+ class f {
35
35
  constructor() {
36
- c(this, "listeners", /* @__PURE__ */ new Map());
36
+ r(this, "listeners", /* @__PURE__ */ new Map());
37
37
  }
38
- addEventListener(e, t) {
39
- this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t);
38
+ addEventListener(e, n) {
39
+ this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(n);
40
40
  }
41
- removeEventListener(e, t) {
41
+ removeEventListener(e, n) {
42
42
  const i = this.listeners.get(e);
43
43
  if (i) {
44
- const n = i.indexOf(t);
45
- n > -1 && i.splice(n, 1);
44
+ const t = i.indexOf(n);
45
+ t > -1 && i.splice(t, 1);
46
46
  }
47
47
  }
48
- emit(e, t) {
48
+ emit(e, n) {
49
49
  const i = this.listeners.get(e);
50
- i && i.forEach((n) => n(t));
50
+ i && i.forEach((t) => t(n));
51
51
  }
52
52
  }
53
- class f {
53
+ class y {
54
54
  constructor() {
55
- c(this, "emitter", new y());
55
+ r(this, "emitter", new f());
56
56
  }
57
57
  /**
58
58
  * Emit a message to subscribers
@@ -63,9 +63,9 @@ class f {
63
63
  /**
64
64
  * Subscribe to messages on a specific endpoint
65
65
  */
66
- subscribe(e, t) {
67
- const i = (n) => {
68
- t(n);
66
+ subscribe(e, n) {
67
+ const i = (t) => {
68
+ n(t);
69
69
  };
70
70
  return this.emitter.addEventListener(e, i), new a(() => {
71
71
  this.emitter.removeEventListener(e, i);
@@ -74,18 +74,19 @@ class f {
74
74
  /**
75
75
  * Subscribe to a single message (auto-unsubscribe after first message)
76
76
  */
77
- once(e, t) {
78
- const i = this.subscribe(e, (n) => {
79
- i.cancel(), t(n);
77
+ once(e, n) {
78
+ const i = this.subscribe(e, (t) => {
79
+ i.cancel(), n(t);
80
80
  });
81
81
  return i;
82
82
  }
83
83
  }
84
84
  class h {
85
85
  constructor() {
86
- c(this, "receiveChannel", new f());
87
- c(this, "seq", 0);
88
- c(this, "motionListeners", []);
86
+ r(this, "receiveChannel", new y());
87
+ r(this, "seq", 0);
88
+ r(this, "motionListeners", []);
89
+ r(this, "noListenersWarned", !1);
89
90
  }
90
91
  /**
91
92
  * Unified native data receiver - Routes to specific handlers based on message type
@@ -115,10 +116,10 @@ class h {
115
116
  isTweaksMessage(e) {
116
117
  if (typeof e != "object" || e === null || "endpoint" in e || "payload" in e)
117
118
  return !1;
118
- const t = Object.keys(e);
119
- return t.length === 0 ? !1 : t.some((n) => {
120
- const r = e[n];
121
- return typeof r == "object" && r !== null && "value" in r;
119
+ const n = Object.keys(e);
120
+ return n.length === 0 ? !1 : n.some((t) => {
121
+ const c = e[t];
122
+ return typeof c == "object" && c !== null && "value" in c;
122
123
  });
123
124
  }
124
125
  /**
@@ -128,37 +129,37 @@ class h {
128
129
  * @param callback - Callback to handle received data
129
130
  * @returns Cancellable subscription
130
131
  */
131
- createSubscription(e, t, i) {
132
- const n = (this.seq++).toString(), r = {
133
- command: t.command,
132
+ createSubscription(e, n, i) {
133
+ const t = (this.seq++).toString(), c = {
134
+ command: n.command,
134
135
  parameters: {
135
- type: t.type,
136
+ type: n.type,
136
137
  action: "subscribe",
137
- endpoint: n
138
+ endpoint: t
138
139
  }
139
140
  };
140
- console.log("๐Ÿ“จ [Aippy Runtime] Creating subscription with message:", JSON.stringify(r, null, 2));
141
- const p = this.receiveChannel.subscribe(n, (s) => {
142
- if (console.log(`๐Ÿ“ฌ [Aippy Runtime] Received data on endpoint ${n}:`, s), s.error !== void 0) {
141
+ console.log("๐Ÿ“จ [Aippy Runtime] Creating subscription with message:", JSON.stringify(c, null, 2));
142
+ const l = this.receiveChannel.subscribe(t, (s) => {
143
+ if (console.log(`๐Ÿ“ฌ [Aippy Runtime] Received data on endpoint ${t}:`, s), s.error !== void 0) {
143
144
  console.warn("โš ๏ธ [Aippy Runtime] Received error, skipping:", s.error);
144
145
  return;
145
146
  }
146
147
  i(s);
147
148
  });
148
149
  try {
149
- console.log("๐Ÿ“ค [Aippy Runtime] Sending postMessage to native iOS:", r), e.postMessage(r), console.log("โœ… [Aippy Runtime] postMessage sent successfully");
150
+ console.log("๐Ÿ“ค [Aippy Runtime] Sending postMessage to native iOS:", c), e.postMessage(c), console.log("โœ… [Aippy Runtime] postMessage sent successfully");
150
151
  } catch (s) {
151
152
  console.error("โŒ [Aippy Runtime] Failed to send postMessage:", s);
152
153
  }
153
154
  return new a(() => {
154
- console.log(`๐Ÿ”Œ [Aippy Runtime] Unsubscribing from endpoint ${n}`), p.cancel();
155
+ console.log(`๐Ÿ”Œ [Aippy Runtime] Unsubscribing from endpoint ${t}`), l.cancel();
155
156
  try {
156
157
  const s = {
157
- command: t.command,
158
+ command: n.command,
158
159
  parameters: {
159
- type: t.type,
160
+ type: n.type,
160
161
  action: "unsubscribe",
161
- endpoint: n
162
+ endpoint: t
162
163
  }
163
164
  };
164
165
  e.postMessage(s), console.log("โœ… [Aippy Runtime] Unsubscribe message sent:", s);
@@ -174,27 +175,27 @@ class h {
174
175
  */
175
176
  addMotionListener(e) {
176
177
  console.log("๐ŸŽฌ [Aippy Runtime] addMotionListener called"), this.motionListeners.push(e), console.log(`๐Ÿ“ [Aippy Runtime] Total motion listeners: ${this.motionListeners.length}`);
177
- const t = window.webkit?.messageHandlers?.aippyListener;
178
- if (!t)
178
+ const n = window.webkit?.messageHandlers?.aippyListener;
179
+ if (!n)
179
180
  return console.warn("โš ๏ธ [Aippy Runtime] No webkit message handler found, using fallback mode"), () => {
180
- const n = this.motionListeners.indexOf(e);
181
- n > -1 && this.motionListeners.splice(n, 1);
181
+ const t = this.motionListeners.indexOf(e);
182
+ t > -1 && this.motionListeners.splice(t, 1);
182
183
  };
183
184
  console.log("โœ… [Aippy Runtime] Webkit handler found, creating subscription");
184
185
  const i = this.createSubscription(
185
- t,
186
+ n,
186
187
  {
187
188
  command: "navigator.motion",
188
189
  type: "motion"
189
190
  },
190
- (n) => {
191
- console.log("๐Ÿ“ฅ [Aippy Runtime] Received motion data from native:", n), n.motion && e(n.motion);
191
+ (t) => {
192
+ console.log("๐Ÿ“ฅ [Aippy Runtime] Received motion data from native:", t), t.motion && e(t.motion);
192
193
  }
193
194
  );
194
195
  return () => {
195
196
  console.log("๐Ÿงน [Aippy Runtime] Cleaning up motion listener"), i.cancel();
196
- const n = this.motionListeners.indexOf(e);
197
- n > -1 && this.motionListeners.splice(n, 1);
197
+ const t = this.motionListeners.indexOf(e);
198
+ t > -1 && this.motionListeners.splice(t, 1);
198
199
  };
199
200
  }
200
201
  /**
@@ -203,22 +204,22 @@ class h {
203
204
  * @param data - Motion data from iOS
204
205
  */
205
206
  broadcastMotionData(e) {
206
- if (console.log(`๐Ÿ“ข [Aippy Runtime] broadcastMotionData called, listeners: ${this.motionListeners.length}`), this.motionListeners.length === 0) {
207
- console.warn("โš ๏ธ [Aippy Runtime] No motion listeners to broadcast to");
207
+ if (this.motionListeners.length === 0) {
208
+ this.noListenersWarned || (console.warn("โš ๏ธ [Aippy Runtime] No motion listeners to broadcast to"), this.noListenersWarned = !0);
208
209
  return;
209
210
  }
210
- const t = e.motion || e;
211
- console.log("๐Ÿ“Š [Aippy Runtime] Broadcasting motion data:", t), this.motionListeners.forEach((i, n) => {
211
+ const n = e.motion || e;
212
+ this.motionListeners.forEach((i) => {
212
213
  try {
213
- console.log(`๐Ÿ“ฒ [Aippy Runtime] Calling listener #${n + 1}`), i(t);
214
- } catch (r) {
215
- console.error(`โš ๏ธ [Aippy Runtime] Error in motion listener #${n + 1}:`, r);
214
+ i(n);
215
+ } catch (t) {
216
+ console.error("โš ๏ธ [Aippy Runtime] Error in motion listener:", t);
216
217
  }
217
218
  });
218
219
  }
219
220
  }
220
- function g(o) {
221
- if (console.log("๐ŸŽฏ [Aippy Runtime] processMotionData called by iOS with data:", o), !o || typeof o != "object") {
221
+ function w(o) {
222
+ if (!o || typeof o != "object") {
222
223
  console.warn("โš ๏ธ [Aippy Runtime] Invalid motion data type:", typeof o);
223
224
  return;
224
225
  }
@@ -226,17 +227,17 @@ function g(o) {
226
227
  console.warn("โš ๏ธ [Aippy Runtime] Motion data missing valid motion field");
227
228
  return;
228
229
  }
229
- console.log("โœ… [Aippy Runtime] Motion data validated, broadcasting to listeners"), l.broadcastMotionData(o);
230
+ p.broadcastMotionData(o);
230
231
  }
231
- const l = new h();
232
- typeof window < "u" && (window.aippyRuntime = l, window.processMotionData = g);
232
+ const p = new h();
233
+ typeof window < "u" && (window.aippyRuntime = p, window.processMotionData = w);
233
234
  export {
234
235
  d as A,
235
236
  a as C,
236
237
  R as E,
237
- f as R,
238
+ y as R,
238
239
  h as a,
239
- l as b,
240
- w as c,
241
- g as p
240
+ p as b,
241
+ g as c,
242
+ w as p
242
243
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aippy/runtime",
3
- "version": "0.2.4-dev.7",
3
+ "version": "0.2.4-dev.8",
4
4
  "description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
5
5
  "private": false,
6
6
  "type": "module",