@builder.io/sdk 2.2.7 → 2.2.8
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/CHANGELOG.md +6 -0
- package/dist/index.browser.js +19 -30
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +19 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +19 -30
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/builder.class.d.ts +1 -0
- package/dist/src/builder.class.js +18 -29
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/builder.class.test.js +136 -0
- package/dist/src/builder.class.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -126,7 +126,7 @@ function assertAllowedPropertyName(name) {
|
|
|
126
126
|
throw new Error("Property name \"".concat(name, "\" is not allowed"));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
var version = "2.2.
|
|
129
|
+
var version = "2.2.8";
|
|
130
130
|
|
|
131
131
|
var Subscription = /** @class */ (function () {
|
|
132
132
|
function Subscription(listeners, listener) {
|
|
@@ -1347,36 +1347,25 @@ var Builder = /** @class */ (function () {
|
|
|
1347
1347
|
enumerable: false,
|
|
1348
1348
|
configurable: true
|
|
1349
1349
|
});
|
|
1350
|
+
Builder.serializeComponentInfo = function (info) {
|
|
1351
|
+
var serializeFn = function (fnValue) {
|
|
1352
|
+
var fnStr = fnValue.toString().trim();
|
|
1353
|
+
// we need to account for a few different fn syntaxes:
|
|
1354
|
+
// 1. `function name(args) => {code}`
|
|
1355
|
+
// 2. `name(args) => {code}`
|
|
1356
|
+
// 3. `(args) => {}`
|
|
1357
|
+
var appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
1358
|
+
return "return (".concat(appendFunction ? 'function ' : '').concat(fnStr, ").apply(this, arguments)");
|
|
1359
|
+
};
|
|
1360
|
+
return JSON.parse(JSON.stringify(info, function (key, value) {
|
|
1361
|
+
if (typeof value === 'function') {
|
|
1362
|
+
return serializeFn(value);
|
|
1363
|
+
}
|
|
1364
|
+
return value;
|
|
1365
|
+
}));
|
|
1366
|
+
};
|
|
1350
1367
|
Builder.prepareComponentSpecToSend = function (spec) {
|
|
1351
|
-
return tslib.__assign(tslib.__assign(
|
|
1352
|
-
inputs: spec.inputs.map(function (input) {
|
|
1353
|
-
var _a;
|
|
1354
|
-
// TODO: do for nexted fields too
|
|
1355
|
-
// TODO: probably just convert all functions, not just
|
|
1356
|
-
// TODO: put this in input hooks: { onChange: ..., showIf: ... }
|
|
1357
|
-
var keysToConvertFnToString = ['onChange', 'showIf'];
|
|
1358
|
-
for (var _i = 0, keysToConvertFnToString_1 = keysToConvertFnToString; _i < keysToConvertFnToString_1.length; _i++) {
|
|
1359
|
-
var key = keysToConvertFnToString_1[_i];
|
|
1360
|
-
if (input[key] && typeof input[key] === 'function') {
|
|
1361
|
-
var fn = input[key];
|
|
1362
|
-
input = tslib.__assign(tslib.__assign({}, input), (_a = {}, _a[key] = "return (".concat(fn.toString(), ").apply(this, arguments)"), _a));
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
return input;
|
|
1366
|
-
}),
|
|
1367
|
-
})), { hooks: Object.keys(spec.hooks || {}).reduce(function (memo, key) {
|
|
1368
|
-
var value = spec.hooks && spec.hooks[key];
|
|
1369
|
-
if (!value) {
|
|
1370
|
-
return memo;
|
|
1371
|
-
}
|
|
1372
|
-
if (typeof value === 'string') {
|
|
1373
|
-
memo[key] = value;
|
|
1374
|
-
}
|
|
1375
|
-
else {
|
|
1376
|
-
memo[key] = "return (".concat(value.toString(), ").apply(this, arguments)");
|
|
1377
|
-
}
|
|
1378
|
-
return memo;
|
|
1379
|
-
}, {}), class: undefined });
|
|
1368
|
+
return tslib.__assign(tslib.__assign({}, this.serializeComponentInfo(spec)), { class: undefined });
|
|
1380
1369
|
};
|
|
1381
1370
|
Builder.registerBlock = function (component, options) {
|
|
1382
1371
|
this.registerComponent(component, options);
|