@optionfactory/fml 8.0.3 → 9.0.0-rc1
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/LICENSE.md +7 -0
- package/README.md +88 -0
- package/dist/client-errors.iife.js +30 -9
- package/dist/client-errors.iife.js.map +1 -1
- package/dist/client-errors.iife.min.js +1 -1
- package/dist/client-errors.iife.min.js.map +1 -1
- package/dist/custom-elements.json +1529 -435
- package/dist/fml.css +21 -10
- package/dist/fml.css.map +1 -1
- package/dist/fml.d.mts +3 -1322
- package/dist/fml.iife.js +5267 -2276
- package/dist/fml.iife.js.map +1 -1
- package/dist/fml.iife.min.js +1 -1
- package/dist/fml.iife.min.js.map +1 -1
- package/dist/fml.min.mjs +1 -1
- package/dist/fml.min.mjs.map +1 -1
- package/dist/fml.mjs +6 -8737
- package/dist/fml.mjs.map +1 -1
- package/dist/ftl.d.mts +430 -92
- package/dist/ftl.iife.js +1314 -809
- package/dist/ftl.iife.js.map +1 -1
- package/dist/ftl.iife.min.js +1 -1
- package/dist/ftl.iife.min.js.map +1 -1
- package/dist/ftl.min.mjs +1 -1
- package/dist/ftl.min.mjs.map +1 -1
- package/dist/ftl.mjs +1313 -810
- package/dist/ftl.mjs.map +1 -1
- package/dist/ful.css +21 -10
- package/dist/ful.css.map +1 -1
- package/dist/ful.d.mts +801 -252
- package/dist/ful.iife.js +3677 -1378
- 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 +3666 -1378
- package/dist/ful.mjs.map +1 -1
- package/dist/httpc.d.mts +114 -19
- package/dist/httpc.iife.js +253 -83
- package/dist/httpc.iife.js.map +1 -1
- package/dist/httpc.iife.min.js +1 -1
- package/dist/httpc.iife.min.js.map +1 -1
- package/dist/httpc.min.mjs +1 -1
- package/dist/httpc.min.mjs.map +1 -1
- package/dist/httpc.mjs +250 -84
- package/dist/httpc.mjs.map +1 -1
- package/dist/vscode.html-custom-data.json +600 -58
- package/dist/web-types.json +1475 -380
- package/package.json +16 -8
package/dist/httpc.d.mts
CHANGED
|
@@ -7,6 +7,11 @@ export type Problem = {
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {{ type: string; context: string?; reason: string; details: any?; }} Problem
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* An error carrying a list of problems rather than one message. A problem's
|
|
12
|
+
* `context` names the field it belongs to, which is what lets a form show each
|
|
13
|
+
* one beside its own input instead of in a banner.
|
|
14
|
+
*/
|
|
10
15
|
declare class Failure extends Error {
|
|
11
16
|
problems: Problem[];
|
|
12
17
|
/**
|
|
@@ -16,21 +21,71 @@ declare class Failure extends Error {
|
|
|
16
21
|
* @param {*} cause
|
|
17
22
|
*/
|
|
18
23
|
constructor(message: string, problems: Problem[], cause: any);
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns a copy whose problems' contexts have the prefix removed, so a
|
|
26
|
+
* caller can rethrow namespaced problems as its own.
|
|
27
|
+
* @param {string} prefix
|
|
28
|
+
* @returns {Failure}
|
|
29
|
+
*/
|
|
30
|
+
dropping(prefix: string): Failure;
|
|
31
|
+
/**
|
|
32
|
+
* @param {Problem[]} problems
|
|
33
|
+
* @param {string} prefix
|
|
34
|
+
* @returns {Problem[]}
|
|
35
|
+
*/
|
|
36
|
+
static dropProblemsContext(problems: Problem[], prefix: string): Problem[];
|
|
37
|
+
/**
|
|
38
|
+
* The one reading of a failure: its problems' reasons, one per line, or
|
|
39
|
+
* the fallback when the value carries none. An empty problems array
|
|
40
|
+
* carries nothing: the failure's own message reads instead.
|
|
41
|
+
*
|
|
42
|
+
* @param {any} cause
|
|
43
|
+
* @param {string|null} [fallback]
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
static problemsText(cause: any, fallback?: string | null): string;
|
|
21
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Base64 encoding and decoding over ArrayBuffers, in the STANDARD and URL_SAFE
|
|
50
|
+
* alphabets. The encoder never emits padding; the decoder accepts both padded
|
|
51
|
+
* and unpadded input, and rejects anything it cannot decode faithfully instead
|
|
52
|
+
* of corrupting silently.
|
|
53
|
+
*/
|
|
22
54
|
declare class Base64 {
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
/**
|
|
56
|
+
* @param {ArrayBuffer} arrayBuffer
|
|
57
|
+
* @param {string} [dialect] one of Base64.STANDARD or Base64.URL_SAFE, URL_SAFE by default
|
|
58
|
+
* @returns {string} the unpadded encoding
|
|
59
|
+
*/
|
|
60
|
+
static encode(arrayBuffer: ArrayBuffer, dialect?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} str
|
|
63
|
+
* @param {string} [dialect] one of Base64.STANDARD or Base64.URL_SAFE, URL_SAFE by default
|
|
64
|
+
* @returns {ArrayBuffer}
|
|
65
|
+
*/
|
|
66
|
+
static decode(str: string, dialect?: string): ArrayBuffer;
|
|
25
67
|
}
|
|
26
68
|
declare namespace Base64 {
|
|
27
69
|
var STANDARD: string;
|
|
28
70
|
var URL_SAFE: string;
|
|
29
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Hex encoding and decoding over byte sequences, lowercase by default.
|
|
74
|
+
*/
|
|
30
75
|
declare class Hex {
|
|
31
|
-
|
|
32
|
-
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} hex
|
|
78
|
+
* @returns {Uint8Array}
|
|
79
|
+
*/
|
|
80
|
+
static decode(hex: string): Uint8Array;
|
|
81
|
+
/**
|
|
82
|
+
* @param {Iterable<number>} bytes
|
|
83
|
+
* @param {boolean} [upper]
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
86
|
+
static encode(bytes: Iterable<number>, upper?: boolean): string;
|
|
33
87
|
}
|
|
88
|
+
/** A parsed `Content-Type`: the type and subtype without the parameters, so a comparison is not defeated by a charset. */
|
|
34
89
|
declare class MediaType {
|
|
35
90
|
#private;
|
|
36
91
|
constructor(type: any, subtype: any);
|
|
@@ -38,7 +93,7 @@ declare class MediaType {
|
|
|
38
93
|
get type(): any;
|
|
39
94
|
get subtype(): any;
|
|
40
95
|
/**
|
|
41
|
-
*
|
|
96
|
+
* Parses a Content-Type header value into its type/subtype pair, dropping any parameter.
|
|
42
97
|
* @param {string|null|undefined} v
|
|
43
98
|
* @returns
|
|
44
99
|
*/
|
|
@@ -55,7 +110,13 @@ export type HttpInterceptor = {
|
|
|
55
110
|
* @typedef {object} HttpInterceptor
|
|
56
111
|
* @property {(url: URL, init: RequestInit|undefined, chain: HttpInterceptorChain) => Promise<Response>} intercept
|
|
57
112
|
*/
|
|
113
|
+
/**
|
|
114
|
+
* A Failure from an http exchange, carrying the status that was served. Status
|
|
115
|
+
* 0 means no response was served at all: the transport failed, or a body the
|
|
116
|
+
* server did send could not be read.
|
|
117
|
+
*/
|
|
58
118
|
declare class HttpClientError extends Failure {
|
|
119
|
+
#private;
|
|
59
120
|
status: number;
|
|
60
121
|
/**
|
|
61
122
|
* @param {string} message
|
|
@@ -69,9 +130,27 @@ declare class HttpClientError extends Failure {
|
|
|
69
130
|
reason: string;
|
|
70
131
|
details: any | null;
|
|
71
132
|
}[], cause?: Error | undefined);
|
|
72
|
-
dropping(prefix: any): HttpClientError;
|
|
73
133
|
/**
|
|
74
|
-
*
|
|
134
|
+
* Returns a copy whose problems' contexts have the prefix removed, keeping
|
|
135
|
+
* this error's status.
|
|
136
|
+
* @param {string} prefix
|
|
137
|
+
* @returns {HttpClientError}
|
|
138
|
+
*/
|
|
139
|
+
dropping(prefix: string): HttpClientError;
|
|
140
|
+
/**
|
|
141
|
+
* One problem of the client's own making: the four the client mints are the
|
|
142
|
+
* same shape, and the server's arrive already shaped from the wire.
|
|
143
|
+
* @param {string} type
|
|
144
|
+
* @param {string} reason
|
|
145
|
+
*/
|
|
146
|
+
static problem(type: string, reason: string): {
|
|
147
|
+
type: string;
|
|
148
|
+
context: null;
|
|
149
|
+
reason: string;
|
|
150
|
+
details: null;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Creates a client failure carrying no status, wrapping the cause and its message.
|
|
75
154
|
* @param {string} type
|
|
76
155
|
* @param {any} cause
|
|
77
156
|
* @returns
|
|
@@ -84,6 +163,7 @@ declare class HttpClientError extends Failure {
|
|
|
84
163
|
*/
|
|
85
164
|
static fromResponse(response: Response): Promise<HttpClientError>;
|
|
86
165
|
}
|
|
166
|
+
/** Collects the interceptors an HttpClient will run, in the order they are added. */
|
|
87
167
|
declare class HttpClientBuilder {
|
|
88
168
|
#private;
|
|
89
169
|
constructor();
|
|
@@ -95,6 +175,7 @@ declare class HttpClientBuilder {
|
|
|
95
175
|
withInterceptors(...interceptors: HttpInterceptor[]): this;
|
|
96
176
|
build(): HttpClient;
|
|
97
177
|
}
|
|
178
|
+
/** One request's position in the interceptor list: `proceed` runs the next interceptor, the last of which performs the request. */
|
|
98
179
|
declare class HttpInterceptorChain {
|
|
99
180
|
#private;
|
|
100
181
|
/**
|
|
@@ -111,6 +192,11 @@ declare class HttpInterceptorChain {
|
|
|
111
192
|
*/
|
|
112
193
|
proceed(url: URL, request: RequestInit): Promise<Response>;
|
|
113
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Performs http requests through a fixed list of interceptors. The verbs
|
|
197
|
+
* return a request builder; `exchange` is the lower-level entry that returns
|
|
198
|
+
* the Response itself without treating an error status as a failure.
|
|
199
|
+
*/
|
|
114
200
|
declare class HttpClient {
|
|
115
201
|
#private;
|
|
116
202
|
/**
|
|
@@ -176,6 +262,12 @@ declare class HttpClient {
|
|
|
176
262
|
*/
|
|
177
263
|
delete(uri: string): HttpRequestBuilder;
|
|
178
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* One request under construction: method, url, parameters, headers and body,
|
|
267
|
+
* with a `fetch*` method per body type. Every configuration method returns the
|
|
268
|
+
* builder, and a `fetch*` rejects with an HttpClientError for any status
|
|
269
|
+
* outside 200-299.
|
|
270
|
+
*/
|
|
179
271
|
declare class HttpRequestBuilder {
|
|
180
272
|
#private;
|
|
181
273
|
/**
|
|
@@ -196,8 +288,9 @@ declare class HttpRequestBuilder {
|
|
|
196
288
|
* @param {any} body
|
|
197
289
|
* @param {Omit<RequestInit,"headers"|"method"|"body">} options
|
|
198
290
|
* @param {HttpInterceptor[]} interceptors
|
|
291
|
+
* @param {string} [fragment]
|
|
199
292
|
*/
|
|
200
|
-
constructor(client: HttpClient, method: string, uri: string, params: URLSearchParams, headers: Headers, body: any, options: Omit<RequestInit, "headers" | "method" | "body">, interceptors: HttpInterceptor[]);
|
|
293
|
+
constructor(client: HttpClient, method: string, uri: string, params: URLSearchParams, headers: Headers, body: any, options: Omit<RequestInit, "headers" | "method" | "body">, interceptors: HttpInterceptor[], fragment?: string);
|
|
201
294
|
/**
|
|
202
295
|
* 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.
|
|
203
296
|
* @param {HeadersInit|Record<string,string|null|undefined>} hs
|
|
@@ -218,7 +311,7 @@ declare class HttpRequestBuilder {
|
|
|
218
311
|
*/
|
|
219
312
|
params(ps: URLSearchParams | Record<string, string | null | undefined> | string[][] | string): HttpRequestBuilder;
|
|
220
313
|
/**
|
|
221
|
-
* Adds a query parameter to the request, overriding it if it already exists.
|
|
314
|
+
* Adds a query parameter to the request, overriding it if it already exists. An empty list, or one carrying only null and undefined values, causes the key to be removed; nullish entries among real values are skipped.
|
|
222
315
|
* @param {string} k
|
|
223
316
|
* @param {...string} vs
|
|
224
317
|
* @returns {HttpRequestBuilder} this builder
|
|
@@ -260,13 +353,13 @@ declare class HttpRequestBuilder {
|
|
|
260
353
|
option(k: keyof Omit<RequestInit, "headers" | "method" | "body">, v: any): HttpRequestBuilder;
|
|
261
354
|
/**
|
|
262
355
|
* Adds interceptors to the request.
|
|
263
|
-
* @param {[HttpInterceptor]} is - the interceptor to be
|
|
356
|
+
* @param {[HttpInterceptor]} is - the interceptor to be registered
|
|
264
357
|
* @returns {HttpRequestBuilder} this builder
|
|
265
358
|
*/
|
|
266
359
|
interceptors(is: [HttpInterceptor]): HttpRequestBuilder;
|
|
267
360
|
/**
|
|
268
361
|
* Adds an interceptor to the request.
|
|
269
|
-
* @param {HttpInterceptor} i - the interceptor to be
|
|
362
|
+
* @param {HttpInterceptor} i - the interceptor to be registered
|
|
270
363
|
* @returns {HttpRequestBuilder} this builder
|
|
271
364
|
*/
|
|
272
365
|
interceptor(i: HttpInterceptor): HttpRequestBuilder;
|
|
@@ -276,31 +369,33 @@ declare class HttpRequestBuilder {
|
|
|
276
369
|
*/
|
|
277
370
|
exchange(): Promise<Response>;
|
|
278
371
|
/**
|
|
279
|
-
* Performs an HTTP exchange using the configured client request, and
|
|
372
|
+
* Performs an HTTP exchange using the configured client request, and interceptors throwing a failure when response status is not in the 200-299 range.
|
|
280
373
|
* @returns {Promise<Response>} the response
|
|
281
374
|
*/
|
|
282
375
|
fetch(): Promise<Response>;
|
|
283
376
|
/**
|
|
284
|
-
* Performs an HTTP exchange using the configured client request, and
|
|
377
|
+
* Performs an HTTP exchange using the configured client request, and interceptors throwing a failure when response status is not in the 200-299 range.
|
|
285
378
|
* @returns {Promise<string>} the response body, as text
|
|
286
379
|
*/
|
|
287
380
|
fetchText(): Promise<string>;
|
|
288
381
|
/**
|
|
289
|
-
* Performs an HTTP exchange using the configured client request, and
|
|
382
|
+
* Performs an HTTP exchange using the configured client request, and interceptors throwing a failure when response status is not in the 200-299 range.
|
|
383
|
+
* A 204 yields null without reading the body; any other empty body is an unmarshaling failure.
|
|
290
384
|
* @returns {Promise<any>} the response body, deserialized as JSON
|
|
291
385
|
*/
|
|
292
386
|
fetchJson(): Promise<any>;
|
|
293
387
|
/**
|
|
294
|
-
* Performs an HTTP exchange using the configured client request, and
|
|
388
|
+
* Performs an HTTP exchange using the configured client request, and interceptors throwing a failure when response status is not in the 200-299 range.
|
|
295
389
|
* @returns {Promise<Blob>} the response body, as a Blob
|
|
296
390
|
*/
|
|
297
391
|
fetchBlob(): Promise<Blob>;
|
|
298
392
|
/**
|
|
299
|
-
* Performs an HTTP exchange using the configured client request, and
|
|
393
|
+
* Performs an HTTP exchange using the configured client request, and interceptors throwing a failure when response status is not in the 200-299 range.
|
|
300
394
|
* @returns {Promise<ArrayBuffer>} the response body, as an ArrayBuffer
|
|
301
395
|
*/
|
|
302
396
|
fetchArrayBuffer(): Promise<ArrayBuffer>;
|
|
303
397
|
}
|
|
398
|
+
/** Builds a multipart body: text fields, json parts, and single or repeated blobs. */
|
|
304
399
|
declare class HttpMultipartRequestCustomizer {
|
|
305
400
|
#private;
|
|
306
401
|
/**
|
|
@@ -344,6 +439,6 @@ declare class HttpMultipartRequestCustomizer {
|
|
|
344
439
|
*/
|
|
345
440
|
json(name: string, value: any, filename: string | undefined): this;
|
|
346
441
|
}
|
|
347
|
-
export { Base64, Failure, Hex, HttpClient, HttpClientError, MediaType };
|
|
442
|
+
export { Base64, Failure, Hex, HttpClient, HttpClientBuilder, HttpClientError, HttpInterceptorChain, HttpMultipartRequestCustomizer, HttpRequestBuilder, MediaType };
|
|
348
443
|
|
|
349
444
|
export as namespace httpc;
|