@niibase/uniwind 1.0.0 → 1.0.11

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.
Files changed (107) hide show
  1. package/dist/common/components/react-native-gesture-handler/index.js +122 -0
  2. package/dist/common/components/react-native-gesture-handler/native/BaseButton.js +18 -0
  3. package/dist/common/components/react-native-gesture-handler/native/BorderlessButton.js +18 -0
  4. package/dist/common/components/react-native-gesture-handler/native/DrawerLayoutAndroid.js +18 -0
  5. package/dist/common/components/react-native-gesture-handler/native/FlatList.js +30 -0
  6. package/dist/common/components/react-native-gesture-handler/native/GestureHandlerRootView.js +18 -0
  7. package/dist/common/components/react-native-gesture-handler/native/Pressable.js +29 -0
  8. package/dist/common/components/react-native-gesture-handler/native/PureNativeButton.js +18 -0
  9. package/dist/common/components/react-native-gesture-handler/native/RawButton.js +18 -0
  10. package/dist/common/components/react-native-gesture-handler/native/RectButton.js +18 -0
  11. package/dist/common/components/react-native-gesture-handler/native/RefreshControl.js +27 -0
  12. package/dist/common/components/react-native-gesture-handler/native/ScrollView.js +23 -0
  13. package/dist/common/components/react-native-gesture-handler/native/Switch.js +32 -0
  14. package/dist/common/components/react-native-gesture-handler/native/Text.js +36 -0
  15. package/dist/common/components/react-native-gesture-handler/native/TextInput.js +53 -0
  16. package/dist/common/components/react-native-gesture-handler/native/TouchableNativeFeedback.js +32 -0
  17. package/dist/common/components/react-native-gesture-handler/native/TouchableOpacity.js +32 -0
  18. package/dist/common/components/react-native-gesture-handler/native/TouchableWithoutFeedback.js +32 -0
  19. package/dist/common/components/react-native-svg/index.js +14 -0
  20. package/dist/common/components/react-native-svg/native/Svg.js +18 -0
  21. package/dist/common/components/react-native-svg/web/Svg.js +17 -0
  22. package/dist/common/core/native/runtime.js +2 -1
  23. package/dist/common/core/native/store.js +33 -3
  24. package/dist/metro/index.cjs +22 -6
  25. package/dist/metro/index.mjs +20 -4
  26. package/dist/metro/metro-transformer.cjs +56 -19
  27. package/dist/metro/metro-transformer.mjs +56 -19
  28. package/dist/module/components/react-native-gesture-handler/index.d.ts +0 -0
  29. package/dist/module/components/react-native-gesture-handler/index.js +120 -0
  30. package/dist/module/components/react-native-gesture-handler/native/BaseButton.d.ts +3 -0
  31. package/dist/module/components/react-native-gesture-handler/native/BaseButton.js +15 -0
  32. package/dist/module/components/react-native-gesture-handler/native/BorderlessButton.d.ts +3 -0
  33. package/dist/module/components/react-native-gesture-handler/native/BorderlessButton.js +18 -0
  34. package/dist/module/components/react-native-gesture-handler/native/DrawerLayoutAndroid.d.ts +5 -0
  35. package/dist/module/components/react-native-gesture-handler/native/DrawerLayoutAndroid.js +18 -0
  36. package/dist/module/components/react-native-gesture-handler/native/FlatList.d.ts +4 -0
  37. package/dist/module/components/react-native-gesture-handler/native/FlatList.js +27 -0
  38. package/dist/module/components/react-native-gesture-handler/native/GestureHandlerRootView.d.ts +3 -0
  39. package/dist/module/components/react-native-gesture-handler/native/GestureHandlerRootView.js +18 -0
  40. package/dist/module/components/react-native-gesture-handler/native/Pressable.d.ts +3 -0
  41. package/dist/module/components/react-native-gesture-handler/native/Pressable.js +29 -0
  42. package/dist/module/components/react-native-gesture-handler/native/PureNativeButton.d.ts +3 -0
  43. package/dist/module/components/react-native-gesture-handler/native/PureNativeButton.js +15 -0
  44. package/dist/module/components/react-native-gesture-handler/native/RawButton.d.ts +3 -0
  45. package/dist/module/components/react-native-gesture-handler/native/RawButton.js +15 -0
  46. package/dist/module/components/react-native-gesture-handler/native/RectButton.d.ts +3 -0
  47. package/dist/module/components/react-native-gesture-handler/native/RectButton.js +15 -0
  48. package/dist/module/components/react-native-gesture-handler/native/RefreshControl.d.ts +3 -0
  49. package/dist/module/components/react-native-gesture-handler/native/RefreshControl.js +24 -0
  50. package/dist/module/components/react-native-gesture-handler/native/ScrollView.d.ts +3 -0
  51. package/dist/module/components/react-native-gesture-handler/native/ScrollView.js +20 -0
  52. package/dist/module/components/react-native-gesture-handler/native/Switch.d.ts +3 -0
  53. package/dist/module/components/react-native-gesture-handler/native/Switch.js +26 -0
  54. package/dist/module/components/react-native-gesture-handler/native/Text.d.ts +2 -0
  55. package/dist/module/components/react-native-gesture-handler/native/Text.js +33 -0
  56. package/dist/module/components/react-native-gesture-handler/native/TextInput.d.ts +3 -0
  57. package/dist/module/components/react-native-gesture-handler/native/TextInput.js +50 -0
  58. package/dist/module/components/react-native-gesture-handler/native/TouchableNativeFeedback.d.ts +2 -0
  59. package/dist/module/components/react-native-gesture-handler/native/TouchableNativeFeedback.js +32 -0
  60. package/dist/module/components/react-native-gesture-handler/native/TouchableOpacity.d.ts +3 -0
  61. package/dist/module/components/react-native-gesture-handler/native/TouchableOpacity.js +32 -0
  62. package/dist/module/components/react-native-gesture-handler/native/TouchableWithoutFeedback.d.ts +4 -0
  63. package/dist/module/components/react-native-gesture-handler/native/TouchableWithoutFeedback.js +34 -0
  64. package/dist/module/components/react-native-svg/index.d.ts +1 -0
  65. package/dist/module/components/react-native-svg/index.js +10 -0
  66. package/dist/module/components/react-native-svg/native/Svg.d.ts +3 -0
  67. package/dist/module/components/react-native-svg/native/Svg.js +15 -0
  68. package/dist/module/components/react-native-svg/web/Svg.d.ts +3 -0
  69. package/dist/module/components/react-native-svg/web/Svg.js +14 -0
  70. package/dist/module/core/native/runtime.js +2 -6
  71. package/dist/module/core/native/store.d.ts +2 -0
  72. package/dist/module/core/native/store.js +30 -3
  73. package/dist/module/core/types.d.ts +10 -0
  74. package/package.json +6 -1
  75. package/readme.md +3 -0
  76. package/src/components/react-native-gesture-handler/index.ts +121 -0
  77. package/src/components/react-native-gesture-handler/native/BaseButton.tsx +18 -0
  78. package/src/components/react-native-gesture-handler/native/BorderlessButton.tsx +19 -0
  79. package/src/components/react-native-gesture-handler/native/DrawerLayoutAndroid.tsx +20 -0
  80. package/src/components/react-native-gesture-handler/native/FlatList.tsx +29 -0
  81. package/src/components/react-native-gesture-handler/native/GestureHandlerRootView.tsx +20 -0
  82. package/src/components/react-native-gesture-handler/native/Pressable.tsx +31 -0
  83. package/src/components/react-native-gesture-handler/native/PureNativeButton.tsx +16 -0
  84. package/src/components/react-native-gesture-handler/native/RawButton.tsx +16 -0
  85. package/src/components/react-native-gesture-handler/native/RectButton.tsx +16 -0
  86. package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +26 -0
  87. package/src/components/react-native-gesture-handler/native/ScrollView.tsx +22 -0
  88. package/src/components/react-native-gesture-handler/native/Switch.tsx +29 -0
  89. package/src/components/react-native-gesture-handler/native/Text.tsx +40 -0
  90. package/src/components/react-native-gesture-handler/native/TextInput.tsx +53 -0
  91. package/src/components/react-native-gesture-handler/native/TouchableNativeFeedback.tsx +35 -0
  92. package/src/components/react-native-gesture-handler/native/TouchableOpacity.tsx +34 -0
  93. package/src/components/react-native-gesture-handler/native/TouchableWithoutFeedback.tsx +37 -0
  94. package/src/components/react-native-svg/index.ts +12 -0
  95. package/src/components/react-native-svg/native/Svg.tsx +16 -0
  96. package/src/components/react-native-svg/web/Svg.tsx +14 -0
  97. package/src/core/native/runtime.ts +2 -6
  98. package/src/core/native/store.ts +51 -5
  99. package/src/core/types.ts +10 -0
  100. package/src/metro/compileVirtual.ts +5 -1
  101. package/src/metro/processor/mq.ts +15 -10
  102. package/src/metro/processor/processor.ts +55 -16
  103. package/src/metro/resolvers.ts +25 -3
  104. package/src/metro/types.ts +3 -2
  105. package/src/metro/withUniwindConfig.ts +1 -1
  106. package/types.d.ts +38 -0
  107. package/uniwind.css +1 -6
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UniwindRuntime = void 0;
7
7
  var _reactNative = require("react-native");
