inferred-types 1.2.2 → 1.2.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.
@@ -169,6 +169,309 @@ const WHITESPACE_CHARS = [
169
169
  "\b"
170
170
  ];
171
171
 
172
+ //#endregion
173
+ //#region ../constants/src/colors.ts
174
+ const CSS_NAMED_COLORS = [
175
+ "aliceblue",
176
+ "antiquewhite",
177
+ "aqua",
178
+ "aquamarine",
179
+ "azure",
180
+ "beige",
181
+ "bisque",
182
+ "black",
183
+ "blanchedalmond",
184
+ "blue",
185
+ "blueviolet",
186
+ "brown",
187
+ "burlywood",
188
+ "cadetblue",
189
+ "chartreuse",
190
+ "chocolate",
191
+ "coral",
192
+ "cornflowerblue",
193
+ "cornsilk",
194
+ "crimson",
195
+ "cyan",
196
+ "darkblue",
197
+ "darkcyan",
198
+ "darkgoldenrod",
199
+ "darkgray",
200
+ "darkgreen",
201
+ "darkgrey",
202
+ "darkkhaki",
203
+ "darkmagenta",
204
+ "darkolivegreen",
205
+ "darkorange",
206
+ "darkorchid",
207
+ "darkred",
208
+ "darksalmon",
209
+ "darkseagreen",
210
+ "darkslateblue",
211
+ "darkslategray",
212
+ "darkslategrey",
213
+ "darkturquoise",
214
+ "darkviolet",
215
+ "deeppink",
216
+ "deepskyblue",
217
+ "dimgray",
218
+ "dimgrey",
219
+ "dodgerblue",
220
+ "firebrick",
221
+ "floralwhite",
222
+ "forestgreen",
223
+ "fuchsia",
224
+ "gainsboro",
225
+ "ghostwhite",
226
+ "gold",
227
+ "goldenrod",
228
+ "gray",
229
+ "green",
230
+ "greenyellow",
231
+ "grey",
232
+ "honeydew",
233
+ "hotpink",
234
+ "indianred",
235
+ "indigo",
236
+ "ivory",
237
+ "khaki",
238
+ "lavender",
239
+ "lavenderblush",
240
+ "lawngreen",
241
+ "lemonchiffon",
242
+ "lightblue",
243
+ "lightcoral",
244
+ "lightcyan",
245
+ "lightgoldenrodyellow",
246
+ "lightgray",
247
+ "lightgreen",
248
+ "lightgrey",
249
+ "lightpink",
250
+ "lightsalmon",
251
+ "lightseagreen",
252
+ "lightskyblue",
253
+ "lightslategray",
254
+ "lightslategrey",
255
+ "lightsteelblue",
256
+ "lightyellow",
257
+ "lime",
258
+ "limegreen",
259
+ "linen",
260
+ "magenta",
261
+ "maroon",
262
+ "mediumaquamarine",
263
+ "mediumblue",
264
+ "mediumorchid",
265
+ "mediumpurple",
266
+ "mediumseagreen",
267
+ "mediumslateblue",
268
+ "mediumspringgreen",
269
+ "mediumturquoise",
270
+ "mediumvioletred",
271
+ "midnightblue",
272
+ "mintcream",
273
+ "mistyrose",
274
+ "moccasin",
275
+ "navajowhite",
276
+ "navy",
277
+ "oldlace",
278
+ "olive",
279
+ "olivedrab",
280
+ "orange",
281
+ "orangered",
282
+ "orchid",
283
+ "palegoldenrod",
284
+ "palegreen",
285
+ "paleturquoise",
286
+ "palevioletred",
287
+ "papayawhip",
288
+ "peachpuff",
289
+ "peru",
290
+ "pink",
291
+ "plum",
292
+ "powderblue",
293
+ "purple",
294
+ "rebeccapurple",
295
+ "red",
296
+ "rosybrown",
297
+ "royalblue",
298
+ "saddlebrown",
299
+ "salmon",
300
+ "sandybrown",
301
+ "seagreen",
302
+ "seashell",
303
+ "sienna",
304
+ "silver",
305
+ "skyblue",
306
+ "slateblue",
307
+ "slategray",
308
+ "slategrey",
309
+ "snow",
310
+ "springgreen",
311
+ "steelblue",
312
+ "tan",
313
+ "teal",
314
+ "thistle",
315
+ "tomato",
316
+ "turquoise",
317
+ "violet",
318
+ "wheat",
319
+ "white",
320
+ "whitesmoke",
321
+ "yellow",
322
+ "yellowgreen"
323
+ ];
324
+ const CSS_COLOR_LOOKUP = {
325
+ aliceblue: "rgb(240,248,255)",
326
+ antiquewhite: "rgb(250,235,215)",
327
+ aqua: "rgb(0,255,255)",
328
+ aquamarine: "rgb(127,255,212)",
329
+ azure: "rgb(240,255,255)",
330
+ beige: "rgb(245,245,220)",
331
+ bisque: "rgb(255,228,196)",
332
+ black: "rgb(0,0,0)",
333
+ blanchedalmond: "rgb(255,235,205)",
334
+ blue: "rgb(0,0,255)",
335
+ blueviolet: "rgb(138,43,226)",
336
+ brown: "rgb(165,42,42)",
337
+ burlywood: "rgb(222,184,135)",
338
+ cadetblue: "rgb(95,158,160)",
339
+ chartreuse: "rgb(127,255,0)",
340
+ chocolate: "rgb(210,105,30)",
341
+ coral: "rgb(255,127,80)",
342
+ cornflowerblue: "rgb(100,149,237)",
343
+ cornsilk: "rgb(255,248,220)",
344
+ crimson: "rgb(220,20,60)",
345
+ cyan: "rgb(0,255,255)",
346
+ darkblue: "rgb(0,0,139)",
347
+ darkcyan: "rgb(0,139,139)",
348
+ darkgoldenrod: "rgb(184,134,11)",
349
+ darkgray: "rgb(169,169,169)",
350
+ darkgreen: "rgb(0,100,0)",
351
+ darkgrey: "rgb(169,169,169)",
352
+ darkkhaki: "rgb(189,183,107)",
353
+ darkmagenta: "rgb(139,0,139)",
354
+ darkolivegreen: "rgb(85,107,47)",
355
+ darkorange: "rgb(255,140,0)",
356
+ darkorchid: "rgb(153,50,204)",
357
+ darkred: "rgb(139,0,0)",
358
+ darksalmon: "rgb(233,150,122)",
359
+ darkseagreen: "rgb(143,188,143)",
360
+ darkslateblue: "rgb(72,61,139)",
361
+ darkslategray: "rgb(47,79,79)",
362
+ darkslategrey: "rgb(47,79,79)",
363
+ darkturquoise: "rgb(0,206,209)",
364
+ darkviolet: "rgb(148,0,211)",
365
+ deeppink: "rgb(255,20,147)",
366
+ deepskyblue: "rgb(0,191,255)",
367
+ dimgray: "rgb(105,105,105)",
368
+ dimgrey: "rgb(105,105,105)",
369
+ dodgerblue: "rgb(30,144,255)",
370
+ firebrick: "rgb(178,34,34)",
371
+ floralwhite: "rgb(255,250,240)",
372
+ forestgreen: "rgb(34,139,34)",
373
+ fuchsia: "rgb(255,0,255)",
374
+ gainsboro: "rgb(220,220,220)",
375
+ ghostwhite: "rgb(248,248,255)",
376
+ gold: "rgb(255,215,0)",
377
+ goldenrod: "rgb(218,165,32)",
378
+ gray: "rgb(128,128,128)",
379
+ green: "rgb(0,128,0)",
380
+ greenyellow: "rgb(173,255,47)",
381
+ grey: "rgb(128,128,128)",
382
+ honeydew: "rgb(240,255,240)",
383
+ hotpink: "rgb(255,105,180)",
384
+ indianred: "rgb(205,92,92)",
385
+ indigo: "rgb(75,0,130)",
386
+ ivory: "rgb(255,255,240)",
387
+ khaki: "rgb(240,230,140)",
388
+ lavender: "rgb(230,230,250)",
389
+ lavenderblush: "rgb(255,240,245)",
390
+ lawngreen: "rgb(124,252,0)",
391
+ lemonchiffon: "rgb(255,250,205)",
392
+ lightblue: "rgb(173,216,230)",
393
+ lightcoral: "rgb(240,128,128)",
394
+ lightcyan: "rgb(224,255,255)",
395
+ lightgoldenrodyellow: "rgb(250,250,210)",
396
+ lightgray: "rgb(211,211,211)",
397
+ lightgreen: "rgb(144,238,144)",
398
+ lightgrey: "rgb(211,211,211)",
399
+ lightpink: "rgb(255,182,193)",
400
+ lightsalmon: "rgb(255,160,122)",
401
+ lightseagreen: "rgb(32,178,170)",
402
+ lightskyblue: "rgb(135,206,250)",
403
+ lightslategray: "rgb(119,136,153)",
404
+ lightslategrey: "rgb(119,136,153)",
405
+ lightsteelblue: "rgb(176,196,222)",
406
+ lightyellow: "rgb(255,255,224)",
407
+ lime: "rgb(0,255,0)",
408
+ limegreen: "rgb(50,205,50)",
409
+ linen: "rgb(250,240,230)",
410
+ magenta: "rgb(255,0,255)",
411
+ maroon: "rgb(128,0,0)",
412
+ mediumaquamarine: "rgb(102,205,170)",
413
+ mediumblue: "rgb(0,0,205)",
414
+ mediumorchid: "rgb(186,85,211)",
415
+ mediumpurple: "rgb(147,112,219)",
416
+ mediumseagreen: "rgb(60,179,113)",
417
+ mediumslateblue: "rgb(123,104,238)",
418
+ mediumspringgreen: "rgb(0,250,154)",
419
+ mediumturquoise: "rgb(72,209,204)",
420
+ mediumvioletred: "rgb(199,21,133)",
421
+ midnightblue: "rgb(25,25,112)",
422
+ mintcream: "rgb(245,255,250)",
423
+ mistyrose: "rgb(255,228,225)",
424
+ moccasin: "rgb(255,228,181)",
425
+ navajowhite: "rgb(255,222,173)",
426
+ navy: "rgb(0,0,128)",
427
+ oldlace: "rgb(253,245,230)",
428
+ olive: "rgb(128,128,0)",
429
+ olivedrab: "rgb(107,142,35)",
430
+ orange: "rgb(255,165,0)",
431
+ orangered: "rgb(255,69,0)",
432
+ orchid: "rgb(218,112,214)",
433
+ palegoldenrod: "rgb(238,232,170)",
434
+ palegreen: "rgb(152,251,152)",
435
+ paleturquoise: "rgb(175,238,238)",
436
+ palevioletred: "rgb(219,112,147)",
437
+ papayawhip: "rgb(255,239,213)",
438
+ peachpuff: "rgb(255,218,185)",
439
+ peru: "rgb(205,133,63)",
440
+ pink: "rgb(255,192,203)",
441
+ plum: "rgb(221,160,221)",
442
+ powderblue: "rgb(176,224,230)",
443
+ purple: "rgb(128,0,128)",
444
+ rebeccapurple: "rgb(102,51,153)",
445
+ red: "rgb(255,0,0)",
446
+ rosybrown: "rgb(188,143,143)",
447
+ royalblue: "rgb(65,105,225)",
448
+ saddlebrown: "rgb(139,69,19)",
449
+ salmon: "rgb(250,128,114)",
450
+ sandybrown: "rgb(244,164,96)",
451
+ seagreen: "rgb(46,139,87)",
452
+ seashell: "rgb(255,245,238)",
453
+ sienna: "rgb(160,82,45)",
454
+ silver: "rgb(192,192,192)",
455
+ skyblue: "rgb(135,206,235)",
456
+ slateblue: "rgb(106,90,205)",
457
+ slategray: "rgb(112,128,144)",
458
+ slategrey: "rgb(112,128,144)",
459
+ snow: "rgb(255,250,250)",
460
+ springgreen: "rgb(0,255,127)",
461
+ steelblue: "rgb(70,130,180)",
462
+ tan: "rgb(210,180,140)",
463
+ teal: "rgb(0,128,128)",
464
+ thistle: "rgb(216,191,216)",
465
+ tomato: "rgb(255,99,71)",
466
+ turquoise: "rgb(64,224,208)",
467
+ violet: "rgb(238,130,238)",
468
+ wheat: "rgb(245,222,179)",
469
+ white: "rgb(255,255,255)",
470
+ whitesmoke: "rgb(245,245,245)",
471
+ yellow: "rgb(255,255,0)",
472
+ yellowgreen: "rgb(154,205,50)"
473
+ };
474
+
172
475
  //#endregion
173
476
  //#region ../constants/src/Comma.ts
174
477
  /**
@@ -7139,6 +7442,31 @@ function isValidComparisonParams(op, params) {
7139
7442
  return !!isComparisonOperation(op);
7140
7443
  }
7141
7444
 
7445
+ //#endregion
7446
+ //#region src/type-guards/css/isNamedColor.ts
7447
+ /**
7448
+ * **isNamedColor**`(val) -> is CssNamedColor`
7449
+ *
7450
+ * Typeguard to validate that `val` is a CSS/HTML Named Color.
7451
+ *
7452
+ * - to match you must make sure the string name is lowercase
7453
+ */
7454
+ function isNamedColor(val) {
7455
+ return isString(val) && CSS_NAMED_COLORS.includes(val);
7456
+ }
7457
+
7458
+ //#endregion
7459
+ //#region src/type-guards/css/isRgbColor.ts
7460
+ /**
7461
+ * **isRgbColor**`(val) -> is RgbColor`
7462
+ *
7463
+ * Typeguard that validates that `val` is a valid RbgColor (e.g.,
7464
+ * `rgb(127,0,0)`)
7465
+ */
7466
+ function isRgbColor(val) {
7467
+ return isString(val) && val.startsWith("rgb(") && val.endsWith(")");
7468
+ }
7469
+
7142
7470
  //#endregion
