@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.
- package/bin/vista.js +98 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.js +16 -0
- package/dist/bin/build-rsc.d.ts +17 -0
- package/dist/bin/build-rsc.js +320 -0
- package/dist/bin/build.d.ts +4 -0
- package/dist/bin/build.js +336 -0
- package/dist/bin/file-scanner.d.ts +66 -0
- package/dist/bin/file-scanner.js +399 -0
- package/dist/bin/server-component-plugin.d.ts +17 -0
- package/dist/bin/server-component-plugin.js +133 -0
- package/dist/bin/webpack.config.d.ts +6 -0
- package/dist/bin/webpack.config.js +138 -0
- package/dist/build/manifest.d.ts +95 -0
- package/dist/build/manifest.js +168 -0
- package/dist/build/rsc/client-manifest.d.ts +48 -0
- package/dist/build/rsc/client-manifest.js +191 -0
- package/dist/build/rsc/client-reference-plugin.d.ts +37 -0
- package/dist/build/rsc/client-reference-plugin.js +185 -0
- package/dist/build/rsc/compiler.d.ts +36 -0
- package/dist/build/rsc/compiler.js +311 -0
- package/dist/build/rsc/index.d.ts +16 -0
- package/dist/build/rsc/index.js +32 -0
- package/dist/build/rsc/native-scanner.d.ts +123 -0
- package/dist/build/rsc/native-scanner.js +165 -0
- package/dist/build/rsc/rsc-renderer.d.ts +99 -0
- package/dist/build/rsc/rsc-renderer.js +269 -0
- package/dist/build/rsc/server-component-loader.d.ts +19 -0
- package/dist/build/rsc/server-component-loader.js +147 -0
- package/dist/build/rsc/server-manifest.d.ts +63 -0
- package/dist/build/rsc/server-manifest.js +268 -0
- package/dist/build/webpack/loaders/vista-flight-loader.d.ts +17 -0
- package/dist/build/webpack/loaders/vista-flight-loader.js +93 -0
- package/dist/build/webpack/plugins/vista-flight-plugin.d.ts +36 -0
- package/dist/build/webpack/plugins/vista-flight-plugin.js +133 -0
- package/dist/client/dynamic.d.ts +25 -0
- package/dist/client/dynamic.js +68 -0
- package/dist/client/font.d.ts +98 -0
- package/dist/client/font.js +109 -0
- package/dist/client/head.d.ts +79 -0
- package/dist/client/head.js +261 -0
- package/dist/client/hydration.d.ts +45 -0
- package/dist/client/hydration.js +291 -0
- package/dist/client/link.d.ts +30 -0
- package/dist/client/link.js +188 -0
- package/dist/client/navigation.d.ts +28 -0
- package/dist/client/navigation.js +116 -0
- package/dist/client/router.d.ts +41 -0
- package/dist/client/router.js +190 -0
- package/dist/client/script.d.ts +51 -0
- package/dist/client/script.js +118 -0
- package/dist/components/client-island.d.ts +34 -0
- package/dist/components/client-island.js +75 -0
- package/dist/components/client.d.ts +29 -0
- package/dist/components/client.js +102 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +8 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +13 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +31 -0
- package/dist/dev-error.d.ts +35 -0
- package/dist/dev-error.js +310 -0
- package/dist/image/get-img-props.d.ts +28 -0
- package/dist/image/get-img-props.js +49 -0
- package/dist/image/image-config.d.ts +20 -0
- package/dist/image/image-config.js +20 -0
- package/dist/image/image-loader.d.ts +7 -0
- package/dist/image/image-loader.js +14 -0
- package/dist/image/index.d.ts +6 -0
- package/dist/image/index.js +110 -0
- package/dist/image.d.ts +10 -0
- package/dist/image.js +7 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +53 -0
- package/dist/metadata/generate.d.ts +22 -0
- package/dist/metadata/generate.js +324 -0
- package/dist/metadata/index.d.ts +7 -0
- package/dist/metadata/index.js +26 -0
- package/dist/metadata/types.d.ts +325 -0
- package/dist/metadata/types.js +15 -0
- package/dist/router/context.d.ts +8 -0
- package/dist/router/context.js +13 -0
- package/dist/router/index.d.ts +2 -0
- package/dist/router/index.js +18 -0
- package/dist/router/provider.d.ts +5 -0
- package/dist/router/provider.js +31 -0
- package/dist/server/client-boundary.d.ts +48 -0
- package/dist/server/client-boundary.js +133 -0
- package/dist/server/engine.d.ts +4 -0
- package/dist/server/engine.js +651 -0
- package/dist/server/index.d.ts +95 -0
- package/dist/server/index.js +177 -0
- package/dist/server/rsc-engine.d.ts +20 -0
- package/dist/server/rsc-engine.js +588 -0
- package/dist/server/rsc-module-system.d.ts +33 -0
- package/dist/server/rsc-module-system.js +119 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +2 -0
- package/package.json +103 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vista Flight Client Entry Plugin
|
|
4
|
+
*
|
|
5
|
+
* Webpack plugin that creates separate client entries for components
|
|
6
|
+
* marked with 'client load' directive. Uses Rust scanner for detection.
|
|
7
|
+
*
|
|
8
|
+
* This is similar to Next.js's FlightClientEntryPlugin.
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.VistaFlightPlugin = void 0;
|
|
15
|
+
exports.getClientModules = getClientModules;
|
|
16
|
+
exports.isClientModule = isClientModule;
|
|
17
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
// Plugin state for tracking client modules
|
|
20
|
+
const pluginState = {
|
|
21
|
+
clientModules: new Map(),
|
|
22
|
+
serverModules: new Map(),
|
|
23
|
+
};
|
|
24
|
+
const PLUGIN_NAME = 'VistaFlightPlugin';
|
|
25
|
+
class VistaFlightPlugin {
|
|
26
|
+
appDir;
|
|
27
|
+
dev;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.appDir = options.appDir;
|
|
30
|
+
this.dev = options.dev;
|
|
31
|
+
}
|
|
32
|
+
apply(compiler) {
|
|
33
|
+
// Hook into afterCompile to collect module info
|
|
34
|
+
compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => {
|
|
35
|
+
this.collectModuleInfo(compilation, compiler);
|
|
36
|
+
});
|
|
37
|
+
// Hook into emit to generate client reference manifest
|
|
38
|
+
compiler.hooks.emit.tapAsync(PLUGIN_NAME, (compilation, callback) => {
|
|
39
|
+
this.generateClientManifest(compilation);
|
|
40
|
+
callback();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Collect information about all modules and their RSC status
|
|
45
|
+
*/
|
|
46
|
+
collectModuleInfo(compilation, compiler) {
|
|
47
|
+
const modules = compilation.modules;
|
|
48
|
+
const normalizedAppDir = this.appDir.replace(/\\/g, '/').toLowerCase();
|
|
49
|
+
let checkedCount = 0;
|
|
50
|
+
let matchedCount = 0;
|
|
51
|
+
for (const mod of modules) {
|
|
52
|
+
// Check if it's a NormalModule (by checking for resource property)
|
|
53
|
+
const normalMod = mod;
|
|
54
|
+
const resource = normalMod.resource;
|
|
55
|
+
if (!resource)
|
|
56
|
+
continue;
|
|
57
|
+
checkedCount++;
|
|
58
|
+
// Normalize paths for comparison
|
|
59
|
+
const normalizedResource = resource.replace(/\\/g, '/').toLowerCase();
|
|
60
|
+
// Only process app directory files
|
|
61
|
+
if (!normalizedResource.includes(normalizedAppDir))
|
|
62
|
+
continue;
|
|
63
|
+
// Skip non-JS/TS files
|
|
64
|
+
if (!/\.(tsx?|jsx?)$/i.test(resource))
|
|
65
|
+
continue;
|
|
66
|
+
matchedCount++;
|
|
67
|
+
// Get RSC info from build info (set by vista-flight-loader)
|
|
68
|
+
const buildInfo = normalMod.buildInfo;
|
|
69
|
+
const rscInfo = buildInfo?.rsc;
|
|
70
|
+
if (!rscInfo)
|
|
71
|
+
continue;
|
|
72
|
+
const moduleId = compilation.chunkGraph.getModuleId(normalMod);
|
|
73
|
+
const relativePath = path_1.default.relative(this.appDir, resource);
|
|
74
|
+
const moduleInfo = {
|
|
75
|
+
moduleId: moduleId !== null ? moduleId : resource,
|
|
76
|
+
absolutePath: resource,
|
|
77
|
+
relativePath: relativePath.replace(/\\/g, '/'),
|
|
78
|
+
exports: ['default'],
|
|
79
|
+
};
|
|
80
|
+
if (rscInfo.isClientRef) {
|
|
81
|
+
pluginState.clientModules.set(resource, moduleInfo);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
pluginState.serverModules.set(resource, moduleInfo);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Debug logging (only in dev mode)
|
|
88
|
+
if (this.dev && process.env.VISTA_DEBUG) {
|
|
89
|
+
console.log(`[Vista Flight Plugin] Found ${pluginState.clientModules.size} client, ${pluginState.serverModules.size} server modules`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate client reference manifest for hydration
|
|
94
|
+
*/
|
|
95
|
+
generateClientManifest(compilation) {
|
|
96
|
+
const manifest = {
|
|
97
|
+
clientModules: {},
|
|
98
|
+
};
|
|
99
|
+
// Build manifest from collected client modules
|
|
100
|
+
pluginState.clientModules.forEach((info, resource) => {
|
|
101
|
+
const componentId = path_1.default.basename(resource).replace(/\.(tsx?|jsx?)$/, '');
|
|
102
|
+
manifest.clientModules[componentId] = {
|
|
103
|
+
id: info.moduleId,
|
|
104
|
+
chunks: ['client.js'],
|
|
105
|
+
name: 'default',
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
// Emit manifest as a JS file that sets a global
|
|
109
|
+
const manifestSource = `
|
|
110
|
+
// Vista Client Reference Manifest
|
|
111
|
+
// Generated by VistaFlightPlugin
|
|
112
|
+
(function() {
|
|
113
|
+
if (typeof window !== 'undefined') {
|
|
114
|
+
window.__VISTA_CLIENT_MANIFEST__ = ${JSON.stringify(manifest, null, 2)};
|
|
115
|
+
}
|
|
116
|
+
})();
|
|
117
|
+
`.trim();
|
|
118
|
+
compilation.emitAsset('vista-client-manifest.js', new webpack_1.default.sources.RawSource(manifestSource));
|
|
119
|
+
// Also emit as JSON for debugging
|
|
120
|
+
if (this.dev) {
|
|
121
|
+
compilation.emitAsset('vista-client-manifest.json', new webpack_1.default.sources.RawSource(JSON.stringify(manifest, null, 2)));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.VistaFlightPlugin = VistaFlightPlugin;
|
|
126
|
+
// Export plugin state for other modules to access
|
|
127
|
+
function getClientModules() {
|
|
128
|
+
return pluginState.clientModules;
|
|
129
|
+
}
|
|
130
|
+
function isClientModule(resourcePath) {
|
|
131
|
+
return pluginState.clientModules.has(resourcePath);
|
|
132
|
+
}
|
|
133
|
+
exports.default = VistaFlightPlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vista Dynamic Import
|
|
3
|
+
*
|
|
4
|
+
* Dynamic component loading with SSR support.
|
|
5
|
+
* Similar to Next.js dynamic.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
export interface DynamicOptions<P = {}> {
|
|
9
|
+
/**
|
|
10
|
+
* Loading component to show while the dynamic component is loading
|
|
11
|
+
*/
|
|
12
|
+
loading?: () => React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to disable SSR for this component
|
|
15
|
+
*/
|
|
16
|
+
ssr?: boolean;
|
|
17
|
+
}
|
|
18
|
+
type ImportFn<P> = () => Promise<{
|
|
19
|
+
default: React.ComponentType<P>;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Dynamically import a component with loading state
|
|
23
|
+
*/
|
|
24
|
+
export default function dynamic<P = {}>(importFn: ImportFn<P>, options?: DynamicOptions<P>): React.ComponentType<P>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vista Dynamic Import
|
|
3
|
+
*
|
|
4
|
+
* Dynamic component loading with SSR support.
|
|
5
|
+
* Similar to Next.js dynamic.
|
|
6
|
+
*/
|
|
7
|
+
'client load';
|
|
8
|
+
"use strict";
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.default = dynamic;
|
|
44
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
45
|
+
const React = __importStar(require("react"));
|
|
46
|
+
/**
|
|
47
|
+
* Dynamically import a component with loading state
|
|
48
|
+
*/
|
|
49
|
+
function dynamic(importFn, options = {}) {
|
|
50
|
+
const { loading: LoadingComponent, ssr = true } = options;
|
|
51
|
+
// Use React.lazy for dynamic import
|
|
52
|
+
const LazyComponent = React.lazy(importFn);
|
|
53
|
+
// Wrapper component
|
|
54
|
+
const DynamicComponent = (props) => {
|
|
55
|
+
// Handle SSR disabled
|
|
56
|
+
const [isClient, setIsClient] = React.useState(false);
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
setIsClient(true);
|
|
59
|
+
}, []);
|
|
60
|
+
if (!ssr && !isClient) {
|
|
61
|
+
return LoadingComponent ? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: LoadingComponent() }) : null;
|
|
62
|
+
}
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(React.Suspense, { fallback: LoadingComponent ? LoadingComponent() : null, children: (0, jsx_runtime_1.jsx)(LazyComponent, { ...props }) }));
|
|
64
|
+
};
|
|
65
|
+
// Preserve display name for debugging
|
|
66
|
+
DynamicComponent.displayName = `Dynamic(${importFn.name || 'Component'})`;
|
|
67
|
+
return DynamicComponent;
|
|
68
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vista Font Optimization
|
|
3
|
+
*
|
|
4
|
+
* Provides optimized font loading similar to Next.js font system.
|
|
5
|
+
* Supports Google Fonts and local fonts with:
|
|
6
|
+
* - Automatic font-display: swap
|
|
7
|
+
* - Preloading of font files
|
|
8
|
+
* - CSS variable generation
|
|
9
|
+
* - Subset support
|
|
10
|
+
*/
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
type FontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | 'variable';
|
|
13
|
+
type FontStyle = 'normal' | 'italic';
|
|
14
|
+
type FontDisplay = 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
15
|
+
export interface GoogleFontOptions {
|
|
16
|
+
weight?: FontWeight | FontWeight[];
|
|
17
|
+
style?: FontStyle | FontStyle[];
|
|
18
|
+
subsets?: string[];
|
|
19
|
+
display?: FontDisplay;
|
|
20
|
+
preload?: boolean;
|
|
21
|
+
fallback?: string[];
|
|
22
|
+
adjustFontFallback?: boolean;
|
|
23
|
+
variable?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface LocalFontOptions {
|
|
26
|
+
src: string | FontSource[];
|
|
27
|
+
weight?: FontWeight | string;
|
|
28
|
+
style?: FontStyle;
|
|
29
|
+
display?: FontDisplay;
|
|
30
|
+
preload?: boolean;
|
|
31
|
+
fallback?: string[];
|
|
32
|
+
variable?: string;
|
|
33
|
+
declarations?: FontFaceDeclaration[];
|
|
34
|
+
}
|
|
35
|
+
export interface FontSource {
|
|
36
|
+
path: string;
|
|
37
|
+
weight?: FontWeight | string;
|
|
38
|
+
style?: FontStyle;
|
|
39
|
+
}
|
|
40
|
+
export interface FontFaceDeclaration {
|
|
41
|
+
prop: string;
|
|
42
|
+
value: string;
|
|
43
|
+
}
|
|
44
|
+
export interface FontResult {
|
|
45
|
+
className: string;
|
|
46
|
+
style: {
|
|
47
|
+
fontFamily: string;
|
|
48
|
+
};
|
|
49
|
+
variable?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a Google Font loader
|
|
53
|
+
*/
|
|
54
|
+
export declare function createGoogleFont(fontFamily: string, options?: GoogleFontOptions): FontResult;
|
|
55
|
+
/**
|
|
56
|
+
* Create a local font loader
|
|
57
|
+
*/
|
|
58
|
+
export declare function createLocalFont(options: LocalFontOptions): FontResult;
|
|
59
|
+
export declare const Inter: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
60
|
+
export declare const Roboto: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
61
|
+
export declare const Open_Sans: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
62
|
+
export declare const Lato: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
63
|
+
export declare const Montserrat: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
64
|
+
export declare const Poppins: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
65
|
+
export declare const Roboto_Mono: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
66
|
+
export declare const Source_Code_Pro: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
67
|
+
export declare const JetBrains_Mono: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
68
|
+
export declare const Playfair_Display: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
69
|
+
export declare const Merriweather: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
70
|
+
export declare const Outfit: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
71
|
+
export declare const Space_Grotesk: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
72
|
+
/**
|
|
73
|
+
* FontProvider component - injects font styles
|
|
74
|
+
*/
|
|
75
|
+
interface FontProviderProps {
|
|
76
|
+
fonts: FontResult[];
|
|
77
|
+
children: React.ReactNode;
|
|
78
|
+
}
|
|
79
|
+
export declare function FontProvider({ fonts, children }: FontProviderProps): React.ReactElement;
|
|
80
|
+
export declare const localFont: typeof createLocalFont;
|
|
81
|
+
declare const _default: {
|
|
82
|
+
Inter: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
83
|
+
Roboto: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
84
|
+
Open_Sans: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
85
|
+
Lato: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
86
|
+
Montserrat: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
87
|
+
Poppins: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
88
|
+
Roboto_Mono: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
89
|
+
Source_Code_Pro: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
90
|
+
JetBrains_Mono: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
91
|
+
Playfair_Display: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
92
|
+
Merriweather: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
93
|
+
Outfit: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
94
|
+
Space_Grotesk: (options?: Omit<GoogleFontOptions, "fallback">) => FontResult;
|
|
95
|
+
localFont: typeof createLocalFont;
|
|
96
|
+
FontProvider: typeof FontProvider;
|
|
97
|
+
};
|
|
98
|
+
export default _default;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.localFont = exports.Space_Grotesk = exports.Outfit = exports.Merriweather = exports.Playfair_Display = exports.JetBrains_Mono = exports.Source_Code_Pro = exports.Roboto_Mono = exports.Poppins = exports.Montserrat = exports.Lato = exports.Open_Sans = exports.Roboto = exports.Inter = void 0;
|
|
4
|
+
exports.createGoogleFont = createGoogleFont;
|
|
5
|
+
exports.createLocalFont = createLocalFont;
|
|
6
|
+
exports.FontProvider = FontProvider;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
// Generate unique class name
|
|
9
|
+
function generateClassName(name) {
|
|
10
|
+
const hash = name.split('').reduce((acc, char) => {
|
|
11
|
+
return ((acc << 5) - acc + char.charCodeAt(0)) | 0;
|
|
12
|
+
}, 0);
|
|
13
|
+
return `__font_${Math.abs(hash).toString(36)}`;
|
|
14
|
+
}
|
|
15
|
+
// Google Fonts base URL
|
|
16
|
+
const GOOGLE_FONTS_URL = 'https://fonts.googleapis.com/css2';
|
|
17
|
+
/**
|
|
18
|
+
* Create a Google Font loader
|
|
19
|
+
*/
|
|
20
|
+
function createGoogleFont(fontFamily, options = {}) {
|
|
21
|
+
const { weight = 400, style = 'normal', subsets = ['latin'], display = 'swap', fallback = ['system-ui', 'sans-serif'], variable, } = options;
|
|
22
|
+
const className = generateClassName(fontFamily);
|
|
23
|
+
const weights = Array.isArray(weight) ? weight : [weight];
|
|
24
|
+
const styles = Array.isArray(style) ? style : [style];
|
|
25
|
+
// Build font family string with fallbacks
|
|
26
|
+
const fontFamilyValue = `'${fontFamily}', ${fallback.join(', ')}`;
|
|
27
|
+
// Generate CSS for injection
|
|
28
|
+
const cssVariableName = variable || `--font-${fontFamily.toLowerCase().replace(/\s+/g, '-')}`;
|
|
29
|
+
// In a real implementation, this would inject a <link> tag or fetch the CSS
|
|
30
|
+
// For now, we return the configuration for the build system to handle
|
|
31
|
+
return {
|
|
32
|
+
className,
|
|
33
|
+
style: { fontFamily: fontFamilyValue },
|
|
34
|
+
variable: cssVariableName,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a local font loader
|
|
39
|
+
*/
|
|
40
|
+
function createLocalFont(options) {
|
|
41
|
+
const { src, weight = 400, style = 'normal', display = 'swap', fallback = ['system-ui', 'sans-serif'], variable, declarations = [], } = options;
|
|
42
|
+
const sources = Array.isArray(src) ? src : [{ path: src, weight, style }];
|
|
43
|
+
const fontName = `LocalFont_${Date.now().toString(36)}`;
|
|
44
|
+
const className = generateClassName(fontName);
|
|
45
|
+
const fontFamilyValue = `'${fontName}', ${fallback.join(', ')}`;
|
|
46
|
+
const cssVariableName = variable || `--font-local-${className}`;
|
|
47
|
+
return {
|
|
48
|
+
className,
|
|
49
|
+
style: { fontFamily: fontFamilyValue },
|
|
50
|
+
variable: cssVariableName,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Pre-configured Google Fonts (like Next.js)
|
|
54
|
+
const Inter = (options) => createGoogleFont('Inter', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
55
|
+
exports.Inter = Inter;
|
|
56
|
+
const Roboto = (options) => createGoogleFont('Roboto', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
57
|
+
exports.Roboto = Roboto;
|
|
58
|
+
const Open_Sans = (options) => createGoogleFont('Open Sans', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
59
|
+
exports.Open_Sans = Open_Sans;
|
|
60
|
+
const Lato = (options) => createGoogleFont('Lato', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
61
|
+
exports.Lato = Lato;
|
|
62
|
+
const Montserrat = (options) => createGoogleFont('Montserrat', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
63
|
+
exports.Montserrat = Montserrat;
|
|
64
|
+
const Poppins = (options) => createGoogleFont('Poppins', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
65
|
+
exports.Poppins = Poppins;
|
|
66
|
+
const Roboto_Mono = (options) => createGoogleFont('Roboto Mono', { ...options, fallback: ['monospace'] });
|
|
67
|
+
exports.Roboto_Mono = Roboto_Mono;
|
|
68
|
+
const Source_Code_Pro = (options) => createGoogleFont('Source Code Pro', { ...options, fallback: ['monospace'] });
|
|
69
|
+
exports.Source_Code_Pro = Source_Code_Pro;
|
|
70
|
+
const JetBrains_Mono = (options) => createGoogleFont('JetBrains Mono', { ...options, fallback: ['monospace'] });
|
|
71
|
+
exports.JetBrains_Mono = JetBrains_Mono;
|
|
72
|
+
const Playfair_Display = (options) => createGoogleFont('Playfair Display', { ...options, fallback: ['serif'] });
|
|
73
|
+
exports.Playfair_Display = Playfair_Display;
|
|
74
|
+
const Merriweather = (options) => createGoogleFont('Merriweather', { ...options, fallback: ['serif'] });
|
|
75
|
+
exports.Merriweather = Merriweather;
|
|
76
|
+
const Outfit = (options) => createGoogleFont('Outfit', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
77
|
+
exports.Outfit = Outfit;
|
|
78
|
+
const Space_Grotesk = (options) => createGoogleFont('Space Grotesk', { ...options, fallback: ['system-ui', 'sans-serif'] });
|
|
79
|
+
exports.Space_Grotesk = Space_Grotesk;
|
|
80
|
+
function FontProvider({ fonts, children }) {
|
|
81
|
+
// Generate CSS for fonts
|
|
82
|
+
const fontCSS = fonts.map(font => {
|
|
83
|
+
if (font.variable) {
|
|
84
|
+
return `:root { ${font.variable}: ${font.style.fontFamily}; }`;
|
|
85
|
+
}
|
|
86
|
+
return '';
|
|
87
|
+
}).filter(Boolean).join('\n');
|
|
88
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [fontCSS && ((0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: fontCSS } })), children] }));
|
|
89
|
+
}
|
|
90
|
+
// Local font helper
|
|
91
|
+
exports.localFont = createLocalFont;
|
|
92
|
+
// Default export
|
|
93
|
+
exports.default = {
|
|
94
|
+
Inter: exports.Inter,
|
|
95
|
+
Roboto: exports.Roboto,
|
|
96
|
+
Open_Sans: exports.Open_Sans,
|
|
97
|
+
Lato: exports.Lato,
|
|
98
|
+
Montserrat: exports.Montserrat,
|
|
99
|
+
Poppins: exports.Poppins,
|
|
100
|
+
Roboto_Mono: exports.Roboto_Mono,
|
|
101
|
+
Source_Code_Pro: exports.Source_Code_Pro,
|
|
102
|
+
JetBrains_Mono: exports.JetBrains_Mono,
|
|
103
|
+
Playfair_Display: exports.Playfair_Display,
|
|
104
|
+
Merriweather: exports.Merriweather,
|
|
105
|
+
Outfit: exports.Outfit,
|
|
106
|
+
Space_Grotesk: exports.Space_Grotesk,
|
|
107
|
+
localFont: exports.localFont,
|
|
108
|
+
FontProvider,
|
|
109
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vista Head Component
|
|
3
|
+
*
|
|
4
|
+
* Allows injection of elements into the document <head>.
|
|
5
|
+
* Similar to Next.js Head component.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
interface HeadProps {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Head component - injects children into document head
|
|
13
|
+
*/
|
|
14
|
+
export declare function Head({ children }: HeadProps): null;
|
|
15
|
+
/**
|
|
16
|
+
* Default metadata configuration
|
|
17
|
+
*/
|
|
18
|
+
export interface Metadata {
|
|
19
|
+
title?: string | {
|
|
20
|
+
default: string;
|
|
21
|
+
template?: string;
|
|
22
|
+
};
|
|
23
|
+
description?: string;
|
|
24
|
+
keywords?: string | string[];
|
|
25
|
+
authors?: {
|
|
26
|
+
name: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
}[];
|
|
29
|
+
creator?: string;
|
|
30
|
+
publisher?: string;
|
|
31
|
+
robots?: string | {
|
|
32
|
+
index?: boolean;
|
|
33
|
+
follow?: boolean;
|
|
34
|
+
};
|
|
35
|
+
icons?: {
|
|
36
|
+
icon?: string;
|
|
37
|
+
apple?: string;
|
|
38
|
+
};
|
|
39
|
+
openGraph?: {
|
|
40
|
+
title?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
url?: string;
|
|
43
|
+
siteName?: string;
|
|
44
|
+
images?: {
|
|
45
|
+
url: string;
|
|
46
|
+
width?: number;
|
|
47
|
+
height?: number;
|
|
48
|
+
alt?: string;
|
|
49
|
+
}[];
|
|
50
|
+
locale?: string;
|
|
51
|
+
type?: string;
|
|
52
|
+
};
|
|
53
|
+
twitter?: {
|
|
54
|
+
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
55
|
+
site?: string;
|
|
56
|
+
creator?: string;
|
|
57
|
+
title?: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
images?: string[];
|
|
60
|
+
};
|
|
61
|
+
viewport?: string | {
|
|
62
|
+
width?: string;
|
|
63
|
+
initialScale?: number;
|
|
64
|
+
};
|
|
65
|
+
themeColor?: string | {
|
|
66
|
+
media?: string;
|
|
67
|
+
color: string;
|
|
68
|
+
}[];
|
|
69
|
+
manifest?: string;
|
|
70
|
+
alternates?: {
|
|
71
|
+
canonical?: string;
|
|
72
|
+
languages?: Record<string, string>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Generate head elements from metadata object
|
|
77
|
+
*/
|
|
78
|
+
export declare function generateMetadataHead(metadata: Metadata): React.ReactElement;
|
|
79
|
+
export default Head;
|