@kbach/react-native 1.0.0-beta.46 → 1.0.0-beta.48
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/AGENTS.md +325 -0
- package/README.md +73 -13
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-3KLOVONL.mjs +564 -0
- package/dist/{chunk-UFSVFF3V.mjs → chunk-SC3L5I7H.mjs} +1 -1
- package/dist/{chunk-KT6TQLWI.mjs → chunk-XOH25F3E.mjs} +1 -1
- package/dist/dynamicTokens.d.ts +18 -1
- package/dist/index.js +23 -2
- package/dist/index.web.js +1 -1
- package/dist/index.web.mjs +2 -2
- package/dist/jsx-dev-runtime.js +23 -2
- package/dist/jsx-dev-runtime.web.js +1 -1
- package/dist/jsx-dev-runtime.web.mjs +3 -3
- package/dist/jsx-runtime.js +23 -2
- package/dist/jsx-runtime.web.js +1 -1
- package/dist/jsx-runtime.web.mjs +2 -2
- package/package.json +3 -2
- package/dist/chunk-DKZM4NUU.mjs +0 -564
package/dist/dynamicTokens.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
|
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,28 @@ 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 quoted = match[1].replace(/\s+/g, "");
|
|
1904
|
+
if (quoted === "") return classString;
|
|
1905
|
+
const parts = classString.split(/(\s+)/);
|
|
1906
|
+
const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
|
|
1907
|
+
if (idx === -1) return classString;
|
|
1908
|
+
parts[idx] = `\xBB${parts[idx]}\xAB`;
|
|
1909
|
+
return parts.join("");
|
|
1910
|
+
}
|
|
1891
1911
|
function warnIfDev(classString, warnings) {
|
|
1892
1912
|
if (warnings.length === 0) return;
|
|
1893
1913
|
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
1894
1914
|
for (const warning of warnings) {
|
|
1895
1915
|
const message = `${warning}
|
|
1896
|
-
From className: "${classString}"`;
|
|
1916
|
+
From className: "${highlightToken(classString, warning)}"`;
|
|
1897
1917
|
if (warnedMessages.has(message)) continue;
|
|
1918
|
+
if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
|
|
1898
1919
|
warnedMessages.add(message);
|
|
1899
1920
|
console.warn(message);
|
|
1900
1921
|
}
|