@vistagenic/vista 0.2.16 → 0.3.2
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/bin/vista.js +184 -177
- package/dist/ai/agent.d.ts +37 -0
- package/dist/ai/agent.js +385 -0
- package/dist/ai/embeddings.d.ts +11 -0
- package/dist/ai/embeddings.js +71 -0
- package/dist/ai/index.d.ts +10 -0
- package/dist/ai/index.js +26 -0
- package/dist/ai/memory.d.ts +16 -0
- package/dist/ai/memory.js +39 -0
- package/dist/ai/observability.d.ts +21 -0
- package/dist/ai/observability.js +69 -0
- package/dist/ai/providers/anthropic.d.ts +2 -0
- package/dist/ai/providers/anthropic.js +190 -0
- package/dist/ai/providers/base.d.ts +7 -0
- package/dist/ai/providers/base.js +85 -0
- package/dist/ai/providers/gemini.d.ts +2 -0
- package/dist/ai/providers/gemini.js +194 -0
- package/dist/ai/providers/index.d.ts +5 -0
- package/dist/ai/providers/index.js +21 -0
- package/dist/ai/providers/mock.d.ts +8 -0
- package/dist/ai/providers/mock.js +77 -0
- package/dist/ai/providers/openai.d.ts +2 -0
- package/dist/ai/providers/openai.js +211 -0
- package/dist/ai/rag.d.ts +35 -0
- package/dist/ai/rag.js +110 -0
- package/dist/ai/react/index.d.ts +1 -0
- package/dist/ai/react/index.js +17 -0
- package/dist/ai/react/react-server.d.ts +1 -0
- package/dist/ai/react/react-server.js +17 -0
- package/dist/ai/react/use-agent.d.ts +23 -0
- package/dist/ai/react/use-agent.js +138 -0
- package/dist/ai/stream.d.ts +24 -0
- package/dist/ai/stream.js +109 -0
- package/dist/ai/tool.d.ts +11 -0
- package/dist/ai/tool.js +47 -0
- package/dist/ai/types.d.ts +117 -0
- package/dist/ai/types.js +5 -0
- package/dist/auth/core.d.ts +140 -0
- package/dist/auth/core.js +165 -0
- package/dist/auth/index.d.ts +20 -8
- package/dist/auth/index.js +369 -16
- package/dist/auth/react-server.d.ts +1 -0
- package/dist/auth/react-server.js +10 -0
- package/dist/auth/react.d.ts +18 -0
- package/dist/auth/react.js +71 -0
- package/dist/bin/build-rsc.js +602 -604
- package/dist/bin/build.js +389 -388
- package/dist/bin/deploy-output.d.ts +2 -7
- package/dist/bin/deploy-output.js +3 -76
- package/dist/bin/deploy.d.ts +7 -0
- package/dist/bin/deploy.js +102 -0
- package/dist/bin/dev-error-overlay-snippet.js +778 -552
- package/dist/bin/devtools-indicator-snippet.js +387 -387
- package/dist/bin/generate.js +510 -248
- package/dist/build/manifest.d.ts +169 -139
- package/dist/build/manifest.js +423 -367
- package/dist/build/rsc/client-manifest.d.ts +62 -52
- package/dist/build/rsc/client-manifest.js +295 -193
- package/dist/build/rsc/client-reference-plugin.d.ts +37 -37
- package/dist/build/rsc/client-reference-plugin.js +160 -160
- package/dist/build/rsc/native-scanner.d.ts +135 -123
- package/dist/build/rsc/native-scanner.js +203 -170
- package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -22
- package/dist/build/rsc/react-client-reference-manifest.js +240 -219
- package/dist/build/rsc/rsc-renderer.d.ts +99 -99
- package/dist/build/rsc/rsc-renderer.js +263 -263
- package/dist/build/rsc/server-component-loader.d.ts +19 -19
- package/dist/build/rsc/server-component-loader.js +91 -91
- package/dist/build/rsc/server-manifest.d.ts +17 -0
- package/dist/build/rsc/server-manifest.js +20 -0
- package/dist/build/standalone.js +337 -334
- package/dist/build/webpack/plugins/vista-flight-plugin.js +5 -5
- package/dist/client/dynamic.react-server.d.ts +2 -0
- package/dist/client/dynamic.react-server.js +23 -0
- package/dist/client/link.react-server.d.ts +2 -0
- package/dist/client/link.react-server.js +11 -0
- package/dist/client/navigation.react-server.d.ts +1 -0
- package/dist/client/navigation.react-server.js +17 -0
- package/dist/client/router.react-server.d.ts +1 -0
- package/dist/client/router.react-server.js +17 -0
- package/dist/client/rsc-router.react-server.d.ts +1 -0
- package/dist/client/rsc-router.react-server.js +17 -0
- package/dist/client/script.react-server.d.ts +2 -0
- package/dist/client/script.react-server.js +23 -0
- package/dist/components/client-island.d.ts +34 -34
- package/dist/components/client-island.js +75 -75
- package/dist/config.d.ts +17 -0
- package/dist/config.js +60 -1
- package/dist/deploy/adapters/cloudflare.d.ts +2 -0
- package/dist/deploy/adapters/cloudflare.js +124 -0
- package/dist/deploy/adapters/docker.d.ts +2 -0
- package/dist/deploy/adapters/docker.js +112 -0
- package/dist/deploy/adapters/index.d.ts +15 -0
- package/dist/deploy/adapters/index.js +24 -0
- package/dist/deploy/adapters/netlify.d.ts +2 -0
- package/dist/deploy/adapters/netlify.js +115 -0
- package/dist/deploy/adapters/render.d.ts +2 -0
- package/dist/deploy/adapters/render.js +95 -0
- package/dist/deploy/adapters/vercel.d.ts +7 -0
- package/dist/deploy/adapters/vercel.js +164 -0
- package/dist/deploy/cli-runner.d.ts +8 -0
- package/dist/deploy/cli-runner.js +58 -0
- package/dist/deploy/detect.d.ts +6 -0
- package/dist/deploy/detect.js +77 -0
- package/dist/deploy/index.d.ts +24 -0
- package/dist/deploy/index.js +112 -0
- package/dist/deploy/preflight.d.ts +8 -0
- package/dist/deploy/preflight.js +80 -0
- package/dist/deploy/types.d.ts +48 -0
- package/dist/deploy/types.js +2 -0
- package/dist/deploy/utils.d.ts +18 -0
- package/dist/deploy/utils.js +70 -0
- package/dist/dev-error.d.ts +14 -0
- package/dist/dev-error.js +1763 -705
- package/dist/index.d.ts +23 -21
- package/dist/index.js +61 -57
- package/dist/server/cookie-parse.d.ts +4 -0
- package/dist/server/cookie-parse.js +14 -0
- package/dist/server/engine.js +7 -26
- package/dist/server/index.d.ts +109 -102
- package/dist/server/index.js +315 -286
- package/dist/server/middleware-runner.d.ts +125 -57
- package/dist/server/middleware-runner.js +615 -218
- package/dist/server/middleware-security.d.ts +36 -0
- package/dist/server/middleware-security.js +183 -0
- package/dist/server/module-compile-hook.js +695 -662
- package/dist/server/route-handler-registry.d.ts +65 -0
- package/dist/server/route-handler-registry.js +195 -0
- package/dist/server/route-patterns.d.ts +67 -0
- package/dist/server/route-patterns.js +186 -0
- package/dist/server/rsc-engine.js +75 -92
- package/dist/server/rsc-module-system.d.ts +33 -33
- package/dist/server/rsc-module-system.js +87 -87
- package/dist/server/rsc-upstream.js +892 -888
- package/dist/server/static-generator.js +10 -10
- package/dist/server/typed-api-runtime.d.ts +18 -0
- package/dist/server/typed-api-runtime.js +635 -507
- package/dist/server/vista-import-map.js +134 -123
- package/dist/stack/index.d.ts +34 -32
- package/dist/stack/index.js +49 -45
- package/dist/stack/server/caller.d.ts +13 -0
- package/dist/stack/server/caller.js +42 -0
- package/dist/stack/server/executor.d.ts +40 -36
- package/dist/stack/server/executor.js +222 -174
- package/dist/stack/server/index.d.ts +11 -10
- package/dist/stack/server/index.js +24 -23
- package/dist/stack/server/procedure.d.ts +20 -18
- package/dist/stack/server/procedure.js +66 -58
- package/dist/stack/server/types.d.ts +113 -100
- package/dist/theme/react-server.d.ts +10 -0
- package/dist/theme/react-server.js +16 -0
- package/package.json +28 -3
- package/LICENSE +0 -21
|
@@ -7,392 +7,392 @@ exports.getDevToolsIndicatorBootstrapSource = getDevToolsIndicatorBootstrapSourc
|
|
|
7
7
|
*/
|
|
8
8
|
function getDevToolsIndicatorBootstrapSource(bootSessionId) {
|
|
9
9
|
const escapedBootSessionId = JSON.stringify(bootSessionId);
|
|
10
|
-
return `
|
|
11
|
-
(function installVistaDevToolsIndicator() {
|
|
12
|
-
if (typeof window === 'undefined' || typeof document === 'undefined') return;
|
|
13
|
-
var hideStorageKey = '__vista_devtools_hidden_boot__';
|
|
14
|
-
var hideBootId = ${escapedBootSessionId};
|
|
15
|
-
|
|
16
|
-
function mount() {
|
|
17
|
-
var existingIndicator = window.__VISTA_DEVTOOLS_INDICATOR__;
|
|
18
|
-
if (existingIndicator && existingIndicator.hidden === true) {
|
|
19
|
-
try {
|
|
20
|
-
var hiddenBootId = window.sessionStorage.getItem(hideStorageKey);
|
|
21
|
-
if (hiddenBootId !== hideBootId) {
|
|
22
|
-
window.__VISTA_DEVTOOLS_INDICATOR__ = undefined;
|
|
23
|
-
existingIndicator = undefined;
|
|
24
|
-
}
|
|
25
|
-
} catch (e) {}
|
|
26
|
-
}
|
|
27
|
-
if (existingIndicator && typeof existingIndicator.ensureAttached === 'function') {
|
|
28
|
-
if (existingIndicator.ensureAttached()) return;
|
|
29
|
-
window.__VISTA_DEVTOOLS_INDICATOR__ = undefined;
|
|
30
|
-
existingIndicator = undefined;
|
|
31
|
-
}
|
|
32
|
-
if (existingIndicator) {
|
|
33
|
-
var mountedRoot = document.getElementById('__vista-devtools-root');
|
|
34
|
-
var mountedStyle = document.getElementById('__vista-devtools-style');
|
|
35
|
-
if (mountedRoot && mountedStyle) return;
|
|
36
|
-
window.__VISTA_DEVTOOLS_INDICATOR__ = undefined;
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
if (window.sessionStorage.getItem(hideStorageKey) === hideBootId) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
} catch (e) {}
|
|
43
|
-
|
|
44
|
-
var style = document.getElementById('__vista-devtools-style');
|
|
45
|
-
if (!style) {
|
|
46
|
-
style = document.createElement('style');
|
|
47
|
-
style.id = '__vista-devtools-style';
|
|
48
|
-
style.textContent = [
|
|
49
|
-
'#__vista-devtools-root{position:fixed;left:28px;bottom:22px;z-index:2147482000;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;color:#fff;}',
|
|
50
|
-
'#__vista-devtools-root [data-vista-trigger]{width:40px;height:40px;border-radius:9999px;border:1px solid rgba(255,255,255,0.2);background:rgba(0,0,0,0.82);display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 10px 24px rgba(0,0,0,0.4);position:relative;transition:transform 180ms ease,border-color 180ms ease,background 180ms ease,width 180ms ease,padding 180ms ease,gap 180ms ease;}',
|
|
51
|
-
'#__vista-devtools-root [data-vista-trigger]:hover{transform:translateY(-1px);border-color:rgba(255,255,255,0.42);background:rgba(0,0,0,0.92);}',
|
|
52
|
-
'#__vista-devtools-root [data-vista-trigger]:focus-visible{outline:2px solid rgba(255,255,255,0.65);outline-offset:2px;}',
|
|
53
|
-
'#__vista-devtools-root [data-vista-trigger][data-busy="true"]{border-color:rgba(255,255,255,0.5);}',
|
|
54
|
-
'#__vista-devtools-root [data-vista-trigger][data-error="true"]{width:86px;padding:0 8px;justify-content:flex-start;gap:6px;border-color:rgba(248,113,113,0.9);background:rgba(53,11,16,0.94);box-shadow:0 10px 24px rgba(248,113,113,0.24);}',
|
|
55
|
-
'#__vista-devtools-root .vista-devtools-logo{display:block;width:16px;height:16px;}',
|
|
56
|
-
'#__vista-devtools-root .vista-devtools-logo svg{width:100%;height:100%;display:block;}',
|
|
57
|
-
'#__vista-devtools-root [data-vista-trigger][data-error="true"] .vista-devtools-logo{width:14px;height:14px;}',
|
|
58
|
-
'#__vista-devtools-root .vista-devtools-logo-fill{fill:#fff;opacity:1;transition:opacity 180ms ease;}',
|
|
59
|
-
'#__vista-devtools-root .vista-devtools-logo-draw{fill:none;stroke:#fff;stroke-width:12;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:100;stroke-dashoffset:100;opacity:0;}',
|
|
60
|
-
'#__vista-devtools-root [data-vista-trigger][data-busy="true"] .vista-devtools-logo-fill{opacity:0.18;}',
|
|
61
|
-
'#__vista-devtools-root [data-vista-trigger][data-busy="true"] .vista-devtools-logo-draw{opacity:1;animation:vista-devtools-v-draw 900ms ease-in-out infinite;}',
|
|
62
|
-
'#__vista-devtools-root .vista-devtools-error-pill{display:inline-flex;align-items:center;gap:4px;padding:2px 7px;border-radius:999px;border:1px solid rgba(248,113,113,0.65);background:rgba(248,113,113,0.16);color:#fecaca;font-size:11px;font-weight:670;font-variant-numeric:tabular-nums;line-height:1;}',
|
|
63
|
-
'#__vista-devtools-root .vista-devtools-error-close{font-size:11px;line-height:1;color:#fca5a5;}',
|
|
64
|
-
'#__vista-devtools-root [data-vista-panel]{position:absolute;left:0;bottom:50px;width:244px;padding:10px;border-radius:12px;border:1px solid rgba(255,255,255,0.18);background:rgba(8,8,8,0.94);backdrop-filter:blur(8px);box-shadow:0 16px 36px rgba(0,0,0,0.45);}',
|
|
65
|
-
'#__vista-devtools-root [data-vista-panel][hidden]{display:none;}',
|
|
66
|
-
'#__vista-devtools-root .vista-devtools-title{font-size:11px;letter-spacing:0.08em;text-transform:uppercase;color:rgba(255,255,255,0.72);margin:0 0 8px;}',
|
|
67
|
-
'#__vista-devtools-root .vista-devtools-row{font-size:12px;display:flex;justify-content:space-between;gap:10px;margin:4px 0;color:rgba(255,255,255,0.92);}',
|
|
68
|
-
'#__vista-devtools-root .vista-devtools-key{color:rgba(255,255,255,0.6);}',
|
|
69
|
-
'#__vista-devtools-root .vista-devtools-value{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;max-width:148px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}',
|
|
70
|
-
'#__vista-devtools-root .vista-devtools-actions{margin-top:8px;padding-top:8px;border-top:1px solid rgba(255,255,255,0.12);display:flex;justify-content:flex-end;}',
|
|
71
|
-
'#__vista-devtools-root [data-vista-hide]{font-size:11px;line-height:1;padding:6px 8px;border-radius:8px;border:1px solid rgba(255,255,255,0.26);background:transparent;color:rgba(255,255,255,0.85);cursor:pointer;transition:background 140ms ease,border-color 140ms ease,color 140ms ease;display:inline-flex;align-items:center;gap:5px;}',
|
|
72
|
-
'#__vista-devtools-root [data-vista-hide]:hover{background:rgba(255,255,255,0.12);border-color:rgba(255,255,255,0.5);color:#fff;}',
|
|
73
|
-
'#__vista-devtools-root .vista-hide-icon{width:12px;height:12px;display:block;}',
|
|
74
|
-
'@keyframes vista-devtools-v-draw{0%{stroke-dashoffset:100;opacity:0.35;}45%{stroke-dashoffset:0;opacity:1;}72%{stroke-dashoffset:0;opacity:1;}100%{stroke-dashoffset:-100;opacity:0.35;}}',
|
|
75
|
-
'@media (max-width:640px){#__vista-devtools-root{left:16px;bottom:14px;}#__vista-devtools-root [data-vista-panel]{width:220px;}}',
|
|
76
|
-
].join('');
|
|
77
|
-
}
|
|
78
|
-
if (!style.isConnected && document.head) {
|
|
79
|
-
document.head.appendChild(style);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var root = document.getElementById('__vista-devtools-root');
|
|
83
|
-
if (!root) {
|
|
84
|
-
root = document.createElement('div');
|
|
85
|
-
root.id = '__vista-devtools-root';
|
|
86
|
-
root.innerHTML =
|
|
87
|
-
'<button type="button" aria-label="Vista Dev Tools" aria-expanded="false" data-busy="false" data-vista-trigger>' +
|
|
88
|
-
'<span class="vista-devtools-logo" aria-hidden="true">' +
|
|
89
|
-
'<svg viewBox="0 0 168 177" fill="none" xmlns="http://www.w3.org/2000/svg">' +
|
|
90
|
-
'<path class="vista-devtools-logo-fill" d="M81.872 176.988L-2.01405e-06 -2.68173e-06H30.5816L83.5576 121.604L136.774 -2.68173e-06H167.115L85.484 176.988H81.872Z"></path>' +
|
|
91
|
-
'<path class="vista-devtools-logo-draw" pathLength="100" d="M81.872 176.988L-2.01405e-06 -2.68173e-06H30.5816L83.5576 121.604L136.774 -2.68173e-06H167.115L85.484 176.988H81.872Z"></path>' +
|
|
92
|
-
'</svg>' +
|
|
93
|
-
'</span>' +
|
|
94
|
-
'<span class="vista-devtools-error-pill" data-vista-error-pill hidden>' +
|
|
95
|
-
'<span class="vista-devtools-error-close">×</span>' +
|
|
96
|
-
'<span data-vista-error-count>1</span>' +
|
|
97
|
-
'</span>' +
|
|
98
|
-
'</button>' +
|
|
99
|
-
'<div data-vista-panel hidden>' +
|
|
100
|
-
'<p class="vista-devtools-title">Vista Dev Tools</p>' +
|
|
101
|
-
'<div class="vista-devtools-row"><span class="vista-devtools-key">status</span><span class="vista-devtools-value" data-vista-status>idle</span></div>' +
|
|
102
|
-
'<div class="vista-devtools-row"><span class="vista-devtools-key">activity</span><span class="vista-devtools-value" data-vista-reason>idle</span></div>' +
|
|
103
|
-
'<div class="vista-devtools-row"><span class="vista-devtools-key">route</span><span class="vista-devtools-value" data-vista-route>/</span></div>' +
|
|
104
|
-
'<div class="vista-devtools-actions"><button type="button" data-vista-hide>' +
|
|
105
|
-
'<svg class="vista-hide-icon" viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg">' +
|
|
106
|
-
'<path d="M3 3L21 21" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path>' +
|
|
107
|
-
'<path d="M10.58 10.58C10.21 10.95 10 11.45 10 12C10 13.1 10.9 14 12 14C12.55 14 13.05 13.79 13.42 13.42" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path>' +
|
|
108
|
-
'<path d="M9.88 5.09C10.55 4.85 11.26 4.72 12 4.72C17 4.72 21 12 21 12C20.39 13.14 19.58 14.16 18.62 15.02M14.12 18.91C13.45 19.15 12.74 19.28 12 19.28C7 19.28 3 12 3 12C3.61 10.86 4.42 9.84 5.38 8.98" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>' +
|
|
109
|
-
'</svg>' +
|
|
110
|
-
'<span>Hide</span>' +
|
|
111
|
-
'</button></div>' +
|
|
112
|
-
'</div>';
|
|
113
|
-
document.body.appendChild(root);
|
|
114
|
-
} else if (!root.isConnected && document.body) {
|
|
115
|
-
document.body.appendChild(root);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
var button = null;
|
|
119
|
-
var panel = null;
|
|
120
|
-
var statusValue = null;
|
|
121
|
-
var reasonValue = null;
|
|
122
|
-
var routeValue = null;
|
|
123
|
-
var hideButton = null;
|
|
124
|
-
var errorPill = null;
|
|
125
|
-
var errorCountNode = null;
|
|
126
|
-
var open = false;
|
|
127
|
-
var pendingCount = 0;
|
|
128
|
-
var busyStartedAt = 0;
|
|
129
|
-
var clearTimer = null;
|
|
130
|
-
var minimumBusyMs = 420;
|
|
131
|
-
var hasError = false;
|
|
132
|
-
var errorCount = 1;
|
|
133
|
-
var currentBusy = false;
|
|
134
|
-
var currentReason = 'idle';
|
|
135
|
-
|
|
136
|
-
function syncRefs() {
|
|
137
|
-
if (!root) return;
|
|
138
|
-
button = root.querySelector('[data-vista-trigger]');
|
|
139
|
-
panel = root.querySelector('[data-vista-panel]');
|
|
140
|
-
statusValue = root.querySelector('[data-vista-status]');
|
|
141
|
-
reasonValue = root.querySelector('[data-vista-reason]');
|
|
142
|
-
routeValue = root.querySelector('[data-vista-route]');
|
|
143
|
-
hideButton = root.querySelector('[data-vista-hide]');
|
|
144
|
-
errorPill = root.querySelector('[data-vista-error-pill]');
|
|
145
|
-
errorCountNode = root.querySelector('[data-vista-error-count]');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function ensureAttached() {
|
|
149
|
-
if (!root) return false;
|
|
150
|
-
var changed = false;
|
|
151
|
-
if (style && !style.isConnected && document.head) {
|
|
152
|
-
document.head.appendChild(style);
|
|
153
|
-
changed = true;
|
|
154
|
-
}
|
|
155
|
-
if (!root.isConnected && document.body) {
|
|
156
|
-
document.body.appendChild(root);
|
|
157
|
-
changed = true;
|
|
158
|
-
}
|
|
159
|
-
if (changed) {
|
|
160
|
-
syncRefs();
|
|
161
|
-
if (panel) panel.hidden = !open;
|
|
162
|
-
if (button) button.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
163
|
-
}
|
|
164
|
-
return !!root.isConnected;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
syncRefs();
|
|
168
|
-
|
|
169
|
-
function hideUntilRestart() {
|
|
170
|
-
try {
|
|
171
|
-
window.sessionStorage.setItem(hideStorageKey, hideBootId);
|
|
172
|
-
} catch (e) {}
|
|
173
|
-
if (root && root.parentNode) root.parentNode.removeChild(root);
|
|
174
|
-
if (style && style.parentNode) style.parentNode.removeChild(style);
|
|
175
|
-
window.__VISTA_DEVTOOLS_INDICATOR__ = {
|
|
176
|
-
hidden: true,
|
|
177
|
-
begin: function () {},
|
|
178
|
-
end: function () {},
|
|
179
|
-
pulse: function () {},
|
|
180
|
-
setRoute: function () {},
|
|
181
|
-
setError: function () {},
|
|
182
|
-
clearError: function () {},
|
|
183
|
-
ensureAttached: function () {
|
|
184
|
-
return false;
|
|
185
|
-
},
|
|
186
|
-
hide: hideUntilRestart,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function setRoute() {
|
|
191
|
-
ensureAttached();
|
|
192
|
-
if (!routeValue) return;
|
|
193
|
-
routeValue.textContent = window.location.pathname + window.location.search;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function setState(isBusy, reason) {
|
|
197
|
-
ensureAttached();
|
|
198
|
-
currentBusy = isBusy;
|
|
199
|
-
currentReason = reason || 'idle';
|
|
200
|
-
if (button) button.setAttribute('data-busy', isBusy ? 'true' : 'false');
|
|
201
|
-
if (hasError) return;
|
|
202
|
-
if (statusValue) statusValue.textContent = isBusy ? 'busy' : 'idle';
|
|
203
|
-
if (reasonValue) reasonValue.textContent = currentReason;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function setError(message, count) {
|
|
207
|
-
ensureAttached();
|
|
208
|
-
hasError = true;
|
|
209
|
-
if (typeof count === 'number' && count > 0) {
|
|
210
|
-
errorCount = Math.max(1, Math.floor(count));
|
|
211
|
-
} else {
|
|
212
|
-
errorCount = 1;
|
|
213
|
-
}
|
|
214
|
-
if (button) button.setAttribute('data-error', 'true');
|
|
215
|
-
if (errorPill) errorPill.hidden = false;
|
|
216
|
-
if (errorCountNode) errorCountNode.textContent = String(errorCount);
|
|
217
|
-
if (statusValue) statusValue.textContent = 'error';
|
|
218
|
-
if (reasonValue)
|
|
219
|
-
reasonValue.textContent =
|
|
220
|
-
(message ? String(message).slice(0, 56) : 'build-error') + ' (' + errorCount + ')';
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function clearError() {
|
|
224
|
-
ensureAttached();
|
|
225
|
-
hasError = false;
|
|
226
|
-
if (button) button.setAttribute('data-error', 'false');
|
|
227
|
-
if (errorPill) errorPill.hidden = true;
|
|
228
|
-
errorCount = 1;
|
|
229
|
-
setState(currentBusy, currentReason);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function begin(reason) {
|
|
233
|
-
if (clearTimer) {
|
|
234
|
-
clearTimeout(clearTimer);
|
|
235
|
-
clearTimer = null;
|
|
236
|
-
}
|
|
237
|
-
pendingCount += 1;
|
|
238
|
-
if (pendingCount === 1) {
|
|
239
|
-
busyStartedAt = Date.now();
|
|
240
|
-
}
|
|
241
|
-
setState(true, reason || 'activity');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function end() {
|
|
245
|
-
if (pendingCount > 0) pendingCount -= 1;
|
|
246
|
-
if (pendingCount > 0) return;
|
|
247
|
-
|
|
248
|
-
var elapsed = Date.now() - busyStartedAt;
|
|
249
|
-
var wait = elapsed < minimumBusyMs ? minimumBusyMs - elapsed : 0;
|
|
250
|
-
if (clearTimer) clearTimeout(clearTimer);
|
|
251
|
-
clearTimer = setTimeout(function () {
|
|
252
|
-
setState(false, 'idle');
|
|
253
|
-
clearTimer = null;
|
|
254
|
-
}, wait);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function pulse(reason, duration) {
|
|
258
|
-
begin(reason || 'update');
|
|
259
|
-
setTimeout(end, typeof duration === 'number' ? duration : 650);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function togglePanel() {
|
|
263
|
-
if (!ensureAttached()) return;
|
|
264
|
-
open = !open;
|
|
265
|
-
if (panel) panel.hidden = !open;
|
|
266
|
-
if (button) button.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
267
|
-
setRoute();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (button) {
|
|
271
|
-
button.addEventListener('click', function () {
|
|
272
|
-
var errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
273
|
-
if (
|
|
274
|
-
errorOverlay &&
|
|
275
|
-
typeof errorOverlay.restoreFromIndicator === 'function' &&
|
|
276
|
-
errorOverlay.restoreFromIndicator()
|
|
277
|
-
) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
togglePanel();
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
if (hideButton) {
|
|
284
|
-
hideButton.addEventListener('click', function () {
|
|
285
|
-
hideUntilRestart();
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
var originalPushState = window.history.pushState;
|
|
290
|
-
if (typeof originalPushState === 'function') {
|
|
291
|
-
window.history.pushState = function () {
|
|
292
|
-
begin('navigation');
|
|
293
|
-
var result = originalPushState.apply(this, arguments);
|
|
294
|
-
setRoute();
|
|
295
|
-
setTimeout(end, 0);
|
|
296
|
-
return result;
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
var originalReplaceState = window.history.replaceState;
|
|
301
|
-
if (typeof originalReplaceState === 'function') {
|
|
302
|
-
window.history.replaceState = function () {
|
|
303
|
-
begin('navigation');
|
|
304
|
-
var result = originalReplaceState.apply(this, arguments);
|
|
305
|
-
setRoute();
|
|
306
|
-
setTimeout(end, 0);
|
|
307
|
-
return result;
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
window.addEventListener('popstate', function () {
|
|
312
|
-
pulse('navigation', 450);
|
|
313
|
-
setRoute();
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
if (typeof window.fetch === 'function') {
|
|
317
|
-
var nativeFetch = window.fetch.bind(window);
|
|
318
|
-
window.fetch = function (input, init) {
|
|
319
|
-
var rawUrl = '';
|
|
320
|
-
if (typeof input === 'string') {
|
|
321
|
-
rawUrl = input;
|
|
322
|
-
} else if (input && typeof input === 'object' && 'url' in input) {
|
|
323
|
-
rawUrl = input.url || '';
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
var pathname = '';
|
|
327
|
-
try {
|
|
328
|
-
pathname = new URL(rawUrl, window.location.href).pathname;
|
|
329
|
-
} catch (e) {
|
|
330
|
-
pathname = '';
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
var shouldTrack = pathname.indexOf('/rsc') === 0;
|
|
334
|
-
if (!shouldTrack) {
|
|
335
|
-
return nativeFetch(input, init);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
begin('navigation');
|
|
339
|
-
return nativeFetch(input, init).finally(function () {
|
|
340
|
-
end();
|
|
341
|
-
setRoute();
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
document.addEventListener('vista:ppr-shell', function () {
|
|
347
|
-
pulse('ppr-shell', 420);
|
|
348
|
-
});
|
|
349
|
-
document.addEventListener('vista:ppr-resume', function (event) {
|
|
350
|
-
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
351
|
-
begin('ppr-' + (detail.mode || 'resume'));
|
|
352
|
-
});
|
|
353
|
-
document.addEventListener('vista:ppr-complete', function (event) {
|
|
354
|
-
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
355
|
-
pulse('ppr-' + (detail.mode || 'complete'), 520);
|
|
356
|
-
clearError();
|
|
357
|
-
setRoute();
|
|
358
|
-
});
|
|
359
|
-
document.addEventListener('vista:ppr-error', function (event) {
|
|
360
|
-
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
361
|
-
setError(detail.message || 'ppr-resume', 1);
|
|
362
|
-
});
|
|
363
|
-
document.addEventListener('vista:rsc-resume-start', function () {
|
|
364
|
-
begin('flight-resume');
|
|
365
|
-
});
|
|
366
|
-
document.addEventListener('vista:rsc-resume-complete', function () {
|
|
367
|
-
pulse('flight-ready', 480);
|
|
368
|
-
clearError();
|
|
369
|
-
setRoute();
|
|
370
|
-
});
|
|
371
|
-
document.addEventListener('vista:rsc-resume-error', function (event) {
|
|
372
|
-
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
373
|
-
setError(detail.message || 'flight-resume', 1);
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
setRoute();
|
|
377
|
-
setState(false, 'idle');
|
|
378
|
-
|
|
379
|
-
window.__VISTA_DEVTOOLS_INDICATOR__ = {
|
|
380
|
-
begin: begin,
|
|
381
|
-
end: end,
|
|
382
|
-
pulse: pulse,
|
|
383
|
-
setRoute: setRoute,
|
|
384
|
-
setError: setError,
|
|
385
|
-
clearError: clearError,
|
|
386
|
-
ensureAttached: ensureAttached,
|
|
387
|
-
hide: hideUntilRestart,
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
if (document.readyState === 'loading') {
|
|
392
|
-
document.addEventListener('DOMContentLoaded', mount, { once: true });
|
|
393
|
-
} else {
|
|
394
|
-
mount();
|
|
395
|
-
}
|
|
396
|
-
})();
|
|
10
|
+
return `
|
|
11
|
+
(function installVistaDevToolsIndicator() {
|
|
12
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') return;
|
|
13
|
+
var hideStorageKey = '__vista_devtools_hidden_boot__';
|
|
14
|
+
var hideBootId = ${escapedBootSessionId};
|
|
15
|
+
|
|
16
|
+
function mount() {
|
|
17
|
+
var existingIndicator = window.__VISTA_DEVTOOLS_INDICATOR__;
|
|
18
|
+
if (existingIndicator && existingIndicator.hidden === true) {
|
|
19
|
+
try {
|
|
20
|
+
var hiddenBootId = window.sessionStorage.getItem(hideStorageKey);
|
|
21
|
+
if (hiddenBootId !== hideBootId) {
|
|
22
|
+
window.__VISTA_DEVTOOLS_INDICATOR__ = undefined;
|
|
23
|
+
existingIndicator = undefined;
|
|
24
|
+
}
|
|
25
|
+
} catch (e) {}
|
|
26
|
+
}
|
|
27
|
+
if (existingIndicator && typeof existingIndicator.ensureAttached === 'function') {
|
|
28
|
+
if (existingIndicator.ensureAttached()) return;
|
|
29
|
+
window.__VISTA_DEVTOOLS_INDICATOR__ = undefined;
|
|
30
|
+
existingIndicator = undefined;
|
|
31
|
+
}
|
|
32
|
+
if (existingIndicator) {
|
|
33
|
+
var mountedRoot = document.getElementById('__vista-devtools-root');
|
|
34
|
+
var mountedStyle = document.getElementById('__vista-devtools-style');
|
|
35
|
+
if (mountedRoot && mountedStyle) return;
|
|
36
|
+
window.__VISTA_DEVTOOLS_INDICATOR__ = undefined;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
if (window.sessionStorage.getItem(hideStorageKey) === hideBootId) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {}
|
|
43
|
+
|
|
44
|
+
var style = document.getElementById('__vista-devtools-style');
|
|
45
|
+
if (!style) {
|
|
46
|
+
style = document.createElement('style');
|
|
47
|
+
style.id = '__vista-devtools-style';
|
|
48
|
+
style.textContent = [
|
|
49
|
+
'#__vista-devtools-root{position:fixed;left:28px;bottom:22px;z-index:2147482000;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;color:#fff;}',
|
|
50
|
+
'#__vista-devtools-root [data-vista-trigger]{width:40px;height:40px;border-radius:9999px;border:1px solid rgba(255,255,255,0.2);background:rgba(0,0,0,0.82);display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 10px 24px rgba(0,0,0,0.4);position:relative;transition:transform 180ms ease,border-color 180ms ease,background 180ms ease,width 180ms ease,padding 180ms ease,gap 180ms ease;}',
|
|
51
|
+
'#__vista-devtools-root [data-vista-trigger]:hover{transform:translateY(-1px);border-color:rgba(255,255,255,0.42);background:rgba(0,0,0,0.92);}',
|
|
52
|
+
'#__vista-devtools-root [data-vista-trigger]:focus-visible{outline:2px solid rgba(255,255,255,0.65);outline-offset:2px;}',
|
|
53
|
+
'#__vista-devtools-root [data-vista-trigger][data-busy="true"]{border-color:rgba(255,255,255,0.5);}',
|
|
54
|
+
'#__vista-devtools-root [data-vista-trigger][data-error="true"]{width:86px;padding:0 8px;justify-content:flex-start;gap:6px;border-color:rgba(248,113,113,0.9);background:rgba(53,11,16,0.94);box-shadow:0 10px 24px rgba(248,113,113,0.24);}',
|
|
55
|
+
'#__vista-devtools-root .vista-devtools-logo{display:block;width:16px;height:16px;}',
|
|
56
|
+
'#__vista-devtools-root .vista-devtools-logo svg{width:100%;height:100%;display:block;}',
|
|
57
|
+
'#__vista-devtools-root [data-vista-trigger][data-error="true"] .vista-devtools-logo{width:14px;height:14px;}',
|
|
58
|
+
'#__vista-devtools-root .vista-devtools-logo-fill{fill:#fff;opacity:1;transition:opacity 180ms ease;}',
|
|
59
|
+
'#__vista-devtools-root .vista-devtools-logo-draw{fill:none;stroke:#fff;stroke-width:12;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:100;stroke-dashoffset:100;opacity:0;}',
|
|
60
|
+
'#__vista-devtools-root [data-vista-trigger][data-busy="true"] .vista-devtools-logo-fill{opacity:0.18;}',
|
|
61
|
+
'#__vista-devtools-root [data-vista-trigger][data-busy="true"] .vista-devtools-logo-draw{opacity:1;animation:vista-devtools-v-draw 900ms ease-in-out infinite;}',
|
|
62
|
+
'#__vista-devtools-root .vista-devtools-error-pill{display:inline-flex;align-items:center;gap:4px;padding:2px 7px;border-radius:999px;border:1px solid rgba(248,113,113,0.65);background:rgba(248,113,113,0.16);color:#fecaca;font-size:11px;font-weight:670;font-variant-numeric:tabular-nums;line-height:1;}',
|
|
63
|
+
'#__vista-devtools-root .vista-devtools-error-close{font-size:11px;line-height:1;color:#fca5a5;}',
|
|
64
|
+
'#__vista-devtools-root [data-vista-panel]{position:absolute;left:0;bottom:50px;width:244px;padding:10px;border-radius:12px;border:1px solid rgba(255,255,255,0.18);background:rgba(8,8,8,0.94);backdrop-filter:blur(8px);box-shadow:0 16px 36px rgba(0,0,0,0.45);}',
|
|
65
|
+
'#__vista-devtools-root [data-vista-panel][hidden]{display:none;}',
|
|
66
|
+
'#__vista-devtools-root .vista-devtools-title{font-size:11px;letter-spacing:0.08em;text-transform:uppercase;color:rgba(255,255,255,0.72);margin:0 0 8px;}',
|
|
67
|
+
'#__vista-devtools-root .vista-devtools-row{font-size:12px;display:flex;justify-content:space-between;gap:10px;margin:4px 0;color:rgba(255,255,255,0.92);}',
|
|
68
|
+
'#__vista-devtools-root .vista-devtools-key{color:rgba(255,255,255,0.6);}',
|
|
69
|
+
'#__vista-devtools-root .vista-devtools-value{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;max-width:148px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}',
|
|
70
|
+
'#__vista-devtools-root .vista-devtools-actions{margin-top:8px;padding-top:8px;border-top:1px solid rgba(255,255,255,0.12);display:flex;justify-content:flex-end;}',
|
|
71
|
+
'#__vista-devtools-root [data-vista-hide]{font-size:11px;line-height:1;padding:6px 8px;border-radius:8px;border:1px solid rgba(255,255,255,0.26);background:transparent;color:rgba(255,255,255,0.85);cursor:pointer;transition:background 140ms ease,border-color 140ms ease,color 140ms ease;display:inline-flex;align-items:center;gap:5px;}',
|
|
72
|
+
'#__vista-devtools-root [data-vista-hide]:hover{background:rgba(255,255,255,0.12);border-color:rgba(255,255,255,0.5);color:#fff;}',
|
|
73
|
+
'#__vista-devtools-root .vista-hide-icon{width:12px;height:12px;display:block;}',
|
|
74
|
+
'@keyframes vista-devtools-v-draw{0%{stroke-dashoffset:100;opacity:0.35;}45%{stroke-dashoffset:0;opacity:1;}72%{stroke-dashoffset:0;opacity:1;}100%{stroke-dashoffset:-100;opacity:0.35;}}',
|
|
75
|
+
'@media (max-width:640px){#__vista-devtools-root{left:16px;bottom:14px;}#__vista-devtools-root [data-vista-panel]{width:220px;}}',
|
|
76
|
+
].join('');
|
|
77
|
+
}
|
|
78
|
+
if (!style.isConnected && document.head) {
|
|
79
|
+
document.head.appendChild(style);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var root = document.getElementById('__vista-devtools-root');
|
|
83
|
+
if (!root) {
|
|
84
|
+
root = document.createElement('div');
|
|
85
|
+
root.id = '__vista-devtools-root';
|
|
86
|
+
root.innerHTML =
|
|
87
|
+
'<button type="button" aria-label="Vista Dev Tools" aria-expanded="false" data-busy="false" data-vista-trigger>' +
|
|
88
|
+
'<span class="vista-devtools-logo" aria-hidden="true">' +
|
|
89
|
+
'<svg viewBox="0 0 168 177" fill="none" xmlns="http://www.w3.org/2000/svg">' +
|
|
90
|
+
'<path class="vista-devtools-logo-fill" d="M81.872 176.988L-2.01405e-06 -2.68173e-06H30.5816L83.5576 121.604L136.774 -2.68173e-06H167.115L85.484 176.988H81.872Z"></path>' +
|
|
91
|
+
'<path class="vista-devtools-logo-draw" pathLength="100" d="M81.872 176.988L-2.01405e-06 -2.68173e-06H30.5816L83.5576 121.604L136.774 -2.68173e-06H167.115L85.484 176.988H81.872Z"></path>' +
|
|
92
|
+
'</svg>' +
|
|
93
|
+
'</span>' +
|
|
94
|
+
'<span class="vista-devtools-error-pill" data-vista-error-pill hidden>' +
|
|
95
|
+
'<span class="vista-devtools-error-close">×</span>' +
|
|
96
|
+
'<span data-vista-error-count>1</span>' +
|
|
97
|
+
'</span>' +
|
|
98
|
+
'</button>' +
|
|
99
|
+
'<div data-vista-panel hidden>' +
|
|
100
|
+
'<p class="vista-devtools-title">Vista Dev Tools</p>' +
|
|
101
|
+
'<div class="vista-devtools-row"><span class="vista-devtools-key">status</span><span class="vista-devtools-value" data-vista-status>idle</span></div>' +
|
|
102
|
+
'<div class="vista-devtools-row"><span class="vista-devtools-key">activity</span><span class="vista-devtools-value" data-vista-reason>idle</span></div>' +
|
|
103
|
+
'<div class="vista-devtools-row"><span class="vista-devtools-key">route</span><span class="vista-devtools-value" data-vista-route>/</span></div>' +
|
|
104
|
+
'<div class="vista-devtools-actions"><button type="button" data-vista-hide>' +
|
|
105
|
+
'<svg class="vista-hide-icon" viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg">' +
|
|
106
|
+
'<path d="M3 3L21 21" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path>' +
|
|
107
|
+
'<path d="M10.58 10.58C10.21 10.95 10 11.45 10 12C10 13.1 10.9 14 12 14C12.55 14 13.05 13.79 13.42 13.42" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path>' +
|
|
108
|
+
'<path d="M9.88 5.09C10.55 4.85 11.26 4.72 12 4.72C17 4.72 21 12 21 12C20.39 13.14 19.58 14.16 18.62 15.02M14.12 18.91C13.45 19.15 12.74 19.28 12 19.28C7 19.28 3 12 3 12C3.61 10.86 4.42 9.84 5.38 8.98" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>' +
|
|
109
|
+
'</svg>' +
|
|
110
|
+
'<span>Hide</span>' +
|
|
111
|
+
'</button></div>' +
|
|
112
|
+
'</div>';
|
|
113
|
+
document.body.appendChild(root);
|
|
114
|
+
} else if (!root.isConnected && document.body) {
|
|
115
|
+
document.body.appendChild(root);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
var button = null;
|
|
119
|
+
var panel = null;
|
|
120
|
+
var statusValue = null;
|
|
121
|
+
var reasonValue = null;
|
|
122
|
+
var routeValue = null;
|
|
123
|
+
var hideButton = null;
|
|
124
|
+
var errorPill = null;
|
|
125
|
+
var errorCountNode = null;
|
|
126
|
+
var open = false;
|
|
127
|
+
var pendingCount = 0;
|
|
128
|
+
var busyStartedAt = 0;
|
|
129
|
+
var clearTimer = null;
|
|
130
|
+
var minimumBusyMs = 420;
|
|
131
|
+
var hasError = false;
|
|
132
|
+
var errorCount = 1;
|
|
133
|
+
var currentBusy = false;
|
|
134
|
+
var currentReason = 'idle';
|
|
135
|
+
|
|
136
|
+
function syncRefs() {
|
|
137
|
+
if (!root) return;
|
|
138
|
+
button = root.querySelector('[data-vista-trigger]');
|
|
139
|
+
panel = root.querySelector('[data-vista-panel]');
|
|
140
|
+
statusValue = root.querySelector('[data-vista-status]');
|
|
141
|
+
reasonValue = root.querySelector('[data-vista-reason]');
|
|
142
|
+
routeValue = root.querySelector('[data-vista-route]');
|
|
143
|
+
hideButton = root.querySelector('[data-vista-hide]');
|
|
144
|
+
errorPill = root.querySelector('[data-vista-error-pill]');
|
|
145
|
+
errorCountNode = root.querySelector('[data-vista-error-count]');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function ensureAttached() {
|
|
149
|
+
if (!root) return false;
|
|
150
|
+
var changed = false;
|
|
151
|
+
if (style && !style.isConnected && document.head) {
|
|
152
|
+
document.head.appendChild(style);
|
|
153
|
+
changed = true;
|
|
154
|
+
}
|
|
155
|
+
if (!root.isConnected && document.body) {
|
|
156
|
+
document.body.appendChild(root);
|
|
157
|
+
changed = true;
|
|
158
|
+
}
|
|
159
|
+
if (changed) {
|
|
160
|
+
syncRefs();
|
|
161
|
+
if (panel) panel.hidden = !open;
|
|
162
|
+
if (button) button.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
163
|
+
}
|
|
164
|
+
return !!root.isConnected;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
syncRefs();
|
|
168
|
+
|
|
169
|
+
function hideUntilRestart() {
|
|
170
|
+
try {
|
|
171
|
+
window.sessionStorage.setItem(hideStorageKey, hideBootId);
|
|
172
|
+
} catch (e) {}
|
|
173
|
+
if (root && root.parentNode) root.parentNode.removeChild(root);
|
|
174
|
+
if (style && style.parentNode) style.parentNode.removeChild(style);
|
|
175
|
+
window.__VISTA_DEVTOOLS_INDICATOR__ = {
|
|
176
|
+
hidden: true,
|
|
177
|
+
begin: function () {},
|
|
178
|
+
end: function () {},
|
|
179
|
+
pulse: function () {},
|
|
180
|
+
setRoute: function () {},
|
|
181
|
+
setError: function () {},
|
|
182
|
+
clearError: function () {},
|
|
183
|
+
ensureAttached: function () {
|
|
184
|
+
return false;
|
|
185
|
+
},
|
|
186
|
+
hide: hideUntilRestart,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function setRoute() {
|
|
191
|
+
ensureAttached();
|
|
192
|
+
if (!routeValue) return;
|
|
193
|
+
routeValue.textContent = window.location.pathname + window.location.search;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function setState(isBusy, reason) {
|
|
197
|
+
ensureAttached();
|
|
198
|
+
currentBusy = isBusy;
|
|
199
|
+
currentReason = reason || 'idle';
|
|
200
|
+
if (button) button.setAttribute('data-busy', isBusy ? 'true' : 'false');
|
|
201
|
+
if (hasError) return;
|
|
202
|
+
if (statusValue) statusValue.textContent = isBusy ? 'busy' : 'idle';
|
|
203
|
+
if (reasonValue) reasonValue.textContent = currentReason;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function setError(message, count) {
|
|
207
|
+
ensureAttached();
|
|
208
|
+
hasError = true;
|
|
209
|
+
if (typeof count === 'number' && count > 0) {
|
|
210
|
+
errorCount = Math.max(1, Math.floor(count));
|
|
211
|
+
} else {
|
|
212
|
+
errorCount = 1;
|
|
213
|
+
}
|
|
214
|
+
if (button) button.setAttribute('data-error', 'true');
|
|
215
|
+
if (errorPill) errorPill.hidden = false;
|
|
216
|
+
if (errorCountNode) errorCountNode.textContent = String(errorCount);
|
|
217
|
+
if (statusValue) statusValue.textContent = 'error';
|
|
218
|
+
if (reasonValue)
|
|
219
|
+
reasonValue.textContent =
|
|
220
|
+
(message ? String(message).slice(0, 56) : 'build-error') + ' (' + errorCount + ')';
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function clearError() {
|
|
224
|
+
ensureAttached();
|
|
225
|
+
hasError = false;
|
|
226
|
+
if (button) button.setAttribute('data-error', 'false');
|
|
227
|
+
if (errorPill) errorPill.hidden = true;
|
|
228
|
+
errorCount = 1;
|
|
229
|
+
setState(currentBusy, currentReason);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function begin(reason) {
|
|
233
|
+
if (clearTimer) {
|
|
234
|
+
clearTimeout(clearTimer);
|
|
235
|
+
clearTimer = null;
|
|
236
|
+
}
|
|
237
|
+
pendingCount += 1;
|
|
238
|
+
if (pendingCount === 1) {
|
|
239
|
+
busyStartedAt = Date.now();
|
|
240
|
+
}
|
|
241
|
+
setState(true, reason || 'activity');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function end() {
|
|
245
|
+
if (pendingCount > 0) pendingCount -= 1;
|
|
246
|
+
if (pendingCount > 0) return;
|
|
247
|
+
|
|
248
|
+
var elapsed = Date.now() - busyStartedAt;
|
|
249
|
+
var wait = elapsed < minimumBusyMs ? minimumBusyMs - elapsed : 0;
|
|
250
|
+
if (clearTimer) clearTimeout(clearTimer);
|
|
251
|
+
clearTimer = setTimeout(function () {
|
|
252
|
+
setState(false, 'idle');
|
|
253
|
+
clearTimer = null;
|
|
254
|
+
}, wait);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function pulse(reason, duration) {
|
|
258
|
+
begin(reason || 'update');
|
|
259
|
+
setTimeout(end, typeof duration === 'number' ? duration : 650);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function togglePanel() {
|
|
263
|
+
if (!ensureAttached()) return;
|
|
264
|
+
open = !open;
|
|
265
|
+
if (panel) panel.hidden = !open;
|
|
266
|
+
if (button) button.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
267
|
+
setRoute();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (button) {
|
|
271
|
+
button.addEventListener('click', function () {
|
|
272
|
+
var errorOverlay = window.__VISTA_DEV_ERROR_OVERLAY__;
|
|
273
|
+
if (
|
|
274
|
+
errorOverlay &&
|
|
275
|
+
typeof errorOverlay.restoreFromIndicator === 'function' &&
|
|
276
|
+
errorOverlay.restoreFromIndicator()
|
|
277
|
+
) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
togglePanel();
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
if (hideButton) {
|
|
284
|
+
hideButton.addEventListener('click', function () {
|
|
285
|
+
hideUntilRestart();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var originalPushState = window.history.pushState;
|
|
290
|
+
if (typeof originalPushState === 'function') {
|
|
291
|
+
window.history.pushState = function () {
|
|
292
|
+
begin('navigation');
|
|
293
|
+
var result = originalPushState.apply(this, arguments);
|
|
294
|
+
setRoute();
|
|
295
|
+
setTimeout(end, 0);
|
|
296
|
+
return result;
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
var originalReplaceState = window.history.replaceState;
|
|
301
|
+
if (typeof originalReplaceState === 'function') {
|
|
302
|
+
window.history.replaceState = function () {
|
|
303
|
+
begin('navigation');
|
|
304
|
+
var result = originalReplaceState.apply(this, arguments);
|
|
305
|
+
setRoute();
|
|
306
|
+
setTimeout(end, 0);
|
|
307
|
+
return result;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
window.addEventListener('popstate', function () {
|
|
312
|
+
pulse('navigation', 450);
|
|
313
|
+
setRoute();
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
if (typeof window.fetch === 'function') {
|
|
317
|
+
var nativeFetch = window.fetch.bind(window);
|
|
318
|
+
window.fetch = function (input, init) {
|
|
319
|
+
var rawUrl = '';
|
|
320
|
+
if (typeof input === 'string') {
|
|
321
|
+
rawUrl = input;
|
|
322
|
+
} else if (input && typeof input === 'object' && 'url' in input) {
|
|
323
|
+
rawUrl = input.url || '';
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
var pathname = '';
|
|
327
|
+
try {
|
|
328
|
+
pathname = new URL(rawUrl, window.location.href).pathname;
|
|
329
|
+
} catch (e) {
|
|
330
|
+
pathname = '';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
var shouldTrack = pathname.indexOf('/rsc') === 0;
|
|
334
|
+
if (!shouldTrack) {
|
|
335
|
+
return nativeFetch(input, init);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
begin('navigation');
|
|
339
|
+
return nativeFetch(input, init).finally(function () {
|
|
340
|
+
end();
|
|
341
|
+
setRoute();
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
document.addEventListener('vista:ppr-shell', function () {
|
|
347
|
+
pulse('ppr-shell', 420);
|
|
348
|
+
});
|
|
349
|
+
document.addEventListener('vista:ppr-resume', function (event) {
|
|
350
|
+
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
351
|
+
begin('ppr-' + (detail.mode || 'resume'));
|
|
352
|
+
});
|
|
353
|
+
document.addEventListener('vista:ppr-complete', function (event) {
|
|
354
|
+
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
355
|
+
pulse('ppr-' + (detail.mode || 'complete'), 520);
|
|
356
|
+
clearError();
|
|
357
|
+
setRoute();
|
|
358
|
+
});
|
|
359
|
+
document.addEventListener('vista:ppr-error', function (event) {
|
|
360
|
+
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
361
|
+
setError(detail.message || 'ppr-resume', 1);
|
|
362
|
+
});
|
|
363
|
+
document.addEventListener('vista:rsc-resume-start', function () {
|
|
364
|
+
begin('flight-resume');
|
|
365
|
+
});
|
|
366
|
+
document.addEventListener('vista:rsc-resume-complete', function () {
|
|
367
|
+
pulse('flight-ready', 480);
|
|
368
|
+
clearError();
|
|
369
|
+
setRoute();
|
|
370
|
+
});
|
|
371
|
+
document.addEventListener('vista:rsc-resume-error', function (event) {
|
|
372
|
+
var detail = event && event.detail && typeof event.detail === 'object' ? event.detail : {};
|
|
373
|
+
setError(detail.message || 'flight-resume', 1);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
setRoute();
|
|
377
|
+
setState(false, 'idle');
|
|
378
|
+
|
|
379
|
+
window.__VISTA_DEVTOOLS_INDICATOR__ = {
|
|
380
|
+
begin: begin,
|
|
381
|
+
end: end,
|
|
382
|
+
pulse: pulse,
|
|
383
|
+
setRoute: setRoute,
|
|
384
|
+
setError: setError,
|
|
385
|
+
clearError: clearError,
|
|
386
|
+
ensureAttached: ensureAttached,
|
|
387
|
+
hide: hideUntilRestart,
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (document.readyState === 'loading') {
|
|
392
|
+
document.addEventListener('DOMContentLoaded', mount, { once: true });
|
|
393
|
+
} else {
|
|
394
|
+
mount();
|
|
395
|
+
}
|
|
396
|
+
})();
|
|
397
397
|
`;
|
|
398
398
|
}
|