MCPcopy Index your code
hub / github.com/fontsource/fontsource / updateVariableCSS

Function updateVariableCSS

api/cdn/src/css.ts:100–176  ·  view source on GitHub ↗
(
	id: string,
	version: string,
	file: string,
	metadata: IDResponse,
	variableMeta: VariableMetadata,
	env: Env,
	ctx: ExecutionContext,
)

Source from the content-addressed store, hash-verified

98};
99
100export const updateVariableCSS = async (
101 id: string,
102 version: string,
103 file: string,
104 metadata: IDResponse,
105 variableMeta: VariableMetadata,
106 env: Env,
107 ctx: ExecutionContext,
108): Promise<string> => {
109 let css: string | undefined;
110 const { category, type } = metadata;
111 const tag = `${id}@${version}`;
112 const vfTag = `${id}:vf@${version}`;
113
114 const generateMeta = {
115 id,
116 ...generateVariableVariants(metadata, variableMeta),
117 };
118
119 // Icons are handled differently
120 if (category === 'icons' && type === 'google') {
121 const cssGenerate = generateIconVariableCSS(
122 generateMeta,
123 makeFontFileVariablePath,
124 vfTag,
125 );
126 for (const item of cssGenerate) {
127 // Reject index.css for variable fonts
128 if (item.filename === 'index.css') {
129 continue;
130 }
131
132 if (item.filename === file) {
133 css = item.css;
134
135 ctx.waitUntil(
136 env.CSS.put(keyGenV(tag, item.filename), item.css, {
137 metadata: {
138 ttl: Date.now() / 1000 + CSS_TTL,
139 },
140 }),
141 );
142 }
143 }
144 } else {
145 const cssGenerate = generateVariableCSS(
146 metadata,
147 generateMeta,
148 makeFontFileVariablePath,
149 vfTag,
150 );
151 for (const item of cssGenerate) {
152 // Reject index.css for variable fonts
153 if (item.filename === 'index.css') {
154 continue;
155 }
156
157 if (item.filename === file) {

Callers 1

router.tsFile · 0.90

Calls 7

generateVariableVariantsFunction · 0.90
generateIconVariableCSSFunction · 0.90
generateVariableCSSFunction · 0.90
keyGenVFunction · 0.85
nowMethod · 0.80
waitUntilMethod · 0.65
putMethod · 0.65

Tested by

no test coverage detected