@2112-lab/central-plant 0.3.17 → 0.3.19

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.
@@ -28,12 +28,14 @@ function _measureS3Transfer() {
28
28
  var fileSize,
29
29
  startTime,
30
30
  executeTransfer,
31
+ isExpiredToken,
31
32
  Auth,
32
33
  endTime,
33
34
  duration,
34
35
  _args2 = arguments,
35
36
  _t,
36
- _t2;
37
+ _t2,
38
+ _t3;
37
39
  return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
38
40
  while (1) switch (_context2.n) {
39
41
  case 0:
@@ -74,8 +76,12 @@ function _measureS3Transfer() {
74
76
  case 3:
75
77
  _context2.p = 3;
76
78
  _t = _context2.v;
77
- if (!(_t.code === 'ExpiredToken' || _t.message && _t.message.includes('ExpiredToken'))) {
78
- _context2.n = 8;
79
+ // Check for ExpiredToken error.
80
+ // AWS SDK v3 (used by Amplify v5) sets error.name, not error.code.
81
+ // error.message is 'The provided token has expired.' (no 'ExpiredToken' substring).
82
+ isExpiredToken = _t.code === 'ExpiredToken' || _t.Code === 'ExpiredToken' || _t.name === 'ExpiredToken' || _t.message && _t.message.toLowerCase().includes('token has expired');
83
+ if (!isExpiredToken) {
84
+ _context2.n = 12;
79
85
  break;
80
86
  }
81
87
  console.warn("\u26A0\uFE0F Token expired during ".concat(operation, ". Attempting session refresh and retry..."));
@@ -88,35 +94,50 @@ function _measureS3Transfer() {
88
94
  throw _t;
89
95
  case 4:
90
96
  _context2.p = 4;
91
- _context2.n = 5;
97
+ _context2.p = 5;
98
+ _context2.n = 6;
99
+ return Auth.currentSession();
100
+ case 6:
101
+ console.log("\u2705 User Pool session refreshed for ".concat(operation, "."));
102
+ _context2.n = 8;
103
+ break;
104
+ case 7:
105
+ _context2.p = 7;
106
+ _t2 = _context2.v;
107
+ // If currentSession() fails the refresh token itself is expired —
108
+ // the user needs to sign in again. Surface that immediately.
109
+ console.error("\u274C Failed to refresh User Pool session during ".concat(operation, ":"), _t2);
110
+ throw _t2;
111
+ case 8:
112
+ _context2.n = 9;
92
113
  return Auth.currentCredentials({
93
114
  bypassCache: true
94
115
  });
95
- case 5:
96
- console.log("\u2705 Session refreshed. Retrying ".concat(operation, "..."));
116
+ case 9:
117
+ console.log("\u2705 STS credentials refreshed. Retrying ".concat(operation, "..."));
97
118
 
98
119
  // Reset timer for the retry
99
120
  startTime = performance.now();
100
- _context2.n = 6;
121
+ _context2.n = 10;
101
122
  return executeTransfer();
102
- case 6:
123
+ case 10:
103
124
  return _context2.a(2, _context2.v);
104
- case 7:
105
- _context2.p = 7;
106
- _t2 = _context2.v;
107
- console.error("\u274C Retry failed for ".concat(operation, ":"), _t2);
125
+ case 11:
126
+ _context2.p = 11;
127
+ _t3 = _context2.v;
128
+ console.error("\u274C Retry failed for ".concat(operation, ":"), _t3);
108
129
  // If retry fails, throw the Retry Error (likely unrelated or persistent auth issue)
109
- throw _t2;
110
- case 8:
130
+ throw _t3;
131
+ case 12:
111
132
  // Standard error handling for non-expired tokens (or if logic above didn't catch it)
112
133
  endTime = performance.now();
113
134
  duration = ((endTime - startTime) / 1000).toFixed(3);
114
135
  console.error("\u274C S3 ".concat(operation, " failed after ").concat(duration, "s:"), _t);
115
136
  throw _t;
116
- case 9:
137
+ case 13:
117
138
  return _context2.a(2);
118
139
  }
119
- }, _callee2, null, [[4, 7], [1, 3]]);
140
+ }, _callee2, null, [[5, 7], [4, 11], [1, 3]]);
120
141
  }));
