vista-core-js 0.0.5 → 0.0.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.
- package/dist/app.d.ts +0 -8
- package/dist/app.js +1 -47
- package/dist/client.js +1 -1
- package/dist/entry-client.js +2 -2
- package/dist/entry-server.js +3 -3
- package/dist/image/get-img-props.d.ts +2 -2
- package/dist/image/get-img-props.js +1 -1
- package/dist/image/index.d.ts +1 -1
- package/dist/image/index.js +3 -3
- package/dist/plugin.js +2 -2
- package/dist/router-loader.d.ts +13 -0
- package/dist/router-loader.js +44 -0
- package/package.json +1 -1
package/dist/app.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare function loadRoute(path: string): Promise<React.ComponentType<any> | null>;
|
|
3
|
-
export declare function loadRootLayout(): Promise<{
|
|
4
|
-
Component: React.ComponentType<any>;
|
|
5
|
-
metadata: any;
|
|
6
|
-
} | {
|
|
7
|
-
Component: null;
|
|
8
|
-
metadata: {};
|
|
9
|
-
}>;
|
|
10
2
|
export type VistaAsset = {
|
|
11
3
|
type: 'style' | 'script' | 'preamble';
|
|
12
4
|
src?: string;
|
package/dist/app.js
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { Suspense } from 'react';
|
|
3
3
|
import { useRouter } from './router.js';
|
|
4
|
-
|
|
5
|
-
// Note: Vite treats absolute paths in glob as relative to the project root
|
|
6
|
-
// Lazy load all pages and layouts at module level so they can be accessed by loadRoute
|
|
7
|
-
// Note: Vite treats absolute paths in glob as relative to the project root
|
|
8
|
-
// FIX: Use eager: true to solve HMR instability with lazy boundaries
|
|
9
|
-
// FIX: Use eager: true to solve HMR instability with lazy boundaries
|
|
10
|
-
const pages = import.meta.glob('/app/**/index.tsx', { eager: true });
|
|
11
|
-
const layouts = import.meta.glob('/app/**/layout.tsx', { eager: true });
|
|
12
|
-
const rootLayout = import.meta.glob('/app/layout.tsx', { eager: true });
|
|
13
|
-
// Helper to resolve route path to file key
|
|
14
|
-
function getPageKey(path) {
|
|
15
|
-
const cleanPath = path === '/' ? '/' : path.replace(/\/$/, '');
|
|
16
|
-
return `/app${cleanPath === '/' ? '' : cleanPath}/index.tsx`;
|
|
17
|
-
}
|
|
18
|
-
// Exported loader for entry-client to preload the initial route
|
|
19
|
-
export async function loadRoute(path) {
|
|
20
|
-
const pageKey = getPageKey(path);
|
|
21
|
-
if (pages[pageKey]) {
|
|
22
|
-
try {
|
|
23
|
-
// Eager: pages[pageKey] is the module itself
|
|
24
|
-
const mod = pages[pageKey];
|
|
25
|
-
return mod.default;
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
console.error(`Failed to load route: ${path}`, e);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
// Exported loader for entry-client/server to preload the root layout and metadata
|
|
34
|
-
export async function loadRootLayout() {
|
|
35
|
-
const rootLayoutKey = '/app/layout.tsx';
|
|
36
|
-
if (rootLayout[rootLayoutKey]) {
|
|
37
|
-
try {
|
|
38
|
-
// Eager: rootLayout[rootLayoutKey] is the module itself
|
|
39
|
-
const mod = rootLayout[rootLayoutKey];
|
|
40
|
-
return {
|
|
41
|
-
Component: mod.default,
|
|
42
|
-
metadata: mod.metadata || {}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
console.error('Failed to load root layout', e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return { Component: null, metadata: {} };
|
|
50
|
-
}
|
|
4
|
+
import { pages, rootLayout, getPageKey } from './router-loader.js';
|
|
51
5
|
function VistaHead({ assets, metadata }) {
|
|
52
6
|
// Serialize assets for client hydration
|
|
53
7
|
const serializedAssets = JSON.stringify(assets || []);
|
package/dist/client.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { useState, useEffect } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom/client';
|
|
4
4
|
import { RouterProvider, useRouter } from './router.js';
|
|
5
|
-
import { ErrorOverlay } from './ErrorOverlay';
|
|
5
|
+
import { ErrorOverlay } from './ErrorOverlay.js';
|
|
6
6
|
// --- Error Management ---
|
|
7
7
|
function VistaErrorManager({ children, initialError }) {
|
|
8
8
|
const [error, setError] = useState(initialError || null);
|
package/dist/entry-client.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import ReactDOM from 'react-dom/client';
|
|
3
3
|
import { RouterProvider } from './router';
|
|
4
|
-
import App from './app';
|
|
4
|
+
import App from './app.js';
|
|
5
5
|
import { showErrorOverlay } from './error-overlay';
|
|
6
|
-
import { loadRoute, loadRootLayout } from './
|
|
6
|
+
import { loadRoute, loadRootLayout } from './router-loader.js';
|
|
7
7
|
export async function mount() {
|
|
8
8
|
// For Full Document Hydration (RootLayout provides html/body)
|
|
9
9
|
// we hydrate 'document' directly.
|
package/dist/entry-server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { renderToPipeableStream } from 'react-dom/server';
|
|
3
|
-
import { RouterProvider } from './router';
|
|
4
|
-
import App from './app';
|
|
5
|
-
import { loadRootLayout } from './
|
|
3
|
+
import { RouterProvider } from './router.js';
|
|
4
|
+
import App from './app.js';
|
|
5
|
+
import { loadRootLayout } from './router-loader.js';
|
|
6
6
|
export async function render(url, options = {}) {
|
|
7
7
|
// Preload Root Layout synchronously for the render pass
|
|
8
8
|
let initialRootLayout;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageConfigComplete } from './image-config';
|
|
2
|
-
import { ImageLoader } from './image-loader';
|
|
1
|
+
import { ImageConfigComplete } from './image-config.js';
|
|
2
|
+
import { ImageLoader } from './image-loader.js';
|
|
3
3
|
export type ImageProps = React.ImgHTMLAttributes<HTMLImageElement> & {
|
|
4
4
|
src: string;
|
|
5
5
|
alt: string;
|
package/dist/image/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const Image: React.ForwardRefExoticComponent<React.ImgHTMLAttribu
|
|
|
5
5
|
width?: number | string;
|
|
6
6
|
height?: number | string;
|
|
7
7
|
fill?: boolean;
|
|
8
|
-
loader?: import("./image-loader").ImageLoader;
|
|
8
|
+
loader?: import("./image-loader.js").ImageLoader;
|
|
9
9
|
quality?: number | string;
|
|
10
10
|
priority?: boolean;
|
|
11
11
|
unoptimized?: boolean;
|
package/dist/image/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import { getImgProps } from './get-img-props';
|
|
4
|
-
import { imageConfigDefault } from './image-config';
|
|
5
|
-
import { defaultLoader } from './image-loader';
|
|
3
|
+
import { getImgProps } from './get-img-props.js';
|
|
4
|
+
import { imageConfigDefault } from './image-config.js';
|
|
5
|
+
import { defaultLoader } from './image-loader.js';
|
|
6
6
|
export const Image = forwardRef((props, ref) => {
|
|
7
7
|
// In a real implementation, we might consume config from a Context Provider
|
|
8
8
|
// For now, we use the default config.
|
package/dist/plugin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
4
|
-
const clientPath = path.resolve(__dirname, './client.
|
|
4
|
+
const clientPath = path.resolve(__dirname, './client.js'); // Resolves to dist/client.js
|
|
5
5
|
export function vistaPlugin(options = {}) {
|
|
6
6
|
const logoPath = options.logo || '/favicon.ico';
|
|
7
7
|
return {
|
|
@@ -39,7 +39,7 @@ export function vistaPlugin(options = {}) {
|
|
|
39
39
|
<body>
|
|
40
40
|
<div id="root"></div>
|
|
41
41
|
<script type="module">
|
|
42
|
-
import { mount, mountError } from '
|
|
42
|
+
import { mount, mountError } from 'vista-core-js';
|
|
43
43
|
console.log('[Vista] Bootstrapping...');
|
|
44
44
|
try {
|
|
45
45
|
// use lazy loading (default) to allow catching syntax errors per module
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const pages: Record<string, unknown>;
|
|
3
|
+
export declare const layouts: Record<string, unknown>;
|
|
4
|
+
export declare const rootLayout: Record<string, unknown>;
|
|
5
|
+
export declare function getPageKey(path: string): string;
|
|
6
|
+
export declare function loadRoute(path: string): Promise<React.ComponentType<any> | null>;
|
|
7
|
+
export declare function loadRootLayout(): Promise<{
|
|
8
|
+
Component: React.ComponentType<any>;
|
|
9
|
+
metadata: any;
|
|
10
|
+
} | {
|
|
11
|
+
Component: null;
|
|
12
|
+
metadata: {};
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Lazy load all pages and layouts at module level so they can be accessed by loadRoute
|
|
2
|
+
// Note: Vite treats absolute paths in glob as relative to the project root
|
|
3
|
+
// FIX: Use eager: true to solve HMR instability with lazy boundaries
|
|
4
|
+
export const pages = import.meta.glob('/app/**/index.tsx', { eager: true });
|
|
5
|
+
export const layouts = import.meta.glob('/app/**/layout.tsx', { eager: true });
|
|
6
|
+
export const rootLayout = import.meta.glob('/app/layout.tsx', { eager: true });
|
|
7
|
+
// Helper to resolve route path to file key
|
|
8
|
+
export function getPageKey(path) {
|
|
9
|
+
const cleanPath = path === '/' ? '/' : path.replace(/\/$/, '');
|
|
10
|
+
return `/app${cleanPath === '/' ? '' : cleanPath}/index.tsx`;
|
|
11
|
+
}
|
|
12
|
+
// Exported loader for entry-client to preload the initial route
|
|
13
|
+
export async function loadRoute(path) {
|
|
14
|
+
const pageKey = getPageKey(path);
|
|
15
|
+
if (pages[pageKey]) {
|
|
16
|
+
try {
|
|
17
|
+
// Eager: pages[pageKey] is the module itself
|
|
18
|
+
const mod = pages[pageKey];
|
|
19
|
+
return mod.default;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.error(`Failed to load route: ${path}`, e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
// Exported loader for entry-client/server to preload the root layout and metadata
|
|
28
|
+
export async function loadRootLayout() {
|
|
29
|
+
const rootLayoutKey = '/app/layout.tsx';
|
|
30
|
+
if (rootLayout[rootLayoutKey]) {
|
|
31
|
+
try {
|
|
32
|
+
// Eager: rootLayout[rootLayoutKey] is the module itself
|
|
33
|
+
const mod = rootLayout[rootLayoutKey];
|
|
34
|
+
return {
|
|
35
|
+
Component: mod.default,
|
|
36
|
+
metadata: mod.metadata || {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
console.error('Failed to load root layout', e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { Component: null, metadata: {} };
|
|
44
|
+
}
|