@webqit/webflo 0.11.61-0 → 1.0.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 (118) hide show
  1. package/.gitignore +7 -7
  2. package/LICENSE +20 -20
  3. package/README.md +2079 -2074
  4. package/docker/Dockerfile +42 -42
  5. package/docker/README.md +91 -91
  6. package/docker/package.json +2 -2
  7. package/package.json +80 -81
  8. package/src/{Context.js → AbstractContext.js} +71 -79
  9. package/src/config-pi/deployment/Env.js +68 -68
  10. package/src/config-pi/deployment/Layout.js +63 -63
  11. package/src/config-pi/deployment/Origins.js +139 -139
  12. package/src/config-pi/deployment/Proxy.js +74 -74
  13. package/src/config-pi/deployment/index.js +17 -17
  14. package/src/config-pi/index.js +15 -15
  15. package/src/config-pi/runtime/Client.js +116 -98
  16. package/src/config-pi/runtime/Server.js +125 -125
  17. package/src/config-pi/runtime/client/Worker.js +109 -134
  18. package/src/config-pi/runtime/client/index.js +11 -11
  19. package/src/config-pi/runtime/index.js +17 -17
  20. package/src/config-pi/runtime/server/Headers.js +74 -74
  21. package/src/config-pi/runtime/server/Redirects.js +69 -69
  22. package/src/config-pi/runtime/server/index.js +13 -13
  23. package/src/config-pi/static/Manifest.js +319 -319
  24. package/src/config-pi/static/Ssg.js +49 -49
  25. package/src/config-pi/static/index.js +13 -13
  26. package/src/deployment-pi/index.js +10 -10
  27. package/src/deployment-pi/origins/index.js +216 -216
  28. package/src/index.js +11 -19
  29. package/src/runtime-pi/HttpEvent.js +126 -106
  30. package/src/runtime-pi/HttpUser.js +126 -0
  31. package/src/runtime-pi/MessagingOverBroadcast.js +9 -0
  32. package/src/runtime-pi/MessagingOverChannel.js +85 -0
  33. package/src/runtime-pi/MessagingOverSocket.js +106 -0
  34. package/src/runtime-pi/MultiportMessagingAPI.js +81 -0
  35. package/src/runtime-pi/WebfloCookieStorage.js +27 -0
  36. package/src/runtime-pi/WebfloEventTarget.js +39 -0
  37. package/src/runtime-pi/WebfloMessageEvent.js +58 -0
  38. package/src/runtime-pi/WebfloMessagingAPI.js +69 -0
  39. package/src/runtime-pi/{Router.js → WebfloRouter.js} +99 -130
  40. package/src/runtime-pi/WebfloRuntime.js +52 -0
  41. package/src/runtime-pi/WebfloStorage.js +109 -0
  42. package/src/runtime-pi/client/ClientMessaging.js +5 -0
  43. package/src/runtime-pi/client/Context.js +3 -7
  44. package/src/runtime-pi/client/CookieStorage.js +17 -0
  45. package/src/runtime-pi/client/Router.js +38 -48
  46. package/src/runtime-pi/client/SessionStorage.js +33 -0
  47. package/src/runtime-pi/client/Url.js +156 -205
  48. package/src/runtime-pi/client/WebfloClient.js +544 -0
  49. package/src/runtime-pi/client/WebfloRootClient1.js +179 -0
  50. package/src/runtime-pi/client/WebfloRootClient2.js +109 -0
  51. package/src/runtime-pi/client/WebfloSubClient.js +165 -0
  52. package/src/runtime-pi/client/Workport.js +118 -178
  53. package/src/runtime-pi/client/generate.js +480 -471
  54. package/src/runtime-pi/client/index.js +16 -21
  55. package/src/runtime-pi/client/worker/ClientMessaging.js +5 -0
  56. package/src/runtime-pi/client/worker/Context.js +3 -7
  57. package/src/runtime-pi/client/worker/CookieStorage.js +17 -0
  58. package/src/runtime-pi/client/worker/SessionStorage.js +13 -0
  59. package/src/runtime-pi/client/worker/WebfloWorker.js +294 -0
  60. package/src/runtime-pi/client/worker/Workport.js +17 -85
  61. package/src/runtime-pi/client/worker/index.js +10 -21
  62. package/src/runtime-pi/index.js +6 -13
  63. package/src/runtime-pi/server/ClientMessaging.js +18 -0
  64. package/src/runtime-pi/server/ClientMessagingRegistry.js +57 -0
  65. package/src/runtime-pi/server/Context.js +11 -15
  66. package/src/runtime-pi/server/CookieStorage.js +17 -0
  67. package/src/runtime-pi/server/Router.js +93 -159
  68. package/src/runtime-pi/server/SessionStorage.js +53 -0
  69. package/src/runtime-pi/server/WebfloServer.js +755 -0
  70. package/src/runtime-pi/server/index.js +10 -21
  71. package/src/runtime-pi/util-http.js +322 -86
  72. package/src/runtime-pi/util-url.js +146 -146
  73. package/src/runtime-pi/xURL.js +108 -105
  74. package/src/runtime-pi/xfetch.js +22 -22
  75. package/src/services-pi/cert/http-auth-hook.js +22 -22
  76. package/src/services-pi/cert/http-cleanup-hook.js +22 -22
  77. package/src/services-pi/cert/index.js +79 -79
  78. package/src/services-pi/index.js +8 -8
  79. package/src/static-pi/index.js +10 -10
  80. package/src/webflo.js +30 -30
  81. package/test/index.test.js +26 -26
  82. package/test/site/package.json +9 -9
  83. package/test/site/public/bundle.html +5 -5
  84. package/test/site/public/bundle.html.json +3 -3
  85. package/test/site/public/bundle.js +2 -2
  86. package/test/site/public/bundle.webflo.js +15 -15
  87. package/test/site/public/index.html +29 -29
  88. package/test/site/public/index1.html +34 -34
  89. package/test/site/public/page-2/bundle.html +4 -4
  90. package/test/site/public/page-2/bundle.js +2 -2
  91. package/test/site/public/page-2/index.html +45 -45
  92. package/test/site/public/page-2/main.html +2 -2
  93. package/test/site/public/page-4/subpage/bundle.js +2 -2
  94. package/test/site/public/page-4/subpage/index.html +30 -30
  95. package/test/site/public/sparoots.json +4 -4
  96. package/test/site/public/worker.js +3 -3
  97. package/test/site/server/index.js +15 -15
  98. package/src/runtime-pi/Application.js +0 -29
  99. package/src/runtime-pi/Cookies.js +0 -82
  100. package/src/runtime-pi/Runtime.js +0 -21
  101. package/src/runtime-pi/client/Application.js +0 -100
  102. package/src/runtime-pi/client/Runtime.js +0 -332
  103. package/src/runtime-pi/client/createStorage.js +0 -57
  104. package/src/runtime-pi/client/oohtml/full.js +0 -7
  105. package/src/runtime-pi/client/oohtml/namespacing.js +0 -7
  106. package/src/runtime-pi/client/oohtml/scripting.js +0 -8
  107. package/src/runtime-pi/client/oohtml/templating.js +0 -8
  108. package/src/runtime-pi/client/worker/Application.js +0 -44
  109. package/src/runtime-pi/client/worker/Runtime.js +0 -269
  110. package/src/runtime-pi/server/Application.js +0 -116
  111. package/src/runtime-pi/server/Runtime.js +0 -557
  112. package/src/runtime-pi/xFormData.js +0 -24
  113. package/src/runtime-pi/xHeaders.js +0 -146
  114. package/src/runtime-pi/xRequest.js +0 -46
  115. package/src/runtime-pi/xRequestHeaders.js +0 -109
  116. package/src/runtime-pi/xResponse.js +0 -33
  117. package/src/runtime-pi/xResponseHeaders.js +0 -117
  118. package/src/runtime-pi/xxHttpMessage.js +0 -102
