kitchen-simulator 3.1.15 → 3.3.0

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.
@@ -137,6 +137,7 @@ export default function (_ref) {
137
137
  img: base,
138
138
  obj: obj_property,
139
139
  cds: cds,
140
+ structure_json: structure_json,
140
141
  render2D: function render2D(element, layer, scene) {
141
142
  return render2DItem.call(this, element, layer, scene, sizeinfo, layoutpos, is_corner, shape_svg);
142
143
  },
@@ -16,7 +16,7 @@ import { verticesDistance } from "../../utils/geometry";
16
16
  import * as GeomUtils from "../../catalog/utils/geom-utils";
17
17
  import { loadTexture } from "../../catalog/utils/item-loader";
18
18
  import { returnReplaceableDeepSearchType } from "../viewer2d/utils";
19
- import { animateDoor, isElevationView, isEmpty, replaceMeshesWithLineSegments, translateDrawer } from "../../utils/helper";
19
+ import { animateDoor, isElevationView, isEmpty, isImmutable, replaceMeshesWithLineSegments, translateDrawer } from "../../utils/helper";
20
20
  import { formatNumber } from "../../utils/math";
21
21
  var transformBox;
22
22
  export var fVLine = [];
@@ -187,6 +187,31 @@ export function createWarningObject() {
187
187
  warningObj.name = 'warningObj';
188
188
  return warningObj;
189
189
  }
190
+ function swapLengthProperty(diffs) {
191
+ var idx1 = diffs.findIndex(function (v) {
192
+ return v.path[v.path.length - 1] === 'length';
193
+ });
194
+ var idx2 = diffs.findIndex(function (v) {
195
+ return v.path[v.path.length - 1] === '_length';
196
+ });
197
+ if (idx1 < 0 || idx2 < 0) return diffs;
198
+ if (idx1 > idx2) return diffs;
199
+ if (diffs[idx1].op === diffs[idx2].op) {
200
+ var isSwap = true;
201
+ for (var i = 0; i < diffs[idx1].path.length - 2; i++) {
202
+ if (diffs[idx1].path[i] !== diffs[idx2].path[i]) {
203
+ isSwap = false;
204
+ break;
205
+ }
206
+ }
207
+ if (isSwap) {
208
+ var temp = diffs[idx1];
209
+ diffs[idx1] = diffs[idx2];
210
+ diffs[idx2] = temp;
211
+ }
212
+ }
213
+ return diffs;
214
+ }
190
215
  export function updateScene(planData, sceneData, oldSceneData, diffArray, actions, catalog) {
191
216
  var _draggingItem$toJS, _filteredDiffs, _filteredDiffs2;
192
217
  var mode = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
@@ -204,6 +229,9 @@ export function updateScene(planData, sceneData, oldSceneData, diffArray, action
204
229
  value: el.value
205
230
  };
206
231
  });
232
+
233
+ // move "length" to after "_length"
234
+ splitted = swapLengthProperty(splitted);
207
235
  var filteredDiffs = filterDiffs(splitted, sceneData, oldSceneData);
208
236
  //***testing additional filter***
