@one-commerce/sdk-core 1.24.0 → 1.25.0-UNITYONE-11259.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 (39) hide show
  1. package/lib/bundles/bundle.esm.js +25 -89
  2. package/lib/bundles/bundle.esm.js.map +1 -1
  3. package/lib/bundles/bundle.esm.min.js +1 -1
  4. package/lib/bundles/bundle.esm.min.js.map +1 -1
  5. package/lib/bundles/bundle.umd.js +24 -89
  6. package/lib/bundles/bundle.umd.js.map +1 -1
  7. package/lib/bundles/bundle.umd.min.js +1 -1
  8. package/lib/bundles/bundle.umd.min.js.map +1 -1
  9. package/lib/cjs/backoffice/context.js +33 -57
  10. package/lib/cjs/backoffice/context.js.map +1 -1
  11. package/lib/cjs/events.js +14 -0
  12. package/lib/cjs/events.js.map +1 -1
  13. package/lib/cjs/index.js +10 -17
  14. package/lib/cjs/index.js.map +1 -1
  15. package/lib/cjs/shop/context.js +88 -0
  16. package/lib/cjs/shop/context.js.map +1 -0
  17. package/lib/cjs/utils.js +43 -1
  18. package/lib/cjs/utils.js.map +1 -1
  19. package/lib/esm/backoffice/context.js +1 -11
  20. package/lib/esm/backoffice/context.js.map +1 -1
  21. package/lib/esm/events.js +13 -0
  22. package/lib/esm/events.js.map +1 -1
  23. package/lib/esm/index.js +9 -10
  24. package/lib/esm/index.js.map +1 -1
  25. package/lib/esm/shop/context.js +36 -0
  26. package/lib/esm/shop/context.js.map +1 -0
  27. package/lib/esm/utils.js +8 -0
  28. package/lib/esm/utils.js.map +1 -1
  29. package/lib/types/backoffice/context.d.ts +2 -6
  30. package/lib/types/backoffice/context.d.ts.map +1 -1
  31. package/lib/types/events.d.ts +1 -0
  32. package/lib/types/events.d.ts.map +1 -1
  33. package/lib/types/index.d.ts +15 -13
  34. package/lib/types/index.d.ts.map +1 -1
  35. package/lib/types/shop/context.d.ts +16 -0
  36. package/lib/types/shop/context.d.ts.map +1 -0
  37. package/lib/types/utils.d.ts +3 -0
  38. package/lib/types/utils.d.ts.map +1 -1
  39. package/package.json +3 -3
@@ -294,85 +294,6 @@ var BaseCallClass = /*#__PURE__*/function () {
294
294
  return BaseCallClass;
295
295
  }();
296
296
 