@@ -1,146 +0,0 @@
1
-
2
- /**
3
- * The xHeaders Mixin
4
- */
5
- export default class xHeaders extends Headers {
6
-
7
- // construct
8
- constructor(definition = {}) {
9
- const cookies = definition.cookies;
10
- delete definition.cookies;
11
- // -----------------
12
- if (definition instanceof Headers) {
13
- // It's another Headers instance
14
- super(definition);
15
- } else {
16
- super();
17
- this.json(definition);
18
- }
19
- // -----------------
20
- this.cookies = cookies;
21
- }
22
-
23
- set(name, value) {
24
- // Will sync forth to this._cookies if is cookie
25
- this.catchCookies(name, value);
26
- return super.set(name, value);
27
- }
28
-
29
- append(name, value) {
30
- // Will sync forth to this._cookies if is cookie
31
- this.catchCookies(name, value, true);
32
- return super.append(name, value);
33
- }
34
-
35
- delete(name) {
36
- // Will sync forth to this._cookies if is cookie
37
- this.catchCookies(name);
38
- return super.delete(name);
39
- }
40
-
41
- set cookies(cookies) {
42
- if (cookies instanceof Map) {
43
- this.cookies.clear();
44
- for (let [ name, value ] of cookies) {
45
- this.cookies.set(name, value);
46
- }
47
- } else if (cookies) { this.set(this.cookieHeaderName, cookies); }
48
- return true;
49
- }
50
-
51
- get cookies() {
52
- if (!this._cookies) {
53
- this._cookies = new this.Cookies;
54
- Object.defineProperty(this._cookies, 'headers', { value: this });
55
- }
56
- return this._cookies;
57
- }
58
-
59
- catchCookies(name, value, append = false) {
60
- if (!this.cookies || name.toLowerCase() !== this.cookieHeaderName.toLowerCase()) return;
61
- this.cookies.outLock = true;
62
- // -----------------
63
- if (arguments.length > 1) {
64
- if (!append) { this.cookies.clear(); }
65
- const cookiesObj = this.cookies.parse(value);
66
- for (let name in cookiesObj) {
67
- this.cookies.set(name, cookiesObj[name]);
68
- }
69
- } else { this.cookies.clear(); }
70
- // -----------------
71
- this.cookies.outLock = false;
72
- }
73
-
74
- json(headers = {}, replace = true) {
75
- if (arguments.length) {
76
- const _setters = getAllPropertyDescriptors(this);
77
- const setters = Object.keys(_setters).reduce((list, key) => list.concat((typeof key !== 'symbol') && ('set' in _setters[key]) ? key : []), []);
78
- Object.keys(headers).forEach(name => {
79
- var nameCs = setters.reduce((prev, curr) => prev || (curr === name || curr.toLocaleLowerCase() === name ? curr : null), null);
80
- if (nameCs) {
81
- if (replace || this[nameCs] === undefined) {
82
- this[nameCs] = headers[name];
83
- }
84
- } else {
85
- if (replace || !this.has(name)) {
86
- this.set(name, headers[name]);
87
- }
88
- }
89
- });
90
- return;
91
- }
92
- const _headers = {};
93
- for (var [ name, value ] of this) {
94
- _headers[name] = value;
95
- }
96
- return _headers;
97
- }
98
-
99
- set cacheControl(value) {
100
- return this.set('Cache-Control', value);
101
- }
102
-
103
- get cacheControl() {
104
- return this.get('Cache-Control');
105
- }
106
-
107
- set contentLength(value) {
108
- return this.set('Content-Length', value);
109
- }
110
-
111
- get contentLength() {
112
- return this.get('Content-Length');
113
- }
114
-
115
- set contentType(value) {
116
- return this.set('Content-Type', value);
117
- }
118
-
119
- get contentType() {
120
- return this.get('Content-Type');
121
- }
122
-
123
- static compat(headers) {
124
- if (!(headers instanceof this) && !headers.json) {
125
- const descs = getAllPropertyDescriptors(new this);
126
- Object.keys(descs).forEach(key => {
127
- if (typeof key === 'symbol' || (key in headers)) return;
128
- Object.defineProperty(headers, key, descs[key]);
129
- });
130
- }
131
- return headers;
132
- }
133
-
134
- }
135
-
136
- function getAllPropertyDescriptors(obj) {
137
- if (!obj) {
138
- return Object.create(null);
139
- } else {
140
- const proto = Object.getPrototypeOf(obj);
141
- return proto === Object.prototype ? {} : {
142
- ...getAllPropertyDescriptors(proto),
143
- ...Object.getOwnPropertyDescriptors(obj)
144
- };
145
- }
146
- }
@@ -1,46 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import mxHttpMessage from './xxHttpMessage.js';
6
- import xRequestHeaders from './xRequestHeaders.js';
7
- import { formatMessage } from './util-http.js';
8
-
9
- /**
10
- * The xRequest Mixin
11
- */
12
- export default class xRequest extends mxHttpMessage(Request, xRequestHeaders) {
13
-
14
- constructor(input, init = {}, meta = {}) {
15
- if (init instanceof Request) {
16
-
17
- } else if ('body' in init) {
18
- const [ body, headers, type ] = formatMessage(init);
19
- meta = { ...meta, type, body: init.body };
20
- init = { ...init, body, headers };
21
- }
22
- super(input, init, meta);
23
- }
24
-
25
- static compat(request) {
26
- if (request instanceof this) return request;
27
- if (request instanceof Request) {
28
- return Object.setPrototypeOf(request, new this);
29
- }
30
- return new this(request);
31
- }
32
-
33
- static async rip(request) {
34
- const requestInit = [
35
- 'method', 'headers', 'mode', 'credentials', 'cache', 'redirect', 'referrer', 'integrity',
36
- ].reduce((init, prop) => ({ [prop]: request[prop], ...init }), {});
37
- if (!['GET', 'HEAD'].includes(request.method)) {
38
- requestInit.body = await request.clone().arrayBuffer();
39
- }
40
- if (requestInit.mode === 'navigate') {
41
- requestInit.mode = 'cors';
42
- }
43
- return [ request.url, requestInit ];
44
- }
45
-
46
- }
@@ -1,109 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { _after } from "@webqit/util/str/index.js";
6
- import { _from as _arrFrom } from "@webqit/util/arr/index.js";
7
- import { params } from './util-url.js';
8
- import xHeaders from './xHeaders.js';
9
- import xCookies from './Cookies.js';
10
-
11
- /**
12
- * The xHeaders Mixin
13
- */
14
- export default class xRequestHeaders extends xHeaders {
15
-
16
- get cookieHeaderName() {
17
- return 'Cookie';
18
- }
19
-
20
- get cookieHeaderSeparator() {
21
- return ';';
22
- }
23
-
24
- get Cookies() {
25
- return Cookies;
26
- }
27
-
28
- set accept(value) {
29
- return this.set('Accept', value);
30
- }
31
-
32
- get accept() {
33
- const accept = this.get('Accept');
34
- const list = accept && accept.split(',').map(a => (a = a.trim().split(';').map(a => a.trim()), [a.shift(), parseFloat((a.pop() || '1').replace('q=', ''))]))
35
- .sort((a, b) => a[1] > b[1] ? -1 : 1) || [];
36
- return {
37
- match(mime) {
38
- mime = (mime + '').split('/');
39
- return list.reduce((prev, entry) => prev || (
40
- (entry = entry[0].split('/')) && [0, 1].every(i => ((mime[i] === entry[i]) || mime[i] === '*' || entry[i] === '*'))
41
- ), false);
42
- },
43
- toString() {
44
- return accept;
45
- }
46
- };
47
- }
48
-
49
- set range(value) {
50
- let rangeArr = [];
51
- _arrFrom(value).forEach((range, i) => {
52
- let rangeStr = Array.isArray(range) ? range.join('-') : range + '';
53
- if (i === 0 && !rangeStr.includes('bytes=')) {
54
- rangeStr = `bytes=${rangeStr}`;
55
- }
56
- rangeArr.push(rangeStr);
57
- });
58
- return this.set('Range', rangeArr.join(', '));
59
- }
60
-
61
- get range() {
62
- const value = this.get('Range');
63
- if (!value) return;
64
- const rangeArr = _after(value, 'bytes=').split(',').map(rangeStr => {
65
- let range = rangeStr.trim().split('-');
66
- range[0] = range[0] ? parseInt(range[0], 10) : undefined;
67
- if (range[1]) {
68
- range[1] = parseInt(range[1], 10);
69
- }
70
- range.clamp = max => {
71
- if (range[1] > max - 1 || range[1] === undefined) {
72
- range[1] = max - 1;
73
- }
74
- if (range[0] === undefined) range[0] = range[1] ? max - range[1] - 1 : 0;
75
- };
76
- return range;
77
- });
78
- return rangeArr;
79
- }
80
-
81
- set cors(value) {
82
- return this.set('Access-Control-Allow-Origin', value === true ? '*' : (value === false ? '' : value));
83
- }
84
-
85
- get cors() {
86
- return this.get('Access-Control-Allow-Origin');
87
- }
88
-
89
-
90
- }
91
-
92
- /**
93
- * Cookies
94
- */
95
- class Cookies extends xCookies {
96
-
97
- parse(str) {
98
- return params.parse(str, ';');
99
- }
100
-
101
- parseEntry(str) {
102
- return str.trim().split('=');
103
- }
104
-
105
- stringifyEntry(cookieBody) {
106
- return cookieBody;
107
- }
108
-
109
- }
@@ -1,33 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import mxHttpMessage from './xxHttpMessage.js';
6
- import xResponseHeaders from './xResponseHeaders.js';
7
- import { formatMessage } from './util-http.js';
8
-
9
- /**
10
- * The xResponse Mixin
11
- */
12
- export default class xResponse extends mxHttpMessage(Response, xResponseHeaders) {
13
-
14
- // construct
15
- constructor(body = null, init = {}, meta = {}) {
16
- if (body || body === 0) {
17
- let headers, type, _body = body;
18
- [ body, headers, type ] = formatMessage({ body, headers: init.headers });
19
- meta = { ...init, type, body: _body };
20
- init = { ...init, headers };
21
- }
22
- super(body, init, meta);
23
- }
24
-
25
- static compat(response) {
26
- if (response instanceof this) return response;
27
- if (response instanceof Response) {
28
- return Object.setPrototypeOf(response, new this);
29
- }
30
- return new this(response);
31
- }
32
-
33
- }
@@ -1,117 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { _after, _beforeLast } from "@webqit/util/str/index.js";
6
- import { _isString, _getType, _isObject } from "@webqit/util/js/index.js";
7
- import xHeaders from './xHeaders.js';
8
- import xCookies from './Cookies.js';
9
-
10
- /**
11
- * The _Headers Mixin
12
- */
13
- export default class xResponseHeaders extends xHeaders {
14
-
15
- get cookieHeaderName() {
16
- return 'Set-Cookie';
17
- }
18
-
19
- get cookieHeaderSeparator() {
20
- return ',';
21
- }
22
-
23
- get Cookies() {
24
- return Cookies;
25
- }
26
-
27
- set contentRange(value) {
28
- if (Array.isArray(value)) {
29
- if ((value.length === 2 && !value[0].includes('-')) || value.length < 2) {
30
- throw new Error(`A Content-Range array must be in the format: [ 'start-end', 'total' ]`);
31
- }
32
- return this.set('Content-Range', `bytes ${value.join('/')}`);
33
- }
34
- return this.set('Content-Range', value);
35
- }
36
-
37
- get contentRange() {
38
- const value = this.get('Content-Range');
39
- return value && _after(value, 'bytes ').split('/');
40
- }
41
-
42
- set cors(value) {
43
- return this.set('Access-Control-Allow-Origin', value === true ? '*' : (value === false ? '' : value));
44
- }
45
-
46
- get cors() {
47
- return this.get('Access-Control-Allow-Origin');
48
- }
49
-
50
- set attachment(value) {
51
- value = value === true ? 'attachment' : (value === false ? 'inline' : value);
52
- if (!_isString(value)) {
53
- throw new Error(`The "download" response directive does not support the type: ${_getType(value)}`);
54
- }
55
- if (![ 'attachment', 'inline' ].includes(value)) {
56
- value = `attachment; filename="${value}"`;
57
- }
58
- return this.set('Content-Disposition', value);
59
- }
60
-
61
- get attachment() {
62
- var value = (this.get('Content-Disposition') || '').trim();
63
- value = value === 'attachment' ? true : (
64
- value === 'inline' ? false : _after(_beforeLast(value, '"'), 'filename="')
65
- );
66
- return value;
67
- }
68
-
69
- get location() {
70
- return this.get('Location');
71
- }
72
-
73
- set location(value) {
74
- return this.set('Location', value);
75
- }
76
-
77
- }
78
-
79
- /**
80
- * Cookies
81
- */
82
- class Cookies extends xCookies {
83
-
84
- parse(cookieStr) {
85
- const obj = {};
86
- cookieStr && cookieStr.split(',').forEach(str => {
87
- let [ cookieName, definition ] = this.parseEntry(str);
88
- obj[cookieName] = definition;
89
- });
90
- return obj;
91
- }
92
-
93
- parseEntry(str) {
94
- let [ cookieDefinition, attrsStr ] = str.split(';');
95
- let [ cookieName, cookieValue ] = cookieDefinition.trim().split('=');
96
- let attrs = { value: cookieValue, };
97
- attrsStr && (attrsStr || '').split(/\;/g).map(attrStr => attrStr.trim().split('=')).forEach(attrsArr => {
98
- attrs[attrsArr[0][0].toLowerCase() + attrsArr[0].substring(1).replace('-', '')] = attrsArr.length === 1 ? true : attrsArr[1];
99
- });
100
- return [ cookieName, attrs ];
101
- }
102
-
103
- stringifyEntry(cookieBody) {
104
- if (_isObject(cookieBody)) {
105
- let attrsArr = [ cookieBody.value ];
106
- for (let attrName in cookieBody) {
107
- if (attrName === 'value') continue;
108
- let _attrName = attrName[0].toUpperCase() + attrName.substring(1);
109
- if (_attrName === 'MaxAge') { _attrName = 'Max-Age' };
110
- attrsArr.push(cookieBody[attrName] === true ? _attrName : `${_attrName}=${cookieBody[attrName]}`);
111
- }
112
- cookieBody = attrsArr.join(';');
113
- }
114
- return cookieBody;
115
- }
116
-
117
- }
@@ -1,102 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { _isTypeObject } from '@webqit/util/js/index.js';
6
- import xFormData from './xFormData.js';
7
-
8
- /**
9
- * The _Request Mixin
10
- */
11
- const xxHttpMessage = (whatwagHttpMessage, xHeaders) => {
12
- const HttpMessage = class extends whatwagHttpMessage {
13
-
14
- constructor(input, init, meta) {
15
- // ------------
16
- if (init.headers) { init = { ...init, headers: new xHeaders(init.headers) }; }
17
- super(input, init);
18
- if (meta.headers) { this.headers.json(meta.headers); }
19
- // ------------
20
- let attrs = {};
21
- Object.defineProperty(this, '_attrs', { get: () => attrs });
22
- Object.defineProperty(this, 'meta', { get: () => meta });
23
- }
24
-
25
- get attrs() {
26
- return this._attrs || {};
27
- }
28
-
29
- clone() {
30
- return new this.constructor(super.clone());
31
- }
32
-
33
- get headers() {
34
- xHeaders.compat(super.headers);
35
- return super.headers;
36
- }
37
-
38
- get url() {
39
- return 'url' in this.attrs ? this.attrs.url : super.url;
40
- }
41
-
42
- async arrayBuffer() {
43
- if (this.meta.type === 'ArrayBuffer') { return this.meta.body; }
44
- return super.arrayBuffer();
45
- }
46
-
47
- async blob() {
48
- if (['Blob', 'File'].includes(this.meta.type)) { return this.meta.body; }
49
- return super.blob();
50
- }
51
-
52
- async formData() {
53
- let formData;
54
- if (this.meta.type === 'FormData' && this.meta.body instanceof FormData) {
55
- formData = this.meta.body;
56
- } else { formData = await super.formData(); }
57
- if (formData) { formData = xFormData.compat(formData); }
58
- return formData;
59
- }
60
-
61
- async json() {
62
- if (this.meta.type === 'json' && _isTypeObject(this.meta.body)) { return this.meta.body; }
63
- return super.json();
64
- }
65
-
66
- async text() {
67
- if (this.meta.type === 'json' && !_isTypeObject(this.meta.body)) { return this.meta.body; }
68
- return super.text();
69
- }
70
-
71
- // Resolve
72
- jsonfy(force = false) {
73
- if (!this.meta.jsonfied || force) {
74
- this.meta.jsonfied = new Promise(async (resolve, reject) => {
75
- let jsonfied;
76
- let contentType = this.headers.get('Content-Type') || '';
77
- try {
78
- if (contentType === 'application/x-www-form-urlencoded' || contentType.startsWith('multipart/form-data')) {
79
- const formData = await this.formData();
80
- jsonfied = await formData?.json();
81
- } else if (contentType === 'application/json') {
82
- jsonfied = await this.json();
83
- } else if (contentType === 'text/plain') {
84
- jsonfied = await this.text();
85
- }
86
- resolve(jsonfied);
87
- } catch(e) {
88
- reject(e);
89
- }
90
- });
91
- }
92
- return this.meta.jsonfied;
93
- }
94
-
95
- };
96
- // ----------
97
- HttpMessage.Headers = xHeaders;
98
- // ----------
99
- return HttpMessage;
100
- }
101
-
102
- export default xxHttpMessage;