kitchen-simulator 4.4.1 → 4.4.2

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.
@@ -13,7 +13,6 @@ exports.getLinesFromItems = getLinesFromItems;
13
13
  exports.getLinesFromItems2 = getLinesFromItems2;
14
14
  exports.getLinesOfItem = getLinesOfItem;
15
15
  exports.getLinesOfItem2 = getLinesOfItem2;
16
- exports.getMoldingDataOfScene = getMoldingDataOfScene;
17
16
  exports.getMoldingDataOfScene2 = getMoldingDataOfScene2;
18
17
  exports.hasMoldingLayout = hasMoldingLayout;
19
18
  exports.isAttachedWall = isAttachedWall;
@@ -968,7 +967,7 @@ function createMonldingGroup(oldMG, layer, molding, catalog) {
968
967
  newMG = getMDPoints(newMG);
969
968
  return newMG;
970
969
  }
971
- function getMoldingDataOfScene2(layer, catalog, doorStyle) {
970
+ function getMoldingDataOfScene2(layer, catalog, doorStyle, moldingPieceLength) {
972
971
  var _layer$items;
973
972
  var moldingData = [];
974
973
  var items = layer === null || layer === void 0 || (_layer$items = layer.items) === null || _layer$items === void 0 ? void 0 : _layer$items.toArray();
@@ -1130,10 +1129,10 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle) {
1130
1129
  if (idx < 0) moldingData.push(_objectSpread(_objectSpread({}, ml.molding), {}, {
1131
1130
  doorStyle: ml.doorStyle,
1132
1131
  totalLength: mlLength,
1133
- count: Math.ceil(mlLength * 1.1 / 96)
1132
+ count: Math.ceil(mlLength * 1.1 / moldingPieceLength)
1134
1133
  }));else {
1135
1134
  moldingData[idx].totalLength += mlLength;
1136
- moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / 96);
1135
+ moldingData[idx].count = Math.ceil(moldingData[idx].totalLength * 1.1 / moldingPieceLength);
1137
1136
  }
1138
1137
  };
