cancellazione modifiche dopo step before oauth

This commit is contained in:
2026-06-16 21:43:24 +02:00
parent 6001c2e3b8
commit c333bbce4e
5770 changed files with 677814 additions and 16 deletions
+7
View File
@@ -0,0 +1,7 @@
export declare function resolveCacheDir(projectRoot: string, cacheDir?: string): string;
export declare function cacheKey(input: string): string;
export declare function readCache(cacheDir: string, key: string): Buffer | undefined;
export declare function readCacheText(cacheDir: string, key: string): string | undefined;
export declare function writeCache(cacheDir: string, key: string, data: Buffer | string): void;
export declare function fetchAndCache(url: string, cacheDir: string, headers?: Record<string, string>): Promise<Buffer>;
export declare function fetchTextAndCache(url: string, cacheDir: string, headers?: Record<string, string>): Promise<string>;
+26
View File
@@ -0,0 +1,26 @@
import type { BaseFontOptions, FontDefinition, FontFormat, FontProviderType, FontStyle, FontWeight, FormatConfig, LocalVariantDefinition, ResolvedFontFamily, ResolvedFontVariant } from './types.js';
export declare const FORMATS: FormatConfig[];
export declare function inferWeightFromFilename(filePath: string): FontWeight;
export declare function inferStyleFromFilename(filePath: string): FontStyle;
export declare function inferLocalVariantFromFilename(filePath: string): {
weight: FontWeight;
style: FontStyle;
};
export declare function looksLikeVariableFontFilename(filePath: string): boolean;
export declare function resolveLocalShorthandVariants(definition: FontDefinition, localConfig: {
src: string;
}, projectRoot: string): Promise<ResolvedFontVariant[]>;
export declare function familyToVariable(family: string): string;
export declare function familyToSlug(family: string): string;
export declare function aliasToVariable(alias: string): string;
export declare function buildFontDefinition(family: string, provider: FontProviderType, options?: BaseFontOptions, extra?: Partial<FontDefinition>): FontDefinition;
export declare function buildResolvedFamily(definition: FontDefinition, variants: ResolvedFontVariant[]): ResolvedFontFamily;
export declare function inferFormat(filePath: string): FontFormat;
export declare function validateFontDefinition(definition: FontDefinition): void;
export declare function mergeFontDefinitions(fonts: FontDefinition[]): FontDefinition[];
export declare function validateFontsConfig(fonts: FontDefinition[]): FontDefinition[];
export declare function resolveLocalExplicitVariants(definition: FontDefinition, localConfig: {
variants: LocalVariantDefinition[];
}, projectRoot: string): ResolvedFontVariant[];
export declare function resolveLocalVariants(definition: FontDefinition, projectRoot: string): Promise<ResolvedFontVariant[]>;
export declare function resolveLocalFont(definition: FontDefinition, projectRoot: string): Promise<ResolvedFontFamily>;
+2
View File
@@ -0,0 +1,2 @@
import type { ParsedFontFace } from './types.js';
export declare function parseFontFaceCss(css: string): ParsedFontFace[];
+18
View File
@@ -0,0 +1,18 @@
import type { ResolvedFontFamily, FallbackMetrics } from './types.js';
export declare function generateFontFace(family: ResolvedFontFamily, filePathMap: Map<string, string>): string;
export declare function generateFallbackFontFace(fallbackFamily: string, metrics: FallbackMetrics): string;
export declare function generateFontClassForFamily(family: ResolvedFontFamily): string;
export declare function generateFontClasses(families: ResolvedFontFamily[]): string;
export declare function generateCssVariables(families: ResolvedFontFamily[]): string;
export declare function generateCssVariablesMap(families: ResolvedFontFamily[]): Record<string, string>;
export declare function generateFamilyStyles(families: ResolvedFontFamily[], filePathMap: Map<string, string>, fallbackMap?: Map<string, {
fallbackFamily: string;
metrics: FallbackMetrics;
}>): {
familyStyles: Record<string, string>;
variables: Record<string, string>;
};
export declare function generateFontCss(families: ResolvedFontFamily[], filePathMap: Map<string, string>, fallbackMap?: Map<string, {
fallbackFamily: string;
metrics: FallbackMetrics;
}>): string;
+7
View File
@@ -0,0 +1,7 @@
import type { IncomingMessage, ServerResponse } from 'http';
import type { ResolvedFontFamily } from './types.js';
export declare function buildDevUrlMap(families: ResolvedFontFamily[], devServerUrl: string): Map<string, string>;
export declare function createFontMiddleware(): {
middleware: (req: IncomingMessage, res: ServerResponse, next: () => void) => void;
update: (families: ResolvedFontFamily[]) => void;
};
+2
View File
@@ -0,0 +1,2 @@
import type { FallbackMetrics } from './types.js';
export declare function generateFallbackMetrics(fontSource: string): Promise<FallbackMetrics | undefined>;
+2
View File
@@ -0,0 +1,2 @@
export { local, google, bunny, fontsource } from './providers/providers.js';
export type { FontDefinition, BaseFontOptions, LocalFontOptions, LocalVariantDefinition, RemoteFontOptions, FontsourceFontOptions, PreloadSelector, FontProviderType, FontFormat, FontStyle, RemoteFontStyle, FontWeight, FontDisplay, FontManifest, FontManifestPreload, FontManifestFamily, FontManifestVariant, FontManifestVariantFile, ResolvedFontFamily, ResolvedFontVariant, ResolvedFontFile, FallbackMetrics, ParsedFontFace, ParsedFontSrc, } from './types.js';
+80
View File
@@ -0,0 +1,80 @@
// src/fonts/config.ts
var FORMATS = [
{
type: "woff2",
extension: ".woff2"
},
{
type: "woff",
extension: ".woff"
},
{
type: "ttf",
extension: ".ttf"
},
{
type: "otf",
extension: ".otf"
},
{
type: "eot",
extension: ".eot"
}
];
var FORMAT_PREFERENCE = FORMATS.map((f) => f.type);
var FORMAT_MAP = Object.fromEntries(
FORMATS.map((f) => [f.extension, f.type])
);
var SUPPORTED_EXTENSIONS = FORMATS.map((f) => f.extension);
var SUPPORTED_GLOB = `*.{${SUPPORTED_EXTENSIONS.map((ext) => ext.slice(1)).join(",")}}`;
function familyToSlug(family) {
return family.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
}
function aliasToVariable(alias) {
return "--font-" + alias;
}
function buildFontDefinition(family, provider, options, extra) {
const alias = options?.alias ?? familyToSlug(family);
return {
family,
alias,
provider,
variable: options?.variable ?? aliasToVariable(alias),
weights: options?.weights ? [...options.weights] : [400],
styles: options?.styles ?? ["normal"],
subsets: options?.subsets ?? ["latin"],
display: options?.display ?? "swap",
preload: options?.preload ?? true,
fallbacks: options?.fallbacks ?? [],
optimizedFallbacks: options?.optimizedFallbacks ?? true,
...extra
};
}
// src/fonts/providers/providers.ts
function google(family, options) {
return buildFontDefinition(family, "google", options);
}
function bunny(family, options) {
return buildFontDefinition(family, "bunny", options);
}
function fontsource(family, options) {
return buildFontDefinition(family, "fontsource", options, {
_fontsource: { package: options?.package }
});
}
function local(family, options) {
const _local = "src" in options && options.src !== void 0 ? { src: options.src } : { variants: options.variants };
return buildFontDefinition(family, "local", options, {
weights: [],
styles: [],
subsets: [],
_local
});
}
export {
bunny,
fontsource,
google,
local
};
+3
View File
@@ -0,0 +1,3 @@
import type { FontManifest, ResolvedFontFamily } from './types.js';
export declare function buildManifest(families: ResolvedFontFamily[], cssFile: string, filePathMap: Map<string, string>, familyStyles: Record<string, string>, variables: Record<string, string>): FontManifest;
export declare function buildDevManifest(families: ResolvedFontFamily[], inlineCss: string, urlMap: Map<string, string>, familyStyles: Record<string, string>, variables: Record<string, string>): FontManifest;
+5
View File
@@ -0,0 +1,5 @@
import type { Plugin } from 'vite';
import type { FontDefinition, ResolvedFontFamily } from './types.js';
/** @internal Exported for tests; not part of the public plugin API. */
export declare function assertFileRefsResolved(families: ResolvedFontFamily[], fileRefMap: Map<string, string>): void;
export declare function resolveFontsPlugin(fonts: FontDefinition[] | undefined, hotFile: string, buildDirectory: string): Plugin[];
+5
View File
@@ -0,0 +1,5 @@
import type { FontDefinition, FontWeight, RemoteFontOptions, FontsourceFontOptions, LocalFontOptions } from '../types.js';
export declare function google<const W extends FontWeight = FontWeight>(family: string, options?: RemoteFontOptions<W>): FontDefinition;
export declare function bunny<const W extends FontWeight = FontWeight>(family: string, options?: RemoteFontOptions<W>): FontDefinition;
export declare function fontsource<const W extends FontWeight = FontWeight>(family: string, options?: FontsourceFontOptions<W>): FontDefinition;
export declare function local(family: string, options: LocalFontOptions): FontDefinition;
@@ -0,0 +1,3 @@
import type { FontDefinition, ResolvedFontFamily, ResolvedFontVariant } from '../types.js';
export declare function resolveFontsourceVariants(definition: FontDefinition, projectRoot: string): ResolvedFontVariant[];
export declare function resolveFontsourceFont(definition: FontDefinition, projectRoot: string): ResolvedFontFamily;
@@ -0,0 +1,4 @@
import type { FontDefinition, ResolvedFontFamily, ResolvedFontVariant } from '../types.js';
export declare function buildCss2Url(baseUrl: string, definition: FontDefinition): string;
export declare function resolveRemoteVariants(definition: FontDefinition, cacheDir: string, baseUrl: string): Promise<ResolvedFontVariant[]>;
export declare function resolveRemoteFont(definition: FontDefinition, cacheDir: string, baseUrl: string): Promise<ResolvedFontFamily>;
+195
View File
@@ -0,0 +1,195 @@
export type FormatConfig = {
extension: string;
type: FontFormat;
};
export type FontProviderType = 'local' | 'google' | 'bunny' | 'fontsource';
export type FontFormat = 'woff2' | 'woff' | 'ttf' | 'otf' | 'eot';
export type FontStyle = 'normal' | 'italic' | 'oblique';
/**
* Subset of FontStyle supported by remote providers (Google, Bunny, Fontsource).
* The CSS2 / Fontsource APIs do not expose `oblique`.
*/
export type RemoteFontStyle = 'normal' | 'italic';
export type FontWeight = number | string;
export type FontDisplay = 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
export type PreloadSelector<W extends FontWeight = FontWeight> = {
weight: W;
/** @default 'normal' */
style?: FontStyle;
};
export type BaseFontOptions<W extends FontWeight = FontWeight> = {
/**
* Used to reference font with `@fonts` Blade directive or programatically.
* Defaults to a slug of the family name.
*/
alias?: string;
/** Defaults to `--font-{alias}`. */
variable?: string;
/** @default [400] */
weights?: readonly W[];
/** @default ['normal'] */
styles?: FontStyle[];
/** @default ['latin'] */
subsets?: string[];
/** @default 'swap' */
display?: FontDisplay;
/**
* - `true`: preload all WOFF2 variants (default)
* - `false`: do not preload
* - `[{ weight, style }]`: preload only matching variants.
* When `weights` is a literal tuple, preload weights are type-narrowed
* to its members.
*
* @default true
*/
preload?: boolean | PreloadSelector<NoInfer<W>>[];
/** @default [] */
fallbacks?: string[];
/**
* Generate metric-optimized fallback font faces using fontaine.
*
* @default true
*/
optimizedFallbacks?: boolean;
};
export type LocalVariantDefinition = {
/** Path(s) relative to the project root. */
src: string | string[];
/** When omitted, inferred from filename. Defaults to 400 if no token found. */
weight?: FontWeight;
/** @default 'normal' — inferred from filename when omitted. */
style?: FontStyle;
};
export type LocalFontOptions = Omit<BaseFontOptions, 'weights' | 'styles' | 'subsets'> & ({
/** Explicit list of font variants. Mutually exclusive with `src`. */
variants: LocalVariantDefinition[];
src?: never;
} | {
/**
* Shorthand: a file path, directory, or glob pattern.
* Mutually exclusive with `variants`.
*/
src: string;
variants?: never;
});
export type RemoteFontOptions<W extends FontWeight = FontWeight> = Omit<BaseFontOptions<W>, 'styles'> & {
/** @default ['normal'] */
styles?: RemoteFontStyle[];
};
export type FontsourceFontOptions<W extends FontWeight = FontWeight> = Omit<BaseFontOptions<W>, 'styles'> & {
/** @default ['normal'] */
styles?: RemoteFontStyle[];
/** Defaults to `@fontsource/{family-slug}`. */
package?: string;
};
export type FontDefinition = {
family: string;
alias: string;
provider: FontProviderType;
variable: string;
weights: FontWeight[];
styles: FontStyle[];
subsets: string[];
display: FontDisplay;
preload: boolean | PreloadSelector[];
fallbacks: string[];
optimizedFallbacks: boolean;
/** @internal */
_local?: {
variants: LocalVariantDefinition[];
} | {
src: string;
};
/** @internal */
_fontsource?: {
package?: string;
};
};
export type ResolvedFontVariant = {
weight: FontWeight;
style: FontStyle;
files: ResolvedFontFile[];
};
export type ResolvedFontFile = {
source: string;
format: FontFormat;
unicodeRange?: string;
};
export type ResolvedFontFamily = {
family: string;
alias: string;
variable: string;
display: FontDisplay;
optimizedFallbacks: boolean;
fallbacks: string[];
preload: boolean | PreloadSelector[];
provider: FontProviderType;
variants: ResolvedFontVariant[];
};
export type FontManifest = {
version: 1;
style: {
file?: string;
inline?: string;
familyStyles: Record<string, string>;
variables: Record<string, string>;
};
preloads: FontManifestPreload[];
families: Record<string, FontManifestFamily>;
};
export type FontManifestPreload = {
alias: string;
family: string;
weight: FontWeight;
style: FontStyle;
file?: string;
url?: string;
as: 'font';
type: string;
crossorigin: 'anonymous';
};
export type FontManifestFamily = {
family: string;
variable: string;
fallbackFamily?: string;
fallbacks?: string[];
variants: Record<string, FontManifestVariant>;
};
export type FontManifestVariant = {
files: FontManifestVariantFile[];
};
export type FontManifestVariantFile = {
file?: string;
url?: string;
format: FontFormat;
unicodeRange?: string;
};
export type FallbackMetrics = {
localFont: string;
ascentOverride: string;
descentOverride: string;
lineGapOverride: string;
sizeAdjust: string;
};
export type FallbackCategory = 'sans-serif' | 'serif' | 'monospace';
export type FallbackEntry = {
localFont: string;
ascent: number;
descent: number;
lineGap: number;
unitsPerEm: number;
xWidthAvg: number;
};
export type ParsedFontFace = {
family: string;
style: FontStyle;
weight: FontWeight;
src: ParsedFontSrc[];
unicodeRange?: string;
display?: string;
};
export type ParsedFontSrc = {
url: string;
format: FontFormat;
};
export declare const FORMAT_MIME: Record<FontFormat, string>;