@walkeros/explorer 0.0.7 → 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/LICENSE +42 -0
- package/README.md +646 -374
- package/dist/chunk-P5UDSGZL.mjs +18485 -0
- package/dist/chunk-P5UDSGZL.mjs.map +1 -0
- package/dist/index.d.cts +1248 -0
- package/dist/index.d.ts +1185 -180
- package/dist/index.js +31721 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +12983 -2300
- package/dist/index.mjs.map +1 -1
- package/dist/monaco-types-T3WXA7KH.mjs +34 -0
- package/dist/monaco-types-T3WXA7KH.mjs.map +1 -0
- package/dist/styles.css +4923 -0
- package/package.json +96 -55
- package/dist/examples/destination.html +0 -143
- package/dist/examples/index.html +0 -110
- package/dist/examples/livecode-js.html +0 -396
- package/dist/explorer.js +0 -2996
- package/dist/explorer.js.map +0 -1
- package/dist/index.cjs +0 -2528
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.mts +0 -243
- package/serve.js +0 -52
package/dist/index.cjs
DELETED
|
@@ -1,2528 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __esm = (fn, res) => function __init() {
|
|
24
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
25
|
-
};
|
|
26
|
-
var __export = (target, all) => {
|
|
27
|
-
for (var name2 in all)
|
|
28
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
29
|
-
};
|
|
30
|
-
var __copyProps = (to, from, except, desc) => {
|
|
31
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
32
|
-
for (let key of __getOwnPropNames(from))
|
|
33
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
34
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
35
|
-
}
|
|
36
|
-
return to;
|
|
37
|
-
};
|
|
38
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
-
var __async = (__this, __arguments, generator) => {
|
|
40
|
-
return new Promise((resolve, reject) => {
|
|
41
|
-
var fulfilled = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.next(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var rejected = (value) => {
|
|
49
|
-
try {
|
|
50
|
-
step(generator.throw(value));
|
|
51
|
-
} catch (e) {
|
|
52
|
-
reject(e);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
56
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// src/core/css-theme-system.ts
|
|
61
|
-
function setElementTheme(element, theme) {
|
|
62
|
-
const htmlTheme = document.documentElement.getAttribute("data-theme");
|
|
63
|
-
if (htmlTheme && (htmlTheme === "light" || htmlTheme === "dark")) {
|
|
64
|
-
if (element instanceof HTMLElement) {
|
|
65
|
-
element.classList.add("explorer-component");
|
|
66
|
-
}
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (element instanceof HTMLElement) {
|
|
70
|
-
element.setAttribute("data-theme", theme);
|
|
71
|
-
} else if (element instanceof ShadowRoot) {
|
|
72
|
-
if (element.host instanceof HTMLElement) {
|
|
73
|
-
element.host.setAttribute("data-theme", theme);
|
|
74
|
-
}
|
|
75
|
-
} else if (element instanceof DocumentFragment) {
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function getElementTheme(element) {
|
|
79
|
-
const htmlTheme = document.documentElement.getAttribute("data-theme");
|
|
80
|
-
if (htmlTheme === "light" || htmlTheme === "dark") {
|
|
81
|
-
return htmlTheme;
|
|
82
|
-
}
|
|
83
|
-
const elementTheme = element.getAttribute("data-theme");
|
|
84
|
-
if (elementTheme) {
|
|
85
|
-
return elementTheme;
|
|
86
|
-
}
|
|
87
|
-
return "light";
|
|
88
|
-
}
|
|
89
|
-
function detectTheme() {
|
|
90
|
-
const htmlTheme = document.documentElement.getAttribute("data-theme");
|
|
91
|
-
if (htmlTheme === "light" || htmlTheme === "dark") {
|
|
92
|
-
return htmlTheme;
|
|
93
|
-
}
|
|
94
|
-
if (document.documentElement.classList.contains("dark")) {
|
|
95
|
-
return "dark";
|
|
96
|
-
}
|
|
97
|
-
if (typeof window !== "undefined" && window.matchMedia) {
|
|
98
|
-
const prefersDark = window.matchMedia(
|
|
99
|
-
"(prefers-color-scheme: dark)"
|
|
100
|
-
).matches;
|
|
101
|
-
if (prefersDark) {
|
|
102
|
-
return "dark";
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return "light";
|
|
106
|
-
}
|
|
107
|
-
function toggleElementTheme(element) {
|
|
108
|
-
const currentTheme = getElementTheme(element);
|
|
109
|
-
const newTheme = currentTheme === "light" ? "dark" : "light";
|
|
110
|
-
setElementTheme(element, newTheme);
|
|
111
|
-
return newTheme;
|
|
112
|
-
}
|
|
113
|
-
var CSS_THEME_VARIABLES, CSS_SYNTAX_HIGHLIGHTING;
|
|
114
|
-
var init_css_theme_system = __esm({
|
|
115
|
-
"src/core/css-theme-system.ts"() {
|
|
116
|
-
"use strict";
|
|
117
|
-
CSS_THEME_VARIABLES = `
|
|
118
|
-
:root,
|
|
119
|
-
[data-theme="light"],
|
|
120
|
-
html[data-theme="light"] .explorer-component,
|
|
121
|
-
html[data-theme="light"] [class*="explorer-"] {
|
|
122
|
-
/* Base colors - transparent by default for website integration */
|
|
123
|
-
--explorer-bg-primary: transparent;
|
|
124
|
-
--explorer-bg-primary-opaque: #ffffff;
|
|
125
|
-
--explorer-bg-secondary: rgba(248, 250, 252, 0.8);
|
|
126
|
-
--explorer-bg-tertiary: rgba(241, 245, 249, 0.9);
|
|
127
|
-
--explorer-bg-input: #fafafa;
|
|
128
|
-
|
|
129
|
-
/* Text colors */
|
|
130
|
-
--explorer-text-primary: #1f2937;
|
|
131
|
-
--explorer-text-secondary: #6b7280;
|
|
132
|
-
--explorer-text-muted: #9ca3af;
|
|
133
|
-
--explorer-text-inverse: #ffffff;
|
|
134
|
-
|
|
135
|
-
/* Border colors */
|
|
136
|
-
--explorer-border-primary: #d1d5db;
|
|
137
|
-
--explorer-border-secondary: #e5e7eb;
|
|
138
|
-
--explorer-border-focus: #3b82f6;
|
|
139
|
-
|
|
140
|
-
/* Action colors */
|
|
141
|
-
--explorer-primary: #3b82f6;
|
|
142
|
-
--explorer-primary-hover: #2563eb;
|
|
143
|
-
--explorer-primary-active: #1d4ed8;
|
|
144
|
-
|
|
145
|
-
--explorer-success: #10b981;
|
|
146
|
-
--explorer-success-hover: #059669;
|
|
147
|
-
--explorer-success-active: #047857;
|
|
148
|
-
|
|
149
|
-
--explorer-warning: #f59e0b;
|
|
150
|
-
--explorer-warning-hover: #d97706;
|
|
151
|
-
--explorer-warning-active: #b45309;
|
|
152
|
-
|
|
153
|
-
--explorer-danger: #ef4444;
|
|
154
|
-
--explorer-danger-hover: #dc2626;
|
|
155
|
-
--explorer-danger-active: #b91c1c;
|
|
156
|
-
|
|
157
|
-
/* Surface colors */
|
|
158
|
-
--explorer-surface-hover: #f1f5f9;
|
|
159
|
-
--explorer-surface-active: #e2e8f0;
|
|
160
|
-
--explorer-surface-selected: #dbeafe;
|
|
161
|
-
|
|
162
|
-
/* Shadow colors */
|
|
163
|
-
--explorer-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
164
|
-
--explorer-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
165
|
-
--explorer-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
166
|
-
|
|
167
|
-
/* Scrollbar colors */
|
|
168
|
-
--explorer-scrollbar-track: #f1f5f9;
|
|
169
|
-
--explorer-scrollbar-thumb: #cbd5e1;
|
|
170
|
-
--explorer-scrollbar-thumb-hover: #94a3b8;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
[data-theme="dark"],
|
|
174
|
-
html[data-theme="dark"] .explorer-component,
|
|
175
|
-
html[data-theme="dark"] [class*="explorer-"] {
|
|
176
|
-
/* Base colors - transparent by default for website integration */
|
|
177
|
-
--explorer-bg-primary: transparent;
|
|
178
|
-
--explorer-bg-primary-opaque: #1f2937;
|
|
179
|
-
--explorer-bg-secondary: rgba(55, 65, 81, 0.8);
|
|
180
|
-
--explorer-bg-tertiary: rgba(75, 85, 99, 0.9);
|
|
181
|
-
--explorer-bg-input: #111827;
|
|
182
|
-
|
|
183
|
-
/* Text colors */
|
|
184
|
-
--explorer-text-primary: #f3f4f6;
|
|
185
|
-
--explorer-text-secondary: #d1d5db;
|
|
186
|
-
--explorer-text-muted: #9ca3af;
|
|
187
|
-
--explorer-text-inverse: #1f2937;
|
|
188
|
-
|
|
189
|
-
/* Border colors */
|
|
190
|
-
--explorer-border-primary: #374151;
|
|
191
|
-
--explorer-border-secondary: #4b5563;
|
|
192
|
-
--explorer-border-focus: #3b82f6;
|
|
193
|
-
|
|
194
|
-
/* Action colors remain the same for consistency */
|
|
195
|
-
--explorer-primary: #3b82f6;
|
|
196
|
-
--explorer-primary-hover: #2563eb;
|
|
197
|
-
--explorer-primary-active: #1d4ed8;
|
|
198
|
-
|
|
199
|
-
--explorer-success: #10b981;
|
|
200
|
-
--explorer-success-hover: #059669;
|
|
201
|
-
--explorer-success-active: #047857;
|
|
202
|
-
|
|
203
|
-
--explorer-warning: #f59e0b;
|
|
204
|
-
--explorer-warning-hover: #d97706;
|
|
205
|
-
--explorer-warning-active: #b45309;
|
|
206
|
-
|
|
207
|
-
--explorer-danger: #ef4444;
|
|
208
|
-
--explorer-danger-hover: #dc2626;
|
|
209
|
-
--explorer-danger-active: #b91c1c;
|
|
210
|
-
|
|
211
|
-
/* Surface colors */
|
|
212
|
-
--explorer-surface-hover: #374151;
|
|
213
|
-
--explorer-surface-active: #4b5563;
|
|
214
|
-
--explorer-surface-selected: #1e3a8a;
|
|
215
|
-
|
|
216
|
-
/* Shadow colors */
|
|
217
|
-
--explorer-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
|
218
|
-
--explorer-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
219
|
-
--explorer-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
|
|
220
|
-
|
|
221
|
-
/* Scrollbar colors */
|
|
222
|
-
--explorer-scrollbar-track: #374151;
|
|
223
|
-
--explorer-scrollbar-thumb: #6b7280;
|
|
224
|
-
--explorer-scrollbar-thumb-hover: #9ca3af;
|
|
225
|
-
}
|
|
226
|
-
`;
|
|
227
|
-
CSS_SYNTAX_HIGHLIGHTING = `
|
|
228
|
-
/* Light mode - Palenight-inspired colors adapted for light backgrounds */
|
|
229
|
-
.explorer-component .syntax-keyword,
|
|
230
|
-
.explorer-shadow-container .syntax-keyword,
|
|
231
|
-
:host .syntax-keyword {
|
|
232
|
-
color: #ab47bc !important;
|
|
233
|
-
font-weight: 600 !important;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.explorer-component .syntax-string,
|
|
237
|
-
.explorer-shadow-container .syntax-string,
|
|
238
|
-
:host .syntax-string {
|
|
239
|
-
color: #689f38 !important;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.explorer-component .syntax-number,
|
|
243
|
-
.explorer-shadow-container .syntax-number,
|
|
244
|
-
:host .syntax-number {
|
|
245
|
-
color: #f57c00 !important;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.explorer-component .syntax-comment,
|
|
249
|
-
.explorer-shadow-container .syntax-comment,
|
|
250
|
-
:host .syntax-comment {
|
|
251
|
-
color: #757575 !important;
|
|
252
|
-
font-style: italic !important;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.explorer-component .syntax-function,
|
|
256
|
-
.explorer-shadow-container .syntax-function,
|
|
257
|
-
:host .syntax-function {
|
|
258
|
-
color: #3f51b5 !important;
|
|
259
|
-
font-weight: 500 !important;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.explorer-component .syntax-tag,
|
|
263
|
-
.explorer-shadow-container .syntax-tag,
|
|
264
|
-
:host .syntax-tag {
|
|
265
|
-
color: #e91e63 !important;
|
|
266
|
-
font-weight: 600 !important;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
.explorer-component .syntax-attribute,
|
|
270
|
-
.explorer-shadow-container .syntax-attribute,
|
|
271
|
-
:host .syntax-attribute {
|
|
272
|
-
color: #6f42c1 !important;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.explorer-component .syntax-value,
|
|
276
|
-
.explorer-shadow-container .syntax-value,
|
|
277
|
-
:host .syntax-value {
|
|
278
|
-
color: #032f62 !important;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
.explorer-component .syntax-operator,
|
|
282
|
-
.explorer-shadow-container .syntax-operator,
|
|
283
|
-
:host .syntax-operator {
|
|
284
|
-
color: #d73a49 !important;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.explorer-component .syntax-type,
|
|
288
|
-
.explorer-shadow-container .syntax-type,
|
|
289
|
-
:host .syntax-type {
|
|
290
|
-
color: #005cc5 !important;
|
|
291
|
-
font-weight: 500 !important;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.explorer-component .syntax-property,
|
|
295
|
-
.explorer-shadow-container .syntax-property,
|
|
296
|
-
:host .syntax-property {
|
|
297
|
-
color: #6f42c1 !important;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/* JSON-specific styling for better readability */
|
|
301
|
-
.explorer-component[data-language="json"] .syntax-string,
|
|
302
|
-
.explorer-shadow-container[data-language="json"] .syntax-string,
|
|
303
|
-
:host([data-language="json"]) .syntax-string {
|
|
304
|
-
color: #22863a !important; /* GitHub green for JSON strings */
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.explorer-component[data-language="json"] .syntax-number,
|
|
308
|
-
.explorer-shadow-container[data-language="json"] .syntax-number,
|
|
309
|
-
:host([data-language="json"]) .syntax-number {
|
|
310
|
-
color: #005cc5 !important; /* GitHub blue for JSON numbers */
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.explorer-component[data-language="json"] .syntax-property,
|
|
314
|
-
.explorer-shadow-container[data-language="json"] .syntax-property,
|
|
315
|
-
:host([data-language="json"]) .syntax-property {
|
|
316
|
-
color: #032f62 !important; /* GitHub dark blue for JSON keys */
|
|
317
|
-
font-weight: 500 !important;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
.explorer-component[data-language="json"] .syntax-keyword,
|
|
321
|
-
.explorer-shadow-container[data-language="json"] .syntax-keyword,
|
|
322
|
-
:host([data-language="json"]) .syntax-keyword {
|
|
323
|
-
color: #d73a49 !important; /* GitHub red for true/false/null */
|
|
324
|
-
font-weight: 600 !important;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/* JSON-specific dark mode styling */
|
|
328
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-string,
|
|
329
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-string,
|
|
330
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-string {
|
|
331
|
-
color: #98d982 !important; /* Softer green for dark mode JSON strings */
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-number,
|
|
335
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-number,
|
|
336
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-number {
|
|
337
|
-
color: #79b8ff !important; /* Softer blue for dark mode JSON numbers */
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-property,
|
|
341
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-property,
|
|
342
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-property {
|
|
343
|
-
color: #b392f0 !important; /* Light purple for dark mode JSON keys */
|
|
344
|
-
font-weight: 500 !important;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-keyword,
|
|
348
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-keyword,
|
|
349
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-keyword {
|
|
350
|
-
color: #f97583 !important; /* Soft red for dark mode true/false/null */
|
|
351
|
-
font-weight: 600 !important;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/* Special highlighting for elb attributes */
|
|
355
|
-
.explorer-component .syntax-elb-attribute,
|
|
356
|
-
.explorer-shadow-container .syntax-elb-attribute,
|
|
357
|
-
:host .syntax-elb-attribute {
|
|
358
|
-
color: #28a745 !important;
|
|
359
|
-
font-weight: 700 !important;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
.explorer-component .syntax-elb-value,
|
|
363
|
-
.explorer-shadow-container .syntax-elb-value,
|
|
364
|
-
:host .syntax-elb-value {
|
|
365
|
-
color: #28a745 !important;
|
|
366
|
-
font-weight: 500 !important;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/* Dark mode - Palenight theme with higher specificity */
|
|
370
|
-
[data-theme='dark'] .explorer-component .syntax-keyword,
|
|
371
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-keyword,
|
|
372
|
-
:host([data-theme='dark']) .syntax-keyword {
|
|
373
|
-
color: #c792ea !important;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
[data-theme='dark'] .explorer-component .syntax-string,
|
|
377
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-string,
|
|
378
|
-
:host([data-theme='dark']) .syntax-string {
|
|
379
|
-
color: #c3e88d !important;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
[data-theme='dark'] .explorer-component .syntax-number,
|
|
383
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-number,
|
|
384
|
-
:host([data-theme='dark']) .syntax-number {
|
|
385
|
-
color: #f78c6c !important;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
[data-theme='dark'] .explorer-component .syntax-comment,
|
|
389
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-comment,
|
|
390
|
-
:host([data-theme='dark']) .syntax-comment {
|
|
391
|
-
color: #676e95 !important;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
[data-theme='dark'] .explorer-component .syntax-function,
|
|
395
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-function,
|
|
396
|
-
:host([data-theme='dark']) .syntax-function {
|
|
397
|
-
color: #82aaff !important;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
[data-theme='dark'] .explorer-component .syntax-tag,
|
|
401
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-tag,
|
|
402
|
-
:host([data-theme='dark']) .syntax-tag {
|
|
403
|
-
color: #f07178 !important;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
[data-theme='dark'] .explorer-component .syntax-attribute,
|
|
407
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-attribute,
|
|
408
|
-
:host([data-theme='dark']) .syntax-attribute {
|
|
409
|
-
color: #ffcb6b !important;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
[data-theme='dark'] .explorer-component .syntax-value,
|
|
413
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-value,
|
|
414
|
-
:host([data-theme='dark']) .syntax-value {
|
|
415
|
-
color: #c3e88d !important;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
[data-theme='dark'] .explorer-component .syntax-operator,
|
|
419
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-operator,
|
|
420
|
-
:host([data-theme='dark']) .syntax-operator {
|
|
421
|
-
color: #89ddff !important;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
[data-theme='dark'] .explorer-component .syntax-type,
|
|
425
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-type,
|
|
426
|
-
:host([data-theme='dark']) .syntax-type {
|
|
427
|
-
color: #ffcb6b !important;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
[data-theme='dark'] .explorer-component .syntax-property,
|
|
431
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-property,
|
|
432
|
-
:host([data-theme='dark']) .syntax-property {
|
|
433
|
-
color: #82aaff !important;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
[data-theme='dark'] .explorer-component .syntax-elb-attribute,
|
|
437
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-elb-attribute,
|
|
438
|
-
:host([data-theme='dark']) .syntax-elb-attribute {
|
|
439
|
-
color: #c3e88d !important;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
[data-theme='dark'] .explorer-component .syntax-elb-value,
|
|
443
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-elb-value,
|
|
444
|
-
:host([data-theme='dark']) .syntax-elb-value {
|
|
445
|
-
color: #c3e88d !important;
|
|
446
|
-
}
|
|
447
|
-
`;
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// src/index.ts
|
|
452
|
-
var index_exports = {};
|
|
453
|
-
__export(index_exports, {
|
|
454
|
-
createCodeEditor: () => createCodeEditor,
|
|
455
|
-
createDestination: () => createDestination,
|
|
456
|
-
createLiveCodeJS: () => createLiveCodeJS,
|
|
457
|
-
createResultDisplay: () => createResultDisplay,
|
|
458
|
-
createSafeContext: () => createSafeContext,
|
|
459
|
-
evaluateJavaScript: () => evaluateJavaScript,
|
|
460
|
-
formatEvaluationResult: () => formatEvaluationResult,
|
|
461
|
-
name: () => name,
|
|
462
|
-
version: () => version
|
|
463
|
-
});
|
|
464
|
-
module.exports = __toCommonJS(index_exports);
|
|
465
|
-
|
|
466
|
-
// src/core/Component.ts
|
|
467
|
-
init_css_theme_system();
|
|
468
|
-
var componentRegistry = /* @__PURE__ */ new Map();
|
|
469
|
-
function generateUniqueId(prefix = "explorer") {
|
|
470
|
-
const timestamp = Date.now().toString(36);
|
|
471
|
-
const random = Math.random().toString(36).substring(2, 8);
|
|
472
|
-
return `${prefix}-${timestamp}-${random}`;
|
|
473
|
-
}
|
|
474
|
-
function getElement(elementOrSelector) {
|
|
475
|
-
if (typeof elementOrSelector === "string") {
|
|
476
|
-
const element = document.querySelector(elementOrSelector);
|
|
477
|
-
if (!element) {
|
|
478
|
-
throw new Error(`Element not found: ${elementOrSelector}`);
|
|
479
|
-
}
|
|
480
|
-
return element;
|
|
481
|
-
}
|
|
482
|
-
return elementOrSelector;
|
|
483
|
-
}
|
|
484
|
-
function createComponent(elementOrSelector, options = {}) {
|
|
485
|
-
const element = getElement(elementOrSelector);
|
|
486
|
-
const existingId = element.getAttribute("data-explorer-component");
|
|
487
|
-
if (existingId && componentRegistry.has(existingId)) {
|
|
488
|
-
console.warn(
|
|
489
|
-
`Component already exists on element, destroying existing instance: ${existingId}`
|
|
490
|
-
);
|
|
491
|
-
const existingComponent = componentRegistry.get(existingId);
|
|
492
|
-
existingComponent == null ? void 0 : existingComponent.destroy();
|
|
493
|
-
}
|
|
494
|
-
const id = generateUniqueId();
|
|
495
|
-
let mounted = false;
|
|
496
|
-
let destroyed = false;
|
|
497
|
-
const eventListeners = /* @__PURE__ */ new Map();
|
|
498
|
-
const cleanupFunctions = [];
|
|
499
|
-
let shadowRoot = null;
|
|
500
|
-
if (!element.id) {
|
|
501
|
-
element.id = id;
|
|
502
|
-
}
|
|
503
|
-
element.setAttribute("data-explorer-component", id);
|
|
504
|
-
if (options.useShadowDOM && element.attachShadow) {
|
|
505
|
-
try {
|
|
506
|
-
shadowRoot = element.attachShadow({ mode: "open" });
|
|
507
|
-
const shadowContainer = document.createElement("div");
|
|
508
|
-
shadowContainer.className = "explorer-shadow-container";
|
|
509
|
-
shadowContainer.setAttribute("data-explorer-component", id);
|
|
510
|
-
shadowRoot.appendChild(shadowContainer);
|
|
511
|
-
} catch (error) {
|
|
512
|
-
console.warn(
|
|
513
|
-
"Failed to create shadow DOM, falling back to light DOM:",
|
|
514
|
-
error
|
|
515
|
-
);
|
|
516
|
-
shadowRoot = null;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
const setupComponent = () => {
|
|
520
|
-
const targetElement = (shadowRoot == null ? void 0 : shadowRoot.firstElementChild) || element;
|
|
521
|
-
targetElement.classList.add("explorer-component");
|
|
522
|
-
};
|
|
523
|
-
const api = {
|
|
524
|
-
id,
|
|
525
|
-
mount() {
|
|
526
|
-
if (mounted || destroyed) return;
|
|
527
|
-
mounted = true;
|
|
528
|
-
setupComponent();
|
|
529
|
-
if (options.className) {
|
|
530
|
-
element.classList.add(options.className);
|
|
531
|
-
}
|
|
532
|
-
if (options.theme) {
|
|
533
|
-
if (options.theme === "auto") {
|
|
534
|
-
const detectedTheme = detectTheme();
|
|
535
|
-
setElementTheme(element, detectedTheme);
|
|
536
|
-
} else {
|
|
537
|
-
setElementTheme(element, options.theme);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
api.emit("mount");
|
|
541
|
-
},
|
|
542
|
-
unmount() {
|
|
543
|
-
if (!mounted || destroyed) return;
|
|
544
|
-
mounted = false;
|
|
545
|
-
api.emit("unmount");
|
|
546
|
-
},
|
|
547
|
-
destroy() {
|
|
548
|
-
if (destroyed) return;
|
|
549
|
-
destroyed = true;
|
|
550
|
-
if (mounted) {
|
|
551
|
-
api.unmount();
|
|
552
|
-
}
|
|
553
|
-
api.emit("destroy");
|
|
554
|
-
eventListeners.clear();
|
|
555
|
-
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
556
|
-
cleanupFunctions.length = 0;
|
|
557
|
-
element.removeAttribute("data-explorer-component");
|
|
558
|
-
element.classList.remove("explorer-component");
|
|
559
|
-
if (shadowRoot) {
|
|
560
|
-
shadowRoot.innerHTML = "";
|
|
561
|
-
shadowRoot = null;
|
|
562
|
-
}
|
|
563
|
-
componentRegistry.delete(id);
|
|
564
|
-
},
|
|
565
|
-
on(event, handler) {
|
|
566
|
-
if (!eventListeners.has(event)) {
|
|
567
|
-
eventListeners.set(event, /* @__PURE__ */ new Set());
|
|
568
|
-
}
|
|
569
|
-
const handlers = eventListeners.get(event);
|
|
570
|
-
handlers.add(handler);
|
|
571
|
-
return () => {
|
|
572
|
-
handlers.delete(handler);
|
|
573
|
-
if (handlers.size === 0) {
|
|
574
|
-
eventListeners.delete(event);
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
},
|
|
578
|
-
emit(event, data) {
|
|
579
|
-
const handlers = eventListeners.get(event);
|
|
580
|
-
if (!handlers) return;
|
|
581
|
-
handlers.forEach((handler) => {
|
|
582
|
-
try {
|
|
583
|
-
handler(data, api);
|
|
584
|
-
} catch (error) {
|
|
585
|
-
console.error(`Error in event handler for '${event}':`, error);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
},
|
|
589
|
-
getElement() {
|
|
590
|
-
return destroyed ? null : element;
|
|
591
|
-
},
|
|
592
|
-
getShadowRoot() {
|
|
593
|
-
return destroyed ? null : shadowRoot;
|
|
594
|
-
},
|
|
595
|
-
getContentRoot() {
|
|
596
|
-
if (destroyed) return element;
|
|
597
|
-
return (shadowRoot == null ? void 0 : shadowRoot.firstElementChild) || element;
|
|
598
|
-
},
|
|
599
|
-
injectCSS(css, id2) {
|
|
600
|
-
if (destroyed) return;
|
|
601
|
-
const targetRoot = shadowRoot || document.head;
|
|
602
|
-
const styleId = id2 || `explorer-css-${api.id}`;
|
|
603
|
-
const existingStyle = targetRoot.querySelector(`#${styleId}`);
|
|
604
|
-
if (existingStyle) {
|
|
605
|
-
existingStyle.remove();
|
|
606
|
-
}
|
|
607
|
-
const style = document.createElement("style");
|
|
608
|
-
style.id = styleId;
|
|
609
|
-
style.textContent = css;
|
|
610
|
-
if (shadowRoot) {
|
|
611
|
-
shadowRoot.appendChild(style);
|
|
612
|
-
} else {
|
|
613
|
-
document.head.appendChild(style);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
componentRegistry.set(id, api);
|
|
618
|
-
if (options.autoMount !== false) {
|
|
619
|
-
api.mount();
|
|
620
|
-
}
|
|
621
|
-
return api;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// src/utils/dom.ts
|
|
625
|
-
function createElement(tagName, attributes = {}, styles = {}) {
|
|
626
|
-
const element = document.createElement(tagName);
|
|
627
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
628
|
-
if (key === "className") {
|
|
629
|
-
element.className = value;
|
|
630
|
-
} else if (key === "textContent") {
|
|
631
|
-
element.textContent = value;
|
|
632
|
-
} else if (key === "innerHTML") {
|
|
633
|
-
element.innerHTML = value;
|
|
634
|
-
} else {
|
|
635
|
-
element.setAttribute(key, value);
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
Object.entries(styles).forEach(([property, value]) => {
|
|
639
|
-
element.style[property] = value;
|
|
640
|
-
});
|
|
641
|
-
return element;
|
|
642
|
-
}
|
|
643
|
-
function addEventListener(element, event, handler, options) {
|
|
644
|
-
element.addEventListener(event, handler, options);
|
|
645
|
-
return () => {
|
|
646
|
-
element.removeEventListener(
|
|
647
|
-
event,
|
|
648
|
-
handler,
|
|
649
|
-
options
|
|
650
|
-
);
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
function injectCSS(css, id, target) {
|
|
654
|
-
const targetDocument = target || document;
|
|
655
|
-
const targetHead = target instanceof ShadowRoot ? target : target instanceof HTMLElement ? target : document.head;
|
|
656
|
-
if (id) {
|
|
657
|
-
const existing = targetDocument.querySelector ? targetDocument.querySelector(`#${id}`) : document.getElementById(id);
|
|
658
|
-
if (existing) {
|
|
659
|
-
existing.remove();
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
const style = createElement("style", __spreadValues({
|
|
663
|
-
type: "text/css"
|
|
664
|
-
}, id && { id }));
|
|
665
|
-
style.textContent = css;
|
|
666
|
-
targetHead.appendChild(style);
|
|
667
|
-
return style;
|
|
668
|
-
}
|
|
669
|
-
function injectComponentCSS(css, id, shadowRoot, scopePrefix) {
|
|
670
|
-
let scopedCSS = css;
|
|
671
|
-
if (!shadowRoot && scopePrefix) {
|
|
672
|
-
scopedCSS = css.replace(/(\.explorer-[\w-]+)/g, `${scopePrefix} $1`);
|
|
673
|
-
}
|
|
674
|
-
const target = shadowRoot || document;
|
|
675
|
-
return injectCSS(scopedCSS, id, target);
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// src/core/UnifiedHeader.ts
|
|
679
|
-
function createUnifiedHeader(options) {
|
|
680
|
-
let currentTitle = options.title;
|
|
681
|
-
let headerElement;
|
|
682
|
-
let titleElement;
|
|
683
|
-
let actionsElement;
|
|
684
|
-
const cleanupFunctions = [];
|
|
685
|
-
const shadowRoot = options.shadowRoot || null;
|
|
686
|
-
function injectStyles() {
|
|
687
|
-
const css = `
|
|
688
|
-
/* UnifiedHeader Component Styles */
|
|
689
|
-
.explorer-unified-header {
|
|
690
|
-
display: flex;
|
|
691
|
-
align-items: center;
|
|
692
|
-
justify-content: space-between;
|
|
693
|
-
padding: 8px 12px;
|
|
694
|
-
background: var(--explorer-bg-tertiary, #f9fafb);
|
|
695
|
-
border-bottom: 1px solid var(--explorer-border-primary, #e5e7eb);
|
|
696
|
-
font-size: 12px;
|
|
697
|
-
font-weight: 600;
|
|
698
|
-
color: var(--explorer-text-secondary, #6b7280);
|
|
699
|
-
min-height: 32px;
|
|
700
|
-
box-sizing: border-box;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
.explorer-unified-header__title {
|
|
704
|
-
flex: 1;
|
|
705
|
-
color: var(--explorer-text-secondary, #6b7280);
|
|
706
|
-
font-weight: 600;
|
|
707
|
-
font-size: 12px;
|
|
708
|
-
margin: 0;
|
|
709
|
-
padding: 0;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
.explorer-unified-header__actions {
|
|
713
|
-
display: flex;
|
|
714
|
-
align-items: center;
|
|
715
|
-
gap: 4px;
|
|
716
|
-
margin-left: auto;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
.explorer-unified-header__btn {
|
|
720
|
-
background: none;
|
|
721
|
-
border: 1px solid var(--explorer-border-primary, #e5e7eb);
|
|
722
|
-
color: var(--explorer-text-secondary, #6b7280);
|
|
723
|
-
cursor: pointer;
|
|
724
|
-
padding: 2px 6px;
|
|
725
|
-
border-radius: 3px;
|
|
726
|
-
font-size: 10px;
|
|
727
|
-
font-weight: 500;
|
|
728
|
-
transition: all 0.2s ease;
|
|
729
|
-
line-height: 1.2;
|
|
730
|
-
min-width: auto;
|
|
731
|
-
height: 20px;
|
|
732
|
-
display: flex;
|
|
733
|
-
align-items: center;
|
|
734
|
-
justify-content: center;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
.explorer-unified-header__btn:hover {
|
|
738
|
-
background: var(--explorer-interactive-hover, #f3f4f6);
|
|
739
|
-
color: var(--explorer-text-primary, #111827);
|
|
740
|
-
border-color: var(--explorer-border-secondary, #d1d5db);
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
.explorer-unified-header__btn:active {
|
|
744
|
-
background: var(--explorer-interactive-active, #e5e7eb);
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
.explorer-unified-header__btn--clear {
|
|
748
|
-
/* Specific styling for clear button if needed */
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
.explorer-unified-header__btn--copy {
|
|
752
|
-
/* Specific styling for copy button if needed */
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
.explorer-unified-header__btn--refresh {
|
|
756
|
-
/* Specific styling for refresh button if needed */
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
.explorer-unified-header__btn--theme {
|
|
760
|
-
/* Specific styling for theme toggle button */
|
|
761
|
-
font-size: 12px;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/* Responsive design */
|
|
765
|
-
@media (max-width: 768px) {
|
|
766
|
-
.explorer-unified-header {
|
|
767
|
-
padding: 6px 10px;
|
|
768
|
-
min-height: 28px;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
.explorer-unified-header__btn {
|
|
772
|
-
padding: 1px 4px;
|
|
773
|
-
font-size: 9px;
|
|
774
|
-
height: 18px;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
`;
|
|
778
|
-
injectComponentCSS(
|
|
779
|
-
css,
|
|
780
|
-
"explorer-unified-header-styles",
|
|
781
|
-
shadowRoot,
|
|
782
|
-
".explorer-unified-header"
|
|
783
|
-
);
|
|
784
|
-
}
|
|
785
|
-
function createButtons(opts) {
|
|
786
|
-
const buttons = [];
|
|
787
|
-
if (opts.onClear) {
|
|
788
|
-
const clearBtn = createElement("button", {
|
|
789
|
-
className: "explorer-unified-header__btn explorer-unified-header__btn--clear",
|
|
790
|
-
textContent: "Clear",
|
|
791
|
-
title: "Clear content"
|
|
792
|
-
});
|
|
793
|
-
cleanupFunctions.push(addEventListener(clearBtn, "click", opts.onClear));
|
|
794
|
-
buttons.push(clearBtn);
|
|
795
|
-
}
|
|
796
|
-
if (opts.onCopy) {
|
|
797
|
-
const copyBtn = createElement("button", {
|
|
798
|
-
className: "explorer-unified-header__btn explorer-unified-header__btn--copy",
|
|
799
|
-
textContent: "\u{1F4CB}",
|
|
800
|
-
title: "Copy content"
|
|
801
|
-
});
|
|
802
|
-
cleanupFunctions.push(addEventListener(copyBtn, "click", opts.onCopy));
|
|
803
|
-
buttons.push(copyBtn);
|
|
804
|
-
}
|
|
805
|
-
if (opts.onRefresh) {
|
|
806
|
-
const refreshBtn = createElement("button", {
|
|
807
|
-
className: "explorer-unified-header__btn explorer-unified-header__btn--refresh",
|
|
808
|
-
textContent: "\u{1F504}",
|
|
809
|
-
title: "Refresh"
|
|
810
|
-
});
|
|
811
|
-
cleanupFunctions.push(
|
|
812
|
-
addEventListener(refreshBtn, "click", opts.onRefresh)
|
|
813
|
-
);
|
|
814
|
-
buttons.push(refreshBtn);
|
|
815
|
-
}
|
|
816
|
-
if (opts.onThemeToggle) {
|
|
817
|
-
const themeBtn = createElement("button", {
|
|
818
|
-
className: "explorer-unified-header__btn explorer-unified-header__btn--theme",
|
|
819
|
-
textContent: "\u{1F319}",
|
|
820
|
-
title: "Toggle theme"
|
|
821
|
-
});
|
|
822
|
-
cleanupFunctions.push(
|
|
823
|
-
addEventListener(themeBtn, "click", opts.onThemeToggle)
|
|
824
|
-
);
|
|
825
|
-
buttons.push(themeBtn);
|
|
826
|
-
}
|
|
827
|
-
if (opts.customButtons) {
|
|
828
|
-
opts.customButtons.forEach((buttonConfig) => {
|
|
829
|
-
const customBtn = createElement("button", {
|
|
830
|
-
className: `explorer-unified-header__btn ${buttonConfig.className || ""}`,
|
|
831
|
-
textContent: buttonConfig.text,
|
|
832
|
-
title: buttonConfig.title || buttonConfig.text
|
|
833
|
-
});
|
|
834
|
-
cleanupFunctions.push(
|
|
835
|
-
addEventListener(customBtn, "click", buttonConfig.callback)
|
|
836
|
-
);
|
|
837
|
-
buttons.push(customBtn);
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
return buttons;
|
|
841
|
-
}
|
|
842
|
-
function createDOM() {
|
|
843
|
-
headerElement = createElement("div", {
|
|
844
|
-
className: `explorer-unified-header ${options.className || ""}`
|
|
845
|
-
});
|
|
846
|
-
titleElement = createElement("div", {
|
|
847
|
-
className: "explorer-unified-header__title",
|
|
848
|
-
textContent: currentTitle
|
|
849
|
-
});
|
|
850
|
-
actionsElement = createElement("div", {
|
|
851
|
-
className: "explorer-unified-header__actions"
|
|
852
|
-
});
|
|
853
|
-
const buttons = createButtons(options);
|
|
854
|
-
buttons.forEach((button) => actionsElement.appendChild(button));
|
|
855
|
-
headerElement.appendChild(titleElement);
|
|
856
|
-
headerElement.appendChild(actionsElement);
|
|
857
|
-
return headerElement;
|
|
858
|
-
}
|
|
859
|
-
function updateButtons(newOptions) {
|
|
860
|
-
actionsElement.innerHTML = "";
|
|
861
|
-
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
862
|
-
cleanupFunctions.length = 0;
|
|
863
|
-
const mergedOptions = __spreadValues(__spreadValues({}, options), newOptions);
|
|
864
|
-
const buttons = createButtons(mergedOptions);
|
|
865
|
-
buttons.forEach((button) => actionsElement.appendChild(button));
|
|
866
|
-
Object.assign(options, newOptions);
|
|
867
|
-
}
|
|
868
|
-
const api = {
|
|
869
|
-
getElement() {
|
|
870
|
-
return headerElement;
|
|
871
|
-
},
|
|
872
|
-
setTitle(title) {
|
|
873
|
-
currentTitle = title;
|
|
874
|
-
titleElement.textContent = title;
|
|
875
|
-
},
|
|
876
|
-
updateButtons(newOptions) {
|
|
877
|
-
updateButtons(newOptions);
|
|
878
|
-
},
|
|
879
|
-
destroy() {
|
|
880
|
-
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
881
|
-
cleanupFunctions.length = 0;
|
|
882
|
-
headerElement == null ? void 0 : headerElement.remove();
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
injectStyles();
|
|
886
|
-
createDOM();
|
|
887
|
-
return api;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
// src/core/UnifiedContainer.ts
|
|
891
|
-
function createUnifiedContainer(options = {}) {
|
|
892
|
-
let containerElement;
|
|
893
|
-
let contentElement;
|
|
894
|
-
let headerAPI = null;
|
|
895
|
-
const shadowRoot = options.shadowRoot || null;
|
|
896
|
-
function injectStyles() {
|
|
897
|
-
const css = `
|
|
898
|
-
/* UnifiedContainer Component Styles */
|
|
899
|
-
.explorer-unified-container {
|
|
900
|
-
display: flex;
|
|
901
|
-
flex-direction: column;
|
|
902
|
-
background: var(--explorer-bg-primary);
|
|
903
|
-
border: 1px solid var(--explorer-border-primary, #e5e7eb);
|
|
904
|
-
border-radius: 8px;
|
|
905
|
-
overflow: hidden;
|
|
906
|
-
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
907
|
-
transition: all 0.2s ease;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
.explorer-unified-container:focus-within {
|
|
912
|
-
border-color: var(--explorer-interactive-primary, #2563eb);
|
|
913
|
-
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
.explorer-unified-container__content {
|
|
917
|
-
flex: 1;
|
|
918
|
-
overflow: hidden;
|
|
919
|
-
display: flex;
|
|
920
|
-
flex-direction: column;
|
|
921
|
-
background: transparent;
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
/* Specific container variants */
|
|
925
|
-
.explorer-unified-container--code-editor {
|
|
926
|
-
/* Specific styling for code editor containers */
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
.explorer-unified-container--result-display {
|
|
930
|
-
/* Specific styling for result display containers */
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
.explorer-unified-container--preview {
|
|
934
|
-
/* Specific styling for preview containers */
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
.explorer-unified-container--destination {
|
|
938
|
-
/* Specific styling for destination containers */
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
/* Height management */
|
|
942
|
-
.explorer-unified-container--fixed-height {
|
|
943
|
-
height: var(--container-height);
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
.explorer-unified-container--flex-height {
|
|
947
|
-
flex: 1;
|
|
948
|
-
min-height: 0;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
/* Responsive design */
|
|
952
|
-
@media (max-width: 768px) {
|
|
953
|
-
.explorer-unified-container {
|
|
954
|
-
border-radius: 6px;
|
|
955
|
-
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
`;
|
|
959
|
-
injectComponentCSS(
|
|
960
|
-
css,
|
|
961
|
-
"explorer-unified-container-styles",
|
|
962
|
-
shadowRoot,
|
|
963
|
-
".explorer-unified-container"
|
|
964
|
-
);
|
|
965
|
-
}
|
|
966
|
-
function createDOM() {
|
|
967
|
-
containerElement = createElement("div", {
|
|
968
|
-
className: `explorer-unified-container ${options.className || ""}`
|
|
969
|
-
});
|
|
970
|
-
if (options.height) {
|
|
971
|
-
containerElement.style.setProperty("--container-height", options.height);
|
|
972
|
-
containerElement.classList.add(
|
|
973
|
-
"explorer-unified-container--fixed-height"
|
|
974
|
-
);
|
|
975
|
-
} else {
|
|
976
|
-
containerElement.classList.add("explorer-unified-container--flex-height");
|
|
977
|
-
}
|
|
978
|
-
if (options.showHeader && options.headerOptions) {
|
|
979
|
-
const headerOptions = __spreadProps(__spreadValues({}, options.headerOptions), { shadowRoot });
|
|
980
|
-
headerAPI = createUnifiedHeader(headerOptions);
|
|
981
|
-
containerElement.appendChild(headerAPI.getElement());
|
|
982
|
-
}
|
|
983
|
-
contentElement = createElement("div", {
|
|
984
|
-
className: `explorer-unified-container__content ${options.contentClassName || ""}`
|
|
985
|
-
});
|
|
986
|
-
containerElement.appendChild(contentElement);
|
|
987
|
-
return containerElement;
|
|
988
|
-
}
|
|
989
|
-
const api = {
|
|
990
|
-
getElement() {
|
|
991
|
-
return containerElement;
|
|
992
|
-
},
|
|
993
|
-
getContentElement() {
|
|
994
|
-
return contentElement;
|
|
995
|
-
},
|
|
996
|
-
getHeader() {
|
|
997
|
-
return headerAPI;
|
|
998
|
-
},
|
|
999
|
-
setHeight(height) {
|
|
1000
|
-
containerElement.style.setProperty("--container-height", height);
|
|
1001
|
-
if (!containerElement.classList.contains(
|
|
1002
|
-
"explorer-unified-container--fixed-height"
|
|
1003
|
-
)) {
|
|
1004
|
-
containerElement.classList.remove(
|
|
1005
|
-
"explorer-unified-container--flex-height"
|
|
1006
|
-
);
|
|
1007
|
-
containerElement.classList.add(
|
|
1008
|
-
"explorer-unified-container--fixed-height"
|
|
1009
|
-
);
|
|
1010
|
-
}
|
|
1011
|
-
},
|
|
1012
|
-
destroy() {
|
|
1013
|
-
headerAPI == null ? void 0 : headerAPI.destroy();
|
|
1014
|
-
containerElement == null ? void 0 : containerElement.remove();
|
|
1015
|
-
}
|
|
1016
|
-
};
|
|
1017
|
-
injectStyles();
|
|
1018
|
-
createDOM();
|
|
1019
|
-
return api;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
// src/core/MultiColumnLayout.ts
|
|
1023
|
-
init_css_theme_system();
|
|
1024
|
-
|
|
1025
|
-
// src/utils/syntax.ts
|
|
1026
|
-
var languageDefinitions = {
|
|
1027
|
-
javascript: [
|
|
1028
|
-
{
|
|
1029
|
-
type: "comment",
|
|
1030
|
-
pattern: /\/\*[\s\S]*?\*\/|\/\/.*$/gm,
|
|
1031
|
-
className: "syntax-comment"
|
|
1032
|
-
},
|
|
1033
|
-
{
|
|
1034
|
-
type: "string",
|
|
1035
|
-
pattern: /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`/g,
|
|
1036
|
-
className: "syntax-string"
|
|
1037
|
-
},
|
|
1038
|
-
{
|
|
1039
|
-
type: "keyword",
|
|
1040
|
-
pattern: /\b(?:async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|let|new|return|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/g,
|
|
1041
|
-
className: "syntax-keyword"
|
|
1042
|
-
},
|
|
1043
|
-
{
|
|
1044
|
-
type: "boolean",
|
|
1045
|
-
pattern: /\b(?:true|false|null|undefined)\b/g,
|
|
1046
|
-
className: "syntax-keyword"
|
|
1047
|
-
},
|
|
1048
|
-
{
|
|
1049
|
-
type: "number",
|
|
1050
|
-
pattern: /\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/g,
|
|
1051
|
-
className: "syntax-number"
|
|
1052
|
-
},
|
|
1053
|
-
{
|
|
1054
|
-
type: "function",
|
|
1055
|
-
pattern: /\b[a-zA-Z_$][a-zA-Z0-9_$]*(?=\s*\()/g,
|
|
1056
|
-
className: "syntax-function"
|
|
1057
|
-
},
|
|
1058
|
-
{
|
|
1059
|
-
type: "operator",
|
|
1060
|
-
pattern: /[+\-*/%=!<>?:&|^~]+|===|!==|==|!=|<=|>=|\|\||&&|\+\+|--|=>|\.\.\./g,
|
|
1061
|
-
className: "syntax-operator"
|
|
1062
|
-
}
|
|
1063
|
-
],
|
|
1064
|
-
typescript: [
|
|
1065
|
-
{
|
|
1066
|
-
type: "comment",
|
|
1067
|
-
pattern: /\/\*[\s\S]*?\*\/|\/\/.*$/gm,
|
|
1068
|
-
className: "syntax-comment"
|
|
1069
|
-
},
|
|
1070
|
-
{
|
|
1071
|
-
type: "string",
|
|
1072
|
-
pattern: /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`/g,
|
|
1073
|
-
className: "syntax-string"
|
|
1074
|
-
},
|
|
1075
|
-
{
|
|
1076
|
-
type: "keyword",
|
|
1077
|
-
pattern: /\b(?:abstract|any|as|async|await|boolean|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|module|namespace|new|private|protected|public|readonly|return|set|static|string|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/g,
|
|
1078
|
-
className: "syntax-keyword"
|
|
1079
|
-
},
|
|
1080
|
-
{
|
|
1081
|
-
type: "boolean",
|
|
1082
|
-
pattern: /\b(?:true|false|null|undefined)\b/g,
|
|
1083
|
-
className: "syntax-keyword"
|
|
1084
|
-
},
|
|
1085
|
-
{
|
|
1086
|
-
type: "number",
|
|
1087
|
-
pattern: /\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/g,
|
|
1088
|
-
className: "syntax-number"
|
|
1089
|
-
},
|
|
1090
|
-
{
|
|
1091
|
-
type: "function",
|
|
1092
|
-
pattern: /\b[a-zA-Z_$][a-zA-Z0-9_$]*(?=\s*\()/g,
|
|
1093
|
-
className: "syntax-function"
|
|
1094
|
-
},
|
|
1095
|
-
{
|
|
1096
|
-
type: "type",
|
|
1097
|
-
pattern: /\b[A-Z][a-zA-Z0-9]*\b/g,
|
|
1098
|
-
className: "syntax-type"
|
|
1099
|
-
},
|
|
1100
|
-
{
|
|
1101
|
-
type: "operator",
|
|
1102
|
-
pattern: /[+\-*/%=!<>?:&|^~]+|===|!==|==|!=|<=|>=|\|\||&&|\+\+|--|=>|\.\.\./g,
|
|
1103
|
-
className: "syntax-operator"
|
|
1104
|
-
}
|
|
1105
|
-
],
|
|
1106
|
-
html: [
|
|
1107
|
-
{
|
|
1108
|
-
type: "comment",
|
|
1109
|
-
pattern: /<!--[\s\S]*?-->/g,
|
|
1110
|
-
className: "syntax-comment"
|
|
1111
|
-
},
|
|
1112
|
-
{
|
|
1113
|
-
type: "tag",
|
|
1114
|
-
pattern: /<\/?[a-zA-Z][a-zA-Z0-9-]*\b/g,
|
|
1115
|
-
className: "syntax-tag"
|
|
1116
|
-
},
|
|
1117
|
-
{
|
|
1118
|
-
type: "elb-attribute",
|
|
1119
|
-
pattern: /\bdata-elb[a-zA-Z-]*(?==)/g,
|
|
1120
|
-
className: "syntax-elb-attribute"
|
|
1121
|
-
},
|
|
1122
|
-
{
|
|
1123
|
-
type: "elb-value",
|
|
1124
|
-
pattern: new RegExp(`(?<=data-elb[a-zA-Z-]*=)"[^"]*"|(?<=data-elb[a-zA-Z-]*=)'[^']*'`, "g"),
|
|
1125
|
-
className: "syntax-elb-value"
|
|
1126
|
-
},
|
|
1127
|
-
{
|
|
1128
|
-
type: "attribute",
|
|
1129
|
-
pattern: /\b[a-zA-Z-]+(?==)/g,
|
|
1130
|
-
className: "syntax-attribute"
|
|
1131
|
-
},
|
|
1132
|
-
{ type: "value", pattern: /"[^"]*"|'[^']*'/g, className: "syntax-value" }
|
|
1133
|
-
],
|
|
1134
|
-
json: [
|
|
1135
|
-
{
|
|
1136
|
-
type: "key",
|
|
1137
|
-
pattern: /"(?:\\.|[^"\\])*"(?=\s*:)/g,
|
|
1138
|
-
className: "syntax-attribute"
|
|
1139
|
-
},
|
|
1140
|
-
{
|
|
1141
|
-
type: "string",
|
|
1142
|
-
pattern: /"(?:\\.|[^"\\])*"/g,
|
|
1143
|
-
className: "syntax-string"
|
|
1144
|
-
},
|
|
1145
|
-
{
|
|
1146
|
-
type: "number",
|
|
1147
|
-
pattern: /-?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b/g,
|
|
1148
|
-
className: "syntax-number"
|
|
1149
|
-
},
|
|
1150
|
-
{
|
|
1151
|
-
type: "boolean",
|
|
1152
|
-
pattern: /\b(true|false|null)\b/g,
|
|
1153
|
-
className: "syntax-keyword"
|
|
1154
|
-
}
|
|
1155
|
-
],
|
|
1156
|
-
css: [
|
|
1157
|
-
{
|
|
1158
|
-
type: "comment",
|
|
1159
|
-
pattern: /\/\*[\s\S]*?\*\//g,
|
|
1160
|
-
className: "syntax-comment"
|
|
1161
|
-
},
|
|
1162
|
-
{
|
|
1163
|
-
type: "selector",
|
|
1164
|
-
pattern: /[.#]?[a-zA-Z][\w-]*(?=\s*\{)/g,
|
|
1165
|
-
className: "syntax-tag"
|
|
1166
|
-
},
|
|
1167
|
-
{
|
|
1168
|
-
type: "property",
|
|
1169
|
-
pattern: new RegExp("(?<=\\{|\\;)\\s*[a-zA-Z-]+(?=\\s*:)", "g"),
|
|
1170
|
-
className: "syntax-property"
|
|
1171
|
-
},
|
|
1172
|
-
{
|
|
1173
|
-
type: "value",
|
|
1174
|
-
pattern: new RegExp("(?<=:\\s*)[^;}]+", "g"),
|
|
1175
|
-
className: "syntax-string"
|
|
1176
|
-
},
|
|
1177
|
-
{
|
|
1178
|
-
type: "unit",
|
|
1179
|
-
pattern: /\b\d+(?:px|em|rem|%|vh|vw|pt|pc|in|cm|mm|ex|ch|fr)\b/g,
|
|
1180
|
-
className: "syntax-number"
|
|
1181
|
-
},
|
|
1182
|
-
{
|
|
1183
|
-
type: "color",
|
|
1184
|
-
pattern: /#[0-9a-fA-F]{3,6}\b|rgb\([^)]+\)|rgba\([^)]+\)|hsl\([^)]+\)|hsla\([^)]+\)/g,
|
|
1185
|
-
className: "syntax-number"
|
|
1186
|
-
}
|
|
1187
|
-
],
|
|
1188
|
-
text: []
|
|
1189
|
-
};
|
|
1190
|
-
function highlightSyntax(code, language = "text") {
|
|
1191
|
-
if (language === "text" || !code.trim()) {
|
|
1192
|
-
return escapeHtml(code);
|
|
1193
|
-
}
|
|
1194
|
-
const definition = languageDefinitions[language];
|
|
1195
|
-
if (!definition) {
|
|
1196
|
-
return escapeHtml(code);
|
|
1197
|
-
}
|
|
1198
|
-
const matches = [];
|
|
1199
|
-
definition.forEach(({ type, pattern, className }) => {
|
|
1200
|
-
let match;
|
|
1201
|
-
while ((match = pattern.exec(code)) !== null) {
|
|
1202
|
-
matches.push({
|
|
1203
|
-
start: match.index,
|
|
1204
|
-
end: match.index + match[0].length,
|
|
1205
|
-
type,
|
|
1206
|
-
className,
|
|
1207
|
-
content: match[0]
|
|
1208
|
-
});
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
matches.sort((a, b) => a.start - b.start);
|
|
1212
|
-
const filteredMatches = [];
|
|
1213
|
-
let lastEnd = 0;
|
|
1214
|
-
for (const match of matches) {
|
|
1215
|
-
if (match.start >= lastEnd) {
|
|
1216
|
-
filteredMatches.push(match);
|
|
1217
|
-
lastEnd = match.end;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
let result = "";
|
|
1221
|
-
let currentPos = 0;
|
|
1222
|
-
for (const match of filteredMatches) {
|
|
1223
|
-
if (match.start > currentPos) {
|
|
1224
|
-
result += escapeHtml(code.slice(currentPos, match.start));
|
|
1225
|
-
}
|
|
1226
|
-
result += `<span class="${match.className}">${escapeHtml(match.content)}</span>`;
|
|
1227
|
-
currentPos = match.end;
|
|
1228
|
-
}
|
|
1229
|
-
if (currentPos < code.length) {
|
|
1230
|
-
result += escapeHtml(code.slice(currentPos));
|
|
1231
|
-
}
|
|
1232
|
-
return result;
|
|
1233
|
-
}
|
|
1234
|
-
function escapeHtml(text) {
|
|
1235
|
-
const map = {
|
|
1236
|
-
"&": "&",
|
|
1237
|
-
"<": "<",
|
|
1238
|
-
">": ">",
|
|
1239
|
-
'"': """,
|
|
1240
|
-
"'": "'"
|
|
1241
|
-
};
|
|
1242
|
-
return text.replace(/[&<>"']/g, (char) => map[char]);
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
// src/utils/debounce.ts
|
|
1246
|
-
function debounce(func, delay, immediate = false) {
|
|
1247
|
-
let timeoutId;
|
|
1248
|
-
let lastArgs;
|
|
1249
|
-
let lastResult;
|
|
1250
|
-
const debounced = (...args) => {
|
|
1251
|
-
lastArgs = args;
|
|
1252
|
-
const callNow = immediate && !timeoutId;
|
|
1253
|
-
if (timeoutId) {
|
|
1254
|
-
clearTimeout(timeoutId);
|
|
1255
|
-
}
|
|
1256
|
-
timeoutId = setTimeout(() => {
|
|
1257
|
-
timeoutId = void 0;
|
|
1258
|
-
if (!immediate) {
|
|
1259
|
-
lastResult = func(...args);
|
|
1260
|
-
}
|
|
1261
|
-
}, delay);
|
|
1262
|
-
if (callNow) {
|
|
1263
|
-
lastResult = func(...args);
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
debounced.cancel = () => {
|
|
1267
|
-
if (timeoutId) {
|
|
1268
|
-
clearTimeout(timeoutId);
|
|
1269
|
-
timeoutId = void 0;
|
|
1270
|
-
}
|
|
1271
|
-
};
|
|
1272
|
-
debounced.flush = () => {
|
|
1273
|
-
if (timeoutId && lastArgs) {
|
|
1274
|
-
debounced.cancel();
|
|
1275
|
-
lastResult = func(...lastArgs);
|
|
1276
|
-
}
|
|
1277
|
-
return lastResult;
|
|
1278
|
-
};
|
|
1279
|
-
return debounced;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
// src/components/CodeEditor.ts
|
|
1283
|
-
var CODE_EDITOR_CSS = `
|
|
1284
|
-
/* CodeEditor Component Styles */
|
|
1285
|
-
.explorer-code-editor {
|
|
1286
|
-
position: relative;
|
|
1287
|
-
background: var(--explorer-bg-primary);
|
|
1288
|
-
overflow: hidden;
|
|
1289
|
-
font-family: 'Fira Code', 'JetBrains Mono', Menlo, Monaco, 'Courier New', monospace;
|
|
1290
|
-
height: 100%;
|
|
1291
|
-
display: flex;
|
|
1292
|
-
flex-direction: column;
|
|
1293
|
-
box-sizing: border-box;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
.explorer-code-editor * {
|
|
1297
|
-
box-sizing: border-box;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
.explorer-code-editor:focus-within {
|
|
1301
|
-
border-color: var(--explorer-primary);
|
|
1302
|
-
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
.explorer-code-editor--readonly {
|
|
1306
|
-
background: var(--explorer-bg-tertiary);
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
.explorer-code-editor__content {
|
|
1310
|
-
position: relative;
|
|
1311
|
-
overflow: hidden;
|
|
1312
|
-
display: flex;
|
|
1313
|
-
flex-direction: column;
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
.explorer-code-editor__textarea {
|
|
1317
|
-
position: absolute !important;
|
|
1318
|
-
top: 0 !important;
|
|
1319
|
-
left: 0 !important;
|
|
1320
|
-
width: 100% !important;
|
|
1321
|
-
height: 100% !important;
|
|
1322
|
-
padding: 4px !important;
|
|
1323
|
-
margin: 0 !important;
|
|
1324
|
-
border: none !important;
|
|
1325
|
-
outline: none !important;
|
|
1326
|
-
background: transparent !important;
|
|
1327
|
-
color: transparent !important;
|
|
1328
|
-
font-family: 'Fira Code', 'JetBrains Mono', Menlo, Monaco, 'Courier New', monospace !important;
|
|
1329
|
-
font-size: 14px !important;
|
|
1330
|
-
line-height: 1.6 !important;
|
|
1331
|
-
resize: none !important;
|
|
1332
|
-
z-index: 2 !important;
|
|
1333
|
-
white-space: pre !important;
|
|
1334
|
-
overflow-wrap: normal !important;
|
|
1335
|
-
word-break: normal !important;
|
|
1336
|
-
caret-color: var(--explorer-text-primary) !important;
|
|
1337
|
-
box-sizing: border-box !important;
|
|
1338
|
-
/* Force cursor visibility and animation */
|
|
1339
|
-
cursor: text !important;
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
.explorer-code-editor__textarea::placeholder {
|
|
1343
|
-
color: var(--explorer-text-muted);
|
|
1344
|
-
font-style: italic;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
/* Ensure cursor animation is enabled */
|
|
1348
|
-
.explorer-code-editor__textarea:focus {
|
|
1349
|
-
caret-color: var(--explorer-text-primary) !important;
|
|
1350
|
-
animation: none !important; /* Remove any conflicting animations */
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
/* Force caret visibility across browsers */
|
|
1354
|
-
@supports (caret-color: var(--explorer-text-primary)) {
|
|
1355
|
-
.explorer-code-editor__textarea {
|
|
1356
|
-
caret-color: var(--explorer-text-primary) !important;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
/* Fallback for browsers that don't support caret-color */
|
|
1361
|
-
@supports not (caret-color: var(--explorer-text-primary)) {
|
|
1362
|
-
.explorer-code-editor__textarea {
|
|
1363
|
-
color: var(--explorer-text-primary) !important;
|
|
1364
|
-
text-shadow: none !important;
|
|
1365
|
-
background: transparent !important;
|
|
1366
|
-
}
|
|
1367
|
-
.explorer-code-editor__highlight {
|
|
1368
|
-
display: none !important;
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
.explorer-code-editor__highlight {
|
|
1373
|
-
position: absolute !important;
|
|
1374
|
-
top: 0 !important;
|
|
1375
|
-
left: 0 !important;
|
|
1376
|
-
width: 100% !important;
|
|
1377
|
-
height: 100% !important;
|
|
1378
|
-
padding: 4px !important;
|
|
1379
|
-
margin: 0 !important;
|
|
1380
|
-
border: none !important;
|
|
1381
|
-
background: transparent !important;
|
|
1382
|
-
color: var(--explorer-text-primary) !important;
|
|
1383
|
-
font-family: 'Fira Code', 'JetBrains Mono', Menlo, Monaco, 'Courier New', monospace !important;
|
|
1384
|
-
font-size: 14px !important;
|
|
1385
|
-
line-height: 1.6 !important;
|
|
1386
|
-
white-space: pre !important;
|
|
1387
|
-
overflow-wrap: normal !important;
|
|
1388
|
-
word-break: normal !important;
|
|
1389
|
-
z-index: 1 !important;
|
|
1390
|
-
pointer-events: none !important;
|
|
1391
|
-
overflow: auto !important;
|
|
1392
|
-
box-sizing: border-box !important;
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
.explorer-code-editor__highlight pre {
|
|
1396
|
-
margin: 0;
|
|
1397
|
-
padding: 0;
|
|
1398
|
-
background: transparent;
|
|
1399
|
-
color: var(--explorer-text-primary);
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
/* Responsive design */
|
|
1403
|
-
@media (max-width: 768px) {
|
|
1404
|
-
.explorer-code-editor__textarea,
|
|
1405
|
-
.explorer-code-editor__highlight {
|
|
1406
|
-
font-size: 13px;
|
|
1407
|
-
padding: 4px;
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
`;
|
|
1411
|
-
function createCodeEditor(elementOrSelector, options = {}) {
|
|
1412
|
-
const baseComponent = createComponent(elementOrSelector, {
|
|
1413
|
-
autoMount: false,
|
|
1414
|
-
useShadowDOM: false
|
|
1415
|
-
// No shadow DOM - parent layout provides CSS isolation
|
|
1416
|
-
});
|
|
1417
|
-
const element = baseComponent.getElement();
|
|
1418
|
-
const shadowRoot = baseComponent.getShadowRoot();
|
|
1419
|
-
const contentRoot = baseComponent.getContentRoot();
|
|
1420
|
-
element.classList.add("explorer-code-editor");
|
|
1421
|
-
contentRoot.classList.add("explorer-code-editor");
|
|
1422
|
-
let currentValue = options.value || "";
|
|
1423
|
-
let currentLanguage = options.language || "text";
|
|
1424
|
-
let textArea;
|
|
1425
|
-
let highlightLayer;
|
|
1426
|
-
let isHighlighting = false;
|
|
1427
|
-
let lastHighlightedValue = "";
|
|
1428
|
-
const cleanupFunctions = [];
|
|
1429
|
-
const debouncedHighlight = debounce(() => {
|
|
1430
|
-
updateHighlighting();
|
|
1431
|
-
}, 20);
|
|
1432
|
-
const debouncedChange = debounce((value) => {
|
|
1433
|
-
var _a;
|
|
1434
|
-
(_a = options.onChange) == null ? void 0 : _a.call(options, value, currentLanguage);
|
|
1435
|
-
}, 200);
|
|
1436
|
-
function injectStyles() {
|
|
1437
|
-
}
|
|
1438
|
-
function createDOM() {
|
|
1439
|
-
contentRoot.innerHTML = "";
|
|
1440
|
-
const content = createElement("div", {
|
|
1441
|
-
className: "explorer-code-editor__content"
|
|
1442
|
-
});
|
|
1443
|
-
if (options.height) {
|
|
1444
|
-
content.style.height = options.height;
|
|
1445
|
-
} else if (options.maxHeight) {
|
|
1446
|
-
content.style.maxHeight = options.maxHeight;
|
|
1447
|
-
content.style.overflow = "auto";
|
|
1448
|
-
} else {
|
|
1449
|
-
content.style.height = "100%";
|
|
1450
|
-
}
|
|
1451
|
-
textArea = createElement("textarea", {
|
|
1452
|
-
className: "explorer-code-editor__textarea",
|
|
1453
|
-
placeholder: options.placeholder || `Enter ${currentLanguage} code...`,
|
|
1454
|
-
spellcheck: "false",
|
|
1455
|
-
autocomplete: "off",
|
|
1456
|
-
autocorrect: "off",
|
|
1457
|
-
autocapitalize: "off"
|
|
1458
|
-
});
|
|
1459
|
-
if (options.readOnly) {
|
|
1460
|
-
textArea.readOnly = true;
|
|
1461
|
-
element.classList.add("explorer-code-editor--readonly");
|
|
1462
|
-
}
|
|
1463
|
-
if (options.tabSize) {
|
|
1464
|
-
textArea.style.tabSize = options.tabSize.toString();
|
|
1465
|
-
}
|
|
1466
|
-
if (options.fontSize) {
|
|
1467
|
-
textArea.style.fontSize = options.fontSize;
|
|
1468
|
-
}
|
|
1469
|
-
textArea.value = currentValue;
|
|
1470
|
-
highlightLayer = createElement("div", {
|
|
1471
|
-
className: "explorer-code-editor__highlight"
|
|
1472
|
-
});
|
|
1473
|
-
content.appendChild(highlightLayer);
|
|
1474
|
-
content.appendChild(textArea);
|
|
1475
|
-
contentRoot.appendChild(content);
|
|
1476
|
-
}
|
|
1477
|
-
function updateHighlighting() {
|
|
1478
|
-
if (isHighlighting || currentValue === lastHighlightedValue) return;
|
|
1479
|
-
isHighlighting = true;
|
|
1480
|
-
requestAnimationFrame(() => {
|
|
1481
|
-
const highlighted = highlightSyntax(currentValue, currentLanguage);
|
|
1482
|
-
highlightLayer.innerHTML = `<pre>${highlighted}</pre>`;
|
|
1483
|
-
lastHighlightedValue = currentValue;
|
|
1484
|
-
isHighlighting = false;
|
|
1485
|
-
});
|
|
1486
|
-
}
|
|
1487
|
-
function setupEventListeners() {
|
|
1488
|
-
const onInput = () => {
|
|
1489
|
-
const newValue = textArea.value;
|
|
1490
|
-
if (newValue !== currentValue) {
|
|
1491
|
-
currentValue = newValue;
|
|
1492
|
-
debouncedHighlight();
|
|
1493
|
-
debouncedChange(newValue);
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
const onKeyDown = (e) => {
|
|
1497
|
-
if (e.key === "Tab") {
|
|
1498
|
-
e.preventDefault();
|
|
1499
|
-
const start = textArea.selectionStart;
|
|
1500
|
-
const end = textArea.selectionEnd;
|
|
1501
|
-
const tabChar = " ".repeat(options.tabSize || 2);
|
|
1502
|
-
textArea.value = currentValue.substring(0, start) + tabChar + currentValue.substring(end);
|
|
1503
|
-
textArea.selectionStart = textArea.selectionEnd = start + tabChar.length;
|
|
1504
|
-
onInput();
|
|
1505
|
-
}
|
|
1506
|
-
};
|
|
1507
|
-
const onScroll = () => {
|
|
1508
|
-
highlightLayer.scrollTop = textArea.scrollTop;
|
|
1509
|
-
highlightLayer.scrollLeft = textArea.scrollLeft;
|
|
1510
|
-
};
|
|
1511
|
-
const onClick = () => {
|
|
1512
|
-
textArea.focus();
|
|
1513
|
-
};
|
|
1514
|
-
cleanupFunctions.push(addEventListener(textArea, "input", onInput));
|
|
1515
|
-
cleanupFunctions.push(addEventListener(textArea, "keydown", onKeyDown));
|
|
1516
|
-
cleanupFunctions.push(addEventListener(textArea, "scroll", onScroll));
|
|
1517
|
-
cleanupFunctions.push(addEventListener(contentRoot, "click", onClick));
|
|
1518
|
-
cleanupFunctions.push(addEventListener(highlightLayer, "click", onClick));
|
|
1519
|
-
}
|
|
1520
|
-
const api = __spreadProps(__spreadValues({}, baseComponent), {
|
|
1521
|
-
getValue() {
|
|
1522
|
-
return currentValue;
|
|
1523
|
-
},
|
|
1524
|
-
setValue(value) {
|
|
1525
|
-
currentValue = value;
|
|
1526
|
-
textArea.value = value;
|
|
1527
|
-
updateHighlighting();
|
|
1528
|
-
},
|
|
1529
|
-
getLanguage() {
|
|
1530
|
-
return currentLanguage;
|
|
1531
|
-
},
|
|
1532
|
-
setLanguage(language) {
|
|
1533
|
-
var _a;
|
|
1534
|
-
currentLanguage = language;
|
|
1535
|
-
textArea.placeholder = options.placeholder || `Enter ${language} code...`;
|
|
1536
|
-
updateHighlighting();
|
|
1537
|
-
(_a = options.onLanguageChange) == null ? void 0 : _a.call(options, language);
|
|
1538
|
-
},
|
|
1539
|
-
focus() {
|
|
1540
|
-
textArea.focus();
|
|
1541
|
-
},
|
|
1542
|
-
selectAll() {
|
|
1543
|
-
textArea.select();
|
|
1544
|
-
},
|
|
1545
|
-
insertText(text) {
|
|
1546
|
-
var _a;
|
|
1547
|
-
const start = textArea.selectionStart;
|
|
1548
|
-
const end = textArea.selectionEnd;
|
|
1549
|
-
const newValue = currentValue.substring(0, start) + text + currentValue.substring(end);
|
|
1550
|
-
this.setValue(newValue);
|
|
1551
|
-
textArea.selectionStart = textArea.selectionEnd = start + text.length;
|
|
1552
|
-
textArea.focus();
|
|
1553
|
-
(_a = options.onChange) == null ? void 0 : _a.call(options, newValue, currentLanguage);
|
|
1554
|
-
},
|
|
1555
|
-
getSelection() {
|
|
1556
|
-
const start = textArea.selectionStart;
|
|
1557
|
-
const end = textArea.selectionEnd;
|
|
1558
|
-
return {
|
|
1559
|
-
start,
|
|
1560
|
-
end,
|
|
1561
|
-
text: currentValue.substring(start, end)
|
|
1562
|
-
};
|
|
1563
|
-
},
|
|
1564
|
-
destroy() {
|
|
1565
|
-
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
1566
|
-
cleanupFunctions.length = 0;
|
|
1567
|
-
baseComponent.destroy();
|
|
1568
|
-
}
|
|
1569
|
-
});
|
|
1570
|
-
injectStyles();
|
|
1571
|
-
createDOM();
|
|
1572
|
-
setupEventListeners();
|
|
1573
|
-
updateHighlighting();
|
|
1574
|
-
api.mount();
|
|
1575
|
-
setTimeout(() => {
|
|
1576
|
-
if (!options.readOnly) {
|
|
1577
|
-
textArea.focus();
|
|
1578
|
-
}
|
|
1579
|
-
}, 100);
|
|
1580
|
-
return api;
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
// src/components/ResultDisplay.ts
|
|
1584
|
-
var RESULT_DISPLAY_CSS = `
|
|
1585
|
-
/* ResultDisplay Component Styles */
|
|
1586
|
-
.explorer-result-display {
|
|
1587
|
-
background: var(--explorer-bg-primary);
|
|
1588
|
-
overflow: hidden;
|
|
1589
|
-
display: flex;
|
|
1590
|
-
flex-direction: column;
|
|
1591
|
-
height: 100%;
|
|
1592
|
-
box-sizing: border-box;
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
.explorer-result-display * {
|
|
1596
|
-
box-sizing: border-box;
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
.explorer-result-display__content {
|
|
1600
|
-
flex: 1;
|
|
1601
|
-
overflow-y: auto;
|
|
1602
|
-
padding: 4px;
|
|
1603
|
-
font-family: 'Fira Code', 'JetBrains Mono', Menlo, Monaco, 'Courier New', monospace;
|
|
1604
|
-
font-size: 13px;
|
|
1605
|
-
line-height: 1.4;
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
.explorer-result-display__empty {
|
|
1609
|
-
display: flex;
|
|
1610
|
-
align-items: center;
|
|
1611
|
-
justify-content: center;
|
|
1612
|
-
height: 100px;
|
|
1613
|
-
color: var(--explorer-text-muted);
|
|
1614
|
-
font-style: italic;
|
|
1615
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
.explorer-result-item__content {
|
|
1619
|
-
color: var(--explorer-text-primary);
|
|
1620
|
-
word-break: break-word;
|
|
1621
|
-
padding: 0;
|
|
1622
|
-
margin: 0;
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
.explorer-result-item__content pre {
|
|
1626
|
-
margin: 0;
|
|
1627
|
-
padding: 0;
|
|
1628
|
-
background: transparent;
|
|
1629
|
-
border: none;
|
|
1630
|
-
font-family: inherit;
|
|
1631
|
-
font-size: inherit;
|
|
1632
|
-
white-space: pre-wrap;
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
.explorer-result-item__content--json {
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
.explorer-result-item__content--error {
|
|
1639
|
-
color: var(--explorer-danger);
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
.explorer-result-item__content--collapsed {
|
|
1643
|
-
max-height: 100px;
|
|
1644
|
-
overflow: hidden;
|
|
1645
|
-
position: relative;
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
.explorer-result-item__content--collapsed::after {
|
|
1649
|
-
content: '';
|
|
1650
|
-
position: absolute;
|
|
1651
|
-
bottom: 0;
|
|
1652
|
-
left: 0;
|
|
1653
|
-
right: 0;
|
|
1654
|
-
height: 20px;
|
|
1655
|
-
background: linear-gradient(transparent, var(--explorer-bg-secondary));
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
.explorer-result-item__expand-btn {
|
|
1659
|
-
background: none;
|
|
1660
|
-
border: none;
|
|
1661
|
-
color: var(--explorer-primary);
|
|
1662
|
-
cursor: pointer;
|
|
1663
|
-
font-size: 11px;
|
|
1664
|
-
margin-top: 4px;
|
|
1665
|
-
text-decoration: underline;
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
/* Responsive design */
|
|
1669
|
-
@media (max-width: 768px) {
|
|
1670
|
-
.explorer-result-display__content {
|
|
1671
|
-
font-size: 12px;
|
|
1672
|
-
padding: 4px;
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
.explorer-result-item {
|
|
1676
|
-
padding: 4px;
|
|
1677
|
-
margin-bottom: 8px;
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
`;
|
|
1681
|
-
function createResultDisplay(elementOrSelector, options = {}) {
|
|
1682
|
-
const baseComponent = createComponent(elementOrSelector, {
|
|
1683
|
-
autoMount: false,
|
|
1684
|
-
useShadowDOM: false
|
|
1685
|
-
// No shadow DOM - parent layout provides CSS isolation
|
|
1686
|
-
});
|
|
1687
|
-
const element = baseComponent.getElement();
|
|
1688
|
-
const shadowRoot = baseComponent.getShadowRoot();
|
|
1689
|
-
const contentRoot = baseComponent.getContentRoot();
|
|
1690
|
-
element.classList.add("explorer-result-display");
|
|
1691
|
-
contentRoot.classList.add("explorer-result-display");
|
|
1692
|
-
let results = [];
|
|
1693
|
-
let contentContainer;
|
|
1694
|
-
const cleanupFunctions = [];
|
|
1695
|
-
function injectStyles() {
|
|
1696
|
-
}
|
|
1697
|
-
function createDOM() {
|
|
1698
|
-
contentRoot.innerHTML = "";
|
|
1699
|
-
contentContainer = createElement("div", {
|
|
1700
|
-
className: "explorer-result-display__content"
|
|
1701
|
-
});
|
|
1702
|
-
if (options.height) {
|
|
1703
|
-
contentContainer.style.height = options.height;
|
|
1704
|
-
} else {
|
|
1705
|
-
contentContainer.style.minHeight = "150px";
|
|
1706
|
-
contentContainer.style.maxHeight = "400px";
|
|
1707
|
-
}
|
|
1708
|
-
contentRoot.appendChild(contentContainer);
|
|
1709
|
-
updateDisplay();
|
|
1710
|
-
}
|
|
1711
|
-
function formatContent(content) {
|
|
1712
|
-
if (content === null) {
|
|
1713
|
-
return { html: '<span class="syntax-null">null</span>', isJSON: false };
|
|
1714
|
-
}
|
|
1715
|
-
if (content === void 0) {
|
|
1716
|
-
return {
|
|
1717
|
-
html: '<span class="syntax-null">undefined</span>',
|
|
1718
|
-
isJSON: false
|
|
1719
|
-
};
|
|
1720
|
-
}
|
|
1721
|
-
if (typeof content === "string") {
|
|
1722
|
-
return { html: `"${content}"`, isJSON: false };
|
|
1723
|
-
}
|
|
1724
|
-
if (typeof content === "number") {
|
|
1725
|
-
return {
|
|
1726
|
-
html: `<span class="syntax-number">${content}</span>`,
|
|
1727
|
-
isJSON: false
|
|
1728
|
-
};
|
|
1729
|
-
}
|
|
1730
|
-
if (typeof content === "boolean") {
|
|
1731
|
-
return {
|
|
1732
|
-
html: `<span class="syntax-boolean">${content}</span>`,
|
|
1733
|
-
isJSON: false
|
|
1734
|
-
};
|
|
1735
|
-
}
|
|
1736
|
-
if (typeof content === "function") {
|
|
1737
|
-
return { html: "[Function]", isJSON: false };
|
|
1738
|
-
}
|
|
1739
|
-
if (content instanceof Error) {
|
|
1740
|
-
return { html: `${content.name}: ${content.message}`, isJSON: false };
|
|
1741
|
-
}
|
|
1742
|
-
try {
|
|
1743
|
-
const json = JSON.stringify(content, null, 2);
|
|
1744
|
-
const highlighted = highlightSyntax(json, "json");
|
|
1745
|
-
return { html: highlighted, isJSON: true };
|
|
1746
|
-
} catch (e) {
|
|
1747
|
-
return { html: String(content), isJSON: false };
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
function formatTimestamp(timestamp) {
|
|
1751
|
-
const date = new Date(timestamp);
|
|
1752
|
-
return date.toLocaleTimeString();
|
|
1753
|
-
}
|
|
1754
|
-
function createResultItem(result, index) {
|
|
1755
|
-
const { html, isJSON } = formatContent(result.content);
|
|
1756
|
-
const content = createElement("div", {
|
|
1757
|
-
className: `explorer-result-item__content ${isJSON ? "explorer-result-item__content--json" : ""} ${result.type === "error" ? "explorer-result-item__content--error" : ""}`
|
|
1758
|
-
});
|
|
1759
|
-
if (isJSON) {
|
|
1760
|
-
content.innerHTML = `<pre>${html}</pre>`;
|
|
1761
|
-
} else {
|
|
1762
|
-
content.innerHTML = html;
|
|
1763
|
-
}
|
|
1764
|
-
if (options.collapsible && content.scrollHeight > 120) {
|
|
1765
|
-
content.classList.add("explorer-result-item__content--collapsed");
|
|
1766
|
-
const expandBtn = createElement("button", {
|
|
1767
|
-
className: "explorer-result-item__expand-btn",
|
|
1768
|
-
textContent: "Show more"
|
|
1769
|
-
});
|
|
1770
|
-
const onExpand = () => {
|
|
1771
|
-
content.classList.remove("explorer-result-item__content--collapsed");
|
|
1772
|
-
expandBtn.remove();
|
|
1773
|
-
};
|
|
1774
|
-
cleanupFunctions.push(addEventListener(expandBtn, "click", onExpand));
|
|
1775
|
-
content.appendChild(expandBtn);
|
|
1776
|
-
}
|
|
1777
|
-
return content;
|
|
1778
|
-
}
|
|
1779
|
-
function updateDisplay() {
|
|
1780
|
-
contentContainer.innerHTML = "";
|
|
1781
|
-
if (results.length === 0) {
|
|
1782
|
-
const empty = createElement("div", {
|
|
1783
|
-
className: "explorer-result-display__empty",
|
|
1784
|
-
textContent: "No results yet"
|
|
1785
|
-
});
|
|
1786
|
-
contentContainer.appendChild(empty);
|
|
1787
|
-
return;
|
|
1788
|
-
}
|
|
1789
|
-
results.forEach((result, index) => {
|
|
1790
|
-
const item = createResultItem(result, index);
|
|
1791
|
-
contentContainer.appendChild(item);
|
|
1792
|
-
if (index < results.length - 1) {
|
|
1793
|
-
const spacer = createElement("div", {
|
|
1794
|
-
style: "margin-bottom: 12px;"
|
|
1795
|
-
});
|
|
1796
|
-
contentContainer.appendChild(spacer);
|
|
1797
|
-
}
|
|
1798
|
-
});
|
|
1799
|
-
if (options.autoScroll !== false) {
|
|
1800
|
-
contentContainer.scrollTop = contentContainer.scrollHeight;
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
function setupEventListeners() {
|
|
1804
|
-
}
|
|
1805
|
-
const api = __spreadProps(__spreadValues({}, baseComponent), {
|
|
1806
|
-
addResult(result) {
|
|
1807
|
-
const newResult = __spreadProps(__spreadValues({}, result), {
|
|
1808
|
-
timestamp: result.timestamp || Date.now()
|
|
1809
|
-
});
|
|
1810
|
-
results.push(newResult);
|
|
1811
|
-
if (options.maxResults && results.length > options.maxResults) {
|
|
1812
|
-
results = results.slice(-options.maxResults);
|
|
1813
|
-
}
|
|
1814
|
-
updateDisplay();
|
|
1815
|
-
},
|
|
1816
|
-
addValue(value, label) {
|
|
1817
|
-
this.addResult({ type: "value", content: value, label });
|
|
1818
|
-
},
|
|
1819
|
-
addError(error, label) {
|
|
1820
|
-
const content = error instanceof Error ? error : new Error(error);
|
|
1821
|
-
this.addResult({ type: "error", content, label });
|
|
1822
|
-
},
|
|
1823
|
-
addLog(message, label) {
|
|
1824
|
-
this.addResult({ type: "log", content: message, label });
|
|
1825
|
-
},
|
|
1826
|
-
addWarning(message, label) {
|
|
1827
|
-
this.addResult({ type: "warning", content: message, label });
|
|
1828
|
-
},
|
|
1829
|
-
addInfo(message, label) {
|
|
1830
|
-
this.addResult({ type: "info", content: message, label });
|
|
1831
|
-
},
|
|
1832
|
-
clear() {
|
|
1833
|
-
results = [];
|
|
1834
|
-
updateDisplay();
|
|
1835
|
-
},
|
|
1836
|
-
getResults() {
|
|
1837
|
-
return [...results];
|
|
1838
|
-
},
|
|
1839
|
-
setResults(newResults) {
|
|
1840
|
-
results = [...newResults];
|
|
1841
|
-
updateDisplay();
|
|
1842
|
-
},
|
|
1843
|
-
destroy() {
|
|
1844
|
-
cleanupFunctions.forEach((cleanup) => cleanup());
|
|
1845
|
-
cleanupFunctions.length = 0;
|
|
1846
|
-
baseComponent.destroy();
|
|
1847
|
-
}
|
|
1848
|
-
});
|
|
1849
|
-
injectStyles();
|
|
1850
|
-
createDOM();
|
|
1851
|
-
setupEventListeners();
|
|
1852
|
-
api.mount();
|
|
1853
|
-
return api;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
// src/core/MultiColumnLayout.ts
|
|
1857
|
-
var MULTI_COLUMN_CSS = `
|
|
1858
|
-
/* Multi-Column Layout Component Styles */
|
|
1859
|
-
.explorer-multi-column-layout {
|
|
1860
|
-
display: flex;
|
|
1861
|
-
flex-direction: column;
|
|
1862
|
-
height: 100%;
|
|
1863
|
-
background: transparent;
|
|
1864
|
-
overflow: hidden;
|
|
1865
|
-
}
|
|
1866
|
-
|
|
1867
|
-
.explorer-multi-column-layout__content {
|
|
1868
|
-
display: grid;
|
|
1869
|
-
flex: 1;
|
|
1870
|
-
gap: var(--column-gap, 16px);
|
|
1871
|
-
height: 100%;
|
|
1872
|
-
min-height: 0;
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
.explorer-multi-column-layout__content--horizontal {
|
|
1876
|
-
grid-auto-flow: column;
|
|
1877
|
-
grid-auto-columns: 1fr;
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
.explorer-multi-column-layout__content--vertical {
|
|
1881
|
-
grid-auto-flow: row;
|
|
1882
|
-
grid-auto-rows: 1fr;
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
/* Responsive design */
|
|
1886
|
-
@media (max-width: 1024px) {
|
|
1887
|
-
.explorer-multi-column-layout__content--horizontal {
|
|
1888
|
-
grid-auto-flow: row;
|
|
1889
|
-
grid-auto-rows: minmax(300px, 1fr);
|
|
1890
|
-
gap: 12px;
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
@media (max-width: 768px) {
|
|
1895
|
-
.explorer-multi-column-layout__content {
|
|
1896
|
-
gap: 8px;
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
`;
|
|
1900
|
-
function createMultiColumnLayout(elementOrSelector, options) {
|
|
1901
|
-
const { columns, layout = "horizontal", gap = "16px" } = options;
|
|
1902
|
-
if (!columns || columns.length === 0) {
|
|
1903
|
-
throw new Error(
|
|
1904
|
-
"MultiColumnLayout requires at least one column configuration"
|
|
1905
|
-
);
|
|
1906
|
-
}
|
|
1907
|
-
const baseComponent = createComponent(elementOrSelector, {
|
|
1908
|
-
autoMount: false,
|
|
1909
|
-
useShadowDOM: true
|
|
1910
|
-
// Always use shadow DOM for optimal CSS isolation
|
|
1911
|
-
});
|
|
1912
|
-
const element = baseComponent.getElement();
|
|
1913
|
-
const shadowRoot = baseComponent.getShadowRoot();
|
|
1914
|
-
const contentRoot = baseComponent.getContentRoot();
|
|
1915
|
-
element.classList.add("explorer-multi-column-layout");
|
|
1916
|
-
contentRoot.classList.add("explorer-multi-column-layout");
|
|
1917
|
-
let currentLayout = layout;
|
|
1918
|
-
const columnContainers = [];
|
|
1919
|
-
const cleanupFunctions = [];
|
|
1920
|
-
function injectStyles() {
|
|
1921
|
-
if (!shadowRoot) {
|
|
1922
|
-
throw new Error(
|
|
1923
|
-
"MultiColumnLayout requires shadow DOM for CSS isolation"
|
|
1924
|
-
);
|
|
1925
|
-
}
|
|
1926
|
-
baseComponent.injectCSS(CSS_THEME_VARIABLES, "explorer-foundation-theme");
|
|
1927
|
-
baseComponent.injectCSS(
|
|
1928
|
-
CSS_SYNTAX_HIGHLIGHTING,
|
|
1929
|
-
"syntax-highlighting-styles"
|
|
1930
|
-
);
|
|
1931
|
-
baseComponent.injectCSS(CODE_EDITOR_CSS, "code-editor-styles");
|
|
1932
|
-
baseComponent.injectCSS(RESULT_DISPLAY_CSS, "result-display-styles");
|
|
1933
|
-
baseComponent.injectCSS(
|
|
1934
|
-
MULTI_COLUMN_CSS,
|
|
1935
|
-
"explorer-multi-column-layout-styles"
|
|
1936
|
-
);
|
|
1937
|
-
}
|
|
1938
|
-
function createColumns() {
|
|
1939
|
-
const contentElement2 = createElement("div", {
|
|
1940
|
-
className: `explorer-multi-column-layout__content explorer-multi-column-layout__content--${currentLayout}`
|
|
1941
|
-
});
|
|
1942
|
-
contentElement2.style.setProperty("--column-gap", gap);
|
|
1943
|
-
columns.forEach((columnConfig, index) => {
|
|
1944
|
-
const container = createUnifiedContainer({
|
|
1945
|
-
className: `explorer-multi-column-layout__column ${columnConfig.className || ""}`,
|
|
1946
|
-
contentClassName: columnConfig.contentClassName,
|
|
1947
|
-
showHeader: true,
|
|
1948
|
-
headerOptions: {
|
|
1949
|
-
title: columnConfig.title
|
|
1950
|
-
},
|
|
1951
|
-
shadowRoot
|
|
1952
|
-
});
|
|
1953
|
-
columnContainers.push(container);
|
|
1954
|
-
contentElement2.appendChild(container.getElement());
|
|
1955
|
-
});
|
|
1956
|
-
return contentElement2;
|
|
1957
|
-
}
|
|
1958
|
-
function initialize() {
|
|
1959
|
-
injectStyles();
|
|
1960
|
-
const contentElement2 = createColumns();
|
|
1961
|
-
contentRoot.appendChild(contentElement2);
|
|
1962
|
-
return contentElement2;
|
|
1963
|
-
}
|
|
1964
|
-
const contentElement = initialize();
|
|
1965
|
-
const api = __spreadProps(__spreadValues({}, baseComponent), {
|
|
1966
|
-
getColumnElement(index) {
|
|
1967
|
-
if (index < 0 || index >= columnContainers.length) {
|
|
1968
|
-
return null;
|
|
1969
|
-
}
|
|
1970
|
-
return columnContainers[index].getElement();
|
|
1971
|
-
},
|
|
1972
|
-
getColumnContentElement(index) {
|
|
1973
|
-
if (index < 0 || index >= columnContainers.length) {
|
|
1974
|
-
return null;
|
|
1975
|
-
}
|
|
1976
|
-
return columnContainers[index].getContentElement();
|
|
1977
|
-
},
|
|
1978
|
-
setLayout(newLayout) {
|
|
1979
|
-
if (newLayout === currentLayout) return;
|
|
1980
|
-
currentLayout = newLayout;
|
|
1981
|
-
const content = contentRoot.querySelector(
|
|
1982
|
-
".explorer-multi-column-layout__content"
|
|
1983
|
-
);
|
|
1984
|
-
if (content) {
|
|
1985
|
-
content.className = `explorer-multi-column-layout__content explorer-multi-column-layout__content--${currentLayout}`;
|
|
1986
|
-
}
|
|
1987
|
-
},
|
|
1988
|
-
getLayout() {
|
|
1989
|
-
return currentLayout;
|
|
1990
|
-
},
|
|
1991
|
-
destroy() {
|
|
1992
|
-
columnContainers.forEach((container) => {
|
|
1993
|
-
var _a;
|
|
1994
|
-
(_a = container.destroy) == null ? void 0 : _a.call(container);
|
|
1995
|
-
});
|
|
1996
|
-
cleanupFunctions.forEach((fn) => fn());
|
|
1997
|
-
baseComponent.destroy();
|
|
1998
|
-
}
|
|
1999
|
-
});
|
|
2000
|
-
return {
|
|
2001
|
-
api,
|
|
2002
|
-
contentElement,
|
|
2003
|
-
columnContainers,
|
|
2004
|
-
cleanup: cleanupFunctions
|
|
2005
|
-
};
|
|
2006
|
-
}
|
|
2007
|
-
|
|
2008
|
-
// src/utils/evaluation.ts
|
|
2009
|
-
function evaluateJavaScript(_0) {
|
|
2010
|
-
return __async(this, arguments, function* (code, context = {}, options = {}) {
|
|
2011
|
-
const startTime = performance.now();
|
|
2012
|
-
try {
|
|
2013
|
-
const contextKeys = Object.keys(context);
|
|
2014
|
-
const contextValues = Object.values(context);
|
|
2015
|
-
const processedCode = options.autoReturn ? `return ${code}` : code;
|
|
2016
|
-
const wrappedCode = `
|
|
2017
|
-
"use strict";
|
|
2018
|
-
return (async () => {
|
|
2019
|
-
${processedCode}
|
|
2020
|
-
})();
|
|
2021
|
-
`;
|
|
2022
|
-
const evalFunction = new Function(...contextKeys, wrappedCode);
|
|
2023
|
-
const result = yield evalFunction(...contextValues);
|
|
2024
|
-
const executionTime = performance.now() - startTime;
|
|
2025
|
-
return {
|
|
2026
|
-
success: true,
|
|
2027
|
-
result,
|
|
2028
|
-
executionTime
|
|
2029
|
-
};
|
|
2030
|
-
} catch (error) {
|
|
2031
|
-
const executionTime = performance.now() - startTime;
|
|
2032
|
-
return {
|
|
2033
|
-
success: false,
|
|
2034
|
-
error: error instanceof Error ? error.message : String(error),
|
|
2035
|
-
executionTime
|
|
2036
|
-
};
|
|
2037
|
-
}
|
|
2038
|
-
});
|
|
2039
|
-
}
|
|
2040
|
-
function formatEvaluationResult(result) {
|
|
2041
|
-
if (result === void 0) {
|
|
2042
|
-
return "undefined";
|
|
2043
|
-
}
|
|
2044
|
-
if (result === null) {
|
|
2045
|
-
return "null";
|
|
2046
|
-
}
|
|
2047
|
-
if (typeof result === "string") {
|
|
2048
|
-
return result;
|
|
2049
|
-
}
|
|
2050
|
-
if (typeof result === "number" || typeof result === "boolean") {
|
|
2051
|
-
return String(result);
|
|
2052
|
-
}
|
|
2053
|
-
if (typeof result === "function") {
|
|
2054
|
-
return "[Function]";
|
|
2055
|
-
}
|
|
2056
|
-
if (typeof result === "object") {
|
|
2057
|
-
try {
|
|
2058
|
-
return JSON.stringify(result, null, 2);
|
|
2059
|
-
} catch (e) {
|
|
2060
|
-
return "[Object]";
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
return String(result);
|
|
2064
|
-
}
|
|
2065
|
-
function createSafeContext(additionalContext = {}) {
|
|
2066
|
-
const safeContext = __spreadValues({
|
|
2067
|
-
// Safe built-ins
|
|
2068
|
-
console: {
|
|
2069
|
-
log: (...args) => console.log(...args),
|
|
2070
|
-
error: (...args) => console.error(...args),
|
|
2071
|
-
warn: (...args) => console.warn(...args)
|
|
2072
|
-
},
|
|
2073
|
-
JSON,
|
|
2074
|
-
Math,
|
|
2075
|
-
Date,
|
|
2076
|
-
Array,
|
|
2077
|
-
Object,
|
|
2078
|
-
String,
|
|
2079
|
-
Number,
|
|
2080
|
-
Boolean
|
|
2081
|
-
}, additionalContext);
|
|
2082
|
-
return safeContext;
|
|
2083
|
-
}
|
|
2084
|
-
|
|
2085
|
-
// src/components/LiveCodeJS.ts
|
|
2086
|
-
init_css_theme_system();
|
|
2087
|
-
function createLiveCodeJS(elementOrSelector, options = {}) {
|
|
2088
|
-
let currentCode = options.initCode || "";
|
|
2089
|
-
let currentContext = createSafeContext(options.context);
|
|
2090
|
-
let codeEditor;
|
|
2091
|
-
let resultDisplay;
|
|
2092
|
-
const {
|
|
2093
|
-
api: baseApi,
|
|
2094
|
-
contentElement,
|
|
2095
|
-
columnContainers,
|
|
2096
|
-
cleanup
|
|
2097
|
-
} = createMultiColumnLayout(elementOrSelector, {
|
|
2098
|
-
columns: [
|
|
2099
|
-
{
|
|
2100
|
-
title: "JavaScript Code",
|
|
2101
|
-
className: "explorer-unified-container--code-editor"
|
|
2102
|
-
},
|
|
2103
|
-
{
|
|
2104
|
-
title: "Results",
|
|
2105
|
-
className: "explorer-unified-container--result-display"
|
|
2106
|
-
}
|
|
2107
|
-
],
|
|
2108
|
-
layout: options.layout || "horizontal",
|
|
2109
|
-
height: options.height,
|
|
2110
|
-
showHeader: options.showHeader,
|
|
2111
|
-
title: options.title || "JavaScript Evaluator"
|
|
2112
|
-
});
|
|
2113
|
-
const handleThemeToggle = () => {
|
|
2114
|
-
const element = baseApi.getElement();
|
|
2115
|
-
if (element) {
|
|
2116
|
-
const newTheme = toggleElementTheme(element);
|
|
2117
|
-
const themeButtons = element.querySelectorAll(
|
|
2118
|
-
".explorer-unified-header__btn--theme"
|
|
2119
|
-
);
|
|
2120
|
-
themeButtons.forEach((btn) => {
|
|
2121
|
-
btn.textContent = newTheme === "dark" ? "\u2600\uFE0F" : "\u{1F319}";
|
|
2122
|
-
});
|
|
2123
|
-
}
|
|
2124
|
-
};
|
|
2125
|
-
setTimeout(() => {
|
|
2126
|
-
const firstColumn = baseApi.getColumnElement(0);
|
|
2127
|
-
if (firstColumn) {
|
|
2128
|
-
const container = firstColumn.querySelector(
|
|
2129
|
-
".explorer-unified-container"
|
|
2130
|
-
);
|
|
2131
|
-
if (container) {
|
|
2132
|
-
const headerElement = container.querySelector(
|
|
2133
|
-
".explorer-unified-header"
|
|
2134
|
-
);
|
|
2135
|
-
if (headerElement) {
|
|
2136
|
-
const actionsElement = headerElement.querySelector(
|
|
2137
|
-
".explorer-unified-header__actions"
|
|
2138
|
-
);
|
|
2139
|
-
if (actionsElement) {
|
|
2140
|
-
const themeBtn = document.createElement("button");
|
|
2141
|
-
themeBtn.className = "explorer-unified-header__btn explorer-unified-header__btn--theme";
|
|
2142
|
-
themeBtn.textContent = getElementTheme(baseApi.getElement()) === "dark" ? "\u2600\uFE0F" : "\u{1F319}";
|
|
2143
|
-
themeBtn.title = "Toggle theme";
|
|
2144
|
-
themeBtn.addEventListener("click", handleThemeToggle);
|
|
2145
|
-
actionsElement.appendChild(themeBtn);
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
}, 10);
|
|
2151
|
-
const debouncedEvaluate = debounce(() => {
|
|
2152
|
-
if (options.autoEvaluate !== false) {
|
|
2153
|
-
evaluateCode();
|
|
2154
|
-
}
|
|
2155
|
-
}, options.evaluationDelay || 500);
|
|
2156
|
-
function createPanels() {
|
|
2157
|
-
const editorContentElement = baseApi.getColumnContentElement(0);
|
|
2158
|
-
const resultContentElement = baseApi.getColumnContentElement(1);
|
|
2159
|
-
if (!editorContentElement || !resultContentElement) {
|
|
2160
|
-
throw new Error(
|
|
2161
|
-
"Failed to get column content elements from multi-column layout"
|
|
2162
|
-
);
|
|
2163
|
-
}
|
|
2164
|
-
codeEditor = createCodeEditor(editorContentElement, {
|
|
2165
|
-
language: "javascript",
|
|
2166
|
-
value: currentCode,
|
|
2167
|
-
height: "100%",
|
|
2168
|
-
onChange: (value) => {
|
|
2169
|
-
currentCode = value;
|
|
2170
|
-
debouncedEvaluate();
|
|
2171
|
-
}
|
|
2172
|
-
});
|
|
2173
|
-
resultDisplay = createResultDisplay(resultContentElement, {
|
|
2174
|
-
height: "100%",
|
|
2175
|
-
maxResults: 10
|
|
2176
|
-
});
|
|
2177
|
-
if (currentCode && options.autoEvaluate !== false) {
|
|
2178
|
-
evaluateCode();
|
|
2179
|
-
}
|
|
2180
|
-
}
|
|
2181
|
-
function evaluateCode() {
|
|
2182
|
-
return __async(this, null, function* () {
|
|
2183
|
-
if (!currentCode.trim()) {
|
|
2184
|
-
resultDisplay.clear();
|
|
2185
|
-
return;
|
|
2186
|
-
}
|
|
2187
|
-
try {
|
|
2188
|
-
resultDisplay.clear();
|
|
2189
|
-
const result = yield evaluateJavaScript(currentCode, currentContext, {
|
|
2190
|
-
autoReturn: options.autoReturn
|
|
2191
|
-
});
|
|
2192
|
-
if (result.success) {
|
|
2193
|
-
resultDisplay.addValue(result.result);
|
|
2194
|
-
} else {
|
|
2195
|
-
resultDisplay.addError(result.error || "Unknown error");
|
|
2196
|
-
}
|
|
2197
|
-
} catch (error) {
|
|
2198
|
-
resultDisplay.clear();
|
|
2199
|
-
resultDisplay.addError(String(error));
|
|
2200
|
-
}
|
|
2201
|
-
});
|
|
2202
|
-
}
|
|
2203
|
-
const api = __spreadProps(__spreadValues({}, baseApi), {
|
|
2204
|
-
getCode() {
|
|
2205
|
-
return currentCode;
|
|
2206
|
-
},
|
|
2207
|
-
setCode(code) {
|
|
2208
|
-
currentCode = code;
|
|
2209
|
-
codeEditor.setValue(code);
|
|
2210
|
-
if (options.autoEvaluate !== false) {
|
|
2211
|
-
debouncedEvaluate();
|
|
2212
|
-
}
|
|
2213
|
-
},
|
|
2214
|
-
setContext(context) {
|
|
2215
|
-
currentContext = createSafeContext(context);
|
|
2216
|
-
if (options.autoEvaluate !== false) {
|
|
2217
|
-
debouncedEvaluate();
|
|
2218
|
-
}
|
|
2219
|
-
},
|
|
2220
|
-
evaluate() {
|
|
2221
|
-
evaluateCode();
|
|
2222
|
-
},
|
|
2223
|
-
clear() {
|
|
2224
|
-
currentCode = "";
|
|
2225
|
-
codeEditor.setValue("");
|
|
2226
|
-
resultDisplay.clear();
|
|
2227
|
-
},
|
|
2228
|
-
getResults() {
|
|
2229
|
-
return resultDisplay.getResults();
|
|
2230
|
-
},
|
|
2231
|
-
setLayout(layout) {
|
|
2232
|
-
baseApi.setLayout(layout);
|
|
2233
|
-
},
|
|
2234
|
-
getLayout() {
|
|
2235
|
-
return baseApi.getLayout();
|
|
2236
|
-
},
|
|
2237
|
-
destroy() {
|
|
2238
|
-
cleanup.forEach((fn) => fn());
|
|
2239
|
-
codeEditor == null ? void 0 : codeEditor.destroy();
|
|
2240
|
-
resultDisplay == null ? void 0 : resultDisplay.destroy();
|
|
2241
|
-
baseApi.destroy();
|
|
2242
|
-
}
|
|
2243
|
-
});
|
|
2244
|
-
createPanels();
|
|
2245
|
-
api.mount();
|
|
2246
|
-
return api;
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
// src/components/Destination.ts
|
|
2250
|
-
var import_collector = require("@walkeros/collector");
|
|
2251
|
-
init_css_theme_system();
|
|
2252
|
-
function createDestination(elementOrSelector, options = {}) {
|
|
2253
|
-
let eventData = options.initialEvent || "";
|
|
2254
|
-
let mappingData = options.initialMapping || "";
|
|
2255
|
-
let eventEditor;
|
|
2256
|
-
let mappingEditor;
|
|
2257
|
-
let resultDisplay;
|
|
2258
|
-
let elbFunction = null;
|
|
2259
|
-
let collector = null;
|
|
2260
|
-
let capturedResults = [];
|
|
2261
|
-
const { api: baseApi, cleanup } = createMultiColumnLayout(elementOrSelector, {
|
|
2262
|
-
columns: [
|
|
2263
|
-
{
|
|
2264
|
-
title: "Event",
|
|
2265
|
-
className: "explorer-unified-container--code-editor"
|
|
2266
|
-
},
|
|
2267
|
-
{
|
|
2268
|
-
title: "Mapping",
|
|
2269
|
-
className: "explorer-unified-container--code-editor"
|
|
2270
|
-
},
|
|
2271
|
-
{
|
|
2272
|
-
title: "Result",
|
|
2273
|
-
className: "explorer-unified-container--result-display"
|
|
2274
|
-
}
|
|
2275
|
-
],
|
|
2276
|
-
layout: "horizontal",
|
|
2277
|
-
height: options.height,
|
|
2278
|
-
showHeader: options.showHeader,
|
|
2279
|
-
title: options.title || "Destination Mapping"
|
|
2280
|
-
});
|
|
2281
|
-
const handleThemeToggle = () => {
|
|
2282
|
-
const element = baseApi.getElement();
|
|
2283
|
-
if (element) {
|
|
2284
|
-
const newTheme = toggleElementTheme(element);
|
|
2285
|
-
const themeButtons = element.querySelectorAll(
|
|
2286
|
-
".explorer-unified-header__btn--theme"
|
|
2287
|
-
);
|
|
2288
|
-
themeButtons.forEach((btn) => {
|
|
2289
|
-
btn.textContent = newTheme === "dark" ? "\u2600\uFE0F" : "\u{1F319}";
|
|
2290
|
-
});
|
|
2291
|
-
}
|
|
2292
|
-
};
|
|
2293
|
-
setTimeout(() => {
|
|
2294
|
-
const firstColumn = baseApi.getColumnElement(0);
|
|
2295
|
-
if (firstColumn) {
|
|
2296
|
-
const container = firstColumn.querySelector(
|
|
2297
|
-
".explorer-unified-container"
|
|
2298
|
-
);
|
|
2299
|
-
if (container) {
|
|
2300
|
-
const headerElement = container.querySelector(
|
|
2301
|
-
".explorer-unified-header"
|
|
2302
|
-
);
|
|
2303
|
-
if (headerElement) {
|
|
2304
|
-
const actionsElement = headerElement.querySelector(
|
|
2305
|
-
".explorer-unified-header__actions"
|
|
2306
|
-
);
|
|
2307
|
-
if (actionsElement) {
|
|
2308
|
-
const themeBtn = document.createElement("button");
|
|
2309
|
-
themeBtn.className = "explorer-unified-header__btn explorer-unified-header__btn--theme";
|
|
2310
|
-
themeBtn.textContent = getElementTheme(baseApi.getElement()) === "dark" ? "\u2600\uFE0F" : "\u{1F319}";
|
|
2311
|
-
themeBtn.title = "Toggle theme";
|
|
2312
|
-
themeBtn.addEventListener("click", handleThemeToggle);
|
|
2313
|
-
actionsElement.appendChild(themeBtn);
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
}, 10);
|
|
2319
|
-
const debouncedUpdate = debounce(() => {
|
|
2320
|
-
updateResults();
|
|
2321
|
-
}, options.updateDelay || 300);
|
|
2322
|
-
function createDemoDestination() {
|
|
2323
|
-
return {
|
|
2324
|
-
type: "demo",
|
|
2325
|
-
config: {},
|
|
2326
|
-
push(event, context) {
|
|
2327
|
-
const { data, mapping } = context;
|
|
2328
|
-
capturedResults = [];
|
|
2329
|
-
if (data !== void 0) {
|
|
2330
|
-
capturedResults.push({
|
|
2331
|
-
type: "mapped_result",
|
|
2332
|
-
mappingRule: (mapping == null ? void 0 : mapping.name) || "default",
|
|
2333
|
-
data,
|
|
2334
|
-
timestamp: Date.now()
|
|
2335
|
-
});
|
|
2336
|
-
} else {
|
|
2337
|
-
capturedResults.push({
|
|
2338
|
-
type: "no_mapping",
|
|
2339
|
-
event,
|
|
2340
|
-
message: "No mapping rule matched or no data produced",
|
|
2341
|
-
timestamp: Date.now()
|
|
2342
|
-
});
|
|
2343
|
-
}
|
|
2344
|
-
updateResultDisplay();
|
|
2345
|
-
}
|
|
2346
|
-
};
|
|
2347
|
-
}
|
|
2348
|
-
function initializeCollector() {
|
|
2349
|
-
return __async(this, null, function* () {
|
|
2350
|
-
try {
|
|
2351
|
-
const destination = options.destination || createDemoDestination();
|
|
2352
|
-
const { elb, collector: newCollector } = yield (0, import_collector.createCollector)({
|
|
2353
|
-
destinations: {
|
|
2354
|
-
demo: destination
|
|
2355
|
-
},
|
|
2356
|
-
run: true
|
|
2357
|
-
});
|
|
2358
|
-
return { elb, collector: newCollector };
|
|
2359
|
-
} catch (error) {
|
|
2360
|
-
capturedResults = [
|
|
2361
|
-
{
|
|
2362
|
-
type: "error",
|
|
2363
|
-
message: `Failed to initialize collector: ${String(error)}`,
|
|
2364
|
-
timestamp: Date.now()
|
|
2365
|
-
}
|
|
2366
|
-
];
|
|
2367
|
-
updateResultDisplay();
|
|
2368
|
-
return null;
|
|
2369
|
-
}
|
|
2370
|
-
});
|
|
2371
|
-
}
|
|
2372
|
-
function createComponents() {
|
|
2373
|
-
const eventContentElement = baseApi.getColumnContentElement(0);
|
|
2374
|
-
const mappingContentElement = baseApi.getColumnContentElement(1);
|
|
2375
|
-
const resultContentElement = baseApi.getColumnContentElement(2);
|
|
2376
|
-
if (!eventContentElement || !mappingContentElement || !resultContentElement) {
|
|
2377
|
-
throw new Error(
|
|
2378
|
-
"Failed to get column content elements from multi-column layout"
|
|
2379
|
-
);
|
|
2380
|
-
}
|
|
2381
|
-
eventEditor = createCodeEditor(eventContentElement, {
|
|
2382
|
-
language: "json",
|
|
2383
|
-
value: eventData,
|
|
2384
|
-
height: "100%",
|
|
2385
|
-
onChange: (value) => {
|
|
2386
|
-
eventData = value;
|
|
2387
|
-
debouncedUpdate();
|
|
2388
|
-
}
|
|
2389
|
-
});
|
|
2390
|
-
mappingEditor = createCodeEditor(mappingContentElement, {
|
|
2391
|
-
language: "json",
|
|
2392
|
-
value: mappingData,
|
|
2393
|
-
height: "100%",
|
|
2394
|
-
onChange: (value) => {
|
|
2395
|
-
mappingData = value;
|
|
2396
|
-
debouncedUpdate();
|
|
2397
|
-
}
|
|
2398
|
-
});
|
|
2399
|
-
resultDisplay = createResultDisplay(resultContentElement, {
|
|
2400
|
-
height: "100%",
|
|
2401
|
-
maxResults: 1
|
|
2402
|
-
});
|
|
2403
|
-
updateResultDisplay();
|
|
2404
|
-
initializeCollector().then((result) => {
|
|
2405
|
-
if (result) {
|
|
2406
|
-
elbFunction = result.elb;
|
|
2407
|
-
collector = result.collector;
|
|
2408
|
-
setTimeout(() => {
|
|
2409
|
-
updateResults();
|
|
2410
|
-
}, 200);
|
|
2411
|
-
}
|
|
2412
|
-
});
|
|
2413
|
-
}
|
|
2414
|
-
function updateResults() {
|
|
2415
|
-
return __async(this, null, function* () {
|
|
2416
|
-
try {
|
|
2417
|
-
capturedResults = [];
|
|
2418
|
-
if (!elbFunction) {
|
|
2419
|
-
resultDisplay.clear();
|
|
2420
|
-
resultDisplay.addError("Collector not initialized");
|
|
2421
|
-
return;
|
|
2422
|
-
}
|
|
2423
|
-
let parsedEvent;
|
|
2424
|
-
try {
|
|
2425
|
-
parsedEvent = eventData.trim() ? JSON.parse(eventData) : null;
|
|
2426
|
-
} catch (error) {
|
|
2427
|
-
resultDisplay.clear();
|
|
2428
|
-
resultDisplay.addError(`Invalid JSON in Event: ${String(error)}`);
|
|
2429
|
-
return;
|
|
2430
|
-
}
|
|
2431
|
-
if (parsedEvent) {
|
|
2432
|
-
updateDestinationMapping();
|
|
2433
|
-
yield elbFunction(parsedEvent);
|
|
2434
|
-
}
|
|
2435
|
-
} catch (error) {
|
|
2436
|
-
resultDisplay.clear();
|
|
2437
|
-
resultDisplay.addError(`Processing error: ${String(error)}`);
|
|
2438
|
-
}
|
|
2439
|
-
});
|
|
2440
|
-
}
|
|
2441
|
-
function updateDestinationMapping() {
|
|
2442
|
-
if (!collector) return;
|
|
2443
|
-
try {
|
|
2444
|
-
const demoDestination = collector.destinations.demo;
|
|
2445
|
-
if (demoDestination && mappingData.trim()) {
|
|
2446
|
-
const mapping = JSON.parse(mappingData);
|
|
2447
|
-
demoDestination.config.mapping = mapping;
|
|
2448
|
-
}
|
|
2449
|
-
} catch (error) {
|
|
2450
|
-
capturedResults.push({
|
|
2451
|
-
type: "error",
|
|
2452
|
-
message: `Failed to update mapping: ${String(error)}`,
|
|
2453
|
-
timestamp: Date.now()
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
function updateResultDisplay() {
|
|
2458
|
-
resultDisplay.clear();
|
|
2459
|
-
if (capturedResults.length === 0) {
|
|
2460
|
-
resultDisplay.addInfo(
|
|
2461
|
-
"Ready - modify the event or mapping and see the destination processing results"
|
|
2462
|
-
);
|
|
2463
|
-
return;
|
|
2464
|
-
}
|
|
2465
|
-
capturedResults.forEach((result) => {
|
|
2466
|
-
if (result.type === "mapped_result") {
|
|
2467
|
-
resultDisplay.addValue(
|
|
2468
|
-
result.data,
|
|
2469
|
-
`Destination receives (${result.mappingRule})`
|
|
2470
|
-
);
|
|
2471
|
-
} else if (result.type === "no_mapping") {
|
|
2472
|
-
resultDisplay.addInfo(result.message || "No mapping applied");
|
|
2473
|
-
} else {
|
|
2474
|
-
resultDisplay.addValue(result);
|
|
2475
|
-
}
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
|
-
const api = __spreadProps(__spreadValues({}, baseApi), {
|
|
2479
|
-
getEventData() {
|
|
2480
|
-
return eventData;
|
|
2481
|
-
},
|
|
2482
|
-
setEventData(data) {
|
|
2483
|
-
eventData = data;
|
|
2484
|
-
eventEditor == null ? void 0 : eventEditor.setValue(data);
|
|
2485
|
-
debouncedUpdate();
|
|
2486
|
-
},
|
|
2487
|
-
getMappingData() {
|
|
2488
|
-
return mappingData;
|
|
2489
|
-
},
|
|
2490
|
-
setMappingData(data) {
|
|
2491
|
-
mappingData = data;
|
|
2492
|
-
mappingEditor == null ? void 0 : mappingEditor.setValue(data);
|
|
2493
|
-
debouncedUpdate();
|
|
2494
|
-
},
|
|
2495
|
-
getResults() {
|
|
2496
|
-
return capturedResults || [];
|
|
2497
|
-
},
|
|
2498
|
-
refresh() {
|
|
2499
|
-
updateResults();
|
|
2500
|
-
},
|
|
2501
|
-
clear() {
|
|
2502
|
-
eventData = "{}";
|
|
2503
|
-
mappingData = "{}";
|
|
2504
|
-
eventEditor == null ? void 0 : eventEditor.setValue("{}");
|
|
2505
|
-
mappingEditor == null ? void 0 : mappingEditor.setValue("{}");
|
|
2506
|
-
capturedResults = [];
|
|
2507
|
-
resultDisplay == null ? void 0 : resultDisplay.clear();
|
|
2508
|
-
},
|
|
2509
|
-
destroy() {
|
|
2510
|
-
cleanup.forEach((fn) => fn());
|
|
2511
|
-
eventEditor == null ? void 0 : eventEditor.destroy();
|
|
2512
|
-
mappingEditor == null ? void 0 : mappingEditor.destroy();
|
|
2513
|
-
resultDisplay == null ? void 0 : resultDisplay.destroy();
|
|
2514
|
-
elbFunction = null;
|
|
2515
|
-
collector = null;
|
|
2516
|
-
capturedResults = [];
|
|
2517
|
-
baseApi.destroy();
|
|
2518
|
-
}
|
|
2519
|
-
});
|
|
2520
|
-
createComponents();
|
|
2521
|
-
api.mount();
|
|
2522
|
-
return api;
|
|
2523
|
-
}
|
|
2524
|
-
|
|
2525
|
-
// src/index.ts
|
|
2526
|
-
var version = "1.0.0";
|
|
2527
|
-
var name = "@walkeros/explorer";
|
|
2528
|
-
//# sourceMappingURL=index.cjs.map
|