kitchen-simulator 4.0.6-react-18 → 4.0.7-measurement-unit-payload

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