kitchen-simulator 4.0.0-queuedEvents → 4.0.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.
Files changed (111) hide show
  1. package/es/LiteKitchenConfigurator.js +141 -288
  2. package/es/LiteRenderer.js +159 -398
  3. package/es/actions/items-actions.js +10 -6
  4. package/es/actions/lines-actions.js +3 -1
  5. package/es/actions/project-actions.js +15 -5
  6. package/es/assets/img/svg/bottombar/elevation.svg +12 -5
  7. package/es/catalog/areas/area/planner-element.js +10 -5
  8. package/es/catalog/catalog.js +1 -4
  9. package/es/catalog/factories/area-factory-3d.js +2 -1
  10. package/es/catalog/factories/wall-factory-3d.js +2 -2
  11. package/es/catalog/factories/wall-factory.js +8 -8
  12. package/es/catalog/lines/wall/planner-element.js +18 -9
  13. package/es/catalog/utils/exporter.js +7 -3
  14. package/es/catalog/utils/item-loader.js +24 -14
  15. package/es/catalog/utils/mtl-loader.js +2 -2
  16. package/es/catalog/utils/obj-loader.js +2 -2
  17. package/es/class/hole.js +0 -2
  18. package/es/class/item.js +183 -184
  19. package/es/class/line.js +11 -3
  20. package/es/class/project.js +165 -48
  21. package/es/components/content.js +19 -6
  22. package/es/components/viewer2d/grids/grid-streak.js +1 -1
  23. package/es/components/viewer2d/item.js +84 -51
  24. package/es/components/viewer2d/line.js +315 -243
  25. package/es/components/viewer2d/ruler.js +20 -38
  26. package/es/components/viewer2d/rulerDist.js +48 -78
  27. package/es/components/viewer2d/utils.js +6 -0
  28. package/es/components/viewer2d/viewer2d.js +298 -220
  29. package/es/components/viewer3d/front3D.js +3 -2
  30. package/es/components/viewer3d/libs/mtl-loader.js +2 -2
  31. package/es/components/viewer3d/libs/obj-loader.js +2 -2
  32. package/es/components/viewer3d/libs/orbit-controls.js +3 -4
  33. package/es/components/viewer3d/libs/pointer-lock-controls.js +6 -7
  34. package/es/components/viewer3d/scene-creator.js +51 -15
  35. package/es/components/viewer3d/viewer3d.js +121 -82
  36. package/es/constants.js +111 -3
  37. package/es/devLiteRenderer.js +688 -31
  38. package/es/index.js +567 -87
  39. package/es/models.js +9 -5
  40. package/es/plugins/SVGLoader.js +7 -5
  41. package/es/plugins/console-debugger.js +0 -2
  42. package/es/plugins/keyboard.js +15 -6
  43. package/es/reducers/items-reducer.js +5 -5
  44. package/es/reducers/lines-reducer.js +1 -1
  45. package/es/reducers/project-reducer.js +5 -3
  46. package/es/shared-style.js +4 -4
  47. package/es/utils/geometry.js +163 -2
  48. package/es/utils/get-edges-of-subgraphs.js +1 -1
  49. package/es/utils/graph-cycles.js +1 -1
  50. package/es/utils/graph.js +1 -1
  51. package/es/utils/helper.js +105 -3
  52. package/es/utils/isolate-event-handler.js +1542 -164
  53. package/es/utils/molding.js +461 -11
  54. package/lib/LiteKitchenConfigurator.js +141 -289
  55. package/lib/LiteRenderer.js +159 -399
  56. package/lib/actions/items-actions.js +10 -6
  57. package/lib/actions/lines-actions.js +3 -1
  58. package/lib/actions/project-actions.js +15 -4
  59. package/lib/assets/img/svg/bottombar/elevation.svg +12 -5
  60. package/lib/catalog/areas/area/planner-element.js +11 -5
  61. package/lib/catalog/catalog.js +1 -4
  62. package/lib/catalog/factories/area-factory-3d.js +2 -1
  63. package/lib/catalog/factories/wall-factory-3d.js +2 -2
  64. package/lib/catalog/factories/wall-factory.js +8 -8
  65. package/lib/catalog/lines/wall/planner-element.js +19 -9
  66. package/lib/catalog/utils/exporter.js +7 -3
  67. package/lib/catalog/utils/item-loader.js +24 -14
  68. package/lib/catalog/utils/mtl-loader.js +9 -2
  69. package/lib/catalog/utils/obj-loader.js +10 -2
  70. package/lib/class/hole.js +0 -2
  71. package/lib/class/item.js +180 -181
  72. package/lib/class/line.js +9 -1
  73. package/lib/class/project.js +164 -47
  74. package/lib/components/content.js +19 -6
  75. package/lib/components/viewer2d/grids/grid-streak.js +1 -1
  76. package/lib/components/viewer2d/item.js +83 -50
  77. package/lib/components/viewer2d/line.js +315 -242
  78. package/lib/components/viewer2d/ruler.js +19 -37
  79. package/lib/components/viewer2d/rulerDist.js +48 -78
  80. package/lib/components/viewer2d/utils.js +7 -0
  81. package/lib/components/viewer2d/viewer2d.js +296 -219
  82. package/lib/components/viewer3d/front3D.js +3 -2
  83. package/lib/components/viewer3d/libs/mtl-loader.js +9 -2
  84. package/lib/components/viewer3d/libs/obj-loader.js +9 -2
  85. package/lib/components/viewer3d/libs/orbit-controls.js +11 -5
  86. package/lib/components/viewer3d/libs/pointer-lock-controls.js +13 -7
  87. package/lib/components/viewer3d/scene-creator.js +49 -13
  88. package/lib/components/viewer3d/viewer3d.js +119 -80
  89. package/lib/constants.js +116 -7
  90. package/lib/devLiteRenderer.js +687 -30
  91. package/lib/index.js +567 -87
  92. package/lib/models.js +9 -5
  93. package/lib/plugins/SVGLoader.js +7 -5
  94. package/lib/plugins/console-debugger.js +0 -2
  95. package/lib/plugins/keyboard.js +15 -6
  96. package/lib/reducers/items-reducer.js +5 -5
  97. package/lib/reducers/lines-reducer.js +1 -1
  98. package/lib/reducers/project-reducer.js +4 -2
  99. package/lib/shared-style.js +4 -4
  100. package/lib/utils/geometry.js +164 -2
  101. package/lib/utils/get-edges-of-subgraphs.js +6 -1
  102. package/lib/utils/graph-cycles.js +7 -8
  103. package/lib/utils/graph.js +6 -1
  104. package/lib/utils/helper.js +108 -2
  105. package/lib/utils/isolate-event-handler.js +1538 -159
  106. package/lib/utils/molding.js +463 -9
  107. package/package.json +1 -1
  108. package/es/assets/Window.hdr +0 -2100
  109. package/es/assets/img/1.jpg +0 -0
  110. package/lib/assets/Window.hdr +0 -2100
  111. package/lib/assets/img/1.jpg +0 -0