209
237
  filteredDiffs = filteredDiffs.filter(function (_ref) {
@@ -3418,9 +3446,11 @@ export function updateMoldingGroupArray(MGArray, selItem, planData, layer) {
3418
3446
  // refresh mesh of the updating molding groups
3419
3447
  new_MGArray.forEach(function (mg, index) {
3420
3448
  if (mg.items[0].molding.some(function (mol) {
3421
- return mol.location_type === mg.location_type;
3449
+ return isImmutable(mol) ? mol.toJS().location_type === mg.location_type : mol.location_type === mg.location_type;
3422
3450
  })) {
3423
- var molding = mg.items[0].molding.filter(function (mol) {
3451
+ var molding = isImmutable(mg.items[0].molding) ? mg.items[0].molding.filter(function (mol) {
3452
+ return mol.toJS().location_type === mg.location_type;
3453
+ }).toJS()[0] : mg.items[0].molding.filter(function (mol) {
3424
3454
  return mol.location_type === mg.location_type;
3425
3455
  })[0];
3426
3456
  if (mg.molding === null || mg.molding.itemID !== mol.itemID || mg.lines === null || mg.points === null) {
@@ -1490,8 +1490,8 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1490
1490
  }
1491
1491
  gridMatrix.copy(gridPlane.matrixWorld).invert();
1492
1492
  var addItemToolObj = function addItemToolObj() {
1493
- var _intersects$_i;
1494
- var selectedItem = planData.sceneGraph.layers[selectedObject.layerID].items[selectedObject.itemID];
1493
+ var _planData$sceneGraph, _selectedObject, _intersects$_i;
1494
+ var selectedItem = (_planData$sceneGraph = planData.sceneGraph) === null || _planData$sceneGraph === void 0 || (_planData$sceneGraph = _planData$sceneGraph.layers[selectedObject.layerID]) === null || _planData$sceneGraph === void 0 ? void 0 : _planData$sceneGraph.items[(_selectedObject = selectedObject) === null || _selectedObject === void 0 ? void 0 : _selectedObject.itemID];
1495
1495
  if (isUndefined(selectedItem)) return;
1496
1496
  selectedElement = _this2.props.state.scene.layers.get(selectedObject.layerID).items.get(selectedObject.itemID);
1497
1497
  var itemPos = selectedItem.position.clone();
@@ -1592,6 +1592,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1592
1592
  selectedObj = allItemRect.cur;
1593
1593
  }
1594
1594
  } else {
1595
+ var _planData$sceneGraph2, _selectedObject2, _selectedObject3;
1595
1596
  visibleTransformBox(false);
1596
1597
  var alti = 0;
1597
1598
  if (allItemRect && allItemRect.cur && allItemRect.cur.itemInfo !== undefined) {
@@ -1601,16 +1602,17 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1601
1602
  alti = convert(alti).from(_unit2).to(_this2.props.state.scene.unit);
1602
1603
  }
1603
1604
  getPoint(event, alti);
1605
+ var _selectedItem = planData === null || planData === void 0 || (_planData$sceneGraph2 = planData.sceneGraph) === null || _planData$sceneGraph2 === void 0 || (_planData$sceneGraph2 = _planData$sceneGraph2.layers[(_selectedObject2 = selectedObject) === null || _selectedObject2 === void 0 ? void 0 : _selectedObject2.layerID]) === null || _planData$sceneGraph2 === void 0 ? void 0 : _planData$sceneGraph2.items[(_selectedObject3 = selectedObject) === null || _selectedObject3 === void 0 ? void 0 : _selectedObject3.itemID];
1606
+ if (isSelected && !isEmpty(_selectedItem)) addItemToolObj();
1604
1607
  if (bRotate) {
1605
- addItemToolObj();
1606
1608
  _this2.setState({
1607
1609
  toolObj: toolObj
1608
1610
  });
1609
1611
  _this2.context.itemsActions.endRotatingItem3D(Point.x, Point.y);
1610
1612
  bRotate = false;
1611
- } else if (bMove) {
1613
+ }
1614
+ if (bMove) {
1612
1615
  bMove = false;
1613
- addItemToolObj();
1614
1616
  _this2.setState({
1615
1617
  toolObj: toolObj
1616
1618
  });
@@ -1630,7 +1632,7 @@ var Scene3DViewer = /*#__PURE__*/function (_React$Component) {
1630
1632
  _item3D.position.z = targetPoint.z;
1631
1633
  _item3D.visible = true;
1632
1634
  }
1633
- } else {}
1635
+ }
1634
1636
  if (bMoveUP) {
1635
1637
  bMoveUP = false;
1636
1638
  }
package/es/index.js CHANGED
@@ -4,26 +4,335 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
8
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
14
  import React from 'react';
10
- import ReactDOM from 'react-dom';
11
15
  import LiteRenderer from "./LiteRenderer";
16
+ import { createRoot } from 'react-dom/client';
17
+ function nextFrame() {
18
+ return new Promise(function (resolve) {
19
+ return requestAnimationFrame(resolve);
20
+ });
21
+ }
22
+ function sleep(ms) {
23
+ return new Promise(function (resolve) {
24
+ return setTimeout(resolve, ms);
25
+ });
26
+ }
27
+
28
+ /**
29
+ * Track GLTF/GLB network activity via XHR + fetch.
30
+ * Returns { getInFlight, waitForIdle, uninstall }.
31
+ */
32
+ function installGltfTracker() {
33
+ var _XHR$prototype, _XHR$prototype2;
34
+ if (typeof window === 'undefined') {
35
+ return {
36
+ getInFlight: function getInFlight() {
37
+ return 0;
38
+ },
39
+ waitForIdle: function () {
40
+ var _waitForIdle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
41
+ return _regeneratorRuntime.wrap(function (_context) {
42
+ while (1) switch (_context.prev = _context.next) {
43
+ case 0:
44
+ return _context.abrupt("return", true);
45
+ case 1:
46
+ case "end":
47
+ return _context.stop();
48
+ }
49
+ }, _callee);
50
+ }));
51
+ function waitForIdle() {
52
+ return _waitForIdle.apply(this, arguments);
53
+ }
54
+ return waitForIdle;
55
+ }(),
56
+ uninstall: function uninstall() {}
57
+ };
58
+ }
59
+ var inFlight = 0;
60
+ var listeners = new Set();
61
+ var notify = function notify() {
62
+ var _iterator = _createForOfIteratorHelper(listeners),
63
+ _step;
64
+ try {
65
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
66
+ var fn = _step.value;
67
+ fn(inFlight);
68
+ }
69
+ } catch (err) {
70
+ _iterator.e(err);
71
+ } finally {
72
+ _iterator.f();
73
+ }
74
+ };
75
+ var isGltfUrl = function isGltfUrl(url) {
76
+ try {
77
+ var _url$toString, _url$toString2;
78
+ var s = typeof url === 'string' ? url : (_url$toString = url === null || url === void 0 || (_url$toString2 = url.toString) === null || _url$toString2 === void 0 ? void 0 : _url$toString2.call(url)) !== null && _url$toString !== void 0 ? _url$toString : '';
79
+ var u = s.toLowerCase();
80
+ return u.includes('.gltf') || u.includes('.glb');
81
+ } catch (_unused) {
82
+ return false;
83
+ }
84
+ };
85
+
86
+ // ---- XHR hook ----
87
+ var XHR = window.XMLHttpRequest;
88
+ var originalOpen = null;
89
+ var originalSend = null;
90
+ if (XHR !== null && XHR !== void 0 && (_XHR$prototype = XHR.prototype) !== null && _XHR$prototype !== void 0 && _XHR$prototype.open && XHR !== null && XHR !== void 0 && (_XHR$prototype2 = XHR.prototype) !== null && _XHR$prototype2 !== void 0 && _XHR$prototype2.send) {
91
+ originalOpen = XHR.prototype.open;
92
+ originalSend = XHR.prototype.send;
93
+ XHR.prototype.open = function (method, url) {
94
+ var _originalOpen;
95
+ this.__isGltfRequest = isGltfUrl(url);
96
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
97
+ rest[_key - 2] = arguments[_key];
98
+ }
99
+ return (_originalOpen = originalOpen).call.apply(_originalOpen, [this, method, url].concat(rest));
100
+ };
101
+ XHR.prototype.send = function () {
102
+ var _this = this;
103
+ if (this.__isGltfRequest) {
104
+ inFlight += 1;
105
+ notify();
106
+ var _done = function done() {
107
+ inFlight -= 1;
108
+ if (inFlight < 0) inFlight = 0;
109
+ notify();
110
+ _this.removeEventListener('loadend', _done);
111
+ };
112
+ this.addEventListener('loadend', _done);
113
+ }
114
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
115
+ args[_key2] = arguments[_key2];
116
+ }
117
+ return originalSend.apply(this, args);
118
+ };
119
+ }
120
+
121
+ // ---- fetch hook ----
122
+ var originalFetch = window.fetch;
123
+ if (typeof originalFetch === 'function') {
124
+ window.fetch = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
125
+ var _len3,
126
+ args,
127
+ _key3,
128
+ url,
129
+ track,
130
+ _args2 = arguments;
131
+ return _regeneratorRuntime.wrap(function (_context2) {
132
+ while (1) switch (_context2.prev = _context2.next) {
133
+ case 0:
134
+ for (_len3 = _args2.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
135
+ args[_key3] = _args2[_key3];
136
+ }
137
+ url = args === null || args === void 0 ? void 0 : args[0];
138
+ track = isGltfUrl(url);
139
+ if (track) {
140
+ _context2.next = 1;
141
+ break;
142
+ }
143
+ return _context2.abrupt("return", originalFetch.apply(this, args));
144
+ case 1:
145
+ inFlight += 1;
146
+ notify();
147
+ _context2.prev = 2;
148
+ _context2.next = 3;
149
+ return originalFetch.apply(this, args);
150
+ case 3:
151
+ return _context2.abrupt("return", _context2.sent);
152
+ case 4:
153
+ _context2.prev = 4;
154
+ inFlight -= 1;
155
+ if (inFlight < 0) inFlight = 0;
156
+ notify();
157
+ return _context2.finish(4);
158
+ case 5:
159
+ case "end":
160
+ return _context2.stop();
161
+ }
162
+ }, _callee2, this, [[2,, 4, 5]]);
163
+ }));
164
+ }
165
+ var subscribe = function subscribe(fn) {
166
+ listeners.add(fn);
167
+ fn(inFlight);
168
+ return function () {
169
+ return listeners["delete"](fn);
170
+ };
171
+ };
172
+
173
+ /**
174
+ * Wait until GLTF network is idle (inFlight===0).
175
+ * Includes a grace window to catch loads that start slightly after the event.
176
+ */
177
+ var waitForIdle = /*#__PURE__*/function () {
178
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
179
+ var _ref3,
180
+ _ref3$timeoutMs,
181
+ timeoutMs,
182
+ _ref3$graceMs,
183
+ graceMs,
184
+ start,
185
+ _args3 = arguments;
186
+ return _regeneratorRuntime.wrap(function (_context3) {
187
+ while (1) switch (_context3.prev = _context3.next) {
188
+ case 0:
189
+ _ref3 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref3$timeoutMs = _ref3.timeoutMs, timeoutMs = _ref3$timeoutMs === void 0 ? 30000 : _ref3$timeoutMs, _ref3$graceMs = _ref3.graceMs, graceMs = _ref3$graceMs === void 0 ? 50 : _ref3$graceMs;
190
+ start = Date.now(); // Grace: give async pipelines a chance to start requests
191
+ if (!(graceMs > 0)) {
192
+ _context3.next = 1;
193
+ break;
194
+ }
195
+ _context3.next = 1;
196
+ return sleep(graceMs);
197
+ case 1:
198
+ return _context3.abrupt("return", new Promise(function (resolve, reject) {
199
+ var unsub = subscribe(function (count) {
200
+ if (count === 0) {
201
+ unsub();
202
+ resolve(true);
203
+ return;
204
+ }
205
+ if (Date.now() - start > timeoutMs) {
206
+ unsub();
207
+ reject(new Error('GLTF did not become idle within timeout'));
208
+ }
209
+ });
210
+ }));
211
+ case 2:
212
+ case "end":
213
+ return _context3.stop();
214
+ }
215
+ }, _callee3);
216
+ }));
217
+ return function waitForIdle() {
218
+ return _ref2.apply(this, arguments);
219
+ };
220
+ }();
221
+ var uninstall = function uninstall() {
222
+ var _XHR$prototype3, _XHR$prototype4;
223
+ if (XHR !== null && XHR !== void 0 && (_XHR$prototype3 = XHR.prototype) !== null && _XHR$prototype3 !== void 0 && _XHR$prototype3.open && originalOpen) XHR.prototype.open = originalOpen;
224
+ if (XHR !== null && XHR !== void 0 && (_XHR$prototype4 = XHR.prototype) !== null && _XHR$prototype4 !== void 0 && _XHR$prototype4.send && originalSend) XHR.prototype.send = originalSend;
225
+ if (typeof originalFetch === 'function') window.fetch = originalFetch;
226
+ listeners.clear();
227
+ inFlight = 0;
228
+ };
229
+ return {
230
+ getInFlight: function getInFlight() {
231
+ return inFlight;
232
+ },
233
+ waitForIdle: waitForIdle,
234
+ uninstall: uninstall
235
+ };
236
+ }
12
237
  export function renderKitchenSimulator(container) {
238
+ var _props$framesPerEvent, _props$waitForGltfIdl, _props$gltfTimeoutMs, _props$gltfGraceMs;
13
239
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
240
+ var root = createRoot(container);
14
241
  var setExternalEventFn = null;
242
+ var queue = [];
243
+ var pendingMarkers = new Set();
244
+ var draining = false;
245
+ var destroyed = false;
246
+ var FRAMES_PER_EVENT = (_props$framesPerEvent = props.framesPerEvent) !== null && _props$framesPerEvent !== void 0 ? _props$framesPerEvent : 2;
247
+
248
+ // ✅ assume all events may load gltfs
249
+ var WAIT_FOR_GLTF_IDLE_AFTER_EACH_EVENT = (_props$waitForGltfIdl = props.waitForGltfIdleAfterEachEvent) !== null && _props$waitForGltfIdl !== void 0 ? _props$waitForGltfIdl : true;
250
+ var GLTF_TIMEOUT_MS = (_props$gltfTimeoutMs = props.gltfTimeoutMs) !== null && _props$gltfTimeoutMs !== void 0 ? _props$gltfTimeoutMs : 30000;
251
+ var GLTF_GRACE_MS = (_props$gltfGraceMs = props.gltfGraceMs) !== null && _props$gltfGraceMs !== void 0 ? _props$gltfGraceMs : 50;
252
+ var gltfTracker = installGltfTracker();
253
+ function drain() {
254
+ return _drain.apply(this, arguments);
255
+ }
256
+ function _drain() {
257
+ _drain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
258
+ var _setExternalEventFn, ev, i, _ev$gltfTimeoutMs, _ev$gltfGraceMs;
259
+ return _regeneratorRuntime.wrap(function (_context5) {
260
+ while (1) switch (_context5.prev = _context5.next) {
261
+ case 0:
262
+ if (!(draining || destroyed)) {
263
+ _context5.next = 1;
264
+ break;
265
+ }
266
+ return _context5.abrupt("return");
267
+ case 1:
268
+ draining = true;
269
+ _context5.prev = 2;
270
+ case 3:
271
+ if (!(queue.length && !destroyed)) {
272
+ _context5.next = 10;
273
+ break;
274
+ }
275
+ ev = queue.shift(); // skip internal markers
276
+ if (!(ev && ev.__batchMarker)) {
277
+ _context5.next = 4;
278
+ break;
279
+ }
280
+ pendingMarkers["delete"](ev.__batchMarker);
281
+ return _context5.abrupt("continue", 3);
282
+ case 4:
283
+ (_setExternalEventFn = setExternalEventFn) === null || _setExternalEventFn === void 0 || _setExternalEventFn(ev);
15
284
 
16
- // Internal wrapper that exposes a state setter
285
+ // baseline spacing for react + legacy lifecycle
286
+ i = 0;
287
+ case 5:
288
+ if (!(i < FRAMES_PER_EVENT)) {
289
+ _context5.next = 7;
290
+ break;
291
+ }
292
+ _context5.next = 6;
293
+ return nextFrame();
294
+ case 6:
295
+ i += 1;
296
+ _context5.next = 5;
297
+ break;
298
+ case 7:
299
+ if (!WAIT_FOR_GLTF_IDLE_AFTER_EACH_EVENT) {
300
+ _context5.next = 9;
301
+ break;
302
+ }
303
+ _context5.next = 8;
304
+ return gltfTracker.waitForIdle({
305
+ timeoutMs: (_ev$gltfTimeoutMs = ev === null || ev === void 0 ? void 0 : ev.gltfTimeoutMs) !== null && _ev$gltfTimeoutMs !== void 0 ? _ev$gltfTimeoutMs : GLTF_TIMEOUT_MS,
306
+ graceMs: (_ev$gltfGraceMs = ev === null || ev === void 0 ? void 0 : ev.gltfGraceMs) !== null && _ev$gltfGraceMs !== void 0 ? _ev$gltfGraceMs : GLTF_GRACE_MS
307
+ });
308
+ case 8:
309
+ _context5.next = 9;
310
+ return nextFrame();
311
+ case 9:
312
+ _context5.next = 3;
313
+ break;
314
+ case 10:
315
+ _context5.prev = 10;
316
+ draining = false;
317
+ return _context5.finish(10);
318
+ case 11:
319
+ case "end":
320
+ return _context5.stop();
321
+ }
322
+ }, _callee5, null, [[2,, 10, 11]]);
323
+ }));
324
+ return _drain.apply(this, arguments);
325
+ }
17
326
  var Wrapper = /*#__PURE__*/function (_React$Component) {
18
327
  function Wrapper(p) {
19
- var _this;
328
+ var _this2;
20
329
  _classCallCheck(this, Wrapper);
21
- _this = _callSuper(this, Wrapper, [p]);
22
- _this.state = {
330
+ _this2 = _callSuper(this, Wrapper, [p]);
331
+ _this2.state = {
23
332
  externalEvent: p.externalEvent || null
24
333
  };
25
- setExternalEventFn = _this.setExternalEvent.bind(_this);
26
- return _this;
334
+ setExternalEventFn = _this2.setExternalEvent.bind(_this2);
335
+ return _this2;
27
336
  }
28
337
  _inherits(Wrapper, _React$Component);
29
338
  return _createClass(Wrapper, [{
@@ -41,15 +350,80 @@ export function renderKitchenSimulator(container) {
41
350
  }));
42
351
  }
43
352
  }]);
