@react-native-ohos/react-native-default-preference 1.5.0 → 1.6.0-beta.2
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 +37 -4
- package/COMMITTERS.md +8 -7
- package/LICENSE +21 -21
- package/OAT.xml +74 -68
- package/README.OpenSource +10 -10
- package/README.md +248 -13
- package/README_EN.md +241 -0
- package/flow-typed/index.js +23 -23
- package/harmony/react_native_default_preference/BuildProfile.ets +16 -16
- package/harmony/react_native_default_preference/Index.ets +8 -7
- package/harmony/react_native_default_preference/build-profile.json5 +25 -25
- package/harmony/react_native_default_preference/hvigorfile.ts +6 -6
- package/harmony/react_native_default_preference/obfuscation-rules.txt +17 -17
- package/harmony/react_native_default_preference/oh-package.json5 +12 -12
- package/harmony/react_native_default_preference/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/react_native_default_preference/src/main/cpp/DefaultPreferencePackage.h +18 -18
- package/harmony/react_native_default_preference/src/main/cpp/generated/RNOH/generated/BaseReactNativeDefaultPreferencePackage.h +72 -72
- package/harmony/react_native_default_preference/src/main/cpp/generated/RNOH/generated/turbo_modules/DefaultPreferenceNativeModule.cpp +25 -25
- package/harmony/react_native_default_preference/src/main/cpp/generated/RNOH/generated/turbo_modules/DefaultPreferenceNativeModule.h +16 -16
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/ComponentDescriptors.h +24 -24
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/EventEmitters.cpp +16 -16
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/EventEmitters.h +17 -17
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/Props.cpp +19 -19
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/Props.h +18 -18
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/ShadowNodes.cpp +17 -17
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/ShadowNodes.h +23 -23
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/States.cpp +16 -16
- package/harmony/react_native_default_preference/src/main/cpp/generated/react/renderer/components/react_native_default_preference/States.h +18 -18
- package/harmony/react_native_default_preference/src/main/ets/Logger.ts +45 -45
- package/harmony/react_native_default_preference/src/main/ets/{RNDefaultPreferencePackage.ts → RNDefaultPreferencePackage.ets} +28 -27
- package/harmony/react_native_default_preference/src/main/ets/RNDefaultPreferenceTurboModule.ts +184 -144
- package/harmony/react_native_default_preference/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/react_native_default_preference/src/main/ets/generated/index.ets +5 -5
- package/harmony/react_native_default_preference/src/main/ets/generated/ts.ts +6 -6
- package/harmony/react_native_default_preference/src/main/ets/generated/turboModules/DefaultPreferenceNativeModule.ts +32 -32
- package/harmony/react_native_default_preference/src/main/ets/generated/turboModules/ts.ts +5 -5
- package/harmony/react_native_default_preference/src/main/ets/pages/Index.ets +22 -22
- package/harmony/react_native_default_preference/src/main/ets/utils/Calc.ets +8 -8
- package/harmony/react_native_default_preference/src/main/module.json5 +10 -10
- package/harmony/react_native_default_preference/src/main/resources/base/element/string.json +7 -7
- package/harmony/react_native_default_preference/ts.ets +8 -0
- package/harmony/react_native_default_preference/ts.ts +7 -7
- package/harmony/react_native_default_preference.har +0 -0
- package/index.d.ts +19 -19
- package/index.js +12 -12
- package/package.json +52 -35
- package/src/NativeDefaultPreference.ts +21 -21
- package/RNDefaultPreference.podspec +0 -22
package/README_EN.md
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
> Template version: v0.4.2
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<h1 align="center"> <code>react-native-default-preference</code> </h1>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
This project is based on [react-native-default-preference](https://github.com/kevinresol/react-native-default-preference).
|
|
8
|
+
|
|
9
|
+
This third-party library has been migrated to Gitcode and is available on npm as `@react-native-ohos/react-native-default-preference`. Version mapping:
|
|
10
|
+
|
|
11
|
+
| Name | Version (npm) | Release Information | Supported RN Version | Autolink | Compile API Version | Community Baseline Version | Source |
|
|
12
|
+
| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
|
|
13
|
+
| @react-native-ohos/react-native-default-preference | [~ 1.6.0](https://www.npmjs.com/package/@react-native-ohos/react-native-default-preference) | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-default-preference/releases) | 0.82.* / 0.77.* / 0.72.* | partially | API12+ | 1.4.4 | [master](https://gitcode.com/CPF-RN/rntpc_react-native-default-preference/tree/master) |
|
|
14
|
+
| @react-native-oh-tpl/react-native-default-preference | [<= 1.4.4-0.0.1@deprecated](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-default-preference) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-default-preference/releases) | 0.72.* | No | API12+ | 1.4.4 | [sig](https://github.com/react-native-oh-library/react-native-default-preference) |
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Introduction
|
|
18
|
+
|
|
19
|
+
This library exposes a unified React Native API over Android `SharedPreferences`, iOS `UserDefaults`, and HarmonyOS `@ohos.data.preferences`.
|
|
20
|
+
|
|
21
|
+
All values are stored as strings. Use serialization/deserialization (for example JSON) for complex data structures.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
From your project directory:
|
|
26
|
+
|
|
27
|
+
**npm**
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @react-native-ohos/react-native-default-preference
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**yarn**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yarn add @react-native-ohos/react-native-default-preference
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Link
|
|
40
|
+
|
|
41
|
+
| | Autolink | RN Version |
|
|
42
|
+
|--------------------------------------|----------------|-----------|
|
|
43
|
+
| ~ 1.6.0 | partially | 0.82 / 0.77 / 0.72 |
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Projects using Autolink should follow the [Autolinking guide](https://gitcode.com/CPF-RN/ohos_react_native/blob/main/docs/en/02-development/02-development-guide/autolinking.md).
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary>ManualLink: manual native dependency setup</summary>
|
|
50
|
+
|
|
51
|
+
Open the HarmonyOS project directory `harmony` in DevEco Studio.
|
|
52
|
+
|
|
53
|
+
### 1. Overrides RN SDK
|
|
54
|
+
|
|
55
|
+
Add an `overrides` field in the root `oh-package.json5` to pin the RN SDK version used by the project:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"overrides": {
|
|
60
|
+
"@rnoh/react-native-openharmony": "~0.82.1"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Add native dependency
|
|
66
|
+
|
|
67
|
+
Method 1 (recommended): HAR package
|
|
68
|
+
|
|
69
|
+
> [!TIP] The HAR file is under the library `harmony` directory.
|
|
70
|
+
|
|
71
|
+
In `entry/oh-package.json5`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@react-native-ohos/react-native-default-preference": "file:../../node_modules/@react-native-ohos/react-native-default-preference/harmony/react_native_default_preference.har"
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Method 2: link source directly
|
|
80
|
+
|
|
81
|
+
> [!TIP] See [link source code guide](https://gitcode.com/CPF-RN/usage-docs/blob/master/en/link-source-code.md)
|
|
82
|
+
|
|
83
|
+
### 3. Configure CMakeLists and DefaultPreferencePackage
|
|
84
|
+
|
|
85
|
+
Update `entry/src/main/cpp/CMakeLists.txt`:
|
|
86
|
+
|
|
87
|
+
```diff
|
|
88
|
+
+ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
89
|
+
+ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-default-preference/src/main/cpp" ./default_preference)
|
|
90
|
+
+ target_link_libraries(rnoh_app PUBLIC rnoh_default_preference)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Update `entry/src/main/cpp/PackageProvider.cpp`:
|
|
94
|
+
|
|
95
|
+
```diff
|
|
96
|
+
+ #include "DefaultPreferencePackage.h"
|
|
97
|
+
+ std::make_shared<DefaultPreferencePackage>(ctx)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. Register RNDefaultPreferencePackage on ArkTS side
|
|
101
|
+
|
|
102
|
+
In `entry/src/main/ets/RNPackagesFactory.ts`:
|
|
103
|
+
|
|
104
|
+
```diff
|
|
105
|
+
+ import { RNDefaultPreferencePackage } from '@react-native-ohos/react-native-default-preference/ts';
|
|
106
|
+
|
|
107
|
+
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
|
|
108
|
+
return [
|
|
109
|
+
+ new RNDefaultPreferencePackage(ctx)
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
### Running
|
|
117
|
+
|
|
118
|
+
Click `sync` in DevEco Studio, or run:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
cd entry
|
|
122
|
+
ohpm install
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Then build and run the app.
|
|
126
|
+
|
|
127
|
+
## Constraints and Limitations
|
|
128
|
+
|
|
129
|
+
### Compatibility
|
|
130
|
+
|
|
131
|
+
Verified with:
|
|
132
|
+
|
|
133
|
+
1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
134
|
+
2. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
135
|
+
3. RNOH: 0.82.1; SDK: HarmonyOS 6.0.1 Release SDK; IDE: DevEco Studio 6.0.1 Release; ROM: 6.0.0.120 SP7;
|
|
136
|
+
|
|
137
|
+
> [!TIP] All current library versions support version isolation and run on `API12+` ROMs when built with `API12+`.
|
|
138
|
+
|
|
139
|
+
## Usage Example
|
|
140
|
+
|
|
141
|
+
> [!WARNING] Keep the import package name unchanged.
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
import DefaultPreference from 'react-native-default-preference';
|
|
145
|
+
|
|
146
|
+
DefaultPreference.get('my key').then((value) => {
|
|
147
|
+
console.log(value);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
DefaultPreference.set('my key', 'my value').then(() => {
|
|
151
|
+
console.log('done');
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Usage Guide
|
|
156
|
+
|
|
157
|
+
**Preferences file name**
|
|
158
|
+
|
|
159
|
+
- Android default: `packageName_preferences`
|
|
160
|
+
- HarmonyOS default: `bundleName_preferences` (aligned with Android)
|
|
161
|
+
- Use `setName` / `getName` to switch storage instances
|
|
162
|
+
|
|
163
|
+
**Cordova Native Storage compatibility**
|
|
164
|
+
|
|
165
|
+
On Android, use the same SharedPreferences name as cordova-plugin-native-storage:
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
import { Platform } from 'react-native';
|
|
169
|
+
import DefaultPreference from 'react-native-default-preference';
|
|
170
|
+
|
|
171
|
+
if (Platform.OS === 'android') {
|
|
172
|
+
DefaultPreference.setName('NativeStorage');
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Generated bridge code is included under `harmony/react_native_default_preference/src/main/ets/generated` and `src/main/cpp/generated`. Regeneration is usually not required; run from the library root when needed:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm run codegen-lib
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## API Reference
|
|
183
|
+
|
|
184
|
+
> [!TIP] **Platform** indicates supported platforms in the upstream library.
|
|
185
|
+
>
|
|
186
|
+
> [!TIP] **HarmonyOS Support**: `yes` = supported; `no` = not supported; `partially` = partially supported.
|
|
187
|
+
|
|
188
|
+
| Name | Description | Type | Required | Platform | HarmonyOS Support |
|
|
189
|
+
| ------------- | ----------------------------- | -------- | -------- | ------------ | ----------------- |
|
|
190
|
+
| get | Read a key; returns `null` if missing | function | no | Android, iOS | yes |
|
|
191
|
+
| set | Write a key-value pair | function | no | Android, iOS | yes |
|
|
192
|
+
| clear | Remove a key | function | no | Android, iOS | yes |
|
|
193
|
+
| getMultiple | Read multiple keys | function | no | Android, iOS | yes |
|
|
194
|
+
| setMultiple | Write multiple key-value pairs | function | no | Android, iOS | yes |
|
|
195
|
+
| clearMultiple | Remove multiple keys | function | no | Android, iOS | yes |
|
|
196
|
+
| getAll | Read all entries as `{ [key: string]: string }` | function | no | Android, iOS | yes |
|
|
197
|
+
| clearAll | Remove all entries | function | no | Android, iOS | yes |
|
|
198
|
+
| getName | Get current Preferences instance name | function | no | Android, iOS | yes |
|
|
199
|
+
| setName | Set Preferences instance name | function | no | Android, iOS | yes |
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
## Known Issues
|
|
203
|
+
|
|
204
|
+
None
|
|
205
|
+
|
|
206
|
+
## Others
|
|
207
|
+
|
|
208
|
+
None
|
|
209
|
+
|
|
210
|
+
## Directory Structure
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
/rntpc_react-native-default-preference
|
|
214
|
+
├── harmony/ # HarmonyOS adaptation code
|
|
215
|
+
│ ├── react_native_default_preference.har
|
|
216
|
+
│ └── react_native_default_preference/ # HarmonyOS HAR module
|
|
217
|
+
│ ├── Index.ets
|
|
218
|
+
│ ├── ts.ets # ArkTS Package export
|
|
219
|
+
│ └── src/main/
|
|
220
|
+
│ ├── cpp/ # C++ TurboModule bridge
|
|
221
|
+
│ └── ets/ # ArkTS TurboModule implementation
|
|
222
|
+
│ ├── RNDefaultPreferencePackage.ets
|
|
223
|
+
│ └── RNDefaultPreferenceTurboModule.ts
|
|
224
|
+
├── src/
|
|
225
|
+
│ └── NativeDefaultPreference.ts # TurboModule Codegen Spec
|
|
226
|
+
├── example/ # Example and gate-test project
|
|
227
|
+
├── index.js # JS entry
|
|
228
|
+
├── index.d.ts
|
|
229
|
+
├── package.json
|
|
230
|
+
├── README.md
|
|
231
|
+
├── README_EN.md
|
|
232
|
+
└── CHANGELOG.md
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Contributing
|
|
236
|
+
|
|
237
|
+
Report issues via [Issue](https://gitcode.com/CPF-RN/rntpc_react-native-default-preference/issues) or send a [PR](https://gitcode.com/CPF-RN/rntpc_react-native-default-preference/pulls).
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
This project is licensed under [The MIT License (MIT)](https://gitcode.com/CPF-RN/rntpc_react-native-default-preference/blob/master/LICENSE).
|
package/flow-typed/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for index
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.10.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
declare module "react-native-default-preference" {
|
|
8
|
-
declare export interface RNDefaultPreferenceKeys {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
}
|
|
11
|
-
declare export default class RNDefaultPreference {
|
|
12
|
-
static get(key: string): Promise<string | undefined | null>;
|
|
13
|
-
static set(key: string, value: string): Promise<void>;
|
|
14
|
-
static clear(key: string): Promise<void>;
|
|
15
|
-
static getMultiple(keys: string[]): Promise<RNDefaultPreferenceKeys>;
|
|
16
|
-
static setMultiple(data: RNDefaultPreferenceKeys): Promise<void>;
|
|
17
|
-
static clearMultiple(keys: string[]): Promise<void>;
|
|
18
|
-
static getAll(): Promise<RNDefaultPreferenceKeys>;
|
|
19
|
-
static clearAll(): Promise<void>;
|
|
20
|
-
static getName(): Promise<string>;
|
|
21
|
-
static setName(name: string): Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for index
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.10.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare module "react-native-default-preference" {
|
|
8
|
+
declare export interface RNDefaultPreferenceKeys {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
}
|
|
11
|
+
declare export default class RNDefaultPreference {
|
|
12
|
+
static get(key: string): Promise<string | undefined | null>;
|
|
13
|
+
static set(key: string, value: string): Promise<void>;
|
|
14
|
+
static clear(key: string): Promise<void>;
|
|
15
|
+
static getMultiple(keys: string[]): Promise<RNDefaultPreferenceKeys>;
|
|
16
|
+
static setMultiple(data: RNDefaultPreferenceKeys): Promise<void>;
|
|
17
|
+
static clearMultiple(keys: string[]): Promise<void>;
|
|
18
|
+
static getAll(): Promise<RNDefaultPreferenceKeys>;
|
|
19
|
+
static clearAll(): Promise<void>;
|
|
20
|
+
static getName(): Promise<string>;
|
|
21
|
+
static setName(name: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
-
*/
|
|
4
|
-
export const HAR_VERSION = '1.
|
|
5
|
-
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
-
export const DEBUG = true;
|
|
7
|
-
export const TARGET_NAME = 'default';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
-
*/
|
|
12
|
-
export default class BuildProfile {
|
|
13
|
-
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
-
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
-
static readonly DEBUG = DEBUG;
|
|
16
|
-
static readonly TARGET_NAME = TARGET_NAME;
|
|
1
|
+
/**
|
|
2
|
+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
+
*/
|
|
4
|
+
export const HAR_VERSION = '1.6.0-beta.2';
|
|
5
|
+
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
+
export const DEBUG = true;
|
|
7
|
+
export const TARGET_NAME = 'default';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
+
*/
|
|
12
|
+
export default class BuildProfile {
|
|
13
|
+
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
+
static readonly DEBUG = DEBUG;
|
|
16
|
+
static readonly TARGET_NAME = TARGET_NAME;
|
|
17
17
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
-
* Use of this source code is governed by a MIT license that can be
|
|
4
|
-
* found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export * from "./ts"
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export * from "./ts"
|
|
8
|
+
export { RNDefaultPreferencePackage as default } from './src/main/ets/RNDefaultPreferencePackage';
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"apiType": "stageMode",
|
|
3
|
-
/* "buildOption": {
|
|
4
|
-
},
|
|
5
|
-
"buildOptionSet": [
|
|
6
|
-
{
|
|
7
|
-
"name": "release",
|
|
8
|
-
"arkOptions": {
|
|
9
|
-
"obfuscation": {
|
|
10
|
-
"ruleOptions": {
|
|
11
|
-
"enable": true,
|
|
12
|
-
"files": [
|
|
13
|
-
"./obfuscation-rules.txt"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
],*/
|
|
20
|
-
"targets": [
|
|
21
|
-
{
|
|
22
|
-
"name": "default",
|
|
23
|
-
"runtimeOS": "HarmonyOS"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"apiType": "stageMode",
|
|
3
|
+
/* "buildOption": {
|
|
4
|
+
},
|
|
5
|
+
"buildOptionSet": [
|
|
6
|
+
{
|
|
7
|
+
"name": "release",
|
|
8
|
+
"arkOptions": {
|
|
9
|
+
"obfuscation": {
|
|
10
|
+
"ruleOptions": {
|
|
11
|
+
"enable": true,
|
|
12
|
+
"files": [
|
|
13
|
+
"./obfuscation-rules.txt"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],*/
|
|
20
|
+
"targets": [
|
|
21
|
+
{
|
|
22
|
+
"name": "default",
|
|
23
|
+
"runtimeOS": "HarmonyOS"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
-
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
|
6
|
-
}
|
|
1
|
+
import { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
5
|
+
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
|
6
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# Define project specific obfuscation rules here.
|
|
2
|
-
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
-
#
|
|
4
|
-
# For more details, see
|
|
5
|
-
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
|
6
|
-
|
|
7
|
-
# Obfuscation options:
|
|
8
|
-
# -disable-obfuscation: disable all obfuscations
|
|
9
|
-
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
-
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
-
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
-
# -remove-log: remove all console.* statements
|
|
13
|
-
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
-
# -apply-namecache: reuse the given cache file
|
|
15
|
-
|
|
16
|
-
# Keep options:
|
|
17
|
-
# -keep-property-name: specifies property names that you want to keep
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
18
|
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@react-native-ohos/react-native-default-preference",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "Index.ets",
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"@rnoh/react-native-openharmony": 'file:../react_native_openharmony'
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-default-preference",
|
|
3
|
+
"version": "1.6.0-beta.2",
|
|
4
|
+
"description": "use shared preference with react native over a unified interface",
|
|
5
|
+
"main": "Index.ets",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@rnoh/react-native-openharmony": 'file:../react_native_openharmony'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.13)
|
|
2
|
-
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
-
|
|
4
|
-
set(rnoh_default_preference_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
5
|
-
file(GLOB_RECURSE rnoh_default_preference_generated_SRC "${rnoh_default_preference_generated_dir}/**/*.cpp")
|
|
6
|
-
file(GLOB rnoh_default_preference_SRC CONFIGURE_DEPENDS *.cpp)
|
|
7
|
-
add_library(rnoh_default_preference SHARED ${rnoh_default_preference_SRC} ${rnoh_default_preference_generated_SRC})
|
|
8
|
-
target_include_directories(rnoh_default_preference PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_default_preference_generated_dir} ${CMAKE_CURRENT_SOURCE_DIR}/generated/RNOH/generated)
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
+
|
|
4
|
+
set(rnoh_default_preference_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
5
|
+
file(GLOB_RECURSE rnoh_default_preference_generated_SRC "${rnoh_default_preference_generated_dir}/**/*.cpp")
|
|
6
|
+
file(GLOB rnoh_default_preference_SRC CONFIGURE_DEPENDS *.cpp)
|
|
7
|
+
add_library(rnoh_default_preference SHARED ${rnoh_default_preference_SRC} ${rnoh_default_preference_generated_SRC})
|
|
8
|
+
target_include_directories(rnoh_default_preference PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_default_preference_generated_dir} ${CMAKE_CURRENT_SOURCE_DIR}/generated/RNOH/generated)
|
|
9
9
|
target_link_libraries(rnoh_default_preference PUBLIC rnoh)
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
-
// Use of this source code is governed by a MIT license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#ifndef DEFAULTPREFERENCEPACKAGE_H
|
|
6
|
-
#define DEFAULTPREFERENCEPACKAGE_H
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#include "generated/RNOH/generated/BaseReactNativeDefaultPreferencePackage.h"
|
|
10
|
-
#pragma once
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
namespace rnoh {
|
|
14
|
-
class DefaultPreferencePackage : public BaseReactNativeDefaultPreferencePackage {
|
|
15
|
-
using Super = BaseReactNativeDefaultPreferencePackage;
|
|
16
|
-
using Super::Super;
|
|
17
|
-
};
|
|
18
|
-
} // namespace rnoh
|
|
1
|
+
// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
+
// Use of this source code is governed by a MIT license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef DEFAULTPREFERENCEPACKAGE_H
|
|
6
|
+
#define DEFAULTPREFERENCEPACKAGE_H
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#include "generated/RNOH/generated/BaseReactNativeDefaultPreferencePackage.h"
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
namespace rnoh {
|
|
14
|
+
class DefaultPreferencePackage : public BaseReactNativeDefaultPreferencePackage {
|
|
15
|
+
using Super = BaseReactNativeDefaultPreferencePackage;
|
|
16
|
+
using Super::Super;
|
|
17
|
+
};
|
|
18
|
+
} // namespace rnoh
|
|
19
19
|
#endif //DEFAULTPREFERENCEPACKAGE_H
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#pragma once
|
|
6
|
-
|
|
7
|
-
#include "RNOH/Package.h"
|
|
8
|
-
#include "RNOH/ArkTSTurboModule.h"
|
|
9
|
-
#include "RNOH/generated/turbo_modules/DefaultPreferenceNativeModule.h"
|
|
10
|
-
|
|
11
|
-
namespace rnoh {
|
|
12
|
-
|
|
13
|
-
class BaseReactNativeDefaultPreferencePackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
14
|
-
public:
|
|
15
|
-
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
16
|
-
if (name == "DefaultPreferenceNativeModule") {
|
|
17
|
-
return std::make_shared<DefaultPreferenceNativeModule>(ctx, name);
|
|
18
|
-
}
|
|
19
|
-
return nullptr;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
class BaseReactNativeDefaultPreferencePackageEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
24
|
-
public:
|
|
25
|
-
void handleEvent(Context const &ctx) override {
|
|
26
|
-
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
27
|
-
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
28
|
-
|
|
29
|
-
if (eventEmitter == nullptr) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
std::vector<std::string> supportedComponentNames = {
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
std::vector<std::string> supportedEventNames = {
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
40
|
-
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
41
|
-
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class BaseReactNativeDefaultPreferencePackage : public Package {
|
|
48
|
-
public:
|
|
49
|
-
BaseReactNativeDefaultPreferencePackage(Package::Context ctx) : Package(ctx){};
|
|
50
|
-
|
|
51
|
-
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
52
|
-
return std::make_unique<BaseReactNativeDefaultPreferencePackageTurboModuleFactoryDelegate>();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
56
|
-
return {
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
61
|
-
return {
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
66
|
-
return {
|
|
67
|
-
std::make_shared<BaseReactNativeDefaultPreferencePackageEventEmitRequestHandler>(),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
} // namespace rnoh
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "RNOH/Package.h"
|
|
8
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
9
|
+
#include "RNOH/generated/turbo_modules/DefaultPreferenceNativeModule.h"
|
|
10
|
+
|
|
11
|
+
namespace rnoh {
|
|
12
|
+
|
|
13
|
+
class BaseReactNativeDefaultPreferencePackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
14
|
+
public:
|
|
15
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
16
|
+
if (name == "DefaultPreferenceNativeModule") {
|
|
17
|
+
return std::make_shared<DefaultPreferenceNativeModule>(ctx, name);
|
|
18
|
+
}
|
|
19
|
+
return nullptr;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class BaseReactNativeDefaultPreferencePackageEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
24
|
+
public:
|
|
25
|
+
void handleEvent(Context const &ctx) override {
|
|
26
|
+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
27
|
+
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
28
|
+
|
|
29
|
+
if (eventEmitter == nullptr) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
std::vector<std::string> supportedComponentNames = {
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
std::vector<std::string> supportedEventNames = {
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
40
|
+
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
41
|
+
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class BaseReactNativeDefaultPreferencePackage : public Package {
|
|
48
|
+
public:
|
|
49
|
+
BaseReactNativeDefaultPreferencePackage(Package::Context ctx) : Package(ctx){};
|
|
50
|
+
|
|
51
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
52
|
+
return std::make_unique<BaseReactNativeDefaultPreferencePackageTurboModuleFactoryDelegate>();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
56
|
+
return {
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
61
|
+
return {
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
66
|
+
return {
|
|
67
|
+
std::make_shared<BaseReactNativeDefaultPreferencePackageEventEmitRequestHandler>(),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
} // namespace rnoh
|