8
+ var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
8
9
  var _types = require("../../types");
9
10
  var _nativeUtils = require("./native-utils");
10
11
  const window = _reactNative.Dimensions.get("window");
@@ -20,7 +21,7 @@ const UniwindRuntime = exports.UniwindRuntime = {
20
21
  fontScale: value => value * _reactNative.PixelRatio.getFontScale(),
21
22
  hairlineWidth: _reactNative.StyleSheet.hairlineWidth,
22
23
  rtl: _reactNative.I18nManager.isRTL,
23
- insets: {
24
+ insets: _reactNativeSafeAreaContext.initialWindowMetrics?.insets ?? {
24
25
  top: 0,
25
26
  left: 0,
26
27
  bottom: 0,
@@ -15,6 +15,7 @@ class UniwindStoreBuilder {
15
15
  vars = {};
16
16
  runtimeThemeVariables = /* @__PURE__ */new Map();
17
17
  stylesheet = {};
18
+ varsWithMediaQueries = [];
18
19
  cache = /* @__PURE__ */new Map();
19
20
  generateStyleSheetCallbackResult = null;
20
21
  getStyles(className, state) {
@@ -43,11 +44,15 @@ class UniwindStoreBuilder {
43
44
  const {
44
45
  scopedVars,
45
46
  stylesheet,
46
- vars
47
+ vars,
48
+ varsWithMediaQueries
47
49
  } = config;
50
+ this.vars = varsWithMediaQueries.length > 0 ? {
51
+ ...vars
52
+ } : vars;
53
+ this.varsWithMediaQueries = varsWithMediaQueries;
48
54
  this.generateStyleSheetCallbackResult = config;
49
55
  this.stylesheet = stylesheet;
50
- this.vars = vars;
51
56
  const themeVars = scopedVars[`__uniwind-theme-${this.runtime.currentThemeName}`];
52
57
  const platformVars = scopedVars[`__uniwind-platform-${_reactNative.Platform.OS}`];
53
58
  const runtimeThemeVars = this.runtimeThemeVariables.get(this.runtime.currentThemeName);
@@ -64,11 +69,36 @@ class UniwindStoreBuilder {
64
69
  _listener.UniwindListener.notifyAll();
65
70
  }
66
71
  };
72
+ resolveMediaQueryVars(dependencies) {
73
+ for (const [varName, mqVariants] of this.varsWithMediaQueries) {
74
+ let bestMatch = null;
75
+ for (const variant of mqVariants) {
76
+ if (variant.orientation !== null) dependencies.add(_types.StyleDependency.Orientation);
77
+ if (variant.maxWidth !== null || variant.minWidth !== null) dependencies.add(_types.StyleDependency.Dimensions);
78
+ if (variant.colorScheme !== null) {
79
+ dependencies.add(_types.StyleDependency.ColorScheme);
80
+ dependencies.add(_types.StyleDependency.Theme);
81
+ }
82
+ if (variant.minWidth !== null && variant.minWidth > this.runtime.screen.width || variant.maxWidth !== null && variant.maxWidth !== Number.MAX_VALUE && variant.maxWidth < this.runtime.screen.width || variant.orientation !== null && this.runtime.orientation !== variant.orientation || variant.colorScheme !== null && this.runtime.currentThemeName !== variant.colorScheme) {
83
+ continue;
84
+ }
85
+ if (bestMatch === null || (variant.minWidth ?? 0) > (bestMatch.minWidth ?? 0)) bestMatch = variant;
86
+ }
87
+ if (bestMatch !== null) {
88
+ Object.defineProperty(this.vars, varName, {
89
+ configurable: true,
90
+ enumerable: true,
91
+ get: () => bestMatch.value
92
+ });
93
+ }
94
+ }
95
+ return this.vars;
96
+ }
67
97
  resolveStyles(classNames, state) {
68
98
  const result = {};
69
- let vars = this.vars;
70
99
  const dependencies = /* @__PURE__ */new Set();
71
100
  const bestBreakpoints = /* @__PURE__ */new Map();
101
+ let vars = this.resolveMediaQueryVars(dependencies);
72
102
  for (const className of classNames.split(" ")) {
73
103
  if (!(className in this.stylesheet)) {
74
104
  continue;
@@ -46,7 +46,9 @@ const patchMetroGraphToSupportUncachedModules = () => {
46
46
 
47
47
  const thisModuleDist = node_path.resolve(__dirname, "../../dist");
48
48
  const thisModuleSrc = node_path.resolve(__dirname, "../../src");
49
+ const nodeModulesPath = node_path.resolve(__dirname, "../../../");
49
50
  const isFromThisModule = (filename) => filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc);
51
+ const name = node_path.basename(nodeModulesPath) === "node_modules" ? node_path.basename(node_path.resolve(__dirname, "../../")) : common.name;
50
52
  const SUPPORTED_COMPONENTS = [
51
53
  "ActivityIndicator",
52
54
  "Button",
@@ -71,7 +73,7 @@ const SUPPORTED_COMPONENTS = [
71
73
  "View",
72
74
  "VirtualizedList"
73
75
  ];
74
- const nativeResolver = ({
76
+ const nativeResolver = (extraComponents) => ({
75
77
  context,
76
78
  moduleName,
77
79
  platform,
@@ -86,18 +88,28 @@ const nativeResolver = ({
86
88
  return resolution;
87
89
  }
88
90
  if (moduleName === "react-native") {
89
- return resolver(context, `${common.name}/components`, platform);
91
+ return resolver(context, `${name}/components`, platform);
92
+ }
93
+ if (moduleName === "react-native-gesture-handler") {
94
+ return resolver(context, `${name}/components/react-native-gesture-handler`, platform);
95
+ }
96
+ if (moduleName === "react-native-svg") {
97
+ return resolver(context, `${name}/components/react-native-svg`, platform);
90
98
  }
91
99
  if (resolution.filePath.includes(`${node_path.sep}react-native${node_path.sep}Libraries${node_path.sep}`)) {
92
100
  const filename = node_path.basename(resolution.filePath.split(node_path.sep).at(-1) ?? "");
93
101
  const module = filename.split(".").at(0);
94
102
  if (module !== void 0 && SUPPORTED_COMPONENTS.includes(module)) {
95
- return resolver(context, `${common.name}/components/${module}`, platform);
103
+ return resolver(context, `${name}/components/${module}`, platform);
96
104
  }
97
105
  }
106
+ if (moduleName in extraComponents) {
107
+ const componentPath = extraComponents[moduleName];
108
+ return resolver(context, componentPath, platform);
109
+ }
98
110
  return resolution;
99
111
  };
100
- const webResolver = ({
112
+ const webResolver = (extraComponents) => ({
101
113
  context,
102
114
  moduleName,
103
115
  platform,
@@ -107,13 +119,17 @@ const webResolver = ({
107
119
  if (isFromThisModule(context.originModulePath) || resolution.type !== "sourceFile" || !resolution.filePath.includes(`${node_path.sep}react-native-web${node_path.sep}`)) {
108
120
  return resolution;
109
121
  }
122
+ if (moduleName in extraComponents) {
123
+ const componentPath = extraComponents[moduleName];
124
+ return resolver(context, componentPath, platform);
125
+ }
110
126
  const segments = resolution.filePath.split(node_path.sep);
111
127
  const isIndex = segments.at(-1)?.startsWith("index.");
112
128
  const module = segments.at(-2);
113
129
  if (!isIndex || module === void 0 || !SUPPORTED_COMPONENTS.includes(module) || context.originModulePath.endsWith(`${module}${node_path.sep}index.js`)) {
114
130
  return resolution;
115
131
  }
116
- return resolver(context, `${common.name}/components/${module}`, platform);
132
+ return resolver(context, `${name}/components/${module}`, platform);
117
133
  };
118
134
 
119
135
  const withUniwindConfig = (config, uniwindConfig) => {
@@ -150,7 +166,7 @@ const withUniwindConfig = (config, uniwindConfig) => {
150
166
  ),
151
167
  resolveRequest: (context, moduleName, platform) => {
152
168
  const resolver = config.resolver?.resolveRequest ?? context.resolveRequest;
153
- const platformResolver = platform === types.Platform.Web ? webResolver : nativeResolver;
169
+ const platformResolver = (platform === types.Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {});
154
170
  const resolved = platformResolver({
155
171
  context,
156
172
  moduleName,
@@ -2,7 +2,7 @@ import FileStoreBase from 'metro-cache/private/stores/FileStore';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
4
  import { sep, basename, resolve } from 'node:path';
5
- import { n as name, u as uniq } from '../shared/uniwind.D3fvrgEG.mjs';
5
+ import { n as name$1, u as uniq } from '../shared/uniwind.D3fvrgEG.mjs';
6
6
  import { P as Platform } from '../shared/uniwind.CyoRUwOj.mjs';
7
7
 
8
8
  class FileStore extends FileStoreBase {
@@ -38,7 +38,9 @@ const patchMetroGraphToSupportUncachedModules = () => {
38
38
 
39
39
  const thisModuleDist = resolve(__dirname, "../../dist");
40
40
  const thisModuleSrc = resolve(__dirname, "../../src");
41
+ const nodeModulesPath = resolve(__dirname, "../../../");
41
42
  const isFromThisModule = (filename) => filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc);
43
+ const name = basename(nodeModulesPath) === "node_modules" ? basename(resolve(__dirname, "../../")) : name$1;
42
44
  const SUPPORTED_COMPONENTS = [
43
45
  "ActivityIndicator",
44
46
  "Button",
@@ -63,7 +65,7 @@ const SUPPORTED_COMPONENTS = [
63
65
  "View",
64
66
  "VirtualizedList"
65
67
  ];
66
- const nativeResolver = ({
68
+ const nativeResolver = (extraComponents) => ({
67
69
  context,
68
70
  moduleName,
69
71
  platform,
@@ -80,6 +82,12 @@ const nativeResolver = ({
80
82
  if (moduleName === "react-native") {
81
83
  return resolver(context, `${name}/components`, platform);
82
84
  }
85
+ if (moduleName === "react-native-gesture-handler") {
86
+ return resolver(context, `${name}/components/react-native-gesture-handler`, platform);
87
+ }
88
+ if (moduleName === "react-native-svg") {
89
+ return resolver(context, `${name}/components/react-native-svg`, platform);
90
+ }
83
91
  if (resolution.filePath.includes(`${sep}react-native${sep}Libraries${sep}`)) {
84
92
  const filename = basename(resolution.filePath.split(sep).at(-1) ?? "");
85
93
  const module = filename.split(".").at(0);
@@ -87,9 +95,13 @@ const nativeResolver = ({
87
95
  return resolver(context, `${name}/components/${module}`, platform);
88
96
  }
89
97
  }
98
+ if (moduleName in extraComponents) {
99
+ const componentPath = extraComponents[moduleName];
100
+ return resolver(context, componentPath, platform);
101
+ }
90
102
  return resolution;
91
103
  };
92
- const webResolver = ({
104
+ const webResolver = (extraComponents) => ({
93
105
  context,
94
106
  moduleName,
95
107
  platform,
@@ -99,6 +111,10 @@ const webResolver = ({
99
111
  if (isFromThisModule(context.originModulePath) || resolution.type !== "sourceFile" || !resolution.filePath.includes(`${sep}react-native-web${sep}`)) {
100
112
  return resolution;
101
113
  }
114
+ if (moduleName in extraComponents) {
115
+ const componentPath = extraComponents[moduleName];
116
+ return resolver(context, componentPath, platform);
117
+ }
102
118
  const segments = resolution.filePath.split(sep);
103
119
  const isIndex = segments.at(-1)?.startsWith("index.");
104
120
  const module = segments.at(-2);
@@ -142,7 +158,7 @@ const withUniwindConfig = (config, uniwindConfig) => {
142
158
  ),
143
159
  resolveRequest: (context, moduleName, platform) => {
144
160
  const resolver = config.resolver?.resolveRequest ?? context.resolveRequest;
145
- const platformResolver = platform === Platform.Web ? webResolver : nativeResolver;
161
+ const platformResolver = (platform === Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {});
146
162
  const resolved = platformResolver({
147
163
  context,
148
164
  moduleName,
@@ -898,23 +898,29 @@ class MQ {
898
898
  }
899
899
  processMediaQueries(mediaQueries) {
900
900
  const mq = this.getInitialMediaQueryResolver();
901
- mediaQueries.forEach((mediaQuery) => {
901
+ for (const mediaQuery of mediaQueries) {
902
902
  const { condition, mediaType } = mediaQuery;
903
903
  if ([types.Platform.Android, types.Platform.iOS, types.Platform.Native].includes(mediaType)) {
904
904
  mq.platform = mediaType;
905
- return;
906
- }
907
- if (condition?.type !== "feature") {
908
- return;
905
+ continue;
909
906
  }
907
+ if (condition) this.processCondition(condition, mq);
908
+ }
909
+ return mq;
910
+ }
911
+ processCondition(condition, mq) {
912
+ if (condition.type === "operation") {
913
+ condition.conditions.forEach((nestedCondition) => {
914
+ this.processCondition(nestedCondition, mq);
915
+ });
916
+ } else if (condition.type === "feature") {
910
917
  if (condition.value.type === "range") {
911
918
  this.processWidthMediaQuery(condition.value, mq);
912
919
  }
913
920
  if (condition.value.type === "plain") {
914
921
  this.processPlainMediaQuery(condition.value, mq);
915
922
  }
916
- });
917
- return mq;
923
+ }
918
924
  }
919
925
  processWidthMediaQuery(query, mq) {
920
926
  const { operator, value } = query;
@@ -1250,6 +1256,7 @@ class ProcessorBuilder {
1250
1256
  stylesheets = {};
1251
1257
  vars = {};
1252
1258
  scopedVars = {};
1259
+ varsWithMediaQueries = {};
1253
1260
  CSS = new CSS(this);
1254
1261
  RN = new RN(this);
1255
1262
  Var = new Var(this);
@@ -1283,6 +1290,32 @@ class ProcessorBuilder {
1283
1290
  disabled: null
1284
1291
  };
1285
1292
  }
1293
+ storeVarWithMediaQuery(varName, value, mq) {
1294
+ if (!Array.isArray(this.varsWithMediaQueries[varName])) {
1295
+ this.varsWithMediaQueries[varName] = [];
1296
+ }
1297
+ this.varsWithMediaQueries[varName].push({
1298
+ value,
1299
+ minWidth: mq.minWidth,
1300
+ maxWidth: mq.maxWidth,
1301
+ orientation: mq.orientation ? `'${mq.orientation}'` : null,
1302
+ colorScheme: mq.colorScheme ? `'${mq.colorScheme}'` : null
1303
+ });
1304
+ }
1305
+ hasMediaQuery(mq) {
1306
+ return mq.minWidth !== 0 || mq.maxWidth !== Number.MAX_VALUE || mq.orientation !== null || mq.colorScheme !== null;
1307
+ }
1308
+ processDeclarationValue(mq, varName, processedValue, context) {
1309
+ const { isVar, style, important } = context;
1310
+ if (isVar && this.hasMediaQuery(mq)) {
1311
+ this.storeVarWithMediaQuery(varName, processedValue, mq);
1312
+ } else {
1313
+ style[varName] = processedValue;
1314
+ }
1315
+ if (!isVar && important) {
1316
+ style.importantProperties.push(varName);
1317
+ }
1318
+ }
1286
1319
  addDeclaration(declaration, important = false) {
1287
1320
  const isVar = this.declarationConfig.root || this.declarationConfig.className === null;
1288
1321
  const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries);
@@ -1312,24 +1345,22 @@ class ProcessorBuilder {
1312
1345
  style.disabled = this.declarationConfig.disabled;
1313
1346
  this.meta.className = this.declarationConfig.className;
1314
1347
  }
1348
+ const context = { isVar, style, important };
1315
1349
  if (declaration.property === "unparsed") {
1316
- style[declaration.value.propertyId.property] = this.CSS.processValue(declaration.value.value);
1317
- if (!isVar && important) {
1318
- style.importantProperties.push(declaration.value.propertyId.property);
1319
- }
1350
+ const varName2 = declaration.value.propertyId.property;
1351
+ const processedValue2 = this.CSS.processValue(declaration.value.value);
1352
+ this.processDeclarationValue(mq, varName2, processedValue2, context);
1320
1353
  return;
1321
1354
  }
1322
1355
  if (declaration.property === "custom") {
1323
- style[declaration.value.name] = this.CSS.processValue(declaration.value.value);
1324
- if (!isVar && important) {
1325
- style.importantProperties.push(declaration.value.name);
1326
- }
1356
+ const varName2 = declaration.value.name;
1357
+ const processedValue2 = this.CSS.processValue(declaration.value.value);
1358
+ this.processDeclarationValue(mq, varName2, processedValue2, context);
1327
1359
  return;
1328
1360
  }
1329
- style[declaration.property] = this.CSS.processValue(declaration.value);
1330
- if (!isVar && important) {
1331
- style.importantProperties.push(declaration.property);
1332
- }
1361
+ const varName = declaration.property;
1362
+ const processedValue = this.CSS.processValue(declaration.value);
1363
+ this.processDeclarationValue(mq, varName, processedValue, context);
1333
1364
  }
1334
1365
  parseRuleRec(rule) {
1335
1366
  if (this.declarationConfig.className !== null) {
@@ -1417,6 +1448,10 @@ class ProcessorBuilder {
1417
1448
  this.parseRuleRec(rule2);
1418
1449
  this.declarationConfig = this.getDeclarationConfig();
1419
1450
  });
1451
+ this.declarationConfig.mediaQueries.splice(
1452
+ this.declarationConfig.mediaQueries.length - mediaQueries.length,
1453
+ mediaQueries.length
1454
+ );
1420
1455
  return;
1421
1456
  }
1422
1457
  if (rule.type === "layer-block") {
@@ -1470,12 +1505,14 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
1470
1505
  serializeJSObject(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)
1471
1506
  ])
1472
1507
  );
1508
+ const varsWithMediaQueries = Object.entries(Processor.varsWithMediaQueries).map(([key, value]) => `["${key}", ${serialize(value)}]`).join(",");
1473
1509
  const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
1474
1510
  const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
1475
1511
  return [
1476
1512
  "({",
1477
1513
  `scopedVars: ({ ${serializedScopedVars} }),`,
1478
1514
  `vars: ({ ${currentColorVar} ${vars} }),`,
1515
+ `varsWithMediaQueries: ([ ${varsWithMediaQueries} ]),`,
1479
1516
  `stylesheet: ({ ${stylesheet} }),`,
1480
1517
  "})"
1481
1518
  ].join("");
@@ -891,23 +891,29 @@ class MQ {
891
891
  }
892
892
  processMediaQueries(mediaQueries) {
893
893
  const mq = this.getInitialMediaQueryResolver();
894
- mediaQueries.forEach((mediaQuery) => {
894
+ for (const mediaQuery of mediaQueries) {
895
895
  const { condition, mediaType } = mediaQuery;
896
896
  if ([Platform.Android, Platform.iOS, Platform.Native].includes(mediaType)) {
897
897
  mq.platform = mediaType;
898
- return;
899
- }
900
- if (condition?.type !== "feature") {
901
- return;
898
+ continue;
902
899
  }
900
+ if (condition) this.processCondition(condition, mq);
901
+ }
902
+ return mq;
903
+ }
904
+ processCondition(condition, mq) {
905
+ if (condition.type === "operation") {
906
+ condition.conditions.forEach((nestedCondition) => {
907
+ this.processCondition(nestedCondition, mq);
908
+ });
909
+ } else if (condition.type === "feature") {
903
910
  if (condition.value.type === "range") {
904
911
  this.processWidthMediaQuery(condition.value, mq);
905
912
  }
906
913
  if (condition.value.type === "plain") {
907
914
  this.processPlainMediaQuery(condition.value, mq);
908
915
  }
909
- });
910
- return mq;
916
+ }
911
917
  }
912
918
  processWidthMediaQuery(query, mq) {
913
919
  const { operator, value } = query;
@@ -1243,6 +1249,7 @@ class ProcessorBuilder {
1243
1249
  stylesheets = {};
1244
1250
  vars = {};
1245
1251
  scopedVars = {};
1252
+ varsWithMediaQueries = {};
1246
1253
  CSS = new CSS(this);
1247
1254
  RN = new RN(this);
1248
1255
  Var = new Var(this);
@@ -1276,6 +1283,32 @@ class ProcessorBuilder {
1276
1283
  disabled: null
1277
1284
  };
1278
1285
  }
1286
+ storeVarWithMediaQuery(varName, value, mq) {
1287
+ if (!Array.isArray(this.varsWithMediaQueries[varName])) {
1288
+ this.varsWithMediaQueries[varName] = [];
1289
+ }
1290
+ this.varsWithMediaQueries[varName].push({
1291
+ value,
1292
+ minWidth: mq.minWidth,
1293
+ maxWidth: mq.maxWidth,
1294
+ orientation: mq.orientation ? `'${mq.orientation}'` : null,
1295
+ colorScheme: mq.colorScheme ? `'${mq.colorScheme}'` : null
1296
+ });
1297
+ }
1298
+ hasMediaQuery(mq) {
1299
+ return mq.minWidth !== 0 || mq.maxWidth !== Number.MAX_VALUE || mq.orientation !== null || mq.colorScheme !== null;
1300
+ }
1301
+ processDeclarationValue(mq, varName, processedValue, context) {
1302
+ const { isVar, style, important } = context;
1303
+ if (isVar && this.hasMediaQuery(mq)) {
1304
+ this.storeVarWithMediaQuery(varName, processedValue, mq);
1305
+ } else {
1306
+ style[varName] = processedValue;
1307
+ }
1308
+ if (!isVar && important) {
1309
+ style.importantProperties.push(varName);
1310
+ }
1311
+ }
1279
1312
  addDeclaration(declaration, important = false) {
1280
1313
  const isVar = this.declarationConfig.root || this.declarationConfig.className === null;
1281
1314
  const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries);
@@ -1305,24 +1338,22 @@ class ProcessorBuilder {
1305
1338
  style.disabled = this.declarationConfig.disabled;
1306
1339
  this.meta.className = this.declarationConfig.className;
1307
1340
  }
1341
+ const context = { isVar, style, important };
1308
1342
  if (declaration.property === "unparsed") {
1309
- style[declaration.value.propertyId.property] = this.CSS.processValue(declaration.value.value);
1310
- if (!isVar && important) {
1311
- style.importantProperties.push(declaration.value.propertyId.property);
1312
- }
1343
+ const varName2 = declaration.value.propertyId.property;
1344
+ const processedValue2 = this.CSS.processValue(declaration.value.value);
1345
+ this.processDeclarationValue(mq, varName2, processedValue2, context);
1313
1346
  return;
1314
1347
  }
1315
1348
  if (declaration.property === "custom") {
1316
- style[declaration.value.name] = this.CSS.processValue(declaration.value.value);
1317
- if (!isVar && important) {
1318
- style.importantProperties.push(declaration.value.name);
1319
- }
1349
+ const varName2 = declaration.value.name;
1350
+ const processedValue2 = this.CSS.processValue(declaration.value.value);
1351
+ this.processDeclarationValue(mq, varName2, processedValue2, context);
1320
1352
  return;
1321
1353
  }
1322
- style[declaration.property] = this.CSS.processValue(declaration.value);
1323
- if (!isVar && important) {
1324
- style.importantProperties.push(declaration.property);
1325
- }
1354
+ const varName = declaration.property;
1355
+ const processedValue = this.CSS.processValue(declaration.value);
1356
+ this.processDeclarationValue(mq, varName, processedValue, context);
1326
1357
  }
1327
1358
  parseRuleRec(rule) {
1328
1359
  if (this.declarationConfig.className !== null) {
@@ -1410,6 +1441,10 @@ class ProcessorBuilder {
1410
1441
  this.parseRuleRec(rule2);
1411
1442
  this.declarationConfig = this.getDeclarationConfig();
1412
1443
  });
1444
+ this.declarationConfig.mediaQueries.splice(
1445
+ this.declarationConfig.mediaQueries.length - mediaQueries.length,
1446
+ mediaQueries.length
1447
+ );
1413
1448
  return;
1414
1449
  }
1415
1450
  if (rule.type === "layer-block") {
@@ -1463,12 +1498,14 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
1463
1498
  serializeJSObject(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)
1464
1499
  ])
1465
1500
  );
1501
+ const varsWithMediaQueries = Object.entries(Processor.varsWithMediaQueries).map(([key, value]) => `["${key}", ${serialize(value)}]`).join(",");
1466
1502
  const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
1467
1503
  const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
1468
1504
  return [
1469
1505
  "({",
1470
1506
  `scopedVars: ({ ${serializedScopedVars} }),`,
1471
1507
  `vars: ({ ${currentColorVar} ${vars} }),`,
1508
+ `varsWithMediaQueries: ([ ${varsWithMediaQueries} ]),`,
1472
1509
  `stylesheet: ({ ${stylesheet} }),`,
1473
1510
  "})"
1474
1511
  ].join("");
@@ -0,0 +1,120 @@
1
+ module.exports = {
2
+ get BaseButton() {
3
+ return require("./native/BaseButton").BaseButton;
4
+ },
5
+ get BorderlessButton() {
6
+ return require("./native/BorderlessButton").BorderlessButton;
7
+ },
8
+ get DrawerLayoutAndroid() {
9
+ return require("./native/DrawerLayoutAndroid").DrawerLayoutAndroid;
10
+ },
11
+ get FlatList() {
12
+ return require("./native/FlatList").FlatList;
13
+ },
14
+ get GestureHandlerRootView() {
15
+ return require("./native/GestureHandlerRootView").GestureHandlerRootView;
16
+ },
17
+ get Pressable() {
18
+ return require("./native/Pressable").Pressable;
19
+ },
20
+ get PureNativeButton() {
21
+ return require("./native/PureNativeButton").PureNativeButton;
22
+ },
23
+ get RawButton() {
24
+ return require("./native/RawButton").RawButton;
25
+ },
26
+ get RectButton() {
27
+ return require("./native/RectButton").RectButton;
28
+ },
29
+ get RefreshControl() {
30
+ return require("./native/RefreshControl").RefreshControl;
31
+ },
32
+ get ScrollView() {
33
+ return require("./native/ScrollView").ScrollView;
34
+ },
35
+ get Switch() {
36
+ return require("./native/Switch").Switch;
37
+ },
38
+ get Text() {
39
+ return require("./native/Text").Text;
40
+ },
41
+ get TextInput() {
42
+ return require("./native/TextInput").TextInput;
43
+ },
44
+ get TouchableNativeFeedback() {
45
+ return require("./native/TouchableNativeFeedback").TouchableNativeFeedback;
46
+ },
47
+ get TouchableOpacity() {
48
+ return require("./native/TouchableOpacity").TouchableOpacity;
49
+ },
50
+ get TouchableWithoutFeedback() {
51
+ return require("./native/TouchableWithoutFeedback").TouchableWithoutFeedback;
52
+ },
53
+ // Re-export non-component exports from react-native-gesture-handler
54
+ get DrawerLayout() {
55
+ return require("react-native-gesture-handler").DrawerLayout;
56
+ },
57
+ get Swipeable() {
58
+ return require("react-native-gesture-handler").Swipeable;
59
+ },
60
+ get TouchableHighlight() {
61
+ return require("react-native-gesture-handler").TouchableHighlight;
62
+ },
63
+ get Directions() {
64
+ return require("react-native-gesture-handler").Directions;
65
+ },
66
+ get State() {
67
+ return require("react-native-gesture-handler").State;
68
+ },
69
+ get PointerType() {
70
+ return require("react-native-gesture-handler").PointerType;
71
+ },
72
+ get gestureHandlerRootHOC() {
73
+ return require("react-native-gesture-handler").gestureHandlerRootHOC;
74
+ },
75
+ get GestureDetector() {
76
+ return require("react-native-gesture-handler").GestureDetector;
77
+ },
78
+ get Gesture() {
79
+ return require("react-native-gesture-handler").Gesture;
80
+ },
81
+ get TapGestureHandler() {
82
+ return require("react-native-gesture-handler").TapGestureHandler;
83
+ },
84
+ get ForceTouchGestureHandler() {
85
+ return require("react-native-gesture-handler").ForceTouchGestureHandler;
86
+ },
87
+ get LongPressGestureHandler() {
88
+ return require("react-native-gesture-handler").LongPressGestureHandler;
89
+ },
90
+ get PanGestureHandler() {
91
+ return require("react-native-gesture-handler").PanGestureHandler;
92
+ },
93
+ get PinchGestureHandler() {
94
+ return require("react-native-gesture-handler").PinchGestureHandler;
95
+ },
96
+ get RotationGestureHandler() {
97
+ return require("react-native-gesture-handler").RotationGestureHandler;
98
+ },
99
+ get FlingGestureHandler() {
100
+ return require("react-native-gesture-handler").FlingGestureHandler;
101
+ },
102
+ get createNativeWrapper() {
103
+ return require("react-native-gesture-handler").createNativeWrapper;
104
+ },
105
+ get NativeViewGestureHandler() {
106
+ return require("react-native-gesture-handler").NativeViewGestureHandler;
107
+ },
108
+ get HoverEffect() {
109
+ return require("react-native-gesture-handler").HoverEffect;
110
+ },
111
+ get MouseButton() {
112
+ return require("react-native-gesture-handler").MouseButton;
113
+ },
114
+ get enableExperimentalWebImplementation() {
115
+ return require("react-native-gesture-handler").enableExperimentalWebImplementation;
116
+ },
117
+ get enableLegacyWebImplementation() {
118
+ return require("react-native-gesture-handler").enableLegacyWebImplementation;
119
+ }
120
+ };
@@ -0,0 +1,3 @@
1
+ import { BaseButtonProps } from 'react-native-gesture-handler';
2
+ export declare const BaseButton: import("react").ForwardRefExoticComponent<Omit<BaseButtonProps, "innerRef"> & import("react").RefAttributes<import("react").ComponentType<{}>>>;
3
+ export default BaseButton;
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { BaseButton as RNGHBaseButton } from "react-native-gesture-handler";
3
+ import { useStyle } from "../../native/useStyle.js";
4
+ import { copyComponentProperties } from "../../utils.js";
5
+ export const BaseButton = copyComponentProperties(RNGHBaseButton, (props) => {
6
+ const style = useStyle(props.className);
7
+ return /* @__PURE__ */ jsx(
8
+ RNGHBaseButton,
9
+ {
10
+ ...props,
11
+ style: [style, props.style]
12
+ }
13
+ );
14
+ });
15
+ export default BaseButton;
@@ -0,0 +1,3 @@
1
+ import { BorderlessButtonProps } from 'react-native-gesture-handler';
2
+ export declare const BorderlessButton: import("react").ForwardRefExoticComponent<Omit<BorderlessButtonProps, "innerRef"> & import("react").RefAttributes<import("react").ComponentType<{}>>>;
3
+ export default BorderlessButton;