@upstash/qstash 0.1.4 → 0.1.7

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.
Files changed (44) hide show
  1. package/README.md +3 -3
  2. package/esm/deps/deno.land/{std@0.147.0 → std@0.152.0}/_wasm_crypto/lib/deno_std_wasm_crypto.generated.mjs +0 -0
  3. package/esm/deps/deno.land/{std@0.147.0 → std@0.152.0}/_wasm_crypto/mod.js +0 -0
  4. package/esm/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/fnv32.js +0 -0
  5. package/esm/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/fnv64.js +0 -0
  6. package/esm/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/index.js +0 -0
  7. package/esm/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/util.js +0 -0
  8. package/esm/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/mod.js +17 -9
  9. package/esm/deps/deno.land/std@0.152.0/crypto/timing_safe_equal.js +24 -0
  10. package/esm/deps/deno.land/std@0.152.0/fmt/colors.js +442 -0
  11. package/esm/deps/deno.land/std@0.152.0/testing/_diff.js +304 -0
  12. package/esm/deps/deno.land/std@0.152.0/testing/_format.js +21 -0
  13. package/esm/deps/deno.land/std@0.152.0/testing/asserts.js +620 -0
  14. package/esm/entrypoints/nextjs.js +2 -2
  15. package/esm/pkg/client/client.js +1 -1
  16. package/package.json +1 -1
  17. package/script/deps/deno.land/{std@0.147.0 → std@0.152.0}/_wasm_crypto/lib/deno_std_wasm_crypto.generated.mjs +0 -0
  18. package/script/deps/deno.land/{std@0.147.0 → std@0.152.0}/_wasm_crypto/mod.js +0 -0
  19. package/script/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/fnv32.js +0 -0
  20. package/script/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/fnv64.js +0 -0
  21. package/script/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/index.js +0 -0
  22. package/script/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/util.js +0 -0
  23. package/script/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/mod.js +18 -10
  24. package/script/deps/deno.land/std@0.152.0/crypto/timing_safe_equal.js +28 -0
  25. package/script/deps/deno.land/std@0.152.0/fmt/colors.js +516 -0
  26. package/script/deps/deno.land/std@0.152.0/testing/_diff.js +310 -0
  27. package/script/deps/deno.land/std@0.152.0/testing/_format.js +48 -0
  28. package/script/deps/deno.land/std@0.152.0/testing/asserts.js +645 -0
  29. package/script/entrypoints/nextjs.js +2 -2
  30. package/script/pkg/client/client.js +1 -1
  31. package/types/deps/deno.land/{std@0.147.0 → std@0.152.0}/_wasm_crypto/lib/deno_std_wasm_crypto.generated.d.mts +0 -0
  32. package/types/deps/deno.land/{std@0.147.0 → std@0.152.0}/_wasm_crypto/mod.d.ts +0 -0
  33. package/types/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/fnv32.d.ts +0 -0
  34. package/types/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/fnv64.d.ts +0 -0
  35. package/types/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/index.d.ts +0 -0
  36. package/types/deps/deno.land/{std@0.147.0 → std@0.152.0}/crypto/_fnv/util.d.ts +0 -0
  37. package/types/deps/deno.land/std@0.152.0/crypto/mod.d.ts +51 -0
  38. package/types/deps/deno.land/std@0.152.0/crypto/timing_safe_equal.d.ts +3 -0
  39. package/types/deps/deno.land/std@0.152.0/fmt/colors.d.ts +270 -0
  40. package/types/deps/deno.land/std@0.152.0/testing/_diff.d.ts +26 -0
  41. package/types/deps/deno.land/std@0.152.0/testing/_format.d.ts +1 -0
  42. package/types/deps/deno.land/std@0.152.0/testing/asserts.d.ts +160 -0
  43. package/types/pkg/receiver.d.ts +1 -1
  44. package/types/deps/deno.land/std@0.147.0/crypto/mod.d.ts +0 -53
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -24,14 +25,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
25
  };
25
26
  Object.defineProperty(exports, "__esModule", { value: true });
26
27
  exports.crypto = void 0;
