@builder.io/sdk 3.0.0 → 3.0.2-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 (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.browser.js +6 -3
  3. package/dist/index.browser.js.map +1 -1
  4. package/dist/index.cjs.js +6 -3
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.esm.js +6 -3
  7. package/dist/index.esm.js.map +1 -1
  8. package/dist/index.umd.js +6 -3
  9. package/dist/index.umd.js.map +1 -1
  10. package/dist/package.json +3 -2
  11. package/dist/src/builder.class.d.ts +2 -1
  12. package/dist/src/builder.class.js +5 -2
  13. package/dist/src/builder.class.js.map +1 -1
  14. package/dist/src/builder.class.test.js +5 -5
  15. package/dist/src/builder.class.test.js.map +1 -1
  16. package/dist/src/classes/promise.class.js +150 -154
  17. package/dist/src/classes/query-string.class.js +73 -74
  18. package/dist/src/classes/query-string.class.test.js +20 -20
  19. package/dist/src/functions/assign.function.js +19 -19
  20. package/dist/src/functions/fetch.function.js +97 -75
  21. package/dist/src/functions/finder.function.js +389 -274
  22. package/dist/src/functions/get-top-level-domain.js +8 -8
  23. package/dist/src/functions/next-tick.function.js +26 -23
  24. package/dist/src/functions/omit.function.js +13 -13
  25. package/dist/src/functions/server-only-require.function.js +10 -9
  26. package/dist/src/functions/throttle.function.js +35 -37
  27. package/dist/src/functions/to-error.js +5 -6
  28. package/dist/src/functions/uuid.js +9 -8
  29. package/dist/src/types/api-version.js +3 -3
  30. package/dist/src/types/element.js +3 -3
  31. package/dist/src/url.test.js +222 -118
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +4 -3
  34. package/.yarnrc.yml +0 -1
@@ -1,85 +1,107 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ 'use strict';
2
+ var __importDefault =
3
+ (this && this.__importDefault) ||
4
+ function (mod) {
5
+ return mod && mod.__esModule ? mod : { default: mod };
6
+ };
7
+ Object.defineProperty(exports, '__esModule', { value: true });
6
8
  exports.getFetch = void 0;
7
- var promise_class_1 = __importDefault(require("../classes/promise.class"));
8
- var server_only_require_function_1 = __importDefault(require("./server-only-require.function"));
9
+ var promise_class_1 = __importDefault(require('../classes/promise.class'));
10
+ var server_only_require_function_1 = __importDefault(require('./server-only-require.function'));
9
11
  function promiseResolve(value) {
10
- return new promise_class_1.default(function (resolve) { return resolve(value); });
12
+ return new promise_class_1.default(function (resolve) {
13
+ return resolve(value);
14
+ });
11
15
  }
12
16
  // Adapted from https://raw.githubusercontent.com/developit/unfetch/master/src/index.mjs
13
17
  function tinyFetch(url, options) {
14
- if (options === void 0) { options = {}; }
15
- return new promise_class_1.default(function (resolve, reject) {
16
- var request = new XMLHttpRequest();
17
- request.open(options.method || 'get', url, true);
18
- if (options.headers) {
19
- for (var i in options.headers) {
20
- request.setRequestHeader(i, options.headers[i]);
21
- }
22
- }
23
- request.withCredentials = options.credentials === 'include';
24
- request.onload = function () {
25
- resolve(response());
26
- };
27
- request.onerror = reject;
28
- request.send(options.body);
29
- function response() {
30
- var keys = [];
31
- var all = [];
32
- var headers = {};
33
- var header = undefined;
34
- request
35
- .getAllResponseHeaders()
36
- .replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function (_match, _key, value) {
37
- var key = _key;
38
- keys.push((key = key.toLowerCase()));
39
- all.push([key, value]);
40
- header = headers[key];
41
- headers[key] = header ? "".concat(header, ",").concat(value) : value;
42
- return '';
43
- });
44
- return {
45
- ok: ((request.status / 100) | 0) === 2,
46
- status: request.status,
47
- statusText: request.statusText,
48
- url: request.responseURL,
49
- clone: response,
50
- text: function () { return promiseResolve(request.responseText); },
51
- json: function () { return promiseResolve(request.responseText).then(JSON.parse); },
52
- blob: function () { return promiseResolve(new Blob([request.response])); },
53
- headers: {
54
- keys: function () { return keys; },
55
- entries: function () { return all; },
56
- get: function (n) { return headers[n.toLowerCase()]; },
57
- has: function (n) { return n.toLowerCase() in headers; },
58
- },
59
- };
60
- }
61
- });
18
+ if (options === void 0) {
19
+ options = {};
20
+ }
21
+ return new promise_class_1.default(function (resolve, reject) {
22
+ var request = new XMLHttpRequest();
23
+ request.open(options.method || 'get', url, true);
24
+ if (options.headers) {
25
+ for (var i in options.headers) {
26
+ request.setRequestHeader(i, options.headers[i]);
27
+ }
28
+ }
29
+ request.withCredentials = options.credentials === 'include';
30
+ request.onload = function () {
31
+ resolve(response());
32
+ };
33
+ request.onerror = reject;
34
+ request.send(options.body);
35
+ function response() {
36
+ var keys = [];
37
+ var all = [];
38
+ var headers = {};
39
+ var header = undefined;
40
+ request
41
+ .getAllResponseHeaders()
42
+ .replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function (_match, _key, value) {
43
+ var key = _key;
44
+ keys.push((key = key.toLowerCase()));
45
+ all.push([key, value]);
46
+ header = headers[key];
47
+ headers[key] = header ? ''.concat(header, ',').concat(value) : value;
48
+ return '';
49
+ });
50
+ return {
51
+ ok: ((request.status / 100) | 0) === 2,
52
+ status: request.status,
53
+ statusText: request.statusText,
54
+ url: request.responseURL,
55
+ clone: response,
56
+ text: function () {
57
+ return promiseResolve(request.responseText);
58
+ },
59
+ json: function () {
60
+ return promiseResolve(request.responseText).then(JSON.parse);
61
+ },
62
+ blob: function () {
63
+ return promiseResolve(new Blob([request.response]));
64
+ },
65
+ headers: {
66
+ keys: function () {
67
+ return keys;
68
+ },
69
+ entries: function () {
70
+ return all;
71
+ },
72
+ get: function (n) {
73
+ return headers[n.toLowerCase()];
74
+ },
75
+ has: function (n) {
76
+ return n.toLowerCase() in headers;
77
+ },
78
+ },
79
+ };
80
+ }
81
+ });
62
82
  }
