ahmedelgabri 7.0.0 → 8.0.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/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  <br>
8
8
  <br>
9
9
  <br>
10
- <pre><code>curl -L gabri.me/api/card</code></pre>
10
+ <pre><code>curl -L gabri.me/card</code></pre>
11
11
  or
12
12
  <br>
13
13
  <br>
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ const dntGlobals = {
4
+ Deno,
5
+ };
6
+ export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
7
+ function createMergeProxy(baseObj, extObj) {
8
+ return new Proxy(baseObj, {
9
+ get(_target, prop, _receiver) {
10
+ if (prop in extObj) {
11
+ return extObj[prop];
12
+ }
13
+ else {
14
+ return baseObj[prop];
15
+ }
16
+ },
17
+ set(_target, prop, value) {
18
+ if (prop in extObj) {
19
+ delete extObj[prop];
20
+ }
21
+ baseObj[prop] = value;
22
+ return true;
23
+ },
24
+ deleteProperty(_target, prop) {
25
+ let success = false;
26
+ if (prop in extObj) {
27
+ delete extObj[prop];
28
+ success = true;
29
+ }
30
+ if (prop in baseObj) {
31
+ delete baseObj[prop];
32
+ success = true;
33
+ }
34
+ return success;
35
+ },
36
+ ownKeys(_target) {
37
+ const baseKeys = Reflect.ownKeys(baseObj);
38
+ const extKeys = Reflect.ownKeys(extObj);
39
+ const extKeysSet = new Set(extKeys);
40
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
41
+ },
42
+ defineProperty(_target, prop, desc) {
43
+ if (prop in extObj) {
44
+ delete extObj[prop];
45
+ }
46
+ Reflect.defineProperty(baseObj, prop, desc);
47
+ return true;
48
+ },
49
+ getOwnPropertyDescriptor(_target, prop) {
50
+ if (prop in extObj) {
51
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
52
+ }
53
+ else {
54
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
55
+ }
56
+ },
57
+ has(_target, prop) {
58
+ return prop in extObj || prop in baseObj;
59
+ },
60
+ });
61
+ }
@@ -0,0 +1,489 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ // A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
4
+ // on npm.
5
+ /**
6
+ * String formatters and utilities for dealing with ANSI color codes.
7
+ *
8
+ * This module is browser compatible.
9
+ *
10
+ * This module supports `NO_COLOR` environmental variable disabling any coloring
11
+ * if `NO_COLOR` is set.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import {
16
+ * bgBlue,
17
+ * bgRgb24,
18
+ * bgRgb8,
19
+ * bold,
20
+ * italic,
21
+ * red,
22
+ * rgb24,
23
+ * rgb8,
24
+ * } from "@std/fmt/colors";
25
+ *
26
+ * console.log(bgBlue(italic(red(bold("Hello, World!")))));
27
+ *
28
+ * // also supports 8bit colors
29
+ *
30
+ * console.log(rgb8("Hello, World!", 42));
31
+ *
32
+ * console.log(bgRgb8("Hello, World!", 42));
33
+ *
34
+ * // and 24bit rgb
35
+ *
36
+ * console.log(rgb24("Hello, World!", {
37
+ * r: 41,
38
+ * g: 42,
39
+ * b: 43,
40
+ * }));
41
+ *
42
+ * console.log(bgRgb24("Hello, World!", {
43
+ * r: 41,
44
+ * g: 42,
45
+ * b: 43,
46
+ * }));
47
+ * ```
48
+ *
49
+ * @module
50
+ */
51
+ // deno-lint-ignore no-explicit-any
52
+ import * as dntShim from "../../../../../_dnt.shims.js";
53
+ const { Deno } = dntShim.dntGlobalThis;
54
+ const noColor = typeof Deno?.noColor === "boolean"
55
+ ? Deno.noColor
56
+ : false;
57
+ let enabled = !noColor;
58
+ /**
59
+ * Set changing text color to enabled or disabled
60
+ * @param value
61
+ */
62
+ export function setColorEnabled(value) {
63
+ if (Deno?.noColor) {
64
+ return;
65
+ }
66
+ enabled = value;
67
+ }
68
+ /** Get whether text color change is enabled or disabled. */
69
+ export function getColorEnabled() {
70
+ return enabled;
71
+ }
72
+ /**
73
+ * Builds color code
74
+ * @param open
75
+ * @param close
76
+ */
77
+ function code(open, close) {
78
+ return {
79
+ open: `\x1b[${open.join(";")}m`,
80
+ close: `\x1b[${close}m`,
81
+ regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
82
+ };
83
+ }
84
+ /**
85
+ * Applies color and background based on color code and its associated text
86
+ * @param str text to apply color settings to
87
+ * @param code color code to apply
88
+ */
89
+ function run(str, code) {
90
+ return enabled
91
+ ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
92
+ : str;
93
+ }
94
+ /**
95
+ * Reset the text modified.
96
+ * @param str text to reset
97
+ */
98
+ export function reset(str) {
99
+ return run(str, code([0], 0));
100
+ }
101
+ /**
102
+ * Make the text bold.
103
+ * @param str text to make bold
104
+ */
105
+ export function bold(str) {
106
+ return run(str, code([1], 22));
107
+ }
108
+ /**
109
+ * The text emits only a small amount of light.
110
+ * @param str text to dim
111
+ *
112
+ * Warning: Not all terminal emulators support `dim`.
113
+ * For compatibility across all terminals, use {@linkcode gray} or {@linkcode brightBlack} instead.
114
+ */
115
+ export function dim(str) {
116
+ return run(str, code([2], 22));
117
+ }
118
+ /**
119
+ * Make the text italic.
120
+ * @param str text to make italic
121
+ */
122
+ export function italic(str) {
123
+ return run(str, code([3], 23));
124
+ }
125
+ /**
126
+ * Make the text underline.
127
+ * @param str text to underline
128
+ */
129
+ export function underline(str) {
130
+ return run(str, code([4], 24));
131
+ }
132
+ /**
133
+ * Invert background color and text color.
134
+ * @param str text to invert its color
135
+ */
136
+ export function inverse(str) {
137
+ return run(str, code([7], 27));
138
+ }
139
+ /**
140
+ * Make the text hidden.
141
+ * @param str text to hide
142
+ */
143
+ export function hidden(str) {
144
+ return run(str, code([8], 28));
145
+ }
146
+ /**
147
+ * Put horizontal line through the center of the text.
148
+ * @param str text to strike through
149
+ */
150
+ export function strikethrough(str) {
151
+ return run(str, code([9], 29));
152
+ }
153
+ /**
154
+ * Set text color to black.
155
+ * @param str text to make black
156
+ */
157
+ export function black(str) {
158
+ return run(str, code([30], 39));
159
+ }
160
+ /**
161
+ * Set text color to red.
162
+ * @param str text to make red
163
+ */
164
+ export function red(str) {
165
+ return run(str, code([31], 39));
166
+ }
167
+ /**
168
+ * Set text color to green.
169
+ * @param str text to make green
170
+ */
171
+ export function green(str) {
172
+ return run(str, code([32], 39));
173
+ }
174
+ /**
175
+ * Set text color to yellow.
176
+ * @param str text to make yellow
177
+ */
178
+ export function yellow(str) {
179
+ return run(str, code([33], 39));
180
+ }
181
+ /**
182
+ * Set text color to blue.
183
+ * @param str text to make blue
184
+ */
185
+ export function blue(str) {
186
+ return run(str, code([34], 39));
187
+ }
188
+ /**
189
+ * Set text color to magenta.
190
+ * @param str text to make magenta
191
+ */
192
+ export function magenta(str) {
193
+ return run(str, code([35], 39));
194
+ }
195
+ /**
196
+ * Set text color to cyan.
197
+ * @param str text to make cyan
198
+ */
199
+ export function cyan(str) {
200
+ return run(str, code([36], 39));
201
+ }
202
+ /**
203
+ * Set text color to white.
204
+ * @param str text to make white
205
+ */
206
+ export function white(str) {
207
+ return run(str, code([37], 39));
208
+ }
209
+ /**
210
+ * Set text color to gray.
211
+ * @param str text to make gray
212
+ */
213
+ export function gray(str) {
214
+ return brightBlack(str);
215
+ }
216
+ /**
217
+ * Set text color to bright black.
218
+ * @param str text to make bright-black
219
+ */
220
+ export function brightBlack(str) {
221
+ return run(str, code([90], 39));
222
+ }
223
+ /**
224
+ * Set text color to bright red.
225
+ * @param str text to make bright-red
226
+ */
227
+ export function brightRed(str) {
228
+ return run(str, code([91], 39));
229
+ }
230
+ /**
231
+ * Set text color to bright green.
232
+ * @param str text to make bright-green
233
+ */
234
+ export function brightGreen(str) {
235
+ return run(str, code([92], 39));
236
+ }
237
+ /**
238
+ * Set text color to bright yellow.
239
+ * @param str text to make bright-yellow
240
+ */
241
+ export function brightYellow(str) {
242
+ return run(str, code([93], 39));
243
+ }
244
+ /**
245
+ * Set text color to bright blue.
246
+ * @param str text to make bright-blue
247
+ */
248
+ export function brightBlue(str) {
249
+ return run(str, code([94], 39));
250
+ }
251
+ /**
252
+ * Set text color to bright magenta.
253
+ * @param str text to make bright-magenta
254
+ */
255
+ export function brightMagenta(str) {
256
+ return run(str, code([95], 39));
257
+ }
258
+ /**
259
+ * Set text color to bright cyan.
260
+ * @param str text to make bright-cyan
261
+ */
262
+ export function brightCyan(str) {
263
+ return run(str, code([96], 39));
264
+ }
265
+ /**
266
+ * Set text color to bright white.
267
+ * @param str text to make bright-white
268
+ */
269
+ export function brightWhite(str) {
270
+ return run(str, code([97], 39));
271
+ }
272
+ /**
273
+ * Set background color to black.
274
+ * @param str text to make its background black
275
+ */
276
+ export function bgBlack(str) {
277
+ return run(str, code([40], 49));
278
+ }
279
+ /**
280
+ * Set background color to red.
281
+ * @param str text to make its background red
282
+ */
283
+ export function bgRed(str) {
284
+ return run(str, code([41], 49));
285
+ }
286
+ /**
287
+ * Set background color to green.
288
+ * @param str text to make its background green
289
+ */
290
+ export function bgGreen(str) {
291
+ return run(str, code([42], 49));
292
+ }
293
+ /**
294
+ * Set background color to yellow.
295
+ * @param str text to make its background yellow
296
+ */
297
+ export function bgYellow(str) {
298
+ return run(str, code([43], 49));
299
+ }
300
+ /**
301
+ * Set background color to blue.
302
+ * @param str text to make its background blue
303
+ */
304
+ export function bgBlue(str) {
305
+ return run(str, code([44], 49));
306
+ }
307
+ /**
308
+ * Set background color to magenta.
309
+ * @param str text to make its background magenta
310
+ */
311
+ export function bgMagenta(str) {
312
+ return run(str, code([45], 49));
313
+ }
314
+ /**
315
+ * Set background color to cyan.
316
+ * @param str text to make its background cyan
317
+ */
318
+ export function bgCyan(str) {
319
+ return run(str, code([46], 49));
320
+ }
321
+ /**
322
+ * Set background color to white.
323
+ * @param str text to make its background white
324
+ */
325
+ export function bgWhite(str) {
326
+ return run(str, code([47], 49));
327
+ }
328
+ /**
329
+ * Set background color to bright black.
330
+ * @param str text to make its background bright-black
331
+ */
332
+ export function bgBrightBlack(str) {
333
+ return run(str, code([100], 49));
334
+ }
335
+ /**
336
+ * Set background color to bright red.
337
+ * @param str text to make its background bright-red
338
+ */
339
+ export function bgBrightRed(str) {
340
+ return run(str, code([101], 49));
341
+ }
342
+ /**
343
+ * Set background color to bright green.
344
+ * @param str text to make its background bright-green
345
+ */
346
+ export function bgBrightGreen(str) {
347
+ return run(str, code([102], 49));
348
+ }
349
+ /**
350
+ * Set background color to bright yellow.
351
+ * @param str text to make its background bright-yellow
352
+ */
353
+ export function bgBrightYellow(str) {
354
+ return run(str, code([103], 49));
355
+ }
356
+ /**
357
+ * Set background color to bright blue.
358
+ * @param str text to make its background bright-blue
359
+ */
360
+ export function bgBrightBlue(str) {
361
+ return run(str, code([104], 49));
362
+ }
363
+ /**
364
+ * Set background color to bright magenta.
365
+ * @param str text to make its background bright-magenta
366
+ */
367
+ export function bgBrightMagenta(str) {
368
+ return run(str, code([105], 49));
369
+ }
370
+ /**
371
+ * Set background color to bright cyan.
372
+ * @param str text to make its background bright-cyan
373
+ */
374
+ export function bgBrightCyan(str) {
375
+ return run(str, code([106], 49));
376
+ }
377
+ /**
378
+ * Set background color to bright white.
379
+ * @param str text to make its background bright-white
380
+ */
381
+ export function bgBrightWhite(str) {
382
+ return run(str, code([107], 49));
383
+ }
384
+ /* Special Color Sequences */
385
+ /**
386
+ * Clam and truncate color codes
387
+ * @param n
388
+ * @param max number to truncate to
389
+ * @param min number to truncate from
390
+ */
391
+ function clampAndTruncate(n, max = 255, min = 0) {
392
+ return Math.trunc(Math.max(Math.min(n, max), min));
393
+ }
394
+ /**
395
+ * Set text color using paletted 8bit colors.
396
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
397
+ * @param str text color to apply paletted 8bit colors to
398
+ * @param color code
399
+ */
400
+ export function rgb8(str, color) {
401
+ return run(str, code([38, 5, clampAndTruncate(color)], 39));
402
+ }
403
+ /**
404
+ * Set background color using paletted 8bit colors.
405
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
406
+ * @param str text color to apply paletted 8bit background colors to
407
+ * @param color code
408
+ */
409
+ export function bgRgb8(str, color) {
410
+ return run(str, code([48, 5, clampAndTruncate(color)], 49));
411
+ }
412
+ /**
413
+ * Set text color using 24bit rgb.
414
+ * `color` can be a number in range `0x000000` to `0xffffff` or
415
+ * an `Rgb`.
416
+ *
417
+ * To produce the color magenta:
418
+ *
419
+ * ```ts
420
+ * import { rgb24 } from "@std/fmt/colors";
421
+ *
422
+ * rgb24("foo", 0xff00ff);
423
+ * rgb24("foo", {r: 255, g: 0, b: 255});
424
+ * ```
425
+ * @param str text color to apply 24bit rgb to
426
+ * @param color code
427
+ */
428
+ export function rgb24(str, color) {
429
+ if (typeof color === "number") {
430
+ return run(str, code([38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 39));
431
+ }
432
+ return run(str, code([
433
+ 38,
434
+ 2,
435
+ clampAndTruncate(color.r),
436
+ clampAndTruncate(color.g),
437
+ clampAndTruncate(color.b),
438
+ ], 39));
439
+ }
440
+ /**
441
+ * Set background color using 24bit rgb.
442
+ * `color` can be a number in range `0x000000` to `0xffffff` or
443
+ * an `Rgb`.
444
+ *
445
+ * To produce the color magenta:
446
+ *
447
+ * ```ts
448
+ * import { bgRgb24 } from "@std/fmt/colors";
449
+ *
450
+ * bgRgb24("foo", 0xff00ff);
451
+ * bgRgb24("foo", {r: 255, g: 0, b: 255});
452
+ * ```
453
+ * @param str text color to apply 24bit rgb to
454
+ * @param color code
455
+ */
456
+ export function bgRgb24(str, color) {
457
+ if (typeof color === "number") {
458
+ return run(str, code([48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 49));
459
+ }
460
+ return run(str, code([
461
+ 48,
462
+ 2,
463
+ clampAndTruncate(color.r),
464
+ clampAndTruncate(color.g),
465
+ clampAndTruncate(color.b),
466
+ ], 49));
467
+ }
468
+ // https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
469
+ const ANSI_PATTERN = new RegExp([
470
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
471
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))",
472
+ ].join("|"), "g");
473
+ /**
474
+ * Remove ANSI escape codes from the string.
475
+ * @param string to remove ANSI escape codes from
476
+ *
477
+ * @deprecated (will be removed in 1.0.0) Use {@linkcode stripAnsiCode} instead.
478
+ */
479
+ export function stripColor(string) {
480
+ return stripAnsiCode(string);
481
+ }
482
+ /**
483
+ * Remove ANSI escape codes from the string.
484
+ *
485
+ * @param string to remove ANSI escape codes from
486
+ */
487
+ export function stripAnsiCode(string) {
488
+ return string.replace(ANSI_PATTERN, "");
489
+ }
package/esm/mod.js ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ import "./_dnt.polyfills.js";
3
+ import "./_dnt.polyfills.js";
4
+ import * as dntShim from "./_dnt.shims.js";
5
+ import * as c from "./deps/jsr.io/@std/fmt/0.221.0/colors.js";
6
+ import boxen from "boxen";
7
+ const fullname = "Ahmed El Gabri";
8
+ const social = fullname.toLowerCase().replaceAll(" ", "");
9
+ const mastodonHandle = fullname.toLowerCase().split(" ").at(-1);
10
+ const jsrUserName = fullname.toLowerCase().split(" ").at(0);
11
+ // Text + pc definitions
12
+ const handle = c.blue(social);
13
+ const work = c.reset("Staff Software Engineer @MiroHQ");
14
+ const twitter = c.blue(`https://twitter.com/${handle}`);
15
+ const github = c.blue(`https://github.com/${handle}`);
16
+ const linkedin = c.blue(`https://linkedin.com/in/${handle}`);
17
+ const mastodon = c.blue(`https://mastodon.online/@${mastodonHandle}`);
18
+ const web = c.blue("https://gabri.me");
19
+ const npx = c.reset(`npx ${handle}`);
20
+ const deno = c.reset(`deno run jsr:@${c.blue(jsrUserName)}/card`);
21
+ const labelWork = c.gray(" Work: ");
22
+ const labelTwitter = c.dim(" Twitter: ");
23
+ const labelGitHub = c.dim(" GitHub: ");
24
+ const labelLinkedIn = c.dim("LinkedIn: ");
25
+ const labelWeb = c.dim(" Web: ");
26
+ const labelNode = c.gray(" Node: ");
27
+ const labelDeno = c.gray(" Deno: ");
28
+ const labelMastodon = c.dim("Mastodon: ");
29
+ // Actual strings we're going to output
30
+ const working = `${labelWork} ${work}`;
31
+ const twittering = `${labelTwitter} ${twitter}`;
32
+ const githubing = `${labelGitHub} ${github}`;
33
+ const linkedining = `${labelLinkedIn} ${linkedin}`;
34
+ const webing = `${labelWeb} ${web}`;
35
+ const npming = `${labelNode} ${npx}`;
36
+ const denoing = `${labelDeno} ${deno}`;
37
+ const mastodoning = `${labelMastodon} ${mastodon}`;
38
+ // Put all our output together into a single variable so we can use boxen effectively
39
+ const output = `${working}
40
+
41
+ ${githubing}
42
+ ${linkedining}
43
+ ${twittering}
44
+ ${mastodoning}
45
+ ${webing}
46
+
47
+ ${denoing}
48
+ ${npming}`;
49
+ /**
50
+ * Returns a boxed and colored personal card containing personal information
51
+ *
52
+ * @returns {string}
53
+ */
54
+ export function getCard() {
55
+ return boxen(output, {
56
+ title: fullname,
57
+ padding: 1,
58
+ margin: 5,
59
+ borderStyle: "round",
60
+ borderColor: dntShim.Deno.env.get("NO_COLOR") ? undefined : "blue",
61
+ });
62
+ }
63
+ /**
64
+ * Returns personal card containing personal information without ascii art or
65
+ * colors
66
+ *
67
+ * @returns {string}
68
+ */
69
+ export function getPlainCard() {
70
+ return output;
71
+ }
72
+ if ((import.meta.url === ("file:///" + process.argv[1].replace(/\\/g, "/")).replace(/\/{3,}/, "///"))) {
73
+ console.log(getCard());
74
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }