@react-native-gpui/config 0.0.0-stage → 1.7.0-alpha.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@react-native-gpui/config` are listed here. Each version's section becomes the notes of its GitHub release.
4
+
5
+ ## 1.7.0-alpha.1 - 2026-11-27
6
+
7
+ - First release, for `react-native-config` 1.7.x: exposes the values of a `.env` file to JavaScript on desktop.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Streetwriters
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # @react-native-gpui/config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Adapter for [`react-native-config`](https://github.com/react-native-config/react-native-config) (MIT): exposes the values of a `.env` file to JavaScript on desktop.
4
+
5
+ ## About
6
+
7
+ This package is the desktop adapter for [`react-native-config`](https://github.com/react-native-config/react-native-config) 1.7. Install the original library next to it; its JavaScript runs unchanged on desktop, and this package provides the native side. The upstream library is licensed under the MIT license.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install react-native-config @react-native-gpui/config
13
+ ```
14
+
15
+ The module is autolinked on desktop.
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ import Config from 'react-native-config';
21
+
22
+ const apiUrl = Config.API_URL;
23
+ ```
24
+
25
+ ## Platforms
26
+
27
+ macOS is tested. Windows and Linux are not tested yet.
28
+
29
+ ## Limitations
30
+
31
+ The file is read when the app is built, not when it runs. The build reads `ENVFILE` if it is set, otherwise `.env` in the folder named by `RN_GPUI_PROJECT_ROOT`. Changing the file rebuilds the module. Values are read as text, with `\n` expanded to a newline; `export` prefixes and inline comments after a space are dropped.
32
+
33
+ ## License
34
+
35
+ MIT. See [LICENSE](LICENSE). The upstream library, [`react-native-config`](https://github.com/react-native-config/react-native-config), is MIT licensed.
@@ -0,0 +1,10 @@
1
+ [package]
2
+ name = "rn-gpui-config"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ rn-gpui-module = { version = "0.1" }
8
+
9
+ [build-dependencies]
10
+ rn-gpui-module-build = { version = "0.1" }
@@ -0,0 +1,58 @@
1
+ use std::fmt::Write as _;
2
+ use std::path::PathBuf;
3
+
4
+ fn main() {
5
+ rn_gpui_module_build::generate(&["../src/NativeConfigModule.ts"]);
6
+
7
+ println!("cargo:rerun-if-env-changed=ENVFILE");
8
+ println!("cargo:rerun-if-env-changed=RN_GPUI_PROJECT_ROOT");
9
+ println!("cargo:rerun-if-env-changed=RN_GPUI_AUTOLINK_CMAKE");
10
+
11
+ let file = std::env::var_os("ENVFILE")
12
+ .map(PathBuf::from)
13
+ .unwrap_or_else(|| project_root().join(".env"));
14
+ println!("cargo:rerun-if-changed={}", file.display());
15
+
16
+ let mut entries = String::new();
17
+ if let Ok(text) = std::fs::read_to_string(&file) {
18
+ for (key, value) in parse(&text) {
19
+ let _ = writeln!(entries, " ({key:?}, {value:?}),");
20
+ }
21
+ }
22
+ let out = PathBuf::from(std::env::var_os("OUT_DIR").expect("OUT_DIR"));
23
+ std::fs::write(
24
+ out.join("config_env.rs"),
25
+ format!("pub const ENTRIES: &[(&str, &str)] = &[\n{entries}];\n"),
26
+ )
27
+ .expect("write config_env.rs");
28
+ }
29
+
30
+ /// The app root, the folder that holds `desktop/autolink/`, as the core does it.
31
+ fn project_root() -> PathBuf {
32
+ if let Some(root) = std::env::var_os("RN_GPUI_PROJECT_ROOT") {
33
+ return PathBuf::from(root);
34
+ }
35
+ std::env::var_os("RN_GPUI_AUTOLINK_CMAKE")
36
+ .map(PathBuf::from)
37
+ .and_then(|cmake| cmake.parent()?.parent()?.parent().map(PathBuf::from))
38
+ .unwrap_or_else(|| PathBuf::from("."))
39
+ }
40
+
41
+ fn parse(text: &str) -> Vec<(String, String)> {
42
+ text.lines()
43
+ .filter_map(|line| {
44
+ let line = line.trim();
45
+ if line.is_empty() || line.starts_with('#') {
46
+ return None;
47
+ }
48
+ let line = line.strip_prefix("export ").unwrap_or(line);
49
+ let (key, value) = line.split_once('=')?;
50
+ let value = value.trim();
51
+ let value = match value.as_bytes() {
52
+ [quote @ (b'"' | b'\''), .., last] if quote == last => &value[1..value.len() - 1],
53
+ _ => value.split(" #").next().unwrap_or(value).trim(),
54
+ };
55
+ Some((key.trim().to_string(), value.replace("\\n", "\n")))
56
+ })
57
+ .collect()
58
+ }
@@ -0,0 +1,26 @@
1
+ rn_gpui_module::include_specs!();
2
+
3
+ use rn_gpui_module::{ModuleError, Value};
4
+
5
+ include!(concat!(env!("OUT_DIR"), "/config_env.rs"));
6
+
7
+ pub struct RNCConfigModule;
8
+
9
+ impl NativeConfigModuleSpec for RNCConfigModule {
10
+ fn new(_events: NativeConfigModuleEvents) -> Self {
11
+ Self
12
+ }
13
+
14
+ fn get_config(&self) -> Result<GetConfigResult, ModuleError> {
15
+ let config = Value::object(
16
+ ENTRIES
17
+ .iter()
18
+ .map(|(key, value)| (*key, Value::String((*value).to_string()))),
19
+ );
20
+ Ok(GetConfigResult { config })
21
+ }
22
+ }
23
+
24
+ pub fn rn_gpui_register() {
25
+ rn_gpui_module::register(native_config_module_module::<RNCConfigModule>());
26
+ }
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@react-native-gpui/config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.7.0-alpha.1",
4
+ "description": "Adapter for react-native-config (MIT): exposes the values of the .env file to JavaScript on desktop",
5
+ "license": "MIT",
6
+ "main": "src/index.ts",
7
+ "files": [
8
+ "src",
9
+ "desktop",
10
+ "react-native.config.js",
11
+ "README.md",
12
+ "CHANGELOG.md",
13
+ "LICENSE"
14
+ ],
15
+ "codegenConfig": {
16
+ "name": "RNCConfigSpec",
17
+ "type": "modules",
18
+ "jsSrcsDir": "src"
19
+ },
20
+ "peerDependencies": {
21
+ "react-native": "0.87.x",
22
+ "react-native-config": "1.7.x"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/streetwriters/react-native-gpui-modules.git",
27
+ "directory": "modules/config"
28
+ },
29
+ "homepage": "https://github.com/streetwriters/react-native-gpui-modules/tree/main/modules/config#readme",
30
+ "bugs": {
31
+ "url": "https://github.com/streetwriters/react-native-gpui-modules/issues"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public",
35
+ "tag": "latest"
36
+ }
37
+ }
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ desktop: {
5
+ crate: 'rn-gpui-config',
6
+ },
7
+ },
8
+ },
9
+ };
@@ -0,0 +1,10 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ getConfig(): {
6
+ config: Object;
7
+ };
8
+ }
9
+
10
+ export default TurboModuleRegistry.getEnforcing<Spec>('RNCConfigModule');
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export {};