@mathiscode/pucc 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.
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # Pucc
2
+
3
+ Power User Console Component - A browser library that provides a console command system.
4
+
5
+ Register custom commands and execute them via the browser console with a `$` prefix or via the dropdown or embedded terminal Custom Element.
6
+
7
+ This can be very useful for web apps that need to provide a console for users to interact with the app, bypassing the UI for power users.
8
+
9
+ ## Features
10
+
11
+ - 🚀 Zero dependencies (runtime)
12
+ - 📦 Built with esbuild for fast builds
13
+ - 🔧 TypeScript for type safety
14
+ - 🎯 Flexible command parsing (positional args + key=value pairs)
15
+ - 📝 Built-in commands: `$help`, `$about`
16
+ - 🔌 Extensible command system
17
+
18
+ ## Installation
19
+
20
+ ### Via pnpm/yarn/npm
21
+
22
+ ```bash
23
+ pnpm add @mathiscode/pucc
24
+ # or
25
+ yarn add @mathiscode/pucc
26
+ # or
27
+ npm install @mathiscode/pucc
28
+ ```
29
+
30
+ ### Via Script Tag
31
+
32
+ ```html
33
+ <script src="https://unpkg.com/@mathiscode/pucc/dist/pucc.js"></script>
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### Basic Usage
39
+
40
+ After including the library, commands are automatically available in the browser console:
41
+
42
+ ```javascript
43
+ // Built-in commands
44
+ $help() // Lists all available commands
45
+ $about() // Shows library information
46
+ ```
47
+
48
+ ### Adding Custom Commands
49
+
50
+ ```javascript
51
+ // Register a new command
52
+ Pucc.addCommand('new', (args) => {
53
+ console.log('Creating:', args._[0]);
54
+ console.log('Arguments:', args);
55
+ }, 'Create a new entity');
56
+
57
+ // Now you can use it in the console or dropdown terminal:
58
+ // $new('customer', 'name="John Smith"', 'balance=5400')
59
+ // new customer name="John Smith" balance=5400
60
+ ```
61
+
62
+ ### Command Arguments
63
+
64
+ The command parser supports flexible argument formats:
65
+
66
+ **Positional arguments:**
67
+
68
+ ```javascript
69
+ $new customer
70
+ // args = { _: ['customer'] }
71
+ ```
72
+
73
+ **Key-value pairs:**
74
+
75
+ ```javascript
76
+ $new name="John Smith" balance=5400
77
+ // args = { name: "John Smith", balance: 5400 }
78
+ ```
79
+
80
+ **Mixed (positional + key-value):**
81
+
82
+ ```javascript
83
+ $new customer name="John Smith" balance=5400
84
+ // args = { _: ['customer'], name: "John Smith", balance: 5400 }
85
+ ```
86
+
87
+ **Type conversion:**
88
+
89
+ - Numbers are automatically parsed: `balance=5400` → `5400` (number)
90
+ - Booleans: `active=true` → `true` (boolean)
91
+ - Strings: `name="John"` → `"John"` (string)
92
+
93
+ ### Module Import (ESM)
94
+
95
+ ```javascript
96
+ import { Pucc } from 'pucc';
97
+
98
+ // When using ESM, no global instance is created automatically
99
+ // You have full control over whether to create a global instance
100
+ // or use terminal-only commands
101
+
102
+ // Option 1: Create a global instance (like IIFE build)
103
+ const shell = new Pucc();
104
+ shell.initialize();
105
+ // Now commands are available: $help(), $about()
106
+
107
+ // Option 2: Create a terminal-only instance
108
+ const shell = new Pucc({ enableGlobalRegistrations: false });
109
+ // Commands only available in terminal elements, not globally
110
+ ```
111
+
112
+ ### Disabling Global Command Registrations
113
+
114
+ By default, commands are registered globally on the `window` object, making them accessible from the browser console. If you want to limit command execution to only the terminal element (avoiding global namespace pollution), you can disable global registrations:
115
+
116
+ ```javascript
117
+ import { Pucc } from 'pucc';
118
+
119
+ // Create a Pucc instance with global registrations disabled
120
+ const shell = new Pucc({ enableGlobalRegistrations: false });
121
+
122
+ // Commands will only be available through the terminal
123
+ // They will NOT be accessible via window.$commandName
124
+ shell.addCommand('mycommand', (args) => {
125
+ console.log('This command is only available in the terminal');
126
+ }, 'A terminal-only command');
127
+ ```
128
+
129
+ ### Custom Command Prefix
130
+
131
+ By default, commands use the `$` prefix (e.g., `$help`, `$about`). You can customize this prefix when creating a Pucc instance:
132
+
133
+ ```javascript
134
+ import { Pucc } from 'pucc';
135
+
136
+ // Use a custom prefix (must be a valid JavaScript identifier)
137
+ const shell = new Pucc({ commandPrefix: 'cmd' });
138
+
139
+ // Now commands can be called with the custom prefix
140
+ // cmdhelp() or cmdabout() in the console
141
+ // Or without prefix: help() or about()
142
+
143
+ // Commands are still accessible both ways
144
+ shell.addCommand('greet', (args) => {
145
+ console.log(`Hello, ${args._[0] || 'World'}!`);
146
+ }, 'Greet someone');
147
+
148
+ // Can be called as: cmdgreet('Alice')
149
+ ```
150
+
151
+ **Valid prefix examples:**
152
+
153
+ - `$` (default)
154
+ - `_`
155
+ - `cmd`
156
+ - `myPrefix`
157
+ - `prefix123`
158
+ - `_prefix`
159
+
160
+ **Invalid prefix examples:**
161
+
162
+ - `>` (special character not allowed)
163
+ - `123` (cannot start with a digit)
164
+ - `prefix-` (hyphen not allowed)
165
+ - `prefix.` (dot not allowed)
166
+
167
+ **Note:** The prefix must be a valid JavaScript identifier (starts with a letter, underscore, or dollar sign; can only contain letters, digits, underscores, and dollar signs). The prefix is used for console commands and is automatically stripped when parsing command input. Commands can always be called with or without the prefix in the terminal.
168
+
169
+ ### Passing Pucc Options to Terminal Element
170
+
171
+ When using the `pucc-terminal` custom element, you can pass Pucc constructor options in two ways:
172
+
173
+ **Via attribute (for simple options):**
174
+
175
+ ```html
176
+ <pucc-terminal
177
+ embedded="true"
178
+ pucc-options='{"enableGlobalRegistrations": false, "commandPrefix": "_"}'>
179
+ </pucc-terminal>
180
+ ```
181
+
182
+ **Via property (for full functionality, including functions):**
183
+
184
+ ```javascript
185
+ import { Pucc } from 'pucc';
186
+
187
+ const terminal = document.querySelector('pucc-terminal');
188
+
189
+ terminal.puccOptions = {
190
+ enableGlobalRegistrations: false,
191
+ commandPrefix: 'cmd',
192
+ customHelpHandler: (args, shell) => {
193
+ console.log('Custom help!');
194
+ },
195
+ initialCommands: [
196
+ {
197
+ name: 'greet',
198
+ description: 'Greet someone',
199
+ handler: (args) => {
200
+ console.log(`Hello, ${args._[0] || 'World'}!`);
201
+ }
202
+ }
203
+ ]
204
+ };
205
+ ```
206
+
207
+ **Note:** The `pucc-options` attribute only supports JSON-serializable options (`enableGlobalRegistrations`, `commandPrefix`). For options that include functions (`customHelpHandler`, `initialCommands`), use the `puccOptions` property instead.
208
+
209
+ ## API Reference
210
+
211
+ ### `new Pucc(options?)`
212
+
213
+ Create a new Pucc instance.
214
+
215
+ **Parameters:**
216
+
217
+ - `options` (object, optional): Configuration options
218
+ - `customHelpHandler` (function, optional): Custom handler for the `help` command
219
+ - `initialCommands` (Command[], optional): Array of commands to register on initialization
220
+ - `enableGlobalRegistrations` (boolean, optional): Whether to register commands globally on `window`. Defaults to `true`. Set to `false` to limit commands to the dropdown/embedded terminal only.
221
+ - `commandPrefix` (string, optional): Custom prefix for console commands. Defaults to `$`. Must be a valid JavaScript identifier (starts with letter, underscore, or dollar sign; can contain letters, digits, underscores, and dollar signs). Commands can be called with or without the prefix.
222
+
223
+ **Example:**
224
+
225
+ ```javascript
226
+ // Default behavior (global registrations enabled, $ prefix)
227
+ const shell = new Pucc();
228
+
229
+ // Disable global registrations
230
+ const shell = new Pucc({ enableGlobalRegistrations: false });
231
+
232
+ // Use custom command prefix (must be a valid JavaScript identifier)
233
+ const shell = new Pucc({ commandPrefix: 'cmd_' });
234
+ // Now commands can be called as cmd_help, cmd_about, etc.
235
+ ```
236
+
237
+ ### `Pucc.addCommand(name, handler, description)`
238
+
239
+ Register a new command.
240
+
241
+ **Parameters:**
242
+
243
+ - `name` (string): Command name (without prefix)
244
+ - `handler` (function): Command handler function `(args: ParsedArgs) => void | Promise<void>`
245
+ - `description` (string): Command description (shown in `$help`)
246
+
247
+ **Example:**
248
+
249
+ ```javascript
250
+ Pucc.addCommand('greet', (args) => {
251
+ const name = args.name || args._[0] || 'World';
252
+ console.log(`Hello, ${name}!`);
253
+ }, 'Greet someone by name');
254
+ ```
255
+
256
+ ### `ParsedArgs`
257
+
258
+ The argument object passed to command handlers:
259
+
260
+ ```typescript
261
+ interface ParsedArgs {
262
+ _: string[]; // Positional arguments
263
+ [key: string]: string | number | boolean | string[];
264
+ }
265
+ ```
266
+
267
+ ## Development
268
+
269
+ ### Setup
270
+
271
+ ```bash
272
+ # Install dependencies
273
+ pnpm install
274
+
275
+ # Build for production
276
+ pnpm build
277
+
278
+ # Build in watch mode (development)
279
+ pnpm build:dev
280
+
281
+ # Run linter
282
+ pnpm lint
283
+
284
+ # Format code
285
+ pnpm format
286
+
287
+ # Run server
288
+ pnpm server
289
+
290
+ # Type check
291
+ pnpm type-check
292
+ ```
293
+
294
+ ### Project Structure
295
+
296
+ ```
297
+ pucc/
298
+ ├── src/
299
+ │ ├── index.ts # Main entry point
300
+ │ ├── core/
301
+ │ │ ├── Pucc.ts # Core class
302
+ │ │ └── CommandParser.ts # Command parser
303
+ │ ├── commands/
304
+ │ │ ├── help.ts # $help command
305
+ │ │ └── about.ts # $about command
306
+ │ └── types.ts # Type definitions
307
+ ├── config/
308
+ │ └── build.js # Build configuration
309
+ └── dist/ # Build output
310
+ ```
311
+
312
+ ## License
313
+
314
+ MIT
@@ -0,0 +1,6 @@
1
+ import type { CommandHandler } from '../types';
2
+ /**
3
+ * Built-in about command handler
4
+ */
5
+ export declare const aboutCommand: CommandHandler;
6
+ //# sourceMappingURL=about.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"about.d.ts","sourceRoot":"","sources":["../../src/commands/about.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,cA0B1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CommandHandler } from '../types';
2
+ export declare const echoCommand: CommandHandler;
3
+ //# sourceMappingURL=echo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../src/commands/echo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,eAAO,MAAM,WAAW,EAAE,cAUzB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { CommandHandler } from '../types';
2
+ /**
3
+ * Built-in help command handler
4
+ */
5
+ export declare const helpCommand: CommandHandler;
6
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAW,MAAM,UAAU,CAAC;AAGxD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,cA0CzB,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { Terminal } from '@xterm/xterm';
2
+ import '@xterm/xterm/css/xterm.css';
3
+ import type { Pucc } from '../core/Pucc';
4
+ import { TerminalLogger } from './TerminalLogger';
5
+ import type { Command, CommandHandler } from '../types';
6
+ export declare class ShellTerminal extends HTMLElement {
7
+ private terminal;
8
+ private fitAddon;
9
+ private container;
10
+ private isVisible;
11
+ private currentLine;
12
+ private cursorPos;
13
+ private history;
14
+ private historyIndex;
15
+ private savedLine;
16
+ private shell;
17
+ private hotkeyConfig;
18
+ private logger;
19
+ private promptText;
20
+ private isEmbedded;
21
+ private initialContent;
22
+ private _puccOptions;
23
+ static get observedAttributes(): string[];
24
+ constructor();
25
+ connectedCallback(): void;
26
+ disconnectedCallback(): void;
27
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
28
+ private getThemeColors;
29
+ private render;
30
+ private initializeTerminal;
31
+ private getThemeFromCSS;
32
+ private handleInput;
33
+ private replaceLine;
34
+ private executeCommand;
35
+ private setupHotkeyListener;
36
+ private handleHotkey;
37
+ private parseHotkey;
38
+ private parseHeightValue;
39
+ private updateHeight;
40
+ private updateTheme;
41
+ private writePrompt;
42
+ private updatePrompt;
43
+ private cleanup;
44
+ get visible(): boolean;
45
+ set visible(value: boolean);
46
+ private parsePuccOptions;
47
+ private initializeShell;
48
+ get terminalInstance(): Terminal | null;
49
+ get shellInstance(): Pucc | null;
50
+ set shellInstance(shell: Pucc);
51
+ get puccOptions(): {
52
+ customHelpHandler?: CommandHandler;
53
+ initialCommands?: Command[];
54
+ enableGlobalRegistrations?: boolean;
55
+ commandPrefix?: string;
56
+ } | null;
57
+ set puccOptions(options: {
58
+ customHelpHandler?: CommandHandler;
59
+ initialCommands?: Command[];
60
+ enableGlobalRegistrations?: boolean;
61
+ commandPrefix?: string;
62
+ } | null);
63
+ getLogger(): TerminalLogger | null;
64
+ get prompt(): string;
65
+ set prompt(value: string);
66
+ show(): void;
67
+ hide(): void;
68
+ toggle(): void;
69
+ write(text: string): void;
70
+ writeln(text: string): void;
71
+ clear(): void;
72
+ }
73
+ //# sourceMappingURL=ShellTerminal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShellTerminal.d.ts","sourceRoot":"","sources":["../../src/components/ShellTerminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAUvD,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,SAAS,CAAI;IACrB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,YAAY,CAA2C;IAC/D,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC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C,EAAE,OAAO,EAAE,CAAC;QAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,EAG/J;IAED,SAAS,IAAI,cAAc,GAAG,IAAI;IAIlC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAIvB;IAED,IAAI;IAiBJ,IAAI;IASJ,MAAM;IAQN,KAAK,CAAC,IAAI,EAAE,MAAM;IAMlB,OAAO,CAAC,IAAI,EAAE,MAAM;IAMpB,KAAK;CAQN"}
@@ -0,0 +1,12 @@
1
+ import type { Terminal } from '@xterm/xterm';
2
+ export declare class TerminalLogger {
3
+ private terminal;
4
+ constructor(terminal: Terminal);
5
+ write(message: string): void;
6
+ writeln(message: string): void;
7
+ info(message: string): void;
8
+ error(message: string): void;
9
+ warn(message: string): void;
10
+ success(message: string): void;
11
+ }
12
+ //# sourceMappingURL=TerminalLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerminalLogger.d.ts","sourceRoot":"","sources":["../../src/components/TerminalLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG5C,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAU;gBAEd,QAAQ,EAAE,QAAQ;IAI9B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI9B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG/B"}
@@ -0,0 +1,17 @@
1
+ import type { ParsedArgs } from '../types';
2
+ /**
3
+ * Parses command strings into structured arguments
4
+ * Supports both positional arguments and key=value pairs
5
+ *
6
+ * Examples:
7
+ * - `$new customer` → `{ _: ['customer'] }`
8
+ * - `name="John Smith" balance=5400` → `{ name: "John Smith", balance: 5400 }`
9
+ * - `$new customer name="John"` → `{ _: ['customer'], name: "John" }`
10
+ */
11
+ export declare class CommandParser {
12
+ /**
13
+ * Parse a command string into structured arguments
14
+ */
15
+ static parse(input: string): ParsedArgs;
16
+ }
17
+ //# sourceMappingURL=CommandParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandParser.d.ts","sourceRoot":"","sources":["../../src/core/CommandParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;GAQG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;CA8GxC"}
@@ -0,0 +1,38 @@
1
+ import type { Command, CommandHandler } from '../types';
2
+ /**
3
+ * Core DevToolsShell class managing command registry and execution
4
+ */
5
+ export declare class DevToolsShell {
6
+ private commands;
7
+ private initialized;
8
+ constructor();
9
+ /**
10
+ * Register a custom command
11
+ */
12
+ addCommand(name: string, handler: CommandHandler, description: string): void;
13
+ /**
14
+ * Execute a command by name with arguments
15
+ */
16
+ execute(commandName: string, input?: string): void;
17
+ /**
18
+ * Get all registered commands
19
+ */
20
+ getCommands(): Command[];
21
+ /**
22
+ * Get a specific command by name
23
+ */
24
+ getCommand(name: string): Command | undefined;
25
+ /**
26
+ * Initialize the shell and attach to window
27
+ */
28
+ initialize(): void;
29
+ /**
30
+ * Register built-in commands
31
+ */
32
+ private registerBuiltInCommands;
33
+ /**
34
+ * Attach a command to window as $commandName
35
+ */
36
+ private attachCommandToWindow;
37
+ }
38
+ //# sourceMappingURL=DevToolsShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevToolsShell.d.ts","sourceRoot":"","sources":["../../src/core/DevToolsShell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAc,MAAM,UAAU,CAAC;AAKpE;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,WAAW,CAAS;;IAM5B;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IA2B5E;;OAEG;IACH,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,IAAI;IAwBtD;;OAEG;IACH,WAAW,IAAI,OAAO,EAAE;IAIxB;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI7C;;OAEG;IACH,UAAU,IAAI,IAAI;IAalB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAK/B;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAU9B"}
@@ -0,0 +1,74 @@
1
+ import type { Command, CommandHandler } from '../types';
2
+ import type { TerminalLogger } from '../components/TerminalLogger';
3
+ /**
4
+ * Core Pucc class managing command registry and execution
5
+ */
6
+ export declare class Pucc {
7
+ private commands;
8
+ private initialized;
9
+ private logger;
10
+ private customHelpHandler;
11
+ private enableGlobalRegistrations;
12
+ private commandPrefix;
13
+ constructor(options?: {
14
+ customHelpHandler?: CommandHandler;
15
+ initialCommands?: Command[];
16
+ enableGlobalRegistrations?: boolean;
17
+ commandPrefix?: string;
18
+ });
19
+ /**
20
+ * Validate that the command prefix contains only characters valid for JavaScript function names
21
+ * Valid characters: letters (a-z, A-Z), digits (0-9), underscore (_), dollar sign ($)
22
+ * Must start with a letter, underscore, or dollar sign
23
+ */
24
+ private validateCommandPrefix;
25
+ /**
26
+ * Register a custom command
27
+ */
28
+ addCommand(name: string, handler: CommandHandler, description: string): void;
29
+ /**
30
+ * Execute a command by name with arguments
31
+ */
32
+ execute(commandName: string, input?: string, logger?: TerminalLogger | null): void;
33
+ /**
34
+ * Execute a command from raw input string (handles command prefix automatically)
35
+ */
36
+ executeFromInput(input: string, logger?: TerminalLogger | null): void;
37
+ /**
38
+ * Get all registered commands
39
+ */
40
+ getCommands(): Command[];
41
+ /**
42
+ * Get a specific command by name
43
+ */
44
+ getCommand(name: string): Command | undefined;
45
+ /**
46
+ * Initialize the shell and attach to window
47
+ */
48
+ initialize(): void;
49
+ /**
50
+ * Register built-in commands
51
+ */
52
+ private registerBuiltInCommands;
53
+ /**
54
+ * Register initial commands provided in constructor
55
+ */
56
+ private registerInitialCommands;
57
+ /**
58
+ * Get the terminal logger if available
59
+ */
60
+ getLogger(): TerminalLogger | null;
61
+ /**
62
+ * Set the terminal logger
63
+ */
64
+ setLogger(logger: TerminalLogger | null): void;
65
+ /**
66
+ * Get the command prefix
67
+ */
68
+ getCommandPrefix(): string;
69
+ /**
70
+ * Attach a command to window as both prefix+commandName and commandName
71
+ */
72
+ private attachCommandToWindow;
73
+ }
74
+ //# sourceMappingURL=Pucc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pucc.d.ts","sourceRoot":"","sources":["../../src/core/Pucc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAKxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE;;GAEG;AACH,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,iBAAiB,CAA+B;IACxD,OAAO,CAAC,yBAAyB,CAAU;IAC3C,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,cAAc,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC;QAAC,yBAAyB,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