Skip to content

Commit 63409cc

Browse files
authored
Add New Architecture support for Windows (#932)
1 parent ad233ec commit 63409cc

24 files changed

+2340
-724
lines changed

.vscode/c_cpp_properties.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [
9+
"_DEBUG",
10+
"UNICODE",
11+
"_UNICODE"
12+
],
13+
"windowsSdkVersion": "10.0.22621.0",
14+
"compilerPath": "cl.exe",
15+
"cStandard": "c17",
16+
"cppStandard": "c++17",
17+
"intelliSenseMode": "windows-msvc-x64"
18+
}
19+
],
20+
"version": 4
21+
}

.vscode/settings.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"files.associations": {
3+
"algorithm": "cpp",
4+
"array": "cpp",
5+
"atomic": "cpp",
6+
"bit": "cpp",
7+
"bitset": "cpp",
8+
"cctype": "cpp",
9+
"cfenv": "cpp",
10+
"charconv": "cpp",
11+
"chrono": "cpp",
12+
"cinttypes": "cpp",
13+
"clocale": "cpp",
14+
"cmath": "cpp",
15+
"compare": "cpp",
16+
"concepts": "cpp",
17+
"condition_variable": "cpp",
18+
"coroutine": "cpp",
19+
"csetjmp": "cpp",
20+
"csignal": "cpp",
21+
"cstdarg": "cpp",
22+
"cstddef": "cpp",
23+
"cstdint": "cpp",
24+
"cstdio": "cpp",
25+
"cstdlib": "cpp",
26+
"cstring": "cpp",
27+
"ctime": "cpp",
28+
"cwchar": "cpp",
29+
"deque": "cpp",
30+
"exception": "cpp",
31+
"filesystem": "cpp",
32+
"format": "cpp",
33+
"forward_list": "cpp",
34+
"fstream": "cpp",
35+
"functional": "cpp",
36+
"future": "cpp",
37+
"initializer_list": "cpp",
38+
"iomanip": "cpp",
39+
"ios": "cpp",
40+
"iosfwd": "cpp",
41+
"iostream": "cpp",
42+
"istream": "cpp",
43+
"iterator": "cpp",
44+
"limits": "cpp",
45+
"list": "cpp",
46+
"locale": "cpp",
47+
"map": "cpp",
48+
"memory": "cpp",
49+
"memory_resource": "cpp",
50+
"mutex": "cpp",
51+
"new": "cpp",
52+
"optional": "cpp",
53+
"ostream": "cpp",
54+
"queue": "cpp",
55+
"random": "cpp",
56+
"ranges": "cpp",
57+
"ratio": "cpp",
58+
"regex": "cpp",
59+
"semaphore": "cpp",
60+
"set": "cpp",
61+
"shared_mutex": "cpp",
62+
"source_location": "cpp",
63+
"span": "cpp",
64+
"sstream": "cpp",
65+
"stack": "cpp",
66+
"stdexcept": "cpp",
67+
"stop_token": "cpp",
68+
"streambuf": "cpp",
69+
"string": "cpp",
70+
"system_error": "cpp",
71+
"thread": "cpp",
72+
"tuple": "cpp",
73+
"type_traits": "cpp",
74+
"typeinfo": "cpp",
75+
"unordered_map": "cpp",
76+
"unordered_set": "cpp",
77+
"utility": "cpp",
78+
"variant": "cpp",
79+
"vector": "cpp",
80+
"xfacet": "cpp",
81+
"xhash": "cpp",
82+
"xiosbase": "cpp",
83+
"xlocale": "cpp",
84+
"xlocbuf": "cpp",
85+
"xlocinfo": "cpp",
86+
"xlocmes": "cpp",
87+
"xlocmon": "cpp",
88+
"xlocnum": "cpp",
89+
"xloctime": "cpp",
90+
"xmemory": "cpp",
91+
"xstring": "cpp",
92+
"xtr1common": "cpp",
93+
"xtree": "cpp",
94+
"xutility": "cpp"
95+
}
96+
}

NuGet.config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="react-native" value="https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/nuget/v3/index.json" />
6+
<add key="Nuget.org" value="https://api.nuget.org/v3/index.json" />
7+
</packageSources>
8+
<disabledPackageSources>
9+
<clear />
10+
</disabledPackageSources>
11+
</configuration>

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
"jsSrcsDir": "./src",
5757
"android": {
5858
"javaPackageName": "com.zoontek.rnpermissions"
59+
},
60+
"windows": {
61+
"namespace": "RNPermissionsCodegen",
62+
"outputDirectory": "windows/RNPermissions/codegen",
63+
"separateDataTypes": true
5964
}
6065
},
6166
"peerDependencies": {
@@ -83,6 +88,14 @@
8388
"react": "18.3.1",
8489
"react-native": "0.77.1",
8590
"react-native-builder-bob": "^0.37.0",
91+
"react-native-windows": "0.77.2",
8692
"typescript": "^5.7.3"
93+
},
94+
"react-native-windows": {
95+
"init-windows": {
96+
"name": "RNPermissions",
97+
"namespace": "RNPermissions",
98+
"template": "cpp-lib"
99+
}
87100
}
88101
}

src/methods.windows.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {NativeModules} from 'react-native';
1+
import NativeModule from './NativeRNPermissions';
22
import type {Contract} from './contract';
3-
import type {Permission, PermissionStatus} from './types';
3+
import type {NotificationsResponse, Permission, PermissionStatus} from './types';
44
import {
55
canScheduleExactAlarms,
66
checkLocationAccuracy,
@@ -9,28 +9,23 @@ import {
99
} from './unsupportedMethods';
1010
import {uniq} from './utils';
1111

12-
const NativeModule: {
13-
Check: (permission: Permission) => Promise<PermissionStatus>;
14-
CheckNotifications: () => Promise<PermissionStatus>;
15-
Request: (permission: Permission) => Promise<PermissionStatus>;
16-
OpenSettings: () => Promise<void>;
17-
} = NativeModules.RNPermissions;
18-
1912
const openSettings: Contract['openSettings'] = async () => {
20-
await NativeModule.OpenSettings();
13+
await NativeModule.openSettings("N/A");
2114
};
2215

23-
const check: Contract['check'] = (permission) => {
24-
return NativeModule.Check(permission);
16+
const check: Contract['check'] = async (permission) => {
17+
const response = (await NativeModule.check(permission)) as PermissionStatus;
18+
return response;
2519
};
2620

27-
const request: Contract['request'] = (permission) => {
28-
return NativeModule.Request(permission);
21+
const request: Contract['request'] = async (permission) => {
22+
const response = (await NativeModule.request(permission)) as PermissionStatus;
23+
return response;
2924
};
3025

3126
const checkNotifications: Contract['checkNotifications'] = async () => {
32-
const status = await NativeModule.CheckNotifications();
33-
return {status, settings: {}};
27+
const response = (await NativeModule.checkNotifications()) as NotificationsResponse;
28+
return response;
3429
};
3530

3631
const checkMultiple: Contract['checkMultiple'] = async (permissions) => {

0 commit comments

Comments
 (0)