@retor/react-native 0.1.0 → 0.3.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.
- package/README.md +151 -91
- package/dist/index.d.mts +184 -33
- package/dist/index.d.ts +184 -33
- package/dist/index.js +738 -85
- package/dist/index.mjs +729 -85
- package/package.json +13 -3
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ interface RetorTag {
|
|
|
16
16
|
color?: string;
|
|
17
17
|
tagType?: string;
|
|
18
18
|
iconName?: string;
|
|
19
|
+
objectId?: string;
|
|
19
20
|
}
|
|
20
21
|
interface RetorLine {
|
|
21
22
|
_id: string;
|
|
@@ -50,12 +51,106 @@ interface ViewerHandle {
|
|
|
50
51
|
toggleAutoplay: () => void;
|
|
51
52
|
setAutoplay: (playing: boolean) => void;
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
interface NoteSubmitPayload {
|
|
56
|
+
text: string;
|
|
57
|
+
isPrivate: boolean;
|
|
58
|
+
tagId: string | null;
|
|
59
|
+
lineId: string | null;
|
|
60
|
+
position: {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
z: number;
|
|
64
|
+
} | null;
|
|
65
|
+
}
|
|
66
|
+
interface RetorBridgeContextValue {
|
|
67
|
+
project: RetorProject | null;
|
|
68
|
+
lines: RetorLine[];
|
|
69
|
+
activeLineId: string | null;
|
|
70
|
+
activeLine: RetorLine | null;
|
|
71
|
+
closestTagId: string | null;
|
|
72
|
+
progress: number;
|
|
73
|
+
isPlaying: boolean;
|
|
74
|
+
isAddNoteOpen: boolean;
|
|
75
|
+
addNoteTagId: string | null;
|
|
76
|
+
controls: ViewerHandle;
|
|
77
|
+
openAddNote: (tagId?: string) => void;
|
|
78
|
+
closeAddNote: () => void;
|
|
79
|
+
submitNote: (text: string, isPrivate?: boolean) => void;
|
|
80
|
+
onNoteSubmit?: (payload: NoteSubmitPayload) => void;
|
|
81
|
+
}
|
|
82
|
+
declare function useRetorBridge(): RetorBridgeContextValue;
|
|
83
|
+
/** Returns the array of all lines in the current project. */
|
|
84
|
+
declare function useLines(): RetorLine[];
|
|
85
|
+
/** Returns the project metadata once `init` has fired. */
|
|
86
|
+
declare function useProject(): RetorProject | null;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the line that's currently open (after the user enters a scroll path),
|
|
89
|
+
* or null when in browse mode.
|
|
90
|
+
*/
|
|
91
|
+
declare function useActiveLine(): RetorLine | null;
|
|
92
|
+
/**
|
|
93
|
+
* Returns scroll progress (0..1) and the id of the closest tag along the
|
|
94
|
+
* currently active line. Both are null when no line is open.
|
|
95
|
+
*/
|
|
96
|
+
declare function useLineProgress(): {
|
|
97
|
+
progress: number;
|
|
98
|
+
closestTagId: string | null;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Returns the autoplay state and controls.
|
|
102
|
+
*/
|
|
103
|
+
declare function useAutoplay(): {
|
|
104
|
+
isPlaying: boolean;
|
|
105
|
+
toggle: () => void;
|
|
106
|
+
play: () => void;
|
|
107
|
+
pause: () => void;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Returns the current add-note flow state and actions.
|
|
111
|
+
*/
|
|
112
|
+
declare function useAddNote(): {
|
|
113
|
+
isOpen: boolean;
|
|
114
|
+
tagId: string | null;
|
|
115
|
+
open: (tagId?: string) => void;
|
|
116
|
+
close: () => void;
|
|
117
|
+
submit: (text: string, isPrivate?: boolean) => void;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Hook for controlling a Viewer from anywhere in your tree.
|
|
122
|
+
*
|
|
123
|
+
* Default usage (single viewer):
|
|
124
|
+
* ```tsx
|
|
125
|
+
* const { openLine, exitLine } = useViewer();
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* Multiple viewers:
|
|
129
|
+
* ```tsx
|
|
130
|
+
* <Viewer id="left" projectId="..." />
|
|
131
|
+
* const left = useViewer("left");
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* With a ref:
|
|
135
|
+
* ```tsx
|
|
136
|
+
* const ref = useRef<ViewerHandle>(null);
|
|
137
|
+
* const { openLine } = useViewer(ref);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare function useViewer(target?: string | React.RefObject<ViewerHandle | null>): ViewerHandle;
|
|
141
|
+
interface NotesProps {
|
|
142
|
+
/** Array of notes (same shape as RetorTag) to push into the 3D scene. */
|
|
143
|
+
notes: RetorTag[];
|
|
144
|
+
}
|
|
145
|
+
declare function Notes(_props: NotesProps): React.ReactElement | null;
|
|
53
146
|
interface ViewerProps {
|
|
54
147
|
projectId: string;
|
|
55
148
|
/** Identifier for this viewer instance. Used by `useViewer(id)`. Defaults to "default". */
|
|
56
149
|
id?: string;
|
|
57
150
|
/** Base URL where Retor is hosted. Defaults to https://retor.app */
|
|
58
151
|
baseUrl?: string;
|
|
152
|
+
/** Called when a note is submitted via `<AddNoteSheet>`. Receives the text + position. */
|
|
153
|
+
onNoteSubmit?: (note: NoteSubmitPayload) => void;
|
|
59
154
|
onInit?: (data: InitPayload) => void;
|
|
60
155
|
onLineOpen?: (data: {
|
|
61
156
|
lineId: string;
|
|
@@ -66,48 +161,104 @@ interface ViewerProps {
|
|
|
66
161
|
style?: StyleProp<ViewStyle>;
|
|
67
162
|
children?: React.ReactNode;
|
|
68
163
|
}
|
|
164
|
+
declare const Viewer: React.ForwardRefExoticComponent<ViewerProps & React.RefAttributes<ViewerHandle>>;
|
|
165
|
+
|
|
166
|
+
interface HudProps {
|
|
167
|
+
children: React.ReactNode;
|
|
168
|
+
}
|
|
69
169
|
/**
|
|
70
|
-
*
|
|
170
|
+
* Sets up the bottom-sheet provider tree for the SDK's UI components
|
|
171
|
+
* (`<ProjectSheet>`, `<LineDetailSheet>`, `<AddNoteSheet>`).
|
|
71
172
|
*
|
|
72
|
-
*
|
|
73
|
-
* ```tsx
|
|
74
|
-
* <Viewer projectId="..." /> // id defaults to "default"
|
|
75
|
-
* const { openLine, exitLine } = useViewer();
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* With an explicit ID (multiple viewers on one screen):
|
|
79
|
-
* ```tsx
|
|
80
|
-
* <Viewer id="left" projectId="..." />
|
|
81
|
-
* <Viewer id="right" projectId="..." />
|
|
82
|
-
* const left = useViewer("left");
|
|
83
|
-
* left.openLine("...");
|
|
84
|
-
* ```
|
|
173
|
+
* Place inside `<Viewer>` so the sheets can read scene state from the bridge:
|
|
85
174
|
*
|
|
86
|
-
* With a ref (if you prefer imperative style):
|
|
87
175
|
* ```tsx
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
176
|
+
* <Viewer projectId="...">
|
|
177
|
+
* <Hud>
|
|
178
|
+
* <ProjectSheet />
|
|
179
|
+
* <LineDetailSheet />
|
|
180
|
+
* <AddNoteSheet />
|
|
181
|
+
* </Hud>
|
|
182
|
+
* </Viewer>
|
|
91
183
|
* ```
|
|
92
184
|
*/
|
|
93
|
-
declare function
|
|
185
|
+
declare function Hud({ children }: HudProps): React.JSX.Element;
|
|
186
|
+
|
|
187
|
+
interface ProjectSheetProps {
|
|
188
|
+
/** Snap points. Defaults to ["35%", "85%"]. */
|
|
189
|
+
snapPoints?: (string | number)[];
|
|
190
|
+
/** Override the default header (project name + description + arrow button). */
|
|
191
|
+
renderHeader?: (project: {
|
|
192
|
+
name?: string;
|
|
193
|
+
description?: string;
|
|
194
|
+
}) => React.ReactNode;
|
|
195
|
+
/** Children to render inside. Defaults to a built-in `<LinesCarousel>`. */
|
|
196
|
+
children?: React.ReactNode;
|
|
197
|
+
}
|
|
94
198
|
/**
|
|
95
|
-
*
|
|
96
|
-
* (info card, tag list, autoplay controls). Without it, the viewer runs in
|
|
97
|
-
* vanilla mode — you build your own UI around the 3D scene using the props.
|
|
199
|
+
* Browse-mode bottom sheet — auto-presents whenever no line is open.
|
|
98
200
|
*/
|
|
99
|
-
declare function
|
|
100
|
-
interface
|
|
101
|
-
|
|
102
|
-
|
|
201
|
+
declare function ProjectSheet({ snapPoints, renderHeader, children }: ProjectSheetProps): React.JSX.Element;
|
|
202
|
+
interface LinesCarouselProps {
|
|
203
|
+
children: (line: RetorLine, index: number) => React.ReactNode;
|
|
204
|
+
gap?: number;
|
|
205
|
+
paddingHorizontal?: number;
|
|
206
|
+
}
|
|
207
|
+
declare function LinesCarousel({ children, gap, paddingHorizontal }: LinesCarouselProps): React.JSX.Element | null;
|
|
208
|
+
|
|
209
|
+
interface LineDetailSheetProps {
|
|
210
|
+
/** Snap points. Defaults to ["35%", "85%"]. */
|
|
211
|
+
snapPoints?: (string | number)[];
|
|
212
|
+
/** Override the header. */
|
|
213
|
+
renderHeader?: (line: RetorLine) => React.ReactNode;
|
|
214
|
+
/** Custom content (typically a `<LineTagList>`). */
|
|
215
|
+
children?: React.ReactNode;
|
|
103
216
|
}
|
|
104
217
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* the scene and tag lists. Persistence is handled entirely by your app:
|
|
108
|
-
* re-render with an updated `notes` array to sync changes.
|
|
218
|
+
* Sheet shown when a line is open. Includes a default header with the
|
|
219
|
+
* autoplay button + minimize arrow, the tag list, and a Done footer.
|
|
109
220
|
*/
|
|
110
|
-
declare function
|
|
111
|
-
|
|
221
|
+
declare function LineDetailSheet({ snapPoints, renderHeader, children }: LineDetailSheetProps): React.JSX.Element;
|
|
222
|
+
interface LineTagListProps {
|
|
223
|
+
children: (tag: RetorTag, isActive: boolean) => React.ReactNode;
|
|
224
|
+
}
|
|
225
|
+
declare function LineTagList({ children }: LineTagListProps): React.JSX.Element | null;
|
|
226
|
+
|
|
227
|
+
interface AddNoteSheetProps {
|
|
228
|
+
/** Snap points. Defaults to ["50%"]. */
|
|
229
|
+
snapPoints?: (string | number)[];
|
|
230
|
+
/** Max characters allowed. Defaults to 280. */
|
|
231
|
+
maxLength?: number;
|
|
232
|
+
/** Placeholder text. */
|
|
233
|
+
placeholder?: string;
|
|
234
|
+
/** Override the entire form. Receives helpers + state. */
|
|
235
|
+
renderForm?: (api: AddNoteFormApi) => React.ReactNode;
|
|
236
|
+
}
|
|
237
|
+
interface AddNoteFormApi {
|
|
238
|
+
text: string;
|
|
239
|
+
setText: (v: string) => void;
|
|
240
|
+
isPrivate: boolean;
|
|
241
|
+
setPrivate: (v: boolean) => void;
|
|
242
|
+
submit: () => void;
|
|
243
|
+
close: () => void;
|
|
244
|
+
maxLength: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Sheet for adding a note. Auto-presents when `useAddNote().open()` is called.
|
|
248
|
+
* On submit, fires `onNoteSubmit` on the parent `<Viewer>` with the text + position.
|
|
249
|
+
*/
|
|
250
|
+
declare function AddNoteSheet({ snapPoints, maxLength, placeholder, renderForm, }: AddNoteSheetProps): React.JSX.Element;
|
|
251
|
+
|
|
252
|
+
interface CoverPhotoProps {
|
|
253
|
+
projectId: string;
|
|
254
|
+
/** Base URL where Retor is hosted. Defaults to https://retor.app */
|
|
255
|
+
baseUrl?: string;
|
|
256
|
+
style?: StyleProp<ViewStyle>;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Renders a Retor project's start view as a static cover image.
|
|
260
|
+
* No 3D rendering, no bridge — use as a thumbnail or hero.
|
|
261
|
+
*/
|
|
262
|
+
declare function CoverPhoto({ projectId, baseUrl, style }: CoverPhotoProps): React.JSX.Element;
|
|
112
263
|
|
|
113
|
-
export { Hud, type InitPayload, type LineProgressPayload, Notes, type NotesProps, type RetorLine, type RetorProject, type RetorTag, Viewer, type ViewerHandle, type ViewerProps, useViewer };
|
|
264
|
+
export { type AddNoteFormApi, AddNoteSheet, type AddNoteSheetProps, CoverPhoto, type CoverPhotoProps, Hud, type HudProps, type InitPayload, LineDetailSheet, type LineDetailSheetProps, type LineProgressPayload, LineTagList, type LineTagListProps, LinesCarousel, type LinesCarouselProps, type NoteSubmitPayload, Notes, type NotesProps, ProjectSheet, type ProjectSheetProps, type RetorBridgeContextValue, type RetorLine, type RetorProject, type RetorTag, Viewer, type ViewerHandle, type ViewerProps, useActiveLine, useAddNote, useAutoplay, useLineProgress, useLines, useProject, useRetorBridge, useViewer };
|