uitheme-rn 1.0.2 → 1.0.3

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/dist/core.cjs CHANGED
@@ -26,10 +26,20 @@ __export(core_exports, {
26
26
  module.exports = __toCommonJS(core_exports);
27
27
 
28
28
  // src/core/store.ts
29
- var import_zod = require("zod");
30
29
  function isTheme(value) {
31
30
  return value === "light" || value === "dark" || value === "system";
32
31
  }
32
+ function isStoredRecord(value) {
33
+ return value instanceof Object && !Array.isArray(value);
34
+ }
35
+ function parseStoredPreferences(record, colorThemes) {
36
+ if (record.version !== 1) return void 0;
37
+ return {
38
+ version: 1,
39
+ theme: isTheme(record.theme) ? record.theme : void 0,
40
+ colorTheme: colorThemes.find((name) => name === record.colorTheme)
41
+ };
42
+ }
33
43
  function createThemeStore(options) {
34
44
  const colorThemes = [...options.colorThemes];
35
45
  const defaultColorTheme = options.defaultColorTheme ?? colorThemes[0];
@@ -40,11 +50,6 @@ function createThemeStore(options) {
40
50
  throw new Error("Invalid default appearance mode.");
41
51
  }
42
52
  const storageKey = options.storageKey ?? "uitheme-rn:preferences";
43
- const storedPreferences = import_zod.z.object({
44
- version: import_zod.z.literal(1),
45
- theme: import_zod.z.enum(["light", "dark", "system"]).optional().catch(void 0),
46
- colorTheme: import_zod.z.string().refine((name) => colorThemes.includes(name)).optional().catch(void 0)
47
- });
48
53
  const listeners = /* @__PURE__ */ new Set();
49
54
  let state = Object.freeze({
50
55
  theme: options.defaultTheme ?? "system",
@@ -82,9 +87,9 @@ function createThemeStore(options) {
82
87
  try {
83
88
  const value = await options.storage?.getItem(storageKey);
84
89
  if (value) {
85
- const result = storedPreferences.safeParse(JSON.parse(value));
86
- if (!result.success) return;
87
- const saved = result.data;
90
+ const record = JSON.parse(value);
91
+ const saved = isStoredRecord(record) ? parseStoredPreferences(record, colorThemes) : void 0;
92
+ if (!saved) return;
88
93
  update({
89
94
  theme: !dirtyTheme && saved.theme !== void 0 ? saved.theme : state.theme,
90
95
  colorTheme: !dirtyColorTheme && saved.colorTheme !== void 0 ? saved.colorTheme : state.colorTheme
package/dist/core.js CHANGED
@@ -1,8 +1,18 @@
1
1
  // src/core/store.ts
2
- import { z } from "zod";
3
2
  function isTheme(value) {
4
3
  return value === "light" || value === "dark" || value === "system";
5
4
  }
5
+ function isStoredRecord(value) {
6
+ return value instanceof Object && !Array.isArray(value);
7
+ }
8
+ function parseStoredPreferences(record, colorThemes) {
9
+ if (record.version !== 1) return void 0;
10
+ return {
11
+ version: 1,
12
+ theme: isTheme(record.theme) ? record.theme : void 0,
13
+ colorTheme: colorThemes.find((name) => name === record.colorTheme)
14
+ };
15
+ }
6
16
  function createThemeStore(options) {
7
17
  const colorThemes = [...options.colorThemes];
8
18
  const defaultColorTheme = options.defaultColorTheme ?? colorThemes[0];
@@ -13,11 +23,6 @@ function createThemeStore(options) {
13
23
  throw new Error("Invalid default appearance mode.");
14
24
  }
15
25
  const storageKey = options.storageKey ?? "uitheme-rn:preferences";
16
- const storedPreferences = z.object({
17
- version: z.literal(1),
18
- theme: z.enum(["light", "dark", "system"]).optional().catch(void 0),
19
- colorTheme: z.string().refine((name) => colorThemes.includes(name)).optional().catch(void 0)
20
- });
21
26
  const listeners = /* @__PURE__ */ new Set();
22
27
  let state = Object.freeze({
23
28
  theme: options.defaultTheme ?? "system",
@@ -55,9 +60,9 @@ function createThemeStore(options) {
55
60
  try {
56
61
  const value = await options.storage?.getItem(storageKey);
57
62
  if (value) {
58
- const result = storedPreferences.safeParse(JSON.parse(value));
59
- if (!result.success) return;
60
- const saved = result.data;
63
+ const record = JSON.parse(value);
64
+ const saved = isStoredRecord(record) ? parseStoredPreferences(record, colorThemes) : void 0;
65
+ if (!saved) return;
61
66
  update({
62
67
  theme: !dirtyTheme && saved.theme !== void 0 ? saved.theme : state.theme,
63
68
  colorTheme: !dirtyColorTheme && saved.colorTheme !== void 0 ? saved.colorTheme : state.colorTheme
package/dist/index.cjs CHANGED
@@ -37,10 +37,20 @@ var import_react = require("react");
37
37
  var import_react_native = require("react-native");
38
38
 
39
39
  // src/core/store.ts
40
- var import_zod = require("zod");
41
40
  function isTheme(value) {
42
41
  return value === "light" || value === "dark" || value === "system";
43
42
  }
43
+ function isStoredRecord(value) {
44
+ return value instanceof Object && !Array.isArray(value);
45
+ }
46
+ function parseStoredPreferences(record, colorThemes) {
47
+ if (record.version !== 1) return void 0;
48
+ return {
49
+ version: 1,
50
+ theme: isTheme(record.theme) ? record.theme : void 0,
51
+ colorTheme: colorThemes.find((name) => name === record.colorTheme)
52
+ };
53
+ }
44
54
  function createThemeStore(options) {
45
55
  const colorThemes = [...options.colorThemes];
46
56
  const defaultColorTheme = options.defaultColorTheme ?? colorThemes[0];
@@ -51,11 +61,6 @@ function createThemeStore(options) {
51
61
  throw new Error("Invalid default appearance mode.");
52
62
  }
53
63
  const storageKey = options.storageKey ?? "uitheme-rn:preferences";
54
- const storedPreferences = import_zod.z.object({
55
- version: import_zod.z.literal(1),
56
- theme: import_zod.z.enum(["light", "dark", "system"]).optional().catch(void 0),
57
- colorTheme: import_zod.z.string().refine((name) => colorThemes.includes(name)).optional().catch(void 0)
58
- });
59
64
  const listeners = /* @__PURE__ */ new Set();
60
65
  let state = Object.freeze({
61
66
  theme: options.defaultTheme ?? "system",
@@ -93,9 +98,9 @@ function createThemeStore(options) {
93
98
  try {
94
99
  const value = await options.storage?.getItem(storageKey);
95
100
  if (value) {
96
- const result = storedPreferences.safeParse(JSON.parse(value));
97
- if (!result.success) return;
98
- const saved = result.data;
101
+ const record = JSON.parse(value);
102
+ const saved = isStoredRecord(record) ? parseStoredPreferences(record, colorThemes) : void 0;
103
+ if (!saved) return;
99
104
  update({
100
105
  theme: !dirtyTheme && saved.theme !== void 0 ? saved.theme : state.theme,
101
106
  colorTheme: !dirtyColorTheme && saved.colorTheme !== void 0 ? saved.colorTheme : state.colorTheme
@@ -309,8 +314,15 @@ function useThemeColors() {
309
314
  return useUITheme().colors;
310
315
  }
311
316
 
317
+ // src/validators.ts
318
+ function isString(value) {
319
+ return typeof value === "string";
320
+ }
321
+ function isCssColor(value) {
322
+ return isString(value) && value.trim().length > 0;
323
+ }
324
+
312
325
  // src/css-variables.ts
313
- var import_zod2 = require("zod");
314
326
  var themeVariableNames = {
315
327
  background: "--color-background",
316
328
  surface: "--color-card",
@@ -320,15 +332,14 @@ var themeVariableNames = {
320
332
  accent: "--color-primary",
321
333
  onAccent: "--color-primary-foreground"
322
334
  };
323
- var cssColor = import_zod2.z.string().trim().min(1);
324
335
  function toThemeVariables(colors) {
325
336
  const read = (key) => {
326
- const result = cssColor.safeParse(colors[key]);
327
- if (!result.success)
337
+ const color = colors[key];
338
+ if (!isCssColor(color))
328
339
  throw new Error(
329
340
  `CSS styling requires a string color for ${key}. Use native styles for platform color objects.`
330
341
  );
331
- return result.data;
342
+ return color.trim();
332
343
  };
333
344
  return {
334
345
  "--background": read("background"),
package/dist/index.js CHANGED
@@ -10,10 +10,20 @@ import {
10
10
  import { AccessibilityInfo, Appearance, AppState } from "react-native";
11
11
 
12
12
  // src/core/store.ts
13
- import { z } from "zod";
14
13
  function isTheme(value) {
15
14
  return value === "light" || value === "dark" || value === "system";
16
15
  }
16
+ function isStoredRecord(value) {
17
+ return value instanceof Object && !Array.isArray(value);
18
+ }
19
+ function parseStoredPreferences(record, colorThemes) {
20
+ if (record.version !== 1) return void 0;
21
+ return {
22
+ version: 1,
23
+ theme: isTheme(record.theme) ? record.theme : void 0,
24
+ colorTheme: colorThemes.find((name) => name === record.colorTheme)
25
+ };
26
+ }
17
27
  function createThemeStore(options) {
18
28
  const colorThemes = [...options.colorThemes];
19
29
  const defaultColorTheme = options.defaultColorTheme ?? colorThemes[0];
@@ -24,11 +34,6 @@ function createThemeStore(options) {
24
34
  throw new Error("Invalid default appearance mode.");
25
35
  }
26
36
  const storageKey = options.storageKey ?? "uitheme-rn:preferences";
27
- const storedPreferences = z.object({
28
- version: z.literal(1),
29
- theme: z.enum(["light", "dark", "system"]).optional().catch(void 0),
30
- colorTheme: z.string().refine((name) => colorThemes.includes(name)).optional().catch(void 0)
31
- });
32
37
  const listeners = /* @__PURE__ */ new Set();
33
38
  let state = Object.freeze({
34
39
  theme: options.defaultTheme ?? "system",
@@ -66,9 +71,9 @@ function createThemeStore(options) {
66
71
  try {
67
72
  const value = await options.storage?.getItem(storageKey);
68
73
  if (value) {
69
- const result = storedPreferences.safeParse(JSON.parse(value));
70
- if (!result.success) return;
71
- const saved = result.data;
74
+ const record = JSON.parse(value);
75
+ const saved = isStoredRecord(record) ? parseStoredPreferences(record, colorThemes) : void 0;
76
+ if (!saved) return;
72
77
  update({
73
78
  theme: !dirtyTheme && saved.theme !== void 0 ? saved.theme : state.theme,
74
79
  colorTheme: !dirtyColorTheme && saved.colorTheme !== void 0 ? saved.colorTheme : state.colorTheme
@@ -282,8 +287,15 @@ function useThemeColors() {
282
287
  return useUITheme().colors;
283
288
  }
284
289
 
290
+ // src/validators.ts
291
+ function isString(value) {
292
+ return typeof value === "string";
293
+ }
294
+ function isCssColor(value) {
295
+ return isString(value) && value.trim().length > 0;
296
+ }
297
+
285
298
  // src/css-variables.ts
286
- import { z as z2 } from "zod";
287
299
  var themeVariableNames = {
288
300
  background: "--color-background",
289
301
  surface: "--color-card",
@@ -293,15 +305,14 @@ var themeVariableNames = {
293
305
  accent: "--color-primary",
294
306
  onAccent: "--color-primary-foreground"
295
307
  };
296
- var cssColor = z2.string().trim().min(1);
297
308
  function toThemeVariables(colors) {
298
309
  const read = (key) => {
299
- const result = cssColor.safeParse(colors[key]);
300
- if (!result.success)
310
+ const color = colors[key];
311
+ if (!isCssColor(color))
301
312
  throw new Error(
302
313
  `CSS styling requires a string color for ${key}. Use native styles for platform color objects.`
303
314
  );
304
- return result.data;
315
+ return color.trim();
305
316
  };
306
317
  return {
307
318
  "--background": read("background"),
@@ -24,13 +24,23 @@ __export(nativewind_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(nativewind_exports);
26
26
  var import_react = require("react");
27
- var import_zod2 = require("zod");
28
27
  var import_react_native = require("react-native");
29
28
  var import_nativewind = require("nativewind");
30
29
  var import_uitheme_rn = require("uitheme-rn");
31
30
 
31
+ // src/validators.ts
32
+ function isString(value) {
33
+ return typeof value === "string";
34
+ }
35
+ function isCssColor(value) {
36
+ return isString(value) && value.trim().length > 0;
37
+ }
38
+ function assertDomElement(value) {
39
+ if (typeof Element === "undefined" || !(value instanceof Element))
40
+ throw new TypeError("Expected a DOM Element.");
41
+ }
42
+
32
43
  // src/css-variables.ts
33
- var import_zod = require("zod");
34
44
  var themeVariableNames = {
35
45
  background: "--color-background",
36
46
  surface: "--color-card",
@@ -40,15 +50,14 @@ var themeVariableNames = {
40
50
  accent: "--color-primary",
41
51
  onAccent: "--color-primary-foreground"
42
52
  };
43
- var cssColor = import_zod.z.string().trim().min(1);
44
53
  function colorsFromVariables(values) {
45
54
  const read = (index, key) => {
46
- const result = cssColor.safeParse(values[index]);
47
- if (!result.success)
55
+ const color = values[index];
56
+ if (!isCssColor(color))
48
57
  throw new Error(
49
58
  `Missing CSS color ${themeVariableNames[key]}. Define all seven semantic variables in the selected theme.`
50
59
  );
51
- return result.data;
60
+ return color.trim();
52
61
  };
53
62
  return {
54
63
  background: read(0, "background"),
@@ -98,7 +107,8 @@ function WebCSSColors({
98
107
  const ref = (0, import_react.useCallback)(
99
108
  (view) => {
100
109
  if (!scope || !view) return;
101
- const element = import_zod2.z.instanceof(Element).parse(view);
110
+ assertDomElement(view);
111
+ const element = view;
102
112
  const style = globalThis.getComputedStyle(element);
103
113
  setColors(
104
114
  colorsFromVariables(
@@ -3,7 +3,6 @@ import {
3
3
  useCallback,
4
4
  useState
5
5
  } from "react";
6
- import { z as z2 } from "zod";
7
6
  import { Platform, View } from "react-native";
8
7
  import {
9
8
  styled,
@@ -17,8 +16,19 @@ import {
17
16
  themeVariableNames as themeVariableNames2
18
17
  } from "uitheme-rn";
19
18
 
19
+ // src/validators.ts
20
+ function isString(value) {
21
+ return typeof value === "string";
22
+ }
23
+ function isCssColor(value) {
24
+ return isString(value) && value.trim().length > 0;
25
+ }
26
+ function assertDomElement(value) {
27
+ if (typeof Element === "undefined" || !(value instanceof Element))
28
+ throw new TypeError("Expected a DOM Element.");
29
+ }
30
+
20
31
  // src/css-variables.ts
21
- import { z } from "zod";
22
32
  var themeVariableNames = {
23
33
  background: "--color-background",
24
34
  surface: "--color-card",
@@ -28,15 +38,14 @@ var themeVariableNames = {
28
38
  accent: "--color-primary",
29
39
  onAccent: "--color-primary-foreground"
30
40
  };
31
- var cssColor = z.string().trim().min(1);
32
41
  function colorsFromVariables(values) {
33
42
  const read = (index, key) => {
34
- const result = cssColor.safeParse(values[index]);
35
- if (!result.success)
43
+ const color = values[index];
44
+ if (!isCssColor(color))
36
45
  throw new Error(
37
46
  `Missing CSS color ${themeVariableNames[key]}. Define all seven semantic variables in the selected theme.`
38
47
  );
39
- return result.data;
48
+ return color.trim();
40
49
  };
41
50
  return {
42
51
  background: read(0, "background"),
@@ -86,7 +95,8 @@ function WebCSSColors({
86
95
  const ref = useCallback(
87
96
  (view) => {
88
97
  if (!scope || !view) return;
89
- const element = z2.instanceof(Element).parse(view);
98
+ assertDomElement(view);
99
+ const element = view;
90
100
  const style = globalThis.getComputedStyle(element);
91
101
  setColors(
92
102
  colorsFromVariables(
package/dist/uniwind.cjs CHANGED
@@ -27,8 +27,15 @@ var import_react_native = require("react-native");
27
27
  var import_uniwind = require("uniwind");
28
28
  var import_uitheme_rn = require("uitheme-rn");
29
29
 
30
+ // src/validators.ts
31
+ function isString(value) {
32
+ return typeof value === "string";
33
+ }
34
+ function isCssColor(value) {
35
+ return isString(value) && value.trim().length > 0;
36
+ }
37
+
30
38
  // src/css-variables.ts
31
- var import_zod = require("zod");
32
39
  var themeVariableNames = {
33
40
  background: "--color-background",
34
41
  surface: "--color-card",
@@ -38,15 +45,14 @@ var themeVariableNames = {
38
45
  accent: "--color-primary",
39
46
  onAccent: "--color-primary-foreground"
40
47
  };
41
- var cssColor = import_zod.z.string().trim().min(1);
42
48
  function colorsFromVariables(values) {
43
49
  const read = (index, key) => {
44
- const result = cssColor.safeParse(values[index]);
45
- if (!result.success)
50
+ const color = values[index];
51
+ if (!isCssColor(color))
46
52
  throw new Error(
47
53
  `Missing CSS color ${themeVariableNames[key]}. Define all seven semantic variables in the selected theme.`
48
54
  );
49
- return result.data;
55
+ return color.trim();
50
56
  };
51
57
  return {
52
58
  background: read(0, "background"),
package/dist/uniwind.js CHANGED
@@ -8,8 +8,15 @@ import {
8
8
  themeVariableNames as themeVariableNames2
9
9
  } from "uitheme-rn";
10
10
 
11
+ // src/validators.ts
12
+ function isString(value) {
13
+ return typeof value === "string";
14
+ }
15
+ function isCssColor(value) {
16
+ return isString(value) && value.trim().length > 0;
17
+ }
18
+
11
19
  // src/css-variables.ts
12
- import { z } from "zod";
13
20
  var themeVariableNames = {
14
21
  background: "--color-background",
15
22
  surface: "--color-card",
@@ -19,15 +26,14 @@ var themeVariableNames = {
19
26
  accent: "--color-primary",
20
27
  onAccent: "--color-primary-foreground"
21
28
  };
22
- var cssColor = z.string().trim().min(1);
23
29
  function colorsFromVariables(values) {
24
30
  const read = (index, key) => {
25
- const result = cssColor.safeParse(values[index]);
26
- if (!result.success)
31
+ const color = values[index];
32
+ if (!isCssColor(color))
27
33
  throw new Error(
28
34
  `Missing CSS color ${themeVariableNames[key]}. Define all seven semantic variables in the selected theme.`
29
35
  );
30
- return result.data;
36
+ return color.trim();
31
37
  };
32
38
  return {
33
39
  background: read(0, "background"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uitheme-rn",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Native appearance and color palettes for React Native and Expo",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -105,7 +105,7 @@
105
105
  "react-native": ">=0.83.0 <0.89",
106
106
  "react-native-reanimated": ">=4.5.1 <4.8",
107
107
  "react-native-worklets": ">=0.10.1 <0.14",
108
- "nativewind": "5.0.0-rc.0",
108
+ "nativewind": ">=5.0.0-rc.0 <6",
109
109
  "uniwind": ">=1.12.2 <2"
110
110
  },
111
111
  "peerDependenciesMeta": {
@@ -145,9 +145,6 @@
145
145
  "tailwindcss": "4.3.3",
146
146
  "lightningcss": "1.30.1"
147
147
  },
148
- "dependencies": {
149
- "zod": "^4.6.7"
150
- },
151
148
  "scripts": {
152
149
  "build": "tsup",
153
150
  "dev": "tsup --watch",