@monoes/monodesign 1.2.20 → 1.2.23

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 (95) hide show
  1. package/README.md +2 -2
  2. package/cli/engine/cli/main.mjs +21 -1
  3. package/cli/engine/design-system-checks.mjs +381 -0
  4. package/cli/engine/design-system-parse.mjs +433 -0
  5. package/cli/engine/design-system.mjs +20 -736
  6. package/cli/engine/detect-antipatterns-browser.js +28 -5
  7. package/cli/engine/detect-antipatterns.mjs +1 -0
  8. package/cli/engine/engines/regex/detect-text-matchers.mjs +371 -0
  9. package/cli/engine/engines/regex/detect-text-run.mjs +186 -0
  10. package/cli/engine/engines/regex/detect-text.mjs +11 -523
  11. package/cli/engine/engines/static-html/css-cascade-color.mjs +219 -0
  12. package/cli/engine/engines/static-html/css-cascade-static-data.mjs +138 -0
  13. package/cli/engine/engines/static-html/css-cascade-static-dom.mjs +132 -0
  14. package/cli/engine/engines/static-html/css-cascade-static-parse.mjs +393 -0
  15. package/cli/engine/engines/static-html/css-cascade.mjs +24 -837
  16. package/cli/engine/engines/static-html/detect-html.mjs +6 -1
  17. package/cli/engine/findings-group.mjs +94 -0
  18. package/cli/engine/fix/index.mjs +1 -26
  19. package/cli/engine/fix/unified-diff.mjs +107 -0
  20. package/cli/engine/rules/checks-background.mjs +17 -3
  21. package/cli/engine/rules/checks-element.mjs +2 -0
  22. package/cli/engine/rules/checks-pure.mjs +9 -2
  23. package/cli/lib/monodesign-config-consent.mjs +93 -0
  24. package/cli/lib/monodesign-config-core.mjs +37 -0
  25. package/cli/lib/monodesign-config-detection.mjs +133 -0
  26. package/cli/lib/monodesign-config-filter.mjs +198 -0
  27. package/cli/lib/monodesign-config-ignore-value.mjs +212 -0
  28. package/cli/lib/monodesign-config.mjs +21 -623
  29. package/package.json +2 -2
  30. package/skill/scripts/context-fields.mjs +65 -0
  31. package/skill/scripts/context-resolve.mjs +425 -0
  32. package/skill/scripts/context-update.mjs +151 -0
  33. package/skill/scripts/context-utils.mjs +68 -0
  34. package/skill/scripts/context-workspace.mjs +245 -0
  35. package/skill/scripts/context.mjs +17 -891
  36. package/skill/scripts/hook-admin-config.mjs +152 -0
  37. package/skill/scripts/hook-admin-ignore.mjs +131 -0
  38. package/skill/scripts/hook-admin-manifest.mjs +292 -0
  39. package/skill/scripts/hook-admin.mjs +8 -541
  40. package/skill/scripts/hook-lib-cache.mjs +145 -0
  41. package/skill/scripts/hook-lib-config.mjs +292 -0
  42. package/skill/scripts/hook-lib-detector.mjs +72 -0
  43. package/skill/scripts/hook-lib-events.mjs +182 -0
  44. package/skill/scripts/hook-lib-findings.mjs +201 -0
  45. package/skill/scripts/hook-lib-ignore.mjs +205 -0
  46. package/skill/scripts/hook-lib-render.mjs +273 -0
  47. package/skill/scripts/hook-lib-run.mjs +281 -0
  48. package/skill/scripts/hook-lib-scan-targets.mjs +128 -0
  49. package/skill/scripts/hook-lib.mjs +71 -1747
  50. package/skill/scripts/lib/design-parser-colors.mjs +182 -0
  51. package/skill/scripts/lib/design-parser-extract.mjs +333 -0
  52. package/skill/scripts/lib/design-parser-sections.mjs +214 -0
  53. package/skill/scripts/lib/design-parser-yaml.mjs +135 -0
  54. package/skill/scripts/lib/design-parser.mjs +10 -783
  55. package/skill/scripts/live/manual-apply-chunk.mjs +151 -0
  56. package/skill/scripts/live/manual-apply-compact.mjs +122 -0
  57. package/skill/scripts/live/manual-apply-evidence.mjs +115 -0
  58. package/skill/scripts/live/manual-apply-log.mjs +179 -0
  59. package/skill/scripts/live/manual-apply-transaction.mjs +122 -0
  60. package/skill/scripts/live/manual-apply.mjs +65 -640
  61. package/skill/scripts/live/svelte-component-accept.mjs +248 -0
  62. package/skill/scripts/live/svelte-component-css.mjs +230 -0
  63. package/skill/scripts/live/svelte-component-markup.mjs +104 -0
  64. package/skill/scripts/live/svelte-component-scaffold.mjs +118 -0
  65. package/skill/scripts/live/svelte-component-session.mjs +158 -0
  66. package/skill/scripts/live/svelte-component.mjs +32 -792
  67. package/skill/scripts/live-accept-mutate.mjs +152 -0
  68. package/skill/scripts/live-accept-parse.mjs +370 -0
  69. package/skill/scripts/live-accept-scrub.mjs +59 -0
  70. package/skill/scripts/live-accept-search.mjs +58 -0
  71. package/skill/scripts/live-accept.mjs +15 -631
  72. package/skill/scripts/live-commit-manual-edits-paths.mjs +27 -0
  73. package/skill/scripts/live-commit-manual-edits-repair.mjs +166 -0
  74. package/skill/scripts/live-commit-manual-edits-rollback.mjs +231 -0
  75. package/skill/scripts/live-commit-manual-edits-utils.mjs +167 -0
  76. package/skill/scripts/live-commit-manual-edits-verify.mjs +356 -0
  77. package/skill/scripts/live-commit-manual-edits.mjs +24 -881
  78. package/skill/scripts/live-copy-edit-agent.mjs +16 -551
  79. package/skill/scripts/live-copy-edit-compact.mjs +137 -0
  80. package/skill/scripts/live-copy-edit-post-apply.mjs +175 -0
  81. package/skill/scripts/live-copy-edit-runners.mjs +297 -0
  82. package/skill/scripts/live-inject-csp.mjs +132 -0
  83. package/skill/scripts/live-inject-files.mjs +229 -0
  84. package/skill/scripts/live-inject-tag.mjs +114 -0
  85. package/skill/scripts/live-inject.mjs +13 -440
  86. package/skill/scripts/live-server-poll.mjs +232 -0
  87. package/skill/scripts/live-server-routes.mjs +449 -0
  88. package/skill/scripts/live-server-state.mjs +361 -0
  89. package/skill/scripts/live-server.mjs +10 -946
  90. package/skill/scripts/live-wrap-css.mjs +132 -0
  91. package/skill/scripts/live-wrap-manual-edit.mjs +153 -0
  92. package/skill/scripts/live-wrap-search.mjs +247 -0
  93. package/skill/scripts/live-wrap.mjs +21 -484
  94. package/skill/scripts/palette-seeds.mjs +401 -0
  95. package/skill/scripts/palette.mjs +1 -395
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Detection findings/ignore-file filtering for monodesign-config.mjs: glob
3
+ * matching against `detector.ignoreFiles`, and matching findings against
4
+ * `detector.ignoreValues` entries (including scoped-to-file wildcards).
5
+ *
6
+ * Split out of monodesign-config.mjs. See that file for context.
7
+ */
8
+ import { isAbsolute, relative, resolve, sep } from 'node:path';
9
+ import {
10
+ ignoreValueMatches,
11
+ normalizeIgnoreRule,
12
+ normalizeIgnoreValue,
13
+ normalizeIgnoreValueEntries,
14
+ } from './monodesign-config-ignore-value.mjs';
15
+
16
+ // Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
17
+ function globToRegex(glob) {
18
+ let re = '^';
19
+ let i = 0;
20
+ while (i < glob.length) {
21
+ const c = glob[i];
22
+ if (c === '*') {
23
+ if (glob[i + 1] === '*') {
24
+ re += '.*';
25
+ i += 2;
26
+ if (glob[i] === '/') i += 1;
27
+ } else {
28
+ re += '[^/]*';
29
+ i += 1;
30
+ }
31
+ } else if (c === '?') {
32
+ re += '[^/]';
33
+ i += 1;
34
+ } else if (c === '{') {
35
+ const end = glob.indexOf('}', i);
36
+ if (end === -1) { re += '\\{'; i += 1; continue; }
37
+ const parts = glob.slice(i + 1, end).split(',').map((p) => p.replace(/[.+^$()|[\]\\]/g, '\\$&'));
38
+ re += `(?:${parts.join('|')})`;
39
+ i = end + 1;
40
+ } else if (/[.+^$()|[\]\\]/.test(c)) {
41
+ re += `\\${c}`;
42
+ i += 1;
43
+ } else {
44
+ re += c;
45
+ i += 1;
46
+ }
47
+ }
48
+ re += '$';
49
+ return new RegExp(re);
50
+ }
51
+
52
+ export function matchesAnyGlob(filePath, globs) {
53
+ if (!Array.isArray(globs) || globs.length === 0) return false;
54
+ const normalized = String(filePath || '').split(sep).join('/');
55
+ for (const glob of globs) {
56
+ try {
57
+ const re = globToRegex(String(glob));
58
+ if (re.test(normalized)) return true;
59
+ const base = normalized.split('/').pop();
60
+ if (re.test(base)) return true;
61
+ } catch {
62
+ /* malformed glob, skip */
63
+ }
64
+ }
65
+ return false;
66
+ }
67
+
68
+ export function shouldIgnoreDetectionFile(filePath, root, config) {
69
+ const globs = config?.ignoreFiles || [];
70
+ if (!Array.isArray(globs) || globs.length === 0) return false;
71
+ const raw = String(filePath || '').trim();
72
+ if (!raw) return false;
73
+ if (matchesAnyGlob(raw, globs)) return true;
74
+
75
+ try {
76
+ const abs = isAbsolute(raw) ? raw : resolve(root, raw);
77
+ if (matchesAnyGlob(abs, globs)) return true;
78
+ const rel = relative(root, abs);
79
+ if (rel && !rel.startsWith('..') && !isAbsolute(rel)) {
80
+ return matchesAnyGlob(rel, globs);
81
+ }
82
+ } catch {
83
+ /* ignore */
84
+ }
85
+ return false;
86
+ }
87
+
88
+ export function filterDetectionFindings(findings, config) {
89
+ if (!Array.isArray(findings) || findings.length === 0) return [];
90
+ const ignoreRules = new Set((config?.ignoreRules || []).map((rule) => normalizeIgnoreRule(rule)));
91
+ const ignoreValues = normalizeIgnoreValueEntries(config?.ignoreValues || []);
92
+ return findings.filter((finding) => {
93
+ if (!finding || typeof finding !== 'object') return false;
94
+ if (ignoreRules.has(normalizeIgnoreRule(finding.antipattern))) return false;
95
+ if (isIgnoredFindingValue(finding, ignoreValues)) return false;
96
+ return true;
97
+ });
98
+ }
99
+
100
+ function isIgnoredFindingValue(finding, ignoreValues) {
101
+ if (!Array.isArray(ignoreValues) || ignoreValues.length === 0) return false;
102
+ const rule = normalizeIgnoreRule(finding.antipattern);
103
+ if (!rule) return false;
104
+ // File-scoped wildcards suppress rules with no extractable value, such as side-tab.
105
+ const value = extractFindingIgnoreValue(finding);
106
+ return ignoreValues.some((entry) => {
107
+ if (entry.rule !== rule) return false;
108
+ const wildcardValue = entry.value === '*';
109
+ if (!wildcardValue && (!value || !ignoreValueMatches(rule, entry.value, value))) return false;
110
+ if (!Array.isArray(entry.files) || entry.files.length === 0) return !wildcardValue;
111
+ return findingMatchesScopedIgnoreFile(finding, entry.files);
112
+ });
113
+ }
114
+
115
+ function findingMatchesScopedIgnoreFile(finding, globs) {
116
+ const filePath = String(finding?.file || '').trim();
117
+ if (!filePath) return false;
118
+ if (matchesAnyGlob(filePath, globs)) return true;
119
+
120
+ const normalized = filePath.split(sep).join('/');
121
+ const parts = normalized.split('/').filter(Boolean);
122
+ for (let i = 0; i < parts.length; i++) {
123
+ const suffix = parts.slice(i).join('/');
124
+ if (matchesAnyGlob(suffix, globs)) return true;
125
+ }
126
+ return false;
127
+ }
128
+
129
+ export function extractFindingIgnoreValue(finding) {
130
+ if (!finding || typeof finding !== 'object') return '';
131
+ const rule = normalizeIgnoreRule(finding.antipattern);
132
+ const directValueRules = new Set([
133
+ 'overused-font',
134
+ 'bounce-easing',
135
+ 'design-system-font',
136
+ 'design-system-color',
137
+ 'design-system-radius',
138
+ ]);
139
+ if (!directValueRules.has(rule)) return '';
140
+ return normalizeIgnoreValue(extractFindingIgnoreValueRaw(finding, rule));
141
+ }
142
+
143
+ function extractFindingIgnoreValueRaw(finding, rule = normalizeIgnoreRule(finding?.antipattern)) {
144
+ const direct = cleanIgnoreValueDisplay(finding.ignoreValue || finding.value || '');
145
+ if (direct) return direct;
146
+
147
+ const candidates = [finding.detail, finding.snippet].filter((v) => typeof v === 'string' && v);
148
+ for (const text of candidates) {
149
+ if (rule === 'bounce-easing') {
150
+ const motion = extractMotionIgnoreValue(text);
151
+ if (motion) return motion;
152
+ continue;
153
+ }
154
+
155
+ const primary = text.match(/Primary font:\s*([^()\n;]+)/i);
156
+ if (primary) return cleanIgnoreValueDisplay(primary[1]);
157
+
158
+ const family = text.match(/font-family\s*:\s*["']?([^'",;\n]+)/i);
159
+ if (family) return cleanIgnoreValueDisplay(family[1]);
160
+
161
+ const google = text.match(/[?&]family=([^&:;\n]+)/i);
162
+ if (google) {
163
+ try {
164
+ return cleanIgnoreValueDisplay(decodeURIComponent(google[1]));
165
+ } catch {
166
+ return cleanIgnoreValueDisplay(google[1]);
167
+ }
168
+ }
169
+ }
170
+
171
+ return '';
172
+ }
173
+
174
+ function extractMotionIgnoreValue(text) {
175
+ const tailwind = text.match(/\banimate-bounce\b/i);
176
+ if (tailwind) return cleanIgnoreValueDisplay(tailwind[0]);
177
+
178
+ const bezier = text.match(/cubic-bezier\([^)]+\)/i);
179
+ if (bezier) return cleanIgnoreValueDisplay(bezier[0]);
180
+
181
+ const animation = text.match(/animation(?:-name)?\s*:\s*([^;\n]+)/i);
182
+ if (animation) {
183
+ const token = animation[1]
184
+ .split(/[,\s]+/)
185
+ .find((part) => /bounce|elastic|wobble|jiggle|spring/i.test(part));
186
+ if (token) return cleanIgnoreValueDisplay(token);
187
+ }
188
+
189
+ return '';
190
+ }
191
+
192
+ function cleanIgnoreValueDisplay(value) {
193
+ return String(value || '')
194
+ .trim()
195
+ .replace(/^["']|["']$/g, '')
196
+ .replace(/\+/g, ' ')
197
+ .replace(/\s+/g, ' ');
198
+ }
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Ignore-value normalization for monodesign-config.mjs: canonicalizing rule
3
+ * ids and finding values (including CSS color parsing, so
4
+ * `design-system-color` ignores match regardless of color-function syntax).
5
+ *
6
+ * Split out of monodesign-config.mjs. See that file for context.
7
+ */
8
+ import { uniqueStrings } from './monodesign-config-core.mjs';
9
+
10
+ export function normalizeIgnoreValue(value) {
11
+ return String(value || '')
12
+ .trim()
13
+ .replace(/^["']|["']$/g, '')
14
+ .replace(/\+/g, ' ')
15
+ .replace(/\s+/g, ' ')
16
+ .toLowerCase();
17
+ }
18
+
19
+ export function normalizeIgnoreRule(rule) {
20
+ return String(rule || '').trim().toLowerCase();
21
+ }
22
+
23
+ function colorIgnoreKey(value) {
24
+ const color = parseIgnoreColor(value);
25
+ if (!color) return '';
26
+ return `${color.r},${color.g},${color.b},${Math.round(color.a * 255)}`;
27
+ }
28
+
29
+ function parseIgnoreColor(value) {
30
+ const text = String(value || '').trim().toLowerCase();
31
+ if (!text) return null;
32
+
33
+ const hex = text.match(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);
34
+ if (hex) return parseHexIgnoreColor(hex[1]);
35
+
36
+ const rgb = text.match(/^rgba?\((.*)\)$/i);
37
+ if (rgb) {
38
+ const parts = splitColorArgs(rgb[1]);
39
+ if (parts.length < 3 || parts.length > 4) return null;
40
+ const r = parseRgbChannel(parts[0]);
41
+ const g = parseRgbChannel(parts[1]);
42
+ const b = parseRgbChannel(parts[2]);
43
+ const a = parts[3] === undefined ? 1 : parseAlphaChannel(parts[3]);
44
+ if ([r, g, b, a].some((v) => v === null)) return null;
45
+ return { r, g, b, a };
46
+ }
47
+
48
+ const hsl = text.match(/^hsla?\((.*)\)$/i);
49
+ if (hsl) {
50
+ const parts = splitColorArgs(hsl[1]);
51
+ if (parts.length < 3 || parts.length > 4) return null;
52
+ const h = parseHueChannel(parts[0]);
53
+ const s = parsePercentChannel(parts[1]);
54
+ const l = parsePercentChannel(parts[2]);
55
+ const a = parts[3] === undefined ? 1 : parseAlphaChannel(parts[3]);
56
+ if ([h, s, l, a].some((v) => v === null)) return null;
57
+ return hslToRgb(h, s, l, a);
58
+ }
59
+
60
+ return null;
61
+ }
62
+
63
+ function parseHexIgnoreColor(hex) {
64
+ if (hex.length === 3 || hex.length === 4) {
65
+ const r = parseInt(hex[0] + hex[0], 16);
66
+ const g = parseInt(hex[1] + hex[1], 16);
67
+ const b = parseInt(hex[2] + hex[2], 16);
68
+ const a = hex.length === 4 ? parseInt(hex[3] + hex[3], 16) / 255 : 1;
69
+ return { r, g, b, a };
70
+ }
71
+ const r = parseInt(hex.slice(0, 2), 16);
72
+ const g = parseInt(hex.slice(2, 4), 16);
73
+ const b = parseInt(hex.slice(4, 6), 16);
74
+ const a = hex.length === 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1;
75
+ return { r, g, b, a };
76
+ }
77
+
78
+ function splitColorArgs(body) {
79
+ const text = String(body || '').trim();
80
+ if (!text) return [];
81
+ if (text.includes(',')) {
82
+ const parts = text.split(',').map((part) => part.trim()).filter(Boolean);
83
+ const last = parts[parts.length - 1];
84
+ if (last?.includes('/')) {
85
+ const split = last.split('/').map((part) => part.trim()).filter(Boolean);
86
+ return [...parts.slice(0, -1), ...split];
87
+ }
88
+ return parts;
89
+ }
90
+ return text.replace(/\s*\/\s*/g, ' / ').split(/\s+/).filter((part) => part && part !== '/');
91
+ }
92
+
93
+ function parseRgbChannel(raw) {
94
+ const text = String(raw || '').trim();
95
+ const match = text.match(/^(-?\d*\.?\d+)(%)?$/);
96
+ if (!match) return null;
97
+ const value = Number.parseFloat(match[1]);
98
+ if (!Number.isFinite(value)) return null;
99
+ const scaled = match[2] ? value * 2.55 : value;
100
+ if (scaled < 0 || scaled > 255) return null;
101
+ return Math.round(scaled);
102
+ }
103
+
104
+ function parseAlphaChannel(raw) {
105
+ const text = String(raw || '').trim();
106
+ const match = text.match(/^(-?\d*\.?\d+)(%)?$/);
107
+ if (!match) return null;
108
+ const value = Number.parseFloat(match[1]);
109
+ if (!Number.isFinite(value)) return null;
110
+ const alpha = match[2] ? value / 100 : value;
111
+ return alpha >= 0 && alpha <= 1 ? alpha : null;
112
+ }
113
+
114
+ function parseHueChannel(raw) {
115
+ const text = String(raw || '').trim();
116
+ const match = text.match(/^(-?\d*\.?\d+)(deg|rad|turn|grad)?$/);
117
+ if (!match) return null;
118
+ const value = Number.parseFloat(match[1]);
119
+ if (!Number.isFinite(value)) return null;
120
+ const unit = match[2] || 'deg';
121
+ if (unit === 'turn') return value * 360;
122
+ if (unit === 'rad') return value * (180 / Math.PI);
123
+ if (unit === 'grad') return value * 0.9;
124
+ return value;
125
+ }
126
+
127
+ function parsePercentChannel(raw) {
128
+ const text = String(raw || '').trim();
129
+ const match = text.match(/^(-?\d*\.?\d+)%$/);
130
+ if (!match) return null;
131
+ const value = Number.parseFloat(match[1]);
132
+ if (!Number.isFinite(value)) return null;
133
+ return value >= 0 && value <= 100 ? value / 100 : null;
134
+ }
135
+
136
+ function hslToRgb(hue, saturation, lightness, alpha) {
137
+ const h = (((hue % 360) + 360) % 360) / 360;
138
+ if (saturation === 0) {
139
+ const gray = clampByte(Math.round(lightness * 255));
140
+ return { r: gray, g: gray, b: gray, a: alpha };
141
+ }
142
+ const q = lightness < 0.5
143
+ ? lightness * (1 + saturation)
144
+ : lightness + saturation - lightness * saturation;
145
+ const p = 2 * lightness - q;
146
+ const toRgb = (t) => {
147
+ let channel = t;
148
+ if (channel < 0) channel += 1;
149
+ if (channel > 1) channel -= 1;
150
+ if (channel < 1 / 6) return p + (q - p) * 6 * channel;
151
+ if (channel < 1 / 2) return q;
152
+ if (channel < 2 / 3) return p + (q - p) * (2 / 3 - channel) * 6;
153
+ return p;
154
+ };
155
+ return {
156
+ r: clampByte(Math.round(toRgb(h + 1 / 3) * 255)),
157
+ g: clampByte(Math.round(toRgb(h) * 255)),
158
+ b: clampByte(Math.round(toRgb(h - 1 / 3) * 255)),
159
+ a: alpha,
160
+ };
161
+ }
162
+
163
+ function clampByte(value) {
164
+ return Math.min(255, Math.max(0, value));
165
+ }
166
+
167
+ export function ignoreValueMatches(rule, entryValue, findingValue) {
168
+ if (entryValue === findingValue) return true;
169
+ if (rule !== 'design-system-color') return false;
170
+ const entryColor = colorIgnoreKey(entryValue);
171
+ return Boolean(entryColor && entryColor === colorIgnoreKey(findingValue));
172
+ }
173
+
174
+ export function normalizeIgnoreValueEntries(entries) {
175
+ if (!Array.isArray(entries)) return [];
176
+ const out = [];
177
+ for (const entry of entries) {
178
+ if (!entry || typeof entry !== 'object') continue;
179
+ const rule = normalizeIgnoreRule(entry.rule);
180
+ const value = normalizeIgnoreValue(entry.value);
181
+ if (!rule || !value) continue;
182
+ const normalized = { rule, value };
183
+ const files = uniqueStrings([
184
+ ...(typeof entry.file === 'string' && entry.file.trim() ? [entry.file.trim()] : []),
185
+ ...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
186
+ ]);
187
+ if (files.length > 0) normalized.files = files;
188
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
189
+ normalized.reason = entry.reason.trim();
190
+ }
191
+ if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
192
+ normalized.createdAt = entry.createdAt.trim();
193
+ }
194
+ out.push(normalized);
195
+ }
196
+ return out;
197
+ }
198
+
199
+ export function mergeIgnoreValues(existing, incoming) {
200
+ const map = new Map();
201
+ for (const entry of normalizeIgnoreValueEntries(existing)) {
202
+ map.set(`${entry.rule}\0${entry.value}\0${ignoreValueFilesKey(entry.files)}`, entry);
203
+ }
204
+ for (const entry of normalizeIgnoreValueEntries(incoming)) {
205
+ map.set(`${entry.rule}\0${entry.value}\0${ignoreValueFilesKey(entry.files)}`, entry);
206
+ }
207
+ return Array.from(map.values());
208
+ }
209
+
210
+ function ignoreValueFilesKey(files) {
211
+ return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
212
+ }