maomao-terminal 1.0.2 → 1.0.3

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 (2) hide show
  1. package/README.md +14 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -81,21 +81,25 @@ import { useEffect } from 'react';
81
81
  import { useTerminalContext } from 'maomao-terminal';
82
82
 
83
83
  const UserProfile = ({ userId }) => {
84
- const { registerCommand, unregisterCommand } = useTerminalContext();
84
+ const { registerDynamicCommands, unregisterDynamicCommands } = useTerminalContext();
85
85
 
86
86
  useEffect(() => {
87
- // Register a command specific to this component
88
- registerCommand({
89
- command: 'getUser',
90
- response: async (args) => {
91
- // You can clear data, fetch API, or log info
92
- return `Current User ID: ${userId}`;
87
+ const commands = [
88
+ {
89
+ command: 'getUser',
90
+ response: async (args) => {
91
+ // You can clear data, fetch API, or log info
92
+ return `Current User ID: ${userId}`;
93
+ }
93
94
  }
94
- });
95
+ ];
96
+
97
+ // Register a command specific to this component
98
+ registerDynamicCommands(commands);
95
99
 
96
100
  // Cleanup when component unmounts
97
- return () => unregisterCommand('getUser');
98
- }, [userId, registerCommand, unregisterCommand]);
101
+ return () => unregisterDynamicCommands(commands);
102
+ }, [userId, registerDynamicCommands, unregisterDynamicCommands]);
99
103
 
100
104
  return <div>User Profile Component</div>;
101
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maomao-terminal",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A React-style terminal component library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",