@osm-editor-kit/street-imagery-react 0.1.0-alpha.11 → 0.1.0-alpha.13

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,8 +1,9 @@
1
- import { useViewerActions } from './chunk-25UGGXIE.js';
1
+ import { useViewerActions } from './chunk-GYUS2JVV.js';
2
+ import { c } from 'react/compiler-runtime';
2
3
  import '@panoramax/web-viewer';
3
4
  import { getStreetImageryConfig } from '@osm-editor-kit/street-imagery';
4
5
  import { useRef, useEffectEvent, useEffect } from 'react';
5
- import { jsxs, jsx } from 'react/jsx-runtime';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
7
 
7
8
  // src/panels/panoramaxLimitPanning.ts
8
9
  var toRad = (degrees) => degrees * Math.PI / 180;
@@ -19,7 +20,10 @@ var limitToImage = (psv, position) => {
19
20
  }
20
21
  const halfH = toRad(psv.state.hFov) / 2;
21
22
  const halfV = toRad(psv.state.vFov) / 2;
22
- let { yaw, pitch } = position;
23
+ let {
24
+ yaw,
25
+ pitch
26
+ } = position;
23
27
  if (crop.croppedWidth < crop.fullWidth) {
24
28
  const left = crop.croppedX / crop.fullWidth * 2 * Math.PI - Math.PI;
25
29
  const right = (crop.croppedX + crop.croppedWidth) / crop.fullWidth * 2 * Math.PI - Math.PI;
@@ -31,7 +35,10 @@ var limitToImage = (psv, position) => {
31
35
  const bottom = Math.PI / 2 - (crop.croppedY + crop.croppedHeight) / crop.fullHeight * Math.PI;
32
36
  pitch = keepInView(pitch, bottom, top, halfV);
33
37
  }
34
- return { yaw, pitch };
38
+ return {
39
+ yaw,
40
+ pitch
41
+ };
35
42
  };
36
43
  var toDeg = (radians) => radians * 180 / Math.PI;
37
44
  var widestZoomLevel = (psv) => {
@@ -100,20 +107,48 @@ var panoramaxPhotoFromMetadata = (metadata) => {
100
107
  const exifEntries = Object.entries(properties.exif ?? {}).filter(([, value]) => typeof value === "string" || typeof value === "number").map(([key, value]) => [key, String(value)]);
101
108
  const exif = exifEntries.length > 0 ? Object.fromEntries(exifEntries) : null;
102
109
  const details = {
103
- ...creatorContact && creatorContact !== creatorName ? { creatorContact } : {},
104
- ...properties.license ? { license: properties.license } : {},
105
- ...metadata.origLinks?.find((link) => link.rel === "license")?.href ? { licenseUrl: metadata.origLinks.find((link) => link.rel === "license")?.href } : {},
106
- ...properties.datetimetz ? { capturedAtLocal: properties.datetimetz } : {},
107
- ...uploadedAt != null ? { uploadedAt } : {},
108
- ...cameraName ? { camera: cameraName } : {},
109
- ...isFlat && metadata.horizontalFov ? { fieldOfViewDeg: metadata.horizontalFov } : {},
110
- ...properties["quality:horizontal_accuracy"] != null ? { positionAccuracyMeters: properties["quality:horizontal_accuracy"] } : {},
111
- ...metadata.origInstance?.instance_name ? { instance: metadata.origInstance.instance_name } : {},
112
- ...camera?.focal_length != null ? { focalLengthMm: camera.focal_length } : {},
113
- ...properties["original_file:name"] ? { originalFileName: properties["original_file:name"] } : {},
114
- ...properties["original_file:size"] != null ? { originalFileSizeBytes: properties["original_file:size"] } : {},
115
- ...properties["geovisio:rank_in_collection"] != null ? { rankInSequence: properties["geovisio:rank_in_collection"] } : {},
116
- ...exif ? { exif } : {}
110
+ ...creatorContact && creatorContact !== creatorName ? {
111
+ creatorContact
112
+ } : {},
113
+ ...properties.license ? {
114
+ license: properties.license
115
+ } : {},
116
+ ...metadata.origLinks?.find((link) => link.rel === "license")?.href ? {
117
+ licenseUrl: metadata.origLinks.find((link) => link.rel === "license")?.href
118
+ } : {},
119
+ ...properties.datetimetz ? {
120
+ capturedAtLocal: properties.datetimetz
121
+ } : {},
122
+ ...uploadedAt != null ? {
123
+ uploadedAt
124
+ } : {},
125
+ ...cameraName ? {
126
+ camera: cameraName
127
+ } : {},
128
+ ...isFlat && metadata.horizontalFov ? {
129
+ fieldOfViewDeg: metadata.horizontalFov
130
+ } : {},
131
+ ...properties["quality:horizontal_accuracy"] != null ? {
132
+ positionAccuracyMeters: properties["quality:horizontal_accuracy"]
133
+ } : {},
134
+ ...metadata.origInstance?.instance_name ? {
135
+ instance: metadata.origInstance.instance_name
136
+ } : {},
137
+ ...camera?.focal_length != null ? {
138
+ focalLengthMm: camera.focal_length
139
+ } : {},
140
+ ...properties["original_file:name"] ? {
141
+ originalFileName: properties["original_file:name"]
142
+ } : {},
143
+ ...properties["original_file:size"] != null ? {
144
+ originalFileSizeBytes: properties["original_file:size"]
145
+ } : {},
146
+ ...properties["geovisio:rank_in_collection"] != null ? {
147
+ rankInSequence: properties["geovisio:rank_in_collection"]
148
+ } : {},
149
+ ...exif ? {
150
+ exif
151
+ } : {}
117
152
  };
118
153
  return {
119
154
  providerId: "panoramax",
@@ -123,21 +158,27 @@ var panoramaxPhotoFromMetadata = (metadata) => {
123
158
  isPano: !isFlat,
124
159
  heading: properties["view:azimuth"] ?? null,
125
160
  lngLat: metadata.gps,
126
- ...creatorName ? { creatorName } : {},
161
+ ...creatorName ? {
162
+ creatorName
163
+ } : {},
127
164
  details
128
165
  };
129
166
  };
130
167
  var panoramaxApiEndpoint = () => `${getStreetImageryConfig().panoramaxApiBase}/api`;
131
168
  var HIDE_LEGEND_CSS = "pnx-photo-viewer pnx-bottom-drawer, pnx-photo-viewer pnx-picture-legend { display: none !important; }";
132
169
  var normalizeBearing = (degrees) => (degrees % 360 + 360) % 360;
133
- var PanoramaxWebViewerPanel = ({
134
- photo,
135
- onPhotoSelected,
136
- onEaseMapToPoint,
137
- onViewerPhoto,
138
- hideLegend: hideLegendProp = false,
139
- hideAttribution = false
140
- }) => {
170
+ var PanoramaxWebViewerPanel = (t0) => {
171
+ const $ = c(35);
172
+ const {
173
+ photo,
174
+ onPhotoSelected,
175
+ onEaseMapToPoint,
176
+ onViewerPhoto,
177
+ hideLegend: t1,
178
+ hideAttribution: t2
179
+ } = t0;
180
+ const hideLegendProp = t1 === void 0 ? false : t1;
181
+ const hideAttribution = t2 === void 0 ? false : t2;
141
182
  const hideLegend = hideLegendProp || hideAttribution;
142
183
  const containerRef = useRef(null);
143
184
  const viewerRef = useRef(null);
@@ -149,25 +190,55 @@ var PanoramaxWebViewerPanel = ({
149
190
  const pendingBearingRef = useRef(null);
150
191
  const pendingHfovRef = useRef(null);
151
192
  const actions = useViewerActions();
152
- const emitViewerPhoto = useEffectEvent(
153
- (viewerPhoto) => onViewerPhoto?.(viewerPhoto)
154
- );
155
- useEffect(
156
- function syncPhotoRef() {
193
+ let t3;
194
+ if ($[0] !== onViewerPhoto) {
195
+ t3 = (viewerPhoto) => onViewerPhoto?.(viewerPhoto);
196
+ $[0] = onViewerPhoto;
197
+ $[1] = t3;
198
+ } else {
199
+ t3 = $[1];
200
+ }
201
+ const emitViewerPhoto = useEffectEvent(t3);
202
+ let t4;
203
+ let t5;
204
+ if ($[2] !== photo) {
205
+ t4 = function syncPhotoRef() {
157
206
  photoRef.current = photo;
158
- },
159
- [photo]
160
- );
161
- useEffect(
162
- function resetViewerStoreOnProviderChange() {
207
+ };
208
+ t5 = [photo];
209
+ $[2] = photo;
210
+ $[3] = t4;
211
+ $[4] = t5;
212
+ } else {
213
+ t4 = $[3];
214
+ t5 = $[4];
215
+ }
216
+ useEffect(t4, t5);
217
+ let t6;
218
+ if ($[5] !== actions) {
219
+ t6 = function resetViewerStoreOnProviderChange() {
163
220
  return () => {
164
221
  actions.reset();
165
222
  };
166
- },
167
- [actions, photo.providerId]
168
- );
169
- useEffect(
170
- function mountPanoramaxViewer() {
223
+ };
224
+ $[5] = actions;
225
+ $[6] = t6;
226
+ } else {
227
+ t6 = $[6];
228
+ }
229
+ let t7;
230
+ if ($[7] !== actions || $[8] !== photo.providerId) {
231
+ t7 = [actions, photo.providerId];
232
+ $[7] = actions;
233
+ $[8] = photo.providerId;
234
+ $[9] = t7;
235
+ } else {
236
+ t7 = $[9];
237
+ }
238
+ useEffect(t6, t7);
239
+ let t8;
240
+ if ($[10] !== actions || $[11] !== emitViewerPhoto || $[12] !== onEaseMapToPoint || $[13] !== onPhotoSelected) {
241
+ t8 = function mountPanoramaxViewer() {
171
242
  const viewer = viewerRef.current;
172
243
  const container = containerRef.current;
173
244
  if (!viewer || !container) {
@@ -177,16 +248,23 @@ var PanoramaxWebViewerPanel = ({
177
248
  const flushBearing = () => {
178
249
  bearingRafRef.current = null;
179
250
  if (pendingBearingRef.current != null) {
180
- actions.setPov({ bearing: pendingBearingRef.current });
251
+ actions.setPov({
252
+ bearing: pendingBearingRef.current
253
+ });
181
254
  pendingBearingRef.current = null;
182
255
  }
183
256
  if (pendingHfovRef.current != null) {
184
- actions.setPov({ hfov: pendingHfovRef.current });
257
+ actions.setPov({
258
+ hfov: pendingHfovRef.current
259
+ });
185
260
  pendingHfovRef.current = null;
186
261
  }
187
262
  };
188
263
  const onSelect = (event) => {
189
- const { seqId, picId } = event.detail;
264
+ const {
265
+ seqId,
266
+ picId
267
+ } = event.detail;
190
268
  if (!picId) {
191
269
  return;
192
270
  }
@@ -199,8 +277,8 @@ var PanoramaxWebViewerPanel = ({
199
277
  photoId: picId
200
278
  });
201
279
  };
202
- const onPictureLoaded = (event) => {
203
- const detail = event.detail;
280
+ const onPictureLoaded = (event_0) => {
281
+ const detail = event_0.detail;
204
282
  const metadata = viewer.psv?.getPictureMetadata();
205
283
  if (metadata) {
206
284
  emitViewerPhoto(panoramaxPhotoFromMetadata(metadata));
@@ -208,22 +286,28 @@ var PanoramaxWebViewerPanel = ({
208
286
  if (detail.lon == null || detail.lat == null) {
209
287
  return;
210
288
  }
211
- actions.setPov({ lngLat: [detail.lon, detail.lat] });
289
+ actions.setPov({
290
+ lngLat: [detail.lon, detail.lat]
291
+ });
212
292
  if (detail.x != null) {
213
- actions.setPov({ bearing: normalizeBearing(detail.x) });
293
+ actions.setPov({
294
+ bearing: normalizeBearing(detail.x)
295
+ });
214
296
  }
215
297
  const psv = viewer.psv;
216
298
  if (psv && detail.z != null) {
217
- actions.setPov({ hfov: psv.dataHelper.zoomLevelToFov(detail.z) });
299
+ actions.setPov({
300
+ hfov: psv.dataHelper.zoomLevelToFov(detail.z)
301
+ });
218
302
  }
219
303
  onEaseMapToPoint(detail.lon, detail.lat);
220
304
  };
221
- const onViewRotated = (event) => {
222
- const detail = event.detail;
223
- pendingBearingRef.current = normalizeBearing(detail.x);
224
- const psv = viewer.psv;
225
- if (psv && detail.z != null) {
226
- pendingHfovRef.current = psv.dataHelper.zoomLevelToFov(detail.z);
305
+ const onViewRotated = (event_1) => {
306
+ const detail_0 = event_1.detail;
307
+ pendingBearingRef.current = normalizeBearing(detail_0.x);
308
+ const psv_0 = viewer.psv;
309
+ if (psv_0 && detail_0.z != null) {
310
+ pendingHfovRef.current = psv_0.dataHelper.zoomLevelToFov(detail_0.z);
227
311
  }
228
312
  if (bearingRafRef.current == null) {
229
313
  bearingRafRef.current = requestAnimationFrame(flushBearing);
@@ -236,7 +320,8 @@ var PanoramaxWebViewerPanel = ({
236
320
  viewer.psv?.resize();
237
321
  });
238
322
  resizeObserver.observe(container);
239
- let stopLimit = null;
323
+ let stopLimit;
324
+ stopLimit = null;
240
325
  const startLimit = () => {
241
326
  if (!stopLimit && viewer.psv) {
242
327
  stopLimit = limitPanningToImage(viewer.psv);
@@ -265,50 +350,107 @@ var PanoramaxWebViewerPanel = ({
265
350
  viewer.removeEventListener("psv:picture-loaded", startLimit);
266
351
  stopLimit?.();
267
352
  };
268
- },
269
- [actions, onEaseMapToPoint, onPhotoSelected]
270
- );
271
- useEffect(
272
- function syncExternalPhotoSelection() {
273
- const viewer = viewerRef.current;
274
- if (!viewer || photo.photoId === lastViewerPhotoIdRef.current) {
353
+ };
354
+ $[10] = actions;
355
+ $[11] = emitViewerPhoto;
356
+ $[12] = onEaseMapToPoint;
357
+ $[13] = onPhotoSelected;
358
+ $[14] = t8;
359
+ } else {
360
+ t8 = $[14];
361
+ }
362
+ let t9;
363
+ if ($[15] !== actions || $[16] !== onEaseMapToPoint || $[17] !== onPhotoSelected) {
364
+ t9 = [actions, onEaseMapToPoint, onPhotoSelected];
365
+ $[15] = actions;
366
+ $[16] = onEaseMapToPoint;
367
+ $[17] = onPhotoSelected;
368
+ $[18] = t9;
369
+ } else {
370
+ t9 = $[18];
371
+ }
372
+ useEffect(t8, t9);
373
+ let t10;
374
+ let t11;
375
+ if ($[19] !== actions || $[20] !== photo.photoId || $[21] !== photo.sequenceId) {
376
+ t10 = function syncExternalPhotoSelection() {
377
+ const viewer_0 = viewerRef.current;
378
+ if (!viewer_0 || photo.photoId === lastViewerPhotoIdRef.current) {
275
379
  return;
276
380
  }
277
381
  actions.reset();
278
382
  lastViewerPhotoIdRef.current = photo.photoId;
279
383
  if (!readyRef.current) {
280
- pendingSelectRef.current = { sequenceId: photo.sequenceId, photoId: photo.photoId };
384
+ pendingSelectRef.current = {
385
+ sequenceId: photo.sequenceId,
386
+ photoId: photo.photoId
387
+ };
281
388
  return;
282
389
  }
283
- if (typeof viewer.select === "function") {
284
- viewer.select(photo.sequenceId ?? null, photo.photoId);
390
+ if (typeof viewer_0.select === "function") {
391
+ viewer_0.select(photo.sequenceId ?? null, photo.photoId);
285
392
  }
286
- },
287
- [actions, photo.photoId, photo.sequenceId]
288
- );
289
- return /* @__PURE__ */ jsxs(
290
- "div",
291
- {
292
- ref: containerRef,
293
- className: "min-h-48 overflow-hidden rounded-lg border border-slate-200 bg-slate-900",
294
- style: { aspectRatio: "4 / 3" },
295
- children: [
296
- hideLegend ? /* @__PURE__ */ jsx("style", { children: HIDE_LEGEND_CSS }) : null,
297
- /* @__PURE__ */ jsx(
298
- "pnx-photo-viewer",
299
- {
300
- ref: viewerRef,
301
- className: "block h-full w-full",
302
- endpoint: panoramaxApiEndpoint(),
303
- "url-parameters": "false",
304
- widgets: hideLegend ? "false" : void 0,
305
- picture: photo.photoId,
306
- sequence: photo.sequenceId ?? void 0
307
- }
308
- )
309
- ]
310
- }
311
- );
393
+ };
394
+ t11 = [actions, photo.photoId, photo.sequenceId];
395
+ $[19] = actions;
396
+ $[20] = photo.photoId;
397
+ $[21] = photo.sequenceId;
398
+ $[22] = t10;
399
+ $[23] = t11;
400
+ } else {
401
+ t10 = $[22];
402
+ t11 = $[23];
403
+ }
404
+ useEffect(t10, t11);
405
+ let t12;
406
+ if ($[24] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
407
+ t12 = {
408
+ aspectRatio: "4 / 3"
409
+ };
410
+ $[24] = t12;
411
+ } else {
412
+ t12 = $[24];
413
+ }
414
+ let t13;
415
+ if ($[25] !== hideLegend) {
416
+ t13 = hideLegend ? /* @__PURE__ */ jsx("style", { children: HIDE_LEGEND_CSS }) : null;
417
+ $[25] = hideLegend;
418
+ $[26] = t13;
419
+ } else {
420
+ t13 = $[26];
421
+ }
422
+ let t14;
423
+ if ($[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
424
+ t14 = panoramaxApiEndpoint();
425
+ $[27] = t14;
426
+ } else {
427
+ t14 = $[27];
428
+ }
429
+ const t15 = hideLegend ? "false" : void 0;
430
+ const t16 = photo.sequenceId ?? void 0;
431
+ let t17;
432
+ if ($[28] !== photo.photoId || $[29] !== t15 || $[30] !== t16) {
433
+ t17 = /* @__PURE__ */ jsx("pnx-photo-viewer", { ref: viewerRef, className: "block h-full w-full", endpoint: t14, "url-parameters": "false", widgets: t15, picture: photo.photoId, sequence: t16 });
434
+ $[28] = photo.photoId;
435
+ $[29] = t15;
436
+ $[30] = t16;
437
+ $[31] = t17;
438
+ } else {
439
+ t17 = $[31];
440
+ }
441
+ let t18;
442
+ if ($[32] !== t13 || $[33] !== t17) {
443
+ t18 = /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "min-h-48 overflow-hidden rounded-lg border border-slate-200 bg-slate-900", style: t12, children: [
444
+ t13,
445
+ t17
446
+ ] });
447
+ $[32] = t13;
448
+ $[33] = t17;
449
+ $[34] = t18;
450
+ } else {
451
+ t18 = $[34];
452
+ }
453
+ return t18;
312
454
  };
313
455
 
314
456
  export { PanoramaxWebViewerPanel };