@optionfactory/ful 0.98.0 → 0.100.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 +44 -12
- 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 +44 -12
- package/dist/ful.mjs.map +1 -1
- package/package.json +4 -4
package/dist/ful.mjs
CHANGED
|
@@ -94,7 +94,7 @@ class MediaType {
|
|
|
94
94
|
this.#type = type;
|
|
95
95
|
this.#subtype = subtype;
|
|
96
96
|
}
|
|
97
|
-
get normalized(){
|
|
97
|
+
get normalized() {
|
|
98
98
|
return `${this.#type}/${this.#subtype}`;
|
|
99
99
|
}
|
|
100
100
|
get type() {
|
|
@@ -159,7 +159,7 @@ class HttpClientError extends Failure {
|
|
|
159
159
|
* @returns an HttpClientError
|
|
160
160
|
*/
|
|
161
161
|
static async fromResponse(response) {
|
|
162
|
-
switch(MediaType.parse(response.headers.get("Content-Type")).normalized){
|
|
162
|
+
switch (MediaType.parse(response.headers.get("Content-Type")).normalized) {
|
|
163
163
|
case 'application/failures+json': {
|
|
164
164
|
const data = await response.json();
|
|
165
165
|
const message = `${response.status} ${response.statusText}: ${data.length} failures`;
|
|
@@ -438,45 +438,61 @@ class HttpRequestBuilder {
|
|
|
438
438
|
this.#interceptors = interceptors;
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
|
-
* Add all passed headers to the request, overriding existing ones if that key already exists.
|
|
441
|
+
* Add all passed headers to the request, overriding existing ones if that key already exists. Null and undefined values cause the key to be removed.
|
|
442
442
|
* @param {HeadersInit} hs
|
|
443
443
|
* @returns {HttpRequestBuilder} this builder
|
|
444
444
|
*/
|
|
445
445
|
headers(hs) {
|
|
446
446
|
for (const [k, v] of new Headers(hs).entries()) {
|
|
447
|
-
|
|
447
|
+
if (v === null || v === undefined) {
|
|
448
|
+
this.#headers.delete(k);
|
|
449
|
+
} else {
|
|
450
|
+
this.#headers.set(k, v);
|
|
451
|
+
}
|
|
448
452
|
}
|
|
449
453
|
return this;
|
|
450
454
|
}
|
|
451
455
|
/**
|
|
452
|
-
* Adds an header to the request, overriding it if it already exists.
|
|
456
|
+
* Adds an header to the request, overriding it if it already exists. Null and undefined values cause the key to be removed
|
|
453
457
|
* @param {string} k
|
|
454
458
|
* @param {string} v
|
|
455
459
|
* @returns {HttpRequestBuilder} this builder
|
|
456
460
|
*/
|
|
457
461
|
header(k, v) {
|
|
458
|
-
|
|
462
|
+
if (v === null || v === undefined) {
|
|
463
|
+
this.#headers.delete(k);
|
|
464
|
+
} else {
|
|
465
|
+
this.#headers.set(k, v);
|
|
466
|
+
}
|
|
459
467
|
return this;
|
|
460
468
|
}
|
|
461
469
|
/**
|
|
462
|
-
* Add all query parameters to the request, overriding existing ones if that key already exists.
|
|
470
|
+
* Add all query parameters to the request, overriding existing ones if that key already exists. Null and undefined values cause the key to be removed
|
|
463
471
|
* @param {URLSearchParams|Record<string,string>|string[][]|string} ps
|
|
464
472
|
* @returns {HttpRequestBuilder} this builder
|
|
465
473
|
*/
|
|
466
474
|
params(ps) {
|
|
467
475
|
for (const [k, v] of new URLSearchParams(ps).entries()) {
|
|
468
|
-
|
|
476
|
+
if (v === null || v === undefined) {
|
|
477
|
+
this.#params.delete(k);
|
|
478
|
+
} else {
|
|
479
|
+
this.#params.set(k, v);
|
|
480
|
+
}
|
|
469
481
|
}
|
|
470
482
|
return this;
|
|
471
483
|
}
|
|
472
484
|
/**
|
|
473
|
-
* Adds a query parameter to the request, overriding it if it already exists.
|
|
485
|
+
* Adds a query parameter to the request, overriding it if it already exists. Null and undefined values cause the key to be removed.
|
|
474
486
|
* @param {string} k
|
|
475
487
|
* @param {string} v
|
|
476
488
|
* @returns {HttpRequestBuilder} this builder
|
|
477
489
|
*/
|
|
478
490
|
param(k, v) {
|
|
479
|
-
|
|
491
|
+
if (v === null || v === undefined) {
|
|
492
|
+
this.#params.delete(k);
|
|
493
|
+
} else {
|
|
494
|
+
this.#params.set(k, v);
|
|
495
|
+
}
|
|
480
496
|
return this;
|
|
481
497
|
}
|
|
482
498
|
/**
|
|
@@ -1141,8 +1157,7 @@ class LightSlots {
|
|
|
1141
1157
|
*/
|
|
1142
1158
|
static from(el) {
|
|
1143
1159
|
/** @type [string, Element][] */
|
|
1144
|
-
const namedSlots = Array.from(el.
|
|
1145
|
-
.filter(el => el instanceof Element)
|
|
1160
|
+
const namedSlots = Array.from(el.children)
|
|
1146
1161
|
.filter(el => el.matches('[slot]'))
|
|
1147
1162
|
.map(el => {
|
|
1148
1163
|
el.remove();
|
|
@@ -1172,6 +1187,23 @@ class Nodes {
|
|
|
1172
1187
|
}
|
|
1173
1188
|
return false;
|
|
1174
1189
|
}
|
|
1190
|
+
static queryChildren(node, selector) {
|
|
1191
|
+
for (const c of node.children) {
|
|
1192
|
+
if (c.matches(selector)) {
|
|
1193
|
+
return c;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
return null;
|
|
1197
|
+
}
|
|
1198
|
+
queryChildrenAll(node, selector) {
|
|
1199
|
+
const r = [];
|
|
1200
|
+
for (const c of node.children) {
|
|
1201
|
+
if (c.matches(selector)) {
|
|
1202
|
+
r.push(c);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
return r;
|
|
1206
|
+
}
|
|
1175
1207
|
}
|
|
1176
1208
|
|
|
1177
1209
|
class TemplatesRegistry {
|