121
142
  return _measureS3Transfer.apply(this, arguments);
122
143
  }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var THREE = require('three');
7
+ var directionUtils = require('../../helpers/directionUtils.js');
7
8
 
8
9
  function _interopNamespace(e) {
9
10
  if (e && e.__esModule) return e;
@@ -716,16 +717,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
716
717
  if (!component || degrees % 90 !== 0) {
717
718
  return;
718
719
  }
719
- console.log("\uD83D\uDD04 Updating connector directions after ".concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
720
720
 
721
- // Simple approach: just log that directions may need manual verification
722
- // In most cases, Three.js world matrices handle the actual positioning correctly
723
- component.traverse(function (child) {
724
- var _child$userData5, _child$userData6;
725
- if (((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.objectType) === 'connector' && (_child$userData6 = child.userData) !== null && _child$userData6 !== void 0 && _child$userData6.direction) {
726
- console.log("\uD83D\uDCCD Connector ".concat(child.uuid, " direction may need verification after rotation"));
727
- }
728
- });
721
+ // Use the direction utility to update direction vectors on Three.js connector objects
722
+ directionUtils.updateDirectionAfterRotation(component, axis, degrees);
729
723
  }
730
724
 
731
725
  /**
@@ -879,9 +873,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
879
873
 
880
874
  // Traverse scene to find all connectors
881
875
  this.sceneViewer.scene.traverse(function (child) {
882
- var _child$userData7;
876
+ var _child$userData5;
883
877
  // Check if this is a connector (component connector or manual segment connector)
884
- if (((_child$userData7 = child.userData) === null || _child$userData7 === void 0 ? void 0 : _child$userData7.objectType) === 'connector') {
878
+ if (((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.objectType) === 'connector') {
885
879
  // Get world position of connector
886
880
  var connectorWorldPos = new THREE__namespace.Vector3();
887
881
  child.getWorldPosition(connectorWorldPos);
@@ -932,8 +926,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
932
926
  // Find all child connectors of the segment in the Three.js scene
933
927
  var connectors = [];
934
928
  segment.traverse(function (child) {
935
- var _child$userData8;
936
- if (((_child$userData8 = child.userData) === null || _child$userData8 === void 0 ? void 0 : _child$userData8.objectType) === 'segment-connector') {
929
+ var _child$userData6;
930
+ if (((_child$userData6 = child.userData) === null || _child$userData6 === void 0 ? void 0 : _child$userData6.objectType) === 'segment-connector') {
937
931
  connectors.push(child);
938
932
  }
939
933
  });
@@ -997,17 +991,17 @@ var TransformOperationsManager = /*#__PURE__*/function () {
997
991
 
998
992
  // Check all segments in the scene
999
993
  this.sceneViewer.scene.traverse(function (child) {
1000
- var _child$userData9, _child$userData0;
994
+ var _child$userData7, _child$userData8;
1001
995
  // Skip the segment itself
1002
996
  if (child.uuid === segment.uuid) {
1003
997
  return;
1004
998
  }
1005
999
 
1006
1000
  // Only check computed segments in the scene
1007
- if (((_child$userData9 = child.userData) === null || _child$userData9 === void 0 ? void 0 : _child$userData9.objectType) === 'segment' && (_child$userData0 = child.userData) !== null && _child$userData0 !== void 0 && _child$userData0.isDeclared) {
1008
- var _segment$userData6, _child$userData1, _segment$userData7, _child$userData10;
1001
+ if (((_child$userData7 = child.userData) === null || _child$userData7 === void 0 ? void 0 : _child$userData7.objectType) === 'segment' && (_child$userData8 = child.userData) !== null && _child$userData8 !== void 0 && _child$userData8.isDeclared) {
1002
+ var _segment$userData6, _child$userData9, _segment$userData7, _child$userData0;
1009
1003
  // Check if segments are part of the same connection path
1010
- var sameConnection = ((_segment$userData6 = segment.userData) === null || _segment$userData6 === void 0 ? void 0 : _segment$userData6.pathFrom) === ((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.pathFrom) && ((_segment$userData7 = segment.userData) === null || _segment$userData7 === void 0 ? void 0 : _segment$userData7.pathTo) === ((_child$userData10 = child.userData) === null || _child$userData10 === void 0 ? void 0 : _child$userData10.pathTo);
1004
+ var sameConnection = ((_segment$userData6 = segment.userData) === null || _segment$userData6 === void 0 ? void 0 : _segment$userData6.pathFrom) === ((_child$userData9 = child.userData) === null || _child$userData9 === void 0 ? void 0 : _child$userData9.pathFrom) && ((_segment$userData7 = segment.userData) === null || _segment$userData7 === void 0 ? void 0 : _segment$userData7.pathTo) === ((_child$userData0 = child.userData) === null || _child$userData0 === void 0 ? void 0 : _child$userData0.pathTo);
1011
1005
 
1012
1006
  // Get endpoints of the other segment (use stored endpoints if available)
1013
1007
  var otherEndpoints = _this2.getSegmentEndpoints(child);
@@ -1228,11 +1222,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1228
1222
 
1229
1223
  // Traverse scene to find all component connectors
1230
1224
  this.sceneViewer.scene.traverse(function (child) {
1231
- var _child$userData11;
1225
+ var _child$userData1;
1232
1226
  if (collision) return; // Stop if collision already found
1233
1227
 
1234
1228
  // Check if this is a component connector (not a segment-connector)
1235
- if (((_child$userData11 = child.userData) === null || _child$userData11 === void 0 ? void 0 : _child$userData11.objectType) === 'connector') {
1229
+ if (((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.objectType) === 'connector') {
1236
1230
  var _segment$userData10, _segment$userData11;
1237
1231
  // Skip connectors that are connected to this segment (pathFrom or pathTo)
1238
1232
  var segmentPathFrom = (_segment$userData10 = segment.userData) === null || _segment$userData10 === void 0 ? void 0 : _segment$userData10.pathFrom;
@@ -1346,9 +1340,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1346
1340
 
1347
1341
  // Traverse scene to find all component connectors
1348
1342
  this.sceneViewer.scene.traverse(function (child) {
1349
- var _child$userData12;
1343
+ var _child$userData10;
1350
1344
  // Check if this is a component connector (not a segment-connector)
1351
- if (((_child$userData12 = child.userData) === null || _child$userData12 === void 0 ? void 0 : _child$userData12.objectType) === 'connector') {
1345
+ if (((_child$userData10 = child.userData) === null || _child$userData10 === void 0 ? void 0 : _child$userData10.objectType) === 'connector') {
1352
1346
  // Get world position of connector
1353
1347
  var connectorWorldPos = new THREE__namespace.Vector3();
1354
1348
  child.getWorldPosition(connectorWorldPos);
@@ -1405,11 +1399,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1405
1399
 
1406
1400
  // Traverse scene to find all components
1407
1401
  this.sceneViewer.scene.traverse(function (child) {
1408
- var _child$userData13, _child$userData14;
1402
+ var _child$userData11, _child$userData12;
1409
1403
  if (collision) return; // Stop if collision already found
1410
1404
 
1411
1405
  // Check if this is a component (equipment)
1412
- if (((_child$userData13 = child.userData) === null || _child$userData13 === void 0 ? void 0 : _child$userData13.objectType) === 'component' && (_child$userData14 = child.userData) !== null && _child$userData14 !== void 0 && _child$userData14.libraryId) {
1406
+ if (((_child$userData11 = child.userData) === null || _child$userData11 === void 0 ? void 0 : _child$userData11.objectType) === 'component' && (_child$userData12 = child.userData) !== null && _child$userData12 !== void 0 && _child$userData12.libraryId) {
1413
1407
  // Create bounding box for the component
1414
1408
  var componentBBox = new THREE__namespace.Box3().setFromObject(child);
1415
1409
 
@@ -1448,11 +1442,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1448
1442
 
1449
1443
  // Traverse scene to find all manual segments (isDeclared === true)
1450
1444
  this.sceneViewer.scene.traverse(function (child) {
1451
- var _child$userData15, _child$userData16;
1445
+ var _child$userData13, _child$userData14;
1452
1446
  if (collision) return; // Stop if collision already found
1453
1447
 
1454
1448
  // Only check manual segments (isDeclared === true)
1455
- if (((_child$userData15 = child.userData) === null || _child$userData15 === void 0 ? void 0 : _child$userData15.objectType) === 'segment' && ((_child$userData16 = child.userData) === null || _child$userData16 === void 0 ? void 0 : _child$userData16.isDeclared) === true) {
1449
+ if (((_child$userData13 = child.userData) === null || _child$userData13 === void 0 ? void 0 : _child$userData13.objectType) === 'segment' && ((_child$userData14 = child.userData) === null || _child$userData14 === void 0 ? void 0 : _child$userData14.isDeclared) === true) {
1456
1450
  // Get segment endpoints
1457
1451
  var segmentEndpoints = _this3.getSegmentEndpoints(child);
1458
1452
 
@@ -1541,11 +1535,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1541
1535
 
1542
1536
  // Traverse scene to find all manual segments (isDeclared === true)
1543
1537
  this.sceneViewer.scene.traverse(function (child) {
1544
- var _child$userData17, _child$userData18;
1538
+ var _child$userData15, _child$userData16;
1545
1539
  if (collision) return; // Stop if collision already found
1546
1540
 
1547
1541
  // Only check manual segments (isDeclared === true)
1548
- if (((_child$userData17 = child.userData) === null || _child$userData17 === void 0 ? void 0 : _child$userData17.objectType) === 'segment' && ((_child$userData18 = child.userData) === null || _child$userData18 === void 0 ? void 0 : _child$userData18.isDeclared) === true) {
1542
+ if (((_child$userData15 = child.userData) === null || _child$userData15 === void 0 ? void 0 : _child$userData15.objectType) === 'segment' && ((_child$userData16 = child.userData) === null || _child$userData16 === void 0 ? void 0 : _child$userData16.isDeclared) === true) {
1549
1543
  // Get segment endpoints
1550
1544
  var segmentEndpoints = _this4.getSegmentEndpoints(child);
1551
1545
 
@@ -1602,11 +1596,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1602
1596
 
1603
1597
  // Traverse scene to find all components
1604
1598
  this.sceneViewer.scene.traverse(function (child) {
1605
- var _child$userData19, _child$userData20;
1599
+ var _child$userData17, _child$userData18;
1606
1600
  if (collision) return; // Stop if collision already found
1607
1601
 
1608
1602
  // Check if this is a component (equipment)
1609
- if (((_child$userData19 = child.userData) === null || _child$userData19 === void 0 ? void 0 : _child$userData19.objectType) === 'component' && (_child$userData20 = child.userData) !== null && _child$userData20 !== void 0 && _child$userData20.libraryId) {
1603
+ if (((_child$userData17 = child.userData) === null || _child$userData17 === void 0 ? void 0 : _child$userData17.objectType) === 'component' && (_child$userData18 = child.userData) !== null && _child$userData18 !== void 0 && _child$userData18.libraryId) {
1610
1604
  // Try to get worldBoundingBox from userData first (most up-to-date)
1611
1605
  var bbox = null;
1612
1606
  if (child.userData.worldBoundingBox) {
@@ -1751,8 +1745,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1751
1745
  // Get the moved segment's connectors
1752
1746
  var movedConnectors = [];
1753
1747
  movedSegment.traverse(function (child) {
1754
- var _child$userData21;
1755
- if (((_child$userData21 = child.userData) === null || _child$userData21 === void 0 ? void 0 : _child$userData21.objectType) === 'segment-connector') {
1748
+ var _child$userData19;
1749
+ if (((_child$userData19 = child.userData) === null || _child$userData19 === void 0 ? void 0 : _child$userData19.objectType) === 'segment-connector') {
1756
1750
  movedConnectors.push(child);
1757
1751
  }
1758
1752
  });
@@ -1822,8 +1816,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1822
1816
  // Get all connectors of the adjacent segment
1823
1817
  var adjacentConnectors = [];
1824
1818
  adjacentSegment.traverse(function (child) {
1825
- var _child$userData22;
1826
- if (((_child$userData22 = child.userData) === null || _child$userData22 === void 0 ? void 0 : _child$userData22.objectType) === 'segment-connector') {
1819
+ var _child$userData20;
1820
+ if (((_child$userData20 = child.userData) === null || _child$userData20 === void 0 ? void 0 : _child$userData20.objectType) === 'segment-connector') {
1827
1821
  adjacentConnectors.push(child);
1828
1822
  }
1829
1823
  });
@@ -1946,8 +1940,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
1946
1940
  // Also update child connectors' positions if they exist
1947
1941
  if (sceneDataComponent.children) {
1948
1942
  sceneDataComponent.children.forEach(function (child) {
1949
- var _child$userData23;
1950
- if (((_child$userData23 = child.userData) === null || _child$userData23 === void 0 ? void 0 : _child$userData23.objectType) === 'connector') {
1943
+ var _child$userData21;
1944
+ if (((_child$userData21 = child.userData) === null || _child$userData21 === void 0 ? void 0 : _child$userData21.objectType) === 'connector') {
1951
1945
  // Find the actual connector object in the scene
1952
1946
  var connectorObj = component.children.find(function (c) {
1953
1947
  var _c$userData;
@@ -2009,14 +2003,15 @@ var TransformOperationsManager = /*#__PURE__*/function () {
2009
2003
  // Also update child connectors' positions if they exist (rotation moves them in world space)
2010
2004
  if (sceneDataComponent.children) {
2011
2005
  sceneDataComponent.children.forEach(function (child) {
2012
- var _child$userData24;
2013
- if (((_child$userData24 = child.userData) === null || _child$userData24 === void 0 ? void 0 : _child$userData24.objectType) === 'connector') {
2006
+ var _child$userData22;
2007
+ if (((_child$userData22 = child.userData) === null || _child$userData22 === void 0 ? void 0 : _child$userData22.objectType) === 'connector') {
2014
2008
  // Find the actual connector object in the scene
2015
2009
  var connectorObj = component.children.find(function (c) {
2016
2010
  var _c$userData2;
2017
2011
  return c.uuid === child.uuid || ((_c$userData2 = c.userData) === null || _c$userData2 === void 0 ? void 0 : _c$userData2.originalUuid) === child.uuid;
2018
2012
  });
2019
2013
  if (connectorObj) {
2014
+ var _connectorObj$userDat;
2020
2015
  // Get world position of connector
2021
2016
  var worldPos = new THREE__namespace.Vector3();
2022
2017
  connectorObj.getWorldPosition(worldPos);
@@ -2027,6 +2022,12 @@ var TransformOperationsManager = /*#__PURE__*/function () {
2027
2022
  }
2028
2023
  child.userData.position = [cleanValue(worldPos.x), cleanValue(worldPos.y), cleanValue(worldPos.z)];
2029
2024
  console.log(" \u21B3 Updated child connector ".concat(child.uuid, " position to [").concat(child.userData.position.join(', '), "]"));
2025
+
2026
+ // Update connector's direction in scene data from the Three.js object
2027
+ if ((_connectorObj$userDat = connectorObj.userData) !== null && _connectorObj$userDat !== void 0 && _connectorObj$userDat.direction && Array.isArray(connectorObj.userData.direction)) {
2028
+ child.userData.direction = _rollupPluginBabelHelpers.toConsumableArray(connectorObj.userData.direction);
2029
+ console.log(" \u21B3 Updated child connector ".concat(child.uuid, " direction to [").concat(child.userData.direction.join(', '), "]"));
2030
+ }
2030
2031
  }
2031
2032
  }
2032
2033
  });
@@ -2339,8 +2340,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
2339
2340
  // Check if either external connector belongs to the active segment
2340
2341
  var activeSegmentConnectors = [];
2341
2342
  activeSegment.traverse(function (child) {
2342
- var _child$userData25;
2343
- if (((_child$userData25 = child.userData) === null || _child$userData25 === void 0 ? void 0 : _child$userData25.objectType) === 'segment-connector') {
2343
+ var _child$userData23;
2344
+ if (((_child$userData23 = child.userData) === null || _child$userData23 === void 0 ? void 0 : _child$userData23.objectType) === 'segment-connector') {
2344
2345
  activeSegmentConnectors.push(child.uuid);
2345
2346
  }
2346
2347
  });
@@ -2388,8 +2389,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
2388
2389
  // Get all connectors of the active segment
2389
2390
  var activeConnectors = [];
2390
2391
  activeSegment.traverse(function (child) {
2391
- var _child$userData26;
2392
- if (((_child$userData26 = child.userData) === null || _child$userData26 === void 0 ? void 0 : _child$userData26.objectType) === 'segment-connector') {
2392
+ var _child$userData24;
2393
+ if (((_child$userData24 = child.userData) === null || _child$userData24 === void 0 ? void 0 : _child$userData24.objectType) === 'segment-connector') {
2393
2394
  activeConnectors.push(child);
2394
2395
  }
2395
2396
  });
@@ -171,15 +171,23 @@ var ModelManager = /*#__PURE__*/function () {
171
171
  if (child.userData) {
172
172
  clonedConnector.userData = _rollupPluginBabelHelpers.objectSpread2({}, child.userData);
173
173
 
174
- // Deep copy critical data
174
+ // Deep copy critical data - handle both array [x,y,z] and object {x,y,z} formats
175
175
  if (child.userData.worldBoundingBox) {
176
+ var wbb = child.userData.worldBoundingBox;
176
177
  clonedConnector.userData.worldBoundingBox = {
177
- min: _rollupPluginBabelHelpers.toConsumableArray(child.userData.worldBoundingBox.min),
178
- max: _rollupPluginBabelHelpers.toConsumableArray(child.userData.worldBoundingBox.max)
178
+ min: Array.isArray(wbb.min) ? _rollupPluginBabelHelpers.toConsumableArray(wbb.min) : _rollupPluginBabelHelpers.objectSpread2({}, wbb.min),
179
+ max: Array.isArray(wbb.max) ? _rollupPluginBabelHelpers.toConsumableArray(wbb.max) : _rollupPluginBabelHelpers.objectSpread2({}, wbb.max)
179
180
  };
180
181
  }
181
182
  if (child.userData.direction) {
182
- clonedConnector.userData.direction = _rollupPluginBabelHelpers.toConsumableArray(child.userData.direction);
183
+ // Handle both array [x,y,z] and object {x,y,z} formats
184
+ if (Array.isArray(child.userData.direction)) {
185
+ clonedConnector.userData.direction = _rollupPluginBabelHelpers.toConsumableArray(child.userData.direction);
186
+ } else if (_rollupPluginBabelHelpers["typeof"](child.userData.direction) === 'object') {
187
+ clonedConnector.userData.direction = _rollupPluginBabelHelpers.objectSpread2({}, child.userData.direction);
188
+ } else {
189
+ clonedConnector.userData.direction = child.userData.direction;
190
+ }
183
191
  }
184
192
 
185
193
  // Set originalUuid to match the actual uuid (maintains consistency)
@@ -31,7 +31,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
31
31
  * Initialize the CentralPlant manager
32
32
  *
33
33
  * @constructor
34
- * @version 0.3.17
34
+ * @version 0.3.19
35
35
  * @updated 2025-10-22
36
36
  *
37
37
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -0,0 +1,111 @@
1
+ import { toConsumableArray as _toConsumableArray, slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+
3
+ /**
4
+ * Utility function to update userData.direction for components after 90-degree rotation
5
+ * This function handles the direction vector transformation for connectors when their parent component is rotated
6
+ *
7
+ * @param {THREE.Object3D} component - The component that was rotated
8
+ * @param {string} axis - The axis of rotation ('x', 'y', or 'z')
9
+ * @param {number} degrees - The rotation angle in degrees (should be multiple of 90)
10
+ */
11
+ function updateDirectionAfterRotation(component, axis, degrees) {
12
+ if (!component) {
13
+ console.warn('⚠️ updateDirectionAfterRotation: No component provided');
14
+ return;
15
+ }
16
+
17
+ // Only handle 90-degree increments
18
+ if (degrees % 90 !== 0) {
19
+ console.warn('⚠️ updateDirectionAfterRotation: Only 90-degree increments are supported');
20
+ return;
21
+ }
22
+
23
+ // Normalize degrees to 0-360 range
24
+ var normalizedDegrees = (degrees % 360 + 360) % 360;
25
+ console.log("\uD83D\uDD04 Updating direction vectors for ".concat(component.name || component.uuid, " after ").concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
26
+
27
+ // Traverse all children (connectors) and update their direction vectors
28
+ component.traverse(function (child) {
29
+ var _child$userData, _child$userData2;
30
+ var childType = ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.objectType) || ((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.objectType);
31
+ if (child.userData && Array.isArray(child.userData.direction) && childType === 'connector') {
32
+ var originalDirection = _toConsumableArray(child.userData.direction);
33
+ var newDirection = rotateDirectionVector(originalDirection, axis, normalizedDegrees);
34
+
35
+ // Update the direction
36
+ child.userData.direction = newDirection;
37
+ console.log("\uD83D\uDCCD Updated connector ".concat(child.name || child.uuid, " direction:"), {
38
+ original: originalDirection,
39
+ new: newDirection,
40
+ rotationAxis: axis,
41
+ rotationDegrees: degrees
42
+ });
43
+ }
44
+ });
45
+ }
46
+
47
+ /**
48
+ * Rotate a direction vector by 90-degree increments around a specific axis
49
+ *
50
+ * @param {Array<number>} direction - The original direction vector [x, y, z]
51
+ * @param {string} axis - The axis of rotation ('x', 'y', or 'z')
52
+ * @param {number} degrees - The rotation angle in degrees (must be multiple of 90)
53
+ * @returns {Array<number>} The new direction vector [x, y, z]
54
+ */
55
+ function rotateDirectionVector(direction, axis, degrees) {
56
+ if (!Array.isArray(direction) || direction.length !== 3) {
57
+ console.warn('⚠️ rotateDirectionVector: Invalid direction vector');
58
+ return direction;
59
+ }
60
+ var _direction = _slicedToArray(direction, 3),
61
+ x = _direction[0],
62
+ y = _direction[1],
63
+ z = _direction[2];
64
+ var steps = degrees / 90; // Number of 90-degree steps
65
+
66
+ for (var i = 0; i < steps; i++) {
67
+ var newX = x,
68
+ newY = y,
69
+ newZ = z;
70
+ switch (axis) {
71
+ case 'x':
72
+ // Rotation around X-axis in Z-up system with flipped Y: Y becomes -Z, Z becomes Y
73
+ newY = -z;
74
+ newZ = y;
75
+ break;
76
+ case 'y':
77
+ // Rotation around Y-axis in Z-up system with flipped Y: X becomes Z, Z becomes -X
78
+ newX = z;
79
+ newZ = -x;
80
+ break;
81
+ case 'z':
82
+ // Rotation around Z-axis in Z-up system with flipped Y: X becomes -Y, Y becomes X
83
+ newX = -y;
84
+ newY = x;
85
+ break;
86
+ default:
87
+ console.warn("\u26A0\uFE0F rotateDirectionVector: Invalid axis '".concat(axis, "'"));
88
+ return direction;
89
+ }
90
+ x = newX;
91
+ y = newY;
92
+ z = newZ;
93
+ }
94
+ return [x, y, z];
95
+ }
96
+
97
+ /**
98
+ * Example usage in your rotate method:
99
+ *
100
+ * // After applying rotation to the component
101
+ * component.rotation[axis] += radians
102
+ *
103
+ * // Update direction vectors for connectors
104
+ * updateDirectionAfterRotation(component, axis, value)
105
+ *
106
+ * // Update matrices
107
+ * component.updateMatrix()
108
+ * component.updateMatrixWorld(true)
109
+ */
110
+
111
+ export { updateDirectionAfterRotation };
@@ -24,12 +24,14 @@ function _measureS3Transfer() {
24
24
  var fileSize,
25
25
  startTime,
26
26
  executeTransfer,
27
+ isExpiredToken,
27
28
  Auth,
28
29
  endTime,
29
30
  duration,
30
31
  _args2 = arguments,
31
32
  _t,
32
- _t2;
33
+ _t2,
34
+ _t3;
33
35
  return _regenerator().w(function (_context2) {
34
36
  while (1) switch (_context2.n) {
35
37
  case 0:
@@ -70,8 +72,12 @@ function _measureS3Transfer() {
70
72
  case 3:
71
73
  _context2.p = 3;
72
74
  _t = _context2.v;
73
- if (!(_t.code === 'ExpiredToken' || _t.message && _t.message.includes('ExpiredToken'))) {
74
- _context2.n = 8;
75
+ // Check for ExpiredToken error.
76
+ // AWS SDK v3 (used by Amplify v5) sets error.name, not error.code.
77
+ // error.message is 'The provided token has expired.' (no 'ExpiredToken' substring).
78
+ isExpiredToken = _t.code === 'ExpiredToken' || _t.Code === 'ExpiredToken' || _t.name === 'ExpiredToken' || _t.message && _t.message.toLowerCase().includes('token has expired');
79
+ if (!isExpiredToken) {
80
+ _context2.n = 12;
75
81
  break;
76
82
  }
77
83
  console.warn("\u26A0\uFE0F Token expired during ".concat(operation, ". Attempting session refresh and retry..."));
@@ -84,35 +90,50 @@ function _measureS3Transfer() {
84
90
  throw _t;
85
91
  case 4:
86
92
  _context2.p = 4;
87
- _context2.n = 5;
93
+ _context2.p = 5;
94
+ _context2.n = 6;
95
+ return Auth.currentSession();
96
+ case 6:
97
+ console.log("\u2705 User Pool session refreshed for ".concat(operation, "."));
98
+ _context2.n = 8;
99
+ break;
100
+ case 7:
101
+ _context2.p = 7;
102
+ _t2 = _context2.v;
103
+ // If currentSession() fails the refresh token itself is expired —
104
+ // the user needs to sign in again. Surface that immediately.
105
+ console.error("\u274C Failed to refresh User Pool session during ".concat(operation, ":"), _t2);
106
+ throw _t2;
107
+ case 8:
108
+ _context2.n = 9;
88
109
  return Auth.currentCredentials({
89
110
  bypassCache: true
90
111
  });
91
- case 5:
92
- console.log("\u2705 Session refreshed. Retrying ".concat(operation, "..."));
112
+ case 9:
113
+ console.log("\u2705 STS credentials refreshed. Retrying ".concat(operation, "..."));
93
114
 
94
115
  // Reset timer for the retry
95
116
  startTime = performance.now();
96
- _context2.n = 6;
117
+ _context2.n = 10;
97
118
  return executeTransfer();
98
- case 6:
119
+ case 10:
99
120
  return _context2.a(2, _context2.v);
100
- case 7:
101
- _context2.p = 7;
102
- _t2 = _context2.v;
103
- console.error("\u274C Retry failed for ".concat(operation, ":"), _t2);
121
+ case 11:
122
+ _context2.p = 11;
123
+ _t3 = _context2.v;
124
+ console.error("\u274C Retry failed for ".concat(operation, ":"), _t3);
104
125
  // If retry fails, throw the Retry Error (likely unrelated or persistent auth issue)
105
- throw _t2;
106
- case 8:
126
+ throw _t3;
127
+ case 12:
107
128
  // Standard error handling for non-expired tokens (or if logic above didn't catch it)
108
129
  endTime = performance.now();
109
130
  duration = ((endTime - startTime) / 1000).toFixed(3);
110
131
  console.error("\u274C S3 ".concat(operation, " failed after ").concat(duration, "s:"), _t);
111
132
  throw _t;
112
- case 9:
133
+ case 13:
113
134
  return _context2.a(2);
114
135
  }
115
- }, _callee2, null, [[4, 7], [1, 3]]);
136
+ }, _callee2, null, [[5, 7], [4, 11], [1, 3]]);
116
137
  }));
117
138
  return _measureS3Transfer.apply(this, arguments);
118
139
  }