@ecopages/dev-toolbar 0.2.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +61 -0
  2. package/package.json +54 -0
  3. package/src/api/dev-manifest.d.ts +33 -0
  4. package/src/api/dev-manifest.js +34 -0
  5. package/src/api/types.d.ts +21 -0
  6. package/src/api/types.js +1 -0
  7. package/src/apps/a11y/a11y-badge.d.ts +3 -0
  8. package/src/apps/a11y/a11y-badge.js +10 -0
  9. package/src/apps/a11y/a11y-issue-groups.d.ts +12 -0
  10. package/src/apps/a11y/a11y-issue-groups.js +27 -0
  11. package/src/apps/a11y/audit-cache.d.ts +6 -0
  12. package/src/apps/a11y/audit-cache.js +16 -0
  13. package/src/apps/a11y/dom-path.d.ts +10 -0
  14. package/src/apps/a11y/dom-path.js +32 -0
  15. package/src/apps/a11y/run-a11y-checks.d.ts +30 -0
  16. package/src/apps/a11y/run-a11y-checks.js +286 -0
  17. package/src/apps/a11y-panel.d.ts +29 -0
  18. package/src/apps/a11y-panel.js +163 -0
  19. package/src/apps/deps/load-deps-insights.d.ts +19 -0
  20. package/src/apps/deps/load-deps-insights.js +76 -0
  21. package/src/apps/deps-panel.d.ts +24 -0
  22. package/src/apps/deps-panel.js +100 -0
  23. package/src/apps/islands-panel.d.ts +26 -0
  24. package/src/apps/islands-panel.js +126 -0
  25. package/src/apps/navigation-panel.d.ts +25 -0
  26. package/src/apps/navigation-panel.js +95 -0
  27. package/src/apps/settings-panel.d.ts +17 -0
  28. package/src/apps/settings-panel.js +58 -0
  29. package/src/bootstrap.d.ts +1 -0
  30. package/src/bootstrap.js +6 -0
  31. package/src/config.d.ts +14 -0
  32. package/src/config.js +10 -0
  33. package/src/islands/island-discovery.d.ts +5 -0
  34. package/src/islands/island-discovery.js +99 -0
  35. package/src/islands/island-record-builder.d.ts +21 -0
  36. package/src/islands/island-record-builder.js +100 -0
  37. package/src/islands/read-island-records.d.ts +11 -0
  38. package/src/islands/read-island-records.js +43 -0
  39. package/src/runtime/constants.d.ts +20 -0
  40. package/src/runtime/constants.js +20 -0
  41. package/src/runtime/highlight-element.d.ts +3 -0
  42. package/src/runtime/highlight-element.js +46 -0
  43. package/src/runtime/navigation-telemetry.d.ts +51 -0
  44. package/src/runtime/navigation-telemetry.js +259 -0
  45. package/src/runtime/preferences.d.ts +9 -0
  46. package/src/runtime/preferences.js +32 -0
  47. package/src/shell/badges.d.ts +2 -0
  48. package/src/shell/badges.js +9 -0
  49. package/src/shell/brand-logo.d.ts +4 -0
  50. package/src/shell/brand-logo.js +4 -0
  51. package/src/shell/eco-dev-toolbar.d.ts +67 -0
  52. package/src/shell/eco-dev-toolbar.js +356 -0
  53. package/src/shell/ensure-dev-toolbar-styles.d.ts +7 -0
  54. package/src/shell/ensure-dev-toolbar-styles.js +18 -0
  55. package/src/shell/icons.d.ts +8 -0
  56. package/src/shell/icons.js +29 -0
  57. package/src/shell/legacy-app-host.d.ts +23 -0
  58. package/src/shell/legacy-app-host.js +36 -0
  59. package/src/shell/motion.d.ts +6 -0
  60. package/src/shell/motion.js +82 -0
  61. package/src/shell/navigation-loading.d.ts +14 -0
  62. package/src/shell/navigation-loading.js +39 -0
  63. package/src/shell/panel-slot-visibility.d.ts +10 -0
  64. package/src/shell/panel-slot-visibility.js +25 -0
  65. package/src/shell/stealth-controller.d.ts +27 -0
  66. package/src/shell/stealth-controller.js +83 -0
  67. package/src/shell/styles/base.d.ts +1 -0
  68. package/src/shell/styles/base.js +65 -0
  69. package/src/shell/styles/content.d.ts +1 -0
  70. package/src/shell/styles/content.js +209 -0
  71. package/src/shell/styles/dock.d.ts +1 -0
  72. package/src/shell/styles/dock.js +207 -0
  73. package/src/shell/styles/index.d.ts +1 -0
  74. package/src/shell/styles/index.js +12 -0
  75. package/src/shell/styles/panel.d.ts +1 -0
  76. package/src/shell/styles/panel.js +121 -0
  77. package/src/shell/styles/settings.d.ts +1 -0
  78. package/src/shell/styles/settings.js +206 -0
  79. package/src/shell/styles.d.ts +1 -0
  80. package/src/shell/styles.js +1 -0
