zakeke-configurator-react 0.1.366 → 0.1.367

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.
@@ -1,5 +1,6 @@
1
1
  /// <reference path="../../../../../../../typescript_definitions/declarations/All.d.ts" />
2
2
  import { FocusAttributesEventListener } from '@zakeke/zakeke-3d-core';
3
+ import _ from 'lodash';
3
4
  import { EventMessage, ExtensionFields, NftForm, NftSettings, OnBeforeSendDataToParent, SceneAnimationsConfig, TryOnMode, TryOnProvidersTypesMapping, VisibleEventMessage } from '.';
4
5
  import { PlatformAttributeSelection } from './integrations/Integration';
5
6
  import { BootParameters, Camera, Composition, FontFamily, Group, ImageMacroCategory, Item, Product, ProductQuantityRule, SellerSettings, Settings, Template, TemplateMacroCategory, TryOnGenericFineTuningSettings, TryOnProduct, TryOnSeller, AIPresetCategory, AIPreset, AIProductStagingRule, AIProductStagingOptions, AIProductStagingResult, AIVirtualTryOnOptions, AIVirtualTryOnResult, AIVirtualModelRule } from './models';
@@ -203,6 +204,7 @@ export declare class ZakekeEnvironment {
203
204
  size: number;
204
205
  }) => void;
205
206
  renderDesign: () => Promise<void>;
207
+ debouncedRefresh: _.DebouncedFunc<() => Promise<void>>;
206
208
  private debouncedChange;
207
209
  restoreLastCameraLocation: () => void;
208
210
  private buildRecapProps;
@@ -1,24 +1,24 @@
1
- import { Item } from "..";
2
- import { DesignPriceCalculatorRuleBased } from "../../../../libs/pricingRuleBase/DesignPriceCalculatorRuleBased";
3
- export declare class PlatformAttributeSelection {
4
- attributeCode: string;
5
- optionCode: string;
6
- attributeLabel: string;
7
- optionLabel: string;
8
- attributeIsEnabled: boolean;
9
- optionIsEnabled: boolean;
10
- constructor(attributeCode: string, optionCode: string, attributeLabel: string, optionLabel: string, attributeIsEnabled: boolean, optionIsEnabled: boolean);
11
- }
12
- export interface Integration {
13
- addToCart(composition: any, design: any, model: any, attributes: PlatformAttributeSelection[], designItems: Item[], quantity: number, additionalProperties: Record<string, any>, shopifyNFTPrice: number): void;
14
- getPrice(composition: any, design: any, model: any, attributes: PlatformAttributeSelection[], compositionPrice: number, isCustomPricingConfiguratorEnabled: boolean, isCustomPricingRuleBasedEnabled: boolean, quantity: number, shopifyNFTPrice: number): Promise<number | {
15
- price: number;
16
- isOutOfStock: boolean;
17
- }>;
18
- getSharedCompositionUrl(compositionDocID: string): Promise<{
19
- url: string;
20
- }>;
21
- setPricingCalculator(pricingCalculator: DesignPriceCalculatorRuleBased): void;
22
- close(): void;
23
- setPricingCalculator(pricingCalculator: DesignPriceCalculatorRuleBased): void;
24
- }
1
+ import { Item } from "..";
2
+ import { DesignPriceCalculatorRuleBased } from "../../../../libs/pricingRuleBase/DesignPriceCalculatorRuleBased";
3
+ export declare class PlatformAttributeSelection {
4
+ attributeCode: string;
5
+ optionCode: string;
6
+ attributeLabel: string;
7
+ optionLabel: string;
8
+ attributeIsEnabled: boolean;
9
+ optionIsEnabled: boolean;
10
+ constructor(attributeCode: string, optionCode: string, attributeLabel: string, optionLabel: string, attributeIsEnabled: boolean, optionIsEnabled: boolean);
11
+ }
12
+ export interface Integration {
13
+ addToCart(composition: any, design: any, model: any, attributes: PlatformAttributeSelection[], designItems: Item[], quantity: number, additionalProperties: Record<string, any>, shopifyNFTPrice: number): void;
14
+ getPrice(composition: any, design: any, model: any, attributes: PlatformAttributeSelection[], compositionPrice: number, isCustomPricingConfiguratorEnabled: boolean, isCustomPricingRuleBasedEnabled: boolean, quantity: number, shopifyNFTPrice: number): Promise<number | {
15
+ price: number;
16
+ isOutOfStock: boolean;
17
+ }>;
18
+ getSharedCompositionUrl(compositionDocID: string): Promise<{
19
+ url: string;
20
+ }>;
21
+ setPricingCalculator(pricingCalculator: DesignPriceCalculatorRuleBased): void;
22
+ close(): void;
23
+ setPricingCalculator(pricingCalculator: DesignPriceCalculatorRuleBased): void;
24
+ }
@@ -1,16 +1,16 @@
1
- import { DesignPriceCalculatorRuleBased } from '../../../../libs/pricingRuleBase/DesignPriceCalculatorRuleBased';
2
- import { Item } from '../models';
3
- import { Integration, PlatformAttributeSelection } from './Integration';
4
- export default class MerchantIntegrationGeneric implements Integration {
5
- private readonly callbacks;
6
- private messageIds;
7
- private pricingCalculator;
8
- constructor();
9
- addToCart(composition: any, design: any, model: any, attributes: PlatformAttributeSelection[], designItems: Item[], quantity: number, additionalProperties: any, shopifyNFTPrice: number): void;
10
- getPrice(composition: any, design: any, model: any, attributes: any, compositionPrice: any, isCustomPricingConfiguratorEnabled: any, isCustomPricingRuleBasedEnabled: any, quantity: number): Promise<number>;
11
- getSharedCompositionUrl(compositionDocID: string): Promise<{
12
- url: string;
13
- }>;
14
- close(): void;
15
- setPricingCalculator(pricingCalculator: DesignPriceCalculatorRuleBased): void;
16
- }
1
+ import { DesignPriceCalculatorRuleBased } from '../../../../libs/pricingRuleBase/DesignPriceCalculatorRuleBased';
2
+ import { Item } from '../models';
3
+ import { Integration, PlatformAttributeSelection } from './Integration';
4
+ export default class MerchantIntegrationGeneric implements Integration {
5
+ private readonly callbacks;
6
+ private messageIds;
7
+ private pricingCalculator;
8
+ constructor();
9
+ addToCart(composition: any, design: any, model: any, attributes: PlatformAttributeSelection[], designItems: Item[], quantity: number, additionalProperties: any, shopifyNFTPrice: number): void;
10
+ getPrice(composition: any, design: any, model: any, attributes: any, compositionPrice: any, isCustomPricingConfiguratorEnabled: any, isCustomPricingRuleBasedEnabled: any, quantity: number): Promise<number>;
11
+ getSharedCompositionUrl(compositionDocID: string): Promise<{
12
+ url: string;
13
+ }>;
14
+ close(): void;
15
+ setPricingCalculator(pricingCalculator: DesignPriceCalculatorRuleBased): void;
16
+ }
package/dist/index.js CHANGED
@@ -21648,6 +21648,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
21648
21648
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21649
21649
  /// <reference path="../../../typescript_definitions/declarations/All.d.ts" />
21650
21650
 
21651
+ console.log('[MODULE BUILD MARKER] v=debouncedRefresh-50ms-diagnostic-2');
21651
21652
 
21652
21653
 
21653
21654
 
@@ -22942,6 +22943,13 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
22942
22943
  }
22943
22944
  }, _callee18);
22944
22945
  })));
22946
+ // Debounced 2D texture refresh. Replaces the 3D-core-side item listeners
22947
+ // (MeshDesignManager addItem*/addImageLoaded) that were disabled because they
22948
+ // updated too aggressively. Call after any 2D item mutation in this class so
22949
+ // rapid bursts (drag color picker, typing in text, batch ops) coalesce into one refresh.
22950
+ _defineProperty(this, "debouncedRefresh", (0,lodash__WEBPACK_IMPORTED_MODULE_1__.debounce)(function () {
22951
+ return _this.renderDesign();
22952
+ }, 50));
22945
22953
  _defineProperty(this, "debouncedChange", (0,lodash__WEBPACK_IMPORTED_MODULE_1__.debounce)(function () {
22946
22954
  return _this.trigger('change');
22947
22955
  }, 300));
@@ -24895,7 +24903,11 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
24895
24903
  case 0:
24896
24904
  return _context51.abrupt("return", new Promise(function (resolve, reject) {
24897
24905
  if (_this.viewer) {
24906
+ console.log('[environment.removeItem] CALLED', {
24907
+ guid: guid
24908
+ });
24898
24909
  _this.viewer.removeDesignItem(guid, _this.visibleCustomizer);
24910
+ _this.debouncedRefresh();
24899
24911
  _this.fireItemsChange();
24900
24912
  resolve();
24901
24913
  } else {
@@ -24915,12 +24927,14 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
24915
24927
  _defineProperty(this, "moveItemUp", function (guid) {
24916
24928
  if (_this.viewer) {
24917
24929
  _this.viewer.moveDesignItemUp(guid, _this.visibleCustomizer);
24930
+ _this.debouncedRefresh();
24918
24931
  _this.fireItemsChange();
24919
24932
  } else throw 'Called move item up but no viewer or viewer not ready';
24920
24933
  });
24921
24934
  _defineProperty(this, "moveItemDown", function (guid) {
24922
24935
  if (_this.viewer) {
24923
24936
  _this.viewer.moveDesignItemDown(guid, _this.visibleCustomizer);
24937
+ _this.debouncedRefresh();
24924
24938
  _this.fireItemsChange();
24925
24939
  } else throw 'Called move item down but no viewer or viewer not ready';
24926
24940
  });
@@ -24931,6 +24945,7 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
24931
24945
  var sanitizedText = (0,_helpers__WEBPACK_IMPORTED_MODULE_8__.sanitizeTextFromUnsupportedAndEmojiCharacters)(item, text, _this.fonts);
24932
24946
  if (_this.viewer) {
24933
24947
  _this.viewer.setDesignItemText(guid, sanitizedText, _this.visibleCustomizer);
24948
+ _this.debouncedRefresh();
24934
24949
  } else throw 'Called set item text but no viewer or viewer not ready';
24935
24950
  return sanitizedText;
24936
24951
  });
@@ -24948,6 +24963,7 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
24948
24963
  }
24949
24964
  if (font) {
24950
24965
  _this.updateFontWeightForTextItem(guid, font, undefined, italic);
24966
+ _this.debouncedRefresh();
24951
24967
  }
24952
24968
  } else throw 'Called set item italic but no viewer or viewer not ready';
24953
24969
  });
@@ -24965,12 +24981,14 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
24965
24981
  }
24966
24982
  if (font) {
24967
24983
  _this.updateFontWeightForTextItem(guid, font, bold, undefined);
24984
+ _this.debouncedRefresh();
24968
24985
  }
24969
24986
  } else throw 'Called set item bold but no viewer or viewer not ready';
24970
24987
  });
24971
24988
  _defineProperty(this, "setItemColor", function (guid, color) {
24972
24989
  if (_this.viewer) {
24973
24990
  _this.viewer.setDesignItemColor(guid, color, _this.visibleCustomizer);
24991
+ _this.debouncedRefresh();
24974
24992
  } else throw 'Called set item color but no viewer or viewer not ready';
24975
24993
  });
24976
24994
  _defineProperty(this, "setItemFontFamily", /*#__PURE__*/function () {
@@ -24980,14 +24998,14 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
24980
24998
  while (1) switch (_context52.prev = _context52.next) {
24981
24999
  case 0:
24982
25000
  if (!_this.viewer) {
24983
- _context52.next = 21;
25001
+ _context52.next = 22;
24984
25002
  break;
24985
25003
  }
24986
25004
  font = _this.fonts.find(function (x) {
24987
25005
  return x.name === fontFamily;
24988
25006
  });
24989
25007
  if (!font) {
24990
- _context52.next = 19;
25008
+ _context52.next = 20;
24991
25009
  break;
24992
25010
  }
24993
25011
  // IMPORTANT: Read current styles BEFORE changing the font
@@ -25034,13 +25052,14 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25034
25052
  _this.viewer.setDesignItemItalic(guid, false, font, _this.visibleCustomizer);
25035
25053
  }
25036
25054
  }
25055
+ _this.debouncedRefresh();
25037
25056
  _this.fireItemsChange();
25038
- case 19:
25039
- _context52.next = 22;
25057
+ case 20:
25058
+ _context52.next = 23;
25040
25059
  break;
25041
- case 21:
25042
- throw 'Called set item font family but no viewer or viewer not ready';
25043
25060
  case 22:
25061
+ throw 'Called set item font family but no viewer or viewer not ready';
25062
+ case 23:
25044
25063
  case "end":
25045
25064
  return _context52.stop();
25046
25065
  }
@@ -25053,6 +25072,7 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25053
25072
  _defineProperty(this, "setItemTextOnPath", function (guid, areaId, value) {
25054
25073
  if (_this.viewer) {
25055
25074
  _this.viewer.setItemTextOnPath(guid, areaId, value, _this.visibleCustomizer);
25075
+ _this.debouncedRefresh();
25056
25076
  _this.fireItemsChange();
25057
25077
  } else throw 'Called toggleItemTextOnPath but no viewer or viewer not ready';
25058
25078
  });
@@ -25138,21 +25158,19 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25138
25158
  while (1) switch (_context55.prev = _context55.next) {
25139
25159
  case 0:
25140
25160
  if (!_this.viewer) {
25141
- _context55.next = 10;
25161
+ _context55.next = 9;
25142
25162
  break;
25143
25163
  }
25144
25164
  _context55.next = 3;
25145
25165
  return _this.viewer.addDesignItemImage(id, areaId, _this.visibleCustomizer);
25146
25166
  case 3:
25147
25167
  guid = _context55.sent;
25148
- _context55.next = 6;
25149
- return _this.renderDesign();
25150
- case 6:
25168
+ _this.debouncedRefresh();
25151
25169
  _this.fireItemsChange();
25152
25170
  return _context55.abrupt("return", guid);
25153
- case 10:
25171
+ case 9:
25154
25172
  throw 'Called add item text but no viewer or viewer not ready';
25155
- case 11:
25173
+ case 10:
25156
25174
  case "end":
25157
25175
  return _context55.stop();
25158
25176
  }
