kitchen-simulator 10.0.10 → 10.1.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.
package/es/class/item.js CHANGED
@@ -15,6 +15,7 @@ import { hasMoldingLayout } from "../utils/molding";
15
15
  import { getInstallationSuffix, isEmpty } from "../components/viewer2d/utils";
16
16
  import { historyPush } from "../utils/history";
17
17
  import { toJSIfNeeded } from "../shared/objects/immutable";
18
+ import { normalizeLongName } from "../shared/domain/cabinet-identity";
18
19
  var allItemRect;
19
20
  var allItemSnap;
20
21
  var allLines;
@@ -268,10 +269,14 @@ var Item = /*#__PURE__*/function () {
268
269
  idSet = new Set(targetItemIDs);
269
270
  }
270
271
  layer.items.forEach(function (it) {
271
- var _idSet, _picked$door_finish_i;
272
+ var _idSet, _ccdf_list$find, _picked$door_finish_i;
272
273
  var should = applyScope === DOORSTYLE_SCOPE_ALL ? true : (_idSet = idSet) === null || _idSet === void 0 ? void 0 : _idSet.has(it.id);
273
274
  if (!should) return;
274
- var picked = ccdf_list.find(function (c) {
275
+
276
+ // Prefer stable join key: long_name. Fall back to cabinet_id for older payloads.
277
+ var picked = (_ccdf_list$find = ccdf_list.find(function (c) {
278
+ return (c === null || c === void 0 ? void 0 : c.long_name) && (it === null || it === void 0 ? void 0 : it.long_name) && normalizeLongName(c.long_name) === normalizeLongName(it.long_name);
279
+ })) !== null && _ccdf_list$find !== void 0 ? _ccdf_list$find : ccdf_list.find(function (c) {
275
280
  return (c === null || c === void 0 ? void 0 : c.cabinet_id) === it.itemID;
276
281
  });
277
282
  if (!picked) return;
@@ -5,7 +5,8 @@ import React, { useState, useEffect } from 'react';
5
5
  import { Map } from 'immutable';
6
6
  import ContainerDimensions from 'react-container-dimensions';
7
7
  import projectItemsCatalog from "./mocks/projectItemsCatalog.json";
8
- import mockProps from "./mocks/mockProps.json";
8
+ import configData from "./mocks/configData.json";
9
+ import projectJson from "./mocks/project.json";
9
10
  import cabinetPaylod from "./mocks/cabinetPayload.json";
10
11
  import appliancePaylod from "./mocks/appliancePayload.json";
11
12
  import doorStylePayload from "./mocks/doorStylePayload.json";
@@ -79,7 +80,7 @@ function WorkSpace(props) {
79
80
  var evt = {
80
81
  type: EXTERNAL_EVENT_LOAD_PROJECT,
81
82
  // send request for sync scene data to 3DTool
82
- payload: mockProps.projectElement[0].project_data
83
+ payload: projectJson
83
84
  };
84
85
  setExternalEvent(evt);
85
86
  }
@@ -869,7 +870,7 @@ function WorkSpace(props) {
869
870
  }, "Setting-MeasurementUnit-'mm'")), /*#__PURE__*/React.createElement(LiteRenderer, {
870
871
  width: props.width,
871
872
  height: props.height,
872
- configData: mockProps.configData,
873
+ configData: configData,
873
874
  options: options,
874
875
  logoImg: "/assets/logo.png",
875
876
  companyUrl: "https://example.com",
@@ -1,7 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- 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; }
4
- 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; }
5
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
3
  export function handleChangeDoorStyleEvent(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x0, _x1, _x10) {
7
4
  return _handleChangeDoorStyleEvent.apply(this, arguments);
@@ -51,12 +48,12 @@ function _handleChangeDoorStyleEvent() {
51
48
  if (!ccdf_list.some(function (v) {
52
49
  return item.itemID === v.itemID && item.name === v.name && doorStyle.id === v.doorFinishId;
53
50
  })) {
54
- ccdf_list.push(_objectSpread(_objectSpread({}, item), {}, {
51
+ ccdf_list.push({
55
52
  cabinetSku: item.type,
56
53
  sizeInfo: item.sizeinfo,
57
54
  catalogSku: item.sku_number,
58
55
  ccdf: item.ccdf
59
- }));
56
+ });
60
57
  }
61
58
  case 1:
62
59
  case "end":
@@ -92,7 +89,9 @@ function _handleChangeDoorStyleEvent() {
92
89
  return _regeneratorRuntime.wrap(function (_context) {
93
90
  while (1) switch (_context.prev = _context.next) {
94
91
  case 0:
95
- itemCDS = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list);
92
+ // Map CCDF rows back to placed items using stable identity (long_name),
93
+ // because host `cabinet_id` can vary by doorstyle.
94
+ itemCDS = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list, targetItems);
96
95
  mappedCabinetDefinitionList = ccdfMapper(result.ccdf_list, layer); // result: ccdf_list
97
96
  rt = mergeSameElements(mappedCabinetDefinitionList);
98
97
  _i = 0;
@@ -6,6 +6,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
6
6
  import { convert } from "../../utils/convert-units-lite";
7
7
  import { INTERNAL_EVENT_ITEMS_CATALOG } from "../../constants";
8
8
  import { Scene, State } from "../../models";
9
+ import { normalizeLongName } from "../../shared/domain/cabinet-identity";
9
10
  export function handleLoadProjectEvent(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
10
11
  return _handleLoadProjectEvent.apply(this, arguments);
11
12
  }
@@ -32,8 +33,8 @@ function _handleLoadProjectEvent() {
32
33
  var _it$doorStyle;
33
34
  return it.itemID === v.itemID && it.name === v.name && ((_it$doorStyle = it.doorStyle) === null || _it$doorStyle === void 0 ? void 0 : _it$doorStyle.id) === v.doorFinishId;
34
35
  })) ccdf_list.push({
35
- cabinetSku: it.sku,
36
- sizeInfo: it.sizeInfo,
36
+ cabinetSku: it.type,
37
+ sizeInfo: it.sizeinfo,
37
38
  catalogSku: it.sku_number,
38
39
  ccdf: it.ccdf
39
40
  });
@@ -56,7 +57,7 @@ function _handleLoadProjectEvent() {
56
57
  return _regeneratorRuntime.wrap(function (_context) {
57
58
  while (1) switch (_context.prev = _context.next) {
58
59
  case 0:
59
- cdsList = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list);
60
+ cdsList = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list, items);
60
61
  evt.payload = updateProjectWithCDSList(evt.payload, cdsList);
61
62
 
62
63
  // Attach matched ccdf to each scene instance before loading into state,
@@ -66,11 +67,13 @@ function _handleLoadProjectEvent() {
66
67
  try {
67
68
  resp = (_result$ccdf_list = result === null || result === void 0 ? void 0 : result.ccdf_list) !== null && _result$ccdf_list !== void 0 ? _result$ccdf_list : [];
68
69
  Object.keys(items).forEach(function (k) {
69
- var _it$doorStyle$id, _it$doorStyle2;
70
+ var _it$doorStyle$id, _it$doorStyle2, _resp$find;
70
71
  var it = items[k];
71
72
  var desiredDoorFinishId = (_it$doorStyle$id = it === null || it === void 0 || (_it$doorStyle2 = it.doorStyle) === null || _it$doorStyle2 === void 0 ? void 0 : _it$doorStyle2.id) !== null && _it$doorStyle$id !== void 0 ? _it$doorStyle$id : null;
72
73
  if (!desiredDoorFinishId) return;
73
- var picked = resp.find(function (c) {
74
+ var picked = (_resp$find = resp.find(function (c) {
75
+ return (c === null || c === void 0 ? void 0 : c.long_name) && (it === null || it === void 0 ? void 0 : it.long_name) && normalizeLongName(c.long_name) === normalizeLongName(it.long_name);
76
+ })) !== null && _resp$find !== void 0 ? _resp$find : resp.find(function (c) {
74
77
  return (c === null || c === void 0 ? void 0 : c.cabinet_id) === it.itemID;
75
78
  });
76
79
  if (picked) {
@@ -35,8 +35,8 @@ export function mapAddItemEvent(orgEvtPayload, state) {
35
35
  var cabinetDoorFinish = (_evtPayload3 = evtPayload) === null || _evtPayload3 === void 0 ? void 0 : _evtPayload3.ccdf;
36
36
  var assets3d = cabinetDoorFinish === null || cabinetDoorFinish === void 0 ? void 0 : cabinetDoorFinish.assets3d;
37
37
  if (isEmpty(assets3d)) {
38
- // nothing to map; keep event as-is
39
- return evtPayload;
38
+ var _evtPayload4;
39
+ tempStructure.base = (_evtPayload4 = evtPayload) === null || _evtPayload4 === void 0 ? void 0 : _evtPayload4.gltf;
40
40
  }
41
41
  if (!isEmpty(cabinetDoorFinish === null || cabinetDoorFinish === void 0 ? void 0 : cabinetDoorFinish.id)) {
42
42
  cabinetDoorFinishId = cabinetDoorFinish.id;
@@ -46,34 +46,36 @@ export function mapAddItemEvent(orgEvtPayload, state) {
46
46
  var updatedAssets3D = _toConsumableArray(assets3d);
47
47
 
48
48
  // first pass: inject door-handle assets where needed
49
- assets3d.forEach(function (asItem) {
50
- // make door handle
51
- if (!isEmpty(asItem === null || asItem === void 0 ? void 0 : asItem.placeholder_name)) {
52
- var phName = asItem.placeholder_name;
53
- if (phName.includes('door_')) {
54
- var doorHandleName = phName.slice(0, phName.length - 2) + '_handle' + phName.slice(phName.length - 2);
55
- updatedAssets3D.push({
56
- placeholder_name: doorHandleName,
57
- gltf: layer.get('doorHandle')
58
- });
49
+ if (!isEmpty(assets3d)) {
50
+ assets3d.forEach(function (asItem) {
51
+ // make door handle
52
+ if (!isEmpty(asItem === null || asItem === void 0 ? void 0 : asItem.placeholder_name)) {
53
+ var phName = asItem.placeholder_name;
54
+ if (phName.includes('door_')) {
55
+ var doorHandleName = phName.slice(0, phName.length - 2) + '_handle' + phName.slice(phName.length - 2);
56
+ updatedAssets3D.push({
57
+ placeholder_name: doorHandleName,
58
+ gltf: layer.get('doorHandle')
59
+ });
60
+ }
59
61
  }
60
- }
61
- });
62
+ });
62
63
 
63
- // second pass: build structure + placeholders from full asset list
64
- updatedAssets3D.forEach(function (asitem) {
65
- var _evtPayload4;
66
- // set base field with gltf
67
- tempStructure.base = (_evtPayload4 = evtPayload) === null || _evtPayload4 === void 0 ? void 0 : _evtPayload4.gltf;
68
- if (!isEmpty(asitem === null || asitem === void 0 ? void 0 : asitem.placeholder_name)) {
69
- // make the structure using placeholder_name and gltf
70
- var phName = asitem.placeholder_name;
71
- if (!phName.includes('_handle_') && !phName.includes('sink')) {
72
- phName = 'base_' + phName;
64
+ // second pass: build structure + placeholders from full asset list
65
+ updatedAssets3D.forEach(function (asitem) {
66
+ var _evtPayload5;
67
+ // set base field with gltf
68
+ tempStructure.base = (_evtPayload5 = evtPayload) === null || _evtPayload5 === void 0 ? void 0 : _evtPayload5.gltf;
69
+ if (!isEmpty(asitem === null || asitem === void 0 ? void 0 : asitem.placeholder_name)) {
70
+ // make the structure using placeholder_name and gltf
71
+ var phName = asitem.placeholder_name;
72
+ if (!phName.includes('_handle_') && !phName.includes('sink')) {
73
+ phName = 'base_' + phName;
74
+ }
75
+ tempStructure[phName] = asitem.gltf;
73
76
  }
74
- tempStructure[phName] = asitem.gltf;
75
- }
76
- });
77
+ });
78
+ }
77
79
 
78
80
  // make the tempPlaceholders using structure and id
79
81
  tempPlaceholders.push({
@@ -1,6 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import { isEmpty } from "../../../components/viewer2d/utils";
3
3
  import { toJSIfNeeded } from "../../../shared/objects/immutable";
4
+ import { normalizeLongName } from "../../../shared/domain/cabinet-identity";
4
5
  export function ccdfMapper(ccdf_list, layer) {
5
6
  // This function make cabinet definition using ccdf, layer's item information and catalog
6
7
  // console.log(ccdf_list, catalog);
@@ -20,10 +21,12 @@ export function ccdfMapper(ccdf_list, layer) {
20
21
  var itemKeys = Object.keys(layerJS.items);
21
22
  var correctItemId = '';
22
23
  for (var i = 0; i < itemKeys.length; i++) {
23
- if (layerJS.items[itemKeys[i]].itemID === ccdf.cabinet_id) correctItemId = layerJS.items[itemKeys[i]].id;
24
+ var it = layerJS.items[itemKeys[i]];
25
+ // Prefer stable join key: long_name. Fall back to cabinet_id.
26
+ if (!isEmpty(ccdf === null || ccdf === void 0 ? void 0 : ccdf.long_name) && !isEmpty(it === null || it === void 0 ? void 0 : it.long_name) && normalizeLongName(it.long_name) === normalizeLongName(ccdf.long_name) || it.itemID === ccdf.cabinet_id) correctItemId = layerJS.items[itemKeys[i]].id;
24
27
  }
25
28
  var cd = layerJS.items[correctItemId];
26
- if (cd.itemID === ccdf.cabinet_id) {
29
+ if (cd && (!isEmpty(ccdf === null || ccdf === void 0 ? void 0 : ccdf.long_name) && !isEmpty(cd === null || cd === void 0 ? void 0 : cd.long_name) && normalizeLongName(cd.long_name) === normalizeLongName(ccdf.long_name) || cd.itemID === ccdf.cabinet_id)) {
27
30
  if (!isEmpty(ccdf === null || ccdf === void 0 ? void 0 : ccdf.id)) {
28
31
  cdfId = ccdf.id;
29
32
  }
@@ -45,7 +48,7 @@ export function ccdfMapper(ccdf_list, layer) {
45
48
  });
46
49
  updatedAssets3D.forEach(function (asitem) {
47
50
  // set base field with gltf
48
- structure.base = cd.gltf;
51
+ structure.base = (ccdf === null || ccdf === void 0 ? void 0 : ccdf.gltf) || cd.gltf;
49
52
  if (!isEmpty(asitem === null || asitem === void 0 ? void 0 : asitem.placeholder_name)) {
50
53
  // make the structure using placeholder_name and gltf
51
54
  var phName = asitem.placeholder_name;
@@ -75,7 +78,9 @@ export function ccdfMapper(ccdf_list, layer) {
75
78
  prototype: cd.prototype,
76
79
  base: cd.base,
77
80
  shape_svg: cd.shape_svg,
78
- gltf: cd.gltf,
81
+ // If host provides cabinet base gltf/bin at CCDF top-level, prefer it.
82
+ gltf: (ccdf === null || ccdf === void 0 ? void 0 : ccdf.gltf) || cd.gltf,
83
+ bin: (ccdf === null || ccdf === void 0 ? void 0 : ccdf.bin) || (cd === null || cd === void 0 ? void 0 : cd.bin),
79
84
  structure_json: structure_json,
80
85
  layoutpos: cd.layoutpos,
81
86
  is_corner: cd.is_corner,
@@ -1,6 +1,11 @@
1
1
  import { isEmpty } from "../../../components/viewer2d/utils";
2
+ import { normalizeLongName } from "../../../shared/domain/cabinet-identity";
2
3
  export function mapFromCCDFToCDS(ccdf_list) {
4
+ var sceneItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
3
5
  // This function make CDS from CCDF_List
6
+ // `sceneItems` (optional) lets us map CCDF rows back onto placed scene items
7
+ // using stable identity (long_name), because host `cabinet_id` can vary per doorstyle.
8
+ var itemsArray = sceneItems ? Array.isArray(sceneItems) ? sceneItems : Object.values(sceneItems) : null;
4
9
  var itemCDSList = [];
5
10
  ccdf_list === null || ccdf_list === void 0 || ccdf_list.forEach(function (asItem) {
6
11
  // IMPORTANT: DIY-834-43
@@ -24,8 +29,21 @@ export function mapFromCCDFToCDS(ccdf_list) {
24
29
  });
25
30
  var data = [];
26
31
  data.push(itemCDSData);
32
+
33
+ // Prefer stable join key: long_name -> scene item's itemID.
34
+ // Fall back to host cabinet_id for backward compatibility.
35
+ var resolvedItemID = asItem === null || asItem === void 0 ? void 0 : asItem.cabinet_id;
36
+ var ln = asItem === null || asItem === void 0 ? void 0 : asItem.long_name;
37
+ if (itemsArray && !isEmpty(ln)) {
38
+ var nl = normalizeLongName(ln);
39
+ var match = itemsArray.find(function (it) {
40
+ return normalizeLongName(it === null || it === void 0 ? void 0 : it.long_name) === nl;
41
+ });
42
+ if (match !== null && match !== void 0 && match.itemID) resolvedItemID = match.itemID;
43
+ }
27
44
  itemCDSList.push({
28
- itemID: asItem.cabinet_id,
45
+ itemID: resolvedItemID,
46
+ long_name: asItem === null || asItem === void 0 ? void 0 : asItem.long_name,
29
47
  data: data,
30
48
  cabinet_door_style_id: cabitnetDoorStyleId
31
49
  });
@@ -0,0 +1,6 @@
1
+ // Domain utilities for identifying cabinets across backend responses and scene state.
2
+ // We normalize `long_name` because it is the stable identity across door-style changes.
3
+
4
+ export function normalizeLongName(value) {
5
+ return (value !== null && value !== void 0 ? value : '').toString().trim().toLowerCase();
6
+ }
package/lib/class/item.js CHANGED
@@ -20,6 +20,7 @@ var _molding = require("../utils/molding");
20
20
  var _utils = require("../components/viewer2d/utils");
21
21
  var _history = require("../utils/history");
22
22
  var _immutable2 = require("../shared/objects/immutable");
23
+ var _cabinetIdentity = require("../shared/domain/cabinet-identity");
23
24
  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; }
24
25
  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) { (0, _defineProperty2["default"])(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; }
25
26
  var allItemRect;
@@ -275,10 +276,14 @@ var Item = exports["default"] = /*#__PURE__*/function () {
275
276
  idSet = new Set(targetItemIDs);
276
277
  }
277
278
  layer.items.forEach(function (it) {
278
- var _idSet, _picked$door_finish_i;
279
+ var _idSet, _ccdf_list$find, _picked$door_finish_i;
279
280
  var should = applyScope === _constants.DOORSTYLE_SCOPE_ALL ? true : (_idSet = idSet) === null || _idSet === void 0 ? void 0 : _idSet.has(it.id);
280
281
  if (!should) return;
281
- var picked = ccdf_list.find(function (c) {
282
+
283
+ // Prefer stable join key: long_name. Fall back to cabinet_id for older payloads.
284
+ var picked = (_ccdf_list$find = ccdf_list.find(function (c) {
285
+ return (c === null || c === void 0 ? void 0 : c.long_name) && (it === null || it === void 0 ? void 0 : it.long_name) && (0, _cabinetIdentity.normalizeLongName)(c.long_name) === (0, _cabinetIdentity.normalizeLongName)(it.long_name);
286
+ })) !== null && _ccdf_list$find !== void 0 ? _ccdf_list$find : ccdf_list.find(function (c) {
282
287
  return (c === null || c === void 0 ? void 0 : c.cabinet_id) === it.itemID;
283
288
  });
284
289
  if (!picked) return;
@@ -9,7 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _immutable = require("immutable");
10
10
  var _reactContainerDimensions = _interopRequireDefault(require("react-container-dimensions"));
11
11
  var _projectItemsCatalog = _interopRequireDefault(require("./mocks/projectItemsCatalog.json"));
12
- var _mockProps = _interopRequireDefault(require("./mocks/mockProps.json"));
12
+ var _configData = _interopRequireDefault(require("./mocks/configData.json"));
13
+ var _project = _interopRequireDefault(require("./mocks/project.json"));
13
14
  var _cabinetPayload = _interopRequireDefault(require("./mocks/cabinetPayload.json"));
14
15
  var _appliancePayload = _interopRequireDefault(require("./mocks/appliancePayload.json"));
15
16
  var _doorStylePayload = _interopRequireDefault(require("./mocks/doorStylePayload.json"));
@@ -83,7 +84,7 @@ function WorkSpace(props) {
83
84
  var evt = {
84
85
  type: _constants.EXTERNAL_EVENT_LOAD_PROJECT,
85
86
  // send request for sync scene data to 3DTool
86
- payload: _mockProps["default"].projectElement[0].project_data
87
+ payload: _project["default"]
87
88
  };
88
89
  setExternalEvent(evt);
89
90
  }
@@ -873,7 +874,7 @@ function WorkSpace(props) {
873
874
  }, "Setting-MeasurementUnit-'mm'")), /*#__PURE__*/_react["default"].createElement(_LiteRenderer["default"], {
874
875
  width: props.width,
875
876
  height: props.height,
876
- configData: _mockProps["default"].configData,
877
+ configData: _configData["default"],
877
878
  options: options,
878
879
  logoImg: "/assets/logo.png",
879
880
  companyUrl: "https://example.com",
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.handleChangeDoorStyleEvent = handleChangeDoorStyleEvent;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- 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; }
12
- 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) { (0, _defineProperty2["default"])(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; }
13
10
  function handleChangeDoorStyleEvent(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x0, _x1, _x10) {
14
11
  return _handleChangeDoorStyleEvent.apply(this, arguments);
15
12
  }
@@ -58,12 +55,12 @@ function _handleChangeDoorStyleEvent() {
58
55
  if (!ccdf_list.some(function (v) {
59
56
  return item.itemID === v.itemID && item.name === v.name && doorStyle.id === v.doorFinishId;
60
57
  })) {
61
- ccdf_list.push(_objectSpread(_objectSpread({}, item), {}, {
58
+ ccdf_list.push({
62
59
  cabinetSku: item.type,
63
60
  sizeInfo: item.sizeinfo,
64
61
  catalogSku: item.sku_number,
65
62
  ccdf: item.ccdf
66
- }));
63
+ });
67
64
  }
68
65
  case 1:
69
66
  case "end":
@@ -99,7 +96,9 @@ function _handleChangeDoorStyleEvent() {
99
96
  return _regenerator["default"].wrap(function (_context) {
100
97
  while (1) switch (_context.prev = _context.next) {
101
98
  case 0:
102
- itemCDS = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list);
99
+ // Map CCDF rows back to placed items using stable identity (long_name),
100
+ // because host `cabinet_id` can vary by doorstyle.
101
+ itemCDS = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list, targetItems);
103
102
  mappedCabinetDefinitionList = ccdfMapper(result.ccdf_list, layer); // result: ccdf_list
104
103
  rt = mergeSameElements(mappedCabinetDefinitionList);
105
104
  _i = 0;
@@ -11,6 +11,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
11
11
  var _convertUnitsLite = require("../../utils/convert-units-lite");
12
12
  var _constants = require("../../constants");
13
13
  var _models = require("../../models");
14
+ var _cabinetIdentity = require("../../shared/domain/cabinet-identity");
14
15
  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; }
15
16
  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) { (0, _defineProperty2["default"])(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; }
16
17
  function handleLoadProjectEvent(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
@@ -39,8 +40,8 @@ function _handleLoadProjectEvent() {
39
40
  var _it$doorStyle;
40
41
  return it.itemID === v.itemID && it.name === v.name && ((_it$doorStyle = it.doorStyle) === null || _it$doorStyle === void 0 ? void 0 : _it$doorStyle.id) === v.doorFinishId;
41
42
  })) ccdf_list.push({
42
- cabinetSku: it.sku,
43
- sizeInfo: it.sizeInfo,
43
+ cabinetSku: it.type,
44
+ sizeInfo: it.sizeinfo,
44
45
  catalogSku: it.sku_number,
45
46
  ccdf: it.ccdf
46
47
  });
@@ -63,7 +64,7 @@ function _handleLoadProjectEvent() {
63
64
  return _regenerator["default"].wrap(function (_context) {
64
65
  while (1) switch (_context.prev = _context.next) {
65
66
  case 0:
66
- cdsList = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list);
67
+ cdsList = mapFromCCDFToCDS(result === null || result === void 0 ? void 0 : result.ccdf_list, items);
67
68
  evt.payload = updateProjectWithCDSList(evt.payload, cdsList);
68
69
 
69
70
  // Attach matched ccdf to each scene instance before loading into state,
@@ -73,11 +74,13 @@ function _handleLoadProjectEvent() {
73
74
  try {
74
75
  resp = (_result$ccdf_list = result === null || result === void 0 ? void 0 : result.ccdf_list) !== null && _result$ccdf_list !== void 0 ? _result$ccdf_list : [];
75
76
  Object.keys(items).forEach(function (k) {
76
- var _it$doorStyle$id, _it$doorStyle2;
77
+ var _it$doorStyle$id, _it$doorStyle2, _resp$find;
77
78
  var it = items[k];
78
79
  var desiredDoorFinishId = (_it$doorStyle$id = it === null || it === void 0 || (_it$doorStyle2 = it.doorStyle) === null || _it$doorStyle2 === void 0 ? void 0 : _it$doorStyle2.id) !== null && _it$doorStyle$id !== void 0 ? _it$doorStyle$id : null;
79
80
  if (!desiredDoorFinishId) return;
80
- var picked = resp.find(function (c) {
81
+ var picked = (_resp$find = resp.find(function (c) {
82
+ return (c === null || c === void 0 ? void 0 : c.long_name) && (it === null || it === void 0 ? void 0 : it.long_name) && (0, _cabinetIdentity.normalizeLongName)(c.long_name) === (0, _cabinetIdentity.normalizeLongName)(it.long_name);
83
+ })) !== null && _resp$find !== void 0 ? _resp$find : resp.find(function (c) {
81
84
  return (c === null || c === void 0 ? void 0 : c.cabinet_id) === it.itemID;
82
85
  });
83
86
  if (picked) {
@@ -41,8 +41,8 @@ function mapAddItemEvent(orgEvtPayload, state) {
41
41
  var cabinetDoorFinish = (_evtPayload3 = evtPayload) === null || _evtPayload3 === void 0 ? void 0 : _evtPayload3.ccdf;
42
42
  var assets3d = cabinetDoorFinish === null || cabinetDoorFinish === void 0 ? void 0 : cabinetDoorFinish.assets3d;
43
43
  if ((0, _helper.isEmpty)(assets3d)) {
44
- // nothing to map; keep event as-is
45
- return evtPayload;
44
+ var _evtPayload4;
45
+ tempStructure.base = (_evtPayload4 = evtPayload) === null || _evtPayload4 === void 0 ? void 0 : _evtPayload4.gltf;
46
46
  }
47
47
  if (!(0, _helper.isEmpty)(cabinetDoorFinish === null || cabinetDoorFinish === void 0 ? void 0 : cabinetDoorFinish.id)) {
48
48
  cabinetDoorFinishId = cabinetDoorFinish.id;
@@ -52,34 +52,36 @@ function mapAddItemEvent(orgEvtPayload, state) {
52
52
  var updatedAssets3D = (0, _toConsumableArray2["default"])(assets3d);
53
53
 
54
54
  // first pass: inject door-handle assets where needed
55
- assets3d.forEach(function (asItem) {
56
- // make door handle
57
- if (!(0, _helper.isEmpty)(asItem === null || asItem === void 0 ? void 0 : asItem.placeholder_name)) {
58
- var phName = asItem.placeholder_name;
59
- if (phName.includes('door_')) {
60
- var doorHandleName = phName.slice(0, phName.length - 2) + '_handle' + phName.slice(phName.length - 2);
61
- updatedAssets3D.push({
62
- placeholder_name: doorHandleName,
63
- gltf: layer.get('doorHandle')
64
- });
55
+ if (!(0, _helper.isEmpty)(assets3d)) {
56
+ assets3d.forEach(function (asItem) {
57
+ // make door handle
58
+ if (!(0, _helper.isEmpty)(asItem === null || asItem === void 0 ? void 0 : asItem.placeholder_name)) {
59
+ var phName = asItem.placeholder_name;
60
+ if (phName.includes('door_')) {
61
+ var doorHandleName = phName.slice(0, phName.length - 2) + '_handle' + phName.slice(phName.length - 2);
62
+ updatedAssets3D.push({
63
+ placeholder_name: doorHandleName,
64
+ gltf: layer.get('doorHandle')
65
+ });
66
+ }
65
67
  }
66
- }
67
- });
68
+ });
68
69
 
69
- // second pass: build structure + placeholders from full asset list
70
- updatedAssets3D.forEach(function (asitem) {
71
- var _evtPayload4;
72
- // set base field with gltf
73
- tempStructure.base = (_evtPayload4 = evtPayload) === null || _evtPayload4 === void 0 ? void 0 : _evtPayload4.gltf;
74
- if (!(0, _helper.isEmpty)(asitem === null || asitem === void 0 ? void 0 : asitem.placeholder_name)) {
75
- // make the structure using placeholder_name and gltf
76
- var phName = asitem.placeholder_name;
77
- if (!phName.includes('_handle_') && !phName.includes('sink')) {
78
- phName = 'base_' + phName;
70
+ // second pass: build structure + placeholders from full asset list
71
+ updatedAssets3D.forEach(function (asitem) {
72
+ var _evtPayload5;
73
+ // set base field with gltf
74
+ tempStructure.base = (_evtPayload5 = evtPayload) === null || _evtPayload5 === void 0 ? void 0 : _evtPayload5.gltf;
75
+ if (!(0, _helper.isEmpty)(asitem === null || asitem === void 0 ? void 0 : asitem.placeholder_name)) {
76
+ // make the structure using placeholder_name and gltf
77
+ var phName = asitem.placeholder_name;
78
+ if (!phName.includes('_handle_') && !phName.includes('sink')) {
79
+ phName = 'base_' + phName;
80
+ }
81
+ tempStructure[phName] = asitem.gltf;
79
82
  }
80
- tempStructure[phName] = asitem.gltf;
81
- }
82
- });
83
+ });
84
+ }
83
85
 
84
86
  // make the tempPlaceholders using structure and id
85
87
  tempPlaceholders.push({
@@ -8,6 +8,7 @@ exports.ccdfMapper = ccdfMapper;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _utils = require("../../../components/viewer2d/utils");
10
10
  var _immutable = require("../../../shared/objects/immutable");
11
+ var _cabinetIdentity = require("../../../shared/domain/cabinet-identity");
11
12
  function ccdfMapper(ccdf_list, layer) {
12
13
  // This function make cabinet definition using ccdf, layer's item information and catalog
13
14
  // console.log(ccdf_list, catalog);
@@ -27,10 +28,12 @@ function ccdfMapper(ccdf_list, layer) {
27
28
  var itemKeys = Object.keys(layerJS.items);
28
29
  var correctItemId = '';
29
30
  for (var i = 0; i < itemKeys.length; i++) {
30
- if (layerJS.items[itemKeys[i]].itemID === ccdf.cabinet_id) correctItemId = layerJS.items[itemKeys[i]].id;
31
+ var it = layerJS.items[itemKeys[i]];
32
+ // Prefer stable join key: long_name. Fall back to cabinet_id.
33
+ if (!(0, _utils.isEmpty)(ccdf === null || ccdf === void 0 ? void 0 : ccdf.long_name) && !(0, _utils.isEmpty)(it === null || it === void 0 ? void 0 : it.long_name) && (0, _cabinetIdentity.normalizeLongName)(it.long_name) === (0, _cabinetIdentity.normalizeLongName)(ccdf.long_name) || it.itemID === ccdf.cabinet_id) correctItemId = layerJS.items[itemKeys[i]].id;
31
34
  }
32
35
  var cd = layerJS.items[correctItemId];
33
- if (cd.itemID === ccdf.cabinet_id) {
36
+ if (cd && (!(0, _utils.isEmpty)(ccdf === null || ccdf === void 0 ? void 0 : ccdf.long_name) && !(0, _utils.isEmpty)(cd === null || cd === void 0 ? void 0 : cd.long_name) && (0, _cabinetIdentity.normalizeLongName)(cd.long_name) === (0, _cabinetIdentity.normalizeLongName)(ccdf.long_name) || cd.itemID === ccdf.cabinet_id)) {
34
37
  if (!(0, _utils.isEmpty)(ccdf === null || ccdf === void 0 ? void 0 : ccdf.id)) {
35
38
  cdfId = ccdf.id;
36
39
  }
@@ -52,7 +55,7 @@ function ccdfMapper(ccdf_list, layer) {
52
55
  });
53
56
  updatedAssets3D.forEach(function (asitem) {
54
57
  // set base field with gltf
55
- structure.base = cd.gltf;
58
+ structure.base = (ccdf === null || ccdf === void 0 ? void 0 : ccdf.gltf) || cd.gltf;
56
59
  if (!(0, _utils.isEmpty)(asitem === null || asitem === void 0 ? void 0 : asitem.placeholder_name)) {
57
60
  // make the structure using placeholder_name and gltf
58
61
  var phName = asitem.placeholder_name;
@@ -82,7 +85,9 @@ function ccdfMapper(ccdf_list, layer) {
82
85
  prototype: cd.prototype,
83
86
  base: cd.base,
84
87
  shape_svg: cd.shape_svg,
85
- gltf: cd.gltf,
88
+ // If host provides cabinet base gltf/bin at CCDF top-level, prefer it.
89
+ gltf: (ccdf === null || ccdf === void 0 ? void 0 : ccdf.gltf) || cd.gltf,
90
+ bin: (ccdf === null || ccdf === void 0 ? void 0 : ccdf.bin) || (cd === null || cd === void 0 ? void 0 : cd.bin),
86
91
  structure_json: structure_json,
87
92
  layoutpos: cd.layoutpos,
88
93
  is_corner: cd.is_corner,
@@ -5,8 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.mapFromCCDFToCDS = mapFromCCDFToCDS;
7
7
  var _utils = require("../../../components/viewer2d/utils");
8
+ var _cabinetIdentity = require("../../../shared/domain/cabinet-identity");
8
9
  function mapFromCCDFToCDS(ccdf_list) {
10
+ var sceneItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
9
11
  // This function make CDS from CCDF_List
12
+ // `sceneItems` (optional) lets us map CCDF rows back onto placed scene items
13
+ // using stable identity (long_name), because host `cabinet_id` can vary per doorstyle.
14
+ var itemsArray = sceneItems ? Array.isArray(sceneItems) ? sceneItems : Object.values(sceneItems) : null;
10
15
  var itemCDSList = [];
11
16
  ccdf_list === null || ccdf_list === void 0 || ccdf_list.forEach(function (asItem) {
12
17
  // IMPORTANT: DIY-834-43
@@ -30,8 +35,21 @@ function mapFromCCDFToCDS(ccdf_list) {
30
35
  });
31
36
  var data = [];
32
37
  data.push(itemCDSData);
38
+
39
+ // Prefer stable join key: long_name -> scene item's itemID.
40
+ // Fall back to host cabinet_id for backward compatibility.
41
+ var resolvedItemID = asItem === null || asItem === void 0 ? void 0 : asItem.cabinet_id;
42
+ var ln = asItem === null || asItem === void 0 ? void 0 : asItem.long_name;
43
+ if (itemsArray && !(0, _utils.isEmpty)(ln)) {
44
+ var nl = (0, _cabinetIdentity.normalizeLongName)(ln);
45
+ var match = itemsArray.find(function (it) {
46
+ return (0, _cabinetIdentity.normalizeLongName)(it === null || it === void 0 ? void 0 : it.long_name) === nl;
47
+ });
48
+ if (match !== null && match !== void 0 && match.itemID) resolvedItemID = match.itemID;
49
+ }
33
50
  itemCDSList.push({
34
- itemID: asItem.cabinet_id,
51
+ itemID: resolvedItemID,
52
+ long_name: asItem === null || asItem === void 0 ? void 0 : asItem.long_name,
35
53
  data: data,
36
54
  cabinet_door_style_id: cabitnetDoorStyleId
37
55
  });
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeLongName = normalizeLongName;
7
+ // Domain utilities for identifying cabinets across backend responses and scene state.
8
+ // We normalize `long_name` because it is the stable identity across door-style changes.
9
+
10
+ function normalizeLongName(value) {
11
+ return (value !== null && value !== void 0 ? value : '').toString().trim().toLowerCase();
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "10.0.10",
3
+ "version": "10.1.0",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",