xdebug-mcp 1.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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +341 -0
  3. package/dist/config.d.ts +36 -0
  4. package/dist/config.js +47 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/dbgp/connection.d.ts +52 -0
  7. package/dist/dbgp/connection.js +362 -0
  8. package/dist/dbgp/connection.js.map +1 -0
  9. package/dist/dbgp/index.d.ts +3 -0
  10. package/dist/dbgp/index.js +4 -0
  11. package/dist/dbgp/index.js.map +1 -0
  12. package/dist/dbgp/server.d.ts +34 -0
  13. package/dist/dbgp/server.js +94 -0
  14. package/dist/dbgp/server.js.map +1 -0
  15. package/dist/dbgp/types.d.ts +112 -0
  16. package/dist/dbgp/types.js +28 -0
  17. package/dist/dbgp/types.js.map +1 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.js +93 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/session/code-coverage.d.ts +94 -0
  22. package/dist/session/code-coverage.js +226 -0
  23. package/dist/session/code-coverage.js.map +1 -0
  24. package/dist/session/debug-config.d.ts +102 -0
  25. package/dist/session/debug-config.js +194 -0
  26. package/dist/session/debug-config.js.map +1 -0
  27. package/dist/session/index.d.ts +10 -0
  28. package/dist/session/index.js +11 -0
  29. package/dist/session/index.js.map +1 -0
  30. package/dist/session/logpoint-manager.d.ts +94 -0
  31. package/dist/session/logpoint-manager.js +167 -0
  32. package/dist/session/logpoint-manager.js.map +1 -0
  33. package/dist/session/manager.d.ts +41 -0
  34. package/dist/session/manager.js +135 -0
  35. package/dist/session/manager.js.map +1 -0
  36. package/dist/session/profiler.d.ts +89 -0
  37. package/dist/session/profiler.js +191 -0
  38. package/dist/session/profiler.js.map +1 -0
  39. package/dist/session/request-context.d.ts +50 -0
  40. package/dist/session/request-context.js +182 -0
  41. package/dist/session/request-context.js.map +1 -0
  42. package/dist/session/session-export.d.ts +83 -0
  43. package/dist/session/session-export.js +320 -0
  44. package/dist/session/session-export.js.map +1 -0
  45. package/dist/session/session.d.ts +92 -0
  46. package/dist/session/session.js +369 -0
  47. package/dist/session/session.js.map +1 -0
  48. package/dist/session/step-filter.d.ts +81 -0
  49. package/dist/session/step-filter.js +174 -0
  50. package/dist/session/step-filter.js.map +1 -0
  51. package/dist/session/watch-manager.d.ts +64 -0
  52. package/dist/session/watch-manager.js +137 -0
  53. package/dist/session/watch-manager.js.map +1 -0
  54. package/dist/tools/advanced.d.ts +26 -0
  55. package/dist/tools/advanced.js +502 -0
  56. package/dist/tools/advanced.js.map +1 -0
  57. package/dist/tools/breakpoints.d.ts +6 -0
  58. package/dist/tools/breakpoints.js +308 -0
  59. package/dist/tools/breakpoints.js.map +1 -0
  60. package/dist/tools/execution.d.ts +6 -0
  61. package/dist/tools/execution.js +283 -0
  62. package/dist/tools/execution.js.map +1 -0
  63. package/dist/tools/index.d.ts +31 -0
  64. package/dist/tools/index.js +44 -0
  65. package/dist/tools/index.js.map +1 -0
  66. package/dist/tools/inspection.d.ts +7 -0
  67. package/dist/tools/inspection.js +431 -0
  68. package/dist/tools/inspection.js.map +1 -0
  69. package/dist/tools/session.d.ts +6 -0
  70. package/dist/tools/session.js +164 -0
  71. package/dist/tools/session.js.map +1 -0
  72. package/dist/utils/logger.d.ts +16 -0
  73. package/dist/utils/logger.js +47 -0
  74. package/dist/utils/logger.js.map +1 -0
  75. package/dist/utils/path-mapper.d.ts +13 -0
  76. package/dist/utils/path-mapper.js +56 -0
  77. package/dist/utils/path-mapper.js.map +1 -0
  78. package/package.json +56 -0