27
- // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
28
+ /**
29
+ * Extensions to the
30
+ * [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
31
+ * supporting additional encryption APIs.
32
+ *
33
+ * Provides additional digest algorithms that are not part of the WebCrypto
34
+ * standard as well as a `subtle.digest` and `subtle.digestSync` methods. It
35
+ * also provide a `subtle.timingSafeEqual()` method to compare array buffers
36
+ * or data views in a way that isn't prone to timing based attacks.
37
+ *
38
+ * The "polyfill" delegates to `WebCrypto` where possible.
39
+ *
40
+ * @module
41
+ */
28
42
  const dntShim = __importStar(require("../../../../_dnt.shims.js"));
29
43
  const mod_js_1 = require("../_wasm_crypto/mod.js");
44
+ const timing_safe_equal_js_1 = require("./timing_safe_equal.js");
30
45
  const index_js_1 = require("./_fnv/index.js");
31
46
  /**
32
47
  * A copy of the global WebCrypto interface, with methods bound so they're
33
48
  * safe to re-export.
34
- * @module
35
49
  */
36
50
  const webCrypto = ((crypto) => ({
37
51
  getRandomValues: crypto.getRandomValues?.bind(crypto),
@@ -73,10 +87,6 @@ const stdCrypto = ((x) => x)({
73
87
  ...webCrypto,
74
88
  subtle: {
75
89
  ...webCrypto.subtle,
76
- /**
77
- * Returns a new `Promise` object that will digest `data` using the specified
78
- * `AlgorithmIdentifier`.
79
- */
80
90
  async digest(algorithm, data) {
81
91
  const { name, length } = normalizeAlgorithm(algorithm);
82
92
  const bytes = bufferSourceBytes(data);
@@ -127,10 +137,6 @@ const stdCrypto = ((x) => x)({
127
137
  throw new TypeError(`unsupported digest algorithm: ${algorithm}`);
128
138
  }
129
139
  },
130
- /**
131
- * Returns a ArrayBuffer with the result of digesting `data` using the
132
- * specified `AlgorithmIdentifier`.
133
- */
134
140
  digestSync(algorithm, data) {
135
141
  algorithm = normalizeAlgorithm(algorithm);
136
142
  const bytes = bufferSourceBytes(data);
@@ -157,6 +163,8 @@ const stdCrypto = ((x) => x)({
157
163
  throw new TypeError("data must be a BufferSource or Iterable<BufferSource>");
158
164
  }
159
165
  },
166
+ // TODO(@kitsonk): rework when https://github.com/w3c/webcrypto/issues/270 resolved
167
+ timingSafeEqual: timing_safe_equal_js_1.timingSafeEqual,
160
168
  },
161
169
  });
162
170
  exports.crypto = stdCrypto;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.timingSafeEqual = void 0;
5
+ const asserts_js_1 = require("../testing/asserts.js");
6
+ /** Compare to array buffers or data views in a way that timing based attacks
7
+ * cannot gain information about the platform. */
8
+ function timingSafeEqual(a, b) {
9
+ if (a.byteLength !== b.byteLength) {
10
+ return false;
11
+ }
12
+ if (!(a instanceof DataView)) {
13
+ a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
14
+ }
15
+ if (!(b instanceof DataView)) {
16
+ b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
17
+ }
18
+ (0, asserts_js_1.assert)(a instanceof DataView);
19
+ (0, asserts_js_1.assert)(b instanceof DataView);
20
+ const length = a.byteLength;
21
+ let out = 0;
22
+ let i = -1;
23
+ while (++i < length) {
24
+ out |= a.getUint8(i) ^ b.getUint8(i);
25
+ }
26
+ return out === 0;
27
+ }
28
+ exports.timingSafeEqual = timingSafeEqual;
@@ -0,0 +1,516 @@
1
+ "use strict";
2
+ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
3
+ // A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
4
+ // on npm.
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.stripColor = exports.bgRgb24 = exports.rgb24 = exports.bgRgb8 = exports.rgb8 = exports.bgBrightWhite = exports.bgBrightCyan = exports.bgBrightMagenta = exports.bgBrightBlue = exports.bgBrightYellow = exports.bgBrightGreen = exports.bgBrightRed = exports.bgBrightBlack = exports.bgWhite = exports.bgCyan = exports.bgMagenta = exports.bgBlue = exports.bgYellow = exports.bgGreen = exports.bgRed = exports.bgBlack = exports.brightWhite = exports.brightCyan = exports.brightMagenta = exports.brightBlue = exports.brightYellow = exports.brightGreen = exports.brightRed = exports.brightBlack = exports.gray = exports.white = exports.cyan = exports.magenta = exports.blue = exports.yellow = exports.green = exports.red = exports.black = exports.strikethrough = exports.hidden = exports.inverse = exports.underline = exports.italic = exports.dim = exports.bold = exports.reset = exports.getColorEnabled = exports.setColorEnabled = void 0;
30
+ /**
31
+ * String formatters and utilities for dealing with ANSI color codes.
32
+ *
33
+ * This module is browser compatible.
34
+ *
35
+ * ```ts
36
+ * import { bgBlue, red, bold } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
37
+ * console.log(bgBlue(red(bold("Hello world!"))));
38
+ * ```
39
+ *
40
+ * This module supports `NO_COLOR` environmental variable disabling any coloring
41
+ * if `NO_COLOR` is set.
42
+ *
43
+ * @module
44
+ */
45
+ // deno-lint-ignore no-explicit-any
46
+ const dntShim = __importStar(require("../../../../_dnt.shims.js"));
47
+ const { Deno } = dntShim.dntGlobalThis;
48
+ const noColor = typeof Deno?.noColor === "boolean"
49
+ ? Deno.noColor
50
+ : true;
51
+ let enabled = !noColor;
52
+ /**
53
+ * Set changing text color to enabled or disabled
54
+ * @param value
55
+ */
56
+ function setColorEnabled(value) {
57
+ if (noColor) {
58
+ return;
59
+ }
60
+ enabled = value;
61
+ }
62
+ exports.setColorEnabled = setColorEnabled;
63
+ /** Get whether text color change is enabled or disabled. */
64
+ function getColorEnabled() {
65
+ return enabled;
66
+ }
67
+ exports.getColorEnabled = getColorEnabled;
68
+ /**
69
+ * Builds color code
70
+ * @param open
71
+ * @param close
72
+ */
73
+ function code(open, close) {
74
+ return {
75
+ open: `\x1b[${open.join(";")}m`,
76
+ close: `\x1b[${close}m`,
77
+ regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
78
+ };
79
+ }
80
+ /**
81
+ * Applies color and background based on color code and its associated text
82
+ * @param str text to apply color settings to
83
+ * @param code color code to apply
84
+ */
85
+ function run(str, code) {
86
+ return enabled
87
+ ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
88
+ : str;
89
+ }
90
+ /**
91
+ * Reset the text modified
92
+ * @param str text to reset
93
+ */
94
+ function reset(str) {
95
+ return run(str, code([0], 0));
96
+ }
97
+ exports.reset = reset;
98
+ /**
99
+ * Make the text bold.
100
+ * @param str text to make bold
101
+ */
102
+ function bold(str) {
103
+ return run(str, code([1], 22));
104
+ }
105
+ exports.bold = bold;
106
+ /**
107
+ * The text emits only a small amount of light.
108
+ * @param str text to dim
109
+ */
110
+ function dim(str) {
111
+ return run(str, code([2], 22));
112
+ }
113
+ exports.dim = dim;
114
+ /**
115
+ * Make the text italic.
116
+ * @param str text to make italic
117
+ */
118
+ function italic(str) {
119
+ return run(str, code([3], 23));
120
+ }
121
+ exports.italic = italic;
122
+ /**
123
+ * Make the text underline.
124
+ * @param str text to underline
125
+ */
126
+ function underline(str) {
127
+ return run(str, code([4], 24));
128
+ }
129
+ exports.underline = underline;
130
+ /**
131
+ * Invert background color and text color.
132
+ * @param str text to invert its color
133
+ */
134
+ function inverse(str) {
135
+ return run(str, code([7], 27));
136
+ }
137
+ exports.inverse = inverse;
138
+ /**
139
+ * Make the text hidden.
140
+ * @param str text to hide
141
+ */
142
+ function hidden(str) {
143
+ return run(str, code([8], 28));
144
+ }
145
+ exports.hidden = hidden;
146
+ /**
147
+ * Put horizontal line through the center of the text.
148
+ * @param str text to strike through
149
+ */
150
+ function strikethrough(str) {
151
+ return run(str, code([9], 29));
152
+ }
153
+ exports.strikethrough = strikethrough;
154
+ /**
155
+ * Set text color to black.
156
+ * @param str text to make black
157
+ */
158
+ function black(str) {
159
+ return run(str, code([30], 39));
160
+ }
161
+ exports.black = black;
162
+ /**
163
+ * Set text color to red.
164
+ * @param str text to make red
165
+ */
166
+ function red(str) {
167
+ return run(str, code([31], 39));
168
+ }
169
+ exports.red = red;
170
+ /**
171
+ * Set text color to green.
172
+ * @param str text to make green
173
+ */
174
+ function green(str) {
175
+ return run(str, code([32], 39));
176
+ }
177
+ exports.green = green;
178
+ /**
179
+ * Set text color to yellow.
180
+ * @param str text to make yellow
181
+ */
182
+ function yellow(str) {
183
+ return run(str, code([33], 39));
184
+ }
185
+ exports.yellow = yellow;
186
+ /**
187
+ * Set text color to blue.
188
+ * @param str text to make blue
189
+ */
190
+ function blue(str) {
191
+ return run(str, code([34], 39));
192
+ }
193
+ exports.blue = blue;
194
+ /**
195
+ * Set text color to magenta.
196
+ * @param str text to make magenta
197
+ */
198
+ function magenta(str) {
199
+ return run(str, code([35], 39));
200
+ }
201
+ exports.magenta = magenta;
202
+ /**
203
+ * Set text color to cyan.
204
+ * @param str text to make cyan
205
+ */
206
+ function cyan(str) {
207
+ return run(str, code([36], 39));
208
+ }
209
+ exports.cyan = cyan;
210
+ /**
211
+ * Set text color to white.
212
+ * @param str text to make white
213
+ */
214
+ function white(str) {
215
+ return run(str, code([37], 39));
216
+ }
217
+ exports.white = white;
218
+ /**
219
+ * Set text color to gray.
220
+ * @param str text to make gray
221
+ */
222
+ function gray(str) {
223
+ return brightBlack(str);
224
+ }
225
+ exports.gray = gray;
226
+ /**
227
+ * Set text color to bright black.
228
+ * @param str text to make bright-black
229
+ */
230
+ function brightBlack(str) {
231
+ return run(str, code([90], 39));
232
+ }
233
+ exports.brightBlack = brightBlack;
234
+ /**
235
+ * Set text color to bright red.
236
+ * @param str text to make bright-red
237
+ */
238
+ function brightRed(str) {
239
+ return run(str, code([91], 39));
240
+ }
241
+ exports.brightRed = brightRed;
242
+ /**
243
+ * Set text color to bright green.
244
+ * @param str text to make bright-green
245
+ */
246
+ function brightGreen(str) {
247
+ return run(str, code([92], 39));
248
+ }
249
+ exports.brightGreen = brightGreen;
250
+ /**
251
+ * Set text color to bright yellow.
252
+ * @param str text to make bright-yellow
253
+ */
254
+ function brightYellow(str) {
255
+ return run(str, code([93], 39));
256
+ }
257
+ exports.brightYellow = brightYellow;
258
+ /**
259
+ * Set text color to bright blue.
260
+ * @param str text to make bright-blue
261
+ */
262
+ function brightBlue(str) {
263
+ return run(str, code([94], 39));
264
+ }
265
+ exports.brightBlue = brightBlue;
266
+ /**
267
+ * Set text color to bright magenta.
268
+ * @param str text to make bright-magenta
269
+ */
270
+ function brightMagenta(str) {
271
+ return run(str, code([95], 39));
272
+ }
273
+ exports.brightMagenta = brightMagenta;
274
+ /**
275
+ * Set text color to bright cyan.
276
+ * @param str text to make bright-cyan
277
+ */
278
+ function brightCyan(str) {
279
+ return run(str, code([96], 39));
280
+ }
281
+ exports.brightCyan = brightCyan;
282
+ /**
283
+ * Set text color to bright white.
284
+ * @param str text to make bright-white
285
+ */
286
+ function brightWhite(str) {
287
+ return run(str, code([97], 39));
288
+ }
289
+ exports.brightWhite = brightWhite;
290
+ /**
291
+ * Set background color to black.
292
+ * @param str text to make its background black
293
+ */
294
+ function bgBlack(str) {
295
+ return run(str, code([40], 49));
296
+ }
297
+ exports.bgBlack = bgBlack;
298
+ /**
299
+ * Set background color to red.
300
+ * @param str text to make its background red
301
+ */
302
+ function bgRed(str) {
303
+ return run(str, code([41], 49));
304
+ }
305
+ exports.bgRed = bgRed;
306
+ /**
307
+ * Set background color to green.
308
+ * @param str text to make its background green
309
+ */
310
+ function bgGreen(str) {
311
+ return run(str, code([42], 49));
312
+ }
313
+ exports.bgGreen = bgGreen;
314
+ /**
315
+ * Set background color to yellow.
316
+ * @param str text to make its background yellow
317
+ */
318
+ function bgYellow(str) {
319
+ return run(str, code([43], 49));
320
+ }
321
+ exports.bgYellow = bgYellow;
322
+ /**
323
+ * Set background color to blue.
324
+ * @param str text to make its background blue
325
+ */
326
+ function bgBlue(str) {
327
+ return run(str, code([44], 49));
328
+ }
329
+ exports.bgBlue = bgBlue;
330
+ /**
331
+ * Set background color to magenta.
332
+ * @param str text to make its background magenta
333
+ */
334
+ function bgMagenta(str) {
335
+ return run(str, code([45], 49));
336
+ }
337
+ exports.bgMagenta = bgMagenta;
338
+ /**
339
+ * Set background color to cyan.
340
+ * @param str text to make its background cyan
341
+ */
342
+ function bgCyan(str) {
343
+ return run(str, code([46], 49));
344
+ }
345
+ exports.bgCyan = bgCyan;
346
+ /**
347
+ * Set background color to white.
348
+ * @param str text to make its background white
349
+ */
350
+ function bgWhite(str) {
351
+ return run(str, code([47], 49));
352
+ }
353
+ exports.bgWhite = bgWhite;
354
+ /**
355
+ * Set background color to bright black.
356
+ * @param str text to make its background bright-black
357
+ */
358
+ function bgBrightBlack(str) {
359
+ return run(str, code([100], 49));
360
+ }
361
+ exports.bgBrightBlack = bgBrightBlack;
362
+ /**
363
+ * Set background color to bright red.
364
+ * @param str text to make its background bright-red
365
+ */
366
+ function bgBrightRed(str) {
367
+ return run(str, code([101], 49));
368
+ }
369
+ exports.bgBrightRed = bgBrightRed;
370
+ /**
371
+ * Set background color to bright green.
372
+ * @param str text to make its background bright-green
373
+ */
374
+ function bgBrightGreen(str) {
375
+ return run(str, code([102], 49));
376
+ }
377
+ exports.bgBrightGreen = bgBrightGreen;
378
+ /**
379
+ * Set background color to bright yellow.
380
+ * @param str text to make its background bright-yellow
381
+ */
382
+ function bgBrightYellow(str) {
383
+ return run(str, code([103], 49));
384
+ }
385
+ exports.bgBrightYellow = bgBrightYellow;
386
+ /**
387
+ * Set background color to bright blue.
388
+ * @param str text to make its background bright-blue
389
+ */
390
+ function bgBrightBlue(str) {
391
+ return run(str, code([104], 49));
392
+ }
393
+ exports.bgBrightBlue = bgBrightBlue;
394
+ /**
395
+ * Set background color to bright magenta.
396
+ * @param str text to make its background bright-magenta
397
+ */
398
+ function bgBrightMagenta(str) {
399
+ return run(str, code([105], 49));
400
+ }
401
+ exports.bgBrightMagenta = bgBrightMagenta;
402
+ /**
403
+ * Set background color to bright cyan.
404
+ * @param str text to make its background bright-cyan
405
+ */
406
+ function bgBrightCyan(str) {
407
+ return run(str, code([106], 49));
408
+ }
409
+ exports.bgBrightCyan = bgBrightCyan;
410
+ /**
411
+ * Set background color to bright white.
412
+ * @param str text to make its background bright-white
413
+ */
414
+ function bgBrightWhite(str) {
415
+ return run(str, code([107], 49));
416
+ }
417
+ exports.bgBrightWhite = bgBrightWhite;
418
+ /* Special Color Sequences */
419
+ /**
420
+ * Clam and truncate color codes
421
+ * @param n
422
+ * @param max number to truncate to
423
+ * @param min number to truncate from
424
+ */
425
+ function clampAndTruncate(n, max = 255, min = 0) {
426
+ return Math.trunc(Math.max(Math.min(n, max), min));
427
+ }
428
+ /**
429
+ * Set text color using paletted 8bit colors.
430
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
431
+ * @param str text color to apply paletted 8bit colors to
432
+ * @param color code
433
+ */
434
+ function rgb8(str, color) {
435
+ return run(str, code([38, 5, clampAndTruncate(color)], 39));
436
+ }
437
+ exports.rgb8 = rgb8;
438
+ /**
439
+ * Set background color using paletted 8bit colors.
440
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
441
+ * @param str text color to apply paletted 8bit background colors to
442
+ * @param color code
443
+ */
444
+ function bgRgb8(str, color) {
445
+ return run(str, code([48, 5, clampAndTruncate(color)], 49));
446
+ }
447
+ exports.bgRgb8 = bgRgb8;
448
+ /**
449
+ * Set text color using 24bit rgb.
450
+ * `color` can be a number in range `0x000000` to `0xffffff` or
451
+ * an `Rgb`.
452
+ *
453
+ * To produce the color magenta:
454
+ *
455
+ * ```ts
456
+ * import { rgb24 } from "./colors.ts";
457
+ * rgb24("foo", 0xff00ff);
458
+ * rgb24("foo", {r: 255, g: 0, b: 255});
459
+ * ```
460
+ * @param str text color to apply 24bit rgb to
461
+ * @param color code
462
+ */
463
+ function rgb24(str, color) {
464
+ if (typeof color === "number") {
465
+ return run(str, code([38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 39));
466
+ }
467
+ return run(str, code([
468
+ 38,
469
+ 2,
470
+ clampAndTruncate(color.r),
471
+ clampAndTruncate(color.g),
472
+ clampAndTruncate(color.b),
473
+ ], 39));
474
+ }
475
+ exports.rgb24 = rgb24;
476
+ /**
477
+ * Set background color using 24bit rgb.
478
+ * `color` can be a number in range `0x000000` to `0xffffff` or
479
+ * an `Rgb`.
480
+ *
481
+ * To produce the color magenta:
482
+ *
483
+ * ```ts
484
+ * import { bgRgb24 } from "./colors.ts";
485
+ * bgRgb24("foo", 0xff00ff);
486
+ * bgRgb24("foo", {r: 255, g: 0, b: 255});
487
+ * ```
488
+ * @param str text color to apply 24bit rgb to
489
+ * @param color code
490
+ */
491
+ function bgRgb24(str, color) {
492
+ if (typeof color === "number") {
493
+ return run(str, code([48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 49));
494
+ }
495
+ return run(str, code([
496
+ 48,
497
+ 2,
498
+ clampAndTruncate(color.r),
499
+ clampAndTruncate(color.g),
500
+ clampAndTruncate(color.b),
501
+ ], 49));
502
+ }
503
+ exports.bgRgb24 = bgRgb24;
504
+ // https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
505
+ const ANSI_PATTERN = new RegExp([
506
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
507
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))",
508
+ ].join("|"), "g");
509
+ /**
510
+ * Remove ANSI escape codes from the string.
511
+ * @param string to remove ANSI escape codes from
512
+ */
513
+ function stripColor(string) {
514
+ return string.replace(ANSI_PATTERN, "");
515
+ }
516
+ exports.stripColor = stripColor;