1139
1138
  for (var k = 0; k < moldingLines.length; k++) {
@@ -1141,237 +1140,5 @@ function getMoldingDataOfScene2(layer, catalog, doorStyle) {
1141
1140
  }
1142
1141
  // console.log('moldingData: ', moldingData);
1143
1142
 
1144
- return moldingData;
1145
- }
1146
- function getMoldingDataOfScene(layer, catalog, doorStyle) {
1147
- var moldingData = [];
1148
- var items = layer.items.toArray();
1149
- var moldings = [];
1150
- // get all moldings info
1151
- items.forEach(function (itemCat) {
1152
- var _itemCat$molding;
1153
- itemCat === null || itemCat === void 0 || (_itemCat$molding = itemCat.molding) === null || _itemCat$molding === void 0 || _itemCat$molding.forEach(function (molding) {
1154
- if (!moldings.some(function (m) {
1155
- return m.name === molding.name;
1156
- })) moldings.push(molding);
1157
- });
1158
- });
1159
-
1160
- // calc normal molding
1161
- moldings.forEach(function (molding) {
1162
- var itemGroups = [];
1163
- var temp_items = [];
1164
- items.forEach(function (item) {
1165
- if (item.molding.some(function (mol) {
1166
- return mol.itemID === molding.itemID;
1167
- }) && isEnableItemForMolding(layer, item)) {
1168
- temp_items.push(item);
1169
- }
1170
- });
1171
- if (temp_items.length) {
1172
- while (temp_items.length > 0) {
1173
- var itemGroup = [temp_items[0]];
1174
- var _loop10 = function _loop10(_idx) {
1175
- if (!itemGroup.some(function (it) {
1176
- return it.id === temp_items[_idx].id;
1177
- }) && isItemSnappedGroup(temp_items[_idx], itemGroup)) {
1178
- itemGroup.push(temp_items[_idx]);
1179
- _idx = 0;
1180
- }
1181
- idx = _idx;
1182
- };
1183
- for (var idx = 0; idx < temp_items.length; idx++) {
1184
- _loop10(idx);
1185
- }
1186
- itemGroup.forEach(function (item) {
1187
- var index = temp_items.findIndex(function (it) {
1188
- return it.id === item.id;
1189
- });
1190
- if (index > -1) {
1191
- temp_items.splice(index, 1);
1192
- }
1193
- });
1194
- itemGroups.push(itemGroup);
1195
- }
1196
- var molding_totalLength = 0;
1197
- itemGroups.forEach(function (itemgroup) {
1198
- var allLineRects = _export.GeometryUtils.buildRectFromLines(layer, _export.GeometryUtils.getAllLines(layer));
1199
- var items = (0, _toConsumableArray2["default"])(itemgroup);
1200
- var MGlines = getLinesOfItem(items[0], allLineRects, catalog);
1201
- items = sortItemsByDistance(items, items[0]);
1202
- var _loop11 = function _loop11() {
1203
- var itemLines = getLinesOfItem(items[i], allLineRects, catalog);
1204
- var temp_MGLines = [];
1205
- MGlines.forEach(function (line) {
1206
- var idx = itemLines.findIndex(function (itemLine) {
1207
- return isLinesOverlapped(line, itemLine);
1208
- });
1209
- var curItemLine = itemLines[idx];
1210
- if (idx > -1) {
1211
- if (!(_export.GeometryUtils.samePoints(line[0], curItemLine[0]) && _export.GeometryUtils.samePoints(line[1], curItemLine[1]) || _export.GeometryUtils.samePoints(line[0], curItemLine[1]) && _export.GeometryUtils.samePoints(line[1], curItemLine[0]))) {
1212
- var MGLine = mergeOverlappedLines(line, curItemLine);
1213
- temp_MGLines.push(MGLine);
1214
- }
1215
- itemLines.splice(idx, 1);
1216
- } else {
1217
- temp_MGLines.push(line);
1218
- }
1219
- });
1220
- itemLines.forEach(function (itemLine) {
1221
- return temp_MGLines.push(itemLine);
1222
- });
1223
- MGlines = [].concat(temp_MGLines);
1224
- };
1225
- for (var i = 1; i < items.length; i++) {
1226
- _loop11();
1227
- }
1228
- MGlines.forEach(function (line) {
1229
- molding_totalLength += _export.GeometryUtils.verticesDistance(line[0], line[1]);
1230
- });
1231
- });
1232
- molding_totalLength = (0, _convertUnitsLite.convert)(molding_totalLength).from('cm').to('in');
1233
- moldingData.push(_objectSpread(_objectSpread({}, molding), {}, {
1234
- doorStyle: doorStyle,
1235
- count: Math.ceil(molding_totalLength * 1.1 / 96)
1236
- }));
1237
- }
1238
- });
1239
-
1240
- // calc toe kick molding
1241
- var tmp = [];
1242
- items.forEach(function (item) {
1243
- if (item.category === 'cabinet' && !item.cabinet_category.toLowerCase().includes('microwave')) {
1244
- tmp.push(item);
1245
- }
1246
- });
1247
- var tmpMoldingData = [];
1248
- var toedoorStyles = [];
1249
- tmp.map(function (item) {
1250
- var _item$molding2;
1251
- if (item.layoutpos === _constants.BASE_CABINET_LAYOUTPOS && ((0, _helper.isEmpty)(item.molding) || ((_item$molding2 = item.molding) === null || _item$molding2 === void 0 ? void 0 : _item$molding2.length) < 1 || !isEnableItemForMolding(layer, item))) {
1252
- var w = item.properties.get('width').get('_length');
1253
- var wUnit = item.properties.get('width').get('_unit') || 'cm';
1254
- w = (0, _convertUnitsLite.convert)(w / 2).from(wUnit).to('cm');
1255
- var h = item.properties.get('depth').get('_length');
1256
- var hUnit = item.properties.get('depth').get('_unit') || 'cm';
1257
- h = (0, _convertUnitsLite.convert)(h / 2).from(hUnit).to('cm');
1258
- var outline = null;
1259
- var element = catalog.elements[item.get('type')];
1260
- if (!element) element = catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(item.get('type'))];
1261
- outline = element.info.outline;
1262
- var len = 0;
1263
- if (outline) {
1264
- // Extract Points from `outline`
1265
- var outlinePaths = outline.paths;
1266
- var outlineWidth = outline.svgWidth;
1267
- var outlineHeight = outline.svgHeight;
1268
- var outlinePoints = []; // Hold Points Of SVG
1269
- var _iterator5 = _createForOfIteratorHelper(outlinePaths),
1270
- _step5;
1271
- try {
1272
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1273
- var path = _step5.value;
1274
- var _iterator6 = _createForOfIteratorHelper(path.subPaths),
1275
- _step6;
1276
- try {
1277
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1278
- var subPath = _step6.value;
1279
- outlinePoints = outlinePoints.concat(subPath.getPoints());
1280
- }
1281
- } catch (err) {
1282
- _iterator6.e(err);
1283
- } finally {
1284
- _iterator6.f();
1285
- }
1286
- }
1287
- } catch (err) {
1288
- _iterator5.e(err);
1289
- } finally {
1290
- _iterator5.f();
1291
- }
1292
- var maxX = outlinePoints[0].x,
1293
- minX = outlinePoints[0].x;
1294
- var maxY = outlinePoints[0].y,
1295
- minY = outlinePoints[0].y;
1296
- outlinePoints.forEach(function (point) {
1297
- if (point.x > maxX) {
1298
- maxX = point.x;
1299
- }
1300
- if (point.x < minX) {
1301
- minX = point.x;
1302
- }
1303
- if (point.y > maxY) {
1304
- maxY = point.y;
1305
- }
1306
- if (point.y < minY) {
1307
- minY = point.y;
1308
- }
1309
- });
1310
- outlinePoints.forEach(function (point) {
1311
- if (_export.GeometryUtils.isPointInRect([{
1312
- x: minX,
1313
- y: minY
1314
- }, {
1315
- x: minX,
1316
- y: maxY
1317
- }, {
1318
- x: maxX,
1319
- y: maxY
1320
- }, {
1321
- x: maxX,
1322
- y: minY
1323
- }], point)) {
1324
- if (point.x > 10) len += (point.x / outlineWidth - 0.5) * w * 2 + h * 2 - (point.y / outlineHeight - 0.5) * h * 2;
1325
- }
1326
- });
1327
- len = (0, _convertUnitsLite.convert)(len).from('cm').to('in');
1328
- } else {
1329
- w = (0, _convertUnitsLite.convert)(w * 2).from('cm').to('in');
1330
- len += w;
1331
- }
1332
- var doorIndex = toedoorStyles.findIndex(function (a) {
1333
- var iDS = item === null || item === void 0 ? void 0 : item.doorStyle;
1334
- if (!iDS) return false;
1335
- if (!iDS.hasOwnProperty('id')) {
1336
- iDS = iDS.toJS();
1337
- }
1338
- return a.doorStyle.id === iDS.id && (0, _utils.isEqualInstallationType)(a.doorStyle, iDS);
1339
- });
1340
- if (doorIndex > -1) {
1341
- toedoorStyles[doorIndex].totalLength += len;
1342
- } else {
1343
- toedoorStyles.push({
1344
- doorStyle: item.doorStyle.hasOwnProperty('id') ? item.doorStyle : item.doorStyle && item.doorStyle.toJS(),
1345
- totalLength: len
1346
- });
1347
- }
1348
- }
1349
- });
1350
- toedoorStyles.forEach(function (doorStyle) {
1351
- var skuName = (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog);
1352
- var thumbnail = skuName ? skuName : '';
1353
- // moldings.forEach(molding => {
1354
- // if (
1355
- // molding.name ===
1356
- // getToeKickSKU(
1357
- // doorStyle.doorStyle,
1358
- // catalog,
1359
- // true
1360
- // )
1361
- // )
1362
- // thumbnail = molding.thumbnail;
1363
- // });
1364
-
1365
- doorStyle.totalLength && tmpMoldingData.push({
1366
- name: _constants.TOE_KICK_MOLDING,
1367
- sku: (0, _utils.getToeKickSKU)(doorStyle.doorStyle, catalog),
1368
- thumbnail: thumbnail,
1369
- category: 'molding',
1370
- type: 'cabinet',
1371
- doorStyle: doorStyle.doorStyle,
1372
- count: Math.ceil(doorStyle.totalLength * 1.1 / 96)
1373
- });
1374
- });
1375
- if (tmpMoldingData.length > 0) moldingData = [].concat((0, _toConsumableArray2["default"])(moldingData), tmpMoldingData);
1376
1143
  return moldingData;
