@kbach/react-native 1.0.0-beta.3 → 1.0.0-beta.5

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.
@@ -0,0 +1,32 @@
1
+ import {
2
+ ThemeProvider,
3
+ useGlobalDarkMode,
4
+ useTheme
5
+ } from "./chunk-4KCCEMEN.mjs";
6
+ import {
7
+ resolveStyle
8
+ } from "./chunk-KSDFO34H.mjs";
9
+ import {
10
+ defaultTheme,
11
+ getGlobalDarkMode,
12
+ getGlobalThemeMode,
13
+ getTheme,
14
+ setGlobalThemeMode,
15
+ setTheme,
16
+ subscribeGlobalDarkMode,
17
+ toggleGlobalDarkMode
18
+ } from "./chunk-AEVOM2NB.mjs";
19
+ export {
20
+ ThemeProvider,
21
+ defaultTheme,
22
+ getGlobalDarkMode,
23
+ getGlobalThemeMode,
24
+ getTheme,
25
+ resolveStyle,
26
+ setGlobalThemeMode,
27
+ setTheme,
28
+ subscribeGlobalDarkMode,
29
+ toggleGlobalDarkMode,
30
+ useGlobalDarkMode,
31
+ useTheme
32
+ };
@@ -1,19 +1,10 @@
1
- import { ReactElement } from 'react';
1
+ import * as react from 'react';
2
2
  export { Fragment } from 'react';
3
3
 
4
- /**
5
- * @kbach/react-native/jsx-dev-runtime
6
- *
7
- * Development variant — Metro calls jsxDEV instead of jsx/jsxs in dev
8
- * builds. Same pattern as @kbach/react/jsx-dev-runtime (Phase 3): reuses
9
- * jsx/jsxs for the actual interception, then patches _source/_self onto
10
- * the result so React DevTools shows the original file/line.
11
- */
12
-
13
- declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
4
+ declare const jsxDEV: (type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
14
5
  fileName: string;
15
6
  lineNumber: number;
16
7
  columnNumber: number;
17
- }, self?: unknown): ReactElement;
8
+ }, self?: unknown) => react.ReactElement;
18
9
 
19
10
  export { jsxDEV };
@@ -1,19 +1,10 @@
1
- import { ReactElement } from 'react';
1
+ import * as react from 'react';
2
2
  export { Fragment } from 'react';
3
3
 
4
- /**
5
- * @kbach/react-native/jsx-dev-runtime
6
- *
7
- * Development variant — Metro calls jsxDEV instead of jsx/jsxs in dev
8
- * builds. Same pattern as @kbach/react/jsx-dev-runtime (Phase 3): reuses
9
- * jsx/jsxs for the actual interception, then patches _source/_self onto
10
- * the result so React DevTools shows the original file/line.
11
- */
12
-
13
- declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
4
+ declare const jsxDEV: (type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
14
5
  fileName: string;
15
6
  lineNumber: number;
16
7
  columnNumber: number;
17
- }, self?: unknown): ReactElement;
8
+ }, self?: unknown) => react.ReactElement;
18
9
 
19
10
  export { jsxDEV };
@@ -25,13 +25,56 @@ __export(jsx_dev_runtime_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(jsx_dev_runtime_exports);
27
27
 
28
- // src/jsx-runtime.tsx
28
+ // src/jsxRuntimeCore.ts
29
29
  var import_jsx_runtime = require("react/jsx-runtime");
30
30
  var import_react = require("react");
31
- var import_react_native3 = require("react-native");
31
+ var import_react_native = require("react-native");
32
+ function makeElement(isStaticChildren, type, props, key) {
33
+ return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
34
+ }
35
+ function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
36
+ const resolved = resolveStyle2(classStrRaw, pressed);
37
+ if (userStyle === void 0) {
38
+ return resolved;
39
+ }
40
+ if (typeof userStyle === "function") {
41
+ return [resolved, userStyle({ pressed })];
42
+ }
43
+ return [resolved, userStyle];
44
+ }
45
+ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
46
+ if (type === null || typeof type === "symbol" || !rawProps) {
47
+ return makeElement(isStaticChildren, type, rawProps ?? {}, key);
48
+ }
49
+ const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
50
+ if (typeof classStrRaw !== "string") {
51
+ return makeElement(isStaticChildren, type, rawProps, key);
52
+ }
53
+ const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
54
+ return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
55
+ }
56
+ function createJsxFunctions(resolveStyle2) {
57
+ function jsx2(type, props, key) {
58
+ return processElement(resolveStyle2, type, props, key, false);
59
+ }
60
+ function jsxs2(type, props, key) {
61
+ return processElement(resolveStyle2, type, props, key, true);
62
+ }
63
+ return { jsx: jsx2, jsxs: jsxs2 };
64
+ }
65
+ function createJsxDEV(jsx2, jsxs2) {
66
+ return function jsxDEV2(type, props, key, isStaticChildren, source, self) {
67
+ const element = (isStaticChildren ? jsxs2 : jsx2)(type, props, key);
68
+ if (source && element && typeof element === "object" && Object.isExtensible(element)) {
69
+ element._source = source;
70
+ element._self = self;
71
+ }
72
+ return element;
73
+ };
74
+ }
32
75
 
33
76
  // src/nativeBridge.ts
34
- var import_react_native2 = require("react-native");
77
+ var import_react_native3 = require("react-native");
35
78
 
36
79
  // src/generatedPalette.ts
37
80
  var PALETTE = {
@@ -339,17 +382,17 @@ function getThemeJson() {
339
382
  }
340
383
 
341
384
  // src/darkModeStore.ts
342
- var import_react_native = require("react-native");
385
+ var import_react_native2 = require("react-native");
343
386
  var listeners = /* @__PURE__ */ new Set();
344
387
  function systemPrefersDark() {
345
- return import_react_native.Appearance.getColorScheme() === "dark";
388
+ return import_react_native2.Appearance.getColorScheme() === "dark";
346
389
  }
347
390
  function resolveIsDark(m) {
348
391
  return m === "system" ? systemPrefersDark() : m === "dark";
349
392
  }
350
393
  var mode = "system";
351
394
  var isDark = resolveIsDark(mode);
352
- var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
395
+ var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
353
396
  if (mode !== "system") return;
354
397
  isDark = colorScheme === "dark";
355
398
  notify();
@@ -363,54 +406,18 @@ function getGlobalDarkMode() {
363
406
 
364
407
  // src/nativeBridge.ts
365
408
  function resolveStyle(classString, pressed = false) {
366
- const KbachModule = import_react_native2.TurboModuleRegistry.getEnforcing("KbachModule");
409
+ const KbachModule = import_react_native3.TurboModuleRegistry.getEnforcing("KbachModule");
367
410
  const colorScheme = getGlobalDarkMode() ? "dark" : "light";
368
- const width = import_react_native2.Dimensions.get("window").width;
411
+ const width = import_react_native3.Dimensions.get("window").width;
369
412
  const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
370
413
  return JSON.parse(json);
371
414
  }
372
415
 
373
416
  // src/jsx-runtime.tsx
374
- function makeElement(isStaticChildren, type, props, key) {
375
- return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
376
- }
377
- function resolvedStyleFor(classStrRaw, userStyle, pressed) {
378
- const resolved = resolveStyle(classStrRaw, pressed);
379
- if (userStyle === void 0) {
380
- return resolved;
381
- }
382
- if (typeof userStyle === "function") {
383
- return [resolved, userStyle({ pressed })];
384
- }
385
- return [resolved, userStyle];
386
- }
387
- function processElement(type, rawProps, key, isStaticChildren) {
388
- if (type === null || typeof type === "symbol" || !rawProps) {
389
- return makeElement(isStaticChildren, type, rawProps ?? {}, key);
390
- }
391
- const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
392
- if (typeof classStrRaw !== "string") {
393
- return makeElement(isStaticChildren, type, rawProps, key);
394
- }
395
- const finalStyle = type === import_react_native3.Pressable ? (state) => resolvedStyleFor(classStrRaw, userStyle, state.pressed) : resolvedStyleFor(classStrRaw, userStyle, false);
396
- return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
397
- }
398
- function jsx(type, props, key) {
399
- return processElement(type, props, key, false);
400
- }
401
- function jsxs(type, props, key) {
402
- return processElement(type, props, key, true);
403
- }
417
+ var { jsx, jsxs } = createJsxFunctions(resolveStyle);
404
418
 
405
419
  // src/jsx-dev-runtime.tsx
406
- function jsxDEV(type, props, key, isStaticChildren, source, self) {
407
- const element = (isStaticChildren ? jsxs : jsx)(type, props, key);
408
- if (source && element && typeof element === "object" && Object.isExtensible(element)) {
409
- element._source = source;
410
- element._self = self;
411
- }
412
- return element;
413
- }
420
+ var jsxDEV = createJsxDEV(jsx, jsxs);
414
421
  // Annotate the CommonJS export names for ESM import in node:
415
422
  0 && (module.exports = {
416
423
  Fragment,
@@ -1,19 +1,16 @@
1
1
  import {
2
- Fragment,
3
2
  jsx,
4
3
  jsxs
5
- } from "./chunk-UP5ZN7CN.mjs";
6
- import "./chunk-7KUNKZBM.mjs";
4
+ } from "./chunk-OJQAJLYT.mjs";
5
+ import "./chunk-FG5E4NLJ.mjs";
6
+ import {
7
+ Fragment,
8
+ createJsxDEV
9
+ } from "./chunk-DLIXI5OW.mjs";
10
+ import "./chunk-AEVOM2NB.mjs";
7
11
 
8
12
  // src/jsx-dev-runtime.tsx
9
- function jsxDEV(type, props, key, isStaticChildren, source, self) {
10
- const element = (isStaticChildren ? jsxs : jsx)(type, props, key);
11
- if (source && element && typeof element === "object" && Object.isExtensible(element)) {
12
- element._source = source;
13
- element._self = self;
14
- }
15
- return element;
16
- }
13
+ var jsxDEV = createJsxDEV(jsx, jsxs);
17
14
  export {
18
15
  Fragment,
19
16
  jsxDEV
@@ -0,0 +1,10 @@
1
+ import * as react from 'react';
2
+ export { Fragment } from 'react';
3
+
4
+ declare const jsxDEV: (type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
5
+ fileName: string;
6
+ lineNumber: number;
7
+ columnNumber: number;
8
+ }, self?: unknown) => react.ReactElement;
9
+
10
+ export { jsxDEV };
@@ -0,0 +1,10 @@
1
+ import * as react from 'react';
2
+ export { Fragment } from 'react';
3
+
4
+ declare const jsxDEV: (type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
5
+ fileName: string;
6
+ lineNumber: number;
7
+ columnNumber: number;
8
+ }, self?: unknown) => react.ReactElement;
9
+
10
+ export { jsxDEV };