@streamplace/components 0.0.1 → 0.7.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.
Files changed (169) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +35 -0
  3. package/dist/components/chat/chat-box.js +109 -0
  4. package/dist/components/chat/chat-message.js +76 -0
  5. package/dist/components/chat/chat.js +56 -0
  6. package/dist/components/chat/mention-suggestions.js +39 -0
  7. package/dist/components/chat/mod-view.js +33 -0
  8. package/dist/components/mobile-player/fullscreen.js +69 -0
  9. package/dist/components/mobile-player/fullscreen.native.js +151 -0
  10. package/dist/components/mobile-player/player.js +103 -0
  11. package/dist/components/mobile-player/props.js +1 -0
  12. package/dist/components/mobile-player/shared.js +51 -0
  13. package/dist/components/mobile-player/ui/countdown.js +79 -0
  14. package/dist/components/mobile-player/ui/index.js +5 -0
  15. package/dist/components/mobile-player/ui/input.js +38 -0
  16. package/dist/components/mobile-player/ui/metrics.js +40 -0
  17. package/dist/components/mobile-player/ui/streamer-context-menu.js +4 -0
  18. package/dist/components/mobile-player/ui/viewer-context-menu.js +20 -0
  19. package/dist/components/mobile-player/use-webrtc.js +232 -0
  20. package/dist/components/mobile-player/video.js +375 -0
  21. package/dist/components/mobile-player/video.native.js +238 -0
  22. package/dist/components/mobile-player/webrtc-diagnostics.js +106 -0
  23. package/dist/components/mobile-player/webrtc-primitives.js +25 -0
  24. package/dist/components/mobile-player/webrtc-primitives.native.js +1 -0
  25. package/dist/components/ui/button.js +220 -0
  26. package/dist/components/ui/dialog.js +203 -0
  27. package/dist/components/ui/dropdown.js +148 -0
  28. package/dist/components/ui/icons.js +22 -0
  29. package/dist/components/ui/index.js +22 -0
  30. package/dist/components/ui/input.js +202 -0
  31. package/dist/components/ui/loader.js +7 -0
  32. package/dist/components/ui/primitives/button.js +121 -0
  33. package/dist/components/ui/primitives/input.js +202 -0
  34. package/dist/components/ui/primitives/modal.js +203 -0
  35. package/dist/components/ui/primitives/text.js +286 -0
  36. package/dist/components/ui/resizeable.js +101 -0
  37. package/dist/components/ui/text.js +175 -0
  38. package/dist/components/ui/textarea.js +17 -0
  39. package/dist/components/ui/toast.js +129 -0
  40. package/dist/components/ui/view.js +250 -0
  41. package/dist/hooks/index.js +9 -0
  42. package/dist/hooks/useAvatars.js +32 -0
  43. package/dist/hooks/useCameraToggle.js +9 -0
  44. package/dist/hooks/useKeyboard.js +33 -0
  45. package/dist/hooks/useKeyboardSlide.js +11 -0
  46. package/dist/hooks/useLivestreamInfo.js +62 -0
  47. package/dist/hooks/useOuterAndInnerDimensions.js +27 -0
  48. package/dist/hooks/usePlayerDimensions.js +19 -0
  49. package/dist/hooks/useSegmentTiming.js +62 -0
  50. package/dist/index.js +16 -0
  51. package/dist/lib/facet.js +88 -0
  52. package/dist/lib/theme/atoms.js +620 -0
  53. package/dist/lib/theme/atoms.types.js +5 -0
  54. package/dist/lib/theme/index.js +9 -0
  55. package/dist/lib/theme/theme.js +248 -0
  56. package/dist/lib/theme/tokens.js +383 -0
  57. package/dist/lib/utils.js +94 -0
  58. package/dist/livestream-provider/index.js +25 -0
  59. package/dist/livestream-provider/websocket.js +41 -0
  60. package/dist/livestream-store/chat.js +186 -0
  61. package/dist/livestream-store/context.js +2 -0
  62. package/dist/livestream-store/index.js +4 -0
  63. package/dist/livestream-store/livestream-state.js +1 -0
  64. package/dist/livestream-store/livestream-store.js +42 -0
  65. package/dist/livestream-store/stream-key.js +115 -0
  66. package/dist/livestream-store/websocket-consumer.js +55 -0
  67. package/dist/player-store/context.js +2 -0
  68. package/dist/player-store/index.js +6 -0
  69. package/dist/player-store/player-provider.js +52 -0
  70. package/dist/player-store/player-state.js +22 -0
  71. package/dist/player-store/player-store.js +159 -0
  72. package/dist/player-store/single-player-provider.js +109 -0
  73. package/dist/streamplace-provider/context.js +2 -0
  74. package/dist/streamplace-provider/index.js +16 -0
  75. package/dist/streamplace-provider/poller.js +46 -0
  76. package/dist/streamplace-provider/xrpc.js +0 -0
  77. package/dist/streamplace-store/block.js +23 -0
  78. package/dist/streamplace-store/index.js +3 -0
  79. package/dist/streamplace-store/stream.js +193 -0
  80. package/dist/streamplace-store/streamplace-store.js +37 -0
  81. package/dist/streamplace-store/user.js +47 -0
  82. package/dist/streamplace-store/xrpc.js +12 -0
  83. package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
  84. package/node-compile-cache/v22.15.0-x64-efe9a9df-0/56540125 +0 -0
  85. package/node-compile-cache/v22.15.0-x64-efe9a9df-0/67b1eb60 +0 -0
  86. package/node-compile-cache/v22.15.0-x64-efe9a9df-0/7c275f90 +0 -0
  87. package/package.json +50 -8
  88. package/src/components/chat/chat-box.tsx +195 -0
  89. package/src/components/chat/chat-message.tsx +192 -0
  90. package/src/components/chat/chat.tsx +128 -0
  91. package/src/components/chat/mention-suggestions.tsx +71 -0
  92. package/src/components/chat/mod-view.tsx +118 -0
  93. package/src/components/mobile-player/fullscreen.native.tsx +193 -0
  94. package/src/components/mobile-player/fullscreen.tsx +79 -0
  95. package/src/components/mobile-player/player.tsx +134 -0
  96. package/src/components/mobile-player/props.tsx +11 -0
  97. package/src/components/mobile-player/shared.tsx +56 -0
  98. package/src/components/mobile-player/ui/countdown.tsx +119 -0
  99. package/src/components/mobile-player/ui/index.ts +5 -0
  100. package/src/components/mobile-player/ui/input.tsx +85 -0
  101. package/src/components/mobile-player/ui/metrics.tsx +69 -0
  102. package/src/components/mobile-player/ui/streamer-context-menu.tsx +3 -0
  103. package/src/components/mobile-player/ui/viewer-context-menu.tsx +70 -0
  104. package/src/components/mobile-player/use-webrtc.tsx +282 -0
  105. package/src/components/mobile-player/video.native.tsx +360 -0
  106. package/src/components/mobile-player/video.tsx +557 -0
  107. package/src/components/mobile-player/webrtc-diagnostics.tsx +149 -0
  108. package/src/components/mobile-player/webrtc-primitives.native.tsx +6 -0
  109. package/src/components/mobile-player/webrtc-primitives.tsx +33 -0
  110. package/src/components/ui/button.tsx +309 -0
  111. package/src/components/ui/dialog.tsx +376 -0
  112. package/src/components/ui/dropdown.tsx +399 -0
  113. package/src/components/ui/icons.tsx +50 -0
  114. package/src/components/ui/index.ts +33 -0
  115. package/src/components/ui/input.tsx +350 -0
  116. package/src/components/ui/loader.tsx +9 -0
  117. package/src/components/ui/primitives/button.tsx +292 -0
  118. package/src/components/ui/primitives/input.tsx +422 -0
  119. package/src/components/ui/primitives/modal.tsx +421 -0
  120. package/src/components/ui/primitives/text.tsx +499 -0
  121. package/src/components/ui/resizeable.tsx +169 -0
  122. package/src/components/ui/text.tsx +330 -0
  123. package/src/components/ui/textarea.tsx +34 -0
  124. package/src/components/ui/toast.tsx +203 -0
  125. package/src/components/ui/view.tsx +344 -0
  126. package/src/hooks/index.ts +9 -0
  127. package/src/hooks/useAvatars.tsx +44 -0
  128. package/src/hooks/useCameraToggle.ts +12 -0
  129. package/src/hooks/useKeyboard.tsx +41 -0
  130. package/src/hooks/useKeyboardSlide.ts +12 -0
  131. package/src/hooks/useLivestreamInfo.ts +67 -0
  132. package/src/hooks/useOuterAndInnerDimensions.tsx +32 -0
  133. package/src/hooks/usePlayerDimensions.ts +23 -0
  134. package/src/hooks/useSegmentTiming.tsx +88 -0
  135. package/src/index.tsx +27 -0
  136. package/src/lib/facet.ts +131 -0
  137. package/src/lib/theme/atoms.ts +760 -0
  138. package/src/lib/theme/atoms.types.ts +258 -0
  139. package/src/lib/theme/index.ts +48 -0
  140. package/src/lib/theme/theme.tsx +436 -0
  141. package/src/lib/theme/tokens.ts +409 -0
  142. package/src/lib/utils.ts +132 -0
  143. package/src/livestream-provider/index.tsx +48 -0
  144. package/src/livestream-provider/websocket.tsx +47 -0
  145. package/src/livestream-store/chat.tsx +261 -0
  146. package/src/livestream-store/context.tsx +10 -0
  147. package/src/livestream-store/index.tsx +4 -0
  148. package/src/livestream-store/livestream-state.tsx +21 -0
  149. package/src/livestream-store/livestream-store.tsx +59 -0
  150. package/src/livestream-store/stream-key.tsx +124 -0
  151. package/src/livestream-store/websocket-consumer.tsx +62 -0
  152. package/src/player-store/context.tsx +11 -0
  153. package/src/player-store/index.tsx +6 -0
  154. package/src/player-store/player-provider.tsx +89 -0
  155. package/src/player-store/player-state.tsx +187 -0
  156. package/src/player-store/player-store.tsx +239 -0
  157. package/src/player-store/single-player-provider.tsx +181 -0
  158. package/src/streamplace-provider/context.tsx +10 -0
  159. package/src/streamplace-provider/index.tsx +32 -0
  160. package/src/streamplace-provider/poller.tsx +55 -0
  161. package/src/streamplace-provider/xrpc.tsx +0 -0
  162. package/src/streamplace-store/block.tsx +29 -0
  163. package/src/streamplace-store/index.tsx +3 -0
  164. package/src/streamplace-store/stream.tsx +262 -0
  165. package/src/streamplace-store/streamplace-store.tsx +89 -0
  166. package/src/streamplace-store/user.tsx +57 -0
  167. package/src/streamplace-store/xrpc.tsx +15 -0
  168. package/tsconfig.json +9 -0
  169. package/tsconfig.tsbuildinfo +1 -0