@@ -25202,7 +25220,7 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25202
25220
  while (1) switch (_context57.prev = _context57.next) {
25203
25221
  case 0:
25204
25222
  if (!_this.viewer) {
25205
- _context57.next = 9;
25223
+ _context57.next = 10;
25206
25224
  break;
25207
25225
  }
25208
25226
  image = new MPlaza.Image();
@@ -25211,12 +25229,13 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25211
25229
  _context57.next = 6;
25212
25230
  return _this.viewer.setDesignItemImage(guid, image, _this.visibleCustomizer);
25213
25231
  case 6:
25232
+ _this.debouncedRefresh();
25214
25233
  _this.fireItemsChange();
25215
- _context57.next = 10;
25234
+ _context57.next = 11;
25216
25235
  break;
25217
- case 9:
25218
- throw 'Called set item image but no viewer or viewer not ready';
25219
25236
  case 10:
25237
+ throw 'Called set item image but no viewer or viewer not ready';
25238
+ case 11:
25220
25239
  case "end":
25221
25240
  return _context57.stop();
25222
25241
  }
@@ -25252,9 +25271,10 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25252
25271
  _context58.next = 2;
25253
25272
  return _this.viewer.setDesignItemImage(guid, image, _this.visibleCustomizer);
25254
25273
  case 2:
25274
+ _this.debouncedRefresh();
25255
25275
  _this.fireItemsChange();
25256
25276
  resolve();
25257
- case 4:
25277
+ case 5:
25258
25278
  case "end":
25259
25279
  return _context58.stop();
25260
25280
  }
@@ -25299,18 +25319,16 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25299
25319
  while (1) switch (_context61.prev = _context61.next) {
25300
25320
  case 0:
25301
25321
  if (!_this.viewer) {
25302
- _context61.next = 7;
25322
+ _context61.next = 6;
25303
25323
  break;
25304
25324
  }
25305
25325
  _context61.next = 3;
25306
25326
  return _this.viewer.setDesignItemSize(guid, width, height, _this.visibleCustomizer);
25307
25327
  case 3:
25308
25328
  console.log('finished item size');
25309
- _context61.next = 6;
25310
- return _this.renderDesign();
25311
- case 6:
25329
+ _this.debouncedRefresh();
25312
25330
  _this.fireItemsChange();
25313
- case 7:
25331
+ case 6:
25314
25332
  case "end":
25315
25333
  return _context61.stop();
25316
25334
  }
@@ -25325,16 +25343,12 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
25325
25343
  return _regeneratorRuntime().wrap(function _callee61$(_context62) {
25326
25344
  while (1) switch (_context62.prev = _context62.next) {
25327
25345
  case 0:
25328
- if (!_this.viewer) {
25329
- _context62.next = 5;
25330
- break;
25346
+ if (_this.viewer) {
25347
+ _this.viewer.setDesignItemConstraints(guid, constraints, _this.visibleCustomizer);
25348
+ _this.debouncedRefresh();
25349
+ _this.fireItemsChange();
25331
25350
  }
25332
- _this.viewer.setDesignItemConstraints(guid, constraints, _this.visibleCustomizer);
25333
- _context62.next = 4;
25334
- return _this.renderDesign();
25335
- case 4:
25336
- _this.fireItemsChange();
25337
- case 5:
25351
+ case 1:
25338
25352
  case "end":
25339
25353
  return _context62.stop();
25340
25354
  }
@@ -28057,7 +28071,7 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
28057
28071
  this.viewer.addDesignItemText(_objectSpread(_objectSpread({}, settings), {}, {
28058
28072
  content: settings.text
28059
28073
  }), areaId, this.visibleCustomizer);
28060
- this.renderDesign();
28074
+ this.debouncedRefresh();
28061
28075
  _context104.next = 10;
28062
28076
  break;
28063
28077
  case 9:
@@ -28090,7 +28104,7 @@ var ZakekeEnvironment = /*#__PURE__*/function () {
28090
28104
  break;
28091
28105
  }
28092
28106
  this.viewer.setDesignPrintingMethod(printingMethodId, areaId, this.visibleCustomizer);
28093
- this.renderDesign();
28107
+ this.debouncedRefresh();
28094
28108
  _context105.next = 6;
28095
28109
  break;
28096
28110
  case 5: