@zthun/webigail-url 5.0.2 → 5.0.3

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.
@@ -1,15 +1,86 @@
1
+ /**
2
+ * Represents information about a data url.
3
+ */
1
4
  export interface IZDataUrlInfo {
5
+ /**
6
+ * The content information mime type.
7
+ */
2
8
  mimeType: string;
9
+ /**
10
+ * The output encoding.
11
+ */
3
12
  encoding: "base64" | "utf8";
13
+ /**
14
+ * The raw data buffer.
15
+ */
4
16
  buffer: Uint8Array;
5
17
  }
18
+ /**
19
+ * Represents an object that is helpful in building a data url with support
20
+ * for data encoding.
21
+ */
6
22
  export declare class ZDataUrlBuilder {
23
+ /**
24
+ * The representation of the data url object.
25
+ */
7
26
  private _data;
27
+ /**
28
+ * Initializes a new instance of this object.
29
+ */
8
30
  constructor();
31
+ /**
32
+ * Parses an existing data url and sets all properties.
33
+ *
34
+ * @param url -
35
+ * The url to parse.
36
+ *
37
+ * @returns
38
+ * This object.
39
+ */
9
40
  parse(url: string): this;
41
+ /**
42
+ * Sets the mime type.
43
+ *
44
+ * @param type -
45
+ * The mime type.
46
+ *
47
+ * @returns
48
+ * This object.
49
+ */
10
50
  mimeType(type: string): this;
51
+ /**
52
+ * Sets the data buffer.
53
+ *
54
+ * @param data -
55
+ * The data to set. If you pass a raw string, then the input encoding
56
+ * is expected to be utf8.
57
+ * @returns
58
+ * This object.
59
+ */
11
60
  buffer(data: string | Uint8Array): this;
61
+ /**
62
+ * Sets the output encoding.
63
+ *
64
+ * If you output encode the data as utf8, then it will be properly
65
+ * escaped.
66
+ *
67
+ * @param encoding -
68
+ * The output encoding.
69
+ *
70
+ * @returns
71
+ * This object.
72
+ */
12
73
  encode(encoding: "base64" | "utf8"): this;
74
+ /**
75
+ * Builds the url string and returns it.
76
+ *
77
+ * @returns The url string.
78
+ */
13
79
  build(): string;
80
+ /**
81
+ * Gets the current information about the url being built.
82
+ *
83
+ * @returns The current information about the url being built.
84
+ */
14
85
  info(): IZDataUrlInfo;
15
86
  }
@@ -1,5 +1,19 @@
1
+ /**
2
+ * Application mime types.
3
+ */
1
4
  export declare enum ZMimeTypeApplication {
5
+ /**
6
+ * JSON data.
7
+ */
2
8
  JSON = "application/json",
9
+ /**
10
+ * The unknown type.
11
+ *
12
+ * Used for raw byte data.
13
+ */
3
14
  OctetStream = "application/octet-stream",
15
+ /**
16
+ * Compressed zip stream.
17
+ */
4
18
  Zip = "application/zip"
5
19
  }
