@react-native-gpui/mmkv 0.0.0-stage → 4.3.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 +7 -0
- package/LICENSE +21 -0
- package/README.md +40 -2
- package/desktop/CMakeLists.txt +146 -0
- package/desktop/cpp/HybridMMKVPlatformContextDesktop.cpp +118 -0
- package/desktop/cpp/HybridMMKVPlatformContextDesktop.hpp +15 -0
- package/desktop/cpp/MMKVCore/MMKV.h +21 -0
- package/desktop/cpp/aes-arm.cpp +3 -0
- package/package.json +30 -4
- package/react-native.config.js +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@react-native-gpui/mmkv` are listed here. Each version's section becomes the notes of its GitHub release.
|
|
4
|
+
|
|
5
|
+
## 4.3.0-alpha.1 - 2026-11-27
|
|
6
|
+
|
|
7
|
+
- First release, for `react-native-mmkv` 4.3.x: the MMKV storage on desktop, with encryption, multiple instances, value-changed listeners and buffers.
|
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,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @react-native-gpui/mmkv
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Adapter for [`react-native-mmkv`](https://github.com/mrousavy/react-native-mmkv) (MIT): fast synchronous key-value storage on the desktop renderer.
|
|
4
|
+
|
|
5
|
+
Part of [react-native-gpui](https://github.com/streetwriters/react-native-gpui), React Native for macOS, Windows and Linux.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Install it next to `react-native-mmkv` and the Nitro adapter it builds on:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install react-native-mmkv@4.3.x react-native-nitro-modules@0.37.x @react-native-gpui/nitro-modules @react-native-gpui/mmkv
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Keep using `react-native-mmkv` as you do on iOS and Android; its JavaScript API is unchanged. Autolinking builds the desktop side when the app is built.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { createMMKV } from 'react-native-mmkv';
|
|
19
|
+
|
|
20
|
+
const storage = createMMKV();
|
|
21
|
+
storage.set('name', 'desktop');
|
|
22
|
+
const user = createMMKV({ id: 'user', encryptionKey: 'secret' });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Storage location
|
|
26
|
+
|
|
27
|
+
Files are kept in the `mmkv` folder of the application data directory (`RN_GPUI_APP_DATA_DIR` when set, otherwise the platform's data folder). App groups are an iOS feature and are not used.
|
|
28
|
+
|
|
29
|
+
## Platforms
|
|
30
|
+
|
|
31
|
+
macOS is tested. The MMKV core and the glue build for Windows and Linux, but are not tested yet.
|
|
32
|
+
|
|
33
|
+
## Not supported
|
|
34
|
+
|
|
35
|
+
`addMemoryWarningListener` has no effect: desktop has no memory warnings.
|
|
36
|
+
|
|
37
|
+
## Licenses
|
|
38
|
+
|
|
39
|
+
MIT. See [LICENSE](LICENSE). `react-native-mmkv` is MIT, copyright Marc Rousavy.
|
|
40
|
+
|
|
41
|
+
The build downloads the MMKV core, Tencent MMKV 2.4.0 (the version react-native-mmkv pins), from GitHub and checks its SHA-256. It is cached in the native dependency cache, so it is downloaded once. The MMKV core is copyright Tencent and licensed under the [BSD 3-Clause License](https://github.com/Tencent/MMKV/blob/v2.4.0/LICENSE.TXT).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
if(NOT RN_GPUI_PROJECT_ROOT)
|
|
2
|
+
message(FATAL_ERROR
|
|
3
|
+
"@react-native-gpui/mmkv was added by the platform; RN_GPUI_PROJECT_ROOT must be set by its build.rs")
|
|
4
|
+
endif()
|
|
5
|
+
find_program(_gpui_node node REQUIRED)
|
|
6
|
+
|
|
7
|
+
function(_gpui_mmkv_resolve out package)
|
|
8
|
+
execute_process(
|
|
9
|
+
COMMAND "${_gpui_node}" -e
|
|
10
|
+
"process.stdout.write(require.resolve(process.argv[2] + '/package.json', {paths: [process.argv[1]]}))"
|
|
11
|
+
"${RN_GPUI_PROJECT_ROOT}" "${package}"
|
|
12
|
+
RESULT_VARIABLE _result
|
|
13
|
+
OUTPUT_VARIABLE _package_json
|
|
14
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
15
|
+
if(NOT _result EQUAL 0 OR NOT EXISTS "${_package_json}")
|
|
16
|
+
message(FATAL_ERROR "${package} could not be resolved from ${RN_GPUI_PROJECT_ROOT}")
|
|
17
|
+
endif()
|
|
18
|
+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_package_json}")
|
|
19
|
+
get_filename_component(_root "${_package_json}" DIRECTORY)
|
|
20
|
+
set(${out} "${_root}" PARENT_SCOPE)
|
|
21
|
+
endfunction()
|
|
22
|
+
|
|
23
|
+
_gpui_mmkv_resolve(_mmkv_root react-native-mmkv)
|
|
24
|
+
_gpui_mmkv_resolve(_nitro_adapter_root @react-native-gpui/nitro-modules)
|
|
25
|
+
|
|
26
|
+
execute_process(
|
|
27
|
+
COMMAND "${_gpui_node}" -e
|
|
28
|
+
"process.stdout.write(require(process.argv[1] + '/package.json').version)"
|
|
29
|
+
"${_mmkv_root}"
|
|
30
|
+
OUTPUT_VARIABLE _mmkv_version
|
|
31
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
32
|
+
if(NOT _mmkv_version MATCHES "^4\\.3\\.")
|
|
33
|
+
message(FATAL_ERROR
|
|
34
|
+
"@react-native-gpui/mmkv supports react-native-mmkv 4.3.x, found ${_mmkv_version}")
|
|
35
|
+
endif()
|
|
36
|
+
|
|
37
|
+
include("${_nitro_adapter_root}/desktop/NitroDesktop.cmake")
|
|
38
|
+
|
|
39
|
+
# Tencent MMKV Core, the version react-native-mmkv pins, downloaded once into
|
|
40
|
+
# the shared native-deps cache. react-native-mmkv includes it as <MMKV/MMKV.h>,
|
|
41
|
+
# so the extracted Core folder is copied to a folder named MMKV. FORCE_POSIX
|
|
42
|
+
# selects the portable implementation on macOS, which keeps Objective-C out of
|
|
43
|
+
# the build.
|
|
44
|
+
set(_mmkv_core_version 2.4.0)
|
|
45
|
+
set(_mmkv_core_sha256 ea31077212e81c930370d2d142e76c5005c63d9f359211f03766b49d89b28ce5)
|
|
46
|
+
if(RN_GPUI_NATIVE_DEPS_CACHE)
|
|
47
|
+
set(_mmkv_cache "${RN_GPUI_NATIVE_DEPS_CACHE}")
|
|
48
|
+
elseif(NOT "$ENV{RN_GPUI_NATIVE_DEPS_CACHE}" STREQUAL "")
|
|
49
|
+
set(_mmkv_cache "$ENV{RN_GPUI_NATIVE_DEPS_CACHE}")
|
|
50
|
+
else()
|
|
51
|
+
set(_mmkv_cache "${CMAKE_BINARY_DIR}/native-deps/cache")
|
|
52
|
+
endif()
|
|
53
|
+
file(TO_CMAKE_PATH "${_mmkv_cache}" _mmkv_cache)
|
|
54
|
+
string(SUBSTRING "${_mmkv_core_sha256}" 0 12 _mmkv_key)
|
|
55
|
+
set(_mmkv_extracted "${_mmkv_cache}/sources/mmkv-${_mmkv_key}")
|
|
56
|
+
set(_mmkv_include "${_mmkv_cache}/sources/mmkv-${_mmkv_key}-include")
|
|
57
|
+
if(NOT EXISTS "${_mmkv_include}/MMKV/MMKV.h")
|
|
58
|
+
set(_mmkv_archive "${_mmkv_cache}/downloads/mmkv-${_mmkv_core_version}.tar.gz")
|
|
59
|
+
if(NOT EXISTS "${_mmkv_archive}")
|
|
60
|
+
message(STATUS "Downloading Tencent MMKV ${_mmkv_core_version}")
|
|
61
|
+
file(DOWNLOAD
|
|
62
|
+
"https://codeload.github.com/Tencent/MMKV/tar.gz/refs/tags/v${_mmkv_core_version}"
|
|
63
|
+
"${_mmkv_archive}.part"
|
|
64
|
+
EXPECTED_HASH SHA256=${_mmkv_core_sha256}
|
|
65
|
+
TLS_VERIFY ON
|
|
66
|
+
STATUS _mmkv_status)
|
|
67
|
+
list(GET _mmkv_status 0 _mmkv_code)
|
|
68
|
+
if(NOT _mmkv_code EQUAL 0)
|
|
69
|
+
file(REMOVE "${_mmkv_archive}.part")
|
|
70
|
+
message(FATAL_ERROR "Downloading Tencent MMKV ${_mmkv_core_version} failed: ${_mmkv_status}")
|
|
71
|
+
endif()
|
|
72
|
+
file(RENAME "${_mmkv_archive}.part" "${_mmkv_archive}")
|
|
73
|
+
endif()
|
|
74
|
+
file(REMOVE_RECURSE "${_mmkv_extracted}.part" "${_mmkv_include}.part")
|
|
75
|
+
file(ARCHIVE_EXTRACT INPUT "${_mmkv_archive}" DESTINATION "${_mmkv_extracted}.part")
|
|
76
|
+
file(MAKE_DIRECTORY "${_mmkv_include}.part")
|
|
77
|
+
file(RENAME "${_mmkv_extracted}.part/MMKV-${_mmkv_core_version}/Core" "${_mmkv_include}.part/MMKV")
|
|
78
|
+
file(REMOVE_RECURSE "${_mmkv_extracted}.part")
|
|
79
|
+
file(REMOVE_RECURSE "${_mmkv_include}")
|
|
80
|
+
file(RENAME "${_mmkv_include}.part" "${_mmkv_include}")
|
|
81
|
+
endif()
|
|
82
|
+
set(_mmkv_core "${_mmkv_include}/MMKV")
|
|
83
|
+
set(_mmkv_core_sources
|
|
84
|
+
${_mmkv_core}/MMKV.cpp
|
|
85
|
+
${_mmkv_core}/MMKV_IO.cpp
|
|
86
|
+
${_mmkv_core}/MMKVLog.cpp
|
|
87
|
+
${_mmkv_core}/CodedInputData.cpp
|
|
88
|
+
${_mmkv_core}/CodedInputDataCrypt.cpp
|
|
89
|
+
${_mmkv_core}/CodedOutputData.cpp
|
|
90
|
+
${_mmkv_core}/KeyValueHolder.cpp
|
|
91
|
+
${_mmkv_core}/PBUtility.cpp
|
|
92
|
+
${_mmkv_core}/MiniPBCoder.cpp
|
|
93
|
+
${_mmkv_core}/MMBuffer.cpp
|
|
94
|
+
${_mmkv_core}/InterProcessLock.cpp
|
|
95
|
+
${_mmkv_core}/MemoryFile.cpp
|
|
96
|
+
${_mmkv_core}/ThreadLock.cpp
|
|
97
|
+
${_mmkv_core}/aes/AESCrypt.cpp
|
|
98
|
+
${_mmkv_core}/aes/openssl/openssl_aes_core.cpp
|
|
99
|
+
${_mmkv_core}/aes/openssl/openssl_cfb128.cpp
|
|
100
|
+
${_mmkv_core}/aes/openssl/openssl_md5_dgst.cpp
|
|
101
|
+
${_mmkv_core}/aes/openssl/openssl_md5_one.cpp
|
|
102
|
+
${_mmkv_core}/crc32/crc32_armv8.cpp
|
|
103
|
+
${_mmkv_core}/crc32/zlib/crc32.cpp)
|
|
104
|
+
if(WIN32)
|
|
105
|
+
list(APPEND _mmkv_core_sources
|
|
106
|
+
${_mmkv_core}/InterProcessLock_Win32.cpp
|
|
107
|
+
${_mmkv_core}/MemoryFile_Win32.cpp
|
|
108
|
+
${_mmkv_core}/ThreadLock_Win32.cpp)
|
|
109
|
+
elseif(NOT APPLE)
|
|
110
|
+
list(APPEND _mmkv_core_sources ${_mmkv_core}/MemoryFile_Linux.cpp)
|
|
111
|
+
endif()
|
|
112
|
+
|
|
113
|
+
# The ARMv8 AES routines are assembly; the preprocessed source is pulled into a
|
|
114
|
+
# C++ file so the app build needs no assembler language.
|
|
115
|
+
if(NOT WIN32 AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64|ARM64")
|
|
116
|
+
set(_mmkv_aes_arm "${CMAKE_CURRENT_BINARY_DIR}/mmkv-aes-arm.s")
|
|
117
|
+
execute_process(
|
|
118
|
+
COMMAND ${CMAKE_CXX_COMPILER} -E -P -x assembler-with-cpp
|
|
119
|
+
-I${_mmkv_core}/aes/openssl
|
|
120
|
+
${_mmkv_core}/aes/openssl/openssl_aesv8-armx.S
|
|
121
|
+
-o ${_mmkv_aes_arm}
|
|
122
|
+
COMMAND_ERROR_IS_FATAL ANY)
|
|
123
|
+
list(APPEND _mmkv_core_sources "${CMAKE_CURRENT_LIST_DIR}/cpp/aes-arm.cpp")
|
|
124
|
+
set_property(GLOBAL APPEND PROPERTY RN_GPUI_APP_CPP_DEFINITIONS
|
|
125
|
+
"MMKV_AES_ARM_ASM=\"${_mmkv_aes_arm}\"")
|
|
126
|
+
endif()
|
|
127
|
+
|
|
128
|
+
file(GLOB _mmkv_sources CONFIGURE_DEPENDS "${_mmkv_root}/cpp/*.cpp")
|
|
129
|
+
file(GLOB _mmkv_desktop_sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/cpp/Hybrid*.cpp")
|
|
130
|
+
|
|
131
|
+
rn_gpui_nitro_library(
|
|
132
|
+
PACKAGE react-native-mmkv
|
|
133
|
+
SOURCES ${_mmkv_sources} ${_mmkv_core_sources} ${_mmkv_desktop_sources}
|
|
134
|
+
INCLUDE_DIRS
|
|
135
|
+
"${_mmkv_root}/cpp"
|
|
136
|
+
"${_mmkv_include}"
|
|
137
|
+
"${CMAKE_CURRENT_LIST_DIR}/cpp"
|
|
138
|
+
HYBRIDS "MMKVPlatformContext=HybridMMKVPlatformContextDesktop")
|
|
139
|
+
|
|
140
|
+
set_property(GLOBAL APPEND PROPERTY RN_GPUI_APP_CPP_DEFINITIONS MMKV_EMBED_ZLIB=1)
|
|
141
|
+
if(APPLE)
|
|
142
|
+
set_property(GLOBAL APPEND PROPERTY RN_GPUI_APP_CPP_DEFINITIONS FORCE_POSIX)
|
|
143
|
+
endif()
|
|
144
|
+
if(WIN32)
|
|
145
|
+
set_property(GLOBAL APPEND PROPERTY RN_GPUI_APP_CPP_DEFINITIONS UNICODE _UNICODE)
|
|
146
|
+
endif()
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#include "HybridMMKVPlatformContextDesktop.hpp"
|
|
2
|
+
|
|
3
|
+
#include <cstdlib>
|
|
4
|
+
#include <filesystem>
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <system_error>
|
|
8
|
+
|
|
9
|
+
#if defined(_WIN32)
|
|
10
|
+
#include <windows.h>
|
|
11
|
+
#elif defined(__APPLE__)
|
|
12
|
+
#include <mach-o/dyld.h>
|
|
13
|
+
#else
|
|
14
|
+
#include <unistd.h>
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::mmkv {
|
|
18
|
+
|
|
19
|
+
namespace {
|
|
20
|
+
|
|
21
|
+
namespace fs = std::filesystem;
|
|
22
|
+
|
|
23
|
+
std::string envValue(const char* name) {
|
|
24
|
+
const char* value = std::getenv(name);
|
|
25
|
+
return value ? value : "";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
std::string sanitize(const std::string& id) {
|
|
29
|
+
std::string out;
|
|
30
|
+
for (char c : id) {
|
|
31
|
+
switch (c) {
|
|
32
|
+
case '/': case '\\': case ':': case '*': case '?': case '"': case '<': case '>': case '|': case '\0':
|
|
33
|
+
out.push_back('-');
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
out.push_back(c);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const auto first = out.find_first_not_of(".-");
|
|
40
|
+
if (first == std::string::npos) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
return out.substr(first, out.find_last_not_of(".-") - first + 1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fs::path executablePath() {
|
|
47
|
+
#if defined(_WIN32)
|
|
48
|
+
wchar_t buffer[MAX_PATH];
|
|
49
|
+
const DWORD length = GetModuleFileNameW(nullptr, buffer, MAX_PATH);
|
|
50
|
+
return length ? fs::path(std::wstring(buffer, length)) : fs::path();
|
|
51
|
+
#elif defined(__APPLE__)
|
|
52
|
+
uint32_t size = 0;
|
|
53
|
+
_NSGetExecutablePath(nullptr, &size);
|
|
54
|
+
std::string buffer(size, '\0');
|
|
55
|
+
if (_NSGetExecutablePath(buffer.data(), &size) != 0) {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
return fs::path(buffer.c_str());
|
|
59
|
+
#else
|
|
60
|
+
std::error_code error;
|
|
61
|
+
return fs::read_symlink("/proc/self/exe", error);
|
|
62
|
+
#endif
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fs::path platformDataDirectory() {
|
|
66
|
+
#if defined(_WIN32)
|
|
67
|
+
const std::string appData = envValue("APPDATA");
|
|
68
|
+
return appData.empty() ? fs::path() : fs::path(appData);
|
|
69
|
+
#elif defined(__APPLE__)
|
|
70
|
+
const std::string home = envValue("HOME");
|
|
71
|
+
return home.empty() ? fs::path() : fs::path(home) / "Library" / "Application Support";
|
|
72
|
+
#else
|
|
73
|
+
const std::string xdg = envValue("XDG_DATA_HOME");
|
|
74
|
+
if (!xdg.empty()) {
|
|
75
|
+
return fs::path(xdg);
|
|
76
|
+
}
|
|
77
|
+
const std::string home = envValue("HOME");
|
|
78
|
+
return home.empty() ? fs::path() : fs::path(home) / ".local" / "share";
|
|
79
|
+
#endif
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Mirrors the application data folder the other desktop modules use.
|
|
83
|
+
fs::path appDataDirectory() {
|
|
84
|
+
std::string id = sanitize(envValue("RN_GPUI_APP_ID"));
|
|
85
|
+
if (id.empty()) {
|
|
86
|
+
id = sanitize(executablePath().stem().string());
|
|
87
|
+
}
|
|
88
|
+
if (id.empty()) {
|
|
89
|
+
id = "rn-gpui-app";
|
|
90
|
+
}
|
|
91
|
+
const std::string root = envValue("RN_GPUI_APP_DATA_DIR");
|
|
92
|
+
if (!root.empty()) {
|
|
93
|
+
return fs::path(root) / id;
|
|
94
|
+
}
|
|
95
|
+
const fs::path base = platformDataDirectory();
|
|
96
|
+
if (base.empty()) {
|
|
97
|
+
return fs::temp_directory_path() / id;
|
|
98
|
+
}
|
|
99
|
+
return base / id;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
} // namespace
|
|
103
|
+
|
|
104
|
+
std::string HybridMMKVPlatformContextDesktop::getBaseDirectory() {
|
|
105
|
+
const fs::path directory = appDataDirectory() / "mmkv";
|
|
106
|
+
std::error_code error;
|
|
107
|
+
fs::create_directories(directory, error);
|
|
108
|
+
if (error) {
|
|
109
|
+
throw std::runtime_error("Could not create the MMKV directory " + directory.string() + ": " + error.message());
|
|
110
|
+
}
|
|
111
|
+
return directory.string();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
std::optional<std::string> HybridMMKVPlatformContextDesktop::getAppGroupDirectory() {
|
|
115
|
+
return std::nullopt;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
} // namespace margelo::nitro::mmkv
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "HybridMMKVPlatformContextSpec.hpp"
|
|
4
|
+
|
|
5
|
+
namespace margelo::nitro::mmkv {
|
|
6
|
+
|
|
7
|
+
class HybridMMKVPlatformContextDesktop final : public HybridMMKVPlatformContextSpec {
|
|
8
|
+
public:
|
|
9
|
+
HybridMMKVPlatformContextDesktop() : HybridObject(TAG) {}
|
|
10
|
+
|
|
11
|
+
std::string getBaseDirectory() override;
|
|
12
|
+
std::optional<std::string> getAppGroupDirectory() override;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
} // namespace margelo::nitro::mmkv
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// react-native-mmkv expects Apple's namespaced MMKV; the portable core used on
|
|
4
|
+
// desktop declares its types globally, so they are aliased into `mmkv`.
|
|
5
|
+
#include <MMKV/MMKV.h>
|
|
6
|
+
|
|
7
|
+
namespace mmkv {
|
|
8
|
+
using MMKV = ::MMKV;
|
|
9
|
+
using MMKVMode = ::MMKVMode;
|
|
10
|
+
using MMKVLogLevel = ::MMKVLogLevel;
|
|
11
|
+
|
|
12
|
+
constexpr auto MMKVLogDebug = ::MMKVLogDebug;
|
|
13
|
+
constexpr auto MMKVLogInfo = ::MMKVLogInfo;
|
|
14
|
+
constexpr auto MMKVLogWarning = ::MMKVLogWarning;
|
|
15
|
+
constexpr auto MMKVLogError = ::MMKVLogError;
|
|
16
|
+
constexpr auto MMKVLogNone = ::MMKVLogNone;
|
|
17
|
+
|
|
18
|
+
constexpr auto MMKV_SINGLE_PROCESS = ::MMKV_SINGLE_PROCESS;
|
|
19
|
+
constexpr auto MMKV_MULTI_PROCESS = ::MMKV_MULTI_PROCESS;
|
|
20
|
+
constexpr auto MMKV_READ_ONLY = ::MMKVMode::MMKV_READ_ONLY;
|
|
21
|
+
} // namespace mmkv
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-gpui/mmkv",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "4.3.0-alpha.1",
|
|
4
|
+
"description": "Adapter for react-native-mmkv (MIT): fast synchronous key-value storage on the desktop renderer",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/streetwriters/react-native-gpui-modules.git",
|
|
9
|
+
"directory": "modules/mmkv"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/streetwriters/react-native-gpui-modules/tree/main/modules/mmkv#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/streetwriters/react-native-gpui-modules/issues"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"desktop",
|
|
17
|
+
"react-native.config.js",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"CHANGELOG.md"
|
|
21
|
+
],
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react-native": "0.87.x",
|
|
24
|
+
"react-native-mmkv": "4.3.x",
|
|
25
|
+
"react-native-nitro-modules": "0.37.x",
|
|
26
|
+
"@react-native-gpui/nitro-modules": "0.37.0-alpha.1"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public",
|
|
30
|
+
"tag": "latest"
|
|
31
|
+
}
|
|
32
|
+
}
|