package/src/index.tsx ADDED
@@ -0,0 +1,27 @@
1
+ // barrel file :)
2
+ export * from "./livestream-provider";
3
+ export * from "./livestream-store";
4
+ export * from "./player-store";
5
+ export * from "./streamplace-provider";
6
+ export * from "./streamplace-store";
7
+
8
+ export {
9
+ PlayerProvider,
10
+ withPlayerProvider,
11
+ } from "./player-store/player-provider";
12
+ export { usePlayerContext } from "./player-store/player-store";
13
+
14
+ export { Player, PlayerUI } from "./components/mobile-player/player";
15
+ export { PlayerProps } from "./components/mobile-player/props";
16
+
17
+ export * as ui from "./components/ui";
18
+
19
+ export * from "./components/ui";
20
+
21
+ export * as theme from "./lib/theme";
22
+ export * as atoms from "./lib/theme/atoms";
23
+
24
+ export * from "./hooks";
25
+
26
+ export * from "./components/chat/chat";
27
+ export * from "./components/chat/chat-box";
@@ -0,0 +1,131 @@
1
+ // Taken from ATcute's richtext-segmenter
2
+ // https://github.com/mary-ext/atcute/blob/trunk/packages/bluesky/richtext-segmenter/lib/index.ts
3
+ // repoed b/c we need to import types from @atproto/api not @atcute/bsky
4
+ import { Main } from "@atproto/api/dist/client/types/app/bsky/richtext/facet";
5
+
6
+ type UnwrapArray<T> = T extends (infer V)[] ? V : never;
7
+
8
+ export type Facet = Main;
9
+ export type FacetFeature = UnwrapArray<Facet["features"]>;
10
+
11
+ export interface RichtextSegment {
12
+ text: string;
13
+ features: FacetFeature[] | undefined;
14
+ }
15
+
16
+ const segment = (
17
+ text: string,
18
+ features: FacetFeature[] | undefined,
19
+ ): RichtextSegment => {
20
+ return { text, features: text.length > 0 ? features : undefined };
21
+ };
22
+
23
+ export const segmentize = (
24
+ text: string,
25
+ facets: Facet[] | undefined,
26
+ ): RichtextSegment[] => {
27
+ if (facets === undefined || facets.length === 0) {
28
+ return [segment(text, undefined)];
29
+ }
30
+
31
+ const segments: RichtextSegment[] = [];
32
+ const utf16Length = text.length;
33
+ let utf16Cursor = 0;
34
+ let utf8Cursor = 0;
35
+
36
+ const advanceCursor = (startUtf16: number, endUtf8: number): number => {
37
+ let curs = startUtf16;
38
+
39
+ // Fast-path for entirely ASCII text
40
+ const isLikelyAsciiText = text.charCodeAt(curs) < 0x80;
41
+ if (isLikelyAsciiText) {
42
+ curs += 1;
43
+ utf8Cursor += 1;
44
+
45
+ // SIMD-like batch processing
46
+ while (utf8Cursor + 8 <= endUtf8 && curs + 8 <= utf16Length) {
47
+ const char1 = text.charCodeAt(curs);
48
+ const char2 = text.charCodeAt(curs + 1);
49
+ const char3 = text.charCodeAt(curs + 2);
50
+ const char4 = text.charCodeAt(curs + 3);
51
+ const char5 = text.charCodeAt(curs + 4);
52
+ const char6 = text.charCodeAt(curs + 5);
53
+ const char7 = text.charCodeAt(curs + 6);
54
+ const char8 = text.charCodeAt(curs + 7);
55
+
56
+ if (
57
+ (char1 | char2 | char3 | char4 | char5 | char6 | char7 | char8) <
58
+ 0x80
59
+ ) {
60
+ curs += 8;
61
+ utf8Cursor += 8;
62
+ continue;
63
+ }
64
+
65
+ break;
66
+ }
67
+ }
68
+
69
+ // Process remaining characters individually
70
+ while (utf8Cursor < endUtf8 && curs < utf16Length) {
71
+ const code = text.charCodeAt(curs);
72
+
73
+ if (code < 0x80) {
74
+ curs += 1;
75
+ utf8Cursor += 1;
76
+ } else if (code < 0x800) {
77
+ curs += 1;
78
+ utf8Cursor += 2;
79
+ } else if (code < 0xd800 || code > 0xdbff) {
80
+ curs += 1;
81
+ utf8Cursor += 3;
82
+ } else {
83
+ curs += 2;
84
+ utf8Cursor += 4;
85
+ }
86
+ }
87
+
88
+ return curs;
89
+ };
90
+
91
+ // Process facets
92
+ for (let idx = 0, len = facets.length; idx < len; idx++) {
93
+ const facet = facets[idx];
94
+
95
+ const { byteStart, byteEnd } = facet.index;
96
+ const features = facet.features;
97
+
98
+ if (byteStart > byteEnd || features.length === 0) {
99
+ continue;
100
+ }
101
+
102
+ if (utf8Cursor < byteStart) {
103
+ const nextUtf16Cursor = advanceCursor(utf16Cursor, byteStart);
104
+ if (nextUtf16Cursor > utf16Cursor) {
105
+ segments.push(
106
+ segment(text.slice(utf16Cursor, nextUtf16Cursor), undefined),
107
+ );
108
+ }
109
+
110
+ utf16Cursor = nextUtf16Cursor;
111
+ }
112
+
113
+ {
114
+ const nextUtf16Cursor = advanceCursor(utf16Cursor, byteEnd);
115
+ if (nextUtf16Cursor > utf16Cursor) {
116
+ segments.push(
117
+ segment(text.slice(utf16Cursor, nextUtf16Cursor), features),
118
+ );
119
+ }
120
+
121
+ utf16Cursor = nextUtf16Cursor;
122
+ }
123
+ }
124
+
125
+ // Handle remaining text
126
+ if (utf16Cursor < utf16Length) {
127
+ segments.push(segment(text.slice(utf16Cursor), undefined));
128
+ }
129
+
130
+ return segments;
131
+ };