@optionfactory/ful 0.92.0 → 0.94.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.
- package/dist/ful.iife.js +73 -26
- package/dist/ful.iife.js.map +1 -1
- package/dist/ful.iife.min.js +1 -1
- package/dist/ful.iife.min.js.map +1 -1
- package/dist/ful.min.mjs +1 -1
- package/dist/ful.min.mjs.map +1 -1
- package/dist/ful.mjs +73 -27
- package/dist/ful.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ful.mjs
CHANGED
|
@@ -87,6 +87,38 @@ class Failure extends Error {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
class MediaType {
|
|
91
|
+
#type;
|
|
92
|
+
#subtype;
|
|
93
|
+
constructor(type, subtype) {
|
|
94
|
+
this.#type = type;
|
|
95
|
+
this.#subtype = subtype;
|
|
96
|
+
}
|
|
97
|
+
get normalized(){
|
|
98
|
+
return `${this.#type}/${this.#subtype}`;
|
|
99
|
+
}
|
|
100
|
+
get type() {
|
|
101
|
+
return this.#type;
|
|
102
|
+
}
|
|
103
|
+
get subtype() {
|
|
104
|
+
return this.#subtype;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @param {string|null|undefined} v
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
111
|
+
static parse(v) {
|
|
112
|
+
if (!v) {
|
|
113
|
+
return new MediaType("unknown", "unknown");
|
|
114
|
+
}
|
|
115
|
+
const [prefix, _] = v.split(";");
|
|
116
|
+
const [ptype, psubtype] = prefix.trim().split("/");
|
|
117
|
+
return new MediaType(ptype.toLowerCase(), psubtype?.toLowerCase());
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
90
122
|
/**
|
|
91
123
|
* @typedef {Int8Array| Uint8Array| Uint8ClampedArray| Int16Array| Uint16Array| Int32Array| Uint32Array| Float32Array| Float64Array| BigInt64Array| BigUint64Array} TypedArray
|
|
92
124
|
*/
|
|
@@ -127,18 +159,32 @@ class HttpClientError extends Failure {
|
|
|
127
159
|
* @returns an HttpClientError
|
|
128
160
|
*/
|
|
129
161
|
static async fromResponse(response) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
162
|
+
switch(MediaType.parse(response.headers.get("Content-Type")).normalized){
|
|
163
|
+
case 'application/failures+json': {
|
|
164
|
+
const data = await response.json();
|
|
165
|
+
const message = `${response.status} ${response.statusText}: ${data.length} failures`;
|
|
166
|
+
return new HttpClientError(message, response.status, data);
|
|
167
|
+
}
|
|
168
|
+
case 'application/problem+json': {
|
|
169
|
+
const data = await response.json();
|
|
170
|
+
const message = `${response.status} ${response.statusText}: ${data.title} ${data.detail}`;
|
|
171
|
+
return new HttpClientError(message, response.status, data.problems || [{
|
|
172
|
+
type: "GENERIC_PROBLEM",
|
|
173
|
+
context: null,
|
|
174
|
+
reason: message,
|
|
175
|
+
details: null
|
|
176
|
+
}]);
|
|
177
|
+
}
|
|
178
|
+
default: {
|
|
179
|
+
const text = await response.text();
|
|
180
|
+
const message = `${response.status} ${response.statusText}: ${text}`;
|
|
181
|
+
return new HttpClientError(message, response.status, [{
|
|
182
|
+
type: "GENERIC_PROBLEM",
|
|
183
|
+
context: null,
|
|
184
|
+
reason: message,
|
|
185
|
+
details: null
|
|
186
|
+
}]);
|
|
187
|
+
}
|
|
142
188
|
}
|
|
143
189
|
}
|
|
144
190
|
}
|
|
@@ -151,9 +197,9 @@ class CsrfTokenInterceptor {
|
|
|
151
197
|
constructor() {
|
|
152
198
|
this.#k = document.querySelector("meta[name='_csrf_header']")?.getAttribute("content");
|
|
153
199
|
this.#v = document.querySelector("meta[name='_csrf']")?.getAttribute("content");
|
|
154
|
-
}
|
|
200
|
+
}
|
|
155
201
|
async intercept(request, chain) {
|
|
156
|
-
if(this.#k && this.#v) {
|
|
202
|
+
if (this.#k && this.#v) {
|
|
157
203
|
request.headers.set(this.#k, this.#v);
|
|
158
204
|
}
|
|
159
205
|
return await chain.proceed(request);
|
|
@@ -589,7 +635,7 @@ class HttpMultipartRequestCustomizer {
|
|
|
589
635
|
*
|
|
590
636
|
* @param {FormData} formData
|
|
591
637
|
*/
|
|
592
|
-
constructor(formData){
|
|
638
|
+
constructor(formData) {
|
|
593
639
|
this.#formData = formData;
|
|
594
640
|
}
|
|
595
641
|
/**
|
|
@@ -598,7 +644,7 @@ class HttpMultipartRequestCustomizer {
|
|
|
598
644
|
* @param {*} value
|
|
599
645
|
* @returns this builder
|
|
600
646
|
*/
|
|
601
|
-
field(name, value){
|
|
647
|
+
field(name, value) {
|
|
602
648
|
this.#formData.append(name, value);
|
|
603
649
|
return this;
|
|
604
650
|
}
|
|
@@ -612,10 +658,10 @@ class HttpMultipartRequestCustomizer {
|
|
|
612
658
|
* @param {string|undefined} filename
|
|
613
659
|
* @returns this builder
|
|
614
660
|
*/
|
|
615
|
-
blob(name, value, filename){
|
|
661
|
+
blob(name, value, filename) {
|
|
616
662
|
this.#formData.append(name, value, filename);
|
|
617
663
|
return this;
|
|
618
|
-
}
|
|
664
|
+
}
|
|
619
665
|
/**
|
|
620
666
|
* Appends multiple Blobs to the FormData with the same name.
|
|
621
667
|
* The default filename for Blob objects is "blob";
|
|
@@ -623,13 +669,13 @@ class HttpMultipartRequestCustomizer {
|
|
|
623
669
|
* @param {string} name
|
|
624
670
|
* @param {Blob[]} values
|
|
625
671
|
* @returns this builder
|
|
626
|
-
*/
|
|
627
|
-
blobs(name, values){
|
|
628
|
-
for(let v of values){
|
|
672
|
+
*/
|
|
673
|
+
blobs(name, values) {
|
|
674
|
+
for (let v of values) {
|
|
629
675
|
this.#formData.append(name, v);
|
|
630
676
|
}
|
|
631
677
|
return this;
|
|
632
|
-
}
|
|
678
|
+
}
|
|
633
679
|
/**
|
|
634
680
|
* Appends a JSON serialized blob to the FormData.
|
|
635
681
|
* @param {string} name
|
|
@@ -637,8 +683,8 @@ class HttpMultipartRequestCustomizer {
|
|
|
637
683
|
* @param {string|undefined} filename
|
|
638
684
|
* @returns this builder
|
|
639
685
|
*/
|
|
640
|
-
json(name, value, filename){
|
|
641
|
-
const blob = new Blob([JSON.stringify(value)], {type: 'application/json'});
|
|
686
|
+
json(name, value, filename) {
|
|
687
|
+
const blob = new Blob([JSON.stringify(value)], { type: 'application/json' });
|
|
642
688
|
this.#formData.append(name, blob, filename);
|
|
643
689
|
return this;
|
|
644
690
|
}
|
|
@@ -1327,10 +1373,10 @@ const ParsedElement = (conf) => {
|
|
|
1327
1373
|
enumerable: true,
|
|
1328
1374
|
configurable: true,
|
|
1329
1375
|
get() {
|
|
1330
|
-
return this.internals.states.has(`--${attr}`);
|
|
1376
|
+
return this.internals.states ? this.internals.states.has(`--${attr}`) : this.hasAttribute(attr);
|
|
1331
1377
|
},
|
|
1332
1378
|
set(value) {
|
|
1333
|
-
this.internals.states[value ? 'add' : 'delete'](`--${attr}`);
|
|
1379
|
+
this.internals.states?.[value ? 'add' : 'delete'](`--${attr}`);
|
|
1334
1380
|
this.reflect(() => Attributes.toggle(this, attr, value));
|
|
1335
1381
|
}
|
|
1336
1382
|
});
|
|
@@ -1787,5 +1833,5 @@ class Spinner extends ParsedElement({
|
|
|
1787
1833
|
}
|
|
1788
1834
|
}
|
|
1789
1835
|
|
|
1790
|
-
export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, Deferred, ElementsRegistry, Failure, Form, Fragments, Hex, HttpClient, HttpClientError, INPUT_TEMPLATE, Input, LightSlots, LocalStorage, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Spinner, TemplatesRegistry, VersionedStorage, elements, makeInputFragment, timing };
|
|
1836
|
+
export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, Deferred, ElementsRegistry, Failure, Form, Fragments, Hex, HttpClient, HttpClientError, INPUT_TEMPLATE, Input, LightSlots, LocalStorage, MediaType, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Spinner, TemplatesRegistry, VersionedStorage, elements, makeInputFragment, timing };
|
|
1791
1837
|
//# sourceMappingURL=ful.mjs.map
|