44
- }(React.Component); // Mount once
45
- ReactDOM.render(/*#__PURE__*/React.createElement(Wrapper, props), container);
353
+ }(React.Component);
354
+ root.render(/*#__PURE__*/React.createElement(Wrapper, props));
46
355
  return {
356
+ sendExternalEvents: function sendExternalEvents(eventOrEvents) {
357
+ var events = Array.isArray(eventOrEvents) ? eventOrEvents : [eventOrEvents];
358
+ var _iterator2 = _createForOfIteratorHelper(events),
359
+ _step2;
360
+ try {
361
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
362
+ var e = _step2.value;
363
+ queue.push(e);
364
+ }
365
+
366
+ // marker for this batch
367
+ } catch (err) {
368
+ _iterator2.e(err);
369
+ } finally {
370
+ _iterator2.f();
371
+ }
372
+ var token = Symbol('batch');
373
+ pendingMarkers.add(token);
374
+ queue.push({
375
+ __batchMarker: token
376
+ });
377
+ drain();
378
+ return new Promise(function (resolve) {
379
+ var check = /*#__PURE__*/function () {
380
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
381
+ return _regeneratorRuntime.wrap(function (_context4) {
382
+ while (1) switch (_context4.prev = _context4.next) {
383
+ case 0:
384
+ if (destroyed) {
385
+ _context4.next = 3;
386
+ break;
387
+ }
388
+ if (!pendingMarkers.has(token)) {
389
+ _context4.next = 2;
390
+ break;
391
+ }
392
+ _context4.next = 1;
393
+ return nextFrame();
394
+ case 1:
395
+ return _context4.abrupt("continue", 0);
396
+ case 2:
397
+ resolve(true);
398
+ return _context4.abrupt("return");
399
+ case 3:
400
+ resolve(false);
401
+ case 4:
402
+ case "end":
403
+ return _context4.stop();
404
+ }
405
+ }, _callee4);
406
+ }));
407
+ return function check() {
408
+ return _ref4.apply(this, arguments);
409
+ };
410
+ }();
411
+ check();
412
+ });
413
+ },
47
414
  updateExternalEvent: function updateExternalEvent(newExternalEvent) {
48
- var _setExternalEventFn;
49
- (_setExternalEventFn = setExternalEventFn) === null || _setExternalEventFn === void 0 || _setExternalEventFn(newExternalEvent);
415
+ return this.sendExternalEvents(newExternalEvent);
416
+ },
417
+ clearQueue: function clearQueue() {
418
+ queue.length = 0;
419
+ pendingMarkers.clear();
50
420
  },
51
421
  unmount: function unmount() {
52
- ReactDOM.unmountComponentAtNode(container);
422
+ var _this$clearQueue;
423
+ destroyed = true;
424
+ (_this$clearQueue = this.clearQueue) === null || _this$clearQueue === void 0 || _this$clearQueue.call(this);
425
+ gltfTracker.uninstall();
426
+ root.unmount();
53
427
  }
54
428
  };
55
429
  }
package/es/models.js CHANGED
@@ -341,7 +341,8 @@ export var CatalogElement = /*#__PURE__*/function (_Record1) {
341
341
  properties: new Map(),
342
342
  obj: new Map(),
343
343
  type: '',
344
- cds: new Map()
344
+ cds: new Map(),
345
+ structure_json: {}
345
346
  }, 'CatalogElement'));
346
347
  export var Catalog = /*#__PURE__*/function (_Record10) {
347
348
  function Catalog() {