@walkeros/explorer 0.0.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 -2997
- 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/explorer.js
DELETED
|
@@ -1,2997 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var WalkerExplorer = (() => {
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __esm = (fn, res) => function __init() {
|
|
25
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
26
|
-
};
|
|
27
|
-
var __export = (target, all) => {
|
|
28
|
-
for (var name2 in all)
|
|
29
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
30
|
-
};
|
|
31
|
-
var __copyProps = (to, from, except, desc) => {
|
|
32
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
33
|
-
for (let key of __getOwnPropNames(from))
|
|
34
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
35
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
36
|
-
}
|
|
37
|
-
return to;
|
|
38
|
-
};
|
|
39
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
|
-
var __async = (__this, __arguments, generator) => {
|
|
41
|
-
return new Promise((resolve, reject) => {
|
|
42
|
-
var fulfilled = (value) => {
|
|
43
|
-
try {
|
|
44
|
-
step(generator.next(value));
|
|
45
|
-
} catch (e3) {
|
|
46
|
-
reject(e3);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var rejected = (value) => {
|
|
50
|
-
try {
|
|
51
|
-
step(generator.throw(value));
|
|
52
|
-
} catch (e3) {
|
|
53
|
-
reject(e3);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
57
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// src/core/css-theme-system.ts
|
|
62
|
-
function setElementTheme(element, theme) {
|
|
63
|
-
const htmlTheme = document.documentElement.getAttribute("data-theme");
|
|
64
|
-
if (htmlTheme && (htmlTheme === "light" || htmlTheme === "dark")) {
|
|
65
|
-
if (element instanceof HTMLElement) {
|
|
66
|
-
element.classList.add("explorer-component");
|
|
67
|
-
}
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (element instanceof HTMLElement) {
|
|
71
|
-
element.setAttribute("data-theme", theme);
|
|
72
|
-
} else if (element instanceof ShadowRoot) {
|
|
73
|
-
if (element.host instanceof HTMLElement) {
|
|
74
|
-
element.host.setAttribute("data-theme", theme);
|
|
75
|
-
}
|
|
76
|
-
} else if (element instanceof DocumentFragment) {
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function getElementTheme(element) {
|
|
80
|
-
const htmlTheme = document.documentElement.getAttribute("data-theme");
|
|
81
|
-
if (htmlTheme === "light" || htmlTheme === "dark") {
|
|
82
|
-
return htmlTheme;
|
|
83
|
-
}
|
|
84
|
-
const elementTheme = element.getAttribute("data-theme");
|
|
85
|
-
if (elementTheme) {
|
|
86
|
-
return elementTheme;
|
|
87
|
-
}
|
|
88
|
-
return "light";
|
|
89
|
-
}
|
|
90
|
-
function detectTheme() {
|
|
91
|
-
const htmlTheme = document.documentElement.getAttribute("data-theme");
|
|
92
|
-
if (htmlTheme === "light" || htmlTheme === "dark") {
|
|
93
|
-
return htmlTheme;
|
|
94
|
-
}
|
|
95
|
-
if (document.documentElement.classList.contains("dark")) {
|
|
96
|
-
return "dark";
|
|
97
|
-
}
|
|
98
|
-
if (typeof window !== "undefined" && window.matchMedia) {
|
|
99
|
-
const prefersDark = window.matchMedia(
|
|
100
|
-
"(prefers-color-scheme: dark)"
|
|
101
|
-
).matches;
|
|
102
|
-
if (prefersDark) {
|
|
103
|
-
return "dark";
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return "light";
|
|
107
|
-
}
|
|
108
|
-
function toggleElementTheme(element) {
|
|
109
|
-
const currentTheme = getElementTheme(element);
|
|
110
|
-
const newTheme = currentTheme === "light" ? "dark" : "light";
|
|
111
|
-
setElementTheme(element, newTheme);
|
|
112
|
-
return newTheme;
|
|
113
|
-
}
|
|
114
|
-
var CSS_THEME_VARIABLES, CSS_SYNTAX_HIGHLIGHTING;
|
|
115
|
-
var init_css_theme_system = __esm({
|
|
116
|
-
"src/core/css-theme-system.ts"() {
|
|
117
|
-
"use strict";
|
|
118
|
-
CSS_THEME_VARIABLES = `
|
|
119
|
-
:root,
|
|
120
|
-
[data-theme="light"],
|
|
121
|
-
html[data-theme="light"] .explorer-component,
|
|
122
|
-
html[data-theme="light"] [class*="explorer-"] {
|
|
123
|
-
/* Base colors - transparent by default for website integration */
|
|
124
|
-
--explorer-bg-primary: transparent;
|
|
125
|
-
--explorer-bg-primary-opaque: #ffffff;
|
|
126
|
-
--explorer-bg-secondary: rgba(248, 250, 252, 0.8);
|
|
127
|
-
--explorer-bg-tertiary: rgba(241, 245, 249, 0.9);
|
|
128
|
-
--explorer-bg-input: #fafafa;
|
|
129
|
-
|
|
130
|
-
/* Text colors */
|
|
131
|
-
--explorer-text-primary: #1f2937;
|
|
132
|
-
--explorer-text-secondary: #6b7280;
|
|
133
|
-
--explorer-text-muted: #9ca3af;
|
|
134
|
-
--explorer-text-inverse: #ffffff;
|
|
135
|
-
|
|
136
|
-
/* Border colors */
|
|
137
|
-
--explorer-border-primary: #d1d5db;
|
|
138
|
-
--explorer-border-secondary: #e5e7eb;
|
|
139
|
-
--explorer-border-focus: #3b82f6;
|
|
140
|
-
|
|
141
|
-
/* Action colors */
|
|
142
|
-
--explorer-primary: #3b82f6;
|
|
143
|
-
--explorer-primary-hover: #2563eb;
|
|
144
|
-
--explorer-primary-active: #1d4ed8;
|
|
145
|
-
|
|
146
|
-
--explorer-success: #10b981;
|
|
147
|
-
--explorer-success-hover: #059669;
|
|
148
|
-
--explorer-success-active: #047857;
|
|
149
|
-
|
|
150
|
-
--explorer-warning: #f59e0b;
|
|
151
|
-
--explorer-warning-hover: #d97706;
|
|
152
|
-
--explorer-warning-active: #b45309;
|
|
153
|
-
|
|
154
|
-
--explorer-danger: #ef4444;
|
|
155
|
-
--explorer-danger-hover: #dc2626;
|
|
156
|
-
--explorer-danger-active: #b91c1c;
|
|
157
|
-
|
|
158
|
-
/* Surface colors */
|
|
159
|
-
--explorer-surface-hover: #f1f5f9;
|
|
160
|
-
--explorer-surface-active: #e2e8f0;
|
|
161
|
-
--explorer-surface-selected: #dbeafe;
|
|
162
|
-
|
|
163
|
-
/* Shadow colors */
|
|
164
|
-
--explorer-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
165
|
-
--explorer-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
166
|
-
--explorer-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
167
|
-
|
|
168
|
-
/* Scrollbar colors */
|
|
169
|
-
--explorer-scrollbar-track: #f1f5f9;
|
|
170
|
-
--explorer-scrollbar-thumb: #cbd5e1;
|
|
171
|
-
--explorer-scrollbar-thumb-hover: #94a3b8;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
[data-theme="dark"],
|
|
175
|
-
html[data-theme="dark"] .explorer-component,
|
|
176
|
-
html[data-theme="dark"] [class*="explorer-"] {
|
|
177
|
-
/* Base colors - transparent by default for website integration */
|
|
178
|
-
--explorer-bg-primary: transparent;
|
|
179
|
-
--explorer-bg-primary-opaque: #1f2937;
|
|
180
|
-
--explorer-bg-secondary: rgba(55, 65, 81, 0.8);
|
|
181
|
-
--explorer-bg-tertiary: rgba(75, 85, 99, 0.9);
|
|
182
|
-
--explorer-bg-input: #111827;
|
|
183
|
-
|
|
184
|
-
/* Text colors */
|
|
185
|
-
--explorer-text-primary: #f3f4f6;
|
|
186
|
-
--explorer-text-secondary: #d1d5db;
|
|
187
|
-
--explorer-text-muted: #9ca3af;
|
|
188
|
-
--explorer-text-inverse: #1f2937;
|
|
189
|
-
|
|
190
|
-
/* Border colors */
|
|
191
|
-
--explorer-border-primary: #374151;
|
|
192
|
-
--explorer-border-secondary: #4b5563;
|
|
193
|
-
--explorer-border-focus: #3b82f6;
|
|
194
|
-
|
|
195
|
-
/* Action colors remain the same for consistency */
|
|
196
|
-
--explorer-primary: #3b82f6;
|
|
197
|
-
--explorer-primary-hover: #2563eb;
|
|
198
|
-
--explorer-primary-active: #1d4ed8;
|
|
199
|
-
|
|
200
|
-
--explorer-success: #10b981;
|
|
201
|
-
--explorer-success-hover: #059669;
|
|
202
|
-
--explorer-success-active: #047857;
|
|
203
|
-
|
|
204
|
-
--explorer-warning: #f59e0b;
|
|
205
|
-
--explorer-warning-hover: #d97706;
|
|
206
|
-
--explorer-warning-active: #b45309;
|
|
207
|
-
|
|
208
|
-
--explorer-danger: #ef4444;
|
|
209
|
-
--explorer-danger-hover: #dc2626;
|
|
210
|
-
--explorer-danger-active: #b91c1c;
|
|
211
|
-
|
|
212
|
-
/* Surface colors */
|
|
213
|
-
--explorer-surface-hover: #374151;
|
|
214
|
-
--explorer-surface-active: #4b5563;
|
|
215
|
-
--explorer-surface-selected: #1e3a8a;
|
|
216
|
-
|
|
217
|
-
/* Shadow colors */
|
|
218
|
-
--explorer-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
|
219
|
-
--explorer-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
220
|
-
--explorer-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
|
|
221
|
-
|
|
222
|
-
/* Scrollbar colors */
|
|
223
|
-
--explorer-scrollbar-track: #374151;
|
|
224
|
-
--explorer-scrollbar-thumb: #6b7280;
|
|
225
|
-
--explorer-scrollbar-thumb-hover: #9ca3af;
|
|
226
|
-
}
|
|
227
|
-
`;
|
|
228
|
-
CSS_SYNTAX_HIGHLIGHTING = `
|
|
229
|
-
/* Light mode - Palenight-inspired colors adapted for light backgrounds */
|
|
230
|
-
.explorer-component .syntax-keyword,
|
|
231
|
-
.explorer-shadow-container .syntax-keyword,
|
|
232
|
-
:host .syntax-keyword {
|
|
233
|
-
color: #ab47bc !important;
|
|
234
|
-
font-weight: 600 !important;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.explorer-component .syntax-string,
|
|
238
|
-
.explorer-shadow-container .syntax-string,
|
|
239
|
-
:host .syntax-string {
|
|
240
|
-
color: #689f38 !important;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.explorer-component .syntax-number,
|
|
244
|
-
.explorer-shadow-container .syntax-number,
|
|
245
|
-
:host .syntax-number {
|
|
246
|
-
color: #f57c00 !important;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.explorer-component .syntax-comment,
|
|
250
|
-
.explorer-shadow-container .syntax-comment,
|
|
251
|
-
:host .syntax-comment {
|
|
252
|
-
color: #757575 !important;
|
|
253
|
-
font-style: italic !important;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
.explorer-component .syntax-function,
|
|
257
|
-
.explorer-shadow-container .syntax-function,
|
|
258
|
-
:host .syntax-function {
|
|
259
|
-
color: #3f51b5 !important;
|
|
260
|
-
font-weight: 500 !important;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.explorer-component .syntax-tag,
|
|
264
|
-
.explorer-shadow-container .syntax-tag,
|
|
265
|
-
:host .syntax-tag {
|
|
266
|
-
color: #e91e63 !important;
|
|
267
|
-
font-weight: 600 !important;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.explorer-component .syntax-attribute,
|
|
271
|
-
.explorer-shadow-container .syntax-attribute,
|
|
272
|
-
:host .syntax-attribute {
|
|
273
|
-
color: #6f42c1 !important;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.explorer-component .syntax-value,
|
|
277
|
-
.explorer-shadow-container .syntax-value,
|
|
278
|
-
:host .syntax-value {
|
|
279
|
-
color: #032f62 !important;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
.explorer-component .syntax-operator,
|
|
283
|
-
.explorer-shadow-container .syntax-operator,
|
|
284
|
-
:host .syntax-operator {
|
|
285
|
-
color: #d73a49 !important;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
.explorer-component .syntax-type,
|
|
289
|
-
.explorer-shadow-container .syntax-type,
|
|
290
|
-
:host .syntax-type {
|
|
291
|
-
color: #005cc5 !important;
|
|
292
|
-
font-weight: 500 !important;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.explorer-component .syntax-property,
|
|
296
|
-
.explorer-shadow-container .syntax-property,
|
|
297
|
-
:host .syntax-property {
|
|
298
|
-
color: #6f42c1 !important;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/* JSON-specific styling for better readability */
|
|
302
|
-
.explorer-component[data-language="json"] .syntax-string,
|
|
303
|
-
.explorer-shadow-container[data-language="json"] .syntax-string,
|
|
304
|
-
:host([data-language="json"]) .syntax-string {
|
|
305
|
-
color: #22863a !important; /* GitHub green for JSON strings */
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.explorer-component[data-language="json"] .syntax-number,
|
|
309
|
-
.explorer-shadow-container[data-language="json"] .syntax-number,
|
|
310
|
-
:host([data-language="json"]) .syntax-number {
|
|
311
|
-
color: #005cc5 !important; /* GitHub blue for JSON numbers */
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.explorer-component[data-language="json"] .syntax-property,
|
|
315
|
-
.explorer-shadow-container[data-language="json"] .syntax-property,
|
|
316
|
-
:host([data-language="json"]) .syntax-property {
|
|
317
|
-
color: #032f62 !important; /* GitHub dark blue for JSON keys */
|
|
318
|
-
font-weight: 500 !important;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
.explorer-component[data-language="json"] .syntax-keyword,
|
|
322
|
-
.explorer-shadow-container[data-language="json"] .syntax-keyword,
|
|
323
|
-
:host([data-language="json"]) .syntax-keyword {
|
|
324
|
-
color: #d73a49 !important; /* GitHub red for true/false/null */
|
|
325
|
-
font-weight: 600 !important;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/* JSON-specific dark mode styling */
|
|
329
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-string,
|
|
330
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-string,
|
|
331
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-string {
|
|
332
|
-
color: #98d982 !important; /* Softer green for dark mode JSON strings */
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-number,
|
|
336
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-number,
|
|
337
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-number {
|
|
338
|
-
color: #79b8ff !important; /* Softer blue for dark mode JSON numbers */
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-property,
|
|
342
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-property,
|
|
343
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-property {
|
|
344
|
-
color: #b392f0 !important; /* Light purple for dark mode JSON keys */
|
|
345
|
-
font-weight: 500 !important;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
[data-theme='dark'] .explorer-component[data-language="json"] .syntax-keyword,
|
|
349
|
-
[data-theme='dark'] .explorer-shadow-container[data-language="json"] .syntax-keyword,
|
|
350
|
-
:host([data-theme='dark'][data-language="json"]) .syntax-keyword {
|
|
351
|
-
color: #f97583 !important; /* Soft red for dark mode true/false/null */
|
|
352
|
-
font-weight: 600 !important;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/* Special highlighting for elb attributes */
|
|
356
|
-
.explorer-component .syntax-elb-attribute,
|
|
357
|
-
.explorer-shadow-container .syntax-elb-attribute,
|
|
358
|
-
:host .syntax-elb-attribute {
|
|
359
|
-
color: #28a745 !important;
|
|
360
|
-
font-weight: 700 !important;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
.explorer-component .syntax-elb-value,
|
|
364
|
-
.explorer-shadow-container .syntax-elb-value,
|
|
365
|
-
:host .syntax-elb-value {
|
|
366
|
-
color: #28a745 !important;
|
|
367
|
-
font-weight: 500 !important;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/* Dark mode - Palenight theme with higher specificity */
|
|
371
|
-
[data-theme='dark'] .explorer-component .syntax-keyword,
|
|
372
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-keyword,
|
|
373
|
-
:host([data-theme='dark']) .syntax-keyword {
|
|
374
|
-
color: #c792ea !important;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
[data-theme='dark'] .explorer-component .syntax-string,
|
|
378
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-string,
|
|
379
|
-
:host([data-theme='dark']) .syntax-string {
|
|
380
|
-
color: #c3e88d !important;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
[data-theme='dark'] .explorer-component .syntax-number,
|
|
384
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-number,
|
|
385
|
-
:host([data-theme='dark']) .syntax-number {
|
|
386
|
-
color: #f78c6c !important;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
[data-theme='dark'] .explorer-component .syntax-comment,
|
|
390
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-comment,
|
|
391
|
-
:host([data-theme='dark']) .syntax-comment {
|
|
392
|
-
color: #676e95 !important;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
[data-theme='dark'] .explorer-component .syntax-function,
|
|
396
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-function,
|
|
397
|
-
:host([data-theme='dark']) .syntax-function {
|
|
398
|
-
color: #82aaff !important;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
[data-theme='dark'] .explorer-component .syntax-tag,
|
|
402
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-tag,
|
|
403
|
-
:host([data-theme='dark']) .syntax-tag {
|
|
404
|
-
color: #f07178 !important;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
[data-theme='dark'] .explorer-component .syntax-attribute,
|
|
408
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-attribute,
|
|
409
|
-
:host([data-theme='dark']) .syntax-attribute {
|
|
410
|
-
color: #ffcb6b !important;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
[data-theme='dark'] .explorer-component .syntax-value,
|
|
414
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-value,
|
|
415
|
-
:host([data-theme='dark']) .syntax-value {
|
|
416
|
-
color: #c3e88d !important;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
[data-theme='dark'] .explorer-component .syntax-operator,
|
|
420
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-operator,
|
|
421
|
-
:host([data-theme='dark']) .syntax-operator {
|
|
422
|
-
color: #89ddff !important;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
[data-theme='dark'] .explorer-component .syntax-type,
|
|
426
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-type,
|
|
427
|
-
:host([data-theme='dark']) .syntax-type {
|
|
428
|
-
color: #ffcb6b !important;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
[data-theme='dark'] .explorer-component .syntax-property,
|
|
432
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-property,
|
|
433
|
-
:host([data-theme='dark']) .syntax-property {
|
|
434
|
-
color: #82aaff !important;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
[data-theme='dark'] .explorer-component .syntax-elb-attribute,
|
|
438
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-elb-attribute,
|
|
439
|
-
:host([data-theme='dark']) .syntax-elb-attribute {
|
|
440
|
-
color: #c3e88d !important;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
[data-theme='dark'] .explorer-component .syntax-elb-value,
|
|
444
|
-
[data-theme='dark'] .explorer-shadow-container .syntax-elb-value,
|
|
445
|
-
:host([data-theme='dark']) .syntax-elb-value {
|
|
446
|
-
color: #c3e88d !important;
|
|
447
|
-
}
|
|
448
|
-
`;
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
// src/index.ts
|
|
453
|
-
var index_exports = {};
|
|
454
|
-
__export(index_exports, {
|
|
455
|
-
createCodeEditor: () => createCodeEditor,
|
|
456
|
-
createDestination: () => createDestination,
|
|
457
|
-
createLiveCodeJS: () => createLiveCodeJS,
|
|
458
|
-
createResultDisplay: () => createResultDisplay,
|
|
459
|
-
createSafeContext: () => createSafeContext,
|
|
460
|
-
evaluateJavaScript: () => evaluateJavaScript,
|
|
461
|
-
formatEvaluationResult: () => formatEvaluationResult,
|
|
462
|
-
name: () => name,
|
|
463
|
-
version: () => version
|
|
464
|
-
});
|
|
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 = (e3) => {
|
|
1497
|
-
if (e3.key === "Tab") {
|
|
1498
|
-
e3.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 (e3) {
|
|
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 (e3) {
|
|
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
|
-
// ../../packages/core/dist/index.mjs
|
|
2250
|
-
var e;
|
|
2251
|
-
var t;
|
|
2252
|
-
var n = Object.getOwnPropertyNames;
|
|
2253
|
-
var r = (e = { "package.json"(e3, t3) {
|
|
2254
|
-
t3.exports = { name: "@walkeros/core", description: "Core types and platform-agnostic utilities for walkerOS", version: "0.0.8", main: "./dist/index.js", module: "./dist/index.mjs", types: "./dist/index.d.ts", license: "MIT", files: ["dist/**"], scripts: { build: "tsup --silent", clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist", dev: "jest --watchAll --colors", lint: 'tsc && eslint "**/*.ts*"', test: "jest", update: "npx npm-check-updates -u && npm update" }, dependencies: {}, devDependencies: {}, repository: { url: "git+https://github.com/elbwalker/walkerOS.git", directory: "packages/core" }, author: "elbwalker <hello@elbwalker.com>", homepage: "https://github.com/elbwalker/walkerOS#readme", bugs: { url: "https://github.com/elbwalker/walkerOS/issues" }, keywords: ["walker", "walkerOS", "analytics", "tracking", "data collection", "measurement", "data privacy", "privacy friendly", "web analytics", "product analytics", "core", "types", "utils"], funding: [{ type: "GitHub Sponsors", url: "https://github.com/sponsors/elbwalker" }] };
|
|
2255
|
-
} }, function() {
|
|
2256
|
-
return t || (0, e[n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
|
|
2257
|
-
});
|
|
2258
|
-
var w = { merge: true, shallow: true, extend: true };
|
|
2259
|
-
function v(e3, t3 = {}, n3 = {}) {
|
|
2260
|
-
n3 = __spreadValues(__spreadValues({}, w), n3);
|
|
2261
|
-
const r2 = Object.entries(t3).reduce((t4, [r3, o2]) => {
|
|
2262
|
-
const i2 = e3[r3];
|
|
2263
|
-
return n3.merge && Array.isArray(i2) && Array.isArray(o2) ? t4[r3] = o2.reduce((e4, t5) => e4.includes(t5) ? e4 : [...e4, t5], [...i2]) : (n3.extend || r3 in e3) && (t4[r3] = o2), t4;
|
|
2264
|
-
}, {});
|
|
2265
|
-
return n3.shallow ? __spreadValues(__spreadValues({}, e3), r2) : (Object.assign(e3, r2), e3);
|
|
2266
|
-
}
|
|
2267
|
-
function k(e3) {
|
|
2268
|
-
return Array.isArray(e3);
|
|
2269
|
-
}
|
|
2270
|
-
function S(e3) {
|
|
2271
|
-
return "boolean" == typeof e3;
|
|
2272
|
-
}
|
|
2273
|
-
function O(e3) {
|
|
2274
|
-
return void 0 !== e3;
|
|
2275
|
-
}
|
|
2276
|
-
function $(e3) {
|
|
2277
|
-
return "function" == typeof e3;
|
|
2278
|
-
}
|
|
2279
|
-
function A(e3) {
|
|
2280
|
-
return "number" == typeof e3 && !Number.isNaN(e3);
|
|
2281
|
-
}
|
|
2282
|
-
function M(e3) {
|
|
2283
|
-
return "object" == typeof e3 && null !== e3 && !k(e3) && "[object Object]" === Object.prototype.toString.call(e3);
|
|
2284
|
-
}
|
|
2285
|
-
function P(e3, t3) {
|
|
2286
|
-
return typeof e3 == typeof t3;
|
|
2287
|
-
}
|
|
2288
|
-
function T(e3) {
|
|
2289
|
-
return "string" == typeof e3;
|
|
2290
|
-
}
|
|
2291
|
-
function C(e3, t3 = /* @__PURE__ */ new WeakMap()) {
|
|
2292
|
-
if ("object" != typeof e3 || null === e3) return e3;
|
|
2293
|
-
if (t3.has(e3)) return t3.get(e3);
|
|
2294
|
-
const n3 = Object.prototype.toString.call(e3);
|
|
2295
|
-
if ("[object Object]" === n3) {
|
|
2296
|
-
const n4 = {};
|
|
2297
|
-
t3.set(e3, n4);
|
|
2298
|
-
for (const r2 in e3) Object.prototype.hasOwnProperty.call(e3, r2) && (n4[r2] = C(e3[r2], t3));
|
|
2299
|
-
return n4;
|
|
2300
|
-
}
|
|
2301
|
-
if ("[object Array]" === n3) {
|
|
2302
|
-
const n4 = [];
|
|
2303
|
-
return t3.set(e3, n4), e3.forEach((e4) => {
|
|
2304
|
-
n4.push(C(e4, t3));
|
|
2305
|
-
}), n4;
|
|
2306
|
-
}
|
|
2307
|
-
if ("[object Date]" === n3) return new Date(e3.getTime());
|
|
2308
|
-
if ("[object RegExp]" === n3) {
|
|
2309
|
-
const t4 = e3;
|
|
2310
|
-
return new RegExp(t4.source, t4.flags);
|
|
2311
|
-
}
|
|
2312
|
-
return e3;
|
|
2313
|
-
}
|
|
2314
|
-
function I(e3, t3 = "", n3) {
|
|
2315
|
-
const r2 = t3.split(".");
|
|
2316
|
-
let o2 = e3;
|
|
2317
|
-
for (let e4 = 0; e4 < r2.length; e4++) {
|
|
2318
|
-
const t4 = r2[e4];
|
|
2319
|
-
if ("*" === t4 && k(o2)) {
|
|
2320
|
-
const t5 = r2.slice(e4 + 1).join("."), i2 = [];
|
|
2321
|
-
for (const e5 of o2) {
|
|
2322
|
-
const r3 = I(e5, t5, n3);
|
|
2323
|
-
i2.push(r3);
|
|
2324
|
-
}
|
|
2325
|
-
return i2;
|
|
2326
|
-
}
|
|
2327
|
-
if (o2 = o2 instanceof Object ? o2[t4] : void 0, !o2) break;
|
|
2328
|
-
}
|
|
2329
|
-
return O(o2) ? o2 : n3;
|
|
2330
|
-
}
|
|
2331
|
-
function N(e3, t3, n3) {
|
|
2332
|
-
const r2 = C(e3), o2 = t3.split(".");
|
|
2333
|
-
let i2 = r2;
|
|
2334
|
-
for (let e4 = 0; e4 < o2.length; e4++) {
|
|
2335
|
-
const t4 = o2[e4];
|
|
2336
|
-
e4 === o2.length - 1 ? i2[t4] = n3 : (t4 in i2 && "object" == typeof i2[t4] && null !== i2[t4] || (i2[t4] = {}), i2 = i2[t4]);
|
|
2337
|
-
}
|
|
2338
|
-
return r2;
|
|
2339
|
-
}
|
|
2340
|
-
function D(e3, t3 = {}, n3 = {}) {
|
|
2341
|
-
const r2 = __spreadValues(__spreadValues({}, t3), n3), o2 = {};
|
|
2342
|
-
let i2 = void 0 === e3;
|
|
2343
|
-
return Object.keys(r2).forEach((t4) => {
|
|
2344
|
-
r2[t4] && (o2[t4] = true, e3 && e3[t4] && (i2 = true));
|
|
2345
|
-
}), !!i2 && o2;
|
|
2346
|
-
}
|
|
2347
|
-
var { version: V } = r();
|
|
2348
|
-
function K(e3 = 6) {
|
|
2349
|
-
let t3 = "";
|
|
2350
|
-
for (let n3 = 36; t3.length < e3; ) t3 += (Math.random() * n3 | 0).toString(n3);
|
|
2351
|
-
return t3;
|
|
2352
|
-
}
|
|
2353
|
-
function U(e3, t3 = 1e3, n3 = false) {
|
|
2354
|
-
let r2, o2 = null, i2 = false;
|
|
2355
|
-
return (...s2) => new Promise((c) => {
|
|
2356
|
-
const a = n3 && !i2;
|
|
2357
|
-
o2 && clearTimeout(o2), o2 = setTimeout(() => {
|
|
2358
|
-
o2 = null, n3 && !i2 || (r2 = e3(...s2), c(r2));
|
|
2359
|
-
}, t3), a && (i2 = true, r2 = e3(...s2), c(r2));
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
|
-
function B(e3) {
|
|
2363
|
-
return S(e3) || T(e3) || A(e3) || !O(e3) || k(e3) && e3.every(B) || M(e3) && Object.values(e3).every(B);
|
|
2364
|
-
}
|
|
2365
|
-
function X(e3) {
|
|
2366
|
-
return B(e3) ? e3 : void 0;
|
|
2367
|
-
}
|
|
2368
|
-
function G(e3, t3, n3) {
|
|
2369
|
-
return function(...r2) {
|
|
2370
|
-
try {
|
|
2371
|
-
return e3(...r2);
|
|
2372
|
-
} catch (e4) {
|
|
2373
|
-
if (!t3) return;
|
|
2374
|
-
return t3(e4);
|
|
2375
|
-
} finally {
|
|
2376
|
-
n3 == null ? void 0 : n3();
|
|
2377
|
-
}
|
|
2378
|
-
};
|
|
2379
|
-
}
|
|
2380
|
-
function J(e3, t3, n3) {
|
|
2381
|
-
return function(...r2) {
|
|
2382
|
-
return __async(this, null, function* () {
|
|
2383
|
-
try {
|
|
2384
|
-
return yield e3(...r2);
|
|
2385
|
-
} catch (e4) {
|
|
2386
|
-
if (!t3) return;
|
|
2387
|
-
return yield t3(e4);
|
|
2388
|
-
} finally {
|
|
2389
|
-
yield n3 == null ? void 0 : n3();
|
|
2390
|
-
}
|
|
2391
|
-
});
|
|
2392
|
-
};
|
|
2393
|
-
}
|
|
2394
|
-
function Q(e3, t3) {
|
|
2395
|
-
return __async(this, null, function* () {
|
|
2396
|
-
var _a;
|
|
2397
|
-
const [n3, r2] = (e3.event || "").split(" ");
|
|
2398
|
-
if (!t3 || !n3 || !r2) return {};
|
|
2399
|
-
let o2, i2 = "", s2 = n3, c = r2;
|
|
2400
|
-
const a = (t4) => {
|
|
2401
|
-
if (t4) return (t4 = k(t4) ? t4 : [t4]).find((t5) => !t5.condition || t5.condition(e3));
|
|
2402
|
-
};
|
|
2403
|
-
t3[s2] || (s2 = "*");
|
|
2404
|
-
const u = t3[s2];
|
|
2405
|
-
return u && (u[c] || (c = "*"), o2 = a(u[c])), o2 || (s2 = "*", c = "*", o2 = a((_a = t3[s2]) == null ? void 0 : _a[c])), o2 && (i2 = `${s2} ${c}`), { eventMapping: o2, mappingKey: i2 };
|
|
2406
|
-
});
|
|
2407
|
-
}
|
|
2408
|
-
function Y(_0) {
|
|
2409
|
-
return __async(this, arguments, function* (e3, t3 = {}, n3 = {}) {
|
|
2410
|
-
var _a;
|
|
2411
|
-
if (!O(e3)) return;
|
|
2412
|
-
const r2 = M(e3) && e3.consent || n3.consent || ((_a = n3.collector) == null ? void 0 : _a.consent), o2 = k(t3) ? t3 : [t3];
|
|
2413
|
-
for (const t4 of o2) {
|
|
2414
|
-
const o3 = yield J(Z)(e3, t4, __spreadProps(__spreadValues({}, n3), { consent: r2 }));
|
|
2415
|
-
if (O(o3)) return o3;
|
|
2416
|
-
}
|
|
2417
|
-
});
|
|
2418
|
-
}
|
|
2419
|
-
function Z(_0, _1) {
|
|
2420
|
-
return __async(this, arguments, function* (e3, t3, n3 = {}) {
|
|
2421
|
-
const { collector: r2, consent: o2 } = n3;
|
|
2422
|
-
return (k(t3) ? t3 : [t3]).reduce((t4, i2) => __async(null, null, function* () {
|
|
2423
|
-
const s2 = yield t4;
|
|
2424
|
-
if (s2) return s2;
|
|
2425
|
-
const c = T(i2) ? { key: i2 } : i2;
|
|
2426
|
-
if (!Object.keys(c).length) return;
|
|
2427
|
-
const { condition: a, consent: u, fn: l, key: p, loop: d, map: g, set: f, validate: m, value: h } = c;
|
|
2428
|
-
if (a && !(yield J(a)(e3, i2, r2))) return;
|
|
2429
|
-
if (u && !D(u, o2)) return h;
|
|
2430
|
-
let y = O(h) ? h : e3;
|
|
2431
|
-
if (l && (y = yield J(l)(e3, i2, n3)), p && (y = I(e3, p, h)), d) {
|
|
2432
|
-
const [t5, r3] = d, o3 = "this" === t5 ? [e3] : yield Y(e3, t5, n3);
|
|
2433
|
-
k(o3) && (y = (yield Promise.all(o3.map((e4) => Y(e4, r3, n3)))).filter(O));
|
|
2434
|
-
} else g ? y = yield Object.entries(g).reduce((_02, _12) => __async(null, [_02, _12], function* (t5, [r3, o3]) {
|
|
2435
|
-
const i3 = yield t5, s3 = yield Y(e3, o3, n3);
|
|
2436
|
-
return O(s3) && (i3[r3] = s3), i3;
|
|
2437
|
-
}), Promise.resolve({})) : f && (y = yield Promise.all(f.map((t5) => Z(e3, t5, n3))));
|
|
2438
|
-
m && !(yield J(m)(y)) && (y = void 0);
|
|
2439
|
-
const b = X(y);
|
|
2440
|
-
return O(b) ? b : X(h);
|
|
2441
|
-
}), Promise.resolve(void 0));
|
|
2442
|
-
});
|
|
2443
|
-
}
|
|
2444
|
-
function ee(e3, t3 = false) {
|
|
2445
|
-
t3 && console.dir(e3, { depth: 4 });
|
|
2446
|
-
}
|
|
2447
|
-
function ce(e3, t3, n3) {
|
|
2448
|
-
return function(...r2) {
|
|
2449
|
-
let o2;
|
|
2450
|
-
const i2 = "post" + t3, s2 = n3["pre" + t3], c = n3[i2];
|
|
2451
|
-
return o2 = s2 ? s2({ fn: e3 }, ...r2) : e3(...r2), c && (o2 = c({ fn: e3, result: o2 }, ...r2)), o2;
|
|
2452
|
-
};
|
|
2453
|
-
}
|
|
2454
|
-
function he(e3 = "unknown", { dryRun: t3 = false, mockReturn: n3, onCall: r2 } = {}) {
|
|
2455
|
-
return function(o2, i2) {
|
|
2456
|
-
return "function" != typeof i2 ? i2 : (...s2) => (r2 && r2({ name: o2, type: e3 }, s2), t3 ? n3 : i2(...s2));
|
|
2457
|
-
};
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
// ../../packages/collector/dist/index.mjs
|
|
2461
|
-
var e2;
|
|
2462
|
-
var t2;
|
|
2463
|
-
var n2 = Object.getOwnPropertyNames;
|
|
2464
|
-
var o = (e2 = { "package.json"(e3, t3) {
|
|
2465
|
-
t3.exports = { name: "@walkeros/collector", description: "Unified platform-agnostic collector for walkerOS", version: "0.0.8", main: "./dist/index.js", module: "./dist/index.mjs", types: "./dist/index.d.ts", license: "MIT", files: ["dist/**"], scripts: { build: "tsup --silent", clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist", dev: "jest --watchAll --colors", lint: 'tsc && eslint "**/*.ts*"', test: "jest", update: "npx npm-check-updates -u && npm update" }, dependencies: { "@walkeros/core": "0.0.8" }, devDependencies: {}, repository: { url: "git+https://github.com/elbwalker/walkerOS.git", directory: "packages/collector" }, author: "elbwalker <hello@elbwalker.com>", homepage: "https://github.com/elbwalker/walkerOS#readme", bugs: { url: "https://github.com/elbwalker/walkerOS/issues" }, keywords: ["walker", "walkerOS", "analytics", "tracking", "data collection", "measurement", "data privacy", "privacy friendly", "collector", "event processing"], funding: [{ type: "GitHub Sponsors", url: "https://github.com/sponsors/elbwalker" }] };
|
|
2466
|
-
} }, function() {
|
|
2467
|
-
return t2 || (0, e2[n2(e2)[0]])((t2 = { exports: {} }).exports, t2), t2.exports;
|
|
2468
|
-
});
|
|
2469
|
-
var s = { Action: "action", Config: "config", Consent: "consent", Context: "context", Custom: "custom", Destination: "destination", Elb: "elb", Globals: "globals", Hook: "hook", Init: "init", Link: "link", On: "on", Prefix: "data-elb", Ready: "ready", Run: "run", Session: "session", User: "user", Walker: "walker" };
|
|
2470
|
-
var i = { Commands: s, Utils: { Storage: { Cookie: "cookie", Local: "local", Session: "session" } } };
|
|
2471
|
-
function S2(e3, t3, n3) {
|
|
2472
|
-
const o2 = e3.on, s2 = o2[t3] || [], i2 = k(n3) ? n3 : [n3];
|
|
2473
|
-
i2.forEach((e4) => {
|
|
2474
|
-
s2.push(e4);
|
|
2475
|
-
}), o2[t3] = s2, D2(e3, t3, i2);
|
|
2476
|
-
}
|
|
2477
|
-
function D2(e3, t3, n3, o2) {
|
|
2478
|
-
let s2 = n3 || [];
|
|
2479
|
-
if (n3 || (s2 = e3.on[t3] || [], Object.values(e3.destinations).forEach((e4) => {
|
|
2480
|
-
var _a;
|
|
2481
|
-
const n4 = (_a = e4.config.on) == null ? void 0 : _a[t3];
|
|
2482
|
-
n4 && (s2 = s2.concat(n4));
|
|
2483
|
-
})), s2.length) switch (t3) {
|
|
2484
|
-
case i.Commands.Consent:
|
|
2485
|
-
!function(e4, t4, n4) {
|
|
2486
|
-
const o3 = n4 || e4.consent;
|
|
2487
|
-
t4.forEach((t5) => {
|
|
2488
|
-
Object.keys(o3).filter((e5) => e5 in t5).forEach((n5) => {
|
|
2489
|
-
G(t5[n5])(e4, o3);
|
|
2490
|
-
});
|
|
2491
|
-
});
|
|
2492
|
-
}(e3, s2, o2);
|
|
2493
|
-
break;
|
|
2494
|
-
case i.Commands.Ready:
|
|
2495
|
-
case i.Commands.Run:
|
|
2496
|
-
!function(e4, t4) {
|
|
2497
|
-
e4.allowed && t4.forEach((t5) => {
|
|
2498
|
-
G(t5)(e4);
|
|
2499
|
-
});
|
|
2500
|
-
}(e3, s2);
|
|
2501
|
-
break;
|
|
2502
|
-
case i.Commands.Session:
|
|
2503
|
-
!function(e4, t4) {
|
|
2504
|
-
if (!e4.session) return;
|
|
2505
|
-
t4.forEach((t5) => {
|
|
2506
|
-
G(t5)(e4, e4.session);
|
|
2507
|
-
});
|
|
2508
|
-
}(e3, s2);
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
function R(e3, t3, n3, o2) {
|
|
2512
|
-
return __async(this, null, function* () {
|
|
2513
|
-
let s2;
|
|
2514
|
-
switch (t3) {
|
|
2515
|
-
case i.Commands.Config:
|
|
2516
|
-
M(n3) && v(e3.config, n3, { shallow: false });
|
|
2517
|
-
break;
|
|
2518
|
-
case i.Commands.Consent:
|
|
2519
|
-
M(n3) && (s2 = yield M2(e3, n3));
|
|
2520
|
-
break;
|
|
2521
|
-
case i.Commands.Custom:
|
|
2522
|
-
M(n3) && (e3.custom = v(e3.custom, n3));
|
|
2523
|
-
break;
|
|
2524
|
-
case i.Commands.Destination:
|
|
2525
|
-
M(n3) && $(n3.push) && (s2 = yield L(e3, n3, o2));
|
|
2526
|
-
break;
|
|
2527
|
-
case i.Commands.Globals:
|
|
2528
|
-
M(n3) && (e3.globals = v(e3.globals, n3));
|
|
2529
|
-
break;
|
|
2530
|
-
case i.Commands.On:
|
|
2531
|
-
T(n3) && S2(e3, n3, o2);
|
|
2532
|
-
break;
|
|
2533
|
-
case i.Commands.Run:
|
|
2534
|
-
s2 = yield $2(e3, n3);
|
|
2535
|
-
break;
|
|
2536
|
-
case i.Commands.User:
|
|
2537
|
-
M(n3) && v(e3.user, n3, { shallow: false });
|
|
2538
|
-
}
|
|
2539
|
-
return s2 || { ok: true, successful: [], queued: [], failed: [] };
|
|
2540
|
-
});
|
|
2541
|
-
}
|
|
2542
|
-
function P2(e3, t3, n3 = {}) {
|
|
2543
|
-
const o2 = P(t3, "") ? __spreadValues({ event: t3 }, n3) : __spreadValues(__spreadValues({}, n3), t3 || {});
|
|
2544
|
-
if (!o2.event) throw new Error("Event name is required");
|
|
2545
|
-
const [i2, a] = o2.event.split(" ");
|
|
2546
|
-
if (!i2 || !a) throw new Error("Event name is invalid");
|
|
2547
|
-
if (i2 === s.Walker) return { command: a };
|
|
2548
|
-
++e3.count;
|
|
2549
|
-
const { timestamp: r2 = Date.now(), group: c = e3.group, count: u = e3.count } = o2, { event: l = `${i2} ${a}`, data: d = {}, context: g = {}, globals: f = e3.globals, custom: m = {}, user: p = e3.user, nested: b = [], consent: w2 = e3.consent, id: h = `${r2}-${c}-${u}`, trigger: k2 = "", entity: y = i2, action: v2 = a, timing: q = 0, version: C2 = { source: e3.version, tagging: e3.config.tagging || 0 }, source: O2 = { type: "collector", id: "", previous_id: "" } } = o2;
|
|
2550
|
-
return { event: { event: l, data: d, context: g, globals: f, custom: m, user: p, nested: b, consent: w2, id: h, trigger: k2, entity: y, action: v2, timestamp: r2, timing: q, group: c, count: u, version: C2, source: O2 } };
|
|
2551
|
-
}
|
|
2552
|
-
function $2(e3, t3) {
|
|
2553
|
-
return __async(this, null, function* () {
|
|
2554
|
-
e3.allowed = true, e3.count = 0, e3.group = K(), e3.timing = Date.now(), t3 && (t3.consent && (e3.consent = v(e3.consent, t3.consent)), t3.user && (e3.user = v(e3.user, t3.user)), t3.globals && (e3.globals = v(e3.config.globalsStatic || {}, t3.globals)), t3.custom && (e3.custom = v(e3.custom, t3.custom))), Object.values(e3.destinations).forEach((e4) => {
|
|
2555
|
-
e4.queue = [];
|
|
2556
|
-
}), e3.queue = [], e3.round++;
|
|
2557
|
-
const n3 = yield U2(e3);
|
|
2558
|
-
return D2(e3, "run"), n3;
|
|
2559
|
-
});
|
|
2560
|
-
}
|
|
2561
|
-
function I2(e3, t3, n3) {
|
|
2562
|
-
return ce((o2, s2, i2) => __async(null, null, function* () {
|
|
2563
|
-
return yield J(() => __async(null, null, function* () {
|
|
2564
|
-
if ("string" == typeof o2 && o2.startsWith("walker ")) {
|
|
2565
|
-
const n4 = o2.replace("walker ", "");
|
|
2566
|
-
return yield t3(e3, n4, s2, i2);
|
|
2567
|
-
}
|
|
2568
|
-
{
|
|
2569
|
-
const a = n3("string" == typeof o2 ? { event: o2 } : o2), { event: r2, command: c } = P2(e3, a.event, a);
|
|
2570
|
-
return c ? yield t3(e3, c, s2, i2) : yield U2(e3, r2);
|
|
2571
|
-
}
|
|
2572
|
-
}), () => B2({ ok: false }))();
|
|
2573
|
-
}), "Push", e3.hooks);
|
|
2574
|
-
}
|
|
2575
|
-
function L(e3, t3, n3) {
|
|
2576
|
-
return __async(this, null, function* () {
|
|
2577
|
-
const o2 = n3 || t3.config || { init: false }, s2 = __spreadProps(__spreadValues({}, t3), { config: o2 });
|
|
2578
|
-
let i2 = o2.id;
|
|
2579
|
-
if (!i2) do {
|
|
2580
|
-
i2 = K(4);
|
|
2581
|
-
} while (e3.destinations[i2]);
|
|
2582
|
-
return e3.destinations[i2] = s2, false !== o2.queue && (s2.queue = [...e3.queue]), U2(e3, void 0, { [i2]: s2 });
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
function U2(e3, t3, n3) {
|
|
2586
|
-
return __async(this, null, function* () {
|
|
2587
|
-
const { allowed: o2, consent: s2, globals: i2, user: a } = e3;
|
|
2588
|
-
if (!o2) return B2({ ok: false });
|
|
2589
|
-
t3 && e3.queue.push(t3), n3 || (n3 = e3.destinations);
|
|
2590
|
-
const u = yield Promise.all(Object.entries(n3 || {}).map((_0) => __async(null, [_0], function* ([n4, o3]) {
|
|
2591
|
-
let u2 = (o3.queue || []).map((e4) => __spreadProps(__spreadValues({}, e4), { consent: s2 }));
|
|
2592
|
-
if (o3.queue = [], t3) {
|
|
2593
|
-
let n5 = C(t3);
|
|
2594
|
-
yield Promise.all(Object.entries(o3.config.policy || []).map((_02) => __async(null, [_02], function* ([o4, s3]) {
|
|
2595
|
-
const i3 = yield Y(t3, s3, { collector: e3 });
|
|
2596
|
-
n5 = N(n5, o4, i3);
|
|
2597
|
-
}))), u2.push(n5);
|
|
2598
|
-
}
|
|
2599
|
-
if (!u2.length) return { id: n4, destination: o3, skipped: true };
|
|
2600
|
-
const l2 = [], d2 = u2.filter((e4) => {
|
|
2601
|
-
const t4 = D(o3.config.consent, s2, e4.consent);
|
|
2602
|
-
return !t4 || (e4.consent = t4, l2.push(e4), false);
|
|
2603
|
-
});
|
|
2604
|
-
if (o3.queue.concat(d2), !l2.length) return { id: n4, destination: o3, queue: u2 };
|
|
2605
|
-
if (!(yield J(_)(e3, o3))) return { id: n4, destination: o3, queue: u2 };
|
|
2606
|
-
let f2 = false;
|
|
2607
|
-
return o3.dlq || (o3.dlq = []), yield Promise.all(l2.map((t4) => __async(null, null, function* () {
|
|
2608
|
-
return t4.globals = v(i2, t4.globals), t4.user = v(a, t4.user), yield J(A2, (n5) => (e3.config.onError && e3.config.onError(n5, e3), f2 = true, o3.dlq.push([t4, n5]), false))(e3, o3, t4), t4;
|
|
2609
|
-
}))), { id: n4, destination: o3, error: f2 };
|
|
2610
|
-
}))), l = [], d = [], f = [];
|
|
2611
|
-
for (const e4 of u) {
|
|
2612
|
-
if (e4.skipped) continue;
|
|
2613
|
-
const t4 = e4.destination, n4 = { id: e4.id, destination: t4 };
|
|
2614
|
-
e4.error ? f.push(n4) : e4.queue && e4.queue.length ? (t4.queue = (t4.queue || []).concat(e4.queue), d.push(n4)) : l.push(n4);
|
|
2615
|
-
}
|
|
2616
|
-
return B2({ ok: !f.length, event: t3, successful: l, queued: d, failed: f });
|
|
2617
|
-
});
|
|
2618
|
-
}
|
|
2619
|
-
function _(e3, t3) {
|
|
2620
|
-
return __async(this, null, function* () {
|
|
2621
|
-
if (t3.init && !t3.config.init) {
|
|
2622
|
-
const n3 = { collector: e3, config: t3.config, wrap: G2(t3, e3) }, o2 = yield ce(t3.init, "DestinationInit", e3.hooks)(n3);
|
|
2623
|
-
if (false === o2) return o2;
|
|
2624
|
-
t3.config = __spreadProps(__spreadValues({}, o2 || t3.config), { init: true });
|
|
2625
|
-
}
|
|
2626
|
-
return true;
|
|
2627
|
-
});
|
|
2628
|
-
}
|
|
2629
|
-
function A2(e3, t3, n3) {
|
|
2630
|
-
return __async(this, null, function* () {
|
|
2631
|
-
var _a;
|
|
2632
|
-
const { config: o2 } = t3, { eventMapping: s2, mappingKey: i2 } = yield Q(n3, o2.mapping);
|
|
2633
|
-
let a = o2.data && (yield Y(n3, o2.data, { collector: e3 }));
|
|
2634
|
-
if (s2) {
|
|
2635
|
-
if (s2.ignore) return false;
|
|
2636
|
-
if (s2.name && (n3.event = s2.name), s2.data) {
|
|
2637
|
-
const t4 = s2.data && (yield Y(n3, s2.data, { collector: e3 }));
|
|
2638
|
-
a = M(a) && M(t4) ? v(a, t4) : t4;
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
const c = { collector: e3, config: o2, data: a, mapping: s2, wrap: G2(t3, e3) };
|
|
2642
|
-
if ((s2 == null ? void 0 : s2.batch) && t3.pushBatch) {
|
|
2643
|
-
const r2 = s2.batched || { key: i2 || "", events: [], data: [] };
|
|
2644
|
-
r2.events.push(n3), O(a) && r2.data.push(a), s2.batchFn = s2.batchFn || U((e4, t4) => {
|
|
2645
|
-
const n4 = { collector: t4, config: o2, data: a, mapping: s2, wrap: G2(e4, t4) };
|
|
2646
|
-
ce(e4.pushBatch, "DestinationPushBatch", t4.hooks)(r2, n4), r2.events = [], r2.data = [];
|
|
2647
|
-
}, s2.batch), s2.batched = r2, (_a = s2.batchFn) == null ? void 0 : _a.call(s2, t3, e3);
|
|
2648
|
-
} else yield ce(t3.push, "DestinationPush", e3.hooks)(n3, c);
|
|
2649
|
-
return true;
|
|
2650
|
-
});
|
|
2651
|
-
}
|
|
2652
|
-
function B2(e3) {
|
|
2653
|
-
var _a;
|
|
2654
|
-
return v({ ok: !((_a = e3 == null ? void 0 : e3.failed) == null ? void 0 : _a.length), successful: [], queued: [], failed: [] }, e3);
|
|
2655
|
-
}
|
|
2656
|
-
function F(e3) {
|
|
2657
|
-
return Object.entries(e3).reduce((e4, [t3, n3]) => (e4[t3] = __spreadProps(__spreadValues({}, n3), { config: M(n3.config) ? n3.config : {} }), e4), {});
|
|
2658
|
-
}
|
|
2659
|
-
function G2(e3, t3) {
|
|
2660
|
-
var _a;
|
|
2661
|
-
const n3 = e3.config.wrapper || {}, o2 = (_a = e3.config.dryRun) != null ? _a : t3 == null ? void 0 : t3.config.dryRun;
|
|
2662
|
-
return he(e3.type || "unknown", __spreadValues(__spreadValues({}, n3), O(o2) && { dryRun: o2 }));
|
|
2663
|
-
}
|
|
2664
|
-
function M2(e3, t3) {
|
|
2665
|
-
return __async(this, null, function* () {
|
|
2666
|
-
const { consent: n3 } = e3;
|
|
2667
|
-
let o2 = false;
|
|
2668
|
-
const s2 = {};
|
|
2669
|
-
return Object.entries(t3).forEach(([e4, t4]) => {
|
|
2670
|
-
const n4 = !!t4;
|
|
2671
|
-
s2[e4] = n4, o2 = o2 || n4;
|
|
2672
|
-
}), e3.consent = v(n3, s2), D2(e3, "consent", void 0, s2), o2 ? U2(e3) : B2({ ok: true });
|
|
2673
|
-
});
|
|
2674
|
-
}
|
|
2675
|
-
function T2(e3, t3, n3) {
|
|
2676
|
-
return __async(this, null, function* () {
|
|
2677
|
-
var _a, _b;
|
|
2678
|
-
const o2 = { disabled: (_a = n3.disabled) != null ? _a : false, settings: (_b = n3.settings) != null ? _b : {}, onError: n3.onError };
|
|
2679
|
-
if (o2.disabled) return {};
|
|
2680
|
-
const s2 = yield J(t3)(e3, o2);
|
|
2681
|
-
if (!s2 || !s2.source) return {};
|
|
2682
|
-
const i2 = o2.type || s2.source.type || "", a = n3.id || `${i2}_${K(5)}`;
|
|
2683
|
-
if (s2.source && s2.elb) {
|
|
2684
|
-
s2.source.elb = s2.elb;
|
|
2685
|
-
}
|
|
2686
|
-
return e3.sources || (e3.sources = {}), e3.sources[a] = { type: i2, settings: o2.settings, mapping: void 0, elb: s2.elb }, s2;
|
|
2687
|
-
});
|
|
2688
|
-
}
|
|
2689
|
-
function z(_0) {
|
|
2690
|
-
return __async(this, arguments, function* (e3, t3 = {}) {
|
|
2691
|
-
for (const [n3, o2] of Object.entries(t3)) {
|
|
2692
|
-
const t4 = { id: n3 }, s2 = yield T2(e3, o2, t4);
|
|
2693
|
-
if (s2.source) {
|
|
2694
|
-
if (s2.elb) {
|
|
2695
|
-
s2.source.elb = s2.elb;
|
|
2696
|
-
}
|
|
2697
|
-
e3.sources[n3] = { type: s2.source.type, settings: s2.source.config.settings, mapping: void 0, elb: s2.elb };
|
|
2698
|
-
}
|
|
2699
|
-
}
|
|
2700
|
-
});
|
|
2701
|
-
}
|
|
2702
|
-
function J2() {
|
|
2703
|
-
return __async(this, arguments, function* (e3 = {}) {
|
|
2704
|
-
const t3 = function(e4) {
|
|
2705
|
-
const { version: t4 } = o(), n4 = v({ dryRun: false, globalsStatic: {}, sessionStatic: {}, tagging: 0, verbose: false, onLog: s3, run: true, destinations: {}, consent: {}, user: {}, globals: {}, custom: {} }, e4, { merge: false, extend: false });
|
|
2706
|
-
function s3(e5, t5) {
|
|
2707
|
-
ee({ message: e5 }, t5 || n4.verbose);
|
|
2708
|
-
}
|
|
2709
|
-
n4.onLog = s3;
|
|
2710
|
-
const i3 = __spreadValues(__spreadValues({}, n4.globalsStatic), n4.globals), a2 = { allowed: false, config: n4, consent: n4.consent || {}, count: 0, custom: n4.custom || {}, destinations: F(n4.destinations || {}), globals: i3, group: "", hooks: {}, on: {}, queue: [], round: 0, session: void 0, timing: Date.now(), user: n4.user || {}, version: t4, sources: {}, push: void 0 };
|
|
2711
|
-
return a2.push = I2(a2, R, (e5) => __spreadValues({ timing: Math.round((Date.now() - a2.timing) / 10) / 100, source: { type: "collector", id: "", previous_id: "" } }, e5)), a2;
|
|
2712
|
-
}(e3), { consent: n3, user: s2, globals: i2, custom: a, sources: r2 } = e3;
|
|
2713
|
-
return n3 && (yield t3.push("walker consent", n3)), s2 && (yield t3.push("walker user", s2)), i2 && Object.assign(t3.globals, i2), a && Object.assign(t3.custom, a), r2 && (yield z(t3, r2)), t3.config.run && (yield t3.push("walker run")), { collector: t3, elb: t3.push };
|
|
2714
|
-
});
|
|
2715
|
-
}
|
|
2716
|
-
|
|
2717
|
-
// src/components/Destination.ts
|
|
2718
|
-
init_css_theme_system();
|
|
2719
|
-
function createDestination(elementOrSelector, options = {}) {
|
|
2720
|
-
let eventData = options.initialEvent || "";
|
|
2721
|
-
let mappingData = options.initialMapping || "";
|
|
2722
|
-
let eventEditor;
|
|
2723
|
-
let mappingEditor;
|
|
2724
|
-
let resultDisplay;
|
|
2725
|
-
let elbFunction = null;
|
|
2726
|
-
let collector = null;
|
|
2727
|
-
let capturedResults = [];
|
|
2728
|
-
const { api: baseApi, cleanup } = createMultiColumnLayout(elementOrSelector, {
|
|
2729
|
-
columns: [
|
|
2730
|
-
{
|
|
2731
|
-
title: "Event",
|
|
2732
|
-
className: "explorer-unified-container--code-editor"
|
|
2733
|
-
},
|
|
2734
|
-
{
|
|
2735
|
-
title: "Mapping",
|
|
2736
|
-
className: "explorer-unified-container--code-editor"
|
|
2737
|
-
},
|
|
2738
|
-
{
|
|
2739
|
-
title: "Result",
|
|
2740
|
-
className: "explorer-unified-container--result-display"
|
|
2741
|
-
}
|
|
2742
|
-
],
|
|
2743
|
-
layout: "horizontal",
|
|
2744
|
-
height: options.height,
|
|
2745
|
-
showHeader: options.showHeader,
|
|
2746
|
-
title: options.title || "Destination Mapping"
|
|
2747
|
-
});
|
|
2748
|
-
const handleThemeToggle = () => {
|
|
2749
|
-
const element = baseApi.getElement();
|
|
2750
|
-
if (element) {
|
|
2751
|
-
const newTheme = toggleElementTheme(element);
|
|
2752
|
-
const themeButtons = element.querySelectorAll(
|
|
2753
|
-
".explorer-unified-header__btn--theme"
|
|
2754
|
-
);
|
|
2755
|
-
themeButtons.forEach((btn) => {
|
|
2756
|
-
btn.textContent = newTheme === "dark" ? "\u2600\uFE0F" : "\u{1F319}";
|
|
2757
|
-
});
|
|
2758
|
-
}
|
|
2759
|
-
};
|
|
2760
|
-
setTimeout(() => {
|
|
2761
|
-
const firstColumn = baseApi.getColumnElement(0);
|
|
2762
|
-
if (firstColumn) {
|
|
2763
|
-
const container = firstColumn.querySelector(
|
|
2764
|
-
".explorer-unified-container"
|
|
2765
|
-
);
|
|
2766
|
-
if (container) {
|
|
2767
|
-
const headerElement = container.querySelector(
|
|
2768
|
-
".explorer-unified-header"
|
|
2769
|
-
);
|
|
2770
|
-
if (headerElement) {
|
|
2771
|
-
const actionsElement = headerElement.querySelector(
|
|
2772
|
-
".explorer-unified-header__actions"
|
|
2773
|
-
);
|
|
2774
|
-
if (actionsElement) {
|
|
2775
|
-
const themeBtn = document.createElement("button");
|
|
2776
|
-
themeBtn.className = "explorer-unified-header__btn explorer-unified-header__btn--theme";
|
|
2777
|
-
themeBtn.textContent = getElementTheme(baseApi.getElement()) === "dark" ? "\u2600\uFE0F" : "\u{1F319}";
|
|
2778
|
-
themeBtn.title = "Toggle theme";
|
|
2779
|
-
themeBtn.addEventListener("click", handleThemeToggle);
|
|
2780
|
-
actionsElement.appendChild(themeBtn);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
}
|
|
2785
|
-
}, 10);
|
|
2786
|
-
const debouncedUpdate = debounce(() => {
|
|
2787
|
-
updateResults();
|
|
2788
|
-
}, options.updateDelay || 300);
|
|
2789
|
-
function createDemoDestination() {
|
|
2790
|
-
return {
|
|
2791
|
-
type: "demo",
|
|
2792
|
-
config: {},
|
|
2793
|
-
push(event, context) {
|
|
2794
|
-
const { data, mapping } = context;
|
|
2795
|
-
capturedResults = [];
|
|
2796
|
-
if (data !== void 0) {
|
|
2797
|
-
capturedResults.push({
|
|
2798
|
-
type: "mapped_result",
|
|
2799
|
-
mappingRule: (mapping == null ? void 0 : mapping.name) || "default",
|
|
2800
|
-
data,
|
|
2801
|
-
timestamp: Date.now()
|
|
2802
|
-
});
|
|
2803
|
-
} else {
|
|
2804
|
-
capturedResults.push({
|
|
2805
|
-
type: "no_mapping",
|
|
2806
|
-
event,
|
|
2807
|
-
message: "No mapping rule matched or no data produced",
|
|
2808
|
-
timestamp: Date.now()
|
|
2809
|
-
});
|
|
2810
|
-
}
|
|
2811
|
-
updateResultDisplay();
|
|
2812
|
-
}
|
|
2813
|
-
};
|
|
2814
|
-
}
|
|
2815
|
-
function initializeCollector() {
|
|
2816
|
-
return __async(this, null, function* () {
|
|
2817
|
-
try {
|
|
2818
|
-
const destination = options.destination || createDemoDestination();
|
|
2819
|
-
const { elb, collector: newCollector } = yield J2({
|
|
2820
|
-
destinations: {
|
|
2821
|
-
demo: destination
|
|
2822
|
-
},
|
|
2823
|
-
run: true
|
|
2824
|
-
});
|
|
2825
|
-
return { elb, collector: newCollector };
|
|
2826
|
-
} catch (error) {
|
|
2827
|
-
capturedResults = [
|
|
2828
|
-
{
|
|
2829
|
-
type: "error",
|
|
2830
|
-
message: `Failed to initialize collector: ${String(error)}`,
|
|
2831
|
-
timestamp: Date.now()
|
|
2832
|
-
}
|
|
2833
|
-
];
|
|
2834
|
-
updateResultDisplay();
|
|
2835
|
-
return null;
|
|
2836
|
-
}
|
|
2837
|
-
});
|
|
2838
|
-
}
|
|
2839
|
-
function createComponents() {
|
|
2840
|
-
const eventContentElement = baseApi.getColumnContentElement(0);
|
|
2841
|
-
const mappingContentElement = baseApi.getColumnContentElement(1);
|
|
2842
|
-
const resultContentElement = baseApi.getColumnContentElement(2);
|
|
2843
|
-
if (!eventContentElement || !mappingContentElement || !resultContentElement) {
|
|
2844
|
-
throw new Error(
|
|
2845
|
-
"Failed to get column content elements from multi-column layout"
|
|
2846
|
-
);
|
|
2847
|
-
}
|
|
2848
|
-
eventEditor = createCodeEditor(eventContentElement, {
|
|
2849
|
-
language: "json",
|
|
2850
|
-
value: eventData,
|
|
2851
|
-
height: "100%",
|
|
2852
|
-
onChange: (value) => {
|
|
2853
|
-
eventData = value;
|
|
2854
|
-
debouncedUpdate();
|
|
2855
|
-
}
|
|
2856
|
-
});
|
|
2857
|
-
mappingEditor = createCodeEditor(mappingContentElement, {
|
|
2858
|
-
language: "json",
|
|
2859
|
-
value: mappingData,
|
|
2860
|
-
height: "100%",
|
|
2861
|
-
onChange: (value) => {
|
|
2862
|
-
mappingData = value;
|
|
2863
|
-
debouncedUpdate();
|
|
2864
|
-
}
|
|
2865
|
-
});
|
|
2866
|
-
resultDisplay = createResultDisplay(resultContentElement, {
|
|
2867
|
-
height: "100%",
|
|
2868
|
-
maxResults: 1
|
|
2869
|
-
});
|
|
2870
|
-
updateResultDisplay();
|
|
2871
|
-
initializeCollector().then((result) => {
|
|
2872
|
-
if (result) {
|
|
2873
|
-
elbFunction = result.elb;
|
|
2874
|
-
collector = result.collector;
|
|
2875
|
-
setTimeout(() => {
|
|
2876
|
-
updateResults();
|
|
2877
|
-
}, 200);
|
|
2878
|
-
}
|
|
2879
|
-
});
|
|
2880
|
-
}
|
|
2881
|
-
function updateResults() {
|
|
2882
|
-
return __async(this, null, function* () {
|
|
2883
|
-
try {
|
|
2884
|
-
capturedResults = [];
|
|
2885
|
-
if (!elbFunction) {
|
|
2886
|
-
resultDisplay.clear();
|
|
2887
|
-
resultDisplay.addError("Collector not initialized");
|
|
2888
|
-
return;
|
|
2889
|
-
}
|
|
2890
|
-
let parsedEvent;
|
|
2891
|
-
try {
|
|
2892
|
-
parsedEvent = eventData.trim() ? JSON.parse(eventData) : null;
|
|
2893
|
-
} catch (error) {
|
|
2894
|
-
resultDisplay.clear();
|
|
2895
|
-
resultDisplay.addError(`Invalid JSON in Event: ${String(error)}`);
|
|
2896
|
-
return;
|
|
2897
|
-
}
|
|
2898
|
-
if (parsedEvent) {
|
|
2899
|
-
updateDestinationMapping();
|
|
2900
|
-
yield elbFunction(parsedEvent);
|
|
2901
|
-
}
|
|
2902
|
-
} catch (error) {
|
|
2903
|
-
resultDisplay.clear();
|
|
2904
|
-
resultDisplay.addError(`Processing error: ${String(error)}`);
|
|
2905
|
-
}
|
|
2906
|
-
});
|
|
2907
|
-
}
|
|
2908
|
-
function updateDestinationMapping() {
|
|
2909
|
-
if (!collector) return;
|
|
2910
|
-
try {
|
|
2911
|
-
const demoDestination = collector.destinations.demo;
|
|
2912
|
-
if (demoDestination && mappingData.trim()) {
|
|
2913
|
-
const mapping = JSON.parse(mappingData);
|
|
2914
|
-
demoDestination.config.mapping = mapping;
|
|
2915
|
-
}
|
|
2916
|
-
} catch (error) {
|
|
2917
|
-
capturedResults.push({
|
|
2918
|
-
type: "error",
|
|
2919
|
-
message: `Failed to update mapping: ${String(error)}`,
|
|
2920
|
-
timestamp: Date.now()
|
|
2921
|
-
});
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
function updateResultDisplay() {
|
|
2925
|
-
resultDisplay.clear();
|
|
2926
|
-
if (capturedResults.length === 0) {
|
|
2927
|
-
resultDisplay.addInfo(
|
|
2928
|
-
"Ready - modify the event or mapping and see the destination processing results"
|
|
2929
|
-
);
|
|
2930
|
-
return;
|
|
2931
|
-
}
|
|
2932
|
-
capturedResults.forEach((result) => {
|
|
2933
|
-
if (result.type === "mapped_result") {
|
|
2934
|
-
resultDisplay.addValue(
|
|
2935
|
-
result.data,
|
|
2936
|
-
`Destination receives (${result.mappingRule})`
|
|
2937
|
-
);
|
|
2938
|
-
} else if (result.type === "no_mapping") {
|
|
2939
|
-
resultDisplay.addInfo(result.message || "No mapping applied");
|
|
2940
|
-
} else {
|
|
2941
|
-
resultDisplay.addValue(result);
|
|
2942
|
-
}
|
|
2943
|
-
});
|
|
2944
|
-
}
|
|
2945
|
-
const api = __spreadProps(__spreadValues({}, baseApi), {
|
|
2946
|
-
getEventData() {
|
|
2947
|
-
return eventData;
|
|
2948
|
-
},
|
|
2949
|
-
setEventData(data) {
|
|
2950
|
-
eventData = data;
|
|
2951
|
-
eventEditor == null ? void 0 : eventEditor.setValue(data);
|
|
2952
|
-
debouncedUpdate();
|
|
2953
|
-
},
|
|
2954
|
-
getMappingData() {
|
|
2955
|
-
return mappingData;
|
|
2956
|
-
},
|
|
2957
|
-
setMappingData(data) {
|
|
2958
|
-
mappingData = data;
|
|
2959
|
-
mappingEditor == null ? void 0 : mappingEditor.setValue(data);
|
|
2960
|
-
debouncedUpdate();
|
|
2961
|
-
},
|
|
2962
|
-
getResults() {
|
|
2963
|
-
return capturedResults || [];
|
|
2964
|
-
},
|
|
2965
|
-
refresh() {
|
|
2966
|
-
updateResults();
|
|
2967
|
-
},
|
|
2968
|
-
clear() {
|
|
2969
|
-
eventData = "{}";
|
|
2970
|
-
mappingData = "{}";
|
|
2971
|
-
eventEditor == null ? void 0 : eventEditor.setValue("{}");
|
|
2972
|
-
mappingEditor == null ? void 0 : mappingEditor.setValue("{}");
|
|
2973
|
-
capturedResults = [];
|
|
2974
|
-
resultDisplay == null ? void 0 : resultDisplay.clear();
|
|
2975
|
-
},
|
|
2976
|
-
destroy() {
|
|
2977
|
-
cleanup.forEach((fn) => fn());
|
|
2978
|
-
eventEditor == null ? void 0 : eventEditor.destroy();
|
|
2979
|
-
mappingEditor == null ? void 0 : mappingEditor.destroy();
|
|
2980
|
-
resultDisplay == null ? void 0 : resultDisplay.destroy();
|
|
2981
|
-
elbFunction = null;
|
|
2982
|
-
collector = null;
|
|
2983
|
-
capturedResults = [];
|
|
2984
|
-
baseApi.destroy();
|
|
2985
|
-
}
|
|
2986
|
-
});
|
|
2987
|
-
createComponents();
|
|
2988
|
-
api.mount();
|
|
2989
|
-
return api;
|
|
2990
|
-
}
|
|
2991
|
-
|
|
2992
|
-
// src/index.ts
|
|
2993
|
-
var version = "1.0.0";
|
|
2994
|
-
var name = "@walkeros/explorer";
|
|
2995
|
-
return __toCommonJS(index_exports);
|
|
2996
|
-
})();
|
|
2997
|
-
//# sourceMappingURL=index.js.map
|