kitchen-simulator 4.4.1 → 4.4.2-dynamic-holes
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.
- package/es/LiteRenderer.js +153 -57
- package/es/catalog/holes/door-double/door_double.png +0 -0
- package/es/catalog/holes/door-panic/panicDoor.png +0 -0
- package/es/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
- package/es/catalog/holes/gate/gate.jpg +0 -0
- package/es/catalog/holes/window-clear/texture.png +0 -0
- package/es/catalog/holes/window-cross/texture.png +0 -0
- package/es/catalog/holes/window-double-hung/texture.png +0 -0
- package/es/catalog/holes/window-vertical/texture.png +0 -0
- package/es/constants.js +5 -5
- package/es/devLiteRenderer.js +2 -0
- package/es/utils/isolate-event-handler.js +502 -122
- package/lib/LiteRenderer.js +153 -57
- package/lib/catalog/holes/door-double/door_double.png +0 -0
- package/lib/catalog/holes/door-panic/panicDoor.png +0 -0
- package/lib/catalog/holes/door-panic-double/panicDoorDouble.png +0 -0
- package/lib/catalog/holes/gate/gate.jpg +0 -0
- package/lib/catalog/holes/window-clear/texture.png +0 -0
- package/lib/catalog/holes/window-cross/texture.png +0 -0
- package/lib/catalog/holes/window-double-hung/texture.png +0 -0
- package/lib/catalog/holes/window-vertical/texture.png +0 -0
- package/lib/constants.js +5 -5
- package/lib/devLiteRenderer.js +2 -0
- package/lib/utils/isolate-event-handler.js +502 -122
- package/package.json +1 -1
package/es/LiteRenderer.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
9
|
-
var _excluded = ["width", "height", "configData", "externalEvent", "onInternalEvent", "onError"];
|
|
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; }
|
|
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; }
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
var _excluded = ["width", "height", "configData", "externalEvent", "onInternalEvent", "onError", "holes"];
|
|
12
6
|
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
7
|
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
8
|
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
|
-
function
|
|
16
|
-
function
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
17
11
|
// LiteRenderer.jsx
|
|
18
12
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
19
13
|
import PropTypes from 'prop-types';
|
|
@@ -79,48 +73,147 @@ function serializeError(err) {
|
|
|
79
73
|
};
|
|
80
74
|
}
|
|
81
75
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
var INCH_TO_CM = 2.54;
|
|
77
|
+
var normalizeKey = function normalizeKey(value) {
|
|
78
|
+
return (value !== null && value !== void 0 ? value : '').toString().toLowerCase().replace(/[^a-z0-9]+/g, '');
|
|
79
|
+
};
|
|
80
|
+
var safeParseJson = function safeParseJson(value) {
|
|
81
|
+
if (!value) return null;
|
|
82
|
+
try {
|
|
83
|
+
return JSON.parse(value);
|
|
84
|
+
} catch (_unused3) {
|
|
85
|
+
return null;
|
|
88
86
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
};
|
|
88
|
+
var toCatalogLength = function toCatalogLength(value, prop) {
|
|
89
|
+
var _prop$defaultValue;
|
|
90
|
+
if (value == null) return null;
|
|
91
|
+
var unit = prop === null || prop === void 0 || (_prop$defaultValue = prop.defaultValue) === null || _prop$defaultValue === void 0 ? void 0 : _prop$defaultValue.unit;
|
|
92
|
+
if (unit && unit.toLowerCase() === 'in') return value;
|
|
93
|
+
return value * INCH_TO_CM;
|
|
94
|
+
};
|
|
95
|
+
var overrideLengthProperty = function overrideLengthProperty(prop, value) {
|
|
96
|
+
if (!prop || value == null) return prop;
|
|
97
|
+
var length = toCatalogLength(value, prop);
|
|
98
|
+
if (length == null) return prop;
|
|
99
|
+
return _objectSpread(_objectSpread({}, prop), {}, {
|
|
100
|
+
defaultValue: _objectSpread(_objectSpread({}, prop.defaultValue), {}, {
|
|
101
|
+
length: length
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
var findBaseHoleTemplate = function findBaseHoleTemplate(hole, templates) {
|
|
106
|
+
var target = normalizeKey(hole === null || hole === void 0 ? void 0 : hole.name);
|
|
107
|
+
if (!target) return null;
|
|
108
|
+
return templates.find(function (template) {
|
|
109
|
+
var _template$info, _template$info2;
|
|
110
|
+
var candidates = [template === null || template === void 0 ? void 0 : template.name, template === null || template === void 0 || (_template$info = template.info) === null || _template$info === void 0 ? void 0 : _template$info.title, template === null || template === void 0 || (_template$info2 = template.info) === null || _template$info2 === void 0 ? void 0 : _template$info2.description].map(normalizeKey);
|
|
111
|
+
return candidates.includes(target);
|
|
112
|
+
}) || null;
|
|
113
|
+
};
|
|
114
|
+
var buildHoleElementFromTemplate = function buildHoleElementFromTemplate(hole, base) {
|
|
115
|
+
var _base$info, _base$info2, _base$info3, _base$info4, _base$info5, _base$structure_json;
|
|
116
|
+
if (!hole || !base) return null;
|
|
117
|
+
var nextInfo = _objectSpread(_objectSpread({}, base.info), {}, {
|
|
118
|
+
title: hole.name || ((_base$info = base.info) === null || _base$info === void 0 ? void 0 : _base$info.title),
|
|
119
|
+
description: ((_base$info2 = base.info) === null || _base$info2 === void 0 ? void 0 : _base$info2.description) || hole.name || ((_base$info3 = base.info) === null || _base$info3 === void 0 ? void 0 : _base$info3.title),
|
|
120
|
+
image: hole.menu_thumbnail || ((_base$info4 = base.info) === null || _base$info4 === void 0 ? void 0 : _base$info4.image),
|
|
121
|
+
url: hole.gltf || ((_base$info5 = base.info) === null || _base$info5 === void 0 ? void 0 : _base$info5.url)
|
|
122
|
+
});
|
|
123
|
+
var nextProperties = _objectSpread({}, base.properties);
|
|
124
|
+
if (nextProperties.width) {
|
|
125
|
+
nextProperties.width = overrideLengthProperty(nextProperties.width, hole.width);
|
|
126
|
+
}
|
|
127
|
+
if (nextProperties.height) {
|
|
128
|
+
nextProperties.height = overrideLengthProperty(nextProperties.height, hole.height);
|
|
129
|
+
}
|
|
130
|
+
if (nextProperties.length) {
|
|
131
|
+
nextProperties.length = overrideLengthProperty(nextProperties.length, hole.length);
|
|
132
|
+
}
|
|
133
|
+
var customConfig = safeParseJson(hole.custom_config);
|
|
134
|
+
var customProps = (customConfig === null || customConfig === void 0 ? void 0 : customConfig.properties) || {};
|
|
135
|
+
Object.keys(customProps).forEach(function (key) {
|
|
136
|
+
if (!nextProperties[key]) return;
|
|
137
|
+
nextProperties[key] = overrideLengthProperty(nextProperties[key], customProps[key]);
|
|
138
|
+
});
|
|
139
|
+
return _objectSpread(_objectSpread({}, base), {}, {
|
|
140
|
+
name: hole.name || base.name,
|
|
141
|
+
info: nextInfo,
|
|
142
|
+
properties: nextProperties,
|
|
143
|
+
structure_json: _objectSpread(_objectSpread({}, base.structure_json || {}), {}, {
|
|
144
|
+
hole_id: hole.id || ((_base$structure_json = base.structure_json) === null || _base$structure_json === void 0 ? void 0 : _base$structure_json.hole_id)
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
var buildHoleElements = function buildHoleElements(holes) {
|
|
149
|
+
var categories = {
|
|
150
|
+
Doors: [],
|
|
151
|
+
Windows: []
|
|
152
|
+
};
|
|
153
|
+
var elements = [];
|
|
154
|
+
if (!Array.isArray(holes)) return {
|
|
155
|
+
elements: elements,
|
|
156
|
+
categories: categories
|
|
157
|
+
};
|
|
158
|
+
var templates = Object.values(Holes);
|
|
159
|
+
var usedNames = new Set();
|
|
160
|
+
holes.forEach(function (hole) {
|
|
161
|
+
var _base$info6;
|
|
162
|
+
if (!hole || hole.is_deleted) return;
|
|
163
|
+
var base = findBaseHoleTemplate(hole, templates);
|
|
164
|
+
if (!base) return;
|
|
165
|
+
var element = buildHoleElementFromTemplate(hole, base);
|
|
166
|
+
if (!element || !element.name || usedNames.has(element.name)) return;
|
|
167
|
+
usedNames.add(element.name);
|
|
168
|
+
elements.push(element);
|
|
169
|
+
var typeKey = normalizeKey(hole.type);
|
|
170
|
+
if (typeKey === 'window') {
|
|
171
|
+
categories.Windows.push(element);
|
|
172
|
+
} else if (typeKey === 'door') {
|
|
173
|
+
categories.Doors.push(element);
|
|
174
|
+
} else if ((_base$info6 = base.info) !== null && _base$info6 !== void 0 && (_base$info6 = _base$info6.tag) !== null && _base$info6 !== void 0 && _base$info6.includes('window')) {
|
|
175
|
+
categories.Windows.push(element);
|
|
176
|
+
} else {
|
|
177
|
+
categories.Doors.push(element);
|
|
106
178
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
elements: elements,
|
|
182
|
+
categories: categories
|
|
183
|
+
};
|
|
112
184
|
};
|
|
113
185
|
|
|
114
186
|
// ----------------- catalog init -----------------
|
|
115
|
-
function initCatalogOnce(catalog) {
|
|
187
|
+
function initCatalogOnce(catalog, holePayload) {
|
|
116
188
|
if (!catalog) return;
|
|
117
|
-
if (catalog.__ksInitialized)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
189
|
+
if (!catalog.__ksInitialized) {
|
|
190
|
+
for (var x in Areas) catalog.registerElement(Areas[x]);
|
|
191
|
+
for (var _x in Lines) catalog.registerElement(Lines[_x]);
|
|
192
|
+
catalog.__ksInitialized = true;
|
|
193
|
+
}
|
|
194
|
+
var holeElements = (holePayload === null || holePayload === void 0 ? void 0 : holePayload.elements) || [];
|
|
195
|
+
holeElements.forEach(function (element) {
|
|
196
|
+
if (!catalog.hasElement(element.name)) {
|
|
197
|
+
console.log(element);
|
|
198
|
+
catalog.registerElement(element);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
var categories = (holePayload === null || holePayload === void 0 ? void 0 : holePayload.categories) || {};
|
|
202
|
+
Object.entries(categories).forEach(function (_ref) {
|
|
203
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
204
|
+
name = _ref2[0],
|
|
205
|
+
elements = _ref2[1];
|
|
206
|
+
if (!elements.length) return;
|
|
207
|
+
if (!catalog.hasCategory(name)) {
|
|
208
|
+
catalog.registerCategory(name, name, elements);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
elements.forEach(function (element) {
|
|
212
|
+
if (!catalog.categoryHasElement(name, element.name)) {
|
|
213
|
+
catalog.addToCategory(name, element);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
});
|
|
124
217
|
}
|
|
125
218
|
|
|
126
219
|
// ----------------- store factory -----------------
|
|
@@ -164,7 +257,11 @@ export default function LiteRenderer(props) {
|
|
|
164
257
|
externalEvent = props.externalEvent,
|
|
165
258
|
onInternalEvent = props.onInternalEvent,
|
|
166
259
|
onError = props.onError,
|
|
260
|
+
holes = props.holes,
|
|
167
261
|
passThrough = _objectWithoutProperties(props, _excluded);
|
|
262
|
+
var holePayload = useMemo(function () {
|
|
263
|
+
return buildHoleElements(holes);
|
|
264
|
+
}, [holes]);
|
|
168
265
|
|
|
169
266
|
// ✅ instance-scoped store (no module singleton)
|
|
170
267
|
var storeRef = useRef(null);
|
|
@@ -174,8 +271,8 @@ export default function LiteRenderer(props) {
|
|
|
174
271
|
var catalogRef = useRef(null);
|
|
175
272
|
if (!catalogRef.current) {
|
|
176
273
|
catalogRef.current = new Catalog();
|
|
177
|
-
initCatalogOnce(catalogRef.current);
|
|
178
274
|
}
|
|
275
|
+
initCatalogOnce(catalogRef.current, holePayload);
|
|
179
276
|
|
|
180
277
|
// ✅ stable plugins array
|
|
181
278
|
var plugins = useMemo(function () {
|
|
@@ -198,7 +295,7 @@ export default function LiteRenderer(props) {
|
|
|
198
295
|
try {
|
|
199
296
|
var maybeCleanup = p === null || p === void 0 ? void 0 : p(store, stateExtractor);
|
|
200
297
|
if (typeof maybeCleanup === 'function') cleanups.push(maybeCleanup);
|
|
201
|
-
} catch (
|
|
298
|
+
} catch (_unused5) {
|
|
202
299
|
// keep prior behavior: do not crash
|
|
203
300
|
}
|
|
204
301
|
}
|
|
@@ -216,7 +313,7 @@ export default function LiteRenderer(props) {
|
|
|
216
313
|
var fn = _step2.value;
|
|
217
314
|
try {
|
|
218
315
|
fn();
|
|
219
|
-
} catch (
|
|
316
|
+
} catch (_unused4) {}
|
|
220
317
|
}
|
|
221
318
|
} catch (err) {
|
|
222
319
|
_iterator2.e(err);
|
|
@@ -247,7 +344,7 @@ export default function LiteRenderer(props) {
|
|
|
247
344
|
};
|
|
248
345
|
try {
|
|
249
346
|
onError === null || onError === void 0 || onError(payload);
|
|
250
|
-
} catch (
|
|
347
|
+
} catch (_unused6) {}
|
|
251
348
|
// eslint-disable-next-line no-console
|
|
252
349
|
console.debug('[LiteRenderer:onError]', payload);
|
|
253
350
|
lastEmittedRef.current = payload;
|
|
@@ -308,13 +405,11 @@ export default function LiteRenderer(props) {
|
|
|
308
405
|
emit(lastExternalEventRef.current, last.errors);
|
|
309
406
|
}
|
|
310
407
|
}, [externalEvent, emit]);
|
|
311
|
-
var
|
|
312
|
-
logoImg =
|
|
313
|
-
companyUrl =
|
|
408
|
+
var _ref3 = configData || {},
|
|
409
|
+
logoImg = _ref3.logoImg,
|
|
410
|
+
companyUrl = _ref3.companyUrl;
|
|
314
411
|
return /*#__PURE__*/React.createElement(AppContext.Provider, null, /*#__PURE__*/React.createElement(Provider, {
|
|
315
412
|
store: storeRef.current
|
|
316
|
-
}, /*#__PURE__*/React.createElement(ToolErrorBoundary, {
|
|
317
|
-
pushError: pushError
|
|
318
413
|
}, /*#__PURE__*/React.createElement(LiteKitchenConfigurator, _extends({
|
|
319
414
|
catalog: catalogRef.current,
|
|
320
415
|
width: width,
|
|
@@ -328,7 +423,7 @@ export default function LiteRenderer(props) {
|
|
|
328
423
|
configData: configData,
|
|
329
424
|
externalEvent: externalEvent,
|
|
330
425
|
onInternalEvent: onInternalEvent
|
|
331
|
-
}, passThrough))))
|
|
426
|
+
}, passThrough))));
|
|
332
427
|
}
|
|
333
428
|
LiteRenderer.propTypes = {
|
|
334
429
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -348,5 +443,6 @@ LiteRenderer.propTypes = {
|
|
|
348
443
|
externalEvent: PropTypes.object,
|
|
349
444
|
onInternalEvent: PropTypes.func,
|
|
350
445
|
onError: PropTypes.func,
|
|
446
|
+
holes: PropTypes.array,
|
|
351
447
|
store: PropTypes.object
|
|
352
448
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/es/constants.js
CHANGED
|
@@ -657,16 +657,16 @@ export var PROJECT_SETTING_OPTION = {
|
|
|
657
657
|
CHANGE_MEASUREMENT_UNIT: CHANGE_MEASUREMENT_UNIT
|
|
658
658
|
};
|
|
659
659
|
export var HOLE_NAMES = {
|
|
660
|
-
WINDOW_CLEAR: '
|
|
661
|
-
WINDOW_CROSS: 'Cross
|
|
662
|
-
WINDOW_DOUBLE_HUNG: 'Double Hung
|
|
663
|
-
WINDOW_VERTICAL: '
|
|
660
|
+
WINDOW_CLEAR: 'Clear',
|
|
661
|
+
WINDOW_CROSS: 'Cross',
|
|
662
|
+
WINDOW_DOUBLE_HUNG: 'Double Hung',
|
|
663
|
+
WINDOW_VERTICAL: 'Vertical',
|
|
664
664
|
DOOR_CLOSET: 'Closet',
|
|
665
665
|
DOOR_EXTERIOR: 'Exterior',
|
|
666
666
|
DOOR_INTERIOR: 'Interior',
|
|
667
667
|
DOOR_SLIDING: 'Sliding',
|
|
668
668
|
DOOR_FRAMED: 'Framed Doorway',
|
|
669
|
-
DOOR_FRAMELESS: '
|
|
669
|
+
DOOR_FRAMELESS: 'Frameless Doorway'
|
|
670
670
|
};
|
|
671
671
|
|
|
672
672
|
// direction type
|
package/es/devLiteRenderer.js
CHANGED
|
@@ -17,6 +17,7 @@ import furnishingPayload from "./mocks/furnishingPayload.json";
|
|
|
17
17
|
import rectangleData from "./mocks/rectangleShape.json";
|
|
18
18
|
import moldingPayload from "./mocks/moldingPayload.json";
|
|
19
19
|
import replaceCabinetPayload from "./mocks/replaceCabinetPayload.json";
|
|
20
|
+
import holesPayload from "./mocks/holesPayload.json";
|
|
20
21
|
import ReactDOM from 'react-dom';
|
|
21
22
|
import LiteRenderer from "./LiteRenderer";
|
|
22
23
|
import { Button } from 'antd';
|
|
@@ -860,6 +861,7 @@ function WorkSpace(props) {
|
|
|
860
861
|
logoImg: "/assets/logo.png",
|
|
861
862
|
companyUrl: "https://example.com",
|
|
862
863
|
toolbarButtons: [],
|
|
864
|
+
holes: holesPayload,
|
|
863
865
|
externalEvent: externalEvent,
|
|
864
866
|
onInternalEvent: onInternalEvent,
|
|
865
867
|
onError: function onError(payload) {
|