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

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
@@ -28,7 +28,7 @@ Disable per project with `devToolbar: { enabled: false }`, or per process with `
28
28
 
29
29
  ## Built-in apps
30
30
 
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
31
+ - **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
32
  - **Deps** — Page Browser Graph entry/chunk assets, vendor URLs, lazy-load hints
33
33
  - **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
34
  - **A11y** — axe-core audit (with built-in fallback checks) and in-page highlights
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.35",
4
4
  "description": "Development toolbar for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -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() {