297
- var ContextCallClass = /*#__PURE__*/function (_BaseCallClass) {
298
- _inherits(ContextCallClass, _BaseCallClass);
299
-
300
- var _super = _createSuper(ContextCallClass);
301
-
302
- function ContextCallClass() {
303
- var _this;
304
-
305
- _classCallCheck(this, ContextCallClass);
306
-
307
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
308
- args[_key] = arguments[_key];
309
- }
310
-
311
- _this = _super.call.apply(_super, [this].concat(args));
312
-
313
- _defineProperty(_assertThisInitialized(_this), "serviceName", 'context');
314
-
315
- return _this;
316
- }
317
-
318
- return _createClass(ContextCallClass);
319
- }(BaseCallClass);
320
-
321
- var AddToCartContext = /*#__PURE__*/function (_ContextCallClass) {
322
- _inherits(AddToCartContext, _ContextCallClass);
323
-
324
- var _super2 = _createSuper(AddToCartContext);
325
-
326
- function AddToCartContext() {
327
- var _this2;
328
-
329
- _classCallCheck(this, AddToCartContext);
330
-
331
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
332
- args[_key2] = arguments[_key2];
333
- }
334
-
335
- _this2 = _super2.call.apply(_super2, [this].concat(args));
336
-
337
- _defineProperty(_assertThisInitialized(_this2), "productId", void 0);
338
-
339
- _defineProperty(_assertThisInitialized(_this2), "cartId", void 0);
340
-
341
- _defineProperty(_assertThisInitialized(_this2), "offerId", void 0);
342
-
343
- _defineProperty(_assertThisInitialized(_this2), "warehouses", void 0);
344
-
345
- _defineProperty(_assertThisInitialized(_this2), "warehouseId", void 0);
346
-
347
- _defineProperty(_assertThisInitialized(_this2), "meta", void 0);
348
-
349
- _defineProperty(_assertThisInitialized(_this2), "pluginProductLines", void 0);
350
-
351
- _defineProperty(_assertThisInitialized(_this2), "productLines", void 0);
352
-
353
- return _this2;
354
- }
355
-
356
- _createClass(AddToCartContext, [{
357
- key: "closePlugin",
358
- value: function closePlugin() {
359
- return this.call('closePlugin');
360
- }
361
- }, {
362
- key: "closePluginAndAddToCart",
363
- value: function closePluginAndAddToCart() {
364
- return this.call('closePluginAndAddToCart');
365
- }
366
- }, {
367
- key: "closePluginAndRefreshCart",
368
- value: function closePluginAndRefreshCart() {
369
- return this.call('closePluginAndRefreshCart');
370
- }
371
- }]);
372
-
373
- return AddToCartContext;
374
- }(ContextCallClass);
375
-
376
297
  var BackofficeCatalog = /*#__PURE__*/function (_BaseCallClass) {
377
298
  _inherits(BackofficeCatalog, _BaseCallClass);
378
299
 
@@ -635,6 +556,20 @@ var Events = /*#__PURE__*/function () {
635
556
 
636
557
  this._callbacks[key].push(callback);
637
558
  }
559
+ }, {
560
+ key: "off",
561
+ value: function off(key, callback) {
562
+ // if the key exists
563
+ if (this._callbacks[key] !== undefined) {
564
+ // iterate through the callbacks for the event key
565
+ for (var i = 0; i < this._callbacks[key].length; i++) {
566
+ // if the callback matches, remove it
567
+ if (this._callbacks[key][i] === callback) {
568
+ this._callbacks[key].splice(i, 1);
569
+ }
570
+ }
571
+ }
572
+ }
638
573
  }, {
639
574
  key: "emit",
640
575
  value: function emit(key) {
@@ -1136,15 +1071,6 @@ var Sdk = /*#__PURE__*/function (_Events) {
1136
1071
  }
1137
1072
 
1138
1073
  _createClass(Sdk, [{
1139
- key: "initializeContextClass",
1140
- value: function initializeContextClass() {
1141
- if (this.contextClass) {
1142
- return new this.contextClass(this.callFunction.bind(this));
1143
- }
1144
-
1145
- return {};
1146
- }
1147
- }, {
1148
1074
  key: "initializeServiceGetters",
1149
1075
  value: function initializeServiceGetters() {
1150
1076
  var _this2 = this;
@@ -1159,6 +1085,15 @@ var Sdk = /*#__PURE__*/function (_Events) {
1159
1085
  });
1160
1086
  }
1161
1087
  }
1088
+ }, {
1089
+ key: "initializeContextClass",
1090
+ value: function initializeContextClass() {
1091
+ if (this.contextClass) {
1092
+ return new this.contextClass(this.callFunction.bind(this));
1093
+ }
1094
+
1095
+ return {};
1096
+ }
1162
1097
  }, {
1163
1098
  key: "sendFrameHeight",
1164
1099
  value: function sendFrameHeight() {
@@ -1347,6 +1282,7 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
1347
1282
  config: new ShopConfig(_this6.callFunction.bind(_assertThisInitialized(_this6))),
1348
1283
  tenant: new ShopTenant(_this6.callFunction.bind(_assertThisInitialized(_this6))),
1349
1284
  wishlist: new ShopWishlist(_this6.callFunction.bind(_assertThisInitialized(_this6))),
1285
+ context: _this6.initializeContextClass(),
1350
1286
  plugin: new ShopPlugin(_this6.callFunction.bind(_assertThisInitialized(_this6)))
1351
1287
  });
1352
1288
 
@@ -1356,5 +1292,5 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
1356
1292
  return _createClass(ShopSdk);
1357
1293
  }(Sdk);
1358
1294
 
1359
- export { AddToCartContext, BackofficeSdk, SdkEvents, ShopSdk };
1295
+ export { BackofficeSdk, SdkEvents, ShopSdk };
1360
1296
  //# sourceMappingURL=bundle.esm.js.map