fern-api 0.19.2 → 0.19.3

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 (2) hide show
  1. package/bundle.cjs +125 -61
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -797931,7 +797931,7 @@ var AccessTokenPosthogManager = class {
797931
797931
  properties: {
797932
797932
  ...event,
797933
797933
  ...event.properties,
797934
- version: "0.19.2",
797934
+ version: "0.19.3",
797935
797935
  usingAccessToken: true
797936
797936
  }
797937
797937
  });
@@ -797993,7 +797993,7 @@ var UserPosthogManager = class {
797993
797993
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
797994
797994
  event: "CLI",
797995
797995
  properties: {
797996
- version: "0.19.2",
797996
+ version: "0.19.3",
797997
797997
  ...event,
797998
797998
  ...event.properties
797999
797999
  }
@@ -824771,10 +824771,10 @@ var CliContext = class {
824771
824771
  return "fern-api";
824772
824772
  }
824773
824773
  getPackageVersion() {
824774
- if ("0.19.2" == null) {
824774
+ if ("0.19.3" == null) {
824775
824775
  this.logger.error("CLI_VERSION is not defined");
824776
824776
  }
824777
- return "0.19.2";
824777
+ return "0.19.3";
824778
824778
  }
824779
824779
  getCliName() {
824780
824780
  if ("fern" == null) {
@@ -841003,10 +841003,6 @@ async function runRemoteGenerationForAPIWorkspace({ organization, workspace, con
841003
841003
  };
841004
841004
  }
841005
841005
 
841006
- // pnp:/home/circleci/project/packages/cli/config-management/docs-configuration/lib/parseDocsConfiguration.js
841007
- var import_fdr_sdk3 = __toESM(require_dist());
841008
- var import_promises40 = require("fs/promises");
841009
-
841010
841006
  // pnp:/home/circleci/project/.yarn/cache/tinycolor2-npm-1.6.0-8df41252c6-6df4d07fce.zip/node_modules/tinycolor2/esm/tinycolor.js
841011
841007
  function _typeof2(obj) {
841012
841008
  "@babel/helpers - typeof";
@@ -841986,6 +841982,7 @@ function validateWCAG2Parms(parms) {
841986
841982
 
841987
841983
  // pnp:/home/circleci/project/packages/cli/config-management/docs-configuration/lib/convertColorsConfiguration.js
841988
841984
  function convertColorsConfiguration(rawConfig, context) {
841985
+ rawConfig.accentPrimary = rawConfig.accentPrimary ?? rawConfig.accentPrimaryDeprecated;
841989
841986
  const colorType = getColorType(rawConfig);
841990
841987
  switch (colorType) {
841991
841988
  case "dark":
@@ -842041,74 +842038,46 @@ function getColorType({ background, accentPrimary, accentPrimaryDeprecated }) {
842041
842038
  }
842042
842039
  function convertThemedColorConfig(rawConfig, context, theme) {
842043
842040
  var _a2, _b2, _c2, _d;
842044
- let accentPrimaryColor = getColorInstanceFromRawConfig(rawConfig.accentPrimary, context, "accent-primary", theme) ?? tinycolor.random();
842045
- let backgroundColor = getColorInstanceFromRawConfig(rawConfig.background, context, "background", theme);
842046
- if (backgroundColor != null) {
842047
- const newBackgroundColor = enforceBackgroundTheme(tinycolor(backgroundColor.toString()), theme);
842048
- if (newBackgroundColor.toHexString() !== backgroundColor.toHexString()) {
842049
- context.logger.warn(`The chosen shade, 'colors.background' in ${theme} mode, fails to meet minimum contrast requirements. The brightness is ${backgroundColor.getBrightness()}. To enhance accessibility and ensure content readability, Fern will adjust from ${backgroundColor.toHexString()} to a more contrast-rich ${newBackgroundColor.toHexString()}.`);
842050
- backgroundColor = newBackgroundColor;
842051
- }
842052
- }
842053
- if (accentPrimaryColor != null) {
842054
- const backgroundColorWithFallback = backgroundColor ?? tinycolor(theme === "dark" ? "#000" : "#FFF");
842055
- const newAccentPrimaryColor = increaseForegroundContrast(tinycolor(accentPrimaryColor.toString()), backgroundColorWithFallback);
842056
- if (newAccentPrimaryColor.toHexString() !== accentPrimaryColor.toHexString()) {
842057
- const ratio = tinycolor.readability(accentPrimaryColor, backgroundColorWithFallback);
842058
- context.logger.warn(`The chosen shade, 'colors.accent-primary' in ${theme} mode, fails to meet minimum contrast requirements. The contrast ratio is ${ratio}, which is below WCAG AA requirements (4.5:1). To enhance accessibility and ensure content readability, Fern will adjust from ${accentPrimaryColor.toHexString()} to a more contrast-rich ${newAccentPrimaryColor.toHexString()}.`);
842059
- accentPrimaryColor = newAccentPrimaryColor;
842060
- }
842061
- }
842041
+ const accentPrimaryColor = getColorInstanceFromRawConfigOrThrow(rawConfig.accentPrimary ?? rawConfig.accentPrimaryDeprecated, context, "accent-primary", theme) ?? tinycolor.random();
842042
+ const backgroundColor = getColorInstanceFromRawConfigOrThrow(rawConfig.background, context, "background", theme);
842062
842043
  return {
842063
842044
  accentPrimary: accentPrimaryColor.toRgb(),
842064
842045
  background: backgroundColor == null ? void 0 : backgroundColor.toRgb(),
842065
- border: (_a2 = getColorInstanceFromRawConfig(rawConfig.border, context, "border", theme)) == null ? void 0 : _a2.toRgb(),
842066
- sidebarBackground: (_b2 = getColorInstanceFromRawConfig(rawConfig.sidebarBackground, context, "sidebar-background", theme)) == null ? void 0 : _b2.toRgb(),
842067
- headerBackground: (_c2 = getColorInstanceFromRawConfig(rawConfig.headerBackground, context, "header-background", theme)) == null ? void 0 : _c2.toRgb(),
842068
- cardBackground: (_d = getColorInstanceFromRawConfig(rawConfig.cardBackground, context, "card-background", theme)) == null ? void 0 : _d.toRgb()
842046
+ border: (_a2 = getColorInstanceFromRawConfigOrThrow(rawConfig.border, context, "border", theme)) == null ? void 0 : _a2.toRgb(),
842047
+ sidebarBackground: (_b2 = getColorInstanceFromRawConfigOrThrow(rawConfig.sidebarBackground, context, "sidebar-background", theme)) == null ? void 0 : _b2.toRgb(),
842048
+ headerBackground: (_c2 = getColorInstanceFromRawConfigOrThrow(rawConfig.headerBackground, context, "header-background", theme)) == null ? void 0 : _c2.toRgb(),
842049
+ cardBackground: (_d = getColorInstanceFromRawConfigOrThrow(rawConfig.cardBackground, context, "card-background", theme)) == null ? void 0 : _d.toRgb()
842069
842050
  };
842070
842051
  }
842071
- function increaseForegroundContrast(foregroundColor, backgroundColor) {
842072
- let newForgroundColor = foregroundColor;
842073
- const dark = backgroundColor.isDark();
842074
- while (!tinycolor.isReadable(newForgroundColor, backgroundColor)) {
842075
- if (dark ? newForgroundColor.getBrightness() === 255 : newForgroundColor.getBrightness() === 0) {
842076
- break;
842077
- }
842078
- newForgroundColor = dark ? newForgroundColor.lighten(1) : newForgroundColor.darken(1);
842052
+ function getColorFromRawConfig(raw, key2, theme) {
842053
+ if (raw == null) {
842054
+ return void 0;
842079
842055
  }
842080
- return newForgroundColor;
842081
- }
842082
- function enforceBackgroundTheme(color3, theme) {
842083
- if (theme === "dark" && color3.isDark()) {
842084
- return color3;
842085
- } else if (theme === "light" && color3.isLight()) {
842086
- return color3;
842056
+ let rawColor = typeof raw === "string" ? raw : raw[theme];
842057
+ if (rawColor == null && key2 === "accent-primary" && typeof raw !== "string") {
842058
+ rawColor = raw[theme === "dark" ? "light" : "dark"];
842087
842059
  }
842088
- return getOppositeBrightness(color3);
842089
- }
842090
- function getOppositeBrightness(color3) {
842091
- if (color3 == null) {
842060
+ if (rawColor == null) {
842092
842061
  return void 0;
842093
842062
  }
842094
- const { h: h3, s: s2, v: v2 } = color3.toHsv();
842095
- return tinycolor({ h: h3, s: s2, v: 1 - v2 });
842063
+ return rawColor;
842096
842064
  }
842097
- function getColorInstanceFromRawConfig(raw, context, key2, theme) {
842098
- if (raw == null) {
842099
- return void 0;
842100
- }
842101
- const rawColor = typeof raw === "string" ? raw : raw[theme];
842102
- if (rawColor == null) {
842065
+ function getColorInstanceFromRawConfigOrThrow(raw, context, key2, theme) {
842066
+ const color3 = getColorFromRawConfig(raw, key2, theme);
842067
+ if (color3 == null) {
842103
842068
  return void 0;
842104
842069
  }
842105
- const color3 = tinycolor(rawColor);
842106
- if (!color3.isValid()) {
842070
+ const instance = tinycolor(color3);
842071
+ if (!instance.isValid()) {
842107
842072
  context.failAndThrow(`'${typeof raw === "string" ? key2 : `colors.${key2}.${theme}`}' should be a hex color of the format #FFFFFF`);
842108
842073
  }
842109
- return color3;
842074
+ return instance;
842110
842075
  }
842111
842076
 
842077
+ // pnp:/home/circleci/project/packages/cli/config-management/docs-configuration/lib/parseDocsConfiguration.js
842078
+ var import_fdr_sdk3 = __toESM(require_dist());
842079
+ var import_promises40 = require("fs/promises");
842080
+
842112
842081
  // pnp:/home/circleci/project/packages/cli/config-management/docs-configuration/lib/getAllPages.js
842113
842082
  var import_promises39 = require("fs/promises");
842114
842083
  async function getAllPages({ navigation, absolutePathToFernFolder }) {
@@ -843441,6 +843410,95 @@ function createDocsConfigFileAstVisitorForRules({ relativeFilepath, allRuleVisit
843441
843410
  };
843442
843411
  }
843443
843412
 
843413
+ // pnp:/home/circleci/project/packages/cli/yaml/docs-validator/lib/rules/accent-color-contrast/index.js
843414
+ var AccentColorContrastRule = {
843415
+ name: "accent-color-contrast",
843416
+ create: () => {
843417
+ return {
843418
+ file: async ({ config }) => {
843419
+ if (config.colors == null) {
843420
+ return [];
843421
+ }
843422
+ const colorType = getColorType(config.colors);
843423
+ if (colorType === "dark") {
843424
+ return validateTheme(config.colors, "dark");
843425
+ } else if (colorType === "light") {
843426
+ return validateTheme(config.colors, "light");
843427
+ } else if (colorType === "darkAndLight") {
843428
+ return [...validateTheme(config.colors, "dark"), ...validateTheme(config.colors, "light")];
843429
+ }
843430
+ return [];
843431
+ }
843432
+ };
843433
+ }
843434
+ };
843435
+ function validateTheme(colors, theme) {
843436
+ const accentPrimaryColor = getColorFromRawConfig(colors.accentPrimary ?? colors.accentPrimaryDeprecated, "accent-primary", theme);
843437
+ let backgroundColor = getColorFromRawConfig(colors.background, "background", theme) ?? (theme === "dark" ? "#000" : "#FFF");
843438
+ const ruleViolations = [];
843439
+ if (!tinycolor(backgroundColor).isValid()) {
843440
+ ruleViolations.push({
843441
+ severity: "error",
843442
+ message: `Invalid background color provided for colors.background.${theme}: ${backgroundColor}.`
843443
+ });
843444
+ } else {
843445
+ const newBackground = enforceBackgroundTheme(tinycolor(backgroundColor), theme);
843446
+ if (tinycolor(backgroundColor).toHexString() !== newBackground.toHexString()) {
843447
+ ruleViolations.push({
843448
+ severity: "warning",
843449
+ message: `The provided background color for ${theme} mode is not ${theme} enough. It will be adjusted to ${newBackground.toHexString()}.`
843450
+ });
843451
+ }
843452
+ backgroundColor = newBackground.toHexString();
843453
+ }
843454
+ if (accentPrimaryColor == null) {
843455
+ ruleViolations.push({
843456
+ severity: "warning",
843457
+ message: `No accent-color provided for ${theme} mode. A random color will be used.`
843458
+ });
843459
+ } else if (!tinycolor(accentPrimaryColor).isValid()) {
843460
+ ruleViolations.push({
843461
+ severity: "error",
843462
+ message: `Invalid accent-color provided for colors.accent-primary.${theme}: ${accentPrimaryColor}.`
843463
+ });
843464
+ } else {
843465
+ const ratio = tinycolor.readability(accentPrimaryColor, backgroundColor);
843466
+ const readableRatio = `${ratio.toFixed(2)}:1`;
843467
+ if (ratio < 3) {
843468
+ ruleViolations.push({
843469
+ severity: "warning",
843470
+ message: `The contrast ratio between the accent color and the background color for ${theme} mode is ${readableRatio}. It should be at least 3:1.`
843471
+ });
843472
+ } else if (ratio < 4.5) {
843473
+ ruleViolations.push({
843474
+ severity: "warning",
843475
+ message: `The contrast ratio between the accent color and the background color for ${theme} mode is ${readableRatio}. Fern will adjust the color to meet the minimum contrast ratio of 4.5:1 for WCAG AA and 7:1 for WCAG AAA.`
843476
+ });
843477
+ } else if (ratio < 7) {
843478
+ ruleViolations.push({
843479
+ severity: "warning",
843480
+ message: `The contrast ratio between the accent color and the background color for ${theme} mode is ${readableRatio}. Fern will adjust the color to meet the minimum contrast ratio of 7:1 for WCAG AAA.`
843481
+ });
843482
+ }
843483
+ }
843484
+ return ruleViolations;
843485
+ }
843486
+ function enforceBackgroundTheme(color3, theme) {
843487
+ if (theme === "dark" && color3.isDark()) {
843488
+ return color3;
843489
+ } else if (theme === "light" && color3.isLight()) {
843490
+ return color3;
843491
+ }
843492
+ return getOppositeBrightness(color3);
843493
+ }
843494
+ function getOppositeBrightness(color3) {
843495
+ if (color3 == null) {
843496
+ return void 0;
843497
+ }
843498
+ const { h: h3, s: s2, v: v2 } = color3.toHsv();
843499
+ return tinycolor({ h: h3, s: s2, v: 1 - v2 });
843500
+ }
843501
+
843444
843502
  // pnp:/home/circleci/project/packages/cli/yaml/docs-validator/lib/rules/filepaths-exist/filepaths-exist.js
843445
843503
  var FilepathsExistRule = {
843446
843504
  name: "filepaths-exist",
@@ -868868,7 +868926,13 @@ var ValidateVersionFileRule = {
868868
868926
 
868869
868927
  // pnp:/home/circleci/project/packages/cli/yaml/docs-validator/lib/getAllRules.js
868870
868928
  function getAllRules2() {
868871
- return [FilepathsExistRule, ValidMarkdownRule, OnlyVersionedNavigation, ValidateVersionFileRule];
868929
+ return [
868930
+ FilepathsExistRule,
868931
+ ValidMarkdownRule,
868932
+ OnlyVersionedNavigation,
868933
+ ValidateVersionFileRule,
868934
+ AccentColorContrastRule
868935
+ ];
868872
868936
  }
868873
868937
 
868874
868938
  // pnp:/home/circleci/project/packages/cli/yaml/docs-validator/lib/validateDocsWorkspace.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.19.2",
3
+ "version": "0.19.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",