63
83
  function getFetch() {
64
- // If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it.
65
- var _fetch = undefined;
66
- if (globalThis.fetch) {
67
- _fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = globalThis.fetch);
68
- }
69
- else if (typeof window === 'undefined') {
70
- // If fetch is not defined, in a Node.js environment, use node-fetch.
71
- try {
72
- // node-fetch@^3 is ESM only, and will throw error on require.
73
- _fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = (0, server_only_require_function_1.default)('node-fetch'));
74
- }
75
- catch (e) {
76
- // If node-fetch is not installed, use tiny-fetch.
77
- console.warn('node-fetch is not installed. consider polyfilling fetch or installing node-fetch.');
78
- console.warn(e);
79
- }
84
+ // If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it.
85
+ var _fetch = undefined;
86
+ if (globalThis.fetch) {
87
+ _fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = globalThis.fetch);
88
+ } else if (typeof window === 'undefined') {
89
+ // If fetch is not defined, in a Node.js environment, use node-fetch.
90
+ try {
91
+ // node-fetch@^3 is ESM only, and will throw error on require.
92
+ _fetch !== null && _fetch !== void 0
93
+ ? _fetch
94
+ : (_fetch = (0, server_only_require_function_1.default)('node-fetch'));
95
+ } catch (e) {
96
+ // If node-fetch is not installed, use tiny-fetch.
97
+ console.warn(
98
+ 'node-fetch is not installed. consider polyfilling fetch or installing node-fetch.'
99
+ );
100
+ console.warn(e);
80
101
  }
81
- // Otherwise, use tiny-fetch.
82
- return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch;
102
+ }
103
+ // Otherwise, use tiny-fetch.
104
+ return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch;
83
105
  }
84
106
  exports.getFetch = getFetch;
85
- //# sourceMappingURL=fetch.function.js.map
107
+ //# sourceMappingURL=fetch.function.js.map