@builder.io/sdk 6.0.7 → 6.0.9

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/dist/index.cjs.js CHANGED
@@ -958,7 +958,7 @@ function toError(err) {
958
958
 
959
959
  var DEFAULT_API_VERSION = 'v3';
960
960
 
961
- var SDK_VERSION = '6.0.7';
961
+ var SDK_VERSION = '6.0.9';
962
962
 
963
963
  function datePlusMinutes(minutes) {
964
964
  if (minutes === void 0) { minutes = 30; }
@@ -1229,7 +1229,7 @@ var Builder = /** @class */ (function () {
1229
1229
  }
1230
1230
  Builder.register = function (type, info) {
1231
1231
  if (type === 'plugin') {
1232
- info = this.serializeIncludingFunctions(info);
1232
+ info = this.serializeIncludingFunctions(info, true);
1233
1233
  }
1234
1234
  // TODO: all must have name and can't conflict?
1235
1235
  var typeList = this.registry[type];
@@ -1274,7 +1274,18 @@ var Builder = /** @class */ (function () {
1274
1274
  this.plugins.push(info);
1275
1275
  };
1276
1276
  Builder.registerAction = function (action) {
1277
+ var _a;
1277
1278
  this.actions.push(action);
1279
+ if (Builder.isBrowser) {
1280
+ var actionClone = JSON.parse(JSON.stringify(action));
1281
+ if (action.action) {
1282
+ actionClone.action = action.action.toString();
1283
+ }
1284
+ (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
1285
+ type: 'builder.registerAction',
1286
+ data: actionClone,
1287
+ }, '*');
1288
+ }
1278
1289
  };
1279
1290
  Builder.registerTrustedHost = function (host) {
1280
1291
  this.trustedHosts.push(host);
@@ -1360,7 +1371,7 @@ var Builder = /** @class */ (function () {
1360
1371
  enumerable: false,
1361
1372
  configurable: true
1362
1373
  });
1363
- Builder.serializeIncludingFunctions = function (info) {
1374
+ Builder.serializeIncludingFunctions = function (info, isForPlugin) {
1364
1375
  var serializeFn = function (fnValue) {
1365
1376
  var fnStr = fnValue.toString().trim();
1366
1377
  // we need to account for a few different fn syntaxes:
@@ -1378,12 +1389,17 @@ var Builder = /** @class */ (function () {
1378
1389
  !isArrowWithoutParens;
1379
1390
  return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
1380
1391
  };
1381
- return JSON.parse(JSON.stringify(info, function (key, value) {
1382
- if (typeof value === 'function') {
1392
+ var objToReturn = JSON.parse(JSON.stringify(info, function (key, value) {
1393
+ var shouldNotSerializeFn = isForPlugin && key === 'onSave';
1394
+ if (typeof value === 'function' && !shouldNotSerializeFn) {
1383
1395
  return serializeFn(value);
1384
1396
  }
1385
1397
  return value;
1386
1398
  }));
1399
+ if (isForPlugin) {
1400
+ objToReturn.onSave = info.onSave;
1401
+ }
1402
+ return objToReturn;
1387
1403
  };
1388
1404
  Builder.prepareComponentSpecToSend = function (spec) {
1389
1405
  return tslib.__assign(tslib.__assign({}, this.serializeIncludingFunctions(spec)), { class: undefined });