@vistagenic/vista 0.1.0-alpha.1

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 (100) hide show
  1. package/bin/vista.js +98 -0
  2. package/dist/auth/index.d.ts +8 -0
  3. package/dist/auth/index.js +16 -0
  4. package/dist/bin/build-rsc.d.ts +17 -0
  5. package/dist/bin/build-rsc.js +320 -0
  6. package/dist/bin/build.d.ts +4 -0
  7. package/dist/bin/build.js +336 -0
  8. package/dist/bin/file-scanner.d.ts +66 -0
  9. package/dist/bin/file-scanner.js +399 -0
  10. package/dist/bin/server-component-plugin.d.ts +17 -0
  11. package/dist/bin/server-component-plugin.js +133 -0
  12. package/dist/bin/webpack.config.d.ts +6 -0
  13. package/dist/bin/webpack.config.js +138 -0
  14. package/dist/build/manifest.d.ts +95 -0
  15. package/dist/build/manifest.js +168 -0
  16. package/dist/build/rsc/client-manifest.d.ts +48 -0
  17. package/dist/build/rsc/client-manifest.js +191 -0
  18. package/dist/build/rsc/client-reference-plugin.d.ts +37 -0
  19. package/dist/build/rsc/client-reference-plugin.js +185 -0
  20. package/dist/build/rsc/compiler.d.ts +36 -0
  21. package/dist/build/rsc/compiler.js +311 -0
  22. package/dist/build/rsc/index.d.ts +16 -0
  23. package/dist/build/rsc/index.js +32 -0
  24. package/dist/build/rsc/native-scanner.d.ts +123 -0
  25. package/dist/build/rsc/native-scanner.js +165 -0
  26. package/dist/build/rsc/rsc-renderer.d.ts +99 -0
  27. package/dist/build/rsc/rsc-renderer.js +269 -0
  28. package/dist/build/rsc/server-component-loader.d.ts +19 -0
  29. package/dist/build/rsc/server-component-loader.js +147 -0
  30. package/dist/build/rsc/server-manifest.d.ts +63 -0
  31. package/dist/build/rsc/server-manifest.js +268 -0
  32. package/dist/build/webpack/loaders/vista-flight-loader.d.ts +17 -0
  33. package/dist/build/webpack/loaders/vista-flight-loader.js +93 -0
  34. package/dist/build/webpack/plugins/vista-flight-plugin.d.ts +36 -0
  35. package/dist/build/webpack/plugins/vista-flight-plugin.js +133 -0
  36. package/dist/client/dynamic.d.ts +25 -0
  37. package/dist/client/dynamic.js +68 -0
  38. package/dist/client/font.d.ts +98 -0
  39. package/dist/client/font.js +109 -0
  40. package/dist/client/head.d.ts +79 -0
  41. package/dist/client/head.js +261 -0
  42. package/dist/client/hydration.d.ts +45 -0
  43. package/dist/client/hydration.js +291 -0
  44. package/dist/client/link.d.ts +30 -0
  45. package/dist/client/link.js +188 -0
  46. package/dist/client/navigation.d.ts +28 -0
  47. package/dist/client/navigation.js +116 -0
  48. package/dist/client/router.d.ts +41 -0
  49. package/dist/client/router.js +190 -0
  50. package/dist/client/script.d.ts +51 -0
  51. package/dist/client/script.js +118 -0
  52. package/dist/components/client-island.d.ts +34 -0
  53. package/dist/components/client-island.js +75 -0
  54. package/dist/components/client.d.ts +29 -0
  55. package/dist/components/client.js +102 -0
  56. package/dist/components/index.d.ts +1 -0
  57. package/dist/components/index.js +8 -0
  58. package/dist/components/link.d.ts +6 -0
  59. package/dist/components/link.js +13 -0
  60. package/dist/config.d.ts +10 -0
  61. package/dist/config.js +31 -0
  62. package/dist/dev-error.d.ts +35 -0
  63. package/dist/dev-error.js +310 -0
  64. package/dist/image/get-img-props.d.ts +28 -0
  65. package/dist/image/get-img-props.js +49 -0
  66. package/dist/image/image-config.d.ts +20 -0
  67. package/dist/image/image-config.js +20 -0
  68. package/dist/image/image-loader.d.ts +7 -0
  69. package/dist/image/image-loader.js +14 -0
  70. package/dist/image/index.d.ts +6 -0
  71. package/dist/image/index.js +110 -0
  72. package/dist/image.d.ts +10 -0
  73. package/dist/image.js +7 -0
  74. package/dist/index.d.ts +20 -0
  75. package/dist/index.js +53 -0
  76. package/dist/metadata/generate.d.ts +22 -0
  77. package/dist/metadata/generate.js +324 -0
  78. package/dist/metadata/index.d.ts +7 -0
  79. package/dist/metadata/index.js +26 -0
  80. package/dist/metadata/types.d.ts +325 -0
  81. package/dist/metadata/types.js +15 -0
  82. package/dist/router/context.d.ts +8 -0
  83. package/dist/router/context.js +13 -0
  84. package/dist/router/index.d.ts +2 -0
  85. package/dist/router/index.js +18 -0
  86. package/dist/router/provider.d.ts +5 -0
  87. package/dist/router/provider.js +31 -0
  88. package/dist/server/client-boundary.d.ts +48 -0
  89. package/dist/server/client-boundary.js +133 -0
  90. package/dist/server/engine.d.ts +4 -0
  91. package/dist/server/engine.js +651 -0
  92. package/dist/server/index.d.ts +95 -0
  93. package/dist/server/index.js +177 -0
  94. package/dist/server/rsc-engine.d.ts +20 -0
  95. package/dist/server/rsc-engine.js +588 -0
  96. package/dist/server/rsc-module-system.d.ts +33 -0
  97. package/dist/server/rsc-module-system.js +119 -0
  98. package/dist/types/index.d.ts +4 -0
  99. package/dist/types/index.js +2 -0
  100. package/package.json +103 -0
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.VistaDevErrorBoundary = exports.DevErrorBoundary = void 0;
7
+ exports.ErrorOverlay = ErrorOverlay;
8
+ exports.VistaErrorOverlay = ErrorOverlay;
9
+ const jsx_runtime_1 = require("react/jsx-runtime");
10
+ /**
11
+ * Vista Error Overlay
12
+ *
13
+ * A standalone error overlay that works without React hydration.
14
+ * Uses inline styles and vanilla JS for interactivity.
15
+ */
16
+ const react_1 = __importDefault(require("react"));
17
+ // ============================================================================
18
+ // Inline CSS (no external dependencies)
19
+ // ============================================================================
20
+ const INLINE_STYLES = `
21
+ <style>
22
+ * { box-sizing: border-box; margin: 0; padding: 0; }
23
+ body {
24
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
25
+ background: #0a0a0a;
26
+ color: #ededed;
27
+ min-height: 100vh;
28
+ }
29
+ .vista-error-container {
30
+ min-height: 100vh;
31
+ display: flex;
32
+ align-items: flex-start;
33
+ justify-content: center;
34
+ padding: 40px 20px;
35
+ }
36
+ .vista-error-dialog {
37
+ width: 100%;
38
+ max-width: 800px;
39
+ background: #0a0a0a;
40
+ border: 1px solid #333;
41
+ border-radius: 12px;
42
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
43
+ overflow: hidden;
44
+ }
45
+ .vista-error-header {
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: space-between;
49
+ padding: 16px 20px;
50
+ background: #111;
51
+ border-bottom: 1px solid #333;
52
+ }
53
+ .vista-error-badge {
54
+ display: inline-flex;
55
+ align-items: center;
56
+ gap: 8px;
57
+ padding: 6px 12px;
58
+ background: rgba(255, 76, 76, 0.15);
59
+ color: #ff4c4c;
60
+ border-radius: 20px;
61
+ font-size: 12px;
62
+ font-weight: 600;
63
+ text-transform: uppercase;
64
+ letter-spacing: 0.5px;
65
+ }
66
+ .vista-error-badge::before {
67
+ content: '';
68
+ width: 8px;
69
+ height: 8px;
70
+ background: #ff4c4c;
71
+ border-radius: 50%;
72
+ animation: pulse 2s infinite;
73
+ }
74
+ @keyframes pulse {
75
+ 0%, 100% { opacity: 1; }
76
+ 50% { opacity: 0.5; }
77
+ }
78
+ .vista-error-content {
79
+ padding: 24px;
80
+ }
81
+ .vista-error-message {
82
+ font-size: 20px;
83
+ font-weight: 600;
84
+ line-height: 1.5;
85
+ margin-bottom: 20px;
86
+ color: #fff;
87
+ }
88
+ .vista-error-location {
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 8px;
92
+ padding: 12px 16px;
93
+ background: #111;
94
+ border: 1px solid #333;
95
+ border-radius: 8px;
96
+ margin-bottom: 20px;
97
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
98
+ font-size: 13px;
99
+ }
100
+ .vista-error-location-file {
101
+ color: #0070f3;
102
+ }
103
+ .vista-error-location-line {
104
+ color: #888;
105
+ }
106
+ .vista-error-stack {
107
+ background: #0d0d0d;
108
+ border: 1px solid #333;
109
+ border-radius: 8px;
110
+ padding: 16px;
111
+ overflow-x: auto;
112
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
113
+ font-size: 12px;
114
+ line-height: 1.6;
115
+ white-space: pre-wrap;
116
+ word-break: break-word;
117
+ color: #999;
118
+ max-height: 400px;
119
+ overflow-y: auto;
120
+ }
121
+ .vista-error-footer {
122
+ display: flex;
123
+ align-items: center;
124
+ justify-content: space-between;
125
+ padding: 16px 20px;
126
+ background: #111;
127
+ border-top: 1px solid #333;
128
+ }
129
+ .vista-error-footer-text {
130
+ font-size: 12px;
131
+ color: #666;
132
+ }
133
+ .vista-error-btn {
134
+ display: inline-flex;
135
+ align-items: center;
136
+ gap: 6px;
137
+ padding: 10px 16px;
138
+ background: #0070f3;
139
+ border: none;
140
+ border-radius: 8px;
141
+ color: #fff;
142
+ font-size: 13px;
143
+ font-weight: 500;
144
+ cursor: pointer;
145
+ transition: all 0.15s ease;
146
+ }
147
+ .vista-error-btn:hover {
148
+ filter: brightness(1.1);
149
+ }
150
+ .vista-error-nav {
151
+ display: flex;
152
+ gap: 8px;
153
+ align-items: center;
154
+ }
155
+ .vista-error-nav-btn {
156
+ display: flex;
157
+ align-items: center;
158
+ justify-content: center;
159
+ width: 32px;
160
+ height: 32px;
161
+ background: transparent;
162
+ border: 1px solid #333;
163
+ border-radius: 8px;
164
+ color: #888;
165
+ cursor: pointer;
166
+ transition: all 0.15s ease;
167
+ }
168
+ .vista-error-nav-btn:hover:not(:disabled) {
169
+ background: #1a1a1a;
170
+ color: #fff;
171
+ }
172
+ .vista-error-nav-btn:disabled {
173
+ opacity: 0.3;
174
+ cursor: not-allowed;
175
+ }
176
+ .vista-error-count {
177
+ font-size: 13px;
178
+ color: #666;
179
+ min-width: 60px;
180
+ text-align: center;
181
+ }
182
+ .vista-error-stack-title {
183
+ font-size: 11px;
184
+ font-weight: 600;
185
+ text-transform: uppercase;
186
+ letter-spacing: 1px;
187
+ color: #666;
188
+ margin-bottom: 12px;
189
+ }
190
+ </style>
191
+ `;
192
+ // ============================================================================
193
+ // Inline JS for interactivity (no React required)
194
+ // ============================================================================
195
+ const INLINE_SCRIPT = `
196
+ <script>
197
+ function reloadPage() {
198
+ window.location.reload();
199
+ }
200
+ function openInEditor(file, line, column) {
201
+ const url = 'vscode://file' + file + ':' + (line || 1) + ':' + (column || 1);
202
+ window.open(url, '_blank');
203
+ }
204
+ </script>
205
+ `;
206
+ // ============================================================================
207
+ // Stack Trace Parser
208
+ // ============================================================================
209
+ function parseStackTrace(stack) {
210
+ if (!stack)
211
+ return [];
212
+ return stack.split('\n').filter(line => line.trim());
213
+ }
214
+ // ============================================================================
215
+ // Error Overlay Component (SSR only - no hydration)
216
+ // ============================================================================
217
+ function ErrorOverlay({ errors }) {
218
+ const error = errors[0];
219
+ if (!error)
220
+ return (0, jsx_runtime_1.jsx)("div", {});
221
+ const stackLines = parseStackTrace(error.stack || '');
222
+ const errorTypeLabel = error.type === 'build' ? 'Build Error' :
223
+ error.type === 'hydration' ? 'Hydration Error' : 'Runtime Error';
224
+ const fileName = error.file?.split(/[/\\]/).pop() || '';
225
+ return ((0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: {
226
+ __html: `
227
+ ${INLINE_STYLES}
228
+ ${INLINE_SCRIPT}
229
+ <div class="vista-error-container">
230
+ <div class="vista-error-dialog" role="dialog">
231
+ <div class="vista-error-header">
232
+ <span class="vista-error-badge">${errorTypeLabel}</span>
233
+ ${errors.length > 1 ? `
234
+ <div class="vista-error-nav">
235
+ <span class="vista-error-count">1 of ${errors.length}</span>
236
+ </div>
237
+ ` : ''}
238
+ </div>
239
+
240
+ <div class="vista-error-content">
241
+ <div class="vista-error-message">${escapeHtml(error.message)}</div>
242
+
243
+ ${error.file ? `
244
+ <div class="vista-error-location" onclick="openInEditor('${escapeAttr(error.file)}', ${error.line || 1}, ${error.column || 1})" style="cursor: pointer">
245
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="color: #888">
246
+ <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"></path>
247
+ <polyline points="14,2 14,8 20,8"></polyline>
248
+ </svg>
249
+ <span class="vista-error-location-file">${escapeHtml(error.file)}</span>
250
+ ${error.line ? `<span class="vista-error-location-line">:${error.line}${error.column ? `:${error.column}` : ''}</span>` : ''}
251
+ </div>
252
+ ` : ''}
253
+
254
+ ${stackLines.length > 0 ? `
255
+ <div class="vista-error-stack-title">Stack Trace</div>
256
+ <div class="vista-error-stack">${escapeHtml(stackLines.join('\n'))}</div>
257
+ ` : ''}
258
+ </div>
259
+
260
+ <div class="vista-error-footer">
261
+ <span class="vista-error-footer-text">Vista Development Mode</span>
262
+ <button class="vista-error-btn" onclick="reloadPage()">
263
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
264
+ <polyline points="23,4 23,10 17,10"></polyline>
265
+ <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"></path>
266
+ </svg>
267
+ Reload Page
268
+ </button>
269
+ </div>
270
+ </div>
271
+ </div>
272
+ `
273
+ } }));
274
+ }
275
+ // Helper functions
276
+ function escapeHtml(text) {
277
+ return text
278
+ .replace(/&/g, '&amp;')
279
+ .replace(/</g, '&lt;')
280
+ .replace(/>/g, '&gt;')
281
+ .replace(/"/g, '&quot;')
282
+ .replace(/'/g, '&#039;');
283
+ }
284
+ function escapeAttr(text) {
285
+ return text.replace(/'/g, "\\'").replace(/"/g, '\\"');
286
+ }
287
+ // ============================================================================
288
+ // Legacy exports for compatibility
289
+ // ============================================================================
290
+ class DevErrorBoundary extends react_1.default.Component {
291
+ constructor(props) {
292
+ super(props);
293
+ this.state = { hasError: false, error: null };
294
+ }
295
+ static getDerivedStateFromError(error) {
296
+ return { hasError: true, error };
297
+ }
298
+ render() {
299
+ if (this.state.hasError && this.state.error) {
300
+ return ((0, jsx_runtime_1.jsx)(ErrorOverlay, { errors: [{
301
+ type: 'runtime',
302
+ message: this.state.error.message || 'Unknown Error',
303
+ stack: this.state.error.stack
304
+ }] }));
305
+ }
306
+ return this.props.children;
307
+ }
308
+ }
309
+ exports.DevErrorBoundary = DevErrorBoundary;
310
+ exports.VistaDevErrorBoundary = DevErrorBoundary;
@@ -0,0 +1,28 @@
1
+ import { ImageConfigComplete } from './image-config';
2
+ import { ImageLoader } from './image-loader';
3
+ import React from 'react';
4
+ export type PlaceholderValue = 'blur' | 'empty';
5
+ export type ImageProps = React.ImgHTMLAttributes<HTMLImageElement> & {
6
+ src: string;
7
+ alt: string;
8
+ width?: number | string;
9
+ height?: number | string;
10
+ fill?: boolean;
11
+ loader?: ImageLoader;
12
+ quality?: number | string;
13
+ priority?: boolean;
14
+ unoptimized?: boolean;
15
+ placeholder?: PlaceholderValue;
16
+ blurDataURL?: string;
17
+ onLoadingComplete?: (result: {
18
+ naturalWidth: number;
19
+ naturalHeight: number;
20
+ }) => void;
21
+ };
22
+ type ImgProps = React.ImgHTMLAttributes<HTMLImageElement> & {
23
+ width?: number;
24
+ height?: number;
25
+ srcSet?: string;
26
+ };
27
+ export declare function getImgProps(props: ImageProps, config: ImageConfigComplete, defaultLoader: ImageLoader): ImgProps;
28
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getImgProps = getImgProps;
4
+ const image_config_1 = require("./image-config");
5
+ // Helper: Generate srcSet
6
+ function generateSrcSet(src, width, loader, config, unoptimized) {
7
+ if (unoptimized)
8
+ return undefined;
9
+ const { deviceSizes, imageSizes } = config;
10
+ const sizes = [...deviceSizes, ...imageSizes].sort((a, b) => a - b);
11
+ // If width is known, only generate sizes up to that width (plus maybe 2x/3x for density)
12
+ // For simplicity MVP, we'll generate device sizes.
13
+ return sizes
14
+ .map((size) => {
15
+ const url = loader({ src, width: size });
16
+ return `${url} ${size}w`;
17
+ })
18
+ .join(', ');
19
+ }
20
+ function getImgProps(props, config = image_config_1.imageConfigDefault, defaultLoader) {
21
+ const { src, alt, width, height, fill, loader = defaultLoader, quality, priority, unoptimized, style, sizes, className, loading, placeholder, blurDataURL, onLoadingComplete, ...rest } = props;
22
+ const imgStyle = { ...style };
23
+ // Handle Fill Mode
24
+ if (fill) {
25
+ imgStyle.position = 'absolute';
26
+ imgStyle.height = '100%';
27
+ imgStyle.width = '100%';
28
+ imgStyle.inset = 0;
29
+ imgStyle.objectFit = 'cover'; // Default to cover for bg images
30
+ }
31
+ // Handle Dimensions
32
+ let widthInt = width ? Number(width) : undefined;
33
+ let heightInt = height ? Number(height) : undefined;
34
+ // Generate SrcSet
35
+ const srcSet = generateSrcSet(src, widthInt, loader, config, !!unoptimized);
36
+ return {
37
+ ...rest,
38
+ src,
39
+ alt,
40
+ width: widthInt,
41
+ height: heightInt,
42
+ loading: priority ? 'eager' : (loading || 'lazy'),
43
+ // fetchPriority: priority ? 'high' : undefined, // React types might strict on this
44
+ style: imgStyle,
45
+ sizes: sizes || (fill ? '100vw' : undefined),
46
+ srcSet,
47
+ className,
48
+ };
49
+ }
@@ -0,0 +1,20 @@
1
+ export declare const imageConfigDefault: {
2
+ deviceSizes: number[];
3
+ imageSizes: number[];
4
+ path: string;
5
+ loader: "default";
6
+ loaderFile: string;
7
+ domains: string[];
8
+ disableStaticImages: boolean;
9
+ minimumCacheTTL: number;
10
+ formats: readonly ["image/webp"];
11
+ dangerouslyAllowSVG: boolean;
12
+ contentSecurityPolicy: string;
13
+ contentDispositionType: "inline";
14
+ remotePatterns: any[];
15
+ unoptimized: boolean;
16
+ };
17
+ export type ImageConfigComplete = typeof imageConfigDefault;
18
+ export type ImageConfig = Partial<ImageConfigComplete>;
19
+ export declare const VALID_LOADERS: readonly ["default", "imgix", "cloudinary", "akamai", "custom"];
20
+ export type LoaderValue = typeof VALID_LOADERS[number];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VALID_LOADERS = exports.imageConfigDefault = void 0;
4
+ exports.imageConfigDefault = {
5
+ deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
6
+ imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
7
+ path: '/_next/image',
8
+ loader: 'default',
9
+ loaderFile: '',
10
+ domains: [],
11
+ disableStaticImages: false,
12
+ minimumCacheTTL: 60,
13
+ formats: ['image/webp'],
14
+ dangerouslyAllowSVG: false,
15
+ contentSecurityPolicy: "script-src 'none'; frame-src 'none'; sandbox;",
16
+ contentDispositionType: 'inline',
17
+ remotePatterns: [],
18
+ unoptimized: false,
19
+ };
20
+ exports.VALID_LOADERS = ['default', 'imgix', 'cloudinary', 'akamai', 'custom'];
@@ -0,0 +1,7 @@
1
+ export type ImageLoaderProps = {
2
+ src: string;
3
+ width: number;
4
+ quality?: number;
5
+ };
6
+ export type ImageLoader = (p: ImageLoaderProps) => string;
7
+ export declare const defaultLoader: ImageLoader;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultLoader = void 0;
4
+ // Default loader: simple pass-through for now,
5
+ // envisioning a future where this hits an optimization endpoint.
6
+ const defaultLoader = ({ src, width, quality }) => {
7
+ // If user wants optimization, they would hook up a real loader here.
8
+ // For static dev, we just return the src.
9
+ // In a real Next.js app, this would be: `/_next/image?url=${encodeURIComponent(src)}&w=${width}&q=${quality || 75}`
10
+ // NOTE: Emulating optimizing behavior by appending query params for now (if backend supported it)
11
+ // return `${src}?w=${width}&q=${quality || 75}`;
12
+ return src;
13
+ };
14
+ exports.defaultLoader = defaultLoader;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ImageProps } from './get-img-props';
3
+ export interface EnhancedImageProps extends ImageProps {
4
+ }
5
+ export declare const Image: React.ForwardRefExoticComponent<EnhancedImageProps & React.RefAttributes<HTMLImageElement>>;
6
+ export default Image;
@@ -0,0 +1,110 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Image = void 0;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const get_img_props_1 = require("./get-img-props");
8
+ const image_config_1 = require("./image-config");
9
+ const image_loader_1 = require("./image-loader");
10
+ // Blur placeholder styles
11
+ const blurStyle = {
12
+ position: 'absolute',
13
+ top: 0,
14
+ left: 0,
15
+ bottom: 0,
16
+ right: 0,
17
+ backgroundSize: 'cover',
18
+ backgroundPosition: 'center',
19
+ filter: 'blur(20px)',
20
+ transform: 'scale(1.1)',
21
+ transition: 'opacity 0.3s ease-in-out',
22
+ };
23
+ const wrapperStyle = {
24
+ position: 'relative',
25
+ overflow: 'hidden',
26
+ };
27
+ exports.Image = (0, react_1.forwardRef)((props, ref) => {
28
+ const { placeholder, blurDataURL, onLoadingComplete, priority, ...restProps } = props;
29
+ const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
30
+ const [isInView, setIsInView] = (0, react_1.useState)(priority || false);
31
+ const imgRef = (0, react_1.useRef)(null);
32
+ const observerRef = (0, react_1.useRef)(null);
33
+ // Combine refs
34
+ const setRefs = (0, react_1.useCallback)((node) => {
35
+ imgRef.current = node;
36
+ if (typeof ref === 'function') {
37
+ ref(node);
38
+ }
39
+ else if (ref) {
40
+ ref.current = node;
41
+ }
42
+ }, [ref]);
43
+ // IntersectionObserver for lazy loading
44
+ (0, react_1.useEffect)(() => {
45
+ if (priority) {
46
+ setIsInView(true);
47
+ return;
48
+ }
49
+ const element = imgRef.current;
50
+ if (!element)
51
+ return;
52
+ observerRef.current = new IntersectionObserver((entries) => {
53
+ entries.forEach((entry) => {
54
+ if (entry.isIntersecting) {
55
+ setIsInView(true);
56
+ observerRef.current?.disconnect();
57
+ }
58
+ });
59
+ }, {
60
+ rootMargin: '200px', // Start loading 200px before viewport
61
+ threshold: 0,
62
+ });
63
+ observerRef.current.observe(element);
64
+ return () => {
65
+ observerRef.current?.disconnect();
66
+ };
67
+ }, [priority]);
68
+ // Handle image load complete
69
+ const handleLoad = (0, react_1.useCallback)((event) => {
70
+ const img = event.currentTarget;
71
+ setIsLoaded(true);
72
+ if (onLoadingComplete) {
73
+ onLoadingComplete({
74
+ naturalWidth: img.naturalWidth,
75
+ naturalHeight: img.naturalHeight,
76
+ });
77
+ }
78
+ }, [onLoadingComplete]);
79
+ // Get processed img props
80
+ const imgProps = (0, get_img_props_1.getImgProps)({ ...restProps, priority }, image_config_1.imageConfigDefault, image_loader_1.defaultLoader);
81
+ // Determine if we should show blur placeholder
82
+ const showBlur = placeholder === 'blur' && blurDataURL && !isLoaded;
83
+ const needsWrapper = showBlur;
84
+ // Render image element
85
+ const imageElement = ((0, jsx_runtime_1.jsx)("img", { ...imgProps, ref: setRefs, onLoad: handleLoad, style: {
86
+ ...imgProps.style,
87
+ ...(showBlur ? {
88
+ opacity: isLoaded ? 1 : 0,
89
+ transition: 'opacity 0.5s ease-in-out'
90
+ } : {}),
91
+ },
92
+ // Only set src when in view (lazy loading)
93
+ src: isInView ? imgProps.src : undefined, srcSet: isInView ? imgProps.srcSet : undefined, decoding: priority ? 'sync' : 'async', fetchPriority: priority ? 'high' : undefined }));
94
+ // Wrap with blur placeholder if needed
95
+ if (needsWrapper) {
96
+ return ((0, jsx_runtime_1.jsxs)("span", { style: {
97
+ ...wrapperStyle,
98
+ display: imgProps.style?.display || 'inline-block',
99
+ width: imgProps.width,
100
+ height: imgProps.height,
101
+ }, children: [(0, jsx_runtime_1.jsx)("span", { style: {
102
+ ...blurStyle,
103
+ backgroundImage: `url("${blurDataURL}")`,
104
+ opacity: isLoaded ? 0 : 1,
105
+ }, "aria-hidden": "true" }), imageElement] }));
106
+ }
107
+ return imageElement;
108
+ });
109
+ exports.Image.displayName = 'Image';
110
+ exports.default = exports.Image;
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
3
+ src: string;
4
+ alt: string;
5
+ width?: number | string;
6
+ height?: number | string;
7
+ className?: string;
8
+ priority?: boolean;
9
+ }
10
+ export default function Image({ src, alt, width, height, className, priority, ...props }: ImageProps): import("react/jsx-runtime").JSX.Element;
package/dist/image.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Image;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function Image({ src, alt, width, height, className, priority, ...props }) {
6
+ return ((0, jsx_runtime_1.jsx)("img", { src: src, alt: alt, width: width, height: height, className: className, loading: priority ? "eager" : "lazy", ...props }));
7
+ }
@@ -0,0 +1,20 @@
1
+ export * from './router';
2
+ export * from './components';
3
+ export * from './auth';
4
+ export * from './types';
5
+ export * from './dev-error';
6
+ export { useRouter } from './client/router';
7
+ export { usePathname, useSearchParams, useParams, useSelectedLayoutSegment, useSelectedLayoutSegments, } from './client/navigation';
8
+ export { default as dynamic } from './client/dynamic';
9
+ export { default as Script } from './client/script';
10
+ export { default as Head, generateMetadataHead } from './client/head';
11
+ export type { Metadata as HeadMetadata } from './client/head';
12
+ export * from './client/font';
13
+ export * from './metadata';
14
+ export type { Metadata } from './metadata/types';
15
+ export { hydrateClientComponents, initializeHydration } from './client/hydration';
16
+ export { ClientIsland } from './components/client-island';
17
+ export { Client } from './components/client';
18
+ export type { ClientManifest, ClientComponentEntry } from './build/rsc/client-manifest';
19
+ export type { ServerManifest, ServerComponentEntry, RouteEntry } from './build/rsc/server-manifest';
20
+ export type { RSCPayload, ClientReference } from './build/rsc/rsc-renderer';
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Client = exports.ClientIsland = exports.initializeHydration = exports.hydrateClientComponents = exports.generateMetadataHead = exports.Head = exports.Script = exports.dynamic = exports.useSelectedLayoutSegments = exports.useSelectedLayoutSegment = exports.useParams = exports.useSearchParams = exports.usePathname = exports.useRouter = void 0;
21
+ __exportStar(require("./router"), exports);
22
+ __exportStar(require("./components"), exports);
23
+ __exportStar(require("./auth"), exports);
24
+ __exportStar(require("./types"), exports);
25
+ __exportStar(require("./dev-error"), exports);
26
+ // Client-side features
27
+ var router_1 = require("./client/router");
28
+ Object.defineProperty(exports, "useRouter", { enumerable: true, get: function () { return router_1.useRouter; } });
29
+ var navigation_1 = require("./client/navigation");
30
+ Object.defineProperty(exports, "usePathname", { enumerable: true, get: function () { return navigation_1.usePathname; } });
31
+ Object.defineProperty(exports, "useSearchParams", { enumerable: true, get: function () { return navigation_1.useSearchParams; } });
32
+ Object.defineProperty(exports, "useParams", { enumerable: true, get: function () { return navigation_1.useParams; } });
33
+ Object.defineProperty(exports, "useSelectedLayoutSegment", { enumerable: true, get: function () { return navigation_1.useSelectedLayoutSegment; } });
34
+ Object.defineProperty(exports, "useSelectedLayoutSegments", { enumerable: true, get: function () { return navigation_1.useSelectedLayoutSegments; } });
35
+ var dynamic_1 = require("./client/dynamic");
36
+ Object.defineProperty(exports, "dynamic", { enumerable: true, get: function () { return __importDefault(dynamic_1).default; } });
37
+ var script_1 = require("./client/script");
38
+ Object.defineProperty(exports, "Script", { enumerable: true, get: function () { return __importDefault(script_1).default; } });
39
+ var head_1 = require("./client/head");
40
+ Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return __importDefault(head_1).default; } });
41
+ Object.defineProperty(exports, "generateMetadataHead", { enumerable: true, get: function () { return head_1.generateMetadataHead; } });
42
+ // Font exports
43
+ __exportStar(require("./client/font"), exports);
44
+ // Metadata exports (Next.js compatible)
45
+ __exportStar(require("./metadata"), exports);
46
+ // RSC (React Server Components) exports
47
+ var hydration_1 = require("./client/hydration");
48
+ Object.defineProperty(exports, "hydrateClientComponents", { enumerable: true, get: function () { return hydration_1.hydrateClientComponents; } });
49
+ Object.defineProperty(exports, "initializeHydration", { enumerable: true, get: function () { return hydration_1.initializeHydration; } });
50
+ var client_island_1 = require("./components/client-island");
51
+ Object.defineProperty(exports, "ClientIsland", { enumerable: true, get: function () { return client_island_1.ClientIsland; } });
52
+ var client_1 = require("./components/client");
53
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });