@ecopages/dev-toolbar 0.2.0-beta.34 → 0.2.0-beta.36

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 CHANGED
@@ -24,11 +24,13 @@ pnpm add -D @ecopages/dev-toolbar
24
24
 
25
25
  During `ecopages dev`, core bundles your configured package to `/_dev_toolbar.js` and injects the dev manifest for the Deps panel. Restart the dev server after toolbar client changes.
26
26
 
27
+ `@ecopages/dev-toolbar` mirrors the core manifest contract locally for browser bundling (`src/api/manifest-contract.ts`); keep it in sync via `manifest-contract.test.ts`.
28
+
27
29
  Disable per project with `devToolbar: { enabled: false }`, or per process with `ECOPAGES_DEV_TOOLBAR=false`.
28
30
 
29
31
  ## Built-in apps
30
32
 
31
- - **Navigation** — route timing archive, initial load, client navigation latency, HMR status, page Integration (route owner); writes `#__ECO_DEV_NAV_TELEMETRY__` for machine/AI debug
33
+ - **Navigation** — route timing archive, initial load, client navigation latency, HMR status, page Integration (route owner); writes `#__ECO_DEV_NAV_TELEMETRY__` in `document.head` (with `data-eco-persist`) and exposes `window.__ECO_DEV_NAV_TELEMETRY__` for machine/AI debug
32
34
  - **Deps** — Page Browser Graph entry/chunk assets, vendor URLs, lazy-load hints
33
35
  - **Islands** — inspect island hosts stamped with `data-eco-island` (plus legacy React `eco-island` roots); click a row to highlight the live DOM node
34
36
  - **A11y** — axe-core audit (with built-in fallback checks) and in-page highlights
@@ -56,6 +58,7 @@ To replace this reference toolbar:
56
58
  - `src/shell/eco-dev-toolbar.tsx` — Radiant light-DOM host (JSX `render()`, no shadow root); panel positioning is pure CSS
57
59
  - `src/shell/motion.ts` — WAAPI motion for stealth dock reveal only; panel show/hide is CSS
58
60
  - `src/apps/*-panel.tsx` — Radiant JSX panels (navigation, deps, islands, a11y, settings)
59
- - `src/api/` — manifest and app contracts
60
- - `src/apps/` — built-in toolbar apps
61
+ - `src/api/manifest-contract.ts` — browser-local mirror of the core dev manifest contract
62
+ - `src/api/dev-manifest.ts` — internal DOM read/write for `#__ECO_DEV_MANIFEST__`
63
+ - `src/api/types.ts` — toolbar app host contracts
61
64
  - `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.2.0-beta.34",
3
+ "version": "0.2.0-beta.36",
4
4
  "description": "Development toolbar for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -22,10 +22,6 @@
22
22
  "types": "./src/api/types.d.ts",
23
23
  "default": "./src/api/types.js"
24
24
  },
25
- "./manifest": {
26
- "types": "./src/api/dev-manifest.d.ts",
27
- "default": "./src/api/dev-manifest.js"
28
- },
29
25
  "./config.ts": {
30
26
  "types": "./src/config.d.ts",
31
27
  "default": "./src/config.js"
@@ -33,10 +29,6 @@
33
29
  "./api.ts": {
34
30
  "types": "./src/api/types.d.ts",
35
31
  "default": "./src/api/types.js"
36
- },
37
- "./manifest.ts": {
38
- "types": "./src/api/dev-manifest.d.ts",
39
- "default": "./src/api/dev-manifest.js"
40
32
  }
41
33
  },
42
34
  "repository": {
@@ -1,24 +1,4 @@
1
- export declare const DEV_MANIFEST_ELEMENT_ID = "__ECO_DEV_MANIFEST__";
2
- export type DevManifestAsset = {
3
- srcUrl?: string;
4
- kind: 'script' | 'stylesheet';
5
- packageRole?: string;
6
- inline?: boolean;
7
- };
8
- export type DevManifestPageBrowserGraph = {
9
- entryAssets: DevManifestAsset[];
10
- chunkAssets: DevManifestAsset[];
11
- };
12
- /**
13
- * Server-serialized development metadata injected into HTML responses.
14
- */
15
- export type EcoDevManifest = {
16
- route: string;
17
- integration?: string;
18
- pageBrowserGraph?: DevManifestPageBrowserGraph;
19
- vendorUrls: string[];
20
- devTransformUrls: string[];
21
- };
1
+ import { type EcoDevManifest } from './manifest-contract.js';
22
2
  /**
23
3
  * Parses `#__ECO_DEV_MANIFEST__` from the active document.