@@ -1,6 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
4
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
@@ -8,83 +6,57 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
8
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
9
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
8
  import _inherits from "@babel/runtime/helpers/esm/inherits";
11
- var _excluded = ["width", "height", "projectElement", "categoryData", "dataBundle", "configData", "options", "user", "auth", "featureFlags", "sentry", "analytics", "externalEvent", "onExternalEventProcessed", "onError"];
12
- import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+ var _excluded = ["width", "height", "configData", "externalEvent", "onInternalEvent", "onError"];
13
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ 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; } } }; }
13
+ 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; } }
14
+ 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; }
15
15
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
16
16
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
17
- import React, { useCallback, useEffect, useRef } from 'react';
17
+ // LiteRenderer.jsx
18
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
18
19
  import PropTypes from 'prop-types';
19
20
  import { Provider } from 'react-redux';
20
21
  import { createStore } from 'redux';
22
+ import { Map } from 'immutable';
23
+ import * as Sentry from '@sentry/react';
24
+ import * as THREE from 'three';
21
25
  import * as Models from "./models";
22
26
  import { State } from "./models";
23
27
  import PlannerReducer from "./reducers/reducer";
24
28
  import AppContext from "./AppContext";
25
29
  import Catalog from "./catalog/catalog";
26
- import { SVGLoader } from 'three/addons/loaders/SVGLoader';
27
- import { isEmpty } from "./utils/helper";
28
- import { TOE_KICK_MOLDING } from "./constants";
29
30
  import * as Areas from "./catalog/areas/area/planner-element";
30
31
  import * as Lines from "./catalog/lines/wall/planner-element";
31
32
  import * as Holes from "./catalog/holes/export";
32
- import { render2DItem, render3DApplianceItem, render3DItem, render3DLightingItem } from "./catalog/utils/item-loader";
33
33
  import { ConsoleDebugger, Keyboard } from "./plugins/export";
34
- import { Map } from 'immutable';
35
- import * as Sentry from '@sentry/react';
36
- import { loadProject, rename } from "./actions/project-actions";
37
- import exporter from "./catalog/utils/exporter";
38
- import * as THREE from 'three';
39
34
  import LiteKitchenConfigurator from "./LiteKitchenConfigurator";
