aeo.js 0.0.2 → 0.0.3

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.
Files changed (62) hide show
  1. package/README.md +132 -17
  2. package/dist/angular.d.mts +29 -0
  3. package/dist/angular.d.ts +29 -0
  4. package/dist/angular.js +1314 -0
  5. package/dist/angular.js.map +1 -0
  6. package/dist/angular.mjs +1310 -0
  7. package/dist/angular.mjs.map +1 -0
  8. package/dist/astro.d.mts +8 -2
  9. package/dist/astro.d.ts +8 -2
  10. package/dist/astro.js +342 -100
  11. package/dist/astro.js.map +1 -1
  12. package/dist/astro.mjs +342 -100
  13. package/dist/astro.mjs.map +1 -1
  14. package/dist/cli.d.mts +1 -0
  15. package/dist/cli.d.ts +1 -0
  16. package/dist/cli.js +1880 -0
  17. package/dist/cli.js.map +1 -0
  18. package/dist/cli.mjs +1878 -0
  19. package/dist/cli.mjs.map +1 -0
  20. package/dist/index.d.mts +178 -4
  21. package/dist/index.d.ts +178 -4
  22. package/dist/index.js +972 -19
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +952 -20
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/next.d.mts +2 -17
  27. package/dist/next.d.ts +2 -17
  28. package/dist/next.js +262 -73
  29. package/dist/next.js.map +1 -1
  30. package/dist/next.mjs +262 -73
  31. package/dist/next.mjs.map +1 -1
  32. package/dist/nuxt.d.mts +13 -0
  33. package/dist/nuxt.d.ts +13 -0
  34. package/dist/nuxt.js +1344 -0
  35. package/dist/nuxt.js.map +1 -0
  36. package/dist/nuxt.mjs +1337 -0
  37. package/dist/nuxt.mjs.map +1 -0
  38. package/dist/react.d.mts +1 -1
  39. package/dist/react.d.ts +1 -1
  40. package/dist/{types-BTY-v-7i.d.mts → types-Cn_Qbkmg.d.mts} +34 -0
  41. package/dist/{types-BTY-v-7i.d.ts → types-Cn_Qbkmg.d.ts} +34 -0
  42. package/dist/vite.d.mts +5 -0
  43. package/dist/vite.d.ts +5 -0
  44. package/dist/vite.js +1370 -0
  45. package/dist/vite.js.map +1 -0
  46. package/dist/vite.mjs +1366 -0
  47. package/dist/vite.mjs.map +1 -0
  48. package/dist/vue.d.mts +19 -0
  49. package/dist/vue.d.ts +19 -0
  50. package/dist/vue.js +1078 -0
  51. package/dist/vue.js.map +1 -0
  52. package/dist/vue.mjs +1072 -0
  53. package/dist/vue.mjs.map +1 -0
  54. package/dist/webpack.d.mts +1 -1
  55. package/dist/webpack.d.ts +1 -1
  56. package/dist/webpack.js +178 -18
  57. package/dist/webpack.js.map +1 -1
  58. package/dist/webpack.mjs +178 -18
  59. package/dist/webpack.mjs.map +1 -1
  60. package/dist/widget.d.mts +1 -1
  61. package/dist/widget.d.ts +1 -1
  62. package/package.json +48 -2
