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