@@ -0,0 +1,356 @@
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 '@ecopages/radiant/client/install-hydrator';
10
+ import { RadiantElement } from '@ecopages/radiant';
11
+ import { customElement } from '@ecopages/radiant/decorators/custom-element';
12
+ import { onUpdated } from '@ecopages/radiant/decorators/on-updated';
13
+ import { query } from '@ecopages/radiant/decorators/query';
14
+ import { state } from '@ecopages/radiant/decorators/state';
15
+ import '../apps/a11y-panel.js';
16
+ import '../apps/deps-panel.js';
17
+ import '../apps/islands-panel.js';
18
+ import '../apps/navigation-panel.js';
19
+ import '../apps/settings-panel.js';
20
+ import { readDevManifestFromDocument, updateDevManifestInDocument } from '../api/dev-manifest.js';
21
+ import { DEV_TOOLBAR_ELEMENT_NAME, DEV_TOOLBAR_PERSIST_KEY } from '../runtime/constants.js';
22
+ import { readDevToolbarPreferences, writeDevToolbarPreferences, } from '../runtime/preferences.js';
23
+ import { A11yIcon, DepsIcon, IslandsIcon, NavigationIcon, SettingsIcon } from './icons.js';
24
+ import { badgesEqual } from './badges.js';
25
+ import { DevToolbarLegacyAppHost } from './legacy-app-host.js';
26
+ import { DevToolbarNavigationLoading } from './navigation-loading.js';
27
+ import { DevToolbarStealthController } from './stealth-controller.js';
28
+ const BUILT_IN_APPS = [
29
+ { id: 'navigation', label: 'Navigation' },
30
+ { id: 'deps', label: 'Deps' },
31
+ { id: 'islands', label: 'Islands' },
32
+ { id: 'a11y', label: 'A11y' },
33
+ { id: 'settings', label: 'Settings' },
34
+ ];
35
+ const RADIANT_APP_IDS = new Set(BUILT_IN_APPS.map((app) => app.id));
36
+ let EcoDevToolbar = class EcoDevToolbar extends RadiantElement {
37
+ placement = readDevToolbarPreferences().placement;
38
+ stealthEnabled = readDevToolbarPreferences().stealth;
39
+ stealthPhase = readDevToolbarPreferences().stealth ? 'hidden' : 'visible';
40
+ hovered = false;
41
+ panelOpen = false;
42
+ activeAppId = null;
43
+ badges = {};
44
+ loadingApps = {};
45
+ mountedAppIds = [];
46
+ /** Optional dock apps from the reference-toolbar internal registry (`window.__ECO_DEV_TOOLBAR_APPS__`). */
47
+ extensionApps = [];
48
+ legacyPanel;
49
+ cleanupActiveApp;
50
+ documentListenersWired = false;
51
+ routeListeners = new Set();
52
+ legacyAppHost = new DevToolbarLegacyAppHost();
53
+ stealthController;
54
+ navigationLoading;
55
+ constructor() {
56
+ super();
57
+ this.stealthController = new DevToolbarStealthController({
58
+ onPhaseChange: (phase) => {
59
+ this.stealthPhase = phase;
60
+ },
61
+ isPanelOpen: () => this.panelOpen,
62
+ isEnabled: () => this.stealthEnabled,
63
+ getShellElement: () => this.getRef('shell'),
64
+ getPlacement: () => this.placement,
65
+ });
66
+ this.navigationLoading = new DevToolbarNavigationLoading({
67
+ onLoadingChange: (appId, loading) => {
68
+ if (!loading) {
69
+ if (!this.loadingApps[appId]) {
70
+ return;
71
+ }
72
+ const next = { ...this.loadingApps };
73
+ delete next[appId];
74
+ this.loadingApps = next;
75
+ return;
76
+ }
77
+ this.loadingApps = { ...this.loadingApps, [appId]: true };
78
+ },
79
+ });
80
+ }
81
+ static mount() {
82
+ let host = document.querySelector(DEV_TOOLBAR_ELEMENT_NAME);
83
+ if (!host) {
84
+ host = document.createElement(DEV_TOOLBAR_ELEMENT_NAME);
85
+ host.setAttribute('data-eco-persist', DEV_TOOLBAR_PERSIST_KEY);
86
+ document.documentElement.append(host);
87
+ }
88
+ return host;
89
+ }
90
+ connectedCallback() {
91
+ super.connectedCallback();
92
+ const panelShell = this.querySelector('.eco-dev-toolbar__panel-shell');
93
+ if (panelShell instanceof HTMLElement) {
94
+ panelShell.removeAttribute('style');
95
+ }
96
+ this.legacyAppHost.registerFromWindow();
97
+ this.extensionApps = this.legacyAppHost.listApps().map((app) => ({ id: app.id, label: app.label }));
98
+ this.wireDocumentListeners();
99
+ if (this.stealthEnabled) {
100
+ this.stealthController.setPhase('hidden');
101
+ }
102
+ }
103
+ disconnectedCallback() {
104
+ this.unwireDocumentListeners();
105
+ this.stealthController.clearTimers();
106
+ this.navigationLoading.clear();
107
+ this.cleanupActiveApp?.();
108
+ this.cleanupActiveApp = undefined;
109
+ super.disconnectedCallback();
110
+ }
111
+ setAppBadge(appId, badge) {
112
+ const current = this.badges[appId];
113
+ if (badgesEqual(current, badge)) {
114
+ return;
115
+ }
116
+ if (badge === undefined) {
117
+ const next = { ...this.badges };
118
+ delete next[appId];
119
+ this.badges = next;
120
+ return;
121
+ }
122
+ this.badges = { ...this.badges, [appId]: badge };
123
+ }
124
+ notifyRouteChange(manifest) {
125
+ if (manifest) {
126
+ updateDevManifestInDocument(manifest);
127
+ }
128
+ this.navigationLoading.end();
129
+ this.closePanel();
130
+ for (const listener of this.routeListeners) {
131
+ listener();
132
+ }
133
+ this.querySelector('eco-dev-toolbar-navigation')?.refreshSnapshot();
134
+ }
135
+ applyPreferences(partial) {
136
+ const next = writeDevToolbarPreferences(partial);
137
+ this.placement = next.placement;
138
+ this.stealthEnabled = next.stealth;
139
+ if (!next.stealth) {
140
+ this.stealthController.clearTimers();
141
+ this.stealthController.setPhase('visible');
142
+ return;
143
+ }
144
+ if (!this.panelOpen) {
145
+ this.stealthController.schedule();
146
+ }
147
+ }
148
+ handleShellEnter() {
149
+ this.hovered = true;
150
+ this.stealthController.reveal();
151
+ }
152
+ handleShellLeave(event) {
153
+ this.handlePointerLeave(event);
154
+ }
155
+ handleShellClick() {
156
+ if (!this.stealthEnabled || this.panelOpen || this.stealthPhase !== 'hidden') {
157
+ return;
158
+ }
159
+ this.hovered = true;
160
+ this.stealthController.reveal();
161
+ }
162
+ handlePointerLeave(event) {
163
+ const related = event.relatedTarget;
164
+ if (related instanceof Node && this.contains(related)) {
165
+ return;
166
+ }
167
+ this.hovered = false;
168
+ if (!this.panelOpen) {
169
+ this.stealthController.schedule();
170
+ }
171
+ }
172
+ mountLegacyPanelWhenNeeded() {
173
+ this.cleanupActiveApp?.();
174
+ this.cleanupActiveApp = undefined;
175
+ if (!this.activeAppId || RADIANT_APP_IDS.has(this.activeAppId) || !this.legacyPanel) {
176
+ return;
177
+ }
178
+ const cleanup = this.legacyAppHost.mount(this.activeAppId, this.legacyPanel, {
179
+ onBadgeChange: (appId, badge) => this.setAppBadge(appId, badge),
180
+ onRouteListener: (listener) => {
181
+ this.routeListeners.add(listener);
182
+ return () => this.routeListeners.delete(listener);
183
+ },
184
+ });
185
+ if (cleanup) {
186
+ this.cleanupActiveApp = cleanup;
187
+ }
188
+ }
189
+ wireDocumentListeners() {
190
+ if (this.documentListenersWired) {
191
+ return;
192
+ }
193
+ document.addEventListener('click', this.handleOutsideClick, true);
194
+ document.addEventListener('eco:before-swap', this.handleNavigationStart);
195
+ document.addEventListener('eco:after-swap', this.handleNavigationEnd);
196
+ document.addEventListener('eco:page-load', this.handleNavigationEnd);
197
+ document.addEventListener('eco:page-load', this.handleRouteChange);
198
+ document.addEventListener('eco:after-swap', this.handleRouteChange);
199
+ this.documentListenersWired = true;
200
+ }
201
+ unwireDocumentListeners() {
202
+ if (!this.documentListenersWired) {
203
+ return;
204
+ }
205
+ document.removeEventListener('click', this.handleOutsideClick, true);
206
+ document.removeEventListener('eco:before-swap', this.handleNavigationStart);
207
+ document.removeEventListener('eco:after-swap', this.handleNavigationEnd);
208
+ document.removeEventListener('eco:page-load', this.handleNavigationEnd);
209
+ document.removeEventListener('eco:page-load', this.handleRouteChange);
210
+ document.removeEventListener('eco:after-swap', this.handleRouteChange);
211
+ this.documentListenersWired = false;
212
+ }
213
+ handleOutsideClick = (event) => {
214
+ if (!this.panelOpen || event.composedPath().includes(this)) {
215
+ return;
216
+ }
217
+ this.closePanel();
218
+ };
219
+ handleNavigationStart = () => {
220
+ this.navigationLoading.begin();
221
+ };
222
+ handleNavigationEnd = () => {
223
+ this.navigationLoading.end();
224
+ };
225
+ handleRouteChange = () => {
226
+ this.notifyRouteChange();
227
+ };
228
+ toggleApp(appId) {
229
+ if (this.activeAppId === appId) {
230
+ this.closePanel();
231
+ return;
232
+ }
233
+ this.openApp(appId);
234
+ }
235
+ openApp(appId) {
236
+ this.cleanupActiveApp?.();
237
+ this.cleanupActiveApp = undefined;
238
+ if (RADIANT_APP_IDS.has(appId) && !this.mountedAppIds.includes(appId)) {
239
+ this.mountedAppIds = [...this.mountedAppIds, appId];
240
+ }
241
+ this.activeAppId = appId;
242
+ this.panelOpen = true;
243
+ this.stealthController.reveal();
244
+ }
245
+ closePanel() {
246
+ if (!this.panelOpen) {
247
+ return;
248
+ }
249
+ this.cleanupActiveApp?.();
250
+ this.cleanupActiveApp = undefined;
251
+ this.activeAppId = null;
252
+ this.panelOpen = false;
253
+ this.stealthController.schedule();
254
+ }
255
+ renderAppIcon(appId) {
256
+ const loading = this.loadingApps[appId] === true;
257
+ switch (appId) {
258
+ case 'navigation':
259
+ return _jsx(NavigationIcon, { loading: loading });
260
+ case 'deps':
261
+ return _jsx(DepsIcon, {});
262
+ case 'islands':
263
+ return _jsx(IslandsIcon, {});
264
+ case 'a11y':
265
+ return _jsx(A11yIcon, {});
266
+ case 'settings':
267
+ return _jsx(SettingsIcon, {});
268
+ default:
269
+ return _jsx("span", { class: "eco-dev-toolbar__icon-text", children: appId.slice(0, 1).toUpperCase() });
270
+ }
271
+ }
272
+ renderDockButton(app) {
273
+ const pressed = this.activeAppId === app.id;
274
+ const loading = this.loadingApps[app.id] === true;
275
+ const badge = this.badges[app.id];
276
+ return (_jsxs("button", { type: "button", class: "eco-dev-toolbar__button", title: app.label, "aria-label": app.label, "aria-pressed": pressed, "aria-busy": loading, "data-loading": loading ? 'true' : undefined, "on:click": () => this.toggleApp(app.id), children: [this.renderAppIcon(app.id), badge?.count ? (_jsx("span", { class: "eco-dev-toolbar__badge", "data-severity": badge.severity, children: badge.count })) : null] }, app.id));
277
+ }
278
+ renderRadiantPanelSlot(appId) {
279
+ const visible = this.panelOpen && this.activeAppId === appId;
280
+ switch (appId) {
281
+ case 'navigation':
282
+ return (_jsx("div", { class: "eco-dev-toolbar__panel-slot", hidden: !visible, children: _jsx("eco-dev-toolbar-navigation", {}) }, appId));
283
+ case 'deps':
284
+ return (_jsx("div", { class: "eco-dev-toolbar__panel-slot", hidden: !visible, children: _jsx("eco-dev-toolbar-deps", {}) }, appId));
285
+ case 'islands':
286
+ return (_jsx("div", { class: "eco-dev-toolbar__panel-slot", hidden: !visible, children: _jsx("eco-dev-toolbar-islands", {}) }, appId));
287
+ case 'a11y':
288
+ return (_jsx("div", { class: "eco-dev-toolbar__panel-slot", hidden: !visible, children: _jsx("eco-dev-toolbar-a11y", {}) }, appId));
289
+ case 'settings':
290
+ return (_jsx("div", { class: "eco-dev-toolbar__panel-slot", hidden: !visible, children: _jsx("eco-dev-toolbar-settings", {}) }, appId));
291
+ default:
292
+ return null;
293
+ }
294
+ }
295
+ renderLegacyPanel() {
296
+ if (!this.panelOpen || !this.activeAppId || RADIANT_APP_IDS.has(this.activeAppId)) {
297
+ return null;
298
+ }
299
+ return _jsx("div", { "data-ref": "legacyPanel", class: "eco-dev-toolbar__panel-slot" });
300
+ }
301
+ renderActivePanel() {
302
+ const radiantSlots = this.mountedAppIds.map((appId) => this.renderRadiantPanelSlot(appId));
303
+ const legacyPanel = this.renderLegacyPanel();
304
+ if (radiantSlots.length === 0 && !legacyPanel) {
305
+ return null;
306
+ }
307
+ return (_jsxs(_Fragment, { children: [radiantSlots, legacyPanel] }));
308
+ }
309
+ render() {
310
+ this.dataset.placement = this.placement;
311
+ this.dataset.panelOpen = this.panelOpen ? 'true' : undefined;
312
+ const dockEmphasized = this.hovered || this.panelOpen;
313
+ return (_jsxs(_Fragment, { children: [_jsx("div", { "data-ref": "panelShell", class: "eco-dev-toolbar__panel-shell", "on:mouseenter": () => this.handleShellEnter(), "on:mouseleave": (event) => this.handlePointerLeave(event), children: this.renderActivePanel() }), this.panelOpen ? (_jsx("div", { class: "eco-dev-toolbar__hit-bridge", "data-placement": this.placement, "aria-hidden": "true", "on:mouseenter": () => this.handleShellEnter(), "on:mouseleave": (event) => this.handlePointerLeave(event) })) : null, _jsx("div", { "data-ref": "shell", class: "eco-dev-toolbar__shell", "data-placement": this.placement, "data-open": this.panelOpen ? 'true' : undefined, "data-stealth": this.stealthPhase === 'hidden' ? 'true' : undefined, "data-stealth-phase": this.stealthPhase === 'dwell' || this.stealthPhase === 'fade' ? this.stealthPhase : undefined, "data-hover": dockEmphasized ? 'true' : undefined, "on:mouseenter": () => this.handleShellEnter(), "on:mouseleave": (event) => this.handleShellLeave(event), "on:click": () => this.handleShellClick(), children: _jsxs("div", { class: "eco-dev-toolbar__dock", role: "toolbar", "aria-label": "Ecopages dev toolbar", children: [BUILT_IN_APPS.map((app) => this.renderDockButton(app)), this.extensionApps.map((app) => this.renderDockButton(app))] }) })] }));
314
+ }
315
+ };
316
+ __decorate([
317
+ state
318
+ ], EcoDevToolbar.prototype, "placement", void 0);
319
+ __decorate([
320
+ state
321
+ ], EcoDevToolbar.prototype, "stealthEnabled", void 0);
322
+ __decorate([
323
+ state
324
+ ], EcoDevToolbar.prototype, "stealthPhase", void 0);
325
+ __decorate([
326
+ state
327
+ ], EcoDevToolbar.prototype, "hovered", void 0);
328
+ __decorate([
329
+ state
330
+ ], EcoDevToolbar.prototype, "panelOpen", void 0);
331
+ __decorate([
332
+ state
333
+ ], EcoDevToolbar.prototype, "activeAppId", void 0);
334
+ __decorate([
335
+ state
336
+ ], EcoDevToolbar.prototype, "badges", void 0);
337
+ __decorate([
338
+ state
339
+ ], EcoDevToolbar.prototype, "loadingApps", void 0);
340
+ __decorate([
341
+ state
342
+ ], EcoDevToolbar.prototype, "mountedAppIds", void 0);
343
+ __decorate([
344
+ state
345
+ ], EcoDevToolbar.prototype, "extensionApps", void 0);
346
+ __decorate([
347
+ query({ ref: 'legacyPanel' })
348
+ ], EcoDevToolbar.prototype, "legacyPanel", void 0);
349
+ __decorate([
350
+ onUpdated('activeAppId')
351
+ ], EcoDevToolbar.prototype, "mountLegacyPanelWhenNeeded", null);
352
+ EcoDevToolbar = __decorate([
353
+ customElement(DEV_TOOLBAR_ELEMENT_NAME)
354
+ ], EcoDevToolbar);
355
+ export { EcoDevToolbar };
356
+ export { DEV_TOOLBAR_ELEMENT_NAME };
@@ -0,0 +1,7 @@
1
+ export declare const DEV_TOOLBAR_STYLES_ELEMENT_ID = "eco-dev-toolbar-styles";
2
+ /**
3
+ * @remarks
4
+ * Radiant JSX does not populate `<style>` text children the way a static tag would.
5
+ * Inject once into `document.head` so toolbar rules apply globally in light DOM.
6
+ */
7
+ export declare function ensureDevToolbarStyles(styles?: string): void;
@@ -0,0 +1,18 @@
1
+ import { DEV_TOOLBAR_PERSIST_KEY } from '../runtime/constants.js';
2
+ import { DEV_TOOLBAR_STYLES } from './styles.js';
3
+ export const DEV_TOOLBAR_STYLES_ELEMENT_ID = 'eco-dev-toolbar-styles';
4
+ /**
5
+ * @remarks
6
+ * Radiant JSX does not populate `<style>` text children the way a static tag would.
7
+ * Inject once into `document.head` so toolbar rules apply globally in light DOM.
8
+ */
9
+ export function ensureDevToolbarStyles(styles = DEV_TOOLBAR_STYLES) {
10
+ if (document.getElementById(DEV_TOOLBAR_STYLES_ELEMENT_ID)) {
11
+ return;
12
+ }
13
+ const style = document.createElement('style');
14
+ style.id = DEV_TOOLBAR_STYLES_ELEMENT_ID;
15
+ style.setAttribute('data-eco-persist', DEV_TOOLBAR_PERSIST_KEY);
16
+ style.textContent = styles;
17
+ document.head.append(style);
18
+ }
@@ -0,0 +1,8 @@
1
+ /** @jsxImportSource @ecopages/jsx */
2
+ export declare function NavigationIcon({ loading }: {
3
+ loading?: boolean;
4
+ }): import("@ecopages/jsx").JsxRenderable;
5
+ export declare function DepsIcon(): import("@ecopages/jsx").JsxRenderable;
6
+ export declare function IslandsIcon(): import("@ecopages/jsx").JsxRenderable;
7
+ export declare function A11yIcon(): import("@ecopages/jsx").JsxRenderable;
8
+ export declare function SettingsIcon(): import("@ecopages/jsx").JsxRenderable;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@ecopages/jsx/jsx-runtime";
2
+ /** @jsxImportSource @ecopages/jsx */
3
+ const SVG_PROPS = {
4
+ xmlns: 'http://www.w3.org/2000/svg',
5
+ width: 15,
6
+ height: 15,
7
+ viewBox: '0 0 16 16',
8
+ fill: 'none',
9
+ stroke: 'currentColor',
10
+ 'stroke-width': 1.5,
11
+ 'stroke-linecap': 'round',
12
+ 'stroke-linejoin': 'round',
13
+ 'aria-hidden': true,
14
+ };
15
+ export function NavigationIcon({ loading = false }) {
16
+ return (_jsx("svg", { ...SVG_PROPS, children: loading ? (_jsx("path", { d: "M8 2.5a5.5 5.5 0 1 1 0 11", class: "eco-dev-toolbar__spinner-arc" })) : (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "4.25", cy: "8", r: "1.5" }), _jsx("path", { d: "M6 8h5.5" }), _jsx("path", { d: "m10.5 5.5 2.5 2.5-2.5 2.5" })] })) }));
17
+ }
18
+ export function DepsIcon() {
19
+ return (_jsxs("svg", { ...SVG_PROPS, children: [_jsx("path", { d: "M8 2.25 2.75 5.25 8 8.25l5.25-3-5.25-3Z" }), _jsx("path", { d: "m2.75 8.25 5.25 3 5.25-3" }), _jsx("path", { d: "m2.75 11.25 5.25 3 5.25-3" })] }));
20
+ }
21
+ export function IslandsIcon() {
22
+ return (_jsxs("svg", { ...SVG_PROPS, children: [_jsx("rect", { x: "2.25", y: "2.25", width: "5.25", height: "5.25", rx: "1" }), _jsx("rect", { x: "8.5", y: "8.5", width: "5.25", height: "5.25", rx: "1" }), _jsx("path", { d: "M7.5 5h1.75M5 7.5v1.75" })] }));
23
+ }
24
+ export function A11yIcon() {
25
+ return (_jsxs("svg", { ...SVG_PROPS, children: [_jsx("circle", { cx: "8", cy: "3.75", r: "1.25" }), _jsx("path", { d: "M5.25 6.75h5.5" }), _jsx("path", { d: "M6.25 6.75 5 12.75" }), _jsx("path", { d: "M9.75 6.75 11 12.75" }), _jsx("path", { d: "M7 10.25h2" })] }));
26
+ }
27
+ export function SettingsIcon() {
28
+ return (_jsxs("svg", { ...SVG_PROPS, children: [_jsx("path", { d: "M2.25 5.25h11.5" }), _jsx("path", { d: "M2.25 10.75h11.5" }), _jsx("circle", { cx: "5.25", cy: "5.25", r: "1.25" }), _jsx("circle", { cx: "10.75", cy: "10.75", r: "1.25" })] }));
29
+ }
@@ -0,0 +1,23 @@
1
+ import type { DevToolbarApp, DevToolbarBadge } from '../api/types.js';
2
+ export type LegacyAppHostContext = {
3
+ onBadgeChange: (appId: string, badge: DevToolbarBadge | undefined) => void;
4
+ onRouteListener: (listener: () => void) => () => void;
5
+ };
6
+ /**
7
+ * Mounts optional extension dock apps from `window.__ECO_DEV_TOOLBAR_APPS__`.
8
+ *
9
+ * @remarks Internal to `@ecopages/dev-toolbar`. Not a stable Ecopages platform API.
10
+ * App authors extend the toolbar by replacing `devToolbar.package`, not this registry.
11
+ */
12
+ export declare class DevToolbarLegacyAppHost {
13
+ private readonly apps;
14
+ registerFromWindow(): void;
15
+ listApps(): DevToolbarApp[];
16
+ mount(appId: string, mountTarget: HTMLElement, context: LegacyAppHostContext): (() => void) | undefined;
17
+ }
18
+ declare global {
19
+ interface Window {
20
+ /** Reference-toolbar internal registry. Not a supported extension API for app authors. */
21
+ __ECO_DEV_TOOLBAR_APPS__?: Array<() => DevToolbarApp>;
22
+ }
23
+ }
@@ -0,0 +1,36 @@
1
+ import { readDevManifestFromDocument } from '../api/dev-manifest.js';
2
+ /**
3
+ * Mounts optional extension dock apps from `window.__ECO_DEV_TOOLBAR_APPS__`.
4
+ *
5
+ * @remarks Internal to `@ecopages/dev-toolbar`. Not a stable Ecopages platform API.
6
+ * App authors extend the toolbar by replacing `devToolbar.package`, not this registry.
7
+ */
8
+ export class DevToolbarLegacyAppHost {
9
+ apps = new Map();
10
+ registerFromWindow() {
11
+ for (const factory of window.__ECO_DEV_TOOLBAR_APPS__ ?? []) {
12
+ const app = factory();
13
+ this.apps.set(app.id, app);
14
+ }
15
+ }
16
+ listApps() {
17
+ return [...this.apps.values()];
18
+ }
19
+ mount(appId, mountTarget, context) {
20
+ const app = this.apps.get(appId);
21
+ if (!app) {
22
+ return undefined;
23
+ }
24
+ mountTarget.replaceChildren();
25
+ const cleanup = app.mount({
26
+ document,
27
+ manifest: readDevManifestFromDocument(document),
28
+ mountTarget,
29
+ onBadgeChange: (badge) => {
30
+ context.onBadgeChange(app.id, badge);
31
+ },
32
+ onRouteChange: context.onRouteListener,
33
+ });
34
+ return typeof cleanup === 'function' ? cleanup : undefined;
35
+ }
36
+ }
@@ -0,0 +1,6 @@
1
+ import type { DevToolbarPlacement } from '../runtime/preferences.js';
2
+ export declare function prefersReducedMotion(): boolean;
3
+ /**
4
+ * @remarks WAAPI slide-in when stealth mode hands control back to the dock.
5
+ */
6
+ export declare function runStealthRevealMotion(shell: HTMLElement, placement: DevToolbarPlacement): Animation | undefined;
@@ -0,0 +1,82 @@
1
+ const TOOLBAR_EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';
2
+ export function prefersReducedMotion() {
3
+ return globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
4
+ }
5
+ function cancelElementAnimations(element) {
6
+ for (const animation of element.getAnimations()) {
7
+ animation.cancel();
8
+ }
9
+ }
10
+ function setMotionActive(element, active) {
11
+ if (active) {
12
+ element.dataset.motion = 'active';
13
+ return;
14
+ }
15
+ delete element.dataset.motion;
16
+ }
17
+ function finishMotion(element, animation) {
18
+ const cleanup = () => {
19
+ setMotionActive(element, false);
20
+ };
21
+ animation.addEventListener('finish', cleanup, { once: true });
22
+ animation.addEventListener('cancel', cleanup, { once: true });
23
+ }
24
+ function resolveStealthPeek(shell) {
25
+ const value = getComputedStyle(shell).getPropertyValue('--eco-dev-toolbar-stealth-peek').trim();
26
+ return value || '0.12rem';
27
+ }
28
+ function hiddenShellTransform(shell, placement) {
29
+ const peek = resolveStealthPeek(shell);
30
+ switch (placement) {
31
+ case 'top':
32
+ return `translateY(calc(-100% + ${peek}))`;
33
+ case 'left':
34
+ return `translateX(calc(-100% + ${peek}))`;
35
+ case 'right':
36
+ return `translateX(calc(100% - ${peek}))`;
37
+ case 'bottom':
38
+ default:
39
+ return `translateY(calc(100% - ${peek}))`;
40
+ }
41
+ }
42
+ function visibleShellTransform() {
43
+ return 'translate(0, 0)';
44
+ }
45
+ /**
46
+ * @remarks WAAPI slide-in when stealth mode hands control back to the dock.
47
+ */
48
+ export function runStealthRevealMotion(shell, placement) {
49
+ if (prefersReducedMotion()) {
50
+ return;
51
+ }
52
+ cancelElementAnimations(shell);
53
+ setMotionActive(shell, true);
54
+ const animation = shell.animate([
55
+ { transform: hiddenShellTransform(shell, placement), opacity: 0.55 },
56
+ { transform: visibleShellTransform(), opacity: 1 },
57
+ ], {
58
+ duration: 380,
59
+ easing: TOOLBAR_EASE,
60
+ fill: 'both',
61
+ });
62
+ finishMotion(shell, animation);
63
+ const dock = shell.querySelector('.eco-dev-toolbar__dock');
64
+ if (dock) {
65
+ runDockRevealMotion(dock);
66
+ }
67
+ return animation;
68
+ }
69
+ function runDockRevealMotion(dock) {
70
+ if (prefersReducedMotion()) {
71
+ return;
72
+ }
73
+ cancelElementAnimations(dock);
74
+ return dock.animate([
75
+ { transform: 'scale(0.94)', opacity: 0.45 },
76
+ { transform: 'scale(1)', opacity: 1 },
77
+ ], {
78
+ duration: 320,
79
+ easing: TOOLBAR_EASE,
80
+ fill: 'both',
81
+ });
82
+ }
@@ -0,0 +1,14 @@
1
+ type NavigationLoadingOptions = {
2
+ onLoadingChange: (appId: string, loading: boolean) => void;
3
+ };
4
+ export declare class DevToolbarNavigationLoading {
5
+ private readonly options;
6
+ private delayTimer;
7
+ private timeoutTimer;
8
+ private loading;
9
+ constructor(options: NavigationLoadingOptions);
10
+ begin(): void;
11
+ end(): void;
12
+ clear(): void;
13
+ }
14
+ export {};
@@ -0,0 +1,39 @@
1
+ import { DEV_TOOLBAR_NAVIGATION_APP_ID, DEV_TOOLBAR_NAVIGATION_LOADING_DELAY_MS, DEV_TOOLBAR_NAVIGATION_LOADING_TIMEOUT_MS, } from '../runtime/constants.js';
2
+ export class DevToolbarNavigationLoading {
3
+ options;
4
+ delayTimer;
5
+ timeoutTimer;
6
+ loading = false;
7
+ constructor(options) {
8
+ this.options = options;
9
+ }
10
+ begin() {
11
+ this.clear();
12
+ this.delayTimer = setTimeout(() => {
13
+ this.delayTimer = undefined;
14
+ this.loading = true;
15
+ this.options.onLoadingChange(DEV_TOOLBAR_NAVIGATION_APP_ID, true);
16
+ this.timeoutTimer = setTimeout(() => {
17
+ this.end();
18
+ }, DEV_TOOLBAR_NAVIGATION_LOADING_TIMEOUT_MS);
19
+ }, DEV_TOOLBAR_NAVIGATION_LOADING_DELAY_MS);
20
+ }
21
+ end() {
22
+ this.clear();
23
+ if (!this.loading) {
24
+ return;
25
+ }
26
+ this.loading = false;
27
+ this.options.onLoadingChange(DEV_TOOLBAR_NAVIGATION_APP_ID, false);
28
+ }
29
+ clear() {
30
+ if (this.delayTimer !== undefined) {
31
+ clearTimeout(this.delayTimer);
32
+ this.delayTimer = undefined;
33
+ }
34
+ if (this.timeoutTimer !== undefined) {
35
+ clearTimeout(this.timeoutTimer);
36
+ this.timeoutTimer = undefined;
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whether a panel element's keep-alive slot is visible (not `hidden`).
3
+ */
4
+ export declare function isPanelSlotVisible(element: Element): boolean;
5
+ /**
6
+ * Invokes `onVisible` when a keep-alive panel slot becomes visible again.
7
+ *
8
+ * @returns Disconnect function for the observer.
9
+ */
10
+ export declare function observePanelSlotVisibility(element: Element, onVisible: () => void): () => void;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Whether a panel element's keep-alive slot is visible (not `hidden`).
3
+ */
4
+ export function isPanelSlotVisible(element) {
5
+ const slot = element.closest('.eco-dev-toolbar__panel-slot');
6
+ return slot instanceof HTMLElement && !slot.hidden;
7
+ }
8
+ /**
9
+ * Invokes `onVisible` when a keep-alive panel slot becomes visible again.
10
+ *
11
+ * @returns Disconnect function for the observer.
12
+ */
13
+ export function observePanelSlotVisibility(element, onVisible) {
14
+ const slot = element.closest('.eco-dev-toolbar__panel-slot');
15
+ if (!(slot instanceof HTMLElement)) {
16
+ return () => { };
17
+ }
18
+ const observer = new MutationObserver(() => {
19
+ if (isPanelSlotVisible(element)) {
20
+ onVisible();
21
+ }
22
+ });
23
+ observer.observe(slot, { attributes: true, attributeFilter: ['hidden'] });
24
+ return () => observer.disconnect();
25
+ }