fluxion-ts 0.3.2 → 0.3.4

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/dist/index.mjs CHANGED
@@ -35,6 +35,61 @@ function loadFunction(injectionConfig) {
35
35
  }
36
36
  }
37
37
 
38
+ const useColor = process.env.FLUXION_COLORS !== '0';
39
+ /**
40
+ * Color Control Characters for Terminal (cctl)
41
+ */
42
+ var cctl;
43
+ (function (cctl) {
44
+ cctl.reset = useColor ? '\x1b[0m' : '';
45
+ cctl.bold = useColor ? '\x1b[1m' : '';
46
+ cctl.dim = useColor ? '\x1b[2m' : '';
47
+ cctl.italic = useColor ? '\x1b[3m' : '';
48
+ cctl.underline = useColor ? '\x1b[4m' : '';
49
+ cctl.blink = useColor ? '\x1b[5m' : '';
50
+ cctl.inverse = useColor ? '\x1b[7m' : '';
51
+ cctl.black = useColor ? '\x1b[30m' : '';
52
+ cctl.red = useColor ? '\x1b[31m' : '';
53
+ cctl.green = useColor ? '\x1b[32m' : '';
54
+ cctl.yellow = useColor ? '\x1b[33m' : '';
55
+ cctl.blue = useColor ? '\x1b[34m' : '';
56
+ cctl.magenta = useColor ? '\x1b[35m' : '';
57
+ cctl.cyan = useColor ? '\x1b[36m' : '';
58
+ cctl.white = useColor ? '\x1b[37m' : '';
59
+ cctl.brightBlack = useColor ? '\x1b[90m' : '';
60
+ cctl.brightRed = useColor ? '\x1b[91m' : '';
61
+ cctl.brightGreen = useColor ? '\x1b[92m' : '';
62
+ cctl.brightYellow = useColor ? '\x1b[93m' : '';
63
+ cctl.brightBlue = useColor ? '\x1b[94m' : '';
64
+ cctl.brightMagenta = useColor ? '\x1b[95m' : '';
65
+ cctl.brightCyan = useColor ? '\x1b[96m' : '';
66
+ cctl.brightWhite = useColor ? '\x1b[97m' : '';
67
+ cctl.bgBlack = useColor ? '\x1b[40m' : '';
68
+ cctl.bgRed = useColor ? '\x1b[41m' : '';
69
+ cctl.bgGreen = useColor ? '\x1b[42m' : '';
70
+ cctl.bgYellow = useColor ? '\x1b[43m' : '';
71
+ cctl.bgBlue = useColor ? '\x1b[44m' : '';
72
+ cctl.bgMagenta = useColor ? '\x1b[45m' : '';
73
+ cctl.bgCyan = useColor ? '\x1b[46m' : '';
74
+ cctl.bgWhite = useColor ? '\x1b[47m' : '';
75
+ cctl.bgBrightBlack = useColor ? '\x1b[100m' : '';
76
+ cctl.bgBrightRed = useColor ? '\x1b[101m' : '';
77
+ cctl.bgBrightGreen = useColor ? '\x1b[102m' : '';
78
+ cctl.bgBrightYellow = useColor ? '\x1b[103m' : '';
79
+ cctl.bgBrightBlue = useColor ? '\x1b[104m' : '';
80
+ cctl.bgBrightMagenta = useColor ? '\x1b[105m' : '';
81
+ cctl.bgBrightCyan = useColor ? '\x1b[106m' : '';
82
+ cctl.bgBrightWhite = useColor ? '\x1b[107m' : '';
83
+ // 'rgb(225, 16, 248)';
84
+ cctl.purple = useColor ? '\x1b[38;2;225;16;248m' : '';
85
+ // 'rgb(248, 147, 16)';
86
+ cctl.orange = useColor ? '\x1b[38;2;248;147;16m' : '';
87
+ cctl.darkGreen = useColor ? '\x1b[38;2;22;101;52m' : '';
88
+ cctl.claude = useColor ? '\x1b[38;2;217;119;87m' : '';
89
+ cctl.deepseek = useColor ? '\x1b[38;2;57;100;254m' : '';
90
+ cctl.gpt = useColor ? '\x1b[38;2;41;60;77m' : '';
91
+ })(cctl || (cctl = {}));
92
+
38
93
  const safeStringify = (value) => {
39
94
  try {
40
95
  return $stringify(value);
@@ -44,19 +99,19 @@ const safeStringify = (value) => {
44
99
  }
45
100
  };
46
101
  const ColoredLevels = {
47
- INFO: 'INFO',
48
- WARN: 'WARN',
49
- ERROR: 'ERROR',
50
- SUCC: 'SUCC',
51
- DEBUG: 'DEBUG',
52
- VERBOSE: 'VERBOSE',
102
+ INFO: `${cctl.cyan}INFO${cctl.reset}`,
103
+ WARN: `${cctl.orange}WARN${cctl.reset}`,
104
+ ERROR: `${cctl.red}ERROR${cctl.reset}`,
105
+ SUCC: `${cctl.green}SUCC${cctl.reset}`,
106
+ DEBUG: `${cctl.blue}DEBUG${cctl.reset}`,
107
+ VERBOSE: `${cctl.purple}VERBOSE${cctl.reset}`,
53
108
  };
54
109
  const oneLineLogger = (entry) => {
55
110
  const { level: rawLevel, timestamp: rawTimestamp, event: rawEvent, message: rawMessage, ...fields } = entry;
56
- const timestamp = `[${rawTimestamp}]`;
111
+ const timestamp = `${cctl.darkGreen}[${rawTimestamp}]${cctl.reset}`;
57
112
  const level = ColoredLevels[rawLevel] ?? rawLevel;
58
113
  const body = rawMessage ?? rawEvent;
59
- const fieldsText = $keys(fields).length > 0 ? ` ${safeStringify(fields)}` : '';
114
+ const fieldsText = $keys(fields).length > 0 ? `${cctl.dim}${safeStringify(fields)}${cctl.reset}` : '';
60
115
  console.log(`${timestamp} ${level} ${body}${fieldsText}`);
61
116
  };
62
117
  /**
@@ -3530,7 +3585,7 @@ class FluxionRouter {
3530
3585
  : path$1.join(process.cwd(), this.cx.options.dir, filepath);
3531
3586
  if (!fs.existsSync(fullpath)) {
3532
3587
  this.handlers.delete(filepath);
3533
- this.cx.logger.info(`[${filepath}] deleted`);
3588
+ this.cx.logger.info(`${cctl.red}Deleted ${cctl.reset} - ${filepath}`);
3534
3589
  return;
3535
3590
  }
3536
3591
  delete require.cache[fullpath];
@@ -3539,7 +3594,7 @@ class FluxionRouter {
3539
3594
  const matchesInclude = this.cx.options.include.some((pattern) => minimatch(filepath, pattern));
3540
3595
  if (!matchesInclude) {
3541
3596
  this.handlers.delete(filepath);
3542
- this.cx.logger.info(`[${filepath}] skipped (not in include)`);
3597
+ this.cx.logger.info(`${cctl.yellow}Skipped ${cctl.reset} - ${filepath}`);
3543
3598
  return;
3544
3599
  }
3545
3600
  // Step 3: Check if file matches exclude patterns
@@ -3547,7 +3602,7 @@ class FluxionRouter {
3547
3602
  const matchesExclude = this.cx.options.exclude.some((pattern) => minimatch(filepath, pattern));
3548
3603
  if (matchesExclude) {
3549
3604
  this.handlers.delete(filepath);
3550
- this.cx.logger.info(`[${filepath}] excluded`);
3605
+ this.cx.logger.info(`${cctl.orange}Excluded${cctl.reset} - ${filepath}`);
3551
3606
  return;
3552
3607
  }
3553
3608
  // Step 4 & 5: Check if file matches apiInclude patterns
@@ -3556,12 +3611,12 @@ class FluxionRouter {
3556
3611
  if (matchesApiInclude) {
3557
3612
  const handler = loadFunction({ modulePath: fullpath });
3558
3613
  this.handlers.set(filepath, handler);
3559
- this.cx.logger.info(`[${filepath}] handler registered`);
3614
+ this.cx.logger.info(`${cctl.green}Api ${cctl.reset} - ${filepath}`);
3560
3615
  return;
3561
3616
  }
3562
3617
  // register as static resource
3563
3618
  this.handlers.set(filepath, this.makeStaticResource(filepath));
3564
- this.cx.logger.info(`[${filepath}] static resource registered`);
3619
+ this.cx.logger.info(`${cctl.brightBlue}Static ${cctl.reset} - ${filepath}`);
3565
3620
  }
3566
3621
  getHandler(url) {
3567
3622
  const relativePath = url.pathname.replace(/^[\/]+/, '').replace(/[\/]+$/, '');