@cssxio/react-native 0.3.4 → 0.5.1

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/index.cjs CHANGED
@@ -25,7 +25,115 @@ __export(index_exports, {
25
25
  sx: () => sx
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/create.ts
30
+ var import_compiler2 = require("@cssxio/compiler");
31
+
32
+ // src/compile-candidates.ts
28
33
  var import_compiler = require("@cssxio/compiler");
34
+
35
+ // src/oklch-to-srgb-hex.ts
36
+ function oklchToSrgbHex(value) {
37
+ const match = /^oklch\(([\d.]+)%(?:\s|_)+([\d.]+)(?:\s|_)+([\d.]+)\)$/.exec(value);
38
+ if (!match) {
39
+ return null;
40
+ }
41
+ const lightness = Number(match[1]) / 100;
42
+ const chroma = Number(match[2]);
43
+ const hue = Number(match[3]) * Math.PI / 180;
44
+ const a = chroma * Math.cos(hue);
45
+ const b = chroma * Math.sin(hue);
46
+ const l = (lightness + 0.3963377774 * a + 0.2158037574 * b) ** 3;
47
+ const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
48
+ const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
49
+ const channels = [
50
+ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
51
+ -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
52
+ -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
53
+ ];
54
+ return `#${channels.map((channel) => {
55
+ const bounded = Math.max(0, Math.min(1, channel));
56
+ const srgb = bounded <= 31308e-7 ? 12.92 * bounded : 1.055 * bounded ** (1 / 2.4) - 0.055;
57
+ return Math.round(srgb * 255).toString(16).padStart(2, "0");
58
+ }).join("")}`;
59
+ }
60
+
61
+ // src/native-values.ts
62
+ function nativeValue(value, candidate) {
63
+ const important = value.endsWith(" !important") ? value.slice(0, -11) : value;
64
+ const calculation = /^calc\((-?[\d.]+)rem \* (-?[\d.]+)\)$/.exec(important);
65
+ if (calculation) {
66
+ return Number(calculation[1]) * 16 * Number(calculation[2]);
67
+ }
68
+ const rem = /^(-?[\d.]+)rem$/.exec(important);
69
+ if (rem) {
70
+ return Number(rem[1]) * 16;
71
+ }
72
+ const pixels = /^(-?[\d.]+)px$/.exec(important);
73
+ if (pixels) {
74
+ return Number(pixels[1]);
75
+ }
76
+ if (/^-?[\d.]+$/.test(important)) {
77
+ return Number(important);
78
+ }
79
+ if (/^(?:#|rgb|rgba|hsl|hsla|hwb|transparent|black|white)/.test(important) || important.endsWith("%")) {
80
+ return important;
81
+ }
82
+ const oklch = oklchToSrgbHex(important);
83
+ if (oklch) {
84
+ return oklch;
85
+ }
86
+ if (important.startsWith("var(") || important.startsWith("color-mix(") || important.startsWith("oklch(")) {
87
+ throw new Error(`CSSX React Native requires "${candidate}" to resolve to a native color or value at build time.`);
88
+ }
89
+ return important;
90
+ }
91
+
92
+ // src/append-custom-transform.ts
93
+ function appendCustomTransform(style, property, value, candidate) {
94
+ const transformProperty = {
95
+ "--cssx-rotate": "rotate",
96
+ "--cssx-scale-x": "scaleX",
97
+ "--cssx-scale-y": "scaleY",
98
+ "--cssx-translate-x": "translateX",
99
+ "--cssx-translate-y": "translateY"
100
+ };
101
+ const nativeProperty = transformProperty[property];
102
+ if (!nativeProperty) {
103
+ return false;
104
+ }
105
+ style.transform = [
106
+ ...style.transform ?? [],
107
+ { [nativeProperty]: nativeValue(value, candidate) }
108
+ ];
109
+ return true;
110
+ }
111
+
112
+ // src/append-transform.ts
113
+ function appendTransform(style, property, value) {
114
+ if ((property === "translate" || property === "rotate" || property === "scale") && value.includes("var(")) {
115
+ return true;
116
+ }
117
+ let transforms;
118
+ if (property === "translate") {
119
+ const x = value.split(" ", 1).join("");
120
+ const [y = "0"] = value.split(" ").slice(1);
121
+ transforms = [{ translateX: nativeValue(x, "translate") }, { translateY: nativeValue(y, "translate") }];
122
+ } else if (property === "rotate") {
123
+ transforms = [{ rotate: value }];
124
+ } else if (property === "scale") {
125
+ const x = value.split(" ", 1).join("");
126
+ const [y = x] = value.split(" ").slice(1);
127
+ transforms = [{ scaleX: Number(x) }, { scaleY: Number(y) }];
128
+ }
129
+ if (!transforms) {
130
+ return false;
131
+ }
132
+ style.transform = [...style.transform ?? [], ...transforms];
133
+ return true;
134
+ }
135
+
136
+ // src/native-properties.ts
29
137
  var propertyNames = {
30
138
  "align-content": "alignContent",
31
139
  "align-items": "alignItems",
@@ -98,89 +206,8 @@ var logicalProperties = {
98
206
  "padding-block": ["paddingTop", "paddingBottom"],
99
207
  "padding-inline": ["paddingLeft", "paddingRight"]
100
208
  };
101
- function create(styles, options = {}) {
102
- const records = (0, import_compiler.compileStyleRecords)(styles, { theme: options.theme });
103
- const theme = (0, import_compiler.parseTheme)(options.theme);
104
- return Object.fromEntries(
105
- Object.entries(records.candidates).map(([name, candidates]) => [
106
- name,
107
- { $$cssx: 3, style: compileCandidates(candidates, theme, options.platform) }
108
- ])
109
- );
110
- }
111
- function props(...inputs) {
112
- const styles = [];
113
- visitStyles(inputs, styles);
114
- return { style: mergeStyles(styles) };
115
- }
116
- function sx(...inputs) {
117
- const styles = [];
118
- for (const input of inputs) {
119
- if (typeof input === "string") {
120
- styles.push(create({ value: input }).value.style);
121
- } else {
122
- visitStyles([input], styles);
123
- }
124
- }
125
- return mergeStyles(styles);
126
- }
127
- function visitStyles(inputs, output) {
128
- for (const input of inputs) {
129
- if (!input) {
130
- continue;
131
- }
132
- if (isNativeStyleArray(input)) {
133
- visitStyles(input, output);
134
- continue;
135
- }
136
- if (typeof input !== "object" || input.$$cssx !== 3) {
137
- throw new Error("cssx.props() received an object that was not compiled by CSSX for React Native.");
138
- }
139
- output.push(input.style);
140
- }
141
- }
142
- function isNativeStyleArray(input) {
143
- return Array.isArray(input);
144
- }
145
- function mergeStyles(styles) {
146
- const output = {};
147
- for (const style of styles) {
148
- for (const [property, value] of Object.entries(style)) {
149
- if (property === "transform" && Array.isArray(output.transform) && Array.isArray(value)) {
150
- output.transform = [...output.transform, ...value];
151
- } else {
152
- output[property] = value;
153
- }
154
- }
155
- }
156
- return output;
157
- }
158
- function compileCandidates(candidates, theme, platform) {
159
- const style = {};
160
- for (const source of candidates) {
161
- const candidate = platformCandidate(source, platform);
162
- if (candidate === null) {
163
- continue;
164
- }
165
- const recipe = (0, import_compiler.describeUtilityRecipe)(candidate, theme);
166
- for (const atom of recipe.atoms) {
167
- for (const declaration of atom) {
168
- appendDeclaration(style, candidate, declaration);
169
- }
170
- }
171
- }
172
- return style;
173
- }
174
- function platformCandidate(source, platform) {
175
- const match = /^(ios|android):(.*)$/.exec(source);
176
- if (match) {
177
- return match[1] === platform ? match[2] : null;
178
- }
179
- if (!source.startsWith("[") && source.includes(":")) {
180
- throw new Error(`CSSX React Native cannot represent the variant in "${source}".`);
181
- }
182
- return source;
183
- }
209
+
210
+ // src/append-declaration.ts
184
211
  function appendDeclaration(style, candidate, declaration) {
185
212
  if (declaration.selectorSuffix || declaration.atRule) {
186
213
  throw new Error(`CSSX React Native cannot represent browser-only utility "${candidate}".`);
@@ -212,104 +239,105 @@ function appendDeclaration(style, candidate, declaration) {
212
239
  if (property === "overflow" && value !== "visible" && value !== "hidden") {
213
240
  throw new Error(`CSSX React Native cannot represent overflow value "${String(value)}" from "${candidate}".`);
214
241
  }
215
- if (property === "flex" && typeof value === "string") {
216
- style[property] = Number.parseFloat(value);
217
- return;
218
- }
219
- style[property] = value;
242
+ style[property] = property === "flex" && typeof value === "string" ? Number.parseFloat(value) : value;
220
243
  }
221
- function appendTransform(style, property, value) {
222
- if ((property === "translate" || property === "rotate" || property === "scale") && value.includes("var(")) {
223
- return true;
224
- }
225
- let transforms;
226
- if (property === "translate") {
227
- const [x = "0", y = "0"] = value.split(" ");
228
- transforms = [{ translateX: nativeValue(x, "translate") }, { translateY: nativeValue(y, "translate") }];
229
- } else if (property === "rotate") {
230
- transforms = [{ rotate: value }];
231
- } else if (property === "scale") {
232
- const [x = "1", y = x] = value.split(" ");
233
- transforms = [{ scaleX: Number(x) }, { scaleY: Number(y) }];
244
+
245
+ // src/platform-candidate.ts
246
+ function platformCandidate(source, platform) {
247
+ const match = /^(ios|android):(.*)$/.exec(source);
248
+ if (match) {
249
+ return match[1] === platform ? match[2] : null;
234
250
  }
235
- if (!transforms) {
236
- return false;
251
+ if (!source.startsWith("[") && source.includes(":")) {
252
+ throw new Error(`CSSX React Native cannot represent the variant in "${source}".`);
237
253
  }
238
- style.transform = [...style.transform ?? [], ...transforms];
239
- return true;
254
+ return source;
240
255
  }
241
- function appendCustomTransform(style, property, value, candidate) {
242
- const transformProperty = {
243
- "--cssx-rotate": "rotate",
244
- "--cssx-scale-x": "scaleX",
245
- "--cssx-scale-y": "scaleY",
246
- "--cssx-translate-x": "translateX",
247
- "--cssx-translate-y": "translateY"
248
- };
249
- const nativeProperty = transformProperty[property];
250
- if (!nativeProperty) {
251
- return false;
256
+
257
+ // src/compile-candidates.ts
258
+ function compileCandidates(candidates, theme, platform) {
259
+ const style = {};
260
+ for (const source of candidates) {
261
+ const candidate = platformCandidate(source, platform);
262
+ if (candidate === null) {
263
+ continue;
264
+ }
265
+ for (const atom of (0, import_compiler.describeUtilityRecipe)(candidate, theme).atoms) {
266
+ for (const declaration of atom) {
267
+ appendDeclaration(style, candidate, declaration);
268
+ }
269
+ }
252
270
  }
253
- const native = nativeValue(value, candidate);
254
- style.transform = [
255
- ...style.transform ?? [],
256
- { [nativeProperty]: native }
257
- ];
258
- return true;
271
+ return style;
259
272
  }
260
- function nativeValue(value, candidate) {
261
- const important = value.endsWith(" !important") ? value.slice(0, -11) : value;
262
- const calculation = /^calc\((-?[\d.]+)rem \* (-?[\d.]+)\)$/.exec(important);
263
- if (calculation) {
264
- return Number(calculation[1]) * 16 * Number(calculation[2]);
265
- }
266
- const rem = /^(-?[\d.]+)rem$/.exec(important);
267
- if (rem) {
268
- return Number(rem[1]) * 16;
269
- }
270
- const pixels = /^(-?[\d.]+)px$/.exec(important);
271
- if (pixels) {
272
- return Number(pixels[1]);
273
- }
274
- if (/^-?[\d.]+$/.test(important)) {
275
- return Number(important);
276
- }
277
- if (/^(?:#|rgb|rgba|hsl|hsla|hwb|transparent|black|white)/.test(important) || important.endsWith("%")) {
278
- return important;
279
- }
280
- const oklch = oklchToSrgbHex(important);
281
- if (oklch) {
282
- return oklch;
273
+
274
+ // src/create.ts
275
+ function create(styles, options = {}) {
276
+ const records = (0, import_compiler2.compileStyleRecords)(styles, { theme: options.theme });
277
+ const theme = (0, import_compiler2.parseTheme)(options.theme);
278
+ return Object.fromEntries(
279
+ Object.entries(records.candidates).map(([name, candidates]) => [
280
+ name,
281
+ { $$cssx: 3, style: compileCandidates(candidates, theme, options.platform) }
282
+ ])
283
+ );
284
+ }
285
+
286
+ // src/merge-styles.ts
287
+ function mergeStyles(styles) {
288
+ const output = {};
289
+ for (const style of styles) {
290
+ for (const [property, value] of Object.entries(style)) {
291
+ if (property === "transform" && Array.isArray(output.transform) && Array.isArray(value)) {
292
+ output.transform = [...output.transform, ...value];
293
+ } else {
294
+ output[property] = value;
295
+ }
296
+ }
283
297
  }
284
- if (important.startsWith("var(") || important.startsWith("color-mix(") || important.startsWith("oklch(")) {
285
- throw new Error(`CSSX React Native requires "${candidate}" to resolve to a native color or value at build time.`);
298
+ return output;
299
+ }
300
+
301
+ // src/is-native-style-array.ts
302
+ function isNativeStyleArray(input) {
303
+ return Array.isArray(input);
304
+ }
305
+
306
+ // src/visit-styles.ts
307
+ function visitStyles(inputs, output) {
308
+ for (const input of inputs) {
309
+ if (!input) {
310
+ continue;
311
+ }
312
+ if (isNativeStyleArray(input)) {
313
+ visitStyles(input, output);
314
+ continue;
315
+ }
316
+ if (typeof input !== "object" || input.$$cssx !== 3) {
317
+ throw new Error("cssx.props() received an object that was not compiled by CSSX for React Native.");
318
+ }
319
+ output.push(input.style);
286
320
  }
287
- return important;
288
321
  }
289
- function oklchToSrgbHex(value) {
290
- const match = /^oklch\(([\d.]+)%(?:\s|_)+([\d.]+)(?:\s|_)+([\d.]+)\)$/.exec(value);
291
- if (!match) {
292
- return null;
322
+
323
+ // src/props.ts
324
+ function props(...inputs) {
325
+ const styles = [];
326
+ visitStyles(inputs, styles);
327
+ return { style: mergeStyles(styles) };
328
+ }
329
+
330
+ // src/sx.ts
331
+ function sx(...inputs) {
332
+ const styles = [];
333
+ for (const input of inputs) {
334
+ if (typeof input === "string") {
335
+ styles.push(create({ value: input }).value.style);
336
+ } else {
337
+ visitStyles([input], styles);
338
+ }
293
339
  }
294
- const lightness = Number(match[1]) / 100;
295
- const chroma = Number(match[2]);
296
- const hue = Number(match[3]) * Math.PI / 180;
297
- const a = chroma * Math.cos(hue);
298
- const b = chroma * Math.sin(hue);
299
- const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
300
- const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
301
- const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
302
- const channels = [
303
- 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
304
- -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
305
- -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
306
- ];
307
- const hex = channels.map((channel) => {
308
- const bounded = Math.max(0, Math.min(1, channel));
309
- const srgb = bounded <= 31308e-7 ? 12.92 * bounded : 1.055 * bounded ** (1 / 2.4) - 0.055;
310
- return Math.round(srgb * 255).toString(16).padStart(2, "0");
311
- }).join("");
312
- return `#${hex}`;
340
+ return mergeStyles(styles);
313
341
  }
314
342
  // Annotate the CommonJS export names for ESM import in node:
315
343
  0 && (module.exports = {
package/dist/index.d.cts CHANGED
@@ -1,27 +1,31 @@
1
- type NativePlatform = 'android' | 'ios';
2
- type NativeTransform = Readonly<Record<string, number | string>>;
3
- type NativeStyleValue = number | string | readonly NativeTransform[];
4
- type NativeStyle = Readonly<Record<string, NativeStyleValue>>;
5
- interface NativeCompilerOptions {
6
- readonly platform?: NativePlatform;
7
- readonly theme?: string;
8
- }
9
- interface CompiledNativeStyle {
10
- readonly $$cssx: 3;
11
- readonly style: NativeStyle;
12
- }
13
- type NativeStyleInput = CompiledNativeStyle | false | null | undefined | readonly NativeStyleInput[];
14
- type NativeSxInput = string | NativeStyleInput;
15
- type NativeStyleMap<T extends Readonly<Record<string, string>>> = {
16
- readonly [Key in keyof T]: CompiledNativeStyle;
17
- };
18
- /** Compiles static utility maps to React Native-compatible style records. */
1
+ import { N as NativeCompilerOptions, a as NativeStyleMap, b as NativeStyleInput, c as NativeStyle, d as NativeSxInput } from './native-types-Cv9_KYf7.cjs';
2
+ export { C as CompiledNativeStyle, e as NativePlatform, f as NativeStyleValue, g as NativeTransform } from './native-types-Cv9_KYf7.cjs';
3
+
4
+ /**
5
+ * Compiles static utility maps to React Native-compatible style records.
6
+ *
7
+ * @param styles Named static utility strings.
8
+ * @param options Target platform and optional theme.
9
+ * @returns Compiled native style records.
10
+ */
19
11
  declare function create<T extends Readonly<Record<string, string>>>(styles: T, options?: NativeCompilerOptions): NativeStyleMap<T>;
20
- /** Merges compiled native styles from left to right. */
12
+
13
+ /**
14
+ * Merges compiled React Native styles from left to right.
15
+ *
16
+ * @param inputs Compiled styles or nested conditional style lists.
17
+ * @returns The merged React Native style prop.
18
+ */
21
19
  declare function props(...inputs: readonly NativeStyleInput[]): {
22
20
  readonly style: NativeStyle;
23
21
  };
24
- /** Compiles inline utility strings and merges compiled native styles. */
22
+
23
+ /**
24
+ * Compiles inline utility strings and merges compiled React Native styles.
25
+ *
26
+ * @param inputs Utility strings or compiled conditional styles.
27
+ * @returns A merged native style object.
28
+ */
25
29
  declare function sx(...inputs: readonly NativeSxInput[]): NativeStyle;
26
30
 
27
- export { type CompiledNativeStyle, type NativeCompilerOptions, type NativePlatform, type NativeStyle, type NativeStyleInput, type NativeStyleMap, type NativeStyleValue, type NativeSxInput, type NativeTransform, create, props, sx };
31
+ export { NativeCompilerOptions, NativeStyle, NativeStyleInput, NativeStyleMap, NativeSxInput, create, props, sx };
package/dist/index.d.ts CHANGED
@@ -1,27 +1,31 @@
1
- type NativePlatform = 'android' | 'ios';
2
- type NativeTransform = Readonly<Record<string, number | string>>;
3
- type NativeStyleValue = number | string | readonly NativeTransform[];
4
- type NativeStyle = Readonly<Record<string, NativeStyleValue>>;
5
- interface NativeCompilerOptions {
6
- readonly platform?: NativePlatform;
7
- readonly theme?: string;
8
- }
9
- interface CompiledNativeStyle {
10
- readonly $$cssx: 3;
11
- readonly style: NativeStyle;
12
- }
13
- type NativeStyleInput = CompiledNativeStyle | false | null | undefined | readonly NativeStyleInput[];
14
- type NativeSxInput = string | NativeStyleInput;
15
- type NativeStyleMap<T extends Readonly<Record<string, string>>> = {
16
- readonly [Key in keyof T]: CompiledNativeStyle;
17
- };
18
- /** Compiles static utility maps to React Native-compatible style records. */
1
+ import { N as NativeCompilerOptions, a as NativeStyleMap, b as NativeStyleInput, c as NativeStyle, d as NativeSxInput } from './native-types-Cv9_KYf7.js';
2
+ export { C as CompiledNativeStyle, e as NativePlatform, f as NativeStyleValue, g as NativeTransform } from './native-types-Cv9_KYf7.js';
3
+
4
+ /**
5
+ * Compiles static utility maps to React Native-compatible style records.
6
+ *
7
+ * @param styles Named static utility strings.
8
+ * @param options Target platform and optional theme.
9
+ * @returns Compiled native style records.
10
+ */
19
11
  declare function create<T extends Readonly<Record<string, string>>>(styles: T, options?: NativeCompilerOptions): NativeStyleMap<T>;
20
- /** Merges compiled native styles from left to right. */
12
+
13
+ /**
14
+ * Merges compiled React Native styles from left to right.
15
+ *
16
+ * @param inputs Compiled styles or nested conditional style lists.
17
+ * @returns The merged React Native style prop.
18
+ */
21
19
  declare function props(...inputs: readonly NativeStyleInput[]): {
22
20
  readonly style: NativeStyle;
23
21
  };
24
- /** Compiles inline utility strings and merges compiled native styles. */
22
+
23
+ /**
24
+ * Compiles inline utility strings and merges compiled React Native styles.
25
+ *
26
+ * @param inputs Utility strings or compiled conditional styles.
27
+ * @returns A merged native style object.
28
+ */
25
29
  declare function sx(...inputs: readonly NativeSxInput[]): NativeStyle;
26
30
 
27
- export { type CompiledNativeStyle, type NativeCompilerOptions, type NativePlatform, type NativeStyle, type NativeStyleInput, type NativeStyleMap, type NativeStyleValue, type NativeSxInput, type NativeTransform, create, props, sx };
31
+ export { NativeCompilerOptions, NativeStyle, NativeStyleInput, NativeStyleMap, NativeSxInput, create, props, sx };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  create,
3
3
  props,
4
4
  sx
5
- } from "./chunk-7REDTOKV.js";
5
+ } from "./chunk-5ETB3X4A.js";
6
6
  export {
7
7
  create,
8
8
  props,
@@ -0,0 +1,28 @@
1
+ /** Platforms represented by React Native-specific utility variants. */
2
+ type NativePlatform = 'android' | 'ios';
3
+ /** One React Native transform record. */
4
+ type NativeTransform = Readonly<Record<string, number | string>>;
5
+ /** A value accepted by React Native's style object. */
6
+ type NativeStyleValue = number | string | readonly NativeTransform[];
7
+ /** A React Native style object emitted by CSSX. */
8
+ type NativeStyle = Readonly<Record<string, NativeStyleValue>>;
9
+ /** Options used when CSSX compiles utilities for React Native. */
10
+ interface NativeCompilerOptions {
11
+ readonly platform?: NativePlatform;
12
+ readonly theme?: string;
13
+ }
14
+ /** A compiled React Native style value. */
15
+ interface CompiledNativeStyle {
16
+ readonly $$cssx: 3;
17
+ readonly style: NativeStyle;
18
+ }
19
+ /** A value accepted by the React Native `props` helper. */
20
+ type NativeStyleInput = CompiledNativeStyle | false | null | undefined | readonly NativeStyleInput[];
21
+ /** A value accepted by the React Native `sx` helper. */
22
+ type NativeSxInput = string | NativeStyleInput;
23
+ /** A map of CSSX names to compiled React Native styles. */
24
+ type NativeStyleMap<T extends Readonly<Record<string, string>>> = {
25
+ readonly [Key in keyof T]: CompiledNativeStyle;
26
+ };
27
+
28
+ export type { CompiledNativeStyle as C, NativeCompilerOptions as N, NativeStyleMap as a, NativeStyleInput as b, NativeStyle as c, NativeSxInput as d, NativePlatform as e, NativeStyleValue as f, NativeTransform as g };
@@ -0,0 +1,28 @@
1
+ /** Platforms represented by React Native-specific utility variants. */
2
+ type NativePlatform = 'android' | 'ios';
3
+ /** One React Native transform record. */
4
+ type NativeTransform = Readonly<Record<string, number | string>>;
5
+ /** A value accepted by React Native's style object. */
6
+ type NativeStyleValue = number | string | readonly NativeTransform[];
7
+ /** A React Native style object emitted by CSSX. */
8
+ type NativeStyle = Readonly<Record<string, NativeStyleValue>>;
9
+ /** Options used when CSSX compiles utilities for React Native. */
10
+ interface NativeCompilerOptions {
11
+ readonly platform?: NativePlatform;
12
+ readonly theme?: string;
13
+ }
14
+ /** A compiled React Native style value. */
15
+ interface CompiledNativeStyle {
16
+ readonly $$cssx: 3;
17
+ readonly style: NativeStyle;
18
+ }
19
+ /** A value accepted by the React Native `props` helper. */
20
+ type NativeStyleInput = CompiledNativeStyle | false | null | undefined | readonly NativeStyleInput[];
21
+ /** A value accepted by the React Native `sx` helper. */
22
+ type NativeSxInput = string | NativeStyleInput;
23
+ /** A map of CSSX names to compiled React Native styles. */
24
+ type NativeStyleMap<T extends Readonly<Record<string, string>>> = {
25
+ readonly [Key in keyof T]: CompiledNativeStyle;
26
+ };
27
+
28
+ export type { CompiledNativeStyle as C, NativeCompilerOptions as N, NativeStyleMap as a, NativeStyleInput as b, NativeStyle as c, NativeSxInput as d, NativePlatform as e, NativeStyleValue as f, NativeTransform as g };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cssxio/react-native",
3
- "version": "0.3.4",
3
+ "version": "0.5.1",
4
4
  "description": "CSSX utility styling runtime and compiler transform for React Native and Expo.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "sideEffects": false,
31
31
  "dependencies": {
32
- "@cssxio/compiler": "^0.6.0"
32
+ "@cssxio/compiler": "^0.9.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@babel/core": "^7.28.0"