@aippy/runtime 0.2.3 → 0.2.4-dev.2

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.
@@ -8,6 +8,7 @@
8
8
  */
9
9
  export { patchAudioContext } from './patchAudioContext';
10
10
  export type { AudioContextPatchOptions, AutoPauseOptions, MediaElementType, PatchedAudioContext, } from './types';
11
- export { createHiddenMediaElement, createHiddenVideoElement, isIOSDevice, isMediaStreamAudioSupported, } from './utils';
11
+ export { createHiddenMediaElement, createHiddenVideoElement, isMediaStreamAudioSupported, } from './utils';
12
12
  export { useAudioContext } from './useAudioContext';
13
13
  export type { UseAudioContextOptions, UseAudioContextReturn } from './useAudioContext';
14
+ export { isIOSDevice } from './utils';
@@ -1,4 +1,4 @@
1
- import { c as i, a as t, i as d, b as o, p as s, u as n } from "../useAudioContext-BKgy28A1.js";
1
+ import { c as i, a as t, b as d, i as o, p as s, u as n } from "../useAudioContext-CNQQSTab.js";
2
2
  export {
3
3
  i as createHiddenMediaElement,
4
4
  t as createHiddenVideoElement,
@@ -2,3 +2,4 @@ export * from './types';
2
2
  export * from './config';
3
3
  export * from './errors';
4
4
  export * from './version';
5
+ export * from './runtime';
@@ -1,45 +1,50 @@
1
- import { A as d, E as v, c as _ } from "../errors-CDEBaBxB.js";
2
- const o = {
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
+ const s = {
3
3
  mode: "development",
4
4
  debug: !1,
5
5
  apiBaseUrl: void 0,
6
6
  headers: {}
7
7
  };
8
- function r() {
8
+ function o() {
9
9
  const e = {};
10
10
  return typeof process < "u" && process.env && (process.env.NODE_ENV && (e.mode = process.env.NODE_ENV), process.env.AIPPY_DEBUG && (e.debug = process.env.AIPPY_DEBUG === "true"), process.env.AIPPY_API_BASE_URL && (e.apiBaseUrl = process.env.AIPPY_API_BASE_URL)), e;
11
11
  }
12
- function a(e) {
13
- const n = r();
12
+ function c(e) {
13
+ const n = o();
14
14
  return {
15
- ...o,
15
+ ...s,
16
16
  ...n,
17
17
  ...e,
18
18
  headers: {
19
- ...o.headers,
19
+ ...s.headers,
20
20
  ...n.headers,
21
21
  ...e?.headers
22
22
  }
23
23
  };
24
24
  }
25
- const s = "0.2.3", t = {
26
- version: s
27
- }, i = t.version, c = "@aippy/runtime";
25
+ const r = "0.2.4-dev.2", a = {
26
+ version: r
27
+ }, i = a.version, t = "@aippy/runtime";
28
28
  function p() {
29
29
  return {
30
- name: c,
30
+ name: t,
31
31
  version: i,
32
32
  buildTime: (/* @__PURE__ */ new Date()).toISOString()
33
33
  };
34
34
  }
35
35
  export {
36
- d as AippyRuntimeError,
37
- o as DEFAULT_CONFIG,
38
- v as ERROR_CODES,
39
- c as SDK_NAME,
36
+ d as AippyRuntime,
37
+ f as AippyRuntimeError,
38
+ u as Cancellable,
39
+ s as DEFAULT_CONFIG,
40
+ A as ERROR_CODES,
41
+ _ as ReceiveChannel,
42
+ t as SDK_NAME,
40
43
  i as VERSION,
41
- _ as createError,
42
- r as getConfigFromEnv,
44
+ m as aippyRuntime,
45
+ R as createError,
46
+ o as getConfigFromEnv,
43
47
  p as getVersionInfo,
44
- a as mergeConfig
48
+ c as mergeConfig,
49
+ g as processMotionData
45
50
  };
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Aippy Runtime - Unified runtime for native bridge communication
3
+ */
4
+ /**
5
+ * Cancellable class - For managing subscriptions
6
+ */
7
+ export declare class Cancellable {
8
+ private cancelFn?;
9
+ private cancelled;
10
+ constructor(cancelFn?: (() => void) | undefined);
11
+ cancel(): void;
12
+ get isCancelled(): boolean;
13
+ }
14
+ /**
15
+ * ReceiveChannel - Manages message receiving and subscription
16
+ */
17
+ export declare class ReceiveChannel {
18
+ private emitter;
19
+ /**
20
+ * Emit a message to subscribers
21
+ */
22
+ emit(message: {
23
+ endpoint: string;
24
+ payload: any;
25
+ }): void;
26
+ /**
27
+ * Subscribe to messages on a specific endpoint
28
+ */
29
+ subscribe(endpoint: string, callback: (payload: any) => void): Cancellable;
30
+ /**
31
+ * Subscribe to a single message (auto-unsubscribe after first message)
32
+ */
33
+ once(endpoint: string, callback: (payload: any) => void): Cancellable;
34
+ }
35
+ /**
36
+ * AippyRuntime - Main runtime class for native bridge communication
37
+ */
38
+ export declare class AippyRuntime {
39
+ receiveChannel: ReceiveChannel;
40
+ private seq;
41
+ private motionListeners;
42
+ private noListenersWarned;
43
+ /**
44
+ * Unified native data receiver - Routes to specific handlers based on message type
45
+ * Called by native code via: window.aippyRuntime.receiveMessage(message)
46
+ *
47
+ * Supports two message formats:
48
+ * 1. Motion: { command: "navigator.motion", endpoint: "0", data: { motion: {...} } }
49
+ * 2. Tweaks: { "tweakKey": { value: ..., type: ... }, ... }
50
+ */
51
+ receiveMessage(message: any): Promise<void>;
52
+ /**
53
+ * Check if message is Motion format
54
+ * Motion: { command: "navigator.motion", endpoint: string, data: object }
55
+ */
56
+ private isMotionMessage;
57
+ /**
58
+ * Check if message is Tweaks format
59
+ * Tweaks: { "key": { value: any, type?: string, ... }, ... }
60
+ */
61
+ private isTweaksMessage;
62
+ /**
63
+ * Create a subscription to native events
64
+ * @param handler - WebKit message handler (e.g., aippyListener)
65
+ * @param subscribePayload - Subscription parameters (e.g., { command: "navigator.motion", type: "motion" })
66
+ * @param callback - Callback to handle received data
67
+ * @returns Cancellable subscription
68
+ */
69
+ createSubscription(handler: any, subscribePayload: any, callback: (data: any) => void): Cancellable;
70
+ /**
71
+ * Add motion listener (convenience method)
72
+ * @param callback - Callback to handle motion data
73
+ * @returns Cleanup function
74
+ */
75
+ addMotionListener(callback: (data: any) => void): () => void;
76
+ /**
77
+ * Broadcast motion data to all registered listeners
78
+ * Called by processMotionData when iOS sends data directly
79
+ * @param data - Motion data from iOS
80
+ */
81
+ broadcastMotionData(data: any): void;
82
+ }
83
+ /**
84
+ * Process Motion data from iOS native layer
85
+ * Called by native code via: window.processMotionData(data)
86
+ *
87
+ * @param data - Motion data in simplified format
88
+ * Expected format: { motion: { gravity: {x, y, z}, acceleration: {...}, rotation: {...} } }
89
+ */
90
+ export declare function processMotionData(data: any): void;
91
+ /**
92
+ * Global runtime instance - Singleton pattern
93
+ */
94
+ export declare const aippyRuntime: AippyRuntime;