@@ -1,9 +1,48 @@
1
+ /**
2
+ * Mime types for images.
3
+ */
1
4
  export declare enum ZMimeTypeImage {
5
+ /**
6
+ * Good choice for lossless animation sequences (GIF is less performant). AVIF and
7
+ * WebP have better performance but less broad browser support.
8
+ */
2
9
  APNG = "image/apng",
10
+ /**
11
+ * Good choice for both images and animated images due to high performance and
12
+ * royalty free image format. It offers much better compression than PNG or JPEG
13
+ * with support for higher color depths, animated frames, transparency etc.
14
+ *
15
+ * Note that when using AVIF, you should include fallbacks to formats with
16
+ * better browser support (i.e. using the <picture> element).
17
+ */
3
18
  AVIF = "image/avif",
19
+ /**
20
+ * Good choice for simple images and animations. Prefer PNG for lossless and
21
+ * indexed still images, and consider WebP, AVIF or APNG for animation sequences.
22
+ */
4
23
  GIF = "image/gif",
24
+ /**
25
+ * Good choice for lossy compression of still images (currently the most popular). Prefer
26
+ * PNG when more precise reproduction of the image is required, or WebP/AVIF if both better
27
+ * reproduction and higher compression are required.
28
+ */
5
29
  JPEG = "image/jpeg",
30
+ /**
31
+ * PNG is preferred over JPEG for more precise reproduction of source images, or when
32
+ * transparency is needed. WebP/AVIF provide even better compression and reproduction,
33
+ * but browser support is more limited.
34
+ */
6
35
  PNG = "image/png",
36
+ /**
37
+ * Vector image format; ideal for user interface elements, icons, diagrams, etc., that
38
+ * must be drawn accurately at different sizes.
39
+ */
7
40
  SVG = "image/svg+xml",
41
+ /**
42
+ * Excellent choice for both images and animated images. WebP offers much better compression
43
+ * than PNG or JPEG with support for higher color depths, animated frames, transparency etc.
44
+ * AVIF offers slightly better compression, but is not quite as well-supported in browsers
45
+ * and does not support progressive rendering.
46
+ */
8
47
  WebP = "image/webp"
9
48
  }
@@ -1,9 +1,38 @@
1
+ /**
2
+ * Mime types for text based data.
3
+ */
1
4
  export declare enum ZMimeTypeText {
5
+ /**
6
+ * Style files used in html documents must be sent as
7
+ * css.
8
+ */
2
9
  CSS = "text/css",
10
+ /**
11
+ * Comma separated values.
12
+ */
3
13
  CSV = "text/csv",
14
+ /**
15
+ * JavaScript.
16
+ */
4
17
  EcmaScript = "text/ecmascript",
18
+ /**
19
+ * Hyper Text Markup Language. Markup language for
20
+ * web pages.
21
+ */
5
22
  HTML = "text/html",
23
+ /**
24
+ * JavaScript.
25
+ */
6
26
  JavaScript = "text/javascript",
27
+ /**
28
+ * Plain (basic) text.
29
+ */
7
30
  Plain = "text/plain",
31
+ /**
32
+ * Xtreme Markup Language.
33
+ *
34
+ * Superset of HTML. Bulky, but can
35
+ * represent anything.
36
+ */
8
37
  XML = "text/xml"
9
38
  }
@@ -1,7 +1,13 @@
1
1
  import { ZMimeTypeApplication } from './mime-type-application.mjs';
2
2
  import { ZMimeTypeImage } from './mime-type-image.mjs';
3
3
  import { ZMimeTypeText } from './mime-type-text.mjs';
4
+ /**
5
+ * Mime types for file data.
6
+ */
4
7
  export type ZMimeType = ZMimeTypeApplication | ZMimeTypeText | ZMimeTypeImage;
8
+ /**
9
+ * A mapping of supported mime types.
10
+ */
5
11
  export declare const ZSupportedMimeTypes: Readonly<{
6
12
  "": "text/plain;charset=ASCII";
7
13
  }>;
@@ -1,23 +1,76 @@
1
+ /**
2
+ * Represents information about a url.
3
+ */
1
4
  export interface IZUrlInfo {
5
+ /**
6
+ * The protocol for the url.
7
+ */
2
8
  protocol: string;
9
+ /**
10
+ * The username.
11
+ */
3
12
  username?: string;
13
+ /**
14
+ * The password.
15
+ */
4
16
  password?: string;
17
+ /**
18
+ * The host.
19
+ */
5
20
  hostname: string;
21
+ /**
22
+ * The port number.
23
+ */
6
24
  port?: number;
25
+ /**
26
+ * A list of current paths.
27
+ *
28
+ * You can always get the full path using
29
+ * path.join('/')
30
+ */
7
31
  path: string[];
32
+ /**
33
+ * The client side hash route.
34
+ */
8
35
  hash?: string;
36
+ /**
37
+ * The key value params.
38
+ */
9
39
  params: Array<{
10
40
  key: string;
11
41
  val: string;
12
42
  }>;
13
43
  }
