@ecopages/dev-toolbar 0.2.0-beta.30

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 (80) hide show
  1. package/README.md +61 -0
  2. package/package.json +54 -0
  3. package/src/api/dev-manifest.d.ts +33 -0
  4. package/src/api/dev-manifest.js +34 -0
  5. package/src/api/types.d.ts +21 -0
  6. package/src/api/types.js +1 -0
  7. package/src/apps/a11y/a11y-badge.d.ts +3 -0
  8. package/src/apps/a11y/a11y-badge.js +10 -0
  9. package/src/apps/a11y/a11y-issue-groups.d.ts +12 -0
  10. package/src/apps/a11y/a11y-issue-groups.js +27 -0
  11. package/src/apps/a11y/audit-cache.d.ts +6 -0
  12. package/src/apps/a11y/audit-cache.js +16 -0
  13. package/src/apps/a11y/dom-path.d.ts +10 -0
  14. package/src/apps/a11y/dom-path.js +32 -0
  15. package/src/apps/a11y/run-a11y-checks.d.ts +30 -0
  16. package/src/apps/a11y/run-a11y-checks.js +286 -0
  17. package/src/apps/a11y-panel.d.ts +29 -0
  18. package/src/apps/a11y-panel.js +163 -0
  19. package/src/apps/deps/load-deps-insights.d.ts +19 -0
  20. package/src/apps/deps/load-deps-insights.js +76 -0
  21. package/src/apps/deps-panel.d.ts +24 -0
  22. package/src/apps/deps-panel.js +100 -0
  23. package/src/apps/islands-panel.d.ts +26 -0
  24. package/src/apps/islands-panel.js +126 -0
  25. package/src/apps/navigation-panel.d.ts +25 -0
  26. package/src/apps/navigation-panel.js +95 -0
  27. package/src/apps/settings-panel.d.ts +17 -0
  28. package/src/apps/settings-panel.js +58 -0
  29. package/src/bootstrap.d.ts +1 -0
  30. package/src/bootstrap.js +6 -0
  31. package/src/config.d.ts +14 -0
  32. package/src/config.js +10 -0
  33. package/src/islands/island-discovery.d.ts +5 -0
  34. package/src/islands/island-discovery.js +99 -0
  35. package/src/islands/island-record-builder.d.ts +21 -0
  36. package/src/islands/island-record-builder.js +100 -0
  37. package/src/islands/read-island-records.d.ts +11 -0
  38. package/src/islands/read-island-records.js +43 -0
  39. package/src/runtime/constants.d.ts +20 -0
  40. package/src/runtime/constants.js +20 -0
  41. package/src/runtime/highlight-element.d.ts +3 -0
  42. package/src/runtime/highlight-element.js +46 -0
  43. package/src/runtime/navigation-telemetry.d.ts +51 -0
  44. package/src/runtime/navigation-telemetry.js +259 -0
  45. package/src/runtime/preferences.d.ts +9 -0
  46. package/src/runtime/preferences.js +32 -0
  47. package/src/shell/badges.d.ts +2 -0
  48. package/src/shell/badges.js +9 -0
  49. package/src/shell/brand-logo.d.ts +4 -0
  50. package/src/shell/brand-logo.js +4 -0
  51. package/src/shell/eco-dev-toolbar.d.ts +67 -0
  52. package/src/shell/eco-dev-toolbar.js +356 -0
  53. package/src/shell/ensure-dev-toolbar-styles.d.ts +7 -0
  54. package/src/shell/ensure-dev-toolbar-styles.js +18 -0
  55. package/src/shell/icons.d.ts +8 -0
  56. package/src/shell/icons.js +29 -0
  57. package/src/shell/legacy-app-host.d.ts +23 -0
  58. package/src/shell/legacy-app-host.js +36 -0
  59. package/src/shell/motion.d.ts +6 -0
  60. package/src/shell/motion.js +82 -0
  61. package/src/shell/navigation-loading.d.ts +14 -0
  62. package/src/shell/navigation-loading.js +39 -0
  63. package/src/shell/panel-slot-visibility.d.ts +10 -0
  64. package/src/shell/panel-slot-visibility.js +25 -0
  65. package/src/shell/stealth-controller.d.ts +27 -0
  66. package/src/shell/stealth-controller.js +83 -0
  67. package/src/shell/styles/base.d.ts +1 -0
  68. package/src/shell/styles/base.js +65 -0
  69. package/src/shell/styles/content.d.ts +1 -0
  70. package/src/shell/styles/content.js +209 -0
  71. package/src/shell/styles/dock.d.ts +1 -0
  72. package/src/shell/styles/dock.js +207 -0
  73. package/src/shell/styles/index.d.ts +1 -0
  74. package/src/shell/styles/index.js +12 -0
  75. package/src/shell/styles/panel.d.ts +1 -0
  76. package/src/shell/styles/panel.js +121 -0
  77. package/src/shell/styles/settings.d.ts +1 -0
  78. package/src/shell/styles/settings.js +206 -0
  79. package/src/shell/styles.d.ts +1 -0
  80. package/src/shell/styles.js +1 -0
