@walkeros/explorer 0.0.7

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,476 @@
1
+ # WalkerOS Explorer
2
+
3
+ Interactive code editor and preview components for walkerOS development,
4
+ testing, and debugging. Built with functional factory patterns, zero external
5
+ dependencies, and comprehensive TypeScript support.
6
+
7
+ ## ๐ŸŽฏ Overview
8
+
9
+ WalkerOS Explorer is a complete toolkit for building interactive development
10
+ environments. It provides a set of composable components that can be used
11
+ individually or combined to create powerful code editing and preview
12
+ experiences.
13
+
14
+ ### โœจ Key Features
15
+
16
+ - ๐Ÿงฉ **Functional Factory Pattern** - Clean, composable component architecture
17
+ - ๐Ÿš€ **Zero Dependencies** - No external libraries except for React peer
18
+ dependencies
19
+ - ๐Ÿ’Ž **Full TypeScript Support** - Complete type definitions and IntelliSense
20
+ - ๐ŸŽจ **Theme-aware** - Built-in light/dark theme support
21
+ - ๐Ÿ“ฑ **Responsive Design** - Works on all screen sizes
22
+ - โšก **High Performance** - Optimized for speed and memory efficiency
23
+ - ๐Ÿงช **Fully Tested** - 101 comprehensive tests with Jest and JSDOM
24
+
25
+ ## ๐Ÿ“ฆ Installation
26
+
27
+ ```bash
28
+ # In walkerOS monorepo (already included)
29
+ npm install
30
+
31
+ # As external dependency (future)
32
+ npm install @walkeros/explorer
33
+ ```
34
+
35
+ ## ๐Ÿ—๏ธ Architecture
36
+
37
+ The explorer is built in phases, each building upon the previous:
38
+
39
+ ### Phase 1: Foundation
40
+
41
+ - **Component Factory** - Base component system with lifecycle management
42
+ - **Event Bus** - Global communication system
43
+ - **DOM Utilities** - Safe DOM manipulation and event handling
44
+ - **Performance Utilities** - Debounce, throttle, and memoization
45
+ - **Syntax Highlighting** - Code syntax detection and highlighting
46
+
47
+ ### Phase 2: Individual Components
48
+
49
+ - **CodeEditor** - Interactive code editor with syntax highlighting
50
+ - **Preview** - HTML preview with iframe sandboxing
51
+ - **ResultDisplay** - Execution results with multiple result types
52
+
53
+ ### Phase 3: Composite Components
54
+
55
+ - **LiveCode** - Combined editor and preview for live development
56
+ - **EventFlow** - walkerOS event visualization and debugging
57
+ - **Destination** - walkerOS destination testing and configuration
58
+
59
+ ## ๐Ÿš€ Quick Start
60
+
61
+ ### Individual Components
62
+
63
+ ```typescript
64
+ import {
65
+ createCodeEditor,
66
+ createPreview,
67
+ createResultDisplay,
68
+ } from '@walkeros/explorer';
69
+
70
+ // Create a code editor
71
+ const editor = createCodeEditor('#editor', {
72
+ language: 'javascript',
73
+ value: 'console.log("Hello World");',
74
+ height: '400px',
75
+ onChange: (value) => console.log('Code changed:', value),
76
+ });
77
+
78
+ // Create a preview
79
+ const preview = createPreview('#preview', {
80
+ html: '<h1>Hello World</h1>',
81
+ height: '400px',
82
+ });
83
+
84
+ // Create a results display
85
+ const results = createResultDisplay('#results', {
86
+ maxResults: 100,
87
+ });
88
+ ```
89
+
90
+ ### Composite Components
91
+
92
+ ```typescript
93
+ import {
94
+ createLiveCode,
95
+ createEventFlow,
96
+ createDestination,
97
+ } from '@walkeros/explorer';
98
+
99
+ // Live code editor with preview
100
+ const liveCode = createLiveCode('#livecode', {
101
+ layout: 'horizontal',
102
+ showTabs: true,
103
+ initialHTML: '<h1>Hello World</h1>',
104
+ initialCSS: 'h1 { color: blue; }',
105
+ initialJS: 'console.log("Hello");',
106
+ });
107
+
108
+ // Event flow visualization
109
+ const eventFlow = createEventFlow('#events', {
110
+ maxEvents: 1000,
111
+ showMetrics: true,
112
+ onEventCapture: (event) => console.log('Event:', event),
113
+ });
114
+
115
+ // Destination testing
116
+ const destination = createDestination('#destination', {
117
+ showTemplates: true,
118
+ enableValidation: true,
119
+ });
120
+ ```
121
+
122
+ ## ๐Ÿ“š Components Reference
123
+
124
+ ### CodeEditor
125
+
126
+ Interactive code editor with syntax highlighting and multiple language support.
127
+
128
+ ```typescript
129
+ const editor = createCodeEditor(elementOrSelector, {
130
+ language: 'javascript' | 'typescript' | 'html' | 'css' | 'json' | 'markdown',
131
+ value: string,
132
+ height: string,
133
+ readOnly: boolean,
134
+ onChange: (value: string, language: string) => void
135
+ });
136
+
137
+ // API Methods
138
+ editor.getValue() // Get current code
139
+ editor.setValue(code) // Set code content
140
+ editor.getLanguage() // Get current language
141
+ editor.setLanguage(lang) // Set programming language
142
+ editor.focus() // Focus the editor
143
+ editor.selectAll() // Select all content
144
+ editor.insertText(text) // Insert text at cursor
145
+ ```
146
+
147
+ ### Preview
148
+
149
+ HTML preview component with iframe sandboxing and error handling.
150
+
151
+ ```typescript
152
+ const preview = createPreview(elementOrSelector, {
153
+ html: string,
154
+ height: string,
155
+ sandbox: boolean,
156
+ showErrors: boolean,
157
+ onLoad: (iframe) => void,
158
+ onError: (error) => void
159
+ });
160
+
161
+ // API Methods
162
+ preview.setHTML(html) // Set HTML content
163
+ preview.getHTML() // Get current HTML
164
+ preview.refresh() // Refresh preview
165
+ preview.executeScript(script) // Execute script in preview
166
+ preview.injectCSS(css) // Inject CSS into preview
167
+ ```
168
+
169
+ ### ResultDisplay
170
+
171
+ Display execution results with multiple result types and formatting.
172
+
173
+ ```typescript
174
+ const results = createResultDisplay(elementOrSelector, {
175
+ maxResults: number,
176
+ height: string,
177
+ autoScroll: boolean
178
+ });
179
+
180
+ // API Methods
181
+ results.addValue(value, label?) // Add value result
182
+ results.addError(error, label?) // Add error result
183
+ results.addLog(message, label?) // Add log result
184
+ results.addWarning(message, label?) // Add warning result
185
+ results.addInfo(message, label?) // Add info result
186
+ results.clear() // Clear all results
187
+ results.getResults() // Get all results
188
+ ```
189
+
190
+ ### LiveCode
191
+
192
+ Combined code editor and preview for live HTML/CSS/JS development.
193
+
194
+ ```typescript
195
+ const liveCode = createLiveCode(elementOrSelector, {
196
+ layout: 'horizontal' | 'vertical' | 'tabs',
197
+ showTabs: boolean,
198
+ showResults: boolean,
199
+ autoRun: boolean,
200
+ initialHTML: string,
201
+ initialCSS: string,
202
+ initialJS: string,
203
+ enableConsoleCapture: boolean,
204
+ onRun: (code) => void
205
+ });
206
+
207
+ // API Methods
208
+ liveCode.getHTML() // Get HTML content
209
+ liveCode.setHTML(html) // Set HTML content
210
+ liveCode.getCSS() // Get CSS content
211
+ liveCode.setCSS(css) // Set CSS content
212
+ liveCode.getJS() // Get JavaScript content
213
+ liveCode.setJS(js) // Set JavaScript content
214
+ liveCode.run() // Execute code manually
215
+ liveCode.clear() // Clear all editors
216
+ liveCode.setLayout(layout) // Change layout
217
+ ```
218
+
219
+ ### EventFlow
220
+
221
+ WalkerOS event visualization and debugging component.
222
+
223
+ ```typescript
224
+ const eventFlow = createEventFlow(elementOrSelector, {
225
+ maxEvents: number,
226
+ showTimeline: boolean,
227
+ showFilters: boolean,
228
+ showMetrics: boolean,
229
+ groupByEntity: boolean,
230
+ onEventCapture: (event) => void,
231
+ onEventSelect: (event) => void
232
+ });
233
+
234
+ // API Methods
235
+ eventFlow.addEvent(event) // Add new event
236
+ eventFlow.getEvents() // Get all events
237
+ eventFlow.clearEvents() // Clear all events
238
+ eventFlow.filterEvents(filter) // Filter events
239
+ eventFlow.exportEvents() // Export filtered events
240
+ eventFlow.getMetrics() // Get performance metrics
241
+ ```
242
+
243
+ ### Destination
244
+
245
+ WalkerOS destination testing and configuration component.
246
+
247
+ ```typescript
248
+ const destination = createDestination(elementOrSelector, {
249
+ initialConfig: DestinationConfig,
250
+ showTemplates: boolean,
251
+ showTesting: boolean,
252
+ enableValidation: boolean,
253
+ onConfigChange: (config) => void,
254
+ onTest: (config, event) => void
255
+ });
256
+
257
+ // API Methods
258
+ destination.getConfig() // Get current configuration
259
+ destination.setConfig(config) // Set configuration
260
+ destination.testDestination(event) // Test with event
261
+ destination.validateConfig() // Validate configuration
262
+ destination.exportConfig() // Export config as JSON
263
+ destination.importConfig(json) // Import config from JSON
264
+ destination.loadTemplate(name) // Load predefined template
265
+ destination.getAvailableTemplates() // Get available templates
266
+ ```
267
+
268
+ ## ๐Ÿงช Testing
269
+
270
+ The project includes comprehensive testing with Jest and JSDOM:
271
+
272
+ ```bash
273
+ # Run all tests
274
+ npm run test
275
+
276
+ # Run tests in watch mode
277
+ npm run test:watch
278
+
279
+ # Run specific test file
280
+ npm run test foundation.test.ts
281
+
282
+ # Run tests with coverage
283
+ npm run test:coverage
284
+ ```
285
+
286
+ ### Test Coverage
287
+
288
+ - **101 total tests** across 4 test suites
289
+ - **Foundation tests (27)** - Core utilities and base components
290
+ - **Phase 2 tests (47)** - Individual component functionality
291
+ - **Phase 3 tests (27)** - Composite component integration
292
+ - **Quick tests** - Fast smoke tests for CI/CD
293
+
294
+ ## ๐ŸŽจ Demos
295
+
296
+ Interactive demos are included to showcase all components:
297
+
298
+ ### Phase 2 Demo
299
+
300
+ ```bash
301
+ # Serves demo-phase2.html
302
+ npm run demo:phase2
303
+ ```
304
+
305
+ Features individual components with interactive controls.
306
+
307
+ ### Phase 3 Demo
308
+
309
+ ```bash
310
+ # Serves demo-phase3.html
311
+ npm run demo:phase3
312
+ ```
313
+
314
+ Features composite components with real-world examples.
315
+
316
+ ## ๐Ÿ”ง Development
317
+
318
+ ### Project Structure
319
+
320
+ ```
321
+ src/
322
+ โ”œโ”€โ”€ core/ # Foundation components
323
+ โ”‚ โ”œโ”€โ”€ Component.ts # Base component factory
324
+ โ”‚ โ””โ”€โ”€ EventBus.ts # Global event system
325
+ โ”œโ”€โ”€ components/ # All components
326
+ โ”‚ โ”œโ”€โ”€ CodeEditor.ts # Code editor component
327
+ โ”‚ โ”œโ”€โ”€ Preview.ts # HTML preview component
328
+ โ”‚ โ”œโ”€โ”€ ResultDisplay.ts # Results display component
329
+ โ”‚ โ”œโ”€โ”€ LiveCode.ts # Live coding component
330
+ โ”‚ โ”œโ”€โ”€ EventFlow.ts # Event visualization component
331
+ โ”‚ โ””โ”€โ”€ Destination.ts # Destination testing component
332
+ โ”œโ”€โ”€ utils/ # Utility functions
333
+ โ”‚ โ”œโ”€โ”€ dom.ts # DOM manipulation utilities
334
+ โ”‚ โ”œโ”€โ”€ debounce.ts # Performance utilities
335
+ โ”‚ โ””โ”€โ”€ syntax.ts # Syntax highlighting
336
+ โ””โ”€โ”€ __tests__/ # Test suites
337
+ โ”œโ”€โ”€ foundation.test.ts
338
+ โ”œโ”€โ”€ phase2-components.test.ts
339
+ โ””โ”€โ”€ phase3-composites.test.ts
340
+ ```
341
+
342
+ ### Build System
343
+
344
+ ```bash
345
+ # Development build with watch
346
+ npm run dev
347
+
348
+ # Production build
349
+ npm run build
350
+
351
+ # Type checking
352
+ npm run type-check
353
+
354
+ # Linting
355
+ npm run lint
356
+ ```
357
+
358
+ The project uses:
359
+
360
+ - **tsup** for building with multiple output formats (ESM, CJS, IIFE)
361
+ - **TypeScript** for type safety and IntelliSense
362
+ - **Jest** with JSDOM for testing
363
+ - **ESLint** for code quality
364
+
365
+ ## ๐ŸŽฏ Use Cases
366
+
367
+ ### Development Tools
368
+
369
+ Create interactive code playgrounds and documentation with live examples.
370
+
371
+ ```typescript
372
+ const playground = createLiveCode('#playground', {
373
+ layout: 'horizontal',
374
+ initialHTML: '<div>Interactive example</div>',
375
+ onRun: (code) => console.log('Code executed:', code),
376
+ });
377
+ ```
378
+
379
+ ### Event Debugging
380
+
381
+ Monitor and debug walkerOS events in real-time.
382
+
383
+ ```typescript
384
+ const debugger = createEventFlow('#debugger', {
385
+ showMetrics: true,
386
+ onEventCapture: (event) => {
387
+ console.log('Event captured:', event);
388
+ // Send to analytics, log to server, etc.
389
+ }
390
+ });
391
+ ```
392
+
393
+ ### Destination Testing
394
+
395
+ Test and configure walkerOS destinations with built-in templates.
396
+
397
+ ```typescript
398
+ const tester = createDestination('#tester', {
399
+ showTemplates: true,
400
+ onTest: (config, event) => {
401
+ console.log('Testing destination:', config.name);
402
+ },
403
+ });
404
+ ```
405
+
406
+ ## ๐Ÿ“– Documentation
407
+
408
+ - **[API Reference](./API.md)** - Complete API documentation
409
+ - **[Testing Guide](./TESTING.md)** - Testing strategy and best practices
410
+ - **[Development Guidelines](./DEVELOPMENT_GUIDELINES.md)** - Development best
411
+ practices
412
+
413
+ ## ๐ŸŒŸ Key Benefits
414
+
415
+ ### For Developers
416
+
417
+ - **Zero Learning Curve** - Familiar functional patterns
418
+ - **Full TypeScript Support** - Complete IntelliSense and type safety
419
+ - **Composable Architecture** - Use individual components or combine them
420
+ - **Performance Optimized** - Debounced updates and efficient rendering
421
+
422
+ ### For Teams
423
+
424
+ - **Consistent Architecture** - Functional factory pattern across all components
425
+ - **Comprehensive Testing** - High test coverage with automated CI/CD
426
+ - **Documentation** - Complete API docs and usage examples
427
+ - **Maintenance** - Clean, well-organized codebase
428
+
429
+ ### For Projects
430
+
431
+ - **Framework Agnostic** - Works with any framework or vanilla JS
432
+ - **Theme Support** - Built-in light/dark mode compatibility
433
+ - **Responsive Design** - Works on desktop, tablet, and mobile
434
+ - **Accessibility** - ARIA support and keyboard navigation
435
+
436
+ ## ๐Ÿš€ Roadmap
437
+
438
+ ### Immediate (Phase 5)
439
+
440
+ - [x] Complete testing suite
441
+ - [x] Comprehensive documentation
442
+ - [x] Interactive demos
443
+ - [ ] Performance optimizations
444
+ - [ ] Accessibility improvements
445
+
446
+ ### Short Term
447
+
448
+ - [ ] npm package publication
449
+ - [ ] CDN builds for easy integration
450
+ - [ ] React wrapper components
451
+ - [ ] Storybook integration
452
+
453
+ ### Long Term
454
+
455
+ - [ ] Browser extension for debugging
456
+ - [ ] VS Code extension integration
457
+ - [ ] Advanced theming system
458
+ - [ ] Plugin architecture for extensibility
459
+
460
+ ## ๐Ÿค Contributing
461
+
462
+ 1. Follow the functional factory pattern established in the codebase
463
+ 2. Add comprehensive tests for new functionality
464
+ 3. Update documentation and type definitions
465
+ 4. Ensure all tests pass: `npm run test`
466
+ 5. Follow TypeScript best practices
467
+
468
+ ## ๐Ÿ“„ License
469
+
470
+ Part of the walkerOS project. See the main repository for license information.
471
+
472
+ ## ๐Ÿ”— Links
473
+
474
+ - **walkerOS Documentation**: https://docs.walkerOS.com
475
+ - **GitHub Repository**: https://github.com/elbwalker/walkerOS
476
+ - **Issues**: https://github.com/elbwalker/walkerOS/issues
@@ -0,0 +1,143 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Destination Component Demo</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ margin: 0;
11
+ padding: 20px;
12
+ background: #f5f5f5;
13
+ }
14
+ .container {
15
+ max-width: 1600px;
16
+ margin: 0 auto;
17
+ }
18
+ h1 {
19
+ color: #333;
20
+ margin-bottom: 20px;
21
+ text-align: center;
22
+ }
23
+ .theme-toggle {
24
+ position: absolute;
25
+ top: 20px;
26
+ right: 20px;
27
+ background: none;
28
+ border: 2px solid #ddd;
29
+ border-radius: 50%;
30
+ width: 40px;
31
+ height: 40px;
32
+ cursor: pointer;
33
+ font-size: 18px;
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+ transition: all 0.2s ease;
38
+ }
39
+ .theme-toggle:hover {
40
+ border-color: #007bff;
41
+ background: rgba(0, 123, 255, 0.1);
42
+ }
43
+ .destination-demo {
44
+ height: 600px;
45
+ min-height: 500px;
46
+ }
47
+
48
+ /* Ensure the explorer container uses full height */
49
+ #destination-container {
50
+ height: 100%;
51
+ min-height: 500px;
52
+ }
53
+ </style>
54
+ </head>
55
+ <body>
56
+ <button class="theme-toggle" onclick="toggleTheme()" title="Toggle theme">
57
+ <span id="theme-icon">๐ŸŒ™</span>
58
+ </button>
59
+
60
+ <div class="container">
61
+ <h1>Destination Component Demo</h1>
62
+ <p style="text-align: center; margin-bottom: 30px">
63
+ Edit the Event and Mapping to see the processed result from the
64
+ destination.
65
+ </p>
66
+
67
+ <div class="destination-demo">
68
+ <div id="destination-container"></div>
69
+ </div>
70
+ </div>
71
+
72
+ <script src="../explorer.js"></script>
73
+ <script>
74
+ // Theme toggle functionality
75
+ window.toggleTheme = () => {
76
+ const html = document.documentElement;
77
+ const currentTheme = html.getAttribute('data-theme');
78
+ const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
79
+
80
+ html.setAttribute('data-theme', newTheme);
81
+
82
+ // Update icon
83
+ const icon = document.getElementById('theme-icon');
84
+ icon.textContent = newTheme === 'dark' ? 'โ˜€๏ธ' : '๐ŸŒ™';
85
+
86
+ // Save preference
87
+ localStorage.setItem('theme', newTheme);
88
+ };
89
+
90
+ document.addEventListener('DOMContentLoaded', () => {
91
+ // Create the destination component with PiwikPro order complete example
92
+ const destinationComponent = WalkerExplorer.createDestination(
93
+ '#destination-container',
94
+ {
95
+ height: '100%',
96
+ showHeader: true,
97
+ initialEvent: `{
98
+ "event": "order complete",
99
+ "data": {
100
+ "id": "0rd3r1d",
101
+ "currency": "EUR",
102
+ "shipping": 5.22,
103
+ "taxes": 73.76,
104
+ "total": 555
105
+ },
106
+ "context": {
107
+ "shopping": ["complete", 0]
108
+ },
109
+ "globals": {
110
+ "pagegroup": "shop"
111
+ },
112
+ "nested": [
113
+ {
114
+ "type": "product",
115
+ "data": {
116
+ "id": "ers",
117
+ "name": "Everyday Ruck Snack",
118
+ "color": "black",
119
+ "size": "l",
120
+ "price": 420
121
+ }
122
+ }
123
+ ]
124
+ }`,
125
+ initialMapping: `{
126
+ "order": {
127
+ "complete": {
128
+ "data": {
129
+ "event_name": "purchase",
130
+ "product_id": "data.id",
131
+ "product_name": "data.name",
132
+ "product_price": "data.price",
133
+ "product_category": "data.category"
134
+ }
135
+ }
136
+ }
137
+ }`,
138
+ },
139
+ );
140
+ });
141
+ </script>
142
+ </body>
143
+ </html>