@@ -0,0 +1,369 @@
1
+ /**
2
+ * Debug Session
3
+ * Represents a single PHP debug session with all debugging operations.
4
+ */
5
+ import { EventEmitter } from 'events';
6
+ import { logger } from '../utils/logger.js';
7
+ export class DebugSession extends EventEmitter {
8
+ connection;
9
+ id;
10
+ status = 'starting';
11
+ currentFile;
12
+ currentLine;
13
+ startTime;
14
+ breakpoints = new Map();
15
+ initialized = false;
16
+ constructor(connection) {
17
+ super();
18
+ this.connection = connection;
19
+ this.id = connection.id;
20
+ this.startTime = new Date();
21
+ // Update state on responses
22
+ connection.on('response', (response) => {
23
+ if (response.status) {
24
+ this.status = response.status;
25
+ }
26
+ if (response.message) {
27
+ this.currentFile = response.message.filename;
28
+ this.currentLine = response.message.lineno;
29
+ }
30
+ this.emit('stateChange', this.getState());
31
+ });
32
+ connection.on('close', () => {
33
+ this.status = 'stopped';
34
+ this.emit('close');
35
+ });
36
+ connection.on('stream', (data) => {
37
+ this.emit('output', data);
38
+ });
39
+ }
40
+ get initPacket() {
41
+ return this.connection.initPacket;
42
+ }
43
+ getState() {
44
+ return {
45
+ id: this.id,
46
+ status: this.status,
47
+ filename: this.currentFile,
48
+ lineno: this.currentLine,
49
+ ideKey: this.initPacket?.ideKey,
50
+ startTime: this.startTime,
51
+ };
52
+ }
53
+ // === Initialization ===
54
+ async initialize() {
55
+ if (this.initialized)
56
+ return;
57
+ try {
58
+ // Set preferred features
59
+ await this.setFeature('max_depth', '3');
60
+ await this.setFeature('max_children', '128');
61
+ await this.setFeature('max_data', '2048');
62
+ await this.setFeature('show_hidden', '1');
63
+ this.initialized = true;
64
+ logger.debug(`Session ${this.id} initialized`);
65
+ }
66
+ catch (error) {
67
+ logger.error(`Failed to initialize session ${this.id}:`, error);
68
+ throw error;
69
+ }
70
+ }
71
+ // === Feature Negotiation ===
72
+ async setFeature(name, value) {
73
+ try {
74
+ const response = await this.connection.sendCommand('feature_set', {
75
+ n: name,
76
+ v: value,
77
+ });
78
+ return response.success === true;
79
+ }
80
+ catch {
81
+ return false;
82
+ }
83
+ }
84
+ async getFeature(name) {
85
+ try {
86
+ const response = await this.connection.sendCommand('feature_get', {
87
+ n: name,
88
+ });
89
+ const data = response.data;
90
+ return data['@_supported'] === '1' ? data['#text'] || null : null;
91
+ }
92
+ catch {
93
+ return null;
94
+ }
95
+ }
96
+ // === Breakpoint Operations ===
97
+ async setLineBreakpoint(filename, line, options) {
98
+ const args = {
99
+ t: options?.condition ? 'conditional' : 'line',
100
+ f: this.normalizeFileUri(filename),
101
+ n: line.toString(),
102
+ };
103
+ if (options?.hitValue !== undefined) {
104
+ args['h'] = options.hitValue.toString();
105
+ }
106
+ if (options?.hitCondition) {
107
+ args['o'] = options.hitCondition;
108
+ }
109
+ if (options?.temporary) {
110
+ args['r'] = '1';
111
+ }
112
+ const response = await this.connection.sendCommand('breakpoint_set', args, options?.condition);
113
+ if (response.error) {
114
+ throw new Error(`Failed to set breakpoint: ${response.error.message}`);
115
+ }
116
+ const result = this.connection.parseBreakpointSet(response);
117
+ const breakpoint = {
118
+ id: result.id,
119
+ type: options?.condition ? 'conditional' : 'line',
120
+ state: 'enabled',
121
+ resolved: result.resolved,
122
+ filename,
123
+ lineno: line,
124
+ expression: options?.condition,
125
+ hitValue: options?.hitValue,
126
+ hitCondition: options?.hitCondition,
127
+ };
128
+ this.breakpoints.set(breakpoint.id, breakpoint);
129
+ logger.debug(`Breakpoint set: ${breakpoint.id} at ${filename}:${line}`);
130
+ return breakpoint;
131
+ }
132
+ async setExceptionBreakpoint(exception = '*') {
133
+ const response = await this.connection.sendCommand('breakpoint_set', {
134
+ t: 'exception',
135
+ x: exception,
136
+ });
137
+ if (response.error) {
138
+ throw new Error(`Failed to set exception breakpoint: ${response.error.message}`);
139
+ }
140
+ const result = this.connection.parseBreakpointSet(response);
141
+ const breakpoint = {
142
+ id: result.id,
143
+ type: 'exception',
144
+ state: 'enabled',
145
+ exception,
146
+ };
147
+ this.breakpoints.set(breakpoint.id, breakpoint);
148
+ return breakpoint;
149
+ }
150
+ async setCallBreakpoint(functionName) {
151
+ const response = await this.connection.sendCommand('breakpoint_set', {
152
+ t: 'call',
153
+ m: functionName,
154
+ });
155
+ if (response.error) {
156
+ throw new Error(`Failed to set call breakpoint: ${response.error.message}`);
157
+ }
158
+ const result = this.connection.parseBreakpointSet(response);
159
+ const breakpoint = {
160
+ id: result.id,
161
+ type: 'call',
162
+ state: 'enabled',
163
+ function: functionName,
164
+ };
165
+ this.breakpoints.set(breakpoint.id, breakpoint);
166
+ return breakpoint;
167
+ }
168
+ async removeBreakpoint(breakpointId) {
169
+ const response = await this.connection.sendCommand('breakpoint_remove', {
170
+ d: breakpointId,
171
+ });
172
+ if (!response.error) {
173
+ this.breakpoints.delete(breakpointId);
174
+ logger.debug(`Breakpoint removed: ${breakpointId}`);
175
+ return true;
176
+ }
177
+ return false;
178
+ }
179
+ async updateBreakpoint(breakpointId, options) {
180
+ const args = { d: breakpointId };
181
+ if (options.state)
182
+ args['s'] = options.state;
183
+ if (options.hitValue !== undefined)
184
+ args['h'] = options.hitValue.toString();
185
+ if (options.hitCondition)
186
+ args['o'] = options.hitCondition;
187
+ const response = await this.connection.sendCommand('breakpoint_update', args);
188
+ return !response.error;
189
+ }
190
+ async getBreakpoint(breakpointId) {
191
+ const response = await this.connection.sendCommand('breakpoint_get', {
192
+ d: breakpointId,
193
+ });
194
+ if (response.error)
195
+ return null;
196
+ const breakpoints = this.connection.parseBreakpoints(response);
197
+ return breakpoints[0] || null;
198
+ }
199
+ async listBreakpoints() {
200
+ const response = await this.connection.sendCommand('breakpoint_list');
201
+ const breakpoints = this.connection.parseBreakpoints(response);
202
+ // Update local cache
203
+ this.breakpoints.clear();
204
+ for (const bp of breakpoints) {
205
+ this.breakpoints.set(bp.id, bp);
206
+ }
207
+ return breakpoints;
208
+ }
209
+ // === Execution Control ===
210
+ async run() {
211
+ const response = await this.connection.sendCommand('run');
212
+ return this.handleStepResponse(response);
213
+ }
214
+ async stepInto() {
215
+ const response = await this.connection.sendCommand('step_into');
216
+ return this.handleStepResponse(response);
217
+ }
218
+ async stepOver() {
219
+ const response = await this.connection.sendCommand('step_over');
220
+ return this.handleStepResponse(response);
221
+ }
222
+ async stepOut() {
223
+ const response = await this.connection.sendCommand('step_out');
224
+ return this.handleStepResponse(response);
225
+ }
226
+ async stop() {
227
+ await this.connection.sendCommand('stop');
228
+ this.status = 'stopped';
229
+ }
230
+ async detach() {
231
+ await this.connection.sendCommand('detach');
232
+ }
233
+ handleStepResponse(response) {
234
+ const status = response.status || 'break';
235
+ this.status = status;
236
+ if (response.message) {
237
+ this.currentFile = response.message.filename;
238
+ this.currentLine = response.message.lineno;
239
+ }
240
+ return {
241
+ status,
242
+ file: this.currentFile,
243
+ line: this.currentLine,
244
+ };
245
+ }
246
+ // === Stack Inspection ===
247
+ async getStackDepth() {
248
+ const response = await this.connection.sendCommand('stack_depth');
249
+ const data = response.data;
250
+ return parseInt(data['@_depth'] || '0', 10);
251
+ }
252
+ async getStackTrace(depth) {
253
+ const args = {};
254
+ if (depth !== undefined) {
255
+ args['d'] = depth.toString();
256
+ }
257
+ const response = await this.connection.sendCommand('stack_get', args);
258
+ return this.connection.parseStackFrames(response);
259
+ }
260
+ // === Context and Variables ===
261
+ async getContexts(stackDepth = 0) {
262
+ const response = await this.connection.sendCommand('context_names', {
263
+ d: stackDepth.toString(),
264
+ });
265
+ return this.connection.parseContexts(response);
266
+ }
267
+ async getVariables(contextId = 0, stackDepth = 0) {
268
+ const response = await this.connection.sendCommand('context_get', {
269
+ c: contextId.toString(),
270
+ d: stackDepth.toString(),
271
+ });
272
+ return this.connection.parseProperties(response);
273
+ }
274
+ async getVariable(name, options) {
275
+ const args = {
276
+ n: name,
277
+ };
278
+ if (options?.contextId !== undefined) {
279
+ args['c'] = options.contextId.toString();
280
+ }
281
+ if (options?.stackDepth !== undefined) {
282
+ args['d'] = options.stackDepth.toString();
283
+ }
284
+ if (options?.maxDepth !== undefined) {
285
+ args['m'] = options.maxDepth.toString();
286
+ }
287
+ if (options?.page !== undefined) {
288
+ args['p'] = options.page.toString();
289
+ }
290
+ const response = await this.connection.sendCommand('property_get', args);
291
+ if (response.error) {
292
+ return null;
293
+ }
294
+ return this.connection.parseProperty(response);
295
+ }
296
+ async setVariable(name, value, options) {
297
+ const args = {
298
+ n: name,
299
+ };
300
+ if (options?.contextId !== undefined) {
301
+ args['c'] = options.contextId.toString();
302
+ }
303
+ if (options?.stackDepth !== undefined) {
304
+ args['d'] = options.stackDepth.toString();
305
+ }
306
+ if (options?.type) {
307
+ args['t'] = options.type;
308
+ }
309
+ const response = await this.connection.sendCommand('property_set', args, value);
310
+ return response.success === true || !response.error;
311
+ }
312
+ // === Expression Evaluation ===
313
+ async evaluate(expression, stackDepth = 0) {
314
+ const response = await this.connection.sendCommand('eval', { d: stackDepth.toString() }, expression);
315
+ if (response.error) {
316
+ throw new Error(`Evaluation error: ${response.error.message}`);
317
+ }
318
+ return this.connection.parseProperty(response);
319
+ }
320
+ // === Source Code ===
321
+ async getSource(fileUri, beginLine, endLine) {
322
+ const args = {
323
+ f: this.normalizeFileUri(fileUri),
324
+ };
325
+ if (beginLine !== undefined)
326
+ args['b'] = beginLine.toString();
327
+ if (endLine !== undefined)
328
+ args['e'] = endLine.toString();
329
+ const response = await this.connection.sendCommand('source', args);
330
+ if (response.error)
331
+ return null;
332
+ const data = response.data;
333
+ const encoding = data['@_encoding'];
334
+ const content = data['#text'] || '';
335
+ if (encoding === 'base64' && content) {
336
+ return Buffer.from(content, 'base64').toString('utf8');
337
+ }
338
+ return content;
339
+ }
340
+ // === Stream Redirection ===
341
+ async redirectStdout(mode) {
342
+ const modeMap = { disable: '0', copy: '1', redirect: '2' };
343
+ const response = await this.connection.sendCommand('stdout', {
344
+ c: modeMap[mode],
345
+ });
346
+ return response.success === true;
347
+ }
348
+ async redirectStderr(mode) {
349
+ const modeMap = { disable: '0', copy: '1', redirect: '2' };
350
+ const response = await this.connection.sendCommand('stderr', {
351
+ c: modeMap[mode],
352
+ });
353
+ return response.success === true;
354
+ }
355
+ // === Utilities ===
356
+ normalizeFileUri(path) {
357
+ if (path.startsWith('file://')) {
358
+ return path;
359
+ }
360
+ return `file://${path}`;
361
+ }
362
+ close() {
363
+ this.connection.close();
364
+ }
365
+ get isConnected() {
366
+ return this.connection.isConnected;
367
+ }
368
+ }
369
+ //# sourceMappingURL=session.js.map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
5
+ export interface StepFilterRule {
6
+ id: string;
7
+ pattern: string;
8
+ type: 'include' | 'exclude';
9
+ enabled: boolean;
10
+ description?: string;
11
+ }
12
+ export interface FunctionCallEntry {
13
+ timestamp: Date;
14
+ name: string;
15
+ file: string;
16
+ line: number;
17
+ depth: number;
18
+ args?: string[];
19
+ }
20
+ export declare class StepFilter {
21
+ private rules;
22
+ private ruleIdCounter;
23
+ private functionHistory;
24
+ private maxHistorySize;
25
+ constructor();
26
+ /**
27
+ * Add a step filter rule
28
+ */
29
+ addRule(pattern: string, type: 'include' | 'exclude', description?: string): StepFilterRule;
30
+ /**
31
+ * Remove a rule
32
+ */
33
+ removeRule(id: string): boolean;
34
+ /**
35
+ * Enable/disable a rule
36
+ */
37
+ setRuleEnabled(id: string, enabled: boolean): boolean;
38
+ /**
39
+ * Get all rules
40
+ */
41
+ getAllRules(): StepFilterRule[];
42
+ /**
43
+ * Check if a file should be skipped during stepping
44
+ */
45
+ shouldSkip(filePath: string): boolean;
46
+ /**
47
+ * Check if a path matches a pattern
48
+ */
49
+ private matchesPattern;
50
+ /**
51
+ * Record a function call in history
52
+ */
53
+ recordFunctionCall(entry: Omit<FunctionCallEntry, 'timestamp'>): void;
54
+ /**
55
+ * Get function call history
56
+ */
57
+ getFunctionHistory(limit?: number): FunctionCallEntry[];
58
+ /**
59
+ * Clear function history
60
+ */
61
+ clearHistory(): void;
62
+ /**
63
+ * Search function history
64
+ */
65
+ searchHistory(query: string): FunctionCallEntry[];
66
+ /**
67
+ * Get function call statistics
68
+ */
69
+ getCallStatistics(): Map<string, {
70
+ count: number;
71
+ lastCall: Date;
72
+ }>;
73
+ /**
74
+ * Export filter configuration
75
+ */
76
+ exportConfig(): StepFilterRule[];
77
+ /**
78
+ * Import filter configuration
79
+ */
80
+ importConfig(rules: Array<Omit<StepFilterRule, 'id'>>): void;
81
+ }
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Step Filter
3
+ * Manages step filtering to skip vendor/library code during debugging.
4
+ */
5
+ import { logger } from '../utils/logger.js';
6
+ export class StepFilter {
7
+ rules = new Map();
8
+ ruleIdCounter = 0;
9
+ functionHistory = [];
10
+ maxHistorySize = 1000;
11
+ constructor() {
12
+ // Add default rules for common vendor directories
13
+ this.addRule('/vendor/', 'exclude', 'Skip Composer vendor directory');
14
+ this.addRule('/node_modules/', 'exclude', 'Skip Node modules');
15
+ }
16
+ /**
17
+ * Add a step filter rule
18
+ */
19
+ addRule(pattern, type, description) {
20
+ const id = `filter_${++this.ruleIdCounter}`;
21
+ const rule = {
22
+ id,
23
+ pattern,
24
+ type,
25
+ enabled: true,
26
+ description,
27
+ };
28
+ this.rules.set(id, rule);
29
+ logger.debug(`Step filter rule added: ${id} - ${type} ${pattern}`);
30
+ return rule;
31
+ }
32
+ /**
33
+ * Remove a rule
34
+ */
35
+ removeRule(id) {
36
+ return this.rules.delete(id);
37
+ }
38
+ /**
39
+ * Enable/disable a rule
40
+ */
41
+ setRuleEnabled(id, enabled) {
42
+ const rule = this.rules.get(id);
43
+ if (rule) {
44
+ rule.enabled = enabled;
45
+ return true;
46
+ }
47
+ return false;
48
+ }
49
+ /**
50
+ * Get all rules
51
+ */
52
+ getAllRules() {
53
+ return Array.from(this.rules.values());
54
+ }
55
+ /**
56
+ * Check if a file should be skipped during stepping
57
+ */
58
+ shouldSkip(filePath) {
59
+ const enabledRules = Array.from(this.rules.values()).filter((r) => r.enabled);
60
+ // Check exclude rules first
61
+ for (const rule of enabledRules) {
62
+ if (rule.type === 'exclude' && this.matchesPattern(filePath, rule.pattern)) {
63
+ // Check if any include rule overrides
64
+ const hasIncludeOverride = enabledRules.some((r) => r.type === 'include' && this.matchesPattern(filePath, r.pattern));
65
+ if (!hasIncludeOverride) {
66
+ return true;
67
+ }
68
+ }
69
+ }
70
+ return false;
71
+ }
72
+ /**
73
+ * Check if a path matches a pattern
74
+ */
75
+ matchesPattern(path, pattern) {
76
+ // Simple substring matching
77
+ if (pattern.startsWith('/') && pattern.endsWith('/')) {
78
+ // It's a regex pattern
79
+ try {
80
+ const regex = new RegExp(pattern.slice(1, -1));
81
+ return regex.test(path);
82
+ }
83
+ catch {
84
+ return path.includes(pattern);
85
+ }
86
+ }
87
+ // Glob-like matching
88
+ if (pattern.includes('*')) {
89
+ const regexPattern = pattern
90
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
91
+ .replace(/\*/g, '.*')
92
+ .replace(/\?/g, '.');
93
+ return new RegExp(regexPattern).test(path);
94
+ }
95
+ // Simple substring match
96
+ return path.includes(pattern);
97
+ }
98
+ /**
99
+ * Record a function call in history
100
+ */
101
+ recordFunctionCall(entry) {
102
+ this.functionHistory.push({
103
+ ...entry,
104
+ timestamp: new Date(),
105
+ });
106
+ // Trim history if too large
107
+ if (this.functionHistory.length > this.maxHistorySize) {
108
+ this.functionHistory = this.functionHistory.slice(-this.maxHistorySize);
109
+ }
110
+ }
111
+ /**
112
+ * Get function call history
113
+ */
114
+ getFunctionHistory(limit) {
115
+ if (limit) {
116
+ return this.functionHistory.slice(-limit);
117
+ }
118
+ return [...this.functionHistory];
119
+ }
120
+ /**
121
+ * Clear function history
122
+ */
123
+ clearHistory() {
124
+ this.functionHistory = [];
125
+ }
126
+ /**
127
+ * Search function history
128
+ */
129
+ searchHistory(query) {
130
+ const lowerQuery = query.toLowerCase();
131
+ return this.functionHistory.filter((entry) => entry.name.toLowerCase().includes(lowerQuery) ||
132
+ entry.file.toLowerCase().includes(lowerQuery));
133
+ }
134
+ /**
135
+ * Get function call statistics
136
+ */
137
+ getCallStatistics() {
138
+ const stats = new Map();
139
+ for (const entry of this.functionHistory) {
140
+ const existing = stats.get(entry.name);
141
+ if (existing) {
142
+ existing.count++;
143
+ if (entry.timestamp > existing.lastCall) {
144
+ existing.lastCall = entry.timestamp;
145
+ }
146
+ }
147
+ else {
148
+ stats.set(entry.name, { count: 1, lastCall: entry.timestamp });
149
+ }
150
+ }
151
+ return stats;
152
+ }
153
+ /**
154
+ * Export filter configuration
155
+ */
156
+ exportConfig() {
157
+ return this.getAllRules();
158
+ }
159
+ /**
160
+ * Import filter configuration
161
+ */
162
+ importConfig(rules) {
163
+ this.rules.clear();
164
+ this.ruleIdCounter = 0;
165
+ for (const rule of rules) {
166
+ this.addRule(rule.pattern, rule.type, rule.description);
167
+ const added = this.rules.get(`filter_${this.ruleIdCounter}`);
168
+ if (added) {
169
+ added.enabled = rule.enabled;
170
+ }
171
+ }
172
+ }
173
+ }
174
+ //# sourceMappingURL=step-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-filter.js","sourceRoot":"","sources":["../../src/session/step-filter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB5C,MAAM,OAAO,UAAU;IACb,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IAC/C,aAAa,GAAW,CAAC,CAAC;IAC1B,eAAe,GAAwB,EAAE,CAAC;IAC1C,cAAc,GAAW,IAAI,CAAC;IAEtC;QACE,kDAAkD;QAClD,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,gCAAgC,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,OAAO,CACL,OAAe,EACf,IAA2B,EAC3B,WAAoB;QAEpB,MAAM,EAAE,GAAG,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAmB;YAC3B,EAAE;YACF,OAAO;YACP,IAAI;YACJ,OAAO,EAAE,IAAI;YACb,WAAW;SACZ,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED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