@@ -0,0 +1,95 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { jsx as _jsx, jsxs as _jsxs } from "@ecopages/jsx/jsx-runtime";
8
+ /** @jsxImportSource @ecopages/jsx */
9
+ import { RadiantElement } from '@ecopages/radiant';
10
+ import { customElement } from '@ecopages/radiant/decorators/custom-element';
11
+ import { state } from '@ecopages/radiant/decorators/state';
12
+ import { readDevManifestFromDocument } from '../api/dev-manifest.js';
13
+ import { DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE } from '../runtime/constants.js';
14
+ import { clearNavigationTelemetryHistory, readNavigationTelemetrySnapshot, } from '../runtime/navigation-telemetry.js';
15
+ function formatMs(value) {
16
+ return typeof value === 'number' ? `${value}ms` : 'n/a';
17
+ }
18
+ function formatKind(entry) {
19
+ if (entry.status === 'aborted') {
20
+ return 'aborted';
21
+ }
22
+ return entry.kind;
23
+ }
24
+ let EcoDevToolbarNavigation = class EcoDevToolbarNavigation extends RadiantElement {
25
+ snapshot = readNavigationTelemetrySnapshot();
26
+ manifest = readDevManifestFromDocument();
27
+ historyPage = 0;
28
+ connectedCallback() {
29
+ super.connectedCallback();
30
+ this.ownerDocument.addEventListener('eco:page-load', this.refresh);
31
+ this.ownerDocument.addEventListener('eco:after-swap', this.refresh);
32
+ }
33
+ disconnectedCallback() {
34
+ this.ownerDocument.removeEventListener('eco:page-load', this.refresh);
35
+ this.ownerDocument.removeEventListener('eco:after-swap', this.refresh);
36
+ super.disconnectedCallback();
37
+ }
38
+ refreshSnapshot() {
39
+ this.refresh();
40
+ }
41
+ refresh = () => {
42
+ this.manifest = readDevManifestFromDocument(this.ownerDocument);
43
+ this.snapshot = readNavigationTelemetrySnapshot(this.ownerDocument);
44
+ const totalPages = Math.max(1, Math.ceil((this.snapshot?.history.length ?? 0) / DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE));
45
+ if (this.historyPage > totalPages - 1) {
46
+ this.historyPage = Math.max(0, totalPages - 1);
47
+ }
48
+ };
49
+ resetHistory() {
50
+ this.snapshot = clearNavigationTelemetryHistory() ?? readNavigationTelemetrySnapshot(this.ownerDocument);
51
+ this.historyPage = 0;
52
+ }
53
+ showPreviousHistoryPage() {
54
+ this.historyPage = Math.max(0, this.historyPage - 1);
55
+ }
56
+ showNextHistoryPage() {
57
+ const totalPages = Math.max(1, Math.ceil((this.snapshot?.history.length ?? 0) / DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE));
58
+ this.historyPage = Math.min(totalPages - 1, this.historyPage + 1);
59
+ }
60
+ renderRow(entry) {
61
+ const routeLabel = entry.fromRoute ? `${entry.fromRoute} → ${entry.route}` : entry.route;
62
+ const kind = formatKind(entry);
63
+ return (_jsxs("tr", { children: [_jsx("td", { children: entry.status === 'aborted' ? (_jsx("span", { class: "eco-dev-toolbar__status-pill", "data-status": "aborted", children: "aborted" })) : (kind) }), _jsx("td", { class: "eco-dev-toolbar__mono", children: routeLabel }), _jsx("td", { children: formatMs(entry.durationMs ?? entry.swapMs) }), _jsx("td", { children: formatMs(entry.hydrationMs) })] }, entry.id));
64
+ }
65
+ renderHistoryPagination(totalEntries, totalPages) {
66
+ if (totalEntries <= DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE) {
67
+ return null;
68
+ }
69
+ const start = this.historyPage * DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE + 1;
70
+ const end = Math.min(totalEntries, (this.historyPage + 1) * DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE);
71
+ return (_jsxs("div", { class: "eco-dev-toolbar__pagination", children: [_jsxs("p", { class: "eco-dev-toolbar__pagination-copy", children: ["Showing ", start, "-", end, " of ", totalEntries] }), _jsxs("div", { class: "eco-dev-toolbar__pagination-actions", children: [_jsx("button", { type: "button", class: "eco-dev-toolbar__pagination-button", disabled: this.historyPage === 0, "on:click": () => this.showPreviousHistoryPage(), children: "Previous" }), _jsx("button", { type: "button", class: "eco-dev-toolbar__pagination-button", disabled: this.historyPage >= totalPages - 1, "on:click": () => this.showNextHistoryPage(), children: "Next" })] })] }));
72
+ }
73
+ render() {
74
+ const hmrConnected = Boolean(window.__ECO_HMR_CONNECTED__);
75
+ const history = [...(this.snapshot?.history ?? [])].reverse();
76
+ const totalPages = Math.max(1, Math.ceil(history.length / DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE));
77
+ const page = Math.min(this.historyPage, totalPages - 1);
78
+ const rows = history.slice(page * DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE, (page + 1) * DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE);
79
+ const hasHistory = history.length > 0;
80
+ return (_jsxs("section", { class: "eco-dev-toolbar__panel", children: [_jsx("header", { class: "eco-dev-toolbar__settings-header", children: _jsx("h2", { children: "Navigation" }) }), _jsxs("dl", { class: "eco-dev-toolbar__kv", children: [_jsxs("div", { children: [_jsx("dt", { children: "Route" }), _jsx("dd", { children: this.snapshot?.currentRoute ?? `${window.location.pathname}${window.location.search}` })] }), _jsxs("div", { children: [_jsx("dt", { children: "Integration" }), _jsx("dd", { children: this.manifest?.integration ?? 'unknown' })] }), _jsxs("div", { children: [_jsx("dt", { children: "HMR" }), _jsx("dd", { children: hmrConnected ? 'connected' : 'disconnected' })] }), _jsxs("div", { children: [_jsx("dt", { children: "Initial load" }), _jsx("dd", { children: formatMs(this.snapshot?.summary.initialLoadMs) })] }), _jsxs("div", { children: [_jsx("dt", { children: "Last navigation" }), _jsx("dd", { children: formatMs(this.snapshot?.summary.lastNavigationMs) })] }), _jsxs("div", { children: [_jsx("dt", { children: "Average navigation" }), _jsx("dd", { children: formatMs(this.snapshot?.summary.averageNavigationMs) })] }), _jsxs("div", { children: [_jsx("dt", { children: "Archive" }), _jsxs("dd", { children: [this.snapshot?.summary.navigationCount ?? 0, " client navigations"] })] })] }), _jsxs("div", { class: "eco-dev-toolbar__settings-section eco-dev-toolbar__history-section", children: [_jsxs("div", { class: "eco-dev-toolbar__section-header", children: [_jsx("h3", { class: "eco-dev-toolbar__settings-title", children: "Recent timings" }), _jsx("button", { type: "button", class: "eco-dev-toolbar__pagination-button", disabled: !hasHistory, "on:click": () => this.resetHistory(), children: "Reset" })] }), this.renderHistoryPagination(history.length, totalPages), _jsx("div", { class: "eco-dev-toolbar__table-wrap", children: _jsxs("table", { class: "eco-dev-toolbar__table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "Kind" }), _jsx("th", { scope: "col", children: "Route" }), _jsx("th", { scope: "col", children: "Duration" }), _jsx("th", { scope: "col", children: "Hydration" })] }) }), _jsx("tbody", { children: rows.length > 0 ? (rows.map((entry) => this.renderRow(entry))) : (_jsx("tr", { children: _jsx("td", { colspan: "4", class: "eco-dev-toolbar__muted", children: "No navigation samples yet." }) })) })] }) })] }), _jsxs("p", { class: "eco-dev-toolbar__muted", children: ["Route timing, swap latency, and a machine-readable trace in ", _jsx("code", { children: "#__ECO_DEV_NAV_TELEMETRY__" }), "."] })] }));
81
+ }
82
+ };
83
+ __decorate([
84
+ state
85
+ ], EcoDevToolbarNavigation.prototype, "snapshot", void 0);
86
+ __decorate([
87
+ state
88
+ ], EcoDevToolbarNavigation.prototype, "manifest", void 0);
89
+ __decorate([
90
+ state
91
+ ], EcoDevToolbarNavigation.prototype, "historyPage", void 0);
92
+ EcoDevToolbarNavigation = __decorate([
93
+ customElement('eco-dev-toolbar-navigation')
94
+ ], EcoDevToolbarNavigation);
95
+ export { EcoDevToolbarNavigation };
@@ -0,0 +1,17 @@
1
+ /** @jsxImportSource @ecopages/jsx */
2
+ import { RadiantElement } from '@ecopages/radiant';
3
+ import type { JsxCustomElementAttributes } from '@ecopages/jsx';
4
+ import { type DevToolbarPlacement } from '../runtime/preferences.js';
5
+ export declare class EcoDevToolbarSettings extends RadiantElement {
6
+ placement: DevToolbarPlacement;
7
+ stealth: boolean;
8
+ private get toolbar();
9
+ private handlePlacementChange;
10
+ private handleStealthChange;
11
+ render(): import("@ecopages/jsx").JsxRenderable;
12
+ }
13
+ declare module '@ecopages/jsx' {
14
+ interface JsxCustomIntrinsicElements {
15
+ 'eco-dev-toolbar-settings': JsxCustomElementAttributes<EcoDevToolbarSettings>;
16
+ }
17
+ }
@@ -0,0 +1,58 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { jsx as _jsx, jsxs as _jsxs } from "@ecopages/jsx/jsx-runtime";
8
+ /** @jsxImportSource @ecopages/jsx */
9
+ import { RadiantElement } from '@ecopages/radiant';
10
+ import { customElement } from '@ecopages/radiant/decorators/custom-element';
11
+ import { state } from '@ecopages/radiant/decorators/state';
12
+ import { ECOPAGES_DOCS_URL } from '../runtime/constants.js';
13
+ import { parseDevToolbarPlacement, readDevToolbarPreferences, writeDevToolbarPreferences, } from '../runtime/preferences.js';
14
+ const PLACEMENT_OPTIONS = [
15
+ { value: 'bottom', label: 'Bottom' },
16
+ { value: 'top', label: 'Top' },
17
+ { value: 'left', label: 'Left' },
18
+ { value: 'right', label: 'Right' },
19
+ ];
20
+ let EcoDevToolbarSettings = class EcoDevToolbarSettings extends RadiantElement {
21
+ placement = readDevToolbarPreferences().placement;
22
+ stealth = readDevToolbarPreferences().stealth;
23
+ get toolbar() {
24
+ return this.closest('eco-dev-toolbar');
25
+ }
26
+ handlePlacementChange(event) {
27
+ const target = event.currentTarget;
28
+ if (!(target instanceof HTMLSelectElement)) {
29
+ return;
30
+ }
31
+ const placement = parseDevToolbarPlacement(target.value);
32
+ this.placement = placement;
33
+ writeDevToolbarPreferences({ placement });
34
+ this.toolbar?.applyPreferences({ placement });
35
+ }
36
+ handleStealthChange(event) {
37
+ const target = event.currentTarget;
38
+ if (!(target instanceof HTMLInputElement)) {
39
+ return;
40
+ }
41
+ this.stealth = target.checked;
42
+ writeDevToolbarPreferences({ stealth: this.stealth });
43
+ this.toolbar?.applyPreferences({ stealth: this.stealth });
44
+ }
45
+ render() {
46
+ return (_jsxs("section", { class: "eco-dev-toolbar__panel", children: [_jsxs("header", { class: "eco-dev-toolbar__settings-header", children: [_jsx("h2", { children: "Settings" }), _jsx("p", { class: "eco-dev-toolbar__muted", children: "Customize the Ecopages dev toolbar." })] }), _jsxs("div", { class: "eco-dev-toolbar__settings-section", children: [_jsx("h3", { class: "eco-dev-toolbar__settings-title", children: "Dock" }), _jsxs("label", { class: "eco-dev-toolbar__setting-row", children: [_jsxs("span", { class: "eco-dev-toolbar__setting-copy", children: [_jsx("strong", { children: "Placement" }), _jsx("span", { class: "eco-dev-toolbar__muted", children: "Where the dock appears on screen." })] }), _jsx("span", { class: "eco-dev-toolbar__select-wrap", children: _jsx("select", { class: "eco-dev-toolbar__select", value: this.placement, "on:change": (event) => this.handlePlacementChange(event), children: PLACEMENT_OPTIONS.map((option) => (_jsx("option", { value: option.value, selected: this.placement === option.value, children: option.label }))) }) })] }), _jsxs("label", { class: "eco-dev-toolbar__setting-row", children: [_jsxs("span", { class: "eco-dev-toolbar__setting-copy", children: [_jsx("strong", { children: "Stealth mode" }), _jsx("span", { class: "eco-dev-toolbar__muted", children: "Hide the dock after 8s idle (4s visible, 4s fade)." })] }), _jsxs("span", { class: "eco-dev-toolbar__switch", children: [_jsx("input", { type: "checkbox", checked: this.stealth, "on:change": (event) => this.handleStealthChange(event) }), _jsx("span", { class: "eco-dev-toolbar__switch-track", "aria-hidden": "true" })] })] })] }), _jsxs("div", { class: "eco-dev-toolbar__settings-section", children: [_jsx("h3", { class: "eco-dev-toolbar__settings-title", children: "Resources" }), _jsxs("a", { class: "eco-dev-toolbar__settings-link", href: ECOPAGES_DOCS_URL, target: "_blank", rel: "noopener noreferrer", children: [_jsxs("span", { children: [_jsx("strong", { children: "Documentation" }), _jsx("span", { class: "eco-dev-toolbar__muted", children: "Guides, API reference, and integrations." })] }), _jsx("span", { class: "eco-dev-toolbar__settings-link-icon", "aria-hidden": "true", children: "\u2197" })] })] })] }));
47
+ }
48
+ };
49
+ __decorate([
50
+ state
51
+ ], EcoDevToolbarSettings.prototype, "placement", void 0);
52
+ __decorate([
53
+ state
54
+ ], EcoDevToolbarSettings.prototype, "stealth", void 0);
55
+ EcoDevToolbarSettings = __decorate([
56
+ customElement('eco-dev-toolbar-settings')
57
+ ], EcoDevToolbarSettings);
58
+ export { EcoDevToolbarSettings };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { initNavigationTelemetry } from './runtime/navigation-telemetry.js';
2
+ import { EcoDevToolbar } from './shell/eco-dev-toolbar.js';
3
+ import { ensureDevToolbarStyles } from './shell/ensure-dev-toolbar-styles.js';
4
+ ensureDevToolbarStyles();
5
+ initNavigationTelemetry();
6
+ EcoDevToolbar.mount();
@@ -0,0 +1,14 @@
1
+ declare const PACKAGE_NAME: "@ecopages/dev-toolbar";
2
+ export type DevToolbarOptions = {
3
+ /** @default true */
4
+ enabled?: boolean;
5
+ };
6
+ export type DevToolbarConfig = {
7
+ package: typeof PACKAGE_NAME;
8
+ enabled?: boolean;
9
+ };
10
+ /**
11
+ * Returns the `devToolbar` config block for {@link ConfigBuilder.setDevToolbar}.
12
+ */
13
+ export declare function devToolbar(options?: DevToolbarOptions): DevToolbarConfig;
14
+ export {};
package/src/config.js ADDED
@@ -0,0 +1,10 @@
1
+ const PACKAGE_NAME = '@ecopages/dev-toolbar';
2
+ /**
3
+ * Returns the `devToolbar` config block for {@link ConfigBuilder.setDevToolbar}.
4
+ */
5
+ export function devToolbar(options) {
6
+ return {
7
+ package: PACKAGE_NAME,
8
+ ...(options?.enabled === undefined ? {} : { enabled: options.enabled }),
9
+ };
10
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Collects unique island host elements from the live document.
3
+ */
4
+ export declare function discoverIslandElements(doc: Document): HTMLElement[];
5
+ export declare function readIslandRoots(): Record<string, unknown>;
@@ -0,0 +1,99 @@
1
+ function isToolbarElement(element) {
2
+ return element.tagName.toLowerCase() === 'eco-dev-toolbar';
3
+ }
4
+ function islandPriority(element) {
5
+ if (!element.isConnected) {
6
+ return -1;
7
+ }
8
+ const tag = element.tagName.toLowerCase();
9
+ if (tag === 'eco-island') {
10
+ return 100;
11
+ }
12
+ if (element.hasAttribute('data-eco-island')) {
13
+ return 90;
14
+ }
15
+ if (element.hasAttribute('data-eco-component-key')) {
16
+ return 80;
17
+ }
18
+ if (element.hasAttribute('data-eco-component-id')) {
19
+ return 70;
20
+ }
21
+ return 10;
22
+ }
23
+ function getDedupeKey(element, doc) {
24
+ const componentKey = element.getAttribute('data-eco-component-key');
25
+ if (componentKey) {
26
+ return `key:${componentKey}`;
27
+ }
28
+ const componentId = element.getAttribute('data-eco-component-id');
29
+ if (componentId) {
30
+ return `id:${componentId}`;
31
+ }
32
+ if (element.id) {
33
+ return `dom-id:${element.id}`;
34
+ }
35
+ const tag = element.tagName.toLowerCase();
36
+ if (tag.includes('-')) {
37
+ const index = [...(element.parentElement?.children ?? [])].indexOf(element);
38
+ return `custom:${tag}:${index}`;
39
+ }
40
+ const index = [...doc.querySelectorAll(tag)].indexOf(element);
41
+ return `tag:${tag}:${index}`;
42
+ }
43
+ function addCandidate(candidates, element) {
44
+ if (!isToolbarElement(element)) {
45
+ candidates.add(element);
46
+ }
47
+ }
48
+ /**
49
+ * Collects unique island host elements from the live document.
50
+ */
51
+ export function discoverIslandElements(doc) {
52
+ const candidates = new Set();
53
+ for (const element of doc.querySelectorAll('[data-eco-island]')) {
54
+ addCandidate(candidates, element);
55
+ }
56
+ for (const element of doc.querySelectorAll('[data-eco-component-key]')) {
57
+ addCandidate(candidates, element);
58
+ }
59
+ for (const element of doc.querySelectorAll('eco-island')) {
60
+ addCandidate(candidates, element);
61
+ }
62
+ const islandRoots = window.__ECO_PAGES__?.islandRoots ?? {};
63
+ for (const componentKey of Object.keys(islandRoots)) {
64
+ const escapedKey = CSS.escape(componentKey);
65
+ for (const element of doc.querySelectorAll(`[data-eco-component-key="${escapedKey}"]`)) {
66
+ addCandidate(candidates, element);
67
+ }
68
+ for (const element of doc.querySelectorAll(`eco-island[data-eco-component-key="${escapedKey}"]`)) {
69
+ addCandidate(candidates, element);
70
+ }
71
+ }
72
+ const deduped = new Map();
73
+ for (const element of candidates) {
74
+ if (!element.isConnected) {
75
+ continue;
76
+ }
77
+ const key = getDedupeKey(element, doc);
78
+ const existing = deduped.get(key);
79
+ if (!existing || islandPriority(element) > islandPriority(existing)) {
80
+ deduped.set(key, element);
81
+ }
82
+ }
83
+ return [...deduped.values()].sort((left, right) => {
84
+ if (left === right) {
85
+ return 0;
86
+ }
87
+ const position = left.compareDocumentPosition(right);
88
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
89
+ return -1;
90
+ }
91
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
92
+ return 1;
93
+ }
94
+ return 0;
95
+ });
96
+ }
97
+ export function readIslandRoots() {
98
+ return window.__ECO_PAGES__?.islandRoots ?? {};
99
+ }
@@ -0,0 +1,21 @@
1
+ export type IslandRecord = {
2
+ id: string;
3
+ label: string;
4
+ componentKey?: string;
5
+ componentId?: string;
6
+ hostTag: string;
7
+ kind: 'react-island' | 'integration' | 'custom-element';
8
+ integration?: string;
9
+ propsPreview: string;
10
+ hydrated: boolean;
11
+ element: HTMLElement;
12
+ };
13
+ export type IslandRecordView = Omit<IslandRecord, 'element'> & {
14
+ targetSelector: string;
15
+ };
16
+ export declare function buildIslandTargetSelector(element: HTMLElement, record: Pick<IslandRecord, 'componentKey' | 'componentId'>): string;
17
+ export declare function toIslandRecordView(record: IslandRecord): IslandRecordView;
18
+ /**
19
+ * Builds one island record from a discovered host element.
20
+ */
21
+ export declare function buildIslandRecord(element: HTMLElement, islandRoots: Record<string, unknown>): IslandRecord;
@@ -0,0 +1,100 @@
1
+ function parsePropsPreview(encoded) {
2
+ if (!encoded) {
3
+ return '';
4
+ }
5
+ try {
6
+ return JSON.stringify(JSON.parse(atob(encoded)), null, 0).slice(0, 120);
7
+ }
8
+ catch {
9
+ return '(invalid props)';
10
+ }
11
+ }
12
+ function isHydratedIsland(element, componentKey, islandRoots) {
13
+ if (componentKey && islandRoots[componentKey]) {
14
+ return true;
15
+ }
16
+ if (element.tagName.toLowerCase() === 'eco-island') {
17
+ return element.childElementCount > 0;
18
+ }
19
+ return false;
20
+ }
21
+ function buildLabel(element, componentKey, componentId, integration) {
22
+ if (componentId) {
23
+ return componentId;
24
+ }
25
+ if (componentKey) {
26
+ const segments = componentKey.split('/');
27
+ return segments[segments.length - 1] || componentKey;
28
+ }
29
+ if (integration) {
30
+ return `${integration} island`;
31
+ }
32
+ if (element.id) {
33
+ return element.id;
34
+ }
35
+ return element.tagName.toLowerCase();
36
+ }
37
+ function getIslandKind(element, componentKey, integration) {
38
+ if (integration === 'react' || componentKey || element.tagName.toLowerCase() === 'eco-island') {
39
+ return 'react-island';
40
+ }
41
+ if (integration) {
42
+ return 'integration';
43
+ }
44
+ return 'custom-element';
45
+ }
46
+ export function buildIslandTargetSelector(element, record) {
47
+ if (record.componentKey) {
48
+ return `[data-eco-component-key="${CSS.escape(record.componentKey)}"]`;
49
+ }
50
+ if (record.componentId) {
51
+ return `[data-eco-component-id="${CSS.escape(record.componentId)}"]`;
52
+ }
53
+ if (element.id) {
54
+ return `#${CSS.escape(element.id)}`;
55
+ }
56
+ const segments = [];
57
+ let current = element;
58
+ while (current && current !== current.ownerDocument.documentElement) {
59
+ let segment = current.tagName.toLowerCase();
60
+ const parent = current.parentElement;
61
+ if (parent) {
62
+ const siblings = [...parent.children].filter((child) => child.tagName === current.tagName);
63
+ if (siblings.length > 1) {
64
+ segment += `:nth-of-type(${siblings.indexOf(current) + 1})`;
65
+ }
66
+ }
67
+ segments.unshift(segment);
68
+ current = parent;
69
+ }
70
+ return segments.join(' > ');
71
+ }
72
+ export function toIslandRecordView(record) {
73
+ const { element, ...view } = record;
74
+ return {
75
+ ...view,
76
+ targetSelector: buildIslandTargetSelector(element, record),
77
+ };
78
+ }
79
+ /**
80
+ * Builds one island record from a discovered host element.
81
+ */
82
+ export function buildIslandRecord(element, islandRoots) {
83
+ const componentKey = element.getAttribute('data-eco-component-key') ?? undefined;
84
+ const componentId = element.getAttribute('data-eco-component-id') ?? undefined;
85
+ const integration = element.getAttribute('data-eco-island-integration') ?? undefined;
86
+ const label = buildLabel(element, componentKey, componentId, integration);
87
+ const id = componentId ?? componentKey ?? label;
88
+ return {
89
+ id,
90
+ label,
91
+ componentKey,
92
+ componentId,
93
+ integration,
94
+ hostTag: element.tagName.toLowerCase(),
95
+ kind: getIslandKind(element, componentKey, integration),
96
+ propsPreview: parsePropsPreview(element.getAttribute('data-eco-props')),
97
+ hydrated: isHydratedIsland(element, componentKey, islandRoots),
98
+ element,
99
+ };
100
+ }
@@ -0,0 +1,11 @@
1
+ import { type IslandRecord, type IslandRecordView } from './island-record-builder.js';
2
+ export type { IslandRecord, IslandRecordView } from './island-record-builder.js';
3
+ export { toIslandRecordView } from './island-record-builder.js';
4
+ /**
5
+ * Resolves the live DOM node for an island record after hydration or route swaps.
6
+ */
7
+ export declare function resolveIslandElement(record: IslandRecordView, doc?: Document): HTMLElement | null;
8
+ /**
9
+ * Collects island hosts stamped by core (`data-eco-island`) plus legacy React hydration roots.
10
+ */
11
+ export declare function readIslandRecords(doc?: Document): IslandRecord[];
@@ -0,0 +1,43 @@
1
+ import { discoverIslandElements, readIslandRoots } from './island-discovery.js';
2
+ import { buildIslandRecord } from './island-record-builder.js';
3
+ export { toIslandRecordView } from './island-record-builder.js';
4
+ /**
5
+ * Resolves the live DOM node for an island record after hydration or route swaps.
6
+ */
7
+ export function resolveIslandElement(record, doc = document) {
8
+ if (record.componentKey) {
9
+ const escapedKey = CSS.escape(record.componentKey);
10
+ const hydratedIsland = doc.querySelector(`eco-island[data-eco-component-key="${escapedKey}"]`);
11
+ if (hydratedIsland instanceof HTMLElement && hydratedIsland.isConnected) {
12
+ return hydratedIsland;
13
+ }
14
+ const keyedHost = doc.querySelector(`[data-eco-component-key="${escapedKey}"]`);
15
+ if (keyedHost instanceof HTMLElement && keyedHost.isConnected) {
16
+ return keyedHost;
17
+ }
18
+ }
19
+ if (record.componentId) {
20
+ const escapedId = CSS.escape(record.componentId);
21
+ const hostById = doc.querySelector(`[data-eco-component-id="${escapedId}"]`);
22
+ if (hostById instanceof HTMLElement && hostById.isConnected) {
23
+ return hostById;
24
+ }
25
+ }
26
+ try {
27
+ const fallback = doc.querySelector(record.targetSelector);
28
+ if (fallback instanceof HTMLElement && fallback.isConnected) {
29
+ return fallback;
30
+ }
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ return null;
36
+ }
37
+ /**
38
+ * Collects island hosts stamped by core (`data-eco-island`) plus legacy React hydration roots.
39
+ */
40
+ export function readIslandRecords(doc = document) {
41
+ const islandRoots = readIslandRoots();
42
+ return discoverIslandElements(doc).map((element) => buildIslandRecord(element, islandRoots));
43
+ }
@@ -0,0 +1,20 @@
1
+ export declare const ECOPAGES_DOCS_URL = "https://ecopages.app";
2
+ export declare const DEV_TOOLBAR_ELEMENT_NAME = "eco-dev-toolbar";
3
+ export declare const DEV_TOOLBAR_PERSIST_KEY = "eco-dev-toolbar";
4
+ export declare const DEV_TOOLBAR_PLACEMENT_STORAGE_KEY = "ecopages:dev-toolbar:placement";
5
+ export declare const DEV_TOOLBAR_STEALTH_STORAGE_KEY = "ecopages:dev-toolbar:stealth";
6
+ export declare const DEV_TOOLBAR_NAVIGATION_APP_ID = "navigation";
7
+ /** Full-opacity dwell after hover ends, before the fade phase. */
8
+ export declare const DEV_TOOLBAR_STEALTH_DWELL_MS = 4000;
9
+ /** Partial-opacity fade before the dock hides off-screen. */
10
+ export declare const DEV_TOOLBAR_STEALTH_FADE_MS = 4000;
11
+ /** Total idle time before the dock is fully hidden in stealth mode. */
12
+ export declare const DEV_TOOLBAR_STEALTH_IDLE_MS: number;
13
+ /** Wait before showing the navigation dock spinner during route changes. */
14
+ export declare const DEV_TOOLBAR_NAVIGATION_LOADING_DELAY_MS = 100;
15
+ /** Clears navigation loading if no lifecycle end event arrives. */
16
+ export declare const DEV_TOOLBAR_NAVIGATION_LOADING_TIMEOUT_MS = 8000;
17
+ /** Client navigation rows shown per page in the Navigation panel. */
18
+ export declare const DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE = 8;
19
+ /** Debounce route-driven deps refresh to avoid rapid manifest churn. */
20
+ export declare const DEV_TOOLBAR_DEPS_REFRESH_DEBOUNCE_MS = 250;
@@ -0,0 +1,20 @@
1
+ export const ECOPAGES_DOCS_URL = 'https://ecopages.app';
2
+ export const DEV_TOOLBAR_ELEMENT_NAME = 'eco-dev-toolbar';
3
+ export const DEV_TOOLBAR_PERSIST_KEY = 'eco-dev-toolbar';
4
+ export const DEV_TOOLBAR_PLACEMENT_STORAGE_KEY = 'ecopages:dev-toolbar:placement';
5
+ export const DEV_TOOLBAR_STEALTH_STORAGE_KEY = 'ecopages:dev-toolbar:stealth';
6
+ export const DEV_TOOLBAR_NAVIGATION_APP_ID = 'navigation';
7
+ /** Full-opacity dwell after hover ends, before the fade phase. */
8
+ export const DEV_TOOLBAR_STEALTH_DWELL_MS = 4_000;
9
+ /** Partial-opacity fade before the dock hides off-screen. */
10
+ export const DEV_TOOLBAR_STEALTH_FADE_MS = 4_000;
11
+ /** Total idle time before the dock is fully hidden in stealth mode. */
12
+ export const DEV_TOOLBAR_STEALTH_IDLE_MS = DEV_TOOLBAR_STEALTH_DWELL_MS + DEV_TOOLBAR_STEALTH_FADE_MS;
13
+ /** Wait before showing the navigation dock spinner during route changes. */
14
+ export const DEV_TOOLBAR_NAVIGATION_LOADING_DELAY_MS = 100;
15
+ /** Clears navigation loading if no lifecycle end event arrives. */
16
+ export const DEV_TOOLBAR_NAVIGATION_LOADING_TIMEOUT_MS = 8_000;
17
+ /** Client navigation rows shown per page in the Navigation panel. */
18
+ export const DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE = 8;
19
+ /** Debounce route-driven deps refresh to avoid rapid manifest churn. */
20
+ export const DEV_TOOLBAR_DEPS_REFRESH_DEBOUNCE_MS = 250;
@@ -0,0 +1,3 @@
1
+ export type DevToolbarHighlightTone = 'a11y' | 'island';
2
+ export declare function highlightElement(element: HTMLElement, tone?: DevToolbarHighlightTone): () => void;
3
+ export declare function clearElementHighlight(element: Element | null | undefined): void;
@@ -0,0 +1,46 @@
1
+ const HIGHLIGHT_CLASS = 'eco-dev-toolbar__dom-highlight';
2
+ const HIGHLIGHT_OUTLINE = {
3
+ a11y: '2px solid #ff5c7a',
4
+ island: '2px solid #7c5cff',
5
+ };
6
+ function focusElement(element) {
7
+ if (element.matches('a[href], button, input, textarea, select, [tabindex]:not([tabindex="-1"])')) {
8
+ element.focus({ preventScroll: true });
9
+ return { addedTabIndex: false };
10
+ }
11
+ if (!element.hasAttribute('tabindex')) {
12
+ element.setAttribute('tabindex', '-1');
13
+ element.focus({ preventScroll: true });
14
+ return { addedTabIndex: true };
15
+ }
16
+ element.focus({ preventScroll: true });
17
+ return { addedTabIndex: false };
18
+ }
19
+ export function highlightElement(element, tone = 'a11y') {
20
+ const previousOutline = element.style.outline;
21
+ const previousOutlineOffset = element.style.outlineOffset;
22
+ const { addedTabIndex } = focusElement(element);
23
+ element.classList.add(HIGHLIGHT_CLASS);
24
+ element.dataset.ecoDevToolbarHighlight = tone;
25
+ element.style.outline = HIGHLIGHT_OUTLINE[tone];
26
+ element.style.outlineOffset = '2px';
27
+ element.scrollIntoView({ block: 'center', behavior: 'smooth' });
28
+ return () => {
29
+ element.style.outline = previousOutline;
30
+ element.style.outlineOffset = previousOutlineOffset;
31
+ element.classList.remove(HIGHLIGHT_CLASS);
32
+ delete element.dataset.ecoDevToolbarHighlight;
33
+ if (addedTabIndex) {
34
+ element.removeAttribute('tabindex');
35
+ }
36
+ };
37
+ }
38
+ export function clearElementHighlight(element) {
39
+ if (!(element instanceof HTMLElement)) {
40
+ return;
41
+ }
42
+ element.style.outline = '';
43
+ element.style.outlineOffset = '';
44
+ element.classList.remove(HIGHLIGHT_CLASS);
45
+ delete element.dataset.ecoDevToolbarHighlight;
46
+ }
@@ -0,0 +1,51 @@
1
+ export declare const NAV_TELEMETRY_ELEMENT_ID = "__ECO_DEV_NAV_TELEMETRY__";
2
+ export declare const NAV_TELEMETRY_STORAGE_KEY = "ecopages:dev-toolbar:nav-telemetry";
3
+ export declare const NAV_TELEMETRY_MAX_ENTRIES = 50;
4
+ export type NavigationTelemetryKind = 'initial' | 'client-navigation';
5
+ export type NavigationTelemetryStatus = 'completed' | 'aborted';
6
+ export type NavigationTimingMetrics = {
7
+ ttfbMs?: number;
8
+ domInteractiveMs?: number;
9
+ loadEventMs?: number;
10
+ domContentLoadedMs?: number;
11
+ };
12
+ export type NavigationTelemetryEntry = {
13
+ id: string;
14
+ kind: NavigationTelemetryKind;
15
+ route: string;
16
+ fromRoute?: string;
17
+ startedAt: string;
18
+ endedAt?: string;
19
+ durationMs?: number;
20
+ swapMs?: number;
21
+ hydrationMs?: number;
22
+ navigationOwner?: string;
23
+ status?: NavigationTelemetryStatus;
24
+ navigationTiming?: NavigationTimingMetrics;
25
+ };
26
+ export type NavigationTelemetrySummary = {
27
+ initialLoadMs?: number;
28
+ lastNavigationMs?: number;
29
+ averageNavigationMs?: number;
30
+ navigationCount: number;
31
+ };
32
+ export type NavigationTelemetrySnapshot = {
33
+ updatedAt: string;
34
+ currentRoute: string;
35
+ active: NavigationTelemetryEntry | null;
36
+ history: NavigationTelemetryEntry[];
37
+ summary: NavigationTelemetrySummary;
38
+ };
39
+ export type NavigationTelemetryApi = {
40
+ getSnapshot: () => NavigationTelemetrySnapshot;
41
+ clearHistory: () => NavigationTelemetrySnapshot;
42
+ };
43
+ /** @internal */
44
+ export declare function resetNavigationTelemetryForTests(): void;
45
+ /**
46
+ * Boots route timing collection, DOM JSON trace export, and `window.__ECO_DEV_NAV_TELEMETRY__`.
47
+ */
48
+ export declare function initNavigationTelemetry(doc?: Document): NavigationTelemetryApi;
49
+ export declare function readNavigationTelemetrySnapshot(doc?: Document): NavigationTelemetrySnapshot | undefined;
50
+ /** Clears persisted navigation history and the DOM telemetry trace. */
51
+ export declare function clearNavigationTelemetryHistory(): NavigationTelemetrySnapshot | undefined;