vista-core-js 0.0.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.
Files changed (53) hide show
  1. package/dist/ErrorOverlay.d.ts +7 -0
  2. package/dist/ErrorOverlay.js +68 -0
  3. package/dist/app.d.ts +21 -0
  4. package/dist/app.js +119 -0
  5. package/dist/client/link.d.ts +23 -0
  6. package/dist/client/link.js +42 -0
  7. package/dist/client.d.ts +2 -0
  8. package/dist/client.js +290 -0
  9. package/dist/components/PixelBlast.d.ts +28 -0
  10. package/dist/components/PixelBlast.js +584 -0
  11. package/dist/entry-client.d.ts +1 -0
  12. package/dist/entry-client.js +56 -0
  13. package/dist/entry-server.d.ts +9 -0
  14. package/dist/entry-server.js +33 -0
  15. package/dist/error-overlay.d.ts +1 -0
  16. package/dist/error-overlay.js +166 -0
  17. package/dist/font/google/index.d.ts +1923 -0
  18. package/dist/font/google/index.js +1948 -0
  19. package/dist/image/get-img-props.d.ts +20 -0
  20. package/dist/image/get-img-props.js +46 -0
  21. package/dist/image/image-config.d.ts +20 -0
  22. package/dist/image/image-config.js +17 -0
  23. package/dist/image/image-loader.d.ts +7 -0
  24. package/dist/image/image-loader.js +10 -0
  25. package/dist/image/index.d.ts +12 -0
  26. package/dist/image/index.js +12 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.js +4 -0
  29. package/dist/plugin.d.ts +5 -0
  30. package/dist/plugin.js +88 -0
  31. package/dist/router.d.ts +18 -0
  32. package/dist/router.js +55 -0
  33. package/package.json +47 -0
  34. package/src/ErrorOverlay.tsx +194 -0
  35. package/src/app.tsx +138 -0
  36. package/src/assets/vista.gif +0 -0
  37. package/src/client/link.tsx +85 -0
  38. package/src/client.tsx +368 -0
  39. package/src/entry-client.tsx +70 -0
  40. package/src/entry-server.tsx +58 -0
  41. package/src/error-overlay.ts +187 -0
  42. package/src/font/google/index.d.ts +19011 -0
  43. package/src/font/google/index.ts +1968 -0
  44. package/src/font/types.d.ts +13 -0
  45. package/src/image/get-img-props.ts +100 -0
  46. package/src/image/image-config.ts +22 -0
  47. package/src/image/image-loader.ts +23 -0
  48. package/src/image/index.tsx +21 -0
  49. package/src/index.ts +7 -0
  50. package/src/plugin.ts +100 -0
  51. package/src/router-loader.ts +51 -0
  52. package/src/router.tsx +80 -0
  53. package/tsconfig.json +23 -0
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import ReactDOMServer, { renderToPipeableStream } from 'react-dom/server';
3
+ import { RouterProvider } from './router';
4
+ import App from './app.js';
5
+ import { loadRoute, loadRootLayout } from './router-loader.js';
6
+
7
+ export async function render(
8
+ url: string,
9
+ options: {
10
+ onShellReady?: () => void,
11
+ onAllReady?: () => void,
12
+ onError?: (err: unknown) => void,
13
+ bootstrapModules?: string[],
14
+ stylesheets?: string[],
15
+ preamble?: string // New option for Preamble Content
16
+ } = {}
17
+ ) {
18
+ // Preload Root Layout synchronously for the render pass
19
+ let initialRootLayout;
20
+ let initialMetadata = {};
21
+
22
+ try {
23
+ const result = await loadRootLayout();
24
+ initialRootLayout = result.Component;
25
+ initialMetadata = result.metadata;
26
+ } catch (e) {
27
+ console.error('Server failed to load root layout', e);
28
+ }
29
+
30
+ // Construct Assets Array
31
+ const assets: any[] = [];
32
+
33
+ // 1. Preamble (if any)
34
+ if (options.preamble) {
35
+ assets.push({ type: 'preamble', content: options.preamble, key: 'preamble' });
36
+ }
37
+
38
+ // 2. Stylesheets
39
+ options.stylesheets?.forEach(src => {
40
+ assets.push({ type: 'style', src, key: src });
41
+ });
42
+
43
+ // 3. Bootstrap Scripts
44
+ options.bootstrapModules?.forEach(src => {
45
+ assets.push({ type: 'script', src, key: src });
46
+ });
47
+
48
+ return renderToPipeableStream(
49
+ <RouterProvider url={url}>
50
+ <App
51
+ initialRootLayout={initialRootLayout || undefined}
52
+ metadata={initialMetadata}
53
+ assets={assets}
54
+ />
55
+ </RouterProvider>,
56
+ options
57
+ );
58
+ }
@@ -0,0 +1,187 @@
1
+ export function showErrorOverlay(err: Error, title: string = 'Application Error') {
2
+ if (typeof document === 'undefined') return;
3
+
4
+ // Check if overlay already exists
5
+ if (document.getElementById('vista-error-overlay')) return;
6
+
7
+ // Create fonts and animations
8
+ const style = document.createElement('style');
9
+ style.innerHTML = `
10
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
11
+
12
+ .vista-scrollbar::-webkit-scrollbar { width: 8px; height: 8px; }
13
+ .vista-scrollbar::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px; }
14
+ .vista-scrollbar::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
15
+ .vista-scrollbar::-webkit-scrollbar-thumb:hover { background: #555; }
16
+
17
+ @keyframes vistaFadeIn { from { opacity: 0; } to { opacity: 1; } }
18
+ @keyframes vistaSlideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
19
+ @keyframes vistaPulse { 0% { box-shadow: 0 0 0 0 rgba(255, 85, 85, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(255, 85, 85, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 85, 85, 0); } }
20
+ `;
21
+ document.head.appendChild(style);
22
+
23
+ const overlay = document.createElement('div');
24
+ overlay.id = 'vista-error-overlay';
25
+ // Overlay handles blocking interaction when expanded, but lets clicks through when minimized
26
+ overlay.style.cssText = `
27
+ position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
28
+ z-index: 2147483647; display: flex; align-items: center; justify-content: center;
29
+ font-family: 'Inter', -apple-system, sans-serif; color: #fff;
30
+ pointer-events: auto; background: rgba(0, 0, 0, 0.85);
31
+ backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
32
+ transition: all 0.3s ease;
33
+ `;
34
+
35
+ const container = document.createElement('div');
36
+ container.style.cssText = `
37
+ background: #0A0A0A; border: 1px solid #333; border-radius: 16px;
38
+ box-shadow: 0 0 0 1px rgba(255,255,255,0.05), 0 24px 72px rgba(0,0,0,0.5);
39
+ width: 90%; max-width: 900px; max-height: 85vh;
40
+ display: flex; flex-direction: column; overflow: hidden;
41
+ animation: vistaSlideUp 0.3s ease-out 0.1s backwards;
42
+ transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
43
+ `;
44
+
45
+ // HEADER
46
+ const header = document.createElement('div');
47
+ header.style.cssText = `
48
+ padding: 16px 24px; border-bottom: 1px solid #222; background: rgba(255,255,255,0.02);
49
+ display: flex; align-items: center; justify-content: space-between;
50
+ `;
51
+
52
+ const titleGroup = document.createElement('div');
53
+ titleGroup.style.display = 'flex';
54
+ titleGroup.style.alignItems = 'center';
55
+ titleGroup.style.gap = '12px';
56
+ titleGroup.innerHTML = `
57
+ <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" width="20" height="20" style="color: #FF5555;">
58
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
59
+ </svg>
60
+ <div style="font-size: 14px; font-weight: 600; color: #EDEDED;">${title}</div>
61
+ `;
62
+
63
+ const actions = document.createElement('div');
64
+ actions.style.display = 'flex';
65
+ actions.style.gap = '8px';
66
+
67
+ const minimizeBtn = document.createElement('button');
68
+ minimizeBtn.innerHTML = `
69
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
70
+ <line x1="5" y1="12" x2="19" y2="12"></line>
71
+ </svg>
72
+ `;
73
+ minimizeBtn.title = "Minimize Overlay";
74
+ minimizeBtn.style.cssText = `
75
+ background: transparent; border: none; color: #888; cursor: pointer;
76
+ padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
77
+ `;
78
+ minimizeBtn.onmouseover = () => { minimizeBtn.style.background = 'rgba(255,255,255,0.1)'; minimizeBtn.style.color = '#fff'; };
79
+ minimizeBtn.onmouseout = () => { minimizeBtn.style.background = 'transparent'; minimizeBtn.style.color = '#888'; };
80
+
81
+ const closeBtn = document.createElement('button'); // Reuse logic for minimize
82
+
83
+ actions.appendChild(minimizeBtn);
84
+ header.appendChild(titleGroup);
85
+ header.appendChild(actions);
86
+
87
+ // BODY
88
+ const body = document.createElement('div');
89
+ body.className = 'vista-scrollbar';
90
+ body.style.cssText = `padding: 24px; overflow-y: auto; flex: 1;`;
91
+
92
+ const message = document.createElement('h2');
93
+ message.style.cssText = `margin: 0 0 20px 0; font-size: 18px; font-weight: 500; line-height: 1.4; color: #ffffff;`;
94
+ message.textContent = err.message || 'Unknown Error';
95
+
96
+ const stackContainer = document.createElement('div');
97
+ stackContainer.style.cssText = `
98
+ background: #111; border: 1px solid #222; border-radius: 8px; padding: 16px;
99
+ overflow-x: auto; font-family: 'JetBrains Mono', monospace; font-size: 12px;
100
+ line-height: 1.6; color: #A1A1AA;
101
+ `;
102
+
103
+ const stack = err.stack ? err.stack.replace(err.message, '') : '';
104
+ const formattedStack = stack.split('\n').filter(line => line.trim() !== '')
105
+ .map(line => line.replace(/(\(.*\))/, '<span style="color: #666;">$1</span>').replace(/(at\s+)/, '<span style="color: #FF5555;">$1</span>'))
106
+ .join('\n');
107
+ stackContainer.innerHTML = `<pre style="margin:0">${formattedStack || 'No stack trace available.'}</pre>`;
108
+
109
+ body.appendChild(message);
110
+ body.appendChild(stackContainer);
111
+
112
+ // FOOTER
113
+ const footer = document.createElement('div');
114
+ footer.style.cssText = `
115
+ padding: 16px 24px; border-top: 1px solid #222; background: #0A0A0A;
116
+ display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #555;
117
+ `;
118
+ footer.innerHTML = `
119
+ <span>Vista Framework Debugger</span>
120
+ <button onclick="window.location.reload()" style="
121
+ background: #fff; color: #000; border: none; padding: 6px 12px; border-radius: 6px;
122
+ font-weight: 600; font-size: 13px; cursor: pointer; transition: opacity 0.2s;
123
+ " onmouseover="this.style.opacity=0.9" onmouseout="this.style.opacity=1">Reload Page</button>
124
+ `;
125
+
126
+ container.appendChild(header);
127
+ container.appendChild(body);
128
+ container.appendChild(footer);
129
+ overlay.appendChild(container);
130
+
131
+ // RESTORE BADGE (Hidden primarily)
132
+ const restoreBadge = document.createElement('div');
133
+ restoreBadge.style.cssText = `
134
+ position: fixed; bottom: 20px; right: 20px;
135
+ background: #FF5555; color: white;
136
+ padding: 10px 16px; border-radius: 30px;
137
+ font-weight: 600; font-size: 13px;
138
+ box-shadow: 0 4px 12px rgba(255, 85, 85, 0.4);
139
+ cursor: pointer; z-index: 2147483647;
140
+ display: flex; align-items: center; gap: 8px;
141
+ transform: translateY(100px); opacity: 0;
142
+ transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
143
+ animation: vistaPulse 2s infinite;
144
+ `;
145
+ restoreBadge.innerHTML = `
146
+ <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" width="16" height="16">
147
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
148
+ </svg>
149
+ <span>Error Detected</span>
150
+ `;
151
+
152
+ document.body.appendChild(restoreBadge);
153
+ document.body.appendChild(overlay);
154
+
155
+ // LOGIC
156
+ let isMinimized = false;
157
+
158
+ const toggleMinimize = () => {
159
+ isMinimized = !isMinimized;
160
+ if (isMinimized) {
161
+ // Minimize
162
+ container.style.transform = 'scale(0.9) translateY(20px)';
163
+ container.style.opacity = '0';
164
+ overlay.style.background = 'rgba(0,0,0,0)';
165
+ overlay.style.backdropFilter = 'none';
166
+ (overlay.style as any).webkitBackdropFilter = 'none';
167
+ overlay.style.pointerEvents = 'none';
168
+
169
+ restoreBadge.style.transform = 'translateY(0)';
170
+ restoreBadge.style.opacity = '1';
171
+ } else {
172
+ // Restore
173
+ container.style.transform = 'scale(1) translateY(0)';
174
+ container.style.opacity = '1';
175
+ overlay.style.background = 'rgba(0, 0, 0, 0.85)';
176
+ overlay.style.backdropFilter = 'blur(12px)';
177
+ (overlay.style as any).webkitBackdropFilter = 'blur(12px)';
178
+ overlay.style.pointerEvents = 'auto';
179
+
180
+ restoreBadge.style.transform = 'translateY(100px)';
181
+ restoreBadge.style.opacity = '0';
182
+ }
183
+ };
184
+
185
+ minimizeBtn.onclick = toggleMinimize;
186
+ restoreBadge.onclick = toggleMinimize;
187
+ }