40
- if (typeof window !== 'undefined') window.THREE = THREE;
41
-
42
- /* ============================== component ============================= */
43
- var MyCatalog = new Catalog();
44
- var AppState = Map({
45
- KitchenConfigurator: new State()
46
- });
47
- console.log('Version: 378.45-202509_DIY-364-mbox-crash');
48
- isProduction && Sentry.init({
49
- dsn: process.env.SENTRY_DSN,
50
- environment: process.env.SENTRY_ENVIRONMENT
51
- });
35
+ var isBrowser = typeof window !== 'undefined';
36
+ if (isBrowser) window.THREE = THREE;
52
37
 
53
- //define reducer
54
- var reducer = function reducer(state, action) {
55
- state = state || AppState;
56
- state = state.update('KitchenConfigurator', function (plannerState) {
57
- return PlannerReducer(plannerState, action);
38
+ // ---- Keep prior Sentry behavior but ensure it only initializes once ----
39
+ var __sentryInited = false;
40
+ function ensureSentryInit() {
41
+ if (!isBrowser) return;
42
+ // assumes isProduction exists in your build just like today
43
+ if (!isProduction) return;
44
+ if (__sentryInited) return;
45
+ __sentryInited = true;
46
+ Sentry.init({
47
+ dsn: process.env.SENTRY_DSN,
48
+ environment: process.env.SENTRY_ENVIRONMENT
58
49
  });
59
- return state;
60
- };
61
- var store = createStore(reducer, null, !isProduction && window.devToolsExtension ? window.devToolsExtension({
62
- features: {
63
- pause: true,
64
- // start/pause recording of dispatched actions
65
- lock: true,
66
- // lock/unlock dispatching actions and side effects
67
- persist: true,
68
- // persist states on page reloading
69
- "export": true,
70
- // export history of actions in a file
71
- "import": 'custom',
72
- // import history of actions from a file
73
- jump: true,
74
- // jump back and forth (time travelling)
75
- skip: true,
76
- // skip (cancel) actions
77
- reorder: true,
78
- // drag and drop actions in the history list
79
- dispatch: true,
80
- // dispatch custom actions or action creators
81
- test: true // generate tests for the selected actions
82
- },
83
- maxAge: 999999
84
- }) : function (f) {
85
- return f;
86
- });
87
- var plugins = [Keyboard(), ConsoleDebugger()];
50
+ }
51
+
52
+ // ---------------- error helpers ----------------
53
+ function safeJson(v) {
54
+ try {
55
+ return JSON.parse(JSON.stringify(v));
56
+ } catch (_unused) {
57
+ return undefined;
58
+ }
59
+ }
88
60
  function serializeError(err) {
89
61
  try {
90
62
  if (!err) return {
@@ -101,19 +73,12 @@ function serializeError(err) {
101
73
  message: String(err),
102
74
  raw: safeJson(err)
103
75
  };
104
- } catch (_unused) {
76
+ } catch (_unused2) {
105
77
  return {
106
78
  message: 'Error serializing error'
107
79
  };
108
80
  }
109
81
  }
110
- function safeJson(v) {
111
- try {
112
- return JSON.parse(JSON.stringify(v));
113
- } catch (_unused2) {
114
- return undefined;
115
- }
116
- }
117
82
 
118
83
  /* ---------- Error Boundary that pushes into buffer ---------- */
119
84
  var ToolErrorBoundary = /*#__PURE__*/function (_React$Component) {
@@ -141,38 +106,139 @@ var ToolErrorBoundary = /*#__PURE__*/function (_React$Component) {
141
106
  }
142
107
  }]);
143
108
  }(React.Component);
