@modulehub/expo-custom-strings 1.0.0
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/LICENSE +21 -0
- package/README.md +70 -0
- package/app.plugin.js +1 -0
- package/build/pluginConfig.d.ts +17 -0
- package/build/pluginConfig.d.ts.map +1 -0
- package/build/pluginConfig.js +2 -0
- package/build/withCustomStrings.d.ts +10 -0
- package/build/withCustomStrings.d.ts.map +1 -0
- package/build/withCustomStrings.js +29 -0
- package/package.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 modulehub7
|
|
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
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
**ModuleHub Expo Custom Strings Plugin**
|
|
2
|
+
Internal Expo config plugin for injecting custom Android string resources into strings.xml during expo prebuild.
|
|
3
|
+
|
|
4
|
+
This allows native Android string values to be configured directly from app.json.
|
|
5
|
+
|
|
6
|
+
📦 Installation
|
|
7
|
+
1️⃣ Add the dependency in your app’s package.json
|
|
8
|
+
{
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@modulehub/expo-custom-strings":"1.0.0"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
2️⃣ Install dependencies
|
|
14
|
+
|
|
15
|
+
Using pnpm:
|
|
16
|
+
|
|
17
|
+
pnpm install
|
|
18
|
+
⚙️ Usage
|
|
19
|
+
1️⃣ Configure the plugin in app.json
|
|
20
|
+
{
|
|
21
|
+
"expo": {
|
|
22
|
+
"plugins": [
|
|
23
|
+
[
|
|
24
|
+
"@modulehub/expo-custom-strings",
|
|
25
|
+
{
|
|
26
|
+
"api_url": {
|
|
27
|
+
"value": "https://example.com",
|
|
28
|
+
"moduleConfig": true
|
|
29
|
+
},
|
|
30
|
+
"app_name_native": {
|
|
31
|
+
"value": "value"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
2️⃣ Run prebuild
|
|
39
|
+
npx expo prebuild
|
|
40
|
+
🧠 What It Does
|
|
41
|
+
|
|
42
|
+
During prebuild, the plugin:
|
|
43
|
+
|
|
44
|
+
Reads Android strings.xml
|
|
45
|
+
|
|
46
|
+
Appends new <string> entries
|
|
47
|
+
|
|
48
|
+
Skips keys that already exist
|
|
49
|
+
|
|
50
|
+
Optionally adds moduleConfig="true" attribute
|
|
51
|
+
|
|
52
|
+
Example output:
|
|
53
|
+
|
|
54
|
+
<string name="api_url" moduleConfig="true">
|
|
55
|
+
https://example.com
|
|
56
|
+
</string>
|
|
57
|
+
|
|
58
|
+
<string name="app_name_native">
|
|
59
|
+
example_value
|
|
60
|
+
</string>
|
|
61
|
+
🛠 Configuration Format
|
|
62
|
+
|
|
63
|
+
Each string entry must follow:
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
"string_key": {
|
|
67
|
+
"value": "string value",
|
|
68
|
+
"moduleConfig": true
|
|
69
|
+
}
|
|
70
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./build/withCustomStrings');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for a single custom string entry in Android strings.xml
|
|
3
|
+
*/
|
|
4
|
+
export interface CustomStringEntry {
|
|
5
|
+
/** The string value to write */
|
|
6
|
+
value: string;
|
|
7
|
+
/** If true, adds moduleConfig="true" to the string element */
|
|
8
|
+
moduleConfig?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Plugin configuration: a map of string resource names to their entries.
|
|
12
|
+
* Keys become the `name` attribute of each <string> element.
|
|
13
|
+
*/
|
|
14
|
+
export interface CustomStringsPluginProps {
|
|
15
|
+
[key: string]: CustomStringEntry;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=pluginConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginConfig.d.ts","sourceRoot":"","sources":["../src/pluginConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAClC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import type { CustomStringsPluginProps } from './pluginConfig';
|
|
3
|
+
export type { CustomStringsPluginProps, CustomStringEntry } from './pluginConfig';
|
|
4
|
+
/**
|
|
5
|
+
* Expo config plugin that adds custom string resources to Android strings.xml.
|
|
6
|
+
* Each key in props becomes a <string name="key">value</string> entry.
|
|
7
|
+
*/
|
|
8
|
+
declare const withCustomStrings: ConfigPlugin<CustomStringsPluginProps>;
|
|
9
|
+
export default withCustomStrings;
|
|
10
|
+
//# sourceMappingURL=withCustomStrings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withCustomStrings.d.ts","sourceRoot":"","sources":["../src/withCustomStrings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,YAAY,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAElF;;;GAGG;AACH,QAAA,MAAM,iBAAiB,EAAE,YAAY,CAAC,wBAAwB,CA2B7D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
+
/**
|
|
5
|
+
* Expo config plugin that adds custom string resources to Android strings.xml.
|
|
6
|
+
* Each key in props becomes a <string name="key">value</string> entry.
|
|
7
|
+
*/
|
|
8
|
+
const withCustomStrings = (config, props) => {
|
|
9
|
+
return (0, config_plugins_1.withStringsXml)(config, (modConfig) => {
|
|
10
|
+
const strings = modConfig.modResults.resources.string || [];
|
|
11
|
+
for (const key of Object.keys(props)) {
|
|
12
|
+
const { value, moduleConfig } = props[key];
|
|
13
|
+
const existing = strings.find((s) => s.$?.name === key);
|
|
14
|
+
if (existing)
|
|
15
|
+
continue;
|
|
16
|
+
const entry = {
|
|
17
|
+
$: { name: key },
|
|
18
|
+
_: value,
|
|
19
|
+
};
|
|
20
|
+
if (moduleConfig === true) {
|
|
21
|
+
entry.$['moduleConfig'] = 'true';
|
|
22
|
+
}
|
|
23
|
+
strings.push(entry);
|
|
24
|
+
}
|
|
25
|
+
modConfig.modResults.resources.string = strings;
|
|
26
|
+
return modConfig;
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.default = withCustomStrings;
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@modulehub/expo-custom-strings",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "app.plugin.js",
|
|
5
|
+
"types": "build/withCustomStrings.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"prepublishOnly": "npm run build"
|
|
9
|
+
},
|
|
10
|
+
"files": ["app.plugin.js", "build", "README.md"],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": ["expo", "expo-config-plugin"],
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"expo": "*"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@expo/config-plugins": "*",
|
|
18
|
+
"typescript": "~5.3.0"
|
|
19
|
+
}
|
|
20
|
+
}
|