@ecopages/dev-toolbar 0.2.0 → 0.3.1
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 +10 -8
- package/package.json +3 -4
- package/src/api/build-error-contract.d.ts +4 -0
- package/src/api/build-error-contract.js +4 -0
- package/src/api/manifest-contract.d.ts +1 -1
- package/src/api/manifest-contract.js +1 -1
- package/src/apps/a11y-panel.js +2 -1
- package/src/apps/deps-panel.js +2 -1
- package/src/apps/islands-panel.js +2 -1
- package/src/apps/navigation-panel.js +2 -1
- package/src/config.d.ts +1 -1
- package/src/config.js +1 -1
- package/src/islands/island-record-builder.js +7 -1
- package/src/runtime/navigation-events.d.ts +2 -1
- package/src/runtime/navigation-events.js +1 -0
- package/src/runtime/navigation-telemetry.d.ts +0 -2
- package/src/runtime/navigation-telemetry.js +8 -23
- package/src/shell/eco-dev-toolbar.d.ts +3 -0
- package/src/shell/eco-dev-toolbar.js +38 -4
- package/src/shell/ensure-dev-toolbar-styles.js +2 -1
- package/src/shell/styles/content.d.ts +1 -1
- package/src/shell/styles/content.js +6 -0
- package/src/apps/a11y/run-a11y-checks.test.browser.d.ts +0 -1
- package/src/apps/a11y/run-a11y-checks.test.browser.js +0 -77
- package/src/islands/read-island-records.test.browser.d.ts +0 -1
- package/src/islands/read-island-records.test.browser.js +0 -95
package/README.md
CHANGED
|
@@ -9,13 +9,10 @@ User-facing docs: [Dev toolbar](https://ecopages.dev/docs/core/dev-toolbar) (ena
|
|
|
9
9
|
Add the package to your app and opt in from config:
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import {
|
|
12
|
+
import { defineConfig } from '@ecopages/core/config';
|
|
13
13
|
import { devToolbar } from '@ecopages/dev-toolbar/config';
|
|
14
14
|
|
|
15
|
-
export default
|
|
16
|
-
.setRootDir(import.meta.dirname)
|
|
17
|
-
.setDevToolbar(devToolbar())
|
|
18
|
-
.build();
|
|
15
|
+
export default defineConfig({ devToolbar: devToolbar() });
|
|
19
16
|
```
|
|
20
17
|
|
|
21
18
|
```bash
|
|
@@ -30,7 +27,8 @@ Disable per project with `devToolbar: { enabled: false }`, or per process with `
|
|
|
30
27
|
|
|
31
28
|
## Built-in apps
|
|
32
29
|
|
|
33
|
-
- **
|
|
30
|
+
- **Build errors** — opens automatically on HMR errors, reveals stealth mode, lists distinct messages as text, and shows an error count badge; any non-error HMR event clears messages and the badge
|
|
31
|
+
- **Navigation** — route timing archive, initial load, client navigation latency, HMR status, and page Integration (the current owner reported by core's navigation coordinator); writes `#__ECO_DEV_NAV_TELEMETRY__` in `document.head` (with `data-eco-persist`) and exposes `window.__ECO_DEV_NAV_TELEMETRY__` for machine/AI debug
|
|
34
32
|
- **Deps** — Page Browser Graph entry/chunk assets, vendor URLs, lazy-load hints
|
|
35
33
|
- **Islands** — inspect island hosts stamped with `data-eco-island`, including SSR-emitted React `<eco-island>` hosts; repeated component instances are shown independently and hydration status reports `hydrated` (via `data-eco-hydrated` or verified component update completion), `registered` (for defined custom elements awaiting update completion), or `ssr-only`
|
|
36
34
|
- **A11y** — axe-core audit (with built-in fallback checks) and in-page highlights
|
|
@@ -43,11 +41,13 @@ Core delivers the configured client at `/_dev_toolbar.js` and injects `#__ECO_DE
|
|
|
43
41
|
To replace this reference toolbar:
|
|
44
42
|
|
|
45
43
|
1. Create a client package that exports a browser bootstrap module (same layout as `@ecopages/dev-toolbar`).
|
|
46
|
-
2. Set `devToolbar.package` in `eco.config.ts` (use `defineDevTool` from `@ecopages/core/
|
|
44
|
+
2. Set `devToolbar.package` in `eco.config.ts` (use `defineDevTool` from `@ecopages/core/client` for BYO packages).
|
|
47
45
|
3. Fork or copy this package if you want Radiant panels, manifest readers, and stealth dock behavior.
|
|
48
46
|
|
|
49
47
|
`@ecopages/dev-toolbar` is the reference implementation.
|
|
50
48
|
|
|
49
|
+
Custom clients can claim the HMR runtime's cancelable `ecopages:build-error` window event (`detail: { message: string }`) with synchronous `preventDefault()` to suppress the in-page fallback. Listen for `ecopages:build-error-clear` to reset errors. After registering listeners, dispatch `ecopages:build-error-request` to replay active messages if mounting late. Core exports the names and payload type from `@ecopages/core/client`; the reference client mirrors the event names locally for browser bundling. Unclaimed errors still use the fallback. Remove listeners when unmounting.
|
|
50
|
+
|
|
51
51
|
## Reference-toolbar internals
|
|
52
52
|
|
|
53
53
|
`window.__ECO_DEV_TOOLBAR_APPS__` is an optional registry used inside this package for experimental extra dock apps. It is **not** a supported Ecopages extension API — app authors should replace `devToolbar.package` instead.
|
|
@@ -55,11 +55,13 @@ To replace this reference toolbar:
|
|
|
55
55
|
## Package layout
|
|
56
56
|
|
|
57
57
|
- `src/bootstrap.ts` — injects toolbar CSS into `document.head`, boots navigation telemetry, and mounts `eco-dev-toolbar`; reload-safe telemetry ownership prevents HMR bundle re-evaluation from adding duplicate document listeners
|
|
58
|
-
- `src/runtime/navigation-events.ts` — shares
|
|
58
|
+
- `src/runtime/navigation-events.ts` — shares core's navigation lifecycle event names and one DOM listener across toolbar apps, removing it when the final subscriber unmounts
|
|
59
|
+
- `src/runtime/navigation-telemetry.ts` — reads the current owner from `getOwnerState()` so browser and React router ownership is reported consistently
|
|
59
60
|
- `src/shell/eco-dev-toolbar.tsx` — Radiant light-DOM host (JSX `render()`, no shadow root); panel positioning is pure CSS
|
|
60
61
|
- `src/shell/motion.ts` — WAAPI motion for stealth dock reveal only; panel show/hide is CSS
|
|
61
62
|
- `src/apps/*-panel.tsx` — Radiant JSX panels (navigation, deps, islands, a11y, settings)
|
|
62
63
|
- `src/api/manifest-contract.ts` — browser-local mirror of the core dev manifest contract
|
|
64
|
+
- `src/api/build-error-contract.ts` — browser-local event names checked against the public core build error contract
|
|
63
65
|
- `src/api/dev-manifest.ts` — internal DOM read/write for `#__ECO_DEV_MANIFEST__`
|
|
64
66
|
- `src/api/types.ts` — toolbar app host contracts
|
|
65
67
|
- `src/shell/` — custom element host, SVG icons, styles, and `ensureDevToolbarStyles()` (optional CSS override for BYO toolbars)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/dev-toolbar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Development toolbar for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -40,9 +40,8 @@
|
|
|
40
40
|
"directory": "packages/dev-toolbar"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@ecopages/jsx": "^0.
|
|
44
|
-
"@ecopages/radiant": "^0.
|
|
45
|
-
"@ecopages/signals": "^0.3.0-rc.9",
|
|
43
|
+
"@ecopages/jsx": "^0.4.0",
|
|
44
|
+
"@ecopages/radiant": "^0.4.0",
|
|
46
45
|
"axe-core": "^4.10.3"
|
|
47
46
|
},
|
|
48
47
|
"types": "./src/bootstrap.d.ts"
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type BuildErrorDetail } from '@ecopages/core/client';
|
|
2
|
+
export declare const BUILD_ERROR_EVENT = "ecopages:build-error";
|
|
3
|
+
export declare const BUILD_ERROR_CLEAR_EVENT = "ecopages:build-error-clear";
|
|
4
|
+
export declare const BUILD_ERROR_REQUEST_EVENT = "ecopages:build-error-request";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser-local mirror of `@ecopages/core/
|
|
2
|
+
* Browser-local mirror of `@ecopages/core/client`.
|
|
3
3
|
*
|
|
4
4
|
* @remarks Dev-toolbar is browser-bundled separately; Rolldown cannot resolve core
|
|
5
5
|
* package export subpaths from the client entry. Keep in sync with core via
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser-local mirror of `@ecopages/core/
|
|
2
|
+
* Browser-local mirror of `@ecopages/core/client`.
|
|
3
3
|
*
|
|
4
4
|
* @remarks Dev-toolbar is browser-bundled separately; Rolldown cannot resolve core
|
|
5
5
|
* package export subpaths from the client entry. Keep in sync with core via
|
package/src/apps/a11y-panel.js
CHANGED
|
@@ -9,6 +9,7 @@ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "@ecopages/jsx
|
|
|
9
9
|
import { RadiantElement } from '@ecopages/radiant';
|
|
10
10
|
import { customElement } from '@ecopages/radiant/decorators/custom-element';
|
|
11
11
|
import { state } from '@ecopages/radiant/decorators/state';
|
|
12
|
+
import { ECO_NAVIGATION_LIFECYCLE_EVENTS } from '@ecopages/core/client';
|
|
12
13
|
import { toA11yBadge } from './a11y/a11y-badge.js';
|
|
13
14
|
import { resolveA11yIssueElement, runA11yChecks, toA11yIssueView } from './a11y/run-a11y-checks.js';
|
|
14
15
|
import { groupA11yIssues } from './a11y/a11y-issue-groups.js';
|
|
@@ -41,7 +42,7 @@ let EcoDevToolbarA11y = class EcoDevToolbarA11y extends RadiantElement {
|
|
|
41
42
|
}
|
|
42
43
|
connectedCallback() {
|
|
43
44
|
super.connectedCallback();
|
|
44
|
-
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [
|
|
45
|
+
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [ECO_NAVIGATION_LIFECYCLE_EVENTS.PAGE_LOAD, ECO_NAVIGATION_LIFECYCLE_EVENTS.AFTER_SWAP], this.scheduleAudit);
|
|
45
46
|
void this.runAudit();
|
|
46
47
|
}
|
|
47
48
|
disconnectedCallback() {
|
package/src/apps/deps-panel.js
CHANGED
|
@@ -9,6 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ecopages/jsx
|
|
|
9
9
|
import { RadiantElement } from '@ecopages/radiant';
|
|
10
10
|
import { customElement } from '@ecopages/radiant/decorators/custom-element';
|
|
11
11
|
import { state } from '@ecopages/radiant/decorators/state';
|
|
12
|
+
import { ECO_NAVIGATION_LIFECYCLE_EVENTS } from '@ecopages/core/client';
|
|
12
13
|
import { DEV_TOOLBAR_DEPS_REFRESH_DEBOUNCE_MS } from '../runtime/constants.js';
|
|
13
14
|
import { isPanelSlotVisible, observePanelSlotVisibility } from '../shell/panel-slot-visibility.js';
|
|
14
15
|
import { loadDepsInsights } from './deps/load-deps-insights.js';
|
|
@@ -28,7 +29,7 @@ let EcoDevToolbarDeps = class EcoDevToolbarDeps extends RadiantElement {
|
|
|
28
29
|
unsubscribeNavigationEvents;
|
|
29
30
|
connectedCallback() {
|
|
30
31
|
super.connectedCallback();
|
|
31
|
-
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [
|
|
32
|
+
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [ECO_NAVIGATION_LIFECYCLE_EVENTS.PAGE_LOAD, ECO_NAVIGATION_LIFECYCLE_EVENTS.AFTER_SWAP], this.scheduleRefresh);
|
|
32
33
|
this.wireVisibilityObserver();
|
|
33
34
|
void this.refresh();
|
|
34
35
|
}
|
|
@@ -9,6 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@ecopages/jsx/jsx-runtime";
|
|
|
9
9
|
import { RadiantElement } from '@ecopages/radiant';
|
|
10
10
|
import { customElement } from '@ecopages/radiant/decorators/custom-element';
|
|
11
11
|
import { state } from '@ecopages/radiant/decorators/state';
|
|
12
|
+
import { ECO_NAVIGATION_LIFECYCLE_EVENTS } from '@ecopages/core/client';
|
|
12
13
|
import { readIslandRecords, resolveIslandElement, toIslandRecordView, } from '../islands/read-island-records.js';
|
|
13
14
|
import { highlightElement } from '../runtime/highlight-element.js';
|
|
14
15
|
import { subscribeToNavigationEvents } from '../runtime/navigation-events.js';
|
|
@@ -28,7 +29,7 @@ let EcoDevToolbarIslands = class EcoDevToolbarIslands extends RadiantElement {
|
|
|
28
29
|
super.connectedCallback();
|
|
29
30
|
this.refresh();
|
|
30
31
|
this.wireMutationObserver();
|
|
31
|
-
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [
|
|
32
|
+
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [ECO_NAVIGATION_LIFECYCLE_EVENTS.PAGE_LOAD, ECO_NAVIGATION_LIFECYCLE_EVENTS.AFTER_SWAP], this.scheduleRefresh);
|
|
32
33
|
}
|
|
33
34
|
disconnectedCallback() {
|
|
34
35
|
this.unsubscribeNavigationEvents?.();
|
|
@@ -9,6 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@ecopages/jsx/jsx-runtime";
|
|
|
9
9
|
import { RadiantElement } from '@ecopages/radiant';
|
|
10
10
|
import { customElement } from '@ecopages/radiant/decorators/custom-element';
|
|
11
11
|
import { state } from '@ecopages/radiant/decorators/state';
|
|
12
|
+
import { ECO_NAVIGATION_LIFECYCLE_EVENTS } from '@ecopages/core/client';
|
|
12
13
|
import { readDevManifestFromDocument } from '../api/dev-manifest.js';
|
|
13
14
|
import { DEV_TOOLBAR_NAV_HISTORY_PAGE_SIZE } from '../runtime/constants.js';
|
|
14
15
|
import { clearNavigationTelemetryHistory, readNavigationTelemetrySnapshot, } from '../runtime/navigation-telemetry.js';
|
|
@@ -29,7 +30,7 @@ let EcoDevToolbarNavigation = class EcoDevToolbarNavigation extends RadiantEleme
|
|
|
29
30
|
unsubscribeNavigationEvents;
|
|
30
31
|
connectedCallback() {
|
|
31
32
|
super.connectedCallback();
|
|
32
|
-
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [
|
|
33
|
+
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(this.ownerDocument, [ECO_NAVIGATION_LIFECYCLE_EVENTS.PAGE_LOAD, ECO_NAVIGATION_LIFECYCLE_EVENTS.AFTER_SWAP], this.refresh);
|
|
33
34
|
}
|
|
34
35
|
disconnectedCallback() {
|
|
35
36
|
this.unsubscribeNavigationEvents?.();
|
package/src/config.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type DevToolbarConfig = {
|
|
|
8
8
|
enabled?: boolean;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* Returns the `devToolbar`
|
|
11
|
+
* Returns the `devToolbar` block for `defineConfig({ devToolbar })`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function devToolbar(options?: DevToolbarOptions): DevToolbarConfig;
|
|
14
14
|
export {};
|
package/src/config.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @remarks
|
|
3
|
+
* Browser-local mirror of the decode for core's `encodeIslandProps` (base64 of UTF-8 JSON). The toolbar
|
|
4
|
+
* cannot import core, which already lists the toolbar as an optional peer.
|
|
5
|
+
*/
|
|
1
6
|
function parsePropsPreview(encoded) {
|
|
2
7
|
if (!encoded) {
|
|
3
8
|
return '';
|
|
4
9
|
}
|
|
5
10
|
try {
|
|
6
|
-
|
|
11
|
+
const json = new TextDecoder().decode(Uint8Array.from(atob(encoded), (char) => char.charCodeAt(0)));
|
|
12
|
+
return JSON.stringify(JSON.parse(json), null, 0).slice(0, 120);
|
|
7
13
|
}
|
|
8
14
|
catch {
|
|
9
15
|
return '(invalid props)';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { ECO_NAVIGATION_LIFECYCLE_EVENTS } from '@ecopages/core/client';
|
|
2
|
+
export type NavigationLifecycleEvent = (typeof ECO_NAVIGATION_LIFECYCLE_EVENTS)[keyof typeof ECO_NAVIGATION_LIFECYCLE_EVENTS];
|
|
2
3
|
type NavigationListener = () => void;
|
|
3
4
|
/**
|
|
4
5
|
* Shares one DOM listener per navigation event while allowing toolbar panels to subscribe independently.
|
|
@@ -40,8 +40,6 @@ export type NavigationTelemetryApi = {
|
|
|
40
40
|
getSnapshot: () => NavigationTelemetrySnapshot;
|
|
41
41
|
clearHistory: () => NavigationTelemetrySnapshot;
|
|
42
42
|
};
|
|
43
|
-
/** @internal */
|
|
44
|
-
export declare function resetNavigationTelemetryForTests(): void;
|
|
45
43
|
/**
|
|
46
44
|
* Boots route timing collection, DOM JSON trace export, and `window.__ECO_DEV_NAV_TELEMETRY__`.
|
|
47
45
|
*/
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ECO_NAVIGATION_LIFECYCLE_EVENTS } from '@ecopages/core/client';
|
|
2
|
+
import { ECO_PERSIST_ATTRIBUTE } from '@ecopages/core/client';
|
|
1
3
|
import { DEV_TOOLBAR_NAV_TELEMETRY_PERSIST_KEY } from './constants.js';
|
|
2
4
|
import { subscribeToNavigationEvents } from './navigation-events.js';
|
|
3
5
|
export const NAV_TELEMETRY_ELEMENT_ID = '__ECO_DEV_NAV_TELEMETRY__';
|
|
@@ -10,31 +12,14 @@ let swapStartedAt = null;
|
|
|
10
12
|
let initialized = false;
|
|
11
13
|
let telemetryDocument;
|
|
12
14
|
let disposeTelemetryListeners;
|
|
13
|
-
/** @internal */
|
|
14
|
-
export function resetNavigationTelemetryForTests() {
|
|
15
|
-
disposeTelemetryListeners?.();
|
|
16
|
-
disposeTelemetryListeners = undefined;
|
|
17
|
-
if (typeof window !== 'undefined') {
|
|
18
|
-
const telemetryWindow = window;
|
|
19
|
-
telemetryWindow.__ECO_DEV_NAV_TELEMETRY_RUNTIME__?.dispose();
|
|
20
|
-
delete telemetryWindow.__ECO_DEV_NAV_TELEMETRY_RUNTIME__;
|
|
21
|
-
delete telemetryWindow.__ECO_DEV_NAV_TELEMETRY__;
|
|
22
|
-
}
|
|
23
|
-
initialized = false;
|
|
24
|
-
telemetryDocument = undefined;
|
|
25
|
-
nextEntryId = 0;
|
|
26
|
-
activeEntry = null;
|
|
27
|
-
history = [];
|
|
28
|
-
swapStartedAt = null;
|
|
29
|
-
}
|
|
30
15
|
function createEntryId() {
|
|
31
16
|
nextEntryId += 1;
|
|
32
17
|
return `nav-${nextEntryId}`;
|
|
33
18
|
}
|
|
34
19
|
function getNavigationOwner() {
|
|
35
20
|
const runtime = window.__ECO_PAGES__?.navigation;
|
|
36
|
-
const owner = runtime?.
|
|
37
|
-
if (owner) {
|
|
21
|
+
const owner = runtime?.getOwnerState().owner;
|
|
22
|
+
if (owner && owner !== 'none') {
|
|
38
23
|
return owner;
|
|
39
24
|
}
|
|
40
25
|
if (window.__ecopages_browser_router__) {
|
|
@@ -119,7 +104,7 @@ function syncTelemetryElement(doc = getTelemetryDocument()) {
|
|
|
119
104
|
const script = doc.createElement('script');
|
|
120
105
|
script.id = NAV_TELEMETRY_ELEMENT_ID;
|
|
121
106
|
script.setAttribute('type', 'application/json');
|
|
122
|
-
script.setAttribute(
|
|
107
|
+
script.setAttribute(ECO_PERSIST_ATTRIBUTE, DEV_TOOLBAR_NAV_TELEMETRY_PERSIST_KEY);
|
|
123
108
|
element = script;
|
|
124
109
|
doc.head.append(element);
|
|
125
110
|
}
|
|
@@ -250,9 +235,9 @@ export function initNavigationTelemetry(doc = document) {
|
|
|
250
235
|
recordInitialLoad(doc);
|
|
251
236
|
};
|
|
252
237
|
const handleDomContentLoaded = () => recordInitialLoad(doc);
|
|
253
|
-
const unsubscribeBeforeSwap = subscribeToNavigationEvents(doc, [
|
|
254
|
-
const unsubscribeAfterSwap = subscribeToNavigationEvents(doc, [
|
|
255
|
-
const unsubscribePageLoad = subscribeToNavigationEvents(doc, [
|
|
238
|
+
const unsubscribeBeforeSwap = subscribeToNavigationEvents(doc, [ECO_NAVIGATION_LIFECYCLE_EVENTS.BEFORE_SWAP], handleBeforeSwap);
|
|
239
|
+
const unsubscribeAfterSwap = subscribeToNavigationEvents(doc, [ECO_NAVIGATION_LIFECYCLE_EVENTS.AFTER_SWAP], handleAfterSwap);
|
|
240
|
+
const unsubscribePageLoad = subscribeToNavigationEvents(doc, [ECO_NAVIGATION_LIFECYCLE_EVENTS.PAGE_LOAD], handlePageLoad);
|
|
256
241
|
if (doc.readyState === 'complete' || doc.readyState === 'interactive') {
|
|
257
242
|
recordInitialLoad(doc);
|
|
258
243
|
}
|
|
@@ -21,6 +21,7 @@ export declare class EcoDevToolbar extends RadiantElement {
|
|
|
21
21
|
badges: Record<string, DevToolbarBadge | undefined>;
|
|
22
22
|
loadingApps: Record<string, boolean>;
|
|
23
23
|
mountedAppIds: string[];
|
|
24
|
+
buildErrors: string[];
|
|
24
25
|
/** Optional dock apps from the reference-toolbar internal registry (`window.__ECO_DEV_TOOLBAR_APPS__`). */
|
|
25
26
|
extensionApps: Array<{
|
|
26
27
|
id: string;
|
|
@@ -51,6 +52,8 @@ export declare class EcoDevToolbar extends RadiantElement {
|
|
|
51
52
|
private mountLegacyPanelWhenNeeded;
|
|
52
53
|
private wireDocumentListeners;
|
|
53
54
|
private unwireDocumentListeners;
|
|
55
|
+
private readonly handleBuildError;
|
|
56
|
+
private readonly handleBuildErrorClear;
|
|
54
57
|
private readonly handleOutsideClick;
|
|
55
58
|
private readonly handleNavigationStart;
|
|
56
59
|
private readonly handleNavigationEnd;
|
|
@@ -7,7 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ecopages/jsx/jsx-runtime";
|
|
8
8
|
/** @jsxImportSource @ecopages/jsx */
|
|
9
9
|
import '@ecopages/radiant/client/install-hydrator';
|
|
10
|
+
import { ECO_NAVIGATION_LIFECYCLE_EVENTS } from '@ecopages/core/client';
|
|
11
|
+
import { ECO_PERSIST_ATTRIBUTE } from '@ecopages/core/client';
|
|
10
12
|
import { RadiantElement } from '@ecopages/radiant';
|
|
13
|
+
import { BUILD_ERROR_EVENT, BUILD_ERROR_CLEAR_EVENT, BUILD_ERROR_REQUEST_EVENT, } from '../api/build-error-contract.js';
|
|
11
14
|
import { customElement } from '@ecopages/radiant/decorators/custom-element';
|
|
12
15
|
import { onUpdated } from '@ecopages/radiant/decorators/on-updated';
|
|
13
16
|
import { query } from '@ecopages/radiant/decorators/query';
|
|
@@ -27,6 +30,7 @@ import { DevToolbarNavigationLoading } from './navigation-loading.js';
|
|
|
27
30
|
import { DevToolbarStealthController } from './stealth-controller.js';
|
|
28
31
|
import { subscribeToNavigationEvents } from '../runtime/navigation-events.js';
|
|
29
32
|
const BUILT_IN_APPS = [
|
|
33
|
+
{ id: 'build-errors', label: 'Build errors' },
|
|
30
34
|
{ id: 'navigation', label: 'Navigation' },
|
|
31
35
|
{ id: 'deps', label: 'Deps' },
|
|
32
36
|
{ id: 'islands', label: 'Islands' },
|
|
@@ -44,6 +48,7 @@ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
|
|
|
44
48
|
badges = {};
|
|
45
49
|
loadingApps = {};
|
|
46
50
|
mountedAppIds = [];
|
|
51
|
+
buildErrors = [];
|
|
47
52
|
/** Optional dock apps from the reference-toolbar internal registry (`window.__ECO_DEV_TOOLBAR_APPS__`). */
|
|
48
53
|
extensionApps = [];
|
|
49
54
|
legacyPanel;
|
|
@@ -84,7 +89,7 @@ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
|
|
|
84
89
|
let host = document.querySelector(DEV_TOOLBAR_ELEMENT_NAME);
|
|
85
90
|
if (!host) {
|
|
86
91
|
host = document.createElement(DEV_TOOLBAR_ELEMENT_NAME);
|
|
87
|
-
host.setAttribute(
|
|
92
|
+
host.setAttribute(ECO_PERSIST_ATTRIBUTE, DEV_TOOLBAR_PERSIST_KEY);
|
|
88
93
|
document.documentElement.append(host);
|
|
89
94
|
}
|
|
90
95
|
return host;
|
|
@@ -101,8 +106,14 @@ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
|
|
|
101
106
|
if (this.stealthEnabled) {
|
|
102
107
|
this.stealthController.setPhase('hidden');
|
|
103
108
|
}
|
|
109
|
+
this.handleBuildErrorClear();
|
|
110
|
+
window.addEventListener(BUILD_ERROR_EVENT, this.handleBuildError);
|
|
111
|
+
window.addEventListener(BUILD_ERROR_CLEAR_EVENT, this.handleBuildErrorClear);
|
|
112
|
+
window.dispatchEvent(new Event(BUILD_ERROR_REQUEST_EVENT));
|
|
104
113
|
}
|
|
105
114
|
disconnectedCallback() {
|
|
115
|
+
window.removeEventListener(BUILD_ERROR_EVENT, this.handleBuildError);
|
|
116
|
+
window.removeEventListener(BUILD_ERROR_CLEAR_EVENT, this.handleBuildErrorClear);
|
|
106
117
|
this.unwireDocumentListeners();
|
|
107
118
|
this.stealthController.clearTimers();
|
|
108
119
|
this.navigationLoading.clear();
|
|
@@ -193,9 +204,9 @@ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
|
|
|
193
204
|
return;
|
|
194
205
|
}
|
|
195
206
|
document.addEventListener('click', this.handleOutsideClick, true);
|
|
196
|
-
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(document, [
|
|
197
|
-
const unsubscribeNavigationEnd = subscribeToNavigationEvents(document, [
|
|
198
|
-
const unsubscribeRouteChange = subscribeToNavigationEvents(document, [
|
|
207
|
+
this.unsubscribeNavigationEvents = subscribeToNavigationEvents(document, [ECO_NAVIGATION_LIFECYCLE_EVENTS.BEFORE_SWAP], this.handleNavigationStart);
|
|
208
|
+
const unsubscribeNavigationEnd = subscribeToNavigationEvents(document, [ECO_NAVIGATION_LIFECYCLE_EVENTS.AFTER_SWAP, ECO_NAVIGATION_LIFECYCLE_EVENTS.PAGE_LOAD], this.handleNavigationEnd);
|
|
209
|
+
const unsubscribeRouteChange = subscribeToNavigationEvents(document, [ECO_NAVIGATION_LIFECYCLE_EVENTS.AFTER_SWAP, ECO_NAVIGATION_LIFECYCLE_EVENTS.PAGE_LOAD], this.handleRouteChange);
|
|
199
210
|
const unsubscribeExisting = this.unsubscribeNavigationEvents;
|
|
200
211
|
this.unsubscribeNavigationEvents = () => {
|
|
201
212
|
unsubscribeExisting();
|
|
@@ -213,6 +224,22 @@ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
|
|
|
213
224
|
this.unsubscribeNavigationEvents = undefined;
|
|
214
225
|
this.documentListenersWired = false;
|
|
215
226
|
}
|
|
227
|
+
handleBuildError = (event) => {
|
|
228
|
+
const { message } = event.detail;
|
|
229
|
+
if (typeof message !== 'string')
|
|
230
|
+
return;
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
if (!this.buildErrors.includes(message))
|
|
233
|
+
this.buildErrors = [...this.buildErrors, message];
|
|
234
|
+
this.setAppBadge('build-errors', { count: this.buildErrors.length, severity: 'error' });
|
|
235
|
+
this.openApp('build-errors');
|
|
236
|
+
};
|
|
237
|
+
handleBuildErrorClear = () => {
|
|
238
|
+
this.buildErrors = [];
|
|
239
|
+
this.setAppBadge('build-errors', undefined);
|
|
240
|
+
if (this.activeAppId === 'build-errors')
|
|
241
|
+
this.closePanel();
|
|
242
|
+
};
|
|
216
243
|
handleOutsideClick = (event) => {
|
|
217
244
|
if (!this.panelOpen || event.composedPath().includes(this)) {
|
|
218
245
|
return;
|
|
@@ -258,6 +285,8 @@ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
|
|
|
258
285
|
renderAppIcon(appId) {
|
|
259
286
|
const loading = this.loadingApps[appId] === true;
|
|
260
287
|
switch (appId) {
|
|
288
|
+
case 'build-errors':
|
|
289
|
+
return (_jsx("span", { class: "eco-dev-toolbar__icon-text", "aria-hidden": "true", children: "!" }));
|
|
261
290
|
case 'navigation':
|
|
262
291
|
return _jsx(NavigationIcon, { loading: loading });
|
|
263
292
|
case 'deps':
|
|
@@ -281,6 +310,8 @@ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
|
|
|
281
310
|
renderRadiantPanelSlot(appId) {
|
|
282
311
|
const visible = this.panelOpen && this.activeAppId === appId;
|
|
283
312
|
switch (appId) {
|
|
313
|
+
case 'build-errors':
|
|
314
|
+
return (_jsx("div", { class: "eco-dev-toolbar__panel-slot", hidden: !visible, children: _jsxs("section", { class: "eco-dev-toolbar__panel", "aria-label": "Build errors", children: [_jsx("h2", { children: "Build errors" }), _jsx("div", { role: "alert", children: this.buildErrors.map((message) => (_jsx("pre", { class: "eco-dev-toolbar__build-error", children: message }, message))) }), this.buildErrors.length === 0 ? (_jsx("p", { class: "eco-dev-toolbar__muted", children: "No build errors." })) : null] }) }, appId));
|
|
284
315
|
case 'navigation':
|
|
285
316
|
return (_jsx("div", { class: "eco-dev-toolbar__panel-slot", hidden: !visible, children: _jsx("eco-dev-toolbar-navigation", {}) }, appId));
|
|
286
317
|
case 'deps':
|
|
@@ -343,6 +374,9 @@ __decorate([
|
|
|
343
374
|
__decorate([
|
|
344
375
|
state
|
|
345
376
|
], EcoDevToolbar.prototype, "mountedAppIds", void 0);
|
|
377
|
+
__decorate([
|
|
378
|
+
state
|
|
379
|
+
], EcoDevToolbar.prototype, "buildErrors", void 0);
|
|
346
380
|
__decorate([
|
|
347
381
|
state
|
|
348
382
|
], EcoDevToolbar.prototype, "extensionApps", void 0);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ECO_PERSIST_ATTRIBUTE } from '@ecopages/core/client';
|
|
1
2
|
import { DEV_TOOLBAR_PERSIST_KEY } from '../runtime/constants.js';
|
|
2
3
|
import { DEV_TOOLBAR_STYLES } from './styles.js';
|
|
3
4
|
export const DEV_TOOLBAR_STYLES_ELEMENT_ID = 'eco-dev-toolbar-styles';
|
|
@@ -12,7 +13,7 @@ export function ensureDevToolbarStyles(styles = DEV_TOOLBAR_STYLES) {
|
|
|
12
13
|
}
|
|
13
14
|
const style = document.createElement('style');
|
|
14
15
|
style.id = DEV_TOOLBAR_STYLES_ELEMENT_ID;
|
|
15
|
-
style.setAttribute(
|
|
16
|
+
style.setAttribute(ECO_PERSIST_ATTRIBUTE, DEV_TOOLBAR_PERSIST_KEY);
|
|
16
17
|
style.textContent = styles;
|
|
17
18
|
document.head.append(style);
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const DEV_TOOLBAR_CONTENT_STYLES = "\n.eco-dev-toolbar__panel {\n\tpadding: 0.95rem 1rem 1.05rem;\n\tdisplay: grid;\n\tgap: 1rem;\n}\n\n.eco-dev-toolbar__panel h2 {\n\tmargin: 0 0 0.5rem;\n\tfont-size: 0.92rem;\n\tfont-weight: 600;\n\tletter-spacing: 0.01em;\n}\n\n.eco-dev-toolbar__muted {\n\tcolor: var(--eco-dev-toolbar-muted);\n\tmargin: 0;\n}\n\n.eco-dev-toolbar__docs-link {\n\tcolor: var(--eco-dev-toolbar-accent);\n\ttext-decoration: none;\n}\n\n.eco-dev-toolbar__docs-link:hover {\n\ttext-decoration: underline;\n}\n\n.eco-dev-toolbar__warning {\n\tcolor: var(--eco-dev-toolbar-warning);\n\tmargin-top: 0.25rem;\n}\n\n.eco-dev-toolbar__kv {\n\tdisplay: grid;\n\tgap: 0.45rem;\n\tmargin: 0;\n}\n\n.eco-dev-toolbar__kv > div {\n\tdisplay: grid;\n\tgrid-template-columns: 6rem 1fr;\n\tgap: 0.5rem;\n}\n\n.eco-dev-toolbar__kv dt {\n\tmargin: 0;\n\tcolor: var(--eco-dev-toolbar-muted);\n}\n\n.eco-dev-toolbar__kv dd {\n\tmargin: 0;\n\tword-break: break-word;\n}\n\n.eco-dev-toolbar__mono {\n\tfont-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n\tfont-size: 0.72rem;\n\tword-break: break-all;\n}\n\n.eco-dev-toolbar__table-wrap {\n\toverflow: auto;\n\tborder: 1px solid rgba(255, 255, 255, 0.08);\n\tborder-radius: 0.55rem;\n}\n\n.eco-dev-toolbar__table {\n\twidth: 100%;\n\tborder-collapse: collapse;\n\tfont-size: 0.72rem;\n}\n\n.eco-dev-toolbar__table th,\n.eco-dev-toolbar__table td {\n\tpadding: 0.45rem 0.55rem;\n\ttext-align: left;\n\tborder-bottom: 1px solid rgba(255, 255, 255, 0.06);\n\tvertical-align: top;\n}\n\n.eco-dev-toolbar__table th {\n\tcolor: var(--eco-dev-toolbar-muted);\n\tfont-weight: 600;\n}\n\n.eco-dev-toolbar__table tbody tr:last-child td {\n\tborder-bottom: 0;\n}\n\n.eco-dev-toolbar__list {\n\tlist-style: none;\n\tpadding: 0;\n\tmargin: 0;\n\tdisplay: grid;\n\tgap: 0.65rem;\n}\n\n.eco-dev-toolbar__link {\n\tborder: 0;\n\tbackground: transparent;\n\tcolor: inherit;\n\tpadding: 0;\n\ttext-align: left;\n\tcursor: pointer;\n}\n\n.eco-dev-toolbar__list-entry {\n\tdisplay: grid;\n\tgap: 0.45rem;\n}\n\n.eco-dev-toolbar__issue-pagination {\n\tpadding: 0 0.15rem 0.1rem;\n}\n\n.eco-dev-toolbar__list-item {\n\tdisplay: grid;\n\tgap: 0.2rem;\n\twidth: 100%;\n\tborder: 1px solid rgba(255, 255, 255, 0.08);\n\tborder-radius: 0.5rem;\n\tbackground: color-mix(in srgb, var(--eco-dev-toolbar-bg) 92%, transparent);\n\tcolor: inherit;\n\tpadding: 0.55rem 0.65rem;\n\ttext-align: left;\n\tcursor: pointer;\n\ttransition: border-color 160ms var(--eco-dev-toolbar-ease);\n}\n\n.eco-dev-toolbar__dom-highlight[data-eco-dev-toolbar-highlight='a11y'] {\n\toutline: 2px solid #ff5c7a !important;\n\toutline-offset: 2px;\n}\n\n.eco-dev-toolbar__dom-highlight[data-eco-dev-toolbar-highlight='island'] {\n\toutline: 2px solid #7c5cff !important;\n\toutline-offset: 2px;\n}\n\n.eco-dev-toolbar__list-item:hover,\n.eco-dev-toolbar__list-item[data-highlighted='true'] {\n\tborder-color: rgba(139, 124, 255, 0.55);\n}\n\n.eco-dev-toolbar__pagination {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tgap: 0.75rem;\n}\n\n.eco-dev-toolbar__pagination-copy {\n\tmargin: 0;\n\tfont-size: 0.72rem;\n\tcolor: var(--eco-dev-toolbar-muted);\n}\n\n.eco-dev-toolbar__pagination-actions {\n\tdisplay: inline-flex;\n\tgap: 0.35rem;\n}\n\n.eco-dev-toolbar__pagination-button {\n\tborder: 1px solid rgba(255, 255, 255, 0.12);\n\tborder-radius: 0.45rem;\n\tbackground: color-mix(in srgb, var(--eco-dev-toolbar-bg) 92%, transparent);\n\tcolor: var(--eco-dev-toolbar-fg);\n\tfont: inherit;\n\tfont-size: 0.72rem;\n\tpadding: 0.28rem 0.55rem;\n\tcursor: pointer;\n}\n\n.eco-dev-toolbar__pagination-button:disabled {\n\topacity: 0.45;\n\tcursor: not-allowed;\n}\n\n.eco-dev-toolbar__status-pill {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tborder-radius: 999px;\n\tpadding: 0.1rem 0.45rem;\n\tfont-size: 0.68rem;\n\ttext-transform: uppercase;\n\tletter-spacing: 0.04em;\n}\n\n.eco-dev-toolbar__status-pill[data-status='aborted'] {\n\tbackground: rgba(245, 158, 11, 0.16);\n\tcolor: var(--eco-dev-toolbar-warning);\n}\n\n.eco-dev-toolbar__list-item strong {\n\tfont-size: 0.82rem;\n}\n\n.eco-dev-toolbar__list-item .eco-dev-toolbar__muted,\n.eco-dev-toolbar__list-item .eco-dev-toolbar__mono {\n\tdisplay: block;\n}\n\n.eco-dev-toolbar__field {\n\tdisplay: grid;\n\tgap: 0.35rem;\n}\n\n";
|
|
1
|
+
export declare const DEV_TOOLBAR_CONTENT_STYLES = "\n.eco-dev-toolbar__build-error {\n\twhite-space: pre-wrap;\n\toverflow-wrap: anywhere;\n\tfont: 0.75rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n\n.eco-dev-toolbar__panel {\n\tpadding: 0.95rem 1rem 1.05rem;\n\tdisplay: grid;\n\tgap: 1rem;\n}\n\n.eco-dev-toolbar__panel h2 {\n\tmargin: 0 0 0.5rem;\n\tfont-size: 0.92rem;\n\tfont-weight: 600;\n\tletter-spacing: 0.01em;\n}\n\n.eco-dev-toolbar__muted {\n\tcolor: var(--eco-dev-toolbar-muted);\n\tmargin: 0;\n}\n\n.eco-dev-toolbar__docs-link {\n\tcolor: var(--eco-dev-toolbar-accent);\n\ttext-decoration: none;\n}\n\n.eco-dev-toolbar__docs-link:hover {\n\ttext-decoration: underline;\n}\n\n.eco-dev-toolbar__warning {\n\tcolor: var(--eco-dev-toolbar-warning);\n\tmargin-top: 0.25rem;\n}\n\n.eco-dev-toolbar__kv {\n\tdisplay: grid;\n\tgap: 0.45rem;\n\tmargin: 0;\n}\n\n.eco-dev-toolbar__kv > div {\n\tdisplay: grid;\n\tgrid-template-columns: 6rem 1fr;\n\tgap: 0.5rem;\n}\n\n.eco-dev-toolbar__kv dt {\n\tmargin: 0;\n\tcolor: var(--eco-dev-toolbar-muted);\n}\n\n.eco-dev-toolbar__kv dd {\n\tmargin: 0;\n\tword-break: break-word;\n}\n\n.eco-dev-toolbar__mono {\n\tfont-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n\tfont-size: 0.72rem;\n\tword-break: break-all;\n}\n\n.eco-dev-toolbar__table-wrap {\n\toverflow: auto;\n\tborder: 1px solid rgba(255, 255, 255, 0.08);\n\tborder-radius: 0.55rem;\n}\n\n.eco-dev-toolbar__table {\n\twidth: 100%;\n\tborder-collapse: collapse;\n\tfont-size: 0.72rem;\n}\n\n.eco-dev-toolbar__table th,\n.eco-dev-toolbar__table td {\n\tpadding: 0.45rem 0.55rem;\n\ttext-align: left;\n\tborder-bottom: 1px solid rgba(255, 255, 255, 0.06);\n\tvertical-align: top;\n}\n\n.eco-dev-toolbar__table th {\n\tcolor: var(--eco-dev-toolbar-muted);\n\tfont-weight: 600;\n}\n\n.eco-dev-toolbar__table tbody tr:last-child td {\n\tborder-bottom: 0;\n}\n\n.eco-dev-toolbar__list {\n\tlist-style: none;\n\tpadding: 0;\n\tmargin: 0;\n\tdisplay: grid;\n\tgap: 0.65rem;\n}\n\n.eco-dev-toolbar__link {\n\tborder: 0;\n\tbackground: transparent;\n\tcolor: inherit;\n\tpadding: 0;\n\ttext-align: left;\n\tcursor: pointer;\n}\n\n.eco-dev-toolbar__list-entry {\n\tdisplay: grid;\n\tgap: 0.45rem;\n}\n\n.eco-dev-toolbar__issue-pagination {\n\tpadding: 0 0.15rem 0.1rem;\n}\n\n.eco-dev-toolbar__list-item {\n\tdisplay: grid;\n\tgap: 0.2rem;\n\twidth: 100%;\n\tborder: 1px solid rgba(255, 255, 255, 0.08);\n\tborder-radius: 0.5rem;\n\tbackground: color-mix(in srgb, var(--eco-dev-toolbar-bg) 92%, transparent);\n\tcolor: inherit;\n\tpadding: 0.55rem 0.65rem;\n\ttext-align: left;\n\tcursor: pointer;\n\ttransition: border-color 160ms var(--eco-dev-toolbar-ease);\n}\n\n.eco-dev-toolbar__dom-highlight[data-eco-dev-toolbar-highlight='a11y'] {\n\toutline: 2px solid #ff5c7a !important;\n\toutline-offset: 2px;\n}\n\n.eco-dev-toolbar__dom-highlight[data-eco-dev-toolbar-highlight='island'] {\n\toutline: 2px solid #7c5cff !important;\n\toutline-offset: 2px;\n}\n\n.eco-dev-toolbar__list-item:hover,\n.eco-dev-toolbar__list-item[data-highlighted='true'] {\n\tborder-color: rgba(139, 124, 255, 0.55);\n}\n\n.eco-dev-toolbar__pagination {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tgap: 0.75rem;\n}\n\n.eco-dev-toolbar__pagination-copy {\n\tmargin: 0;\n\tfont-size: 0.72rem;\n\tcolor: var(--eco-dev-toolbar-muted);\n}\n\n.eco-dev-toolbar__pagination-actions {\n\tdisplay: inline-flex;\n\tgap: 0.35rem;\n}\n\n.eco-dev-toolbar__pagination-button {\n\tborder: 1px solid rgba(255, 255, 255, 0.12);\n\tborder-radius: 0.45rem;\n\tbackground: color-mix(in srgb, var(--eco-dev-toolbar-bg) 92%, transparent);\n\tcolor: var(--eco-dev-toolbar-fg);\n\tfont: inherit;\n\tfont-size: 0.72rem;\n\tpadding: 0.28rem 0.55rem;\n\tcursor: pointer;\n}\n\n.eco-dev-toolbar__pagination-button:disabled {\n\topacity: 0.45;\n\tcursor: not-allowed;\n}\n\n.eco-dev-toolbar__status-pill {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tborder-radius: 999px;\n\tpadding: 0.1rem 0.45rem;\n\tfont-size: 0.68rem;\n\ttext-transform: uppercase;\n\tletter-spacing: 0.04em;\n}\n\n.eco-dev-toolbar__status-pill[data-status='aborted'] {\n\tbackground: rgba(245, 158, 11, 0.16);\n\tcolor: var(--eco-dev-toolbar-warning);\n}\n\n.eco-dev-toolbar__list-item strong {\n\tfont-size: 0.82rem;\n}\n\n.eco-dev-toolbar__list-item .eco-dev-toolbar__muted,\n.eco-dev-toolbar__list-item .eco-dev-toolbar__mono {\n\tdisplay: block;\n}\n\n.eco-dev-toolbar__field {\n\tdisplay: grid;\n\tgap: 0.35rem;\n}\n\n";
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export const DEV_TOOLBAR_CONTENT_STYLES = `
|
|
2
|
+
.eco-dev-toolbar__build-error {
|
|
3
|
+
white-space: pre-wrap;
|
|
4
|
+
overflow-wrap: anywhere;
|
|
5
|
+
font: 0.75rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
6
|
+
}
|
|
7
|
+
|
|
2
8
|
.eco-dev-toolbar__panel {
|
|
3
9
|
padding: 0.95rem 1rem 1.05rem;
|
|
4
10
|
display: grid;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { runBuiltinChecks } from './run-a11y-checks.js';
|
|
3
|
-
function createDocument(html) {
|
|
4
|
-
const template = document.createElement('template');
|
|
5
|
-
template.innerHTML = html.trim();
|
|
6
|
-
const doc = document.implementation.createHTMLDocument('a11y-test');
|
|
7
|
-
doc.body.replaceChildren(...Array.from(template.content.childNodes).map((node) => node.cloneNode(true)));
|
|
8
|
-
return doc;
|
|
9
|
-
}
|
|
10
|
-
function issueSnapshot(issues) {
|
|
11
|
-
return issues.map((issue) => ({
|
|
12
|
-
id: issue.id,
|
|
13
|
-
message: issue.message,
|
|
14
|
-
severity: issue.severity,
|
|
15
|
-
source: issue.source,
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
describe('runBuiltinChecks', () => {
|
|
19
|
-
it('reports builtin issues in document order', () => {
|
|
20
|
-
const doc = createDocument(`
|
|
21
|
-
<img src="/hero.png" />
|
|
22
|
-
<input />
|
|
23
|
-
<h1>Title</h1>
|
|
24
|
-
<h3>Section</h3>
|
|
25
|
-
`);
|
|
26
|
-
const issues = runBuiltinChecks(doc);
|
|
27
|
-
expect(issueSnapshot(issues)).toEqual([
|
|
28
|
-
{
|
|
29
|
-
id: 'img-alt',
|
|
30
|
-
message: 'Image is missing alt text',
|
|
31
|
-
severity: 'error',
|
|
32
|
-
source: 'builtin',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 'form-label',
|
|
36
|
-
message: 'Form control is missing an accessible label',
|
|
37
|
-
severity: 'error',
|
|
38
|
-
source: 'builtin',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
id: 'heading-order',
|
|
42
|
-
message: 'Heading level skips from h1 to h3',
|
|
43
|
-
severity: 'warning',
|
|
44
|
-
source: 'builtin',
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
});
|
|
48
|
-
it('ignores hidden inputs and honors aria labels', () => {
|
|
49
|
-
const doc = createDocument(`
|
|
50
|
-
<input type="hidden" name="token" value="secret" />
|
|
51
|
-
<input aria-label="Search" />
|
|
52
|
-
`);
|
|
53
|
-
const issues = runBuiltinChecks(doc);
|
|
54
|
-
expect(issues).toEqual([]);
|
|
55
|
-
});
|
|
56
|
-
it('reports duplicate ids', () => {
|
|
57
|
-
const doc = createDocument(`
|
|
58
|
-
<div id="panel"></div>
|
|
59
|
-
<section id="panel"></section>
|
|
60
|
-
`);
|
|
61
|
-
const issues = runBuiltinChecks(doc);
|
|
62
|
-
expect(issues).toHaveLength(1);
|
|
63
|
-
expect(issues[0]?.id).toBe('duplicate-id');
|
|
64
|
-
expect(issues[0]?.message).toBe('Duplicate id "panel"');
|
|
65
|
-
});
|
|
66
|
-
it('skips nodes inside eco-dev-toolbar', () => {
|
|
67
|
-
const doc = createDocument(`
|
|
68
|
-
<eco-dev-toolbar>
|
|
69
|
-
<img src="/logo.png" />
|
|
70
|
-
<input />
|
|
71
|
-
</eco-dev-toolbar>
|
|
72
|
-
<img src="/content.png" alt="Decorative" />
|
|
73
|
-
`);
|
|
74
|
-
const issues = runBuiltinChecks(doc);
|
|
75
|
-
expect(issues).toEqual([]);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { readIslandRecords, resolveIslandElement } from './read-island-records.js';
|
|
3
|
-
describe('readIslandRecords', () => {
|
|
4
|
-
it('deduplicates by component ID in favor of island container and preserves standalone elements', () => {
|
|
5
|
-
document.body.innerHTML = `
|
|
6
|
-
<div data-eco-island data-eco-component-id="inst-1">
|
|
7
|
-
<eco-island data-eco-island data-eco-component-id="inst-1"></eco-island>
|
|
8
|
-
</div>
|
|
9
|
-
<eco-island data-eco-island data-eco-component-key="standalone-1"></eco-island>
|
|
10
|
-
<eco-island data-eco-island data-eco-component-key="standalone-2"></eco-island>
|
|
11
|
-
`;
|
|
12
|
-
const records = readIslandRecords(document);
|
|
13
|
-
expect(records).toHaveLength(3);
|
|
14
|
-
expect(records[0].componentId).toBe('inst-1');
|
|
15
|
-
expect(records[0].hostTag).toBe('eco-island');
|
|
16
|
-
expect(records[1].componentKey).toBe('standalone-1');
|
|
17
|
-
expect(records[2].componentKey).toBe('standalone-2');
|
|
18
|
-
});
|
|
19
|
-
it('respects integration metadata over componentKey for island kind', () => {
|
|
20
|
-
document.body.innerHTML = `
|
|
21
|
-
<my-lit-island data-eco-island data-eco-island-integration="lit" data-eco-component-key="lit-counter"></my-lit-island>
|
|
22
|
-
<eco-island data-eco-island data-eco-component-key="react-counter"></eco-island>
|
|
23
|
-
`;
|
|
24
|
-
const records = readIslandRecords(document);
|
|
25
|
-
expect(records).toHaveLength(2);
|
|
26
|
-
expect(records[0].kind).toBe('integration');
|
|
27
|
-
expect(records[0].integration).toBe('lit');
|
|
28
|
-
expect(records[1].kind).toBe('react-island');
|
|
29
|
-
});
|
|
30
|
-
it('determines integration-specific lifecycle status for React, Lit, and custom elements', () => {
|
|
31
|
-
class TestRegisteredCustomElement extends HTMLElement {
|
|
32
|
-
}
|
|
33
|
-
if (!customElements.get('test-toolbar-registered')) {
|
|
34
|
-
customElements.define('test-toolbar-registered', TestRegisteredCustomElement);
|
|
35
|
-
}
|
|
36
|
-
class TestLitHydratedElement extends HTMLElement {
|
|
37
|
-
hasUpdated = true;
|
|
38
|
-
}
|
|
39
|
-
if (!customElements.get('test-toolbar-lit-hydrated')) {
|
|
40
|
-
customElements.define('test-toolbar-lit-hydrated', TestLitHydratedElement);
|
|
41
|
-
}
|
|
42
|
-
document.body.innerHTML = `
|
|
43
|
-
<eco-island data-eco-island data-eco-island-integration="react" data-eco-component-id="react-unhydrated"></eco-island>
|
|
44
|
-
<eco-island data-eco-island data-eco-island-integration="react" data-eco-hydrated="true" data-eco-component-id="react-hydrated"></eco-island>
|
|
45
|
-
<test-toolbar-lit-hydrated data-eco-island data-eco-island-integration="lit" defer-hydration></test-toolbar-lit-hydrated>
|
|
46
|
-
<test-toolbar-lit-hydrated data-eco-island data-eco-island-integration="lit"></test-toolbar-lit-hydrated>
|
|
47
|
-
<test-toolbar-registered data-eco-island data-eco-island-integration="ecopages-jsx"></test-toolbar-registered>
|
|
48
|
-
<test-toolbar-unregistered data-eco-island data-eco-island-integration="ecopages-jsx"></test-toolbar-unregistered>
|
|
49
|
-
`;
|
|
50
|
-
const records = readIslandRecords(document);
|
|
51
|
-
expect(records).toHaveLength(6);
|
|
52
|
-
// React without data-eco-hydrated
|
|
53
|
-
expect(records[0].status).toBe('ssr-only');
|
|
54
|
-
expect(records[0].hydrated).toBe(false);
|
|
55
|
-
// React with data-eco-hydrated
|
|
56
|
-
expect(records[1].status).toBe('hydrated');
|
|
57
|
-
expect(records[1].hydrated).toBe(true);
|
|
58
|
-
// Lit with defer-hydration
|
|
59
|
-
expect(records[2].status).toBe('registered');
|
|
60
|
-
expect(records[2].hydrated).toBe(false);
|
|
61
|
-
// Lit with completed initial update (hasUpdated = true)
|
|
62
|
-
expect(records[3].status).toBe('hydrated');
|
|
63
|
-
expect(records[3].hydrated).toBe(true);
|
|
64
|
-
// Custom element registered without update completion signal: registered, not hydrated
|
|
65
|
-
expect(records[4].status).toBe('registered');
|
|
66
|
-
expect(records[4].hydrated).toBe(false);
|
|
67
|
-
// Custom element not registered in customElements
|
|
68
|
-
expect(records[5].status).toBe('ssr-only');
|
|
69
|
-
expect(records[5].hydrated).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
describe('resolveIslandElement', () => {
|
|
73
|
-
it('does not resolve a removed instance to a sibling with the same component key', () => {
|
|
74
|
-
document.body.innerHTML = `
|
|
75
|
-
<eco-island data-eco-component-id="first" data-eco-component-key="shared"></eco-island>
|
|
76
|
-
<eco-island data-eco-component-id="second" data-eco-component-key="shared"></eco-island>
|
|
77
|
-
`;
|
|
78
|
-
const first = document.querySelector('[data-eco-component-id="first"]');
|
|
79
|
-
if (!(first instanceof HTMLElement))
|
|
80
|
-
throw new Error('missing first island');
|
|
81
|
-
first.remove();
|
|
82
|
-
expect(resolveIslandElement({
|
|
83
|
-
id: 'first',
|
|
84
|
-
label: 'first',
|
|
85
|
-
componentId: 'first',
|
|
86
|
-
componentKey: 'shared',
|
|
87
|
-
hostTag: 'eco-island',
|
|
88
|
-
kind: 'react-island',
|
|
89
|
-
propsPreview: '',
|
|
90
|
-
status: 'ssr-only',
|
|
91
|
-
hydrated: false,
|
|
92
|
-
targetSelector: '[data-eco-component-key="shared"]',
|
|
93
|
-
}, document)).toBeNull();
|
|
94
|
-
});
|
|
95
|
-
});
|