MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / rewriteInlineVars

Function rewriteInlineVars

packages/extension/utils/variable-output.ts:192–211  ·  view source on GitHub ↗
(
  style: Record<string, string>,
  replacements: Map<string, string>,
  { preserveInlineFallbacks = false }: VariableStyleOptions = {}
)

Source from the content-addressed store, hash-verified

190}
191
192function rewriteInlineVars(
193 style: Record<string, string>,
194 replacements: Map<string, string>,
195 { preserveInlineFallbacks = false }: VariableStyleOptions = {}
196): void {
197 if (!replacements.size) return
198
199 for (const [key, value] of Object.entries(style)) {
200 if (!value || !value.includes('var(')) continue
201
202 style[key] = replaceVarFunctions(value, ({ full, name, fallback }) => {
203 const replacement = replacements.get(normalizeCustomPropertyName(name.trim()))
204 if (!replacement) return full
205 if (preserveInlineFallbacks && fallback && replacement.startsWith('var(')) {
206 return replacement.replace(/\)$/, `, ${fallback})`)
207 }
208 return replacement
209 })
210 }
211}
212
213function applyBoundFields(
214 style: Record<string, string>,

Callers 1

applyVariableStyleFunction · 0.85

Calls 3

replaceVarFunctionsFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected