create project

This commit is contained in:
ismailsosic
2022-12-27 12:05:56 +01:00
parent 2a33a2d3de
commit cd2143287c
16035 changed files with 2489703 additions and 0 deletions

7
kitabcitab/node_modules/@next/font/README.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
# `@next/font`
`@next/font` includes built-in automatic self-hosting for any font file. This means you can optimally load web fonts with zero layout shift, thanks to the underlying CSS size-adjust property used.
This new font system also allows you to conveniently use all Google Fonts with performance and privacy in mind. CSS and font files are downloaded at build time and self-hosted with the rest of your static assets. No requests are sent to Google by the browser.
[Read more](https://beta.nextjs.org/docs/optimizing/fonts)

27733
kitabcitab/node_modules/@next/font/dist/fontkit/index.js generated vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

14825
kitabcitab/node_modules/@next/font/dist/google/index.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,3 @@
import type { FontLoader } from 'next/font';
declare const downloadGoogleFonts: FontLoader;
export default downloadGoogleFonts;

View File

@@ -0,0 +1,181 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
const font_utils_1 = require("next/dist/server/font-utils");
// @ts-ignore
const Log = __importStar(require("next/dist/build/output/log"));
// @ts-ignore
const chalk_1 = __importDefault(require("next/dist/compiled/chalk"));
const utils_1 = require("./utils");
const utils_2 = require("../utils");
const cssCache = new Map();
const fontCache = new Map();
// regexp is based on https://github.com/sindresorhus/escape-string-regexp
const reHasRegExp = /[|\\{}()[\]^$+*?.-]/;
const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g;
function escapeStringRegexp(str) {
// see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23
if (reHasRegExp.test(str)) {
return str.replace(reReplaceRegExp, '\\$&');
}
return str;
}
const downloadGoogleFonts = async ({ functionName, data, config, emitFontFile, isDev, isServer, loaderContext, }) => {
var _a, _b, _c;
const subsets = (config === null || config === void 0 ? void 0 : config.subsets) || [];
const { fontFamily, weights, styles, display, preload, selectedVariableAxes, fallback, adjustFontFallback, variable, subsets: callSubsets, } = (0, utils_1.validateData)(functionName, data);
if (isServer && preload && !callSubsets && !(config === null || config === void 0 ? void 0 : config.subsets)) {
Log.warn(`The ${chalk_1.default.bold('@next/font/google')} font ${chalk_1.default.bold(fontFamily)} has no selected subsets. Please specify subsets in the function call or in your ${chalk_1.default.bold('next.config.js')}, otherwise no fonts will be preloaded. Read more: https://nextjs.org/docs/messages/google-fonts-missing-subsets`);
}
const fontAxes = (0, utils_1.getFontAxes)(fontFamily, weights, styles, selectedVariableAxes);
const url = (0, utils_1.getUrl)(fontFamily, fontAxes, display);
// Find fallback font metrics
let adjustFontFallbackMetrics;
if (adjustFontFallback) {
try {
const { ascent, descent, lineGap, fallbackFont, sizeAdjust } = (0, font_utils_1.calculateSizeAdjustValues)(require('next/dist/server/google-font-metrics.json')[fontFamily]);
adjustFontFallbackMetrics = {
fallbackFont,
ascentOverride: `${ascent}%`,
descentOverride: `${descent}%`,
lineGapOverride: `${lineGap}%`,
sizeAdjust: `${sizeAdjust}%`,
};
}
catch {
Log.error(`Failed to find font override values for font \`${fontFamily}\``);
}
}
const result = {
fallbackFonts: fallback,
weight: weights.length === 1 && weights[0] !== 'variable'
? weights[0]
: undefined,
style: styles.length === 1 ? styles[0] : undefined,
variable,
adjustFontFallback: adjustFontFallbackMetrics,
};
try {
const hasCachedCSS = cssCache.has(url);
let fontFaceDeclarations = hasCachedCSS
? cssCache.get(url)
: await (0, utils_1.fetchCSSFromGoogleFonts)(url, fontFamily).catch(() => null);
if (!hasCachedCSS) {
cssCache.set(url, fontFaceDeclarations);
}
else {
cssCache.delete(url);
}
if (fontFaceDeclarations === null) {
(0, utils_2.nextFontError)(`Failed to fetch \`${fontFamily}\` from Google Fonts.`);
}
// CSS Variables may be set on a body tag, ignore them to keep the CSS module pure
fontFaceDeclarations = fontFaceDeclarations.split('body {')[0];
// Find font files to download
const fontFiles = [];
let currentSubset = '';
for (const line of fontFaceDeclarations.split('\n')) {
// Each @font-face has the subset above it in a comment
const newSubset = (_a = /\/\* (.+?) \*\//.exec(line)) === null || _a === void 0 ? void 0 : _a[1];
if (newSubset) {
currentSubset = newSubset;
}
else {
const googleFontFileUrl = (_b = /src: url\((.+?)\)/.exec(line)) === null || _b === void 0 ? void 0 : _b[1];
if (googleFontFileUrl &&
!fontFiles.some((foundFile) => foundFile.googleFontFileUrl === googleFontFileUrl)) {
fontFiles.push({
googleFontFileUrl,
preloadFontFile: !!preload && (callSubsets !== null && callSubsets !== void 0 ? callSubsets : subsets).includes(currentSubset),
});
}
}
}
// Download font files
const downloadedFiles = await Promise.all(fontFiles.map(async ({ googleFontFileUrl, preloadFontFile }) => {
const hasCachedFont = fontCache.has(googleFontFileUrl);
const fontFileBuffer = hasCachedFont
? fontCache.get(googleFontFileUrl)
: await (0, utils_1.fetchFontFile)(googleFontFileUrl).catch(() => null);
if (!hasCachedFont) {
fontCache.set(googleFontFileUrl, fontFileBuffer);
}
else {
fontCache.delete(googleFontFileUrl);
}
if (fontFileBuffer === null) {
(0, utils_2.nextFontError)(`Failed to fetch \`${fontFamily}\` from Google Fonts.`);
}
const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(googleFontFileUrl)[1];
// Emit font file to .next/static/media
const selfHostedFileUrl = emitFontFile(fontFileBuffer, ext, preloadFontFile);
return {
googleFontFileUrl,
selfHostedFileUrl,
};
}));
// Replace @font-face sources with self-hosted files
let updatedCssResponse = fontFaceDeclarations;
for (const { googleFontFileUrl, selfHostedFileUrl } of downloadedFiles) {
updatedCssResponse = updatedCssResponse.replace(new RegExp(escapeStringRegexp(googleFontFileUrl), 'g'), selfHostedFileUrl);
}
return {
...result,
css: updatedCssResponse,
};
}
catch (err) {
loaderContext.cacheable(false);
if (isDev) {
if (isServer) {
Log.error(`Failed to download \`${fontFamily}\` from Google Fonts. Using fallback font instead.`);
}
// In dev we should return the fallback font instead of throwing an error
let css = `@font-face {
font-family: '${fontFamily} Fallback';
src: local("${(_c = adjustFontFallbackMetrics === null || adjustFontFallbackMetrics === void 0 ? void 0 : adjustFontFallbackMetrics.fallbackFont) !== null && _c !== void 0 ? _c : 'Arial'}");`;
if (adjustFontFallbackMetrics) {
css += `
ascent-override:${adjustFontFallbackMetrics.ascentOverride};
descent-override:${adjustFontFallbackMetrics.descentOverride};
line-gap-override:${adjustFontFallbackMetrics.lineGapOverride};
size-adjust:${adjustFontFallbackMetrics.sizeAdjust};`;
}
css += '\n}';
return {
...result,
css,
};
}
else {
throw err;
}
}
};
exports.default = downloadGoogleFonts;

View File

@@ -0,0 +1,27 @@
/// <reference types="node" />
declare type FontOptions = {
fontFamily: string;
weights: string[];
styles: string[];
display: string;
preload: boolean;
selectedVariableAxes?: string[];
fallback?: string[];
adjustFontFallback: boolean;
variable?: string;
subsets?: string[];
};
export declare function validateData(functionName: string, data: any): FontOptions;
export declare function getUrl(fontFamily: string, axes: {
wght?: string[];
ital?: string[];
variableAxes?: [string, string][];
}, display: string): string;
export declare function fetchCSSFromGoogleFonts(url: string, fontFamily: string): Promise<any>;
export declare function fetchFontFile(url: string): Promise<Buffer>;
export declare function getFontAxes(fontFamily: string, weights: string[], styles: string[], selectedVariableAxes?: string[]): {
wght?: string[];
ital?: string[];
variableAxes?: [string, string][];
};
export {};

219
kitabcitab/node_modules/@next/font/dist/google/utils.js generated vendored Normal file
View File

@@ -0,0 +1,219 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFontAxes = exports.fetchFontFile = exports.fetchCSSFromGoogleFonts = exports.getUrl = exports.validateData = void 0;
const fs_1 = __importDefault(require("fs"));
// @ts-ignore
const node_fetch_1 = __importDefault(require("next/dist/compiled/node-fetch"));
const utils_1 = require("../utils");
const font_data_json_1 = __importDefault(require("./font-data.json"));
const allowedDisplayValues = ['auto', 'block', 'swap', 'fallback', 'optional'];
const formatValues = (values) => values.map((val) => `\`${val}\``).join(', ');
function validateData(functionName, data) {
let { weight, style, display = 'optional', preload = true, axes, fallback, adjustFontFallback = true, variable, subsets, } = data[0] || {};
if (functionName === '') {
(0, utils_1.nextFontError)(`@next/font/google has no default export`);
}
const fontFamily = functionName.replace(/_/g, ' ');
const fontFamilyData = font_data_json_1.default[fontFamily];
const fontWeights = fontFamilyData === null || fontFamilyData === void 0 ? void 0 : fontFamilyData.weights;
if (!fontWeights) {
(0, utils_1.nextFontError)(`Unknown font \`${fontFamily}\``);
}
const fontStyles = fontFamilyData.styles;
const weights = !weight
? []
: [...new Set(Array.isArray(weight) ? weight : [weight])];
const styles = !style
? []
: [...new Set(Array.isArray(style) ? style : [style])];
if (weights.length === 0) {
// Set variable as default, throw if not available
if (fontWeights.includes('variable')) {
weights.push('variable');
}
else {
(0, utils_1.nextFontError)(`Missing weight for font \`${fontFamily}\`.\nAvailable weights: ${formatValues(fontWeights)}`);
}
}
if (weights.length > 1 && weights.includes('variable')) {
(0, utils_1.nextFontError)(`Unexpected \`variable\` in weight array for font \`${fontFamily}\`. You only need \`variable\`, it includes all available weights.`);
}
weights.forEach((selectedWeight) => {
if (!fontWeights.includes(selectedWeight)) {
(0, utils_1.nextFontError)(`Unknown weight \`${selectedWeight}\` for font \`${fontFamily}\`.\nAvailable weights: ${formatValues(fontWeights)}`);
}
});
if (styles.length === 0) {
if (fontStyles.length === 1) {
styles.push(fontStyles[0]);
}
else {
styles.push('normal');
}
}
styles.forEach((selectedStyle) => {
if (!fontStyles.includes(selectedStyle)) {
(0, utils_1.nextFontError)(`Unknown style \`${selectedStyle}\` for font \`${fontFamily}\`.\nAvailable styles: ${formatValues(fontStyles)}`);
}
});
if (!allowedDisplayValues.includes(display)) {
(0, utils_1.nextFontError)(`Invalid display value \`${display}\` for font \`${fontFamily}\`.\nAvailable display values: ${formatValues(allowedDisplayValues)}`);
}
if (weights[0] !== 'variable' && axes) {
(0, utils_1.nextFontError)('Axes can only be defined for variable fonts');
}
return {
fontFamily,
weights,
styles,
display,
preload,
selectedVariableAxes: axes,
fallback,
adjustFontFallback,
variable,
subsets,
};
}
exports.validateData = validateData;
function getUrl(fontFamily, axes, display) {
var _a, _b;
// Variants are all combinations of weight and style, each variant will result in a separate font file
const variants = [];
if (axes.wght) {
for (const wgth of axes.wght) {
if (!axes.ital) {
variants.push([['wght', wgth], ...((_a = axes.variableAxes) !== null && _a !== void 0 ? _a : [])]);
}
else {
for (const ital of axes.ital) {
variants.push([
['ital', ital],
['wght', wgth],
...((_b = axes.variableAxes) !== null && _b !== void 0 ? _b : []),
]);
}
}
}
}
else if (axes.variableAxes) {
// Variable fonts might not have a range of weights, just add optional variable axes in that case
variants.push([...axes.variableAxes]);
}
// Google api requires the axes to be sorted, starting with lowercase words
if (axes.variableAxes) {
variants.forEach((variant) => {
variant.sort(([a], [b]) => {
const aIsLowercase = a.charCodeAt(0) > 96;
const bIsLowercase = b.charCodeAt(0) > 96;
if (aIsLowercase && !bIsLowercase)
return -1;
if (bIsLowercase && !aIsLowercase)
return 1;
return a > b ? 1 : -1;
});
});
}
let url = `https://fonts.googleapis.com/css2?family=${fontFamily.replace(/ /g, '+')}`;
if (variants.length > 0) {
url = `${url}:${variants[0].map(([key]) => key).join(',')}@${variants
.map((variant) => variant.map(([, val]) => val).join(','))
.sort()
.join(';')}`;
}
url = `${url}&display=${display}`;
return url;
}
exports.getUrl = getUrl;
async function fetchCSSFromGoogleFonts(url, fontFamily) {
let mockedResponse;
if (process.env.NEXT_FONT_GOOGLE_MOCKED_RESPONSES) {
const mockFile = require(process.env.NEXT_FONT_GOOGLE_MOCKED_RESPONSES);
mockedResponse = mockFile[url];
if (!mockedResponse) {
(0, utils_1.nextFontError)('Missing mocked response for URL: ' + url);
}
}
let cssResponse;
if (mockedResponse) {
cssResponse = mockedResponse;
}
else {
const res = await (0, node_fetch_1.default)(url, {
headers: {
// The file format is based off of the user agent, make sure woff2 files are fetched
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36',
},
});
if (!res.ok) {
(0, utils_1.nextFontError)(`Failed to fetch font \`${fontFamily}\`.\nURL: ${url}`);
}
cssResponse = await res.text();
}
return cssResponse;
}
exports.fetchCSSFromGoogleFonts = fetchCSSFromGoogleFonts;
async function fetchFontFile(url) {
if (process.env.NEXT_FONT_GOOGLE_MOCKED_RESPONSES) {
if (url.startsWith('/')) {
return fs_1.default.readFileSync(url);
}
return Buffer.from(url);
}
const arrayBuffer = await (0, node_fetch_1.default)(url).then((r) => r.arrayBuffer());
return Buffer.from(arrayBuffer);
}
exports.fetchFontFile = fetchFontFile;
function getFontAxes(fontFamily, weights, styles, selectedVariableAxes) {
const allAxes = font_data_json_1.default[fontFamily].axes;
const hasItalic = styles.includes('italic');
const hasNormal = styles.includes('normal');
const ital = hasItalic ? [...(hasNormal ? ['0'] : []), '1'] : undefined;
// Weights will always contain one element if it's a variable font
if (weights[0] === 'variable') {
if (selectedVariableAxes) {
const defineAbleAxes = allAxes
.map(({ tag }) => tag)
.filter((tag) => tag !== 'wght');
if (defineAbleAxes.length === 0) {
(0, utils_1.nextFontError)(`Font \`${fontFamily}\` has no definable \`axes\``);
}
if (!Array.isArray(selectedVariableAxes)) {
(0, utils_1.nextFontError)(`Invalid axes value for font \`${fontFamily}\`, expected an array of axes.\nAvailable axes: ${formatValues(defineAbleAxes)}`);
}
selectedVariableAxes.forEach((key) => {
if (!defineAbleAxes.some((tag) => tag === key)) {
(0, utils_1.nextFontError)(`Invalid axes value \`${key}\` for font \`${fontFamily}\`.\nAvailable axes: ${formatValues(defineAbleAxes)}`);
}
});
}
let weightAxis;
let variableAxes;
for (const { tag, min, max } of allAxes) {
if (tag === 'wght') {
weightAxis = `${min}..${max}`;
}
else if (selectedVariableAxes === null || selectedVariableAxes === void 0 ? void 0 : selectedVariableAxes.includes(tag)) {
if (!variableAxes) {
variableAxes = [];
}
variableAxes.push([tag, `${min}..${max}`]);
}
}
return {
wght: weightAxis ? [weightAxis] : undefined,
ital,
variableAxes,
};
}
else {
return {
ital,
wght: weights,
};
}
}
exports.getFontAxes = getFontAxes;

View File

@@ -0,0 +1,21 @@
import type { CssVariable, Display, NextFont, NextFontWithVariable } from '../types';
declare type LocalFont<T extends CssVariable | undefined = undefined> = {
src: string | Array<{
path: string;
weight?: string;
style?: string;
}>;
display?: Display;
weight?: string;
style?: string;
adjustFontFallback?: 'Arial' | 'Times New Roman' | false;
fallback?: string[];
preload?: boolean;
variable?: T;
declarations?: Array<{
prop: string;
value: string;
}>;
};
export default function localFont<T extends CssVariable | undefined = undefined>(options: LocalFont<T>): T extends undefined ? NextFont : NextFontWithVariable;
export {};

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function localFont(options) {
throw new Error();
}
exports.default = localFont;

View File

@@ -0,0 +1,3 @@
import type { FontLoader } from 'next/font';
declare const fetchFonts: FontLoader;
export default fetchFonts;

127
kitabcitab/node_modules/@next/font/dist/local/loader.js generated vendored Normal file
View File

@@ -0,0 +1,127 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
const fontkit_1 = __importDefault(require("@next/font/dist/fontkit"));
const util_1 = require("util");
const utils_1 = require("./utils");
const utils_2 = require("../utils");
const NORMAL_WEIGHT = 400;
const BOLD_WEIGHT = 700;
function getWeightNumber(weight) {
// Weight can be 'normal', 'bold' or a number https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight
return weight === 'normal'
? NORMAL_WEIGHT
: weight === 'bold'
? BOLD_WEIGHT
: Number(weight);
}
function getDistanceFromNormalWeight(weight) {
if (!weight)
return 0;
const [firstWeight, secondWeight] = weight
.trim()
.split(/ +/)
.map(getWeightNumber);
if (Number.isNaN(firstWeight) || Number.isNaN(secondWeight)) {
(0, utils_2.nextFontError)(`Invalid weight value in src array: \`${weight}\`.\nExpected \`normal\`, \`bold\` or a number.`);
}
// Not a variable font
if (!secondWeight) {
return firstWeight - NORMAL_WEIGHT;
}
// Normal weight is within variable font range
if (firstWeight <= NORMAL_WEIGHT && secondWeight >= NORMAL_WEIGHT) {
return 0;
}
// Return the distance of normal weight to the variable font range
const firstWeightDistance = firstWeight - NORMAL_WEIGHT;
const secondWeightDistance = secondWeight - NORMAL_WEIGHT;
if (Math.abs(firstWeightDistance) < Math.abs(secondWeightDistance)) {
return firstWeightDistance;
}
return secondWeightDistance;
}
const fetchFonts = async ({ functionName, variableName, data, emitFontFile, resolve, loaderContext, }) => {
const { src, display, fallback, preload, variable, adjustFontFallback, declarations, weight: defaultWeight, style: defaultStyle, } = (0, utils_1.validateData)(functionName, data[0]);
const fontFiles = await Promise.all(src.map(async ({ path, style, weight, ext, format }) => {
const resolved = await resolve(path);
const fileBuffer = await (0, util_1.promisify)(loaderContext.fs.readFile)(resolved);
const fontUrl = emitFontFile(fileBuffer, ext, preload);
let fontMetadata;
try {
fontMetadata = (0, fontkit_1.default)(fileBuffer);
}
catch (e) {
console.error(`Failed to load font file: ${resolved}\n${e}`);
}
const fontFaceProperties = [
...(declarations
? declarations.map(({ prop, value }) => [prop, value])
: []),
['font-family', variableName],
['src', `url(${fontUrl}) format('${format}')`],
['font-display', display],
...((weight !== null && weight !== void 0 ? weight : defaultWeight)
? [['font-weight', weight !== null && weight !== void 0 ? weight : defaultWeight]]
: []),
...((style !== null && style !== void 0 ? style : defaultStyle)
? [['font-style', style !== null && style !== void 0 ? style : defaultStyle]]
: []),
];
return {
css: `@font-face {
${fontFaceProperties
.map(([property, value]) => `${property}: ${value};`)
.join('\n')}
}\n`,
fontMetadata,
weight,
style,
};
}));
// Add fallback font
let adjustFontFallbackMetrics;
if (adjustFontFallback !== false) {
// Pick the font file to generate a fallback font from.
// Prefer the file closest to normal weight, this will typically make up most of the text on a page.
const fallbackFontFile = fontFiles.reduce((usedFontFile, currentFontFile) => {
if (!usedFontFile)
return currentFontFile;
const usedFontDistance = getDistanceFromNormalWeight(usedFontFile.weight);
const currentFontDistance = getDistanceFromNormalWeight(currentFontFile.weight);
// Prefer normal style if they have the same weight
if (usedFontDistance === currentFontDistance &&
(typeof currentFontFile.style === 'undefined' ||
currentFontFile.style === 'normal')) {
return currentFontFile;
}
const absUsedDistance = Math.abs(usedFontDistance);
const absCurrentDistance = Math.abs(currentFontDistance);
// Use closest absolute distance to normal weight
if (absCurrentDistance < absUsedDistance)
return currentFontFile;
// Prefer the thinner font if both are the same absolute distance from normal weight
if (absUsedDistance === absCurrentDistance &&
currentFontDistance < usedFontDistance) {
return currentFontFile;
}
return usedFontFile;
});
if (fallbackFontFile.fontMetadata) {
adjustFontFallbackMetrics = (0, utils_2.calculateFallbackFontValues)(fallbackFontFile.fontMetadata, adjustFontFallback === 'Times New Roman' ? 'serif' : 'sans-serif');
}
}
return {
css: fontFiles.map(({ css }) => css).join('\n'),
fallbackFonts: fallback,
weight: src.length === 1 ? src[0].weight : undefined,
style: src.length === 1 ? src[0].style : undefined,
variable,
adjustFontFallback: adjustFontFallbackMetrics,
};
};
exports.default = fetchFonts;

View File

@@ -0,0 +1,22 @@
declare type FontOptions = {
src: Array<{
path: string;
weight?: string;
style?: string;
ext: string;
format: string;
}>;
display: string;
weight?: string;
style?: string;
fallback?: string[];
preload: boolean;
variable?: string;
adjustFontFallback?: string | false;
declarations?: Array<{
prop: string;
value: string;
}>;
};
export declare function validateData(functionName: string, fontData: any): FontOptions;
export {};

70
kitabcitab/node_modules/@next/font/dist/local/utils.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateData = void 0;
const utils_1 = require("../utils");
const allowedDisplayValues = ['auto', 'block', 'swap', 'fallback', 'optional'];
const formatValues = (values) => values.map((val) => `\`${val}\``).join(', ');
const extToFormat = {
woff: 'woff',
woff2: 'woff2',
ttf: 'truetype',
otf: 'opentype',
eot: 'embedded-opentype',
};
function validateData(functionName, fontData) {
if (functionName) {
(0, utils_1.nextFontError)(`@next/font/local has no named exports`);
}
let { src, display = 'optional', weight, style, fallback, preload = true, variable, adjustFontFallback, declarations, } = fontData || {};
if (!allowedDisplayValues.includes(display)) {
(0, utils_1.nextFontError)(`Invalid display value \`${display}\`.\nAvailable display values: ${formatValues(allowedDisplayValues)}`);
}
if (!src) {
(0, utils_1.nextFontError)('Missing required `src` property');
}
if (!Array.isArray(src)) {
src = [{ path: src, weight, style }];
}
else {
if (src.length === 0) {
(0, utils_1.nextFontError)('Unexpected empty `src` array.');
}
}
src = src.map((fontFile) => {
var _a;
const ext = (_a = /\.(woff|woff2|eot|ttf|otf)$/.exec(fontFile.path)) === null || _a === void 0 ? void 0 : _a[1];
if (!ext) {
(0, utils_1.nextFontError)(`Unexpected file \`${fontFile.path}\``);
}
return {
...fontFile,
ext,
format: extToFormat[ext],
};
});
if (Array.isArray(declarations)) {
declarations.forEach((declaration) => {
if ([
'font-family',
'src',
'font-display',
'font-weight',
'font-style',
].includes(declaration === null || declaration === void 0 ? void 0 : declaration.prop)) {
(0, utils_1.nextFontError)(`Invalid declaration prop: \`${declaration.prop}\``);
}
});
}
return {
src,
display,
weight,
style,
fallback,
preload,
variable,
adjustFontFallback,
declarations,
};
}
exports.validateData = validateData;

13
kitabcitab/node_modules/@next/font/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
export declare type CssVariable = `--${string}`;
export declare type Display = 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
export declare type NextFont = {
className: string;
style: {
fontFamily: string;
fontWeight?: number;
fontStyle?: string;
};
};
export declare type NextFontWithVariable = NextFont & {
variable: string;
};

2
kitabcitab/node_modules/@next/font/dist/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

4
kitabcitab/node_modules/@next/font/dist/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { Font } from 'fontkit';
import type { AdjustFontFallback } from 'next/font';
export declare function calculateFallbackFontValues(font: Font, category?: string): AdjustFontFallback;
export declare function nextFontError(message: string): never;

59
kitabcitab/node_modules/@next/font/dist/utils.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nextFontError = exports.calculateFallbackFontValues = void 0;
const DEFAULT_SANS_SERIF_FONT = {
name: 'Arial',
azAvgWidth: 934.5116279069767,
unitsPerEm: 2048,
};
const DEFAULT_SERIF_FONT = {
name: 'Times New Roman',
azAvgWidth: 854.3953488372093,
unitsPerEm: 2048,
};
function calcAverageWidth(font) {
try {
const avgCharacters = 'aaabcdeeeefghiijklmnnoopqrrssttuvwxyz ';
const hasAllChars = font
.glyphsForString(avgCharacters)
.flatMap((glyph) => glyph.codePoints)
.every((codePoint) => font.hasGlyphForCodePoint(codePoint));
if (!hasAllChars)
return undefined;
const widths = font
.glyphsForString(avgCharacters)
.map((glyph) => glyph.advanceWidth);
const totalWidth = widths.reduce((sum, width) => sum + width, 0);
return totalWidth / widths.length;
}
catch {
// Could not calculate average width from the font file, skip size-adjust
return undefined;
}
}
function formatOverrideValue(val) {
return Math.abs(val * 100).toFixed(2) + '%';
}
function calculateFallbackFontValues(font, category = 'serif') {
const fallbackFont = category === 'serif' ? DEFAULT_SERIF_FONT : DEFAULT_SANS_SERIF_FONT;
const azAvgWidth = calcAverageWidth(font);
const { ascent, descent, lineGap, unitsPerEm } = font;
const fallbackFontAvgWidth = fallbackFont.azAvgWidth / fallbackFont.unitsPerEm;
let sizeAdjust = azAvgWidth
? azAvgWidth / unitsPerEm / fallbackFontAvgWidth
: 1;
return {
ascentOverride: formatOverrideValue(ascent / (unitsPerEm * sizeAdjust)),
descentOverride: formatOverrideValue(descent / (unitsPerEm * sizeAdjust)),
lineGapOverride: formatOverrideValue(lineGap / (unitsPerEm * sizeAdjust)),
fallbackFont: fallbackFont.name,
sizeAdjust: formatOverrideValue(sizeAdjust),
};
}
exports.calculateFallbackFontValues = calculateFallbackFontValues;
function nextFontError(message) {
const err = new Error(message);
err.name = 'NextFontError';
throw err;
}
exports.nextFontError = nextFontError;

1
kitabcitab/node_modules/@next/font/google/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from '../dist/google'

15
kitabcitab/node_modules/@next/font/google/index.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
// Validate next version
const semver = require('next/dist/compiled/semver')
if (semver.lt(require('next/package.json').version, '13.0.0')) {
throw new Error('`@next/font` is only available in Next.js 13 and newer.')
}
let message = '@next/font/google failed to run or is incorrectly configured.'
if (process.env.NODE_ENV === 'development') {
message +=
'\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
}
message += `\n\nRead more: https://nextjs.org/docs/basic-features/font-optimization`
throw new Error(message)

View File

@@ -0,0 +1 @@
export { default } from '../dist/google/loader'

1
kitabcitab/node_modules/@next/font/google/loader.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../dist/google/loader')

1
kitabcitab/node_modules/@next/font/google/target.css generated vendored Normal file
View File

@@ -0,0 +1 @@
/* target file for webpack loader */

1
kitabcitab/node_modules/@next/font/local/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export { default } from '../dist/local/index'

15
kitabcitab/node_modules/@next/font/local/index.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
// Validate next version
const semver = require('next/dist/compiled/semver')
if (semver.lt(require('next/package.json').version, '13.0.0')) {
throw new Error('`@next/font` is only available in Next.js 13 and newer.')
}
let message = '@next/font/local failed to run or is incorrectly configured.'
if (process.env.NODE_ENV === 'development') {
message +=
'\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
}
message += `\n\nRead more: https://nextjs.org/docs/basic-features/font-optimization`
throw new Error(message)

1
kitabcitab/node_modules/@next/font/local/loader.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export { default } from '../dist/local/loader'

1
kitabcitab/node_modules/@next/font/local/loader.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../dist/local/loader')

1
kitabcitab/node_modules/@next/font/local/target.css generated vendored Normal file
View File

@@ -0,0 +1 @@
/* target file for webpack loader */

26
kitabcitab/node_modules/@next/font/package.json generated vendored Normal file
View File

@@ -0,0 +1,26 @@
{
"name": "@next/font",
"version": "13.1.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
},
"files": [
"dist",
"google",
"local"
],
"license": "MIT",
"scripts": {
"build": "rimraf dist && pnpm ncc-fontkit && tsc -d -p tsconfig.json",
"prepublishOnly": "cd ../../ && turbo run build",
"dev": "pnpm ncc-fontkit && tsc -d -w -p tsconfig.json",
"typescript": "tsec --noEmit -p tsconfig.json",
"ncc-fontkit": "ncc build ./fontkit.js -o dist/fontkit"
},
"devDependencies": {
"@types/fontkit": "2.0.0",
"@vercel/ncc": "0.34.0",
"fontkit": "2.0.2"
}
}