@neurodyn/react-room-viewer 0.0.5 → 0.0.7

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.ts CHANGED
@@ -5,6 +5,31 @@ import * as React_3 from 'react';
5
5
 
6
6
  declare type DialogProps = React_3.ComponentProps<typeof DialogPrimitive.Root>
7
7
 
8
+ declare type IssueWidgetToken = (data: {
9
+ token?: string;
10
+ }, config?: WidgetSessionApiConfig) => Promise<IssueWidgetTokenResponseDtoOutput>;
11
+
12
+ /**
13
+ * Generated by Kubb (https://kubb.dev/).
14
+ * Do not edit manually.
15
+ */
16
+ declare type IssueWidgetTokenResponseDtoOutput = {
17
+ /**
18
+ * @type string
19
+ */
20
+ token: string;
21
+ /**
22
+ * @type string
23
+ */
24
+ sid: string;
25
+ /**
26
+ * @minLength -9007199254740991
27
+ * @maxLength 9007199254740991
28
+ * @type integer
29
+ */
30
+ expiresIn: number;
31
+ };
32
+
8
33
  declare const resources: {
9
34
  en: {
10
35
  translation: {
@@ -26,10 +51,17 @@ declare const resources: {
26
51
  readonly ar: {
27
52
  readonly viewInPlace: "View in place";
28
53
  readonly scanQrCode: "Scan this QR code with your phone's camera to view the object in Augmented Reality";
54
+ readonly deviceRequirementsDisclaimer: "*Requires AR-supported device and browser. We recommend iOS 12 or later with Safari, or Android 7.0 or later with Chrome.";
55
+ };
56
+ readonly legal: {
57
+ readonly termsOfUse: "Terms of Use";
58
+ readonly conjunction: "and";
59
+ readonly privacyPolicy: "Privacy Policy";
29
60
  };
30
61
  readonly shareMessage: {
31
- readonly poster: "Preview poster";
32
- readonly carpet: "Preview carpet";
62
+ readonly wallart: "Preview wall art";
63
+ readonly rugs: "Preview rug";
64
+ readonly flooring: "Preview flooring";
33
65
  };
34
66
  readonly rooms: {
35
67
  readonly 'room-example-11': "Room Example 11";
@@ -54,6 +86,62 @@ declare const resources: {
54
86
  readonly unauthorized: "Invalid API key";
55
87
  readonly 'payment-required': "Viewer temporarily unavailable";
56
88
  };
89
+ readonly resourceType: {
90
+ readonly rugs: {
91
+ readonly productCategory: "Rug";
92
+ readonly productCardTitle: "Selected rug";
93
+ readonly replaceProduct: "Replace rug";
94
+ readonly replaceProductShort: "Replace";
95
+ };
96
+ readonly flooring: {
97
+ readonly productCategory: "Flooring";
98
+ readonly productCardTitle: "Selected flooring";
99
+ readonly replaceProduct: "Replace flooring";
100
+ readonly replaceProductShort: "Replace";
101
+ };
102
+ };
103
+ readonly floor: {
104
+ readonly scene: {
105
+ readonly companyFallback: "Company name";
106
+ readonly share: "Share";
107
+ readonly download: "Download";
108
+ readonly hideCatalog: "Hide catalog";
109
+ readonly interiorCardTitle: "Interior";
110
+ readonly tryAtHome: "Try at home";
111
+ readonly tryAtHomeBody: "Through your phone camera";
112
+ };
113
+ readonly materialSelection: {
114
+ readonly title: "Material Selection";
115
+ };
116
+ readonly interiorSelection: {
117
+ readonly title: "Choose interior";
118
+ readonly uploadPhoto: "Upload your photo";
119
+ readonly invalidFile: "Could not upload photo, please try again";
120
+ readonly customTitle: "Your photos";
121
+ readonly presetsTitle: "Preset interiors";
122
+ readonly currentInterior: "Current interior";
123
+ readonly chooseInterior: "Choose interior";
124
+ readonly chooseInteriorShort: "Choose";
125
+ };
126
+ readonly processing: {
127
+ readonly title: "Preparing your room";
128
+ readonly progressLabel: "Room preparation progress";
129
+ readonly stages: {
130
+ readonly reading: "Reading your photo...";
131
+ readonly mapping: "Finding floors and walls...";
132
+ readonly lighting: "Balancing light and perspective...";
133
+ readonly finalizing: "Building your preview...";
134
+ readonly ready: "Room is ready...";
135
+ };
136
+ };
137
+ readonly error: {
138
+ readonly title: "Something went wrong";
139
+ readonly processingBody: "This time we could not upload and process the photo";
140
+ readonly loadBody: "We could not load the viewer. Please try again.";
141
+ readonly tryAgain: "Try again";
142
+ readonly cancel: "Cancel";
143
+ };
144
+ };
57
145
  };
58
146
  };
59
147
  ru: {
@@ -76,10 +164,17 @@ declare const resources: {
76
164
  readonly ar: {
77
165
  readonly viewInPlace: "Примерить в комнате";
78
166
  readonly scanQrCode: "Отсканируйте этот QR-код камерой телефона, чтобы просмотреть объект в дополненной реальности";
167
+ readonly deviceRequirementsDisclaimer: "*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 12 или новее с Safari либо Android 7.0 или новее с Chrome.";
168
+ };
169
+ readonly legal: {
170
+ readonly termsOfUse: "Условия использования";
171
+ readonly conjunction: "и";
172
+ readonly privacyPolicy: "Политика конфиденциальности";
79
173
  };
80
174
  readonly shareMessage: {
81
- readonly poster: "Примерить постер";
82
- readonly carpet: "Примерить ковер";
175
+ readonly wallart: "Примерить настенный декор";
176
+ readonly rugs: "Примерить ковер";
177
+ readonly flooring: "Примерить напольное покрытие";
83
178
  };
84
179
  readonly rooms: {
85
180
  readonly 'room-example-11': "Пример комнаты 11";
@@ -104,15 +199,71 @@ declare const resources: {
104
199
  readonly unauthorized: "Неверный API-ключ";
105
200
  readonly 'payment-required': "Просмотр временно недоступен";
106
201
  };
202
+ readonly resourceType: {
203
+ readonly rugs: {
204
+ readonly productCategory: "Ковер";
205
+ readonly productCardTitle: "Выбранный ковер";
206
+ readonly replaceProduct: "Заменить ковер";
207
+ readonly replaceProductShort: "Заменить";
208
+ };
209
+ readonly flooring: {
210
+ readonly productCategory: "Напольное покрытие";
211
+ readonly productCardTitle: "Выбранное напольное покрытие";
212
+ readonly replaceProduct: "Заменить";
213
+ readonly replaceProductShort: "Заменить";
214
+ };
215
+ };
216
+ readonly floor: {
217
+ readonly scene: {
218
+ readonly companyFallback: "Компания";
219
+ readonly share: "Поделиться";
220
+ readonly download: "Скачать";
221
+ readonly hideCatalog: "Скрыть каталог";
222
+ readonly interiorCardTitle: "Интерьер";
223
+ readonly tryAtHome: "Примерить дома";
224
+ readonly tryAtHomeBody: "Через камеру телефона";
225
+ };
226
+ readonly materialSelection: {
227
+ readonly title: "Выбор материала";
228
+ };
229
+ readonly interiorSelection: {
230
+ readonly title: "Выберите интерьер";
231
+ readonly uploadPhoto: "Загрузить свое фото";
232
+ readonly invalidFile: "Не получилось загрузить фото, попробуйте еще раз";
233
+ readonly customTitle: "Ваши фото";
234
+ readonly presetsTitle: "Готовые интерьеры";
235
+ readonly currentInterior: "Текущий интерьер";
236
+ readonly chooseInterior: "Выбрать интерьер";
237
+ readonly chooseInteriorShort: "Выбрать";
238
+ };
239
+ readonly processing: {
240
+ readonly title: "Готовим вашу комнату";
241
+ readonly progressLabel: "Прогресс подготовки комнаты";
242
+ readonly stages: {
243
+ readonly reading: "Читаем ваше фото...";
244
+ readonly mapping: "Ищем пол и стены...";
245
+ readonly lighting: "Настраиваем свет и перспективу...";
246
+ readonly finalizing: "Собираем превью...";
247
+ readonly ready: "Комната готова...";
248
+ };
249
+ };
250
+ readonly error: {
251
+ readonly title: "Что-то пошло не так";
252
+ readonly processingBody: "В этот раз не получилось загрузить обработать фотографию";
253
+ readonly loadBody: "Не удалось загрузить просмотр. Попробуйте снова.";
254
+ readonly tryAgain: "Попробовать еще раз";
255
+ readonly cancel: "Отменить";
256
+ };
257
+ };
107
258
  };
108
259
  };
109
260
  };
110
261
 
111
- export declare function RoomViewer({ type, src, tinuuid, name, language, width, height, dimensionUnit, displayUnit, rooms, apiKey, source, className, ...props }: RoomViewerProps & React_2.ComponentProps<'div'>): JSX.Element;
262
+ export declare function RoomViewer({ type, src, tinuuid, name, language, width, height, dimensionUnit, displayUnit, apiKey, source, widgetSession, className, ...props }: RoomViewerProps & React_2.ComponentProps<'div'>): JSX.Element;
112
263
 
113
- export declare function RoomViewerDialog({ type, src, tinuuid, width, height, dimensionUnit, displayUnit, name, language, rooms, apiKey, source, ...props }: RoomViewerDialogProps): JSX.Element;
264
+ export declare function RoomViewerDialog({ type, src, tinuuid, width, height, dimensionUnit, displayUnit, name, language, apiKey, source, widgetSession, open, defaultOpen, onOpenChange, ...props }: RoomViewerDialogProps): JSX.Element;
114
265
 
115
- declare interface RoomViewerDialogProps extends Omit<RoomViewerRootProps, 'showDialogCloseButton'>, Omit<DialogProps, 'children' | 'modal'> {
266
+ declare interface RoomViewerDialogProps extends Omit<RoomViewerRootProps, 'showDialogCloseButton' | 'viewerSurface' | 'dialogPortalContainer' | 'viewerDialogOpen' | 'onViewerDialogOpenChange'>, Omit<DialogProps, 'children' | 'modal'> {
116
267
  /** The controlled open state of the dialog. */
117
268
  open?: boolean;
118
269
  /** The open state of the dialog when it is initially rendered. */
@@ -127,16 +278,27 @@ export declare type RoomViewerDisplayUnit = 'cm' | 'in';
127
278
 
128
279
  declare type RoomViewerLanguage = keyof typeof resources;
129
280
 
281
+ /**
282
+ * Legacy Resource Type values kept working as deprecated aliases.
283
+ *
284
+ * @deprecated Use canonical Resource Type values instead: `poster` → `wallart`,
285
+ * `carpet` → `rugs`.
286
+ */
287
+ export declare type RoomViewerLegacyResourceType = 'poster' | 'carpet';
288
+
130
289
  export declare type RoomViewerPlaneKind = 'floor' | 'wall' | 'ceiling';
131
290
 
132
- export declare interface RoomViewerProps extends Omit<RoomViewerRootProps, 'showDialogCloseButton'> {
291
+ export declare interface RoomViewerProps extends Omit<RoomViewerRootProps, 'showDialogCloseButton' | 'viewerSurface'> {
133
292
  }
134
293
 
135
- declare type RoomViewerResourceCarpet = 'carpet';
294
+ /**
295
+ * Canonical Resource Type values. Internal code only ever sees these — legacy
296
+ * inputs are normalized to canonical at the viewer entry.
297
+ */
298
+ export declare type RoomViewerResourceType = 'wallart' | 'rugs' | 'flooring';
136
299
 
137
- declare type RoomViewerResourcePoster = 'poster';
138
-
139
- declare type RoomViewerResourceType = RoomViewerResourcePoster | RoomViewerResourceCarpet;
300
+ /** Resource Type values accepted at the public boundary (canonical ∪ legacy). */
301
+ export declare type RoomViewerResourceTypeInput = RoomViewerResourceType | RoomViewerLegacyResourceType;
140
302
 
141
303
  export declare interface RoomViewerRoom {
142
304
  id: string;
@@ -146,11 +308,18 @@ export declare interface RoomViewerRoom {
146
308
  }
147
309
 
148
310
  declare interface RoomViewerRootProps {
149
- /** Resource display mode. */
150
- type: RoomViewerResourceType;
151
- /** Poster image URL. Used when `type` is `poster`. */
311
+ /**
312
+ * Resource Type. Canonical values are `wallart`, `rugs`, and `flooring`.
313
+ *
314
+ * @remarks
315
+ * `poster` and `carpet` are accepted as deprecated aliases (`poster` →
316
+ * `wallart`, `carpet` → `rugs`) and still work unchanged, but emit a
317
+ * development-only console warning. Migrate to the canonical values.
318
+ */
319
+ type: RoomViewerResourceTypeInput;
320
+ /** Wall-art image URL. Used for wall products (`wallart`). */
152
321
  src?: string;
153
- /** The object's tinuuid. Used when `type` is `carpet`. */
322
+ /** The object's tinuuid. Used for floor products (`rugs`, `flooring`). */
154
323
  tinuuid?: string;
155
324
  /** Title shown in the dialog header. */
156
325
  name: string;
@@ -160,12 +329,12 @@ declare interface RoomViewerRootProps {
160
329
  * @defaultValue User locale.
161
330
  */
162
331
  language?: RoomViewerLanguage;
163
- /** Poster width. Used when `type` is `poster`. */
332
+ /** Wall-art width. Used for wall products (`wallart`). */
164
333
  width?: number;
165
- /** Poster height. Used when `type` is `poster`. */
334
+ /** Wall-art height. Used for wall products (`wallart`). */
166
335
  height?: number;
167
336
  /**
168
- * Unit used by the poster width and height.
337
+ * Unit used by the wall-art width and height.
169
338
  *
170
339
  * @defaultValue 'm'
171
340
  */
@@ -176,7 +345,6 @@ declare interface RoomViewerRootProps {
176
345
  * @defaultValue 'cm'
177
346
  */
178
347
  displayUnit?: RoomViewerDisplayUnit;
179
- rooms?: RoomViewerRoom[];
180
348
  /**
181
349
  * API key used by Public API requests.
182
350
  */
@@ -189,6 +357,16 @@ declare interface RoomViewerRootProps {
189
357
  source?: RoomViewerSource;
190
358
  /** Enables dialog-only close controls. */
191
359
  showDialogCloseButton?: boolean;
360
+ /** Internal surface boundary for dialog and Inline QR entry behavior. */
361
+ viewerSurface?: RoomViewerSurface;
362
+ /** Internal portal container for dialog-surface floor flow dialogs. */
363
+ dialogPortalContainer?: HTMLDivElement | null;
364
+ /** Internal controlled open state for dialog-surface floor flow. */
365
+ viewerDialogOpen?: boolean;
366
+ /** Internal controlled open-state handler for dialog-surface floor flow. */
367
+ onViewerDialogOpenChange?: (open: boolean) => void;
368
+ /** Existing Widget Session from an embedding surface such as Shopify activation. */
369
+ widgetSession?: WidgetSessionActivationData | WidgetSessionClient | null;
192
370
  }
193
371
 
194
372
  export declare interface RoomViewerScene {
@@ -239,4 +417,53 @@ export declare interface RoomViewerSceneShading {
239
417
 
240
418
  declare type RoomViewerSource = 'default' | 'shopify';
241
419
 
420
+ declare type RoomViewerSurface = 'dialog' | 'inline';
421
+
422
+ declare const WIDGET_SESSION_TOKEN_HEADER = "x-widget-session-token";
423
+
424
+ export declare interface WidgetSessionActivationData {
425
+ token: string;
426
+ sid: string;
427
+ expiresIn: number;
428
+ }
429
+
430
+ declare interface WidgetSessionApiConfig {
431
+ baseURL?: string;
432
+ headers?: Record<string, string | undefined>;
433
+ signal?: AbortSignal;
434
+ }
435
+
436
+ declare class WidgetSessionClient {
437
+ private apiConfig;
438
+ private issueWidgetToken;
439
+ private now;
440
+ private refreshPromise;
441
+ private refreshThresholdMs;
442
+ private session;
443
+ constructor(activationData: WidgetSessionActivationData, options?: WidgetSessionClientOptions);
444
+ get snapshot(): WidgetSessionSnapshot;
445
+ get token(): string;
446
+ get sid(): string;
447
+ get expiresAt(): number;
448
+ isCloseToExpiry(): boolean;
449
+ getTokenForRequest(): Promise<string>;
450
+ getHeadersForRequest(): Promise<Record<typeof WIDGET_SESSION_TOKEN_HEADER, string>>;
451
+ getApiConfigForRequest(apiConfig?: WidgetSessionApiConfig): Promise<WidgetSessionApiConfig>;
452
+ private refresh;
453
+ private toSnapshot;
454
+ }
455
+
456
+ declare interface WidgetSessionClientOptions {
457
+ apiConfig?: WidgetSessionApiConfig;
458
+ issueWidgetToken?: IssueWidgetToken;
459
+ now?: () => number;
460
+ refreshThresholdMs?: number;
461
+ }
462
+
463
+ declare interface WidgetSessionSnapshot {
464
+ token: string;
465
+ sid: string;
466
+ expiresAt: number;
467
+ }
468
+
242
469
  export { }