@symbo.ls/mermaid 3.14.4 → 3.14.5

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,131 +0,0 @@
1
- // Lightweight logger replacement (no external deps)
2
- // Provides log.trace/debug/info/warn/error/fatal
3
-
4
- const LEVELS = {
5
- trace: 10,
6
- debug: 20,
7
- info: 30,
8
- warn: 40,
9
- error: 50,
10
- fatal: 60,
11
- };
12
-
13
- let currentLevelName = process.env.LOG_LEVEL || 'info';
14
- if (!Object.prototype.hasOwnProperty.call(LEVELS, currentLevelName)) currentLevelName = 'info';
15
- let currentLevel = LEVELS[currentLevelName];
16
-
17
- let isLocal = process.env.NODE_ENV === 'local' || process.env.NODE_ENV === 'development';
18
-
19
- const COLORS = {
20
- trace: '\x1b[34m',
21
- debug: '\x1b[36m',
22
- info: '\x1b[32m',
23
- warn: '\x1b[33m',
24
- error: '\x1b[31m',
25
- fatal: '\x1b[35m',
26
- reset: '\x1b[0m',
27
- };
28
-
29
- function pad(num, size = 2) {
30
- let s = String(num);
31
- while (s.length < size) s = '0' + s;
32
- return s;
33
- }
34
-
35
- function utcTimestamp() {
36
- const d = new Date();
37
- const yyyy = d.getUTCFullYear();
38
- const mm = pad(d.getUTCMonth() + 1);
39
- const dd = pad(d.getUTCDate());
40
- const hh = pad(d.getUTCHours());
41
- const min = pad(d.getUTCMinutes());
42
- const ss = pad(d.getUTCSeconds());
43
- const ms = pad(d.getUTCMilliseconds(), 3);
44
- return `${yyyy}-${mm}-${dd} ${hh}:${min}:${ss}.${ms} +0000`;
45
- }
46
-
47
- function shouldLog(levelName) {
48
- return LEVELS[levelName] >= currentLevel;
49
- }
50
-
51
- function stringifyMeta(metaObjects) {
52
- if (!metaObjects.length) return '';
53
- try {
54
- return JSON.stringify(Object.assign({}, ...metaObjects));
55
- } catch {
56
- return '';
57
- }
58
- }
59
-
60
- function makeLoggerFn(levelName) {
61
- const color = COLORS[levelName];
62
- const useStderr = levelName === 'error' || levelName === 'fatal';
63
- const stream = useStderr ? console.error : console.log;
64
-
65
- return (...args) => {
66
- if (!shouldLog(levelName)) return;
67
-
68
- if (!args.length) {
69
- stream('');
70
- return;
71
- }
72
-
73
- let msg = '';
74
- let metaObjects = [];
75
-
76
- if (typeof args[0] === 'string') {
77
- msg = args[0];
78
- metaObjects = args.slice(1).filter((a) => typeof a === 'object' && a !== null);
79
-
80
- if (levelName === 'error' && args[1] instanceof Error) {
81
- metaObjects.push({
82
- err: {
83
- message: args[1].message,
84
- stack: args[1].stack,
85
- },
86
- });
87
- }
88
- } else {
89
- metaObjects = args.filter((a) => typeof a === 'object' && a !== null);
90
- }
91
-
92
- const metaStr = stringifyMeta(metaObjects);
93
- const timeStr = utcTimestamp();
94
- const lvl = levelName.toUpperCase();
95
-
96
- let output = `[${timeStr}] ${lvl}: ${msg}`;
97
- if (metaStr) output += ` ${metaStr}`;
98
-
99
- if (isLocal && color) {
100
- output = `${color}${output}${COLORS.reset}`;
101
- }
102
-
103
- stream(output);
104
- };
105
- }
106
-
107
- const log = {};
108
- for (const lvl of Object.keys(LEVELS)) {
109
- log[lvl] = makeLoggerFn(lvl);
110
- }
111
-
112
- Object.defineProperty(log, 'level', {
113
- get: () => currentLevelName,
114
- set: (lvl) => {
115
- if (Object.prototype.hasOwnProperty.call(LEVELS, lvl)) {
116
- currentLevelName = lvl;
117
- currentLevel = LEVELS[lvl];
118
- }
119
- },
120
- });
121
-
122
- export const updateLoggerConfig = (config) => {
123
- if (config?.logging?.level) {
124
- log.level = config.logging.level;
125
- }
126
- if (config?.env) {
127
- isLocal = config.env === 'local' || config.env === 'development';
128
- }
129
- };
130
-
131
- export default log;
@@ -1,30 +0,0 @@
1
- 'use strict';
2
- import log from './logger.js';
3
-
4
- export default function replaceVariablesInFileSync(filedata, replacementObject, opts = {}) {
5
- try {
6
- const regex = /(['"])\${{{\s*([^}\s]+)\s*}}}\1/g;
7
- if (!filedata) {
8
- const error = new Error('File data is empty');
9
- log.error('[REQ_FLOW] File data is empty in replaceVariablesInFileSync');
10
- throw error;
11
- }
12
-
13
- const replacedData = filedata.replace(regex, (match, quoteChar, variableName) => {
14
- if (Object.hasOwn(replacementObject, variableName)) {
15
- const value = replacementObject[variableName];
16
- return opts.allowScript ? value : value.replace(/<\/?script>/g, '&lt;/?script&gt;');
17
- } else {
18
- log.warn(
19
- `[REQ_FLOW] Missing replacement value for ${JSON.stringify({ name: variableName })}`,
20
- );
21
- return match;
22
- }
23
- });
24
-
25
- return replacedData;
26
- } catch (err) {
27
- log.error(`[REQ_FLOW] Error in replaceVariablesInFileSync: ${err}`);
28
- return null;
29
- }
30
- }