24
4
  *
@@ -1,4 +1,4 @@
1
- export const DEV_MANIFEST_ELEMENT_ID = '__ECO_DEV_MANIFEST__';
1
+ import { DEV_MANIFEST_ELEMENT_ID } from './manifest-contract.js';
2
2
  /**
3
3
  * Parses `#__ECO_DEV_MANIFEST__` from the active document.
4
4
  *
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Browser-local mirror of `@ecopages/core/dev-toolbar/dev-toolbar-manifest-contract`.
3
+ *
4
+ * @remarks Dev-toolbar is browser-bundled separately; Rolldown cannot resolve core
5
+ * package export subpaths from the client entry. Keep in sync with core via
6
+ * `manifest-contract.test.ts`.
7
+ */
8
+ export declare const DEV_MANIFEST_ELEMENT_ID = "__ECO_DEV_MANIFEST__";
9
+ export type DevManifestAsset = {
10
+ srcUrl?: string;
11
+ kind: 'script' | 'stylesheet';
12
+ packageRole?: string;
13
+ inline?: boolean;
14
+ };
15
+ export type DevManifestPageBrowserGraph = {
16
+ entryAssets: DevManifestAsset[];
17
+ chunkAssets: DevManifestAsset[];
18
+ };
19
+ export type EcoDevManifest = {
20
+ route: string;
21
+ integration?: string;
22
+ pageBrowserGraph?: DevManifestPageBrowserGraph;
23
+ vendorUrls: string[];
24
+ devTransformUrls: string[];
25
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Browser-local mirror of `@ecopages/core/dev-toolbar/dev-toolbar-manifest-contract`.
3
+ *
4
+ * @remarks Dev-toolbar is browser-bundled separately; Rolldown cannot resolve core
5
+ * package export subpaths from the client entry. Keep in sync with core via
6
+ * `manifest-contract.test.ts`.
7
+ */
8
+ export const DEV_MANIFEST_ELEMENT_ID = '__ECO_DEV_MANIFEST__';
@@ -1,4 +1,4 @@
1
- import type { EcoDevManifest } from './dev-manifest.js';
1
+ import type { EcoDevManifest } from './manifest-contract.js';
2
2
  export type DevToolbarBadge = {
3
3
  count?: number;
4
4
  severity?: 'info' | 'warning' | 'error';
@@ -1,7 +1,7 @@
1
1
  /** @jsxImportSource @ecopages/jsx */
2
2
  import { RadiantElement } from '@ecopages/radiant';
3
3
  import type { JsxCustomElementAttributes } from '@ecopages/jsx';
4
- import { type EcoDevManifest } from '../api/dev-manifest.js';
4
+ import type { EcoDevManifest } from '../api/manifest-contract.js';
5
5
  import { type NavigationTelemetrySnapshot } from '../runtime/navigation-telemetry.js';
6
6
  export declare class EcoDevToolbarNavigation extends RadiantElement {
7
7
  snapshot: NavigationTelemetrySnapshot | undefined;
@@ -4,6 +4,7 @@ export declare const DEV_TOOLBAR_PERSIST_KEY = "eco-dev-toolbar";
4
4
  export declare const DEV_TOOLBAR_PLACEMENT_STORAGE_KEY = "ecopages:dev-toolbar:placement";
5
5
  export declare const DEV_TOOLBAR_STEALTH_STORAGE_KEY = "ecopages:dev-toolbar:stealth";
6
6
  export declare const DEV_TOOLBAR_NAVIGATION_APP_ID = "navigation";
7
+ export declare const DEV_TOOLBAR_NAV_TELEMETRY_PERSIST_KEY = "eco-dev-toolbar-nav-telemetry";
7
8
  /** Full-opacity dwell after hover ends, before the fade phase. */
8
9
  export declare const DEV_TOOLBAR_STEALTH_DWELL_MS = 4000;
9
10
  /** Partial-opacity fade before the dock hides off-screen. */
@@ -4,6 +4,7 @@ export const DEV_TOOLBAR_PERSIST_KEY = 'eco-dev-toolbar';
4
4
  export const DEV_TOOLBAR_PLACEMENT_STORAGE_KEY = 'ecopages:dev-toolbar:placement';
5
5
  export const DEV_TOOLBAR_STEALTH_STORAGE_KEY = 'ecopages:dev-toolbar:stealth';
6
6
  export const DEV_TOOLBAR_NAVIGATION_APP_ID = 'navigation';
7
+ export const DEV_TOOLBAR_NAV_TELEMETRY_PERSIST_KEY = 'eco-dev-toolbar-nav-telemetry';
7
8
  /** Full-opacity dwell after hover ends, before the fade phase. */
8
9
  export const DEV_TOOLBAR_STEALTH_DWELL_MS = 4_000;
9
10
  /** Partial-opacity fade before the dock hides off-screen. */
@@ -1,3 +1,4 @@
1
+ import { DEV_TOOLBAR_NAV_TELEMETRY_PERSIST_KEY } from './constants.js';
1
2
  export const NAV_TELEMETRY_ELEMENT_ID = '__ECO_DEV_NAV_TELEMETRY__';
2
3
  export const NAV_TELEMETRY_STORAGE_KEY = 'ecopages:dev-toolbar:nav-telemetry';
3
4
  export const NAV_TELEMETRY_MAX_ENTRIES = 50;
@@ -98,6 +99,9 @@ function buildSnapshot() {
98
99
  summary: summarize(history),
99
100
  };
100
101
  }
102
+ function escapeTelemetryJson(snapshot) {
103
+ return JSON.stringify(snapshot).replace(/</g, '\\u003c');
104
+ }
101
105
  function syncTelemetryElement(doc = getTelemetryDocument()) {
102
106
  const snapshot = buildSnapshot();
103
107
  let element = doc.getElementById(NAV_TELEMETRY_ELEMENT_ID);
@@ -105,10 +109,11 @@ function syncTelemetryElement(doc = getTelemetryDocument()) {
105
109
  const script = doc.createElement('script');
106
110
  script.id = NAV_TELEMETRY_ELEMENT_ID;
107
111
  script.setAttribute('type', 'application/json');
112
+ script.setAttribute('data-eco-persist', DEV_TOOLBAR_NAV_TELEMETRY_PERSIST_KEY);
108
113
  element = script;
109
- doc.body.append(element);
114
+ doc.head.append(element);
110
115
  }
111
- element.textContent = JSON.stringify(snapshot);
116
+ element.textContent = escapeTelemetryJson(snapshot);
112
117
  window.__ECO_DEV_NAV_TELEMETRY__ = createNavigationTelemetryApi();
113
118
  return snapshot;
114
119
  }
@@ -242,15 +247,16 @@ export function initNavigationTelemetry(doc = document) {
242
247
  }
243
248
  export function readNavigationTelemetrySnapshot(doc = document) {
244
249
  const element = doc.getElementById(NAV_TELEMETRY_ELEMENT_ID);
245
- if (!element?.textContent) {
246
- return undefined;
247
- }
248
- try {
249
- return JSON.parse(element.textContent);
250
- }
251
- catch {
252
- return undefined;
250
+ if (element?.textContent) {
251
+ try {
252
+ return JSON.parse(element.textContent);
253
+ }
254
+ catch {
255
+ // Fall through to the in-memory API when the DOM trace is stale or invalid.
256
+ }
253
257
  }
258
+ const api = window.__ECO_DEV_NAV_TELEMETRY__;
259
+ return api?.getSnapshot();
254
260
  }
255
261
  /** Clears persisted navigation history and the DOM telemetry trace. */
256
262
  export function clearNavigationTelemetryHistory() {
@@ -6,7 +6,7 @@ import '../apps/deps-panel.js';
6
6
  import '../apps/islands-panel.js';
7
7
  import '../apps/navigation-panel.js';
8
8
  import '../apps/settings-panel.js';
9
- import { type EcoDevManifest } from '../api/dev-manifest.js';
9
+ import type { EcoDevManifest } from '../api/manifest-contract.js';
10
10
  import type { DevToolbarBadge } from '../api/types.js';
11
11
  import { DEV_TOOLBAR_ELEMENT_NAME } from '../runtime/constants.js';
12
12
  import { type DevToolbarPlacement } from '../runtime/preferences.js';