@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.
- package/README.md +61 -0
- package/package.json +54 -0
- package/src/api/dev-manifest.d.ts +33 -0
- package/src/api/dev-manifest.js +34 -0
- package/src/api/types.d.ts +21 -0
- package/src/api/types.js +1 -0
- package/src/apps/a11y/a11y-badge.d.ts +3 -0
- package/src/apps/a11y/a11y-badge.js +10 -0
- package/src/apps/a11y/a11y-issue-groups.d.ts +12 -0
- package/src/apps/a11y/a11y-issue-groups.js +27 -0
- package/src/apps/a11y/audit-cache.d.ts +6 -0
- package/src/apps/a11y/audit-cache.js +16 -0
- package/src/apps/a11y/dom-path.d.ts +10 -0
- package/src/apps/a11y/dom-path.js +32 -0
- package/src/apps/a11y/run-a11y-checks.d.ts +30 -0
- package/src/apps/a11y/run-a11y-checks.js +286 -0
- package/src/apps/a11y-panel.d.ts +29 -0
- package/src/apps/a11y-panel.js +163 -0
- package/src/apps/deps/load-deps-insights.d.ts +19 -0
- package/src/apps/deps/load-deps-insights.js +76 -0
- package/src/apps/deps-panel.d.ts +24 -0
- package/src/apps/deps-panel.js +100 -0
- package/src/apps/islands-panel.d.ts +26 -0
- package/src/apps/islands-panel.js +126 -0
- package/src/apps/navigation-panel.d.ts +25 -0
- package/src/apps/navigation-panel.js +95 -0
- package/src/apps/settings-panel.d.ts +17 -0
- package/src/apps/settings-panel.js +58 -0
- package/src/bootstrap.d.ts +1 -0
- package/src/bootstrap.js +6 -0
- package/src/config.d.ts +14 -0
- package/src/config.js +10 -0
- package/src/islands/island-discovery.d.ts +5 -0
- package/src/islands/island-discovery.js +99 -0
- package/src/islands/island-record-builder.d.ts +21 -0
- package/src/islands/island-record-builder.js +100 -0
- package/src/islands/read-island-records.d.ts +11 -0
- package/src/islands/read-island-records.js +43 -0
- package/src/runtime/constants.d.ts +20 -0
- package/src/runtime/constants.js +20 -0
- package/src/runtime/highlight-element.d.ts +3 -0
- package/src/runtime/highlight-element.js +46 -0
- package/src/runtime/navigation-telemetry.d.ts +51 -0
- package/src/runtime/navigation-telemetry.js +259 -0
- package/src/runtime/preferences.d.ts +9 -0
- package/src/runtime/preferences.js +32 -0
- package/src/shell/badges.d.ts +2 -0
- package/src/shell/badges.js +9 -0
- package/src/shell/brand-logo.d.ts +4 -0
- package/src/shell/brand-logo.js +4 -0
- package/src/shell/eco-dev-toolbar.d.ts +67 -0
- package/src/shell/eco-dev-toolbar.js +356 -0
- package/src/shell/ensure-dev-toolbar-styles.d.ts +7 -0
- package/src/shell/ensure-dev-toolbar-styles.js +18 -0
- package/src/shell/icons.d.ts +8 -0
- package/src/shell/icons.js +29 -0
- package/src/shell/legacy-app-host.d.ts +23 -0
- package/src/shell/legacy-app-host.js +36 -0
- package/src/shell/motion.d.ts +6 -0
- package/src/shell/motion.js +82 -0
- package/src/shell/navigation-loading.d.ts +14 -0
- package/src/shell/navigation-loading.js +39 -0
- package/src/shell/panel-slot-visibility.d.ts +10 -0
- package/src/shell/panel-slot-visibility.js +25 -0
- package/src/shell/stealth-controller.d.ts +27 -0
- package/src/shell/stealth-controller.js +83 -0
- package/src/shell/styles/base.d.ts +1 -0
- package/src/shell/styles/base.js +65 -0
- package/src/shell/styles/content.d.ts +1 -0
- package/src/shell/styles/content.js +209 -0
- package/src/shell/styles/dock.d.ts +1 -0
- package/src/shell/styles/dock.js +207 -0
- package/src/shell/styles/index.d.ts +1 -0
- package/src/shell/styles/index.js +12 -0
- package/src/shell/styles/panel.d.ts +1 -0
- package/src/shell/styles/panel.js +121 -0
- package/src/shell/styles/settings.d.ts +1 -0
- package/src/shell/styles/settings.js +206 -0
- package/src/shell/styles.d.ts +1 -0
- package/src/shell/styles.js +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @jsxImportSource @ecopages/jsx */
|
|
2
|
+
import { RadiantElement } from '@ecopages/radiant';
|
|
3
|
+
import type { JsxCustomElementAttributes } from '@ecopages/jsx';
|
|
4
|
+
import { type A11yIssueView } from './a11y/run-a11y-checks.js';
|
|
5
|
+
export declare class EcoDevToolbarA11y extends RadiantElement {
|
|
6
|
+
axeRunning: boolean;
|
|
7
|
+
issues: A11yIssueView[];
|
|
8
|
+
highlightedGroupIndex: number | null;
|
|
9
|
+
highlightedNodeIndex: number;
|
|
10
|
+
private auditGeneration;
|
|
11
|
+
private auditDebounceTimer;
|
|
12
|
+
private clearHighlight;
|
|
13
|
+
private get toolbar();
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
16
|
+
private readonly scheduleAudit;
|
|
17
|
+
private applyAuditResults;
|
|
18
|
+
private runAudit;
|
|
19
|
+
private resetHighlight;
|
|
20
|
+
private highlightNode;
|
|
21
|
+
private cycleHighlightedNode;
|
|
22
|
+
private renderIssuePagination;
|
|
23
|
+
render(): import("@ecopages/jsx").JsxRenderable;
|
|
24
|
+
}
|
|
25
|
+
declare module '@ecopages/jsx' {
|
|
26
|
+
interface JsxCustomIntrinsicElements {
|
|
27
|
+
'eco-dev-toolbar-a11y': JsxCustomElementAttributes<EcoDevToolbarA11y>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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 { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } 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 { toA11yBadge } from './a11y/a11y-badge.js';
|
|
13
|
+
import { clearAuditCache, readAuditCache, writeAuditCache } from './a11y/audit-cache.js';
|
|
14
|
+
import { resolveA11yIssueElement, runA11yChecks, toA11yIssueView } from './a11y/run-a11y-checks.js';
|
|
15
|
+
import { groupA11yIssues } from './a11y/a11y-issue-groups.js';
|
|
16
|
+
import { highlightElement } from '../runtime/highlight-element.js';
|
|
17
|
+
let EcoDevToolbarA11y = class EcoDevToolbarA11y extends RadiantElement {
|
|
18
|
+
axeRunning = false;
|
|
19
|
+
issues = [];
|
|
20
|
+
highlightedGroupIndex = null;
|
|
21
|
+
highlightedNodeIndex = 0;
|
|
22
|
+
auditGeneration = 0;
|
|
23
|
+
auditDebounceTimer;
|
|
24
|
+
clearHighlight;
|
|
25
|
+
get toolbar() {
|
|
26
|
+
return this.closest('eco-dev-toolbar');
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback();
|
|
30
|
+
this.ownerDocument.addEventListener('eco:page-load', this.scheduleAudit);
|
|
31
|
+
this.ownerDocument.addEventListener('eco:after-swap', this.scheduleAudit);
|
|
32
|
+
void this.runAudit();
|
|
33
|
+
}
|
|
34
|
+
disconnectedCallback() {
|
|
35
|
+
this.ownerDocument.removeEventListener('eco:page-load', this.scheduleAudit);
|
|
36
|
+
this.ownerDocument.removeEventListener('eco:after-swap', this.scheduleAudit);
|
|
37
|
+
if (this.auditDebounceTimer !== undefined) {
|
|
38
|
+
clearTimeout(this.auditDebounceTimer);
|
|
39
|
+
this.auditDebounceTimer = undefined;
|
|
40
|
+
}
|
|
41
|
+
this.auditGeneration += 1;
|
|
42
|
+
this.resetHighlight();
|
|
43
|
+
super.disconnectedCallback();
|
|
44
|
+
}
|
|
45
|
+
scheduleAudit = () => {
|
|
46
|
+
clearAuditCache(this.ownerDocument);
|
|
47
|
+
this.issues = [];
|
|
48
|
+
this.toolbar?.setAppBadge('a11y', undefined);
|
|
49
|
+
if (this.auditDebounceTimer !== undefined) {
|
|
50
|
+
clearTimeout(this.auditDebounceTimer);
|
|
51
|
+
}
|
|
52
|
+
this.auditDebounceTimer = setTimeout(() => {
|
|
53
|
+
this.auditDebounceTimer = undefined;
|
|
54
|
+
void this.runAudit();
|
|
55
|
+
}, 250);
|
|
56
|
+
};
|
|
57
|
+
applyAuditResults(issues, generation) {
|
|
58
|
+
if (generation !== this.auditGeneration) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.issues = issues;
|
|
62
|
+
this.toolbar?.setAppBadge('a11y', toA11yBadge(issues));
|
|
63
|
+
}
|
|
64
|
+
async runAudit() {
|
|
65
|
+
const generation = ++this.auditGeneration;
|
|
66
|
+
const cached = readAuditCache(this.ownerDocument);
|
|
67
|
+
this.resetHighlight();
|
|
68
|
+
if (cached) {
|
|
69
|
+
this.applyAuditResults(cached, generation);
|
|
70
|
+
this.axeRunning = false;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.axeRunning = true;
|
|
74
|
+
try {
|
|
75
|
+
const issues = await runA11yChecks(this.ownerDocument, (builtinIssues) => {
|
|
76
|
+
if (generation !== this.auditGeneration) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.applyAuditResults(builtinIssues.map(toA11yIssueView), generation);
|
|
80
|
+
});
|
|
81
|
+
if (generation !== this.auditGeneration) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const views = issues.map(toA11yIssueView);
|
|
85
|
+
writeAuditCache(this.ownerDocument, views);
|
|
86
|
+
this.applyAuditResults(views, generation);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
if (generation !== this.auditGeneration) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.issues = [];
|
|
93
|
+
this.toolbar?.setAppBadge('a11y', undefined);
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
if (generation === this.auditGeneration) {
|
|
97
|
+
this.axeRunning = false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
resetHighlight() {
|
|
102
|
+
this.clearHighlight?.();
|
|
103
|
+
this.clearHighlight = undefined;
|
|
104
|
+
this.highlightedGroupIndex = null;
|
|
105
|
+
this.highlightedNodeIndex = 0;
|
|
106
|
+
}
|
|
107
|
+
highlightNode(groupIndex, nodeIndex) {
|
|
108
|
+
const group = groupA11yIssues(this.issues)[groupIndex];
|
|
109
|
+
const issue = group?.nodes[nodeIndex];
|
|
110
|
+
if (!issue) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const element = resolveA11yIssueElement(this.ownerDocument, issue);
|
|
114
|
+
if (!(element instanceof HTMLElement)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
this.clearHighlight?.();
|
|
118
|
+
this.highlightedGroupIndex = groupIndex;
|
|
119
|
+
this.highlightedNodeIndex = nodeIndex;
|
|
120
|
+
this.clearHighlight = highlightElement(element, 'a11y');
|
|
121
|
+
}
|
|
122
|
+
cycleHighlightedNode(groupIndex, delta) {
|
|
123
|
+
const group = groupA11yIssues(this.issues)[groupIndex];
|
|
124
|
+
if (!group || group.nodes.length <= 1) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const currentIndex = this.highlightedGroupIndex === groupIndex ? this.highlightedNodeIndex : 0;
|
|
128
|
+
const nextIndex = (currentIndex + delta + group.nodes.length) % group.nodes.length;
|
|
129
|
+
this.highlightNode(groupIndex, nextIndex);
|
|
130
|
+
}
|
|
131
|
+
renderIssuePagination(groupIndex, nodeCount) {
|
|
132
|
+
if (nodeCount <= 1) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const activeIndex = this.highlightedGroupIndex === groupIndex ? this.highlightedNodeIndex : 0;
|
|
136
|
+
return (_jsxs("div", { class: "eco-dev-toolbar__pagination eco-dev-toolbar__issue-pagination", "on:click": (event) => event.stopPropagation(), children: [_jsxs("p", { class: "eco-dev-toolbar__pagination-copy", children: ["Element ", activeIndex + 1, " of ", nodeCount] }), _jsxs("div", { class: "eco-dev-toolbar__pagination-actions", children: [_jsx("button", { type: "button", class: "eco-dev-toolbar__pagination-button", "on:click": () => this.cycleHighlightedNode(groupIndex, -1), children: "Previous" }), _jsx("button", { type: "button", class: "eco-dev-toolbar__pagination-button", "on:click": () => this.cycleHighlightedNode(groupIndex, 1), children: "Next" })] })] }));
|
|
137
|
+
}
|
|
138
|
+
render() {
|
|
139
|
+
const axeCount = this.issues.filter((issue) => issue.source === 'axe').length;
|
|
140
|
+
const issueGroups = groupA11yIssues(this.issues);
|
|
141
|
+
return (_jsxs("section", { class: "eco-dev-toolbar__panel", children: [_jsxs("header", { class: "eco-dev-toolbar__settings-header", children: [_jsx("h2", { children: "Accessibility" }), _jsx("p", { class: "eco-dev-toolbar__muted", children: "axe-core and built-in checks for the current page. Click a row to highlight a node; use Previous/Next when an issue affects multiple elements." })] }), this.issues.length > 0 || !this.axeRunning ? (_jsxs(_Fragment, { children: [_jsxs("p", { class: "eco-dev-toolbar__muted", children: [this.issues.length, " issue", this.issues.length === 1 ? '' : 's', " found", issueGroups.length !== this.issues.length
|
|
142
|
+
? ` · ${issueGroups.length} rule${issueGroups.length === 1 ? '' : 's'}`
|
|
143
|
+
: '', axeCount > 0 ? ` · ${axeCount} from axe-core` : ''] }), _jsx("ul", { class: "eco-dev-toolbar__list", children: issueGroups.length > 0 ? (issueGroups.map((group, groupIndex) => (_jsxs("li", { class: "eco-dev-toolbar__list-entry", children: [_jsxs("button", { type: "button", class: "eco-dev-toolbar__list-item", "data-highlighted": this.highlightedGroupIndex === groupIndex ? 'true' : undefined, "on:click": () => this.highlightNode(groupIndex, this.highlightedGroupIndex === groupIndex
|
|
144
|
+
? this.highlightedNodeIndex
|
|
145
|
+
: 0), children: [_jsx("strong", { children: group.severity }), _jsxs("span", { class: "eco-dev-toolbar__muted", children: [group.source, " \u00B7 ", group.id, group.nodes.length > 1 ? ` · ${group.nodes.length} elements` : ''] }), _jsx("span", { class: "eco-dev-toolbar__mono", children: group.message })] }), this.renderIssuePagination(groupIndex, group.nodes.length)] }, `${group.source}-${group.id}-${group.message}`)))) : (_jsx("li", { class: "eco-dev-toolbar__muted", children: "No accessibility issues found." })) })] })) : null, this.axeRunning ? _jsx("p", { class: "eco-dev-toolbar__muted", children: "Running axe-core audit\u2026" }) : null] }));
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
__decorate([
|
|
149
|
+
state
|
|
150
|
+
], EcoDevToolbarA11y.prototype, "axeRunning", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
state
|
|
153
|
+
], EcoDevToolbarA11y.prototype, "issues", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
state
|
|
156
|
+
], EcoDevToolbarA11y.prototype, "highlightedGroupIndex", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
state
|
|
159
|
+
], EcoDevToolbarA11y.prototype, "highlightedNodeIndex", void 0);
|
|
160
|
+
EcoDevToolbarA11y = __decorate([
|
|
161
|
+
customElement('eco-dev-toolbar-a11y')
|
|
162
|
+
], EcoDevToolbarA11y);
|
|
163
|
+
export { EcoDevToolbarA11y };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type AssetInsight = {
|
|
2
|
+
label: string;
|
|
3
|
+
srcUrl: string;
|
|
4
|
+
bytes: number | null;
|
|
5
|
+
category: 'entry' | 'chunk' | 'vendor' | 'dev-transform';
|
|
6
|
+
warning?: string;
|
|
7
|
+
};
|
|
8
|
+
export type DepsInsightsSnapshot = {
|
|
9
|
+
entryCount: number;
|
|
10
|
+
chunkCount: number;
|
|
11
|
+
vendorCount: number;
|
|
12
|
+
insights: AssetInsight[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Loads dependency insights for the current route from the dev manifest.
|
|
16
|
+
*
|
|
17
|
+
* @remarks Fetches `Content-Length` via parallel `HEAD` requests. Large vendor bundles receive a warning heuristic.
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadDepsInsights(doc: Document): Promise<DepsInsightsSnapshot>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { readDevManifestFromDocument } from '../../api/dev-manifest.js';
|
|
2
|
+
const LARGE_VENDOR_BYTES = 100_000;
|
|
3
|
+
async function fetchAssetBytes(url) {
|
|
4
|
+
try {
|
|
5
|
+
const response = await fetch(url, { method: 'HEAD', cache: 'no-store' });
|
|
6
|
+
const length = response.headers.get('content-length');
|
|
7
|
+
return length ? Number.parseInt(length, 10) : null;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function dedupeAssets(assets) {
|
|
14
|
+
const seen = new Set();
|
|
15
|
+
const result = [];
|
|
16
|
+
for (const asset of assets) {
|
|
17
|
+
if (!asset.srcUrl || seen.has(asset.srcUrl)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
seen.add(asset.srcUrl);
|
|
21
|
+
result.push(asset);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function manifestAssets(manifest) {
|
|
26
|
+
if (!manifest) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const insights = [];
|
|
30
|
+
for (const asset of manifest.pageBrowserGraph?.entryAssets ?? []) {
|
|
31
|
+
if (asset.srcUrl) {
|
|
32
|
+
insights.push({ label: asset.srcUrl, srcUrl: asset.srcUrl, bytes: null, category: 'entry' });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const asset of manifest.pageBrowserGraph?.chunkAssets ?? []) {
|
|
36
|
+
if (asset.srcUrl) {
|
|
37
|
+
insights.push({
|
|
38
|
+
label: asset.srcUrl,
|
|
39
|
+
srcUrl: asset.srcUrl,
|
|
40
|
+
bytes: null,
|
|
41
|
+
category: 'chunk',
|
|
42
|
+
warning: 'Lazy chunk referenced by this page',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const url of manifest.vendorUrls) {
|
|
47
|
+
insights.push({ label: url, srcUrl: url, bytes: null, category: 'vendor' });
|
|
48
|
+
}
|
|
49
|
+
for (const url of manifest.devTransformUrls) {
|
|
50
|
+
insights.push({ label: url, srcUrl: url, bytes: null, category: 'dev-transform' });
|
|
51
|
+
}
|
|
52
|
+
return insights;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Loads dependency insights for the current route from the dev manifest.
|
|
56
|
+
*
|
|
57
|
+
* @remarks Fetches `Content-Length` via parallel `HEAD` requests. Large vendor bundles receive a warning heuristic.
|
|
58
|
+
*/
|
|
59
|
+
export async function loadDepsInsights(doc) {
|
|
60
|
+
const manifest = readDevManifestFromDocument(doc);
|
|
61
|
+
const insights = manifestAssets(manifest);
|
|
62
|
+
const uniqueInsights = insights.filter((item, index, array) => array.findIndex((candidate) => candidate.srcUrl === item.srcUrl) === index);
|
|
63
|
+
await Promise.all(uniqueInsights.map(async (insight) => {
|
|
64
|
+
insight.bytes = await fetchAssetBytes(insight.srcUrl);
|
|
65
|
+
if (insight.category === 'vendor' && insight.bytes !== null && insight.bytes >= LARGE_VENDOR_BYTES) {
|
|
66
|
+
insight.warning = 'Large vendor loaded eagerly — consider runtimeModules or lazy loading';
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
const graph = manifest?.pageBrowserGraph;
|
|
70
|
+
return {
|
|
71
|
+
entryCount: dedupeAssets(graph?.entryAssets ?? []).length,
|
|
72
|
+
chunkCount: dedupeAssets(graph?.chunkAssets ?? []).length,
|
|
73
|
+
vendorCount: manifest?.vendorUrls.length ?? 0,
|
|
74
|
+
insights: uniqueInsights,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @jsxImportSource @ecopages/jsx */
|
|
2
|
+
import { RadiantElement } from '@ecopages/radiant';
|
|
3
|
+
import type { JsxCustomElementAttributes } from '@ecopages/jsx';
|
|
4
|
+
import { type DepsInsightsSnapshot } from './deps/load-deps-insights.js';
|
|
5
|
+
export declare class EcoDevToolbarDeps extends RadiantElement {
|
|
6
|
+
loading: boolean;
|
|
7
|
+
refreshing: boolean;
|
|
8
|
+
snapshot: DepsInsightsSnapshot;
|
|
9
|
+
private loadGeneration;
|
|
10
|
+
private refreshDebounceTimer;
|
|
11
|
+
private disconnectVisibilityObserver;
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
disconnectedCallback(): void;
|
|
14
|
+
private wireVisibilityObserver;
|
|
15
|
+
private readonly scheduleRefresh;
|
|
16
|
+
private refresh;
|
|
17
|
+
private renderInsight;
|
|
18
|
+
render(): import("@ecopages/jsx").JsxRenderable;
|
|
19
|
+
}
|
|
20
|
+
declare module '@ecopages/jsx' {
|
|
21
|
+
interface JsxCustomIntrinsicElements {
|
|
22
|
+
'eco-dev-toolbar-deps': JsxCustomElementAttributes<EcoDevToolbarDeps>;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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, Fragment as _Fragment } 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 { DEV_TOOLBAR_DEPS_REFRESH_DEBOUNCE_MS } from '../runtime/constants.js';
|
|
13
|
+
import { isPanelSlotVisible, observePanelSlotVisibility } from '../shell/panel-slot-visibility.js';
|
|
14
|
+
import { loadDepsInsights } from './deps/load-deps-insights.js';
|
|
15
|
+
let EcoDevToolbarDeps = class EcoDevToolbarDeps extends RadiantElement {
|
|
16
|
+
loading = true;
|
|
17
|
+
refreshing = false;
|
|
18
|
+
snapshot = {
|
|
19
|
+
entryCount: 0,
|
|
20
|
+
chunkCount: 0,
|
|
21
|
+
vendorCount: 0,
|
|
22
|
+
insights: [],
|
|
23
|
+
};
|
|
24
|
+
loadGeneration = 0;
|
|
25
|
+
refreshDebounceTimer;
|
|
26
|
+
disconnectVisibilityObserver;
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
super.connectedCallback();
|
|
29
|
+
this.ownerDocument.addEventListener('eco:page-load', this.scheduleRefresh);
|
|
30
|
+
this.ownerDocument.addEventListener('eco:after-swap', this.scheduleRefresh);
|
|
31
|
+
this.wireVisibilityObserver();
|
|
32
|
+
void this.refresh();
|
|
33
|
+
}
|
|
34
|
+
disconnectedCallback() {
|
|
35
|
+
this.ownerDocument.removeEventListener('eco:page-load', this.scheduleRefresh);
|
|
36
|
+
this.ownerDocument.removeEventListener('eco:after-swap', this.scheduleRefresh);
|
|
37
|
+
this.disconnectVisibilityObserver?.();
|
|
38
|
+
this.disconnectVisibilityObserver = undefined;
|
|
39
|
+
if (this.refreshDebounceTimer !== undefined) {
|
|
40
|
+
clearTimeout(this.refreshDebounceTimer);
|
|
41
|
+
this.refreshDebounceTimer = undefined;
|
|
42
|
+
}
|
|
43
|
+
this.loadGeneration += 1;
|
|
44
|
+
super.disconnectedCallback();
|
|
45
|
+
}
|
|
46
|
+
wireVisibilityObserver() {
|
|
47
|
+
this.disconnectVisibilityObserver?.();
|
|
48
|
+
this.disconnectVisibilityObserver = observePanelSlotVisibility(this, () => {
|
|
49
|
+
void this.refresh();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
scheduleRefresh = () => {
|
|
53
|
+
if (!isPanelSlotVisible(this)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (this.refreshDebounceTimer !== undefined) {
|
|
57
|
+
clearTimeout(this.refreshDebounceTimer);
|
|
58
|
+
}
|
|
59
|
+
this.refreshDebounceTimer = setTimeout(() => {
|
|
60
|
+
this.refreshDebounceTimer = undefined;
|
|
61
|
+
void this.refresh();
|
|
62
|
+
}, DEV_TOOLBAR_DEPS_REFRESH_DEBOUNCE_MS);
|
|
63
|
+
};
|
|
64
|
+
async refresh() {
|
|
65
|
+
const generation = ++this.loadGeneration;
|
|
66
|
+
const isInitialLoad = this.snapshot.insights.length === 0;
|
|
67
|
+
if (isInitialLoad) {
|
|
68
|
+
this.loading = true;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.refreshing = true;
|
|
72
|
+
}
|
|
73
|
+
const snapshot = await loadDepsInsights(this.ownerDocument);
|
|
74
|
+
if (generation !== this.loadGeneration) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.snapshot = snapshot;
|
|
78
|
+
this.loading = false;
|
|
79
|
+
this.refreshing = false;
|
|
80
|
+
}
|
|
81
|
+
renderInsight(item) {
|
|
82
|
+
return (_jsxs("li", { children: [_jsx("div", { class: "eco-dev-toolbar__mono", children: item.label }), _jsxs("div", { class: "eco-dev-toolbar__muted", children: [item.category, item.bytes !== null ? ` · ${item.bytes} bytes` : ''] }), item.warning ? _jsx("div", { class: "eco-dev-toolbar__warning", children: item.warning }) : null] }, item.srcUrl));
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
return (_jsxs("section", { class: "eco-dev-toolbar__panel", children: [_jsxs("header", { class: "eco-dev-toolbar__settings-header", children: [_jsx("h2", { children: "Dependencies" }), _jsx("p", { class: "eco-dev-toolbar__muted", children: "Page Browser Graph assets from the current route manifest." })] }), this.loading ? (_jsx("p", { class: "eco-dev-toolbar__muted", children: "Loading asset sizes\u2026" })) : (_jsxs(_Fragment, { children: [_jsxs("p", { class: "eco-dev-toolbar__muted", children: [this.snapshot.entryCount, " entry \u00B7 ", this.snapshot.chunkCount, " chunks \u00B7", ' ', this.snapshot.vendorCount, " vendors", this.refreshing ? ' · refreshing…' : ''] }), _jsx("ul", { class: "eco-dev-toolbar__list", children: this.snapshot.insights.length > 0 ? (this.snapshot.insights.map((item) => this.renderInsight(item))) : (_jsx("li", { class: "eco-dev-toolbar__muted", children: "No dependency assets in the dev manifest." })) })] }))] }));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
__decorate([
|
|
89
|
+
state
|
|
90
|
+
], EcoDevToolbarDeps.prototype, "loading", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
state
|
|
93
|
+
], EcoDevToolbarDeps.prototype, "refreshing", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
state
|
|
96
|
+
], EcoDevToolbarDeps.prototype, "snapshot", void 0);
|
|
97
|
+
EcoDevToolbarDeps = __decorate([
|
|
98
|
+
customElement('eco-dev-toolbar-deps')
|
|
99
|
+
], EcoDevToolbarDeps);
|
|
100
|
+
export { EcoDevToolbarDeps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsxImportSource @ecopages/jsx */
|
|
2
|
+
import { RadiantElement } from '@ecopages/radiant';
|
|
3
|
+
import type { JsxCustomElementAttributes } from '@ecopages/jsx';
|
|
4
|
+
import { type IslandRecordView } from '../islands/read-island-records.js';
|
|
5
|
+
export declare class EcoDevToolbarIslands extends RadiantElement {
|
|
6
|
+
islands: IslandRecordView[];
|
|
7
|
+
highlightedIndex: number | null;
|
|
8
|
+
private refreshFrame;
|
|
9
|
+
private mutationObserver;
|
|
10
|
+
private clearHighlight;
|
|
11
|
+
private liveIslandTargets;
|
|
12
|
+
private suppressRefreshUntil;
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
disconnectedCallback(): void;
|
|
15
|
+
private wireMutationObserver;
|
|
16
|
+
private readonly scheduleRefresh;
|
|
17
|
+
private refresh;
|
|
18
|
+
private resetHighlight;
|
|
19
|
+
private highlightIsland;
|
|
20
|
+
render(): import("@ecopages/jsx").JsxRenderable;
|
|
21
|
+
}
|
|
22
|
+
declare module '@ecopages/jsx' {
|
|
23
|
+
interface JsxCustomIntrinsicElements {
|
|
24
|
+
'eco-dev-toolbar-islands': JsxCustomElementAttributes<EcoDevToolbarIslands>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
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 { readIslandRecords, resolveIslandElement, toIslandRecordView, } from '../islands/read-island-records.js';
|
|
13
|
+
import { highlightElement } from '../runtime/highlight-element.js';
|
|
14
|
+
function islandsSignature(islands) {
|
|
15
|
+
return islands.map((island) => `${island.id}|${island.hostTag}|${island.hydrated}|${island.kind}`).join('\n');
|
|
16
|
+
}
|
|
17
|
+
let EcoDevToolbarIslands = class EcoDevToolbarIslands extends RadiantElement {
|
|
18
|
+
islands = [];
|
|
19
|
+
highlightedIndex = null;
|
|
20
|
+
refreshFrame;
|
|
21
|
+
mutationObserver;
|
|
22
|
+
clearHighlight;
|
|
23
|
+
liveIslandTargets = [];
|
|
24
|
+
suppressRefreshUntil = 0;
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback();
|
|
27
|
+
this.refresh();
|
|
28
|
+
this.wireMutationObserver();
|
|
29
|
+
this.ownerDocument.addEventListener('eco:page-load', this.scheduleRefresh);
|
|
30
|
+
this.ownerDocument.addEventListener('eco:after-swap', this.scheduleRefresh);
|
|
31
|
+
}
|
|
32
|
+
disconnectedCallback() {
|
|
33
|
+
this.ownerDocument.removeEventListener('eco:page-load', this.scheduleRefresh);
|
|
34
|
+
this.ownerDocument.removeEventListener('eco:after-swap', this.scheduleRefresh);
|
|
35
|
+
this.mutationObserver?.disconnect();
|
|
36
|
+
this.mutationObserver = undefined;
|
|
37
|
+
if (this.refreshFrame !== undefined) {
|
|
38
|
+
cancelAnimationFrame(this.refreshFrame);
|
|
39
|
+
this.refreshFrame = undefined;
|
|
40
|
+
}
|
|
41
|
+
this.resetHighlight();
|
|
42
|
+
this.liveIslandTargets = [];
|
|
43
|
+
super.disconnectedCallback();
|
|
44
|
+
}
|
|
45
|
+
wireMutationObserver() {
|
|
46
|
+
this.mutationObserver?.disconnect();
|
|
47
|
+
this.mutationObserver = new MutationObserver(() => this.scheduleRefresh());
|
|
48
|
+
this.mutationObserver.observe(this.ownerDocument.documentElement, {
|
|
49
|
+
childList: true,
|
|
50
|
+
subtree: true,
|
|
51
|
+
attributes: true,
|
|
52
|
+
attributeFilter: [
|
|
53
|
+
'data-eco-island',
|
|
54
|
+
'data-eco-island-integration',
|
|
55
|
+
'data-eco-component-key',
|
|
56
|
+
'data-eco-component-id',
|
|
57
|
+
'data-eco-props',
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
scheduleRefresh = () => {
|
|
62
|
+
if (performance.now() < this.suppressRefreshUntil) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this.refreshFrame !== undefined) {
|
|
66
|
+
cancelAnimationFrame(this.refreshFrame);
|
|
67
|
+
}
|
|
68
|
+
this.refreshFrame = requestAnimationFrame(() => {
|
|
69
|
+
this.refreshFrame = undefined;
|
|
70
|
+
this.refresh();
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
refresh() {
|
|
74
|
+
const records = readIslandRecords(this.ownerDocument);
|
|
75
|
+
const nextIslands = records.map(toIslandRecordView);
|
|
76
|
+
const nextTargets = records.map((record) => record.element);
|
|
77
|
+
const islandsChanged = islandsSignature(nextIslands) !== islandsSignature(this.islands);
|
|
78
|
+
if (islandsChanged) {
|
|
79
|
+
this.resetHighlight();
|
|
80
|
+
this.islands = nextIslands;
|
|
81
|
+
}
|
|
82
|
+
this.liveIslandTargets = nextTargets;
|
|
83
|
+
}
|
|
84
|
+
resetHighlight() {
|
|
85
|
+
this.clearHighlight?.();
|
|
86
|
+
this.clearHighlight = undefined;
|
|
87
|
+
this.highlightedIndex = null;
|
|
88
|
+
}
|
|
89
|
+
highlightIsland(index) {
|
|
90
|
+
const island = this.islands[index];
|
|
91
|
+
if (!island) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let element = this.liveIslandTargets[index];
|
|
95
|
+
if (!(element instanceof HTMLElement) || !element.isConnected) {
|
|
96
|
+
element = resolveIslandElement(island, this.ownerDocument) ?? undefined;
|
|
97
|
+
}
|
|
98
|
+
if (!element) {
|
|
99
|
+
this.refresh();
|
|
100
|
+
element = resolveIslandElement(island, this.ownerDocument) ?? undefined;
|
|
101
|
+
if (!element) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const target = element;
|
|
106
|
+
this.mutationObserver?.disconnect();
|
|
107
|
+
this.resetHighlight();
|
|
108
|
+
this.highlightedIndex = index;
|
|
109
|
+
this.suppressRefreshUntil = performance.now() + 750;
|
|
110
|
+
this.clearHighlight = highlightElement(target, 'island');
|
|
111
|
+
this.wireMutationObserver();
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
return (_jsxs("section", { class: "eco-dev-toolbar__panel", children: [_jsxs("header", { class: "eco-dev-toolbar__settings-header", children: [_jsx("h2", { children: "Islands" }), _jsx("p", { class: "eco-dev-toolbar__muted", children: "React islands, integration counters, and custom elements on this page." })] }), _jsxs("p", { class: "eco-dev-toolbar__muted", children: [this.islands.length, " island", this.islands.length === 1 ? '' : 's', " on this page"] }), _jsx("ul", { class: "eco-dev-toolbar__list", children: this.islands.length > 0 ? (this.islands.map((island, index) => (_jsx("li", { children: _jsxs("button", { type: "button", class: "eco-dev-toolbar__list-item", "data-highlighted": this.highlightedIndex === index ? 'true' : undefined, "on:click": () => this.highlightIsland(index), children: [_jsx("strong", { children: island.label }), _jsxs("span", { class: "eco-dev-toolbar__muted", children: [island.hostTag, island.integration ? ` · ${island.integration}` : '', " \u00B7", ' ', island.hydrated ? 'hydrated' : 'ssr-only', " \u00B7 ", island.kind] }), island.componentKey ? (_jsxs("span", { class: "eco-dev-toolbar__mono", children: ["key=", island.componentKey] })) : null, island.propsPreview ? (_jsx("span", { class: "eco-dev-toolbar__mono", children: island.propsPreview })) : null] }) }, `${island.id}-${island.hostTag}-${index}`)))) : (_jsx("li", { class: "eco-dev-toolbar__muted", children: "No islands detected on this page." })) })] }));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
__decorate([
|
|
118
|
+
state
|
|
119
|
+
], EcoDevToolbarIslands.prototype, "islands", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
state
|
|
122
|
+
], EcoDevToolbarIslands.prototype, "highlightedIndex", void 0);
|
|
123
|
+
EcoDevToolbarIslands = __decorate([
|
|
124
|
+
customElement('eco-dev-toolbar-islands')
|
|
125
|
+
], EcoDevToolbarIslands);
|
|
126
|
+
export { EcoDevToolbarIslands };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @jsxImportSource @ecopages/jsx */
|
|
2
|
+
import { RadiantElement } from '@ecopages/radiant';
|
|
3
|
+
import type { JsxCustomElementAttributes } from '@ecopages/jsx';
|
|
4
|
+
import { type EcoDevManifest } from '../api/dev-manifest.js';
|
|
5
|
+
import { type NavigationTelemetrySnapshot } from '../runtime/navigation-telemetry.js';
|
|
6
|
+
export declare class EcoDevToolbarNavigation extends RadiantElement {
|
|
7
|
+
snapshot: NavigationTelemetrySnapshot | undefined;
|
|
8
|
+
manifest: EcoDevManifest | undefined;
|
|
9
|
+
historyPage: number;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
refreshSnapshot(): void;
|
|
13
|
+
private readonly refresh;
|
|
14
|
+
private resetHistory;
|
|
15
|
+
private showPreviousHistoryPage;
|
|
16
|
+
private showNextHistoryPage;
|
|
17
|
+
private renderRow;
|
|
18
|
+
private renderHistoryPagination;
|
|
19
|
+
render(): import("@ecopages/jsx").JsxRenderable;
|
|
20
|
+
}
|
|
21
|
+
declare module '@ecopages/jsx' {
|
|
22
|
+
interface JsxCustomIntrinsicElements {
|
|
23
|
+
'eco-dev-toolbar-navigation': JsxCustomElementAttributes<EcoDevToolbarNavigation>;
|
|
24
|
+
}
|
|
25
|
+
}
|