@retor/react-native 0.4.6 → 0.5.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/dist/index.d.mts CHANGED
@@ -25,6 +25,13 @@ interface RetorTag {
25
25
  authorName?: string;
26
26
  /** ID of the user who created this note. Compared against `Viewer.userId` to show the delete button. */
27
27
  userId?: string;
28
+ /** Absolute elevation in meters (above the GPS reference's elevation datum, typically MSL).
29
+ * Null if the project isn't georeferenced or has too few reference points (<4 non-coplanar). */
30
+ elevationAboveSeaLevel?: number | null;
31
+ /** Cumulative distance along the parent line from start to this tag, in meters.
32
+ * Uses the same arc-length lookup as `LineProgressPayload.distanceFromStart`, so the
33
+ * values are directly comparable. Null if the project isn't georeferenced. */
34
+ distanceFromStart?: number | null;
28
35
  }
29
36
  interface RetorLine {
30
37
  _id: string;
@@ -62,6 +69,25 @@ interface LineProgressPayload {
62
69
  /** Distance along the line from the start.
63
70
  * In meters if GPS is configured on the project, else project-local units. */
64
71
  distanceFromStart?: number | null;
72
+ /** Pitch of the line tangent above the ground plane at the current point, in degrees.
73
+ * Positive = uphill, negative = downhill. Null if the curve isn't ready. */
74
+ pitchDeg?: number | null;
75
+ /** Absolute elevation in meters at the current point. Requires a georeferenced
76
+ * project (coord tags with lat/lon/elevation); null otherwise. */
77
+ elevationM?: number | null;
78
+ /** Cursor latitude in degrees. Null if not georeferenced. */
79
+ lat?: number | null;
80
+ /** Cursor longitude in degrees. Null if not georeferenced. */
81
+ lon?: number | null;
82
+ /** Elevation difference (meters) between the cursor and the line's first control tag.
83
+ * Positive = above start, negative = below. Null if not georeferenced. */
84
+ elevationGainM?: number | null;
85
+ /** Length in meters of the split-section the cursor is currently inside. */
86
+ sectionLengthM?: number | null;
87
+ /** 1-based index of the current split-section (1 if the line has no splits). */
88
+ sectionIndex?: number | null;
89
+ /** 0..1 progress of the cursor within the current section. */
90
+ sectionProgress?: number | null;
65
91
  }
66
92
  interface ViewerHandle {
67
93
  openLine: (lineId: string) => void;
@@ -142,6 +168,14 @@ declare function useLineProgress(): {
142
168
  z: number;
143
169
  } | null;
144
170
  distanceFromStart: number | null;
171
+ pitchDeg: number | null;
172
+ elevationM: number | null;
173
+ lat: number | null;
174
+ lon: number | null;
175
+ elevationGainM: number | null;
176
+ sectionLengthM: number | null;
177
+ sectionIndex: number | null;
178
+ sectionProgress: number | null;
145
179
  };
146
180
  /**
147
181
  * Returns the autoplay state and controls.
package/dist/index.d.ts CHANGED
@@ -25,6 +25,13 @@ interface RetorTag {
25
25
  authorName?: string;
26
26
  /** ID of the user who created this note. Compared against `Viewer.userId` to show the delete button. */
27
27
  userId?: string;
28
+ /** Absolute elevation in meters (above the GPS reference's elevation datum, typically MSL).
29
+ * Null if the project isn't georeferenced or has too few reference points (<4 non-coplanar). */
30
+ elevationAboveSeaLevel?: number | null;
31
+ /** Cumulative distance along the parent line from start to this tag, in meters.
32
+ * Uses the same arc-length lookup as `LineProgressPayload.distanceFromStart`, so the
33
+ * values are directly comparable. Null if the project isn't georeferenced. */
34
+ distanceFromStart?: number | null;
28
35
  }
