@neurodyn/react-room-viewer 0.0.26 → 0.0.28
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 +10 -4
- package/dist/index.js +83 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ declare const resources: {
|
|
|
51
51
|
readonly ar: {
|
|
52
52
|
readonly viewInPlace: "View in place";
|
|
53
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
|
|
54
|
+
readonly deviceRequirementsDisclaimer: "*Requires AR-supported device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.";
|
|
55
55
|
};
|
|
56
56
|
readonly legal: {
|
|
57
57
|
readonly termsOfUse: "Terms of Use";
|
|
@@ -189,7 +189,7 @@ declare const resources: {
|
|
|
189
189
|
readonly ar: {
|
|
190
190
|
readonly viewInPlace: "Примерить в комнате";
|
|
191
191
|
readonly scanQrCode: "Отсканируйте этот QR-код камерой телефона, чтобы просмотреть объект в дополненной реальности";
|
|
192
|
-
readonly deviceRequirementsDisclaimer: "*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS
|
|
192
|
+
readonly deviceRequirementsDisclaimer: "*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.";
|
|
193
193
|
};
|
|
194
194
|
readonly legal: {
|
|
195
195
|
readonly termsOfUse: "Условия использования";
|
|
@@ -309,9 +309,9 @@ declare const resources: {
|
|
|
309
309
|
};
|
|
310
310
|
};
|
|
311
311
|
|
|
312
|
-
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;
|
|
312
|
+
export declare function RoomViewer({ type, src, tinuuid, roomId, name, language, width, height, dimensionUnit, displayUnit, apiKey, source, widgetSession, className, ...props }: RoomViewerProps & React_2.ComponentProps<'div'>): JSX.Element;
|
|
313
313
|
|
|
314
|
-
export declare function RoomViewerDialog({ type, src, tinuuid, width, height, dimensionUnit, displayUnit, name, language, apiKey, source, widgetSession, disableClose, open, defaultOpen, onOpenChange, }: RoomViewerDialogProps): JSX.Element;
|
|
314
|
+
export declare function RoomViewerDialog({ type, src, tinuuid, roomId, width, height, dimensionUnit, displayUnit, name, language, apiKey, source, widgetSession, disableClose, open, defaultOpen, onOpenChange, }: RoomViewerDialogProps): JSX.Element;
|
|
315
315
|
|
|
316
316
|
declare interface RoomViewerDialogProps extends Omit<RoomViewerRootProps, 'showDialogCloseButton' | 'viewerSurface' | 'dialogPortalContainer' | 'viewerDialogOpen' | 'onViewerDialogOpenChange'>, Omit<DialogProps, 'children' | 'modal'> {
|
|
317
317
|
/** Hide close controls and prevent user dismissal for rugs and flooring. Defaults to false. */
|
|
@@ -378,6 +378,12 @@ declare interface RoomViewerRootProps {
|
|
|
378
378
|
src?: string;
|
|
379
379
|
/** The object's tinuuid. Used for modelled products (`rugs`, `flooring`, `wall-panel`). */
|
|
380
380
|
tinuuid?: string;
|
|
381
|
+
/**
|
|
382
|
+
* Initial Room from the available catalog. Skips the new layout's initial chooser.
|
|
383
|
+
* Changed nonempty values select another Room; empty values do nothing.
|
|
384
|
+
* Ignored by the legacy poster layout.
|
|
385
|
+
*/
|
|
386
|
+
roomId?: string;
|
|
381
387
|
/** Title shown in the dialog header. */
|
|
382
388
|
name: string;
|
|
383
389
|
/**
|
package/dist/index.js
CHANGED
|
@@ -6672,7 +6672,7 @@ const ns1 = {
|
|
|
6672
6672
|
ar: {
|
|
6673
6673
|
viewInPlace: 'View in place',
|
|
6674
6674
|
scanQrCode: 'Scan this QR code with your phone\'s camera to view the object in Augmented Reality',
|
|
6675
|
-
deviceRequirementsDisclaimer: '*Requires AR-supported device and browser. We recommend iOS
|
|
6675
|
+
deviceRequirementsDisclaimer: '*Requires AR-supported device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.'
|
|
6676
6676
|
},
|
|
6677
6677
|
legal: {
|
|
6678
6678
|
termsOfUse: 'Terms of Use',
|
|
@@ -6809,7 +6809,7 @@ const ns1_ns1 = {
|
|
|
6809
6809
|
ar: {
|
|
6810
6810
|
viewInPlace: 'Примерить в комнате',
|
|
6811
6811
|
scanQrCode: 'Отсканируйте этот QR-код камерой телефона, чтобы просмотреть объект в дополненной реальности',
|
|
6812
|
-
deviceRequirementsDisclaimer: '*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS
|
|
6812
|
+
deviceRequirementsDisclaimer: '*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.'
|
|
6813
6813
|
},
|
|
6814
6814
|
legal: {
|
|
6815
6815
|
termsOfUse: 'Условия использования',
|
|
@@ -20003,6 +20003,20 @@ function getInitialFloorViewerFlowState(viewerSurface) {
|
|
|
20003
20003
|
}
|
|
20004
20004
|
function reduceFloorViewerFlow(state, action) {
|
|
20005
20005
|
switch(action.type){
|
|
20006
|
+
case 'clear-interior-selection':
|
|
20007
|
+
return {
|
|
20008
|
+
...state,
|
|
20009
|
+
step: 'interior-selection',
|
|
20010
|
+
hasSceneSelection: false,
|
|
20011
|
+
automaticRoomId: action.automaticRoomId
|
|
20012
|
+
};
|
|
20013
|
+
case 'select-initial-room':
|
|
20014
|
+
return {
|
|
20015
|
+
step: 'scene',
|
|
20016
|
+
hasSceneSelection: true,
|
|
20017
|
+
sceneResetKey: state.sceneResetKey + 1,
|
|
20018
|
+
automaticRoomId: action.roomId
|
|
20019
|
+
};
|
|
20006
20020
|
case 'open-interior-selection':
|
|
20007
20021
|
return {
|
|
20008
20022
|
...state,
|
|
@@ -20414,8 +20428,18 @@ function useCustomInteriorIntakeFlow({ apiOptions, floorFlow, commitCustomInteri
|
|
|
20414
20428
|
uploadRetryRequestId
|
|
20415
20429
|
]);
|
|
20416
20430
|
}
|
|
20417
|
-
function useFloorViewerFlow(viewerSurface, resetHandlers) {
|
|
20431
|
+
function useFloorViewerFlow(viewerSurface, resetHandlers, initialRoomSelection) {
|
|
20418
20432
|
const [state, dispatch] = (0, __rspack_external_react.useReducer)(reduceFloorViewerFlow, viewerSurface, getInitialFloorViewerFlowState);
|
|
20433
|
+
const [appliedInitialRoomId, setAppliedInitialRoomId] = (0, __rspack_external_react.useState)();
|
|
20434
|
+
if (!initialRoomSelection?.isPending && appliedInitialRoomId !== initialRoomSelection?.roomId) {
|
|
20435
|
+
setAppliedInitialRoomId(initialRoomSelection?.roomId);
|
|
20436
|
+
if (initialRoomSelection) dispatch(initialRoomSelection.isAvailable ? {
|
|
20437
|
+
type: 'select-initial-room',
|
|
20438
|
+
roomId: initialRoomSelection.roomId
|
|
20439
|
+
} : {
|
|
20440
|
+
type: 'clear-interior-selection'
|
|
20441
|
+
});
|
|
20442
|
+
}
|
|
20419
20443
|
const commitInteriorSelection = (0, __rspack_external_react.useCallback)((applySelection)=>{
|
|
20420
20444
|
applySelection();
|
|
20421
20445
|
resetSceneState(resetHandlers);
|
|
@@ -20445,6 +20469,14 @@ function useFloorViewerFlow(viewerSurface, resetHandlers) {
|
|
|
20445
20469
|
type: 'return-to-interior-selection'
|
|
20446
20470
|
});
|
|
20447
20471
|
}, []);
|
|
20472
|
+
const clearInteriorSelection = (0, __rspack_external_react.useCallback)(()=>{
|
|
20473
|
+
dispatch({
|
|
20474
|
+
type: 'clear-interior-selection',
|
|
20475
|
+
automaticRoomId: state.automaticRoomId
|
|
20476
|
+
});
|
|
20477
|
+
}, [
|
|
20478
|
+
state.automaticRoomId
|
|
20479
|
+
]);
|
|
20448
20480
|
const startCustomInteriorProcessing = (0, __rspack_external_react.useCallback)(()=>{
|
|
20449
20481
|
dispatch({
|
|
20450
20482
|
type: 'start-custom-interior-processing'
|
|
@@ -20457,6 +20489,7 @@ function useFloorViewerFlow(viewerSurface, resetHandlers) {
|
|
|
20457
20489
|
openInteriorSelection,
|
|
20458
20490
|
recoverToScene,
|
|
20459
20491
|
returnToInteriorSelection,
|
|
20492
|
+
clearInteriorSelection,
|
|
20460
20493
|
startCustomInteriorProcessing
|
|
20461
20494
|
}), [
|
|
20462
20495
|
commitInteriorSelection,
|
|
@@ -20464,11 +20497,15 @@ function useFloorViewerFlow(viewerSurface, resetHandlers) {
|
|
|
20464
20497
|
openInteriorSelection,
|
|
20465
20498
|
recoverToScene,
|
|
20466
20499
|
returnToInteriorSelection,
|
|
20500
|
+
clearInteriorSelection,
|
|
20467
20501
|
startCustomInteriorProcessing,
|
|
20468
20502
|
state
|
|
20469
20503
|
]);
|
|
20470
20504
|
}
|
|
20471
20505
|
function useRoomViewerFloorFlow(viewerSurface) {
|
|
20506
|
+
const { initialRoomId, room, sourceRooms } = useRoomViewerRooms();
|
|
20507
|
+
const { isViewerAccessPending, loadError, setLoadError } = useRoomViewerResource();
|
|
20508
|
+
const { type } = useRoomViewerMetadata();
|
|
20472
20509
|
const { patchSceneLoad, setAngle, setRotation } = useRoomViewerSceneState();
|
|
20473
20510
|
const resetHandlers = (0, __rspack_external_react.useMemo)(()=>({
|
|
20474
20511
|
patchSceneLoad,
|
|
@@ -20479,7 +20516,27 @@ function useRoomViewerFloorFlow(viewerSurface) {
|
|
|
20479
20516
|
setAngle,
|
|
20480
20517
|
setRotation
|
|
20481
20518
|
]);
|
|
20482
|
-
|
|
20519
|
+
const initialRoom = sourceRooms.find((room)=>room.id === initialRoomId);
|
|
20520
|
+
const isAvailable = Boolean(initialRoom) && (!initialRoom?.scene || getAllowedRoomScenePlanes(initialRoom.scene, resolveResourceSurfaces(type)).length > 0);
|
|
20521
|
+
const floorFlow = useFloorViewerFlow(viewerSurface, resetHandlers, initialRoomId ? {
|
|
20522
|
+
roomId: initialRoomId,
|
|
20523
|
+
isAvailable,
|
|
20524
|
+
isPending: isViewerAccessPending
|
|
20525
|
+
} : void 0);
|
|
20526
|
+
const { automaticRoomId, clearInteriorSelection } = floorFlow;
|
|
20527
|
+
(0, __rspack_external_react.useEffect)(()=>{
|
|
20528
|
+
if (automaticRoomId && room.id === automaticRoomId && 'room-load-failed' === loadError) {
|
|
20529
|
+
clearInteriorSelection();
|
|
20530
|
+
setLoadError(null);
|
|
20531
|
+
}
|
|
20532
|
+
}, [
|
|
20533
|
+
automaticRoomId,
|
|
20534
|
+
clearInteriorSelection,
|
|
20535
|
+
loadError,
|
|
20536
|
+
room.id,
|
|
20537
|
+
setLoadError
|
|
20538
|
+
]);
|
|
20539
|
+
return floorFlow;
|
|
20483
20540
|
}
|
|
20484
20541
|
function useRoomViewerFloorInteriorSelectionCommands(options) {
|
|
20485
20542
|
const { room, setRoomId, setRooms } = useRoomViewerRooms();
|
|
@@ -21202,10 +21259,11 @@ function mergeRuntimeRooms(currentRooms, currentSourceRooms, nextSourceRooms) {
|
|
|
21202
21259
|
...nextSourceRooms
|
|
21203
21260
|
] : nextSourceRooms;
|
|
21204
21261
|
}
|
|
21205
|
-
function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, type, viewerSurface, dialogPortalContainer = null, viewerDialogOpen = true, onViewerDialogOpenChange, width, height, displayUnit, name, apiKey, baseURL, source, externalWidgetSession }) {
|
|
21262
|
+
function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: configuredRoomId, type, viewerSurface, dialogPortalContainer = null, viewerDialogOpen = true, onViewerDialogOpenChange, width, height, displayUnit, name, apiKey, baseURL, source, externalWidgetSession }) {
|
|
21206
21263
|
const frameWidthOptions = useFrameWidthOptions();
|
|
21207
21264
|
const mattingOptions = useMattingOptions(displayUnit);
|
|
21208
21265
|
const identity = resolveResourceIdentityAnswers(type);
|
|
21266
|
+
const initialRoomId = 'immersive-room' === resolveResourceProfile(type).chrome ? configuredRoomId?.trim() || void 0 : void 0;
|
|
21209
21267
|
const hasPanelFinishes = 'finish' === resolveResourceProfile(type).materialRole;
|
|
21210
21268
|
const { offersSizeVariants } = resolveProductCompositionAnswers(type);
|
|
21211
21269
|
const defaultRooms = resolveRoomPresets(resolveResourceProfile(type).roomPresets);
|
|
@@ -21348,7 +21406,18 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, type, view
|
|
|
21348
21406
|
}, [
|
|
21349
21407
|
sourceRooms
|
|
21350
21408
|
]);
|
|
21351
|
-
const [roomId, setRoomId] = (0, __rspack_external_react.useState)(()=>defaultRooms[0].id);
|
|
21409
|
+
const [roomId, setRoomId] = (0, __rspack_external_react.useState)(()=>initialRoomId ?? defaultRooms[0].id);
|
|
21410
|
+
const [previousInitialRoomId, setPreviousInitialRoomId] = (0, __rspack_external_react.useState)(initialRoomId);
|
|
21411
|
+
if (previousInitialRoomId !== initialRoomId) {
|
|
21412
|
+
setPreviousInitialRoomId(initialRoomId);
|
|
21413
|
+
if (initialRoomId) {
|
|
21414
|
+
setRoomId(initialRoomId);
|
|
21415
|
+
setAngle(0);
|
|
21416
|
+
setRotation(0);
|
|
21417
|
+
setSceneLoad(getInitialSceneLoadState(identity));
|
|
21418
|
+
setLoadError((current)=>'room-load-failed' === current ? null : current);
|
|
21419
|
+
}
|
|
21420
|
+
}
|
|
21352
21421
|
const selectedRoom = rooms.find((currentRoom)=>currentRoom.id === roomId);
|
|
21353
21422
|
const room = selectedRoom ?? rooms[0] ?? defaultRooms[0];
|
|
21354
21423
|
const resetsRotationOnRoomChange = 'rotate-on-floor' === resolveResourceProfile(type).manipulation;
|
|
@@ -21591,10 +21660,12 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, type, view
|
|
|
21591
21660
|
sourceRooms,
|
|
21592
21661
|
setRooms,
|
|
21593
21662
|
room,
|
|
21663
|
+
initialRoomId,
|
|
21594
21664
|
setRoomId
|
|
21595
21665
|
}), [
|
|
21596
21666
|
rooms,
|
|
21597
21667
|
room,
|
|
21668
|
+
initialRoomId,
|
|
21598
21669
|
setRooms,
|
|
21599
21670
|
sourceRooms
|
|
21600
21671
|
]);
|
|
@@ -21733,7 +21804,7 @@ const root_queryClient = new QueryClient({
|
|
|
21733
21804
|
}
|
|
21734
21805
|
}
|
|
21735
21806
|
});
|
|
21736
|
-
function RoomViewerRoot({ type, src, tinuuid, name, height, width, language, dimensionUnit = "m", displayUnit = "cm", apiKey, source = 'default', showDialogCloseButton = false, viewerSurface = 'inline', dialogPortalContainer = null, viewerDialogOpen = true, onViewerDialogOpenChange, widgetSession }) {
|
|
21807
|
+
function RoomViewerRoot({ type, src, tinuuid, roomId, name, height, width, language, dimensionUnit = "m", displayUnit = "cm", apiKey, source = 'default', showDialogCloseButton = false, viewerSurface = 'inline', dialogPortalContainer = null, viewerDialogOpen = true, onViewerDialogOpenChange, widgetSession }) {
|
|
21737
21808
|
const { i18n } = useTranslation();
|
|
21738
21809
|
const normalizedApiKey = normalizeRoomViewerApiKey(apiKey);
|
|
21739
21810
|
const normalizedTinuuid = normalizeRoomViewerTinuuid(tinuuid);
|
|
@@ -21756,6 +21827,7 @@ function RoomViewerRoot({ type, src, tinuuid, name, height, width, language, dim
|
|
|
21756
21827
|
children: /*#__PURE__*/ jsx_runtime_jsx(RoomViewerProvider, {
|
|
21757
21828
|
src: src ?? null,
|
|
21758
21829
|
tinuuid: normalizedTinuuid ?? null,
|
|
21830
|
+
roomId: roomId,
|
|
21759
21831
|
type: resourceType,
|
|
21760
21832
|
viewerSurface: viewerSurface,
|
|
21761
21833
|
dialogPortalContainer: dialogPortalContainer,
|
|
@@ -21781,7 +21853,7 @@ configureApiClient({
|
|
|
21781
21853
|
configureNodeApiClient({
|
|
21782
21854
|
baseURL: config_env.NODE_API_BASE_URL
|
|
21783
21855
|
});
|
|
21784
|
-
function RoomViewerDialog({ type, src, tinuuid, width, height, dimensionUnit, displayUnit, name, language, apiKey, source, widgetSession, disableClose = false, open, defaultOpen, onOpenChange }) {
|
|
21856
|
+
function RoomViewerDialog({ type, src, tinuuid, roomId, width, height, dimensionUnit, displayUnit, name, language, apiKey, source, widgetSession, disableClose = false, open, defaultOpen, onOpenChange }) {
|
|
21785
21857
|
const [themeRoot, setThemeRoot] = (0, __rspack_external_react.useState)(null);
|
|
21786
21858
|
const isCloseDisabled = 'immersive-room' === resolveResourceProfile(normalizeResourceType(type)).chrome && disableClose;
|
|
21787
21859
|
const [uncontrolledOpen, setUncontrolledOpen] = (0, __rspack_external_react.useState)(defaultOpen ?? false);
|
|
@@ -21802,6 +21874,7 @@ function RoomViewerDialog({ type, src, tinuuid, width, height, dimensionUnit, di
|
|
|
21802
21874
|
type: type,
|
|
21803
21875
|
src: src,
|
|
21804
21876
|
tinuuid: tinuuid,
|
|
21877
|
+
roomId: roomId,
|
|
21805
21878
|
name: name,
|
|
21806
21879
|
height: height,
|
|
21807
21880
|
width: width,
|
|
@@ -21853,7 +21926,7 @@ function RoomViewerDialog({ type, src, tinuuid, width, height, dimensionUnit, di
|
|
|
21853
21926
|
]
|
|
21854
21927
|
});
|
|
21855
21928
|
}
|
|
21856
|
-
function RoomViewer({ type, src, tinuuid, name, language, width, height, dimensionUnit, displayUnit, apiKey, source, widgetSession, className, ...props }) {
|
|
21929
|
+
function RoomViewer({ type, src, tinuuid, roomId, name, language, width, height, dimensionUnit, displayUnit, apiKey, source, widgetSession, className, ...props }) {
|
|
21857
21930
|
const [themeRoot, setThemeRoot] = (0, __rspack_external_react.useState)(null);
|
|
21858
21931
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
21859
21932
|
children: [
|
|
@@ -21889,6 +21962,7 @@ function RoomViewer({ type, src, tinuuid, name, language, width, height, dimensi
|
|
|
21889
21962
|
type: type,
|
|
21890
21963
|
src: src,
|
|
21891
21964
|
tinuuid: tinuuid,
|
|
21965
|
+
roomId: roomId,
|
|
21892
21966
|
name: name,
|
|
21893
21967
|
language: language,
|
|
21894
21968
|
width: width,
|