1377
1144
  }
@@ -311,14 +311,27 @@ function buildSkinPanelData(faces) {
311
311
  }
312
312
  return result;
313
313
  }
314
+ function shouldExcludeSkinPanel(itemJS, exclusionSet) {
315
+ var _itemJS$doorStyle;
316
+ var cabinetSku = itemJS === null || itemJS === void 0 ? void 0 : itemJS.sku_number;
317
+ var doorColorSku = itemJS === null || itemJS === void 0 || (_itemJS$doorStyle = itemJS.doorStyle) === null || _itemJS$doorStyle === void 0 ? void 0 : _itemJS$doorStyle.sku;
318
+ if (!cabinetSku || !doorColorSku) return false;
319
+ return exclusionSet.has("".concat(cabinetSku, "-").concat(doorColorSku));
320
+ }
314
321
  function computeSkinPanels(layer) {
322
+ var skinPanelExclusionSKUs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
323
+ var exclusionSet = new Set(skinPanelExclusionSKUs);
324
+
315
325
  // Get candidate skin panel items and other items
316
326
  var _collectLayerItems = collectLayerItems(layer),
317
327
  skinPanelItems = _collectLayerItems.skinPanelItems,
318
328
  otherItems = _collectLayerItems.otherItems;
329
+ var filteredSkinPanelItems = skinPanelItems.filter(function (item) {
330
+ return !shouldExcludeSkinPanel(item.toJS(), exclusionSet);
331
+ });
319
332
 
320
333
  // Get all skin face list of [skinPanelItems] & [otherItems]
321
- var skinFaces = collectFaces(skinPanelItems, layer);
334
+ var skinFaces = collectFaces(filteredSkinPanelItems, layer);
322
335
  var otherFaces = collectFaces(otherItems, layer);
323
336
  skinFaces = filterFacesBlockedByFaces(skinFaces, skinFaces);
324
337
  skinFaces = filterFacesBlockedByFaces(skinFaces, otherFaces);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",