recoder-code 2.2.0 → 2.2.2

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.
@@ -57,21 +57,41 @@ class EnhancedPluginManager {
57
57
  filename: filename,
58
58
  enabled: pluginModule.enabled !== false,
59
59
 
60
- // Plugin functions
61
- init: pluginModule.init || (() => {}),
62
- cleanup: pluginModule.cleanup || (() => {}),
63
- onMessage: pluginModule.onMessage || null,
64
- onResponse: pluginModule.onResponse || null,
65
- onCommand: pluginModule.onCommand || null,
66
- onFileChange: pluginModule.onFileChange || null,
60
+ // Plugin functions - bind to original module context
61
+ init: pluginModule.init ? pluginModule.init.bind(pluginModule) : (() => {}),
62
+ cleanup: pluginModule.cleanup ? pluginModule.cleanup.bind(pluginModule) : (() => {}),
63
+ onMessage: pluginModule.onMessage ? pluginModule.onMessage.bind(pluginModule) : null,
64
+ onResponse: pluginModule.onResponse ? pluginModule.onResponse.bind(pluginModule) : null,
65
+ onCommand: pluginModule.onCommand ? pluginModule.onCommand.bind(pluginModule) : null,
66
+ onFileChange: pluginModule.onFileChange ? pluginModule.onFileChange.bind(pluginModule) : null,
67
67
 
68
- // Custom commands
69
- commands: pluginModule.commands || {},
68
+ // Store reference to original module for context
69
+ module: pluginModule,
70
70
 
71
- // Hooks
72
- hooks: pluginModule.hooks || {}
71
+ // Custom commands - bind each command handler
72
+ commands: {},
73
+
74
+ // Hooks - bind each hook handler
75
+ hooks: {}
73
76
  };
74
77
 
78
+ // Bind ALL methods of the plugin module to preserve context
79
+ Object.getOwnPropertyNames(pluginModule).forEach(prop => {
80
+ if (typeof pluginModule[prop] === 'function' && !plugin.hasOwnProperty(prop)) {
81
+ plugin[prop] = pluginModule[prop].bind(pluginModule);
82
+ }
83
+ });
84
+
85
+ // Bind command handlers to original module context
86
+ Object.entries(pluginModule.commands || {}).forEach(([command, handler]) => {
87
+ plugin.commands[command] = typeof handler === 'function' ? handler.bind(pluginModule) : handler;
88
+ });
89
+
90
+ // Bind hook handlers to original module context
91
+ Object.entries(pluginModule.hooks || {}).forEach(([hook, handler]) => {
92
+ plugin.hooks[hook] = typeof handler === 'function' ? handler.bind(pluginModule) : handler;
93
+ });
94
+
75
95
  // Register plugin
76
96
  this.plugins.set(plugin.name, plugin);
77
97
 
@@ -8,7 +8,9 @@
8
8
  const fs = require('fs');
9
9
  const path = require('path');
10
10
  const { execSync, spawn } = require('child_process');
11
- const chalk = require('chalk');
11
+ // Handle chalk properly
12
+ const chalkModule = require('chalk');
13
+ const chalk = chalkModule.default || chalkModule;
12
14
  const { performance } = require('perf_hooks');
13
15
 
14
16
  class PerformanceBenchmark {
@@ -8,7 +8,9 @@
8
8
  const fs = require('fs');
9
9
  const path = require('path');
10
10
  const { execSync } = require('child_process');
11
- const chalk = require('chalk');
11
+ // Handle chalk properly
12
+ const chalkModule = require('chalk');
13
+ const chalk = chalkModule.default || chalkModule;
12
14
 
13
15
  class SecurityAuditor {
14
16
  constructor() {
package/setup.js CHANGED
@@ -3,7 +3,9 @@
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const readline = require('readline');
6
- const chalk = require('chalk');
6
+ // Handle chalk properly
7
+ const chalkModule = require('chalk');
8
+ const chalk = chalkModule.default || chalkModule;
7
9
  const { exec } = require('child_process');
8
10
  const { promisify } = require('util');
9
11