@neurodyn/react-room-viewer 0.0.28 → 0.0.29
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.js +41 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7665,18 +7665,25 @@ function sendWidgetEvent(session, event, options = {}) {
|
|
|
7665
7665
|
}
|
|
7666
7666
|
async function getRoomViewerPublicApiHeaders(options) {
|
|
7667
7667
|
const headers = {
|
|
7668
|
-
'x-api-key': options.apiKey
|
|
7668
|
+
'x-api-key': options.apiKey,
|
|
7669
|
+
...getRoomViewerLanguageHeaders(options)
|
|
7669
7670
|
};
|
|
7670
7671
|
const token = await options.widgetSession?.getTokenForRequest();
|
|
7671
7672
|
if (token) headers[WIDGET_SESSION_TOKEN_HEADER] = token;
|
|
7672
7673
|
return headers;
|
|
7673
7674
|
}
|
|
7675
|
+
function getRoomViewerLanguageHeaders(options) {
|
|
7676
|
+
return options.language ? {
|
|
7677
|
+
Lang: options.language
|
|
7678
|
+
} : void 0;
|
|
7679
|
+
}
|
|
7674
7680
|
function roomViewerObjectQueryKey(tinuuid, options) {
|
|
7675
7681
|
return [
|
|
7676
7682
|
'room-viewer',
|
|
7677
7683
|
'object',
|
|
7678
7684
|
{
|
|
7679
7685
|
apiKey: options.apiKey ?? null,
|
|
7686
|
+
language: options.language ?? null,
|
|
7680
7687
|
source: options.source,
|
|
7681
7688
|
tinuuid: tinuuid ?? null,
|
|
7682
7689
|
resourceType: options.resourceType ?? null
|
|
@@ -7689,6 +7696,7 @@ function roomViewerOwnerObjectsQueryKey(ownerUuid, options) {
|
|
|
7689
7696
|
'public-objects',
|
|
7690
7697
|
{
|
|
7691
7698
|
apiKey: options.apiKey ?? null,
|
|
7699
|
+
language: options.language ?? null,
|
|
7692
7700
|
ownerUuid: ownerUuid ?? null,
|
|
7693
7701
|
resourceType: options.resourceType ?? null,
|
|
7694
7702
|
source: options.source
|
|
@@ -7701,6 +7709,7 @@ function roomViewerKitObjectsQueryKey(kitUuid, ownerUuid, options) {
|
|
|
7701
7709
|
'kit-objects',
|
|
7702
7710
|
{
|
|
7703
7711
|
apiKey: options.apiKey ?? null,
|
|
7712
|
+
language: options.language ?? null,
|
|
7704
7713
|
kitUuid: kitUuid ?? null,
|
|
7705
7714
|
ownerUuid: ownerUuid ?? null,
|
|
7706
7715
|
resourceType: options.resourceType ?? null,
|
|
@@ -7712,6 +7721,7 @@ async function fetchRoomViewerObject(tinuuid, options) {
|
|
|
7712
7721
|
if (!shouldUseRoomViewerPublicApi(options)) return objFetch({
|
|
7713
7722
|
tinuuid
|
|
7714
7723
|
}, {
|
|
7724
|
+
headers: getRoomViewerLanguageHeaders(options),
|
|
7715
7725
|
signal: options.signal
|
|
7716
7726
|
});
|
|
7717
7727
|
const { query, config } = getRoomViewerPublicApiQuery(options);
|
|
@@ -7735,6 +7745,7 @@ async function fetchRoomViewerOwnerObjects(ownerUuid, page, options) {
|
|
|
7735
7745
|
...data,
|
|
7736
7746
|
productType: getRoomViewerBackendProductType(options)
|
|
7737
7747
|
}, {
|
|
7748
|
+
headers: getRoomViewerLanguageHeaders(options),
|
|
7738
7749
|
signal: options.signal
|
|
7739
7750
|
});
|
|
7740
7751
|
const { query, config } = getRoomViewerPublicApiQuery(options);
|
|
@@ -7762,6 +7773,7 @@ async function fetchRoomViewerKitObjects(kitUuid, _ownerUuid, page, options) {
|
|
|
7762
7773
|
page
|
|
7763
7774
|
}, {
|
|
7764
7775
|
baseURL: getRoomViewerBackendApiBaseUrl(options.baseURL),
|
|
7776
|
+
headers: getRoomViewerLanguageHeaders(options),
|
|
7765
7777
|
signal: options.signal
|
|
7766
7778
|
});
|
|
7767
7779
|
return {
|
|
@@ -7776,6 +7788,7 @@ function roomViewerRoomsQueryKey(options) {
|
|
|
7776
7788
|
'rooms',
|
|
7777
7789
|
{
|
|
7778
7790
|
apiKey: options.apiKey ?? null,
|
|
7791
|
+
language: options.language ?? null,
|
|
7779
7792
|
source: options.source,
|
|
7780
7793
|
resourceType: options.resourceType ?? null,
|
|
7781
7794
|
widgetSessionId: options.widgetSession?.sid ?? null
|
|
@@ -8900,17 +8913,19 @@ function getRoomViewerOwnerObjectsNextPage(lastPage, lastPageParam) {
|
|
|
8900
8913
|
return lastPageParam + 1;
|
|
8901
8914
|
}
|
|
8902
8915
|
function useRoomViewerWallResourceMaterialOptions() {
|
|
8903
|
-
const { material, setMaterial, setTinuuid, apiKey, baseURL, source, widgetSession } = useRoomViewerResource();
|
|
8916
|
+
const { material, setMaterial, setTinuuid, apiKey, baseURL, language, source, widgetSession } = useRoomViewerResource();
|
|
8904
8917
|
const queries = useQueries({
|
|
8905
8918
|
queries: RAM_TINUUIDS.map((tinuuid)=>({
|
|
8906
8919
|
queryKey: roomViewerObjectQueryKey(tinuuid, {
|
|
8907
8920
|
apiKey,
|
|
8908
8921
|
baseURL,
|
|
8922
|
+
language,
|
|
8909
8923
|
source
|
|
8910
8924
|
}),
|
|
8911
8925
|
queryFn: ({ signal })=>fetchRoomViewerObject(tinuuid, {
|
|
8912
8926
|
apiKey,
|
|
8913
8927
|
baseURL,
|
|
8928
|
+
language,
|
|
8914
8929
|
signal,
|
|
8915
8930
|
source,
|
|
8916
8931
|
widgetSession
|
|
@@ -8963,13 +8978,14 @@ function useRoomViewerWallResourceMaterialOptions() {
|
|
|
8963
8978
|
};
|
|
8964
8979
|
}
|
|
8965
8980
|
function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
|
|
8966
|
-
const { material, tinuuid, embeddedObject, selectedObject, setMaterial, setTinuuid, apiKey, baseURL, source, widgetSession, setAccessError, setLoadError } = useRoomViewerResource();
|
|
8981
|
+
const { material, tinuuid, embeddedObject, selectedObject, setMaterial, setTinuuid, apiKey, baseURL, language, source, widgetSession, setAccessError, setLoadError } = useRoomViewerResource();
|
|
8967
8982
|
const { type, name } = useRoomViewerMetadata();
|
|
8968
8983
|
const ownerUuid = embeddedObject?.owner?.uuid;
|
|
8969
8984
|
const { data, error, isFetchingNextPage, fetchNextPage, hasNextPage, isLoading } = useInfiniteQuery({
|
|
8970
8985
|
queryKey: roomViewerOwnerObjectsQueryKey(ownerUuid, {
|
|
8971
8986
|
apiKey,
|
|
8972
8987
|
baseURL,
|
|
8988
|
+
language,
|
|
8973
8989
|
source,
|
|
8974
8990
|
resourceType: type
|
|
8975
8991
|
}),
|
|
@@ -8979,6 +8995,7 @@ function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
|
|
|
8979
8995
|
return fetchRoomViewerOwnerObjects(ownerUuid, pageParam, {
|
|
8980
8996
|
apiKey,
|
|
8981
8997
|
baseURL,
|
|
8998
|
+
language,
|
|
8982
8999
|
signal,
|
|
8983
9000
|
source,
|
|
8984
9001
|
widgetSession,
|
|
@@ -9006,12 +9023,14 @@ function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
|
|
|
9006
9023
|
queryKey: roomViewerObjectQueryKey(object.tinuuid, {
|
|
9007
9024
|
apiKey,
|
|
9008
9025
|
baseURL,
|
|
9026
|
+
language,
|
|
9009
9027
|
source,
|
|
9010
9028
|
resourceType: type
|
|
9011
9029
|
}),
|
|
9012
9030
|
queryFn: ({ signal })=>fetchRoomViewerObject(object.tinuuid, {
|
|
9013
9031
|
apiKey,
|
|
9014
9032
|
baseURL,
|
|
9033
|
+
language,
|
|
9015
9034
|
signal,
|
|
9016
9035
|
source,
|
|
9017
9036
|
widgetSession,
|
|
@@ -14892,13 +14911,14 @@ function panelModelQuery(url) {
|
|
|
14892
14911
|
};
|
|
14893
14912
|
}
|
|
14894
14913
|
function usePanelMaterials(currentObject, enabled) {
|
|
14895
|
-
const { apiKey, baseURL, source, widgetSession } = useRoomViewerResource();
|
|
14914
|
+
const { apiKey, baseURL, language, source, widgetSession } = useRoomViewerResource();
|
|
14896
14915
|
const { type } = useRoomViewerMetadata();
|
|
14897
14916
|
const kitUuid = currentObject?.kit?.uuid;
|
|
14898
14917
|
const ownerUuid = currentObject?.owner?.uuid;
|
|
14899
14918
|
const options = {
|
|
14900
14919
|
apiKey,
|
|
14901
14920
|
baseURL,
|
|
14921
|
+
language,
|
|
14902
14922
|
source,
|
|
14903
14923
|
widgetSession,
|
|
14904
14924
|
resourceType: type
|
|
@@ -19359,7 +19379,7 @@ function getNextVariantsPage(lastPage, lastPageParam) {
|
|
|
19359
19379
|
return lastPage.objs?.length ? lastPageParam + 1 : void 0;
|
|
19360
19380
|
}
|
|
19361
19381
|
function useRoomViewerVariantCatalog() {
|
|
19362
|
-
const { tinuuid, selectedObject, selectResourceVariant, apiKey, baseURL, source, widgetSession } = useRoomViewerResource();
|
|
19382
|
+
const { tinuuid, selectedObject, selectResourceVariant, apiKey, baseURL, language, source, widgetSession } = useRoomViewerResource();
|
|
19363
19383
|
const { type } = useRoomViewerMetadata();
|
|
19364
19384
|
const { decodeVariant } = resolveProductCompositionAnswers(type);
|
|
19365
19385
|
const kitUuid = selectedObject?.kit?.uuid;
|
|
@@ -19368,6 +19388,7 @@ function useRoomViewerVariantCatalog() {
|
|
|
19368
19388
|
queryKey: roomViewerKitObjectsQueryKey(kitUuid, ownerUuid, {
|
|
19369
19389
|
apiKey,
|
|
19370
19390
|
baseURL,
|
|
19391
|
+
language,
|
|
19371
19392
|
source,
|
|
19372
19393
|
resourceType: type
|
|
19373
19394
|
}),
|
|
@@ -19377,6 +19398,7 @@ function useRoomViewerVariantCatalog() {
|
|
|
19377
19398
|
return fetchRoomViewerKitObjects(kitUuid, ownerUuid, pageParam, {
|
|
19378
19399
|
apiKey,
|
|
19379
19400
|
baseURL,
|
|
19401
|
+
language,
|
|
19380
19402
|
signal,
|
|
19381
19403
|
source,
|
|
19382
19404
|
widgetSession,
|
|
@@ -21230,6 +21252,11 @@ function useFrameWidthOptions() {
|
|
|
21230
21252
|
t
|
|
21231
21253
|
]);
|
|
21232
21254
|
}
|
|
21255
|
+
function useRoomViewerLanguage() {
|
|
21256
|
+
const { i18n } = useTranslation();
|
|
21257
|
+
const language = i18n.resolvedLanguage ?? i18n.language;
|
|
21258
|
+
return 'ru' === language ? 'ru' : 'en';
|
|
21259
|
+
}
|
|
21233
21260
|
function isBlankArtworkSource(src) {
|
|
21234
21261
|
return 'string' != typeof src || 0 === src.trim().length;
|
|
21235
21262
|
}
|
|
@@ -21262,6 +21289,7 @@ function mergeRuntimeRooms(currentRooms, currentSourceRooms, nextSourceRooms) {
|
|
|
21262
21289
|
function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: configuredRoomId, type, viewerSurface, dialogPortalContainer = null, viewerDialogOpen = true, onViewerDialogOpenChange, width, height, displayUnit, name, apiKey, baseURL, source, externalWidgetSession }) {
|
|
21263
21290
|
const frameWidthOptions = useFrameWidthOptions();
|
|
21264
21291
|
const mattingOptions = useMattingOptions(displayUnit);
|
|
21292
|
+
const language = useRoomViewerLanguage();
|
|
21265
21293
|
const identity = resolveResourceIdentityAnswers(type);
|
|
21266
21294
|
const initialRoomId = 'immersive-room' === resolveResourceProfile(type).chrome ? configuredRoomId?.trim() || void 0 : void 0;
|
|
21267
21295
|
const hasPanelFinishes = 'finish' === resolveResourceProfile(type).materialRole;
|
|
@@ -21363,6 +21391,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21363
21391
|
queryKey: roomViewerRoomsQueryKey({
|
|
21364
21392
|
apiKey,
|
|
21365
21393
|
baseURL,
|
|
21394
|
+
language,
|
|
21366
21395
|
source,
|
|
21367
21396
|
widgetSession,
|
|
21368
21397
|
resourceType: type
|
|
@@ -21373,6 +21402,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21373
21402
|
return await fetchRoomViewerRooms({
|
|
21374
21403
|
apiKey,
|
|
21375
21404
|
baseURL,
|
|
21405
|
+
language,
|
|
21376
21406
|
signal,
|
|
21377
21407
|
source,
|
|
21378
21408
|
widgetSession,
|
|
@@ -21434,6 +21464,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21434
21464
|
queryKey: roomViewerObjectQueryKey(initialTinuuid ?? void 0, {
|
|
21435
21465
|
apiKey,
|
|
21436
21466
|
baseURL,
|
|
21467
|
+
language,
|
|
21437
21468
|
source,
|
|
21438
21469
|
resourceType: type
|
|
21439
21470
|
}),
|
|
@@ -21443,6 +21474,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21443
21474
|
return fetchRoomViewerObject(initialTinuuid, {
|
|
21444
21475
|
apiKey,
|
|
21445
21476
|
baseURL,
|
|
21477
|
+
language,
|
|
21446
21478
|
signal,
|
|
21447
21479
|
source,
|
|
21448
21480
|
widgetSession,
|
|
@@ -21454,6 +21486,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21454
21486
|
queryKey: roomViewerObjectQueryKey(tinuuid ?? void 0, {
|
|
21455
21487
|
apiKey,
|
|
21456
21488
|
baseURL,
|
|
21489
|
+
language,
|
|
21457
21490
|
source,
|
|
21458
21491
|
resourceType: type
|
|
21459
21492
|
}),
|
|
@@ -21464,6 +21497,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21464
21497
|
return fetchRoomViewerObject(tinuuid, {
|
|
21465
21498
|
apiKey,
|
|
21466
21499
|
baseURL,
|
|
21500
|
+
language,
|
|
21467
21501
|
signal,
|
|
21468
21502
|
source,
|
|
21469
21503
|
widgetSession,
|
|
@@ -21681,6 +21715,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21681
21715
|
setMaterial,
|
|
21682
21716
|
apiKey,
|
|
21683
21717
|
baseURL,
|
|
21718
|
+
language,
|
|
21684
21719
|
source,
|
|
21685
21720
|
widgetSession,
|
|
21686
21721
|
hasRooms,
|
|
@@ -21700,6 +21735,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
|
|
|
21700
21735
|
selectResourceVariant,
|
|
21701
21736
|
apiKey,
|
|
21702
21737
|
baseURL,
|
|
21738
|
+
language,
|
|
21703
21739
|
source,
|
|
21704
21740
|
widgetSession,
|
|
21705
21741
|
hasRooms,
|