@neurodyn/react-room-viewer 0.0.23 → 0.0.25

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.
Files changed (2) hide show
  1. package/dist/index.js +159 -32
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5409,6 +5409,10 @@ var __webpack_modules__ = {
5409
5409
  color: var(--v-text-dark);
5410
5410
  }
5411
5411
 
5412
+ .data-\\[variant\\=destructive\\]\\:\\[\\&_svg\\:not\\(\\[class\\*\\=text-\\]\\)\\]\\:text-inherit[data-variant="destructive"] svg:not([class*="text-"]) {
5413
+ color: inherit;
5414
+ }
5415
+
5412
5416
  .\\[\\&_tr\\]\\:border-b tr {
5413
5417
  border-bottom-style: var(--tw-border-style);
5414
5418
  border-bottom-width: 1px;
@@ -7721,7 +7725,10 @@ async function fetchRoomViewerOwnerObjects(ownerUuid, page, options) {
7721
7725
  signal: options.signal
7722
7726
  });
7723
7727
  const { query, config } = getRoomViewerPublicApiQuery(options);
7724
- const response = await publicApiControllerGetPublicObjects(data, query, {
7728
+ const response = await publicApiControllerGetPublicObjects({
7729
+ ...data,
7730
+ productType: getRoomViewerPublicApiProductType(options)
7731
+ }, query, {
7725
7732
  ...config,
7726
7733
  baseURL: options.baseURL,
7727
7734
  headers: await getRoomViewerPublicApiHeaders(options),
@@ -7795,7 +7802,7 @@ const RESOURCE_TYPE_PROFILES = {
7795
7802
  chrome: 'immersive-room',
7796
7803
  presentation: 'immersive-panels',
7797
7804
  manipulation: 'panel-group',
7798
- catalogLabel: 'product-name',
7805
+ productNameSource: 'collection',
7799
7806
  catalogTitle: 'wall-panel',
7800
7807
  introduction: 'focus-resource',
7801
7808
  identity: 'modelled-resource',
@@ -7815,7 +7822,7 @@ const RESOURCE_TYPE_PROFILES = {
7815
7822
  chrome: 'framed-scene',
7816
7823
  presentation: 'framed-default',
7817
7824
  manipulation: 'single-resource',
7818
- catalogLabel: 'material-name',
7825
+ productNameSource: 'material',
7819
7826
  catalogTitle: 'title',
7820
7827
  introduction: null,
7821
7828
  identity: 'textured-resource',
@@ -7832,7 +7839,7 @@ const RESOURCE_TYPE_PROFILES = {
7832
7839
  chrome: 'immersive-room',
7833
7840
  presentation: 'immersive-default',
7834
7841
  manipulation: 'drag-with-rotation-handle',
7835
- catalogLabel: 'material-name',
7842
+ productNameSource: 'collection',
7836
7843
  catalogTitle: 'rugs',
7837
7844
  introduction: null,
7838
7845
  identity: 'modelled-resource',
@@ -7849,7 +7856,7 @@ const RESOURCE_TYPE_PROFILES = {
7849
7856
  chrome: 'immersive-room',
7850
7857
  presentation: 'immersive-default',
7851
7858
  manipulation: 'rotate-on-floor',
7852
- catalogLabel: 'material-name',
7859
+ productNameSource: 'collection',
7853
7860
  catalogTitle: 'flooring',
7854
7861
  introduction: null,
7855
7862
  identity: 'modelled-resource',
@@ -8807,13 +8814,7 @@ function getListingKey(object) {
8807
8814
  return object.kit?.uuid ?? object.uuid ?? object.tinuuid ?? '';
8808
8815
  }
8809
8816
  function getSizedDesignKey(object) {
8810
- const meta = decodeRugSizeMeta(object.description);
8811
- const name = object.name?.trim();
8812
- const sizeSuffix = meta ? ` — ${meta.size}` : null;
8813
- if (name && sizeSuffix && name.endsWith(sizeSuffix)) {
8814
- const designName = name.slice(0, -sizeSuffix.length).trim();
8815
- if (designName) return `rug-name:${designName}`;
8816
- }
8817
+ if (object.kit?.uuid) return object.kit.uuid;
8817
8818
  return `object:${getListingKey(object)}`;
8818
8819
  }
8819
8820
  const PRODUCT_COMPOSITION_ANSWERS = {
@@ -8835,16 +8836,13 @@ const PRODUCT_COMPOSITION_ANSWERS = {
8835
8836
  };
8836
8837
  const MATERIAL_ROLE_ANSWERS = {
8837
8838
  'product-identity': {
8838
- catalogsEveryMaterial: true,
8839
- namesProduct: true
8839
+ catalogsEveryMaterial: true
8840
8840
  },
8841
8841
  finish: {
8842
- catalogsEveryMaterial: false,
8843
- namesProduct: false
8842
+ catalogsEveryMaterial: false
8844
8843
  },
8845
8844
  placeholder: {
8846
- catalogsEveryMaterial: false,
8847
- namesProduct: false
8845
+ catalogsEveryMaterial: false
8848
8846
  }
8849
8847
  };
8850
8848
  function resolveProductCompositionAnswers(type) {
@@ -8869,8 +8867,7 @@ function resolveResourceIdentityAnswers(type) {
8869
8867
  return RESOURCE_IDENTITY_ANSWERS[resolveResourceProfile(type).identity];
8870
8868
  }
8871
8869
  function getResourceProductName(type, object, material, fallback = '') {
8872
- const { namesProduct } = resolveMaterialRoleAnswers(type);
8873
- return namesProduct ? material?.name ?? object?.name ?? object?.kit?.name ?? fallback : object?.kit?.name ?? object?.name ?? material?.name ?? fallback;
8870
+ return 'material' === resolveResourceProfile(type).productNameSource ? material?.name ?? object?.name ?? object?.kit?.name ?? fallback : object?.kit?.name?.trim() || object?.name?.trim() || material?.name?.trim() || fallback;
8874
8871
  }
8875
8872
  function getMaterialId(material) {
8876
8873
  return material.hid ?? '';
@@ -8982,13 +8979,14 @@ function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
8982
8979
  const { requiresMaterialModel } = resolveResourceIdentityAnswers(type);
8983
8980
  const { getCollapseKey } = resolveProductCompositionAnswers(type);
8984
8981
  const { catalogsEveryMaterial } = resolveMaterialRoleAnswers(type);
8985
- const { catalogLabel, composition } = resolveResourceProfile(type);
8982
+ const { composition, productNameSource } = resolveResourceProfile(type);
8986
8983
  const fetchedObjects = (0, __rspack_external_react.useMemo)(()=>data?.pages.flatMap((page)=>page.objs ?? []) ?? [], [
8987
8984
  data
8988
8985
  ]);
8989
- const unresolvedObjects = (0, __rspack_external_react.useMemo)(()=>'color-design' === composition ? fetchedObjects.filter((object)=>object.tinuuid && !object.kit?.uuid && object.materials?.[0]?.native?.glbUrl) : [], [
8990
- composition,
8991
- fetchedObjects
8986
+ const unresolvedObjects = (0, __rspack_external_react.useMemo)(()=>'material' === productNameSource ? [] : fetchedObjects.filter((object)=>object.tinuuid && (!object.kit?.uuid || !object.kit.name?.trim()) && (!requiresMaterialModel || object.materials?.[0]?.native?.glbUrl)), [
8987
+ fetchedObjects,
8988
+ productNameSource,
8989
+ requiresMaterialModel
8992
8990
  ]);
8993
8991
  const collectionQueries = useQueries({
8994
8992
  queries: unresolvedObjects.map((object)=>({
@@ -9015,7 +9013,10 @@ function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
9015
9013
  return [
9016
9014
  {
9017
9015
  ...object,
9018
- kit: query?.data?.kit ?? object.kit
9016
+ kit: query?.data?.kit ? {
9017
+ ...object.kit,
9018
+ ...query.data.kit
9019
+ } : object.kit
9019
9020
  }
9020
9021
  ];
9021
9022
  });
@@ -9043,17 +9044,16 @@ function useRoomViewerMaterialCatalog({ includeEmbeddedObject = false } = {}) {
9043
9044
  return catalogMaterials?.map((material)=>{
9044
9045
  const materialId = getMaterialId(material);
9045
9046
  if (!materialId || !object.tinuuid) return null;
9047
+ const productName = getResourceProductName(type, object, material, name);
9046
9048
  return {
9047
9049
  materialId,
9048
- name: ('material-name' === catalogLabel ? material.name : object.kit?.name ?? object.name) ?? material.name ?? '',
9049
- productName: getResourceProductName(type, object, material, name),
9050
+ productName,
9050
9051
  material,
9051
9052
  tinuuid: object.tinuuid
9052
9053
  };
9053
9054
  }).filter((item)=>null !== item) ?? [];
9054
9055
  }), [
9055
9056
  catalogsEveryMaterial,
9056
- catalogLabel,
9057
9057
  composition,
9058
9058
  objects,
9059
9059
  type,
@@ -14676,7 +14676,7 @@ function dropdown_menu_DropdownMenuItem({ className, inset, variant = 'default',
14676
14676
  "data-slot": "dropdown-menu-item",
14677
14677
  "data-inset": inset,
14678
14678
  "data-variant": variant,
14679
- className: utils_cn('relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden hover:bg-background-base focus:bg-background-base data-[highlighted]:bg-background-base data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:hover:bg-destructive/10 data-[highlighted][data-variant=destructive]:bg-destructive/10 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*=text-])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0', inset && 'pl-8', className),
14679
+ className: utils_cn('relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden hover:bg-background-base focus:bg-background-base data-[highlighted]:bg-background-base data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:hover:bg-destructive/10 data-[highlighted][data-variant=destructive]:bg-destructive/10 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*=text-])]:text-muted-foreground data-[variant=destructive]:[&_svg:not([class*=text-])]:text-inherit [&_svg]:pointer-events-none [&_svg]:shrink-0', inset && 'pl-8', className),
14680
14680
  ...props
14681
14681
  });
14682
14682
  }
@@ -14878,6 +14878,120 @@ function panelModelQuery(url) {
14878
14878
  retry: false
14879
14879
  };
14880
14880
  }
14881
+ function usePanelMaterials(currentObject, enabled) {
14882
+ const { apiKey, baseURL, source, widgetSession } = useRoomViewerResource();
14883
+ const { type } = useRoomViewerMetadata();
14884
+ const kitUuid = currentObject?.kit?.uuid;
14885
+ const ownerUuid = currentObject?.owner?.uuid;
14886
+ const options = {
14887
+ apiKey,
14888
+ baseURL,
14889
+ source,
14890
+ widgetSession,
14891
+ resourceType: type
14892
+ };
14893
+ const { data, hasNextPage, fetchNextPage, isFetching, isFetchNextPageError } = useInfiniteQuery({
14894
+ queryKey: [
14895
+ ...roomViewerKitObjectsQueryKey(kitUuid, ownerUuid, options),
14896
+ 'panel-materials'
14897
+ ],
14898
+ enabled: enabled && Boolean(kitUuid),
14899
+ queryFn: async ({ pageParam, signal })=>{
14900
+ try {
14901
+ return await fetchRoomViewerKitObjects(kitUuid, ownerUuid ?? '', pageParam, {
14902
+ ...options,
14903
+ signal
14904
+ });
14905
+ } catch (error) {
14906
+ if (0 === pageParam || signal.aborted) throw error;
14907
+ return {
14908
+ objs: [],
14909
+ pages_count: void 0
14910
+ };
14911
+ }
14912
+ },
14913
+ initialPageParam: 0,
14914
+ getNextPageParam: (lastPage, pages, page)=>{
14915
+ const count = lastPage.pages_count ?? pages[0]?.pages_count;
14916
+ return void 0 !== count ? page + 1 < count ? page + 1 : void 0 : lastPage.objs?.length ? page + 1 : void 0;
14917
+ },
14918
+ retry: false
14919
+ });
14920
+ (0, __rspack_external_react.useEffect)(()=>{
14921
+ if (enabled && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage({
14922
+ cancelRefetch: false
14923
+ });
14924
+ }, [
14925
+ data?.pages.length,
14926
+ enabled,
14927
+ fetchNextPage,
14928
+ hasNextPage,
14929
+ isFetching,
14930
+ isFetchNextPageError
14931
+ ]);
14932
+ const siblings = (0, __rspack_external_react.useMemo)(()=>{
14933
+ if (!enabled || !kitUuid) return [];
14934
+ const objects = new Map();
14935
+ for (const object of data?.pages.flatMap((page)=>page.objs ?? []) ?? [])if (object.tinuuid && object.tinuuid !== currentObject?.tinuuid) objects.set(object.tinuuid, object);
14936
+ return Array.from(objects.values());
14937
+ }, [
14938
+ currentObject?.tinuuid,
14939
+ data,
14940
+ enabled,
14941
+ kitUuid
14942
+ ]);
14943
+ const details = useQueries({
14944
+ queries: siblings.map((object)=>({
14945
+ queryKey: roomViewerObjectQueryKey(object.tinuuid, options),
14946
+ queryFn: ({ signal })=>fetchRoomViewerObject(object.tinuuid, {
14947
+ ...options,
14948
+ signal
14949
+ }),
14950
+ enabled,
14951
+ retry: false
14952
+ }))
14953
+ });
14954
+ const [resolvedResourceOrder, setResolvedResourceOrder] = (0, __rspack_external_react.useState)({
14955
+ ids: []
14956
+ });
14957
+ const sameSelection = resolvedResourceOrder.resourceId === currentObject?.tinuuid && resolvedResourceOrder.kitUuid === kitUuid;
14958
+ const previousIds = sameSelection ? resolvedResourceOrder.ids : [];
14959
+ const knownIds = new Set(previousIds);
14960
+ const resolvedMaterials = new Map(siblings.flatMap((object, index)=>{
14961
+ const detail = details[index]?.data;
14962
+ return detail ? [
14963
+ [
14964
+ object.tinuuid,
14965
+ detail.materials ?? []
14966
+ ]
14967
+ ] : [];
14968
+ }));
14969
+ const newIds = Array.from(resolvedMaterials.keys()).filter((id)=>!knownIds.has(id));
14970
+ const resourceIds = newIds.length ? [
14971
+ ...previousIds,
14972
+ ...newIds
14973
+ ] : previousIds;
14974
+ if (!sameSelection || newIds.length) setResolvedResourceOrder({
14975
+ resourceId: currentObject?.tinuuid,
14976
+ kitUuid,
14977
+ ids: resourceIds
14978
+ });
14979
+ const allMaterials = enabled ? [
14980
+ ...currentObject?.materials ?? [],
14981
+ ...resourceIds.flatMap((id)=>resolvedMaterials.get(id) ?? [])
14982
+ ] : [];
14983
+ const seen = new Set();
14984
+ return allMaterials.flatMap((material, index)=>{
14985
+ if (!material.hid || !material.native?.glbUrl || seen.has(material.hid)) return [];
14986
+ seen.add(material.hid);
14987
+ return [
14988
+ {
14989
+ material,
14990
+ number: index + 1
14991
+ }
14992
+ ];
14993
+ });
14994
+ }
14881
14995
  function panelCellKey(cell) {
14882
14996
  return `${cell.x},${cell.y}`;
14883
14997
  }
@@ -15046,7 +15160,8 @@ function usePanelSession(enabled, introduce) {
15046
15160
  const firstMaterial = currentObject?.materials?.[0];
15047
15161
  const isPhone = useMediaQuery('(max-width: 639px)');
15048
15162
  const composition = usePanelComposition(tinuuid, firstMaterial?.hid ?? '', introduce && isPhone);
15049
- const materials = enabled ? currentObject?.materials?.filter((candidate)=>candidate.hid && candidate.native?.glbUrl) ?? [] : [];
15163
+ const entries = usePanelMaterials(currentObject, enabled && viewerDialogOpen);
15164
+ const materials = entries.map((entry)=>entry.material);
15050
15165
  const queries = useQueries({
15051
15166
  queries: materials.map((material)=>({
15052
15167
  ...panelModelQuery(material.native.glbUrl),
@@ -15056,7 +15171,7 @@ function usePanelSession(enabled, introduce) {
15056
15171
  const base = queries[materials.findIndex((material)=>material.hid === firstMaterial?.hid)]?.data;
15057
15172
  const options = materials.map((material, index)=>({
15058
15173
  material,
15059
- number: (currentObject?.materials?.indexOf(material) ?? index) + 1,
15174
+ number: entries[index].number,
15060
15175
  model: queries[index]?.data,
15061
15176
  loading: queries[index]?.isFetching ?? false,
15062
15177
  error: queries[index]?.isError ?? false
@@ -17895,9 +18010,21 @@ function AR({ className, buttonClassName, buttonLeadingIcon, buttonLabel, button
17895
18010
  setIsSceneExporting(true);
17896
18011
  const clone = sceneResource.clone(true);
17897
18012
  clone.position.set(0, 0, 0);
18013
+ clone.quaternion.identity();
18014
+ clone.updateMatrix();
18015
+ clone.updateMatrixWorld(true);
17898
18016
  if (isIOS) {
17899
18017
  const usdzExporter = new USDZExporter();
17900
- const usdzBuffer = await usdzExporter.parseAsync(clone);
18018
+ const usdzBuffer = await usdzExporter.parseAsync(clone, {
18019
+ ar: {
18020
+ anchoring: {
18021
+ type: 'plane'
18022
+ },
18023
+ planeAnchoring: {
18024
+ alignment: 'vertical'
18025
+ }
18026
+ }
18027
+ });
17901
18028
  const usdzFile = new File([
17902
18029
  usdzBuffer
17903
18030
  ], 'scene.usdz', {
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.23",
4
+ "version": "0.0.25",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },