@streamplace/components 0.7.0 → 0.7.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.
Files changed (97) hide show
  1. package/dist/components/chat/chat-box.js +46 -43
  2. package/dist/components/chat/chat-message.js +36 -33
  3. package/dist/components/chat/chat.js +31 -27
  4. package/dist/components/chat/mention-suggestions.js +16 -13
  5. package/dist/components/chat/mod-view.js +20 -17
  6. package/dist/components/mobile-player/fullscreen.js +21 -17
  7. package/dist/components/mobile-player/fullscreen.native.js +39 -35
  8. package/dist/components/mobile-player/player.js +38 -32
  9. package/dist/components/mobile-player/props.js +2 -1
  10. package/dist/components/mobile-player/shared.js +16 -13
  11. package/dist/components/mobile-player/ui/countdown.js +23 -19
  12. package/dist/components/mobile-player/ui/index.js +9 -5
  13. package/dist/components/mobile-player/ui/input.js +16 -12
  14. package/dist/components/mobile-player/ui/metrics.js +20 -16
  15. package/dist/components/mobile-player/ui/streamer-context-menu.js +6 -3
  16. package/dist/components/mobile-player/ui/viewer-context-menu.js +19 -16
  17. package/dist/components/mobile-player/ui/viewers.js +23 -0
  18. package/dist/components/mobile-player/use-webrtc.js +29 -24
  19. package/dist/components/mobile-player/video.js +109 -99
  20. package/dist/components/mobile-player/video.native.js +108 -84
  21. package/dist/components/mobile-player/webrtc-diagnostics.js +9 -5
  22. package/dist/components/mobile-player/webrtc-primitives.js +8 -6
  23. package/dist/components/mobile-player/webrtc-primitives.native.js +8 -1
  24. package/dist/components/ui/button.js +26 -23
  25. package/dist/components/ui/dialog.js +43 -40
  26. package/dist/components/ui/dropdown.js +121 -116
  27. package/dist/components/ui/icons.js +8 -5
  28. package/dist/components/ui/index.js +27 -19
  29. package/dist/components/ui/input.js +31 -28
  30. package/dist/components/ui/loader.js +9 -6
  31. package/dist/components/ui/primitives/button.js +33 -29
  32. package/dist/components/ui/primitives/input.js +44 -40
  33. package/dist/components/ui/primitives/modal.js +45 -41
  34. package/dist/components/ui/primitives/text.js +35 -29
  35. package/dist/components/ui/resizeable.js +54 -43
  36. package/dist/components/ui/text.js +50 -48
  37. package/dist/components/ui/textarea.js +13 -11
  38. package/dist/components/ui/toast.js +26 -23
  39. package/dist/components/ui/view.js +41 -39
  40. package/dist/hooks/index.js +12 -8
  41. package/dist/hooks/useAvatars.js +11 -8
  42. package/dist/hooks/useCameraToggle.js +7 -4
  43. package/dist/hooks/useKeyboard.js +13 -10
  44. package/dist/hooks/useKeyboardSlide.js +8 -5
  45. package/dist/hooks/useLivestreamInfo.js +17 -14
  46. package/dist/hooks/useOuterAndInnerDimensions.js +9 -6
  47. package/dist/hooks/usePlayerDimensions.js +9 -6
  48. package/dist/hooks/useSegmentDimensions.js +17 -0
  49. package/dist/hooks/useSegmentTiming.js +13 -10
  50. package/dist/index.js +24 -15
  51. package/dist/lib/facet.js +5 -1
  52. package/dist/lib/theme/atoms.js +153 -148
  53. package/dist/lib/theme/atoms.types.js +2 -1
  54. package/dist/lib/theme/index.js +31 -5
  55. package/dist/lib/theme/theme.js +91 -83
  56. package/dist/lib/theme/tokens.js +15 -12
  57. package/dist/lib/utils.js +22 -11
  58. package/dist/livestream-provider/index.js +19 -14
  59. package/dist/livestream-provider/websocket.js +14 -10
  60. package/dist/livestream-store/chat.js +26 -19
  61. package/dist/livestream-store/context.js +5 -2
  62. package/dist/livestream-store/index.js +7 -4
  63. package/dist/livestream-store/livestream-state.js +2 -1
  64. package/dist/livestream-store/livestream-store.js +31 -18
  65. package/dist/livestream-store/stream-key.js +22 -18
  66. package/dist/livestream-store/websocket-consumer.js +18 -14
  67. package/dist/player-store/context.js +5 -2
  68. package/dist/player-store/index.js +8 -5
  69. package/dist/player-store/player-provider.js +20 -15
  70. package/dist/player-store/player-state.js +9 -6
  71. package/dist/player-store/player-store.js +32 -21
  72. package/dist/player-store/single-player-provider.js +35 -23
  73. package/dist/streamplace-provider/context.js +5 -2
  74. package/dist/streamplace-provider/index.js +14 -10
  75. package/dist/streamplace-provider/poller.js +20 -17
  76. package/dist/streamplace-store/block.js +6 -3
  77. package/dist/streamplace-store/index.js +6 -3
  78. package/dist/streamplace-store/stream.js +14 -10
  79. package/dist/streamplace-store/streamplace-store.js +23 -13
  80. package/dist/streamplace-store/user.js +19 -14
  81. package/dist/streamplace-store/xrpc.js +10 -7
  82. package/node-compile-cache/v22.15.0-x64-92db9086-0/37be0eec +0 -0
  83. package/node-compile-cache/v22.15.0-x64-92db9086-0/56540125 +0 -0
  84. package/node-compile-cache/{v22.15.0-x64-efe9a9df-0 → v22.15.0-x64-92db9086-0}/67b1eb60 +0 -0
  85. package/node-compile-cache/{v22.15.0-x64-efe9a9df-0 → v22.15.0-x64-92db9086-0}/7c275f90 +0 -0
  86. package/package.json +6 -7
  87. package/src/components/mobile-player/ui/index.ts +1 -0
  88. package/src/components/mobile-player/ui/viewer-context-menu.tsx +5 -4
  89. package/src/components/mobile-player/ui/viewers.tsx +32 -0
  90. package/src/components/mobile-player/video.native.tsx +50 -5
  91. package/src/components/ui/resizeable.tsx +15 -3
  92. package/src/hooks/index.ts +1 -0
  93. package/src/hooks/useSegmentDimensions.tsx +18 -0
  94. package/tsconfig.json +2 -1
  95. package/tsconfig.tsbuildinfo +1 -1
  96. package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
  97. package/node-compile-cache/v22.15.0-x64-efe9a9df-0/56540125 +0 -0
@@ -1,51 +1,59 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { PortalHost } from "@rn-primitives/portal";
3
- import { createContext, useContext, useMemo, useState, } from "react";
4
- import { Platform, useColorScheme } from "react-native";
5
- import { animations, borderRadius, colors, shadows, spacing, touchTargets, typography, } from "./tokens";
6
- import { GestureHandlerRootView } from "react-native-gesture-handler";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createThemeStyles = exports.createThemeIcons = exports.createThemeColors = exports.darkTheme = exports.lightTheme = void 0;
4
+ exports.ThemeProvider = ThemeProvider;
5
+ exports.useTheme = useTheme;
6
+ exports.usePlatformTypography = usePlatformTypography;
7
+ exports.createThemedStyles = createThemedStyles;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const portal_1 = require("@rn-primitives/portal");
10
+ const react_1 = require("react");
11
+ const react_native_1 = require("react-native");
12
+ const tokens_1 = require("./tokens");
13
+ const react_native_gesture_handler_1 = require("react-native-gesture-handler");
7
14
  // Create theme colors based on dark mode
8
15
  const createThemeColors = (isDark) => ({
9
- background: isDark ? colors.gray[950] : colors.white,
10
- foreground: isDark ? colors.gray[50] : colors.gray[950],
11
- card: isDark ? colors.gray[900] : colors.white,
12
- cardForeground: isDark ? colors.gray[50] : colors.gray[950],
13
- popover: isDark ? colors.gray[900] : colors.white,
14
- popoverForeground: isDark ? colors.gray[50] : colors.gray[950],
15
- primary: Platform.OS === "ios" ? colors.ios.systemBlue : colors.primary[500],
16
- primaryForeground: colors.white,
17
- secondary: isDark ? colors.gray[800] : colors.gray[100],
18
- secondaryForeground: isDark ? colors.gray[50] : colors.gray[900],
19
- muted: isDark ? colors.gray[800] : colors.gray[100],
20
- mutedForeground: isDark ? colors.gray[400] : colors.gray[500],
21
- accent: isDark ? colors.gray[800] : colors.gray[100],
22
- accentForeground: isDark ? colors.gray[50] : colors.gray[900],
23
- destructive: Platform.OS === "ios" ? colors.ios.systemRed : colors.destructive[500],
24
- destructiveForeground: colors.white,
25
- success: Platform.OS === "ios" ? colors.ios.systemGreen : colors.success[500],
26
- successForeground: colors.white,
27
- warning: Platform.OS === "ios" ? colors.ios.systemOrange : colors.warning[500],
28
- warningForeground: colors.white,
29
- border: isDark ? colors.gray[500] + "30" : colors.gray[200] + "30",
30
- input: isDark ? colors.gray[800] : colors.gray[200],
31
- ring: Platform.OS === "ios" ? colors.ios.systemBlue : colors.primary[500],
32
- text: isDark ? colors.gray[50] : colors.gray[950],
33
- textMuted: isDark ? colors.gray[400] : colors.gray[500],
34
- textDisabled: isDark ? colors.gray[600] : colors.gray[400],
16
+ background: isDark ? tokens_1.colors.gray[950] : tokens_1.colors.white,
17
+ foreground: isDark ? tokens_1.colors.gray[50] : tokens_1.colors.gray[950],
18
+ card: isDark ? tokens_1.colors.gray[900] : tokens_1.colors.white,
19
+ cardForeground: isDark ? tokens_1.colors.gray[50] : tokens_1.colors.gray[950],
20
+ popover: isDark ? tokens_1.colors.gray[900] : tokens_1.colors.white,
21
+ popoverForeground: isDark ? tokens_1.colors.gray[50] : tokens_1.colors.gray[950],
22
+ primary: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemBlue : tokens_1.colors.primary[500],
23
+ primaryForeground: tokens_1.colors.white,
24
+ secondary: isDark ? tokens_1.colors.gray[800] : tokens_1.colors.gray[100],
25
+ secondaryForeground: isDark ? tokens_1.colors.gray[50] : tokens_1.colors.gray[900],
26
+ muted: isDark ? tokens_1.colors.gray[800] : tokens_1.colors.gray[100],
27
+ mutedForeground: isDark ? tokens_1.colors.gray[400] : tokens_1.colors.gray[500],
28
+ accent: isDark ? tokens_1.colors.gray[800] : tokens_1.colors.gray[100],
29
+ accentForeground: isDark ? tokens_1.colors.gray[50] : tokens_1.colors.gray[900],
30
+ destructive: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemRed : tokens_1.colors.destructive[500],
31
+ destructiveForeground: tokens_1.colors.white,
32
+ success: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemGreen : tokens_1.colors.success[500],
33
+ successForeground: tokens_1.colors.white,
34
+ warning: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemOrange : tokens_1.colors.warning[500],
35
+ warningForeground: tokens_1.colors.white,
36
+ border: isDark ? tokens_1.colors.gray[500] + "30" : tokens_1.colors.gray[200] + "30",
37
+ input: isDark ? tokens_1.colors.gray[800] : tokens_1.colors.gray[200],
38
+ ring: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemBlue : tokens_1.colors.primary[500],
39
+ text: isDark ? tokens_1.colors.gray[50] : tokens_1.colors.gray[950],
40
+ textMuted: isDark ? tokens_1.colors.gray[400] : tokens_1.colors.gray[500],
41
+ textDisabled: isDark ? tokens_1.colors.gray[600] : tokens_1.colors.gray[400],
35
42
  });
