@vistagenic/vista 0.2.4 → 0.2.6

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.
@@ -0,0 +1,368 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDevToolsIndicatorBootstrapSource = getDevToolsIndicatorBootstrapSource;
4
+ /**
5
+ * Returns a plain JS snippet that installs a floating Vista devtools indicator
6
+ * in development builds. The snippet is injected into generated client entries.
7
+ */
8
+ function getDevToolsIndicatorBootstrapSource(bootSessionId) {
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
+ setRoute();
347
+ setState(false, 'idle');
348
+
349
+ window.__VISTA_DEVTOOLS_INDICATOR__ = {
350
+ begin: begin,
351
+ end: end,
352
+ pulse: pulse,
353
+ setRoute: setRoute,
354
+ setError: setError,
355
+ clearError: clearError,
356
+ ensureAttached: ensureAttached,
357
+ hide: hideUntilRestart,
358
+ };
359
+ }
360
+
361
+ if (document.readyState === 'loading') {
362
+ document.addEventListener('DOMContentLoaded', mount, { once: true });
363
+ } else {
364
+ mount();
365
+ }
366
+ })();
367
+ `;
368
+ }
@@ -282,8 +282,8 @@ function buildRoutes(components, appDir) {
282
282
  // Static URL pattern + auto mode = static by default
283
283
  renderMode = 'static';
284
284
  }
285
- else if (rt === 'dynamic' && hasStaticParams) {
286
- // Dynamic URL pattern + generateStaticParams = can be statically generated
285
+ else if ((rt === 'dynamic' || rt === 'catch-all') && hasStaticParams) {
286
+ // Dynamic or catch-all URL pattern + generateStaticParams = can be statically generated
287
287
  renderMode = 'static';
288
288
  }
289
289
  routes.push({
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Vista Error Overlay
3
3
  *
4
- * A standalone error overlay that works without React hydration.
5
- * Uses inline styles and vanilla JS for interactivity.
4
+ * Standalone dev error UI with Next.js-style pagination and controls.
6
5
  */
7
6
  import React from 'react';
8
7
  export interface VistaError {