@builder.io/sdk 3.0.2-0 → 3.0.2-2
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.browser.js +8 -16
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +8 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +8 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -13
- package/dist/index.umd.js +8 -16
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +2 -3
- package/dist/src/builder.class.d.ts +3 -1
- package/dist/src/builder.class.js +7 -2
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/builder.class.test.js +171 -153
- package/dist/src/classes/animator.class.js +218 -195
- package/dist/src/classes/cookies.class.js +0 -2
- package/dist/src/classes/cookies.class.js.map +1 -1
- package/dist/src/classes/observable.class.js +102 -97
- package/dist/src/constants/builder.js +4 -4
- package/dist/src/functions/get-top-level-domain.d.ts +6 -6
- package/dist/src/types/content.js +3 -3
- package/dist/src/url.js +41 -42
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,159 +1,177 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
var builder_class_1 = require(
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var builder_class_1 = require('./builder.class');
|
|
4
4
|
describe('Builder', function () {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
test('trustedHosts', function () {
|
|
6
|
+
expect(builder_class_1.Builder.isTrustedHost('localhost')).toBe(true);
|
|
7
|
+
expect(builder_class_1.Builder.isTrustedHost('builder.io')).toBe(true);
|
|
8
|
+
expect(builder_class_1.Builder.isTrustedHost('beta.builder.io')).toBe(true);
|
|
9
|
+
expect(builder_class_1.Builder.isTrustedHost('qa.builder.io')).toBe(true);
|
|
10
|
+
expect(builder_class_1.Builder.isTrustedHost('123-review-build.beta.builder.io')).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
test('arbitrary builder.io subdomains', function () {
|
|
13
|
+
expect(builder_class_1.Builder.isTrustedHost('cdn.builder.io')).toBe(false);
|
|
14
|
+
expect(builder_class_1.Builder.isTrustedHost('foo.builder.io')).toBe(false);
|
|
15
|
+
expect(builder_class_1.Builder.isTrustedHost('evildomainbeta.builder.io')).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
test('add trusted host', function () {
|
|
18
|
+
expect(builder_class_1.Builder.isTrustedHost('example.com')).toBe(false);
|
|
19
|
+
builder_class_1.Builder.registerTrustedHost('example.com');
|
|
20
|
+
expect(builder_class_1.Builder.isTrustedHost('example.com')).toBe(true);
|
|
21
|
+
});
|
|
22
22
|
});
|
|
23
23
|
describe('serializeIncludingFunctions', function () {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
24
|
+
test('serializes functions in inputs', function () {
|
|
25
|
+
var input = {
|
|
26
|
+
name: 'TestComponent',
|
|
27
|
+
inputs: [
|
|
28
|
+
{
|
|
29
|
+
name: 'text',
|
|
30
|
+
type: 'string',
|
|
31
|
+
onChange: function (value) {
|
|
32
|
+
return value.toUpperCase();
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
var result = builder_class_1.Builder['serializeIncludingFunctions'](input);
|
|
38
|
+
expect(typeof result.inputs[0].onChange).toBe('string');
|
|
39
|
+
expect(result.inputs[0].onChange).toContain('return value.toUpperCase()');
|
|
40
|
+
});
|
|
41
|
+
test('serializes arrow functions in inputs', function () {
|
|
42
|
+
var input = {
|
|
43
|
+
name: 'ArrowComponent',
|
|
44
|
+
inputs: [
|
|
45
|
+
{
|
|
46
|
+
name: 'number',
|
|
47
|
+
type: 'number',
|
|
48
|
+
onChange: function (value) {
|
|
49
|
+
return value * 2;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
var result = builder_class_1.Builder['serializeIncludingFunctions'](input);
|
|
55
|
+
expect(typeof result.inputs[0].onChange).toBe('string');
|
|
56
|
+
expect(result.inputs[0].onChange).toContain('value * 2');
|
|
57
|
+
});
|
|
58
|
+
test('does not modify non-function properties', function () {
|
|
59
|
+
var input = {
|
|
60
|
+
name: 'MixedComponent',
|
|
61
|
+
inputs: [
|
|
62
|
+
{
|
|
63
|
+
name: 'text',
|
|
64
|
+
type: 'string',
|
|
65
|
+
defaultValue: 'hello',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
var result = builder_class_1.Builder['serializeIncludingFunctions'](input);
|
|
70
|
+
expect(result).toEqual(input);
|
|
71
|
+
});
|
|
72
|
+
test('handles multiple inputs with mixed properties', function () {
|
|
73
|
+
var input = {
|
|
74
|
+
name: 'ComplexComponent',
|
|
75
|
+
inputs: [
|
|
76
|
+
{
|
|
77
|
+
name: 'text',
|
|
78
|
+
type: 'string',
|
|
79
|
+
onChange: function (value) {
|
|
80
|
+
return value.trim();
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'number',
|
|
85
|
+
type: 'number',
|
|
86
|
+
defaultValue: 42,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'options',
|
|
90
|
+
type: 'string',
|
|
91
|
+
onChange: function (value) {
|
|
92
|
+
return value.map(function (v) {
|
|
93
|
+
return v.toLowerCase();
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
var result = builder_class_1.Builder['serializeIncludingFunctions'](input);
|
|
100
|
+
expect(typeof result.inputs[0].onChange).toBe('string');
|
|
101
|
+
expect(result.inputs[0].onChange).toContain('value.trim()');
|
|
102
|
+
expect(result.inputs[1]).toEqual(input.inputs[1]);
|
|
103
|
+
expect(typeof result.inputs[2].onChange).toBe('string');
|
|
104
|
+
expect(result.inputs[2].onChange).toContain('v.toLowerCase()');
|
|
105
|
+
});
|
|
100
106
|
});
|
|
101
107
|
describe('prepareComponentSpecToSend', function () {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
108
|
+
test('removes class property and serializes functions in inputs', function () {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
var input = {
|
|
111
|
+
name: 'TestComponent',
|
|
112
|
+
class: /** @class */ (function () {
|
|
113
|
+
function TestClass() {}
|
|
114
|
+
return TestClass;
|
|
115
|
+
})(),
|
|
116
|
+
inputs: [
|
|
117
|
+
{
|
|
118
|
+
name: 'text',
|
|
119
|
+
type: 'string',
|
|
120
|
+
onChange: function (value) {
|
|
121
|
+
return value.toUpperCase();
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
var result = builder_class_1.Builder['prepareComponentSpecToSend'](input);
|
|
127
|
+
expect(result.class).toBeUndefined();
|
|
128
|
+
expect(typeof ((_a = result.inputs) === null || _a === void 0 ? void 0 : _a[0].onChange)).toBe(
|
|
129
|
+
'string'
|
|
130
|
+
);
|
|
131
|
+
expect((_b = result.inputs) === null || _b === void 0 ? void 0 : _b[0].onChange).toContain(
|
|
132
|
+
'value.toUpperCase()'
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
test('preserves other properties', function () {
|
|
136
|
+
var _a, _b, _c, _d, _e;
|
|
137
|
+
var input = {
|
|
138
|
+
name: 'ComplexComponent',
|
|
139
|
+
class: /** @class */ (function () {
|
|
140
|
+
function ComplexClass() {}
|
|
141
|
+
return ComplexClass;
|
|
142
|
+
})(),
|
|
143
|
+
inputs: [
|
|
144
|
+
{
|
|
145
|
+
name: 'text',
|
|
146
|
+
type: 'string',
|
|
147
|
+
defaultValue: 'hello',
|
|
148
|
+
onChange: function (value) {
|
|
149
|
+
return value.trim();
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'number',
|
|
154
|
+
type: 'number',
|
|
155
|
+
defaultValue: 42,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
var result = builder_class_1.Builder['prepareComponentSpecToSend'](input);
|
|
160
|
+
expect(result.class).toBeUndefined();
|
|
161
|
+
expect(result.name).toBe('ComplexComponent');
|
|
162
|
+
expect((_a = result.inputs) === null || _a === void 0 ? void 0 : _a.length).toBe(2);
|
|
163
|
+
expect(typeof ((_b = result.inputs) === null || _b === void 0 ? void 0 : _b[0].onChange)).toBe(
|
|
164
|
+
'string'
|
|
165
|
+
);
|
|
166
|
+
expect((_c = result.inputs) === null || _c === void 0 ? void 0 : _c[0].onChange).toContain(
|
|
167
|
+
'value.trim()'
|
|
168
|
+
);
|
|
169
|
+
expect((_d = result.inputs) === null || _d === void 0 ? void 0 : _d[0].defaultValue).toBe(
|
|
170
|
+
'hello'
|
|
171
|
+
);
|
|
172
|
+
expect((_e = result.inputs) === null || _e === void 0 ? void 0 : _e[1]).toEqual(
|
|
173
|
+
input.inputs[1]
|
|
174
|
+
);
|
|
175
|
+
});
|
|
158
176
|
});
|
|
159
|
-
//# sourceMappingURL=builder.class.test.js.map
|
|
177
|
+
//# sourceMappingURL=builder.class.test.js.map
|