109
+ ToolErrorBoundary.propTypes = {
110
+ pushError: PropTypes.func.isRequired,
111
+ children: PropTypes.any
112
+ };
113
+
114
+ // ----------------- catalog init -----------------
115
+ function initCatalogOnce(catalog) {
116
+ if (!catalog) return;
117
+ if (catalog.__ksInitialized) return;
118
+ for (var x in Areas) catalog.registerElement(Areas[x]);
119
+ for (var _x in Lines) catalog.registerElement(Lines[_x]);
120
+ for (var _x2 in Holes) catalog.registerElement(Holes[_x2]);
121
+ catalog.registerCategory('Windows', 'Windows', [Holes.windowClear, Holes.windowCross, Holes.windowDoubleHung, Holes.windowVertical]);
122
+ catalog.registerCategory('Doors', 'Doors', [Holes.doorInterior, Holes.doorExterior, Holes.doorCloset, Holes.doorSliding, Holes.doorwayFramed, Holes.doorwayFrameless]);
123
+ catalog.__ksInitialized = true;
124
+ }
125
+
126
+ // ----------------- store factory -----------------
127
+ function createInstanceStore() {
128
+ var AppState = Map({
129
+ KitchenConfigurator: new State()
130
+ });
131
+ var reducer = function reducer(state, action) {
132
+ state = state || AppState;
133
+ return state.update('KitchenConfigurator', function (plannerState) {
134
+ return PlannerReducer(plannerState, action);
135
+ });
136
+ };
137
+ var enhancer = !isProduction && isBrowser && window.devToolsExtension ? window.devToolsExtension({
138
+ features: {
139
+ pause: true,
140
+ lock: true,
141
+ persist: true,
142
+ "export": true,
143
+ "import": 'custom',
144
+ jump: true,
145
+ skip: true,
146
+ reorder: true,
147
+ dispatch: true,
148
+ test: true
149
+ },
150
+ maxAge: 999999
151
+ }) : function (f) {
152
+ return f;
153
+ };
154
+ return createStore(reducer, null, enhancer);
155
+ }
156
+ function createPlugins() {
157
+ return [Keyboard(), ConsoleDebugger()];
158
+ }
144
159
  export default function LiteRenderer(props) {
160
+ ensureSentryInit();
145
161
  var width = props.width,
146
162
  height = props.height,
147
- projectElement = props.projectElement,
148
- categoryData = props.categoryData,
149
- dataBundle = props.dataBundle,
150
163
  configData = props.configData,
151
- options = props.options,
152
- user = props.user,
153
- auth = props.auth,
154
- featureFlags = props.featureFlags,
155
- sentry = props.sentry,
156
- analytics = props.analytics,
157
164
  externalEvent = props.externalEvent,
158
- onExternalEventProcessed = props.onExternalEventProcessed,
165
+ onInternalEvent = props.onInternalEvent,
159
166
  onError = props.onError,
160
167
  passThrough = _objectWithoutProperties(props, _excluded);
161
168
 
169
+ // ✅ instance-scoped store (no module singleton)
170
+ var storeRef = useRef(null);
171
+ if (!storeRef.current) storeRef.current = createInstanceStore();
172
+
173
+ // ✅ instance-scoped catalog (no module singleton)
174
+ var catalogRef = useRef(null);
175
+ if (!catalogRef.current) {
176
+ catalogRef.current = new Catalog();
177
+ initCatalogOnce(catalogRef.current);
178
+ }
179
+
180
+ // ✅ stable plugins array
181
+ var plugins = useMemo(function () {
182
+ return createPlugins();
183
+ }, []);
184
+
185
+ // ✅ plugin lifecycle: supports cleanup if plugin returns function
186
+ var pluginCleanupsRef = useRef([]);
187
+ useEffect(function () {
188
+ var store = storeRef.current;
189
+ var stateExtractor = function stateExtractor(state) {
190
+ return state.get('KitchenConfigurator');
191
+ };
192
+ var cleanups = [];
193
+ var _iterator = _createForOfIteratorHelper(plugins),
194
+ _step;
195
+ try {
196
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
197
+ var p = _step.value;
198
+ try {
199
+ var maybeCleanup = p === null || p === void 0 ? void 0 : p(store, stateExtractor);
200
+ if (typeof maybeCleanup === 'function') cleanups.push(maybeCleanup);
201
+ } catch (_unused4) {
202
+ // keep prior behavior: do not crash
203
+ }
204
+ }
205
+ } catch (err) {
206
+ _iterator.e(err);
207
+ } finally {
208
+ _iterator.f();
209
+ }
210
+ pluginCleanupsRef.current = cleanups;
211
+ return function () {
212
+ var _iterator2 = _createForOfIteratorHelper(pluginCleanupsRef.current),
213
+ _step2;
214
+ try {
215
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
216
+ var fn = _step2.value;
217
+ try {
218
+ fn();
219
+ } catch (_unused3) {}
220
+ }
221
+ } catch (err) {
222
+ _iterator2.e(err);
223
+ } finally {
224
+ _iterator2.f();
225
+ }
226
+ pluginCleanupsRef.current = [];
227
+ };
228
+ }, [plugins]);
229
+
162
230
  /* ---------- track last external event ---------- */
163
231
  var lastExternalEventRef = useRef(null);
164
232
  useEffect(function () {
165
- if (externalEvent) {
166
- lastExternalEventRef.current = externalEvent;
167
- }
233
+ if (externalEvent) lastExternalEventRef.current = externalEvent;
168
234
  }, [externalEvent]);
169
235
 
170
236
  /* ---------- error buffer + last emitted bundle ---------- */
