Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capsizecss/core

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capsizecss/core - npm Package Compare versions

Comparing version 0.0.0-add-language-support-20231121023926 to 0.0.0-add-language-support-v2-20231129052138

22

dist/capsizecss-core.browser.cjs.js

@@ -267,11 +267,7 @@ 'use strict';

metrics,
fallbackMetrics,
language
fallbackMetrics
} = _ref;
const preferredAvgWidth = 'xWidthAvgByLang' in metrics ? metrics.xWidthAvgByLang[language] : metrics.xWidthAvg;
const fallbackAvgWidth = 'xWidthAvgByLang' in fallbackMetrics ? fallbackMetrics.xWidthAvgByLang[language] : fallbackMetrics.xWidthAvg;
// Calculate size adjust
const preferredFontXAvgRatio = preferredAvgWidth / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackAvgWidth / fallbackMetrics.unitsPerEm;
const preferredFontXAvgRatio = metrics.xWidthAvg / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackMetrics.xWidthAvg / fallbackMetrics.unitsPerEm;
const sizeAdjust = preferredFontXAvgRatio && fallbackFontXAvgRatio ? preferredFontXAvgRatio / fallbackFontXAvgRatio : 1;

@@ -347,9 +343,5 @@ const adjustedEmSquare = metrics.unitsPerEm * sizeAdjust;

let optionsArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (optionsArg.language && !metrics.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const {
fontFaceFormat,
fontFaceProperties,
language = 'en'
fontFaceProperties
} = _objectSpread2({

@@ -364,5 +356,2 @@ fontFaceFormat: 'styleString'

fallbackMetrics.forEach(fallback => {
if (optionsArg.language && !fallback.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const fontFamily = "".concat(familyName, " Fallback").concat(fallbackMetrics.length > 1 ? ": ".concat(fallback.familyName) : '');

@@ -376,4 +365,3 @@ fontFamilies.push(quoteIfNeeded(fontFamily));

metrics,
fallbackMetrics: fallback,
language
fallbackMetrics: fallback
})), fontFaceProperties !== null && fontFaceProperties !== void 0 && fontFaceProperties.sizeAdjust ? {

@@ -380,0 +368,0 @@ sizeAdjust: fontFaceProperties.sizeAdjust

@@ -263,11 +263,7 @@ function normaliseOptions(options) {

metrics,
fallbackMetrics,
language
fallbackMetrics
} = _ref;
const preferredAvgWidth = 'xWidthAvgByLang' in metrics ? metrics.xWidthAvgByLang[language] : metrics.xWidthAvg;
const fallbackAvgWidth = 'xWidthAvgByLang' in fallbackMetrics ? fallbackMetrics.xWidthAvgByLang[language] : fallbackMetrics.xWidthAvg;
// Calculate size adjust
const preferredFontXAvgRatio = preferredAvgWidth / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackAvgWidth / fallbackMetrics.unitsPerEm;
const preferredFontXAvgRatio = metrics.xWidthAvg / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackMetrics.xWidthAvg / fallbackMetrics.unitsPerEm;
const sizeAdjust = preferredFontXAvgRatio && fallbackFontXAvgRatio ? preferredFontXAvgRatio / fallbackFontXAvgRatio : 1;

@@ -343,9 +339,5 @@ const adjustedEmSquare = metrics.unitsPerEm * sizeAdjust;

let optionsArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (optionsArg.language && !metrics.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const {
fontFaceFormat,
fontFaceProperties,
language = 'en'
fontFaceProperties
} = _objectSpread2({

@@ -360,5 +352,2 @@ fontFaceFormat: 'styleString'

fallbackMetrics.forEach(fallback => {
if (optionsArg.language && !fallback.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const fontFamily = "".concat(familyName, " Fallback").concat(fallbackMetrics.length > 1 ? ": ".concat(fallback.familyName) : '');

@@ -372,4 +361,3 @@ fontFamilies.push(quoteIfNeeded(fontFamily));

metrics,
fallbackMetrics: fallback,
language
fallbackMetrics: fallback
})), fontFaceProperties !== null && fontFaceProperties !== void 0 && fontFaceProperties.sizeAdjust ? {

@@ -376,0 +364,0 @@ sizeAdjust: fontFaceProperties.sizeAdjust

@@ -267,11 +267,7 @@ 'use strict';

metrics,
fallbackMetrics,
language
fallbackMetrics
} = _ref;
const preferredAvgWidth = 'xWidthAvgByLang' in metrics ? metrics.xWidthAvgByLang[language] : metrics.xWidthAvg;
const fallbackAvgWidth = 'xWidthAvgByLang' in fallbackMetrics ? fallbackMetrics.xWidthAvgByLang[language] : fallbackMetrics.xWidthAvg;
// Calculate size adjust
const preferredFontXAvgRatio = preferredAvgWidth / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackAvgWidth / fallbackMetrics.unitsPerEm;
const preferredFontXAvgRatio = metrics.xWidthAvg / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackMetrics.xWidthAvg / fallbackMetrics.unitsPerEm;
const sizeAdjust = preferredFontXAvgRatio && fallbackFontXAvgRatio ? preferredFontXAvgRatio / fallbackFontXAvgRatio : 1;

@@ -347,9 +343,5 @@ const adjustedEmSquare = metrics.unitsPerEm * sizeAdjust;

let optionsArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (optionsArg.language && !metrics.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const {
fontFaceFormat,
fontFaceProperties,
language = 'en'
fontFaceProperties
} = _objectSpread2({

@@ -364,5 +356,2 @@ fontFaceFormat: 'styleString'

fallbackMetrics.forEach(fallback => {
if (optionsArg.language && !fallback.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const fontFamily = "".concat(familyName, " Fallback").concat(fallbackMetrics.length > 1 ? ": ".concat(fallback.familyName) : '');

@@ -376,4 +365,3 @@ fontFamilies.push(quoteIfNeeded(fontFamily));

metrics,
fallbackMetrics: fallback,
language
fallbackMetrics: fallback
})), fontFaceProperties !== null && fontFaceProperties !== void 0 && fontFaceProperties.sizeAdjust ? {

@@ -380,0 +368,0 @@ sizeAdjust: fontFaceProperties.sizeAdjust

@@ -267,11 +267,7 @@ 'use strict';

metrics,
fallbackMetrics,
language
fallbackMetrics
} = _ref;
const preferredAvgWidth = 'xWidthAvgByLang' in metrics ? metrics.xWidthAvgByLang[language] : metrics.xWidthAvg;
const fallbackAvgWidth = 'xWidthAvgByLang' in fallbackMetrics ? fallbackMetrics.xWidthAvgByLang[language] : fallbackMetrics.xWidthAvg;
// Calculate size adjust
const preferredFontXAvgRatio = preferredAvgWidth / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackAvgWidth / fallbackMetrics.unitsPerEm;
const preferredFontXAvgRatio = metrics.xWidthAvg / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackMetrics.xWidthAvg / fallbackMetrics.unitsPerEm;
const sizeAdjust = preferredFontXAvgRatio && fallbackFontXAvgRatio ? preferredFontXAvgRatio / fallbackFontXAvgRatio : 1;

@@ -347,9 +343,5 @@ const adjustedEmSquare = metrics.unitsPerEm * sizeAdjust;

let optionsArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (optionsArg.language && !metrics.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const {
fontFaceFormat,
fontFaceProperties,
language = 'en'
fontFaceProperties
} = _objectSpread2({

@@ -364,5 +356,2 @@ fontFaceFormat: 'styleString'

fallbackMetrics.forEach(fallback => {
if (optionsArg.language && !fallback.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const fontFamily = "".concat(familyName, " Fallback").concat(fallbackMetrics.length > 1 ? ": ".concat(fallback.familyName) : '');

@@ -376,4 +365,3 @@ fontFamilies.push(quoteIfNeeded(fontFamily));

metrics,
fallbackMetrics: fallback,
language
fallbackMetrics: fallback
})), fontFaceProperties !== null && fontFaceProperties !== void 0 && fontFaceProperties.sizeAdjust ? {

@@ -380,0 +368,0 @@ sizeAdjust: fontFaceProperties.sizeAdjust

@@ -263,11 +263,7 @@ function normaliseOptions(options) {

metrics,
fallbackMetrics,
language
fallbackMetrics
} = _ref;
const preferredAvgWidth = 'xWidthAvgByLang' in metrics ? metrics.xWidthAvgByLang[language] : metrics.xWidthAvg;
const fallbackAvgWidth = 'xWidthAvgByLang' in fallbackMetrics ? fallbackMetrics.xWidthAvgByLang[language] : fallbackMetrics.xWidthAvg;
// Calculate size adjust
const preferredFontXAvgRatio = preferredAvgWidth / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackAvgWidth / fallbackMetrics.unitsPerEm;
const preferredFontXAvgRatio = metrics.xWidthAvg / metrics.unitsPerEm;
const fallbackFontXAvgRatio = fallbackMetrics.xWidthAvg / fallbackMetrics.unitsPerEm;
const sizeAdjust = preferredFontXAvgRatio && fallbackFontXAvgRatio ? preferredFontXAvgRatio / fallbackFontXAvgRatio : 1;

@@ -343,9 +339,5 @@ const adjustedEmSquare = metrics.unitsPerEm * sizeAdjust;

let optionsArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (optionsArg.language && !metrics.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const {
fontFaceFormat,
fontFaceProperties,
language = 'en'
fontFaceProperties
} = _objectSpread2({

@@ -360,5 +352,2 @@ fontFaceFormat: 'styleString'

fallbackMetrics.forEach(fallback => {
if (optionsArg.language && !fallback.xWidthAvgByLang) {
throw new Error("Specifying the 'language' option is only available when the provided metrics contain `xWidthAvgByLang`. You may need to update the '@capsizecss/metrics' or '@capsizecss/unpack' package.");
}
const fontFamily = "".concat(familyName, " Fallback").concat(fallbackMetrics.length > 1 ? ": ".concat(fallback.familyName) : '');

@@ -372,4 +361,3 @@ fontFamilies.push(quoteIfNeeded(fontFamily));

metrics,
fallbackMetrics: fallback,
language
fallbackMetrics: fallback
})), fontFaceProperties !== null && fontFaceProperties !== void 0 && fontFaceProperties.sizeAdjust ? {

@@ -376,0 +364,0 @@ sizeAdjust: fontFaceProperties.sizeAdjust

import type { AtRule } from 'csstype';
import type { FontMetrics } from './types';
export declare const toCssProperty: (property: string) => string;
declare type FontStackMetrics = Pick<FontMetrics, 'familyName' | 'ascent' | 'descent' | 'lineGap' | 'unitsPerEm' | 'xWidthAvg' | 'xWidthAvgByLang'>;
declare type Language = keyof FontMetrics['xWidthAvgByLang'];
declare type FontStackMetrics = Pick<FontMetrics, 'familyName' | 'ascent' | 'descent' | 'lineGap' | 'unitsPerEm' | 'xWidthAvg'>;
export declare const quoteIfNeeded: (name: string) => string;

@@ -21,3 +20,2 @@ declare type FontFace = {

fontFaceProperties?: AdditionalFontFaceProperties;
language?: Language;
};

@@ -24,0 +22,0 @@ declare type FontFaceFormatString = {

@@ -1,2 +0,1 @@

declare type SupportedLanguage = 'en' | 'de' | 'es' | 'es' | 'fr' | 'id' | 'it' | 'th';
export interface FontMetrics {

@@ -25,4 +24,2 @@ /** The font family name as authored by font creator */

xWidthAvg: number;
/** The xWidthAvg as calculated for a subset of supported languages */
xWidthAvgByLang: Record<SupportedLanguage, number>;
}

@@ -29,0 +26,0 @@ export declare type ComputedValues = {

{
"name": "@capsizecss/core",
"version": "0.0.0-add-language-support-20231121023926",
"version": "0.0.0-add-language-support-v2-20231129052138",
"description": "Flipping how we define typography",

@@ -5,0 +5,0 @@ "main": "dist/capsizecss-core.cjs.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc