@kbach/react-native 1.0.0-beta.25 → 1.0.0-beta.27

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,10 +1,10 @@
1
- import "./chunk-JENWPIJT.mjs";
1
+ import "./chunk-MXIT3EDJ.mjs";
2
2
  import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-EBLZ3CJG.mjs";
7
- import "./chunk-TBDAJIR3.mjs";
6
+ } from "./chunk-GHQ7DWLO.mjs";
7
+ import "./chunk-BEXNFWW6.mjs";
8
8
 
9
9
  // src/jsxRuntimeCore.ts
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1929,16 +1929,33 @@ function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, wi
1929
1929
  }
1930
1930
 
1931
1931
  // src/nativeBridge.ts
1932
+ var RESOLVE_STYLE_CACHE_MAX = 500;
1933
+ var resolveStyleCache = /* @__PURE__ */ new Map();
1934
+ var cachedForThemeJson = null;
1932
1935
  function resolveStyle(classString, pressed = false) {
1933
1936
  const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
1934
1937
  const width = import_react_native2.Dimensions.get("window").width;
1938
+ const themeJson = (0, import_theme.getThemeJson)();
1939
+ if (themeJson !== cachedForThemeJson) {
1940
+ resolveStyleCache.clear();
1941
+ cachedForThemeJson = themeJson;
1942
+ }
1943
+ const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
1944
+ const cached = resolveStyleCache.get(cacheKey);
1945
+ if (cached !== void 0) return { ...cached };
1946
+ const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
1947
+ if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
1948
+ resolveStyleCache.set(cacheKey, style);
1949
+ return { ...style };
1950
+ }
1951
+ function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
1935
1952
  const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
1936
1953
  if (!KbachModule) {
1937
1954
  const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
1938
1955
  warnIfDev(classString, warnings2);
1939
1956
  return style2;
1940
1957
  }
1941
- const json = KbachModule.resolveStyle(classString, (0, import_theme.getThemeJson)(), colorScheme, pressed, width);
1958
+ const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
1942
1959
  const style = JSON.parse(json);
1943
1960
  const warnings = style.__kbachWarnings;
1944
1961
  if (warnings !== void 0) {