package/dist/vue.mjs ADDED
@@ -0,0 +1,1072 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/widget/styles.ts
9
+ function getStyles(theme) {
10
+ const t = {
11
+ background: (theme == null ? void 0 : theme.background) || "#0a0a0f",
12
+ text: (theme == null ? void 0 : theme.text) || "#a0a0a8",
13
+ accent: (theme == null ? void 0 : theme.accent) || "#e8e8ea",
14
+ badge: (theme == null ? void 0 : theme.badge) || "#4ADE80"
15
+ };
16
+ return `
17
+ @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');
18
+
19
+ .aeo-toggle {
20
+ position: fixed;
21
+ z-index: 10001;
22
+ font-family: 'JetBrains Mono', monospace;
23
+ font-size: 14px;
24
+ animation: aeo-fade-in 0.3s ease;
25
+ }
26
+
27
+ .aeo-toggle.aeo-bottom-right {
28
+ bottom: 20px;
29
+ right: 20px;
30
+ }
31
+
32
+ .aeo-toggle.aeo-bottom-left {
33
+ bottom: 20px;
34
+ left: 20px;
35
+ }
36
+
37
+ .aeo-toggle.aeo-top-right {
38
+ top: 20px;
39
+ right: 20px;
40
+ }
41
+
42
+ .aeo-toggle.aeo-top-left {
43
+ top: 20px;
44
+ left: 20px;
45
+ }
46
+
47
+ .aeo-toggle-inner {
48
+ display: flex;
49
+ background: ${t.background};
50
+ backdrop-filter: blur(10px);
51
+ border: 1px solid rgba(255, 255, 255, 0.1);
52
+ border-radius: 24px;
53
+ padding: 4px;
54
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
55
+ }
56
+
57
+ .aeo-toggle-btn {
58
+ display: flex;
59
+ align-items: center;
60
+ gap: 8px;
61
+ padding: 8px 16px;
62
+ border: none;
63
+ background: transparent;
64
+ color: ${t.text};
65
+ cursor: pointer;
66
+ border-radius: 20px;
67
+ transition: all 0.2s ease;
68
+ font-family: inherit;
69
+ font-size: 14px;
70
+ font-weight: 500;
71
+ }
72
+
73
+ .aeo-toggle-btn svg {
74
+ width: 16px;
75
+ height: 16px;
76
+ fill: currentColor;
77
+ }
78
+
79
+ .aeo-toggle-btn:hover {
80
+ background: rgba(255, 255, 255, 0.05);
81
+ }
82
+
83
+ .aeo-toggle-btn.aeo-active {
84
+ background: ${t.accent};
85
+ color: ${t.background};
86
+ }
87
+
88
+ /* Full-screen overlay */
89
+ .aeo-overlay {
90
+ position: fixed;
91
+ top: 0;
92
+ left: 0;
93
+ right: 0;
94
+ bottom: 0;
95
+ background: ${t.background};
96
+ z-index: 10000;
97
+ display: flex;
98
+ flex-direction: column;
99
+ animation: aeo-fade-in 0.2s ease;
100
+ font-family: 'JetBrains Mono', monospace;
101
+ }
102
+
103
+ /* Top bar */
104
+ .aeo-topbar {
105
+ display: flex;
106
+ align-items: center;
107
+ gap: 12px;
108
+ padding: 12px 24px;
109
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
110
+ background: rgba(255, 255, 255, 0.02);
111
+ flex-shrink: 0;
112
+ }
113
+
114
+ .aeo-badge {
115
+ display: inline-flex;
116
+ align-items: center;
117
+ gap: 6px;
118
+ background: rgba(74, 222, 128, 0.1);
119
+ color: ${t.badge};
120
+ padding: 6px 14px;
121
+ border-radius: 20px;
122
+ font-size: 11px;
123
+ font-weight: 600;
124
+ text-transform: uppercase;
125
+ letter-spacing: 0.8px;
126
+ border: 1px solid rgba(74, 222, 128, 0.2);
127
+ }
128
+
129
+ .aeo-badge-dot {
130
+ width: 6px;
131
+ height: 6px;
132
+ background: ${t.badge};
133
+ border-radius: 50%;
134
+ flex-shrink: 0;
135
+ }
136
+
137
+ .aeo-route-tab {
138
+ display: inline-flex;
139
+ align-items: center;
140
+ padding: 6px 14px;
141
+ background: rgba(255, 255, 255, 0.05);
142
+ color: ${t.accent};
143
+ border-radius: 8px;
144
+ font-size: 13px;
145
+ font-weight: 500;
146
+ border: 1px solid rgba(255, 255, 255, 0.08);
147
+ }
148
+
149
+ .aeo-topbar-spacer {
150
+ flex: 1;
151
+ }
152
+
153
+ .aeo-topbar-actions {
154
+ display: flex;
155
+ align-items: center;
156
+ gap: 4px;
157
+ }
158
+
159
+ .aeo-topbar-btn {
160
+ display: inline-flex;
161
+ align-items: center;
162
+ gap: 6px;
163
+ padding: 6px 14px;
164
+ background: transparent;
165
+ color: ${t.text};
166
+ border: 1px solid rgba(255, 255, 255, 0.1);
167
+ border-radius: 8px;
168
+ font-family: inherit;
169
+ font-size: 12px;
170
+ font-weight: 500;
171
+ cursor: pointer;
172
+ transition: all 0.15s ease;
173
+ white-space: nowrap;
174
+ }
175
+
176
+ .aeo-topbar-btn:hover:not(:disabled) {
177
+ background: rgba(255, 255, 255, 0.05);
178
+ color: ${t.accent};
179
+ border-color: rgba(255, 255, 255, 0.2);
180
+ }
181
+
182
+ .aeo-topbar-btn:disabled {
183
+ opacity: 0.4;
184
+ cursor: not-allowed;
185
+ }
186
+
187
+ .aeo-topbar-btn svg {
188
+ width: 14px;
189
+ height: 14px;
190
+ fill: currentColor;
191
+ }
192
+
193
+ .aeo-close-btn {
194
+ display: inline-flex;
195
+ align-items: center;
196
+ gap: 6px;
197
+ padding: 6px 14px;
198
+ background: transparent;
199
+ color: ${t.text};
200
+ border: 1px solid rgba(255, 255, 255, 0.1);
201
+ border-radius: 8px;
202
+ font-family: inherit;
203
+ font-size: 12px;
204
+ font-weight: 500;
205
+ cursor: pointer;
206
+ transition: all 0.15s ease;
207
+ white-space: nowrap;
208
+ }
209
+
210
+ .aeo-close-btn:hover {
211
+ background: rgba(255, 60, 60, 0.1);
212
+ color: #ff6b6b;
213
+ border-color: rgba(255, 60, 60, 0.3);
214
+ }
215
+
216
+ .aeo-close-btn svg {
217
+ width: 14px;
218
+ height: 14px;
219
+ fill: none;
220
+ stroke: currentColor;
221
+ }
222
+
223
+ /* Content area */
224
+ .aeo-content-area {
225
+ flex: 1;
226
+ overflow-y: auto;
227
+ padding: 40px 24px;
228
+ }
229
+
230
+ .aeo-content-wrapper {
231
+ max-width: 800px;
232
+ margin: 0 auto;
233
+ }
234
+
235
+ .aeo-loading {
236
+ display: flex;
237
+ flex-direction: column;
238
+ align-items: center;
239
+ justify-content: center;
240
+ gap: 16px;
241
+ padding: 80px 24px;
242
+ color: ${t.text};
243
+ }
244
+
245
+ .aeo-loading svg {
246
+ width: 24px;
247
+ height: 24px;
248
+ fill: ${t.text};
249
+ animation: aeo-spin 1s linear infinite;
250
+ }
251
+
252
+ .aeo-loading span {
253
+ font-size: 13px;
254
+ opacity: 0.6;
255
+ }
256
+
257
+ /* Markdown source display */
258
+ .aeo-markdown-source {
259
+ font-family: 'JetBrains Mono', monospace;
260
+ font-size: 13px;
261
+ line-height: 1.7;
262
+ color: ${t.text};
263
+ background: transparent;
264
+ margin: 0;
265
+ padding: 0;
266
+ border: none;
267
+ white-space: pre-wrap;
268
+ word-wrap: break-word;
269
+ overflow-x: auto;
270
+ }
271
+
272
+ .aeo-markdown-source code {
273
+ font-family: inherit;
274
+ background: transparent;
275
+ }
276
+
277
+ .aeo-markdown-source .hl-fm {
278
+ color: rgba(160, 160, 168, 0.5);
279
+ }
280
+
281
+ .aeo-markdown-source .hl-heading {
282
+ color: ${t.accent};
283
+ font-weight: 600;
284
+ }
285
+
286
+ .aeo-markdown-source .hl-bold {
287
+ color: ${t.accent};
288
+ font-weight: 600;
289
+ }
290
+
291
+ .aeo-markdown-source .hl-italic {
292
+ font-style: italic;
293
+ color: ${t.accent};
294
+ opacity: 0.85;
295
+ }
296
+
297
+ .aeo-markdown-source .hl-code {
298
+ color: ${t.badge};
299
+ }
300
+
301
+ .aeo-markdown-source .hl-link {
302
+ color: rgba(160, 160, 168, 0.6);
303
+ }
304
+
305
+ .aeo-markdown-source .hl-link-text {
306
+ color: ${t.badge};
307
+ }
308
+
309
+ .aeo-markdown-source .hl-link-url {
310
+ color: rgba(160, 160, 168, 0.4);
311
+ }
312
+
313
+ .aeo-markdown-source .hl-quote {
314
+ color: ${t.text};
315
+ opacity: 0.7;
316
+ font-style: italic;
317
+ }
318
+
319
+ .aeo-markdown-source .hl-hr {
320
+ color: rgba(160, 160, 168, 0.3);
321
+ }
322
+
323
+ .aeo-error {
324
+ text-align: center;
325
+ padding: 80px 24px;
326
+ color: ${t.text};
327
+ }
328
+
329
+ .aeo-error p {
330
+ margin: 0 0 16px;
331
+ font-size: 14px;
332
+ }
333
+
334
+ .aeo-error a {
335
+ color: ${t.accent};
336
+ text-decoration: none;
337
+ padding: 8px 16px;
338
+ border: 1px solid rgba(255, 255, 255, 0.15);
339
+ border-radius: 8px;
340
+ display: inline-block;
341
+ margin: 4px;
342
+ font-size: 13px;
343
+ transition: all 0.15s ease;
344
+ }
345
+
346
+ .aeo-error a:hover {
347
+ background: rgba(255, 255, 255, 0.05);
348
+ border-color: rgba(255, 255, 255, 0.25);
349
+ }
350
+
351
+ .aeo-toast {
352
+ position: fixed;
353
+ bottom: 100px;
354
+ left: 50%;
355
+ transform: translateX(-50%) translateY(20px);
356
+ background: ${t.background};
357
+ color: ${t.accent};
358
+ padding: 10px 20px;
359
+ border-radius: 8px;
360
+ border: 1px solid rgba(255, 255, 255, 0.15);
361
+ font-family: 'JetBrains Mono', monospace;
362
+ font-size: 13px;
363
+ opacity: 0;
364
+ transition: all 0.3s ease;
365
+ z-index: 10002;
366
+ }
367
+
368
+ .aeo-toast.aeo-toast-show {
369
+ opacity: 1;
370
+ transform: translateX(-50%) translateY(0);
371
+ }
372
+
373
+ @keyframes aeo-fade-in {
374
+ from { opacity: 0; }
375
+ to { opacity: 1; }
376
+ }
377
+
378
+ @keyframes aeo-spin {
379
+ from { transform: rotate(0deg); }
380
+ to { transform: rotate(360deg); }
381
+ }
382
+
383
+ @media (max-width: 640px) {
384
+ .aeo-toggle {
385
+ bottom: 12px !important;
386
+ right: 12px !important;
387
+ left: auto !important;
388
+ top: auto !important;
389
+ }
390
+
391
+ .aeo-toggle-btn {
392
+ padding: 6px 12px;
393
+ font-size: 13px;
394
+ }
395
+
396
+ .aeo-toggle-btn span {
397
+ display: none;
398
+ }
399
+
400
+ .aeo-topbar {
401
+ padding: 10px 16px;
402
+ gap: 8px;
403
+ flex-wrap: wrap;
404
+ }
405
+
406
+ .aeo-topbar-btn span {
407
+ display: none;
408
+ }
409
+
410
+ .aeo-close-btn span {
411
+ display: none;
412
+ }
413
+
414
+ .aeo-content-area {
415
+ padding: 24px 16px;
416
+ }
417
+ }
418
+
419
+ @media (prefers-reduced-motion: reduce) {
420
+ .aeo-toggle,
421
+ .aeo-overlay,
422
+ .aeo-toast {
423
+ animation: none;
424
+ transition: none;
425
+ }
426
+ }
427
+ `.trim();
428
+ }
429
+
430
+ // src/widget/icons.ts
431
+ function getIcons() {
432
+ return {
433
+ human: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
434
+ <path d="M12 2C10.9 2 10 2.9 10 4C10 5.1 10.9 6 12 6C13.1 6 14 5.1 14 4C14 2.9 13.1 2 12 2ZM10 7C10 7 8 7 8 9V13C8 13 8 14 9 14H10V21C10 21 10 22 11 22H13C13 22 14 22 14 21V14H15C15 14 16 14 16 13V9C16 7 14 7 14 7H10Z" fill="currentColor"/>
435
+ </svg>`,
436
+ ai: `<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
437
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M11 2a1 1 0 0 1 2 0v2h3a3 3 0 0 1 3 3v6a3 3 0 0 1-3 3H8a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h3V2ZM9.5 7a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm5 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z"/>
438
+ <rect x="6" y="17" width="12" height="5" rx="2"/>
439
+ <rect x="1" y="8" width="3" height="4" rx="1.5"/>
440
+ <rect x="20" y="8" width="3" height="4" rx="1.5"/>
441
+ </svg>`,
442
+ close: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
443
+ <path d="M18 6L6 18M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
444
+ </svg>`,
445
+ copy: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
446
+ <path d="M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z" fill="currentColor"/>
447
+ </svg>`,
448
+ download: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
449
+ <path d="M5 20H19V18H5V20ZM19 9H15V3H9V9H5L12 16L19 9Z" fill="currentColor"/>
450
+ </svg>`,
451
+ spinner: `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
452
+ <path d="M12 2V6M12 18V22M4.93 4.93L7.76 7.76M16.24 16.24L19.07 19.07M2 12H6M18 12H22M4.93 19.07L7.76 16.24M16.24 7.76L19.07 4.93" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
453
+ </svg>`
454
+ };
455
+ }
456
+
457
+ // src/widget/extract.ts
458
+ function extractDOMToMarkdown() {
459
+ const lines = [];
460
+ const processed = /* @__PURE__ */ new WeakSet();
461
+ const title = document.title;
462
+ if (title) {
463
+ lines.push(`# ${title}`, "");
464
+ }
465
+ const description = document.querySelector('meta[name="description"]');
466
+ if (description == null ? void 0 : description.content) {
467
+ lines.push(`> ${description.content}`, "");
468
+ }
469
+ const mainContent = findMainContent();
470
+ if (mainContent) {
471
+ processNode(mainContent, lines, processed);
472
+ } else {
473
+ processNode(document.body, lines, processed);
474
+ }
475
+ return lines.join("\n").trim();
476
+ }
477
+ function findMainContent() {
478
+ const selectors = [
479
+ "main",
480
+ '[role="main"]',
481
+ "article",
482
+ ".content",
483
+ ".main-content",
484
+ "#content",
485
+ "#main-content",
486
+ ".container",
487
+ ".wrapper"
488
+ ];
489
+ for (const selector of selectors) {
490
+ const element = document.querySelector(selector);
491
+ if (element) return element;
492
+ }
493
+ return null;
494
+ }
495
+ function processNode(node, lines, processed) {
496
+ var _a, _b, _c, _d;
497
+ if (processed.has(node)) return;
498
+ processed.add(node);
499
+ if (node instanceof HTMLElement) {
500
+ const tagName = node.tagName.toLowerCase();
501
+ const skipTags = ["script", "style", "noscript", "iframe", "svg", "canvas", "video", "audio"];
502
+ if (skipTags.includes(tagName)) return;
503
+ const style = window.getComputedStyle(node);
504
+ if (style.display === "none" || style.visibility === "hidden") return;
505
+ if (tagName === "nav" || tagName === "footer" || node.classList.contains("nav") || node.classList.contains("footer")) {
506
+ if (!hasImportantContent(node)) return;
507
+ }
508
+ if (node.classList.contains("aeo-toggle") || node.classList.contains("aeo-overlay")) return;
509
+ }
510
+ if (node instanceof HTMLElement) {
511
+ const tagName = node.tagName.toLowerCase();
512
+ switch (tagName) {
513
+ case "h1":
514
+ lines.push("", `# ${getTextContent(node)}`, "");
515
+ break;
516
+ case "h2":
517
+ lines.push("", `## ${getTextContent(node)}`, "");
518
+ break;
519
+ case "h3":
520
+ lines.push("", `### ${getTextContent(node)}`, "");
521
+ break;
522
+ case "h4":
523
+ lines.push("", `#### ${getTextContent(node)}`, "");
524
+ break;
525
+ case "h5":
526
+ lines.push("", `##### ${getTextContent(node)}`, "");
527
+ break;
528
+ case "h6":
529
+ lines.push("", `###### ${getTextContent(node)}`, "");
530
+ break;
531
+ case "p":
532
+ const text = getTextContent(node);
533
+ if (text) lines.push("", text, "");
534
+ break;
535
+ case "blockquote":
536
+ const quoteText = getTextContent(node);
537
+ if (quoteText) {
538
+ lines.push("", ...quoteText.split("\n").map((line) => `> ${line}`), "");
539
+ }
540
+ break;
541
+ case "pre":
542
+ const codeElement = node.querySelector("code");
543
+ if (codeElement) {
544
+ const lang = extractLanguage(codeElement);
545
+ lines.push("", `\`\`\`${lang}`, getTextContent(codeElement), "```", "");
546
+ } else {
547
+ lines.push("", "```", getTextContent(node), "```", "");
548
+ }
549
+ break;
550
+ case "code":
551
+ if (((_a = node.parentElement) == null ? void 0 : _a.tagName.toLowerCase()) !== "pre") {
552
+ const codeText = getTextContent(node);
553
+ if (codeText && !((_b = lines[lines.length - 1]) == null ? void 0 : _b.includes(codeText))) {
554
+ lines[lines.length - 1] = (lines[lines.length - 1] || "") + ` \`${codeText}\` `;
555
+ }
556
+ }
557
+ break;
558
+ case "ul":
559
+ case "ol":
560
+ processListItems(node, lines, processed, tagName === "ol");
561
+ lines.push("");
562
+ break;
563
+ case "a":
564
+ const href = node.href;
565
+ const linkText = getTextContent(node);
566
+ if (linkText && href && !href.startsWith("javascript:")) {
567
+ const markdown = `[${linkText}](${href})`;
568
+ if (!((_c = lines[lines.length - 1]) == null ? void 0 : _c.includes(markdown))) {
569
+ lines[lines.length - 1] = (lines[lines.length - 1] || "") + " " + markdown + " ";
570
+ }
571
+ } else {
572
+ processChildren(node, lines, processed);
573
+ }
574
+ break;
575
+ case "img":
576
+ const img = node;
577
+ if (img.src && img.alt) {
578
+ lines.push("", `![${img.alt}](${img.src})`, "");
579
+ }
580
+ break;
581
+ case "table":
582
+ processTable(node, lines);
583
+ lines.push("");
584
+ break;
585
+ case "strong":
586
+ case "b":
587
+ const boldText = getTextContent(node);
588
+ if (boldText) {
589
+ lines[lines.length - 1] = (lines[lines.length - 1] || "") + ` **${boldText}** `;
590
+ }
591
+ break;
592
+ case "em":
593
+ case "i":
594
+ const italicText = getTextContent(node);
595
+ if (italicText) {
596
+ lines[lines.length - 1] = (lines[lines.length - 1] || "") + ` *${italicText}* `;
597
+ }
598
+ break;
599
+ case "hr":
600
+ lines.push("", "---", "");
601
+ break;
602
+ default:
603
+ processChildren(node, lines, processed);
604
+ }
605
+ } else if (node.nodeType === Node.TEXT_NODE) {
606
+ const text = (_d = node.textContent) == null ? void 0 : _d.trim();
607
+ if (text && !isWhitespaceOnly(text)) {
608
+ if (lines.length === 0 || lines[lines.length - 1] === "") {
609
+ lines.push(text);
610
+ } else {
611
+ lines[lines.length - 1] += " " + text;
612
+ }
613
+ }
614
+ } else {
615
+ processChildren(node, lines, processed);
616
+ }
617
+ }
618
+ function processChildren(node, lines, processed) {
619
+ for (const child of Array.from(node.childNodes)) {
620
+ processNode(child, lines, processed);
621
+ }
622
+ }
623
+ function processListItems(list, lines, processed, isOrdered) {
624
+ const items = Array.from(list.querySelectorAll(":scope > li"));
625
+ items.forEach((item, index) => {
626
+ const prefix = isOrdered ? `${index + 1}. ` : "- ";
627
+ const text = getTextContent(item);
628
+ if (text) {
629
+ lines.push(prefix + text);
630
+ }
631
+ processed.add(item);
632
+ });
633
+ }
634
+ function processTable(table, lines) {
635
+ const rows = Array.from(table.querySelectorAll("tr"));
636
+ if (rows.length === 0) return;
637
+ const headers = Array.from(rows[0].querySelectorAll("th, td")).map((cell) => getTextContent(cell));
638
+ if (headers.length > 0) {
639
+ lines.push("", "| " + headers.join(" | ") + " |");
640
+ lines.push("|" + headers.map(() => " --- ").join("|") + "|");
641
+ for (let i = 1; i < rows.length; i++) {
642
+ const cells = Array.from(rows[i].querySelectorAll("td")).map((cell) => getTextContent(cell));
643
+ if (cells.length > 0) {
644
+ lines.push("| " + cells.join(" | ") + " |");
645
+ }
646
+ }
647
+ }
648
+ }
649
+ function getTextContent(node) {
650
+ var _a, _b;
651
+ if (node instanceof HTMLElement) {
652
+ return ((_a = node.innerText) == null ? void 0 : _a.trim().replace(/\s+/g, " ")) || "";
653
+ }
654
+ return ((_b = node.textContent) == null ? void 0 : _b.trim().replace(/\s+/g, " ")) || "";
655
+ }
656
+ function isWhitespaceOnly(text) {
657
+ return /^\s*$/.test(text);
658
+ }
659
+ function hasImportantContent(node) {
660
+ var _a;
661
+ const importantKeywords = ["documentation", "docs", "api", "guide", "tutorial", "reference"];
662
+ const text = ((_a = node.textContent) == null ? void 0 : _a.toLowerCase()) || "";
663
+ return importantKeywords.some((keyword) => text.includes(keyword));
664
+ }
665
+ function extractLanguage(codeElement) {
666
+ const classes = Array.from(codeElement.classList);
667
+ for (const cls of classes) {
668
+ if (cls.startsWith("language-")) {
669
+ return cls.replace("language-", "");
670
+ }
671
+ if (cls.startsWith("lang-")) {
672
+ return cls.replace("lang-", "");
673
+ }
674
+ }
675
+ const pre = codeElement.closest("pre");
676
+ if (pre) {
677
+ const preClasses = Array.from(pre.classList);
678
+ for (const cls of preClasses) {
679
+ if (cls.startsWith("language-")) {
680
+ return cls.replace("language-", "");
681
+ }
682
+ if (cls.startsWith("lang-")) {
683
+ return cls.replace("lang-", "");
684
+ }
685
+ }
686
+ }
687
+ return "";
688
+ }
689
+
690
+ // src/widget/core.ts
691
+ var AeoWidget = class {
692
+ constructor(options = {}) {
693
+ this.isAIMode = false;
694
+ var _a;
695
+ this.config = this.resolveConfig(options.config);
696
+ this.container = options.container || document.body;
697
+ if (((_a = this.config.widget) == null ? void 0 : _a.enabled) !== false) {
698
+ this.init();
699
+ }
700
+ }
701
+ resolveConfig(config) {
702
+ const defaultConfig = {
703
+ title: document.title || "Website",
704
+ description: "",
705
+ url: window.location.origin,
706
+ contentDir: "docs",
707
+ outDir: "dist",
708
+ generators: {
709
+ robotsTxt: true,
710
+ llmsTxt: true,
711
+ llmsFullTxt: true,
712
+ rawMarkdown: true,
713
+ manifest: true,
714
+ sitemap: true,
715
+ aiIndex: true
716
+ },
717
+ widget: {
718
+ enabled: true,
719
+ position: "bottom-right",
720
+ theme: {
721
+ background: "#0a0a0f",
722
+ text: "#a0a0a8",
723
+ accent: "#e8e8ea",
724
+ badge: "#4ADE80"
725
+ },
726
+ humanLabel: "Human",
727
+ aiLabel: "AI",
728
+ showBadge: true
729
+ }
730
+ };
731
+ return { ...defaultConfig, ...config };
732
+ }
733
+ init() {
734
+ this.injectStyles();
735
+ this.createToggle();
736
+ this.bindEvents();
737
+ }
738
+ injectStyles() {
739
+ var _a;
740
+ if (this.styleElement) return;
741
+ this.styleElement = document.createElement("style");
742
+ this.styleElement.textContent = getStyles((_a = this.config.widget) == null ? void 0 : _a.theme);
743
+ document.head.appendChild(this.styleElement);
744
+ }
745
+ createToggle() {
746
+ var _a, _b, _c;
747
+ const position = ((_a = this.config.widget) == null ? void 0 : _a.position) || "bottom-right";
748
+ const icons = getIcons();
749
+ this.toggleElement = document.createElement("div");
750
+ this.toggleElement.className = `aeo-toggle aeo-${position}`;
751
+ this.toggleElement.innerHTML = `
752
+ <div class="aeo-toggle-inner">
753
+ <button class="aeo-toggle-btn aeo-human-btn aeo-active" data-mode="human">
754
+ ${icons.human}
755
+ <span>${((_b = this.config.widget) == null ? void 0 : _b.humanLabel) || "Human"}</span>
756
+ </button>
757
+ <button class="aeo-toggle-btn aeo-ai-btn" data-mode="ai">
758
+ ${icons.ai}
759
+ <span>${((_c = this.config.widget) == null ? void 0 : _c.aiLabel) || "AI"}</span>
760
+ </button>
761
+ </div>
762
+ `;
763
+ this.container.appendChild(this.toggleElement);
764
+ }
765
+ bindEvents() {
766
+ if (!this.toggleElement) return;
767
+ this.toggleElement.addEventListener("click", (e) => {
768
+ const target = e.target;
769
+ const btn = target.closest(".aeo-toggle-btn");
770
+ if (!btn) return;
771
+ const mode = btn.dataset.mode;
772
+ if (mode === "ai" && !this.isAIMode) {
773
+ this.switchToAI();
774
+ } else if (mode === "human" && this.isAIMode) {
775
+ this.switchToHuman();
776
+ }
777
+ });
778
+ document.addEventListener("keydown", (e) => {
779
+ if (e.key === "Escape" && this.overlayElement) {
780
+ this.closeOverlay();
781
+ }
782
+ });
783
+ }
784
+ async switchToAI() {
785
+ this.isAIMode = true;
786
+ this.updateToggleState();
787
+ await this.showOverlay();
788
+ }
789
+ switchToHuman() {
790
+ this.isAIMode = false;
791
+ this.updateToggleState();
792
+ this.closeOverlay();
793
+ }
794
+ updateToggleState() {
795
+ if (!this.toggleElement) return;
796
+ const humanBtn = this.toggleElement.querySelector(".aeo-human-btn");
797
+ const aiBtn = this.toggleElement.querySelector(".aeo-ai-btn");
798
+ if (this.isAIMode) {
799
+ humanBtn == null ? void 0 : humanBtn.classList.remove("aeo-active");
800
+ aiBtn == null ? void 0 : aiBtn.classList.add("aeo-active");
801
+ } else {
802
+ humanBtn == null ? void 0 : humanBtn.classList.add("aeo-active");
803
+ aiBtn == null ? void 0 : aiBtn.classList.remove("aeo-active");
804
+ }
805
+ }
806
+ getMarkdownPath() {
807
+ const currentPath = window.location.pathname;
808
+ if (currentPath === "/" || currentPath.endsWith("/")) {
809
+ return `${currentPath}index.md`;
810
+ }
811
+ return `${currentPath}.md`;
812
+ }
813
+ async showOverlay() {
814
+ var _a;
815
+ const icons = getIcons();
816
+ const mdPath = this.getMarkdownPath();
817
+ this.overlayElement = document.createElement("div");
818
+ this.overlayElement.className = "aeo-overlay";
819
+ this.overlayElement.innerHTML = `
820
+ <div class="aeo-topbar">
821
+ ${((_a = this.config.widget) == null ? void 0 : _a.showBadge) !== false ? '<span class="aeo-badge"><span class="aeo-badge-dot"></span>LLM-READY</span>' : ""}
822
+ <span class="aeo-route-tab">${mdPath}</span>
823
+ <div class="aeo-topbar-spacer"></div>
824
+ <div class="aeo-topbar-actions">
825
+ <button class="aeo-topbar-btn aeo-copy-btn" disabled>
826
+ ${icons.copy}
827
+ <span>Copy</span>
828
+ </button>
829
+ <button class="aeo-topbar-btn aeo-download-btn" disabled>
830
+ ${icons.download}
831
+ <span>Download .md</span>
832
+ </button>
833
+ <button class="aeo-close-btn">
834
+ ${icons.close}
835
+ <span>Close</span>
836
+ </button>
837
+ </div>
838
+ </div>
839
+ <div class="aeo-content-area">
840
+ <div class="aeo-content-wrapper">
841
+ <div class="aeo-loading">
842
+ ${icons.spinner}
843
+ <span>Loading AI-optimized content...</span>
844
+ </div>
845
+ </div>
846
+ </div>
847
+ `;
848
+ this.container.appendChild(this.overlayElement);
849
+ const closeBtn = this.overlayElement.querySelector(".aeo-close-btn");
850
+ closeBtn == null ? void 0 : closeBtn.addEventListener("click", () => this.closeOverlay());
851
+ await this.loadContent();
852
+ }
853
+ async loadContent() {
854
+ if (!this.overlayElement) return;
855
+ const wrapper = this.overlayElement.querySelector(".aeo-content-wrapper");
856
+ if (!wrapper) return;
857
+ try {
858
+ const mdPath = this.getMarkdownPath();
859
+ const response = await fetch(mdPath);
860
+ let content;
861
+ if (response.ok) {
862
+ content = await response.text();
863
+ } else {
864
+ content = extractDOMToMarkdown();
865
+ }
866
+ wrapper.innerHTML = `
867
+ <pre class="aeo-markdown-source"><code>${this.highlightMarkdown(content)}</code></pre>
868
+ `;
869
+ const copyBtn = this.overlayElement.querySelector(".aeo-copy-btn");
870
+ const downloadBtn = this.overlayElement.querySelector(".aeo-download-btn");
871
+ if (copyBtn) {
872
+ copyBtn.disabled = false;
873
+ copyBtn.addEventListener("click", () => this.copyToClipboard(content));
874
+ }
875
+ if (downloadBtn) {
876
+ downloadBtn.disabled = false;
877
+ downloadBtn.addEventListener("click", () => this.downloadMarkdown(content));
878
+ }
879
+ } catch {
880
+ wrapper.innerHTML = `
881
+ <div class="aeo-error">
882
+ <p>Unable to load AI-optimized content.</p>
883
+ <p>Try these alternatives:</p>
884
+ <div>
885
+ <a href="/llms.txt" target="_blank">llms.txt</a>
886
+ <a href="/llms-full.txt" target="_blank">llms-full.txt</a>
887
+ </div>
888
+ </div>
889
+ `;
890
+ }
891
+ }
892
+ highlightMarkdown(md) {
893
+ var _a;
894
+ const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
895
+ const lines = md.split("\n");
896
+ const out = [];
897
+ let inFrontmatter = false;
898
+ let inCode = false;
899
+ let frontmatterStart = ((_a = lines[0]) == null ? void 0 : _a.trim()) === "---";
900
+ for (let i = 0; i < lines.length; i++) {
901
+ const line = lines[i];
902
+ const trimmed = line.trim();
903
+ if (i === 0 && frontmatterStart) {
904
+ inFrontmatter = true;
905
+ out.push(`<span class="hl-fm">${esc(line)}</span>`);
906
+ continue;
907
+ }
908
+ if (inFrontmatter) {
909
+ if (trimmed === "---") {
910
+ inFrontmatter = false;
911
+ out.push(`<span class="hl-fm">${esc(line)}</span>`);
912
+ } else {
913
+ out.push(`<span class="hl-fm">${esc(line)}</span>`);
914
+ }
915
+ continue;
916
+ }
917
+ if (trimmed.startsWith("```")) {
918
+ inCode = !inCode;
919
+ out.push(`<span class="hl-code">${esc(line)}</span>`);
920
+ continue;
921
+ }
922
+ if (inCode) {
923
+ out.push(`<span class="hl-code">${esc(line)}</span>`);
924
+ continue;
925
+ }
926
+ if (/^#{1,6}\s/.test(trimmed)) {
927
+ out.push(`<span class="hl-heading">${esc(line)}</span>`);
928
+ continue;
929
+ }
930
+ if (/^(-{3,}|\*{3,}|_{3,})$/.test(trimmed)) {
931
+ out.push(`<span class="hl-hr">${esc(line)}</span>`);
932
+ continue;
933
+ }
934
+ if (trimmed.startsWith(">")) {
935
+ out.push(`<span class="hl-quote">${esc(line)}</span>`);
936
+ continue;
937
+ }
938
+ if (/^[-*+]\s/.test(trimmed) || /^\d+\.\s/.test(trimmed)) {
939
+ out.push(this.highlightInline(esc(line)));
940
+ continue;
941
+ }
942
+ out.push(this.highlightInline(esc(line)));
943
+ }
944
+ return out.join("\n");
945
+ }
946
+ highlightInline(escaped) {
947
+ let text = escaped.replace(/\*\*(.+?)\*\*/g, '<span class="hl-bold">**$1**</span>');
948
+ text = text.replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, '<span class="hl-italic">*$1*</span>');
949
+ text = text.replace(/`([^`]+)`/g, '<span class="hl-code">`$1`</span>');
950
+ text = text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<span class="hl-link">[<span class="hl-link-text">$1</span>](<span class="hl-link-url">$2</span>)</span>');
951
+ return text;
952
+ }
953
+ closeOverlay() {
954
+ if (this.overlayElement) {
955
+ this.overlayElement.remove();
956
+ this.overlayElement = void 0;
957
+ }
958
+ this.switchToHuman();
959
+ }
960
+ async copyToClipboard(text) {
961
+ try {
962
+ await navigator.clipboard.writeText(text);
963
+ this.showToast("Copied to clipboard!");
964
+ } catch {
965
+ this.showToast("Failed to copy");
966
+ }
967
+ }
968
+ downloadMarkdown(content) {
969
+ const blob = new Blob([content], { type: "text/markdown" });
970
+ const url = URL.createObjectURL(blob);
971
+ const a = document.createElement("a");
972
+ a.href = url;
973
+ a.download = `${this.sanitizeFilename(document.title)}.md`;
974
+ document.body.appendChild(a);
975
+ a.click();
976
+ document.body.removeChild(a);
977
+ URL.revokeObjectURL(url);
978
+ }
979
+ sanitizeFilename(name) {
980
+ return name.replace(/[^a-z0-9]/gi, "-").toLowerCase();
981
+ }
982
+ showToast(message) {
983
+ const toast = document.createElement("div");
984
+ toast.className = "aeo-toast";
985
+ toast.textContent = message;
986
+ this.container.appendChild(toast);
987
+ setTimeout(() => {
988
+ toast.classList.add("aeo-toast-show");
989
+ }, 10);
990
+ setTimeout(() => {
991
+ toast.classList.remove("aeo-toast-show");
992
+ setTimeout(() => toast.remove(), 300);
993
+ }, 2e3);
994
+ }
995
+ destroy() {
996
+ var _a, _b, _c;
997
+ (_a = this.toggleElement) == null ? void 0 : _a.remove();
998
+ (_b = this.overlayElement) == null ? void 0 : _b.remove();
999
+ (_c = this.styleElement) == null ? void 0 : _c.remove();
1000
+ }
1001
+ };
1002
+
1003
+ // src/widget/vue.ts
1004
+ var AeoWidgetVue = {
1005
+ name: "AeoWidget",
1006
+ props: {
1007
+ config: {
1008
+ type: Object,
1009
+ default: () => ({})
1010
+ }
1011
+ },
1012
+ setup(props) {
1013
+ const vue = __require("vue");
1014
+ const widgetInstance = vue.ref(null);
1015
+ const containerRef = vue.ref(null);
1016
+ vue.onMounted(() => {
1017
+ if (!containerRef.value) return;
1018
+ const options = {
1019
+ config: props.config,
1020
+ container: containerRef.value
1021
+ };
1022
+ widgetInstance.value = new AeoWidget(options);
1023
+ });
1024
+ vue.onUnmounted(() => {
1025
+ if (widgetInstance.value) {
1026
+ widgetInstance.value.destroy();
1027
+ widgetInstance.value = null;
1028
+ }
1029
+ });
1030
+ return () => vue.h("div", {
1031
+ ref: containerRef,
1032
+ class: "aeo-widget-vue-container"
1033
+ });
1034
+ }
1035
+ };
1036
+ function useAeoWidget(config) {
1037
+ const vue = __require("vue");
1038
+ const widget = vue.ref(null);
1039
+ const init = (customConfig) => {
1040
+ if (widget.value) {
1041
+ widget.value.destroy();
1042
+ }
1043
+ const options = {
1044
+ config: customConfig || config
1045
+ };
1046
+ widget.value = new AeoWidget(options);
1047
+ };
1048
+ const destroy = () => {
1049
+ if (widget.value) {
1050
+ widget.value.destroy();
1051
+ widget.value = null;
1052
+ }
1053
+ };
1054
+ vue.onMounted(() => {
1055
+ if (config) {
1056
+ init();
1057
+ }
1058
+ });
1059
+ vue.onUnmounted(() => {
1060
+ destroy();
1061
+ });
1062
+ return {
1063
+ widget,
1064
+ init,
1065
+ destroy
1066
+ };
1067
+ }
1068
+ var vue_default = AeoWidgetVue;
1069
+
1070
+ export { AeoWidgetVue, vue_default as default, useAeoWidget };
1071
+ //# sourceMappingURL=vue.mjs.map
1072
+ //# sourceMappingURL=vue.mjs.map