kitchen-simulator 4.0.3-react-18 → 4.0.3

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 (190) hide show
  1. package/README.md +3 -0
  2. package/es/AppContext.js +1 -1
  3. package/es/LiteKitchenConfigurator.js +165 -107
  4. package/es/LiteRenderer.js +161 -129
  5. package/es/actions/export.js +25 -12
  6. package/es/assets/gltf/door_sliding.bin +0 -0
  7. package/es/assets/img/png/helper/video_preview_start.png +0 -0
  8. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  9. package/es/catalog/catalog.js +21 -5
  10. package/es/catalog/holes/window-clear/planner-element.js +2 -2
  11. package/es/catalog/properties/export.js +21 -0
  12. package/es/catalog/properties/property-checkbox.js +68 -0
  13. package/es/catalog/properties/property-color.js +39 -0
  14. package/es/catalog/properties/property-enum.js +50 -0
  15. package/es/catalog/properties/property-hidden.js +19 -0
  16. package/es/catalog/properties/property-lenght-measure.js +100 -0
  17. package/es/catalog/properties/property-length-measure.js +84 -0
  18. package/es/catalog/properties/property-length-measure_hole.js +100 -0
  19. package/es/catalog/properties/property-number.js +48 -0
  20. package/es/catalog/properties/property-read-only.js +26 -0
  21. package/es/catalog/properties/property-string.js +48 -0
  22. package/es/catalog/properties/property-toggle.js +39 -0
  23. package/es/catalog/properties/shared-property-style.js +14 -0
  24. package/es/catalog/utils/exporter.js +1 -0
  25. package/es/catalog/utils/item-loader.js +35 -26
  26. package/es/class/hole.js +0 -2
  27. package/es/class/item.js +95 -69
  28. package/es/class/line.js +4 -8
  29. package/es/class/project.js +93 -80
  30. package/es/components/content.js +5 -93
  31. package/es/components/export.js +4 -6
  32. package/es/components/style/button.js +106 -0
  33. package/es/components/style/cancel-button.js +21 -0
  34. package/es/components/style/content-container.js +30 -0
  35. package/es/components/style/content-title.js +25 -0
  36. package/es/components/style/delete-button.js +24 -0
  37. package/es/components/style/export.js +28 -2
  38. package/es/components/style/form-block.js +20 -0
  39. package/es/components/style/form-color-input.js +26 -0
  40. package/es/components/style/form-label.js +22 -0
  41. package/es/components/style/form-number-input.js +11 -22
  42. package/es/components/style/form-number-input_2.js +200 -0
  43. package/es/components/style/form-select.js +19 -0
  44. package/es/components/style/form-slider.js +60 -0
  45. package/es/components/style/form-submit-button.js +25 -0
  46. package/es/components/style/form-text-input.js +69 -0
  47. package/es/components/viewer2d/group.js +5 -4
  48. package/es/components/viewer2d/item.js +155 -359
  49. package/es/components/viewer2d/layer.js +1 -1
  50. package/es/components/viewer2d/line.js +17 -47
  51. package/es/components/viewer2d/ruler.js +5 -3
  52. package/es/components/viewer2d/rulerDist.js +8 -7
  53. package/es/components/viewer2d/rulerX.js +4 -2
  54. package/es/components/viewer2d/rulerY.js +3 -0
  55. package/es/components/viewer2d/scene.js +4 -1
  56. package/es/components/viewer2d/state.js +1 -1
  57. package/es/components/viewer2d/utils.js +2 -2
  58. package/es/components/viewer2d/vertex.js +3 -2
  59. package/es/components/viewer2d/viewer2d.js +51 -84
  60. package/es/components/viewer3d/ruler-utils/scene3D.js +1 -1
  61. package/es/components/viewer3d/scene-creator.js +59 -18
  62. package/es/components/viewer3d/viewer3d-first-person.js +8 -0
  63. package/es/components/viewer3d/viewer3d.js +80 -88
  64. package/es/constants.js +6 -2
  65. package/es/devLiteRenderer.js +491 -150
  66. package/es/index.js +566 -25
  67. package/es/models.js +2 -1
  68. package/es/plugins/SVGLoader.js +1414 -0
  69. package/es/plugins/console-debugger.js +34 -0
  70. package/es/plugins/export.js +7 -0
  71. package/es/plugins/keyboard.js +110 -0
  72. package/es/reducers/project-reducer.js +3 -0
  73. package/es/styles/export.js +5 -0
  74. package/es/styles/tabs.css +40 -0
  75. package/es/utils/geometry.js +72 -114
  76. package/es/utils/helper.js +38 -1
  77. package/es/utils/isolate-event-handler.js +826 -606
  78. package/es/utils/molding.js +457 -11
  79. package/lib/AppContext.js +1 -1
  80. package/lib/LiteKitchenConfigurator.js +164 -107
  81. package/lib/LiteRenderer.js +160 -129
  82. package/lib/actions/export.js +35 -39
  83. package/lib/assets/gltf/door_sliding.bin +0 -0
  84. package/lib/assets/img/png/helper/video_preview_start.png +0 -0
  85. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  86. package/lib/catalog/catalog.js +20 -4
  87. package/lib/catalog/holes/window-clear/planner-element.js +2 -2
  88. package/lib/catalog/properties/export.js +81 -0
  89. package/lib/catalog/properties/property-checkbox.js +76 -0
  90. package/lib/catalog/properties/property-color.js +47 -0
  91. package/lib/catalog/properties/property-enum.js +58 -0
  92. package/lib/catalog/properties/property-hidden.js +27 -0
  93. package/lib/catalog/properties/property-lenght-measure.js +108 -0
  94. package/lib/catalog/properties/property-length-measure.js +92 -0
  95. package/lib/catalog/properties/property-length-measure_hole.js +108 -0
  96. package/lib/catalog/properties/property-number.js +56 -0
  97. package/lib/catalog/properties/property-read-only.js +34 -0
  98. package/lib/catalog/properties/property-string.js +56 -0
  99. package/lib/catalog/properties/property-toggle.js +47 -0
  100. package/lib/catalog/properties/shared-property-style.js +21 -0
  101. package/lib/catalog/utils/exporter.js +1 -0
  102. package/lib/catalog/utils/item-loader.js +35 -26
  103. package/lib/class/hole.js +0 -2
  104. package/lib/class/item.js +93 -67
  105. package/lib/class/line.js +3 -7
  106. package/lib/class/project.js +93 -80
  107. package/lib/components/content.js +5 -93
  108. package/lib/components/export.js +6 -26
  109. package/lib/components/style/button.js +115 -0
  110. package/lib/components/style/cancel-button.js +29 -0
  111. package/lib/components/style/content-container.js +38 -0
  112. package/lib/components/style/content-title.js +35 -0
  113. package/lib/components/style/delete-button.js +34 -0
  114. package/lib/components/style/export.js +105 -1
  115. package/lib/components/style/form-block.js +28 -0
  116. package/lib/components/style/form-color-input.js +34 -0
  117. package/lib/components/style/form-label.js +30 -0
  118. package/lib/components/style/form-number-input.js +11 -22
  119. package/lib/components/style/form-number-input_2.js +209 -0
  120. package/lib/components/style/form-select.js +29 -0
  121. package/lib/components/style/form-slider.js +68 -0
  122. package/lib/components/style/form-submit-button.js +35 -0
  123. package/lib/components/style/form-text-input.js +78 -0
  124. package/lib/components/viewer2d/group.js +5 -4
  125. package/lib/components/viewer2d/item.js +152 -356
  126. package/lib/components/viewer2d/layer.js +1 -1
  127. package/lib/components/viewer2d/line.js +17 -47
  128. package/lib/components/viewer2d/ruler.js +4 -2
  129. package/lib/components/viewer2d/rulerDist.js +8 -7
  130. package/lib/components/viewer2d/rulerX.js +4 -2
  131. package/lib/components/viewer2d/rulerY.js +3 -0
  132. package/lib/components/viewer2d/scene.js +4 -1
  133. package/lib/components/viewer2d/state.js +1 -1
  134. package/lib/components/viewer2d/utils.js +2 -2
  135. package/lib/components/viewer2d/vertex.js +3 -2
  136. package/lib/components/viewer2d/viewer2d.js +49 -81
  137. package/lib/components/viewer3d/ruler-utils/scene3D.js +1 -1
  138. package/lib/components/viewer3d/scene-creator.js +57 -16
  139. package/lib/components/viewer3d/viewer3d-first-person.js +8 -0
  140. package/lib/components/viewer3d/viewer3d.js +77 -84
  141. package/lib/constants.js +11 -7
  142. package/lib/devLiteRenderer.js +489 -148
  143. package/lib/index.js +566 -25
  144. package/lib/models.js +2 -1
  145. package/lib/plugins/SVGLoader.js +1419 -0
  146. package/lib/plugins/console-debugger.js +42 -0
  147. package/lib/plugins/export.js +25 -0
  148. package/lib/plugins/keyboard.js +117 -0
  149. package/lib/reducers/project-reducer.js +3 -0
  150. package/lib/styles/export.js +13 -0
  151. package/lib/styles/tabs.css +40 -0
  152. package/lib/utils/geometry.js +72 -114
  153. package/lib/utils/helper.js +40 -1
  154. package/lib/utils/isolate-event-handler.js +826 -605
  155. package/lib/utils/molding.js +458 -9
  156. package/package.json +21 -16
  157. package/es/mocks/appliancePayload.json +0 -27
  158. package/es/mocks/cabinetPayload.json +0 -1914
  159. package/es/mocks/cabinetPayload2.json +0 -76
  160. package/es/mocks/dataBundle2.json +0 -4
  161. package/es/mocks/distancePayload.json +0 -6
  162. package/es/mocks/doorStylePayload2.json +0 -84
  163. package/es/mocks/furnishingPayload.json +0 -23
  164. package/es/mocks/itemCDSPayload.json +0 -27
  165. package/es/mocks/lightingPayload.json +0 -23
  166. package/es/mocks/mockProps.json +0 -43
  167. package/es/mocks/mockProps2.json +0 -9
  168. package/es/mocks/moldingPayload.json +0 -19
  169. package/es/mocks/projectItemsCatalog.json +0 -133
  170. package/es/mocks/rectangleShape.json +0 -238
  171. package/es/mocks/replaceCabinetPayload.json +0 -81
  172. package/es/mocks/roomShapePayload.json +0 -5
  173. package/es/useAppContext.js +0 -8
  174. package/lib/mocks/appliancePayload.json +0 -27
  175. package/lib/mocks/cabinetPayload.json +0 -1914
  176. package/lib/mocks/cabinetPayload2.json +0 -76
  177. package/lib/mocks/dataBundle2.json +0 -4
  178. package/lib/mocks/distancePayload.json +0 -6
  179. package/lib/mocks/doorStylePayload2.json +0 -84
  180. package/lib/mocks/furnishingPayload.json +0 -23
  181. package/lib/mocks/itemCDSPayload.json +0 -27
  182. package/lib/mocks/lightingPayload.json +0 -23
  183. package/lib/mocks/mockProps.json +0 -43
  184. package/lib/mocks/mockProps2.json +0 -9
  185. package/lib/mocks/moldingPayload.json +0 -19
  186. package/lib/mocks/projectItemsCatalog.json +0 -133
  187. package/lib/mocks/rectangleShape.json +0 -238
  188. package/lib/mocks/replaceCabinetPayload.json +0 -81
  189. package/lib/mocks/roomShapePayload.json +0 -5
  190. package/lib/useAppContext.js +0 -16
