@optionfactory/ful 0.92.0 → 0.93.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 +71 -24
- 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 +71 -25
- package/dist/ful.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ful.iife.js
CHANGED
|
@@ -90,6 +90,38 @@ var ful = (function (exports) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
class MediaType {
|
|
94
|
+
#type;
|
|
95
|
+
#subtype;
|
|
96
|
+
constructor(type, subtype) {
|
|
97
|
+
this.#type = type;
|
|
98
|
+
this.#subtype = subtype;
|
|
99
|
+
}
|
|
100
|
+
get normalized(){
|
|
101
|
+
return `${this.#type}/${this.#subtype}`;
|
|
102
|
+
}
|
|
103
|
+
get type() {
|
|
104
|
+
return this.#type;
|
|
105
|
+
}
|
|
106
|
+
get subtype() {
|
|
107
|
+
return this.#subtype;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @param {string|null|undefined} v
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
static parse(v) {
|
|
115
|
+
if (!v) {
|
|
116
|
+
return new MediaType("unknown", "unknown");
|
|
117
|
+
}
|
|
118
|
+
const [prefix, _] = v.split(";");
|
|
119
|
+
const [ptype, psubtype] = prefix.trim().split("/");
|
|
120
|
+
return new MediaType(ptype.toLowerCase(), psubtype?.toLowerCase());
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
93
125
|
/**
|
|
94
126
|
* @typedef {Int8Array| Uint8Array| Uint8ClampedArray| Int16Array| Uint16Array| Int32Array| Uint32Array| Float32Array| Float64Array| BigInt64Array| BigUint64Array} TypedArray
|
|
95
127
|
*/
|
|
@@ -130,18 +162,32 @@ var ful = (function (exports) {
|
|
|
130
162
|
* @returns an HttpClientError
|
|
131
163
|
*/
|
|
132
164
|
static async fromResponse(response) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
165
|
+
switch(MediaType.parse(response.headers.get("Content-Type")).normalized){
|
|
166
|
+
case 'application/failures+json': {
|
|
167
|
+
const data = await response.json();
|
|
168
|
+
const message = `${response.status} ${response.statusText}: ${data.length} failures`;
|
|
169
|
+
return new HttpClientError(message, response.status, data);
|
|
170
|
+
}
|
|
171
|
+
case 'application/problem+json': {
|
|
172
|
+
const data = await response.json();
|
|
173
|
+
const message = `${response.status} ${response.statusText}: ${data.title} ${data.detail}`;
|
|
174
|
+
return new HttpClientError(message, response.status, data.problems || [{
|
|
175
|
+
type: "GENERIC_PROBLEM",
|
|
176
|
+
context: null,
|
|
177
|
+
reason: message,
|
|
178
|
+
details: null
|
|
179
|
+
}]);
|
|
180
|
+
}
|
|
181
|
+
default: {
|
|
182
|
+
const text = await response.text();
|
|
183
|
+
const message = `${response.status} ${response.statusText}: ${text}`;
|
|
184
|
+
return new HttpClientError(message, response.status, [{
|
|
185
|
+
type: "GENERIC_PROBLEM",
|
|
186
|
+
context: null,
|
|
187
|
+
reason: message,
|
|
188
|
+
details: null
|
|
189
|
+
}]);
|
|
190
|
+
}
|
|
145
191
|
}
|
|
146
192
|
}
|
|
147
193
|
}
|
|
@@ -154,9 +200,9 @@ var ful = (function (exports) {
|
|
|
154
200
|
constructor() {
|
|
155
201
|
this.#k = document.querySelector("meta[name='_csrf_header']")?.getAttribute("content");
|
|
156
202
|
this.#v = document.querySelector("meta[name='_csrf']")?.getAttribute("content");
|
|
157
|
-
}
|
|
203
|
+
}
|
|
158
204
|
async intercept(request, chain) {
|
|
159
|
-
if(this.#k && this.#v) {
|
|
205
|
+
if (this.#k && this.#v) {
|
|
160
206
|
request.headers.set(this.#k, this.#v);
|
|
161
207
|
}
|
|
162
208
|
return await chain.proceed(request);
|
|
@@ -592,7 +638,7 @@ var ful = (function (exports) {
|
|
|
592
638
|
*
|
|
593
639
|
* @param {FormData} formData
|
|
594
640
|
*/
|
|
595
|
-
constructor(formData){
|
|
641
|
+
constructor(formData) {
|
|
596
642
|
this.#formData = formData;
|
|
597
643
|
}
|
|
598
644
|
/**
|
|
@@ -601,7 +647,7 @@ var ful = (function (exports) {
|
|
|
601
647
|
* @param {*} value
|
|
602
648
|
* @returns this builder
|
|
603
649
|
*/
|
|
604
|
-
field(name, value){
|
|
650
|
+
field(name, value) {
|
|
605
651
|
this.#formData.append(name, value);
|
|
606
652
|
return this;
|
|
607
653
|
}
|
|
@@ -615,10 +661,10 @@ var ful = (function (exports) {
|
|
|
615
661
|
* @param {string|undefined} filename
|
|
616
662
|
* @returns this builder
|
|
617
663
|
*/
|
|
618
|
-
blob(name, value, filename){
|
|
664
|
+
blob(name, value, filename) {
|
|
619
665
|
this.#formData.append(name, value, filename);
|
|
620
666
|
return this;
|
|
621
|
-
}
|
|
667
|
+
}
|
|
622
668
|
/**
|
|
623
669
|
* Appends multiple Blobs to the FormData with the same name.
|
|
624
670
|
* The default filename for Blob objects is "blob";
|
|
@@ -626,13 +672,13 @@ var ful = (function (exports) {
|
|
|
626
672
|
* @param {string} name
|
|
627
673
|
* @param {Blob[]} values
|
|
628
674
|
* @returns this builder
|
|
629
|
-
*/
|
|
630
|
-
blobs(name, values){
|
|
631
|
-
for(let v of values){
|
|
675
|
+
*/
|
|
676
|
+
blobs(name, values) {
|
|
677
|
+
for (let v of values) {
|
|
632
678
|
this.#formData.append(name, v);
|
|
633
679
|
}
|
|
634
680
|
return this;
|
|
635
|
-
}
|
|
681
|
+
}
|
|
636
682
|
/**
|
|
637
683
|
* Appends a JSON serialized blob to the FormData.
|
|
638
684
|
* @param {string} name
|
|
@@ -640,8 +686,8 @@ var ful = (function (exports) {
|
|
|
640
686
|
* @param {string|undefined} filename
|
|
641
687
|
* @returns this builder
|
|
642
688
|
*/
|
|
643
|
-
json(name, value, filename){
|
|
644
|
-
const blob = new Blob([JSON.stringify(value)], {type: 'application/json'});
|
|
689
|
+
json(name, value, filename) {
|
|
690
|
+
const blob = new Blob([JSON.stringify(value)], { type: 'application/json' });
|
|
645
691
|
this.#formData.append(name, blob, filename);
|
|
646
692
|
return this;
|
|
647
693
|
}
|
|
@@ -1807,6 +1853,7 @@ var ful = (function (exports) {
|
|
|
1807
1853
|
exports.Input = Input;
|
|
1808
1854
|
exports.LightSlots = LightSlots;
|
|
1809
1855
|
exports.LocalStorage = LocalStorage;
|
|
1856
|
+
exports.MediaType = MediaType;
|
|
1810
1857
|
exports.Nodes = Nodes;
|
|
1811
1858
|
exports.ParsedElement = ParsedElement;
|
|
1812
1859
|
exports.RadioGroup = RadioGroup;
|