@tamagui/core 1.0.17 → 1.0.19

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createFont.ts"],
4
- "sourcesContent": ["import { FontWeightSteps, GenericFont } from './types'\n\nconst fontWeights: FontWeightSteps[] = [\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n]\n\nconst processSection = <T>(\n section: string | Record<string, T>,\n keys: string[],\n defaultValue?: any\n): string | Record<string, T> => {\n if (typeof section === 'string') return section\n\n const sectionKeys = Object.keys(section)\n let fillValue = section[sectionKeys[0]]\n\n return Object.fromEntries(\n [...new Set([...keys, ...sectionKeys])].map((key) => {\n const value = section[key] ?? defaultValue ?? fillValue\n fillValue = value\n defaultValue = value\n return [key, value]\n })\n )\n}\n\nexport const createFont = <A extends GenericFont>(font: A): A => {\n const sizeKeys = Object.keys(font.size)\n const processedFont = Object.fromEntries(\n Object.entries(font).map(([key, section]) => {\n return [\n key,\n processSection(\n section,\n key === 'face' ? fontWeights : sizeKeys,\n key === 'face' ? { normal: font.family } : undefined\n ),\n ]\n })\n )\n return Object.freeze(processedFont) as A\n}\n"],
4
+ "sourcesContent": ["import { FontWeightSteps, GenericFont } from './types'\n\nconst fontWeights: FontWeightSteps[] = [\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n]\n\nconst processSection = <T>(\n section: string | Record<string, T>,\n keys: string[],\n defaultValue?: any\n): string | Record<string, T> => {\n if (typeof section === 'string') return section\n\n const sectionKeys = Object.keys(section)\n let fillValue = section[sectionKeys[0]]\n\n return Object.fromEntries(\n [...new Set([...keys, ...sectionKeys])].map((key) => {\n const value = section[key] ?? defaultValue ?? fillValue\n fillValue = value\n defaultValue = value\n return [key, value]\n })\n )\n}\n\nexport const createFont = <A extends GenericFont>(font: A): A => {\n const sizeKeys = Object.keys(font.size)\n const processedFont = Object.fromEntries(\n Object.entries(font).map(([key, section]) => {\n return [\n key,\n processSection(\n section as any,\n key === 'face' ? fontWeights : sizeKeys,\n key === 'face' ? { normal: font.family } : undefined\n ),\n ]\n })\n )\n return Object.freeze(processedFont) as A\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,cAAiC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CACrB,SACA,MACA,iBAC+B;AAC/B,MAAI,OAAO,YAAY;AAAU,WAAO;AAExC,QAAM,cAAc,OAAO,KAAK,OAAO;AACvC,MAAI,YAAY,QAAQ,YAAY;AAEpC,SAAO,OAAO;AAAA,IACZ,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ;AACnD,YAAM,QAAQ,QAAQ,QAAQ,gBAAgB;AAC9C,kBAAY;AACZ,qBAAe;AACf,aAAO,CAAC,KAAK,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,aAAa,CAAwB,SAAe;AAC/D,QAAM,WAAW,OAAO,KAAK,KAAK,IAAI;AACtC,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,QAAQ,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,OAAO,MAAM;AAC3C,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE;AAAA,UACA,QAAQ,SAAS,cAAc;AAAA,UAC/B,QAAQ,SAAS,EAAE,QAAQ,KAAK,OAAO,IAAI;AAAA,QAC7C;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO,OAAO,OAAO,aAAa;AACpC;",
6
6
  "names": []
7
7
  }
@@ -159,6 +159,7 @@ function createTamagui(configIn) {
159
159
  animations: {},
160
160
  media: {},
161
161
  ...configIn,
162
+ tokens: configIn.tokens,
162
163
  shorthands: { ...shorthands },
163
164
  inverseShorthands: shorthands ? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k])) : {},
164
165
  themes: themeConfig.themes,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createTamagui.ts"],
4
- "sourcesContent": ["import { isRSC, isWeb } from '@tamagui/constants'\n\nimport { configListeners, setConfig } from './config'\nimport { createVariables, tokensKeysOrdered } from './createVariables'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport {\n getAllRules,\n listenForSheetChanges,\n scanAllSheets,\n} from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokensValueToVariable,\n variableToCSS,\n} from './helpers/registerCSSVariable'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport {\n CreateTamaguiProps,\n InferTamaguiConfig,\n TamaguiInternalConfig,\n ThemeParsed,\n} from './types'\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n configIn: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(configIn)) {\n return configIn as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!configIn.tokens) {\n throw new Error('Must define tokens')\n }\n if (!configIn.themes) {\n throw new Error('Must define themes')\n }\n if (!configIn.fonts) {\n throw new Error('Must define fonts')\n }\n }\n\n scanAllSheets()\n listenForSheetChanges()\n\n const fontTokens = Object.fromEntries(\n Object.entries(configIn.fonts!).map(([k, v]) => {\n return [k, createVariables(v, 'f', true)]\n })\n )\n\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...configIn.themes }\n const cssRuleSets: string[] = []\n\n if (isWeb) {\n const declarations: string[] = []\n const fontDeclarations: Record<\n string,\n { name: string; declarations: string[]; language?: string }\n > = {}\n\n for (const key in configIn.tokens) {\n for (const skey in configIn.tokens[key]) {\n const val = configIn.tokens[key][skey]\n registerCSSVariable(val)\n declarations.push(variableToCSS(val))\n }\n }\n\n for (const key in fontsParsed) {\n const fontParsed = fontsParsed[key]\n const [name, language] = key.includes('_') ? key.split('_') : [key]\n const fontVars = registerFontVariables(fontParsed)\n fontDeclarations[key] = {\n name: name.slice(1),\n declarations: fontVars,\n language,\n }\n }\n\n const sep =\n process.env.NODE_ENV === 'development' ? configIn.cssStyleSeparator || ' ' : ''\n\n function declarationsToRuleSet(decs: string[], selector = '') {\n return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`\n }\n\n // non-font\n cssRuleSets.push(declarationsToRuleSet(declarations))\n\n // fonts\n if (fontDeclarations) {\n for (const key in fontDeclarations) {\n const { name, declarations, language = 'default' } = fontDeclarations[key]\n const fontSelector = `.font_${name}`\n const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`\n const selectors =\n language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector\n const specificRuleSet = declarationsToRuleSet(declarations, selectors)\n cssRuleSets.push(specificRuleSet)\n }\n }\n }\n\n // dedupe themes to avoid duplicate CSS generation\n type DedupedTheme = {\n names: string[]\n theme: ThemeParsed\n }\n const dedupedThemes: {\n [key: string]: DedupedTheme\n } = {}\n const existing = new WeakMap<ThemeParsed, DedupedTheme>()\n\n // first, de-dupe and parse them\n for (const themeName in themes) {\n const rawTheme = themes[themeName] as ThemeParsed\n\n // if existing, avoid\n if (existing.has(rawTheme)) {\n const e = existing.get(rawTheme)!\n themes[themeName] = e.theme\n e.names.push(themeName)\n continue\n }\n\n // ensure each theme object unique for dedupe\n const theme = { ...rawTheme }\n // parse into variables\n for (const key in theme) {\n // make sure properly names theme variables\n ensureThemeVariable(theme, key)\n }\n themes[themeName] = theme\n\n // set deduped\n dedupedThemes[themeName] = {\n names: [themeName],\n theme,\n }\n existing.set(rawTheme, dedupedThemes[themeName])\n }\n\n // then, generate CSS from de-duped\n let themeRuleSets: string[] = []\n\n if (isWeb || isRSC) {\n for (const themeName in dedupedThemes) {\n themeRuleSets = [\n ...themeRuleSets,\n ...getThemeCSSRules({\n config: configIn,\n themeName,\n ...dedupedThemes[themeName],\n }),\n ]\n }\n }\n\n // proxy upwards to get parent variables (themes are subset going down)\n for (const themeName in themes) {\n themes[themeName] = proxyThemeToParents(themeName, themes[themeName], themes)\n }\n\n tokensValueToVariable.clear()\n\n return {\n themes,\n cssRuleSets,\n themeRuleSets,\n }\n })()\n\n // faster $lookups\n const tokensParsed: any = Object.fromEntries(\n Object.entries(configIn.tokens).map(([k, v]) => {\n const val = Object.fromEntries(Object.entries(v).map(([k, v]) => [`$${k}`, v]))\n tokensKeysOrdered.set(val, tokensKeysOrdered.get(v))\n return [k, val]\n })\n )\n\n const shorthands = configIn.shorthands || {}\n\n const config: TamaguiInternalConfig = {\n fontLanguages: [],\n animations: {} as any,\n media: {},\n ...configIn,\n // vite made this into a function if it wasn't set\n shorthands: { ...shorthands },\n inverseShorthands: shorthands\n ? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k]))\n : {},\n themes: themeConfig.themes as any,\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS: (separator = '\\n') => {\n return `.t_unmounted .t_will-mount {opacity:0;visibility:hidden;}\n.is_Text .is_Text {display:inline-flex;}\n._dsp_contents {display:contents;}\n${themeConfig.cssRuleSets.join(separator)}\n${themeConfig.themeRuleSets.join(separator)}\n${getAllRules().join(separator)}`\n },\n // const tokens = [...getToken(tokens.size[0])]\n // .spacer-sm + ._dsp_contents._dsp-sm-hidden { margin-left: -var(--${}) }\n }\n\n configureMedia(config)\n setConfig(config)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(config))\n configListeners.clear()\n }\n\n createdConfigs.set(config, true)\n\n if (process.env.NODE_ENV === 'development') {\n if (process.env.DEBUG?.startsWith('tamagui')) {\n // eslint-disable-next-line no-console\n console.log('Tamagui config:', config)\n }\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n }\n\n return config as any\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA6B;AAE7B,oBAA2C;AAC3C,6BAAmD;AACnD,8BAAiC;AACjC,6BAIO;AACP,iCAIO;AACP,oBAAyD;AACzD,sBAA+B;AAC/B,wBAAiD;AACjD,qBAAwB;AASxB,MAAM,iBAAiB,oBAAI,QAAsB;AAE1C,SAAS,cACd,UAC0B;AA/B5B;AAgCE,MAAI,eAAe,IAAI,QAAQ,GAAG;AAChC,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,SAAS,QAAQ;AACpB,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AACA,QAAI,CAAC,SAAS,QAAQ;AACpB,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AACA,QAAI,CAAC,SAAS,OAAO;AACnB,YAAM,IAAI,MAAM,mBAAmB;AAAA,IACrC;AAAA,EACF;AAEA,4CAAc;AACd,oDAAsB;AAEtB,QAAM,aAAa,OAAO;AAAA,IACxB,OAAO,QAAQ,SAAS,KAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM;AAC9C,aAAO,CAAC,OAAG,wCAAgB,GAAG,KAAK,IAAI,CAAC;AAAA,IAC1C,CAAC;AAAA,EACH;AAEA,QAAM,eAAe,MAAM;AACzB,UAAM,MAAM,CAAC;AACb,eAAW,cAAc,YAAY;AACnC,UAAI,IAAI,oBAAgB,6BAAU,WAAW,WAAW;AAAA,IAC1D;AACA,WAAO;AAAA,EACT,GAAG;AAEH,QAAM,eAAe,MAAM;AACzB,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,IAChB,CAAC;AAAA,EACH;AAEA,QAAM,aAAa,SAAS,cAAc,CAAC;AAE3C,QAAM,SAAgC;AAAA,IACpC,eAAe,CAAC;AAAA,IAChB,YAAY,CAAC;AAAA,IACb,OAAO,CAAC;AAAA,IACR,GAAG;AAAA,IAEH,YAAY,EAAE,GAAG,WAAW;AAAA,IAC5B,mBAAmB,aACf,OAAO,YAAY,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IACrE,CAAC;AAAA,IACL,QAAQ,YAAY;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ,CAAC,YAAY,SAAS;AAC5B,aAAO;AAAA;AAAA;AAAA,EAGX,YAAY,YAAY,KAAK,SAAS;AAAA,EACtC,YAAY,cAAc,KAAK,SAAS;AAAA,MACxC,oCAAY,EAAE,KAAK,SAAS;AAAA,IAC1B;AAAA,EAGF;AAEA,sCAAe,MAAM;AACrB,+BAAU,MAAM;AAEhB,MAAI,8BAAgB,MAAM;AACxB,kCAAgB,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;AAC1C,kCAAgB,MAAM;AAAA,EACxB;AAEA,iBAAe,IAAI,QAAQ,IAAI;AAE/B,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,SAAI,aAAQ,IAAI,UAAZ,mBAAmB,WAAW,YAAY;AAE5C,cAAQ,IAAI,mBAAmB,MAAM;AAAA,IACvC;AACA,QAAI,CAAC,WAAW,YAAY;AAC1B,iBAAW,aAAa;AAAA,IAC1B;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isRSC, isWeb } from '@tamagui/constants'\n\nimport { configListeners, setConfig } from './config'\nimport { createVariables, tokensKeysOrdered } from './createVariables'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport {\n getAllRules,\n listenForSheetChanges,\n scanAllSheets,\n} from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokensValueToVariable,\n variableToCSS,\n} from './helpers/registerCSSVariable'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport {\n CreateTamaguiProps,\n InferTamaguiConfig,\n TamaguiInternalConfig,\n ThemeParsed,\n} from './types'\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n configIn: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(configIn)) {\n return configIn as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!configIn.tokens) {\n throw new Error('Must define tokens')\n }\n if (!configIn.themes) {\n throw new Error('Must define themes')\n }\n if (!configIn.fonts) {\n throw new Error('Must define fonts')\n }\n }\n\n scanAllSheets()\n listenForSheetChanges()\n\n const fontTokens = Object.fromEntries(\n Object.entries(configIn.fonts!).map(([k, v]) => {\n return [k, createVariables(v, 'f', true)]\n })\n )\n\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...configIn.themes }\n const cssRuleSets: string[] = []\n\n if (isWeb) {\n const declarations: string[] = []\n const fontDeclarations: Record<\n string,\n { name: string; declarations: string[]; language?: string }\n > = {}\n\n for (const key in configIn.tokens) {\n for (const skey in configIn.tokens[key]) {\n const val = configIn.tokens[key][skey]\n registerCSSVariable(val)\n declarations.push(variableToCSS(val))\n }\n }\n\n for (const key in fontsParsed) {\n const fontParsed = fontsParsed[key]\n const [name, language] = key.includes('_') ? key.split('_') : [key]\n const fontVars = registerFontVariables(fontParsed)\n fontDeclarations[key] = {\n name: name.slice(1),\n declarations: fontVars,\n language,\n }\n }\n\n const sep =\n process.env.NODE_ENV === 'development' ? configIn.cssStyleSeparator || ' ' : ''\n\n function declarationsToRuleSet(decs: string[], selector = '') {\n return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`\n }\n\n // non-font\n cssRuleSets.push(declarationsToRuleSet(declarations))\n\n // fonts\n if (fontDeclarations) {\n for (const key in fontDeclarations) {\n const { name, declarations, language = 'default' } = fontDeclarations[key]\n const fontSelector = `.font_${name}`\n const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`\n const selectors =\n language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector\n const specificRuleSet = declarationsToRuleSet(declarations, selectors)\n cssRuleSets.push(specificRuleSet)\n }\n }\n }\n\n // dedupe themes to avoid duplicate CSS generation\n type DedupedTheme = {\n names: string[]\n theme: ThemeParsed\n }\n const dedupedThemes: {\n [key: string]: DedupedTheme\n } = {}\n const existing = new WeakMap<ThemeParsed, DedupedTheme>()\n\n // first, de-dupe and parse them\n for (const themeName in themes) {\n const rawTheme = themes[themeName] as ThemeParsed\n\n // if existing, avoid\n if (existing.has(rawTheme)) {\n const e = existing.get(rawTheme)!\n themes[themeName] = e.theme\n e.names.push(themeName)\n continue\n }\n\n // ensure each theme object unique for dedupe\n const theme = { ...rawTheme }\n // parse into variables\n for (const key in theme) {\n // make sure properly names theme variables\n ensureThemeVariable(theme, key)\n }\n themes[themeName] = theme\n\n // set deduped\n dedupedThemes[themeName] = {\n names: [themeName],\n theme,\n }\n existing.set(rawTheme, dedupedThemes[themeName])\n }\n\n // then, generate CSS from de-duped\n let themeRuleSets: string[] = []\n\n if (isWeb || isRSC) {\n for (const themeName in dedupedThemes) {\n themeRuleSets = [\n ...themeRuleSets,\n ...getThemeCSSRules({\n config: configIn,\n themeName,\n ...dedupedThemes[themeName],\n }),\n ]\n }\n }\n\n // proxy upwards to get parent variables (themes are subset going down)\n for (const themeName in themes) {\n themes[themeName] = proxyThemeToParents(themeName, themes[themeName], themes)\n }\n\n tokensValueToVariable.clear()\n\n return {\n themes,\n cssRuleSets,\n themeRuleSets,\n }\n })()\n\n // faster $lookups\n const tokensParsed: any = Object.fromEntries(\n Object.entries(configIn.tokens).map(([k, v]) => {\n const val = Object.fromEntries(Object.entries(v).map(([k, v]) => [`$${k}`, v]))\n tokensKeysOrdered.set(val, tokensKeysOrdered.get(v))\n return [k, val]\n })\n )\n\n const shorthands = configIn.shorthands || {}\n\n const config: TamaguiInternalConfig = {\n fontLanguages: [],\n animations: {} as any,\n media: {},\n ...configIn,\n // already processed by createTokens()\n tokens: configIn.tokens as any,\n // vite made this into a function if it wasn't set\n shorthands: { ...shorthands },\n inverseShorthands: shorthands\n ? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k]))\n : {},\n themes: themeConfig.themes as any,\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS: (separator = '\\n') => {\n return `.t_unmounted .t_will-mount {opacity:0;visibility:hidden;}\n.is_Text .is_Text {display:inline-flex;}\n._dsp_contents {display:contents;}\n${themeConfig.cssRuleSets.join(separator)}\n${themeConfig.themeRuleSets.join(separator)}\n${getAllRules().join(separator)}`\n },\n // const tokens = [...getToken(tokens.size[0])]\n // .spacer-sm + ._dsp_contents._dsp-sm-hidden { margin-left: -var(--${}) }\n }\n\n configureMedia(config)\n setConfig(config)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(config))\n configListeners.clear()\n }\n\n createdConfigs.set(config, true)\n\n if (process.env.NODE_ENV === 'development') {\n if (process.env.DEBUG?.startsWith('tamagui')) {\n // eslint-disable-next-line no-console\n console.log('Tamagui config:', config)\n }\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n }\n\n return config as any\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA6B;AAE7B,oBAA2C;AAC3C,6BAAmD;AACnD,8BAAiC;AACjC,6BAIO;AACP,iCAIO;AACP,oBAAyD;AACzD,sBAA+B;AAC/B,w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A,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ,CAAC,YAAY,SAAS;AAC5B,aAAO;AAAA;AAAA;AAAA,EAGX,YAAY,YAAY,KAAK,SAAS;AAAA,EACtC,YAAY,cAAc,KAAK,SAAS;AAAA,MACxC,oCAAY,EAAE,KAAK,SAAS;AAAA,IAC1B;AAAA,EAGF;AAEA,sCAAe,MAAM;AACrB,+BAAU,MAAM;AAEhB,MAAI,8BAAgB,MAAM;AACxB,kCAAgB,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;AAC1C,kCAAgB,MAAM;AAAA,EACxB;AAEA,iBAAe,IAAI,QAAQ,IAAI;AAE/B,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,SAAI,aAAQ,IAAI,UAAZ,mBAAmB,WAAW,YAAY;AAE5C,cAAQ,IAAI,mBAAmB,MAAM;AAAA,IACvC;AACA,QAAI,CAAC,WAAW,YAAY;AAC1B,iBAAW,aAAa;AAAA,IAC1B;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": ["declarationsToRuleSet", "declarations", "k", "v"]
7
7
  }
@@ -22,9 +22,16 @@ __export(createTokens_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(createTokens_exports);
24
24
  var import_createVariables = require("./createVariables");
25
- function createTokens(tokens) {
26
- return (0, import_createVariables.createVariables)(tokens);
25
+ function createTokens(tokens2) {
26
+ return (0, import_createVariables.createVariables)(tokens2);
27
27
  }
28
+ const tokens = createTokens({
29
+ size: { 0: 1 },
30
+ space: { 0: 1 },
31
+ radius: { 0: 1 },
32
+ zIndex: { 0: 1 },
33
+ color: { 0: "hi" }
34
+ });
28
35
  // Annotate the CommonJS export names for ESM import in node:
29
36
  0 && (module.exports = {
30
37
  createTokens
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createTokens.ts"],
4
- "sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n return createVariables(tokens) as any\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n [Key in keyof E]: E[Key] extends Variable ? E[Key] : Variable<E[Key]>\n }\n space: {\n [Key in keyof F]: F[Key] extends Variable ? F[Key] : Variable<F[Key]>\n }\n size: {\n [Key in keyof G]: G[Key] extends Variable ? G[Key] : Variable<G[Key]>\n }\n radius: {\n [Key in keyof H]: H[Key] extends Variable ? H[Key] : Variable<H[Key]>\n }\n zIndex: {\n [Key in keyof J]: J[Key] extends Variable ? J[Key] : Variable<J[Key]>\n }\n }\n : never\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAAgC;AAIzB,SAAS,aAAqC,QAA0B;AAC7E,aAAO,wCAAgB,MAAM;AAC/B;",
6
- "names": []
4
+ "sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n return createVariables(tokens) as any\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n // removes $ prefix allowing for defining either as $1: or 1:,\n // which is important because Chrome re-orders numerical-seeming keys :/\n [Key in keyof E extends `$${infer X}` ? X : keyof E]: Variable<string>\n }\n space: {\n [Key in keyof F extends `$${infer X}` ? X : keyof F]: Variable<number>\n }\n size: {\n [Key in keyof G extends `$${infer X}` ? X : keyof G]: Variable<number>\n }\n radius: {\n [Key in keyof H extends `$${infer X}` ? X : keyof H]: Variable<number>\n }\n zIndex: {\n [Key in keyof J extends `$${infer X}` ? X : keyof J]: Variable<number>\n }\n }\n : never\n\n// test\nconst tokens = createTokens({\n size: { 0: 1 },\n space: { 0: 1 },\n radius: { 0: 1 },\n zIndex: { 0: 1 },\n color: { 0: 'hi' },\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAAgC;AAIzB,SAAS,aAAqCA,SAA0B;AAC7E,aAAO,wCAAgBA,OAAM;AAC/B;AAgCA,MAAM,SAAS,aAAa;AAAA,EAC1B,MAAM,EAAE,GAAG,EAAE;AAAA,EACb,OAAO,EAAE,GAAG,EAAE;AAAA,EACd,QAAQ,EAAE,GAAG,EAAE;AAAA,EACf,QAAQ,EAAE,GAAG,EAAE;AAAA,EACf,OAAO,EAAE,GAAG,KAAK;AACnB,CAAC;",
6
+ "names": ["tokens"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createVariable.ts"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = 'isVar'\n\ntype VariableIn<A = any> = {\n val: A\n name: string\n key: string\n}\n\nexport type Variable<A = any> = VariableIn<A> & {\n [IS_VAR]?: true\n variable?: string\n}\n\nexport const createVariable = <A extends string | number = any>(props: VariableIn<A>) => {\n if (isVariable(props)) return props\n const { key, name, val } = props\n return {\n [IS_VAR]: true,\n key,\n name: simpleHash(name, 40),\n val,\n variable: isWeb ? createCSSVariable(name) : '',\n }\n}\n\n// could do weakmap cache\nexport function variableToString(vrble?: any, getValue = false) {\n if (isVariable(vrble)) {\n if (!getValue && isWeb && vrble.variable) {\n return vrble.variable\n }\n return `${vrble.val}`\n }\n return `${vrble || ''}`\n}\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v && typeof v === 'object' && IS_VAR in v\n}\n\nexport function getVariable(nameOrVariable: Variable | string) {\n setDidGetVariableValue(true)\n if (isVariable(nameOrVariable)) {\n return variableToString(nameOrVariable)\n }\n const tokens = getConfig().tokensParsed\n return variableToString(tokens[nameOrVariable] ?? nameOrVariable)\n}\n\nlet accessed = false\nexport const setDidGetVariableValue = (val: boolean) => (accessed = val)\nexport const didGetVariableValue = () => accessed\n\nexport function getVariableValue(v: Variable | any) {\n if (isVariable(v)) {\n setDidGetVariableValue(true)\n return v.val\n }\n return v\n}\n\nexport function getVariableName(v: Variable | any) {\n if (isVariable(v)) return v.name\n return v\n}\n\nexport function getVariableVariable(v: Variable | any) {\n if (isVariable(v)) return v.variable\n return v\n}\n\n// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):\nexport const createCSSVariable = (nameProp: string, includeVar = true) => {\n if (process.env.NODE_ENV === 'development') {\n if (!nameProp || typeof nameProp !== 'string') {\n throw new Error(`createCSSVariable expected string: ${nameProp}`)\n }\n }\n const name = simpleHash(nameProp, 60)\n return includeVar ? `var(--${name})` : name\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,qBAA2B;AAE3B,oBAA0B;AAO1B,MAAM,SAAS;AAaR,MAAM,iBAAiB,CAAkC,UAAyB;AACvF,MAAI,WAAW,KAAK;AAAG,WAAO;AAC9B,QAAM,EAAE,KAAK,MAAM,IAAI,IAAI;AAC3B,SAAO;AAAA,IACL,CAAC,SAAS;AAAA,IACV;AAAA,IACA,UAAM,2BAAW,MAAM,EAAE;AAAA,IACzB;AAAA,IACA,UAAU,yBAAQ,kBAAkB,IAAI,IAAI;AAAA,EAC9C;AACF;AAGO,SAAS,iBAAiB,OAAa,WAAW,OAAO;AAC9D,MAAI,WAAW,KAAK,GAAG;AACrB,QAAI,CAAC,YAAY,0BAAS,MAAM,UAAU;AACxC,aAAO,MAAM;AAAA,IACf;AACA,WAAO,GAAG,MAAM;AAAA,EAClB;AACA,SAAO,GAAG,SAAS;AACrB;AAEO,SAAS,WAAW,GAAkC;AAC3D,SAAO,KAAK,OAAO,MAAM,YAAY,UAAU;AACjD;AAEO,SAAS,YAAY,gBAAmC;AAC7D,yBAAuB,IAAI;AAC3B,MAAI,WAAW,cAAc,GAAG;AAC9B,WAAO,iBAAiB,cAAc;AAAA,EACxC;AACA,QAAM,aAAS,yBAAU,EAAE;AAC3B,SAAO,iBAAiB,OAAO,mBAAmB,cAAc;AAClE;AAEA,IAAI,WAAW;AACR,MAAM,yBAAyB,CAAC,QAAkB,WAAW;AAC7D,MAAM,sBAAsB,MAAM;AAElC,SAAS,iBAAiB,GAAmB;AAClD,MAAI,WAAW,CAAC,GAAG;AACjB,2BAAuB,IAAI;AAC3B,WAAO,EAAE;AAAA,EACX;AACA,SAAO;AACT;AAEO,SAAS,gBAAgB,GAAmB;AACjD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAEO,SAAS,oBAAoB,GAAmB;AACrD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAGO,MAAM,oBAAoB,CAAC,UAAkB,aAAa,SAAS;AACxE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,YAAY,OAAO,aAAa,UAAU;AAC7C,YAAM,IAAI,MAAM,sCAAsC,UAAU;AAAA,IAClE;AAAA,EACF;AACA,QAAM,WAAO,2BAAW,UAAU,EAAE;AACpC,SAAO,aAAa,SAAS,UAAU;AACzC;",
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = 'isVar'\n\nexport interface Variable<A = any> {\n [IS_VAR]?: true\n variable?: string\n val: A\n name: string\n key: string\n}\n\nexport type MakeVariable<A = any> = A extends string | number ? Variable<A> : A\n\ntype VariableIn<A = any> = Pick<Variable<A>, 'key' | 'name' | 'val'>\nexport const createVariable = <A extends string | number = any>(\n props: VariableIn<A>\n): Variable<A> => {\n if (isVariable(props)) return props\n const { key, name, val } = props\n return {\n [IS_VAR]: true,\n key: key!,\n name: simpleHash(name, 40),\n val: val as any,\n variable: isWeb ? createCSSVariable(name) : '',\n }\n}\n\n// could do weakmap cache\nexport function variableToString(vrble?: any, getValue = false) {\n if (isVariable(vrble)) {\n if (!getValue && isWeb && vrble.variable) {\n return vrble.variable\n }\n return `${vrble.val}`\n }\n return `${vrble || ''}`\n}\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v && typeof v === 'object' && IS_VAR in v\n}\n\nexport function getVariable(nameOrVariable: Variable | string) {\n setDidGetVariableValue(true)\n if (isVariable(nameOrVariable)) {\n return variableToString(nameOrVariable)\n }\n const tokens = getConfig().tokensParsed\n return variableToString(tokens[nameOrVariable] ?? nameOrVariable)\n}\n\nlet accessed = false\nexport const setDidGetVariableValue = (val: boolean) => (accessed = val)\nexport const didGetVariableValue = () => accessed\n\nexport function getVariableValue(v: Variable | any) {\n if (isVariable(v)) {\n setDidGetVariableValue(true)\n return v.val\n }\n return v\n}\n\nexport function getVariableName(v: Variable | any) {\n if (isVariable(v)) return v.name\n return v\n}\n\nexport function getVariableVariable(v: Variable | any) {\n if (isVariable(v)) return v.variable\n return v\n}\n\n// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):\nexport const createCSSVariable = (nameProp: string, includeVar = true) => {\n if (process.env.NODE_ENV === 'development') {\n if (!nameProp || typeof nameProp !== 'string') {\n throw new Error(`createCSSVariable expected string: ${nameProp}`)\n }\n }\n const name = simpleHash(nameProp, 60)\n return includeVar ? `var(--${name})` : name\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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;AACT;AAGO,MAAM,oBAAoB,CAAC,UAAkB,aAAa,SAAS;AACxE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,YAAY,OAAO,aAAa,UAAU;AAC7C,YAAM,IAAI,MAAM,sCAAsC,UAAU;AAAA,IAClE;AAAA,EACF;AACA,QAAM,WAAO,2BAAW,UAAU,EAAE;AACpC,SAAO,aAAa,SAAS,UAAU;AACzC;",
6
6
  "names": []
7
7
  }
@@ -49,20 +49,19 @@ function proxyThemeToParents(themeName, theme, themes) {
49
49
  cur.push(part);
50
50
  return cur.join("_");
51
51
  });
52
- const hasParents = parents.length;
52
+ const len = parents.length;
53
53
  return new Proxy(theme, {
54
54
  get(target, key) {
55
55
  if (key === import_getThemeUnwrapped.GetThemeUnwrapped) {
56
56
  return theme;
57
57
  }
58
- if (!hasParents || Reflect.has(target, key)) {
58
+ if (!len || Reflect.has(target, key)) {
59
59
  return Reflect.get(target, key);
60
60
  }
61
- for (let i = parents.length - 1; i >= 0; i--) {
61
+ for (let i = len - 1; i >= 0; i--) {
62
62
  const parent = themes[parents[i]];
63
- if (!parent) {
63
+ if (!parent)
64
64
  continue;
65
- }
66
65
  if (Reflect.has(parent, key)) {
67
66
  return Reflect.get(parent, key);
68
67
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/themes.ts"],
4
- "sourcesContent": ["import { createVariable, isVariable } from '../createVariable'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { CreateTamaguiProps } from '../types'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const hasParents = parents.length\n\n // proxy fallback values to parent theme values\n return new Proxy(theme, {\n get(target, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (!hasParents || Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n // check parents\n for (let i = parents.length - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) {\n continue\n }\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n return Reflect.get(target, key)\n },\n })\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA2C;AAC3C,+BAAkC;AAK3B,SAAS,oBAAoB,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM;AAClB,QAAM,WAAW;AACjB,MAAI,KAAC,kCAAW,GAAG,GAAG;AACpB,UAAM,WAAO,sCAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,WAAO,sCAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACA,OACA,QACA;AAEA,QAAM,MAAgB,CAAC;AAGvB,QAAM,UAAU,UACb,MAAM,GAAG,EACT,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,IAAI;AACb,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB,CAAC;AAEH,QAAM,aAAa,QAAQ;AAG3B,SAAO,IAAI,MAAM,OAAO;AAAA,IACtB,IAAI,QAAQ,KAAK;AACf,UAAI,QAAQ,4CAAmB;AAC7B,eAAO;AAAA,MACT;AACA,UAAI,CAAC,cAAc,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC3C,eAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,MAChC;AAEA,eAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AAC5C,cAAM,SAAS,OAAO,QAAQ;AAC9B,YAAI,CAAC,QAAQ;AACX;AAAA,QACF;AACA,YAAI,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC5B,iBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,QAChC;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAChC;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import { createVariable, isVariable } from '../createVariable'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { CreateTamaguiProps } from '../types'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const len = parents.length\n\n // proxy fallback values to parent theme values\n return new Proxy(theme, {\n get(target, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (!len || Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n // check parents\n for (let i = len - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) continue\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n return Reflect.get(target, key)\n },\n })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA2C;AAC3C,+BAAkC;AAK3B,SAAS,oBAAoB,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM;AAClB,QAAM,WAAW;AACjB,MAAI,KAAC,kCAAW,GAAG,GAAG;AACpB,UAAM,WAAO,sCAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,WAAO,sCAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACA,OACA,QACA;AAEA,QAAM,MAAgB,CAAC;AAGvB,QAAM,UAAU,UACb,MAAM,GAAG,EACT,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,IAAI;AACb,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB,CAAC;AAEH,QAAM,MAAM,QAAQ;AAGpB,SAAO,IAAI,MAAM,OAAO;AAAA,IACtB,IAAI,QAAQ,KAAK;AACf,UAAI,QAAQ,4CAAmB;AAC7B,eAAO;AAAA,MACT;AACA,UAAI,CAAC,OAAO,QAAQ,IAAI,QAAQ,GAAG,GAAG;AACpC,eAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,MAChC;AAEA,eAAS,IAAI,MAAM,GAAG,KAAK,GAAG,KAAK;AACjC,cAAM,SAAS,OAAO,QAAQ;AAC9B,YAAI,CAAC;AAAQ;AACb,YAAI,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC5B,iBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,QAChC;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAChC;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.tsx"],
4
- "sourcesContent": ["// TODO split this into own package @tamagui/types to share with animations packages\n\nimport type { Properties } from 'csstype'\nimport type {\n ComponentType,\n ForwardRefExoticComponent,\n FunctionComponent,\n HTMLAttributes,\n ReactNode,\n RefAttributes,\n RefObject,\n} from 'react'\nimport type {\n Image,\n PressableProps,\n TextProps as ReactTextProps,\n Text,\n TextInput,\n TextStyle,\n View,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport type { Variable } from './createVariable'\nimport type { ResolveVariableTypes } from './helpers/createPropMapper'\nimport type { TamaguiReactElement } from './static'\nimport type { RNWTextProps, RNWViewProps } from './types-rnw'\nimport type { FontLanguageProps } from './views/FontLanguage.types'\nimport type { ThemeProviderProps } from './views/ThemeProvider'\n\nexport type SpaceDirection = 'vertical' | 'horizontal' | 'both'\n\nexport type TamaguiElement = HTMLElement | View\n\nexport type DebugProp = boolean | 'break' | 'verbose'\n\n// base props that are accepted by createComponent (additional to react-native-web)\n\ntype DivAttributes = HTMLAttributes<HTMLDivElement>\n\nexport type TamaguiComponentPropsBase = {\n hitSlop?: PressableProps['hitSlop']\n asChild?: boolean\n space?: SpaceTokens | null\n spaceDirection?: SpaceDirection\n separator?: ReactNode\n dangerouslySetInnerHTML?: { __html: string }\n animation?: AnimationProp | null\n animateOnly?: string[]\n children?: any | any[]\n debug?: DebugProp\n disabled?: boolean\n className?: string\n themeShallow?: boolean\n id?: string\n tag?: string\n theme?: ThemeName | null\n componentName?: string\n /**\n * Forces the pseudo style state to be on\n */\n forceStyle?: 'hover' | 'press' | 'focus'\n onHoverIn?: DivAttributes['onMouseEnter']\n onHoverOut?: DivAttributes['onMouseLeave']\n onPress?: PressableProps['onPress']\n onPressIn?: PressableProps['onPress']\n onPressOut?: PressableProps['onPress']\n // WEB ONLY\n onMouseEnter?: DivAttributes['onMouseEnter']\n onMouseLeave?: DivAttributes['onMouseLeave']\n onMouseDown?: DivAttributes['onMouseDown']\n}\n\nexport type ReactComponentWithRef<Props, Ref> = ForwardRefExoticComponent<\n Props & RefAttributes<Ref>\n>\n\nexport type ConfigListener = (conf: TamaguiInternalConfig) => void\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport type VariableVal = number | string | Variable\nexport type VariableColorVal = string | Variable\n\ntype GenericKey = string | number | symbol\n\nexport interface CreateTokens<Val extends VariableVal = VariableVal> {\n color: { [key: GenericKey]: Val }\n space: { [key: GenericKey]: Val }\n size: { [key: GenericKey]: Val }\n radius: { [key: GenericKey]: Val }\n zIndex: { [key: GenericKey]: Val }\n}\n\nexport type TamaguiBaseTheme = {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n background: VariableColorVal\n backgroundHover: VariableColorVal\n backgroundPress: VariableColorVal\n backgroundFocus: VariableColorVal\n color: VariableColorVal\n colorHover: VariableColorVal\n colorPress: VariableColorVal\n colorFocus: VariableColorVal\n borderColor: VariableColorVal\n borderColorHover: VariableColorVal\n borderColorPress: VariableColorVal\n borderColorFocus: VariableColorVal\n shadowColor: VariableColorVal\n shadowColorHover: VariableColorVal\n shadowColorPress: VariableColorVal\n shadowColorFocus: VariableColorVal\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]:\n | Partial<TamaguiBaseTheme> & {\n [key: string]: VariableVal\n }\n}\n\ntype AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase\n\nexport type CreateShorthands = {\n [key: string]: AllStyleKeys\n}\n\nexport type GenericShorthands = {}\n\n// sm: { minWidth: 100 }\ntype GenericMedia = {\n [key: string]: {\n [key: string]: number | string\n }\n}\n\nexport type GenericFonts = Record<string, GenericFont>\n\ntype GenericAnimations = {\n [key: string]:\n | string\n | {\n [key: string]: any\n }\n | any[]\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n fonts: RemoveLanguagePostfixes<F>\n fontLanguages: GetLanguagePostfixes<F> extends never\n ? string[]\n : GetLanguagePostfixes<F>[]\n tokens: A\n // parsed\n themes: {\n [Name in keyof B]: {\n [Key in keyof B[Name]]: Variable\n }\n }\n shorthands: C\n media: D\n animations: AnimationDriver<E>\n}\n\ntype GetLanguagePostfix<Set> = Set extends string\n ? Set extends `${string}_${infer Postfix}`\n ? Postfix\n : never\n : never\n\ntype OmitLanguagePostfix<Set> = Set extends string\n ? Set extends `${infer Prefix}_${string}`\n ? Prefix\n : Set\n : never\n\ntype RemoveLanguagePostfixes<F extends GenericFonts> = {\n [Key in OmitLanguagePostfix<keyof F>]: F[Key]\n}\n\ntype GetLanguagePostfixes<F extends GenericFonts> = GetLanguagePostfix<keyof F>\n\n// test RemoveLanguagePostfixes\n// type x = CreateTamaguiConfig<any, any, any, any, any, {\n// body: any,\n// body_en: any\n// }>['fonts']\n\ntype ConfProps<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n tokens: A\n themes: B\n shorthands?: C\n media?: D\n animations?: AnimationDriver<E>\n fonts: F\n}\n\nexport type InferTamaguiConfig<Conf> = Conf extends ConfProps<\n infer A,\n infer B,\n infer C,\n infer D,\n infer E,\n infer F\n>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown\n\n// for use in creation functions so it doesnt get overwritten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia,\n GenericAnimations,\n GenericFonts\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type ThemeKeys = keyof ThemeDefinition\nexport type ThemeParsed = {\n [key in ThemeKeys]: Variable<any>\n}\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\nexport type ThemeName = Exclude<GetAltThemeNames<keyof Themes>, number>\nexport type ThemeTokens = `$${ThemeKeys}`\nexport type AnimationKeys = TamaguiConfig['animations'] extends AnimationDriver<\n infer Config\n>\n ? keyof Config\n : string\nexport type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>\n\nexport interface ThemeProps {\n className?: string\n name?: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n inverse?: boolean\n // on the web, for portals we need to re-insert className\n forceClassName?: boolean\n // allows for disabling the auto-update behavior\n shouldUpdate?: () => boolean\n}\n\ntype ArrayIntersection<A extends any[]> = A[keyof A]\n\ntype GetAltThemeNames<S> =\n | (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S)\n | S\n\ntype SpacerPropsBase = {\n size?: number | SpaceTokens | null\n flex?: boolean | number\n direction?: SpaceDirection\n}\ntype SpacerOwnProps = SpacerPropsBase &\n //\n WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>\n\nexport type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> &\n //\n SpacerOwnProps\n\nexport type CreateTamaguiProps = {\n reactNative?: any\n shorthands?: CreateShorthands\n media?: GenericTamaguiConfig['media']\n animations?: AnimationDriver<any>\n fonts: GenericTamaguiConfig['fonts']\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n /**\n * *Advanced use case* For all CSS extracted views, this has no effect.\n *\n * For SSR compatibility on the web, Tamagui will render once with the settings\n * from `mediaQueryDefaultActive` set for all media queries. Then, it will render\n * again after the initial render using the proper media query values. This is so that\n * hydration will match perfectly with the server.\n *\n * Setting disableSSR will avoid this second render by setting the media query state\n * to the actual browser dimensions on initial load. This is only useful for client-only\n * apps.\n *\n */\n disableSSR?: boolean\n\n /**\n * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.\n * For custom use cases like integration with next-theme.\n */\n disableRootThemeClass?: boolean\n\n defaultProps?: Record<string, any> & {\n Stack?: StackProps\n Text?: TextProps\n Spacer?: SpacerProps\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: Record<MediaQueryKey, boolean>\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n}\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> &\n CreateTamaguiConfig<A, B, C, D, E, F> & {\n // TODO need to make it this but this breaks types, revisit\n // animations: E //AnimationDriver<E>\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n tokensParsed: CreateTokens<Variable>\n themeConfig: any\n fontsParsed: GenericFonts\n getCSS: () => string\n parsed: boolean\n inverseShorthands: Record<string, string>\n reactNative?: any\n }\n\nexport type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends TamaguiComponent> = A extends FunctionComponent<\n infer Props\n>\n ? Props\n : unknown\n\nexport type GenericFont<Key extends number | string = number | string> = {\n size: { [key in Key]: number | Variable }\n lineHeight: Partial<{ [key in Key]: number | Variable }>\n letterSpacing: Partial<{ [key in Key]: number | Variable }>\n weight: Partial<{ [key in Key]: number | string | Variable }>\n family: string | Variable\n style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>\n transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>\n color?: Partial<{ [key in Key]: string | Variable }>\n // for native use only, lets you map to alternative fonts\n face?: Partial<{\n [key in FontWeightSteps]: { normal?: string; italic?: string }\n }>\n}\n\n// media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryKey = keyof Media\nexport type MediaPropKeys = `$${MediaQueryKey}`\nexport type MediaQueryState = { [key in MediaQueryKey]: boolean }\nexport type MediaProps<A> = {\n [key in MediaPropKeys]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\n\nexport interface MediaQueryList {\n addListener(listener?: any): void\n removeListener(listener?: any): void\n matches: boolean\n}\n\nexport type MatchMedia = (query: string) => MediaQueryList\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n// animation=\"bouncy\"\n// animation={['bouncy', { }]}\n// { all: 'name' }\n\n// TODO can override for better types\nexport type AnimationConfigType = any\n\nexport type AnimationProp =\n | AnimationKeys\n | {\n [key: string]:\n | AnimationKeys\n | {\n type: AnimationKeys\n [key: string]: any\n }\n }\n | [\n AnimationKeys,\n {\n [key: string]:\n | AnimationKeys\n | {\n type?: AnimationKeys\n [key: string]: any\n }\n }\n ]\n\ntype GetTokenFontKeysFor<\n A extends\n | 'size'\n | 'weight'\n | 'letterSpacing'\n | 'family'\n | 'lineHeight'\n | 'transform'\n | 'style'\n | 'color'\n> = keyof TamaguiConfig['fonts']['body'][A]\n\ntype GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`\n\n// base tokens\nexport type SizeTokens = GetTokenString<keyof Tokens['size']> | number\nexport type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean\n\nexport type ColorTokens =\n | GetTokenString<keyof Tokens['color']>\n | GetTokenString<keyof ThemeParsed>\n | CSSColorNames\nexport type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number\nexport type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number\n\n// font tokens\nexport type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>\nexport type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number\nexport type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number\nexport type FontWeightSteps = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`\nexport type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | FontWeightSteps\nexport type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number\nexport type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number\nexport type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']\nexport type FontTransformTokens =\n | `$${GetTokenFontKeysFor<'transform'>}`\n | TextStyle['textTransform']\n\n//\n// adds theme short values to relevant props\n//\n\nexport type ThemeValueByCategory<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends 'size'\n ? SizeTokens\n : K extends 'font'\n ? FontTokens\n : K extends 'fontSize'\n ? FontSizeTokens\n : K extends 'space'\n ? SpaceTokens\n : K extends 'color'\n ? ColorTokens\n : K extends 'zIndex'\n ? ZIndexTokens\n : K extends 'lineHeight'\n ? FontLineHeightTokens\n : K extends 'fontWeight'\n ? FontWeightTokens\n : K extends 'letterSpacing'\n ? FontLetterSpacingTokens\n : {}\n\ntype FontKeys = 'fontFamily'\ntype FontSizeKeys = 'fontSize'\ntype FontWeightKeys = 'fontWeight'\ntype FontLetterSpacingKeys = 'letterSpacing'\ntype LineHeightKeys = 'lineHeight'\ntype ZIndexKeys = 'zIndex'\n\nexport type ThemeValueGet<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends SizeKeys\n ? SizeTokens\n : K extends FontKeys\n ? FontTokens\n : K extends FontSizeKeys\n ? FontSizeTokens\n : K extends `${`border${string | ''}Radius`}`\n ? RadiusTokens\n : K extends SpaceKeys\n ? K extends 'shadowOffset'\n ? { width: SpaceTokens; height: SpaceTokens }\n : SpaceTokens\n : K extends ColorKeys\n ? ColorTokens\n : K extends ZIndexKeys\n ? ZIndexTokens\n : K extends LineHeightKeys\n ? FontLineHeightTokens\n : K extends FontWeightKeys\n ? FontWeightTokens\n : K extends FontLetterSpacingKeys\n ? FontLetterSpacingTokens\n : never\n\nexport type ThemeValueFallback = UnionableString | Variable\n\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]: ThemeValueGet<K> extends never\n ? T[K]\n : ThemeValueGet<K> | Exclude<T[K], string> | ThemeValueFallback\n}\n\n// adds shorthand props\nexport type WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n// adds pseudo props\nexport type PseudoProps<A> = {\n hoverStyle?: A | null\n pressStyle?: A | null\n focusStyle?: A | null\n exitStyle?: A | null\n enterStyle?: A | null\n}\n\nexport type PseudoPropKeys = keyof PseudoProps<any>\n\nexport type PseudoStyles = {\n hoverStyle?: ViewStyle\n pressStyle?: ViewStyle\n focusStyle?: ViewStyle\n enterStyle?: ViewStyle\n exitStyle?: ViewStyle\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// combines all of theme, shorthands, pseudos...\n//\ntype WithThemeShorthandsAndPseudos<A extends object> =\n | WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>\n\n//\n// ... media queries and animations\n//\ntype WithThemeShorthandsPseudosMediaAnimation<A extends object> =\n WithThemeShorthandsAndPseudos<A> & MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n/**\n * Base style-only props (no media, pseudo):\n */\n\ntype StylePropsWebOnly = {\n pointerEvents?: ViewProps['pointerEvents']\n cursor?: Properties['cursor']\n contain?: Properties['contain']\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n userSelect?: Properties['userSelect']\n outlineColor?: Properties['outlineColor']\n outlineStyle?: Properties['outlineStyle']\n outlineOffset?: Properties['outlineOffset']\n outlineWidth?: Properties['outlineWidth']\n}\n\nexport type StackStylePropsBase = Omit<\n ViewStyle,\n 'display' | 'backfaceVisibility' | 'elevation'\n> &\n TransformStyleProps &\n StylePropsWebOnly\n\nexport type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &\n TransformStyleProps &\n StylePropsWebOnly & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n textOverflow?: Properties['textOverflow']\n whiteSpace?: Properties['whiteSpace']\n wordWrap?: Properties['wordWrap']\n }\n\n//\n// Stack\n//\n\nexport type StackNonStyleProps = Omit<ViewProps, 'display' | 'children'> &\n RNWViewProps &\n TamaguiComponentPropsBase\n\nexport type StackStyleProps =\n WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>\nexport type StackPropsBase = StackNonStyleProps &\n WithThemeAndShorthands<StackStylePropsBase>\nexport type StackProps = StackNonStyleProps & StackStyleProps\n\n//\n// Text props\n//\n\nexport type TextNonStyleProps = Omit<ReactTextProps, 'children'> &\n RNWTextProps &\n TamaguiComponentPropsBase\n\nexport type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>\nexport type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>\nexport type TextProps = TextNonStyleProps & TextStyleProps\n\n// could actually infer from parent\nexport type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<\n Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase\n>\n\n//\n// StaticComponent\n//\n\nexport type TamaguiComponent<\n Props = any,\n Ref = any,\n BaseProps = {},\n VariantProps = {}\n> = ReactComponentWithRef<Props, Ref> & StaticComponentObject\n\ntype StaticComponentObject = {\n staticConfig: StaticConfig\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: Partial<StaticConfig>) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n config: TamaguiInternalConfig\n disableInjectCSS?: boolean\n children?: ReactNode\n}\n\nexport type PropMapper = (\n key: string,\n value: any,\n theme: ThemeParsed,\n props: Record<string, any>,\n state: Partial<SplitStyleState>,\n languageContext?: FontLanguageProps,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => undefined | [string, any][]\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: PropMapper\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type GenericVariantDefinitions = {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfigPublic = {\n /**\n * (compiler) If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /**\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /**\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /**\n * (compiler) If these props are encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /**\n * (compiler) If these props are encountered, leave them un-extracted.\n */\n inlineProps?: Set<string>\n\n /**\n * (compiler) If not flattening, leave this prop as original value.\n * Only applies to style attributes\n */\n inlineWhenUnflattened?: Set<string>\n\n /**\n * (compiler) A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /**\n * Auto-detected, but can ovverride. Wraps children to space them on top\n */\n isZStack?: boolean\n\n /**\n * Auto-detect, but can override, passes styles properly to react-native-web\n */\n isReactNative?: boolean\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n}\n\nexport type StaticConfig = StaticConfigPublic & {\n Component?: FunctionComponent<any> & StaticComponentObject\n\n variants?: GenericVariantDefinitions\n\n /**\n * Used for applying sub theme style\n */\n componentName?: string\n\n /**\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps: Record<string, any>\n\n /**\n * Merges into defaultProps later on, used internally yonly\n */\n defaultVariants?: { [key: string]: any }\n\n /**\n * Memoize the component\n */\n memo?: boolean\n\n /**\n * Used insternally to attach default props to names\n */\n parentNames?: string[]\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n\n /**\n * Used internally for handling focus\n */\n isInput?: boolean\n}\n\n/**\n * --------------------------------------------\n * variants\n * --------------------------------------------\n */\n\nexport type StylableComponent =\n | TamaguiComponent\n // * excessively deep type instantiation\n // | TamaguiReactElement\n | ComponentType<any>\n | ForwardRefExoticComponent<any>\n | ReactComponentWithRef<any, any>\n | (new (props: any) => any)\n | typeof View\n | typeof Text\n | typeof TextInput\n | typeof Image\n\nexport type GetStyledVariants<A extends TamaguiComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer Variants\n>\n ? Variants\n : never\n\nexport type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer BaseProps\n>\n ? BaseProps\n : never\n\nexport type GetProps<A extends StylableComponent> = A extends TamaguiComponent<\n infer Props\n>\n ? Props\n : A extends TamaguiReactElement<infer Props>\n ? Props\n : A extends ComponentType<infer Props>\n ? GetGenericComponentTamaguiProps<Props>\n : A extends new (props: infer Props) => any\n ? GetGenericComponentTamaguiProps<Props>\n : {}\n\ntype GetGenericComponentTamaguiProps<P> = P &\n Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>\n\nexport type SpreadKeys =\n | '...fontSize'\n | '...fontStyle'\n | '...fontTransform'\n | '...lineHeight'\n | '...letterSpacing'\n | '...size'\n | '...space'\n | '...color'\n | '...zIndex'\n | '...theme'\n | '...radius'\n\nexport type VariantDefinitions<\n Parent extends StylableComponent = TamaguiComponent,\n MyProps extends Object = GetProps<Parent>,\n Val = any\n> = VariantDefinitionFromProps<MyProps, Val>\n\nexport type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object\n ? {\n [propName: string]:\n | VariantSpreadFunction<MyProps, Val>\n | ({\n [Key in SpreadKeys]?: Key extends '...fontSize'\n ? FontSizeVariantSpreadFunction<MyProps>\n : Key extends '...size'\n ? SizeVariantSpreadFunction<MyProps>\n : Key extends '...space'\n ? SpaceVariantSpreadFunction<MyProps>\n : Key extends '...color'\n ? ColorVariantSpreadFunction<MyProps>\n : Key extends '...lineHeight'\n ? FontLineHeightVariantSpreadFunction<MyProps>\n : Key extends '...fontTransform'\n ? FontTransformVariantSpreadFunction<MyProps>\n : Key extends '...fontStyle'\n ? FontStyleVariantSpreadFunction<MyProps>\n : Key extends '...letterSpacing'\n ? FontLetterSpacingVariantSpreadFunction<MyProps>\n : Key extends '...zIndex'\n ? ZIndexVariantSpreadFunction<MyProps>\n : Key extends '...radius'\n ? RadiusVariantSpreadFunction<MyProps>\n : Key extends '...theme'\n ? ThemeVariantSpreadFunction<MyProps>\n : never\n } & {\n [Key in string | number | 'true' | 'false']?:\n | MyProps\n | VariantSpreadFunction<MyProps, Val>\n } & {\n [Key in VariantTypeKeys]?: Key extends ':number'\n ? VariantSpreadFunction<MyProps, number>\n : Key extends ':boolean'\n ? VariantSpreadFunction<MyProps, boolean>\n : Key extends ':string'\n ? VariantSpreadFunction<MyProps, string>\n : never\n })\n }\n : never\n\nexport type GenericStackVariants = VariantDefinitionFromProps<StackProps, any>\nexport type GenericTextVariants = VariantDefinitionFromProps<StackProps, any>\n\nexport type GetVariantProps<Variants> = {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n}\n\nexport type VariantSpreadExtras<Props> = {\n fonts: TamaguiConfig['fonts']\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: Props\n}\n\ntype PropLike = { [key: string]: any }\n\nexport type VariantSpreadFunction<Props extends PropLike, Val = any> = (\n val: Val,\n config: VariantSpreadExtras<Props>\n) =>\n | {\n [Key in keyof Props]: Props[Key] | Variable\n }\n | null\n | undefined\n\nexport type VariantTypeKeys = ':string' | ':boolean' | ':number'\n\nexport type GetVariantValues<Key> = Key extends `...${infer VariantSpread}`\n ? ThemeValueByCategory<VariantSpread>\n : Key extends 'true' | 'false'\n ? boolean\n : Key extends ':string'\n ? string\n : Key extends ':boolean'\n ? boolean\n : Key extends ':number'\n ? number\n : Key\n\nexport type FontSizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontSizeTokens\n>\nexport type SizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n SizeTokens\n>\nexport type SpaceVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n SpaceTokens\n>\nexport type ColorVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n ColorTokens\n>\nexport type FontLineHeightVariantSpreadFunction<A extends PropLike> =\n VariantSpreadFunction<A, FontLineHeightTokens>\nexport type FontLetterSpacingVariantSpreadFunction<A extends PropLike> =\n VariantSpreadFunction<A, FontLetterSpacingTokens>\nexport type FontStyleVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontStyleTokens\n>\nexport type FontTransformVariantSpreadFunction<A extends PropLike> =\n VariantSpreadFunction<A, FontTransformTokens>\nexport type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n ZIndexTokens\n>\nexport type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n RadiusTokens\n>\nexport type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n ThemeTokens\n>\n\n/**\n * --------------------------------------------\n * end variants\n * --------------------------------------------\n */\n\ntype SizeKeys =\n | 'width'\n | 'height'\n | 'minWidth'\n | 'minHeight'\n | 'maxWidth'\n | 'maxHeight'\n | 'shadowRadius'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n | 'textShadowColor'\n\ntype SpaceKeys =\n | 'space'\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n\ntype CSSColorNames =\n | 'aliceblue'\n | 'antiquewhite'\n | 'aqua'\n | 'aquamarine'\n | 'azure'\n | 'beige'\n | 'bisque'\n | 'black'\n | 'blanchedalmond'\n | 'blue'\n | 'blueviolet'\n | 'brown'\n | 'burlywood'\n | 'cadetblue'\n | 'chartreuse'\n | 'chocolate'\n | 'coral'\n | 'cornflowerblue'\n | 'cornsilk'\n | 'crimson'\n | 'cyan'\n | 'darkblue'\n | 'darkcyan'\n | 'darkgoldenrod'\n | 'darkgray'\n | 'darkgreen'\n | 'darkkhaki'\n | 'darkmagenta'\n | 'darkolivegreen'\n | 'darkorange'\n | 'darkorchid'\n | 'darkred'\n | 'darksalmon'\n | 'darkseagreen'\n | 'darkslateblue'\n | 'darkslategray'\n | 'darkturquoise'\n | 'darkviolet'\n | 'deeppink'\n | 'deepskyblue'\n | 'dimgray'\n | 'dodgerblue'\n | 'firebrick'\n | 'floralwhite'\n | 'forestgreen'\n | 'fuchsia'\n | 'gainsboro'\n | 'ghostwhite'\n | 'gold'\n | 'goldenrod'\n | 'gray'\n | 'green'\n | 'greenyellow'\n | 'honeydew'\n | 'hotpink'\n | 'indianred '\n | 'indigo '\n | 'ivory'\n | 'khaki'\n | 'lavender'\n | 'lavenderblush'\n | 'lawngreen'\n | 'lemonchiffon'\n | 'lightblue'\n | 'lightcoral'\n | 'lightcyan'\n | 'lightgoldenrodyellow'\n | 'lightgrey'\n | 'lightgreen'\n | 'lightpink'\n | 'lightsalmon'\n | 'lightseagreen'\n | 'lightskyblue'\n | 'lightslategray'\n | 'lightsteelblue'\n | 'lightyellow'\n | 'lime'\n | 'limegreen'\n | 'linen'\n | 'magenta'\n | 'maroon'\n | 'mediumaquamarine'\n | 'mediumblue'\n | 'mediumorchid'\n | 'mediumpurple'\n | 'mediumseagreen'\n | 'mediumslateblue'\n | 'mediumspringgreen'\n | 'mediumturquoise'\n | 'mediumvioletred'\n | 'midnightblue'\n | 'mintcream'\n | 'mistyrose'\n | 'moccasin'\n | 'navajowhite'\n | 'navy'\n | 'oldlace'\n | 'olive'\n | 'olivedrab'\n | 'orange'\n | 'orangered'\n | 'orchid'\n | 'palegoldenrod'\n | 'palegreen'\n | 'paleturquoise'\n | 'palevioletred'\n | 'papayawhip'\n | 'peachpuff'\n | 'peru'\n | 'pink'\n | 'plum'\n | 'powderblue'\n | 'purple'\n | 'red'\n | 'rosybrown'\n | 'royalblue'\n | 'saddlebrown'\n | 'salmon'\n | 'sandybrown'\n | 'seagreen'\n | 'seashell'\n | 'sienna'\n | 'silver'\n | 'skyblue'\n | 'slateblue'\n | 'slategray'\n | 'snow'\n | 'springgreen'\n | 'steelblue'\n | 'tan'\n | 'teal'\n | 'thistle'\n | 'tomato'\n | 'turquoise'\n | 'violet'\n | 'wheat'\n | 'white'\n | 'whitesmoke'\n | 'yellow'\n | 'yellowgreen'\n\nexport type TamaguiComponentState = {\n hover: boolean\n press: boolean\n pressIn: boolean\n focus: boolean\n unmounted: boolean\n animation?: null | {\n style?: any\n avoidClasses?: boolean\n }\n}\n\nexport type SplitStyleState = TamaguiComponentState & {\n mediaState?: Record<string, boolean>\n noClassNames?: boolean\n dynamicStylesInline?: boolean\n resolveVariablesAs?: ResolveVariableTypes\n fallbackProps?: Record<string, any>\n keepVariantsAsProps?: boolean\n hasTextAncestor?: boolean\n\n // for animations\n isExiting?: boolean\n exitVariant?: string\n enterVariant?: string\n}\n\n// Presence\n\nexport interface PresenceContextProps {\n id: string\n isPresent: boolean\n register: (id: string) => () => void\n onExitComplete?: (id: string) => void\n initial?: false | string | string[]\n custom?: any\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\ntype SafeToRemoveCallback = () => void\ntype AlwaysPresent = [true, null, null]\ntype Present = [true, undefined, PresenceContextProps]\ntype NotPresent = [false, SafeToRemoveCallback, PresenceContextProps]\n\nexport type UsePresenceResult = AlwaysPresent | Present | NotPresent\n\n// Animations:\n\ntype AnimationConfig = {\n [key: string]: any\n}\n\n// includes a very limited adapter between various impls for number => style\n// this is useful only in limited scenarios like `Sheet`, but necessary in those cases\n\nexport type AnimatedNumberStrategy =\n // only values shared between reanimated/react-native for now\n | {\n type: 'spring'\n stiffness?: number\n damping?: number\n mass?: number\n overshootClamping?: boolean\n restSpeedThreshold?: number\n restDisplacementThreshold?: number\n }\n | { type: 'timing'; duration: number }\n | { type: 'direct' }\n\nexport type UniversalAnimatedNumber<A> = {\n getInstance(): A\n getValue(): number\n setValue(next: number, config?: AnimatedNumberStrategy): void\n stop(): void\n}\n\nexport type AnimationDriver<A extends AnimationConfig = AnimationConfig> = {\n isReactNative?: boolean\n useAnimations: UseAnimationHook\n usePresence: () => UsePresenceResult\n useAnimatedNumber: (initial: number) => UniversalAnimatedNumber<any>\n useAnimatedNumberStyle: <V extends UniversalAnimatedNumber<any>>(\n val: V,\n getStyle: (current: any) => any\n ) => any\n useAnimatedNumberReaction: (\n val: UniversalAnimatedNumber<any>,\n onValue: (current: number) => void\n ) => void\n animations: A\n View?: any\n Text?: any\n}\n\nexport type UseAnimationProps = TamaguiComponentPropsBase & Record<string, any>\n\nexport type UseAnimationHook = (props: {\n style: Record<string, any>\n props: Record<string, any>\n presence?: UsePresenceResult | null\n hostRef: RefObject<HTMLElement | View>\n staticConfig: StaticConfigParsed\n state: SplitStyleState\n pseudos: PseudoProps<ViewStyle> | null\n onDidAnimate?: any\n delay?: number\n}) => null | {\n style?: StackStylePropsBase | StackStylePropsBase[]\n}\n\nexport type GestureReponderEvent = Exclude<\n View['props']['onResponderMove'],\n void\n> extends (event: infer Event) => void\n ? Event\n : never\n"],
4
+ "sourcesContent": ["// TODO split this into own package @tamagui/types to share with animations packages\n\nimport type { Properties } from 'csstype'\nimport type {\n ComponentType,\n ForwardRefExoticComponent,\n FunctionComponent,\n HTMLAttributes,\n ReactNode,\n RefAttributes,\n RefObject,\n} from 'react'\nimport type {\n Image,\n PressableProps,\n TextProps as ReactTextProps,\n Text,\n TextInput,\n TextStyle,\n View,\n ViewProps,\n ViewStyle,\n} from 'react-native'\n\nimport type { Variable } from './createVariable'\nimport type { ResolveVariableTypes } from './helpers/createPropMapper'\nimport type { TamaguiReactElement } from './static'\nimport type { RNWTextProps, RNWViewProps } from './types-rnw'\nimport type { FontLanguageProps } from './views/FontLanguage.types'\nimport type { ThemeProviderProps } from './views/ThemeProvider'\n\nexport type SpaceDirection = 'vertical' | 'horizontal' | 'both'\n\nexport type TamaguiElement = HTMLElement | View\n\nexport type DebugProp = boolean | 'break' | 'verbose'\n\n// base props that are accepted by createComponent (additional to react-native-web)\n\ntype DivAttributes = HTMLAttributes<HTMLDivElement>\n\nexport type TamaguiComponentPropsBase = {\n hitSlop?: PressableProps['hitSlop']\n asChild?: boolean\n space?: SpaceTokens | null\n spaceDirection?: SpaceDirection\n separator?: ReactNode\n dangerouslySetInnerHTML?: { __html: string }\n animation?: AnimationProp | null\n animateOnly?: string[]\n children?: any | any[]\n debug?: DebugProp\n disabled?: boolean\n className?: string\n themeShallow?: boolean\n id?: string\n tag?: string\n theme?: ThemeName | null\n componentName?: string\n /**\n * Forces the pseudo style state to be on\n */\n forceStyle?: 'hover' | 'press' | 'focus'\n onHoverIn?: DivAttributes['onMouseEnter']\n onHoverOut?: DivAttributes['onMouseLeave']\n onPress?: PressableProps['onPress']\n onPressIn?: PressableProps['onPress']\n onPressOut?: PressableProps['onPress']\n // WEB ONLY\n onMouseEnter?: DivAttributes['onMouseEnter']\n onMouseLeave?: DivAttributes['onMouseLeave']\n onMouseDown?: DivAttributes['onMouseDown']\n}\n\nexport type ReactComponentWithRef<Props, Ref> = ForwardRefExoticComponent<\n Props & RefAttributes<Ref>\n>\n\nexport type ConfigListener = (conf: TamaguiInternalConfig) => void\n\n// to prevent things from going circular, hoisting some types in this file\n// to generally order them as building up towards TamaguiConfig\n\nexport type VariableVal = number | string | Variable\nexport type VariableColorVal = string | Variable\n\ntype GenericKey = string | number | symbol\n\nexport interface CreateTokens<Val extends VariableVal = VariableVal> {\n color: { [key: GenericKey]: Val }\n space: { [key: GenericKey]: Val }\n size: { [key: GenericKey]: Val }\n radius: { [key: GenericKey]: Val }\n zIndex: { [key: GenericKey]: Val }\n}\n\ntype Tokenify<A extends GenericTokens> = {\n color: TokenifyRecord<A['color']>\n space: TokenifyRecord<A['space']>\n size: TokenifyRecord<A['size']>\n radius: TokenifyRecord<A['radius']>\n zIndex: TokenifyRecord<A['zIndex']>\n}\n\ntype TokenifyRecord<A extends CreateTokens[keyof CreateTokens]> = {\n [Key in keyof A]: Variable<A[Key]>\n}\n\nexport type TamaguiBaseTheme = {\n // defined for our tamagui kit , we could do this inside `tamagui`\n // but maybe helpful to have some sort of universally shared things +\n // + enforce if they want their own, redefine in their design sys\n background: VariableColorVal\n backgroundHover: VariableColorVal\n backgroundPress: VariableColorVal\n backgroundFocus: VariableColorVal\n color: VariableColorVal\n colorHover: VariableColorVal\n colorPress: VariableColorVal\n colorFocus: VariableColorVal\n borderColor: VariableColorVal\n borderColorHover: VariableColorVal\n borderColorPress: VariableColorVal\n borderColorFocus: VariableColorVal\n shadowColor: VariableColorVal\n shadowColorHover: VariableColorVal\n shadowColorPress: VariableColorVal\n shadowColorFocus: VariableColorVal\n}\n\ntype GenericTokens = CreateTokens\ntype GenericThemes = {\n [key: string]:\n | Partial<TamaguiBaseTheme> & {\n [key: string]: VariableVal\n }\n}\n\ntype AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase\n\nexport type CreateShorthands = {\n [key: string]: AllStyleKeys\n}\n\nexport type GenericShorthands = {}\n\n// sm: { minWidth: 100 }\ntype GenericMedia = {\n [key: string]: {\n [key: string]: number | string\n }\n}\n\nexport type GenericFonts = Record<string, GenericFont>\n\ntype GenericAnimations = {\n [key: string]:\n | string\n | {\n [key: string]: any\n }\n | any[]\n}\n\n// this is the \"main\" typed object, which users re-define\n// (internal) keep all types directly on this object and reference them from elsewhere\n//\n// const config = createTamagui(...)\n// type MyConfig = typeof config\n// declare module 'tamagui' {\n// export interface TamaguiCustomConfig extends MyConfig {}\n// }\n// now your whole app/kit should be typed correctly\n//\nexport interface TamaguiCustomConfig {}\n\nexport interface TamaguiConfig\n extends Omit<GenericTamaguiConfig, keyof TamaguiCustomConfig>,\n TamaguiCustomConfig {}\n\nexport type CreateTamaguiConfig<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n fonts: RemoveLanguagePostfixes<F>\n fontLanguages: GetLanguagePostfixes<F> extends never\n ? string[]\n : GetLanguagePostfixes<F>[]\n tokens: A\n // parsed\n themes: {\n [Name in keyof B]: {\n [Key in keyof B[Name]]: Variable\n }\n }\n shorthands: C\n media: D\n animations: AnimationDriver<E>\n}\n\ntype GetLanguagePostfix<Set> = Set extends string\n ? Set extends `${string}_${infer Postfix}`\n ? Postfix\n : never\n : never\n\ntype OmitLanguagePostfix<Set> = Set extends string\n ? Set extends `${infer Prefix}_${string}`\n ? Prefix\n : Set\n : never\n\ntype RemoveLanguagePostfixes<F extends GenericFonts> = {\n [Key in OmitLanguagePostfix<keyof F>]: F[Key]\n}\n\ntype GetLanguagePostfixes<F extends GenericFonts> = GetLanguagePostfix<keyof F>\n\n// test RemoveLanguagePostfixes\n// type x = CreateTamaguiConfig<any, any, any, any, any, {\n// body: any,\n// body_en: any\n// }>['fonts']\n\ntype ConfProps<\n A extends GenericTokens,\n B extends GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = {\n tokens: A\n themes: B\n shorthands?: C\n media?: D\n animations?: AnimationDriver<E>\n fonts: F\n}\n\nexport type InferTamaguiConfig<Conf> = Conf extends ConfProps<\n infer A,\n infer B,\n infer C,\n infer D,\n infer E,\n infer F\n>\n ? TamaguiInternalConfig<A, B, C, D, E, F>\n : unknown\n\n// for use in creation functions so it doesnt get overwritten\nexport type GenericTamaguiConfig = CreateTamaguiConfig<\n GenericTokens,\n GenericThemes,\n GenericShorthands,\n GenericMedia,\n GenericAnimations,\n GenericFonts\n>\n\n// since TamaguiConfig will be re-declared, these will all be typed globally\nexport type ThemeDefinition = TamaguiConfig['themes'][keyof TamaguiConfig['themes']]\nexport type ThemeKeys = keyof ThemeDefinition\nexport type ThemeParsed = {\n [key in ThemeKeys]: Variable<any>\n}\nexport type Tokens = TamaguiConfig['tokens']\nexport type Shorthands = TamaguiConfig['shorthands']\nexport type Media = TamaguiConfig['media']\nexport type Themes = TamaguiConfig['themes']\nexport type ThemeName = Exclude<GetAltThemeNames<keyof Themes>, number>\nexport type ThemeTokens = `$${ThemeKeys}`\nexport type AnimationKeys = TamaguiConfig['animations'] extends AnimationDriver<\n infer Config\n>\n ? keyof Config\n : string\nexport type FontLanguages = ArrayIntersection<TamaguiConfig['fontLanguages']>\n\nexport interface ThemeProps {\n className?: string\n name?: Exclude<ThemeName, number> | null\n componentName?: string\n children?: any\n reset?: boolean\n debug?: boolean | 'verbose'\n inverse?: boolean\n // on the web, for portals we need to re-insert className\n forceClassName?: boolean\n // allows for disabling the auto-update behavior\n shouldUpdate?: () => boolean\n}\n\ntype ArrayIntersection<A extends any[]> = A[keyof A]\n\ntype GetAltThemeNames<S> =\n | (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S)\n | S\n\ntype SpacerPropsBase = {\n size?: number | SpaceTokens | null\n flex?: boolean | number\n direction?: SpaceDirection\n}\ntype SpacerOwnProps = SpacerPropsBase &\n //\n WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>\n\nexport type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> &\n //\n SpacerOwnProps\n\nexport type CreateTamaguiProps = {\n reactNative?: any\n shorthands?: CreateShorthands\n media?: GenericTamaguiConfig['media']\n animations?: AnimationDriver<any>\n fonts: GenericTamaguiConfig['fonts']\n tokens: GenericTamaguiConfig['tokens']\n themes: {\n [key: string]: {\n [key: string]: string | number | Variable\n }\n }\n\n /**\n * *Advanced use case* For all CSS extracted views, this has no effect.\n *\n * For SSR compatibility on the web, Tamagui will render once with the settings\n * from `mediaQueryDefaultActive` set for all media queries. Then, it will render\n * again after the initial render using the proper media query values. This is so that\n * hydration will match perfectly with the server.\n *\n * Setting disableSSR will avoid this second render by setting the media query state\n * to the actual browser dimensions on initial load. This is only useful for client-only\n * apps.\n *\n */\n disableSSR?: boolean\n\n /**\n * Disable inserting a theme class in the DOM or context, allowing you to manually place it higher.\n * For custom use cases like integration with next-theme.\n */\n disableRootThemeClass?: boolean\n\n defaultProps?: Record<string, any> & {\n Stack?: StackProps\n Text?: TextProps\n Spacer?: SpacerProps\n }\n\n // for the first render, determines which media queries are true\n // useful for SSR\n mediaQueryDefaultActive?: Record<MediaQueryKey, boolean>\n\n // what's between each CSS style rule, set to \"\\n\" to be easier to read\n // defaults: \"\\n\" when NODE_ENV=development, \"\" otherwise\n cssStyleSeparator?: string\n\n // (Advanced)\n // on the web, tamagui treats `dark` and `light` themes as special and\n // generates extra CSS to avoid having to re-render the entire page.\n // this CSS relies on specificity hacks that multiply by your sub-themes.\n // this sets the maxiumum number of nested dark/light themes you can do\n // defaults to 3 for a balance, but can be higher if you nest them deeply.\n maxDarkLightNesting?: number\n\n // adds @media(prefers-color-scheme) media queries for dark/light\n shouldAddPrefersColorThemes?: boolean\n\n // only if you put the theme classname on the html element we have to generate diff\n themeClassNameOnRoot?: boolean\n}\n\n// this is the config generated via createTamagui()\nexport type TamaguiInternalConfig<\n A extends GenericTokens = GenericTokens,\n B extends GenericThemes = GenericThemes,\n C extends GenericShorthands = GenericShorthands,\n D extends GenericMedia = GenericMedia,\n E extends GenericAnimations = GenericAnimations,\n F extends GenericFonts = GenericFonts\n> = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> &\n Omit<CreateTamaguiConfig<A, B, C, D, E, F>, 'tokens'> & {\n // TODO need to make it this but this breaks types, revisit\n // animations: E //AnimationDriver<E>\n // with $ prefixes for fast lookups (one time cost at startup vs every render)\n tokens: Tokenify<A>\n tokensParsed: Tokenify<A>\n themeConfig: any\n fontsParsed: GenericFonts\n getCSS: () => string\n parsed: boolean\n inverseShorthands: Record<string, string>\n reactNative?: any\n }\n\nexport type GetAnimationKeys<A extends GenericTamaguiConfig> = keyof A['animations']\n\n// prevents const intersections from being clobbered into string, keeping the consts\nexport type UnionableString = string & {}\nexport type UnionableNumber = number & {}\nexport type PropTypes<A extends TamaguiComponent> = A extends FunctionComponent<\n infer Props\n>\n ? Props\n : unknown\n\nexport type GenericFont<Key extends number | string = number | string> = {\n size: { [key in Key]: number | Variable }\n lineHeight: Partial<{ [key in Key]: number | Variable }>\n letterSpacing: Partial<{ [key in Key]: number | Variable }>\n weight: Partial<{ [key in Key]: number | string | Variable }>\n family: string | Variable\n style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>\n transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>\n color?: Partial<{ [key in Key]: string | Variable }>\n // for native use only, lets you map to alternative fonts\n face?: Partial<{\n [key in FontWeightSteps]: { normal?: string; italic?: string }\n }>\n}\n\n// media\nexport type MediaQueryObject = { [key: string]: string | number | string }\nexport type MediaQueryKey = keyof Media\nexport type MediaPropKeys = `$${MediaQueryKey}`\nexport type MediaQueryState = { [key in MediaQueryKey]: boolean }\nexport type MediaProps<A> = {\n [key in MediaPropKeys]?: A\n}\nexport type MediaQueries = {\n [key in MediaQueryKey]: MediaQueryObject\n}\n\nexport interface MediaQueryList {\n addListener(listener?: any): void\n removeListener(listener?: any): void\n matches: boolean\n}\n\nexport type MatchMedia = (query: string) => MediaQueryList\n\nexport type TransformStyleProps = {\n x?: number\n y?: number\n perspective?: number\n scale?: number\n scaleX?: number\n scaleY?: number\n skewX?: string\n skewY?: string\n matrix?: number[]\n rotate?: string\n rotateY?: string\n rotateX?: string\n rotateZ?: string\n}\n\n// createComponent props helpers\n\n// animation=\"bouncy\"\n// animation={['bouncy', { }]}\n// { all: 'name' }\n\n// TODO can override for better types\nexport type AnimationConfigType = any\n\nexport type AnimationProp =\n | AnimationKeys\n | {\n [key: string]:\n | AnimationKeys\n | {\n type: AnimationKeys\n [key: string]: any\n }\n }\n | [\n AnimationKeys,\n {\n [key: string]:\n | AnimationKeys\n | {\n type?: AnimationKeys\n [key: string]: any\n }\n }\n ]\n\ntype GetTokenFontKeysFor<\n A extends\n | 'size'\n | 'weight'\n | 'letterSpacing'\n | 'family'\n | 'lineHeight'\n | 'transform'\n | 'style'\n | 'color'\n> = keyof TamaguiConfig['fonts']['body'][A]\n\ntype GetTokenString<A> = A extends string | number ? `$${A}` : `$${string}`\n\n// base tokens\nexport type SizeTokens = GetTokenString<keyof Tokens['size']> | number\nexport type SpaceTokens = GetTokenString<keyof Tokens['space']> | number | boolean\n\nexport type ColorTokens =\n | GetTokenString<keyof Tokens['color']>\n | GetTokenString<keyof ThemeParsed>\n | CSSColorNames\nexport type ZIndexTokens = GetTokenString<keyof Tokens['zIndex']> | number\nexport type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number\n\n// font tokens\nexport type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>\nexport type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number\nexport type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number\nexport type FontWeightSteps = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`\nexport type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | FontWeightSteps\nexport type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number\nexport type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number\nexport type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']\nexport type FontTransformTokens =\n | `$${GetTokenFontKeysFor<'transform'>}`\n | TextStyle['textTransform']\n\n//\n// adds theme short values to relevant props\n//\n\nexport type ThemeValueByCategory<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends 'size'\n ? SizeTokens\n : K extends 'font'\n ? FontTokens\n : K extends 'fontSize'\n ? FontSizeTokens\n : K extends 'space'\n ? SpaceTokens\n : K extends 'color'\n ? ColorTokens\n : K extends 'zIndex'\n ? ZIndexTokens\n : K extends 'lineHeight'\n ? FontLineHeightTokens\n : K extends 'fontWeight'\n ? FontWeightTokens\n : K extends 'letterSpacing'\n ? FontLetterSpacingTokens\n : {}\n\ntype FontKeys = 'fontFamily'\ntype FontSizeKeys = 'fontSize'\ntype FontWeightKeys = 'fontWeight'\ntype FontLetterSpacingKeys = 'letterSpacing'\ntype LineHeightKeys = 'lineHeight'\ntype ZIndexKeys = 'zIndex'\n\nexport type ThemeValueGet<K extends string | number | symbol> = K extends 'theme'\n ? ThemeTokens\n : K extends SizeKeys\n ? SizeTokens\n : K extends FontKeys\n ? FontTokens\n : K extends FontSizeKeys\n ? FontSizeTokens\n : K extends `${`border${string | ''}Radius`}`\n ? RadiusTokens\n : K extends SpaceKeys\n ? K extends 'shadowOffset'\n ? { width: SpaceTokens; height: SpaceTokens }\n : SpaceTokens\n : K extends ColorKeys\n ? ColorTokens\n : K extends ZIndexKeys\n ? ZIndexTokens\n : K extends LineHeightKeys\n ? FontLineHeightTokens\n : K extends FontWeightKeys\n ? FontWeightTokens\n : K extends FontLetterSpacingKeys\n ? FontLetterSpacingTokens\n : never\n\nexport type ThemeValueFallback = UnionableString | Variable\n\nexport type WithThemeValues<T extends object> = {\n [K in keyof T]: ThemeValueGet<K> extends never\n ? T[K]\n : ThemeValueGet<K> | Exclude<T[K], string> | ThemeValueFallback\n}\n\n// adds shorthand props\nexport type WithShorthands<StyleProps> = {\n [Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps\n ? StyleProps[Shorthands[Key]] | null\n : undefined\n}\n\n// adds pseudo props\nexport type PseudoProps<A> = {\n hoverStyle?: A | null\n pressStyle?: A | null\n focusStyle?: A | null\n exitStyle?: A | null\n enterStyle?: A | null\n}\n\nexport type PseudoPropKeys = keyof PseudoProps<any>\n\nexport type PseudoStyles = {\n hoverStyle?: ViewStyle\n pressStyle?: ViewStyle\n focusStyle?: ViewStyle\n enterStyle?: ViewStyle\n exitStyle?: ViewStyle\n}\n\n//\n// add both theme and shorthands\n//\ntype WithThemeAndShorthands<A extends object> = WithThemeValues<A> &\n WithShorthands<WithThemeValues<A>>\n\n//\n// combines all of theme, shorthands, pseudos...\n//\ntype WithThemeShorthandsAndPseudos<A extends object> =\n | WithThemeAndShorthands<A> & PseudoProps<WithThemeAndShorthands<A>>\n\n//\n// ... media queries and animations\n//\ntype WithThemeShorthandsPseudosMediaAnimation<A extends object> =\n WithThemeShorthandsAndPseudos<A> & MediaProps<WithThemeShorthandsAndPseudos<A>>\n\n/**\n * Base style-only props (no media, pseudo):\n */\n\ntype StylePropsWebOnly = {\n pointerEvents?: ViewProps['pointerEvents']\n cursor?: Properties['cursor']\n contain?: Properties['contain']\n display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'\n userSelect?: Properties['userSelect']\n outlineColor?: Properties['outlineColor']\n outlineStyle?: Properties['outlineStyle']\n outlineOffset?: Properties['outlineOffset']\n outlineWidth?: Properties['outlineWidth']\n}\n\nexport type StackStylePropsBase = Omit<\n ViewStyle,\n 'display' | 'backfaceVisibility' | 'elevation'\n> &\n TransformStyleProps &\n StylePropsWebOnly\n\nexport type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &\n TransformStyleProps &\n StylePropsWebOnly & {\n ellipse?: boolean\n selectable?: boolean\n textDecorationDistance?: number\n textOverflow?: Properties['textOverflow']\n whiteSpace?: Properties['whiteSpace']\n wordWrap?: Properties['wordWrap']\n }\n\n//\n// Stack\n//\n\nexport type StackNonStyleProps = Omit<ViewProps, 'display' | 'children'> &\n RNWViewProps &\n TamaguiComponentPropsBase\n\nexport type StackStyleProps =\n WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>\nexport type StackPropsBase = StackNonStyleProps &\n WithThemeAndShorthands<StackStylePropsBase>\nexport type StackProps = StackNonStyleProps & StackStyleProps\n\n//\n// Text props\n//\n\nexport type TextNonStyleProps = Omit<ReactTextProps, 'children'> &\n RNWTextProps &\n TamaguiComponentPropsBase\n\nexport type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>\nexport type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>\nexport type TextProps = TextNonStyleProps & TextStyleProps\n\n// could actually infer from parent\nexport type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<\n Omit<TextStylePropsBase, keyof StackStylePropsBase> & StackStylePropsBase\n>\n\n//\n// StaticComponent\n//\n\nexport type TamaguiComponent<\n Props = any,\n Ref = any,\n BaseProps = {},\n VariantProps = {}\n> = ReactComponentWithRef<Props, Ref> & StaticComponentObject\n\ntype StaticComponentObject = {\n staticConfig: StaticConfig\n /*\n * Only needed for more complex components\n * If you create a styled frame component this is a HoC to extract\n * styles from all parents.\n */\n extractable: <X>(a: X, opts?: Partial<StaticConfig>) => X\n}\n\nexport type TamaguiProviderProps = Partial<Omit<ThemeProviderProps, 'children'>> & {\n config: TamaguiInternalConfig\n disableInjectCSS?: boolean\n children?: ReactNode\n}\n\nexport type PropMapper = (\n key: string,\n value: any,\n theme: ThemeParsed,\n props: Record<string, any>,\n state: Partial<SplitStyleState>,\n languageContext?: FontLanguageProps,\n avoidDefaultProps?: boolean,\n debug?: DebugProp\n) => undefined | [string, any][]\n\nexport type StaticConfigParsed = StaticConfig & {\n parsed: true\n propMapper: PropMapper\n variantsParsed?: {\n [key: string]: {\n [key: string]: any\n }\n }\n}\n\nexport type GenericVariantDefinitions = {\n [key: string]: {\n [key: string]:\n | ((a: any, b: any) => any)\n | {\n [key: string]: any\n }\n }\n}\n\nexport type StaticConfigPublic = {\n /**\n * (compiler) If you need to pass context or something, prevents from ever\n * flattening. The 'jsx' option means it will never flatten. if you\n * pass JSX as a children (if its purely string, it will still flatten).\n */\n neverFlatten?: boolean | 'jsx'\n\n /**\n * Determines ultimate output tag (Text vs View)\n */\n isText?: boolean\n\n /**\n * Which style keys are allowed to be extracted.\n */\n validStyles?: { [key: string]: boolean }\n\n /**\n * (compiler) If these props are encountered, bail on all optimization.\n */\n deoptProps?: Set<string>\n\n /**\n * (compiler) If these props are encountered, leave them un-extracted.\n */\n inlineProps?: Set<string>\n\n /**\n * (compiler) If not flattening, leave this prop as original value.\n * Only applies to style attributes\n */\n inlineWhenUnflattened?: Set<string>\n\n /**\n * (compiler) A bit odd, only for more advanced heirarchies.\n * Indicates that the component will set this prop so the\n * static extraction can ensure it sets them to ={undefined}\n * so they get overriddent. In the future, this can be smarter.\n */\n ensureOverriddenProp?: { [key: string]: boolean }\n\n /**\n * Auto-detected, but can ovverride. Wraps children to space them on top\n */\n isZStack?: boolean\n\n /**\n * Auto-detect, but can override, passes styles properly to react-native-web\n */\n isReactNative?: boolean\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n}\n\nexport type StaticConfig = StaticConfigPublic & {\n Component?: FunctionComponent<any> & StaticComponentObject\n\n variants?: GenericVariantDefinitions\n\n /**\n * Used for applying sub theme style\n */\n componentName?: string\n\n /**\n * Same as React.defaultProps, be sure to sync\n */\n defaultProps: Record<string, any>\n\n /**\n * Merges into defaultProps later on, used internally yonly\n */\n defaultVariants?: { [key: string]: any }\n\n /**\n * Memoize the component\n */\n memo?: boolean\n\n /**\n * Used insternally to attach default props to names\n */\n parentNames?: string[]\n\n /**\n * By default if styled() doesn't recognize a parent Tamagui compoent or specific react-native views,\n * it will assume the passed in component only accepts style={} for react-native compatibility.\n * Setting `acceptsClassName: true` indicates Tamagui can pass in className props.\n */\n acceptsClassName?: boolean\n\n /**\n * Used internally for handling focus\n */\n isInput?: boolean\n}\n\n/**\n * --------------------------------------------\n * variants\n * --------------------------------------------\n */\n\nexport type StylableComponent =\n | TamaguiComponent\n // * excessively deep type instantiation\n // | TamaguiReactElement\n | ComponentType<any>\n | ForwardRefExoticComponent<any>\n | ReactComponentWithRef<any, any>\n | (new (props: any) => any)\n | typeof View\n | typeof Text\n | typeof TextInput\n | typeof Image\n\nexport type GetStyledVariants<A extends TamaguiComponent> = A extends TamaguiComponent<\n any,\n any,\n any,\n infer Variants\n>\n ? Variants\n : never\n\nexport type GetBaseProps<A extends StylableComponent> = A extends TamaguiComponent<\n any,\n any,\n infer BaseProps\n>\n ? BaseProps\n : never\n\nexport type GetProps<A extends StylableComponent> = A extends TamaguiComponent<\n infer Props\n>\n ? Props\n : A extends TamaguiReactElement<infer Props>\n ? Props\n : A extends ComponentType<infer Props>\n ? GetGenericComponentTamaguiProps<Props>\n : A extends new (props: infer Props) => any\n ? GetGenericComponentTamaguiProps<Props>\n : {}\n\ntype GetGenericComponentTamaguiProps<P> = P &\n Omit<'textAlign' extends keyof P ? TextProps : StackProps, keyof P>\n\nexport type SpreadKeys =\n | '...fontSize'\n | '...fontStyle'\n | '...fontTransform'\n | '...lineHeight'\n | '...letterSpacing'\n | '...size'\n | '...space'\n | '...color'\n | '...zIndex'\n | '...theme'\n | '...radius'\n\nexport type VariantDefinitions<\n Parent extends StylableComponent = TamaguiComponent,\n MyProps extends Object = GetProps<Parent>,\n Val = any\n> = VariantDefinitionFromProps<MyProps, Val>\n\nexport type VariantDefinitionFromProps<MyProps, Val> = MyProps extends Object\n ? {\n [propName: string]:\n | VariantSpreadFunction<MyProps, Val>\n | ({\n [Key in SpreadKeys]?: Key extends '...fontSize'\n ? FontSizeVariantSpreadFunction<MyProps>\n : Key extends '...size'\n ? SizeVariantSpreadFunction<MyProps>\n : Key extends '...space'\n ? SpaceVariantSpreadFunction<MyProps>\n : Key extends '...color'\n ? ColorVariantSpreadFunction<MyProps>\n : Key extends '...lineHeight'\n ? FontLineHeightVariantSpreadFunction<MyProps>\n : Key extends '...fontTransform'\n ? FontTransformVariantSpreadFunction<MyProps>\n : Key extends '...fontStyle'\n ? FontStyleVariantSpreadFunction<MyProps>\n : Key extends '...letterSpacing'\n ? FontLetterSpacingVariantSpreadFunction<MyProps>\n : Key extends '...zIndex'\n ? ZIndexVariantSpreadFunction<MyProps>\n : Key extends '...radius'\n ? RadiusVariantSpreadFunction<MyProps>\n : Key extends '...theme'\n ? ThemeVariantSpreadFunction<MyProps>\n : never\n } & {\n [Key in string | number | 'true' | 'false']?:\n | MyProps\n | VariantSpreadFunction<MyProps, Val>\n } & {\n [Key in VariantTypeKeys]?: Key extends ':number'\n ? VariantSpreadFunction<MyProps, number>\n : Key extends ':boolean'\n ? VariantSpreadFunction<MyProps, boolean>\n : Key extends ':string'\n ? VariantSpreadFunction<MyProps, string>\n : never\n })\n }\n : never\n\nexport type GenericStackVariants = VariantDefinitionFromProps<StackProps, any>\nexport type GenericTextVariants = VariantDefinitionFromProps<StackProps, any>\n\nexport type GetVariantProps<Variants> = {\n [Key in keyof Variants]?: Variants[Key] extends VariantSpreadFunction<any, infer Val>\n ? Val\n : GetVariantValues<keyof Variants[Key]>\n}\n\nexport type VariantSpreadExtras<Props> = {\n fonts: TamaguiConfig['fonts']\n tokens: TamaguiConfig['tokens']\n theme: Themes extends { [key: string]: infer B } ? B : unknown\n props: Props\n}\n\ntype PropLike = { [key: string]: any }\n\nexport type VariantSpreadFunction<Props extends PropLike, Val = any> = (\n val: Val,\n config: VariantSpreadExtras<Props>\n) =>\n | {\n [Key in keyof Props]: Props[Key] | Variable\n }\n | null\n | undefined\n\nexport type VariantTypeKeys = ':string' | ':boolean' | ':number'\n\nexport type GetVariantValues<Key> = Key extends `...${infer VariantSpread}`\n ? ThemeValueByCategory<VariantSpread>\n : Key extends 'true' | 'false'\n ? boolean\n : Key extends ':string'\n ? string\n : Key extends ':boolean'\n ? boolean\n : Key extends ':number'\n ? number\n : Key\n\nexport type FontSizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontSizeTokens\n>\nexport type SizeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n SizeTokens\n>\nexport type SpaceVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n SpaceTokens\n>\nexport type ColorVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n ColorTokens\n>\nexport type FontLineHeightVariantSpreadFunction<A extends PropLike> =\n VariantSpreadFunction<A, FontLineHeightTokens>\nexport type FontLetterSpacingVariantSpreadFunction<A extends PropLike> =\n VariantSpreadFunction<A, FontLetterSpacingTokens>\nexport type FontStyleVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n FontStyleTokens\n>\nexport type FontTransformVariantSpreadFunction<A extends PropLike> =\n VariantSpreadFunction<A, FontTransformTokens>\nexport type ZIndexVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n ZIndexTokens\n>\nexport type RadiusVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n RadiusTokens\n>\nexport type ThemeVariantSpreadFunction<A extends PropLike> = VariantSpreadFunction<\n A,\n ThemeTokens\n>\n\n/**\n * --------------------------------------------\n * end variants\n * --------------------------------------------\n */\n\ntype SizeKeys =\n | 'width'\n | 'height'\n | 'minWidth'\n | 'minHeight'\n | 'maxWidth'\n | 'maxHeight'\n | 'shadowRadius'\n\ntype ColorKeys =\n | 'color'\n | 'backgroundColor'\n | 'borderColor'\n | 'borderBottomColor'\n | 'borderTopColor'\n | 'borderLeftColor'\n | 'borderRightColor'\n | 'shadowColor'\n | 'textShadowColor'\n\ntype SpaceKeys =\n | 'space'\n | 'padding'\n | 'paddingHorizontal'\n | 'paddingVertical'\n | 'paddingLeft'\n | 'paddingTop'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'paddingRight'\n | 'paddingEnd'\n | 'paddingStart'\n | 'margin'\n | 'marginHorizontal'\n | 'marginVertical'\n | 'marginLeft'\n | 'marginTop'\n | 'marginBottom'\n | 'marginLeft'\n | 'marginRight'\n | 'marginEnd'\n | 'marginStart'\n | 'x'\n | 'y'\n | 'scale'\n | 'scaleX'\n | 'scaleY'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderTopStartRadius'\n | 'borderBottomEndRadius'\n | 'borderBottomLeftRadius'\n | 'borderBottomRightRadius'\n | 'borderBottomStartRadius'\n | 'borderBottomWidth'\n | 'borderLeftWidth'\n | 'borderRadius'\n | 'borderRightWidth'\n | 'borderTopEndRadius'\n | 'borderTopLeftRadius'\n | 'borderTopRightRadius'\n | 'borderEndWidth'\n | 'borderStartWidth'\n | 'borderTopStartRadius'\n | 'borderTopWidth'\n | 'borderWidth'\n | 'left'\n | 'top'\n | 'right'\n | 'bottom'\n | 'shadowOffset'\n\ntype CSSColorNames =\n | 'aliceblue'\n | 'antiquewhite'\n | 'aqua'\n | 'aquamarine'\n | 'azure'\n | 'beige'\n | 'bisque'\n | 'black'\n | 'blanchedalmond'\n | 'blue'\n | 'blueviolet'\n | 'brown'\n | 'burlywood'\n | 'cadetblue'\n | 'chartreuse'\n | 'chocolate'\n | 'coral'\n | 'cornflowerblue'\n | 'cornsilk'\n | 'crimson'\n | 'cyan'\n | 'darkblue'\n | 'darkcyan'\n | 'darkgoldenrod'\n | 'darkgray'\n | 'darkgreen'\n | 'darkkhaki'\n | 'darkmagenta'\n | 'darkolivegreen'\n | 'darkorange'\n | 'darkorchid'\n | 'darkred'\n | 'darksalmon'\n | 'darkseagreen'\n | 'darkslateblue'\n | 'darkslategray'\n | 'darkturquoise'\n | 'darkviolet'\n | 'deeppink'\n | 'deepskyblue'\n | 'dimgray'\n | 'dodgerblue'\n | 'firebrick'\n | 'floralwhite'\n | 'forestgreen'\n | 'fuchsia'\n | 'gainsboro'\n | 'ghostwhite'\n | 'gold'\n | 'goldenrod'\n | 'gray'\n | 'green'\n | 'greenyellow'\n | 'honeydew'\n | 'hotpink'\n | 'indianred '\n | 'indigo '\n | 'ivory'\n | 'khaki'\n | 'lavender'\n | 'lavenderblush'\n | 'lawngreen'\n | 'lemonchiffon'\n | 'lightblue'\n | 'lightcoral'\n | 'lightcyan'\n | 'lightgoldenrodyellow'\n | 'lightgrey'\n | 'lightgreen'\n | 'lightpink'\n | 'lightsalmon'\n | 'lightseagreen'\n | 'lightskyblue'\n | 'lightslategray'\n | 'lightsteelblue'\n | 'lightyellow'\n | 'lime'\n | 'limegreen'\n | 'linen'\n | 'magenta'\n | 'maroon'\n | 'mediumaquamarine'\n | 'mediumblue'\n | 'mediumorchid'\n | 'mediumpurple'\n | 'mediumseagreen'\n | 'mediumslateblue'\n | 'mediumspringgreen'\n | 'mediumturquoise'\n | 'mediumvioletred'\n | 'midnightblue'\n | 'mintcream'\n | 'mistyrose'\n | 'moccasin'\n | 'navajowhite'\n | 'navy'\n | 'oldlace'\n | 'olive'\n | 'olivedrab'\n | 'orange'\n | 'orangered'\n | 'orchid'\n | 'palegoldenrod'\n | 'palegreen'\n | 'paleturquoise'\n | 'palevioletred'\n | 'papayawhip'\n | 'peachpuff'\n | 'peru'\n | 'pink'\n | 'plum'\n | 'powderblue'\n | 'purple'\n | 'red'\n | 'rosybrown'\n | 'royalblue'\n | 'saddlebrown'\n | 'salmon'\n | 'sandybrown'\n | 'seagreen'\n | 'seashell'\n | 'sienna'\n | 'silver'\n | 'skyblue'\n | 'slateblue'\n | 'slategray'\n | 'snow'\n | 'springgreen'\n | 'steelblue'\n | 'tan'\n | 'teal'\n | 'thistle'\n | 'tomato'\n | 'turquoise'\n | 'violet'\n | 'wheat'\n | 'white'\n | 'whitesmoke'\n | 'yellow'\n | 'yellowgreen'\n\nexport type TamaguiComponentState = {\n hover: boolean\n press: boolean\n pressIn: boolean\n focus: boolean\n unmounted: boolean\n animation?: null | {\n style?: any\n avoidClasses?: boolean\n }\n}\n\nexport type SplitStyleState = TamaguiComponentState & {\n mediaState?: Record<string, boolean>\n noClassNames?: boolean\n dynamicStylesInline?: boolean\n resolveVariablesAs?: ResolveVariableTypes\n fallbackProps?: Record<string, any>\n keepVariantsAsProps?: boolean\n hasTextAncestor?: boolean\n\n // for animations\n isExiting?: boolean\n exitVariant?: string\n enterVariant?: string\n}\n\n// Presence\n\nexport interface PresenceContextProps {\n id: string\n isPresent: boolean\n register: (id: string) => () => void\n onExitComplete?: (id: string) => void\n initial?: false | string | string[]\n custom?: any\n exitVariant?: string | null\n enterVariant?: string | null\n}\n\ntype SafeToRemoveCallback = () => void\ntype AlwaysPresent = [true, null, null]\ntype Present = [true, undefined, PresenceContextProps]\ntype NotPresent = [false, SafeToRemoveCallback, PresenceContextProps]\n\nexport type UsePresenceResult = AlwaysPresent | Present | NotPresent\n\n// Animations:\n\ntype AnimationConfig = {\n [key: string]: any\n}\n\n// includes a very limited adapter between various impls for number => style\n// this is useful only in limited scenarios like `Sheet`, but necessary in those cases\n\nexport type AnimatedNumberStrategy =\n // only values shared between reanimated/react-native for now\n | {\n type: 'spring'\n stiffness?: number\n damping?: number\n mass?: number\n overshootClamping?: boolean\n restSpeedThreshold?: number\n restDisplacementThreshold?: number\n }\n | { type: 'timing'; duration: number }\n | { type: 'direct' }\n\nexport type UniversalAnimatedNumber<A> = {\n getInstance(): A\n getValue(): number\n setValue(next: number, config?: AnimatedNumberStrategy): void\n stop(): void\n}\n\nexport type AnimationDriver<A extends AnimationConfig = AnimationConfig> = {\n isReactNative?: boolean\n useAnimations: UseAnimationHook\n usePresence: () => UsePresenceResult\n useAnimatedNumber: (initial: number) => UniversalAnimatedNumber<any>\n useAnimatedNumberStyle: <V extends UniversalAnimatedNumber<any>>(\n val: V,\n getStyle: (current: any) => any\n ) => any\n useAnimatedNumberReaction: (\n val: UniversalAnimatedNumber<any>,\n onValue: (current: number) => void\n ) => void\n animations: A\n View?: any\n Text?: any\n}\n\nexport type UseAnimationProps = TamaguiComponentPropsBase & Record<string, any>\n\nexport type UseAnimationHook = (props: {\n style: Record<string, any>\n props: Record<string, any>\n presence?: UsePresenceResult | null\n hostRef: RefObject<HTMLElement | View>\n staticConfig: StaticConfigParsed\n state: SplitStyleState\n pseudos: PseudoProps<ViewStyle> | null\n onDidAnimate?: any\n delay?: number\n}) => null | {\n style?: StackStylePropsBase | StackStylePropsBase[]\n}\n\nexport type GestureReponderEvent = Exclude<\n View['props']['onResponderMove'],\n void\n> extends (event: infer Event) => void\n ? Event\n : never\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createFont.ts"],
4
- "sourcesContent": ["import { FontWeightSteps, GenericFont } from './types'\n\nconst fontWeights: FontWeightSteps[] = [\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n]\n\nconst processSection = <T>(\n section: string | Record<string, T>,\n keys: string[],\n defaultValue?: any\n): string | Record<string, T> => {\n if (typeof section === 'string') return section\n\n const sectionKeys = Object.keys(section)\n let fillValue = section[sectionKeys[0]]\n\n return Object.fromEntries(\n [...new Set([...keys, ...sectionKeys])].map((key) => {\n const value = section[key] ?? defaultValue ?? fillValue\n fillValue = value\n defaultValue = value\n return [key, value]\n })\n )\n}\n\nexport const createFont = <A extends GenericFont>(font: A): A => {\n const sizeKeys = Object.keys(font.size)\n const processedFont = Object.fromEntries(\n Object.entries(font).map(([key, section]) => {\n return [\n key,\n processSection(\n section,\n key === 'face' ? fontWeights : sizeKeys,\n key === 'face' ? { normal: font.family } : undefined\n ),\n ]\n })\n )\n return Object.freeze(processedFont) as A\n}\n"],
4
+ "sourcesContent": ["import { FontWeightSteps, GenericFont } from './types'\n\nconst fontWeights: FontWeightSteps[] = [\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n]\n\nconst processSection = <T>(\n section: string | Record<string, T>,\n keys: string[],\n defaultValue?: any\n): string | Record<string, T> => {\n if (typeof section === 'string') return section\n\n const sectionKeys = Object.keys(section)\n let fillValue = section[sectionKeys[0]]\n\n return Object.fromEntries(\n [...new Set([...keys, ...sectionKeys])].map((key) => {\n const value = section[key] ?? defaultValue ?? fillValue\n fillValue = value\n defaultValue = value\n return [key, value]\n })\n )\n}\n\nexport const createFont = <A extends GenericFont>(font: A): A => {\n const sizeKeys = Object.keys(font.size)\n const processedFont = Object.fromEntries(\n Object.entries(font).map(([key, section]) => {\n return [\n key,\n processSection(\n section as any,\n key === 'face' ? fontWeights : sizeKeys,\n key === 'face' ? { normal: font.family } : undefined\n ),\n ]\n })\n )\n return Object.freeze(processedFont) as A\n}\n"],
5
5
  "mappings": "AAEA,MAAM,cAAiC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,iBAAiB,CACrB,SACA,MACA,iBAC+B;AAC/B,MAAI,OAAO,YAAY;AAAU,WAAO;AAExC,QAAM,cAAc,OAAO,KAAK,OAAO;AACvC,MAAI,YAAY,QAAQ,YAAY;AAEpC,SAAO,OAAO;AAAA,IACZ,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ;AACnD,YAAM,QAAQ,QAAQ,QAAQ,gBAAgB;AAC9C,kBAAY;AACZ,qBAAe;AACf,aAAO,CAAC,KAAK,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,aAAa,CAAwB,SAAe;AAC/D,QAAM,WAAW,OAAO,KAAK,KAAK,IAAI;AACtC,QAAM,gBAAgB,OAAO;AAAA,IAC3B,OAAO,QAAQ,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,OAAO,MAAM;AAC3C,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE;AAAA,UACA,QAAQ,SAAS,cAAc;AAAA,UAC/B,QAAQ,SAAS,EAAE,QAAQ,KAAK,OAAO,IAAI;AAAA,QAC7C;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO,OAAO,OAAO,aAAa;AACpC;",
6
6
  "names": []
7
7
  }
@@ -144,6 +144,7 @@ function createTamagui(configIn) {
144
144
  animations: {},
145
145
  media: {},
146
146
  ...configIn,
147
+ tokens: configIn.tokens,
147
148
  shorthands: { ...shorthands },
148
149
  inverseShorthands: shorthands ? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k])) : {},
149
150
  themes: themeConfig.themes,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createTamagui.ts"],
4
- "sourcesContent": ["import { isRSC, isWeb } from '@tamagui/constants'\n\nimport { configListeners, setConfig } from './config'\nimport { createVariables, tokensKeysOrdered } from './createVariables'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport {\n getAllRules,\n listenForSheetChanges,\n scanAllSheets,\n} from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokensValueToVariable,\n variableToCSS,\n} from './helpers/registerCSSVariable'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport {\n CreateTamaguiProps,\n InferTamaguiConfig,\n TamaguiInternalConfig,\n ThemeParsed,\n} from './types'\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n configIn: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(configIn)) {\n return configIn as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!configIn.tokens) {\n throw new Error('Must define tokens')\n }\n if (!configIn.themes) {\n throw new Error('Must define themes')\n }\n if (!configIn.fonts) {\n throw new Error('Must define fonts')\n }\n }\n\n scanAllSheets()\n listenForSheetChanges()\n\n const fontTokens = Object.fromEntries(\n Object.entries(configIn.fonts!).map(([k, v]) => {\n return [k, createVariables(v, 'f', true)]\n })\n )\n\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...configIn.themes }\n const cssRuleSets: string[] = []\n\n if (isWeb) {\n const declarations: string[] = []\n const fontDeclarations: Record<\n string,\n { name: string; declarations: string[]; language?: string }\n > = {}\n\n for (const key in configIn.tokens) {\n for (const skey in configIn.tokens[key]) {\n const val = configIn.tokens[key][skey]\n registerCSSVariable(val)\n declarations.push(variableToCSS(val))\n }\n }\n\n for (const key in fontsParsed) {\n const fontParsed = fontsParsed[key]\n const [name, language] = key.includes('_') ? key.split('_') : [key]\n const fontVars = registerFontVariables(fontParsed)\n fontDeclarations[key] = {\n name: name.slice(1),\n declarations: fontVars,\n language,\n }\n }\n\n const sep =\n process.env.NODE_ENV === 'development' ? configIn.cssStyleSeparator || ' ' : ''\n\n function declarationsToRuleSet(decs: string[], selector = '') {\n return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`\n }\n\n // non-font\n cssRuleSets.push(declarationsToRuleSet(declarations))\n\n // fonts\n if (fontDeclarations) {\n for (const key in fontDeclarations) {\n const { name, declarations, language = 'default' } = fontDeclarations[key]\n const fontSelector = `.font_${name}`\n const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`\n const selectors =\n language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector\n const specificRuleSet = declarationsToRuleSet(declarations, selectors)\n cssRuleSets.push(specificRuleSet)\n }\n }\n }\n\n // dedupe themes to avoid duplicate CSS generation\n type DedupedTheme = {\n names: string[]\n theme: ThemeParsed\n }\n const dedupedThemes: {\n [key: string]: DedupedTheme\n } = {}\n const existing = new WeakMap<ThemeParsed, DedupedTheme>()\n\n // first, de-dupe and parse them\n for (const themeName in themes) {\n const rawTheme = themes[themeName] as ThemeParsed\n\n // if existing, avoid\n if (existing.has(rawTheme)) {\n const e = existing.get(rawTheme)!\n themes[themeName] = e.theme\n e.names.push(themeName)\n continue\n }\n\n // ensure each theme object unique for dedupe\n const theme = { ...rawTheme }\n // parse into variables\n for (const key in theme) {\n // make sure properly names theme variables\n ensureThemeVariable(theme, key)\n }\n themes[themeName] = theme\n\n // set deduped\n dedupedThemes[themeName] = {\n names: [themeName],\n theme,\n }\n existing.set(rawTheme, dedupedThemes[themeName])\n }\n\n // then, generate CSS from de-duped\n let themeRuleSets: string[] = []\n\n if (isWeb || isRSC) {\n for (const themeName in dedupedThemes) {\n themeRuleSets = [\n ...themeRuleSets,\n ...getThemeCSSRules({\n config: configIn,\n themeName,\n ...dedupedThemes[themeName],\n }),\n ]\n }\n }\n\n // proxy upwards to get parent variables (themes are subset going down)\n for (const themeName in themes) {\n themes[themeName] = proxyThemeToParents(themeName, themes[themeName], themes)\n }\n\n tokensValueToVariable.clear()\n\n return {\n themes,\n cssRuleSets,\n themeRuleSets,\n }\n })()\n\n // faster $lookups\n const tokensParsed: any = Object.fromEntries(\n Object.entries(configIn.tokens).map(([k, v]) => {\n const val = Object.fromEntries(Object.entries(v).map(([k, v]) => [`$${k}`, v]))\n tokensKeysOrdered.set(val, tokensKeysOrdered.get(v))\n return [k, val]\n })\n )\n\n const shorthands = configIn.shorthands || {}\n\n const config: TamaguiInternalConfig = {\n fontLanguages: [],\n animations: {} as any,\n media: {},\n ...configIn,\n // vite made this into a function if it wasn't set\n shorthands: { ...shorthands },\n inverseShorthands: shorthands\n ? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k]))\n : {},\n themes: themeConfig.themes as any,\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS: (separator = '\\n') => {\n return `.t_unmounted .t_will-mount {opacity:0;visibility:hidden;}\n.is_Text .is_Text {display:inline-flex;}\n._dsp_contents {display:contents;}\n${themeConfig.cssRuleSets.join(separator)}\n${themeConfig.themeRuleSets.join(separator)}\n${getAllRules().join(separator)}`\n },\n // const tokens = [...getToken(tokens.size[0])]\n // .spacer-sm + ._dsp_contents._dsp-sm-hidden { margin-left: -var(--${}) }\n }\n\n configureMedia(config)\n setConfig(config)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(config))\n configListeners.clear()\n }\n\n createdConfigs.set(config, true)\n\n if (process.env.NODE_ENV === 'development') {\n if (process.env.DEBUG?.startsWith('tamagui')) {\n // eslint-disable-next-line no-console\n console.log('Tamagui config:', config)\n }\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n }\n\n return config as any\n}\n"],
5
- "mappings": "AAAA,SAAS,OAAO,aAAa;AAE7B,SAAS,iBAAiB,iBAAiB;AAC3C,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,wBAAwB;AACjC;AAAA,EACE;A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UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IACrE,CAAC;AAAA,IACL,QAAQ,YAAY;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ,CAAC,YAAY,SAAS;AAC5B,aAAO;AAAA;AAAA;AAAA,EAGX,YAAY,YAAY,KAAK,SAAS;AAAA,EACtC,YAAY,cAAc,KAAK,SAAS;AAAA,EACxC,YAAY,EAAE,KAAK,SAAS;AAAA,IAC1B;AAAA,EAGF;AAEA,iBAAe,MAAM;AACrB,YAAU,MAAM;AAEhB,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;AAC1C,oBAAgB,MAAM;AAAA,EACxB;AAEA,iBAAe,IAAI,QAAQ,IAAI;AAE/B,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,SAAI,aAAQ,IAAI,UAAZ,mBAAmB,WAAW,YAAY;AAE5C,cAAQ,IAAI,mBAAmB,MAAM;AAAA,IACvC;AACA,QAAI,CAAC,WAAW,YAAY;AAC1B,iBAAW,aAAa;AAAA,IAC1B;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { isRSC, isWeb } from '@tamagui/constants'\n\nimport { configListeners, setConfig } from './config'\nimport { createVariables, tokensKeysOrdered } from './createVariables'\nimport { getThemeCSSRules } from './helpers/getThemeCSSRules'\nimport {\n getAllRules,\n listenForSheetChanges,\n scanAllSheets,\n} from './helpers/insertStyleRule'\nimport {\n registerCSSVariable,\n tokensValueToVariable,\n variableToCSS,\n} from './helpers/registerCSSVariable'\nimport { ensureThemeVariable, proxyThemeToParents } from './helpers/themes'\nimport { configureMedia } from './hooks/useMedia'\nimport { parseFont, registerFontVariables } from './insertFont'\nimport { Tamagui } from './Tamagui'\nimport {\n CreateTamaguiProps,\n InferTamaguiConfig,\n TamaguiInternalConfig,\n ThemeParsed,\n} from './types'\n\n// config is re-run by the @tamagui/static, dont double validate\nconst createdConfigs = new WeakMap<any, boolean>()\n\nexport function createTamagui<Conf extends CreateTamaguiProps>(\n configIn: Conf\n): InferTamaguiConfig<Conf> {\n if (createdConfigs.has(configIn)) {\n return configIn as any\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (!configIn.tokens) {\n throw new Error('Must define tokens')\n }\n if (!configIn.themes) {\n throw new Error('Must define themes')\n }\n if (!configIn.fonts) {\n throw new Error('Must define fonts')\n }\n }\n\n scanAllSheets()\n listenForSheetChanges()\n\n const fontTokens = Object.fromEntries(\n Object.entries(configIn.fonts!).map(([k, v]) => {\n return [k, createVariables(v, 'f', true)]\n })\n )\n\n const fontsParsed = (() => {\n const res = {} as typeof fontTokens\n for (const familyName in fontTokens) {\n res[`$${familyName}`] = parseFont(fontTokens[familyName])\n }\n return res!\n })()\n\n const themeConfig = (() => {\n const themes = { ...configIn.themes }\n const cssRuleSets: string[] = []\n\n if (isWeb) {\n const declarations: string[] = []\n const fontDeclarations: Record<\n string,\n { name: string; declarations: string[]; language?: string }\n > = {}\n\n for (const key in configIn.tokens) {\n for (const skey in configIn.tokens[key]) {\n const val = configIn.tokens[key][skey]\n registerCSSVariable(val)\n declarations.push(variableToCSS(val))\n }\n }\n\n for (const key in fontsParsed) {\n const fontParsed = fontsParsed[key]\n const [name, language] = key.includes('_') ? key.split('_') : [key]\n const fontVars = registerFontVariables(fontParsed)\n fontDeclarations[key] = {\n name: name.slice(1),\n declarations: fontVars,\n language,\n }\n }\n\n const sep =\n process.env.NODE_ENV === 'development' ? configIn.cssStyleSeparator || ' ' : ''\n\n function declarationsToRuleSet(decs: string[], selector = '') {\n return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`\n }\n\n // non-font\n cssRuleSets.push(declarationsToRuleSet(declarations))\n\n // fonts\n if (fontDeclarations) {\n for (const key in fontDeclarations) {\n const { name, declarations, language = 'default' } = fontDeclarations[key]\n const fontSelector = `.font_${name}`\n const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`\n const selectors =\n language === 'default' ? ` ${fontSelector}, ${langSelector}` : langSelector\n const specificRuleSet = declarationsToRuleSet(declarations, selectors)\n cssRuleSets.push(specificRuleSet)\n }\n }\n }\n\n // dedupe themes to avoid duplicate CSS generation\n type DedupedTheme = {\n names: string[]\n theme: ThemeParsed\n }\n const dedupedThemes: {\n [key: string]: DedupedTheme\n } = {}\n const existing = new WeakMap<ThemeParsed, DedupedTheme>()\n\n // first, de-dupe and parse them\n for (const themeName in themes) {\n const rawTheme = themes[themeName] as ThemeParsed\n\n // if existing, avoid\n if (existing.has(rawTheme)) {\n const e = existing.get(rawTheme)!\n themes[themeName] = e.theme\n e.names.push(themeName)\n continue\n }\n\n // ensure each theme object unique for dedupe\n const theme = { ...rawTheme }\n // parse into variables\n for (const key in theme) {\n // make sure properly names theme variables\n ensureThemeVariable(theme, key)\n }\n themes[themeName] = theme\n\n // set deduped\n dedupedThemes[themeName] = {\n names: [themeName],\n theme,\n }\n existing.set(rawTheme, dedupedThemes[themeName])\n }\n\n // then, generate CSS from de-duped\n let themeRuleSets: string[] = []\n\n if (isWeb || isRSC) {\n for (const themeName in dedupedThemes) {\n themeRuleSets = [\n ...themeRuleSets,\n ...getThemeCSSRules({\n config: configIn,\n themeName,\n ...dedupedThemes[themeName],\n }),\n ]\n }\n }\n\n // proxy upwards to get parent variables (themes are subset going down)\n for (const themeName in themes) {\n themes[themeName] = proxyThemeToParents(themeName, themes[themeName], themes)\n }\n\n tokensValueToVariable.clear()\n\n return {\n themes,\n cssRuleSets,\n themeRuleSets,\n }\n })()\n\n // faster $lookups\n const tokensParsed: any = Object.fromEntries(\n Object.entries(configIn.tokens).map(([k, v]) => {\n const val = Object.fromEntries(Object.entries(v).map(([k, v]) => [`$${k}`, v]))\n tokensKeysOrdered.set(val, tokensKeysOrdered.get(v))\n return [k, val]\n })\n )\n\n const shorthands = configIn.shorthands || {}\n\n const config: TamaguiInternalConfig = {\n fontLanguages: [],\n animations: {} as any,\n media: {},\n ...configIn,\n // already processed by createTokens()\n tokens: configIn.tokens as any,\n // vite made this into a function if it wasn't set\n shorthands: { ...shorthands },\n inverseShorthands: shorthands\n ? Object.fromEntries(Object.entries(shorthands).map(([k, v]) => [v, k]))\n : {},\n themes: themeConfig.themes as any,\n fontsParsed,\n themeConfig,\n tokensParsed,\n parsed: true,\n getCSS: (separator = '\\n') => {\n return `.t_unmounted .t_will-mount {opacity:0;visibility:hidden;}\n.is_Text .is_Text {display:inline-flex;}\n._dsp_contents {display:contents;}\n${themeConfig.cssRuleSets.join(separator)}\n${themeConfig.themeRuleSets.join(separator)}\n${getAllRules().join(separator)}`\n },\n // const tokens = [...getToken(tokens.size[0])]\n // .spacer-sm + ._dsp_contents._dsp-sm-hidden { margin-left: -var(--${}) }\n }\n\n configureMedia(config)\n setConfig(config)\n\n if (configListeners.size) {\n configListeners.forEach((cb) => cb(config))\n configListeners.clear()\n }\n\n createdConfigs.set(config, true)\n\n if (process.env.NODE_ENV === 'development') {\n if (process.env.DEBUG?.startsWith('tamagui')) {\n // eslint-disable-next-line no-console\n console.log('Tamagui config:', config)\n }\n if (!globalThis['Tamagui']) {\n globalThis['Tamagui'] = Tamagui\n }\n }\n\n return config as any\n}\n"],
5
+ "mappings": "AAAA,SAAS,OAAO,aAAa;AAE7B,SAAS,iBAAiB,iBAAiB;AAC3C,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB,2BAA2B;AACzD,SAAS,sBAAsB;AAC/B,SAAS,WAAW,6BAA6B;AACjD,SAAS,eAAe;AASxB,MAAM,iBAAiB,oBAAI,QAAsB;AAE1C,SAAS,cACd,UAC0B;AA/B5B;AAgCE,MAAI,eAAe,IAAI,QAAQ,GAAG;AAChC,WAAO;AAAA,EACT;AAEA,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AAc,KAAK,SAAS;AAAA,EACxC,YAAY,EAAE,KAAK,SAAS;AAAA,IAC1B;AAAA,EAGF;AAEA,iBAAe,MAAM;AACrB,YAAU,MAAM;AAEhB,MAAI,gBAAgB,MAAM;AACxB,oBAAgB,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;AAC1C,oBAAgB,MAAM;AAAA,EACxB;AAEA,iBAAe,IAAI,QAAQ,IAAI;AAE/B,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,SAAI,aAAQ,IAAI,UAAZ,mBAAmB,WAAW,YAAY;AAE5C,cAAQ,IAAI,mBAAmB,MAAM;AAAA,IACvC;AACA,QAAI,CAAC,WAAW,YAAY;AAC1B,iBAAW,aAAa;AAAA,IAC1B;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": ["declarationsToRuleSet", "declarations", "k", "v"]
7
7
  }
@@ -1,7 +1,14 @@
1
1
  import { createVariables } from "./createVariables";
2
- function createTokens(tokens) {
3
- return createVariables(tokens);
2
+ function createTokens(tokens2) {
3
+ return createVariables(tokens2);
4
4
  }
5
+ const tokens = createTokens({
6
+ size: { 0: 1 },
7
+ space: { 0: 1 },
8
+ radius: { 0: 1 },
9
+ zIndex: { 0: 1 },
10
+ color: { 0: "hi" }
11
+ });
5
12
  export {
6
13
  createTokens
7
14
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createTokens.ts"],
4
- "sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n return createVariables(tokens) as any\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n [Key in keyof E]: E[Key] extends Variable ? E[Key] : Variable<E[Key]>\n }\n space: {\n [Key in keyof F]: F[Key] extends Variable ? F[Key] : Variable<F[Key]>\n }\n size: {\n [Key in keyof G]: G[Key] extends Variable ? G[Key] : Variable<G[Key]>\n }\n radius: {\n [Key in keyof H]: H[Key] extends Variable ? H[Key] : Variable<H[Key]>\n }\n zIndex: {\n [Key in keyof J]: J[Key] extends Variable ? J[Key] : Variable<J[Key]>\n }\n }\n : never\n"],
5
- "mappings": "AACA,SAAS,uBAAuB;AAIzB,SAAS,aAAqC,QAA0B;AAC7E,SAAO,gBAAgB,MAAM;AAC/B;",
6
- "names": []
4
+ "sourcesContent": ["import { Variable } from './createVariable'\nimport { createVariables } from './createVariables'\nimport { CreateTokens } from './types'\n\n// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' }\nexport function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> {\n return createVariables(tokens) as any\n}\n\n// verbose but gives us nice types...\ntype MakeTokens<T> = T extends {\n color: infer E\n space: infer F\n size: infer G\n radius: infer H\n zIndex: infer J\n}\n ? {\n color: {\n // removes $ prefix allowing for defining either as $1: or 1:,\n // which is important because Chrome re-orders numerical-seeming keys :/\n [Key in keyof E extends `$${infer X}` ? X : keyof E]: Variable<string>\n }\n space: {\n [Key in keyof F extends `$${infer X}` ? X : keyof F]: Variable<number>\n }\n size: {\n [Key in keyof G extends `$${infer X}` ? X : keyof G]: Variable<number>\n }\n radius: {\n [Key in keyof H extends `$${infer X}` ? X : keyof H]: Variable<number>\n }\n zIndex: {\n [Key in keyof J extends `$${infer X}` ? X : keyof J]: Variable<number>\n }\n }\n : never\n\n// test\nconst tokens = createTokens({\n size: { 0: 1 },\n space: { 0: 1 },\n radius: { 0: 1 },\n zIndex: { 0: 1 },\n color: { 0: 'hi' },\n})\n"],
5
+ "mappings": "AACA,SAAS,uBAAuB;AAIzB,SAAS,aAAqCA,SAA0B;AAC7E,SAAO,gBAAgBA,OAAM;AAC/B;AAgCA,MAAM,SAAS,aAAa;AAAA,EAC1B,MAAM,EAAE,GAAG,EAAE;AAAA,EACb,OAAO,EAAE,GAAG,EAAE;AAAA,EACd,QAAQ,EAAE,GAAG,EAAE;AAAA,EACf,QAAQ,EAAE,GAAG,EAAE;AAAA,EACf,OAAO,EAAE,GAAG,KAAK;AACnB,CAAC;",
6
+ "names": ["tokens"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createVariable.ts"],
4
- "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = 'isVar'\n\ntype VariableIn<A = any> = {\n val: A\n name: string\n key: string\n}\n\nexport type Variable<A = any> = VariableIn<A> & {\n [IS_VAR]?: true\n variable?: string\n}\n\nexport const createVariable = <A extends string | number = any>(props: VariableIn<A>) => {\n if (isVariable(props)) return props\n const { key, name, val } = props\n return {\n [IS_VAR]: true,\n key,\n name: simpleHash(name, 40),\n val,\n variable: isWeb ? createCSSVariable(name) : '',\n }\n}\n\n// could do weakmap cache\nexport function variableToString(vrble?: any, getValue = false) {\n if (isVariable(vrble)) {\n if (!getValue && isWeb && vrble.variable) {\n return vrble.variable\n }\n return `${vrble.val}`\n }\n return `${vrble || ''}`\n}\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v && typeof v === 'object' && IS_VAR in v\n}\n\nexport function getVariable(nameOrVariable: Variable | string) {\n setDidGetVariableValue(true)\n if (isVariable(nameOrVariable)) {\n return variableToString(nameOrVariable)\n }\n const tokens = getConfig().tokensParsed\n return variableToString(tokens[nameOrVariable] ?? nameOrVariable)\n}\n\nlet accessed = false\nexport const setDidGetVariableValue = (val: boolean) => (accessed = val)\nexport const didGetVariableValue = () => accessed\n\nexport function getVariableValue(v: Variable | any) {\n if (isVariable(v)) {\n setDidGetVariableValue(true)\n return v.val\n }\n return v\n}\n\nexport function getVariableName(v: Variable | any) {\n if (isVariable(v)) return v.name\n return v\n}\n\nexport function getVariableVariable(v: Variable | any) {\n if (isVariable(v)) return v.variable\n return v\n}\n\n// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):\nexport const createCSSVariable = (nameProp: string, includeVar = true) => {\n if (process.env.NODE_ENV === 'development') {\n if (!nameProp || typeof nameProp !== 'string') {\n throw new Error(`createCSSVariable expected string: ${nameProp}`)\n }\n }\n const name = simpleHash(nameProp, 60)\n return includeVar ? `var(--${name})` : name\n}\n"],
5
- "mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAE3B,SAAS,iBAAiB;AAO1B,MAAM,SAAS;AAaR,MAAM,iBAAiB,CAAkC,UAAyB;AACvF,MAAI,WAAW,KAAK;AAAG,WAAO;AAC9B,QAAM,EAAE,KAAK,MAAM,IAAI,IAAI;AAC3B,SAAO;AAAA,IACL,CAAC,SAAS;AAAA,IACV;AAAA,IACA,MAAM,WAAW,MAAM,EAAE;AAAA,IACzB;AAAA,IACA,UAAU,QAAQ,kBAAkB,IAAI,IAAI;AAAA,EAC9C;AACF;AAGO,SAAS,iBAAiB,OAAa,WAAW,OAAO;AAC9D,MAAI,WAAW,KAAK,GAAG;AACrB,QAAI,CAAC,YAAY,SAAS,MAAM,UAAU;AACxC,aAAO,MAAM;AAAA,IACf;AACA,WAAO,GAAG,MAAM;AAAA,EAClB;AACA,SAAO,GAAG,SAAS;AACrB;AAEO,SAAS,WAAW,GAAkC;AAC3D,SAAO,KAAK,OAAO,MAAM,YAAY,UAAU;AACjD;AAEO,SAAS,YAAY,gBAAmC;AAC7D,yBAAuB,IAAI;AAC3B,MAAI,WAAW,cAAc,GAAG;AAC9B,WAAO,iBAAiB,cAAc;AAAA,EACxC;AACA,QAAM,SAAS,UAAU,EAAE;AAC3B,SAAO,iBAAiB,OAAO,mBAAmB,cAAc;AAClE;AAEA,IAAI,WAAW;AACR,MAAM,yBAAyB,CAAC,QAAkB,WAAW;AAC7D,MAAM,sBAAsB,MAAM;AAElC,SAAS,iBAAiB,GAAmB;AAClD,MAAI,WAAW,CAAC,GAAG;AACjB,2BAAuB,IAAI;AAC3B,WAAO,EAAE;AAAA,EACX;AACA,SAAO;AACT;AAEO,SAAS,gBAAgB,GAAmB;AACjD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAEO,SAAS,oBAAoB,GAAmB;AACrD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAGO,MAAM,oBAAoB,CAAC,UAAkB,aAAa,SAAS;AACxE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,YAAY,OAAO,aAAa,UAAU;AAC7C,YAAM,IAAI,MAAM,sCAAsC,UAAU;AAAA,IAClE;AAAA,EACF;AACA,QAAM,OAAO,WAAW,UAAU,EAAE;AACpC,SAAO,aAAa,SAAS,UAAU;AACzC;",
4
+ "sourcesContent": ["import { isWeb } from '@tamagui/constants'\nimport { simpleHash } from '@tamagui/helpers'\n\nimport { getConfig } from './config'\n\n/**\n * Should rename this to Token\n * Moving to objects for React Server Components support\n */\n\nconst IS_VAR = 'isVar'\n\nexport interface Variable<A = any> {\n [IS_VAR]?: true\n variable?: string\n val: A\n name: string\n key: string\n}\n\nexport type MakeVariable<A = any> = A extends string | number ? Variable<A> : A\n\ntype VariableIn<A = any> = Pick<Variable<A>, 'key' | 'name' | 'val'>\nexport const createVariable = <A extends string | number = any>(\n props: VariableIn<A>\n): Variable<A> => {\n if (isVariable(props)) return props\n const { key, name, val } = props\n return {\n [IS_VAR]: true,\n key: key!,\n name: simpleHash(name, 40),\n val: val as any,\n variable: isWeb ? createCSSVariable(name) : '',\n }\n}\n\n// could do weakmap cache\nexport function variableToString(vrble?: any, getValue = false) {\n if (isVariable(vrble)) {\n if (!getValue && isWeb && vrble.variable) {\n return vrble.variable\n }\n return `${vrble.val}`\n }\n return `${vrble || ''}`\n}\n\nexport function isVariable(v: Variable | any): v is Variable {\n return v && typeof v === 'object' && IS_VAR in v\n}\n\nexport function getVariable(nameOrVariable: Variable | string) {\n setDidGetVariableValue(true)\n if (isVariable(nameOrVariable)) {\n return variableToString(nameOrVariable)\n }\n const tokens = getConfig().tokensParsed\n return variableToString(tokens[nameOrVariable] ?? nameOrVariable)\n}\n\nlet accessed = false\nexport const setDidGetVariableValue = (val: boolean) => (accessed = val)\nexport const didGetVariableValue = () => accessed\n\nexport function getVariableValue(v: Variable | any) {\n if (isVariable(v)) {\n setDidGetVariableValue(true)\n return v.val\n }\n return v\n}\n\nexport function getVariableName(v: Variable | any) {\n if (isVariable(v)) return v.name\n return v\n}\n\nexport function getVariableVariable(v: Variable | any) {\n if (isVariable(v)) return v.variable\n return v\n}\n\n// bugfix { space: { 0.5: 10 } } was generating var(--space-0.5) (invalid CSS):\nexport const createCSSVariable = (nameProp: string, includeVar = true) => {\n if (process.env.NODE_ENV === 'development') {\n if (!nameProp || typeof nameProp !== 'string') {\n throw new Error(`createCSSVariable expected string: ${nameProp}`)\n }\n }\n const name = simpleHash(nameProp, 60)\n return includeVar ? `var(--${name})` : name\n}\n"],
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAE3B,SAAS,iBAAiB;AAO1B,MAAM,SAAS;AAaR,MAAM,iBAAiB,CAC5B,UACgB;AAChB,MAAI,WAAW,KAAK;AAAG,WAAO;AAC9B,QAAM,EAAE,KAAK,MAAM,IAAI,IAAI;AAC3B,SAAO;AAAA,IACL,CAAC,SAAS;AAAA,IACV;AAAA,IACA,MAAM,WAAW,MAAM,EAAE;AAAA,IACzB;AAAA,IACA,UAAU,QAAQ,kBAAkB,IAAI,IAAI;AAAA,EAC9C;AACF;AAGO,SAAS,iBAAiB,OAAa,WAAW,OAAO;AAC9D,MAAI,WAAW,KAAK,GAAG;AACrB,QAAI,CAAC,YAAY,SAAS,MAAM,UAAU;AACxC,aAAO,MAAM;AAAA,IACf;AACA,WAAO,GAAG,MAAM;AAAA,EAClB;AACA,SAAO,GAAG,SAAS;AACrB;AAEO,SAAS,WAAW,GAAkC;AAC3D,SAAO,KAAK,OAAO,MAAM,YAAY,UAAU;AACjD;AAEO,SAAS,YAAY,gBAAmC;AAC7D,yBAAuB,IAAI;AAC3B,MAAI,WAAW,cAAc,GAAG;AAC9B,WAAO,iBAAiB,cAAc;AAAA,EACxC;AACA,QAAM,SAAS,UAAU,EAAE;AAC3B,SAAO,iBAAiB,OAAO,mBAAmB,cAAc;AAClE;AAEA,IAAI,WAAW;AACR,MAAM,yBAAyB,CAAC,QAAkB,WAAW;AAC7D,MAAM,sBAAsB,MAAM;AAElC,SAAS,iBAAiB,GAAmB;AAClD,MAAI,WAAW,CAAC,GAAG;AACjB,2BAAuB,IAAI;AAC3B,WAAO,EAAE;AAAA,EACX;AACA,SAAO;AACT;AAEO,SAAS,gBAAgB,GAAmB;AACjD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAEO,SAAS,oBAAoB,GAAmB;AACrD,MAAI,WAAW,CAAC;AAAG,WAAO,EAAE;AAC5B,SAAO;AACT;AAGO,MAAM,oBAAoB,CAAC,UAAkB,aAAa,SAAS;AACxE,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,CAAC,YAAY,OAAO,aAAa,UAAU;AAC7C,YAAM,IAAI,MAAM,sCAAsC,UAAU;AAAA,IAClE;AAAA,EACF;AACA,QAAM,OAAO,WAAW,UAAU,EAAE;AACpC,SAAO,aAAa,SAAS,UAAU;AACzC;",
6
6
  "names": []
7
7
  }
@@ -25,20 +25,19 @@ function proxyThemeToParents(themeName, theme, themes) {
25
25
  cur.push(part);
26
26
  return cur.join("_");
27
27
  });
28
- const hasParents = parents.length;
28
+ const len = parents.length;
29
29
  return new Proxy(theme, {
30
30
  get(target, key) {
31
31
  if (key === GetThemeUnwrapped) {
32
32
  return theme;
33
33
  }
34
- if (!hasParents || Reflect.has(target, key)) {
34
+ if (!len || Reflect.has(target, key)) {
35
35
  return Reflect.get(target, key);
36
36
  }
37
- for (let i = parents.length - 1; i >= 0; i--) {
37
+ for (let i = len - 1; i >= 0; i--) {
38
38
  const parent = themes[parents[i]];
39
- if (!parent) {
39
+ if (!parent)
40
40
  continue;
41
- }
42
41
  if (Reflect.has(parent, key)) {
43
42
  return Reflect.get(parent, key);
44
43
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/themes.ts"],
4
- "sourcesContent": ["import { createVariable, isVariable } from '../createVariable'\nimport { GetThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { CreateTamaguiProps } from '../types'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const hasParents = parents.length\n\n // proxy fallback values to parent theme values\n return new Proxy(theme, {\n get(target, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (!hasParents || Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n // check parents\n for (let i = parents.length - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) {\n continue\n }\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n return Reflect.get(target, key)\n },\n })\n}\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS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wrapped'\nimport { CreateTamaguiProps } from '../types'\n\n// mutates, freeze after\n// shared by createTamagui so extracted here\nexport function ensureThemeVariable(theme: any, key: string) {\n const val = theme[key]\n const themeKey = key\n if (!isVariable(val)) {\n theme[key] = createVariable({\n key: themeKey,\n name: themeKey,\n val,\n })\n } else {\n if (val.name !== themeKey) {\n // rename to theme name\n theme[key] = createVariable({\n key: val.name,\n name: themeKey,\n val: val.val,\n })\n }\n }\n}\n\nexport function proxyThemeToParents(\n themeName: string,\n theme: any,\n themes: CreateTamaguiProps['themes']\n) {\n // we could test if this is better as just a straight object spread or fancier proxy\n const cur: string[] = []\n // if theme is dark_blue_alt1_Button\n // this will be the parent names in order: ['dark', 'dark_blue', 'dark_blue_alt1\"]\n const parents = themeName\n .split('_')\n .slice(0, -1)\n .map((part) => {\n cur.push(part)\n return cur.join('_')\n })\n\n const len = parents.length\n\n // proxy fallback values to parent theme values\n return new Proxy(theme, {\n get(target, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n }\n if (!len || Reflect.has(target, key)) {\n return Reflect.get(target, key)\n }\n // check parents\n for (let i = len - 1; i >= 0; i--) {\n const parent = themes[parents[i]]\n if (!parent) continue\n if (Reflect.has(parent, key)) {\n return Reflect.get(parent, key)\n }\n }\n return Reflect.get(target, key)\n },\n })\n}\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,yBAAyB;AAK3B,SAAS,oBAAoB,OAAY,KAAa;AAC3D,QAAM,MAAM,MAAM;AAClB,QAAM,WAAW;AACjB,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,OAAO,eAAe;AAAA,MAC1B,KAAK;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,QAAI,IAAI,SAAS,UAAU;AAEzB,YAAM,OAAO,eAAe;AAAA,QAC1B,KAAK,IAAI;AAAA,QACT,MAAM;AAAA,QACN,KAAK,IAAI;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,oBACd,WACA,OACA,QACA;AAEA,QAAM,MAAgB,CAAC;AAGvB,QAAM,UAAU,UACb,MAAM,GAAG,EACT,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,QAAI,KAAK,IAAI;AACb,WAAO,IAAI,KAAK,GAAG;AAAA,EACrB,CAAC;AAEH,QAAM,MAAM,QAAQ;AAGpB,SAAO,IAAI,MAAM,OAAO;AAAA,IACtB,IAAI,QAAQ,KAAK;AACf,UAAI,QAAQ,mBAAmB;AAC7B,eAAO;AAAA,MACT;AACA,UAAI,CAAC,OAAO,QAAQ,IAAI,QAAQ,GAAG,GAAG;AACpC,eAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,MAChC;AAEA,eAAS,IAAI,MAAM,GAAG,KAAK,GAAG,KAAK;AACjC,cAAM,SAAS,OAAO,QAAQ;AAC9B,YAAI,CAAC;AAAQ;AACb,YAAI,QAAQ,IAAI,QAAQ,GAAG,GAAG;AAC5B,iBAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,QAChC;AAAA,MACF;AACA,aAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,IAChC;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -30,22 +30,22 @@
30
30
  "reset.css"
31
31
  ],
32
32
  "dependencies": {
33
- "@tamagui/compose-refs": "^1.0.17",
34
- "@tamagui/constants": "^1.0.17",
35
- "@tamagui/helpers": "^1.0.17",
36
- "@tamagui/normalize-css-color": "^1.0.17",
37
- "@tamagui/react-native-use-pressable": "^1.0.17",
38
- "@tamagui/react-native-use-responder-events": "^1.0.17",
39
- "@tamagui/use-did-finish-ssr": "^1.0.17",
40
- "@tamagui/use-event": "^1.0.17",
41
- "@tamagui/use-force-update": "^1.0.17"
33
+ "@tamagui/compose-refs": "^1.0.19",
34
+ "@tamagui/constants": "^1.0.19",
35
+ "@tamagui/helpers": "^1.0.19",
36
+ "@tamagui/normalize-css-color": "^1.0.19",
37
+ "@tamagui/react-native-use-pressable": "^1.0.19",
38
+ "@tamagui/react-native-use-responder-events": "^1.0.19",
39
+ "@tamagui/use-did-finish-ssr": "^1.0.19",
40
+ "@tamagui/use-event": "^1.0.19",
41
+ "@tamagui/use-force-update": "^1.0.19"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": "*",
45
45
  "react-dom": "*"
46
46
  },
47
47
  "devDependencies": {
48
- "@tamagui/build": "^1.0.17",
48
+ "@tamagui/build": "^1.0.19",
49
49
  "@testing-library/react": "^13.4.0",
50
50
  "csstype": "^3.0.10",
51
51
  "react": "^18.2.0",
package/src/createFont.ts CHANGED
@@ -39,7 +39,7 @@ export const createFont = <A extends GenericFont>(font: A): A => {
39
39
  return [
40
40
  key,
41
41
  processSection(
42
- section,
42
+ section as any,
43
43
  key === 'face' ? fontWeights : sizeKeys,
44
44
  key === 'face' ? { normal: font.family } : undefined
45
45
  ),
@@ -202,6 +202,8 @@ export function createTamagui<Conf extends CreateTamaguiProps>(
202
202
  animations: {} as any,
203
203
  media: {},
204
204
  ...configIn,
205
+ // already processed by createTokens()
206
+ tokens: configIn.tokens as any,
205
207
  // vite made this into a function if it wasn't set
206
208
  shorthands: { ...shorthands },
207
209
  inverseShorthands: shorthands
@@ -17,19 +17,30 @@ type MakeTokens<T> = T extends {
17
17
  }
18
18
  ? {
19
19
  color: {
20
- [Key in keyof E]: E[Key] extends Variable ? E[Key] : Variable<E[Key]>
20
+ // removes $ prefix allowing for defining either as $1: or 1:,
21
+ // which is important because Chrome re-orders numerical-seeming keys :/
22
+ [Key in keyof E extends `$${infer X}` ? X : keyof E]: Variable<string>
21
23
  }
22
24
  space: {
23
- [Key in keyof F]: F[Key] extends Variable ? F[Key] : Variable<F[Key]>
25
+ [Key in keyof F extends `$${infer X}` ? X : keyof F]: Variable<number>
24
26
  }
25
27
  size: {
26
- [Key in keyof G]: G[Key] extends Variable ? G[Key] : Variable<G[Key]>
28
+ [Key in keyof G extends `$${infer X}` ? X : keyof G]: Variable<number>
27
29
  }
28
30
  radius: {
29
- [Key in keyof H]: H[Key] extends Variable ? H[Key] : Variable<H[Key]>
31
+ [Key in keyof H extends `$${infer X}` ? X : keyof H]: Variable<number>
30
32
  }
31
33
  zIndex: {
32
- [Key in keyof J]: J[Key] extends Variable ? J[Key] : Variable<J[Key]>
34
+ [Key in keyof J extends `$${infer X}` ? X : keyof J]: Variable<number>
33
35
  }
34
36
  }
35
37
  : never
38
+
39
+ // test
40
+ const tokens = createTokens({
41
+ size: { 0: 1 },
42
+ space: { 0: 1 },
43
+ radius: { 0: 1 },
44
+ zIndex: { 0: 1 },
45
+ color: { 0: 'hi' },
46
+ })
@@ -10,25 +10,27 @@ import { getConfig } from './config'
10
10
 
11
11
  const IS_VAR = 'isVar'
12
12
 
13
- type VariableIn<A = any> = {
13
+ export interface Variable<A = any> {
14
+ [IS_VAR]?: true
15
+ variable?: string
14
16
  val: A
15
17
  name: string
16
18
  key: string
17
19
  }
18
20
 
19
- export type Variable<A = any> = VariableIn<A> & {
20
- [IS_VAR]?: true
21
- variable?: string
22
- }
21
+ export type MakeVariable<A = any> = A extends string | number ? Variable<A> : A
23
22
 
24
- export const createVariable = <A extends string | number = any>(props: VariableIn<A>) => {
23
+ type VariableIn<A = any> = Pick<Variable<A>, 'key' | 'name' | 'val'>
24
+ export const createVariable = <A extends string | number = any>(
25
+ props: VariableIn<A>
26
+ ): Variable<A> => {
25
27
  if (isVariable(props)) return props
26
28
  const { key, name, val } = props
27
29
  return {
28
30
  [IS_VAR]: true,
29
- key,
31
+ key: key!,
30
32
  name: simpleHash(name, 40),
31
- val,
33
+ val: val as any,
32
34
  variable: isWeb ? createCSSVariable(name) : '',
33
35
  }
34
36
  }
@@ -42,7 +42,7 @@ export function proxyThemeToParents(
42
42
  return cur.join('_')
43
43
  })
44
44
 
45
- const hasParents = parents.length
45
+ const len = parents.length
46
46
 
47
47
  // proxy fallback values to parent theme values
48
48
  return new Proxy(theme, {
@@ -50,15 +50,13 @@ export function proxyThemeToParents(
50
50
  if (key === GetThemeUnwrapped) {
51
51
  return theme
52
52
  }
53
- if (!hasParents || Reflect.has(target, key)) {
53
+ if (!len || Reflect.has(target, key)) {
54
54
  return Reflect.get(target, key)
55
55
  }
56
56
  // check parents
57
- for (let i = parents.length - 1; i >= 0; i--) {
57
+ for (let i = len - 1; i >= 0; i--) {
58
58
  const parent = themes[parents[i]]
59
- if (!parent) {
60
- continue
61
- }
59
+ if (!parent) continue
62
60
  if (Reflect.has(parent, key)) {
63
61
  return Reflect.get(parent, key)
64
62
  }
package/src/types.tsx CHANGED
@@ -94,6 +94,18 @@ export interface CreateTokens<Val extends VariableVal = VariableVal> {
94
94
  zIndex: { [key: GenericKey]: Val }
95
95
  }
96
96
 
97
+ type Tokenify<A extends GenericTokens> = {
98
+ color: TokenifyRecord<A['color']>
99
+ space: TokenifyRecord<A['space']>
100
+ size: TokenifyRecord<A['size']>
101
+ radius: TokenifyRecord<A['radius']>
102
+ zIndex: TokenifyRecord<A['zIndex']>
103
+ }
104
+
105
+ type TokenifyRecord<A extends CreateTokens[keyof CreateTokens]> = {
106
+ [Key in keyof A]: Variable<A[Key]>
107
+ }
108
+
97
109
  export type TamaguiBaseTheme = {
98
110
  // defined for our tamagui kit , we could do this inside `tamagui`
99
111
  // but maybe helpful to have some sort of universally shared things +
@@ -375,11 +387,12 @@ export type TamaguiInternalConfig<
375
387
  E extends GenericAnimations = GenericAnimations,
376
388
  F extends GenericFonts = GenericFonts
377
389
  > = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> &
378
- CreateTamaguiConfig<A, B, C, D, E, F> & {
390
+ Omit<CreateTamaguiConfig<A, B, C, D, E, F>, 'tokens'> & {
379
391
  // TODO need to make it this but this breaks types, revisit
380
392
  // animations: E //AnimationDriver<E>
381
393
  // with $ prefixes for fast lookups (one time cost at startup vs every render)
382
- tokensParsed: CreateTokens<Variable>
394
+ tokens: Tokenify<A>
395
+ tokensParsed: Tokenify<A>
383
396
  themeConfig: any
384
397
  fontsParsed: GenericFonts
385
398
  getCSS: () => string
@@ -9,19 +9,19 @@ type MakeTokens<T> = T extends {
9
9
  zIndex: infer J;
10
10
  } ? {
11
11
  color: {
12
- [Key in keyof E]: E[Key] extends Variable ? E[Key] : Variable<E[Key]>;
12
+ [Key in keyof E extends `$${infer X}` ? X : keyof E]: Variable<string>;
13
13
  };
14
14
  space: {
15
- [Key in keyof F]: F[Key] extends Variable ? F[Key] : Variable<F[Key]>;
15
+ [Key in keyof F extends `$${infer X}` ? X : keyof F]: Variable<number>;
16
16
  };
17
17
  size: {
18
- [Key in keyof G]: G[Key] extends Variable ? G[Key] : Variable<G[Key]>;
18
+ [Key in keyof G extends `$${infer X}` ? X : keyof G]: Variable<number>;
19
19
  };
20
20
  radius: {
21
- [Key in keyof H]: H[Key] extends Variable ? H[Key] : Variable<H[Key]>;
21
+ [Key in keyof H extends `$${infer X}` ? X : keyof H]: Variable<number>;
22
22
  };
23
23
  zIndex: {
24
- [Key in keyof J]: J[Key] extends Variable ? J[Key] : Variable<J[Key]>;
24
+ [Key in keyof J extends `$${infer X}` ? X : keyof J]: Variable<number>;
25
25
  };
26
26
  } : never;
27
27
  export {};
@@ -3,22 +3,16 @@
3
3
  * Moving to objects for React Server Components support
4
4
  */
5
5
  declare const IS_VAR = "isVar";
6
- type VariableIn<A = any> = {
7
- val: A;
8
- name: string;
9
- key: string;
10
- };
11
- export type Variable<A = any> = VariableIn<A> & {
6
+ export interface Variable<A = any> {
12
7
  [IS_VAR]?: true;
13
8
  variable?: string;
14
- };
15
- export declare const createVariable: <A extends string | number = any>(props: VariableIn<A>) => VariableIn<A> | {
16
- isVar: boolean;
17
- key: string;
18
- name: string;
19
9
  val: A;
20
- variable: string;
21
- };
10
+ name: string;
11
+ key: string;
12
+ }
13
+ export type MakeVariable<A = any> = A extends string | number ? Variable<A> : A;
14
+ type VariableIn<A = any> = Pick<Variable<A>, 'key' | 'name' | 'val'>;
15
+ export declare const createVariable: <A extends string | number = any>(props: VariableIn<A>) => Variable<A>;
22
16
  export declare function variableToString(vrble?: any, getValue?: boolean): string;
23
17
  export declare function isVariable(v: Variable | any): v is Variable;
24
18
  export declare function getVariable(nameOrVariable: Variable | string): string;
@@ -28,7 +28,7 @@ export declare class ThemeManager {
28
28
  getState(props?: ThemeProps, parentManager?: ThemeManager | null): ThemeManagerState | null;
29
29
  _allKeys: Set<string> | null;
30
30
  get allKeys(): Set<string>;
31
- getValue(key: string, state?: ThemeManagerState): import("../types").VariableVal | undefined;
31
+ getValue(key: string, state?: ThemeManagerState): string | number | import("..").Variable<any> | undefined;
32
32
  notify(): void;
33
33
  onChangeTheme(cb: ThemeListener): () => void;
34
34
  }
package/types/types.d.ts CHANGED
@@ -66,6 +66,16 @@ export interface CreateTokens<Val extends VariableVal = VariableVal> {
66
66
  [key: GenericKey]: Val;
67
67
  };
68
68
  }
69
+ type Tokenify<A extends GenericTokens> = {
70
+ color: TokenifyRecord<A['color']>;
71
+ space: TokenifyRecord<A['space']>;
72
+ size: TokenifyRecord<A['size']>;
73
+ radius: TokenifyRecord<A['radius']>;
74
+ zIndex: TokenifyRecord<A['zIndex']>;
75
+ };
76
+ type TokenifyRecord<A extends CreateTokens[keyof CreateTokens]> = {
77
+ [Key in keyof A]: Variable<A[Key]>;
78
+ };
69
79
  export type TamaguiBaseTheme = {
70
80
  background: VariableColorVal;
71
81
  backgroundHover: VariableColorVal;
@@ -214,8 +224,9 @@ export type CreateTamaguiProps = {
214
224
  shouldAddPrefersColorThemes?: boolean;
215
225
  themeClassNameOnRoot?: boolean;
216
226
  };
217
- export type TamaguiInternalConfig<A extends GenericTokens = GenericTokens, B extends GenericThemes = GenericThemes, C extends GenericShorthands = GenericShorthands, D extends GenericMedia = GenericMedia, E extends GenericAnimations = GenericAnimations, F extends GenericFonts = GenericFonts> = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> & CreateTamaguiConfig<A, B, C, D, E, F> & {
218
- tokensParsed: CreateTokens<Variable>;
227
+ export type TamaguiInternalConfig<A extends GenericTokens = GenericTokens, B extends GenericThemes = GenericThemes, C extends GenericShorthands = GenericShorthands, D extends GenericMedia = GenericMedia, E extends GenericAnimations = GenericAnimations, F extends GenericFonts = GenericFonts> = Omit<CreateTamaguiProps, keyof GenericTamaguiConfig> & Omit<CreateTamaguiConfig<A, B, C, D, E, F>, 'tokens'> & {
228
+ tokens: Tokenify<A>;
229
+ tokensParsed: Tokenify<A>;
219
230
  themeConfig: any;
220
231
  fontsParsed: GenericFonts;
221
232
  getCSS: () => string;