@kbach/react-native 1.0.0-beta.46 → 1.0.0-beta.47

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,6 +1,6 @@
1
1
  import {
2
2
  resolveClassName
3
- } from "./chunk-DKZM4NUU.mjs";
3
+ } from "./chunk-3KLOVONL.mjs";
4
4
 
5
5
  // src/jsxRuntimeCoreWeb.ts
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getTheme
3
- } from "./chunk-DKZM4NUU.mjs";
3
+ } from "./chunk-3KLOVONL.mjs";
4
4
 
5
5
  // src/darkModeStore.ts
6
6
  import { Appearance } from "react-native";
@@ -24,7 +24,24 @@
24
24
  * one of those re-renders, so the resolved style stays correct regardless
25
25
  * — the redundant re-render is a cheap, accepted trade-off, not a bug.
26
26
  */
27
- /** `name` is the bare token name, WITHOUT the leading `--` (matching how `getDynamicToken`/`var(--name)` substitution both address it). */
27
+ /**
28
+ * `name` is the bare token name, WITHOUT the leading `--` (matching how
29
+ * `getDynamicToken`/`var(--name)` substitution both address it).
30
+ *
31
+ * `notify()` below is synchronous and immediately re-renders every
32
+ * already-mounted `ReactiveElement` subscribed via `useSyncExternalStore`
33
+ * (jsxRuntimeCore.ts) — safe when called from a component's own render
34
+ * body (React explicitly allows a component updating external state during
35
+ * its OWN render), a real hazard called from anywhere else with no fixed
36
+ * point in the render lifecycle: module-top-level code in particular runs
37
+ * whenever Metro's inline-requires first evaluates that module, which can
38
+ * land in the middle of React rendering a completely unrelated component
39
+ * elsewhere in the tree — the "Cannot update a component while rendering a
40
+ * different component" class of bug. Reported from a QA pass. Call it
41
+ * synchronously from your app's ROOT component's render (before any
42
+ * consumer has mounted), guarded so it only fires once — see this
43
+ * package's own AGENTS.md section 8 for the full Bad/Good example.
44
+ */
28
45
  declare function setDynamicToken(name: string, value: string): void;
29
46
  declare function getDynamicToken(name: string): string | undefined;
30
47
  declare function deleteDynamicToken(name: string): void;
package/dist/index.js CHANGED
@@ -1739,6 +1739,12 @@ function isPlainPercentage(value) {
1739
1739
  if (digits.startsWith("-")) digits = digits.slice(1);
1740
1740
  return digits.length > 0 && /^[0-9.]+$/.test(digits);
1741
1741
  }
1742
+ function sanitizeForWarning(value) {
1743
+ const MAX_CHARS = 60;
1744
+ const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
1745
+ if (escaped.length <= MAX_CHARS) return escaped;
1746
+ return `${escaped.slice(0, MAX_CHARS)}\u2026`;
1747
+ }
1742
1748
  function rnStyleValue(property, value) {
1743
1749
  if (property === "aspect-ratio") {
1744
1750
  if (value.trim() === "auto") return { value: null, warning: null };
@@ -1779,7 +1785,8 @@ function rnStyleValue(property, value) {
1779
1785
  if (reduced !== null) {
1780
1786
  return { value: reduced, warning: null };
1781
1787
  }
1782
- const warning = `[Kbach] "${value}" isn't a valid native value for "${property}" \u2014 dropped.
1788
+ const sanitizedValue = sanitizeForWarning(value);
1789
+ const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
1783
1790
  calc()/min()/max()/clamp() only resolve on native when every operand is a constant px/rem length (no %, vw, vh, var(), or other viewport/CSS-variable units \u2014 those need real layout/DOM, which doesn't exist on native at paint time).
1784
1791
  Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
1785
1792
  return { value: null, warning };
@@ -1887,14 +1894,27 @@ function resolveStyleUncached(classString, pressed, colorScheme, width, themeJso
1887
1894
  }
1888
1895
  return style;
1889
1896
  }
1897
+ var WARNED_MESSAGES_MAX = 500;
1890
1898
  var warnedMessages = /* @__PURE__ */ new Set();
1899
+ var QUOTED_TOKEN_RE = /"([^"]*)"/;
1900
+ function highlightToken(classString, warning) {
1901
+ const match = QUOTED_TOKEN_RE.exec(warning);
1902
+ if (match === null) return classString;
1903
+ const token = match[1];
1904
+ const parts = classString.split(/(\s+)/);
1905
+ const idx = parts.indexOf(token);
1906
+ if (idx === -1) return classString;
1907
+ parts[idx] = `\xBB${token}\xAB`;
1908
+ return parts.join("");
1909
+ }
1891
1910
  function warnIfDev(classString, warnings) {
1892
1911
  if (warnings.length === 0) return;
1893
1912
  if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1894
1913
  for (const warning of warnings) {
1895
1914
  const message = `${warning}
1896
- From className: "${classString}"`;
1915
+ From className: "${highlightToken(classString, warning)}"`;
1897
1916
  if (warnedMessages.has(message)) continue;
1917
+ if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
1898
1918
  warnedMessages.add(message);
1899
1919
  console.warn(message);
1900
1920
  }