43
+ exports.createThemeColors = createThemeColors;
36
44
  // Create theme styles based on colors
37
45
  const createThemeStyles = (themeColors) => ({
38
46
  shadow: {
39
- sm: shadows.sm,
40
- md: shadows.md,
41
- lg: shadows.lg,
42
- xl: shadows.xl,
47
+ sm: tokens_1.shadows.sm,
48
+ md: tokens_1.shadows.md,
49
+ lg: tokens_1.shadows.lg,
50
+ xl: tokens_1.shadows.xl,
43
51
  },
44
52
  button: {
45
53
  primary: {
46
54
  backgroundColor: themeColors.primary,
47
55
  borderWidth: 0,
48
- ...shadows.sm,
56
+ ...tokens_1.shadows.sm,
49
57
  },
50
58
  secondary: {
51
59
  backgroundColor: themeColors.secondary,
@@ -77,10 +85,10 @@ const createThemeStyles = (themeColors) => ({
77
85
  backgroundColor: themeColors.background,
78
86
  borderWidth: 1,
79
87
  borderColor: themeColors.border,
80
- borderRadius: borderRadius.md,
81
- paddingHorizontal: spacing[3],
82
- paddingVertical: spacing[3],
83
- minHeight: touchTargets.minimum,
88
+ borderRadius: tokens_1.borderRadius.md,
89
+ paddingHorizontal: tokens_1.spacing[3],
90
+ paddingVertical: tokens_1.spacing[3],
91
+ minHeight: tokens_1.touchTargets.minimum,
84
92
  },
85
93
  focused: {
86
94
  borderColor: themeColors.ring,
@@ -94,11 +102,12 @@ const createThemeStyles = (themeColors) => ({
94
102
  card: {
95
103
  base: {
96
104
  backgroundColor: themeColors.card,
97
- borderRadius: borderRadius.lg,
98
- ...shadows.sm,
105
+ borderRadius: tokens_1.borderRadius.lg,
106
+ ...tokens_1.shadows.sm,
99
107
  },
100
108
  },
101
109
  });
110
+ exports.createThemeStyles = createThemeStyles;
102
111
  // Create theme icons based on colors
103
112
  const createThemeIcons = (themeColors) => ({
104
113
  color: {
@@ -117,14 +126,15 @@ const createThemeIcons = (themeColors) => ({
117
126
  xl: 32,
118
127
  },
119
128
  });
129
+ exports.createThemeIcons = createThemeIcons;
120
130
  // Create the theme context
121
- const ThemeContext = createContext(null);
131
+ const ThemeContext = (0, react_1.createContext)(null);
122
132
  // Theme provider component
123
- export function ThemeProvider({ children, defaultTheme = "system", forcedTheme, }) {
124
- const systemColorScheme = useColorScheme();
125
- const [currentTheme, setCurrentTheme] = useState(defaultTheme);
133
+ function ThemeProvider({ children, defaultTheme = "system", forcedTheme, }) {
134
+ const systemColorScheme = (0, react_native_1.useColorScheme)();
135
+ const [currentTheme, setCurrentTheme] = (0, react_1.useState)(defaultTheme);
126
136
  // Determine if dark mode should be active
127
- const isDark = useMemo(() => {
137
+ const isDark = (0, react_1.useMemo)(() => {
128
138
  if (forcedTheme === "light")
129
139
  return false;
130
140
  if (forcedTheme === "dark")
@@ -138,24 +148,24 @@ export function ThemeProvider({ children, defaultTheme = "system", forcedTheme,
138
148
  return systemColorScheme === "dark";
139
149
  }, [forcedTheme, currentTheme, systemColorScheme]);
140
150
  // Create theme based on dark mode
141
- const theme = useMemo(() => {
151
+ const theme = (0, react_1.useMemo)(() => {
142
152
  const themeColors = createThemeColors(isDark);
143
153
  return {
144
154
  colors: themeColors,
145
- spacing,
146
- borderRadius,
147
- typography,
148
- shadows,
149
- touchTargets,
150
- animations,
155
+ spacing: tokens_1.spacing,
156
+ borderRadius: tokens_1.borderRadius,
157
+ typography: tokens_1.typography,
158
+ shadows: tokens_1.shadows,
159
+ touchTargets: tokens_1.touchTargets,
160
+ animations: tokens_1.animations,
151
161
  };
152
162
  }, [isDark]);
153
163
  // Create utility styles
154
- const styles = useMemo(() => {
164
+ const styles = (0, react_1.useMemo)(() => {
155
165
  return createThemeStyles(theme.colors);
156
166
  }, [theme.colors]);
157
167
  // Create icon utilities
158
- const icons = useMemo(() => {
168
+ const icons = (0, react_1.useMemo)(() => {
159
169
  return createThemeIcons(theme.colors);
160
170
  }, [theme.colors]);
161
171
  // Theme controls
@@ -175,7 +185,7 @@ export function ThemeProvider({ children, defaultTheme = "system", forcedTheme,
175
185
  });
176
186
  }
177
187
  };
178
- const value = useMemo(() => ({
188
+ const value = (0, react_1.useMemo)(() => ({
179
189
  theme,
180
190
  styles,
181
191
  icons,
@@ -195,54 +205,52 @@ export function ThemeProvider({ children, defaultTheme = "system", forcedTheme,
195
205
  setTheme,
196
206
  toggleTheme,
197
207
  ]);
198
- return (_jsx(ThemeContext.Provider, { value: value, children: _jsxs(GestureHandlerRootView, { children: [children, _jsx(PortalHost, {})] }) }));
208
+ return ((0, jsx_runtime_1.jsx)(ThemeContext.Provider, { value: value, children: (0, jsx_runtime_1.jsxs)(react_native_gesture_handler_1.GestureHandlerRootView, { children: [children, (0, jsx_runtime_1.jsx)(portal_1.PortalHost, {})] }) }));
199
209
  }
200
210
  // Hook to use theme
201
- export function useTheme() {
202
- const context = useContext(ThemeContext);
211
+ function useTheme() {
212
+ const context = (0, react_1.useContext)(ThemeContext);
203
213
  if (!context) {
204
214
  throw new Error("useTheme must be used within a ThemeProvider");
205
215
  }
206
216
  return context;
207
217
  }
208
218
  // Hook to get current platform's typography
209
- export function usePlatformTypography() {
219
+ function usePlatformTypography() {
210
220
  const { theme } = useTheme();
211
- return useMemo(() => {
212
- if (Platform.OS === "ios") {
221
+ return (0, react_1.useMemo)(() => {
222
+ if (react_native_1.Platform.OS === "ios") {
213
223
  return theme.typography.ios;
214
224
  }
215
- else if (Platform.OS === "android") {
225
+ else if (react_native_1.Platform.OS === "android") {
216
226
  return theme.typography.android;
217
227
  }
218
228
  return theme.typography.universal;
219
229
  }, [theme.typography]);
220
230
  }
221
231
  // Utility function to create theme-aware styles
222
- export function createThemedStyles(styleCreator) {
232
+ function createThemedStyles(styleCreator) {
223
233
  return function useThemedStyles() {
224
234
  const { theme, styles, icons } = useTheme();
225
- return useMemo(() => styleCreator(theme, styles, icons), [theme, styles, icons]);
235
+ return (0, react_1.useMemo)(() => styleCreator(theme, styles, icons), [theme, styles, icons]);
226
236
  };
227
237
  }
228
238
  // Create light and dark theme instances for external use
229
- export const lightTheme = {
239
+ exports.lightTheme = {
230
240
  colors: createThemeColors(false),
231
- spacing,
232
- borderRadius,
233
- typography,
234
- shadows,
235
- touchTargets,
236
- animations,
241
+ spacing: tokens_1.spacing,
242
+ borderRadius: tokens_1.borderRadius,
243
+ typography: tokens_1.typography,
244
+ shadows: tokens_1.shadows,
245
+ touchTargets: tokens_1.touchTargets,
246
+ animations: tokens_1.animations,
237
247
  };
238
- export const darkTheme = {
248
+ exports.darkTheme = {
239
249
  colors: createThemeColors(true),
240
- spacing,
241
- borderRadius,
242
- typography,
243
- shadows,
244
- touchTargets,
245
- animations,
250
+ spacing: tokens_1.spacing,
251
+ borderRadius: tokens_1.borderRadius,
252
+ typography: tokens_1.typography,
253
+ shadows: tokens_1.shadows,
254
+ touchTargets: tokens_1.touchTargets,
255
+ animations: tokens_1.animations,
246
256
  };
247
- // Export individual theme utilities for convenience
248
- export { createThemeColors, createThemeIcons, createThemeStyles };
@@ -1,8 +1,11 @@
1
+ "use strict";
1
2
  /**
2
3
  * Design tokens for React Native components
3
4
  * Inspired by shadcn/ui but adapted for React Native styling
4
5
  */
5
- export const colors = {
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.breakpoints = exports.animations = exports.touchTargets = exports.shadows = exports.typography = exports.borderRadius = exports.spacing = exports.colors = void 0;
8
+ exports.colors = {
6
9
  // Primary colors
7
10
  primary: {
8
11
  50: "#eff6ff",
@@ -109,7 +112,7 @@ export const colors = {
109
112
  black: "#000000",
110
113
  white: "#FFFFFF",
111
114
  };
112
- export const spacing = {
115
+ exports.spacing = {
113
116
  0: 0,
114
117
  1: 4,
115
118
  2: 8,
@@ -142,7 +145,7 @@ export const spacing = {
142
145
  96: 384,
143
146
  auto: "auto",
144
147
  };
145
- export const borderRadius = {
148
+ exports.borderRadius = {
146
149
  none: 0,
147
150
  sm: 4,
148
151
  md: 8,
@@ -152,7 +155,7 @@ export const borderRadius = {
152
155
  "3xl": 24,
153
156
  full: 999,
154
157
  };
155
- export const typography = {
158
+ exports.typography = {
156
159
  // iOS system font sizes
157
160
  ios: {
158
161
  largeTitle: {
@@ -323,7 +326,7 @@ export const typography = {
323
326
  },
324
327
  },
325
328
  };
326
- export const shadows = {
329
+ exports.shadows = {
327
330
  none: {
328
331
  shadowColor: "transparent",
329
332
  shadowOffset: { width: 0, height: 0 },
@@ -332,28 +335,28 @@ export const shadows = {
332
335
  elevation: 0,
333
336
  },
334
337
  sm: {
335
- shadowColor: colors.black,
338
+ shadowColor: exports.colors.black,
336
339
  shadowOffset: { width: 0, height: 1 },
337
340
  shadowOpacity: 0.05,
338
341
  shadowRadius: 2,
339
342
  elevation: 2,
340
343
  },
341
344
  md: {
342
- shadowColor: colors.black,
345
+ shadowColor: exports.colors.black,
343
346
  shadowOffset: { width: 0, height: 2 },
344
347
  shadowOpacity: 0.1,
345
348
  shadowRadius: 4,
346
349
  elevation: 4,
347
350
  },
348
351
  lg: {
349
- shadowColor: colors.black,
352
+ shadowColor: exports.colors.black,
350
353
  shadowOffset: { width: 0, height: 4 },
351
354
  shadowOpacity: 0.15,
352
355
  shadowRadius: 8,
353
356
  elevation: 8,
354
357
  },
355
358
  xl: {
356
- shadowColor: colors.black,
359
+ shadowColor: exports.colors.black,
357
360
  shadowOffset: { width: 0, height: 8 },
358
361
  shadowOpacity: 0.2,
359
362
  shadowRadius: 16,
@@ -361,20 +364,20 @@ export const shadows = {
361
364
  },
362
365
  };
363
366
  // Touch targets (iOS Human Interface Guidelines)
364
- export const touchTargets = {
367
+ exports.touchTargets = {
365
368
  minimum: 44, // Minimum touch target size
366
369
  comfortable: 48, // Comfortable touch target size
367
370
  large: 56, // Large touch target size
368
371
  };
369
372
  // Animation durations
370
- export const animations = {
373
+ exports.animations = {
371
374
  fast: 150,
372
375
  normal: 200,
373
376
  slow: 300,
374
377
  slower: 500,
375
378
  };
376
379
  // Breakpoints for responsive design
377
- export const breakpoints = {
380
+ exports.breakpoints = {
378
381
  sm: 640,
379
382
  md: 768,
380
383
  lg: 1024,
package/dist/lib/utils.js CHANGED
@@ -1,17 +1,28 @@
1
- import { StyleSheet } from "react-native";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeStyles = mergeStyles;
4
+ exports.createStyleMerger = createStyleMerger;
5
+ exports.conditionalStyle = conditionalStyle;
6
+ exports.responsiveValue = responsiveValue;
7
+ exports.platformStyle = platformStyle;
8
+ exports.hexToRgba = hexToRgba;
9
+ exports.debounce = debounce;
10
+ exports.throttle = throttle;
11
+ exports.forwardProps = forwardProps;
12
+ const react_native_1 = require("react-native");
2
13
  /**
3
14
  * Merges React Native styles similar to how cn() merges CSS classes
4
15
  * Handles arrays, objects, and falsy values
5
16
  */
6
- export function mergeStyles(...styles) {
17
+ function mergeStyles(...styles) {
7
18
  const validStyles = styles.filter(Boolean).flat();
8
- return StyleSheet.flatten(validStyles) || {};
19
+ return react_native_1.StyleSheet.flatten(validStyles) || {};
9
20
  }
10
21
  /**
11
22
  * Creates a style merger function that includes base styles
12
23
  * Useful for component variants
13
24
  */
14
- export function createStyleMerger(baseStyle) {
25
+ function createStyleMerger(baseStyle) {
15
26
  return (...styles) => {
16
27
  return mergeStyles(baseStyle, ...styles);
17
28
  };
@@ -19,13 +30,13 @@ export function createStyleMerger(baseStyle) {
19
30
  /**
20
31
  * Conditionally applies styles based on boolean conditions
21
32
  */
22
- export function conditionalStyle(condition, trueStyle, falseStyle) {
33
+ function conditionalStyle(condition, trueStyle, falseStyle) {
23
34
  return condition ? trueStyle : falseStyle;
24
35
  }
25
36
  /**
26
37
  * Creates responsive values based on screen dimensions
27
38
  */
28
- export function responsiveValue(values, screenWidth) {
39
+ function responsiveValue(values, screenWidth) {
29
40
  if (screenWidth >= 1280 && values.xl !== undefined)
30
41
  return values.xl;
31
42
  if (screenWidth >= 1024 && values.lg !== undefined)
@@ -39,7 +50,7 @@ export function responsiveValue(values, screenWidth) {
39
50
  /**
40
51
  * Creates platform-specific styles
41
52
  */
42
- export function platformStyle(styles) {
53
+ function platformStyle(styles) {
43
54
  const Platform = require("react-native").Platform;
44
55
  if (Platform.OS === "ios" && styles.ios)
45
56
  return styles.ios;
@@ -52,7 +63,7 @@ export function platformStyle(styles) {
52
63
  /**
53
64
  * Converts hex color to rgba
54
65
  */
55
- export function hexToRgba(hex, alpha = 1) {
66
+ function hexToRgba(hex, alpha = 1) {
56
67
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
57
68
  if (!result)
58
69
  return hex;
@@ -64,7 +75,7 @@ export function hexToRgba(hex, alpha = 1) {
64
75
  /**
65
76
  * Creates a debounced function for performance
66
77
  */
67
- export function debounce(func, delay) {
78
+ function debounce(func, delay) {
68
79
  let timeoutId;
69
80
  return (...args) => {
70
81
  clearTimeout(timeoutId);
@@ -74,7 +85,7 @@ export function debounce(func, delay) {
74
85
  /**
75
86
  * Creates a throttled function for performance
76
87
  */
77
- export function throttle(func, delay) {
88
+ function throttle(func, delay) {
78
89
  let lastCall = 0;
79
90
  return (...args) => {
80
91
  const now = Date.now();
@@ -87,7 +98,7 @@ export function throttle(func, delay) {
87
98
  /**
88
99
  * Type-safe component prop forwarding
89
100
  */
90
- export function forwardProps(props, omit) {
101
+ function forwardProps(props, omit) {
91
102
  const result = { ...props };
92
103
  omit.forEach((key) => delete result[key]);
93
104
  return result;
@@ -1,25 +1,30 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useContext, useRef } from "react";
3
- import { LivestreamContext, makeLivestreamStore } from "../livestream-store";
4
- import { useLivestreamWebsocket } from "./websocket";
5
- export function LivestreamProvider({ children, src, }) {
6
- const context = useContext(LivestreamContext);
7
- const store = useRef(makeLivestreamStore()).current;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LivestreamProvider = LivestreamProvider;
4
+ exports.WebsocketWatcher = WebsocketWatcher;
5
+ exports.LivestreamPoller = LivestreamPoller;
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const livestream_store_1 = require("../livestream-store");
9
+ const websocket_1 = require("./websocket");
10
+ function LivestreamProvider({ children, src, }) {
11
+ const context = (0, react_1.useContext)(livestream_store_1.LivestreamContext);
12
+ const store = (0, react_1.useRef)((0, livestream_store_1.makeLivestreamStore)()).current;
8
13
  if (context) {
9
14
  // this is ok, there's use cases for having one in another
10
15
  // like having a player component that's independently usable
11
16
  // but can also be embedded within an entire livestream page
12
- return _jsx(_Fragment, { children: children });
17
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
13
18
  }
14
19
  window.livestreamStore = store;
15
- return (_jsx(LivestreamContext.Provider, { value: { store: store }, children: _jsx(LivestreamPoller, { src: src, children: children }) }));
20
+ return ((0, jsx_runtime_1.jsx)(livestream_store_1.LivestreamContext.Provider, { value: { store: store }, children: (0, jsx_runtime_1.jsx)(LivestreamPoller, { src: src, children: children }) }));
16
21
  }
17
- export function WebsocketWatcher({ src }) {
18
- useLivestreamWebsocket(src);
19
- return _jsx(_Fragment, {});
22
+ function WebsocketWatcher({ src }) {
23
+ (0, websocket_1.useLivestreamWebsocket)(src);
24
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
20
25
  }
21
- export function LivestreamPoller({ children, src, }) {
26
+ function LivestreamPoller({ children, src, }) {
22
27
  // Websocket watcher is a sibling instead of a parent to avoid
23
28
  // re-rendering when the websocket does stuff
24
- return (_jsxs(_Fragment, { children: [_jsx(WebsocketWatcher, { src: src }), children] }));
29
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(WebsocketWatcher, { src: src }), children] }));
25
30
  }
@@ -1,15 +1,19 @@
1
- import { useRef } from "react";
2
- import useWebSocket from "react-use-websocket";
3
- import { useHandleWebsocketMessages } from "../livestream-store";
4
- import { useUrl } from "../streamplace-store";
5
- export function useLivestreamWebsocket(src) {
6
- const url = useUrl();
7
- const handleWebSocketMessages = useHandleWebsocketMessages();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLivestreamWebsocket = useLivestreamWebsocket;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = require("react");
6
+ const react_use_websocket_1 = tslib_1.__importDefault(require("react-use-websocket"));
7
+ const livestream_store_1 = require("../livestream-store");
8
+ const streamplace_store_1 = require("../streamplace-store");
9
+ function useLivestreamWebsocket(src) {
10
+ const url = (0, streamplace_store_1.useUrl)();
11
+ const handleWebSocketMessages = (0, livestream_store_1.useHandleWebsocketMessages)();
8
12
  let wsUrl = url.replace(/^http\:/, "ws:");
9
13
  wsUrl = wsUrl.replace(/^https\:/, "wss:");
10
- const ref = useRef([]);
11
- const handle = useRef(null);
12
- const { readyState } = useWebSocket(`${wsUrl}/api/websocket/${src}`, {
14
+ const ref = (0, react_1.useRef)([]);
15
+ const handle = (0, react_1.useRef)(null);
16
+ const { readyState } = (0, react_use_websocket_1.default)(`${wsUrl}/api/websocket/${src}`, {
13
17
  reconnectInterval: 1000,
14
18
  shouldReconnect: () => true,
15
19
  onOpen: () => {
@@ -1,21 +1,26 @@
1
- import { RichText } from "@atproto/api";
2
- import { useCallback } from "react";
3
- import { useChatProfile, useDID, useHandle } from "../streamplace-store";
4
- import { usePDSAgent } from "../streamplace-store/xrpc";
5
- import { getStoreFromContext, useLivestreamStore } from "./livestream-store";
6
- export const useReplyToMessage = () => useLivestreamStore((state) => state.replyToMessage);
7
- export const useSetReplyToMessage = () => {
8
- const store = getStoreFromContext();
9
- return useCallback((message) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reduceChat = exports.reduceChatIncremental = exports.useCreateChatMessage = exports.useSetReplyToMessage = exports.useReplyToMessage = void 0;
4
+ const api_1 = require("@atproto/api");
5
+ const react_1 = require("react");
6
+ const streamplace_store_1 = require("../streamplace-store");
7
+ const xrpc_1 = require("../streamplace-store/xrpc");
8
+ const livestream_store_1 = require("./livestream-store");
9
+ const useReplyToMessage = () => (0, livestream_store_1.useLivestreamStore)((state) => state.replyToMessage);
10
+ exports.useReplyToMessage = useReplyToMessage;
11
+ const useSetReplyToMessage = () => {
12
+ const store = (0, livestream_store_1.getStoreFromContext)();
13
+ return (0, react_1.useCallback)((message) => {
10
14
  store.setState({ replyToMessage: message });
11
15
  }, [store]);
12
16
  };
13
- export const useCreateChatMessage = () => {
14
- const pdsAgent = usePDSAgent();
15
- const store = getStoreFromContext();
16
- const userDID = useDID();
17
- const userHandle = useHandle();
18
- const chatProfile = useChatProfile();
17
+ exports.useSetReplyToMessage = useSetReplyToMessage;
18
+ const useCreateChatMessage = () => {
19
+ const pdsAgent = (0, xrpc_1.usePDSAgent)();
20
+ const store = (0, livestream_store_1.getStoreFromContext)();
21
+ const userDID = (0, streamplace_store_1.useDID)();
22
+ const userHandle = (0, streamplace_store_1.useHandle)();
23
+ const chatProfile = (0, streamplace_store_1.useChatProfile)();
19
24
  return async (msg) => {
20
25
  if (!pdsAgent || !userDID) {
21
26
  throw new Error("No PDS agent or user DID found");
@@ -25,7 +30,7 @@ export const useCreateChatMessage = () => {
25
30
  if (!streamerProfile) {
26
31
  throw new Error("Profile not found");
27
32
  }
28
- const rt = new RichText({ text: msg.text });
33
+ const rt = new api_1.RichText({ text: msg.text });
29
34
  await rt.detectFacets(pdsAgent);
30
35
  const record = {
31
36
  text: msg.text,
@@ -58,7 +63,7 @@ export const useCreateChatMessage = () => {
58
63
  indexedAt: new Date().toISOString(),
59
64
  chatProfile: chatProfile || undefined,
60
65
  };
61
- state = reduceChat(state, [localChat], []);
66
+ state = (0, exports.reduceChat)(state, [localChat], []);
62
67
  store.setState(state);
63
68
  await pdsAgent.com.atproto.repo.createRecord({
64
69
  repo: userDID,
@@ -67,6 +72,7 @@ export const useCreateChatMessage = () => {
67
72
  });
68
73
  };
69
74
  };
75
+ exports.useCreateChatMessage = useCreateChatMessage;
70
76
  const buildSortedChatList = (chatIndex, existingChatList, newMessages, removedKeys) => {
71
77
  const sortedKeys = Object.keys(chatIndex).sort((a, b) => {
72
78
  const aTime = parseInt(a.split("-")[0], 10);
@@ -93,7 +99,7 @@ const profileIsDifferent = (newProfile, oldProfile) => {
93
99
  const { red: oldRed, green: oldGreen, blue: oldBlue } = oldProfile.color;
94
100
  return newRed !== oldRed || newGreen !== oldGreen || newBlue !== oldBlue;
95
101
  };
96
- export const reduceChatIncremental = (state, newMessages, blocks) => {
102
+ const reduceChatIncremental = (state, newMessages, blocks) => {
97
103
  if (newMessages.length === 0 && blocks.length === 0) {
98
104
  return state;
99
105
  }
@@ -183,4 +189,5 @@ export const reduceChatIncremental = (state, newMessages, blocks) => {
183
189
  chat: newChatList,
184
190
  };
185
191
  };
186
- export const reduceChat = reduceChatIncremental;
192
+ exports.reduceChatIncremental = reduceChatIncremental;
193
+ exports.reduceChat = exports.reduceChatIncremental;
@@ -1,2 +1,5 @@
1
- import { createContext } from "react";
2
- export const LivestreamContext = createContext(null);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LivestreamContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.LivestreamContext = (0, react_1.createContext)(null);
@@ -1,4 +1,7 @@
1
- export * from "./chat";
2
- export * from "./context";
3
- export * from "./livestream-store";
4
- export * from "./stream-key";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./chat"), exports);
5
+ tslib_1.__exportStar(require("./context"), exports);
6
+ tslib_1.__exportStar(require("./livestream-store"), exports);
7
+ tslib_1.__exportStar(require("./stream-key"), exports);
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });