ccgauge 1.1.1 → 1.1.2

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 (109) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-build-manifest.json +39 -39
  3. package/.next/standalone/.next/app-path-routes-manifest.json +6 -6
  4. package/.next/standalone/.next/build-manifest.json +2 -2
  5. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  6. package/.next/standalone/.next/server/app/api/blocks/route_client-reference-manifest.js +1 -1
  7. package/.next/standalone/.next/server/app/api/export/usage/route_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
  9. package/.next/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  10. package/.next/standalone/.next/server/app/api/scan/route_client-reference-manifest.js +1 -1
  11. package/.next/standalone/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
  12. package/.next/standalone/.next/server/app/api/usage/route_client-reference-manifest.js +1 -1
  13. package/.next/standalone/.next/server/app/models/page_client-reference-manifest.js +1 -1
  14. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  15. package/.next/standalone/.next/server/app/projects/[id]/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  17. package/.next/standalone/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  19. package/.next/standalone/.next/server/app/settings/page.js +1 -1
  20. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  21. package/.next/standalone/.next/server/app/usage/page_client-reference-manifest.js +1 -1
  22. package/.next/standalone/.next/server/app-paths-manifest.json +6 -6
  23. package/.next/standalone/.next/server/chunks/567.js +2 -2
  24. package/.next/standalone/.next/server/chunks/716.js +1 -1
  25. package/.next/standalone/.next/server/functions-config-manifest.json +3 -3
  26. package/.next/standalone/.next/server/middleware-manifest.json +1 -1
  27. package/.next/standalone/.next/server/pages/500.html +1 -1
  28. package/.next/standalone/.next/static/chunks/148-edf90b0918345dc2.js +1 -0
  29. package/.next/standalone/.next/static/chunks/app/{layout-78960a03a026ecdf.js → layout-af71188a257674b5.js} +1 -1
  30. package/.next/standalone/.next/static/css/{e69fbe3cba63076e.css → fabb40b2545c70dd.css} +1 -1
  31. package/.next/standalone/package.json +2 -2
  32. package/.next/standalone/public/codex-logo.webp +0 -0
  33. package/CHANGELOG.md +75 -0
  34. package/dist/mcp/server.mjs +2 -2
  35. package/dist/report/index.mjs +36 -8158
  36. package/package.json +2 -2
  37. package/.next/standalone/.next/static/chunks/148-f2cba0b76260b8d3.js +0 -1
  38. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/constants.js +0 -10
  39. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/fontkit/index.js +0 -1
  40. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/format-available-values.js +0 -9
  41. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/fetch-css-from-google-fonts.js +0 -28
  42. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/fetch-font-file.js +0 -24
  43. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/fetch-resource.js +0 -46
  44. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/find-font-files-in-css.js +0 -34
  45. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/font-data.json +0 -17669
  46. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/get-fallback-font-override-metrics.js +0 -62
  47. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/get-font-axes.js +0 -66
  48. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/get-google-fonts-url.js +0 -55
  49. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/get-proxy-agent.js +0 -23
  50. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/google-fonts-metadata.js +0 -8
  51. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/loader.js +0 -175
  52. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/retry.js +0 -18
  53. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/sort-fonts-variant-values.js +0 -26
  54. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/google/validate-google-font-function-call.js +0 -101
  55. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/local/get-fallback-metrics-from-font-file.js +0 -85
  56. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/local/loader.js +0 -78
  57. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/local/pick-font-file-for-fallback-generation.js +0 -85
  58. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/local/validate-local-font-function-call.js +0 -66
  59. package/.next/standalone/node_modules/next/dist/compiled/@next/font/dist/next-font-error.js +0 -11
  60. package/.next/standalone/node_modules/next/dist/compiled/@next/font/google/loader.js +0 -1
  61. package/.next/standalone/node_modules/next/dist/compiled/@next/font/local/loader.js +0 -1
  62. package/.next/standalone/node_modules/next/dist/compiled/@next/font/package.json +0 -1
  63. package/.next/standalone/node_modules/next/dist/compiled/amphtml-validator/index.js +0 -1
  64. package/.next/standalone/node_modules/next/dist/compiled/amphtml-validator/package.json +0 -1
  65. package/.next/standalone/node_modules/next/dist/compiled/amphtml-validator/validator_wasm.js +0 -2672
  66. package/.next/standalone/node_modules/next/dist/compiled/babel/bundle.js +0 -227
  67. package/.next/standalone/node_modules/next/dist/compiled/babel/code-frame.js +0 -1
  68. package/.next/standalone/node_modules/next/dist/compiled/babel/core-lib-block-hoist-plugin.js +0 -1
  69. package/.next/standalone/node_modules/next/dist/compiled/babel/core-lib-config.js +0 -1
  70. package/.next/standalone/node_modules/next/dist/compiled/babel/core-lib-normalize-file.js +0 -1
  71. package/.next/standalone/node_modules/next/dist/compiled/babel/core-lib-normalize-opts.js +0 -1
  72. package/.next/standalone/node_modules/next/dist/compiled/babel/core-lib-plugin-pass.js +0 -1
  73. package/.next/standalone/node_modules/next/dist/compiled/babel/core.js +0 -1
  74. package/.next/standalone/node_modules/next/dist/compiled/babel/generator.js +0 -1
  75. package/.next/standalone/node_modules/next/dist/compiled/babel/package.json +0 -1
  76. package/.next/standalone/node_modules/next/dist/compiled/babel/parser.js +0 -1
  77. package/.next/standalone/node_modules/next/dist/compiled/babel/plugin-syntax-jsx.js +0 -1
  78. package/.next/standalone/node_modules/next/dist/compiled/babel/plugin-transform-define.js +0 -1
  79. package/.next/standalone/node_modules/next/dist/compiled/babel/plugin-transform-modules-commonjs.js +0 -1
  80. package/.next/standalone/node_modules/next/dist/compiled/babel/preset-typescript.js +0 -1
  81. package/.next/standalone/node_modules/next/dist/compiled/babel/traverse.js +0 -1
  82. package/.next/standalone/node_modules/next/dist/compiled/babel/types.js +0 -1
  83. package/.next/standalone/node_modules/next/dist/compiled/babel-packages/package.json +0 -1
  84. package/.next/standalone/node_modules/next/dist/compiled/babel-packages/packages-bundle.js +0 -335
  85. package/.next/standalone/node_modules/next/dist/server/capsize-font-metrics.json +0 -181516
  86. package/.next/standalone/node_modules/next/node_modules/@img/sharp-darwin-arm64/LICENSE +0 -191
  87. package/.next/standalone/node_modules/next/node_modules/@img/sharp-darwin-arm64/lib/sharp-darwin-arm64.node +0 -0
  88. package/.next/standalone/node_modules/next/node_modules/@img/sharp-darwin-arm64/package.json +0 -40
  89. package/.next/standalone/node_modules/next/node_modules/@img/sharp-libvips-darwin-arm64/lib/index.js +0 -1
  90. package/.next/standalone/node_modules/next/node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.8.17.3.dylib +0 -0
  91. package/.next/standalone/node_modules/next/node_modules/@img/sharp-libvips-darwin-arm64/package.json +0 -36
  92. package/.next/standalone/node_modules/next/node_modules/@img/sharp-libvips-darwin-arm64/versions.json +0 -30
  93. package/.next/standalone/node_modules/next/node_modules/sharp/lib/channel.js +0 -177
  94. package/.next/standalone/node_modules/next/node_modules/sharp/lib/colour.js +0 -195
  95. package/.next/standalone/node_modules/next/node_modules/sharp/lib/composite.js +0 -212
  96. package/.next/standalone/node_modules/next/node_modules/sharp/lib/constructor.js +0 -499
  97. package/.next/standalone/node_modules/next/node_modules/sharp/lib/index.js +0 -16
  98. package/.next/standalone/node_modules/next/node_modules/sharp/lib/input.js +0 -809
  99. package/.next/standalone/node_modules/next/node_modules/sharp/lib/is.js +0 -143
  100. package/.next/standalone/node_modules/next/node_modules/sharp/lib/libvips.js +0 -207
  101. package/.next/standalone/node_modules/next/node_modules/sharp/lib/operation.js +0 -1016
  102. package/.next/standalone/node_modules/next/node_modules/sharp/lib/output.js +0 -1666
  103. package/.next/standalone/node_modules/next/node_modules/sharp/lib/resize.js +0 -595
  104. package/.next/standalone/node_modules/next/node_modules/sharp/lib/sharp.js +0 -121
  105. package/.next/standalone/node_modules/next/node_modules/sharp/lib/utility.js +0 -291
  106. package/.next/standalone/node_modules/next/node_modules/sharp/package.json +0 -202
  107. package/.next/standalone/public/codex-logo.png +0 -0
  108. /package/.next/standalone/.next/static/{7PsGBJ1-BFrm7kVcPye-n → EQqRlXV5HyaCYSZWOVllH}/_buildManifest.js +0 -0
  109. /package/.next/standalone/.next/static/{7PsGBJ1-BFrm7kVcPye-n → EQqRlXV5HyaCYSZWOVllH}/_ssgManifest.js +0 -0
@@ -1,62 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getFallbackFontOverrideMetrics = getFallbackFontOverrideMetrics;
37
- // @ts-ignore
38
- const font_utils_1 = require("next/dist/server/font-utils");
39
- // @ts-ignore
40
- const Log = __importStar(require("next/dist/build/output/log"));
41
- /**
42
- * Get precalculated fallback font metrics for the Google Fonts family.
43
- *
44
- * TODO:
45
- * We might want to calculate these values with fontkit instead (like in next/font/local).
46
- * That way we don't have to update the precalculated values every time a new font is added to Google Fonts.
47
- */
48
- function getFallbackFontOverrideMetrics(fontFamily) {
49
- try {
50
- const { ascent, descent, lineGap, fallbackFont, sizeAdjust } = (0, font_utils_1.calculateSizeAdjustValues)(fontFamily);
51
- return {
52
- fallbackFont,
53
- ascentOverride: `${ascent}%`,
54
- descentOverride: `${descent}%`,
55
- lineGapOverride: `${lineGap}%`,
56
- sizeAdjust: `${sizeAdjust}%`,
57
- };
58
- }
59
- catch {
60
- Log.error(`Failed to find font override values for font \`${fontFamily}\``);
61
- }
62
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFontAxes = getFontAxes;
4
- const format_available_values_1 = require("../format-available-values");
5
- const next_font_error_1 = require("../next-font-error");
6
- const google_fonts_metadata_1 = require("./google-fonts-metadata");
7
- /**
8
- * Validates and gets the data for each font axis required to generate the Google Fonts URL.
9
- */
10
- function getFontAxes(fontFamily, weights, styles, selectedVariableAxes) {
11
- const hasItalic = styles.includes('italic');
12
- const hasNormal = styles.includes('normal');
13
- // Make sure the order is correct, otherwise Google Fonts will return an error
14
- // If only normal is set, we can skip returning the ital axis as normal is the default
15
- const ital = hasItalic ? [...(hasNormal ? ['0'] : []), '1'] : undefined;
16
- // Weights will always contain one element if it's a variable font
17
- if (weights[0] === 'variable') {
18
- // Get all the available axes for the current font from the metadata file
19
- const allAxes = google_fonts_metadata_1.googleFontsMetadata[fontFamily].axes;
20
- if (!allAxes) {
21
- throw new Error('invariant variable font without axes');
22
- }
23
- if (selectedVariableAxes) {
24
- // The axes other than weight and style that can be defined for the current variable font
25
- const defineAbleAxes = allAxes
26
- .map(({ tag }) => tag)
27
- .filter((tag) => tag !== 'wght');
28
- if (defineAbleAxes.length === 0) {
29
- (0, next_font_error_1.nextFontError)(`Font \`${fontFamily}\` has no definable \`axes\``);
30
- }
31
- if (!Array.isArray(selectedVariableAxes)) {
32
- (0, next_font_error_1.nextFontError)(`Invalid axes value for font \`${fontFamily}\`, expected an array of axes.\nAvailable axes: ${(0, format_available_values_1.formatAvailableValues)(defineAbleAxes)}`);
33
- }
34
- selectedVariableAxes.forEach((key) => {
35
- if (!defineAbleAxes.some((tag) => tag === key)) {
36
- (0, next_font_error_1.nextFontError)(`Invalid axes value \`${key}\` for font \`${fontFamily}\`.\nAvailable axes: ${(0, format_available_values_1.formatAvailableValues)(defineAbleAxes)}`);
37
- }
38
- });
39
- }
40
- let weightAxis;
41
- let variableAxes;
42
- for (const { tag, min, max } of allAxes) {
43
- if (tag === 'wght') {
44
- // In variable fonts the weight is a range
45
- weightAxis = `${min}..${max}`;
46
- }
47
- else if (selectedVariableAxes === null || selectedVariableAxes === void 0 ? void 0 : selectedVariableAxes.includes(tag)) {
48
- if (!variableAxes) {
49
- variableAxes = [];
50
- }
51
- variableAxes.push([tag, `${min}..${max}`]);
52
- }
53
- }
54
- return {
55
- wght: weightAxis ? [weightAxis] : undefined,
56
- ital,
57
- variableAxes,
58
- };
59
- }
60
- else {
61
- return {
62
- ital,
63
- wght: weights,
64
- };
65
- }
66
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGoogleFontsUrl = getGoogleFontsUrl;
4
- const sort_fonts_variant_values_1 = require("./sort-fonts-variant-values");
5
- /**
6
- * Generate the Google Fonts URL given the requested weight(s), style(s) and additional variable axes
7
- */
8
- function getGoogleFontsUrl(fontFamily, axes, display) {
9
- var _a, _b;
10
- // Variants are all combinations of weight and style, each variant will result in a separate font file
11
- const variants = [];
12
- if (axes.wght) {
13
- for (const wght of axes.wght) {
14
- if (!axes.ital) {
15
- variants.push([['wght', wght], ...((_a = axes.variableAxes) !== null && _a !== void 0 ? _a : [])]);
16
- }
17
- else {
18
- for (const ital of axes.ital) {
19
- variants.push([
20
- ['ital', ital],
21
- ['wght', wght],
22
- ...((_b = axes.variableAxes) !== null && _b !== void 0 ? _b : []),
23
- ]);
24
- }
25
- }
26
- }
27
- }
28
- else if (axes.variableAxes) {
29
- // Variable fonts might not have a range of weights, just add optional variable axes in that case
30
- variants.push([...axes.variableAxes]);
31
- }
32
- // Google api requires the axes to be sorted, starting with lowercase words
33
- if (axes.variableAxes) {
34
- variants.forEach((variant) => {
35
- variant.sort(([a], [b]) => {
36
- const aIsLowercase = a.charCodeAt(0) > 96;
37
- const bIsLowercase = b.charCodeAt(0) > 96;
38
- if (aIsLowercase && !bIsLowercase)
39
- return -1;
40
- if (bIsLowercase && !aIsLowercase)
41
- return 1;
42
- return a > b ? 1 : -1;
43
- });
44
- });
45
- }
46
- let url = `https://fonts.googleapis.com/css2?family=${fontFamily.replace(/ /g, '+')}`;
47
- if (variants.length > 0) {
48
- url = `${url}:${variants[0].map(([key]) => key).join(',')}@${variants
49
- .map((variant) => variant.map(([, val]) => val).join(','))
50
- .sort(sort_fonts_variant_values_1.sortFontsVariantValues)
51
- .join(';')}`;
52
- }
53
- url = `${url}&display=${display}`;
54
- return url;
55
- }
@@ -1,23 +0,0 @@
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.getProxyAgent = getProxyAgent;
7
- // @ts-ignore
8
- const https_proxy_agent_1 = __importDefault(require("next/dist/compiled/https-proxy-agent"));
9
- // @ts-ignore
10
- const http_proxy_agent_1 = __importDefault(require("next/dist/compiled/http-proxy-agent"));
11
- /**
12
- * If the http(s)_proxy environment variables is set, return a proxy agent.
13
- */
14
- function getProxyAgent() {
15
- const httpsProxy = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
16
- if (httpsProxy) {
17
- return new https_proxy_agent_1.default(httpsProxy);
18
- }
19
- const httpProxy = process.env['http_proxy'] || process.env['HTTP_PROXY'];
20
- if (httpProxy) {
21
- return new http_proxy_agent_1.default(httpProxy);
22
- }
23
- }
@@ -1,8 +0,0 @@
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.googleFontsMetadata = void 0;
7
- const font_data_json_1 = __importDefault(require("./font-data.json"));
8
- exports.googleFontsMetadata = font_data_json_1.default;
@@ -1,175 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- // @ts-ignore
37
- const Log = __importStar(require("next/dist/build/output/log"));
38
- const validate_google_font_function_call_1 = require("./validate-google-font-function-call");
39
- const get_font_axes_1 = require("./get-font-axes");
40
- const get_google_fonts_url_1 = require("./get-google-fonts-url");
41
- const next_font_error_1 = require("../next-font-error");
42
- const find_font_files_in_css_1 = require("./find-font-files-in-css");
43
- const get_fallback_font_override_metrics_1 = require("./get-fallback-font-override-metrics");
44
- const fetch_css_from_google_fonts_1 = require("./fetch-css-from-google-fonts");
45
- const fetch_font_file_1 = require("./fetch-font-file");
46
- const cssCache = new Map();
47
- const fontCache = new Map();
48
- // regexp is based on https://github.com/sindresorhus/escape-string-regexp
49
- const reHasRegExp = /[|\\{}()[\]^$+*?.-]/;
50
- const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g;
51
- function escapeStringRegexp(str) {
52
- // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23
53
- if (reHasRegExp.test(str)) {
54
- return str.replace(reReplaceRegExp, '\\$&');
55
- }
56
- return str;
57
- }
58
- const nextFontGoogleFontLoader = async ({ functionName, data, emitFontFile, isDev, isServer, }) => {
59
- var _a;
60
- const { fontFamily, weights, styles, display, preload, selectedVariableAxes, fallback, adjustFontFallback, variable, subsets, } = (0, validate_google_font_function_call_1.validateGoogleFontFunctionCall)(functionName, data[0]);
61
- // Validate and get the font axes required to generated the URL
62
- const fontAxes = (0, get_font_axes_1.getFontAxes)(fontFamily, weights, styles, selectedVariableAxes);
63
- // Generate the Google Fonts URL from the font family, axes and display value
64
- const url = (0, get_google_fonts_url_1.getGoogleFontsUrl)(fontFamily, fontAxes, display);
65
- // Get precalculated fallback font metrics, used to generate the fallback font CSS
66
- const adjustFontFallbackMetrics = adjustFontFallback ? (0, get_fallback_font_override_metrics_1.getFallbackFontOverrideMetrics)(fontFamily) : undefined;
67
- const result = {
68
- fallbackFonts: fallback,
69
- weight: weights.length === 1 && weights[0] !== 'variable'
70
- ? weights[0]
71
- : undefined,
72
- style: styles.length === 1 ? styles[0] : undefined,
73
- variable,
74
- adjustFontFallback: adjustFontFallbackMetrics,
75
- };
76
- try {
77
- /**
78
- * Hacky way to make sure the fetch is only done once.
79
- * Otherwise both the client and server compiler would fetch the CSS.
80
- * The reason we need to return the actual CSS from both the server and client is because a hash is generated based on the CSS content.
81
- */
82
- const hasCachedCSS = cssCache.has(url);
83
- // Fetch CSS from Google Fonts or get it from the cache
84
- let fontFaceDeclarations = hasCachedCSS
85
- ? cssCache.get(url)
86
- : await (0, fetch_css_from_google_fonts_1.fetchCSSFromGoogleFonts)(url, fontFamily, isDev).catch((err) => {
87
- console.error(err);
88
- return null;
89
- });
90
- if (!hasCachedCSS) {
91
- cssCache.set(url, fontFaceDeclarations !== null && fontFaceDeclarations !== void 0 ? fontFaceDeclarations : null);
92
- }
93
- else {
94
- cssCache.delete(url);
95
- }
96
- if (fontFaceDeclarations == null) {
97
- (0, next_font_error_1.nextFontError)(`Failed to fetch \`${fontFamily}\` from Google Fonts.`);
98
- }
99
- // CSS Variables may be set on a body tag, ignore them to keep the CSS module pure
100
- fontFaceDeclarations = fontFaceDeclarations.split('body {', 1)[0];
101
- // Find font files to download, provide the array of subsets we want to preload if preloading is enabled
102
- const fontFiles = (0, find_font_files_in_css_1.findFontFilesInCss)(fontFaceDeclarations, preload ? subsets : undefined);
103
- // Download the font files extracted from the CSS
104
- const downloadedFiles = await Promise.all(fontFiles.map(async ({ googleFontFileUrl, preloadFontFile }) => {
105
- const hasCachedFont = fontCache.has(googleFontFileUrl);
106
- // Download the font file or get it from cache
107
- const fontFileBuffer = hasCachedFont
108
- ? fontCache.get(googleFontFileUrl)
109
- : await (0, fetch_font_file_1.fetchFontFile)(googleFontFileUrl, isDev).catch((err) => {
110
- console.error(err);
111
- return null;
112
- });
113
- if (!hasCachedFont) {
114
- fontCache.set(googleFontFileUrl, fontFileBuffer !== null && fontFileBuffer !== void 0 ? fontFileBuffer : null);
115
- }
116
- else {
117
- fontCache.delete(googleFontFileUrl);
118
- }
119
- if (fontFileBuffer == null) {
120
- (0, next_font_error_1.nextFontError)(`Failed to fetch \`${fontFamily}\` from Google Fonts.`);
121
- }
122
- const ext = /\.(woff|woff2|eot|ttf|otf)$/.exec(googleFontFileUrl)[1];
123
- // Emit font file to .next/static/media
124
- const selfHostedFileUrl = emitFontFile(fontFileBuffer, ext, preloadFontFile, !!adjustFontFallbackMetrics);
125
- return {
126
- googleFontFileUrl,
127
- selfHostedFileUrl,
128
- };
129
- }));
130
- /**
131
- * Replace the @font-face sources with the self-hosted files we just downloaded to .next/static/media
132
- *
133
- * E.g.
134
- * @font-face {
135
- * font-family: 'Inter';
136
- * src: url(https://fonts.gstatic.com/...) -> url(/_next/static/media/_.woff2)
137
- * }
138
- */
139
- let updatedCssResponse = fontFaceDeclarations;
140
- for (const { googleFontFileUrl, selfHostedFileUrl } of downloadedFiles) {
141
- updatedCssResponse = updatedCssResponse.replace(new RegExp(escapeStringRegexp(googleFontFileUrl), 'g'), selfHostedFileUrl);
142
- }
143
- return {
144
- ...result,
145
- css: updatedCssResponse,
146
- };
147
- }
148
- catch (err) {
149
- if (isDev) {
150
- if (isServer) {
151
- Log.error(`Failed to download \`${fontFamily}\` from Google Fonts. Using fallback font instead.\n\n${err.message}}`);
152
- }
153
- // In dev we should return the fallback font instead of throwing an error
154
- let css = `@font-face {
155
- font-family: '${fontFamily} Fallback';
156
- src: local("${(_a = adjustFontFallbackMetrics === null || adjustFontFallbackMetrics === void 0 ? void 0 : adjustFontFallbackMetrics.fallbackFont) !== null && _a !== void 0 ? _a : 'Arial'}");`;
157
- if (adjustFontFallbackMetrics) {
158
- css += `
159
- ascent-override:${adjustFontFallbackMetrics.ascentOverride};
160
- descent-override:${adjustFontFallbackMetrics.descentOverride};
161
- line-gap-override:${adjustFontFallbackMetrics.lineGapOverride};
162
- size-adjust:${adjustFontFallbackMetrics.sizeAdjust};`;
163
- }
164
- css += '\n}';
165
- return {
166
- ...result,
167
- css,
168
- };
169
- }
170
- else {
171
- throw err;
172
- }
173
- }
174
- };
175
- exports.default = nextFontGoogleFontLoader;
@@ -1,18 +0,0 @@
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.retry = retry;
7
- // eslint-disable-next-line import/no-extraneous-dependencies
8
- // @ts-expect-error File exists
9
- const async_retry_1 = __importDefault(require("next/dist/compiled/async-retry"));
10
- async function retry(fn, retries) {
11
- return await (0, async_retry_1.default)(fn, {
12
- retries,
13
- onRetry(e, attempt) {
14
- console.error(e.message + `\n\nRetrying ${attempt}/${retries}...`);
15
- },
16
- minTimeout: 100,
17
- });
18
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /**
3
- * Callback function for sorting font variant values.
4
- * Used as a parameter in `Array.prototype.sort` function to ensure correct sorting.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.sortFontsVariantValues = sortFontsVariantValues;
8
- function sortFontsVariantValues(valA, valB) {
9
- // If both values contain commas, it indicates they are in "ital,wght" format
10
- if (valA.includes(',') && valB.includes(',')) {
11
- // Split the values into prefix and suffix
12
- const [aPrefix, aSuffix] = valA.split(',', 2);
13
- const [bPrefix, bSuffix] = valB.split(',', 2);
14
- // Compare the prefixes (ital values)
15
- if (aPrefix === bPrefix) {
16
- // If prefixes are equal, then compare the suffixes (wght values)
17
- return parseInt(aSuffix) - parseInt(bSuffix);
18
- }
19
- else {
20
- // If prefixes are different, then compare the prefixes directly
21
- return parseInt(aPrefix) - parseInt(bPrefix);
22
- }
23
- }
24
- // If values are not in "ital,wght" format, then directly compare them as integers
25
- return parseInt(valA) - parseInt(valB);
26
- }
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateGoogleFontFunctionCall = validateGoogleFontFunctionCall;
4
- const constants_1 = require("../constants");
5
- const format_available_values_1 = require("../format-available-values");
6
- const next_font_error_1 = require("../next-font-error");
7
- const google_fonts_metadata_1 = require("./google-fonts-metadata");
8
- /**
9
- * Validate the data received from next-swc next-transform-font on next/font/google calls
10
- */
11
- function validateGoogleFontFunctionCall(functionName, fontFunctionArgument) {
12
- let { weight, style, preload = true, display = 'swap', axes, fallback, adjustFontFallback = true, variable, subsets, } = fontFunctionArgument || {};
13
- if (functionName === '') {
14
- (0, next_font_error_1.nextFontError)(`next/font/google has no default export`);
15
- }
16
- const fontFamily = functionName.replace(/_/g, ' ');
17
- // Get the Google font metadata, we'll use this to validate the font arguments and to print better error messages
18
- const fontFamilyData = google_fonts_metadata_1.googleFontsMetadata[fontFamily];
19
- if (!fontFamilyData) {
20
- (0, next_font_error_1.nextFontError)(`Unknown font \`${fontFamily}\``);
21
- }
22
- const availableSubsets = fontFamilyData.subsets;
23
- if (availableSubsets.length === 0) {
24
- // If the font doesn't have any preloadeable subsets, disable preload
25
- preload = false;
26
- }
27
- else if (preload) {
28
- if (!subsets) {
29
- (0, next_font_error_1.nextFontError)(`Preload is enabled but no subsets were specified for font \`${fontFamily}\`. Please specify subsets or disable preloading if your intended subset can't be preloaded.\nAvailable subsets: ${(0, format_available_values_1.formatAvailableValues)(availableSubsets)}\n\nRead more: https://nextjs.org/docs/messages/google-fonts-missing-subsets`);
30
- }
31
- subsets.forEach((subset) => {
32
- if (!availableSubsets.includes(subset)) {
33
- (0, next_font_error_1.nextFontError)(`Unknown subset \`${subset}\` for font \`${fontFamily}\`.\nAvailable subsets: ${(0, format_available_values_1.formatAvailableValues)(availableSubsets)}`);
34
- }
35
- });
36
- }
37
- const fontWeights = fontFamilyData.weights;
38
- const fontStyles = fontFamilyData.styles;
39
- // Get the unique weights and styles from the function call
40
- const weights = !weight
41
- ? []
42
- : [...new Set(Array.isArray(weight) ? weight : [weight])];
43
- const styles = !style
44
- ? []
45
- : [...new Set(Array.isArray(style) ? style : [style])];
46
- if (weights.length === 0) {
47
- // Set variable as default, throw if not available
48
- if (fontWeights.includes('variable')) {
49
- weights.push('variable');
50
- }
51
- else {
52
- (0, next_font_error_1.nextFontError)(`Missing weight for font \`${fontFamily}\`.\nAvailable weights: ${(0, format_available_values_1.formatAvailableValues)(fontWeights)}`);
53
- }
54
- }
55
- if (weights.length > 1 && weights.includes('variable')) {
56
- (0, next_font_error_1.nextFontError)(`Unexpected \`variable\` in weight array for font \`${fontFamily}\`. You only need \`variable\`, it includes all available weights.`);
57
- }
58
- weights.forEach((selectedWeight) => {
59
- if (!fontWeights.includes(selectedWeight)) {
60
- (0, next_font_error_1.nextFontError)(`Unknown weight \`${selectedWeight}\` for font \`${fontFamily}\`.\nAvailable weights: ${(0, format_available_values_1.formatAvailableValues)(fontWeights)}`);
61
- }
62
- });
63
- if (styles.length === 0) {
64
- if (fontStyles.length === 1) {
65
- // Handle default style for fonts that only have italic
66
- styles.push(fontStyles[0]);
67
- }
68
- else {
69
- // Otherwise set default style to normal
70
- styles.push('normal');
71
- }
72
- }
73
- styles.forEach((selectedStyle) => {
74
- if (!fontStyles.includes(selectedStyle)) {
75
- (0, next_font_error_1.nextFontError)(`Unknown style \`${selectedStyle}\` for font \`${fontFamily}\`.\nAvailable styles: ${(0, format_available_values_1.formatAvailableValues)(fontStyles)}`);
76
- }
77
- });
78
- if (!constants_1.allowedDisplayValues.includes(display)) {
79
- (0, next_font_error_1.nextFontError)(`Invalid display value \`${display}\` for font \`${fontFamily}\`.\nAvailable display values: ${(0, format_available_values_1.formatAvailableValues)(constants_1.allowedDisplayValues)}`);
80
- }
81
- if (axes) {
82
- if (!fontWeights.includes('variable')) {
83
- (0, next_font_error_1.nextFontError)('Axes can only be defined for variable fonts.');
84
- }
85
- if (weights[0] !== 'variable') {
86
- (0, next_font_error_1.nextFontError)('Axes can only be defined for variable fonts when the weight property is nonexistent or set to `variable`.');
87
- }
88
- }
89
- return {
90
- fontFamily,
91
- weights,
92
- styles,
93
- display,
94
- preload,
95
- selectedVariableAxes: axes,
96
- fallback,
97
- adjustFontFallback,
98
- variable,
99
- subsets,
100
- };
101
- }
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFallbackMetricsFromFontFile = getFallbackMetricsFromFontFile;
4
- // The font metadata of the fallback fonts, retrieved with fontkit on system font files
5
- // The average width is calculated with the calcAverageWidth function below
6
- const DEFAULT_SANS_SERIF_FONT = {
7
- name: 'Arial',
8
- azAvgWidth: 934.5116279069767,
9
- unitsPerEm: 2048,
10
- };
11
- const DEFAULT_SERIF_FONT = {
12
- name: 'Times New Roman',
13
- azAvgWidth: 854.3953488372093,
14
- unitsPerEm: 2048,
15
- };
16
- /**
17
- * Calculate the average character width of a font file.
18
- * Used to calculate the size-adjust property by comparing the fallback average with the loaded font average.
19
- */
20
- function calcAverageWidth(font) {
21
- try {
22
- /**
23
- * Finding the right characters to use when calculating the average width is tricky.
24
- * We can't just use the average width of all characters, because we have to take letter frequency into account.
25
- * We also have to take word length into account, because the font's space width usually differ a lot from other characters.
26
- * The goal is to find a string that'll give you a good average width, given most texts in most languages.
27
- *
28
- * TODO: Currently only works for the latin alphabet. Support more languages by finding the right characters for additional languages.
29
- *
30
- * The used characters were decided through trial and error with letter frequency and word length tables as a guideline.
31
- * E.g. https://en.wikipedia.org/wiki/Letter_frequency
32
- */
33
- const avgCharacters = 'aaabcdeeeefghiijklmnnoopqrrssttuvwxyz ';
34
- // Check if the font file has all the characters we need to calculate the average width
35
- const hasAllChars = font
36
- .glyphsForString(avgCharacters)
37
- .flatMap((glyph) => glyph.codePoints)
38
- .every((codePoint) => font.hasGlyphForCodePoint(codePoint));
39
- if (!hasAllChars)
40
- return undefined;
41
- const widths = font
42
- .glyphsForString(avgCharacters)
43
- .map((glyph) => glyph.advanceWidth);
44
- const totalWidth = widths.reduce((sum, width) => sum + width, 0);
45
- return totalWidth / widths.length;
46
- }
47
- catch {
48
- // Could not calculate average width from the font file, skip size-adjust
49
- return undefined;
50
- }
51
- }
52
- function formatOverrideValue(val) {
53
- return Math.abs(val * 100).toFixed(2) + '%';
54
- }
55
- /**
56
- * Given a font file and category, calculate the fallback font override values.
57
- * The returned values can be used to generate a CSS @font-face declaration.
58
- *
59
- * For example:
60
- * @font-face {
61
- * font-family: local-font;
62
- * src: local(Arial);
63
- * size-adjust: 90%;
64
- * }
65
- *
66
- * Read more about this technique in these texts by the Google Aurora team:
67
- * https://developer.chrome.com/blog/font-fallbacks/
68
- * https://docs.google.com/document/d/e/2PACX-1vRsazeNirATC7lIj2aErSHpK26hZ6dA9GsQ069GEbq5fyzXEhXbvByoftSfhG82aJXmrQ_sJCPBqcx_/pub
69
- */
70
- function getFallbackMetricsFromFontFile(font, category = 'serif') {
71
- const fallbackFont = category === 'serif' ? DEFAULT_SERIF_FONT : DEFAULT_SANS_SERIF_FONT;
72
- const azAvgWidth = calcAverageWidth(font);
73
- const { ascent, descent, lineGap, unitsPerEm } = font;
74
- const fallbackFontAvgWidth = fallbackFont.azAvgWidth / fallbackFont.unitsPerEm;
75
- let sizeAdjust = azAvgWidth
76
- ? azAvgWidth / unitsPerEm / fallbackFontAvgWidth
77
- : 1;
78
- return {
79
- ascentOverride: formatOverrideValue(ascent / (unitsPerEm * sizeAdjust)),
80
- descentOverride: formatOverrideValue(descent / (unitsPerEm * sizeAdjust)),
81
- lineGapOverride: formatOverrideValue(lineGap / (unitsPerEm * sizeAdjust)),
82
- fallbackFont: fallbackFont.name,
83
- sizeAdjust: formatOverrideValue(sizeAdjust),
84
- };
85
- }