@aippy/runtime 0.2.5-dev.1 → 0.2.6

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,111 +0,0 @@
1
- /**
2
- * User SDK types and interfaces
3
- */
4
- /**
5
- * Global type declarations for User SDK iOS bridge
6
- * Note: webkit.messageHandlers.aippyListener is already declared in tweaks/types.ts
7
- */
8
- declare global {
9
- interface Window {
10
- /** User credentials callback from iOS */
11
- processUserCredentials?: (data: unknown) => void;
12
- }
13
- }
14
- /**
15
- * User profile data structure
16
- */
17
- export interface UserProfile {
18
- /** User unique identifier */
19
- id: string;
20
- /** Display name */
21
- displayName: string;
22
- /** Username (for @mentions) */
23
- username: string;
24
- /** Avatar URL */
25
- photoUrl?: string;
26
- /** Online status */
27
- online?: boolean;
28
- /** User bio */
29
- bio?: string;
30
- /** Cover image URL */
31
- coverImageUrl?: string;
32
- /** Additional metadata */
33
- [key: string]: unknown;
34
- }
35
- /**
36
- * Query result for user profile
37
- */
38
- export interface UserProfileQueryResult {
39
- /** User profile data */
40
- data: UserProfile | null;
41
- /** Loading state */
42
- isLoading: boolean;
43
- /** Error state */
44
- isError: boolean;
45
- /** Error object */
46
- error: Error | null;
47
- /** Refetch function */
48
- refetch: () => Promise<void>;
49
- }
50
- /**
51
- * Options for getting user profile by ID
52
- */
53
- export interface GetUserProfileByIdOptions {
54
- /** User ID to fetch */
55
- id: string;
56
- }
57
- /**
58
- * Options for getting joined user profiles
59
- */
60
- export interface GetJoinedUserProfilesOptions {
61
- /** Whether to include current user */
62
- includeSelf?: boolean;
63
- }
64
- /**
65
- * Query result for multiple user profiles
66
- */
67
- export interface UserProfilesQueryResult {
68
- /** User profiles array */
69
- data: UserProfile[];
70
- /** Loading state */
71
- isLoading: boolean;
72
- /** Error state */
73
- isError: boolean;
74
- /** Error object */
75
- error: Error | null;
76
- /** Refetch function */
77
- refetch: () => Promise<void>;
78
- }
79
- /**
80
- * Date format options
81
- */
82
- export interface FormatDateOptions {
83
- /** Timestamp in milliseconds */
84
- timestampMs: number;
85
- /** Format string (e.g., 'MMM d, h:mm a') */
86
- formatString: string;
87
- }
88
- /**
89
- * User session info interface
90
- */
91
- export interface UserSessionInfoInterface {
92
- /** Get current user ID synchronously */
93
- getCurrentUserId: () => string | null;
94
- /** Get current timestamp in milliseconds */
95
- getTimestampInMs: () => number;
96
- /** Format date with given format string */
97
- formatDate: (options: FormatDateOptions) => string;
98
- }
99
- /**
100
- * User SDK configuration
101
- */
102
- export interface UserSdkConfig {
103
- /** API base URL */
104
- apiBaseUrl: string;
105
- /** Auth token */
106
- authToken: string;
107
- /** Current user ID */
108
- currentUserId: string | null;
109
- /** Cache time in milliseconds */
110
- cacheTime?: number;
111
- }
@@ -1,6 +0,0 @@
1
- import { UserSessionInfoInterface } from './types';
2
- /**
3
- * User session info object
4
- * Provides synchronous access to current user data and utilities
5
- */
6
- export declare const userSessionInfo: UserSessionInfoInterface;
package/dist/user.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './user/index'
2
- export {}
@@ -1,186 +0,0 @@
1
- import { useState as s, useEffect as y, useCallback as h } from "react";
2
- import { g as m, b as E } from "./bridge-DdAH4txB.js";
3
- const U = /* @__PURE__ */ new Map();
4
- async function S(e) {
5
- const t = m(), n = U.get(e);
6
- if (n && Date.now() - n.timestamp < (t.cacheTime || 3e5))
7
- return n.data;
8
- try {
9
- const r = await fetch(
10
- `${t.apiBaseUrl}/user/profile?targetUid=${e}`,
11
- {
12
- method: "GET",
13
- headers: {
14
- Authorization: `Bearer ${t.authToken}`,
15
- "Content-Type": "application/json"
16
- }
17
- }
18
- );
19
- if (!r.ok)
20
- throw new Error(`Failed to fetch user profile: ${r.status}`);
21
- const a = await r.json(), o = M(a, e);
22
- return U.set(e, { data: o, timestamp: Date.now() }), o;
23
- } catch (r) {
24
- return console.error("[UserSDK] Failed to fetch user profile:", r), null;
25
- }
26
- }
27
- function M(e, t) {
28
- const n = typeof e == "object" && e !== null ? e : {}, r = n.data || n.user || n;
29
- return {
30
- id: r.id || r.uid || t,
31
- displayName: r.displayName || r.nickname || r.name || "Unknown User",
32
- username: r.username || r.id || t,
33
- photoUrl: r.photoUrl || r.avatar || r.avatarUrl,
34
- online: r.online ?? !1,
35
- bio: r.bio,
36
- coverImageUrl: r.coverImageUrl,
37
- ...r
38
- };
39
- }
40
- function w(e) {
41
- e ? U.delete(e) : U.clear();
42
- }
43
- function I() {
44
- const [e, t] = s(
45
- m().currentUserId
46
- );
47
- return y(() => {
48
- t(m().currentUserId);
49
- }, []), e;
50
- }
51
- function T() {
52
- const [e, t] = s(E());
53
- return y(() => {
54
- t(E());
55
- }, []), e;
56
- }
57
- function b() {
58
- const e = I(), [t, n] = s(null), [r, a] = s(!0), [o, u] = s(!1), [g, f] = s(null), i = h(async () => {
59
- if (!e) {
60
- n(null), a(!1);
61
- return;
62
- }
63
- a(!0), u(!1), f(null);
64
- try {
65
- const c = await S(e);
66
- n(c);
67
- } catch (c) {
68
- u(!0), f(c instanceof Error ? c : new Error(String(c)));
69
- } finally {
70
- a(!1);
71
- }
72
- }, [e]);
73
- y(() => {
74
- i();
75
- }, [i]);
76
- const l = h(async () => {
77
- e && w(e), await i();
78
- }, [e, i]);
79
- return { data: t, isLoading: r, isError: o, error: g, refetch: l };
80
- }
81
- function A(e) {
82
- const { id: t } = e, [n, r] = s(null), [a, o] = s(!0), [u, g] = s(!1), [f, i] = s(null), l = h(async () => {
83
- if (!t) {
84
- r(null), o(!1);
85
- return;
86
- }
87
- o(!0), g(!1), i(null);
88
- try {
89
- const p = await S(t);
90
- r(p);
91
- } catch (p) {
92
- g(!0), i(p instanceof Error ? p : new Error(String(p)));
93
- } finally {
94
- o(!1);
95
- }
96
- }, [t]);
97
- y(() => {
98
- l();
99
- }, [l]);
100
- const c = h(async () => {
101
- w(t), await l();
102
- }, [t, l]);
103
- return { data: n, isLoading: a, isError: u, error: f, refetch: c };
104
- }
105
- function L(e = {}) {
106
- const { includeSelf: t = !0 } = e, n = I(), [r, a] = s([]), [o, u] = s(!0), [g, f] = s(!1), [i, l] = s(null), c = h(async () => {
107
- u(!0), f(!1), l(null);
108
- try {
109
- const d = [];
110
- if (t && n) {
111
- const D = await S(n);
112
- D && d.push(D);
113
- }
114
- a(d);
115
- } catch (d) {
116
- f(!0), l(d instanceof Error ? d : new Error(String(d)));
117
- } finally {
118
- u(!1);
119
- }
120
- }, [t, n]);
121
- y(() => {
122
- c();
123
- }, [c]);
124
- const p = h(async () => {
125
- w(), await c();
126
- }, [c]);
127
- return { data: r, isLoading: o, isError: g, error: i, refetch: p };
128
- }
129
- function v() {
130
- return m().currentUserId;
131
- }
132
- function k(e, t) {
133
- const n = [
134
- "Jan",
135
- "Feb",
136
- "Mar",
137
- "Apr",
138
- "May",
139
- "Jun",
140
- "Jul",
141
- "Aug",
142
- "Sep",
143
- "Oct",
144
- "Nov",
145
- "Dec"
146
- ], r = e.getHours(), a = r % 12 || 12, o = r >= 12 ? "PM" : "AM";
147
- return t.replace("MMM", n[e.getMonth()]).replace("dd", String(e.getDate()).padStart(2, "0")).replace("d", String(e.getDate())).replace("hh", String(a).padStart(2, "0")).replace("h", String(a)).replace("mm", String(e.getMinutes()).padStart(2, "0")).replace("a", o).replace("yyyy", String(e.getFullYear())).replace("yy", String(e.getFullYear()).slice(-2));
148
- }
149
- const F = {
150
- /**
151
- * Get current user ID synchronously
152
- */
153
- getCurrentUserId() {
154
- return m().currentUserId;
155
- },
156
- /**
157
- * Get current timestamp in milliseconds
158
- */
159
- getTimestampInMs() {
160
- return Date.now();
161
- },
162
- /**
163
- * Format date with given format string
164
- * @param options - Format options with timestamp and format string
165
- * @returns Formatted date string
166
- *
167
- * @example
168
- * userSessionInfo.formatDate({ timestampMs: Date.now(), formatString: 'MMM d, h:mm a' })
169
- * // Returns: "Jan 7, 10:30 PM"
170
- */
171
- formatDate(e) {
172
- const { timestampMs: t, formatString: n } = e, r = new Date(t);
173
- return k(r, n);
174
- }
175
- };
176
- export {
177
- T as a,
178
- b,
179
- A as c,
180
- L as d,
181
- w as e,
182
- S as f,
183
- v as g,
184
- F as h,
185
- I as u
186
- };