@walkeros/explorer 0.0.8 → 0.3.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/dist/index.d.mts DELETED
@@ -1,243 +0,0 @@
1
- import { Destination } from '@walkeros/core';
2
-
3
- interface ComponentAPI {
4
- id: string;
5
- mount(): void;
6
- unmount(): void;
7
- destroy(): void;
8
- on(event: string, handler: Function): () => void;
9
- emit(event: string, data?: unknown): void;
10
- getElement(): HTMLElement | null;
11
- getShadowRoot(): ShadowRoot | null;
12
- getContentRoot(): HTMLElement | ShadowRoot;
13
- injectCSS(css: string, id?: string): void;
14
- }
15
-
16
- /**
17
- * LiveCodeJS Component - JavaScript evaluation with context injection
18
- *
19
- * Features:
20
- * - Single JavaScript editor with syntax highlighting
21
- * - Direct evaluation results (no iframe)
22
- * - Context injection for functions like getMappingValue
23
- * - Two-panel layout (editor + results)
24
- * - Automatic evaluation with debouncing
25
- */
26
-
27
- interface LiveCodeJSOptions {
28
- initCode?: string;
29
- context?: Record<string, unknown>;
30
- layout?: 'horizontal' | 'vertical';
31
- autoEvaluate?: boolean;
32
- evaluationDelay?: number;
33
- height?: string;
34
- showHeader?: boolean;
35
- title?: string;
36
- autoReturn?: boolean;
37
- }
38
- interface LiveCodeJSAPI extends ComponentAPI {
39
- getCode(): string;
40
- setCode(code: string): void;
41
- setContext(context: Record<string, unknown>): void;
42
- evaluate(): void;
43
- clear(): void;
44
- getResults(): any[];
45
- setLayout(layout: 'horizontal' | 'vertical'): void;
46
- getLayout(): string;
47
- }
48
- /**
49
- * Create a LiveCodeJS component
50
- */
51
- declare function createLiveCodeJS(elementOrSelector: HTMLElement | string, options?: LiveCodeJSOptions): LiveCodeJSAPI;
52
-
53
- type SupportedLanguage = 'javascript' | 'html' | 'css' | 'json' | 'typescript' | 'text';
54
-
55
- /**
56
- * CodeEditor Component - Interactive code editor with syntax highlighting
57
- *
58
- * Features:
59
- * - Syntax highlighting for multiple languages
60
- * - Live editing with change events
61
- * - Copy to clipboard functionality
62
- * - Theme-aware styling
63
- * - Functional factory pattern
64
- */
65
-
66
- interface CodeEditorOptions {
67
- language?: SupportedLanguage;
68
- value?: string;
69
- placeholder?: string;
70
- readOnly?: boolean;
71
- tabSize?: number;
72
- fontSize?: string;
73
- height?: string;
74
- maxHeight?: string;
75
- onChange?: (value: string, language: SupportedLanguage) => void;
76
- onLanguageChange?: (language: SupportedLanguage) => void;
77
- }
78
- interface CodeEditorAPI extends ComponentAPI {
79
- getValue(): string;
80
- setValue(value: string): void;
81
- getLanguage(): SupportedLanguage;
82
- setLanguage(language: SupportedLanguage): void;
83
- focus(): void;
84
- selectAll(): void;
85
- insertText(text: string): void;
86
- getSelection(): {
87
- start: number;
88
- end: number;
89
- text: string;
90
- };
91
- }
92
- /**
93
- * Create a CodeEditor component
94
- */
95
- declare function createCodeEditor(elementOrSelector: HTMLElement | string, options?: CodeEditorOptions): CodeEditorAPI;
96
-
97
- /**
98
- * ResultDisplay Component - Display execution results, logs, and errors
99
- *
100
- * Features:
101
- * - Multiple result types (value, error, log)
102
- * - JSON formatting and syntax highlighting
103
- * - Collapsible sections
104
- * - Copy functionality
105
- * - Theme-aware styling
106
- * - Functional factory pattern
107
- */
108
-
109
- type ResultType = 'value' | 'error' | 'log' | 'warning' | 'info';
110
- interface ResultItem {
111
- type: ResultType;
112
- content: unknown;
113
- timestamp?: number;
114
- label?: string;
115
- metadata?: Record<string, unknown>;
116
- }
117
- interface ResultDisplayOptions {
118
- maxResults?: number;
119
- collapsible?: boolean;
120
- autoScroll?: boolean;
121
- height?: string;
122
- onCopy?: (content: string) => void;
123
- onClear?: () => void;
124
- }
125
- interface ResultDisplayAPI extends ComponentAPI {
126
- addResult(result: ResultItem): void;
127
- addValue(value: unknown, label?: string): void;
128
- addError(error: Error | string, label?: string): void;
129
- addLog(message: string, label?: string): void;
130
- addWarning(message: string, label?: string): void;
131
- addInfo(message: string, label?: string): void;
132
- clear(): void;
133
- getResults(): ResultItem[];
134
- setResults(results: ResultItem[]): void;
135
- }
136
- /**
137
- * Create a ResultDisplay component
138
- */
139
- declare function createResultDisplay(elementOrSelector: HTMLElement | string, options?: ResultDisplayOptions): ResultDisplayAPI;
140
-
141
- /**
142
- * MultiColumnLayout - Reusable multi-column layout component
143
- *
144
- * Features:
145
- * - Configurable column count and titles
146
- * - Unified styling with existing explorer components
147
- * - Shadow DOM support for CSS isolation
148
- * - Consistent theming and layout behavior
149
- * - Based on proven LiveCodeBase architecture
150
- */
151
-
152
- interface MultiColumnLayoutAPI extends ComponentAPI {
153
- getColumnElement(index: number): HTMLElement | null;
154
- getColumnContentElement(index: number): HTMLElement | null;
155
- setLayout(layout: 'horizontal' | 'vertical'): void;
156
- getLayout(): string;
157
- }
158
-
159
- /**
160
- * Destination Component - Three-column layout for Event, Mapping, and Result
161
- *
162
- * Features:
163
- * - Three-column layout with Event, Mapping, and Result
164
- * - Two CodeEditor components for JSON input
165
- * - Live walkerOS collector integration with custom destination
166
- * - Real destination processing with mapping transformations
167
- * - Wrap function to capture destination calls and display results
168
- * - Theme-aware styling with shadow DOM support
169
- */
170
-
171
- interface DestinationOptions {
172
- height?: string;
173
- showHeader?: boolean;
174
- title?: string;
175
- initialEvent?: string;
176
- initialMapping?: string;
177
- updateDelay?: number;
178
- destination?: Destination.Instance;
179
- }
180
- interface CapturedResult {
181
- type?: string;
182
- mappingRule?: string;
183
- data?: unknown;
184
- event?: unknown;
185
- message?: string;
186
- [key: string]: unknown;
187
- }
188
- interface DestinationAPI extends MultiColumnLayoutAPI {
189
- getEventData(): string;
190
- setEventData(data: string): void;
191
- getMappingData(): string;
192
- setMappingData(data: string): void;
193
- getResults(): CapturedResult[];
194
- refresh(): void;
195
- clear(): void;
196
- }
197
- /**
198
- * Create a Destination component
199
- */
200
- declare function createDestination(elementOrSelector: HTMLElement | string, options?: DestinationOptions): DestinationAPI;
201
-
202
- /**
203
- * JavaScript Evaluation Utilities
204
- *
205
- * Provides safe JavaScript evaluation with context injection
206
- * and result formatting for explorer components.
207
- */
208
- interface EvaluationContext {
209
- [key: string]: unknown;
210
- }
211
- interface EvaluationResult {
212
- success: boolean;
213
- result?: unknown;
214
- error?: string;
215
- executionTime?: number;
216
- }
217
- interface EvaluationOptions {
218
- autoReturn?: boolean;
219
- }
220
- /**
221
- * Safely evaluate JavaScript code with injected context
222
- */
223
- declare function evaluateJavaScript(code: string, context?: EvaluationContext, options?: EvaluationOptions): Promise<EvaluationResult>;
224
- /**
225
- * Format evaluation result for display
226
- */
227
- declare function formatEvaluationResult(result: unknown): string;
228
- /**
229
- * Create a safe evaluation context with common utilities
230
- */
231
- declare function createSafeContext(additionalContext?: EvaluationContext): EvaluationContext;
232
-
233
- /**
234
- * WalkerOS Explorer - LiveCodeJS Component
235
- *
236
- * JavaScript evaluation component with context injection
237
- * Zero dependencies, framework-agnostic
238
- */
239
-
240
- declare const version = "1.0.0";
241
- declare const name = "@walkeros/explorer";
242
-
243
- export { type CodeEditorAPI, type CodeEditorOptions, type ComponentAPI, type DestinationAPI, type DestinationOptions, type EvaluationContext, type EvaluationOptions, type EvaluationResult, type LiveCodeJSAPI, type LiveCodeJSOptions, type ResultDisplayAPI, type ResultDisplayOptions, type ResultItem, type ResultType, createCodeEditor, createDestination, createLiveCodeJS, createResultDisplay, createSafeContext, evaluateJavaScript, formatEvaluationResult, name, version };
package/serve.js DELETED
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
- // Simple HTTP server to serve the walkerOS Explorer demo
3
- const http = require('http');
4
- const fs = require('fs');
5
- const path = require('path');
6
-
7
- const port = process.env.PORT || 3002;
8
-
9
- const mimeTypes = {
10
- '.html': 'text/html',
11
- '.js': 'application/javascript',
12
- '.mjs': 'application/javascript',
13
- '.cjs': 'application/javascript',
14
- '.css': 'text/css',
15
- '.json': 'application/json',
16
- '.map': 'application/json',
17
- };
18
-
19
- const server = http.createServer((req, res) => {
20
- let filePath = req.url === '/' ? '/index.html' : req.url;
21
- filePath = path.join(__dirname, filePath);
22
-
23
- const extname = path.extname(filePath);
24
- const contentType = mimeTypes[extname] || 'application/octet-stream';
25
-
26
- fs.readFile(filePath, (err, content) => {
27
- if (err) {
28
- if (err.code === 'ENOENT') {
29
- res.writeHead(404);
30
- res.end('File not found');
31
- } else {
32
- res.writeHead(500);
33
- res.end('Server error: ' + err.code);
34
- }
35
- } else {
36
- res.writeHead(200, { 'Content-Type': contentType });
37
- res.end(content, 'utf-8');
38
- }
39
- });
40
- });
41
-
42
- server.listen(port, () => {
43
- console.log(`šŸš€ walkerOS Explorer Demo Server running at:`);
44
- console.log(` http://localhost:${port}`);
45
- console.log(`\nšŸ“‹ Available demos:`);
46
- console.log(` • Main Demo: http://localhost:${port}/index.html`);
47
- console.log(` • Built files available at: http://localhost:${port}/dist/`);
48
- console.log(
49
- `\nšŸŽÆ Test all Phase 1 components interactively in your browser!`,
50
- );
51
- console.log(`\n⚔ Press Ctrl+C to stop the server`);
52
- });