@neurodyn/react-room-viewer 0.0.28 → 0.0.30

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
@@ -52,6 +52,8 @@ declare const resources: {
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
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
+ readonly appClipScanTitle: "Scan with your phone camera";
56
+ readonly appClipRequirement: "AR view works on iOS 18 or later";
55
57
  };
56
58
  readonly legal: {
57
59
  readonly termsOfUse: "Terms of Use";
@@ -190,6 +192,8 @@ declare const resources: {
190
192
  readonly viewInPlace: "Примерить в комнате";
191
193
  readonly scanQrCode: "Отсканируйте этот QR-код камерой телефона, чтобы просмотреть объект в дополненной реальности";
192
194
  readonly deviceRequirementsDisclaimer: "*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.";
195
+ readonly appClipScanTitle: "Наведите камеру телефона";
196
+ readonly appClipRequirement: "AR-просмотр работает на iOS 18 и новее";
193
197
  };
194
198
  readonly legal: {
195
199
  readonly termsOfUse: "Условия использования";
package/dist/index.js CHANGED
@@ -6672,7 +6672,9 @@ 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 18 or later with Safari, or Android 7.0 or later with Chrome.'
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
+ appClipScanTitle: 'Scan with your phone camera',
6677
+ appClipRequirement: 'AR view works on iOS 18 or later'
6676
6678
  },
6677
6679
  legal: {
6678
6680
  termsOfUse: 'Terms of Use',
@@ -6809,7 +6811,9 @@ const ns1_ns1 = {
6809
6811
  ar: {
6810
6812
  viewInPlace: 'Примерить в комнате',
6811
6813
  scanQrCode: 'Отсканируйте этот QR-код камерой телефона, чтобы просмотреть объект в дополненной реальности',
6812
- deviceRequirementsDisclaimer: '*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.'
6814
+ deviceRequirementsDisclaimer: '*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.',
6815
+ appClipScanTitle: 'Наведите камеру телефона',
6816
+ appClipRequirement: 'AR-просмотр работает на iOS 18 и новее'
6813
6817
  },
6814
6818
  legal: {
6815
6819
  termsOfUse: 'Условия использования',
@@ -7665,18 +7669,25 @@ function sendWidgetEvent(session, event, options = {}) {
7665
7669
  }
7666
7670
  async function getRoomViewerPublicApiHeaders(options) {
7667
7671
  const headers = {
7668
- 'x-api-key': options.apiKey
7672
+ 'x-api-key': options.apiKey,
7673
+ ...getRoomViewerLanguageHeaders(options)
7669
7674
  };
7670
7675
  const token = await options.widgetSession?.getTokenForRequest();
7671
7676
  if (token) headers[WIDGET_SESSION_TOKEN_HEADER] = token;
7672
7677
  return headers;
7673
7678
  }
7679
+ function getRoomViewerLanguageHeaders(options) {
7680
+ return options.language ? {
7681
+ Lang: options.language
7682
+ } : void 0;
7683
+ }
7674
7684
  function roomViewerObjectQueryKey(tinuuid, options) {
7675
7685
  return [
7676
7686
  'room-viewer',
7677
7687
  'object',
7678
7688
  {
7679
7689
  apiKey: options.apiKey ?? null,
7690
+ language: options.language ?? null,
7680
7691
  source: options.source,
7681
7692
  tinuuid: tinuuid ?? null,
7682
7693
  resourceType: options.resourceType ?? null
@@ -7689,6 +7700,7 @@ function roomViewerOwnerObjectsQueryKey(ownerUuid, options) {
7689
7700
  'public-objects',
7690
7701
  {
7691
7702
  apiKey: options.apiKey ?? null,
7703
+ language: options.language ?? null,
7692
7704
  ownerUuid: ownerUuid ?? null,
7693
7705
  resourceType: options.resourceType ?? null,
7694
7706
  source: options.source
@@ -7701,6 +7713,7 @@ function roomViewerKitObjectsQueryKey(kitUuid, ownerUuid, options) {
7701
7713
  'kit-objects',
7702
7714
  {
7703
7715
  apiKey: options.apiKey ?? null,
7716
+ language: options.language ?? null,
7704
7717
  kitUuid: kitUuid ?? null,
7705
7718
  ownerUuid: ownerUuid ?? null,
7706
7719
  resourceType: options.resourceType ?? null,
@@ -7712,6 +7725,7 @@ async function fetchRoomViewerObject(tinuuid, options) {
7712
7725
  if (!shouldUseRoomViewerPublicApi(options)) return objFetch({
7713
7726
  tinuuid
7714
7727
  }, {
7728
+ headers: getRoomViewerLanguageHeaders(options),
7715
7729
  signal: options.signal
7716
7730
  });
7717
7731
  const { query, config } = getRoomViewerPublicApiQuery(options);
@@ -7735,6 +7749,7 @@ async function fetchRoomViewerOwnerObjects(ownerUuid, page, options) {
7735
7749
  ...data,
7736
7750
  productType: getRoomViewerBackendProductType(options)
7737
7751
  }, {
7752
+ headers: getRoomViewerLanguageHeaders(options),
7738
7753
  signal: options.signal
7739
7754
  });
7740
7755
  const { query, config } = getRoomViewerPublicApiQuery(options);
@@ -7762,6 +7777,7 @@ async function fetchRoomViewerKitObjects(kitUuid, _ownerUuid, page, options) {
7762
7777
  page
7763
7778
  }, {
7764
7779
  baseURL: getRoomViewerBackendApiBaseUrl(options.baseURL),
7780
+ headers: getRoomViewerLanguageHeaders(options),
7765
7781
  signal: options.signal
7766
7782
  });
7767
7783
  return {
@@ -7776,6 +7792,7 @@ function roomViewerRoomsQueryKey(options) {
7776
7792
  'rooms',
7777
7793
  {
7778
7794
  apiKey: options.apiKey ?? null,
7795
+ language: options.language ?? null,
7779
7796
  source: options.source,
7780
7797
  resourceType: options.resourceType ?? null,
7781
7798
  widgetSessionId: options.widgetSession?.sid ?? null
@@ -8900,17 +8917,19 @@ function getRoomViewerOwnerObjectsNextPage(lastPage, lastPageParam) {
8900
8917
  return lastPageParam + 1;
8901
8918
  }
8902
8919
  function useRoomViewerWallResourceMaterialOptions() {
8903
- const { material, setMaterial, setTinuuid, apiKey, baseURL, source, widgetSession } = useRoomViewerResource();
8920
+ const { material, setMaterial, setTinuuid, apiKey, baseURL, language, source, widgetSession } = useRoomViewerResource();
8904
8921
  const queries = useQueries({
8905
8922
  queries: RAM_TINUUIDS.map((tinuuid)=>({
8906
8923
  queryKey: roomViewerObjectQueryKey(tinuuid, {
8907
8924
  apiKey,
8908
8925
  baseURL,
8926
+ language,
8909
8927
  source
8910
8928
  }),
8911
8929
  queryFn: ({ signal })=>fetchRoomViewerObject(tinuuid, {
8912
8930
  apiKey,
8913
8931
  baseURL,
8932
+ language,
8914
8933
  signal,
8915
8934
  source,
8916
8935
  widgetSession
@@ -8963,13 +8982,14 @@ function useRoomViewerWallResourceMaterialOptions() {
8963
8982
  };
8964
8983
  }
8965
8984
  function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
8966
- const { material, tinuuid, embeddedObject, selectedObject, setMaterial, setTinuuid, apiKey, baseURL, source, widgetSession, setAccessError, setLoadError } = useRoomViewerResource();
8985
+ const { material, tinuuid, embeddedObject, selectedObject, setMaterial, setTinuuid, apiKey, baseURL, language, source, widgetSession, setAccessError, setLoadError } = useRoomViewerResource();
8967
8986
  const { type, name } = useRoomViewerMetadata();
8968
8987
  const ownerUuid = embeddedObject?.owner?.uuid;
8969
8988
  const { data, error, isFetchingNextPage, fetchNextPage, hasNextPage, isLoading } = useInfiniteQuery({
8970
8989
  queryKey: roomViewerOwnerObjectsQueryKey(ownerUuid, {
8971
8990
  apiKey,
8972
8991
  baseURL,
8992
+ language,
8973
8993
  source,
8974
8994
  resourceType: type
8975
8995
  }),
@@ -8979,6 +8999,7 @@ function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
8979
8999
  return fetchRoomViewerOwnerObjects(ownerUuid, pageParam, {
8980
9000
  apiKey,
8981
9001
  baseURL,
9002
+ language,
8982
9003
  signal,
8983
9004
  source,
8984
9005
  widgetSession,
@@ -9006,12 +9027,14 @@ function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
9006
9027
  queryKey: roomViewerObjectQueryKey(object.tinuuid, {
9007
9028
  apiKey,
9008
9029
  baseURL,
9030
+ language,
9009
9031
  source,
9010
9032
  resourceType: type
9011
9033
  }),
9012
9034
  queryFn: ({ signal })=>fetchRoomViewerObject(object.tinuuid, {
9013
9035
  apiKey,
9014
9036
  baseURL,
9037
+ language,
9015
9038
  signal,
9016
9039
  source,
9017
9040
  widgetSession,
@@ -14892,13 +14915,14 @@ function panelModelQuery(url) {
14892
14915
  };
14893
14916
  }
14894
14917
  function usePanelMaterials(currentObject, enabled) {
14895
- const { apiKey, baseURL, source, widgetSession } = useRoomViewerResource();
14918
+ const { apiKey, baseURL, language, source, widgetSession } = useRoomViewerResource();
14896
14919
  const { type } = useRoomViewerMetadata();
14897
14920
  const kitUuid = currentObject?.kit?.uuid;
14898
14921
  const ownerUuid = currentObject?.owner?.uuid;
14899
14922
  const options = {
14900
14923
  apiKey,
14901
14924
  baseURL,
14925
+ language,
14902
14926
  source,
14903
14927
  widgetSession,
14904
14928
  resourceType: type
@@ -17911,6 +17935,10 @@ const os = parser.getOS();
17911
17935
  const isIOS = 'iOS' === os.name;
17912
17936
  const isAndroid = 'Android' === os.name;
17913
17937
  const device_isMobile = 'mobile' === device.type;
17938
+ function isArEntryOffered(handoff, tinuuid) {
17939
+ if (!handoff || isAndroid && device_isMobile || isAndroid && 'appclip' === handoff.ar) return false;
17940
+ return 'floor' !== handoff.destination || Boolean(tinuuid);
17941
+ }
17914
17942
  function isAbsoluteUrl(value1) {
17915
17943
  return /^[a-z][a-z0-9+.-]*:/i.test(value1) || value1.startsWith('//');
17916
17944
  }
@@ -18066,7 +18094,8 @@ function AR({ className, buttonClassName, buttonLeadingIcon, buttonLabel, button
18066
18094
  usdzUrl,
18067
18095
  glbUrl
18068
18096
  ]);
18069
- if (!handoff || isAndroid && device_isMobile || 'floor' === handoff.destination && !tinuuid) return null;
18097
+ if (!isArEntryOffered(handoff, tinuuid)) return null;
18098
+ const isAppClip = 'appclip' === handoff.ar;
18070
18099
  return /*#__PURE__*/ jsxs("div", {
18071
18100
  className: utils_cn(className),
18072
18101
  ...props,
@@ -18098,15 +18127,31 @@ function AR({ className, buttonClassName, buttonLeadingIcon, buttonLabel, button
18098
18127
  data: url ?? ''
18099
18128
  })
18100
18129
  }),
18101
- /*#__PURE__*/ jsx_runtime_jsx("p", {
18130
+ isAppClip ? /*#__PURE__*/ jsxs("div", {
18131
+ className: "grid gap-2 text-center",
18132
+ children: [
18133
+ /*#__PURE__*/ jsx_runtime_jsx("p", {
18134
+ className: "text-lg text-text-sub font-medium",
18135
+ children: t('ar.appClipScanTitle')
18136
+ }),
18137
+ /*#__PURE__*/ jsx_runtime_jsx("p", {
18138
+ className: "text-sm text-text-light",
18139
+ children: t('ar.appClipRequirement')
18140
+ })
18141
+ ]
18142
+ }) : /*#__PURE__*/ jsx_runtime_jsx("p", {
18102
18143
  className: "text-lg text-center text-text-sub font-medium",
18103
18144
  children: t('ar.scanQrCode')
18104
18145
  }),
18105
18146
  /*#__PURE__*/ jsxs("p", {
18106
18147
  className: "text-xs text-center text-text-light",
18107
18148
  children: [
18108
- t('ar.deviceRequirementsDisclaimer'),
18109
- /*#__PURE__*/ jsx_runtime_jsx("br", {}),
18149
+ !isAppClip && /*#__PURE__*/ jsxs(Fragment, {
18150
+ children: [
18151
+ t('ar.deviceRequirementsDisclaimer'),
18152
+ /*#__PURE__*/ jsx_runtime_jsx("br", {})
18153
+ ]
18154
+ }),
18110
18155
  /*#__PURE__*/ jsx_runtime_jsx("a", {
18111
18156
  href: tenantConfig.TERMS_URL,
18112
18157
  target: "_blank",
@@ -19286,8 +19331,9 @@ const CARD_TEST_IDS = {
19286
19331
  function ArCardSlot({ band, slot, presentation }) {
19287
19332
  const { t } = useTranslation();
19288
19333
  const { room } = useRoomViewerRooms();
19334
+ const { type } = useRoomViewerMetadata();
19289
19335
  const { tinuuid } = useRoomViewerResource();
19290
- if (!tinuuid || isAndroid && device_isMobile) return null;
19336
+ if (!isArEntryOffered(resolveResourceProfile(type).handoff, tinuuid)) return null;
19291
19337
  if ('card' === presentation.appearance) return /*#__PURE__*/ jsxs("div", {
19292
19338
  className: "flex h-24 w-[280px] items-center gap-4 overflow-hidden rounded-2xl bg-background-containers p-4 text-text-dark shadow-[var(--shadow-login)]",
19293
19339
  "data-chrome-slot": slot,
@@ -19359,7 +19405,7 @@ function getNextVariantsPage(lastPage, lastPageParam) {
19359
19405
  return lastPage.objs?.length ? lastPageParam + 1 : void 0;
19360
19406
  }
19361
19407
  function useRoomViewerVariantCatalog() {
19362
- const { tinuuid, selectedObject, selectResourceVariant, apiKey, baseURL, source, widgetSession } = useRoomViewerResource();
19408
+ const { tinuuid, selectedObject, selectResourceVariant, apiKey, baseURL, language, source, widgetSession } = useRoomViewerResource();
19363
19409
  const { type } = useRoomViewerMetadata();
19364
19410
  const { decodeVariant } = resolveProductCompositionAnswers(type);
19365
19411
  const kitUuid = selectedObject?.kit?.uuid;
@@ -19368,6 +19414,7 @@ function useRoomViewerVariantCatalog() {
19368
19414
  queryKey: roomViewerKitObjectsQueryKey(kitUuid, ownerUuid, {
19369
19415
  apiKey,
19370
19416
  baseURL,
19417
+ language,
19371
19418
  source,
19372
19419
  resourceType: type
19373
19420
  }),
@@ -19377,6 +19424,7 @@ function useRoomViewerVariantCatalog() {
19377
19424
  return fetchRoomViewerKitObjects(kitUuid, ownerUuid, pageParam, {
19378
19425
  apiKey,
19379
19426
  baseURL,
19427
+ language,
19380
19428
  signal,
19381
19429
  source,
19382
19430
  widgetSession,
@@ -21230,6 +21278,11 @@ function useFrameWidthOptions() {
21230
21278
  t
21231
21279
  ]);
21232
21280
  }
21281
+ function useRoomViewerLanguage() {
21282
+ const { i18n } = useTranslation();
21283
+ const language = i18n.resolvedLanguage ?? i18n.language;
21284
+ return 'ru' === language ? 'ru' : 'en';
21285
+ }
21233
21286
  function isBlankArtworkSource(src) {
21234
21287
  return 'string' != typeof src || 0 === src.trim().length;
21235
21288
  }
@@ -21262,6 +21315,7 @@ function mergeRuntimeRooms(currentRooms, currentSourceRooms, nextSourceRooms) {
21262
21315
  function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: configuredRoomId, type, viewerSurface, dialogPortalContainer = null, viewerDialogOpen = true, onViewerDialogOpenChange, width, height, displayUnit, name, apiKey, baseURL, source, externalWidgetSession }) {
21263
21316
  const frameWidthOptions = useFrameWidthOptions();
21264
21317
  const mattingOptions = useMattingOptions(displayUnit);
21318
+ const language = useRoomViewerLanguage();
21265
21319
  const identity = resolveResourceIdentityAnswers(type);
21266
21320
  const initialRoomId = 'immersive-room' === resolveResourceProfile(type).chrome ? configuredRoomId?.trim() || void 0 : void 0;
21267
21321
  const hasPanelFinishes = 'finish' === resolveResourceProfile(type).materialRole;
@@ -21363,6 +21417,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21363
21417
  queryKey: roomViewerRoomsQueryKey({
21364
21418
  apiKey,
21365
21419
  baseURL,
21420
+ language,
21366
21421
  source,
21367
21422
  widgetSession,
21368
21423
  resourceType: type
@@ -21373,6 +21428,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21373
21428
  return await fetchRoomViewerRooms({
21374
21429
  apiKey,
21375
21430
  baseURL,
21431
+ language,
21376
21432
  signal,
21377
21433
  source,
21378
21434
  widgetSession,
@@ -21434,6 +21490,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21434
21490
  queryKey: roomViewerObjectQueryKey(initialTinuuid ?? void 0, {
21435
21491
  apiKey,
21436
21492
  baseURL,
21493
+ language,
21437
21494
  source,
21438
21495
  resourceType: type
21439
21496
  }),
@@ -21443,6 +21500,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21443
21500
  return fetchRoomViewerObject(initialTinuuid, {
21444
21501
  apiKey,
21445
21502
  baseURL,
21503
+ language,
21446
21504
  signal,
21447
21505
  source,
21448
21506
  widgetSession,
@@ -21454,6 +21512,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21454
21512
  queryKey: roomViewerObjectQueryKey(tinuuid ?? void 0, {
21455
21513
  apiKey,
21456
21514
  baseURL,
21515
+ language,
21457
21516
  source,
21458
21517
  resourceType: type
21459
21518
  }),
@@ -21464,6 +21523,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21464
21523
  return fetchRoomViewerObject(tinuuid, {
21465
21524
  apiKey,
21466
21525
  baseURL,
21526
+ language,
21467
21527
  signal,
21468
21528
  source,
21469
21529
  widgetSession,
@@ -21681,6 +21741,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21681
21741
  setMaterial,
21682
21742
  apiKey,
21683
21743
  baseURL,
21744
+ language,
21684
21745
  source,
21685
21746
  widgetSession,
21686
21747
  hasRooms,
@@ -21700,6 +21761,7 @@ function RoomViewerProvider({ children, src, tinuuid: initialTinuuid, roomId: co
21700
21761
  selectResourceVariant,
21701
21762
  apiKey,
21702
21763
  baseURL,
21764
+ language,
21703
21765
  source,
21704
21766
  widgetSession,
21705
21767
  hasRooms,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neurodyn/react-room-viewer",
3
3
  "type": "module",
4
- "version": "0.0.28",
4
+ "version": "0.0.30",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },