architwin 1.18.10 → 1.18.12

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.
@@ -213,11 +213,13 @@ export function displayPartitionItems(partitionItems, partitionId, object, paren
213
213
  // This is for the walls
214
214
  partitionItems.forEach((wall, index) => {
215
215
  log.info("__@ partition item: ", wall);
216
+ if (!wall || !wall.name || !(object === null || object === void 0 ? void 0 : object[index]))
217
+ return;
216
218
  if (!wall.options.is_deleted) {
217
219
  if (!wall.hide) {
218
220
  // Split wall name to localize
219
221
  const match = wall.name.match(/wall-(\d+)$/);
220
- const wallNumber = parseInt(match[1]) + 1;
222
+ const wallNumber = match ? parseInt(match[1]) + 1 : index + 1;
221
223
  const isVisible = wall.options.is_visible;
222
224
  const objName = object[index].name.includes('_') ? object[index].name : `${partitionId}_${object[index].name}`;
223
225
  log.info("__@ objName: ", objName);
@@ -274,6 +274,11 @@ export function renderTags(tags, showOwnTagsOnly = false) {
274
274
  console.log("TAG DELETE", tagId, _tags);
275
275
  const targetTag = _tags.find(tag => tag.json_data.id.toString() == tagId);
276
276
  yield disposeTag({ tagId: tagId });
277
+ if (targetTag) {
278
+ const tagType = targetTag.tag_type || TAG_TYPE.MP;
279
+ delete tagVisibility[tagType][tagId];
280
+ updateShowAllButton();
281
+ }
277
282
  const tagRow = document.getElementById(`at-tag-row-${tagId}`);
278
283
  tagRow.remove();
279
284
  const payload = { tag: targetTag };
@@ -488,7 +493,13 @@ export function addClickEventToTagRow(tag) {
488
493
  if (tag) {
489
494
  const tagId = tag.getAttribute('tag-id');
490
495
  if (tagId && tagId !== null) {
496
+ const deletedTag = _tags.find(t => t.json_data.id.toString() === tagId);
491
497
  yield disposeTag({ tagId: tagId });
498
+ if (deletedTag) {
499
+ const tagType = deletedTag.tag_type || TAG_TYPE.MP;
500
+ delete tagVisibility[tagType][tagId];
501
+ updateShowAllButton();
502
+ }
492
503
  const tagRow = document.getElementById(`at-tag-row-${tagId}`);
493
504
  tagRow.remove();
494
505
  notify.success(i18n.t('Successfully deleted tag'));
@@ -181,7 +181,13 @@ function toggleDisplayPane(targetId) {
181
181
  if (tag) {
182
182
  const tagId = tag.getAttribute('tag-id');
183
183
  if (tagId && tagId !== null) {
184
+ const deletedTag = _tags.find(t => t.json_data.id.toString() === tagId);
184
185
  yield disposeTag({ tagId: tagId });
186
+ if (deletedTag) {
187
+ const tagType = deletedTag.tag_type || TAG_TYPE.MP;
188
+ delete tagVisibility[tagType][tagId];
189
+ updateShowAllButton();
190
+ }
185
191
  const tagRow = document.getElementById(`at-tag-row-${tagId}`);
186
192
  log.info("tagRow", tagRow);
187
193
  tagRow.remove();
@@ -817,6 +823,15 @@ function handlePlaceTag() {
817
823
  const tags = getMpTags();
818
824
  _tags[tags.length - 1].category_uuid = payload.tagSubcategoryId;
819
825
  currentTag = _tags[_tags.length - 1];
826
+ if (currentTag) {
827
+ const tagType = currentTag.tag_type || TAG_TYPE.MP;
828
+ const tagId = currentTag.json_data.id;
829
+ if (!tagVisibility[tagType])
830
+ tagVisibility[tagType] = {};
831
+ tagVisibility[tagType][tagId] = true;
832
+ updateShowAllButton();
833
+ saveTagVisibilityToStorage(tagVisibility);
834
+ }
820
835
  log.info('_tags', _tags);
821
836
  log.info("Last Tag Pushed", currentTag);
822
837
  cancelTagPlacementPrompt.style.display = 'none';
@@ -850,6 +865,15 @@ function handlePlaceTag() {
850
865
  notyf.success(`${i18n.t('SuccessAddTagToSpace')}`);
851
866
  const tags = getMpTags();
852
867
  currentTag = tags[tags.length - 1];
868
+ if (currentTag) {
869
+ const tagType = currentTag.tag_type || TAG_TYPE.MP;
870
+ const tagId = currentTag.json_data.id;
871
+ if (!tagVisibility[tagType])
872
+ tagVisibility[tagType] = {};
873
+ tagVisibility[tagType][tagId] = true;
874
+ updateShowAllButton();
875
+ saveTagVisibilityToStorage(tagVisibility);
876
+ }
853
877
  log.info("Last Tag Pushed", tags[tags.length - 1]);
854
878
  cancelTagPlacementPrompt.style.display = 'none';
855
879
  isPlacingTag = false;
@@ -907,6 +931,14 @@ function handlePlaceTag() {
907
931
  if (index !== -1) {
908
932
  log.info("tag found");
909
933
  _tags[index].category_uuid = payload.tagSubcategoryId;
934
+ const newTag = _tags[index];
935
+ const tagType = newTag.tag_type || TAG_TYPE.MP;
936
+ const tagId = newTag.json_data.id;
937
+ if (!tagVisibility[tagType])
938
+ tagVisibility[tagType] = {};
939
+ tagVisibility[tagType][tagId] = true;
940
+ updateShowAllButton();
941
+ saveTagVisibilityToStorage(tagVisibility);
910
942
  }
911
943
  else {
912
944
  log.info("tag not found");
@@ -946,6 +978,14 @@ function handlePlaceTag() {
946
978
  if (index !== -1) {
947
979
  log.info("tag found");
948
980
  _tags[index].category_uuid = payload.tagSubcategoryId;
981
+ const newTag = _tags[index];
982
+ const tagType = newTag.tag_type || TAG_TYPE.MP;
983
+ const tagId = newTag.json_data.id;
984
+ if (!tagVisibility[tagType])
985
+ tagVisibility[tagType] = {};
986
+ tagVisibility[tagType][tagId] = true;
987
+ updateShowAllButton();
988
+ saveTagVisibilityToStorage(tagVisibility);
949
989
  }
950
990
  else {
951
991
  log.info("tag not found");
@@ -975,7 +1015,13 @@ function onDisposeTag() {
975
1015
  if (tag) {
976
1016
  const tagId = tag.getAttribute('tag-id');
977
1017
  if (tagId && tagId !== null) {
1018
+ const deletedTag = _tags.find(t => t.json_data.id.toString() === tagId);
978
1019
  yield disposeTag({ tagId: tagId });
1020
+ if (deletedTag) {
1021
+ const tagType = deletedTag.tag_type || TAG_TYPE.MP;
1022
+ delete tagVisibility[tagType][tagId];
1023
+ updateShowAllButton();
1024
+ }
979
1025
  const tagRow = document.getElementById(`at-tag-row-${tagId}`);
980
1026
  log.info("tagRow", tagRow);
981
1027
  tagRow.remove();
@@ -994,7 +1040,13 @@ function onDisposeTag() {
994
1040
  }
995
1041
  cancelMoveTag();
996
1042
  if (iTag !== null) {
1043
+ const deletedTag = _tags.find(t => t.id.toString() === iTag.id.toString());
997
1044
  yield disposeTag({ tagId: iTag.id });
1045
+ if (deletedTag) {
1046
+ const tagType = deletedTag.tag_type || TAG_TYPE.MP;
1047
+ delete tagVisibility[tagType][iTag.id.toString()];
1048
+ updateShowAllButton();
1049
+ }
998
1050
  }
999
1051
  iTag = null;
1000
1052
  if (cancelTagPlacementPrompt) {
@@ -1230,7 +1282,7 @@ function handleToggleVisibilityTags() {
1230
1282
  const updateAll = (visible) => __awaiter(this, void 0, void 0, function* () {
1231
1283
  // Determine which tags to update based on current mode
1232
1284
  const tagsToUpdate = currentTagPaneMode
1233
- ? _tags.filter(tag => tag.tag_type === currentTagPaneMode)
1285
+ ? _tags.filter(tag => (tag.tag_type || TAG_TYPE.MP) === currentTagPaneMode)
1234
1286
  : _tags;
1235
1287
  for (const tag of tagsToUpdate) {
1236
1288
  const tagType = tag.tag_type || TAG_TYPE.MP;
@@ -3540,6 +3592,15 @@ function handlePlaceIotTag() {
3540
3592
  const tags = getMpTags();
3541
3593
  currentTag = _tags[tags.length - 1];
3542
3594
  _tags[tags.length - 1].category_uuid = payload.tagCategoryId;
3595
+ if (currentTag) {
3596
+ const tagType = currentTag.tag_type || TAG_TYPE.IOT;
3597
+ const tagId = currentTag.json_data.id;
3598
+ if (!tagVisibility[tagType])
3599
+ tagVisibility[tagType] = {};
3600
+ tagVisibility[tagType][tagId] = true;
3601
+ updateShowAllButton();
3602
+ saveTagVisibilityToStorage(tagVisibility);
3603
+ }
3543
3604
  cancelTagPlacementPrompt.style.display = 'none';
3544
3605
  isPlacingTag = false;
3545
3606
  });
@@ -3571,6 +3632,15 @@ function handlePlaceIotTag() {
3571
3632
  notyf.success(`${i18n.t('SuccessAddTagToSpace')}`);
3572
3633
  const tags = getMpTags();
3573
3634
  currentTag = tags[tags.length - 1];
3635
+ if (currentTag) {
3636
+ const tagType = currentTag.tag_type || TAG_TYPE.IOT;
3637
+ const tagId = currentTag.json_data.id;
3638
+ if (!tagVisibility[tagType])
3639
+ tagVisibility[tagType] = {};
3640
+ tagVisibility[tagType][tagId] = true;
3641
+ updateShowAllButton();
3642
+ saveTagVisibilityToStorage(tagVisibility);
3643
+ }
3574
3644
  log.info("Last IoT Tag Pushed", tags[tags.length - 1]);
3575
3645
  cancelTagPlacementPrompt.style.display = 'none';
3576
3646
  isPlacingTag = false;
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  import { _mpConfig } from "../architwin";
12
12
  import { _3DXObjects } from "../architwin";
13
13
  import { socketEmit } from '../socketio';
14
+ import pdfjs from 'pdfjs-dist/build/pdf';
14
15
  export class Plane {
15
16
  constructor(sdk) {
16
17
  this.disposables = [];
@@ -112,10 +113,10 @@ export class Plane {
112
113
  this.texture = new THREE.TextureLoader().load(this.inputs.url);
113
114
  break;
114
115
  case 'pdf':
115
- const pdfjs = yield import('pdfjs-dist/build/pdf');
116
- const pdfjsWorker = yield import('pdfjs-dist/build/pdf.worker.entry');
117
116
  const pdfPages = [];
118
- pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
117
+ // pdf.worker.entry is a webpack-only shim that breaks Vite consumers; use a
118
+ // bundler-agnostic CDN worker pinned to the installed pdfjs-dist version.
119
+ pdfjs.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
119
120
  const pdfDoc = yield pdfjs.getDocument(this.inputs.url).promise;
120
121
  const numPages = pdfDoc.numPages;
121
122
  for (let pageNum = 1; pageNum <= numPages; pageNum++) {
@@ -883,10 +883,10 @@ class PlanePdf {
883
883
  // const geometry = new THREE.PlaneGeometry(1.0, 1.0)
884
884
  // @ts-ignore
885
885
  const pdfjs = yield import('pdfjs-dist/build/pdf');
886
- // @ts-ignore
887
- const pdfjsWorker = yield import('pdfjs-dist/build/pdf.worker.entry');
888
886
  const pdfPages = [];
889
- pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
887
+ // pdf.worker.entry is a webpack-only shim that breaks Vite consumers; use a
888
+ // bundler-agnostic CDN worker pinned to the installed pdfjs-dist version.
889
+ pdfjs.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
890
890
  const pdfDoc = yield pdfjs.getDocument(this.inputs.url).promise;
891
891
  const numPages = pdfDoc.numPages;
892
892
  for (let pageNum = 1; pageNum <= numPages; pageNum++) {
@@ -621,11 +621,13 @@ export class BufferGeometry {
621
621
  // }
622
622
  };
623
623
  this.renderPolygon = () => {
624
- var _a;
624
+ var _a, _b, _c, _d;
625
625
  const THREE = this.context.three;
626
+ if (!this.inputs.path || this.inputs.path.length === 0)
627
+ return;
626
628
  const polyData = this.inputs.polygonData;
627
629
  console.log("polyData ", polyData);
628
- const WALL_HEIGHT = polyData && polyData.walls[0].wall_height ? polyData.walls[0].wall_height : this.inputs.wallHeight;
630
+ const WALL_HEIGHT = (_c = (_b = (_a = polyData === null || polyData === void 0 ? void 0 : polyData.walls) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.wall_height) !== null && _c !== void 0 ? _c : this.inputs.wallHeight;
629
631
  this.groupedMesh = new THREE.Group();
630
632
  let floorDataArray = [];
631
633
  let wallDataArray = [];
@@ -637,7 +639,7 @@ export class BufferGeometry {
637
639
  return point;
638
640
  });
639
641
  let floorLevel;
640
- console.log("floorLevel polyData.floor.floor_level", (_a = polyData === null || polyData === void 0 ? void 0 : polyData.floor) === null || _a === void 0 ? void 0 : _a.floor_level);
642
+ console.log("floorLevel polyData.floor.floor_level", (_d = polyData === null || polyData === void 0 ? void 0 : polyData.floor) === null || _d === void 0 ? void 0 : _d.floor_level);
641
643
  floorLevel = this.inputs.path[0].y;
642
644
  console.log("floorLevel ", floorLevel);
643
645
  console.log("floorLevel this.inputs.path[0].y", this.inputs.path[0].y);
package/lib/minimap.js CHANGED
@@ -57,6 +57,29 @@ let notyf = new Notyf({ position: { x: 'left', y: 'bottom' }, duration: 4500, ty
57
57
  //Map placement presets
58
58
  const mapPositions = ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'];
59
59
  setInterval(locateAvatar, 5000);
60
+ function setActiveMinimapSweep(currentSweep, sweepIds, sweepLegacyIds) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ if (activeSweep !== null) {
63
+ const swp = document.getElementById('p' + activeSweep);
64
+ if (swp)
65
+ swp.classList.remove('active');
66
+ }
67
+ activeSweep = currentSweep.id;
68
+ if (_isInitialLoad) {
69
+ log.info('=== minimap: initial load; will delay activating current sweep; to resolve timing issues ');
70
+ yield new Promise(resolve => setTimeout(resolve, 2000));
71
+ }
72
+ const mapConfig = getMapConfig();
73
+ if (mapConfig && mapConfig.showDirection) {
74
+ showDirection();
75
+ }
76
+ const sweepBtn = document.getElementById('p' + activeSweep);
77
+ if (sweepBtn) {
78
+ sweepBtn.classList.add('active');
79
+ log.info('Entering Sweep - API ID:' + currentSweep.id + ' (#' + sweepIds[currentSweep.id] + ') - Legacy SDK ID: ' + sweepLegacyIds[currentSweep.id]);
80
+ }
81
+ });
82
+ }
60
83
  function setMap(mpSdk, appKey, mapId, openOnLoad) {
61
84
  return __awaiter(this, void 0, void 0, function* () {
62
85
  log.info('setMap(mpSdk: MpSdk)', mpSdk);
@@ -102,31 +125,7 @@ function setMap(mpSdk, appKey, mapId, openOnLoad) {
102
125
  return __awaiter(this, void 0, void 0, function* () {
103
126
  // Change to the current sweep has occurred.
104
127
  if (currentSweep.id !== '') {
105
- if (activeSweep !== null) {
106
- const swp = document.getElementById('p' + activeSweep);
107
- if (swp)
108
- swp.classList.remove('active');
109
- }
110
- activeSweep = currentSweep.id;
111
- if (_isInitialLoad) {
112
- log.info('=== minimap: initial load; will delay activating current sweep; to resolve timing issues ');
113
- yield new Promise(resolve => setTimeout(resolve, 2000));
114
- const mapConfig = getMapConfig();
115
- if (mapConfig && mapConfig.showDirection) {
116
- showDirection();
117
- }
118
- }
119
- else {
120
- const mapConfig = getMapConfig();
121
- if (mapConfig && mapConfig.showDirection) {
122
- showDirection();
123
- }
124
- }
125
- const sweepBtn = document.getElementById('p' + activeSweep);
126
- if (sweepBtn) {
127
- sweepBtn.classList.add('active');
128
- log.info('Entering Sweep - API ID:' + currentSweep.id + ' (#' + sweepIds[currentSweep.id] + ') - Legacy SDK ID: ' + sweepLegacyIds[currentSweep.id]);
129
- }
128
+ setActiveMinimapSweep(currentSweep, sweepIds, sweepLegacyIds);
130
129
  // document.getElementById('p' + activeSweep).classList.add('active');
131
130
  // log.info('Entering Sweep - API ID:' + currentSweep.id + ' (#' + sweepIds[currentSweep.id] + ') - Legacy SDK ID: ' + sweepLegacyIds[currentSweep.id]);
132
131
  }
@@ -286,7 +285,7 @@ function setMap(mpSdk, appKey, mapId, openOnLoad) {
286
285
  onCollectionUpdated: function (collection) {
287
286
  log.info('default the entire up-to-date collection', collection);
288
287
  _minimapSweepCollection = collection;
289
- if (_currentFloor) {
288
+ if (_currentFloor !== undefined) {
290
289
  toggleSweepMarkerFloors(_currentFloor);
291
290
  }
292
291
  dispatchSpaceEvent(SPACE_EVENTS.MINIMAP_SWEEPS_RENDERED);
@@ -340,6 +339,11 @@ function setMap(mpSdk, appKey, mapId, openOnLoad) {
340
339
  // Show Minimap when Tour Starts Playing.
341
340
  yield mpSdk.App.state.waitUntil((appState) => appState.phase == 'appphase.playing');
342
341
  document.body.classList.add('minimap');
342
+ //Tying to fix the issue where the minimap is not showing up on initial load. The minimap is not showing up because the current floor is not being set when the app starts. This is a workaround to set the current floor when the app starts.
343
+ const currentFloor = getCurrentFloor();
344
+ toggleSweepMarkerFloors(currentFloor.sequence);
345
+ const currentSweep = getCurrentSweep();
346
+ setActiveMinimapSweep(currentSweep, sweepIds, sweepLegacyIds);
343
347
  _isInitialLoad = false;
344
348
  });
345
349
  }
@@ -1307,7 +1311,7 @@ function generateCustomMinimap(mpSdk) {
1307
1311
  onCollectionUpdated: function (collection) {
1308
1312
  log.info('custom map: the entire up-to-date collection', collection);
1309
1313
  _minimapSweepCollection = collection;
1310
- if (_currentFloor) {
1314
+ if (_currentFloor !== undefined) {
1311
1315
  toggleSweepMarkerFloors(_currentFloor);
1312
1316
  }
1313
1317
  // Convert object to array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.18.10",
3
+ "version": "1.18.12",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",