achery-ui 0.8.1 → 0.8.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "achery-ui",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Achery Workshop design system — autumn alchemy, hard edges, botanical marginalia.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,11 +2,22 @@ import { View } from 'react-native'
2
2
  import type { ViewStyle } from 'react-native'
3
3
  import { useTheme } from '../theme/ThemeContext'
4
4
  import type { GlyphName } from '../../types/components'
5
- import * as NativeGlyphs from '../../glyphs/svg-components-native/index'
6
5
 
7
6
  const toComponentName = (name: GlyphName): string =>
8
7
  name.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join('')
9
8
 
9
+ // Inline require() at render time — avoids the import* barrel forcing all
10
+ // 396 react-native-svg component modules to initialise before native is ready.
11
+ function getGlyphComponent(compName: string): React.ComponentType<{ size?: number; color?: string }> | null {
12
+ try {
13
+ // Metro resolves this as a static require map because the path prefix is constant.
14
+ const mod = require(`../../glyphs/svg-components-native/${compName}.tsx`)
15
+ return mod?.default ?? null
16
+ } catch {
17
+ return null
18
+ }
19
+ }
20
+
10
21
  export interface NativeGlyphProps {
11
22
  /** Name of the glyph to render. */
12
23
  name: GlyphName
@@ -28,7 +39,7 @@ export const Glyph = ({ name, size = 24, color, accessibilityLabel, style }: Nat
28
39
  const { tokens } = useTheme()
29
40
  const resolvedColor = color ?? tokens.fg
30
41
  const compName = toComponentName(name)
31
- const SvgComponent = (NativeGlyphs as Record<string, React.ComponentType<{ size?: number; color?: string }> | undefined>)[compName]
42
+ const SvgComponent = getGlyphComponent(compName)
32
43
 
33
44
  if (!SvgComponent) {
34
45
  return <View style={[{ width: size, height: size }, style]} accessibilityLabel={accessibilityLabel} />