@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.esm.js CHANGED
@@ -950,7 +950,7 @@ function toError(err) {
950
950
 
951
951
  var DEFAULT_API_VERSION = 'v3';
952
952
 
953
- var SDK_VERSION = '6.0.7';
953
+ var SDK_VERSION = '6.0.9';
954
954
 
955
955
  function datePlusMinutes(minutes) {
956
956
  if (minutes === void 0) { minutes = 30; }
@@ -1221,7 +1221,7 @@ var Builder = /** @class */ (function () {
1221
1221
  }
1222
1222
  Builder.register = function (type, info) {
1223
1223
  if (type === 'plugin') {
1224
- info = this.serializeIncludingFunctions(info);
1224
+ info = this.serializeIncludingFunctions(info, true);
1225
1225
  }
1226
1226
  // TODO: all must have name and can't conflict?
1227
1227
  var typeList = this.registry[type];
@@ -1266,7 +1266,18 @@ var Builder = /** @class */ (function () {
1266
1266
  this.plugins.push(info);
1267
1267
  };
1268
1268
  Builder.registerAction = function (action) {
1269
+ var _a;
1269
1270
  this.actions.push(action);
1271
+ if (Builder.isBrowser) {
1272
+ var actionClone = JSON.parse(JSON.stringify(action));
1273
+ if (action.action) {
1274
+ actionClone.action = action.action.toString();
1275
+ }
1276
+ (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage({
1277
+ type: 'builder.registerAction',
1278
+ data: actionClone,
1279
+ }, '*');
1280
+ }
1270
1281
  };
1271
1282
  Builder.registerTrustedHost = function (host) {
1272
1283
  this.trustedHosts.push(host);
@@ -1352,7 +1363,7 @@ var Builder = /** @class */ (function () {
1352
1363
  enumerable: false,
1353
1364
  configurable: true
1354
1365
  });
1355
- Builder.serializeIncludingFunctions = function (info) {
1366
+ Builder.serializeIncludingFunctions = function (info, isForPlugin) {
1356
1367
  var serializeFn = function (fnValue) {
1357
1368
  var fnStr = fnValue.toString().trim();
1358
1369
  // we need to account for a few different fn syntaxes:
@@ -1370,12 +1381,17 @@ var Builder = /** @class */ (function () {
1370
1381
  !isArrowWithoutParens;
1371
1382
  return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
1372
1383
  };
1373
- return JSON.parse(JSON.stringify(info, function (key, value) {
1374
- if (typeof value === 'function') {
1384
+ var objToReturn = JSON.parse(JSON.stringify(info, function (key, value) {
1385
+ var shouldNotSerializeFn = isForPlugin && key === 'onSave';
1386
+ if (typeof value === 'function' && !shouldNotSerializeFn) {
1375
1387
  return serializeFn(value);
1376
1388
  }
1377
1389
  return value;
1378
1390
  }));
1391
+ if (isForPlugin) {
1392
+ objToReturn.onSave = info.onSave;
1393
+ }
1394
+ return objToReturn;
1379
1395
  };
1380
1396
  Builder.prepareComponentSpecToSend = function (spec) {
1381
1397
  return __assign(__assign({}, this.serializeIncludingFunctions(spec)), { class: undefined });