44
+ /**
45
+ * The api to target for YouTube.
46
+ */
14
47
  export declare enum ZYouTubeApi {
48
+ /**
49
+ * An embedded video link.
50
+ */
15
51
  Embed = "embed",
52
+ /**
53
+ * A watch video link.
54
+ */
16
55
  Watch = "watch"
17
56
  }
57
+ /**
58
+ * Represents an object that is helpful in building a url.
59
+ */
18
60
  export declare class ZUrlBuilder {
61
+ /**
62
+ * The url to the gravatar api.
63
+ */
19
64
  static UrlGravatar: string;
65
+ /**
66
+ * The url to youtube.
67
+ *
68
+ * This is mostly used to embed videos.
69
+ */
20
70
  static UrlYouTube: string;
71
+ /**
72
+ * A mapping between protocol and default port.
73
+ */
21
74
  static ProtocolPorts: {
22
75
  http: number;
23
76
  https: number;
@@ -27,32 +80,316 @@ export declare class ZUrlBuilder {
27
80
  smtp: number;
28
81
  smb: number;
29
82
  };
83
+ /**
84
+ * Gets whether the given protocols default port is port.
85
+ *
86
+ * The main purpose of this method is to determine if a url requires
87
+ * a port section. Therefore, there are some special behaviors which may
88
+ * not be obvious:
89
+ *
90
+ * 1. If the port is falsy then this method returns true.
91
+ * 2. If the port is NaN, then this method returns true.
92
+ * 3. If the port is a string that evaluates to 0, then this method returns true.
93
+ * 4. If port is less than 0, then this method returns true.
94
+ *
95
+ * @param protocol -
96
+ * The protocol to check.
97
+ * @param port -
98
+ * The port to compare.
99
+ *
100
+ * @returns
101
+ * True if the default port for protocol is port.
102
+ */
30
103
  static defaults(protocol: string, port: string | number): boolean;
104
+ /**
105
+ * The representation of the url object.
106
+ */
31
107
  private readonly _url;
108
+ /**
109
+ * Initializes a new instance of this object.
110
+ *
111
+ * @param protocol -
112
+ * The protocol to use.
113
+ * @param hostname -
114
+ * The hostname to connect with.
115
+ */
32
116
  constructor(protocol?: string, hostname?: string);
117
+ /**
118
+ * Fills the information from the current location data.
119
+ *
120
+ * @param loc -
121
+ * The optional location object to populate with.
122
+ *
123
+ * @returns
124
+ * This object.
125
+ */
33
126
  location(loc: Location): this;
127
+ /**
128
+ * Fills the information for an api path call.
129
+ *
130
+ * This is a combination of location, hash with an empty string, and an
131
+ * append of the basePath.
132
+ *
133
+ * @param loc -
134
+ * The optional location object to populate with.
135
+ * @param basePath -
136
+ * The basePath for the api. Generally, it's best to
137
+ * just keep this as api and have your server accept
138
+ * this path.
139
+ *
140
+ * @returns
141
+ * This object.
142
+ */
34
143
  api(loc: Location, basePath?: string): this;
144
+ /**
145
+ * Parses an existing url and sets all properties.
146
+ *
147
+ * If you give this a path without the protocol and hostname, then it will
148
+ * automatically append the protocol and host of the browser window if it
149
+ * exists.
150
+ *
151
+ * This method sets all the properties so if you need to modify the url before
152
+ * parsing it, it is best to always call this method first.
153
+ *
154
+ * @param url -
155
+ * The url to parse.
156
+ *
157
+ * @returns
158
+ * This object.
159
+ */
35
160
  parse(url: string): this;
161
+ /**
162
+ * Sets the url for a user gravatar.
163
+ *
164
+ * @param hash -
165
+ * The md5 email hash.
166
+ * @param size -
167
+ * The dimensional size of the gravatar image.
168
+ *
169
+ * @returns
170
+ * This object.
171
+ */
36
172
  gravatar(hash?: string, size?: number): this;
173
+ /**
174
+ * Sets the url for a target video on YouTube.
175
+ *
176
+ * @param api -
177
+ * The target api. If this is watch, then
178
+ * it will be a target link to a youTube url.
179
+ * If this is embed, then it will be a target
180
+ * link that can be put into an iframe for
181
+ * embedded youtube videos.
182
+ * @param id -
183
+ * The id of the video to watch.
184
+ *
185
+ * @returns
186
+ * This object.
187
+ */
37
188
  youTube(api: ZYouTubeApi, id: string): this;
189
+ /**
190
+ * Sets the url to the base YouTube domain.
191
+ *
192
+ * @returns
193
+ * This object.
194
+ */
38
195
  youTube(): this;
196
+ /**
197
+ * Sets the protocol.
198
+ *
199
+ * @param protocol -
200
+ * The protocol.
201
+ *
202
+ * @returns
203
+ * This object.
204
+ */
39
205
  protocol(protocol: string): this;
206
+ /**
207
+ * Sets the user name.
208
+ *
209
+ * Used for things like ssh and ftp.
210
+ *
211
+ * @param user -
212
+ * The username
213
+ *
214
+ * @returns
215
+ * This object.
216
+ */
40
217
  username(user: string | undefined): this;
218
+ /**
219
+ * Sets the password.
220
+ *
221
+ * This is only valid if the username is set.
222
+ *
223
+ * @param pwd -
224
+ * The user password.
225
+ *
226
+ * @returns
227
+ * This object.
228
+ */
41
229
  password(pwd: string | undefined): this;
230
+ /**
231
+ * Sets the host name.
232
+ *
233
+ * This sets the entire hostname as the root domain. This
234
+ * will blow away any subdomains added, so it's best to
235
+ * call this method first.
236
+ *
237
+ * @param host -
238
+ * The hostname.
239
+ *
240
+ * @returns
241
+ * This object.
242
+ */
42
243
  hostname(host: string): this;
244
+ /**
245
+ * Adds a subdomain in front of the hostname.
246
+ *
247
+ * If a hostname was never set, then domain becomes the hostname.
248
+ *
249
+ * @param domain -
250
+ * The domain to append.
251
+ *
252
+ * @returns
253
+ * This object.
254
+ */
43
255
  subdomain(domain: string): this;
256
+ /**
257
+ * Removes a subdomain from the current domain.
258
+ *
259
+ * @returns
260
+ * This object.
261
+ */
44
262
  popSubdomain(): this;
263
+ /**
264
+ * Sets the port.
265
+ *
266
+ * @param port -
267
+ * The port.
268
+ *
269
+ * @returns
270
+ * This object.
271
+ */
45
272
  port(port: number | undefined): this;
273
+ /**
274
+ * Removes all existing path segments and restarts the path.
275
+ *
276
+ * @param path -
277
+ * The starting path.
278
+ *
279
+ * @returns
280
+ * This object.
281
+ */
46
282
  path(path: string): this;
283
+ /**
284
+ * Appends a path segment.
285
+ *
286
+ * @param path -
287
+ * The segment to append.
288
+ *
289
+ * @returns
290
+ * This object.
291
+ */
47
292
  append(path: string): this;
293
+ /**
294
+ * Sets the hash section.
295
+ *
296
+ * @param hash -
297
+ * The hash section.
298
+ *
299
+ * @returns
300
+ * This object.
301
+ */
48
302
  hash(hash: string | undefined): this;
303
+ /**
304
+ * Adds a search parameter.
305
+ *
306
+ * This version assumes that value is not null.
307
+ *
308
+ * @param key -
309
+ * The parameter key.
310
+ * @param val -
311
+ * The parameter value.
312
+ *
313
+ * @returns
314
+ * This object.
315
+ */
49
316
  param(key: string, val: string): this;
317
+ /**
318
+ * Removes all duplicate params and adds one with the key to the value.
319
+ *
320
+ * @param key -
321
+ * The parameter key that can have only one.
322
+ * @param val -
323
+ * The parameter value. If this is falsy, then
324
+ * the key is deleted.
325
+ */
50
326
  onlyParam(key: string, val?: string): this;
327
+ /**
328
+ * Adds a page param.
329
+ *
330
+ * @param page -
331
+ * The page param to add. If this null, undefined,
332
+ * or less than 1, then any page param is deleted.
333
+ *
334
+ * @returns
335
+ * This object.
336
+ */
51
337
  page(page?: number | null): this;
338
+ /**
339
+ * Adds a size param.
340
+ *
341
+ * @param size -
342
+ * The size param to add. If this is null, undefined,
343
+ * or less than 0, then any size param is deleted.
344
+ *
345
+ * @returns
346
+ * This object.
347
+ */
52
348
  size(size?: number | null): this;
349
+ /**
350
+ * Adds a search param.
351
+ *
352
+ * @param search -
353
+ * The search param to add. If this is null, undefined,
354
+ * or empty, then any search param is deleted.
355
+ *
356
+ * @returns
357
+ * This object.
358
+ */
53
359
  search(search?: string | null): this;
360
+ /**
361
+ * Adds a filter param.
362
+ *
363
+ * @param filter -
364
+ * The filter param to add. If this is null, undefined,
365
+ * or empty, then any filter param is deleted.
366
+ *
367
+ * @returns
368
+ * This object.
369
+ */
54
370
  filter(filter?: string | null): this;
371
+ /**
372
+ * Adds a sort param.
373
+ *
374
+ * @param sort -
375
+ * The sort param to add. If this is null, undefined,
376
+ * or empty, then any filter param is deleted.
377
+ *
378
+ * @returns
379
+ * This object.
380
+ */
55
381
  sort(sort?: string | null): this;
382
+ /**
383
+ * Builds the url string and returns it.
384
+ *
385
+ * @returns
386
+ * The url string.
387
+ */
56
388
  build(): string;
389
+ /**
390
+ * Gets the current information about the uri being built.
391
+ *
392
+ * @returns The current uri information.
393
+ */
57
394
  info(): IZUrlInfo;
58
395
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zthun/webigail-url",
3
- "version": "5.0.2",
3
+ "version": "5.0.3",
4
4
  "description": "Url parsing and building.",
5
5
  "author": "Anthony Bonta",
6
6
  "license": "MIT",
@@ -25,17 +25,19 @@
25
25
  "access": "public"
26
26
  },
27
27
  "dependencies": {
28
- "@zthun/janitor-build-config": "^19.5.3",
29
- "lodash-es": "^4.17.21",
28
+ "lodash-es": "^4.17.22",
30
29
  "url-parse": "^1.5.10"
31
30
  },
32
31
  "devDependencies": {
33
- "vite": "^7.2.7",
34
- "vitest": "^4.0.15"
32
+ "@zthun/janitor-build-config": "^19.5.4",
33
+ "@zthun/janitor-ts-config": "^19.5.3",
34
+ "typescript": "~5.9.3",
35
+ "vite": "^7.3.0",
36
+ "vitest": "^4.0.16"
35
37
  },
36
38
  "files": [
37
39
  "dist"
38
40
  ],
39
41
  "sideEffects": false,
40
- "gitHead": "a9bb37cb546337dce70e531a66ed08b90751c305"
42
+ "gitHead": "72e9e39897db1a5105194b6b40d5060e537a0a55"
41
43
  }