171
- var errorsBufferRef = useRef([]); // pending errors (not yet emitted)
237
+ var errorsBufferRef = useRef([]);
172
238
  var lastEmittedRef = useRef({
173
239
  externalEvent: null,
174
240
  errors: []
175
- }); // last bundle we sent
241
+ });
176
242
  var flushTimerRef = useRef(null);
177
243
  var emit = useCallback(function (external, errors) {
178
244
  var payload = {
@@ -181,13 +247,11 @@ export default function LiteRenderer(props) {
181
247
  };
182
248
  try {
183
249
  onError === null || onError === void 0 || onError(payload);
184
- } catch (_unused3) {}
250
+ } catch (_unused5) {}
185
251
  // eslint-disable-next-line no-console
186
252
  console.debug('[LiteRenderer:onError]', payload);
187
253
  lastEmittedRef.current = payload;
188
254
  }, [onError]);
189
-
190
- // batch short bursts (e.g., multiple async errors in same tick)
191
255
  var scheduleFlush = useCallback(function () {
192
256
  if (flushTimerRef.current) return;
193
257
  flushTimerRef.current = setTimeout(function () {
@@ -196,7 +260,7 @@ export default function LiteRenderer(props) {
196
260
  if (!errors.length) return;
197
261
  errorsBufferRef.current = [];
198
262
  emit(lastExternalEventRef.current, errors);
199
- }, 0); // micro-batch; increase (e.g. 50ms) if you want coarser batching
263
+ }, 0);
200
264
  }, [emit]);