7143
7471
  //#region src/type-guards/datetime/isDate.ts
7144
7472
  /**
@@ -12882,6 +13210,46 @@ function defineCss(defn) {
12882
13210
  return createFnWithProps(fn$1, { defn });
12883
13211
  }
12884
13212
 
13213
+ //#endregion
13214
+ //#region src/css/parseColor.ts
13215
+ function parseRgbColor(color) {
13216
+ if (isRgbColor(color)) {
13217
+ const [r, g, b] = stripTrailing(stripLeading(color, "rgb("), ")").split(",").map((i) => i.trim().toLowerCase());
13218
+ return [
13219
+ r,
13220
+ g,
13221
+ b
13222
+ ].every((i) => isNumberLike(i)) ? {
13223
+ r: asNumber(r),
13224
+ g: asNumber(g),
13225
+ b: asNumber(b)
13226
+ } : err(`invalid-color/rgb`, `Some of the values assigned to the RGB colors are unable to be parsed to a numeric value: ${color}`, {
13227
+ color,
13228
+ r,
13229
+ g,
13230
+ b
13231
+ });
13232
+ }
13233
+ return err(`invalid-color/rgb`, `Could not parse the string passed in -- '${color}' -- as an RGB color. Must look something like: rgb(#,#,#)`, { color });
13234
+ }
13235
+ function parseNamedColor(color) {
13236
+ return Object.keys(CSS_COLOR_LOOKUP).includes(color) ? parseRgbColor(CSS_COLOR_LOOKUP[color]) : err(`invalid-color/named`, `The string -- ${color} -- is not a valid "named color" recognized by HTML and CSS. Make sure you have no whitespace or uppercase characters.`, { color });
13237
+ }
13238
+ /**
13239
+ * **parseColor**`(color) -> RGB`
13240
+ *
13241
+ * Extracts the discrete RGB values from both `CssRgb` strings and
13242
+ * _named colors_ recognized by HTML and CSS.
13243
+ *
13244
+ * = Note: all strings are trimmed and forced to lowercase to help
13245
+ * with matching.
13246
+ */
13247
+ function parseColor(color) {
13248
+ if (isRgbColor(color)) return parseRgbColor(color);
13249
+ else if (isNamedColor(color)) return parseNamedColor(color);
13250
+ else return err("invalid-color", `The string passed in -- ${color} -- could not be parsed as either a CSS RGB Color or a CSS Named Color.`, { color });
13251
+ }
13252
+
12885
13253
  //#endregion
12886
13254
  //#region src/datetime/asDate.ts
12887
13255
  /**
@@ -16559,6 +16927,7 @@ exports.isMinimalDigitDate = isMinimalDigitDate;
16559
16927
  exports.isMoment = isMoment;
16560
16928
  exports.isMonthAbbrev = isMonthAbbrev;
16561
16929
  exports.isMonthName = isMonthName;
16930
+ exports.isNamedColor = isNamedColor;
16562
16931
  exports.isNarrowable = isNarrowable;
16563
16932
  exports.isNarrowableArray = isNarrowableArray;
16564
16933
  exports.isNarrowableDictionary = isNarrowableDictionary;
@@ -16604,6 +16973,7 @@ exports.isRepoUrl = isRepoUrl;
16604
16973
  exports.isResistanceMetric = isResistanceMetric;
16605
16974
  exports.isResistanceUom = isResistanceUom;
16606
16975
  exports.isRetailUrl = isRetailUrl;
16976
+ exports.isRgbColor = isRgbColor;
16607
16977
  exports.isSameDay = isSameDay;
16608
16978
  exports.isSameMonth = isSameMonth;
16609
16979
  exports.isSameMonthYear = isSameMonthYear;
@@ -16751,10 +17121,13 @@ exports.optional = optional;
16751
17121
  exports.optionalOrNull = optionalOrNull;
16752
17122
  exports.or = or;
16753
17123
  exports.orNull = orNull;
17124
+ exports.parseColor = parseColor;
16754
17125
  exports.parseDate = parseDate;
16755
17126
  exports.parseDateObject = parseDateObject;
16756
17127
  exports.parseIsoDate = parseIsoDate;
17128
+ exports.parseNamedColor = parseNamedColor;
16757
17129
  exports.parseNumericDate = parseNumericDate;
17130
+ exports.parseRgbColor = parseRgbColor;
16758
17131
  exports.pathJoin = pathJoin;
16759
17132
  exports.pluralize = pluralize;
16760
17133
  exports.pop = pop;