package/es/index.js CHANGED
@@ -4,40 +4,498 @@ 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 { createRoot } from 'react-dom/client';
11
15
  import LiteRenderer from "./LiteRenderer";
16
+ import { createRoot } from 'react-dom/client';
17
+ var ROOT_KEY = '__kitchenSimulatorRoot__';
18
+ var API_KEY = '__kitchenSimulatorApi__';
19
+ function nextFrame() {
20
+ return new Promise(function (resolve) {
21
+ return requestAnimationFrame(resolve);
22
+ });
23
+ }
24
+
25
+ /**
26
+ * Track 3D asset network activity (gltf/glb/bin/textures/hdr/etc)
27
+ * Ref-counted global install so multiple instances don't clobber each other.
28
+ */
29
+ function installGltfTracker() {
30
+ if (typeof window === 'undefined') {
31
+ var _subscribe = function _subscribe() {
32
+ return function () {};
33
+ };
34
+ return {
35
+ getInFlight: function getInFlight() {
36
+ return 0;
37
+ },
38
+ waitForIdle: function () {
39
+ var _waitForIdle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
40
+ return _regeneratorRuntime.wrap(function (_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ return _context.abrupt("return", true);
44
+ case 1:
45
+ case "end":
46
+ return _context.stop();
47
+ }
48
+ }, _callee);
49
+ }));
50
+ function waitForIdle() {
51
+ return _waitForIdle.apply(this, arguments);
52
+ }
53
+ return waitForIdle;
54
+ }(),
55
+ uninstall: function uninstall() {},
56
+ subscribe: _subscribe
57
+ };
58
+ }
59
+ var GLOBAL_KEY = '__kitchenSimulatorGltfTracker__';
60
+ if (!window[GLOBAL_KEY]) {
61
+ window[GLOBAL_KEY] = {
62
+ refCount: 0,
63
+ inFlight: 0,
64
+ listeners: new Set(),
65
+ installed: false,
66
+ originalFetch: null,
67
+ originalOpen: null,
68
+ originalSend: null
69
+ };
70
+ }
71
+ var g = window[GLOBAL_KEY];
72
+ var is3dAssetUrl = function is3dAssetUrl(url) {
73
+ try {
74
+ var _url$toString, _url$toString2;
75
+ 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 : '';
76
+ var u = s.toLowerCase().split('?')[0]; // ignore cache params
77
+ return u.endsWith('.gltf') || u.endsWith('.glb') || u.endsWith('.bin') || u.endsWith('.ktx2') || u.endsWith('.hdr') || u.endsWith('.exr') || u.endsWith('.png') || u.endsWith('.jpg') || u.endsWith('.jpeg') || u.endsWith('.webp');
78
+ } catch (_unused) {
79
+ return false;
80
+ }
81
+ };
82
+ var notify = function notify() {
83
+ var _iterator = _createForOfIteratorHelper(g.listeners),
84
+ _step;
85
+ try {
86
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
87
+ var fn = _step.value;
88
+ fn(g.inFlight);
89
+ }
90
+ } catch (err) {
91
+ _iterator.e(err);
92
+ } finally {
93
+ _iterator.f();
94
+ }
95
+ };
96
+ var subscribe = function subscribe(fn) {
97
+ g.listeners.add(fn);
98
+ fn(g.inFlight); // sync emit on subscribe
99
+ return function () {
100
+ return g.listeners["delete"](fn);
101
+ };
102
+ };
103
+ var installIfNeeded = function installIfNeeded() {
104
+ var _XHR$prototype, _XHR$prototype2;
105
+ if (g.installed) return;
106
+
107
+ // ---- XHR hook ----
108
+ var XHR = window.XMLHttpRequest;
109
+ 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) {
110
+ g.originalOpen = XHR.prototype.open;
111
+ g.originalSend = XHR.prototype.send;
112
+ XHR.prototype.open = function (method, url) {
113
+ var _g$originalOpen;
114
+ this.__is3dAssetRequest = is3dAssetUrl(url);
115
+ for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
116
+ rest[_key - 2] = arguments[_key];
117
+ }
118
+ return (_g$originalOpen = g.originalOpen).call.apply(_g$originalOpen, [this, method, url].concat(rest));
119
+ };
120
+ XHR.prototype.send = function () {
121
+ var _this = this;
122
+ if (this.__is3dAssetRequest) {
123
+ g.inFlight += 1;
124
+ notify();
125
+ var _done = function done() {
126
+ g.inFlight -= 1;
127
+ if (g.inFlight < 0) g.inFlight = 0;
128
+ notify();
129
+ _this.removeEventListener('loadend', _done);
130
+ };
131
+ this.addEventListener('loadend', _done);
132
+ }
133
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
134
+ args[_key2] = arguments[_key2];
135
+ }
136
+ return g.originalSend.apply(this, args);
137
+ };
138
+ }
139
+
140
+ // ---- fetch hook ----
141
+ g.originalFetch = window.fetch;
142
+ if (typeof g.originalFetch === 'function') {
143
+ window.fetch = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
144
+ var _len3,
145
+ args,
146
+ _key3,
147
+ url,
148
+ track,
149
+ _args2 = arguments;
150
+ return _regeneratorRuntime.wrap(function (_context2) {
151
+ while (1) switch (_context2.prev = _context2.next) {
152
+ case 0:
153
+ for (_len3 = _args2.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
154
+ args[_key3] = _args2[_key3];
155
+ }
156
+ url = args === null || args === void 0 ? void 0 : args[0];
157
+ track = is3dAssetUrl(url);
158
+ if (track) {
159
+ _context2.next = 1;
160
+ break;
161
+ }
162
+ return _context2.abrupt("return", g.originalFetch.apply(this, args));
163
+ case 1:
164
+ g.inFlight += 1;
165
+ notify();
166
+ _context2.prev = 2;
167
+ _context2.next = 3;
168
+ return g.originalFetch.apply(this, args);
169
+ case 3:
170
+ return _context2.abrupt("return", _context2.sent);
171
+ case 4:
172
+ _context2.prev = 4;
173
+ g.inFlight -= 1;
174
+ if (g.inFlight < 0) g.inFlight = 0;
175
+ notify();
176
+ return _context2.finish(4);
177
+ case 5:
178
+ case "end":
179
+ return _context2.stop();
180
+ }
181
+ }, _callee2, this, [[2,, 4, 5]]);
182
+ }));
183
+ }
184
+ g.installed = true;
185
+ };
186
+
187
+ // “No grace” but stable: idle must remain idle for 2 RAF frames
188
+ function waitStableIdle2Frames() {
189
+ return _waitStableIdle2Frames.apply(this, arguments);
190
+ }
191
+ function _waitStableIdle2Frames() {
192
+ _waitStableIdle2Frames = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
193
+ return _regeneratorRuntime.wrap(function (_context5) {
194
+ while (1) switch (_context5.prev = _context5.next) {
195
+ case 0:
196
+ _context5.next = 1;
197
+ return nextFrame();
198
+ case 1:
199
+ if (!(g.inFlight !== 0)) {
200
+ _context5.next = 2;
201
+ break;
202
+ }
203
+ return _context5.abrupt("return", false);
204
+ case 2:
205
+ _context5.next = 3;
206
+ return nextFrame();
207
+ case 3:
208
+ return _context5.abrupt("return", g.inFlight === 0);
209
+ case 4:
210
+ case "end":
211
+ return _context5.stop();
212
+ }
213
+ }, _callee5);
214
+ }));
215
+ return _waitStableIdle2Frames.apply(this, arguments);
216
+ }
217
+ var waitForIdle = /*#__PURE__*/function () {
218
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
219
+ var _ref3,
220
+ _ref3$timeoutMs,
221
+ timeoutMs,
222
+ start,
223
+ _args4 = arguments;
224
+ return _regeneratorRuntime.wrap(function (_context4) {
225
+ while (1) switch (_context4.prev = _context4.next) {
226
+ case 0:
227
+ _ref3 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref3$timeoutMs = _ref3.timeoutMs, timeoutMs = _ref3$timeoutMs === void 0 ? 30000 : _ref3$timeoutMs;
228
+ start = Date.now();
229
+ _context4.next = 1;
230
+ return waitStableIdle2Frames();
231
+ case 1:
232
+ if (!_context4.sent) {
233
+ _context4.next = 2;
234
+ break;
235
+ }
236
+ return _context4.abrupt("return", true);
237
+ case 2:
238
+ return _context4.abrupt("return", new Promise(function (resolve, reject) {
239
+ var unsub = null;
240
+ var onChange = /*#__PURE__*/function () {
241
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(count) {
242
+ var stable;
243
+ return _regeneratorRuntime.wrap(function (_context3) {
244
+ while (1) switch (_context3.prev = _context3.next) {
245
+ case 0:
246
+ if (!(count !== 0)) {
247
+ _context3.next = 1;
248
+ break;
249
+ }
250
+ if (Date.now() - start > timeoutMs) {
251
+ if (unsub) unsub();
252
+ reject(new Error('3D assets did not become idle within timeout'));
253
+ }
254
+ return _context3.abrupt("return");
255
+ case 1:
256
+ _context3.next = 2;
257
+ return waitStableIdle2Frames();
258
+ case 2:
259
+ stable = _context3.sent;
260
+ if (!stable) {
261
+ _context3.next = 3;
262
+ break;
263
+ }
264
+ if (unsub) unsub();
265
+ resolve(true);
266
+ return _context3.abrupt("return");
267
+ case 3:
268
+ if (Date.now() - start > timeoutMs) {
269
+ if (unsub) unsub();
270
+ reject(new Error('3D assets did not become idle within timeout'));
271
+ }
272
+ case 4:
273
+ case "end":
274
+ return _context3.stop();
275
+ }
276
+ }, _callee3);
277
+ }));
278
+ return function onChange(_x) {
279
+ return _ref4.apply(this, arguments);
280
+ };
281
+ }();
282
+ unsub = subscribe(onChange);
283
+ }));
284
+ case 3:
285
+ case "end":
286
+ return _context4.stop();
287
+ }
288
+ }, _callee4);
289
+ }));
290
+ return function waitForIdle() {
291
+ return _ref2.apply(this, arguments);
292
+ };
293
+ }();
294
+ var uninstall = function uninstall() {
295
+ var _XHR$prototype3, _XHR$prototype4;
296
+ g.refCount -= 1;
297
+ if (g.refCount > 0) return;
298
+ var XHR = window.XMLHttpRequest;
299
+ if (XHR !== null && XHR !== void 0 && (_XHR$prototype3 = XHR.prototype) !== null && _XHR$prototype3 !== void 0 && _XHR$prototype3.open && g.originalOpen) XHR.prototype.open = g.originalOpen;
300
+ if (XHR !== null && XHR !== void 0 && (_XHR$prototype4 = XHR.prototype) !== null && _XHR$prototype4 !== void 0 && _XHR$prototype4.send && g.originalSend) XHR.prototype.send = g.originalSend;
301
+ if (typeof g.originalFetch === 'function') window.fetch = g.originalFetch;
302
+ g.listeners.clear();
303
+ g.inFlight = 0;
304
+ g.installed = false;
305
+ g.originalFetch = null;
306
+ g.originalOpen = null;
307
+ g.originalSend = null;
308
+ };
309
+ g.refCount += 1;
310
+ installIfNeeded();
311
+ return {
312
+ getInFlight: function getInFlight() {
313
+ return g.inFlight;
314
+ },
315
+ waitForIdle: waitForIdle,
316
+ uninstall: uninstall,
317
+ subscribe: subscribe
318
+ };
319
+ }
12
320
  export function renderKitchenSimulator(container) {
321
+ var _props$framesPerEvent, _props$waitForGltfIdl, _props$gltfTimeoutMs;
13
322
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
- if (!container) {
15
- throw new Error('renderKitchenSimulator: container is required');
323
+ if (!container) throw new Error('renderKitchenSimulator: container is required');
324
+
325
+ // ✅ Reuse existing API
326
+ if (container[API_KEY]) {
327
+ var _container$API_KEY$__, _container$API_KEY;
328
+ (_container$API_KEY$__ = (_container$API_KEY = container[API_KEY]).__render) === null || _container$API_KEY$__ === void 0 || _container$API_KEY$__.call(_container$API_KEY, props);
329
+ return container[API_KEY];
16
330
  }
17
331
 
18
- // cache the root on the container so we never call createRoot twice
19
- if (!container.__kitchenRoot) {
20
- container.__kitchenRoot = createRoot(container);
332
+ // Reuse root
333
+ var root = container[ROOT_KEY];
334
+ if (!root) {
335
+ root = createRoot(container);
336
+ container[ROOT_KEY] = root;
21
337
  }
22
338
  var setExternalEventFn = null;
339
+ var destroyed = false;
340
+ var queue = [];
341
+ var pendingMarkers = new Set();
342
+ var MARKER = Symbol('marker');
343
+ var gltfTracker = installGltfTracker();
344
+
345
+ // FAST defaults (safe)
346
+ var defaultFramesPerEvent = (_props$framesPerEvent = props.framesPerEvent) !== null && _props$framesPerEvent !== void 0 ? _props$framesPerEvent : 1;
347
+ var waitForAssets = (_props$waitForGltfIdl = props.waitForGltfIdleAfterEachEvent) !== null && _props$waitForGltfIdl !== void 0 ? _props$waitForGltfIdl : true;
348
+ var defaultTimeout = (_props$gltfTimeoutMs = props.gltfTimeoutMs) !== null && _props$gltfTimeoutMs !== void 0 ? _props$gltfTimeoutMs : 30000;
349
+
350
+ // If you want ultra-fast UI responsiveness, you can disable waiting per-event
351
+ // and only wait on “important” events, see comment in settle() below.
352
+
353
+ var draining = false;
354
+ function isSyncScene(ev) {
355
+ var _ev$payload;
356
+ return (ev === null || ev === void 0 ? void 0 : ev.type) === 'EXTERNAL_EVENT_SYNC_SCENE' || (ev === null || ev === void 0 || (_ev$payload = ev.payload) === null || _ev$payload === void 0 ? void 0 : _ev$payload.mode) === 'sync-scene' || (ev === null || ev === void 0 ? void 0 : ev.__sync) === true;
357
+ }
358
+ function settle(_x2) {
359
+ return _settle.apply(this, arguments);
360
+ }
361
+ function _settle() {
362
+ _settle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(ev) {
363
+ var _ev$framesPerEvent, _ev$waitForGltfIdleAf;
364
+ var frames, i, shouldWait, _ev$gltfTimeoutMs, timeoutMs;
365
+ return _regeneratorRuntime.wrap(function (_context7) {
366
+ while (1) switch (_context7.prev = _context7.next) {
367
+ case 0:
368
+ frames = (_ev$framesPerEvent = ev === null || ev === void 0 ? void 0 : ev.framesPerEvent) !== null && _ev$framesPerEvent !== void 0 ? _ev$framesPerEvent : defaultFramesPerEvent; // (1) allow react/reducers to run (fixes “must zoom to see updates”)
369
+ i = 0;
370
+ case 1:
371
+ if (!(i < frames)) {
372
+ _context7.next = 3;
373
+ break;
374
+ }
375
+ _context7.next = 2;
376
+ return nextFrame();
377
+ case 2:
378
+ i += 1;
379
+ _context7.next = 1;
380
+ break;
381
+ case 3:
382
+ // (2) optionally wait for assets
383
+ // fastest safe approach: keep ON for events that add/replace/load models
384
+ // You can override per-event via ev.waitForGltfIdleAfterEachEvent = false
385
+ shouldWait = (_ev$waitForGltfIdleAf = ev === null || ev === void 0 ? void 0 : ev.waitForGltfIdleAfterEachEvent) !== null && _ev$waitForGltfIdleAf !== void 0 ? _ev$waitForGltfIdleAf : waitForAssets;
386
+ if (!shouldWait) {
387
+ _context7.next = 4;
388
+ break;
389
+ }
390
+ timeoutMs = (_ev$gltfTimeoutMs = ev === null || ev === void 0 ? void 0 : ev.gltfTimeoutMs) !== null && _ev$gltfTimeoutMs !== void 0 ? _ev$gltfTimeoutMs : defaultTimeout;
391
+ _context7.next = 4;
392
+ return gltfTracker.waitForIdle({
393
+ timeoutMs: timeoutMs
394
+ });
395
+ case 4:
396
+ _context7.next = 5;
397
+ return nextFrame();
398
+ case 5:
399
+ if (!isSyncScene(ev)) {
400
+ _context7.next = 6;
401
+ break;
402
+ }
403
+ _context7.next = 6;
404
+ return nextFrame();
405
+ case 6:
406
+ case "end":
407
+ return _context7.stop();
408
+ }
409
+ }, _callee7);
410
+ }));
411
+ return _settle.apply(this, arguments);
412
+ }
413
+ function drain() {
414
+ return _drain.apply(this, arguments);
415
+ }
416
+ function _drain() {
417
+ _drain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
418
+ var item;
419
+ return _regeneratorRuntime.wrap(function (_context8) {
420
+ while (1) switch (_context8.prev = _context8.next) {
421
+ case 0:
422
+ if (!(draining || destroyed)) {
423
+ _context8.next = 1;
424
+ break;
425
+ }
426
+ return _context8.abrupt("return");
427
+ case 1:
428
+ draining = true;
429
+ _context8.prev = 2;
430
+ case 3:
431
+ if (!(!destroyed && queue.length)) {
432
+ _context8.next = 8;
433
+ break;
434
+ }
435
+ if (setExternalEventFn) {
436
+ _context8.next = 5;
437
+ break;
438
+ }
439
+ _context8.next = 4;
440
+ return nextFrame();
441
+ case 4:
442
+ return _context8.abrupt("continue", 3);
443
+ case 5:
444
+ item = queue.shift();
445
+ if (!(item && item.__marker === MARKER)) {
446
+ _context8.next = 6;
447
+ break;
448
+ }
449
+ pendingMarkers["delete"](item.token);
450
+ return _context8.abrupt("continue", 3);
451
+ case 6:
452
+ setExternalEventFn(item);
453
+ _context8.next = 7;
454
+ return settle(item);
455
+ case 7:
456
+ _context8.next = 3;
457
+ break;
458
+ case 8:
459
+ _context8.prev = 8;
460
+ draining = false;
461
+ return _context8.finish(8);
462
+ case 9:
463
+ case "end":
464
+ return _context8.stop();
465
+ }
466
+ }, _callee8, null, [[2,, 8, 9]]);
467
+ }));
468
+ return _drain.apply(this, arguments);
469
+ }
23
470
  var Wrapper = /*#__PURE__*/function (_React$Component) {
24
471
  function Wrapper(p) {
25
- var _this;
472
+ var _this2;
26
473
  _classCallCheck(this, Wrapper);
27
- _this = _callSuper(this, Wrapper, [p]);
28
- _this.state = {
474
+ _this2 = _callSuper(this, Wrapper, [p]);
475
+ _this2.state = {
29
476
  externalEvent: p.externalEvent || null
30
477
  };
31
- setExternalEventFn = _this.setExternalEvent.bind(_this);
32
- return _this;
478
+ _this2._mounted = false;
479
+ return _this2;
33
480
  }
34
481
  _inherits(Wrapper, _React$Component);
35
482
  return _createClass(Wrapper, [{
36
- key: "setExternalEvent",
37
- value: function setExternalEvent(newEvent) {
38
- this.setState({
39
- externalEvent: newEvent
40
- });
483
+ key: "componentDidMount",
484
+ value: function componentDidMount() {
485
+ var _this3 = this;
486
+ this._mounted = true;
487
+ setExternalEventFn = function setExternalEventFn(newEvent) {
488
+ if (!_this3._mounted) return;
489
+ _this3.setState({
490
+ externalEvent: newEvent
491
+ });
492
+ };
493
+ }
494
+ }, {
495
+ key: "componentWillUnmount",
496
+ value: function componentWillUnmount() {
497
+ this._mounted = false;
498
+ setExternalEventFn = null;
41
499
  }
42
500
  }, {
43
501
  key: "render",
@@ -48,18 +506,101 @@ export function renderKitchenSimulator(container) {
48
506
  }
49
507
  }]);
50
508
  }(React.Component);
51
- container.__kitchenRoot.render(/*#__PURE__*/React.createElement(Wrapper, props));
52
- return {
53
- updateExternalEvent: function updateExternalEvent(newExternalEvent) {
54
- setExternalEventFn && setExternalEventFn(newExternalEvent);
509
+ var api = {
510
+ __render: function __render(nextProps) {
511
+ root.render(/*#__PURE__*/React.createElement(Wrapper, nextProps));
55
512
  },
56
- unmount: function unmount() {
57
- if (container.__kitchenRoot) {
58
- container.__kitchenRoot.unmount();
59
- container.__kitchenRoot = null;
513
+ // host can query current inFlight
514
+ getGltfInFlight: function getGltfInFlight() {
515
+ return gltfTracker.getInFlight();
516
+ },
517
+ // ✅ host can subscribe to inFlight changes (loader)
518
+ subscribeGltfInFlight: function subscribeGltfInFlight(cb) {
519
+ return gltfTracker.subscribe(cb);
520
+ },
521
+ sendExternalEvents: function sendExternalEvents(eventOrEvents) {
522
+ var events = Array.isArray(eventOrEvents) ? eventOrEvents : [eventOrEvents];
523
+ var _iterator2 = _createForOfIteratorHelper(events),
524
+ _step2;
525
+ try {
526
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
527
+ var e = _step2.value;
528
+ queue.push(e);
529
+ }
530
+ } catch (err) {
531
+ _iterator2.e(err);
532
+ } finally {
533
+ _iterator2.f();
60
534
  }
61
- setExternalEventFn = null;
535
+ var token = Symbol('batch');
536
+ pendingMarkers.add(token);
537
+ queue.push({
538
+ __marker: MARKER,
539
+ token: token
540
+ });
541
+ drain();
542
+
543
+ // resolve when marker cleared
544
+ return new Promise(function (resolve) {
545
+ var check = /*#__PURE__*/function () {
546
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
547
+ return _regeneratorRuntime.wrap(function (_context6) {
548
+ while (1) switch (_context6.prev = _context6.next) {
549
+ case 0:
550
+ if (destroyed) {
551
+ _context6.next = 3;
552
+ break;
553
+ }
554
+ if (!pendingMarkers.has(token)) {
555
+ _context6.next = 2;
556
+ break;
557
+ }
558
+ _context6.next = 1;
559
+ return nextFrame();
560
+ case 1:
561
+ return _context6.abrupt("continue", 0);
562
+ case 2:
563
+ resolve(true);
564
+ return _context6.abrupt("return");
565
+ case 3:
566
+ resolve(false);
567
+ case 4:
568
+ case "end":
569
+ return _context6.stop();
570
+ }
571
+ }, _callee6);
572
+ }));
573
+ return function check() {
574
+ return _ref5.apply(this, arguments);
575
+ };
576
+ }();
577
+ check();
578
+ });
579
+ },
580
+ updateExternalEvent: function updateExternalEvent(e) {
581
+ return api.sendExternalEvents(e);
582
+ },
583
+ clearQueue: function clearQueue() {
584
+ queue.length = 0;
585
+ pendingMarkers.clear();
586
+ },
587
+ unmount: function unmount() {
588
+ destroyed = true;
589
+ api.clearQueue();
590
+ gltfTracker.uninstall();
591
+ var doUnmount = function doUnmount() {
592
+ try {
593
+ root.unmount();
594
+ } finally {
595
+ container[ROOT_KEY] = null;
596
+ container[API_KEY] = null;
597
+ }
598
+ };
599
+ if (typeof queueMicrotask === 'function') queueMicrotask(doUnmount);else setTimeout(doUnmount, 0);
62
600
  }
63
601
  };
602
+ api.__render(props);
603
+ container[API_KEY] = api;
604
+ return api;
64
605
  }
65
606
  export default renderKitchenSimulator;
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() {