201
265
  var pushError = useCallback(function (errPayload) {
202
266
  errorsBufferRef.current.push(_objectSpread({
@@ -207,6 +271,7 @@ export default function LiteRenderer(props) {
207
271
 
208
272
  /* ---------- global runtime + async error capture ---------- */
209
273
  useEffect(function () {
274
+ if (!isBrowser) return;
210
275
  var onWindowError = function onWindowError(event) {
211
276
  pushError({
212
277
  type: 'runtime-error',
@@ -238,316 +303,20 @@ export default function LiteRenderer(props) {
238
303
  var prev = prevExternalEventRef.current;
239
304
  if (prev === externalEvent) return;
240
305
  prevExternalEventRef.current = externalEvent;
241
-
242
- // if we already emitted something before, re-send it with the new event context
243
306
  var last = lastEmittedRef.current;
244
307
  if (last && last.errors && last.errors.length) {
245
308
  emit(lastExternalEventRef.current, last.errors);
246
309
  }
247
310
  }, [externalEvent, emit]);
248
- var _ref = categoryData && categoryData.data || {},
249
- catalogs = _ref.catalogs,
250
- colorAlias = _ref.colorAlias,
251
- subgroups = _ref.subgroups;
252
- var _ref2 = dataBundle || {},
253
- _ref2$data = _ref2.data,
254
- data = _ref2$data === void 0 ? [] : _ref2$data,
255
- _ref2$appliances = _ref2.appliances,
256
- appliances = _ref2$appliances === void 0 ? [] : _ref2$appliances,
257
- _ref2$furnishing = _ref2.furnishing,
258
- furnishing = _ref2$furnishing === void 0 ? [] : _ref2$furnishing,
259
- _ref2$lighting = _ref2.lighting,
260
- lighting = _ref2$lighting === void 0 ? [] : _ref2$lighting;
261
- var _projectElement = _slicedToArray(projectElement, 1),
262
- project_data = _projectElement[0].project_data;
263
- var id = configData.id,
264
- logoImg = configData.logoImg,
265
- companyUrl = configData.companyUrl;
266
- var _React$useState = React.useState([]),
267
- _React$useState2 = _slicedToArray(_React$useState, 2),
268
- outlineSVGData = _React$useState2[0],
269
- setOutlineSVGData = _React$useState2[1];
270
- var _React$useState3 = React.useState(false),
271
- _React$useState4 = _slicedToArray(_React$useState3, 2),
272
- catalogInitiated = _React$useState4[0],
273
- setCatalogInitiated = _React$useState4[1];
274
- useEffect(function () {
275
- var initMyCatalog = /*#__PURE__*/function () {
276
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
277
- var x, _x, _x2;
278
- return _regeneratorRuntime.wrap(function (_context) {
279
- while (1) switch (_context.prev = _context.next) {
280
- case 0:
281
- for (x in Areas) MyCatalog.registerElement(Areas[x]);
282
- for (_x in Lines) MyCatalog.registerElement(Lines[_x]);
283
- for (_x2 in Holes) MyCatalog.registerElement(Holes[_x2]);
284
- MyCatalog.registerCategory('Windows', 'Windows', [Holes.windowClear, Holes.windowCross, Holes.windowDoubleHung, Holes.windowVertical]);
285
- MyCatalog.registerCategory('Doors', 'Doors', [Holes.doorInterior, Holes.doorExterior, Holes.doorCloset, Holes.doorSliding, Holes.doorwayFramed, Holes.doorwayFrameless]);
286
- case 1:
287
- case "end":
288
- return _context.stop();
289
- }
290
- }, _callee);
291
- }));
292
- return function initMyCatalog() {
293
- return _ref3.apply(this, arguments);
294
- };
295
- }();
296
- var loadMoldings = /*#__PURE__*/function () {
297
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
298
- var door_color_alias, subgroup_ids, door_color_alias_ids, doorStyleData, molding, toeMoldingData, cabinets, promises;
299
- return _regeneratorRuntime.wrap(function (_context2) {
300
- while (1) switch (_context2.prev = _context2.next) {
301
- case 0:
302
- door_color_alias = [];
303
- subgroup_ids = catalogs.filter(function (item) {
304
- return item.id == id;
305
- })[0].manufacturer_subgroup_ids.split(',');
306
- door_color_alias_ids = [];
307
- subgroups.forEach(function (subgroup) {
308
- if (subgroup_ids.some(function (id) {
309
- return id == subgroup.id.toString();
310
- })) {
311
- subgroup.door_color_alias_ids.split(',').forEach(function (item) {
312
- item != '' && door_color_alias_ids.push(item);
313
- });
314
- }
315
- });
316
- colorAlias.forEach(function (color) {
317
- return door_color_alias_ids.some(function (id) {
318
- return id == color.id.toString();
319
- }) && door_color_alias.push(color);
320
- });
321
- doorStyleData = categoryData.data.doorStyles.items;
322
- categoryData.data.doorStyles.items = doorStyleData.treeStruct;
323
- door_color_alias.forEach(function (dca) {
324
- doorStyleData.doorColorData.forEach(function (dc) {
325
- dc.door_style_id = parseInt(dc.door_style_id);
326
- if (dc.id !== dca.door_color_id) return;
327
- dc.name = dca.alias_name;
328
- dc.color_sku_alias = dca.sku_alias_name;
329
- doorStyleData.treeStruct.forEach(function (el) {
330
- el.items.forEach(function (elem) {
331
- return dc.door_style_id === elem.id && (dc.door_style_name = elem.name);
332
- });
333
- });
334
- dca.alias_installation_type = isEmpty(dca.alias_installation_type) ? [] : dca.alias_installation_type.split(',').map(function (n) {
335
- return parseInt(n);
336
- });
337
- categoryData.data.doorStyles.items.forEach(function (item) {
338
- if (dca.alias_installation_type.some(function (ait) {
339
- return ait === item.id;
340
- })) item.items.forEach(function (ds) {
341
- if (ds.name === dc.door_style_name) ds.items.push(dc);
342
- });
343
- });
344
- });
345
- });
346
- molding = [];
347
- toeMoldingData = [];
348
- cabinets = categoryData.data.cabinets;
349
- cabinets[cabinets.length - 1].items.forEach(function (index) {
350
- if (index.name.toLowerCase().includes('molding')) {
351
- index.items.forEach(function (item) {
352
- return molding.push(item);
353
- });
354
- }
355
- if (index.name.includes(TOE_KICK_MOLDING)) {
356
- index.items.forEach(function (item) {
357
- return toeMoldingData.push(item);
358
- });
359
- }
360
- });
361
- categoryData.data.toeMoldingData = toeMoldingData;
362
- promises = molding.map(function (child) {
363
- return new Promise(function (resolve, reject) {
364
- var url = child === null || child === void 0 ? void 0 : child.shape_svg;
365
- if (!url) return resolve();
366
- var loader = new SVGLoader();
367
- loader.load(url, function (data) {
368
- var _data$xml$viewBox$ani, _data$xml, _data$xml$viewBox$ani2, _data$xml2;
369
- child.data = {
370
- paths: data.paths,
371
- svg_width: (_data$xml$viewBox$ani = (_data$xml = data.xml) === null || _data$xml === void 0 || (_data$xml = _data$xml.viewBox) === null || _data$xml === void 0 || (_data$xml = _data$xml.animVal) === null || _data$xml === void 0 ? void 0 : _data$xml.width) !== null && _data$xml$viewBox$ani !== void 0 ? _data$xml$viewBox$ani : 0,
372
- svg_height: (_data$xml$viewBox$ani2 = (_data$xml2 = data.xml) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.viewBox) === null || _data$xml2 === void 0 || (_data$xml2 = _data$xml2.animVal) === null || _data$xml2 === void 0 ? void 0 : _data$xml2.height) !== null && _data$xml$viewBox$ani2 !== void 0 ? _data$xml$viewBox$ani2 : 0
373
- };
374
- resolve();
375
- }, null, function (error) {
376
- console.error(error);
377
- reject(error);
378
- });
379
- });
380
- });
381
- return _context2.abrupt("return", Promise.all(promises));
382
- case 1:
383
- case "end":
384
- return _context2.stop();
385
- }
386
- }, _callee2);
387
- }));
388
- return function loadMoldings() {
389
- return _ref4.apply(this, arguments);
390
- };
391
- }();
392
- var loadSVGs = /*#__PURE__*/function () {
393
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
394
- var svgLoadPromises, outlineData;
395
- return _regeneratorRuntime.wrap(function (_context4) {
396
- while (1) switch (_context4.prev = _context4.next) {
397
- case 0:
398
- svgLoadPromises = data.map(/*#__PURE__*/function () {
399
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(item) {
400
- var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
401
- return _regeneratorRuntime.wrap(function (_context3) {
402
- while (1) switch (_context3.prev = _context3.next) {
403
- case 0:
404
- if (item.outline) {
405
- _context3.next = 1;
406
- break;
407
- }
408
- return _context3.abrupt("return", null);
409
- case 1:
410
- _context3.prev = 1;
411
- _context3.next = 2;
412
- return fetch(item.outline, {
413
- cache: 'no-store'
414
- });
415
- case 2:
416
- response = _context3.sent;
417
- _context3.next = 3;
418
- return response.text();
419
- case 3:
420
- svgText = _context3.sent;
421
- loader = new SVGLoader();
422
- parsed = loader.parse(svgText);
423
- if (!isEmpty(parsed.paths)) {
424
- _context3.next = 4;
425
- break;
426
- }
427
- return _context3.abrupt("return", null);
428
- case 4:
429
- return _context3.abrupt("return", {
430
- paths: parsed.paths,
431
- svgWidth: parseFloat(parsed.xml.getAttribute('width')) || ((_parsed$xml$viewBox = parsed.xml.viewBox) === null || _parsed$xml$viewBox === void 0 || (_parsed$xml$viewBox = _parsed$xml$viewBox.animVal) === null || _parsed$xml$viewBox === void 0 ? void 0 : _parsed$xml$viewBox.width) || 0,
432
- svgHeight: parseFloat(parsed.xml.getAttribute('height')) || ((_parsed$xml$viewBox2 = parsed.xml.viewBox) === null || _parsed$xml$viewBox2 === void 0 || (_parsed$xml$viewBox2 = _parsed$xml$viewBox2.animVal) === null || _parsed$xml$viewBox2 === void 0 ? void 0 : _parsed$xml$viewBox2.height) || 0,
433
- reverse: !parseFloat(parsed.xml.getAttribute('height'))
434
- });
435
- case 5:
436
- _context3.prev = 5;
437
- _t = _context3["catch"](1);
438
- console.error('Failed to load SVG:', item.outline, _t);
439
- return _context3.abrupt("return", null);
440
- case 6:
441
- case "end":
442
- return _context3.stop();
443
- }
444
- }, _callee3, null, [[1, 5]]);
445
- }));
446
- return function (_x3) {
447
- return _ref6.apply(this, arguments);
448
- };
449
- }());
450
- _context4.next = 1;
451
- return Promise.all(svgLoadPromises);
452
- case 1:
453
- outlineData = _context4.sent;
454
- setOutlineSVGData(outlineData);
455
- case 2:
456
- case "end":
457
- return _context4.stop();
458
- }
459
- }, _callee4);
460
- }));
461
- return function loadSVGs() {
462
- return _ref5.apply(this, arguments);
463
- };
464
- }();
465
- var initCatalog = /*#__PURE__*/function () {
466
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
467
- return _regeneratorRuntime.wrap(function (_context5) {
468
- while (1) switch (_context5.prev = _context5.next) {
469
- case 0:
470
- setCatalogInitiated(false);
471
- _context5.next = 1;
472
- return initMyCatalog();
473
- case 1:
474
- _context5.next = 2;
475
- return loadMoldings();
476
- case 2:
477
- _context5.next = 3;
478
- return loadSVGs();
479
- case 3:
480
- setCatalogInitiated(true);
481
- case 4:
482
- case "end":
483
- return _context5.stop();
484
- }
485
- }, _callee5);
486
- }));
487
- return function initCatalog() {
488
- return _ref7.apply(this, arguments);
489
- };
490
- }();
491
- initCatalog();
492
- // eslint-disable-next-line react-hooks/exhaustive-deps
493
- }, [categoryData, data, id, catalogs, colorAlias, subgroups]);
494
-
495
- // Register items once SVGs are loaded
496
- useEffect(function () {
497
- if (!outlineSVGData.length) return;
498
- var Item = [];
499
- data.forEach(function (obj, index) {
500
- Item.push(exporter(_objectSpread(_objectSpread({}, obj), {}, {
501
- type: 'cabinet',
502
- outlineSVGData: outlineSVGData[index],
503
- render2DItem: render2DItem,
504
- render3DItem: render3DItem
505
- })));
506
- });
507
- appliances.forEach(function (obj) {
508
- Item.push(exporter(_objectSpread(_objectSpread({}, obj), {}, {
509
- render2DItem: render2DItem,
510
- render3DItem: render3DApplianceItem,
511
- type: 'appliance'
512
- })));
513
- });
514
- lighting.forEach(function (obj) {
515
- Item.push(exporter(_objectSpread(_objectSpread({}, obj), {}, {
516
- type: 'lighting',
517
- render2DItem: render2DItem,
518
- render3DItem: render3DLightingItem
519
- })));
520
- });
521
- furnishing.forEach(function (obj) {
522
- Item.push(exporter(_objectSpread(_objectSpread({}, obj), {}, {
523
- type: 'furnishing',
524
- render2DItem: render2DItem,
525
- render3DItem: render3DApplianceItem
526
- })));
527
- });
528
- for (var x in Item) MyCatalog.registerElement(Item[x]);
529
- }, [outlineSVGData, data, appliances, furnishing, lighting]);
530
- useEffect(function () {
531
- if (projectElement.length === 0) return;
532
- if (!catalogInitiated) return;
533
- sessionStorage.setItem('projectTitle', projectElement[0].title);
534
- store.dispatch(rename(projectElement[0].title));
535
- sessionStorage.setItem('projectId', projectElement[0].id);
536
- sessionStorage.setItem('email', projectElement[0].email);
537
- sessionStorage.setItem('firstName', projectElement[0].firstName);
538
- sessionStorage.setItem('lastName', projectElement[0].lastName);
539
- sessionStorage.setItem('phone', projectElement[0].phone);
540
- var jsonData;
541
- jsonData = JSON.parse(projectElement[0].project_data);
542
- jsonData.isLoadingCabinet = false;
543
- store.dispatch(loadProject(jsonData, categoryData));
544
- }, [project_data, catalogInitiated]);
311
+ var _ref = configData || {},
312
+ logoImg = _ref.logoImg,
313
+ companyUrl = _ref.companyUrl;
545
314
  return /*#__PURE__*/React.createElement(AppContext.Provider, null, /*#__PURE__*/React.createElement(Provider, {
546
- store: store
315
+ store: storeRef.current
547
316
  }, /*#__PURE__*/React.createElement(ToolErrorBoundary, {
548
317
  pushError: pushError
549
318
  }, /*#__PURE__*/React.createElement(LiteKitchenConfigurator, _extends({
550
- catalog: MyCatalog,
319
+ catalog: catalogRef.current,
551
320
  width: width,
552
321
  height: height,
553
322
  logoImage: logoImg,
@@ -556,22 +325,14 @@ export default function LiteRenderer(props) {
556
325
  stateExtractor: function stateExtractor(state) {
557
326
  return state.get('KitchenConfigurator');
558
327
  },
559
- categoryData: categoryData,
560
- data: data,
561
328
  configData: configData,
562
329
  externalEvent: externalEvent,
563
- onExternalEventProcessed: onExternalEventProcessed
330
+ onInternalEvent: onInternalEvent
564
331
  }, passThrough)))));
565
332
  }
566
-
567
- /* ============================== prop types ============================== */
568
-
569
333
  LiteRenderer.propTypes = {
570
334
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
571
335
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
572
- projectElement: PropTypes.arrayOf(PropTypes.object),
573
- categoryData: PropTypes.any,
574
- dataBundle: PropTypes.any,
575
336
  configData: PropTypes.any,
576
337
  catalog: PropTypes.oneOfType([PropTypes.object, PropTypes.instanceOf(Models.Catalog)]),
577
338
  logoImg: PropTypes.any,
@@ -585,7 +346,7 @@ LiteRenderer.propTypes = {
585
346
  environment: PropTypes.string
586
347
  }),
587
348
  externalEvent: PropTypes.object,
588
- onExternalEventProcessed: PropTypes.func,
349
+ onInternalEvent: PropTypes.func,
589
350
  onError: PropTypes.func,
590
351
  store: PropTypes.object
591
352
  };