29
36
  interface RetorLine {
30
37
  _id: string;
@@ -62,6 +69,25 @@ interface LineProgressPayload {
62
69
  /** Distance along the line from the start.
63
70
  * In meters if GPS is configured on the project, else project-local units. */
64
71
  distanceFromStart?: number | null;
72
+ /** Pitch of the line tangent above the ground plane at the current point, in degrees.
73
+ * Positive = uphill, negative = downhill. Null if the curve isn't ready. */
74
+ pitchDeg?: number | null;
75
+ /** Absolute elevation in meters at the current point. Requires a georeferenced
76
+ * project (coord tags with lat/lon/elevation); null otherwise. */
77
+ elevationM?: number | null;
78
+ /** Cursor latitude in degrees. Null if not georeferenced. */
79
+ lat?: number | null;
80
+ /** Cursor longitude in degrees. Null if not georeferenced. */
81
+ lon?: number | null;
82
+ /** Elevation difference (meters) between the cursor and the line's first control tag.
83
+ * Positive = above start, negative = below. Null if not georeferenced. */
84
+ elevationGainM?: number | null;
85
+ /** Length in meters of the split-section the cursor is currently inside. */
86
+ sectionLengthM?: number | null;
87
+ /** 1-based index of the current split-section (1 if the line has no splits). */
88
+ sectionIndex?: number | null;
89
+ /** 0..1 progress of the cursor within the current section. */
90
+ sectionProgress?: number | null;
65
91
  }
66
92
  interface ViewerHandle {
67
93
  openLine: (lineId: string) => void;
@@ -142,6 +168,14 @@ declare function useLineProgress(): {
142
168
  z: number;
143
169
  } | null;
144
170
  distanceFromStart: number | null;
171
+ pitchDeg: number | null;
172
+ elevationM: number | null;
173
+ lat: number | null;
174
+ lon: number | null;
175
+ elevationGainM: number | null;
176
+ sectionLengthM: number | null;
177
+ sectionIndex: number | null;
178
+ sectionProgress: number | null;
145
179
  };
146
180
  /**
147
181
  * Returns the autoplay state and controls.
package/dist/index.js CHANGED
@@ -59,6 +59,14 @@ var RetorProgressContext = (0, import_react.createContext)({
59
59
  closestTagId: null,
60
60
  targetPosition: null,
61
61
  distanceFromStart: null,
62
+ pitchDeg: null,
63
+ elevationM: null,
64
+ lat: null,
65
+ lon: null,
66
+ elevationGainM: null,
67
+ sectionLengthM: null,
68
+ sectionIndex: null,
69
+ sectionProgress: null,
62
70
  isPlaying: false
63
71
  });
64
72
  function noop() {
@@ -103,10 +111,49 @@ function useActiveLine() {
103
111
  return useRetorBridge().activeLine;
104
112
  }
105
113
  function useLineProgress() {
106
- const { progress, closestTagId, targetPosition, distanceFromStart } = useRetorProgress();
114
+ const {
115
+ progress,
116
+ closestTagId,
117
+ targetPosition,
118
+ distanceFromStart,
119
+ pitchDeg,
120
+ elevationM,
121
+ lat,
122
+ lon,
123
+ elevationGainM,
124
+ sectionLengthM,
125
+ sectionIndex,
126
+ sectionProgress
127
+ } = useRetorProgress();
107
128
  return (0, import_react.useMemo)(
108
- () => ({ progress, closestTagId, targetPosition, distanceFromStart }),
109
- [progress, closestTagId, targetPosition, distanceFromStart]
129
+ () => ({
130
+ progress,
131
+ closestTagId,
132
+ targetPosition,
133
+ distanceFromStart,
134
+ pitchDeg,
135
+ elevationM,
136
+ lat,
137
+ lon,
138
+ elevationGainM,
139
+ sectionLengthM,
140
+ sectionIndex,
141
+ sectionProgress
142
+ }),
143
+ [
144
+ progress,
145
+ closestTagId,
146
+ targetPosition,
147
+ distanceFromStart,
148
+ pitchDeg,
149
+ elevationM,
150
+ lat,
151
+ lon,
152
+ elevationGainM,
153
+ sectionLengthM,
154
+ sectionIndex,
155
+ sectionProgress
156
+ ]
110
157
  );
111
158
  }
112
159
  function useAutoplay() {
@@ -218,6 +265,14 @@ var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "d
218
265
  const [progress, setProgress] = (0, import_react2.useState)(0);
219
266
  const [targetPosition, setTargetPosition] = (0, import_react2.useState)(null);
220
267
  const [distanceFromStart, setDistanceFromStart] = (0, import_react2.useState)(null);
268
+ const [pitchDeg, setPitchDeg] = (0, import_react2.useState)(null);
269
+ const [elevationM, setElevationM] = (0, import_react2.useState)(null);
270
+ const [lat, setLat] = (0, import_react2.useState)(null);
271
+ const [lon, setLon] = (0, import_react2.useState)(null);
272
+ const [elevationGainM, setElevationGainM] = (0, import_react2.useState)(null);
273
+ const [sectionLengthM, setSectionLengthM] = (0, import_react2.useState)(null);
274
+ const [sectionIndex, setSectionIndex] = (0, import_react2.useState)(null);
275
+ const [sectionProgress, setSectionProgress] = (0, import_react2.useState)(null);
221
276
  const [isPlaying, setIsPlaying] = (0, import_react2.useState)(false);
222
277
  const [isAddNoteOpen, setIsAddNoteOpen] = (0, import_react2.useState)(false);
223
278
  const [addNoteTagId, setAddNoteTagId] = (0, import_react2.useState)(null);
@@ -366,6 +421,14 @@ var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "d
366
421
  setClosestTagId(payload.closestTagId);
367
422
  setTargetPosition(payload.targetPosition ?? null);
368
423
  setDistanceFromStart(payload.distanceFromStart ?? null);
424
+ setPitchDeg(payload.pitchDeg ?? null);
425
+ setElevationM(payload.elevationM ?? null);
426
+ setLat(payload.lat ?? null);
427
+ setLon(payload.lon ?? null);
428
+ setElevationGainM(payload.elevationGainM ?? null);
429
+ setSectionLengthM(payload.sectionLengthM ?? null);
430
+ setSectionIndex(payload.sectionIndex ?? null);
431
+ setSectionProgress(payload.sectionProgress ?? null);
369
432
  onLineProgress?.(payload);
370
433
  break;
371
434
  }
@@ -413,8 +476,36 @@ var Viewer = (0, import_react2.forwardRef)(function Viewer2({ projectId, id = "d
413
476
  [project, lines, activeLineId, activeLine, lineNotes, externalNotes, userId, isAddNoteOpen, addNoteTagId, controls, openAddNote, closeAddNote, submitNote, deleteNote]
414
477
  );
415
478
  const progressCtx = (0, import_react2.useMemo)(
416
- () => ({ progress, closestTagId, targetPosition, distanceFromStart, isPlaying }),
417
- [progress, closestTagId, targetPosition, distanceFromStart, isPlaying]
479
+ () => ({
480
+ progress,
481
+ closestTagId,
482
+ targetPosition,
483
+ distanceFromStart,
484
+ pitchDeg,
485
+ elevationM,
486
+ lat,
487
+ lon,
488
+ elevationGainM,
489
+ sectionLengthM,
490
+ sectionIndex,
491
+ sectionProgress,
492
+ isPlaying
493
+ }),
494
+ [
495
+ progress,
496
+ closestTagId,
497
+ targetPosition,
498
+ distanceFromStart,
499
+ pitchDeg,
500
+ elevationM,
501
+ lat,
502
+ lon,
503
+ elevationGainM,
504
+ sectionLengthM,
505
+ sectionIndex,
506
+ sectionProgress,
507
+ isPlaying
508
+ ]
418
509
  );
419
510
  return /* @__PURE__ */ import_react2.default.createElement(RetorBridgeProvider, { value: ctxValue }, /* @__PURE__ */ import_react2.default.createElement(RetorProgressProvider, { value: progressCtx }, /* @__PURE__ */ import_react2.default.createElement(import_react_native.View, { style: [styles.root, style] }, /* @__PURE__ */ import_react2.default.createElement(
420
511
  import_react_native_webview.WebView,
package/dist/index.mjs CHANGED
@@ -6,6 +6,14 @@ var RetorProgressContext = createContext({
6
6
  closestTagId: null,
7
7
  targetPosition: null,
8
8
  distanceFromStart: null,
9
+ pitchDeg: null,
10
+ elevationM: null,
11
+ lat: null,
12
+ lon: null,
13
+ elevationGainM: null,
14
+ sectionLengthM: null,
15
+ sectionIndex: null,
16
+ sectionProgress: null,
9
17
  isPlaying: false
10
18
  });
11
19
  function noop() {
@@ -50,10 +58,49 @@ function useActiveLine() {
50
58
  return useRetorBridge().activeLine;
51
59
  }
52
60
  function useLineProgress() {
53
- const { progress, closestTagId, targetPosition, distanceFromStart } = useRetorProgress();
61
+ const {
62
+ progress,
63
+ closestTagId,
64
+ targetPosition,
65
+ distanceFromStart,
66
+ pitchDeg,
67
+ elevationM,
68
+ lat,
69
+ lon,
70
+ elevationGainM,
71
+ sectionLengthM,
72
+ sectionIndex,
73
+ sectionProgress
74
+ } = useRetorProgress();
54
75
  return useMemo(
55
- () => ({ progress, closestTagId, targetPosition, distanceFromStart }),
56
- [progress, closestTagId, targetPosition, distanceFromStart]
76
+ () => ({
77
+ progress,
78
+ closestTagId,
79
+ targetPosition,
80
+ distanceFromStart,
81
+ pitchDeg,
82
+ elevationM,
83
+ lat,
84
+ lon,
85
+ elevationGainM,
86
+ sectionLengthM,
87
+ sectionIndex,
88
+ sectionProgress
89
+ }),
90
+ [
91
+ progress,
92
+ closestTagId,
93
+ targetPosition,
94
+ distanceFromStart,
95
+ pitchDeg,
96
+ elevationM,
97
+ lat,
98
+ lon,
99
+ elevationGainM,
100
+ sectionLengthM,
101
+ sectionIndex,
102
+ sectionProgress
103
+ ]
57
104
  );
58
105
  }
59
106
  function useAutoplay() {
@@ -174,6 +221,14 @@ var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl =
174
221
  const [progress, setProgress] = useState(0);
175
222
  const [targetPosition, setTargetPosition] = useState(null);
176
223
  const [distanceFromStart, setDistanceFromStart] = useState(null);
224
+ const [pitchDeg, setPitchDeg] = useState(null);
225
+ const [elevationM, setElevationM] = useState(null);
226
+ const [lat, setLat] = useState(null);
227
+ const [lon, setLon] = useState(null);
228
+ const [elevationGainM, setElevationGainM] = useState(null);
229
+ const [sectionLengthM, setSectionLengthM] = useState(null);
230
+ const [sectionIndex, setSectionIndex] = useState(null);
231
+ const [sectionProgress, setSectionProgress] = useState(null);
177
232
  const [isPlaying, setIsPlaying] = useState(false);
178
233
  const [isAddNoteOpen, setIsAddNoteOpen] = useState(false);
179
234
  const [addNoteTagId, setAddNoteTagId] = useState(null);
@@ -322,6 +377,14 @@ var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl =
322
377
  setClosestTagId(payload.closestTagId);
323
378
  setTargetPosition(payload.targetPosition ?? null);
324
379
  setDistanceFromStart(payload.distanceFromStart ?? null);
380
+ setPitchDeg(payload.pitchDeg ?? null);
381
+ setElevationM(payload.elevationM ?? null);
382
+ setLat(payload.lat ?? null);
383
+ setLon(payload.lon ?? null);
384
+ setElevationGainM(payload.elevationGainM ?? null);
385
+ setSectionLengthM(payload.sectionLengthM ?? null);
386
+ setSectionIndex(payload.sectionIndex ?? null);
387
+ setSectionProgress(payload.sectionProgress ?? null);
325
388
  onLineProgress?.(payload);
326
389
  break;
327
390
  }
@@ -369,8 +432,36 @@ var Viewer = forwardRef(function Viewer2({ projectId, id = "default", baseUrl =
369
432
  [project, lines, activeLineId, activeLine, lineNotes, externalNotes, userId, isAddNoteOpen, addNoteTagId, controls, openAddNote, closeAddNote, submitNote, deleteNote]
370
433
  );
371
434
  const progressCtx = useMemo2(
372
- () => ({ progress, closestTagId, targetPosition, distanceFromStart, isPlaying }),
373
- [progress, closestTagId, targetPosition, distanceFromStart, isPlaying]
435
+ () => ({
436
+ progress,
437
+ closestTagId,
438
+ targetPosition,
439
+ distanceFromStart,
440
+ pitchDeg,
441
+ elevationM,
442
+ lat,
443
+ lon,
444
+ elevationGainM,
445
+ sectionLengthM,
446
+ sectionIndex,
447
+ sectionProgress,
448
+ isPlaying
449
+ }),
450
+ [
451
+ progress,
452
+ closestTagId,
453
+ targetPosition,
454
+ distanceFromStart,
455
+ pitchDeg,
456
+ elevationM,
457
+ lat,
458
+ lon,
459
+ elevationGainM,
460
+ sectionLengthM,
461
+ sectionIndex,
462
+ sectionProgress,
463
+ isPlaying
464
+ ]
374
465
  );
375
466
  return /* @__PURE__ */ React2.createElement(RetorBridgeProvider, { value: ctxValue }, /* @__PURE__ */ React2.createElement(RetorProgressProvider, { value: progressCtx }, /* @__PURE__ */ React2.createElement(View, { style: [styles.root, style] }, /* @__PURE__ */ React2.createElement(
376
467
  WebView,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retor/react-native",
3
- "version": "0.4.6",
3
+ "version": "0.5.0",
4
4
  "description": "React Native SDK for embedding Retor 3D experiences",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,6 +17,12 @@
17
17
  "README.md",
18
18
  "LICENSE"
19
19
  ],
20
+ "scripts": {
21
+ "build": "tsup src/index.tsx --format cjs,esm --dts --clean --external react --external react-native --external react-native-webview --external @gorhom/bottom-sheet --external react-native-gesture-handler --external react-native-reanimated --external react-native-svg --external lucide-react-native --external expo-blur",
22
+ "dev": "tsup src/index.tsx --format cjs,esm --dts --watch --external react --external react-native --external react-native-webview --external @gorhom/bottom-sheet --external react-native-gesture-handler --external react-native-reanimated --external react-native-svg --external lucide-react-native --external expo-blur",
23
+ "typecheck": "tsc --noEmit",
24
+ "prepublishOnly": "pnpm build"
25
+ },
20
26
  "keywords": [
21
27
  "retor",
22
28
  "3d",
@@ -55,9 +61,5 @@
55
61
  "tsup": "^8.0.0",
56
62
  "typescript": "^5.4.0"
57
63
  },
58
- "scripts": {
59
- "build": "tsup src/index.tsx --format cjs,esm --dts --clean --external react --external react-native --external react-native-webview --external @gorhom/bottom-sheet --external react-native-gesture-handler --external react-native-reanimated --external react-native-svg --external lucide-react-native --external expo-blur",
60
- "dev": "tsup src/index.tsx --format cjs,esm --dts --watch --external react --external react-native --external react-native-webview --external @gorhom/bottom-sheet --external react-native-gesture-handler --external react-native-reanimated --external react-native-svg --external lucide-react-native --external expo-blur",
61
- "typecheck": "tsc --noEmit"
62
- }
63
- }
64
+ "packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
65
+ }